/// 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;
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())
}
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