mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-05 09:31:03 +03:00
Misc. merge fixes (C++)
This commit is contained in:
parent
48809250d8
commit
a053480010
17 changed files with 49 additions and 75 deletions
|
@ -339,7 +339,7 @@ int createStaticLibrary() {
|
|||
|
||||
if (useInternalArchiver) {
|
||||
const auto fullArgs =
|
||||
getFullArgs(tool.c_str(), args, global.params.verbose);
|
||||
getFullArgs(tool.c_str(), args, global.params.v.verbose);
|
||||
|
||||
const int exitCode =
|
||||
isTargetMSVC ? internalLib(fullArgs) : internalAr(fullArgs);
|
||||
|
@ -350,7 +350,7 @@ int createStaticLibrary() {
|
|||
}
|
||||
|
||||
// invoke external archiver
|
||||
return executeToolAndWait(Loc(), tool, args, global.params.verbose);
|
||||
return executeToolAndWait(Loc(), tool, args, global.params.v.verbose);
|
||||
}
|
||||
|
||||
const char *getPathToProducedStaticLibrary() {
|
||||
|
|
|
@ -85,16 +85,16 @@ cl::opt<DLLImport, true> dllimport(
|
|||
"-fvisibility=public)")));
|
||||
|
||||
static cl::opt<bool, true> verbose("v", cl::desc("Verbose"), cl::ZeroOrMore,
|
||||
cl::location(global.params.verbose));
|
||||
cl::location(global.params.v.verbose));
|
||||
|
||||
static cl::opt<bool, true>
|
||||
vcolumns("vcolumns",
|
||||
cl::desc("Print character (column) numbers in diagnostics"),
|
||||
cl::ZeroOrMore, cl::location(global.params.showColumns));
|
||||
cl::ZeroOrMore, cl::location(global.params.v.showColumns));
|
||||
|
||||
static cl::opt<bool, true>
|
||||
vgc("vgc", cl::desc("List all gc allocations including hidden ones"),
|
||||
cl::ZeroOrMore, cl::location(global.params.vgc));
|
||||
cl::ZeroOrMore, cl::location(global.params.v.gc));
|
||||
|
||||
// Dummy data type for custom parsers where the help output shouldn't display
|
||||
// any value.
|
||||
|
@ -106,14 +106,14 @@ struct VTemplatesParser : public cl::parser<DummyDataType> {
|
|||
|
||||
bool parse(cl::Option &O, llvm::StringRef /*ArgName*/, llvm::StringRef Arg,
|
||||
DummyDataType & /*Val*/) {
|
||||
global.params.vtemplates = true;
|
||||
global.params.v.templates = true;
|
||||
|
||||
if (Arg.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Arg == "list-instances") {
|
||||
global.params.vtemplatesListInstances = true;
|
||||
global.params.v.templatesListInstances = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -136,23 +136,23 @@ static cl::opt<bool, true> verbose_cg_ast("vcg-ast", cl::ZeroOrMore, cl::Hidden,
|
|||
cl::location(global.params.vcg_ast));
|
||||
|
||||
static cl::opt<unsigned, true> errorLimit(
|
||||
"verrors", cl::ZeroOrMore, cl::location(global.params.errorLimit),
|
||||
"verrors", cl::ZeroOrMore, cl::location(global.params.v.errorLimit),
|
||||
cl::desc("Limit the number of error messages (0 means unlimited)"));
|
||||
|
||||
static cl::opt<bool, true>
|
||||
showGaggedErrors("verrors-spec", cl::ZeroOrMore,
|
||||
cl::location(global.params.showGaggedErrors),
|
||||
cl::location(global.params.v.showGaggedErrors),
|
||||
cl::desc("Show errors from speculative compiles such as "
|
||||
"__traits(compiles,...)"));
|
||||
|
||||
static cl::opt<bool, true> printErrorContext(
|
||||
"verrors-context", cl::ZeroOrMore,
|
||||
cl::location(global.params.printErrorContext),
|
||||
cl::location(global.params.v.printErrorContext),
|
||||
cl::desc(
|
||||
"Show error messages with the context of the erroring source line"));
|
||||
|
||||
static cl::opt<MessageStyle, true> verrorStyle(
|
||||
"verror-style", cl::ZeroOrMore, cl::location(global.params.messageStyle),
|
||||
"verror-style", cl::ZeroOrMore, cl::location(global.params.v.messageStyle),
|
||||
cl::desc(
|
||||
"Set the style for file/line number annotations on compiler messages"),
|
||||
cl::values(
|
||||
|
@ -165,7 +165,7 @@ static cl::opt<MessageStyle, true> verrorStyle(
|
|||
|
||||
static cl::opt<unsigned, true>
|
||||
verrorSupplements("verror-supplements", cl::ZeroOrMore,
|
||||
cl::location(global.params.errorSupplementLimit),
|
||||
cl::location(global.params.v.errorSupplementLimit),
|
||||
cl::desc("Limit the number of supplemental messages for "
|
||||
"each error (0 means unlimited)"));
|
||||
|
||||
|
@ -178,10 +178,6 @@ static cl::opt<Diagnostic, true> warnings(
|
|||
"Enable warnings as messages (compilation will continue)")),
|
||||
cl::init(DIAGNOSTICoff));
|
||||
|
||||
static cl::opt<bool, true> warningsObsolete(
|
||||
"wo", cl::ZeroOrMore, cl::location(global.params.obsolete),
|
||||
cl::desc("Enable warnings about use of obsolete features"));
|
||||
|
||||
static cl::opt<bool, true> ignoreUnsupportedPragmas(
|
||||
"ignore", cl::desc("Ignore unsupported pragmas"), cl::ZeroOrMore,
|
||||
cl::location(global.params.ignoreUnsupportedPragmas));
|
||||
|
@ -760,7 +756,7 @@ void createClashingOptions() {
|
|||
|
||||
// Step 2. Add the LDC options.
|
||||
new cl::opt<bool, true, FlagParser<bool>>(
|
||||
"color", cl::ZeroOrMore, cl::location(global.params.color),
|
||||
"color", cl::ZeroOrMore, cl::location(global.params.v.color),
|
||||
cl::desc("(*) Force colored console output"));
|
||||
new cl::opt<bool, true>("ffast-math", cl::ZeroOrMore, cl::location(fFastMath),
|
||||
cl::desc("Set @fastmath for all functions."));
|
||||
|
|
|
@ -144,7 +144,7 @@ FileName runCPreprocessor(FileName csrcfile, const Loc &loc, bool &ifile,
|
|||
args.push_back(ipath.toChars());
|
||||
}
|
||||
|
||||
const int status = executeToolAndWait(loc, cc, args, global.params.verbose);
|
||||
const int status = executeToolAndWait(loc, cc, args, global.params.v.verbose);
|
||||
if (status) {
|
||||
errorSupplemental(loc, "C preprocessor failed for file '%s'", csrcfile.toChars());
|
||||
fatal();
|
||||
|
|
|
@ -594,12 +594,7 @@ void translateArgs(const llvm::SmallVectorImpl<const char *> &ldmdArgs,
|
|||
* -revert
|
||||
* -w
|
||||
* -wi
|
||||
*/
|
||||
else if (strcmp(p + 1, "wo") == 0) {
|
||||
ldcArgs.push_back("-wo");
|
||||
ldcArgs.push_back("-wi"); // DMD overrides a previous `-w` to `-wi`; LDC doesn't
|
||||
}
|
||||
/* -O
|
||||
* -O
|
||||
* -o-
|
||||
* -od
|
||||
* -of
|
||||
|
|
|
@ -756,7 +756,7 @@ int linkObjToBinaryGcc(llvm::StringRef outputPath,
|
|||
argsBuilder.build(outputPath, defaultLibNames);
|
||||
|
||||
const auto fullArgs =
|
||||
getFullArgs("lld", argsBuilder.args, global.params.verbose);
|
||||
getFullArgs("lld", argsBuilder.args, global.params.v.verbose);
|
||||
|
||||
// CanExitEarly == true means that LLD can and will call `exit()` when
|
||||
// errors occur.
|
||||
|
@ -861,5 +861,5 @@ int linkObjToBinaryGcc(llvm::StringRef outputPath,
|
|||
|
||||
// try to call linker
|
||||
return executeToolAndWait(Loc(), tool, argsBuilder->args,
|
||||
global.params.verbose);
|
||||
global.params.v.verbose);
|
||||
}
|
||||
|
|
|
@ -268,7 +268,8 @@ int linkObjToBinaryMSVC(llvm::StringRef outputPath,
|
|||
#if LDC_WITH_LLD
|
||||
if (useInternalLLDForLinking() ||
|
||||
(useInternalToolchain && opts::linker.empty())) {
|
||||
const auto fullArgs = getFullArgs("lld-link", args, global.params.verbose);
|
||||
const auto fullArgs =
|
||||
getFullArgs("lld-link", args, global.params.v.verbose);
|
||||
|
||||
const bool canExitEarly = false;
|
||||
const bool success = lld::coff::link(fullArgs
|
||||
|
@ -302,5 +303,5 @@ int linkObjToBinaryMSVC(llvm::StringRef outputPath,
|
|||
#endif
|
||||
}
|
||||
|
||||
return executeToolAndWait(Loc(), linker, args, global.params.verbose);
|
||||
return executeToolAndWait(Loc(), linker, args, global.params.v.verbose);
|
||||
}
|
||||
|
|
|
@ -326,8 +326,8 @@ int runProgram() {
|
|||
assert(!gExePath.empty());
|
||||
|
||||
// Run executable
|
||||
int status =
|
||||
executeToolAndWait(Loc(), gExePath, opts::runargs, global.params.verbose);
|
||||
int status = executeToolAndWait(Loc(), gExePath, opts::runargs,
|
||||
global.params.v.verbose);
|
||||
if (status < 0) {
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
error(Loc(), "program received signal %d", -status);
|
||||
|
|
|
@ -139,8 +139,9 @@ void printVersion(llvm::raw_ostream &OS) {
|
|||
}
|
||||
|
||||
// Helper function to handle -d-debug=* and -d-version=*
|
||||
void processVersions(std::vector<std::string> &list, const char *type,
|
||||
unsigned &globalLevel, Strings *&globalIDs) {
|
||||
template <typename Condition>
|
||||
void processVersions(const std::vector<std::string> &list, const char *type,
|
||||
unsigned &globalLevel) {
|
||||
for (const auto &i : list) {
|
||||
const char *value = i.c_str();
|
||||
if (isdigit(value[0])) {
|
||||
|
@ -155,12 +156,9 @@ void processVersions(std::vector<std::string> &list, const char *type,
|
|||
} else {
|
||||
char *cstr = mem.xstrdup(value);
|
||||
if (Identifier::isValidIdentifier(cstr)) {
|
||||
if (!globalIDs)
|
||||
globalIDs = createStrings();
|
||||
globalIDs->push(cstr);
|
||||
continue;
|
||||
Condition::addGlobalIdent(cstr);
|
||||
} else {
|
||||
error(Loc(), "Invalid %s identifier or level: '%s'", type, i.c_str());
|
||||
error(Loc(), "Invalid %s identifier or level: '%s'", type, cstr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -324,7 +322,7 @@ void parseCommandLine(Strings &sourceFiles) {
|
|||
// - path to compiler binary
|
||||
// - version number
|
||||
// - used config file
|
||||
if (global.params.verbose) {
|
||||
if (global.params.v.verbose) {
|
||||
message("binary %s", exe_path::getExePath().c_str());
|
||||
message("version %s (DMD %s, LLVM %s)", ldc::ldc_version,
|
||||
ldc::dmd_version, ldc::llvm_version);
|
||||
|
@ -416,10 +414,9 @@ void parseCommandLine(Strings &sourceFiles) {
|
|||
|
||||
opts::initializeSanitizerOptionsFromCmdline();
|
||||
|
||||
processVersions(debugArgs, "debug", global.params.debuglevel,
|
||||
global.params.debugids);
|
||||
processVersions(versions, "version", global.params.versionlevel,
|
||||
global.params.versionids);
|
||||
processVersions<DebugCondition>(debugArgs, "debug", global.params.debuglevel);
|
||||
processVersions<VersionCondition>(versions, "version",
|
||||
global.params.versionlevel);
|
||||
|
||||
for (const auto &id : transitions)
|
||||
parseTransitionOption(global.params, id.c_str());
|
||||
|
@ -449,11 +446,6 @@ void parseCommandLine(Strings &sourceFiles) {
|
|||
global.params.allInst = true;
|
||||
}
|
||||
|
||||
// -wo implies at least -wi (print the warnings)
|
||||
if (global.params.obsolete && global.params.warnings == DIAGNOSTICoff) {
|
||||
global.params.warnings = DIAGNOSTICinform;
|
||||
}
|
||||
|
||||
global.params.output_o =
|
||||
(opts::output_o == cl::BOU_UNSET &&
|
||||
!(opts::output_bc || opts::output_ll || opts::output_s ||
|
||||
|
@ -1136,8 +1128,6 @@ int cppmain() {
|
|||
|
||||
global.compileEnv.previewIn = global.params.previewIn;
|
||||
global.compileEnv.ddocOutput = global.params.ddoc.doOutput;
|
||||
global.compileEnv.shortenedMethods = global.params.shortenedMethods;
|
||||
global.compileEnv.obsolete = global.params.obsolete;
|
||||
|
||||
if (opts::fTimeTrace) {
|
||||
initializeTimeTrace(opts::fTimeTraceGranularity, 0, opts::allArguments[0]);
|
||||
|
@ -1268,7 +1258,7 @@ void codegenModules(Modules &modules) {
|
|||
if (m->filetype == FileType::dhdr)
|
||||
continue;
|
||||
|
||||
if (global.params.verbose)
|
||||
if (global.params.v.verbose)
|
||||
message("code %s", m->toChars());
|
||||
|
||||
const auto atCompute = hasComputeAttr(m);
|
||||
|
|
|
@ -148,7 +148,7 @@ static void assemble(const std::string &asmpath, const std::string &objpath) {
|
|||
appendTargetArgsForGcc(args);
|
||||
|
||||
// Run the compiler to assembly the program.
|
||||
int R = executeToolAndWait(Loc(), getGcc(), args, global.params.verbose);
|
||||
int R = executeToolAndWait(Loc(), getGcc(), args, global.params.v.verbose);
|
||||
if (R) {
|
||||
error(Loc(), "Error while invoking external assembler.");
|
||||
fatal();
|
||||
|
|
|
@ -330,7 +330,7 @@ bool setupMsvcEnvironmentImpl(
|
|||
if (!rollback) // check for availability only
|
||||
return true;
|
||||
|
||||
if (global.params.verbose)
|
||||
if (global.params.v.verbose)
|
||||
message("Prepending to environment variables:");
|
||||
|
||||
const auto prependToEnvVar =
|
||||
|
@ -348,7 +348,7 @@ bool setupMsvcEnvironmentImpl(
|
|||
head += entry;
|
||||
}
|
||||
|
||||
if (global.params.verbose)
|
||||
if (global.params.v.verbose)
|
||||
message(" %s += %.*s", key, (int)head.size(), head.data());
|
||||
|
||||
llvm::SmallVector<wchar_t, 1024> wvalue;
|
||||
|
@ -372,7 +372,7 @@ bool setupMsvcEnvironmentImpl(
|
|||
prependToEnvVar("LIB", L"LIB", libPaths);
|
||||
prependToEnvVar("PATH", L"PATH", binPaths);
|
||||
|
||||
if (global.params.verbose) {
|
||||
if (global.params.v.verbose) {
|
||||
const auto end = std::chrono::steady_clock::now();
|
||||
message("MSVC setup took %lld microseconds",
|
||||
std::chrono::duration_cast<std::chrono::microseconds>(end - begin)
|
||||
|
|
|
@ -3234,7 +3234,7 @@ struct AsmProcessor {
|
|||
if (isIntExp(e1) && (!e2 || isIntExp(e2))) {
|
||||
Expression *e = createExpressionForIntOp(stmt->loc, op, e1, e2);
|
||||
e = expressionSemantic(e, sc);
|
||||
return e->ctfeInterpret();
|
||||
return ctfeInterpret(e);
|
||||
}
|
||||
|
||||
stmt->error("expected integer operand(s) for `%s`", Token::toChars(op));
|
||||
|
@ -3793,7 +3793,7 @@ struct AsmProcessor {
|
|||
|
||||
// parse primary: DMD allows 'MyAlign' (const int) but not '2+2'
|
||||
// GAS is padding with NOPs last time I checked.
|
||||
Expression *e = parseAsmExp()->ctfeInterpret();
|
||||
Expression *e = ctfeInterpret(parseAsmExp());
|
||||
uinteger_t align = e->toUInteger();
|
||||
|
||||
if ((align & (align - 1)) == 0) {
|
||||
|
|
|
@ -114,10 +114,4 @@ void print(const char *fmt, ...) {
|
|||
va_end(va);
|
||||
}
|
||||
}
|
||||
void attention(const Loc &loc, const char *fmt, ...) {
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
vwarning(loc, fmt, va);
|
||||
va_end(va);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,8 +105,6 @@ inline void enable() { _Logger_enabled = true; }
|
|||
inline void disable() { _Logger_enabled = false; }
|
||||
inline bool enabled() { return _Logger_enabled; }
|
||||
|
||||
void attention(Loc loc, const char *fmt, ...) IS_PRINTF(2);
|
||||
|
||||
struct LoggerScope {
|
||||
LoggerScope() { Logger::indent(); }
|
||||
~LoggerScope() { Logger::undent(); }
|
||||
|
|
|
@ -250,7 +250,7 @@ struct LazyFunctionDeclarer {
|
|||
StorageClass stc = paramsSTC.empty() ? 0 : paramsSTC[i];
|
||||
Type *paramTy = paramTypes[i].get(loc);
|
||||
params->push(
|
||||
Parameter::create(stc, paramTy, nullptr, nullptr, nullptr));
|
||||
Parameter::create(Loc(), stc, paramTy, nullptr, nullptr, nullptr));
|
||||
}
|
||||
}
|
||||
Type *returnTy = returnType.get(loc);
|
||||
|
@ -454,7 +454,8 @@ static Type *rt_dg1() {
|
|||
return dg_t;
|
||||
|
||||
auto params = createParameters();
|
||||
params->push(Parameter::create(0, Type::tvoidptr, nullptr, nullptr, nullptr));
|
||||
params->push(
|
||||
Parameter::create(Loc(), 0, Type::tvoidptr, nullptr, nullptr, nullptr));
|
||||
auto fty = TypeFunction::create(params, Type::tint32, VARARGnone, LINK::d);
|
||||
dg_t = TypeDelegate::create(fty);
|
||||
return dg_t;
|
||||
|
@ -467,8 +468,10 @@ static Type *rt_dg2() {
|
|||
return dg2_t;
|
||||
|
||||
auto params = createParameters();
|
||||
params->push(Parameter::create(0, Type::tvoidptr, nullptr, nullptr, nullptr));
|
||||
params->push(Parameter::create(0, Type::tvoidptr, nullptr, nullptr, nullptr));
|
||||
params->push(
|
||||
Parameter::create(Loc(), 0, Type::tvoidptr, nullptr, nullptr, nullptr));
|
||||
params->push(
|
||||
Parameter::create(Loc(), 0, Type::tvoidptr, nullptr, nullptr, nullptr));
|
||||
auto fty = TypeFunction::create(params, Type::tint32, VARARGnone, LINK::d);
|
||||
dg2_t = TypeDelegate::create(fty);
|
||||
return dg2_t;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "dmd/mtype.h"
|
||||
#include "dmd/scope.h"
|
||||
#include "dmd/template.h"
|
||||
#include "dmd/typinf.h"
|
||||
#include "gen/arrays.h"
|
||||
#include "gen/classes.h"
|
||||
#include "gen/irstate.h"
|
||||
|
@ -57,16 +58,12 @@
|
|||
#include <cassert>
|
||||
#include <cstdio>
|
||||
|
||||
// in dmd/typinf.d:
|
||||
void genTypeInfo(Expression *e, const Loc &loc, Type *torig, Scope *sc, bool genObjCode = true);
|
||||
|
||||
TypeInfoDeclaration *getOrCreateTypeInfoDeclaration(const Loc &loc, Type *forType) {
|
||||
IF_LOG Logger::println("getOrCreateTypeInfoDeclaration(): %s",
|
||||
forType->toChars());
|
||||
LOG_SCOPE
|
||||
|
||||
// the `genObjCode` parameter is unused by LDC
|
||||
genTypeInfo(nullptr, loc, forType, nullptr, false);
|
||||
genTypeInfo(nullptr, loc, forType, nullptr);
|
||||
|
||||
return forType->vtinfo;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ StructLiteralExp *getLdcAttributesStruct(Expression *attr) {
|
|||
// attributes are struct literals that may be constructed using a CTFE
|
||||
// function.
|
||||
unsigned prevErrors = global.startGagging();
|
||||
auto e = attr->ctfeInterpret();
|
||||
auto e = ctfeInterpret(attr);
|
||||
if (global.endGagging(prevErrors)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ void IrGlobal::define() {
|
|||
Logger::println("Defining global: %s", V->toChars());
|
||||
LOG_SCOPE
|
||||
|
||||
if (global.params.vtls && V->isThreadlocal() &&
|
||||
if (global.params.v.tls && V->isThreadlocal() &&
|
||||
!(V->storage_class & STCtemp)) {
|
||||
message("%s: `%s` is thread local", V->loc.toChars(), V->toChars());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue