summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2013-01-30 00:19:24 +0000
committerDaniel Dunbar <daniel@zuster.org>2013-01-30 00:19:24 +0000
commit9f2374565e3d4dacb00af85ec4b16ebc05dfb4a7 (patch)
tree47829254b03a1524355704ad767c908195cdc8a1
parent1b3815cbf483fa1cc5c5b6d7b567722b3c802bf6 (diff)
downloadbcm5719-llvm-9f2374565e3d4dacb00af85ec4b16ebc05dfb4a7.tar.gz
bcm5719-llvm-9f2374565e3d4dacb00af85ec4b16ebc05dfb4a7.zip
[Frontend] Add an ExternCSystem include entry group.
- The only group where it makes sense for the "ExternC" bit is System, so this simplifies having to have the extra isCXXAware (or ImplicitExternC, depending on what code you talk to) bit caried around. llvm-svn: 173859
-rw-r--r--clang/include/clang/Lex/HeaderSearchOptions.h13
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp11
-rw-r--r--clang/lib/Frontend/InitHeaderSearch.cpp143
-rw-r--r--clang/lib/Serialization/ASTReader.cpp3
-rw-r--r--clang/lib/Serialization/ASTWriter.cpp1
5 files changed, 83 insertions, 88 deletions
diff --git a/clang/include/clang/Lex/HeaderSearchOptions.h b/clang/include/clang/Lex/HeaderSearchOptions.h
index 52885635e43..006bf4357b7 100644
--- a/clang/include/clang/Lex/HeaderSearchOptions.h
+++ b/clang/include/clang/Lex/HeaderSearchOptions.h
@@ -28,6 +28,8 @@ namespace frontend {
IndexHeaderMap, ///< Like Angled, but marks header maps used when
/// building frameworks.
System, ///< Like Angled, but marks system directories.
+ ExternCSystem, ///< Like System, but headers are implicitly wrapped in
+ /// extern "C".
CSystem, ///< Like System, but only used for C.
CXXSystem, ///< Like System, but only used for C++.
ObjCSystem, ///< Like System, but only used for ObjC.
@@ -61,11 +63,9 @@ public:
unsigned ImplicitExternC : 1;
Entry(StringRef path, frontend::IncludeDirGroup group,
- bool isFramework, bool ignoreSysRoot, bool isInternal,
- bool implicitExternC)
+ bool isFramework, bool ignoreSysRoot, bool isInternal)
: Path(path), Group(group), IsFramework(isFramework),
- IgnoreSysRoot(ignoreSysRoot), IsInternal(isInternal),
- ImplicitExternC(implicitExternC) {}
+ IgnoreSysRoot(ignoreSysRoot), IsInternal(isInternal) {}
};
struct SystemHeaderPrefix {
@@ -126,10 +126,9 @@ public:
/// AddPath - Add the \p Path path to the specified \p Group list.
void AddPath(StringRef Path, frontend::IncludeDirGroup Group,
- bool IsFramework, bool IgnoreSysRoot,
- bool IsInternal = false, bool ImplicitExternC = false) {
+ bool IsFramework, bool IgnoreSysRoot, bool IsInternal = false) {
UserEntries.push_back(Entry(Path, Group, IsFramework,
- IgnoreSysRoot, IsInternal, ImplicitExternC));
+ IgnoreSysRoot, IsInternal));
}
/// AddSystemHeaderPrefix - Override whether \#include directives naming a
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index b6a83b24d85..49f89d4c79e 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -885,10 +885,13 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args) {
for (arg_iterator I = Args.filtered_begin(OPT_internal_isystem,
OPT_internal_externc_isystem),
E = Args.filtered_end();
- I != E; ++I)
- Opts.AddPath((*I)->getValue(), frontend::System,
- false, /*IgnoreSysRoot=*/true, /*IsInternal=*/true,
- (*I)->getOption().matches(OPT_internal_externc_isystem));
+ I != E; ++I) {
+ frontend::IncludeDirGroup Group = frontend::System;
+ if ((*I)->getOption().matches(OPT_internal_externc_isystem))
+ Group = frontend::ExternCSystem;
+ Opts.AddPath((*I)->getValue(), Group, false, /*IgnoreSysRoot=*/true,
+ /*IsInternal=*/true);
+ }
// Add the path prefixes which are implicitly treated as being system headers.
for (arg_iterator I = Args.filtered_begin(OPT_isystem_prefix,
diff --git a/clang/lib/Frontend/InitHeaderSearch.cpp b/clang/lib/Frontend/InitHeaderSearch.cpp
index ba3abbaebc1..16b5dd25d08 100644
--- a/clang/lib/Frontend/InitHeaderSearch.cpp
+++ b/clang/lib/Frontend/InitHeaderSearch.cpp
@@ -53,8 +53,8 @@ public:
}
/// AddPath - Add the specified path to the specified group list.
- void AddPath(const Twine &Path, IncludeDirGroup Group,
- bool isCXXAware, bool isFramework, bool IgnoreSysRoot = false);
+ void AddPath(const Twine &Path, IncludeDirGroup Group, bool isFramework,
+ bool IgnoreSysRoot = false);
/// AddSystemHeaderPrefix - Add the specified prefix to the system header
/// prefix list.
@@ -111,8 +111,7 @@ static bool CanPrefixSysroot(StringRef Path) {
#endif
}
-void InitHeaderSearch::AddPath(const Twine &Path,
- IncludeDirGroup Group, bool isCXXAware,
+void InitHeaderSearch::AddPath(const Twine &Path, IncludeDirGroup Group,
bool isFramework, bool IgnoreSysRoot) {
assert(!Path.isTriviallyEmpty() && "can't handle empty path here");
FileManager &FM = Headers.getFileMgr();
@@ -129,13 +128,13 @@ void InitHeaderSearch::AddPath(const Twine &Path,
// Compute the DirectoryLookup type.
SrcMgr::CharacteristicKind Type;
- if (Group == Quoted || Group == Angled || Group == IndexHeaderMap)
+ if (Group == Quoted || Group == Angled || Group == IndexHeaderMap) {
Type = SrcMgr::C_User;
- else if (isCXXAware)
- Type = SrcMgr::C_System;
- else
+ } else if (Group == ExternCSystem) {
Type = SrcMgr::C_ExternCSystem;
-
+ } else {
+ Type = SrcMgr::C_System;
+ }
// If the directory exists, add it.
if (const DirectoryEntry *DE = FM.getDirectory(MappedPathStr)) {
@@ -169,42 +168,42 @@ void InitHeaderSearch::AddGnuCPlusPlusIncludePaths(StringRef Base,
StringRef Dir64,
const llvm::Triple &triple) {
// Add the base dir
- AddPath(Base, CXXSystem, true, false);
+ AddPath(Base, CXXSystem, false);
// Add the multilib dirs
llvm::Triple::ArchType arch = triple.getArch();
bool is64bit = arch == llvm::Triple::ppc64 || arch == llvm::Triple::x86_64;
if (is64bit)
- AddPath(Base + "/" + ArchDir + "/" + Dir64, CXXSystem, true, false);
+ AddPath(Base + "/" + ArchDir + "/" + Dir64, CXXSystem, false);
else
- AddPath(Base + "/" + ArchDir + "/" + Dir32, CXXSystem, true, false);
+ AddPath(Base + "/" + ArchDir + "/" + Dir32, CXXSystem, false);
// Add the backward dir
- AddPath(Base + "/backward", CXXSystem, true, false);
+ AddPath(Base + "/backward", CXXSystem, false);
}
void InitHeaderSearch::AddMinGWCPlusPlusIncludePaths(StringRef Base,
StringRef Arch,
StringRef Version) {
AddPath(Base + "/" + Arch + "/" + Version + "/include/c++",
- CXXSystem, true, false);
+ CXXSystem, false);
AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/" + Arch,
- CXXSystem, true, false);
+ CXXSystem, false);
AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/backward",
- CXXSystem, true, false);
+ CXXSystem, false);
}
void InitHeaderSearch::AddMinGW64CXXPaths(StringRef Base,
StringRef Version) {
// Assumes Base is HeaderSearchOpts' ResourceDir
AddPath(Base + "/../../../include/c++/" + Version,
- CXXSystem, true, false);
+ CXXSystem, false);
AddPath(Base + "/../../../include/c++/" + Version + "/x86_64-w64-mingw32",
- CXXSystem, true, false);
+ CXXSystem, false);
AddPath(Base + "/../../../include/c++/" + Version + "/i686-w64-mingw32",
- CXXSystem, true, false);
+ CXXSystem, false);
AddPath(Base + "/../../../include/c++/" + Version + "/backward",
- CXXSystem, true, false);
+ CXXSystem, false);
}
void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
@@ -220,7 +219,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
break;
default:
// FIXME: temporary hack: hard-coded paths.
- AddPath("/usr/local/include", System, true, false);
+ AddPath("/usr/local/include", System, false);
break;
}
}
@@ -232,7 +231,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
// supplied path.
llvm::sys::Path P(HSOpts.ResourceDir);
P.appendComponent("include");
- AddPath(P.str(), System, false, false, /*IgnoreSysRoot=*/ true);
+ AddPath(P.str(), ExternCSystem, false, /*IgnoreSysRoot=*/true);
}
// All remaining additions are for system include directories, early exit if
@@ -248,7 +247,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
for (SmallVectorImpl<StringRef>::iterator i = dirs.begin();
i != dirs.end();
++i)
- AddPath(*i, System, false, false);
+ AddPath(*i, ExternCSystem, false);
return;
}
@@ -258,62 +257,59 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
llvm_unreachable("Include management is handled in the driver.");
case llvm::Triple::Haiku:
- AddPath("/boot/common/include", System, true, false);
- AddPath("/boot/develop/headers/os", System, true, false);
- AddPath("/boot/develop/headers/os/app", System, true, false);
- AddPath("/boot/develop/headers/os/arch", System, true, false);
- AddPath("/boot/develop/headers/os/device", System, true, false);
- AddPath("/boot/develop/headers/os/drivers", System, true, false);
- AddPath("/boot/develop/headers/os/game", System, true, false);
- AddPath("/boot/develop/headers/os/interface", System, true, false);
- AddPath("/boot/develop/headers/os/kernel", System, true, false);
- AddPath("/boot/develop/headers/os/locale", System, true, false);
- AddPath("/boot/develop/headers/os/mail", System, true, false);
- AddPath("/boot/develop/headers/os/media", System, true, false);
- AddPath("/boot/develop/headers/os/midi", System, true, false);
- AddPath("/boot/develop/headers/os/midi2", System, true, false);
- AddPath("/boot/develop/headers/os/net", System, true, false);
- AddPath("/boot/develop/headers/os/storage", System, true, false);
- AddPath("/boot/develop/headers/os/support", System, true, false);
- AddPath("/boot/develop/headers/os/translation", System, true, false);
- AddPath("/boot/develop/headers/os/add-ons/graphics", System, true, false);
- AddPath("/boot/develop/headers/os/add-ons/input_server",
- System, true, false);
- AddPath("/boot/develop/headers/os/add-ons/screen_saver",
- System, true, false);
- AddPath("/boot/develop/headers/os/add-ons/tracker", System, true, false);
- AddPath("/boot/develop/headers/os/be_apps/Deskbar", System, true, false);
- AddPath("/boot/develop/headers/os/be_apps/NetPositive",
- System, true, false);
- AddPath("/boot/develop/headers/os/be_apps/Tracker", System, true, false);
- AddPath("/boot/develop/headers/cpp", System, true, false);
- AddPath("/boot/develop/headers/cpp/i586-pc-haiku", System, true, false);
- AddPath("/boot/develop/headers/3rdparty", System, true, false);
- AddPath("/boot/develop/headers/bsd", System, true, false);
- AddPath("/boot/develop/headers/glibc", System, true, false);
- AddPath("/boot/develop/headers/posix", System, true, false);
- AddPath("/boot/develop/headers", System, true, false);
+ AddPath("/boot/common/include", System, false);
+ AddPath("/boot/develop/headers/os", System, false);
+ AddPath("/boot/develop/headers/os/app", System, false);
+ AddPath("/boot/develop/headers/os/arch", System, false);
+ AddPath("/boot/develop/headers/os/device", System, false);
+ AddPath("/boot/develop/headers/os/drivers", System, false);
+ AddPath("/boot/develop/headers/os/game", System, false);
+ AddPath("/boot/develop/headers/os/interface", System, false);
+ AddPath("/boot/develop/headers/os/kernel", System, false);
+ AddPath("/boot/develop/headers/os/locale", System, false);
+ AddPath("/boot/develop/headers/os/mail", System, false);
+ AddPath("/boot/develop/headers/os/media", System, false);
+ AddPath("/boot/develop/headers/os/midi", System, false);
+ AddPath("/boot/develop/headers/os/midi2", System, false);
+ AddPath("/boot/develop/headers/os/net", System, false);
+ AddPath("/boot/develop/headers/os/storage", System, false);
+ AddPath("/boot/develop/headers/os/support", System, false);
+ AddPath("/boot/develop/headers/os/translation", System, false);
+ AddPath("/boot/develop/headers/os/add-ons/graphics", System, false);
+ AddPath("/boot/develop/headers/os/add-ons/input_server", System, false);
+ AddPath("/boot/develop/headers/os/add-ons/screen_saver", System, false);
+ AddPath("/boot/develop/headers/os/add-ons/tracker", System, false);
+ AddPath("/boot/develop/headers/os/be_apps/Deskbar", System, false);
+ AddPath("/boot/develop/headers/os/be_apps/NetPositive", System, false);
+ AddPath("/boot/develop/headers/os/be_apps/Tracker", System, false);
+ AddPath("/boot/develop/headers/cpp", System, false);
+ AddPath("/boot/develop/headers/cpp/i586-pc-haiku", System, false);
+ AddPath("/boot/develop/headers/3rdparty", System, false);
+ AddPath("/boot/develop/headers/bsd", System, false);
+ AddPath("/boot/develop/headers/glibc", System, false);
+ AddPath("/boot/develop/headers/posix", System, false);
+ AddPath("/boot/develop/headers", System, false);
break;
case llvm::Triple::RTEMS:
break;
case llvm::Triple::Cygwin:
- AddPath("/usr/include/w32api", System, true, false);
+ AddPath("/usr/include/w32api", System, false);
break;
case llvm::Triple::MinGW32: {
// mingw-w64 crt include paths
llvm::sys::Path P(HSOpts.ResourceDir);
P.appendComponent("../../../i686-w64-mingw32/include"); // <sysroot>/i686-w64-mingw32/include
- AddPath(P.str(), System, true, false);
+ AddPath(P.str(), System, false);
P = llvm::sys::Path(HSOpts.ResourceDir);
P.appendComponent("../../../x86_64-w64-mingw32/include"); // <sysroot>/x86_64-w64-mingw32/include
- AddPath(P.str(), System, true, false);
+ AddPath(P.str(), System, false);
// mingw.org crt include paths
P = llvm::sys::Path(HSOpts.ResourceDir);
P.appendComponent("../../../include"); // <sysroot>/include
- AddPath(P.str(), System, true, false);
- AddPath("/mingw/include", System, true, false);
+ AddPath(P.str(), System, false);
+ AddPath("/mingw/include", System, false);
#if defined(_WIN32)
- AddPath("c:/mingw/include", System, true, false);
+ AddPath("c:/mingw/include", System, false);
#endif
}
break;
@@ -323,7 +319,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
}
if ( os != llvm::Triple::RTEMS )
- AddPath("/usr/include", System, false, false);
+ AddPath("/usr/include", ExternCSystem, false);
}
void InitHeaderSearch::
@@ -400,7 +396,7 @@ AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple, const HeaderSearchOp
#endif
break;
case llvm::Triple::DragonFly:
- AddPath("/usr/include/c++/4.1", CXXSystem, true, false);
+ AddPath("/usr/include/c++/4.1", CXXSystem, false);
break;
case llvm::Triple::FreeBSD:
// FreeBSD 8.0
@@ -466,15 +462,15 @@ void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang,
// Get foo/lib/c++/v1
P.appendComponent("c++");
P.appendComponent("v1");
- AddPath(P.str(), CXXSystem, true, false, true);
+ AddPath(P.str(), CXXSystem, false, true);
}
}
// On Solaris, include the support directory for things like xlocale and
// fudged system headers.
if (triple.getOS() == llvm::Triple::Solaris)
- AddPath("/usr/include/c++/v1/support/solaris", CXXSystem, true, false);
+ AddPath("/usr/include/c++/v1/support/solaris", CXXSystem, false);
- AddPath("/usr/include/c++/v1", CXXSystem, true, false);
+ AddPath("/usr/include/c++/v1", CXXSystem, false);
} else {
AddDefaultCPlusPlusIncludePaths(triple, HSOpts);
}
@@ -485,8 +481,8 @@ void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang,
// Add the default framework include paths on Darwin.
if (HSOpts.UseStandardSystemIncludes) {
if (triple.isOSDarwin()) {
- AddPath("/System/Library/Frameworks", System, true, true);
- AddPath("/Library/Frameworks", System, true, true);
+ AddPath("/System/Library/Frameworks", System, true);
+ AddPath("/Library/Frameworks", System, true);
}
}
}
@@ -604,7 +600,7 @@ void InitHeaderSearch::Realize(const LangOptions &Lang) {
for (path_iterator it = IncludePath.begin(), ie = IncludePath.end();
it != ie; ++it) {
- if (it->first == System ||
+ if (it->first == System || it->first == ExternCSystem ||
(!Lang.ObjC1 && !Lang.CPlusPlus && it->first == CSystem) ||
(/*FIXME !Lang.ObjC1 && */Lang.CPlusPlus && it->first == CXXSystem) ||
(Lang.ObjC1 && !Lang.CPlusPlus && it->first == ObjCSystem) ||
@@ -660,8 +656,7 @@ void clang::ApplyHeaderSearchOptions(HeaderSearch &HS,
// Add the user defined entries.
for (unsigned i = 0, e = HSOpts.UserEntries.size(); i != e; ++i) {
const HeaderSearchOptions::Entry &E = HSOpts.UserEntries[i];
- Init.AddPath(E.Path, E.Group, !E.ImplicitExternC, E.IsFramework,
- E.IgnoreSysRoot);
+ Init.AddPath(E.Path, E.Group, E.IsFramework, E.IgnoreSysRoot);
}
Init.AddDefaultIncludePaths(Lang, Triple, HSOpts);
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 8a8f6a2cfe9..c07e1e9982f 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -3692,10 +3692,9 @@ bool ASTReader::ParseHeaderSearchOptions(const RecordData &Record,
bool IsFramework = Record[Idx++];
bool IgnoreSysRoot = Record[Idx++];
bool IsInternal = Record[Idx++];
- bool ImplicitExternC = Record[Idx++];
HSOpts.UserEntries.push_back(
HeaderSearchOptions::Entry(Path, Group, IsFramework, IgnoreSysRoot,
- IsInternal, ImplicitExternC));
+ IsInternal));
}
// System header prefixes.
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index d3981533245..0499f5c6f47 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1115,7 +1115,6 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
Record.push_back(Entry.IsFramework);
Record.push_back(Entry.IgnoreSysRoot);
Record.push_back(Entry.IsInternal);
- Record.push_back(Entry.ImplicitExternC);
}
// System header prefixes.
OpenPOWER on IntegriCloud