r293523 - [AST] Give TemplateArgumentLoc a constexpr ctor.

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 30 10:32:46 PST 2017


Author: d0k
Date: Mon Jan 30 12:32:46 2017
New Revision: 293523

URL: http://llvm.org/viewvc/llvm-project?rev=293523&view=rev
Log:
[AST] Give TemplateArgumentLoc a constexpr ctor.

This removes the thread-safe static from
clang::TemplateTemplateParmDecl::getDefaultArgument() const::None

Modified:
    cfe/trunk/include/clang/AST/TemplateBase.h
    cfe/trunk/lib/AST/TemplateBase.cpp

Modified: cfe/trunk/include/clang/AST/TemplateBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TemplateBase.h?rev=293523&r1=293522&r2=293523&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/TemplateBase.h (original)
+++ cfe/trunk/include/clang/AST/TemplateBase.h Mon Jan 30 12:32:46 2017
@@ -119,10 +119,7 @@ private:
   
 public:
   /// \brief Construct an empty, invalid template argument.
-  TemplateArgument() {
-    TypeOrValue.Kind = Null;
-    TypeOrValue.V = 0;
-  }
+  constexpr TemplateArgument() : TypeOrValue({Null, 0}) {}
 
   /// \brief Construct a template type argument.
   TemplateArgument(QualType T, bool isNullPtr = false) {
@@ -388,8 +385,8 @@ private:
   };
 
 public:
-  TemplateArgumentLocInfo();
-  
+  constexpr TemplateArgumentLocInfo() : Template({nullptr, nullptr, 0, 0}) {}
+
   TemplateArgumentLocInfo(TypeSourceInfo *TInfo) : Declarator(TInfo) {}
   
   TemplateArgumentLocInfo(Expr *E) : Expression(E) {}
@@ -433,7 +430,7 @@ class TemplateArgumentLoc {
   TemplateArgumentLocInfo LocInfo;
 
 public:
-  TemplateArgumentLoc() {}
+  constexpr TemplateArgumentLoc() {}
 
   TemplateArgumentLoc(const TemplateArgument &Argument,
                       TemplateArgumentLocInfo Opaque)

Modified: cfe/trunk/lib/AST/TemplateBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TemplateBase.cpp?rev=293523&r1=293522&r2=293523&view=diff
==============================================================================
--- cfe/trunk/lib/AST/TemplateBase.cpp (original)
+++ cfe/trunk/lib/AST/TemplateBase.cpp Mon Jan 30 12:32:46 2017
@@ -453,10 +453,6 @@ LLVM_DUMP_METHOD void TemplateArgument::
 // TemplateArgumentLoc Implementation
 //===----------------------------------------------------------------------===//
 
-TemplateArgumentLocInfo::TemplateArgumentLocInfo() {
-  memset((void*)this, 0, sizeof(TemplateArgumentLocInfo));
-}
-
 SourceRange TemplateArgumentLoc::getSourceRange() const {
   switch (Argument.getKind()) {
   case TemplateArgument::Expression:




More information about the cfe-commits mailing list