Skip to content

Commit e2d2ae0

Browse files
Fznamznonyuxuanchen1997
authored andcommitted
[clang] Fix assertion failure in injectEmbedTokens (#99624)
Summary: It seems for C++ lexer has some caching ability which doesn't expect injecting "new" tokens in the middle of the cache. Technically #embed tokens are not completely new since they have already been read from the file and there was #embed annotation token in this place, so set `reinject` flag for them to silence assertion. Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251200
1 parent d6fec00 commit e2d2ae0

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

clang/lib/Parse/ParseExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3597,7 +3597,7 @@ void Parser::injectEmbedTokens() {
35973597
I += 2;
35983598
}
35993599
PP.EnterTokenStream(std::move(Toks), /*DisableMacroExpansion=*/true,
3600-
/*IsReinject=*/false);
3600+
/*IsReinject=*/true);
36013601
ConsumeAnyToken(/*ConsumeCodeCompletionTok=*/true);
36023602
}
36033603

clang/test/Preprocessor/embed_weird.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ void f1() {
116116
}
117117
#endif
118118

119+
static_assert(_Generic(
120+
#embed __FILE__ limit(1)
121+
, int : 1, default : 0));
122+
123+
static_assert(alignof(typeof(
124+
#embed __FILE__ limit(1)
125+
)) == alignof(int));
126+
119127
struct HasChar {
120128
signed char ch;
121129
};

0 commit comments

Comments
 (0)