From 19d78b743f805c5b89c8f6ae644c4cbb9c5f924e Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Sat, 29 Sep 2012 01:06:10 +0000 Subject: For PPCallbacks::InclusionDirective() add a parameter for the module, whenever an inclusion directive was automatically turned into a module import, and PPCallbacks::moduleImport() for an explicit module import. llvm-svn: 164874 --- clang/lib/Lex/PPDirectives.cpp | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'clang/lib/Lex/PPDirectives.cpp') diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index 5cff2fc48f3..23cbef63edf 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -1314,6 +1314,8 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, return; } + CharSourceRange FilenameRange + = CharSourceRange::getCharRange(FilenameTok.getLocation(), CharEnd); StringRef OriginalFilename = Filename; bool isAngled = GetIncludeFilenameSpelling(FilenameTok.getLocation(), Filename); @@ -1384,10 +1386,13 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, } } - // Notify the callback object that we've seen an inclusion directive. - Callbacks->InclusionDirective(HashLoc, IncludeTok, Filename, isAngled, - CharSourceRange::getCharRange(FilenameTok.getLocation(), CharEnd), - File, SearchPath, RelativePath); + if (!SuggestedModule) { + // Notify the callback object that we've seen an inclusion directive. + Callbacks->InclusionDirective(HashLoc, IncludeTok, Filename, isAngled, + FilenameRange, File, + SearchPath, RelativePath, + /*ImportedModule=*/0); + } } if (File == 0) { @@ -1485,8 +1490,24 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, "the imported module is different than the suggested one"); // If this header isn't part of the module we're building, we're done. - if (!BuildingImportedModule && Imported) + if (!BuildingImportedModule && Imported) { + if (Callbacks) { + Callbacks->InclusionDirective(HashLoc, IncludeTok, Filename, isAngled, + FilenameRange, File, + SearchPath, RelativePath, Imported); + } return; + } + } + + if (Callbacks && SuggestedModule) { + // We didn't notify the callback object that we've seen an inclusion + // directive before. Now that we are parsing the include normally and not + // turning it to a module import, notify the callback object. + Callbacks->InclusionDirective(HashLoc, IncludeTok, Filename, isAngled, + FilenameRange, File, + SearchPath, RelativePath, + /*ImportedModule=*/0); } // The #included file will be considered to be a system header if either it is -- cgit v1.2.3