[ClangImporter] Don't pass API notes options when compiling bitcode. (#10422)

Avoids a bogus "argument unused" warning, since bitcode compilation
doesn't bother to set up much of a Clang AST context. (-embed-bitcode
compiles in two steps: source -> bitcode, then bitcode -> object
file. This is about the second step.)

Patch by Bob Wilson, who's currently on vacation but wanted this to
get in sooner rather than later.

rdar://problem/31372950
This commit is contained in:
Jordan Rose
2017-06-20 16:02:34 -07:00
committed by GitHub
parent 351ffabf1a
commit 65391ccac5
2 changed files with 18 additions and 17 deletions

View File

@@ -620,6 +620,23 @@ getNormalInvocationArguments(std::vector<std::string> &invocationArgStrs,
"-Xclang", "-fmodule-format=obj",
});
}
// Enable API notes alongside headers/in frameworks.
invocationArgStrs.push_back("-fapinotes-modules");
// Add API notes paths.
for (const auto &searchPath : searchPathOpts.ImportSearchPaths) {
invocationArgStrs.push_back("-iapinotes-modules");
invocationArgStrs.push_back(searchPath);
}
invocationArgStrs.push_back("-iapinotes-modules");
invocationArgStrs.push_back(searchPathOpts.RuntimeLibraryImportPath);
// Map the Swift major version into the API notes version for Swift. This
// has the effect of allowing API notes to effect changes only on Swift
// major versions, not minor versions.
invocationArgStrs.push_back("-fapinotes-swift-version=" +
llvm::itostr(languageVersion[0]));
}
static void
@@ -691,23 +708,6 @@ addCommonInvocationArguments(std::vector<std::string> &invocationArgStrs,
for (auto extraArg : importerOpts.ExtraArgs) {
invocationArgStrs.push_back(extraArg);
}
// Enable API notes alongside headers/in frameworks.
invocationArgStrs.push_back("-fapinotes-modules");
// Add API notes paths.
for (const auto &searchPath : searchPathOpts.ImportSearchPaths) {
invocationArgStrs.push_back("-iapinotes-modules");
invocationArgStrs.push_back(searchPath);
}
invocationArgStrs.push_back("-iapinotes-modules");
invocationArgStrs.push_back(searchPathOpts.RuntimeLibraryImportPath);
// Map the Swift major version into the API notes version for Swift. This
// has the effect of allowing API notes to effect changes only on Swift
// major versions, not minor versions.
invocationArgStrs.push_back("-fapinotes-swift-version=" +
llvm::itostr(ctx.LangOpts.EffectiveLanguageVersion[0]));
}
bool ClangImporter::canReadPCH(StringRef PCHFilename) {

View File

@@ -23,6 +23,7 @@ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
; CHECK-IMPORTER: clang
; CHECK-IMPORTER: -fembed-bitcode
; CHECK-IMPORTER: -target
; CHECK-IMPORTER-NOT: argument unused
define i32 @f0() nounwind ssp {
ret i32 0