summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/plist-macros-with-expansion.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/Analysis/plist-macros-with-expansion.cpp')
-rw-r--r--clang/test/Analysis/plist-macros-with-expansion.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/clang/test/Analysis/plist-macros-with-expansion.cpp b/clang/test/Analysis/plist-macros-with-expansion.cpp
index 6bbaf3d70c0..14dccd07c65 100644
--- a/clang/test/Analysis/plist-macros-with-expansion.cpp
+++ b/clang/test/Analysis/plist-macros-with-expansion.cpp
@@ -345,9 +345,17 @@ void hashHashOperatorTest() {
*ptr = 5; // expected-warning{{Dereference of null pointer}}
}
-// TODO: Should expand correctly.
// CHECK: <key>name</key><string>DECLARE_FUNC_AND_SET_TO_NULL</string>
-// CHECK-NEXT: <key>expansion</key><string>void generated_##whatever(); ptr = nullptr;</string>
+// CHECK-NEXT: <key>expansion</key><string>void generated_whatever(); ptr = nullptr;</string>
+
+void macroArgContainsHashHashInStringTest() {
+ int *a;
+ TO_NULL_AND_PRINT(a, "Will this ## cause a crash?");
+ *a = 5; // expected-warning{{Dereference of null pointer}}
+}
+
+// CHECK: <key>name</key><string>TO_NULL_AND_PRINT</string>
+// CHECK-NEXT: <key>expansion</key><string>a = 0; print( &quot;Will this ## cause a crash?&quot;)</string>
#define PRINT_STR(str, ptr) \
print(#str); \
@@ -359,9 +367,17 @@ void hashOperatorTest() {
*ptr = 5; // expected-warning{{Dereference of null pointer}}
}
-// TODO: Should expand correctly.
// CHECK: <key>name</key><string>PRINT_STR</string>
-// CHECK-NEXT: <key>expansion</key><string>print(#Hello); ptr = nullptr</string>
+// CHECK-NEXT: <key>expansion</key><string>print(&quot;Hello&quot;); ptr = nullptr</string>
+
+void macroArgContainsHashInStringTest() {
+ int *a;
+ TO_NULL_AND_PRINT(a, "Will this # cause a crash?");
+ *a = 5; // expected-warning{{Dereference of null pointer}}
+}
+
+// CHECK: <key>name</key><string>TO_NULL_AND_PRINT</string>
+// CHECK-NEXT: <key>expansion</key><string>a = 0; print( &quot;Will this # cause a crash?&quot;)</string>
//===----------------------------------------------------------------------===//
// Tests for more complex macro expansions.
OpenPOWER on IntegriCloud