aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCraig Silverstein <csilvers2000@yahoo.com>2010-11-19 21:33:15 +0000
committerCraig Silverstein <csilvers2000@yahoo.com>2010-11-19 21:33:15 +0000
commit2aa9267cf193e5eceb9fd24a51b51c031b606fe9 (patch)
treec82fdac0bd4e44ce6510051d02e146ec51bf4f00 /lib
parente4539ef4633fa5c0867e247b5bc88e0f753a2336 (diff)
Several PPCallbacks take an SourceLocation + IdentifierInfo, rather
than a Token that holds the same information all in one easy-to-use package. There's no technical reason to prefer the former -- the information comes from a Token originally -- and it's clumsier to use, so I've changed the code to use tokens everywhere. Approved by clattner git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119845 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Frontend/PrintPreprocessedOutput.cpp17
-rw-r--r--lib/Lex/PPDirectives.cpp9
-rw-r--r--lib/Lex/PreprocessingRecord.cpp9
3 files changed, 16 insertions, 19 deletions
diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp
index 429999cd5e..7494bd3002 100644
--- a/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -147,11 +147,10 @@ public:
void HandleNewlinesInToken(const char *TokStr, unsigned Len);
/// MacroDefined - This hook is called whenever a macro definition is seen.
- void MacroDefined(const IdentifierInfo *II, const MacroInfo *MI);
+ void MacroDefined(const Token &MacroNameTok, const MacroInfo *MI);
/// MacroUndefined - This hook is called whenever a macro #undef is seen.
- void MacroUndefined(SourceLocation Loc, const IdentifierInfo *II,
- const MacroInfo *MI);
+ void MacroUndefined(const Token &MacroNameTok, const MacroInfo *MI);
};
} // end anonymous namespace
@@ -323,7 +322,7 @@ void PrintPPOutputPPCallbacks::Ident(SourceLocation Loc, const std::string &S) {
}
/// MacroDefined - This hook is called whenever a macro definition is seen.
-void PrintPPOutputPPCallbacks::MacroDefined(const IdentifierInfo *II,
+void PrintPPOutputPPCallbacks::MacroDefined(const Token &MacroNameTok,
const MacroInfo *MI) {
// Only print out macro definitions in -dD mode.
if (!DumpDefines ||
@@ -331,18 +330,17 @@ void PrintPPOutputPPCallbacks::MacroDefined(const IdentifierInfo *II,
MI->isBuiltinMacro()) return;
MoveToLine(MI->getDefinitionLoc());
- PrintMacroDefinition(*II, *MI, PP, OS);
+ PrintMacroDefinition(*MacroNameTok.getIdentifierInfo(), *MI, PP, OS);
EmittedMacroOnThisLine = true;
}
-void PrintPPOutputPPCallbacks::MacroUndefined(SourceLocation Loc,
- const IdentifierInfo *II,
+void PrintPPOutputPPCallbacks::MacroUndefined(const Token &MacroNameTok,
const MacroInfo *MI) {
// Only print out macro definitions in -dD mode.
if (!DumpDefines) return;
- MoveToLine(Loc);
- OS << "#undef " << II->getName();
+ MoveToLine(MacroNameTok.getLocation());
+ OS << "#undef " << MacroNameTok.getIdentifierInfo()->getName();
EmittedMacroOnThisLine = true;
}
@@ -616,4 +614,3 @@ void clang::DoPrintPreprocessedInput(Preprocessor &PP, llvm::raw_ostream *OS,
PrintPreprocessedTokens(PP, Tok, Callbacks, *OS);
*OS << '\n';
}
-
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
index 7aa3b31bc7..ee8883b8b2 100644
--- a/lib/Lex/PPDirectives.cpp
+++ b/lib/Lex/PPDirectives.cpp
@@ -1532,7 +1532,7 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok) {
// If the callbacks want to know, tell them about the macro definition.
if (Callbacks)
- Callbacks->MacroDefined(MacroNameTok.getIdentifierInfo(), MI);
+ Callbacks->MacroDefined(MacroNameTok, MI);
}
/// HandleUndefDirective - Implements #undef.
@@ -1561,8 +1561,7 @@ void Preprocessor::HandleUndefDirective(Token &UndefTok) {
// If the callbacks want to know, tell them about the macro #undef.
if (Callbacks)
- Callbacks->MacroUndefined(MacroNameTok.getLocation(),
- MacroNameTok.getIdentifierInfo(), MI);
+ Callbacks->MacroUndefined(MacroNameTok, MI);
// Free macro definition.
ReleaseMacroInfo(MI);
@@ -1633,9 +1632,9 @@ void Preprocessor::HandleIfdefDirective(Token &Result, bool isIfndef,
if (Callbacks) {
if (isIfndef)
- Callbacks->Ifndef(MacroNameTok.getLocation(), MII);
+ Callbacks->Ifndef(MacroNameTok);
else
- Callbacks->Ifdef(MacroNameTok.getLocation(), MII);
+ Callbacks->Ifdef(MacroNameTok);
}
}
diff --git a/lib/Lex/PreprocessingRecord.cpp b/lib/Lex/PreprocessingRecord.cpp
index f6036ef779..3a43ac11e4 100644
--- a/lib/Lex/PreprocessingRecord.cpp
+++ b/lib/Lex/PreprocessingRecord.cpp
@@ -127,17 +127,18 @@ void PreprocessingRecord::MacroExpands(const Token &Id, const MacroInfo* MI) {
Def));
}
-void PreprocessingRecord::MacroDefined(const IdentifierInfo *II,
+void PreprocessingRecord::MacroDefined(const Token &Id,
const MacroInfo *MI) {
SourceRange R(MI->getDefinitionLoc(), MI->getDefinitionEndLoc());
MacroDefinition *Def
- = new (*this) MacroDefinition(II, MI->getDefinitionLoc(), R);
+ = new (*this) MacroDefinition(Id.getIdentifierInfo(),
+ MI->getDefinitionLoc(),
+ R);
MacroDefinitions[MI] = Def;
PreprocessedEntities.push_back(Def);
}
-void PreprocessingRecord::MacroUndefined(SourceLocation Loc,
- const IdentifierInfo *II,
+void PreprocessingRecord::MacroUndefined(const Token &Id,
const MacroInfo *MI) {
llvm::DenseMap<const MacroInfo *, MacroDefinition *>::iterator Pos
= MacroDefinitions.find(MI);