aboutsummaryrefslogtreecommitdiffstats
path: root/cc/tidy.go
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2018-05-14 16:30:46 -0700
committerGeorge Burgess IV <gbiv@google.com>2018-05-14 16:30:46 -0700
commit030ccee01c7b46b56d89b97a4226599cbf68e1c1 (patch)
tree8fa77c8fd2f9b4d74a3ebeb328543fd52f3bfd3b /cc/tidy.go
parent470969df19079ad1c2eeb94fcc984ca2ce5e68ab (diff)
downloadbuild_soong-030ccee01c7b46b56d89b97a4226599cbf68e1c1.tar.gz
build_soong-030ccee01c7b46b56d89b97a4226599cbf68e1c1.tar.bz2
build_soong-030ccee01c7b46b56d89b97a4226599cbf68e1c1.zip
Disable dtor inlining for clang-tidy
LLVM r328258 turned on a feature called temporary dtor inlining by default for all of C++ in clang-tidy. This feature appears to be somewhat over-aggressive when objects are being passed by value. For example, given: void foo(std::unique_ptr<int> i); void bar() { auto x = std::make_unique<int>(); int *i = x.get(); foo(std::move(x)); *i = 99; } ...clang-tidy will complain about `*i = 99;` being a definite use-after-free. This is incorrect, however: `foo` could stash the `unique_ptr` it's given in a global, or a class member, or ... Until upstream fixes this bug, it's probably best to keep this disabled. Bug: None Test: Ran the analyzer across Android locally. Nothing broke; number of complaints dropped significantly. Change-Id: I806c7ead34b61f4a88a7e6ec1c94751836a21e70
Diffstat (limited to 'cc/tidy.go')
-rw-r--r--cc/tidy.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/cc/tidy.go b/cc/tidy.go
index 8ca94efc..491cc22d 100644
--- a/cc/tidy.go
+++ b/cc/tidy.go
@@ -83,9 +83,21 @@ func (tidy *tidyFeature) flags(ctx ModuleContext, flags Flags) Flags {
flags.TidyFlags = append(flags.TidyFlags, "-extra-arg-before=-fno-caret-diagnostics")
}
- // We might be using the static analyzer through clang tidy.
- // https://bugs.llvm.org/show_bug.cgi?id=32914
- flags.TidyFlags = append(flags.TidyFlags, "-extra-arg-before=-D__clang_analyzer__")
+ extraArgFlags := []string{
+ // We might be using the static analyzer through clang tidy.
+ // https://bugs.llvm.org/show_bug.cgi?id=32914
+ "-D__clang_analyzer__",
+
+ // A recent change in clang-tidy (r328258) enabled destructor inlining, which
+ // appears to cause a number of false positives. Until that's resolved, this turns
+ // off the effects of r328258.
+ // https://bugs.llvm.org/show_bug.cgi?id=37459
+ "-Xclang", "-analyzer-config", "-Xclang", "c++-temp-dtor-inlining=false",
+ }
+
+ for _, f := range extraArgFlags {
+ flags.TidyFlags = append(flags.TidyFlags, "-extra-arg-before="+f)
+ }
tidyChecks := "-checks="
if checks := ctx.Config().TidyChecks(); len(checks) > 0 {