[clang] [clang] "modular_format" attribute for functions using format strings (PR #147431)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 1 11:52:33 PST 2025


================
@@ -6973,6 +6973,27 @@ static void handleVTablePointerAuthentication(Sema &S, Decl *D,
       CustomDiscriminationValue));
 }
 
+static void handleModularFormat(Sema &S, Decl *D, const ParsedAttr &AL) {
+  StringRef ImplName;
+  if (!S.checkStringLiteralArgumentAttr(AL, 1, ImplName))
+    return;
+  SmallVector<StringRef> Aspects;
+  for (unsigned I = 2, E = AL.getNumArgs(); I != E; ++I) {
+    StringRef Aspect;
+    if (!S.checkStringLiteralArgumentAttr(AL, I, Aspect))
+      return;
+    Aspects.push_back(Aspect);
+  }
+
+  // Store aspects sorted and without duplicates.
+  llvm::sort(Aspects);
+  Aspects.erase(llvm::unique(Aspects), Aspects.end());
----------------
erichkeane wrote:

IS there a good reason not to diagnose dupes?

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


More information about the cfe-commits mailing list