]> granicus.if.org Git - clang/commitdiff
Fix various bugs in recent commits for C++ PCH.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 28 Jun 2010 09:31:34 +0000 (09:31 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 28 Jun 2010 09:31:34 +0000 (09:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106995 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclTemplate.cpp
lib/Frontend/PCHReader.cpp
lib/Frontend/PCHReaderDecl.cpp
lib/Frontend/PCHWriterDecl.cpp
test/PCH/cxx-templates.h

index ca19d1ff033ecf6a2b298f2f5403d2b1fed970e5..5984eaaac137c74d2b1161ae51b5c7af44520f49 100644 (file)
@@ -393,7 +393,8 @@ TemplateArgumentList::TemplateArgumentList(ASTContext &Context,
 
 TemplateArgumentList::TemplateArgumentList(ASTContext &Context,
                                            const TemplateArgument *Args,
-                                           unsigned NumArgs) {
+                                           unsigned NumArgs)
+  : NumFlatArguments(0), NumStructuredArguments(0) {
   init(Context, Args, NumArgs);
 }
 
index c220e269c23513783c6131e009ac8c02d175dbb2..386462443efade74cd25739f20f93dc924465961 100644 (file)
@@ -3012,8 +3012,11 @@ PCHReader::ReadTemplateArgument(const RecordData &Record, unsigned &Idx) {
     return TemplateArgument(GetType(Record[Idx++]));
   case TemplateArgument::Declaration:
     return TemplateArgument(GetDecl(Record[Idx++]));
-  case TemplateArgument::Integral:
-    return TemplateArgument(ReadAPSInt(Record, Idx), GetType(Record[Idx++]));
+  case TemplateArgument::Integral: {
+    llvm::APSInt Value = ReadAPSInt(Record, Idx);
+    QualType T = GetType(Record[Idx++]);
+    return TemplateArgument(Value, T);
+  }
   case TemplateArgument::Template:
     return TemplateArgument(ReadTemplateName(Record, Idx));
   case TemplateArgument::Expression:
index 028c563a0746ea0c5795e7128a6acc29f85f14ba..d7c5d77eb9ad30dcfb893d9b5f9a7965a742863a 100644 (file)
@@ -216,6 +216,8 @@ void PCHDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
   FD->setLocEnd(SourceLocation::getFromRawEncoding(Record[Idx++]));
 
   switch ((FunctionDecl::TemplatedKind)Record[Idx++]) {
+  default: assert(false && "Unhandled TemplatedKind!");
+    break;
   case FunctionDecl::TK_NonTemplate:
     break;
   case FunctionDecl::TK_FunctionTemplate:
@@ -257,6 +259,7 @@ void PCHDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
                                           NumTemplateArgLocs,
                                   NumTemplateArgLocs ? TemplArgLocs.data() : 0,
                                           LAngleLoc, RAngleLoc);
+    break;
   }
   case FunctionDecl::TK_DependentFunctionTemplateSpecialization: {
     // Templates.
@@ -273,6 +276,7 @@ void PCHDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
     
     FD->setDependentTemplateSpecialization(*Reader.getContext(),
                                            TemplDecls, TemplArgs);
+    break;
   }
   }
   
index 36a1848d2ae0fb7a174616e1294b5a1ff19f85bb..42d506953cb54ae9191b1fa316ac4c8d2f6ed3b5 100644 (file)
@@ -225,6 +225,8 @@ void PCHDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
   
   Record.push_back(D->getTemplatedKind());
   switch (D->getTemplatedKind()) {
+  default: assert(false && "Unhandled TemplatedKind!");
+    break;
   case FunctionDecl::TK_NonTemplate:
     break;
   case FunctionDecl::TK_FunctionTemplate:
index 840850d813ad1e452a7cfe0bfa38ee8911348de5..9446b086968c1da9344885f36e4aa868cc6644f0 100644 (file)
@@ -17,6 +17,7 @@ struct S<int, float> {
 
 template <typename T, int y>
 T templ_f(T x) {
+  int z = templ_f<int, 5>(3);
   return x+y;
 }