Skip to content

Commit

Permalink
[clang][analyzer] Fix #embed crash (#107764)
Browse files Browse the repository at this point in the history
Fix #107724.
  • Loading branch information
nicovank authored Sep 9, 2024
1 parent 09c00b6 commit d84d955
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 1 addition & 4 deletions clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1938,6 +1938,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
case Stmt::CXXRewrittenBinaryOperatorClass:
case Stmt::RequiresExprClass:
case Expr::CXXParenListInitExprClass:
case Stmt::EmbedExprClass:
// Fall through.

// Cases we intentionally don't evaluate, since they don't need
Expand Down Expand Up @@ -2440,10 +2441,6 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
Bldr.addNodes(Dst);
break;
}

case Stmt::EmbedExprClass:
llvm::report_fatal_error("Support for EmbedExpr is not implemented.");
break;
}
}

Expand Down
12 changes: 12 additions & 0 deletions clang/test/Analysis/embed.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: %clang_analyze_cc1 -std=c23 -analyzer-checker=core,debug.ExprInspection -verify %s

void clang_analyzer_dump_ptr(const unsigned char *ptr);
void clang_analyzer_dump(unsigned char val);

int main() {
const unsigned char SelfBytes[] = {
#embed "embed.c"
};
clang_analyzer_dump_ptr(SelfBytes); // expected-warning {{&Element{SelfBytes,0 S64b,unsigned char}}}
clang_analyzer_dump(SelfBytes[0]); // expected-warning {{Unknown}} FIXME: This should be the `/` character.
}

0 comments on commit d84d955

Please sign in to comment.