Fall back to [[clang::no_sanitize("hwaddress")]] for HWASan on Clang < 21.

Clang added the `[[gnu::no_sanitize(...)]]` spelling in Clang 21, while supporting `[[clang::no_sanitize(...)]]` in earlier releases. Without checking `clang::no_sanitize`, Clang 20 and earlier fall back to GNU `__attribute__((no_sanitize("hwaddress")))` for `ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS` under HWASan, which fails to compile when stacked before `[[clang::no_sanitize_memory]]` on a class member function.

Also move `ABSL_ATTRIBUTE_NOINLINE` after `ABSL_ATTRIBUTE_NO_SANITIZE_*` in `stacktrace_aarch64-inl.inc` (matching `stacktrace_x86-inl.inc`) so C++11 `[[...]]` attributes precede GNU `__attribute__((noinline))`.

PiperOrigin-RevId: 1023287149
diff --git a/absl/base/attributes.h b/absl/base/attributes.h
index 32af1dd..b68c52c 100644
--- a/absl/base/attributes.h
+++ b/absl/base/attributes.h
@@ -287,6 +287,9 @@
 // out of bounds or does other scary things with memory.
 // NOTE: GCC supports AddressSanitizer(asan) since 4.8.
 // https://gcc.gnu.org/gcc-4.8/changes.html
+// NOTE: When active on Clang/GCC, this macro expands to a C++11 `[[...]]`
+// attribute and must precede GNU `__attribute__((...))` macros such as
+// `ABSL_ATTRIBUTE_NOINLINE` on declarations.
 #if defined(ABSL_HAVE_ADDRESS_SANITIZER) && \
     ABSL_HAVE_ATTRIBUTE(no_sanitize_address)
 #if ABSL_HAVE_CPP_ATTRIBUTE(gnu::no_sanitize_address)
@@ -305,6 +308,8 @@
 // https://gcc.gnu.org/gcc-11/changes.html
 #if ABSL_HAVE_CPP_ATTRIBUTE(gnu::no_sanitize)
 #define ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS [[gnu::no_sanitize("hwaddress")]]
+#elif ABSL_HAVE_CPP_ATTRIBUTE(clang::no_sanitize)
+#define ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS [[clang::no_sanitize("hwaddress")]]
 #else
 #define ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS \
   __attribute__((no_sanitize("hwaddress")))
diff --git a/absl/base/attributes_test.cc b/absl/base/attributes_test.cc
index deabd5d..a014a06 100644
--- a/absl/base/attributes_test.cc
+++ b/absl/base/attributes_test.cc
@@ -105,4 +105,41 @@
   EXPECT_EQ(NoSanitizeCfiCall([](int x) { return x + 1; }, 41), 42);
 }
 
+// Verifies compile-time appertainment when C++11 `[[...]]` sanitizer/cold
+// attributes are stacked together and before GNU `__attribute__((noinline))` on
+// class member functions and member function templates.
+class StackedNoSanitizeTarget {
+ public:
+  ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS ABSL_ATTRIBUTE_NO_SANITIZE_MEMORY int
+  AddressAndMemory(int value) const {
+    return value + 1;
+  }
+
+#if !defined(_MSC_VER) || defined(__clang__)
+  // On native MSVC under ASan, ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS expands to
+  // __declspec(no_sanitize_address) while ABSL_ATTRIBUTE_NOINLINE expands to
+  // [[msvc::noinline]], which cannot follow __declspec.
+  ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS ABSL_ATTRIBUTE_NOINLINE int
+  AddressAndNoInline(int value) const {
+    return value + 2;
+  }
+
+  template <typename T>
+  ABSL_ATTRIBUTE_COLD ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS ABSL_ATTRIBUTE_NOINLINE
+      T
+      ColdAddressAndNoInline(T value) const {
+    return value + 3;
+  }
+#endif
+};
+
+TEST(Attributes, StackedNoSanitizeMemberFunctions) {
+  StackedNoSanitizeTarget target;
+  EXPECT_EQ(target.AddressAndMemory(10), 11);
+#if !defined(_MSC_VER) || defined(__clang__)
+  EXPECT_EQ(target.AddressAndNoInline(20), 22);
+  EXPECT_EQ(target.ColdAddressAndNoInline(30), 33);
+#endif
+}
+
 }  // namespace
diff --git a/absl/debugging/internal/stacktrace_aarch64-inl.inc b/absl/debugging/internal/stacktrace_aarch64-inl.inc
index 79d6858..b5bf60e 100644
--- a/absl/debugging/internal/stacktrace_aarch64-inl.inc
+++ b/absl/debugging/internal/stacktrace_aarch64-inl.inc
@@ -193,12 +193,12 @@
 }
 
 template <bool IS_STACK_FRAMES, bool IS_WITH_CONTEXT>
-// We count on the bottom frame being this one. See the comment
-// at prev_return_address
-ABSL_ATTRIBUTE_NOINLINE
 ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS  // May read random elements from stack.
 ABSL_ATTRIBUTE_NO_SANITIZE_MEMORY   // May read random elements from stack.
 ABSL_ATTRIBUTE_NO_SANITIZE_THREAD   // May read random elements from stack.
+// We count on the bottom frame being this one. See the comment
+// at prev_return_address
+ABSL_ATTRIBUTE_NOINLINE
 static int UnwindImpl(void **result, uintptr_t *frames, int *sizes,
                       int max_depth, int skip_count, const void *ucp,
                       int *min_dropped_frames) {