[PATCH] D97109: [clangd] Add support for auxiliary triple specification
Tommy Chiang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 20 04:03:46 PST 2021
oToToT updated this revision to Diff 325186.
oToToT added a comment.
re-upload diff with full context, sorry for that.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97109/new/
https://reviews.llvm.org/D97109
Files:
clang-tools-extra/clangd/Compiler.cpp
clang/lib/Frontend/PrecompiledPreamble.cpp
Index: clang/lib/Frontend/PrecompiledPreamble.cpp
===================================================================
--- clang/lib/Frontend/PrecompiledPreamble.cpp
+++ clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -370,12 +370,33 @@
if (!Clang->hasTarget())
return BuildPreambleError::CouldntCreateTargetInfo;
+ // Correctly set AuxTarget. The code is borrowed from
+ // `CompilerInstance::ExecuteAction(FrontendAction &)` inside
+ // "clang/lib/Frontend/CompilerInstance.cpp"
+ if ((Clang->getLangOpts().CUDA || Clang->getLangOpts().OpenMPIsDevice ||
+ Clang->getLangOpts().SYCLIsDevice) &&
+ !Clang->getFrontendOpts().AuxTriple.empty()) {
+ auto TO = std::make_shared<TargetOptions>();
+ TO->Triple = llvm::Triple::normalize(Clang->getFrontendOpts().AuxTriple);
+ if (Clang->getFrontendOpts().AuxTargetCPU)
+ TO->CPU = Clang->getFrontendOpts().AuxTargetCPU.getValue();
+ if (Clang->getFrontendOpts().AuxTargetFeatures)
+ TO->FeaturesAsWritten =
+ Clang->getFrontendOpts().AuxTargetFeatures.getValue();
+ TO->HostTriple = Clang->getTarget().getTriple().str();
+ Clang->setAuxTarget(
+ TargetInfo::CreateTargetInfo(Clang->getDiagnostics(), TO));
+ }
+
// Inform the target of the language options.
//
// FIXME: We shouldn't need to do this, the target should be immutable once
// created. This complexity should be lifted elsewhere.
Clang->getTarget().adjust(Clang->getLangOpts());
+ if (auto *Aux = Clang->getAuxTarget())
+ Clang->getTarget().setAuxTarget(Aux);
+
if (Clang->getFrontendOpts().Inputs.size() != 1 ||
Clang->getFrontendOpts().Inputs[0].getKind().getFormat() !=
InputKind::Source ||
Index: clang-tools-extra/clangd/Compiler.cpp
===================================================================
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -123,6 +123,33 @@
if (!Clang->hasTarget())
return nullptr;
+ // Correctly set AuxTarget. The code is borrowed from
+ // `CompilerInstance::ExecuteAction(FrontendAction &)` inside
+ // "clang/lib/Frontend/CompilerInstance.cpp"
+ if ((Clang->getLangOpts().CUDA || Clang->getLangOpts().OpenMPIsDevice ||
+ Clang->getLangOpts().SYCLIsDevice) &&
+ !Clang->getFrontendOpts().AuxTriple.empty()) {
+ auto TO = std::make_shared<TargetOptions>();
+ TO->Triple = llvm::Triple::normalize(Clang->getFrontendOpts().AuxTriple);
+ if (Clang->getFrontendOpts().AuxTargetCPU)
+ TO->CPU = Clang->getFrontendOpts().AuxTargetCPU.getValue();
+ if (Clang->getFrontendOpts().AuxTargetFeatures)
+ TO->FeaturesAsWritten =
+ Clang->getFrontendOpts().AuxTargetFeatures.getValue();
+ TO->HostTriple = Clang->getTarget().getTriple().str();
+ Clang->setAuxTarget(
+ TargetInfo::CreateTargetInfo(Clang->getDiagnostics(), TO));
+ }
+
+ // Inform the target of the language options.
+ //
+ // FIXME: We shouldn't need to do this, the target should be immutable once
+ // created. This complexity should be lifted elsewhere.
+ Clang->getTarget().adjust(Clang->getLangOpts());
+
+ if (auto *Aux = Clang->getAuxTarget())
+ Clang->getTarget().setAuxTarget(Aux);
+
// RemappedFileBuffers will handle the lifetime of the Buffer pointer,
// release it.
Buffer.release();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97109.325186.patch
Type: text/x-patch
Size: 3328 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210220/8ec78f02/attachment.bin>
More information about the cfe-commits
mailing list