From ec12f5febed04dd32e7d4b766b2853d50fca9657 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Tue, 9 Feb 2021 11:06:03 +0100 Subject: [clang][codegen] Remember string used to create llvm::Regex for optimization remarks Regular expression patterns passed through the command line are being used to create an instances of `llvm::Regex` and thrown away. There is no API to serialize `Regex` back to the original pattern. This means we have no way to reconstruct the original pattern from command line. This is necessary for serializing `CompilerInvocation`. This patch stores the original pattern string in `CodeGenOptions` alongside the `llvm::Regex` instance. Reviewed By: dexonsmith, thegameg Differential Revision: https://reviews.llvm.org/D96036 --- clang/lib/Frontend/CompilerInvocation.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'clang/lib/Frontend/CompilerInvocation.cpp') diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 09444b2..658dad5 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1164,8 +1164,8 @@ static void parseAnalyzerConfigs(AnalyzerOptions &AnOpts, } /// Create a new Regex instance out of the string value in \p RpassArg. -/// It returns a pointer to the newly generated Regex instance. -static std::shared_ptr +/// It returns the string and a pointer to the newly generated Regex instance. +static CodeGenOptions::RemarkPattern GenerateOptimizationRemarkRegex(DiagnosticsEngine &Diags, ArgList &Args, Arg *RpassArg) { StringRef Val = RpassArg->getValue(); @@ -1176,7 +1176,7 @@ GenerateOptimizationRemarkRegex(DiagnosticsEngine &Diags, ArgList &Args, << RegexError << RpassArg->getAsString(Args); Pattern.reset(); } - return Pattern; + return {std::string(Val), Pattern}; } static bool parseDiagnosticLevelMask(StringRef FlagName, -- cgit v1.1