Add -isystem-prefix and -ino-system-prefix arguments, which can be used to

override whether headers are system headers by checking for prefixes of the
header name specified in the #include directive.

This allows warnings to be disabled for third-party code which is found in
specific subdirectories of include paths.

llvm-svn: 158418
This commit is contained in:
Richard Smith
2012-06-13 20:27:03 +00:00
parent dc3559106b
commit 8acadcb84b
14 changed files with 148 additions and 0 deletions

View File

@@ -624,6 +624,16 @@ static void HeaderSearchOptsToArgs(const HeaderSearchOptions &Opts,
Res.push_back(E.Path);
}
/// User-specified system header prefixes.
for (unsigned i = 0, e = Opts.SystemHeaderPrefixes.size(); i != e; ++i) {
if (Opts.SystemHeaderPrefixes[i].IsSystemHeader)
Res.push_back("-isystem-prefix");
else
Res.push_back("-ino-system-prefix");
Res.push_back(Opts.SystemHeaderPrefixes[i].Prefix);
}
if (!Opts.ResourceDir.empty())
Res.push_back("-resource-dir", Opts.ResourceDir);
if (!Opts.ModuleCachePath.empty())
@@ -1688,6 +1698,14 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args) {
Opts.AddPath((*I)->getValue(Args), frontend::System,
false, false, /*IgnoreSysRoot=*/true, /*IsInternal=*/true,
(*I)->getOption().matches(OPT_internal_externc_isystem));
// Add the path prefixes which are implicitly treated as being system headers.
for (arg_iterator I = Args.filtered_begin(OPT_isystem_prefix,
OPT_ino_system_prefix),
E = Args.filtered_end();
I != E; ++I)
Opts.AddSystemHeaderPrefix((*I)->getValue(Args),
(*I)->getOption().matches(OPT_isystem_prefix));
}
void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,