OLD | NEW |
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 /// | 54 /// |
55 /// This routine performs ordinary name lookup of the identifier II | 55 /// This routine performs ordinary name lookup of the identifier II |
56 /// within the given scope, with optional C++ scope specifier SS, to | 56 /// within the given scope, with optional C++ scope specifier SS, to |
57 /// determine whether the name refers to a type. If so, returns an | 57 /// determine whether the name refers to a type. If so, returns an |
58 /// opaque pointer (actually a QualType) corresponding to that | 58 /// opaque pointer (actually a QualType) corresponding to that |
59 /// type. Otherwise, returns NULL. | 59 /// type. Otherwise, returns NULL. |
60 /// | 60 /// |
61 /// If name lookup results in an ambiguity, this routine will complain | 61 /// If name lookup results in an ambiguity, this routine will complain |
62 /// and then return NULL. | 62 /// and then return NULL. |
63 Sema::TypeTy *Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc, | 63 Sema::TypeTy *Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc, |
64 Scope *S, const 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->isNotEmpty()) { | 73 } else if (SS && SS->isNotEmpty()) { |
74 LookupCtx = computeDeclContext(*SS, false); | 74 LookupCtx = computeDeclContext(*SS, false); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 case TagDecl::TK_enum: return DeclSpec::TST_enum; | 229 case TagDecl::TK_enum: return DeclSpec::TST_enum; |
230 } | 230 } |
231 } | 231 } |
232 | 232 |
233 return DeclSpec::TST_unspecified; | 233 return DeclSpec::TST_unspecified; |
234 } | 234 } |
235 | 235 |
236 bool Sema::DiagnoseUnknownTypeName(const IdentifierInfo &II,· | 236 bool Sema::DiagnoseUnknownTypeName(const IdentifierInfo &II,· |
237 SourceLocation IILoc, | 237 SourceLocation IILoc, |
238 Scope *S, | 238 Scope *S, |
239 const CXXScopeSpec *SS, | 239 CXXScopeSpec *SS, |
240 TypeTy *&SuggestedType) { | 240 TypeTy *&SuggestedType) { |
241 // We don't have anything to suggest (yet). | 241 // We don't have anything to suggest (yet). |
242 SuggestedType = 0; | 242 SuggestedType = 0; |
243 ·· | 243 ·· |
244 // There may have been a typo in the name of the type. Look up typo | 244 // There may have been a typo in the name of the type. Look up typo |
245 // results, in case we have something that we can suggest. | 245 // results, in case we have something that we can suggest. |
246 LookupResult Lookup(*this, &II, IILoc, LookupOrdinaryName,· | 246 LookupResult Lookup(*this, &II, IILoc, LookupOrdinaryName,· |
247 NotForRedeclaration); | 247 NotForRedeclaration); |
248 | 248 |
249 // FIXME: It would be nice if we could correct for typos in built-in | 249 // FIXME: It would be nice if we could correct for typos in built-in |
(...skipping 4435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4685 return true; | 4685 return true; |
4686 } | 4686 } |
4687 return false; | 4687 return false; |
4688 } | 4688 } |
4689 | 4689 |
4690 /// ActOnTag - This is invoked when we see 'struct foo' or 'struct {'. In the | 4690 /// ActOnTag - This is invoked when we see 'struct foo' or 'struct {'. In the |
4691 /// former case, Name will be non-null. In the later case, Name will be null. | 4691 /// former case, Name will be non-null. In the later case, Name will be null. |
4692 /// TagSpec indicates what kind of tag this is. TUK indicates whether this is a | 4692 /// TagSpec indicates what kind of tag this is. TUK indicates whether this is a |
4693 /// reference/declaration/definition of a tag. | 4693 /// reference/declaration/definition of a tag. |
4694 Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, | 4694 Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, |
4695 SourceLocation KWLoc, const CXXScopeSpec &SS, | 4695 SourceLocation KWLoc, CXXScopeSpec &SS, |
4696 IdentifierInfo *Name, SourceLocation NameLoc, | 4696 IdentifierInfo *Name, SourceLocation NameLoc, |
4697 AttributeList *Attr, AccessSpecifier AS, | 4697 AttributeList *Attr, AccessSpecifier AS, |
4698 MultiTemplateParamsArg TemplateParameterLists, | 4698 MultiTemplateParamsArg TemplateParameterLists, |
4699 bool &OwnedDecl, bool &IsDependent) { | 4699 bool &OwnedDecl, bool &IsDependent) { |
4700 // If this is not a definition, it must have a name. | 4700 // If this is not a definition, it must have a name. |
4701 assert((Name != 0 || TUK == TUK_Definition) && | 4701 assert((Name != 0 || TUK == TUK_Definition) && |
4702 "Nameless record must be a definition!"); | 4702 "Nameless record must be a definition!"); |
4703 | 4703 |
4704 OwnedDecl = false; | 4704 OwnedDecl = false; |
4705 TagDecl::TagKind Kind = TagDecl::getTagKindForTypeSpec(TagSpec); | 4705 TagDecl::TagKind Kind = TagDecl::getTagKindForTypeSpec(TagSpec); |
(...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6410 | 6410 |
6411 if (PrevDecl) { | 6411 if (PrevDecl) { |
6412 if (!PrevDecl->hasAttr<AliasAttr>()) | 6412 if (!PrevDecl->hasAttr<AliasAttr>()) |
6413 if (NamedDecl *ND = dyn_cast<NamedDecl>(PrevDecl)) | 6413 if (NamedDecl *ND = dyn_cast<NamedDecl>(PrevDecl)) |
6414 DeclApplyPragmaWeak(TUScope, ND, W); | 6414 DeclApplyPragmaWeak(TUScope, ND, W); |
6415 } else { | 6415 } else { |
6416 (void)WeakUndeclaredIdentifiers.insert( | 6416 (void)WeakUndeclaredIdentifiers.insert( |
6417 std::pair<IdentifierInfo*,WeakInfo>(AliasName, W)); | 6417 std::pair<IdentifierInfo*,WeakInfo>(AliasName, W)); |
6418 } | 6418 } |
6419 } | 6419 } |
OLD | NEW |