Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[analyzer] pr28449: Fix support for various array initializers.
In some cases the analyzer didn't expect an array-type variable to be initialized with anything other than a string literal. The patch essentially removes the assertion, and ensures relatively sane behavior. There is a bigger problem with these initializers. Currently our memory model (RegionStore) is being ordered to initialize the array with a region that is assumed to be storing the initializer rvalue, and it guesses to copy the contents of that region to the array variable. However, it would make more sense for RegionStore to receive the correct initializer in the first place. This problem isn't addressed with this patch. rdar://problem/27248428 Differential Revision: https://reviews.llvm.org/D23963 llvm-svn: 315750
- Loading branch information
Showing
3 changed files
with
23 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// RUN: %clang_cc1 -triple=i386-apple-darwin10 -analyze -analyzer-checker=debug.ExprInspection -verify %s | ||
void clang_analyzer_eval(int); | ||
|
||
// pr28449: Used to crash. | ||
void foo(void) { | ||
static const unsigned short array[] = (const unsigned short[]){0x0F00}; | ||
// FIXME: Should be true. | ||
clang_analyzer_eval(array[0] == 0x0F00); // expected-warning{{UNKNOWN}} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// RUN: %clang_cc1 -analyze -analyzer-checker=debug.ExprInspection -verify %s | ||
// expected-no-diagnostics | ||
|
||
void clang_analyzer_eval(int); | ||
|
||
// rdar://problem/34831581: Used to crash. | ||
void foo(void) { | ||
char buf1[] = @encode(int **); | ||
} |