-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[Clang] Fix PPChainedCallbacks::EmbedFileNotFound()
#170293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -463,6 +463,40 @@ TEST_F(PPCallbacksTest, FileNotFoundSkipped) { | |
| ASSERT_EQ(0u, DiagConsumer->getNumErrors()); | ||
| } | ||
|
|
||
| TEST_F(PPCallbacksTest, EmbedFileNotFoundChained) { | ||
| const char *SourceText = "#embed \"notfound.h\"\n"; | ||
|
|
||
| std::unique_ptr<llvm::MemoryBuffer> SourceBuf = | ||
| llvm::MemoryBuffer::getMemBuffer(SourceText); | ||
| SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(SourceBuf))); | ||
|
|
||
| HeaderSearchOptions HSOpts; | ||
| TrivialModuleLoader ModLoader; | ||
| PreprocessorOptions PPOpts; | ||
| HeaderSearch HeaderInfo(HSOpts, SourceMgr, Diags, LangOpts, Target.get()); | ||
|
|
||
| DiagnosticConsumer *DiagConsumer = new DiagnosticConsumer; | ||
| DiagnosticsEngine EmbedFileNotFoundDiags(DiagID, DiagOpts, DiagConsumer); | ||
| Preprocessor PP(PPOpts, EmbedFileNotFoundDiags, LangOpts, SourceMgr, | ||
| HeaderInfo, ModLoader, /*IILookup=*/nullptr, | ||
| /*OwnsHeaderSearch=*/false); | ||
| PP.Initialize(*Target); | ||
|
|
||
| class EmbedFileNotFoundCallbacks : public PPCallbacks { | ||
| public: | ||
| bool EmbedFileNotFound(StringRef FileName) override { return true; } | ||
cofibrant marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }; | ||
|
|
||
| PP.addPPCallbacks(std::make_unique<EmbedFileNotFoundCallbacks>()); | ||
| PP.addPPCallbacks(std::make_unique<EmbedFileNotFoundCallbacks>()); | ||
|
||
|
|
||
| // Lex source text. | ||
| PP.EnterMainSourceFile(); | ||
| PP.LexTokensUntilEOF(); | ||
|
|
||
| ASSERT_EQ(0u, DiagConsumer->getNumErrors()); | ||
| } | ||
|
|
||
| TEST_F(PPCallbacksTest, OpenCLExtensionPragmaEnabled) { | ||
| const char* Source = | ||
| "#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n"; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.