<< getSpelling(Tok) << "'";
if (!DumpFlags) return;
+
std::cerr << "\t";
if (Tok.isAtStartOfLine())
std::cerr << " [StartOfLine]";
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 {
Tok.setLocation(CreateString(TmpBuffer, Len, Tok.getLocation()));
} else {
assert(0 && "Unknown identifier!");
- }
+ }
}
//===----------------------------------------------------------------------===//
/// DumpToken - Print the token to stderr, used for debugging.
///
void DumpToken(const Token &Tok, bool DumpFlags = false) const;
+ void DumpLocation(SourceLocation Loc) const;
void DumpMacro(const MacroInfo &MI) const;
/// AdvanceToTokenCharacter - Given a location that specifies the start of a