aboutsummaryrefslogtreecommitdiff
path: root/lib/Index/ResolveLocation.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-07-14 03:18:17 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-07-14 03:18:17 +0000
commit2e46aeef8bf51603dfb11e17fdbf9effe91fef01 (patch)
treed909a8f280aefdadd35533a1e527326221c7c9d0 /lib/Index/ResolveLocation.cpp
parent9e6bc0657e3e1b6ec0462620b59d1441195bedc8 (diff)
In ResolveLocationInAST, handle locations that are inside TagDecl definitions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75594 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Index/ResolveLocation.cpp')
-rw-r--r--lib/Index/ResolveLocation.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/Index/ResolveLocation.cpp b/lib/Index/ResolveLocation.cpp
index e93d689c04..edb46c23f4 100644
--- a/lib/Index/ResolveLocation.cpp
+++ b/lib/Index/ResolveLocation.cpp
@@ -89,7 +89,9 @@ public:
DeclLocResolver(ASTContext &ctx, SourceLocation loc)
: LocResolverBase(ctx, loc) {}
+ ASTLocation VisitDeclContext(DeclContext *DC);
ASTLocation VisitTranslationUnitDecl(TranslationUnitDecl *TU);
+ ASTLocation VisitRecordDecl(RecordDecl *D);
ASTLocation VisitVarDecl(VarDecl *D);
ASTLocation VisitFunctionDecl(FunctionDecl *D);
ASTLocation VisitDecl(Decl *D);
@@ -131,9 +133,7 @@ ASTLocation StmtLocResolver::VisitStmt(Stmt *Node) {
return ASTLocation(Parent, Node);
}
-ASTLocation DeclLocResolver::VisitTranslationUnitDecl(TranslationUnitDecl *TU) {
- DeclContext *DC = TU;
-
+ASTLocation DeclLocResolver::VisitDeclContext(DeclContext *DC) {
for (DeclContext::decl_iterator
I = DC->decls_begin(), E = DC->decls_end(); I != E; ++I) {
RangePos RP = CheckRange(*I);
@@ -143,7 +143,20 @@ ASTLocation DeclLocResolver::VisitTranslationUnitDecl(TranslationUnitDecl *TU) {
return Visit(*I);
}
- return ASTLocation();
+ return ASTLocation(cast<Decl>(DC));
+}
+
+ASTLocation DeclLocResolver::VisitTranslationUnitDecl(TranslationUnitDecl *TU) {
+ ASTLocation ASTLoc = VisitDeclContext(TU);
+ if (ASTLoc.getDecl() == TU)
+ return ASTLocation();
+ return ASTLoc;
+}
+
+ASTLocation DeclLocResolver::VisitRecordDecl(RecordDecl *D) {
+ assert(ContainsLocation(D) &&
+ "Should visit only after verifying that loc is in range");
+ return VisitDeclContext(D);
}
ASTLocation DeclLocResolver::VisitFunctionDecl(FunctionDecl *D) {