2019-02-05 08:39:33 +08:00
==================
Available Checkers
==================
2019-02-11 23:17:13 +08:00
The analyzer performs checks that are categorized into families or "checkers".
The default set of checkers covers a variety of checks targeted at finding security and API usage bugs,
dead code, and other logic errors. See the :ref: `default-checkers` checkers list below.
2019-02-05 08:39:33 +08:00
In addition to these, the analyzer contains a number of :ref: `alpha-checkers` (aka *alpha* checkers).
These checkers are under development and are switched off by default. They may crash or emit a higher number of false positives.
The :ref: `debug-checkers` package contains checkers for analyzer developers for debugging purposes.
.. contents :: Table of Contents
:depth: 4
.. _default-checkers:
Default Checkers
----------------
.. _core-checkers:
core
^^^^
2019-02-11 23:17:13 +08:00
Models core language features and contains general-purpose checkers such as division by zero,
null pointer dereference, usage of uninitialized values, etc.
2019-02-05 08:39:33 +08:00
*These checkers must be always switched on as other checker rely on them.*
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _core-CallAndMessage:
2019-02-05 08:39:33 +08:00
core.CallAndMessage (C, C++, ObjC)
""""""""""""""""""""""""""""""""""
Check for logical errors for function calls and Objective-C message expressions (e.g., uninitialized arguments, null function pointers).
2019-02-11 23:17:13 +08:00
.. literalinclude :: checkers/callandmessage_example.c
2019-02-05 08:39:33 +08:00
:language: objc
2019-02-11 23:17:13 +08:00
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _core-DivideZero:
2019-02-05 08:39:33 +08:00
core.DivideZero (C, C++, ObjC)
""""""""""""""""""""""""""""""
Check for division by zero.
.. literalinclude :: checkers/dividezero_example.c
:language: c
2019-02-11 23:17:13 +08:00
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _core-NonNullParamChecker:
2019-02-11 23:17:13 +08:00
core.NonNullParamChecker (C, C++, ObjC)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""""""""""""""""""
Check for null pointers passed as arguments to a function whose arguments are references or marked with the 'nonnull' attribute.
2019-02-11 23:17:13 +08:00
.. code-block :: cpp
2019-02-05 08:39:33 +08:00
int f(int *p) __attribute__((nonnull));
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test(int *p) {
if (!p)
f(p); // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _core-NullDereference:
2019-02-05 08:39:33 +08:00
core.NullDereference (C, C++, ObjC)
"""""""""""""""""""""""""""""""""""
Check for dereferences of null pointers.
.. code-block :: objc
// C
void test(int *p) {
if (p)
return;
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
int x = p[0]; // warn
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
// C
void test(int *p) {
if (!p)
*p = 0; // warn
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
// C++
class C {
public:
int x;
};
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
C *pc = 0;
int k = pc->x; // warn
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
// Objective-C
@interface MyClass {
@public
int x;
}
@end
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
MyClass *obj = 0;
obj->x = 1; // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _core-StackAddressEscape:
2019-02-05 08:39:33 +08:00
core.StackAddressEscape (C)
"""""""""""""""""""""""""""
Check that addresses to stack memory do not escape the function.
.. code-block :: c
char const *p;
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
char const str[] = "string";
p = str; // warn
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void* test() {
return __builtin_alloca(12); // warn
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
static int *x;
int y;
x = &y; // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _core-UndefinedBinaryOperatorResult:
2019-02-05 08:39:33 +08:00
core.UndefinedBinaryOperatorResult (C)
""""""""""""""""""""""""""""""""""""""
Check for undefined results of binary operators.
.. code-block :: c
void test() {
int x;
int y = x + 1; // warn: left operand is garbage
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _core-VLASize:
2019-02-11 23:17:13 +08:00
core.VLASize (C)
2019-02-05 08:39:33 +08:00
""""""""""""""""
Check for declarations of Variable Length Arrays of undefined or zero size.
Check for declarations of VLA of undefined or zero size.
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
.. code-block :: c
void test() {
int x;
int vla1[x]; // warn: garbage as size
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
int x = 0;
int vla2[x]; // warn: zero size
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _core-uninitialized-ArraySubscript:
2019-02-05 08:39:33 +08:00
core.uninitialized.ArraySubscript (C)
"""""""""""""""""""""""""""""""""""""
Check for uninitialized values used as array subscripts.
.. code-block :: c
void test() {
int i, a[10];
int x = a[i]; // warn: array subscript is undefined
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _core-uninitialized-Assign:
2019-02-05 08:39:33 +08:00
core.uninitialized.Assign (C)
"""""""""""""""""""""""""""""
Check for assigning uninitialized values.
.. code-block :: c
void test() {
int x;
x |= 1; // warn: left expression is uninitialized
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _core-uninitialized-Branch:
2019-02-05 08:39:33 +08:00
core.uninitialized.Branch (C)
"""""""""""""""""""""""""""""
Check for uninitialized values used as branch conditions.
.. code-block :: c
void test() {
int x;
if (x) // warn
return;
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _core-uninitialized-CapturedBlockVariable:
2019-02-05 08:39:33 +08:00
core.uninitialized.CapturedBlockVariable (C)
""""""""""""""""""""""""""""""""""""""""""""
Check for blocks that capture uninitialized values.
.. code-block :: c
void test() {
int x;
^{ int y = x; }(); // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _core-uninitialized-UndefReturn:
2019-02-05 08:39:33 +08:00
core.uninitialized.UndefReturn (C)
""""""""""""""""""""""""""""""""""
Check for uninitialized values being returned to the caller.
.. code-block :: c
int test() {
int x;
return x; // warn
}
.. _cplusplus-checkers:
[Analyzer] Checker for non-determinism caused by iteration of unordered container of pointers
Summary: Added a checker for non-determinism caused by iterating unordered containers like std::unordered_set containing pointer elements.
Reviewers: NoQ, george.karpenkov, whisperity, Szelethus, baloghadamsoftware
Reviewed By: Szelethus
Subscribers: mgorny, xazax.hun, baloghadamsoftware, szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy, dkrupp, jdoerfert, Charusso, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D59279
llvm-svn: 361664
2019-05-25 03:24:08 +08:00
cplusplus
^^^^^^^^^
2019-02-05 08:39:33 +08:00
C++ Checkers.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _cplusplus-InnerPointer:
2019-08-15 16:52:10 +08:00
cplusplus.InnerPointer (C++)
""""""""""""""""""""""""""""
2019-02-05 08:39:33 +08:00
Check for inner pointers of C++ containers used after re/deallocation.
2019-08-15 16:52:10 +08:00
Many container methods in the C++ standard library are known to invalidate
"references" (including actual references, iterators and raw pointers) to
elements of the container. Using such references after they are invalidated
causes undefined behavior, which is a common source of memory errors in C++ that
this checker is capable of finding.
The checker is currently limited to `` std::string `` objects and doesn't
recognize some of the more sophisticated approaches to passing unowned pointers
around, such as `` std::string_view `` .
.. code-block :: cpp
void deref_after_assignment() {
std::string s = "llvm";
const char *c = s.data(); // note: pointer to inner buffer of 'std::string' obtained here
s = "clang"; // note: inner buffer of 'std::string' reallocated by call to 'operator='
consume(c); // warn: inner pointer of container used after re/deallocation
}
const char *return_temp(int x) {
return std::to_string(x).c_str(); // warn: inner pointer of container used after re/deallocation
// note: pointer to inner buffer of 'std::string' obtained here
// note: inner buffer of 'std::string' deallocated by call to destructor
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _cplusplus-NewDelete:
2019-02-11 23:17:13 +08:00
cplusplus.NewDelete (C++)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""""
Check for double-free and use-after-free problems. Traces memory managed by new/delete.
.. literalinclude :: checkers/newdelete_example.cpp
:language: cpp
2019-02-11 23:17:13 +08:00
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _cplusplus-NewDeleteLeaks:
2019-02-11 23:17:13 +08:00
cplusplus.NewDeleteLeaks (C++)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""""""""
Check for memory leaks. Traces memory managed by new/delete.
.. code-block :: cpp
void test() {
int *p = new int;
} // warn
2020-01-10 23:51:14 +08:00
.. _cplusplus-PlacementNewChecker:
cplusplus.PlacementNewChecker (C++)
"""""""""""""""""""""""""""""""""""
Check if default placement new is provided with pointers to sufficient storage capacity.
.. code-block :: cpp
#include <new>
void f() {
short s;
long *lp = ::new (&s) long; // warn
}
2019-02-05 08:39:33 +08:00
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _cplusplus-SelfAssignment:
2019-02-11 23:17:13 +08:00
cplusplus.SelfAssignment (C++)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""""""""
Checks C++ copy and move assignment operators for self assignment.
.. _deadcode-checkers:
deadcode
^^^^^^^^
Dead Code Checkers.
2019-02-11 23:17:13 +08:00
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _deadcode-DeadStores:
2019-02-11 23:17:13 +08:00
deadcode.DeadStores (C)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""
Check for values stored to variables that are never read afterwards.
.. code-block :: c
void test() {
int x;
x = 1; // warn
}
2019-09-03 23:22:43 +08:00
The `` WarnForDeadNestedAssignments `` option enables the checker to emit
warnings for nested dead assignments. You can disable with the
`` -analyzer-config deadcode.DeadStores:WarnForDeadNestedAssignments=false `` .
*Defaults to true* .
Would warn for this e.g.:
if ((y = make_int())) {
}
2019-02-05 08:39:33 +08:00
.. _nullability-checkers:
nullability
^^^^^^^^^^^
Objective C checkers that warn for null pointer passing and dereferencing errors.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _nullability-NullPassedToNonnull:
2019-02-05 08:39:33 +08:00
nullability.NullPassedToNonnull (ObjC)
""""""""""""""""""""""""""""""""""""""
Warns when a null pointer is passed to a pointer which has a _Nonnull type.
.. code-block :: objc
if (name != nil)
return;
// Warning: nil passed to a callee that requires a non-null 1st parameter
NSString *greeting = [@"Hello " stringByAppendingString:name];
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _nullability-NullReturnedFromNonnull:
2019-02-11 23:17:13 +08:00
nullability.NullReturnedFromNonnull (ObjC)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""""""""""""""""""""
Warns when a null pointer is returned from a function that has _Nonnull return type.
.. code-block :: objc
- (nonnull id)firstChild {
id result = nil;
if ([_children count] > 0)
result = _children[0];
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
// Warning: nil returned from a method that is expected
// to return a non-null value
return result;
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _nullability-NullableDereferenced:
2019-02-05 08:39:33 +08:00
nullability.NullableDereferenced (ObjC)
"""""""""""""""""""""""""""""""""""""""
Warns when a nullable pointer is dereferenced.
.. code-block :: objc
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
struct LinkedList {
int data;
struct LinkedList *next;
};
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
struct LinkedList * _Nullable getNext(struct LinkedList * l);
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void updateNextData(struct LinkedList *list, int newData) {
struct LinkedList *next = getNext(list);
// Warning: Nullable pointer is dereferenced
next->data = 7;
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _nullability-NullablePassedToNonnull:
2019-02-05 08:39:33 +08:00
nullability.NullablePassedToNonnull (ObjC)
""""""""""""""""""""""""""""""""""""""""""
Warns when a nullable pointer is passed to a pointer which has a _Nonnull type.
.. code-block :: objc
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
typedef struct Dummy { int val; } Dummy;
Dummy *_Nullable returnsNullable();
void takesNonnull(Dummy *_Nonnull);
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
Dummy *p = returnsNullable();
takesNonnull(p); // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _nullability-NullableReturnedFromNonnull:
2019-02-11 23:17:13 +08:00
nullability.NullableReturnedFromNonnull (ObjC)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""""""""""""""""""""""""
Warns when a nullable pointer is returned from a function that has _Nonnull return type.
.. _optin-checkers:
optin
^^^^^
Checkers for portability, performance or coding style specific rules.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _optin-cplusplus-UninitializedObject:
2019-04-20 07:33:50 +08:00
optin.cplusplus.UninitializedObject (C++)
2019-05-04 02:54:18 +08:00
"""""""""""""""""""""""""""""""""""""""""
2019-04-20 07:33:50 +08:00
This checker reports uninitialized fields in objects created after a constructor
call. It doesn't only find direct uninitialized fields, but rather makes a deep
inspection of the object, analyzing all of it's fields subfields.
2020-01-20 07:13:08 +08:00
The checker regards inherited fields as direct fields, so one will receive
2019-04-20 07:33:50 +08:00
warnings for uninitialized inherited data members as well.
.. code-block :: cpp
// With Pedantic and CheckPointeeInitialization set to true
struct A {
struct B {
int x; // note: uninitialized field 'this->b.x'
// note: uninitialized field 'this->bptr->x'
int y; // note: uninitialized field 'this->b.y'
// note: uninitialized field 'this->bptr->y'
};
int *iptr; // note: uninitialized pointer 'this->iptr'
B b;
B *bptr;
char *cptr; // note: uninitialized pointee 'this->cptr'
A (B *bptr, char * cptr) : bptr(bptr), cptr(cptr) {}
};
void f() {
A::B b;
char c;
A a(&b, &c); // warning: 6 uninitialized fields
// after the constructor call
}
// With Pedantic set to false and
// CheckPointeeInitialization set to true
// (every field is uninitialized)
struct A {
struct B {
int x;
int y;
};
int *iptr;
B b;
B *bptr;
char *cptr;
A (B *bptr, char * cptr) : bptr(bptr), cptr(cptr) {}
};
void f() {
A::B b;
char c;
A a(&b, &c); // no warning
}
// With Pedantic set to true and
// CheckPointeeInitialization set to false
// (pointees are regarded as initialized)
struct A {
struct B {
int x; // note: uninitialized field 'this->b.x'
int y; // note: uninitialized field 'this->b.y'
};
int *iptr; // note: uninitialized pointer 'this->iptr'
B b;
B *bptr;
char *cptr;
A (B *bptr, char * cptr) : bptr(bptr), cptr(cptr) {}
};
void f() {
A::B b;
char c;
A a(&b, &c); // warning: 3 uninitialized fields
// after the constructor call
}
**Options**
This checker has several options which can be set from command line (e.g.
`` -analyzer-config optin.cplusplus.UninitializedObject:Pedantic=true `` ):
* `` Pedantic `` (boolean). If to false, the checker won't emit warnings for
objects that don't have at least one initialized field. Defaults to false.
* `` NotesAsWarnings `` (boolean). If set to true, the checker will emit a
2020-01-20 07:13:08 +08:00
warning for each uninitialized field, as opposed to emitting one warning per
2019-04-20 07:33:50 +08:00
constructor call, and listing the uninitialized fields that belongs to it in
notes. *Defaults to false* .
* `` CheckPointeeInitialization `` (boolean). If set to false, the checker will
not analyze the pointee of pointer/reference fields, and will only check
whether the object itself is initialized. *Defaults to false* .
* `` IgnoreRecordsWithField `` (string). If supplied, the checker will not analyze
structures that have a field with a name or type name that matches the given
pattern. *Defaults to ""* .
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _optin-cplusplus-VirtualCall:
2019-02-05 08:39:33 +08:00
optin.cplusplus.VirtualCall (C++)
"""""""""""""""""""""""""""""""""
Check virtual function calls during construction or destruction.
.. code-block :: cpp
class A {
public:
A() {
f(); // warn
}
virtual void f();
};
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
class A {
public:
~A() {
this->f(); // warn
}
virtual void f();
};
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _optin-mpi-MPI-Checker:
2019-02-05 08:39:33 +08:00
optin.mpi.MPI-Checker (C)
"""""""""""""""""""""""""
Checks MPI code.
.. code-block :: c
void test() {
double buf = 0;
MPI_Request sendReq1;
MPI_Ireduce(MPI_IN_PLACE, &buf, 1, MPI_DOUBLE, MPI_SUM,
0, MPI_COMM_WORLD, &sendReq1);
} // warn: request 'sendReq1' has no matching wait.
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
double buf = 0;
MPI_Request sendReq;
MPI_Isend(&buf, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, &sendReq);
MPI_Irecv(&buf, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, &sendReq); // warn
MPI_Isend(&buf, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, &sendReq); // warn
MPI_Wait(&sendReq, MPI_STATUS_IGNORE);
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void missingNonBlocking() {
int rank = 0;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Request sendReq1[10][10][10];
MPI_Wait(&sendReq1[1][7][9], MPI_STATUS_IGNORE); // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _optin-osx-cocoa-localizability-EmptyLocalizationContextChecker:
2019-02-05 08:39:33 +08:00
optin.osx.cocoa.localizability.EmptyLocalizationContextChecker (ObjC)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Check that NSLocalizedString macros include a comment for context.
.. code-block :: objc
- (void)test {
NSString *string = NSLocalizedString(@"LocalizedString", nil); // warn
NSString *string2 = NSLocalizedString(@"LocalizedString", @" "); // warn
NSString *string3 = NSLocalizedStringWithDefaultValue(
@"LocalizedString", nil, [[NSBundle alloc] init], nil,@""); // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _optin-osx-cocoa-localizability-NonLocalizedStringChecker:
2019-02-11 23:17:13 +08:00
optin.osx.cocoa.localizability.NonLocalizedStringChecker (ObjC)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Warns about uses of non-localized NSStrings passed to UI methods expecting localized NSStrings.
.. code-block :: objc
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
NSString *alarmText =
NSLocalizedString(@"Enabled", @"Indicates alarm is turned on");
if (!isEnabled) {
alarmText = @"Disabled";
}
UILabel *alarmStateLabel = [[UILabel alloc] init];
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
// Warning: User-facing text should use localized string macro
[alarmStateLabel setText:alarmText];
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _optin-performance-GCDAntipattern:
2019-02-05 08:39:33 +08:00
optin.performance.GCDAntipattern
""""""""""""""""""""""""""""""""
Check for performance anti-patterns when using Grand Central Dispatch.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _optin-performance-Padding:
2019-02-05 08:39:33 +08:00
optin.performance.Padding
"""""""""""""""""""""""""
Check for excessively padded structs.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _optin-portability-UnixAPI:
2019-02-05 08:39:33 +08:00
optin.portability.UnixAPI
"""""""""""""""""""""""""
Finds implementation-defined behavior in UNIX/Posix functions.
.. _security-checkers:
security
^^^^^^^^
Security related checkers.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _security-FloatLoopCounter:
2019-02-11 23:17:13 +08:00
security.FloatLoopCounter (C)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""""""""
Warn on using a floating point value as a loop counter (CERT: FLP30-C, FLP30-CPP).
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
for (float x = 0.1f; x <= 1.0f; x += 0.1f) {} // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _security-insecureAPI-UncheckedReturn:
2019-02-11 23:17:13 +08:00
security.insecureAPI.UncheckedReturn (C)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""""""""""""""""""
Warn on uses of functions whose return values must be always checked.
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
setuid(1); // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _security-insecureAPI-bcmp:
2019-02-05 08:39:33 +08:00
security.insecureAPI.bcmp (C)
"""""""""""""""""""""""""""""
Warn on uses of the 'bcmp' function.
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
bcmp(ptr0, ptr1, n); // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _security-insecureAPI-bcopy:
2019-02-05 08:39:33 +08:00
security.insecureAPI.bcopy (C)
""""""""""""""""""""""""""""""
Warn on uses of the 'bcopy' function.
.. code-block :: c
void test() {
bcopy(src, dst, n); // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _security-insecureAPI-bzero:
2019-02-05 08:39:33 +08:00
security.insecureAPI.bzero (C)
""""""""""""""""""""""""""""""
Warn on uses of the 'bzero' function.
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
bzero(ptr, n); // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _security-insecureAPI-getpw:
2019-02-11 23:17:13 +08:00
security.insecureAPI.getpw (C)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""""""""
Warn on uses of the 'getpw' function.
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
char buff[1024];
getpw(2, buff); // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _security-insecureAPI-gets:
2019-02-05 08:39:33 +08:00
security.insecureAPI.gets (C)
"""""""""""""""""""""""""""""
Warn on uses of the 'gets' function.
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
char buff[1024];
gets(buff); // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _security-insecureAPI-mkstemp:
2019-02-05 08:39:33 +08:00
security.insecureAPI.mkstemp (C)
""""""""""""""""""""""""""""""""
Warn when 'mkstemp' is passed fewer than 6 X's in the format string.
.. code-block :: c
void test() {
mkstemp("XX"); // warn
}
2019-02-11 23:17:13 +08:00
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _security-insecureAPI-mktemp:
2019-02-11 23:17:13 +08:00
security.insecureAPI.mktemp (C)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""""""""""
Warn on uses of the `` mktemp `` function.
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
char *x = mktemp("/tmp/zxcv"); // warn: insecure, use mkstemp
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _security-insecureAPI-rand:
2019-02-11 23:17:13 +08:00
security.insecureAPI.rand (C)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""""""""
2019-02-11 23:17:13 +08:00
Warn on uses of inferior random number generating functions (only if arc4random function is available):
2019-02-05 08:39:33 +08:00
`` drand48, erand48, jrand48, lcong48, lrand48, mrand48, nrand48, random, rand_r `` .
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
random(); // warn
}
2019-02-11 23:17:13 +08:00
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _security-insecureAPI-strcpy:
2019-02-05 08:39:33 +08:00
security.insecureAPI.strcpy (C)
"""""""""""""""""""""""""""""""
Warn on uses of the `` strcpy `` and `` strcat `` functions.
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
char x[4];
char *y = "abcd";
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
strcpy(x, y); // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _security-insecureAPI-vfork:
2019-02-11 23:17:13 +08:00
security.insecureAPI.vfork (C)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""""""""
Warn on uses of the 'vfork' function.
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
vfork(); // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _security-insecureAPI-DeprecatedOrUnsafeBufferHandling:
2019-02-11 23:17:13 +08:00
security.insecureAPI.DeprecatedOrUnsafeBufferHandling (C)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2019-02-11 21:46:43 +08:00
Warn on occurrences of unsafe or deprecated buffer handling functions, which now have a secure variant: `` sprintf, vsprintf, scanf, wscanf, fscanf, fwscanf, vscanf, vwscanf, vfscanf, vfwscanf, sscanf, swscanf, vsscanf, vswscanf, swprintf, snprintf, vswprintf, vsnprintf, memcpy, memmove, strncpy, strncat, memset ``
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-11 21:46:43 +08:00
void test() {
char buf [5];
strncpy(buf, "a", 1); // warn
}
2019-02-05 08:39:33 +08:00
.. _unix-checkers:
unix
^^^^
POSIX/Unix checkers.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _unix-API:
2019-02-11 23:17:13 +08:00
unix.API (C)
2019-02-05 08:39:33 +08:00
""""""""""""
Check calls to various UNIX/Posix functions: `` open, pthread_once, calloc, malloc, realloc, alloca `` .
2019-02-11 23:17:13 +08:00
.. literalinclude :: checkers/unix_api_example.c
2019-02-05 08:39:33 +08:00
:language: c
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _unix-Malloc:
2019-02-11 23:17:13 +08:00
unix.Malloc (C)
2019-02-05 08:39:33 +08:00
"""""""""""""""
Check for memory leaks, double free, and use-after-free problems. Traces memory managed by malloc()/free().
2019-02-11 23:17:13 +08:00
.. literalinclude :: checkers/unix_malloc_example.c
2019-02-05 08:39:33 +08:00
:language: c
2019-02-11 23:17:13 +08:00
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _unix-MallocSizeof:
2019-02-11 23:17:13 +08:00
unix.MallocSizeof (C)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""
Check for dubious `` malloc `` arguments involving `` sizeof `` .
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
long *p = malloc(sizeof(short));
// warn: result is converted to 'long *', which is
// incompatible with operand type 'short'
free(p);
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _unix-MismatchedDeallocator:
2019-02-05 08:39:33 +08:00
unix.MismatchedDeallocator (C, C++)
"""""""""""""""""""""""""""""""""""
Check for mismatched deallocators.
2019-02-11 23:17:13 +08:00
.. literalinclude :: checkers/mismatched_deallocator_example.cpp
2019-02-05 08:39:33 +08:00
:language: c
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _unix-Vfork:
2019-02-11 23:17:13 +08:00
unix.Vfork (C)
2019-02-05 08:39:33 +08:00
""""""""""""""
Check for proper usage of `` vfork `` .
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
int test(int x) {
pid_t pid = vfork(); // warn
if (pid != 0)
return 0;
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
switch (x) {
case 0:
pid = 1;
execl("", "", 0);
_exit(1);
break;
case 1:
x = 0; // warn: this assignment is prohibited
break;
case 2:
foo(); // warn: this function call is prohibited
break;
default:
return 0; // warn: return is prohibited
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
while(1);
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _unix-cstring-BadSizeArg:
2019-02-11 23:17:13 +08:00
unix.cstring.BadSizeArg (C)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""""""
2019-02-11 23:17:13 +08:00
Check the size argument passed into C string functions for common erroneous patterns. Use `` -Wno-strncat-size `` compiler option to mute other `` strncat `` -related compiler warnings.
2019-02-05 08:39:33 +08:00
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
char dest[3];
strncat(dest, """""""""""""""""""""""""*", sizeof(dest));
// warn: potential buffer overflow
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _unix-cstrisng-NullArg:
2019-02-11 23:17:13 +08:00
unix.cstrisng.NullArg (C)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""""
2019-02-11 23:17:13 +08:00
Check for null pointers being passed as arguments to C string functions:
2019-02-05 08:39:33 +08:00
`` strlen, strnlen, strcpy, strncpy, strcat, strncat, strcmp, strncmp, strcasecmp, strncasecmp `` .
.. code-block :: c
int test() {
return strlen(0); // warn
}
.. _osx-checkers:
osx
^^^
[Docs] Modernize references to macOS
Summary:
This updates all places in documentation that refer to "Mac OS X", "OS X", etc.
to instead use the modern name "macOS" when no specific version number is
mentioned.
If a specific version is mentioned, this attempts to use the OS name at the time
of that version:
* Mac OS X for 10.0 - 10.7
* OS X for 10.8 - 10.11
* macOS for 10.12 - present
Reviewers: JDevlieghere
Subscribers: mgorny, christof, arphaman, cfe-commits, lldb-commits, libcxx-commits, llvm-commits
Tags: #clang, #lldb, #libc, #llvm
Differential Revision: https://reviews.llvm.org/D62654
llvm-svn: 362113
2019-05-31 00:46:22 +08:00
macOS checkers.
2019-02-11 23:17:13 +08:00
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-API:
2019-02-11 23:17:13 +08:00
osx.API (C)
2019-02-05 08:39:33 +08:00
"""""""""""
Check for proper uses of various Apple APIs.
.. code-block :: objc
void test() {
dispatch_once_t pred = 0;
dispatch_once(&pred, ^(){}); // warn: dispatch_once uses local
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-NumberObjectConversion:
2019-02-05 08:39:33 +08:00
osx.NumberObjectConversion (C, C++, ObjC)
"""""""""""""""""""""""""""""""""""""""""
Check for erroneous conversions of objects representing numbers into numbers.
.. code-block :: objc
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
NSNumber *photoCount = [albumDescriptor objectForKey:@"PhotoCount"];
// Warning: Comparing a pointer value of type 'NSNumber *'
// to a scalar integer value
if (photoCount > 0) {
[self displayPhotos];
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-ObjCProperty:
2019-02-05 08:39:33 +08:00
osx.ObjCProperty (ObjC)
"""""""""""""""""""""""
Check for proper uses of Objective-C properties.
.. code-block :: objc
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
NSNumber *photoCount = [albumDescriptor objectForKey:@"PhotoCount"];
// Warning: Comparing a pointer value of type 'NSNumber *'
// to a scalar integer value
if (photoCount > 0) {
[self displayPhotos];
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-SecKeychainAPI:
2019-02-11 23:17:13 +08:00
osx.SecKeychainAPI (C)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""
Check for proper uses of Secure Keychain APIs.
2019-02-11 23:17:13 +08:00
.. literalinclude :: checkers/seckeychainapi_example.m
2019-02-05 08:39:33 +08:00
:language: objc
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-cocoa-AtSync:
2019-02-05 08:39:33 +08:00
osx.cocoa.AtSync (ObjC)
"""""""""""""""""""""""
Check for nil pointers used as mutexes for @synchronized.
.. code-block :: objc
void test(id x) {
if (!x)
@synchronized(x) {} // warn: nil value used as mutex
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
id y;
@synchronized(y) {} // warn: uninitialized value used as mutex
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-cocoa-AutoreleaseWrite:
2019-02-05 08:39:33 +08:00
osx.cocoa.AutoreleaseWrite
2019-02-11 23:17:13 +08:00
""""""""""""""""""""""""""
2019-02-05 08:39:33 +08:00
Warn about potentially crashing writes to autoreleasing objects from different autoreleasing pools in Objective-C.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-cocoa-ClassRelease:
2019-02-05 08:39:33 +08:00
osx.cocoa.ClassRelease (ObjC)
"""""""""""""""""""""""""""""
Check for sending 'retain', 'release', or 'autorelease' directly to a Class.
.. code-block :: objc
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@interface MyClass : NSObject
@end
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test(void) {
[MyClass release]; // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-cocoa-Dealloc:
2019-02-05 08:39:33 +08:00
osx.cocoa.Dealloc (ObjC)
""""""""""""""""""""""""
Warn about Objective-C classes that lack a correct implementation of -dealloc
2019-02-11 23:17:13 +08:00
.. literalinclude :: checkers/dealloc_example.m
2019-02-05 08:39:33 +08:00
:language: objc
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-cocoa-IncompatibleMethodTypes:
2019-02-11 23:17:13 +08:00
osx.cocoa.IncompatibleMethodTypes (ObjC)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""""""""""""""""""
Warn about Objective-C method signatures with type incompatibilities.
.. code-block :: objc
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@interface MyClass1 : NSObject
- (int)foo;
@end
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@implementation MyClass1
- (int)foo { return 1; }
@end
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@interface MyClass2 : MyClass1
- (float)foo;
@end
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@implementation MyClass2
- (float)foo { return 1.0; } // warn
@end
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-cocoa-Loops:
2019-02-05 08:39:33 +08:00
osx.cocoa.Loops
"""""""""""""""
Improved modeling of loops using Cocoa collection types.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-cocoa-MissingSuperCall:
2019-02-05 08:39:33 +08:00
osx.cocoa.MissingSuperCall (ObjC)
"""""""""""""""""""""""""""""""""
Warn about Objective-C methods that lack a necessary call to super.
.. code-block :: objc
@interface Test : UIViewController
@end
@implementation test
- (void)viewDidLoad {} // warn
@end
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-cocoa-NSAutoreleasePool:
2019-02-05 08:39:33 +08:00
osx.cocoa.NSAutoreleasePool (ObjC)
""""""""""""""""""""""""""""""""""
Warn for suboptimal uses of NSAutoreleasePool in Objective-C GC mode.
.. code-block :: objc
void test() {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[pool release]; // warn
}
2019-02-11 23:17:13 +08:00
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-cocoa-NSError:
2019-02-11 23:17:13 +08:00
osx.cocoa.NSError (ObjC)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""
Check usage of NSError parameters.
.. code-block :: objc
@interface A : NSObject
- (void)foo:(NSError """""""""""""""""""""""")error;
@end
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@implementation A
- (void)foo:(NSError """""""""""""""""""""""")error {
// warn: method accepting NSError"""""""""""""""""""""""" should have a non-void
// return value
}
@end
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@interface A : NSObject
- (BOOL)foo:(NSError """""""""""""""""""""""")error;
@end
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@implementation A
- (BOOL)foo:(NSError """""""""""""""""""""""")error {
*error = 0; // warn: potential null dereference
return 0;
}
@end
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-cocoa-NilArg:
2019-02-11 23:17:13 +08:00
osx.cocoa.NilArg (ObjC)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""
Check for prohibited nil arguments to ObjC method calls.
- caseInsensitiveCompare:
- compare:
- compare:options:
- compare:options:range:
- compare:options:range:locale:
2019-02-11 23:17:13 +08:00
- componentsSeparatedByCharactersInSet:
2019-02-05 08:39:33 +08:00
- initWithFormat:
.. code-block :: objc
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
NSComparisonResult test(NSString *s) {
NSString *aString = nil;
return [s caseInsensitiveCompare:aString];
// warn: argument to 'NSString' method
// 'caseInsensitiveCompare:' cannot be nil
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-cocoa-NonNilReturnValue:
2019-02-05 08:39:33 +08:00
osx.cocoa.NonNilReturnValue
"""""""""""""""""""""""""""
Models the APIs that are guaranteed to return a non-nil value.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-cocoa-ObjCGenerics:
2019-02-11 23:17:13 +08:00
osx.cocoa.ObjCGenerics (ObjC)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""""""""
Check for type errors when using Objective-C generics.
.. code-block :: objc
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
NSMutableArray *names = [NSMutableArray array];
NSMutableArray *birthDates = names;
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
// Warning: Conversion from value of type 'NSDate *'
// to incompatible type 'NSString *'
[birthDates addObject: [NSDate date]];
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-cocoa-RetainCount:
2019-02-11 23:17:13 +08:00
osx.cocoa.RetainCount (ObjC)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""""""
Check for leaks and improper reference count management
.. code-block :: objc
void test() {
NSString *s = [[NSString alloc] init]; // warn
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
CFStringRef test(char *bytes) {
return CFStringCreateWithCStringNoCopy(
0, bytes, NSNEXTSTEPStringEncoding, 0); // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-cocoa-RunLoopAutoreleaseLeak:
2019-02-05 08:39:33 +08:00
osx.cocoa.RunLoopAutoreleaseLeak
""""""""""""""""""""""""""""""""
Check for leaked memory in autorelease pools that will never be drained.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-cocoa-SelfInit:
2019-02-05 08:39:33 +08:00
osx.cocoa.SelfInit (ObjC)
"""""""""""""""""""""""""
Check that 'self' is properly initialized inside an initializer method.
.. code-block :: objc
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@interface MyObj : NSObject {
id x;
}
- (id)init;
@end
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@implementation MyObj
- (id)init {
[super init];
x = 0; // warn: instance variable used while 'self' is not
// initialized
return 0;
}
@end
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@interface MyObj : NSObject
- (id)init;
@end
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@implementation MyObj
- (id)init {
[super init];
return self; // warn: returning uninitialized 'self'
}
@end
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-cocoa-SuperDealloc:
2019-02-11 23:17:13 +08:00
osx.cocoa.SuperDealloc (ObjC)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""""""""
Warn about improper use of '[super dealloc]' in Objective-C.
.. code-block :: objc
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@interface SuperDeallocThenReleaseIvarClass : NSObject {
NSObject *_ivar;
}
@end
@implementation SuperDeallocThenReleaseIvarClass
- (void)dealloc {
[super dealloc];
[_ivar release]; // warn
}
@end
2019-02-11 23:17:13 +08:00
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-cocoa-UnusedIvars:
2019-02-05 08:39:33 +08:00
osx.cocoa.UnusedIvars (ObjC)
""""""""""""""""""""""""""""
Warn about private ivars that are never used.
.. code-block :: objc
@interface MyObj : NSObject {
@private
id x; // warn
}
@end
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@implementation MyObj
@end
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-cocoa-VariadicMethodTypes:
2019-02-05 08:39:33 +08:00
osx.cocoa.VariadicMethodTypes (ObjC)
""""""""""""""""""""""""""""""""""""
2019-02-11 23:17:13 +08:00
Check for passing non-Objective-C types to variadic collection
2019-02-05 08:39:33 +08:00
initialization methods that expect only Objective-C types.
.. code-block :: objc
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
[NSSet setWithObjects:@"Foo", "Bar", nil];
// warn: argument should be an ObjC pointer type, not 'char *'
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-coreFoundation-CFError:
2019-02-11 23:17:13 +08:00
osx.coreFoundation.CFError (C)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""""""""
Check usage of CFErrorRef* parameters
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test(CFErrorRef *error) {
// warn: function accepting CFErrorRef* should have a
// non-void return
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
int foo(CFErrorRef *error) {
*error = 0; // warn: potential null dereference
return 0;
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-coreFoundation-CFNumber:
2019-02-11 23:17:13 +08:00
osx.coreFoundation.CFNumber (C)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""""""""""
Check for proper uses of CFNumber APIs.
.. code-block :: c
CFNumberRef test(unsigned char x) {
return CFNumberCreate(0, kCFNumberSInt16Type, &x);
// warn: 8 bit integer is used to initialize a 16 bit integer
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-coreFoundation-CFRetainRelease:
2019-02-11 23:17:13 +08:00
osx.coreFoundation.CFRetainRelease (C)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""""""""""""""""
Check for null arguments to CFRetain/CFRelease/CFMakeCollectable.
.. code-block :: c
void test(CFTypeRef p) {
if (!p)
CFRetain(p); // warn
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test(int x, CFTypeRef p) {
if (p)
return;
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
CFRelease(p); // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-coreFoundation-containers-OutOfBounds:
2019-02-11 23:17:13 +08:00
osx.coreFoundation.containers.OutOfBounds (C)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""""""""""""""""""""""""
Checks for index out-of-bounds when using 'CFArray' API.
.. code-block :: c
void test() {
CFArrayRef A = CFArrayCreate(0, 0, 0, &kCFTypeArrayCallBacks);
CFArrayGetValueAtIndex(A, 0); // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _osx-coreFoundation-containers-PointerSizedValues:
2019-02-11 23:17:13 +08:00
osx.coreFoundation.containers.PointerSizedValues (C)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""""""""""""""""""""""""""""""
Warns if 'CFArray', 'CFDictionary', 'CFSet' are created with non-pointer-size values.
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
int x[] = { 1 };
CFArrayRef A = CFArrayCreate(0, (const void """""""""""""""""""""""")x, 1,
&kCFTypeArrayCallBacks); // warn
}
2019-11-16 08:00:46 +08:00
Fuchsia
^^^^^^^
Fuchsia is an open source capability-based operating system currently being
developed by Google. This section describes checkers that can find various
misuses of Fuchsia APIs.
.. _fuchsia-HandleChecker:
fuchsia.HandleChecker
""""""""""""""""""""""""""""
Handles identify resources. Similar to pointers they can be leaked,
double freed, or use after freed. This check attempts to find such problems.
.. code-block :: cpp
void checkLeak08(int tag) {
zx_handle_t sa, sb;
zx_channel_create(0, &sa, &sb);
if (tag)
zx_handle_close(sa);
use(sb); // Warn: Potential leak of handle
zx_handle_close(sb);
}
2020-05-22 05:37:41 +08:00
WebKit
^^^^^^
WebKit is an open-source web browser engine available for macOS, iOS and Linux.
This section describes checkers that can find issues in WebKit codebase.
Most of the checkers focus on memory management for which WebKit uses custom implementation of reference counted smartpointers.
2020-06-03 07:03:24 +08:00
Checkers are formulated in terms related to ref-counting:
- *Ref-counted type* is either `` Ref<T> `` or `` RefPtr<T> `` .
- *Ref-countable type* is any type that implements `` ref() `` and `` deref() `` methods as `` RefPtr<> `` is a template (i. e. relies on duck typing).
- *Uncounted type* is ref-countable but not ref-counted type.
2020-05-22 05:37:41 +08:00
.. _webkit-RefCntblBaseVirtualDtor:
webkit.RefCntblBaseVirtualDtor
""""""""""""""""""""""""""""""""""""
All uncounted types used as base classes must have a virtual destructor.
Ref-counted types hold their ref-countable data by a raw pointer and allow implicit upcasting from ref-counted pointer to derived type to ref-counted pointer to base type. This might lead to an object of (dynamic) derived type being deleted via pointer to the base class type which C++ standard defines as UB in case the base class doesn't have virtual destructor `` [expr.delete] `` .
.. code-block :: cpp
2020-05-23 18:28:06 +08:00
2020-05-22 05:37:41 +08:00
struct RefCntblBase {
void ref() {}
void deref() {}
};
struct Derived : RefCntblBase { }; // warn
2019-02-05 08:39:33 +08:00
2020-06-16 04:58:34 +08:00
.. _webkit-NoUncountedMemberChecker:
2020-04-01 05:05:17 +08:00
2020-06-16 04:58:34 +08:00
webkit.NoUncountedMemberChecker
2020-06-16 04:29:08 +08:00
"""""""""""""""""""""""""""""""""""""
2020-04-01 05:05:17 +08:00
Raw pointers and references to uncounted types can't be used as class members. Only ref-counted types are allowed.
.. code-block :: cpp
2020-06-03 07:03:24 +08:00
2020-04-01 05:05:17 +08:00
struct RefCntbl {
void ref() {}
void deref() {}
};
struct Foo {
RefCntbl * ptr; // warn
RefCntbl & ptr; // warn
// ...
};
2020-06-30 12:34:44 +08:00
.. _webkit-UncountedLambdaCapturesChecker:
webkit.UncountedLambdaCapturesChecker
"""""""""""""""""""""""""""""""""""""
Raw pointers and references to uncounted types can't be captured in lambdas. Only ref-counted types are allowed.
.. code-block :: cpp
struct RefCntbl {
void ref() {}
void deref() {}
};
void foo(RefCntbl* a, RefCntbl& b) {
[&, a](){ // warn about 'a'
do_something(b); // warn about 'b'
};
};
2019-02-05 08:39:33 +08:00
.. _alpha-checkers:
Experimental Checkers
---------------------
*These are checkers with known issues or limitations that keep them from being on by default. They are likely to have false positives. Bug reports and especially patches are welcome.*
alpha.clone
^^^^^^^^^^^
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-clone-CloneChecker:
2019-02-11 23:17:13 +08:00
alpha.clone.CloneChecker (C, C++, ObjC)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""""""""""""""""""
Reports similar pieces of code.
.. code-block :: c
void log();
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
int max(int a, int b) { // warn
log();
if (a > b)
return a;
return b;
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
int maxClone(int x, int y) { // similar code here
log();
if (x > y)
return x;
return y;
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-core-BoolAssignment:
2019-02-05 08:39:33 +08:00
alpha.core.BoolAssignment (ObjC)
""""""""""""""""""""""""""""""""
Warn about assigning non-{0,1} values to boolean variables.
.. code-block :: objc
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
BOOL b = -1; // warn
2019-02-11 23:17:13 +08:00
}
2019-02-05 08:39:33 +08:00
alpha.core
^^^^^^^^^^
2020-08-25 19:49:41 +08:00
.. _alpha-core-C11Lock:
alpha.core.C11Lock
""""""""""""""""""
Similarly to :ref: `alpha.unix.PthreadLock <alpha-unix-PthreadLock>` , checks for
the locking/unlocking of `` mtx_t `` mutexes.
.. code-block :: cpp
mtx_t mtx1;
void bad1(void)
{
mtx_lock(&mtx1);
mtx_lock(&mtx1); // warn: This lock has already been acquired
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-core-CallAndMessageUnInitRefArg:
2019-02-05 08:39:33 +08:00
alpha.core.CallAndMessageUnInitRefArg (C,C++, ObjC)
"""""""""""""""""""""""""""""""""""""""""""""""""""
2019-02-11 23:17:13 +08:00
Check for logical errors for function calls and Objective-C
2019-02-05 08:39:33 +08:00
message expressions (e.g., uninitialized arguments, null function pointers, and pointer to undefined variables).
.. code-block :: c
void test(void) {
int t;
int &p = t;
int &s = p;
int &q = s;
foo(q); // warn
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test(void) {
int x;
foo(&x); // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-core-CastSize:
2019-02-05 08:39:33 +08:00
alpha.core.CastSize (C)
"""""""""""""""""""""""
Check when casting a malloc'ed type `` T `` , whether the size is a multiple of the size of `` T `` .
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
int *x = (int * ) malloc(11); // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-core-CastToStruct:
2019-02-05 08:39:33 +08:00
alpha.core.CastToStruct (C, C++)
2019-02-11 23:17:13 +08:00
""""""""""""""""""""""""""""""""
2019-02-05 08:39:33 +08:00
Check for cast from non-struct pointer to struct pointer.
.. code-block :: cpp
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
// C
struct s {};
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test(int *p) {
struct s *ps = (struct s * ) p; // warn
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
// C++
class c {};
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test(int *p) {
c *pc = (c * ) p; // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-core-Conversion:
2019-02-05 08:39:33 +08:00
alpha.core.Conversion (C, C++, ObjC)
""""""""""""""""""""""""""""""""""""
Loss of sign/precision in implicit conversions.
.. code-block :: c
void test(unsigned U, signed S) {
if (S > 10) {
if (U < S) {
}
}
if (S < -10) {
if (U < S) { // warn (loss of sign)
}
}
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
long long A = 1LL << 60;
short X = A; // warn (loss of precision)
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-core-DynamicTypeChecker:
2019-02-11 23:17:13 +08:00
alpha.core.DynamicTypeChecker (ObjC)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""""""""""""""
Check for cases where the dynamic and the static type of an object are unrelated.
.. code-block :: objc
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
id date = [NSDate date];
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
// Warning: Object has a dynamic type 'NSDate *' which is
// incompatible with static type 'NSNumber *'"
NSNumber *number = date;
[number doubleValue];
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-core-FixedAddr:
2019-02-11 23:17:13 +08:00
alpha.core.FixedAddr (C)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""
Check for assignment of a fixed address to a pointer.
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
int *p;
p = (int *) 0x10000; // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-core-IdenticalExpr:
2019-02-05 08:39:33 +08:00
alpha.core.IdenticalExpr (C, C++)
"""""""""""""""""""""""""""""""""
Warn about unintended use of identical expressions in operators.
.. code-block :: cpp
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
// C
void test() {
int a = 5;
int b = a | 4 | a; // warn: identical expr on both sides
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
// C++
bool f(void);
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test(bool b) {
int i = 10;
if (f()) { // warn: true and false branches are identical
do {
i--;
} while (f());
} else {
do {
i--;
} while (f());
}
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-core-PointerArithm:
2019-02-11 23:17:13 +08:00
alpha.core.PointerArithm (C)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""""""
Check for pointer arithmetic on locations other than array elements.
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
int x;
int *p;
p = &x + 1; // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-core-PointerSub:
2019-02-11 23:17:13 +08:00
alpha.core.PointerSub (C)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""""
Check for pointer subtractions on two pointers pointing to different memory chunks.
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
int x, y;
int d = &y - &x; // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-core-SizeofPtr:
2019-02-11 23:17:13 +08:00
alpha.core.SizeofPtr (C)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""
Warn about unintended use of `` sizeof() `` on pointer expressions.
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
struct s {};
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
int test(struct s *p) {
return sizeof(p);
// warn: sizeof(ptr) can produce an unexpected result
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-core-StackAddressAsyncEscape:
2019-02-11 23:17:13 +08:00
alpha.core.StackAddressAsyncEscape (C)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""""""""""""""""
2019-02-11 23:17:13 +08:00
Check that addresses to stack memory do not escape the function that involves dispatch_after or dispatch_async.
2019-02-05 08:39:33 +08:00
This checker is a part of `` core.StackAddressEscape `` , but is temporarily disabled until some false positives are fixed.
.. code-block :: c
dispatch_block_t test_block_inside_block_async_leak() {
int x = 123;
void (^inner)(void) = ^void(void) {
int y = x;
++y;
};
void (^outer)(void) = ^void(void) {
int z = x;
++z;
inner();
};
return outer; // warn: address of stack-allocated block is captured by a
// returned block
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-core-TestAfterDivZero:
2019-02-11 23:17:13 +08:00
alpha.core.TestAfterDivZero (C)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""""""""""
2019-02-11 23:17:13 +08:00
Check for division by variable that is later compared against 0.
2019-02-05 08:39:33 +08:00
Either the comparison is useless or there is division by zero.
.. code-block :: c
void test(int x) {
var = 77 / x;
if (x == 0) { } // warn
}
alpha.cplusplus
^^^^^^^^^^^^^^^
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-cplusplus-DeleteWithNonVirtualDtor:
2019-02-11 23:17:13 +08:00
alpha.cplusplus.DeleteWithNonVirtualDtor (C++)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""""""""""""""""""""""""
Reports destructions of polymorphic objects with a non-virtual destructor in their base class.
.. code-block :: cpp
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
NonVirtual *create() {
NonVirtual *x = new NVDerived(); // note: conversion from derived to base
// happened here
return x;
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void sink(NonVirtual *x) {
delete x; // warn: destruction of a polymorphic object with no virtual
// destructor
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-cplusplus-EnumCastOutOfRange:
2019-02-11 23:17:13 +08:00
alpha.cplusplus.EnumCastOutOfRange (C++)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""""""""""""""""""
2019-02-11 23:17:13 +08:00
Check for integer to enumeration casts that could result in undefined values.
2019-02-05 08:39:33 +08:00
.. code-block :: cpp
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
enum TestEnum {
A = 0
};
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void foo() {
TestEnum t = static_cast(-1);
// warn: the value provided to the cast expression is not in
2020-09-04 00:28:34 +08:00
// the valid range of values for the enum
2019-02-05 08:39:33 +08:00
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-cplusplus-InvalidatedIterator:
2019-02-11 23:17:13 +08:00
alpha.cplusplus.InvalidatedIterator (C++)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""""""""""""""""""""
Check for use of invalidated iterators.
.. code-block :: cpp
void bad_copy_assign_operator_list1(std::list &L1,
const std::list &L2) {
auto i0 = L1.cbegin();
L1 = L2;
*i0; // warn: invalidated iterator accessed
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-cplusplus-IteratorRange:
2019-02-05 08:39:33 +08:00
alpha.cplusplus.IteratorRange (C++)
"""""""""""""""""""""""""""""""""""
Check for iterators used outside their valid ranges.
.. code-block :: cpp
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void simple_bad_end(const std::vector &v) {
auto i = v.end();
*i; // warn: iterator accessed outside of its range
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-cplusplus-MismatchedIterator:
2019-02-11 23:17:13 +08:00
alpha.cplusplus.MismatchedIterator (C++)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""""""""""""""""""
Check for use of iterators of different containers where iterators of the same container are expected.
.. code-block :: cpp
void bad_insert3(std::vector &v1, std::vector &v2) {
v2.insert(v1.cbegin(), v2.cbegin(), v2.cend()); // warn: container accessed
// using foreign
// iterator argument
v1.insert(v1.cbegin(), v1.cbegin(), v2.cend()); // warn: iterators of
// different containers
// used where the same
// container is
// expected
v1.insert(v1.cbegin(), v2.cbegin(), v1.cend()); // warn: iterators of
// different containers
// used where the same
// container is
// expected
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-cplusplus-MisusedMovedObject:
2019-02-05 08:39:33 +08:00
alpha.cplusplus.MisusedMovedObject (C++)
""""""""""""""""""""""""""""""""""""""""
Method calls on a moved-from object and copying a moved-from object will be reported.
.. code-block :: cpp
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
struct A {
void foo() {}
};
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void f() {
A a;
A b = std::move(a); // note: 'a' became 'moved-from' here
a.foo(); // warn: method call on a 'moved-from' object 'a'
}
alpha.deadcode
^^^^^^^^^^^^^^
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-deadcode-UnreachableCode:
2019-02-11 23:17:13 +08:00
alpha.deadcode.UnreachableCode (C, C++)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""""""""""""""""""
Check unreachable code.
.. code-block :: cpp
// C
int test() {
int x = 1;
while(x);
return x; // warn
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
// C++
void test() {
int a = 2;
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
while (a > 1)
a--;
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
if (a > 1)
a++; // warn
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
// Objective-C
void test(id x) {
return;
[x retain]; // warn
}
2020-06-26 08:31:20 +08:00
.. _alpha-cplusplus-SmartPtr:
alpha.cplusplus.SmartPtr (C++)
""""""""""""""""""""""""""""""
Check for dereference of null smart pointers.
.. code-block :: cpp
void deref_smart_ptr() {
std::unique_ptr<int> P;
*P; // warn: dereference of a default constructed smart unique_ptr
}
2020-08-25 19:49:41 +08:00
alpha.fuchsia
^^^^^^^^^^^^^
.. _alpha-fuchsia-lock:
alpha.fuchsia.Lock
""""""""""""""""""
Similarly to :ref: `alpha.unix.PthreadLock <alpha-unix-PthreadLock>` , checks for
the locking/unlocking of fuchsia mutexes.
.. code-block :: cpp
spin_lock_t mtx1;
void bad1(void)
{
spin_lock(&mtx1);
spin_lock(&mtx1); // warn: This lock has already been acquired
}
2019-02-05 08:39:33 +08:00
alpha.llvm
^^^^^^^^^^
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-llvm-Conventions:
2019-02-05 08:39:33 +08:00
alpha.llvm.Conventions
""""""""""""""""""""""
Check code for LLVM codebase conventions:
* A StringRef should not be bound to a temporary std::string whose lifetime is shorter than the StringRef's.
* Clang AST nodes should not have fields that can allocate memory.
alpha.osx
^^^^^^^^^
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-osx-cocoa-DirectIvarAssignment:
2019-02-05 08:39:33 +08:00
alpha.osx.cocoa.DirectIvarAssignment (ObjC)
"""""""""""""""""""""""""""""""""""""""""""
Check for direct assignments to instance variables.
.. code-block :: objc
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@interface MyClass : NSObject {}
@property (readonly) id A;
- (void) foo;
@end
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@implementation MyClass
- (void) foo {
_A = 0; // warn
}
@end
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-osx-cocoa-DirectIvarAssignmentForAnnotatedFunctions:
2019-02-11 23:17:13 +08:00
alpha.osx.cocoa.DirectIvarAssignmentForAnnotatedFunctions (ObjC)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2019-02-11 23:17:13 +08:00
Check for direct assignments to instance variables in
2019-02-05 08:39:33 +08:00
the methods annotated with `` objc_no_direct_instance_variable_assignment `` .
.. code-block :: objc
@interface MyClass : NSObject {}
@property (readonly) id A;
- (void) fAnnotated __attribute__((
annotate("objc_no_direct_instance_variable_assignment")));
- (void) fNotAnnotated;
@end
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@implementation MyClass
- (void) fAnnotated {
_A = 0; // warn
}
- (void) fNotAnnotated {
_A = 0; // no warn
}
@end
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-osx-cocoa-InstanceVariableInvalidation:
2019-02-05 08:39:33 +08:00
alpha.osx.cocoa.InstanceVariableInvalidation (ObjC)
"""""""""""""""""""""""""""""""""""""""""""""""""""
2019-02-11 23:17:13 +08:00
Check that the invalidatable instance variables are
2019-02-05 08:39:33 +08:00
invalidated in the methods annotated with objc_instance_variable_invalidator.
.. code-block :: objc
@protocol Invalidation <NSObject>
- (void) invalidate
__attribute__((annotate("objc_instance_variable_invalidator")));
@end
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@interface InvalidationImpObj : NSObject <Invalidation>
@end
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@interface SubclassInvalidationImpObj : InvalidationImpObj {
InvalidationImpObj *var;
}
- (void)invalidate;
@end
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@implementation SubclassInvalidationImpObj
- (void) invalidate {}
@end
// warn: var needs to be invalidated or set to nil
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-osx-cocoa-MissingInvalidationMethod:
2019-02-05 08:39:33 +08:00
alpha.osx.cocoa.MissingInvalidationMethod (ObjC)
""""""""""""""""""""""""""""""""""""""""""""""""
Check that the invalidation methods are present in classes that contain invalidatable instance variables.
.. code-block :: objc
@protocol Invalidation <NSObject>
- (void)invalidate
__attribute__((annotate("objc_instance_variable_invalidator")));
@end
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@interface NeedInvalidation : NSObject <Invalidation>
@end
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@interface MissingInvalidationMethodDecl : NSObject {
NeedInvalidation *Var; // warn
}
@end
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
@implementation MissingInvalidationMethodDecl
@end
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-osx-cocoa-localizability-PluralMisuseChecker:
2019-02-11 23:17:13 +08:00
alpha.osx.cocoa.localizability.PluralMisuseChecker (ObjC)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Warns against using one vs. many plural pattern in code when generating localized strings.
.. code-block :: objc
NSString *reminderText =
NSLocalizedString(@"None", @"Indicates no reminders");
if (reminderCount == 1) {
// Warning: Plural cases are not supported across all languages.
// Use a .stringsdict file instead
reminderText =
NSLocalizedString(@"1 Reminder", @"Indicates single reminder");
} else if (reminderCount >= 2) {
// Warning: Plural cases are not supported across all languages.
// Use a .stringsdict file instead
reminderText =
[NSString stringWithFormat:
NSLocalizedString(@"%@ Reminders", @"Indicates multiple reminders"),
reminderCount];
}
alpha.security
^^^^^^^^^^^^^^
2020-02-20 01:10:31 +08:00
alpha.security.cert
^^^^^^^^^^^^^^^^^^^
2020-03-21 23:57:19 +08:00
SEI CERT checkers which tries to find errors based on their `C coding rules <https://wiki.sei.cmu.edu/confluence/display/c/2+Rules> `_ .
2020-02-20 01:10:31 +08:00
.. _alpha-security-cert-pos-checkers:
alpha.security.cert.pos
^^^^^^^^^^^^^^^^^^^^^^^
2020-03-21 23:57:19 +08:00
SEI CERT checkers of `POSIX C coding rules <https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152405> `_ .
2020-02-20 01:10:31 +08:00
.. _alpha-security-cert-pos-34c:
alpha.security.cert.pos.34c
"""""""""""""""""""""""""""
Finds calls to the `` putenv `` function which pass a pointer to an automatic variable as the argument.
.. code-block :: c
int func(const char *var) {
char env[1024];
int retval = snprintf(env, sizeof(env),"TEST=%s", var);
if (retval < 0 || (size_t)retval >= sizeof(env)) {
/* Handle error * /
}
return putenv(env); // putenv function should not be called with auto variables
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-security-ArrayBound:
2019-02-11 23:17:13 +08:00
alpha.security.ArrayBound (C)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""""""""
Warn about buffer overflows (older checker).
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
char *s = "";
char c = s[1]; // warn
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
struct seven_words {
int c[7];
};
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
struct seven_words a, *p;
p = &a;
p[0] = a;
p[1] = a;
p[2] = a; // warn
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
// note: requires unix.Malloc or
// alpha.unix.MallocWithAnnotations checks enabled.
void test() {
int *p = malloc(12);
p[3] = 4; // warn
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
char a[2];
int *b = (int* )a;
b[1] = 3; // warn
}
2019-02-11 23:17:13 +08:00
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-security-ArrayBoundV2:
2019-02-11 23:17:13 +08:00
alpha.security.ArrayBoundV2 (C)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""""""""""
Warn about buffer overflows (newer checker).
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
char *s = "";
char c = s[1]; // warn
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
int buf[100];
int *p = buf;
p = p + 99;
p[1] = 1; // warn
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
// note: compiler has internal check for this.
// Use -Wno-array-bounds to suppress compiler warning.
void test() {
int buf[100][100];
buf[0][-1] = 1; // warn
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
// note: requires alpha.security.taint check turned on.
void test() {
char s[] = "abc";
int x = getchar();
char c = s[x]; // warn: index is tainted
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-security-MallocOverflow:
2019-02-11 23:17:13 +08:00
alpha.security.MallocOverflow (C)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""""""""""""
Check for overflows in the arguments to malloc().
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test(int n) {
void *p = malloc(n * sizeof(int)); // warn
}
2019-11-24 03:55:19 +08:00
void test2(int n) {
if (n > 100) // gives an upper-bound
return;
void *p = malloc(n * sizeof(int)); // no warning
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-security-MmapWriteExec:
2019-02-11 23:17:13 +08:00
alpha.security.MmapWriteExec (C)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""""""""""
Warn on mmap() calls that are both writable and executable.
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test(int n) {
void *c = mmap(NULL, 32, PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE | MAP_ANON, -1, 0);
// warn: Both PROT_WRITE and PROT_EXEC flags are set. This can lead to
// exploitable memory regions, which could be overwritten with malicious
// code
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-security-ReturnPtrRange:
2019-02-05 08:39:33 +08:00
alpha.security.ReturnPtrRange (C)
"""""""""""""""""""""""""""""""""
Check for an out-of-bound pointer being returned to callers.
.. code-block :: c
static int A[10];
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
int *test() {
int *p = A + 10;
return p; // warn
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
int test(void) {
int x;
return x; // warn: undefined or garbage returned
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-security-taint-TaintPropagation:
2019-02-05 08:39:33 +08:00
alpha.security.taint.TaintPropagation (C, C++)
2019-02-11 23:17:13 +08:00
""""""""""""""""""""""""""""""""""""""""""""""
Generate taint information used by other checkers.
2019-02-05 08:39:33 +08:00
A data is tainted when it comes from an unreliable source.
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
char x = getchar(); // 'x' marked as tainted
system(&x); // warn: untrusted data is passed to a system call
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
// note: compiler internally checks if the second param to
// sprintf is a string literal or not.
// Use -Wno-format-security to suppress compiler warning.
void test() {
char s[10], buf[10];
fscanf(stdin, "%s", s); // 's' marked as tainted
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
sprintf(buf, s); // warn: untrusted data as a format string
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
size_t ts;
scanf("%zd", &ts); // 'ts' marked as tainted
int *p = (int * )malloc(ts * sizeof(int));
// warn: untrusted data as buffer size
}
alpha.unix
^^^^^^^^^^^
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-unix-BlockInCriticalSection:
2019-02-11 23:17:13 +08:00
alpha.unix.BlockInCriticalSection (C)
2019-02-05 08:39:33 +08:00
"""""""""""""""""""""""""""""""""""""
2019-02-11 23:17:13 +08:00
Check for calls to blocking functions inside a critical section.
2019-02-05 08:39:33 +08:00
Applies to: `` lock, unlock, sleep, getc, fgets, read, recv, pthread_mutex_lock, ``
`` pthread_mutex_unlock, mtx_lock, mtx_timedlock, mtx_trylock, mtx_unlock, lock_guard, unique_lock ``
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
std::mutex m;
m.lock();
sleep(3); // warn: a blocking function sleep is called inside a critical
// section
m.unlock();
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-unix-Chroot:
2019-02-05 08:39:33 +08:00
alpha.unix.Chroot (C)
"""""""""""""""""""""
Check improper use of chroot.
.. code-block :: c
void f();
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
chroot("/usr/local");
f(); // warn: no call of chdir("/") immediately after chroot
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-unix-PthreadLock:
2019-02-11 23:17:13 +08:00
alpha.unix.PthreadLock (C)
2019-02-05 08:39:33 +08:00
""""""""""""""""""""""""""
Simple lock -> unlock checker.
Applies to: `` pthread_mutex_lock, pthread_rwlock_rdlock, pthread_rwlock_wrlock, lck_mtx_lock, lck_rw_lock_exclusive ``
2019-02-11 23:17:13 +08:00
`` lck_rw_lock_shared, pthread_mutex_trylock, pthread_rwlock_tryrdlock, pthread_rwlock_tryrwlock, lck_mtx_try_lock,
2019-02-05 08:39:33 +08:00
lck_rw_try_lock_exclusive, lck_rw_try_lock_shared, pthread_mutex_unlock, pthread_rwlock_unlock, lck_mtx_unlock, lck_rw_done`` .
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
pthread_mutex_t mtx;
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
pthread_mutex_lock(&mtx);
pthread_mutex_lock(&mtx);
// warn: this lock has already been acquired
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
lck_mtx_t lck1, lck2;
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
lck_mtx_lock(&lck1);
lck_mtx_lock(&lck2);
lck_mtx_unlock(&lck1);
// warn: this was not the most recently acquired lock
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
lck_mtx_t lck1, lck2;
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
if (lck_mtx_try_lock(&lck1) == 0)
return;
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
lck_mtx_lock(&lck2);
lck_mtx_unlock(&lck1);
// warn: this was not the most recently acquired lock
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-unix-SimpleStream:
2019-02-05 08:39:33 +08:00
alpha.unix.SimpleStream (C)
"""""""""""""""""""""""""""
Check for misuses of stream APIs. Check for misuses of stream APIs: `` fopen, fclose ``
2020-03-23 05:42:03 +08:00
(demo checker, the subject of the demo (`Slides <https://llvm.org/devmtg/2012-11/Zaks-Rose-Checker24Hours.pdf> `_ ,
2019-02-11 23:17:13 +08:00
`Video <https://youtu.be/kdxlsP5QVPw> `_ ) by Anna Zaks and Jordan Rose presented at the
2020-03-23 05:42:03 +08:00
`2012 LLVM Developers' Meeting <https://llvm.org/devmtg/2012-11/> `_ ).
2019-02-05 08:39:33 +08:00
.. code-block :: c
void test() {
FILE *F = fopen("myfile.txt", "w");
} // warn: opened file is never closed
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
FILE *F = fopen("myfile.txt", "w");
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
if (F)
fclose(F);
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
fclose(F); // warn: closing a previously closed file stream
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-unix-Stream:
2019-02-05 08:39:33 +08:00
alpha.unix.Stream (C)
"""""""""""""""""""""
Check stream handling functions: `` fopen, tmpfile, fclose, fread, fwrite, fseek, ftell, rewind, fgetpos, ``
`` fsetpos, clearerr, feof, ferror, fileno `` .
.. code-block :: c
void test() {
FILE *p = fopen("foo", "r");
} // warn: opened file is never closed
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
FILE *p = fopen("foo", "r");
fseek(p, 1, SEEK_SET); // warn: stream pointer might be NULL
fclose(p);
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
FILE *p = fopen("foo", "r");
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
if (p)
fseek(p, 1, 3);
// warn: third arg should be SEEK_SET, SEEK_END, or SEEK_CUR
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
fclose(p);
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
FILE *p = fopen("foo", "r");
fclose(p);
fclose(p); // warn: already closed
}
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
FILE *p = tmpfile();
ftell(p); // warn: stream pointer might be NULL
fclose(p);
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-unix-cstring-BufferOverlap:
2019-02-05 08:39:33 +08:00
alpha.unix.cstring.BufferOverlap (C)
""""""""""""""""""""""""""""""""""""
Checks for overlap in two buffer arguments. Applies to: `` memcpy, mempcpy `` .
.. code-block :: c
void test() {
int a[4] = {0};
memcpy(a + 2, a + 1, 8); // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-unix-cstring-NotNullTerminated:
2019-02-05 08:39:33 +08:00
alpha.unix.cstring.NotNullTerminated (C)
""""""""""""""""""""""""""""""""""""""""
Check for arguments which are not null-terminated strings; applies to: `` strlen, strnlen, strcpy, strncpy, strcat, strncat `` .
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
int y = strlen((char *)&test); // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-unix-cstring-OutOfBounds:
2019-02-05 08:39:33 +08:00
alpha.unix.cstring.OutOfBounds (C)
""""""""""""""""""""""""""""""""""
Check for out-of-bounds access in string functions; applies to:`` strncopy, strncat `` .
.. code-block :: c
2019-02-11 23:17:13 +08:00
2019-02-05 08:39:33 +08:00
void test() {
int y = strlen((char *)&test); // warn
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-nondeterminism-PointerIteration:
[Analyzer] Checker for non-determinism caused by iteration of unordered container of pointers
Summary: Added a checker for non-determinism caused by iterating unordered containers like std::unordered_set containing pointer elements.
Reviewers: NoQ, george.karpenkov, whisperity, Szelethus, baloghadamsoftware
Reviewed By: Szelethus
Subscribers: mgorny, xazax.hun, baloghadamsoftware, szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy, dkrupp, jdoerfert, Charusso, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D59279
llvm-svn: 361664
2019-05-25 03:24:08 +08:00
alpha.nondeterminism.PointerIteration (C++)
"""""""""""""""""""""""""""""""""""""""""""
Check for non-determinism caused by iterating unordered containers of pointers.
.. code-block :: c
void test() {
int a = 1, b = 2;
std::unordered_set<int *> UnorderedPtrSet = {&a, &b};
for (auto i : UnorderedPtrSet) // warn
f(i);
}
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _alpha-nondeterminism-PointerSorting:
[Analyzer] Checker for non-determinism caused by sorting of pointer-like elements
Summary:
Added a new category of checkers for non-determinism. Added a checker for non-determinism
caused due to sorting containers with pointer-like elements.
Reviewers: NoQ, george.karpenkov, whisperity, Szelethus
Reviewed By: NoQ, Szelethus
Subscribers: Charusso, baloghadamsoftware, jdoerfert, donat.nagy, dkrupp, martong, dblaikie, MTC, Szelethus, mgorny, xazax.hun, szepet, rnkovacs, a.sidorin, mikhail.ramalho, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D50488
llvm-svn: 355720
2019-03-09 04:13:53 +08:00
alpha.nondeterminism.PointerSorting (C++)
2019-03-09 04:35:25 +08:00
"""""""""""""""""""""""""""""""""""""""""
[Analyzer] Checker for non-determinism caused by sorting of pointer-like elements
Summary:
Added a new category of checkers for non-determinism. Added a checker for non-determinism
caused due to sorting containers with pointer-like elements.
Reviewers: NoQ, george.karpenkov, whisperity, Szelethus
Reviewed By: NoQ, Szelethus
Subscribers: Charusso, baloghadamsoftware, jdoerfert, donat.nagy, dkrupp, martong, dblaikie, MTC, Szelethus, mgorny, xazax.hun, szepet, rnkovacs, a.sidorin, mikhail.ramalho, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D50488
llvm-svn: 355720
2019-03-09 04:13:53 +08:00
Check for non-determinism caused by sorting of pointers.
.. code-block :: c
void test() {
int a = 1, b = 2;
std::vector<int *> V = {&a, &b};
std::sort(V.begin(), V.end()); // warn
}
2019-02-05 08:39:33 +08:00
2020-06-16 04:29:08 +08:00
alpha.WebKit
^^^^^^^^^^^^
.. _alpha-webkit-UncountedCallArgsChecker:
alpha.webkit.UncountedCallArgsChecker
"""""""""""""""""""""""""""""""""""""
The goal of this rule is to make sure that lifetime of any dynamically allocated ref-countable object passed as a call argument spans past the end of the call. This applies to call to any function, method, lambda, function pointer or functor. Ref-countable types aren't supposed to be allocated on stack so we check arguments for parameters of raw pointers and references to uncounted types.
Here are some examples of situations that we warn about as they *might* be potentially unsafe. The logic is that either we're able to guarantee that an argument is safe or it's considered if not a bug then bug-prone.
.. code-block :: cpp
RefCountable* provide_uncounted();
void consume(RefCountable*);
// In these cases we can't make sure callee won't directly or indirectly call `deref()` on the argument which could make it unsafe from such point until the end of the call.
void foo1() {
consume(provide_uncounted()); // warn
}
void foo2() {
RefCountable* uncounted = provide_uncounted();
consume(uncounted); // warn
}
2020-06-16 04:58:34 +08:00
Although we are enforcing member variables to be ref-counted by `webkit.NoUncountedMemberChecker` any method of the same class still has unrestricted access to these. Since from a caller's perspective we can't guarantee a particular member won't get modified by callee (directly or indirectly) we don't consider values obtained from members safe.
2020-06-16 04:29:08 +08:00
Note: It's likely this heuristic could be made more precise with fewer false positives - for example calls to free functions that don't have any parameter other than the pointer should be safe as the callee won't be able to tamper with the member unless it's a global variable.
.. code-block :: cpp
struct Foo {
RefPtr<RefCountable> member;
void consume(RefCountable*) { /* ... */ }
void bugprone() {
consume(member.get()); // warn
}
};
The implementation of this rule is a heuristic - we define a whitelist of kinds of values that are considered safe to be passed as arguments. If we can't prove an argument is safe it's considered an error.
Allowed kinds of arguments:
- values obtained from ref-counted objects (including temporaries as those survive the call too)
.. code-block :: cpp
RefCountable* provide_uncounted();
void consume(RefCountable*);
void foo() {
RefPtr<RefCountable> rc = makeRef(provide_uncounted());
consume(rc.get()); // ok
consume(makeRef(provide_uncounted()).get()); // ok
}
- forwarding uncounted arguments from caller to callee
.. code-block :: cpp
void foo(RefCountable& a) {
bar(a); // ok
}
Caller of `` foo() `` is responsible for `` a `` 's lifetime.
- `` this `` pointer
.. code-block :: cpp
void Foo::foo() {
baz(this); // ok
}
Caller of `` foo() `` is responsible for keeping the memory pointed to by `` this `` pointer safe.
- constants
.. code-block :: cpp
foo(nullptr, NULL, 0); // ok
We also define a set of safe transformations which if passed a safe value as an input provide (usually it's the return value) a safe value (or an object that provides safe values). This is also a heuristic.
- constructors of ref-counted types (including factory methods)
- getters of ref-counted types
- member overloaded operators
- casts
- unary operators like `` & `` or `` * ``
2020-08-07 03:07:47 +08:00
alpha.webkit.UncountedLocalVarsChecker
""""""""""""""""""""""""""""""""""""""
The goal of this rule is to make sure that any uncounted local variable is backed by a ref-counted object with lifetime that is strictly larger than the scope of the uncounted local variable. To be on the safe side we require the scope of an uncounted variable to be embedded in the scope of ref-counted object that backs it.
These are examples of cases that we consider safe:
.. code-block :: cpp
2020-09-24 19:13:27 +08:00
2020-08-07 03:07:47 +08:00
void foo1() {
RefPtr<RefCountable> counted;
// The scope of uncounted is EMBEDDED in the scope of counted.
{
RefCountable* uncounted = counted.get(); // ok
}
}
void foo2(RefPtr<RefCountable> counted_param) {
RefCountable* uncounted = counted_param.get(); // ok
}
void FooClass::foo_method() {
RefCountable* uncounted = this; // ok
}
Here are some examples of situations that we warn about as they *might* be potentially unsafe. The logic is that either we're able to guarantee that an argument is safe or it's considered if not a bug then bug-prone.
.. code-block :: cpp
void foo1() {
RefCountable* uncounted = new RefCountable; // warn
}
RefCountable* global_uncounted;
void foo2() {
RefCountable* uncounted = global_uncounted; // warn
}
void foo3() {
RefPtr<RefCountable> counted;
// The scope of uncounted is not EMBEDDED in the scope of counted.
RefCountable* uncounted = counted.get(); // warn
}
We don't warn about these cases - we don't consider them necessarily safe but since they are very common and usually safe we'd introduce a lot of false positives otherwise:
- variable defined in condition part of an `` ` if ` `` statement
- variable defined in init statement condition of a `` ` for ` `` statement
For the time being we also don't warn about uninitialized uncounted local variables.
2020-06-16 04:29:08 +08:00
2019-02-05 08:39:33 +08:00
Debug Checkers
---------------
.. _debug-checkers:
debug
^^^^^
Checkers used for debugging the analyzer.
2019-02-05 18:19:39 +08:00
:doc: `developer-docs/DebugChecks` page contains a detailed description.
2019-02-05 08:39:33 +08:00
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _debug-AnalysisOrder:
2019-02-05 08:39:33 +08:00
debug.AnalysisOrder
"""""""""""""""""""
Print callbacks that are called during analysis in order.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _debug-ConfigDumper:
2019-02-05 08:39:33 +08:00
debug.ConfigDumper
""""""""""""""""""
Dump config table.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _debug-DumpCFG Display:
2019-02-05 08:39:33 +08:00
debug.DumpCFG Display
"""""""""""""""""""""
Control-Flow Graphs.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _debug-DumpCallGraph:
2019-02-05 08:39:33 +08:00
debug.DumpCallGraph
"""""""""""""""""""
Display Call Graph.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _debug-DumpCalls:
2019-02-05 08:39:33 +08:00
debug.DumpCalls
"""""""""""""""
Print calls as they are traversed by the engine.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _debug-DumpDominators:
2019-02-05 08:39:33 +08:00
debug.DumpDominators
""""""""""""""""""""
Print the dominance tree for a given CFG.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _debug-DumpLiveVars:
2019-02-05 08:39:33 +08:00
debug.DumpLiveVars
""""""""""""""""""
Print results of live variable analysis.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _debug-DumpTraversal:
2019-02-05 08:39:33 +08:00
debug.DumpTraversal
"""""""""""""""""""
Print branch conditions as they are traversed by the engine.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _debug-ExprInspection:
2019-02-05 08:39:33 +08:00
debug.ExprInspection
""""""""""""""""""""
Check the analyzer's understanding of expressions.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _debug-Stats:
2019-02-05 08:39:33 +08:00
debug.Stats
"""""""""""
Emit warnings with analyzer statistics.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _debug-TaintTest:
2019-02-05 08:39:33 +08:00
debug.TaintTest
"""""""""""""""
Mark tainted symbols as such.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _debug-ViewCFG:
2019-02-05 08:39:33 +08:00
debug.ViewCFG
"""""""""""""
View Control-Flow Graphs using GraphViz.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _debug-ViewCallGraph:
2019-02-05 08:39:33 +08:00
debug.ViewCallGraph
"""""""""""""""""""
View Call Graph using GraphViz.
[Docs] Add standardized header links to analyzer doc
Summary:
Header links should have some standard form so clang tidy
docs can easily reference them. The form is as follows.
Start with the analyzer full name including packages.
Replace all periods with dashes and lowercase everything.
Ex: core.CallAndMessage -> core-callandmessage
Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus
Reviewed By: aaron.ballman, Szelethus
Subscribers: nickdesaulniers, lebedev.ri, baloghadamsoftware, mgrang, a.sidorin, Szelethus, jfb, donat.nagy, dkrupp, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64543
llvm-svn: 365797
2019-07-12 01:12:05 +08:00
.. _debug-ViewExplodedGraph:
2019-02-05 08:39:33 +08:00
debug.ViewExplodedGraph
"""""""""""""""""""""""
View Exploded Graphs using GraphViz.