[PCH] In ASTWriter::associateDeclWithFile don't bother finding the file loc

if we are not interested in the decl.

llvm-svn: 143255
This commit is contained in:
Argyrios Kyrtzidis 2011-10-28 23:57:43 +00:00
parent 1848afbbe8
commit df53da8725
3 changed files with 10 additions and 10 deletions

View File

@ -162,8 +162,7 @@ private:
/// that it contains. /// that it contains.
FileDeclIDsTy FileDeclIDs; FileDeclIDsTy FileDeclIDs;
void associateDeclWithFile(const Decl *D, serialization::DeclID, void associateDeclWithFile(const Decl *D, serialization::DeclID);
SourceLocation FileLoc);
/// \brief The first ID number we can use for our own types. /// \brief The first ID number we can use for our own types.
serialization::TypeID FirstTypeID; serialization::TypeID FirstTypeID;

View File

@ -3486,17 +3486,20 @@ static inline bool compLocDecl(std::pair<unsigned, serialization::DeclID> L,
return L.first < R.first; return L.first < R.first;
} }
void ASTWriter::associateDeclWithFile(const Decl *D, DeclID ID, void ASTWriter::associateDeclWithFile(const Decl *D, DeclID ID) {
SourceLocation FileLoc) {
assert(ID); assert(ID);
assert(FileLoc.isValid()); assert(D);
assert(FileLoc.isFileID());
SourceLocation Loc = D->getLocation();
if (Loc.isInvalid())
return;
// We only keep track of the file-level declarations of each file. // We only keep track of the file-level declarations of each file.
if (!D->getLexicalDeclContext()->isFileContext()) if (!D->getLexicalDeclContext()->isFileContext())
return; return;
SourceManager &SM = Context->getSourceManager(); SourceManager &SM = Context->getSourceManager();
SourceLocation FileLoc = SM.getFileLoc(Loc);
assert(SM.isLocalSourceLocation(FileLoc)); assert(SM.isLocalSourceLocation(FileLoc));
FileID FID = SM.getFileID(FileLoc); FileID FID = SM.getFileID(FileLoc);
if (FID.isInvalid()) if (FID.isInvalid())

View File

@ -1662,10 +1662,8 @@ void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
} }
SourceManager &SM = Context.getSourceManager(); SourceManager &SM = Context.getSourceManager();
if (Loc.isValid() && SM.isLocalSourceLocation(Loc)) { if (Loc.isValid() && SM.isLocalSourceLocation(Loc))
SourceLocation FileLoc = SM.getFileLoc(Loc); associateDeclWithFile(D, ID);
associateDeclWithFile(D, ID, FileLoc);
}
} }
// Build and emit a record for this declaration // Build and emit a record for this declaration