Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ C23 Feature Support
`WG14 N2710 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2710.htm>`_.
- Fixed accepting as compatible unnamed tag types with the same fields within
the same translation unit but from different types.
- ``-MG`` now silences the "file not found" errors with ``#embed`` when
scanning for dependencies and encountering an unknown file. #GH165632

Non-comprehensive list of changes in this release
-------------------------------------------------
Expand Down
11 changes: 11 additions & 0 deletions clang/lib/Frontend/DependencyFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ struct DepCollectorPPCallbacks : public PPCallbacks {
/*IsMissing*/ false);
}

bool EmbedFileNotFound(StringRef FileName) override {
DepCollector.maybeAddDependency(
llvm::sys::path::remove_leading_dotslash(FileName),
/*FromModule*/ false,
/*IsSystem*/ false,
/*IsModuleFile*/ false,
/*IsMissing*/ false);
// Return true to silence the file not found diagnostic.
return true;
}

void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange,
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Lex/PPDirectives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4018,7 +4018,7 @@ void Preprocessor::HandleEmbedDirective(SourceLocation HashLoc, Token &EmbedTok,
this->LookupEmbedFile(Filename, isAngled, true, LookupFromFile);
if (!MaybeFileRef) {
// could not find file
if (Callbacks && Callbacks->EmbedFileNotFound(OriginalFilename)) {
if (Callbacks && Callbacks->EmbedFileNotFound(Filename)) {
return;
}
Diag(FilenameTok, diag::err_pp_file_not_found) << Filename;
Expand Down
4 changes: 3 additions & 1 deletion clang/test/Driver/mg.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// RUN: %clang -M -MG -include nonexistent-preinclude.h %s | FileCheck %s
// RUN: %clang -M -MG -include nonexistent-preinclude.h -std=c23 %s | FileCheck %s
// CHECK: nonexistent-preinclude.h
// CHECK: nonexistent-ppinclude.h
// CHECK: nonexistent-embed

#include "nonexistent-ppinclude.h"
#embed "nonexistent-embed"