diff options
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!"); - } + } } //===----------------------------------------------------------------------===// |