summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-06-18 07:44:41 +0000
committerChris Lattner <sabre@nondot.org>2006-06-18 07:44:41 +0000
commit7e0dd2b11fa0fcb15cfec7982ade636f6415a916 (patch)
tree60a8077f8f704a395240b7f0f402be1688359006 /clang
parent33ce7283ee667d76a714ea4419857b1ece10a4e8 (diff)
downloadbcm5719-llvm-7e0dd2b11fa0fcb15cfec7982ade636f6415a916.tar.gz
bcm5719-llvm-7e0dd2b11fa0fcb15cfec7982ade636f6415a916.zip
Fix a fixme by passing language options into LexerToken::dump, instead of
relying on TheLexer. llvm-svn: 38549
Diffstat (limited to 'clang')
-rw-r--r--clang/Driver/clang.cpp2
-rw-r--r--clang/Lex/Lexer.cpp16
-rw-r--r--clang/Lex/MacroInfo.cpp4
-rw-r--r--clang/include/clang/Lex/Lexer.h4
-rw-r--r--clang/include/clang/Lex/MacroInfo.h2
5 files changed, 9 insertions, 19 deletions
diff --git a/clang/Driver/clang.cpp b/clang/Driver/clang.cpp
index 41d5adac528..4c341213506 100644
--- a/clang/Driver/clang.cpp
+++ b/clang/Driver/clang.cpp
@@ -751,7 +751,7 @@ int main(int argc, char **argv) {
LexerToken Tok;
do {
PP.Lex(Tok);
- Tok.dump(true);
+ Tok.dump(Options, true);
std::cerr << "\n";
} while (Tok.getKind() != tok::eof);
break;
diff --git a/clang/Lex/Lexer.cpp b/clang/Lex/Lexer.cpp
index fac724529fc..eaf5ff099fb 100644
--- a/clang/Lex/Lexer.cpp
+++ b/clang/Lex/Lexer.cpp
@@ -75,20 +75,12 @@ SourceLocation LexerToken::getSourceLocation() const {
/// dump - Print the token to stderr, used for debugging.
///
-void LexerToken::dump(bool DumpFlags) const {
+void LexerToken::dump(const LangOptions &Features, bool DumpFlags) const {
std::cerr << clang::tok::getTokenName(Kind) << " '";
- if (needsCleaning()) {
- if (getLexer())
- std::cerr << getLexer()->getSpelling(*this);
- else {
- // FIXME: expansion from macros clears location info. Testcase:
- // #define TWELVE 1\ <whitespace only>
- // 2
- // TWELVE
- std::cerr << "*unspelled*" << std::string(getStart(), getEnd());
- }
- } else
+ if (needsCleaning())
+ std::cerr << Lexer::getSpelling(*this, Features);
+ else
std::cerr << std::string(getStart(), getEnd());
std::cerr << "'";
diff --git a/clang/Lex/MacroInfo.cpp b/clang/Lex/MacroInfo.cpp
index cd5895ab932..267325bf8f3 100644
--- a/clang/Lex/MacroInfo.cpp
+++ b/clang/Lex/MacroInfo.cpp
@@ -18,10 +18,10 @@ using namespace clang;
/// dump - Print the macro to stderr, used for debugging.
///
-void MacroInfo::dump() const {
+void MacroInfo::dump(const LangOptions &Features) const {
std::cerr << "MACRO: ";
for (unsigned i = 0, e = ReplacementTokens.size(); i != e; ++i) {
- ReplacementTokens[i].dump();
+ ReplacementTokens[i].dump(Features);
std::cerr << " ";
}
std::cerr << "\n";
diff --git a/clang/include/clang/Lex/Lexer.h b/clang/include/clang/Lex/Lexer.h
index 894f56c6eb6..e2493abb144 100644
--- a/clang/include/clang/Lex/Lexer.h
+++ b/clang/include/clang/Lex/Lexer.h
@@ -93,8 +93,6 @@ public:
/// start of the token having already been set.
void SetEnd(const char *End) { Length = End-Start; }
- const Lexer *getLexer() const { return TheLexer; }
-
/// ClearFlags - Reset all flags to cleared.
///
void StartToken(const Lexer *L) {
@@ -150,7 +148,7 @@ public:
/// dump - Print the token to stderr, used for debugging.
///
- void dump(bool DumpFlags = false) const;
+ void dump(const LangOptions &Features, bool DumpFlags = false) const;
};
/// PPConditionalInfo - Information about the conditional stack (#if directives)
diff --git a/clang/include/clang/Lex/MacroInfo.h b/clang/include/clang/Lex/MacroInfo.h
index 92195c38db4..23152fd4b69 100644
--- a/clang/include/clang/Lex/MacroInfo.h
+++ b/clang/include/clang/Lex/MacroInfo.h
@@ -94,7 +94,7 @@ public:
/// dump - Print the macro to stderr, used for debugging.
///
- void dump() const;
+ void dump(const LangOptions &Features) const;
// Todo:
// bool isDefinedInSystemHeader() { Look this up based on Location }
OpenPOWER on IntegriCloud