r173859 - [Frontend] Add an ExternCSystem include entry group.
Daniel Dunbar
daniel at zuster.org
Tue Jan 29 16:19:24 PST 2013
Author: ddunbar
Date: Tue Jan 29 18:19:24 2013
New Revision: 173859
URL: http://llvm.org/viewvc/llvm-project?rev=173859&view=rev
Log:
[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.
Modified:
cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
Modified: cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearchOptions.h?rev=173859&r1=173858&r2=173859&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/HeaderSearchOptions.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearchOptions.h Tue Jan 29 18:19:24 2013
@@ -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
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=173859&r1=173858&r2=173859&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Jan 29 18:19:24 2013
@@ -885,10 +885,13 @@ static void ParseHeaderSearchArgs(Header
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,
Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=173859&r1=173858&r2=173859&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Tue Jan 29 18:19:24 2013
@@ -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 P
#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 Twi
// 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::AddGnuCPlusPlusIn
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::AddDefaultCInclud
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::AddDefaultCInclud
// 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::AddDefaultCInclud
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::AddDefaultCInclud
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::AddDefaultCInclud
}
if ( os != llvm::Triple::RTEMS )
- AddPath("/usr/include", System, false, false);
+ AddPath("/usr/include", ExternCSystem, false);
}
void InitHeaderSearch::
@@ -400,7 +396,7 @@ AddDefaultCPlusPlusIncludePaths(const ll
#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::AddDefaultInclude
// 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::AddDefaultInclude
// 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 Lan
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(Hea
// 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);
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=173859&r1=173858&r2=173859&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Jan 29 18:19:24 2013
@@ -3692,10 +3692,9 @@ bool ASTReader::ParseHeaderSearchOptions
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.
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=173859&r1=173858&r2=173859&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Tue Jan 29 18:19:24 2013
@@ -1115,7 +1115,6 @@ void ASTWriter::WriteControlBlock(Prepro
Record.push_back(Entry.IsFramework);
Record.push_back(Entry.IgnoreSysRoot);
Record.push_back(Entry.IsInternal);
- Record.push_back(Entry.ImplicitExternC);
}
// System header prefixes.
More information about the cfe-commits
mailing list