[llvm-branch-commits] [llvm] ace516f - Change the LLVM_ATTRIBUTE_DEPRECATED macro to use C++14 attribute.

Christian Sigg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Jan 12 03:45:10 PST 2021


Author: Christian Sigg
Date: 2021-01-12T12:41:00+01:00
New Revision: ace516fb33d1f3de85f046e96efc1048b4ee8c08

URL: https://github.com/llvm/llvm-project/commit/ace516fb33d1f3de85f046e96efc1048b4ee8c08
DIFF: https://github.com/llvm/llvm-project/commit/ace516fb33d1f3de85f046e96efc1048b4ee8c08.diff

LOG: Change the LLVM_ATTRIBUTE_DEPRECATED macro to use C++14 attribute.

C++14 attributes are superior because they can be applied to functions with inline definition and the syntax is cleaner.

I intend to convert all uses and then remove the macro.

One issue that might hold back switching uses to C++14  attributes is that
clang-format does not put long attributes on separate lines and formatted code will look like:

```
template <typename T>
[[deprecated("blah blah")]] void
    foooooooooooooooooooooooooooo() {
  ...
}
```

Putting long attributes on a separate line would be prettier.
See https://stackoverflow.com/questions/45740466/clang-format-setting-to-control-c-attributes

AttributeMacros probably won't help because it can't match the custom message.
https://clang.llvm.org/docs/ClangFormatStyleOptions.html

Reviewed By: rriddle, MaskRay

Differential Revision: https://reviews.llvm.org/D94219

Added: 
    

Modified: 
    llvm/include/llvm/Support/Compiler.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
index a9e4f7f8353d..9348ada91325 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -314,19 +314,9 @@
 #endif
 
 // LLVM_ATTRIBUTE_DEPRECATED(decl, "message")
-#if __has_feature(attribute_deprecated_with_message)
-# define LLVM_ATTRIBUTE_DEPRECATED(decl, message) \
-  decl __attribute__((deprecated(message)))
-#elif defined(__GNUC__)
-# define LLVM_ATTRIBUTE_DEPRECATED(decl, message) \
-  decl __attribute__((deprecated))
-#elif defined(_MSC_VER)
-# define LLVM_ATTRIBUTE_DEPRECATED(decl, message) \
-  __declspec(deprecated(message)) decl
-#else
-# define LLVM_ATTRIBUTE_DEPRECATED(decl, message) \
-  decl
-#endif
+// This macro will be removed.
+// Use C++14's attribute instead: [[deprecated("message")]]
+#define LLVM_ATTRIBUTE_DEPRECATED(decl, message) [[deprecated(message)]] decl
 
 /// LLVM_BUILTIN_UNREACHABLE - On compilers which support it, expands
 /// to an expression which states that it is undefined behavior for the


        


More information about the llvm-branch-commits mailing list