Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ Bug Fixes in This Version
- Fixed an assertion when an improper use of the ``malloc`` attribute targeting
a function without arguments caused us to try to access a non-existent argument.
(#GH159080)
- Fixed a failed assertion with empty filename arguments in ``__has_embed``. (#GH159898)

Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
4 changes: 3 additions & 1 deletion clang/lib/Lex/PPMacroExpansion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1282,11 +1282,13 @@ EmbedResult Preprocessor::EvaluateHasEmbed(Token &Tok, IdentifierInfo *II) {

SmallString<128> FilenameBuffer;
StringRef Filename = this->getSpelling(FilenameTok, FilenameBuffer);
if (Filename.empty())
return EmbedResult::Empty;

bool isAngled =
this->GetIncludeFilenameSpelling(FilenameTok.getLocation(), Filename);
// If GetIncludeFilenameSpelling set the start ptr to null, there was an
// error.
assert(!Filename.empty());
const FileEntry *LookupFromFile =
this->getCurrentFileLexer() ? *this->getCurrentFileLexer()->getFileEntry()
: static_cast<FileEntry *>(nullptr);
Expand Down
3 changes: 3 additions & 0 deletions clang/test/Preprocessor/embed___has_embed_parsing_errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,6 @@
expected-error@+2 {{expected value in expression}}
#if __has_embed (__FILE__ limit(-100000000000000000)) != __STDC_EMBED_NOT_FOUND__
#endif

#if __has_embed("") // expected-error {{empty filename}}
#endif