Skip to content

Commit

Permalink
[analyzer] Drop deprecated flags
Browse files Browse the repository at this point in the history
As proposed in D126215 (ffe7950),
I'm dropping the `-analyzer-store` and
`-analyzer-opt-analyze-nested-blocks` clang frontend flags.
I'm also dropping the corresponding commandline handlers of `scanbuild`.

This behavior is planned to be part of `clang-16`.

Reviewed By: xazax.hun

Differential Revision: https://reviews.llvm.org/D132289
  • Loading branch information
steakhal committed Aug 23, 2022
1 parent 16cb3be commit 6ca17b5
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 46 deletions.
5 changes: 5 additions & 0 deletions clang/docs/ReleaseNotes.rst
Expand Up @@ -233,6 +233,11 @@ libclang
Static Analyzer
---------------

- Removed the deprecated ``-analyzer-store`` and
``-analyzer-opt-analyze-nested-blocks`` analyzer flags.
``scanbuild`` was also updated accordingly.
Passing these flags will result in a hard error.

.. _release-notes-ubsan:

Undefined Behavior Sanitizer (UBSan)
Expand Down
8 changes: 0 additions & 8 deletions clang/include/clang/Driver/Options.td
Expand Up @@ -5075,11 +5075,6 @@ def analysis_UnoptimizedCFG : Flag<["-"], "unoptimized-cfg">,
def analysis_CFGAddImplicitDtors : Flag<["-"], "cfg-add-implicit-dtors">,
HelpText<"Add C++ implicit destructors to CFGs for all analyses">;

// We should remove this option in clang-16 release.
def analyzer_store : Separate<["-"], "analyzer-store">,
HelpText<"Source Code Analysis - Abstract Memory Store Models [DEPRECATED, removing in clang-16]">;
def analyzer_store_EQ : Joined<["-"], "analyzer-store=">, Alias<analyzer_store>;

def analyzer_constraints : Separate<["-"], "analyzer-constraints">,
HelpText<"Source Code Analysis - Symbolic Constraint Engines">;
def analyzer_constraints_EQ : Joined<["-"], "analyzer-constraints=">,
Expand All @@ -5097,9 +5092,6 @@ def analyzer_purge_EQ : Joined<["-"], "analyzer-purge=">, Alias<analyzer_purge>;
def analyzer_opt_analyze_headers : Flag<["-"], "analyzer-opt-analyze-headers">,
HelpText<"Force the static analyzer to analyze functions defined in header files">,
MarshallingInfoFlag<AnalyzerOpts<"AnalyzeAll">>;
// We should remove this option in clang-16 release.
def analyzer_opt_analyze_nested_blocks : Flag<["-"], "analyzer-opt-analyze-nested-blocks">,
HelpText<"Analyze the definitions of blocks in addition to functions [DEPRECATED, removing in clang-16]">;
def analyzer_display_progress : Flag<["-"], "analyzer-display-progress">,
HelpText<"Emit verbose output about the analyzer's progress">,
MarshallingInfoFlag<AnalyzerOpts<"AnalyzerDisplayProgress">>;
Expand Down
8 changes: 0 additions & 8 deletions clang/lib/Frontend/CompilerInvocation.cpp
Expand Up @@ -907,14 +907,6 @@ static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
#include "clang/Driver/Options.inc"
#undef ANALYZER_OPTION_WITH_MARSHALLING

if (Args.hasArg(OPT_analyzer_store))
Diags.Report(diag::warn_analyzer_deprecated_option) << "-analyzer-store"
<< "clang-16";
if (Args.hasArg(OPT_analyzer_opt_analyze_nested_blocks))
Diags.Report(diag::warn_analyzer_deprecated_option)
<< "-analyzer-opt-analyze-nested-blocks"
<< "clang-16";

if (Arg *A = Args.getLastArg(OPT_analyzer_constraints)) {
StringRef Name = A->getValue();
AnalysisConstraints Value = llvm::StringSwitch<AnalysisConstraints>(Name)
Expand Down
17 changes: 6 additions & 11 deletions clang/test/Analysis/deprecated-flags-and-options.cpp
@@ -1,18 +1,13 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core %s 2>&1 \
// RUN: | FileCheck %s --check-prefixes=CHECK

// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store=region %s 2>&1 \
// RUN: | FileCheck %s --check-prefixes=CHECK,DEPRECATED-STORE
// DEPRECATED-STORE: warning: analyzer option '-analyzer-store' is deprecated. This flag will be removed in clang-16, and passing this option will be an error.
// RUN: not %clang_analyze_cc1 -analyzer-checker=core -analyzer-store=region %s 2>&1 \
// RUN: | FileCheck %s --check-prefixes=DEPRECATED-STORE
// DEPRECATED-STORE: error: unknown argument: '-analyzer-store=region'

// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-opt-analyze-nested-blocks %s 2>&1 \
// RUN: | FileCheck %s --check-prefixes=CHECK,DEPRECATED-NESTED-BLOCKS
// DEPRECATED-NESTED-BLOCKS: warning: analyzer option '-analyzer-opt-analyze-nested-blocks' is deprecated. This flag will be removed in clang-16, and passing this option will be an error.

// RUN: %clang_analyze_cc1 -analyzer-checker=core %s --help 2>&1 \
// RUN: | FileCheck %s --check-prefixes=CHECK-HELP
// CHECK-HELP: Analyze the definitions of blocks in addition to functions [DEPRECATED, removing in clang-16]
// CHECK-HELP: -analyzer-store <value> Source Code Analysis - Abstract Memory Store Models [DEPRECATED, removing in clang-16]
// RUN: not %clang_analyze_cc1 -analyzer-checker=core -analyzer-opt-analyze-nested-blocks %s 2>&1 \
// RUN: | FileCheck %s --check-prefixes=DEPRECATED-NESTED-BLOCKS
// DEPRECATED-NESTED-BLOCKS: error: unknown argument: '-analyzer-opt-analyze-nested-blocks'

int empty(int x) {
// CHECK: warning: Division by zero
Expand Down
2 changes: 0 additions & 2 deletions clang/tools/scan-build-py/lib/libscanbuild/analyze.py
Expand Up @@ -386,8 +386,6 @@ def analyzer_params(args):

result = []

if args.store_model:
result.append('-analyzer-store={0}'.format(args.store_model))
if args.constraints_model:
result.append('-analyzer-constraints={0}'.format(
args.constraints_model))
Expand Down
11 changes: 1 addition & 10 deletions clang/tools/scan-build/bin/scan-build
Expand Up @@ -61,7 +61,6 @@ my %Options = (
UseCC => undef, # C compiler to use for compilation.
UseCXX => undef, # C++ compiler to use for compilation.
AnalyzerTarget => undef,
StoreModel => undef,
ConstraintsModel => undef,
InternalStats => undef,
OutputFormat => "html",
Expand Down Expand Up @@ -977,8 +976,7 @@ sub SetEnv {
die "$var is undefined\n" if (!defined $var);
$ENV{$var} = $EnvVars->{$var};
}
foreach my $var ('CCC_ANALYZER_STORE_MODEL',
'CCC_ANALYZER_CONSTRAINTS_MODEL',
foreach my $var ('CCC_ANALYZER_CONSTRAINTS_MODEL',
'CCC_ANALYZER_INTERNAL_STATS',
'CCC_ANALYZER_OUTPUT_FORMAT',
'CCC_CC',
Expand Down Expand Up @@ -1704,12 +1702,6 @@ sub ProcessArgs {
next;
}

if ($arg eq "-store") {
shift @$Args;
$Options{StoreModel} = shift @$Args;
next;
}

if ($arg eq "-constraints") {
shift @$Args;
$Options{ConstraintsModel} = shift @$Args;
Expand Down Expand Up @@ -1958,7 +1950,6 @@ my %EnvVars = (
'CCC_CC' => $Options{UseCC},
'CCC_CXX' => $Options{UseCXX},
'CCC_REPORT_FAILURES' => $Options{ReportFailures},
'CCC_ANALYZER_STORE_MODEL' => $Options{StoreModel},
'CCC_ANALYZER_CONSTRAINTS_MODEL' => $Options{ConstraintsModel},
'CCC_ANALYZER_INTERNAL_STATS' => $Options{InternalStats},
'CCC_ANALYZER_OUTPUT_FORMAT' => $Options{OutputFormat},
Expand Down
7 changes: 0 additions & 7 deletions clang/tools/scan-build/libexec/ccc-analyzer
Expand Up @@ -466,9 +466,6 @@ my $Analyses = $ENV{'CCC_ANALYZER_ANALYSIS'};
# Get the plugins to load.
my $Plugins = $ENV{'CCC_ANALYZER_PLUGINS'};

# Get the store model.
my $StoreModel = $ENV{'CCC_ANALYZER_STORE_MODEL'};

# Get the constraints engine.
my $ConstraintsModel = $ENV{'CCC_ANALYZER_CONSTRAINTS_MODEL'};

Expand Down Expand Up @@ -729,10 +726,6 @@ if ($Action eq 'compile' or $Action eq 'link') {
push @CmdArgs, '-x', $FileLang;
}

if (defined $StoreModel) {
push @AnalyzeArgs, "-analyzer-store=$StoreModel";
}

if (defined $ConstraintsModel) {
push @AnalyzeArgs, "-analyzer-constraints=$ConstraintsModel";
}
Expand Down

0 comments on commit 6ca17b5

Please sign in to comment.