[clang] [clang-tools-extra] [llvm] [compiler-rt] [flang] [clang] Add support for new loop attribute [[clang::code_align()]] (PR #70762)

Mike Rice via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 16 11:23:30 PST 2023


================
@@ -359,16 +359,34 @@ static Attr *handleCodeAlignAttr(Sema &S, Stmt *St, const ParsedAttr &A) {
 static void
 CheckForDuplicateCodeAlignAttrs(Sema &S,
                                 const SmallVectorImpl<const Attr *> &Attrs) {
-  const Attr *A = nullptr;
-  for (const auto *I : Attrs) {
-    if (isa<CodeAlignAttr>(I)) {
-      if (A) {
-        S.Diag(I->getLocation(), diag::err_loop_attr_duplication) << A;
-        S.Diag(A->getLocation(), diag::note_previous_attribute);
-      }
-      A = I;
+    const auto *FirstItr =
+      std::find_if(Attrs.begin(), Attrs.end(), [](const Attr *A) {
+         return isa<const CodeAlignAttr>(A);
+      });
+
+    const Attr *FirstItrAttr =
----------------
mikerice1969 wrote:

Don't think we need FirstItrAttr or NextItrAttr. Couldn't you use (*FirstItr) and (*NextItr) for those?

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


More information about the cfe-commits mailing list