From a576fcd7404a955d444fd768b57bf1caff5fb955 Mon Sep 17 00:00:00 2001 From: Adam Nemet Date: Tue, 19 Sep 2017 17:59:40 +0000 Subject: [PATCH] Fix ClangDiagnosticHandler::is*RemarkEnabled members 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 | 9 +++++---- test/Frontend/optimization-remark-extra-analysis.c | 11 +++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 test/Frontend/optimization-remark-extra-analysis.c diff --git a/lib/CodeGen/CodeGenAction.cpp b/lib/CodeGen/CodeGenAction.cpp index a29e8de317..3873ef4eb5 100644 --- a/lib/CodeGen/CodeGenAction.cpp +++ b/lib/CodeGen/CodeGenAction.cpp @@ -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 index 0000000000..1a8415e69c --- /dev/null +++ b/test/Frontend/optimization-remark-extra-analysis.c @@ -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; +} -- 2.49.0