summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/Pragma.cpp
diff options
context:
space:
mode:
authorLubos Lunak <l.lunak@centrum.cz>2014-05-01 12:54:03 +0000
committerLubos Lunak <l.lunak@centrum.cz>2014-05-01 12:54:03 +0000
commit576a0415cb8b0615c2d6e8fd87e5427ddbc7fb20 (patch)
tree032789f8ef00241add4e5a3b7f2f93b7d3269f34 /clang/lib/Lex/Pragma.cpp
parent4a04294882bdd530bd0c3b388980e5326423e1b2 (diff)
downloadbcm5719-llvm-576a0415cb8b0615c2d6e8fd87e5427ddbc7fb20.tar.gz
bcm5719-llvm-576a0415cb8b0615c2d6e8fd87e5427ddbc7fb20.zip
do not warn about unknown pragmas in modes that do not handle them (pr9537)
And refactor to have just one place in code that sets up the empty pragma handlers. llvm-svn: 207758
Diffstat (limited to 'clang/lib/Lex/Pragma.cpp')
-rw-r--r--clang/lib/Lex/Pragma.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp
index 99ba8dee2db..97a08da8ef3 100644
--- a/clang/lib/Lex/Pragma.cpp
+++ b/clang/lib/Lex/Pragma.cpp
@@ -1385,3 +1385,25 @@ void Preprocessor::RegisterBuiltinPragmas() {
AddPragmaHandler(new PragmaRegionHandler("endregion"));
}
}
+
+/// Ignore all pragmas, useful for modes such as -Eonly which would otherwise
+/// warn about those pragmas being unknown.
+void Preprocessor::IgnorePragmas() {
+ AddPragmaHandler(new EmptyPragmaHandler());
+ // Also ignore all pragmas in all namespaces created
+ // in Preprocessor::RegisterBuiltinPragmas().
+ AddPragmaHandler("GCC", new EmptyPragmaHandler());
+ AddPragmaHandler("clang", new EmptyPragmaHandler());
+ if (PragmaHandler *NS = PragmaHandlers->FindHandler("STDC")) {
+ // Preprocessor::RegisterBuiltinPragmas() already registers
+ // PragmaSTDC_UnknownHandler as the empty handler, so remove it first,
+ // otherwise there will be an assert about a duplicate handler.
+ PragmaNamespace *STDCNamespace = NS->getIfNamespace();
+ assert(STDCNamespace &&
+ "Invalid namespace, registered as a regular pragma handler!");
+ if (PragmaHandler *Existing = STDCNamespace->FindHandler("", false)) {
+ RemovePragmaHandler("STDC", Existing);
+ }
+ }
+ AddPragmaHandler("STDC", new EmptyPragmaHandler());
+}
OpenPOWER on IntegriCloud