forked from OSchip/llvm-project
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: 196372
This commit is contained in:
parent
cdd86884a4
commit
5c4269c688
|
@ -643,6 +643,9 @@ public:
|
|||
RemovePragmaHandler(StringRef(), Handler);
|
||||
}
|
||||
|
||||
/// Install empty handlers for all pragmas (making them ignored).
|
||||
void IgnorePragmas();
|
||||
|
||||
/// \brief Add the specified comment handler to the preprocessor.
|
||||
void addCommentHandler(CommentHandler *Handler);
|
||||
|
||||
|
|
|
@ -485,7 +485,7 @@ void PreprocessOnlyAction::ExecuteAction() {
|
|||
Preprocessor &PP = getCompilerInstance().getPreprocessor();
|
||||
|
||||
// Ignore unknown pragmas.
|
||||
PP.AddPragmaHandler(new EmptyPragmaHandler());
|
||||
PP.IgnorePragmas();
|
||||
|
||||
Token Tok;
|
||||
// Start parsing the specified input file.
|
||||
|
|
|
@ -704,7 +704,7 @@ static int MacroIDCompare(const id_macro_pair *LHS, const id_macro_pair *RHS) {
|
|||
|
||||
static void DoPrintMacros(Preprocessor &PP, raw_ostream *OS) {
|
||||
// Ignore unknown pragmas.
|
||||
PP.AddPragmaHandler(new EmptyPragmaHandler());
|
||||
PP.IgnorePragmas();
|
||||
|
||||
// -dM mode just scans and ignores all tokens in the files, then dumps out
|
||||
// the macro table at the end.
|
||||
|
|
|
@ -1401,3 +1401,14 @@ 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());
|
||||
AddPragmaHandler("STDC", new EmptyPragmaHandler());
|
||||
}
|
||||
|
|
|
@ -518,13 +518,7 @@ void clang::RewriteIncludesInInput(Preprocessor &PP, raw_ostream *OS,
|
|||
InclusionRewriter *Rewrite = new InclusionRewriter(PP, *OS,
|
||||
Opts.ShowLineMarkers);
|
||||
PP.addPPCallbacks(Rewrite);
|
||||
// Ignore all pragmas, otherwise there will be warnings about unknown pragmas
|
||||
// (because there's nothing to handle them).
|
||||
PP.AddPragmaHandler(new EmptyPragmaHandler());
|
||||
// Ignore also all pragma in all namespaces created
|
||||
// in Preprocessor::RegisterBuiltinPragmas().
|
||||
PP.AddPragmaHandler("GCC", new EmptyPragmaHandler());
|
||||
PP.AddPragmaHandler("clang", new EmptyPragmaHandler());
|
||||
PP.IgnorePragmas();
|
||||
|
||||
// First let the preprocessor process the entire file and call callbacks.
|
||||
// Callbacks will record which #include's were actually performed.
|
||||
|
|
Loading…
Reference in New Issue