Parcourir la source

Check for nullptr argument.

Addresses static analysis report in PR15492.

Differential Revision: http://reviews.llvm.org/D20141

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@270086 91177308-0d34-0410-b5e6-96231b3b80d8
Artem Belevich il y a 9 ans
Parent
commit
f17e647af8
1 fichiers modifiés avec 2 ajouts et 2 suppressions
  1. 2 2
      lib/CodeGen/CodeGenModule.cpp

+ 2 - 2
lib/CodeGen/CodeGenModule.cpp

@@ -2082,7 +2082,7 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
 
       // Check that D is not yet in DiagnosedConflictingDefinitions is required
       // to make sure that we issue an error only once.
-      if (lookupRepresentativeDecl(MangledName, OtherGD) &&
+      if (D && lookupRepresentativeDecl(MangledName, OtherGD) &&
           (D->getCanonicalDecl() != OtherGD.getCanonicalDecl().getDecl()) &&
           (OtherD = dyn_cast<VarDecl>(OtherGD.getDecl())) &&
           OtherD->hasInit() &&
@@ -2301,7 +2301,7 @@ CharUnits CodeGenModule::GetTargetTypeStoreSize(llvm::Type *Ty) const {
 
 unsigned CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D,
                                                  unsigned AddrSpace) {
-  if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {
+  if (D && LangOpts.CUDA && LangOpts.CUDAIsDevice) {
     if (D->hasAttr<CUDAConstantAttr>())
       AddrSpace = getContext().getTargetAddressSpace(LangAS::cuda_constant);
     else if (D->hasAttr<CUDASharedAttr>())