[llvm-branch-commits] [clang] [SSAF][UnsafeBufferUsage] Remove UnsafeBufferUsageExtractor.h (PR #191931)

Balázs Benics via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Apr 17 07:22:32 PDT 2026


================
@@ -125,39 +130,36 @@ void UnsafeBufferUsageTUSummaryExtractor::HandleTranslationUnit(
 
       if (DC->isFileContext() || DC->isNamespace())
         Contributors.push_back(D);
-      return false;
+      return true;
     }
   } ContributorFinder;
 
-  ContributorFinder.VisitTranslationUnitDecl(Ctx.getTranslationUnitDecl());
-
-  llvm::Error Errors = llvm::ErrorSuccess();
-  auto addError = [&Errors](llvm::Error Err) {
-    Errors = llvm::joinErrors(std::move(Errors), std::move(Err));
-  };
-
+  ContributorFinder.TraverseAST(Ctx);
   for (auto *CD : ContributorFinder.Contributors) {
-    llvm::Error Error = llvm::ErrorSuccess();
-    auto EntitySummary = extractEntitySummary(CD, Ctx, Error);
+    auto EntitySummary = extractEntitySummary(CD, Ctx);
 
-    if (Error)
-      addError(std::move(Error));
-    if (EntitySummary->empty())
+    if (!EntitySummary)
+      llvm::reportFatalInternalError(EntitySummary.takeError());
+    assert(*EntitySummary);
+    if ((*EntitySummary)->empty())
       continue;
 
     auto ContributorName = getEntityName(CD);
 
-    if (!ContributorName) {
-      addError(makeCreateEntityNameError(CD, Ctx));
-      continue;
-    }
+    if (!ContributorName)
+      llvm::reportFatalInternalError(makeCreateEntityNameError(CD, Ctx));
 
-    auto [EntitySummaryPtr, Success] = SummaryBuilder.addSummary(
-        addEntity(*ContributorName), std::move(EntitySummary));
+    auto [Ignored, InsertionSucceeded] = SummaryBuilder.addSummary(
+        addEntity(*ContributorName), std::move(*EntitySummary));
 
-    if (!Success)
-      addError(makeAddEntitySummaryError(CD, Ctx));
+    assert(InsertionSucceeded && "duplicated contributor extraction");
   }
-  // FIXME: handle errors!
-  llvm::consumeError(std::move(Errors));
 }
+
+// NOLINTNEXTLINE(misc-use-internal-linkage)
+volatile int UnsafeBufferUsageTUSummaryExtractorAnchorSource = 0;
+
+static clang::ssaf::TUSummaryExtractorRegistry::Add<
+    ssaf::UnsafeBufferUsageTUSummaryExtractor>
+    RegisterExtractor(UnsafeBufferUsageEntitySummary::Name,
+                      "The TUSummaryExtractor for unsafe buffer pointers");
----------------
steakhal wrote:

```suggestion
                      "The TUSummaryExtractor for unsafe buffer pointers");

```

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


More information about the llvm-branch-commits mailing list