summaryrefslogtreecommitdiffstats
path: root/clang/docs/analyzer/checkers/callandmessage_example.c
diff options
context:
space:
mode:
authorKristof Umann <dkszelethus@gmail.com>2019-02-05 00:39:33 +0000
committerKristof Umann <dkszelethus@gmail.com>2019-02-05 00:39:33 +0000
commit1a17032b788016299ea4e3c4b53670c6dcd94b4f (patch)
tree318aac876ac4171cb6613f534126f39430fc193e /clang/docs/analyzer/checkers/callandmessage_example.c
parent7f09fd6b045da9fd62529fede180ac3e48a88305 (diff)
downloadbcm5719-llvm-1a17032b788016299ea4e3c4b53670c6dcd94b4f.tar.gz
bcm5719-llvm-1a17032b788016299ea4e3c4b53670c6dcd94b4f.zip
[analyzer] Creating standard Sphinx documentation
The lack of documentation has been a long standing issue in the Static Analyzer, and one of the leading reasons behind this was a lack of good documentation infrastucture. This lead serious drawbacks, such as * Not having proper release notes for years * Not being able to have a sensible auto-generated checker documentations (which lead to most of them not having any) * The HTML website that has to updated manually is a chore, and has been outdated for a long while * Many design discussions are now hidden in phabricator revisions This patch implements a new documentation infrastucture using Sphinx, like most of the other subprojects in LLVM. It transformed some pages as a proof-of- concept, with many others to follow in later patches. The eventual goal is to preserve the original website's (https://clang-analyzer.llvm.org/) frontpage, but move everything else to the new format. Some other ideas, like creating a unipage for each checker (similar to how clang-tidy works now), are also being discussed. Patch by Dániel Krupp! Differential Revision: https://reviews.llvm.org/D54429 llvm-svn: 353126
Diffstat (limited to 'clang/docs/analyzer/checkers/callandmessage_example.c')
-rw-r--r--clang/docs/analyzer/checkers/callandmessage_example.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/clang/docs/analyzer/checkers/callandmessage_example.c b/clang/docs/analyzer/checkers/callandmessage_example.c
new file mode 100644
index 00000000000..7e14fbe464f
--- /dev/null
+++ b/clang/docs/analyzer/checkers/callandmessage_example.c
@@ -0,0 +1,66 @@
+//C
+void test() {
+ void (*foo)(void);
+ foo = 0;
+ foo(); // warn: function pointer is null
+ }
+
+ // C++
+ class C {
+ public:
+ void f();
+ };
+
+ void test() {
+ C *pc;
+ pc->f(); // warn: object pointer is uninitialized
+ }
+
+ // C++
+ class C {
+ public:
+ void f();
+ };
+
+ void test() {
+ C *pc = 0;
+ pc->f(); // warn: object pointer is null
+ }
+
+ // Objective-C
+ @interface MyClass : NSObject
+ @property (readwrite,assign) id x;
+ - (long double)longDoubleM;
+ @end
+
+ void test() {
+ MyClass *obj1;
+ long double ld1 = [obj1 longDoubleM];
+ // warn: receiver is uninitialized
+ }
+
+ // Objective-C
+ @interface MyClass : NSObject
+ @property (readwrite,assign) id x;
+ - (long double)longDoubleM;
+ @end
+
+ void test() {
+ MyClass *obj1;
+ id i = obj1.x; // warn: uninitialized object pointer
+ }
+
+ // Objective-C
+ @interface Subscriptable : NSObject
+ - (id)objectAtIndexedSubscript:(unsigned int)index;
+ @end
+
+ @interface MyClass : Subscriptable
+ @property (readwrite,assign) id x;
+ - (long double)longDoubleM;
+ @end
+
+ void test() {
+ MyClass *obj1;
+ id i = obj1[0]; // warn: uninitialized object pointer
+ }
OpenPOWER on IntegriCloud