[cfe-commits] r62339 - in /cfe/trunk: Driver/PrintPreprocessedOutput.cpp test/Preprocessor/pragma_microsoft.c
Chris Lattner
sabre at nondot.org
Fri Jan 16 11:25:54 PST 2009
Author: lattner
Date: Fri Jan 16 13:25:54 2009
New Revision: 62339
URL: http://llvm.org/viewvc/llvm-project?rev=62339&view=rev
Log:
Make -E mode propagate #pragma comment's into the output.
Modified:
cfe/trunk/Driver/PrintPreprocessedOutput.cpp
cfe/trunk/test/Preprocessor/pragma_microsoft.c
Modified: cfe/trunk/Driver/PrintPreprocessedOutput.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/PrintPreprocessedOutput.cpp?rev=62339&r1=62338&r2=62339&view=diff
==============================================================================
--- cfe/trunk/Driver/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/Driver/PrintPreprocessedOutput.cpp Fri Jan 16 13:25:54 2009
@@ -67,7 +67,9 @@
virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType);
virtual void Ident(SourceLocation Loc, const std::string &str);
-
+ virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
+ const std::string &Str);
+
bool HandleFirstTokOnLine(Token &Tok);
bool MoveToLine(SourceLocation Loc);
@@ -186,7 +188,7 @@
}
}
-/// HandleIdent - Handle #ident directives when read by the preprocessor.
+/// Ident - Handle #ident directives when read by the preprocessor.
///
void PrintPPOutputPPCallbacks::Ident(SourceLocation Loc, const std::string &S) {
MoveToLine(Loc);
@@ -196,6 +198,33 @@
EmittedTokensOnThisLine = true;
}
+void PrintPPOutputPPCallbacks::PragmaComment(SourceLocation Loc,
+ const IdentifierInfo *Kind,
+ const std::string &Str) {
+ MoveToLine(Loc);
+ OS << "#pragma comment(" << Kind->getName();
+
+ if (!Str.empty()) {
+ OS << ", \"";
+
+ for (unsigned i = 0, e = Str.size(); i != e; ++i) {
+ unsigned char Char = Str[i];
+ if (isprint(Char) && Char != '\\')
+ OS << (char)Char;
+ else // Output anything hard as an octal escape.
+ OS << '\\'
+ << (char)('0'+ ((Char >> 6) & 7))
+ << (char)('0'+ ((Char >> 3) & 7))
+ << (char)('0'+ ((Char >> 0) & 7));
+ }
+ OS << '"';
+ }
+
+ OS << ')';
+ EmittedTokensOnThisLine = true;
+}
+
+
/// HandleFirstTokOnLine - When emitting a preprocessed file in -E mode, this
/// is called for the first token on each new line. If this really is the start
/// of a new logical line, handle it and return true, otherwise return false.
Modified: cfe/trunk/test/Preprocessor/pragma_microsoft.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/pragma_microsoft.c?rev=62339&r1=62338&r2=62339&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/pragma_microsoft.c (original)
+++ cfe/trunk/test/Preprocessor/pragma_microsoft.c Fri Jan 16 13:25:54 2009
@@ -13,6 +13,8 @@
#pragma comment(foo) // expected-error {{unknown kind of pragma comment}}
#pragma comment(compiler,) // expected-error {{pragma comment requires}}
#define foo compiler
-#pragma comment(foo) // macro expand kind?
+#pragma comment(foo) // macro expand kind.
#pragma comment(foo) x // expected-error {{pragma comment requires}}
+#pragma comment(user, "foo\abar\nbaz\tsome thing")
+
More information about the cfe-commits
mailing list