Skip to content

Commit 747f7a3

Browse files
committed
clang-format files touched in d01a91f [nfc]
Some housekeeping on files that recently saw large changes anyway.
1 parent ae6ff33 commit 747f7a3

File tree

13 files changed

+95
-87
lines changed

13 files changed

+95
-87
lines changed

.clang-format

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
BasedOnStyle: LLVM
22
SortIncludes: false
3+
FixNamespaceComments: false

driver/cache.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,8 @@ llvm::cl::opt<unsigned> pruneInterval(
128128
llvm::cl::value_desc("dur"), llvm::cl::init(20 * 60));
129129
llvm::cl::opt<unsigned> pruneExpiration(
130130
"cache-prune-expiration",
131-
llvm::cl::desc(
132-
"Sets the pruning expiration time of cache files to "
133-
"<dur> seconds (default: 1 week). Implies -cache-prune."),
131+
llvm::cl::desc("Sets the pruning expiration time of cache files to "
132+
"<dur> seconds (default: 1 week). Implies -cache-prune."),
134133
llvm::cl::value_desc("dur"), llvm::cl::init(7 * 24 * 3600));
135134
llvm::cl::opt<unsigned> pruneSizeLimitPercentage(
136135
"cache-prune-maxpercentage",
@@ -219,8 +218,7 @@ void storeCacheFileName(llvm::StringRef cacheObjectHash,
219218
// Because the compiler version is part of the hash, differences in the
220219
// default settings between compiler versions are already taken care of.
221220
// (Note: config and response files may also add compiler flags.)
222-
void outputIR2ObjRelevantCmdlineArgs(llvm::raw_ostream &hash_os)
223-
{
221+
void outputIR2ObjRelevantCmdlineArgs(llvm::raw_ostream &hash_os) {
224222
// Use a "whitelist" of cmdline args that do not need to be added to the hash,
225223
// and add all others. There is no harm (other than missed cache
226224
// opportunities) in adding commandline arguments that also change the hashed
@@ -272,13 +270,13 @@ void outputIR2ObjRelevantCmdlineArgs(llvm::raw_ostream &hash_os)
272270
if (arg[1] == 'o' && arg[2] == 'd')
273271
continue;
274272
// All "-cache..." options can be ignored
275-
if (strncmp(arg+1, "cache", 5) == 0)
273+
if (strncmp(arg + 1, "cache", 5) == 0)
276274
continue;
277275
// Ignore "-lib"
278276
if (arg[1] == 'l' && arg[2] == 'i' && arg[3] == 'b' && !arg[4])
279277
continue;
280278
// All effects of -d-version... are already included in the IR hash.
281-
if (strncmp(arg+1, "d-version", 9) == 0)
279+
if (strncmp(arg + 1, "d-version", 9) == 0)
282280
continue;
283281
// All effects of -unittest are already included in the IR hash.
284282
if (strcmp(arg + 1, "unittest") == 0) {
@@ -314,8 +312,7 @@ void outputIR2ObjRelevantCmdlineArgs(llvm::raw_ostream &hash_os)
314312

315313
// Output to `hash_os` all environment flags that influence object code output
316314
// in ways that are not observable in the pre-LLVM passes IR used for hashing.
317-
void outputIR2ObjRelevantEnvironmentOpts(llvm::raw_ostream &hash_os)
318-
{
315+
void outputIR2ObjRelevantEnvironmentOpts(llvm::raw_ostream &hash_os) {
319316
// There are no relevant environment options at the moment.
320317
}
321318

@@ -477,8 +474,8 @@ void recoverObjectFile(llvm::StringRef cacheObjectHash,
477474

478475
void pruneCache() {
479476
if (!opts::cacheDir.empty() && isPruningEnabled()) {
480-
::pruneCache(opts::cacheDir.data(), opts::cacheDir.size(),
481-
pruneInterval, pruneExpiration, pruneSizeLimitInBytes,
477+
::pruneCache(opts::cacheDir.data(), opts::cacheDir.size(), pruneInterval,
478+
pruneExpiration, pruneSizeLimitInBytes,
482479
pruneSizeLimitPercentage);
483480
}
484481
}

driver/cl_options.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,9 @@ static cl::opt<bool, true> unittest("unittest", cl::ZeroOrMore,
223223
cl::location(global.params.useUnitTests));
224224

225225
cl::opt<std::string>
226-
cacheDir("cache", cl::desc("Enable compilation cache, using <cache dir> to "
227-
"store cache files (experimental)"),
226+
cacheDir("cache",
227+
cl::desc("Enable compilation cache, using <cache dir> to "
228+
"store cache files (experimental)"),
228229
cl::value_desc("cache dir"), cl::ZeroOrMore);
229230

230231
static StringsAdapter strImpPathStore("J", global.params.fileImppath);
@@ -277,13 +278,14 @@ cl::list<std::string> transitions(
277278
cl::desc(
278279
"Help with language change identified by <idents>, use ? for list"));
279280

280-
cl::list<std::string> linkerSwitches("L",
281-
cl::desc("Pass <linkerflag> to the linker"),
282-
cl::value_desc("linkerflag"), cl::Prefix);
281+
cl::list<std::string>
282+
linkerSwitches("L", cl::desc("Pass <linkerflag> to the linker"),
283+
cl::value_desc("linkerflag"), cl::Prefix);
283284

284-
cl::list<std::string> ccSwitches("Xcc", cl::CommaSeparated,
285-
cl::desc("Pass <ccflag> to GCC/Clang for linking"),
286-
cl::value_desc("ccflag"));
285+
cl::list<std::string>
286+
ccSwitches("Xcc", cl::CommaSeparated,
287+
cl::desc("Pass <ccflag> to GCC/Clang for linking"),
288+
cl::value_desc("ccflag"));
287289

288290
cl::opt<std::string>
289291
moduleDeps("deps", cl::ValueOptional, cl::ZeroOrMore,
@@ -304,8 +306,7 @@ cl::opt<std::string>
304306
cl::desc("Target a specific cpu type (-mcpu=help for details)"));
305307

306308
cl::list<std::string>
307-
mAttrs("mattr", cl::CommaSeparated,
308-
cl::value_desc("a1,+a2,-a3,..."),
309+
mAttrs("mattr", cl::CommaSeparated, cl::value_desc("a1,+a2,-a3,..."),
309310
cl::desc("Target specific attributes (-mattr=help for details)"));
310311

311312
cl::opt<std::string> mTargetTriple("mtriple", cl::ZeroOrMore,

driver/configfile.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,23 @@ static bool ReadPathFromRegistry(llvm::SmallString<128> &p) {
5656
HKEY hkey;
5757
bool res = false;
5858
// FIXME: Version number should be a define.
59-
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\ldc-developers\\LDC\\0.11.0"),
60-
NULL, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS) {
59+
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
60+
_T("SOFTWARE\\ldc-developers\\LDC\\0.11.0"), NULL,
61+
KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS) {
6162
DWORD length;
62-
if (RegGetValue(hkey, NULL, _T("Path"), RRF_RT_REG_SZ, NULL, NULL, &length) ==
63-
ERROR_SUCCESS) {
63+
if (RegGetValue(hkey, NULL, _T("Path"), RRF_RT_REG_SZ, NULL, NULL,
64+
&length) == ERROR_SUCCESS) {
6465
TCHAR *data = static_cast<TCHAR *>(_alloca(length * sizeof(TCHAR)));
65-
if (RegGetValue(hkey, NULL, _T("Path"), RRF_RT_REG_SZ, NULL, data, &length) ==
66-
ERROR_SUCCESS) {
66+
if (RegGetValue(hkey, NULL, _T("Path"), RRF_RT_REG_SZ, NULL, data,
67+
&length) == ERROR_SUCCESS) {
6768
#if UNICODE
6869
#if LDC_LLVM_VER >= 400
6970
using UTF16 = llvm::UTF16;
7071
#endif
7172
std::string out;
7273
res = llvm::convertUTF16ToUTF8String(
73-
llvm::ArrayRef<UTF16>(reinterpret_cast<UTF16 *>(data), length), out);
74+
llvm::ArrayRef<UTF16>(reinterpret_cast<UTF16 *>(data), length),
75+
out);
7476
p = out;
7577
#else
7678
p = std::string(data);
@@ -84,8 +86,7 @@ static bool ReadPathFromRegistry(llvm::SmallString<128> &p) {
8486
}
8587
#endif
8688

87-
88-
bool ConfigFile::locate(std::string& pathstr) {
89+
bool ConfigFile::locate(std::string &pathstr) {
8990
// temporary configuration
9091

9192
llvm::SmallString<128> p;
@@ -169,7 +170,7 @@ bool ConfigFile::locate(std::string& pathstr) {
169170
return false;
170171
}
171172

172-
bool ConfigFile::read(const char *explicitConfFile, const char* section) {
173+
bool ConfigFile::read(const char *explicitConfFile, const char *section) {
173174
std::string pathstr;
174175
// explicitly provided by user in command line?
175176
if (explicitConfFile) {
@@ -180,8 +181,9 @@ bool ConfigFile::read(const char *explicitConfFile, const char* section) {
180181
if (sys::fs::exists(clPath)) {
181182
pathstr = clPath;
182183
} else {
183-
fprintf(stderr, "Warning: configuration file '%s' not found, falling "
184-
"back to default\n",
184+
fprintf(stderr,
185+
"Warning: configuration file '%s' not found, falling "
186+
"back to default\n",
185187
clPath.c_str());
186188
}
187189
}

driver/linker.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ std::string getLTOdylibPath() {
202202
void addDarwinLTOFlags(std::vector<std::string> &args) {
203203
std::string dylibPath = getLTOdylibPath();
204204
if (!dylibPath.empty()) {
205-
args.push_back("-lto_library");
206-
args.push_back(std::move(dylibPath));
205+
args.push_back("-lto_library");
206+
args.push_back(std::move(dylibPath));
207207
}
208208
}
209209

@@ -356,22 +356,22 @@ static int linkObjToBinaryGcc(bool sharedLib) {
356356
// additional linker and cc switches (preserve order across both lists)
357357
for (unsigned ilink = 0, icc = 0;;) {
358358
unsigned linkpos = ilink < opts::linkerSwitches.size()
359-
? opts::linkerSwitches.getPosition(ilink)
360-
: std::numeric_limits<unsigned>::max();
359+
? opts::linkerSwitches.getPosition(ilink)
360+
: std::numeric_limits<unsigned>::max();
361361
unsigned ccpos = icc < opts::ccSwitches.size()
362-
? opts::ccSwitches.getPosition(icc)
363-
: std::numeric_limits<unsigned>::max();
362+
? opts::ccSwitches.getPosition(icc)
363+
: std::numeric_limits<unsigned>::max();
364364
if (linkpos < ccpos) {
365-
const std::string& p = opts::linkerSwitches[ilink++];
365+
const std::string &p = opts::linkerSwitches[ilink++];
366366
// Don't push -l and -L switches using -Xlinker, but pass them indirectly
367367
// via GCC. This makes sure user-defined paths take precedence over
368368
// GCC's builtin LIBRARY_PATHs.
369369
// Options starting with `-Wl,`, -shared or -static are not handled by
370370
// the linker and must be passed to the driver.
371371
auto str = llvm::StringRef(p);
372372
if (!(str.startswith("-l") || str.startswith("-L") ||
373-
str.startswith("-Wl,") ||
374-
str.startswith("-shared") || str.startswith("-static"))) {
373+
str.startswith("-Wl,") || str.startswith("-shared") ||
374+
str.startswith("-static"))) {
375375
args.push_back("-Xlinker");
376376
}
377377
args.push_back(p);
@@ -616,7 +616,7 @@ static int linkObjToBinaryMSVC(bool sharedLib) {
616616
args.push_back(str);
617617
};
618618

619-
for (const auto& str : opts::linkerSwitches) {
619+
for (const auto &str : opts::linkerSwitches) {
620620
addSwitch(str);
621621
}
622622

driver/toobj.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,7 @@ void writeModule(llvm::Module *m, const char *filename) {
429429
// Use cached object code if possible.
430430
// TODO: combine LDC's cache and LTO (the advantage is skipping the IR
431431
// optimization).
432-
const bool useIR2ObjCache =
433-
!opts::cacheDir.empty() && outputObj && !doLTO;
432+
const bool useIR2ObjCache = !opts::cacheDir.empty() && outputObj && !doLTO;
434433
llvm::SmallString<32> moduleHash;
435434
if (useIR2ObjCache) {
436435
llvm::SmallString<128> cacheDir(opts::cacheDir.c_str());

gen/llvmhelpers.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ bool isTargetWindowsMSVC() {
7171
}
7272

7373
/******************************************************************************
74-
* Global context
75-
******************************************************************************/
74+
* Global context
75+
******************************************************************************/
7676
static llvm::ManagedStatic<llvm::LLVMContext> GlobalContext;
7777

7878
llvm::LLVMContext &getGlobalContext() { return *GlobalContext; }
@@ -1416,9 +1416,10 @@ bool isLLVMUnsigned(Type *t) { return t->isunsigned() || t->ty == Tpointer; }
14161416

14171417
void printLabelName(std::ostream &target, const char *func_mangle,
14181418
const char *label_name) {
1419-
target << gTargetMachine->getMCAsmInfo()->getPrivateGlobalPrefix()
1419+
target << gTargetMachine->getMCAsmInfo()
1420+
->getPrivateGlobalPrefix()
14201421
#if LDC_LLVM_VER >= 400
1421-
.str()
1422+
.str()
14221423
#endif
14231424
<< func_mangle << "_" << label_name;
14241425
}
@@ -1619,9 +1620,9 @@ DValue *DtoSymbolAddress(Loc &loc, Type *type, Declaration *decl) {
16191620
fatal();
16201621
}
16211622
DtoResolveFunction(fdecl);
1622-
return new DFuncValue(fdecl, fdecl->llvmInternal != LLVMva_arg
1623-
? DtoCallee(fdecl)
1624-
: nullptr);
1623+
const auto llValue =
1624+
fdecl->llvmInternal != LLVMva_arg ? DtoCallee(fdecl) : nullptr;
1625+
return new DFuncValue(fdecl, llValue);
16251626
}
16261627

16271628
if (SymbolDeclaration *sdecl = decl->isSymbolDeclaration()) {
@@ -1657,8 +1658,9 @@ llvm::Constant *DtoConstSymbolAddress(Loc &loc, Declaration *decl) {
16571658
// needed for the current hacky implementation of
16581659
// AssocArrayLiteralExp::toElem, which requires on error
16591660
// gagging to check for constantness of the initializer.
1660-
error(loc, "cannot use address of non-global variable '%s' "
1661-
"as constant initializer",
1661+
error(loc,
1662+
"cannot use address of non-global variable '%s' as constant "
1663+
"initializer",
16621664
vd->toChars());
16631665
if (!global.gag) {
16641666
fatal();
@@ -1725,8 +1727,9 @@ llvm::GlobalVariable *getOrCreateGlobal(const Loc &loc, llvm::Module &module,
17251727
llvm::GlobalVariable *existing = module.getGlobalVariable(name, true);
17261728
if (existing) {
17271729
if (existing->getType()->getElementType() != type) {
1728-
error(loc, "Global variable type does not match previous "
1729-
"declaration with same mangled name: %s",
1730+
error(loc,
1731+
"Global variable type does not match previous declaration with "
1732+
"same mangled name: %s",
17301733
name.str().c_str());
17311734
fatal();
17321735
}

gen/modules.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ void Module::checkAndAddOutputFile(File *file) {
7070
auto i = files.find(key);
7171
if (i != files.end()) {
7272
Module *previousMod = i->second;
73-
::error(Loc(), "Output file '%s' for module '%s' collides with previous "
74-
"module '%s'. See the -oq option",
73+
::error(Loc(),
74+
"Output file '%s' for module '%s' collides with previous "
75+
"module '%s'. See the -oq option",
7576
key.c_str(), toPrettyChars(), previousMod->toPrettyChars());
7677
fatal();
7778
}
@@ -290,7 +291,8 @@ llvm::Function *buildRegisterDSO(RegistryStyle style,
290291

291292
{
292293
IRBuilder<> b(entryBB);
293-
const auto loadedFlag = b.CreateTrunc(b.CreateLoad(dsoInitialized), b.getInt1Ty());
294+
const auto loadedFlag =
295+
b.CreateTrunc(b.CreateLoad(dsoInitialized), b.getInt1Ty());
294296
const auto condEval =
295297
b.CreateICmp(llvm::ICmpInst::ICMP_EQ, loadedFlag, isShutdown);
296298
b.CreateCondBr(condEval, initBB, endBB);
@@ -687,8 +689,7 @@ void registerModuleInfo(Module *m) {
687689
const char *mangle = mangleBuf.peekString();
688690

689691
if (style == RegistryStyle::legacyLinkedList) {
690-
const auto miCtor =
691-
build_module_reference_and_ctor(mangle, moduleInfoSym);
692+
const auto miCtor = build_module_reference_and_ctor(mangle, moduleInfoSym);
692693
AppendFunctionToLLVMGlobalCtorsDtors(miCtor, 65535, true);
693694
} else {
694695
emitModuleRefToSection(style, mangle, moduleInfoSym);

gen/optimizer.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ bool willCrossModuleInline() {
133133
#if LDC_LLVM_VER >= 307
134134
return enableCrossModuleInlining == llvm::cl::BOU_TRUE;
135135
#else
136-
// Cross-module inlining is disabled for <3.7 because we don't emit symbols in
137-
// COMDAT any groups pre-LLVM3.7. With cross-module inlining enabled, without
138-
// COMDAT any there are multiple-def linker errors when linking druntime.
139-
// See supportsCOMDAT().
136+
// Cross-module inlining is disabled for <3.7 because we don't emit symbols in
137+
// COMDAT any groups pre-LLVM3.7. With cross-module inlining enabled, without
138+
// COMDAT any there are multiple-def linker errors when linking druntime.
139+
// See supportsCOMDAT().
140140
return false;
141141
#endif
142142
}
@@ -456,10 +456,9 @@ void verifyModule(llvm::Module *m) {
456456
Logger::println("Verification passed!");
457457
}
458458

459-
// Output to `hash_os` all optimization settings that influence object code output
460-
// and that are not observable in the IR.
461-
// This is used to calculate the hash use for caching that uniquely identifies
462-
// the object file output.
459+
// Output to `hash_os` all optimization settings that influence object code
460+
// output and that are not observable in the IR. This is used to calculate the
461+
// hash use for caching that uniquely identifies the object file output.
463462
void outputOptimizationSettings(llvm::raw_ostream &hash_os) {
464463
hash_os << optimizeLevel;
465464
hash_os << willInline();

gen/passes/GarbageCollect2Stack.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,11 @@ class FunctionInfo {
123123
Instruction *Begin = &(*BB.begin());
124124

125125
// FIXME: set alignment on alloca?
126-
return new AllocaInst(
127-
Ty,
126+
return new AllocaInst(Ty,
128127
#if LDC_LLVM_VER >= 500
129-
BB.getModule()->getDataLayout().getAllocaAddrSpace(),
128+
BB.getModule()->getDataLayout().getAllocaAddrSpace(),
130129
#endif
131-
".nongc_mem", Begin);
130+
".nongc_mem", Begin);
132131
}
133132

134133
explicit FunctionInfo(ReturnType::Type returnType) : ReturnType(returnType) {}
@@ -840,7 +839,8 @@ bool isSafeToStackAllocateArray(
840839
/// the attribute has to be removed before promoting the memory to the
841840
/// stack. The affected instructions are added to RemoveTailCallInsts. If
842841
/// the function returns false, these entries are meaningless.
843-
bool isSafeToStackAllocate(BasicBlock::iterator Alloc, Value *V, DominatorTree &DT,
842+
bool isSafeToStackAllocate(BasicBlock::iterator Alloc, Value *V,
843+
DominatorTree &DT,
844844
SmallVector<CallInst *, 4> &RemoveTailCallInsts) {
845845
assert(isa<PointerType>(V->getType()) && "Allocated value is not a pointer?");
846846

0 commit comments

Comments
 (0)