Commit graph

14 commits

Author SHA1 Message Date
Chih-Hung Hsieh
3d3df826c1 Disable bugprone-reserved-identifier
* Disable it for the next clang compiler update
  until all source files with this warning are fixed.

Bug: 153464409
Test: WITH_TIDY=1 make
Change-Id: I126d2f5170f3883192348577e523ef99f5c5a70e
2020-04-08 10:42:16 -07:00
Nikita Ioffe
32c4986268 Add support for clang-tidy -warnings-as-errors in Android.bp files
Test: manually change Android.bp and checked clang-tidy invocation cmd
Change-Id: I51a64b3f7da82428b896f46f739c93d76a050aaf
2019-03-26 20:47:08 +00:00
Colin Cross
0b9f31fb08 Replace *Escape with *EscapeList
Follow the change to blueprint to make *Escape take and return a string
and add *EscapeList that take and return slices of strings.  Fix up
a few places that were unnecessarily converting a string to a slice
and back to a string.

Test: m nothing
Change-Id: I3fa87de175522205f36544ef76aa2f04aef1b936
2019-03-04 18:11:53 +00:00
Chih-Hung Hsieh
327b6f0c69 Disable cert-dcl16-c clang-tidy check for mingw32.
Bug: 120614316
Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,cert-*
Change-Id: Ibe46409543eaa4a7f3b710d9742b3252dc9ac7e8
2018-12-10 16:28:56 -08:00
Dan Willemsen
8536d6b3b7 Remove GCC checks
Clang is always used now, so we can remove all the GCC checks. Removing
GCC-specific configuration will happen in the next CL.

Test: m
Change-Id: I4835ecf6062159315d0dfb07b098e60bff033a8a
2018-10-09 02:16:58 +00:00
Chih-Hung Hsieh
9e5d8a60e2 Use WITH_TIDY_FLAGS env variable.
This variable is a space separated string of clang-tidy flags to be passed
to clang-tidy before any other system required extra flags.
Note that when this flag or local tidy_flags is defined,
the default -header-filter flag is suppressed.

Test: make with WITH_TIDY=1 WITH_TIDY_FLAGS="-extra-arg=-DABCD1=1 -extra-arg=-DABCD2=2"
Bug: 32668284
Change-Id: If7bd31c65404ef7fe6c3499d51f0f209a704efd9
2018-09-21 15:19:24 -07:00
George Burgess IV
030ccee01c 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
2018-05-14 16:30:46 -07:00
Chih-Hung Hsieh
669cb9150e Call clang-tidy with -fno-caret-diagnostics by default.
* clang -fno-caret-diagnostics
  suppresses warning source lines, carets, and
  the stats line of "n warnings generated"
* clang-tidy -extra-arg-before=-fno-caret-diagnotics
  only suppresses the "n warnings generated" line.
* Pass this flag and -quiet to clang-tidy when
  WITH_TIDY is not 1 or true.

Bug: 69051430
Test: normal build and build with WITH_TIDY=1

Change-Id: I34e34cddc0e7329e73b5f04da4b1458dabfcd4c8
2018-01-04 01:41:16 -08:00
Chih-Hung Hsieh
dc0c0302e9 Call clang-tidy with -quiet unless WITH_TIDY is set.
* Default builds calls clang-tidy only if enabled locally.
  In this case, clang-tidy should be quiet.
* If WITH_TIDY is 1 or true, let clang-tidy emit default messages.
* Even with -quiet and all warnings are suppressed,
  clang-tidy emits one line message of the number of suppressed messages.
  This one-liner could be suppressed in future changes.

Bug: 69051430
Test: default build and build with WITH_TIDY=1
Change-Id: I45303149930b33544e271e6d5eeddf18c9e48d7a
2017-12-15 20:57:48 -08:00
Colin Cross
6510f91a1c Replace ModuleContext.AConfig() with Config()
AConfig() now duplicates Config().  Replace the uses of AConfig()
with Config().  Leave AConfig() for now until code in other
projects is cleaned up.

Test: m checkbuild
Change-Id: Ic88be643049d21dba45dbd1a65588ed94bf43bdc
2017-11-30 00:44:18 +00:00
George Burgess IV
561a3fe4af soong: add __clang_analyzer__ to clang-tidy
We have code that acts slightly differently when the static analyzer is
running, so that it can produce more accurate diagnostics (e.g. less
false positives). It uses __clang_analyzer__ to detect the static
analyzer.

When the static analyzer is run via clang-tidy, __clang_analyzer__
doesn't get defined.

Bug: None
Test: WITH_TIDY=1 m. clang-tidy now acts as expected in code made for
the static analyzer

Change-Id: I460ff410640524633c0a60b71d34927d17e1ed98
2017-05-04 01:19:02 +00:00
Colin Cross
37047f1c7e Pass DepsContext to dependency methods
Pass a DepsContext that embeds android.BottomUpMutatorContext
instead of android.BaseContext so that dependency methods can
directly add dependencies.

Test: m -j
Change-Id: Id4c157975d3d6f03efd99785d217bef486a76139
2016-12-13 17:32:29 -08:00
Colin Cross
379d2cb511 Always check tidy properties
To avoid build breakages when WITH_TIDY=1 is set, check for bad tidy
properties before checking if tidy is enabled.

Test: mmma -j external/llvm with a tidy error
Test: m -j
Change-Id: Ia338c417091ff6b03909bbac8b26febed5b6d6ea
2016-12-05 17:12:10 -08:00
Dan Willemsen
a03cf6d322 Add clang-tidy support
For every file which we can run clang-tidy (C/C++ clang-built), we add a
new build node that depends on the object file (since clang-tidy does
not export a depfile), and is depended on by the link step. This is
better than how we're doing it in make, since calling tidy can be turned
on or off without needing to rebuild the object files.

This does not attempt to port WITH_TIDY_ONLY from Make, since the way
that it works is broken (due to the lack of a depfile).

Bug: 32244182
Test: WITH_TIDY=true mmma -j bionic/libc
Test: ./soong (Setting ClangTidy: true)
Change-Id: I40bbb5bb00d292d72bf1c293b93080b5f9f6d8ea
2016-10-31 16:21:01 -07:00