Files
llvm-project/clang-tools-extra/test/clang-tidy/temporaries.cpp
Alexander Kornienko 23fe95904c Change the behavior of clang-tidy -checks=, remove -disable-checks.
Summary:
Make checks filtering more intuitive and easy to use. Remove
-disable-checks and change the format of -checks= to a comma-separated list of
globs with optional '-' prefix to denote exclusion. The -checks= option is now
cumulative, so it modifies defaults, not overrides them. Each glob adds or
removes to the current set of checks, so the filter can be refined or overriden
by adding globs.

Example:
  The default value for -checks= is
  '*,-clang-analyzer-alpha*,-llvm-include-order,-llvm-namespace-comment,-google-*',
  which allows all checks except for the ones named clang-analyzer-alpha* and
  others specified with the leading '-'. To allow all google-* checks one can
  write:
    clang-tidy -checks=google-* ...
  If one needs only google-* checks, we first need to remove everything (-*):
    clang-tidy -checks=-*,google-*
  etc.

I'm not sure if we need to change something here, so I didn't touch the docs
yet.

Reviewers: klimek, alexfh

Reviewed By: alexfh

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D3770

llvm-svn: 208883
2014-05-15 14:27:36 +00:00

24 lines
684 B
C++

// RUN: clang-tidy -checks='-*,clang-analyzer-core.NullDereference' -analyze-temporary-dtors %s -- | FileCheck %s
struct NoReturnDtor {
~NoReturnDtor() __attribute__((noreturn));
};
extern bool check(const NoReturnDtor &);
// CHECK-NOT: warning
void testNullPointerDereferencePositive() {
int *value = 0;
// CHECK: [[@LINE+1]]:10: warning: Dereference of null pointer (loaded from variable 'value') [clang-analyzer-core.NullDereference]
*value = 1;
}
// CHECK-NOT: warning
void testNullPointerDereference() {
int *value = 0;
if (check(NoReturnDtor())) {
// This unreachable code causes a warning if we don't run with -analyze-temporary-dtors
*value = 1;
}
}