1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -verify %s
2 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -analyzer-output=plist-multi-file %s -o %t.plist
3 // RUN: %normalize_plist <%t.plist | diff -ub %S/Inputs/expected-plists/plist-macros.cpp.plist -
6 typedef __typeof(sizeof(int)) size_t;
9 #define mallocmemory int *x = (int*)malloc(12);
10 void noteOnMacro(int y
) {
16 delete x
; // expected-warning {{Memory allocated by malloc() should be deallocated by free(), not 'delete'}}
19 void macroIsFirstInFunction(int y
) {
21 y
++; // expected-warning {{Potential leak of memory pointed to by 'x'}}
24 #define checkmacro p==0
25 void macroInExpressionAux(bool b
);
26 int macroInExpression(int *p
, int y
) {;
28 macroInExpressionAux(checkmacro
);
30 return *p
; // expected-warning {{Dereference of null pointer}}
33 #define noPathNoteMacro y+y
34 int macroInExpressionNoNote(int *p
, int y
) {;
36 if (5 + noPathNoteMacro
)
39 return *p
; // expected-warning {{Dereference of null pointer}}
42 #define macroWithArg(mp) mp==0
43 int macroWithArgInExpression(int *p
, int y
) {;
47 return *p
; // expected-warning {{Dereference of null pointer}}
50 #define multiNoteMacroWithError \
54 int useMultiNoteMacroWithError(int *p
, int y
) {;
56 multiNoteMacroWithError
// expected-warning {{Dereference of null pointer}}
61 #define multiNoteMacro \
66 int useMultiNote(int *p
, int y
) {;
71 return *p
; // expected-warning {{Dereference of null pointer}}
74 #define CALL_FN(a) null_deref(a)
76 void null_deref(int *a
) {
79 *a
= 1; // expected-warning {{Dereference of null pointer}}