[PATCH] D16923: [AST] Implemented missing VisitAccessSpecDecl function in ASTImporter class.

2016-02-05 Thread Elisavet Sakellari via cfe-commits
esakella created this revision.
esakella added a reviewer: rsmith.
esakella added subscribers: cfe-commits, karies.

+ test.

http://reviews.llvm.org/D16923

Files:
  lib/AST/ASTImporter.cpp
  test/ASTMerge/Inputs/class1.cpp
  test/ASTMerge/Inputs/class2.cpp
  test/ASTMerge/class.cpp

Index: test/ASTMerge/class.cpp
===
--- test/ASTMerge/class.cpp
+++ test/ASTMerge/class.cpp
@@ -3,12 +3,12 @@
 // RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 
2>&1 | FileCheck %s
 // RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 
2>&1 -Wno-odr -Werror
 
-// CHECK: class1.cpp:5:8: warning: type 'B' has incompatible definitions in 
different translation units
-// CHECK: class1.cpp:6:9: note: field 'y' has type 'float' here
-// CHECK: class2.cpp:6:7: note: field 'y' has type 'int' here
+// CHECK: class1.cpp:6:8: warning: type 'B' has incompatible definitions in 
different translation units
+// CHECK: class1.cpp:7:9: note: field 'y' has type 'float' here
+// CHECK: class2.cpp:7:7: note: field 'y' has type 'int' here
 
 // FIXME: we should also complain about mismatched types on the method
 
-// CHECK: class1.cpp:17:6: warning: type 'E' has incompatible definitions in 
different translation units
-// CHECK: class1.cpp:18:3: note: enumerator 'b' with value 1 here
-// CHECK: class2.cpp:11:3: note: enumerator 'a' with value 0 here
+// CHECK: class1.cpp:18:6: warning: type 'E' has incompatible definitions in 
different translation units
+// CHECK: class1.cpp:19:3: note: enumerator 'b' with value 1 here
+// CHECK: class2.cpp:12:3: note: enumerator 'a' with value 0 here
Index: test/ASTMerge/Inputs/class2.cpp
===
--- test/ASTMerge/Inputs/class2.cpp
+++ test/ASTMerge/Inputs/class2.cpp
@@ -1,5 +1,6 @@
 struct A {
-  int x;
+  public:
+int x;
 };
 
 struct B : A {
Index: test/ASTMerge/Inputs/class1.cpp
===
--- test/ASTMerge/Inputs/class1.cpp
+++ test/ASTMerge/Inputs/class1.cpp
@@ -1,5 +1,6 @@
 struct A {
-  int x;
+  public:
+int x;
 };
 
 struct B : A {
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -130,6 +130,7 @@
 bool IsStructuralMatch(ClassTemplateDecl *From, ClassTemplateDecl *To);
 bool IsStructuralMatch(VarTemplateDecl *From, VarTemplateDecl *To);
 Decl *VisitDecl(Decl *D);
+Decl *VisitAccessSpecDecl(AccessSpecDecl *D);
 Decl *VisitTranslationUnitDecl(TranslationUnitDecl *D);
 Decl *VisitNamespaceDecl(NamespaceDecl *D);
 Decl *VisitTypedefNameDecl(TypedefNameDecl *D, bool IsAlias);
@@ -2316,6 +2317,31 @@
   return ToD;
 }
 
+Decl *ASTNodeImporter::VisitAccessSpecDecl(AccessSpecDecl *D) {
+
+  SourceLocation Loc = Importer.Import(D->getLocation());
+  SourceLocation ColonLoc = Importer.Import(D->getColonLoc());
+
+  // Import the context of this declaration.
+  DeclContext *DC = Importer.ImportContext(D->getDeclContext());
+  if (!DC)
+return nullptr;
+
+  AccessSpecDecl *accessSpecDecl
+= AccessSpecDecl::Create(Importer.getToContext(), D->getAccess(),
+ DC, Loc, ColonLoc);
+
+  if (!accessSpecDecl)
+return nullptr;
+
+  // Lexical DeclContext and Semantic DeclContext
+  // is always the same for the accessSpec.
+  accessSpecDecl->setLexicalDeclContext(DC);
+  DC->addDeclInternal(accessSpecDecl);
+
+  return accessSpecDecl;
+}
+
 Decl *ASTNodeImporter::VisitNamespaceDecl(NamespaceDecl *D) {
   // Import the major distinguishing characteristics of this namespace.
   DeclContext *DC, *LexicalDC;


Index: test/ASTMerge/class.cpp
===
--- test/ASTMerge/class.cpp
+++ test/ASTMerge/class.cpp
@@ -3,12 +3,12 @@
 // RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
 // RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 -Wno-odr -Werror
 
-// CHECK: class1.cpp:5:8: warning: type 'B' has incompatible definitions in different translation units
-// CHECK: class1.cpp:6:9: note: field 'y' has type 'float' here
-// CHECK: class2.cpp:6:7: note: field 'y' has type 'int' here
+// CHECK: class1.cpp:6:8: warning: type 'B' has incompatible definitions in different translation units
+// CHECK: class1.cpp:7:9: note: field 'y' has type 'float' here
+// CHECK: class2.cpp:7:7: note: field 'y' has type 'int' here
 
 // FIXME: we should also complain about mismatched types on the method
 
-// CHECK: class1.cpp:17:6: warning: type 'E' has incompatible definitions in different translation units
-// CHECK: class1.cpp:18:3: note: enumerator 'b' with value 1 here
-// CHECK: class2.cpp:11:3: note: enumerator 'a' with value 0 here
+// CHECK: class1.cpp:18:6: warning: type 'E' has incompatible definitions in diff

[PATCH] D17026: Changed ASTImporter DiagnosticsEngine from FromDiag to ToDiag for unsupported ASTNodes Import.

2016-02-09 Thread Elisavet Sakellari via cfe-commits
esakella created this revision.
esakella added reviewers: rsmith, klimek, bkramer.
esakella added subscribers: cfe-commits, karies.

Before this change the errors produced by the ASTImporter when trying to import 
an unsupported ASTNode where produced through the DiagnosticsEngine of the 
FromContext. However when running clang with the -verify option, (like in this 
test), the VerifyDiagnosticConsumer was expecting the DiagnosticsEngine from 
the ToContext. 
This was leading to a test like this one being considered successful despite 
emitting an error because the error was not being "caught". 


http://reviews.llvm.org/D17026

Files:
  lib/AST/ASTImporter.cpp
  test/ASTMerge/Inputs/accessSpecDeclImport1.cpp
  test/ASTMerge/Inputs/accessSpecDeclImport2.cpp
  test/ASTMerge/accessSpecDeclImport.cpp

Index: test/ASTMerge/accessSpecDeclImport.cpp
===
--- /dev/null
+++ test/ASTMerge/accessSpecDeclImport.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/accessSpecDeclImport1.cpp
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/accessSpecDeclImport2.cpp
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only 
-verify %s
+// expected-no-diagnostics
Index: test/ASTMerge/Inputs/accessSpecDeclImport2.cpp
===
--- /dev/null
+++ test/ASTMerge/Inputs/accessSpecDeclImport2.cpp
@@ -0,0 +1,4 @@
+class B {
+ public:
+   int a;
+ };
Index: test/ASTMerge/Inputs/accessSpecDeclImport1.cpp
===
--- /dev/null
+++ test/ASTMerge/Inputs/accessSpecDeclImport1.cpp
@@ -0,0 +1,4 @@
+class B {
+ public:
+   int a;
+ };
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -1473,7 +1473,7 @@
 //
 
 QualType ASTNodeImporter::VisitType(const Type *T) {
-  Importer.FromDiag(SourceLocation(), diag::err_unsupported_ast_node)
+  Importer.ToDiag(SourceLocation(), diag::err_unsupported_ast_node)
 << T->getTypeClassName();
   return QualType();
 }
@@ -2302,7 +2302,7 @@
 }
 
 Decl *ASTNodeImporter::VisitDecl(Decl *D) {
-  Importer.FromDiag(D->getLocation(), diag::err_unsupported_ast_node)
+  Importer.ToDiag(SourceLocation(), diag::err_unsupported_ast_node)
 << D->getDeclKindName();
   return nullptr;
 }


Index: test/ASTMerge/accessSpecDeclImport.cpp
===
--- /dev/null
+++ test/ASTMerge/accessSpecDeclImport.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/accessSpecDeclImport1.cpp
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/accessSpecDeclImport2.cpp
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
Index: test/ASTMerge/Inputs/accessSpecDeclImport2.cpp
===
--- /dev/null
+++ test/ASTMerge/Inputs/accessSpecDeclImport2.cpp
@@ -0,0 +1,4 @@
+class B {
+ public:
+   int a;
+ };
Index: test/ASTMerge/Inputs/accessSpecDeclImport1.cpp
===
--- /dev/null
+++ test/ASTMerge/Inputs/accessSpecDeclImport1.cpp
@@ -0,0 +1,4 @@
+class B {
+ public:
+   int a;
+ };
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -1473,7 +1473,7 @@
 //
 
 QualType ASTNodeImporter::VisitType(const Type *T) {
-  Importer.FromDiag(SourceLocation(), diag::err_unsupported_ast_node)
+  Importer.ToDiag(SourceLocation(), diag::err_unsupported_ast_node)
 << T->getTypeClassName();
   return QualType();
 }
@@ -2302,7 +2302,7 @@
 }
 
 Decl *ASTNodeImporter::VisitDecl(Decl *D) {
-  Importer.FromDiag(D->getLocation(), diag::err_unsupported_ast_node)
+  Importer.ToDiag(SourceLocation(), diag::err_unsupported_ast_node)
 << D->getDeclKindName();
   return nullptr;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17029: [AST] Implemented missing import for the Template type parameter and Injected Class Name in ASTImporter class.

2016-02-09 Thread Elisavet Sakellari via cfe-commits
esakella created this revision.
esakella added reviewers: klimek, bkramer, rsmith.
esakella added subscribers: cfe-commits, karies.
Herald added a subscriber: aemerson.

-Implemented the VisitTemplateTypeParmType and VisitInjectedClassNameType 
functions in the ASTImporter class, and also enabled the import of the 
definition of the template class. 

-Edited the existing tests to check for the import of these ASTNodes.

http://reviews.llvm.org/D17029

Files:
  lib/AST/ASTImporter.cpp
  test/ASTMerge/Inputs/class-template1.cpp
  test/ASTMerge/Inputs/class-template2.cpp

Index: test/ASTMerge/Inputs/class-template2.cpp
===
--- test/ASTMerge/Inputs/class-template2.cpp
+++ test/ASTMerge/Inputs/class-template2.cpp
@@ -33,3 +33,17 @@
 struct X0 {
   float member;
 };
+
+template
+class X7 {
+  V var;
+  void f(T t) { }
+  V g(T t) { return t; }
+};
+
+template
+class X8 {
+  typedef X8 x;
+  X8() { }
+  int var;
+};
Index: test/ASTMerge/Inputs/class-template1.cpp
===
--- test/ASTMerge/Inputs/class-template1.cpp
+++ test/ASTMerge/Inputs/class-template1.cpp
@@ -32,3 +32,17 @@
 struct X0 {
   int member;
 };
+
+template
+class X7 {
+  V var;
+  void f(T t) { }
+  V g(T t) { return t; }
+};
+
+template
+class X8 {
+  typedef X8 x;
+  X8() { }
+  int var;
+};
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -68,10 +68,11 @@
 QualType VisitRecordType(const RecordType *T);
 QualType VisitEnumType(const EnumType *T);
 QualType VisitAttributedType(const AttributedType *T);
-// FIXME: TemplateTypeParmType
+QualType VisitTemplateTypeParmType(const TemplateTypeParmType *T);
 // FIXME: SubstTemplateTypeParmType
 QualType VisitTemplateSpecializationType(const TemplateSpecializationType *T);
 QualType VisitElaboratedType(const ElaboratedType *T);
+QualType VisitInjectedClassNameType(const InjectedClassNameType *T);
 // FIXME: DependentNameType
 // FIXME: DependentTemplateSpecializationType
 QualType VisitObjCInterfaceType(const ObjCInterfaceType *T);
@@ -1797,6 +1798,18 @@
 ToModifiedType, ToEquivalentType);
 }
 
+QualType ASTNodeImporter::VisitTemplateTypeParmType(const TemplateTypeParmType *T) {
+  TemplateTypeParmDecl *ToDecl
+= dyn_cast_or_null(Importer.Import(T->getDecl()));
+  if (!ToDecl)
+return QualType();
+
+  return Importer.getToContext().getTemplateTypeParmType(T->getDepth(),
+ T->getIndex(),
+ T->isParameterPack(),
+ ToDecl);
+}
+
 QualType ASTNodeImporter::VisitTemplateSpecializationType(
const TemplateSpecializationType *T) {
   TemplateName ToTemplate = Importer.Import(T->getTemplateName());
@@ -1838,6 +1851,15 @@
ToQualifier, ToNamedType);
 }
 
+QualType ASTNodeImporter::VisitInjectedClassNameType(const InjectedClassNameType *T) {
+  CXXRecordDecl *ToDecl
+= dyn_cast_or_null(Importer.Import(T->getDecl()));
+  if (!ToDecl)
+return  QualType();
+
+  return Importer.getToContext().getTagDeclType(ToDecl);
+}
+
 QualType ASTNodeImporter::VisitObjCInterfaceType(const ObjCInterfaceType *T) {
   ObjCInterfaceDecl *Class
 = dyn_cast_or_null(Importer.Import(T->getDecl()));
@@ -4279,7 +4301,7 @@
 
   if (DTemplated->isCompleteDefinition() &&
   !D2Templated->isCompleteDefinition()) {
-// FIXME: Import definition!
+ImportDefinition(DTemplated, D2Templated);
   }
   
   return D2;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17075: [AST] Added SubstTemplateTypeParm, DependentNameType, DependentSizedArrayType import functions in the ASTImporter.

2016-02-10 Thread Elisavet Sakellari via cfe-commits
esakella created this revision.
esakella added reviewers: klimek, bkramer, rsmith, spyffe.
esakella added subscribers: karies, cfe-commits.
Herald added subscribers: rengolin, aemerson.

Implemented the 

VisitSubstTemplateTypeParmType
VisitDependentNameType
VisitDependentSizedArrayType 

functions in the ASTImporter class and also added the necessary tests. 

Also made a necessary change in the VisitFunctionDecl function to support the 
dependent name type parameters. 

http://reviews.llvm.org/D17075

Files:
  lib/AST/ASTImporter.cpp
  test/ASTMerge/Inputs/class-template1.cpp
  test/ASTMerge/Inputs/class-template2.cpp

Index: test/ASTMerge/Inputs/class-template2.cpp
===
--- test/ASTMerge/Inputs/class-template2.cpp
+++ test/ASTMerge/Inputs/class-template2.cpp
@@ -33,3 +33,30 @@
 struct X0 {
   float member;
 };
+
+//Substituted template type parameter import test
+template
+struct X7 {
+  T t;
+};
+
+X7 x;
+
+//Dependent name type import test
+struct X9 {
+ struct X10 { };
+};
+
+template
+struct X8 {
+  struct T::X10* t;
+  void f(struct T::X10* v){ }
+};
+
+X8 x8;
+
+//Dependent sized array import test
+template
+struct X11 {
+  T data[S];
+};
Index: test/ASTMerge/Inputs/class-template1.cpp
===
--- test/ASTMerge/Inputs/class-template1.cpp
+++ test/ASTMerge/Inputs/class-template1.cpp
@@ -32,3 +32,30 @@
 struct X0 {
   int member;
 };
+
+//Substituted template type parameter import test
+template
+struct X7 {
+  T t;
+};
+
+extern X7 x;
+
+//Dependent name type import test
+struct X9 {
+ struct X10 { };
+};
+
+template
+struct X8 {
+  struct T::X10* t;
+  void f(struct T::X10* v){ }
+};
+
+extern X8 x8;
+
+//Dependent sized array import test
+template
+struct X11 {
+  T data[S];
+};
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -49,7 +49,7 @@
 QualType VisitConstantArrayType(const ConstantArrayType *T);
 QualType VisitIncompleteArrayType(const IncompleteArrayType *T);
 QualType VisitVariableArrayType(const VariableArrayType *T);
-// FIXME: DependentSizedArrayType
+QualType VisitDependentSizedArrayType(const DependentSizedArrayType *T);
 // FIXME: DependentSizedExtVectorType
 QualType VisitVectorType(const VectorType *T);
 QualType VisitExtVectorType(const ExtVectorType *T);
@@ -69,10 +69,10 @@
 QualType VisitEnumType(const EnumType *T);
 QualType VisitAttributedType(const AttributedType *T);
 // FIXME: TemplateTypeParmType
-// FIXME: SubstTemplateTypeParmType
+QualType VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T);
 QualType VisitTemplateSpecializationType(const TemplateSpecializationType *T);
 QualType VisitElaboratedType(const ElaboratedType *T);
-// FIXME: DependentNameType
+QualType VisitDependentNameType(const DependentNameType *T);
 // FIXME: DependentTemplateSpecializationType
 QualType VisitObjCInterfaceType(const ObjCInterfaceType *T);
 QualType VisitObjCObjectType(const ObjCObjectType *T);
@@ -1613,6 +1613,19 @@
   Brackets);
 }
 
+QualType ASTNodeImporter::VisitDependentSizedArrayType(
+   const DependentSizedArrayType *T) {
+  QualType ToType = Importer.Import(T->getElementType());
+  if (ToType.isNull())
+return QualType();
+
+  return
+Importer.getToContext().getDependentSizedArrayType(ToType, T->getSizeExpr(),
+   T->getSizeModifier(),
+T->getIndexTypeCVRQualifiers(),
+   T->getBracketsRange());
+}
+
 QualType ASTNodeImporter::VisitVectorType(const VectorType *T) {
   QualType ToElementType = Importer.Import(T->getElementType());
   if (ToElementType.isNull())
@@ -1776,6 +1789,18 @@
   return Importer.getToContext().getTagDeclType(ToDecl);
 }
 
+QualType ASTNodeImporter::VisitSubstTemplateTypeParmType(
+  const SubstTemplateTypeParmType *T) {
+
+  QualType ToType =  Importer.Import(T->getReplacementType());
+  if (ToType.isNull())
+return QualType();
+
+  return Importer.getToContext().getSubstTemplateTypeParmType(
+ T->getReplacedParameter(),
+ T->getReplacementType());
+}
+
 QualType ASTNodeImporter::VisitAttributedType(const AttributedType *T) {
   QualType FromModifiedType = T->getModifiedType();
   QualType FromEquivalentType = T->getEquivalentType();
@@ -1838,6 +1863,21 @@
ToQualifier, ToNamedType);
 }
 
+QualType ASTNodeImporter::VisitDependentNameType(const DependentNameType *T) {
+  NestedNameSpecifier *T

[PATCH] D17136: [AST] VisitFunctionTemplateDecl implementation in ASTImporter class.

2016-02-11 Thread Elisavet Sakellari via cfe-commits
esakella created this revision.
esakella added reviewers: rsmith, klimek, bkramer, spyffe.
esakella added subscribers: karies, cfe-commits.
Herald added a subscriber: aemerson.

Implemented the VisitFunctionTemplateDecl function for the import of template 
function definitions. 

Note that this function needs the VisitTemplateTypeParmType function to be also 
implemented in order to work,  therefore it is dependent on the Differential 
D17029. It also needs the change in Differential D17026 in the Diagnostics 
Engine of the ASTImporter in order for this test to catch any error emitted. 

http://reviews.llvm.org/D17136

Files:
  lib/AST/ASTImporter.cpp
  test/ASTMerge/Inputs/function-template1.cpp
  test/ASTMerge/Inputs/function-template2.cpp
  test/ASTMerge/function-template.cpp

Index: test/ASTMerge/function-template.cpp
===
--- /dev/null
+++ test/ASTMerge/function-template.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/function-template1.cpp
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/function-template2.cpp
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
Index: test/ASTMerge/Inputs/function-template2.cpp
===
--- /dev/null
+++ test/ASTMerge/Inputs/function-template2.cpp
@@ -0,0 +1,16 @@
+template
+  T funcTempl(T x, T y) {
+return x + y;
+  }
+
+template 
+  T cast(V x) {
+return (T)x;
+  }
+
+class B {
+ template
+  C templFun(C arg) {
+   return arg;
+  }
+};
Index: test/ASTMerge/Inputs/function-template1.cpp
===
--- /dev/null
+++ test/ASTMerge/Inputs/function-template1.cpp
@@ -0,0 +1,16 @@
+template
+  T funcTempl(T x, T y) {
+return x + y;
+  }
+
+template 
+  T cast(V x) {
+return (T)x;
+  }
+
+class B {
+ template
+  C templFun(C arg) {
+   return arg;
+  }
+};
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -169,6 +169,7 @@
 ClassTemplateSpecializationDecl *D);
 Decl *VisitVarTemplateDecl(VarTemplateDecl *D);
 Decl *VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D);
+Decl *VisitFunctionTemplateDecl(FunctionTemplateDecl *D);
 
 // Importing statements
 DeclGroupRef ImportDeclGroup(DeclGroupRef DG);
@@ -4576,6 +4577,93 @@
   return D2;
 }
 
+Decl *ASTNodeImporter::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
+  // Import the major distinguishing characteristics of this function.
+  DeclContext *DC, *LexicalDC;
+  DeclarationName Name;
+  SourceLocation Loc;
+  NamedDecl *ToD;
+  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
+return nullptr;
+
+  DeclarationNameInfo NameInfo(Name, Loc);
+
+  QualType FromTy = D->getTemplatedDecl()->getType();
+
+  // Import the type.
+  QualType T = Importer.Import(FromTy);
+  if (T.isNull())
+return nullptr;
+
+  TypeSourceInfo *TInfo
+= Importer.Import(D->getTemplatedDecl()->getTypeSourceInfo());
+
+  // Import the function parameters.
+  SmallVector Parameters;
+  TypeLoc ToTypeLoc = TInfo->getTypeLoc();
+  unsigned I = 0;
+  for (auto P : D->getTemplatedDecl()->params()) {
+ParmVarDecl *ToP = cast_or_null(Importer.Import(P));
+ToP->setScopeInfo(P->getFunctionScopeDepth(), P->getFunctionScopeIndex());
+if (!ToP)
+  return nullptr;
+
+Parameters.push_back(ToP);
+
+if (FunctionProtoTypeLoc ToProtoLoc
+  = ToTypeLoc.getAs()) {
+  ToProtoLoc.setParam(I, Parameters[I]);
+  I++;
+}
+  }
+
+  FunctionDecl *ToFunction;
+  if (CXXMethodDecl *Method = dyn_cast(D->getTemplatedDecl())) {
+ToFunction = CXXMethodDecl::Create(Importer.getToContext(),
+   cast(DC),
+   D->getTemplatedDecl()->getInnerLocStart(),
+   NameInfo, T, TInfo,
+   Method->getStorageClass(),
+   Method->isInlineSpecified(),
+   D->getTemplatedDecl()->isConstexpr(),
+   Importer.Import(D->getLocEnd()));
+  } else {
+ToFunction = FunctionDecl::Create(Importer.getToContext(), DC,
+  D->getTemplatedDecl()->getInnerLocStart(),
+  NameInfo, T, TInfo,
+  D->getTemplatedDecl()->getStorageClass(),
+  D->getTemplatedDecl()->isInlineSpecified(),
+  D->getTemplatedDecl()->hasWrittenPrototype(),
+  D->getTemplatedDecl()->isConstexpr());
+  }
+
+  // Import the qualifier, if any.
+  ToFunction

Re: [PATCH] D17029: [AST] Implemented missing import for the Template type parameter and Injected Class Name in ASTImporter class.

2016-02-20 Thread Elisavet Sakellari via cfe-commits
esakella added a comment.

In http://reviews.llvm.org/D17029#356428, @akyrtzi wrote:

> If I apply just the test changes without the rest of the changes, I don't see 
> any failures, so I'm not sure these are effective tests.


This happens because also one of the changes is the new line 4304 which 
triggers the import of the template class definition , which in turn triggers 
the import of the other two elements.

If you only apply this change and the run the tests, then you see the 
respective error messages 'error: cannot import unsupported AST node 
InjectedClassName' and 'error: cannot import unsupported AST node 
TemplateTypeParm'.

I thought it would be better not to split and add this small change by itself, 
so I put them all together.


http://reviews.llvm.org/D17029



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17026: Changed ASTImporter DiagnosticsEngine from FromDiag to ToDiag for unsupported ASTNodes Import.

2016-02-20 Thread Elisavet Sakellari via cfe-commits
esakella added a comment.

In http://reviews.llvm.org/D17026#356418, @akyrtzi wrote:

> Doesn't this mean that _all_ of the Importer.FromDiag() calls will be ignored 
> by VerifyDiagnosticConsumer ? Why specifically change only this two and what 
> are we going to do with the others ?
>  This seems more like needing a fix higher up in the stack, not at the 
> ASTImporter level.


Yes I think also that the right thing would be to change it in all the places, 
but for now we decided to make this change only in these two places which are 
relevant to the other things I implemented, to see first if this change would 
be acceptable.


http://reviews.llvm.org/D17026



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits