summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Grasman <kim.grasman@gmail.com>2017-05-01 13:02:22 +0200
committerKim Grasman <kim.grasman@gmail.com>2017-07-16 11:26:21 +0200
commitf6333b78cb12e57c70f91e704d5f335f22ad5200 (patch)
tree109654ee47071ea2fc85efc43954c76ab62da454
parent9926e99d20ee0d5e3103e268d8622ba643276725 (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.