diff options
author | Fangrui Song <maskray@google.com> | 2018-07-30 19:24:48 +0000 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2018-07-30 19:24:48 +0000 |
commit | abdbb605f2c3cbe63cd589da230f648535dff76b (patch) | |
tree | 5f8677c5a6cdf9e4aebd71560932f399f956f7cc /lib/Sema | |
parent | 19e630a4739c684e5848d2f926d0beb114bbce7b (diff) | |
download | clang-abdbb605f2c3cbe63cd589da230f648535dff76b.tar.gz |
Remove trailing space
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338291 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
34 files changed, 1509 insertions, 1509 deletions
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp index 82d9df25d9..ed240f4ed2 100644 --- a/lib/Sema/AnalysisBasedWarnings.cpp +++ b/lib/Sema/AnalysisBasedWarnings.cpp @@ -90,7 +90,7 @@ namespace { } S.Diag(L, diag) << R1 << R2; - + SourceLocation Open = SilenceableCondVal.getBegin(); if (Open.isValid()) { SourceLocation Close = SilenceableCondVal.getEnd(); @@ -330,7 +330,7 @@ static void EmitDiagForCXXThrowInNonThrowingFunc(Sema &S, SourceLocation OpLoc, S.Diag(FD->getLocation(), diag::note_throw_in_dtor) << !isa<CXXDestructorDecl>(FD) << !Ty->hasExceptionSpec() << FD->getExceptionSpecSourceRange(); - } else + } else S.Diag(FD->getLocation(), diag::note_throw_in_function) << FD->getExceptionSpecSourceRange(); } @@ -525,18 +525,18 @@ struct CheckFallThroughDiagnostics { bool isVirtualMethod = false; if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Func)) isVirtualMethod = Method->isVirtual(); - + // Don't suggest that template instantiations be marked "noreturn" bool isTemplateInstantiation = false; if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(Func)) isTemplateInstantiation = Function->isTemplateInstantiation(); - + if (!isVirtualMethod && !isTemplateInstantiation) D.diag_NeverFallThroughOrReturn = diag::warn_suggest_noreturn_function; else D.diag_NeverFallThroughOrReturn = 0; - + D.funMode = Function; return D; } @@ -1226,7 +1226,7 @@ static void DiagnoseSwitchLabelsFallthrough(Sema &S, AnalysisDeclContext &AC, bool PerFunction) { // Only perform this analysis when using [[]] attributes. There is no good // workflow for this warning when not using C++11. There is no good way to - // silence the warning (no attribute is available) unless we are using + // silence the warning (no attribute is available) unless we are using // [[]] attributes. One could use pragmas to silence the warning, but as a // general solution that is gross and not in the spirit of this warning. // @@ -1492,7 +1492,7 @@ class UninitValsDiagReporter : public UninitVariablesHandler { // order of diagnostics when calling flushDiagnostics(). typedef llvm::MapVector<const VarDecl *, MappedType> UsesMap; UsesMap uses; - + public: UninitValsDiagReporter(Sema &S) : S(S) {} ~UninitValsDiagReporter() override { flushDiagnostics(); } @@ -1508,11 +1508,11 @@ public: const UninitUse &use) override { getUses(vd).getPointer()->push_back(use); } - + void handleSelfInit(const VarDecl *vd) override { getUses(vd).setInt(true); } - + void flushDiagnostics() { for (const auto &P : uses) { const VarDecl *vd = P.first; @@ -1521,7 +1521,7 @@ public: UsesVec *vec = V.getPointer(); bool hasSelfInit = V.getInt(); - // Specially handle the case where we have uses of an uninitialized + // Specially handle the case where we have uses of an uninitialized // variable, but the root cause is an idiomatic self-init. We want // to report the diagnostic at the self-init since that is the root cause. if (!vec->empty() && hasSelfInit && hasAlwaysUninitializedUse(vec)) @@ -1551,7 +1551,7 @@ public: break; } } - + // Release the uses vector. delete vec; } @@ -1865,10 +1865,10 @@ namespace clang { namespace consumed { namespace { class ConsumedWarningsHandler : public ConsumedWarningsHandlerBase { - + Sema &S; DiagList Warnings; - + public: ConsumedWarningsHandler(Sema &S) : S(S) {} @@ -1889,28 +1889,28 @@ public: Warnings.emplace_back(std::move(Warning), OptionalNotes()); } - + void warnParamReturnTypestateMismatch(SourceLocation Loc, StringRef VariableName, StringRef ExpectedState, StringRef ObservedState) override { - + PartialDiagnosticAt Warning(Loc, S.PDiag( diag::warn_param_return_typestate_mismatch) << VariableName << ExpectedState << ObservedState); Warnings.emplace_back(std::move(Warning), OptionalNotes()); } - + void warnParamTypestateMismatch(SourceLocation Loc, StringRef ExpectedState, StringRef ObservedState) override { - + PartialDiagnosticAt Warning(Loc, S.PDiag( diag::warn_param_typestate_mismatch) << ExpectedState << ObservedState); Warnings.emplace_back(std::move(Warning), OptionalNotes()); } - + void warnReturnTypestateForUnconsumableType(SourceLocation Loc, StringRef TypeName) override { PartialDiagnosticAt Warning(Loc, S.PDiag( @@ -1918,28 +1918,28 @@ public: Warnings.emplace_back(std::move(Warning), OptionalNotes()); } - + void warnReturnTypestateMismatch(SourceLocation Loc, StringRef ExpectedState, StringRef ObservedState) override { - + PartialDiagnosticAt Warning(Loc, S.PDiag( diag::warn_return_typestate_mismatch) << ExpectedState << ObservedState); Warnings.emplace_back(std::move(Warning), OptionalNotes()); } - + void warnUseOfTempInInvalidState(StringRef MethodName, StringRef State, SourceLocation Loc) override { - + PartialDiagnosticAt Warning(Loc, S.PDiag( diag::warn_use_of_temp_in_invalid_state) << MethodName << State); Warnings.emplace_back(std::move(Warning), OptionalNotes()); } - + void warnUseInInvalidState(StringRef MethodName, StringRef VariableName, StringRef State, SourceLocation Loc) override { - + PartialDiagnosticAt Warning(Loc, S.PDiag(diag::warn_use_in_invalid_state) << MethodName << VariableName << State); @@ -2027,7 +2027,7 @@ AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P, flushDiagnostics(S, fscope); return; } - + const Stmt *Body = D->getBody(); assert(Body); @@ -2113,7 +2113,7 @@ AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P, if (!analyzed) flushDiagnostics(S, fscope); } - + // Warning: check missing 'return' if (P.enableCheckFallThrough) { const CheckFallThroughDiagnostics &CD = diff --git a/lib/Sema/CodeCompleteConsumer.cpp b/lib/Sema/CodeCompleteConsumer.cpp index 9c4d315a69..8af54b9939 100644 --- a/lib/Sema/CodeCompleteConsumer.cpp +++ b/lib/Sema/CodeCompleteConsumer.cpp @@ -49,7 +49,7 @@ bool CodeCompletionContext::wantConstructorResults() const { case CCC_ObjCMessageReceiver: case CCC_ParenthesizedExpression: return true; - + case CCC_TopLevel: case CCC_ObjCInterface: case CCC_ObjCImplementation: @@ -164,7 +164,7 @@ StringRef clang::getCompletionKindString(CodeCompletionContext::Kind Kind) { // Code completion string implementation //===----------------------------------------------------------------------===// -CodeCompletionString::Chunk::Chunk(ChunkKind Kind, const char *Text) +CodeCompletionString::Chunk::Chunk(ChunkKind Kind, const char *Text) : Kind(Kind), Text("") { switch (Kind) { case CK_TypedText: @@ -178,7 +178,7 @@ CodeCompletionString::Chunk::Chunk(ChunkKind Kind, const char *Text) case CK_Optional: llvm_unreachable("Optional strings cannot be created from text"); - + case CK_LeftParen: this->Text = "("; break; @@ -190,11 +190,11 @@ CodeCompletionString::Chunk::Chunk(ChunkKind Kind, const char *Text) case CK_LeftBracket: this->Text = "["; break; - + case CK_RightBracket: this->Text = "]"; break; - + case CK_LeftBrace: this->Text = "{"; break; @@ -206,11 +206,11 @@ CodeCompletionString::Chunk::Chunk(ChunkKind Kind, const char *Text) case CK_LeftAngle: this->Text = "<"; break; - + case CK_RightAngle: this->Text = ">"; break; - + case CK_Comma: this->Text = ", "; break; @@ -242,7 +242,7 @@ CodeCompletionString::Chunk::CreateText(const char *Text) { return Chunk(CK_Text, Text); } -CodeCompletionString::Chunk +CodeCompletionString::Chunk CodeCompletionString::Chunk::CreateOptional(CodeCompletionString *Optional) { Chunk Result; Result.Kind = CK_Optional; @@ -250,30 +250,30 @@ CodeCompletionString::Chunk::CreateOptional(CodeCompletionString *Optional) { return Result; } -CodeCompletionString::Chunk +CodeCompletionString::Chunk CodeCompletionString::Chunk::CreatePlaceholder(const char *Placeholder) { return Chunk(CK_Placeholder, Placeholder); } -CodeCompletionString::Chunk +CodeCompletionString::Chunk CodeCompletionString::Chunk::CreateInformative(const char *Informative) { return Chunk(CK_Informative, Informative); } -CodeCompletionString::Chunk +CodeCompletionString::Chunk CodeCompletionString::Chunk::CreateResultType(const char *ResultType) { return Chunk(CK_ResultType, ResultType); } -CodeCompletionString::Chunk +CodeCompletionString::Chunk CodeCompletionString::Chunk::CreateCurrentParameter( const char *CurrentParameter) { return Chunk(CK_CurrentParameter, CurrentParameter); } -CodeCompletionString::CodeCompletionString(const Chunk *Chunks, +CodeCompletionString::CodeCompletionString(const Chunk *Chunks, unsigned NumChunks, - unsigned Priority, + unsigned Priority, CXAvailabilityKind Availability, const char **Annotations, unsigned NumAnnotations, @@ -281,7 +281,7 @@ CodeCompletionString::CodeCompletionString(const Chunk *Chunks, const char *BriefComment) : NumChunks(NumChunks), NumAnnotations(NumAnnotations), Priority(Priority), Availability(Availability), - ParentName(ParentName), BriefComment(BriefComment) { + ParentName(ParentName), BriefComment(BriefComment) { assert(NumChunks <= 0xffff); assert(NumAnnotations <= 0xffff); @@ -308,17 +308,17 @@ const char *CodeCompletionString::getAnnotation(unsigned AnnotationNr) const { std::string CodeCompletionString::getAsString() const { std::string Result; llvm::raw_string_ostream OS(Result); - + for (iterator C = begin(), CEnd = end(); C != CEnd; ++C) { switch (C->Kind) { case CK_Optional: OS << "{#" << C->Optional->getAsString() << "#}"; break; case CK_Placeholder: OS << "<#" << C->Text << "#>"; break; - - case CK_Informative: + + case CK_Informative: case CK_ResultType: - OS << "[#" << C->Text << "#]"; + OS << "[#" << C->Text << "#]"; break; - + case CK_CurrentParameter: OS << "<#" << C->Text << "#>"; break; default: OS << C->Text; break; } @@ -350,7 +350,7 @@ StringRef CodeCompletionTUInfo::getParentName(const DeclContext *DC) { const NamedDecl *ND = dyn_cast<NamedDecl>(DC); if (!ND) return {}; - + // Check whether we've already cached the parent name. StringRef &CachedParentName = ParentNames[DC]; if (!CachedParentName.empty()) @@ -368,7 +368,7 @@ StringRef CodeCompletionTUInfo::getParentName(const DeclContext *DC) { if (ND->getIdentifier()) Contexts.push_back(DC); } - + DC = DC->getParent(); } @@ -382,11 +382,11 @@ StringRef CodeCompletionTUInfo::getParentName(const DeclContext *DC) { else { OS << "::"; } - + const DeclContext *CurDC = Contexts[I-1]; if (const ObjCCategoryImplDecl *CatImpl = dyn_cast<ObjCCategoryImplDecl>(CurDC)) CurDC = CatImpl->getCategoryDecl(); - + if (const ObjCCategoryDecl *Cat = dyn_cast<ObjCCategoryDecl>(CurDC)) { const ObjCInterfaceDecl *Interface = Cat->getClassInterface(); if (!Interface) { @@ -395,13 +395,13 @@ StringRef CodeCompletionTUInfo::getParentName(const DeclContext *DC) { CachedParentName = StringRef((const char *)(uintptr_t)~0U, 0); return {}; } - + OS << Interface->getName() << '(' << Cat->getName() << ')'; } else { OS << cast<NamedDecl>(CurDC)->getName(); } } - + CachedParentName = AllocatorRef->CopyString(OS.str()); } @@ -413,7 +413,7 @@ CodeCompletionString *CodeCompletionBuilder::TakeString() { sizeof(CodeCompletionString) + sizeof(Chunk) * Chunks.size() + sizeof(const char *) * Annotations.size(), alignof(CodeCompletionString)); - CodeCompletionString *Result + CodeCompletionString *Result = new (Mem) CodeCompletionString(Chunks.data(), Chunks.size(), Priority, Availability, Annotations.data(), Annotations.size(), @@ -459,14 +459,14 @@ void CodeCompletionBuilder::AddChunk(CodeCompletionString::ChunkKind CK, void CodeCompletionBuilder::addParentContext(const DeclContext *DC) { if (DC->isTranslationUnit()) return; - + if (DC->isFunctionOrMethod()) return; - + const NamedDecl *ND = dyn_cast<NamedDecl>(DC); if (!ND) return; - + ParentName = getCodeCompletionTUInfo().getParentName(DC); } @@ -492,11 +492,11 @@ CodeCompleteConsumer::OverloadCandidate::getFunctionType() const { switch (Kind) { case CK_Function: return Function->getType()->getAs<FunctionType>(); - + case CK_FunctionTemplate: return FunctionTemplate->getTemplatedDecl()->getType() ->getAs<FunctionType>(); - + case CK_FunctionType: return Type; } @@ -526,13 +526,13 @@ bool PrintingCodeCompleteConsumer::isResultFilteredOut(StringRef Filter, llvm_unreachable("Unknown code completion result Kind."); } -void +void PrintingCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &SemaRef, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults) { std::stable_sort(Results, Results + NumResults); - + StringRef Filter = SemaRef.getPreprocessor().getCodeCompletionFilter(); // Print the results. @@ -545,7 +545,7 @@ PrintingCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &SemaRef, OS << *Results[I].Declaration; if (Results[I].Hidden) OS << " (Hidden)"; - if (CodeCompletionString *CCS + if (CodeCompletionString *CCS = Results[I].CreateCodeCompletionString(SemaRef, Context, getAllocator(), CCTUInfo, @@ -574,14 +574,14 @@ PrintingCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &SemaRef, } OS << '\n'; break; - + case CodeCompletionResult::RK_Keyword: OS << Results[I].Keyword << '\n'; break; - + case CodeCompletionResult::RK_Macro: OS << Results[I].Macro->getName(); - if (CodeCompletionString *CCS + if (CodeCompletionString *CCS = Results[I].CreateCodeCompletionString(SemaRef, Context, getAllocator(), CCTUInfo, @@ -590,9 +590,9 @@ PrintingCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &SemaRef, } OS << '\n'; break; - + case CodeCompletionResult::RK_Pattern: - OS << "Pattern : " + OS << "Pattern : " << Results[I].Pattern->getAsString() << '\n'; break; } @@ -624,7 +624,7 @@ static std::string getOverloadAsString(const CodeCompletionString &CCS) { return OS.str(); } -void +void PrintingCodeCompleteConsumer::ProcessOverloadCandidates(Sema &SemaRef, unsigned CurrentArg, OverloadCandidate *Candidates, @@ -655,19 +655,19 @@ void CodeCompletionResult::computeCursorKindAndAvailability(bool Accessible) { break; } LLVM_FALLTHROUGH; - + case RK_Declaration: { // Set the availability based on attributes. switch (getDeclAvailability(Declaration)) { case AR_Available: case AR_NotYetIntroduced: - Availability = CXAvailability_Available; + Availability = CXAvailability_Available; break; - + case AR_Deprecated: Availability = CXAvailability_Deprecated; break; - + case AR_Unavailable: Availability = CXAvailability_NotAvailable; break; @@ -676,11 +676,11 @@ void CodeCompletionResult::computeCursorKindAndAvailability(bool Accessible) { if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(Declaration)) if (Function->isDeleted()) Availability = CXAvailability_NotAvailable; - + CursorKind = getCursorKindForDecl(Declaration); if (CursorKind == CXCursor_UnexposedDecl) { - // FIXME: Forward declarations of Objective-C classes and protocols - // are not directly exposed, but we want code completion to treat them + // FIXME: Forward declarations of Objective-C classes and protocols + // are not directly exposed, but we want code completion to treat them // like a definition. if (isa<ObjCInterfaceDecl>(Declaration)) CursorKind = CXCursor_ObjCInterfaceDecl; @@ -717,9 +717,9 @@ StringRef CodeCompletionResult::getOrderedName(std::string &Saved) const { // Handle declarations below. break; } - + DeclarationName Name = Declaration->getDeclName(); - + // If the name is a simple identifier (by far the common case), or a // zero-argument selector, just return a reference to that identifier. if (IdentifierInfo *Id = Name.getAsIdentifierInfo()) @@ -728,12 +728,12 @@ StringRef CodeCompletionResult::getOrderedName(std::string &Saved) const { if (IdentifierInfo *Id = Name.getObjCSelector().getIdentifierInfoForSlot(0)) return Id->getName(); - + Saved = Name.getAsString(); return Saved; } - -bool clang::operator<(const CodeCompletionResult &X, + +bool clang::operator<(const CodeCompletionResult &X, const CodeCompletionResult &Y) { std::string XSaved, YSaved; StringRef XStr = X.getOrderedName(XSaved); @@ -741,11 +741,11 @@ bool clang::operator<(const CodeCompletionResult &X, int cmp = XStr.compare_lower(YStr); if (cmp) return cmp < 0; - + // If case-insensitive comparison fails, try case-sensitive comparison. cmp = XStr.compare(YStr); if (cmp) return cmp < 0; - + return false; } diff --git a/lib/Sema/DeclSpec.cpp b/lib/Sema/DeclSpec.cpp index ccca5d37ea..b22eea2b36 100644 --- a/lib/Sema/DeclSpec.cpp +++ b/lib/Sema/DeclSpec.cpp @@ -44,7 +44,7 @@ void UnqualifiedId::setConstructorTemplateId(TemplateIdAnnotation *TemplateId) { EndLocation = TemplateId->RAngleLoc; } -void CXXScopeSpec::Extend(ASTContext &Context, SourceLocation TemplateKWLoc, +void CXXScopeSpec::Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL, SourceLocation ColonColonLoc) { Builder.Extend(Context, TemplateKWLoc, TL, ColonColonLoc); if (Range.getBegin().isInvalid()) @@ -56,23 +56,23 @@ void CXXScopeSpec::Extend(ASTContext &Context, SourceLocation TemplateKWLoc, } void CXXScopeSpec::Extend(ASTContext &Context, IdentifierInfo *Identifier, - SourceLocation IdentifierLoc, + SourceLocation IdentifierLoc, SourceLocation ColonColonLoc) { Builder.Extend(Context, Identifier, IdentifierLoc, ColonColonLoc); - + if (Range.getBegin().isInvalid()) Range.setBegin(IdentifierLoc); Range.setEnd(ColonColonLoc); - + assert(Range == Builder.getSourceRange() && "NestedNameSpecifierLoc range computation incorrect"); } void CXXScopeSpec::Extend(ASTContext &Context, NamespaceDecl *Namespace, - SourceLocation NamespaceLoc, + SourceLocation NamespaceLoc, SourceLocation ColonColonLoc) { Builder.Extend(Context, Namespace, NamespaceLoc, ColonColonLoc); - + if (Range.getBegin().isInvalid()) Range.setBegin(NamespaceLoc); Range.setEnd(ColonColonLoc); @@ -82,10 +82,10 @@ void CXXScopeSpec::Extend(ASTContext &Context, NamespaceDecl *Namespace, } void CXXScopeSpec::Extend(ASTContext &Context, NamespaceAliasDecl *Alias, - SourceLocation AliasLoc, + SourceLocation AliasLoc, SourceLocation ColonColonLoc) { Builder.Extend(Context, Alias, AliasLoc, ColonColonLoc); - + if (Range.getBegin().isInvalid()) Range.setBegin(AliasLoc); Range.setEnd(ColonColonLoc); @@ -94,12 +94,12 @@ void CXXScopeSpec::Extend(ASTContext &Context, NamespaceAliasDecl *Alias, "NestedNameSpecifierLoc range computation incorrect"); } -void CXXScopeSpec::MakeGlobal(ASTContext &Context, +void CXXScopeSpec::MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc) { Builder.MakeGlobal(Context, ColonColonLoc); - + Range = SourceRange(ColonColonLoc); - + assert(Range == Builder.getSourceRange() && "NestedNameSpecifierLoc range computation incorrect"); } @@ -116,7 +116,7 @@ void CXXScopeSpec::MakeSuper(ASTContext &Context, CXXRecordDecl *RD, "NestedNameSpecifierLoc range computation incorrect"); } -void CXXScopeSpec::MakeTrivial(ASTContext &Context, +void CXXScopeSpec::MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R) { Builder.MakeTrivial(Context, Qualifier, R); Range = R; @@ -139,11 +139,11 @@ SourceLocation CXXScopeSpec::getLastQualifierNameLoc() const { return Builder.getTemporary().getLocalBeginLoc(); } -NestedNameSpecifierLoc +NestedNameSpecifierLoc CXXScopeSpec::getWithLocInContext(ASTContext &Context) const { if (!Builder.getRepresentation()) return NestedNameSpecifierLoc(); - + return Builder.getWithLocInContext(Context); } @@ -232,7 +232,7 @@ DeclaratorChunk DeclaratorChunk::getFunction(bool hasProto, I.Fun.DeleteParams = true; } for (unsigned i = 0; i < NumParams; i++) - I.Fun.Params[i] = std::move(Params[i]); + I.Fun.Params[i] = std::move(Params[i]); } // Check what exception specification information we should actually store. @@ -323,7 +323,7 @@ bool Declarator::isDeclarationOfFunction() const { } llvm_unreachable("Invalid type chunk"); } - + switch (DS.getTypeSpecType()) { case TST_atomic: case TST_auto: @@ -369,20 +369,20 @@ bool Declarator::isDeclarationOfFunction() const { if (Expr *E = DS.getRepAsExpr()) return E->getType()->isFunctionType(); return false; - + case TST_underlyingType: case TST_typename: case TST_typeofType: { QualType QT = DS.getRepAsType().get(); if (QT.isNull()) return false; - + if (const LocInfoType *LIT = dyn_cast<LocInfoType>(QT)) QT = LIT->getType(); if (QT.isNull()) return false; - + return QT->isFunctionType(); } } @@ -438,8 +438,8 @@ template <class T> static bool BadSpecifier(T TNew, T TPrev, if (TNew != TPrev) DiagID = diag::err_invalid_decl_spec_combination; else - DiagID = IsExtension ? diag::ext_duplicate_declspec : - diag::warn_duplicate_declspec; + DiagID = IsExtension ? diag::ext_duplicate_declspec : + diag::warn_duplicate_declspec; return true; } @@ -970,7 +970,7 @@ bool DeclSpec::setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec, DiagID = diag::ext_duplicate_declspec; return true; } - + ModulePrivateLoc = Loc; return false; } @@ -1300,7 +1300,7 @@ bool DeclSpec::isMissingDeclaratorOk() { StorageClassSpec != DeclSpec::SCS_typedef; } -void UnqualifiedId::setOperatorFunctionId(SourceLocation OperatorLoc, +void UnqualifiedId::setOperatorFunctionId(SourceLocation OperatorLoc, OverloadedOperatorKind Op, SourceLocation SymbolLocations[3]) { Kind = UnqualifiedIdKind::IK_OperatorFunctionId; @@ -1309,7 +1309,7 @@ void UnqualifiedId::setOperatorFunctionId(SourceLocation OperatorLoc, OperatorFunctionId.Operator = Op; for (unsigned I = 0; I != 3; ++I) { OperatorFunctionId.SymbolLocations[I] = SymbolLocations[I].getRawEncoding(); - + if (SymbolLocations[I].isValid()) EndLocation = SymbolLocations[I]; } @@ -1321,7 +1321,7 @@ bool VirtSpecifiers::SetSpecifier(Specifier VS, SourceLocation Loc, FirstLocation = Loc; LastLocation = Loc; LastSpecifier = VS; - + if (Specifiers & VS) { PrevSpec = getSpecifierName(VS); return true; diff --git a/lib/Sema/DelayedDiagnostic.cpp b/lib/Sema/DelayedDiagnostic.cpp index 122b477d55..a064e492c0 100644 --- a/lib/Sema/DelayedDiagnostic.cpp +++ b/lib/Sema/DelayedDiagnostic.cpp @@ -59,8 +59,8 @@ DelayedDiagnostic::makeAvailability(AvailabilityResult AR, void DelayedDiagnostic::Destroy() { switch (Kind) { - case Access: - getAccessData().~AccessedEntity(); + case Access: + getAccessData().~AccessedEntity(); break; case Availability: diff --git a/lib/Sema/IdentifierResolver.cpp b/lib/Sema/IdentifierResolver.cpp index dbd52dee1e..dba56931d4 100644 --- a/lib/Sema/IdentifierResolver.cpp +++ b/lib/Sema/IdentifierResolver.cpp @@ -46,7 +46,7 @@ class IdentifierResolver::IdDeclInfoMap { IdDeclInfoPool(IdDeclInfoPool *Next) : Next(Next) {} }; - + IdDeclInfoPool *CurPool = nullptr; unsigned int CurIndex = POOL_SIZE; @@ -171,9 +171,9 @@ void IdentifierResolver::InsertDeclAfter(iterator Pos, NamedDecl *D) { DeclarationName Name = D->getDeclName(); if (IdentifierInfo *II = Name.getAsIdentifierInfo()) updatingIdentifier(*II); - + void *Ptr = Name.getFETokenInfo<void>(); - + if (!Ptr) { AddDecl(D); return; @@ -196,7 +196,7 @@ void IdentifierResolver::InsertDeclAfter(iterator Pos, NamedDecl *D) { return; } - // General case: insert the declaration at the appropriate point in the + // General case: insert the declaration at the appropriate point in the // list, which already has at least two elements. IdDeclInfo *IDI = toIdDeclInfo(Ptr); if (Pos.isIterator()) { @@ -231,7 +231,7 @@ IdentifierResolver::iterator IdentifierResolver::begin(DeclarationName Name) { if (IdentifierInfo *II = Name.getAsIdentifierInfo()) readingIdentifier(*II); - + void *Ptr = Name.getFETokenInfo<void>(); if (!Ptr) return end(); @@ -258,7 +258,7 @@ enum DeclMatchKind { } // namespace /// Compare two declarations to see whether they are different or, -/// if they are the same, whether the new declaration should replace the +/// if they are the same, whether the new declaration should replace the /// existing declaration. static DeclMatchKind compareDeclarations(NamedDecl *Existing, NamedDecl *New) { // If the declarations are identical, ignore the new one. @@ -289,40 +289,40 @@ static DeclMatchKind compareDeclarations(NamedDecl *Existing, NamedDecl *New) { for (auto RD : New->redecls()) { if (RD == Existing) return DMK_Replace; - + if (RD->isCanonicalDecl()) break; } - + return DMK_Ignore; } - + return DMK_Different; } bool IdentifierResolver::tryAddTopLevelDecl(NamedDecl *D, DeclarationName Name){ if (IdentifierInfo *II = Name.getAsIdentifierInfo()) readingIdentifier(*II); - + void *Ptr = Name.getFETokenInfo<void>(); - + if (!Ptr) { Name.setFETokenInfo(D); return true; } - + IdDeclInfo *IDI; - + if (isDeclPtr(Ptr)) { NamedDecl *PrevD = static_cast<NamedDecl*>(Ptr); - + switch (compareDeclarations(PrevD, D)) { case DMK_Different: break; - + case DMK_Ignore: return false; - + case DMK_Replace: Name.setFETokenInfo(D); return true; @@ -330,7 +330,7 @@ bool IdentifierResolver::tryAddTopLevelDecl(NamedDecl *D, DeclarationName Name){ Name.setFETokenInfo(nullptr); IDI = &(*IdDeclInfos)[Name]; - + // If the existing declaration is not visible in translation unit scope, // then add the new top-level declaration first. if (!PrevD->getDeclContext()->getRedeclContext()->isTranslationUnit()) { @@ -341,28 +341,28 @@ bool IdentifierResolver::tryAddTopLevelDecl(NamedDecl *D, DeclarationName Name){ IDI->AddDecl(D); } return true; - } - + } + IDI = toIdDeclInfo(Ptr); // See whether this declaration is identical to any existing declarations. // If not, find the right place to insert it. - for (IdDeclInfo::DeclsTy::iterator I = IDI->decls_begin(), + for (IdDeclInfo::DeclsTy::iterator I = IDI->decls_begin(), IEnd = IDI->decls_end(); I != IEnd; ++I) { - + switch (compareDeclarations(*I, D)) { case DMK_Different: break; - + case DMK_Ignore: return false; - + case DMK_Replace: *I = D; return true; } - + if (!(*I)->getDeclContext()->getRedeclContext()->isTranslationUnit()) { // We've found a declaration that is not visible from the translation // unit (it's in an inner scope). Insert our declaration here. @@ -370,7 +370,7 @@ bool IdentifierResolver::tryAddTopLevelDecl(NamedDecl *D, DeclarationName Name){ return true; } } - + // Add the declaration to the end. IDI->AddDecl(D); return true; @@ -378,13 +378,13 @@ bool IdentifierResolver::tryAddTopLevelDecl(NamedDecl *D, DeclarationName Name){ void IdentifierResolver::readingIdentifier(IdentifierInfo &II) { if (II.isOutOfDate()) - PP.getExternalSource()->updateOutOfDateIdentifier(II); + PP.getExternalSource()->updateOutOfDateIdentifier(II); } void IdentifierResolver::updatingIdentifier(IdentifierInfo &II) { if (II.isOutOfDate()) PP.getExternalSource()->updateOutOfDateIdentifier(II); - + if (II.isFromAST()) II.setFETokenInfoChangedSinceDeserialization(); } diff --git a/lib/Sema/MultiplexExternalSemaSource.cpp b/lib/Sema/MultiplexExternalSemaSource.cpp index 7e61ccbb10..50808effe0 100644 --- a/lib/Sema/MultiplexExternalSemaSource.cpp +++ b/lib/Sema/MultiplexExternalSemaSource.cpp @@ -121,7 +121,7 @@ void MultiplexExternalSemaSource::FindExternalLexicalDecls( Sources[i]->FindExternalLexicalDecls(DC, IsKindWeWant, Result); } -void MultiplexExternalSemaSource::FindFileRegionDecls(FileID File, +void MultiplexExternalSemaSource::FindFileRegionDecls(FileID File, unsigned Offset, unsigned Length, SmallVectorImpl<Decl *> &Decls){ @@ -179,13 +179,13 @@ bool MultiplexExternalSemaSource::DeclIsFromPCHWithObjectFile(const Decl *D) { } bool MultiplexExternalSemaSource::layoutRecordType(const RecordDecl *Record, - uint64_t &Size, + uint64_t &Size, uint64_t &Alignment, llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets, llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets, llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets){ for(size_t i = 0; i < Sources.size(); ++i) - if (Sources[i]->layoutRecordType(Record, Size, Alignment, FieldOffsets, + if (Sources[i]->layoutRecordType(Record, Size, Alignment, FieldOffsets, BaseOffsets, VirtualBaseOffsets)) return true; return false; @@ -243,10 +243,10 @@ void MultiplexExternalSemaSource::ReadMismatchingDeleteExpressions( Source->ReadMismatchingDeleteExpressions(Exprs); } -bool MultiplexExternalSemaSource::LookupUnqualified(LookupResult &R, Scope *S){ +bool MultiplexExternalSemaSource::LookupUnqualified(LookupResult &R, Scope *S){ for(size_t i = 0; i < Sources.size(); ++i) Sources[i]->LookupUnqualified(R, S); - + return !R.empty(); } @@ -255,13 +255,13 @@ void MultiplexExternalSemaSource::ReadTentativeDefinitions( for(size_t i = 0; i < Sources.size(); ++i) Sources[i]->ReadTentativeDefinitions(TentativeDefs); } - + void MultiplexExternalSemaSource::ReadUnusedFileScopedDecls( SmallVectorImpl<const DeclaratorDecl*> &Decls) { for(size_t i = 0; i < Sources.size(); ++i) Sources[i]->ReadUnusedFileScopedDecls(Decls); } - + void MultiplexExternalSemaSource::ReadDelegatingConstructors( SmallVectorImpl<CXXConstructorDecl*> &Decls) { for(size_t i = 0; i < Sources.size(); ++i) diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index d57473c561..49f3decc11 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -1500,7 +1500,7 @@ LambdaScopeInfo *Sema::getCurLambda(bool IgnoreNonLambdaCapturingScope) { return CurLSI; } -// We have a generic lambda if we parsed auto parameters, or we have +// We have a generic lambda if we parsed auto parameters, or we have // an associated template parameter list. LambdaScopeInfo *Sema::getCurGenericLambda() { if (LambdaScopeInfo *LSI = getCurLambda()) { diff --git a/lib/Sema/SemaAccess.cpp b/lib/Sema/SemaAccess.cpp index 9fbae2ca29..e06792cae7 100644 --- a/lib/Sema/SemaAccess.cpp +++ b/lib/Sema/SemaAccess.cpp @@ -152,8 +152,8 @@ struct AccessTarget : public AccessedEntity { : AccessedEntity(Entity) { initialize(); } - - AccessTarget(ASTContext &Context, + + AccessTarget(ASTContext &Context, MemberNonce _, CXXRecordDecl *NamingClass, DeclAccessPair FoundDecl, @@ -163,7 +163,7 @@ struct AccessTarget : public AccessedEntity { initialize(); } - AccessTarget(ASTContext &Context, + AccessTarget(ASTContext &Context, BaseNonce _, CXXRecordDecl *BaseClass, CXXRecordDecl *DerivedClass, @@ -777,7 +777,7 @@ static AccessResult HasAccess(Sema &S, // We interpret this as a restriction on [M3]. // In this part of the code, 'C' is just our context class ECRecord. - + // These rules are different if we don't have an instance context. if (!Target.hasInstanceContext()) { // If it's not an instance member, these restrictions don't apply. @@ -1272,8 +1272,8 @@ static void DiagnoseBadAccess(Sema &S, SourceLocation Loc, DiagnoseAccessPath(S, EC, Entity); } -/// MSVC has a bug where if during an using declaration name lookup, -/// the declaration found is unaccessible (private) and that declaration +/// MSVC has a bug where if during an using declaration name lookup, +/// the declaration found is unaccessible (private) and that declaration /// was bring into scope via another using declaration whose target /// declaration is accessible (public) then no error is generated. /// Example: @@ -1290,15 +1290,15 @@ static void DiagnoseBadAccess(Sema &S, SourceLocation Loc, /// using B::f; /// }; /// -/// Here, B::f is private so this should fail in Standard C++, but +/// Here, B::f is private so this should fail in Standard C++, but /// because B::f refers to A::f which is public MSVC accepts it. -static bool IsMicrosoftUsingDeclarationAccessBug(Sema& S, +static bool IsMicrosoftUsingDeclarationAccessBug(Sema& S, SourceLocation AccessLoc, AccessTarget &Entity) { if (UsingShadowDecl *Shadow = dyn_cast<UsingShadowDecl>(Entity.getTargetDecl())) { const NamedDecl *OrigDecl = Entity.getTargetDecl()->getUnderlyingDecl(); - if (Entity.getTargetDecl()->getAccess() == AS_private && + if (Entity.getTargetDecl()->getAccess() == AS_private && (OrigDecl->getAccess() == AS_public || OrigDecl->getAccess() == AS_protected)) { S.Diag(AccessLoc, diag::ext_ms_using_declaration_inaccessible) @@ -1536,7 +1536,7 @@ Sema::AccessResult Sema::CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E, Found.getAccess() == AS_public) return AR_accessible; - AccessTarget Entity(Context, AccessTarget::Member, E->getNamingClass(), + AccessTarget Entity(Context, AccessTarget::Member, E->getNamingClass(), Found, QualType()); Entity.setDiag(diag::err_access) << E->getSourceRange(); @@ -1691,7 +1691,7 @@ Sema::AccessResult Sema::CheckConstructorAccess(SourceLocation UseLoc, AccessEntity.setDiag(PD); return CheckAccess(*this, UseLoc, AccessEntity); -} +} /// Checks access to an overloaded operator new or delete. Sema::AccessResult Sema::CheckAllocationAccess(SourceLocation OpLoc, @@ -1823,7 +1823,7 @@ Sema::AccessResult Sema::CheckBaseClassAccess(SourceLocation AccessLoc, BaseD = cast<CXXRecordDecl>(Base->getAs<RecordType>()->getDecl()); DerivedD = cast<CXXRecordDecl>(Derived->getAs<RecordType>()->getDecl()); - AccessTarget Entity(Context, AccessTarget::Base, BaseD, DerivedD, + AccessTarget Entity(Context, AccessTarget::Base, BaseD, DerivedD, Path.Access); if (DiagID) Entity.setDiag(DiagID) << Derived << Base; @@ -1893,7 +1893,7 @@ bool Sema::IsSimplyAccessible(NamedDecl *Target, DeclContext *Ctx) { if (ObjCMethodDecl *MD = getCurMethodDecl()) ClassOfMethodDecl = MD->getClassInterface(); else if (FunctionDecl *FD = getCurFunctionDecl()) { - if (ObjCImplDecl *Impl + if (ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(FD->getLexicalDeclContext())) { if (ObjCImplementationDecl *IMPD = dyn_cast<ObjCImplementationDecl>(Impl)) @@ -1903,21 +1903,21 @@ bool Sema::IsSimplyAccessible(NamedDecl *Target, DeclContext *Ctx) { ClassOfMethodDecl = CatImplClass->getClassInterface(); } } - + // If we're not in an interface, this ivar is inaccessible. if (!ClassOfMethodDecl) return false; - + // If we're inside the same interface that owns the ivar, we're fine. if (declaresSameEntity(ClassOfMethodDecl, Ivar->getContainingInterface())) return true; - + // If the ivar is private, it's inaccessible. if (Ivar->getCanonicalAccessControl() == ObjCIvarDecl::Private) return false; - + return Ivar->getContainingInterface()->isSuperClassOf(ClassOfMethodDecl); } - + return true; } diff --git a/lib/Sema/SemaAttr.cpp b/lib/Sema/SemaAttr.cpp index 4f3cf4633c..1a8a000753 100644 --- a/lib/Sema/SemaAttr.cpp +++ b/lib/Sema/SemaAttr.cpp @@ -268,7 +268,7 @@ void Sema::DiagnoseUnterminatedPragmaPack() { } } -void Sema::ActOnPragmaMSStruct(PragmaMSStructKind Kind) { +void Sema::ActOnPragmaMSStruct(PragmaMSStructKind Kind) { MSStructPragmaOn = (Kind == PMSST_ON); } @@ -693,7 +693,7 @@ void Sema::AddRangeBasedOptnone(FunctionDecl *FD) { AddOptnoneAttributeIfNoConflicts(FD, OptimizeOffPragmaLocation); } -void Sema::AddOptnoneAttributeIfNoConflicts(FunctionDecl *FD, +void Sema::AddOptnoneAttributeIfNoConflicts(FunctionDecl *FD, SourceLocation Loc) { // Don't add a conflicting attribute. No diagnostic is needed. if (FD->hasAttr<MinSizeAttr>() || FD->hasAttr<AlwaysInlineAttr>()) diff --git a/lib/Sema/SemaCXXScopeSpec.cpp b/lib/Sema/SemaCXXScopeSpec.cpp index f2fad825c3..4e39d06754 100644 --- a/lib/Sema/SemaCXXScopeSpec.cpp +++ b/lib/Sema/SemaCXXScopeSpec.cpp @@ -401,18 +401,18 @@ bool Sema::isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS, isDependent = isDependentScopeSpecifier(SS); Found.setContextRange(SS.getRange()); } - + if (LookupCtx) { // Perform "qualified" name lookup into the declaration context we // computed, which is either the type of the base of a member access // expression or the declaration context associated with a prior // nested-name-specifier. - + // The declaration context must be complete. if (!LookupCtx->isDependentContext() && RequireCompleteDeclContext(SS, LookupCtx)) return false; - + LookupQualifiedName(Found, LookupCtx); } else if (isDependent) { return false; @@ -420,7 +420,7 @@ bool Sema::isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS, LookupName(Found, S); } Found.suppressDiagnostics(); - + return Found.getAsSingle<NamespaceDecl>(); } @@ -739,7 +739,7 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, = TLB.push<UnresolvedUsingTypeLoc>(T); UnresolvedTL.setNameLoc(IdInfo.IdentifierLoc); } else if (isa<SubstTemplateTypeParmType>(T)) { - SubstTemplateTypeParmTypeLoc TL + SubstTemplateTypeParmTypeLoc TL = TLB.push<SubstTemplateTypeParmTypeLoc>(T); TL.setNameLoc(IdInfo.IdentifierLoc); } else if (isa<SubstTemplateTypeParmPackType>(T)) { @@ -772,11 +772,11 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, } // In Microsoft mode, if we are within a templated function and we can't - // resolve Identifier, then extend the SS with Identifier. This will have - // the effect of resolving Identifier during template instantiation. + // resolve Identifier, then extend the SS with Identifier. This will have + // the effect of resolving Identifier during template instantiation. // The goal is to be able to resolve a function call whose // nested-name-specifier is located inside a dependent base class. - // Example: + // Example: // // class C { // public: @@ -850,7 +850,7 @@ bool Sema::ActOnCXXNestedNameSpecifierDecltype(CXXScopeSpec &SS, return true; if (!T->isDependentType() && !T->getAs<TagType>()) { - Diag(DS.getTypeSpecTypeLoc(), diag::err_expected_class_or_namespace) + Diag(DS.getTypeSpecTypeLoc(), diag::err_expected_class_or_namespace) << T << getLangOpts().CPlusPlus; return true; } @@ -891,7 +891,7 @@ bool Sema::ActOnCXXNestedNameSpecifier(Scope *S, bool EnteringContext) { if (SS.isInvalid()) return true; - + // Translate the parser's template argument list in our AST format. TemplateArgumentListInfo TemplateArgs(LAngleLoc, RAngleLoc); translateTemplateArguments(TemplateArgsIn, TemplateArgs); @@ -905,7 +905,7 @@ bool Sema::ActOnCXXNestedNameSpecifier(Scope *S, DTN->getQualifier(), DTN->getIdentifier(), TemplateArgs); - + // Create source-location information for this type. TypeLocBuilder Builder; DependentTemplateSpecializationTypeLoc SpecTL @@ -918,7 +918,7 @@ bool Sema::ActOnCXXNestedNameSpecifier(Scope *S, SpecTL.setRAngleLoc(RAngleLoc); for (unsigned I = 0, N = TemplateArgs.size(); I != N; ++I) SpecTL.setArgLocInfo(I, TemplateArgs[I].getLocInfo()); - + SS.Extend(Context, TemplateKWLoc, Builder.getTypeLocInContext(Context, T), CCLoc); return false; @@ -937,7 +937,7 @@ bool Sema::ActOnCXXNestedNameSpecifier(Scope *S, return true; } - // We were able to resolve the template name to an actual template. + // We were able to resolve the template name to an actual template. // Build an appropriate nested-name-specifier. QualType T = CheckTemplateIdType(Template.get(), TemplateNameLoc, TemplateArgs); @@ -971,7 +971,7 @@ bool Sema::ActOnCXXNestedNameSpecifier(Scope *S, namespace { /// A structure that stores a nested-name-specifier annotation, - /// including both the nested-name-specifier + /// including both the nested-name-specifier struct NestedNameSpecifierAnnotation { NestedNameSpecifier *NNS; }; @@ -991,14 +991,14 @@ void *Sema::SaveNestedNameSpecifierAnnotation(CXXScopeSpec &SS) { return Annotation; } -void Sema::RestoreNestedNameSpecifierAnnotation(void *AnnotationPtr, +void Sema::RestoreNestedNameSpecifierAnnotation(void *AnnotationPtr, SourceRange AnnotationRange, CXXScopeSpec &SS) { if (!AnnotationPtr) { SS.SetInvalid(AnnotationRange); return; } - + NestedNameSpecifierAnnotation *Annotation = static_cast<NestedNameSpecifierAnnotation *>(AnnotationPtr); SS.Adopt(NestedNameSpecifierLoc(Annotation->NNS, Annotation + 1)); @@ -1065,7 +1065,7 @@ bool Sema::ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS) { // it is a complete declaration context. if (!DC->isDependentContext() && RequireCompleteDeclContext(SS, DC)) return true; - + EnterDeclaratorContext(S, DC); // Rebuild the nested name specifier for the new scope. diff --git a/lib/Sema/SemaCast.cpp b/lib/Sema/SemaCast.cpp index b7f4629fba..57aac80f5a 100644 --- a/lib/Sema/SemaCast.cpp +++ b/lib/Sema/SemaCast.cpp @@ -205,13 +205,13 @@ static TryCastResult TryStaticMemberPointerUpcast(Sema &Self, ExprResult &SrcExp CXXCastPath &BasePath); static TryCastResult TryStaticImplicitCast(Sema &Self, ExprResult &SrcExpr, - QualType DestType, + QualType DestType, Sema::CheckedConversionKind CCK, SourceRange OpRange, unsigned &msg, CastKind &Kind, bool ListInitialization); static TryCastResult TryStaticCast(Sema &Self, ExprResult &SrcExpr, - QualType DestType, + QualType DestType, Sema::CheckedConversionKind CCK, SourceRange OpRange, unsigned &msg, CastKind &Kind, @@ -319,7 +319,7 @@ Sema::BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, return ExprError(); DiscardMisalignedMemberAddress(DestType.getTypePtr(), E); } - + return Op.complete(CXXStaticCastExpr::Create(Context, Op.ResultType, Op.ValueKind, Op.Kind, Op.SrcExpr.get(), &Op.BasePath, DestTInfo, @@ -573,11 +573,11 @@ CastsAwayConstness(Sema &Self, QualType SrcType, QualType DestType, "Destination type is not pointer or pointer to member."); } - QualType UnwrappedSrcType = Self.Context.getCanonicalType(SrcType), + QualType UnwrappedSrcType = Self.Context.getCanonicalType(SrcType), UnwrappedDestType = Self.Context.getCanonicalType(DestType); - // Find the qualifiers. We only care about cvr-qualifiers for the - // purpose of this check, because other qualifiers (address spaces, + // Find the qualifiers. We only care about cvr-qualifiers for the + // purpose of this check, because other qualifiers (address spaces, // Objective-C GC, etc.) are part of the type's identity. QualType PrevUnwrappedSrcType = UnwrappedSrcType; QualType PrevUnwrappedDestType = UnwrappedDestType; @@ -719,7 +719,7 @@ void CastOperation::CheckDynamicCast() { // C++0x 5.2.7p2: If T is a pointer type, v shall be an rvalue of a pointer to // complete class type, [...]. If T is an lvalue reference type, v shall be - // an lvalue of a complete class type, [...]. If T is an rvalue reference + // an lvalue of a complete class type, [...]. If T is an rvalue reference // type, v shall be an expression having a complete class type, [...] QualType SrcType = Self.Context.getCanonicalType(OrigSrcType); QualType SrcPointee; @@ -788,7 +788,7 @@ void CastOperation::CheckDynamicCast() { if (DestRecord && Self.IsDerivedFrom(OpRange.getBegin(), SrcPointee, DestPointee)) { if (Self.CheckDerivedToBaseConversion(SrcPointee, DestPointee, - OpRange.getBegin(), OpRange, + OpRange.getBegin(), OpRange, &BasePath)) { SrcExpr = ExprError(); return; @@ -950,15 +950,15 @@ void CastOperation::CheckReinterpretCast() { return; unsigned msg = diag::err_bad_cxx_cast_generic; - TryCastResult tcr = - TryReinterpretCast(Self, SrcExpr, DestType, + TryCastResult tcr = + TryReinterpretCast(Self, SrcExpr, DestType, /*CStyle*/false, OpRange, msg, Kind); if (tcr != TC_Success && msg != 0) { if (SrcExpr.isInvalid()) // if conversion failed, don't report another error return; if (SrcExpr.get()->getType() == Self.Context.OverloadTy) { - //FIXME: &f<int>; is overloaded and resolvable - Self.Diag(OpRange.getBegin(), diag::err_bad_reinterpret_cast_overload) + //FIXME: &f<int>; is overloaded and resolvable + Self.Diag(OpRange.getBegin(), diag::err_bad_reinterpret_cast_overload) << OverloadExpr::find(SrcExpr.get()).Expression->getName() << DestType << OpRange; Self.NoteAllOverloadCandidates(SrcExpr.get()); @@ -996,8 +996,8 @@ void CastOperation::CheckStaticCast() { Kind = CK_ToVoid; if (claimPlaceholder(BuiltinType::Overload)) { - Self.ResolveAndFixSingleFunctionTemplateSpecialization(SrcExpr, - false, // Decay Function to ptr + Self.ResolveAndFixSingleFunctionTemplateSpecialization(SrcExpr, + false, // Decay Function to ptr true, // Complain OpRange, DestType, diag::err_bad_static_cast_overload); if (SrcExpr.isInvalid()) @@ -1025,7 +1025,7 @@ void CastOperation::CheckStaticCast() { if (SrcExpr.get()->getType() == Self.Context.OverloadTy) { OverloadExpr* oe = OverloadExpr::find(SrcExpr.get()).Expression; Self.Diag(OpRange.getBegin(), diag::err_bad_static_cast_overload) - << oe->getName() << DestType << OpRange + << oe->getName() << DestType << OpRange << oe->getQualifierLoc().getSourceRange(); Self.NoteAllOverloadCandidates(SrcExpr.get()); } else { @@ -1048,15 +1048,15 @@ void CastOperation::CheckStaticCast() { /// possible. If @p CStyle, ignore access restrictions on hierarchy casting /// and casting away constness. static TryCastResult TryStaticCast(Sema &Self, ExprResult &SrcExpr, - QualType DestType, + QualType DestType, Sema::CheckedConversionKind CCK, SourceRange OpRange, unsigned &msg, CastKind &Kind, CXXCastPath &BasePath, bool ListInitialization) { // Determine whether we have the semantics of a C-style cast. - bool CStyle + bool CStyle = (CCK == Sema::CCK_CStyleCast || CCK == Sema::CCK_FunctionalCast); - + // The order the tests is not entirely arbitrary. There is one conversion // that can be handled in two different ways. Given: // struct A {}; @@ -1082,7 +1082,7 @@ static TryCastResult TryStaticCast(Sema &Self, ExprResult &SrcExpr, if (tcr != TC_NotApplicable) return tcr; - // C++11 [expr.static.cast]p3: + // C++11 [expr.static.cast]p3: // A glvalue of type "cv1 T1" can be cast to type "rvalue reference to cv2 // T2" if "cv2 T2" is reference-compatible with "cv1 T1". tcr = TryLValueToRValueCast(Self, SrcExpr.get(), DestType, CStyle, Kind, @@ -1098,7 +1098,7 @@ static TryCastResult TryStaticCast(Sema &Self, ExprResult &SrcExpr, return TC_Failed; if (tcr != TC_NotApplicable) return tcr; - + // C++ 5.2.9p6: May apply the reverse of any standard conversion, except // lvalue-to-rvalue, array-to-pointer, function-to-pointer, and boolean // conversions, subject to further restrictions. @@ -1126,7 +1126,7 @@ static TryCastResult TryStaticCast(Sema &Self, ExprResult &SrcExpr, } } } - + // Reverse integral promotion/conversion. All such conversions are themselves // again integral promotions or conversions and are thus already handled by // p2 (TryDirectInitialization above). @@ -1199,7 +1199,7 @@ static TryCastResult TryStaticCast(Sema &Self, ExprResult &SrcExpr, } } else if (DestType->isObjCObjectPointerType()) { - // allow both c-style cast and static_cast of objective-c pointers as + // allow both c-style cast and static_cast of objective-c pointers as // they are pervasive. Kind = CK_CPointerToObjCPointerCast; return TC_Success; @@ -1230,7 +1230,7 @@ static TryCastResult TryStaticCast(Sema &Self, ExprResult &SrcExpr, if (SrcPointer->getPointeeType()->getAs<RecordType>() && DestPointer->getPointeeType()->getAs<RecordType>()) msg = diag::err_bad_cxx_cast_unrelated_class; - + // We tried everything. Everything! Nothing works! :-( return TC_NotApplicable; } @@ -1284,11 +1284,11 @@ TryCastResult TryLValueToRValueCast(Sema &Self, Expr *SrcExpr, if (!Self.IsDerivedFrom(SrcExpr->getLocStart(), SrcExpr->getType(), R->getPointeeType(), Paths)) return TC_NotApplicable; - + Self.BuildBasePathArray(Paths, BasePath); } else Kind = CK_NoOp; - + return TC_Success; } @@ -1323,8 +1323,8 @@ TryStaticReferenceDowncast(Sema &Self, Expr *SrcExpr, QualType DestType, // FIXME: If the source is a prvalue, we should issue a warning (because the // cast always has undefined behavior), and for AST consistency, we should // materialize a temporary. - return TryStaticDowncast(Self, - Self.Context.getCanonicalType(SrcExpr->getType()), + return TryStaticDowncast(Self, + Self.Context.getCanonicalType(SrcExpr->getType()), Self.Context.getCanonicalType(DestPointee), CStyle, OpRange, SrcExpr->getType(), DestType, msg, Kind, BasePath); @@ -1355,9 +1355,9 @@ TryStaticPointerDowncast(Sema &Self, QualType SrcType, QualType DestType, return TC_NotApplicable; } - return TryStaticDowncast(Self, + return TryStaticDowncast(Self, Self.Context.getCanonicalType(SrcPointer->getPointeeType()), - Self.Context.getCanonicalType(DestPointer->getPointeeType()), + Self.Context.getCanonicalType(DestPointer->getPointeeType()), CStyle, OpRange, SrcType, DestType, msg, Kind, BasePath); } @@ -1368,7 +1368,7 @@ TryStaticPointerDowncast(Sema &Self, QualType SrcType, QualType DestType, TryCastResult TryStaticDowncast(Sema &Self, CanQualType SrcType, CanQualType DestType, bool CStyle, SourceRange OpRange, QualType OrigSrcType, - QualType OrigDestType, unsigned &msg, + QualType OrigDestType, unsigned &msg, CastKind &Kind, CXXCastPath &BasePath) { // We can only work with complete types. But don't complain if it doesn't work if (!Self.isCompleteType(OpRange.getBegin(), SrcType) || @@ -1434,7 +1434,7 @@ TryStaticDowncast(Sema &Self, CanQualType SrcType, CanQualType DestType, } Self.Diag(OpRange.getBegin(), diag::err_ambiguous_base_to_derived_cast) - << QualType(SrcType).getUnqualifiedType() + << QualType(SrcType).getUnqualifiedType() << QualType(DestType).getUnqualifiedType() << PathDisplayStr << OpRange; msg = 0; @@ -1478,8 +1478,8 @@ TryStaticDowncast(Sema &Self, CanQualType SrcType, CanQualType DestType, /// where B is a base class of D [...]. /// TryCastResult -TryStaticMemberPointerUpcast(Sema &Self, ExprResult &SrcExpr, QualType SrcType, - QualType DestType, bool CStyle, +TryStaticMemberPointerUpcast(Sema &Self, ExprResult &SrcExpr, QualType SrcType, + QualType DestType, bool CStyle, SourceRange OpRange, unsigned &msg, CastKind &Kind, CXXCastPath &BasePath) { @@ -1499,7 +1499,7 @@ TryStaticMemberPointerUpcast(Sema &Self, ExprResult &SrcExpr, QualType SrcType, WasOverloadedFunction = true; } } - + const MemberPointerType *SrcMemPtr = SrcType->getAs<MemberPointerType>(); if (!SrcMemPtr) { msg = diag::err_bad_static_cast_member_pointer_nonmp; @@ -1569,8 +1569,8 @@ TryStaticMemberPointerUpcast(Sema &Self, ExprResult &SrcExpr, QualType SrcType, if (WasOverloadedFunction) { // Resolve the address of the overloaded function again, this time // allowing complaints if something goes wrong. - FunctionDecl *Fn = Self.ResolveAddressOfOverloadedFunction(SrcExpr.get(), - DestType, + FunctionDecl *Fn = Self.ResolveAddressOfOverloadedFunction(SrcExpr.get(), + DestType, true, FoundOverload); if (!Fn) { @@ -1597,7 +1597,7 @@ TryStaticMemberPointerUpcast(Sema &Self, ExprResult &SrcExpr, QualType SrcType, /// @c static_cast if the declaration "T t(e);" is well-formed [...]. TryCastResult TryStaticImplicitCast(Sema &Self, ExprResult &SrcExpr, QualType DestType, - Sema::CheckedConversionKind CCK, + Sema::CheckedConversionKind CCK, SourceRange OpRange, unsigned &msg, CastKind &Kind, bool ListInitialization) { if (DestType->isRecordType()) { @@ -1625,26 +1625,26 @@ TryStaticImplicitCast(Sema &Self, ExprResult &SrcExpr, QualType DestType, InitializationSequence InitSeq(Self, Entity, InitKind, SrcExprRaw); // At this point of CheckStaticCast, if the destination is a reference, - // or the expression is an overload expression this has to work. + // or the expression is an overload expression this has to work. // There is no other way that works. // On the other hand, if we're checking a C-style cast, we've still got // the reinterpret_cast way. - bool CStyle + bool CStyle = (CCK == Sema::CCK_CStyleCast || CCK == Sema::CCK_FunctionalCast); if (InitSeq.Failed() && (CStyle || !DestType->isReferenceType())) return TC_NotApplicable; - + ExprResult Result = InitSeq.Perform(Self, Entity, InitKind, SrcExprRaw); if (Result.isInvalid()) { msg = 0; return TC_Failed; } - + if (InitSeq.isConstructorInitialization()) Kind = CK_ConstructorConversion; else Kind = CK_NoOp; - + SrcExpr = Result; return TC_Success; } @@ -1976,7 +1976,7 @@ static TryCastResult TryReinterpretCast(Sema &Self, ExprResult &SrcExpr, unsigned &msg, CastKind &Kind) { bool IsLValueCast = false; - + DestType = Self.Context.getCanonicalType(DestType); QualType SrcType = SrcExpr.get()->getType(); @@ -2019,7 +2019,7 @@ static TryCastResult TryReinterpretCast(Sema &Self, ExprResult &SrcExpr, // FIXME: Use a specific diagnostic for the rest of these cases. case OK_VectorComponent: inappropriate = "vector element"; break; case OK_ObjCProperty: inappropriate = "property expression"; break; - case OK_ObjCSubscript: inappropriate = "container subscripting expression"; + case OK_ObjCSubscript: inappropriate = "container subscripting expression"; break; } if (inappropriate) { @@ -2033,7 +2033,7 @@ static TryCastResult TryReinterpretCast(Sema &Self, ExprResult &SrcExpr, // This code does this transformation for the checked types. DestType = Self.Context.getPointerType(DestTypeTmp->getPointeeType()); SrcType = Self.Context.getPointerType(SrcType); - + IsLValueCast = true; } @@ -2121,18 +2121,18 @@ static TryCastResult TryReinterpretCast(Sema &Self, ExprResult &SrcExpr, msg = diag::err_bad_cxx_cast_scalar_to_vector_different_size; else msg = diag::err_bad_cxx_cast_vector_to_vector_different_size; - + return TC_Failed; } if (SrcType == DestType) { // C++ 5.2.10p2 has a note that mentions that, subject to all other // restrictions, a cast to the same type is allowed so long as it does not - // cast away constness. In C++98, the intent was not entirely clear here, + // cast away constness. In C++98, the intent was not entirely clear here, // since all other paragraphs explicitly forbid casts to the same type. // C++11 clarifies this case with p2. // - // The only allowed types are: integral, enumeration, pointer, or + // The only allowed types are: integral, enumeration, pointer, or // pointer-to-member types. We also won't restrict Obj-C pointers either. Kind = CK_NoOp; TryCastResult Result = TC_NotApplicable; @@ -2260,7 +2260,7 @@ static TryCastResult TryReinterpretCast(Sema &Self, ExprResult &SrcExpr, << OpRange; return SuccessResult; } - + // C++ 5.2.10p7: A pointer to an object can be explicitly converted to // a pointer to an object of different type. // Void pointers are not specified, but supported by every compiler out there. @@ -2296,7 +2296,7 @@ void CastOperation::CheckCXXCStyleCast(bool FunctionalStyle, if (claimPlaceholder(BuiltinType::Overload)) { Self.ResolveAndFixSingleFunctionTemplateSpecialization( - SrcExpr, /* Decay Function to ptr */ false, + SrcExpr, /* Decay Function to ptr */ false, /* Complain */ true, DestRange, DestType, diag::err_bad_cstyle_cast_overload); if (SrcExpr.isInvalid()) @@ -2404,7 +2404,7 @@ void CastOperation::CheckCXXCStyleCast(bool FunctionalStyle, } } -/// DiagnoseBadFunctionCast - Warn whenever a function call is cast to a +/// DiagnoseBadFunctionCast - Warn whenever a function call is cast to a /// non-matching type. Such as enum function call to int, int call to /// pointer; etc. Cast to 'void' is an exception. static void DiagnoseBadFunctionCast(Sema &Self, const ExprResult &SrcExpr, @@ -2412,10 +2412,10 @@ static void DiagnoseBadFunctionCast(Sema &Self, const ExprResult &SrcExpr, if (Self.Diags.isIgnored(diag::warn_bad_function_cast, SrcExpr.get()->getExprLoc())) return; - + if (!isa<CallExpr>(SrcExpr.get())) return; - + QualType SrcType = SrcExpr.get()->getType(); if (DestType.getUnqualifiedType()->isVoidType()) return; @@ -2434,7 +2434,7 @@ static void DiagnoseBadFunctionCast(Sema &Self, const ExprResult &SrcExpr, return; if (SrcType->isComplexIntegerType() && DestType->isComplexIntegerType()) return; - + Self.Diag(SrcExpr.get()->getExprLoc(), diag::warn_bad_function_cast) << SrcType << DestType << SrcExpr.get()->getSourceRange(); @@ -2641,26 +2641,26 @@ void CastOperation::CheckCStyleCast() { if (const PointerType *ExprPtr = SrcType->getAs<PointerType>()) { Qualifiers CastQuals = CastPtr->getPointeeType().getQualifiers(); Qualifiers ExprQuals = ExprPtr->getPointeeType().getQualifiers(); - if (CastPtr->getPointeeType()->isObjCLifetimeType() && + if (CastPtr->getPointeeType()->isObjCLifetimeType() && ExprPtr->getPointeeType()->isObjCLifetimeType() && !CastQuals.compatiblyIncludesObjCLifetime(ExprQuals)) { - Self.Diag(SrcExpr.get()->getLocStart(), + Self.Diag(SrcExpr.get()->getLocStart(), diag::err_typecheck_incompatible_ownership) << SrcType << DestType << Sema::AA_Casting << SrcExpr.get()->getSourceRange(); return; } } - } + } else if (!Self.CheckObjCARCUnavailableWeakConversion(DestType, SrcType)) { - Self.Diag(SrcExpr.get()->getLocStart(), + Self.Diag(SrcExpr.get()->getLocStart(), diag::err_arc_convesion_of_weak_unavailable) << 1 << SrcType << DestType << SrcExpr.get()->getSourceRange(); SrcExpr = ExprError(); return; } } - + DiagnoseCastOfObjCSEL(Self, SrcExpr, DestType); DiagnoseCallingConvCast(Self, SrcExpr, DestType, OpRange); DiagnoseBadFunctionCast(Self, SrcExpr, DestType); @@ -2714,7 +2714,7 @@ ExprResult Sema::BuildCStyleCastExpr(SourceLocation LPLoc, TypeSourceInfo *CastTypeInfo, SourceLocation RPLoc, Expr *CastExpr) { - CastOperation Op(*this, CastTypeInfo->getType(), CastExpr); + CastOperation Op(*this, CastTypeInfo->getType(), CastExpr); Op.DestRange = CastTypeInfo->getTypeLoc().getSourceRange(); Op.OpRange = SourceRange(LPLoc, CastExpr->getLocEnd()); diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 8d953b6ef3..93dbeab5b0 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -119,7 +119,7 @@ static bool checkArgCount(Sema &S, CallExpr *call, unsigned desiredArgCount) { // Highlight all the excess arguments. SourceRange range(call->getArg(desiredArgCount)->getLocStart(), call->getArg(argCount - 1)->getLocEnd()); - + return S.Diag(range.getBegin(), diag::err_typecheck_call_too_many_args) << 0 /*function call*/ << desiredArgCount << argCount << call->getArg(1)->getSourceRange(); @@ -888,18 +888,18 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, Context.GetBuiltinType(BuiltinID, Error, &ICEArguments); if (Error != ASTContext::GE_None) ICEArguments = 0; // Don't diagnose previously diagnosed errors. - + // If any arguments are required to be ICE's, check and diagnose. for (unsigned ArgNo = 0; ICEArguments != 0; ++ArgNo) { // Skip arguments not required to be ICE's. if ((ICEArguments & (1 << ArgNo)) == 0) continue; - + llvm::APSInt Result; if (SemaBuiltinConstantArg(TheCall, ArgNo, Result)) return true; ICEArguments &= ~(1 << ArgNo); } - + switch (BuiltinID) { case Builtin::BI__builtin___CFStringMakeConstantString: assert(TheCall->getNumArgs() == 1 && @@ -3850,7 +3850,7 @@ DiagnoseCStringFormatDirectiveInCFAPI(Sema &S, static bool isNonNullType(ASTContext &ctx, QualType type) { if (auto nullability = type->getNullability(ctx)) return *nullability == NullabilityKind::NonNull; - + return false; } @@ -3893,12 +3893,12 @@ static void CheckNonNullArguments(Sema &S, parms = FD->parameters(); else parms = cast<ObjCMethodDecl>(FDecl)->parameters(); - + unsigned ParamIndex = 0; for (ArrayRef<ParmVarDecl*>::iterator I = parms.begin(), E = parms.end(); I != E; ++I, ++ParamIndex) { const ParmVarDecl *PVD = *I; - if (PVD->hasAttr<NonNullAttr>() || + if (PVD->hasAttr<NonNullAttr>() || isNonNullType(S.Context, PVD->getType())) { if (NonNullArgs.empty()) NonNullArgs.resize(Args.size()); @@ -3920,7 +3920,7 @@ static void CheckNonNullArguments(Sema &S, // Dig out the function prototype, if there is one. Proto = type->getAs<FunctionProtoType>(); - } + } } // Fill in non-null argument information from the nullability @@ -3931,17 +3931,17 @@ static void CheckNonNullArguments(Sema &S, if (isNonNullType(S.Context, paramType)) { if (NonNullArgs.empty()) NonNullArgs.resize(Args.size()); - + NonNullArgs.set(Index); } - + ++Index; } } } // Check for non-null arguments. - for (unsigned ArgIndex = 0, ArgIndexEnd = NonNullArgs.size(); + for (unsigned ArgIndex = 0, ArgIndexEnd = NonNullArgs.size(); ArgIndex != ArgIndexEnd; ++ArgIndex) { if (NonNullArgs[ArgIndex]) CheckNonNullArgument(S, Args[ArgIndex], CallSiteLoc); @@ -4074,7 +4074,7 @@ bool Sema::CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall, return false; } -bool Sema::CheckObjCMethodCall(ObjCMethodDecl *Method, SourceLocation lbrac, +bool Sema::CheckObjCMethodCall(ObjCMethodDecl *Method, SourceLocation lbrac, ArrayRef<const Expr *> Args) { VariadicCallType CallType = Method->isVariadic() ? VariadicMethod : VariadicDoesNotApply; @@ -4577,7 +4577,7 @@ ExprResult Sema::SemaAtomicOpsOverloaded(ExprResult TheCallResult, AtomicExpr *AE = new (Context) AtomicExpr(TheCall->getCallee()->getLocStart(), SubExprs, ResultType, Op, TheCall->getRParenLoc()); - + if ((Op == AtomicExpr::AO__c11_atomic_load || Op == AtomicExpr::AO__c11_atomic_store || Op == AtomicExpr::AO__opencl_atomic_load || @@ -4744,52 +4744,52 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { bool WarnAboutSemanticsChange = false; switch (BuiltinID) { default: llvm_unreachable("Unknown overloaded atomic builtin!"); - case Builtin::BI__sync_fetch_and_add: + case Builtin::BI__sync_fetch_and_add: case Builtin::BI__sync_fetch_and_add_1: case Builtin::BI__sync_fetch_and_add_2: case Builtin::BI__sync_fetch_and_add_4: case Builtin::BI__sync_fetch_and_add_8: case Builtin::BI__sync_fetch_and_add_16: - BuiltinIndex = 0; + BuiltinIndex = 0; break; - - case Builtin::BI__sync_fetch_and_sub: + + case Builtin::BI__sync_fetch_and_sub: case Builtin::BI__sync_fetch_and_sub_1: case Builtin::BI__sync_fetch_and_sub_2: case Builtin::BI__sync_fetch_and_sub_4: case Builtin::BI__sync_fetch_and_sub_8: case Builtin::BI__sync_fetch_and_sub_16: - BuiltinIndex = 1; + BuiltinIndex = 1; break; - - case Builtin::BI__sync_fetch_and_or: + + case Builtin::BI__sync_fetch_and_or: case Builtin::BI__sync_fetch_and_or_1: case Builtin::BI__sync_fetch_and_or_2: case Builtin::BI__sync_fetch_and_or_4: case Builtin::BI__sync_fetch_and_or_8: case Builtin::BI__sync_fetch_and_or_16: - BuiltinIndex = 2; + BuiltinIndex = 2; break; - - case Builtin::BI__sync_fetch_and_and: + + case Builtin::BI__sync_fetch_and_and: case Builtin::BI__sync_fetch_and_and_1: case Builtin::BI__sync_fetch_and_and_2: case Builtin::BI__sync_fetch_and_and_4: case Builtin::BI__sync_fetch_and_and_8: case Builtin::BI__sync_fetch_and_and_16: - BuiltinIndex = 3; + BuiltinIndex = 3; break; - case Builtin::BI__sync_fetch_and_xor: + case Builtin::BI__sync_fetch_and_xor: case Builtin::BI__sync_fetch_and_xor_1: case Builtin::BI__sync_fetch_and_xor_2: case Builtin::BI__sync_fetch_and_xor_4: case Builtin::BI__sync_fetch_and_xor_8: case Builtin::BI__sync_fetch_and_xor_16: - BuiltinIndex = 4; + BuiltinIndex = 4; break; - case Builtin::BI__sync_fetch_and_nand: + case Builtin::BI__sync_fetch_and_nand: case Builtin::BI__sync_fetch_and_nand_1: case Builtin::BI__sync_fetch_and_nand_2: case Builtin::BI__sync_fetch_and_nand_4: @@ -4799,43 +4799,43 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { WarnAboutSemanticsChange = true; break; - case Builtin::BI__sync_add_and_fetch: + case Builtin::BI__sync_add_and_fetch: case Builtin::BI__sync_add_and_fetch_1: case Builtin::BI__sync_add_and_fetch_2: case Builtin::BI__sync_add_and_fetch_4: case Builtin::BI__sync_add_and_fetch_8: case Builtin::BI__sync_add_and_fetch_16: - BuiltinIndex = 6; + BuiltinIndex = 6; break; - - case Builtin::BI__sync_sub_and_fetch: + + case Builtin::BI__sync_sub_and_fetch: case Builtin::BI__sync_sub_and_fetch_1: case Builtin::BI__sync_sub_and_fetch_2: case Builtin::BI__sync_sub_and_fetch_4: case Builtin::BI__sync_sub_and_fetch_8: case Builtin::BI__sync_sub_and_fetch_16: - BuiltinIndex = 7; + BuiltinIndex = 7; break; - - case Builtin::BI__sync_and_and_fetch: + + case Builtin::BI__sync_and_and_fetch: case Builtin::BI__sync_and_and_fetch_1: case Builtin::BI__sync_and_and_fetch_2: case Builtin::BI__sync_and_and_fetch_4: case Builtin::BI__sync_and_and_fetch_8: case Builtin::BI__sync_and_and_fetch_16: - BuiltinIndex = 8; + BuiltinIndex = 8; break; - - case Builtin::BI__sync_or_and_fetch: + + case Builtin::BI__sync_or_and_fetch: case Builtin::BI__sync_or_and_fetch_1: case Builtin::BI__sync_or_and_fetch_2: case Builtin::BI__sync_or_and_fetch_4: case Builtin::BI__sync_or_and_fetch_8: case Builtin::BI__sync_or_and_fetch_16: - BuiltinIndex = 9; + BuiltinIndex = 9; break; - - case Builtin::BI__sync_xor_and_fetch: + + case Builtin::BI__sync_xor_and_fetch: case Builtin::BI__sync_xor_and_fetch_1: case Builtin::BI__sync_xor_and_fetch_2: case Builtin::BI__sync_xor_and_fetch_4: @@ -4844,7 +4844,7 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { BuiltinIndex = 10; break; - case Builtin::BI__sync_nand_and_fetch: + case Builtin::BI__sync_nand_and_fetch: case Builtin::BI__sync_nand_and_fetch_1: case Builtin::BI__sync_nand_and_fetch_2: case Builtin::BI__sync_nand_and_fetch_4: @@ -4863,7 +4863,7 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { BuiltinIndex = 12; NumFixed = 2; break; - + case Builtin::BI__sync_bool_compare_and_swap: case Builtin::BI__sync_bool_compare_and_swap_1: case Builtin::BI__sync_bool_compare_and_swap_2: @@ -4874,16 +4874,16 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { NumFixed = 2; ResultType = Context.BoolTy; break; - + case Builtin::BI__sync_lock_test_and_set: case Builtin::BI__sync_lock_test_and_set_1: case Builtin::BI__sync_lock_test_and_set_2: case Builtin::BI__sync_lock_test_and_set_4: case Builtin::BI__sync_lock_test_and_set_8: case Builtin::BI__sync_lock_test_and_set_16: - BuiltinIndex = 14; + BuiltinIndex = 14; break; - + case Builtin::BI__sync_lock_release: case Builtin::BI__sync_lock_release_1: case Builtin::BI__sync_lock_release_2: @@ -4894,14 +4894,14 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { NumFixed = 0; ResultType = Context.VoidTy; break; - - case Builtin::BI__sync_swap: + + case Builtin::BI__sync_swap: case Builtin::BI__sync_swap_1: case Builtin::BI__sync_swap_2: case Builtin::BI__sync_swap_4: case Builtin::BI__sync_swap_8: case Builtin::BI__sync_swap_16: - BuiltinIndex = 16; + BuiltinIndex = 16; break; } @@ -5410,7 +5410,7 @@ bool Sema::SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs) { } } } - + return false; } @@ -5787,13 +5787,13 @@ bool Sema::SemaBuiltinConstantArg(CallExpr *TheCall, int ArgNum, Expr *Arg = TheCall->getArg(ArgNum); DeclRefExpr *DRE =cast<DeclRefExpr>(TheCall->getCallee()->IgnoreParenCasts()); FunctionDecl *FDecl = cast<FunctionDecl>(DRE->getDecl()); - + if (Arg->isTypeDependent() || Arg->isValueDependent()) return false; - + if (!Arg->isIntegerConstantExpr(Result, Context)) return Diag(TheCall->getLocStart(), diag::err_constant_integer_arg_type) << FDecl->getDeclName() << Arg->getSourceRange(); - + return false; } @@ -5964,7 +5964,7 @@ bool Sema::SemaBuiltinLongjmp(CallExpr *TheCall) { // TODO: This is less than ideal. Overload this to take a value. if (SemaBuiltinConstantArg(TheCall, 1, Result)) return true; - + if (Result != 1) return Diag(TheCall->getLocStart(), diag::err_builtin_longjmp_invalid_val) << SourceRange(Arg->getLocStart(), Arg->getLocEnd()); @@ -6231,7 +6231,7 @@ checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef<const Expr *> Args, // cannot contain format specifiers and thus are not a security // liability. return SLCT_UncheckedLiteral; - + case Stmt::DeclRefExprClass: { const DeclRefExpr *DR = cast<DeclRefExpr>(E); @@ -6626,14 +6626,14 @@ protected: void HandlePositionalNonpositionalArgs(SourceLocation Loc, const char *startSpec, unsigned specifierLen); - + SourceRange getFormatStringRange(); CharSourceRange getSpecifierRange(const char *startSpecifier, unsigned specifierLen); SourceLocation getLocationOfByte(const char *x); const Expr *getDataArg(unsigned i) const; - + bool CheckNumArgs(const analyze_format_string::FormatSpecifier &FS, const analyze_format_string::ConversionSpecifier &CS, const char *startSpecifier, unsigned specifierLen, @@ -7052,7 +7052,7 @@ public: const char *startSpecifier, unsigned specifierLen); bool checkForCStrMembers(const analyze_printf::ArgType &AT, const Expr *E); - + void HandleEmptyObjCModifierFlag(const char *startFlag, unsigned flagLen) override; @@ -7061,7 +7061,7 @@ public: void HandleObjCFlagsWithNonObjCConversion(const char *flagsStart, const char *flagsEnd, - const char *conversionPosition) + const char *conversionPosition) override; }; @@ -7073,7 +7073,7 @@ bool CheckPrintfHandler::HandleInvalidPrintfConversionSpecifier( unsigned specifierLen) { const analyze_printf::PrintfConversionSpecifier &CS = FS.getConversionSpecifier(); - + return HandleInvalidConversionSpecifier(FS.getArgIndex(), getLocationOfByte(CS.getStart()), startSpecifier, specifierLen, @@ -7736,7 +7736,7 @@ CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS, CastFix << ")"; SmallVector<FixItHint,4> Hints; - if (!AT.matchesType(S.Context, IntendedTy) || ShouldNotPrintDirectly) + if (!AT.matchesType(S.Context, IntendedTy) || ShouldNotPrintDirectly) Hints.push_back(FixItHint::CreateReplacement(SpecRange, os.str())); if (const CStyleCastExpr *CCast = dyn_cast<CStyleCastExpr>(E)) { @@ -7777,7 +7777,7 @@ CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS, SpecRange, Hints); } else { // In this case, the expression could be printed using a different - // specifier, but we've decided that the specifier is probably correct + // specifier, but we've decided that the specifier is probably correct // and we should cast instead. Just use the normal warning message. EmitFormatDiagnostic( S.PDiag(diag::warn_format_conversion_argument_type_mismatch) @@ -7852,7 +7852,7 @@ CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS, //===--- CHECK: Scanf format string checking ------------------------------===// -namespace { +namespace { class CheckScanfHandler : public CheckFormatHandler { public: @@ -7872,7 +7872,7 @@ public: bool HandleScanfSpecifier(const analyze_scanf::ScanfSpecifier &FS, const char *startSpecifier, unsigned specifierLen) override; - + bool HandleInvalidScanfConversionSpecifier( const analyze_scanf::ScanfSpecifier &FS, const char *startSpecifier, @@ -7908,7 +7908,7 @@ bool CheckScanfHandler::HandleScanfSpecifier( const char *startSpecifier, unsigned specifierLen) { using namespace analyze_scanf; - using namespace analyze_format_string; + using namespace analyze_format_string; const ScanfConversionSpecifier &CS = FS.getConversionSpecifier(); @@ -7925,7 +7925,7 @@ bool CheckScanfHandler::HandleScanfSpecifier( return false; } } - + // Check if the field with is non-zero. const OptionalAmount &Amt = FS.getFieldWidth(); if (Amt.getHowSpecified() == OptionalAmount::Constant) { @@ -8981,7 +8981,7 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call, else if (BId == Builtin::BImemcmp) OperationType = 3; } - + DiagRuntimeBehavior( Dest->getExprLoc(), Dest, PDiag(diag::warn_dyn_class_memaccess) @@ -9035,7 +9035,7 @@ static const Expr *ignoreLiteralAdditions(const Expr *Ex, ASTContext &Ctx) { const Expr *RHS = BO->getRHS()->IgnoreParenCasts(); const Expr *LHS = BO->getLHS()->IgnoreParenCasts(); - + if (isa<IntegerLiteral>(RHS)) Ex = LHS; else if (isa<IntegerLiteral>(LHS)) @@ -9077,7 +9077,7 @@ void Sema::CheckStrlcpycatArguments(const CallExpr *Call, if (CheckMemorySizeofForComparison(*this, SizeArg, FnName, Call->getLocStart(), Call->getRParenLoc())) return; - + // Look for 'strlcpy(dst, x, sizeof(x))' if (const Expr *Ex = getSizeOfExprArg(SizeArg)) CompareWithSrc = Ex; @@ -9100,16 +9100,16 @@ void Sema::CheckStrlcpycatArguments(const CallExpr *Call, const DeclRefExpr *SrcArgDRE = dyn_cast<DeclRefExpr>(SrcArg); if (!SrcArgDRE) return; - + const DeclRefExpr *CompareWithSrcDRE = dyn_cast<DeclRefExpr>(CompareWithSrc); - if (!CompareWithSrcDRE || + if (!CompareWithSrcDRE || SrcArgDRE->getDecl() != CompareWithSrcDRE->getDecl()) return; - + const Expr *OriginalSizeArg = Call->getArg(2); Diag(CompareWithSrcDRE->getLocStart(), diag::warn_strlcpycat_wrong_size) << OriginalSizeArg->getSourceRange() << FnName; - + // Output a FIXIT hint if the destination is an array (rather than a // pointer to an array). This could be enhanced to handle some // pointers if we know the actual size, like if DstArg is 'array+2' @@ -9123,7 +9123,7 @@ void Sema::CheckStrlcpycatArguments(const CallExpr *Call, OS << "sizeof("; DstArg->printPretty(OS, nullptr, getPrintingPolicy()); OS << ")"; - + Diag(OriginalSizeArg->getLocStart(), diag::note_strlcpycat_wrong_size) << FixItHint::CreateReplacement(OriginalSizeArg->getSourceRange(), OS.str()); @@ -10271,7 +10271,7 @@ static void AnalyzeAssignment(Sema &S, BinaryOperator *E) { } /// Diagnose an implicit cast; purely a helper for CheckImplicitConversion. -static void DiagnoseImpCast(Sema &S, Expr *E, QualType SourceType, QualType T, +static void DiagnoseImpCast(Sema &S, Expr *E, QualType SourceType, QualType T, SourceLocation CContext, unsigned diag, bool pruneControlFlow = false) { if (pruneControlFlow) { @@ -10876,7 +10876,7 @@ CheckImplicitConversion(Sema &S, Expr *E, QualType T, SourceLocation CC, // We also want to warn about it in -Wconversion. // So if -Wconversion is off, use a completely identical diagnostic // in the sign-compare group. - // The conditional-checking code will + // The conditional-checking code will if (ICContext) { DiagID = diag::warn_impcast_integer_sign_conditional; *ICContext = true; @@ -10897,7 +10897,7 @@ CheckImplicitConversion(Sema &S, Expr *E, QualType T, SourceLocation CC, Source = S.Context.getCanonicalType(SourceType).getTypePtr(); } } - + if (const EnumType *SourceEnum = Source->getAs<EnumType>()) if (const EnumType *TargetEnum = Target->getAs<EnumType>()) if (SourceEnum->getDecl()->hasNameForLinkage() && @@ -10906,7 +10906,7 @@ CheckImplicitConversion(Sema &S, Expr *E, QualType T, SourceLocation CC, if (S.SourceMgr.isInSystemMacro(CC)) return; - return DiagnoseImpCast(S, E, SourceType, T, CC, + return DiagnoseImpCast(S, E, SourceType, T, CC, diag::warn_impcast_different_enum_types); } } @@ -10945,7 +10945,7 @@ static void CheckConditionalOperator(Sema &S, ConditionalOperator *E, // ...then check whether it would have warned about either of the // candidates for a signedness conversion to the condition type. if (E->getType() == T) return; - + Suspicious = false; CheckImplicitConversion(S, E->getTrueExpr()->IgnoreParenImpCasts(), E->getType(), CC, &Suspicious); @@ -12426,11 +12426,11 @@ namespace { } void VisitBlockExpr(BlockExpr *block) { - // Look inside nested blocks + // Look inside nested blocks if (block->getBlockDecl()->capturesVariable(Variable)) Visit(block->getBlockDecl()->getBody()); } - + void VisitOpaqueValueExpr(OpaqueValueExpr *OVE) { if (Capturer) return; if (OVE->getSourceExpr()) @@ -12483,7 +12483,7 @@ static Expr *findCapturingExpr(Sema &S, Expr *e, RetainCycleOwner &owner) { } } } - + BlockExpr *block = dyn_cast<BlockExpr>(e); if (!block || !block->getBlockDecl()->capturesVariable(owner.Variable)) return nullptr; @@ -12736,12 +12736,12 @@ void Sema::checkRetainCycles(VarDecl *Var, Expr *Init) { RetainCycleOwner Owner; if (!considerVariable(Var, /*DeclRefExpr=*/nullptr, Owner)) return; - + // Because we don't have an expression for the variable, we have to set the // location explicitly here. Owner.Loc = Var->getLocation(); Owner.Range = Var->getSourceRange(); - + if (Expr *Capturer = findCapturingExpr(*this, Init, Owner)) diagnoseRetainCycle(*this, Capturer, Owner); } @@ -12814,7 +12814,7 @@ void Sema::checkUnsafeExprAssigns(SourceLocation Loc, if (PD) LHSType = PD->getType(); } - + if (LHSType.isNull()) LHSType = LHS->getType(); @@ -12831,14 +12831,14 @@ void Sema::checkUnsafeExprAssigns(SourceLocation Loc, // FIXME. Check for other life times. if (LT != Qualifiers::OCL_None) return; - + if (PRE) { if (PRE->isImplicitProperty()) return; const ObjCPropertyDecl *PD = PRE->getExplicitProperty(); if (!PD) return; - + unsigned Attributes = PD->getPropertyAttributes(); if (Attributes & ObjCPropertyDecl::OBJC_PR_assign) { // when 'assign' attribute was not explicitly specified @@ -12848,7 +12848,7 @@ void Sema::checkUnsafeExprAssigns(SourceLocation Loc, if (!(AsWrittenAttr & ObjCPropertyDecl::OBJC_PR_assign) && LHSType->isObjCRetainableType()) return; - + while (ImplicitCastExpr *cast = dyn_cast<ImplicitCastExpr>(RHS)) { if (cast->getCastKind() == CK_ARCConsumeObject) { Diag(Loc, diag::warn_arc_retained_property_assign) diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 6bee72a398..2e871d6029 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3182,7 +3182,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, if (OldTypeInfo.getNoCallerSavedRegs() != NewTypeInfo.getNoCallerSavedRegs()) { if (NewTypeInfo.getNoCallerSavedRegs()) { - AnyX86NoCallerSavedRegistersAttr *Attr = + AnyX86NoCallerSavedRegistersAttr *Attr = New->getAttr<AnyX86NoCallerSavedRegistersAttr>(); Diag(New->getLocation(), diag::err_function_attribute_mismatch) << Attr; Diag(OldLocation, diag::note_previous_declaration); @@ -10720,7 +10720,7 @@ QualType Sema::deduceVarTypeFromInitializer(VarDecl *VDecl, InitializedEntity Entity = InitializedEntity::InitializeVariable(VDecl); InitializationKind Kind = InitializationKind::CreateForInit( VDecl->getLocation(), DirectInit, Init); - // FIXME: Initialization should not be taking a mutable list of inits. + // FIXME: Initialization should not be taking a mutable list of inits. SmallVector<Expr*, 8> InitsCopy(DeduceInits.begin(), DeduceInits.end()); return DeduceTemplateSpecializationFromInitializer(TSI, Entity, Kind, InitsCopy); @@ -13409,7 +13409,7 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) { break; } } - + if (Context.BuiltinInfo.isReturnsTwice(BuiltinID) && !FD->hasAttr<ReturnsTwiceAttr>()) FD->addAttr(ReturnsTwiceAttr::CreateImplicit(Context, diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 320eabd5ec..f6caff6b7d 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -1051,7 +1051,7 @@ static void handleConsumableAttr(Sema &S, Decl *D, const ParsedAttr &AL) { << AL.getName() << AANT_ArgumentIdentifier; return; } - + D->addAttr(::new (S.Context) ConsumableAttr(AL.getRange(), S.Context, DefaultState, AL.getAttributeSpellingListIndex())); @@ -1061,30 +1061,30 @@ static bool checkForConsumableClass(Sema &S, const CXXMethodDecl *MD, const ParsedAttr &AL) { ASTContext &CurrContext = S.getASTContext(); QualType ThisType = MD->getThisType(CurrContext)->getPointeeType(); - + if (const CXXRecordDecl *RD = ThisType->getAsCXXRecordDecl()) { if (!RD->hasAttr<ConsumableAttr>()) { S.Diag(AL.getLoc(), diag::warn_attr_on_unconsumable_class) << RD->getNameAsString(); - + return false; } } - + return true; } static void handleCallableWhenAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!checkAttributeAtLeastNumArgs(S, AL, 1)) return; - + if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL)) return; - + SmallVector<CallableWhenAttr::ConsumedState, 3> States; for (unsigned ArgIndex = 0; ArgIndex < AL.getNumArgs(); ++ArgIndex) { CallableWhenAttr::ConsumedState CallableState; - + StringRef StateString; SourceLocation Loc; if (AL.isArgIdent(ArgIndex)) { @@ -1102,10 +1102,10 @@ static void handleCallableWhenAttr(Sema &S, Decl *D, const ParsedAttr &AL) { << AL.getName() << StateString; return; } - + States.push_back(CallableState); } - + D->addAttr(::new (S.Context) CallableWhenAttr(AL.getRange(), S.Context, States.data(), States.size(), AL.getAttributeSpellingListIndex())); @@ -1113,7 +1113,7 @@ static void handleCallableWhenAttr(Sema &S, Decl *D, const ParsedAttr &AL) { static void handleParamTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { ParamTypestateAttr::ConsumedState ParamState; - + if (AL.isArgIdent(0)) { IdentifierLoc *Ident = AL.getArgAsIdent(0); StringRef StateString = Ident->Ident->getName(); @@ -1129,7 +1129,7 @@ static void handleParamTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { AL.getName() << AANT_ArgumentIdentifier; return; } - + // FIXME: This check is currently being done in the analysis. It can be // enabled here only after the parser propagates attributes at // template specialization definition, not declaration. @@ -1141,7 +1141,7 @@ static void handleParamTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { // ReturnType.getAsString(); // return; //} - + D->addAttr(::new (S.Context) ParamTypestateAttr(AL.getRange(), S.Context, ParamState, AL.getAttributeSpellingListIndex())); @@ -1149,7 +1149,7 @@ static void handleParamTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { static void handleReturnTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { ReturnTypestateAttr::ConsumedState ReturnState; - + if (AL.isArgIdent(0)) { IdentifierLoc *IL = AL.getArgAsIdent(0); if (!ReturnTypestateAttr::ConvertStrToConsumedState(IL->Ident->getName(), @@ -1163,7 +1163,7 @@ static void handleReturnTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { AL.getName() << AANT_ArgumentIdentifier; return; } - + // FIXME: This check is currently being done in the analysis. It can be // enabled here only after the parser propagates attributes at // template specialization definition, not declaration. @@ -1175,9 +1175,9 @@ static void handleReturnTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { //} else if (const CXXConstructorDecl *Constructor = // dyn_cast<CXXConstructorDecl>(D)) { // ReturnType = Constructor->getThisType(S.getASTContext())->getPointeeType(); - // + // //} else { - // + // // ReturnType = cast<FunctionDecl>(D)->getCallResultType(); //} // @@ -1197,7 +1197,7 @@ static void handleReturnTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { static void handleSetTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL)) return; - + SetTypestateAttr::ConsumedState NewState; if (AL.isArgIdent(0)) { IdentifierLoc *Ident = AL.getArgAsIdent(0); @@ -1212,7 +1212,7 @@ static void handleSetTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { AL.getName() << AANT_ArgumentIdentifier; return; } - + D->addAttr(::new (S.Context) SetTypestateAttr(AL.getRange(), S.Context, NewState, AL.getAttributeSpellingListIndex())); @@ -1221,8 +1221,8 @@ static void handleSetTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { static void handleTestTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL)) return; - - TestTypestateAttr::ConsumedState TestState; + + TestTypestateAttr::ConsumedState TestState; if (AL.isArgIdent(0)) { IdentifierLoc *Ident = AL.getArgAsIdent(0); StringRef Param = Ident->Ident->getName(); @@ -1236,7 +1236,7 @@ static void handleTestTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { AL.getName() << AANT_ArgumentIdentifier; return; } - + D->addAttr(::new (S.Context) TestTypestateAttr(AL.getRange(), S.Context, TestState, AL.getAttributeSpellingListIndex())); @@ -1980,7 +1980,7 @@ static void handleAnalyzerNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &AL) { return; } } - + D->addAttr(::new (S.Context) AnalyzerNoReturnAttr(AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); @@ -2343,7 +2343,7 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) { return; IdentifierLoc *Platform = AL.getArgAsIdent(0); unsigned Index = AL.getAttributeSpellingListIndex(); - + IdentifierInfo *II = Platform->Ident; if (AvailabilityAttr::getPrettyPlatformName(II->getName()).empty()) S.Diag(Platform->Loc, diag::warn_availability_unknown_platform) @@ -2533,7 +2533,7 @@ static void handleVisibilityAttr(Sema &S, Decl *D, const ParsedAttr &AL, << AL.getName() << TypeStr; return; } - + // Complain about attempts to use protected visibility on targets // (like Darwin) that don't support it. if (type == VisibilityAttr::Protected && @@ -2604,7 +2604,7 @@ static void handleObjCNSObject(Sema &S, Decl *D, const ParsedAttr &AL) { // @property (retain, nonatomic) struct Bork *Q __attribute__((NSObject)); // // In this case it follows tradition and suppresses an error in the above - // case. + // case. S.Diag(D->getLocation(), diag::warn_nsobject_attribute); } D->addAttr(::new (S.Context) @@ -2752,14 +2752,14 @@ static void handleWarnUnusedResult(Sema &S, Decl *D, const ParsedAttr &AL) { << AL.getName() << 1; return; } - + // If this is spelled as the standard C++17 attribute, but not in C++17, warn // about using it as an extension. if (!S.getLangOpts().CPlusPlus17 && AL.isCXX11Attribute() && !AL.getScopeName()) S.Diag(AL.getLoc(), diag::ext_cxx17_attr) << AL.getName(); - D->addAttr(::new (S.Context) + D->addAttr(::new (S.Context) WarnUnusedResultAttr(AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); } @@ -2892,7 +2892,7 @@ bool Sema::checkSectionName(SourceLocation LiteralLoc, StringRef SecName) { std::string Error = Context.getTargetInfo().isValidSectionSpecifier(SecName); if (!Error.empty()) { Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target) << Error - << 1 /*'section'*/; + << 1 /*'section'*/; return false; } return true; @@ -3191,7 +3191,7 @@ static void handleInitPriorityAttr(Sema &S, Decl *D, const ParsedAttr &AL) { S.Diag(AL.getLoc(), diag::warn_attribute_ignored) << AL.getName(); return; } - + if (S.getCurFunctionOrMethodDecl()) { S.Diag(AL.getLoc(), diag::err_init_priority_object_attr); AL.setInvalid(); @@ -3269,10 +3269,10 @@ static void handleFormatAttr(Sema &S, Decl *D, const ParsedAttr &AL) { // Check for supported formats. FormatAttrKind Kind = getFormatAttrKind(Format); - + if (Kind == IgnoredFormat) return; - + if (Kind == InvalidFormat) { S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) << AL.getName() << II->getName(); @@ -3454,7 +3454,7 @@ static void handleAnnotateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (I->getAnnotation() == Str) return; } - + D->addAttr(::new (S.Context) AnnotateAttr(AL.getRange(), S.Context, Str, AL.getAttributeSpellingListIndex())); @@ -4595,7 +4595,7 @@ static void handleTypeTagForDatatypeAttr(Sema &S, Decl *D, << AL.getName() << 1 << AANT_ArgumentIdentifier; return; } - + if (!checkAttributeNumArgs(S, AL, 1)) return; @@ -4819,7 +4819,7 @@ static void handleObjCReturnsInnerPointerAttr(Sema &S, Decl *D, const ParsedAttr &Attrs) { const int EP_ObjCMethod = 1; const int EP_ObjCProperty = 2; - + SourceLocation loc = Attrs.getLoc(); QualType resultType; if (isa<ObjCMethodDecl>(D)) @@ -4887,7 +4887,7 @@ static void handleObjCBridgeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { return; } } - + D->addAttr(::new (S.Context) ObjCBridgeAttr(AL.getRange(), S.Context, Parm->Ident, AL.getAttributeSpellingListIndex())); @@ -4901,7 +4901,7 @@ static void handleObjCBridgeMutableAttr(Sema &S, Decl *D, S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << AL.getName() << 0; return; } - + D->addAttr(::new (S.Context) ObjCBridgeMutableAttr(AL.getRange(), S.Context, Parm->Ident, AL.getAttributeSpellingListIndex())); @@ -5195,7 +5195,7 @@ static void handleMSP430InterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!AL.isArgExpr(0)) { S.Diag(AL.getLoc(), diag::err_attribute_argument_type) << AL.getName() << AANT_ArgumentIntegerConstant; - return; + return; } // FIXME: Check for decl - it should be void ()(void). diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index ab0ff0c4c9..595cc76cd4 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -133,9 +133,9 @@ static void diagnoseNoescape(const ParmVarDecl *NewD, const ParmVarDecl *OldD, << cast<ObjCMethodDecl>(NewD->getDeclContext()); } -void Sema::CheckObjCMethodOverride(ObjCMethodDecl *NewMethod, +void Sema::CheckObjCMethodOverride(ObjCMethodDecl *NewMethod, const ObjCMethodDecl *Overridden) { - if (Overridden->hasRelatedResultType() && + if (Overridden->hasRelatedResultType() && !NewMethod->hasRelatedResultType()) { // This can only happen when the method follows a naming convention that // implies a related result type, and the original (overridden) method has @@ -143,9 +143,9 @@ void Sema::CheckObjCMethodOverride(ObjCMethodDecl *NewMethod, // a suitable return type. QualType ResultType = NewMethod->getReturnType(); SourceRange ResultTypeRange = NewMethod->getReturnTypeSourceRange(); - + // Figure out which class this method is part of, if any. - ObjCInterfaceDecl *CurrentClass + ObjCInterfaceDecl *CurrentClass = dyn_cast<ObjCInterfaceDecl>(NewMethod->getDeclContext()); if (!CurrentClass) { DeclContext *DC = NewMethod->getDeclContext(); @@ -157,27 +157,27 @@ void Sema::CheckObjCMethodOverride(ObjCMethodDecl *NewMethod, = dyn_cast<ObjCCategoryImplDecl>(DC)) CurrentClass = CatImpl->getClassInterface(); } - + if (CurrentClass) { - Diag(NewMethod->getLocation(), + Diag(NewMethod->getLocation(), diag::warn_related_result_type_compatibility_class) << Context.getObjCInterfaceType(CurrentClass) << ResultType << ResultTypeRange; } else { - Diag(NewMethod->getLocation(), + Diag(NewMethod->getLocation(), diag::warn_related_result_type_compatibility_protocol) << ResultType << ResultTypeRange; } - + if (ObjCMethodFamily Family = Overridden->getMethodFamily()) - Diag(Overridden->getLocation(), + Diag(Overridden->getLocation(), diag::note_related_result_type_family) << /*overridden method*/ 0 << Family; else - Diag(Overridden->getLocation(), + Diag(Overridden->getLocation(), diag::note_related_result_type_overridden); } @@ -250,7 +250,7 @@ bool Sema::CheckARCMethodDecl(ObjCMethodDecl *method) { return true; } return false; - + case OMF_init: // If the method doesn't obey the init rules, don't bother annotating it. if (checkInitMethod(method, QualType())) @@ -328,7 +328,7 @@ static void DiagnoseObjCImplementedDeprecations(Sema &S, const NamedDecl *ND, /// pool. void Sema::AddAnyMethodToGlobalPool(Decl *D) { ObjCMethodDecl *MDecl = dyn_cast_or_null<ObjCMethodDecl>(D); - + // If we don't have a valid method decl, simply return. if (!MDecl) return; @@ -343,7 +343,7 @@ void Sema::AddAnyMethodToGlobalPool(Decl *D) { static bool HasExplicitOwnershipAttr(Sema &S, ParmVarDecl *Param) { QualType T = Param->getType(); - + if (const PointerType *PT = T->getAs<PointerType>()) { T = PT->getPointeeType(); } else if (const ReferenceType *RT = T->getAs<ReferenceType>()) { @@ -351,8 +351,8 @@ HasExplicitOwnershipAttr(Sema &S, ParmVarDecl *Param) { } else { return true; } - - // If we have a lifetime qualifier, but it's local, we must have + + // If we have a lifetime qualifier, but it's local, we must have // inferred it. So, it is implicit. return !T.getLocalQualifiers().hasObjCLifetime(); } @@ -362,7 +362,7 @@ HasExplicitOwnershipAttr(Sema &S, ParmVarDecl *Param) { void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) { assert((getCurMethodDecl() == nullptr) && "Methodparsing confused"); ObjCMethodDecl *MDecl = dyn_cast_or_null<ObjCMethodDecl>(D); - + // If we don't have a valid method decl, simply return. if (!MDecl) return; @@ -377,7 +377,7 @@ void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) { // Allow all of Sema to see that we are entering a method definition. PushDeclContext(FnBodyScope, MDecl); PushFunctionScope(); - + // Create Decl objects for each parameter, entrring them in the scope for // binding to their use. @@ -398,7 +398,7 @@ void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) { !HasExplicitOwnershipAttr(*this, Param)) Diag(Param->getLocation(), diag::warn_arc_strong_pointer_objc_pointer) << Param->getType(); - + if (Param->getIdentifier()) PushOnScopeChains(Param, FnBodyScope); } @@ -432,13 +432,13 @@ void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) { // Warn on deprecated methods under -Wdeprecated-implementations, // and prepare for warning on missing super calls. if (ObjCInterfaceDecl *IC = MDecl->getClassInterface()) { - ObjCMethodDecl *IMD = + ObjCMethodDecl *IMD = IC->lookupMethod(MDecl->getSelector(), MDecl->isInstanceMethod()); - + if (IMD) { - ObjCImplDecl *ImplDeclOfMethodDef = + ObjCImplDecl *ImplDeclOfMethodDef = dyn_cast<ObjCImplDecl>(MDecl->getDeclContext()); - ObjCContainerDecl *ContDeclOfMethodDecl = + ObjCContainerDecl *ContDeclOfMethodDecl = dyn_cast<ObjCContainerDecl>(IMD->getDeclContext()); ObjCImplDecl *ImplDeclOfMethodDecl = nullptr; if (ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(ContDeclOfMethodDecl)) @@ -481,12 +481,12 @@ void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) { } else if (Family == OMF_finalize) { if (Context.getLangOpts().getGC() != LangOptions::NonGC) getCurFunction()->ObjCShouldCallSuper = true; - + } else { const ObjCMethodDecl *SuperMethod = SuperClass->lookupMethod(MDecl->getSelector(), MDecl->isInstanceMethod()); - getCurFunction()->ObjCShouldCallSuper = + getCurFunction()->ObjCShouldCallSuper = (SuperMethod && SuperMethod->hasAttr<ObjCRequiresSuperAttr>()); } } @@ -627,11 +627,11 @@ ActOnSuperClassOfClassInterface(Scope *S, // Handle type arguments on the superclass. TypeSourceInfo *SuperClassTInfo = nullptr; - if (!SuperTypeArgs.empty()) { + if (!SuperTypeArgs.empty()) { TypeResult fullSuperClassType = actOnObjCTypeArgsAndProtocolQualifiers( S, SuperLoc, - CreateParsedType(SuperClassType, + CreateParsedType(SuperClassType, nullptr), SuperTypeArgsRange.getBegin(), SuperTypeArgs, @@ -643,12 +643,12 @@ ActOnSuperClassOfClassInterface(Scope *S, if (!fullSuperClassType.isUsable()) return; - SuperClassType = GetTypeFromParser(fullSuperClassType.get(), + SuperClassType = GetTypeFromParser(fullSuperClassType.get(), &SuperClassTInfo); } if (!SuperClassTInfo) { - SuperClassTInfo = Context.getTrivialTypeSourceInfo(SuperClassType, + SuperClassTInfo = Context.getTrivialTypeSourceInfo(SuperClassType, SuperLoc); } @@ -852,7 +852,7 @@ static bool checkTypeParamListConsistency(Sema &S, // When the new type parameter is invariant and is not part // of the definition, just propagate the variance. newTypeParam->setVariance(prevTypeParam->getVariance()); - } else if (prevTypeParam->getVariance() + } else if (prevTypeParam->getVariance() == ObjCTypeParamVariance::Invariant && !(isa<ObjCInterfaceDecl>(prevTypeParam->getDeclContext()) && cast<ObjCInterfaceDecl>(prevTypeParam->getDeclContext()) @@ -1011,7 +1011,7 @@ Decl *Sema::ActOnStartClassInterface( if (ObjCTypeParamList *prevTypeParamList = PrevIDecl->getTypeParamList()) { if (typeParamList) { // Both have type parameter lists; check for consistency. - if (checkTypeParamListConsistency(*this, prevTypeParamList, + if (checkTypeParamListConsistency(*this, prevTypeParamList, typeParamList, TypeParamListContext::Definition)) { typeParamList = nullptr; @@ -1038,7 +1038,7 @@ Decl *Sema::ActOnStartClassInterface( Context.getTrivialTypeSourceInfo(typeParam->getUnderlyingType()))); } - typeParamList = ObjCTypeParamList::create(Context, + typeParamList = ObjCTypeParamList::create(Context, SourceLocation(), clonedTypeParams, SourceLocation()); @@ -1063,18 +1063,18 @@ Decl *Sema::ActOnStartClassInterface( AddPragmaAttributes(TUScope, IDecl); PushOnScopeChains(IDecl, TUScope); - // Start the definition of this class. If we're in a redefinition case, there + // Start the definition of this class. If we're in a redefinition case, there // may already be a definition, so we'll end up adding to it. if (!IDecl->hasDefinition()) IDecl->startDefinition(); - + if (SuperName) { // Diagnose availability in the context of the @interface. ContextRAII SavedContext(*this, IDecl); - ActOnSuperClassOfClassInterface(S, AtInterfaceLoc, IDecl, - ClassName, ClassLoc, - SuperName, SuperLoc, SuperTypeArgs, + ActOnSuperClassOfClassInterface(S, AtInterfaceLoc, IDecl, + ClassName, ClassLoc, + SuperName, SuperLoc, SuperTypeArgs, SuperTypeArgsRange); } else { // we have a root class. IDecl->setEndOfDefinitionLoc(ClassLoc); @@ -1106,7 +1106,7 @@ void Sema::ActOnTypedefedProtocols(SmallVectorImpl<Decl *> &ProtocolRefs, LookupOrdinaryName); if (!IDecl) return; - + if (const TypedefNameDecl *TDecl = dyn_cast_or_null<TypedefNameDecl>(IDecl)) { QualType T = TDecl->getUnderlyingType(); if (T->isObjCObjectType()) @@ -1175,7 +1175,7 @@ bool Sema::CheckForwardProtocolDeclarationForCircularDependency( IdentifierInfo *PName, SourceLocation &Ploc, SourceLocation PrevLoc, const ObjCList<ObjCProtocolDecl> &PList) { - + bool res = false; for (ObjCList<ObjCProtocolDecl>::iterator I = PList.begin(), E = PList.end(); I != E; ++I) { @@ -1186,10 +1186,10 @@ bool Sema::CheckForwardProtocolDeclarationForCircularDependency( Diag(PrevLoc, diag::note_previous_definition); res = true; } - + if (!PDecl->hasDefinition()) continue; - + if (CheckForwardProtocolDeclarationForCircularDependency(PName, Ploc, PDecl->getLocation(), PDecl->getReferencedProtocols())) res = true; @@ -1241,7 +1241,7 @@ Decl *Sema::ActOnStartProtocolInterface( PDecl = ObjCProtocolDecl::Create(Context, CurContext, ProtocolName, ProtocolLoc, AtProtoInterfaceLoc, /*PrevDecl=*/PrevDecl); - + PushOnScopeChains(PDecl, TUScope); PDecl->startDefinition(); } @@ -1271,7 +1271,7 @@ static bool NestedProtocolHasNoDefinition(ObjCProtocolDecl *PDecl, UndefinedProtocol = PDecl; return true; } - + for (auto *PI : PDecl->protocols()) if (NestedProtocolHasNoDefinition(PI, UndefinedProtocol)) { UndefinedProtocol = PI; @@ -1318,7 +1318,7 @@ Sema::FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer, // case, do it. // FIXME: Recover nicely in the hidden case. ObjCProtocolDecl *UndefinedProtocol; - + if (WarnOnDeclarations && NestedProtocolHasNoDefinition(PDecl, UndefinedProtocol)) { Diag(Pair.second, diag::warn_undef_protocolref) << Pair.first; @@ -1411,7 +1411,7 @@ void Sema::actOnObjCTypeArgsOrProtocolQualifiers( unsigned numProtocolsResolved = 0; auto resolvedAsProtocols = [&] { assert(numProtocolsResolved == identifiers.size() && "Unresolved protocols"); - + // Determine whether the base type is a parameterized class, in // which case we want to warn about typos such as // "NSArray<NSObject>" (that should be NSArray<NSObject *>). @@ -1434,7 +1434,7 @@ void Sema::actOnObjCTypeArgsOrProtocolQualifiers( } for (unsigned i = 0, n = protocols.size(); i != n; ++i) { - ObjCProtocolDecl *&proto + ObjCProtocolDecl *&proto = reinterpret_cast<ObjCProtocolDecl *&>(protocols[i]); // For an objc container, delay protocol reference checking until after we // can set the objc decl as the availability context, otherwise check now. @@ -1476,7 +1476,7 @@ void Sema::actOnObjCTypeArgsOrProtocolQualifiers( } } } - + // All of the protocols listed also have type names, and at least // one is an Objective-C class name. Check whether all of the // protocol conformances are declared by the base class itself, in @@ -1551,7 +1551,7 @@ void Sema::actOnObjCTypeArgsOrProtocolQualifiers( // Local function that forms a reference to the given type or // Objective-C class declaration. - auto resolveTypeReference = [&](TypeOrClassDecl typeDecl, SourceLocation loc) + auto resolveTypeReference = [&](TypeOrClassDecl typeDecl, SourceLocation loc) -> TypeResult { // Form declaration specifiers. They simply refer to the type. DeclSpec DS(attrFactory); @@ -1767,10 +1767,10 @@ Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc, ObjCProtocolDecl *PrevDecl = LookupProtocol(Ident, IdentPair.second, forRedeclarationInCurContext()); ObjCProtocolDecl *PDecl - = ObjCProtocolDecl::Create(Context, CurContext, Ident, + = ObjCProtocolDecl::Create(Context, CurContext, Ident, IdentPair.second, AtProtocolLoc, PrevDecl); - + PushOnScopeChains(PDecl, TUScope); CheckObjCDeclScope(PDecl); @@ -1798,7 +1798,7 @@ Decl *Sema::ActOnStartCategoryInterface( /// Check that class of this category is already completely declared. - if (!IDecl + if (!IDecl || RequireCompleteType(ClassLoc, Context.getObjCInterfaceType(IDecl), diag::err_category_forward_interface, CategoryName == nullptr)) { @@ -1810,7 +1810,7 @@ Decl *Sema::ActOnStartCategoryInterface( IDecl, typeParamList); CDecl->setInvalidDecl(); CurContext->addDecl(CDecl); - + if (!IDecl) Diag(ClassLoc, diag::err_undef_interface) << ClassName; return ActOnObjCContainerStartDefinition(CDecl); @@ -1818,7 +1818,7 @@ Decl *Sema::ActOnStartCategoryInterface( if (!CategoryName && IDecl->getImplementation()) { Diag(ClassLoc, diag::err_class_extension_after_impl) << ClassName; - Diag(IDecl->getImplementation()->getLocation(), + Diag(IDecl->getImplementation()->getLocation(), diag::note_implementation_declared); } @@ -1871,8 +1871,8 @@ Decl *Sema::ActOnStartCategoryInterface( ProtoLocs, Context); // Protocols in the class extension belong to the class. if (CDecl->IsClassExtension()) - IDecl->mergeClassExtensionProtocolList((ObjCProtocolDecl*const*)ProtoRefs, - NumProtoRefs, Context); + IDecl->mergeClassExtensionProtocolList((ObjCProtocolDecl*const*)ProtoRefs, + NumProtoRefs, Context); } CheckObjCDeclScope(CDecl); @@ -1933,7 +1933,7 @@ Decl *Sema::ActOnStartCategoryImplementation( CDecl->setInvalidDecl(); } else { CatIDecl->setImplementation(CDecl); - // Warn on implementating category of deprecated class under + // Warn on implementating category of deprecated class under // -Wdeprecated-implementations flag. DiagnoseObjCImplementedDeprecations(*this, CatIDecl, CDecl->getLocation()); @@ -2027,7 +2027,7 @@ Decl *Sema::ActOnStartClassImplementation( } else { IDecl->setEndOfDefinitionLoc(ClassLoc); } - + PushOnScopeChains(IDecl, TUScope); } else { // Mark the interface as being completed, even if it was just as @@ -2054,7 +2054,7 @@ Decl *Sema::ActOnStartClassImplementation( } else { // add it to the list. IDecl->setImplementation(IMPDecl); PushOnScopeChains(IMPDecl, TUScope); - // Warn on implementating deprecated class under + // Warn on implementating deprecated class under // -Wdeprecated-implementations flag. DiagnoseObjCImplementedDeprecations(*this, IDecl, IMPDecl->getLocation()); } @@ -2108,7 +2108,7 @@ void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, IDecl->makeDeclVisibleInContext(ivars[i]); ImpDecl->addDecl(ivars[i]); } - + return; } // If implementation has empty ivar list, just return. @@ -2121,17 +2121,17 @@ void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, Diag(ImpDecl->getLocation(), diag::warn_on_superclass_use); for (unsigned i = 0; i < numIvars; i++) { ObjCIvarDecl* ImplIvar = ivars[i]; - if (const ObjCIvarDecl *ClsIvar = + if (const ObjCIvarDecl *ClsIvar = IDecl->getIvarDecl(ImplIvar->getIdentifier())) { - Diag(ImplIvar->getLocation(), diag::err_duplicate_ivar_declaration); + Diag(ImplIvar->getLocation(), diag::err_duplicate_ivar_declaration); Diag(ClsIvar->getLocation(), diag::note_previous_definition); continue; } // Check class extensions (unnamed categories) for duplicate ivars. for (const auto *CDecl : IDecl->visible_extensions()) { - if (const ObjCIvarDecl *ClsExtIvar = + if (const ObjCIvarDecl *ClsExtIvar = CDecl->getIvarDecl(ImplIvar->getIdentifier())) { - Diag(ImplIvar->getLocation(), diag::err_duplicate_ivar_declaration); + Diag(ImplIvar->getLocation(), diag::err_duplicate_ivar_declaration); Diag(ClsExtIvar->getLocation(), diag::note_previous_definition); continue; } @@ -2212,8 +2212,8 @@ static void WarnUndefinedMethod(Sema &S, SourceLocation ImpLoc, } /// Determines if type B can be substituted for type A. Returns true if we can -/// guarantee that anything that the user will do to an object of type A can -/// also be done to an object of type B. This is trivially true if the two +/// guarantee that anything that the user will do to an object of type A can +/// also be done to an object of type B. This is trivially true if the two /// types are the same, or if B is a subclass of A. It becomes more complex /// in cases where protocols are involved. /// @@ -2222,12 +2222,12 @@ static void WarnUndefinedMethod(Sema &S, SourceLocation ImpLoc, /// example, if A is a subclass of B, then B* may refer to an instance of A. /// The principle of substitutability means that we may use an instance of A /// anywhere that we may use an instance of B - it will implement all of the -/// ivars of B and all of the methods of B. +/// ivars of B and all of the methods of B. /// -/// This substitutability is important when type checking methods, because +/// This substitutability is important when type checking methods, because /// the implementation may have stricter type definitions than the interface. /// The interface specifies minimum requirements, but the implementation may -/// have more accurate ones. For example, a method may privately accept +/// have more accurate ones. For example, a method may privately accept /// instances of B, but only publish that it accepts instances of A. Any /// object passed to it will be type checked against B, and so will implicitly /// by a valid A*. Similarly, a method may return a subclass of the class that @@ -2243,7 +2243,7 @@ static void WarnUndefinedMethod(Sema &S, SourceLocation ImpLoc, /// advertises, but it may be specified more accurately. This avoids the need /// for explicit down-casting by callers. /// -/// Note: This is a stricter requirement than for assignment. +/// Note: This is a stricter requirement than for assignment. static bool isObjCTypeSubstitutable(ASTContext &Context, const ObjCObjectPointerType *A, const ObjCObjectPointerType *B, @@ -2332,15 +2332,15 @@ static bool CheckMethodOverrideReturn(Sema &S, != 0)); S.Diag(MethodDecl->getLocation(), diag::note_previous_declaration); } - + if (S.Context.hasSameUnqualifiedType(MethodImpl->getReturnType(), MethodDecl->getReturnType())) return true; if (!Warn) return false; - unsigned DiagID = - IsOverridingMode ? diag::warn_conflicting_overriding_ret_types + unsigned DiagID = + IsOverridingMode ? diag::warn_conflicting_overriding_ret_types : diag::warn_conflicting_ret_types; // Mismatches between ObjC pointers go into a different warning @@ -2356,8 +2356,8 @@ static bool CheckMethodOverrideReturn(Sema &S, if (isObjCTypeSubstitutable(S.Context, IfacePtrTy, ImplPtrTy, false)) return false; - DiagID = - IsOverridingMode ? diag::warn_non_covariant_overriding_ret_types + DiagID = + IsOverridingMode ? diag::warn_non_covariant_overriding_ret_types : diag::warn_non_covariant_ret_types; } } @@ -2386,21 +2386,21 @@ static bool CheckMethodOverrideParam(Sema &S, IfaceVar->getObjCDeclQualifier())) { if (Warn) { if (IsOverridingMode) - S.Diag(ImplVar->getLocation(), + S.Diag(ImplVar->getLocation(), diag::warn_conflicting_overriding_param_modifiers) << getTypeRange(ImplVar->getTypeSourceInfo()) << MethodImpl->getDeclName(); - else S.Diag(ImplVar->getLocation(), + else S.Diag(ImplVar->getLocation(), diag::warn_conflicting_param_modifiers) << getTypeRange(ImplVar->getTypeSourceInfo()) << MethodImpl->getDeclName(); S.Diag(IfaceVar->getLocation(), diag::note_previous_declaration) - << getTypeRange(IfaceVar->getTypeSourceInfo()); + << getTypeRange(IfaceVar->getTypeSourceInfo()); } else return false; } - + QualType ImplTy = ImplVar->getType(); QualType IfaceTy = IfaceVar->getType(); if (Warn && IsOverridingMode && @@ -2423,8 +2423,8 @@ static bool CheckMethodOverrideParam(Sema &S, if (!Warn) return false; - unsigned DiagID = - IsOverridingMode ? diag::warn_conflicting_overriding_param_types + unsigned DiagID = + IsOverridingMode ? diag::warn_conflicting_overriding_param_types : diag::warn_conflicting_param_types; // Mismatches between ObjC pointers go into a different warning @@ -2440,8 +2440,8 @@ static bool CheckMethodOverrideParam(Sema &S, if (isObjCTypeSubstitutable(S.Context, ImplPtrTy, IfacePtrTy, true)) return false; - DiagID = - IsOverridingMode ? diag::warn_non_contravariant_overriding_param_types + DiagID = + IsOverridingMode ? diag::warn_non_contravariant_overriding_param_types : diag::warn_non_contravariant_param_types; } } @@ -2449,8 +2449,8 @@ static bool CheckMethodOverrideParam(Sema &S, S.Diag(ImplVar->getLocation(), DiagID) << getTypeRange(ImplVar->getTypeSourceInfo()) << MethodImpl->getDeclName() << IfaceTy << ImplTy; - S.Diag(IfaceVar->getLocation(), - (IsOverridingMode ? diag::note_previous_declaration + S.Diag(IfaceVar->getLocation(), + (IsOverridingMode ? diag::note_previous_declaration : diag::note_previous_definition)) << getTypeRange(IfaceVar->getTypeSourceInfo()); return false; @@ -2535,8 +2535,8 @@ void Sema::WarnConflictingTypedMethods(ObjCMethodDecl *ImpMethodDecl, checkMethodFamilyMismatch(*this, ImpMethodDecl, MethodDecl)) return; - CheckMethodOverrideReturn(*this, ImpMethodDecl, MethodDecl, - IsProtocolMethodDecl, false, + CheckMethodOverrideReturn(*this, ImpMethodDecl, MethodDecl, + IsProtocolMethodDecl, false, true); for (ObjCMethodDecl::param_iterator IM = ImpMethodDecl->param_begin(), @@ -2548,7 +2548,7 @@ void Sema::WarnConflictingTypedMethods(ObjCMethodDecl *ImpMethodDecl, } if (ImpMethodDecl->isVariadic() != MethodDecl->isVariadic()) { - Diag(ImpMethodDecl->getLocation(), + Diag(ImpMethodDecl->getLocation(), diag::warn_conflicting_variadic); Diag(MethodDecl->getLocation(), diag::note_previous_declaration); } @@ -2557,11 +2557,11 @@ void Sema::WarnConflictingTypedMethods(ObjCMethodDecl *ImpMethodDecl, void Sema::CheckConflictingOverridingMethod(ObjCMethodDecl *Method, ObjCMethodDecl *Overridden, bool IsProtocolMethodDecl) { - - CheckMethodOverrideReturn(*this, Method, Overridden, - IsProtocolMethodDecl, true, + + CheckMethodOverrideReturn(*this, Method, Overridden, + IsProtocolMethodDecl, true, true); - + for (ObjCMethodDecl::param_iterator IM = Method->param_begin(), IF = Overridden->param_begin(), EM = Method->param_end(), EF = Overridden->param_end(); @@ -2569,9 +2569,9 @@ void Sema::CheckConflictingOverridingMethod(ObjCMethodDecl *Method, CheckMethodOverrideParam(*this, Method, Overridden, *IM, *IF, IsProtocolMethodDecl, true, true); } - + if (Method->isVariadic() != Overridden->isVariadic()) { - Diag(Method->getLocation(), + Diag(Method->getLocation(), diag::warn_conflicting_overriding_variadic); Diag(Overridden->getLocation(), diag::note_previous_declaration); } @@ -2587,20 +2587,20 @@ void Sema::WarnExactTypedMethods(ObjCMethodDecl *ImpMethodDecl, // to implement it. if (MethodDecl->getImplementationControl() == ObjCMethodDecl::Optional) return; - // don't issue warning when primary class's method is + // don't issue warning when primary class's method is // depecated/unavailable. if (MethodDecl->hasAttr<UnavailableAttr>() || MethodDecl->hasAttr<DeprecatedAttr>()) return; - - bool match = CheckMethodOverrideReturn(*this, ImpMethodDecl, MethodDecl, + + bool match = CheckMethodOverrideReturn(*this, ImpMethodDecl, MethodDecl, IsProtocolMethodDecl, false, false); if (match) for (ObjCMethodDecl::param_iterator IM = ImpMethodDecl->param_begin(), IF = MethodDecl->param_begin(), EM = ImpMethodDecl->param_end(), EF = MethodDecl->param_end(); IM != EM && IF != EF; ++IM, ++IF) { - match = CheckMethodOverrideParam(*this, ImpMethodDecl, MethodDecl, + match = CheckMethodOverrideParam(*this, ImpMethodDecl, MethodDecl, *IM, *IF, IsProtocolMethodDecl, false, false); if (!match) @@ -2611,9 +2611,9 @@ void Sema::WarnExactTypedMethods(ObjCMethodDecl *ImpMethodDecl, if (match) match = !(MethodDecl->isClassMethod() && MethodDecl->getSelector() == GetNullarySelector("load", Context)); - + if (match) { - Diag(ImpMethodDecl->getLocation(), + Diag(ImpMethodDecl->getLocation(), diag::warn_category_method_impl_match); Diag(MethodDecl->getLocation(), diag::note_method_declared_at) << MethodDecl->getDeclName(); @@ -2662,10 +2662,10 @@ static void CheckProtocolMethodDefs(Sema &S, ObjCContainerDecl *CDecl, LazyProtocolNameSet &ProtocolsExplictImpl) { ObjCCategoryDecl *C = dyn_cast<ObjCCategoryDecl>(CDecl); - ObjCInterfaceDecl *IDecl = C ? C->getClassInterface() + ObjCInterfaceDecl *IDecl = C ? C->getClassInterface() : dyn_cast<ObjCInterfaceDecl>(CDecl); assert (IDecl && "CheckProtocolMethodDefs - IDecl is null"); - + ObjCInterfaceDecl *Super = IDecl->getSuperClass(); ObjCInterfaceDecl *NSIDecl = nullptr; @@ -2714,7 +2714,7 @@ static void CheckProtocolMethodDefs(Sema &S, if (!PDecl->isThisDeclarationADefinition() && PDecl->getDefinition()) PDecl = PDecl->getDefinition(); - + // If a method lookup fails locally we still need to look and see if // the method was implemented by a base class or an inherited // protocol. This lookup is slow, but occurs rarely in correct code @@ -2733,10 +2733,10 @@ static void CheckProtocolMethodDefs(Sema &S, nullptr /* category */))) { // If a method is not implemented in the category implementation but // has been declared in its primary class, superclass, - // or in one of their protocols, no need to issue the warning. - // This is because method will be implemented in the primary class + // or in one of their protocols, no need to issue the warning. + // This is because method will be implemented in the primary class // or one of its super class implementation. - + // Ugly, but necessary. Method declared in protocol might have // have been synthesized due to a property declared in the class which // uses the protocol. @@ -2846,7 +2846,7 @@ void Sema::MatchAllMethodDeclarations(const SelectorSet &InsMap, } } } - + if (ObjCProtocolDecl *PD = dyn_cast<ObjCProtocolDecl> (CDecl)) { // Also, check for methods declared in protocols inherited by // this protocol. @@ -2855,7 +2855,7 @@ void Sema::MatchAllMethodDeclarations(const SelectorSet &InsMap, IMPDecl, PI, IncompleteImpl, false, WarnCategoryMethodImpl); } - + if (ObjCInterfaceDecl *I = dyn_cast<ObjCInterfaceDecl> (CDecl)) { // when checking that methods in implementation match their declaration, // i.e. when WarnCategoryMethodImpl is false, check declarations in class @@ -2880,8 +2880,8 @@ void Sema::MatchAllMethodDeclarations(const SelectorSet &InsMap, IMPDecl, PI, IncompleteImpl, false, WarnCategoryMethodImpl); - // FIXME. For now, we are not checking for extact match of methods - // in category implementation and its primary class's super class. + // FIXME. For now, we are not checking for extact match of methods + // in category implementation and its primary class's super class. if (!WarnCategoryMethodImpl && I->getSuperClass()) MatchAllMethodDeclarations(InsMap, ClsMap, InsMapSeen, ClsMapSeen, IMPDecl, @@ -2891,7 +2891,7 @@ void Sema::MatchAllMethodDeclarations(const SelectorSet &InsMap, /// CheckCategoryVsClassMethodMatches - Checks that methods implemented in /// category matches with those implemented in its primary class and -/// warns each time an exact match is found. +/// warns each time an exact match is found. void Sema::CheckCategoryVsClassMethodMatches( ObjCCategoryImplDecl *CatIMPDecl) { // Get category's primary class. @@ -2903,7 +2903,7 @@ void Sema::CheckCategoryVsClassMethodMatches( return; ObjCInterfaceDecl *SuperIDecl = IDecl->getSuperClass(); SelectorSet InsMap, ClsMap; - + for (const auto *I : CatIMPDecl->instance_methods()) { Selector Sel = I->getSelector(); // When checking for methods implemented in the category, skip over @@ -2913,7 +2913,7 @@ void Sema::CheckCategoryVsClassMethodMatches( continue; InsMap.insert(Sel); } - + for (const auto *I : CatIMPDecl->class_methods()) { Selector Sel = I->getSelector(); if (SuperIDecl && SuperIDecl->lookupMethod(Sel, false)) @@ -2922,12 +2922,12 @@ void Sema::CheckCategoryVsClassMethodMatches( } if (InsMap.empty() && ClsMap.empty()) return; - + SelectorSet InsMapSeen, ClsMapSeen; bool IncompleteImpl = false; MatchAllMethodDeclarations(InsMap, ClsMap, InsMapSeen, ClsMapSeen, CatIMPDecl, IDecl, - IncompleteImpl, false, + IncompleteImpl, false, true /*WarnCategoryMethodImpl*/); } @@ -2977,10 +2977,10 @@ void Sema::ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl, MatchAllMethodDeclarations(InsMap, ClsMap, InsMapSeen, ClsMapSeen, IMPDecl, CDecl, IncompleteImpl, true); - + // check all methods implemented in category against those declared // in its primary class. - if (ObjCCategoryImplDecl *CatDecl = + if (ObjCCategoryImplDecl *CatDecl = dyn_cast<ObjCCategoryImplDecl>(IMPDecl)) CheckCategoryVsClassMethodMatches(CatDecl); @@ -3005,7 +3005,7 @@ void Sema::ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl, ExplicitImplProtocols); DiagnoseUnimplementedProperties(S, IMPDecl, CDecl, /*SynthesizeProperties=*/false); - } + } } else llvm_unreachable("invalid ObjCContainerDecl type."); } @@ -3020,7 +3020,7 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc, for (unsigned i = 0; i != NumElts; ++i) { // Check for another declaration kind with the same name. NamedDecl *PrevDecl - = LookupSingleName(TUScope, IdentList[i], IdentLocs[i], + = LookupSingleName(TUScope, IdentList[i], IdentLocs[i], LookupOrdinaryName, forRedeclarationInCurContext()); if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) { // GCC apparently allows the following idiom: @@ -3047,7 +3047,7 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc, } } } - + // Create a declaration to describe this forward declaration. ObjCInterfaceDecl *PrevIDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl); @@ -3138,7 +3138,7 @@ static bool matchTypes(ASTContext &Context, Sema::MethodMatchStrategy strategy, // Consider all the kinds of non-dependent canonical types: // - functions and arrays aren't possible as return and parameter types - + // - vector types of equal size can be arbitrarily mixed if (isa<VectorType>(left)) return isa<VectorType>(right); if (isa<VectorType>(right)) return false; @@ -3386,14 +3386,14 @@ void Sema::AddMethodToGlobalPool(ObjCMethodDecl *Method, bool impl, if (ExternalSource) ReadMethodPool(Method->getSelector()); - + GlobalMethodPool::iterator Pos = MethodPool.find(Method->getSelector()); if (Pos == MethodPool.end()) Pos = MethodPool.insert(std::make_pair(Method->getSelector(), GlobalMethods())).first; Method->setDefined(impl); - + ObjCMethodList &Entry = instance ? Pos->second.first : Pos->second.second; addMethodToGlobalList(&Entry, Method); } @@ -3521,7 +3521,7 @@ ObjCMethodDecl *Sema::LookupMethodInGlobalPool(Selector Sel, SourceRange R, bool instance) { if (ExternalSource) ReadMethodPool(Sel); - + GlobalMethodPool::iterator Pos = MethodPool.find(Sel); if (Pos == MethodPool.end()) return nullptr; @@ -3571,7 +3571,7 @@ void Sema::DiagnoseMultipleMethodInGlobalPool(SmallVectorImpl<ObjCMethodDecl*> & break; } } - + if (issueDiagnostic) { if (issueError) Diag(R.getBegin(), diag::err_arc_multiple_method_decl) << Sel << R; @@ -3579,7 +3579,7 @@ void Sema::DiagnoseMultipleMethodInGlobalPool(SmallVectorImpl<ObjCMethodDecl*> & Diag(R.getBegin(), diag::warn_strict_multiple_method_decl) << Sel << R; else Diag(R.getBegin(), diag::warn_multiple_method_decl) << Sel << R; - + Diag(Methods[0]->getLocStart(), issueError ? diag::note_possibility : diag::note_using) << Methods[0]->getSourceRange(); @@ -3602,7 +3602,7 @@ ObjCMethodDecl *Sema::LookupImplementedMethodInGlobalPool(Selector Sel) { (Method->getMethod()->isDefined() || Method->getMethod()->isPropertyAccessor())) return Method->getMethod(); - + for (const ObjCMethodList *Method = &Methods.second; Method; Method = Method->getNext()) if (Method->getMethod() && @@ -3619,7 +3619,7 @@ HelperSelectorsForTypoCorrection( const unsigned MaxEditDistance = 1; unsigned BestEditDistance = MaxEditDistance + 1; std::string MethodName = Method->getSelector().getAsString(); - + unsigned MinPossibleEditDistance = abs((int)MethodName.size() - (int)Typo.size()); if (MinPossibleEditDistance > 0 && Typo.size() / MinPossibleEditDistance < 1) @@ -3694,7 +3694,7 @@ Sema::SelectorsForTypoCorrection(Selector Sel, Methods.push_back(M->getMethod()); } } - + SmallVector<const ObjCMethodDecl *, 8> SelectedMethods; for (unsigned i = 0, e = Methods.size(); i < e; i++) { HelperSelectorsForTypoCorrection(SelectedMethods, @@ -3704,11 +3704,11 @@ Sema::SelectorsForTypoCorrection(Selector Sel, } /// DiagnoseDuplicateIvars - -/// Check for duplicate ivars in the entire class at the start of +/// Check for duplicate ivars in the entire class at the start of /// \@implementation. This becomes necesssary because class extension can /// add ivars to a class in random order which will not be known until /// class's \@implementation is seen. -void Sema::DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, +void Sema::DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, ObjCInterfaceDecl *SID) { for (auto *Ivar : ID->ivars()) { if (Ivar->isInvalidDecl()) @@ -3980,7 +3980,7 @@ Decl *Sema::ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef<Decl *> allMethods, if (const ObjCPropertyImplDecl *PIDecl = IC->FindPropertyImplDecl(Property->getIdentifier(), Property->getQueryKind())) - if (PIDecl->getPropertyImplementation() + if (PIDecl->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic) continue; @@ -4107,12 +4107,12 @@ CvtQTToAstBitMask(ObjCDeclSpec::ObjCDeclQualifier PQTVal) { /// Check whether the declared result type of the given Objective-C /// method declaration is compatible with the method's class. /// -static Sema::ResultTypeCompatibilityKind +static Sema::ResultTypeCompatibilityKind CheckRelatedResultTypeCompatibility(Sema &S, ObjCMethodDecl *Method, ObjCInterfaceDecl *CurrentClass) { QualType ResultType = Method->getReturnType(); - // If an Objective-C method inherits its related result type, then its + // If an Objective-C method inherits its related result type, then its // declared result type must be compatible with its own class type. The // declared result type is compatible if: if (const ObjCObjectPointerType *ResultObjectType @@ -4121,25 +4121,25 @@ CheckRelatedResultTypeCompatibility(Sema &S, ObjCMethodDecl *Method, if (ResultObjectType->isObjCIdType() || ResultObjectType->isObjCQualifiedIdType()) return Sema::RTC_Compatible; - + if (CurrentClass) { - if (ObjCInterfaceDecl *ResultClass + if (ObjCInterfaceDecl *ResultClass = ResultObjectType->getInterfaceDecl()) { // - it is the same as the method's class type, or if (declaresSameEntity(CurrentClass, ResultClass)) return Sema::RTC_Compatible; - + // - it is a superclass of the method's class type if (ResultClass->isSuperClassOf(CurrentClass)) return Sema::RTC_Compatible; - } + } } else { // Any Objective-C pointer type might be acceptable for a protocol // method; we just don't know. return Sema::RTC_Unknown; } } - + return Sema::RTC_Incompatible; } @@ -4163,7 +4163,7 @@ public: if (it == S.MethodPool.end()) { if (!S.getExternalSource()) return; S.ReadMethodPool(selector); - + it = S.MethodPool.find(selector); if (it == S.MethodPool.end()) return; @@ -4211,7 +4211,7 @@ private: void searchFrom(ObjCProtocolDecl *protocol) { if (!protocol->hasDefinition()) return; - + // A method in a protocol declaration overrides declarations from // referenced ("parent") protocols. search(protocol->getReferencedProtocols()); @@ -4243,7 +4243,7 @@ private: // A method in a class declaration overrides declarations from if (!iface->hasDefinition()) return; - + // - categories, for (auto *Cat : iface->known_categories()) search(Cat); @@ -4360,11 +4360,11 @@ void Sema::CheckObjCMethodOverrides(ObjCMethodDecl *ObjCMethod, continue; // Conflicting properties are detected elsewhere. // Check for overriding methods - if (isa<ObjCInterfaceDecl>(ObjCMethod->getDeclContext()) || + if (isa<ObjCInterfaceDecl>(ObjCMethod->getDeclContext()) || isa<ObjCImplementationDecl>(ObjCMethod->getDeclContext())) CheckConflictingOverridingMethod(ObjCMethod, overridden, isa<ObjCProtocolDecl>(overridden->getDeclContext())); - + if (CurrentClass && overridden->getDeclContext() != CurrentClass && isa<ObjCInterfaceDecl>(overridden->getDeclContext()) && !overridden->isImplicit() /* not meant for properties */) { @@ -4574,17 +4574,17 @@ Decl *Sema::ActOnMethodDeclaration( ArgType = GetTypeFromParser(ArgInfo[i].Type, &DI); } - LookupResult R(*this, ArgInfo[i].Name, ArgInfo[i].NameLoc, + LookupResult R(*this, ArgInfo[i].Name, ArgInfo[i].NameLoc, LookupOrdinaryName, forRedeclarationInCurContext()); LookupName(R, S); if (R.isSingleResult()) { NamedDecl *PrevDecl = R.getFoundDecl(); if (S->isDeclScope(PrevDecl)) { - Diag(ArgInfo[i].NameLoc, - (MethodDefinition ? diag::warn_method_param_redefinition - : diag::warn_method_param_declaration)) + Diag(ArgInfo[i].NameLoc, + (MethodDefinition ? diag::warn_method_param_redefinition + : diag::warn_method_param_declaration)) << ArgInfo[i].Name; - Diag(PrevDecl->getLocation(), + Diag(PrevDecl->getLocation(), diag::note_previous_declaration); } } @@ -4615,7 +4615,7 @@ Decl *Sema::ActOnMethodDeclaration( Params.push_back(Param); } - + for (unsigned i = 0, e = CNumArgs; i != e; ++i) { ParmVarDecl *Param = cast<ParmVarDecl>(CParamInfo[i].Param); QualType ArgType = Param->getType(); @@ -4628,7 +4628,7 @@ Decl *Sema::ActOnMethodDeclaration( Param->setDeclContext(ObjCMethod); Params.push_back(Param); } - + ObjCMethod->setMethodParams(Context, Params, SelectorLocs); ObjCMethod->setObjCDeclQualifier( CvtQTToAstBitMask(ReturnQT.getObjCDeclQualifier())); @@ -4730,12 +4730,12 @@ Decl *Sema::ActOnMethodDeclaration( case OMF_initialize: case OMF_performSelector: break; - + case OMF_alloc: case OMF_new: InferRelatedResultType = ObjCMethod->isClassMethod(); break; - + case OMF_init: case OMF_autorelease: case OMF_retain: @@ -4743,7 +4743,7 @@ Decl *Sema::ActOnMethodDeclaration( InferRelatedResultType = ObjCMethod->isInstanceMethod(); break; } - + if (InferRelatedResultType && !ObjCMethod->getReturnType()->isObjCIndependentClassType()) ObjCMethod->SetRelatedResultType(); @@ -4779,7 +4779,7 @@ bool Sema::CheckObjCDeclScope(Decl *D) { // an objc container, it means the parser missed emitting an error. if (isa<TranslationUnitDecl>(getCurLexicalContext()->getRedeclContext())) return false; - + Diag(D->getLocation(), diag::err_objc_decls_may_only_appear_in_global_scope); D->setInvalidDecl(); @@ -4834,7 +4834,7 @@ VarDecl *Sema::BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType T, SourceLocation IdLoc, IdentifierInfo *Id, bool Invalid) { - // ISO/IEC TR 18037 S6.7.3: "The type of an object with automatic storage + // ISO/IEC TR 18037 S6.7.3: "The type of an object with automatic storage // duration shall not be qualified by an address-space qualifier." // Since all parameters have automatic store duration, they can not have // an address space. @@ -4842,7 +4842,7 @@ VarDecl *Sema::BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType T, Diag(IdLoc, diag::err_arg_with_address_space); Invalid = true; } - + // An @catch parameter must be an unqualified object pointer type; // FIXME: Recover from "NSObject foo" by inserting the * in "NSObject *foo"? if (Invalid) { @@ -4861,11 +4861,11 @@ VarDecl *Sema::BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType T, Invalid = true; Diag(IdLoc, diag::err_catch_param_not_objc_type); } - + VarDecl *New = VarDecl::Create(Context, CurContext, StartLoc, IdLoc, Id, T, TInfo, SC_None); New->setExceptionVariable(true); - + // In ARC, infer 'retaining' for variables of retainable type. if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(New)) Invalid = true; @@ -4877,7 +4877,7 @@ VarDecl *Sema::BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType T, Decl *Sema::ActOnObjCExceptionDecl(Scope *S, Declarator &D) { const DeclSpec &DS = D.getDeclSpec(); - + // We allow the "register" storage class on exception variables because // GCC did, but we drop it completely. Any other storage class is an error. if (DS.getStorageClassSpec() == DeclSpec::SCS_register) { @@ -4897,12 +4897,12 @@ Decl *Sema::ActOnObjCExceptionDecl(Scope *S, Declarator &D) { D.getMutableDeclSpec().ClearStorageClassSpecs(); DiagnoseFunctionSpecifiers(D.getDeclSpec()); - + // Check that there are no default arguments inside the type of this // exception object (C++ only). if (getLangOpts().CPlusPlus) CheckExtraCXXDefaultArguments(D); - + TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S); QualType ExceptionType = TInfo->getType(); @@ -4911,21 +4911,21 @@ Decl *Sema::ActOnObjCExceptionDecl(Scope *S, Declarator &D) { D.getIdentifierLoc(), D.getIdentifier(), D.isInvalidType()); - + // Parameter declarators cannot be qualified (C++ [dcl.meaning]p1). if (D.getCXXScopeSpec().isSet()) { Diag(D.getIdentifierLoc(), diag::err_qualified_objc_catch_parm) << D.getCXXScopeSpec().getRange(); New->setInvalidDecl(); } - + // Add the parameter declaration into this scope. S->AddDecl(New); if (D.getIdentifier()) IdResolver.AddDecl(New); - + ProcessDeclAttributes(S, New, D); - + if (New->hasAttr<BlocksAttr>()) Diag(New->getLocation(), diag::err_block_on_nonlocal); return New; @@ -4935,7 +4935,7 @@ Decl *Sema::ActOnObjCExceptionDecl(Scope *S, Declarator &D) { /// initialization. void Sema::CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI, SmallVectorImpl<ObjCIvarDecl*> &Ivars) { - for (ObjCIvarDecl *Iv = OI->all_declared_ivar_begin(); Iv; + for (ObjCIvarDecl *Iv = OI->all_declared_ivar_begin(); Iv; Iv= Iv->getNextIvar()) { QualType QT = Context.getBaseElementType(Iv->getType()); if (QT->isRecordType()) @@ -4951,11 +4951,11 @@ void Sema::DiagnoseUseOfUnimplementedSelectors() { for (unsigned I = 0, N = Sels.size(); I != N; ++I) ReferencedSelectors[Sels[I].first] = Sels[I].second; } - + // Warning will be issued only when selector table is // generated (which means there is at lease one implementation // in the TU). This is to match gcc's behavior. - if (ReferencedSelectors.empty() || + if (ReferencedSelectors.empty() || !Context.AnyObjCImplementation()) return; for (auto &SelectorAndLocation : ReferencedSelectors) { diff --git a/lib/Sema/SemaExceptionSpec.cpp b/lib/Sema/SemaExceptionSpec.cpp index df5bc9b82b..134c76ef28 100644 --- a/lib/Sema/SemaExceptionSpec.cpp +++ b/lib/Sema/SemaExceptionSpec.cpp @@ -385,7 +385,7 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) { OnFirstException = false; else OS << ", "; - + OS << E.getAsString(getPrintingPolicy()); } OS << ")"; diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 60abd718e2..3dc6fb151c 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -248,7 +248,7 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs, Diag(Loc, diag::err_deleted_inherited_ctor_use) << Ctor->getParent() << Ctor->getInheritedConstructor().getConstructor()->getParent(); - else + else Diag(Loc, diag::err_deleted_function_use); NoteDeletedFunction(FD); return true; @@ -401,7 +401,7 @@ void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, if (MissingNilLoc.isInvalid()) Diag(Loc, diag::warn_missing_sentinel) << int(calleeType); else - Diag(MissingNilLoc, diag::warn_missing_sentinel) + Diag(MissingNilLoc, diag::warn_missing_sentinel) << int(calleeType) << FixItHint::CreateInsertion(MissingNilLoc, ", " + NullValue); Diag(D->getLocation(), diag::note_sentinel_here) << int(calleeType); @@ -423,7 +423,7 @@ ExprResult Sema::DefaultFunctionArrayConversion(Expr *E, bool Diagnose) { if (result.isInvalid()) return ExprError(); E = result.get(); } - + QualType Ty = E->getType(); assert(!Ty.isNull() && "DefaultFunctionArrayConversion - missing type"); @@ -479,12 +479,12 @@ static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE, const ObjCIvarDecl *IV = OIRE->getDecl(); if (!IV) return; - + DeclarationName MemberName = IV->getDeclName(); IdentifierInfo *Member = MemberName.getAsIdentifierInfo(); if (!Member || !Member->isStr("isa")) return; - + const Expr *Base = OIRE->getBase(); QualType BaseType = Base->getType(); if (OIRE->isArrow()) @@ -536,7 +536,7 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) { if (result.isInvalid()) return ExprError(); E = result.get(); } - + // C++ [conv.lval]p1: // A glvalue of a non-function, non-array type T can be // converted to a prvalue. @@ -604,8 +604,8 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) { (void)isCompleteType(E->getExprLoc(), T); UpdateMarkingForLValueToRValue(E); - - // Loading a __weak object implicitly retains the value, so we need a cleanup to + + // Loading a __weak object implicitly retains the value, so we need a cleanup to // balance that. if (E->getType().getObjCLifetime() == Qualifiers::OCL_Weak) Cleanup.setExprNeedsCleanups(true); @@ -614,14 +614,14 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) { nullptr, VK_RValue); // C11 6.3.2.1p2: - // ... if the lvalue has atomic type, the value has the non-atomic version + // ... if the lvalue has atomic type, the value has the non-atomic version // of the type of the lvalue ... if (const AtomicType *Atomic = T->getAs<AtomicType>()) { T = Atomic->getValueType().getUnqualifiedType(); Res = ImplicitCastExpr::Create(Context, T, CK_AtomicToNonAtomic, Res.get(), nullptr, VK_RValue); } - + return Res; } @@ -876,7 +876,7 @@ ExprResult Sema::DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, E = ExprRes.get(); } } - + ExprResult ExprRes = DefaultArgumentPromotion(E); if (ExprRes.isInvalid()) return ExprError(); @@ -1011,7 +1011,7 @@ static QualType handleIntToFloatConversion(Sema &S, ExprResult &FloatExpr, CK_IntegralToFloating); return FloatTy; } - + // Convert both sides to the appropriate complex float. assert(IntTy->isComplexIntegerType()); QualType result = S.Context.getComplexType(FloatTy); @@ -1201,7 +1201,7 @@ static QualType handleComplexIntConversion(Sema &S, ExprResult &LHS, QualType ComplexType = S.Context.getComplexType(ScalarType); RHS = S.ImpCastExprToType(RHS.get(), ComplexType, CK_IntegralRealToComplex); - + return ComplexType; } @@ -1212,7 +1212,7 @@ static QualType handleComplexIntConversion(Sema &S, ExprResult &LHS, handleIntegerConversion<doIntegralCast, doComplexIntegralCast> (S, LHS, RHS, LHSType, RHSEltType, IsCompAssign); QualType ComplexType = S.Context.getComplexType(ScalarType); - + if (!IsCompAssign) LHS = S.ImpCastExprToType(LHS.get(), ComplexType, CK_IntegralRealToComplex); @@ -2099,7 +2099,7 @@ Sema::ActOnIdExpression(Scope *S, CXXScopeSpec &SS, bool IvarLookupFollowUp = II && !SS.isSet() && getCurMethodDecl(); LookupParsedName(R, S, &SS, !IvarLookupFollowUp); - // If the result might be in a dependent base class, this is a dependent + // If the result might be in a dependent base class, this is a dependent // id-expression. if (R.getResultKind() == LookupResult::NotFoundInCurrentInstantiation) return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo, @@ -2357,7 +2357,7 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S, IdentifierInfo *II, bool AllowBuiltinCreation) { SourceLocation Loc = Lookup.getNameLoc(); ObjCMethodDecl *CurMethod = getCurMethodDecl(); - + // Check for error condition which is already reported. if (!CurMethod) return ExprError(); @@ -2445,7 +2445,7 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S, Diag(Loc, diag::warn_implicitly_retains_self) << FixItHint::CreateInsertion(Loc, "self->"); } - + return Result; } } else if (CurMethod->isInstanceMethod()) { @@ -2918,7 +2918,7 @@ ExprResult Sema::BuildDeclarationNameExpr( if (!CapturedType.isNull()) type = CapturedType; } - + break; } @@ -2934,7 +2934,7 @@ ExprResult Sema::BuildDeclarationNameExpr( diagnoseUncapturableValueReference(*this, Loc, BD, CurContext); break; } - + case Decl::Function: { if (unsigned BID = cast<FunctionDecl>(VD)->getBuiltinID()) { if (!Context.BuiltinInfo.isPredefinedLibFunction(BID)) { @@ -2959,7 +2959,7 @@ ExprResult Sema::BuildDeclarationNameExpr( valueKind = VK_LValue; break; } - + // C99 DR 316 says that, if a function type comes from a // function definition (without a prototype), that type is only // used for checking compatibility. Therefore, when referencing @@ -4029,11 +4029,11 @@ ExprResult Sema::CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind) { ExprResult PE = CheckPlaceholderExpr(E); - if (PE.isInvalid()) + if (PE.isInvalid()) return ExprError(); E = PE.get(); - + // Verify that the operand is valid. bool isInvalid = false; if (E->isTypeDependent()) { @@ -4562,7 +4562,7 @@ bool Sema::CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, diag::note_default_argument_declared_here); return true; } - + if (Param->hasUninstantiatedDefaultArg()) { Expr *UninstExpr = Param->getUninstantiatedDefaultArg(); @@ -4664,7 +4664,7 @@ bool Sema::CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, "default argument expression has capturing blocks?"); } - // We already type-checked the argument, so we know it works. + // We already type-checked the argument, so we know it works. // Just mark all of the declarations in this potentially-evaluated expression // as being "referenced". MarkDeclarationsReferencedInExpr(Param->getDefaultArg(), @@ -4861,7 +4861,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig) Diag(FDecl->getLocStart(), diag::note_callee_decl) << FDecl; - + // This deletes the extra arguments. Call->setNumArgs(Context, NumParams); return true; @@ -4869,7 +4869,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, } SmallVector<Expr *, 8> AllArgs; VariadicCallType CallType = getVariadicCallType(FDecl, Proto, Fn); - + Invalid = GatherArgumentsForCall(Call->getLocStart(), FDecl, Proto, 0, Args, AllArgs, CallType); if (Invalid) @@ -5275,11 +5275,11 @@ tryImplicitlyCaptureThisIfImplicitMemberFunctionAccessWithDependentArgs( // Check if the naming class in which the unresolved members were found is // related (same as or is a base of) to the enclosing class. - + if (!enclosingClassIsRelatedToClassInWhichMembersWereFound(UME, S)) return; - - + + DeclContext *EnclosingFunctionCtx = S.CurContext->getParent()->getParent(); // If the enclosing function is not dependent, then this lambda is // capture ready, so if we can capture this, do so. @@ -5625,7 +5625,7 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments) << (Args.size() > Def->param_size()) << FDecl << Fn->getSourceRange(); } - + // If the function we're calling isn't a function prototype, but we have // a function prototype from a prior declaratiom, use that prototype. if (!FDecl->hasPrototype()) @@ -5643,7 +5643,7 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, PerformCopyInitialization(Entity, SourceLocation(), Arg); if (ArgE.isInvalid()) return true; - + Arg = ArgE.getAs<Expr>(); } else { @@ -5654,7 +5654,7 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, Arg = ArgE.getAs<Expr>(); } - + if (RequireCompleteType(Arg->getLocStart(), Arg->getType(), diag::err_call_incomplete_argument, Arg)) @@ -5728,7 +5728,7 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, InitializedEntity Entity = InitializedEntity::InitializeCompoundLiteralInit(TInfo); InitializationKind Kind - = InitializationKind::CreateCStyleCast(LParenLoc, + = InitializationKind::CreateCStyleCast(LParenLoc, SourceRange(LParenLoc, RParenLoc), /*InitList=*/true); InitializationSequence InitSeq(*this, Entity, Kind, LiteralExpr); @@ -6007,11 +6007,11 @@ static bool breakDownVectorType(QualType type, uint64_t &len, assert(eltType->isScalarType()); return true; } - + // We allow lax conversion to and from non-vector types, but only if // they're real types (i.e. non-complex, non-pointer scalar types). if (!type->isRealType()) return false; - + len = 1; eltType = type; return true; @@ -6026,7 +6026,7 @@ static bool breakDownVectorType(QualType type, uint64_t &len, /// vector nor a real type. bool Sema::areLaxCompatibleVectorTypes(QualType srcTy, QualType destTy) { assert(destTy->isVectorType() || srcTy->isVectorType()); - + // Disallow lax conversions between scalars and ExtVectors (these // conversions are allowed for other vector types because common headers // depend on them). Most scalar OP ExtVector cases are handled by the @@ -6039,13 +6039,13 @@ bool Sema::areLaxCompatibleVectorTypes(QualType srcTy, QualType destTy) { QualType srcEltTy, destEltTy; if (!breakDownVectorType(srcTy, srcLen, srcEltTy)) return false; if (!breakDownVectorType(destTy, destLen, destEltTy)) return false; - + // ASTContext::getTypeSize will return the size rounded up to a // power of 2, so instead of using that, we need to use the raw // element size multiplied by the element count. uint64_t srcEltSize = Context.getTypeSize(srcEltTy); uint64_t destEltSize = Context.getTypeSize(destEltTy); - + return (srcLen * srcEltSize == destLen * destEltSize); } @@ -6053,7 +6053,7 @@ bool Sema::areLaxCompatibleVectorTypes(QualType srcTy, QualType destTy) { /// known to be a vector type? bool Sema::isLaxVectorConversion(QualType srcTy, QualType destTy) { assert(destTy->isVectorType() || srcTy->isVectorType()); - + if (!Context.getLangOpts().LaxVectorConversions) return false; return areLaxCompatibleVectorTypes(srcTy, destTy); @@ -6211,9 +6211,9 @@ Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc, if (getLangOpts().CPlusPlus && !castType->isVoidType() && !getSourceManager().isInSystemMacro(LParenLoc)) Diag(LParenLoc, diag::warn_old_style_cast) << CastExpr->getSourceRange(); - + CheckTollFreeBridgeCast(castType, CastExpr); - + CheckObjCBridgeRelatedCast(castType, CastExpr); DiscardMisalignedMemberAddress(castType.getTypePtr(), CastExpr); @@ -6250,7 +6250,7 @@ ExprResult Sema::BuildVectorLiteral(SourceLocation LParenLoc, SmallVector<Expr *, 8> initExprs; const VectorType *VTy = Ty->getAs<VectorType>(); unsigned numElems = Ty->getAs<VectorType>()->getNumElements(); - + // '(...)' form of vector initialization in AltiVec: the number of // initializers must be one or must match the size of the vector. // If a single value is specified in the initializer then it will be @@ -6290,7 +6290,7 @@ ExprResult Sema::BuildVectorLiteral(SourceLocation LParenLoc, PrepareScalarCast(Literal, ElemTy)); return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.get()); } - + initExprs.append(exprs, exprs + numExprs); } // FIXME: This means that pretty-printing the final AST will produce curly @@ -6787,7 +6787,7 @@ static QualType OpenCLCheckVectorConditional(Sema &S, ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc) { - Cond = S.DefaultFunctionArrayLvalueConversion(Cond.get()); + Cond = S.DefaultFunctionArrayLvalueConversion(Cond.get()); if (Cond.isInvalid()) return QualType(); QualType CondTy = Cond.get()->getType(); @@ -7359,7 +7359,7 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc, ExprValueKind VK = VK_RValue; ExprObjectKind OK = OK_Ordinary; ExprResult Cond = CondExpr, LHS = LHSExpr, RHS = RHSExpr; - QualType result = CheckConditionalOperands(Cond, LHS, RHS, + QualType result = CheckConditionalOperands(Cond, LHS, RHS, VK, OK, QuestionLoc); if (result.isNull() || Cond.isInvalid() || LHS.isInvalid() || RHS.isInvalid()) @@ -7431,7 +7431,7 @@ checkPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType) { // Treat lifetime mismatches as fatal. else if (lhq.getObjCLifetime() != rhq.getObjCLifetime()) ConvTy = Sema::IncompatiblePointerDiscardsQualifiers; - + // For GCC/MS compatibility, other qualifier mismatches are treated // as still compatible in C. else ConvTy = Sema::CompatiblePointerDiscardsQualifiers; @@ -7778,7 +7778,7 @@ Sema::CheckAssignmentConstraints(QualType LHSType, ExprResult &RHS, // - conversions from 'Class' to the redefinition type if (RHSType->isObjCClassType() && - Context.hasSameType(LHSType, + Context.hasSameType(LHSType, Context.getObjCClassRedefinitionType())) { Kind = CK_BitCast; return Compatible; @@ -7845,10 +7845,10 @@ Sema::CheckAssignmentConstraints(QualType LHSType, ExprResult &RHS, // A* -> B* if (RHSType->isObjCObjectPointerType()) { Kind = CK_BitCast; - Sema::AssignConvertType result = + Sema::AssignConvertType result = checkObjCPointerTypesForAssignment(*this, LHSType, RHSType); if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() && - result == Compatible && + result == Compatible && !CheckObjCARCUnavailableWeakConversion(OrigLHSType, RHSType)) result = IncompatibleObjCWeakRef; return result; @@ -7872,7 +7872,7 @@ Sema::CheckAssignmentConstraints(QualType LHSType, ExprResult &RHS, // - conversions to 'Class' from its redefinition type if (LHSType->isObjCClassType() && - Context.hasSameType(RHSType, + Context.hasSameType(RHSType, Context.getObjCClassRedefinitionType())) { return Compatible; } @@ -7881,7 +7881,7 @@ Sema::CheckAssignmentConstraints(QualType LHSType, ExprResult &RHS, } // Only under strict condition T^ is compatible with an Objective-C pointer. - if (RHSType->isBlockPointerType() && + if (RHSType->isBlockPointerType() && LHSType->isBlockCompatibleObjCPointerType(Context)) { if (ConvertRHS) maybeExtendBlockObject(RHS); @@ -8113,7 +8113,7 @@ Sema::CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &CallerRHS, Diag(PDecl->getLocation(), diag::note_entity_declared_at) << PDecl; } } - + CastKind Kind; Sema::AssignConvertType result = CheckAssignmentConstraints(LHSType, RHS, Kind, ConvertRHS); @@ -8249,7 +8249,7 @@ static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar, // The conversion to apply to the scalar before splatting it, // if necessary. CastKind scalarCast = CK_NoOp; - + if (vectorEltTy->isIntegralType(S.Context)) { if (S.getLangOpts().OpenCL && (scalarTy->isRealFloatingType() || (scalarTy->isIntegerType() && @@ -8709,7 +8709,7 @@ QualType Sema::CheckRemainderOperands( if (LHS.get()->getType()->isVectorType() || RHS.get()->getType()->isVectorType()) { - if (LHS.get()->getType()->hasIntegerRepresentation() && + if (LHS.get()->getType()->hasIntegerRepresentation() && RHS.get()->getType()->hasIntegerRepresentation()) return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign, /*AllowBothBool*/getLangOpts().AltiVec, @@ -9061,7 +9061,7 @@ QualType Sema::CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS, // In C++ adding zero to a null pointer is defined. llvm::APSInt KnownVal; if (!getLangOpts().CPlusPlus || - (!IExp->isValueDependent() && + (!IExp->isValueDependent() && (!IExp->EvaluateAsInt(KnownVal, Context) || KnownVal != 0))) { // Check the conditions to see if this is the 'p = nullptr + n' idiom. bool IsGNUIdiom = BinaryOperator::isNullPointerArithmeticExtension( @@ -9138,7 +9138,7 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, Expr::NPC_ValueDependentIsNotNull)) { // In C++ adding zero to a null pointer is defined. llvm::APSInt KnownVal; - if (!getLangOpts().CPlusPlus || + if (!getLangOpts().CPlusPlus || (!RHS.get()->isValueDependent() && (!RHS.get()->EvaluateAsInt(KnownVal, Context) || KnownVal != 0))) { diagnoseArithmeticOnNullPointer(*this, Loc, LHS.get(), false); @@ -10416,7 +10416,7 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, if (isError) return QualType(); } - + if (LHSType->isIntegerType()) LHS = ImpCastExprToType(LHS.get(), RHSType, LHSIsNull ? CK_NullToPointer : CK_IntegralToPointer); @@ -10425,7 +10425,7 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, RHSIsNull ? CK_NullToPointer : CK_IntegralToPointer); return computeResultTy(); } - + // Handle block pointers. if (!IsRelational && RHSIsNull && LHSType->isBlockPointerType() && RHSType->isIntegerType()) { @@ -10596,7 +10596,7 @@ inline QualType Sema::CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS, // Check vector operands differently. if (LHS.get()->getType()->isVectorType() || RHS.get()->getType()->isVectorType()) return CheckVectorLogicalOperands(LHS, RHS, Loc); - + // Diagnose cases where the user write a logical and/or but probably meant a // bitwise one. We do this when the LHS is a non-bool integer and the RHS // is a constant. @@ -11120,7 +11120,7 @@ QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS, << LHSType.getUnqualifiedType(); return QualType(); } - + AssignConvertType ConvTy; if (CompoundType.isNull()) { Expr *RHSCheck = RHS.get(); @@ -11357,7 +11357,7 @@ static QualType CheckIncrementDecrementOperand(Sema &S, Expr *Op, // Otherwise, we just need a complete type. if (checkArithmeticIncompletePointerType(S, OpLoc, Op) || checkArithmeticOnObjCPointer(S, OpLoc, Op)) - return QualType(); + return QualType(); } else if (ResType->isAnyComplexType()) { // C99 does not support ++/-- on complex types, we allow as an extension. S.Diag(OpLoc, diag::ext_integer_increment_complex) @@ -11397,7 +11397,7 @@ static QualType CheckIncrementDecrementOperand(Sema &S, Expr *Op, return ResType.getUnqualifiedType(); } } - + /// getPrimaryDecl - Helper function for CheckAddressOfOperand(). /// This routine allows us to typecheck complex/recursive expressions @@ -11557,7 +11557,7 @@ QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) { Expr::LValueClassification lval = op->ClassifyLValue(Context); unsigned AddressOfError = AO_No_Error; - if (lval == Expr::LV_ClassTemporary || lval == Expr::LV_ArrayTemporary) { + if (lval == Expr::LV_ClassTemporary || lval == Expr::LV_ArrayTemporary) { bool sfinae = (bool)isSFINAEContext(); Diag(OpLoc, isSFINAEContext() ? diag::err_typecheck_addrof_temporary : diag::ext_typecheck_addrof_temporary) @@ -11772,7 +11772,7 @@ static QualType CheckIndirectionOperand(Sema &S, Expr *Op, ExprValueKind &VK, // ...except that certain expressions are never l-values in C. if (!S.getLangOpts().CPlusPlus && Result.isCForbiddenLValueType()) VK = VK_RValue; - + return Result; } @@ -11910,7 +11910,7 @@ static void checkObjCPointerIntrospection(Sema &S, ExprResult &L, ExprResult &R, if (SelArg0.startswith("performSelector")) Diag = diag::warn_objc_pointer_masking_performSelector; } - + S.Diag(OpLoc, Diag) << ObjCPointerExpr->getSourceRange(); } @@ -12209,7 +12209,7 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc, else if (const ObjCIvarRefExpr *OIRE = dyn_cast<ObjCIvarRefExpr>(LHS.get()->IgnoreParenCasts())) DiagnoseDirectIsaAccess(*this, OIRE, OpLoc, RHS.get()); - + // Opc is not a compound assignment if CompResultTy is null. if (CompResultTy.isNull()) { if (ConvertHalfVec) @@ -12549,7 +12549,7 @@ ExprResult Sema::BuildBinOp(Scope *S, SourceLocation OpLoc, return ExprError(); } } - + ExprResult LHS = CheckPlaceholderExpr(LHSExpr); if (LHS.isInvalid()) return ExprError(); LHSExpr = LHS.get(); @@ -12762,7 +12762,7 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc, return ExprError(Diag(OpLoc, diag::err_typecheck_unary_expr) << resultType << Input.get()->getSourceRange()); } - + // LNot always has type int. C99 6.5.3.3p5. // In C++, it's bool. C++ 5.3.1p8 resultType = Context.getLogicalOperationType(); @@ -12820,23 +12820,23 @@ bool Sema::isQualifiedMemberAccess(Expr *E) { if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) { if (!DRE->getQualifier()) return false; - + ValueDecl *VD = DRE->getDecl(); if (!VD->isCXXClassMember()) return false; - + if (isa<FieldDecl>(VD) || isa<IndirectFieldDecl>(VD)) return true; if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(VD)) return Method->isInstance(); - + return false; } - + if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(E)) { if (!ULE->getQualifier()) return false; - + for (NamedDecl *D : ULE->decls()) { if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D)) { if (Method->isInstance()) @@ -12846,10 +12846,10 @@ bool Sema::isQualifiedMemberAccess(Expr *E) { break; } } - + return false; } - + return false; } @@ -13031,17 +13031,17 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, QualType ArgTy = TInfo->getType(); bool Dependent = ArgTy->isDependentType(); SourceRange TypeRange = TInfo->getTypeLoc().getLocalSourceRange(); - + // We must have at least one component that refers to the type, and the first // one is known to be a field designator. Verify that the ArgTy represents // a struct/union/class. if (!Dependent && !ArgTy->isRecordType()) - return ExprError(Diag(BuiltinLoc, diag::err_offsetof_record_type) + return ExprError(Diag(BuiltinLoc, diag::err_offsetof_record_type) << ArgTy << TypeRange); - + // Type must be complete per C99 7.17p3 because a declaring a variable // with an incomplete type would be ill-formed. - if (!Dependent + if (!Dependent && RequireCompleteType(BuiltinLoc, ArgTy, diag::err_offsetof_incomplete_type, TypeRange)) return ExprError(); @@ -13061,7 +13061,7 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, CurrentType = AT->getElementType(); } else CurrentType = Context.DependentTy; - + ExprResult IdxRval = DefaultLvalueConversion(static_cast<Expr*>(OC.U.E)); if (IdxRval.isInvalid()) return ExprError(); @@ -13080,7 +13080,7 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, Exprs.push_back(Idx); continue; } - + // Offset of a field. if (CurrentType->isDependentType()) { // We have the offset of a field, but we can't look into the dependent @@ -13089,19 +13089,19 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, CurrentType = Context.DependentTy; continue; } - + // We need to have a complete type to look into. if (RequireCompleteType(OC.LocStart, CurrentType, diag::err_offsetof_incomplete_type)) return ExprError(); - + // Look for the designated field. const RecordType *RC = CurrentType->getAs<RecordType>(); - if (!RC) + if (!RC) return ExprError(Diag(OC.LocEnd, diag::err_offsetof_record_type) << CurrentType); RecordDecl *RD = RC->getDecl(); - + // C++ [lib.support.types]p5: // The macro offsetof accepts a restricted set of type arguments in this // International Standard. type shall be a POD structure or a POD union @@ -13122,7 +13122,7 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, << CurrentType)) DidWarnAboutNonPOD = true; } - + // Look for the field. LookupResult R(*this, OC.U.IdentInfo, OC.LocStart, LookupMemberName); LookupQualifiedName(R, RD); @@ -13135,9 +13135,9 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, if (!MemberDecl) return ExprError(Diag(BuiltinLoc, diag::err_no_member) - << OC.U.IdentInfo << RD << SourceRange(OC.LocStart, + << OC.U.IdentInfo << RD << SourceRange(OC.LocStart, OC.LocEnd)); - + // C99 7.17p3: // (If the specified member is a bit-field, the behavior is undefined.) // @@ -13180,9 +13180,9 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, } else Comps.push_back(OffsetOfNode(OC.LocStart, MemberDecl, OC.LocEnd)); - CurrentType = MemberDecl->getType().getNonReferenceType(); + CurrentType = MemberDecl->getType().getNonReferenceType(); } - + return OffsetOfExpr::Create(Context, Context.getSizeType(), BuiltinLoc, TInfo, Comps, Exprs, RParenLoc); } @@ -13193,7 +13193,7 @@ ExprResult Sema::ActOnBuiltinOffsetOf(Scope *S, ParsedType ParsedArgTy, ArrayRef<OffsetOfComponent> Components, SourceLocation RParenLoc) { - + TypeSourceInfo *ArgTInfo; QualType ArgTy = GetTypeFromParser(ParsedArgTy, &ArgTInfo); if (ArgTy.isNull()) @@ -13298,7 +13298,7 @@ void Sema::ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, T = Context.getFunctionType(Context.DependentTy, None, EPI); Sig = Context.getTrivialTypeSourceInfo(T); } - + // GetTypeForDeclarator always produces a function type for a block // literal signature. Furthermore, it is always a FunctionProtoType // unless the function was written with a typedef. @@ -13376,7 +13376,7 @@ void Sema::ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, CheckParmsForFunctionDef(CurBlock->TheDecl->parameters(), /*CheckParameterNames=*/false); } - + // Finally we can process decl attributes. ProcessDeclAttributes(CurScope, CurBlock->TheDecl, ParamInfo); @@ -13452,7 +13452,7 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, FunctionType::ExtInfo Ext = FTy->getExtInfo(); if (NoReturn && !Ext.getNoReturn()) Ext = Ext.withNoReturn(true); - + // Turn protoless block types into nullary block types. if (isa<FunctionNoProtoType>(FTy)) { FunctionProtoType::ExtProtoInfo EPI; @@ -13500,7 +13500,7 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, if (getLangOpts().CPlusPlus && RetTy->isRecordType() && !BSI->TheDecl->isDependentContext()) computeNRVO(Body, BSI); - + BlockExpr *Result = new (Context) BlockExpr(BSI->TheDecl, BlockTy); AnalysisBasedWarnings::Policy WP = AnalysisWarnings.getDefaultPolicy(); PopFunctionScopeInfo(&WP, Result->getBlockDecl(), Result); @@ -13674,7 +13674,7 @@ bool Sema::ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&Exp, if (!ID || !ID->getIdentifier()->isStr("NSString")) return false; } - + // Ignore any parens, implicit casts (should only be // array-to-pointer decays), and not-so-opaque values. The last is // important for making this trigger for property assignments. @@ -13907,7 +13907,7 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy, PDecl && IFace && !IFace->hasDefinition()) Diag(IFace->getLocation(), diag::note_incomplete_class_and_qualified_id) << IFace << PDecl; - + if (SecondType == Context.OverloadTy) NoteAllOverloadCandidates(OverloadExpr::find(SrcExpr).Expression, FirstType, /*TakingAddress=*/true); @@ -13917,7 +13917,7 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy, if (Action == AA_Returning && ConvTy == IncompatiblePointer) EmitRelatedResultTypeNoteForReturn(DstType); - + if (Complained) *Complained = true; return isInvalid; @@ -13931,7 +13931,7 @@ ExprResult Sema::VerifyIntegerConstantExpression(Expr *E, S.Diag(Loc, diag::err_expr_not_ice) << S.LangOpts.CPlusPlus << SR; } } Diagnoser; - + return VerifyIntegerConstantExpression(E, Result, Diagnoser); } @@ -13941,16 +13941,16 @@ ExprResult Sema::VerifyIntegerConstantExpression(Expr *E, bool AllowFold) { class IDDiagnoser : public VerifyICEDiagnoser { unsigned DiagID; - + public: IDDiagnoser(unsigned DiagID) : VerifyICEDiagnoser(DiagID == 0), DiagID(DiagID) { } - + void diagnoseNotICE(Sema &S, SourceLocation Loc, SourceRange SR) override { S.Diag(Loc, DiagID) << SR; } } Diagnoser(DiagID); - + return VerifyIntegerConstantExpression(E, Result, Diagnoser, AllowFold); } @@ -14516,19 +14516,19 @@ diagnoseUncapturableValueReference(Sema &S, SourceLocation loc, // capture. } - -static bool isVariableAlreadyCapturedInScopeInfo(CapturingScopeInfo *CSI, VarDecl *Var, + +static bool isVariableAlreadyCapturedInScopeInfo(CapturingScopeInfo *CSI, VarDecl *Var, bool &SubCapturesAreNested, - QualType &CaptureType, + QualType &CaptureType, QualType &DeclRefType) { // Check whether we've already captured it. if (CSI->CaptureMap.count(Var)) { // If we found a capture, any subcaptures are nested. SubCapturesAreNested = true; - + // Retrieve the capture type for this variable. CaptureType = CSI->getCapture(Var).getCaptureType(); - + // Compute the type of an expression that refers to this variable. DeclRefType = CaptureType.getNonReferenceType(); @@ -14548,8 +14548,8 @@ static bool isVariableAlreadyCapturedInScopeInfo(CapturingScopeInfo *CSI, VarDec // Only block literals, captured statements, and lambda expressions can // capture; other scopes don't work. -static DeclContext *getParentOfCapturingContextOrNull(DeclContext *DC, VarDecl *Var, - SourceLocation Loc, +static DeclContext *getParentOfCapturingContextOrNull(DeclContext *DC, VarDecl *Var, + SourceLocation Loc, const bool Diagnose, Sema &S) { if (isa<BlockDecl>(DC) || isa<CapturedDecl>(DC) || isLambdaCallOperator(DC)) return getLambdaAwareParentOfDeclContext(DC); @@ -14560,11 +14560,11 @@ static DeclContext *getParentOfCapturingContextOrNull(DeclContext *DC, VarDecl * return nullptr; } -// Certain capturing entities (lambdas, blocks etc.) are not allowed to capture +// Certain capturing entities (lambdas, blocks etc.) are not allowed to capture // certain types of variables (unnamed, variably modified types etc.) // so check for eligibility. -static bool isVariableCapturable(CapturingScopeInfo *CSI, VarDecl *Var, - SourceLocation Loc, +static bool isVariableCapturable(CapturingScopeInfo *CSI, VarDecl *Var, + SourceLocation Loc, const bool Diagnose, Sema &S) { bool IsBlock = isa<BlockScopeInfo>(CSI); @@ -14586,7 +14586,7 @@ static bool isVariableCapturable(CapturingScopeInfo *CSI, VarDecl *Var, if (Var->getType()->isVariablyModifiedType() && IsBlock) { if (Diagnose) { S.Diag(Loc, diag::err_ref_vm_type); - S.Diag(Var->getLocation(), diag::note_previous_decl) + S.Diag(Var->getLocation(), diag::note_previous_decl) << Var->getDeclName(); } return false; @@ -14631,21 +14631,21 @@ static bool isVariableCapturable(CapturingScopeInfo *CSI, VarDecl *Var, } // Returns true if the capture by block was successful. -static bool captureInBlock(BlockScopeInfo *BSI, VarDecl *Var, - SourceLocation Loc, - const bool BuildAndDiagnose, +static bool captureInBlock(BlockScopeInfo *BSI, VarDecl *Var, + SourceLocation Loc, + const bool BuildAndDiagnose, QualType &CaptureType, - QualType &DeclRefType, + QualType &DeclRefType, const bool Nested, Sema &S) { Expr *CopyExpr = nullptr; bool ByRef = false; - + // Blocks are not allowed to capture arrays. if (CaptureType->isArrayType()) { if (BuildAndDiagnose) { S.Diag(Loc, diag::err_ref_array_type); - S.Diag(Var->getLocation(), diag::note_previous_decl) + S.Diag(Var->getLocation(), diag::note_previous_decl) << Var->getDeclName(); } return false; @@ -14703,7 +14703,7 @@ static bool captureInBlock(BlockScopeInfo *BSI, VarDecl *Var, // Block capture by copy introduces 'const'. CaptureType = CaptureType.getNonReferenceType().withConst(); DeclRefType = CaptureType; - + if (S.getLangOpts().CPlusPlus && BuildAndDiagnose) { if (const RecordType *Record = DeclRefType->getAs<RecordType>()) { // The capture logic needs the destructor, so make sure we mark it. @@ -14723,15 +14723,15 @@ static bool captureInBlock(BlockScopeInfo *BSI, VarDecl *Var, // the stack requires a const copy constructor. This is not true // of the copy/move done to move a __block variable to the heap. Expr *DeclRef = new (S.Context) DeclRefExpr(Var, Nested, - DeclRefType.withConst(), + DeclRefType.withConst(), VK_LValue, Loc); - + ExprResult Result = S.PerformCopyInitialization( InitializedEntity::InitializeBlock(Var->getLocation(), CaptureType, false), Loc, DeclRef); - + // Build a full-expression copy expression if initialization // succeeded and used a non-trivial constructor. Recover from // errors by pretending that the copy isn't necessary. @@ -14747,7 +14747,7 @@ static bool captureInBlock(BlockScopeInfo *BSI, VarDecl *Var, // Actually capture the variable. if (BuildAndDiagnose) - BSI->addCapture(Var, HasBlocksAttr, ByRef, Nested, Loc, + BSI->addCapture(Var, HasBlocksAttr, ByRef, Nested, Loc, SourceLocation(), CaptureType, CopyExpr); return true; @@ -14757,11 +14757,11 @@ static bool captureInBlock(BlockScopeInfo *BSI, VarDecl *Var, /// Capture the given variable in the captured region. static bool captureInCapturedRegion(CapturedRegionScopeInfo *RSI, - VarDecl *Var, - SourceLocation Loc, - const bool BuildAndDiagnose, + VarDecl *Var, + SourceLocation Loc, + const bool BuildAndDiagnose, QualType &CaptureType, - QualType &DeclRefType, + QualType &DeclRefType, const bool RefersToCapturedVariable, Sema &S) { // By default, capture variables by reference. @@ -14799,7 +14799,7 @@ static bool captureInCapturedRegion(CapturedRegionScopeInfo *RSI, RD->addDecl(Field); if (S.getLangOpts().OpenMP && RSI->CapRegionKind == CR_OpenMP) S.setOpenMPCaptureKind(Field, Var, RSI->OpenMPLevel); - + CopyExpr = new (S.Context) DeclRefExpr(Var, RefersToCapturedVariable, DeclRefType, VK_LValue, Loc); Var->setReferenced(true); @@ -14810,14 +14810,14 @@ static bool captureInCapturedRegion(CapturedRegionScopeInfo *RSI, if (BuildAndDiagnose) RSI->addCapture(Var, /*isBlock*/false, ByRef, RefersToCapturedVariable, Loc, SourceLocation(), CaptureType, CopyExpr); - - + + return true; } /// Create a field within the lambda class for the variable /// being captured. -static void addAsFieldToClosureType(Sema &S, LambdaScopeInfo *LSI, +static void addAsFieldToClosureType(Sema &S, LambdaScopeInfo *LSI, QualType FieldType, QualType DeclRefType, SourceLocation Loc, bool RefersToCapturedVariable) { @@ -14835,13 +14835,13 @@ static void addAsFieldToClosureType(Sema &S, LambdaScopeInfo *LSI, /// Capture the given variable in the lambda. static bool captureInLambda(LambdaScopeInfo *LSI, - VarDecl *Var, - SourceLocation Loc, - const bool BuildAndDiagnose, + VarDecl *Var, + SourceLocation Loc, + const bool BuildAndDiagnose, QualType &CaptureType, - QualType &DeclRefType, + QualType &DeclRefType, const bool RefersToCapturedVariable, - const Sema::TryCaptureKind Kind, + const Sema::TryCaptureKind Kind, SourceLocation EllipsisLoc, const bool IsTopScope, Sema &S) { @@ -14853,7 +14853,7 @@ static bool captureInLambda(LambdaScopeInfo *LSI, } else { ByRef = (LSI->ImpCaptureStyle == LambdaScopeInfo::ImpCap_LambdaByref); } - + // Compute the type of the field that will capture this variable. if (ByRef) { // C++11 [expr.prim.lambda]p15: @@ -14865,7 +14865,7 @@ static bool captureInLambda(LambdaScopeInfo *LSI, // // FIXME: It is not clear whether we want to build an lvalue reference // to the DeclRefType or to CaptureType.getNonReferenceType(). GCC appears - // to do the former, while EDG does the latter. Core issue 1249 will + // to do the former, while EDG does the latter. Core issue 1249 will // clarify, but for now we follow GCC because it's a more permissive and // easily defensible position. CaptureType = S.Context.getLValueReferenceType(DeclRefType); @@ -14913,26 +14913,26 @@ static bool captureInLambda(LambdaScopeInfo *LSI, if (BuildAndDiagnose) addAsFieldToClosureType(S, LSI, CaptureType, DeclRefType, Loc, RefersToCapturedVariable); - + // Compute the type of a reference to this captured variable. if (ByRef) DeclRefType = CaptureType.getNonReferenceType(); else { // C++ [expr.prim.lambda]p5: - // The closure type for a lambda-expression has a public inline - // function call operator [...]. This function call operator is - // declared const (9.3.1) if and only if the lambda-expression's + // The closure type for a lambda-expression has a public inline + // function call operator [...]. This function call operator is + // declared const (9.3.1) if and only if the lambda-expression's // parameter-declaration-clause is not followed by mutable. DeclRefType = CaptureType.getNonReferenceType(); if (!LSI->Mutable && !CaptureType->isReferenceType()) - DeclRefType.addConst(); + DeclRefType.addConst(); } - + // Add the capture. if (BuildAndDiagnose) - LSI->addCapture(Var, /*IsBlock=*/false, ByRef, RefersToCapturedVariable, + LSI->addCapture(Var, /*IsBlock=*/false, ByRef, RefersToCapturedVariable, Loc, EllipsisLoc, CaptureType, /*CopyExpr=*/nullptr); - + return true; } @@ -14945,10 +14945,10 @@ bool Sema::tryCaptureVariable( DeclContext *VarDC = Var->getDeclContext(); if (Var->isInitCapture()) VarDC = VarDC->getParent(); - + DeclContext *DC = CurContext; - const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt - ? *FunctionScopeIndexToStopAt : FunctionScopes.size() - 1; + const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt + ? *FunctionScopeIndexToStopAt : FunctionScopes.size() - 1; // We need to sync up the Declaration Context with the // FunctionScopeIndexToStopAt if (FunctionScopeIndexToStopAt) { @@ -14959,7 +14959,7 @@ bool Sema::tryCaptureVariable( } } - + // If the variable is declared in the current context, there is no need to // capture it. if (VarDC == DC) return true; @@ -14975,7 +14975,7 @@ bool Sema::tryCaptureVariable( // performing the "simple" checks that don't depend on type. We stop when // we've either hit the declared scope of the variable or find an existing // capture of that variable. We start from the innermost capturing-entity - // (the DC) and ensure that all intervening capturing-entities + // (the DC) and ensure that all intervening capturing-entities // (blocks/lambdas etc.) between the innermost capturer and the variable`s // declcontext can either capture the variable or have already captured // the variable. @@ -14987,8 +14987,8 @@ bool Sema::tryCaptureVariable( do { // Only block literals, captured statements, and lambda expressions can // capture; other scopes don't work. - DeclContext *ParentDC = getParentOfCapturingContextOrNull(DC, Var, - ExprLoc, + DeclContext *ParentDC = getParentOfCapturingContextOrNull(DC, Var, + ExprLoc, BuildAndDiagnose, *this); // We need to check for the parent *first* because, if we *have* @@ -15007,29 +15007,29 @@ bool Sema::tryCaptureVariable( // Check whether we've already captured it. - if (isVariableAlreadyCapturedInScopeInfo(CSI, Var, Nested, CaptureType, + if (isVariableAlreadyCapturedInScopeInfo(CSI, Var, Nested, CaptureType, DeclRefType)) { CSI->getCapture(Var).markUsed(BuildAndDiagnose); break; } - // If we are instantiating a generic lambda call operator body, + // If we are instantiating a generic lambda call operator body, // we do not want to capture new variables. What was captured // during either a lambdas transformation or initial parsing - // should be used. + // should be used. if (isGenericLambdaCallOperatorSpecialization(DC)) { if (BuildAndDiagnose) { - LambdaScopeInfo *LSI = cast<LambdaScopeInfo>(CSI); + LambdaScopeInfo *LSI = cast<LambdaScopeInfo>(CSI); if (LSI->ImpCaptureStyle == CapturingScopeInfo::ImpCap_None) { Diag(ExprLoc, diag::err_lambda_impcap) << Var->getDeclName(); - Diag(Var->getLocation(), diag::note_previous_decl) + Diag(Var->getLocation(), diag::note_previous_decl) << Var->getDeclName(); - Diag(LSI->Lambda->getLocStart(), diag::note_lambda_decl); + Diag(LSI->Lambda->getLocStart(), diag::note_lambda_decl); } else diagnoseUncapturableValueReference(*this, ExprLoc, Var, DC); } return true; } - // Certain capturing entities (lambdas, blocks etc.) are not allowed to capture + // Certain capturing entities (lambdas, blocks etc.) are not allowed to capture // certain types of variables (unnamed, variably modified types etc.) // so check for eligibility. if (!isVariableCapturable(CSI, Var, ExprLoc, BuildAndDiagnose, *this)) @@ -15070,11 +15070,11 @@ bool Sema::tryCaptureVariable( } } if (CSI->ImpCaptureStyle == CapturingScopeInfo::ImpCap_None && !Explicit) { - // No capture-default, and this is not an explicit capture - // so cannot capture this variable. + // No capture-default, and this is not an explicit capture + // so cannot capture this variable. if (BuildAndDiagnose) { Diag(ExprLoc, diag::err_lambda_impcap) << Var->getDeclName(); - Diag(Var->getLocation(), diag::note_previous_decl) + Diag(Var->getLocation(), diag::note_previous_decl) << Var->getDeclName(); if (cast<LambdaScopeInfo>(CSI)->Lambda) Diag(cast<LambdaScopeInfo>(CSI)->Lambda->getLocStart(), @@ -15083,12 +15083,12 @@ bool Sema::tryCaptureVariable( // capture a variable that an inner lambda explicitly captures, we // should have the inner lambda do the explicit capture - because // it makes for cleaner diagnostics later. This would purely be done - // so that the diagnostic does not misleadingly claim that a variable - // can not be captured by a lambda implicitly even though it is captured + // so that the diagnostic does not misleadingly claim that a variable + // can not be captured by a lambda implicitly even though it is captured // explicitly. Suggestion: - // - create const bool VariableCaptureWasInitiallyExplicit = Explicit + // - create const bool VariableCaptureWasInitiallyExplicit = Explicit // at the function head - // - cache the StartingDeclContext - this must be a lambda + // - cache the StartingDeclContext - this must be a lambda // - captureInLambda in the innermost lambda the variable. } return true; @@ -15100,31 +15100,31 @@ bool Sema::tryCaptureVariable( } while (!VarDC->Equals(DC)); // Walk back down the scope stack, (e.g. from outer lambda to inner lambda) - // computing the type of the capture at each step, checking type-specific - // requirements, and adding captures if requested. - // If the variable had already been captured previously, we start capturing - // at the lambda nested within that one. - for (unsigned I = ++FunctionScopesIndex, N = MaxFunctionScopesIndex + 1; I != N; + // computing the type of the capture at each step, checking type-specific + // requirements, and adding captures if requested. + // If the variable had already been captured previously, we start capturing + // at the lambda nested within that one. + for (unsigned I = ++FunctionScopesIndex, N = MaxFunctionScopesIndex + 1; I != N; ++I) { CapturingScopeInfo *CSI = cast<CapturingScopeInfo>(FunctionScopes[I]); - + if (BlockScopeInfo *BSI = dyn_cast<BlockScopeInfo>(CSI)) { - if (!captureInBlock(BSI, Var, ExprLoc, - BuildAndDiagnose, CaptureType, + if (!captureInBlock(BSI, Var, ExprLoc, + BuildAndDiagnose, CaptureType, DeclRefType, Nested, *this)) return true; Nested = true; } else if (CapturedRegionScopeInfo *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) { - if (!captureInCapturedRegion(RSI, Var, ExprLoc, - BuildAndDiagnose, CaptureType, + if (!captureInCapturedRegion(RSI, Var, ExprLoc, + BuildAndDiagnose, CaptureType, DeclRefType, Nested, *this)) return true; Nested = true; } else { LambdaScopeInfo *LSI = cast<LambdaScopeInfo>(CSI); - if (!captureInLambda(LSI, Var, ExprLoc, - BuildAndDiagnose, CaptureType, - DeclRefType, Nested, Kind, EllipsisLoc, + if (!captureInLambda(LSI, Var, ExprLoc, + BuildAndDiagnose, CaptureType, + DeclRefType, Nested, Kind, EllipsisLoc, /*IsTopScope*/I == N - 1, *this)) return true; Nested = true; @@ -15134,7 +15134,7 @@ bool Sema::tryCaptureVariable( } bool Sema::tryCaptureVariable(VarDecl *Var, SourceLocation Loc, - TryCaptureKind Kind, SourceLocation EllipsisLoc) { + TryCaptureKind Kind, SourceLocation EllipsisLoc) { QualType CaptureType; QualType DeclRefType; return tryCaptureVariable(Var, Loc, Kind, EllipsisLoc, @@ -15153,10 +15153,10 @@ bool Sema::NeedToCaptureVariable(VarDecl *Var, SourceLocation Loc) { QualType Sema::getCapturedDeclRefType(VarDecl *Var, SourceLocation Loc) { QualType CaptureType; QualType DeclRefType; - + // Determine whether we can capture this variable. if (tryCaptureVariable(Var, Loc, TryCapture_Implicit, SourceLocation(), - /*BuildAndDiagnose=*/false, CaptureType, + /*BuildAndDiagnose=*/false, CaptureType, DeclRefType, nullptr)) return QualType(); @@ -15165,49 +15165,49 @@ QualType Sema::getCapturedDeclRefType(VarDecl *Var, SourceLocation Loc) { -// If either the type of the variable or the initializer is dependent, +// If either the type of the variable or the initializer is dependent, // return false. Otherwise, determine whether the variable is a constant // expression. Use this if you need to know if a variable that might or // might not be dependent is truly a constant expression. -static inline bool IsVariableNonDependentAndAConstantExpression(VarDecl *Var, +static inline bool IsVariableNonDependentAndAConstantExpression(VarDecl *Var, ASTContext &Context) { - - if (Var->getType()->isDependentType()) + + if (Var->getType()->isDependentType()) return false; const VarDecl *DefVD = nullptr; Var->getAnyInitializer(DefVD); - if (!DefVD) + if (!DefVD) return false; EvaluatedStmt *Eval = DefVD->ensureEvaluatedStmt(); Expr *Init = cast<Expr>(Eval->Value); - if (Init->isValueDependent()) + if (Init->isValueDependent()) return false; - return IsVariableAConstantExpression(Var, Context); + return IsVariableAConstantExpression(Var, Context); } void Sema::UpdateMarkingForLValueToRValue(Expr *E) { - // Per C++11 [basic.def.odr], a variable is odr-used "unless it is + // Per C++11 [basic.def.odr], a variable is odr-used "unless it is // an object that satisfies the requirements for appearing in a // constant expression (5.19) and the lvalue-to-rvalue conversion (4.1) // is immediately applied." This function handles the lvalue-to-rvalue // conversion part. MaybeODRUseExprs.erase(E->IgnoreParens()); - + // If we are in a lambda, check if this DeclRefExpr or MemberExpr refers // to a variable that is a constant expression, and if so, identify it as - // a reference to a variable that does not involve an odr-use of that - // variable. + // a reference to a variable that does not involve an odr-use of that + // variable. if (LambdaScopeInfo *LSI = getCurLambda()) { Expr *SansParensExpr = E->IgnoreParens(); VarDecl *Var = nullptr; - if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(SansParensExpr)) + if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(SansParensExpr)) Var = dyn_cast<VarDecl>(DRE->getFoundDecl()); else if (MemberExpr *ME = dyn_cast<MemberExpr>(SansParensExpr)) Var = dyn_cast<VarDecl>(ME->getMemberDecl()); - - if (Var && IsVariableNonDependentAndAConstantExpression(Var, Context)) - LSI->markVariableExprAsNonODRUsed(SansParensExpr); + + if (Var && IsVariableNonDependentAndAConstantExpression(Var, Context)) + LSI->markVariableExprAsNonODRUsed(SansParensExpr); } } @@ -15508,13 +15508,13 @@ namespace { class EvaluatedExprMarker : public EvaluatedExprVisitor<EvaluatedExprMarker> { Sema &S; bool SkipLocalVariables; - + public: typedef EvaluatedExprVisitor<EvaluatedExprMarker> Inherited; - - EvaluatedExprMarker(Sema &S, bool SkipLocalVariables) + + EvaluatedExprMarker(Sema &S, bool SkipLocalVariables) : Inherited(S.Context), S(S), SkipLocalVariables(SkipLocalVariables) { } - + void VisitDeclRefExpr(DeclRefExpr *E) { // If we were asked not to visit local variables, don't. if (SkipLocalVariables) { @@ -15522,7 +15522,7 @@ namespace { if (VD->hasLocalStorage()) return; } - + S.MarkDeclRefReferenced(E); } @@ -15530,13 +15530,13 @@ namespace { S.MarkMemberReferenced(E); Inherited::VisitMemberExpr(E); } - + void VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { S.MarkFunctionReferenced(E->getLocStart(), const_cast<CXXDestructorDecl*>(E->getTemporary()->getDestructor())); Visit(E->getSubExpr()); } - + void VisitCXXNewExpr(CXXNewExpr *E) { if (E->getOperatorNew()) S.MarkFunctionReferenced(E->getLocStart(), E->getOperatorNew()); @@ -15551,18 +15551,18 @@ namespace { QualType Destroyed = S.Context.getBaseElementType(E->getDestroyedType()); if (const RecordType *DestroyedRec = Destroyed->getAs<RecordType>()) { CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl()); - S.MarkFunctionReferenced(E->getLocStart(), + S.MarkFunctionReferenced(E->getLocStart(), S.LookupDestructor(Record)); } - + Inherited::VisitCXXDeleteExpr(E); } - + void VisitCXXConstructExpr(CXXConstructExpr *E) { S.MarkFunctionReferenced(E->getLocStart(), E->getConstructor()); Inherited::VisitCXXConstructExpr(E); } - + void VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) { Visit(E->getExpr()); } @@ -15579,9 +15579,9 @@ namespace { /// Mark any declarations that appear within this expression or any /// potentially-evaluated subexpressions as "referenced". /// -/// \param SkipLocalVariables If true, don't mark local variables as +/// \param SkipLocalVariables If true, don't mark local variables as /// 'referenced'. -void Sema::MarkDeclarationsReferencedInExpr(Expr *E, +void Sema::MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables) { EvaluatedExprMarker(*this, SkipLocalVariables).Visit(E); } @@ -15661,7 +15661,7 @@ bool Sema::CheckCallReturnType(QualType ReturnType, SourceLocation Loc, class CallReturnIncompleteDiagnoser : public TypeDiagnoser { FunctionDecl *FD; CallExpr *CE; - + public: CallReturnIncompleteDiagnoser(FunctionDecl *FD, CallExpr *CE) : FD(FD), CE(CE) { } @@ -15672,14 +15672,14 @@ bool Sema::CheckCallReturnType(QualType ReturnType, SourceLocation Loc, << T << CE->getSourceRange(); return; } - + S.Diag(Loc, diag::err_call_function_incomplete_return) << CE->getSourceRange() << FD->getDeclName() << T; S.Diag(FD->getLocation(), diag::note_entity_declared_at) << FD->getDeclName(); } } Diagnoser(FD, CE); - + if (RequireCompleteType(Loc, ReturnType, Diagnoser)) return true; @@ -15762,7 +15762,7 @@ void Sema::DiagnoseEqualityWithExtraParens(ParenExpr *ParenE) { opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(Context) == Expr::MLV_Valid) { SourceLocation Loc = opE->getOperatorLoc(); - + Diag(Loc, diag::warn_equality_with_extra_parens) << E->getSourceRange(); SourceRange ParenERange = ParenE->getSourceRange(); Diag(Loc, diag::note_equality_comparison_silence) @@ -16099,7 +16099,7 @@ ExprResult RebuildUnknownAnyExpr::VisitCallExpr(CallExpr *E) { } // Rebuild the appropriate pointer-to-function type. - switch (Kind) { + switch (Kind) { case FK_MemberFunction: // Nothing to do. break; @@ -16148,15 +16148,15 @@ ExprResult RebuildUnknownAnyExpr::VisitImplicitCastExpr(ImplicitCastExpr *E) { if (E->getCastKind() == CK_FunctionToPointerDecay) { assert(E->getValueKind() == VK_RValue); assert(E->getObjectKind() == OK_Ordinary); - + E->setType(DestType); - + // Rebuild the sub-expression as the pointee (function) type. DestType = DestType->castAs<PointerType>()->getPointeeType(); - + ExprResult Result = Visit(E->getSubExpr()); if (!Result.isUsable()) return ExprError(); - + E->setSubExpr(Result.get()); return E; } else if (E->getCastKind() == CK_LValueToRValue) { @@ -16218,7 +16218,7 @@ ExprResult RebuildUnknownAnyExpr::resolveDecl(Expr *E, ValueDecl *VD) { SC_None, false/*isInlineSpecified*/, FD->hasPrototype(), false/*isConstexprSpecified*/); - + if (FD->getQualifier()) NewFD->setQualifierInfo(FD->getQualifierLoc()); @@ -16486,7 +16486,7 @@ Sema::ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind) { Sema::LookupOrdinaryName); if (LookupName(Result, getCurScope()) && Result.isSingleResult()) { NamedDecl *ND = Result.getFoundDecl(); - if (TypedefDecl *TD = dyn_cast<TypedefDecl>(ND)) + if (TypedefDecl *TD = dyn_cast<TypedefDecl>(ND)) Context.setBOOLDecl(TD); } } diff --git a/lib/Sema/SemaExprMember.cpp b/lib/Sema/SemaExprMember.cpp index 3a8fee862c..e6d2b5068f 100644 --- a/lib/Sema/SemaExprMember.cpp +++ b/lib/Sema/SemaExprMember.cpp @@ -120,7 +120,7 @@ static IMAKind ClassifyImplicitMemberAccess(Sema &SemaRef, // member reference. if (Classes.empty()) return IMA_Static; - + // C++11 [expr.prim.general]p12: // An id-expression that denotes a non-static data member or non-static // member function of a class can only be used: @@ -166,7 +166,7 @@ static IMAKind ClassifyImplicitMemberAccess(Sema &SemaRef, else contextClass = cast<CXXRecordDecl>(DC); - // [class.mfct.non-static]p3: + // [class.mfct.non-static]p3: // ...is used in the body of a non-static member function of class X, // if name lookup (3.4.1) resolves the name in the id-expression to a // non-static non-type member of some class C [...] @@ -417,14 +417,14 @@ CheckExtVectorComponent(Sema &S, QualType baseType, ExprValueKind &VK, QualType VT = S.Context.getExtVectorType(vecType->getElementType(), CompSize); // Now look up the TypeDefDecl from the vector type. Without this, // diagostics look bad. We want extended vector types to appear built-in. - for (Sema::ExtVectorDeclsType::iterator + for (Sema::ExtVectorDeclsType::iterator I = S.ExtVectorDecls.begin(S.getExternalSource()), - E = S.ExtVectorDecls.end(); + E = S.ExtVectorDecls.end(); I != E; ++I) { if ((*I)->getUnderlyingType() == VT) return S.Context.getTypedefType(*I); } - + return VT; // should never get here (a typedef type should always be found). } @@ -817,10 +817,10 @@ Sema::BuildAnonymousStructUnionMemberReference(const CXXScopeSpec &SS, // static data members cannot be anonymous structs or unions. // Supporting this is as easy as building a MemberExpr here. assert(!baseObjectExpr && "anonymous struct/union is static data member?"); - + DeclarationNameInfo baseNameInfo(DeclarationName(), loc); - - ExprResult result + + ExprResult result = BuildDeclarationNameExpr(EmptySS, baseNameInfo, baseVariable); if (result.isInvalid()) return ExprError(); @@ -855,10 +855,10 @@ Sema::BuildAnonymousStructUnionMemberReference(const CXXScopeSpec &SS, if (!result) return ExprError(); } - + // In all cases, we should now skip the first declaration in the chain. ++FI; - + while (FI != FEnd) { FieldDecl *field = cast<FieldDecl>(*FI++); @@ -873,7 +873,7 @@ Sema::BuildAnonymousStructUnionMemberReference(const CXXScopeSpec &SS, fakeFoundDecl, memberNameInfo) .get(); } - + return result; } @@ -965,8 +965,8 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType, return ExprError(); BaseExpr = Converted.get(); } - - + + const DeclarationNameInfo &MemberNameInfo = R.getLookupNameInfo(); DeclarationName MemberName = MemberNameInfo.getName(); SourceLocation MemberLoc = MemberNameInfo.getLoc(); @@ -1035,7 +1035,7 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType, !SuppressQualifierCheck && CheckQualifiedMemberReference(BaseExpr, BaseType, SS, R)) return ExprError(); - + // Construct an unresolved result if we in fact got an unresolved // result. if (R.isOverloadedResult() || R.isUnresolvableResult()) { @@ -1421,7 +1421,7 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult &R, if (UnaryOperator *UO = dyn_cast<UnaryOperator>(BaseExp)) if (UO->getOpcode() == UO_Deref) BaseExp = UO->getSubExpr()->IgnoreParenCasts(); - + if (DeclRefExpr *DE = dyn_cast<DeclRefExpr>(BaseExp)) if (DE->getType().getObjCLifetime() == Qualifiers::OCL_Weak) { S.Diag(DE->getLocation(), diag::err_arc_weak_ivar_access); @@ -1431,7 +1431,7 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult &R, if (warn) { if (ObjCMethodDecl *MD = S.getCurMethodDecl()) { ObjCMethodFamily MF = MD->getMethodFamily(); - warn = (MF != OMF_init && MF != OMF_dealloc && + warn = (MF != OMF_init && MF != OMF_dealloc && MF != OMF_finalize && !S.IvarBacksCurrentMethodAccessor(IDecl, MD, IV)); } @@ -1732,7 +1732,7 @@ Sema::BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow, } if (VK != VK_RValue && Field->isBitField()) OK = OK_BitField; - + // Figure out the type of the member; see C99 6.5.2.3p3, C++ [expr.ref] QualType MemberType = Field->getType(); if (const ReferenceType *Ref = MemberType->getAs<ReferenceType>()) { @@ -1797,7 +1797,7 @@ Sema::BuildImplicitMemberExpr(const CXXScopeSpec &SS, const TemplateArgumentListInfo *TemplateArgs, bool IsKnownInstance, const Scope *S) { assert(!R.empty() && !R.isAmbiguous()); - + SourceLocation loc = R.getNameLoc(); // If this is known to be an instance access, go ahead and build an diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index bf0ffeba06..b291fc8691 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -73,7 +73,7 @@ ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs, /*Pascal=*/false, StrTy, &StrLocs[0], StrLocs.size()); } - + return BuildObjCStringLiteral(AtLocs[0], S); } @@ -92,12 +92,12 @@ ExprResult Sema::BuildObjCStringLiteral(SourceLocation AtLoc, StringLiteral *S){ } else if (getLangOpts().NoConstantCFStrings) { IdentifierInfo *NSIdent=nullptr; std::string StringClass(getLangOpts().ObjCConstantStringClass); - + if (StringClass.empty()) NSIdent = &Context.Idents.get("NSConstantString"); else NSIdent = &Context.Idents.get(StringClass); - + NamedDecl *IF = LookupSingleName(TUScope, NSIdent, AtLoc, LookupOrdinaryName); if (ObjCInterfaceDecl *StrIF = dyn_cast_or_null<ObjCInterfaceDecl>(IF)) { @@ -126,10 +126,10 @@ ExprResult Sema::BuildObjCStringLiteral(SourceLocation AtLoc, StringLiteral *S){ // being an 'id' type. Ty = Context.getObjCNSStringType(); if (Ty.isNull()) { - ObjCInterfaceDecl *NSStringIDecl = - ObjCInterfaceDecl::Create (Context, - Context.getTranslationUnitDecl(), - SourceLocation(), NSIdent, + ObjCInterfaceDecl *NSStringIDecl = + ObjCInterfaceDecl::Create (Context, + Context.getTranslationUnitDecl(), + SourceLocation(), NSIdent, nullptr, nullptr, SourceLocation()); Ty = Context.getObjCInterfaceType(NSStringIDecl); Context.setObjCNSStringType(Ty); @@ -252,16 +252,16 @@ static ObjCMethodDecl *getNSNumberFactoryMethod(Sema &S, SourceLocation Loc, } return nullptr; } - + // If we already looked up this method, we're done. if (S.NSNumberLiteralMethods[*Kind]) return S.NSNumberLiteralMethods[*Kind]; - + Selector Sel = S.NSAPIObj->getNSNumberLiteralSelector(*Kind, /*Instance=*/false); - + ASTContext &CX = S.Context; - + // Look up the NSNumber class, if we haven't done so already. It's cached // in the Sema instance. if (!S.NSNumberDecl) { @@ -277,7 +277,7 @@ static ObjCMethodDecl *getNSNumberFactoryMethod(Sema &S, SourceLocation Loc, QualType NSNumberObject = CX.getObjCInterfaceType(S.NSNumberDecl); S.NSNumberPointer = CX.getObjCObjectPointerType(NSNumberObject); } - + // Look for the appropriate method within NSNumber. ObjCMethodDecl *Method = S.NSNumberDecl->lookupClassMethod(Sel); if (!Method && S.getLangOpts().DebuggerObjCLiteral) { @@ -304,7 +304,7 @@ static ObjCMethodDecl *getNSNumberFactoryMethod(Sema &S, SourceLocation Loc, // Note: if the parameter type is out-of-line, we'll catch it later in the // implicit conversion. - + S.NSNumberLiteralMethods[*Kind] = Method; return Method; } @@ -322,21 +322,21 @@ ExprResult Sema::BuildObjCNumericLiteral(SourceLocation AtLoc, Expr *Number) { case CharacterLiteral::UTF8: NumberType = Context.CharTy; break; - + case CharacterLiteral::Wide: NumberType = Context.getWideCharType(); break; - + case CharacterLiteral::UTF16: NumberType = Context.Char16Ty; break; - + case CharacterLiteral::UTF32: NumberType = Context.Char32Ty; break; } } - + // Look for the appropriate method within NSNumber. // Construct the literal. SourceRange NR(Number->getSourceRange()); @@ -355,33 +355,33 @@ ExprResult Sema::BuildObjCNumericLiteral(SourceLocation AtLoc, Expr *Number) { if (ConvertedNumber.isInvalid()) return ExprError(); Number = ConvertedNumber.get(); - + // Use the effective source range of the literal, including the leading '@'. return MaybeBindToTemporary( new (Context) ObjCBoxedExpr(Number, NSNumberPointer, Method, SourceRange(AtLoc, NR.getEnd()))); } -ExprResult Sema::ActOnObjCBoolLiteral(SourceLocation AtLoc, +ExprResult Sema::ActOnObjCBoolLiteral(SourceLocation AtLoc, SourceLocation ValueLoc, bool Value) { ExprResult Inner; if (getLangOpts().CPlusPlus) { Inner = ActOnCXXBoolLiteral(ValueLoc, Value? tok::kw_true : tok::kw_false); } else { - // C doesn't actually have a way to represent literal values of type + // C doesn't actually have a way to represent literal values of type // _Bool. So, we'll use 0/1 and implicit cast to _Bool. Inner = ActOnIntegerConstant(ValueLoc, Value? 1 : 0); - Inner = ImpCastExprToType(Inner.get(), Context.BoolTy, + Inner = ImpCastExprToType(Inner.get(), Context.BoolTy, CK_IntegralToBoolean); } - + return BuildObjCNumericLiteral(AtLoc, Inner.get()); } /// Check that the given expression is a valid element of an Objective-C /// collection literal. -static ExprResult CheckObjCCollectionLiteralElement(Sema &S, Expr *Element, +static ExprResult CheckObjCCollectionLiteralElement(Sema &S, Expr *Element, QualType T, bool ArrayLiteral = false) { // If the expression is type-dependent, there's nothing for us to do. @@ -393,7 +393,7 @@ static ExprResult CheckObjCCollectionLiteralElement(Sema &S, Expr *Element, return ExprError(); Element = Result.get(); - // In C++, check for an implicit conversion to an Objective-C object pointer + // In C++, check for an implicit conversion to an Objective-C object pointer // type. if (S.getLangOpts().CPlusPlus && Element->getType()->isRecordType()) { InitializedEntity Entity @@ -413,15 +413,15 @@ static ExprResult CheckObjCCollectionLiteralElement(Sema &S, Expr *Element, Result = S.DefaultLvalueConversion(Element); if (Result.isInvalid()) return ExprError(); - Element = Result.get(); + Element = Result.get(); // Make sure that we have an Objective-C pointer type or block. if (!Element->getType()->isObjCObjectPointerType() && !Element->getType()->isBlockPointerType()) { bool Recovered = false; - + // If this is potentially an Objective-C numeric literal, add the '@'. - if (isa<IntegerLiteral>(OrigElement) || + if (isa<IntegerLiteral>(OrigElement) || isa<CharacterLiteral>(OrigElement) || isa<FloatingLiteral>(OrigElement) || isa<ObjCBoolLiteralExpr>(OrigElement) || @@ -431,16 +431,16 @@ static ExprResult CheckObjCCollectionLiteralElement(Sema &S, Expr *Element, : (isa<CXXBoolLiteralExpr>(OrigElement) || isa<ObjCBoolLiteralExpr>(OrigElement)) ? 2 : 3; - + S.Diag(OrigElement->getLocStart(), diag::err_box_literal_collection) << Which << OrigElement->getSourceRange() << FixItHint::CreateInsertion(OrigElement->getLocStart(), "@"); - + Result = S.BuildObjCNumericLiteral(OrigElement->getLocStart(), OrigElement); if (Result.isInvalid()) return ExprError(); - + Element = Result.get(); Recovered = true; } @@ -455,12 +455,12 @@ static ExprResult CheckObjCCollectionLiteralElement(Sema &S, Expr *Element, Result = S.BuildObjCStringLiteral(OrigElement->getLocStart(), String); if (Result.isInvalid()) return ExprError(); - + Element = Result.get(); Recovered = true; } } - + if (!Recovered) { S.Diag(Element->getLocStart(), diag::err_invalid_collection_element) << Element->getType(); @@ -488,17 +488,17 @@ static ExprResult CheckObjCCollectionLiteralElement(Sema &S, Expr *Element, } } - // Make sure that the element has the type that the container factory - // function expects. + // Make sure that the element has the type that the container factory + // function expects. return S.PerformCopyInitialization( - InitializedEntity::InitializeParameter(S.Context, T, + InitializedEntity::InitializeParameter(S.Context, T, /*Consumed=*/false), Element->getLocStart(), Element); } ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { if (ValueExpr->isTypeDependent()) { - ObjCBoxedExpr *BoxedExpr = + ObjCBoxedExpr *BoxedExpr = new (Context) ObjCBoxedExpr(ValueExpr, Context.DependentTy, nullptr, SR); return BoxedExpr; } @@ -525,7 +525,7 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { QualType NSStringObject = Context.getObjCInterfaceType(NSStringDecl); NSStringPointer = Context.getObjCObjectPointerType(NSStringObject); } - + if (!StringWithUTF8StringMethod) { IdentifierInfo *II = &Context.Idents.get("stringWithUTF8String"); Selector stringWithUTF8String = Context.Selectors.getUnarySelector(II); @@ -561,7 +561,7 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { StringWithUTF8StringMethod = BoxingMethod; } - + BoxingMethod = StringWithUTF8StringMethod; BoxedType = NSStringPointer; // Transfer the nullability from method's return type. @@ -588,22 +588,22 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { case CharacterLiteral::UTF8: ValueType = Context.CharTy; break; - + case CharacterLiteral::Wide: ValueType = Context.getWideCharType(); break; - + case CharacterLiteral::UTF16: ValueType = Context.Char16Ty; break; - + case CharacterLiteral::UTF32: ValueType = Context.Char32Ty; break; } } // FIXME: Do I need to do anything special with BoolTy expressions? - + // Look for the appropriate method within NSNumber. BoxingMethod = getNSNumberFactoryMethod(*this, Loc, ValueType); BoxedType = NSNumberPointer; @@ -620,7 +620,7 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { } else if (ValueType->isObjCBoxableRecordType()) { // Support for structure types, that marked as objc_boxable // struct __attribute__((objc_boxable)) s { ... }; - + // Look up the NSValue class, if we haven't done so already. It's cached // in the Sema instance. if (!NSValueDecl) { @@ -634,14 +634,14 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { QualType NSValueObject = Context.getObjCInterfaceType(NSValueDecl); NSValuePointer = Context.getObjCObjectPointerType(NSValueObject); } - + if (!ValueWithBytesObjCTypeMethod) { IdentifierInfo *II[] = { &Context.Idents.get("valueWithBytes"), &Context.Idents.get("objCType") }; Selector ValueWithBytesObjCType = Context.Selectors.getSelector(2, II); - + // Look for the appropriate method within NSValue. BoxingMethod = NSValueDecl->lookupClassMethod(ValueWithBytesObjCType); if (!BoxingMethod && getLangOpts().DebuggerObjCLiteral) { @@ -662,9 +662,9 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { /*isDefined=*/false, ObjCMethodDecl::Required, /*HasRelatedResultType=*/false); - + SmallVector<ParmVarDecl *, 2> Params; - + ParmVarDecl *bytes = ParmVarDecl::Create(Context, M, SourceLocation(), SourceLocation(), @@ -673,7 +673,7 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { /*TInfo=*/nullptr, SC_None, nullptr); Params.push_back(bytes); - + QualType ConstCharType = Context.CharTy.withConst(); ParmVarDecl *type = ParmVarDecl::Create(Context, M, @@ -683,18 +683,18 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { /*TInfo=*/nullptr, SC_None, nullptr); Params.push_back(type); - + M->setMethodParams(Context, Params, None); BoxingMethod = M; } - + if (!validateBoxingMethod(*this, Loc, NSValueDecl, ValueWithBytesObjCType, BoxingMethod)) return ExprError(); - + ValueWithBytesObjCTypeMethod = BoxingMethod; } - + if (!ValueType.isTriviallyCopyableType(Context)) { Diag(Loc, diag::err_objc_non_trivially_copyable_boxed_expression_type) << ValueType << ValueExpr->getSourceRange(); @@ -710,13 +710,13 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { << ValueType << ValueExpr->getSourceRange(); return ExprError(); } - + DiagnoseUseOfDecl(BoxingMethod, Loc); ExprResult ConvertedValueExpr; if (ValueType->isObjCBoxableRecordType()) { InitializedEntity IE = InitializedEntity::InitializeTemporary(ValueType); - ConvertedValueExpr = PerformCopyInitialization(IE, ValueExpr->getExprLoc(), + ConvertedValueExpr = PerformCopyInitialization(IE, ValueExpr->getExprLoc(), ValueExpr); } else { // Convert the expression to the type that the parameter requires. @@ -726,12 +726,12 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { ConvertedValueExpr = PerformCopyInitialization(IE, SourceLocation(), ValueExpr); } - + if (ConvertedValueExpr.isInvalid()) return ExprError(); ValueExpr = ConvertedValueExpr.get(); - - ObjCBoxedExpr *BoxedExpr = + + ObjCBoxedExpr *BoxedExpr = new (Context) ObjCBoxedExpr(ValueExpr, BoxedType, BoxingMethod, SR); return MaybeBindToTemporary(BoxedExpr); @@ -756,7 +756,7 @@ ExprResult Sema::BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr, if (Result.isInvalid()) return ExprError(); IndexExpr = Result.get(); - + // Perform lvalue-to-rvalue conversion on the base. Result = DefaultLvalueConversion(BaseExpr); if (Result.isInvalid()) @@ -821,24 +821,24 @@ ExprResult Sema::BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements) { // Dig out the type that all elements should be converted to. QualType T = Method->parameters()[0]->getType(); const PointerType *PtrT = T->getAs<PointerType>(); - if (!PtrT || + if (!PtrT || !Context.hasSameUnqualifiedType(PtrT->getPointeeType(), IdT)) { Diag(SR.getBegin(), diag::err_objc_literal_method_sig) << Sel; Diag(Method->parameters()[0]->getLocation(), diag::note_objc_literal_method_param) - << 0 << T + << 0 << T << Context.getPointerType(IdT.withConst()); return ExprError(); } - + // Check that the 'count' parameter is integral. if (!Method->parameters()[1]->getType()->isIntegerType()) { Diag(SR.getBegin(), diag::err_objc_literal_method_sig) << Sel; Diag(Method->parameters()[1]->getLocation(), diag::note_objc_literal_method_param) - << 1 + << 1 << Method->parameters()[1]->getType() << "integral"; return ExprError(); @@ -860,11 +860,11 @@ ExprResult Sema::BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements) { RequiredType, true); if (Converted.isInvalid()) return ExprError(); - + ElementsBuffer[I] = Converted.get(); } - - QualType Ty + + QualType Ty = Context.getObjCObjectPointerType( Context.getObjCInterfaceType(NSArrayDecl)); @@ -893,7 +893,7 @@ ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR, NSAPI::NSDict_dictionaryWithObjectsForKeysCount); ObjCMethodDecl *Method = NSDictionaryDecl->lookupClassMethod(Sel); if (!Method && getLangOpts().DebuggerObjCLiteral) { - Method = ObjCMethodDecl::Create(Context, + Method = ObjCMethodDecl::Create(Context, SourceLocation(), SourceLocation(), Sel, IdT, nullptr /*TypeSourceInfo */, @@ -938,7 +938,7 @@ ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR, // Dig out the type that all values should be converted to. QualType ValueT = Method->parameters()[0]->getType(); const PointerType *PtrValue = ValueT->getAs<PointerType>(); - if (!PtrValue || + if (!PtrValue || !Context.hasSameUnqualifiedType(PtrValue->getPointeeType(), IdT)) { Diag(SR.getBegin(), diag::err_objc_literal_method_sig) << Sel; @@ -952,7 +952,7 @@ ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR, // Dig out the type that all keys should be converted to. QualType KeyT = Method->parameters()[1]->getType(); const PointerType *PtrKey = KeyT->getAs<PointerType>(); - if (!PtrKey || + if (!PtrKey || !Context.hasSameUnqualifiedType(PtrKey->getPointeeType(), IdT)) { bool err = true; @@ -962,7 +962,7 @@ ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR, if (ObjCProtocolDecl *NSCopyingPDecl = LookupProtocol(&Context.Idents.get("NSCopying"), SR.getBegin())) { ObjCProtocolDecl *PQ[] = {NSCopyingPDecl}; - QIDNSCopying = + QIDNSCopying = Context.getObjCObjectType(Context.ObjCBuiltinIdTy, { }, llvm::makeArrayRef( (ObjCProtocolDecl**) PQ, @@ -975,7 +975,7 @@ ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR, err = !Context.hasSameUnqualifiedType(PtrKey->getPointeeType(), QIDNSCopying); } - + if (err) { Diag(SR.getBegin(), diag::err_objc_literal_method_sig) << Sel; @@ -1008,7 +1008,7 @@ ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR, QualType KeysT = DictionaryWithObjectsMethod->parameters()[1]->getType(); QualType KeyT = KeysT->castAs<PointerType>()->getPointeeType(); - // Check that each of the keys and values provided is valid in a collection + // Check that each of the keys and values provided is valid in a collection // literal, performing conversions as necessary. bool HasPackExpansions = false; for (ObjCDictionaryElement &Element : Elements) { @@ -1017,19 +1017,19 @@ ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR, KeyT); if (Key.isInvalid()) return ExprError(); - + // Check the value. ExprResult Value = CheckObjCCollectionLiteralElement(*this, Element.Value, ValueT); if (Value.isInvalid()) return ExprError(); - + Element.Key = Key.get(); Element.Value = Value.get(); - + if (Element.EllipsisLoc.isInvalid()) continue; - + if (!Element.Key->containsUnexpandedParameterPack() && !Element.Value->containsUnexpandedParameterPack()) { Diag(Element.EllipsisLoc, @@ -1038,10 +1038,10 @@ ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR, Element.Value->getLocEnd()); return ExprError(); } - + HasPackExpansions = true; } - + QualType Ty = Context.getObjCObjectPointerType( Context.getObjCInterfaceType(NSDictionaryDecl)); @@ -1147,7 +1147,7 @@ static void DiagnoseMismatchedSelectors(Sema &S, SourceLocation AtLoc, if (HelperToDiagnoseMismatchedMethodsInGlobalPool(S, AtLoc, LParenLoc, RParenLoc, Method, InstMethList)) Warned = true; - + // second, class methods ObjCMethodList &ClsMethList = b->second.second; if (HelperToDiagnoseMismatchedMethodsInGlobalPool(S, AtLoc, LParenLoc, RParenLoc, @@ -1175,7 +1175,7 @@ ExprResult Sema::ParseObjCSelectorExpression(Selector Sel, Diag(SelLoc, diag::warn_undeclared_selector_with_typo) << Sel << MatchedSel << FixItHint::CreateReplacement(SelectorRange, MatchedSel.getAsString()); - + } else Diag(SelLoc, diag::warn_undeclared_selector) << Sel; } else @@ -1187,7 +1187,7 @@ ExprResult Sema::ParseObjCSelectorExpression(Selector Sel, !getSourceManager().isInSystemHeader(Method->getLocation())) ReferencedSelectors.insert(std::make_pair(Sel, AtLoc)); - // In ARC, forbid the user from using @selector for + // In ARC, forbid the user from using @selector for // retain/release/autorelease/dealloc/retainCount. if (getLangOpts().ObjCAutoRefCount) { switch (Sel.getMethodFamily()) { @@ -1196,7 +1196,7 @@ ExprResult Sema::ParseObjCSelectorExpression(Selector Sel, case OMF_autorelease: case OMF_retainCount: case OMF_dealloc: - Diag(AtLoc, diag::err_arc_illegal_selector) << + Diag(AtLoc, diag::err_arc_illegal_selector) << Sel << SourceRange(LParenLoc, RParenLoc); break; @@ -1269,7 +1269,7 @@ static QualType stripObjCInstanceType(ASTContext &Context, QualType T) { if (T == Context.getObjCInstanceType()) return Context.getObjCIdType(); - + return origType; } @@ -1313,7 +1313,7 @@ static QualType getBaseMessageSendResultType(Sema &S, // was a class message send, T is the declared return type of the method // found if (Method->isInstanceMethod() && isClassMessage) - return stripObjCInstanceType(Context, + return stripObjCInstanceType(Context, Method->getSendResultType(ReceiverType)); // - if the receiver is super, T is a pointer to the class of the @@ -1334,7 +1334,7 @@ static QualType getBaseMessageSendResultType(Sema &S, // T is the declared return type of the method. if (ReceiverType->isObjCClassType() || ReceiverType->isObjCQualifiedClassType()) - return stripObjCInstanceType(Context, + return stripObjCInstanceType(Context, Method->getSendResultType(ReceiverType)); // - if the receiver is id, qualified id, Class, or qualified Class, T @@ -1424,14 +1424,14 @@ findExplicitInstancetypeDeclarer(const ObjCMethodDecl *MD, if (const ObjCImplDecl *impl = dyn_cast<ObjCImplDecl>(MD->getDeclContext())) { const ObjCContainerDecl *iface; - if (const ObjCCategoryImplDecl *catImpl = + if (const ObjCCategoryImplDecl *catImpl = dyn_cast<ObjCCategoryImplDecl>(impl)) { iface = catImpl->getCategoryDecl(); } else { iface = impl->getClassInterface(); } - const ObjCMethodDecl *ifaceMD = + const ObjCMethodDecl *ifaceMD = iface->getMethod(MD->getSelector(), MD->isInstanceMethod()); if (ifaceMD) return findExplicitInstancetypeDeclarer(ifaceMD, instancetype); } @@ -1481,11 +1481,11 @@ void Sema::EmitRelatedResultTypeNote(const Expr *E) { const ObjCMessageExpr *MsgSend = dyn_cast<ObjCMessageExpr>(E); if (!MsgSend) return; - + const ObjCMethodDecl *Method = MsgSend->getMethodDecl(); if (!Method) return; - + if (!Method->hasRelatedResultType()) return; @@ -1496,7 +1496,7 @@ void Sema::EmitRelatedResultTypeNote(const Expr *E) { if (!Context.hasSameUnqualifiedType(Method->getReturnType(), Context.getObjCInstanceType())) return; - + Diag(Method->getLocation(), diag::note_related_result_type_inferred) << Method->isInstanceMethod() << Method->getSelector() << MsgSend->getType(); @@ -1560,7 +1560,7 @@ bool Sema::CheckMessageArgumentTypes(QualType ReceiverType, } else Diag(SelLoc, DiagID) - << Sel << isClassMessage << SourceRange(SelectorLocs.front(), + << Sel << isClassMessage << SourceRange(SelectorLocs.front(), SelectorLocs.back()); // Find the class to which we are sending this message. if (ReceiverType->isObjCObjectPointerType()) { @@ -1587,7 +1587,7 @@ bool Sema::CheckMessageArgumentTypes(QualType ReceiverType, return false; } - ReturnType = getMessageSendResultType(ReceiverType, Method, isClassMessage, + ReturnType = getMessageSendResultType(ReceiverType, Method, isClassMessage, isSuperMessage); VK = Expr::getValueKindForType(Method->getReturnType()); @@ -1751,7 +1751,7 @@ ObjCMethodDecl *Sema::LookupMethodInObjectType(Selector sel, QualType type, return nullptr; } -/// LookupMethodInQualifiedType - Lookups up a method in protocol qualifier +/// LookupMethodInQualifiedType - Lookups up a method in protocol qualifier /// list of a qualified objective pointer type. ObjCMethodDecl *Sema::LookupMethodInQualifiedType(Selector Sel, const ObjCObjectPointerType *OPT, @@ -1785,14 +1785,14 @@ HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, } IdentifierInfo *Member = MemberName.getAsIdentifierInfo(); - + SourceRange BaseRange = Super? SourceRange(SuperLoc) : BaseExpr->getSourceRange(); - if (RequireCompleteType(MemberLoc, OPT->getPointeeType(), + if (RequireCompleteType(MemberLoc, OPT->getPointeeType(), diag::err_property_not_found_forward_class, MemberName, BaseRange)) return ExprError(); - + if (ObjCPropertyDecl *PD = IFace->FindPropertyDeclaration( Member, ObjCPropertyQueryKind::OBJC_PR_query_instance)) { // Check whether we can reference this property. @@ -1832,7 +1832,7 @@ HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, Selector Sel = PP.getSelectorTable().getNullarySelector(Member); ObjCMethodDecl *Getter = IFace->lookupInstanceMethod(Sel); - + // May be found in property's qualified list. if (!Getter) Getter = LookupMethodInQualifiedType(Sel, OPT, true); @@ -1852,17 +1852,17 @@ HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, SelectorTable::constructSetterSelector(PP.getIdentifierTable(), PP.getSelectorTable(), Member); ObjCMethodDecl *Setter = IFace->lookupInstanceMethod(SetterSel); - + // May be found in property's qualified list. if (!Setter) Setter = LookupMethodInQualifiedType(SetterSel, OPT, true); - + if (!Setter) { // If this reference is in an @implementation, also check for 'private' // methods. Setter = IFace->lookupPrivateMethod(SetterSel); } - + if (Setter && DiagnoseUseOfDecl(Setter, MemberLoc)) return ExprError(); @@ -1926,23 +1926,23 @@ HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, } } ObjCInterfaceDecl *ClassDeclared; - if (ObjCIvarDecl *Ivar = + if (ObjCIvarDecl *Ivar = IFace->lookupInstanceVariable(Member, ClassDeclared)) { QualType T = Ivar->getType(); - if (const ObjCObjectPointerType * OBJPT = + if (const ObjCObjectPointerType * OBJPT = T->getAsObjCInterfacePointerType()) { - if (RequireCompleteType(MemberLoc, OBJPT->getPointeeType(), + if (RequireCompleteType(MemberLoc, OBJPT->getPointeeType(), diag::err_property_not_as_forward_class, MemberName, BaseExpr)) return ExprError(); } - Diag(MemberLoc, + Diag(MemberLoc, diag::err_ivar_access_using_property_syntax_suggest) << MemberName << QualType(OPT, 0) << Ivar->getDeclName() << FixItHint::CreateReplacement(OpLoc, "->"); return ExprError(); } - + Diag(MemberLoc, diag::err_property_not_found) << MemberName << QualType(OPT, 0); if (Setter) @@ -2086,10 +2086,10 @@ Sema::ObjCMessageKind Sema::getObjCMessageKind(Scope *S, // trailing dot, it's an instance message. if (IsSuper && S->isInObjcMethodScope()) return HasTrailingDot? ObjCInstanceMessage : ObjCSuperMessage; - + LookupResult Result(*this, Name, NameLoc, LookupOrdinaryName); LookupName(Result, S); - + switch (Result.getResultKind()) { case LookupResult::NotFound: // Normal name lookup didn't find anything. If we're in an @@ -2103,11 +2103,11 @@ Sema::ObjCMessageKind Sema::getObjCMessageKind(Scope *S, } ObjCInterfaceDecl *ClassDeclared; - if (Method->getClassInterface()->lookupInstanceVariable(Name, + if (Method->getClassInterface()->lookupInstanceVariable(Name, ClassDeclared)) return ObjCInstanceMessage; } - + // Break out; we'll perform typo correction below. break; @@ -2171,7 +2171,7 @@ Sema::ObjCMessageKind Sema::getObjCMessageKind(Scope *S, return ObjCInstanceMessage; } -ExprResult Sema::ActOnSuperMessage(Scope *S, +ExprResult Sema::ActOnSuperMessage(Scope *S, SourceLocation SuperLoc, Selector Sel, SourceLocation LBracLoc, @@ -2213,7 +2213,7 @@ ExprResult Sema::ActOnSuperMessage(Scope *S, Sel, /*Method=*/nullptr, LBracLoc, SelectorLocs, RBracLoc, Args); } - + // Since we are in a class method, this is a class message to // the superclass. return BuildClassMessage(/*ReceiverTypeInfo=*/nullptr, @@ -2353,7 +2353,7 @@ DiagnoseCStringFormatDirectiveInObjCAPI(Sema &S, } if (!Format || NumArgs <= Idx) return; - + Expr *FormatExpr = Args[Idx]; if (ObjCStringLiteral *OSL = dyn_cast<ObjCStringLiteral>(FormatExpr->IgnoreParenImpCasts())) { @@ -2401,7 +2401,7 @@ ExprResult Sema::BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, SourceLocation SuperLoc, Selector Sel, ObjCMethodDecl *Method, - SourceLocation LBracLoc, + SourceLocation LBracLoc, ArrayRef<SourceLocation> SelectorLocs, SourceLocation RBracLoc, MultiExprArg ArgsIn, @@ -2431,7 +2431,7 @@ ExprResult Sema::BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, SelectorLocs, /*Method=*/nullptr, makeArrayRef(Args, NumArgs), RBracLoc, isImplicit); } - + // Find the class to which we are sending this message. ObjCInterfaceDecl *Class = nullptr; const ObjCObjectType *ClassType = ReceiverType->getAs<ObjCObjectType>(); @@ -2446,7 +2446,7 @@ ExprResult Sema::BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, (void)DiagnoseUseOfDecl(Class, SelectorSlotLocs); // Find the method we are messaging. if (!Method) { - SourceRange TypeRange + SourceRange TypeRange = SuperLoc.isValid()? SourceRange(SuperLoc) : ReceiverTypeInfo->getTypeLoc().getSourceRange(); if (RequireCompleteType(Loc, Context.getObjCInterfaceType(Class), @@ -2455,7 +2455,7 @@ ExprResult Sema::BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, : diag::warn_receiver_forward_class), TypeRange)) { // A forward class used in messaging is treated as a 'Class' - Method = LookupFactoryMethodInGlobalPool(Sel, + Method = LookupFactoryMethodInGlobalPool(Sel, SourceRange(LBracLoc, RBracLoc)); if (Method && !getLangOpts().ObjCAutoRefCount) Diag(Method->getLocation(), diag::note_method_sent_forward_class) @@ -2490,7 +2490,7 @@ ExprResult Sema::BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, RequireCompleteType(LBracLoc, Method->getReturnType(), diag::err_illegal_message_expr_incomplete_type)) return ExprError(); - + // Warn about explicit call of +initialize on its own class. But not on 'super'. if (Method && Method->getMethodFamily() == OMF_initialize) { if (!SuperLoc.isValid()) { @@ -2513,19 +2513,19 @@ ExprResult Sema::BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, } } } - + DiagnoseCStringFormatDirectiveInObjCAPI(*this, Method, Sel, Args, NumArgs); - + // Construct the appropriate ObjCMessageExpr. ObjCMessageExpr *Result; if (SuperLoc.isValid()) - Result = ObjCMessageExpr::Create(Context, ReturnType, VK, LBracLoc, - SuperLoc, /*IsInstanceSuper=*/false, + Result = ObjCMessageExpr::Create(Context, ReturnType, VK, LBracLoc, + SuperLoc, /*IsInstanceSuper=*/false, ReceiverType, Sel, SelectorLocs, Method, makeArrayRef(Args, NumArgs), RBracLoc, isImplicit); else { - Result = ObjCMessageExpr::Create(Context, ReturnType, VK, LBracLoc, + Result = ObjCMessageExpr::Create(Context, ReturnType, VK, LBracLoc, ReceiverTypeInfo, Sel, SelectorLocs, Method, makeArrayRef(Args, NumArgs), RBracLoc, isImplicit); @@ -2541,7 +2541,7 @@ ExprResult Sema::BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, // ActOnClassMessage - used for both unary and keyword messages. // ArgExprs is optional - if it is present, the number of expressions // is obtained from Sel.getNumArgs(). -ExprResult Sema::ActOnClassMessage(Scope *S, +ExprResult Sema::ActOnClassMessage(Scope *S, ParsedType Receiver, Selector Sel, SourceLocation LBracLoc, @@ -2556,7 +2556,7 @@ ExprResult Sema::ActOnClassMessage(Scope *S, if (!ReceiverTypeInfo) ReceiverTypeInfo = Context.getTrivialTypeSourceInfo(ReceiverType, LBracLoc); - return BuildClassMessage(ReceiverTypeInfo, ReceiverType, + return BuildClassMessage(ReceiverTypeInfo, ReceiverType, /*SuperLoc=*/SourceLocation(), Sel, /*Method=*/nullptr, LBracLoc, SelectorLocs, RBracLoc, Args); @@ -2625,7 +2625,7 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, SourceLocation SuperLoc, Selector Sel, ObjCMethodDecl *Method, - SourceLocation LBracLoc, + SourceLocation LBracLoc, ArrayRef<SourceLocation> SelectorLocs, SourceLocation RBracLoc, MultiExprArg ArgsIn, @@ -2691,15 +2691,15 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, // do nothing } else if (!getLangOpts().ObjCAutoRefCount && !Context.getObjCIdType().isNull() && - (ReceiverType->isPointerType() || + (ReceiverType->isPointerType() || ReceiverType->isIntegerType())) { // Implicitly convert integers and pointers to 'id' but emit a warning. // But not in ARC. Diag(Loc, diag::warn_bad_receiver_type) - << ReceiverType + << ReceiverType << Receiver->getSourceRange(); if (ReceiverType->isPointerType()) { - Receiver = ImpCastExprToType(Receiver, Context.getObjCIdType(), + Receiver = ImpCastExprToType(Receiver, Context.getObjCIdType(), CK_CPointerToObjCPointerCast).get(); } else { // TODO: specialized warning on null receivers? @@ -2828,7 +2828,7 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, // We allow sending a message to a qualified ID ("id<foo>"), which is ok as // long as one of the protocols implements the selector (if not, warn). // And as long as message is not deprecated/unavailable (warn if it is). - if (const ObjCObjectPointerType *QIdTy + if (const ObjCObjectPointerType *QIdTy = ReceiverType->getAsObjCQualifiedIdType()) { // Search protocols for instance methods. Method = LookupMethodInQualifiedType(Sel, QIdTy, true); @@ -2854,9 +2854,9 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, : SourceRange(SuperLoc))) { if (getLangOpts().ObjCAutoRefCount) return ExprError(); - + forwardClass = OCIType->getInterfaceDecl(); - Diag(Receiver ? Receiver->getLocStart() + Diag(Receiver ? Receiver->getLocStart() : SuperLoc, diag::note_receiver_is_id); Method = nullptr; } else { @@ -2866,7 +2866,7 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, if (!Method) // Search protocol qualifiers. Method = LookupMethodInQualifiedType(Sel, OCIType, true); - + if (!Method) { // If we have implementations in scope, check "private" methods. Method = ClassDecl->lookupPrivateMethod(Sel); @@ -2975,7 +2975,7 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, ReceiverType->isObjCQualifiedClassType()); if (CheckMessageArgumentTypes(ReceiverType, MultiExprArg(Args, NumArgs), Sel, SelectorLocs, Method, - ClassMessage, SuperLoc.isValid(), + ClassMessage, SuperLoc.isValid(), LBracLoc, RBracLoc, RecRange, ReturnType, VK)) return ExprError(); @@ -2984,7 +2984,7 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, diag::err_illegal_message_expr_incomplete_type)) return ExprError(); - // In ARC, forbid the user from sending messages to + // In ARC, forbid the user from sending messages to // retain/release/autorelease/dealloc/retainCount explicitly. if (getLangOpts().ObjCAutoRefCount) { ObjCMethodFamily family = @@ -3013,13 +3013,13 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, Diag(SelLoc, diag::err_arc_illegal_explicit_message) << Sel << RecRange; break; - + case OMF_performSelector: if (Method && NumArgs >= 1) { if (const auto *SelExp = dyn_cast<ObjCSelectorExpr>(Args[0]->IgnoreParens())) { Selector ArgSel = SelExp->getSelector(); - ObjCMethodDecl *SelMethod = + ObjCMethodDecl *SelMethod = LookupInstanceMethodInGlobalPool(ArgSel, SelExp->getSourceRange()); if (!SelMethod) @@ -3036,8 +3036,8 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, case OMF_init: // Issue error, unless ns_returns_not_retained. if (!SelMethod->hasAttr<NSReturnsNotRetainedAttr>()) { - // selector names a +1 method - Diag(SelLoc, + // selector names a +1 method + Diag(SelLoc, diag::err_arc_perform_selector_retains); Diag(SelMethod->getLocation(), diag::note_method_declared_at) << SelMethod->getDeclName(); @@ -3047,7 +3047,7 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, // +0 call. OK. unless ns_returns_retained. if (SelMethod->hasAttr<NSReturnsRetainedAttr>()) { // selector names a +1 method - Diag(SelLoc, + Diag(SelLoc, diag::err_arc_perform_selector_retains); Diag(SelMethod->getLocation(), diag::note_method_declared_at) << SelMethod->getDeclName(); @@ -3066,13 +3066,13 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, } DiagnoseCStringFormatDirectiveInObjCAPI(*this, Method, Sel, Args, NumArgs); - + // Construct the appropriate ObjCMessageExpr instance. ObjCMessageExpr *Result; if (SuperLoc.isValid()) Result = ObjCMessageExpr::Create(Context, ReturnType, VK, LBracLoc, SuperLoc, /*IsInstanceSuper=*/true, - ReceiverType, Sel, SelectorLocs, Method, + ReceiverType, Sel, SelectorLocs, Method, makeArrayRef(Args, NumArgs), RBracLoc, isImplicit); else { @@ -3158,7 +3158,7 @@ static void RemoveSelectorFromWarningCache(Sema &S, Expr* Arg) { // ArgExprs is optional - if it is present, the number of expressions // is obtained from Sel.getNumArgs(). ExprResult Sema::ActOnInstanceMessage(Scope *S, - Expr *Receiver, + Expr *Receiver, Selector Sel, SourceLocation LBracLoc, ArrayRef<SourceLocation> SelectorLocs, @@ -3173,7 +3173,7 @@ ExprResult Sema::ActOnInstanceMessage(Scope *S, if (Result.isInvalid()) return ExprError(); Receiver = Result.get(); } - + if (RespondsToSelectorSel.isNull()) { IdentifierInfo *SelectorId = &Context.Idents.get("respondsToSelector"); RespondsToSelectorSel = Context.Selectors.getUnarySelector(SelectorId); @@ -3218,13 +3218,13 @@ static bool isAnyCLike(ARCConversionTypeClass ACTC) { static ARCConversionTypeClass classifyTypeForARCConversion(QualType type) { bool isIndirect = false; - + // Ignore an outermost reference type. if (const ReferenceType *ref = type->getAs<ReferenceType>()) { type = ref->getPointeeType(); isIndirect = true; } - + // Drill through pointers and arrays recursively. while (true) { if (const PointerType *ptr = type->getAs<PointerType>()) { @@ -3242,7 +3242,7 @@ static ARCConversionTypeClass classifyTypeForARCConversion(QualType type) { } isIndirect = true; } - + if (isIndirect) { if (type->isObjCARCBridgableType()) return ACTC_indirectRetainable; @@ -3322,7 +3322,7 @@ namespace { return ACC_invalid; } - + /// Look through certain implicit and explicit casts. ACCResult VisitCastExpr(CastExpr *e) { switch (e->getCastKind()) { @@ -3428,10 +3428,10 @@ namespace { // Otherwise, don't do anything implicit with an unaudited function. if (!fn->hasAttr<CFAuditedTransferAttr>()) return ACC_invalid; - + // Otherwise, it's +0 unless it follows the create convention. if (ento::coreFoundation::followsCreateRule(fn)) - return Diagnose ? ACC_plusOne + return Diagnose ? ACC_plusOne : ACC_invalid; // ACC_plusOne if we start accepting this return ACC_plusZero; @@ -3458,7 +3458,7 @@ namespace { // return type is CF. if (!isAnyRetainable(TargetClass) || !isCFType(method->getReturnType())) return ACC_invalid; - + // If the method is explicitly marked not-retained, it's +0. if (method->hasAttr<CFReturnsNotRetainedAttr>()) return ACC_plusZero; @@ -3517,12 +3517,12 @@ static void addFixitForObjCARCConversion(Sema &S, SourceRange range(NCE->getOperatorLoc(), NCE->getAngleBrackets().getEnd()); SmallString<32> BridgeCall; - + SourceManager &SM = S.getSourceManager(); char PrevChar = *SM.getCharacterData(range.getBegin().getLocWithOffset(-1)); if (Lexer::isIdentifierBodyChar(PrevChar, S.getLangOpts())) BridgeCall += ' '; - + BridgeCall += CFBridgeName; DiagB.AddFixItHint(FixItHint::CreateReplacement(range, BridgeCall)); } @@ -3623,7 +3623,7 @@ diagnoseObjCARCConversion(Sema &S, SourceRange castRange, Sema::CheckedConversionKind CCK) { SourceLocation loc = (castRange.isValid() ? castRange.getBegin() : castExpr->getExprLoc()); - + if (S.makeUnavailableInSystemHeader(loc, UnavailableAttr::IR_ARCForbiddenConversion)) return; @@ -3637,7 +3637,7 @@ diagnoseObjCARCConversion(Sema &S, SourceRange castRange, (exprACTC == ACTC_coreFoundation && castACTC == ACTC_retainable && ObjCBridgeRelatedAttrFromType(castExprType, TDNDecl))) return; - + unsigned srcKind = 0; switch (exprACTC) { case ACTC_none: @@ -3652,7 +3652,7 @@ diagnoseObjCARCConversion(Sema &S, SourceRange castRange, srcKind = 4; break; } - + // Check whether this could be fixed with a bridge cast. SourceLocation afterLParen = S.getLocForEndOfToken(castRange.getBegin()); SourceLocation noteLoc = afterLParen.isValid() ? afterLParen : loc; @@ -3671,12 +3671,12 @@ diagnoseObjCARCConversion(Sema &S, SourceRange castRange, << castRange << castExpr->getSourceRange(); bool br = S.isKnownName("CFBridgingRelease"); - ACCResult CreateRule = + ACCResult CreateRule = ARCCastChecker(S.Context, exprACTC, castACTC, true).Visit(castExpr); assert(CreateRule != ACC_bottom && "This cast should already be accepted."); if (CreateRule != ACC_plusOne) { - DiagnosticBuilder DiagB = + DiagnosticBuilder DiagB = (CCK != Sema::CCK_OtherCast) ? S.Diag(noteLoc, diag::note_arc_bridge) : S.Diag(noteLoc, diag::note_arc_cstyle_bridge); @@ -3700,7 +3700,7 @@ diagnoseObjCARCConversion(Sema &S, SourceRange castRange, return; } - + // Bridge from a CF type to an ARC type. if (exprACTC == ACTC_retainable && isAnyRetainable(castACTC)) { bool br = S.isKnownName("CFBridgingRetain"); @@ -3712,7 +3712,7 @@ diagnoseObjCARCConversion(Sema &S, SourceRange castRange, << castType << castRange << castExpr->getSourceRange(); - ACCResult CreateRule = + ACCResult CreateRule = ARCCastChecker(S.Context, exprACTC, castACTC, true).Visit(castExpr); assert(CreateRule != ACC_bottom && "This cast should already be accepted."); if (CreateRule != ACC_plusOne) @@ -3740,7 +3740,7 @@ diagnoseObjCARCConversion(Sema &S, SourceRange castRange, return; } - + S.Diag(loc, diag::err_arc_mismatched_cast) << !convKindForDiag << srcKind << castExprType << castType @@ -3759,7 +3759,7 @@ static bool CheckObjCBridgeNSCast(Sema &S, QualType castType, Expr *castExpr, HadTheAttribute = true; if (Parm->isStr("id")) return true; - + NamedDecl *Target = nullptr; // Check for an existing type with this name. LookupResult R(S, DeclarationName(Parm), SourceLocation(), @@ -3897,7 +3897,7 @@ void Sema::CheckTollFreeBridgeCast(QualType castType, Expr *castExpr) { HasObjCBridgeMutableAttr, false); if (ObjCBridgeMutableAttrWillNotWarn && HasObjCBridgeMutableAttr) return; - + if (HasObjCBridgeAttr) CheckObjCBridgeNSCast<ObjCBridgeAttr>(*this, castType, castExpr, HasObjCBridgeAttr, true); @@ -3918,7 +3918,7 @@ void Sema::CheckTollFreeBridgeCast(QualType castType, Expr *castExpr) { HasObjCBridgeMutableAttr, false); if (ObjCBridgeMutableAttrWillNotWarn && HasObjCBridgeMutableAttr) return; - + if (HasObjCBridgeAttr) CheckObjCBridgeCFCast<ObjCBridgeAttr>(*this, castType, castExpr, HasObjCBridgeAttr, true); @@ -3940,7 +3940,7 @@ void Sema::CheckObjCBridgeRelatedCast(QualType castType, Expr *castExpr) { SrcType = Getter->getReturnType(); } } - + ARCConversionTypeClass srcExprACTC = classifyTypeForARCConversion(SrcType); ARCConversionTypeClass castExprACTC = classifyTypeForARCConversion(castType); if (srcExprACTC != ACTC_retainable || castExprACTC != ACTC_coreFoundation) @@ -3977,7 +3977,7 @@ bool Sema::checkObjCBridgeRelatedComponents(SourceLocation Loc, ObjCBridgeRelatedAttr *ObjCBAttr = ObjCBridgeRelatedAttrFromType(T, TDNDecl); if (!ObjCBAttr) return false; - + IdentifierInfo *RCId = ObjCBAttr->getRelatedClass(); IdentifierInfo *CMId = ObjCBAttr->getClassMethod(); IdentifierInfo *IMId = ObjCBAttr->getInstanceMethod(); @@ -4008,7 +4008,7 @@ bool Sema::checkObjCBridgeRelatedComponents(SourceLocation Loc, } return false; } - + // Check for an existing class method with the given selector name. if (CfToNs && CMId) { Selector Sel = Context.Selectors.getUnarySelector(CMId); @@ -4022,7 +4022,7 @@ bool Sema::checkObjCBridgeRelatedComponents(SourceLocation Loc, return false; } } - + // Check for an existing instance method with the given selector name. if (!CfToNs && IMId) { Selector Sel = Context.Selectors.getNullarySelector(IMId); @@ -4049,7 +4049,7 @@ Sema::CheckObjCBridgeRelatedConversions(SourceLocation Loc, bool NsToCf = (rhsExprACTC == ACTC_retainable && lhsExprACTC == ACTC_coreFoundation); if (!CfToNs && !NsToCf) return false; - + ObjCInterfaceDecl *RelatedClass; ObjCMethodDecl *ClassMethod = nullptr; ObjCMethodDecl *InstanceMethod = nullptr; @@ -4058,7 +4058,7 @@ Sema::CheckObjCBridgeRelatedConversions(SourceLocation Loc, ClassMethod, InstanceMethod, TDNDecl, CfToNs, Diagnose)) return false; - + if (CfToNs) { // Implicit conversion from CF to ObjC object is needed. if (ClassMethod) { @@ -4075,7 +4075,7 @@ Sema::CheckObjCBridgeRelatedConversions(SourceLocation Loc, << FixItHint::CreateInsertion(SrcExprEndLoc, "]"); Diag(RelatedClass->getLocStart(), diag::note_declared_at); Diag(TDNDecl->getLocStart(), diag::note_declared_at); - + QualType receiverType = Context.getObjCInterfaceType(RelatedClass); // Argument. Expr *args[] = { SrcExpr }; @@ -4118,7 +4118,7 @@ Sema::CheckObjCBridgeRelatedConversions(SourceLocation Loc, } Diag(RelatedClass->getLocStart(), diag::note_declared_at); Diag(TDNDecl->getLocStart(), diag::note_declared_at); - + ExprResult msg = BuildInstanceMessageImplicit(SrcExpr, SrcType, InstanceMethod->getLocation(), @@ -4144,7 +4144,7 @@ Sema::CheckObjCConversion(SourceRange castRange, QualType castType, QualType effCastType = castType; if (const ReferenceType *ref = castType->getAs<ReferenceType>()) effCastType = ref->getPointeeType(); - + ARCConversionTypeClass exprACTC = classifyTypeForARCConversion(castExprType); ARCConversionTypeClass castACTC = classifyTypeForARCConversion(effCastType); if (exprACTC == castACTC) { @@ -4167,7 +4167,7 @@ Sema::CheckObjCConversion(SourceRange castRange, QualType castType, if (QDT != castType && QDT.getObjCLifetime() != Qualifiers::OCL_None) { if (Diagnose) { - SourceLocation loc = (castRange.isValid() ? castRange.getBegin() + SourceLocation loc = (castRange.isValid() ? castRange.getBegin() : castExpr->getExprLoc()); Diag(loc, diag::err_arc_nolifetime_behavior); } @@ -4188,7 +4188,7 @@ Sema::CheckObjCConversion(SourceRange castRange, QualType castType, // vice-versa). if (castACTC == ACTC_none && castType->isIntegralType(Context)) return ACR_okay; - + // Allow casts between pointers to lifetime types (e.g., __strong id*) // and pointers to void (e.g., cv void *). Casting from void* to lifetime* // must be explicit. @@ -4229,7 +4229,7 @@ Sema::CheckObjCConversion(SourceRange castRange, QualType castType, if (castACTC == ACTC_retainable && exprACTC == ACTC_none && ConversionToObjCStringLiteralCheck(castType, castExpr, Diagnose)) return ACR_error; - + // Do not issue "bridge cast" diagnostic when implicit casting // a retainable object to a CF type parameter belonging to an audited // CF API function. Let caller issue a normal type mismatched diagnostic @@ -4322,9 +4322,9 @@ Expr *Sema::stripARCUnbridgedCast(Expr *e) { bool Sema::CheckObjCARCUnavailableWeakConversion(QualType castType, QualType exprType) { - QualType canCastType = + QualType canCastType = Context.getCanonicalType(castType).getUnqualifiedType(); - QualType canExprType = + QualType canExprType = Context.getCanonicalType(exprType).getUnqualifiedType(); if (isa<ObjCObjectPointerType>(canCastType) && castType.getObjCLifetime() == Qualifiers::OCL_Weak && @@ -4399,7 +4399,7 @@ ExprResult Sema::BuildObjCBridgedCast(SourceLocation LParenLoc, switch (Kind) { case OBC_Bridge: break; - + case OBC_BridgeRetained: { bool br = isKnownName("CFBridgingRelease"); Diag(BridgeKeywordLoc, diag::err_arc_bridge_cast_wrong_kind) @@ -4413,14 +4413,14 @@ ExprResult Sema::BuildObjCBridgedCast(SourceLocation LParenLoc, << FixItHint::CreateReplacement(BridgeKeywordLoc, "__bridge"); Diag(BridgeKeywordLoc, diag::note_arc_bridge_transfer) << FromType << br - << FixItHint::CreateReplacement(BridgeKeywordLoc, - br ? "CFBridgingRelease " + << FixItHint::CreateReplacement(BridgeKeywordLoc, + br ? "CFBridgingRelease " : "__bridge_transfer "); Kind = OBC_Bridge; break; } - + case OBC_BridgeTransfer: // We must consume the Objective-C object produced by the cast. MustConsume = true; @@ -4435,14 +4435,14 @@ ExprResult Sema::BuildObjCBridgedCast(SourceLocation LParenLoc, // is very dangerous, so we don't do it. SubExpr = maybeUndoReclaimObject(SubExpr); break; - - case OBC_BridgeRetained: + + case OBC_BridgeRetained: // Produce the object before casting it. SubExpr = ImplicitCastExpr::Create(Context, FromType, CK_ARCProduceObject, SubExpr, nullptr, VK_RValue); break; - + case OBC_BridgeTransfer: { bool br = isKnownName("CFBridgingRetain"); Diag(BridgeKeywordLoc, diag::err_arc_bridge_cast_wrong_kind) @@ -4452,14 +4452,14 @@ ExprResult Sema::BuildObjCBridgedCast(SourceLocation LParenLoc, << T << SubExpr->getSourceRange() << Kind; - + Diag(BridgeKeywordLoc, diag::note_arc_bridge) << FixItHint::CreateReplacement(BridgeKeywordLoc, "__bridge "); Diag(BridgeKeywordLoc, diag::note_arc_bridge_retained) << T << br - << FixItHint::CreateReplacement(BridgeKeywordLoc, + << FixItHint::CreateReplacement(BridgeKeywordLoc, br ? "CFBridgingRetain " : "__bridge_retained"); - + Kind = OBC_Bridge; break; } @@ -4475,13 +4475,13 @@ ExprResult Sema::BuildObjCBridgedCast(SourceLocation LParenLoc, Expr *Result = new (Context) ObjCBridgedCastExpr(LParenLoc, Kind, CK, BridgeKeywordLoc, TSInfo, SubExpr); - + if (MustConsume) { Cleanup.setExprNeedsCleanups(true); - Result = ImplicitCastExpr::Create(Context, T, CK_ARCConsumeObject, Result, + Result = ImplicitCastExpr::Create(Context, T, CK_ARCConsumeObject, Result, nullptr, VK_RValue); } - + return Result; } @@ -4498,6 +4498,6 @@ ExprResult Sema::ActOnObjCBridgedCast(Scope *S, CheckTollFreeBridgeCast(T, SubExpr); if (!TSInfo) TSInfo = Context.getTrivialTypeSourceInfo(T, LParenLoc); - return BuildObjCBridgedCast(LParenLoc, Kind, BridgeKeywordLoc, TSInfo, + return BuildObjCBridgedCast(LParenLoc, Kind, BridgeKeywordLoc, TSInfo, SubExpr); } diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index be0a74d8f8..cbb9f78e75 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -191,7 +191,7 @@ static void CheckStringInit(Expr *Str, QualType &DeclT, const ArrayType *AT, if (SL->isPascal()) StrLength--; } - + // [dcl.init.string]p2 if (StrLength > CAT->getSize().getZExtValue()) S.Diag(Str->getLocStart(), @@ -450,7 +450,7 @@ ExprResult InitListChecker::PerformEmptyInit(Sema &SemaRef, IsInStd = true; } - if (IsInStd && llvm::StringSwitch<bool>(R->getName()) + if (IsInStd && llvm::StringSwitch<bool>(R->getName()) .Cases("basic_string", "deque", "forward_list", true) .Cases("list", "map", "multimap", "multiset", true) .Cases("priority_queue", "queue", "set", "stack", true) @@ -1578,7 +1578,7 @@ void InitListChecker::CheckVectorType(const InitializedEntity &Entity, T->getVectorKind() == VectorType::NeonPolyVector)) { // The ability to use vector initializer lists is a GNU vector extension // and is unrelated to the NEON intrinsics in arm_neon.h. On little - // endian machines it works fine, however on big endian machines it + // endian machines it works fine, however on big endian machines it // exhibits surprising behaviour: // // uint32x2_t x = {42, 64}; @@ -2225,7 +2225,7 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, SemaRef.Diag(D->getLocStart(), diag::warn_subobject_initializer_overrides) << SourceRange(D->getLocStart(), DIE->getLocEnd()); - + SemaRef.Diag(ExistingInit->getLocStart(), diag::note_previous_initializer) << /*FIXME:has side effects=*/0 @@ -3000,7 +3000,7 @@ DeclarationName InitializedEntity::getName() const { case EK_LambdaCapture: return DeclarationName(Capture.VarID); - + case EK_Result: case EK_StmtExprResult: case EK_Exception: @@ -3653,13 +3653,13 @@ ResolveConstructorOverload(Sema &S, SourceLocation DeclLoc, CandidateSet, SuppressUserConversions); else { // C++ [over.match.copy]p1: - // - When initializing a temporary to be bound to the first parameter + // - When initializing a temporary to be bound to the first parameter // of a constructor [for type T] that takes a reference to possibly // cv-qualified T as its first argument, called with a single // argument in the context of direct-initialization, explicit // conversion functions are also considered. // FIXME: What if a constructor template instantiates to such a signature? - bool AllowExplicitConv = AllowExplicit && !CopyInitializing && + bool AllowExplicitConv = AllowExplicit && !CopyInitializing && Args.size() == 1 && hasCopyOrMoveCtorParam(S.Context, Info); S.AddOverloadCandidate(Info.Constructor, Info.FoundDecl, Args, @@ -4226,7 +4226,7 @@ static OverloadingResult TryRefInitWithConversionFunction( (void)DerivedToBase; (void)ObjCConversion; (void)ObjCLifetimeConversion; - + // Build the candidate set directly in the initialization sequence // structure, so that it will persist if we fail. OverloadCandidateSet &CandidateSet = Sequence.getFailedCandidateSet(); @@ -4646,7 +4646,7 @@ static void TryReferenceInitializationCore(Sema &S, /*FIXME:InOverloadResolution=*/false, /*CStyle=*/Kind.isCStyleOrFunctionalCast(), /*AllowObjCWritebackConversion=*/false); - + if (ICS.isBad()) { // FIXME: Use the conversion function set stored in ICS to turn // this into an overloading ambiguity diagnostic. However, we need @@ -4787,7 +4787,7 @@ static void TryDefaultInitialization(Sema &S, // To default-initialize an object of type T means: // - if T is an array type, each element is default-initialized; QualType DestType = S.Context.getBaseElementType(Entity.getType()); - + // - if T is a (possibly cv-qualified) class type (Clause 9), the default // constructor for T is called (and the initialization is ill-formed if // T has no accessible default constructor); @@ -5043,11 +5043,11 @@ static InvalidICRKind isInvalidICRSource(ASTContext &C, Expr *e, // If we have a declaration reference, it had better be a local variable. } else if (isa<DeclRefExpr>(e)) { - // set isWeakAccess to true, to mean that there will be an implicit + // set isWeakAccess to true, to mean that there will be an implicit // load which requires a cleanup. if (e->getType().getObjCLifetime() == Qualifiers::OCL_Weak) isWeakAccess = true; - + if (!isAddressOf) return IIK_nonlocal; VarDecl *var = dyn_cast<VarDecl>(cast<DeclRefExpr>(e)->getDecl()); @@ -5082,7 +5082,7 @@ static void checkIndirectCopyRestoreSource(Sema &S, Expr *src) { assert(src->isRValue()); bool isWeakAccess = false; InvalidICRKind iik = isInvalidICRSource(S.Context, src, false, isWeakAccess); - // If isWeakAccess to true, there will be an implicit + // If isWeakAccess to true, there will be an implicit // load which requires a cleanup. if (S.getLangOpts().ObjCAutoRefCount && isWeakAccess) S.Cleanup.setExprNeedsCleanups(true); @@ -5124,7 +5124,7 @@ static bool tryObjCWritebackConversion(Sema &S, ArgPointee = ArgArrayType->getElementType(); ArgType = S.Context.getPointerType(ArgPointee); } - + // Handle write-back conversion. QualType ConvertedArgType; if (!S.isObjCWritebackConversion(ArgType, Entity.getType(), @@ -5151,10 +5151,10 @@ static bool tryObjCWritebackConversion(Sema &S, ICS.Standard.First = ICK_Lvalue_To_Rvalue; ResultType = Initializer->getType().getNonLValueExprType(S.Context); } - + Sequence.AddConversionSequenceStep(ICS, ResultType); } - + Sequence.AddPassByIndirectCopyRestoreStep(Entity.getType(), ShouldCopy); return true; } @@ -5567,13 +5567,13 @@ void InitializationSequence::InitializeFrom(Sema &S, if (ICS.isStandard() && ICS.Standard.Second == ICK_Writeback_Conversion) { // Objective-C ARC writeback conversion. - + // We should copy unless we're passing to an argument explicitly // marked 'out'. bool ShouldCopy = true; if (ParmVarDecl *Param = cast_or_null<ParmVarDecl>(Entity.getDecl())) ShouldCopy = (Param->getObjCDeclQualifier() != ParmVarDecl::OBJC_TQ_Out); - + // If there was an lvalue adjustment, add it as a separate conversion. if (ICS.Standard.First == ICK_Array_To_Pointer || ICS.Standard.First == ICK_Lvalue_To_Rvalue) { @@ -5584,7 +5584,7 @@ void InitializationSequence::InitializeFrom(Sema &S, LvalueICS.Standard.First = ICS.Standard.First; AddConversionSequenceStep(LvalueICS, ICS.Standard.getToType(0)); } - + AddPassByIndirectCopyRestoreStep(DestType, ShouldCopy); } else if (ICS.isBad()) { DeclAccessPair dap; @@ -5635,9 +5635,9 @@ getAssignmentAction(const InitializedEntity &Entity, bool Diagnose = false) { if (Entity.getDecl() && isa<ObjCMethodDecl>(Entity.getDecl()->getDeclContext())) return Sema::AA_Sending; - + return !Diagnose ? Sema::AA_Passing : Sema::AA_Passing_CFAudited; - + case InitializedEntity::EK_Result: case InitializedEntity::EK_StmtExprResult: // FIXME: Not quite right. return Sema::AA_Returning; @@ -5743,7 +5743,7 @@ static SourceLocation getInitializationLoc(const InitializedEntity &Entity, case InitializedEntity::EK_LambdaCapture: return Entity.getCaptureLoc(); - + case InitializedEntity::EK_ArrayElement: case InitializedEntity::EK_Member: case InitializedEntity::EK_Parameter: @@ -6065,9 +6065,9 @@ PerformConstructorInitialization(Sema &S, ExprResult CurInit((Expr *)nullptr); // C++ [over.match.copy]p1: - // - When initializing a temporary to be bound to the first parameter - // of a constructor that takes a reference to possibly cv-qualified - // T as its first argument, called with a single argument in the + // - When initializing a temporary to be bound to the first parameter + // of a constructor that takes a reference to possibly cv-qualified + // T as its first argument, called with a single argument in the // context of direct-initialization, explicit conversion functions // are also considered. bool AllowExplicitConv = @@ -7130,7 +7130,7 @@ InitializationSequence::Perform(Sema &S, Args); } assert(Kind.getKind() == InitializationKind::IK_Copy || - Kind.isExplicitCast() || + Kind.isExplicitCast() || Kind.getKind() == InitializationKind::IK_DirectList); return ExprResult(Args[0]); } @@ -7832,7 +7832,7 @@ InitializationSequence::Perform(Sema &S, // this has already been done when parsing the variable declaration. if (!Init->isConstantInitializer(S.Context, false)) break; - + if (!SourceType->isIntegerType() || 32 != S.Context.getIntWidth(SourceType)) { S.Diag(Kind.getLocation(), diag::err_sampler_initializer_not_integer) @@ -7868,7 +7868,7 @@ InitializationSequence::Perform(Sema &S, break; } case SK_OCLZeroEvent: { - assert(Step->Type->isEventT() && + assert(Step->Type->isEventT() && "Event initialization on non-event type."); CurInit = S.ImpCastExprToType(CurInit.get(), Step->Type, @@ -8365,7 +8365,7 @@ bool InitializationSequence::Diagnose(Sema &S, llvm_unreachable("Inconsistent overload resolution?"); break; } - + // If this is a defaulted or implicitly-declared function, then // it was implicitly deleted. Make it clear that the deletion was // implicit. diff --git a/lib/Sema/SemaLambda.cpp b/lib/Sema/SemaLambda.cpp index a42b2e827e..440567e032 100644 --- a/lib/Sema/SemaLambda.cpp +++ b/lib/Sema/SemaLambda.cpp @@ -25,28 +25,28 @@ using namespace clang; using namespace sema; /// Examines the FunctionScopeInfo stack to determine the nearest -/// enclosing lambda (to the current lambda) that is 'capture-ready' for +/// enclosing lambda (to the current lambda) that is 'capture-ready' for /// the variable referenced in the current lambda (i.e. \p VarToCapture). /// If successful, returns the index into Sema's FunctionScopeInfo stack /// of the capture-ready lambda's LambdaScopeInfo. -/// -/// Climbs down the stack of lambdas (deepest nested lambda - i.e. current +/// +/// Climbs down the stack of lambdas (deepest nested lambda - i.e. current /// lambda - is on top) to determine the index of the nearest enclosing/outer -/// lambda that is ready to capture the \p VarToCapture being referenced in -/// the current lambda. +/// lambda that is ready to capture the \p VarToCapture being referenced in +/// the current lambda. /// As we climb down the stack, we want the index of the first such lambda - -/// that is the lambda with the highest index that is 'capture-ready'. -/// +/// that is the lambda with the highest index that is 'capture-ready'. +/// /// A lambda 'L' is capture-ready for 'V' (var or this) if: /// - its enclosing context is non-dependent /// - and if the chain of lambdas between L and the lambda in which -/// V is potentially used (i.e. the lambda at the top of the scope info +/// V is potentially used (i.e. the lambda at the top of the scope info /// stack), can all capture or have already captured V. /// If \p VarToCapture is 'null' then we are trying to capture 'this'. -/// +/// /// Note that a lambda that is deemed 'capture-ready' still needs to be checked /// for whether it is 'capture-capable' (see -/// getStackIndexOfNearestEnclosingCaptureCapableLambda), before it can truly +/// getStackIndexOfNearestEnclosingCaptureCapableLambda), before it can truly /// capture. /// /// \param FunctionScopes - Sema's stack of nested FunctionScopeInfo's (which a @@ -120,7 +120,7 @@ getStackIndexOfNearestEnclosingCaptureReadyLambda( return NoLambdaIsCaptureReady; } EnclosingDC = getLambdaAwareParentOfDeclContext(EnclosingDC); - + assert(CurScopeIndex); --CurScopeIndex; } while (!EnclosingDC->isTranslationUnit() && @@ -136,13 +136,13 @@ getStackIndexOfNearestEnclosingCaptureReadyLambda( } /// Examines the FunctionScopeInfo stack to determine the nearest -/// enclosing lambda (to the current lambda) that is 'capture-capable' for +/// enclosing lambda (to the current lambda) that is 'capture-capable' for /// the variable referenced in the current lambda (i.e. \p VarToCapture). /// If successful, returns the index into Sema's FunctionScopeInfo stack /// of the capture-capable lambda's LambdaScopeInfo. /// /// Given the current stack of lambdas being processed by Sema and -/// the variable of interest, to identify the nearest enclosing lambda (to the +/// the variable of interest, to identify the nearest enclosing lambda (to the /// current lambda at the top of the stack) that can truly capture /// a variable, it has to have the following two properties: /// a) 'capture-ready' - be the innermost lambda that is 'capture-ready': @@ -175,7 +175,7 @@ Optional<unsigned> clang::getStackIndexOfNearestEnclosingCaptureCapableLambda( VarDecl *VarToCapture, Sema &S) { const Optional<unsigned> NoLambdaIsCaptureCapable; - + const Optional<unsigned> OptionalStackIndex = getStackIndexOfNearestEnclosingCaptureReadyLambda(FunctionScopes, VarToCapture); @@ -190,7 +190,7 @@ Optional<unsigned> clang::getStackIndexOfNearestEnclosingCaptureCapableLambda( const sema::LambdaScopeInfo *const CaptureReadyLambdaLSI = cast<sema::LambdaScopeInfo>(FunctionScopes[IndexOfCaptureReadyLambda]); - + // If VarToCapture is null, we are attempting to capture 'this' const bool IsCapturingThis = !VarToCapture; const bool IsCapturingVariable = !IsCapturingThis; @@ -220,7 +220,7 @@ Optional<unsigned> clang::getStackIndexOfNearestEnclosingCaptureCapableLambda( &IndexOfCaptureReadyLambda); if (!CanCaptureThis) return NoLambdaIsCaptureCapable; - } + } return IndexOfCaptureReadyLambda; } @@ -245,18 +245,18 @@ getGenericLambdaTemplateParameterList(LambdaScopeInfo *LSI, Sema &SemaRef) { CXXRecordDecl *Sema::createLambdaClosureType(SourceRange IntroducerRange, TypeSourceInfo *Info, - bool KnownDependent, + bool KnownDependent, LambdaCaptureDefault CaptureDefault) { DeclContext *DC = CurContext; while (!(DC->isFunctionOrMethod() || DC->isRecord() || DC->isFileContext())) DC = DC->getParent(); bool IsGenericLambda = getGenericLambdaTemplateParameterList(getCurLambda(), - *this); + *this); // Start constructing the lambda class. CXXRecordDecl *Class = CXXRecordDecl::CreateLambda(Context, DC, Info, IntroducerRange.getBegin(), - KnownDependent, - IsGenericLambda, + KnownDependent, + IsGenericLambda, CaptureDefault); DC->addDecl(Class); @@ -270,10 +270,10 @@ static bool isInInlineFunction(const DeclContext *DC) { if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(DC)) if (FD->isInlined()) return true; - + DC = DC->getLexicalParent(); } - + return false; } @@ -379,10 +379,10 @@ CXXMethodDecl *Sema::startLambdaDefinition(CXXRecordDecl *Class, ArrayRef<ParmVarDecl *> Params, const bool IsConstexprSpecified) { QualType MethodType = MethodTypeInfo->getType(); - TemplateParameterList *TemplateParams = + TemplateParameterList *TemplateParams = getGenericLambdaTemplateParameterList(getCurLambda(), *this); // If a lambda appears in a dependent context or is a generic lambda (has - // template parameters) and has an 'auto' return type, deduce it to a + // template parameters) and has an 'auto' return type, deduce it to a // dependent type. if (Class->isDependentContext() || TemplateParams) { const FunctionProtoType *FPT = MethodType->castAs<FunctionProtoType>(); @@ -395,9 +395,9 @@ CXXMethodDecl *Sema::startLambdaDefinition(CXXRecordDecl *Class, } // C++11 [expr.prim.lambda]p5: - // The closure type for a lambda-expression has a public inline function + // The closure type for a lambda-expression has a public inline function // call operator (13.5.4) whose parameters and return type are described by - // the lambda-expression's parameter-declaration-clause and + // the lambda-expression's parameter-declaration-clause and // trailing-return-type respectively. DeclarationName MethodName = Context.DeclarationNames.getCXXOperatorName(OO_Call); @@ -408,7 +408,7 @@ CXXMethodDecl *Sema::startLambdaDefinition(CXXRecordDecl *Class, = IntroducerRange.getEnd().getRawEncoding(); CXXMethodDecl *Method = CXXMethodDecl::Create(Context, Class, EndLoc, - DeclarationNameInfo(MethodName, + DeclarationNameInfo(MethodName, IntroducerRange.getBegin(), MethodNameLoc), MethodType, MethodTypeInfo, @@ -417,14 +417,14 @@ CXXMethodDecl *Sema::startLambdaDefinition(CXXRecordDecl *Class, IsConstexprSpecified, EndLoc); Method->setAccess(AS_public); - + // Temporarily set the lexical declaration context to the current // context, so that the Scope stack matches the lexical nesting. - Method->setLexicalDeclContext(CurContext); + Method->setLexicalDeclContext(CurContext); // Create a function template if we have a template parameter list FunctionTemplateDecl *const TemplateMethod = TemplateParams ? FunctionTemplateDecl::Create(Context, Class, - Method->getLocation(), MethodName, + Method->getLocation(), MethodName, TemplateParams, Method) : nullptr; if (TemplateMethod) { @@ -432,7 +432,7 @@ CXXMethodDecl *Sema::startLambdaDefinition(CXXRecordDecl *Class, TemplateMethod->setAccess(AS_public); Method->setDescribedFunctionTemplate(TemplateMethod); } - + // Add parameters. if (!Params.empty()) { Method->setParams(Params); @@ -493,16 +493,16 @@ void Sema::finishLambdaExplicitCaptures(LambdaScopeInfo *LSI) { LSI->finishedExplicitCaptures(); } -void Sema::addLambdaParameters(CXXMethodDecl *CallOperator, Scope *CurScope) { +void Sema::addLambdaParameters(CXXMethodDecl *CallOperator, Scope *CurScope) { // Introduce our parameters into the function scope - for (unsigned p = 0, NumParams = CallOperator->getNumParams(); + for (unsigned p = 0, NumParams = CallOperator->getNumParams(); p < NumParams; ++p) { ParmVarDecl *Param = CallOperator->getParamDecl(p); - + // If this has an identifier, add it to the scope stack. if (CurScope && Param->getIdentifier()) { CheckShadow(CurScope, Param); - + PushOnScopeChains(Param, CurScope); } } @@ -637,7 +637,7 @@ static void adjustBlockReturnsToEnum(Sema &S, ArrayRef<ReturnStmt*> returns, void Sema::deduceClosureReturnType(CapturingScopeInfo &CSI) { assert(CSI.HasImplicitReturnType); // If it was ever a placeholder, it had to been deduced to DependentTy. - assert(CSI.ReturnType.isNull() || !CSI.ReturnType->isUndeducedType()); + assert(CSI.ReturnType.isNull() || !CSI.ReturnType->isUndeducedType()); assert((!isa<LambdaScopeInfo>(CSI) || !getLangOpts().CPlusPlus14) && "lambda expressions use auto deduction in C++14 onwards"); @@ -851,7 +851,7 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, SmallVector<ParmVarDecl *, 8> Params; if (ParamInfo.getNumTypeObjects() == 0) { // C++11 [expr.prim.lambda]p4: - // If a lambda-expression does not include a lambda-declarator, it is as + // If a lambda-expression does not include a lambda-declarator, it is as // if the lambda-declarator were (). FunctionProtoType::ExtProtoInfo EPI(Context.getDefaultCallingConvention( /*IsVariadic=*/false, /*IsCXXMethod=*/true)); @@ -878,8 +878,8 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, DeclaratorChunk::FunctionTypeInfo &FTI = ParamInfo.getFunctionTypeInfo(); // C++11 [expr.prim.lambda]p5: - // This function call operator is declared const (9.3.1) if and only if - // the lambda-expression's parameter-declaration-clause is not followed + // This function call operator is declared const (9.3.1) if and only if + // the lambda-expression's parameter-declaration-clause is not followed // by mutable. It is neither virtual nor declared volatile. [...] if (!FTI.hasMutableQualifier()) FTI.TypeQuals |= DeclSpec::TQ_const; @@ -917,8 +917,8 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, // code_seg attribute on lambda apply to the method. if (Attr *A = getImplicitCodeSegOrSectionAttrForFunction(Method, /*IsDefinition=*/true)) Method->addAttr(A); - - // Attributes on the lambda apply to the method. + + // Attributes on the lambda apply to the method. ProcessDeclAttributes(CurScope, Method, ParamInfo); // CUDA lambdas get implicit attributes based on the scope in which they're @@ -928,7 +928,7 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, // Introduce the function call operator as the current declaration context. PushDeclContext(CurScope, Method); - + // Build the lambda scope. buildLambdaScope(LSI, Method, Intro.Range, Intro.Default, Intro.DefaultLoc, ExplicitParams, ExplicitResultType, !Method->isConst()); @@ -959,13 +959,13 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, for (auto C = Intro.Captures.begin(), E = Intro.Captures.end(); C != E; PrevCaptureLoc = C->Loc, ++C) { if (C->Kind == LCK_This || C->Kind == LCK_StarThis) { - if (C->Kind == LCK_StarThis) + if (C->Kind == LCK_StarThis) Diag(C->Loc, !getLangOpts().CPlusPlus17 ? diag::ext_star_this_lambda_capture_cxx17 : diag::warn_cxx14_compat_star_this_lambda_capture); // C++11 [expr.prim.lambda]p8: - // An identifier or this shall not appear more than once in a + // An identifier or this shall not appear more than once in a // lambda-capture. if (LSI->isCXXThisCaptured()) { Diag(C->Loc, diag::err_capture_more_than_once) @@ -993,7 +993,7 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, Diag(C->Loc, diag::err_this_capture) << true; continue; } - + CheckCXXThisCapture(C->Loc, /*Explicit=*/true, /*BuildAndDiagnose*/ true, /*FunctionScopeIndexToStopAtPtr*/ nullptr, C->Kind == LCK_StarThis); @@ -1018,9 +1018,9 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, // If the initializer expression is usable, but the InitCaptureType // is not, then an error has occurred - so ignore the capture for now. // for e.g., [n{0}] { }; <-- if no <initializer_list> is included. - // FIXME: we should create the init capture variable and mark it invalid + // FIXME: we should create the init capture variable and mark it invalid // in this case. - if (C->InitCaptureType.get().isNull()) + if (C->InitCaptureType.get().isNull()) continue; unsigned InitStyle; @@ -1050,7 +1050,7 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, "init capture has valid but null init?"); // C++11 [expr.prim.lambda]p8: - // If a lambda-capture includes a capture-default that is &, the + // If a lambda-capture includes a capture-default that is &, the // identifiers in the lambda-capture shall not be preceded by &. // If a lambda-capture includes a capture-default that is =, [...] // each identifier it contains shall be preceded by &. @@ -1131,7 +1131,7 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, } else { Diag(C->EllipsisLoc, diag::err_pack_expansion_without_parameter_packs) << SourceRange(C->Loc); - + // Just ignore the ellipsis. } } else if (Var->isParameterPack()) { @@ -1189,14 +1189,14 @@ QualType Sema::getLambdaConversionFunctionResultType( // The function type inside the pointer type is the same as the call // operator with some tweaks. The calling convention is the default free // function convention, and the type qualifications are lost. - const FunctionProtoType::ExtProtoInfo CallOpExtInfo = - CallOpProto->getExtProtoInfo(); + const FunctionProtoType::ExtProtoInfo CallOpExtInfo = + CallOpProto->getExtProtoInfo(); FunctionProtoType::ExtProtoInfo InvokerExtInfo = CallOpExtInfo; CallingConv CC = Context.getDefaultCallingConvention( CallOpProto->isVariadic(), /*IsCXXMethod=*/false); InvokerExtInfo.ExtInfo = InvokerExtInfo.ExtInfo.withCallingConv(CC); InvokerExtInfo.TypeQuals = 0; - assert(InvokerExtInfo.RefQualifier == RQ_None && + assert(InvokerExtInfo.RefQualifier == RQ_None && "Lambda's call operator should not have a reference qualifier"); return Context.getFunctionType(CallOpProto->getReturnType(), CallOpProto->getParamTypes(), InvokerExtInfo); @@ -1227,7 +1227,7 @@ static void addFunctionPointerConversion(Sema &S, /*IsVariadic=*/false, /*IsCXXMethod=*/true)); // The conversion function is always const. ConvExtInfo.TypeQuals = Qualifiers::Const; - QualType ConvTy = + QualType ConvTy = S.Context.getFunctionType(PtrToFunctionTy, None, ConvExtInfo); SourceLocation Loc = IntroducerRange.getBegin(); @@ -1236,8 +1236,8 @@ static void addFunctionPointerConversion(Sema &S, S.Context.getCanonicalType(PtrToFunctionTy)); DeclarationNameLoc ConvNameLoc; // Construct a TypeSourceInfo for the conversion function, and wire - // all the parameters appropriately for the FunctionProtoTypeLoc - // so that everything works during transformation/instantiation of + // all the parameters appropriately for the FunctionProtoTypeLoc + // so that everything works during transformation/instantiation of // generic lambdas. // The main reason for wiring up the parameters of the conversion // function with that of the call operator is so that constructs @@ -1247,46 +1247,46 @@ static void addFunctionPointerConversion(Sema &S, // return a; // }; // }; - // int (*fp)(int) = L(5); + // int (*fp)(int) = L(5); // Because the trailing return type can contain DeclRefExprs that refer - // to the original call operator's variables, we hijack the call + // to the original call operator's variables, we hijack the call // operators ParmVarDecls below. - TypeSourceInfo *ConvNamePtrToFunctionTSI = + TypeSourceInfo *ConvNamePtrToFunctionTSI = S.Context.getTrivialTypeSourceInfo(PtrToFunctionTy, Loc); ConvNameLoc.NamedType.TInfo = ConvNamePtrToFunctionTSI; // The conversion function is a conversion to a pointer-to-function. TypeSourceInfo *ConvTSI = S.Context.getTrivialTypeSourceInfo(ConvTy, Loc); - FunctionProtoTypeLoc ConvTL = + FunctionProtoTypeLoc ConvTL = ConvTSI->getTypeLoc().getAs<FunctionProtoTypeLoc>(); // Get the result of the conversion function which is a pointer-to-function. - PointerTypeLoc PtrToFunctionTL = + PointerTypeLoc PtrToFunctionTL = ConvTL.getReturnLoc().getAs<PointerTypeLoc>(); // Do the same for the TypeSourceInfo that is used to name the conversion // operator. - PointerTypeLoc ConvNamePtrToFunctionTL = + PointerTypeLoc ConvNamePtrToFunctionTL = ConvNamePtrToFunctionTSI->getTypeLoc().getAs<PointerTypeLoc>(); - + // Get the underlying function types that the conversion function will // be converting to (should match the type of the call operator). - FunctionProtoTypeLoc CallOpConvTL = + FunctionProtoTypeLoc CallOpConvTL = PtrToFunctionTL.getPointeeLoc().getAs<FunctionProtoTypeLoc>(); - FunctionProtoTypeLoc CallOpConvNameTL = + FunctionProtoTypeLoc CallOpConvNameTL = ConvNamePtrToFunctionTL.getPointeeLoc().getAs<FunctionProtoTypeLoc>(); - + // Wire up the FunctionProtoTypeLocs with the call operator's parameters. // These parameter's are essentially used to transform the name and // the type of the conversion operator. By using the same parameters // as the call operator's we don't have to fix any back references that - // the trailing return type of the call operator's uses (such as + // the trailing return type of the call operator's uses (such as // decltype(some_type<decltype(a)>::type{} + decltype(a){}) etc.) - // - we can simply use the return type of the call operator, and - // everything should work. + // - we can simply use the return type of the call operator, and + // everything should work. SmallVector<ParmVarDecl *, 4> InvokerParams; for (unsigned I = 0, N = CallOperator->getNumParams(); I != N; ++I) { ParmVarDecl *From = CallOperator->getParamDecl(I); - InvokerParams.push_back(ParmVarDecl::Create(S.Context, + InvokerParams.push_back(ParmVarDecl::Create(S.Context, // Temporarily add to the TU. This is set to the invoker below. S.Context.getTranslationUnitDecl(), From->getLocStart(), @@ -1300,14 +1300,14 @@ static void addFunctionPointerConversion(Sema &S, CallOpConvNameTL.setParam(I, From); } - CXXConversionDecl *Conversion - = CXXConversionDecl::Create(S.Context, Class, Loc, - DeclarationNameInfo(ConversionName, + CXXConversionDecl *Conversion + = CXXConversionDecl::Create(S.Context, Class, Loc, + DeclarationNameInfo(ConversionName, Loc, ConvNameLoc), - ConvTy, + ConvTy, ConvTSI, /*isInline=*/true, /*isExplicit=*/false, - /*isConstexpr=*/S.getLangOpts().CPlusPlus17, + /*isConstexpr=*/S.getLangOpts().CPlusPlus17, CallOperator->getBody()->getLocEnd()); Conversion->setAccess(AS_public); Conversion->setImplicit(true); @@ -1315,7 +1315,7 @@ static void addFunctionPointerConversion(Sema &S, if (Class->isGenericLambda()) { // Create a template version of the conversion operator, using the template // parameter list of the function call operator. - FunctionTemplateDecl *TemplateCallOperator = + FunctionTemplateDecl *TemplateCallOperator = CallOperator->getDescribedFunctionTemplate(); FunctionTemplateDecl *ConversionTemplate = FunctionTemplateDecl::Create(S.Context, Class, @@ -1337,19 +1337,19 @@ static void addFunctionPointerConversion(Sema &S, // using FunctionTy & Loc and get its TypeLoc as a FunctionProtoTypeLoc // then rewire the parameters accordingly, by hoisting up the InvokeParams // loop below and then use its Params to set Invoke->setParams(...) below. - // This would avoid the 'const' qualifier of the calloperator from - // contaminating the type of the invoker, which is currently adjusted + // This would avoid the 'const' qualifier of the calloperator from + // contaminating the type of the invoker, which is currently adjusted // in SemaTemplateDeduction.cpp:DeduceTemplateArguments. Fixing the // trailing return type of the invoker would require a visitor to rebuild // the trailing return type and adjusting all back DeclRefExpr's to refer // to the new static invoker parameters - not the call operator's. CXXMethodDecl *Invoke - = CXXMethodDecl::Create(S.Context, Class, Loc, - DeclarationNameInfo(InvokerName, Loc), + = CXXMethodDecl::Create(S.Context, Class, Loc, + DeclarationNameInfo(InvokerName, Loc), InvokerFunctionTy, - CallOperator->getTypeSourceInfo(), + CallOperator->getTypeSourceInfo(), SC_Static, /*IsInline=*/true, - /*IsConstexpr=*/false, + /*IsConstexpr=*/false, CallOperator->getBody()->getLocEnd()); for (unsigned I = 0, N = CallOperator->getNumParams(); I != N; ++I) InvokerParams[I]->setOwningFunction(Invoke); @@ -1357,7 +1357,7 @@ static void addFunctionPointerConversion(Sema &S, Invoke->setAccess(AS_private); Invoke->setImplicit(true); if (Class->isGenericLambda()) { - FunctionTemplateDecl *TemplateCallOperator = + FunctionTemplateDecl *TemplateCallOperator = CallOperator->getDescribedFunctionTemplate(); FunctionTemplateDecl *StaticInvokerTemplate = FunctionTemplateDecl::Create( S.Context, Class, Loc, InvokerName, @@ -1372,7 +1372,7 @@ static void addFunctionPointerConversion(Sema &S, } /// Add a lambda's conversion to block pointer. -static void addBlockPointerConversion(Sema &S, +static void addBlockPointerConversion(Sema &S, SourceRange IntroducerRange, CXXRecordDecl *Class, CXXMethodDecl *CallOperator) { @@ -1392,13 +1392,13 @@ static void addBlockPointerConversion(Sema &S, S.Context.getCanonicalType(BlockPtrTy)); DeclarationNameLoc NameLoc; NameLoc.NamedType.TInfo = S.Context.getTrivialTypeSourceInfo(BlockPtrTy, Loc); - CXXConversionDecl *Conversion - = CXXConversionDecl::Create(S.Context, Class, Loc, + CXXConversionDecl *Conversion + = CXXConversionDecl::Create(S.Context, Class, Loc, DeclarationNameInfo(Name, Loc, NameLoc), - ConvTy, + ConvTy, S.Context.getTrivialTypeSourceInfo(ConvTy, Loc), /*isInline=*/true, /*isExplicit=*/false, - /*isConstexpr=*/false, + /*isConstexpr=*/false, CallOperator->getBody()->getLocEnd()); Conversion->setAccess(AS_public); Conversion->setImplicit(true); @@ -1421,7 +1421,7 @@ static ExprResult performLambdaVarCaptureInitialization(Sema &S, // direct-initialized in increasing subscript order.) These // initializations are performed in the (unspecified) order in // which the non-static data members are declared. - + // C++ [expr.prim.lambda]p12: // An entity captured by a lambda-expression is odr-used (3.2) in // the scope containing the lambda-expression. @@ -1437,8 +1437,8 @@ static ExprResult performLambdaVarCaptureInitialization(Sema &S, InitializationSequence Init(S, Entity, InitKind, Ref); return Init.Perform(S, Entity, InitKind, Ref); } - -ExprResult Sema::ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body, + +ExprResult Sema::ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body, Scope *CurScope) { LambdaScopeInfo LSI = *cast<LambdaScopeInfo>(FunctionScopes.back()); ActOnFinishFunctionBody(LSI.CallOperator, Body); @@ -1531,9 +1531,9 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, IsGenericLambda = Class->isGenericLambda(); CallOperator->setLexicalDeclContext(Class); - Decl *TemplateOrNonTemplateCallOperatorDecl = - CallOperator->getDescribedFunctionTemplate() - ? CallOperator->getDescribedFunctionTemplate() + Decl *TemplateOrNonTemplateCallOperatorDecl = + CallOperator->getDescribedFunctionTemplate() + ? CallOperator->getDescribedFunctionTemplate() : cast<Decl>(CallOperator); TemplateOrNonTemplateCallOperatorDecl->setLexicalDeclContext(Class); @@ -1646,7 +1646,7 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, // FIXME: Fix generic lambda to block conversions. if (getLangOpts().Blocks && getLangOpts().ObjC1 && !IsGenericLambda) addBlockPointerConversion(*this, IntroducerRange, Class, CallOperator); - + // Finalize the lambda class. SmallVector<Decl*, 4> Fields(Class->fields()); ActOnFields(nullptr, Class->getLocation(), Class, Fields, SourceLocation(), @@ -1656,9 +1656,9 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, Cleanup.mergeFrom(LambdaCleanup); - LambdaExpr *Lambda = LambdaExpr::Create(Context, Class, IntroducerRange, + LambdaExpr *Lambda = LambdaExpr::Create(Context, Class, IntroducerRange, CaptureDefault, CaptureDefaultLoc, - Captures, + Captures, ExplicitParams, ExplicitResultType, CaptureInits, EndLoc, ContainsUnexpandedParameterPack); @@ -1718,7 +1718,7 @@ ExprResult Sema::BuildBlockForLambdaConversion(SourceLocation CurrentLocation, Expr *Src) { // Make sure that the lambda call operator is marked used. CXXRecordDecl *Lambda = Conv->getParent(); - CXXMethodDecl *CallOperator + CXXMethodDecl *CallOperator = cast<CXXMethodDecl>( Lambda->lookup( Context.DeclarationNames.getCXXOperatorName(OO_Call)).front()); @@ -1731,10 +1731,10 @@ ExprResult Sema::BuildBlockForLambdaConversion(SourceLocation CurrentLocation, CurrentLocation, Src); if (!Init.isInvalid()) Init = ActOnFinishFullExpr(Init.get()); - + if (Init.isInvalid()) return ExprError(); - + // Create the new block to be returned. BlockDecl *Block = BlockDecl::Create(Context, CurContext, ConvLocation); diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 2732112c00..0ab70e9dca 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -1621,7 +1621,7 @@ bool Sema::isVisibleSlow(const NamedDecl *D) { bool Sema::shouldLinkPossiblyHiddenDecl(LookupResult &R, const NamedDecl *New) { // FIXME: If there are both visible and hidden declarations, we need to take // into account whether redeclaration is possible. Example: - // + // // Non-imported module: // int f(T); // #1 // Some TU: @@ -1795,7 +1795,7 @@ bool Sema::LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation) { // actually exists in a Scope). while (S && !S->isDeclScope(D)) S = S->getParent(); - + // If the scope containing the declaration is the translation unit, // then we'll need to perform our checks based on the matching // DeclContexts rather than matching scopes. @@ -1806,7 +1806,7 @@ bool Sema::LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation) { DeclContext *DC = nullptr; if (!S) DC = (*I)->getDeclContext()->getRedeclContext(); - + IdentifierResolver::iterator LastI = I; for (++LastI; LastI != IEnd; ++LastI) { if (S) { @@ -1815,7 +1815,7 @@ bool Sema::LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation) { break; } else { // Match based on DeclContext. - DeclContext *LastDC + DeclContext *LastDC = (*LastI)->getDeclContext()->getRedeclContext(); if (!LastDC->Equals(DC)) break; @@ -1843,8 +1843,8 @@ bool Sema::LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation) { if (AllowBuiltinCreation && LookupBuiltin(*this, R)) return true; - // If we didn't find a use of this identifier, the ExternalSource - // may be able to handle the situation. + // If we didn't find a use of this identifier, the ExternalSource + // may be able to handle the situation. // Note: some lookup failures are expected! // See e.g. R.isForRedeclaration(). return (ExternalSource && ExternalSource->LookupUnqualified(R, S)); @@ -2037,11 +2037,11 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool oldVal; DeclContext *Context; // Set flag in DeclContext informing debugger that we're looking for qualified name - QualifiedLookupInScope(DeclContext *ctx) : Context(ctx) { - oldVal = ctx->setUseQualifiedLookup(); + QualifiedLookupInScope(DeclContext *ctx) : Context(ctx) { + oldVal = ctx->setUseQualifiedLookup(); } - ~QualifiedLookupInScope() { - Context->setUseQualifiedLookup(oldVal); + ~QualifiedLookupInScope() { + Context->setUseQualifiedLookup(oldVal); } } QL(LookupCtx); @@ -2738,7 +2738,7 @@ addAssociatedClassesAndNamespaces(AssociatedLookup &Result, QualType Ty) { case Type::DeducedTemplateSpecialization: break; - // If T is an Objective-C object or interface type, or a pointer to an + // If T is an Objective-C object or interface type, or a pointer to an // object or interface type, the associated namespace is the global // namespace. case Type::ObjCObject: @@ -4434,7 +4434,7 @@ static void AddKeywordsToConsumer(Sema &SemaRef, // Add type-specifier keywords to the set of results. static const char *const CTypeSpecs[] = { "char", "const", "double", "enum", "float", "int", "long", "short", - "signed", "struct", "union", "unsigned", "void", "volatile", + "signed", "struct", "union", "unsigned", "void", "volatile", "_Complex", "_Imaginary", // storage-specifiers as well "extern", "inline", "static", "typedef" @@ -4450,7 +4450,7 @@ static void AddKeywordsToConsumer(Sema &SemaRef, Consumer.addKeywordResult("bool"); else if (SemaRef.getLangOpts().C99) Consumer.addKeywordResult("_Bool"); - + if (SemaRef.getLangOpts().CPlusPlus) { Consumer.addKeywordResult("class"); Consumer.addKeywordResult("typename"); diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 2983ec51f4..3e55cf003f 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -307,15 +307,15 @@ makePropertyAttributesAsWritten(unsigned Attributes) { attributesAsWritten |= ObjCPropertyDecl::OBJC_PR_atomic; if (Attributes & ObjCDeclSpec::DQ_PR_class) attributesAsWritten |= ObjCPropertyDecl::OBJC_PR_class; - + return (ObjCPropertyDecl::PropertyAttributeKind)attributesAsWritten; } -static bool LocPropertyAttribute( ASTContext &Context, const char *attrName, +static bool LocPropertyAttribute( ASTContext &Context, const char *attrName, SourceLocation LParenLoc, SourceLocation &Loc) { if (LParenLoc.isMacroID()) return false; - + SourceManager &SM = Context.getSourceManager(); std::pair<FileID, unsigned> locInfo = SM.getDecomposedLoc(LParenLoc); // Try to load the file buffer. @@ -324,7 +324,7 @@ static bool LocPropertyAttribute( ASTContext &Context, const char *attrName, if (invalidTemp) return false; const char *tokenBegin = file.data() + locInfo.second; - + // Lex from the start of the given location. Lexer lexer(SM.getLocForStartOfFile(locInfo.first), Context.getLangOpts(), @@ -365,7 +365,7 @@ static void checkAtomicPropertyMismatch(Sema &S, if (Attrs & ObjCPropertyDecl::OBJC_PR_nonatomic) return false; // Was 'atomic' specified directly? - if (Property->getPropertyAttributesAsWritten() & + if (Property->getPropertyAttributesAsWritten() & ObjCPropertyDecl::OBJC_PR_atomic) return false; @@ -382,7 +382,7 @@ static void checkAtomicPropertyMismatch(Sema &S, Attrs = Attrs & ~AtomicityMask; if (OldIsAtomic) Attrs |= ObjCPropertyDecl::OBJC_PR_atomic; - else + else Attrs |= ObjCPropertyDecl::OBJC_PR_nonatomic; NewProperty->overwritePropertyAttributes(Attrs); @@ -429,7 +429,7 @@ Sema::HandlePropertyInClassExtension(Scope *S, DeclContext *DC = CurContext; IdentifierInfo *PropertyId = FD.D.getIdentifier(); ObjCInterfaceDecl *CCPrimary = CDecl->getClassInterface(); - + // We need to look in the @interface to see if the @property was // already declared. if (!CCPrimary) { @@ -445,7 +445,7 @@ Sema::HandlePropertyInClassExtension(Scope *S, ObjCPropertyDecl *PIDecl = CCPrimary->FindPropertyVisibleInPrimaryClass( PropertyId, ObjCPropertyDecl::getQueryKind(isClassProperty)); - // If we found a property in an extension, complain. + // If we found a property in an extension, complain. if (PIDecl && isa<ObjCCategoryDecl>(PIDecl->getDeclContext())) { Diag(AtLoc, diag::err_duplicate_property); Diag(PIDecl->getLocation(), diag::note_property_declare); @@ -482,7 +482,7 @@ Sema::HandlePropertyInClassExtension(Scope *S, << PIDecl->getGetterName() << GetterSel; Diag(PIDecl->getLocation(), diag::note_property_declare); } - + // Always adopt the getter from the original declaration. GetterSel = PIDecl->getGetterName(); Attributes |= ObjCDeclSpec::DQ_PR_getter; @@ -503,7 +503,7 @@ Sema::HandlePropertyInClassExtension(Scope *S, Attributes = (Attributes & ~OwnershipMask) | ExistingOwnership; } - // If the redeclaration is 'weak' but the original property is not, + // If the redeclaration is 'weak' but the original property is not, if ((Attributes & ObjCPropertyDecl::OBJC_PR_weak) && !(PIDecl->getPropertyAttributesAsWritten() & ObjCPropertyDecl::OBJC_PR_weak) && @@ -511,7 +511,7 @@ Sema::HandlePropertyInClassExtension(Scope *S, PIDecl->getType().getObjCLifetime() == Qualifiers::OCL_None) { Diag(AtLoc, diag::warn_property_implicitly_mismatched); Diag(PIDecl->getLocation(), diag::note_property_declare); - } + } } // Create a new ObjCPropertyDecl with the DeclContext being @@ -546,13 +546,13 @@ Sema::HandlePropertyInClassExtension(Scope *S, (!isObjCPointerConversion(ClassExtPropertyT, PrimaryClassPropertyT, ConvertedType, IncompatibleObjC)) || IncompatibleObjC) { - Diag(AtLoc, + Diag(AtLoc, diag::err_type_mismatch_continuation_class) << PDecl->getType(); Diag(PIDecl->getLocation(), diag::note_property_declare); return nullptr; } } - + // Check that atomicity of property in class extension matches the previous // declaration. checkAtomicPropertyMismatch(*this, PIDecl, PDecl, true); @@ -621,7 +621,7 @@ ObjCPropertyDecl *Sema::CreatePropertyDecl(Scope *S, DeclContext *DC = CDecl; ObjCPropertyDecl *PDecl = ObjCPropertyDecl::Create(Context, DC, FD.D.getIdentifierLoc(), - PropertyId, AtLoc, + PropertyId, AtLoc, LParenLoc, T, TInfo); bool isClassProperty = (AttributesAsWritten & ObjCDeclSpec::DQ_PR_class) || @@ -770,7 +770,7 @@ static void checkARCPropertyImpl(Sema &S, SourceLocation propertyImplLoc, S.Diag(ivar->getLocation(), diag::err_arc_assign_property_ownership) << property->getDeclName() << ivar->getDeclName() - << ((property->getPropertyAttributesAsWritten() + << ((property->getPropertyAttributesAsWritten() & ObjCPropertyDecl::OBJC_PR_assign) != 0); break; @@ -794,12 +794,12 @@ static void checkARCPropertyImpl(Sema &S, SourceLocation propertyImplLoc, /// life-time is assumed 'strong'. static void setImpliedPropertyAttributeForReadOnlyProperty( ObjCPropertyDecl *property, ObjCIvarDecl *ivar) { - Qualifiers::ObjCLifetime propertyLifetime = + Qualifiers::ObjCLifetime propertyLifetime = getImpliedARCOwnership(property->getPropertyAttributes(), property->getType()); if (propertyLifetime != Qualifiers::OCL_None) return; - + if (!ivar) { // if no backing ivar, make property 'strong'. property->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_strong); @@ -1094,7 +1094,7 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, Diag(IC->getLocation(), diag::warn_auto_implicit_atomic_property); Diag(property->getLocation(), diag::note_property_declare); } - + if (const ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(property->getDeclContext())) { if (!CD->IsClassExtension()) { @@ -1121,17 +1121,17 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, } } } - + if (!ReadWriteProperty) { Diag(property->getLocation(), diag::warn_auto_readonly_iboutlet_property) << property; SourceLocation readonlyLoc; - if (LocPropertyAttribute(Context, "readonly", + if (LocPropertyAttribute(Context, "readonly", property->getLParenLoc(), readonlyLoc)) { - SourceLocation endLoc = + SourceLocation endLoc = readonlyLoc.getLocWithOffset(strlen("readonly")-1); SourceRange ReadonlySourceRange(readonlyLoc, endLoc); - Diag(property->getLocation(), + Diag(property->getLocation(), diag::note_auto_readonly_iboutlet_fixup_suggest) << FixItHint::CreateReplacement(ReadonlySourceRange, "readwrite"); } @@ -1194,10 +1194,10 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, (property->getPropertyAttributesAsWritten() & ObjCPropertyDecl::OBJC_PR_readonly) && PropertyIvarType->isObjCRetainableType()) { - setImpliedPropertyAttributeForReadOnlyProperty(property, Ivar); + setImpliedPropertyAttributeForReadOnlyProperty(property, Ivar); } - - ObjCPropertyDecl::PropertyAttributeKind kind + + ObjCPropertyDecl::PropertyAttributeKind kind = property->getPropertyAttributes(); bool isARCWeak = false; @@ -1244,16 +1244,16 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, } if (AtLoc.isInvalid()) { - // Check when default synthesizing a property that there is + // Check when default synthesizing a property that there is // an ivar matching property name and issue warning; since this // is the most common case of not using an ivar used for backing // property in non-default synthesis case. ObjCInterfaceDecl *ClassDeclared=nullptr; - ObjCIvarDecl *originalIvar = - IDecl->lookupInstanceVariable(property->getIdentifier(), + ObjCIvarDecl *originalIvar = + IDecl->lookupInstanceVariable(property->getIdentifier(), ClassDeclared); if (originalIvar) { - Diag(PropertyDiagLoc, + Diag(PropertyDiagLoc, diag::warn_autosynthesis_property_ivar_match) << PropertyId << (Ivar == nullptr) << PropertyIvar << originalIvar->getIdentifier(); @@ -1261,7 +1261,7 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, Diag(originalIvar->getLocation(), diag::note_ivar_decl); } } - + if (!Ivar) { // In ARC, give the ivar a lifetime qualifier based on the // property attributes. @@ -1280,10 +1280,10 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, Qualifiers::ObjCLifetime lifetime = getImpliedARCOwnership(kind, PropertyIvarType); assert(lifetime && "no lifetime for property?"); - + Qualifiers qs; qs.addObjCLifetime(lifetime); - PropertyIvarType = Context.getQualifiedType(PropertyIvarType, qs); + PropertyIvarType = Context.getQualifiedType(PropertyIvarType, qs); } } @@ -1333,7 +1333,7 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, // Check that type of property and its ivar are type compatible. if (!Context.hasSameType(PropertyIvarType, IvarType)) { - if (isa<ObjCObjectPointerType>(PropertyIvarType) + if (isa<ObjCObjectPointerType>(PropertyIvarType) && isa<ObjCObjectPointerType>(IvarType)) compat = Context.canAssignObjCInterfaces( @@ -1390,7 +1390,7 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, } else if (PropertyIvar) // @dynamic Diag(PropertyDiagLoc, diag::err_dynamic_property_ivar_decl); - + assert (property && "ActOnPropertyImplDecl - property declaration missing"); ObjCPropertyImplDecl *PIDecl = ObjCPropertyImplDecl::Create(Context, CurContext, AtLoc, PropertyLoc, @@ -1412,7 +1412,7 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, // FIXME. Eventually we want to do this for Objective-C as well. SynthesizedFunctionScope Scope(*this, getterMethod); ImplicitParamDecl *SelfDecl = getterMethod->getSelfDecl(); - DeclRefExpr *SelfExpr = + DeclRefExpr *SelfExpr = new (Context) DeclRefExpr(SelfDecl, false, SelfDecl->getType(), VK_LValue, PropertyDiagLoc); MarkDeclRefReferenced(SelfExpr); @@ -1440,7 +1440,7 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, } if (property->hasAttr<NSReturnsNotRetainedAttr>() && !getterMethod->hasAttr<NSReturnsNotRetainedAttr>()) { - Diag(getterMethod->getLocation(), + Diag(getterMethod->getLocation(), diag::warn_property_getter_owning_mismatch); Diag(property->getLocation(), diag::note_property_declare); } @@ -1464,7 +1464,7 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, // FIXME. Eventually we want to do this for Objective-C as well. SynthesizedFunctionScope Scope(*this, setterMethod); ImplicitParamDecl *SelfDecl = setterMethod->getSelfDecl(); - DeclRefExpr *SelfExpr = + DeclRefExpr *SelfExpr = new (Context) DeclRefExpr(SelfDecl, false, SelfDecl->getType(), VK_LValue, PropertyDiagLoc); MarkDeclRefReferenced(SelfExpr); @@ -1484,27 +1484,27 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, DeclRefExpr *rhs = new (Context) DeclRefExpr(Param, false, T, VK_LValue, PropertyDiagLoc); MarkDeclRefReferenced(rhs); - ExprResult Res = BuildBinOp(S, PropertyDiagLoc, + ExprResult Res = BuildBinOp(S, PropertyDiagLoc, BO_Assign, lhs, rhs); - if (property->getPropertyAttributes() & + if (property->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_atomic) { Expr *callExpr = Res.getAs<Expr>(); - if (const CXXOperatorCallExpr *CXXCE = + if (const CXXOperatorCallExpr *CXXCE = dyn_cast_or_null<CXXOperatorCallExpr>(callExpr)) if (const FunctionDecl *FuncDecl = CXXCE->getDirectCallee()) if (!FuncDecl->isTrivial()) if (property->getType()->isReferenceType()) { - Diag(PropertyDiagLoc, + Diag(PropertyDiagLoc, diag::err_atomic_property_nontrivial_assign_op) << property->getType(); - Diag(FuncDecl->getLocStart(), + Diag(FuncDecl->getLocStart(), diag::note_callee_decl) << FuncDecl; } } PIDecl->setSetterCXXAssignment(Res.getAs<Expr>()); } } - + if (IC) { if (Synthesize) if (ObjCPropertyImplDecl *PPIDecl = @@ -1537,9 +1537,9 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, Ivar = IDecl->lookupInstanceVariable(PropertyId, ClassDeclared); } // Issue diagnostics only if Ivar belongs to current class. - if (Ivar && Ivar->getSynthesize() && + if (Ivar && Ivar->getSynthesize() && declaresSameEntity(IC->getClassInterface(), ClassDeclared)) { - Diag(Ivar->getLocation(), diag::err_undeclared_var_use) + Diag(Ivar->getLocation(), diag::err_undeclared_var_use) << PropertyId; Ivar->setInvalidDecl(); } @@ -1582,7 +1582,7 @@ Sema::DiagnosePropertyMismatch(ObjCPropertyDecl *Property, Property->getPropertyAttributes(); ObjCPropertyDecl::PropertyAttributeKind SAttr = SuperProperty->getPropertyAttributes(); - + // We allow readonly properties without an explicit ownership // (assign/unsafe_unretained/weak/retain/strong/copy) in super class // to be overridden by a property with any explicit ownership in the subclass. @@ -1642,7 +1642,7 @@ Sema::DiagnosePropertyMismatch(ObjCPropertyDecl *Property, // FIXME. For future support of covariant property types, revisit this. bool IncompatibleObjC = false; QualType ConvertedType; - if (!isObjCPointerConversion(RHSType, LHSType, + if (!isObjCPointerConversion(RHSType, LHSType, ConvertedType, IncompatibleObjC) || IncompatibleObjC) { Diag(Property->getLocation(), diag::warn_property_types_are_incompatible) @@ -1683,7 +1683,7 @@ bool Sema::DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *property, compat = false; } } - + if (!compat) { Diag(Loc, diag::warn_accessor_property_type_mismatch) << property->getDeclName() @@ -1744,9 +1744,9 @@ CollectImmediateProperties(ObjCContainerDecl *CDecl, ObjCPropertyDecl *PropertyFromSuper = SuperPropMap[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())]; - // Exclude property for protocols which conform to class's super-class, + // Exclude property for protocols which conform to class's super-class, // as super-class has to implement the property. - if (!PropertyFromSuper || + if (!PropertyFromSuper || PropertyFromSuper->getIdentifier() != Prop->getIdentifier()) { ObjCPropertyDecl *&PropEntry = PropMap[std::make_pair(Prop->getIdentifier(), @@ -1788,7 +1788,7 @@ Sema::IvarBacksCurrentMethodAccessor(ObjCInterfaceDecl *IFace, Method->isInstanceMethod()); if (!IMD || !IMD->isPropertyAccessor()) return false; - + // look up a property declaration whose one of its accessors is implemented // by this method. for (const auto *Property : IFace->instance_properties()) { @@ -1841,7 +1841,7 @@ void Sema::DefaultSynthesizeProperties(Scope *S, ObjCImplDecl *IMPDecl, return; ObjCInterfaceDecl::PropertyMap SuperPropMap; CollectSuperClassPropertyImplementations(IDecl, SuperPropMap); - + for (unsigned i = 0, e = PropertyOrder.size(); i != e; i++) { ObjCPropertyDecl *Prop = PropertyOrder[i]; // Is there a matching property synthesize/dynamic? @@ -1997,7 +1997,7 @@ void Sema::DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl, } if (IDecl) CollectSuperClassPropertyImplementations(IDecl, NoNeedToImplPropMap); - + // When SynthesizeProperties is true, we only check class properties. CollectImmediateProperties(CDecl, PropMap, NoNeedToImplPropMap, SynthesizeProperties/*CollectClassPropsOnly*/); @@ -2048,7 +2048,7 @@ void Sema::DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl, // Collect property accessors implemented in current implementation. for (const auto *I : IMPDecl->methods()) InsMap.insert(I); - + ObjCCategoryDecl *C = dyn_cast<ObjCCategoryDecl>(CDecl); ObjCInterfaceDecl *PrimaryClass = nullptr; if (C && !C->IsClassExtension()) @@ -2121,7 +2121,7 @@ Sema::AtomicPropertySetterGetterRules (ObjCImplDecl* IMPDecl, for (const auto *Ext : IDecl->known_extensions()) for (auto *Prop : Ext->properties()) PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop; - + for (ObjCContainerDecl::PropertyMap::iterator I = PM.begin(), E = PM.end(); I != E; ++I) { const ObjCPropertyDecl *Property = I->second; @@ -2191,7 +2191,7 @@ Sema::AtomicPropertySetterGetterRules (ObjCImplDecl* IMPDecl, << FixItHint::CreateInsertion(AfterLParen, NonatomicStr); } else if (Property->getLParenLoc().isInvalid()) { //@property id etc. - SourceLocation startLoc = + SourceLocation startLoc = Property->getTypeSourceInfo()->getTypeLoc().getBeginLoc(); Diag(Property->getLocation(), diag::note_atomic_property_fixup_suggest) @@ -2301,8 +2301,8 @@ static void AddPropertyAttrs(Sema &S, ObjCMethodDecl *PropertyMethod, ObjCPropertyDecl *Property) { // Should we just clone all attributes over? for (const auto *A : Property->attrs()) { - if (isa<DeprecatedAttr>(A) || - isa<UnavailableAttr>(A) || + if (isa<DeprecatedAttr>(A) || + isa<UnavailableAttr>(A) || isa<AvailabilityAttr>(A)) PropertyMethod->addAttr(A->clone(S.Context)); } @@ -2332,7 +2332,7 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property) { getClassMethod(property->getGetterName()) : CatDecl->getClassInterface()-> getInstanceMethod(property->getGetterName()); - + SetterMethod = IsClassProperty ? CD->getClassMethod(property->getSetterName()) : CD->getInstanceMethod(property->getSetterName()); @@ -2352,7 +2352,7 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property) { Diag(SetterMethod->getLocation(), diag::err_setter_type_void); if (SetterMethod->param_size() != 1 || !Context.hasSameUnqualifiedType( - (*SetterMethod->param_begin())->getType().getNonReferenceType(), + (*SetterMethod->param_begin())->getType().getNonReferenceType(), property->getType().getNonReferenceType())) { Diag(property->getLocation(), diag::warn_accessor_property_type_mismatch) @@ -2406,11 +2406,11 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property) { if (property->hasAttr<NSReturnsNotRetainedAttr>()) GetterMethod->addAttr(NSReturnsNotRetainedAttr::CreateImplicit(Context, Loc)); - + if (property->hasAttr<ObjCReturnsInnerPointerAttr>()) GetterMethod->addAttr( ObjCReturnsInnerPointerAttr::CreateImplicit(Context, Loc)); - + if (const SectionAttr *SA = property->getAttr<SectionAttr>()) GetterMethod->addAttr( SectionAttr::CreateImplicit(Context, SectionAttr::GNU_section, @@ -2535,12 +2535,12 @@ void Sema::CheckObjCPropertyAttributes(Decl *PDecl, // FIXME: Improve the reported location. if (!PDecl || PDecl->isInvalidDecl()) return; - + if ((Attributes & ObjCDeclSpec::DQ_PR_readonly) && (Attributes & ObjCDeclSpec::DQ_PR_readwrite)) Diag(Loc, diag::err_objc_property_attr_mutually_exclusive) << "readonly" << "readwrite"; - + ObjCPropertyDecl *PropertyDecl = cast<ObjCPropertyDecl>(PDecl); QualType PropertyTy = PropertyDecl->getType(); @@ -2656,19 +2656,19 @@ void Sema::CheckObjCPropertyAttributes(Decl *PDecl, if (Attributes & ObjCDeclSpec::DQ_PR_readonly) { // do nothing } else if (getLangOpts().ObjCAutoRefCount) { - // With arc, @property definitions should default to strong when + // With arc, @property definitions should default to strong when // not specified. PropertyDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_strong); } else if (PropertyTy->isObjCObjectPointerType()) { - bool isAnyClassTy = - (PropertyTy->isObjCClassType() || + bool isAnyClassTy = + (PropertyTy->isObjCClassType() || PropertyTy->isObjCQualifiedClassType()); // In non-gc, non-arc mode, 'Class' is treated as a 'void *' no need to // issue any warning. if (isAnyClassTy && getLangOpts().getGC() == LangOptions::NonGC) ; else if (propertyInPrimaryClass) { - // Don't issue warning on property with no life time in class + // Don't issue warning on property with no life time in class // extension as it is inherited from property in primary class. // Skip this warning in gc-only mode. if (getLangOpts().getGC() != LangOptions::GCOnly) @@ -2696,7 +2696,7 @@ void Sema::CheckObjCPropertyAttributes(Decl *PDecl, !(Attributes & ObjCDeclSpec::DQ_PR_strong) && PropertyTy->isBlockPointerType()) Diag(Loc, diag::warn_objc_property_retain_of_block); - + if ((Attributes & ObjCDeclSpec::DQ_PR_readonly) && (Attributes & ObjCDeclSpec::DQ_PR_setter)) Diag(Loc, diag::warn_objc_readonly_property_has_setter); diff --git a/lib/Sema/SemaPseudoObject.cpp b/lib/Sema/SemaPseudoObject.cpp index 4484e9b351..a8af75d87c 100644 --- a/lib/Sema/SemaPseudoObject.cpp +++ b/lib/Sema/SemaPseudoObject.cpp @@ -316,10 +316,10 @@ namespace { OpaqueValueExpr *InstanceKey; ObjCMethodDecl *AtIndexGetter; Selector AtIndexGetterSelector; - + ObjCMethodDecl *AtIndexSetter; Selector AtIndexSetterSelector; - + public: ObjCSubscriptOpBuilder(Sema &S, ObjCSubscriptRefExpr *refExpr, bool IsUnique) : PseudoOpBuilder(S, refExpr->getSourceRange().getBegin(), IsUnique), @@ -367,7 +367,7 @@ namespace { /// Capture the given expression in an OpaqueValueExpr. OpaqueValueExpr *PseudoOpBuilder::capture(Expr *e) { // Make a new OVE whose source is the given expression. - OpaqueValueExpr *captured = + OpaqueValueExpr *captured = new (S.Context) OpaqueValueExpr(GenericLoc, e->getType(), e->getValueKind(), e->getObjectKind(), e); @@ -389,7 +389,7 @@ OpaqueValueExpr *PseudoOpBuilder::captureValueAsResult(Expr *e) { assert(ResultIndex == PseudoObjectExpr::NoResult); // If the expression hasn't already been captured, just capture it - // and set the new semantic + // and set the new semantic if (!isa<OpaqueValueExpr>(e)) { OpaqueValueExpr *cap = capture(e); setResultToLastSemantic(); @@ -618,11 +618,11 @@ bool ObjCPropertyOpBuilder::findGetter() { // Must build the getter selector the hard way. ObjCMethodDecl *setter = RefExpr->getImplicitPropertySetter(); assert(setter && "both setter and getter are null - cannot happen"); - IdentifierInfo *setterName = + IdentifierInfo *setterName = setter->getSelector().getIdentifierInfoForSlot(0); IdentifierInfo *getterName = &S.Context.Idents.get(setterName->getName().substr(3)); - GetterSelector = + GetterSelector = S.PP.getSelectorTable().getNullarySelector(getterName); return false; } @@ -636,7 +636,7 @@ bool ObjCPropertyOpBuilder::findGetter() { /// Try to find the most accurate setter declaration for the property /// reference. /// -/// \return true if a setter was found, in which case Setter +/// \return true if a setter was found, in which case Setter bool ObjCPropertyOpBuilder::findSetter(bool warn) { // For implicit properties, just trust the lookup we already did. if (RefExpr->isImplicitProperty()) { @@ -987,9 +987,9 @@ ExprResult ObjCPropertyOpBuilder::complete(Expr *SyntacticForm) { // ObjCSubscript build stuff. // -/// objective-c subscripting-specific behavior for doing lvalue-to-rvalue +/// objective-c subscripting-specific behavior for doing lvalue-to-rvalue /// conversion. -/// FIXME. Remove this routine if it is proven that no additional +/// FIXME. Remove this routine if it is proven that no additional /// specifity is needed. ExprResult ObjCSubscriptOpBuilder::buildRValueOperation(Expr *op) { ExprResult result = PseudoOpBuilder::buildRValueOperation(op); @@ -1007,21 +1007,21 @@ ObjCSubscriptOpBuilder::buildAssignmentOperation(Scope *Sc, // There must be a method to do the Index'ed assignment. if (!findAtIndexSetter()) return ExprError(); - + // Verify that we can do a compound assignment. if (opcode != BO_Assign && !findAtIndexGetter()) return ExprError(); - + ExprResult result = PseudoOpBuilder::buildAssignmentOperation(Sc, opcLoc, opcode, LHS, RHS); if (result.isInvalid()) return ExprError(); - + // Various warnings about objc Index'ed assignments in ARC. if (S.getLangOpts().ObjCAutoRefCount && InstanceBase) { S.checkRetainCycles(InstanceBase->getSourceExpr(), RHS); S.checkUnsafeExprAssigns(opcLoc, LHS, RHS); } - + return result; } @@ -1049,15 +1049,15 @@ Expr *ObjCSubscriptOpBuilder::rebuildAndCaptureObject(Expr *syntacticBase) { return syntacticBase; } -/// CheckSubscriptingKind - This routine decide what type +/// CheckSubscriptingKind - This routine decide what type /// of indexing represented by "FromE" is being done. -Sema::ObjCSubscriptKind +Sema::ObjCSubscriptKind Sema::CheckSubscriptingKind(Expr *FromE) { // If the expression already has integral or enumeration type, we're golden. QualType T = FromE->getType(); if (T->isIntegralOrEnumerationType()) return OS_Array; - + // If we don't have a class type in C++, there's no way we can get an // expression of integral or enumeration type. const RecordType *RecordTy = T->getAs<RecordType>(); @@ -1066,7 +1066,7 @@ Sema::ObjCSubscriptKind // All other scalar cases are assumed to be dictionary indexing which // caller handles, with diagnostics if needed. return OS_Dictionary; - if (!getLangOpts().CPlusPlus || + if (!getLangOpts().CPlusPlus || !RecordTy || RecordTy->isIncompleteType()) { // No indexing can be done. Issue diagnostics and quit. const Expr *IndexExpr = FromE->IgnoreParenImpCasts(); @@ -1078,12 +1078,12 @@ Sema::ObjCSubscriptKind << T; return OS_Error; } - + // We must have a complete class type. - if (RequireCompleteType(FromE->getExprLoc(), T, + if (RequireCompleteType(FromE->getExprLoc(), T, diag::err_objc_index_incomplete_class_type, FromE)) return OS_Error; - + // Look for a conversion to an integral, enumeration type, or // objective-C pointer type. int NoIntegrals=0, NoObjCIdPointers=0; @@ -1125,17 +1125,17 @@ Sema::ObjCSubscriptKind /// CheckKeyForObjCARCConversion - This routine suggests bridge casting of CF /// objects used as dictionary subscript key objects. -static void CheckKeyForObjCARCConversion(Sema &S, QualType ContainerT, +static void CheckKeyForObjCARCConversion(Sema &S, QualType ContainerT, Expr *Key) { if (ContainerT.isNull()) return; // dictionary subscripting. // - (id)objectForKeyedSubscript:(id)key; IdentifierInfo *KeyIdents[] = { - &S.Context.Idents.get("objectForKeyedSubscript") + &S.Context.Idents.get("objectForKeyedSubscript") }; Selector GetterSelector = S.Context.Selectors.getSelector(1, KeyIdents); - ObjCMethodDecl *Getter = S.LookupMethodInObjectType(GetterSelector, ContainerT, + ObjCMethodDecl *Getter = S.LookupMethodInObjectType(GetterSelector, ContainerT, true /*instance*/); if (!Getter) return; @@ -1147,25 +1147,25 @@ static void CheckKeyForObjCARCConversion(Sema &S, QualType ContainerT, bool ObjCSubscriptOpBuilder::findAtIndexGetter() { if (AtIndexGetter) return true; - + Expr *BaseExpr = RefExpr->getBaseExpr(); QualType BaseT = BaseExpr->getType(); - + QualType ResultType; if (const ObjCObjectPointerType *PTy = BaseT->getAs<ObjCObjectPointerType>()) { ResultType = PTy->getPointeeType(); } - Sema::ObjCSubscriptKind Res = + Sema::ObjCSubscriptKind Res = S.CheckSubscriptingKind(RefExpr->getKeyExpr()); if (Res == Sema::OS_Error) { if (S.getLangOpts().ObjCAutoRefCount) - CheckKeyForObjCARCConversion(S, ResultType, + CheckKeyForObjCARCConversion(S, ResultType, RefExpr->getKeyExpr()); return false; } bool arrayRef = (Res == Sema::OS_Array); - + if (ResultType.isNull()) { S.Diag(BaseExpr->getExprLoc(), diag::err_objc_subscript_base_type) << BaseExpr->getType() << arrayRef; @@ -1175,24 +1175,24 @@ bool ObjCSubscriptOpBuilder::findAtIndexGetter() { // dictionary subscripting. // - (id)objectForKeyedSubscript:(id)key; IdentifierInfo *KeyIdents[] = { - &S.Context.Idents.get("objectForKeyedSubscript") + &S.Context.Idents.get("objectForKeyedSubscript") }; AtIndexGetterSelector = S.Context.Selectors.getSelector(1, KeyIdents); } else { // - (id)objectAtIndexedSubscript:(size_t)index; IdentifierInfo *KeyIdents[] = { - &S.Context.Idents.get("objectAtIndexedSubscript") + &S.Context.Idents.get("objectAtIndexedSubscript") }; - + AtIndexGetterSelector = S.Context.Selectors.getSelector(1, KeyIdents); } - - AtIndexGetter = S.LookupMethodInObjectType(AtIndexGetterSelector, ResultType, + + AtIndexGetter = S.LookupMethodInObjectType(AtIndexGetterSelector, ResultType, true /*instance*/); - + if (!AtIndexGetter && S.getLangOpts().DebuggerObjCLiteral) { - AtIndexGetter = ObjCMethodDecl::Create(S.Context, SourceLocation(), + AtIndexGetter = ObjCMethodDecl::Create(S.Context, SourceLocation(), SourceLocation(), AtIndexGetterSelector, S.Context.getObjCIdType() /*ReturnType*/, nullptr /*TypeSourceInfo */, @@ -1220,20 +1220,20 @@ bool ObjCSubscriptOpBuilder::findAtIndexGetter() { << BaseExpr->getType() << 0 << arrayRef; return false; } - AtIndexGetter = - S.LookupInstanceMethodInGlobalPool(AtIndexGetterSelector, - RefExpr->getSourceRange(), + AtIndexGetter = + S.LookupInstanceMethodInGlobalPool(AtIndexGetterSelector, + RefExpr->getSourceRange(), true); } - + if (AtIndexGetter) { QualType T = AtIndexGetter->parameters()[0]->getType(); if ((arrayRef && !T->isIntegralOrEnumerationType()) || (!arrayRef && !T->isObjCObjectPointerType())) { - S.Diag(RefExpr->getKeyExpr()->getExprLoc(), + S.Diag(RefExpr->getKeyExpr()->getExprLoc(), arrayRef ? diag::err_objc_subscript_index_type : diag::err_objc_subscript_key_type) << T; - S.Diag(AtIndexGetter->parameters()[0]->getLocation(), + S.Diag(AtIndexGetter->parameters()[0]->getLocation(), diag::note_parameter_type) << T; return false; } @@ -1251,32 +1251,32 @@ bool ObjCSubscriptOpBuilder::findAtIndexGetter() { bool ObjCSubscriptOpBuilder::findAtIndexSetter() { if (AtIndexSetter) return true; - + Expr *BaseExpr = RefExpr->getBaseExpr(); QualType BaseT = BaseExpr->getType(); - + QualType ResultType; if (const ObjCObjectPointerType *PTy = BaseT->getAs<ObjCObjectPointerType>()) { ResultType = PTy->getPointeeType(); } - - Sema::ObjCSubscriptKind Res = + + Sema::ObjCSubscriptKind Res = S.CheckSubscriptingKind(RefExpr->getKeyExpr()); if (Res == Sema::OS_Error) { if (S.getLangOpts().ObjCAutoRefCount) - CheckKeyForObjCARCConversion(S, ResultType, + CheckKeyForObjCARCConversion(S, ResultType, RefExpr->getKeyExpr()); return false; } bool arrayRef = (Res == Sema::OS_Array); - + if (ResultType.isNull()) { S.Diag(BaseExpr->getExprLoc(), diag::err_objc_subscript_base_type) << BaseExpr->getType() << arrayRef; return false; } - + if (!arrayRef) { // dictionary subscripting. // - (void)setObject:(id)object forKeyedSubscript:(id)key; @@ -1294,7 +1294,7 @@ bool ObjCSubscriptOpBuilder::findAtIndexSetter() { }; AtIndexSetterSelector = S.Context.Selectors.getSelector(2, KeyIdents); } - AtIndexSetter = S.LookupMethodInObjectType(AtIndexSetterSelector, ResultType, + AtIndexSetter = S.LookupMethodInObjectType(AtIndexSetterSelector, ResultType, true /*instance*/); if (!AtIndexSetter && S.getLangOpts().DebuggerObjCLiteral) { @@ -1328,35 +1328,35 @@ bool ObjCSubscriptOpBuilder::findAtIndexSetter() { Params.push_back(key); AtIndexSetter->setMethodParams(S.Context, Params, None); } - + if (!AtIndexSetter) { if (!BaseT->isObjCIdType()) { - S.Diag(BaseExpr->getExprLoc(), + S.Diag(BaseExpr->getExprLoc(), diag::err_objc_subscript_method_not_found) << BaseExpr->getType() << 1 << arrayRef; return false; } - AtIndexSetter = - S.LookupInstanceMethodInGlobalPool(AtIndexSetterSelector, - RefExpr->getSourceRange(), + AtIndexSetter = + S.LookupInstanceMethodInGlobalPool(AtIndexSetterSelector, + RefExpr->getSourceRange(), true); } - + bool err = false; if (AtIndexSetter && arrayRef) { QualType T = AtIndexSetter->parameters()[1]->getType(); if (!T->isIntegralOrEnumerationType()) { - S.Diag(RefExpr->getKeyExpr()->getExprLoc(), + S.Diag(RefExpr->getKeyExpr()->getExprLoc(), diag::err_objc_subscript_index_type) << T; - S.Diag(AtIndexSetter->parameters()[1]->getLocation(), + S.Diag(AtIndexSetter->parameters()[1]->getLocation(), diag::note_parameter_type) << T; err = true; } T = AtIndexSetter->parameters()[0]->getType(); if (!T->isObjCObjectPointerType()) { - S.Diag(RefExpr->getBaseExpr()->getExprLoc(), + S.Diag(RefExpr->getBaseExpr()->getExprLoc(), diag::err_objc_subscript_object_type) << T << arrayRef; - S.Diag(AtIndexSetter->parameters()[0]->getLocation(), + S.Diag(AtIndexSetter->parameters()[0]->getLocation(), diag::note_parameter_type) << T; err = true; } @@ -1371,7 +1371,7 @@ bool ObjCSubscriptOpBuilder::findAtIndexSetter() { else S.Diag(RefExpr->getBaseExpr()->getExprLoc(), diag::err_objc_subscript_dic_object_type) << T; - S.Diag(AtIndexSetter->parameters()[i]->getLocation(), + S.Diag(AtIndexSetter->parameters()[i]->getLocation(), diag::note_parameter_type) << T; err = true; } @@ -1385,13 +1385,13 @@ bool ObjCSubscriptOpBuilder::findAtIndexSetter() { ExprResult ObjCSubscriptOpBuilder::buildGet() { if (!findAtIndexGetter()) return ExprError(); - + QualType receiverType = InstanceBase->getType(); - + // Build a message-send. ExprResult msg; Expr *Index = InstanceKey; - + // Arguments. Expr *args[] = { Index }; assert(InstanceBase); @@ -1417,17 +1417,17 @@ ExprResult ObjCSubscriptOpBuilder::buildSet(Expr *op, SourceLocation opcLoc, S.DiagnoseUseOfDecl(AtIndexSetter, GenericLoc); QualType receiverType = InstanceBase->getType(); Expr *Index = InstanceKey; - + // Arguments. Expr *args[] = { op, Index }; - + // Build a message-send. ExprResult msg = S.BuildInstanceMessageImplicit(InstanceBase, receiverType, GenericLoc, AtIndexSetterSelector, AtIndexSetter, MultiExprArg(args, 2)); - + if (!msg.isInvalid() && captureSetValueAsResult) { ObjCMessageExpr *msgExpr = cast<ObjCMessageExpr>(msg.get()->IgnoreImplicit()); @@ -1435,7 +1435,7 @@ ExprResult ObjCSubscriptOpBuilder::buildSet(Expr *op, SourceLocation opcLoc, if (CanCaptureValue(arg)) msgExpr->setArg(0, captureValueAsResult(arg)); } - + return msg; } diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index b2f9783d44..377e2c4dfa 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -216,7 +216,7 @@ void Sema::DiagnoseUnusedExprResult(const Stmt *S) { // expression is a call to a function with the warn_unused_result attribute, // we warn no matter the location. Because of the order in which the various // checks need to happen, we factor out the macro-related test here. - bool ShouldSuppress = + bool ShouldSuppress = SourceMgr.isMacroBodyExpansion(ExprLoc) || SourceMgr.isInSystemMacro(ExprLoc); @@ -1879,7 +1879,7 @@ Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc, VarDecl *D = dyn_cast<VarDecl>(DS->getSingleDecl()); if (!D || D->isInvalidDecl()) return StmtError(); - + FirstType = D->getType(); // C99 6.8.5p3: The declaration part of a 'for' statement shall only // declare identifiers for objects having storage class 'auto' or @@ -2373,7 +2373,7 @@ Sema::BuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation CoawaitLoc, // Rather, we need to determine what it was when the array was first // created - so we resort to using sizeof(vla)/sizeof(element). // For e.g. - // void f(int b) { + // void f(int b) { // int vla[b]; // b = -1; <-- This should not affect the num of iterations below // for (int &c : vla) { .. } @@ -2399,7 +2399,7 @@ Sema::BuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation CoawaitLoc, EndVar->getSourceRange()); if (SizeOfVLAExprR.isInvalid()) return StmtError(); - + ExprResult SizeOfEachElementExprR = ActOnUnaryExprOrTypeTraitExpr( EndVar->getLocation(), UETT_SizeOf, /*isType=*/true, @@ -2416,7 +2416,7 @@ Sema::BuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation CoawaitLoc, SizeOfVLAExprR.get(), SizeOfEachElementExprR.get()); if (BoundExpr.isInvalid()) return StmtError(); - + } else { // Can't be a DependentSizedArrayType or an IncompleteArrayType since // UnqAT is not incomplete and Range is not type-dependent. @@ -3366,7 +3366,7 @@ bool Sema::DeduceFunctionTypeFromReturnExpr(FunctionDecl *FD, // statement with a non-type-dependent operand. assert(AT->isDeduced() && "should have deduced to dependent type"); return false; - } + } if (RetExpr) { // Otherwise, [...] deduce a value for U using the rules of template diff --git a/lib/Sema/SemaStmtAsm.cpp b/lib/Sema/SemaStmtAsm.cpp index 7e26b71c04..0db15ea1f6 100644 --- a/lib/Sema/SemaStmtAsm.cpp +++ b/lib/Sema/SemaStmtAsm.cpp @@ -603,7 +603,7 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, Context.getTargetInfo(), Context); if (ConstraintLoc.isValid()) return Diag(ConstraintLoc, diag::error_inoutput_conflict_with_clobber); - + return NS; } diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 919bc7b63d..fa002de3f5 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -888,7 +888,7 @@ ParsedTemplateArgument Sema::ActOnTemplateTypeArgument(TypeResult ParsedType) { // This is a normal type template argument. Note, if the type template // argument is an injected-class-name for a template, it has a dual nature - // and can be used as either a type or a template. We handle that in + // and can be used as either a type or a template. We handle that in // convertTypeTemplateArgumentToTemplate. return ParsedTemplateArgument(ParsedTemplateArgument::Type, ParsedType.get().getAsOpaquePtr(), @@ -1044,14 +1044,14 @@ NamedDecl *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, // Check that we have valid decl-specifiers specified. auto CheckValidDeclSpecifiers = [this, &D] { // C++ [temp.param] - // p1 + // p1 // template-parameter: // ... // parameter-declaration - // p2 + // p2 // ... A storage class shall not be specified in a template-parameter // declaration. - // [dcl.typedef]p1: + // [dcl.typedef]p1: // The typedef specifier [...] shall not be used in the decl-specifier-seq // of a parameter-declaration const DeclSpec &DS = D.getDeclSpec(); @@ -1061,22 +1061,22 @@ NamedDecl *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, }; if (DS.getStorageClassSpec() != DeclSpec::SCS_unspecified) EmitDiag(DS.getStorageClassSpecLoc()); - + if (DS.getThreadStorageClassSpec() != TSCS_unspecified) EmitDiag(DS.getThreadStorageClassSpecLoc()); - - // [dcl.inline]p1: - // The inline specifier can be applied only to the declaration or + + // [dcl.inline]p1: + // The inline specifier can be applied only to the declaration or // definition of a variable or function. - + if (DS.isInlineSpecified()) EmitDiag(DS.getInlineSpecLoc()); - + // [dcl.constexpr]p1: - // The constexpr specifier shall be applied only to the definition of a - // variable or variable template or the declaration of a function or + // The constexpr specifier shall be applied only to the definition of a + // variable or variable template or the declaration of a function or // function template. - + if (DS.isConstexprSpecified()) EmitDiag(DS.getConstexprSpecLoc()); @@ -1094,7 +1094,7 @@ NamedDecl *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, }; CheckValidDeclSpecifiers(); - + if (TInfo->getType()->isUndeducedType()) { Diag(D.getIdentifierLoc(), diag::warn_cxx14_compat_template_nontype_parm_auto_type) diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp index 633b2837e1..df46d6115a 100644 --- a/lib/Sema/SemaTemplateDeduction.cpp +++ b/lib/Sema/SemaTemplateDeduction.cpp @@ -4599,7 +4599,7 @@ bool Sema::DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, CXXRecordDecl *Lambda = cast<CXXMethodDecl>(FD)->getParent(); FunctionDecl *CallOp = Lambda->getLambdaCallOperator(); - // For a generic lambda, instantiate the call operator if needed. + // For a generic lambda, instantiate the call operator if needed. if (auto *Args = FD->getTemplateSpecializationArgs()) { CallOp = InstantiateFunctionDeclaration( CallOp->getDescribedFunctionTemplate(), Args, Loc); diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index bc2ee42400..1aa69bd35d 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -52,7 +52,7 @@ using namespace sema; /// used to determine the proper set of template instantiation arguments for /// friend function template specializations. MultiLevelTemplateArgumentList -Sema::getTemplateInstantiationArgs(NamedDecl *D, +Sema::getTemplateInstantiationArgs(NamedDecl *D, const TemplateArgumentList *Innermost, bool RelativeToPrimary, const FunctionDecl *Pattern) { @@ -61,7 +61,7 @@ Sema::getTemplateInstantiationArgs(NamedDecl *D, if (Innermost) Result.addOuterTemplateArguments(Innermost); - + DeclContext *Ctx = dyn_cast<DeclContext>(D); if (!Ctx) { Ctx = D->getDeclContext(); @@ -100,7 +100,7 @@ Sema::getTemplateInstantiationArgs(NamedDecl *D, // use empty template parameter lists for all of the outer templates // to avoid performing any substitutions. if (Ctx->isTranslationUnit()) { - if (TemplateTemplateParmDecl *TTP + if (TemplateTemplateParmDecl *TTP = dyn_cast<TemplateTemplateParmDecl>(D)) { for (unsigned I = 0, N = TTP->getDepth() + 1; I != N; ++I) Result.addOuterTemplateArguments(None); @@ -108,7 +108,7 @@ Sema::getTemplateInstantiationArgs(NamedDecl *D, } } } - + while (!Ctx->isFileContext()) { // Add template arguments from a class template instantiation. if (ClassTemplateSpecializationDecl *Spec @@ -119,8 +119,8 @@ Sema::getTemplateInstantiationArgs(NamedDecl *D, break; Result.addOuterTemplateArguments(&Spec->getTemplateInstantiationArgs()); - - // If this class template specialization was instantiated from a + + // If this class template specialization was instantiated from a // specialized member that is a class template, we're done. assert(Spec->getSpecializedTemplate() && "No class template?"); if (Spec->getSpecializedTemplate()->isMemberSpecialization()) @@ -129,11 +129,11 @@ Sema::getTemplateInstantiationArgs(NamedDecl *D, // Add template arguments from a function template specialization. else if (FunctionDecl *Function = dyn_cast<FunctionDecl>(Ctx)) { if (!RelativeToPrimary && - (Function->getTemplateSpecializationKind() == + (Function->getTemplateSpecializationKind() == TSK_ExplicitSpecialization && !Function->getClassScopeSpecializationPattern())) break; - + if (const TemplateArgumentList *TemplateArgs = Function->getTemplateSpecializationArgs()) { // Add the template arguments for this specialization. @@ -154,7 +154,7 @@ Sema::getTemplateInstantiationArgs(NamedDecl *D, // Add the "injected" template arguments. Result.addOuterTemplateArguments(FunTmpl->getInjectedTemplateArgs()); } - + // If this is a friend declaration and it declares an entity at // namespace scope, take arguments from its lexical parent // instead of its semantic parent, unless of course the pattern we're @@ -200,7 +200,7 @@ bool Sema::CodeSynthesisContext::isInstantiationRecord() const { case DeclaringSpecialMember: case DefiningSynthesizedFunction: return false; - + // This function should never be called when Kind's value is Memoization. case Memoization: break; @@ -413,7 +413,7 @@ bool Sema::InstantiatingTemplate::CheckInstantiationDepth( SourceRange InstantiationRange) { assert(SemaRef.NonInstantiationEntries <= SemaRef.CodeSynthesisContexts.size()); - if ((SemaRef.CodeSynthesisContexts.size() - + if ((SemaRef.CodeSynthesisContexts.size() - SemaRef.NonInstantiationEntries) <= SemaRef.getLangOpts().InstantiationDepth) return false; @@ -517,9 +517,9 @@ void Sema::PrintInstantiationStack() { FunctionTemplateDecl *FnTmpl = cast<FunctionTemplateDecl>(Active->Entity); Diags.Report(Active->PointOfInstantiation, diag::note_explicit_template_arg_substitution_here) - << FnTmpl - << getTemplateArgumentBindingsText(FnTmpl->getTemplateParameters(), - Active->TemplateArgs, + << FnTmpl + << getTemplateArgumentBindingsText(FnTmpl->getTemplateParameters(), + Active->TemplateArgs, Active->NumTemplateArgs) << Active->InstantiationRange; break; @@ -531,8 +531,8 @@ void Sema::PrintInstantiationStack() { Diags.Report(Active->PointOfInstantiation, diag::note_function_template_deduction_instantiation_here) << FnTmpl - << getTemplateArgumentBindingsText(FnTmpl->getTemplateParameters(), - Active->TemplateArgs, + << getTemplateArgumentBindingsText(FnTmpl->getTemplateParameters(), + Active->TemplateArgs, Active->NumTemplateArgs) << Active->InstantiationRange; } else { @@ -556,7 +556,7 @@ void Sema::PrintInstantiationStack() { Diags.Report(Active->PointOfInstantiation, diag::note_deduced_template_arg_substitution_here) << IsVar << IsTemplate << cast<NamedDecl>(Active->Entity) - << getTemplateArgumentBindingsText(Params, Active->TemplateArgs, + << getTemplateArgumentBindingsText(Params, Active->TemplateArgs, Active->NumTemplateArgs) << Active->InstantiationRange; } @@ -596,8 +596,8 @@ void Sema::PrintInstantiationStack() { diag::note_prior_template_arg_substitution) << isa<TemplateTemplateParmDecl>(Parm) << Name - << getTemplateArgumentBindingsText(TemplateParams, - Active->TemplateArgs, + << getTemplateArgumentBindingsText(TemplateParams, + Active->TemplateArgs, Active->NumTemplateArgs) << Active->InstantiationRange; break; @@ -614,8 +614,8 @@ void Sema::PrintInstantiationStack() { Diags.Report(Active->PointOfInstantiation, diag::note_template_default_arg_checking) - << getTemplateArgumentBindingsText(TemplateParams, - Active->TemplateArgs, + << getTemplateArgumentBindingsText(TemplateParams, + Active->TemplateArgs, Active->NumTemplateArgs) << Active->InstantiationRange; break; @@ -660,7 +660,7 @@ Optional<TemplateDeductionInfo *> Sema::isSFINAEContext() const { Active = CodeSynthesisContexts.rbegin(), ActiveEnd = CodeSynthesisContexts.rend(); Active != ActiveEnd; - ++Active) + ++Active) { switch (Active->Kind) { case CodeSynthesisContext::TemplateInstantiation: @@ -678,7 +678,7 @@ Optional<TemplateDeductionInfo *> Sema::isSFINAEContext() const { case CodeSynthesisContext::PriorTemplateArgumentSubstitution: case CodeSynthesisContext::DefaultTemplateArgumentChecking: // A default template argument instantiation and substitution into - // template parameters with arguments for prior parameters may or may + // template parameters with arguments for prior parameters may or may // not be a SFINAE context; look further up the stack. break; @@ -752,18 +752,18 @@ namespace { ArrayRef<UnexpandedParameterPack> Unexpanded, bool &ShouldExpand, bool &RetainExpansion, Optional<unsigned> &NumExpansions) { - return getSema().CheckParameterPacksForExpansion(EllipsisLoc, + return getSema().CheckParameterPacksForExpansion(EllipsisLoc, PatternRange, Unexpanded, - TemplateArgs, + TemplateArgs, ShouldExpand, RetainExpansion, NumExpansions); } - void ExpandingFunctionParameterPack(ParmVarDecl *Pack) { + void ExpandingFunctionParameterPack(ParmVarDecl *Pack) { SemaRef.CurrentInstantiationScope->MakeInstantiatedLocalArgPack(Pack); } - + TemplateArgument ForgetPartiallySubstitutedPack() { TemplateArgument Result; if (NamedDecl *PartialPack @@ -777,14 +777,14 @@ namespace { TemplateArgs.setArgument(Depth, Index, TemplateArgument()); } } - + return Result; } - + void RememberPartiallySubstitutedPack(TemplateArgument Arg) { if (Arg.isNull()) return; - + if (NamedDecl *PartialPack = SemaRef.CurrentInstantiationScope->getPartiallySubstitutedPack()){ MultiLevelTemplateArgumentList &TemplateArgs @@ -799,7 +799,7 @@ namespace { /// this declaration. Decl *TransformDecl(SourceLocation Loc, Decl *D); - void transformAttrs(Decl *Old, Decl *New) { + void transformAttrs(Decl *Old, Decl *New) { SemaRef.InstantiateAttrs(TemplateArgs, Old, New); } @@ -817,7 +817,7 @@ namespace { NewMD->setInstantiationOfMemberFunction(OldMD, TSK_ImplicitInstantiation); } - + SemaRef.CurrentInstantiationScope->InstantiatedLocal(Old, New); // We recreated a local declaration, but not by instantiating it. There @@ -825,7 +825,7 @@ namespace { if (auto *DC = dyn_cast<DeclContext>(Old)) SemaRef.PerformDependentDiagnostics(DC, TemplateArgs); } - + /// Transform the definition of the given declaration by /// instantiating it. Decl *TransformDefinition(SourceLocation Loc, Decl *D); @@ -833,20 +833,20 @@ namespace { /// Transform the first qualifier within a scope by instantiating the /// declaration. NamedDecl *TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc); - + /// Rebuild the exception declaration and register the declaration /// as an instantiated local. - VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl, + VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl, TypeSourceInfo *Declarator, SourceLocation StartLoc, SourceLocation NameLoc, IdentifierInfo *Name); - /// Rebuild the Objective-C exception declaration and register the + /// Rebuild the Objective-C exception declaration and register the /// declaration as an instantiated local. - VarDecl *RebuildObjCExceptionDecl(VarDecl *ExceptionDecl, + VarDecl *RebuildObjCExceptionDecl(VarDecl *ExceptionDecl, TypeSourceInfo *TSInfo, QualType T); - + /// Check for tag mismatches when instantiating an /// elaborated type. QualType RebuildElaboratedType(SourceLocation KeywordLoc, @@ -921,11 +921,11 @@ namespace { TemplateParameterList *TransformTemplateParameterList( TemplateParameterList *OrigTPL) { if (!OrigTPL || !OrigTPL->size()) return OrigTPL; - + DeclContext *Owner = OrigTPL->getParam(0)->getDeclContext(); - TemplateDeclInstantiator DeclInstantiator(getSema(), + TemplateDeclInstantiator DeclInstantiator(getSema(), /* DeclContext *Owner */ Owner, TemplateArgs); - return DeclInstantiator.SubstTemplateParams(OrigTPL); + return DeclInstantiator.SubstTemplateParams(OrigTPL); } private: ExprResult transformNonTypeTemplateParmRef(NonTypeTemplateParmDecl *parm, @@ -937,17 +937,17 @@ namespace { bool TemplateInstantiator::AlreadyTransformed(QualType T) { if (T.isNull()) return true; - + if (T->isInstantiationDependentType() || T->isVariablyModifiedType()) return false; - + getSema().MarkDeclarationsReferencedInType(Loc, T); return true; } static TemplateArgument getPackSubstitutedTemplateArgument(Sema &S, TemplateArgument Arg) { - assert(S.ArgumentPackSubstitutionIndex >= 0); + assert(S.ArgumentPackSubstitutionIndex >= 0); assert(S.ArgumentPackSubstitutionIndex < (int)Arg.pack_size()); Arg = Arg.pack_begin()[S.ArgumentPackSubstitutionIndex]; if (Arg.isPackExpansion()) @@ -970,9 +970,9 @@ Decl *TemplateInstantiator::TransformDecl(SourceLocation Loc, Decl *D) { return D; TemplateArgument Arg = TemplateArgs(TTP->getDepth(), TTP->getPosition()); - + if (TTP->isParameterPack()) { - assert(Arg.getKind() == TemplateArgument::Pack && + assert(Arg.getKind() == TemplateArgument::Pack && "Missing argument pack"); Arg = getPackSubstitutedTemplateArgument(getSema(), Arg); } @@ -1000,22 +1000,22 @@ Decl *TemplateInstantiator::TransformDefinition(SourceLocation Loc, Decl *D) { } NamedDecl * -TemplateInstantiator::TransformFirstQualifierInScope(NamedDecl *D, +TemplateInstantiator::TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc) { - // If the first part of the nested-name-specifier was a template type + // If the first part of the nested-name-specifier was a template type // parameter, instantiate that type parameter down to a tag type. if (TemplateTypeParmDecl *TTPD = dyn_cast_or_null<TemplateTypeParmDecl>(D)) { - const TemplateTypeParmType *TTP + const TemplateTypeParmType *TTP = cast<TemplateTypeParmType>(getSema().Context.getTypeDeclType(TTPD)); - + if (TTP->getDepth() < TemplateArgs.getNumLevels()) { // FIXME: This needs testing w/ member access expressions. TemplateArgument Arg = TemplateArgs(TTP->getDepth(), TTP->getIndex()); - + if (TTP->isParameterPack()) { - assert(Arg.getKind() == TemplateArgument::Pack && + assert(Arg.getKind() == TemplateArgument::Pack && "Missing argument pack"); - + if (getSema().ArgumentPackSubstitutionIndex == -1) return nullptr; @@ -1025,16 +1025,16 @@ TemplateInstantiator::TransformFirstQualifierInScope(NamedDecl *D, QualType T = Arg.getAsType(); if (T.isNull()) return cast_or_null<NamedDecl>(TransformDecl(Loc, D)); - + if (const TagType *Tag = T->getAs<TagType>()) return Tag->getDecl(); - + // The resulting type is not a tag; complain. getSema().Diag(Loc, diag::err_nested_name_spec_non_tag) << T; return nullptr; } } - + return cast_or_null<NamedDecl>(TransformDecl(Loc, D)); } @@ -1051,8 +1051,8 @@ TemplateInstantiator::RebuildExceptionDecl(VarDecl *ExceptionDecl, return Var; } -VarDecl *TemplateInstantiator::RebuildObjCExceptionDecl(VarDecl *ExceptionDecl, - TypeSourceInfo *TSInfo, +VarDecl *TemplateInstantiator::RebuildObjCExceptionDecl(VarDecl *ExceptionDecl, + TypeSourceInfo *TSInfo, QualType T) { VarDecl *Var = inherited::RebuildObjCExceptionDecl(ExceptionDecl, TSInfo, T); if (Var) @@ -1107,13 +1107,13 @@ TemplateName TemplateInstantiator::TransformTemplateName( if (!TemplateArgs.hasTemplateArgument(TTP->getDepth(), TTP->getPosition())) return Name; - + TemplateArgument Arg = TemplateArgs(TTP->getDepth(), TTP->getPosition()); - + if (TTP->isParameterPack()) { - assert(Arg.getKind() == TemplateArgument::Pack && + assert(Arg.getKind() == TemplateArgument::Pack && "Missing argument pack"); - + if (getSema().ArgumentPackSubstitutionIndex == -1) { // We have the template argument pack to substitute, but we're not // actually expanding the enclosing pack expansion yet. So, just @@ -1123,7 +1123,7 @@ TemplateName TemplateInstantiator::TransformTemplateName( Arg = getPackSubstitutedTemplateArgument(getSema(), Arg); } - + TemplateName Template = Arg.getAsTemplate().getNameToSubstitute(); assert(!Template.isNull() && "Null template template argument"); assert(!Template.getAsQualifiedTemplateName() && @@ -1133,12 +1133,12 @@ TemplateName TemplateInstantiator::TransformTemplateName( return Template; } } - + if (SubstTemplateTemplateParmPackStorage *SubstPack = Name.getAsSubstTemplateTemplateParmPack()) { if (getSema().ArgumentPackSubstitutionIndex == -1) return Name; - + TemplateArgument Arg = SubstPack->getArgumentPack(); Arg = getPackSubstitutedTemplateArgument(getSema(), Arg); return Arg.getAsTemplate().getNameToSubstitute(); @@ -1149,7 +1149,7 @@ TemplateName TemplateInstantiator::TransformTemplateName( AllowInjectedClassName); } -ExprResult +ExprResult TemplateInstantiator::TransformPredefinedExpr(PredefinedExpr *E) { if (!E->isTypeDependent()) return E; @@ -1187,15 +1187,15 @@ TemplateInstantiator::TransformTemplateParmRefExpr(DeclRefExpr *E, } if (NTTP->isParameterPack()) { - assert(Arg.getKind() == TemplateArgument::Pack && + assert(Arg.getKind() == TemplateArgument::Pack && "Missing argument pack"); - + if (getSema().ArgumentPackSubstitutionIndex == -1) { // We have an argument pack, but we can't select a particular argument // out of it yet. Therefore, we'll build an expression to hold on to that // argument pack. QualType TargetType = SemaRef.SubstType(NTTP->getType(), TemplateArgs, - E->getLocation(), + E->getLocation(), NTTP->getDeclName()); if (TargetType.isNull()) return ExprError(); @@ -1205,7 +1205,7 @@ TemplateInstantiator::TransformTemplateParmRefExpr(DeclRefExpr *E, TargetType->isReferenceType() ? VK_LValue : VK_RValue, NTTP, E->getLocation(), Arg); } - + Arg = getPackSubstitutedTemplateArgument(getSema(), Arg); } @@ -1260,12 +1260,12 @@ ExprResult TemplateInstantiator::transformNonTypeTemplateParmRef( // Propagate NULL template argument. VD = nullptr; } - + // Derive the type we want the substituted decl to have. This had // better be non-dependent, or these checks will have serious problems. if (parm->isExpandedParameterPack()) { type = parm->getExpansionType(SemaRef.ArgumentPackSubstitutionIndex); - } else if (parm->isParameterPack() && + } else if (parm->isParameterPack() && isa<PackExpansionType>(parm->getType())) { type = SemaRef.SubstType( cast<PackExpansionType>(parm->getType())->getPattern(), @@ -1292,8 +1292,8 @@ ExprResult TemplateInstantiator::transformNonTypeTemplateParmRef( return new (SemaRef.Context) SubstNonTypeTemplateParmExpr( type, resultExpr->getValueKind(), loc, parm, resultExpr); } - -ExprResult + +ExprResult TemplateInstantiator::TransformSubstNonTypeTemplateParmPackExpr( SubstNonTypeTemplateParmPackExpr *E) { if (getSema().ArgumentPackSubstitutionIndex == -1) { @@ -1387,7 +1387,7 @@ TemplateInstantiator::TransformDeclRefExpr(DeclRefExpr *E) { if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(D)) { if (NTTP->getDepth() < TemplateArgs.getNumLevels()) return TransformTemplateParmRefExpr(E, NTTP); - + // We have a non-type template parameter that isn't fully substituted; // FindInstantiatedDecl will find it in the local instantiation scope. } @@ -1406,7 +1406,7 @@ ExprResult TemplateInstantiator::TransformCXXDefaultArgExpr( getDescribedFunctionTemplate() && "Default arg expressions are never formed in dependent cases."); return SemaRef.BuildCXXDefaultArgExpr(E->getUsedLocation(), - cast<FunctionDecl>(E->getParam()->getDeclContext()), + cast<FunctionDecl>(E->getParam()->getDeclContext()), E->getParam()); } @@ -1451,11 +1451,11 @@ TemplateInstantiator::TransformTemplateTypeParmType(TypeLocBuilder &TLB, } TemplateArgument Arg = TemplateArgs(T->getDepth(), T->getIndex()); - + if (T->isParameterPack()) { - assert(Arg.getKind() == TemplateArgument::Pack && + assert(Arg.getKind() == TemplateArgument::Pack && "Missing argument pack"); - + if (getSema().ArgumentPackSubstitutionIndex == -1) { // We have the template argument pack, but we're not expanding the // enclosing pack expansion yet. Just save the template argument @@ -1467,10 +1467,10 @@ TemplateInstantiator::TransformTemplateTypeParmType(TypeLocBuilder &TLB, NewTL.setNameLoc(TL.getNameLoc()); return Result; } - + Arg = getPackSubstitutedTemplateArgument(getSema(), Arg); } - + assert(Arg.getKind() == TemplateArgument::Type && "Template argument kind mismatch"); @@ -1502,7 +1502,7 @@ TemplateInstantiator::TransformTemplateTypeParmType(TypeLocBuilder &TLB, return Result; } -QualType +QualType TemplateInstantiator::TransformSubstTemplateTypeParmPackType( TypeLocBuilder &TLB, SubstTemplateTypeParmPackTypeLoc TL) { @@ -1565,8 +1565,8 @@ TypeSourceInfo *Sema::SubstType(TypeSourceInfo *T, assert(!CodeSynthesisContexts.empty() && "Cannot perform an instantiation without some context on the " "instantiation stack"); - - if (!T->getType()->isInstantiationDependentType() && + + if (!T->getType()->isInstantiationDependentType() && !T->getType()->isVariablyModifiedType()) return T; @@ -1582,11 +1582,11 @@ TypeSourceInfo *Sema::SubstType(TypeLoc TL, assert(!CodeSynthesisContexts.empty() && "Cannot perform an instantiation without some context on the " "instantiation stack"); - + if (TL.getType().isNull()) return nullptr; - if (!TL.getType()->isInstantiationDependentType() && + if (!TL.getType()->isInstantiationDependentType() && !TL.getType()->isVariablyModifiedType()) { // FIXME: Make a copy of the TypeLoc data here, so that we can // return a new TypeSourceInfo. Inefficient! @@ -1716,7 +1716,7 @@ void Sema::SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto, UpdateExceptionSpec(New, ESI); } -ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm, +ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm, const MultiLevelTemplateArgumentList &TemplateArgs, int indexAdjustment, Optional<unsigned> NumExpansions, @@ -1727,9 +1727,9 @@ ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm, TypeLoc OldTL = OldDI->getTypeLoc(); if (PackExpansionTypeLoc ExpansionTL = OldTL.getAs<PackExpansionTypeLoc>()) { - // We have a function parameter pack. Substitute into the pattern of the + // We have a function parameter pack. Substitute into the pattern of the // expansion. - NewDI = SubstType(ExpansionTL.getPatternLoc(), TemplateArgs, + NewDI = SubstType(ExpansionTL.getPatternLoc(), TemplateArgs, OldParm->getLocation(), OldParm->getDeclName()); if (!NewDI) return nullptr; @@ -1745,16 +1745,16 @@ ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm, // itself is not a pack expansion type), so complain. This can occur when // the substitution goes through an alias template that "loses" the // pack expansion. - Diag(OldParm->getLocation(), + Diag(OldParm->getLocation(), diag::err_function_parameter_pack_without_parameter_packs) << NewDI->getType(); return nullptr; - } + } } else { - NewDI = SubstType(OldDI, TemplateArgs, OldParm->getLocation(), + NewDI = SubstType(OldDI, TemplateArgs, OldParm->getLocation(), OldParm->getDeclName()); } - + if (!NewDI) return nullptr; @@ -1801,15 +1801,15 @@ ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm, } NewParm->setHasInheritedDefaultArg(OldParm->hasInheritedDefaultArg()); - + if (OldParm->isParameterPack() && !NewParm->isParameterPack()) { // Add the new parameter to the instantiated parameter pack. CurrentInstantiationScope->InstantiatedLocalPackArg(OldParm, NewParm); } else { // Introduce an Old -> New mapping - CurrentInstantiationScope->InstantiatedLocal(OldParm, NewParm); + CurrentInstantiationScope->InstantiatedLocal(OldParm, NewParm); } - + // FIXME: OldParm may come from a FunctionProtoType, in which case CurContext // can be anything, is this right ? NewParm->setDeclContext(CurContext); @@ -1819,7 +1819,7 @@ ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm, InstantiateAttrs(TemplateArgs, OldParm, NewParm); - return NewParm; + return NewParm; } /// Substitute the given template arguments into the given set of @@ -1835,8 +1835,8 @@ bool Sema::SubstParmTypes( assert(!CodeSynthesisContexts.empty() && "Cannot perform an instantiation without some context on the " "instantiation stack"); - - TemplateInstantiator Instantiator(*this, TemplateArgs, Loc, + + TemplateInstantiator Instantiator(*this, TemplateArgs, Loc, DeclarationName()); return Instantiator.TransformFunctionTypeParams( Loc, Params, nullptr, ExtParamInfos, ParamTypes, OutParams, ParamInfos); @@ -1875,21 +1875,21 @@ Sema::SubstBaseSpecifiers(CXXRecordDecl *Instantiation, bool ShouldExpand = false; bool RetainExpansion = false; Optional<unsigned> NumExpansions; - if (CheckParameterPacksForExpansion(Base.getEllipsisLoc(), + if (CheckParameterPacksForExpansion(Base.getEllipsisLoc(), Base.getSourceRange(), Unexpanded, - TemplateArgs, ShouldExpand, + TemplateArgs, ShouldExpand, RetainExpansion, NumExpansions)) { Invalid = true; continue; } - + // If we should expand this pack expansion now, do so. if (ShouldExpand) { for (unsigned I = 0; I != *NumExpansions; ++I) { Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(*this, I); - + TypeSourceInfo *BaseTypeLoc = SubstType(Base.getTypeSourceInfo(), TemplateArgs, Base.getSourceRange().getBegin(), @@ -1898,7 +1898,7 @@ Sema::SubstBaseSpecifiers(CXXRecordDecl *Instantiation, Invalid = true; continue; } - + if (CXXBaseSpecifier *InstantiatedBase = CheckBaseSpecifier(Instantiation, Base.getSourceRange(), @@ -1910,10 +1910,10 @@ Sema::SubstBaseSpecifiers(CXXRecordDecl *Instantiation, else Invalid = true; } - + continue; } - + // The resulting base specifier will (still) be a pack expansion. EllipsisLoc = Base.getEllipsisLoc(); Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(*this, -1); @@ -1927,7 +1927,7 @@ Sema::SubstBaseSpecifiers(CXXRecordDecl *Instantiation, Base.getSourceRange().getBegin(), DeclarationName()); } - + if (!BaseTypeLoc) { Invalid = true; continue; @@ -1999,11 +1999,11 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation, Pattern = PatternDef; // Record the point of instantiation. - if (MemberSpecializationInfo *MSInfo + if (MemberSpecializationInfo *MSInfo = Instantiation->getMemberSpecializationInfo()) { MSInfo->setTemplateSpecializationKind(TSK); MSInfo->setPointOfInstantiation(PointOfInstantiation); - } else if (ClassTemplateSpecializationDecl *Spec + } else if (ClassTemplateSpecializationDecl *Spec = dyn_cast<ClassTemplateSpecializationDecl>(Instantiation)) { Spec->setTemplateSpecializationKind(TSK); Spec->setPointOfInstantiation(PointOfInstantiation); @@ -2563,15 +2563,15 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation, if (auto *Function = dyn_cast<FunctionDecl>(D)) { if (FunctionDecl *Pattern = Function->getInstantiatedFromMemberFunction()) { - MemberSpecializationInfo *MSInfo + MemberSpecializationInfo *MSInfo = Function->getMemberSpecializationInfo(); assert(MSInfo && "No member specialization information?"); if (MSInfo->getTemplateSpecializationKind() == TSK_ExplicitSpecialization) continue; - - if (CheckSpecializationInstantiationRedecl(PointOfInstantiation, TSK, - Function, + + if (CheckSpecializationInstantiationRedecl(PointOfInstantiation, TSK, + Function, MSInfo->getTemplateSpecializationKind(), MSInfo->getPointOfInstantiation(), SuppressNew) || @@ -2610,31 +2610,31 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation, if (MSInfo->getTemplateSpecializationKind() == TSK_ExplicitSpecialization) continue; - - if (CheckSpecializationInstantiationRedecl(PointOfInstantiation, TSK, - Var, + + if (CheckSpecializationInstantiationRedecl(PointOfInstantiation, TSK, + Var, MSInfo->getTemplateSpecializationKind(), MSInfo->getPointOfInstantiation(), SuppressNew) || SuppressNew) continue; - + if (TSK == TSK_ExplicitInstantiationDefinition) { // C++0x [temp.explicit]p8: // An explicit instantiation definition that names a class template - // specialization explicitly instantiates the class template - // specialization and is only an explicit instantiation definition - // of members whose definition is visible at the point of + // specialization explicitly instantiates the class template + // specialization and is only an explicit instantiation definition + // of members whose definition is visible at the point of // instantiation. if (!Var->getInstantiatedFromStaticDataMember()->getDefinition()) continue; - + Var->setTemplateSpecializationKind(TSK, PointOfInstantiation); InstantiateVariableDefinition(PointOfInstantiation, Var); } else { Var->setTemplateSpecializationKind(TSK, PointOfInstantiation); } - } + } } else if (auto *Record = dyn_cast<CXXRecordDecl>(D)) { // Always skip the injected-class-name, along with any // redeclarations of nested classes, since both would cause us @@ -2644,10 +2644,10 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation, if (Record->isInjectedClassName() || Record->getPreviousDecl() || Record->isLambda()) continue; - + MemberSpecializationInfo *MSInfo = Record->getMemberSpecializationInfo(); assert(MSInfo && "No member specialization information?"); - + if (MSInfo->getTemplateSpecializationKind() == TSK_ExplicitSpecialization) continue; @@ -2660,33 +2660,33 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation, continue; } - if (CheckSpecializationInstantiationRedecl(PointOfInstantiation, TSK, - Record, + if (CheckSpecializationInstantiationRedecl(PointOfInstantiation, TSK, + Record, MSInfo->getTemplateSpecializationKind(), MSInfo->getPointOfInstantiation(), SuppressNew) || SuppressNew) continue; - + CXXRecordDecl *Pattern = Record->getInstantiatedFromMemberClass(); assert(Pattern && "Missing instantiated-from-template information"); - + if (!Record->getDefinition()) { if (!Pattern->getDefinition()) { // C++0x [temp.explicit]p8: // An explicit instantiation definition that names a class template - // specialization explicitly instantiates the class template - // specialization and is only an explicit instantiation definition - // of members whose definition is visible at the point of + // specialization explicitly instantiates the class template + // specialization and is only an explicit instantiation definition + // of members whose definition is visible at the point of // instantiation. if (TSK == TSK_ExplicitInstantiationDeclaration) { MSInfo->setTemplateSpecializationKind(TSK); MSInfo->setPointOfInstantiation(PointOfInstantiation); } - + continue; } - + InstantiateClass(PointOfInstantiation, Record, Pattern, TemplateArgs, TSK); @@ -2698,10 +2698,10 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation, MarkVTableUsed(PointOfInstantiation, Record, true); } } - + Pattern = cast_or_null<CXXRecordDecl>(Record->getDefinition()); if (Pattern) - InstantiateClassMembers(PointOfInstantiation, Pattern, TemplateArgs, + InstantiateClassMembers(PointOfInstantiation, Pattern, TemplateArgs, TSK); } else if (auto *Enum = dyn_cast<EnumDecl>(D)) { MemberSpecializationInfo *MSInfo = Enum->getMemberSpecializationInfo(); @@ -2816,10 +2816,10 @@ bool Sema::SubstExprs(ArrayRef<Expr *> Exprs, bool IsCall, NestedNameSpecifierLoc Sema::SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, - const MultiLevelTemplateArgumentList &TemplateArgs) { + const MultiLevelTemplateArgumentList &TemplateArgs) { if (!NNS) return NestedNameSpecifierLoc(); - + TemplateInstantiator Instantiator(*this, TemplateArgs, NNS.getBeginLoc(), DeclarationName()); return Instantiator.TransformNestedNameSpecifierLoc(NNS); @@ -2850,7 +2850,7 @@ bool Sema::Subst(const TemplateArgumentLoc *Args, unsigned NumArgs, const MultiLevelTemplateArgumentList &TemplateArgs) { TemplateInstantiator Instantiator(*this, TemplateArgs, SourceLocation(), DeclarationName()); - + return Instantiator.TransformTemplateArguments(Args, NumArgs, Result); } @@ -2884,7 +2884,7 @@ LocalInstantiationScope::findInstantiationOf(const Decl *D) { LocalDeclsMap::iterator Found = Current->LocalDecls.find(CheckD); if (Found != Current->LocalDecls.end()) return &Found->second; - + // If this is a tag declaration, it's possible that we need to look for // a previous declaration. if (const TagDecl *Tag = dyn_cast<TagDecl>(CheckD)) @@ -2892,8 +2892,8 @@ LocalInstantiationScope::findInstantiationOf(const Decl *D) { else CheckD = nullptr; } while (CheckD); - - // If we aren't combined with our outer scope, we're done. + + // If we aren't combined with our outer scope, we're done. if (!Current->CombineWithOuterScope) break; } @@ -2965,12 +2965,12 @@ void LocalInstantiationScope::MakeInstantiatedLocalArgPack(const Decl *D) { ArgumentPacks.push_back(Pack); } -void LocalInstantiationScope::SetPartiallySubstitutedPack(NamedDecl *Pack, +void LocalInstantiationScope::SetPartiallySubstitutedPack(NamedDecl *Pack, const TemplateArgument *ExplicitArgs, unsigned NumExplicitArgs) { assert((!PartiallySubstitutedPack || PartiallySubstitutedPack == Pack) && "Already have a partially-substituted pack"); - assert((!PartiallySubstitutedPack + assert((!PartiallySubstitutedPack || NumArgsInPartiallySubstitutedPack == NumExplicitArgs) && "Wrong number of arguments in partially-substituted pack"); PartiallySubstitutedPack = Pack; @@ -2985,15 +2985,15 @@ NamedDecl *LocalInstantiationScope::getPartiallySubstitutedPack( *ExplicitArgs = nullptr; if (NumExplicitArgs) *NumExplicitArgs = 0; - - for (const LocalInstantiationScope *Current = this; Current; + + for (const LocalInstantiationScope *Current = this; Current; Current = Current->Outer) { if (Current->PartiallySubstitutedPack) { if (ExplicitArgs) *ExplicitArgs = Current->ArgsInPartiallySubstitutedPack; if (NumExplicitArgs) *NumExplicitArgs = Current->NumArgsInPartiallySubstitutedPack; - + return Current->PartiallySubstitutedPack; } diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 5109dc8290..86492716f6 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -729,7 +729,7 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D, DI, D->getStorageClass()); // In ARC, infer 'retaining' for variables of retainable type. - if (SemaRef.getLangOpts().ObjCAutoRefCount && + if (SemaRef.getLangOpts().ObjCAutoRefCount && SemaRef.inferObjCARCLifetime(Var)) Var->setInvalidDecl(); @@ -2056,7 +2056,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, // previous declaration we just found. if (isFriend && Method->getPreviousDecl()) Method->setAccess(Method->getPreviousDecl()->getAccess()); - else + else Method->setAccess(D->getAccess()); if (FunctionTemplate) FunctionTemplate->setAccess(Method->getAccess()); @@ -3417,7 +3417,7 @@ TemplateDeclInstantiator::SubstFunctionType(FunctionDecl *D, ThisContext = cast<CXXRecordDecl>(Owner); ThisTypeQuals = Method->getTypeQualifiers(); } - + TypeSourceInfo *NewTInfo = SemaRef.SubstFunctionDeclType(OldTInfo, TemplateArgs, D->getTypeSpecStartLoc(), @@ -4890,14 +4890,14 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, bool FindingInstantiatedContext) { DeclContext *ParentDC = D->getDeclContext(); - // FIXME: Parmeters of pointer to functions (y below) that are themselves + // FIXME: Parmeters of pointer to functions (y below) that are themselves // parameters (p below) can have their ParentDC set to the translation-unit - // - thus we can not consistently check if the ParentDC of such a parameter + // - thus we can not consistently check if the ParentDC of such a parameter // is Dependent or/and a FunctionOrMethod. - // For e.g. this code, during Template argument deduction tries to + // For e.g. this code, during Template argument deduction tries to // find an instantiated decl for (T y) when the ParentDC for y is - // the translation unit. - // e.g. template <class T> void Foo(auto (*p)(T y) -> decltype(y())) {} + // the translation unit. + // e.g. template <class T> void Foo(auto (*p)(T y) -> decltype(y())) {} // float baz(float(*)()) { return 0.0; } // Foo(baz); // The better fix here is perhaps to ensure that a ParmVarDecl, by the time diff --git a/lib/Sema/SemaTemplateVariadic.cpp b/lib/Sema/SemaTemplateVariadic.cpp index fc16413342..6f9dddf5c0 100644 --- a/lib/Sema/SemaTemplateVariadic.cpp +++ b/lib/Sema/SemaTemplateVariadic.cpp @@ -29,7 +29,7 @@ using namespace clang; namespace { /// A class that collects unexpanded parameter packs. class CollectUnexpandedParameterPacksVisitor : - public RecursiveASTVisitor<CollectUnexpandedParameterPacksVisitor> + public RecursiveASTVisitor<CollectUnexpandedParameterPacksVisitor> { typedef RecursiveASTVisitor<CollectUnexpandedParameterPacksVisitor> inherited; @@ -58,7 +58,7 @@ namespace { if (T->getDepth() < DepthLimit) Unexpanded.push_back({T, Loc}); } - + public: explicit CollectUnexpandedParameterPacksVisitor( SmallVectorImpl<UnexpandedParameterPack> &Unexpanded) @@ -94,10 +94,10 @@ namespace { bool VisitDeclRefExpr(DeclRefExpr *E) { if (E->getDecl()->isParameterPack()) addUnexpanded(E->getDecl(), E->getLocation()); - + return true; } - + /// Record occurrences of template template parameter packs. bool TraverseTemplateName(TemplateName Template) { if (auto *TTP = dyn_cast_or_null<TemplateTemplateParmDecl>( @@ -105,7 +105,7 @@ namespace { if (TTP->isParameterPack()) addUnexpanded(TTP); } - + return inherited::TraverseTemplateName(Template); } @@ -131,7 +131,7 @@ namespace { /// Suppress traversal into statements and expressions that /// do not contain unexpanded parameter packs. - bool TraverseStmt(Stmt *S) { + bool TraverseStmt(Stmt *S) { Expr *E = dyn_cast_or_null<Expr>(S); if ((E && E->containsUnexpandedParameterPack()) || InLambda) return inherited::TraverseStmt(S); @@ -151,7 +151,7 @@ namespace { /// Suppress traversal into types with location information /// that do not contain unexpanded parameter packs. bool TraverseTypeLoc(TypeLoc TL) { - if ((!TL.getType().isNull() && + if ((!TL.getType().isNull() && TL.getType()->containsUnexpandedParameterPack()) || InLambda) return inherited::TraverseTypeLoc(TL); @@ -160,7 +160,7 @@ namespace { } /// Suppress traversal of parameter packs. - bool TraverseDecl(Decl *D) { + bool TraverseDecl(Decl *D) { // A function parameter pack is a pack expansion, so cannot contain // an unexpanded parameter pack. Likewise for a template parameter // pack that contains any references to other packs. @@ -215,7 +215,7 @@ namespace { bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc) { if (ArgLoc.getArgument().isPackExpansion()) return true; - + return inherited::TraverseTemplateArgumentLoc(ArgLoc); } @@ -335,7 +335,7 @@ Sema::DiagnoseUnexpandedParameterPacks(SourceLocation Loc, return false; } } - + SmallVector<SourceLocation, 4> Locations; SmallVector<IdentifierInfo *, 4> Names; llvm::SmallPtrSet<IdentifierInfo *, 4> NamesKnown; @@ -365,11 +365,11 @@ Sema::DiagnoseUnexpandedParameterPacks(SourceLocation Loc, return true; } -bool Sema::DiagnoseUnexpandedParameterPack(SourceLocation Loc, +bool Sema::DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC) { // C++0x [temp.variadic]p5: - // An appearance of a name of a parameter pack that is not expanded is + // An appearance of a name of a parameter pack that is not expanded is // ill-formed. if (!T->getType()->containsUnexpandedParameterPack()) return false; @@ -384,7 +384,7 @@ bool Sema::DiagnoseUnexpandedParameterPack(SourceLocation Loc, bool Sema::DiagnoseUnexpandedParameterPack(Expr *E, UnexpandedParameterPackContext UPPC) { // C++0x [temp.variadic]p5: - // An appearance of a name of a parameter pack that is not expanded is + // An appearance of a name of a parameter pack that is not expanded is // ill-formed. if (!E->containsUnexpandedParameterPack()) return false; @@ -398,9 +398,9 @@ bool Sema::DiagnoseUnexpandedParameterPack(Expr *E, bool Sema::DiagnoseUnexpandedParameterPack(const CXXScopeSpec &SS, UnexpandedParameterPackContext UPPC) { // C++0x [temp.variadic]p5: - // An appearance of a name of a parameter pack that is not expanded is + // An appearance of a name of a parameter pack that is not expanded is // ill-formed. - if (!SS.getScopeRep() || + if (!SS.getScopeRep() || !SS.getScopeRep()->containsUnexpandedParameterPack()) return false; @@ -415,7 +415,7 @@ bool Sema::DiagnoseUnexpandedParameterPack(const CXXScopeSpec &SS, bool Sema::DiagnoseUnexpandedParameterPack(const DeclarationNameInfo &NameInfo, UnexpandedParameterPackContext UPPC) { // C++0x [temp.variadic]p5: - // An appearance of a name of a parameter pack that is not expanded is + // An appearance of a name of a parameter pack that is not expanded is // ill-formed. switch (NameInfo.getName().getNameKind()) { case DeclarationName::Identifier: @@ -451,7 +451,7 @@ bool Sema::DiagnoseUnexpandedParameterPack(const DeclarationNameInfo &NameInfo, bool Sema::DiagnoseUnexpandedParameterPack(SourceLocation Loc, TemplateName Template, UnexpandedParameterPackContext UPPC) { - + if (Template.isNull() || !Template.containsUnexpandedParameterPack()) return false; @@ -464,10 +464,10 @@ bool Sema::DiagnoseUnexpandedParameterPack(SourceLocation Loc, bool Sema::DiagnoseUnexpandedParameterPack(TemplateArgumentLoc Arg, UnexpandedParameterPackContext UPPC) { - if (Arg.getArgument().isNull() || + if (Arg.getArgument().isNull() || !Arg.getArgument().containsUnexpandedParameterPack()) return false; - + SmallVector<UnexpandedParameterPack, 2> Unexpanded; CollectUnexpandedParameterPacksVisitor(Unexpanded) .TraverseTemplateArgumentLoc(Arg); @@ -489,12 +489,12 @@ void Sema::collectUnexpandedParameterPacks(TemplateArgumentLoc Arg, void Sema::collectUnexpandedParameterPacks(QualType T, SmallVectorImpl<UnexpandedParameterPack> &Unexpanded) { - CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseType(T); -} + CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseType(T); +} void Sema::collectUnexpandedParameterPacks(TypeLoc TL, SmallVectorImpl<UnexpandedParameterPack> &Unexpanded) { - CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseTypeLoc(TL); + CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseTypeLoc(TL); } void Sema::collectUnexpandedParameterPacks( @@ -512,7 +512,7 @@ void Sema::collectUnexpandedParameterPacks( } -ParsedTemplateArgument +ParsedTemplateArgument Sema::ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc) { if (Arg.isInvalid()) @@ -524,7 +524,7 @@ Sema::ActOnPackExpansion(const ParsedTemplateArgument &Arg, if (Result.isInvalid()) return ParsedTemplateArgument(); - return ParsedTemplateArgument(Arg.getKind(), Result.get().getAsOpaquePtr(), + return ParsedTemplateArgument(Arg.getKind(), Result.get().getAsOpaquePtr(), Arg.getLocation()); } @@ -532,11 +532,11 @@ Sema::ActOnPackExpansion(const ParsedTemplateArgument &Arg, ExprResult Result = ActOnPackExpansion(Arg.getAsExpr(), EllipsisLoc); if (Result.isInvalid()) return ParsedTemplateArgument(); - - return ParsedTemplateArgument(Arg.getKind(), Result.get(), + + return ParsedTemplateArgument(Arg.getKind(), Result.get(), Arg.getLocation()); } - + case ParsedTemplateArgument::Template: if (!Arg.getAsTemplate().get().containsUnexpandedParameterPack()) { SourceRange R(Arg.getLocation()); @@ -546,13 +546,13 @@ Sema::ActOnPackExpansion(const ParsedTemplateArgument &Arg, << R; return ParsedTemplateArgument(); } - + return Arg.getTemplatePackExpansion(EllipsisLoc); } llvm_unreachable("Unhandled template argument kind?"); } -TypeResult Sema::ActOnPackExpansion(ParsedType Type, +TypeResult Sema::ActOnPackExpansion(ParsedType Type, SourceLocation EllipsisLoc) { TypeSourceInfo *TSInfo; GetTypeFromParser(Type, &TSInfo); @@ -562,7 +562,7 @@ TypeResult Sema::ActOnPackExpansion(ParsedType Type, TypeSourceInfo *TSResult = CheckPackExpansion(TSInfo, EllipsisLoc, None); if (!TSResult) return true; - + return CreateParsedType(TSResult->getType(), TSResult); } @@ -570,7 +570,7 @@ TypeSourceInfo * Sema::CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, Optional<unsigned> NumExpansions) { // Create the pack expansion type and source-location information. - QualType Result = CheckPackExpansion(Pattern->getType(), + QualType Result = CheckPackExpansion(Pattern->getType(), Pattern->getTypeLoc().getSourceRange(), EllipsisLoc, NumExpansions); if (Result.isNull()) @@ -608,7 +608,7 @@ ExprResult Sema::CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc, Optional<unsigned> NumExpansions) { if (!Pattern) return ExprError(); - + // C++0x [temp.variadic]p5: // The pattern of a pack expansion shall name one or more // parameter packs that are not expanded by a nested pack @@ -618,7 +618,7 @@ ExprResult Sema::CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc, << Pattern->getSourceRange(); return ExprError(); } - + // Create the pack expansion expression and source-location information. return new (Context) PackExpansionExpr(Context.DependentTy, Pattern, EllipsisLoc, NumExpansions); @@ -643,7 +643,7 @@ bool Sema::CheckParameterPacksForExpansion( unsigned Depth = 0, Index = 0; IdentifierInfo *Name; bool IsFunctionParameterPack = false; - + if (const TemplateTypeParmType *TTP = i->first.dyn_cast<const TemplateTypeParmType *>()) { Depth = TTP->getDepth(); @@ -658,13 +658,13 @@ bool Sema::CheckParameterPacksForExpansion( Name = ND->getIdentifier(); } - + // Determine the size of this argument pack. - unsigned NewPackSize; + unsigned NewPackSize; if (IsFunctionParameterPack) { // Figure out whether we're instantiating to an argument pack or not. typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack; - + llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation = CurrentInstantiationScope->findInstantiationOf( i->first.get<NamedDecl *>()); @@ -678,25 +678,25 @@ bool Sema::CheckParameterPacksForExpansion( continue; } } else { - // If we don't have a template argument at this depth/index, then we - // cannot expand the pack expansion. Make a note of this, but we still + // If we don't have a template argument at this depth/index, then we + // cannot expand the pack expansion. Make a note of this, but we still // want to check any parameter packs we *do* have arguments for. if (Depth >= TemplateArgs.getNumLevels() || !TemplateArgs.hasTemplateArgument(Depth, Index)) { ShouldExpand = false; continue; } - + // Determine the size of the argument pack. NewPackSize = TemplateArgs(Depth, Index).pack_size(); } - + // C++0x [temp.arg.explicit]p9: - // Template argument deduction can extend the sequence of template + // Template argument deduction can extend the sequence of template // arguments corresponding to a template parameter pack, even when the // sequence contains explicitly specified template arguments. if (!IsFunctionParameterPack && CurrentInstantiationScope) { - if (NamedDecl *PartialPack + if (NamedDecl *PartialPack = CurrentInstantiationScope->getPartiallySubstitutedPack()){ unsigned PartialDepth, PartialIndex; std::tie(PartialDepth, PartialIndex) = getDepthAndIndex(PartialPack); @@ -709,9 +709,9 @@ bool Sema::CheckParameterPacksForExpansion( } } } - + if (!NumExpansions) { - // The is the first pack we've seen for which we have an argument. + // The is the first pack we've seen for which we have an argument. // Record it. NumExpansions = NewPackSize; FirstPack.first = Name; @@ -719,10 +719,10 @@ bool Sema::CheckParameterPacksForExpansion( HaveFirstPack = true; continue; } - + if (NewPackSize != *NumExpansions) { // C++0x [temp.variadic]p5: - // All of the parameter packs expanded by a pack expansion shall have + // All of the parameter packs expanded by a pack expansion shall have // the same number of arguments specified. if (HaveFirstPack) Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict) @@ -772,17 +772,17 @@ Optional<unsigned> Sema::getNumArgumentsInExpansion(QualType T, // Compute the depth and index for this parameter pack. unsigned Depth; unsigned Index; - + if (const TemplateTypeParmType *TTP = Unexpanded[I].first.dyn_cast<const TemplateTypeParmType *>()) { Depth = TTP->getDepth(); Index = TTP->getIndex(); - } else { + } else { NamedDecl *ND = Unexpanded[I].first.get<NamedDecl *>(); if (isa<ParmVarDecl>(ND)) { // Function parameter pack. typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack; - + llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation = CurrentInstantiationScope->findInstantiationOf( Unexpanded[I].first.get<NamedDecl *>()); @@ -804,13 +804,13 @@ Optional<unsigned> Sema::getNumArgumentsInExpansion(QualType T, // The pattern refers to an unknown template argument. We're not ready to // expand this pack yet. return None; - + // Determine the size of the argument pack. unsigned Size = TemplateArgs(Depth, Index).pack_size(); assert((!Result || *Result == Size) && "inconsistent pack sizes"); Result = Size; } - + return Result; } @@ -826,14 +826,14 @@ bool Sema::containsUnexpandedParameterPacks(Declarator &D) { return true; break; } - + case TST_typeofExpr: case TST_decltype: - if (DS.getRepAsExpr() && + if (DS.getRepAsExpr() && DS.getRepAsExpr()->containsUnexpandedParameterPack()) return true; break; - + case TST_unspecified: case TST_void: case TST_char: @@ -879,7 +879,7 @@ bool Sema::containsUnexpandedParameterPacks(Declarator &D) { case DeclaratorChunk::BlockPointer: // These declarator chunks cannot contain any parameter packs. break; - + case DeclaratorChunk::Array: if (Chunk.Arr.NumElts && Chunk.Arr.NumElts->containsUnexpandedParameterPack()) @@ -964,7 +964,7 @@ ExprResult Sema::ActOnSizeofParameterPackExpr(Scope *S, case LookupResult::Found: ParameterPack = R.getFoundDecl(); break; - + case LookupResult::NotFound: case LookupResult::NotFoundInCurrentInstantiation: if (TypoCorrection Corrected = diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index ac04cecaf7..a374dd8bc2 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -2851,7 +2851,7 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, case DeclaratorContext::ObjCParameterContext: case DeclaratorContext::ObjCResultContext: case DeclaratorContext::PrototypeContext: - Error = 0; + Error = 0; break; case DeclaratorContext::LambdaExprParameterContext: // In C++14, generic lambdas allow 'auto' in their parameters. @@ -2859,7 +2859,7 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, !Auto || Auto->getKeyword() != AutoTypeKeyword::Auto) Error = 16; else { - // If auto is mentioned in a lambda parameter context, convert it to a + // If auto is mentioned in a lambda parameter context, convert it to a // template parameter type. sema::LambdaScopeInfo *LSI = SemaRef.getCurLambda(); assert(LSI && "No LambdaScopeInfo on the stack!"); @@ -2877,7 +2877,7 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, TemplateParameterDepth, AutoParameterPosition, /*Identifier*/nullptr, false, IsParameterPack); LSI->AutoTemplateParams.push_back(CorrespondingTemplateParam); - // Replace the 'auto' in the function parameter with this invented + // Replace the 'auto' in the function parameter with this invented // template type parameter. // FIXME: Retain some type sugar to indicate that this was written // as 'auto'. @@ -4440,7 +4440,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, S.Diag(D.getIdentifierLoc(), diag::err_opencl_invalid_return) << T << 0 /*pointer hint*/; D.setInvalidType(true); - } + } } else if (!S.getLangOpts().HalfArgsAndReturns) { S.Diag(D.getIdentifierLoc(), diag::err_parameters_retval_cannot_have_fp16_type) << 1; @@ -5332,7 +5332,7 @@ namespace { TL.copy(OldTL.castAs<TemplateSpecializationTypeLoc>()); assert(TL.getRAngleLoc() == OldTL.castAs<TemplateSpecializationTypeLoc>().getRAngleLoc()); } - + } void VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) { assert(DS.getTypeSpecType() == DeclSpec::TST_typeofExpr); @@ -5627,11 +5627,11 @@ Sema::GetTypeSourceInfoForDeclarator(Declarator &D, QualType T, } for (unsigned i = 0, e = D.getNumTypeObjects(); i != e; ++i) { - + if (DependentAddressSpaceTypeLoc DASTL = CurrTL.getAs<DependentAddressSpaceTypeLoc>()) { fillDependentAddressSpaceTypeLoc(DASTL, D.getTypeObject(i).getAttrs()); - CurrTL = DASTL.getPointeeTypeLoc().getUnqualifiedLoc(); + CurrTL = DASTL.getPointeeTypeLoc().getUnqualifiedLoc(); } // An AtomicTypeLoc might be produced by an atomic qualifier in this @@ -5727,13 +5727,13 @@ ParsedType Sema::ActOnObjCInstanceType(SourceLocation Loc) { // Type Attribute Processing //===----------------------------------------------------------------------===// -/// BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an expression -/// is uninstantiated. If instantiated it will apply the appropriate address space +/// BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an expression +/// is uninstantiated. If instantiated it will apply the appropriate address space /// to the type. This function allows dependent template variables to be used in -/// conjunction with the address_space attribute +/// conjunction with the address_space attribute QualType Sema::BuildAddressSpaceAttr(QualType &T, Expr *AddrSpace, SourceLocation AttrLoc) { - if (!AddrSpace->isValueDependent()) { + if (!AddrSpace->isValueDependent()) { llvm::APSInt addrSpace(32); if (!AddrSpace->isIntegerConstantExpr(addrSpace, Context)) { @@ -5783,8 +5783,8 @@ QualType Sema::BuildAddressSpaceAttr(QualType &T, Expr *AddrSpace, } // A check with similar intentions as checking if a type already has an - // address space except for on a dependent types, basically if the - // current type is already a DependentAddressSpaceType then its already + // address space except for on a dependent types, basically if the + // current type is already a DependentAddressSpaceType then its already // lined up to have another address space on it and we can't have // multiple address spaces on the one pointer indirection if (T->getAs<DependentAddressSpaceType>()) { @@ -6116,7 +6116,7 @@ static bool handleObjCGCTypeAttr(TypeProcessingState &state, ParsedAttr &attr, attr.setInvalid(); return true; } - + // Check the attribute arguments. if (!attr.isArgIdent(0)) { S.Diag(attr.getLoc(), diag::err_attribute_argument_type) @@ -6327,7 +6327,7 @@ static bool handleMSPointerTypeQualifierAttr(TypeProcessingState &State, << "'__sptr'" << "'__uptr'"; return true; } - + Desugared = AT->getEquivalentType(); AT = dyn_cast<AttributedType>(Desugared); } @@ -6384,7 +6384,7 @@ bool Sema::checkNullabilityTypeSpecifier(QualType &type, << FixItHint::CreateRemoval(nullabilityLoc); break; - } + } // Conflicting nullability. Diag(nullabilityLoc, diag::err_nullability_conflicting) @@ -6430,7 +6430,7 @@ bool Sema::checkNullabilityTypeSpecifier(QualType &type, << DiagNullabilityKind(nullability, isContextSensitive) << type; return true; } - + // For the context-sensitive keywords/Objective-C property // attributes, require that the type be a single-level pointer. if (isContextSensitive) { @@ -6472,7 +6472,7 @@ bool Sema::checkObjCKindOfType(QualType &type, SourceLocation loc) { // Find out if it's an Objective-C object or object pointer type; const ObjCObjectPointerType *ptrType = type->getAs<ObjCObjectPointerType>(); - const ObjCObjectType *objType = ptrType ? ptrType->getObjectType() + const ObjCObjectType *objType = ptrType ? ptrType->getObjectType() : type->getAs<ObjCObjectType>(); // If not, we can't apply __kindof. @@ -6501,7 +6501,7 @@ bool Sema::checkObjCKindOfType(QualType &type, SourceLocation loc) { } // Build the attributed type to record where __kindof occurred. - type = Context.getAttributedType(AttributedType::attr_objc_kindof, + type = Context.getAttributedType(AttributedType::attr_objc_kindof, type, equivType); @@ -6601,7 +6601,7 @@ static bool distributeNullabilityTypeAttr(TypeProcessingState &state, } return false; - + // Don't walk through these. case DeclaratorChunk::Reference: case DeclaratorChunk::Pipe: @@ -6732,7 +6732,7 @@ static bool handleFunctionTypeAttr(TypeProcessingState &state, ParsedAttr &attr, if (S.CheckAttrTarget(attr) || S.CheckAttrNoArgs(attr)) return true; - // If this is not a function type, warning will be asserted by subject + // If this is not a function type, warning will be asserted by subject // check. if (!unwrapped.isFunctionType()) return true; @@ -7972,7 +7972,7 @@ static QualType getDecltypeForExpr(Sema &S, Expr *E) { } else if (auto *PE = dyn_cast<PredefinedExpr>(E)) { return PE->getType(); } - + // C++11 [expr.lambda.prim]p18: // Every occurrence of decltype((x)) where x is a possibly // parenthesized id-expression that names an entity of automatic diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index 3b39539910..de962d775d 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -1815,7 +1815,7 @@ public: OMPClause *RebuildOMPNumTeamsClause(Expr *NumTeams, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc) { - return getSema().ActOnOpenMPNumTeamsClause(NumTeams, StartLoc, LParenLoc, + return getSema().ActOnOpenMPNumTeamsClause(NumTeams, StartLoc, LParenLoc, EndLoc); } @@ -3033,7 +3033,7 @@ public: Sel, Method, LBracLoc, SelectorLocs, RBracLoc, Args); - + } /// Build a new Objective-C ivar reference expression. @@ -6356,7 +6356,7 @@ TreeTransform<Derived>::TransformObjCObjectType(TypeLocBuilder &TLB, TypeLocBuilder TypeArgBuilder; TypeArgBuilder.reserve(PatternLoc.getFullDataSize()); - QualType NewPatternType = getDerived().TransformType(TypeArgBuilder, + QualType NewPatternType = getDerived().TransformType(TypeArgBuilder, PatternLoc); if (NewPatternType.isNull()) return QualType(); @@ -10963,7 +10963,7 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) { TypeSourceInfo *NewCallOpTSI = nullptr; { TypeSourceInfo *OldCallOpTSI = E->getCallOperator()->getTypeSourceInfo(); - FunctionProtoTypeLoc OldCallOpFPTL = + FunctionProtoTypeLoc OldCallOpFPTL = OldCallOpTSI->getTypeLoc().getAs<FunctionProtoTypeLoc>(); TypeLocBuilder NewCallOpTLBuilder; @@ -11059,7 +11059,7 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) { // Rebuild init-captures, including the implied field declaration. if (E->isInitCapture(C)) { - InitCaptureInfoTy InitExprTypePair = + InitCaptureInfoTy InitExprTypePair = InitCaptureExprsAndTypes[C - E->capture_begin()]; ExprResult Init = InitExprTypePair.first; QualType InitQualType = InitExprTypePair.second; diff --git a/lib/Sema/TypeLocBuilder.h b/lib/Sema/TypeLocBuilder.h index a088fe9de6..536ea1c07f 100644 --- a/lib/Sema/TypeLocBuilder.h +++ b/lib/Sema/TypeLocBuilder.h @@ -37,7 +37,7 @@ class TypeLocBuilder { /// The last type pushed on this builder. QualType LastTy; #endif - + /// The inline buffer. enum { BufferMaxAlignment = alignof(void *) }; llvm::AlignedCharArray<BufferMaxAlignment, InlineCapacity> InlineBuffer; @@ -81,7 +81,7 @@ class TypeLocBuilder { #endif Index = Capacity; NumBytesAtAlign4 = NumBytesAtAlign8 = 0; - } + } /// Tell the TypeLocBuilder that the type it is storing has been /// modified in some safe way that doesn't affect type-location information. @@ -90,7 +90,7 @@ class TypeLocBuilder { LastTy = T; #endif } - + /// Pushes space for a new TypeLoc of the given type. Invalidates /// any TypeLocs previously retrieved from this builder. template <class TyLocType> TyLocType push(QualType T) { @@ -112,13 +112,13 @@ class TypeLocBuilder { return DI; } - /// Copies the type-location information to the given AST context and + /// Copies the type-location information to the given AST context and /// returns a \c TypeLoc referring into the AST context. TypeLoc getTypeLocInContext(ASTContext &Context, QualType T) { #ifndef NDEBUG assert(T == LastTy && "type doesn't match last type pushed!"); #endif - + size_t FullDataSize = Capacity - Index; void *Mem = Context.Allocate(FullDataSize); memcpy(Mem, &Buffer[Index], FullDataSize); @@ -135,7 +135,7 @@ private: /// Retrieve a temporary TypeLoc that refers into this \c TypeLocBuilder /// object. /// - /// The resulting \c TypeLoc should only be used so long as the + /// The resulting \c TypeLoc should only be used so long as the /// \c TypeLocBuilder is active and has not had more type information /// pushed into it. TypeLoc getTemporaryTypeLoc(QualType T) { |