forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang][analyzer] Check for label location bindings in `DereferenceCh…
…ecker` (llvm#91119) Resolves llvm#89264 Values should not be stored in addresses of labels, this throws a fatal error when this happens. --------- Co-authored-by: Balazs Benics <[email protected]>
- Loading branch information
1 parent
99934da
commit efe91cf
Showing
3 changed files
with
24 additions
and
9 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
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 |
---|---|---|
@@ -1,14 +1,13 @@ | ||
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s | ||
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-output text -verify %s | ||
|
||
void clang_analyzer_dump(char); | ||
void clang_analyzer_dump_ptr(char*); | ||
void clang_analyzer_warnIfReached(void); | ||
|
||
// https://github.com/llvm/llvm-project/issues/89185 | ||
void binding_to_label_loc() { | ||
char *b = &&MyLabel; | ||
char *b = &&MyLabel; // expected-note {{'b' initialized here}} | ||
MyLabel: | ||
*b = 0; // no-crash | ||
clang_analyzer_dump_ptr(b); // expected-warning {{&&MyLabel}} | ||
clang_analyzer_dump(*b); // expected-warning {{Unknown}} | ||
// FIXME: We should never reach here, as storing to a label is invalid. | ||
*b = 0; | ||
// expected-warning@-1 {{Dereference of the address of a label}} | ||
// expected-note@-2 {{Dereference of the address of a label}} | ||
clang_analyzer_warnIfReached(); // no-warning: Unreachable due to fatal error. | ||
} |