aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorBalazs Benics <benicsbalazs@gmail.com>2022-11-25 10:24:56 +0100
committerBalazs Benics <benicsbalazs@gmail.com>2022-11-25 10:24:56 +0100
commit097ce7616527b8948b2a69d1300a44f552959a43 (patch)
tree197d1bd978856b57160b2f7aff6a1c591d859d8a /clang/lib/Frontend/CompilerInvocation.cpp
parent36481758390caa19d54bbab94d2f5e927fbec1c2 (diff)
downloadllvm-097ce7616527b8948b2a69d1300a44f552959a43.zip
llvm-097ce7616527b8948b2a69d1300a44f552959a43.tar.gz
llvm-097ce7616527b8948b2a69d1300a44f552959a43.tar.bz2
[analyzer] Deprecate FAM analyzer-config, recommend -fstrict-flex-arrays instead
By default, clang assumes that all trailing array objects could be a FAM. So, an array of undefined size, size 0, size 1, or even size 42 is considered as FAMs for optimizations at least. One needs to override the default behavior by supplying the `-fstrict-flex-arrays=<N>` flag, with `N > 0` value to reduce the set of FAM candidates. Value `3` is the most restrictive and `0` is the most permissive on this scale. 0: all trailing arrays are FAMs 1: only incomplete, zero and one-element arrays are FAMs 2: only incomplete, zero-element arrays are FAMs 3: only incomplete arrays are FAMs If the user is happy with consdering single-element arrays as FAMs, they just need to remove the `consider-single-element-arrays-as-flexible-array-members` from the command line. Otherwise, if they don't want to recognize such cases as FAMs, they should specify `-fstrict-flex-arrays` anyway, which will be picked up by CSA. Any use of the deprecated analyzer-config value will trigger a warning explaining what to use instead. The `-analyzer-config-help` is updated accordingly. Depends on D138657 Reviewed By: xazax.hun Differential Revision: https://reviews.llvm.org/D138659
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index a13da5a..9536319 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1018,6 +1018,15 @@ static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
A->claim();
Opts.Config[key] = std::string(val);
+
+ // FIXME: Remove this hunk after clang-17 released.
+ constexpr auto SingleFAM =
+ "consider-single-element-arrays-as-flexible-array-members";
+ if (key == SingleFAM) {
+ Diags.Report(diag::warn_analyzer_deprecated_option_with_alternative)
+ << SingleFAM << "clang-17"
+ << "-fstrict-flex-arrays=<N>";
+ }
}
}