diff options
| author | Kristof Umann <dkszelethus@gmail.com> | 2018-11-30 19:21:35 +0000 |
|---|---|---|
| committer | Kristof Umann <dkszelethus@gmail.com> | 2018-11-30 19:21:35 +0000 |
| commit | 5f9981f8a5a7acf044b347438d16fe46af97c1c0 (patch) | |
| tree | a86304b584ce06c8c944bd2c2c777aa004b6fdcd /clang/test/Analysis/plist-macros-with-expansion.cpp | |
| parent | 27b1e3bd4f7a064a2672e30cc6be31433ebd300b (diff) | |
| download | bcm5719-llvm-5f9981f8a5a7acf044b347438d16fe46af97c1c0.tar.gz bcm5719-llvm-5f9981f8a5a7acf044b347438d16fe46af97c1c0.zip | |
[analyzer][PlistMacroExpansion] Part 5.: Support for # and ##
From what I can see, this should be the last patch needed to replicate macro
argument expansions.
Differential Revision: https://reviews.llvm.org/D52988
llvm-svn: 348025
Diffstat (limited to 'clang/test/Analysis/plist-macros-with-expansion.cpp')
| -rw-r--r-- | clang/test/Analysis/plist-macros-with-expansion.cpp | 24 |
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( "Will this ## cause a crash?")</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("Hello"); 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( "Will this # cause a crash?")</string> //===----------------------------------------------------------------------===// // Tests for more complex macro expansions. |

