forked from OSchip/llvm-project
[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:
parent
1848afbbe8
commit
df53da8725
|
@ -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;
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue