OSDN Git Service

[lldb][NFC] Refactor setup code for Clang diagnostics
authorRaphael Isemann <teemperor@gmail.com>
Fri, 8 Jan 2021 13:24:48 +0000 (14:24 +0100)
committerRaphael Isemann <teemperor@gmail.com>
Fri, 8 Jan 2021 13:26:04 +0000 (14:26 +0100)
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

index 9b6e6e0..c61c010 100644 (file)
@@ -337,6 +337,20 @@ static void RemoveAllCppKeywords(IdentifierTable &idents) {
 #include "clang/Basic/TokenKinds.def"
 }
 
+/// Configures Clang diagnostics for the expression parser.
+static void SetupDefaultClangDiagnostics(CompilerInstance &compiler) {
+  // List of Clang warning groups that are not useful when parsing expressions.
+  const std::vector<const char *> groupsToIgnore = {
+      "unused-value",
+      "odr",
+  };
+  for (const char *group : groupsToIgnore) {
+    compiler.getDiagnostics().setSeverityForGroup(
+        clang::diag::Flavor::WarningOrError, group,
+        clang::diag::Severity::Ignored, SourceLocation());
+  }
+}
+
 //===----------------------------------------------------------------------===//
 // Implementation of ClangExpressionParser
 //===----------------------------------------------------------------------===//
@@ -637,12 +651,7 @@ ClangExpressionParser::ClangExpressionParser(
     m_compiler->getCodeGenOpts().setDebugInfo(codegenoptions::NoDebugInfo);
 
   // Disable some warnings.
-  m_compiler->getDiagnostics().setSeverityForGroup(
-      clang::diag::Flavor::WarningOrError, "unused-value",
-      clang::diag::Severity::Ignored, SourceLocation());
-  m_compiler->getDiagnostics().setSeverityForGroup(
-      clang::diag::Flavor::WarningOrError, "odr",
-      clang::diag::Severity::Ignored, SourceLocation());
+  SetupDefaultClangDiagnostics(*m_compiler);
 
   // Inform the target of the language options
   //