aboutsummaryrefslogtreecommitdiff
path: root/tools/libclang/CIndex.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/libclang/CIndex.cpp')
-rw-r--r--tools/libclang/CIndex.cpp20
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);
}
}