diff options
author | Mike Stump <mrs@apple.com> | 2009-09-09 15:08:12 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-09-09 15:08:12 +0000 |
commit | 1eb4433ac451dc16f4133a88af2d002ac26c58ef (patch) | |
tree | 07065b80cb7787bb7b9ffcb985196007a57e86f7 /lib/Sema/SemaDecl.cpp | |
parent | 79d39f92590cf2e91bf81486b02cd1156d13ca54 (diff) |
Remove tabs, and whitespace cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81346 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 722 |
1 files changed, 361 insertions, 361 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 8074ab94bf..d49ba890b2 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -28,7 +28,7 @@ #include "clang/Basic/TargetInfo.h" // FIXME: layering (ideally, Sema shouldn't be dependent on Lex API's) #include "clang/Lex/Preprocessor.h" -#include "clang/Lex/HeaderSearch.h" +#include "clang/Lex/HeaderSearch.h" #include "llvm/ADT/BitVector.h" #include "llvm/ADT/STLExtras.h" #include <algorithm> @@ -37,7 +37,7 @@ using namespace clang; /// getDeclName - Return a pretty name for the specified decl if possible, or -/// an empty string if not. This is used for pretty crash reporting. +/// an empty string if not. This is used for pretty crash reporting. std::string Sema::getDeclName(DeclPtrTy d) { Decl *D = d.getAs<Decl>(); if (NamedDecl *DN = dyn_cast_or_null<NamedDecl>(D)) @@ -75,16 +75,16 @@ Sema::TypeTy *Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc, if (SS && isUnknownSpecialization(*SS)) { if (!isClassName) return 0; - - // We know from the grammar that this name refers to a type, so build a + + // We know from the grammar that this name refers to a type, so build a // TypenameType node to describe the type. // FIXME: Record somewhere that this TypenameType node has no "typename" // keyword associated with it. return CheckTypenameType((NestedNameSpecifier *)SS->getScopeRep(), II, SS->getRange()).getAsOpaquePtr(); } - - LookupResult Result + + LookupResult Result = LookupParsedName(S, SS, &II, LookupOrdinaryName, false, false); NamedDecl *IIDecl = 0; @@ -100,8 +100,8 @@ Sema::TypeTy *Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc, for (LookupResult::iterator Res = Result.begin(), ResEnd = Result.end(); Res != ResEnd; ++Res) { if (isa<TypeDecl>(*Res) || isa<ObjCInterfaceDecl>(*Res)) { - if (!IIDecl || - (*Res)->getLocation().getRawEncoding() < + if (!IIDecl || + (*Res)->getLocation().getRawEncoding() < IIDecl->getLocation().getRawEncoding()) IIDecl = *Res; } @@ -133,11 +133,11 @@ Sema::TypeTy *Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc, if (IIDecl) { QualType T; - + if (TypeDecl *TD = dyn_cast<TypeDecl>(IIDecl)) { // Check whether we can use this type (void)DiagnoseUseOfDecl(IIDecl, NameLoc); - + if (getLangOptions().CPlusPlus) { // C++ [temp.local]p2: // Within the scope of a class template specialization or @@ -157,7 +157,7 @@ Sema::TypeTy *Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc, } else if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(IIDecl)) { // Check whether we can use this interface. (void)DiagnoseUseOfDecl(IIDecl, NameLoc); - + T = Context.getObjCInterfaceType(IDecl); } else return 0; @@ -188,7 +188,7 @@ DeclSpec::TST Sema::isTagName(IdentifierInfo &II, Scope *S) { case TagDecl::TK_enum: return DeclSpec::TST_enum; } } - + return DeclSpec::TST_unspecified; } @@ -284,7 +284,7 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) { // Move up the scope chain until we find the nearest enclosing // non-transparent context. The declaration will be introduced into this // scope. - while (S->getEntity() && + while (S->getEntity() && ((DeclContext *)S->getEntity())->isTransparentContext()) S = S->getParent(); @@ -304,7 +304,7 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) { // in this case the class name or enumeration name is hidden. if (TagDecl *TD = dyn_cast<TagDecl>(D)) { // We are pushing the name of a tag (enum or class). - if (CurContext->getLookupContext() + if (CurContext->getLookupContext() == TD->getDeclContext()->getLookupContext()) { // We're pushing the tag into the current context, which might // require some reshuffling in the identifier resolver. @@ -313,7 +313,7 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) { IEnd = IdResolver.end(); if (I != IEnd && isDeclInScope(*I, CurContext, S)) { NamedDecl *PrevDecl = *I; - for (; I != IEnd && isDeclInScope(*I, CurContext, S); + for (; I != IEnd && isDeclInScope(*I, CurContext, S); PrevDecl = *I, ++I) { if (TD->declarationReplaces(*I)) { // This is a redeclaration. Remove it from the chain and @@ -336,7 +336,7 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) { // before we find the new declaration, so insert the new // declaration at the end of the chain. IdResolver.AddShadowedDecl(TD, PrevDecl); - + return; } } @@ -360,7 +360,7 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) { } else if (isa<ObjCInterfaceDecl>(D)) { // We're pushing an Objective-C interface into the current // context. If there is already an alias declaration, remove it first. - for (IdentifierResolver::iterator + for (IdentifierResolver::iterator I = IdResolver.begin(D->getDeclName()), IEnd = IdResolver.end(); I != IEnd; ++I) { if (isa<ObjCCompatibleAliasDecl>(*I)) { @@ -377,7 +377,7 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) { void Sema::ActOnPopScope(SourceLocation Loc, Scope *S) { if (S->decl_empty()) return; assert((S->getFlags() & (Scope::DeclScope | Scope::TemplateParamScope)) && - "Scope shouldn't contain decls!"); + "Scope shouldn't contain decls!"); for (Scope::decl_iterator I = S->decl_begin(), E = S->decl_end(); I != E; ++I) { @@ -400,7 +400,7 @@ ObjCInterfaceDecl *Sema::getObjCInterfaceDecl(IdentifierInfo *Id) { // The third "scope" argument is 0 since we aren't enabling lazy built-in // creation from this context. NamedDecl *IDecl = LookupName(TUScope, Id, LookupOrdinaryName); - + return dyn_cast_or_null<ObjCInterfaceDecl>(IDecl); } @@ -413,7 +413,7 @@ ObjCInterfaceDecl *Sema::getObjCInterfaceDecl(IdentifierInfo *Id) { /// struct S6 { /// enum { BAR } e; /// }; -/// +/// /// void test_S6() { /// struct S6 a; /// a.e = BAR; @@ -429,7 +429,7 @@ ObjCInterfaceDecl *Sema::getObjCInterfaceDecl(IdentifierInfo *Id) { /// contain non-field names. Scope *Sema::getNonFieldDeclScope(Scope *S) { while (((S->getFlags() & Scope::DeclScope) == 0) || - (S->getEntity() && + (S->getEntity() && ((DeclContext *)S->getEntity())->isTransparentContext()) || (S->isClassScope() && !getLangOptions().CPlusPlus)) S = S->getParent(); @@ -439,7 +439,7 @@ Scope *Sema::getNonFieldDeclScope(Scope *S) { void Sema::InitBuiltinVaListType() { if (!Context.getBuiltinVaListType().isNull()) return; - + IdentifierInfo *VaIdent = &Context.Idents.get("__builtin_va_list"); NamedDecl *VaDecl = LookupName(TUScope, VaIdent, LookupOrdinaryName); TypedefDecl *VaTypedef = cast<TypedefDecl>(VaDecl); @@ -459,7 +459,7 @@ NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid, InitBuiltinVaListType(); ASTContext::GetBuiltinTypeError Error; - QualType R = Context.GetBuiltinType(BID, Error); + QualType R = Context.GetBuiltinType(BID, Error); switch (Error) { case ASTContext::GE_None: // Okay @@ -507,9 +507,9 @@ NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid, VarDecl::None, 0)); New->setParams(Context, Params.data(), Params.size()); } - - AddKnownFunctionAttributes(New); - + + AddKnownFunctionAttributes(New); + // TUScope is the translation-unit scope to insert this function into. // FIXME: This is hideous. We need to teach PushOnScopeChains to // relate Scopes to DeclContexts, and probably eliminate CurContext @@ -543,14 +543,14 @@ void Sema::MergeTypeDefDecl(TypedefDecl *New, Decl *OldD) { // don't bother doing any merging checks. if (New->isInvalidDecl() || OldD->isInvalidDecl()) return New->setInvalidDecl(); - + // Allow multiple definitions for ObjC built-in typedefs. // FIXME: Verify the underlying types are equivalent! if (getLangOptions().ObjC1) { const IdentifierInfo *TypeID = New->getIdentifier(); switch (TypeID->getLength()) { default: break; - case 2: + case 2: if (!TypeID->isStr("id")) break; Context.ObjCIdRedefinitionType = New->getUnderlyingType(); @@ -580,14 +580,14 @@ void Sema::MergeTypeDefDecl(TypedefDecl *New, Decl *OldD) { // Verify the old decl was also a type. TypeDecl *Old = dyn_cast<TypeDecl>(OldD); if (!Old) { - Diag(New->getLocation(), diag::err_redefinition_different_kind) + Diag(New->getLocation(), diag::err_redefinition_different_kind) << New->getDeclName(); if (OldD->getLocation().isValid()) Diag(OldD->getLocation(), diag::note_previous_definition); return New->setInvalidDecl(); } - // Determine the "old" type we'll use for checking and diagnostics. + // Determine the "old" type we'll use for checking and diagnostics. QualType OldType; if (TypedefDecl *OldTypedef = dyn_cast<TypedefDecl>(Old)) OldType = OldTypedef->getUnderlyingType(); @@ -597,8 +597,8 @@ void Sema::MergeTypeDefDecl(TypedefDecl *New, Decl *OldD) { // If the typedef types are not identical, reject them in all languages and // with any extensions enabled. - if (OldType != New->getUnderlyingType() && - Context.getCanonicalType(OldType) != + if (OldType != New->getUnderlyingType() && + Context.getCanonicalType(OldType) != Context.getCanonicalType(New->getUnderlyingType())) { Diag(New->getLocation(), diag::err_redefinition_different_typedef) << New->getUnderlyingType() << OldType; @@ -606,7 +606,7 @@ void Sema::MergeTypeDefDecl(TypedefDecl *New, Decl *OldD) { Diag(Old->getLocation(), diag::note_previous_definition); return New->setInvalidDecl(); } - + if (getLangOptions().Microsoft) return; @@ -631,7 +631,7 @@ void Sema::MergeTypeDefDecl(TypedefDecl *New, Decl *OldD) { (Context.getSourceManager().isInSystemHeader(Old->getLocation()) || Context.getSourceManager().isInSystemHeader(New->getLocation()))) return; - + Diag(New->getLocation(), diag::warn_redefinition_of_typedef) << New->getDeclName(); Diag(Old->getLocation(), diag::note_previous_definition); @@ -640,7 +640,7 @@ void Sema::MergeTypeDefDecl(TypedefDecl *New, Decl *OldD) { /// DeclhasAttr - returns true if decl Declaration already has the target /// attribute. -static bool +static bool DeclHasAttr(const Decl *decl, const Attr *target) { for (const Attr *attr = decl->getAttrs(); attr; attr = attr->getNext()) if (attr->getKind() == target->getKind()) @@ -680,15 +680,15 @@ struct GNUCompatibleParamWarning { /// /// Returns true if there was an error, false otherwise. bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) { - assert(!isa<OverloadedFunctionDecl>(OldD) && + assert(!isa<OverloadedFunctionDecl>(OldD) && "Cannot merge with an overloaded function declaration"); // Verify the old decl was also a function. FunctionDecl *Old = 0; - if (FunctionTemplateDecl *OldFunctionTemplate + if (FunctionTemplateDecl *OldFunctionTemplate = dyn_cast<FunctionTemplateDecl>(OldD)) Old = OldFunctionTemplate->getTemplatedDecl(); - else + else Old = dyn_cast<FunctionDecl>(OldD); if (!Old) { Diag(New->getLocation(), diag::err_redefinition_different_kind) @@ -704,12 +704,12 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) { PrevDiag = diag::note_previous_definition; else if (Old->isImplicit()) PrevDiag = diag::note_previous_implicit_declaration; - else + else PrevDiag = diag::note_previous_declaration; - + QualType OldQType = Context.getCanonicalType(Old->getType()); QualType NewQType = Context.getCanonicalType(New->getType()); - + if (!isa<CXXMethodDecl>(New) && !isa<CXXMethodDecl>(Old) && New->getStorageClass() == FunctionDecl::Static && Old->getStorageClass() != FunctionDecl::Static) { @@ -722,11 +722,11 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) { if (getLangOptions().CPlusPlus) { // (C++98 13.1p2): // Certain function declarations cannot be overloaded: - // -- Function declarations that differ only in the return type + // -- Function declarations that differ only in the return type // cannot be overloaded. - QualType OldReturnType + QualType OldReturnType = cast<FunctionType>(OldQType.getTypePtr())->getResultType(); - QualType NewReturnType + QualType NewReturnType = cast<FunctionType>(NewQType.getTypePtr())->getResultType(); if (OldReturnType != NewReturnType) { Diag(New->getLocation(), diag::err_ovl_diff_return_type); @@ -738,8 +738,8 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) { const CXXMethodDecl* NewMethod = dyn_cast<CXXMethodDecl>(New); if (OldMethod && NewMethod && !NewMethod->getFriendObjectKind() && NewMethod->getLexicalDeclContext()->isRecord()) { - // -- Member function declarations with the same name and the - // same parameter types cannot be overloaded if any of them + // -- Member function declarations with the same name and the + // same parameter types cannot be overloaded if any of them // is a static member function declaration. if (OldMethod->isStatic() || NewMethod->isStatic()) { Diag(New->getLocation(), diag::err_ovl_static_nonstatic_member); @@ -760,7 +760,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) { NewDiag = diag::err_conv_function_redeclared; else NewDiag = diag::err_member_redeclared; - + Diag(New->getLocation(), NewDiag); Diag(Old->getLocation(), PrevDiag) << Old << Old->getType(); } @@ -797,8 +797,8 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) { // Synthesize a parameter for each argument type. llvm::SmallVector<ParmVarDecl*, 16> Params; - for (FunctionProtoType::arg_type_iterator - ParamType = OldProto->arg_type_begin(), + for (FunctionProtoType::arg_type_iterator + ParamType = OldProto->arg_type_begin(), ParamEnd = OldProto->arg_type_end(); ParamType != ParamEnd; ++ParamType) { ParmVarDecl *Param = ParmVarDecl::Create(Context, New, @@ -810,7 +810,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) { } New->setParams(Context, Params.data(), Params.size()); - } + } return MergeCompatibleFunctionDecls(New, Old); } @@ -832,25 +832,25 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) { Old->getNumParams() == New->getNumParams()) { llvm::SmallVector<QualType, 16> ArgTypes; llvm::SmallVector<GNUCompatibleParamWarning, 16> Warnings; - const FunctionProtoType *OldProto + const FunctionProtoType *OldProto = Old->getType()->getAsFunctionProtoType(); - const FunctionProtoType *NewProto + const FunctionProtoType *NewProto = New->getType()->getAsFunctionProtoType(); - + // Determine whether this is the GNU C extension. QualType MergedReturn = Context.mergeTypes(OldProto->getResultType(), NewProto->getResultType()); bool LooseCompatible = !MergedReturn.isNull(); - for (unsigned Idx = 0, End = Old->getNumParams(); + for (unsigned Idx = 0, End = Old->getNumParams(); LooseCompatible && Idx != End; ++Idx) { ParmVarDecl *OldParm = Old->getParamDecl(Idx); ParmVarDecl *NewParm = New->getParamDecl(Idx); - if (Context.typesAreCompatible(OldParm->getType(), + if (Context.typesAreCompatible(OldParm->getType(), NewProto->getArgType(Idx))) { ArgTypes.push_back(NewParm->getType()); } else if (Context.typesAreCompatible(OldParm->getType(), NewParm->getType())) { - GNUCompatibleParamWarning Warn + GNUCompatibleParamWarning Warn = { OldParm, NewParm, NewProto->getArgType(Idx) }; Warnings.push_back(Warn); ArgTypes.push_back(NewParm->getType()); @@ -864,7 +864,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) { diag::ext_param_promoted_not_compatible_with_prototype) << Warnings[Warn].PromotedType << Warnings[Warn].OldParm->getType(); - Diag(Warnings[Warn].OldParm->getLocation(), + Diag(Warnings[Warn].OldParm->getLocation(), diag::note_previous_declaration); } @@ -904,7 +904,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) { } /// \brief Completes the merge of two function declarations that are -/// known to be compatible. +/// known to be compatible. /// /// This routine handles the merging of attributes and other /// properties of function declarations form the old declaration to @@ -931,7 +931,7 @@ bool Sema::MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old) { New->setC99InlineDefinition(false); else if (Old->isC99InlineDefinition() && !New->isC99InlineDefinition()) { // Mark all preceding definitions as not being C99 inline definitions. - for (const FunctionDecl *Prev = Old; Prev; + for (const FunctionDecl *Prev = Old; Prev; Prev = Prev->getPreviousDeclaration()) const_cast<FunctionDecl *>(Prev)->setC99InlineDefinition(false); } @@ -943,7 +943,7 @@ bool Sema::MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old) { // Merge the "deleted" flag. if (Old->isDeleted()) New->setDeleted(); - + if (getLangOptions().CPlusPlus) return MergeCXXFunctionDecl(New, Old); @@ -954,16 +954,16 @@ bool Sema::MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old) { /// and scope as a previous declaration 'Old'. Figure out how to resolve this /// situation, merging decls or emitting diagnostics as appropriate. /// -/// Tentative definition rules (C99 6.9.2p2) are checked by -/// FinalizeDeclaratorGroup. Unfortunately, we can't analyze tentative +/// Tentative definition rules (C99 6.9.2p2) are checked by +/// FinalizeDeclaratorGroup. Unfortunately, we can't analyze tentative /// definitions here, since the initializer hasn't been attached. -/// +/// void Sema::MergeVarDecl(VarDecl *New, Decl *OldD) { // If either decl is invalid, make sure the new one is marked invalid and // don't do any other checking. if (New->isInvalidDecl() || OldD->isInvalidDecl()) return New->setInvalidDecl(); - + // Verify the old decl was also a variable. VarDecl *Old = dyn_cast<VarDecl>(OldD); if (!Old) { @@ -981,14 +981,14 @@ void Sema::MergeVarDecl(VarDecl *New, Decl *OldD) { if (Context.hasSameType(New->getType(), Old->getType())) MergedT = New->getType(); // C++ [basic.types]p7: - // [...] The declared type of an array object might be an array of - // unknown size and therefore be incomplete at one point in a + // [...] The declared type of an array object might be an array of + // unknown size and therefore be incomplete at one point in a // translation unit and complete later on; [...] - else if (Old->getType()->isIncompleteArrayType() && + else if (Old->getType()->isIncompleteArrayType() && New->getType()->isArrayType()) { - CanQual<ArrayType> OldArray + CanQual<ArrayType> OldArray = Context.getCanonicalType(Old->getType())->getAs<ArrayType>(); - CanQual<ArrayType> NewArray + CanQual<ArrayType> NewArray = Context.getCanonicalType(New->getType())->getAs<ArrayType>(); if (OldArray->getElementType() == NewArray->getElementType()) MergedT = New->getType(); @@ -997,7 +997,7 @@ void Sema::MergeVarDecl(VarDecl *New, Decl *OldD) { MergedT = Context.mergeTypes(New->getType(), Old->getType()); } if (MergedT.isNull()) { - Diag(New->getLocation(), diag::err_redefinition_different_type) + Diag(New->getLocation(), diag::err_redefinition_different_type) << New->getDeclName(); Diag(Old->getLocation(), diag::note_previous_definition); return New->setInvalidDecl(); @@ -1011,7 +1011,7 @@ void Sema::MergeVarDecl(VarDecl *New, Decl *OldD) { Diag(Old->getLocation(), diag::note_previous_definition); return New->setInvalidDecl(); } - // C99 6.2.2p4: + // C99 6.2.2p4: // For an identifier declared with the storage-class specifier // extern in a scope in which a prior declaration of that // identifier is visible,23) if the prior declaration specifies @@ -1030,7 +1030,7 @@ void Sema::MergeVarDecl(VarDecl *New, Decl *OldD) { } // Variables with external linkage are analyzed in FinalizeDeclaratorGroup. - + // FIXME: The test for external storage here seems wrong? We still // need to check for mismatches. if (!New->hasExternalStorage() && !New->isFileVarDecl() && @@ -1063,7 +1063,7 @@ void Sema::MergeVarDecl(VarDecl *New, Decl *OldD) { /// that functions not marked noreturn will return. Sema::ControlFlowKind Sema::CheckFallThrough(Stmt *Root) { llvm::OwningPtr<CFG> cfg (CFG::buildCFG(Root, &Context)); - + // FIXME: They should never return 0, fix that, delete this code. if (cfg == 0) return NeverFallThrough; @@ -1175,7 +1175,7 @@ void Sema::CheckFallThroughForFunctionDef(Decl *D, Stmt *Body) { if (MD->hasAttr<NoReturnAttr>()) HasNoReturn = true; } - + // Short circuit for compilation speed. if ((Diags.getDiagnosticLevel(diag::warn_maybe_falloff_nonvoid_function) == Diagnostic::Ignored || ReturnsVoid) @@ -1228,7 +1228,7 @@ void Sema::CheckFallThroughForBlock(QualType BlockTy, Stmt *Body) { if (FT->getNoReturnAttr()) HasNoReturn = true; } - + // Short circuit for compilation speed. if (ReturnsVoid && !HasNoReturn @@ -1279,10 +1279,10 @@ bool Sema::CheckParmsForFunctionDef(FunctionDecl *FD) { Param->setInvalidDecl(); HasInvalidParm = true; } - + // C99 6.9.1p5: If the declarator includes a parameter type list, the // declaration of each parameter shall include an identifier. - if (Param->getIdentifier() == 0 && + if (Param->getIdentifier() == 0 && !Param->isImplicit() && !getLangOptions().CPlusPlus) Diag(Param->getLocation(), diag::err_parameter_name_omitted); @@ -1333,7 +1333,7 @@ Sema::DeclPtrTy Sema::ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) { return DeclPtrTy::make(Tag); } - if (!DS.isMissingDeclaratorOk() && + if (!DS.isMissingDeclaratorOk() && DS.getTypeSpecType() != DeclSpec::TST_error) { // Warn about typedefs of enums without names, since this is an // extension in both Microsoft an GNU. @@ -1348,7 +1348,7 @@ Sema::DeclPtrTy Sema::ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) { << DS.getSourceRange(); return DeclPtrTy(); } - + return DeclPtrTy::make(Tag); } @@ -1382,7 +1382,7 @@ bool Sema::InjectAnonymousStructOrUnionMembers(Scope *S, DeclContext *Owner, // The names of the members of an anonymous union shall be // distinct from the names of any other entity in the // scope in which the anonymous union is declared. - unsigned diagKind + unsigned diagKind = AnonRecord->isUnion()? diag::err_anonymous_union_member_redecl : diag::err_anonymous_struct_member_redecl; Diag((*F)->getLocation(), diagKind) @@ -1403,7 +1403,7 @@ bool Sema::InjectAnonymousStructOrUnionMembers(Scope *S, DeclContext *Owner, = (*F)->getType()->getAs<RecordType>()) { RecordDecl *InnerRecord = InnerRecordType->getDecl(); if (InnerRecord->isAnonymousStructOrUnion()) - Invalid = Invalid || + Invalid = Invalid || InjectAnonymousStructOrUnionMembers(S, Owner, InnerRecord); } } @@ -1414,7 +1414,7 @@ bool Sema::InjectAnonymousStructOrUnionMembers(Scope *S, DeclContext *Owner, /// ActOnAnonymousStructOrUnion - Handle the declaration of an /// anonymous structure or union. Anonymous unions are a C++ feature /// (C++ [class.union]) and a GNU C extension; anonymous structures -/// are a GNU C and GNU C++ extension. +/// are a GNU C and GNU C++ extension. Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, RecordDecl *Record) { DeclContext *Owner = Record->getDeclContext(); @@ -1424,7 +1424,7 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, Diag(Record->getLocation(), diag::ext_anonymous_union); else if (!Record->isUnion()) Diag(Record->getLocation(), diag::ext_anonymous_struct); - + // C and C++ require different kinds of checks for anonymous // structs/unions. bool Invalid = false; @@ -1436,7 +1436,7 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, // global namespace shall be declared static. if (DS.getStorageClassSpec() != DeclSpec::SCS_static && (isa<TranslationUnitDecl>(Owner) || - (isa<NamespaceDecl>(Owner) && + (isa<NamespaceDecl>(Owner) && cast<NamespaceDecl>(Owner)->getDeclName()))) { Diag(Record->getLocation(), diag::err_anonymous_union_not_static); Invalid = true; @@ -1444,13 +1444,13 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, // Recover by adding 'static'. DS.SetStorageClassSpec(DeclSpec::SCS_static, SourceLocation(), PrevSpec, DiagID); - } + } // C++ [class.union]p3: // A storage class is not allowed in a declaration of an // anonymous union in a class scope. else if (DS.getStorageClassSpec() != DeclSpec::SCS_unspecified && isa<RecordDecl>(Owner)) { - Diag(DS.getStorageClassSpecLoc(), + Diag(DS.getStorageClassSpecLoc(), diag::err_anonymous_union_with_storage_spec); Invalid = true; @@ -1459,7 +1459,7 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, PrevSpec, DiagID); } - // C++ [class.union]p2: + // C++ [class.union]p2: // The member-specification of an anonymous union shall only // define non-static data members. [Note: nested types and // functions cannot be declared within an anonymous union. ] @@ -1505,7 +1505,7 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, Invalid = true; } } - } + } if (!Record->isUnion() && !Owner->isRecord()) { Diag(Record->getLocation(), diag::err_anonymous_struct_not_member) @@ -1513,11 +1513,11 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, Invalid = true; } - // Create a declaration for this anonymous struct/union. + // Create a declaration for this anonymous struct/union. NamedDecl *Anon = 0; if (RecordDecl *OwningClass = dyn_cast<RecordDecl>(Owner)) { Anon = FieldDecl::Create(Context, OwningClass, Record->getLocation(), - /*IdentifierInfo=*/0, + /*IdentifierInfo=*/0, Context.getTypeDeclType(Record), // FIXME: Type source info. /*DInfo=*/0, @@ -1545,7 +1545,7 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, } Anon = VarDecl::Create(Context, Owner, Record->getLocation(), - /*IdentifierInfo=*/0, + /*IdentifierInfo=*/0, Context.getTypeDeclType(Record), // FIXME: Type source info. /*DInfo=*/0, @@ -1569,7 +1569,7 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, // members of this anonymous struct/union type, because otherwise // the members could be injected twice: once by DeclContext when it // builds its lookup table, and once by - // InjectAnonymousStructOrUnionMembers. + // InjectAnonymousStructOrUnionMembers. Record->setAnonymousStructOrUnion(true); if (Invalid) @@ -1643,8 +1643,8 @@ static bool isNearlyMatchingFunction(ASTContext &Context, return true; } -Sema::DeclPtrTy -Sema::HandleDeclarator(Scope *S, Declarator &D, +Sema::DeclPtrTy +Sema::HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists, bool IsFunctionDefinition) { DeclarationName Name = GetNameForDeclarator(D); @@ -1658,13 +1658,13 @@ Sema::HandleDeclarator(Scope *S, Declarator &D, << D.getDeclSpec().getSourceRange() << D.getSourceRange(); return DeclPtrTy(); } - + // The scope passed in may not be a decl scope. Zip up the scope tree until // we find one that is. while ((S->getFlags() & Scope::DeclScope) == 0 || (S->getFlags() & Scope::TemplateParamScope) != 0) S = S->getParent(); - + // If this is an out-of-line definition of a member of a class template // or class template partial specialization, we may need to rebuild the // type specifier in the declarator. See RebuildTypeInCurrentInstantiation() @@ -1689,7 +1689,7 @@ Sema::HandleDeclarator(Scope *S, Declarator &D, DS.UpdateTypeRep(T.getAsOpaquePtr()); } } - + DeclContext *DC; NamedDecl *PrevDecl; NamedDecl *New; @@ -1721,24 +1721,24 @@ Sema::HandleDeclarator(Scope *S, Declarator &D, NameKind = LookupRedeclarationWithLinkage; DC = CurContext; - PrevDecl = LookupName(S, Name, NameKind, true, + PrevDecl = LookupName(S, Name, NameKind, true, NameKind == LookupRedeclarationWithLinkage, D.getIdentifierLoc()); } else { // Something like "int foo::x;" DC = computeDeclContext(D.getCXXScopeSpec(), true); - + if (!DC) { // If we could not compute the declaration context, it's because the // declaration context is dependent but does not refer to a class, // class template, or class template partial specialization. Complain // and return early, to avoid the coming semantic disaster. - Diag(D.getIdentifierLoc(), + Diag(D.getIdentifierLoc(), diag::err_template_qualified_declarator_no_match) << (NestedNameSpecifier*)D.getCXXScopeSpec().getScopeRep() << D.getCXXScopeSpec().getRange(); return DeclPtrTy(); } - + PrevDecl = LookupQualifiedName(DC, Name, LookupOrdinaryName, true); // C++ 7.3.1.2p2: @@ -1762,11 +1762,11 @@ Sema::HandleDeclarator(Scope *S, Declarator &D, // // In this case, PrevDecl will point to the overload set // containing the two f's declared in X, but neither of them - // matches. + // matches. // First check whether we named the global scope. if (isa<TranslationUnitDecl>(DC)) { - Diag(D.getIdentifierLoc(), diag::err_invalid_declarator_global_scope) + Diag(D.getIdentifierLoc(), diag::err_invalid_declarator_global_scope) << Name << D.getCXXScopeSpec().getRange(); } else if (!CurContext->Encloses(DC)) { // The qualifying scope doesn't enclose the original declaration. @@ -1775,7 +1775,7 @@ Sema::HandleDeclarator(Scope *S, Declarator &D, SourceRange R = D.getCXXScopeSpec().getRange(); if (isa<FunctionDecl>(CurContext)) Diag(L, diag::err_invalid_declarator_in_function) << Name << R; - else + else Diag(L, diag::err_invalid_declarator_scope) << Name << cast<NamedDecl>(DC) << R; D.setInvalidType(); @@ -1784,10 +1784,10 @@ Sema::HandleDeclarator(Scope *S, Declarator &D, if (PrevDecl && PrevDecl->isTemplateParameter()) { // Maybe we will complain about the shadowed template parameter. - if (!D.isInvalidType()) + if (!D.isInvalidType()) if (DiagnoseTemplateParameterShadow(D.getIdentifierLoc(), PrevDecl)) D.setInvalidType(); - + // Just pretend that we didn't see the previous declaration. PrevDecl = 0; } @@ -1806,26 +1806,26 @@ Sema::HandleDeclarator(Scope *S, Declarator &D, Diag(D.getIdentifierLoc(), diag::err_template_typedef); return DeclPtrTy(); } - + New = ActOnTypedefDeclarator(S, D, DC, R, DInfo, PrevDecl, Redeclaration); } else if (R->isFunctionType()) { - New = ActOnFunctionDeclarator(S, D, DC, R, DInfo, PrevDecl, + New = ActOnFunctionDeclarator(S, D, DC, R, DInfo, PrevDecl, move(TemplateParamLists), IsFunctionDefinition, Redeclaration); } else { - New = ActOnVariableDeclarator(S, D, DC, R, DInfo, PrevDecl, + New = ActOnVariableDeclarator(S, D, DC, R, DInfo, PrevDecl, move(TemplateParamLists), Redeclaration); } if (New == 0) return DeclPtrTy(); - + // If this has an identifier and is not an invalid redeclaration, // add it to the scope stack. if (Name && !(Redeclaration && New->isInvalidDecl())) PushOnScopeChains(New, S); - + return DeclPtrTy::make(New); } @@ -1857,7 +1857,7 @@ static QualType TryToFixInvalidVariablyModifiedType(QualType T, // FIXME: We should probably handle this case if (VLATy->getElementType()->isVariablyModifiedType()) return QualType(); - + Expr::EvalResult EvalResult; if (!VLATy->getSizeExpr() || !VLATy->getSizeExpr()->Evaluate(EvalResult, Context) || @@ -1884,7 +1884,7 @@ static QualType TryToFixInvalidVariablyModifiedType(QualType T, /// \brief Register the given locally-scoped external C declaration so /// that it can be found later for redeclarations -void +void Sema::RegisterLocallyScopedExternCDecl(NamedDecl *ND, NamedDecl *PrevDecl, Scope *S) { assert(ND->getLexicalDeclContext()->isFunctionOrMethod() && @@ -1915,15 +1915,15 @@ void Sema::DiagnoseFunctionSpecifiers(Declarator& D) { // FIXME: We should probably indicate the identifier in question to avoid // confusion for constructs like "inline int a(), b;" if (D.getDeclSpec().isInlineSpecified()) - Diag(D.getDeclSpec().getInlineSpecLoc(), + Diag(D.getDeclSpec().getInlineSpecLoc(), diag::err_inline_non_function); if (D.getDeclSpec().isVirtualSpecified()) - Diag(D.getDeclSpec().getVirtualSpecLoc(), + Diag(D.getDeclSpec().getVirtualSpecLoc(), diag::err_virtual_non_function); if (D.getDeclSpec().isExplicitSpecified()) - Diag(D.getDeclSpec().getExplicitSpecLoc(), + Diag(D.getDeclSpec().getExplicitSpecLoc(), diag::err_explicit_non_function); } @@ -1952,7 +1952,7 @@ Sema::ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC, TypedefDecl *NewTD = ParseTypedefDecl(S, D, R); if (!NewTD) return 0; - + if (D.isInvalidType()) NewTD->setInvalidDecl(); @@ -1970,7 +1970,7 @@ Sema::ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC, QualType T = NewTD->getUnderlyingType(); if (T->isVariablyModifiedType()) { CurFunctionNeedsScopeChecking = true; - + if (S->getFnParent() == 0) { bool SizeIsNegative; QualType FixedTy = @@ -2017,13 +2017,13 @@ Sema::ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC, /// /// \param PrevDecl the previous declaration found by name /// lookup -/// +/// /// \param DC the context in which the new declaration is being /// declared. /// /// \returns true if PrevDecl is an out-of-scope previous declaration /// for a new delcaration with the same name. -static bool +static bool isOutOfScopePreviousDeclaration(NamedDecl *PrevDecl, DeclContext *DC, ASTContext &Context) { if (!PrevDecl) @@ -2057,10 +2057,10 @@ isOutOfScopePreviousDeclaration(NamedDecl *PrevDecl, DeclContext *DC, OuterContext = OuterContext->getParent(); while (!PrevOuterContext->isFileContext()) PrevOuterContext = PrevOuterContext->getParent(); - + // The previous declaration is in a different namespace, so it // isn't the same function. - if (OuterContext->getPrimaryContext() != + if (OuterContext->getPrimaryContext() != PrevOuterContext->getPrimaryContext()) return false; } @@ -2114,7 +2114,7 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC, // C99 6.9p2: The storage-class specifiers auto and register shall not // appear in the declaration specifiers in an external declaration. if (SC == VarDecl::Auto || SC == VarDecl::Register) { - + // If this is a register variable with an asm label specified, then this // is a GNU exte |