summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/PPDirectives.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-08 18:46:40 +0000
committerChris Lattner <sabre@nondot.org>2009-04-08 18:46:40 +0000
commit58a1eb0ba0e0b573e7fbe1004db30ee5423fa8a6 (patch)
tree73d5a35cc79c813b18cc2bb9c5a5e643965dc048 /clang/lib/Lex/PPDirectives.cpp
parent14a7f39733d7712319be4cd0967e47a5e87507a8 (diff)
downloadbcm5719-llvm-58a1eb0ba0e0b573e7fbe1004db30ee5423fa8a6.tar.gz
bcm5719-llvm-58a1eb0ba0e0b573e7fbe1004db30ee5423fa8a6.zip
reject the #__include_macros directive unless it comes from the
predefines buffer. llvm-svn: 68627
Diffstat (limited to 'clang/lib/Lex/PPDirectives.cpp')
-rw-r--r--clang/lib/Lex/PPDirectives.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index a60d9ba4e1f..034d484a934 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -530,7 +530,7 @@ TryAgain:
case tok::pp_include:
return HandleIncludeDirective(Result); // Handle #include.
case tok::pp___include_macros:
- return HandleIncludeDirective(Result); // Handle #__include_macros.
+ return HandleIncludeMacrosDirective(Result); // Handle -imacros.
// C99 6.10.3 - Macro Replacement.
case tok::pp_define:
@@ -1126,6 +1126,25 @@ void Preprocessor::HandleImportDirective(Token &ImportTok) {
return HandleIncludeDirective(ImportTok, 0, true);
}
+/// HandleIncludeMacrosDirective - The -imacros command line option turns into a
+/// pseudo directive in the predefines buffer. This handles it by sucking all
+/// tokens through the preprocessor and discarding them (only keeping the side
+/// effects on the preprocessor).
+void Preprocessor::HandleIncludeMacrosDirective(Token &IncludeMacrosTok) {
+ // This directive should only occur in the predefines buffer. If not, emit an
+ // error and reject it.
+ SourceLocation Loc = IncludeMacrosTok.getLocation();
+ if (strcmp(SourceMgr.getBufferName(Loc), "<built-in>") != 0) {
+ Diag(IncludeMacrosTok.getLocation(),
+ diag::pp_include_macros_out_of_predefines);
+ DiscardUntilEndOfDirective();
+ return;
+ }
+
+ // TODO: implement me :)
+ DiscardUntilEndOfDirective();
+}
+
//===----------------------------------------------------------------------===//
// Preprocessor Macro Directive Handling.
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud