aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/PPDirectives.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Lex/PPDirectives.cpp')
-rw-r--r--clang/lib/Lex/PPDirectives.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 053ef1d2dd18..d6b03d85913d 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -379,8 +379,12 @@ Optional<unsigned> Preprocessor::getSkippedRangeForExcludedConditionalBlock(
std::pair<FileID, unsigned> HashFileOffset =
SourceMgr.getDecomposedLoc(HashLoc);
- const llvm::MemoryBuffer *Buf = SourceMgr.getBuffer(HashFileOffset.first);
- auto It = ExcludedConditionalDirectiveSkipMappings->find(Buf);
+ Optional<llvm::MemoryBufferRef> Buf =
+ SourceMgr.getBufferOrNone(HashFileOffset.first);
+ if (!Buf)
+ return None;
+ auto It =
+ ExcludedConditionalDirectiveSkipMappings->find(Buf->getBufferStart());
if (It == ExcludedConditionalDirectiveSkipMappings->end())
return None;
@@ -2057,7 +2061,7 @@ Preprocessor::ImportAction Preprocessor::HandleHeaderIncludeOrImport(
// some directives (e.g. #endif of a header guard) will never be seen.
// Since this will lead to confusing errors, avoid the inclusion.
if (Action == Enter && File && PreambleConditionalStack.isRecording() &&
- SourceMgr.isMainFile(*File)) {
+ SourceMgr.isMainFile(File->getFileEntry())) {
Diag(FilenameTok.getLocation(),
diag::err_pp_including_mainfile_in_preamble);
return {ImportAction::None};
@@ -2397,7 +2401,7 @@ bool Preprocessor::ReadMacroParameterList(MacroInfo *MI, Token &Tok) {
diag::ext_variadic_macro);
// OpenCL v1.2 s6.9.e: variadic macros are not supported.
- if (LangOpts.OpenCL) {
+ if (LangOpts.OpenCL && !LangOpts.OpenCLCPlusPlus) {
Diag(Tok, diag::ext_pp_opencl_variadic_macros);
}