r243974 - [AST] Simplify code by letting ArrayRef do the copying.

Benjamin Kramer benny.kra at googlemail.com
Tue Aug 4 05:59:41 PDT 2015


Author: d0k
Date: Tue Aug  4 07:59:41 2015
New Revision: 243974

URL: http://llvm.org/viewvc/llvm-project?rev=243974&view=rev
Log:
[AST] Simplify code by letting ArrayRef do the copying.

No functionality change intended.

Modified:
    cfe/trunk/lib/AST/Type.cpp

Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=243974&r1=243973&r2=243974&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Tue Aug  4 07:59:41 2015
@@ -836,11 +836,8 @@ public:
       }
 
       if (exceptionChanged) {
-        unsigned size = sizeof(QualType) * exceptionTypes.size();
-        void *mem = Ctx.Allocate(size, llvm::alignOf<QualType>());
-        memcpy(mem, exceptionTypes.data(), size);
-        info.ExceptionSpec.Exceptions
-          = llvm::makeArrayRef((QualType *)mem, exceptionTypes.size());
+        info.ExceptionSpec.Exceptions =
+            llvm::makeArrayRef(exceptionTypes).copy(Ctx);
       }
     }
 
@@ -1158,11 +1155,8 @@ QualType QualType::substObjCTypeArgs(
         }
 
         if (exceptionChanged) {
-          unsigned size = sizeof(QualType) * exceptionTypes.size();
-          void *mem = ctx.Allocate(size, llvm::alignOf<QualType>());
-          memcpy(mem, exceptionTypes.data(), size);
-          info.ExceptionSpec.Exceptions
-            = llvm::makeArrayRef((QualType *)mem, exceptionTypes.size());
+          info.ExceptionSpec.Exceptions =
+              llvm::makeArrayRef(exceptionTypes).copy(ctx);
         }
       }
 





More information about the cfe-commits mailing list