diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-11-30 06:16:57 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-11-30 06:16:57 +0000 |
commit | 89d9980bbc2e4a4ac86673e6ec16fb9f5babb63b (patch) | |
tree | b60c5afbdb4f5fd6f12cf38e98ebb6c2746cc163 /tools/libclang/CIndex.cpp | |
parent | bdc4b366e80c125184a3b3c56fa4619cb4ac9e45 (diff) |
When using a precompiled preamble with detailed preprocessing records,
trap the serialized preprocessing records (macro definitions, macro
instantiations, macro definitions) from the generation of the
precompiled preamble, then replay those when walking the list of
preprocessed entities. This eliminates a bug where clang_getCursor()
wasn't able to find preprocessed-entity cursors in the preamble.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120396 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang/CIndex.cpp')
-rw-r--r-- | tools/libclang/CIndex.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 7fc2f6ebb4..cdd7764016 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -410,10 +410,18 @@ CursorVisitor::getPreprocessedEntities() { bool OnlyLocalDecls = !AU->isMainFileAST() && AU->getOnlyLocalDecls(); + PreprocessingRecord::iterator StartEntity, EndEntity; + if (OnlyLocalDecls) { + StartEntity = AU->pp_entity_begin(); + EndEntity = AU->pp_entity_end(); + } else { + StartEntity = PPRec.begin(); + EndEntity = PPRec.end(); + } + // There is no region of interest; we have to walk everything. if (RegionOfInterest.isInvalid()) - return std::make_pair(PPRec.begin(OnlyLocalDecls), - PPRec.end(OnlyLocalDecls)); + return std::make_pair(StartEntity, EndEntity); // Find the file in which the region of interest lands. SourceManager &SM = AU->getSourceManager(); @@ -424,18 +432,16 @@ CursorVisitor::getPreprocessedEntities() { // The region of interest spans files; we have to walk everything. if (Begin.first != End.first) - return std::make_pair(PPRec.begin(OnlyLocalDecls), - PPRec.end(OnlyLocalDecls)); + return std::make_pair(StartEntity, EndEntity); ASTUnit::PreprocessedEntitiesByFileMap &ByFileMap = AU->getPreprocessedEntitiesByFile(); if (ByFileMap.empty()) { // Build the mapping from files to sets of preprocessed entities. - for (PreprocessingRecord::iterator E = PPRec.begin(OnlyLocalDecls), - EEnd = PPRec.end(OnlyLocalDecls); - E != EEnd; ++E) { + for (PreprocessingRecord::iterator E = StartEntity; E != EndEntity; ++E) { std::pair<FileID, unsigned> P = SM.getDecomposedInstantiationLoc((*E)->getSourceRange().getBegin()); + ByFileMap[P.first].push_back(*E); } } |