[cfe-commits] r75594 - /cfe/trunk/lib/Index/ResolveLocation.cpp
Argiris Kirtzidis
akyrtzi at gmail.com
Mon Jul 13 20:18:18 PDT 2009
Author: akirtzidis
Date: Mon Jul 13 22:18:17 2009
New Revision: 75594
URL: http://llvm.org/viewvc/llvm-project?rev=75594&view=rev
Log:
In ResolveLocationInAST, handle locations that are inside TagDecl definitions.
Modified:
cfe/trunk/lib/Index/ResolveLocation.cpp
Modified: cfe/trunk/lib/Index/ResolveLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/ResolveLocation.cpp?rev=75594&r1=75593&r2=75594&view=diff
==============================================================================
--- cfe/trunk/lib/Index/ResolveLocation.cpp (original)
+++ cfe/trunk/lib/Index/ResolveLocation.cpp Mon Jul 13 22:18:17 2009
@@ -89,7 +89,9 @@
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 @@
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 @@
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) {
More information about the cfe-commits
mailing list