diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-11-16 08:58:54 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-11-16 08:58:54 +0000 |
commit | e2079cf54ded1eda9e35d215aef6628373368276 (patch) | |
tree | 67257c0c020da0b5e6ff8c33191d47339a9826ea /tools/libclang/CIndexHigh.cpp | |
parent | 9254bf77d28731e70942e2bfe6053b495a634b64 (diff) | |
download | clang-e2079cf54ded1eda9e35d215aef6628373368276.tar.gz clang-e2079cf54ded1eda9e35d215aef6628373368276.tar.bz2 clang-e2079cf54ded1eda9e35d215aef6628373368276.tar.xz |
[libclang] Make clang_findReferencesInFile use "file-targeted" deserialization and avoid
unnecessary deserializations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144791 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang/CIndexHigh.cpp')
-rw-r--r-- | tools/libclang/CIndexHigh.cpp | 39 |
1 files changed, 9 insertions, 30 deletions
diff --git a/tools/libclang/CIndexHigh.cpp b/tools/libclang/CIndexHigh.cpp index b5a05eaafc..0b36af3c95 100644 --- a/tools/libclang/CIndexHigh.cpp +++ b/tools/libclang/CIndexHigh.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "Index_Internal.h" +#include "CursorVisitor.h" #include "CXCursor.h" #include "CXSourceLocation.h" #include "CXTranslationUnit.h" @@ -16,6 +16,7 @@ #include "clang/AST/DeclObjC.h" using namespace clang; +using namespace cxcursor; static void getTopOverriddenMethods(CXTranslationUnit TU, Decl *D, @@ -197,7 +198,6 @@ static void findIdRefsInFile(CXTranslationUnit TU, CXCursor declCursor, CXCursorAndRangeVisitor Visitor) { assert(clang_isDeclaration(declCursor.kind)); ASTUnit *Unit = static_cast<ASTUnit*>(TU->TUData); - ASTContext &Ctx = Unit->getASTContext(); SourceManager &SM = Unit->getSourceManager(); FileID FID = SM.translateFile(File); @@ -211,35 +211,14 @@ static void findIdRefsInFile(CXTranslationUnit TU, CXCursor declCursor, findFileIdRefVisit, &data); return; } - - if (FID == SM.getMainFileID() && !Unit->isMainFileAST()) { - SourceLocation FileLoc = SM.getLocForStartOfFile(FID); - TranslationUnitDecl *TUD = Ctx.getTranslationUnitDecl(); - CXCursor TUCursor = clang_getTranslationUnitCursor(TU); - for (DeclContext::decl_iterator - I = TUD->noload_decls_begin(), E = TUD->noload_decls_end(); - I != E; ++I) { - Decl *D = *I; - - SourceRange R = D->getSourceRange(); - if (R.isInvalid()) - continue; - if (SM.isBeforeInTranslationUnit(R.getEnd(), FileLoc)) - continue; - - if (TagDecl *TD = dyn_cast<TagDecl>(D)) - if (!TD->isFreeStanding()) - continue; - - CXCursor CurCursor = cxcursor::MakeCXCursor(D, TU); - findFileIdRefVisit(CurCursor, TUCursor, &data); - clang_visitChildren(CurCursor, findFileIdRefVisit, &data); - } - return; - } - clang_visitChildren(clang_getTranslationUnitCursor(TU), - findFileIdRefVisit, &data); + SourceRange Range(SM.getLocForStartOfFile(FID), SM.getLocForEndOfFile(FID)); + CursorVisitor FindIdRefsVisitor(TU, + findFileIdRefVisit, &data, + /*VisitPreprocessorLast=*/true, + /*VisitIncludedEntities=*/false, + Range); + FindIdRefsVisitor.visitFileRegion(); } |