[clang] 19c5057 - Fix "pointer is null" static analyzer warnings. NFCI.
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 16 05:03:52 PST 2020
Author: Simon Pilgrim
Date: 2020-01-16T13:02:40Z
New Revision: 19c5057e8df62e75b26e881dfc8f8f32686fe75c
URL: https://github.com/llvm/llvm-project/commit/19c5057e8df62e75b26e881dfc8f8f32686fe75c
DIFF: https://github.com/llvm/llvm-project/commit/19c5057e8df62e75b26e881dfc8f8f32686fe75c.diff
LOG: Fix "pointer is null" static analyzer warnings. NFCI.
Use castAs<> instead of getAs<> since the pointer is dereferenced immediately in all cases and castAs will perform the null assertion for us.
Added:
Modified:
clang/lib/CodeGen/CodeGenModule.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 038078bbe88d..feb8d000eca3 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1357,7 +1357,7 @@ void CodeGenModule::GenOpenCLArgMetadata(llvm::Function *Fn,
std::string typeName;
if (isPipe)
typeName = ty.getCanonicalType()
- ->getAs<PipeType>()
+ ->castAs<PipeType>()
->getElementType()
.getAsString(Policy);
else
@@ -1371,7 +1371,7 @@ void CodeGenModule::GenOpenCLArgMetadata(llvm::Function *Fn,
std::string baseTypeName;
if (isPipe)
baseTypeName = ty.getCanonicalType()
- ->getAs<PipeType>()
+ ->castAs<PipeType>()
->getElementType()
.getCanonicalType()
.getAsString(Policy);
More information about the cfe-commits
mailing list