summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/PPDirectives.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-09-26 20:12:23 +0000
committerChris Lattner <sabre@nondot.org>2008-09-26 20:12:23 +0000
commitc88a23e8d7a85b002789794ca83eb9da81eae7de (patch)
treef86c320616e57db7cc0d6b1f51bffc2d81a5f9db /clang/lib/Lex/PPDirectives.cpp
parent71efd8159eb41cb53f21385b56c7f6ec73456956 (diff)
downloadbcm5719-llvm-c88a23e8d7a85b002789794ca83eb9da81eae7de.tar.gz
bcm5719-llvm-c88a23e8d7a85b002789794ca83eb9da81eae7de.zip
Fix the rest of rdar://6243860 hopefully. This requires changing FileIDInfo
to whether the fileid is a 'extern c system header' in addition to whether it is a system header, most of this is spreading plumbing around. Once we have that, PPLexerChange bases its "file enter/exit" notifications to PPCallbacks to base the system header state on FileIDInfo instead of HeaderSearch. Finally, in Preprocessor::HandleIncludeDirective, mirror logic in GCC: the system headerness of a file being entered can be set due to the #includer or the #includee. llvm-svn: 56688
Diffstat (limited to 'clang/lib/Lex/PPDirectives.cpp')
-rw-r--r--clang/lib/Lex/PPDirectives.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 70cd0ed1d0b..504bc45dca4 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -600,7 +600,8 @@ static bool ConcatenateIncludeName(llvm::SmallVector<char, 128> &FilenameBuffer,
/// HandleIncludeDirective - The "#include" tokens have just been read, read the
/// file to be included from the lexer, then include it! This is a common
/// routine with functionality shared between #include, #include_next and
-/// #import.
+/// #import. LookupFrom is set when this is a #include_next directive, it
+/// specifies the file to start searching from.
void Preprocessor::HandleIncludeDirective(Token &IncludeTok,
const DirectoryLookup *LookupFrom,
bool isImport) {
@@ -666,15 +667,22 @@ void Preprocessor::HandleIncludeDirective(Token &IncludeTok,
return Diag(FilenameTok, diag::err_pp_file_not_found,
std::string(FilenameStart, FilenameEnd));
- // Ask HeaderInfo if we should enter this #include file.
- if (!HeaderInfo.ShouldEnterIncludeFile(File, isImport)) {
- // If it returns true, #including this file will have no effect.
+ // Ask HeaderInfo if we should enter this #include file. If not, #including
+ // this file will have no effect.
+ if (!HeaderInfo.ShouldEnterIncludeFile(File, isImport))
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.
+ unsigned FileCharacter =
+ // FIXME: Casts
+ std::max((unsigned)HeaderInfo.getFileDirFlavor(File),
+ SourceMgr.getDirCharacteristic(getCurrentFileLexer()->getFileLoc()));
+
// Look up the file, create a File ID for it.
unsigned FileID = SourceMgr.createFileID(File, FilenameTok.getLocation(),
- isSystemHeader(File));
+ FileCharacter);
if (FileID == 0)
return Diag(FilenameTok, diag::err_pp_file_not_found,
std::string(FilenameStart, FilenameEnd));
OpenPOWER on IntegriCloud