diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-31 19:02:11 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-31 19:02:11 +0000 |
commit | 8c4dc1ffd20a8fe90a90c7f471cd9842b981078e (patch) | |
tree | 7b3aa15d348059697f93d37b0158a9b7d8fa4aaf /lib/Index/ResolveLocation.cpp | |
parent | 211c278e536b9f5bf468a99dc24449ad734466fe (diff) |
For a CXXOperatorCallExpr, fix the order that StmtLocResolver uses to check subexpressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77713 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Index/ResolveLocation.cpp')
-rw-r--r-- | lib/Index/ResolveLocation.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/Index/ResolveLocation.cpp b/lib/Index/ResolveLocation.cpp index ba8134fb88..ce8512ddf3 100644 --- a/lib/Index/ResolveLocation.cpp +++ b/lib/Index/ResolveLocation.cpp @@ -78,6 +78,7 @@ public: StmtLocResolver(ASTContext &ctx, SourceLocation loc, Decl *parent) : LocResolverBase(ctx, loc), Parent(parent) {} + ASTLocation VisitCXXOperatorCallExpr(CXXOperatorCallExpr *Node); ASTLocation VisitDeclStmt(DeclStmt *Node); ASTLocation VisitStmt(Stmt *Node); }; @@ -101,6 +102,35 @@ public: } // anonymous namespace +ASTLocation +StmtLocResolver::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *Node) { + assert(ContainsLocation(Node) && + "Should visit only after verifying that loc is in range"); + + if (Node->getNumArgs() == 1) + // Unary operator. Let normal child traversal handle it. + return VisitCallExpr(Node); + + assert(Node->getNumArgs() == 2 && + "Wrong args for the C++ operator call expr ?"); + + llvm::SmallVector<Expr *, 3> Nodes; + // Binary operator. Check in order of 1-left arg, 2-callee, 3-right arg. + Nodes.push_back(Node->getArg(0)); + Nodes.push_back(Node->getCallee()); + Nodes.push_back(Node->getArg(1)); + + for (unsigned i = 0, e = Nodes.size(); i != e; ++i) { + RangePos RP = CheckRange(Nodes[i]); + if (RP == AfterLoc) + break; + if (RP == ContainsLoc) + return Visit(Nodes[i]); + } + + return ASTLocation(Parent, Node); +} + ASTLocation StmtLocResolver::VisitDeclStmt(DeclStmt *Node) { assert(ContainsLocation(Node) && "Should visit only after verifying that loc is in range"); @@ -125,6 +155,9 @@ ASTLocation StmtLocResolver::VisitStmt(Stmt *Node) { // Search the child statements. for (Stmt::child_iterator I = Node->child_begin(), E = Node->child_end(); I != E; ++I) { + if (*I == NULL) + continue; + RangePos RP = CheckRange(*I); if (RP == AfterLoc) break; |