diff options
-rw-r--r-- | lib/Analysis/PrintfFormatString.cpp | 8 | ||||
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 492 | ||||
-rw-r--r-- | lib/Sema/SemaInit.cpp | 696 | ||||
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 456 | ||||
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 642 | ||||
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 170 | ||||
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 970 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateDeduction.cpp | 784 | ||||
-rw-r--r-- | lib/StaticAnalyzer/BasicStore.cpp | 1 |
9 files changed, 2109 insertions, 2110 deletions
diff --git a/lib/Analysis/PrintfFormatString.cpp b/lib/Analysis/PrintfFormatString.cpp index 4eea2bc239..db9f7f2c83 100644 --- a/lib/Analysis/PrintfFormatString.cpp +++ b/lib/Analysis/PrintfFormatString.cpp @@ -100,7 +100,7 @@ static PrintfSpecifierResult ParsePrintfSpecifier(FormatStringHandler &H, for ( ; I != E; ++I) { switch (*I) { default: hasMore = false; break; - case '\'': + case '\'': // FIXME: POSIX specific. Always accept? FS.setHasThousandsGrouping(I); break; @@ -281,7 +281,7 @@ const char *ConversionSpecifier::toString() const { ArgTypeResult PrintfSpecifier::getArgType(ASTContext &Ctx) const { const PrintfConversionSpecifier &CS = getConversionSpecifier(); - + if (!CS.consumesDataArgument()) return ArgTypeResult::Invalid(); @@ -292,7 +292,7 @@ ArgTypeResult PrintfSpecifier::getArgType(ASTContext &Ctx) const { default: return ArgTypeResult::Invalid(); } - + if (CS.isIntArg()) switch (LM.getKind()) { case LengthModifier::AsLongDouble: @@ -593,7 +593,7 @@ bool PrintfSpecifier::hasValidLeftJustified() const { bool PrintfSpecifier::hasValidThousandsGroupingPrefix() const { if (!HasThousandsGrouping) return true; - + switch (CS.getKind()) { case ConversionSpecifier::dArg: case ConversionSpecifier::iArg: diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 7e0cb8a433..53679d370c 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -31,7 +31,7 @@ using namespace clang; using namespace sema; ParsedType Sema::getDestructorName(SourceLocation TildeLoc, - IdentifierInfo &II, + IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, ParsedType ObjectTypePtr, @@ -71,11 +71,11 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, if (SS.isSet()) { NestedNameSpecifier *NNS = (NestedNameSpecifier *)SS.getScopeRep(); - + bool AlreadySearched = false; bool LookAtPrefix = true; // C++ [basic.lookup.qual]p6: - // If a pseudo-destructor-name (5.2.4) contains a nested-name-specifier, + // If a pseudo-destructor-name (5.2.4) contains a nested-name-specifier, // the type-names are looked up as types in the scope designated by the // nested-name-specifier. In a qualified-id of the form: // @@ -86,11 +86,11 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, // // ::opt nested-name-specifier class-name :: ~ class-name // - // the class-names are looked up as types in the scope designated by + // the class-names are looked up as types in the scope designated by // the nested-name-specifier. // // Here, we check the first case (completely) and determine whether the - // code below is permitted to look at the prefix of the + // code below is permitted to look at the prefix of the // nested-name-specifier. DeclContext *DC = computeDeclContext(SS, EnteringContext); if (DC && DC->isFileContext()) { @@ -99,7 +99,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, isDependent = false; } else if (DC && isa<CXXRecordDecl>(DC)) LookAtPrefix = false; - + // The second case from the C++03 rules quoted further above. NestedNameSpecifier *Prefix = 0; if (AlreadySearched) { @@ -116,7 +116,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, LookupCtx = computeDeclContext(SS, EnteringContext); isDependent = LookupCtx && LookupCtx->isDependentContext(); } - + LookInScope = false; } else if (ObjectTypePtr) { // C++ [basic.lookup.classref]p3: @@ -128,7 +128,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, // cv-qualified) T. LookupCtx = computeDeclContext(SearchType); isDependent = SearchType->isDependentType(); - assert((isDependent || !SearchType->isIncompleteType()) && + assert((isDependent || !SearchType->isIncompleteType()) && "Caller should have completed object type"); LookInScope = true; @@ -170,7 +170,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, // nested-name-specifier (if present) or the object type, then // this is the destructor for that class. // FIXME: This is a workaround until we get real drafting for core - // issue 399, for which there isn't even an obvious direction. + // issue 399, for which there isn't even an obvious direction. if (ClassTemplateDecl *Template = Found.getAsSingle<ClassTemplateDecl>()) { QualType MemberOfType; if (SS.isSet()) { @@ -182,7 +182,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, } if (MemberOfType.isNull()) MemberOfType = SearchType; - + if (MemberOfType.isNull()) continue; @@ -199,7 +199,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, continue; } - + // We're referring to an unresolved class template // specialization. Determine whether we class template we found // is the same as the template being specialized or, if we don't @@ -220,7 +220,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, // The class template we found has the same name as the // (dependent) template name being specialized. - if (DependentTemplateName *DepTemplate + if (DependentTemplateName *DepTemplate = SpecName.getAsDependentTemplateName()) { if (DepTemplate->isIdentifier() && DepTemplate->getIdentifier() == Template->getIdentifier()) @@ -253,7 +253,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, if (ObjectTypePtr) Diag(NameLoc, diag::err_ident_in_pseudo_dtor_not_a_type) - << &II; + << &II; else Diag(NameLoc, diag::err_destructor_class_name); @@ -266,9 +266,9 @@ ExprResult Sema::BuildCXXTypeId(QualType TypeInfoType, TypeSourceInfo *Operand, SourceLocation RParenLoc) { // C++ [expr.typeid]p4: - // The top-level cv-qualifiers of the lvalue expression or the type-id + // The top-level cv-qualifiers of the lvalue expression or the type-id // that is the operand of typeid are always ignored. - // If the type of the type-id is a class type or a reference to a class + // If the type of the type-id is a class type or a reference to a class // type, the class shall be completely-defined. Qualifiers Quals; QualType T @@ -277,7 +277,7 @@ ExprResult Sema::BuildCXXTypeId(QualType TypeInfoType, if (T->getAs<RecordType>() && RequireCompleteType(TypeidLoc, T, diag::err_incomplete_typeid)) return ExprError(); - + return Owned(new (Context) CXXTypeidExpr(TypeInfoType.withConst(), Operand, SourceRange(TypeidLoc, RParenLoc))); @@ -298,7 +298,7 @@ ExprResult Sema::BuildCXXTypeId(QualType TypeInfoType, // shall be completely-defined. if (RequireCompleteType(TypeidLoc, T, diag::err_incomplete_typeid)) return ExprError(); - + // C++ [expr.typeid]p3: // When typeid is applied to an expression other than an glvalue of a // polymorphic class type [...] [the] expression is an unevaluated @@ -310,11 +310,11 @@ ExprResult Sema::BuildCXXTypeId(QualType TypeInfoType, MarkVTableUsed(TypeidLoc, RecordD); } } - + // C++ [expr.typeid]p4: // [...] If the type of the type-id is a reference to a possibly - // cv-qualified type, the result of the typeid expression refers to a - // std::type_info object representing the cv-unqualified referenced + // cv-qualified type, the result of the typeid expression refers to a + // std::type_info object representing the cv-unqualified referenced // type. Qualifiers Quals; QualType UnqualT = Context.getUnqualifiedArrayType(T, Quals); @@ -323,16 +323,16 @@ ExprResult Sema::BuildCXXTypeId(QualType TypeInfoType, ImpCastExprToType(E, UnqualT, CK_NoOp, CastCategory(E)); } } - + // If this is an unevaluated operand, clear out the set of // declaration references we have been computing and eliminate any // temporaries introduced in its computation. if (isUnevaluatedOperand) ExprEvalContexts.back().Context = Unevaluated; - + return Owned(new (Context) CXXTypeidExpr(TypeInfoType.withConst(), E, - SourceRange(TypeidLoc, RParenLoc))); + SourceRange(TypeidLoc, RParenLoc))); } /// ActOnCXXTypeidOfType - Parse typeid( type-id ) or typeid (expression); @@ -351,9 +351,9 @@ Sema::ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc, if (!CXXTypeInfoDecl) return ExprError(Diag(OpLoc, diag::err_need_header_before_typeid)); } - + QualType TypeInfoType = Context.getTypeDeclType(CXXTypeInfoDecl); - + if (isType) { // The operand is a type; handle it as such. TypeSourceInfo *TInfo = 0; @@ -361,14 +361,14 @@ Sema::ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc, &TInfo); if (T.isNull()) return ExprError(); - + if (!TInfo) TInfo = Context.getTrivialTypeSourceInfo(T, OpLoc); return BuildCXXTypeId(TypeInfoType, OpLoc, TInfo, RParenLoc); } - // The operand is an expression. + // The operand is an expression. return BuildCXXTypeId(TypeInfoType, OpLoc, (Expr*)TyOrExpr, RParenLoc); } @@ -400,7 +400,7 @@ ExprResult Sema::BuildCXXUuidof(QualType TypeInfoType, if (!GetUuidAttrOfType(Operand->getType())) return ExprError(Diag(TypeidLoc, diag::err_uuidof_without_guid)); } - + // FIXME: add __uuidof semantic analysis for type operand. return Owned(new (Context) CXXUuidofExpr(TypeInfoType.withConst(), Operand, @@ -413,21 +413,21 @@ ExprResult Sema::BuildCXXUuidof(QualType TypeInfoType, Expr *E, SourceLocation RParenLoc) { if (!E->getType()->isDependentType()) { - if (!GetUuidAttrOfType(E->getType()) && + if (!GetUuidAttrOfType(E->getType()) && !E->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull)) return ExprError(Diag(TypeidLoc, diag::err_uuidof_without_guid)); } // FIXME: add __uuidof semantic analysis for type operand. return Owned(new (Context) CXXUuidofExpr(TypeInfoType.withConst(), E, - SourceRange(TypeidLoc, RParenLoc))); + SourceRange(TypeidLoc, RParenLoc))); } /// ActOnCXXUuidof - Parse __uuidof( type-id ) or __uuidof (expression); ExprResult Sema::ActOnCXXUuidof(SourceLocation OpLoc, SourceLocation LParenLoc, bool isType, void *TyOrExpr, SourceLocation RParenLoc) { - // If MSVCGuidDecl has not been cached, do the lookup. + // If MSVCGuidDecl has not been cached, do the lookup. if (!MSVCGuidDecl) { IdentifierInfo *GuidII = &PP.getIdentifierTable().get("_GUID"); LookupResult R(*this, GuidII, SourceLocation(), LookupTagName); @@ -435,10 +435,10 @@ Sema::ActOnCXXUuidof(SourceLocation OpLoc, SourceLocation LParenLoc, MSVCGuidDecl = R.getAsSingle<RecordDecl>(); if (!MSVCGuidDecl) return ExprError(Diag(OpLoc, diag::err_need_header_before_ms_uuidof)); - } - + } + QualType GuidType = Context.getTypeDeclType(MSVCGuidDecl); - + if (isType) { // The operand is a type; handle it as such. TypeSourceInfo *TInfo = 0; @@ -446,14 +446,14 @@ Sema::ActOnCXXUuidof(SourceLocation OpLoc, SourceLocation LParenLoc, &TInfo); if (T.isNull()) return ExprError(); - + if (!TInfo) TInfo = Context.getTrivialTypeSourceInfo(T, OpLoc); return BuildCXXUuidof(GuidType, OpLoc, TInfo, RParenLoc); } - // The operand is an expression. + // The operand is an expression. return BuildCXXUuidof(GuidType, OpLoc, (Expr*)TyOrExpr, RParenLoc); } @@ -486,12 +486,12 @@ bool Sema::CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *&E) { // A throw-expression initializes a temporary object, called the exception // object, the type of which is determined by removing any top-level // cv-qualifiers from the static type of the operand of throw and adjusting - // the type from "array of T" or "function returning T" to "pointer to T" + // the type from "array of T" or "function returning T" to "pointer to T" // or "pointer to function returning T", [...] if (E->getType().hasQualifiers()) ImpCastExprToType(E, E->getType().getUnqualifiedType(), CK_NoOp, CastCategory(E)); - + DefaultFunctionArrayConversion(E); // If the type of the exception would be an incomplete type or a pointer @@ -523,7 +523,7 @@ bool Sema::CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *&E) { InitializedEntity Entity = InitializedEntity::InitializeException(ThrowLoc, E->getType(), /*NRVO=*/false); - ExprResult Res = PerformMoveOrCopyInitialization(Entity, NRVOVariable, + ExprResult Res = PerformMoveOrCopyInitialization(Entity, NRVOVariable, QualType(), E); if (Res.isInvalid()) return true; @@ -547,7 +547,7 @@ bool Sema::CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *&E) { if (RD->hasTrivialDestructor()) return false; - CXXDestructorDecl *Destructor + CXXDestructorDecl *Destructor = const_cast<CXXDestructorDecl*>(LookupDestructor(RD)); if (!Destructor) return false; @@ -580,7 +580,7 @@ Sema::ActOnCXXTypeConstructExpr(ParsedType TypeRep, SourceLocation RParenLoc) { if (!TypeRep) return ExprError(); - + TypeSourceInfo *TInfo; QualType Ty = GetTypeFromParser(TypeRep, &TInfo); if (!TInfo) @@ -622,7 +622,7 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo, PDiag(diag::err_invalid_incomplete_type_use) << FullRange)) return ExprError(); - + if (RequireNonAbstractType(TyBeginLoc, Ty, diag::err_allocation_of_abstract_type)) return ExprError(); @@ -637,7 +637,7 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo, CastKind Kind = CK_Invalid; ExprValueKind VK = VK_RValue; CXXCastPath BasePath; - if (CheckCastTypes(TInfo->getTypeLoc().getSourceRange(), Ty, Exprs[0], + if (CheckCastTypes(TInfo->getTypeLoc().getSourceRange(), Ty, Exprs[0], Kind, VK, BasePath, /*FunctionalStyle=*/true)) return ExprError(); @@ -655,7 +655,7 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo, InitializationKind Kind = NumExprs ? InitializationKind::CreateDirect(TyBeginLoc, LParenLoc, RParenLoc) - : InitializationKind::CreateValue(TyBeginLoc, + : InitializationKind::CreateValue(TyBeginLoc, LParenLoc, RParenLoc); InitializationSequence InitSeq(*this, Entity, Kind, Exprs, NumExprs); ExprResult Result = InitSeq.Perform(*this, Entity, Kind, move(exprs)); @@ -673,7 +673,7 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo, ExprResult Sema::ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, - SourceLocation PlacementRParen, SourceRange TypeIdParens, + SourceLocation PlacementRParen, SourceRange TypeIdParens, Declarator &D, SourceLocation ConstructorLParen, MultiExprArg ConstructorArgs, SourceLocation ConstructorRParen) { @@ -715,10 +715,10 @@ Sema::ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, QualType AllocType = TInfo->getType(); if (D.isInvalidType()) return ExprError(); - + if (!TInfo) TInfo = Context.getTrivialTypeSourceInfo(AllocType); - + return BuildCXXNew(StartLoc, UseGlobal, PlacementLParen, move(PlacementArgs), @@ -766,9 +766,9 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, // C++ 5.3.4p6: "The expression in a direct-new-declarator shall have integral // or enumeration type with a non-negative value." if (ArraySize && !ArraySize->isTypeDependent()) { - + QualType SizeType = ArraySize->getType(); - + ExprResult ConvertedSize = ConvertToIntegralOrEnumerationType(StartLoc, ArraySize, PDiag(diag::err_array_size_not_integral), @@ -778,16 +778,16 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, PDiag(diag::note_array_size_conversion), PDiag(diag::err_array_size_ambiguous_conversion), PDiag(diag::note_array_size_conversion), - PDiag(getLangOptions().CPlusPlus0x? 0 + PDiag(getLangOptions().CPlusPlus0x? 0 : diag::ext_array_size_conversion)); if (ConvertedSize.isInvalid()) return ExprError(); - + ArraySize = ConvertedSize.take(); SizeType = ArraySize->getType(); if (!SizeType->isIntegralOrUnscopedEnumerationType()) return ExprError(); - + // Let's see if this is a constant < 0. If so, we reject it out of hand. // We don't care about special rules, so we tell the machinery it's not // evaluated - it gives us a result in more cases. @@ -795,17 +795,17 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, llvm::APSInt Value; if (ArraySize->isIntegerConstantExpr(Value, Context, 0, false)) { if (Value < llvm::APSInt( - llvm::APInt::getNullValue(Value.getBitWidth()), + llvm::APInt::getNullValue(Value.getBitWidth()), Value.isUnsigned())) return ExprError(Diag(ArraySize->getSourceRange().getBegin(), diag::err_typecheck_negative_array_size) << ArraySize->getSourceRange()); - + if (!AllocType->isDependentType()) { unsigned ActiveSizeBits = ConstantArrayType::getNumAddressingBits(Context, AllocType, Value); if (ActiveSizeBits > ConstantArrayType::getMaxSizeBits(Context)) { - Diag(ArraySize->getSourceRange().getBegin(), + Diag(ArraySize->getSourceRange().getBegin(), diag::err_array_too_large) << Value.toString(10) << ArraySize->getSourceRange(); @@ -818,11 +818,11 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, << ArraySize->getSourceRange() << FixItHint::CreateRemoval(TypeIdParens.getBegin()) << FixItHint::CreateRemoval(TypeIdParens.getEnd()); - + TypeIdParens = SourceRange(); } } - + ImpCastExprToType(ArraySize, Context.getSizeType(), CK_IntegralCast); } @@ -831,7 +831,7 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, FunctionDecl *OperatorDelete = 0; Expr **PlaceArgs = (Expr**)PlacementArgs.get(); unsigned NumPlaceArgs = PlacementArgs.size(); - + if (!AllocType->isDependentType() && !Expr::hasAnyTypeDependentArguments(PlaceArgs, NumPlaceArgs) && FindAllocationFunctions(StartLoc, @@ -842,21 +842,21 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, llvm::SmallVector<Expr *, 8> AllPlaceArgs; if (OperatorNew) { // Add default arguments, if any. - const FunctionProtoType *Proto = + const FunctionProtoType *Proto = OperatorNew->getType()->getAs<FunctionProtoType>(); - VariadicCallType CallType = + VariadicCallType CallType = Proto->isVariadic() ? VariadicFunction : VariadicDoesNotApply; - + if (GatherArgumentsForCall(PlacementLParen, OperatorNew, - Proto, 1, PlaceArgs, NumPlaceArgs, + Proto, 1, PlaceArgs, NumPlaceArgs, AllPlaceArgs, CallType)) return ExprError(); - + NumPlaceArgs = AllPlaceArgs.size(); if (NumPlaceArgs > 0) PlaceArgs = &AllPlaceArgs[0]; } - + bool Init = ConstructorLParen.isValid(); // --- Choosing a constructor --- CXXConstructorDecl *Constructor = 0; @@ -868,7 +868,7 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, if (NumConsArgs && (ResultType->isArrayType() || ArraySize)) { SourceRange InitRange(ConsArgs[0]->getLocStart(), ConsArgs[NumConsArgs - 1]->getLocEnd()); - + Diag(StartLoc, diag::err_new_array_init_args) << InitRange; return ExprError(); } @@ -883,21 +883,21 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, // initialized (8.5); if no initialization is performed, // the object has indeterminate value = !Init? InitializationKind::CreateDefault(TypeRange.getBegin()) - // - Otherwise, the new-initializer is interpreted according to the + // - Otherwise, the new-initializer is interpreted according to the // initialization rules of 8.5 for direct-initialization. : InitializationKind::CreateDirect(TypeRange.getBegin(), - ConstructorLParen, + ConstructorLParen, ConstructorRParen); - + InitializedEntity Entity = InitializedEntity::InitializeNew(StartLoc, AllocType); InitializationSequence InitSeq(*this, Entity, Kind, ConsArgs, NumConsArgs); - ExprResult FullInit = InitSeq.Perform(*this, Entity, Kind, + ExprResult FullInit = InitSeq.Perform(*this, Entity, Kind, move(ConstructorArgs)); if (FullInit.isInvalid()) return ExprError(); - - // FullInit is our initializer; walk through it to determine if it's a + + // FullInit is our initializer; walk through it to determine if it's a // constructor call, which CXXNewExpr handles directly. if (Expr *FullInitExpr = (Expr *)FullInit.get()) { if (CXXBindTemporaryExpr *Binder @@ -917,12 +917,12 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, } else { // No initialization required. } - + // Take the converted arguments and use them for the new expression. NumConsArgs = ConvertedConstructorArgs.size(); ConsArgs = (Expr **)ConvertedConstructorArgs.take(); } - + // Mark the new and delete operators as referenced. if (OperatorNew) MarkDeclarationReferenced(StartLoc, OperatorNew); @@ -930,10 +930,10 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, MarkDeclarationReferenced(StartLoc, OperatorDelete); // FIXME: Also check that the destructor is accessible. (C++ 5.3.4p16) - + PlacementArgs.release(); ConstructorArgs.release(); - + return Owned(new (Context) CXXNewExpr(Context, UseGlobal, OperatorNew, PlaceArgs, NumPlaceArgs, TypeIdParens, ArraySize, Constructor, Init, @@ -969,7 +969,7 @@ bool Sema::CheckAllocatedType(QualType AllocType, SourceLocation Loc, else if (AllocType->isVariablyModifiedType()) return Diag(Loc, diag::err_variably_modified_new_type) << AllocType; - + return false; } @@ -1099,7 +1099,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, // same number of parameters and, after parameter transformations // (8.3.5), all parameter types except the first are // identical. [...] - // + // // To perform this comparison, we compute the function type that // the deallocation function should have, and use that type both // for template argument deduction and for comparison purposes. @@ -1111,7 +1111,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, = OperatorNew->getType()->getAs<FunctionProtoType>(); llvm::SmallVector<QualType, 4> ArgTypes; - ArgTypes.push_back(Context.VoidPtrTy); + ArgTypes.push_back(Context.VoidPtrTy); for (unsigned I = 1, N = Proto->getNumArgs(); I < N; ++I) ArgTypes.push_back(Proto->getArgType(I)); @@ -1123,11 +1123,11 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, ArgTypes.size(), EPI); } - for (LookupResult::iterator D = FoundDelete.begin(), + for (LookupResult::iterator D = FoundDelete.begin(), DEnd = FoundDelete.end(); D != DEnd; ++D) { FunctionDecl *Fn = 0; - if (FunctionTemplateDecl *FnTmpl + if (FunctionTemplateDecl *FnTmpl = dyn_cast<FunctionTemplateDecl>((*D)->getUnderlyingDecl())) { // Perform template argument deduction to try to match the // expected function type. @@ -1144,7 +1144,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, // C++ [expr.new]p20: // [...] Any non-placement deallocation function matches a // non-placement allocation function. [...] - for (LookupResult::iterator D = FoundDelete.begin(), + for (LookupResult::iterator D = FoundDelete.begin(), DEnd = FoundDelete.end(); D != DEnd; ++D) { if (FunctionDecl *Fn = dyn_cast<FunctionDecl>((*D)->getUnderlyingDecl())) @@ -1169,7 +1169,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, if (NumPlaceArgs && getLangOptions().CPlusPlus0x && isNonPlacementDeallocationFunction(OperatorDelete)) { Diag(StartLoc, diag::err_placement_new_non_placement_delete) - << SourceRange(PlaceArgs[0]->getLocStart(), + << SourceRange(PlaceArgs[0]->getLocStart(), PlaceArgs[NumPlaceArgs - 1]->getLocEnd()); Diag(OperatorDelete->getLocation(), diag::note_previous_decl) << DeleteName; @@ -1203,7 +1203,7 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, R.suppressDiagnostics(); OverloadCandidateSet Candidates(StartLoc); - for (LookupResult::iterator Alloc = R.begin(), AllocEnd = R.end(); + for (LookupResult::iterator Alloc = R.begin(), AllocEnd = R.end(); Alloc != AllocEnd; ++Alloc) { // Even member operator new/delete are implicitly treated as // static, so don't use AddMemberCandidate. @@ -1242,7 +1242,7 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, Owned(Args[i])); if (Result.isInvalid()) return true; - + Args[i] = Result.takeAs<Expr>(); } Operator = FnDecl; @@ -1287,18 +1287,18 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, void Sema::DeclareGlobalNewDelete() { if (GlobalNewDeleteDeclared) return; - + // C++ [basic.std.dynamic]p2: - // [...] The following allocation and deallocation functions (18.4) are - // implicitly declared in global scope in each translation unit of a + // [...] The following allocation and deallocation functions (18.4) are + // implicitly declared in global scope in each translation unit of a // program - // + // // void* operator new(std::size_t) throw(std::bad_alloc); - // void* operator new[](std::size_t) throw(std::bad_alloc); - // void operator delete(void*) throw(); + // void* operator new[](std::size_t) throw(std::bad_alloc); + // void operator delete(void*) throw(); // void operator delete[](void*) throw(); // - // These implicit declarations introduce only the function names operator + // These implicit declarations introduce only the function names operator // new, operator new[], operator delete, operator delete[]. // // Here, we need to refer to std::bad_alloc, so we will implicitly declare @@ -1308,14 +1308,14 @@ void Sema::DeclareGlobalNewDelete() { if (!StdBadAlloc) { // The "std::bad_alloc" class has not yet been declared, so build it // implicitly. - StdBadAlloc = CXXRecordDecl::Create(Context, TTK_Class, - getOrCreateStdNamespace(), - SourceLocation(), - &PP.getIdentifierTable().get("bad_alloc"), + StdBadAlloc = CXXRecordDecl::Create(Context, TTK_Class, + getOrCreateStdNamespace(), + SourceLocation(), + &PP.getIdentifierTable().get("bad_alloc"), SourceLocation(), 0); getStdBadAlloc()->setImplicit(true); } - + GlobalNewDeleteDeclared = true; QualType VoidPtr = Context.getPointerType(Context.VoidTy); @@ -1365,7 +1365,7 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name, } QualType BadAllocType; - bool HasBadAllocExceptionSpec + bool HasBadAllocExceptionSpec = (Name.getCXXOverloadedOperator() == OO_New || Name.getCXXOverloadedOperator() == OO_Array_New); if (HasBadAllocExceptionSpec) { @@ -1379,17 +1379,17 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name, EPI.NumExceptions = 1; EPI.Exceptions = &BadAllocType; } - + QualType FnType = Context.getFunctionType(Return, &Argument, 1, EPI); FunctionDecl *Alloc = FunctionDecl::Create(Context, GlobalCtx, SourceLocation(), Name, FnType, /*TInfo=*/0, SC_None, SC_None, false, true); Alloc->setImplicit(); - + if (AddMallocAttr) Alloc->addAttr(::new (Context) MallocAttr(SourceLocation(), Context)); - + ParmVarDecl *Param = ParmVarDecl::Create(Context, Alloc, SourceLocation(), 0, Argument, /*TInfo=*/0, SC_None, @@ -1408,7 +1408,7 @@ bool Sema::FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, LookupResult Found(*this, Name, StartLoc, LookupOrdinaryName); // Try to find operator delete/operator delete[] in class scope. LookupQualifiedName(Found, RD); - + if (Found.isAmbiguous()) return true; @@ -1452,7 +1452,7 @@ bool Sema::FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, if (!Found.empty()) { Diag(StartLoc, diag::err_no_suitable_delete_member_function_found) << Name << RD; - + for (LookupResult::iterator F = Found.begin(), FEnd = Found.end(); F != FEnd; ++F) Diag((*F)->getUnderlyingDecl()->getLocation(), @@ -1464,7 +1464,7 @@ bool Sema::FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, // Look for a global declaration. DeclareGlobalNewDelete(); DeclContext *TUDecl = Context.getTranslationUnitDecl(); - + CXXNullPtrLiteralExpr Null(Context.VoidPtrTy, SourceLocation()); Expr* DeallocArgs[1]; DeallocArgs[0] = &Null; @@ -1497,14 +1497,14 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, QualType Type = Ex->getType(); if (const RecordType *Record = Type->getAs<RecordType>()) { - if (RequireCompleteType(StartLoc, Type, + if (RequireCompleteType(StartLoc, Type, PDiag(diag::err_delete_incomplete_class_type))) return ExprError(); - + llvm::SmallVector<CXXConversionDecl*, 4> ObjectPtrConversions; CXXRecordDecl *RD = cast<CXXRecordDecl>(Record->getDecl()); - const UnresolvedSetImpl *Conversions = RD->getVisibleConversionFunctions(); + const UnresolvedSetImpl *Conversions = RD->getVisibleConversionFunctions(); for (UnresolvedSetImpl::iterator I = Conversions->begin(), E = Conversions->end(); I != E; ++I) { NamedDecl *D = I.getDecl(); @@ -1514,9 +1514,9 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, // Skip over templated conversion functions; they aren't considered. if (isa<FunctionTemplateDecl>(D)) continue; - + CXXConversionDecl *Conv = cast<CXXConversionDecl>(D); - + QualType ConvType = Conv->getConversionType().getNonReferenceType(); if (const PointerType *ConvPtrType = ConvType->getAs<PointerType>()) if (ConvPtrType->getPointeeType()->isIncompleteOrObjectType()) @@ -1547,7 +1547,7 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, QualType Pointee = Type->getAs<PointerType>()->getPointeeType(); if (Pointee->isVoidType() && !isSFINAEContext()) { - // The C++ standard bans deleting a pointer to a non-object type, which + // The C++ standard bans deleting a pointer to a non-object type, which // effectively bans deletion of "void*". However, most compilers support // this, so we treat it as a warning unless we're in a SFINAE context. Diag(StartLoc, diag::ext_delete_void_ptr_operand) @@ -1562,11 +1562,11 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, return ExprError(); // C++ [expr.delete]p2: - // [Note: a pointer to a const type can be the operand of a - // delete-expression; it is not necessary to cast away the constness - // (5.2.11) of the pointer expression before it is used as the operand + // [Note: a pointer to a const type can be the operand of a + // delete-expression; it is not necessary to cast away the constness + // (5.2.11) of the pointer expression before it is used as the operand // of the delete-expression. ] - ImpCastExprToType(Ex, Context.getPointerType(Context.VoidTy), + ImpCastExprToType(Ex, Context.getPointerType(Context.VoidTy), CK_NoOp); if (Pointee->isArrayType() && !ArrayForm) { @@ -1583,10 +1583,10 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, if (const RecordType *RT = PointeeElem->getAs<RecordType>()) { CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl()); - if (!UseGlobal && + if (!UseGlobal && FindDeallocationFunction(StartLoc, RD, DeleteName, OperatorDelete)) return ExprError(); - + if (!RD->hasTrivialDestructor()) if (CXXDestructorDecl *Dtor = LookupDestructor(RD)) { MarkDeclarationReferenced(StartLoc, @@ -1594,7 +1594,7 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, DiagnoseUseOfDecl(Dtor, StartLoc); } } - + if (!OperatorDelete) { // Look for a global declaration. DeclareGlobalNewDelete(); @@ -1621,25 +1621,25 @@ ExprResult Sema::CheckConditionVariable(VarDecl *ConditionVar, SourceLocation StmtLoc, bool ConvertToBoolean) { QualType T = ConditionVar->getType(); - + // C++ [stmt.select]p2: // The declarator shall not specify a function or an array. if (T->isFunctionType()) - return ExprError(Diag(ConditionVar->getLocation(), + return ExprError(Diag(ConditionVar->getLocation(), diag::err_invalid_use_of_function_type) << ConditionVar->getSourceRange()); else if (T->isArrayType()) - return ExprError(Diag(ConditionVar->getLocation(), + return ExprError(Diag(ConditionVar->getLocation(), diag::err_invalid_use_of_array_type) << ConditionVar->getSourceRange()); Expr *Condition = DeclRefExpr::Create(Context, 0, SourceRange(), ConditionVar, - ConditionVar->getLocation(), + ConditionVar->getLocation(), ConditionVar->getType().getNonReferenceType(), VK_LValue); if (ConvertToBoolean && CheckBooleanCondition(Condition, StmtLoc)) return ExprError(); - + return Owned(Condition); } @@ -1687,7 +1687,7 @@ Sema::IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType) { return false; } -st |