]> granicus.if.org Git - clang/commitdiff
[PCH] In ASTWriter::associateDeclWithFile don't bother finding the file loc
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 28 Oct 2011 23:57:43 +0000 (23:57 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 28 Oct 2011 23:57:43 +0000 (23:57 +0000)
if we are not interested in the decl.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143255 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Serialization/ASTWriter.h
lib/Serialization/ASTWriter.cpp
lib/Serialization/ASTWriterDecl.cpp

index 52c80d1248e2450252c9ebb90b77a67b3ed83645..2c747d8ea844aa2a5bc350927c86cc900cb85ffe 100644 (file)
@@ -162,8 +162,7 @@ private:
   /// that it contains.
   FileDeclIDsTy FileDeclIDs;
 
-  void associateDeclWithFile(const Decl *D, serialization::DeclID,
-                             SourceLocation FileLoc);
+  void associateDeclWithFile(const Decl *D, serialization::DeclID);
 
   /// \brief The first ID number we can use for our own types.
   serialization::TypeID FirstTypeID;
index 749c27b1aa10c8cb122047c3089bbf20be16efaa..0c9f0a1247cdacaf86b2a5c1e436e4f81bc0b64b 100644 (file)
@@ -3486,17 +3486,20 @@ static inline bool compLocDecl(std::pair<unsigned, serialization::DeclID> L,
   return L.first < R.first;
 }
 
-void ASTWriter::associateDeclWithFile(const Decl *D, DeclID ID,
-                                      SourceLocation FileLoc) {
+void ASTWriter::associateDeclWithFile(const Decl *D, DeclID ID) {
   assert(ID);
-  assert(FileLoc.isValid());
-  assert(FileLoc.isFileID());
+  assert(D);
+
+  SourceLocation Loc = D->getLocation();
+  if (Loc.isInvalid())
+    return;
 
   // We only keep track of the file-level declarations of each file.
   if (!D->getLexicalDeclContext()->isFileContext())
     return;
 
   SourceManager &SM = Context->getSourceManager();
+  SourceLocation FileLoc = SM.getFileLoc(Loc);
   assert(SM.isLocalSourceLocation(FileLoc));
   FileID FID = SM.getFileID(FileLoc);
   if (FID.isInvalid())
index 1b95e927f9ba992239ab13014e8550198466a802..3e3e28dfbb7d02271de56df53458398e94d21a17 100644 (file)
@@ -1662,10 +1662,8 @@ void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
     }
     
     SourceManager &SM = Context.getSourceManager();
-    if (Loc.isValid() && SM.isLocalSourceLocation(Loc)) {
-      SourceLocation FileLoc = SM.getFileLoc(Loc);
-      associateDeclWithFile(D, ID, FileLoc);
-    }
+    if (Loc.isValid() && SM.isLocalSourceLocation(Loc))
+      associateDeclWithFile(D, ID);
   }
 
   // Build and emit a record for this declaration