Skip to content

Commit 336530b

Browse files
committed
CGOpenMPRuntime::emitDeclareTargetVarDefinition - fix static analyzer null dereference warning. NFCI.
All paths test for or dereference the VD pointer, so just assert that its not null.
1 parent 814c65d commit 336530b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2933,12 +2933,14 @@ bool CGOpenMPRuntime::emitDeclareTargetVarDefinition(const VarDecl *VD,
29332933
HasRequiresUnifiedSharedMemory))
29342934
return CGM.getLangOpts().OpenMPIsDevice;
29352935
VD = VD->getDefinition(CGM.getContext());
2936-
if (VD && !DeclareTargetWithDefinition.insert(CGM.getMangledName(VD)).second)
2936+
assert(VD && "Unknown VarDecl");
2937+
2938+
if (!DeclareTargetWithDefinition.insert(CGM.getMangledName(VD)).second)
29372939
return CGM.getLangOpts().OpenMPIsDevice;
29382940

29392941
QualType ASTTy = VD->getType();
2940-
29412942
SourceLocation Loc = VD->getCanonicalDecl()->getBeginLoc();
2943+
29422944
// Produce the unique prefix to identify the new target regions. We use
29432945
// the source location of the variable declaration which we know to not
29442946
// conflict with any target region.

0 commit comments

Comments
 (0)