Skip to content

Commit a70ffa9

Browse files
author
Pavel Samolysov
authored
[sycl-post-link][NFC] Address clang-tidy concerns in the sycl-post-link (#5552)
The patch fixes some issues from clang-tidy related to the code-style and missed auto-stars (auto*) when a local variable is a pointer.
1 parent 8d5a583 commit a70ffa9

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

llvm/tools/sycl-post-link/SpecConstants.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,11 @@ void collectCompositeElementsDefaultValuesRecursive(
369369

370370
// Assume that we encountered some scalar element
371371
size_t NumBytes = M.getDataLayout().getTypeStoreSize(C->getType());
372-
if (auto IntConst = dyn_cast<ConstantInt>(C)) {
372+
if (auto *IntConst = dyn_cast<ConstantInt>(C)) {
373373
auto Val = IntConst->getValue().getZExtValue();
374374
std::copy_n(reinterpret_cast<char *>(&Val), NumBytes,
375375
std::back_inserter(DefaultValues));
376-
} else if (auto FPConst = dyn_cast<ConstantFP>(C)) {
376+
} else if (auto *FPConst = dyn_cast<ConstantFP>(C)) {
377377
auto Val = FPConst->getValue();
378378

379379
if (NumBytes == 2) {
@@ -383,12 +383,12 @@ void collectCompositeElementsDefaultValuesRecursive(
383383
std::copy_n(reinterpret_cast<char *>(&Storage), NumBytes,
384384
std::back_inserter(DefaultValues));
385385
} else if (NumBytes == 4) {
386-
float v = Val.convertToFloat();
387-
std::copy_n(reinterpret_cast<char *>(&v), NumBytes,
386+
float V = Val.convertToFloat();
387+
std::copy_n(reinterpret_cast<char *>(&V), NumBytes,
388388
std::back_inserter(DefaultValues));
389389
} else if (NumBytes == 8) {
390-
double v = Val.convertToDouble();
391-
std::copy_n(reinterpret_cast<char *>(&v), NumBytes,
390+
double V = Val.convertToDouble();
391+
std::copy_n(reinterpret_cast<char *>(&V), NumBytes,
392392
std::back_inserter(DefaultValues));
393393
} else {
394394
llvm_unreachable("Unexpected constant floating point type");

llvm/tools/sycl-post-link/sycl-post-link.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,14 +368,14 @@ void groupEntryPoints(const Module &M, EntryPointGroupMap &EntryPointsGroups,
368368
// This function traverses over reversed call graph by BFS algorithm.
369369
// It means that an edge links some function @func with functions
370370
// which contain call of function @func. It starts from
371-
// @StartingFunction and lifts up until it reach all reachable functions
371+
// @StartingFunction and lifts up until it reach all reachable functions,
372372
// or it reaches some function containing "referenced-indirectly" attribute.
373373
// If it reaches "referenced-indirectly" attribute than it returns an empty
374374
// Optional.
375375
// Otherwise, it returns an Optional containing a list of reached
376376
// SPIR kernel function's names.
377377
Optional<std::vector<StringRef>>
378-
TraverseCGToFindSPIRKernels(const Function *StartingFunction) {
378+
traverseCGToFindSPIRKernels(const Function *StartingFunction) {
379379
std::queue<const Function *> FunctionsToVisit;
380380
std::unordered_set<const Function *> VisitedFunctions;
381381
FunctionsToVisit.push(StartingFunction);
@@ -411,16 +411,16 @@ TraverseCGToFindSPIRKernels(const Function *StartingFunction) {
411411
}
412412
}
413413

414-
return std::move(KernelNames);
414+
return {std::move(KernelNames)};
415415
}
416416

417417
std::vector<StringRef> getKernelNamesUsingAssert(const Module &M) {
418-
auto DevicelibAssertFailFunction = M.getFunction("__devicelib_assert_fail");
418+
auto *DevicelibAssertFailFunction = M.getFunction("__devicelib_assert_fail");
419419
if (!DevicelibAssertFailFunction)
420420
return {};
421421

422422
auto TraverseResult =
423-
TraverseCGToFindSPIRKernels(DevicelibAssertFailFunction);
423+
traverseCGToFindSPIRKernels(DevicelibAssertFailFunction);
424424

425425
if (TraverseResult.hasValue())
426426
return std::move(*TraverseResult);
@@ -438,7 +438,7 @@ std::vector<StringRef> getKernelNamesUsingAssert(const Module &M) {
438438

439439
// Gets reqd_work_group_size information for function Func.
440440
std::vector<uint32_t> getKernelReqdWorkGroupSizeMetadata(const Function &Func) {
441-
auto ReqdWorkGroupSizeMD = Func.getMetadata("reqd_work_group_size");
441+
auto *ReqdWorkGroupSizeMD = Func.getMetadata("reqd_work_group_size");
442442
if (!ReqdWorkGroupSizeMD)
443443
return {};
444444
// TODO: Remove 3-operand assumption when it is relaxed.

0 commit comments

Comments
 (0)