tcmalloc: Switch thread-safety annotations to support clang

tcmalloc contains its own copy of thread_annotations.h, wrapper
macros for static thread-safety analysis expressions. These thread-
safety expressions allow asserting (at compile time) that certain
locks are held or excluded or certain data is protected by specific
locks; they are checked at compile-time by recent versions of clang
or an old gcc branch (https://gcc.gnu.org/wiki/ThreadSafetyAnnotation).

Convert the #if-guard and macro names from the no-longer-supported
gcc branch's defines & macros to the versions supported by recent
versions of clang. This will allow us to (re-)enable these checks
in Chromium's fork of tcmalloc.

Also see: https://github.com/gperftools/gperftools/pull/1251

Change-Id: I9217d0f4718ba82697e0d8c8096baa390f98edbe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2702729
Reviewed-by: Primiano Tucci <primiano@chromium.org>
Commit-Queue: Venkatesh Srinivas <venkateshs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#856306}
GitOrigin-RevId: e0dedfa0d88dcf40d69b0f7a2f96a3ac66c209e7
diff --git a/src/base/thread_annotations.h b/src/base/thread_annotations.h
index f57b299..7996280 100644
--- a/src/base/thread_annotations.h
+++ b/src/base/thread_annotations.h
@@ -35,8 +35,8 @@
 // of their multi-threaded code. The annotations can also help program
 // analysis tools to identify potential thread safety issues.
 //
-// The annotations are implemented using GCC's "attributes" extension.
-// Using the macros defined here instead of the raw GCC attributes allows
+// The annotations are implemented using clang's "attributes" extension.
+// Using the macros defined here instead of the raw clang attributes allows
 // for portability and future compatibility.
 //
 // This functionality is not yet fully implemented in perftools,
@@ -46,9 +46,7 @@
 #define BASE_THREAD_ANNOTATIONS_H_
 
 
-#if defined(__GNUC__) \
-  && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
-  && defined(__SUPPORT_TS_ANNOTATION__) && (!defined(SWIG))
+#if defined(__clang__)
 #define THREAD_ANNOTATION_ATTRIBUTE__(x)   __attribute__((x))
 #else
 #define THREAD_ANNOTATION_ATTRIBUTE__(x)   // no-op
@@ -113,19 +111,19 @@
 
 // The following annotations specify lock and unlock primitives.
 #define EXCLUSIVE_LOCK_FUNCTION(x) \
-  THREAD_ANNOTATION_ATTRIBUTE__(exclusive_lock(x))
+  THREAD_ANNOTATION_ATTRIBUTE__(exclusive_lock_function(x))
 
 #define SHARED_LOCK_FUNCTION(x) \
-  THREAD_ANNOTATION_ATTRIBUTE__(shared_lock(x))
+  THREAD_ANNOTATION_ATTRIBUTE__(shared_lock_function(x))
 
 #define EXCLUSIVE_TRYLOCK_FUNCTION(x) \
-  THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock(x))
+  THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock_function(x))
 
 #define SHARED_TRYLOCK_FUNCTION(x) \
-  THREAD_ANNOTATION_ATTRIBUTE__(shared_trylock(x))
+  THREAD_ANNOTATION_ATTRIBUTE__(shared_trylock_function(x))
 
 #define UNLOCK_FUNCTION(x) \
-  THREAD_ANNOTATION_ATTRIBUTE__(unlock(x))
+  THREAD_ANNOTATION_ATTRIBUTE__(unlock_function(x))
 
 // An escape hatch for thread safety analysis to ignore the annotated function.
 #define NO_THREAD_SAFETY_ANALYSIS \