r186547 - Add condition expression result to if and elif callbacks.
John Thompson
John.Thompson.JTSoftware at gmail.com
Wed Jul 17 17:00:36 PDT 2013
Author: jtsoftware
Date: Wed Jul 17 19:00:36 2013
New Revision: 186547
URL: http://llvm.org/viewvc/llvm-project?rev=186547&view=rev
Log:
Add condition expression result to if and elif callbacks.
Modified:
cfe/trunk/include/clang/Lex/PPCallbacks.h
cfe/trunk/include/clang/Lex/PPConditionalDirectiveRecord.h
cfe/trunk/lib/Lex/PPConditionalDirectiveRecord.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=186547&r1=186546&r2=186547&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/PPCallbacks.h (original)
+++ cfe/trunk/include/clang/Lex/PPCallbacks.h Wed Jul 17 19:00:36 2013
@@ -243,18 +243,21 @@ public:
/// \brief Hook called whenever an \#if is seen.
/// \param Loc the source location of the directive.
/// \param ConditionRange The SourceRange of the expression being tested.
+ /// \param ConditionValue The evaluated value of the condition.
///
// FIXME: better to pass in a list (or tree!) of Tokens.
- virtual void If(SourceLocation Loc, SourceRange ConditionRange) {
+ virtual void If(SourceLocation Loc, SourceRange ConditionRange,
+ bool ConditionValue) {
}
/// \brief Hook called whenever an \#elif is seen.
/// \param Loc the source location of the directive.
/// \param ConditionRange The SourceRange of the expression being tested.
+ /// \param ConditionValue The evaluated value of the condition.
/// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive.
// FIXME: better to pass in a list (or tree!) of Tokens.
virtual void Elif(SourceLocation Loc, SourceRange ConditionRange,
- SourceLocation IfLoc) {
+ bool ConditionValue, SourceLocation IfLoc) {
}
/// \brief Hook called whenever an \#ifdef is seen.
@@ -418,16 +421,17 @@ public:
}
/// \brief Hook called whenever an \#if is seen.
- virtual void If(SourceLocation Loc, SourceRange ConditionRange) {
- First->If(Loc, ConditionRange);
- Second->If(Loc, ConditionRange);
+ virtual void If(SourceLocation Loc, SourceRange ConditionRange,
+ bool ConditionValue) {
+ First->If(Loc, ConditionRange, ConditionValue);
+ Second->If(Loc, ConditionRange, ConditionValue);
}
- /// \brief Hook called whenever an \#if is seen.
+ /// \brief Hook called whenever an \#elif is seen.
virtual void Elif(SourceLocation Loc, SourceRange ConditionRange,
- SourceLocation IfLoc) {
- First->Elif(Loc, ConditionRange, IfLoc);
- Second->Elif(Loc, ConditionRange, IfLoc);
+ bool ConditionValue, SourceLocation IfLoc) {
+ First->Elif(Loc, ConditionRange, ConditionValue, IfLoc);
+ Second->Elif(Loc, ConditionRange, ConditionValue, IfLoc);
}
/// \brief Hook called whenever an \#ifdef is seen.
Modified: cfe/trunk/include/clang/Lex/PPConditionalDirectiveRecord.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPConditionalDirectiveRecord.h?rev=186547&r1=186546&r2=186547&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/PPConditionalDirectiveRecord.h (original)
+++ cfe/trunk/include/clang/Lex/PPConditionalDirectiveRecord.h Wed Jul 17 19:00:36 2013
@@ -86,9 +86,10 @@ public:
SourceLocation findConditionalDirectiveRegionLoc(SourceLocation Loc) const;
private:
- virtual void If(SourceLocation Loc, SourceRange ConditionRange);
+ virtual void If(SourceLocation Loc, SourceRange ConditionRange,
+ bool ConditionValue);
virtual void Elif(SourceLocation Loc, SourceRange ConditionRange,
- SourceLocation IfLoc);
+ bool ConditionValue, SourceLocation IfLoc);
virtual void Ifdef(SourceLocation Loc, const Token &MacroNameTok,
const MacroDirective *MD);
virtual void Ifndef(SourceLocation Loc, const Token &MacroNameTok,
Modified: cfe/trunk/lib/Lex/PPConditionalDirectiveRecord.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPConditionalDirectiveRecord.cpp?rev=186547&r1=186546&r2=186547&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPConditionalDirectiveRecord.cpp (original)
+++ cfe/trunk/lib/Lex/PPConditionalDirectiveRecord.cpp Wed Jul 17 19:00:36 2013
@@ -76,7 +76,8 @@ void PPConditionalDirectiveRecord::addCo
}
void PPConditionalDirectiveRecord::If(SourceLocation Loc,
- SourceRange ConditionRange) {
+ SourceRange ConditionRange,
+ bool ConditionValue) {
addCondDirectiveLoc(CondDirectiveLoc(Loc, CondDirectiveStack.back()));
CondDirectiveStack.push_back(Loc);
}
@@ -97,6 +98,7 @@ void PPConditionalDirectiveRecord::Ifnde
void PPConditionalDirectiveRecord::Elif(SourceLocation Loc,
SourceRange ConditionRange,
+ bool ConditionValue,
SourceLocation IfLoc) {
addCondDirectiveLoc(CondDirectiveLoc(Loc, CondDirectiveStack.back()));
CondDirectiveStack.back() = Loc;
Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=186547&r1=186546&r2=186547&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Wed Jul 17 19:00:36 2013
@@ -430,7 +430,7 @@ void Preprocessor::SkipExcludedCondition
if (Callbacks)
Callbacks->Elif(Tok.getLocation(),
SourceRange(ConditionalBegin, ConditionalEnd),
- CondInfo.IfLoc);
+ ShouldEnter, CondInfo.IfLoc);
break;
}
}
@@ -2181,7 +2181,8 @@ void Preprocessor::HandleIfDirective(Tok
if (Callbacks)
Callbacks->If(IfToken.getLocation(),
- SourceRange(ConditionalBegin, ConditionalEnd));
+ SourceRange(ConditionalBegin, ConditionalEnd),
+ ConditionalTrue);
// Should we include the stuff contained by this directive?
if (ConditionalTrue) {
@@ -2277,7 +2278,8 @@ void Preprocessor::HandleElifDirective(T
if (Callbacks)
Callbacks->Elif(ElifToken.getLocation(),
- SourceRange(ConditionalBegin, ConditionalEnd), CI.IfLoc);
+ SourceRange(ConditionalBegin, ConditionalEnd),
+ true, CI.IfLoc);
// Finally, skip the rest of the contents of this block.
SkipExcludedConditionalBlock(CI.IfLoc, /*Foundnonskip*/true,
More information about the cfe-commits
mailing list