r270553 - [modules] Ask the canonical decl whether the constructor was defaulted.

Vassil Vassilev via cfe-commits cfe-commits at lists.llvm.org
Tue May 24 05:10:40 PDT 2016


Author: vvassilev
Date: Tue May 24 07:10:36 2016
New Revision: 270553

URL: http://llvm.org/viewvc/llvm-project?rev=270553&view=rev
Log:
[modules] Ask the canonical decl whether the constructor was defaulted.

In case of template instantiations query the template instantiation pattern,
which had actually '=default'.

Fixes https://llvm.org/bugs/show_bug.cgi?id=27739

Patch reviewed by Richard Smith.

Added:
    cfe/trunk/test/Modules/Inputs/PR27739/
    cfe/trunk/test/Modules/Inputs/PR27739/DataInputHandler.h
    cfe/trunk/test/Modules/Inputs/PR27739/Types.h
    cfe/trunk/test/Modules/Inputs/PR27739/map
    cfe/trunk/test/Modules/Inputs/PR27739/module.modulemap
    cfe/trunk/test/Modules/pr27739.cpp
Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=270553&r1=270552&r2=270553&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue May 24 07:10:36 2016
@@ -13098,14 +13098,14 @@ void Sema::SetDeclDefaulted(Decl *Dcl, S
     // the record is complete.
     const FunctionDecl *Primary = MD;
     if (const FunctionDecl *Pattern = MD->getTemplateInstantiationPattern())
-      // Find the uninstantiated declaration that actually had the '= default'
-      // on it.
-      Pattern->isDefined(Primary);
+      // Ask the template instantiation pattern that actually had the
+      // '= default' on it.
+      Primary = Pattern;
 
     // If the method was defaulted on its first declaration, we will have
     // already performed the checking in CheckCompletedCXXClass. Such a
     // declaration doesn't trigger an implicit definition.
-    if (Primary == Primary->getCanonicalDecl())
+    if (Primary->getCanonicalDecl()->isDefaulted())
       return;
 
     CheckExplicitlyDefaultedSpecialMember(MD);

Added: cfe/trunk/test/Modules/Inputs/PR27739/DataInputHandler.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR27739/DataInputHandler.h?rev=270553&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/PR27739/DataInputHandler.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR27739/DataInputHandler.h Tue May 24 07:10:36 2016
@@ -0,0 +1,19 @@
+template < typename > struct vector {};
+
+#include <map>
+#include "Types.h"
+
+struct TString {
+   TString (char *);
+};
+
+struct TreeInfo {};
+
+class DataInputHandler {
+   void AddTree ();
+   void SignalTreeInfo () {
+      fInputTrees[(char*)""];
+   }
+   map <TString, vector <TreeInfo> >fInputTrees;
+   map <string, bool> fExplicitTrainTest;
+};

Added: cfe/trunk/test/Modules/Inputs/PR27739/Types.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR27739/Types.h?rev=270553&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/PR27739/Types.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR27739/Types.h Tue May 24 07:10:36 2016
@@ -0,0 +1 @@
+#include <map>

Added: cfe/trunk/test/Modules/Inputs/PR27739/map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR27739/map?rev=270553&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/PR27739/map (added)
+++ cfe/trunk/test/Modules/Inputs/PR27739/map Tue May 24 07:10:36 2016
@@ -0,0 +1,20 @@
+#ifndef _GLIBCXX_MAP
+#define _GLIBCXX_MAP
+struct basic_string {
+  basic_string(char *);
+} typedef string;
+
+template <typename> class D;
+template <typename _Elements> struct D {
+  _Elements _M_;
+  D(D &) = default;
+};
+
+template <typename _Elements> D<_Elements &&> forward_as_tuple(_Elements);
+
+template <typename _Key, typename _Tp> struct map {
+  _Tp operator[](_Key p1) {
+    auto b = &forward_as_tuple(p1);
+  }
+};
+#endif

Added: cfe/trunk/test/Modules/Inputs/PR27739/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR27739/module.modulemap?rev=270553&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/PR27739/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/PR27739/module.modulemap Tue May 24 07:10:36 2016
@@ -0,0 +1,2 @@
+module "DataInputHandler.h" { header "DataInputHandler.h" export * }
+module "Types.h" { header "Types.h" export *}

Added: cfe/trunk/test/Modules/pr27739.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/pr27739.cpp?rev=270553&view=auto
==============================================================================
--- cfe/trunk/test/Modules/pr27739.cpp (added)
+++ cfe/trunk/test/Modules/pr27739.cpp Tue May 24 07:10:36 2016
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++11 -internal-externc-isystem %S/Inputs/PR27739 -verify %s
+// RUN: %clang_cc1 -std=c++11 -fmodules -fmodule-map-file=%S/Inputs/PR27739/module.modulemap -fmodules-cache-path=%t -internal-externc-isystem %S/Inputs/PR27739/ -verify %s
+
+#include "DataInputHandler.h"
+
+void DataInputHandler::AddTree() {
+   fInputTrees[(char*)""];
+   fExplicitTrainTest[(char*)""];
+}
+
+// expected-no-diagnostics




More information about the cfe-commits mailing list