[cfe-commits] r106995 - in /cfe/trunk: lib/AST/DeclTemplate.cpp lib/Frontend/PCHReader.cpp lib/Frontend/PCHReaderDecl.cpp lib/Frontend/PCHWriterDecl.cpp test/PCH/cxx-templates.h

Argyrios Kyrtzidis akyrtzi at gmail.com
Mon Jun 28 02:31:35 PDT 2010


Author: akirtzidis
Date: Mon Jun 28 04:31:34 2010
New Revision: 106995

URL: http://llvm.org/viewvc/llvm-project?rev=106995&view=rev
Log:
Fix various bugs in recent commits for C++ PCH.

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

Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=106995&r1=106994&r2=106995&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Mon Jun 28 04:31:34 2010
@@ -393,7 +393,8 @@
 
 TemplateArgumentList::TemplateArgumentList(ASTContext &Context,
                                            const TemplateArgument *Args,
-                                           unsigned NumArgs) {
+                                           unsigned NumArgs)
+  : NumFlatArguments(0), NumStructuredArguments(0) {
   init(Context, Args, NumArgs);
 }
 

Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=106995&r1=106994&r2=106995&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Mon Jun 28 04:31:34 2010
@@ -3012,8 +3012,11 @@
     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:

Modified: cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderDecl.cpp?rev=106995&r1=106994&r2=106995&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderDecl.cpp Mon Jun 28 04:31:34 2010
@@ -216,6 +216,8 @@
   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 @@
                                           NumTemplateArgLocs,
                                   NumTemplateArgLocs ? TemplArgLocs.data() : 0,
                                           LAngleLoc, RAngleLoc);
+    break;
   }
   case FunctionDecl::TK_DependentFunctionTemplateSpecialization: {
     // Templates.
@@ -273,6 +276,7 @@
     
     FD->setDependentTemplateSpecialization(*Reader.getContext(),
                                            TemplDecls, TemplArgs);
+    break;
   }
   }
   

Modified: cfe/trunk/lib/Frontend/PCHWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriterDecl.cpp?rev=106995&r1=106994&r2=106995&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriterDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriterDecl.cpp Mon Jun 28 04:31:34 2010
@@ -225,6 +225,8 @@
   
   Record.push_back(D->getTemplatedKind());
   switch (D->getTemplatedKind()) {
+  default: assert(false && "Unhandled TemplatedKind!");
+    break;
   case FunctionDecl::TK_NonTemplate:
     break;
   case FunctionDecl::TK_FunctionTemplate:

Modified: cfe/trunk/test/PCH/cxx-templates.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx-templates.h?rev=106995&r1=106994&r2=106995&view=diff
==============================================================================
--- cfe/trunk/test/PCH/cxx-templates.h (original)
+++ cfe/trunk/test/PCH/cxx-templates.h Mon Jun 28 04:31:34 2010
@@ -17,6 +17,7 @@
 
 template <typename T, int y>
 T templ_f(T x) {
+  int z = templ_f<int, 5>(3);
   return x+y;
 }
 





More information about the cfe-commits mailing list