[clang] [clang][OpenMP][NFC] Remove unnecessary nullptr check (PR #94680)

via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 6 13:40:48 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Mike Rice (mikerice1969)

<details>
<summary>Changes</summary>

Static verifier reports unchecked use of pointer after explicitly checking earlier in the function. It appears the pointer won't be a nullptr, so remove the unneeded check for consistency.

---
Full diff: https://github.com/llvm/llvm-project/pull/94680.diff


1 Files Affected:

- (modified) clang/lib/Sema/SemaOpenMP.cpp (+11-12) 


``````````diff
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 6e6815328e913..5af32cb3589d3 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -6198,18 +6198,17 @@ class TeamsLoopChecker final : public ConstStmtVisitor<TeamsLoopChecker> {
     // unless the assume-no-nested-parallelism flag has been specified.
     // OpenMP API runtime library calls do not inhibit parallel loop
     // translation, regardless of the assume-no-nested-parallelism.
-    if (C) {
-      bool IsOpenMPAPI = false;
-      auto *FD = dyn_cast_or_null<FunctionDecl>(C->getCalleeDecl());
-      if (FD) {
-        std::string Name = FD->getNameInfo().getAsString();
-        IsOpenMPAPI = Name.find("omp_") == 0;
-      }
-      TeamsLoopCanBeParallelFor =
-          IsOpenMPAPI || SemaRef.getLangOpts().OpenMPNoNestedParallelism;
-      if (!TeamsLoopCanBeParallelFor)
-        return;
-    }
+    bool IsOpenMPAPI = false;
+    auto *FD = dyn_cast_or_null<FunctionDecl>(C->getCalleeDecl());
+    if (FD) {
+      std::string Name = FD->getNameInfo().getAsString();
+      IsOpenMPAPI = Name.find("omp_") == 0;
+    }
+    TeamsLoopCanBeParallelFor =
+        IsOpenMPAPI || SemaRef.getLangOpts().OpenMPNoNestedParallelism;
+    if (!TeamsLoopCanBeParallelFor)
+      return;
+
     for (const Stmt *Child : C->children())
       if (Child)
         Visit(Child);

``````````

</details>


https://github.com/llvm/llvm-project/pull/94680


More information about the cfe-commits mailing list