LEFT | RIGHT |
1 //===--- SemaDecl.cpp - Semantic Analysis for Declarations ----------------===// | 1 //===--- SemaDecl.cpp - Semantic Analysis for Declarations ----------------===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file implements semantic analysis for declarations. | 10 // This file implements semantic analysis for declarations. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 Sema::TypeTy *Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc, | 63 Sema::TypeTy *Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc, |
64 Scope *S, CXXScopeSpec *SS, | 64 Scope *S, CXXScopeSpec *SS, |
65 bool isClassName, | 65 bool isClassName, |
66 TypeTy *ObjectTypePtr) { | 66 TypeTy *ObjectTypePtr) { |
67 // Determine where we will perform name lookup. | 67 // Determine where we will perform name lookup. |
68 DeclContext *LookupCtx = 0; | 68 DeclContext *LookupCtx = 0; |
69 if (ObjectTypePtr) { | 69 if (ObjectTypePtr) { |
70 QualType ObjectType = QualType::getFromOpaquePtr(ObjectTypePtr); | 70 QualType ObjectType = QualType::getFromOpaquePtr(ObjectTypePtr); |
71 if (ObjectType->isRecordType()) | 71 if (ObjectType->isRecordType()) |
72 LookupCtx = computeDeclContext(ObjectType); | 72 LookupCtx = computeDeclContext(ObjectType); |
73 } else if (SS && SS->isSet()) { | 73 } else if (SS && SS->isNotEmpty()) { |
74 LookupCtx = computeDeclContext(*SS, false); | 74 LookupCtx = computeDeclContext(*SS, false); |
75 | 75 |
76 if (!LookupCtx) { | 76 if (!LookupCtx) { |
77 if (isDependentScopeSpecifier(*SS)) { | 77 if (isDependentScopeSpecifier(*SS)) { |
78 // C++ [temp.res]p3: | 78 // C++ [temp.res]p3: |
79 // A qualified-id that refers to a type and in which the | 79 // A qualified-id that refers to a type and in which the |
80 // nested-name-specifier depends on a template-parameter (14.6.2) | 80 // nested-name-specifier depends on a template-parameter (14.6.2) |
81 // shall be prefixed by the keyword typename to indicate that the | 81 // shall be prefixed by the keyword typename to indicate that the |
82 // qualified-id denotes a type, forming an | 82 // qualified-id denotes a type, forming an |
83 // elaborated-type-specifier (7.1.5.3). | 83 // elaborated-type-specifier (7.1.5.3). |
(...skipping 5656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5740 Visibility != tok::objc_not_keyword ? TranslateIvarVisibility(Visibility) | 5740 Visibility != tok::objc_not_keyword ? TranslateIvarVisibility(Visibility) |
5741 : ObjCIvarDecl::None; | 5741 : ObjCIvarDecl::None; |
5742 // Must set ivar's DeclContext to its enclosing interface. | 5742 // Must set ivar's DeclContext to its enclosing interface. |
5743 ObjCContainerDecl *EnclosingDecl = IntfDecl.getAs<ObjCContainerDecl>(); | 5743 ObjCContainerDecl *EnclosingDecl = IntfDecl.getAs<ObjCContainerDecl>(); |
5744 ObjCContainerDecl *EnclosingContext; | 5744 ObjCContainerDecl *EnclosingContext; |
5745 if (ObjCImplementationDecl *IMPDecl = | 5745 if (ObjCImplementationDecl *IMPDecl = |
5746 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) { | 5746 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) { |
5747 // Case of ivar declared in an implementation. Context is that of its class. | 5747 // Case of ivar declared in an implementation. Context is that of its class. |
5748 EnclosingContext = IMPDecl->getClassInterface(); | 5748 EnclosingContext = IMPDecl->getClassInterface(); |
5749 assert(EnclosingContext && "Implementation has no class interface!"); | 5749 assert(EnclosingContext && "Implementation has no class interface!"); |
5750 } else | 5750 } else { |
| 5751 if (ObjCCategoryDecl *CDecl =· |
| 5752 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) { |
| 5753 if (!LangOpts.ObjCNonFragileABI2 || !CDecl->IsClassExtension()) { |
| 5754 Diag(Loc, diag::err_misplaced_ivar) << CDecl->IsClassExtension(); |
| 5755 return DeclPtrTy(); |
| 5756 } |
| 5757 } |
5751 EnclosingContext = EnclosingDecl; | 5758 EnclosingContext = EnclosingDecl; |
| 5759 } |
5752 | 5760 |
5753 // Construct the decl. | 5761 // Construct the decl. |
5754 ObjCIvarDecl *NewID = ObjCIvarDecl::Create(Context, | 5762 ObjCIvarDecl *NewID = ObjCIvarDecl::Create(Context, |
5755 EnclosingContext, Loc, II, T, | 5763 EnclosingContext, Loc, II, T, |
5756 TInfo, ac, (Expr *)BitfieldWidth); | 5764 TInfo, ac, (Expr *)BitfieldWidth); |
5757 | 5765 |
5758 if (II) { | 5766 if (II) { |
5759 NamedDecl *PrevDecl = LookupSingleName(S, II, LookupMemberName, | 5767 NamedDecl *PrevDecl = LookupSingleName(S, II, LookupMemberName, |
5760 ForRedeclaration); | 5768 ForRedeclaration); |
5761 if (PrevDecl && isDeclInScope(PrevDecl, EnclosingContext, S) | 5769 if (PrevDecl && isDeclInScope(PrevDecl, EnclosingContext, S) |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5919 } else if (ObjCImplementationDecl *IMPDecl = | 5927 } else if (ObjCImplementationDecl *IMPDecl = |
5920 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) { | 5928 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) { |
5921 assert(IMPDecl && "ActOnFields - missing ObjCImplementationDecl"); | 5929 assert(IMPDecl && "ActOnFields - missing ObjCImplementationDecl"); |
5922 for (unsigned I = 0, N = RecFields.size(); I != N; ++I) | 5930 for (unsigned I = 0, N = RecFields.size(); I != N; ++I) |
5923 // Ivar declared in @implementation never belongs to the implementation. | 5931 // Ivar declared in @implementation never belongs to the implementation. |
5924 // Only it is in implementation's lexical context. | 5932 // Only it is in implementation's lexical context. |
5925 ClsFields[I]->setLexicalDeclContext(IMPDecl); | 5933 ClsFields[I]->setLexicalDeclContext(IMPDecl); |
5926 CheckImplementationIvars(IMPDecl, ClsFields, RecFields.size(), RBrac); | 5934 CheckImplementationIvars(IMPDecl, ClsFields, RecFields.size(), RBrac); |
5927 } else if (ObjCCategoryDecl *CDecl =· | 5935 } else if (ObjCCategoryDecl *CDecl =· |
5928 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) { | 5936 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) { |
5929 if (!LangOpts.ObjCNonFragileABI2 || !CDecl->IsClassExtension()) | 5937 // case of ivars in class extension; all other cases have been |
5930 Diag(LBrac, diag::err_misplaced_ivar) << CDecl->IsClassExtension(); | 5938 // reported as errors elsewhere. |
5931 else { | 5939 // FIXME. Class extension does not have a LocEnd field. |
5932 // FIXME. Class extension does not have a LocEnd field. | 5940 // CDecl->setLocEnd(RBrac); |
5933 // CDecl->setLocEnd(RBrac); | 5941 // Add ivar's to class extension's DeclContext. |
5934 // Add ivar's to class extension's DeclContext. | 5942 for (unsigned i = 0, e = RecFields.size(); i != e; ++i) { |
5935 for (unsigned i = 0, e = RecFields.size(); i != e; ++i) { | 5943 ClsFields[i]->setLexicalDeclContext(CDecl); |
5936 ClsFields[i]->setLexicalDeclContext(CDecl); | 5944 CDecl->addDecl(ClsFields[i]); |
5937 CDecl->addDecl(ClsFields[i]); | |
5938 } | |
5939 } | 5945 } |
5940 } | 5946 } |
5941 } | 5947 } |
5942 | 5948 |
5943 if (Attr) | 5949 if (Attr) |
5944 ProcessDeclAttributeList(S, Record, Attr); | 5950 ProcessDeclAttributeList(S, Record, Attr); |
5945 } | 5951 } |
5946 | 5952 |
5947 /// \brief Determine whether the given integral value is representable within | 5953 /// \brief Determine whether the given integral value is representable within |
5948 /// the given type T. | 5954 /// the given type T. |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6404 | 6410 |
6405 if (PrevDecl) { | 6411 if (PrevDecl) { |
6406 if (!PrevDecl->hasAttr<AliasAttr>()) | 6412 if (!PrevDecl->hasAttr<AliasAttr>()) |
6407 if (NamedDecl *ND = dyn_cast<NamedDecl>(PrevDecl)) | 6413 if (NamedDecl *ND = dyn_cast<NamedDecl>(PrevDecl)) |
6408 DeclApplyPragmaWeak(TUScope, ND, W); | 6414 DeclApplyPragmaWeak(TUScope, ND, W); |
6409 } else { | 6415 } else { |
6410 (void)WeakUndeclaredIdentifiers.insert( | 6416 (void)WeakUndeclaredIdentifiers.insert( |
6411 std::pair<IdentifierInfo*,WeakInfo>(AliasName, W)); | 6417 std::pair<IdentifierInfo*,WeakInfo>(AliasName, W)); |
6412 } | 6418 } |
6413 } | 6419 } |
LEFT | RIGHT |