Skip to content

[ClangImporter] Honor ClangTarget in getNormalInvocationArguments #72375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions lib/ClangImporter/ClangImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,12 +461,15 @@ static inline bool isPCHFilenameExtension(StringRef path) {
.endswith(file_types::getExtension(file_types::TY_PCH));
}

void
importer::getNormalInvocationArguments(
std::vector<std::string> &invocationArgStrs,
ASTContext &ctx) {
void importer::getNormalInvocationArguments(
std::vector<std::string> &invocationArgStrs, ASTContext &ctx,
bool ignoreClangTarget) {
const auto &LangOpts = ctx.LangOpts;
const llvm::Triple &triple = LangOpts.Target;
llvm::Triple triple = LangOpts.Target;
// Use clang specific target triple if given.
if (LangOpts.ClangTarget.has_value() && !ignoreClangTarget) {
triple = LangOpts.ClangTarget.value();
}
SearchPathOptions &searchPathOpts = ctx.SearchPathOpts;
ClangImporterOptions &importerOpts = ctx.ClangImporterOpts;
auto languageVersion = ctx.LangOpts.EffectiveLanguageVersion;
Expand Down Expand Up @@ -1057,7 +1060,7 @@ ClangImporter::getClangDriverArguments(ASTContext &ctx, bool ignoreClangTarget)
switch (ctx.ClangImporterOpts.Mode) {
case ClangImporterOptions::Modes::Normal:
case ClangImporterOptions::Modes::PrecompiledModule:
getNormalInvocationArguments(invocationArgStrs, ctx);
getNormalInvocationArguments(invocationArgStrs, ctx, ignoreClangTarget);
break;
case ClangImporterOptions::Modes::EmbedBitcode:
getEmbedBitcodeInvocationArguments(invocationArgStrs, ctx);
Expand Down
2 changes: 1 addition & 1 deletion lib/ClangImporter/ImporterImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1879,7 +1879,7 @@ bool hasSameUnderlyingType(const clang::Type *a,

/// Add command-line arguments for a normal import of Clang code.
void getNormalInvocationArguments(std::vector<std::string> &invocationArgStrs,
ASTContext &ctx);
ASTContext &ctx, bool ignoreClangTarget);

/// Add command-line arguments common to all imports of Clang code.
void addCommonInvocationArguments(std::vector<std::string> &invocationArgStrs,
Expand Down