summaryrefslogtreecommitdiff
path: root/lib/Lex/Pragma.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Lex/Pragma.cpp')
-rw-r--r--lib/Lex/Pragma.cpp36
1 files changed, 26 insertions, 10 deletions
diff --git a/lib/Lex/Pragma.cpp b/lib/Lex/Pragma.cpp
index afb41a2407768..1819f4f06bc53 100644
--- a/lib/Lex/Pragma.cpp
+++ b/lib/Lex/Pragma.cpp
@@ -938,13 +938,13 @@ struct PragmaDebugHandler : public PragmaHandler {
}
SourceLocation NameLoc = Tok.getLocation();
- Token *Toks = PP.getPreprocessorAllocator().Allocate<Token>(1);
- Toks->startToken();
- Toks->setKind(tok::annot_pragma_captured);
- Toks->setLocation(NameLoc);
+ MutableArrayRef<Token> Toks(
+ PP.getPreprocessorAllocator().Allocate<Token>(1), 1);
+ Toks[0].startToken();
+ Toks[0].setKind(tok::annot_pragma_captured);
+ Toks[0].setLocation(NameLoc);
- PP.EnterTokenStream(Toks, 1, /*DisableMacroExpansion=*/true,
- /*OwnsTokens=*/false);
+ PP.EnterTokenStream(Toks, /*DisableMacroExpansion=*/true);
}
// Disable MSVC warning about runtime stack overflow.
@@ -1024,10 +1024,19 @@ public:
return;
}
- if (PP.getDiagnostics().setSeverityForGroup(
- WarningName[1] == 'W' ? diag::Flavor::WarningOrError
- : diag::Flavor::Remark,
- WarningName.substr(2), SV, DiagLoc))
+ diag::Flavor Flavor = WarningName[1] == 'W' ? diag::Flavor::WarningOrError
+ : diag::Flavor::Remark;
+ StringRef Group = StringRef(WarningName).substr(2);
+ bool unknownDiag = false;
+ if (Group == "everything") {
+ // Special handling for pragma clang diagnostic ... "-Weverything".
+ // There is no formal group named "everything", so there has to be a
+ // special case for it.
+ PP.getDiagnostics().setSeverityForAll(Flavor, SV, DiagLoc);
+ } else
+ unknownDiag = PP.getDiagnostics().setSeverityForGroup(Flavor, Group, SV,
+ DiagLoc);
+ if (unknownDiag)
PP.Diag(StringLoc, diag::warn_pragma_diagnostic_unknown_warning)
<< WarningName;
else if (Callbacks)
@@ -1481,6 +1490,13 @@ void Preprocessor::RegisterBuiltinPragmas() {
AddPragmaHandler(new PragmaRegionHandler("region"));
AddPragmaHandler(new PragmaRegionHandler("endregion"));
}
+
+ // Pragmas added by plugins
+ for (PragmaHandlerRegistry::iterator it = PragmaHandlerRegistry::begin(),
+ ie = PragmaHandlerRegistry::end();
+ it != ie; ++it) {
+ AddPragmaHandler(it->instantiate().release());
+ }
}
/// Ignore all pragmas, useful for modes such as -Eonly which would otherwise