diff options
| -rw-r--r-- | clang/lib/StaticAnalyzer/Core/RegionStore.cpp | 8 | ||||
| -rw-r--r-- | clang/test/Analysis/string.c | 4 |
2 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp index 5bd7d726750..f27c51880be 100644 --- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp +++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -918,8 +918,12 @@ SVal RegionStoreManager::getBinding(Store store, Loc L, QualType T) { isa<SymbolicRegion>(MR) || isa<CodeTextRegion>(MR)) { if (T.isNull()) { - const SymbolicRegion *SR = cast<SymbolicRegion>(MR); - T = SR->getSymbol()->getType(Ctx); + if (const TypedRegion *TR = dyn_cast<TypedRegion>(MR)) + T = TR->getLocationType(); + else { + const SymbolicRegion *SR = cast<SymbolicRegion>(MR); + T = SR->getSymbol()->getType(Ctx); + } } MR = GetElementZeroRegion(MR, T); } diff --git a/clang/test/Analysis/string.c b/clang/test/Analysis/string.c index fcbe298a8fe..d72abb349a5 100644 --- a/clang/test/Analysis/string.c +++ b/clang/test/Analysis/string.c @@ -297,6 +297,10 @@ void strcpy_fn(char *x) { strcpy(x, (char*)&strcpy_fn); // expected-warning{{Argument to string copy function is the address of the function 'strcpy_fn', which is not a null-terminated string}} } +void strcpy_fn_const(char *x) { + strcpy(x, (const char*)&strcpy_fn); // expected-warning{{Argument to string copy function is the address of the function 'strcpy_fn', which is not a null-terminated string}} +} + void strcpy_effects(char *x, char *y) { char a = x[0]; |

