Skip to content

Commit ef4cc8b

Browse files
committed
chore(style): format code with clang-format
1 parent 6a8c64f commit ef4cc8b

12 files changed

+487
-514
lines changed

include/analysis/MemIntrinsicOverflow.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ namespace ctrace::stack::analysis
3838
const std::string& bufferModelPath = "");
3939

4040
std::vector<MemIntrinsicIssue>
41-
analyzeMemIntrinsicOverflowsCached(const llvm::Function& function,
42-
const llvm::DataLayout& DL,
41+
analyzeMemIntrinsicOverflowsCached(const llvm::Function& function, const llvm::DataLayout& DL,
4342
const std::vector<const llvm::CallInst*>& calls,
4443
const std::vector<const llvm::InvokeInst*>& invokes,
4544
const BufferWriteModel* externalModel,

include/analyzer/AnalysisArtifactStore.hpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@ namespace ctrace::stack::analyzer
1818
return *artifact;
1919
}
2020

21-
template <typename T> void set(const T& value) { (void)emplace<T>(value); }
21+
template <typename T> void set(const T& value)
22+
{
23+
(void)emplace<T>(value);
24+
}
2225

23-
template <typename T> void set(T&& value) { (void)emplace<T>(std::move(value)); }
26+
template <typename T> void set(T&& value)
27+
{
28+
(void)emplace<T>(std::move(value));
29+
}
2430

2531
template <typename T> [[nodiscard]] bool has() const
2632
{
@@ -43,7 +49,10 @@ namespace ctrace::stack::analyzer
4349
return static_cast<const T*>(it->second.get());
4450
}
4551

46-
void clear() { artifacts_.clear(); }
52+
void clear()
53+
{
54+
artifacts_.clear();
55+
}
4756

4857
private:
4958
std::unordered_map<std::type_index, std::shared_ptr<void>> artifacts_;

include/analyzer/InstructionSubscriber.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,15 @@ namespace ctrace::stack::analyzer
3333
class InstructionSubscriberRegistry
3434
{
3535
public:
36-
void add(InstructionSubscriber& subscriber) { subscribers_.push_back(&subscriber); }
36+
void add(InstructionSubscriber& subscriber)
37+
{
38+
subscribers_.push_back(&subscriber);
39+
}
3740

38-
[[nodiscard]] bool empty() const { return subscribers_.empty(); }
41+
[[nodiscard]] bool empty() const
42+
{
43+
return subscribers_.empty();
44+
}
3945

4046
void notifyFunctionBegin(const llvm::Function& F) const
4147
{

src/analysis/CommandInjectionAnalysis.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ namespace ctrace::stack::analysis
134134
namespace
135135
{
136136
template <typename CallBaseT>
137-
static void collectCommandInjectionFromCallBases(
138-
const llvm::Function& function,
139-
const std::vector<const CallBaseT*>& callBases,
140-
std::vector<CommandInjectionIssue>& issues)
137+
static void
138+
collectCommandInjectionFromCallBases(const llvm::Function& function,
139+
const std::vector<const CallBaseT*>& callBases,
140+
std::vector<CommandInjectionIssue>& issues)
141141
{
142142
for (const CallBaseT* call : callBases)
143143
{

src/analysis/InputPipeline.cpp

Lines changed: 51 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -837,9 +837,8 @@ namespace ctrace::stack::analysis
837837
bool compileArgsReady = false;
838838
{
839839
const ScopedHotspot hotspot(config.timing, "input.build_compile_args");
840-
compileArgsReady =
841-
buildCompileArgs(filename, result.language, config, args, workingDir,
842-
compileError);
840+
compileArgsReady = buildCompileArgs(filename, result.language, config, args,
841+
workingDir, compileError);
843842
}
844843
if (!compileArgsReady)
845844
{
@@ -857,19 +856,17 @@ namespace ctrace::stack::analysis
857856
std::filesystem::path tempDir = std::filesystem::temp_directory_path(tempDirErr);
858857
if (tempDirErr)
859858
tempDir = std::filesystem::path(".");
860-
const std::string tempBitcodeName = "coretrace-compile-ir-" +
861-
md5Hex(filename + "|" +
862-
std::to_string(compileStart.time_since_epoch()
863-
.count())) +
864-
".bc";
859+
const std::string tempBitcodeName =
860+
"coretrace-compile-ir-" +
861+
md5Hex(filename + "|" + std::to_string(compileStart.time_since_epoch().count())) +
862+
".bc";
865863
const std::filesystem::path tempBitcodePath = tempDir / tempBitcodeName;
866864
const ScopedFileCleanup tempBitcodeCleanup(tempBitcodePath);
867865
const std::vector<std::string> bitcodeArgs =
868866
buildBitcodeCompileArgs(args, tempBitcodePath);
869867

870868
auto compileWithOptionalWorkingDir =
871-
[&](const std::vector<std::string>& compileArgs,
872-
compilerlib::OutputMode outputMode,
869+
[&](const std::vector<std::string>& compileArgs, compilerlib::OutputMode outputMode,
873870
bool useWorkingDir) -> std::optional<compilerlib::CompileResult>
874871
{
875872
if (!useWorkingDir)
@@ -890,8 +887,7 @@ namespace ctrace::stack::analysis
890887
};
891888

892889
auto compileWithConfiguredWorkingDir =
893-
[&](const std::vector<std::string>& compileArgs,
894-
compilerlib::OutputMode outputMode,
890+
[&](const std::vector<std::string>& compileArgs, compilerlib::OutputMode outputMode,
895891
bool& retriedWithWorkingDir) -> std::optional<compilerlib::CompileResult>
896892
{
897893
retriedWithWorkingDir = false;
@@ -945,8 +941,8 @@ namespace ctrace::stack::analysis
945941
"cached_ir_bc");
946942
auto bitcodeModule = [&]()
947943
{
948-
const ScopedHotspot hotspot(
949-
config.timing, "input.cache.parse_bitcode_payload");
944+
const ScopedHotspot hotspot(config.timing,
945+
"input.cache.parse_bitcode_payload");
950946
return llvm::parseBitcodeFile(bcBuffer->getMemBufferRef(), ctx);
951947
}();
952948
if (bitcodeModule)
@@ -980,17 +976,16 @@ namespace ctrace::stack::analysis
980976
auto buffer = llvm::MemoryBuffer::getMemBuffer(cached->llvmIR, "cached_ir");
981977
llvm::SMDiagnostic diag;
982978
{
983-
const ScopedHotspot hotspot(
984-
config.timing, "input.cache.parse_text_payload");
979+
const ScopedHotspot hotspot(config.timing,
980+
"input.cache.parse_text_payload");
985981
result.module = llvm::parseIR(buffer->getMemBufferRef(), diag, ctx);
986982
}
987983
if (config.timing)
988984
{
989985
const auto parseEnd = Clock::now();
990-
const auto ms =
991-
std::chrono::duration_cast<std::chrono::milliseconds>(
992-
parseEnd - parseStart)
993-
.count();
986+
const auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
987+
parseEnd - parseStart)
988+
.count();
994989
coretrace::log(coretrace::Level::Info, "IR parse done in {} ms\n", ms);
995990
}
996991
};
@@ -1049,15 +1044,16 @@ namespace ctrace::stack::analysis
10491044
{
10501045
std::error_code removeErr;
10511046
std::filesystem::remove(cachePaths.depFile, removeErr);
1052-
std::vector<std::string> cacheCompileArgs = preferBitcodeCompile ? bitcodeArgs : args;
1047+
std::vector<std::string> cacheCompileArgs =
1048+
preferBitcodeCompile ? bitcodeArgs : args;
10531049
appendDependencyCaptureArgs(cacheCompileArgs, cachePaths.depFile);
10541050

10551051
bool retriedForDependencyCompile = false;
1056-
res = compileWithConfiguredWorkingDir(
1057-
cacheCompileArgs,
1058-
preferBitcodeCompile ? compilerlib::OutputMode::ToFile
1059-
: compilerlib::OutputMode::ToMemory,
1060-
retriedForDependencyCompile);
1052+
res = compileWithConfiguredWorkingDir(cacheCompileArgs,
1053+
preferBitcodeCompile
1054+
? compilerlib::OutputMode::ToFile
1055+
: compilerlib::OutputMode::ToMemory,
1056+
retriedForDependencyCompile);
10611057
retriedWithWorkingDir = retriedForDependencyCompile;
10621058

10631059
if (preferBitcodeCompile && (!res || !res->success))
@@ -1095,11 +1091,11 @@ namespace ctrace::stack::analysis
10951091
}
10961092
else
10971093
{
1098-
res = compileWithConfiguredWorkingDir(
1099-
preferBitcodeCompile ? bitcodeArgs : args,
1100-
preferBitcodeCompile ? compilerlib::OutputMode::ToFile
1101-
: compilerlib::OutputMode::ToMemory,
1102-
retriedWithWorkingDir);
1094+
res = compileWithConfiguredWorkingDir(preferBitcodeCompile ? bitcodeArgs : args,
1095+
preferBitcodeCompile
1096+
? compilerlib::OutputMode::ToFile
1097+
: compilerlib::OutputMode::ToMemory,
1098+
retriedWithWorkingDir);
11031099
if (res && res->success)
11041100
{
11051101
compiledViaBitcode = preferBitcodeCompile;
@@ -1143,7 +1139,8 @@ namespace ctrace::stack::analysis
11431139
std::string llvmBitcodeForCache;
11441140
if (compiledViaBitcode)
11451141
{
1146-
if (readTextFile(tempBitcodePath, llvmBitcodeForCache) && !llvmBitcodeForCache.empty())
1142+
if (readTextFile(tempBitcodePath, llvmBitcodeForCache) &&
1143+
!llvmBitcodeForCache.empty())
11471144
{
11481145
const auto parseStart = Clock::now();
11491146
auto bcBuffer = llvm::MemoryBuffer::getMemBufferCopy(
@@ -1161,12 +1158,11 @@ namespace ctrace::stack::analysis
11611158
if (config.timing)
11621159
{
11631160
const auto parseEnd = Clock::now();
1164-
const auto ms =
1165-
std::chrono::duration_cast<std::chrono::milliseconds>(
1166-
parseEnd - parseStart)
1167-
.count();
1168-
coretrace::log(coretrace::Level::Info,
1169-
"Bitcode parse done in {} ms\n", ms);
1161+
const auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
1162+
parseEnd - parseStart)
1163+
.count();
1164+
coretrace::log(coretrace::Level::Info, "Bitcode parse done in {} ms\n",
1165+
ms);
11701166
}
11711167
}
11721168
else if (config.timing)
@@ -1255,13 +1251,12 @@ namespace ctrace::stack::analysis
12551251
bitcodeStream.flush();
12561252
}
12571253

1258-
const bool stored =
1259-
[&]()
1254+
const bool stored = [&]()
12601255
{
12611256
const ScopedHotspot hotspot(config.timing, "input.cache.store_compile");
1262-
return storeCompileIRCachePayload(
1263-
cachePaths, *sourceSnapshot, *dependencySnapshots, compileDiagnosticsText,
1264-
llvmIRForCache, llvmBitcodeForCache);
1257+
return storeCompileIRCachePayload(cachePaths, *sourceSnapshot,
1258+
*dependencySnapshots, compileDiagnosticsText,
1259+
llvmIRForCache, llvmBitcodeForCache);
12651260
}();
12661261
if (config.timing && stored)
12671262
{
@@ -1325,12 +1320,11 @@ namespace ctrace::stack::analysis
13251320
if (config.timing)
13261321
{
13271322
const auto cacheParseEnd = Clock::now();
1328-
const auto ms =
1329-
std::chrono::duration_cast<std::chrono::milliseconds>(
1330-
cacheParseEnd - cacheParseStart)
1331-
.count();
1332-
coretrace::log(coretrace::Level::Info,
1333-
"Bitcode parse done in {} ms\n", ms);
1323+
const auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
1324+
cacheParseEnd - cacheParseStart)
1325+
.count();
1326+
coretrace::log(coretrace::Level::Info, "Bitcode parse done in {} ms\n",
1327+
ms);
13341328
}
13351329
}
13361330
else if (config.timing)
@@ -1345,7 +1339,8 @@ namespace ctrace::stack::analysis
13451339

13461340
if (!result.module && !cached->llvmIR.empty())
13471341
{
1348-
auto buffer = llvm::MemoryBuffer::getMemBuffer(cached->llvmIR, "cached_input_ir");
1342+
auto buffer =
1343+
llvm::MemoryBuffer::getMemBuffer(cached->llvmIR, "cached_input_ir");
13491344
llvm::SMDiagnostic diag;
13501345
{
13511346
const ScopedHotspot hotspot(config.timing,
@@ -1367,8 +1362,8 @@ namespace ctrace::stack::analysis
13671362
bool dumpOk = false;
13681363
{
13691364
const ScopedHotspot hotspot(config.timing, "input.dump_module_ir");
1370-
dumpOk = dumpModuleIR(*result.module, filename, config, baseDir,
1371-
result.error);
1365+
dumpOk =
1366+
dumpModuleIR(*result.module, filename, config, baseDir, result.error);
13721367
}
13731368
if (!dumpOk)
13741369
return result;
@@ -1399,8 +1394,9 @@ namespace ctrace::stack::analysis
13991394
if (config.timing)
14001395
{
14011396
const auto parseEnd = Clock::now();
1402-
const auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(parseEnd - parseStart)
1403-
.count();
1397+
const auto ms =
1398+
std::chrono::duration_cast<std::chrono::milliseconds>(parseEnd - parseStart)
1399+
.count();
14041400
coretrace::log(coretrace::Level::Info, "IR parse done in {} ms\n", ms);
14051401
}
14061402
if (result.module)
@@ -1419,8 +1415,7 @@ namespace ctrace::stack::analysis
14191415

14201416
std::vector<FileSnapshot> dependencySnapshots;
14211417
dependencySnapshots.push_back(*sourceSnapshot);
1422-
const bool stored =
1423-
[&]()
1418+
const bool stored = [&]()
14241419
{
14251420
const ScopedHotspot hotspot(config.timing, "input.cache.store_ir_parse");
14261421
return storeCompileIRCachePayload(cachePaths, *sourceSnapshot,

src/analysis/MemIntrinsicOverflow.cpp

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,12 @@ namespace ctrace::stack::analysis
283283
namespace
284284
{
285285
template <typename CallBaseT>
286-
static void analyzeMemIntrinsicFromCallBases(
287-
const llvm::Function& function,
288-
const llvm::DataLayout& DL,
289-
const std::vector<const CallBaseT*>& callBases,
290-
const BufferWriteModel* externalModel,
291-
BufferWriteRuleMatcher* ruleMatcher,
292-
std::vector<MemIntrinsicIssue>& out)
286+
static void analyzeMemIntrinsicFromCallBases(const llvm::Function& function,
287+
const llvm::DataLayout& DL,
288+
const std::vector<const CallBaseT*>& callBases,
289+
const BufferWriteModel* externalModel,
290+
BufferWriteRuleMatcher* ruleMatcher,
291+
std::vector<MemIntrinsicIssue>& out)
293292
{
294293
using namespace llvm;
295294

@@ -300,8 +299,7 @@ namespace ctrace::stack::analysis
300299
auto* CB = const_cast<CallBaseT*>(constCB);
301300

302301
ResolvedSink sink = resolveBuiltInSink(CB);
303-
const ResolvedSink modeledSink =
304-
resolveModelSink(CB, externalModel, ruleMatcher);
302+
const ResolvedSink modeledSink = resolveModelSink(CB, externalModel, ruleMatcher);
305303
if (modeledSink.valid)
306304
sink = modeledSink;
307305

@@ -323,8 +321,7 @@ namespace ctrace::stack::analysis
323321

324322
MemIntrinsicIssue issue;
325323
issue.funcName = function.getName().str();
326-
issue.varName = AI->hasName() ? AI->getName().str()
327-
: std::string("<unnamed>");
324+
issue.varName = AI->hasName() ? AI->getName().str() : std::string("<unnamed>");
328325
issue.destSizeBytes = destBytes;
329326
issue.inst = constCB;
330327
issue.intrinsicName = sink.displayName;
@@ -355,18 +352,15 @@ namespace ctrace::stack::analysis
355352
} // namespace
356353

357354
std::vector<MemIntrinsicIssue>
358-
analyzeMemIntrinsicOverflowsCached(const llvm::Function& function,
359-
const llvm::DataLayout& DL,
355+
analyzeMemIntrinsicOverflowsCached(const llvm::Function& function, const llvm::DataLayout& DL,
360356
const std::vector<const llvm::CallInst*>& calls,
361357
const std::vector<const llvm::InvokeInst*>& invokes,
362358
const BufferWriteModel* externalModel,
363359
BufferWriteRuleMatcher* ruleMatcher)
364360
{
365361
std::vector<MemIntrinsicIssue> issues;
366-
analyzeMemIntrinsicFromCallBases(function, DL, calls,
367-
externalModel, ruleMatcher, issues);
368-
analyzeMemIntrinsicFromCallBases(function, DL, invokes,
369-
externalModel, ruleMatcher, issues);
362+
analyzeMemIntrinsicFromCallBases(function, DL, calls, externalModel, ruleMatcher, issues);
363+
analyzeMemIntrinsicFromCallBases(function, DL, invokes, externalModel, ruleMatcher, issues);
370364
return issues;
371365
}
372366
} // namespace ctrace::stack::analysis

src/analysis/ResourceLifetimeAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2379,7 +2379,7 @@ namespace ctrace::stack::analysis
23792379
}
23802380

23812381
static bool resourceSummaryFunctionEquals(const ResourceSummaryFunction& lhs,
2382-
const ResourceSummaryFunction& rhs)
2382+
const ResourceSummaryFunction& rhs)
23832383
{
23842384
std::vector<std::string> leftKeys;
23852385
std::vector<std::string> rightKeys;

src/analysis/TOCTOUAnalysis.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,9 @@ namespace ctrace::stack::analysis
267267
namespace
268268
{
269269
template <typename CallBaseT>
270-
static void collectTOCTOUEventsFromCallBases(
271-
const std::vector<const CallBaseT*>& callBases,
272-
std::vector<PathEvent>& checks,
273-
std::vector<PathEvent>& uses,
274-
unsigned& order)
270+
static void collectTOCTOUEventsFromCallBases(const std::vector<const CallBaseT*>& callBases,
271+
std::vector<PathEvent>& checks,
272+
std::vector<PathEvent>& uses, unsigned& order)
275273
{
276274
for (const CallBaseT* call : callBases)
277275
{

0 commit comments

Comments
 (0)