[PATCH] D139974: [llvm] Change llvm::Any to wrap std::any

Sebastian Neubauer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 14 10:45:54 PST 2022


sebastian-ne updated this revision to Diff 482933.
sebastian-ne added a comment.

I found a different way to fix the problem with msvc.
Marking the TypeId as non-const fixes the problem, at least in godbolt.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139974/new/

https://reviews.llvm.org/D139974

Files:
  llvm/include/llvm/ADT/Any.h


Index: llvm/include/llvm/ADT/Any.h
===================================================================
--- llvm/include/llvm/ADT/Any.h
+++ llvm/include/llvm/ADT/Any.h
@@ -31,9 +31,7 @@
   // identifier for the type `T`. It is explicitly marked with default
   // visibility so that when `-fvisibility=hidden` is used, the loader still
   // merges duplicate definitions across DSO boundaries.
-  template <typename T> struct TypeId {
-    static const char Id;
-  };
+  template <typename T> struct TypeId { static char Id; };
 
   struct StorageBase {
     virtual ~StorageBase() = default;
@@ -117,7 +115,7 @@
   std::unique_ptr<StorageBase> Storage;
 };
 
-template <typename T> const char Any::TypeId<T>::Id = 0;
+template <typename T> char Any::TypeId<T>::Id = 0;
 
 template <typename T> bool any_isa(const Any &Value) {
   if (!Value.Storage)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139974.482933.patch
Type: text/x-patch
Size: 850 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221214/e6b7057d/attachment.bin>


More information about the llvm-commits mailing list