Skip to content

Commit 99a64cc

Browse files
committed
AMDGPULibCalls::parseFunctionName - use reference instead of pointer. NFCI.
parseFunctionName allowed a default null pointer, despite it being dereferenced immediately to be used as a reference and that all callers were taking the address of an existing reference. Fixes static analyzer warning about potential dereferenced nulls
1 parent 66e06cc commit 99a64cc

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ class AMDGPULibCalls {
6161
// Replace a normal function with its native version.
6262
bool replaceWithNative(CallInst *CI, const FuncInfo &FInfo);
6363

64-
bool parseFunctionName(const StringRef& FMangledName,
65-
FuncInfo *FInfo=nullptr /*out*/);
64+
bool parseFunctionName(const StringRef &FMangledName, FuncInfo &FInfo);
6665

6766
bool TDOFold(CallInst *CI, const FuncInfo &FInfo);
6867

@@ -466,9 +465,9 @@ FunctionCallee AMDGPULibCalls::getFunction(Module *M, const FuncInfo &fInfo) {
466465
: AMDGPULibFunc::getFunction(M, fInfo);
467466
}
468467

469-
bool AMDGPULibCalls::parseFunctionName(const StringRef& FMangledName,
470-
FuncInfo *FInfo) {
471-
return AMDGPULibFunc::parse(FMangledName, *FInfo);
468+
bool AMDGPULibCalls::parseFunctionName(const StringRef &FMangledName,
469+
FuncInfo &FInfo) {
470+
return AMDGPULibFunc::parse(FMangledName, FInfo);
472471
}
473472

474473
bool AMDGPULibCalls::isUnsafeMath(const CallInst *CI) const {
@@ -529,7 +528,7 @@ bool AMDGPULibCalls::useNative(CallInst *aCI) {
529528
Function *Callee = aCI->getCalledFunction();
530529

531530
FuncInfo FInfo;
532-
if (!parseFunctionName(Callee->getName(), &FInfo) || !FInfo.isMangled() ||
531+
if (!parseFunctionName(Callee->getName(), FInfo) || !FInfo.isMangled() ||
533532
FInfo.getPrefix() != AMDGPULibFunc::NOPFX ||
534533
getArgType(FInfo) == AMDGPULibFunc::F64 || !HasNative(FInfo.getId()) ||
535534
!(AllNative || useNativeFunc(FInfo.getName()))) {
@@ -644,7 +643,7 @@ bool AMDGPULibCalls::fold(CallInst *CI, AliasAnalysis *AA) {
644643
}
645644

646645
FuncInfo FInfo;
647-
if (!parseFunctionName(Callee->getName(), &FInfo))
646+
if (!parseFunctionName(Callee->getName(), FInfo))
648647
return false;
649648

650649
// Further check the number of arguments to see if they match.

0 commit comments

Comments
 (0)