diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-12-02 00:08:08 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-12-02 00:08:08 +0000 |
commit | 3c1a41ad9969ae4e3353f5984d66af85ce56cf9a (patch) | |
tree | f19e3452dbc34c152accbcee5057286a353da704 /clang/lib/Lex/PPDirectives.cpp | |
parent | 4cdf4eba74df1c2a679931716fc630fd484bdb3c (diff) | |
download | bcm5719-llvm-3c1a41ad9969ae4e3353f5984d66af85ce56cf9a.tar.gz bcm5719-llvm-3c1a41ad9969ae4e3353f5984d66af85ce56cf9a.zip |
[modules] Track how 'header' directives were written in module map files,
rather than trying to extract this information from the FileEntry after the
fact.
This has a number of beneficial effects. For instance, diagnostic messages for
failed module builds give a path relative to the "module root" rather than an
absolute file path, and the contents of the module includes file is no longer
dependent on what files the including TU happened to inspect prior to
triggering the module build.
llvm-svn: 223095
Diffstat (limited to 'clang/lib/Lex/PPDirectives.cpp')
-rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index 04f3b29bd5b..0a46663d85d 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -550,14 +550,22 @@ const FileEntry *Preprocessor::LookupFile( const FileEntry *FileEnt = SourceMgr.getFileEntryForID(FID); // If there is no file entry associated with this file, it must be the - // predefines buffer. Any other file is not lexed with a normal lexer, so - // it won't be scanned for preprocessor directives. If we have the - // predefines buffer, resolve #include references (which come from the - // -include command line argument) from the current working directory - // instead of relative to the main file. + // predefines buffer or the module includes buffer. Any other file is not + // lexed with a normal lexer, so it won't be scanned for preprocessor + // directives. + // + // If we have the predefines buffer, resolve #include references (which come + // from the -include command line argument) from the current working + // directory instead of relative to the main file. + // + // If we have the module includes buffer, resolve #include references (which + // come from header declarations in the module map) relative to the module + // map file. if (!FileEnt) { - FileEnt = SourceMgr.getFileEntryForID(SourceMgr.getMainFileID()); - if (FileEnt) + if (FID == SourceMgr.getMainFileID() && MainFileDir) + Includers.push_back(std::make_pair(nullptr, MainFileDir)); + else if ((FileEnt = + SourceMgr.getFileEntryForID(SourceMgr.getMainFileID()))) Includers.push_back(std::make_pair(FileEnt, FileMgr.getDirectory("."))); } else { Includers.push_back(std::make_pair(FileEnt, FileEnt->getDir())); |