Skip to content

Commit bb79e7f

Browse files
nicovanktru
authored andcommitted
[clang][analyzer] Fix #embed crash (llvm#107764)
Fix llvm#107724. (cherry picked from commit d84d955)
1 parent 5e1a55e commit bb79e7f

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

clang/lib/StaticAnalyzer/Core/ExprEngine.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
19281928
case Stmt::CXXRewrittenBinaryOperatorClass:
19291929
case Stmt::RequiresExprClass:
19301930
case Expr::CXXParenListInitExprClass:
1931+
case Stmt::EmbedExprClass:
19311932
// Fall through.
19321933

19331934
// Cases we intentionally don't evaluate, since they don't need
@@ -2430,10 +2431,6 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
24302431
Bldr.addNodes(Dst);
24312432
break;
24322433
}
2433-
2434-
case Stmt::EmbedExprClass:
2435-
llvm::report_fatal_error("Support for EmbedExpr is not implemented.");
2436-
break;
24372434
}
24382435
}
24392436

clang/test/Analysis/embed.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang_analyze_cc1 -std=c23 -analyzer-checker=core,debug.ExprInspection -verify %s
2+
3+
void clang_analyzer_dump_ptr(const unsigned char *ptr);
4+
void clang_analyzer_dump(unsigned char val);
5+
6+
int main() {
7+
const unsigned char SelfBytes[] = {
8+
#embed "embed.c"
9+
};
10+
clang_analyzer_dump_ptr(SelfBytes); // expected-warning {{&Element{SelfBytes,0 S64b,unsigned char}}}
11+
clang_analyzer_dump(SelfBytes[0]); // expected-warning {{Unknown}} FIXME: This should be the `/` character.
12+
}

0 commit comments

Comments
 (0)