diff options
author | Artem Dergachev <artem.dergachev@gmail.com> | 2018-05-04 21:39:25 +0000 |
---|---|---|
committer | Artem Dergachev <artem.dergachev@gmail.com> | 2018-05-04 21:39:25 +0000 |
commit | 2fd6aa7d5603e13aaea80bcb391c04a8e1014b13 (patch) | |
tree | a33c161276109616a28ec69679d2f5c0cf50b0a7 /clang/test/Analysis/casts.cpp | |
parent | 5b39acd111e082e2ba91eb83de7ecb9763f76115 (diff) | |
download | bcm5719-llvm-2fd6aa7d5603e13aaea80bcb391c04a8e1014b13.tar.gz bcm5719-llvm-2fd6aa7d5603e13aaea80bcb391c04a8e1014b13.zip |
[analyzer] pr37209: Fix casts of glvalues to references.
Many glvalue expressions aren't of their respective reference type -
they are simply glvalues of their value type.
This was causing problems when we were trying to obtain type of the original
expression while evaluating certain glvalue bit-casts.
Fixed by artificially forging a reference type to provide to the casting
procedure.
Differential Revision: https://reviews.llvm.org/D46224
llvm-svn: 331558
Diffstat (limited to 'clang/test/Analysis/casts.cpp')
-rw-r--r-- | clang/test/Analysis/casts.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/test/Analysis/casts.cpp b/clang/test/Analysis/casts.cpp index f96f19b0ac3..6499b20a79d 100644 --- a/clang/test/Analysis/casts.cpp +++ b/clang/test/Analysis/casts.cpp @@ -21,3 +21,17 @@ void intAsBoolAsSwitchCondition(int c) { break; } } + +int *&castToIntPtrLValueRef(char *p) { + return (int *&)*(int *)p; +} +bool testCastToIntPtrLValueRef(char *p, int *s) { + return castToIntPtrLValueRef(p) != s; // no-crash +} + +int *&&castToIntPtrRValueRef(char *p) { + return (int *&&)*(int *)p; +} +bool testCastToIntPtrRValueRef(char *p, int *s) { + return castToIntPtrRValueRef(p) != s; // no-crash +} |