summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Grasman <kim.grasman@gmail.com>2017-05-01 13:02:22 +0200
committerKim Gräsman <kim.grasman@gmail.com>2017-05-17 19:49:03 +0200
commit13cd94804b140b06e0a58d2f949f13135a29e8d2 (patch)
tree637bfdb60db88bd930b3513da5c6a8c43e891697
parent78d0c15b37750a895219062fedd035cc59074a0e (diff)
Remove second-guessing for DeclRefExprs in CallExprs
In TraverseDeclRefExpr we would exit early if we were under a CallExpr, with the motivation that CallExpr had already handled the relevant cases. However, VisitCallExpr only looks specifically for reference arguments passed to vararg functions, and ignores everything else. Let TraverseDeclRefExpr work on all expressions, so that creating function pointers to templates works in all contexts, including CallExprs. Fixes issue #425.
-rw-r--r--iwyu.cc10
1 files changed, 1 insertions, 9 deletions
diff --git a/iwyu.cc b/iwyu.cc
index 196a574..8650546 100644
--- a/iwyu.cc
+++ b/iwyu.cc
@@ -899,21 +899,13 @@ class BaseAstVisitor : public RecursiveASTVisitor<Derived> {
const_cast<CXXDestructorDecl*>(dtor), parent_type, expr);
}
- // This is to catch assigning template functions to function pointers.
+ // This is to catch function pointers to templates.
// For instance, 'MyFunctionPtr p = &TplFn<MyClass*>;': we need to
// expand TplFn to see if it needs full type info for MyClass.
bool TraverseDeclRefExpr(clang::DeclRefExpr* expr) {
if (!Base::TraverseDeclRefExpr(expr)) return false;
if (CanIgnoreCurrentASTNode()) return true;
- // If it's a normal function call, that was already handled by a
- // CallExpr somewhere. We want only assignments.
- if (current_ast_node()->template ParentIsA<CallExpr>() ||
- (current_ast_node()->template ParentIsA<ImplicitCastExpr>() &&
- current_ast_node()->template AncestorIsA<CallExpr>(2))) {
- return true;
- }
-
if (FunctionDecl* fn_decl = DynCastFrom(expr->getDecl())) {
// If fn_decl has a class-name before it -- 'MyClass::method' --
// it's a method pointer.