Fix "pointer is null" static analyzer warning. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 11 Jan 2020 16:00:17 +0000 (16:00 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 11 Jan 2020 16:02:23 +0000 (16:02 +0000)
Use cast<> instead of dyn_cast<> since we know that the pointer should be valid (and is dereferenced immediately).

clang/lib/CodeGen/CGStmtOpenMP.cpp

index 2590b26..f9406a9 100644 (file)
@@ -5471,7 +5471,7 @@ void CodeGenFunction::EmitSimpleOMPExecutableDirective(
       OMPPrivateScope LoopGlobals(CGF);
       if (const auto *LD = dyn_cast<OMPLoopDirective>(&D)) {
         for (const Expr *E : LD->counters()) {
-          const auto *VD = dyn_cast<VarDecl>(cast<DeclRefExpr>(E)->getDecl());
+          const auto *VD = cast<VarDecl>(cast<DeclRefExpr>(E)->getDecl());
           if (!VD->hasLocalStorage() && !CGF.LocalDeclMap.count(VD)) {
             LValue GlobLVal = CGF.EmitLValue(E);
             LoopGlobals.addPrivate(