https://llvm.org/bugs/show_bug.cgi?id=24748
Bug ID: 24748 Summary: clang_getInclusions is returning no includes after the preamble is compiled Product: clang Version: trunk Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: libclang Assignee: unassignedclangb...@nondot.org Reporter: cl...@bubke.de CC: kli...@google.com, llvm-bugs@lists.llvm.org Classification: Unclassified 1. clang_parseTranslationUnit2 (CXTranslationUnit_CacheCompletionResults | CXTranslationUnit_PrecompiledPreamble | CXTranslationUnit_IncludeBriefCommentsInCodeCompletion) 2. clang_getInclusions -> get expected include list 3. clang_reparseTranslationUnit 4. clang_getInclusions -> get no includes anymore After playing around in the clang source the following patch is fixing it. It looks like there are more than the expected one entry but all except one are invalid. Index: tools/libclang/CIndexInclusionStack.cpp =================================================================== --- tools/libclang/CIndexInclusionStack.cpp (revision 246452) +++ tools/libclang/CIndexInclusionStack.cpp (working copy) @@ -35,12 +35,28 @@ SmallVector<CXSourceLocation, 10> InclusionStack; unsigned n = SM.local_sloc_entry_size(); + unsigned n2 = 0; + const SrcMgr::SLocEntry &(SourceManager::*Getter)(unsigned, bool*) const; + Getter = &SourceManager::getLocalSLocEntry; + + for (unsigned i = 0 ; i < n ; ++i) { + bool Invalid = false; + const SrcMgr::SLocEntry &SL = (SM.*Getter)(i, &Invalid); + + if (!SL.isFile() || Invalid) + continue; + + const SrcMgr::FileInfo &FI = SL.getFile(); + if (!FI.getContentCache()->OrigEntry) + continue; + + ++n2; + } // In the case where all the SLocEntries are in an external source, traverse // those SLocEntries as well. This is the case where we are looking // at the inclusion stack of an AST/PCH file. - const SrcMgr::SLocEntry &(SourceManager::*Getter)(unsigned, bool*) const; - if (n == 1) { + if (n2 == 1) { Getter = &SourceManager::getLoadedSLocEntry; n = SM.loaded_sloc_entry_size(); } else -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs