summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-03-31 00:36:02 +0000
committerChris Lattner <sabre@nondot.org>2008-03-31 00:36:02 +0000
commit59a2594f3f33a312a9395c096651036ff40e75e6 (patch)
tree9e16fbd3f9b1827c612e8891a8c08985b6b96f2e /clang/lib/AST/Decl.cpp
parentf2b0b0eb17a209d7d07b4eb85f92a755c9c062d6 (diff)
downloadbcm5719-llvm-59a2594f3f33a312a9395c096651036ff40e75e6.tar.gz
bcm5719-llvm-59a2594f3f33a312a9395c096651036ff40e75e6.zip
rename Decl::CompatibleAlias -> ObjCCompatibleAlias.
Fix objc ivar lookup. Ivar lookup should occur between lookup of method-local values and lookup of globals. Emulate this with some logic in the handling of Sema::ActOnIdentifierExpr. Two todo's left: 1) sema shouldn't turn a bare reference to an ivar into "self->ivar" in the AST. This is a hack. 2) The new ScopedDecl::isDefinedOutsideFunctionOrMethod method does not correctly handle typedefs and enum constants yet. llvm-svn: 48972
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r--clang/lib/AST/Decl.cpp48
1 files changed, 42 insertions, 6 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index df403ebd66c..bad65cf84c6 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -193,7 +193,7 @@ void Decl::addDeclKind(Kind k) {
case ObjCIvar: nIvarDecls++; break;
case ObjCImplementation: nObjCImplementationDecls++; break;
case ObjCCategoryImpl: nObjCCategoryImpl++; break;
- case CompatibleAlias: nObjCCompatibleAlias++; break;
+ case ObjCCompatibleAlias: nObjCCompatibleAlias++; break;
case PropertyDecl: nObjCPropertyDecl++; break;
case LinkageSpec: nLinkageSpecDecl++; break;
case FileScopeAsm: nFileScopeAsmDecl++; break;
@@ -319,12 +319,46 @@ const Attr *Decl::getAttrs() const {
return (*DeclAttrs)[this];
}
+//===----------------------------------------------------------------------===//
+// NamedDecl Implementation
+//===----------------------------------------------------------------------===//
+
const char *NamedDecl::getName() const {
if (const IdentifierInfo *II = getIdentifier())
return II->getName();
return "";
}
+//===----------------------------------------------------------------------===//
+// ScopedDecl Implementation
+//===----------------------------------------------------------------------===//
+
+// isDefinedOutsideFunctionOrMethod - This predicate returns true if this
+// scoped decl is defined outside the current function or method. This is
+// roughly global variables and functions, but also handles enums (which could
+// be defined inside or outside a function etc).
+bool ScopedDecl::isDefinedOutsideFunctionOrMethod() const {
+ if (const VarDecl *VD = dyn_cast<VarDecl>(this))
+ return VD->hasGlobalStorage();
+ if (isa<FunctionDecl>(this))
+ return true;
+
+ // FIXME: Why is ObjCCompatibleAlias a scopedecl?
+ if (isa<ObjCCompatibleAliasDecl>(this))
+ return true;
+
+ // FIXME: This needs to check the context the decl was defined in!
+ if (isa<TypeDecl>(this) || isa<EnumConstantDecl>(this))
+ return true;
+
+ assert(0 && "Unknown ScopedDecl!");
+ return false;
+}
+
+//===----------------------------------------------------------------------===//
+// FunctionDecl Implementation
+//===----------------------------------------------------------------------===//
+
FunctionDecl::~FunctionDecl() {
delete[] ParamInfo;
}
@@ -346,6 +380,9 @@ void FunctionDecl::setParams(ParmVarDecl **NewParamInfo, unsigned NumParams) {
}
}
+//===----------------------------------------------------------------------===//
+// RecordDecl Implementation
+//===----------------------------------------------------------------------===//
/// defineBody - When created, RecordDecl's correspond to a forward declared
/// record. This method is used to mark the decl as being defined, with the
@@ -360,14 +397,13 @@ void RecordDecl::defineBody(FieldDecl **members, unsigned numMembers) {
}
}
-FieldDecl* RecordDecl::getMember(IdentifierInfo *name) {
+FieldDecl *RecordDecl::getMember(IdentifierInfo *II) {
if (Members == 0 || NumMembers < 0)
return 0;
- // linear search. When C++ classes come along, will likely need to revisit.
- for (int i = 0; i < NumMembers; ++i) {
- if (Members[i]->getIdentifier() == name)
+ // Linear search. When C++ classes come along, will likely need to revisit.
+ for (int i = 0; i != NumMembers; ++i)
+ if (Members[i]->getIdentifier() == II)
return Members[i];
- }
return 0;
}
OpenPOWER on IntegriCloud