summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/PPDirectives.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-11-30 18:12:06 +0000
committerDouglas Gregor <dgregor@apple.com>2011-11-30 18:12:06 +0000
commit11729f01f9a50ae59a054f062a3e18c89760a52e (patch)
treefd88d6c8799f434380fa352b9e3368f2162b78e3 /clang/lib/Lex/PPDirectives.cpp
parent4401fbee563561164858ad7e47480cb0b64a52ba (diff)
downloadbcm5719-llvm-11729f01f9a50ae59a054f062a3e18c89760a52e.tar.gz
bcm5719-llvm-11729f01f9a50ae59a054f062a3e18c89760a52e.zip
Move the module auto-import logic after the logic that allows a
callback client to suggest an alternative search path and after we complain when the included file can't be found. The former can't be tested in isolation, the latter doesn't actually matter (because we won't make a module suggestion if no header is available). However, the flow is better this way. llvm-svn: 145502
Diffstat (limited to 'clang/lib/Lex/PPDirectives.cpp')
-rw-r--r--clang/lib/Lex/PPDirectives.cpp58
1 files changed, 29 insertions, 29 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 98362dfd57e..9e5757f03d0 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -1280,6 +1280,35 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,
Callbacks ? &SearchPath : NULL, Callbacks ? &RelativePath : NULL,
AutoModuleImport? &SuggestedModule : 0);
+ if (Callbacks) {
+ if (!File) {
+ // Give the clients a chance to recover.
+ llvm::SmallString<128> RecoveryPath;
+ if (Callbacks->FileNotFound(Filename, RecoveryPath)) {
+ if (const DirectoryEntry *DE = FileMgr.getDirectory(RecoveryPath)) {
+ // Add the recovery path to the list of search paths.
+ DirectoryLookup DL(DE, SrcMgr::C_User, true, false);
+ HeaderInfo.AddSearchPath(DL, isAngled);
+
+ // Try the lookup again, skipping the cache.
+ File = LookupFile(Filename, isAngled, LookupFrom, CurDir, 0, 0,
+ AutoModuleImport ? &SuggestedModule : 0,
+ /*SkipCache*/true);
+ }
+ }
+ }
+
+ // Notify the callback object that we've seen an inclusion directive.
+ Callbacks->InclusionDirective(HashLoc, IncludeTok, Filename, isAngled, File,
+ End, SearchPath, RelativePath);
+ }
+
+ if (File == 0) {
+ if (!SuppressIncludeNotFoundError)
+ Diag(FilenameTok, diag::err_pp_file_not_found) << Filename;
+ return;
+ }
+
// If we are supposed to import a module rather than including the header,
// do so now.
if (SuggestedModule) {
@@ -1335,35 +1364,6 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,
return;
}
- if (Callbacks) {
- if (!File) {
- // Give the clients a chance to recover.
- llvm::SmallString<128> RecoveryPath;
- if (Callbacks->FileNotFound(Filename, RecoveryPath)) {
- if (const DirectoryEntry *DE = FileMgr.getDirectory(RecoveryPath)) {
- // Add the recovery path to the list of search paths.
- DirectoryLookup DL(DE, SrcMgr::C_User, true, false);
- HeaderInfo.AddSearchPath(DL, isAngled);
-
- // Try the lookup again, skipping the cache.
- File = LookupFile(Filename, isAngled, LookupFrom, CurDir, 0, 0,
- AutoModuleImport ? &SuggestedModule : 0,
- /*SkipCache*/true);
- }
- }
- }
-
- // Notify the callback object that we've seen an inclusion directive.
- Callbacks->InclusionDirective(HashLoc, IncludeTok, Filename, isAngled, File,
- End, SearchPath, RelativePath);
- }
-
- if (File == 0) {
- if (!SuppressIncludeNotFoundError)
- Diag(FilenameTok, diag::err_pp_file_not_found) << Filename;
- return;
- }
-
// The #included file will be considered to be a system header if either it is
// in a system include directory, or if the #includer is a system include
// header.
OpenPOWER on IntegriCloud