================
@@ -3116,6 +3118,25 @@ static bool shouldRunUnsafeBufferUsageAnalysis(const 
Sema &S,
            !Diags.isIgnored(diag::warn_unsafe_buffer_format_attr_call, Loc)));
 }
 
+// This runs at the end of every function definition, so the answer is cached
+// on the diagnostic state at Loc like getPolicyInEffectAt().
+bool sema::AnalysisBasedWarnings::shouldRunUnsafeBufferUsageAnalysis(
+    SourceLocation Loc) {
+  DiagnosticsEngine &D = S.getDiagnostics();
+  if (D.hasDiagSuppressionMapping() || Loc.isInvalid())
+    return isUnsafeBufferUsageAnalysisEnabledAt(S, Loc);
+
+  const void *StateKey = D.getDiagStateKeyForLoc(Loc);
+  auto &Cache = UnsafeBufferUsageCache[static_cast<unsigned>(
+      D.getDiagStateSystemClassForLoc(Loc))];
+  auto It = Cache.find(StateKey);
+  if (It != Cache.end())
+    return It->second;
+  bool Enabled = isUnsafeBufferUsageAnalysisEnabledAt(S, Loc);
+  Cache[StateKey] = Enabled;
+  return Enabled;
----------------
ilyas-mallah wrote:

Done!

https://github.com/llvm/llvm-project/pull/240433
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to