forked from OSchip/llvm-project
[analyzer] Analysis: Fix checker silencing
llvm-svn: 369845
This commit is contained in:
parent
6d5a8c92bf
commit
0d7252b783
|
@ -464,6 +464,35 @@ static void parseAnalyzerConfigs(AnalyzerOptions &AnOpts,
|
|||
|
||||
// At this point, AnalyzerOptions is configured. Let's validate some options.
|
||||
|
||||
// FIXME: Here we try to validate the silenced checkers or packages are valid.
|
||||
// The current approach only validates the registered checkers which does not
|
||||
// contain the runtime enabled checkers and optimally we would validate both.
|
||||
if (!AnOpts.RawSilencedCheckersAndPackages.empty()) {
|
||||
std::vector<StringRef> Checkers =
|
||||
AnOpts.getRegisteredCheckers(/*IncludeExperimental=*/true);
|
||||
std::vector<StringRef> Packages =
|
||||
AnOpts.getRegisteredPackages(/*IncludeExperimental=*/true);
|
||||
|
||||
SmallVector<StringRef, 16> CheckersAndPackages;
|
||||
AnOpts.RawSilencedCheckersAndPackages.split(CheckersAndPackages, ";");
|
||||
|
||||
for (const StringRef CheckerOrPackage : CheckersAndPackages) {
|
||||
if (Diags) {
|
||||
bool IsChecker = CheckerOrPackage.contains('.');
|
||||
bool IsValidName =
|
||||
IsChecker
|
||||
? llvm::find(Checkers, CheckerOrPackage) != Checkers.end()
|
||||
: llvm::find(Packages, CheckerOrPackage) != Packages.end();
|
||||
|
||||
if (!IsValidName)
|
||||
Diags->Report(diag::err_unknown_analyzer_checker_or_package)
|
||||
<< CheckerOrPackage;
|
||||
}
|
||||
|
||||
AnOpts.SilencedCheckersAndPackages.emplace_back(CheckerOrPackage);
|
||||
}
|
||||
}
|
||||
|
||||
if (!Diags)
|
||||
return;
|
||||
|
||||
|
@ -479,32 +508,6 @@ static void parseAnalyzerConfigs(AnalyzerOptions &AnOpts,
|
|||
!llvm::sys::fs::is_directory(AnOpts.ModelPath))
|
||||
Diags->Report(diag::err_analyzer_config_invalid_input) << "model-path"
|
||||
<< "a filename";
|
||||
|
||||
// FIXME: Here we try to validate the silenced checkers or packages are valid.
|
||||
// The current approach only validates the registered checkers which does not
|
||||
// contain the runtime enabled checkers and optimally we would validate both.
|
||||
if (!AnOpts.RawSilencedCheckersAndPackages.empty()) {
|
||||
std::vector<StringRef> Checkers =
|
||||
AnOpts.getRegisteredCheckers(/*IncludeExperimental=*/true);
|
||||
std::vector<StringRef> Packages =
|
||||
AnOpts.getRegisteredPackages(/*IncludeExperimental=*/true);
|
||||
|
||||
SmallVector<StringRef, 16> CheckersAndPackages;
|
||||
AnOpts.RawSilencedCheckersAndPackages.split(CheckersAndPackages, ";");
|
||||
|
||||
for (const StringRef CheckerOrPackage : CheckersAndPackages) {
|
||||
bool IsChecker = CheckerOrPackage.contains('.');
|
||||
bool IsValidName =
|
||||
IsChecker ? llvm::find(Checkers, CheckerOrPackage) != Checkers.end()
|
||||
: llvm::find(Packages, CheckerOrPackage) != Packages.end();
|
||||
|
||||
if (!IsValidName)
|
||||
Diags->Report(diag::err_unknown_analyzer_checker_or_package)
|
||||
<< CheckerOrPackage;
|
||||
|
||||
AnOpts.SilencedCheckersAndPackages.emplace_back(CheckerOrPackage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool ParseMigratorArgs(MigratorOptions &Opts, ArgList &Args) {
|
||||
|
|
|
@ -1889,11 +1889,6 @@ foreach (sort { $Options{DisableCheckers}{$a} <=> $Options{DisableCheckers}{$b}
|
|||
# Push checkers in order they were disabled.
|
||||
push @AnalysesToRun, "-analyzer-disable-checker", $_;
|
||||
}
|
||||
foreach (sort { $Options{SilenceCheckers}{$a} <=> $Options{SilenceCheckers}{$b} }
|
||||
keys %{$Options{SilenceCheckers}}) {
|
||||
# Push checkers in order they were silenced.
|
||||
push @AnalysesToRun, "-analyzer-config silence-checker", $_;
|
||||
}
|
||||
if ($Options{AnalyzeHeaders}) { push @AnalysesToRun, "-analyzer-opt-analyze-headers"; }
|
||||
if ($Options{AnalyzerStats}) { push @AnalysesToRun, '-analyzer-checker=debug.Stats'; }
|
||||
if ($Options{MaxLoop} > 0) { push @AnalysesToRun, "-analyzer-max-loop $Options{MaxLoop}"; }
|
||||
|
@ -1903,6 +1898,14 @@ if ($Options{MaxLoop} > 0) { push @AnalysesToRun, "-analyzer-max-loop $Options{M
|
|||
my $CCC_ANALYZER_ANALYSIS = join ' ', @AnalysesToRun;
|
||||
my $CCC_ANALYZER_PLUGINS = join ' ', map { "-load ".$_ } @{$Options{PluginsToLoad}};
|
||||
my $CCC_ANALYZER_CONFIG = join ' ', map { "-analyzer-config ".$_ } @{$Options{ConfigOptions}};
|
||||
|
||||
foreach (sort { $Options{SilenceCheckers}{$a} <=> $Options{SilenceCheckers}{$b} }
|
||||
keys %{$Options{SilenceCheckers}}) {
|
||||
# Add checkers in order they were silenced.
|
||||
$CCC_ANALYZER_CONFIG =
|
||||
$CCC_ANALYZER_CONFIG." -analyzer-config silence-checkers=".$_;
|
||||
}
|
||||
|
||||
my %EnvVars = (
|
||||
'CC' => $Cmd,
|
||||
'CXX' => $CmdCXX,
|
||||
|
|
Loading…
Reference in New Issue