From df53da872501188319e3914d48eccdd1aa83ed11 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Fri, 28 Oct 2011 23:57:43 +0000 Subject: [PCH] In ASTWriter::associateDeclWithFile don't bother finding the file loc if we are not interested in the decl. llvm-svn: 143255 --- clang/lib/Serialization/ASTWriter.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'clang/lib/Serialization/ASTWriter.cpp') diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 749c27b1aa1..0c9f0a1247c 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -3486,17 +3486,20 @@ static inline bool compLocDecl(std::pair 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()) -- cgit v1.2.3