]> granicus.if.org Git - clang/commitdiff
Read/write some source location for PCH.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 5 Jul 2010 10:37:55 +0000 (10:37 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 5 Jul 2010 10:37:55 +0000 (10:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107616 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Decl.h
lib/AST/Decl.cpp
lib/Frontend/PCHReaderDecl.cpp
lib/Frontend/PCHWriterDecl.cpp

index b31f0385c3ca4802878b365e8189be132da600af..413044bcacf7deeb7046a06d272fcaf643ad5326 100644 (file)
@@ -1508,11 +1508,15 @@ public:
   /// \param TSK the kind of template specialization this is.
   ///
   /// \param TemplateArgsAsWritten location info of template arguments.
+  ///
+  /// \param PointOfInstantiation point at which the function template
+  /// specialization was first instantiated. 
   void setFunctionTemplateSpecialization(FunctionTemplateDecl *Template,
                                       const TemplateArgumentList *TemplateArgs,
                                          void *InsertPos,
                     TemplateSpecializationKind TSK = TSK_ImplicitInstantiation,
-                    const TemplateArgumentListInfo *TemplateArgsAsWritten = 0);
+                    const TemplateArgumentListInfo *TemplateArgsAsWritten = 0,
+                    SourceLocation PointOfInstantiation = SourceLocation());
 
   /// \brief Specify that this function declaration is actually a function
   /// template specialization.
@@ -1537,6 +1541,9 @@ public:
   /// \param LAngleLoc location of left angle token.
   ///
   /// \param RAngleLoc location of right angle token.
+  ///
+  /// \param PointOfInstantiation point at which the function template
+  /// specialization was first instantiated. 
   void setFunctionTemplateSpecialization(FunctionTemplateDecl *Template,
                                          unsigned NumTemplateArgs,
                                          const TemplateArgument *TemplateArgs,
@@ -1544,7 +1551,8 @@ public:
                                          unsigned NumTemplateArgsAsWritten,
                                      TemplateArgumentLoc *TemplateArgsAsWritten,
                                           SourceLocation LAngleLoc,
-                                          SourceLocation RAngleLoc);
+                                          SourceLocation RAngleLoc,
+                                          SourceLocation PointOfInstantiation);
 
   /// \brief Specifies that this function declaration is actually a
   /// dependent function template specialization.
index c3c30f94466a250059a299a759839b2fb36b872c..6fa6745870896b9ff48a8dd48250f5c39fdd83b5 100644 (file)
@@ -1352,7 +1352,8 @@ FunctionDecl::setFunctionTemplateSpecialization(FunctionTemplateDecl *Template,
                                      const TemplateArgumentList *TemplateArgs,
                                                 void *InsertPos,
                                                 TemplateSpecializationKind TSK,
-                        const TemplateArgumentListInfo *TemplateArgsAsWritten) {
+                        const TemplateArgumentListInfo *TemplateArgsAsWritten,
+                                          SourceLocation PointOfInstantiation) {
   assert(TSK != TSK_Undeclared && 
          "Must specify the type of function template specialization");
   FunctionTemplateSpecializationInfo *Info
@@ -1365,6 +1366,7 @@ FunctionDecl::setFunctionTemplateSpecialization(FunctionTemplateDecl *Template,
   Info->Template.setInt(TSK - 1);
   Info->TemplateArguments = TemplateArgs;
   Info->TemplateArgumentsAsWritten = TemplateArgsAsWritten;
+  Info->PointOfInstantiation = PointOfInstantiation;
   TemplateOrSpecialization = Info;
 
   // Insert this function template specialization into the set of known
@@ -1391,7 +1393,8 @@ FunctionDecl::setFunctionTemplateSpecialization(FunctionTemplateDecl *Template,
                                               unsigned NumTemplateArgsAsWritten,
                                    TemplateArgumentLoc *TemplateArgsAsWritten,
                                                 SourceLocation LAngleLoc,
-                                                SourceLocation RAngleLoc) {
+                                                SourceLocation RAngleLoc,
+                                          SourceLocation PointOfInstantiation) {
   ASTContext &Ctx = getASTContext();
   TemplateArgumentList *TemplArgs
     = new (Ctx) TemplateArgumentList(Ctx, TemplateArgs, NumTemplateArgs);
@@ -1401,7 +1404,7 @@ FunctionDecl::setFunctionTemplateSpecialization(FunctionTemplateDecl *Template,
     TemplArgsInfo->addArgument(TemplateArgsAsWritten[i]);
 
   setFunctionTemplateSpecialization(Template, TemplArgs, /*InsertPos=*/0, TSK,
-                                    TemplArgsInfo);
+                                    TemplArgsInfo, PointOfInstantiation);
 }
 
 void
index be4f72ec3b7e75e1f9cb0ec7d0840f5c6e784ac3..1a1f23fc49e0aa52b20580ef0df08d7b3d39c374 100644 (file)
@@ -248,12 +248,14 @@ void PCHDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
       LAngleLoc = Reader.ReadSourceLocation(Record, Idx);
       RAngleLoc = Reader.ReadSourceLocation(Record, Idx);
     }
+    
+    SourceLocation POI = Reader.ReadSourceLocation(Record, Idx);
 
     FD->setFunctionTemplateSpecialization(Template, TemplArgs.size(),
                                           TemplArgs.data(), TSK,
                                           TemplArgLocs.size(),
                                           TemplArgLocs.data(),
-                                          LAngleLoc, RAngleLoc);
+                                          LAngleLoc, RAngleLoc, POI);
     break;
   }
   case FunctionDecl::TK_DependentFunctionTemplateSpecialization: {
@@ -268,6 +270,8 @@ void PCHDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
     unsigned NumArgs = Record[Idx++];
     while (NumArgs--)
       TemplArgs.addArgument(Reader.ReadTemplateArgumentLoc(Record, Idx));
+    TemplArgs.setLAngleLoc(Reader.ReadSourceLocation(Record, Idx));
+    TemplArgs.setRAngleLoc(Reader.ReadSourceLocation(Record, Idx));
     
     FD->setDependentTemplateSpecialization(*Reader.getContext(),
                                            TemplDecls, TemplArgs);
index deca4b22ec620124ad8e76b1b33f8a7b34056512..9f7264ede1881b3d028d882b807ea90c4275f97b 100644 (file)
@@ -249,6 +249,8 @@ void PCHDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
       Writer.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->getRAngleLoc(),
                                Record);
     }
+    
+    Writer.AddSourceLocation(FTSInfo->getPointOfInstantiation(), Record);
     break;
   }
   case FunctionDecl::TK_DependentFunctionTemplateSpecialization: {
@@ -264,6 +266,8 @@ void PCHDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
     Record.push_back(DFTSInfo->getNumTemplateArgs());
     for (int i=0, e = DFTSInfo->getNumTemplateArgs(); i != e; ++i)
       Writer.AddTemplateArgumentLoc(DFTSInfo->getTemplateArg(i), Record);
+    Writer.AddSourceLocation(DFTSInfo->getLAngleLoc(), Record);
+    Writer.AddSourceLocation(DFTSInfo->getRAngleLoc(), Record);
     break;
   }
   }