namespace clang {
class DiagnosticsEngine;
+ class HeaderSearchOptions;
class CodeGenOptions;
class TargetOptions;
class LangOptions;
Backend_EmitObj ///< Emit native object files
};
- void EmitBackendOutput(DiagnosticsEngine &Diags, const CodeGenOptions &CGOpts,
+ void EmitBackendOutput(DiagnosticsEngine &Diags, const HeaderSearchOptions &,
+ const CodeGenOptions &CGOpts,
const TargetOptions &TOpts, const LangOptions &LOpts,
const llvm::DataLayout &TDesc, llvm::Module *M,
BackendAction Action,
#include "clang/Frontend/CodeGenOptions.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Frontend/Utils.h"
+#include "clang/Lex/HeaderSearchOptions.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/IR/ModuleSummaryIndex.h"
#include "llvm/IR/Verifier.h"
#include "llvm/LTO/LTOBackend.h"
+#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/SubtargetFeature.h"
#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
#include "llvm/Passes/PassBuilder.h"
class EmitAssemblyHelper {
DiagnosticsEngine &Diags;
+ const HeaderSearchOptions &HSOpts;
const CodeGenOptions &CodeGenOpts;
const clang::TargetOptions &TargetOpts;
const LangOptions &LangOpts;
raw_pwrite_stream &OS);
public:
- EmitAssemblyHelper(DiagnosticsEngine &_Diags, const CodeGenOptions &CGOpts,
+ EmitAssemblyHelper(DiagnosticsEngine &_Diags,
+ const HeaderSearchOptions &HeaderSearchOpts,
+ const CodeGenOptions &CGOpts,
const clang::TargetOptions &TOpts,
const LangOptions &LOpts, Module *M)
- : Diags(_Diags), CodeGenOpts(CGOpts), TargetOpts(TOpts), LangOpts(LOpts),
- TheModule(M), CodeGenerationTime("codegen", "Code Generation Time") {}
+ : Diags(_Diags), HSOpts(HeaderSearchOpts), CodeGenOpts(CGOpts),
+ TargetOpts(TOpts), LangOpts(LOpts), TheModule(M),
+ CodeGenerationTime("codegen", "Code Generation Time") {}
~EmitAssemblyHelper() {
if (CodeGenOpts.DisableFree)
Options.MCOptions.MCNoExecStack = CodeGenOpts.NoExecStack;
Options.MCOptions.MCIncrementalLinkerCompatible =
CodeGenOpts.IncrementalLinkerCompatible;
- Options.MCOptions.MCPIECopyRelocations =
- CodeGenOpts.PIECopyRelocations;
+ Options.MCOptions.MCPIECopyRelocations = CodeGenOpts.PIECopyRelocations;
Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings;
Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose;
Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments;
Options.MCOptions.ABIName = TargetOpts.ABI;
+ for (const auto &Entry : HSOpts.UserEntries)
+ if (!Entry.IsFramework &&
+ (Entry.Group == frontend::IncludeDirGroup::Quoted ||
+ Entry.Group == frontend::IncludeDirGroup::Angled ||
+ Entry.Group == frontend::IncludeDirGroup::System))
+ Options.MCOptions.IASSearchPaths.push_back(
+ Entry.IgnoreSysRoot ? Entry.Path : HSOpts.Sysroot + Entry.Path);
TM.reset(TheTarget->createTargetMachine(Triple, TargetOpts.CPU, FeaturesStr,
Options, RM, CM, OptLevel));
}
void clang::EmitBackendOutput(DiagnosticsEngine &Diags,
+ const HeaderSearchOptions &HeaderOpts,
const CodeGenOptions &CGOpts,
const clang::TargetOptions &TOpts,
- const LangOptions &LOpts, const llvm::DataLayout &TDesc,
- Module *M, BackendAction Action,
+ const LangOptions &LOpts,
+ const llvm::DataLayout &TDesc, Module *M,
+ BackendAction Action,
std::unique_ptr<raw_pwrite_stream> OS) {
if (!CGOpts.ThinLTOIndexFile.empty()) {
runThinLTOBackend(CGOpts, M, std::move(OS));
return;
}
- EmitAssemblyHelper AsmHelper(Diags, CGOpts, TOpts, LOpts, M);
+ EmitAssemblyHelper AsmHelper(Diags, HeaderOpts, CGOpts, TOpts, LOpts, M);
if (CGOpts.ExperimentalNewPassManager)
AsmHelper.EmitAssemblyWithNewPassManager(Action, std::move(OS));
virtual void anchor();
DiagnosticsEngine &Diags;
BackendAction Action;
+ const HeaderSearchOptions &HeaderSearchOpts;
const CodeGenOptions &CodeGenOpts;
const TargetOptions &TargetOpts;
const LangOptions &LangOpts;
const SmallVectorImpl<std::pair<unsigned, llvm::Module *>> &LinkModules,
std::unique_ptr<raw_pwrite_stream> OS, LLVMContext &C,
CoverageSourceInfo *CoverageInfo = nullptr)
- : Diags(Diags), Action(Action), CodeGenOpts(CodeGenOpts),
- TargetOpts(TargetOpts), LangOpts(LangOpts),
+ : Diags(Diags), Action(Action), HeaderSearchOpts(HeaderSearchOpts),
+ CodeGenOpts(CodeGenOpts), TargetOpts(TargetOpts), LangOpts(LangOpts),
AsmOutStream(std::move(OS)), Context(nullptr),
LLVMIRGeneration("irgen", "LLVM IR Generation Time"),
LLVMIRGenerationRefCount(0),
EmbedBitcode(getModule(), CodeGenOpts, llvm::MemoryBufferRef());
- EmitBackendOutput(Diags, CodeGenOpts, TargetOpts, LangOpts,
- C.getTargetInfo().getDataLayout(),
+ EmitBackendOutput(Diags, HeaderSearchOpts, CodeGenOpts, TargetOpts,
+ LangOpts, C.getTargetInfo().getDataLayout(),
getModule(), Action, std::move(AsmOutStream));
Ctx.setInlineAsmDiagnosticHandler(OldHandler, OldContext);
Ctx.setInlineAsmDiagnosticHandler(BitcodeInlineAsmDiagHandler,
&CI.getDiagnostics());
- EmitBackendOutput(CI.getDiagnostics(), CI.getCodeGenOpts(), TargetOpts,
- CI.getLangOpts(), CI.getTarget().getDataLayout(),
- TheModule.get(), BA, std::move(OS));
+ EmitBackendOutput(CI.getDiagnostics(), CI.getHeaderSearchOpts(),
+ CI.getCodeGenOpts(), TargetOpts, CI.getLangOpts(),
+ CI.getTarget().getDataLayout(), TheModule.get(), BA,
+ std::move(OS));
return;
}
// Print the IR for the PCH container to the debug output.
llvm::SmallString<0> Buffer;
clang::EmitBackendOutput(
- Diags, CodeGenOpts, TargetOpts, LangOpts,
+ Diags, HeaderSearchOpts, CodeGenOpts, TargetOpts, LangOpts,
Ctx.getTargetInfo().getDataLayout(), M.get(),
BackendAction::Backend_EmitLL,
llvm::make_unique<llvm::raw_svector_ostream>(Buffer));
});
// Use the LLVM backend to emit the pch container.
- clang::EmitBackendOutput(Diags, CodeGenOpts, TargetOpts, LangOpts,
- Ctx.getTargetInfo().getDataLayout(), M.get(),
- BackendAction::Backend_EmitObj, std::move(OS));
+ clang::EmitBackendOutput(Diags, HeaderSearchOpts, CodeGenOpts, TargetOpts,
+ LangOpts, Ctx.getTargetInfo().getDataLayout(),
+ M.get(), BackendAction::Backend_EmitObj,
+ std::move(OS));
// Free the memory for the temporary buffer.
llvm::SmallVector<char, 0> Empty;
--- /dev/null
+FUNCTION = 1
--- /dev/null
+MODULE = 1
--- /dev/null
+// RUN: %clang_cc1 -I %p/include -S -o - %s | FileCheck %s
+
+__asm__(".include \"module.x\"");
+void function(void) {
+ __asm__(".include \"function.x\"");
+}
+
+// CHECK: MODULE = 1
+// CHECK: FUNCTION = 1
+