aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/PreprocessingRecord.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-12-04 07:26:53 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-12-04 07:26:53 +0000
commitdf1059cac42d613547d86b4e44c5e364bfc03073 (patch)
tree52406205395d936e24d22eb3c1c6a330c0bf7403 /lib/Lex/PreprocessingRecord.cpp
parent9f9e0d2ecd4b9dd7ceeb57f662f6d8f549adca63 (diff)
In the PreprocessingRecord, to identify the different conditional directive regions
use the SourceLocation at the start of the respective region, instead of a unique integer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169228 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PreprocessingRecord.cpp')
-rw-r--r--lib/Lex/PreprocessingRecord.cpp35
1 files changed, 19 insertions, 16 deletions
diff --git a/lib/Lex/PreprocessingRecord.cpp b/lib/Lex/PreprocessingRecord.cpp
index 01f3665e76..0376e449ae 100644
--- a/lib/Lex/PreprocessingRecord.cpp
+++ b/lib/Lex/PreprocessingRecord.cpp
@@ -41,11 +41,11 @@ InclusionDirective::InclusionDirective(PreprocessingRecord &PPRec,
PreprocessingRecord::PreprocessingRecord(SourceManager &SM,
bool RecordConditionalDirectives)
: SourceMgr(SM),
- RecordCondDirectives(RecordConditionalDirectives), CondDirectiveNextIdx(0),
+ RecordCondDirectives(RecordConditionalDirectives),
ExternalSource(0)
{
if (RecordCondDirectives)
- CondDirectiveStack.push_back(CondDirectiveNextIdx++);
+ CondDirectiveStack.push_back(SourceLocation());
}
/// \brief Returns a pair of [Begin, End) iterators of preprocessed entities
@@ -455,25 +455,24 @@ bool PreprocessingRecord::rangeIntersectsConditionalDirective(
CondDirectiveLocsTy::const_iterator
upp = std::upper_bound(low, CondDirectiveLocs.end(),
Range.getEnd(), CondDirectiveLoc::Comp(SourceMgr));
- unsigned uppIdx;
+ SourceLocation uppRegion;
if (upp != CondDirectiveLocs.end())
- uppIdx = upp->getIdx();
- else
- uppIdx = 0;
+ uppRegion = upp->getRegionLoc();
- return low->getIdx() != uppIdx;
+ return low->getRegionLoc() != uppRegion;
}
-unsigned PreprocessingRecord::findCondDirectiveIdx(SourceLocation Loc) const {
+SourceLocation
+PreprocessingRecord::findCondDirectiveRegionLoc(SourceLocation Loc) const {
if (Loc.isInvalid())
- return 0;
+ return SourceLocation();
CondDirectiveLocsTy::const_iterator
low = std::lower_bound(CondDirectiveLocs.begin(), CondDirectiveLocs.end(),
Loc, CondDirectiveLoc::Comp(SourceMgr));
if (low == CondDirectiveLocs.end())
- return 0;
- return low->getIdx();
+ return SourceLocation();
+ return low->getRegionLoc();
}
void PreprocessingRecord::addCondDirectiveLoc(CondDirectiveLoc DirLoc) {
@@ -490,33 +489,37 @@ void PreprocessingRecord::addCondDirectiveLoc(CondDirectiveLoc DirLoc) {
void PreprocessingRecord::If(SourceLocation Loc, SourceRange ConditionRange) {
if (RecordCondDirectives) {
addCondDirectiveLoc(CondDirectiveLoc(Loc, CondDirectiveStack.back()));
- CondDirectiveStack.push_back(CondDirectiveNextIdx++);
+ CondDirectiveStack.push_back(Loc);
}
}
void PreprocessingRecord::Ifdef(SourceLocation Loc, const Token &MacroNameTok) {
if (RecordCondDirectives) {
addCondDirectiveLoc(CondDirectiveLoc(Loc, CondDirectiveStack.back()));
- CondDirectiveStack.push_back(CondDirectiveNextIdx++);
+ CondDirectiveStack.push_back(Loc);
}
}
void PreprocessingRecord::Ifndef(SourceLocation Loc,const Token &MacroNameTok) {
if (RecordCondDirectives) {
addCondDirectiveLoc(CondDirectiveLoc(Loc, CondDirectiveStack.back()));
- CondDirectiveStack.push_back(CondDirectiveNextIdx++);
+ CondDirectiveStack.push_back(Loc);
}
}
void PreprocessingRecord::Elif(SourceLocation Loc, SourceRange ConditionRange,
SourceLocation IfLoc) {
- if (RecordCondDirectives)
+ if (RecordCondDirectives) {
addCondDirectiveLoc(CondDirectiveLoc(Loc, CondDirectiveStack.back()));
+ CondDirectiveStack.back() = Loc;
+ }
}
void PreprocessingRecord::Else(SourceLocation Loc, SourceLocation IfLoc) {
- if (RecordCondDirectives)
+ if (RecordCondDirectives) {
addCondDirectiveLoc(CondDirectiveLoc(Loc, CondDirectiveStack.back()));
+ CondDirectiveStack.back() = Loc;
+ }
}
void PreprocessingRecord::Endif(SourceLocation Loc, SourceLocation IfLoc) {