diff --git a/clang/include/clang/Lex/PPEmbedParameters.h b/clang/include/clang/Lex/PPEmbedParameters.h index 51bf908524e7ab4..c4fb8d02f6f358e 100644 --- a/clang/include/clang/Lex/PPEmbedParameters.h +++ b/clang/include/clang/Lex/PPEmbedParameters.h @@ -75,7 +75,6 @@ struct LexEmbedParametersResult { std::optional MaybeIfEmptyParam; std::optional MaybePrefixParam; std::optional MaybeSuffixParam; - SourceRange ParamRange; int UnrecognizedParams; size_t PrefixTokenCount() const { diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index a53540b12dee6e5..4e77df9ec444c74 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -1137,7 +1137,9 @@ Preprocessor::LookupEmbedFile(StringRef Filename, bool isAngled, bool OpenFile, SeparateComponents(LookupPath, Entry, Filename, false); llvm::Expected ShouldBeEntry = FM.getFileRef(LookupPath, OpenFile); - return llvm::expectedToOptional(std::move(ShouldBeEntry)); + if (ShouldBeEntry) + return llvm::expectedToOptional(std::move(ShouldBeEntry)); + llvm::consumeError(ShouldBeEntry.takeError()); } return std::nullopt; } @@ -3624,12 +3626,10 @@ Preprocessor::LexEmbedParameters(Token &CurTok, bool ForHasEmbed) { LexEmbedParametersResult Result{}; SmallVector ParameterTokens; tok::TokenKind EndTokenKind = ForHasEmbed ? tok::r_paren : tok::eod; - Result.ParamRange = {CurTok.getLocation(), CurTok.getLocation()}; auto DiagMismatchedBracesAndSkipToEOD = [&](tok::TokenKind Expected, std::pair Matches) { - Result.ParamRange.setEnd(CurTok.getEndLoc()); Diag(CurTok, diag::err_expected) << Expected; Diag(Matches.second, diag::note_matching) << Matches.first; if (CurTok.isNot(tok::eod)) @@ -3638,7 +3638,6 @@ Preprocessor::LexEmbedParameters(Token &CurTok, bool ForHasEmbed) { auto ExpectOrDiagAndSkipToEOD = [&](tok::TokenKind Kind) { if (CurTok.isNot(Kind)) { - Result.ParamRange.setEnd(CurTok.getEndLoc()); Diag(CurTok, diag::err_expected) << Kind; if (CurTok.isNot(tok::eod)) DiscardUntilEndOfDirective(CurTok); @@ -3872,7 +3871,6 @@ Preprocessor::LexEmbedParameters(Token &CurTok, bool ForHasEmbed) { } } } - Result.ParamRange.setEnd(CurTok.getLocation()); return Result; } diff --git a/clang/test/Preprocessor/embed_search_paths.c b/clang/test/Preprocessor/embed_search_paths.c new file mode 100644 index 000000000000000..5cc1bbf9f87a940 --- /dev/null +++ b/clang/test/Preprocessor/embed_search_paths.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -std=c23 %s -E -verify --embed-dir=%S --embed-dir=%S/Inputs +// expected-no-diagnostics + +#embed