[llvm] r373322 - InstrProf - avoid static analyzer dyn_cast<ConstantInt> null dereference warning.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 1 03:38:30 PDT 2019
Author: rksimon
Date: Tue Oct 1 03:38:30 2019
New Revision: 373322
URL: http://llvm.org/viewvc/llvm-project?rev=373322&view=rev
Log:
InstrProf - avoid static analyzer dyn_cast<ConstantInt> null dereference warning.
The static analyzer is warning about a potential null dereference, as we're already earlying-out for a null Constant pointer I've just folded this into a dyn_cast_or_null<ConstantInt>.
No test case, this is by inspection only.
Modified:
llvm/trunk/lib/ProfileData/InstrProf.cpp
Modified: llvm/trunk/lib/ProfileData/InstrProf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProf.cpp?rev=373322&r1=373321&r2=373322&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/InstrProf.cpp (original)
+++ llvm/trunk/lib/ProfileData/InstrProf.cpp Tue Oct 1 03:38:30 2019
@@ -1078,12 +1078,10 @@ bool isIRPGOFlagSet(const Module *M) {
if (!IRInstrVar->hasInitializer())
return false;
- const Constant *InitVal = IRInstrVar->getInitializer();
+ auto *InitVal = dyn_cast_or_null<ConstantInt>(IRInstrVar->getInitializer());
if (!InitVal)
return false;
-
- return (dyn_cast<ConstantInt>(InitVal)->getZExtValue() &
- VARIANT_MASK_IR_PROF) != 0;
+ return (InitVal->getZExtValue() & VARIANT_MASK_IR_PROF) != 0;
}
// Check if we can safely rename this Comdat function.
More information about the llvm-commits
mailing list