diff options
author | Chris Lattner <sabre@nondot.org> | 2007-12-09 20:31:55 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-12-09 20:31:55 +0000 |
commit | c3d8d57b010e2ed15a2a7685d5761db14f5d2252 (patch) | |
tree | 05a43de504096eb5c88516659bda8a62c082a563 /Lex/Preprocessor.cpp | |
parent | 65b3c2759fa66fa46414410feb1520cd6d72a93b (diff) |
Add dumping support for locations, make -dumptokens print out the location
info of each token.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44741 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Lex/Preprocessor.cpp')
-rw-r--r-- | Lex/Preprocessor.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/Lex/Preprocessor.cpp b/Lex/Preprocessor.cpp index a685b0b27b..d2630584a5 100644 --- a/Lex/Preprocessor.cpp +++ b/Lex/Preprocessor.cpp @@ -133,6 +133,7 @@ void Preprocessor::DumpToken(const Token &Tok, bool DumpFlags) const { << getSpelling(Tok) << "'"; if (!DumpFlags) return; + std::cerr << "\t"; if (Tok.isAtStartOfLine()) std::cerr << " [StartOfLine]"; @@ -145,6 +146,24 @@ void Preprocessor::DumpToken(const Token &Tok, bool DumpFlags) const { std::cerr << " [UnClean='" << std::string(Start, Start+Tok.getLength()) << "']"; } + + std::cerr << "\tLoc=<"; + DumpLocation(Tok.getLocation()); + std::cerr << ">"; +} + +void Preprocessor::DumpLocation(SourceLocation Loc) const { + SourceLocation LogLoc = SourceMgr.getLogicalLoc(Loc); + std::cerr << SourceMgr.getSourceName(LogLoc) << ':' + << SourceMgr.getLineNumber(LogLoc) << ':' + << SourceMgr.getLineNumber(LogLoc); + + SourceLocation PhysLoc = SourceMgr.getPhysicalLoc(Loc); + if (PhysLoc != LogLoc) { + std::cerr << " <PhysLoc="; + DumpLocation(PhysLoc); + std::cerr << ">"; + } } void Preprocessor::DumpMacro(const MacroInfo &MI) const { @@ -1140,7 +1159,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { Tok.setLocation(CreateString(TmpBuffer, Len, Tok.getLocation())); } else { assert(0 && "Unknown identifier!"); - } + } } //===----------------------------------------------------------------------===// |