summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-10-28 23:57:43 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-10-28 23:57:43 +0000
commitdf53da872501188319e3914d48eccdd1aa83ed11 (patch)
tree83e1ff27b2e4773b2a7391538ff6e2893983978b
parent1848afbbe8b70f54d546e50ea46f84f70cff7e10 (diff)
downloadbcm5719-llvm-df53da872501188319e3914d48eccdd1aa83ed11.tar.gz
bcm5719-llvm-df53da872501188319e3914d48eccdd1aa83ed11.zip
[PCH] In ASTWriter::associateDeclWithFile don't bother finding the file loc
if we are not interested in the decl. llvm-svn: 143255
-rw-r--r--clang/include/clang/Serialization/ASTWriter.h3
-rw-r--r--clang/lib/Serialization/ASTWriter.cpp11
-rw-r--r--clang/lib/Serialization/ASTWriterDecl.cpp6
3 files changed, 10 insertions, 10 deletions
diff --git a/clang/include/clang/Serialization/ASTWriter.h b/clang/include/clang/Serialization/ASTWriter.h
index 52c80d1248e..2c747d8ea84 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -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;
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<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())
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp
index 1b95e927f9b..3e3e28dfbb7 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -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
OpenPOWER on IntegriCloud