mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-14 17:06:38 +00:00
[clang][lex] Always pass suggested module to InclusionDirective()
callback (#81061)
This patch provides more information to the `PPCallbacks::InclusionDirective()` hook. We now always pass the suggested module, regardless of whether it was actually imported or not. The extra `bool ModuleImported` parameter then denotes whether the header `#include` will be automatically translated into import the the module. The main change is in `clang/lib/Lex/PPDirectives.cpp`, where we take care to not modify `SuggestedModule` after it's been populated by `LookupHeaderIncludeOrImport()`. We now exclusively use the `SM` (`ModuleToImport`) variable instead, which has been equivalent to `SuggestedModule` until now. This allows us to use the original non-modified `SuggestedModule` for the callback itself. (This patch turns out to be necessary for https://github.com/apple/llvm-project/pull/8011).
This commit is contained in:
parent
35fae044c5
commit
da95d926f6
@ -133,7 +133,8 @@ public:
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef /*File*/, StringRef SearchPath,
|
||||
StringRef /*RelativePath*/,
|
||||
const Module * /*Imported*/,
|
||||
const Module * /*SuggestedModule*/,
|
||||
bool /*ModuleImported*/,
|
||||
SrcMgr::CharacteristicKind /*FileType*/) override {
|
||||
if (auto FileEntry = SM.getFileEntryRefForID(SM.getFileID(HashLoc)))
|
||||
MoveTool->addIncludes(FileName, IsAngled, SearchPath,
|
||||
|
@ -166,12 +166,12 @@ void ExpandModularHeadersPPCallbacks::InclusionDirective(
|
||||
SourceLocation DirectiveLoc, const Token &IncludeToken,
|
||||
StringRef IncludedFilename, bool IsAngled, CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef IncludedFile, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *Imported,
|
||||
StringRef RelativePath, const Module *SuggestedModule, bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) {
|
||||
if (Imported) {
|
||||
if (ModuleImported) {
|
||||
serialization::ModuleFile *MF =
|
||||
Compiler.getASTReader()->getModuleManager().lookup(
|
||||
*Imported->getASTFile());
|
||||
*SuggestedModule->getASTFile());
|
||||
handleModuleFile(MF);
|
||||
}
|
||||
parseToLocation(DirectiveLoc);
|
||||
|
@ -69,7 +69,7 @@ private:
|
||||
bool IsAngled, CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef IncludedFile,
|
||||
StringRef SearchPath, StringRef RelativePath,
|
||||
const Module *Imported,
|
||||
const Module *SuggestedModule, bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override;
|
||||
|
||||
void EndOfMainFile() override;
|
||||
|
@ -29,7 +29,8 @@ public:
|
||||
StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FileNameRange,
|
||||
OptionalFileEntryRef File, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *Imported,
|
||||
StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override;
|
||||
|
||||
void EndOfMainFile() override;
|
||||
@ -61,7 +62,7 @@ void KernelNameRestrictionCheck::registerPPCallbacks(const SourceManager &SM,
|
||||
void KernelNameRestrictionPPCallbacks::InclusionDirective(
|
||||
SourceLocation HashLoc, const Token &, StringRef FileName, bool,
|
||||
CharSourceRange, OptionalFileEntryRef, StringRef, StringRef, const Module *,
|
||||
SrcMgr::CharacteristicKind) {
|
||||
bool, SrcMgr::CharacteristicKind) {
|
||||
IncludeDirective ID = {HashLoc, FileName};
|
||||
IncludeDirectives.push_back(std::move(ID));
|
||||
}
|
||||
|
@ -26,7 +26,8 @@ public:
|
||||
StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *Imported,
|
||||
StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override;
|
||||
|
||||
private:
|
||||
@ -51,8 +52,8 @@ void SuspiciousIncludeCheck::registerPPCallbacks(
|
||||
void SuspiciousIncludePPCallbacks::InclusionDirective(
|
||||
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
|
||||
bool IsAngled, CharSourceRange FilenameRange, OptionalFileEntryRef File,
|
||||
StringRef SearchPath, StringRef RelativePath, const Module *Imported,
|
||||
SrcMgr::CharacteristicKind FileType) {
|
||||
StringRef SearchPath, StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported, SrcMgr::CharacteristicKind FileType) {
|
||||
if (IncludeTok.getIdentifierInfo()->getPPKeywordID() == tok::pp_import)
|
||||
return;
|
||||
|
||||
|
@ -27,7 +27,8 @@ public:
|
||||
StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *Imported,
|
||||
StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override;
|
||||
void EndOfMainFile() override;
|
||||
|
||||
@ -81,8 +82,8 @@ static int getPriority(StringRef Filename, bool IsAngled, bool IsMainModule) {
|
||||
void IncludeOrderPPCallbacks::InclusionDirective(
|
||||
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
|
||||
bool IsAngled, CharSourceRange FilenameRange, OptionalFileEntryRef File,
|
||||
StringRef SearchPath, StringRef RelativePath, const Module *Imported,
|
||||
SrcMgr::CharacteristicKind FileType) {
|
||||
StringRef SearchPath, StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported, SrcMgr::CharacteristicKind FileType) {
|
||||
// We recognize the first include as a special main module header and want
|
||||
// to leave it in the top position.
|
||||
IncludeDirective ID = {HashLoc, FilenameRange, std::string(FileName),
|
||||
|
@ -33,7 +33,8 @@ public:
|
||||
StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *Imported,
|
||||
StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override;
|
||||
|
||||
private:
|
||||
@ -45,14 +46,14 @@ private:
|
||||
void RestrictedIncludesPPCallbacks::InclusionDirective(
|
||||
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
|
||||
bool IsAngled, CharSourceRange FilenameRange, OptionalFileEntryRef File,
|
||||
StringRef SearchPath, StringRef RelativePath, const Module *Imported,
|
||||
SrcMgr::CharacteristicKind FileType) {
|
||||
StringRef SearchPath, StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported, SrcMgr::CharacteristicKind FileType) {
|
||||
// Compiler provided headers are allowed (e.g stddef.h).
|
||||
if (SrcMgr::isSystem(FileType) && SearchPath == CompilerIncudeDir)
|
||||
return;
|
||||
portability::RestrictedIncludesPPCallbacks::InclusionDirective(
|
||||
HashLoc, IncludeTok, FileName, IsAngled, FilenameRange, File, SearchPath,
|
||||
RelativePath, Imported, FileType);
|
||||
RelativePath, SuggestedModule, ModuleImported, FileType);
|
||||
}
|
||||
|
||||
void RestrictSystemLibcHeadersCheck::registerPPCallbacks(
|
||||
|
@ -83,7 +83,7 @@ public:
|
||||
void InclusionDirective(SourceLocation, const Token &, StringRef FilePath,
|
||||
bool, CharSourceRange Range,
|
||||
OptionalFileEntryRef File, StringRef, StringRef,
|
||||
const Module *,
|
||||
const Module *, bool,
|
||||
SrcMgr::CharacteristicKind FileType) override {
|
||||
if (FileType != clang::SrcMgr::C_User)
|
||||
return;
|
||||
|
@ -32,7 +32,8 @@ public:
|
||||
StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *Imported,
|
||||
StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override;
|
||||
|
||||
private:
|
||||
@ -178,8 +179,8 @@ IncludeModernizePPCallbacks::IncludeModernizePPCallbacks(
|
||||
void IncludeModernizePPCallbacks::InclusionDirective(
|
||||
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
|
||||
bool IsAngled, CharSourceRange FilenameRange, OptionalFileEntryRef File,
|
||||
StringRef SearchPath, StringRef RelativePath, const Module *Imported,
|
||||
SrcMgr::CharacteristicKind FileType) {
|
||||
StringRef SearchPath, StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported, SrcMgr::CharacteristicKind FileType) {
|
||||
|
||||
// If we don't want to warn for non-main file reports and this is one, skip
|
||||
// it.
|
||||
|
@ -117,7 +117,8 @@ public:
|
||||
StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *Imported,
|
||||
StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override {
|
||||
clearCurrentEnum(HashLoc);
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ namespace clang::tidy::portability {
|
||||
void RestrictedIncludesPPCallbacks::InclusionDirective(
|
||||
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
|
||||
bool IsAngled, CharSourceRange FilenameRange, OptionalFileEntryRef File,
|
||||
StringRef SearchPath, StringRef RelativePath, const Module *Imported,
|
||||
SrcMgr::CharacteristicKind FileType) {
|
||||
StringRef SearchPath, StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported, SrcMgr::CharacteristicKind FileType) {
|
||||
if (!Check.contains(FileName) && SrcMgr::isSystem(FileType)) {
|
||||
SmallString<256> FullPath;
|
||||
llvm::sys::path::append(FullPath, SearchPath);
|
||||
|
@ -50,7 +50,8 @@ public:
|
||||
StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *Imported,
|
||||
StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override;
|
||||
void EndOfMainFile() override;
|
||||
|
||||
|
@ -47,7 +47,8 @@ public:
|
||||
StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *Imported,
|
||||
StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override;
|
||||
|
||||
void MacroDefined(const Token &MacroNameTok,
|
||||
@ -76,8 +77,8 @@ void DuplicateIncludeCallbacks::FileChanged(SourceLocation Loc,
|
||||
void DuplicateIncludeCallbacks::InclusionDirective(
|
||||
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
|
||||
bool IsAngled, CharSourceRange FilenameRange, OptionalFileEntryRef File,
|
||||
StringRef SearchPath, StringRef RelativePath, const Module *Imported,
|
||||
SrcMgr::CharacteristicKind FileType) {
|
||||
StringRef SearchPath, StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported, SrcMgr::CharacteristicKind FileType) {
|
||||
if (llvm::is_contained(Files.back(), FileName)) {
|
||||
// We want to delete the entire line, so make sure that [Start,End] covers
|
||||
// everything.
|
||||
|
@ -25,7 +25,8 @@ public:
|
||||
bool IsAngled, CharSourceRange FileNameRange,
|
||||
OptionalFileEntryRef /*IncludedFile*/,
|
||||
StringRef /*SearchPath*/, StringRef /*RelativePath*/,
|
||||
const Module * /*ImportedModule*/,
|
||||
const Module * /*SuggestedModule*/,
|
||||
bool /*ModuleImported*/,
|
||||
SrcMgr::CharacteristicKind /*FileType*/) override {
|
||||
Inserter->addInclude(FileNameRef, IsAngled, HashLocation,
|
||||
IncludeToken.getEndLoc());
|
||||
|
@ -41,7 +41,8 @@ public:
|
||||
OptionalFileEntryRef File,
|
||||
llvm::StringRef /*SearchPath*/,
|
||||
llvm::StringRef /*RelativePath*/,
|
||||
const clang::Module * /*Imported*/,
|
||||
const clang::Module * /*SuggestedModule*/,
|
||||
bool /*ModuleImported*/,
|
||||
SrcMgr::CharacteristicKind FileKind) override {
|
||||
auto MainFID = SM.getMainFileID();
|
||||
// If an include is part of the preamble patch, translate #line directives.
|
||||
|
@ -244,7 +244,7 @@ private:
|
||||
SynthesizedFilenameTok.getEndLoc())
|
||||
.toCharRange(SM),
|
||||
File, "SearchPath", "RelPath",
|
||||
/*Imported=*/nullptr, Inc.FileKind);
|
||||
/*SuggestedModule=*/nullptr, /*ModuleImported=*/false, Inc.FileKind);
|
||||
if (File)
|
||||
Delegate->FileSkipped(*File, SynthesizedFilenameTok, Inc.FileKind);
|
||||
}
|
||||
|
@ -89,7 +89,8 @@ public:
|
||||
llvm::StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, llvm::StringRef SearchPath,
|
||||
llvm::StringRef RelativePath, const Module *Imported,
|
||||
llvm::StringRef RelativePath,
|
||||
const Module *SuggestedModule, bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override {
|
||||
auto IncludeURI = toURI(File);
|
||||
if (!IncludeURI)
|
||||
|
@ -72,7 +72,7 @@ struct ReplayPreamblePPCallback : public PPCallbacks {
|
||||
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
|
||||
StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange, OptionalFileEntryRef,
|
||||
StringRef, StringRef, const clang::Module *,
|
||||
StringRef, StringRef, const clang::Module *, bool,
|
||||
SrcMgr::CharacteristicKind) override {
|
||||
Includes.emplace_back(SM, HashLoc, IncludeTok, FileName, IsAngled,
|
||||
FilenameRange);
|
||||
|
@ -65,7 +65,8 @@ public:
|
||||
StringRef SpelledFilename, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *,
|
||||
StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind) override {
|
||||
if (!Active)
|
||||
return;
|
||||
@ -214,7 +215,8 @@ public:
|
||||
OptionalFileEntryRef File,
|
||||
llvm::StringRef /*SearchPath*/,
|
||||
llvm::StringRef /*RelativePath*/,
|
||||
const clang::Module * /*Imported*/,
|
||||
const clang::Module * /*SuggestedModule*/,
|
||||
bool /*ModuleImported*/,
|
||||
SrcMgr::CharacteristicKind FileKind) override {
|
||||
FileID HashFID = SM.getFileID(HashLoc);
|
||||
int HashLine = SM.getLineNumber(HashFID, SM.getFileOffset(HashLoc));
|
||||
|
@ -90,7 +90,8 @@ public:
|
||||
StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *Imported,
|
||||
StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override {
|
||||
Checker.collectUmbrellaHeaderHeader(File->getName());
|
||||
}
|
||||
|
@ -730,15 +730,14 @@ public:
|
||||
~PreprocessorCallbacks() override {}
|
||||
|
||||
// Overridden handlers.
|
||||
void InclusionDirective(clang::SourceLocation HashLoc,
|
||||
const clang::Token &IncludeTok,
|
||||
llvm::StringRef FileName, bool IsAngled,
|
||||
clang::CharSourceRange FilenameRange,
|
||||
clang::OptionalFileEntryRef File,
|
||||
llvm::StringRef SearchPath,
|
||||
llvm::StringRef RelativePath,
|
||||
const clang::Module *Imported,
|
||||
clang::SrcMgr::CharacteristicKind FileType) override;
|
||||
void
|
||||
InclusionDirective(clang::SourceLocation HashLoc,
|
||||
const clang::Token &IncludeTok, llvm::StringRef FileName,
|
||||
bool IsAngled, clang::CharSourceRange FilenameRange,
|
||||
clang::OptionalFileEntryRef File,
|
||||
llvm::StringRef SearchPath, llvm::StringRef RelativePath,
|
||||
const clang::Module *SuggestedModule, bool ModuleImported,
|
||||
clang::SrcMgr::CharacteristicKind FileType) override;
|
||||
void FileChanged(clang::SourceLocation Loc,
|
||||
clang::PPCallbacks::FileChangeReason Reason,
|
||||
clang::SrcMgr::CharacteristicKind FileType,
|
||||
@ -1275,7 +1274,8 @@ void PreprocessorCallbacks::InclusionDirective(
|
||||
llvm::StringRef FileName, bool IsAngled,
|
||||
clang::CharSourceRange FilenameRange, clang::OptionalFileEntryRef File,
|
||||
llvm::StringRef SearchPath, llvm::StringRef RelativePath,
|
||||
const clang::Module *Imported, clang::SrcMgr::CharacteristicKind FileType) {
|
||||
const clang::Module *SuggestedModule, bool ModuleImported,
|
||||
clang::SrcMgr::CharacteristicKind FileType) {
|
||||
int DirectiveLine, DirectiveColumn;
|
||||
std::string HeaderPath = getSourceLocationFile(PP, HashLoc);
|
||||
getSourceLocationLineAndColumn(PP, HashLoc, DirectiveLine, DirectiveColumn);
|
||||
|
@ -135,7 +135,8 @@ void PPCallbacksTracker::InclusionDirective(
|
||||
SourceLocation HashLoc, const Token &IncludeTok, llvm::StringRef FileName,
|
||||
bool IsAngled, CharSourceRange FilenameRange, OptionalFileEntryRef File,
|
||||
llvm::StringRef SearchPath, llvm::StringRef RelativePath,
|
||||
const Module *Imported, SrcMgr::CharacteristicKind FileType) {
|
||||
const Module *SuggestedModule, bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) {
|
||||
beginCallback("InclusionDirective");
|
||||
appendArgument("HashLoc", HashLoc);
|
||||
appendArgument("IncludeTok", IncludeTok);
|
||||
@ -145,7 +146,8 @@ void PPCallbacksTracker::InclusionDirective(
|
||||
appendArgument("File", File);
|
||||
appendFilePathArgument("SearchPath", SearchPath);
|
||||
appendFilePathArgument("RelativePath", RelativePath);
|
||||
appendArgument("Imported", Imported);
|
||||
appendArgument("SuggestedModule", SuggestedModule);
|
||||
appendArgument("ModuleImported", ModuleImported);
|
||||
}
|
||||
|
||||
// Callback invoked whenever there was an explicit module-import
|
||||
|
@ -95,7 +95,8 @@ public:
|
||||
llvm::StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, llvm::StringRef SearchPath,
|
||||
llvm::StringRef RelativePath, const Module *Imported,
|
||||
llvm::StringRef RelativePath,
|
||||
const Module *SuggestedModule, bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override;
|
||||
void moduleImport(SourceLocation ImportLoc, ModuleIdPath Path,
|
||||
const Module *Imported) override;
|
||||
|
@ -59,7 +59,8 @@
|
||||
// CHECK-NEXT: File: "{{.*}}{{[/\\]}}Inputs/Level1A.h"
|
||||
// CHECK-NEXT: SearchPath: "{{.*}}{{[/\\]}}pp-trace"
|
||||
// CHECK-NEXT: RelativePath: "Inputs/Level1A.h"
|
||||
// CHECK-NEXT: Imported: (null)
|
||||
// CHECK-NEXT: SuggestedModule: (null)
|
||||
// CHECK-NEXT: ModuleImported: false
|
||||
// CHECK-NEXT: - Callback: FileChanged
|
||||
// CHECK-NEXT: Loc: "{{.*}}{{[/\\]}}Inputs/Level1A.h:1:1"
|
||||
// CHECK-NEXT: Reason: EnterFile
|
||||
@ -74,7 +75,8 @@
|
||||
// CHECK-NEXT: File: "{{.*}}{{[/\\]}}Inputs/Level2A.h"
|
||||
// CHECK-NEXT: SearchPath: "{{.*}}{{[/\\]}}Inputs"
|
||||
// CHECK-NEXT: RelativePath: "Level2A.h"
|
||||
// CHECK-NEXT: Imported: (null)
|
||||
// CHECK-NEXT: SuggestedModule: (null)
|
||||
// CHECK-NEXT: ModuleImported: false
|
||||
// CHECK-NEXT: - Callback: FileChanged
|
||||
// CHECK-NEXT: Loc: "{{.*}}{{[/\\]}}Inputs/Level2A.h:1:1"
|
||||
// CHECK-NEXT: Reason: EnterFile
|
||||
@ -105,7 +107,8 @@
|
||||
// CHECK-NEXT: File: "{{.*}}{{[/\\]}}Inputs/Level1B.h"
|
||||
// CHECK-NEXT: SearchPath: "{{.*}}{{[/\\]}}pp-trace"
|
||||
// CHECK-NEXT: RelativePath: "Inputs/Level1B.h"
|
||||
// CHECK-NEXT: Imported: (null)
|
||||
// CHECK-NEXT: SuggestedModule: (null)
|
||||
// CHECK-NEXT: ModuleImported: false
|
||||
// CHECK-NEXT: - Callback: FileChanged
|
||||
// CHECK-NEXT: Loc: "{{.*}}{{[/\\]}}Inputs/Level1B.h:1:1"
|
||||
// CHECK-NEXT: Reason: EnterFile
|
||||
@ -120,7 +123,8 @@
|
||||
// CHECK-NEXT: File: "{{.*}}{{[/\\]}}Inputs/Level2B.h"
|
||||
// CHECK-NEXT: SearchPath: "{{.*}}{{[/\\]}}Inputs"
|
||||
// CHECK-NEXT: RelativePath: "Level2B.h"
|
||||
// CHECK-NEXT: Imported: (null)
|
||||
// CHECK-NEXT: SuggestedModule: (null)
|
||||
// CHECK-NEXT: ModuleImported: false
|
||||
// CHECK-NEXT: - Callback: FileChanged
|
||||
// CHECK-NEXT: Loc: "{{.*}}{{[/\\]}}Inputs/Level2B.h:1:1"
|
||||
// CHECK-NEXT: Reason: EnterFile
|
||||
|
@ -127,8 +127,10 @@ public:
|
||||
/// \param RelativePath The path relative to SearchPath, at which the include
|
||||
/// file was found. This is equal to FileName except for framework includes.
|
||||
///
|
||||
/// \param Imported The module, whenever an inclusion directive was
|
||||
/// automatically turned into a module import or null otherwise.
|
||||
/// \param SuggestedModule The module suggested for this header, if any.
|
||||
///
|
||||
/// \param ModuleImported Whether this include was translated into import of
|
||||
/// \p SuggestedModule.
|
||||
///
|
||||
/// \param FileType The characteristic kind, indicates whether a file or
|
||||
/// directory holds normal user code, system code, or system code which is
|
||||
@ -139,7 +141,8 @@ public:
|
||||
bool IsAngled, CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File,
|
||||
StringRef SearchPath, StringRef RelativePath,
|
||||
const Module *Imported,
|
||||
const Module *SuggestedModule,
|
||||
bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) {}
|
||||
|
||||
/// Callback invoked whenever a submodule was entered.
|
||||
@ -473,14 +476,15 @@ public:
|
||||
StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *Imported,
|
||||
StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override {
|
||||
First->InclusionDirective(HashLoc, IncludeTok, FileName, IsAngled,
|
||||
FilenameRange, File, SearchPath, RelativePath,
|
||||
Imported, FileType);
|
||||
SuggestedModule, ModuleImported, FileType);
|
||||
Second->InclusionDirective(HashLoc, IncludeTok, FileName, IsAngled,
|
||||
FilenameRange, File, SearchPath, RelativePath,
|
||||
Imported, FileType);
|
||||
SuggestedModule, ModuleImported, FileType);
|
||||
}
|
||||
|
||||
void EnteredSubmodule(Module *M, SourceLocation ImportLoc,
|
||||
|
@ -532,7 +532,8 @@ class Token;
|
||||
StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *Imported,
|
||||
StringRef RelativePath,
|
||||
const Module *SuggestedModule, bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override;
|
||||
void Ifdef(SourceLocation Loc, const Token &MacroNameTok,
|
||||
const MacroDefinition &MD) override;
|
||||
|
@ -166,7 +166,8 @@ public:
|
||||
StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *Imported,
|
||||
StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override;
|
||||
void moduleImport(SourceLocation ImportLoc, ModuleIdPath Path,
|
||||
const Module *Imported) override;
|
||||
|
@ -168,8 +168,8 @@ void MacroPPCallbacks::FileChanged(SourceLocation Loc, FileChangeReason Reason,
|
||||
void MacroPPCallbacks::InclusionDirective(
|
||||
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
|
||||
bool IsAngled, CharSourceRange FilenameRange, OptionalFileEntryRef File,
|
||||
StringRef SearchPath, StringRef RelativePath, const Module *Imported,
|
||||
SrcMgr::CharacteristicKind FileType) {
|
||||
StringRef SearchPath, StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported, SrcMgr::CharacteristicKind FileType) {
|
||||
|
||||
// Record the line location of the current included file.
|
||||
LastHashLoc = HashLoc;
|
||||
|
@ -102,7 +102,8 @@ public:
|
||||
StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *Imported,
|
||||
StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override;
|
||||
|
||||
/// Hook called whenever a macro definition is seen.
|
||||
|
@ -66,7 +66,8 @@ struct DepCollectorPPCallbacks : public PPCallbacks {
|
||||
StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *Imported,
|
||||
StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override {
|
||||
if (!File)
|
||||
DepCollector.maybeAddDependency(FileName, /*FromModule*/ false,
|
||||
|
@ -49,7 +49,8 @@ public:
|
||||
StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *Imported,
|
||||
StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override;
|
||||
|
||||
void EndOfMainFile() override {
|
||||
@ -68,8 +69,8 @@ void clang::AttachDependencyGraphGen(Preprocessor &PP, StringRef OutputFile,
|
||||
void DependencyGraphCallback::InclusionDirective(
|
||||
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
|
||||
bool IsAngled, CharSourceRange FilenameRange, OptionalFileEntryRef File,
|
||||
StringRef SearchPath, StringRef RelativePath, const Module *Imported,
|
||||
SrcMgr::CharacteristicKind FileType) {
|
||||
StringRef SearchPath, StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported, SrcMgr::CharacteristicKind FileType) {
|
||||
if (!File)
|
||||
return;
|
||||
|
||||
|
@ -55,7 +55,8 @@ struct ModuleDependencyPPCallbacks : public PPCallbacks {
|
||||
StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *Imported,
|
||||
StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override {
|
||||
if (!File)
|
||||
return;
|
||||
|
@ -98,7 +98,8 @@ public:
|
||||
StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *Imported,
|
||||
StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override {
|
||||
// File is std::nullopt if it wasn't found.
|
||||
// (We have some false negatives if PP recovered e.g. <foo> -> "foo")
|
||||
|
@ -153,7 +153,8 @@ public:
|
||||
StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *Imported,
|
||||
StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override;
|
||||
void Ident(SourceLocation Loc, StringRef str) override;
|
||||
void PragmaMessage(SourceLocation Loc, StringRef Namespace,
|
||||
@ -401,8 +402,8 @@ void PrintPPOutputPPCallbacks::FileChanged(SourceLocation Loc,
|
||||
void PrintPPOutputPPCallbacks::InclusionDirective(
|
||||
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
|
||||
bool IsAngled, CharSourceRange FilenameRange, OptionalFileEntryRef File,
|
||||
StringRef SearchPath, StringRef RelativePath, const Module *Imported,
|
||||
SrcMgr::CharacteristicKind FileType) {
|
||||
StringRef SearchPath, StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported, SrcMgr::CharacteristicKind FileType) {
|
||||
// In -dI mode, dump #include directives prior to dumping their content or
|
||||
// interpretation. Similar for -fkeep-system-includes.
|
||||
if (DumpIncludeDirectives || (KeepSystemIncludes && isSystem(FileType))) {
|
||||
@ -418,14 +419,14 @@ void PrintPPOutputPPCallbacks::InclusionDirective(
|
||||
}
|
||||
|
||||
// When preprocessing, turn implicit imports into module import pragmas.
|
||||
if (Imported) {
|
||||
if (ModuleImported) {
|
||||
switch (IncludeTok.getIdentifierInfo()->getPPKeywordID()) {
|
||||
case tok::pp_include:
|
||||
case tok::pp_import:
|
||||
case tok::pp_include_next:
|
||||
MoveToLine(HashLoc, /*RequireStartOfLine=*/true);
|
||||
*OS << "#pragma clang module import "
|
||||
<< Imported->getFullModuleName(true)
|
||||
<< SuggestedModule->getFullModuleName(true)
|
||||
<< " /* clang -E: implicit import for "
|
||||
<< "#" << PP.getSpelling(IncludeTok) << " "
|
||||
<< (IsAngled ? '<' : '"') << FileName << (IsAngled ? '>' : '"')
|
||||
|
@ -75,7 +75,8 @@ private:
|
||||
StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *Imported,
|
||||
StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override;
|
||||
void If(SourceLocation Loc, SourceRange ConditionRange,
|
||||
ConditionValueKind ConditionValue) override;
|
||||
@ -189,9 +190,10 @@ void InclusionRewriter::InclusionDirective(
|
||||
StringRef /*FileName*/, bool /*IsAngled*/,
|
||||
CharSourceRange /*FilenameRange*/, OptionalFileEntryRef /*File*/,
|
||||
StringRef /*SearchPath*/, StringRef /*RelativePath*/,
|
||||
const Module *Imported, SrcMgr::CharacteristicKind FileType) {
|
||||
if (Imported) {
|
||||
auto P = ModuleIncludes.insert(std::make_pair(HashLoc, Imported));
|
||||
const Module *SuggestedModule, bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) {
|
||||
if (ModuleImported) {
|
||||
auto P = ModuleIncludes.insert(std::make_pair(HashLoc, SuggestedModule));
|
||||
(void)P;
|
||||
assert(P.second && "Unexpected revisitation of the same include directive");
|
||||
} else
|
||||
|
@ -2253,26 +2253,27 @@ Preprocessor::ImportAction Preprocessor::HandleHeaderIncludeOrImport(
|
||||
|
||||
// FIXME: We do not have a good way to disambiguate C++ clang modules from
|
||||
// C++ standard modules (other than use/non-use of Header Units).
|
||||
Module *SM = SuggestedModule.getModule();
|
||||
|
||||
bool MaybeTranslateInclude =
|
||||
Action == Enter && File && SM && !SM->isForBuilding(getLangOpts());
|
||||
Module *ModuleToImport = SuggestedModule.getModule();
|
||||
|
||||
bool MaybeTranslateInclude = Action == Enter && File && ModuleToImport &&
|
||||
!ModuleToImport->isForBuilding(getLangOpts());
|
||||
|
||||
// Maybe a usable Header Unit
|
||||
bool UsableHeaderUnit = false;
|
||||
if (getLangOpts().CPlusPlusModules && SM && SM->isHeaderUnit()) {
|
||||
if (getLangOpts().CPlusPlusModules && ModuleToImport &&
|
||||
ModuleToImport->isHeaderUnit()) {
|
||||
if (TrackGMFState.inGMF() || IsImportDecl)
|
||||
UsableHeaderUnit = true;
|
||||
else if (!IsImportDecl) {
|
||||
// This is a Header Unit that we do not include-translate
|
||||
SuggestedModule = ModuleMap::KnownHeader();
|
||||
SM = nullptr;
|
||||
ModuleToImport = nullptr;
|
||||
}
|
||||
}
|
||||
// Maybe a usable clang header module.
|
||||
bool UsableClangHeaderModule =
|
||||
(getLangOpts().CPlusPlusModules || getLangOpts().Modules) && SM &&
|
||||
!SM->isHeaderUnit();
|
||||
(getLangOpts().CPlusPlusModules || getLangOpts().Modules) &&
|
||||
ModuleToImport && !ModuleToImport->isHeaderUnit();
|
||||
|
||||
// Determine whether we should try to import the module for this #include, if
|
||||
// there is one. Don't do so if precompiled module support is disabled or we
|
||||
@ -2282,12 +2283,11 @@ Preprocessor::ImportAction Preprocessor::HandleHeaderIncludeOrImport(
|
||||
// unavailable, diagnose the situation and bail out.
|
||||
// FIXME: Remove this; loadModule does the same check (but produces
|
||||
// slightly worse diagnostics).
|
||||
if (checkModuleIsAvailable(getLangOpts(), getTargetInfo(),
|
||||
*SuggestedModule.getModule(),
|
||||
if (checkModuleIsAvailable(getLangOpts(), getTargetInfo(), *ModuleToImport,
|
||||
getDiagnostics())) {
|
||||
Diag(FilenameTok.getLocation(),
|
||||
diag::note_implicit_top_level_module_import_here)
|
||||
<< SuggestedModule.getModule()->getTopLevelModuleName();
|
||||
<< ModuleToImport->getTopLevelModuleName();
|
||||
return {ImportAction::None};
|
||||
}
|
||||
|
||||
@ -2295,7 +2295,7 @@ Preprocessor::ImportAction Preprocessor::HandleHeaderIncludeOrImport(
|
||||
// FIXME: Should we have a second loadModule() overload to avoid this
|
||||
// extra lookup step?
|
||||
SmallVector<std::pair<IdentifierInfo *, SourceLocation>, 2> Path;
|
||||
for (Module *Mod = SM; Mod; Mod = Mod->Parent)
|
||||
for (Module *Mod = ModuleToImport; Mod; Mod = Mod->Parent)
|
||||
Path.push_back(std::make_pair(getIdentifierInfo(Mod->Name),
|
||||
FilenameTok.getLocation()));
|
||||
std::reverse(Path.begin(), Path.end());
|
||||
@ -2306,12 +2306,12 @@ Preprocessor::ImportAction Preprocessor::HandleHeaderIncludeOrImport(
|
||||
|
||||
// Load the module to import its macros. We'll make the declarations
|
||||
// visible when the parser gets here.
|
||||
// FIXME: Pass SuggestedModule in here rather than converting it to a path
|
||||
// and making the module loader convert it back again.
|
||||
// FIXME: Pass SM in here rather than converting it to a path and making the
|
||||
// module loader convert it back again.
|
||||
ModuleLoadResult Imported = TheModuleLoader.loadModule(
|
||||
IncludeTok.getLocation(), Path, Module::Hidden,
|
||||
/*IsInclusionDirective=*/true);
|
||||
assert((Imported == nullptr || Imported == SuggestedModule.getModule()) &&
|
||||
assert((Imported == nullptr || Imported == SM) &&
|
||||
"the imported module is different than the suggested one");
|
||||
|
||||
if (Imported) {
|
||||
@ -2323,8 +2323,7 @@ Preprocessor::ImportAction Preprocessor::HandleHeaderIncludeOrImport(
|
||||
// was in the directory of an umbrella header, for instance), but no
|
||||
// actual module containing it exists (because the umbrella header is
|
||||
// incomplete). Treat this as a textual inclusion.
|
||||
SuggestedModule = ModuleMap::KnownHeader();
|
||||
SM = nullptr;
|
||||
ModuleToImport = nullptr;
|
||||
} else if (Imported.isConfigMismatch()) {
|
||||
// On a configuration mismatch, enter the header textually. We still know
|
||||
// that it's part of the corresponding module.
|
||||
@ -2365,7 +2364,7 @@ Preprocessor::ImportAction Preprocessor::HandleHeaderIncludeOrImport(
|
||||
// this file will have no effect.
|
||||
if (Action == Enter && File &&
|
||||
!HeaderInfo.ShouldEnterIncludeFile(*this, *File, EnterOnce,
|
||||
getLangOpts().Modules, SM,
|
||||
getLangOpts().Modules, ModuleToImport,
|
||||
IsFirstIncludeOfFile)) {
|
||||
// C++ standard modules:
|
||||
// If we are not in the GMF, then we textually include only
|
||||
@ -2380,7 +2379,7 @@ Preprocessor::ImportAction Preprocessor::HandleHeaderIncludeOrImport(
|
||||
if (UsableHeaderUnit && !getLangOpts().CompilingPCH)
|
||||
Action = TrackGMFState.inGMF() ? Import : Skip;
|
||||
else
|
||||
Action = (SuggestedModule && !getLangOpts().CompilingPCH) ? Import : Skip;
|
||||
Action = (ModuleToImport && !getLangOpts().CompilingPCH) ? Import : Skip;
|
||||
}
|
||||
|
||||
// Check for circular inclusion of the main file.
|
||||
@ -2400,8 +2399,7 @@ Preprocessor::ImportAction Preprocessor::HandleHeaderIncludeOrImport(
|
||||
// FIXME: Use a different callback for a pp-import?
|
||||
Callbacks->InclusionDirective(HashLoc, IncludeTok, LookupFilename, isAngled,
|
||||
FilenameRange, File, SearchPath, RelativePath,
|
||||
Action == Import ? SuggestedModule.getModule()
|
||||
: nullptr,
|
||||
SuggestedModule.getModule(), Action == Import,
|
||||
FileCharacter);
|
||||
if (Action == Skip && File)
|
||||
Callbacks->FileSkipped(*File, FilenameTok, FileCharacter);
|
||||
@ -2412,7 +2410,7 @@ Preprocessor::ImportAction Preprocessor::HandleHeaderIncludeOrImport(
|
||||
|
||||
// If this is a C++20 pp-import declaration, diagnose if we didn't find any
|
||||
// module corresponding to the named header.
|
||||
if (IsImportDecl && !SuggestedModule) {
|
||||
if (IsImportDecl && !ModuleToImport) {
|
||||
Diag(FilenameTok, diag::err_header_import_not_header_unit)
|
||||
<< OriginalFilename << File->getName();
|
||||
return {ImportAction::None};
|
||||
@ -2517,8 +2515,8 @@ Preprocessor::ImportAction Preprocessor::HandleHeaderIncludeOrImport(
|
||||
switch (Action) {
|
||||
case Skip:
|
||||
// If we don't need to enter the file, stop now.
|
||||
if (SM)
|
||||
return {ImportAction::SkippedModuleImport, SM};
|
||||
if (ModuleToImport)
|
||||
return {ImportAction::SkippedModuleImport, ModuleToImport};
|
||||
return {ImportAction::None};
|
||||
|
||||
case IncludeLimitReached:
|
||||
@ -2530,13 +2528,13 @@ Preprocessor::ImportAction Preprocessor::HandleHeaderIncludeOrImport(
|
||||
// If this is a module import, make it visible if needed.
|
||||
assert(SM && "no module to import");
|
||||
|
||||
makeModuleVisible(SM, EndLoc);
|
||||
makeModuleVisible(ModuleToImport, EndLoc);
|
||||
|
||||
if (IncludeTok.getIdentifierInfo()->getPPKeywordID() ==
|
||||
tok::pp___include_macros)
|
||||
return {ImportAction::None};
|
||||
|
||||
return {ImportAction::ModuleImport, SM};
|
||||
return {ImportAction::ModuleImport, ModuleToImport};
|
||||
}
|
||||
|
||||
case Enter:
|
||||
@ -2573,13 +2571,14 @@ Preprocessor::ImportAction Preprocessor::HandleHeaderIncludeOrImport(
|
||||
|
||||
// Determine if we're switching to building a new submodule, and which one.
|
||||
// This does not apply for C++20 modules header units.
|
||||
if (SM && !SM->isHeaderUnit()) {
|
||||
if (SM->getTopLevelModule()->ShadowingModule) {
|
||||
if (ModuleToImport && !ModuleToImport->isHeaderUnit()) {
|
||||
if (ModuleToImport->getTopLevelModule()->ShadowingModule) {
|
||||
// We are building a submodule that belongs to a shadowed module. This
|
||||
// means we find header files in the shadowed module.
|
||||
Diag(SM->DefinitionLoc, diag::err_module_build_shadowed_submodule)
|
||||
<< SM->getFullModuleName();
|
||||
Diag(SM->getTopLevelModule()->ShadowingModule->DefinitionLoc,
|
||||
Diag(ModuleToImport->DefinitionLoc,
|
||||
diag::err_module_build_shadowed_submodule)
|
||||
<< ModuleToImport->getFullModuleName();
|
||||
Diag(ModuleToImport->getTopLevelModule()->ShadowingModule->DefinitionLoc,
|
||||
diag::note_previous_definition);
|
||||
return {ImportAction::None};
|
||||
}
|
||||
@ -2591,21 +2590,22 @@ Preprocessor::ImportAction Preprocessor::HandleHeaderIncludeOrImport(
|
||||
// that behaves the same as the header would behave in a compilation using
|
||||
// that PCH, which means we should enter the submodule. We need to teach
|
||||
// the AST serialization layer to deal with the resulting AST.
|
||||
if (getLangOpts().CompilingPCH && SM->isForBuilding(getLangOpts()))
|
||||
if (getLangOpts().CompilingPCH &&
|
||||
ModuleToImport->isForBuilding(getLangOpts()))
|
||||
return {ImportAction::None};
|
||||
|
||||
assert(!CurLexerSubmodule && "should not have marked this as a module yet");
|
||||
CurLexerSubmodule = SM;
|
||||
CurLexerSubmodule = ModuleToImport;
|
||||
|
||||
// Let the macro handling code know that any future macros are within
|
||||
// the new submodule.
|
||||
EnterSubmodule(SM, EndLoc, /*ForPragma*/ false);
|
||||
EnterSubmodule(ModuleToImport, EndLoc, /*ForPragma*/ false);
|
||||
|
||||
// Let the parser know that any future declarations are within the new
|
||||
// submodule.
|
||||
// FIXME: There's no point doing this if we're handling a #__include_macros
|
||||
// directive.
|
||||
return {ImportAction::ModuleBegin, SM};
|
||||
return {ImportAction::ModuleBegin, ModuleToImport};
|
||||
}
|
||||
|
||||
assert(!IsImportDecl && "failed to diagnose missing module for import decl");
|
||||
|
@ -472,8 +472,8 @@ void PreprocessingRecord::MacroUndefined(const Token &Id,
|
||||
void PreprocessingRecord::InclusionDirective(
|
||||
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
|
||||
bool IsAngled, CharSourceRange FilenameRange, OptionalFileEntryRef File,
|
||||
StringRef SearchPath, StringRef RelativePath, const Module *Imported,
|
||||
SrcMgr::CharacteristicKind FileType) {
|
||||
StringRef SearchPath, StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported, SrcMgr::CharacteristicKind FileType) {
|
||||
InclusionDirective::InclusionKind Kind = InclusionDirective::Include;
|
||||
|
||||
switch (IncludeTok.getIdentifierInfo()->getPPKeywordID()) {
|
||||
@ -506,10 +506,9 @@ void PreprocessingRecord::InclusionDirective(
|
||||
EndLoc = EndLoc.getLocWithOffset(-1); // the InclusionDirective expects
|
||||
// a token range.
|
||||
}
|
||||
clang::InclusionDirective *ID =
|
||||
new (*this) clang::InclusionDirective(*this, Kind, FileName, !IsAngled,
|
||||
(bool)Imported, File,
|
||||
SourceRange(HashLoc, EndLoc));
|
||||
clang::InclusionDirective *ID = new (*this) clang::InclusionDirective(
|
||||
*this, Kind, FileName, !IsAngled, ModuleImported, File,
|
||||
SourceRange(HashLoc, EndLoc));
|
||||
addPreprocessedEntity(ID);
|
||||
}
|
||||
|
||||
|
@ -430,14 +430,14 @@ void ModuleDepCollectorPP::LexedFileChanged(FileID FID,
|
||||
void ModuleDepCollectorPP::InclusionDirective(
|
||||
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
|
||||
bool IsAngled, CharSourceRange FilenameRange, OptionalFileEntryRef File,
|
||||
StringRef SearchPath, StringRef RelativePath, const Module *Imported,
|
||||
SrcMgr::CharacteristicKind FileType) {
|
||||
if (!File && !Imported) {
|
||||
StringRef SearchPath, StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported, SrcMgr::CharacteristicKind FileType) {
|
||||
if (!File && !ModuleImported) {
|
||||
// This is a non-modular include that HeaderSearch failed to find. Add it
|
||||
// here as `FileChanged` will never see it.
|
||||
MDC.addFileDep(FileName);
|
||||
}
|
||||
handleImport(Imported);
|
||||
handleImport(SuggestedModule);
|
||||
}
|
||||
|
||||
void ModuleDepCollectorPP::moduleImport(SourceLocation ImportLoc,
|
||||
|
@ -261,12 +261,13 @@ public:
|
||||
StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *Imported,
|
||||
StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override {
|
||||
bool isImport = (IncludeTok.is(tok::identifier) &&
|
||||
IncludeTok.getIdentifierInfo()->getPPKeywordID() == tok::pp_import);
|
||||
DataConsumer.ppIncludedFile(HashLoc, FileName, File, isImport, IsAngled,
|
||||
Imported);
|
||||
ModuleImported);
|
||||
}
|
||||
|
||||
/// MacroDefined - This hook is called whenever a macro definition is seen.
|
||||
|
@ -37,7 +37,8 @@ public:
|
||||
StringRef FileName, bool IsAngled,
|
||||
CharSourceRange FilenameRange,
|
||||
OptionalFileEntryRef File, StringRef SearchPath,
|
||||
StringRef RelativePath, const Module *Imported,
|
||||
StringRef RelativePath, const Module *SuggestedModule,
|
||||
bool ModuleImported,
|
||||
SrcMgr::CharacteristicKind FileType) override {
|
||||
this->HashLoc = HashLoc;
|
||||
this->IncludeTok = IncludeTok;
|
||||
@ -47,7 +48,8 @@ public:
|
||||
this->File = File;
|
||||
this->SearchPath = SearchPath.str();
|
||||
this->RelativePath = RelativePath.str();
|
||||
this->Imported = Imported;
|
||||
this->SuggestedModule = SuggestedModule;
|
||||
this->ModuleImported = ModuleImported;
|
||||
this->FileType = FileType;
|
||||
}
|
||||
|
||||
@ -59,7 +61,8 @@ public:
|
||||
OptionalFileEntryRef File;
|
||||
SmallString<16> SearchPath;
|
||||
SmallString<16> RelativePath;
|
||||
const Module* Imported;
|
||||
const Module *SuggestedModule;
|
||||
bool ModuleImported;
|
||||
SrcMgr::CharacteristicKind FileType;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user