authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-02-28 09:27:07-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-02-28 09:27:07-05:00
logea73b8e2b83a2b178d476aff6902ef3c95458e24
treeb47746236967a4411233d8e0449435000782cdfc
parent2dcf1a239250e60ec9d8865e16528049074ec4b0
signature Commit is signed but in an unrecognized format.

update clang driver code to 8.0.0rc3


3 files changed, 32 insertions(+), 7 deletions(-)

src/zig_clang_cc1_main.cpp+4-3
......@@ -13,10 +13,9 @@
1313//
1414//===----------------------------------------------------------------------===//
1515
16#include "llvm/Option/Arg.h"
16#include "clang/Basic/Stack.h"
1717#include "clang/CodeGen/ObjectFilePCHContainerOperations.h"
1818#include "clang/Config/config.h"
19#include "clang/Basic/Stack.h"
2019#include "clang/Driver/DriverDiagnostic.h"
2120#include "clang/Driver/Options.h"
2221#include "clang/Frontend/CompilerInstance.h"
......@@ -29,8 +28,10 @@
2928#include "llvm/ADT/Statistic.h"
3029#include "llvm/Config/llvm-config.h"
3130#include "llvm/LinkAllPasses.h"
31#include "llvm/Option/Arg.h"
3232#include "llvm/Option/ArgList.h"
3333#include "llvm/Option/OptTable.h"
34#include "llvm/Support/BuryPointer.h"
3435#include "llvm/Support/Compiler.h"
3536#include "llvm/Support/ErrorHandling.h"
3637#include "llvm/Support/ManagedStatic.h"
......@@ -217,7 +218,7 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
217218
218219 // When running with -disable-free, don't do any destruction or shutdown.
219220 if (Clang->getFrontendOpts().DisableFree) {
220 BuryPointer(std::move(Clang));
221 llvm::BuryPointer(std::move(Clang));
221222 return !Success;
222223 }
223224
src/zig_clang_cc1as_main.cpp+25-1
......@@ -33,6 +33,7 @@
3333#include "llvm/MC/MCParser/MCAsmParser.h"
3434#include "llvm/MC/MCParser/MCTargetAsmParser.h"
3535#include "llvm/MC/MCRegisterInfo.h"
36#include "llvm/MC/MCSectionMachO.h"
3637#include "llvm/MC/MCStreamer.h"
3738#include "llvm/MC/MCSubtargetInfo.h"
3839#include "llvm/MC/MCTargetOptions.h"
......@@ -132,6 +133,7 @@ struct AssemblerInvocation {
132133 unsigned NoExecStack : 1;
133134 unsigned FatalWarnings : 1;
134135 unsigned IncrementalLinkerCompatible : 1;
136 unsigned EmbedBitcode : 1;
135137
136138 /// The name of the relocation model to use.
137139 std::string RelocationModel;
......@@ -153,6 +155,7 @@ public:
153155 FatalWarnings = 0;
154156 IncrementalLinkerCompatible = 0;
155157 DwarfVersion = 0;
158 EmbedBitcode = 0;
156159 }
157160
158161 static bool CreateFromArgs(AssemblerInvocation &Res,
......@@ -284,6 +287,16 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
284287 Args.hasArg(OPT_mincremental_linker_compatible);
285288 Opts.SymbolDefs = Args.getAllArgValues(OPT_defsym);
286289
290 // EmbedBitcode Option. If -fembed-bitcode is enabled, set the flag.
291 // EmbedBitcode behaves the same for all embed options for assembly files.
292 if (auto *A = Args.getLastArg(OPT_fembed_bitcode_EQ)) {
293 Opts.EmbedBitcode = llvm::StringSwitch<unsigned>(A->getValue())
294 .Case("all", 1)
295 .Case("bitcode", 1)
296 .Case("marker", 1)
297 .Default(0);
298 }
299
287300 return Success;
288301}
289302
......@@ -449,6 +462,16 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
449462 Str.get()->InitSections(Opts.NoExecStack);
450463 }
451464
465 // When -fembed-bitcode is passed to clang_as, a 1-byte marker
466 // is emitted in __LLVM,__asm section if the object file is MachO format.
467 if (Opts.EmbedBitcode && Ctx.getObjectFileInfo()->getObjectFileType() ==
468 MCObjectFileInfo::IsMachO) {
469 MCSection *AsmLabel = Ctx.getMachOSection(
470 "__LLVM", "__asm", MachO::S_REGULAR, 4, SectionKind::getReadOnly());
471 Str.get()->SwitchSection(AsmLabel);
472 Str.get()->EmitZeros(1);
473 }
474
452475 // Assembly to object compilation should leverage assembly info.
453476 Str->setUseAssemblerInfoForParsing(true);
454477
......@@ -534,7 +557,8 @@ int cc1as_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
534557
535558 if (Asm.ShowHelp) {
536559 std::unique_ptr<OptTable> Opts(driver::createDriverOptTable());
537 Opts->PrintHelp(llvm::outs(), "clang -cc1as", "Clang Integrated Assembler",
560 Opts->PrintHelp(llvm::outs(), "clang -cc1as [options] file...",
561 "Clang Integrated Assembler",
538562 /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
539563 /*ShowAllAliases=*/false);
540564 return 0;
src/zig_clang_driver.cpp+3-3
......@@ -258,9 +258,9 @@ static void FixupDiagPrefixExeName(TextDiagnosticPrinter *DiagClient,
258258 const std::string &Path) {
259259 // If the clang binary happens to be named cl.exe for compatibility reasons,
260260 // use clang-cl.exe as the prefix to avoid confusion between clang and MSVC.
261 StringRef ExeBasename(llvm::sys::path::filename(Path));
262 if (ExeBasename.equals_lower("cl.exe"))
263 ExeBasename = "clang-cl.exe";
261 StringRef ExeBasename(llvm::sys::path::stem(Path));
262 if (ExeBasename.equals_lower("cl"))
263 ExeBasename = "clang-cl";
264264 DiagClient->setPrefix(ExeBasename);
265265}
266266