r284184 - Use SubstInitializer instead of SubstExpr when instantiating a default

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 13 18:12:20 PDT 2016


Author: rsmith
Date: Thu Oct 13 20:12:20 2016
New Revision: 284184

URL: http://llvm.org/viewvc/llvm-project?rev=284184&view=rev
Log:
Use SubstInitializer instead of SubstExpr when instantiating a default
argument, in order to correctly instantiate the initializer.

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/CodeGenCXX/default-arg-temps.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=284184&r1=284183&r2=284184&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Oct 13 20:12:20 2016
@@ -4559,7 +4559,8 @@ ExprResult Sema::BuildCXXDefaultArgExpr(
       //   default argument expression appears.
       ContextRAII SavedContext(*this, FD);
       LocalInstantiationScope Local(*this);
-      Result = SubstExpr(UninstExpr, MutiLevelArgList);
+      Result = SubstInitializer(UninstExpr, MutiLevelArgList,
+                                /*DirectInit*/false);
     }
     if (Result.isInvalid())
       return ExprError();

Modified: cfe/trunk/test/CodeGenCXX/default-arg-temps.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/default-arg-temps.cpp?rev=284184&r1=284183&r2=284184&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/default-arg-temps.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/default-arg-temps.cpp Thu Oct 13 20:12:20 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
 
 struct T {
   T();
@@ -71,3 +71,10 @@ namespace test1 {
 
   D d;
 }
+
+namespace test2 {
+  // CHECK:  define linkonce_odr void @_ZN5test21AIiED2Ev(
+  template <typename T> struct A { A() {} ~A() {} };
+  template <typename> void f(const A<int> & = {}) {}
+  void g() { f<int>(); }
+}




More information about the cfe-commits mailing list