]> granicus.if.org Git - clang/commitdiff
Fix ClangDiagnosticHandler::is*RemarkEnabled members
authorAdam Nemet <anemet@apple.com>
Tue, 19 Sep 2017 17:59:40 +0000 (17:59 +0000)
committerAdam Nemet <anemet@apple.com>
Tue, 19 Sep 2017 17:59:40 +0000 (17:59 +0000)
Apparently these weren't really working. I added test coverage and fixed the
typo in the name and the parameter.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@313653 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenAction.cpp
test/Frontend/optimization-remark-extra-analysis.c [new file with mode: 0644]

index a29e8de317f3290a0e78f1c34f6fc6aa983b65c5..3873ef4eb58ae6746ced3584bebe2aa3675337d6 100644 (file)
@@ -53,19 +53,20 @@ namespace clang {
         : CodeGenOpts(CGOpts), BackendCon(BCon) {}
   
     bool handleDiagnostics(const DiagnosticInfo &DI) override;
-    bool isAnalysisRemarkEnable(const std::string &PassName) {
+
+    bool isAnalysisRemarkEnabled(StringRef PassName) const override {
       return (CodeGenOpts.OptimizationRemarkAnalysisPattern &&
               CodeGenOpts.OptimizationRemarkAnalysisPattern->match(PassName));
     }
-    bool isMissedOptRemarkEnable(const std::string &PassName) {
+    bool isMissedOptRemarkEnabled(StringRef PassName) const override {
       return (CodeGenOpts.OptimizationRemarkMissedPattern &&
               CodeGenOpts.OptimizationRemarkMissedPattern->match(PassName));
     }
-    bool isPassedOptRemarkEnable(const std::string &PassName) {
+    bool isPassedOptRemarkEnabled(StringRef PassName) const override {
       return (CodeGenOpts.OptimizationRemarkPattern &&
               CodeGenOpts.OptimizationRemarkPattern->match(PassName));
     }
-  
+
   private:
     const CodeGenOptions &CodeGenOpts;
     BackendConsumer *BackendCon;
diff --git a/test/Frontend/optimization-remark-extra-analysis.c b/test/Frontend/optimization-remark-extra-analysis.c
new file mode 100644 (file)
index 0000000..1a8415e
--- /dev/null
@@ -0,0 +1,11 @@
+// Test that the is*RemarkEnabled overrides are working properly.  This remark
+// requiring extra analysis is only conditionally enabled.
+
+// RUN: %clang_cc1 %s -Rpass-missed=gvn -O2 -emit-llvm-only -verify
+
+int foo(int *x, int *y) {
+  int a = *x;
+  *y = 2;
+  // expected-remark@+1 {{load of type i32 not eliminated}}
+  return a + *x;
+}