diff options
author | Artem Dergachev <artem.dergachev@gmail.com> | 2018-12-20 21:26:40 +0000 |
---|---|---|
committer | Artem Dergachev <artem.dergachev@gmail.com> | 2018-12-20 21:26:40 +0000 |
commit | d001380a69cdc546b2724d3305b167644f6151f4 (patch) | |
tree | 9a5e31102162ea667441a7d28f4ce5f7857fac30 /clang/lib/Driver/ToolChains/Clang.cpp | |
parent | 0535137e4ad5fc76b19ec6118724f66023f565f7 (diff) | |
download | bcm5719-llvm-d001380a69cdc546b2724d3305b167644f6151f4.tar.gz bcm5719-llvm-d001380a69cdc546b2724d3305b167644f6151f4.zip |
[driver] [analyzer] Fix a backward compatibility issue after r348038.
Since r348038 we emit an error every time an -analyzer-config option is not
found. The driver, however, suppresses this error with another flag,
-analyzer-config-compatibility-mode, so backwards compatibility is maintained,
while analyzer developers still enjoy the new typo-free experience.
The backwards compatibility turns out to be still broken when the -analyze
action is not specified; it is still possible to specify -analyzer-config
in that case. This should be fixed now.
Patch by Kristóf Umann!
Differential Revision: https://reviews.llvm.org/D55823
rdar://problem/46504165
llvm-svn: 349824
Diffstat (limited to 'clang/lib/Driver/ToolChains/Clang.cpp')
-rw-r--r-- | clang/lib/Driver/ToolChains/Clang.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index d377b3c0321..859c4b3d701 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2360,9 +2360,6 @@ static void RenderAnalyzerOptions(const ArgList &Args, ArgStringList &CmdArgs, // Treat blocks as analysis entry points. CmdArgs.push_back("-analyzer-opt-analyze-nested-blocks"); - // Enable compatilibily mode to avoid analyzer-config related errors. - CmdArgs.push_back("-analyzer-config-compatibility-mode=true"); - // Add default argument set. if (!Args.hasArg(options::OPT__analyzer_no_default_checks)) { CmdArgs.push_back("-analyzer-checker=core"); @@ -3738,6 +3735,16 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, if (isa<AnalyzeJobAction>(JA)) RenderAnalyzerOptions(Args, CmdArgs, Triple, Input); + // Enable compatilibily mode to avoid analyzer-config related errors. + // Since we can't access frontend flags through hasArg, let's manually iterate + // through them. + for (size_t Index = 0; Index < Args.size(); ++Index) { + if (StringRef(Args.getArgString(Index)).contains("-analyzer-config")) { + CmdArgs.push_back("-analyzer-config-compatibility-mode=true"); + break; + } + } + CheckCodeGenerationOptions(D, Args); unsigned FunctionAlignment = ParseFunctionAlignment(TC, Args); |