summaryrefslogtreecommitdiffstats
path: root/lib/AST/DeclBase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/AST/DeclBase.cpp')
-rw-r--r--lib/AST/DeclBase.cpp57
1 files changed, 26 insertions, 31 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index 47a0d25..f9ce46d 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -411,23 +411,32 @@ AvailabilityResult Decl::getAvailability(std::string *Message) const {
bool Decl::canBeWeakImported(bool &IsDefinition) const {
IsDefinition = false;
+
+ // Variables, if they aren't definitions.
if (const VarDecl *Var = dyn_cast<VarDecl>(this)) {
if (!Var->hasExternalStorage() || Var->getInit()) {
IsDefinition = true;
return false;
}
+ return true;
+
+ // Functions, if they aren't definitions.
} else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(this)) {
if (FD->hasBody()) {
IsDefinition = true;
return false;
}
- } else if (isa<ObjCPropertyDecl>(this) || isa<ObjCMethodDecl>(this))
- return false;
- else if (!(getASTContext().getLangOpts().ObjCNonFragileABI &&
- isa<ObjCInterfaceDecl>(this)))
- return false;
+ return true;
- return true;
+ // Objective-C classes, if this is the non-fragile runtime.
+ } else if (isa<ObjCInterfaceDecl>(this) &&
+ getASTContext().getLangOpts().ObjCRuntime.hasWeakClassImport()) {
+ return true;
+
+ // Nothing else.
+ } else {
+ return false;
+ }
}
bool Decl::isWeakImported() const {
@@ -974,10 +983,6 @@ DeclContext::decl_iterator DeclContext::noload_decls_begin() const {
return decl_iterator(FirstDecl);
}
-DeclContext::decl_iterator DeclContext::noload_decls_end() const {
- return decl_iterator();
-}
-
DeclContext::decl_iterator DeclContext::decls_begin() const {
if (hasExternalLexicalStorage())
LoadLexicalDeclsFromExternalStorage();
@@ -985,13 +990,6 @@ DeclContext::decl_iterator DeclContext::decls_begin() const {
return decl_iterator(FirstDecl);
}
-DeclContext::decl_iterator DeclContext::decls_end() const {
- if (hasExternalLexicalStorage())
- LoadLexicalDeclsFromExternalStorage();
-
- return decl_iterator();
-}
-
bool DeclContext::decls_empty() const {
if (hasExternalLexicalStorage())
LoadLexicalDeclsFromExternalStorage();
@@ -1192,34 +1190,31 @@ DeclContext::lookup(DeclarationName Name) {
return I->second.getLookupResult();
}
-DeclContext::lookup_const_result
-DeclContext::lookup(DeclarationName Name) const {
- return const_cast<DeclContext*>(this)->lookup(Name);
-}
-
void DeclContext::localUncachedLookup(DeclarationName Name,
llvm::SmallVectorImpl<NamedDecl *> &Results) {
Results.clear();
// If there's no external storage, just perform a normal lookup and copy
// the results.
- if (!hasExternalVisibleStorage() && !hasExternalLexicalStorage()) {
+ if (!hasExternalVisibleStorage() && !hasExternalLexicalStorage() && Name) {
lookup_result LookupResults = lookup(Name);
Results.insert(Results.end(), LookupResults.first, LookupResults.second);
return;
}
// If we have a lookup table, check there first. Maybe we'll get lucky.
- if (StoredDeclsMap *Map = LookupPtr.getPointer()) {
- StoredDeclsMap::iterator Pos = Map->find(Name);
- if (Pos != Map->end()) {
- Results.insert(Results.end(),
- Pos->second.getLookupResult().first,
- Pos->second.getLookupResult().second);
- return;
+ if (Name) {
+ if (StoredDeclsMap *Map = LookupPtr.getPointer()) {
+ StoredDeclsMap::iterator Pos = Map->find(Name);
+ if (Pos != Map->end()) {
+ Results.insert(Results.end(),
+ Pos->second.getLookupResult().first,
+ Pos->second.getLookupResult().second);
+ return;
+ }
}
}
-
+
// Slow case: grovel through the declarations in our chain looking for
// matches.
for (Decl *D = FirstDecl; D; D = D->getNextDeclInContext()) {
OpenPOWER on IntegriCloud