]> granicus.if.org Git - clang/commitdiff
Fix UBSan issue with PPC::isValidCPUName
authorErich Keane <erich.keane@intel.com>
Fri, 9 Feb 2018 00:13:49 +0000 (00:13 +0000)
committerErich Keane <erich.keane@intel.com>
Fri, 9 Feb 2018 00:13:49 +0000 (00:13 +0000)
Apparently storing the pointer to a StringLiteral as
a StringRef caused this section of code to issue a ubsan
warning.  This will hopefully fix that.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324687 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/Targets/PPC.cpp

index 40211dba28ec0f22494863447ebfcee6ef9dd21a..3516a73809892baebba75b8c2cfb51f4920fa88e 100644 (file)
@@ -493,8 +493,7 @@ static constexpr llvm::StringLiteral ValidCPUNames[] = {
 };
 
 bool PPCTargetInfo::isValidCPUName(StringRef Name) const {
-  const StringRef *FoundName = llvm::find(ValidCPUNames, Name);
-  return FoundName != std::end(ValidCPUNames);
+  return llvm::find(ValidCPUNames, Name) != std::end(ValidCPUNames);
 }
 
 void PPCTargetInfo::fillValidCPUList(SmallVectorImpl<StringRef> &Values) const {