[PATCH] D19960: [scan-build] fix warnings emitted on Clang CodeGen code base
David Blaikie via cfe-commits
cfe-commits at lists.llvm.org
Thu May 5 10:58:40 PDT 2016
dblaikie added inline comments.
================
Comment at: lib/CodeGen/CGDebugInfo.cpp:1317
@@ -1316,2 +1316,3 @@
}
+ assert(V && "constant must be not NULL at this point");
TemplateParams.push_back(DBuilder.createTemplateValueParameter(
----------------
It looks like this assertion could actually be a different assertion a little higher up.
For 'V' to be non-null, one of the if/else if chain above must fire.
So change the last else if to an else, and the dyn_cast to a cast, and the cast will fail an internal assertion if it's not valid (& the analyzer can easily then see that at least one of the assignments to V happens - whether or not the analyzer assumes that all the initializers of V are non-null, that's a separate issue...)
================
Comment at: lib/CodeGen/CodeGenModule.cpp:2302
@@ -2301,2 +2301,3 @@
unsigned AddrSpace) {
+ assert(D && "variable declaration must be not NULL");
if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {
----------------
Again, a bit confused about whether you're proposing fixing nearly every pointer parameter in Clang and LLVM to assert non-null... I think we'd need a discussion about what that looks like.
http://reviews.llvm.org/D19960
More information about the cfe-commits
mailing list