aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Serialization/ASTWriterDecl.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-09-11 02:22:03 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-09-11 02:22:03 +0000
commit3864be7bf0ac8dc6c33d6fe0751f340fc1a38129 (patch)
tree9f6f2dd284aaafc4d413097f138467b4a3c80fd2 /clang/lib/Serialization/ASTWriterDecl.cpp
parent59d72b1c8a5d234420ece078449366af0d2f3391 (diff)
downloadllvm-3864be7bf0ac8dc6c33d6fe0751f340fc1a38129.zip
llvm-3864be7bf0ac8dc6c33d6fe0751f340fc1a38129.tar.gz
llvm-3864be7bf0ac8dc6c33d6fe0751f340fc1a38129.tar.bz2
[modules] Slightly defang an assert that produces false-positives on the selfhost bot.
llvm-svn: 247375
Diffstat (limited to 'clang/lib/Serialization/ASTWriterDecl.cpp')
-rw-r--r--clang/lib/Serialization/ASTWriterDecl.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp
index 1095a4b..6b51a76 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1522,20 +1522,21 @@ void ASTDeclWriter::VisitDeclContext(DeclContext *DC, uint64_t LexicalOffset,
Record.push_back(VisibleOffset);
}
-/// \brief Is this a local declaration (that is, one that will be written to
-/// our AST file)? This is the case for declarations that are neither imported
-/// from another AST file nor predefined.
-static bool isLocalDecl(ASTWriter &W, const Decl *D) {
- if (D->isFromASTFile())
- return false;
- return W.getDeclID(D) >= NUM_PREDEF_DECL_IDS;
-}
-
const Decl *ASTWriter::getFirstLocalDecl(const Decl *D) {
- assert(isLocalDecl(*this, D) && "expected a local declaration");
+ /// \brief Is this a local declaration (that is, one that will be written to
+ /// our AST file)? This is the case for declarations that are neither imported
+ /// from another AST file nor predefined.
+ auto IsLocalDecl = [&](const Decl *D) -> bool {
+ if (D->isFromASTFile())
+ return false;
+ auto I = DeclIDs.find(D);
+ return (I == DeclIDs.end() || I->second >= NUM_PREDEF_DECL_IDS);
+ };
+
+ assert(IsLocalDecl(D) && "expected a local declaration");
const Decl *Canon = D->getCanonicalDecl();
- if (isLocalDecl(*this, Canon))
+ if (IsLocalDecl(Canon))
return Canon;
const Decl *&CacheEntry = FirstLocalDeclCache[Canon];
@@ -1543,7 +1544,7 @@ const Decl *ASTWriter::getFirstLocalDecl(const Decl *D) {
return CacheEntry;
for (const Decl *Redecl = D; Redecl; Redecl = Redecl->getPreviousDecl())
- if (isLocalDecl(*this, Redecl))
+ if (IsLocalDecl(Redecl))
D = Redecl;
return CacheEntry = D;
}