From 912fb122714c819d726e58d9fec11af8e6b54f9e Mon Sep 17 00:00:00 2001 From: adeel10x Date: Sun, 10 Dec 2023 20:57:12 +0500 Subject: [PATCH 1/6] [RISCV][Clang] Added code to generate clang error if immediate operand of the following builtins is out of range: - __builtin_riscv_cv_simd_extract_h - __builtin_riscv_cv_simd_extract_b - __builtin_riscv_cv_simd_extractu_h - __builtin_riscv_cv_simd_extractu_b - __builtin_riscv_cv_simd_insert_h - __builtin_riscv_cv_simd_insert_b --- clang/include/clang/Sema/Sema.h | 3 ++- clang/lib/Sema/SemaChecking.cpp | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 92c89e757c9d..750849c44cdc 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -13300,7 +13300,8 @@ class Sema final { bool CheckRISCVLMUL(CallExpr *TheCall, unsigned ArgNum); bool CheckRISCVBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, CallExpr *TheCall); - + bool CheckRISCVCOREVBuiltinFunctionCall(unsigned BuiltinID, + CallExpr *TheCall); bool SemaBuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall); bool SemaBuiltinVAStartARMMicrosoft(CallExpr *Call); bool SemaBuiltinUnorderedCompare(CallExpr *TheCall); diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 4c60c38fd696..879a302811a5 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -2019,7 +2019,8 @@ bool Sema::CheckTSBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, return CheckAMDGCNBuiltinFunctionCall(BuiltinID, TheCall); case llvm::Triple::riscv32: case llvm::Triple::riscv64: - return CheckRISCVBuiltinFunctionCall(TI, BuiltinID, TheCall); + return CheckRISCVBuiltinFunctionCall(TI, BuiltinID, TheCall) || + CheckRISCVCOREVBuiltinFunctionCall(BuiltinID, TheCall); } } @@ -4461,6 +4462,23 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo &TI, return false; } +bool Sema::CheckRISCVCOREVBuiltinFunctionCall(unsigned BuiltinID, + CallExpr *TheCall) { + // For intrinsics which take an immediate value as part of the instruction, + // range check them here. + switch (BuiltinID) { + default: return false; + case RISCVCOREV::BI__builtin_riscv_cv_simd_extract_h: + case RISCVCOREV::BI__builtin_riscv_cv_simd_extract_b: + case RISCVCOREV::BI__builtin_riscv_cv_simd_extractu_h: + case RISCVCOREV::BI__builtin_riscv_cv_simd_extractu_b: + return SemaBuiltinConstantArgRange(TheCall, 1, 0, 63); + case RISCVCOREV::BI__builtin_riscv_cv_simd_insert_h: + case RISCVCOREV::BI__builtin_riscv_cv_simd_insert_b: + return SemaBuiltinConstantArgRange(TheCall, 2, 0, 63); + } +} + bool Sema::CheckSystemZBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { if (BuiltinID == SystemZ::BI__builtin_tabort) { From 1c372bceb0b4438492a3c95e72a31af23b261540 Mon Sep 17 00:00:00 2001 From: adeel10x Date: Sun, 10 Dec 2023 21:05:00 +0500 Subject: [PATCH 2/6] clang formatted --- clang/include/clang/Sema/Sema.h | 2701 +++++++++++++------------------ clang/lib/Sema/SemaChecking.cpp | 2577 ++++++++++++++++------------- 2 files changed, 2577 insertions(+), 2701 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 750849c44cdc..7ce661f288b4 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -73,168 +73,168 @@ #include namespace llvm { - class APSInt; - template class DenseSet; - class SmallBitVector; - struct InlineAsmIdentifierInfo; -} +class APSInt; +template class DenseSet; +class SmallBitVector; +struct InlineAsmIdentifierInfo; +} // namespace llvm namespace clang { - class ADLResult; - class ASTConsumer; - class ASTContext; - class ASTMutationListener; - class ASTReader; - class ASTWriter; - class ArrayType; - class ParsedAttr; - class BindingDecl; - class BlockDecl; - class CapturedDecl; - class CXXBasePath; - class CXXBasePaths; - class CXXBindTemporaryExpr; - typedef SmallVector CXXCastPath; - class CXXConstructorDecl; - class CXXConversionDecl; - class CXXDeleteExpr; - class CXXDestructorDecl; - class CXXFieldCollector; - class CXXMemberCallExpr; - class CXXMethodDecl; - class CXXScopeSpec; - class CXXTemporary; - class CXXTryStmt; - class CallExpr; - class ClassTemplateDecl; - class ClassTemplatePartialSpecializationDecl; - class ClassTemplateSpecializationDecl; - class VarTemplatePartialSpecializationDecl; - class CodeCompleteConsumer; - class CodeCompletionAllocator; - class CodeCompletionTUInfo; - class CodeCompletionResult; - class CoroutineBodyStmt; - class Decl; - class DeclAccessPair; - class DeclContext; - class DeclRefExpr; - class DeclaratorDecl; - class DeducedTemplateArgument; - class DependentDiagnostic; - class DesignatedInitExpr; - class Designation; - class EnableIfAttr; - class EnumConstantDecl; - class Expr; - class ExtVectorType; - class FormatAttr; - class FriendDecl; - class FunctionDecl; - class FunctionProtoType; - class FunctionTemplateDecl; - class ImplicitConversionSequence; - typedef MutableArrayRef ConversionSequenceList; - class InitListExpr; - class InitializationKind; - class InitializationSequence; - class InitializedEntity; - class IntegerLiteral; - class LabelStmt; - class LambdaExpr; - class LangOptions; - class LocalInstantiationScope; - class LookupResult; - class MacroInfo; - typedef ArrayRef> ModuleIdPath; - class ModuleLoader; - class MultiLevelTemplateArgumentList; - class NamedDecl; - class ObjCCategoryDecl; - class ObjCCategoryImplDecl; - class ObjCCompatibleAliasDecl; - class ObjCContainerDecl; - class ObjCImplDecl; - class ObjCImplementationDecl; - class ObjCInterfaceDecl; - class ObjCIvarDecl; - template class ObjCList; - class ObjCMessageExpr; - class ObjCMethodDecl; - class ObjCPropertyDecl; - class ObjCProtocolDecl; - class OMPThreadPrivateDecl; - class OMPRequiresDecl; - class OMPDeclareReductionDecl; - class OMPDeclareSimdDecl; - class OMPClause; - struct OMPVarListLocTy; - struct OverloadCandidate; - enum class OverloadCandidateParamOrder : char; - enum OverloadCandidateRewriteKind : unsigned; - class OverloadCandidateSet; - class OverloadExpr; - class ParenListExpr; - class ParmVarDecl; - class Preprocessor; - class PseudoDestructorTypeStorage; - class PseudoObjectExpr; - class QualType; - class StandardConversionSequence; - class Stmt; - class StringLiteral; - class SwitchStmt; - class TemplateArgument; - class TemplateArgumentList; - class TemplateArgumentLoc; - class TemplateDecl; - class TemplateInstantiationCallback; - class TemplateParameterList; - class TemplatePartialOrderingContext; - class TemplateTemplateParmDecl; - class Token; - class TypeAliasDecl; - class TypedefDecl; - class TypedefNameDecl; - class TypeLoc; - class TypoCorrectionConsumer; - class UnqualifiedId; - class UnresolvedLookupExpr; - class UnresolvedMemberExpr; - class UnresolvedSetImpl; - class UnresolvedSetIterator; - class UsingDecl; - class UsingShadowDecl; - class ValueDecl; - class VarDecl; - class VarTemplateSpecializationDecl; - class VisibilityAttr; - class VisibleDeclConsumer; - class IndirectFieldDecl; - struct DeductionFailureInfo; - class TemplateSpecCandidateSet; +class ADLResult; +class ASTConsumer; +class ASTContext; +class ASTMutationListener; +class ASTReader; +class ASTWriter; +class ArrayType; +class ParsedAttr; +class BindingDecl; +class BlockDecl; +class CapturedDecl; +class CXXBasePath; +class CXXBasePaths; +class CXXBindTemporaryExpr; +typedef SmallVector CXXCastPath; +class CXXConstructorDecl; +class CXXConversionDecl; +class CXXDeleteExpr; +class CXXDestructorDecl; +class CXXFieldCollector; +class CXXMemberCallExpr; +class CXXMethodDecl; +class CXXScopeSpec; +class CXXTemporary; +class CXXTryStmt; +class CallExpr; +class ClassTemplateDecl; +class ClassTemplatePartialSpecializationDecl; +class ClassTemplateSpecializationDecl; +class VarTemplatePartialSpecializationDecl; +class CodeCompleteConsumer; +class CodeCompletionAllocator; +class CodeCompletionTUInfo; +class CodeCompletionResult; +class CoroutineBodyStmt; +class Decl; +class DeclAccessPair; +class DeclContext; +class DeclRefExpr; +class DeclaratorDecl; +class DeducedTemplateArgument; +class DependentDiagnostic; +class DesignatedInitExpr; +class Designation; +class EnableIfAttr; +class EnumConstantDecl; +class Expr; +class ExtVectorType; +class FormatAttr; +class FriendDecl; +class FunctionDecl; +class FunctionProtoType; +class FunctionTemplateDecl; +class ImplicitConversionSequence; +typedef MutableArrayRef ConversionSequenceList; +class InitListExpr; +class InitializationKind; +class InitializationSequence; +class InitializedEntity; +class IntegerLiteral; +class LabelStmt; +class LambdaExpr; +class LangOptions; +class LocalInstantiationScope; +class LookupResult; +class MacroInfo; +typedef ArrayRef> ModuleIdPath; +class ModuleLoader; +class MultiLevelTemplateArgumentList; +class NamedDecl; +class ObjCCategoryDecl; +class ObjCCategoryImplDecl; +class ObjCCompatibleAliasDecl; +class ObjCContainerDecl; +class ObjCImplDecl; +class ObjCImplementationDecl; +class ObjCInterfaceDecl; +class ObjCIvarDecl; +template class ObjCList; +class ObjCMessageExpr; +class ObjCMethodDecl; +class ObjCPropertyDecl; +class ObjCProtocolDecl; +class OMPThreadPrivateDecl; +class OMPRequiresDecl; +class OMPDeclareReductionDecl; +class OMPDeclareSimdDecl; +class OMPClause; +struct OMPVarListLocTy; +struct OverloadCandidate; +enum class OverloadCandidateParamOrder : char; +enum OverloadCandidateRewriteKind : unsigned; +class OverloadCandidateSet; +class OverloadExpr; +class ParenListExpr; +class ParmVarDecl; +class Preprocessor; +class PseudoDestructorTypeStorage; +class PseudoObjectExpr; +class QualType; +class StandardConversionSequence; +class Stmt; +class StringLiteral; +class SwitchStmt; +class TemplateArgument; +class TemplateArgumentList; +class TemplateArgumentLoc; +class TemplateDecl; +class TemplateInstantiationCallback; +class TemplateParameterList; +class TemplatePartialOrderingContext; +class TemplateTemplateParmDecl; +class Token; +class TypeAliasDecl; +class TypedefDecl; +class TypedefNameDecl; +class TypeLoc; +class TypoCorrectionConsumer; +class UnqualifiedId; +class UnresolvedLookupExpr; +class UnresolvedMemberExpr; +class UnresolvedSetImpl; +class UnresolvedSetIterator; +class UsingDecl; +class UsingShadowDecl; +class ValueDecl; +class VarDecl; +class VarTemplateSpecializationDecl; +class VisibilityAttr; +class VisibleDeclConsumer; +class IndirectFieldDecl; +struct DeductionFailureInfo; +class TemplateSpecCandidateSet; namespace sema { - class AccessedEntity; - class BlockScopeInfo; - class Capture; - class CapturedRegionScopeInfo; - class CapturingScopeInfo; - class CompoundScopeInfo; - class DelayedDiagnostic; - class DelayedDiagnosticPool; - class FunctionScopeInfo; - class LambdaScopeInfo; - class PossiblyUnreachableDiag; - class RISCVIntrinsicManager; - class SemaPPCallbacks; - class TemplateDeductionInfo; -} +class AccessedEntity; +class BlockScopeInfo; +class Capture; +class CapturedRegionScopeInfo; +class CapturingScopeInfo; +class CompoundScopeInfo; +class DelayedDiagnostic; +class DelayedDiagnosticPool; +class FunctionScopeInfo; +class LambdaScopeInfo; +class PossiblyUnreachableDiag; +class RISCVIntrinsicManager; +class SemaPPCallbacks; +class TemplateDeductionInfo; +} // namespace sema namespace threadSafety { - class BeforeSet; - void threadSafetyCleanup(BeforeSet* Cache); -} +class BeforeSet; +void threadSafetyCleanup(BeforeSet *Cache); +} // namespace threadSafety // FIXME: No way to easily map from TemplateTypeParmTypes to // TemplateTypeParmDecls, so we have this horrible PointerUnion. @@ -359,7 +359,7 @@ class Sema final { Sema(const Sema &) = delete; void operator=(const Sema &) = delete; - ///Source of additional semantic information. + /// Source of additional semantic information. IntrusiveRefCntPtr ExternalSource; static bool mightHaveNonExternalLinkage(const DeclaratorDecl *FD); @@ -370,7 +370,7 @@ class Sema final { bool shouldLinkPossiblyHiddenDecl(const NamedDecl *Old, const NamedDecl *New) { if (isVisible(Old)) - return true; + return true; // See comment in below overload for why it's safe to compute the linkage // of the new declaration here. if (New->isExternallyDeclarable()) { @@ -435,7 +435,7 @@ class Sema final { MSPointerToMemberRepresentationMethod; /// Stack of active SEH __finally scopes. Can be empty. - SmallVector CurrentSEHFinally; + SmallVector CurrentSEHFinally; /// Source location for newly created implicit MSInheritanceAttrs SourceLocation ImplicitMSInheritanceAttrLoc; @@ -448,39 +448,36 @@ class Sema final { /// pragma clang section kind enum PragmaClangSectionKind { - PCSK_Invalid = 0, - PCSK_BSS = 1, - PCSK_Data = 2, - PCSK_Rodata = 3, - PCSK_Text = 4, - PCSK_Relro = 5 - }; - - enum PragmaClangSectionAction { - PCSA_Set = 0, - PCSA_Clear = 1 + PCSK_Invalid = 0, + PCSK_BSS = 1, + PCSK_Data = 2, + PCSK_Rodata = 3, + PCSK_Text = 4, + PCSK_Relro = 5 }; + enum PragmaClangSectionAction { PCSA_Set = 0, PCSA_Clear = 1 }; + struct PragmaClangSection { std::string SectionName; bool Valid = false; SourceLocation PragmaLocation; }; - PragmaClangSection PragmaClangBSSSection; - PragmaClangSection PragmaClangDataSection; - PragmaClangSection PragmaClangRodataSection; - PragmaClangSection PragmaClangRelroSection; - PragmaClangSection PragmaClangTextSection; + PragmaClangSection PragmaClangBSSSection; + PragmaClangSection PragmaClangDataSection; + PragmaClangSection PragmaClangRodataSection; + PragmaClangSection PragmaClangRelroSection; + PragmaClangSection PragmaClangTextSection; enum PragmaMsStackAction { - PSK_Reset = 0x0, // #pragma () - PSK_Set = 0x1, // #pragma (value) - PSK_Push = 0x2, // #pragma (push[, id]) - PSK_Pop = 0x4, // #pragma (pop[, id]) - PSK_Show = 0x8, // #pragma (show) -- only for "pack"! - PSK_Push_Set = PSK_Push | PSK_Set, // #pragma (push[, id], value) - PSK_Pop_Set = PSK_Pop | PSK_Set, // #pragma (pop[, id], value) + PSK_Reset = 0x0, // #pragma () + PSK_Set = 0x1, // #pragma (value) + PSK_Push = 0x2, // #pragma (push[, id]) + PSK_Pop = 0x4, // #pragma (pop[, id]) + PSK_Show = 0x8, // #pragma (show) -- only for "pack"! + PSK_Push_Set = PSK_Push | PSK_Set, // #pragma (push[, id], value) + PSK_Pop_Set = PSK_Pop | PSK_Set, // #pragma (pop[, id], value) }; // #pragma pack and align. @@ -585,8 +582,7 @@ class Sema final { static constexpr uint32_t PackNumMask{0x0000'01F0}; }; - template - struct PragmaStack { + template struct PragmaStack { struct Slot { llvm::StringRef StackSlotLabel; ValueType Value; @@ -802,7 +798,7 @@ class Sema final { /// context. unsigned FunctionScopesStart = 0; - ArrayRef getFunctionScopes() const { + ArrayRef getFunctionScopes() const { return llvm::makeArrayRef(FunctionScopes.begin() + FunctionScopesStart, FunctionScopes.end()); } @@ -826,7 +822,7 @@ class Sema final { typedef LazyVector - ExtVectorDeclsType; + ExtVectorDeclsType; /// ExtVectorDecls - This is a list all the extended vector types. This allows /// us to associate a raw vector type with one of the ext_vector type names. @@ -854,7 +850,7 @@ class Sema final { typedef llvm::SmallVector DeleteLocs; llvm::MapVector DeleteExprs; - typedef llvm::SmallPtrSet RecordDeclSetTy; + typedef llvm::SmallPtrSet RecordDeclSetTy; /// PureVirtualClassDiagSet - a set of class declarations which we have /// emitted a list of pure virtual functions. Used to prevent emitting the @@ -863,14 +859,14 @@ class Sema final { /// ParsingInitForAutoVars - a set of declarations with auto types for which /// we are currently parsing the initializer. - llvm::SmallPtrSet ParsingInitForAutoVars; + llvm::SmallPtrSet ParsingInitForAutoVars; /// Look for a locally scoped extern "C" declaration by the given name. NamedDecl *findLocallyScopedExternCDecl(DeclarationName Name); typedef LazyVector - TentativeDefinitionsType; + TentativeDefinitionsType; /// All the tentative definitions encountered in the TU. TentativeDefinitionsType TentativeDefinitions; @@ -880,7 +876,7 @@ class Sema final { typedef LazyVector - UnusedFileScopedDeclsType; + UnusedFileScopedDeclsType; /// The set of file scoped decls seen so far that have not been used /// and must warn if not used. Only contains the first declaration. @@ -888,7 +884,7 @@ class Sema final { typedef LazyVector - DelegatingCtorDeclsType; + DelegatingCtorDeclsType; /// All the delegating constructors seen so far in the file, used for /// cycle detection at the end of the TU. @@ -897,16 +893,16 @@ class Sema final { /// All the overriding functions seen during a class definition /// that had their exception spec checks delayed, plus the overridden /// function. - SmallVector, 2> - DelayedOverridingExceptionSpecChecks; + SmallVector, 2> + DelayedOverridingExceptionSpecChecks; /// All the function redeclarations seen during a class definition that had /// their exception spec checks delayed, plus the prior declaration they /// should be checked against. Except during error recovery, the new decl /// should always be a friend declaration, as that's the only valid way to /// redeclare a special member before its class is complete. - SmallVector, 2> - DelayedEquivalentExceptionSpecChecks; + SmallVector, 2> + DelayedEquivalentExceptionSpecChecks; typedef llvm::MapVector> @@ -921,8 +917,7 @@ class Sema final { void *OpaqueParser; void SetLateTemplateParser(LateTemplateParserCB *LTP, - LateTemplateParserCleanupCB *LTPCleanup, - void *P) { + LateTemplateParserCleanupCB *LTPCleanup, void *P) { LateTemplateParser = LTP; LateTemplateParserCleanup = LTPCleanup; OpaqueParser = P; @@ -954,9 +949,7 @@ class Sema final { bool shouldDelayDiagnostics() { return CurPool != nullptr; } /// Returns the current delayed-diagnostics pool. - sema::DelayedDiagnosticPool *getCurrentPool() const { - return CurPool; - } + sema::DelayedDiagnosticPool *getCurrentPool() const { return CurPool; } /// Enter a new scope. Access and deprecation diagnostics will be /// collected in this pool. @@ -1002,12 +995,11 @@ class Sema final { public: ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext = true) - : S(S), SavedContext(S.CurContext), - SavedContextState(S.DelayedDiagnostics.pushUndelayed()), - SavedCXXThisTypeOverride(S.CXXThisTypeOverride), - SavedFunctionScopesStart(S.FunctionScopesStart), - SavedInventedParameterInfosStart(S.InventedParameterInfosStart) - { + : S(S), SavedContext(S.CurContext), + SavedContextState(S.DelayedDiagnostics.pushUndelayed()), + SavedCXXThisTypeOverride(S.CXXThisTypeOverride), + SavedFunctionScopesStart(S.FunctionScopesStart), + SavedInventedParameterInfosStart(S.InventedParameterInfosStart) { assert(ContextToPush && "pushing null context"); S.CurContext = ContextToPush; if (NewThisContext) @@ -1018,7 +1010,8 @@ class Sema final { } void pop() { - if (!SavedContext) return; + if (!SavedContext) + return; S.CurContext = SavedContext; S.DelayedDiagnostics.popUndelayed(SavedContextState); S.CXXThisTypeOverride = SavedCXXThisTypeOverride; @@ -1027,9 +1020,7 @@ class Sema final { SavedContext = nullptr; } - ~ContextRAII() { - pop(); - } + ~ContextRAII() { pop(); } }; /// Whether the AST is currently being rebuilt to correct immediate @@ -1106,8 +1097,7 @@ class Sema final { /// \#pragma redefine_extname before declared. Used in Solaris system headers /// to define functions that occur in multiple standards to call the version /// in the currently selected standard. - llvm::DenseMap ExtnameUndeclaredIdentifiers; - + llvm::DenseMap ExtnameUndeclaredIdentifiers; /// Load weak undeclared identifiers from the external source. void LoadExternalWeakUndeclaredIdentifiers(); @@ -1117,7 +1107,7 @@ class Sema final { /// I couldn't figure out a clean way to generate these in-line, so /// we store them here and handle separately -- which is a hack. /// It would be best to refactor this. - SmallVector WeakTopLevelDecl; + SmallVector WeakTopLevelDecl; IdentifierResolver IdResolver; @@ -1310,10 +1300,11 @@ class Sema final { /// Expressions appearing as the LHS of a volatile assignment in this /// context. We produce a warning for these when popping the context if /// they are not discarded-value expressions nor unevaluated operands. - SmallVector VolatileAssignmentLHSs; + SmallVector VolatileAssignmentLHSs; /// Set of candidates for starting an immediate invocation. - llvm::SmallVector ImmediateInvocationCandidates; + llvm::SmallVector + ImmediateInvocationCandidates; /// Set of DeclRefExprs referencing a consteval function when used in a /// context not already known to be immediately invoked. @@ -1322,7 +1313,9 @@ class Sema final { /// \brief Describes whether we are in an expression constext which we have /// to handle differently. enum ExpressionKind { - EK_Decltype, EK_TemplateArgument, EK_Other + EK_Decltype, + EK_TemplateArgument, + EK_Other } ExprContext; // A context can be nested in both a discarded statement context and @@ -1388,7 +1381,6 @@ class Sema final { std::tuple getCurrentMangleNumberContext(const DeclContext *DC); - /// SpecialMemberOverloadResult - The overloading result for a special member /// function. /// @@ -1396,11 +1388,7 @@ class Sema final { /// integer are used to determine whether overload resolution succeeded. class SpecialMemberOverloadResult { public: - enum Kind { - NoMemberOrDeleted, - Ambiguous, - Success - }; + enum Kind { NoMemberOrDeleted, Ambiguous, Success }; private: llvm::PointerIntPair Pair; @@ -1417,13 +1405,11 @@ class Sema final { void setKind(Kind K) { Pair.setInt(K); } }; - class SpecialMemberOverloadResultEntry - : public llvm::FastFoldingSetNode, - public SpecialMemberOverloadResult { + class SpecialMemberOverloadResultEntry : public llvm::FastFoldingSetNode, + public SpecialMemberOverloadResult { public: SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID) - : FastFoldingSetNode(ID) - {} + : FastFoldingSetNode(ID) {} }; /// A cache of special member function overload resolution results @@ -1432,7 +1418,7 @@ class Sema final { /// A cache of the flags available in enumerations with the flag_bits /// attribute. - mutable llvm::DenseMap FlagBitsCache; + mutable llvm::DenseMap FlagBitsCache; /// The kind of translation unit we are processing. /// @@ -1449,7 +1435,7 @@ class Sema final { unsigned NumSFINAEErrors; typedef llvm::DenseMap> - UnparsedDefaultArgInstantiationsMap; + UnparsedDefaultArgInstantiationsMap; /// A mapping from parameters with unparsed default arguments to the /// set of instantiations of each parameter. @@ -1475,7 +1461,7 @@ class Sema final { /// Obtain a sorted list of functions that are undefined but ODR-used. void getUndefinedButUsed( - SmallVectorImpl > &Undefined); + SmallVectorImpl> &Undefined); /// Retrieves list of suspicious delete-expressions that will be checked at /// the end of translation unit. @@ -1584,7 +1570,7 @@ class Sema final { FPOptionsOverride getOverrides() { return OldOverrides; } private: - Sema& S; + Sema &S; FPOptions OldFPFeaturesState; FPOptionsOverride OldOverrides; LangOptions::FPEvalMethodKind OldEvalMethod; @@ -1629,7 +1615,7 @@ class Sema final { const LangOptions &getLangOpts() const { return LangOpts; } OpenCLOptions &getOpenCLOptions() { return OpenCLFeatures; } - FPOptions &getCurFPFeatures() { return CurFPFeatures; } + FPOptions &getCurFPFeatures() { return CurFPFeatures; } DiagnosticsEngine &getDiagnostics() const { return Diags; } SourceManager &getSourceManager() const { return SourceMgr; } @@ -1643,8 +1629,8 @@ class Sema final { StringRef Platform); DarwinSDKInfo *getDarwinSDKInfoForAvailabilityChecking(); - ///Registers an external source. If an external source already exists, - /// creates a multiplex external source and appends to it. + /// Registers an external source. If an external source already exists, + /// creates a multiplex external source and appends to it. /// ///\param[in] E - A non-null external sema source. /// @@ -1691,7 +1677,8 @@ class Sema final { ~ImmediateDiagBuilder() { // If we aren't active, there is nothing to do. - if (!isActive()) return; + if (!isActive()) + return; // Otherwise, we need to emit the diagnostic. First clear the diagnostic // builder itself so it won't emit the diagnostic in its own destructor. @@ -1882,8 +1869,8 @@ class Sema final { bool findMacroSpelling(SourceLocation &loc, StringRef name); /// Get a string to suggest for zero-initialization of a type. - std::string - getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const; + std::string getFixItZeroInitializerForType(QualType T, + SourceLocation Loc) const; std::string getFixItZeroLiteralForType(QualType T, SourceLocation Loc) const; /// Calls \c Lexer::getLocForEndOfToken() @@ -1899,12 +1886,12 @@ class Sema final { void emitAndClearUnusedLocalTypedefWarnings(); - private: - /// Function or variable declarations to be checked for whether the deferred - /// diagnostics should be emitted. - llvm::SmallSetVector DeclsToCheckForDeferredDiags; +private: + /// Function or variable declarations to be checked for whether the deferred + /// diagnostics should be emitted. + llvm::SmallSetVector DeclsToCheckForDeferredDiags; - public: +public: // Emit all deferred diagnostics. void emitDeferredDiags(); @@ -2024,13 +2011,13 @@ class Sema final { const DeclSpec *DS = nullptr); QualType BuildQualifiedType(QualType T, SourceLocation Loc, unsigned CVRA, const DeclSpec *DS = nullptr); - QualType BuildPointerType(QualType T, - SourceLocation Loc, DeclarationName Entity); - QualType BuildReferenceType(QualType T, bool LValueRef, - SourceLocation Loc, DeclarationName Entity); + QualType BuildPointerType(QualType T, SourceLocation Loc, + DeclarationName Entity); + QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, + DeclarationName Entity); QualType BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, - Expr *ArraySize, unsigned Quals, - SourceRange Brackets, DeclarationName Entity); + Expr *ArraySize, unsigned Quals, SourceRange Brackets, + DeclarationName Entity); QualType BuildVectorType(QualType T, Expr *VecSize, SourceLocation AttrLoc); QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc); @@ -2075,22 +2062,18 @@ class Sema final { /// \returns A suitable function type, if there are no errors. The /// unqualified type will always be a FunctionProtoType. /// Otherwise, returns a NULL type. - QualType BuildFunctionType(QualType T, - MutableArrayRef ParamTypes, + QualType BuildFunctionType(QualType T, MutableArrayRef ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI); QualType BuildMemberPointerType(QualType T, QualType Class, - SourceLocation Loc, - DeclarationName Entity); - QualType BuildBlockPointerType(QualType T, - SourceLocation Loc, DeclarationName Entity); + SourceLocation Loc, DeclarationName Entity); + QualType BuildBlockPointerType(QualType T, SourceLocation Loc, + DeclarationName Entity); QualType BuildParenType(QualType T); QualType BuildAtomicType(QualType T, SourceLocation Loc); - QualType BuildReadPipeType(QualType T, - SourceLocation Loc); - QualType BuildWritePipeType(QualType T, - SourceLocation Loc); + QualType BuildReadPipeType(QualType T, SourceLocation Loc); + QualType BuildWritePipeType(QualType T, SourceLocation Loc); QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc); TypeSourceInfo *GetTypeForDeclarator(Declarator &D, Scope *S); @@ -2114,22 +2097,22 @@ class Sema final { bool CheckSpecifiedExceptionType(QualType &T, SourceRange Range); bool CheckDistantExceptionSpec(QualType T); bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New); - bool CheckEquivalentExceptionSpec( - const FunctionProtoType *Old, SourceLocation OldLoc, - const FunctionProtoType *New, SourceLocation NewLoc); - bool CheckEquivalentExceptionSpec( - const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID, - const FunctionProtoType *Old, SourceLocation OldLoc, - const FunctionProtoType *New, SourceLocation NewLoc); + bool CheckEquivalentExceptionSpec(const FunctionProtoType *Old, + SourceLocation OldLoc, + const FunctionProtoType *New, + SourceLocation NewLoc); + bool CheckEquivalentExceptionSpec(const PartialDiagnostic &DiagID, + const PartialDiagnostic &NoteID, + const FunctionProtoType *Old, + SourceLocation OldLoc, + const FunctionProtoType *New, + SourceLocation NewLoc); bool handlerCanCatch(QualType HandlerType, QualType ExceptionType); - bool CheckExceptionSpecSubset(const PartialDiagnostic &DiagID, - const PartialDiagnostic &NestedDiagID, - const PartialDiagnostic &NoteID, - const PartialDiagnostic &NoThrowDiagID, - const FunctionProtoType *Superset, - SourceLocation SuperLoc, - const FunctionProtoType *Subset, - SourceLocation SubLoc); + bool CheckExceptionSpecSubset( + const PartialDiagnostic &DiagID, const PartialDiagnostic &NestedDiagID, + const PartialDiagnostic &NoteID, const PartialDiagnostic &NoThrowDiagID, + const FunctionProtoType *Superset, SourceLocation SuperLoc, + const FunctionProtoType *Subset, SourceLocation SubLoc); bool CheckParamExceptionSpec(const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID, const FunctionProtoType *Target, @@ -2154,7 +2137,7 @@ class Sema final { static int getPrintable(int I) { return I; } static unsigned getPrintable(unsigned I) { return I; } static bool getPrintable(bool B) { return B; } - static const char * getPrintable(const char *S) { return S; } + static const char *getPrintable(const char *S) { return S; } static StringRef getPrintable(StringRef S) { return S; } static const std::string &getPrintable(const std::string &S) { return S; } static const IdentifierInfo *getPrintable(const IdentifierInfo *II) { @@ -2165,7 +2148,7 @@ class Sema final { static SourceRange getPrintable(SourceRange R) { return R; } static SourceRange getPrintable(SourceLocation L) { return L; } static SourceRange getPrintable(const Expr *E) { return E->getSourceRange(); } - static SourceRange getPrintable(TypeLoc TL) { return TL.getSourceRange();} + static SourceRange getPrintable(TypeLoc TL) { return TL.getSourceRange(); } template class BoundTypeDiagnoser : public TypeDiagnoser { protected: @@ -2210,7 +2193,7 @@ class Sema final { template class SizelessTypeDiagnoser : public BoundTypeDiagnoser { public: - SizelessTypeDiagnoser(unsigned DiagID, const Ts &... Args) + SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args) : BoundTypeDiagnoser(DiagID, Args...) {} void diagnose(Sema &S, SourceLocation Loc, QualType T) override { @@ -2268,7 +2251,7 @@ class Sema final { llvm::SmallPtrSet DirectModuleImports; /// Namespace definitions that we will export when they finish. - llvm::SmallPtrSet DeferredExportedNamespaces; + llvm::SmallPtrSet DeferredExportedNamespaces; /// In a C++ standard module, inline declarations require a definition to be /// present at the end of a definition domain. This set holds the decls to @@ -2379,7 +2362,7 @@ class Sema final { bool OnlyNeedComplete = false); bool hasVisibleDefinition(const NamedDecl *D) { NamedDecl *Hidden; - return hasVisibleDefinition(const_cast(D), &Hidden); + return hasVisibleDefinition(const_cast(D), &Hidden); } /// Determine if \p D has a reachable definition. If not, suggest a @@ -2472,7 +2455,7 @@ class Sema final { template bool RequireCompleteSizedType(SourceLocation Loc, QualType T, unsigned DiagID, - const Ts &... Args) { + const Ts &...Args) { SizelessTypeDiagnoser Diagnoser(DiagID, Args...); return RequireCompleteType(Loc, T, CompleteTypeKind::Normal, Diagnoser); } @@ -2500,7 +2483,7 @@ class Sema final { template bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID, - const Ts &... Args) { + const Ts &...Args) { SizelessTypeDiagnoser Diagnoser(DiagID, Args...); return RequireCompleteExprType(E, CompleteTypeKind::Normal, Diagnoser); } @@ -2582,10 +2565,8 @@ class Sema final { IdentifierInfo **CorrectedII = nullptr); TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S); bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S); - void DiagnoseUnknownTypeName(IdentifierInfo *&II, - SourceLocation IILoc, - Scope *S, - CXXScopeSpec *SS, + void DiagnoseUnknownTypeName(IdentifierInfo *&II, SourceLocation IILoc, + Scope *S, CXXScopeSpec *SS, ParsedType &SuggestedType, bool IsTemplateName = false); @@ -2654,9 +2635,7 @@ class Sema final { NameClassification(const IdentifierInfo *Keyword) : Kind(NC_Keyword) {} - static NameClassification Error() { - return NameClassification(NC_Error); - } + static NameClassification Error() { return NameClassification(NC_Error); } static NameClassification Unknown() { return NameClassification(NC_Unknown); @@ -2840,8 +2819,8 @@ class Sema final { NamedDecl *HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists); - bool tryToFixVariablyModifiedVarType(TypeSourceInfo *&TInfo, - QualType &T, SourceLocation Loc, + bool tryToFixVariablyModifiedVarType(TypeSourceInfo *&TInfo, QualType &T, + SourceLocation Loc, unsigned FailedFoldDiagID); void RegisterLocallyScopedExternCDecl(NamedDecl *ND, Scope *S); bool DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo Info); @@ -2885,10 +2864,10 @@ class Sema final { void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec, TypedefNameDecl *NewTD); void CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *D); - NamedDecl* ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC, + NamedDecl *ActOnTypedefDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous); - NamedDecl* ActOnTypedefNameDecl(Scope* S, DeclContext* DC, TypedefNameDecl *D, + NamedDecl *ActOnTypedefNameDecl(Scope *S, DeclContext *DC, TypedefNameDecl *D, LookupResult &Previous, bool &Redeclaration); NamedDecl *ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, @@ -2908,7 +2887,7 @@ class Sema final { void CheckCompleteDecompositionDeclaration(DecompositionDecl *DD); void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D); - NamedDecl* ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, + NamedDecl *ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, @@ -2927,13 +2906,15 @@ class Sema final { CheckConstexprKind Kind); void DiagnoseHiddenVirtualMethods(CXXMethodDecl *MD); - void FindHiddenVirtualMethods(CXXMethodDecl *MD, - SmallVectorImpl &OverloadedMethods); - void NoteHiddenVirtualMethods(CXXMethodDecl *MD, - SmallVectorImpl &OverloadedMethods); + void + FindHiddenVirtualMethods(CXXMethodDecl *MD, + SmallVectorImpl &OverloadedMethods); + void + NoteHiddenVirtualMethods(CXXMethodDecl *MD, + SmallVectorImpl &OverloadedMethods); // Returns true if the function declaration is a redeclaration - bool CheckFunctionDeclaration(Scope *S, - FunctionDecl *NewFD, LookupResult &Previous, + bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, + LookupResult &Previous, bool IsMemberSpecialization, bool DeclIsDefn); bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl); bool canFullyTypeCheckRedeclaration(ValueDecl *NewD, ValueDecl *OldD, @@ -2945,15 +2926,13 @@ class Sema final { bool IsDefinition); void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D); Decl *ActOnParamDeclarator(Scope *S, Declarator &D); - ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC, - SourceLocation Loc, + ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T); ParmVarDecl *CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC); - void ActOnParamDefaultArgument(Decl *param, - SourceLocation EqualLoc, + void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc, Expr *defarg); void ActOnParamUnparsedDefaultArgument(Decl *param, SourceLocation EqualLoc, SourceLocation ArgLoc); @@ -3056,9 +3035,7 @@ class Sema final { ExprResult ActOnFinishTrailingRequiresClause(ExprResult ConstraintExpr); ExprResult ActOnRequiresClause(ExprResult ConstraintExpr); void ActOnStartOfObjCMethodDef(Scope *S, Decl *D); - bool isObjCMethodDecl(Decl *D) { - return D && isa(D); - } + bool isObjCMethodDecl(Decl *D) { return D && isa(D); } /// Determine whether we can delay parsing the body of a function or /// function template until it is used, assuming we don't care about emitting @@ -3105,8 +3082,7 @@ class Sema final { QualType ReturnTy, NamedDecl *D); void DiagnoseInvalidJumps(Stmt *Body); - Decl *ActOnFileScopeAsmDecl(Expr *expr, - SourceLocation AsmLoc, + Decl *ActOnFileScopeAsmDecl(Expr *expr, SourceLocation AsmLoc, SourceLocation RParenLoc); /// Handle a C++11 empty-declaration and attribute-declaration. @@ -3244,8 +3220,7 @@ class Sema final { bool IsExplicitInstantiation, RecordDecl *&AnonRecord); - Decl *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, - AccessSpecifier AS, + Decl *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS, RecordDecl *Record, const PrintingPolicy &Policy); @@ -3270,9 +3245,8 @@ class Sema final { /// what kind of non-tag type this is. NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK); - bool isAcceptableTagRedeclaration(const TagDecl *Previous, - TagTypeKind NewTag, bool isDefinition, - SourceLocation NewTagLoc, + bool isAcceptableTagRedeclaration(const TagDecl *Previous, TagTypeKind NewTag, + bool isDefinition, SourceLocation NewTagLoc, const IdentifierInfo *Name); enum TagUseKind { @@ -3299,24 +3273,18 @@ class Sema final { const ParsedAttributesView &Attr, MultiTemplateParamsArg TempParamLists); - TypeResult ActOnDependentTag(Scope *S, - unsigned TagSpec, - TagUseKind TUK, - const CXXScopeSpec &SS, - IdentifierInfo *Name, - SourceLocation TagLoc, - SourceLocation NameLoc); + TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, + const CXXScopeSpec &SS, IdentifierInfo *Name, + SourceLocation TagLoc, SourceLocation NameLoc); void ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart, - IdentifierInfo *ClassName, - SmallVectorImpl &Decls); + IdentifierInfo *ClassName, SmallVectorImpl &Decls); Decl *ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth); FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, - InClassInitStyle InitStyle, - AccessSpecifier AS); + InClassInitStyle InitStyle, AccessSpecifier AS); MSPropertyDecl *HandleMSProperty(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, @@ -3325,13 +3293,11 @@ class Sema final { const ParsedAttr &MSPropertyAttr); FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T, - TypeSourceInfo *TInfo, - RecordDecl *Record, SourceLocation Loc, - bool Mutable, Expr *BitfieldWidth, - InClassInitStyle InitStyle, - SourceLocation TSSL, - AccessSpecifier AS, NamedDecl *PrevDecl, - Declarator *D = nullptr); + TypeSourceInfo *TInfo, RecordDecl *Record, + SourceLocation Loc, bool Mutable, + Expr *BitfieldWidth, InClassInitStyle InitStyle, + SourceLocation TSSL, AccessSpecifier AS, + NamedDecl *PrevDecl, Declarator *D = nullptr); bool CheckNontrivialField(FieldDecl *FD); void DiagnoseNontrivial(const CXXRecordDecl *Record, CXXSpecialMember CSM); @@ -3395,9 +3361,8 @@ class Sema final { void ActOnLastBitfield(SourceLocation DeclStart, SmallVectorImpl &AllIvarDecls); - Decl *ActOnIvar(Scope *S, SourceLocation DeclStart, - Declarator &D, Expr *BitfieldWidth, - tok::ObjCKeywordKind visibility); + Decl *ActOnIvar(Scope *S, SourceLocation DeclStart, Declarator &D, + Expr *BitfieldWidth, tok::ObjCKeywordKind visibility); // This is used for both record definitions and ObjC interface declarations. void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, @@ -3452,8 +3417,7 @@ class Sema final { EnumConstantDecl *CheckEnumConstant(EnumDecl *Enum, EnumConstantDecl *LastEnumConst, - SourceLocation IdLoc, - IdentifierInfo *Id, + SourceLocation IdLoc, IdentifierInfo *Id, Expr *val); bool CheckEnumUnderlyingType(TypeSourceInfo *TI); bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped, @@ -3482,13 +3446,13 @@ class Sema final { void EnterDeclaratorContext(Scope *S, DeclContext *DC); void ExitDeclaratorContext(Scope *S); - /// Enter a template parameter scope, after it's been associated with a particular - /// DeclContext. Causes lookup within the scope to chain through enclosing contexts - /// in the correct order. + /// Enter a template parameter scope, after it's been associated with a + /// particular DeclContext. Causes lookup within the scope to chain through + /// enclosing contexts in the correct order. void EnterTemplatedContext(Scope *S, DeclContext *DC); /// Push the parameters of D, which must be a function, into scope. - void ActOnReenterFunctionContext(Scope* S, Decl* D); + void ActOnReenterFunctionContext(Scope *S, Decl *D); void ActOnExitFunctionContext(); /// If \p AllowLambda is true, treat lambda as function. @@ -3617,10 +3581,10 @@ class Sema final { InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL); InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const InternalLinkageAttr &AL); - WebAssemblyImportNameAttr *mergeImportNameAttr( - Decl *D, const WebAssemblyImportNameAttr &AL); - WebAssemblyImportModuleAttr *mergeImportModuleAttr( - Decl *D, const WebAssemblyImportModuleAttr &AL); + WebAssemblyImportNameAttr * + mergeImportNameAttr(Decl *D, const WebAssemblyImportNameAttr &AL); + WebAssemblyImportModuleAttr * + mergeImportModuleAttr(Decl *D, const WebAssemblyImportModuleAttr &AL); EnforceTCBAttr *mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL); EnforceTCBLeafAttr *mergeEnforceTCBLeafAttr(Decl *D, const EnforceTCBLeafAttr &AL); @@ -3674,10 +3638,8 @@ class Sema final { /// non-function. Ovl_NonFunction }; - OverloadKind CheckOverload(Scope *S, - FunctionDecl *New, - const LookupResult &OldDecls, - NamedDecl *&OldDecl, + OverloadKind CheckOverload(Scope *S, FunctionDecl *New, + const LookupResult &OldDecls, NamedDecl *&OldDecl, bool IsForUsingDecl); bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl, bool ConsiderCudaAttrs = true, @@ -3719,45 +3681,39 @@ class Sema final { All }; - ImplicitConversionSequence - TryImplicitConversion(Expr *From, QualType ToType, - bool SuppressUserConversions, - AllowedExplicit AllowExplicit, - bool InOverloadResolution, - bool CStyle, - bool AllowObjCWritebackConversion); + ImplicitConversionSequence TryImplicitConversion( + Expr *From, QualType ToType, bool SuppressUserConversions, + AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle, + bool AllowObjCWritebackConversion); bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType); bool IsFloatingPointPromotion(QualType FromType, QualType ToType); bool IsComplexPromotion(QualType FromType, QualType ToType); bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType, - bool InOverloadResolution, - QualType& ConvertedType, bool &IncompatibleObjC); + bool InOverloadResolution, QualType &ConvertedType, + bool &IncompatibleObjC); bool isObjCPointerConversion(QualType FromType, QualType ToType, - QualType& ConvertedType, bool &IncompatibleObjC); + QualType &ConvertedType, bool &IncompatibleObjC); bool isObjCWritebackConversion(QualType FromType, QualType ToType, QualType &ConvertedType); bool IsBlockPointerConversion(QualType FromType, QualType ToType, - QualType& ConvertedType); + QualType &ConvertedType); bool FunctionParamTypesAreEqual(const FunctionProtoType *OldType, const FunctionProtoType *NewType, unsigned *ArgPos = nullptr, bool Reversed = false); - void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, - QualType FromType, QualType ToType); + void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, + QualType ToType); void maybeExtendBlockObject(ExprResult &E); CastKind PrepareCastToObjCObjectPointer(ExprResult &E); - bool CheckPointerConversion(Expr *From, QualType ToType, - CastKind &Kind, - CXXCastPath& BasePath, - bool IgnoreBaseAccess, + bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind, + CXXCastPath &BasePath, bool IgnoreBaseAccess, bool Diagnose = true); bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType, bool InOverloadResolution, QualType &ConvertedType); - bool CheckMemberPointerConversion(Expr *From, QualType ToType, - CastKind &Kind, + bool CheckMemberPointerConversion(Expr *From, QualType ToType, CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess); bool IsQualificationConversion(QualType FromType, QualType ToType, @@ -3775,8 +3731,7 @@ class Sema final { bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init); ExprResult PerformCopyInitialization(const InitializedEntity &Entity, - SourceLocation EqualLoc, - ExprResult Init, + SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList = false, bool AllowExplicit = false); ExprResult PerformObjectArgumentInitialization(Expr *From, @@ -3824,8 +3779,8 @@ class Sema final { /// Emits a diagnostic complaining that the expression does not have /// integral or enumeration type. - virtual SemaDiagnosticBuilder - diagnoseNoMatch(Sema &S, SourceLocation Loc, QualType T) = 0; + virtual SemaDiagnosticBuilder diagnoseNoMatch(Sema &S, SourceLocation Loc, + QualType T) = 0; /// Emits a diagnostic when the expression has incomplete class type. virtual SemaDiagnosticBuilder @@ -3833,8 +3788,10 @@ class Sema final { /// Emits a diagnostic when the only matching conversion function /// is explicit. - virtual SemaDiagnosticBuilder diagnoseExplicitConv( - Sema &S, SourceLocation Loc, QualType T, QualType ConvTy) = 0; + virtual SemaDiagnosticBuilder diagnoseExplicitConv(Sema &S, + SourceLocation Loc, + QualType T, + QualType ConvTy) = 0; /// Emits a note for the explicit conversion function. virtual SemaDiagnosticBuilder @@ -3842,8 +3799,8 @@ class Sema final { /// Emits a diagnostic when there are multiple possible conversion /// functions. - virtual SemaDiagnosticBuilder - diagnoseAmbiguous(Sema &S, SourceLocation Loc, QualType T) = 0; + virtual SemaDiagnosticBuilder diagnoseAmbiguous(Sema &S, SourceLocation Loc, + QualType T) = 0; /// Emits a note for one of the candidate conversions. virtual SemaDiagnosticBuilder @@ -3851,8 +3808,10 @@ class Sema final { /// Emits a diagnostic when we picked a conversion function /// (for cases when we are not allowed to pick a conversion function). - virtual SemaDiagnosticBuilder diagnoseConversion( - Sema &S, SourceLocation Loc, QualType T, QualType ConvTy) = 0; + virtual SemaDiagnosticBuilder diagnoseConversion(Sema &S, + SourceLocation Loc, + QualType T, + QualType ConvTy) = 0; virtual ~ContextualImplicitConverter() {} }; @@ -3861,35 +3820,31 @@ class Sema final { bool AllowScopedEnumerations; public: - ICEConvertDiagnoser(bool AllowScopedEnumerations, - bool Suppress, bool SuppressConversion) + ICEConvertDiagnoser(bool AllowScopedEnumerations, bool Suppress, + bool SuppressConversion) : ContextualImplicitConverter(Suppress, SuppressConversion), AllowScopedEnumerations(AllowScopedEnumerations) {} /// Match an integral or (possibly scoped) enumeration type. bool match(QualType T) override; - SemaDiagnosticBuilder - diagnoseNoMatch(Sema &S, SourceLocation Loc, QualType T) override { + SemaDiagnosticBuilder diagnoseNoMatch(Sema &S, SourceLocation Loc, + QualType T) override { return diagnoseNotInt(S, Loc, T); } /// Emits a diagnostic complaining that the expression does not have /// integral or enumeration type. - virtual SemaDiagnosticBuilder - diagnoseNotInt(Sema &S, SourceLocation Loc, QualType T) = 0; + virtual SemaDiagnosticBuilder diagnoseNotInt(Sema &S, SourceLocation Loc, + QualType T) = 0; }; /// Perform a contextual implicit conversion. - ExprResult PerformContextualImplicitConversion( - SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter); - + ExprResult + PerformContextualImplicitConversion(SourceLocation Loc, Expr *FromE, + ContextualImplicitConverter &Converter); - enum ObjCSubscriptKind { - OS_Array, - OS_Dictionary, - OS_Error - }; + enum ObjCSubscriptKind { OS_Array, OS_Dictionary, OS_Error }; ObjCSubscriptKind CheckSubscriptingKind(Expr *FromE); // Note that LK_String is intentionally after the other literals, as @@ -3912,7 +3867,7 @@ class Sema final { // Members have to be NamespaceDecl* or TranslationUnitDecl*. // TODO: make this is a typesafe union. - typedef llvm::SmallSetVector AssociatedNamespaceSet; + typedef llvm::SmallSetVector AssociatedNamespaceSet; typedef llvm::SmallSetVector AssociatedClassSet; using ADLCallKind = CallExpr::ADLCallKind; @@ -3927,41 +3882,34 @@ class Sema final { ADLCallKind IsADLCandidate = ADLCallKind::NotADL, ConversionSequenceList EarlyConversions = None, OverloadCandidateParamOrder PO = {}); - void AddFunctionCandidates(const UnresolvedSetImpl &Functions, - ArrayRef Args, - OverloadCandidateSet &CandidateSet, - TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr, - bool SuppressUserConversions = false, - bool PartialOverloading = false, - bool FirstArgumentIsBase = false); - void AddMethodCandidate(DeclAccessPair FoundDecl, - QualType ObjectType, + void AddFunctionCandidates( + const UnresolvedSetImpl &Functions, ArrayRef Args, + OverloadCandidateSet &CandidateSet, + TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr, + bool SuppressUserConversions = false, bool PartialOverloading = false, + bool FirstArgumentIsBase = false); + void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef Args, - OverloadCandidateSet& CandidateSet, + OverloadCandidateSet &CandidateSet, bool SuppressUserConversion = false, OverloadCandidateParamOrder PO = {}); - void AddMethodCandidate(CXXMethodDecl *Method, - DeclAccessPair FoundDecl, + void AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef Args, - OverloadCandidateSet& CandidateSet, + OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false, bool PartialOverloading = false, ConversionSequenceList EarlyConversions = None, OverloadCandidateParamOrder PO = {}); - void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl, - DeclAccessPair FoundDecl, - CXXRecordDecl *ActingContext, - TemplateArgumentListInfo *ExplicitTemplateArgs, - QualType ObjectType, - Expr::Classification ObjectClassification, - ArrayRef Args, - OverloadCandidateSet& CandidateSet, - bool SuppressUserConversions = false, - bool PartialOverloading = false, - OverloadCandidateParamOrder PO = {}); + void AddMethodTemplateCandidate( + FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl, + CXXRecordDecl *ActingContext, + TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType, + Expr::Classification ObjectClassification, ArrayRef Args, + OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false, + bool PartialOverloading = false, OverloadCandidateParamOrder PO = {}); void AddTemplateOverloadCandidate( FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef Args, @@ -3989,9 +3937,9 @@ class Sema final { void AddSurrogateCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, - const FunctionProtoType *Proto, - Expr *Object, ArrayRef Args, - OverloadCandidateSet& CandidateSet); + const FunctionProtoType *Proto, Expr *Object, + ArrayRef Args, + OverloadCandidateSet &CandidateSet); void AddNonMemberOperatorCandidates( const UnresolvedSetImpl &Functions, ArrayRef Args, OverloadCandidateSet &CandidateSet, @@ -4001,18 +3949,16 @@ class Sema final { OverloadCandidateSet &CandidateSet, OverloadCandidateParamOrder PO = {}); void AddBuiltinCandidate(QualType *ParamTys, ArrayRef Args, - OverloadCandidateSet& CandidateSet, + OverloadCandidateSet &CandidateSet, bool IsAssignmentOperator = false, unsigned NumContextualBoolArguments = 0); void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef Args, - OverloadCandidateSet& CandidateSet); - void AddArgumentDependentLookupCandidates(DeclarationName Name, - SourceLocation Loc, - ArrayRef Args, - TemplateArgumentListInfo *ExplicitTemplateArgs, - OverloadCandidateSet& CandidateSet, - bool PartialOverloading = false); + OverloadCandidateSet &CandidateSet); + void AddArgumentDependentLookupCandidates( + DeclarationName Name, SourceLocation Loc, ArrayRef Args, + TemplateArgumentListInfo *ExplicitTemplateArgs, + OverloadCandidateSet &CandidateSet, bool PartialOverloading = false); // Emit as a 'note' the specific overload candidate void NoteOverloadCandidate( @@ -4074,10 +4020,8 @@ class Sema final { QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType); FunctionDecl * - ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, - QualType TargetType, - bool Complain, - DeclAccessPair &Found, + ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, + bool Complain, DeclAccessPair &Found, bool *pHadMultipleCandidates = nullptr); FunctionDecl * @@ -4097,8 +4041,7 @@ class Sema final { QualType DestTypeForComplaining = QualType(), unsigned DiagIDForComplaining = 0); - Expr *FixOverloadedFunctionReference(Expr *E, - DeclAccessPair FoundDecl, + Expr *FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn); ExprResult FixOverloadedFunctionReference(ExprResult, DeclAccessPair FoundDecl, @@ -4127,14 +4070,10 @@ class Sema final { OverloadCandidateSet *CandidateSet, Expr *Range, ExprResult *CallExpr); - ExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn, - UnresolvedLookupExpr *ULE, - SourceLocation LParenLoc, - MultiExprArg Args, - SourceLocation RParenLoc, - Expr *ExecConfig, - bool AllowTypoCorrection=true, - bool CalleesAddressIsTaken=false); + ExprResult BuildOverloadedCallExpr( + Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, + MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig, + bool AllowTypoCorrection = true, bool CalleesAddressIsTaken = false); bool buildOverloadedCallSet(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, MultiExprArg Args, SourceLocation RParenLoc, @@ -4149,18 +4088,16 @@ class Sema final { ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, - const UnresolvedSetImpl &Fns, - Expr *input, bool RequiresADL = true); + const UnresolvedSetImpl &Fns, Expr *input, + bool RequiresADL = true); void LookupOverloadedBinOp(OverloadCandidateSet &CandidateSet, OverloadedOperatorKind Op, const UnresolvedSetImpl &Fns, ArrayRef Args, bool RequiresADL = true); - ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, - BinaryOperatorKind Opc, - const UnresolvedSetImpl &Fns, - Expr *LHS, Expr *RHS, - bool RequiresADL = true, + ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, + const UnresolvedSetImpl &Fns, Expr *LHS, + Expr *RHS, bool RequiresADL = true, bool AllowRewrittenCandidates = true, FunctionDecl *DefaultedFn = nullptr); ExprResult BuildSynthesizedThreeWayComparison(SourceLocation OpLoc, @@ -4172,17 +4109,14 @@ class Sema final { SourceLocation RLoc, Expr *Base, MultiExprArg Args); - ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, - SourceLocation LParenLoc, - MultiExprArg Args, - SourceLocation RParenLoc, - Expr *ExecConfig = nullptr, - bool IsExecConfig = false, - bool AllowRecovery = false); - ExprResult - BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc, - MultiExprArg Args, - SourceLocation RParenLoc); + ExprResult BuildCallToMemberFunction( + Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, + SourceLocation RParenLoc, Expr *ExecConfig = nullptr, + bool IsExecConfig = false, bool AllowRecovery = false); + ExprResult BuildCallToObjectOfClassType(Scope *S, Expr *Object, + SourceLocation LParenLoc, + MultiExprArg Args, + SourceLocation RParenLoc); ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc, @@ -4302,7 +4236,7 @@ class Sema final { // the context has internal linkage, redeclaration lookup won't find things // from other TUs, and we can't safely compute linkage yet in general. if (cast(CurContext) - ->getOwningModuleForLinkage(/*IgnoreLinkage*/true)) + ->getOwningModuleForLinkage(/*IgnoreLinkage*/ true)) return ForVisibleRedeclaration; return ForExternalRedeclaration; } @@ -4329,13 +4263,10 @@ class Sema final { LOLR_StringTemplatePack, }; - SpecialMemberOverloadResult LookupSpecialMember(CXXRecordDecl *D, - CXXSpecialMember SM, - bool ConstArg, - bool VolatileArg, - bool RValueThis, - bool ConstThis, - bool VolatileThis); + SpecialMemberOverloadResult + LookupSpecialMember(CXXRecordDecl *D, CXXSpecialMember SM, bool ConstArg, + bool VolatileArg, bool RValueThis, bool ConstThis, + bool VolatileThis); typedef std::function TypoDiagnosticGenerator; typedef std::function @@ -4365,7 +4296,7 @@ class Sema final { // // The boolean value will be true to indicate that the namespace was loaded // from an AST/PCH file, or false otherwise. - llvm::MapVector KnownNamespaces; + llvm::MapVector KnownNamespaces; /// Whether we have already loaded known namespaces from an extenal /// source. @@ -4374,14 +4305,11 @@ class Sema final { /// Helper for CorrectTypo and CorrectTypoDelayed used to create and /// populate a new TypoCorrectionConsumer. Returns nullptr if typo correction /// should be skipped entirely. - std::unique_ptr - makeTypoCorrectionConsumer(const DeclarationNameInfo &Typo, - Sema::LookupNameKind LookupKind, Scope *S, - CXXScopeSpec *SS, - CorrectionCandidateCallback &CCC, - DeclContext *MemberContext, bool EnteringContext, - const ObjCObjectPointerType *OPT, - bool ErrorRecovery); + std::unique_ptr makeTypoCorrectionConsumer( + const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, + Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, + DeclContext *MemberContext, bool EnteringContext, + const ObjCObjectPointerType *OPT, bool ErrorRecovery); public: const TypoExprState &getTypoExprState(TypoExpr *TE) const; @@ -4395,10 +4323,8 @@ class Sema final { /// It is preferable to use the elaborated form and explicitly handle /// ambiguity and overloaded. NamedDecl *LookupSingleName(Scope *S, DeclarationName Name, - SourceLocation Loc, - LookupNameKind NameKind, - RedeclarationKind Redecl - = NotForRedeclaration); + SourceLocation Loc, LookupNameKind NameKind, + RedeclarationKind Redecl = NotForRedeclaration); bool LookupBuiltin(LookupResult &R); void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID); bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation = false, @@ -4410,9 +4336,9 @@ class Sema final { bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, bool AllowBuiltinCreation = false, bool EnteringContext = false); - ObjCProtocolDecl *LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, - RedeclarationKind Redecl - = NotForRedeclaration); + ObjCProtocolDecl * + LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, + RedeclarationKind Redecl = NotForRedeclaration); bool LookupInSuper(LookupResult &R, CXXRecordDecl *Class); void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, @@ -4475,24 +4401,20 @@ class Sema final { }; TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, - Sema::LookupNameKind LookupKind, - Scope *S, CXXScopeSpec *SS, - CorrectionCandidateCallback &CCC, + Sema::LookupNameKind LookupKind, Scope *S, + CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext = nullptr, bool EnteringContext = false, const ObjCObjectPointerType *OPT = nullptr, bool RecordFailure = true); - TypoExpr *CorrectTypoDelayed(const DeclarationNameInfo &Typo, - Sema::LookupNameKind LookupKind, Scope *S, - CXXScopeSpec *SS, - CorrectionCandidateCallback &CCC, - TypoDiagnosticGenerator TDG, - TypoRecoveryCallback TRC, CorrectTypoKind Mode, - DeclContext *MemberContext = nullptr, - bool EnteringContext = false, - const ObjCObjectPointerType *OPT = nullptr); + TypoExpr *CorrectTypoDelayed( + const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, + Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, + TypoDiagnosticGenerator TDG, TypoRecoveryCallback TRC, + CorrectTypoKind Mode, DeclContext *MemberContext = nullptr, + bool EnteringContext = false, const ObjCObjectPointerType *OPT = nullptr); /// Process any TypoExprs in the given Expr and its children, /// generating diagnostics as appropriate and returning a new Expr if there @@ -4539,10 +4461,10 @@ class Sema final { void MarkTypoCorrectedFunctionDefinition(const NamedDecl *F); - void FindAssociatedClassesAndNamespaces(SourceLocation InstantiationLoc, - ArrayRef Args, - AssociatedNamespaceSet &AssociatedNamespaces, - AssociatedClassSet &AssociatedClasses); + void FindAssociatedClassesAndNamespaces( + SourceLocation InstantiationLoc, ArrayRef Args, + AssociatedNamespaceSet &AssociatedNamespaces, + AssociatedClassSet &AssociatedClasses); void FilterLookupForScope(LookupResult &R, DeclContext *Ctx, Scope *S, bool ConsiderLinkage, bool AllowInlineNamespace); @@ -4550,8 +4472,7 @@ class Sema final { bool CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old); bool CheckRedeclarationExported(NamedDecl *New, NamedDecl *Old); bool CheckRedeclarationInModule(NamedDecl *New, NamedDecl *Old); - bool IsRedefinitionInModule(const NamedDecl *New, - const NamedDecl *Old) const; + bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const; void DiagnoseAmbiguousLookup(LookupResult &Result); //@} @@ -4566,9 +4487,8 @@ class Sema final { bool TypoCorrection = false); FunctionDecl *CreateBuiltin(IdentifierInfo *II, QualType Type, unsigned ID, SourceLocation Loc); - NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, - Scope *S, bool ForRedeclaration, - SourceLocation Loc); + NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S, + bool ForRedeclaration, SourceLocation Loc); NamedDecl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, Scope *S); void AddKnownFunctionAttributesForReplaceableGlobalAllocationFunction( @@ -4616,7 +4536,7 @@ class Sema final { const ProcessDeclAttributeOptions &Options = ProcessDeclAttributeOptions()); bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl, - const ParsedAttributesView &AttrList); + const ParsedAttributesView &AttrList); void checkUnusedDeclAttributes(Declarator &D); @@ -4653,9 +4573,9 @@ class Sema final { const StringLiteral *Literal, bool &HasDefault, bool &HasCommas, SmallVectorImpl &Strings); - bool checkMSInheritanceAttrOnDefinition( - CXXRecordDecl *RD, SourceRange Range, bool BestCase, - MSInheritanceModel SemanticSpelling); + bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, + bool BestCase, + MSInheritanceModel SemanticSpelling); void CheckAlignasUnderalignment(Decl *D); @@ -4684,13 +4604,12 @@ class Sema final { bool IsProtocolMethodDecl); void CheckConflictingOverridingMethod(ObjCMethodDecl *Method, - ObjCMethodDecl *Overridden, - bool IsProtocolMethodDecl); + ObjCMethodDecl *Overridden, + bool IsProtocolMethodDecl); /// WarnExactTypedMethods - This routine issues a warning if method /// implementation declaration matches exactly that of its declaration. - void WarnExactTypedMethods(ObjCMethodDecl *Method, - ObjCMethodDecl *MethodDecl, + void WarnExactTypedMethods(ObjCMethodDecl *Method, ObjCMethodDecl *MethodDecl, bool IsProtocolMethodDecl); typedef llvm::SmallPtrSet SelectorSet; @@ -4703,13 +4622,13 @@ class Sema final { /// ImplMethodsVsClassMethods - This is main routine to warn if any method /// remains unimplemented in the class or category \@implementation. - void ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl, - ObjCContainerDecl* IDecl, + void ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl *IMPDecl, + ObjCContainerDecl *IDecl, bool IncompleteImpl = false); /// DiagnoseUnimplementedProperties - This routine warns on those properties /// which must be implemented by this implementation. - void DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl, + void DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl *IMPDecl, ObjCContainerDecl *CDecl, bool SynthesizeProperties); @@ -4729,71 +4648,54 @@ class Sema final { bool IvarBacksCurrentMethodAccessor(ObjCInterfaceDecl *IFace, ObjCMethodDecl *Method, ObjCIvarDecl *IV); - /// DiagnoseUnusedBackingIvarInAccessor - Issue an 'unused' warning if ivar which - /// backs the property is not used in the property's accessor. + /// DiagnoseUnusedBackingIvarInAccessor - Issue an 'unused' warning if ivar + /// which backs the property is not used in the property's accessor. void DiagnoseUnusedBackingIvarInAccessor(Scope *S, const ObjCImplementationDecl *ImplD); /// GetIvarBackingPropertyAccessor - If method is a property setter/getter and - /// it property has a backing ivar, returns this ivar; otherwise, returns NULL. - /// It also returns ivar's property on success. - ObjCIvarDecl *GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method, - const ObjCPropertyDecl *&PDecl) const; + /// it property has a backing ivar, returns this ivar; otherwise, returns + /// NULL. It also returns ivar's property on success. + ObjCIvarDecl * + GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method, + const ObjCPropertyDecl *&PDecl) const; /// Called by ActOnProperty to handle \@property declarations in /// class extensions. - ObjCPropertyDecl *HandlePropertyInClassExtension(Scope *S, - SourceLocation AtLoc, - SourceLocation LParenLoc, - FieldDeclarator &FD, - Selector GetterSel, - SourceLocation GetterNameLoc, - Selector SetterSel, - SourceLocation SetterNameLoc, - const bool isReadWrite, - unsigned &Attributes, - const unsigned AttributesAsWritten, - QualType T, - TypeSourceInfo *TSI, - tok::ObjCKeywordKind MethodImplKind); + ObjCPropertyDecl *HandlePropertyInClassExtension( + Scope *S, SourceLocation AtLoc, SourceLocation LParenLoc, + FieldDeclarator &FD, Selector GetterSel, SourceLocation GetterNameLoc, + Selector SetterSel, SourceLocation SetterNameLoc, const bool isReadWrite, + unsigned &Attributes, const unsigned AttributesAsWritten, QualType T, + TypeSourceInfo *TSI, tok::ObjCKeywordKind MethodImplKind); /// Called by ActOnProperty and HandlePropertyInClassExtension to /// handle creating the ObjcPropertyDecl for a category or \@interface. - ObjCPropertyDecl *CreatePropertyDecl(Scope *S, - ObjCContainerDecl *CDecl, - SourceLocation AtLoc, - SourceLocation LParenLoc, - FieldDeclarator &FD, - Selector GetterSel, - SourceLocation GetterNameLoc, - Selector SetterSel, - SourceLocation SetterNameLoc, - const bool isReadWrite, - const unsigned Attributes, - const unsigned AttributesAsWritten, - QualType T, - TypeSourceInfo *TSI, - tok::ObjCKeywordKind MethodImplKind, - DeclContext *lexicalDC = nullptr); + ObjCPropertyDecl * + CreatePropertyDecl(Scope *S, ObjCContainerDecl *CDecl, SourceLocation AtLoc, + SourceLocation LParenLoc, FieldDeclarator &FD, + Selector GetterSel, SourceLocation GetterNameLoc, + Selector SetterSel, SourceLocation SetterNameLoc, + const bool isReadWrite, const unsigned Attributes, + const unsigned AttributesAsWritten, QualType T, + TypeSourceInfo *TSI, tok::ObjCKeywordKind MethodImplKind, + DeclContext *lexicalDC = nullptr); /// AtomicPropertySetterGetterRules - This routine enforces the rule (via /// warning) when atomic property has one but not the other user-declared /// setter or getter. - void AtomicPropertySetterGetterRules(ObjCImplDecl* IMPDecl, - ObjCInterfaceDecl* IDecl); + void AtomicPropertySetterGetterRules(ObjCImplDecl *IMPDecl, + ObjCInterfaceDecl *IDecl); void DiagnoseOwningPropertyGetterSynthesis(const ObjCImplementationDecl *D); - void DiagnoseMissingDesignatedInitOverrides( - const ObjCImplementationDecl *ImplD, - const ObjCInterfaceDecl *IFD); + void + DiagnoseMissingDesignatedInitOverrides(const ObjCImplementationDecl *ImplD, + const ObjCInterfaceDecl *IFD); void DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, ObjCInterfaceDecl *SID); - enum MethodMatchStrategy { - MMS_loose, - MMS_strict - }; + enum MethodMatchStrategy { MMS_loose, MMS_strict }; /// MatchTwoMethodDeclarations - Checks if two methods' type match and returns /// true, or false, accordingly. @@ -4803,15 +4705,11 @@ class Sema final { /// MatchAllMethodDeclarations - Check methods declaraed in interface or /// or protocol against those declared in their implementations. - void MatchAllMethodDeclarations(const SelectorSet &InsMap, - const SelectorSet &ClsMap, - SelectorSet &InsMapSeen, - SelectorSet &ClsMapSeen, - ObjCImplDecl* IMPDecl, - ObjCContainerDecl* IDecl, - bool &IncompleteImpl, - bool ImmediateClass, - bool WarnCategoryMethodImpl=false); + void MatchAllMethodDeclarations( + const SelectorSet &InsMap, const SelectorSet &ClsMap, + SelectorSet &InsMapSeen, SelectorSet &ClsMapSeen, ObjCImplDecl *IMPDecl, + ObjCContainerDecl *IDecl, bool &IncompleteImpl, bool ImmediateClass, + bool WarnCategoryMethodImpl = false); /// CheckCategoryVsClassMethodMatches - Checks that methods implemented in /// category matches with those implemented in its primary class and @@ -4843,17 +4741,17 @@ class Sema final { /// returns true. bool CollectMultipleMethodsInGlobalPool(Selector Sel, - SmallVectorImpl& Methods, + SmallVectorImpl &Methods, bool InstanceFirst, bool CheckTheOther, const ObjCObjectType *TypeBound = nullptr); bool AreMultipleMethodsInGlobalPool(Selector Sel, ObjCMethodDecl *BestMethod, SourceRange R, bool receiverIdOrClass, - SmallVectorImpl& Methods); + SmallVectorImpl &Methods); void - DiagnoseMultipleMethodInGlobalPool(SmallVectorImpl &Methods, + DiagnoseMultipleMethodInGlobalPool(SmallVectorImpl &Methods, Selector Sel, SourceRange R, bool receiverIdOrClass); @@ -4862,8 +4760,7 @@ class Sema final { /// nullptr if none could be found ObjCMethodDecl *SelectBestMethod(Selector Sel, MultiExprArg Args, bool IsInstance, - SmallVectorImpl& Methods); - + SmallVectorImpl &Methods); /// Record the typo correction failure and return an empty correction. TypoCorrection FailedCorrection(IdentifierInfo *Typo, SourceLocation TypoLoc, @@ -4878,13 +4775,14 @@ class Sema final { /// unit are added to a global pool. This allows us to efficiently associate /// a selector with a method declaraation for purposes of typechecking /// messages sent to "id" (where the class of the object is unknown). - void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false) { - AddMethodToGlobalPool(Method, impl, /*instance*/true); + void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, + bool impl = false) { + AddMethodToGlobalPool(Method, impl, /*instance*/ true); } /// AddFactoryMethodToGlobalPool - Same as above, but for factory methods. - void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false) { - AddMethodToGlobalPool(Method, impl, /*instance*/false); + void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl = false) { + AddMethodToGlobalPool(Method, impl, /*instance*/ false); } /// AddAnyMethodToGlobalPool - Add any method, instance or factory to global @@ -4893,48 +4791,47 @@ class Sema final { /// LookupInstanceMethodInGlobalPool - Returns the method and warns if /// there are multiple signatures. - ObjCMethodDecl *LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R, - bool receiverIdOrClass=false) { + ObjCMethodDecl * + LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R, + bool receiverIdOrClass = false) { return LookupMethodInGlobalPool(Sel, R, receiverIdOrClass, - /*instance*/true); + /*instance*/ true); } /// LookupFactoryMethodInGlobalPool - Returns the method and warns if /// there are multiple signatures. - ObjCMethodDecl *LookupFactoryMethodInGlobalPool(Selector Sel, SourceRange R, - bool receiverIdOrClass=false) { + ObjCMethodDecl * + LookupFactoryMethodInGlobalPool(Selector Sel, SourceRange R, + bool receiverIdOrClass = false) { return LookupMethodInGlobalPool(Sel, R, receiverIdOrClass, - /*instance*/false); + /*instance*/ false); } - const ObjCMethodDecl *SelectorsForTypoCorrection(Selector Sel, - QualType ObjectType=QualType()); + const ObjCMethodDecl * + SelectorsForTypoCorrection(Selector Sel, QualType ObjectType = QualType()); /// LookupImplementedMethodInGlobalPool - Returns the method which has an /// implementation. ObjCMethodDecl *LookupImplementedMethodInGlobalPool(Selector Sel); /// CollectIvarsToConstructOrDestruct - Collect those ivars which require /// initialization. - void CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI, - SmallVectorImpl &Ivars); + void + CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI, + SmallVectorImpl &Ivars); //===--------------------------------------------------------------------===// // Statement Parsing Callbacks: SemaStmt.cpp. public: class FullExprArg { public: - FullExprArg() : E(nullptr) { } - FullExprArg(Sema &actions) : E(nullptr) { } + FullExprArg() : E(nullptr) {} + FullExprArg(Sema &actions) : E(nullptr) {} - ExprResult release() { - return E; - } + ExprResult release() { return E; } Expr *get() const { return E; } - Expr *operator->() { - return E; - } + Expr *operator->() { return E; } private: // FIXME: No need to make the entire Sema class a friend when it's just @@ -4979,9 +4876,7 @@ class Sema final { S.ActOnStartOfCompoundStmt(IsStmtExpr); } - ~CompoundScopeRAII() { - S.ActOnFinishOfCompoundStmt(); - } + ~CompoundScopeRAII() { S.ActOnFinishOfCompoundStmt(); } private: Sema &S; @@ -4999,9 +4894,8 @@ class Sema final { void disable() { Active = false; } }; - StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, - SourceLocation StartLoc, - SourceLocation EndLoc); + StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, + SourceLocation EndLoc); void ActOnForEachDeclStmt(DeclGroupPtrTy Decl); StmtResult ActOnForEachLValueExpr(Expr *E); ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val); @@ -5011,8 +4905,8 @@ class Sema final { void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt); StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, - SourceLocation ColonLoc, - Stmt *SubStmt, Scope *CurScope); + SourceLocation ColonLoc, Stmt *SubStmt, + Scope *CurScope); StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt); @@ -5035,8 +4929,8 @@ class Sema final { SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc); - StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, - Stmt *Switch, Stmt *Body); + StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, + Stmt *Body); StmtResult ActOnWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body); @@ -5044,17 +4938,14 @@ class Sema final { SourceLocation WhileLoc, SourceLocation CondLParen, Expr *Cond, SourceLocation CondRParen); - StmtResult ActOnForStmt(SourceLocation ForLoc, - SourceLocation LParenLoc, - Stmt *First, - ConditionResult Second, - FullExprArg Third, - SourceLocation RParenLoc, + StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, + Stmt *First, ConditionResult Second, + FullExprArg Third, SourceLocation RParenLoc, Stmt *Body); ExprResult CheckObjCForCollectionOperand(SourceLocation forLoc, Expr *collection); - StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, - Stmt *First, Expr *collection, + StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, Stmt *First, + Expr *collection, SourceLocation RParenLoc); StmtResult FinishObjCForCollectionStmt(Stmt *ForCollection, Stmt *Body); @@ -5070,29 +4961,22 @@ class Sema final { }; StmtResult ActOnCXXForRangeStmt(Scope *S, SourceLocation ForLoc, - SourceLocation CoawaitLoc, - Stmt *InitStmt, - Stmt *LoopVar, - SourceLocation ColonLoc, Expr *Collection, - SourceLocation RParenLoc, + SourceLocation CoawaitLoc, Stmt *InitStmt, + Stmt *LoopVar, SourceLocation ColonLoc, + Expr *Collection, SourceLocation RParenLoc, BuildForRangeKind Kind); StmtResult BuildCXXForRangeStmt(SourceLocation ForLoc, - SourceLocation CoawaitLoc, - Stmt *InitStmt, - SourceLocation ColonLoc, - Stmt *RangeDecl, Stmt *Begin, Stmt *End, - Expr *Cond, Expr *Inc, - Stmt *LoopVarDecl, - SourceLocation RParenLoc, + SourceLocation CoawaitLoc, Stmt *InitStmt, + SourceLocation ColonLoc, Stmt *RangeDecl, + Stmt *Begin, Stmt *End, Expr *Cond, Expr *Inc, + Stmt *LoopVarDecl, SourceLocation RParenLoc, BuildForRangeKind Kind); StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body); - StmtResult ActOnGotoStmt(SourceLocation GotoLoc, - SourceLocation LabelLoc, + StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl); StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, - SourceLocation StarLoc, - Expr *DestExp); + SourceLocation StarLoc, Expr *DestExp); StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope); StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope); @@ -5143,8 +5027,7 @@ class Sema final { unsigned NumInputs, IdentifierInfo **Names, MultiExprArg Constraints, MultiExprArg Exprs, Expr *AsmString, MultiExprArg Clobbers, - unsigned NumLabels, - SourceLocation RParenLoc); + unsigned NumLabels, SourceLocation RParenLoc); void FillInlineAsmIdentifierInfo(Expr *Res, llvm::InlineAsmIdentifierInfo &Info); @@ -5152,26 +5035,22 @@ class Sema final { SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool IsUnevaluatedContext); - bool LookupInlineAsmField(StringRef Base, StringRef Member, - unsigned &Offset, SourceLocation AsmLoc); + bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset, + SourceLocation AsmLoc); ExprResult LookupInlineAsmVarDeclField(Expr *RefExpr, StringRef Member, SourceLocation AsmLoc); StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, - ArrayRef AsmToks, - StringRef AsmString, + ArrayRef AsmToks, StringRef AsmString, unsigned NumOutputs, unsigned NumInputs, ArrayRef Constraints, ArrayRef Clobbers, - ArrayRef Exprs, - SourceLocation EndLoc); + ArrayRef Exprs, SourceLocation EndLoc); LabelDecl *GetOrCreateMSAsmLabel(StringRef ExternalLabelName, - SourceLocation Location, - bool AlwaysCreate); + SourceLocation Location, bool AlwaysCreate); VarDecl *BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType, - SourceLocation StartLoc, - SourceLocation IdLoc, IdentifierInfo *Id, - bool Invalid = false); + SourceLocation StartLoc, SourceLocation IdLoc, + IdentifierInfo *Id, bool Invalid = false); Decl *ActOnObjCExceptionDecl(Scope *S, Declarator &D); @@ -5188,29 +5067,26 @@ class Sema final { Scope *CurScope); ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand); - StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, - Expr *SynchExpr, + StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SynchExpr, Stmt *SynchBody); StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body); VarDecl *BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo, SourceLocation StartLoc, - SourceLocation IdLoc, - IdentifierInfo *Id); + SourceLocation IdLoc, IdentifierInfo *Id); Decl *ActOnExceptionDeclarator(Scope *S, Declarator &D); - StmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc, - Decl *ExDecl, Stmt *HandlerBlock); + StmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc, Decl *ExDecl, + Stmt *HandlerBlock); StmtResult ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock, ArrayRef Handlers); StmtResult ActOnSEHTryBlock(bool IsCXXTry, // try (true) or __try (false) ? SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler); - StmtResult ActOnSEHExceptBlock(SourceLocation Loc, - Expr *FilterExpr, + StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block); void ActOnStartSEHFinallyBlock(); void ActOnAbortSEHFinallyBlock(); @@ -5247,14 +5123,12 @@ class Sema final { /// This helps prevent bugs due to typos, such as: /// if (condition); /// do_stuff(); - void DiagnoseEmptyStmtBody(SourceLocation StmtLoc, - const Stmt *Body, + void DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body, unsigned DiagID); /// Warn if a for/while loop statement \p S, which is followed by /// \p PossibleBody, has a suspicious null statement as a body. - void DiagnoseEmptyLoopBody(const Stmt *S, - const Stmt *PossibleBody); + void DiagnoseEmptyLoopBody(const Stmt *S, const Stmt *PossibleBody); /// Warn if a value is moved to itself. void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr, @@ -5380,7 +5254,9 @@ class Sema final { void CleanupVarDeclMarking(); enum TryCaptureKind { - TryCapture_Implicit, TryCapture_ExplicitByVal, TryCapture_ExplicitByRef + TryCapture_Implicit, + TryCapture_ExplicitByVal, + TryCapture_ExplicitByRef }; /// Try to capture the given variable. @@ -5478,17 +5354,18 @@ class Sema final { const PartialDiagnostic &PD); /// Similar, but diagnostic is only produced if all the specified statements /// are reachable. - bool DiagRuntimeBehavior(SourceLocation Loc, ArrayRef Stmts, + bool DiagRuntimeBehavior(SourceLocation Loc, ArrayRef Stmts, const PartialDiagnostic &PD); // Primary Expressions. SourceRange getExprRange(Expr *E) const; - ExprResult ActOnIdExpression( - Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, - UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, - CorrectionCandidateCallback *CCC = nullptr, - bool IsInlineAsmIdentifier = false, Token *KeywordReplacement = nullptr); + ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, + SourceLocation TemplateKWLoc, UnqualifiedId &Id, + bool HasTrailingLParen, bool IsAddressOfOperand, + CorrectionCandidateCallback *CCC = nullptr, + bool IsInlineAsmIdentifier = false, + Token *KeywordReplacement = nullptr); void DecomposeUnqualifiedId(const UnqualifiedId &Id, TemplateArgumentListInfo &Buffer, @@ -5509,13 +5386,12 @@ class Sema final { ExprResult LookupInObjCMethod(LookupResult &LookUp, Scope *S, IdentifierInfo *II, - bool AllowBuiltinCreation=false); + bool AllowBuiltinCreation = false); - ExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS, - SourceLocation TemplateKWLoc, - const DeclarationNameInfo &NameInfo, - bool isAddressOfOperand, - const TemplateArgumentListInfo *TemplateArgs); + ExprResult ActOnDependentIdExpression( + const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, + const DeclarationNameInfo &NameInfo, bool isAddressOfOperand, + const TemplateArgumentListInfo *TemplateArgs); /// If \p D cannot be odr-used in the current expression evaluation context, /// return a reason explaining why. Otherwise, return NOUR_None. @@ -5534,32 +5410,26 @@ class Sema final { DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, const DeclarationNameInfo &NameInfo, - NestedNameSpecifierLoc NNS, - NamedDecl *FoundD = nullptr, + NestedNameSpecifierLoc NNS, NamedDecl *FoundD = nullptr, SourceLocation TemplateKWLoc = SourceLocation(), const TemplateArgumentListInfo *TemplateArgs = nullptr); - ExprResult - BuildAnonymousStructUnionMemberReference( - const CXXScopeSpec &SS, - SourceLocation nameLoc, + ExprResult BuildAnonymousStructUnionMemberReference( + const CXXScopeSpec &SS, SourceLocation nameLoc, IndirectFieldDecl *indirectField, DeclAccessPair FoundDecl = DeclAccessPair::make(nullptr, AS_none), - Expr *baseObjectExpr = nullptr, - SourceLocation opLoc = SourceLocation()); + Expr *baseObjectExpr = nullptr, SourceLocation opLoc = SourceLocation()); ExprResult BuildPossibleImplicitMemberExpr( const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, UnresolvedLookupExpr *AsULE = nullptr); - ExprResult BuildImplicitMemberExpr(const CXXScopeSpec &SS, - SourceLocation TemplateKWLoc, - LookupResult &R, - const TemplateArgumentListInfo *TemplateArgs, - bool IsDefiniteInstance, - const Scope *S); - bool UseArgumentDependentLookup(const CXXScopeSpec &SS, - const LookupResult &R, + ExprResult + BuildImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, + LookupResult &R, + const TemplateArgumentListInfo *TemplateArgs, + bool IsDefiniteInstance, const Scope *S); + bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R, bool HasTrailingLParen); ExprResult @@ -5568,13 +5438,13 @@ class Sema final { bool IsAddressOfOperand, const Scope *S, TypeSourceInfo **RecoveryTSI = nullptr); - ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS, - SourceLocation TemplateKWLoc, - const DeclarationNameInfo &NameInfo, - const TemplateArgumentListInfo *TemplateArgs); + ExprResult + BuildDependentDeclRefExpr(const CXXScopeSpec &SS, + SourceLocation TemplateKWLoc, + const DeclarationNameInfo &NameInfo, + const TemplateArgumentListInfo *TemplateArgs); - ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, - LookupResult &R, + ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl = false); ExprResult BuildDeclarationNameExpr( @@ -5583,11 +5453,10 @@ class Sema final { const TemplateArgumentListInfo *TemplateArgs = nullptr, bool AcceptInvalidDecl = false); - ExprResult BuildLiteralOperatorCall(LookupResult &R, - DeclarationNameInfo &SuffixInfo, - ArrayRef Args, - SourceLocation LitEndLoc, - TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr); + ExprResult BuildLiteralOperatorCall( + LookupResult &R, DeclarationNameInfo &SuffixInfo, ArrayRef Args, + SourceLocation LitEndLoc, + TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr); ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedExpr::IdentKind IK); @@ -5609,8 +5478,7 @@ class Sema final { ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope = nullptr); ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E); - ExprResult ActOnParenListExpr(SourceLocation L, - SourceLocation R, + ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val); /// ActOnStringLiteral - The specified tokens were lexed as pasted string @@ -5650,11 +5518,10 @@ class Sema final { SourceRange R); ExprResult CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind); - ExprResult - ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc, - UnaryExprOrTypeTrait ExprKind, - bool IsType, void *TyOrEx, - SourceRange ArgRange); + ExprResult ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc, + UnaryExprOrTypeTrait ExprKind, + bool IsType, void *TyOrEx, + SourceRange ArgRange); ExprResult CheckPlaceholderExpr(Expr *E); bool CheckVecStepExpr(Expr *E); @@ -5663,8 +5530,7 @@ class Sema final { bool CheckUnaryExprOrTypeTraitOperand(QualType ExprType, SourceLocation OpLoc, SourceRange ExprRange, UnaryExprOrTypeTrait ExprKind); - ExprResult ActOnSizeofParameterPackExpr(Scope *S, - SourceLocation OpLoc, + ExprResult ActOnSizeofParameterPackExpr(Scope *S, SourceLocation OpLoc, IdentifierInfo &Name, SourceLocation NameLoc, SourceLocation RParenLoc); @@ -5722,8 +5588,7 @@ class Sema final { Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, - const TemplateArgumentListInfo *TemplateArgs, - const Scope *S, + const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs = nullptr); ExprResult @@ -5732,8 +5597,7 @@ class Sema final { SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, - const Scope *S, - bool SuppressQualifierCheck = false, + const Scope *S, bool SuppressQualifierCheck = false, ActOnMemberAccessExtraArgs *ExtraArgs = nullptr); ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow, @@ -5748,30 +5612,23 @@ class Sema final { const CXXScopeSpec &SS, const LookupResult &R); - ExprResult ActOnDependentMemberExpr(Expr *Base, QualType BaseType, - bool IsArrow, SourceLocation OpLoc, - const CXXScopeSpec &SS, - SourceLocation TemplateKWLoc, - NamedDecl *FirstQualifierInScope, - const DeclarationNameInfo &NameInfo, - const TemplateArgumentListInfo *TemplateArgs); + ExprResult ActOnDependentMemberExpr( + Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OpLoc, + const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, + NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, + const TemplateArgumentListInfo *TemplateArgs); - ExprResult ActOnMemberAccessExpr(Scope *S, Expr *Base, - SourceLocation OpLoc, - tok::TokenKind OpKind, - CXXScopeSpec &SS, + ExprResult ActOnMemberAccessExpr(Scope *S, Expr *Base, SourceLocation OpLoc, + tok::TokenKind OpKind, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, - UnqualifiedId &Member, - Decl *ObjCImpDecl); - - MemberExpr * - BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc, - const CXXScopeSpec *SS, SourceLocation TemplateKWLoc, - ValueDecl *Member, DeclAccessPair FoundDecl, - bool HadMultipleCandidates, - const DeclarationNameInfo &MemberNameInfo, QualType Ty, - ExprValueKind VK, ExprObjectKind OK, - const TemplateArgumentListInfo *TemplateArgs = nullptr); + UnqualifiedId &Member, Decl *ObjCImpDecl); + + MemberExpr *BuildMemberExpr( + Expr *Base, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec *SS, + SourceLocation TemplateKWLoc, ValueDecl *Member, DeclAccessPair FoundDecl, + bool HadMultipleCandidates, const DeclarationNameInfo &MemberNameInfo, + QualType Ty, ExprValueKind VK, ExprObjectKind OK, + const TemplateArgumentListInfo *TemplateArgs = nullptr); MemberExpr * BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, @@ -5782,14 +5639,11 @@ class Sema final { const TemplateArgumentListInfo *TemplateArgs = nullptr); void ActOnDefaultCtorInitializers(Decl *CDtorDecl); - bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, - FunctionDecl *FDecl, + bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl, const FunctionProtoType *Proto, - ArrayRef Args, - SourceLocation RParenLoc, + ArrayRef Args, SourceLocation RParenLoc, bool ExecConfig = false); - void CheckStaticArrayArgument(SourceLocation CallLoc, - ParmVarDecl *Param, + void CheckStaticArrayArgument(SourceLocation CallLoc, ParmVarDecl *Param, const Expr *ArgExpr); /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments. @@ -5821,13 +5675,11 @@ class Sema final { MultiExprArg ExecConfig, SourceLocation GGGLoc); - ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, - Declarator &D, ParsedType &Ty, - SourceLocation RParenLoc, Expr *CastExpr); - ExprResult BuildCStyleCastExpr(SourceLocation LParenLoc, - TypeSourceInfo *Ty, - SourceLocation RParenLoc, - Expr *Op); + ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, + ParsedType &Ty, SourceLocation RParenLoc, + Expr *CastExpr); + ExprResult BuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *Ty, + SourceLocation RParenLoc, Expr *Op); CastKind PrepareScalarCast(ExprResult &src, QualType destType); /// Build an altivec or OpenCL literal. @@ -5837,37 +5689,32 @@ class Sema final { ExprResult MaybeConvertParenListExprToParenExpr(Scope *S, Expr *ME); - ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, - ParsedType Ty, - SourceLocation RParenLoc, - Expr *InitExpr); + ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty, + SourceLocation RParenLoc, Expr *InitExpr); ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *LiteralExpr); - ExprResult ActOnInitList(SourceLocation LBraceLoc, - MultiExprArg InitArgList, + ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc); - ExprResult BuildInitList(SourceLocation LBraceLoc, - MultiExprArg InitArgList, + ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc); ExprResult ActOnDesignatedInitializer(Designation &Desig, SourceLocation EqualOrColonLoc, - bool GNUSyntax, - ExprResult Init); + bool GNUSyntax, ExprResult Init); private: static BinaryOperatorKind ConvertTokenKindToBinaryOpcode(tok::TokenKind Kind); public: - ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, - tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr); - ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, - BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr); + ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, tok::TokenKind Kind, + Expr *LHSExpr, Expr *RHSExpr); + ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, + Expr *LHSExpr, Expr *RHSExpr); ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr); void LookupBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, @@ -5878,8 +5725,8 @@ class Sema final { /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null /// in the case of a the GNU conditional expr extension. ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, - SourceLocation ColonLoc, - Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr); + SourceLocation ColonLoc, Expr *CondExpr, + Expr *LHSExpr, Expr *RHSExpr); /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo". ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, @@ -5897,7 +5744,7 @@ class Sema final { // __builtin_offsetof(type, identifier(.identifier|[expr])*) struct OffsetOfComponent { SourceLocation LocStart, LocEnd; - bool isBrackets; // true if [expr], false if .ident + bool isBrackets; // true if [expr], false if .ident union { IdentifierInfo *IdentInfo; Expr *E; @@ -5909,17 +5756,16 @@ class Sema final { TypeSourceInfo *TInfo, ArrayRef Components, SourceLocation RParenLoc); - ExprResult ActOnBuiltinOffsetOf(Scope *S, - SourceLocation BuiltinLoc, + ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, ArrayRef Components, SourceLocation RParenLoc); // __builtin_choose_expr(constExpr, expr1, expr2) - ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, - Expr *CondExpr, Expr *LHSExpr, - Expr *RHSExpr, SourceLocation RPLoc); + ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, + Expr *LHSExpr, Expr *RHSExpr, + SourceLocation RPLoc); // __builtin_va_arg(expr, type) ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, @@ -5964,10 +5810,10 @@ class Sema final { CheckMicrosoftIfExistsSymbol(Scope *S, CXXScopeSpec &SS, const DeclarationNameInfo &TargetNameInfo); - IfExistsResult - CheckMicrosoftIfExistsSymbol(Scope *S, SourceLocation KeywordLoc, - bool IsIfExists, CXXScopeSpec &SS, - UnqualifiedId &Name); + IfExistsResult CheckMicrosoftIfExistsSymbol(Scope *S, + SourceLocation KeywordLoc, + bool IsIfExists, CXXScopeSpec &SS, + UnqualifiedId &Name); StmtResult BuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, @@ -5975,9 +5821,8 @@ class Sema final { DeclarationNameInfo NameInfo, Stmt *Nested); StmtResult ActOnMSDependentExistsStmt(SourceLocation KeywordLoc, - bool IsIfExists, - CXXScopeSpec &SS, UnqualifiedId &Name, - Stmt *Nested); + bool IsIfExists, CXXScopeSpec &SS, + UnqualifiedId &Name, Stmt *Nested); //===------------------------- "Block" Extension ------------------------===// @@ -6096,12 +5941,9 @@ class Sema final { void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir); - Decl *ActOnNamespaceAliasDef(Scope *CurScope, - SourceLocation NamespaceLoc, - SourceLocation AliasLoc, - IdentifierInfo *Alias, - CXXScopeSpec &SS, - SourceLocation IdentLoc, + Decl *ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc, + SourceLocation AliasLoc, IdentifierInfo *Alias, + CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident); void FilterUsingLookup(Scope *S, LookupResult &lookup); @@ -6125,12 +5967,14 @@ class Sema final { const LookupResult *R = nullptr, const UsingDecl *UD = nullptr); - NamedDecl *BuildUsingDeclaration( - Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, - bool HasTypenameKeyword, SourceLocation TypenameLoc, CXXScopeSpec &SS, - DeclarationNameInfo NameInfo, SourceLocation EllipsisLoc, - const ParsedAttributesView &AttrList, bool IsInstantiation, - bool IsUsingIfExists); + NamedDecl *BuildUsingDeclaration(Scope *S, AccessSpecifier AS, + SourceLocation UsingLoc, + bool HasTypenameKeyword, + SourceLocation TypenameLoc, CXXScopeSpec &SS, + DeclarationNameInfo NameInfo, + SourceLocation EllipsisLoc, + const ParsedAttributesView &AttrList, + bool IsInstantiation, bool IsUsingIfExists); NamedDecl *BuildUsingEnumDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, @@ -6170,38 +6014,34 @@ class Sema final { /// \param ConstructKind - a CXXConstructExpr::ConstructionKind ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, - NamedDecl *FoundDecl, - CXXConstructorDecl *Constructor, MultiExprArg Exprs, - bool HadMultipleCandidates, bool IsListInitialization, - bool IsStdInitListInitialization, - bool RequiresZeroInit, unsigned ConstructKind, - SourceRange ParenRange); + NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, + MultiExprArg Exprs, bool HadMultipleCandidates, + bool IsListInitialization, + bool IsStdInitListInitialization, bool RequiresZeroInit, + unsigned ConstructKind, SourceRange ParenRange); /// Build a CXXConstructExpr whose constructor has already been resolved if /// it denotes an inherited constructor. ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, CXXConstructorDecl *Constructor, bool Elidable, - MultiExprArg Exprs, - bool HadMultipleCandidates, bool IsListInitialization, - bool IsStdInitListInitialization, - bool RequiresZeroInit, unsigned ConstructKind, - SourceRange ParenRange); + MultiExprArg Exprs, bool HadMultipleCandidates, + bool IsListInitialization, + bool IsStdInitListInitialization, bool RequiresZeroInit, + unsigned ConstructKind, SourceRange ParenRange); // FIXME: Can we remove this and have the above BuildCXXConstructExpr check if // the constructor can be elidable? ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, - NamedDecl *FoundDecl, - CXXConstructorDecl *Constructor, bool Elidable, - MultiExprArg Exprs, bool HadMultipleCandidates, - bool IsListInitialization, + NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, + bool Elidable, MultiExprArg Exprs, + bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, unsigned ConstructKind, SourceRange ParenRange); ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field); - /// Instantiate or parse a C++ default argument expression as necessary. /// Return true on error. bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, @@ -6209,8 +6049,7 @@ class Sema final { /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating /// the default expr if needed. - ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, - FunctionDecl *FD, + ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param); /// FinalizeVarWithDestructor - Prepare for calling destructor on the @@ -6239,7 +6078,7 @@ class Sema final { public: explicit ImplicitExceptionSpecification(Sema &Self) - : Self(&Self), ComputedEST(EST_BasicNoexcept) { + : Self(&Self), ComputedEST(EST_BasicNoexcept) { if (!Self.getLangOpts().CPlusPlus11) ComputedEST = EST_DynamicNone; } @@ -6278,8 +6117,8 @@ class Sema final { /// The exception-specification is noexcept(false) if the set of /// potential exceptions of the special member function contains "any" ESI.Type = EST_NoexceptFalse; - ESI.NoexceptExpr = Self->ActOnCXXBoolLiteral(SourceLocation(), - tok::kw_false).get(); + ESI.NoexceptExpr = + Self->ActOnCXXBoolLiteral(SourceLocation(), tok::kw_false).get(); } return ESI; } @@ -6311,12 +6150,10 @@ class Sema final { /// Add an exception-specification to the given member function /// (or member function template). The exception-specification was parsed /// after the method itself was declared. - void actOnDelayedExceptionSpecification(Decl *Method, - ExceptionSpecificationType EST, - SourceRange SpecificationRange, - ArrayRef DynamicExceptions, - ArrayRef DynamicExceptionRanges, - Expr *NoexceptExpr); + void actOnDelayedExceptionSpecification( + Decl *Method, ExceptionSpecificationType EST, + SourceRange SpecificationRange, ArrayRef DynamicExceptions, + ArrayRef DynamicExceptionRanges, Expr *NoexceptExpr); class InheritedConstructorInfo; @@ -6335,8 +6172,8 @@ class Sema final { /// default constructor will be added. /// /// \returns The implicitly-declared default constructor. - CXXConstructorDecl *DeclareImplicitDefaultConstructor( - CXXRecordDecl *ClassDecl); + CXXConstructorDecl * + DeclareImplicitDefaultConstructor(CXXRecordDecl *ClassDecl); /// DefineImplicitDefaultConstructor - Checks for feasibility of /// defining this constructor as the default constructor. @@ -6468,10 +6305,9 @@ class Sema final { ParsedType getConstructorName(IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, bool EnteringContext); - ParsedType getDestructorName(SourceLocation TildeLoc, - IdentifierInfo &II, SourceLocation NameLoc, - Scope *S, CXXScopeSpec &SS, - ParsedType ObjectType, + ParsedType getDestructorName(SourceLocation TildeLoc, IdentifierInfo &II, + SourceLocation NameLoc, Scope *S, + CXXScopeSpec &SS, ParsedType ObjectType, bool EnteringContext); ParsedType getDestructorTypeForDecltype(const DeclSpec &DS, @@ -6496,21 +6332,15 @@ class Sema final { /// ActOnCXXNamedCast - Parse /// {dynamic,static,reinterpret,const,addrspace}_cast's. - ExprResult ActOnCXXNamedCast(SourceLocation OpLoc, - tok::TokenKind Kind, - SourceLocation LAngleBracketLoc, - Declarator &D, + ExprResult ActOnCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, + SourceLocation LAngleBracketLoc, Declarator &D, SourceLocation RAngleBracketLoc, - SourceLocation LParenLoc, - Expr *E, + SourceLocation LParenLoc, Expr *E, SourceLocation RParenLoc); - ExprResult BuildCXXNamedCast(SourceLocation OpLoc, - tok::TokenKind Kind, - TypeSourceInfo *Ty, - Expr *E, - SourceRange AngleBrackets, - SourceRange Parens); + ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, + TypeSourceInfo *Ty, Expr *E, + SourceRange AngleBrackets, SourceRange Parens); ExprResult ActOnBuiltinBitCastExpr(SourceLocation KWLoc, Declarator &Dcl, ExprResult Operand, @@ -6519,34 +6349,24 @@ class Sema final { ExprResult BuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI, Expr *Operand, SourceLocation RParenLoc); - ExprResult BuildCXXTypeId(QualType TypeInfoType, - SourceLocation TypeidLoc, - TypeSourceInfo *Operand, - SourceLocation RParenLoc); - ExprResult BuildCXXTypeId(QualType TypeInfoType, - SourceLocation TypeidLoc, - Expr *Operand, - SourceLocation RParenLoc); + ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc, + TypeSourceInfo *Operand, SourceLocation RParenLoc); + ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc, + Expr *Operand, SourceLocation RParenLoc); /// ActOnCXXTypeid - Parse typeid( something ). - ExprResult ActOnCXXTypeid(SourceLocation OpLoc, - SourceLocation LParenLoc, bool isType, - void *TyOrExpr, + ExprResult ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc, + bool isType, void *TyOrExpr, SourceLocation RParenLoc); - ExprResult BuildCXXUuidof(QualType TypeInfoType, - SourceLocation TypeidLoc, - TypeSourceInfo *Operand, - SourceLocation RParenLoc); - ExprResult BuildCXXUuidof(QualType TypeInfoType, - SourceLocation TypeidLoc, - Expr *Operand, - SourceLocation RParenLoc); + ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc, + TypeSourceInfo *Operand, SourceLocation RParenLoc); + ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc, + Expr *Operand, SourceLocation RParenLoc); /// ActOnCXXUuidof - Parse __uuidof( something ). - ExprResult ActOnCXXUuidof(SourceLocation OpLoc, - SourceLocation LParenLoc, bool isType, - void *TyOrExpr, + ExprResult ActOnCXXUuidof(SourceLocation OpLoc, SourceLocation LParenLoc, + bool isType, void *TyOrExpr, SourceLocation RParenLoc); /// Handle a C++1z fold-expression: ( expr op ... op expr ). @@ -6613,8 +6433,8 @@ class Sema final { /// a nested generic lambda (depending on whether the name resolves to /// a non-static member function or a static function). /// \return returns 'true' if failed, 'false' if success. - bool CheckCXXThisCapture(SourceLocation Loc, bool Explicit = false, - bool BuildAndDiagnose = true, + bool CheckCXXThisCapture( + SourceLocation Loc, bool Explicit = false, bool BuildAndDiagnose = true, const unsigned *const FunctionScopeIndexToStopAt = nullptr, bool ByCopy = false); @@ -6626,7 +6446,6 @@ class Sema final { /// ActOnCXXBoolLiteral - Parse {true,false} literals. ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind); - /// ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals. ExprResult ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind); @@ -6666,16 +6485,12 @@ class Sema final { SourceLocation PlacementRParen, SourceRange TypeIdParens, Declarator &D, Expr *Initializer); - ExprResult BuildCXXNew(SourceRange Range, bool UseGlobal, - SourceLocation PlacementLParen, - MultiExprArg PlacementArgs, - SourceLocation PlacementRParen, - SourceRange TypeIdParens, - QualType AllocType, - TypeSourceInfo *AllocTypeInfo, - Optional ArraySize, - SourceRange DirectInitRange, - Expr *Initializer); + ExprResult + BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen, + MultiExprArg PlacementArgs, SourceLocation PlacementRParen, + SourceRange TypeIdParens, QualType AllocType, + TypeSourceInfo *AllocTypeInfo, Optional ArraySize, + SourceRange DirectInitRange, Expr *Initializer); /// Determine whether \p FD is an aligned allocation or deallocation /// function that is unavailable. @@ -6727,9 +6542,8 @@ class Sema final { CXXRecordDecl *RD); /// ActOnCXXDelete - Parsed a C++ 'delete' expression - ExprResult ActOnCXXDelete(SourceLocation StartLoc, - bool UseGlobal, bool ArrayForm, - Expr *Operand); + ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, + bool ArrayForm, Expr *Operand); void CheckVirtualDtorCall(CXXDestructorDecl *dtor, SourceLocation Loc, bool IsDelete, bool CallCanBeVirtual, bool WarnOnNonAbstractTypes, @@ -6750,60 +6564,43 @@ class Sema final { /// ActOnArrayTypeTrait - Parsed one of the binary type trait support /// pseudo-functions. - ExprResult ActOnArrayTypeTrait(ArrayTypeTrait ATT, - SourceLocation KWLoc, - ParsedType LhsTy, - Expr *DimExpr, + ExprResult ActOnArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc, + ParsedType LhsTy, Expr *DimExpr, SourceLocation RParen); - ExprResult BuildArrayTypeTrait(ArrayTypeTrait ATT, - SourceLocation KWLoc, - TypeSourceInfo *TSInfo, - Expr *DimExpr, + ExprResult BuildArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc, + TypeSourceInfo *TSInfo, Expr *DimExpr, SourceLocation RParen); /// ActOnExpressionTrait - Parsed one of the unary type trait support /// pseudo-functions. - ExprResult ActOnExpressionTrait(ExpressionTrait OET, - SourceLocation KWLoc, - Expr *Queried, - SourceLocation RParen); + ExprResult ActOnExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, + Expr *Queried, SourceLocation RParen); - ExprResult BuildExpressionTrait(ExpressionTrait OET, - SourceLocation KWLoc, - Expr *Queried, - SourceLocation RParen); + ExprResult BuildExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, + Expr *Queried, SourceLocation RParen); - ExprResult ActOnStartCXXMemberReference(Scope *S, - Expr *Base, + ExprResult ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, ParsedType &ObjectType, bool &MayBePseudoDestructor); - ExprResult BuildPseudoDestructorExpr(Expr *Base, - SourceLocation OpLoc, - tok::TokenKind OpKind, - const CXXScopeSpec &SS, - TypeSourceInfo *ScopeType, - SourceLocation CCLoc, - SourceLocation TildeLoc, - PseudoDestructorTypeStorage DestroyedType); + ExprResult BuildPseudoDestructorExpr( + Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, + const CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc, + SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType); - ExprResult ActOnPseudoDestructorExpr(Scope *S, Expr *Base, - SourceLocation OpLoc, - tok::TokenKind OpKind, - CXXScopeSpec &SS, - UnqualifiedId &FirstTypeName, - SourceLocation CCLoc, - SourceLocation TildeLoc, - UnqualifiedId &SecondTypeName); + ExprResult ActOnPseudoDestructorExpr( + Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, + CXXScopeSpec &SS, UnqualifiedId &FirstTypeName, SourceLocation CCLoc, + SourceLocation TildeLoc, UnqualifiedId &SecondTypeName); ExprResult ActOnPseudoDestructorExpr(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, SourceLocation TildeLoc, - const DeclSpec& DS); + const DeclSpec &DS); /// MaybeCreateExprWithCleanups - If the current full-expression /// requires any cleanups, surround it with a ExprWithCleanups node. @@ -6881,25 +6678,22 @@ class Sema final { /// Creates info object for the most typical case. NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, - SourceLocation ColonColonLoc, ParsedType ObjectType = ParsedType()) - : ObjectType(ObjectType), Identifier(II), IdentifierLoc(IdLoc), - CCLoc(ColonColonLoc) { - } + SourceLocation ColonColonLoc, + ParsedType ObjectType = ParsedType()) + : ObjectType(ObjectType), Identifier(II), IdentifierLoc(IdLoc), + CCLoc(ColonColonLoc) {} NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, QualType ObjectType) - : ObjectType(ParsedType::make(ObjectType)), Identifier(II), - IdentifierLoc(IdLoc), CCLoc(ColonColonLoc) { - } + : ObjectType(ParsedType::make(ObjectType)), Identifier(II), + IdentifierLoc(IdLoc), CCLoc(ColonColonLoc) {} }; bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS, NestedNameSpecInfo &IdInfo); - bool BuildCXXNestedNameSpecifier(Scope *S, - NestedNameSpecInfo &IdInfo, - bool EnteringContext, - CXXScopeSpec &SS, + bool BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, + bool EnteringContext, CXXScopeSpec &SS, NamedDecl *ScopeLookupResult, bool ErrorRecoveryLookup, bool *IsCorrectedToColon = nullptr, @@ -6927,17 +6721,14 @@ class Sema final { /// \param OnlyNamespace If true, only considers namespaces in lookup. /// /// \returns true if an error occurred, false otherwise. - bool ActOnCXXNestedNameSpecifier(Scope *S, - NestedNameSpecInfo &IdInfo, - bool EnteringContext, - CXXScopeSpec &SS, + bool ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, + bool EnteringContext, CXXScopeSpec &SS, bool *IsCorrectedToColon = nullptr, bool OnlyNamespace = false); ExprResult ActOnDecltypeExpression(Expr *E); - bool ActOnCXXNestedNameSpecifierDecltype(CXXScopeSpec &SS, - const DeclSpec &DS, + bool ActOnCXXNestedNameSpecifierDecltype(CXXScopeSpec &SS, const DeclSpec &DS, SourceLocation ColonColonLoc); bool IsInvalidUnlessNestedName(Scope *S, CXXScopeSpec &SS, @@ -6967,16 +6758,11 @@ class Sema final { /// /// /// \returns true if an error occurred, false otherwise. - bool ActOnCXXNestedNameSpecifier(Scope *S, - CXXScopeSpec &SS, - SourceLocation TemplateKWLoc, - TemplateTy TemplateName, - SourceLocation TemplateNameLoc, - SourceLocation LAngleLoc, - ASTTemplateArgsPtr TemplateArgs, - SourceLocation RAngleLoc, - SourceLocation CCLoc, - bool EnteringContext); + bool ActOnCXXNestedNameSpecifier( + Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, + TemplateTy TemplateName, SourceLocation TemplateNameLoc, + SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, + SourceLocation RAngleLoc, SourceLocation CCLoc, bool EnteringContext); /// Given a C++ nested-name-specifier, produce an annotation value /// that the parser can use later to reconstruct the given @@ -7050,14 +6836,11 @@ class Sema final { Optional> Mangling = None); /// Endow the lambda scope info with the relevant properties. - void buildLambdaScope(sema::LambdaScopeInfo *LSI, - CXXMethodDecl *CallOperator, + void buildLambdaScope(sema::LambdaScopeInfo *LSI, CXXMethodDecl *CallOperator, SourceRange IntroducerRange, LambdaCaptureDefault CaptureDefault, - SourceLocation CaptureDefaultLoc, - bool ExplicitParams, - bool ExplicitResultType, - bool Mutable); + SourceLocation CaptureDefaultLoc, bool ExplicitParams, + bool ExplicitResultType, bool Mutable); /// Perform initialization analysis of the init-capture and perform /// any implicit conversions such as an lvalue-to-rvalue conversion if @@ -7100,9 +6883,8 @@ class Sema final { ExprResult RequiresClause); /// Introduce the lambda parameters into scope. - void addLambdaParameters( - ArrayRef Captures, - CXXMethodDecl *CallOperator, Scope *CurScope); + void addLambdaParameters(ArrayRef Captures, + CXXMethodDecl *CallOperator, Scope *CurScope); /// Deduce a block or lambda's return type based on the return /// statements present in the body. @@ -7159,8 +6941,9 @@ class Sema final { /// in the initialization expression needed to copy the lambda object into /// the block, and IR generation actually generates the real body of the /// block pointer conversion. - void DefineImplicitLambdaToFunctionPointerConversion( - SourceLocation CurrentLoc, CXXConversionDecl *Conv); + void + DefineImplicitLambdaToFunctionPointerConversion(SourceLocation CurrentLoc, + CXXConversionDecl *Conv); /// Define the "body" of the conversion from a lambda object to a /// block pointer. @@ -7174,8 +6957,7 @@ class Sema final { ExprResult BuildBlockForLambdaConversion(SourceLocation CurrentLocation, SourceLocation ConvLocation, - CXXConversionDecl *Conv, - Expr *Src); + CXXConversionDecl *Conv, Expr *Src); /// Check whether the given expression is a valid constraint expression. /// A diagnostic is emitted if it is not, false is returned, and @@ -7194,8 +6976,7 @@ class Sema final { /// constrained declarations). If an error occurred while normalizing the /// associated constraints of the template or concept, nullptr will be cached /// here. - llvm::DenseMap - NormalizationCache; + llvm::DenseMap NormalizationCache; llvm::ContextualFoldingSet SatisfactionCache; @@ -7224,8 +7005,7 @@ class Sema final { LocalInstantiationScope &Scope); public: - const NormalizedConstraint * - getNormalizedAssociatedConstraints( + const NormalizedConstraint *getNormalizedAssociatedConstraints( NamedDecl *ConstrainedDecl, ArrayRef AssociatedConstraints); /// \brief Check whether the given declaration's associated constraints are @@ -7244,8 +7024,9 @@ class Sema final { /// of atomic constraints involved had been declared in a concept and not /// repeated in two separate places in code. /// \returns true if such a diagnostic was emitted, false otherwise. - bool MaybeEmitAmbiguousAtomicConstraintsDiagnostic(NamedDecl *D1, - ArrayRef AC1, NamedDecl *D2, ArrayRef AC2); + bool MaybeEmitAmbiguousAtomicConstraintsDiagnostic( + NamedDecl *D1, ArrayRef AC1, NamedDecl *D2, + ArrayRef AC2); /// \brief Check whether the given list of constraint expressions are /// satisfied (as if in a 'conjunction') given template arguments. @@ -7342,9 +7123,8 @@ class Sema final { /// unsatisfied. /// \param First whether this is the first time an unsatisfied constraint is /// diagnosed for this error. - void - DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction, - bool First = true); + void DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction, + bool First = true); /// \brief Emit diagnostics explaining why a constraint expression was deemed /// unsatisfied. @@ -7378,32 +7158,31 @@ class Sema final { ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod); - ExprResult BuildObjCDictionaryLiteral(SourceRange SR, - MutableArrayRef Elements); + ExprResult + BuildObjCDictionaryLiteral(SourceRange SR, + MutableArrayRef Elements); ExprResult BuildObjCEncodeExpression(SourceLocation AtLoc, - TypeSourceInfo *EncodedTypeInfo, - SourceLocation RParenLoc); + TypeSourceInfo *EncodedTypeInfo, + SourceLocation RParenLoc); ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates); ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc, SourceLocation EncodeLoc, - SourceLocation LParenLoc, - ParsedType Ty, + SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc); /// ParseObjCSelectorExpression - Build selector expression for \@selector - ExprResult ParseObjCSelectorExpression(Selector Sel, - SourceLocation AtLoc, + ExprResult ParseObjCSelectorExpression(Selector Sel, SourceLocation AtLoc, SourceLocation SelLoc, SourceLocation LParenLoc, SourceLocation RParenLoc, bool WarnMultipleSelectors); /// ParseObjCProtocolExpression - Build protocol expression for \@protocol - ExprResult ParseObjCProtocolExpression(IdentifierInfo * ProtocolName, + ExprResult ParseObjCProtocolExpression(IdentifierInfo *ProtocolName, SourceLocation AtLoc, SourceLocation ProtoLoc, SourceLocation LParenLoc, @@ -7413,15 +7192,11 @@ class Sema final { //===--------------------------------------------------------------------===// // C++ Declarations // - Decl *ActOnStartLinkageSpecification(Scope *S, - SourceLocation ExternLoc, - Expr *LangStr, - SourceLocation LBraceLoc); - Decl *ActOnFinishLinkageSpecification(Scope *S, - Decl *LinkageSpec, + Decl *ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, + Expr *LangStr, SourceLocation LBraceLoc); + Decl *ActOnFinishLinkageSpecification(Scope *S, Decl *LinkageSpec, SourceLocation RBraceLoc); - //===--------------------------------------------------------------------===// // C++ Classes // @@ -7434,61 +7209,47 @@ class Sema final { SourceLocation ColonLoc, const ParsedAttributesView &Attrs); - NamedDecl *ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, - Declarator &D, - MultiTemplateParamsArg TemplateParameterLists, - Expr *BitfieldWidth, const VirtSpecifiers &VS, - InClassInitStyle InitStyle); + NamedDecl * + ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, + MultiTemplateParamsArg TemplateParameterLists, + Expr *BitfieldWidth, const VirtSpecifiers &VS, + InClassInitStyle InitStyle); void ActOnStartCXXInClassMemberInitializer(); void ActOnFinishCXXInClassMemberInitializer(Decl *VarDecl, SourceLocation EqualLoc, Expr *Init); - MemInitResult ActOnMemInitializer(Decl *ConstructorD, - Scope *S, - CXXScopeSpec &SS, - IdentifierInfo *MemberOrBase, - ParsedType TemplateTypeTy, - const DeclSpec &DS, - SourceLocation IdLoc, - SourceLocation LParenLoc, - ArrayRef Args, - SourceLocation RParenLoc, - SourceLocation EllipsisLoc); + MemInitResult + ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, + IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, + const DeclSpec &DS, SourceLocation IdLoc, + SourceLocation LParenLoc, ArrayRef Args, + SourceLocation RParenLoc, SourceLocation EllipsisLoc); - MemInitResult ActOnMemInitializer(Decl *ConstructorD, - Scope *S, + MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, - const DeclSpec &DS, - SourceLocation IdLoc, - Expr *InitList, - SourceLocation EllipsisLoc); + const DeclSpec &DS, SourceLocation IdLoc, + Expr *InitList, SourceLocation EllipsisLoc); - MemInitResult BuildMemInitializer(Decl *ConstructorD, - Scope *S, + MemInitResult BuildMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, - const DeclSpec &DS, - SourceLocation IdLoc, - Expr *Init, - SourceLocation EllipsisLoc); + const DeclSpec &DS, SourceLocation IdLoc, + Expr *Init, SourceLocation EllipsisLoc); - MemInitResult BuildMemberInitializer(ValueDecl *Member, - Expr *Init, + MemInitResult BuildMemberInitializer(ValueDecl *Member, Expr *Init, SourceLocation IdLoc); MemInitResult BuildBaseInitializer(QualType BaseType, - TypeSourceInfo *BaseTInfo, - Expr *Init, + TypeSourceInfo *BaseTInfo, Expr *Init, CXXRecordDecl *ClassDecl, SourceLocation EllipsisLoc); - MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo, - Expr *Init, + MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init, CXXRecordDecl *ClassDecl); bool SetDelegatingInitializer(CXXConstructorDecl *Constructor, @@ -7499,7 +7260,6 @@ class Sema final { void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation); - /// MarkBaseAndMemberDestructorsReferenced - Given a record decl, /// mark all the non-trivial destructors of its members and bases as /// referenced. @@ -7525,7 +7285,7 @@ class Sema final { /// The list of classes whose vtables have been used within /// this translation unit, and the source locations at which the /// first use occurred. - typedef std::pair VTableUse; + typedef std::pair VTableUse; /// The list of vtables that are required but have not yet been /// materialized. @@ -7564,9 +7324,8 @@ class Sema final { void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl); - void ActOnMemInitializers(Decl *ConstructorDecl, - SourceLocation ColonLoc, - ArrayRef MemInits, + void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc, + ArrayRef MemInits, bool AnyErrors); /// Check class-level dllimport/dllexport attribute. The caller must @@ -7621,14 +7380,12 @@ class Sema final { bool IsInsideALocalClassWithinATemplateFunction(); Decl *ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc, - Expr *AssertExpr, - Expr *AssertMessageExpr, + Expr *AssertExpr, Expr *AssertMessageExpr, SourceLocation RParenLoc); Decl *BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *AssertMessageExpr, - SourceLocation RParenLoc, - bool Failed); + SourceLocation RParenLoc, bool Failed); void DiagnoseStaticAssertDetails(const Expr *E); FriendDecl *CheckFriendTypeDecl(SourceLocation LocStart, @@ -7640,13 +7397,12 @@ class Sema final { MultiTemplateParamsArg TemplateParams); QualType CheckConstructorDeclarator(Declarator &D, QualType R, - StorageClass& SC); + StorageClass &SC); void CheckConstructor(CXXConstructorDecl *Constructor); QualType CheckDestructorDeclarator(Declarator &D, QualType R, - StorageClass& SC); + StorageClass &SC); bool CheckDestructor(CXXDestructorDecl *Destructor); - void CheckConversionDeclarator(Declarator &D, QualType &R, - StorageClass& SC); + void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC); Decl *ActOnConversionDeclarator(CXXConversionDecl *Conversion); void CheckDeductionGuideDeclarator(Declarator &D, QualType &R, StorageClass &SC); @@ -7672,8 +7428,8 @@ class Sema final { /// ActOnBaseSpecifier - Parsed a base specifier CXXBaseSpecifier *CheckBaseSpecifier(CXXRecordDecl *Class, - SourceRange SpecifierRange, - bool Virtual, AccessSpecifier Access, + SourceRange SpecifierRange, bool Virtual, + AccessSpecifier Access, TypeSourceInfo *TInfo, SourceLocation EllipsisLoc); @@ -7703,8 +7459,7 @@ class Sema final { unsigned InaccessibleBaseID, unsigned AmbiguousBaseConvID, SourceLocation Loc, SourceRange Range, - DeclarationName Name, - CXXCastPath *BasePath, + DeclarationName Name, CXXCastPath *BasePath, bool IgnoreAccess = false); std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths); @@ -7737,7 +7492,6 @@ class Sema final { bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New, const CXXMethodDecl *Old); - //===--------------------------------------------------------------------===// // C++ Access Control // @@ -7762,13 +7516,11 @@ class Sema final { CXXRecordDecl *NamingClass, DeclAccessPair FoundDecl, bool Diagnose = true); - AccessResult CheckConstructorAccess(SourceLocation Loc, - CXXConstructorDecl *D, + AccessResult CheckConstructorAccess(SourceLocation Loc, CXXConstructorDecl *D, DeclAccessPair FoundDecl, const InitializedEntity &Entity, bool IsCopyBindingRefToTemp = false); - AccessResult CheckConstructorAccess(SourceLocation Loc, - CXXConstructorDecl *D, + AccessResult CheckConstructorAccess(SourceLocation Loc, CXXConstructorDecl *D, DeclAccessPair FoundDecl, const InitializedEntity &Entity, const PartialDiagnostic &PDiag); @@ -7787,8 +7539,7 @@ class Sema final { AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, const SourceRange &, DeclAccessPair FoundDecl); - AccessResult CheckMemberOperatorAccess(SourceLocation Loc, - Expr *ObjectExpr, + AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, Expr *ArgExpr, DeclAccessPair FoundDecl); AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, @@ -7796,11 +7547,9 @@ class Sema final { DeclAccessPair FoundDecl); AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr, DeclAccessPair FoundDecl); - AccessResult CheckBaseClassAccess(SourceLocation AccessLoc, - QualType Base, QualType Derived, - const CXXBasePath &Path, - unsigned DiagID, - bool ForceCheck = false, + AccessResult CheckBaseClassAccess(SourceLocation AccessLoc, QualType Base, + QualType Derived, const CXXBasePath &Path, + unsigned DiagID, bool ForceCheck = false, bool ForceUnprivileged = false); void CheckLookupAccess(const LookupResult &R); bool IsSimplyAccessible(NamedDecl *Decl, CXXRecordDecl *NamingClass, @@ -7816,10 +7565,12 @@ class Sema final { SourceLocation(), PDiag()); } - void HandleDependentAccessCheck(const DependentDiagnostic &DD, - const MultiLevelTemplateArgumentList &TemplateArgs); - void PerformDependentDiagnostics(const DeclContext *Pattern, - const MultiLevelTemplateArgumentList &TemplateArgs); + void HandleDependentAccessCheck( + const DependentDiagnostic &DD, + const MultiLevelTemplateArgumentList &TemplateArgs); + void PerformDependentDiagnostics( + const DeclContext *Pattern, + const MultiLevelTemplateArgumentList &TemplateArgs); void HandleDelayedAccessCheck(sema::DelayedDiagnostic &DD, Decl *Ctx); @@ -7892,7 +7643,9 @@ class Sema final { SourceLocation getTemplateKeywordLoc() const { return TemplateKW.value_or(SourceLocation()); } - bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); } + bool hasTemplateKeyword() const { + return getTemplateKeywordLoc().isValid(); + } bool isRequired() const { return TemplateKW != SourceLocation(); } explicit operator bool() const { return isRequired(); } @@ -7915,12 +7668,10 @@ class Sema final { RequiredTemplateKind RequiredTemplate = SourceLocation(), AssumedTemplateKind *ATK = nullptr, bool AllowTypoCorrection = true); - TemplateNameKind isTemplateName(Scope *S, - CXXScopeSpec &SS, + TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, const UnqualifiedId &Name, - ParsedType ObjectType, - bool EnteringContext, + ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization, bool Disambiguation = false); @@ -7946,8 +7697,7 @@ class Sema final { ParsedTemplateTy *Template = nullptr); bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, - SourceLocation IILoc, - Scope *S, + SourceLocation IILoc, Scope *S, const CXXScopeSpec *SS, TemplateTy &SuggestedTemplate, TemplateNameKind &SuggestedKind); @@ -7967,9 +7717,8 @@ class Sema final { SourceLocation EllipsisLoc, SourceLocation KeyLoc, IdentifierInfo *ParamName, - SourceLocation ParamNameLoc, - unsigned Depth, unsigned Position, - SourceLocation EqualLoc, + SourceLocation ParamNameLoc, unsigned Depth, + unsigned Position, SourceLocation EqualLoc, ParsedType DefaultArg, bool HasTypeConstraint); bool ActOnTypeConstraint(const CXXScopeSpec &SS, @@ -8000,29 +7749,19 @@ class Sema final { QualType CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc); NamedDecl *ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, - unsigned Depth, - unsigned Position, - SourceLocation EqualLoc, - Expr *DefaultArg); - NamedDecl *ActOnTemplateTemplateParameter(Scope *S, - SourceLocation TmpLoc, - TemplateParameterList *Params, - SourceLocation EllipsisLoc, - IdentifierInfo *ParamName, - SourceLocation ParamNameLoc, - unsigned Depth, - unsigned Position, - SourceLocation EqualLoc, - ParsedTemplateArgument DefaultArg); - - TemplateParameterList * - ActOnTemplateParameterList(unsigned Depth, - SourceLocation ExportLoc, - SourceLocation TemplateLoc, - SourceLocation LAngleLoc, - ArrayRef Params, - SourceLocation RAngleLoc, - Expr *RequiresClause); + unsigned Depth, unsigned Position, + SourceLocation EqualLoc, + Expr *DefaultArg); + NamedDecl *ActOnTemplateTemplateParameter( + Scope *S, SourceLocation TmpLoc, TemplateParameterList *Params, + SourceLocation EllipsisLoc, IdentifierInfo *ParamName, + SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, + SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg); + + TemplateParameterList *ActOnTemplateParameterList( + unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, + SourceLocation LAngleLoc, ArrayRef Params, + SourceLocation RAngleLoc, Expr *RequiresClause); /// The context in which we are checking a template parameter list. enum TemplateParamListContext { @@ -8043,8 +7782,8 @@ class Sema final { TemplateParameterList *MatchTemplateParametersToScopeSpecifier( SourceLocation DeclStartLoc, SourceLocation DeclLoc, const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId, - ArrayRef ParamLists, - bool IsFriend, bool &IsMemberSpecialization, bool &Invalid, + ArrayRef ParamLists, bool IsFriend, + bool &IsMemberSpecialization, bool &Invalid, bool SuppressDiagnostic = false); DeclResult CheckClassTemplate( @@ -8075,7 +7814,7 @@ class Sema final { QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, - TemplateArgumentListInfo &TemplateArgs); + TemplateArgumentListInfo &TemplateArgs); TypeResult ActOnTemplateIdType(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, @@ -8088,21 +7827,17 @@ class Sema final { /// Parsed an elaborated-type-specifier that refers to a template-id, /// such as \c class T::template apply. - TypeResult ActOnTagTemplateIdType(TagUseKind TUK, - TypeSpecifierType TagSpec, - SourceLocation TagLoc, - CXXScopeSpec &SS, - SourceLocation TemplateKWLoc, - TemplateTy TemplateD, - SourceLocation TemplateLoc, - SourceLocation LAngleLoc, - ASTTemplateArgsPtr TemplateArgsIn, - SourceLocation RAngleLoc); - - DeclResult ActOnVarTemplateSpecialization( - Scope *S, Declarator &D, TypeSourceInfo *DI, - SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams, - StorageClass SC, bool IsPartialSpecialization); + TypeResult ActOnTagTemplateIdType( + TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc, + CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD, + SourceLocation TemplateLoc, SourceLocation LAngleLoc, + ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc); + + DeclResult + ActOnVarTemplateSpecialization(Scope *S, Declarator &D, TypeSourceInfo *DI, + SourceLocation TemplateKWLoc, + TemplateParameterList *TemplateParams, + StorageClass SC, bool IsPartialSpecialization); /// Get the specialization of the given variable template corresponding to /// the specified argument list, or a null-but-valid result if the arguments @@ -8122,8 +7857,7 @@ class Sema final { const TemplateArgumentListInfo *TemplateArgs); ExprResult - CheckConceptTemplateId(const CXXScopeSpec &SS, - SourceLocation TemplateKWLoc, + CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs); @@ -8131,20 +7865,21 @@ class Sema final { void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc); ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, - SourceLocation TemplateKWLoc, - LookupResult &R, + SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, - const TemplateArgumentListInfo *TemplateArgs); + const TemplateArgumentListInfo *TemplateArgs); - ExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS, - SourceLocation TemplateKWLoc, + ExprResult + BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs); - TemplateNameKind ActOnTemplateName( - Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, - const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, - TemplateTy &Template, bool AllowInjectedClassName = false); + TemplateNameKind ActOnTemplateName(Scope *S, CXXScopeSpec &SS, + SourceLocation TemplateKWLoc, + const UnqualifiedId &Name, + ParsedType ObjectType, + bool EnteringContext, TemplateTy &Template, + bool AllowInjectedClassName = false); DeclResult ActOnClassTemplateSpecialization( Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, @@ -8166,17 +7901,14 @@ class Sema final { MultiTemplateParamsArg TemplateParameterLists, Declarator &D); - bool - CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, - TemplateSpecializationKind NewTSK, - NamedDecl *PrevDecl, - TemplateSpecializationKind PrevTSK, - SourceLocation PrevPtOfInstantiation, - bool &SuppressNew); + bool CheckSpecializationInstantiationRedecl( + SourceLocation NewLoc, TemplateSpecializationKind NewTSK, + NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK, + SourceLocation PrevPtOfInstantiation, bool &SuppressNew); - bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD, - const TemplateArgumentListInfo &ExplicitTemplateArgs, - LookupResult &Previous); + bool CheckDependentFunctionTemplateSpecialization( + FunctionDecl *FD, const TemplateArgumentListInfo &ExplicitTemplateArgs, + LookupResult &Previous); bool CheckFunctionTemplateSpecialization( FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, @@ -8198,19 +7930,14 @@ class Sema final { SourceLocation NameLoc, const ParsedAttributesView &Attr); - DeclResult ActOnExplicitInstantiation(Scope *S, - SourceLocation ExternLoc, + DeclResult ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc, Declarator &D); - TemplateArgumentLoc - SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, - SourceLocation TemplateLoc, - SourceLocation RAngleLoc, - Decl *Param, - SmallVectorImpl - &Converted, - bool &HasDefaultArg); + TemplateArgumentLoc SubstDefaultTemplateArgumentIfAvailable( + TemplateDecl *Template, SourceLocation TemplateLoc, + SourceLocation RAngleLoc, Decl *Param, + SmallVectorImpl &Converted, bool &HasDefaultArg); /// Specifies the context in which a particular template /// argument is being checked. @@ -8228,13 +7955,11 @@ class Sema final { CTAK_DeducedFromArrayBound }; - bool CheckTemplateArgument(NamedDecl *Param, - TemplateArgumentLoc &Arg, - NamedDecl *Template, - SourceLocation TemplateLoc, + bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, + NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, - SmallVectorImpl &Converted, + SmallVectorImpl &Converted, CheckTemplateArgumentKind CTAK = CTAK_Specified); /// Check that the given template arguments can be be provided to @@ -8276,21 +8001,20 @@ class Sema final { bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param, TemplateArgumentLoc &Arg, - SmallVectorImpl &Converted); + SmallVectorImpl &Converted); bool CheckTemplateArgument(TypeSourceInfo *Arg); - ExprResult CheckTemplateArgument(NonTypeTemplateParmDecl *Param, - QualType InstantiatedParamType, Expr *Arg, - TemplateArgument &Converted, - CheckTemplateArgumentKind CTAK = CTAK_Specified); + ExprResult + CheckTemplateArgument(NonTypeTemplateParmDecl *Param, + QualType InstantiatedParamType, Expr *Arg, + TemplateArgument &Converted, + CheckTemplateArgumentKind CTAK = CTAK_Specified); bool CheckTemplateTemplateArgument(TemplateTemplateParmDecl *Param, TemplateParameterList *Params, TemplateArgumentLoc &Arg); - ExprResult - BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, - QualType ParamType, - SourceLocation Loc); + ExprResult BuildExpressionFromDeclTemplateArgument( + const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc); ExprResult BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc); @@ -8378,39 +8102,31 @@ class Sema final { /// \param RAngleLoc The location of the closing angle bracket ('>'). TypeResult ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, - const CXXScopeSpec &SS, - SourceLocation TemplateLoc, - TemplateTy TemplateName, - IdentifierInfo *TemplateII, - SourceLocation TemplateIILoc, - SourceLocation LAngleLoc, - ASTTemplateArgsPtr TemplateArgs, - SourceLocation RAngleLoc); + const CXXScopeSpec &SS, SourceLocation TemplateLoc, + TemplateTy TemplateName, IdentifierInfo *TemplateII, + SourceLocation TemplateIILoc, SourceLocation LAngleLoc, + ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc); QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, - const IdentifierInfo &II, - SourceLocation IILoc, - TypeSourceInfo **TSI, - bool DeducedTSTContext); + const IdentifierInfo &II, SourceLocation IILoc, + TypeSourceInfo **TSI, bool DeducedTSTContext); QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, - const IdentifierInfo &II, - SourceLocation IILoc, + const IdentifierInfo &II, SourceLocation IILoc, bool DeducedTSTContext = true); - TypeSourceInfo *RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name); bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS); ExprResult RebuildExprInCurrentInstantiation(Expr *E); - bool RebuildTemplateParamsInCurrentInstantiation( - TemplateParameterList *Params); + bool + RebuildTemplateParamsInCurrentInstantiation(TemplateParameterList *Params); std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, @@ -8424,9 +8140,10 @@ class Sema final { //===--------------------------------------------------------------------===// // C++ Concepts //===--------------------------------------------------------------------===// - Decl *ActOnConceptDefinition( - Scope *S, MultiTemplateParamsArg TemplateParameterLists, - IdentifierInfo *Name, SourceLocation NameLoc, Expr *ConstraintExpr); + Decl *ActOnConceptDefinition(Scope *S, + MultiTemplateParamsArg TemplateParameterLists, + IdentifierInfo *Name, SourceLocation NameLoc, + Expr *ConstraintExpr); void CheckConceptRedefinition(ConceptDecl *NewDecl, LookupResult &Previous, bool &AddToScope); @@ -8437,32 +8154,29 @@ class Sema final { Scope *BodyScope); void ActOnFinishRequiresExpr(); concepts::Requirement *ActOnSimpleRequirement(Expr *E); - concepts::Requirement *ActOnTypeRequirement( - SourceLocation TypenameKWLoc, CXXScopeSpec &SS, SourceLocation NameLoc, - IdentifierInfo *TypeName, TemplateIdAnnotation *TemplateId); + concepts::Requirement *ActOnTypeRequirement(SourceLocation TypenameKWLoc, + CXXScopeSpec &SS, + SourceLocation NameLoc, + IdentifierInfo *TypeName, + TemplateIdAnnotation *TemplateId); concepts::Requirement *ActOnCompoundRequirement(Expr *E, SourceLocation NoexceptLoc); - concepts::Requirement * - ActOnCompoundRequirement( + concepts::Requirement *ActOnCompoundRequirement( Expr *E, SourceLocation NoexceptLoc, CXXScopeSpec &SS, TemplateIdAnnotation *TypeConstraint, unsigned Depth); concepts::Requirement *ActOnNestedRequirement(Expr *Constraint); - concepts::ExprRequirement * - BuildExprRequirement( + concepts::ExprRequirement *BuildExprRequirement( Expr *E, bool IsSatisfied, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement ReturnTypeRequirement); - concepts::ExprRequirement * - BuildExprRequirement( + concepts::ExprRequirement *BuildExprRequirement( concepts::Requirement::SubstitutionDiagnostic *ExprSubstDiag, bool IsSatisfied, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement ReturnTypeRequirement); concepts::TypeRequirement *BuildTypeRequirement(TypeSourceInfo *Type); - concepts::TypeRequirement * - BuildTypeRequirement( + concepts::TypeRequirement *BuildTypeRequirement( concepts::Requirement::SubstitutionDiagnostic *SubstDiag); concepts::NestedRequirement *BuildNestedRequirement(Expr *E); - concepts::NestedRequirement * - BuildNestedRequirement( + concepts::NestedRequirement *BuildNestedRequirement( concepts::Requirement::SubstitutionDiagnostic *SubstDiag); ExprResult ActOnRequiresExpr(SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, @@ -8564,9 +8278,9 @@ class Sema final { /// \param Unexpanded the set of unexpanded parameter packs. /// /// \returns true if an error occurred, false otherwise. - bool DiagnoseUnexpandedParameterPacks(SourceLocation Loc, - UnexpandedParameterPackContext UPPC, - ArrayRef Unexpanded); + bool DiagnoseUnexpandedParameterPacks( + SourceLocation Loc, UnexpandedParameterPackContext UPPC, + ArrayRef Unexpanded); /// If the given type contains an unexpanded parameter pack, /// diagnose the error. @@ -8587,8 +8301,8 @@ class Sema final { /// parameter packs. /// /// \returns true if an error occurred, false otherwise. - bool DiagnoseUnexpandedParameterPack(Expr *E, - UnexpandedParameterPackContext UPPC = UPPC_Expression); + bool DiagnoseUnexpandedParameterPack( + Expr *E, UnexpandedParameterPackContext UPPC = UPPC_Expression); /// If the given requirees-expression contains an unexpanded reference to one /// of its own parameter packs, diagnose the error. @@ -8647,48 +8361,52 @@ class Sema final { /// /// \param Arg The template argument that will be traversed to find /// unexpanded parameter packs. - void collectUnexpandedParameterPacks(TemplateArgument Arg, - SmallVectorImpl &Unexpanded); + void collectUnexpandedParameterPacks( + TemplateArgument Arg, + SmallVectorImpl &Unexpanded); /// Collect the set of unexpanded parameter packs within the given /// template argument. /// /// \param Arg The template argument that will be traversed to find /// unexpanded parameter packs. - void collectUnexpandedParameterPacks(TemplateArgumentLoc Arg, - SmallVectorImpl &Unexpanded); + void collectUnexpandedParameterPacks( + TemplateArgumentLoc Arg, + SmallVectorImpl &Unexpanded); /// Collect the set of unexpanded parameter packs within the given /// type. /// /// \param T The type that will be traversed to find /// unexpanded parameter packs. - void collectUnexpandedParameterPacks(QualType T, - SmallVectorImpl &Unexpanded); + void collectUnexpandedParameterPacks( + QualType T, SmallVectorImpl &Unexpanded); /// Collect the set of unexpanded parameter packs within the given /// type. /// /// \param TL The type that will be traversed to find /// unexpanded parameter packs. - void collectUnexpandedParameterPacks(TypeLoc TL, - SmallVectorImpl &Unexpanded); + void collectUnexpandedParameterPacks( + TypeLoc TL, SmallVectorImpl &Unexpanded); /// Collect the set of unexpanded parameter packs within the given /// nested-name-specifier. /// /// \param NNS The nested-name-specifier that will be traversed to find /// unexpanded parameter packs. - void collectUnexpandedParameterPacks(NestedNameSpecifierLoc NNS, - SmallVectorImpl &Unexpanded); + void collectUnexpandedParameterPacks( + NestedNameSpecifierLoc NNS, + SmallVectorImpl &Unexpanded); /// Collect the set of unexpanded parameter packs within the given /// name. /// /// \param NameInfo The name that will be traversed to find /// unexpanded parameter packs. - void collectUnexpandedParameterPacks(const DeclarationNameInfo &NameInfo, - SmallVectorImpl &Unexpanded); + void collectUnexpandedParameterPacks( + const DeclarationNameInfo &NameInfo, + SmallVectorImpl &Unexpanded); /// Invoked when parsing a template argument followed by an /// ellipsis, which creates a pack expansion. @@ -8717,8 +8435,7 @@ class Sema final { /// Construct a pack expansion type from the pattern of the pack /// expansion. - QualType CheckPackExpansion(QualType Pattern, - SourceRange PatternRange, + QualType CheckPackExpansion(QualType Pattern, SourceRange PatternRange, SourceLocation EllipsisLoc, Optional NumExpansions); @@ -8775,13 +8492,11 @@ class Sema final { /// are to be instantiated with arguments of different lengths), false /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions) /// must be set. - bool CheckParameterPacksForExpansion(SourceLocation EllipsisLoc, - SourceRange PatternRange, - ArrayRef Unexpanded, - const MultiLevelTemplateArgumentList &TemplateArgs, - bool &ShouldExpand, - bool &RetainExpansion, - Optional &NumExpansions); + bool CheckParameterPacksForExpansion( + SourceLocation EllipsisLoc, SourceRange PatternRange, + ArrayRef Unexpanded, + const MultiLevelTemplateArgumentList &TemplateArgs, bool &ShouldExpand, + bool &RetainExpansion, Optional &NumExpansions); /// Determine the number of arguments in the given pack expansion /// type. @@ -8790,8 +8505,8 @@ class Sema final { /// consistent across all of the unexpanded parameter packs in its pattern. /// /// Returns an empty Optional if the type can't be expanded. - Optional getNumArgumentsInExpansion(QualType T, - const MultiLevelTemplateArgumentList &TemplateArgs); + Optional getNumArgumentsInExpansion( + QualType T, const MultiLevelTemplateArgumentList &TemplateArgs); /// Determine whether the given declarator contains any unexpanded /// parameter packs. @@ -8819,8 +8534,7 @@ class Sema final { /// \param NumExpansions Will be set to the number of expansions that will /// be generated from this pack expansion, if known a priori. TemplateArgumentLoc getTemplateArgumentPackExpansionPattern( - TemplateArgumentLoc OrigLoc, - SourceLocation &Ellipsis, + TemplateArgumentLoc OrigLoc, SourceLocation &Ellipsis, Optional &NumExpansions) const; /// Given a template argument that contains an unexpanded parameter pack, but @@ -8947,7 +8661,7 @@ class Sema final { sema::TemplateDeductionInfo &Info, SmallVectorImpl const *OriginalCallArgs = nullptr, bool PartialOverloading = false, - llvm::function_ref CheckNonDependent = []{ return false; }); + llvm::function_ref CheckNonDependent = [] { return false; }); TemplateDeductionResult DeduceTemplateArguments( FunctionTemplateDecl *FunctionTemplate, @@ -8956,18 +8670,15 @@ class Sema final { bool PartialOverloading, llvm::function_ref)> CheckNonDependent); - TemplateDeductionResult - DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, - TemplateArgumentListInfo *ExplicitTemplateArgs, - QualType ArgFunctionType, - FunctionDecl *&Specialization, - sema::TemplateDeductionInfo &Info, - bool IsAddressOfFunction = false); + TemplateDeductionResult DeduceTemplateArguments( + FunctionTemplateDecl *FunctionTemplate, + TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ArgFunctionType, + FunctionDecl *&Specialization, sema::TemplateDeductionInfo &Info, + bool IsAddressOfFunction = false); TemplateDeductionResult DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, - QualType ToType, - CXXConversionDecl *&Specialization, + QualType ToType, CXXConversionDecl *&Specialization, sema::TemplateDeductionInfo &Info); TemplateDeductionResult @@ -8980,7 +8691,7 @@ class Sema final { /// Substitute Replacement for \p auto in \p TypeWithAuto QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement); /// Substitute Replacement for auto in TypeWithAuto - TypeSourceInfo* SubstAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto, + TypeSourceInfo *SubstAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto, QualType Replacement); // Substitute auto in TypeWithAuto for a Dependent auto type @@ -9032,17 +8743,15 @@ class Sema final { UnresolvedSetIterator getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd, TemplateSpecCandidateSet &FailedCandidates, - SourceLocation Loc, - const PartialDiagnostic &NoneDiag, + SourceLocation Loc, const PartialDiagnostic &NoneDiag, const PartialDiagnostic &AmbigDiag, const PartialDiagnostic &CandidateDiag, bool Complain = true, QualType TargetType = QualType()); ClassTemplatePartialSpecializationDecl * getMoreSpecializedPartialSpecialization( - ClassTemplatePartialSpecializationDecl *PS1, - ClassTemplatePartialSpecializationDecl *PS2, - SourceLocation Loc); + ClassTemplatePartialSpecializationDecl *PS1, + ClassTemplatePartialSpecializationDecl *PS2, SourceLocation Loc); bool isMoreSpecializedThanPrimary(ClassTemplatePartialSpecializationDecl *T, sema::TemplateDeductionInfo &Info); @@ -9061,17 +8770,17 @@ class Sema final { unsigned Depth, llvm::SmallBitVector &Used); void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs, - bool OnlyDeduced, - unsigned Depth, + bool OnlyDeduced, unsigned Depth, llvm::SmallBitVector &Used); - void MarkDeducedTemplateParameters( - const FunctionTemplateDecl *FunctionTemplate, - llvm::SmallBitVector &Deduced) { + void + MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, + llvm::SmallBitVector &Deduced) { return MarkDeducedTemplateParameters(Context, FunctionTemplate, Deduced); } - static void MarkDeducedTemplateParameters(ASTContext &Ctx, - const FunctionTemplateDecl *FunctionTemplate, - llvm::SmallBitVector &Deduced); + static void + MarkDeducedTemplateParameters(ASTContext &Ctx, + const FunctionTemplateDecl *FunctionTemplate, + llvm::SmallBitVector &Deduced); //===--------------------------------------------------------------------===// // C++ Template Instantiation @@ -9265,21 +8974,21 @@ class Sema final { /// Extra modules inspected when performing a lookup during a template /// instantiation. Computed lazily. - SmallVector CodeSynthesisContextLookupModules; + SmallVector CodeSynthesisContextLookupModules; /// Cache of additional modules that should be used for name lookup /// within the current template instantiation. Computed lazily; use /// getLookupModules() to get a complete set. - llvm::DenseSet LookupModulesCache; + llvm::DenseSet LookupModulesCache; /// Get the set of additional modules that should be checked during /// name lookup. A module and its imports become visible when instanting a /// template defined within it. - llvm::DenseSet &getLookupModules(); + llvm::DenseSet &getLookupModules(); /// Map from the most recent declaration of a namespace to the most /// recent visible declaration of that namespace. - llvm::DenseMap VisibleNamespaceCache; + llvm::DenseMap VisibleNamespaceCache; /// Whether we are in a SFINAE context that is not associated with /// template instantiation. @@ -9331,7 +9040,7 @@ class Sema final { public: ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex) - : Self(Self), OldSubstitutionIndex(Self.ArgumentPackSubstitutionIndex) { + : Self(Self), OldSubstitutionIndex(Self.ArgumentPackSubstitutionIndex) { Self.ArgumentPackSubstitutionIndex = NewSubstitutionIndex; } @@ -9347,8 +9056,8 @@ class Sema final { /// deduction. /// /// FIXME: Serialize this structure to the AST file. - typedef llvm::DenseMap > - SuppressedDiagnosticsMap; + typedef llvm::DenseMap> + SuppressedDiagnosticsMap; SuppressedDiagnosticsMap SuppressedDiagnostics; /// A stack object to be created when performing template @@ -9429,24 +9138,21 @@ class Sema final { /// Note that we are substituting prior template arguments into a /// non-type parameter. InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, - NamedDecl *Template, - NonTypeTemplateParmDecl *Param, + NamedDecl *Template, NonTypeTemplateParmDecl *Param, ArrayRef TemplateArgs, SourceRange InstantiationRange); /// Note that we are substituting prior template arguments into a /// template template parameter. InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, - NamedDecl *Template, - TemplateTemplateParmDecl *Param, + NamedDecl *Template, TemplateTemplateParmDecl *Param, ArrayRef TemplateArgs, SourceRange InstantiationRange); /// Note that we are checking the default template argument /// against the template parameter for a given template-id. InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, - TemplateDecl *Template, - NamedDecl *Param, + TemplateDecl *Template, NamedDecl *Param, ArrayRef TemplateArgs, SourceRange InstantiationRange); @@ -9519,17 +9225,17 @@ class Sema final { bool CheckInstantiationDepth(SourceLocation PointOfInstantiation, SourceRange InstantiationRange); - InstantiatingTemplate( - Sema &SemaRef, CodeSynthesisContext::SynthesisKind Kind, - SourceLocation PointOfInstantiation, SourceRange InstantiationRange, - Decl *Entity, NamedDecl *Template = nullptr, - ArrayRef TemplateArgs = None, - sema::TemplateDeductionInfo *DeductionInfo = nullptr); + InstantiatingTemplate(Sema &SemaRef, + CodeSynthesisContext::SynthesisKind Kind, + SourceLocation PointOfInstantiation, + SourceRange InstantiationRange, Decl *Entity, + NamedDecl *Template = nullptr, + ArrayRef TemplateArgs = None, + sema::TemplateDeductionInfo *DeductionInfo = nullptr); - InstantiatingTemplate(const InstantiatingTemplate&) = delete; + InstantiatingTemplate(const InstantiatingTemplate &) = delete; - InstantiatingTemplate& - operator=(const InstantiatingTemplate&) = delete; + InstantiatingTemplate &operator=(const InstantiatingTemplate &) = delete; }; void pushCodeSynthesisContext(CodeSynthesisContext Ctx); @@ -9589,13 +9295,12 @@ class Sema final { public: explicit SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE = false) - : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors), - PrevInNonInstantiationSFINAEContext( - SemaRef.InNonInstantiationSFINAEContext), - PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE), - PrevLastDiagnosticIgnored( - SemaRef.getDiagnostics().isLastDiagnosticIgnored()) - { + : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors), + PrevInNonInstantiationSFINAEContext( + SemaRef.InNonInstantiationSFINAEContext), + PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE), + PrevLastDiagnosticIgnored( + SemaRef.getDiagnostics().isLastDiagnosticIgnored()) { if (!SemaRef.isSFINAEContext()) SemaRef.InNonInstantiationSFINAEContext = true; SemaRef.AccessCheckingSFINAE = AccessCheckingSFINAE; @@ -9603,8 +9308,8 @@ class Sema final { ~SFINAETrap() { SemaRef.NumSFINAEErrors = PrevSFINAEErrors; - SemaRef.InNonInstantiationSFINAEContext - = PrevInNonInstantiationSFINAEContext; + SemaRef.InNonInstantiationSFINAEContext = + PrevInNonInstantiationSFINAEContext; SemaRef.AccessCheckingSFINAE = PrevAccessCheckingSFINAE; SemaRef.getDiagnostics().setLastDiagnosticIgnored( PrevLastDiagnosticIgnored); @@ -9625,6 +9330,7 @@ class Sema final { // FIXME: Using a SFINAETrap for this is a hack. SFINAETrap Trap; bool PrevDisableTypoCorrection; + public: explicit TentativeAnalysisScope(Sema &SemaRef) : SemaRef(SemaRef), Trap(SemaRef, true), @@ -9681,7 +9387,8 @@ class Sema final { public: GlobalEagerInstantiationScope(Sema &S, bool Enabled) : S(S), Enabled(Enabled) { - if (!Enabled) return; + if (!Enabled) + return; SavedPendingInstantiations.swap(S.PendingInstantiations); SavedVTableUses.swap(S.VTableUses); @@ -9695,7 +9402,8 @@ class Sema final { } ~GlobalEagerInstantiationScope() { - if (!Enabled) return; + if (!Enabled) + return; // Restore the set of pending vtables. assert(S.VTableUses.empty() && @@ -9775,7 +9483,8 @@ class Sema final { /// ExtParameterInfo array we've built up. const FunctionProtoType::ExtParameterInfo * getPointerOrNull(unsigned numParams) { - if (!HasInteresting) return nullptr; + if (!HasInteresting) + return nullptr; Infos.resize(numParams); return Infos.data(); } @@ -9879,21 +9588,17 @@ class Sema final { FunctionDecl *SubstSpaceshipAsEqualEqual(CXXRecordDecl *RD, FunctionDecl *Spaceship); - ExprResult SubstInitializer(Expr *E, - const MultiLevelTemplateArgumentList &TemplateArgs, - bool CXXDirectInit); + ExprResult + SubstInitializer(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs, + bool CXXDirectInit); - bool - SubstBaseSpecifiers(CXXRecordDecl *Instantiation, - CXXRecordDecl *Pattern, - const MultiLevelTemplateArgumentList &TemplateArgs); + bool SubstBaseSpecifiers(CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, + const MultiLevelTemplateArgumentList &TemplateArgs); - bool - InstantiateClass(SourceLocation PointOfInstantiation, - CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, - const MultiLevelTemplateArgumentList &TemplateArgs, - TemplateSpecializationKind TSK, - bool Complain = true); + bool InstantiateClass(SourceLocation PointOfInstantiation, + CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, + const MultiLevelTemplateArgumentList &TemplateArgs, + TemplateSpecializationKind TSK, bool Complain = true); bool InstantiateEnum(SourceLocation PointOfInstantiation, EnumDecl *Instantiation, EnumDecl *Pattern, @@ -9911,8 +9616,7 @@ class Sema final { LateInstantiatedAttribute(const Attr *A, LocalInstantiationScope *S, Decl *D) - : TmplAttr(A), Scope(S), NewDecl(D) - { } + : TmplAttr(A), Scope(S), NewDecl(D) {} }; typedef SmallVector LateInstantiatedAttrVec; @@ -9932,25 +9636,25 @@ class Sema final { bool usesPartialOrExplicitSpecialization( SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec); - bool - InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, - ClassTemplateSpecializationDecl *ClassTemplateSpec, - TemplateSpecializationKind TSK, - bool Complain = true); + bool InstantiateClassTemplateSpecialization( + SourceLocation PointOfInstantiation, + ClassTemplateSpecializationDecl *ClassTemplateSpec, + TemplateSpecializationKind TSK, bool Complain = true); - void InstantiateClassMembers(SourceLocation PointOfInstantiation, - CXXRecordDecl *Instantiation, - const MultiLevelTemplateArgumentList &TemplateArgs, - TemplateSpecializationKind TSK); + void + InstantiateClassMembers(SourceLocation PointOfInstantiation, + CXXRecordDecl *Instantiation, + const MultiLevelTemplateArgumentList &TemplateArgs, + TemplateSpecializationKind TSK); void InstantiateClassTemplateSpecializationMembers( - SourceLocation PointOfInstantiation, - ClassTemplateSpecializationDecl *ClassTemplateSpec, - TemplateSpecializationKind TSK); + SourceLocation PointOfInstantiation, + ClassTemplateSpecializationDecl *ClassTemplateSpec, + TemplateSpecializationKind TSK); - NestedNameSpecifierLoc - SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, - const MultiLevelTemplateArgumentList &TemplateArgs); + NestedNameSpecifierLoc SubstNestedNameSpecifierLoc( + NestedNameSpecifierLoc NNS, + const MultiLevelTemplateArgumentList &TemplateArgs); DeclarationNameInfo SubstDeclarationNameInfo(const DeclarationNameInfo &NameInfo, @@ -10008,14 +9712,16 @@ class Sema final { bool DefinitionRequired = false, bool AtEndOfTU = false); - void InstantiateMemInitializers(CXXConstructorDecl *New, - const CXXConstructorDecl *Tmpl, - const MultiLevelTemplateArgumentList &TemplateArgs); + void InstantiateMemInitializers( + CXXConstructorDecl *New, const CXXConstructorDecl *Tmpl, + const MultiLevelTemplateArgumentList &TemplateArgs); - NamedDecl *FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, - const MultiLevelTemplateArgumentList &TemplateArgs, - bool FindingInstantiatedContext = false); - DeclContext *FindInstantiatedContext(SourceLocation Loc, DeclContext *DC, + NamedDecl * + FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, + const MultiLevelTemplateArgumentList &TemplateArgs, + bool FindingInstantiatedContext = false); + DeclContext * + FindInstantiatedContext(SourceLocation Loc, DeclContext *DC, const MultiLevelTemplateArgumentList &TemplateArgs); // Objective-C declarations. @@ -10030,14 +9736,11 @@ class Sema final { }; ObjCContainerKind getObjCContainerKind() const; - DeclResult actOnObjCTypeParam(Scope *S, - ObjCTypeParamVariance variance, - SourceLocation varianceLoc, - unsigned index, + DeclResult actOnObjCTypeParam(Scope *S, ObjCTypeParamVariance variance, + SourceLocation varianceLoc, unsigned index, IdentifierInfo *paramName, SourceLocation paramLoc, - SourceLocation colonLoc, - ParsedType typeBound); + SourceLocation colonLoc, ParsedType typeBound); ObjCTypeParamList *actOnObjCTypeParamList(Scope *S, SourceLocation lAngleLoc, ArrayRef typeParams, @@ -10053,30 +9756,26 @@ class Sema final { const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList); - void ActOnSuperClassOfClassInterface(Scope *S, - SourceLocation AtInterfaceLoc, - ObjCInterfaceDecl *IDecl, - IdentifierInfo *ClassName, - SourceLocation ClassLoc, - IdentifierInfo *SuperName, - SourceLocation SuperLoc, - ArrayRef SuperTypeArgs, - SourceRange SuperTypeArgsRange); + void ActOnSuperClassOfClassInterface( + Scope *S, SourceLocation AtInterfaceLoc, ObjCInterfaceDecl *IDecl, + IdentifierInfo *ClassName, SourceLocation ClassLoc, + IdentifierInfo *SuperName, SourceLocation SuperLoc, + ArrayRef SuperTypeArgs, SourceRange SuperTypeArgsRange); void ActOnTypedefedProtocols(SmallVectorImpl &ProtocolRefs, SmallVectorImpl &ProtocolLocs, IdentifierInfo *SuperName, SourceLocation SuperLoc); - Decl *ActOnCompatibilityAlias( - SourceLocation AtCompatibilityAliasLoc, - IdentifierInfo *AliasName, SourceLocation AliasLocation, - IdentifierInfo *ClassName, SourceLocation ClassLocation); + Decl *ActOnCompatibilityAlias(SourceLocation AtCompatibilityAliasLoc, + IdentifierInfo *AliasName, + SourceLocation AliasLocation, + IdentifierInfo *ClassName, + SourceLocation ClassLocation); bool CheckForwardProtocolDeclarationForCircularDependency( - IdentifierInfo *PName, - SourceLocation &PLoc, SourceLocation PrevLoc, - const ObjCList &PList); + IdentifierInfo *PName, SourceLocation &PLoc, SourceLocation PrevLoc, + const ObjCList &PList); ObjCProtocolDecl *ActOnStartProtocolInterface( SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName, @@ -10105,11 +9804,9 @@ class Sema final { DeclGroupPtrTy ActOnFinishObjCImplementation(Decl *ObjCImpDecl, ArrayRef Decls); - DeclGroupPtrTy ActOnForwardClassDeclaration(SourceLocation Loc, - IdentifierInfo **IdentList, - SourceLocation *IdentLocs, - ArrayRef TypeParamLists, - unsigned NumElts); + DeclGroupPtrTy ActOnForwardClassDeclaration( + SourceLocation Loc, IdentifierInfo **IdentList, SourceLocation *IdentLocs, + ArrayRef TypeParamLists, unsigned NumElts); DeclGroupPtrTy ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc, @@ -10130,40 +9827,27 @@ class Sema final { /// names to either Objective-C protocol qualifiers or type /// arguments, as appropriate. void actOnObjCTypeArgsOrProtocolQualifiers( - Scope *S, - ParsedType baseType, - SourceLocation lAngleLoc, - ArrayRef identifiers, - ArrayRef identifierLocs, - SourceLocation rAngleLoc, - SourceLocation &typeArgsLAngleLoc, - SmallVectorImpl &typeArgs, - SourceLocation &typeArgsRAngleLoc, - SourceLocation &protocolLAngleLoc, - SmallVectorImpl &protocols, - SourceLocation &protocolRAngleLoc, - bool warnOnIncompleteProtocols); + Scope *S, ParsedType baseType, SourceLocation lAngleLoc, + ArrayRef identifiers, + ArrayRef identifierLocs, SourceLocation rAngleLoc, + SourceLocation &typeArgsLAngleLoc, SmallVectorImpl &typeArgs, + SourceLocation &typeArgsRAngleLoc, SourceLocation &protocolLAngleLoc, + SmallVectorImpl &protocols, SourceLocation &protocolRAngleLoc, + bool warnOnIncompleteProtocols); /// Build a an Objective-C protocol-qualified 'id' type where no /// base type was specified. TypeResult actOnObjCProtocolQualifierType( - SourceLocation lAngleLoc, - ArrayRef protocols, - ArrayRef protocolLocs, - SourceLocation rAngleLoc); + SourceLocation lAngleLoc, ArrayRef protocols, + ArrayRef protocolLocs, SourceLocation rAngleLoc); /// Build a specialized and/or protocol-qualified Objective-C type. TypeResult actOnObjCTypeArgsAndProtocolQualifiers( - Scope *S, - SourceLocation Loc, - ParsedType BaseType, - SourceLocation TypeArgsLAngleLoc, - ArrayRef TypeArgs, - SourceLocation TypeArgsRAngleLoc, - SourceLocation ProtocolLAngleLoc, - ArrayRef Protocols, - ArrayRef ProtocolLocs, - SourceLocation ProtocolRAngleLoc); + Scope *S, SourceLocation Loc, ParsedType BaseType, + SourceLocation TypeArgsLAngleLoc, ArrayRef TypeArgs, + SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, + ArrayRef Protocols, ArrayRef ProtocolLocs, + SourceLocation ProtocolRAngleLoc); /// Build an Objective-C type parameter type. QualType BuildObjCTypeParamType(const ObjCTypeParamDecl *Decl, @@ -10174,22 +9858,17 @@ class Sema final { bool FailOnError = false); /// Build an Objective-C object pointer type. - QualType BuildObjCObjectType(QualType BaseType, - SourceLocation Loc, - SourceLocation TypeArgsLAngleLoc, - ArrayRef TypeArgs, - SourceLocation TypeArgsRAngleLoc, - SourceLocation ProtocolLAngleLoc, - ArrayRef Protocols, - ArrayRef ProtocolLocs, - SourceLocation ProtocolRAngleLoc, - bool FailOnError = false); + QualType BuildObjCObjectType( + QualType BaseType, SourceLocation Loc, SourceLocation TypeArgsLAngleLoc, + ArrayRef TypeArgs, SourceLocation TypeArgsRAngleLoc, + SourceLocation ProtocolLAngleLoc, ArrayRef Protocols, + ArrayRef ProtocolLocs, SourceLocation ProtocolRAngleLoc, + bool FailOnError = false); /// Ensure attributes are consistent with type. /// \param [in, out] Attributes The attributes to check; they will /// be modified to be consistent with \p PropertyTy. - void CheckObjCPropertyAttributes(Decl *PropertyPtrTy, - SourceLocation Loc, + void CheckObjCPropertyAttributes(Decl *PropertyPtrTy, SourceLocation Loc, unsigned &Attributes, bool propertyInPrimaryClass); @@ -10198,7 +9877,6 @@ class Sema final { /// \param property The property declaration being processed void ProcessPropertyDecl(ObjCPropertyDecl *property); - void DiagnosePropertyMismatch(ObjCPropertyDecl *Property, ObjCPropertyDecl *SuperProperty, const IdentifierInfo *Name, @@ -10211,17 +9889,14 @@ class Sema final { ArrayRef allMethods = None, ArrayRef allTUVars = None); - Decl *ActOnProperty(Scope *S, SourceLocation AtLoc, - SourceLocation LParenLoc, + Decl *ActOnProperty(Scope *S, SourceLocation AtLoc, SourceLocation LParenLoc, FieldDeclarator &FD, ObjCDeclSpec &ODS, Selector GetterSel, Selector SetterSel, tok::ObjCKeywordKind MethodImplKind, DeclContext *lexicalDC = nullptr); - Decl *ActOnPropertyImplDecl(Scope *S, - SourceLocation AtLoc, - SourceLocation PropertyLoc, - bool ImplKind, + Decl *ActOnPropertyImplDecl(Scope *S, SourceLocation AtLoc, + SourceLocation PropertyLoc, bool ImplKind, IdentifierInfo *PropertyId, IdentifierInfo *PropertyIvar, SourceLocation PropertyIvarLoc, @@ -10272,20 +9947,17 @@ class Sema final { void deduceOpenCLAddressSpace(ValueDecl *decl); - ExprResult - HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, - Expr *BaseExpr, - SourceLocation OpLoc, - DeclarationName MemberName, - SourceLocation MemberLoc, - SourceLocation SuperLoc, QualType SuperType, - bool Super); + ExprResult HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, + Expr *BaseExpr, SourceLocation OpLoc, + DeclarationName MemberName, + SourceLocation MemberLoc, + SourceLocation SuperLoc, + QualType SuperType, bool Super); - ExprResult - ActOnClassPropertyRefExpr(IdentifierInfo &receiverName, - IdentifierInfo &propertyName, - SourceLocation receiverNameLoc, - SourceLocation propertyNameLoc); + ExprResult ActOnClassPropertyRefExpr(IdentifierInfo &receiverName, + IdentifierInfo &propertyName, + SourceLocation receiverNameLoc, + SourceLocation propertyNameLoc); ObjCMethodDecl *tryCaptureObjCSelf(SourceLocation Loc); @@ -10301,84 +9973,61 @@ class Sema final { ObjCClassMessage }; - ObjCMessageKind getObjCMessageKind(Scope *S, - IdentifierInfo *Name, - SourceLocation NameLoc, - bool IsSuper, + ObjCMessageKind getObjCMessageKind(Scope *S, IdentifierInfo *Name, + SourceLocation NameLoc, bool IsSuper, bool HasTrailingDot, ParsedType &ReceiverType); - ExprResult ActOnSuperMessage(Scope *S, SourceLocation SuperLoc, - Selector Sel, + ExprResult ActOnSuperMessage(Scope *S, SourceLocation SuperLoc, Selector Sel, SourceLocation LBracLoc, ArrayRef SelectorLocs, - SourceLocation RBracLoc, - MultiExprArg Args); + SourceLocation RBracLoc, MultiExprArg Args); ExprResult BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, - QualType ReceiverType, - SourceLocation SuperLoc, - Selector Sel, - ObjCMethodDecl *Method, + QualType ReceiverType, SourceLocation SuperLoc, + Selector Sel, ObjCMethodDecl *Method, SourceLocation LBracLoc, ArrayRef SelectorLocs, - SourceLocation RBracLoc, - MultiExprArg Args, + SourceLocation RBracLoc, MultiExprArg Args, bool isImplicit = false); ExprResult BuildClassMessageImplicit(QualType ReceiverType, - bool isSuperReceiver, - SourceLocation Loc, - Selector Sel, - ObjCMethodDecl *Method, + bool isSuperReceiver, SourceLocation Loc, + Selector Sel, ObjCMethodDecl *Method, MultiExprArg Args); - ExprResult ActOnClassMessage(Scope *S, - ParsedType Receiver, - Selector Sel, + ExprResult ActOnClassMessage(Scope *S, ParsedType Receiver, Selector Sel, SourceLocation LBracLoc, ArrayRef SelectorLocs, - SourceLocation RBracLoc, - MultiExprArg Args); + SourceLocation RBracLoc, MultiExprArg Args); - ExprResult BuildInstanceMessage(Expr *Receiver, - QualType ReceiverType, - SourceLocation SuperLoc, - Selector Sel, + ExprResult BuildInstanceMessage(Expr *Receiver, QualType ReceiverType, + SourceLocation SuperLoc, Selector Sel, ObjCMethodDecl *Method, SourceLocation LBracLoc, ArrayRef SelectorLocs, - SourceLocation RBracLoc, - MultiExprArg Args, + SourceLocation RBracLoc, MultiExprArg Args, bool isImplicit = false); - ExprResult BuildInstanceMessageImplicit(Expr *Receiver, - QualType ReceiverType, - SourceLocation Loc, - Selector Sel, + ExprResult BuildInstanceMessageImplicit(Expr *Receiver, QualType ReceiverType, + SourceLocation Loc, Selector Sel, ObjCMethodDecl *Method, MultiExprArg Args); - ExprResult ActOnInstanceMessage(Scope *S, - Expr *Receiver, - Selector Sel, + ExprResult ActOnInstanceMessage(Scope *S, Expr *Receiver, Selector Sel, SourceLocation LBracLoc, ArrayRef SelectorLocs, - SourceLocation RBracLoc, - MultiExprArg Args); + SourceLocation RBracLoc, MultiExprArg Args); ExprResult BuildObjCBridgedCast(SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, - TypeSourceInfo *TSInfo, - Expr *SubExpr); + TypeSourceInfo *TSInfo, Expr *SubExpr); - ExprResult ActOnObjCBridgedCast(Scope *S, - SourceLocation LParenLoc, + ExprResult ActOnObjCBridgedCast(Scope *S, SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, - ParsedType Type, - SourceLocation RParenLoc, + ParsedType Type, SourceLocation RParenLoc, Expr *SubExpr); void CheckTollFreeBridgeCast(QualType castType, Expr *castExpr); @@ -10388,17 +10037,17 @@ class Sema final { bool CheckTollFreeBridgeStaticCast(QualType castType, Expr *castExpr, CastKind &Kind); - bool checkObjCBridgeRelatedComponents(SourceLocation Loc, - QualType DestType, QualType SrcType, + bool checkObjCBridgeRelatedComponents(SourceLocation Loc, QualType DestType, + QualType SrcType, ObjCInterfaceDecl *&RelatedClass, ObjCMethodDecl *&ClassMethod, ObjCMethodDecl *&InstanceMethod, - TypedefNameDecl *&TDNDecl, - bool CfToNs, bool Diagnose = true); + TypedefNameDecl *&TDNDecl, bool CfToNs, + bool Diagnose = true); - bool CheckObjCBridgeRelatedConversions(SourceLocation Loc, - QualType DestType, QualType SrcType, - Expr *&SrcExpr, bool Diagnose = true); + bool CheckObjCBridgeRelatedConversions(SourceLocation Loc, QualType DestType, + QualType SrcType, Expr *&SrcExpr, + bool Diagnose = true); bool CheckConversionToObjCLiteral(QualType DstType, Expr *&SrcExpr, bool Diagnose = true); @@ -10436,7 +10085,8 @@ class Sema final { /// ActOnPragmaClangSection - Called on well formed \#pragma clang section void ActOnPragmaClangSection(SourceLocation PragmaLoc, PragmaClangSectionAction Action, - PragmaClangSectionKind SecKind, StringRef SecName); + PragmaClangSectionKind SecKind, + StringRef SecName); /// ActOnPragmaOptionsAlign - Called on well formed \#pragma options align. void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind, @@ -10478,8 +10128,7 @@ class Sema final { /// Called on well formed \#pragma vtordisp(). void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action, - SourceLocation PragmaLoc, - MSVtorDispMode Value); + SourceLocation PragmaLoc, MSVtorDispMode Value); enum PragmaSectionKind { PSK_DataSeg, @@ -10490,20 +10139,18 @@ class Sema final { bool UnifySection(StringRef SectionName, int SectionFlags, NamedDecl *TheDecl); - bool UnifySection(StringRef SectionName, - int SectionFlags, + bool UnifySection(StringRef SectionName, int SectionFlags, SourceLocation PragmaSectionLocation); /// Called on well formed \#pragma bss_seg/data_seg/const_seg/code_seg. void ActOnPragmaMSSeg(SourceLocation PragmaLocation, PragmaMsStackAction Action, llvm::StringRef StackSlotLabel, - StringLiteral *SegmentName, - llvm::StringRef PragmaName); + StringLiteral *SegmentName, llvm::StringRef PragmaName); /// Called on well formed \#pragma section(). - void ActOnPragmaMSSection(SourceLocation PragmaLocation, - int SectionFlags, StringLiteral *SegmentName); + void ActOnPragmaMSSection(SourceLocation PragmaLocation, int SectionFlags, + StringLiteral *SegmentName); /// Called on well-formed \#pragma init_seg(). void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation, @@ -10538,12 +10185,11 @@ class Sema final { PragmaFloatControlKind Value); /// ActOnPragmaUnused - Called on well-formed '\#pragma unused'. - void ActOnPragmaUnused(const Token &Identifier, - Scope *curScope, + void ActOnPragmaUnused(const Token &Identifier, Scope *curScope, SourceLocation PragmaLoc); /// ActOnPragmaVisibility - Called on well formed \#pragma GCC visibility... . - void ActOnPragmaVisibility(const IdentifierInfo* VisType, + void ActOnPragmaVisibility(const IdentifierInfo *VisType, SourceLocation PragmaLoc); NamedDecl *DeclClonePragmaWeak(NamedDecl *ND, const IdentifierInfo *II, @@ -10551,21 +10197,19 @@ class Sema final { void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W); /// ActOnPragmaWeakID - Called on well formed \#pragma weak ident. - void ActOnPragmaWeakID(IdentifierInfo* WeakName, - SourceLocation PragmaLoc, + void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc); /// ActOnPragmaRedefineExtname - Called on well formed /// \#pragma redefine_extname oldname newname. - void ActOnPragmaRedefineExtname(IdentifierInfo* WeakName, - IdentifierInfo* AliasName, + void ActOnPragmaRedefineExtname(IdentifierInfo *WeakName, + IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc); /// ActOnPragmaWeakAlias - Called on well formed \#pragma weak ident = ident. - void ActOnPragmaWeakAlias(IdentifierInfo* WeakName, - IdentifierInfo* AliasName, + void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc); @@ -10722,7 +10366,7 @@ class Sema final { void AddParameterABIAttr(Decl *D, const AttributeCommonInfo &CI, ParameterABI ABI); - enum class RetainOwnershipKind {NS, CF, OS}; + enum class RetainOwnershipKind { NS, CF, OS }; void AddXConsumedAttr(Decl *D, const AttributeCommonInfo &CI, RetainOwnershipKind K, bool IsTemplateInstantiation); @@ -11009,9 +10653,8 @@ class Sema final { const DeclarationNameInfo &Id, OpenMPDirectiveKind Kind); /// Called on well-formed '#pragma omp threadprivate'. - DeclGroupPtrTy ActOnOpenMPThreadprivateDirective( - SourceLocation Loc, - ArrayRef VarList); + DeclGroupPtrTy ActOnOpenMPThreadprivateDirective(SourceLocation Loc, + ArrayRef VarList); /// Builds a new OpenMPThreadPrivateDecl and checks its correctness. OMPThreadPrivateDecl *CheckOMPThreadPrivateDecl(SourceLocation Loc, ArrayRef VarList); @@ -11161,8 +10804,7 @@ class Sema final { /// Called on well-formed '\#pragma omp parallel' after parsing /// of the associated statement. StmtResult ActOnOpenMPParallelDirective(ArrayRef Clauses, - Stmt *AStmt, - SourceLocation StartLoc, + Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc); using VarsWithInheritedDSAType = llvm::SmallDenseMap; @@ -11295,7 +10937,8 @@ class Sema final { /// Called on well-formed '\#pragma omp target data' after parsing of /// the associated statement. StmtResult ActOnOpenMPTargetDataDirective(ArrayRef Clauses, - Stmt *AStmt, SourceLocation StartLoc, + Stmt *AStmt, + SourceLocation StartLoc, SourceLocation EndLoc); /// Called on well-formed '\#pragma omp target enter data' after /// parsing of the associated statement. @@ -11563,8 +11206,7 @@ class Sema final { ArrayRef AppendArgs, SourceLocation AdjustArgsLoc, SourceLocation AppendArgsLoc, SourceRange SR); - OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, - Expr *Expr, + OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc); @@ -11594,8 +11236,7 @@ class Sema final { SourceLocation LParenLoc, SourceLocation EndLoc); /// Called on well-formed 'safelen' clause. - OMPClause *ActOnOpenMPSafelenClause(Expr *Length, - SourceLocation StartLoc, + OMPClause *ActOnOpenMPSafelenClause(Expr *Length, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc); /// Called on well-formed 'simdlen' clause. @@ -11641,8 +11282,7 @@ class Sema final { SourceLocation LParenLoc, SourceLocation EndLoc); - OMPClause *ActOnOpenMPSimpleClause(OpenMPClauseKind Kind, - unsigned Argument, + OMPClause *ActOnOpenMPSimpleClause(OpenMPClauseKind Kind, unsigned Argument, SourceLocation ArgumentLoc, SourceLocation StartLoc, SourceLocation LParenLoc, @@ -11879,8 +11519,7 @@ class Sema final { OpenMPLinearClauseKind LinKind, SourceLocation LinLoc, SourceLocation ColonLoc, SourceLocation EndLoc); /// Called on well-formed 'aligned' clause. - OMPClause *ActOnOpenMPAlignedClause(ArrayRef VarList, - Expr *Alignment, + OMPClause *ActOnOpenMPAlignedClause(ArrayRef VarList, Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, @@ -12248,8 +11887,7 @@ class Sema final { /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the /// assignment conversion type specified by ConvTy. This returns true if the /// conversion was invalid or false if the conversion was accepted. - bool DiagnoseAssignmentResult(AssignConvertType ConvTy, - SourceLocation Loc, + bool DiagnoseAssignmentResult(AssignConvertType ConvTy, SourceLocation Loc, QualType DstType, QualType SrcType, Expr *SrcExpr, AssignmentAction Action, bool *Complained = nullptr); @@ -12276,8 +11914,7 @@ class Sema final { /// the RHS to the LHS type. The conversion is prepared for if ConvertRHS /// is true. AssignConvertType CheckAssignmentConstraints(QualType LHSType, - ExprResult &RHS, - CastKind &Kind, + ExprResult &RHS, CastKind &Kind, bool ConvertRHS = true); /// Check assignment constraints for an assignment of RHS to LHSType. @@ -12310,13 +11947,13 @@ class Sema final { ExprResult PerformImplicitConversion(Expr *From, QualType ToType, AssignmentAction Action, bool AllowExplicit = false); + ExprResult + PerformImplicitConversion(Expr *From, QualType ToType, + const ImplicitConversionSequence &ICS, + AssignmentAction Action, + CheckedConversionKind CCK = CCK_ImplicitConversion); ExprResult PerformImplicitConversion(Expr *From, QualType ToType, - const ImplicitConversionSequence& ICS, - AssignmentAction Action, - CheckedConversionKind CCK - = CCK_ImplicitConversion); - ExprResult PerformImplicitConversion(Expr *From, QualType ToType, - const StandardConversionSequence& SCS, + const StandardConversionSequence &SCS, AssignmentAction Action, CheckedConversionKind CCK); @@ -12331,25 +11968,25 @@ class Sema final { QualType InvalidOperands(SourceLocation Loc, ExprResult &LHS, ExprResult &RHS); QualType InvalidLogicalVectorOperands(SourceLocation Loc, ExprResult &LHS, - ExprResult &RHS); + ExprResult &RHS); QualType CheckPointerToMemberOperands( // C++ 5.5 - ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, - SourceLocation OpLoc, bool isIndirect); + ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, SourceLocation OpLoc, + bool isIndirect); QualType CheckMultiplyDivideOperands( // C99 6.5.5 - ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, - bool IsDivide); + ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, + bool IsDivide); QualType CheckRemainderOperands( // C99 6.5.5 - ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, - bool IsCompAssign = false); + ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, + bool IsCompAssign = false); QualType CheckAdditionOperands( // C99 6.5.6 - ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, - BinaryOperatorKind Opc, QualType* CompLHSTy = nullptr); + ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, + BinaryOperatorKind Opc, QualType *CompLHSTy = nullptr); QualType CheckSubtractionOperands( // C99 6.5.6 - ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, - QualType* CompLHSTy = nullptr); + ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, + QualType *CompLHSTy = nullptr); QualType CheckShiftOperands( // C99 6.5.7 - ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, - BinaryOperatorKind Opc, bool IsCompAssign = false); + ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, + BinaryOperatorKind Opc, bool IsCompAssign = false); void CheckPtrComparisonWithNullChar(ExprResult &E, ExprResult &NullE); QualType CheckCompareOperands( // C99 6.5.8/9 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, @@ -12358,8 +11995,8 @@ class Sema final { ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc); QualType CheckLogicalOperands( // C99 6.5.[13,14] - ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, - BinaryOperatorKind Opc); + ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, + BinaryOperatorKind Opc); // CheckAssignmentOperands is used for both simple and compound assignment. // For simple assignment, pass both expressions and a null converted type. // For compound assignment, pass both expressions and the converted type. @@ -12370,17 +12007,17 @@ class Sema final { ExprResult checkPseudoObjectIncDec(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opcode, Expr *Op); ExprResult checkPseudoObjectAssignment(Scope *S, SourceLocation OpLoc, - BinaryOperatorKind Opcode, - Expr *LHS, Expr *RHS); + BinaryOperatorKind Opcode, Expr *LHS, + Expr *RHS); ExprResult checkPseudoObjectRValue(Expr *E); Expr *recreateSyntacticForm(PseudoObjectExpr *E); QualType CheckConditionalOperands( // C99 6.5.15 - ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, - ExprValueKind &VK, ExprObjectKind &OK, SourceLocation QuestionLoc); + ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, + ExprObjectKind &OK, SourceLocation QuestionLoc); QualType CXXCheckConditionalOperands( // C++ 5.16 - ExprResult &cond, ExprResult &lhs, ExprResult &rhs, - ExprValueKind &VK, ExprObjectKind &OK, SourceLocation questionLoc); + ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK, + ExprObjectKind &OK, SourceLocation questionLoc); QualType CheckVectorConditionalTypes(ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc); @@ -12390,9 +12027,8 @@ class Sema final { SourceLocation QuestionLoc); QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2, bool ConvertArgs = true); - QualType FindCompositePointerType(SourceLocation Loc, - ExprResult &E1, ExprResult &E2, - bool ConvertArgs = true) { + QualType FindCompositePointerType(SourceLocation Loc, ExprResult &E1, + ExprResult &E2, bool ConvertArgs = true) { Expr *E1Tmp = E1.get(), *E2Tmp = E2.get(); QualType Composite = FindCompositePointerType(Loc, E1Tmp, E2Tmp, ConvertArgs); @@ -12501,8 +12137,8 @@ class Sema final { /// Type-check an expression that's being passed to an /// __unknown_anytype parameter. - ExprResult checkUnknownAnyArg(SourceLocation callLoc, - Expr *result, QualType ¶mType); + ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, + QualType ¶mType); // CheckMatrixCast - Check type constraints for matrix casts. // We allow casting between matrixes of the same dimensions i.e. when they @@ -12544,8 +12180,7 @@ class Sema final { CheckedConversionKind CCK, bool Diagnose = true, bool DiagnoseCFAudited = false, - BinaryOperatorKind Opc = BO_PtrMemD - ); + BinaryOperatorKind Opc = BO_PtrMemD); Expr *stripARCUnbridgedCast(Expr *e); void diagnoseARCUnbridgedCast(Expr *e); @@ -12648,8 +12283,7 @@ class Sema final { DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D); ExprResult CheckConditionVariable(VarDecl *ConditionVar, - SourceLocation StmtLoc, - ConditionKind CK); + SourceLocation StmtLoc, ConditionKind CK); ExprResult CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond); /// CheckBooleanCondition - Diagnose problems involving the use of @@ -12700,7 +12334,7 @@ class Sema final { public: bool Suppress; - VerifyICEDiagnoser(bool Suppress = false) : Suppress(Suppress) { } + VerifyICEDiagnoser(bool Suppress = false) : Suppress(Suppress) {} virtual SemaDiagnosticBuilder diagnoseNotICEType(Sema &S, SourceLocation Loc, QualType T); @@ -12974,8 +12608,7 @@ class Sema final { bool inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl, CXXSpecialMember CSM, CXXMethodDecl *MemberDecl, - bool ConstRHS, - bool Diagnose); + bool ConstRHS, bool Diagnose); /// \return true if \p CD can be considered empty according to CUDA /// (E.2.3.1 in CUDA 7.5 Programming guide). @@ -13055,13 +12688,11 @@ class Sema final { void CodeCompleteModuleImport(SourceLocation ImportLoc, ModuleIdPath Path); void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext); - void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS, - bool AllowNonIdentifiers, + void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS, bool AllowNonIdentifiers, bool AllowNestedNameSpecifiers); struct CodeCompleteExpressionData; - void CodeCompleteExpression(Scope *S, - const CodeCompleteExpressionData &Data); + void CodeCompleteExpression(Scope *S, const CodeCompleteExpressionData &Data); void CodeCompleteExpression(Scope *S, QualType PreferredType, bool IsParenthesized = false); void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, Expr *OtherOpBase, @@ -13123,8 +12754,7 @@ class Sema final { void CodeCompleteNamespaceAliasDecl(Scope *S); void CodeCompleteOperatorName(Scope *S); void CodeCompleteConstructorInitializer( - Decl *Constructor, - ArrayRef Initializers); + Decl *Constructor, ArrayRef Initializers); void CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro, bool AfterAmpersand); @@ -13151,20 +12781,16 @@ class Sema final { ArrayRef SelIdents, bool AtArgumentExpression, ObjCInterfaceDecl *Super = nullptr); - void CodeCompleteObjCForCollection(Scope *S, - DeclGroupPtrTy IterationVar); - void CodeCompleteObjCSelector(Scope *S, - ArrayRef SelIdents); - void CodeCompleteObjCProtocolReferences( - ArrayRef Protocols); + void CodeCompleteObjCForCollection(Scope *S, DeclGroupPtrTy IterationVar); + void CodeCompleteObjCSelector(Scope *S, ArrayRef SelIdents); + void + CodeCompleteObjCProtocolReferences(ArrayRef Protocols); void CodeCompleteObjCProtocolDecl(Scope *S); void CodeCompleteObjCInterfaceDecl(Scope *S); - void CodeCompleteObjCSuperclass(Scope *S, - IdentifierInfo *ClassName, + void CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc); void CodeCompleteObjCImplementationDecl(Scope *S); - void CodeCompleteObjCInterfaceCategory(Scope *S, - IdentifierInfo *ClassName, + void CodeCompleteObjCInterfaceCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc); void CodeCompleteObjCImplementationCategory(Scope *S, IdentifierInfo *ClassName, @@ -13174,8 +12800,7 @@ class Sema final { IdentifierInfo *PropertyName); void CodeCompleteObjCMethodDecl(Scope *S, Optional IsInstanceMethod, ParsedType ReturnType); - void CodeCompleteObjCMethodDeclSelector(Scope *S, - bool IsInstanceMethod, + void CodeCompleteObjCMethodDeclSelector(Scope *S, bool IsInstanceMethod, bool AtParameterName, ParsedType ReturnType, ArrayRef SelIdents); @@ -13186,16 +12811,16 @@ class Sema final { void CodeCompleteInPreprocessorConditionalExclusion(Scope *S); void CodeCompletePreprocessorMacroName(bool IsDefinition); void CodeCompletePreprocessorExpression(); - void CodeCompletePreprocessorMacroArgument(Scope *S, - IdentifierInfo *Macro, + void CodeCompletePreprocessorMacroArgument(Scope *S, IdentifierInfo *Macro, MacroInfo *MacroInfo, unsigned Argument); void CodeCompleteIncludedFile(llvm::StringRef Dir, bool IsAngled); void CodeCompleteNaturalLanguage(); void CodeCompleteAvailabilityPlatformName(); - void GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator, - CodeCompletionTUInfo &CCTUInfo, - SmallVectorImpl &Results); + void + GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator, + CodeCompletionTUInfo &CCTUInfo, + SmallVectorImpl &Results); //@} //===--------------------------------------------------------------------===// @@ -13252,8 +12877,8 @@ class Sema final { bool CheckObjCString(Expr *Arg); ExprResult CheckOSLogFormatStringArg(Expr *Arg); - ExprResult CheckBuiltinFunctionCall(FunctionDecl *FDecl, - unsigned BuiltinID, CallExpr *TheCall); + ExprResult CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, + CallExpr *TheCall); bool CheckTSBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, CallExpr *TheCall); @@ -13301,7 +12926,7 @@ class Sema final { bool CheckRISCVBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, CallExpr *TheCall); bool CheckRISCVCOREVBuiltinFunctionCall(unsigned BuiltinID, - CallExpr *TheCall); + CallExpr *TheCall); bool SemaBuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall); bool SemaBuiltinVAStartARMMicrosoft(CallExpr *Call); bool SemaBuiltinUnorderedCompare(CallExpr *TheCall); @@ -13401,21 +13026,17 @@ class Sema final { void CheckMaxUnsignedZero(const CallExpr *Call, const FunctionDecl *FDecl); - void CheckMemaccessArguments(const CallExpr *Call, - unsigned BId, + void CheckMemaccessArguments(const CallExpr *Call, unsigned BId, IdentifierInfo *FnName); - void CheckStrlcpycatArguments(const CallExpr *Call, - IdentifierInfo *FnName); + void CheckStrlcpycatArguments(const CallExpr *Call, IdentifierInfo *FnName); - void CheckStrncatArguments(const CallExpr *Call, - IdentifierInfo *FnName); + void CheckStrncatArguments(const CallExpr *Call, IdentifierInfo *FnName); void CheckFreeArguments(const CallExpr *E); void CheckReturnValExpr(Expr *RetValExp, QualType lhsType, - SourceLocation ReturnLoc, - bool isObjCMethod = false, + SourceLocation ReturnLoc, bool isObjCMethod = false, const AttrVec *Attrs = nullptr, const FunctionDecl *FD = nullptr); @@ -13457,6 +13078,7 @@ class Sema final { void AnalyzeDeleteExprMismatch(const CXXDeleteExpr *DE); void AnalyzeDeleteExprMismatch(FieldDecl *Field, SourceLocation DeleteLoc, bool DeleteWasArrayForm); + public: /// Register a magic integral constant to be used as a type tag. void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind, @@ -13466,10 +13088,9 @@ class Sema final { struct TypeTagData { TypeTagData() {} - TypeTagData(QualType Type, bool LayoutCompatible, bool MustBeNull) : - Type(Type), LayoutCompatible(LayoutCompatible), - MustBeNull(MustBeNull) - {} + TypeTagData(QualType Type, bool LayoutCompatible, bool MustBeNull) + : Type(Type), LayoutCompatible(LayoutCompatible), + MustBeNull(MustBeNull) {} QualType Type; @@ -13588,8 +13209,8 @@ class Sema final { // Emitting members of dllexported classes is delayed until the class // (including field initializers) is fully parsed. - SmallVector DelayedDllExportClasses; - SmallVector DelayedDllExportMemberFunctions; + SmallVector DelayedDllExportClasses; + SmallVector DelayedDllExportMemberFunctions; private: int ParsingClassDepth = 0; diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 879a302811a5..1c3297eab7c4 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -372,7 +372,8 @@ static bool SemaBuiltinOverflow(Sema &S, CallExpr *TheCall, // First two arguments should be integers. for (unsigned I = 0; I < 2; ++I) { ExprResult Arg = S.DefaultFunctionArrayLvalueConversion(TheCall->getArg(I)); - if (Arg.isInvalid()) return true; + if (Arg.isInvalid()) + return true; TheCall->setArg(I, Arg.get()); QualType Ty = Arg.get()->getType(); @@ -388,17 +389,17 @@ static bool SemaBuiltinOverflow(Sema &S, CallExpr *TheCall, // the other qualifiers aren't possible. { ExprResult Arg = S.DefaultFunctionArrayLvalueConversion(TheCall->getArg(2)); - if (Arg.isInvalid()) return true; + if (Arg.isInvalid()) + return true; TheCall->setArg(2, Arg.get()); QualType Ty = Arg.get()->getType(); const auto *PtrTy = Ty->getAs(); - if (!PtrTy || - !PtrTy->getPointeeType()->isIntegerType() || + if (!PtrTy || !PtrTy->getPointeeType()->isIntegerType() || PtrTy->getPointeeType().isConstQualified()) { S.Diag(Arg.get()->getBeginLoc(), diag::err_overflow_builtin_must_be_ptr_int) - << Ty << Arg.get()->getSourceRange(); + << Ty << Arg.get()->getSourceRange(); return true; } } @@ -516,7 +517,8 @@ struct BuiltinDumpStructGenerator { } analyze_printf::PrintfSpecifier Specifier; - if (Specifier.fixType(T, S.getLangOpts(), S.Context, /*IsObjCLiteral=*/false)) { + if (Specifier.fixType(T, S.getLangOpts(), S.Context, + /*IsObjCLiteral=*/false)) { // We were able to guess how to format this. if (Specifier.getConversionSpecifier().getKind() == analyze_printf::PrintfConversionSpecifier::sArg) { @@ -772,7 +774,7 @@ static bool SemaBuiltinCallWithStaticChain(Sema &S, CallExpr *BuiltinCall) { } QualType ReturnTy = CE->getCallReturnType(S.Context); - QualType ArgTys[2] = { ReturnTy, ChainResult.get()->getType() }; + QualType ArgTys[2] = {ReturnTy, ChainResult.get()->getType()}; QualType BuiltinTy = S.Context.getFunctionType( ReturnTy, ArgTys, FunctionProtoType::ExtProtoInfo()); QualType BuiltinPtrTy = S.Context.getPointerType(BuiltinTy); @@ -1467,7 +1469,7 @@ static bool checkOpenCLEnqueueLocalSizeArgs(Sema &S, CallExpr *TheCall, bool IllegalParams = false; for (unsigned I = Start; I <= End; ++I) IllegalParams |= checkOpenCLEnqueueIntType(S, TheCall->getArg(I), - S.Context.getSizeType()); + S.Context.getSizeType()); return IllegalParams; } @@ -1572,7 +1574,8 @@ static bool SemaOpenCLBuiltinEnqueueKernel(Sema &S, CallExpr *TheCall) { // we have a block type, check the prototype const BlockPointerType *BPT = cast(Arg3->getType().getCanonicalType()); - if (BPT->getPointeeType()->castAs()->getNumParams() > 0) { + if (BPT->getPointeeType()->castAs()->getNumParams() > + 0) { S.Diag(Arg3->getBeginLoc(), diag::err_opencl_enqueue_kernel_blocks_no_args); return true; @@ -1643,7 +1646,7 @@ static bool SemaOpenCLBuiltinEnqueueKernel(Sema &S, CallExpr *TheCall) { /// Returns OpenCL access qual. static OpenCLAccessAttr *getOpenCLArgAccess(const Decl *D) { - return D->getAttr(); + return D->getAttr(); } /// Returns true if pipe element type is different from the pointer. @@ -1852,8 +1855,8 @@ static bool SemaOpenCLBuiltinToAddr(Sema &S, unsigned BuiltinID, return true; auto RT = Call->getArg(0)->getType(); - if (!RT->isPointerType() || RT->getPointeeType() - .getAddressSpace() == LangAS::opencl_constant) { + if (!RT->isPointerType() || + RT->getPointeeType().getAddressSpace() == LangAS::opencl_constant) { S.Diag(Call->getBeginLoc(), diag::err_opencl_builtin_to_addr_invalid_arg) << Call->getArg(0) << Call->getDirectCallee() << Call->getSourceRange(); return true; @@ -1881,8 +1884,8 @@ static bool SemaOpenCLBuiltinToAddr(Sema &S, unsigned BuiltinID, default: llvm_unreachable("Invalid builtin function"); } - Call->setType(S.Context.getPointerType(S.Context.getQualifiedType( - RT.getUnqualifiedType(), Qual))); + Call->setType(S.Context.getPointerType( + S.Context.getQualifiedType(RT.getUnqualifiedType(), Qual))); return false; } @@ -2020,13 +2023,13 @@ bool Sema::CheckTSBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case llvm::Triple::riscv32: case llvm::Triple::riscv64: return CheckRISCVBuiltinFunctionCall(TI, BuiltinID, TheCall) || - CheckRISCVCOREVBuiltinFunctionCall(BuiltinID, TheCall); + CheckRISCVCOREVBuiltinFunctionCall(BuiltinID, TheCall); } } -ExprResult -Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, - CallExpr *TheCall) { +ExprResult Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, + unsigned BuiltinID, + CallExpr *TheCall) { ExprResult TheCallResult(TheCall); // Find out if any arguments are required to be integer constant expressions. @@ -2034,12 +2037,13 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, ASTContext::GetBuiltinTypeError Error; Context.GetBuiltinType(BuiltinID, Error, &ICEArguments); if (Error != ASTContext::GE_None) - ICEArguments = 0; // Don't diagnose previously diagnosed errors. + 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; + if ((ICEArguments & (1 << ArgNo)) == 0) + continue; llvm::APSInt Result; // If we don't have enough arguments, continue so we can issue better @@ -2181,7 +2185,8 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, return ExprError(); break; case Builtin::BI__builtin_classify_type: - if (checkArgCount(*this, TheCall, 1)) return true; + if (checkArgCount(*this, TheCall, 1)) + return true; TheCall->setType(Context.IntTy); break; case Builtin::BI__builtin_complex: @@ -2189,9 +2194,11 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, return ExprError(); break; case Builtin::BI__builtin_constant_p: { - if (checkArgCount(*this, TheCall, 1)) return true; + if (checkArgCount(*this, TheCall, 1)) + return true; ExprResult Arg = DefaultFunctionArrayLvalueConversion(TheCall->getArg(0)); - if (Arg.isInvalid()) return true; + if (Arg.isInvalid()) + return true; TheCall->setArg(0, Arg.get()); TheCall->setType(Context.IntTy); break; @@ -2333,8 +2340,8 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, break; } #define BUILTIN(ID, TYPE, ATTRS) -#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \ - case Builtin::BI##ID: \ +#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \ + case Builtin::BI##ID: \ return SemaAtomicOpsOverloaded(TheCallResult, AtomicExpr::AO##ID); #include "clang/Basic/Builtins.def" case Builtin::BI__annotation: @@ -2651,7 +2658,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, const auto *TyA = Arg->getType()->getAs(); if (!TyA || !TyA->getElementType()->isIntegerType()) { Diag(Arg->getBeginLoc(), diag::err_builtin_invalid_arg_type) - << 1 << /* vector of integers */ 6 << Arg->getType(); + << 1 << /* vector of integers */ 6 << Arg->getType(); return ExprError(); } TheCall->setType(TyA->getElementType()); @@ -2786,7 +2793,7 @@ static QualType getNeonEltType(NeonTypeFlags Flags, ASTContext &Context, bool Sema::CheckSVEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { // Range check SVE intrinsics that take immediate values. - SmallVector, 3> ImmChecks; + SmallVector, 3> ImmChecks; switch (BuiltinID) { default: @@ -2802,7 +2809,7 @@ bool Sema::CheckSVEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { int ArgNum, CheckTy, ElementSizeInBits; std::tie(ArgNum, CheckTy, ElementSizeInBits) = I; - typedef bool(*OptionSetCheckFnTy)(int64_t Value); + typedef bool (*OptionSetCheckFnTy)(int64_t Value); // Function that checks whether the operand (ArgNum) is an immediate // that is one of the predefined values. @@ -2914,14 +2921,14 @@ bool Sema::CheckNeonBuiltinFunctionCall(const TargetInfo &TI, bool HasConstPtr = false; switch (BuiltinID) { #define GET_NEON_OVERLOAD_CHECK -#include "clang/Basic/arm_neon.inc" #include "clang/Basic/arm_fp16.inc" +#include "clang/Basic/arm_neon.inc" #undef GET_NEON_OVERLOAD_CHECK } // For NEON intrinsics which are overloaded on vector element type, validate // the immediate which specifies which variant to emit. - unsigned ImmArg = TheCall->getNumArgs()-1; + unsigned ImmArg = TheCall->getNumArgs() - 1; if (mask) { if (SemaBuiltinConstantArg(TheCall, ImmArg, Result)) return true; @@ -2965,10 +2972,10 @@ bool Sema::CheckNeonBuiltinFunctionCall(const TargetInfo &TI, switch (BuiltinID) { default: return false; - #define GET_NEON_IMMEDIATE_CHECK - #include "clang/Basic/arm_neon.inc" - #include "clang/Basic/arm_fp16.inc" - #undef GET_NEON_IMMEDIATE_CHECK +#define GET_NEON_IMMEDIATE_CHECK +#include "clang/Basic/arm_fp16.inc" +#include "clang/Basic/arm_neon.inc" +#undef GET_NEON_IMMEDIATE_CHECK } return SemaBuiltinConstantArgRange(TheCall, i, l, u + l); @@ -2978,7 +2985,7 @@ bool Sema::CheckMVEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { switch (BuiltinID) { default: return false; - #include "clang/Basic/arm_mve_builtin_sema.inc" +#include "clang/Basic/arm_mve_builtin_sema.inc" } } @@ -3036,7 +3043,8 @@ bool Sema::CheckARMBuiltinExclusiveCall(unsigned BuiltinID, CallExpr *TheCall, BuiltinID == AArch64::BI__builtin_arm_ldrex || BuiltinID == AArch64::BI__builtin_arm_ldaex; - DeclRefExpr *DRE =cast(TheCall->getCallee()->IgnoreParenCasts()); + DeclRefExpr *DRE = + cast(TheCall->getCallee()->IgnoreParenCasts()); // Ensure that we have the proper number of arguments. if (checkArgCount(*this, TheCall, IsLdrex ? 1 : 2)) @@ -3146,7 +3154,7 @@ bool Sema::CheckARMBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, if (BuiltinID == ARM::BI__builtin_arm_prefetch) { return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1) || - SemaBuiltinConstantArgRange(TheCall, 2, 0, 1); + SemaBuiltinConstantArgRange(TheCall, 2, 0, 1); } if (BuiltinID == ARM::BI__builtin_arm_rsr64 || @@ -3170,7 +3178,8 @@ bool Sema::CheckARMBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, // range check them here. // FIXME: VFP Intrinsics should error if VFP not present. switch (BuiltinID) { - default: return false; + default: + return false; case ARM::BI__builtin_arm_ssat: return SemaBuiltinConstantArgRange(TheCall, 1, 1, 32); case ARM::BI__builtin_arm_usat: @@ -3223,9 +3232,9 @@ bool Sema::CheckAArch64BuiltinFunctionCall(const TargetInfo &TI, if (BuiltinID == AArch64::BI__builtin_arm_prefetch) { return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1) || - SemaBuiltinConstantArgRange(TheCall, 2, 0, 2) || - SemaBuiltinConstantArgRange(TheCall, 3, 0, 1) || - SemaBuiltinConstantArgRange(TheCall, 4, 0, 1); + SemaBuiltinConstantArgRange(TheCall, 2, 0, 2) || + SemaBuiltinConstantArgRange(TheCall, 3, 0, 1) || + SemaBuiltinConstantArgRange(TheCall, 4, 0, 1); } if (BuiltinID == AArch64::BI__builtin_arm_rsr64 || @@ -3271,11 +3280,18 @@ bool Sema::CheckAArch64BuiltinFunctionCall(const TargetInfo &TI, // range check them here. unsigned i = 0, l = 0, u = 0; switch (BuiltinID) { - default: return false; + default: + return false; case AArch64::BI__builtin_arm_dmb: case AArch64::BI__builtin_arm_dsb: - case AArch64::BI__builtin_arm_isb: l = 0; u = 15; break; - case AArch64::BI__builtin_arm_tcancel: l = 0; u = 65535; break; + case AArch64::BI__builtin_arm_isb: + l = 0; + u = 15; + break; + case AArch64::BI__builtin_arm_tcancel: + l = 0; + u = 65535; + break; } return SemaBuiltinConstantArgRange(TheCall, i, l, u + l); @@ -3365,8 +3381,7 @@ static bool isValidBPFPreserveEnumValueArg(Expr *Arg) { return llvm::is_contained(ET->getDecl()->enumerators(), Enumerator); } -bool Sema::CheckBPFBuiltinFunctionCall(unsigned BuiltinID, - CallExpr *TheCall) { +bool Sema::CheckBPFBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { assert((BuiltinID == BPF::BI__builtin_preserve_field_info || BuiltinID == BPF::BI__builtin_btf_type_id || BuiltinID == BPF::BI__builtin_preserve_type_info || @@ -3442,198 +3457,190 @@ bool Sema::CheckHexagonBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) { }; static BuiltinInfo Infos[] = { - { Hexagon::BI__builtin_circ_ldd, {{ 3, true, 4, 3 }} }, - { Hexagon::BI__builtin_circ_ldw, {{ 3, true, 4, 2 }} }, - { Hexagon::BI__builtin_circ_ldh, {{ 3, true, 4, 1 }} }, - { Hexagon::BI__builtin_circ_lduh, {{ 3, true, 4, 1 }} }, - { Hexagon::BI__builtin_circ_ldb, {{ 3, true, 4, 0 }} }, - { Hexagon::BI__builtin_circ_ldub, {{ 3, true, 4, 0 }} }, - { Hexagon::BI__builtin_circ_std, {{ 3, true, 4, 3 }} }, - { Hexagon::BI__builtin_circ_stw, {{ 3, true, 4, 2 }} }, - { Hexagon::BI__builtin_circ_sth, {{ 3, true, 4, 1 }} }, - { Hexagon::BI__builtin_circ_sthhi, {{ 3, true, 4, 1 }} }, - { Hexagon::BI__builtin_circ_stb, {{ 3, true, 4, 0 }} }, - - { Hexagon::BI__builtin_HEXAGON_L2_loadrub_pci, {{ 1, true, 4, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_L2_loadrb_pci, {{ 1, true, 4, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_L2_loadruh_pci, {{ 1, true, 4, 1 }} }, - { Hexagon::BI__builtin_HEXAGON_L2_loadrh_pci, {{ 1, true, 4, 1 }} }, - { Hexagon::BI__builtin_HEXAGON_L2_loadri_pci, {{ 1, true, 4, 2 }} }, - { Hexagon::BI__builtin_HEXAGON_L2_loadrd_pci, {{ 1, true, 4, 3 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_storerb_pci, {{ 1, true, 4, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_storerh_pci, {{ 1, true, 4, 1 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_storerf_pci, {{ 1, true, 4, 1 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_storeri_pci, {{ 1, true, 4, 2 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_storerd_pci, {{ 1, true, 4, 3 }} }, - - { Hexagon::BI__builtin_HEXAGON_A2_combineii, {{ 1, true, 8, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_A2_tfrih, {{ 1, false, 16, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_A2_tfril, {{ 1, false, 16, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_A2_tfrpi, {{ 0, true, 8, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_A4_bitspliti, {{ 1, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_A4_cmpbeqi, {{ 1, false, 8, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_A4_cmpbgti, {{ 1, true, 8, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_A4_cround_ri, {{ 1, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_A4_round_ri, {{ 1, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_A4_round_ri_sat, {{ 1, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_A4_vcmpbeqi, {{ 1, false, 8, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_A4_vcmpbgti, {{ 1, true, 8, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_A4_vcmpbgtui, {{ 1, false, 7, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_A4_vcmpheqi, {{ 1, true, 8, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_A4_vcmphgti, {{ 1, true, 8, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_A4_vcmphgtui, {{ 1, false, 7, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_A4_vcmpweqi, {{ 1, true, 8, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_A4_vcmpwgti, {{ 1, true, 8, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_A4_vcmpwgtui, {{ 1, false, 7, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_C2_bitsclri, {{ 1, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_C2_muxii, {{ 2, true, 8, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_C4_nbitsclri, {{ 1, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_F2_dfclass, {{ 1, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_F2_dfimm_n, {{ 0, false, 10, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_F2_dfimm_p, {{ 0, false, 10, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_F2_sfclass, {{ 1, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_F2_sfimm_n, {{ 0, false, 10, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_F2_sfimm_p, {{ 0, false, 10, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_M4_mpyri_addi, {{ 2, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_M4_mpyri_addr_u2, {{ 1, false, 6, 2 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_addasl_rrri, {{ 2, false, 3, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_acc, {{ 2, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_and, {{ 2, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p, {{ 1, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_nac, {{ 2, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_or, {{ 2, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_xacc, {{ 2, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_acc, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_and, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r, {{ 1, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_nac, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_or, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_sat, {{ 1, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_xacc, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asl_i_vh, {{ 1, false, 4, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asl_i_vw, {{ 1, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_acc, {{ 2, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_and, {{ 2, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p, {{ 1, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_nac, {{ 2, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_or, {{ 2, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd_goodsyntax, - {{ 1, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd, {{ 1, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_acc, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_and, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r, {{ 1, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_nac, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_or, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd_goodsyntax, - {{ 1, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd, {{ 1, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asr_i_svw_trun, {{ 1, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asr_i_vh, {{ 1, false, 4, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_asr_i_vw, {{ 1, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_clrbit_i, {{ 1, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_extractu, {{ 1, false, 5, 0 }, - { 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_extractup, {{ 1, false, 6, 0 }, - { 2, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_insert, {{ 2, false, 5, 0 }, - { 3, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_insertp, {{ 2, false, 6, 0 }, - { 3, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_acc, {{ 2, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_and, {{ 2, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p, {{ 1, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_nac, {{ 2, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_or, {{ 2, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_xacc, {{ 2, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_acc, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_and, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r, {{ 1, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_nac, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_or, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_xacc, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vh, {{ 1, false, 4, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vw, {{ 1, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_setbit_i, {{ 1, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_tableidxb_goodsyntax, - {{ 2, false, 4, 0 }, - { 3, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_tableidxd_goodsyntax, - {{ 2, false, 4, 0 }, - { 3, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_tableidxh_goodsyntax, - {{ 2, false, 4, 0 }, - { 3, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_tableidxw_goodsyntax, - {{ 2, false, 4, 0 }, - { 3, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_togglebit_i, {{ 1, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_tstbit_i, {{ 1, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_valignib, {{ 2, false, 3, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S2_vspliceib, {{ 2, false, 3, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S4_addi_asl_ri, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S4_addi_lsr_ri, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S4_andi_asl_ri, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S4_andi_lsr_ri, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S4_clbaddi, {{ 1, true , 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S4_clbpaddi, {{ 1, true, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S4_extract, {{ 1, false, 5, 0 }, - { 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S4_extractp, {{ 1, false, 6, 0 }, - { 2, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S4_lsli, {{ 0, true, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S4_ntstbit_i, {{ 1, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S4_ori_asl_ri, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S4_ori_lsr_ri, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S4_subi_asl_ri, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S4_subi_lsr_ri, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S4_vrcrotate_acc, {{ 3, false, 2, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S4_vrcrotate, {{ 2, false, 2, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S5_asrhub_rnd_sat_goodsyntax, - {{ 1, false, 4, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S5_asrhub_sat, {{ 1, false, 4, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S5_vasrhrnd_goodsyntax, - {{ 1, false, 4, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p, {{ 1, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_acc, {{ 2, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_and, {{ 2, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_nac, {{ 2, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_or, {{ 2, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_xacc, {{ 2, false, 6, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r, {{ 1, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_acc, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_and, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_nac, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_or, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_xacc, {{ 2, false, 5, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_V6_valignbi, {{ 2, false, 3, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_V6_valignbi_128B, {{ 2, false, 3, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_V6_vlalignbi, {{ 2, false, 3, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_V6_vlalignbi_128B, {{ 2, false, 3, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi, {{ 2, false, 1, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_128B, {{ 2, false, 1, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc, {{ 3, false, 1, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc_128B, - {{ 3, false, 1, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi, {{ 2, false, 1, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_128B, {{ 2, false, 1, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc, {{ 3, false, 1, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc_128B, - {{ 3, false, 1, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi, {{ 2, false, 1, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_128B, {{ 2, false, 1, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc, {{ 3, false, 1, 0 }} }, - { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc_128B, - {{ 3, false, 1, 0 }} }, + {Hexagon::BI__builtin_circ_ldd, {{3, true, 4, 3}}}, + {Hexagon::BI__builtin_circ_ldw, {{3, true, 4, 2}}}, + {Hexagon::BI__builtin_circ_ldh, {{3, true, 4, 1}}}, + {Hexagon::BI__builtin_circ_lduh, {{3, true, 4, 1}}}, + {Hexagon::BI__builtin_circ_ldb, {{3, true, 4, 0}}}, + {Hexagon::BI__builtin_circ_ldub, {{3, true, 4, 0}}}, + {Hexagon::BI__builtin_circ_std, {{3, true, 4, 3}}}, + {Hexagon::BI__builtin_circ_stw, {{3, true, 4, 2}}}, + {Hexagon::BI__builtin_circ_sth, {{3, true, 4, 1}}}, + {Hexagon::BI__builtin_circ_sthhi, {{3, true, 4, 1}}}, + {Hexagon::BI__builtin_circ_stb, {{3, true, 4, 0}}}, + + {Hexagon::BI__builtin_HEXAGON_L2_loadrub_pci, {{1, true, 4, 0}}}, + {Hexagon::BI__builtin_HEXAGON_L2_loadrb_pci, {{1, true, 4, 0}}}, + {Hexagon::BI__builtin_HEXAGON_L2_loadruh_pci, {{1, true, 4, 1}}}, + {Hexagon::BI__builtin_HEXAGON_L2_loadrh_pci, {{1, true, 4, 1}}}, + {Hexagon::BI__builtin_HEXAGON_L2_loadri_pci, {{1, true, 4, 2}}}, + {Hexagon::BI__builtin_HEXAGON_L2_loadrd_pci, {{1, true, 4, 3}}}, + {Hexagon::BI__builtin_HEXAGON_S2_storerb_pci, {{1, true, 4, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_storerh_pci, {{1, true, 4, 1}}}, + {Hexagon::BI__builtin_HEXAGON_S2_storerf_pci, {{1, true, 4, 1}}}, + {Hexagon::BI__builtin_HEXAGON_S2_storeri_pci, {{1, true, 4, 2}}}, + {Hexagon::BI__builtin_HEXAGON_S2_storerd_pci, {{1, true, 4, 3}}}, + + {Hexagon::BI__builtin_HEXAGON_A2_combineii, {{1, true, 8, 0}}}, + {Hexagon::BI__builtin_HEXAGON_A2_tfrih, {{1, false, 16, 0}}}, + {Hexagon::BI__builtin_HEXAGON_A2_tfril, {{1, false, 16, 0}}}, + {Hexagon::BI__builtin_HEXAGON_A2_tfrpi, {{0, true, 8, 0}}}, + {Hexagon::BI__builtin_HEXAGON_A4_bitspliti, {{1, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_A4_cmpbeqi, {{1, false, 8, 0}}}, + {Hexagon::BI__builtin_HEXAGON_A4_cmpbgti, {{1, true, 8, 0}}}, + {Hexagon::BI__builtin_HEXAGON_A4_cround_ri, {{1, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_A4_round_ri, {{1, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_A4_round_ri_sat, {{1, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_A4_vcmpbeqi, {{1, false, 8, 0}}}, + {Hexagon::BI__builtin_HEXAGON_A4_vcmpbgti, {{1, true, 8, 0}}}, + {Hexagon::BI__builtin_HEXAGON_A4_vcmpbgtui, {{1, false, 7, 0}}}, + {Hexagon::BI__builtin_HEXAGON_A4_vcmpheqi, {{1, true, 8, 0}}}, + {Hexagon::BI__builtin_HEXAGON_A4_vcmphgti, {{1, true, 8, 0}}}, + {Hexagon::BI__builtin_HEXAGON_A4_vcmphgtui, {{1, false, 7, 0}}}, + {Hexagon::BI__builtin_HEXAGON_A4_vcmpweqi, {{1, true, 8, 0}}}, + {Hexagon::BI__builtin_HEXAGON_A4_vcmpwgti, {{1, true, 8, 0}}}, + {Hexagon::BI__builtin_HEXAGON_A4_vcmpwgtui, {{1, false, 7, 0}}}, + {Hexagon::BI__builtin_HEXAGON_C2_bitsclri, {{1, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_C2_muxii, {{2, true, 8, 0}}}, + {Hexagon::BI__builtin_HEXAGON_C4_nbitsclri, {{1, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_F2_dfclass, {{1, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_F2_dfimm_n, {{0, false, 10, 0}}}, + {Hexagon::BI__builtin_HEXAGON_F2_dfimm_p, {{0, false, 10, 0}}}, + {Hexagon::BI__builtin_HEXAGON_F2_sfclass, {{1, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_F2_sfimm_n, {{0, false, 10, 0}}}, + {Hexagon::BI__builtin_HEXAGON_F2_sfimm_p, {{0, false, 10, 0}}}, + {Hexagon::BI__builtin_HEXAGON_M4_mpyri_addi, {{2, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_M4_mpyri_addr_u2, {{1, false, 6, 2}}}, + {Hexagon::BI__builtin_HEXAGON_S2_addasl_rrri, {{2, false, 3, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_acc, {{2, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_and, {{2, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asl_i_p, {{1, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_nac, {{2, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_or, {{2, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_xacc, {{2, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_acc, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_and, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asl_i_r, {{1, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_nac, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_or, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_sat, {{1, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_xacc, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asl_i_vh, {{1, false, 4, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asl_i_vw, {{1, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_acc, {{2, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_and, {{2, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asr_i_p, {{1, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_nac, {{2, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_or, {{2, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd_goodsyntax, + {{1, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd, {{1, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_acc, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_and, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asr_i_r, {{1, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_nac, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_or, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd_goodsyntax, + {{1, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd, {{1, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asr_i_svw_trun, {{1, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asr_i_vh, {{1, false, 4, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_asr_i_vw, {{1, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_clrbit_i, {{1, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_extractu, + {{1, false, 5, 0}, {2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_extractup, + {{1, false, 6, 0}, {2, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_insert, + {{2, false, 5, 0}, {3, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_insertp, + {{2, false, 6, 0}, {3, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_acc, {{2, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_and, {{2, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p, {{1, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_nac, {{2, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_or, {{2, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_xacc, {{2, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_acc, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_and, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r, {{1, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_nac, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_or, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_xacc, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vh, {{1, false, 4, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vw, {{1, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_setbit_i, {{1, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_tableidxb_goodsyntax, + {{2, false, 4, 0}, {3, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_tableidxd_goodsyntax, + {{2, false, 4, 0}, {3, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_tableidxh_goodsyntax, + {{2, false, 4, 0}, {3, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_tableidxw_goodsyntax, + {{2, false, 4, 0}, {3, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_togglebit_i, {{1, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_tstbit_i, {{1, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_valignib, {{2, false, 3, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S2_vspliceib, {{2, false, 3, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S4_addi_asl_ri, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S4_addi_lsr_ri, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S4_andi_asl_ri, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S4_andi_lsr_ri, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S4_clbaddi, {{1, true, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S4_clbpaddi, {{1, true, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S4_extract, + {{1, false, 5, 0}, {2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S4_extractp, + {{1, false, 6, 0}, {2, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S4_lsli, {{0, true, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S4_ntstbit_i, {{1, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S4_ori_asl_ri, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S4_ori_lsr_ri, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S4_subi_asl_ri, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S4_subi_lsr_ri, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S4_vrcrotate_acc, {{3, false, 2, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S4_vrcrotate, {{2, false, 2, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S5_asrhub_rnd_sat_goodsyntax, + {{1, false, 4, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S5_asrhub_sat, {{1, false, 4, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S5_vasrhrnd_goodsyntax, {{1, false, 4, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S6_rol_i_p, {{1, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_acc, {{2, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_and, {{2, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_nac, {{2, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_or, {{2, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_xacc, {{2, false, 6, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S6_rol_i_r, {{1, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_acc, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_and, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_nac, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_or, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_xacc, {{2, false, 5, 0}}}, + {Hexagon::BI__builtin_HEXAGON_V6_valignbi, {{2, false, 3, 0}}}, + {Hexagon::BI__builtin_HEXAGON_V6_valignbi_128B, {{2, false, 3, 0}}}, + {Hexagon::BI__builtin_HEXAGON_V6_vlalignbi, {{2, false, 3, 0}}}, + {Hexagon::BI__builtin_HEXAGON_V6_vlalignbi_128B, {{2, false, 3, 0}}}, + {Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi, {{2, false, 1, 0}}}, + {Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_128B, {{2, false, 1, 0}}}, + {Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc, {{3, false, 1, 0}}}, + {Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc_128B, {{3, false, 1, 0}}}, + {Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi, {{2, false, 1, 0}}}, + {Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_128B, {{2, false, 1, 0}}}, + {Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc, {{3, false, 1, 0}}}, + {Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc_128B, {{3, false, 1, 0}}}, + {Hexagon::BI__builtin_HEXAGON_V6_vrsadubi, {{2, false, 1, 0}}}, + {Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_128B, {{2, false, 1, 0}}}, + {Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc, {{3, false, 1, 0}}}, + {Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc_128B, {{3, false, 1, 0}}}, }; // Use a dynamically initialized static to sort the table exactly once on // first run. static const bool SortOnce = (llvm::sort(Infos, - [](const BuiltinInfo &LHS, const BuiltinInfo &RHS) { - return LHS.BuiltinID < RHS.BuiltinID; - }), + [](const BuiltinInfo &LHS, const BuiltinInfo &RHS) { + return LHS.BuiltinID < RHS.BuiltinID; + }), true); (void)SortOnce; @@ -3712,14 +3719,43 @@ bool Sema::CheckMipsBuiltinCpu(const TargetInfo &TI, unsigned BuiltinID, bool Sema::CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) { unsigned i = 0, l = 0, u = 0, m = 0; switch (BuiltinID) { - default: return false; - case Mips::BI__builtin_mips_wrdsp: i = 1; l = 0; u = 63; break; - case Mips::BI__builtin_mips_rddsp: i = 0; l = 0; u = 63; break; - case Mips::BI__builtin_mips_append: i = 2; l = 0; u = 31; break; - case Mips::BI__builtin_mips_balign: i = 2; l = 0; u = 3; break; - case Mips::BI__builtin_mips_precr_sra_ph_w: i = 2; l = 0; u = 31; break; - case Mips::BI__builtin_mips_precr_sra_r_ph_w: i = 2; l = 0; u = 31; break; - case Mips::BI__builtin_mips_prepend: i = 2; l = 0; u = 31; break; + default: + return false; + case Mips::BI__builtin_mips_wrdsp: + i = 1; + l = 0; + u = 63; + break; + case Mips::BI__builtin_mips_rddsp: + i = 0; + l = 0; + u = 63; + break; + case Mips::BI__builtin_mips_append: + i = 2; + l = 0; + u = 31; + break; + case Mips::BI__builtin_mips_balign: + i = 2; + l = 0; + u = 3; + break; + case Mips::BI__builtin_mips_precr_sra_ph_w: + i = 2; + l = 0; + u = 31; + break; + case Mips::BI__builtin_mips_precr_sra_r_ph_w: + i = 2; + l = 0; + u = 31; + break; + case Mips::BI__builtin_mips_prepend: + i = 2; + l = 0; + u = 31; + break; // MSA intrinsics. Instructions (which the intrinsics maps to) which use the // df/m field. // These intrinsics take an unsigned 3 bit immediate. @@ -3732,9 +3768,17 @@ bool Sema::CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) { case Mips::BI__builtin_msa_srai_b: case Mips::BI__builtin_msa_srari_b: case Mips::BI__builtin_msa_srli_b: - case Mips::BI__builtin_msa_srlri_b: i = 1; l = 0; u = 7; break; + case Mips::BI__builtin_msa_srlri_b: + i = 1; + l = 0; + u = 7; + break; case Mips::BI__builtin_msa_binsli_b: - case Mips::BI__builtin_msa_binsri_b: i = 2; l = 0; u = 7; break; + case Mips::BI__builtin_msa_binsri_b: + i = 2; + l = 0; + u = 7; + break; // These intrinsics take an unsigned 4 bit immediate. case Mips::BI__builtin_msa_bclri_h: case Mips::BI__builtin_msa_bnegi_h: @@ -3745,14 +3789,26 @@ bool Sema::CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) { case Mips::BI__builtin_msa_srai_h: case Mips::BI__builtin_msa_srari_h: case Mips::BI__builtin_msa_srli_h: - case Mips::BI__builtin_msa_srlri_h: i = 1; l = 0; u = 15; break; + case Mips::BI__builtin_msa_srlri_h: + i = 1; + l = 0; + u = 15; + break; case Mips::BI__builtin_msa_binsli_h: - case Mips::BI__builtin_msa_binsri_h: i = 2; l = 0; u = 15; break; + case Mips::BI__builtin_msa_binsri_h: + i = 2; + l = 0; + u = 15; + break; // These intrinsics take an unsigned 5 bit immediate. // The first block of intrinsics actually have an unsigned 5 bit field, // not a df/n field. case Mips::BI__builtin_msa_cfcmsa: - case Mips::BI__builtin_msa_ctcmsa: i = 0; l = 0; u = 31; break; + case Mips::BI__builtin_msa_ctcmsa: + i = 0; + l = 0; + u = 31; + break; case Mips::BI__builtin_msa_clei_u_b: case Mips::BI__builtin_msa_clei_u_h: case Mips::BI__builtin_msa_clei_u_w: @@ -3786,9 +3842,17 @@ bool Sema::CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) { case Mips::BI__builtin_msa_subvi_b: case Mips::BI__builtin_msa_subvi_h: case Mips::BI__builtin_msa_subvi_w: - case Mips::BI__builtin_msa_subvi_d: i = 1; l = 0; u = 31; break; + case Mips::BI__builtin_msa_subvi_d: + i = 1; + l = 0; + u = 31; + break; case Mips::BI__builtin_msa_binsli_w: - case Mips::BI__builtin_msa_binsri_w: i = 2; l = 0; u = 31; break; + case Mips::BI__builtin_msa_binsri_w: + i = 2; + l = 0; + u = 31; + break; // These intrinsics take an unsigned 6 bit immediate. case Mips::BI__builtin_msa_bclri_d: case Mips::BI__builtin_msa_bnegi_d: @@ -3799,9 +3863,17 @@ bool Sema::CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) { case Mips::BI__builtin_msa_srai_d: case Mips::BI__builtin_msa_srari_d: case Mips::BI__builtin_msa_srli_d: - case Mips::BI__builtin_msa_srlri_d: i = 1; l = 0; u = 63; break; + case Mips::BI__builtin_msa_srlri_d: + i = 1; + l = 0; + u = 63; + break; case Mips::BI__builtin_msa_binsli_d: - case Mips::BI__builtin_msa_binsri_d: i = 2; l = 0; u = 63; break; + case Mips::BI__builtin_msa_binsri_d: + i = 2; + l = 0; + u = 63; + break; // These intrinsics take a signed 5 bit immediate. case Mips::BI__builtin_msa_ceqi_b: case Mips::BI__builtin_msa_ceqi_h: @@ -3822,7 +3894,11 @@ bool Sema::CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) { case Mips::BI__builtin_msa_mini_s_b: case Mips::BI__builtin_msa_mini_s_h: case Mips::BI__builtin_msa_mini_s_w: - case Mips::BI__builtin_msa_mini_s_d: i = 1; l = -16; u = 15; break; + case Mips::BI__builtin_msa_mini_s_d: + i = 1; + l = -16; + u = 15; + break; // These intrinsics take an unsigned 8 bit immediate. case Mips::BI__builtin_msa_andi_b: case Mips::BI__builtin_msa_nori_b: @@ -3830,53 +3906,161 @@ bool Sema::CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) { case Mips::BI__builtin_msa_shf_b: case Mips::BI__builtin_msa_shf_h: case Mips::BI__builtin_msa_shf_w: - case Mips::BI__builtin_msa_xori_b: i = 1; l = 0; u = 255; break; + case Mips::BI__builtin_msa_xori_b: + i = 1; + l = 0; + u = 255; + break; case Mips::BI__builtin_msa_bseli_b: case Mips::BI__builtin_msa_bmnzi_b: - case Mips::BI__builtin_msa_bmzi_b: i = 2; l = 0; u = 255; break; + case Mips::BI__builtin_msa_bmzi_b: + i = 2; + l = 0; + u = 255; + break; // df/n format // These intrinsics take an unsigned 4 bit immediate. case Mips::BI__builtin_msa_copy_s_b: case Mips::BI__builtin_msa_copy_u_b: case Mips::BI__builtin_msa_insve_b: - case Mips::BI__builtin_msa_splati_b: i = 1; l = 0; u = 15; break; - case Mips::BI__builtin_msa_sldi_b: i = 2; l = 0; u = 15; break; + case Mips::BI__builtin_msa_splati_b: + i = 1; + l = 0; + u = 15; + break; + case Mips::BI__builtin_msa_sldi_b: + i = 2; + l = 0; + u = 15; + break; // These intrinsics take an unsigned 3 bit immediate. case Mips::BI__builtin_msa_copy_s_h: case Mips::BI__builtin_msa_copy_u_h: case Mips::BI__builtin_msa_insve_h: - case Mips::BI__builtin_msa_splati_h: i = 1; l = 0; u = 7; break; - case Mips::BI__builtin_msa_sldi_h: i = 2; l = 0; u = 7; break; + case Mips::BI__builtin_msa_splati_h: + i = 1; + l = 0; + u = 7; + break; + case Mips::BI__builtin_msa_sldi_h: + i = 2; + l = 0; + u = 7; + break; // These intrinsics take an unsigned 2 bit immediate. case Mips::BI__builtin_msa_copy_s_w: case Mips::BI__builtin_msa_copy_u_w: case Mips::BI__builtin_msa_insve_w: - case Mips::BI__builtin_msa_splati_w: i = 1; l = 0; u = 3; break; - case Mips::BI__builtin_msa_sldi_w: i = 2; l = 0; u = 3; break; + case Mips::BI__builtin_msa_splati_w: + i = 1; + l = 0; + u = 3; + break; + case Mips::BI__builtin_msa_sldi_w: + i = 2; + l = 0; + u = 3; + break; // These intrinsics take an unsigned 1 bit immediate. case Mips::BI__builtin_msa_copy_s_d: case Mips::BI__builtin_msa_copy_u_d: case Mips::BI__builtin_msa_insve_d: - case Mips::BI__builtin_msa_splati_d: i = 1; l = 0; u = 1; break; - case Mips::BI__builtin_msa_sldi_d: i = 2; l = 0; u = 1; break; + case Mips::BI__builtin_msa_splati_d: + i = 1; + l = 0; + u = 1; + break; + case Mips::BI__builtin_msa_sldi_d: + i = 2; + l = 0; + u = 1; + break; // Memory offsets and immediate loads. // These intrinsics take a signed 10 bit immediate. - case Mips::BI__builtin_msa_ldi_b: i = 0; l = -128; u = 255; break; + case Mips::BI__builtin_msa_ldi_b: + i = 0; + l = -128; + u = 255; + break; case Mips::BI__builtin_msa_ldi_h: case Mips::BI__builtin_msa_ldi_w: - case Mips::BI__builtin_msa_ldi_d: i = 0; l = -512; u = 511; break; - case Mips::BI__builtin_msa_ld_b: i = 1; l = -512; u = 511; m = 1; break; - case Mips::BI__builtin_msa_ld_h: i = 1; l = -1024; u = 1022; m = 2; break; - case Mips::BI__builtin_msa_ld_w: i = 1; l = -2048; u = 2044; m = 4; break; - case Mips::BI__builtin_msa_ld_d: i = 1; l = -4096; u = 4088; m = 8; break; - case Mips::BI__builtin_msa_ldr_d: i = 1; l = -4096; u = 4088; m = 8; break; - case Mips::BI__builtin_msa_ldr_w: i = 1; l = -2048; u = 2044; m = 4; break; - case Mips::BI__builtin_msa_st_b: i = 2; l = -512; u = 511; m = 1; break; - case Mips::BI__builtin_msa_st_h: i = 2; l = -1024; u = 1022; m = 2; break; - case Mips::BI__builtin_msa_st_w: i = 2; l = -2048; u = 2044; m = 4; break; - case Mips::BI__builtin_msa_st_d: i = 2; l = -4096; u = 4088; m = 8; break; - case Mips::BI__builtin_msa_str_d: i = 2; l = -4096; u = 4088; m = 8; break; - case Mips::BI__builtin_msa_str_w: i = 2; l = -2048; u = 2044; m = 4; break; + case Mips::BI__builtin_msa_ldi_d: + i = 0; + l = -512; + u = 511; + break; + case Mips::BI__builtin_msa_ld_b: + i = 1; + l = -512; + u = 511; + m = 1; + break; + case Mips::BI__builtin_msa_ld_h: + i = 1; + l = -1024; + u = 1022; + m = 2; + break; + case Mips::BI__builtin_msa_ld_w: + i = 1; + l = -2048; + u = 2044; + m = 4; + break; + case Mips::BI__builtin_msa_ld_d: + i = 1; + l = -4096; + u = 4088; + m = 8; + break; + case Mips::BI__builtin_msa_ldr_d: + i = 1; + l = -4096; + u = 4088; + m = 8; + break; + case Mips::BI__builtin_msa_ldr_w: + i = 1; + l = -2048; + u = 2044; + m = 4; + break; + case Mips::BI__builtin_msa_st_b: + i = 2; + l = -512; + u = 511; + m = 1; + break; + case Mips::BI__builtin_msa_st_h: + i = 2; + l = -1024; + u = 1022; + m = 2; + break; + case Mips::BI__builtin_msa_st_w: + i = 2; + l = -2048; + u = 2044; + m = 4; + break; + case Mips::BI__builtin_msa_st_d: + i = 2; + l = -4096; + u = 4088; + m = 8; + break; + case Mips::BI__builtin_msa_str_d: + i = 2; + l = -4096; + u = 4088; + m = 8; + break; + case Mips::BI__builtin_msa_str_w: + i = 2; + l = -2048; + u = 2044; + m = 4; + break; } if (!m) @@ -3915,10 +4099,13 @@ static QualType DecodePPCMMATypeFromStr(ASTContext &Context, const char *&Str, Str = End; QualType Type; switch (size) { - #define PPC_VECTOR_TYPE(typeName, Id, size) \ - case size: Type = Context.Id##Ty; break; - #include "clang/Basic/PPCTypes.def" - default: llvm_unreachable("Invalid PowerPC MMA vector type"); +#define PPC_VECTOR_TYPE(typeName, Id, size) \ + case size: \ + Type = Context.Id##Ty; \ + break; +#include "clang/Basic/PPCTypes.def" + default: + llvm_unreachable("Invalid PowerPC MMA vector type"); } bool CheckVectorArgs = false; while (!CheckVectorArgs) { @@ -4028,7 +4215,8 @@ bool Sema::CheckPPCBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, << TheCall->getSourceRange(); switch (BuiltinID) { - default: return false; + default: + return false; case PPC::BI__builtin_altivec_crypto_vshasigmaw: case PPC::BI__builtin_altivec_crypto_vshasigmad: return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1) || @@ -4114,15 +4302,15 @@ bool Sema::CheckPPCBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, return SemaFeatureCheck(*this, TheCall, "isa-v31-instructions", diag::err_ppc_builtin_only_on_arch, "10"); case PPC::BI__builtin_altivec_vgnb: - return SemaBuiltinConstantArgRange(TheCall, 1, 2, 7); + return SemaBuiltinConstantArgRange(TheCall, 1, 2, 7); case PPC::BI__builtin_vsx_xxeval: - return SemaBuiltinConstantArgRange(TheCall, 3, 0, 255); + return SemaBuiltinConstantArgRange(TheCall, 3, 0, 255); case PPC::BI__builtin_altivec_vsldbi: - return SemaBuiltinConstantArgRange(TheCall, 2, 0, 7); + return SemaBuiltinConstantArgRange(TheCall, 2, 0, 7); case PPC::BI__builtin_altivec_vsrdbi: - return SemaBuiltinConstantArgRange(TheCall, 2, 0, 7); + return SemaBuiltinConstantArgRange(TheCall, 2, 0, 7); case PPC::BI__builtin_vsx_xxpermx: - return SemaBuiltinConstantArgRange(TheCall, 3, 0, 7); + return SemaBuiltinConstantArgRange(TheCall, 3, 0, 7); case PPC::BI__builtin_ppc_tw: case PPC::BI__builtin_ppc_tdw: return SemaBuiltinConstantArgRange(TheCall, 2, 1, 31); @@ -4273,7 +4461,7 @@ bool Sema::CheckPPCMMAType(QualType Type, SourceLocation TypeLoc) { #define PPC_VECTOR_TYPE(Name, Id, Size) || CoreType == Context.Id##Ty if (false #include "clang/Basic/PPCTypes.def" - ) { + ) { Diag(TypeLoc, diag::err_ppc_invalid_use_mma_type); return true; } @@ -4407,8 +4595,7 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo &TI, // Error message FeatureMissing = true; Diag(TheCall->getBeginLoc(), diag::err_riscv_builtin_requires_extension) - << IsExtension - << TheCall->getSourceRange() << StringRef(FeatureStrs); + << IsExtension << TheCall->getSourceRange() << StringRef(FeatureStrs); } } @@ -4463,11 +4650,12 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo &TI, } bool Sema::CheckRISCVCOREVBuiltinFunctionCall(unsigned BuiltinID, - CallExpr *TheCall) { + CallExpr *TheCall) { // For intrinsics which take an immediate value as part of the instruction, // range check them here. switch (BuiltinID) { - default: return false; + default: + return false; case RISCVCOREV::BI__builtin_riscv_cv_simd_extract_h: case RISCVCOREV::BI__builtin_riscv_cv_simd_extract_b: case RISCVCOREV::BI__builtin_riscv_cv_simd_extractu_h: @@ -4493,12 +4681,21 @@ bool Sema::CheckSystemZBuiltinFunctionCall(unsigned BuiltinID, // range check them here. unsigned i = 0, l = 0, u = 0; switch (BuiltinID) { - default: return false; - case SystemZ::BI__builtin_s390_lcbb: i = 1; l = 0; u = 15; break; + default: + return false; + case SystemZ::BI__builtin_s390_lcbb: + i = 1; + l = 0; + u = 15; + break; case SystemZ::BI__builtin_s390_verimb: case SystemZ::BI__builtin_s390_verimh: case SystemZ::BI__builtin_s390_verimf: - case SystemZ::BI__builtin_s390_verimg: i = 3; l = 0; u = 255; break; + case SystemZ::BI__builtin_s390_verimg: + i = 3; + l = 0; + u = 255; + break; case SystemZ::BI__builtin_s390_vfaeb: case SystemZ::BI__builtin_s390_vfaeh: case SystemZ::BI__builtin_s390_vfaef: @@ -4510,16 +4707,36 @@ bool Sema::CheckSystemZBuiltinFunctionCall(unsigned BuiltinID, case SystemZ::BI__builtin_s390_vfaezf: case SystemZ::BI__builtin_s390_vfaezbs: case SystemZ::BI__builtin_s390_vfaezhs: - case SystemZ::BI__builtin_s390_vfaezfs: i = 2; l = 0; u = 15; break; + case SystemZ::BI__builtin_s390_vfaezfs: + i = 2; + l = 0; + u = 15; + break; case SystemZ::BI__builtin_s390_vfisb: case SystemZ::BI__builtin_s390_vfidb: return SemaBuiltinConstantArgRange(TheCall, 1, 0, 15) || SemaBuiltinConstantArgRange(TheCall, 2, 0, 15); case SystemZ::BI__builtin_s390_vftcisb: - case SystemZ::BI__builtin_s390_vftcidb: i = 1; l = 0; u = 4095; break; - case SystemZ::BI__builtin_s390_vlbb: i = 1; l = 0; u = 15; break; - case SystemZ::BI__builtin_s390_vpdi: i = 2; l = 0; u = 15; break; - case SystemZ::BI__builtin_s390_vsldb: i = 2; l = 0; u = 15; break; + case SystemZ::BI__builtin_s390_vftcidb: + i = 1; + l = 0; + u = 4095; + break; + case SystemZ::BI__builtin_s390_vlbb: + i = 1; + l = 0; + u = 15; + break; + case SystemZ::BI__builtin_s390_vpdi: + i = 2; + l = 0; + u = 15; + break; + case SystemZ::BI__builtin_s390_vsldb: + i = 2; + l = 0; + u = 15; + break; case SystemZ::BI__builtin_s390_vstrcb: case SystemZ::BI__builtin_s390_vstrch: case SystemZ::BI__builtin_s390_vstrcf: @@ -4531,19 +4748,47 @@ bool Sema::CheckSystemZBuiltinFunctionCall(unsigned BuiltinID, case SystemZ::BI__builtin_s390_vstrcfs: case SystemZ::BI__builtin_s390_vstrczbs: case SystemZ::BI__builtin_s390_vstrczhs: - case SystemZ::BI__builtin_s390_vstrczfs: i = 3; l = 0; u = 15; break; - case SystemZ::BI__builtin_s390_vmslg: i = 3; l = 0; u = 15; break; + case SystemZ::BI__builtin_s390_vstrczfs: + i = 3; + l = 0; + u = 15; + break; + case SystemZ::BI__builtin_s390_vmslg: + i = 3; + l = 0; + u = 15; + break; case SystemZ::BI__builtin_s390_vfminsb: case SystemZ::BI__builtin_s390_vfmaxsb: case SystemZ::BI__builtin_s390_vfmindb: - case SystemZ::BI__builtin_s390_vfmaxdb: i = 2; l = 0; u = 15; break; - case SystemZ::BI__builtin_s390_vsld: i = 2; l = 0; u = 7; break; - case SystemZ::BI__builtin_s390_vsrd: i = 2; l = 0; u = 7; break; + case SystemZ::BI__builtin_s390_vfmaxdb: + i = 2; + l = 0; + u = 15; + break; + case SystemZ::BI__builtin_s390_vsld: + i = 2; + l = 0; + u = 7; + break; + case SystemZ::BI__builtin_s390_vsrd: + i = 2; + l = 0; + u = 7; + break; case SystemZ::BI__builtin_s390_vclfnhs: case SystemZ::BI__builtin_s390_vclfnls: case SystemZ::BI__builtin_s390_vcfn: - case SystemZ::BI__builtin_s390_vcnf: i = 1; l = 0; u = 15; break; - case SystemZ::BI__builtin_s390_vcrnfs: i = 2; l = 0; u = 15; break; + case SystemZ::BI__builtin_s390_vcnf: + i = 1; + l = 0; + u = 15; + break; + case SystemZ::BI__builtin_s390_vcrnfs: + i = 2; + l = 0; + u = 15; + break; } return SemaBuiltinConstantArgRange(TheCall, i, l, u); } @@ -4875,9 +5120,8 @@ bool Sema::CheckX86BuiltinRoundingOrSAE(unsigned BuiltinID, CallExpr *TheCall) { // is set. If the intrinsic has rounding control(bits 1:0), make sure its only // combined with ROUND_NO_EXC. If the intrinsic does not have rounding // control, allow ROUND_NO_EXC and ROUND_CUR_DIRECTION together. - if (Result == 4/*ROUND_CUR_DIRECTION*/ || - Result == 8/*ROUND_NO_EXC*/ || - (!HasRC && Result == 12/*ROUND_CUR_DIRECTION|ROUND_NO_EXC*/) || + if (Result == 4 /*ROUND_CUR_DIRECTION*/ || Result == 8 /*ROUND_NO_EXC*/ || + (!HasRC && Result == 12 /*ROUND_CUR_DIRECTION|ROUND_NO_EXC*/) || (HasRC && Result.getZExtValue() >= 8 && Result.getZExtValue() <= 11)) return false; @@ -5105,7 +5349,9 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_extracti64x2_256_mask: case X86::BI__builtin_ia32_extractf32x4_256_mask: case X86::BI__builtin_ia32_extracti32x4_256_mask: - i = 1; l = 0; u = 1; + i = 1; + l = 0; + u = 1; break; case X86::BI__builtin_ia32_vec_set_v2di: case X86::BI__builtin_ia32_vinsertf128_pd256: @@ -5120,7 +5366,9 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_inserti64x2_256: case X86::BI__builtin_ia32_insertf32x4_256: case X86::BI__builtin_ia32_inserti32x4_256: - i = 2; l = 0; u = 1; + i = 2; + l = 0; + u = 1; break; case X86::BI__builtin_ia32_vpermilpd: case X86::BI__builtin_ia32_vec_ext_v4hi: @@ -5131,12 +5379,16 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_extracti32x4_mask: case X86::BI__builtin_ia32_extractf64x2_512_mask: case X86::BI__builtin_ia32_extracti64x2_512_mask: - i = 1; l = 0; u = 3; + i = 1; + l = 0; + u = 3; break; case X86::BI_mm_prefetch: case X86::BI__builtin_ia32_vec_ext_v8hi: case X86::BI__builtin_ia32_vec_ext_v8si: - i = 1; l = 0; u = 7; + i = 1; + l = 0; + u = 7; break; case X86::BI__builtin_ia32_sha1rnds4: case X86::BI__builtin_ia32_blendpd: @@ -5152,13 +5404,17 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_inserti64x2_512: case X86::BI__builtin_ia32_insertf32x4: case X86::BI__builtin_ia32_inserti32x4: - i = 2; l = 0; u = 3; + i = 2; + l = 0; + u = 3; break; case X86::BI__builtin_ia32_vpermil2pd: case X86::BI__builtin_ia32_vpermil2pd256: case X86::BI__builtin_ia32_vpermil2ps: case X86::BI__builtin_ia32_vpermil2ps256: - i = 3; l = 0; u = 3; + i = 3; + l = 0; + u = 3; break; case X86::BI__builtin_ia32_cmpb128_mask: case X86::BI__builtin_ia32_cmpw128_mask: @@ -5194,7 +5450,9 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_vpcomq: case X86::BI__builtin_ia32_vec_set_v8hi: case X86::BI__builtin_ia32_vec_set_v8si: - i = 2; l = 0; u = 7; + i = 2; + l = 0; + u = 7; break; case X86::BI__builtin_ia32_vpermilpd256: case X86::BI__builtin_ia32_roundps: @@ -5212,7 +5470,9 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_getmantph512_mask: case X86::BI__builtin_ia32_vec_ext_v16qi: case X86::BI__builtin_ia32_vec_ext_v16hi: - i = 1; l = 0; u = 15; + i = 1; + l = 0; + u = 15; break; case X86::BI__builtin_ia32_pblendd128: case X86::BI__builtin_ia32_blendps: @@ -5231,10 +5491,14 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_getmantsh_round_mask: case X86::BI__builtin_ia32_vec_set_v16qi: case X86::BI__builtin_ia32_vec_set_v16hi: - i = 2; l = 0; u = 15; + i = 2; + l = 0; + u = 15; break; case X86::BI__builtin_ia32_vec_ext_v32qi: - i = 1; l = 0; u = 31; + i = 1; + l = 0; + u = 31; break; case X86::BI__builtin_ia32_cmpps: case X86::BI__builtin_ia32_cmpss: @@ -5251,7 +5515,9 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_cmpsd_mask: case X86::BI__builtin_ia32_cmpss_mask: case X86::BI__builtin_ia32_vec_set_v32qi: - i = 2; l = 0; u = 31; + i = 2; + l = 0; + u = 31; break; case X86::BI__builtin_ia32_permdf256: case X86::BI__builtin_ia32_permdi256: @@ -5329,7 +5595,9 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_kshiftrihi: case X86::BI__builtin_ia32_kshiftrisi: case X86::BI__builtin_ia32_kshiftridi: - i = 1; l = 0; u = 255; + i = 1; + l = 0; + u = 255; break; case X86::BI__builtin_ia32_vperm2f128_pd256: case X86::BI__builtin_ia32_vperm2f128_ps256: @@ -5379,7 +5647,9 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_vpshrdw128: case X86::BI__builtin_ia32_vpshrdw256: case X86::BI__builtin_ia32_vpshrdw512: - i = 2; l = 0; u = 255; + i = 2; + l = 0; + u = 255; break; case X86::BI__builtin_ia32_fixupimmpd512_mask: case X86::BI__builtin_ia32_fixupimmpd512_maskz: @@ -5409,7 +5679,9 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_pternlogq128_maskz: case X86::BI__builtin_ia32_pternlogq256_mask: case X86::BI__builtin_ia32_pternlogq256_maskz: - i = 3; l = 0; u = 255; + i = 3; + l = 0; + u = 255; break; case X86::BI__builtin_ia32_gatherpfdpd: case X86::BI__builtin_ia32_gatherpfdps: @@ -5419,7 +5691,9 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_scatterpfdps: case X86::BI__builtin_ia32_scatterpfqpd: case X86::BI__builtin_ia32_scatterpfqps: - i = 4; l = 2; u = 3; + i = 4; + l = 2; + u = 3; break; case X86::BI__builtin_ia32_reducesd_mask: case X86::BI__builtin_ia32_reducess_mask: @@ -5427,11 +5701,15 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_rndscaless_round_mask: case X86::BI__builtin_ia32_rndscalesh_round_mask: case X86::BI__builtin_ia32_reducesh_mask: - i = 4; l = 0; u = 255; + i = 4; + l = 0; + u = 255; break; case X86::BI__builtin_ia32_cmpccxadd32: case X86::BI__builtin_ia32_cmpccxadd64: - i = 3; l = 0; u = 15; + i = 3; + l = 0; + u = 15; break; } @@ -5462,7 +5740,7 @@ bool Sema::getFormatStringInfo(const FormatAttr *Format, bool IsCXXMember, // of member functions is counted. However, it doesn't appear in our own // lists, so decrement format_idx in that case. if (IsCXXMember) { - if(FSI->FormatIdx == 0) + if (FSI->FormatIdx == 0) return false; --FSI->FormatIdx; if (FSI->FirstDataArg != 0) @@ -5476,8 +5754,8 @@ bool Sema::getFormatStringInfo(const FormatAttr *Format, bool IsCXXMember, /// Returns true if the value evaluates to null. static bool CheckNonNullExpr(Sema &S, const Expr *Expr) { // If the expression has non-null type, it doesn't evaluate to null. - if (auto nullability - = Expr->IgnoreImplicit()->getType()->getNullability(S.Context)) { + if (auto nullability = + Expr->IgnoreImplicit()->getType()->getNullability(S.Context)) { if (*nullability == NullabilityKind::NonNull) return false; } @@ -5486,21 +5764,18 @@ static bool CheckNonNullExpr(Sema &S, const Expr *Expr) { // considered null for the purposes of the nonnull attribute. if (const RecordType *UT = Expr->getType()->getAsUnionType()) { if (UT->getDecl()->hasAttr()) - if (const CompoundLiteralExpr *CLE = - dyn_cast(Expr)) + if (const CompoundLiteralExpr *CLE = dyn_cast(Expr)) if (const InitListExpr *ILE = - dyn_cast(CLE->getInitializer())) + dyn_cast(CLE->getInitializer())) Expr = ILE->getInit(0); } bool Result; return (!Expr->isValueDependent() && - Expr->EvaluateAsBooleanCondition(Result, S.Context) && - !Result); + Expr->EvaluateAsBooleanCondition(Result, S.Context) && !Result); } -static void CheckNonNullArgument(Sema &S, - const Expr *ArgExpr, +static void CheckNonNullArgument(Sema &S, const Expr *ArgExpr, SourceLocation CallSiteLoc) { if (CheckNonNullExpr(S, ArgExpr)) S.DiagRuntimeBehavior(CallSiteLoc, ArgExpr, @@ -5520,19 +5795,17 @@ bool Sema::GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx) { /// Diagnose use of %s directive in an NSString which is being passed /// as formatting string to formatting method. -static void -DiagnoseCStringFormatDirectiveInCFAPI(Sema &S, - const NamedDecl *FDecl, - Expr **Args, - unsigned NumArgs) { +static void DiagnoseCStringFormatDirectiveInCFAPI(Sema &S, + const NamedDecl *FDecl, + Expr **Args, + unsigned NumArgs) { unsigned Idx = 0; bool Format = false; ObjCStringFormatFamily SFFamily = FDecl->getObjCFStringFormattingFamily(); if (SFFamily == ObjCStringFormatFamily::SFF_CFString) { Idx = 2; Format = true; - } - else + } else for (const auto *I : FDecl->specific_attrs()) { if (S.GetFormatNSStringIdx(I, Idx)) { Format = true; @@ -5546,7 +5819,7 @@ DiagnoseCStringFormatDirectiveInCFAPI(Sema &S, FormatExpr = CSCE->getSubExpr(); const StringLiteral *FormatString; if (const ObjCStringLiteral *OSL = - dyn_cast(FormatExpr->IgnoreParenImpCasts())) + dyn_cast(FormatExpr->IgnoreParenImpCasts())) FormatString = OSL->getString(); else FormatString = dyn_cast(FormatExpr->IgnoreParenImpCasts()); @@ -5554,9 +5827,9 @@ DiagnoseCStringFormatDirectiveInCFAPI(Sema &S, return; if (S.FormatStringHasSArg(FormatString)) { S.Diag(FormatExpr->getExprLoc(), diag::warn_objc_cdirective_format_string) - << "%s" << 1 << 1; + << "%s" << 1 << 1; S.Diag(FDecl->getLocation(), diag::note_entity_declared_at) - << FDecl->getDeclName(); + << FDecl->getDeclName(); } } @@ -5568,8 +5841,7 @@ static bool isNonNullType(ASTContext &ctx, QualType type) { return false; } -static void CheckNonNullArguments(Sema &S, - const NamedDecl *FDecl, +static void CheckNonNullArguments(Sema &S, const NamedDecl *FDecl, const FunctionProtoType *Proto, ArrayRef Args, SourceLocation CallSiteLoc) { @@ -5605,14 +5877,14 @@ static void CheckNonNullArguments(Sema &S, if (FDecl && (isa(FDecl) || isa(FDecl))) { // Handle the nonnull attribute on the parameters of the // function/method. - ArrayRef parms; + ArrayRef parms; if (const FunctionDecl *FD = dyn_cast(FDecl)) parms = FD->parameters(); else parms = cast(FDecl)->parameters(); unsigned ParamIndex = 0; - for (ArrayRef::iterator I = parms.begin(), E = parms.end(); + for (ArrayRef::iterator I = parms.begin(), E = parms.end(); I != E; ++I, ++ParamIndex) { const ParmVarDecl *PVD = *I; if (PVD->hasAttr() || @@ -5767,11 +6039,11 @@ void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto, if (CallType != VariadicDoesNotApply && (!FD || FD->getBuiltinID() != Builtin::BI__noop)) { unsigned NumParams = Proto ? Proto->getNumParams() - : FDecl && isa(FDecl) - ? cast(FDecl)->getNumParams() - : FDecl && isa(FDecl) - ? cast(FDecl)->param_size() - : 0; + : FDecl && isa(FDecl) + ? cast(FDecl)->getNumParams() + : FDecl && isa(FDecl) + ? cast(FDecl)->param_size() + : 0; for (unsigned ArgIdx = NumParams; ArgIdx < Args.size(); ++ArgIdx) { // Args[ArgIdx] can be null in malformed code. @@ -5866,13 +6138,13 @@ void Sema::CheckConstructorCall(FunctionDecl *FDecl, QualType ThisType, /// and safety properties not strictly enforced by the C type system. bool Sema::CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall, const FunctionProtoType *Proto) { - bool IsMemberOperatorCall = isa(TheCall) && - isa(FDecl); - bool IsMemberFunction = isa(TheCall) || - IsMemberOperatorCall; - VariadicCallType CallType = getVariadicCallType(FDecl, Proto, - TheCall->getCallee()); - Expr** Args = TheCall->getArgs(); + bool IsMemberOperatorCall = + isa(TheCall) && isa(FDecl); + bool IsMemberFunction = + isa(TheCall) || IsMemberOperatorCall; + VariadicCallType CallType = + getVariadicCallType(FDecl, Proto, TheCall->getCallee()); + Expr **Args = TheCall->getArgs(); unsigned NumArgs = TheCall->getNumArgs(); Expr *ImplicitThis = nullptr; @@ -5994,8 +6266,8 @@ bool Sema::CheckPointerCall(NamedDecl *NDecl, CallExpr *TheCall, /// Checks function calls when a FunctionDecl or a NamedDecl is not available, /// such as function pointers returned from functions. bool Sema::CheckOtherCall(CallExpr *TheCall, const FunctionProtoType *Proto) { - VariadicCallType CallType = getVariadicCallType(/*FDecl=*/nullptr, Proto, - TheCall->getCallee()); + VariadicCallType CallType = + getVariadicCallType(/*FDecl=*/nullptr, Proto, TheCall->getCallee()); checkCall(/*FDecl=*/nullptr, Proto, /*ThisArg=*/nullptr, llvm::makeArrayRef(TheCall->getArgs(), TheCall->getNumArgs()), /*IsMemberFunction=*/false, TheCall->getRParenLoc(), @@ -6039,7 +6311,8 @@ static bool isValidOrderingForOp(int64_t Ordering, AtomicExpr::AtomicOp Op) { ExprResult Sema::SemaAtomicOpsOverloaded(ExprResult TheCallResult, AtomicExpr::AtomicOp Op) { CallExpr *TheCall = cast(TheCallResult.get()); - DeclRefExpr *DRE =cast(TheCall->getCallee()->IgnoreParenCasts()); + DeclRefExpr *DRE = + cast(TheCall->getCallee()->IgnoreParenCasts()); MultiExprArg Args{TheCall->getArgs(), TheCall->getNumArgs()}; return BuildAtomicExpr({TheCall->getBeginLoc(), TheCall->getEndLoc()}, DRE->getSourceRange(), TheCall->getRParenLoc(), Args, @@ -6083,8 +6356,8 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, } Form = Init; const unsigned NumForm = GNUCmpXchg + 1; - const unsigned NumArgs[] = { 2, 2, 3, 3, 3, 3, 4, 5, 6 }; - const unsigned NumVals[] = { 1, 0, 1, 1, 1, 1, 2, 2, 3 }; + const unsigned NumArgs[] = {2, 2, 3, 3, 3, 3, 4, 5, 6}; + const unsigned NumVals[] = {1, 0, 1, 1, 1, 1, 2, 2, 3}; // where: // C is an appropriate type, // A is volatile _Atomic(C) for __c11 builtins and is C for GNU builtins, @@ -6092,9 +6365,9 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, // M is C if C is an integer, and ptrdiff_t if C is a pointer, and // the int parameters are for orderings. - static_assert(sizeof(NumArgs)/sizeof(NumArgs[0]) == NumForm - && sizeof(NumVals)/sizeof(NumVals[0]) == NumForm, - "need to update code for modified forms"); + static_assert(sizeof(NumArgs) / sizeof(NumArgs[0]) == NumForm && + sizeof(NumVals) / sizeof(NumVals[0]) == NumForm, + "need to update code for modified forms"); static_assert(AtomicExpr::AO__c11_atomic_init == 0 && AtomicExpr::AO__c11_atomic_fetch_min + 1 == AtomicExpr::AO__atomic_load, @@ -6104,7 +6377,7 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, bool IsHIP = Op >= AtomicExpr::AO__hip_atomic_load && Op <= AtomicExpr::AO__hip_atomic_fetch_max; bool IsC11 = (Op >= AtomicExpr::AO__c11_atomic_init && - Op <= AtomicExpr::AO__c11_atomic_fetch_min) || + Op <= AtomicExpr::AO__c11_atomic_fetch_min) || IsOpenCL; bool IsN = Op == AtomicExpr::AO__atomic_load_n || Op == AtomicExpr::AO__atomic_store_n || @@ -6240,7 +6513,7 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, // For a __c11 builtin, this should be a pointer to an _Atomic type. QualType AtomTy = pointerType->getPointeeType(); // 'A' - QualType ValType = AtomTy; // 'C' + QualType ValType = AtomTy; // 'C' if (IsC11) { if (!AtomTy->isAtomicType()) { Diag(ExprRange.getBegin(), diag::err_atomic_op_needs_atomic) @@ -6338,8 +6611,7 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, ValType.removeLocalVolatile(); ValType.removeLocalConst(); QualType ResultType = ValType; - if (Form == Copy || Form == LoadCopy || Form == GNUXchg || - Form == Init) + if (Form == Copy || Form == LoadCopy || Form == GNUXchg || Form == Init) ResultType = Context.VoidTy; else if (Form == C11CmpXchg || Form == GNUCmpXchg) ResultType = Context.BoolTy; @@ -6463,7 +6735,7 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, } // Permute the arguments into a 'consistent' order. - SmallVector SubExprs; + SmallVector SubExprs; SubExprs.push_back(Ptr); switch (Form) { case Init: @@ -6559,7 +6831,7 @@ static bool checkBuiltinArgument(Sema &S, CallExpr *E, unsigned ArgIndex) { ParmVarDecl *Param = Fn->getParamDecl(ArgIndex); InitializedEntity Entity = - InitializedEntity::InitializeParameter(S.Context, Param); + InitializedEntity::InitializeParameter(S.Context, Param); ExprResult Arg = E->getArg(ArgIndex); Arg = S.PerformCopyInitialization(Entity, SourceLocation(), Arg); @@ -6577,8 +6849,7 @@ static bool checkBuiltinArgument(Sema &S, CallExpr *E, unsigned ArgIndex) { /// /// This function goes through and does final semantic checking for these /// builtins, as well as generating any warnings. -ExprResult -Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { +ExprResult Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { CallExpr *TheCall = static_cast(TheCallResult.get()); Expr *Callee = TheCall->getCallee(); DeclRefExpr *DRE = cast(Callee->IgnoreParenCasts()); @@ -6648,41 +6919,52 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { // We need to figure out which concrete builtin this maps onto. For example, // __sync_fetch_and_add with a 2 byte object turns into // __sync_fetch_and_add_2. -#define BUILTIN_ROW(x) \ - { Builtin::BI##x##_1, Builtin::BI##x##_2, Builtin::BI##x##_4, \ - Builtin::BI##x##_8, Builtin::BI##x##_16 } +#define BUILTIN_ROW(x) \ + { \ + Builtin::BI##x##_1, Builtin::BI##x##_2, Builtin::BI##x##_4, \ + Builtin::BI##x##_8, Builtin::BI##x##_16 \ + } static const unsigned BuiltinIndices[][5] = { - BUILTIN_ROW(__sync_fetch_and_add), - BUILTIN_ROW(__sync_fetch_and_sub), - BUILTIN_ROW(__sync_fetch_and_or), - BUILTIN_ROW(__sync_fetch_and_and), - BUILTIN_ROW(__sync_fetch_and_xor), - BUILTIN_ROW(__sync_fetch_and_nand), - - BUILTIN_ROW(__sync_add_and_fetch), - BUILTIN_ROW(__sync_sub_and_fetch), - BUILTIN_ROW(__sync_and_and_fetch), - BUILTIN_ROW(__sync_or_and_fetch), - BUILTIN_ROW(__sync_xor_and_fetch), - BUILTIN_ROW(__sync_nand_and_fetch), - - BUILTIN_ROW(__sync_val_compare_and_swap), - BUILTIN_ROW(__sync_bool_compare_and_swap), - BUILTIN_ROW(__sync_lock_test_and_set), - BUILTIN_ROW(__sync_lock_release), - BUILTIN_ROW(__sync_swap) - }; + BUILTIN_ROW(__sync_fetch_and_add), + BUILTIN_ROW(__sync_fetch_and_sub), + BUILTIN_ROW(__sync_fetch_and_or), + BUILTIN_ROW(__sync_fetch_and_and), + BUILTIN_ROW(__sync_fetch_and_xor), + BUILTIN_ROW(__sync_fetch_and_nand), + + BUILTIN_ROW(__sync_add_and_fetch), + BUILTIN_ROW(__sync_sub_and_fetch), + BUILTIN_ROW(__sync_and_and_fetch), + BUILTIN_ROW(__sync_or_and_fetch), + BUILTIN_ROW(__sync_xor_and_fetch), + BUILTIN_ROW(__sync_nand_and_fetch), + + BUILTIN_ROW(__sync_val_compare_and_swap), + BUILTIN_ROW(__sync_bool_compare_and_swap), + BUILTIN_ROW(__sync_lock_test_and_set), + BUILTIN_ROW(__sync_lock_release), + BUILTIN_ROW(__sync_swap)}; #undef BUILTIN_ROW // Determine the index of the size. unsigned SizeIndex; switch (Context.getTypeSizeInChars(ValType).getQuantity()) { - case 1: SizeIndex = 0; break; - case 2: SizeIndex = 1; break; - case 4: SizeIndex = 2; break; - case 8: SizeIndex = 3; break; - case 16: SizeIndex = 4; break; + case 1: + SizeIndex = 0; + break; + case 2: + SizeIndex = 1; + break; + case 4: + SizeIndex = 2; + break; + case 8: + SizeIndex = 3; + break; + case 16: + SizeIndex = 4; + break; default: Diag(DRE->getBeginLoc(), diag::err_atomic_builtin_pointer_size) << FirstArg->getType() << FirstArg->getSourceRange(); @@ -6697,7 +6979,8 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { unsigned BuiltinIndex, NumFixed = 1; bool WarnAboutSemanticsChange = false; switch (BuiltinID) { - default: llvm_unreachable("Unknown overloaded atomic builtin!"); + default: + llvm_unreachable("Unknown overloaded atomic builtin!"); case Builtin::BI__sync_fetch_and_add: case Builtin::BI__sync_fetch_and_add_1: case Builtin::BI__sync_fetch_and_add_2: @@ -6861,7 +7144,7 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { // Now that we know how many fixed arguments we expect, first check that we // have at least that many. - if (TheCall->getNumArgs() < 1+NumFixed) { + if (TheCall->getNumArgs() < 1 + NumFixed) { Diag(TheCall->getEndLoc(), diag::err_typecheck_call_too_few_args_at_least) << 0 << 1 + NumFixed << TheCall->getNumArgs() << Callee->getSourceRange(); @@ -6898,13 +7181,13 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { // deduce the types of the rest of the arguments accordingly. Walk // the remaining arguments, converting them to the deduced value type. for (unsigned i = 0; i != NumFixed; ++i) { - ExprResult Arg = TheCall->getArg(i+1); + ExprResult Arg = TheCall->getArg(i + 1); // GCC does an implicit conversion to the pointer or integer ValType. This // can fail in some cases (1i -> int**), check for this error case now. // Initialize the argument. - InitializedEntity Entity = InitializedEntity::InitializeParameter(Context, - ValType, /*consume*/ false); + InitializedEntity Entity = InitializedEntity::InitializeParameter( + Context, ValType, /*consume*/ false); Arg = PerformCopyInitialization(Entity, SourceLocation(), Arg); if (Arg.isInvalid()) return ExprError(); @@ -6915,7 +7198,7 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { // pass in 42. The 42 gets converted to char. This is even more strange // for things like 45.123 -> char, etc. // FIXME: Do this check. - TheCall->setArg(i+1, Arg.get()); + TheCall->setArg(i + 1, Arg.get()); } // Create a new DeclRefExpr to refer to the new decl. @@ -6927,8 +7210,8 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { // Set the callee in the CallExpr. // FIXME: This loses syntactic information. QualType CalleePtrTy = Context.getPointerType(NewBuiltinDecl->getType()); - ExprResult PromotedCall = ImpCastExprToType(NewDRE, CalleePtrTy, - CK_BuiltinFnToFnPtr); + ExprResult PromotedCall = + ImpCastExprToType(NewDRE, CalleePtrTy, CK_BuiltinFnToFnPtr); TheCall->setCallee(PromotedCall.get()); // Change the result type of the call to match the original value type. This @@ -7100,8 +7383,7 @@ static bool checkVAStartABI(Sema &S, unsigned BuiltinID, Expr *Fn) { // On x64 Windows, don't allow this in System V ABI functions. // (Yes, that means there's no corresponding way to support variadic // System V ABI functions on Windows.) - if ((IsWindows && CC == CC_X86_64SysV) || - (!IsWindows && CC == CC_Win64)) + if ((IsWindows && CC == CC_X86_64SysV) || (!IsWindows && CC == CC_Win64)) return S.Diag(Fn->getBeginLoc(), diag::err_va_start_used_in_wrong_abi_function) << !IsWindows; @@ -7114,8 +7396,9 @@ static bool checkVAStartABI(Sema &S, unsigned BuiltinID, Expr *Fn) { return false; } -static bool checkVAStartIsInVariadicFunction(Sema &S, Expr *Fn, - ParmVarDecl **LastParam = nullptr) { +static bool +checkVAStartIsInVariadicFunction(Sema &S, Expr *Fn, + ParmVarDecl **LastParam = nullptr) { // Determine whether the current function, block, or obj-c method is variadic // and get its parameter list. bool IsVariadic = false; @@ -7211,8 +7494,10 @@ bool Sema::SemaBuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall) { Context.typesAreCompatible(ED->getPromotionType(), Type)); }()) { unsigned Reason = 0; - if (Type->isReferenceType()) Reason = 1; - else if (IsCRegister) Reason = 2; + if (Type->isReferenceType()) + Reason = 1; + else if (IsCRegister) + Reason = 2; Diag(Arg->getBeginLoc(), diag::warn_va_start_type_is_undefined) << Reason; Diag(ParamLoc, diag::note_parameter_type) << Type; } @@ -7343,7 +7628,7 @@ bool Sema::SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs) { TheCall->setArg(i, Res.get()); } - Expr *OrigArg = TheCall->getArg(NumArgs-1); + Expr *OrigArg = TheCall->getArg(NumArgs - 1); if (OrigArg->isTypeDependent()) return false; @@ -7403,8 +7688,8 @@ bool Sema::SemaBuiltinComplex(CallExpr *TheCall) { if (!Context.hasSameType(Real->getType(), Imag->getType())) { return Diag(Real->getBeginLoc(), diag::err_typecheck_call_different_arg_types) - << Real->getType() << Imag->getType() - << Real->getSourceRange() << Imag->getSourceRange(); + << Real->getType() << Imag->getType() << Real->getSourceRange() + << Imag->getSourceRange(); } // We don't allow _Complex _Float16 nor _Complex __fp16 as type specifiers; @@ -7546,7 +7831,7 @@ ExprResult Sema::SemaBuiltinShuffleVector(CallExpr *TheCall) { << TheCall->getArg(i)->getSourceRange()); } - SmallVector exprs; + SmallVector exprs; for (unsigned i = 0, e = TheCall->getNumArgs(); i != e; i++) { exprs.push_back(TheCall->getArg(i)); @@ -7568,20 +7853,18 @@ ExprResult Sema::SemaConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, QualType SrcTy = E->getType(); if (!SrcTy->isVectorType() && !SrcTy->isDependentType()) - return ExprError(Diag(BuiltinLoc, - diag::err_convertvector_non_vector) + return ExprError(Diag(BuiltinLoc, diag::err_convertvector_non_vector) << E->getSourceRange()); if (!DstTy->isVectorType() && !DstTy->isDependentType()) - return ExprError(Diag(BuiltinLoc, - diag::err_convertvector_non_vector_type)); + return ExprError(Diag(BuiltinLoc, diag::err_convertvector_non_vector_type)); if (!SrcTy->isDependentType() && !DstTy->isDependentType()) { unsigned SrcElts = SrcTy->castAs()->getNumElements(); unsigned DstElts = DstTy->castAs()->getNumElements(); if (SrcElts != DstElts) - return ExprError(Diag(BuiltinLoc, - diag::err_convertvector_incompatible_vector) - << E->getSourceRange()); + return ExprError( + Diag(BuiltinLoc, diag::err_convertvector_incompatible_vector) + << E->getSourceRange()); } return new (Context) @@ -7636,7 +7919,8 @@ bool Sema::SemaBuiltinArithmeticFence(CallExpr *TheCall) { // has side effects. bool Sema::SemaBuiltinAssume(CallExpr *TheCall) { Expr *Arg = TheCall->getArg(0); - if (Arg->isInstantiationDependent()) return false; + if (Arg->isInstantiationDependent()) + return false; if (Arg->HasSideEffects(Context)) Diag(Arg->getBeginLoc(), diag::warn_assume_side_effects) @@ -7690,8 +7974,7 @@ bool Sema::SemaBuiltinAssumeAligned(CallExpr *TheCall) { Expr *FirstArg = TheCall->getArg(0); { - ExprResult FirstArgResult = - DefaultFunctionArrayLvalueConversion(FirstArg); + ExprResult FirstArgResult = DefaultFunctionArrayLvalueConversion(FirstArg); if (FirstArgResult.isInvalid()) return true; TheCall->setArg(0, FirstArgResult.get()); @@ -7810,10 +8093,12 @@ bool Sema::SemaBuiltinOSLogFormat(CallExpr *TheCall) { bool Sema::SemaBuiltinConstantArg(CallExpr *TheCall, int ArgNum, llvm::APSInt &Result) { Expr *Arg = TheCall->getArg(ArgNum); - DeclRefExpr *DRE =cast(TheCall->getCallee()->IgnoreParenCasts()); + DeclRefExpr *DRE = + cast(TheCall->getCallee()->IgnoreParenCasts()); FunctionDecl *FDecl = cast(DRE->getDecl()); - if (Arg->isTypeDependent() || Arg->isValueDependent()) return false; + if (Arg->isTypeDependent() || Arg->isValueDependent()) + return false; Optional R; if (!(R = Arg->getIntegerConstantExpr(Context))) @@ -7825,8 +8110,8 @@ bool Sema::SemaBuiltinConstantArg(CallExpr *TheCall, int ArgNum, /// SemaBuiltinConstantArgRange - Handle a check if argument ArgNum of CallExpr /// TheCall is a constant expression in the range [Low, High]. -bool Sema::SemaBuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, - int Low, int High, bool RangeIsError) { +bool Sema::SemaBuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low, + int High, bool RangeIsError) { if (isConstantEvaluated()) return false; llvm::APSInt Result; @@ -7856,8 +8141,8 @@ bool Sema::SemaBuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, return false; } -/// SemaBuiltinConstantArgMultiple - Handle a check if argument ArgNum of CallExpr -/// TheCall is a constant expression is a multiple of Num.. +/// SemaBuiltinConstantArgMultiple - Handle a check if argument ArgNum of +/// CallExpr TheCall is a constant expression is a multiple of Num.. bool Sema::SemaBuiltinConstantArgMultiple(CallExpr *TheCall, int ArgNum, unsigned Num) { llvm::APSInt Result; @@ -7984,7 +8269,8 @@ bool Sema::SemaBuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall, } /// SemaBuiltinARMMemoryTaggingCall - Handle calls of memory tagging extensions -bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall) { +bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, + CallExpr *TheCall) { if (BuiltinID == AArch64::BI__builtin_arm_irg) { if (checkArgCount(*this, TheCall, 2)) return true; @@ -7997,7 +8283,7 @@ bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall QualType FirstArgType = FirstArg.get()->getType(); if (!FirstArgType->isAnyPointerType()) return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_must_be_pointer) - << "first" << FirstArgType << Arg0->getSourceRange(); + << "first" << FirstArgType << Arg0->getSourceRange(); TheCall->setArg(0, FirstArg.get()); ExprResult SecArg = DefaultLvalueConversion(Arg1); @@ -8006,7 +8292,7 @@ bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall QualType SecArgType = SecArg.get()->getType(); if (!SecArgType->isIntegerType()) return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_must_be_integer) - << "second" << SecArgType << Arg1->getSourceRange(); + << "second" << SecArgType << Arg1->getSourceRange(); // Derive the return type from the pointer argument. TheCall->setType(FirstArgType); @@ -8024,7 +8310,7 @@ bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall QualType FirstArgType = FirstArg.get()->getType(); if (!FirstArgType->isAnyPointerType()) return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_must_be_pointer) - << "first" << FirstArgType << Arg0->getSourceRange(); + << "first" << FirstArgType << Arg0->getSourceRange(); TheCall->setArg(0, FirstArg.get()); // Derive the return type from the pointer argument. @@ -8046,12 +8332,12 @@ bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall QualType FirstArgType = FirstArg.get()->getType(); if (!FirstArgType->isAnyPointerType()) return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_must_be_pointer) - << "first" << FirstArgType << Arg0->getSourceRange(); + << "first" << FirstArgType << Arg0->getSourceRange(); QualType SecArgType = Arg1->getType(); if (!SecArgType->isIntegerType()) return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_must_be_integer) - << "second" << SecArgType << Arg1->getSourceRange(); + << "second" << SecArgType << Arg1->getSourceRange(); TheCall->setType(Context.IntTy); return false; } @@ -8068,7 +8354,7 @@ bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall QualType FirstArgType = FirstArg.get()->getType(); if (!FirstArgType->isAnyPointerType()) return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_must_be_pointer) - << "first" << FirstArgType << Arg0->getSourceRange(); + << "first" << FirstArgType << Arg0->getSourceRange(); TheCall->setArg(0, FirstArg.get()); // Derive the return type from the pointer argument. @@ -8090,18 +8376,19 @@ bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall QualType ArgTypeA = ArgExprA.get()->getType(); QualType ArgTypeB = ArgExprB.get()->getType(); - auto isNull = [&] (Expr *E) -> bool { - return E->isNullPointerConstant( - Context, Expr::NPC_ValueDependentIsNotNull); }; + auto isNull = [&](Expr *E) -> bool { + return E->isNullPointerConstant(Context, + Expr::NPC_ValueDependentIsNotNull); + }; // argument should be either a pointer or null if (!ArgTypeA->isAnyPointerType() && !isNull(ArgA)) return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_null_or_pointer) - << "first" << ArgTypeA << ArgA->getSourceRange(); + << "first" << ArgTypeA << ArgA->getSourceRange(); if (!ArgTypeB->isAnyPointerType() && !isNull(ArgB)) return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_null_or_pointer) - << "second" << ArgTypeB << ArgB->getSourceRange(); + << "second" << ArgTypeB << ArgB->getSourceRange(); // Ensure Pointee types are compatible if (ArgTypeA->isAnyPointerType() && !isNull(ArgA) && @@ -8109,18 +8396,19 @@ bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall QualType pointeeA = ArgTypeA->getPointeeType(); QualType pointeeB = ArgTypeB->getPointeeType(); if (!Context.typesAreCompatible( - Context.getCanonicalType(pointeeA).getUnqualifiedType(), - Context.getCanonicalType(pointeeB).getUnqualifiedType())) { - return Diag(TheCall->getBeginLoc(), diag::err_typecheck_sub_ptr_compatible) - << ArgTypeA << ArgTypeB << ArgA->getSourceRange() - << ArgB->getSourceRange(); + Context.getCanonicalType(pointeeA).getUnqualifiedType(), + Context.getCanonicalType(pointeeB).getUnqualifiedType())) { + return Diag(TheCall->getBeginLoc(), + diag::err_typecheck_sub_ptr_compatible) + << ArgTypeA << ArgTypeB << ArgA->getSourceRange() + << ArgB->getSourceRange(); } } // at least one argument should be pointer type if (!ArgTypeA->isAnyPointerType() && !ArgTypeB->isAnyPointerType()) return Diag(TheCall->getBeginLoc(), diag::err_memtag_any2arg_pointer) - << ArgTypeA << ArgTypeB << ArgA->getSourceRange(); + << ArgTypeA << ArgTypeB << ArgA->getSourceRange(); if (isNull(ArgA)) // adopt type of the other pointer ArgExprA = ImpCastExprToType(ArgExprA.get(), ArgTypeB, CK_NullToPointer); @@ -8207,7 +8495,7 @@ bool Sema::SemaBuiltinARMSpecialReg(unsigned BuiltinID, CallExpr *TheCall, else Ranges.append({15, 7, 15}); - for (unsigned i=0; i= 0 && IntField <= Ranges[i]); @@ -8320,7 +8608,7 @@ bool Sema::SemaBuiltinPPCMMACall(CallExpr *TheCall, unsigned BuiltinID, // number of arguments in TheCall and if it is not the case, to display a // better error message. while (*TypeStr != '\0') { - (void) DecodePPCMMATypeFromStr(Context, TypeStr, Mask); + (void)DecodePPCMMATypeFromStr(Context, TypeStr, Mask); ArgNum++; } if (checkArgCount(*this, TheCall, ArgNum)) @@ -8371,9 +8659,7 @@ class UncoveredArgHandler { public: UncoveredArgHandler() = default; - bool hasUncoveredArg() const { - return (FirstUncoveredArg >= 0); - } + bool hasUncoveredArg() const { return (FirstUncoveredArg >= 0); } unsigned getUncoveredArg() const { assert(hasUncoveredArg() && "no uncovered argument"); @@ -8417,8 +8703,7 @@ enum StringLiteralCheckType { } // namespace static void sumOffsets(llvm::APSInt &Offset, llvm::APSInt Addend, - BinaryOperatorKind BinOpKind, - bool AddendIsRight) { + BinaryOperatorKind BinOpKind, bool AddendIsRight) { unsigned BitWidth = Offset.getBitWidth(); unsigned AddendBitWidth = Addend.getBitWidth(); // There might be negative interim results. @@ -8466,13 +8751,11 @@ class FormatStringLiteral { const StringLiteral *FExpr; int64_t Offset; - public: +public: FormatStringLiteral(const StringLiteral *fexpr, int64_t Offset = 0) : FExpr(fexpr), Offset(Offset) {} - StringRef getString() const { - return FExpr->getString().drop_front(Offset); - } + StringRef getString() const { return FExpr->getString().drop_front(Offset); } unsigned getByteLength() const { return FExpr->getByteLength() - getCharByteWidth() * Offset; @@ -8492,10 +8775,11 @@ class FormatStringLiteral { bool isUTF32() const { return FExpr->isUTF32(); } bool isPascal() const { return FExpr->isPascal(); } - SourceLocation getLocationOfByte( - unsigned ByteNo, const SourceManager &SM, const LangOptions &Features, - const TargetInfo &Target, unsigned *StartToken = nullptr, - unsigned *StartTokenByteOffset = nullptr) const { + SourceLocation + getLocationOfByte(unsigned ByteNo, const SourceManager &SM, + const LangOptions &Features, const TargetInfo &Target, + unsigned *StartToken = nullptr, + unsigned *StartTokenByteOffset = nullptr) const { return FExpr->getLocationOfByte(ByteNo + Offset, SM, Features, Target, StartToken, StartTokenByteOffset); } @@ -8554,8 +8838,7 @@ checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef Args, case Stmt::ConditionalOperatorClass: { // The expression is a literal if both sub-expressions were, and it was // completely checked only if both sub-expressions were checked. - const AbstractConditionalOperator *C = - cast(E); + const AbstractConditionalOperator *C = cast(E); // Determine whether it is necessary to check both sub-expressions, for // example, because the condition expression is a constant that can be @@ -8731,7 +9014,8 @@ checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef Args, case Stmt::CallExprClass: case Stmt::CXXMemberCallExprClass: { const CallExpr *CE = cast(E); - if (const NamedDecl *ND = dyn_cast_or_null(CE->getCalleeDecl())) { + if (const NamedDecl *ND = + dyn_cast_or_null(CE->getCalleeDecl())) { bool IsFirst = true; StringLiteralCheckType CommonResult; for (const auto *FA : ND->specific_attrs()) { @@ -8957,7 +9241,7 @@ bool Sema::CheckFormatArguments(ArrayRef Args, if (UncoveredArg.hasUncoveredArg()) { unsigned ArgIdx = UncoveredArg.getUncoveredArg() + firstDataArg; assert(ArgIdx < Args.size() && "ArgIdx outside bounds"); - UncoveredArg.Diagnose(*this, /*IsFunctionCall*/true, Args[ArgIdx]); + UncoveredArg.Diagnose(*this, /*IsFunctionCall*/ true, Args[ArgIdx]); } if (CT != SLCT_NotALiteral) @@ -8981,7 +9265,7 @@ bool Sema::CheckFormatArguments(ArrayRef Args, // warn only with -Wformat-nonliteral. if (Args.size() == firstDataArg) { Diag(FormatLoc, diag::warn_format_nonliteral_noargs) - << OrigFormatExpr->getSourceRange(); + << OrigFormatExpr->getSourceRange(); switch (Type) { default: break; @@ -8989,16 +9273,16 @@ bool Sema::CheckFormatArguments(ArrayRef Args, case FST_FreeBSDKPrintf: case FST_Printf: Diag(FormatLoc, diag::note_format_security_fixit) - << FixItHint::CreateInsertion(FormatLoc, "\"%s\", "); + << FixItHint::CreateInsertion(FormatLoc, "\"%s\", "); break; case FST_NSString: Diag(FormatLoc, diag::note_format_security_fixit) - << FixItHint::CreateInsertion(FormatLoc, "@\"%@\", "); + << FixItHint::CreateInsertion(FormatLoc, "@\"%@\", "); break; } } else { Diag(FormatLoc, diag::warn_format_nonliteral) - << OrigFormatExpr->getSourceRange(); + << OrigFormatExpr->getSourceRange(); } return false; } @@ -9050,23 +9334,21 @@ class CheckFormatHandler : public analyze_format_string::FormatStringHandler { unsigned specifierLen) override; void HandleInvalidLengthModifier( - const analyze_format_string::FormatSpecifier &FS, - const analyze_format_string::ConversionSpecifier &CS, - const char *startSpecifier, unsigned specifierLen, - unsigned DiagID); + const analyze_format_string::FormatSpecifier &FS, + const analyze_format_string::ConversionSpecifier &CS, + const char *startSpecifier, unsigned specifierLen, unsigned DiagID); void HandleNonStandardLengthModifier( - const analyze_format_string::FormatSpecifier &FS, - const char *startSpecifier, unsigned specifierLen); + const analyze_format_string::FormatSpecifier &FS, + const char *startSpecifier, unsigned specifierLen); void HandleNonStandardConversionSpecifier( - const analyze_format_string::ConversionSpecifier &CS, - const char *startSpecifier, unsigned specifierLen); + const analyze_format_string::ConversionSpecifier &CS, + const char *startSpecifier, unsigned specifierLen); void HandlePosition(const char *startPos, unsigned posLen) override; - void HandleInvalidPosition(const char *startSpecifier, - unsigned specifierLen, + void HandleInvalidPosition(const char *startSpecifier, unsigned specifierLen, analyze_format_string::PositionContext p) override; void HandleZeroPosition(const char *startPos, unsigned posLen) override; @@ -9114,10 +9396,11 @@ SourceRange CheckFormatHandler::getFormatStringRange() { return OrigFormatExpr->getSourceRange(); } -CharSourceRange CheckFormatHandler:: -getSpecifierRange(const char *startSpecifier, unsigned specifierLen) { +CharSourceRange +CheckFormatHandler::getSpecifierRange(const char *startSpecifier, + unsigned specifierLen) { SourceLocation Start = getLocationOfByte(startSpecifier); - SourceLocation End = getLocationOfByte(startSpecifier + specifierLen - 1); + SourceLocation End = getLocationOfByte(startSpecifier + specifierLen - 1); // Advance the end SourceLocation by one due to half-open ranges. End = End.getLocWithOffset(1); @@ -9131,10 +9414,10 @@ SourceLocation CheckFormatHandler::getLocationOfByte(const char *x) { } void CheckFormatHandler::HandleIncompleteSpecifier(const char *startSpecifier, - unsigned specifierLen){ + unsigned specifierLen) { EmitFormatDiagnostic(S.PDiag(diag::warn_printf_incomplete_specifier), getLocationOfByte(startSpecifier), - /*IsStringLocation*/true, + /*IsStringLocation*/ true, getSpecifierRange(startSpecifier, specifierLen)); } @@ -9152,12 +9435,12 @@ void CheckFormatHandler::HandleInvalidLengthModifier( if (FixedLM) { EmitFormatDiagnostic(S.PDiag(DiagID) << LM.toString() << CS.toString(), getLocationOfByte(LM.getStart()), - /*IsStringLocation*/true, + /*IsStringLocation*/ true, getSpecifierRange(startSpecifier, specifierLen)); S.Diag(getLocationOfByte(LM.getStart()), diag::note_format_fix_specifier) - << FixedLM->toString() - << FixItHint::CreateReplacement(LMRange, FixedLM->toString()); + << FixedLM->toString() + << FixItHint::CreateReplacement(LMRange, FixedLM->toString()); } else { FixItHint Hint; @@ -9166,9 +9449,8 @@ void CheckFormatHandler::HandleInvalidLengthModifier( EmitFormatDiagnostic(S.PDiag(DiagID) << LM.toString() << CS.toString(), getLocationOfByte(LM.getStart()), - /*IsStringLocation*/true, - getSpecifierRange(startSpecifier, specifierLen), - Hint); + /*IsStringLocation*/ true, + getSpecifierRange(startSpecifier, specifierLen), Hint); } } @@ -9184,20 +9466,20 @@ void CheckFormatHandler::HandleNonStandardLengthModifier( Optional FixedLM = FS.getCorrectedLengthModifier(); if (FixedLM) { EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard) - << LM.toString() << 0, + << LM.toString() << 0, getLocationOfByte(LM.getStart()), - /*IsStringLocation*/true, + /*IsStringLocation*/ true, getSpecifierRange(startSpecifier, specifierLen)); S.Diag(getLocationOfByte(LM.getStart()), diag::note_format_fix_specifier) - << FixedLM->toString() - << FixItHint::CreateReplacement(LMRange, FixedLM->toString()); + << FixedLM->toString() + << FixItHint::CreateReplacement(LMRange, FixedLM->toString()); } else { EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard) - << LM.toString() << 0, + << LM.toString() << 0, getLocationOfByte(LM.getStart()), - /*IsStringLocation*/true, + /*IsStringLocation*/ true, getSpecifierRange(startSpecifier, specifierLen)); } } @@ -9211,56 +9493,55 @@ void CheckFormatHandler::HandleNonStandardConversionSpecifier( Optional FixedCS = CS.getStandardSpecifier(); if (FixedCS) { EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard) - << CS.toString() << /*conversion specifier*/1, + << CS.toString() << /*conversion specifier*/ 1, getLocationOfByte(CS.getStart()), - /*IsStringLocation*/true, + /*IsStringLocation*/ true, getSpecifierRange(startSpecifier, specifierLen)); CharSourceRange CSRange = getSpecifierRange(CS.getStart(), CS.getLength()); S.Diag(getLocationOfByte(CS.getStart()), diag::note_format_fix_specifier) - << FixedCS->toString() - << FixItHint::CreateReplacement(CSRange, FixedCS->toString()); + << FixedCS->toString() + << FixItHint::CreateReplacement(CSRange, FixedCS->toString()); } else { EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard) - << CS.toString() << /*conversion specifier*/1, + << CS.toString() << /*conversion specifier*/ 1, getLocationOfByte(CS.getStart()), - /*IsStringLocation*/true, + /*IsStringLocation*/ true, getSpecifierRange(startSpecifier, specifierLen)); } } -void CheckFormatHandler::HandlePosition(const char *startPos, - unsigned posLen) { +void CheckFormatHandler::HandlePosition(const char *startPos, unsigned posLen) { EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg), - getLocationOfByte(startPos), - /*IsStringLocation*/true, - getSpecifierRange(startPos, posLen)); + getLocationOfByte(startPos), + /*IsStringLocation*/ true, + getSpecifierRange(startPos, posLen)); } -void -CheckFormatHandler::HandleInvalidPosition(const char *startPos, unsigned posLen, - analyze_format_string::PositionContext p) { +void CheckFormatHandler::HandleInvalidPosition( + const char *startPos, unsigned posLen, + analyze_format_string::PositionContext p) { EmitFormatDiagnostic(S.PDiag(diag::warn_format_invalid_positional_specifier) - << (unsigned) p, - getLocationOfByte(startPos), /*IsStringLocation*/true, + << (unsigned)p, + getLocationOfByte(startPos), /*IsStringLocation*/ true, getSpecifierRange(startPos, posLen)); } void CheckFormatHandler::HandleZeroPosition(const char *startPos, unsigned posLen) { EmitFormatDiagnostic(S.PDiag(diag::warn_format_zero_positional_specifier), - getLocationOfByte(startPos), - /*IsStringLocation*/true, - getSpecifierRange(startPos, posLen)); + getLocationOfByte(startPos), + /*IsStringLocation*/ true, + getSpecifierRange(startPos, posLen)); } void CheckFormatHandler::HandleNullChar(const char *nullCharacter) { if (!isa(OrigFormatExpr)) { // The presence of a null character is likely an error. EmitFormatDiagnostic( - S.PDiag(diag::warn_printf_format_string_contains_null_char), - getLocationOfByte(nullCharacter), /*IsStringLocation*/true, - getFormatStringRange()); + S.PDiag(diag::warn_printf_format_string_contains_null_char), + getLocationOfByte(nullCharacter), /*IsStringLocation*/ true, + getFormatStringRange()); } } @@ -9288,8 +9569,7 @@ void CheckFormatHandler::DoneProcessing() { void UncoveredArgHandler::Diagnose(Sema &S, bool IsFunctionCall, const Expr *ArgExpr) { - assert(hasUncoveredArg() && DiagnosticExprs.size() > 0 && - "Invalid state"); + assert(hasUncoveredArg() && DiagnosticExprs.size() > 0 && "Invalid state"); if (!ArgExpr) return; @@ -9304,25 +9584,19 @@ void UncoveredArgHandler::Diagnose(Sema &S, bool IsFunctionCall, PDiag << E->getSourceRange(); CheckFormatHandler::EmitFormatDiagnostic( - S, IsFunctionCall, DiagnosticExprs[0], - PDiag, Loc, /*IsStringLocation*/false, - DiagnosticExprs[0]->getSourceRange()); -} - -bool -CheckFormatHandler::HandleInvalidConversionSpecifier(unsigned argIndex, - SourceLocation Loc, - const char *startSpec, - unsigned specifierLen, - const char *csStart, - unsigned csLen) { + S, IsFunctionCall, DiagnosticExprs[0], PDiag, Loc, + /*IsStringLocation*/ false, DiagnosticExprs[0]->getSourceRange()); +} + +bool CheckFormatHandler::HandleInvalidConversionSpecifier( + unsigned argIndex, SourceLocation Loc, const char *startSpec, + unsigned specifierLen, const char *csStart, unsigned csLen) { bool keepGoing = true; if (argIndex < NumDataArgs) { // Consider the argument coverered, even though the specifier doesn't // make sense. CoveredArgs.set(argIndex); - } - else { + } else { // If argIndex exceeds the number of data arguments we // don't issue a warning because that is just a cascade of warnings (and // they may have intended '%%' anyway). We don't want to continue processing @@ -9340,8 +9614,7 @@ CheckFormatHandler::HandleInvalidConversionSpecifier(unsigned argIndex, if (!llvm::sys::locale::isPrint(*csStart)) { llvm::UTF32 CodePoint; const llvm::UTF8 **B = reinterpret_cast(&csStart); - const llvm::UTF8 *E = - reinterpret_cast(csStart + csLen); + const llvm::UTF8 *E = reinterpret_cast(csStart + csLen); llvm::ConversionResult Result = llvm::convertUTF8Sequence(B, E, &CodePoint, llvm::strictConversion); @@ -9368,29 +9641,27 @@ CheckFormatHandler::HandleInvalidConversionSpecifier(unsigned argIndex, return keepGoing; } -void -CheckFormatHandler::HandlePositionalNonpositionalArgs(SourceLocation Loc, - const char *startSpec, - unsigned specifierLen) { +void CheckFormatHandler::HandlePositionalNonpositionalArgs( + SourceLocation Loc, const char *startSpec, unsigned specifierLen) { EmitFormatDiagnostic( - S.PDiag(diag::warn_format_mix_positional_nonpositional_args), - Loc, /*isStringLoc*/true, getSpecifierRange(startSpec, specifierLen)); + S.PDiag(diag::warn_format_mix_positional_nonpositional_args), Loc, + /*isStringLoc*/ true, getSpecifierRange(startSpec, specifierLen)); } -bool -CheckFormatHandler::CheckNumArgs( - const analyze_format_string::FormatSpecifier &FS, - const analyze_format_string::ConversionSpecifier &CS, - const char *startSpecifier, unsigned specifierLen, unsigned argIndex) { +bool CheckFormatHandler::CheckNumArgs( + const analyze_format_string::FormatSpecifier &FS, + const analyze_format_string::ConversionSpecifier &CS, + const char *startSpecifier, unsigned specifierLen, unsigned argIndex) { if (argIndex >= NumDataArgs) { - PartialDiagnostic PDiag = FS.usesPositionalArg() - ? (S.PDiag(diag::warn_printf_positional_arg_exceeds_data_args) - << (argIndex+1) << NumDataArgs) - : S.PDiag(diag::warn_printf_insufficient_data_args); - EmitFormatDiagnostic( - PDiag, getLocationOfByte(CS.getStart()), /*IsStringLocation*/true, - getSpecifierRange(startSpecifier, specifierLen)); + PartialDiagnostic PDiag = + FS.usesPositionalArg() + ? (S.PDiag(diag::warn_printf_positional_arg_exceeds_data_args) + << (argIndex + 1) << NumDataArgs) + : S.PDiag(diag::warn_printf_insufficient_data_args); + EmitFormatDiagnostic(PDiag, getLocationOfByte(CS.getStart()), + /*IsStringLocation*/ true, + getSpecifierRange(startSpecifier, specifierLen)); // Since more arguments than conversion tokens are given, by extension // all arguments are covered, so mark this as so. @@ -9400,14 +9671,14 @@ CheckFormatHandler::CheckNumArgs( return true; } -template +template void CheckFormatHandler::EmitFormatDiagnostic(PartialDiagnostic PDiag, SourceLocation Loc, bool IsStringLocation, Range StringRange, ArrayRef FixIt) { - EmitFormatDiagnostic(S, inFunctionCall, Args[FormatIdx], PDiag, - Loc, IsStringLocation, StringRange, FixIt); + EmitFormatDiagnostic(S, inFunctionCall, Args[FormatIdx], PDiag, Loc, + IsStringLocation, StringRange, FixIt); } /// If the format string is not within the function call, emit a note @@ -9448,18 +9719,19 @@ void CheckFormatHandler::EmitFormatDiagnostic( D << FixIt; } else { S.Diag(IsStringLocation ? ArgumentExpr->getExprLoc() : Loc, PDiag) - << ArgumentExpr->getSourceRange(); + << ArgumentExpr->getSourceRange(); const Sema::SemaDiagnosticBuilder &Note = - S.Diag(IsStringLocation ? Loc : StringRange.getBegin(), - diag::note_format_string_defined); + S.Diag(IsStringLocation ? Loc : StringRange.getBegin(), + diag::note_format_string_defined); Note << StringRange; Note << FixIt; } } -//===--- CHECK: Printf format string checking ------------------------------===// +//===--- CHECK: Printf format string checking +//------------------------------===// namespace { @@ -9488,9 +9760,8 @@ class CheckPrintfHandler : public CheckFormatHandler { } bool HandleInvalidPrintfConversionSpecifier( - const analyze_printf::PrintfSpecifier &FS, - const char *startSpecifier, - unsigned specifierLen) override; + const analyze_printf::PrintfSpecifier &FS, const char *startSpecifier, + unsigned specifierLen) override; void handleInvalidMaskType(StringRef MaskType) override; @@ -9498,16 +9769,16 @@ class CheckPrintfHandler : public CheckFormatHandler { const char *startSpecifier, unsigned specifierLen, const TargetInfo &Target) override; bool checkFormatExpr(const analyze_printf::PrintfSpecifier &FS, - const char *StartSpecifier, - unsigned SpecifierLen, + const char *StartSpecifier, unsigned SpecifierLen, const Expr *E); - bool HandleAmount(const analyze_format_string::OptionalAmount &Amt, unsigned k, - const char *startSpecifier, unsigned specifierLen); + bool HandleAmount(const analyze_format_string::OptionalAmount &Amt, + unsigned k, const char *startSpecifier, + unsigned specifierLen); void HandleInvalidAmount(const analyze_printf::PrintfSpecifier &FS, const analyze_printf::OptionalAmount &Amt, - unsigned type, - const char *startSpecifier, unsigned specifierLen); + unsigned type, const char *startSpecifier, + unsigned specifierLen); void HandleFlag(const analyze_printf::PrintfSpecifier &FS, const analyze_printf::OptionalFlag &flag, const char *startSpecifier, unsigned specifierLen); @@ -9515,34 +9786,31 @@ class CheckPrintfHandler : public CheckFormatHandler { const analyze_printf::OptionalFlag &ignoredFlag, const analyze_printf::OptionalFlag &flag, const char *startSpecifier, unsigned specifierLen); - bool checkForCStrMembers(const analyze_printf::ArgType &AT, - const Expr *E); + bool checkForCStrMembers(const analyze_printf::ArgType &AT, const Expr *E); void HandleEmptyObjCModifierFlag(const char *startFlag, unsigned flagLen) override; void HandleInvalidObjCModifierFlag(const char *startFlag, - unsigned flagLen) override; + unsigned flagLen) override; - void HandleObjCFlagsWithNonObjCConversion(const char *flagsStart, - const char *flagsEnd, - const char *conversionPosition) - override; + void + HandleObjCFlagsWithNonObjCConversion(const char *flagsStart, + const char *flagsEnd, + const char *conversionPosition) override; }; } // namespace bool CheckPrintfHandler::HandleInvalidPrintfConversionSpecifier( - const analyze_printf::PrintfSpecifier &FS, - const char *startSpecifier, - unsigned specifierLen) { + const analyze_printf::PrintfSpecifier &FS, const char *startSpecifier, + unsigned specifierLen) { const analyze_printf::PrintfConversionSpecifier &CS = - FS.getConversionSpecifier(); + FS.getConversionSpecifier(); - return HandleInvalidConversionSpecifier(FS.getArgIndex(), - getLocationOfByte(CS.getStart()), - startSpecifier, specifierLen, - CS.getStart(), CS.getLength()); + return HandleInvalidConversionSpecifier( + FS.getArgIndex(), getLocationOfByte(CS.getStart()), startSpecifier, + specifierLen, CS.getStart(), CS.getLength()); } void CheckPrintfHandler::handleInvalidMaskType(StringRef MaskType) { @@ -9582,10 +9850,10 @@ bool CheckPrintfHandler::HandleAmount( if (!AT.matchesType(S.Context, T)) { EmitFormatDiagnostic(S.PDiag(diag::warn_printf_asterisk_wrong_type) - << k << AT.getRepresentativeTypeName(S.Context) - << T << Arg->getSourceRange(), + << k << AT.getRepresentativeTypeName(S.Context) + << T << Arg->getSourceRange(), getLocationOfByte(Amt.getStart()), - /*IsStringLocation*/true, + /*IsStringLocation*/ true, getSpecifierRange(startSpecifier, specifierLen)); // Don't do any more checking. We will just emit // spurious errors. @@ -9597,26 +9865,23 @@ bool CheckPrintfHandler::HandleAmount( } void CheckPrintfHandler::HandleInvalidAmount( - const analyze_printf::PrintfSpecifier &FS, - const analyze_printf::OptionalAmount &Amt, - unsigned type, - const char *startSpecifier, - unsigned specifierLen) { + const analyze_printf::PrintfSpecifier &FS, + const analyze_printf::OptionalAmount &Amt, unsigned type, + const char *startSpecifier, unsigned specifierLen) { const analyze_printf::PrintfConversionSpecifier &CS = - FS.getConversionSpecifier(); + FS.getConversionSpecifier(); FixItHint fixit = - Amt.getHowSpecified() == analyze_printf::OptionalAmount::Constant - ? FixItHint::CreateRemoval(getSpecifierRange(Amt.getStart(), - Amt.getConstantLength())) - : FixItHint(); + Amt.getHowSpecified() == analyze_printf::OptionalAmount::Constant + ? FixItHint::CreateRemoval( + getSpecifierRange(Amt.getStart(), Amt.getConstantLength())) + : FixItHint(); EmitFormatDiagnostic(S.PDiag(diag::warn_printf_nonsensical_optional_amount) - << type << CS.toString(), + << type << CS.toString(), getLocationOfByte(Amt.getStart()), - /*IsStringLocation*/true, - getSpecifierRange(startSpecifier, specifierLen), - fixit); + /*IsStringLocation*/ true, + getSpecifierRange(startSpecifier, specifierLen), fixit); } void CheckPrintfHandler::HandleFlag(const analyze_printf::PrintfSpecifier &FS, @@ -9625,39 +9890,37 @@ void CheckPrintfHandler::HandleFlag(const analyze_printf::PrintfSpecifier &FS, unsigned specifierLen) { // Warn about pointless flag with a fixit removal. const analyze_printf::PrintfConversionSpecifier &CS = - FS.getConversionSpecifier(); - EmitFormatDiagnostic(S.PDiag(diag::warn_printf_nonsensical_flag) - << flag.toString() << CS.toString(), - getLocationOfByte(flag.getPosition()), - /*IsStringLocation*/true, - getSpecifierRange(startSpecifier, specifierLen), - FixItHint::CreateRemoval( - getSpecifierRange(flag.getPosition(), 1))); + FS.getConversionSpecifier(); + EmitFormatDiagnostic( + S.PDiag(diag::warn_printf_nonsensical_flag) + << flag.toString() << CS.toString(), + getLocationOfByte(flag.getPosition()), + /*IsStringLocation*/ true, + getSpecifierRange(startSpecifier, specifierLen), + FixItHint::CreateRemoval(getSpecifierRange(flag.getPosition(), 1))); } void CheckPrintfHandler::HandleIgnoredFlag( - const analyze_printf::PrintfSpecifier &FS, - const analyze_printf::OptionalFlag &ignoredFlag, - const analyze_printf::OptionalFlag &flag, - const char *startSpecifier, - unsigned specifierLen) { + const analyze_printf::PrintfSpecifier &FS, + const analyze_printf::OptionalFlag &ignoredFlag, + const analyze_printf::OptionalFlag &flag, const char *startSpecifier, + unsigned specifierLen) { // Warn about ignored flag with a fixit removal. EmitFormatDiagnostic(S.PDiag(diag::warn_printf_ignored_flag) - << ignoredFlag.toString() << flag.toString(), + << ignoredFlag.toString() << flag.toString(), getLocationOfByte(ignoredFlag.getPosition()), - /*IsStringLocation*/true, + /*IsStringLocation*/ true, getSpecifierRange(startSpecifier, specifierLen), FixItHint::CreateRemoval( - getSpecifierRange(ignoredFlag.getPosition(), 1))); + getSpecifierRange(ignoredFlag.getPosition(), 1))); } void CheckPrintfHandler::HandleEmptyObjCModifierFlag(const char *startFlag, unsigned flagLen) { // Warn about an empty flag. - EmitFormatDiagnostic(S.PDiag(diag::warn_printf_empty_objc_flag), - getLocationOfByte(startFlag), - /*IsStringLocation*/true, - getSpecifierRange(startFlag, flagLen)); + EmitFormatDiagnostic( + S.PDiag(diag::warn_printf_empty_objc_flag), getLocationOfByte(startFlag), + /*IsStringLocation*/ true, getSpecifierRange(startFlag, flagLen)); } void CheckPrintfHandler::HandleInvalidObjCModifierFlag(const char *startFlag, @@ -9666,30 +9929,31 @@ void CheckPrintfHandler::HandleInvalidObjCModifierFlag(const char *startFlag, auto Range = getSpecifierRange(startFlag, flagLen); StringRef flag(startFlag, flagLen); EmitFormatDiagnostic(S.PDiag(diag::warn_printf_invalid_objc_flag) << flag, - getLocationOfByte(startFlag), - /*IsStringLocation*/true, - Range, FixItHint::CreateRemoval(Range)); + getLocationOfByte(startFlag), + /*IsStringLocation*/ true, Range, + FixItHint::CreateRemoval(Range)); } void CheckPrintfHandler::HandleObjCFlagsWithNonObjCConversion( - const char *flagsStart, const char *flagsEnd, const char *conversionPosition) { - // Warn about using '[...]' without a '@' conversion. - auto Range = getSpecifierRange(flagsStart, flagsEnd - flagsStart + 1); - auto diag = diag::warn_printf_ObjCflags_without_ObjCConversion; - EmitFormatDiagnostic(S.PDiag(diag) << StringRef(conversionPosition, 1), - getLocationOfByte(conversionPosition), - /*IsStringLocation*/true, - Range, FixItHint::CreateRemoval(Range)); + const char *flagsStart, const char *flagsEnd, + const char *conversionPosition) { + // Warn about using '[...]' without a '@' conversion. + auto Range = getSpecifierRange(flagsStart, flagsEnd - flagsStart + 1); + auto diag = diag::warn_printf_ObjCflags_without_ObjCConversion; + EmitFormatDiagnostic(S.PDiag(diag) << StringRef(conversionPosition, 1), + getLocationOfByte(conversionPosition), + /*IsStringLocation*/ true, Range, + FixItHint::CreateRemoval(Range)); } // Determines if the specified is a C++ class or struct containing // a member with the specified name and kind (e.g. a CXXMethodDecl named // "c_str()"). -template -static llvm::SmallPtrSet +template +static llvm::SmallPtrSet CXXRecordMembersNamed(StringRef Name, Sema &S, QualType Ty) { const RecordType *RT = Ty->getAs(); - llvm::SmallPtrSet Results; + llvm::SmallPtrSet Results; if (!RT) return Results; @@ -9721,8 +9985,8 @@ bool Sema::hasCStrMethod(const Expr *E) { MethodSet Results = CXXRecordMembersNamed("c_str", *this, E->getType()); - for (MethodSet::iterator MI = Results.begin(), ME = Results.end(); - MI != ME; ++MI) + for (MethodSet::iterator MI = Results.begin(), ME = Results.end(); MI != ME; + ++MI) if ((*MI)->getMinRequiredArguments() == 0) return true; return false; @@ -9731,15 +9995,15 @@ bool Sema::hasCStrMethod(const Expr *E) { // Check if a (w)string was passed when a (w)char* was needed, and offer a // better diagnostic if so. AT is assumed to be valid. // Returns true when a c_str() conversion method is found. -bool CheckPrintfHandler::checkForCStrMembers( - const analyze_printf::ArgType &AT, const Expr *E) { +bool CheckPrintfHandler::checkForCStrMembers(const analyze_printf::ArgType &AT, + const Expr *E) { using MethodSet = llvm::SmallPtrSet; MethodSet Results = CXXRecordMembersNamed("c_str", S, E->getType()); - for (MethodSet::iterator MI = Results.begin(), ME = Results.end(); - MI != ME; ++MI) { + for (MethodSet::iterator MI = Results.begin(), ME = Results.end(); MI != ME; + ++MI) { const CXXMethodDecl *Method = *MI; if (Method->getMinRequiredArguments() == 0 && AT.matchesType(S.Context, Method->getReturnType())) { @@ -9764,10 +10028,9 @@ bool CheckPrintfHandler::HandlePrintfSpecifier( if (FS.consumesDataArgument()) { if (atFirstArg) { - atFirstArg = false; - usesPositionalArgs = FS.usesPositionalArg(); - } - else if (usesPositionalArgs != FS.usesPositionalArg()) { + atFirstArg = false; + usesPositionalArgs = FS.usesPositionalArg(); + } else if (usesPositionalArgs != FS.usesPositionalArg()) { HandlePositionalNonpositionalArgs(getLocationOfByte(CS.getStart()), startSpecifier, specifierLen); return false; @@ -9776,13 +10039,13 @@ bool CheckPrintfHandler::HandlePrintfSpecifier( // First check if the field width, precision, and conversion specifier // have matching data arguments. - if (!HandleAmount(FS.getFieldWidth(), /* field width */ 0, - startSpecifier, specifierLen)) { + if (!HandleAmount(FS.getFieldWidth(), /* field width */ 0, startSpecifier, + specifierLen)) { return false; } - if (!HandleAmount(FS.getPrecision(), /* precision */ 1, - startSpecifier, specifierLen)) { + if (!HandleAmount(FS.getPrecision(), /* precision */ 1, startSpecifier, + specifierLen)) { return false; } @@ -9814,8 +10077,9 @@ bool CheckPrintfHandler::HandlePrintfSpecifier( // Type check the first argument (int for %b, pointer for %D) const Expr *Ex = getDataArg(argIndex); const analyze_printf::ArgType &AT = - (CS.getKind() == ConversionSpecifier::FreeBSDbArg) ? - ArgType(S.Context.IntTy) : ArgType::CPointerTy; + (CS.getKind() == ConversionSpecifier::FreeBSDbArg) + ? ArgType(S.Context.IntTy) + : ArgType::CPointerTy; if (AT.isValid() && !AT.matchesType(S.Context, Ex->getType())) EmitFormatDiagnostic( S.PDiag(diag::warn_format_conversion_argument_type_mismatch) @@ -9835,7 +10099,7 @@ bool CheckPrintfHandler::HandlePrintfSpecifier( Ex->getBeginLoc(), /*IsStringLocation*/ false, getSpecifierRange(startSpecifier, specifierLen)); - return true; + return true; } // Check for using an Objective-C specific conversion specifier @@ -9900,13 +10164,13 @@ bool CheckPrintfHandler::HandlePrintfSpecifier( // Check for invalid use of field width if (!FS.hasValidFieldWidth()) { HandleInvalidAmount(FS, FS.getFieldWidth(), /* field width */ 0, - startSpecifier, specifierLen); + startSpecifier, specifierLen); } // Check for invalid use of precision if (!FS.hasValidPrecision()) { HandleInvalidAmount(FS, FS.getPrecision(), /* precision */ 1, - startSpecifier, specifierLen); + startSpecifier, specifierLen); } // Precision is mandatory for %P specifier. @@ -9935,10 +10199,10 @@ bool CheckPrintfHandler::HandlePrintfSpecifier( // Check that flags are not ignored by another flag if (FS.hasSpacePrefix() && FS.hasPlusPrefix()) // ' ' ignored by '+' HandleIgnoredFlag(FS, FS.hasSpacePrefix(), FS.hasPlusPrefix(), - startSpecifier, specifierLen); + startSpecifier, specifierLen); if (FS.hasLeadingZeros() && FS.isLeftJustified()) // '0' ignored by '-' HandleIgnoredFlag(FS, FS.hasLeadingZeros(), FS.isLeftJustified(), - startSpecifier, specifierLen); + startSpecifier, specifierLen); // Check the length modifier is valid with the given conversion specifier. if (!FS.hasValidLengthModifier(S.getASTContext().getTargetInfo(), @@ -10005,20 +10269,19 @@ static bool requiresParensToAddCast(const Expr *E) { } static std::pair -shouldNotPrintDirectly(const ASTContext &Context, - QualType IntendedTy, +shouldNotPrintDirectly(const ASTContext &Context, QualType IntendedTy, const Expr *E) { // Use a 'while' to peel off layers of typedefs. QualType TyTy = IntendedTy; while (const TypedefType *UserTy = TyTy->getAs()) { StringRef Name = UserTy->getDecl()->getName(); QualType CastTy = llvm::StringSwitch(Name) - .Case("CFIndex", Context.getNSIntegerType()) - .Case("NSInteger", Context.getNSIntegerType()) - .Case("NSUInteger", Context.getNSUIntegerType()) - .Case("SInt32", Context.IntTy) - .Case("UInt32", Context.UnsignedIntTy) - .Default(QualType()); + .Case("CFIndex", Context.getNSIntegerType()) + .Case("NSInteger", Context.getNSIntegerType()) + .Case("NSUInteger", Context.getNSUIntegerType()) + .Case("SInt32", Context.IntTy) + .Case("UInt32", Context.UnsignedIntTy) + .Default(QualType()); if (!CastTy.isNull()) return std::make_pair(CastTy, Name); @@ -10028,8 +10291,7 @@ shouldNotPrintDirectly(const ASTContext &Context, // Strip parens if necessary. if (const ParenExpr *PE = dyn_cast(E)) - return shouldNotPrintDirectly(Context, - PE->getSubExpr()->getType(), + return shouldNotPrintDirectly(Context, PE->getSubExpr()->getType(), PE->getSubExpr()); // If this is a conditional expression, then its result type is constructed @@ -10040,14 +10302,10 @@ shouldNotPrintDirectly(const ASTContext &Context, QualType TrueTy, FalseTy; StringRef TrueName, FalseName; - std::tie(TrueTy, TrueName) = - shouldNotPrintDirectly(Context, - CO->getTrueExpr()->getType(), - CO->getTrueExpr()); - std::tie(FalseTy, FalseName) = - shouldNotPrintDirectly(Context, - CO->getFalseExpr()->getType(), - CO->getFalseExpr()); + std::tie(TrueTy, TrueName) = shouldNotPrintDirectly( + Context, CO->getTrueExpr()->getType(), CO->getTrueExpr()); + std::tie(FalseTy, FalseName) = shouldNotPrintDirectly( + Context, CO->getFalseExpr()->getType(), CO->getFalseExpr()); if (TrueTy == FalseTy) return std::make_pair(TrueTy, TrueName); @@ -10063,8 +10321,8 @@ shouldNotPrintDirectly(const ASTContext &Context, /// Return true if \p ICE is an implicit argument promotion of an arithmetic /// type. Bit-field 'promotions' from a higher ranked type to a lower ranked /// type do not count. -static bool -isArithmeticArgumentPromotion(Sema &S, const ImplicitCastExpr *ICE) { +static bool isArithmeticArgumentPromotion(Sema &S, + const ImplicitCastExpr *ICE) { QualType From = ICE->getSubExpr()->getType(); QualType To = ICE->getType(); // It's an integer promotion if the destination type is the promoted @@ -10084,11 +10342,9 @@ isArithmeticArgumentPromotion(Sema &S, const ImplicitCastExpr *ICE) { S.Context.getFloatingTypeOrder(From, To) < 0; } -bool -CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS, - const char *StartSpecifier, - unsigned SpecifierLen, - const Expr *E) { +bool CheckPrintfHandler::checkFormatExpr( + const analyze_printf::PrintfSpecifier &FS, const char *StartSpecifier, + unsigned SpecifierLen, const Expr *E) { using namespace analyze_format_string; using namespace analyze_printf; @@ -10225,10 +10481,12 @@ CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS, // Special-case some of Darwin's platform-independence types by suggesting // casts to primitive types that are known to be large enough. - bool ShouldNotPrintDirectly = false; StringRef CastTyName; + bool ShouldNotPrintDirectly = false; + StringRef CastTyName; if (S.Context.getTargetInfo().getTriple().isOSDarwin()) { QualType CastTy; - std::tie(CastTy, CastTyName) = shouldNotPrintDirectly(S.Context, IntendedTy, E); + std::tie(CastTy, CastTyName) = + shouldNotPrintDirectly(S.Context, IntendedTy, E); if (!CastTy.isNull()) { // %zi/%zu and %td/%tu are OK to use for NSInteger/NSUInteger of type int // (long in ASTContext). Only complain to pedants. @@ -10294,7 +10552,7 @@ CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS, IntendedTy.print(CastFix, S.Context.getPrintingPolicy()); CastFix << ")"; - SmallVector Hints; + SmallVector Hints; if (!AT.matchesType(S.Context, IntendedTy) || ShouldNotPrintDirectly) Hints.push_back(FixItHint::CreateReplacement(SpecRange, os.str())); @@ -10346,8 +10604,8 @@ CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS, } } } else { - const CharSourceRange &CSR = getSpecifierRange(StartSpecifier, - SpecifierLen); + const CharSourceRange &CSR = + getSpecifierRange(StartSpecifier, SpecifierLen); // Since the warning for passing non-POD types to variadic functions // was deferred until now, we emit a warning for non-POD // arguments here. @@ -10456,10 +10714,10 @@ class CheckScanfHandler : public CheckFormatHandler { const char *startSpecifier, unsigned specifierLen) override; - bool HandleInvalidScanfConversionSpecifier( - const analyze_scanf::ScanfSpecifier &FS, - const char *startSpecifier, - unsigned specifierLen) override; + bool + HandleInvalidScanfConversionSpecifier(const analyze_scanf::ScanfSpecifier &FS, + const char *startSpecifier, + unsigned specifierLen) override; void HandleIncompleteScanList(const char *start, const char *end) override; }; @@ -10469,27 +10727,24 @@ class CheckScanfHandler : public CheckFormatHandler { void CheckScanfHandler::HandleIncompleteScanList(const char *start, const char *end) { EmitFormatDiagnostic(S.PDiag(diag::warn_scanf_scanlist_incomplete), - getLocationOfByte(end), /*IsStringLocation*/true, + getLocationOfByte(end), /*IsStringLocation*/ true, getSpecifierRange(start, end - start)); } bool CheckScanfHandler::HandleInvalidScanfConversionSpecifier( - const analyze_scanf::ScanfSpecifier &FS, - const char *startSpecifier, - unsigned specifierLen) { + const analyze_scanf::ScanfSpecifier &FS, const char *startSpecifier, + unsigned specifierLen) { const analyze_scanf::ScanfConversionSpecifier &CS = - FS.getConversionSpecifier(); + FS.getConversionSpecifier(); - return HandleInvalidConversionSpecifier(FS.getArgIndex(), - getLocationOfByte(CS.getStart()), - startSpecifier, specifierLen, - CS.getStart(), CS.getLength()); + return HandleInvalidConversionSpecifier( + FS.getArgIndex(), getLocationOfByte(CS.getStart()), startSpecifier, + specifierLen, CS.getStart(), CS.getLength()); } bool CheckScanfHandler::HandleScanfSpecifier( - const analyze_scanf::ScanfSpecifier &FS, - const char *startSpecifier, - unsigned specifierLen) { + const analyze_scanf::ScanfSpecifier &FS, const char *startSpecifier, + unsigned specifierLen) { using namespace analyze_scanf; using namespace analyze_format_string; @@ -10501,8 +10756,7 @@ bool CheckScanfHandler::HandleScanfSpecifier( if (atFirstArg) { atFirstArg = false; usesPositionalArgs = FS.usesPositionalArg(); - } - else if (usesPositionalArgs != FS.usesPositionalArg()) { + } else if (usesPositionalArgs != FS.usesPositionalArg()) { HandlePositionalNonpositionalArgs(getLocationOfByte(CS.getStart()), startSpecifier, specifierLen); return false; @@ -10513,11 +10767,11 @@ bool CheckScanfHandler::HandleScanfSpecifier( const OptionalAmount &Amt = FS.getFieldWidth(); if (Amt.getHowSpecified() == OptionalAmount::Constant) { if (Amt.getConstantAmount() == 0) { - const CharSourceRange &R = getSpecifierRange(Amt.getStart(), - Amt.getConstantLength()); + const CharSourceRange &R = + getSpecifierRange(Amt.getStart(), Amt.getConstantLength()); EmitFormatDiagnostic(S.PDiag(diag::warn_scanf_nonzero_width), getLocationOfByte(Amt.getStart()), - /*IsStringLocation*/true, R, + /*IsStringLocation*/ true, R, FixItHint::CreateRemoval(R)); } } @@ -10531,9 +10785,9 @@ bool CheckScanfHandler::HandleScanfSpecifier( // Consume the argument. unsigned argIndex = FS.getArgIndex(); if (argIndex < NumDataArgs) { - // The check to see if the argIndex is valid will come later. - // We set the bit here because we may exit early from this - // function if we encounter some other error. + // The check to see if the argIndex is valid will come later. + // We set the bit here because we may exit early from this + // function if we encounter some other error. CoveredArgs.set(argIndex); } @@ -10630,7 +10884,7 @@ static void CheckFormatString( const char *Str = StrRef.data(); // Account for cases where the string literal is truncated in a declaration. const ConstantArrayType *T = - S.Context.getAsConstantArrayType(FExpr->getType()); + S.Context.getAsConstantArrayType(FExpr->getType()); assert(T && "String literal not of constant array type!"); size_t TypeSize = T->getSize().getZExtValue(); size_t StrLen = std::min(std::max(TypeSize, size_t(1)) - 1, StrRef.size()); @@ -10694,9 +10948,8 @@ bool Sema::FormatStringHasSArg(const StringLiteral *FExpr) { assert(T && "String literal not of constant array type!"); size_t TypeSize = T->getSize().getZExtValue(); size_t StrLen = std::min(std::max(TypeSize, size_t(1)) - 1, StrRef.size()); - return analyze_format_string::ParseFormatStringHasSArg(Str, Str + StrLen, - getLangOpts(), - Context.getTargetInfo()); + return analyze_format_string::ParseFormatStringHasSArg( + Str, Str + StrLen, getLangOpts(), Context.getTargetInfo()); } //===--- CHECK: Warn on use of wrong absolute value function. -------------===// @@ -10744,7 +10997,7 @@ static unsigned getLargerAbsoluteValueFunction(unsigned AbsFunction) { return 0; case Builtin::BIcabsf: - return Builtin::BIcabs; + return Builtin::BIcabs; case Builtin::BIcabs: return Builtin::BIcabsl; case Builtin::BIcabsl: @@ -10794,11 +11047,7 @@ static unsigned getBestAbsFunction(ASTContext &Context, QualType ArgType, return BestKind; } -enum AbsoluteValueKind { - AVK_Integer, - AVK_Floating, - AVK_Complex -}; +enum AbsoluteValueKind { AVK_Integer, AVK_Floating, AVK_Complex }; static AbsoluteValueKind getAbsoluteValueKind(QualType T) { if (T->isIntegralOrEnumerationType()) @@ -10988,8 +11237,8 @@ static void emitReplacement(Sema &S, SourceLocation Loc, SourceRange Range, if (!EmitHeaderHint) return; - S.Diag(Loc, diag::note_include_header_or_declare) << HeaderName - << FunctionName; + S.Diag(Loc, diag::note_include_header_or_declare) + << HeaderName << FunctionName; } template @@ -11088,32 +11337,44 @@ void Sema::CheckAbsoluteValueFunction(const CallExpr *Call, //===--- CHECK: Warn on use of std::max and unsigned zero. r---------------===// void Sema::CheckMaxUnsignedZero(const CallExpr *Call, const FunctionDecl *FDecl) { - if (!Call || !FDecl) return; + if (!Call || !FDecl) + return; // Ignore template specializations and macros. - if (inTemplateInstantiation()) return; - if (Call->getExprLoc().isMacroID()) return; + if (inTemplateInstantiation()) + return; + if (Call->getExprLoc().isMacroID()) + return; // Only care about the one template argument, two function parameter std::max - if (Call->getNumArgs() != 2) return; - if (!IsStdFunction(FDecl, "max")) return; - const auto * ArgList = FDecl->getTemplateSpecializationArgs(); - if (!ArgList) return; - if (ArgList->size() != 1) return; + if (Call->getNumArgs() != 2) + return; + if (!IsStdFunction(FDecl, "max")) + return; + const auto *ArgList = FDecl->getTemplateSpecializationArgs(); + if (!ArgList) + return; + if (ArgList->size() != 1) + return; // Check that template type argument is unsigned integer. - const auto& TA = ArgList->get(0); - if (TA.getKind() != TemplateArgument::Type) return; + const auto &TA = ArgList->get(0); + if (TA.getKind() != TemplateArgument::Type) + return; QualType ArgType = TA.getAsType(); - if (!ArgType->isUnsignedIntegerType()) return; + if (!ArgType->isUnsignedIntegerType()) + return; // See if either argument is a literal zero. - auto IsLiteralZeroArg = [](const Expr* E) -> bool { + auto IsLiteralZeroArg = [](const Expr *E) -> bool { const auto *MTE = dyn_cast(E); - if (!MTE) return false; + if (!MTE) + return false; const auto *Num = dyn_cast(MTE->getSubExpr()); - if (!Num) return false; - if (Num->getValue() != 0) return false; + if (!Num) + return false; + if (Num->getValue() != 0) + return false; return true; }; @@ -11123,7 +11384,8 @@ void Sema::CheckMaxUnsignedZero(const CallExpr *Call, const bool IsSecondArgZero = IsLiteralZeroArg(SecondArg); // Only warn when exactly one argument is zero. - if (IsFirstArgZero == IsSecondArgZero) return; + if (IsFirstArgZero == IsSecondArgZero) + return; SourceRange FirstRange = FirstArg->getSourceRange(); SourceRange SecondRange = SecondArg->getSourceRange(); @@ -11144,8 +11406,8 @@ void Sema::CheckMaxUnsignedZero(const CallExpr *Call, } Diag(Call->getExprLoc(), diag::note_remove_max_call) - << FixItHint::CreateRemoval(Call->getCallee()->getSourceRange()) - << FixItHint::CreateRemoval(RemovalRange); + << FixItHint::CreateRemoval(Call->getCallee()->getSourceRange()) + << FixItHint::CreateRemoval(RemovalRange); } //===--- CHECK: Standard memory functions ---------------------------------===// @@ -11326,7 +11588,7 @@ struct SearchNonTrivialToCopyField Sema &S; }; -} +} // namespace /// Detect if \c SizeofExpr is likely to calculate the sizeof an object. static bool doesExprLikelyComputeSize(const Expr *SizeofExpr) { @@ -11370,7 +11632,7 @@ static void CheckMemaccessSize(Sema &S, unsigned BId, const CallExpr *Call) { return; const Expr *SizeArg = - Call->getArg(BId == Builtin::BImemset ? 2 : 1)->IgnoreImpCasts(); + Call->getArg(BId == Builtin::BImemset ? 2 : 1)->IgnoreImpCasts(); auto isLiteralZero = [](const Expr *E) { return (isa(E) && @@ -11404,8 +11666,7 @@ static void CheckMemaccessSize(Sema &S, unsigned BId, const CallExpr *Call) { // If the second argument to a memset is a sizeof expression and the third // isn't, this is also likely an error. This should catch // 'memset(buf, sizeof(buf), 0xff)'. - if (BId == Builtin::BImemset && - doesExprLikelyComputeSize(Call->getArg(1)) && + if (BId == Builtin::BImemset && doesExprLikelyComputeSize(Call->getArg(1)) && !doesExprLikelyComputeSize(Call->getArg(2))) { SourceLocation DiagLoc = Call->getArg(1)->getExprLoc(); S.Diag(DiagLoc, diag::warn_suspicious_sizeof_memset) << 1; @@ -11421,8 +11682,7 @@ static void CheckMemaccessSize(Sema &S, unsigned BId, const CallExpr *Call) { /// function calls. /// /// \param Call The call expression to diagnose. -void Sema::CheckMemaccessArguments(const CallExpr *Call, - unsigned BId, +void Sema::CheckMemaccessArguments(const CallExpr *Call, unsigned BId, IdentifierInfo *FnName) { assert(BId != 0); @@ -11434,7 +11694,9 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call, return; unsigned LastArg = (BId == Builtin::BImemset || BId == Builtin::BIbzero || - BId == Builtin::BIstrndup ? 1 : 2); + BId == Builtin::BIstrndup + ? 1 + : 2); unsigned LenArg = (BId == Builtin::BIbzero || BId == Builtin::BIstrndup ? 1 : 2); const Expr *LenExpr = Call->getArg(LenArg)->IgnoreParenImpCasts(); @@ -11510,22 +11772,19 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call, ReadableName = Lexer::getImmediateMacroName(SL, SM, LangOpts); SL = SM.getSpellingLoc(SL); DSR = SourceRange(SM.getSpellingLoc(DSR.getBegin()), - SM.getSpellingLoc(DSR.getEnd())); + SM.getSpellingLoc(DSR.getEnd())); SSR = SourceRange(SM.getSpellingLoc(SSR.getBegin()), - SM.getSpellingLoc(SSR.getEnd())); + SM.getSpellingLoc(SSR.getEnd())); } DiagRuntimeBehavior(SL, SizeOfArg, PDiag(diag::warn_sizeof_pointer_expr_memaccess) - << ReadableName - << PointeeTy - << DestTy - << DSR - << SSR); - DiagRuntimeBehavior(SL, SizeOfArg, - PDiag(diag::warn_sizeof_pointer_expr_memaccess_note) - << ActionIdx - << SSR); + << ReadableName << PointeeTy << DestTy << DSR + << SSR); + DiagRuntimeBehavior( + SL, SizeOfArg, + PDiag(diag::warn_sizeof_pointer_expr_memaccess_note) + << ActionIdx << SSR); break; } @@ -11539,9 +11798,9 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call, Context.typesAreCompatible(SizeOfArgTy, DestTy)) { DiagRuntimeBehavior(LenExpr->getExprLoc(), Dest, PDiag(diag::warn_sizeof_pointer_type_memaccess) - << FnName << SizeOfArgTy << ArgIdx - << PointeeTy << Dest->getSourceRange() - << LenExpr->getSourceRange()); + << FnName << SizeOfArgTy << ArgIdx + << PointeeTy << Dest->getSourceRange() + << LenExpr->getSourceRange()); break; } } @@ -11564,7 +11823,7 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call, if (ArgIdx != 0 || IsCmp) { if (BId == Builtin::BImemcpy) OperationType = 1; - else if(BId == Builtin::BImemmove) + else if (BId == Builtin::BImemmove) OperationType = 2; else if (IsCmp) OperationType = 3; @@ -11576,12 +11835,11 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call, << IsContained << ContainedRD << OperationType << Call->getCallee()->getSourceRange()); } else if (PointeeTy.hasNonTrivialObjCLifetime() && - BId != Builtin::BImemset) - DiagRuntimeBehavior( - Dest->getExprLoc(), Dest, - PDiag(diag::warn_arc_object_memaccess) - << ArgIdx << FnName << PointeeTy - << Call->getCallee()->getSourceRange()); + BId != Builtin::BImemset) + DiagRuntimeBehavior(Dest->getExprLoc(), Dest, + PDiag(diag::warn_arc_object_memaccess) + << ArgIdx << FnName << PointeeTy + << Call->getCallee()->getSourceRange()); else if (const auto *RT = PointeeTy->getAs()) { if ((BId == Builtin::BImemset || BId == Builtin::BIbzero) && RT->getDecl()->isNonTrivialToPrimitiveDefaultInitialize()) { @@ -11602,9 +11860,9 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call, continue; DiagRuntimeBehavior( - Dest->getExprLoc(), Dest, - PDiag(diag::note_bad_memaccess_silence) - << FixItHint::CreateInsertion(ArgRange.getBegin(), "(void*)")); + Dest->getExprLoc(), Dest, + PDiag(diag::note_bad_memaccess_silence) + << FixItHint::CreateInsertion(ArgRange.getBegin(), "(void*)")); break; } } @@ -11616,7 +11874,7 @@ static const Expr *ignoreLiteralAdditions(const Expr *Ex, ASTContext &Ctx) { Ex = Ex->IgnoreParenCasts(); while (true) { - const BinaryOperator * BO = dyn_cast(Ex); + const BinaryOperator *BO = dyn_cast(Ex); if (!BO || !BO->isAdditiveOp()) break; @@ -11737,8 +11995,7 @@ static const Expr *getStrlenExprArg(const Expr *E) { // Warn on anti-patterns as the 'size' argument to strncat. // The correct size argument should look like following: // strncat(dst, src, sizeof(dst) - strlen(dest) - 1); -void Sema::CheckStrncatArguments(const CallExpr *CE, - IdentifierInfo *FnName) { +void Sema::CheckStrncatArguments(const CallExpr *CE, IdentifierInfo *FnName) { // Don't crash if the user has the wrong number of arguments. if (CE->getNumArgs() < 3) return; @@ -11791,8 +12048,8 @@ void Sema::CheckStrncatArguments(const CallExpr *CE, // Check if the destination is an array (rather than a pointer to an array). QualType DstTy = DstArg->getType(); - bool isKnownSizeArray = isConstantSizeArrayWithMoreThanOneElement(DstTy, - Context); + bool isKnownSizeArray = + isConstantSizeArrayWithMoreThanOneElement(DstTy, Context); if (!isKnownSizeArray) { if (PatternType == 1) Diag(SL, diag::warn_strncat_wrong_size) << SR; @@ -11816,7 +12073,7 @@ void Sema::CheckStrncatArguments(const CallExpr *CE, OS << ") - 1"; Diag(SL, diag::note_strncat_wrong_size) - << FixItHint::CreateReplacement(SR, OS.str()); + << FixItHint::CreateReplacement(SR, OS.str()); } namespace { @@ -11933,18 +12190,15 @@ void Sema::CheckFreeArguments(const CallExpr *E) { return CheckFreeArgumentsCast(*this, CalleeName, Cast); } -void -Sema::CheckReturnValExpr(Expr *RetValExp, QualType lhsType, - SourceLocation ReturnLoc, - bool isObjCMethod, - const AttrVec *Attrs, - const FunctionDecl *FD) { +void Sema::CheckReturnValExpr(Expr *RetValExp, QualType lhsType, + SourceLocation ReturnLoc, bool isObjCMethod, + const AttrVec *Attrs, const FunctionDecl *FD) { // Check if the return value is null but should not be. if (((Attrs && hasSpecificAttr(*Attrs)) || (!isObjCMethod && isNonNullType(Context, lhsType))) && CheckNonNullExpr(*this, RetValExp)) Diag(ReturnLoc, diag::warn_null_ret) - << (isObjCMethod ? 1 : 0) << RetValExp->getSourceRange(); + << (isObjCMethod ? 1 : 0) << RetValExp->getSourceRange(); // C++11 [basic.stc.dynamic.allocation]p4: // If an allocation function declared with a non-throwing @@ -11954,12 +12208,12 @@ Sema::CheckReturnValExpr(Expr *RetValExp, QualType lhsType, if (FD) { OverloadedOperatorKind Op = FD->getOverloadedOperator(); if (Op == OO_New || Op == OO_Array_New) { - const FunctionProtoType *Proto - = FD->getType()->castAs(); - if (!Proto->isNothrow(/*ResultIfDependent*/true) && + const FunctionProtoType *Proto = + FD->getType()->castAs(); + if (!Proto->isNothrow(/*ResultIfDependent*/ true) && CheckNonNullExpr(*this, RetValExp)) Diag(ReturnLoc, diag::warn_operator_new_returns_null) - << FD << getLangOpts().CPlusPlus11; + << FD << getLangOpts().CPlusPlus11; } } @@ -12006,8 +12260,8 @@ void Sema::CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS, } // Match a more general floating-point equality comparison (-Wfloat-equal). - Expr* LeftExprSansParen = LHS->IgnoreParenImpCasts(); - Expr* RightExprSansParen = RHS->IgnoreParenImpCasts(); + Expr *LeftExprSansParen = LHS->IgnoreParenImpCasts(); + Expr *RightExprSansParen = RHS->IgnoreParenImpCasts(); // Special case: check for x == x (which is OK). // Do not emit warnings for such cases. @@ -12021,26 +12275,26 @@ void Sema::CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS, // is a heuristic: often comparison against such literals are used to // detect if a value in a variable has not changed. This clearly can // lead to false negatives. - if (FloatingLiteral* FLL = dyn_cast(LeftExprSansParen)) { + if (FloatingLiteral *FLL = dyn_cast(LeftExprSansParen)) { if (FLL->isExact()) return; - } else - if (FloatingLiteral* FLR = dyn_cast(RightExprSansParen)) - if (FLR->isExact()) - return; + } else if (FloatingLiteral *FLR = + dyn_cast(RightExprSansParen)) + if (FLR->isExact()) + return; // Check for comparisons with builtin types. - if (CallExpr* CL = dyn_cast(LeftExprSansParen)) + if (CallExpr *CL = dyn_cast(LeftExprSansParen)) if (CL->getBuiltinCallee()) return; - if (CallExpr* CR = dyn_cast(RightExprSansParen)) + if (CallExpr *CR = dyn_cast(RightExprSansParen)) if (CR->getBuiltinCallee()) return; // Emit the diagnostic. Diag(Loc, diag::warn_floatingpoint_eq) - << LHS->getSourceRange() << RHS->getSourceRange(); + << LHS->getSourceRange() << RHS->getSourceRange(); } //===--- CHECK: Integer mixed-sign comparisons (-Wsign-compare) --------===// @@ -12064,19 +12318,15 @@ struct IntRange { : Width(Width), NonNegative(NonNegative) {} /// Number of bits excluding the sign bit. - unsigned valueBits() const { - return NonNegative ? Width : Width - 1; - } + unsigned valueBits() const { return NonNegative ? Width : Width - 1; } /// Returns the range of the bool type. - static IntRange forBoolType() { - return IntRange(1, true); - } + static IntRange forBoolType() { return IntRange(1, true); } /// Returns the range of an opaque value of the given integral type. static IntRange forValueOfType(ASTContext &C, QualType T) { return forValueOfCanonicalType(C, - T->getCanonicalTypeInternal().getTypePtr()); + T->getCanonicalTypeInternal().getTypePtr()); } /// Returns the range of an opaque value of a canonical integral type. @@ -12108,10 +12358,10 @@ struct IntRange { unsigned NumNegative = Enum->getNumNegativeBits(); if (NumNegative == 0) - return IntRange(NumPositive, true/*NonNegative*/); + return IntRange(NumPositive, true /*NonNegative*/); else return IntRange(std::max(NumPositive + 1, NumNegative), - false/*NonNegative*/); + false /*NonNegative*/); } if (const auto *EIT = dyn_cast(T)) @@ -12322,13 +12572,15 @@ static IntRange GetExprRange(ASTContext &C, const Expr *E, unsigned MaxWidth, // GetExprRange requires an integer expression, but a throw expression // results in a void type. Expr *E = CO->getTrueExpr(); - IntRange L = E->getType()->isVoidType() - ? IntRange{0, true} - : GetExprRange(C, E, MaxWidth, InConstantContext, Approximate); + IntRange L = + E->getType()->isVoidType() + ? IntRange{0, true} + : GetExprRange(C, E, MaxWidth, InConstantContext, Approximate); E = CO->getFalseExpr(); - IntRange R = E->getType()->isVoidType() - ? IntRange{0, true} - : GetExprRange(C, E, MaxWidth, InConstantContext, Approximate); + IntRange R = + E->getType()->isVoidType() + ? IntRange{0, true} + : GetExprRange(C, E, MaxWidth, InConstantContext, Approximate); return IntRange::join(L, R); } @@ -12384,8 +12636,8 @@ static IntRange GetExprRange(ASTContext &C, const Expr *E, unsigned MaxWidth, case BO_Shl: // ...except that we want to treat '1 << (blah)' as logically // positive. It's an important idiom. - if (IntegerLiteral *I - = dyn_cast(BO->getLHS()->IgnoreParenCasts())) { + if (IntegerLiteral *I = + dyn_cast(BO->getLHS()->IgnoreParenCasts())) { if (I->getValue() == 1) { IntRange R = IntRange::forValueOfType(C, GetExprType(E)); return IntRange(R.Width, /*NonNegative*/ true); @@ -12568,8 +12820,7 @@ static void AnalyzeImplicitConversions(Sema &S, Expr *E, SourceLocation CC, static bool IsEnumConstOrFromMacro(Sema &S, Expr *E) { // Suppress cases where we are comparing against an enum constant. - if (const DeclRefExpr *DR = - dyn_cast(E->IgnoreParenImpCasts())) + if (const DeclRefExpr *DR = dyn_cast(E->IgnoreParenImpCasts())) if (isa(DR->getDecl())) return true; @@ -12580,8 +12831,8 @@ static bool IsEnumConstOrFromMacro(Sema &S, Expr *E) { if (BeginLoc.isMacroID()) { StringRef MacroName = Lexer::getImmediateMacroName( BeginLoc, S.getSourceManager(), S.getLangOpts()); - return MacroName != "YES" && MacroName != "NO" && - MacroName != "true" && MacroName != "false"; + return MacroName != "YES" && MacroName != "NO" && MacroName != "true" && + MacroName != "false"; } return false; @@ -12658,21 +12909,30 @@ struct PromotedRange { Value.isUnsigned() == PromotedMin.isUnsigned()); if (!isContiguous()) { assert(Value.isUnsigned() && "discontiguous range for signed compare"); - if (Value.isMinValue()) return Min; - if (Value.isMaxValue()) return Max; - if (Value >= PromotedMin) return InRange; - if (Value <= PromotedMax) return InRange; + if (Value.isMinValue()) + return Min; + if (Value.isMaxValue()) + return Max; + if (Value >= PromotedMin) + return InRange; + if (Value <= PromotedMax) + return InRange; return InHole; } switch (llvm::APSInt::compareValues(Value, PromotedMin)) { - case -1: return Less; - case 0: return PromotedMin == PromotedMax ? OnlyValue : Min; + case -1: + return Less; + case 0: + return PromotedMin == PromotedMax ? OnlyValue : Min; case 1: switch (llvm::APSInt::compareValues(Value, PromotedMax)) { - case -1: return InRange; - case 0: return Max; - case 1: return Greater; + case -1: + return InRange; + case 0: + return Max; + case 1: + return Greater; } } @@ -12683,11 +12943,15 @@ struct PromotedRange { constantValue(BinaryOperatorKind Op, ComparisonResult R, bool ConstantOnRHS) { if (Op == BO_Cmp) { ComparisonResult LTFlag = LT, GTFlag = GT; - if (ConstantOnRHS) std::swap(LTFlag, GTFlag); - - if (R & EQ) return StringRef("'std::strong_ordering::equal'"); - if (R & LTFlag) return StringRef("'std::strong_ordering::less'"); - if (R & GTFlag) return StringRef("'std::strong_ordering::greater'"); + if (ConstantOnRHS) + std::swap(LTFlag, GTFlag); + + if (R & EQ) + return StringRef("'std::strong_ordering::equal'"); + if (R & LTFlag) + return StringRef("'std::strong_ordering::less'"); + if (R & GTFlag) + return StringRef("'std::strong_ordering::greater'"); return llvm::None; } @@ -12716,13 +12980,12 @@ struct PromotedRange { return llvm::None; } }; -} +} // namespace static bool HasEnumType(Expr *E) { // Strip off implicit integral promotions. while (ImplicitCastExpr *ICE = dyn_cast(E)) { - if (ICE->getCastKind() != CK_IntegralCast && - ICE->getCastKind() != CK_NoOp) + if (ICE->getCastKind() != CK_IntegralCast && ICE->getCastKind() != CK_NoOp) break; E = ICE->getSubExpr(); } @@ -12733,11 +12996,7 @@ static bool HasEnumType(Expr *E) { static int classifyConstantValue(Expr *Constant) { // The values of this enumeration are used in the diagnostics // diag::warn_out_of_range_compare and diag::warn_tautological_bool_compare. - enum ConstantValueKind { - Miscellaneous = 0, - LiteralTrue, - LiteralFalse - }; + enum ConstantValueKind { Miscellaneous = 0, LiteralTrue, LiteralFalse }; if (auto *BL = dyn_cast(Constant)) return BL->getValue() ? ConstantValueKind::LiteralTrue : ConstantValueKind::LiteralFalse; @@ -12845,7 +13104,7 @@ static bool CheckTautologicalComparison(Sema &S, BinaryOperator *E, if (ED) { OS << '\'' << *ED << "' (" << Value << ")"; } else if (auto *BL = dyn_cast( - Constant->IgnoreParenImpCasts())) { + Constant->IgnoreParenImpCasts())) { OS << (BL->getValue() ? "YES" : "NO"); } else { OS << Value; @@ -12884,8 +13143,8 @@ static bool CheckTautologicalComparison(Sema &S, BinaryOperator *E, (isKnownToHaveUnsignedValue(OriginalOther) && Value == 0) ? (HasEnumType(OriginalOther) ? diag::warn_unsigned_enum_always_true_comparison - : IsCharTy ? diag::warn_unsigned_char_always_true_comparison - : diag::warn_unsigned_always_true_comparison) + : IsCharTy ? diag::warn_unsigned_char_always_true_comparison + : diag::warn_unsigned_always_true_comparison) : diag::warn_tautological_constant_compare; S.Diag(E->getOperatorLoc(), Diag) @@ -13029,7 +13288,7 @@ static bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init, // White-list bool bitfields. QualType BitfieldType = Bitfield->getType(); if (BitfieldType->isBooleanType()) - return false; + return false; if (BitfieldType->isEnumeralType()) { EnumDecl *BitfieldEnumDecl = BitfieldType->castAs()->getDecl(); @@ -13047,8 +13306,7 @@ static bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init, // Ignore value- or type-dependent expressions. if (Bitfield->getBitWidth()->isValueDependent() || - Bitfield->getBitWidth()->isTypeDependent() || - Init->isValueDependent() || + Bitfield->getBitWidth()->isTypeDependent() || Init->isValueDependent() || Init->isTypeDependent()) return false; @@ -13193,19 +13451,19 @@ static void DiagnoseImpCast(Sema &S, Expr *E, QualType SourceType, QualType T, return; } S.Diag(E->getExprLoc(), diag) - << SourceType << T << E->getSourceRange() << SourceRange(CContext); + << SourceType << T << E->getSourceRange() << SourceRange(CContext); } /// Diagnose an implicit cast; purely a helper for CheckImplicitConversion. static void DiagnoseImpCast(Sema &S, Expr *E, QualType T, - SourceLocation CContext, - unsigned diag, bool pruneControlFlow = false) { + SourceLocation CContext, unsigned diag, + bool pruneControlFlow = false) { DiagnoseImpCast(S, E, E->getType(), T, CContext, diag, pruneControlFlow); } static bool isObjCSignedCharBool(Sema &S, QualType Ty) { return Ty->isSpecificBuiltinType(BuiltinType::SChar) && - S.getLangOpts().ObjC && S.NSAPIObj->isObjCBOOLType(Ty); + S.getLangOpts().ObjC && S.NSAPIObj->isObjCBOOLType(Ty); } static void adornObjCBoolConversionDiagWithTernaryFixit( @@ -13240,7 +13498,7 @@ static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T, llvm::APFloat Value(0.0); bool IsConstant = - E->EvaluateAsFloat(Value, S.Context, Expr::SE_AllowSideEffects); + E->EvaluateAsFloat(Value, S.Context, Expr::SE_AllowSideEffects); if (!IsConstant) { if (isObjCSignedCharBool(S, T)) { return adornObjCBoolConversionDiagWithTernaryFixit( @@ -13249,8 +13507,8 @@ static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T, << E->getType()); } - return DiagnoseImpCast(S, E, T, CContext, - diag::warn_impcast_float_integer, PruneWarnings); + return DiagnoseImpCast(S, E, T, CContext, diag::warn_impcast_float_integer, + PruneWarnings); } bool isExact = false; @@ -13278,7 +13536,8 @@ static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T, } if (Result == llvm::APFloat::opOK && isExact) { - if (IsLiteral) return; + if (IsLiteral) + return; return DiagnoseImpCast(S, E, T, CContext, diag::warn_impcast_float_integer, PruneWarnings); } @@ -13297,7 +13556,7 @@ static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T, // Warn on floating point literal to integer. DiagID = diag::warn_impcast_literal_float_to_integer; } else if (IntegerValue == 0) { - if (Value.isZero()) { // Skip -0.0 to 0 conversion. + if (Value.isZero()) { // Skip -0.0 to 0 conversion. return DiagnoseImpCast(S, E, T, CContext, diag::warn_impcast_float_integer, PruneWarnings); } @@ -13309,7 +13568,7 @@ static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T, return DiagnoseImpCast(S, E, T, CContext, diag::warn_impcast_float_integer, PruneWarnings); } - } else { // IntegerValue.isSigned() + } else { // IntegerValue.isSigned() if (!IntegerValue.isMaxSignedValue() && !IntegerValue.isMinSignedValue()) { return DiagnoseImpCast(S, E, T, CContext, @@ -13358,7 +13617,8 @@ static void AnalyzeCompoundAssignment(Sema &S, BinaryOperator *E) { ->getAs(); // The below checks assume source is floating point. - if (!ResultBT || !RBT || !RBT->isFloatingPoint()) return; + if (!ResultBT || !RBT || !RBT->isFloatingPoint()) + return; // If source is floating point but target is an integer. if (ResultBT->isInteger()) @@ -13379,7 +13639,8 @@ static void AnalyzeCompoundAssignment(Sema &S, BinaryOperator *E) { static std::string PrettyPrintInRange(const llvm::APSInt &Value, IntRange Range) { - if (!Range.Width) return "0"; + if (!Range.Width) + return "0"; llvm::APSInt ValueInRange = Value; ValueInRange.setIsSigned(!Range.NonNegative); @@ -13394,12 +13655,12 @@ static bool IsImplicitBoolFloatConversion(Sema &S, Expr *Ex, bool ToBool) { Expr *InnerE = Ex->IgnoreParenImpCasts(); const Type *Target = S.Context.getCanonicalType(Ex->getType()).getTypePtr(); const Type *Source = - S.Context.getCanonicalType(InnerE->getType()).getTypePtr(); + S.Context.getCanonicalType(InnerE->getType()).getTypePtr(); if (Target->isDependentType()) return false; const BuiltinType *FloatCandidateBT = - dyn_cast(ToBool ? Source : Target); + dyn_cast(ToBool ? Source : Target); const Type *BoolCandidateType = ToBool ? Target : Source; return (BoolCandidateType->isSpecificBuiltinType(BuiltinType::Bool) && @@ -13414,14 +13675,13 @@ static void CheckImplicitArgumentConversions(Sema &S, CallExpr *TheCall, if (!IsImplicitBoolFloatConversion(S, CurrA, true)) continue; - bool IsSwapped = ((i > 0) && - IsImplicitBoolFloatConversion(S, TheCall->getArg(i - 1), false)); - IsSwapped |= ((i < (NumArgs - 1)) && - IsImplicitBoolFloatConversion(S, TheCall->getArg(i + 1), false)); + bool IsSwapped = ((i > 0) && IsImplicitBoolFloatConversion( + S, TheCall->getArg(i - 1), false)); + IsSwapped |= ((i < (NumArgs - 1)) && IsImplicitBoolFloatConversion( + S, TheCall->getArg(i + 1), false)); if (IsSwapped) { // Warn on this floating-point to bool conversion. - DiagnoseImpCast(S, CurrA->IgnoreParenImpCasts(), - CurrA->getType(), CC, + DiagnoseImpCast(S, CurrA->IgnoreParenImpCasts(), CurrA->getType(), CC, diag::warn_impcast_floating_point_to_bool); } } @@ -13498,10 +13758,8 @@ static void checkObjCCollectionLiteralElement(Sema &S, QualType ElementType = Element->getType(); ExprResult ElementResult(Element); if (ElementType->getAs() && - S.CheckSingleAssignmentConstraints(TargetElementType, - ElementResult, - false, false) - != Sema::Compatible) { + S.CheckSingleAssignmentConstraints(TargetElementType, ElementResult, + false, false) != Sema::Compatible) { S.Diag(Element->getBeginLoc(), diag::warn_objc_collection_literal_element) << ElementType << ElementKind << TargetElementType << Element->getSourceRange(); @@ -13525,8 +13783,8 @@ static void checkObjCArrayLiteral(Sema &S, QualType TargetType, return; if (TargetObjCPtr->isUnspecialized() || - TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl() - != S.NSArrayDecl->getCanonicalDecl()) + TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl() != + S.NSArrayDecl->getCanonicalDecl()) return; auto TypeArgs = TargetObjCPtr->getTypeArgs(); @@ -13536,8 +13794,7 @@ static void checkObjCArrayLiteral(Sema &S, QualType TargetType, QualType TargetElementType = TypeArgs[0]; for (unsigned I = 0, N = ArrayLiteral->getNumElements(); I != N; ++I) { checkObjCCollectionLiteralElement(S, TargetElementType, - ArrayLiteral->getElement(I), - 0); + ArrayLiteral->getElement(I), 0); } } @@ -13554,8 +13811,8 @@ checkObjCDictionaryLiteral(Sema &S, QualType TargetType, return; if (TargetObjCPtr->isUnspecialized() || - TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl() - != S.NSDictionaryDecl->getCanonicalDecl()) + TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl() != + S.NSDictionaryDecl->getCanonicalDecl()) return; auto TypeArgs = TargetObjCPtr->getTypeArgs(); @@ -13650,12 +13907,15 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T, SourceLocation CC, bool *ICContext = nullptr, bool IsListInit = false) { - if (E->isTypeDependent() || E->isValueDependent()) return; + if (E->isTypeDependent() || E->isValueDependent()) + return; const Type *Source = S.Context.getCanonicalType(E->getType()).getTypePtr(); const Type *Target = S.Context.getCanonicalType(T).getTypePtr(); - if (Source == Target) return; - if (Target->isDependentType()) return; + if (Source == Target) + return; + if (Target->isDependentType()) + return; // If the conversion context location is invalid don't complain. We also // don't want to emit a warning if the issue occurs from the expansion of @@ -13796,9 +14056,10 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T, Expr::EvalResult result; if (E->EvaluateAsRValue(result, S.Context)) { // Value might be a float, a float vector, or a float complex. - if (IsSameFloatAfterCast(result.Val, - S.Context.getFloatTypeSemantics(QualType(TargetBT, 0)), - S.Context.getFloatTypeSemantics(QualType(SourceBT, 0)))) + if (IsSameFloatAfterCast( + result.Val, + S.Context.getFloatTypeSemantics(QualType(TargetBT, 0)), + S.Context.getFloatTypeSemantics(QualType(SourceBT, 0)))) return; } @@ -14147,7 +14408,8 @@ static void CheckConditionalOperator(Sema &S, AbstractConditionalOperator *E, // If -Wconversion would have warned about either of the candidates // for a signedness conversion to the context type... - if (!Suspicious) return; + if (!Suspicious) + return; // ...but it's currently ignored... if (!S.Diags.isIgnored(diag::warn_impcast_integer_sign_conditional, CC)) @@ -14155,11 +14417,12 @@ static void CheckConditionalOperator(Sema &S, AbstractConditionalOperator *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; + if (E->getType() == T) + return; Suspicious = false; - CheckImplicitConversion(S, TrueExpr->IgnoreParenImpCasts(), - E->getType(), CC, &Suspicious); + CheckImplicitConversion(S, TrueExpr->IgnoreParenImpCasts(), E->getType(), CC, + &Suspicious); if (!Suspicious) CheckImplicitConversion(S, E->getFalseExpr()->IgnoreParenImpCasts(), E->getType(), CC, &Suspicious); @@ -14181,7 +14444,7 @@ struct AnalyzeImplicitConversionsWorkItem { SourceLocation CC; bool IsListInit; }; -} +} // namespace /// Data recursive variant of AnalyzeImplicitConversions. Subexpressions /// that should be visited are added to WorkList. @@ -14287,10 +14550,12 @@ static void AnalyzeImplicitConversions( // we don't really need to recurse into them, because any internal // expressions should have been analyzed already when they were // built into statements. - if (isa(E)) return; + if (isa(E)) + return; // Don't descend into unevaluated contexts. - if (isa(E)) return; + if (isa(E)) + return; // Now just recurse over the expression's children. CC = E->getExprLoc(); @@ -14341,7 +14606,7 @@ static void AnalyzeImplicitConversions( /// implicit conversions in the given expression. There are a couple /// of competing diagnostics here, -Wconversion and -Wsign-compare. static void AnalyzeImplicitConversions(Sema &S, Expr *OrigE, SourceLocation CC, - bool IsListInit/*= false*/) { + bool IsListInit /*= false*/) { llvm::SmallVector WorkList; WorkList.push_back({OrigE, CC, IsListInit}); while (!WorkList.empty()) @@ -14454,8 +14719,8 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E, unsigned DiagID = IsCompare ? diag::warn_address_of_reference_null_compare : diag::warn_address_of_reference_bool_conversion; - PartialDiagnostic PD = PDiag(DiagID) << E->getSourceRange() << Range - << IsEqual; + PartialDiagnostic PD = PDiag(DiagID) + << E->getSourceRange() << Range << IsEqual; if (CheckForReference(*this, E, PD)) { return; } @@ -14468,8 +14733,8 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E, E->printPretty(S, nullptr, getPrintingPolicy()); unsigned DiagID = IsCompare ? diag::warn_nonnull_expr_compare : diag::warn_cast_nonnull_to_bool; - Diag(E->getExprLoc(), DiagID) << IsParam << S.str() - << E->getSourceRange() << Range << IsEqual; + Diag(E->getExprLoc(), DiagID) + << IsParam << S.str() << E->getSourceRange() << Range << IsEqual; Diag(NonnullAttr->getLocation(), diag::note_declared_nonnull) << IsParam; }; @@ -14496,7 +14761,7 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E, return; // Check for parameter decl with nonnull attribute - if (const auto* PV = dyn_cast(D)) { + if (const auto *PV = dyn_cast(D)) { if (getCurFunction() && !getCurFunction()->ModifiedNonNullParams.count(PV)) { if (const Attr *A = PV->getAttr()) { @@ -14514,8 +14779,8 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E, for (const auto *NonNull : FD->specific_attrs()) { if (!NonNull->args_size()) { - ComplainAboutNonnullParamOrCall(NonNull); - return; + ComplainAboutNonnullParamOrCall(NonNull); + return; } for (const ParamIdx &ArgNo : NonNull->args()) { @@ -14549,11 +14814,7 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E, unsigned DiagID = IsCompare ? diag::warn_null_pointer_compare : diag::warn_impcast_pointer_to_bool; - enum { - AddressOf, - FunctionPointer, - ArrayPointer - } DiagType; + enum { AddressOf, FunctionPointer, ArrayPointer } DiagType; if (IsAddressOf) DiagType = AddressOf; else if (IsFunction) @@ -14562,8 +14823,8 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E, DiagType = ArrayPointer; else llvm_unreachable("Could not determine diagnostic."); - Diag(E->getExprLoc(), DiagID) << DiagType << S.str() << E->getSourceRange() - << Range << IsEqual; + Diag(E->getExprLoc(), DiagID) + << DiagType << S.str() << E->getSourceRange() << Range << IsEqual; if (!IsFunction) return; @@ -14633,9 +14894,9 @@ void Sema::CheckBoolLikeConversion(Expr *E, SourceLocation CC) { ::CheckBoolLikeConversion(*this, E, CC); } -/// Diagnose when expression is an integer constant expression and its evaluation -/// results in integer overflow -void Sema::CheckForIntOverflow (Expr *E) { +/// Diagnose when expression is an integer constant expression and its +/// evaluation results in integer overflow +void Sema::CheckForIntOverflow(Expr *E) { // Use a work list to deal with nested struct initializers. SmallVector Exprs(1, E); @@ -14705,9 +14966,7 @@ class SequenceChecker : public ConstEvaluatedExprVisitor { } /// Merge a sequence of operations into its parent. - void merge(Seq S) { - Values[S.Index].Merged = true; - } + void merge(Seq S) { Values[S.Index].Merged = true; } /// Determine whether two operations are unsequenced. This operation /// is asymmetric: \p Cur should be the more recent sequence, and \p Old @@ -14798,7 +15057,7 @@ class SequenceChecker : public ConstEvaluatedExprVisitor { /// UK_ModAsValue. struct SequencedSubexpression { SequencedSubexpression(SequenceChecker &Self) - : Self(Self), OldModAsSideEffect(Self.ModAsSideEffect) { + : Self(Self), OldModAsSideEffect(Self.ModAsSideEffect) { Self.ModAsSideEffect = &ModAsSideEffect; } @@ -15533,9 +15792,8 @@ void Sema::CheckCompletedExpr(Expr *E, SourceLocation CheckLoc, } void Sema::CheckBitFieldInitialization(SourceLocation InitLoc, - FieldDecl *BitField, - Expr *Init) { - (void) AnalyzeBitFieldAssignment(*this, BitField, Init, InitLoc); + FieldDecl *BitField, Expr *Init) { + (void)AnalyzeBitFieldAssignment(*this, BitField, Init, InitLoc); } static void diagnoseArrayStarInParamType(Sema &S, QualType PType, @@ -15648,8 +15906,11 @@ bool Sema::CheckParmsForFunctionDef(ArrayRef Parameters, return HasInvalidParm; } -Optional> -static getBaseAlignmentAndOffsetFromPtr(const Expr *E, ASTContext &Ctx); +Optional> static getBaseAlignmentAndOffsetFromPtr(const Expr + *E, + ASTContext + &Ctx); /// Compute the alignment and offset of the base class object given the /// derived-to-base cast expression and the alignment and offset of the derived @@ -15714,8 +15975,10 @@ getAlignmentAndOffsetFromBinAddOrSub(const Expr *PtrE, const Expr *IntE, /// This helper function takes an lvalue expression and returns the alignment of /// a VarDecl and a constant offset from the VarDecl. -Optional> -static getBaseAlignmentAndOffsetFromLValue(const Expr *E, ASTContext &Ctx) { +Optional> static getBaseAlignmentAndOffsetFromLValue(const Expr *E, + ASTContext &Ctx) { E = E->IgnoreParens(); switch (E->getStmtClass()) { default: @@ -15802,8 +16065,11 @@ static getBaseAlignmentAndOffsetFromLValue(const Expr *E, ASTContext &Ctx) { /// This helper function takes a pointer expression and returns the alignment of /// a VarDecl and a constant offset from the VarDecl. -Optional> -static getBaseAlignmentAndOffsetFromPtr(const Expr *E, ASTContext &Ctx) { +Optional> static getBaseAlignmentAndOffsetFromPtr(const Expr + *E, + ASTContext + &Ctx) { E = E->IgnoreParens(); switch (E->getStmtClass()) { default: @@ -15891,39 +16157,44 @@ void Sema::CheckCastAlign(Expr *Op, QualType T, SourceRange TRange) { // Require that the destination be a pointer type. const PointerType *DestPtr = T->getAs(); - if (!DestPtr) return; + if (!DestPtr) + return; // If the destination has alignment 1, we're done. QualType DestPointee = DestPtr->getPointeeType(); - if (DestPointee->isIncompleteType()) return; + if (DestPointee->isIncompleteType()) + return; CharUnits DestAlign = Context.getTypeAlignInChars(DestPointee); - if (DestAlign.isOne()) return; + if (DestAlign.isOne()) + return; // Require that the source be a pointer type. const PointerType *SrcPtr = Op->getType()->getAs(); - if (!SrcPtr) return; + if (!SrcPtr) + return; QualType SrcPointee = SrcPtr->getPointeeType(); // Explicitly allow casts from cv void*. We already implicitly // allowed casts to cv void*, since they have alignment 1. // Also allow casts involving incomplete types, which implicitly // includes 'void'. - if (SrcPointee->isIncompleteType()) return; + if (SrcPointee->isIncompleteType()) + return; CharUnits SrcAlign = getPresumedAlignmentOfPointer(Op, *this); - if (SrcAlign >= DestAlign) return; + if (SrcAlign >= DestAlign) + return; Diag(TRange.getBegin(), diag::warn_cast_align) - << Op->getType() << T - << static_cast(SrcAlign.getQuantity()) - << static_cast(DestAlign.getQuantity()) - << TRange << Op->getSourceRange(); + << Op->getType() << T << static_cast(SrcAlign.getQuantity()) + << static_cast(DestAlign.getQuantity()) << TRange + << Op->getSourceRange(); } void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr, - const ArraySubscriptExpr *ASE, - bool AllowOnePastEnd, bool IndexNegated) { + const ArraySubscriptExpr *ASE, bool AllowOnePastEnd, + bool IndexNegated) { // Already diagnosed by the constant evaluator. if (isConstantEvaluated()) return; @@ -15938,8 +16209,8 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr, const ConstantArrayType *ArrayTy = Context.getAsConstantArrayType(BaseExpr->getType()); - LangOptions::StrictFlexArraysLevelKind - StrictFlexArraysLevel = getLangOpts().getStrictFlexArraysLevel(); + LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = + getLangOpts().getStrictFlexArraysLevel(); const Type *BaseType = ArrayTy == nullptr ? nullptr : ArrayTy->getElementType().getTypePtr(); @@ -16080,8 +16351,8 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr, // ']' location) and the index expression are both from macro expansions // within a system header. if (ASE) { - SourceLocation RBracketLoc = SourceMgr.getSpellingLoc( - ASE->getRBracketLoc()); + SourceLocation RBracketLoc = + SourceMgr.getSpellingLoc(ASE->getRBracketLoc()); if (SourceMgr.isInSystemHeader(RBracketLoc)) { SourceLocation IndexLoc = SourceMgr.getSpellingLoc(IndexExpr->getBeginLoc()); @@ -16103,7 +16374,8 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr, unsigned DiagID = diag::warn_array_index_precedes_bounds; if (!ASE) { DiagID = diag::warn_ptr_arith_precedes_bounds; - if (index.isNegative()) index = -index; + if (index.isNegative()) + index = -index; } DiagRuntimeBehavior(BaseExpr->getBeginLoc(), BaseExpr, @@ -16130,56 +16402,55 @@ void Sema::CheckArrayAccess(const Expr *expr) { while (expr) { expr = expr->IgnoreParenImpCasts(); switch (expr->getStmtClass()) { - case Stmt::ArraySubscriptExprClass: { - const ArraySubscriptExpr *ASE = cast(expr); - CheckArrayAccess(ASE->getBase(), ASE->getIdx(), ASE, - AllowOnePastEnd > 0); - expr = ASE->getBase(); - break; - } - case Stmt::MemberExprClass: { - expr = cast(expr)->getBase(); + case Stmt::ArraySubscriptExprClass: { + const ArraySubscriptExpr *ASE = cast(expr); + CheckArrayAccess(ASE->getBase(), ASE->getIdx(), ASE, AllowOnePastEnd > 0); + expr = ASE->getBase(); + break; + } + case Stmt::MemberExprClass: { + expr = cast(expr)->getBase(); + break; + } + case Stmt::OMPArraySectionExprClass: { + const OMPArraySectionExpr *ASE = cast(expr); + if (ASE->getLowerBound()) + CheckArrayAccess(ASE->getBase(), ASE->getLowerBound(), + /*ASE=*/nullptr, AllowOnePastEnd > 0); + return; + } + case Stmt::UnaryOperatorClass: { + // Only unwrap the * and & unary operators + const UnaryOperator *UO = cast(expr); + expr = UO->getSubExpr(); + switch (UO->getOpcode()) { + case UO_AddrOf: + AllowOnePastEnd++; break; - } - case Stmt::OMPArraySectionExprClass: { - const OMPArraySectionExpr *ASE = cast(expr); - if (ASE->getLowerBound()) - CheckArrayAccess(ASE->getBase(), ASE->getLowerBound(), - /*ASE=*/nullptr, AllowOnePastEnd > 0); - return; - } - case Stmt::UnaryOperatorClass: { - // Only unwrap the * and & unary operators - const UnaryOperator *UO = cast(expr); - expr = UO->getSubExpr(); - switch (UO->getOpcode()) { - case UO_AddrOf: - AllowOnePastEnd++; - break; - case UO_Deref: - AllowOnePastEnd--; - break; - default: - return; - } + case UO_Deref: + AllowOnePastEnd--; break; - } - case Stmt::ConditionalOperatorClass: { - const ConditionalOperator *cond = cast(expr); - if (const Expr *lhs = cond->getLHS()) - CheckArrayAccess(lhs); - if (const Expr *rhs = cond->getRHS()) - CheckArrayAccess(rhs); - return; - } - case Stmt::CXXOperatorCallExprClass: { - const auto *OCE = cast(expr); - for (const auto *Arg : OCE->arguments()) - CheckArrayAccess(Arg); - return; - } default: return; + } + break; + } + case Stmt::ConditionalOperatorClass: { + const ConditionalOperator *cond = cast(expr); + if (const Expr *lhs = cond->getLHS()) + CheckArrayAccess(lhs); + if (const Expr *rhs = cond->getRHS()) + CheckArrayAccess(rhs); + return; + } + case Stmt::CXXOperatorCallExprClass: { + const auto *OCE = cast(expr); + for (const auto *Arg : OCE->arguments()) + CheckArrayAccess(Arg); + return; + } + default: + return; } } } @@ -16245,19 +16516,22 @@ static bool findRetainCycleOwner(Sema &S, Expr *e, RetainCycleOwner &owner) { if (!findRetainCycleOwner(S, ref->getBase(), owner)) return false; - if (ref->isFreeIvar()) owner.setLocsFrom(ref); + if (ref->isFreeIvar()) + owner.setLocsFrom(ref); owner.Indirect = true; return true; } if (DeclRefExpr *ref = dyn_cast(e)) { VarDecl *var = dyn_cast(ref->getDecl()); - if (!var) return false; + if (!var) + return false; return considerVariable(var, ref, owner); } if (MemberExpr *member = dyn_cast(e)) { - if (member->isArrow()) return false; + if (member->isArrow()) + return false; // Don't count this as an indirect ownership. e = member->getBase(); @@ -16266,17 +16540,18 @@ static bool findRetainCycleOwner(Sema &S, Expr *e, RetainCycleOwner &owner) { if (PseudoObjectExpr *pseudo = dyn_cast(e)) { // Only pay attention to pseudo-objects on property references. - ObjCPropertyRefExpr *pre - = dyn_cast(pseudo->getSyntacticForm() - ->IgnoreParens()); - if (!pre) return false; - if (pre->isImplicitProperty()) return false; + ObjCPropertyRefExpr *pre = dyn_cast( + pseudo->getSyntacticForm()->IgnoreParens()); + if (!pre) + return false; + if (pre->isImplicitProperty()) + return false; ObjCPropertyDecl *property = pre->getExplicitProperty(); if (!property->isRetaining() && !(property->getPropertyIvarDecl() && - property->getPropertyIvarDecl()->getType() - .getObjCLifetime() == Qualifiers::OCL_Strong)) - return false; + property->getPropertyIvarDecl()->getType().getObjCLifetime() == + Qualifiers::OCL_Strong)) + return false; owner.Indirect = true; if (pre->isSuperReceiver()) { @@ -16287,8 +16562,8 @@ static bool findRetainCycleOwner(Sema &S, Expr *e, RetainCycleOwner &owner) { owner.Range = pre->getSourceRange(); return true; } - e = const_cast(cast(pre->getBase()) - ->getSourceExpr()); + e = const_cast( + cast(pre->getBase())->getSourceExpr()); continue; } @@ -16300,57 +16575,59 @@ static bool findRetainCycleOwner(Sema &S, Expr *e, RetainCycleOwner &owner) { namespace { - struct FindCaptureVisitor : EvaluatedExprVisitor { - ASTContext &Context; - VarDecl *Variable; - Expr *Capturer = nullptr; - bool VarWillBeReased = false; +struct FindCaptureVisitor : EvaluatedExprVisitor { + ASTContext &Context; + VarDecl *Variable; + Expr *Capturer = nullptr; + bool VarWillBeReased = false; - FindCaptureVisitor(ASTContext &Context, VarDecl *variable) - : EvaluatedExprVisitor(Context), - Context(Context), Variable(variable) {} + FindCaptureVisitor(ASTContext &Context, VarDecl *variable) + : EvaluatedExprVisitor(Context), Context(Context), + Variable(variable) {} - void VisitDeclRefExpr(DeclRefExpr *ref) { - if (ref->getDecl() == Variable && !Capturer) - Capturer = ref; - } + void VisitDeclRefExpr(DeclRefExpr *ref) { + if (ref->getDecl() == Variable && !Capturer) + Capturer = ref; + } - void VisitObjCIvarRefExpr(ObjCIvarRefExpr *ref) { - if (Capturer) return; - Visit(ref->getBase()); - if (Capturer && ref->isFreeIvar()) - Capturer = ref; - } + void VisitObjCIvarRefExpr(ObjCIvarRefExpr *ref) { + if (Capturer) + return; + Visit(ref->getBase()); + if (Capturer && ref->isFreeIvar()) + Capturer = ref; + } - void VisitBlockExpr(BlockExpr *block) { - // Look inside nested blocks - if (block->getBlockDecl()->capturesVariable(Variable)) - Visit(block->getBlockDecl()->getBody()); - } + void VisitBlockExpr(BlockExpr *block) { + // Look inside nested blocks + if (block->getBlockDecl()->capturesVariable(Variable)) + Visit(block->getBlockDecl()->getBody()); + } - void VisitOpaqueValueExpr(OpaqueValueExpr *OVE) { - if (Capturer) return; - if (OVE->getSourceExpr()) - Visit(OVE->getSourceExpr()); - } + void VisitOpaqueValueExpr(OpaqueValueExpr *OVE) { + if (Capturer) + return; + if (OVE->getSourceExpr()) + Visit(OVE->getSourceExpr()); + } - void VisitBinaryOperator(BinaryOperator *BinOp) { - if (!Variable || VarWillBeReased || BinOp->getOpcode() != BO_Assign) + void VisitBinaryOperator(BinaryOperator *BinOp) { + if (!Variable || VarWillBeReased || BinOp->getOpcode() != BO_Assign) + return; + Expr *LHS = BinOp->getLHS(); + if (const DeclRefExpr *DRE = dyn_cast_or_null(LHS)) { + if (DRE->getDecl() != Variable) return; - Expr *LHS = BinOp->getLHS(); - if (const DeclRefExpr *DRE = dyn_cast_or_null(LHS)) { - if (DRE->getDecl() != Variable) - return; - if (Expr *RHS = BinOp->getRHS()) { - RHS = RHS->IgnoreParenCasts(); - Optional Value; - VarWillBeReased = - (RHS && (Value = RHS->getIntegerConstantExpr(Context)) && - *Value == 0); - } + if (Expr *RHS = BinOp->getRHS()) { + RHS = RHS->IgnoreParenCasts(); + Optional Value; + VarWillBeReased = + (RHS && (Value = RHS->getIntegerConstantExpr(Context)) && + *Value == 0); } } - }; + } +}; } // namespace @@ -16397,18 +16674,20 @@ static void diagnoseRetainCycle(Sema &S, Expr *capturer, assert(owner.Variable && owner.Loc.isValid()); S.Diag(capturer->getExprLoc(), diag::warn_arc_retain_cycle) - << owner.Variable << capturer->getSourceRange(); + << owner.Variable << capturer->getSourceRange(); S.Diag(owner.Loc, diag::note_arc_retain_cycle_owner) - << owner.Indirect << owner.Range; + << owner.Indirect << owner.Range; } /// Check for a keyword selector that starts with the word 'add' or /// 'set'. static bool isSetterLikeSelector(Selector sel) { - if (sel.isUnarySelector()) return false; + if (sel.isUnarySelector()) + return false; StringRef str = sel.getNameForSlot(0); - while (!str.empty() && str.front() == '_') str = str.substr(1); + while (!str.empty() && str.front() == '_') + str = str.substr(1); if (str.startswith("set")) str = str.substr(3); else if (str.startswith("add")) { @@ -16416,19 +16695,18 @@ static bool isSetterLikeSelector(Selector sel) { if (sel.getNumArgs() == 1 && str.startswith("addOperationWithBlock")) return false; str = str.substr(3); - } - else + } else return false; - if (str.empty()) return true; + if (str.empty()) + return true; return !isLowercase(str.front()); } static Optional GetNSMutableArrayArgumentIndex(Sema &S, ObjCMessageExpr *Message) { bool IsMutableArray = S.NSAPIObj->isSubclassOfNSClass( - Message->getReceiverInterface(), - NSAPI::ClassId_NSMutableArray); + Message->getReceiverInterface(), NSAPI::ClassId_NSMutableArray); if (!IsMutableArray) { return None; } @@ -16436,7 +16714,7 @@ static Optional GetNSMutableArrayArgumentIndex(Sema &S, Selector Sel = Message->getSelector(); Optional MKOpt = - S.NSAPIObj->getNSArrayMethodKind(Sel); + S.NSAPIObj->getNSArrayMethodKind(Sel); if (!MKOpt) { return None; } @@ -16444,26 +16722,24 @@ static Optional GetNSMutableArrayArgumentIndex(Sema &S, NSAPI::NSArrayMethodKind MK = *MKOpt; switch (MK) { - case NSAPI::NSMutableArr_addObject: - case NSAPI::NSMutableArr_insertObjectAtIndex: - case NSAPI::NSMutableArr_setObjectAtIndexedSubscript: - return 0; - case NSAPI::NSMutableArr_replaceObjectAtIndex: - return 1; + case NSAPI::NSMutableArr_addObject: + case NSAPI::NSMutableArr_insertObjectAtIndex: + case NSAPI::NSMutableArr_setObjectAtIndexedSubscript: + return 0; + case NSAPI::NSMutableArr_replaceObjectAtIndex: + return 1; - default: - return None; + default: + return None; } return None; } -static -Optional GetNSMutableDictionaryArgumentIndex(Sema &S, - ObjCMessageExpr *Message) { +static Optional +GetNSMutableDictionaryArgumentIndex(Sema &S, ObjCMessageExpr *Message) { bool IsMutableDictionary = S.NSAPIObj->isSubclassOfNSClass( - Message->getReceiverInterface(), - NSAPI::ClassId_NSMutableDictionary); + Message->getReceiverInterface(), NSAPI::ClassId_NSMutableDictionary); if (!IsMutableDictionary) { return None; } @@ -16471,7 +16747,7 @@ Optional GetNSMutableDictionaryArgumentIndex(Sema &S, Selector Sel = Message->getSelector(); Optional MKOpt = - S.NSAPIObj->getNSDictionaryMethodKind(Sel); + S.NSAPIObj->getNSDictionaryMethodKind(Sel); if (!MKOpt) { return None; } @@ -16479,13 +16755,13 @@ Optional GetNSMutableDictionaryArgumentIndex(Sema &S, NSAPI::NSDictionaryMethodKind MK = *MKOpt; switch (MK) { - case NSAPI::NSMutableDict_setObjectForKey: - case NSAPI::NSMutableDict_setValueForKey: - case NSAPI::NSMutableDict_setObjectForKeyedSubscript: - return 0; + case NSAPI::NSMutableDict_setObjectForKey: + case NSAPI::NSMutableDict_setValueForKey: + case NSAPI::NSMutableDict_setObjectForKeyedSubscript: + return 0; - default: - return None; + default: + return None; } return None; @@ -16493,12 +16769,10 @@ Optional GetNSMutableDictionaryArgumentIndex(Sema &S, static Optional GetNSSetArgumentIndex(Sema &S, ObjCMessageExpr *Message) { bool IsMutableSet = S.NSAPIObj->isSubclassOfNSClass( - Message->getReceiverInterface(), - NSAPI::ClassId_NSMutableSet); + Message->getReceiverInterface(), NSAPI::ClassId_NSMutableSet); bool IsMutableOrderedSet = S.NSAPIObj->isSubclassOfNSClass( - Message->getReceiverInterface(), - NSAPI::ClassId_NSMutableOrderedSet); + Message->getReceiverInterface(), NSAPI::ClassId_NSMutableOrderedSet); if (!IsMutableSet && !IsMutableOrderedSet) { return None; } @@ -16513,13 +16787,13 @@ static Optional GetNSSetArgumentIndex(Sema &S, ObjCMessageExpr *Message) { NSAPI::NSSetMethodKind MK = *MKOpt; switch (MK) { - case NSAPI::NSMutableSet_addObject: - case NSAPI::NSOrderedSet_setObjectAtIndex: - case NSAPI::NSOrderedSet_setObjectAtIndexedSubscript: - case NSAPI::NSOrderedSet_insertObjectAtIndex: - return 0; - case NSAPI::NSOrderedSet_replaceObjectAtIndexWithObject: - return 1; + case NSAPI::NSMutableSet_addObject: + case NSAPI::NSOrderedSet_setObjectAtIndex: + case NSAPI::NSOrderedSet_setObjectAtIndexedSubscript: + case NSAPI::NSOrderedSet_insertObjectAtIndex: + return 0; + case NSAPI::NSOrderedSet_replaceObjectAtIndexWithObject: + return 1; } return None; @@ -16550,7 +16824,7 @@ void Sema::CheckObjCCircularContainer(ObjCMessageExpr *Message) { if (ArgRE->isObjCSelfExpr()) { Diag(Message->getSourceRange().getBegin(), diag::warn_objc_circular_container) - << ArgRE->getDecl() << StringRef("'super'"); + << ArgRE->getDecl() << StringRef("'super'"); } } } else { @@ -16566,11 +16840,11 @@ void Sema::CheckObjCCircularContainer(ObjCMessageExpr *Message) { ValueDecl *Decl = ReceiverRE->getDecl(); Diag(Message->getSourceRange().getBegin(), diag::warn_objc_circular_container) - << Decl << Decl; + << Decl << Decl; if (!ArgRE->isObjCSelfExpr()) { Diag(Decl->getLocation(), diag::note_objc_circular_container_declared_here) - << Decl; + << Decl; } } } @@ -16580,10 +16854,10 @@ void Sema::CheckObjCCircularContainer(ObjCMessageExpr *Message) { ObjCIvarDecl *Decl = IvarRE->getDecl(); Diag(Message->getSourceRange().getBegin(), diag::warn_objc_circular_container) - << Decl << Decl; + << Decl << Decl; Diag(Decl->getLocation(), diag::note_objc_circular_container_declared_here) - << Decl; + << Decl; } } } @@ -16644,8 +16918,8 @@ void Sema::checkRetainCycles(VarDecl *Var, Expr *Init) { diagnoseRetainCycle(*this, Capturer, Owner); } -static bool checkUnsafeAssignLiteral(Sema &S, SourceLocation Loc, - Expr *RHS, bool isProperty) { +static bool checkUnsafeAssignLiteral(Sema &S, SourceLocation Loc, Expr *RHS, + bool isProperty) { // Check if RHS is an Objective-C object literal, which also can get // immediately zapped in a weak reference. Note that we explicitly // allow ObjCStringLiterals, since those are designed to never really die. @@ -16658,23 +16932,20 @@ static bool checkUnsafeAssignLiteral(Sema &S, SourceLocation Loc, return false; S.Diag(Loc, diag::warn_arc_literal_assign) - << (unsigned) Kind - << (isProperty ? 0 : 1) - << RHS->getSourceRange(); + << (unsigned)Kind << (isProperty ? 0 : 1) << RHS->getSourceRange(); return true; } static bool checkUnsafeAssignObject(Sema &S, SourceLocation Loc, - Qualifiers::ObjCLifetime LT, - Expr *RHS, bool isProperty) { + Qualifiers::ObjCLifetime LT, Expr *RHS, + bool isProperty) { // Strip off any implicit cast added to get to the one ARC-specific. while (ImplicitCastExpr *cast = dyn_cast(RHS)) { if (cast->getCastKind() == CK_ARCConsumeObject) { S.Diag(Loc, diag::warn_arc_retained_assign) - << (LT == Qualifiers::OCL_ExplicitNone) - << (isProperty ? 0 : 1) - << RHS->getSourceRange(); + << (LT == Qualifiers::OCL_ExplicitNone) << (isProperty ? 0 : 1) + << RHS->getSourceRange(); return true; } RHS = cast->getSubExpr(); @@ -16687,8 +16958,7 @@ static bool checkUnsafeAssignObject(Sema &S, SourceLocation Loc, return false; } -bool Sema::checkUnsafeAssigns(SourceLocation Loc, - QualType LHS, Expr *RHS) { +bool Sema::checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS) { Qualifiers::ObjCLifetime LT = LHS.getObjCLifetime(); if (LT != Qualifiers::OCL_Weak && LT != Qualifiers::OCL_ExplicitNone) @@ -16700,13 +16970,11 @@ bool Sema::checkUnsafeAssigns(SourceLocation Loc, return false; } -void Sema::checkUnsafeExprAssigns(SourceLocation Loc, - Expr *LHS, Expr *RHS) { +void Sema::checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS) { QualType LHSType; // PropertyRef on LHS type need be directly obtained from // its declaration as it has a PseudoType. - ObjCPropertyRefExpr *PRE - = dyn_cast(LHS->IgnoreParens()); + ObjCPropertyRefExpr *PRE = dyn_cast(LHS->IgnoreParens()); if (PRE && !PRE->isImplicitProperty()) { const ObjCPropertyDecl *PD = PRE->getExplicitProperty(); if (PD) @@ -16750,7 +17018,7 @@ void Sema::checkUnsafeExprAssigns(SourceLocation Loc, while (ImplicitCastExpr *cast = dyn_cast(RHS)) { if (cast->getCastKind() == CK_ARCConsumeObject) { Diag(Loc, diag::warn_arc_retained_property_assign) - << RHS->getSourceRange(); + << RHS->getSourceRange(); return; } RHS = cast->getSubExpr(); @@ -16777,14 +17045,14 @@ static bool ShouldDiagnoseEmptyStmtBody(const SourceManager &SourceMgr, // Get line numbers of statement and body. bool StmtLineInvalid; - unsigned StmtLine = SourceMgr.getPresumedLineNumber(StmtLoc, - &StmtLineInvalid); + unsigned StmtLine = + SourceMgr.getPresumedLineNumber(StmtLoc, &StmtLineInvalid); if (StmtLineInvalid) return false; bool BodyLineInvalid; - unsigned BodyLine = SourceMgr.getSpellingLineNumber(Body->getSemiLoc(), - &BodyLineInvalid); + unsigned BodyLine = + SourceMgr.getSpellingLineNumber(Body->getSemiLoc(), &BodyLineInvalid); if (BodyLineInvalid) return false; @@ -16795,8 +17063,7 @@ static bool ShouldDiagnoseEmptyStmtBody(const SourceManager &SourceMgr, return true; } -void Sema::DiagnoseEmptyStmtBody(SourceLocation StmtLoc, - const Stmt *Body, +void Sema::DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body, unsigned DiagID) { // Since this is a syntactic check, don't emit diagnostic for template // instantiations, this just adds noise. @@ -16816,8 +17083,7 @@ void Sema::DiagnoseEmptyStmtBody(SourceLocation StmtLoc, Diag(NBody->getSemiLoc(), diag::note_empty_body_on_separate_line); } -void Sema::DiagnoseEmptyLoopBody(const Stmt *S, - const Stmt *PossibleBody) { +void Sema::DiagnoseEmptyLoopBody(const Stmt *S, const Stmt *PossibleBody) { assert(!CurrentInstantiationScope); // Ensured by caller SourceLocation StmtLoc; @@ -16886,7 +17152,7 @@ void Sema::DiagnoseEmptyLoopBody(const Stmt *S, /// DiagnoseSelfMove - Emits a warning if a value is moved to itself. void Sema::DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr, - SourceLocation OpLoc) { + SourceLocation OpLoc) { if (Diags.isIgnored(diag::warn_sizeof_pointer_expr_memaccess, OpLoc)) return; @@ -17023,12 +17289,10 @@ static bool isLayoutCompatibleStruct(ASTContext &C, RecordDecl *RD1, return false; // Check the base classes. - for (CXXRecordDecl::base_class_const_iterator - Base1 = D1CXX->bases_begin(), - BaseEnd1 = D1CXX->bases_end(), - Base2 = D2CXX->bases_begin(); - Base1 != BaseEnd1; - ++Base1, ++Base2) { + for (CXXRecordDecl::base_class_const_iterator Base1 = D1CXX->bases_begin(), + BaseEnd1 = D1CXX->bases_end(), + Base2 = D2CXX->bases_begin(); + Base1 != BaseEnd1; ++Base1, ++Base2) { if (!isLayoutCompatible(C, Base1->getType(), Base2->getType())) return false; } @@ -17043,7 +17307,7 @@ static bool isLayoutCompatibleStruct(ASTContext &C, RecordDecl *RD1, Field2End = RD2->field_end(), Field1 = RD1->field_begin(), Field1End = RD1->field_end(); - for ( ; Field1 != Field1End && Field2 != Field2End; ++Field1, ++Field2) { + for (; Field1 != Field1End && Field2 != Field2End; ++Field1, ++Field2) { if (!isLayoutCompatible(C, *Field1, *Field2)) return false; } @@ -17062,14 +17326,13 @@ static bool isLayoutCompatibleUnion(ASTContext &C, RecordDecl *RD1, UnmatchedFields.insert(Field2); for (auto *Field1 : RD1->fields()) { - llvm::SmallPtrSet::iterator - I = UnmatchedFields.begin(), - E = UnmatchedFields.end(); + llvm::SmallPtrSet::iterator I = UnmatchedFields.begin(), + E = UnmatchedFields.end(); - for ( ; I != E; ++I) { + for (; I != E; ++I) { if (isLayoutCompatible(C, Field1, *I)) { bool Result = UnmatchedFields.erase(*I); - (void) Result; + (void)Result; assert(Result); break; } @@ -17113,15 +17376,13 @@ static bool isLayoutCompatible(ASTContext &C, QualType T1, QualType T2) { return false; if (TC1 == Type::Enum) { - return isLayoutCompatible(C, - cast(T1)->getDecl(), + return isLayoutCompatible(C, cast(T1)->getDecl(), cast(T2)->getDecl()); } else if (TC1 == Type::Record) { if (!T1->isStandardLayoutType() || !T2->isStandardLayoutType()) return false; - return isLayoutCompatible(C, - cast(T1)->getDecl(), + return isLayoutCompatible(C, cast(T1)->getDecl(), cast(T2)->getDecl()); } @@ -17144,7 +17405,7 @@ static bool isLayoutCompatible(ASTContext &C, QualType T1, QualType T2) { static bool FindTypeTagExpr(const Expr *TypeExpr, const ASTContext &Ctx, const ValueDecl **VD, uint64_t *MagicValue, bool isConstantEvaluated) { - while(true) { + while (true) { if (!TypeExpr) return false; @@ -17256,8 +17517,7 @@ static bool GetMatchingCType( if (!MagicValues) return false; - llvm::DenseMap::const_iterator I = + llvm::DenseMap::const_iterator I = MagicValues->find(std::make_pair(ArgumentKind, MagicValue)); if (I == MagicValues->end()) return false; @@ -17268,8 +17528,7 @@ static bool GetMatchingCType( void Sema::RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind, uint64_t MagicValue, QualType Type, - bool LayoutCompatible, - bool MustBeNull) { + bool LayoutCompatible, bool MustBeNull) { if (!TypeTagForDatatypeMagicValues) TypeTagForDatatypeMagicValues.reset( new llvm::DenseMap); @@ -17291,8 +17550,8 @@ static bool IsSameCharType(QualType T1, QualType T2) { BuiltinType::Kind T1Kind = BT1->getKind(); BuiltinType::Kind T2Kind = BT2->getKind(); - return (T1Kind == BuiltinType::SChar && T2Kind == BuiltinType::Char_S) || - (T1Kind == BuiltinType::UChar && T2Kind == BuiltinType::Char_U) || + return (T1Kind == BuiltinType::SChar && T2Kind == BuiltinType::Char_S) || + (T1Kind == BuiltinType::UChar && T2Kind == BuiltinType::Char_U) || (T1Kind == BuiltinType::Char_U && T2Kind == BuiltinType::UChar) || (T1Kind == BuiltinType::Char_S && T2Kind == BuiltinType::SChar); } @@ -17319,7 +17578,7 @@ void Sema::CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr, if (FoundWrongKind) Diag(TypeTagExpr->getExprLoc(), diag::warn_type_tag_for_datatype_wrong_kind) - << TypeTagExpr->getSourceRange(); + << TypeTagExpr->getSourceRange(); return; } @@ -17346,12 +17605,11 @@ void Sema::CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr, if (TypeInfo.MustBeNull) { // Type tag with matching void type requires a null pointer. - if (!ArgumentExpr->isNullPointerConstant(Context, - Expr::NPC_ValueDependentIsNotNull)) { + if (!ArgumentExpr->isNullPointerConstant( + Context, Expr::NPC_ValueDependentIsNotNull)) { Diag(ArgumentExpr->getExprLoc(), diag::warn_type_safety_null_pointer_required) - << ArgumentKind->getName() - << ArgumentExpr->getSourceRange() + << ArgumentKind->getName() << ArgumentExpr->getSourceRange() << TypeTagExpr->getSourceRange(); } return; @@ -17375,19 +17633,16 @@ void Sema::CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr, RequiredType->getPointeeType())) || (!IsPointerAttr && IsSameCharType(ArgumentType, RequiredType))) mismatch = false; - } else - if (IsPointerAttr) - mismatch = !isLayoutCompatible(Context, - ArgumentType->getPointeeType(), - RequiredType->getPointeeType()); - else - mismatch = !isLayoutCompatible(Context, ArgumentType, RequiredType); + } else if (IsPointerAttr) + mismatch = !isLayoutCompatible(Context, ArgumentType->getPointeeType(), + RequiredType->getPointeeType()); + else + mismatch = !isLayoutCompatible(Context, ArgumentType, RequiredType); if (mismatch) Diag(ArgumentExpr->getExprLoc(), diag::warn_type_safety_type_mismatch) - << ArgumentType << ArgumentKind - << TypeInfo.LayoutCompatible << RequiredType - << ArgumentExpr->getSourceRange() + << ArgumentType << ArgumentKind << TypeInfo.LayoutCompatible + << RequiredType << ArgumentExpr->getSourceRange() << TypeTagExpr->getSourceRange(); } @@ -17480,7 +17735,7 @@ void Sema::RefersToMemberWithReducedAlignment( // For now, just disregard these cases. This is left for future // improvement. if (!DRE && !isa(TopBase)) - return; + return; // Alignment expected by the whole expression. CharUnits ExpectedAlignment = Context.getTypeAlignInChars(E->getType()); From f678e5237306c5110b0cb2e84b015794ea3e6f93 Mon Sep 17 00:00:00 2001 From: adeel10x Date: Thu, 14 Dec 2023 11:53:43 +0500 Subject: [PATCH 3/6] [RISCV][Clang]Fixed immediate operand range for the following intrinsics: - __builtin_riscv_cv_simd_extract_h - __builtin_riscv_cv_simd_extract_b - __builtin_riscv_cv_simd_extractu_h - __builtin_riscv_cv_simd_extractu_b - __builtin_riscv_cv_simd_insert_h - __builtin_riscv_cv_simd_insert_b --- clang/lib/Sema/SemaChecking.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 1c3297eab7c4..4fa78109021c 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -4657,13 +4657,15 @@ bool Sema::CheckRISCVCOREVBuiltinFunctionCall(unsigned BuiltinID, default: return false; case RISCVCOREV::BI__builtin_riscv_cv_simd_extract_h: - case RISCVCOREV::BI__builtin_riscv_cv_simd_extract_b: case RISCVCOREV::BI__builtin_riscv_cv_simd_extractu_h: + return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1); + case RISCVCOREV::BI__builtin_riscv_cv_simd_extract_b: case RISCVCOREV::BI__builtin_riscv_cv_simd_extractu_b: - return SemaBuiltinConstantArgRange(TheCall, 1, 0, 63); + return SemaBuiltinConstantArgRange(TheCall, 1, 0, 3); case RISCVCOREV::BI__builtin_riscv_cv_simd_insert_h: + return SemaBuiltinConstantArgRange(TheCall, 2, 0, 1); case RISCVCOREV::BI__builtin_riscv_cv_simd_insert_b: - return SemaBuiltinConstantArgRange(TheCall, 2, 0, 63); + return SemaBuiltinConstantArgRange(TheCall, 2, 0, 3); } } From 93b1c0a1eda0eaab81010fb60792ce51b69eef20 Mon Sep 17 00:00:00 2001 From: adeel10x Date: Mon, 18 Dec 2023 16:04:12 +0500 Subject: [PATCH 4/6] Revert "clang formatted" This reverts commit 1c372bceb0b4438492a3c95e72a31af23b261540. --- clang/include/clang/Sema/Sema.h | 2701 ++++++++++++++++++------------- clang/lib/Sema/SemaChecking.cpp | 2577 +++++++++++++---------------- 2 files changed, 2701 insertions(+), 2577 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 7ce661f288b4..750849c44cdc 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -73,168 +73,168 @@ #include namespace llvm { -class APSInt; -template class DenseSet; -class SmallBitVector; -struct InlineAsmIdentifierInfo; -} // namespace llvm + class APSInt; + template class DenseSet; + class SmallBitVector; + struct InlineAsmIdentifierInfo; +} namespace clang { -class ADLResult; -class ASTConsumer; -class ASTContext; -class ASTMutationListener; -class ASTReader; -class ASTWriter; -class ArrayType; -class ParsedAttr; -class BindingDecl; -class BlockDecl; -class CapturedDecl; -class CXXBasePath; -class CXXBasePaths; -class CXXBindTemporaryExpr; -typedef SmallVector CXXCastPath; -class CXXConstructorDecl; -class CXXConversionDecl; -class CXXDeleteExpr; -class CXXDestructorDecl; -class CXXFieldCollector; -class CXXMemberCallExpr; -class CXXMethodDecl; -class CXXScopeSpec; -class CXXTemporary; -class CXXTryStmt; -class CallExpr; -class ClassTemplateDecl; -class ClassTemplatePartialSpecializationDecl; -class ClassTemplateSpecializationDecl; -class VarTemplatePartialSpecializationDecl; -class CodeCompleteConsumer; -class CodeCompletionAllocator; -class CodeCompletionTUInfo; -class CodeCompletionResult; -class CoroutineBodyStmt; -class Decl; -class DeclAccessPair; -class DeclContext; -class DeclRefExpr; -class DeclaratorDecl; -class DeducedTemplateArgument; -class DependentDiagnostic; -class DesignatedInitExpr; -class Designation; -class EnableIfAttr; -class EnumConstantDecl; -class Expr; -class ExtVectorType; -class FormatAttr; -class FriendDecl; -class FunctionDecl; -class FunctionProtoType; -class FunctionTemplateDecl; -class ImplicitConversionSequence; -typedef MutableArrayRef ConversionSequenceList; -class InitListExpr; -class InitializationKind; -class InitializationSequence; -class InitializedEntity; -class IntegerLiteral; -class LabelStmt; -class LambdaExpr; -class LangOptions; -class LocalInstantiationScope; -class LookupResult; -class MacroInfo; -typedef ArrayRef> ModuleIdPath; -class ModuleLoader; -class MultiLevelTemplateArgumentList; -class NamedDecl; -class ObjCCategoryDecl; -class ObjCCategoryImplDecl; -class ObjCCompatibleAliasDecl; -class ObjCContainerDecl; -class ObjCImplDecl; -class ObjCImplementationDecl; -class ObjCInterfaceDecl; -class ObjCIvarDecl; -template class ObjCList; -class ObjCMessageExpr; -class ObjCMethodDecl; -class ObjCPropertyDecl; -class ObjCProtocolDecl; -class OMPThreadPrivateDecl; -class OMPRequiresDecl; -class OMPDeclareReductionDecl; -class OMPDeclareSimdDecl; -class OMPClause; -struct OMPVarListLocTy; -struct OverloadCandidate; -enum class OverloadCandidateParamOrder : char; -enum OverloadCandidateRewriteKind : unsigned; -class OverloadCandidateSet; -class OverloadExpr; -class ParenListExpr; -class ParmVarDecl; -class Preprocessor; -class PseudoDestructorTypeStorage; -class PseudoObjectExpr; -class QualType; -class StandardConversionSequence; -class Stmt; -class StringLiteral; -class SwitchStmt; -class TemplateArgument; -class TemplateArgumentList; -class TemplateArgumentLoc; -class TemplateDecl; -class TemplateInstantiationCallback; -class TemplateParameterList; -class TemplatePartialOrderingContext; -class TemplateTemplateParmDecl; -class Token; -class TypeAliasDecl; -class TypedefDecl; -class TypedefNameDecl; -class TypeLoc; -class TypoCorrectionConsumer; -class UnqualifiedId; -class UnresolvedLookupExpr; -class UnresolvedMemberExpr; -class UnresolvedSetImpl; -class UnresolvedSetIterator; -class UsingDecl; -class UsingShadowDecl; -class ValueDecl; -class VarDecl; -class VarTemplateSpecializationDecl; -class VisibilityAttr; -class VisibleDeclConsumer; -class IndirectFieldDecl; -struct DeductionFailureInfo; -class TemplateSpecCandidateSet; + class ADLResult; + class ASTConsumer; + class ASTContext; + class ASTMutationListener; + class ASTReader; + class ASTWriter; + class ArrayType; + class ParsedAttr; + class BindingDecl; + class BlockDecl; + class CapturedDecl; + class CXXBasePath; + class CXXBasePaths; + class CXXBindTemporaryExpr; + typedef SmallVector CXXCastPath; + class CXXConstructorDecl; + class CXXConversionDecl; + class CXXDeleteExpr; + class CXXDestructorDecl; + class CXXFieldCollector; + class CXXMemberCallExpr; + class CXXMethodDecl; + class CXXScopeSpec; + class CXXTemporary; + class CXXTryStmt; + class CallExpr; + class ClassTemplateDecl; + class ClassTemplatePartialSpecializationDecl; + class ClassTemplateSpecializationDecl; + class VarTemplatePartialSpecializationDecl; + class CodeCompleteConsumer; + class CodeCompletionAllocator; + class CodeCompletionTUInfo; + class CodeCompletionResult; + class CoroutineBodyStmt; + class Decl; + class DeclAccessPair; + class DeclContext; + class DeclRefExpr; + class DeclaratorDecl; + class DeducedTemplateArgument; + class DependentDiagnostic; + class DesignatedInitExpr; + class Designation; + class EnableIfAttr; + class EnumConstantDecl; + class Expr; + class ExtVectorType; + class FormatAttr; + class FriendDecl; + class FunctionDecl; + class FunctionProtoType; + class FunctionTemplateDecl; + class ImplicitConversionSequence; + typedef MutableArrayRef ConversionSequenceList; + class InitListExpr; + class InitializationKind; + class InitializationSequence; + class InitializedEntity; + class IntegerLiteral; + class LabelStmt; + class LambdaExpr; + class LangOptions; + class LocalInstantiationScope; + class LookupResult; + class MacroInfo; + typedef ArrayRef> ModuleIdPath; + class ModuleLoader; + class MultiLevelTemplateArgumentList; + class NamedDecl; + class ObjCCategoryDecl; + class ObjCCategoryImplDecl; + class ObjCCompatibleAliasDecl; + class ObjCContainerDecl; + class ObjCImplDecl; + class ObjCImplementationDecl; + class ObjCInterfaceDecl; + class ObjCIvarDecl; + template class ObjCList; + class ObjCMessageExpr; + class ObjCMethodDecl; + class ObjCPropertyDecl; + class ObjCProtocolDecl; + class OMPThreadPrivateDecl; + class OMPRequiresDecl; + class OMPDeclareReductionDecl; + class OMPDeclareSimdDecl; + class OMPClause; + struct OMPVarListLocTy; + struct OverloadCandidate; + enum class OverloadCandidateParamOrder : char; + enum OverloadCandidateRewriteKind : unsigned; + class OverloadCandidateSet; + class OverloadExpr; + class ParenListExpr; + class ParmVarDecl; + class Preprocessor; + class PseudoDestructorTypeStorage; + class PseudoObjectExpr; + class QualType; + class StandardConversionSequence; + class Stmt; + class StringLiteral; + class SwitchStmt; + class TemplateArgument; + class TemplateArgumentList; + class TemplateArgumentLoc; + class TemplateDecl; + class TemplateInstantiationCallback; + class TemplateParameterList; + class TemplatePartialOrderingContext; + class TemplateTemplateParmDecl; + class Token; + class TypeAliasDecl; + class TypedefDecl; + class TypedefNameDecl; + class TypeLoc; + class TypoCorrectionConsumer; + class UnqualifiedId; + class UnresolvedLookupExpr; + class UnresolvedMemberExpr; + class UnresolvedSetImpl; + class UnresolvedSetIterator; + class UsingDecl; + class UsingShadowDecl; + class ValueDecl; + class VarDecl; + class VarTemplateSpecializationDecl; + class VisibilityAttr; + class VisibleDeclConsumer; + class IndirectFieldDecl; + struct DeductionFailureInfo; + class TemplateSpecCandidateSet; namespace sema { -class AccessedEntity; -class BlockScopeInfo; -class Capture; -class CapturedRegionScopeInfo; -class CapturingScopeInfo; -class CompoundScopeInfo; -class DelayedDiagnostic; -class DelayedDiagnosticPool; -class FunctionScopeInfo; -class LambdaScopeInfo; -class PossiblyUnreachableDiag; -class RISCVIntrinsicManager; -class SemaPPCallbacks; -class TemplateDeductionInfo; -} // namespace sema + class AccessedEntity; + class BlockScopeInfo; + class Capture; + class CapturedRegionScopeInfo; + class CapturingScopeInfo; + class CompoundScopeInfo; + class DelayedDiagnostic; + class DelayedDiagnosticPool; + class FunctionScopeInfo; + class LambdaScopeInfo; + class PossiblyUnreachableDiag; + class RISCVIntrinsicManager; + class SemaPPCallbacks; + class TemplateDeductionInfo; +} namespace threadSafety { -class BeforeSet; -void threadSafetyCleanup(BeforeSet *Cache); -} // namespace threadSafety + class BeforeSet; + void threadSafetyCleanup(BeforeSet* Cache); +} // FIXME: No way to easily map from TemplateTypeParmTypes to // TemplateTypeParmDecls, so we have this horrible PointerUnion. @@ -359,7 +359,7 @@ class Sema final { Sema(const Sema &) = delete; void operator=(const Sema &) = delete; - /// Source of additional semantic information. + ///Source of additional semantic information. IntrusiveRefCntPtr ExternalSource; static bool mightHaveNonExternalLinkage(const DeclaratorDecl *FD); @@ -370,7 +370,7 @@ class Sema final { bool shouldLinkPossiblyHiddenDecl(const NamedDecl *Old, const NamedDecl *New) { if (isVisible(Old)) - return true; + return true; // See comment in below overload for why it's safe to compute the linkage // of the new declaration here. if (New->isExternallyDeclarable()) { @@ -435,7 +435,7 @@ class Sema final { MSPointerToMemberRepresentationMethod; /// Stack of active SEH __finally scopes. Can be empty. - SmallVector CurrentSEHFinally; + SmallVector CurrentSEHFinally; /// Source location for newly created implicit MSInheritanceAttrs SourceLocation ImplicitMSInheritanceAttrLoc; @@ -448,15 +448,18 @@ class Sema final { /// pragma clang section kind enum PragmaClangSectionKind { - PCSK_Invalid = 0, - PCSK_BSS = 1, - PCSK_Data = 2, - PCSK_Rodata = 3, - PCSK_Text = 4, - PCSK_Relro = 5 - }; + PCSK_Invalid = 0, + PCSK_BSS = 1, + PCSK_Data = 2, + PCSK_Rodata = 3, + PCSK_Text = 4, + PCSK_Relro = 5 + }; - enum PragmaClangSectionAction { PCSA_Set = 0, PCSA_Clear = 1 }; + enum PragmaClangSectionAction { + PCSA_Set = 0, + PCSA_Clear = 1 + }; struct PragmaClangSection { std::string SectionName; @@ -464,20 +467,20 @@ class Sema final { SourceLocation PragmaLocation; }; - PragmaClangSection PragmaClangBSSSection; - PragmaClangSection PragmaClangDataSection; - PragmaClangSection PragmaClangRodataSection; - PragmaClangSection PragmaClangRelroSection; - PragmaClangSection PragmaClangTextSection; + PragmaClangSection PragmaClangBSSSection; + PragmaClangSection PragmaClangDataSection; + PragmaClangSection PragmaClangRodataSection; + PragmaClangSection PragmaClangRelroSection; + PragmaClangSection PragmaClangTextSection; enum PragmaMsStackAction { - PSK_Reset = 0x0, // #pragma () - PSK_Set = 0x1, // #pragma (value) - PSK_Push = 0x2, // #pragma (push[, id]) - PSK_Pop = 0x4, // #pragma (pop[, id]) - PSK_Show = 0x8, // #pragma (show) -- only for "pack"! - PSK_Push_Set = PSK_Push | PSK_Set, // #pragma (push[, id], value) - PSK_Pop_Set = PSK_Pop | PSK_Set, // #pragma (pop[, id], value) + PSK_Reset = 0x0, // #pragma () + PSK_Set = 0x1, // #pragma (value) + PSK_Push = 0x2, // #pragma (push[, id]) + PSK_Pop = 0x4, // #pragma (pop[, id]) + PSK_Show = 0x8, // #pragma (show) -- only for "pack"! + PSK_Push_Set = PSK_Push | PSK_Set, // #pragma (push[, id], value) + PSK_Pop_Set = PSK_Pop | PSK_Set, // #pragma (pop[, id], value) }; // #pragma pack and align. @@ -582,7 +585,8 @@ class Sema final { static constexpr uint32_t PackNumMask{0x0000'01F0}; }; - template struct PragmaStack { + template + struct PragmaStack { struct Slot { llvm::StringRef StackSlotLabel; ValueType Value; @@ -798,7 +802,7 @@ class Sema final { /// context. unsigned FunctionScopesStart = 0; - ArrayRef getFunctionScopes() const { + ArrayRef getFunctionScopes() const { return llvm::makeArrayRef(FunctionScopes.begin() + FunctionScopesStart, FunctionScopes.end()); } @@ -822,7 +826,7 @@ class Sema final { typedef LazyVector - ExtVectorDeclsType; + ExtVectorDeclsType; /// ExtVectorDecls - This is a list all the extended vector types. This allows /// us to associate a raw vector type with one of the ext_vector type names. @@ -850,7 +854,7 @@ class Sema final { typedef llvm::SmallVector DeleteLocs; llvm::MapVector DeleteExprs; - typedef llvm::SmallPtrSet RecordDeclSetTy; + typedef llvm::SmallPtrSet RecordDeclSetTy; /// PureVirtualClassDiagSet - a set of class declarations which we have /// emitted a list of pure virtual functions. Used to prevent emitting the @@ -859,14 +863,14 @@ class Sema final { /// ParsingInitForAutoVars - a set of declarations with auto types for which /// we are currently parsing the initializer. - llvm::SmallPtrSet ParsingInitForAutoVars; + llvm::SmallPtrSet ParsingInitForAutoVars; /// Look for a locally scoped extern "C" declaration by the given name. NamedDecl *findLocallyScopedExternCDecl(DeclarationName Name); typedef LazyVector - TentativeDefinitionsType; + TentativeDefinitionsType; /// All the tentative definitions encountered in the TU. TentativeDefinitionsType TentativeDefinitions; @@ -876,7 +880,7 @@ class Sema final { typedef LazyVector - UnusedFileScopedDeclsType; + UnusedFileScopedDeclsType; /// The set of file scoped decls seen so far that have not been used /// and must warn if not used. Only contains the first declaration. @@ -884,7 +888,7 @@ class Sema final { typedef LazyVector - DelegatingCtorDeclsType; + DelegatingCtorDeclsType; /// All the delegating constructors seen so far in the file, used for /// cycle detection at the end of the TU. @@ -893,16 +897,16 @@ class Sema final { /// All the overriding functions seen during a class definition /// that had their exception spec checks delayed, plus the overridden /// function. - SmallVector, 2> - DelayedOverridingExceptionSpecChecks; + SmallVector, 2> + DelayedOverridingExceptionSpecChecks; /// All the function redeclarations seen during a class definition that had /// their exception spec checks delayed, plus the prior declaration they /// should be checked against. Except during error recovery, the new decl /// should always be a friend declaration, as that's the only valid way to /// redeclare a special member before its class is complete. - SmallVector, 2> - DelayedEquivalentExceptionSpecChecks; + SmallVector, 2> + DelayedEquivalentExceptionSpecChecks; typedef llvm::MapVector> @@ -917,7 +921,8 @@ class Sema final { void *OpaqueParser; void SetLateTemplateParser(LateTemplateParserCB *LTP, - LateTemplateParserCleanupCB *LTPCleanup, void *P) { + LateTemplateParserCleanupCB *LTPCleanup, + void *P) { LateTemplateParser = LTP; LateTemplateParserCleanup = LTPCleanup; OpaqueParser = P; @@ -949,7 +954,9 @@ class Sema final { bool shouldDelayDiagnostics() { return CurPool != nullptr; } /// Returns the current delayed-diagnostics pool. - sema::DelayedDiagnosticPool *getCurrentPool() const { return CurPool; } + sema::DelayedDiagnosticPool *getCurrentPool() const { + return CurPool; + } /// Enter a new scope. Access and deprecation diagnostics will be /// collected in this pool. @@ -995,11 +1002,12 @@ class Sema final { public: ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext = true) - : S(S), SavedContext(S.CurContext), - SavedContextState(S.DelayedDiagnostics.pushUndelayed()), - SavedCXXThisTypeOverride(S.CXXThisTypeOverride), - SavedFunctionScopesStart(S.FunctionScopesStart), - SavedInventedParameterInfosStart(S.InventedParameterInfosStart) { + : S(S), SavedContext(S.CurContext), + SavedContextState(S.DelayedDiagnostics.pushUndelayed()), + SavedCXXThisTypeOverride(S.CXXThisTypeOverride), + SavedFunctionScopesStart(S.FunctionScopesStart), + SavedInventedParameterInfosStart(S.InventedParameterInfosStart) + { assert(ContextToPush && "pushing null context"); S.CurContext = ContextToPush; if (NewThisContext) @@ -1010,8 +1018,7 @@ class Sema final { } void pop() { - if (!SavedContext) - return; + if (!SavedContext) return; S.CurContext = SavedContext; S.DelayedDiagnostics.popUndelayed(SavedContextState); S.CXXThisTypeOverride = SavedCXXThisTypeOverride; @@ -1020,7 +1027,9 @@ class Sema final { SavedContext = nullptr; } - ~ContextRAII() { pop(); } + ~ContextRAII() { + pop(); + } }; /// Whether the AST is currently being rebuilt to correct immediate @@ -1097,7 +1106,8 @@ class Sema final { /// \#pragma redefine_extname before declared. Used in Solaris system headers /// to define functions that occur in multiple standards to call the version /// in the currently selected standard. - llvm::DenseMap ExtnameUndeclaredIdentifiers; + llvm::DenseMap ExtnameUndeclaredIdentifiers; + /// Load weak undeclared identifiers from the external source. void LoadExternalWeakUndeclaredIdentifiers(); @@ -1107,7 +1117,7 @@ class Sema final { /// I couldn't figure out a clean way to generate these in-line, so /// we store them here and handle separately -- which is a hack. /// It would be best to refactor this. - SmallVector WeakTopLevelDecl; + SmallVector WeakTopLevelDecl; IdentifierResolver IdResolver; @@ -1300,11 +1310,10 @@ class Sema final { /// Expressions appearing as the LHS of a volatile assignment in this /// context. We produce a warning for these when popping the context if /// they are not discarded-value expressions nor unevaluated operands. - SmallVector VolatileAssignmentLHSs; + SmallVector VolatileAssignmentLHSs; /// Set of candidates for starting an immediate invocation. - llvm::SmallVector - ImmediateInvocationCandidates; + llvm::SmallVector ImmediateInvocationCandidates; /// Set of DeclRefExprs referencing a consteval function when used in a /// context not already known to be immediately invoked. @@ -1313,9 +1322,7 @@ class Sema final { /// \brief Describes whether we are in an expression constext which we have /// to handle differently. enum ExpressionKind { - EK_Decltype, - EK_TemplateArgument, - EK_Other + EK_Decltype, EK_TemplateArgument, EK_Other } ExprContext; // A context can be nested in both a discarded statement context and @@ -1381,6 +1388,7 @@ class Sema final { std::tuple getCurrentMangleNumberContext(const DeclContext *DC); + /// SpecialMemberOverloadResult - The overloading result for a special member /// function. /// @@ -1388,7 +1396,11 @@ class Sema final { /// integer are used to determine whether overload resolution succeeded. class SpecialMemberOverloadResult { public: - enum Kind { NoMemberOrDeleted, Ambiguous, Success }; + enum Kind { + NoMemberOrDeleted, + Ambiguous, + Success + }; private: llvm::PointerIntPair Pair; @@ -1405,11 +1417,13 @@ class Sema final { void setKind(Kind K) { Pair.setInt(K); } }; - class SpecialMemberOverloadResultEntry : public llvm::FastFoldingSetNode, - public SpecialMemberOverloadResult { + class SpecialMemberOverloadResultEntry + : public llvm::FastFoldingSetNode, + public SpecialMemberOverloadResult { public: SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID) - : FastFoldingSetNode(ID) {} + : FastFoldingSetNode(ID) + {} }; /// A cache of special member function overload resolution results @@ -1418,7 +1432,7 @@ class Sema final { /// A cache of the flags available in enumerations with the flag_bits /// attribute. - mutable llvm::DenseMap FlagBitsCache; + mutable llvm::DenseMap FlagBitsCache; /// The kind of translation unit we are processing. /// @@ -1435,7 +1449,7 @@ class Sema final { unsigned NumSFINAEErrors; typedef llvm::DenseMap> - UnparsedDefaultArgInstantiationsMap; + UnparsedDefaultArgInstantiationsMap; /// A mapping from parameters with unparsed default arguments to the /// set of instantiations of each parameter. @@ -1461,7 +1475,7 @@ class Sema final { /// Obtain a sorted list of functions that are undefined but ODR-used. void getUndefinedButUsed( - SmallVectorImpl> &Undefined); + SmallVectorImpl > &Undefined); /// Retrieves list of suspicious delete-expressions that will be checked at /// the end of translation unit. @@ -1570,7 +1584,7 @@ class Sema final { FPOptionsOverride getOverrides() { return OldOverrides; } private: - Sema &S; + Sema& S; FPOptions OldFPFeaturesState; FPOptionsOverride OldOverrides; LangOptions::FPEvalMethodKind OldEvalMethod; @@ -1615,7 +1629,7 @@ class Sema final { const LangOptions &getLangOpts() const { return LangOpts; } OpenCLOptions &getOpenCLOptions() { return OpenCLFeatures; } - FPOptions &getCurFPFeatures() { return CurFPFeatures; } + FPOptions &getCurFPFeatures() { return CurFPFeatures; } DiagnosticsEngine &getDiagnostics() const { return Diags; } SourceManager &getSourceManager() const { return SourceMgr; } @@ -1629,8 +1643,8 @@ class Sema final { StringRef Platform); DarwinSDKInfo *getDarwinSDKInfoForAvailabilityChecking(); - /// Registers an external source. If an external source already exists, - /// creates a multiplex external source and appends to it. + ///Registers an external source. If an external source already exists, + /// creates a multiplex external source and appends to it. /// ///\param[in] E - A non-null external sema source. /// @@ -1677,8 +1691,7 @@ class Sema final { ~ImmediateDiagBuilder() { // If we aren't active, there is nothing to do. - if (!isActive()) - return; + if (!isActive()) return; // Otherwise, we need to emit the diagnostic. First clear the diagnostic // builder itself so it won't emit the diagnostic in its own destructor. @@ -1869,8 +1882,8 @@ class Sema final { bool findMacroSpelling(SourceLocation &loc, StringRef name); /// Get a string to suggest for zero-initialization of a type. - std::string getFixItZeroInitializerForType(QualType T, - SourceLocation Loc) const; + std::string + getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const; std::string getFixItZeroLiteralForType(QualType T, SourceLocation Loc) const; /// Calls \c Lexer::getLocForEndOfToken() @@ -1886,12 +1899,12 @@ class Sema final { void emitAndClearUnusedLocalTypedefWarnings(); -private: - /// Function or variable declarations to be checked for whether the deferred - /// diagnostics should be emitted. - llvm::SmallSetVector DeclsToCheckForDeferredDiags; + private: + /// Function or variable declarations to be checked for whether the deferred + /// diagnostics should be emitted. + llvm::SmallSetVector DeclsToCheckForDeferredDiags; -public: + public: // Emit all deferred diagnostics. void emitDeferredDiags(); @@ -2011,13 +2024,13 @@ class Sema final { const DeclSpec *DS = nullptr); QualType BuildQualifiedType(QualType T, SourceLocation Loc, unsigned CVRA, const DeclSpec *DS = nullptr); - QualType BuildPointerType(QualType T, SourceLocation Loc, - DeclarationName Entity); - QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, - DeclarationName Entity); + QualType BuildPointerType(QualType T, + SourceLocation Loc, DeclarationName Entity); + QualType BuildReferenceType(QualType T, bool LValueRef, + SourceLocation Loc, DeclarationName Entity); QualType BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, - Expr *ArraySize, unsigned Quals, SourceRange Brackets, - DeclarationName Entity); + Expr *ArraySize, unsigned Quals, + SourceRange Brackets, DeclarationName Entity); QualType BuildVectorType(QualType T, Expr *VecSize, SourceLocation AttrLoc); QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc); @@ -2062,18 +2075,22 @@ class Sema final { /// \returns A suitable function type, if there are no errors. The /// unqualified type will always be a FunctionProtoType. /// Otherwise, returns a NULL type. - QualType BuildFunctionType(QualType T, MutableArrayRef ParamTypes, + QualType BuildFunctionType(QualType T, + MutableArrayRef ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI); QualType BuildMemberPointerType(QualType T, QualType Class, - SourceLocation Loc, DeclarationName Entity); - QualType BuildBlockPointerType(QualType T, SourceLocation Loc, - DeclarationName Entity); + SourceLocation Loc, + DeclarationName Entity); + QualType BuildBlockPointerType(QualType T, + SourceLocation Loc, DeclarationName Entity); QualType BuildParenType(QualType T); QualType BuildAtomicType(QualType T, SourceLocation Loc); - QualType BuildReadPipeType(QualType T, SourceLocation Loc); - QualType BuildWritePipeType(QualType T, SourceLocation Loc); + QualType BuildReadPipeType(QualType T, + SourceLocation Loc); + QualType BuildWritePipeType(QualType T, + SourceLocation Loc); QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc); TypeSourceInfo *GetTypeForDeclarator(Declarator &D, Scope *S); @@ -2097,22 +2114,22 @@ class Sema final { bool CheckSpecifiedExceptionType(QualType &T, SourceRange Range); bool CheckDistantExceptionSpec(QualType T); bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New); - bool CheckEquivalentExceptionSpec(const FunctionProtoType *Old, - SourceLocation OldLoc, - const FunctionProtoType *New, - SourceLocation NewLoc); - bool CheckEquivalentExceptionSpec(const PartialDiagnostic &DiagID, - const PartialDiagnostic &NoteID, - const FunctionProtoType *Old, - SourceLocation OldLoc, - const FunctionProtoType *New, - SourceLocation NewLoc); + bool CheckEquivalentExceptionSpec( + const FunctionProtoType *Old, SourceLocation OldLoc, + const FunctionProtoType *New, SourceLocation NewLoc); + bool CheckEquivalentExceptionSpec( + const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID, + const FunctionProtoType *Old, SourceLocation OldLoc, + const FunctionProtoType *New, SourceLocation NewLoc); bool handlerCanCatch(QualType HandlerType, QualType ExceptionType); - bool CheckExceptionSpecSubset( - const PartialDiagnostic &DiagID, const PartialDiagnostic &NestedDiagID, - const PartialDiagnostic &NoteID, const PartialDiagnostic &NoThrowDiagID, - const FunctionProtoType *Superset, SourceLocation SuperLoc, - const FunctionProtoType *Subset, SourceLocation SubLoc); + bool CheckExceptionSpecSubset(const PartialDiagnostic &DiagID, + const PartialDiagnostic &NestedDiagID, + const PartialDiagnostic &NoteID, + const PartialDiagnostic &NoThrowDiagID, + const FunctionProtoType *Superset, + SourceLocation SuperLoc, + const FunctionProtoType *Subset, + SourceLocation SubLoc); bool CheckParamExceptionSpec(const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID, const FunctionProtoType *Target, @@ -2137,7 +2154,7 @@ class Sema final { static int getPrintable(int I) { return I; } static unsigned getPrintable(unsigned I) { return I; } static bool getPrintable(bool B) { return B; } - static const char *getPrintable(const char *S) { return S; } + static const char * getPrintable(const char *S) { return S; } static StringRef getPrintable(StringRef S) { return S; } static const std::string &getPrintable(const std::string &S) { return S; } static const IdentifierInfo *getPrintable(const IdentifierInfo *II) { @@ -2148,7 +2165,7 @@ class Sema final { static SourceRange getPrintable(SourceRange R) { return R; } static SourceRange getPrintable(SourceLocation L) { return L; } static SourceRange getPrintable(const Expr *E) { return E->getSourceRange(); } - static SourceRange getPrintable(TypeLoc TL) { return TL.getSourceRange(); } + static SourceRange getPrintable(TypeLoc TL) { return TL.getSourceRange();} template class BoundTypeDiagnoser : public TypeDiagnoser { protected: @@ -2193,7 +2210,7 @@ class Sema final { template class SizelessTypeDiagnoser : public BoundTypeDiagnoser { public: - SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args) + SizelessTypeDiagnoser(unsigned DiagID, const Ts &... Args) : BoundTypeDiagnoser(DiagID, Args...) {} void diagnose(Sema &S, SourceLocation Loc, QualType T) override { @@ -2251,7 +2268,7 @@ class Sema final { llvm::SmallPtrSet DirectModuleImports; /// Namespace definitions that we will export when they finish. - llvm::SmallPtrSet DeferredExportedNamespaces; + llvm::SmallPtrSet DeferredExportedNamespaces; /// In a C++ standard module, inline declarations require a definition to be /// present at the end of a definition domain. This set holds the decls to @@ -2362,7 +2379,7 @@ class Sema final { bool OnlyNeedComplete = false); bool hasVisibleDefinition(const NamedDecl *D) { NamedDecl *Hidden; - return hasVisibleDefinition(const_cast(D), &Hidden); + return hasVisibleDefinition(const_cast(D), &Hidden); } /// Determine if \p D has a reachable definition. If not, suggest a @@ -2455,7 +2472,7 @@ class Sema final { template bool RequireCompleteSizedType(SourceLocation Loc, QualType T, unsigned DiagID, - const Ts &...Args) { + const Ts &... Args) { SizelessTypeDiagnoser Diagnoser(DiagID, Args...); return RequireCompleteType(Loc, T, CompleteTypeKind::Normal, Diagnoser); } @@ -2483,7 +2500,7 @@ class Sema final { template bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID, - const Ts &...Args) { + const Ts &... Args) { SizelessTypeDiagnoser Diagnoser(DiagID, Args...); return RequireCompleteExprType(E, CompleteTypeKind::Normal, Diagnoser); } @@ -2565,8 +2582,10 @@ class Sema final { IdentifierInfo **CorrectedII = nullptr); TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S); bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S); - void DiagnoseUnknownTypeName(IdentifierInfo *&II, SourceLocation IILoc, - Scope *S, CXXScopeSpec *SS, + void DiagnoseUnknownTypeName(IdentifierInfo *&II, + SourceLocation IILoc, + Scope *S, + CXXScopeSpec *SS, ParsedType &SuggestedType, bool IsTemplateName = false); @@ -2635,7 +2654,9 @@ class Sema final { NameClassification(const IdentifierInfo *Keyword) : Kind(NC_Keyword) {} - static NameClassification Error() { return NameClassification(NC_Error); } + static NameClassification Error() { + return NameClassification(NC_Error); + } static NameClassification Unknown() { return NameClassification(NC_Unknown); @@ -2819,8 +2840,8 @@ class Sema final { NamedDecl *HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists); - bool tryToFixVariablyModifiedVarType(TypeSourceInfo *&TInfo, QualType &T, - SourceLocation Loc, + bool tryToFixVariablyModifiedVarType(TypeSourceInfo *&TInfo, + QualType &T, SourceLocation Loc, unsigned FailedFoldDiagID); void RegisterLocallyScopedExternCDecl(NamedDecl *ND, Scope *S); bool DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo Info); @@ -2864,10 +2885,10 @@ class Sema final { void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec, TypedefNameDecl *NewTD); void CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *D); - NamedDecl *ActOnTypedefDeclarator(Scope *S, Declarator &D, DeclContext *DC, + NamedDecl* ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC, TypeSourceInfo *TInfo, LookupResult &Previous); - NamedDecl *ActOnTypedefNameDecl(Scope *S, DeclContext *DC, TypedefNameDecl *D, + NamedDecl* ActOnTypedefNameDecl(Scope* S, DeclContext* DC, TypedefNameDecl *D, LookupResult &Previous, bool &Redeclaration); NamedDecl *ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, @@ -2887,7 +2908,7 @@ class Sema final { void CheckCompleteDecompositionDeclaration(DecompositionDecl *DD); void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D); - NamedDecl *ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, + NamedDecl* ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, @@ -2906,15 +2927,13 @@ class Sema final { CheckConstexprKind Kind); void DiagnoseHiddenVirtualMethods(CXXMethodDecl *MD); - void - FindHiddenVirtualMethods(CXXMethodDecl *MD, - SmallVectorImpl &OverloadedMethods); - void - NoteHiddenVirtualMethods(CXXMethodDecl *MD, - SmallVectorImpl &OverloadedMethods); + void FindHiddenVirtualMethods(CXXMethodDecl *MD, + SmallVectorImpl &OverloadedMethods); + void NoteHiddenVirtualMethods(CXXMethodDecl *MD, + SmallVectorImpl &OverloadedMethods); // Returns true if the function declaration is a redeclaration - bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, - LookupResult &Previous, + bool CheckFunctionDeclaration(Scope *S, + FunctionDecl *NewFD, LookupResult &Previous, bool IsMemberSpecialization, bool DeclIsDefn); bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl); bool canFullyTypeCheckRedeclaration(ValueDecl *NewD, ValueDecl *OldD, @@ -2926,13 +2945,15 @@ class Sema final { bool IsDefinition); void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D); Decl *ActOnParamDeclarator(Scope *S, Declarator &D); - ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, + ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC, + SourceLocation Loc, QualType T); ParmVarDecl *CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC); - void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc, + void ActOnParamDefaultArgument(Decl *param, + SourceLocation EqualLoc, Expr *defarg); void ActOnParamUnparsedDefaultArgument(Decl *param, SourceLocation EqualLoc, SourceLocation ArgLoc); @@ -3035,7 +3056,9 @@ class Sema final { ExprResult ActOnFinishTrailingRequiresClause(ExprResult ConstraintExpr); ExprResult ActOnRequiresClause(ExprResult ConstraintExpr); void ActOnStartOfObjCMethodDef(Scope *S, Decl *D); - bool isObjCMethodDecl(Decl *D) { return D && isa(D); } + bool isObjCMethodDecl(Decl *D) { + return D && isa(D); + } /// Determine whether we can delay parsing the body of a function or /// function template until it is used, assuming we don't care about emitting @@ -3082,7 +3105,8 @@ class Sema final { QualType ReturnTy, NamedDecl *D); void DiagnoseInvalidJumps(Stmt *Body); - Decl *ActOnFileScopeAsmDecl(Expr *expr, SourceLocation AsmLoc, + Decl *ActOnFileScopeAsmDecl(Expr *expr, + SourceLocation AsmLoc, SourceLocation RParenLoc); /// Handle a C++11 empty-declaration and attribute-declaration. @@ -3220,7 +3244,8 @@ class Sema final { bool IsExplicitInstantiation, RecordDecl *&AnonRecord); - Decl *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS, + Decl *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, + AccessSpecifier AS, RecordDecl *Record, const PrintingPolicy &Policy); @@ -3245,8 +3270,9 @@ class Sema final { /// what kind of non-tag type this is. NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK); - bool isAcceptableTagRedeclaration(const TagDecl *Previous, TagTypeKind NewTag, - bool isDefinition, SourceLocation NewTagLoc, + bool isAcceptableTagRedeclaration(const TagDecl *Previous, + TagTypeKind NewTag, bool isDefinition, + SourceLocation NewTagLoc, const IdentifierInfo *Name); enum TagUseKind { @@ -3273,18 +3299,24 @@ class Sema final { const ParsedAttributesView &Attr, MultiTemplateParamsArg TempParamLists); - TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, - const CXXScopeSpec &SS, IdentifierInfo *Name, - SourceLocation TagLoc, SourceLocation NameLoc); + TypeResult ActOnDependentTag(Scope *S, + unsigned TagSpec, + TagUseKind TUK, + const CXXScopeSpec &SS, + IdentifierInfo *Name, + SourceLocation TagLoc, + SourceLocation NameLoc); void ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart, - IdentifierInfo *ClassName, SmallVectorImpl &Decls); + IdentifierInfo *ClassName, + SmallVectorImpl &Decls); Decl *ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth); FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, - InClassInitStyle InitStyle, AccessSpecifier AS); + InClassInitStyle InitStyle, + AccessSpecifier AS); MSPropertyDecl *HandleMSProperty(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, @@ -3293,11 +3325,13 @@ class Sema final { const ParsedAttr &MSPropertyAttr); FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T, - TypeSourceInfo *TInfo, RecordDecl *Record, - SourceLocation Loc, bool Mutable, - Expr *BitfieldWidth, InClassInitStyle InitStyle, - SourceLocation TSSL, AccessSpecifier AS, - NamedDecl *PrevDecl, Declarator *D = nullptr); + TypeSourceInfo *TInfo, + RecordDecl *Record, SourceLocation Loc, + bool Mutable, Expr *BitfieldWidth, + InClassInitStyle InitStyle, + SourceLocation TSSL, + AccessSpecifier AS, NamedDecl *PrevDecl, + Declarator *D = nullptr); bool CheckNontrivialField(FieldDecl *FD); void DiagnoseNontrivial(const CXXRecordDecl *Record, CXXSpecialMember CSM); @@ -3361,8 +3395,9 @@ class Sema final { void ActOnLastBitfield(SourceLocation DeclStart, SmallVectorImpl &AllIvarDecls); - Decl *ActOnIvar(Scope *S, SourceLocation DeclStart, Declarator &D, - Expr *BitfieldWidth, tok::ObjCKeywordKind visibility); + Decl *ActOnIvar(Scope *S, SourceLocation DeclStart, + Declarator &D, Expr *BitfieldWidth, + tok::ObjCKeywordKind visibility); // This is used for both record definitions and ObjC interface declarations. void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, @@ -3417,7 +3452,8 @@ class Sema final { EnumConstantDecl *CheckEnumConstant(EnumDecl *Enum, EnumConstantDecl *LastEnumConst, - SourceLocation IdLoc, IdentifierInfo *Id, + SourceLocation IdLoc, + IdentifierInfo *Id, Expr *val); bool CheckEnumUnderlyingType(TypeSourceInfo *TI); bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped, @@ -3446,13 +3482,13 @@ class Sema final { void EnterDeclaratorContext(Scope *S, DeclContext *DC); void ExitDeclaratorContext(Scope *S); - /// Enter a template parameter scope, after it's been associated with a - /// particular DeclContext. Causes lookup within the scope to chain through - /// enclosing contexts in the correct order. + /// Enter a template parameter scope, after it's been associated with a particular + /// DeclContext. Causes lookup within the scope to chain through enclosing contexts + /// in the correct order. void EnterTemplatedContext(Scope *S, DeclContext *DC); /// Push the parameters of D, which must be a function, into scope. - void ActOnReenterFunctionContext(Scope *S, Decl *D); + void ActOnReenterFunctionContext(Scope* S, Decl* D); void ActOnExitFunctionContext(); /// If \p AllowLambda is true, treat lambda as function. @@ -3581,10 +3617,10 @@ class Sema final { InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL); InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const InternalLinkageAttr &AL); - WebAssemblyImportNameAttr * - mergeImportNameAttr(Decl *D, const WebAssemblyImportNameAttr &AL); - WebAssemblyImportModuleAttr * - mergeImportModuleAttr(Decl *D, const WebAssemblyImportModuleAttr &AL); + WebAssemblyImportNameAttr *mergeImportNameAttr( + Decl *D, const WebAssemblyImportNameAttr &AL); + WebAssemblyImportModuleAttr *mergeImportModuleAttr( + Decl *D, const WebAssemblyImportModuleAttr &AL); EnforceTCBAttr *mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL); EnforceTCBLeafAttr *mergeEnforceTCBLeafAttr(Decl *D, const EnforceTCBLeafAttr &AL); @@ -3638,8 +3674,10 @@ class Sema final { /// non-function. Ovl_NonFunction }; - OverloadKind CheckOverload(Scope *S, FunctionDecl *New, - const LookupResult &OldDecls, NamedDecl *&OldDecl, + OverloadKind CheckOverload(Scope *S, + FunctionDecl *New, + const LookupResult &OldDecls, + NamedDecl *&OldDecl, bool IsForUsingDecl); bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl, bool ConsiderCudaAttrs = true, @@ -3681,39 +3719,45 @@ class Sema final { All }; - ImplicitConversionSequence TryImplicitConversion( - Expr *From, QualType ToType, bool SuppressUserConversions, - AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle, - bool AllowObjCWritebackConversion); + ImplicitConversionSequence + TryImplicitConversion(Expr *From, QualType ToType, + bool SuppressUserConversions, + AllowedExplicit AllowExplicit, + bool InOverloadResolution, + bool CStyle, + bool AllowObjCWritebackConversion); bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType); bool IsFloatingPointPromotion(QualType FromType, QualType ToType); bool IsComplexPromotion(QualType FromType, QualType ToType); bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType, - bool InOverloadResolution, QualType &ConvertedType, - bool &IncompatibleObjC); + bool InOverloadResolution, + QualType& ConvertedType, bool &IncompatibleObjC); bool isObjCPointerConversion(QualType FromType, QualType ToType, - QualType &ConvertedType, bool &IncompatibleObjC); + QualType& ConvertedType, bool &IncompatibleObjC); bool isObjCWritebackConversion(QualType FromType, QualType ToType, QualType &ConvertedType); bool IsBlockPointerConversion(QualType FromType, QualType ToType, - QualType &ConvertedType); + QualType& ConvertedType); bool FunctionParamTypesAreEqual(const FunctionProtoType *OldType, const FunctionProtoType *NewType, unsigned *ArgPos = nullptr, bool Reversed = false); - void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, - QualType ToType); + void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, + QualType FromType, QualType ToType); void maybeExtendBlockObject(ExprResult &E); CastKind PrepareCastToObjCObjectPointer(ExprResult &E); - bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind, - CXXCastPath &BasePath, bool IgnoreBaseAccess, + bool CheckPointerConversion(Expr *From, QualType ToType, + CastKind &Kind, + CXXCastPath& BasePath, + bool IgnoreBaseAccess, bool Diagnose = true); bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType, bool InOverloadResolution, QualType &ConvertedType); - bool CheckMemberPointerConversion(Expr *From, QualType ToType, CastKind &Kind, + bool CheckMemberPointerConversion(Expr *From, QualType ToType, + CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess); bool IsQualificationConversion(QualType FromType, QualType ToType, @@ -3731,7 +3775,8 @@ class Sema final { bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init); ExprResult PerformCopyInitialization(const InitializedEntity &Entity, - SourceLocation EqualLoc, ExprResult Init, + SourceLocation EqualLoc, + ExprResult Init, bool TopLevelOfInitList = false, bool AllowExplicit = false); ExprResult PerformObjectArgumentInitialization(Expr *From, @@ -3779,8 +3824,8 @@ class Sema final { /// Emits a diagnostic complaining that the expression does not have /// integral or enumeration type. - virtual SemaDiagnosticBuilder diagnoseNoMatch(Sema &S, SourceLocation Loc, - QualType T) = 0; + virtual SemaDiagnosticBuilder + diagnoseNoMatch(Sema &S, SourceLocation Loc, QualType T) = 0; /// Emits a diagnostic when the expression has incomplete class type. virtual SemaDiagnosticBuilder @@ -3788,10 +3833,8 @@ class Sema final { /// Emits a diagnostic when the only matching conversion function /// is explicit. - virtual SemaDiagnosticBuilder diagnoseExplicitConv(Sema &S, - SourceLocation Loc, - QualType T, - QualType ConvTy) = 0; + virtual SemaDiagnosticBuilder diagnoseExplicitConv( + Sema &S, SourceLocation Loc, QualType T, QualType ConvTy) = 0; /// Emits a note for the explicit conversion function. virtual SemaDiagnosticBuilder @@ -3799,8 +3842,8 @@ class Sema final { /// Emits a diagnostic when there are multiple possible conversion /// functions. - virtual SemaDiagnosticBuilder diagnoseAmbiguous(Sema &S, SourceLocation Loc, - QualType T) = 0; + virtual SemaDiagnosticBuilder + diagnoseAmbiguous(Sema &S, SourceLocation Loc, QualType T) = 0; /// Emits a note for one of the candidate conversions. virtual SemaDiagnosticBuilder @@ -3808,10 +3851,8 @@ class Sema final { /// Emits a diagnostic when we picked a conversion function /// (for cases when we are not allowed to pick a conversion function). - virtual SemaDiagnosticBuilder diagnoseConversion(Sema &S, - SourceLocation Loc, - QualType T, - QualType ConvTy) = 0; + virtual SemaDiagnosticBuilder diagnoseConversion( + Sema &S, SourceLocation Loc, QualType T, QualType ConvTy) = 0; virtual ~ContextualImplicitConverter() {} }; @@ -3820,31 +3861,35 @@ class Sema final { bool AllowScopedEnumerations; public: - ICEConvertDiagnoser(bool AllowScopedEnumerations, bool Suppress, - bool SuppressConversion) + ICEConvertDiagnoser(bool AllowScopedEnumerations, + bool Suppress, bool SuppressConversion) : ContextualImplicitConverter(Suppress, SuppressConversion), AllowScopedEnumerations(AllowScopedEnumerations) {} /// Match an integral or (possibly scoped) enumeration type. bool match(QualType T) override; - SemaDiagnosticBuilder diagnoseNoMatch(Sema &S, SourceLocation Loc, - QualType T) override { + SemaDiagnosticBuilder + diagnoseNoMatch(Sema &S, SourceLocation Loc, QualType T) override { return diagnoseNotInt(S, Loc, T); } /// Emits a diagnostic complaining that the expression does not have /// integral or enumeration type. - virtual SemaDiagnosticBuilder diagnoseNotInt(Sema &S, SourceLocation Loc, - QualType T) = 0; + virtual SemaDiagnosticBuilder + diagnoseNotInt(Sema &S, SourceLocation Loc, QualType T) = 0; }; /// Perform a contextual implicit conversion. - ExprResult - PerformContextualImplicitConversion(SourceLocation Loc, Expr *FromE, - ContextualImplicitConverter &Converter); + ExprResult PerformContextualImplicitConversion( + SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter); + - enum ObjCSubscriptKind { OS_Array, OS_Dictionary, OS_Error }; + enum ObjCSubscriptKind { + OS_Array, + OS_Dictionary, + OS_Error + }; ObjCSubscriptKind CheckSubscriptingKind(Expr *FromE); // Note that LK_String is intentionally after the other literals, as @@ -3867,7 +3912,7 @@ class Sema final { // Members have to be NamespaceDecl* or TranslationUnitDecl*. // TODO: make this is a typesafe union. - typedef llvm::SmallSetVector AssociatedNamespaceSet; + typedef llvm::SmallSetVector AssociatedNamespaceSet; typedef llvm::SmallSetVector AssociatedClassSet; using ADLCallKind = CallExpr::ADLCallKind; @@ -3882,34 +3927,41 @@ class Sema final { ADLCallKind IsADLCandidate = ADLCallKind::NotADL, ConversionSequenceList EarlyConversions = None, OverloadCandidateParamOrder PO = {}); - void AddFunctionCandidates( - const UnresolvedSetImpl &Functions, ArrayRef Args, - OverloadCandidateSet &CandidateSet, - TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr, - bool SuppressUserConversions = false, bool PartialOverloading = false, - bool FirstArgumentIsBase = false); - void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType, + void AddFunctionCandidates(const UnresolvedSetImpl &Functions, + ArrayRef Args, + OverloadCandidateSet &CandidateSet, + TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr, + bool SuppressUserConversions = false, + bool PartialOverloading = false, + bool FirstArgumentIsBase = false); + void AddMethodCandidate(DeclAccessPair FoundDecl, + QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef Args, - OverloadCandidateSet &CandidateSet, + OverloadCandidateSet& CandidateSet, bool SuppressUserConversion = false, OverloadCandidateParamOrder PO = {}); - void AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl, + void AddMethodCandidate(CXXMethodDecl *Method, + DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef Args, - OverloadCandidateSet &CandidateSet, + OverloadCandidateSet& CandidateSet, bool SuppressUserConversions = false, bool PartialOverloading = false, ConversionSequenceList EarlyConversions = None, OverloadCandidateParamOrder PO = {}); - void AddMethodTemplateCandidate( - FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl, - CXXRecordDecl *ActingContext, - TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType, - Expr::Classification ObjectClassification, ArrayRef Args, - OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false, - bool PartialOverloading = false, OverloadCandidateParamOrder PO = {}); + void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl, + DeclAccessPair FoundDecl, + CXXRecordDecl *ActingContext, + TemplateArgumentListInfo *ExplicitTemplateArgs, + QualType ObjectType, + Expr::Classification ObjectClassification, + ArrayRef Args, + OverloadCandidateSet& CandidateSet, + bool SuppressUserConversions = false, + bool PartialOverloading = false, + OverloadCandidateParamOrder PO = {}); void AddTemplateOverloadCandidate( FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef Args, @@ -3937,9 +3989,9 @@ class Sema final { void AddSurrogateCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, - const FunctionProtoType *Proto, Expr *Object, - ArrayRef Args, - OverloadCandidateSet &CandidateSet); + const FunctionProtoType *Proto, + Expr *Object, ArrayRef Args, + OverloadCandidateSet& CandidateSet); void AddNonMemberOperatorCandidates( const UnresolvedSetImpl &Functions, ArrayRef Args, OverloadCandidateSet &CandidateSet, @@ -3949,16 +4001,18 @@ class Sema final { OverloadCandidateSet &CandidateSet, OverloadCandidateParamOrder PO = {}); void AddBuiltinCandidate(QualType *ParamTys, ArrayRef Args, - OverloadCandidateSet &CandidateSet, + OverloadCandidateSet& CandidateSet, bool IsAssignmentOperator = false, unsigned NumContextualBoolArguments = 0); void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef Args, - OverloadCandidateSet &CandidateSet); - void AddArgumentDependentLookupCandidates( - DeclarationName Name, SourceLocation Loc, ArrayRef Args, - TemplateArgumentListInfo *ExplicitTemplateArgs, - OverloadCandidateSet &CandidateSet, bool PartialOverloading = false); + OverloadCandidateSet& CandidateSet); + void AddArgumentDependentLookupCandidates(DeclarationName Name, + SourceLocation Loc, + ArrayRef Args, + TemplateArgumentListInfo *ExplicitTemplateArgs, + OverloadCandidateSet& CandidateSet, + bool PartialOverloading = false); // Emit as a 'note' the specific overload candidate void NoteOverloadCandidate( @@ -4020,8 +4074,10 @@ class Sema final { QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType); FunctionDecl * - ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, - bool Complain, DeclAccessPair &Found, + ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, + QualType TargetType, + bool Complain, + DeclAccessPair &Found, bool *pHadMultipleCandidates = nullptr); FunctionDecl * @@ -4041,7 +4097,8 @@ class Sema final { QualType DestTypeForComplaining = QualType(), unsigned DiagIDForComplaining = 0); - Expr *FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, + Expr *FixOverloadedFunctionReference(Expr *E, + DeclAccessPair FoundDecl, FunctionDecl *Fn); ExprResult FixOverloadedFunctionReference(ExprResult, DeclAccessPair FoundDecl, @@ -4070,10 +4127,14 @@ class Sema final { OverloadCandidateSet *CandidateSet, Expr *Range, ExprResult *CallExpr); - ExprResult BuildOverloadedCallExpr( - Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, - MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig, - bool AllowTypoCorrection = true, bool CalleesAddressIsTaken = false); + ExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn, + UnresolvedLookupExpr *ULE, + SourceLocation LParenLoc, + MultiExprArg Args, + SourceLocation RParenLoc, + Expr *ExecConfig, + bool AllowTypoCorrection=true, + bool CalleesAddressIsTaken=false); bool buildOverloadedCallSet(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, MultiExprArg Args, SourceLocation RParenLoc, @@ -4088,16 +4149,18 @@ class Sema final { ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, - const UnresolvedSetImpl &Fns, Expr *input, - bool RequiresADL = true); + const UnresolvedSetImpl &Fns, + Expr *input, bool RequiresADL = true); void LookupOverloadedBinOp(OverloadCandidateSet &CandidateSet, OverloadedOperatorKind Op, const UnresolvedSetImpl &Fns, ArrayRef Args, bool RequiresADL = true); - ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, - const UnresolvedSetImpl &Fns, Expr *LHS, - Expr *RHS, bool RequiresADL = true, + ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, + BinaryOperatorKind Opc, + const UnresolvedSetImpl &Fns, + Expr *LHS, Expr *RHS, + bool RequiresADL = true, bool AllowRewrittenCandidates = true, FunctionDecl *DefaultedFn = nullptr); ExprResult BuildSynthesizedThreeWayComparison(SourceLocation OpLoc, @@ -4109,14 +4172,17 @@ class Sema final { SourceLocation RLoc, Expr *Base, MultiExprArg Args); - ExprResult BuildCallToMemberFunction( - Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, - SourceLocation RParenLoc, Expr *ExecConfig = nullptr, - bool IsExecConfig = false, bool AllowRecovery = false); - ExprResult BuildCallToObjectOfClassType(Scope *S, Expr *Object, - SourceLocation LParenLoc, - MultiExprArg Args, - SourceLocation RParenLoc); + ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, + SourceLocation LParenLoc, + MultiExprArg Args, + SourceLocation RParenLoc, + Expr *ExecConfig = nullptr, + bool IsExecConfig = false, + bool AllowRecovery = false); + ExprResult + BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc, + MultiExprArg Args, + SourceLocation RParenLoc); ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc, @@ -4236,7 +4302,7 @@ class Sema final { // the context has internal linkage, redeclaration lookup won't find things // from other TUs, and we can't safely compute linkage yet in general. if (cast(CurContext) - ->getOwningModuleForLinkage(/*IgnoreLinkage*/ true)) + ->getOwningModuleForLinkage(/*IgnoreLinkage*/true)) return ForVisibleRedeclaration; return ForExternalRedeclaration; } @@ -4263,10 +4329,13 @@ class Sema final { LOLR_StringTemplatePack, }; - SpecialMemberOverloadResult - LookupSpecialMember(CXXRecordDecl *D, CXXSpecialMember SM, bool ConstArg, - bool VolatileArg, bool RValueThis, bool ConstThis, - bool VolatileThis); + SpecialMemberOverloadResult LookupSpecialMember(CXXRecordDecl *D, + CXXSpecialMember SM, + bool ConstArg, + bool VolatileArg, + bool RValueThis, + bool ConstThis, + bool VolatileThis); typedef std::function TypoDiagnosticGenerator; typedef std::function @@ -4296,7 +4365,7 @@ class Sema final { // // The boolean value will be true to indicate that the namespace was loaded // from an AST/PCH file, or false otherwise. - llvm::MapVector KnownNamespaces; + llvm::MapVector KnownNamespaces; /// Whether we have already loaded known namespaces from an extenal /// source. @@ -4305,11 +4374,14 @@ class Sema final { /// Helper for CorrectTypo and CorrectTypoDelayed used to create and /// populate a new TypoCorrectionConsumer. Returns nullptr if typo correction /// should be skipped entirely. - std::unique_ptr makeTypoCorrectionConsumer( - const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, - Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, - DeclContext *MemberContext, bool EnteringContext, - const ObjCObjectPointerType *OPT, bool ErrorRecovery); + std::unique_ptr + makeTypoCorrectionConsumer(const DeclarationNameInfo &Typo, + Sema::LookupNameKind LookupKind, Scope *S, + CXXScopeSpec *SS, + CorrectionCandidateCallback &CCC, + DeclContext *MemberContext, bool EnteringContext, + const ObjCObjectPointerType *OPT, + bool ErrorRecovery); public: const TypoExprState &getTypoExprState(TypoExpr *TE) const; @@ -4323,8 +4395,10 @@ class Sema final { /// It is preferable to use the elaborated form and explicitly handle /// ambiguity and overloaded. NamedDecl *LookupSingleName(Scope *S, DeclarationName Name, - SourceLocation Loc, LookupNameKind NameKind, - RedeclarationKind Redecl = NotForRedeclaration); + SourceLocation Loc, + LookupNameKind NameKind, + RedeclarationKind Redecl + = NotForRedeclaration); bool LookupBuiltin(LookupResult &R); void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID); bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation = false, @@ -4336,9 +4410,9 @@ class Sema final { bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, bool AllowBuiltinCreation = false, bool EnteringContext = false); - ObjCProtocolDecl * - LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, - RedeclarationKind Redecl = NotForRedeclaration); + ObjCProtocolDecl *LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, + RedeclarationKind Redecl + = NotForRedeclaration); bool LookupInSuper(LookupResult &R, CXXRecordDecl *Class); void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, @@ -4401,20 +4475,24 @@ class Sema final { }; TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, - Sema::LookupNameKind LookupKind, Scope *S, - CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, + Sema::LookupNameKind LookupKind, + Scope *S, CXXScopeSpec *SS, + CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext = nullptr, bool EnteringContext = false, const ObjCObjectPointerType *OPT = nullptr, bool RecordFailure = true); - TypoExpr *CorrectTypoDelayed( - const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, - Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, - TypoDiagnosticGenerator TDG, TypoRecoveryCallback TRC, - CorrectTypoKind Mode, DeclContext *MemberContext = nullptr, - bool EnteringContext = false, const ObjCObjectPointerType *OPT = nullptr); + TypoExpr *CorrectTypoDelayed(const DeclarationNameInfo &Typo, + Sema::LookupNameKind LookupKind, Scope *S, + CXXScopeSpec *SS, + CorrectionCandidateCallback &CCC, + TypoDiagnosticGenerator TDG, + TypoRecoveryCallback TRC, CorrectTypoKind Mode, + DeclContext *MemberContext = nullptr, + bool EnteringContext = false, + const ObjCObjectPointerType *OPT = nullptr); /// Process any TypoExprs in the given Expr and its children, /// generating diagnostics as appropriate and returning a new Expr if there @@ -4461,10 +4539,10 @@ class Sema final { void MarkTypoCorrectedFunctionDefinition(const NamedDecl *F); - void FindAssociatedClassesAndNamespaces( - SourceLocation InstantiationLoc, ArrayRef Args, - AssociatedNamespaceSet &AssociatedNamespaces, - AssociatedClassSet &AssociatedClasses); + void FindAssociatedClassesAndNamespaces(SourceLocation InstantiationLoc, + ArrayRef Args, + AssociatedNamespaceSet &AssociatedNamespaces, + AssociatedClassSet &AssociatedClasses); void FilterLookupForScope(LookupResult &R, DeclContext *Ctx, Scope *S, bool ConsiderLinkage, bool AllowInlineNamespace); @@ -4472,7 +4550,8 @@ class Sema final { bool CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old); bool CheckRedeclarationExported(NamedDecl *New, NamedDecl *Old); bool CheckRedeclarationInModule(NamedDecl *New, NamedDecl *Old); - bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const; + bool IsRedefinitionInModule(const NamedDecl *New, + const NamedDecl *Old) const; void DiagnoseAmbiguousLookup(LookupResult &Result); //@} @@ -4487,8 +4566,9 @@ class Sema final { bool TypoCorrection = false); FunctionDecl *CreateBuiltin(IdentifierInfo *II, QualType Type, unsigned ID, SourceLocation Loc); - NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S, - bool ForRedeclaration, SourceLocation Loc); + NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, + Scope *S, bool ForRedeclaration, + SourceLocation Loc); NamedDecl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, Scope *S); void AddKnownFunctionAttributesForReplaceableGlobalAllocationFunction( @@ -4536,7 +4616,7 @@ class Sema final { const ProcessDeclAttributeOptions &Options = ProcessDeclAttributeOptions()); bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl, - const ParsedAttributesView &AttrList); + const ParsedAttributesView &AttrList); void checkUnusedDeclAttributes(Declarator &D); @@ -4573,9 +4653,9 @@ class Sema final { const StringLiteral *Literal, bool &HasDefault, bool &HasCommas, SmallVectorImpl &Strings); - bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, - bool BestCase, - MSInheritanceModel SemanticSpelling); + bool checkMSInheritanceAttrOnDefinition( + CXXRecordDecl *RD, SourceRange Range, bool BestCase, + MSInheritanceModel SemanticSpelling); void CheckAlignasUnderalignment(Decl *D); @@ -4604,12 +4684,13 @@ class Sema final { bool IsProtocolMethodDecl); void CheckConflictingOverridingMethod(ObjCMethodDecl *Method, - ObjCMethodDecl *Overridden, - bool IsProtocolMethodDecl); + ObjCMethodDecl *Overridden, + bool IsProtocolMethodDecl); /// WarnExactTypedMethods - This routine issues a warning if method /// implementation declaration matches exactly that of its declaration. - void WarnExactTypedMethods(ObjCMethodDecl *Method, ObjCMethodDecl *MethodDecl, + void WarnExactTypedMethods(ObjCMethodDecl *Method, + ObjCMethodDecl *MethodDecl, bool IsProtocolMethodDecl); typedef llvm::SmallPtrSet SelectorSet; @@ -4622,13 +4703,13 @@ class Sema final { /// ImplMethodsVsClassMethods - This is main routine to warn if any method /// remains unimplemented in the class or category \@implementation. - void ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl *IMPDecl, - ObjCContainerDecl *IDecl, + void ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl, + ObjCContainerDecl* IDecl, bool IncompleteImpl = false); /// DiagnoseUnimplementedProperties - This routine warns on those properties /// which must be implemented by this implementation. - void DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl *IMPDecl, + void DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl, ObjCContainerDecl *CDecl, bool SynthesizeProperties); @@ -4648,54 +4729,71 @@ class Sema final { bool IvarBacksCurrentMethodAccessor(ObjCInterfaceDecl *IFace, ObjCMethodDecl *Method, ObjCIvarDecl *IV); - /// DiagnoseUnusedBackingIvarInAccessor - Issue an 'unused' warning if ivar - /// which backs the property is not used in the property's accessor. + /// DiagnoseUnusedBackingIvarInAccessor - Issue an 'unused' warning if ivar which + /// backs the property is not used in the property's accessor. void DiagnoseUnusedBackingIvarInAccessor(Scope *S, const ObjCImplementationDecl *ImplD); /// GetIvarBackingPropertyAccessor - If method is a property setter/getter and - /// it property has a backing ivar, returns this ivar; otherwise, returns - /// NULL. It also returns ivar's property on success. - ObjCIvarDecl * - GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method, - const ObjCPropertyDecl *&PDecl) const; + /// it property has a backing ivar, returns this ivar; otherwise, returns NULL. + /// It also returns ivar's property on success. + ObjCIvarDecl *GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method, + const ObjCPropertyDecl *&PDecl) const; /// Called by ActOnProperty to handle \@property declarations in /// class extensions. - ObjCPropertyDecl *HandlePropertyInClassExtension( - Scope *S, SourceLocation AtLoc, SourceLocation LParenLoc, - FieldDeclarator &FD, Selector GetterSel, SourceLocation GetterNameLoc, - Selector SetterSel, SourceLocation SetterNameLoc, const bool isReadWrite, - unsigned &Attributes, const unsigned AttributesAsWritten, QualType T, - TypeSourceInfo *TSI, tok::ObjCKeywordKind MethodImplKind); + ObjCPropertyDecl *HandlePropertyInClassExtension(Scope *S, + SourceLocation AtLoc, + SourceLocation LParenLoc, + FieldDeclarator &FD, + Selector GetterSel, + SourceLocation GetterNameLoc, + Selector SetterSel, + SourceLocation SetterNameLoc, + const bool isReadWrite, + unsigned &Attributes, + const unsigned AttributesAsWritten, + QualType T, + TypeSourceInfo *TSI, + tok::ObjCKeywordKind MethodImplKind); /// Called by ActOnProperty and HandlePropertyInClassExtension to /// handle creating the ObjcPropertyDecl for a category or \@interface. - ObjCPropertyDecl * - CreatePropertyDecl(Scope *S, ObjCContainerDecl *CDecl, SourceLocation AtLoc, - SourceLocation LParenLoc, FieldDeclarator &FD, - Selector GetterSel, SourceLocation GetterNameLoc, - Selector SetterSel, SourceLocation SetterNameLoc, - const bool isReadWrite, const unsigned Attributes, - const unsigned AttributesAsWritten, QualType T, - TypeSourceInfo *TSI, tok::ObjCKeywordKind MethodImplKind, - DeclContext *lexicalDC = nullptr); + ObjCPropertyDecl *CreatePropertyDecl(Scope *S, + ObjCContainerDecl *CDecl, + SourceLocation AtLoc, + SourceLocation LParenLoc, + FieldDeclarator &FD, + Selector GetterSel, + SourceLocation GetterNameLoc, + Selector SetterSel, + SourceLocation SetterNameLoc, + const bool isReadWrite, + const unsigned Attributes, + const unsigned AttributesAsWritten, + QualType T, + TypeSourceInfo *TSI, + tok::ObjCKeywordKind MethodImplKind, + DeclContext *lexicalDC = nullptr); /// AtomicPropertySetterGetterRules - This routine enforces the rule (via /// warning) when atomic property has one but not the other user-declared /// setter or getter. - void AtomicPropertySetterGetterRules(ObjCImplDecl *IMPDecl, - ObjCInterfaceDecl *IDecl); + void AtomicPropertySetterGetterRules(ObjCImplDecl* IMPDecl, + ObjCInterfaceDecl* IDecl); void DiagnoseOwningPropertyGetterSynthesis(const ObjCImplementationDecl *D); - void - DiagnoseMissingDesignatedInitOverrides(const ObjCImplementationDecl *ImplD, - const ObjCInterfaceDecl *IFD); + void DiagnoseMissingDesignatedInitOverrides( + const ObjCImplementationDecl *ImplD, + const ObjCInterfaceDecl *IFD); void DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, ObjCInterfaceDecl *SID); - enum MethodMatchStrategy { MMS_loose, MMS_strict }; + enum MethodMatchStrategy { + MMS_loose, + MMS_strict + }; /// MatchTwoMethodDeclarations - Checks if two methods' type match and returns /// true, or false, accordingly. @@ -4705,11 +4803,15 @@ class Sema final { /// MatchAllMethodDeclarations - Check methods declaraed in interface or /// or protocol against those declared in their implementations. - void MatchAllMethodDeclarations( - const SelectorSet &InsMap, const SelectorSet &ClsMap, - SelectorSet &InsMapSeen, SelectorSet &ClsMapSeen, ObjCImplDecl *IMPDecl, - ObjCContainerDecl *IDecl, bool &IncompleteImpl, bool ImmediateClass, - bool WarnCategoryMethodImpl = false); + void MatchAllMethodDeclarations(const SelectorSet &InsMap, + const SelectorSet &ClsMap, + SelectorSet &InsMapSeen, + SelectorSet &ClsMapSeen, + ObjCImplDecl* IMPDecl, + ObjCContainerDecl* IDecl, + bool &IncompleteImpl, + bool ImmediateClass, + bool WarnCategoryMethodImpl=false); /// CheckCategoryVsClassMethodMatches - Checks that methods implemented in /// category matches with those implemented in its primary class and @@ -4741,17 +4843,17 @@ class Sema final { /// returns true. bool CollectMultipleMethodsInGlobalPool(Selector Sel, - SmallVectorImpl &Methods, + SmallVectorImpl& Methods, bool InstanceFirst, bool CheckTheOther, const ObjCObjectType *TypeBound = nullptr); bool AreMultipleMethodsInGlobalPool(Selector Sel, ObjCMethodDecl *BestMethod, SourceRange R, bool receiverIdOrClass, - SmallVectorImpl &Methods); + SmallVectorImpl& Methods); void - DiagnoseMultipleMethodInGlobalPool(SmallVectorImpl &Methods, + DiagnoseMultipleMethodInGlobalPool(SmallVectorImpl &Methods, Selector Sel, SourceRange R, bool receiverIdOrClass); @@ -4760,7 +4862,8 @@ class Sema final { /// nullptr if none could be found ObjCMethodDecl *SelectBestMethod(Selector Sel, MultiExprArg Args, bool IsInstance, - SmallVectorImpl &Methods); + SmallVectorImpl& Methods); + /// Record the typo correction failure and return an empty correction. TypoCorrection FailedCorrection(IdentifierInfo *Typo, SourceLocation TypoLoc, @@ -4775,14 +4878,13 @@ class Sema final { /// unit are added to a global pool. This allows us to efficiently associate /// a selector with a method declaraation for purposes of typechecking /// messages sent to "id" (where the class of the object is unknown). - void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, - bool impl = false) { - AddMethodToGlobalPool(Method, impl, /*instance*/ true); + void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false) { + AddMethodToGlobalPool(Method, impl, /*instance*/true); } /// AddFactoryMethodToGlobalPool - Same as above, but for factory methods. - void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl = false) { - AddMethodToGlobalPool(Method, impl, /*instance*/ false); + void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false) { + AddMethodToGlobalPool(Method, impl, /*instance*/false); } /// AddAnyMethodToGlobalPool - Add any method, instance or factory to global @@ -4791,47 +4893,48 @@ class Sema final { /// LookupInstanceMethodInGlobalPool - Returns the method and warns if /// there are multiple signatures. - ObjCMethodDecl * - LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R, - bool receiverIdOrClass = false) { + ObjCMethodDecl *LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R, + bool receiverIdOrClass=false) { return LookupMethodInGlobalPool(Sel, R, receiverIdOrClass, - /*instance*/ true); + /*instance*/true); } /// LookupFactoryMethodInGlobalPool - Returns the method and warns if /// there are multiple signatures. - ObjCMethodDecl * - LookupFactoryMethodInGlobalPool(Selector Sel, SourceRange R, - bool receiverIdOrClass = false) { + ObjCMethodDecl *LookupFactoryMethodInGlobalPool(Selector Sel, SourceRange R, + bool receiverIdOrClass=false) { return LookupMethodInGlobalPool(Sel, R, receiverIdOrClass, - /*instance*/ false); + /*instance*/false); } - const ObjCMethodDecl * - SelectorsForTypoCorrection(Selector Sel, QualType ObjectType = QualType()); + const ObjCMethodDecl *SelectorsForTypoCorrection(Selector Sel, + QualType ObjectType=QualType()); /// LookupImplementedMethodInGlobalPool - Returns the method which has an /// implementation. ObjCMethodDecl *LookupImplementedMethodInGlobalPool(Selector Sel); /// CollectIvarsToConstructOrDestruct - Collect those ivars which require /// initialization. - void - CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI, - SmallVectorImpl &Ivars); + void CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI, + SmallVectorImpl &Ivars); //===--------------------------------------------------------------------===// // Statement Parsing Callbacks: SemaStmt.cpp. public: class FullExprArg { public: - FullExprArg() : E(nullptr) {} - FullExprArg(Sema &actions) : E(nullptr) {} + FullExprArg() : E(nullptr) { } + FullExprArg(Sema &actions) : E(nullptr) { } - ExprResult release() { return E; } + ExprResult release() { + return E; + } Expr *get() const { return E; } - Expr *operator->() { return E; } + Expr *operator->() { + return E; + } private: // FIXME: No need to make the entire Sema class a friend when it's just @@ -4876,7 +4979,9 @@ class Sema final { S.ActOnStartOfCompoundStmt(IsStmtExpr); } - ~CompoundScopeRAII() { S.ActOnFinishOfCompoundStmt(); } + ~CompoundScopeRAII() { + S.ActOnFinishOfCompoundStmt(); + } private: Sema &S; @@ -4894,8 +4999,9 @@ class Sema final { void disable() { Active = false; } }; - StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, - SourceLocation EndLoc); + StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, + SourceLocation StartLoc, + SourceLocation EndLoc); void ActOnForEachDeclStmt(DeclGroupPtrTy Decl); StmtResult ActOnForEachLValueExpr(Expr *E); ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val); @@ -4905,8 +5011,8 @@ class Sema final { void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt); StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, - SourceLocation ColonLoc, Stmt *SubStmt, - Scope *CurScope); + SourceLocation ColonLoc, + Stmt *SubStmt, Scope *CurScope); StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt); @@ -4929,8 +5035,8 @@ class Sema final { SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc); - StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, - Stmt *Body); + StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, + Stmt *Switch, Stmt *Body); StmtResult ActOnWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body); @@ -4938,14 +5044,17 @@ class Sema final { SourceLocation WhileLoc, SourceLocation CondLParen, Expr *Cond, SourceLocation CondRParen); - StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, - Stmt *First, ConditionResult Second, - FullExprArg Third, SourceLocation RParenLoc, + StmtResult ActOnForStmt(SourceLocation ForLoc, + SourceLocation LParenLoc, + Stmt *First, + ConditionResult Second, + FullExprArg Third, + SourceLocation RParenLoc, Stmt *Body); ExprResult CheckObjCForCollectionOperand(SourceLocation forLoc, Expr *collection); - StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, Stmt *First, - Expr *collection, + StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, + Stmt *First, Expr *collection, SourceLocation RParenLoc); StmtResult FinishObjCForCollectionStmt(Stmt *ForCollection, Stmt *Body); @@ -4961,22 +5070,29 @@ class Sema final { }; StmtResult ActOnCXXForRangeStmt(Scope *S, SourceLocation ForLoc, - SourceLocation CoawaitLoc, Stmt *InitStmt, - Stmt *LoopVar, SourceLocation ColonLoc, - Expr *Collection, SourceLocation RParenLoc, + SourceLocation CoawaitLoc, + Stmt *InitStmt, + Stmt *LoopVar, + SourceLocation ColonLoc, Expr *Collection, + SourceLocation RParenLoc, BuildForRangeKind Kind); StmtResult BuildCXXForRangeStmt(SourceLocation ForLoc, - SourceLocation CoawaitLoc, Stmt *InitStmt, - SourceLocation ColonLoc, Stmt *RangeDecl, - Stmt *Begin, Stmt *End, Expr *Cond, Expr *Inc, - Stmt *LoopVarDecl, SourceLocation RParenLoc, + SourceLocation CoawaitLoc, + Stmt *InitStmt, + SourceLocation ColonLoc, + Stmt *RangeDecl, Stmt *Begin, Stmt *End, + Expr *Cond, Expr *Inc, + Stmt *LoopVarDecl, + SourceLocation RParenLoc, BuildForRangeKind Kind); StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body); - StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, + StmtResult ActOnGotoStmt(SourceLocation GotoLoc, + SourceLocation LabelLoc, LabelDecl *TheDecl); StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, - SourceLocation StarLoc, Expr *DestExp); + SourceLocation StarLoc, + Expr *DestExp); StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope); StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope); @@ -5027,7 +5143,8 @@ class Sema final { unsigned NumInputs, IdentifierInfo **Names, MultiExprArg Constraints, MultiExprArg Exprs, Expr *AsmString, MultiExprArg Clobbers, - unsigned NumLabels, SourceLocation RParenLoc); + unsigned NumLabels, + SourceLocation RParenLoc); void FillInlineAsmIdentifierInfo(Expr *Res, llvm::InlineAsmIdentifierInfo &Info); @@ -5035,22 +5152,26 @@ class Sema final { SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool IsUnevaluatedContext); - bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset, - SourceLocation AsmLoc); + bool LookupInlineAsmField(StringRef Base, StringRef Member, + unsigned &Offset, SourceLocation AsmLoc); ExprResult LookupInlineAsmVarDeclField(Expr *RefExpr, StringRef Member, SourceLocation AsmLoc); StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, - ArrayRef AsmToks, StringRef AsmString, + ArrayRef AsmToks, + StringRef AsmString, unsigned NumOutputs, unsigned NumInputs, ArrayRef Constraints, ArrayRef Clobbers, - ArrayRef Exprs, SourceLocation EndLoc); + ArrayRef Exprs, + SourceLocation EndLoc); LabelDecl *GetOrCreateMSAsmLabel(StringRef ExternalLabelName, - SourceLocation Location, bool AlwaysCreate); + SourceLocation Location, + bool AlwaysCreate); VarDecl *BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType, - SourceLocation StartLoc, SourceLocation IdLoc, - IdentifierInfo *Id, bool Invalid = false); + SourceLocation StartLoc, + SourceLocation IdLoc, IdentifierInfo *Id, + bool Invalid = false); Decl *ActOnObjCExceptionDecl(Scope *S, Declarator &D); @@ -5067,26 +5188,29 @@ class Sema final { Scope *CurScope); ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand); - StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SynchExpr, + StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, + Expr *SynchExpr, Stmt *SynchBody); StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body); VarDecl *BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo, SourceLocation StartLoc, - SourceLocation IdLoc, IdentifierInfo *Id); + SourceLocation IdLoc, + IdentifierInfo *Id); Decl *ActOnExceptionDeclarator(Scope *S, Declarator &D); - StmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc, Decl *ExDecl, - Stmt *HandlerBlock); + StmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc, + Decl *ExDecl, Stmt *HandlerBlock); StmtResult ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock, ArrayRef Handlers); StmtResult ActOnSEHTryBlock(bool IsCXXTry, // try (true) or __try (false) ? SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler); - StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, + StmtResult ActOnSEHExceptBlock(SourceLocation Loc, + Expr *FilterExpr, Stmt *Block); void ActOnStartSEHFinallyBlock(); void ActOnAbortSEHFinallyBlock(); @@ -5123,12 +5247,14 @@ class Sema final { /// This helps prevent bugs due to typos, such as: /// if (condition); /// do_stuff(); - void DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body, + void DiagnoseEmptyStmtBody(SourceLocation StmtLoc, + const Stmt *Body, unsigned DiagID); /// Warn if a for/while loop statement \p S, which is followed by /// \p PossibleBody, has a suspicious null statement as a body. - void DiagnoseEmptyLoopBody(const Stmt *S, const Stmt *PossibleBody); + void DiagnoseEmptyLoopBody(const Stmt *S, + const Stmt *PossibleBody); /// Warn if a value is moved to itself. void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr, @@ -5254,9 +5380,7 @@ class Sema final { void CleanupVarDeclMarking(); enum TryCaptureKind { - TryCapture_Implicit, - TryCapture_ExplicitByVal, - TryCapture_ExplicitByRef + TryCapture_Implicit, TryCapture_ExplicitByVal, TryCapture_ExplicitByRef }; /// Try to capture the given variable. @@ -5354,18 +5478,17 @@ class Sema final { const PartialDiagnostic &PD); /// Similar, but diagnostic is only produced if all the specified statements /// are reachable. - bool DiagRuntimeBehavior(SourceLocation Loc, ArrayRef Stmts, + bool DiagRuntimeBehavior(SourceLocation Loc, ArrayRef Stmts, const PartialDiagnostic &PD); // Primary Expressions. SourceRange getExprRange(Expr *E) const; - ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, - SourceLocation TemplateKWLoc, UnqualifiedId &Id, - bool HasTrailingLParen, bool IsAddressOfOperand, - CorrectionCandidateCallback *CCC = nullptr, - bool IsInlineAsmIdentifier = false, - Token *KeywordReplacement = nullptr); + ExprResult ActOnIdExpression( + Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, + UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, + CorrectionCandidateCallback *CCC = nullptr, + bool IsInlineAsmIdentifier = false, Token *KeywordReplacement = nullptr); void DecomposeUnqualifiedId(const UnqualifiedId &Id, TemplateArgumentListInfo &Buffer, @@ -5386,12 +5509,13 @@ class Sema final { ExprResult LookupInObjCMethod(LookupResult &LookUp, Scope *S, IdentifierInfo *II, - bool AllowBuiltinCreation = false); + bool AllowBuiltinCreation=false); - ExprResult ActOnDependentIdExpression( - const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, - const DeclarationNameInfo &NameInfo, bool isAddressOfOperand, - const TemplateArgumentListInfo *TemplateArgs); + ExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS, + SourceLocation TemplateKWLoc, + const DeclarationNameInfo &NameInfo, + bool isAddressOfOperand, + const TemplateArgumentListInfo *TemplateArgs); /// If \p D cannot be odr-used in the current expression evaluation context, /// return a reason explaining why. Otherwise, return NOUR_None. @@ -5410,26 +5534,32 @@ class Sema final { DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, const DeclarationNameInfo &NameInfo, - NestedNameSpecifierLoc NNS, NamedDecl *FoundD = nullptr, + NestedNameSpecifierLoc NNS, + NamedDecl *FoundD = nullptr, SourceLocation TemplateKWLoc = SourceLocation(), const TemplateArgumentListInfo *TemplateArgs = nullptr); - ExprResult BuildAnonymousStructUnionMemberReference( - const CXXScopeSpec &SS, SourceLocation nameLoc, + ExprResult + BuildAnonymousStructUnionMemberReference( + const CXXScopeSpec &SS, + SourceLocation nameLoc, IndirectFieldDecl *indirectField, DeclAccessPair FoundDecl = DeclAccessPair::make(nullptr, AS_none), - Expr *baseObjectExpr = nullptr, SourceLocation opLoc = SourceLocation()); + Expr *baseObjectExpr = nullptr, + SourceLocation opLoc = SourceLocation()); ExprResult BuildPossibleImplicitMemberExpr( const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, UnresolvedLookupExpr *AsULE = nullptr); - ExprResult - BuildImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, - LookupResult &R, - const TemplateArgumentListInfo *TemplateArgs, - bool IsDefiniteInstance, const Scope *S); - bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R, + ExprResult BuildImplicitMemberExpr(const CXXScopeSpec &SS, + SourceLocation TemplateKWLoc, + LookupResult &R, + const TemplateArgumentListInfo *TemplateArgs, + bool IsDefiniteInstance, + const Scope *S); + bool UseArgumentDependentLookup(const CXXScopeSpec &SS, + const LookupResult &R, bool HasTrailingLParen); ExprResult @@ -5438,13 +5568,13 @@ class Sema final { bool IsAddressOfOperand, const Scope *S, TypeSourceInfo **RecoveryTSI = nullptr); - ExprResult - BuildDependentDeclRefExpr(const CXXScopeSpec &SS, - SourceLocation TemplateKWLoc, - const DeclarationNameInfo &NameInfo, - const TemplateArgumentListInfo *TemplateArgs); + ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS, + SourceLocation TemplateKWLoc, + const DeclarationNameInfo &NameInfo, + const TemplateArgumentListInfo *TemplateArgs); - ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, + ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, + LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl = false); ExprResult BuildDeclarationNameExpr( @@ -5453,10 +5583,11 @@ class Sema final { const TemplateArgumentListInfo *TemplateArgs = nullptr, bool AcceptInvalidDecl = false); - ExprResult BuildLiteralOperatorCall( - LookupResult &R, DeclarationNameInfo &SuffixInfo, ArrayRef Args, - SourceLocation LitEndLoc, - TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr); + ExprResult BuildLiteralOperatorCall(LookupResult &R, + DeclarationNameInfo &SuffixInfo, + ArrayRef Args, + SourceLocation LitEndLoc, + TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr); ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedExpr::IdentKind IK); @@ -5478,7 +5609,8 @@ class Sema final { ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope = nullptr); ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E); - ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, + ExprResult ActOnParenListExpr(SourceLocation L, + SourceLocation R, MultiExprArg Val); /// ActOnStringLiteral - The specified tokens were lexed as pasted string @@ -5518,10 +5650,11 @@ class Sema final { SourceRange R); ExprResult CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind); - ExprResult ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc, - UnaryExprOrTypeTrait ExprKind, - bool IsType, void *TyOrEx, - SourceRange ArgRange); + ExprResult + ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc, + UnaryExprOrTypeTrait ExprKind, + bool IsType, void *TyOrEx, + SourceRange ArgRange); ExprResult CheckPlaceholderExpr(Expr *E); bool CheckVecStepExpr(Expr *E); @@ -5530,7 +5663,8 @@ class Sema final { bool CheckUnaryExprOrTypeTraitOperand(QualType ExprType, SourceLocation OpLoc, SourceRange ExprRange, UnaryExprOrTypeTrait ExprKind); - ExprResult ActOnSizeofParameterPackExpr(Scope *S, SourceLocation OpLoc, + ExprResult ActOnSizeofParameterPackExpr(Scope *S, + SourceLocation OpLoc, IdentifierInfo &Name, SourceLocation NameLoc, SourceLocation RParenLoc); @@ -5588,7 +5722,8 @@ class Sema final { Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, - const TemplateArgumentListInfo *TemplateArgs, const Scope *S, + const TemplateArgumentListInfo *TemplateArgs, + const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs = nullptr); ExprResult @@ -5597,7 +5732,8 @@ class Sema final { SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, - const Scope *S, bool SuppressQualifierCheck = false, + const Scope *S, + bool SuppressQualifierCheck = false, ActOnMemberAccessExtraArgs *ExtraArgs = nullptr); ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow, @@ -5612,23 +5748,30 @@ class Sema final { const CXXScopeSpec &SS, const LookupResult &R); - ExprResult ActOnDependentMemberExpr( - Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OpLoc, - const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, - NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, - const TemplateArgumentListInfo *TemplateArgs); + ExprResult ActOnDependentMemberExpr(Expr *Base, QualType BaseType, + bool IsArrow, SourceLocation OpLoc, + const CXXScopeSpec &SS, + SourceLocation TemplateKWLoc, + NamedDecl *FirstQualifierInScope, + const DeclarationNameInfo &NameInfo, + const TemplateArgumentListInfo *TemplateArgs); - ExprResult ActOnMemberAccessExpr(Scope *S, Expr *Base, SourceLocation OpLoc, - tok::TokenKind OpKind, CXXScopeSpec &SS, + ExprResult ActOnMemberAccessExpr(Scope *S, Expr *Base, + SourceLocation OpLoc, + tok::TokenKind OpKind, + CXXScopeSpec &SS, SourceLocation TemplateKWLoc, - UnqualifiedId &Member, Decl *ObjCImpDecl); - - MemberExpr *BuildMemberExpr( - Expr *Base, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec *SS, - SourceLocation TemplateKWLoc, ValueDecl *Member, DeclAccessPair FoundDecl, - bool HadMultipleCandidates, const DeclarationNameInfo &MemberNameInfo, - QualType Ty, ExprValueKind VK, ExprObjectKind OK, - const TemplateArgumentListInfo *TemplateArgs = nullptr); + UnqualifiedId &Member, + Decl *ObjCImpDecl); + + MemberExpr * + BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc, + const CXXScopeSpec *SS, SourceLocation TemplateKWLoc, + ValueDecl *Member, DeclAccessPair FoundDecl, + bool HadMultipleCandidates, + const DeclarationNameInfo &MemberNameInfo, QualType Ty, + ExprValueKind VK, ExprObjectKind OK, + const TemplateArgumentListInfo *TemplateArgs = nullptr); MemberExpr * BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, @@ -5639,11 +5782,14 @@ class Sema final { const TemplateArgumentListInfo *TemplateArgs = nullptr); void ActOnDefaultCtorInitializers(Decl *CDtorDecl); - bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl, + bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, + FunctionDecl *FDecl, const FunctionProtoType *Proto, - ArrayRef Args, SourceLocation RParenLoc, + ArrayRef Args, + SourceLocation RParenLoc, bool ExecConfig = false); - void CheckStaticArrayArgument(SourceLocation CallLoc, ParmVarDecl *Param, + void CheckStaticArrayArgument(SourceLocation CallLoc, + ParmVarDecl *Param, const Expr *ArgExpr); /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments. @@ -5675,11 +5821,13 @@ class Sema final { MultiExprArg ExecConfig, SourceLocation GGGLoc); - ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, - ParsedType &Ty, SourceLocation RParenLoc, - Expr *CastExpr); - ExprResult BuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *Ty, - SourceLocation RParenLoc, Expr *Op); + ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, + Declarator &D, ParsedType &Ty, + SourceLocation RParenLoc, Expr *CastExpr); + ExprResult BuildCStyleCastExpr(SourceLocation LParenLoc, + TypeSourceInfo *Ty, + SourceLocation RParenLoc, + Expr *Op); CastKind PrepareScalarCast(ExprResult &src, QualType destType); /// Build an altivec or OpenCL literal. @@ -5689,32 +5837,37 @@ class Sema final { ExprResult MaybeConvertParenListExprToParenExpr(Scope *S, Expr *ME); - ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty, - SourceLocation RParenLoc, Expr *InitExpr); + ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, + ParsedType Ty, + SourceLocation RParenLoc, + Expr *InitExpr); ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *LiteralExpr); - ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, + ExprResult ActOnInitList(SourceLocation LBraceLoc, + MultiExprArg InitArgList, SourceLocation RBraceLoc); - ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, + ExprResult BuildInitList(SourceLocation LBraceLoc, + MultiExprArg InitArgList, SourceLocation RBraceLoc); ExprResult ActOnDesignatedInitializer(Designation &Desig, SourceLocation EqualOrColonLoc, - bool GNUSyntax, ExprResult Init); + bool GNUSyntax, + ExprResult Init); private: static BinaryOperatorKind ConvertTokenKindToBinaryOpcode(tok::TokenKind Kind); public: - ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, tok::TokenKind Kind, - Expr *LHSExpr, Expr *RHSExpr); - ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, - Expr *LHSExpr, Expr *RHSExpr); + ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, + tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr); + ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, + BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr); ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr); void LookupBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, @@ -5725,8 +5878,8 @@ class Sema final { /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null /// in the case of a the GNU conditional expr extension. ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, - SourceLocation ColonLoc, Expr *CondExpr, - Expr *LHSExpr, Expr *RHSExpr); + SourceLocation ColonLoc, + Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr); /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo". ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, @@ -5744,7 +5897,7 @@ class Sema final { // __builtin_offsetof(type, identifier(.identifier|[expr])*) struct OffsetOfComponent { SourceLocation LocStart, LocEnd; - bool isBrackets; // true if [expr], false if .ident + bool isBrackets; // true if [expr], false if .ident union { IdentifierInfo *IdentInfo; Expr *E; @@ -5756,16 +5909,17 @@ class Sema final { TypeSourceInfo *TInfo, ArrayRef Components, SourceLocation RParenLoc); - ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, + ExprResult ActOnBuiltinOffsetOf(Scope *S, + SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, ArrayRef Components, SourceLocation RParenLoc); // __builtin_choose_expr(constExpr, expr1, expr2) - ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, - Expr *LHSExpr, Expr *RHSExpr, - SourceLocation RPLoc); + ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, + Expr *CondExpr, Expr *LHSExpr, + Expr *RHSExpr, SourceLocation RPLoc); // __builtin_va_arg(expr, type) ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, @@ -5810,10 +5964,10 @@ class Sema final { CheckMicrosoftIfExistsSymbol(Scope *S, CXXScopeSpec &SS, const DeclarationNameInfo &TargetNameInfo); - IfExistsResult CheckMicrosoftIfExistsSymbol(Scope *S, - SourceLocation KeywordLoc, - bool IsIfExists, CXXScopeSpec &SS, - UnqualifiedId &Name); + IfExistsResult + CheckMicrosoftIfExistsSymbol(Scope *S, SourceLocation KeywordLoc, + bool IsIfExists, CXXScopeSpec &SS, + UnqualifiedId &Name); StmtResult BuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, @@ -5821,8 +5975,9 @@ class Sema final { DeclarationNameInfo NameInfo, Stmt *Nested); StmtResult ActOnMSDependentExistsStmt(SourceLocation KeywordLoc, - bool IsIfExists, CXXScopeSpec &SS, - UnqualifiedId &Name, Stmt *Nested); + bool IsIfExists, + CXXScopeSpec &SS, UnqualifiedId &Name, + Stmt *Nested); //===------------------------- "Block" Extension ------------------------===// @@ -5941,9 +6096,12 @@ class Sema final { void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir); - Decl *ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc, - SourceLocation AliasLoc, IdentifierInfo *Alias, - CXXScopeSpec &SS, SourceLocation IdentLoc, + Decl *ActOnNamespaceAliasDef(Scope *CurScope, + SourceLocation NamespaceLoc, + SourceLocation AliasLoc, + IdentifierInfo *Alias, + CXXScopeSpec &SS, + SourceLocation IdentLoc, IdentifierInfo *Ident); void FilterUsingLookup(Scope *S, LookupResult &lookup); @@ -5967,14 +6125,12 @@ class Sema final { const LookupResult *R = nullptr, const UsingDecl *UD = nullptr); - NamedDecl *BuildUsingDeclaration(Scope *S, AccessSpecifier AS, - SourceLocation UsingLoc, - bool HasTypenameKeyword, - SourceLocation TypenameLoc, CXXScopeSpec &SS, - DeclarationNameInfo NameInfo, - SourceLocation EllipsisLoc, - const ParsedAttributesView &AttrList, - bool IsInstantiation, bool IsUsingIfExists); + NamedDecl *BuildUsingDeclaration( + Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, + bool HasTypenameKeyword, SourceLocation TypenameLoc, CXXScopeSpec &SS, + DeclarationNameInfo NameInfo, SourceLocation EllipsisLoc, + const ParsedAttributesView &AttrList, bool IsInstantiation, + bool IsUsingIfExists); NamedDecl *BuildUsingEnumDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, @@ -6014,34 +6170,38 @@ class Sema final { /// \param ConstructKind - a CXXConstructExpr::ConstructionKind ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, - NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, - MultiExprArg Exprs, bool HadMultipleCandidates, - bool IsListInitialization, - bool IsStdInitListInitialization, bool RequiresZeroInit, - unsigned ConstructKind, SourceRange ParenRange); + NamedDecl *FoundDecl, + CXXConstructorDecl *Constructor, MultiExprArg Exprs, + bool HadMultipleCandidates, bool IsListInitialization, + bool IsStdInitListInitialization, + bool RequiresZeroInit, unsigned ConstructKind, + SourceRange ParenRange); /// Build a CXXConstructExpr whose constructor has already been resolved if /// it denotes an inherited constructor. ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, CXXConstructorDecl *Constructor, bool Elidable, - MultiExprArg Exprs, bool HadMultipleCandidates, - bool IsListInitialization, - bool IsStdInitListInitialization, bool RequiresZeroInit, - unsigned ConstructKind, SourceRange ParenRange); + MultiExprArg Exprs, + bool HadMultipleCandidates, bool IsListInitialization, + bool IsStdInitListInitialization, + bool RequiresZeroInit, unsigned ConstructKind, + SourceRange ParenRange); // FIXME: Can we remove this and have the above BuildCXXConstructExpr check if // the constructor can be elidable? ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, - NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, - bool Elidable, MultiExprArg Exprs, - bool HadMultipleCandidates, bool IsListInitialization, + NamedDecl *FoundDecl, + CXXConstructorDecl *Constructor, bool Elidable, + MultiExprArg Exprs, bool HadMultipleCandidates, + bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, unsigned ConstructKind, SourceRange ParenRange); ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field); + /// Instantiate or parse a C++ default argument expression as necessary. /// Return true on error. bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, @@ -6049,7 +6209,8 @@ class Sema final { /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating /// the default expr if needed. - ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, + ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, + FunctionDecl *FD, ParmVarDecl *Param); /// FinalizeVarWithDestructor - Prepare for calling destructor on the @@ -6078,7 +6239,7 @@ class Sema final { public: explicit ImplicitExceptionSpecification(Sema &Self) - : Self(&Self), ComputedEST(EST_BasicNoexcept) { + : Self(&Self), ComputedEST(EST_BasicNoexcept) { if (!Self.getLangOpts().CPlusPlus11) ComputedEST = EST_DynamicNone; } @@ -6117,8 +6278,8 @@ class Sema final { /// The exception-specification is noexcept(false) if the set of /// potential exceptions of the special member function contains "any" ESI.Type = EST_NoexceptFalse; - ESI.NoexceptExpr = - Self->ActOnCXXBoolLiteral(SourceLocation(), tok::kw_false).get(); + ESI.NoexceptExpr = Self->ActOnCXXBoolLiteral(SourceLocation(), + tok::kw_false).get(); } return ESI; } @@ -6150,10 +6311,12 @@ class Sema final { /// Add an exception-specification to the given member function /// (or member function template). The exception-specification was parsed /// after the method itself was declared. - void actOnDelayedExceptionSpecification( - Decl *Method, ExceptionSpecificationType EST, - SourceRange SpecificationRange, ArrayRef DynamicExceptions, - ArrayRef DynamicExceptionRanges, Expr *NoexceptExpr); + void actOnDelayedExceptionSpecification(Decl *Method, + ExceptionSpecificationType EST, + SourceRange SpecificationRange, + ArrayRef DynamicExceptions, + ArrayRef DynamicExceptionRanges, + Expr *NoexceptExpr); class InheritedConstructorInfo; @@ -6172,8 +6335,8 @@ class Sema final { /// default constructor will be added. /// /// \returns The implicitly-declared default constructor. - CXXConstructorDecl * - DeclareImplicitDefaultConstructor(CXXRecordDecl *ClassDecl); + CXXConstructorDecl *DeclareImplicitDefaultConstructor( + CXXRecordDecl *ClassDecl); /// DefineImplicitDefaultConstructor - Checks for feasibility of /// defining this constructor as the default constructor. @@ -6305,9 +6468,10 @@ class Sema final { ParsedType getConstructorName(IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, bool EnteringContext); - ParsedType getDestructorName(SourceLocation TildeLoc, IdentifierInfo &II, - SourceLocation NameLoc, Scope *S, - CXXScopeSpec &SS, ParsedType ObjectType, + ParsedType getDestructorName(SourceLocation TildeLoc, + IdentifierInfo &II, SourceLocation NameLoc, + Scope *S, CXXScopeSpec &SS, + ParsedType ObjectType, bool EnteringContext); ParsedType getDestructorTypeForDecltype(const DeclSpec &DS, @@ -6332,15 +6496,21 @@ class Sema final { /// ActOnCXXNamedCast - Parse /// {dynamic,static,reinterpret,const,addrspace}_cast's. - ExprResult ActOnCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, - SourceLocation LAngleBracketLoc, Declarator &D, + ExprResult ActOnCXXNamedCast(SourceLocation OpLoc, + tok::TokenKind Kind, + SourceLocation LAngleBracketLoc, + Declarator &D, SourceLocation RAngleBracketLoc, - SourceLocation LParenLoc, Expr *E, + SourceLocation LParenLoc, + Expr *E, SourceLocation RParenLoc); - ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, - TypeSourceInfo *Ty, Expr *E, - SourceRange AngleBrackets, SourceRange Parens); + ExprResult BuildCXXNamedCast(SourceLocation OpLoc, + tok::TokenKind Kind, + TypeSourceInfo *Ty, + Expr *E, + SourceRange AngleBrackets, + SourceRange Parens); ExprResult ActOnBuiltinBitCastExpr(SourceLocation KWLoc, Declarator &Dcl, ExprResult Operand, @@ -6349,24 +6519,34 @@ class Sema final { ExprResult BuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI, Expr *Operand, SourceLocation RParenLoc); - ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc, - TypeSourceInfo *Operand, SourceLocation RParenLoc); - ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc, - Expr *Operand, SourceLocation RParenLoc); + ExprResult BuildCXXTypeId(QualType TypeInfoType, + SourceLocation TypeidLoc, + TypeSourceInfo *Operand, + SourceLocation RParenLoc); + ExprResult BuildCXXTypeId(QualType TypeInfoType, + SourceLocation TypeidLoc, + Expr *Operand, + SourceLocation RParenLoc); /// ActOnCXXTypeid - Parse typeid( something ). - ExprResult ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc, - bool isType, void *TyOrExpr, + ExprResult ActOnCXXTypeid(SourceLocation OpLoc, + SourceLocation LParenLoc, bool isType, + void *TyOrExpr, SourceLocation RParenLoc); - ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc, - TypeSourceInfo *Operand, SourceLocation RParenLoc); - ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc, - Expr *Operand, SourceLocation RParenLoc); + ExprResult BuildCXXUuidof(QualType TypeInfoType, + SourceLocation TypeidLoc, + TypeSourceInfo *Operand, + SourceLocation RParenLoc); + ExprResult BuildCXXUuidof(QualType TypeInfoType, + SourceLocation TypeidLoc, + Expr *Operand, + SourceLocation RParenLoc); /// ActOnCXXUuidof - Parse __uuidof( something ). - ExprResult ActOnCXXUuidof(SourceLocation OpLoc, SourceLocation LParenLoc, - bool isType, void *TyOrExpr, + ExprResult ActOnCXXUuidof(SourceLocation OpLoc, + SourceLocation LParenLoc, bool isType, + void *TyOrExpr, SourceLocation RParenLoc); /// Handle a C++1z fold-expression: ( expr op ... op expr ). @@ -6433,8 +6613,8 @@ class Sema final { /// a nested generic lambda (depending on whether the name resolves to /// a non-static member function or a static function). /// \return returns 'true' if failed, 'false' if success. - bool CheckCXXThisCapture( - SourceLocation Loc, bool Explicit = false, bool BuildAndDiagnose = true, + bool CheckCXXThisCapture(SourceLocation Loc, bool Explicit = false, + bool BuildAndDiagnose = true, const unsigned *const FunctionScopeIndexToStopAt = nullptr, bool ByCopy = false); @@ -6446,6 +6626,7 @@ class Sema final { /// ActOnCXXBoolLiteral - Parse {true,false} literals. ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind); + /// ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals. ExprResult ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind); @@ -6485,12 +6666,16 @@ class Sema final { SourceLocation PlacementRParen, SourceRange TypeIdParens, Declarator &D, Expr *Initializer); - ExprResult - BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen, - MultiExprArg PlacementArgs, SourceLocation PlacementRParen, - SourceRange TypeIdParens, QualType AllocType, - TypeSourceInfo *AllocTypeInfo, Optional ArraySize, - SourceRange DirectInitRange, Expr *Initializer); + ExprResult BuildCXXNew(SourceRange Range, bool UseGlobal, + SourceLocation PlacementLParen, + MultiExprArg PlacementArgs, + SourceLocation PlacementRParen, + SourceRange TypeIdParens, + QualType AllocType, + TypeSourceInfo *AllocTypeInfo, + Optional ArraySize, + SourceRange DirectInitRange, + Expr *Initializer); /// Determine whether \p FD is an aligned allocation or deallocation /// function that is unavailable. @@ -6542,8 +6727,9 @@ class Sema final { CXXRecordDecl *RD); /// ActOnCXXDelete - Parsed a C++ 'delete' expression - ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, - bool ArrayForm, Expr *Operand); + ExprResult ActOnCXXDelete(SourceLocation StartLoc, + bool UseGlobal, bool ArrayForm, + Expr *Operand); void CheckVirtualDtorCall(CXXDestructorDecl *dtor, SourceLocation Loc, bool IsDelete, bool CallCanBeVirtual, bool WarnOnNonAbstractTypes, @@ -6564,43 +6750,60 @@ class Sema final { /// ActOnArrayTypeTrait - Parsed one of the binary type trait support /// pseudo-functions. - ExprResult ActOnArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc, - ParsedType LhsTy, Expr *DimExpr, + ExprResult ActOnArrayTypeTrait(ArrayTypeTrait ATT, + SourceLocation KWLoc, + ParsedType LhsTy, + Expr *DimExpr, SourceLocation RParen); - ExprResult BuildArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc, - TypeSourceInfo *TSInfo, Expr *DimExpr, + ExprResult BuildArrayTypeTrait(ArrayTypeTrait ATT, + SourceLocation KWLoc, + TypeSourceInfo *TSInfo, + Expr *DimExpr, SourceLocation RParen); /// ActOnExpressionTrait - Parsed one of the unary type trait support /// pseudo-functions. - ExprResult ActOnExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, - Expr *Queried, SourceLocation RParen); + ExprResult ActOnExpressionTrait(ExpressionTrait OET, + SourceLocation KWLoc, + Expr *Queried, + SourceLocation RParen); - ExprResult BuildExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, - Expr *Queried, SourceLocation RParen); + ExprResult BuildExpressionTrait(ExpressionTrait OET, + SourceLocation KWLoc, + Expr *Queried, + SourceLocation RParen); - ExprResult ActOnStartCXXMemberReference(Scope *S, Expr *Base, + ExprResult ActOnStartCXXMemberReference(Scope *S, + Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, ParsedType &ObjectType, bool &MayBePseudoDestructor); - ExprResult BuildPseudoDestructorExpr( - Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, - const CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc, - SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType); + ExprResult BuildPseudoDestructorExpr(Expr *Base, + SourceLocation OpLoc, + tok::TokenKind OpKind, + const CXXScopeSpec &SS, + TypeSourceInfo *ScopeType, + SourceLocation CCLoc, + SourceLocation TildeLoc, + PseudoDestructorTypeStorage DestroyedType); - ExprResult ActOnPseudoDestructorExpr( - Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, - CXXScopeSpec &SS, UnqualifiedId &FirstTypeName, SourceLocation CCLoc, - SourceLocation TildeLoc, UnqualifiedId &SecondTypeName); + ExprResult ActOnPseudoDestructorExpr(Scope *S, Expr *Base, + SourceLocation OpLoc, + tok::TokenKind OpKind, + CXXScopeSpec &SS, + UnqualifiedId &FirstTypeName, + SourceLocation CCLoc, + SourceLocation TildeLoc, + UnqualifiedId &SecondTypeName); ExprResult ActOnPseudoDestructorExpr(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, SourceLocation TildeLoc, - const DeclSpec &DS); + const DeclSpec& DS); /// MaybeCreateExprWithCleanups - If the current full-expression /// requires any cleanups, surround it with a ExprWithCleanups node. @@ -6678,22 +6881,25 @@ class Sema final { /// Creates info object for the most typical case. NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, - SourceLocation ColonColonLoc, - ParsedType ObjectType = ParsedType()) - : ObjectType(ObjectType), Identifier(II), IdentifierLoc(IdLoc), - CCLoc(ColonColonLoc) {} + SourceLocation ColonColonLoc, ParsedType ObjectType = ParsedType()) + : ObjectType(ObjectType), Identifier(II), IdentifierLoc(IdLoc), + CCLoc(ColonColonLoc) { + } NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, QualType ObjectType) - : ObjectType(ParsedType::make(ObjectType)), Identifier(II), - IdentifierLoc(IdLoc), CCLoc(ColonColonLoc) {} + : ObjectType(ParsedType::make(ObjectType)), Identifier(II), + IdentifierLoc(IdLoc), CCLoc(ColonColonLoc) { + } }; bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS, NestedNameSpecInfo &IdInfo); - bool BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, - bool EnteringContext, CXXScopeSpec &SS, + bool BuildCXXNestedNameSpecifier(Scope *S, + NestedNameSpecInfo &IdInfo, + bool EnteringContext, + CXXScopeSpec &SS, NamedDecl *ScopeLookupResult, bool ErrorRecoveryLookup, bool *IsCorrectedToColon = nullptr, @@ -6721,14 +6927,17 @@ class Sema final { /// \param OnlyNamespace If true, only considers namespaces in lookup. /// /// \returns true if an error occurred, false otherwise. - bool ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, - bool EnteringContext, CXXScopeSpec &SS, + bool ActOnCXXNestedNameSpecifier(Scope *S, + NestedNameSpecInfo &IdInfo, + bool EnteringContext, + CXXScopeSpec &SS, bool *IsCorrectedToColon = nullptr, bool OnlyNamespace = false); ExprResult ActOnDecltypeExpression(Expr *E); - bool ActOnCXXNestedNameSpecifierDecltype(CXXScopeSpec &SS, const DeclSpec &DS, + bool ActOnCXXNestedNameSpecifierDecltype(CXXScopeSpec &SS, + const DeclSpec &DS, SourceLocation ColonColonLoc); bool IsInvalidUnlessNestedName(Scope *S, CXXScopeSpec &SS, @@ -6758,11 +6967,16 @@ class Sema final { /// /// /// \returns true if an error occurred, false otherwise. - bool ActOnCXXNestedNameSpecifier( - Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, - TemplateTy TemplateName, SourceLocation TemplateNameLoc, - SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, - SourceLocation RAngleLoc, SourceLocation CCLoc, bool EnteringContext); + bool ActOnCXXNestedNameSpecifier(Scope *S, + CXXScopeSpec &SS, + SourceLocation TemplateKWLoc, + TemplateTy TemplateName, + SourceLocation TemplateNameLoc, + SourceLocation LAngleLoc, + ASTTemplateArgsPtr TemplateArgs, + SourceLocation RAngleLoc, + SourceLocation CCLoc, + bool EnteringContext); /// Given a C++ nested-name-specifier, produce an annotation value /// that the parser can use later to reconstruct the given @@ -6836,11 +7050,14 @@ class Sema final { Optional> Mangling = None); /// Endow the lambda scope info with the relevant properties. - void buildLambdaScope(sema::LambdaScopeInfo *LSI, CXXMethodDecl *CallOperator, + void buildLambdaScope(sema::LambdaScopeInfo *LSI, + CXXMethodDecl *CallOperator, SourceRange IntroducerRange, LambdaCaptureDefault CaptureDefault, - SourceLocation CaptureDefaultLoc, bool ExplicitParams, - bool ExplicitResultType, bool Mutable); + SourceLocation CaptureDefaultLoc, + bool ExplicitParams, + bool ExplicitResultType, + bool Mutable); /// Perform initialization analysis of the init-capture and perform /// any implicit conversions such as an lvalue-to-rvalue conversion if @@ -6883,8 +7100,9 @@ class Sema final { ExprResult RequiresClause); /// Introduce the lambda parameters into scope. - void addLambdaParameters(ArrayRef Captures, - CXXMethodDecl *CallOperator, Scope *CurScope); + void addLambdaParameters( + ArrayRef Captures, + CXXMethodDecl *CallOperator, Scope *CurScope); /// Deduce a block or lambda's return type based on the return /// statements present in the body. @@ -6941,9 +7159,8 @@ class Sema final { /// in the initialization expression needed to copy the lambda object into /// the block, and IR generation actually generates the real body of the /// block pointer conversion. - void - DefineImplicitLambdaToFunctionPointerConversion(SourceLocation CurrentLoc, - CXXConversionDecl *Conv); + void DefineImplicitLambdaToFunctionPointerConversion( + SourceLocation CurrentLoc, CXXConversionDecl *Conv); /// Define the "body" of the conversion from a lambda object to a /// block pointer. @@ -6957,7 +7174,8 @@ class Sema final { ExprResult BuildBlockForLambdaConversion(SourceLocation CurrentLocation, SourceLocation ConvLocation, - CXXConversionDecl *Conv, Expr *Src); + CXXConversionDecl *Conv, + Expr *Src); /// Check whether the given expression is a valid constraint expression. /// A diagnostic is emitted if it is not, false is returned, and @@ -6976,7 +7194,8 @@ class Sema final { /// constrained declarations). If an error occurred while normalizing the /// associated constraints of the template or concept, nullptr will be cached /// here. - llvm::DenseMap NormalizationCache; + llvm::DenseMap + NormalizationCache; llvm::ContextualFoldingSet SatisfactionCache; @@ -7005,7 +7224,8 @@ class Sema final { LocalInstantiationScope &Scope); public: - const NormalizedConstraint *getNormalizedAssociatedConstraints( + const NormalizedConstraint * + getNormalizedAssociatedConstraints( NamedDecl *ConstrainedDecl, ArrayRef AssociatedConstraints); /// \brief Check whether the given declaration's associated constraints are @@ -7024,9 +7244,8 @@ class Sema final { /// of atomic constraints involved had been declared in a concept and not /// repeated in two separate places in code. /// \returns true if such a diagnostic was emitted, false otherwise. - bool MaybeEmitAmbiguousAtomicConstraintsDiagnostic( - NamedDecl *D1, ArrayRef AC1, NamedDecl *D2, - ArrayRef AC2); + bool MaybeEmitAmbiguousAtomicConstraintsDiagnostic(NamedDecl *D1, + ArrayRef AC1, NamedDecl *D2, ArrayRef AC2); /// \brief Check whether the given list of constraint expressions are /// satisfied (as if in a 'conjunction') given template arguments. @@ -7123,8 +7342,9 @@ class Sema final { /// unsatisfied. /// \param First whether this is the first time an unsatisfied constraint is /// diagnosed for this error. - void DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction, - bool First = true); + void + DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction, + bool First = true); /// \brief Emit diagnostics explaining why a constraint expression was deemed /// unsatisfied. @@ -7158,31 +7378,32 @@ class Sema final { ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod); - ExprResult - BuildObjCDictionaryLiteral(SourceRange SR, - MutableArrayRef Elements); + ExprResult BuildObjCDictionaryLiteral(SourceRange SR, + MutableArrayRef Elements); ExprResult BuildObjCEncodeExpression(SourceLocation AtLoc, - TypeSourceInfo *EncodedTypeInfo, - SourceLocation RParenLoc); + TypeSourceInfo *EncodedTypeInfo, + SourceLocation RParenLoc); ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates); ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc, SourceLocation EncodeLoc, - SourceLocation LParenLoc, ParsedType Ty, + SourceLocation LParenLoc, + ParsedType Ty, SourceLocation RParenLoc); /// ParseObjCSelectorExpression - Build selector expression for \@selector - ExprResult ParseObjCSelectorExpression(Selector Sel, SourceLocation AtLoc, + ExprResult ParseObjCSelectorExpression(Selector Sel, + SourceLocation AtLoc, SourceLocation SelLoc, SourceLocation LParenLoc, SourceLocation RParenLoc, bool WarnMultipleSelectors); /// ParseObjCProtocolExpression - Build protocol expression for \@protocol - ExprResult ParseObjCProtocolExpression(IdentifierInfo *ProtocolName, + ExprResult ParseObjCProtocolExpression(IdentifierInfo * ProtocolName, SourceLocation AtLoc, SourceLocation ProtoLoc, SourceLocation LParenLoc, @@ -7192,11 +7413,15 @@ class Sema final { //===--------------------------------------------------------------------===// // C++ Declarations // - Decl *ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, - Expr *LangStr, SourceLocation LBraceLoc); - Decl *ActOnFinishLinkageSpecification(Scope *S, Decl *LinkageSpec, + Decl *ActOnStartLinkageSpecification(Scope *S, + SourceLocation ExternLoc, + Expr *LangStr, + SourceLocation LBraceLoc); + Decl *ActOnFinishLinkageSpecification(Scope *S, + Decl *LinkageSpec, SourceLocation RBraceLoc); + //===--------------------------------------------------------------------===// // C++ Classes // @@ -7209,47 +7434,61 @@ class Sema final { SourceLocation ColonLoc, const ParsedAttributesView &Attrs); - NamedDecl * - ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, - MultiTemplateParamsArg TemplateParameterLists, - Expr *BitfieldWidth, const VirtSpecifiers &VS, - InClassInitStyle InitStyle); + NamedDecl *ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, + Declarator &D, + MultiTemplateParamsArg TemplateParameterLists, + Expr *BitfieldWidth, const VirtSpecifiers &VS, + InClassInitStyle InitStyle); void ActOnStartCXXInClassMemberInitializer(); void ActOnFinishCXXInClassMemberInitializer(Decl *VarDecl, SourceLocation EqualLoc, Expr *Init); - MemInitResult - ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, - IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, - const DeclSpec &DS, SourceLocation IdLoc, - SourceLocation LParenLoc, ArrayRef Args, - SourceLocation RParenLoc, SourceLocation EllipsisLoc); + MemInitResult ActOnMemInitializer(Decl *ConstructorD, + Scope *S, + CXXScopeSpec &SS, + IdentifierInfo *MemberOrBase, + ParsedType TemplateTypeTy, + const DeclSpec &DS, + SourceLocation IdLoc, + SourceLocation LParenLoc, + ArrayRef Args, + SourceLocation RParenLoc, + SourceLocation EllipsisLoc); - MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S, + MemInitResult ActOnMemInitializer(Decl *ConstructorD, + Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, - const DeclSpec &DS, SourceLocation IdLoc, - Expr *InitList, SourceLocation EllipsisLoc); + const DeclSpec &DS, + SourceLocation IdLoc, + Expr *InitList, + SourceLocation EllipsisLoc); - MemInitResult BuildMemInitializer(Decl *ConstructorD, Scope *S, + MemInitResult BuildMemInitializer(Decl *ConstructorD, + Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, - const DeclSpec &DS, SourceLocation IdLoc, - Expr *Init, SourceLocation EllipsisLoc); + const DeclSpec &DS, + SourceLocation IdLoc, + Expr *Init, + SourceLocation EllipsisLoc); - MemInitResult BuildMemberInitializer(ValueDecl *Member, Expr *Init, + MemInitResult BuildMemberInitializer(ValueDecl *Member, + Expr *Init, SourceLocation IdLoc); MemInitResult BuildBaseInitializer(QualType BaseType, - TypeSourceInfo *BaseTInfo, Expr *Init, + TypeSourceInfo *BaseTInfo, + Expr *Init, CXXRecordDecl *ClassDecl, SourceLocation EllipsisLoc); - MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init, + MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo, + Expr *Init, CXXRecordDecl *ClassDecl); bool SetDelegatingInitializer(CXXConstructorDecl *Constructor, @@ -7260,6 +7499,7 @@ class Sema final { void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation); + /// MarkBaseAndMemberDestructorsReferenced - Given a record decl, /// mark all the non-trivial destructors of its members and bases as /// referenced. @@ -7285,7 +7525,7 @@ class Sema final { /// The list of classes whose vtables have been used within /// this translation unit, and the source locations at which the /// first use occurred. - typedef std::pair VTableUse; + typedef std::pair VTableUse; /// The list of vtables that are required but have not yet been /// materialized. @@ -7324,8 +7564,9 @@ class Sema final { void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl); - void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc, - ArrayRef MemInits, + void ActOnMemInitializers(Decl *ConstructorDecl, + SourceLocation ColonLoc, + ArrayRef MemInits, bool AnyErrors); /// Check class-level dllimport/dllexport attribute. The caller must @@ -7380,12 +7621,14 @@ class Sema final { bool IsInsideALocalClassWithinATemplateFunction(); Decl *ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc, - Expr *AssertExpr, Expr *AssertMessageExpr, + Expr *AssertExpr, + Expr *AssertMessageExpr, SourceLocation RParenLoc); Decl *BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *AssertMessageExpr, - SourceLocation RParenLoc, bool Failed); + SourceLocation RParenLoc, + bool Failed); void DiagnoseStaticAssertDetails(const Expr *E); FriendDecl *CheckFriendTypeDecl(SourceLocation LocStart, @@ -7397,12 +7640,13 @@ class Sema final { MultiTemplateParamsArg TemplateParams); QualType CheckConstructorDeclarator(Declarator &D, QualType R, - StorageClass &SC); + StorageClass& SC); void CheckConstructor(CXXConstructorDecl *Constructor); QualType CheckDestructorDeclarator(Declarator &D, QualType R, - StorageClass &SC); + StorageClass& SC); bool CheckDestructor(CXXDestructorDecl *Destructor); - void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC); + void CheckConversionDeclarator(Declarator &D, QualType &R, + StorageClass& SC); Decl *ActOnConversionDeclarator(CXXConversionDecl *Conversion); void CheckDeductionGuideDeclarator(Declarator &D, QualType &R, StorageClass &SC); @@ -7428,8 +7672,8 @@ class Sema final { /// ActOnBaseSpecifier - Parsed a base specifier CXXBaseSpecifier *CheckBaseSpecifier(CXXRecordDecl *Class, - SourceRange SpecifierRange, bool Virtual, - AccessSpecifier Access, + SourceRange SpecifierRange, + bool Virtual, AccessSpecifier Access, TypeSourceInfo *TInfo, SourceLocation EllipsisLoc); @@ -7459,7 +7703,8 @@ class Sema final { unsigned InaccessibleBaseID, unsigned AmbiguousBaseConvID, SourceLocation Loc, SourceRange Range, - DeclarationName Name, CXXCastPath *BasePath, + DeclarationName Name, + CXXCastPath *BasePath, bool IgnoreAccess = false); std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths); @@ -7492,6 +7737,7 @@ class Sema final { bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New, const CXXMethodDecl *Old); + //===--------------------------------------------------------------------===// // C++ Access Control // @@ -7516,11 +7762,13 @@ class Sema final { CXXRecordDecl *NamingClass, DeclAccessPair FoundDecl, bool Diagnose = true); - AccessResult CheckConstructorAccess(SourceLocation Loc, CXXConstructorDecl *D, + AccessResult CheckConstructorAccess(SourceLocation Loc, + CXXConstructorDecl *D, DeclAccessPair FoundDecl, const InitializedEntity &Entity, bool IsCopyBindingRefToTemp = false); - AccessResult CheckConstructorAccess(SourceLocation Loc, CXXConstructorDecl *D, + AccessResult CheckConstructorAccess(SourceLocation Loc, + CXXConstructorDecl *D, DeclAccessPair FoundDecl, const InitializedEntity &Entity, const PartialDiagnostic &PDiag); @@ -7539,7 +7787,8 @@ class Sema final { AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, const SourceRange &, DeclAccessPair FoundDecl); - AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, + AccessResult CheckMemberOperatorAccess(SourceLocation Loc, + Expr *ObjectExpr, Expr *ArgExpr, DeclAccessPair FoundDecl); AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, @@ -7547,9 +7796,11 @@ class Sema final { DeclAccessPair FoundDecl); AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr, DeclAccessPair FoundDecl); - AccessResult CheckBaseClassAccess(SourceLocation AccessLoc, QualType Base, - QualType Derived, const CXXBasePath &Path, - unsigned DiagID, bool ForceCheck = false, + AccessResult CheckBaseClassAccess(SourceLocation AccessLoc, + QualType Base, QualType Derived, + const CXXBasePath &Path, + unsigned DiagID, + bool ForceCheck = false, bool ForceUnprivileged = false); void CheckLookupAccess(const LookupResult &R); bool IsSimplyAccessible(NamedDecl *Decl, CXXRecordDecl *NamingClass, @@ -7565,12 +7816,10 @@ class Sema final { SourceLocation(), PDiag()); } - void HandleDependentAccessCheck( - const DependentDiagnostic &DD, - const MultiLevelTemplateArgumentList &TemplateArgs); - void PerformDependentDiagnostics( - const DeclContext *Pattern, - const MultiLevelTemplateArgumentList &TemplateArgs); + void HandleDependentAccessCheck(const DependentDiagnostic &DD, + const MultiLevelTemplateArgumentList &TemplateArgs); + void PerformDependentDiagnostics(const DeclContext *Pattern, + const MultiLevelTemplateArgumentList &TemplateArgs); void HandleDelayedAccessCheck(sema::DelayedDiagnostic &DD, Decl *Ctx); @@ -7643,9 +7892,7 @@ class Sema final { SourceLocation getTemplateKeywordLoc() const { return TemplateKW.value_or(SourceLocation()); } - bool hasTemplateKeyword() const { - return getTemplateKeywordLoc().isValid(); - } + bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); } bool isRequired() const { return TemplateKW != SourceLocation(); } explicit operator bool() const { return isRequired(); } @@ -7668,10 +7915,12 @@ class Sema final { RequiredTemplateKind RequiredTemplate = SourceLocation(), AssumedTemplateKind *ATK = nullptr, bool AllowTypoCorrection = true); - TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, + TemplateNameKind isTemplateName(Scope *S, + CXXScopeSpec &SS, bool hasTemplateKeyword, const UnqualifiedId &Name, - ParsedType ObjectType, bool EnteringContext, + ParsedType ObjectType, + bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization, bool Disambiguation = false); @@ -7697,7 +7946,8 @@ class Sema final { ParsedTemplateTy *Template = nullptr); bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, - SourceLocation IILoc, Scope *S, + SourceLocation IILoc, + Scope *S, const CXXScopeSpec *SS, TemplateTy &SuggestedTemplate, TemplateNameKind &SuggestedKind); @@ -7717,8 +7967,9 @@ class Sema final { SourceLocation EllipsisLoc, SourceLocation KeyLoc, IdentifierInfo *ParamName, - SourceLocation ParamNameLoc, unsigned Depth, - unsigned Position, SourceLocation EqualLoc, + SourceLocation ParamNameLoc, + unsigned Depth, unsigned Position, + SourceLocation EqualLoc, ParsedType DefaultArg, bool HasTypeConstraint); bool ActOnTypeConstraint(const CXXScopeSpec &SS, @@ -7749,19 +8000,29 @@ class Sema final { QualType CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc); NamedDecl *ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, - unsigned Depth, unsigned Position, - SourceLocation EqualLoc, - Expr *DefaultArg); - NamedDecl *ActOnTemplateTemplateParameter( - Scope *S, SourceLocation TmpLoc, TemplateParameterList *Params, - SourceLocation EllipsisLoc, IdentifierInfo *ParamName, - SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, - SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg); - - TemplateParameterList *ActOnTemplateParameterList( - unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, - SourceLocation LAngleLoc, ArrayRef Params, - SourceLocation RAngleLoc, Expr *RequiresClause); + unsigned Depth, + unsigned Position, + SourceLocation EqualLoc, + Expr *DefaultArg); + NamedDecl *ActOnTemplateTemplateParameter(Scope *S, + SourceLocation TmpLoc, + TemplateParameterList *Params, + SourceLocation EllipsisLoc, + IdentifierInfo *ParamName, + SourceLocation ParamNameLoc, + unsigned Depth, + unsigned Position, + SourceLocation EqualLoc, + ParsedTemplateArgument DefaultArg); + + TemplateParameterList * + ActOnTemplateParameterList(unsigned Depth, + SourceLocation ExportLoc, + SourceLocation TemplateLoc, + SourceLocation LAngleLoc, + ArrayRef Params, + SourceLocation RAngleLoc, + Expr *RequiresClause); /// The context in which we are checking a template parameter list. enum TemplateParamListContext { @@ -7782,8 +8043,8 @@ class Sema final { TemplateParameterList *MatchTemplateParametersToScopeSpecifier( SourceLocation DeclStartLoc, SourceLocation DeclLoc, const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId, - ArrayRef ParamLists, bool IsFriend, - bool &IsMemberSpecialization, bool &Invalid, + ArrayRef ParamLists, + bool IsFriend, bool &IsMemberSpecialization, bool &Invalid, bool SuppressDiagnostic = false); DeclResult CheckClassTemplate( @@ -7814,7 +8075,7 @@ class Sema final { QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, - TemplateArgumentListInfo &TemplateArgs); + TemplateArgumentListInfo &TemplateArgs); TypeResult ActOnTemplateIdType(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, @@ -7827,17 +8088,21 @@ class Sema final { /// Parsed an elaborated-type-specifier that refers to a template-id, /// such as \c class T::template apply. - TypeResult ActOnTagTemplateIdType( - TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc, - CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD, - SourceLocation TemplateLoc, SourceLocation LAngleLoc, - ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc); - - DeclResult - ActOnVarTemplateSpecialization(Scope *S, Declarator &D, TypeSourceInfo *DI, - SourceLocation TemplateKWLoc, - TemplateParameterList *TemplateParams, - StorageClass SC, bool IsPartialSpecialization); + TypeResult ActOnTagTemplateIdType(TagUseKind TUK, + TypeSpecifierType TagSpec, + SourceLocation TagLoc, + CXXScopeSpec &SS, + SourceLocation TemplateKWLoc, + TemplateTy TemplateD, + SourceLocation TemplateLoc, + SourceLocation LAngleLoc, + ASTTemplateArgsPtr TemplateArgsIn, + SourceLocation RAngleLoc); + + DeclResult ActOnVarTemplateSpecialization( + Scope *S, Declarator &D, TypeSourceInfo *DI, + SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams, + StorageClass SC, bool IsPartialSpecialization); /// Get the specialization of the given variable template corresponding to /// the specified argument list, or a null-but-valid result if the arguments @@ -7857,7 +8122,8 @@ class Sema final { const TemplateArgumentListInfo *TemplateArgs); ExprResult - CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, + CheckConceptTemplateId(const CXXScopeSpec &SS, + SourceLocation TemplateKWLoc, const DeclarationNameInfo &ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs); @@ -7865,21 +8131,20 @@ class Sema final { void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc); ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, - SourceLocation TemplateKWLoc, LookupResult &R, + SourceLocation TemplateKWLoc, + LookupResult &R, bool RequiresADL, - const TemplateArgumentListInfo *TemplateArgs); + const TemplateArgumentListInfo *TemplateArgs); - ExprResult - BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, + ExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS, + SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs); - TemplateNameKind ActOnTemplateName(Scope *S, CXXScopeSpec &SS, - SourceLocation TemplateKWLoc, - const UnqualifiedId &Name, - ParsedType ObjectType, - bool EnteringContext, TemplateTy &Template, - bool AllowInjectedClassName = false); + TemplateNameKind ActOnTemplateName( + Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, + const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, + TemplateTy &Template, bool AllowInjectedClassName = false); DeclResult ActOnClassTemplateSpecialization( Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, @@ -7901,14 +8166,17 @@ class Sema final { MultiTemplateParamsArg TemplateParameterLists, Declarator &D); - bool CheckSpecializationInstantiationRedecl( - SourceLocation NewLoc, TemplateSpecializationKind NewTSK, - NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK, - SourceLocation PrevPtOfInstantiation, bool &SuppressNew); + bool + CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, + TemplateSpecializationKind NewTSK, + NamedDecl *PrevDecl, + TemplateSpecializationKind PrevTSK, + SourceLocation PrevPtOfInstantiation, + bool &SuppressNew); - bool CheckDependentFunctionTemplateSpecialization( - FunctionDecl *FD, const TemplateArgumentListInfo &ExplicitTemplateArgs, - LookupResult &Previous); + bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD, + const TemplateArgumentListInfo &ExplicitTemplateArgs, + LookupResult &Previous); bool CheckFunctionTemplateSpecialization( FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, @@ -7930,14 +8198,19 @@ class Sema final { SourceLocation NameLoc, const ParsedAttributesView &Attr); - DeclResult ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc, + DeclResult ActOnExplicitInstantiation(Scope *S, + SourceLocation ExternLoc, SourceLocation TemplateLoc, Declarator &D); - TemplateArgumentLoc SubstDefaultTemplateArgumentIfAvailable( - TemplateDecl *Template, SourceLocation TemplateLoc, - SourceLocation RAngleLoc, Decl *Param, - SmallVectorImpl &Converted, bool &HasDefaultArg); + TemplateArgumentLoc + SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, + SourceLocation TemplateLoc, + SourceLocation RAngleLoc, + Decl *Param, + SmallVectorImpl + &Converted, + bool &HasDefaultArg); /// Specifies the context in which a particular template /// argument is being checked. @@ -7955,11 +8228,13 @@ class Sema final { CTAK_DeducedFromArrayBound }; - bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, - NamedDecl *Template, SourceLocation TemplateLoc, + bool CheckTemplateArgument(NamedDecl *Param, + TemplateArgumentLoc &Arg, + NamedDecl *Template, + SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, - SmallVectorImpl &Converted, + SmallVectorImpl &Converted, CheckTemplateArgumentKind CTAK = CTAK_Specified); /// Check that the given template arguments can be be provided to @@ -8001,20 +8276,21 @@ class Sema final { bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param, TemplateArgumentLoc &Arg, - SmallVectorImpl &Converted); + SmallVectorImpl &Converted); bool CheckTemplateArgument(TypeSourceInfo *Arg); - ExprResult - CheckTemplateArgument(NonTypeTemplateParmDecl *Param, - QualType InstantiatedParamType, Expr *Arg, - TemplateArgument &Converted, - CheckTemplateArgumentKind CTAK = CTAK_Specified); + ExprResult CheckTemplateArgument(NonTypeTemplateParmDecl *Param, + QualType InstantiatedParamType, Expr *Arg, + TemplateArgument &Converted, + CheckTemplateArgumentKind CTAK = CTAK_Specified); bool CheckTemplateTemplateArgument(TemplateTemplateParmDecl *Param, TemplateParameterList *Params, TemplateArgumentLoc &Arg); - ExprResult BuildExpressionFromDeclTemplateArgument( - const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc); + ExprResult + BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, + QualType ParamType, + SourceLocation Loc); ExprResult BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc); @@ -8102,31 +8378,39 @@ class Sema final { /// \param RAngleLoc The location of the closing angle bracket ('>'). TypeResult ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, - const CXXScopeSpec &SS, SourceLocation TemplateLoc, - TemplateTy TemplateName, IdentifierInfo *TemplateII, - SourceLocation TemplateIILoc, SourceLocation LAngleLoc, - ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc); + const CXXScopeSpec &SS, + SourceLocation TemplateLoc, + TemplateTy TemplateName, + IdentifierInfo *TemplateII, + SourceLocation TemplateIILoc, + SourceLocation LAngleLoc, + ASTTemplateArgsPtr TemplateArgs, + SourceLocation RAngleLoc); QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, - const IdentifierInfo &II, SourceLocation IILoc, - TypeSourceInfo **TSI, bool DeducedTSTContext); + const IdentifierInfo &II, + SourceLocation IILoc, + TypeSourceInfo **TSI, + bool DeducedTSTContext); QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, - const IdentifierInfo &II, SourceLocation IILoc, + const IdentifierInfo &II, + SourceLocation IILoc, bool DeducedTSTContext = true); + TypeSourceInfo *RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name); bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS); ExprResult RebuildExprInCurrentInstantiation(Expr *E); - bool - RebuildTemplateParamsInCurrentInstantiation(TemplateParameterList *Params); + bool RebuildTemplateParamsInCurrentInstantiation( + TemplateParameterList *Params); std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, @@ -8140,10 +8424,9 @@ class Sema final { //===--------------------------------------------------------------------===// // C++ Concepts //===--------------------------------------------------------------------===// - Decl *ActOnConceptDefinition(Scope *S, - MultiTemplateParamsArg TemplateParameterLists, - IdentifierInfo *Name, SourceLocation NameLoc, - Expr *ConstraintExpr); + Decl *ActOnConceptDefinition( + Scope *S, MultiTemplateParamsArg TemplateParameterLists, + IdentifierInfo *Name, SourceLocation NameLoc, Expr *ConstraintExpr); void CheckConceptRedefinition(ConceptDecl *NewDecl, LookupResult &Previous, bool &AddToScope); @@ -8154,29 +8437,32 @@ class Sema final { Scope *BodyScope); void ActOnFinishRequiresExpr(); concepts::Requirement *ActOnSimpleRequirement(Expr *E); - concepts::Requirement *ActOnTypeRequirement(SourceLocation TypenameKWLoc, - CXXScopeSpec &SS, - SourceLocation NameLoc, - IdentifierInfo *TypeName, - TemplateIdAnnotation *TemplateId); + concepts::Requirement *ActOnTypeRequirement( + SourceLocation TypenameKWLoc, CXXScopeSpec &SS, SourceLocation NameLoc, + IdentifierInfo *TypeName, TemplateIdAnnotation *TemplateId); concepts::Requirement *ActOnCompoundRequirement(Expr *E, SourceLocation NoexceptLoc); - concepts::Requirement *ActOnCompoundRequirement( + concepts::Requirement * + ActOnCompoundRequirement( Expr *E, SourceLocation NoexceptLoc, CXXScopeSpec &SS, TemplateIdAnnotation *TypeConstraint, unsigned Depth); concepts::Requirement *ActOnNestedRequirement(Expr *Constraint); - concepts::ExprRequirement *BuildExprRequirement( + concepts::ExprRequirement * + BuildExprRequirement( Expr *E, bool IsSatisfied, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement ReturnTypeRequirement); - concepts::ExprRequirement *BuildExprRequirement( + concepts::ExprRequirement * + BuildExprRequirement( concepts::Requirement::SubstitutionDiagnostic *ExprSubstDiag, bool IsSatisfied, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement ReturnTypeRequirement); concepts::TypeRequirement *BuildTypeRequirement(TypeSourceInfo *Type); - concepts::TypeRequirement *BuildTypeRequirement( + concepts::TypeRequirement * + BuildTypeRequirement( concepts::Requirement::SubstitutionDiagnostic *SubstDiag); concepts::NestedRequirement *BuildNestedRequirement(Expr *E); - concepts::NestedRequirement *BuildNestedRequirement( + concepts::NestedRequirement * + BuildNestedRequirement( concepts::Requirement::SubstitutionDiagnostic *SubstDiag); ExprResult ActOnRequiresExpr(SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, @@ -8278,9 +8564,9 @@ class Sema final { /// \param Unexpanded the set of unexpanded parameter packs. /// /// \returns true if an error occurred, false otherwise. - bool DiagnoseUnexpandedParameterPacks( - SourceLocation Loc, UnexpandedParameterPackContext UPPC, - ArrayRef Unexpanded); + bool DiagnoseUnexpandedParameterPacks(SourceLocation Loc, + UnexpandedParameterPackContext UPPC, + ArrayRef Unexpanded); /// If the given type contains an unexpanded parameter pack, /// diagnose the error. @@ -8301,8 +8587,8 @@ class Sema final { /// parameter packs. /// /// \returns true if an error occurred, false otherwise. - bool DiagnoseUnexpandedParameterPack( - Expr *E, UnexpandedParameterPackContext UPPC = UPPC_Expression); + bool DiagnoseUnexpandedParameterPack(Expr *E, + UnexpandedParameterPackContext UPPC = UPPC_Expression); /// If the given requirees-expression contains an unexpanded reference to one /// of its own parameter packs, diagnose the error. @@ -8361,52 +8647,48 @@ class Sema final { /// /// \param Arg The template argument that will be traversed to find /// unexpanded parameter packs. - void collectUnexpandedParameterPacks( - TemplateArgument Arg, - SmallVectorImpl &Unexpanded); + void collectUnexpandedParameterPacks(TemplateArgument Arg, + SmallVectorImpl &Unexpanded); /// Collect the set of unexpanded parameter packs within the given /// template argument. /// /// \param Arg The template argument that will be traversed to find /// unexpanded parameter packs. - void collectUnexpandedParameterPacks( - TemplateArgumentLoc Arg, - SmallVectorImpl &Unexpanded); + void collectUnexpandedParameterPacks(TemplateArgumentLoc Arg, + SmallVectorImpl &Unexpanded); /// Collect the set of unexpanded parameter packs within the given /// type. /// /// \param T The type that will be traversed to find /// unexpanded parameter packs. - void collectUnexpandedParameterPacks( - QualType T, SmallVectorImpl &Unexpanded); + void collectUnexpandedParameterPacks(QualType T, + SmallVectorImpl &Unexpanded); /// Collect the set of unexpanded parameter packs within the given /// type. /// /// \param TL The type that will be traversed to find /// unexpanded parameter packs. - void collectUnexpandedParameterPacks( - TypeLoc TL, SmallVectorImpl &Unexpanded); + void collectUnexpandedParameterPacks(TypeLoc TL, + SmallVectorImpl &Unexpanded); /// Collect the set of unexpanded parameter packs within the given /// nested-name-specifier. /// /// \param NNS The nested-name-specifier that will be traversed to find /// unexpanded parameter packs. - void collectUnexpandedParameterPacks( - NestedNameSpecifierLoc NNS, - SmallVectorImpl &Unexpanded); + void collectUnexpandedParameterPacks(NestedNameSpecifierLoc NNS, + SmallVectorImpl &Unexpanded); /// Collect the set of unexpanded parameter packs within the given /// name. /// /// \param NameInfo The name that will be traversed to find /// unexpanded parameter packs. - void collectUnexpandedParameterPacks( - const DeclarationNameInfo &NameInfo, - SmallVectorImpl &Unexpanded); + void collectUnexpandedParameterPacks(const DeclarationNameInfo &NameInfo, + SmallVectorImpl &Unexpanded); /// Invoked when parsing a template argument followed by an /// ellipsis, which creates a pack expansion. @@ -8435,7 +8717,8 @@ class Sema final { /// Construct a pack expansion type from the pattern of the pack /// expansion. - QualType CheckPackExpansion(QualType Pattern, SourceRange PatternRange, + QualType CheckPackExpansion(QualType Pattern, + SourceRange PatternRange, SourceLocation EllipsisLoc, Optional NumExpansions); @@ -8492,11 +8775,13 @@ class Sema final { /// are to be instantiated with arguments of different lengths), false /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions) /// must be set. - bool CheckParameterPacksForExpansion( - SourceLocation EllipsisLoc, SourceRange PatternRange, - ArrayRef Unexpanded, - const MultiLevelTemplateArgumentList &TemplateArgs, bool &ShouldExpand, - bool &RetainExpansion, Optional &NumExpansions); + bool CheckParameterPacksForExpansion(SourceLocation EllipsisLoc, + SourceRange PatternRange, + ArrayRef Unexpanded, + const MultiLevelTemplateArgumentList &TemplateArgs, + bool &ShouldExpand, + bool &RetainExpansion, + Optional &NumExpansions); /// Determine the number of arguments in the given pack expansion /// type. @@ -8505,8 +8790,8 @@ class Sema final { /// consistent across all of the unexpanded parameter packs in its pattern. /// /// Returns an empty Optional if the type can't be expanded. - Optional getNumArgumentsInExpansion( - QualType T, const MultiLevelTemplateArgumentList &TemplateArgs); + Optional getNumArgumentsInExpansion(QualType T, + const MultiLevelTemplateArgumentList &TemplateArgs); /// Determine whether the given declarator contains any unexpanded /// parameter packs. @@ -8534,7 +8819,8 @@ class Sema final { /// \param NumExpansions Will be set to the number of expansions that will /// be generated from this pack expansion, if known a priori. TemplateArgumentLoc getTemplateArgumentPackExpansionPattern( - TemplateArgumentLoc OrigLoc, SourceLocation &Ellipsis, + TemplateArgumentLoc OrigLoc, + SourceLocation &Ellipsis, Optional &NumExpansions) const; /// Given a template argument that contains an unexpanded parameter pack, but @@ -8661,7 +8947,7 @@ class Sema final { sema::TemplateDeductionInfo &Info, SmallVectorImpl const *OriginalCallArgs = nullptr, bool PartialOverloading = false, - llvm::function_ref CheckNonDependent = [] { return false; }); + llvm::function_ref CheckNonDependent = []{ return false; }); TemplateDeductionResult DeduceTemplateArguments( FunctionTemplateDecl *FunctionTemplate, @@ -8670,15 +8956,18 @@ class Sema final { bool PartialOverloading, llvm::function_ref)> CheckNonDependent); - TemplateDeductionResult DeduceTemplateArguments( - FunctionTemplateDecl *FunctionTemplate, - TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ArgFunctionType, - FunctionDecl *&Specialization, sema::TemplateDeductionInfo &Info, - bool IsAddressOfFunction = false); + TemplateDeductionResult + DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, + TemplateArgumentListInfo *ExplicitTemplateArgs, + QualType ArgFunctionType, + FunctionDecl *&Specialization, + sema::TemplateDeductionInfo &Info, + bool IsAddressOfFunction = false); TemplateDeductionResult DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, - QualType ToType, CXXConversionDecl *&Specialization, + QualType ToType, + CXXConversionDecl *&Specialization, sema::TemplateDeductionInfo &Info); TemplateDeductionResult @@ -8691,7 +8980,7 @@ class Sema final { /// Substitute Replacement for \p auto in \p TypeWithAuto QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement); /// Substitute Replacement for auto in TypeWithAuto - TypeSourceInfo *SubstAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto, + TypeSourceInfo* SubstAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto, QualType Replacement); // Substitute auto in TypeWithAuto for a Dependent auto type @@ -8743,15 +9032,17 @@ class Sema final { UnresolvedSetIterator getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd, TemplateSpecCandidateSet &FailedCandidates, - SourceLocation Loc, const PartialDiagnostic &NoneDiag, + SourceLocation Loc, + const PartialDiagnostic &NoneDiag, const PartialDiagnostic &AmbigDiag, const PartialDiagnostic &CandidateDiag, bool Complain = true, QualType TargetType = QualType()); ClassTemplatePartialSpecializationDecl * getMoreSpecializedPartialSpecialization( - ClassTemplatePartialSpecializationDecl *PS1, - ClassTemplatePartialSpecializationDecl *PS2, SourceLocation Loc); + ClassTemplatePartialSpecializationDecl *PS1, + ClassTemplatePartialSpecializationDecl *PS2, + SourceLocation Loc); bool isMoreSpecializedThanPrimary(ClassTemplatePartialSpecializationDecl *T, sema::TemplateDeductionInfo &Info); @@ -8770,17 +9061,17 @@ class Sema final { unsigned Depth, llvm::SmallBitVector &Used); void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs, - bool OnlyDeduced, unsigned Depth, + bool OnlyDeduced, + unsigned Depth, llvm::SmallBitVector &Used); - void - MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, - llvm::SmallBitVector &Deduced) { + void MarkDeducedTemplateParameters( + const FunctionTemplateDecl *FunctionTemplate, + llvm::SmallBitVector &Deduced) { return MarkDeducedTemplateParameters(Context, FunctionTemplate, Deduced); } - static void - MarkDeducedTemplateParameters(ASTContext &Ctx, - const FunctionTemplateDecl *FunctionTemplate, - llvm::SmallBitVector &Deduced); + static void MarkDeducedTemplateParameters(ASTContext &Ctx, + const FunctionTemplateDecl *FunctionTemplate, + llvm::SmallBitVector &Deduced); //===--------------------------------------------------------------------===// // C++ Template Instantiation @@ -8974,21 +9265,21 @@ class Sema final { /// Extra modules inspected when performing a lookup during a template /// instantiation. Computed lazily. - SmallVector CodeSynthesisContextLookupModules; + SmallVector CodeSynthesisContextLookupModules; /// Cache of additional modules that should be used for name lookup /// within the current template instantiation. Computed lazily; use /// getLookupModules() to get a complete set. - llvm::DenseSet LookupModulesCache; + llvm::DenseSet LookupModulesCache; /// Get the set of additional modules that should be checked during /// name lookup. A module and its imports become visible when instanting a /// template defined within it. - llvm::DenseSet &getLookupModules(); + llvm::DenseSet &getLookupModules(); /// Map from the most recent declaration of a namespace to the most /// recent visible declaration of that namespace. - llvm::DenseMap VisibleNamespaceCache; + llvm::DenseMap VisibleNamespaceCache; /// Whether we are in a SFINAE context that is not associated with /// template instantiation. @@ -9040,7 +9331,7 @@ class Sema final { public: ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex) - : Self(Self), OldSubstitutionIndex(Self.ArgumentPackSubstitutionIndex) { + : Self(Self), OldSubstitutionIndex(Self.ArgumentPackSubstitutionIndex) { Self.ArgumentPackSubstitutionIndex = NewSubstitutionIndex; } @@ -9056,8 +9347,8 @@ class Sema final { /// deduction. /// /// FIXME: Serialize this structure to the AST file. - typedef llvm::DenseMap> - SuppressedDiagnosticsMap; + typedef llvm::DenseMap > + SuppressedDiagnosticsMap; SuppressedDiagnosticsMap SuppressedDiagnostics; /// A stack object to be created when performing template @@ -9138,21 +9429,24 @@ class Sema final { /// Note that we are substituting prior template arguments into a /// non-type parameter. InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, - NamedDecl *Template, NonTypeTemplateParmDecl *Param, + NamedDecl *Template, + NonTypeTemplateParmDecl *Param, ArrayRef TemplateArgs, SourceRange InstantiationRange); /// Note that we are substituting prior template arguments into a /// template template parameter. InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, - NamedDecl *Template, TemplateTemplateParmDecl *Param, + NamedDecl *Template, + TemplateTemplateParmDecl *Param, ArrayRef TemplateArgs, SourceRange InstantiationRange); /// Note that we are checking the default template argument /// against the template parameter for a given template-id. InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, - TemplateDecl *Template, NamedDecl *Param, + TemplateDecl *Template, + NamedDecl *Param, ArrayRef TemplateArgs, SourceRange InstantiationRange); @@ -9225,17 +9519,17 @@ class Sema final { bool CheckInstantiationDepth(SourceLocation PointOfInstantiation, SourceRange InstantiationRange); - InstantiatingTemplate(Sema &SemaRef, - CodeSynthesisContext::SynthesisKind Kind, - SourceLocation PointOfInstantiation, - SourceRange InstantiationRange, Decl *Entity, - NamedDecl *Template = nullptr, - ArrayRef TemplateArgs = None, - sema::TemplateDeductionInfo *DeductionInfo = nullptr); + InstantiatingTemplate( + Sema &SemaRef, CodeSynthesisContext::SynthesisKind Kind, + SourceLocation PointOfInstantiation, SourceRange InstantiationRange, + Decl *Entity, NamedDecl *Template = nullptr, + ArrayRef TemplateArgs = None, + sema::TemplateDeductionInfo *DeductionInfo = nullptr); - InstantiatingTemplate(const InstantiatingTemplate &) = delete; + InstantiatingTemplate(const InstantiatingTemplate&) = delete; - InstantiatingTemplate &operator=(const InstantiatingTemplate &) = delete; + InstantiatingTemplate& + operator=(const InstantiatingTemplate&) = delete; }; void pushCodeSynthesisContext(CodeSynthesisContext Ctx); @@ -9295,12 +9589,13 @@ class Sema final { public: explicit SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE = false) - : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors), - PrevInNonInstantiationSFINAEContext( - SemaRef.InNonInstantiationSFINAEContext), - PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE), - PrevLastDiagnosticIgnored( - SemaRef.getDiagnostics().isLastDiagnosticIgnored()) { + : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors), + PrevInNonInstantiationSFINAEContext( + SemaRef.InNonInstantiationSFINAEContext), + PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE), + PrevLastDiagnosticIgnored( + SemaRef.getDiagnostics().isLastDiagnosticIgnored()) + { if (!SemaRef.isSFINAEContext()) SemaRef.InNonInstantiationSFINAEContext = true; SemaRef.AccessCheckingSFINAE = AccessCheckingSFINAE; @@ -9308,8 +9603,8 @@ class Sema final { ~SFINAETrap() { SemaRef.NumSFINAEErrors = PrevSFINAEErrors; - SemaRef.InNonInstantiationSFINAEContext = - PrevInNonInstantiationSFINAEContext; + SemaRef.InNonInstantiationSFINAEContext + = PrevInNonInstantiationSFINAEContext; SemaRef.AccessCheckingSFINAE = PrevAccessCheckingSFINAE; SemaRef.getDiagnostics().setLastDiagnosticIgnored( PrevLastDiagnosticIgnored); @@ -9330,7 +9625,6 @@ class Sema final { // FIXME: Using a SFINAETrap for this is a hack. SFINAETrap Trap; bool PrevDisableTypoCorrection; - public: explicit TentativeAnalysisScope(Sema &SemaRef) : SemaRef(SemaRef), Trap(SemaRef, true), @@ -9387,8 +9681,7 @@ class Sema final { public: GlobalEagerInstantiationScope(Sema &S, bool Enabled) : S(S), Enabled(Enabled) { - if (!Enabled) - return; + if (!Enabled) return; SavedPendingInstantiations.swap(S.PendingInstantiations); SavedVTableUses.swap(S.VTableUses); @@ -9402,8 +9695,7 @@ class Sema final { } ~GlobalEagerInstantiationScope() { - if (!Enabled) - return; + if (!Enabled) return; // Restore the set of pending vtables. assert(S.VTableUses.empty() && @@ -9483,8 +9775,7 @@ class Sema final { /// ExtParameterInfo array we've built up. const FunctionProtoType::ExtParameterInfo * getPointerOrNull(unsigned numParams) { - if (!HasInteresting) - return nullptr; + if (!HasInteresting) return nullptr; Infos.resize(numParams); return Infos.data(); } @@ -9588,17 +9879,21 @@ class Sema final { FunctionDecl *SubstSpaceshipAsEqualEqual(CXXRecordDecl *RD, FunctionDecl *Spaceship); - ExprResult - SubstInitializer(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs, - bool CXXDirectInit); + ExprResult SubstInitializer(Expr *E, + const MultiLevelTemplateArgumentList &TemplateArgs, + bool CXXDirectInit); - bool SubstBaseSpecifiers(CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, - const MultiLevelTemplateArgumentList &TemplateArgs); + bool + SubstBaseSpecifiers(CXXRecordDecl *Instantiation, + CXXRecordDecl *Pattern, + const MultiLevelTemplateArgumentList &TemplateArgs); - bool InstantiateClass(SourceLocation PointOfInstantiation, - CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, - const MultiLevelTemplateArgumentList &TemplateArgs, - TemplateSpecializationKind TSK, bool Complain = true); + bool + InstantiateClass(SourceLocation PointOfInstantiation, + CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, + const MultiLevelTemplateArgumentList &TemplateArgs, + TemplateSpecializationKind TSK, + bool Complain = true); bool InstantiateEnum(SourceLocation PointOfInstantiation, EnumDecl *Instantiation, EnumDecl *Pattern, @@ -9616,7 +9911,8 @@ class Sema final { LateInstantiatedAttribute(const Attr *A, LocalInstantiationScope *S, Decl *D) - : TmplAttr(A), Scope(S), NewDecl(D) {} + : TmplAttr(A), Scope(S), NewDecl(D) + { } }; typedef SmallVector LateInstantiatedAttrVec; @@ -9636,25 +9932,25 @@ class Sema final { bool usesPartialOrExplicitSpecialization( SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec); - bool InstantiateClassTemplateSpecialization( - SourceLocation PointOfInstantiation, - ClassTemplateSpecializationDecl *ClassTemplateSpec, - TemplateSpecializationKind TSK, bool Complain = true); + bool + InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, + ClassTemplateSpecializationDecl *ClassTemplateSpec, + TemplateSpecializationKind TSK, + bool Complain = true); - void - InstantiateClassMembers(SourceLocation PointOfInstantiation, - CXXRecordDecl *Instantiation, - const MultiLevelTemplateArgumentList &TemplateArgs, - TemplateSpecializationKind TSK); + void InstantiateClassMembers(SourceLocation PointOfInstantiation, + CXXRecordDecl *Instantiation, + const MultiLevelTemplateArgumentList &TemplateArgs, + TemplateSpecializationKind TSK); void InstantiateClassTemplateSpecializationMembers( - SourceLocation PointOfInstantiation, - ClassTemplateSpecializationDecl *ClassTemplateSpec, - TemplateSpecializationKind TSK); + SourceLocation PointOfInstantiation, + ClassTemplateSpecializationDecl *ClassTemplateSpec, + TemplateSpecializationKind TSK); - NestedNameSpecifierLoc SubstNestedNameSpecifierLoc( - NestedNameSpecifierLoc NNS, - const MultiLevelTemplateArgumentList &TemplateArgs); + NestedNameSpecifierLoc + SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, + const MultiLevelTemplateArgumentList &TemplateArgs); DeclarationNameInfo SubstDeclarationNameInfo(const DeclarationNameInfo &NameInfo, @@ -9712,16 +10008,14 @@ class Sema final { bool DefinitionRequired = false, bool AtEndOfTU = false); - void InstantiateMemInitializers( - CXXConstructorDecl *New, const CXXConstructorDecl *Tmpl, - const MultiLevelTemplateArgumentList &TemplateArgs); + void InstantiateMemInitializers(CXXConstructorDecl *New, + const CXXConstructorDecl *Tmpl, + const MultiLevelTemplateArgumentList &TemplateArgs); - NamedDecl * - FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, - const MultiLevelTemplateArgumentList &TemplateArgs, - bool FindingInstantiatedContext = false); - DeclContext * - FindInstantiatedContext(SourceLocation Loc, DeclContext *DC, + NamedDecl *FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, + const MultiLevelTemplateArgumentList &TemplateArgs, + bool FindingInstantiatedContext = false); + DeclContext *FindInstantiatedContext(SourceLocation Loc, DeclContext *DC, const MultiLevelTemplateArgumentList &TemplateArgs); // Objective-C declarations. @@ -9736,11 +10030,14 @@ class Sema final { }; ObjCContainerKind getObjCContainerKind() const; - DeclResult actOnObjCTypeParam(Scope *S, ObjCTypeParamVariance variance, - SourceLocation varianceLoc, unsigned index, + DeclResult actOnObjCTypeParam(Scope *S, + ObjCTypeParamVariance variance, + SourceLocation varianceLoc, + unsigned index, IdentifierInfo *paramName, SourceLocation paramLoc, - SourceLocation colonLoc, ParsedType typeBound); + SourceLocation colonLoc, + ParsedType typeBound); ObjCTypeParamList *actOnObjCTypeParamList(Scope *S, SourceLocation lAngleLoc, ArrayRef typeParams, @@ -9756,26 +10053,30 @@ class Sema final { const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList); - void ActOnSuperClassOfClassInterface( - Scope *S, SourceLocation AtInterfaceLoc, ObjCInterfaceDecl *IDecl, - IdentifierInfo *ClassName, SourceLocation ClassLoc, - IdentifierInfo *SuperName, SourceLocation SuperLoc, - ArrayRef SuperTypeArgs, SourceRange SuperTypeArgsRange); + void ActOnSuperClassOfClassInterface(Scope *S, + SourceLocation AtInterfaceLoc, + ObjCInterfaceDecl *IDecl, + IdentifierInfo *ClassName, + SourceLocation ClassLoc, + IdentifierInfo *SuperName, + SourceLocation SuperLoc, + ArrayRef SuperTypeArgs, + SourceRange SuperTypeArgsRange); void ActOnTypedefedProtocols(SmallVectorImpl &ProtocolRefs, SmallVectorImpl &ProtocolLocs, IdentifierInfo *SuperName, SourceLocation SuperLoc); - Decl *ActOnCompatibilityAlias(SourceLocation AtCompatibilityAliasLoc, - IdentifierInfo *AliasName, - SourceLocation AliasLocation, - IdentifierInfo *ClassName, - SourceLocation ClassLocation); + Decl *ActOnCompatibilityAlias( + SourceLocation AtCompatibilityAliasLoc, + IdentifierInfo *AliasName, SourceLocation AliasLocation, + IdentifierInfo *ClassName, SourceLocation ClassLocation); bool CheckForwardProtocolDeclarationForCircularDependency( - IdentifierInfo *PName, SourceLocation &PLoc, SourceLocation PrevLoc, - const ObjCList &PList); + IdentifierInfo *PName, + SourceLocation &PLoc, SourceLocation PrevLoc, + const ObjCList &PList); ObjCProtocolDecl *ActOnStartProtocolInterface( SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName, @@ -9804,9 +10105,11 @@ class Sema final { DeclGroupPtrTy ActOnFinishObjCImplementation(Decl *ObjCImpDecl, ArrayRef Decls); - DeclGroupPtrTy ActOnForwardClassDeclaration( - SourceLocation Loc, IdentifierInfo **IdentList, SourceLocation *IdentLocs, - ArrayRef TypeParamLists, unsigned NumElts); + DeclGroupPtrTy ActOnForwardClassDeclaration(SourceLocation Loc, + IdentifierInfo **IdentList, + SourceLocation *IdentLocs, + ArrayRef TypeParamLists, + unsigned NumElts); DeclGroupPtrTy ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc, @@ -9827,27 +10130,40 @@ class Sema final { /// names to either Objective-C protocol qualifiers or type /// arguments, as appropriate. void actOnObjCTypeArgsOrProtocolQualifiers( - Scope *S, ParsedType baseType, SourceLocation lAngleLoc, - ArrayRef identifiers, - ArrayRef identifierLocs, SourceLocation rAngleLoc, - SourceLocation &typeArgsLAngleLoc, SmallVectorImpl &typeArgs, - SourceLocation &typeArgsRAngleLoc, SourceLocation &protocolLAngleLoc, - SmallVectorImpl &protocols, SourceLocation &protocolRAngleLoc, - bool warnOnIncompleteProtocols); + Scope *S, + ParsedType baseType, + SourceLocation lAngleLoc, + ArrayRef identifiers, + ArrayRef identifierLocs, + SourceLocation rAngleLoc, + SourceLocation &typeArgsLAngleLoc, + SmallVectorImpl &typeArgs, + SourceLocation &typeArgsRAngleLoc, + SourceLocation &protocolLAngleLoc, + SmallVectorImpl &protocols, + SourceLocation &protocolRAngleLoc, + bool warnOnIncompleteProtocols); /// Build a an Objective-C protocol-qualified 'id' type where no /// base type was specified. TypeResult actOnObjCProtocolQualifierType( - SourceLocation lAngleLoc, ArrayRef protocols, - ArrayRef protocolLocs, SourceLocation rAngleLoc); + SourceLocation lAngleLoc, + ArrayRef protocols, + ArrayRef protocolLocs, + SourceLocation rAngleLoc); /// Build a specialized and/or protocol-qualified Objective-C type. TypeResult actOnObjCTypeArgsAndProtocolQualifiers( - Scope *S, SourceLocation Loc, ParsedType BaseType, - SourceLocation TypeArgsLAngleLoc, ArrayRef TypeArgs, - SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, - ArrayRef Protocols, ArrayRef ProtocolLocs, - SourceLocation ProtocolRAngleLoc); + Scope *S, + SourceLocation Loc, + ParsedType BaseType, + SourceLocation TypeArgsLAngleLoc, + ArrayRef TypeArgs, + SourceLocation TypeArgsRAngleLoc, + SourceLocation ProtocolLAngleLoc, + ArrayRef Protocols, + ArrayRef ProtocolLocs, + SourceLocation ProtocolRAngleLoc); /// Build an Objective-C type parameter type. QualType BuildObjCTypeParamType(const ObjCTypeParamDecl *Decl, @@ -9858,17 +10174,22 @@ class Sema final { bool FailOnError = false); /// Build an Objective-C object pointer type. - QualType BuildObjCObjectType( - QualType BaseType, SourceLocation Loc, SourceLocation TypeArgsLAngleLoc, - ArrayRef TypeArgs, SourceLocation TypeArgsRAngleLoc, - SourceLocation ProtocolLAngleLoc, ArrayRef Protocols, - ArrayRef ProtocolLocs, SourceLocation ProtocolRAngleLoc, - bool FailOnError = false); + QualType BuildObjCObjectType(QualType BaseType, + SourceLocation Loc, + SourceLocation TypeArgsLAngleLoc, + ArrayRef TypeArgs, + SourceLocation TypeArgsRAngleLoc, + SourceLocation ProtocolLAngleLoc, + ArrayRef Protocols, + ArrayRef ProtocolLocs, + SourceLocation ProtocolRAngleLoc, + bool FailOnError = false); /// Ensure attributes are consistent with type. /// \param [in, out] Attributes The attributes to check; they will /// be modified to be consistent with \p PropertyTy. - void CheckObjCPropertyAttributes(Decl *PropertyPtrTy, SourceLocation Loc, + void CheckObjCPropertyAttributes(Decl *PropertyPtrTy, + SourceLocation Loc, unsigned &Attributes, bool propertyInPrimaryClass); @@ -9877,6 +10198,7 @@ class Sema final { /// \param property The property declaration being processed void ProcessPropertyDecl(ObjCPropertyDecl *property); + void DiagnosePropertyMismatch(ObjCPropertyDecl *Property, ObjCPropertyDecl *SuperProperty, const IdentifierInfo *Name, @@ -9889,14 +10211,17 @@ class Sema final { ArrayRef allMethods = None, ArrayRef allTUVars = None); - Decl *ActOnProperty(Scope *S, SourceLocation AtLoc, SourceLocation LParenLoc, + Decl *ActOnProperty(Scope *S, SourceLocation AtLoc, + SourceLocation LParenLoc, FieldDeclarator &FD, ObjCDeclSpec &ODS, Selector GetterSel, Selector SetterSel, tok::ObjCKeywordKind MethodImplKind, DeclContext *lexicalDC = nullptr); - Decl *ActOnPropertyImplDecl(Scope *S, SourceLocation AtLoc, - SourceLocation PropertyLoc, bool ImplKind, + Decl *ActOnPropertyImplDecl(Scope *S, + SourceLocation AtLoc, + SourceLocation PropertyLoc, + bool ImplKind, IdentifierInfo *PropertyId, IdentifierInfo *PropertyIvar, SourceLocation PropertyIvarLoc, @@ -9947,17 +10272,20 @@ class Sema final { void deduceOpenCLAddressSpace(ValueDecl *decl); - ExprResult HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, - Expr *BaseExpr, SourceLocation OpLoc, - DeclarationName MemberName, - SourceLocation MemberLoc, - SourceLocation SuperLoc, - QualType SuperType, bool Super); + ExprResult + HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, + Expr *BaseExpr, + SourceLocation OpLoc, + DeclarationName MemberName, + SourceLocation MemberLoc, + SourceLocation SuperLoc, QualType SuperType, + bool Super); - ExprResult ActOnClassPropertyRefExpr(IdentifierInfo &receiverName, - IdentifierInfo &propertyName, - SourceLocation receiverNameLoc, - SourceLocation propertyNameLoc); + ExprResult + ActOnClassPropertyRefExpr(IdentifierInfo &receiverName, + IdentifierInfo &propertyName, + SourceLocation receiverNameLoc, + SourceLocation propertyNameLoc); ObjCMethodDecl *tryCaptureObjCSelf(SourceLocation Loc); @@ -9973,61 +10301,84 @@ class Sema final { ObjCClassMessage }; - ObjCMessageKind getObjCMessageKind(Scope *S, IdentifierInfo *Name, - SourceLocation NameLoc, bool IsSuper, + ObjCMessageKind getObjCMessageKind(Scope *S, + IdentifierInfo *Name, + SourceLocation NameLoc, + bool IsSuper, bool HasTrailingDot, ParsedType &ReceiverType); - ExprResult ActOnSuperMessage(Scope *S, SourceLocation SuperLoc, Selector Sel, + ExprResult ActOnSuperMessage(Scope *S, SourceLocation SuperLoc, + Selector Sel, SourceLocation LBracLoc, ArrayRef SelectorLocs, - SourceLocation RBracLoc, MultiExprArg Args); + SourceLocation RBracLoc, + MultiExprArg Args); ExprResult BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, - QualType ReceiverType, SourceLocation SuperLoc, - Selector Sel, ObjCMethodDecl *Method, + QualType ReceiverType, + SourceLocation SuperLoc, + Selector Sel, + ObjCMethodDecl *Method, SourceLocation LBracLoc, ArrayRef SelectorLocs, - SourceLocation RBracLoc, MultiExprArg Args, + SourceLocation RBracLoc, + MultiExprArg Args, bool isImplicit = false); ExprResult BuildClassMessageImplicit(QualType ReceiverType, - bool isSuperReceiver, SourceLocation Loc, - Selector Sel, ObjCMethodDecl *Method, + bool isSuperReceiver, + SourceLocation Loc, + Selector Sel, + ObjCMethodDecl *Method, MultiExprArg Args); - ExprResult ActOnClassMessage(Scope *S, ParsedType Receiver, Selector Sel, + ExprResult ActOnClassMessage(Scope *S, + ParsedType Receiver, + Selector Sel, SourceLocation LBracLoc, ArrayRef SelectorLocs, - SourceLocation RBracLoc, MultiExprArg Args); + SourceLocation RBracLoc, + MultiExprArg Args); - ExprResult BuildInstanceMessage(Expr *Receiver, QualType ReceiverType, - SourceLocation SuperLoc, Selector Sel, + ExprResult BuildInstanceMessage(Expr *Receiver, + QualType ReceiverType, + SourceLocation SuperLoc, + Selector Sel, ObjCMethodDecl *Method, SourceLocation LBracLoc, ArrayRef SelectorLocs, - SourceLocation RBracLoc, MultiExprArg Args, + SourceLocation RBracLoc, + MultiExprArg Args, bool isImplicit = false); - ExprResult BuildInstanceMessageImplicit(Expr *Receiver, QualType ReceiverType, - SourceLocation Loc, Selector Sel, + ExprResult BuildInstanceMessageImplicit(Expr *Receiver, + QualType ReceiverType, + SourceLocation Loc, + Selector Sel, ObjCMethodDecl *Method, MultiExprArg Args); - ExprResult ActOnInstanceMessage(Scope *S, Expr *Receiver, Selector Sel, + ExprResult ActOnInstanceMessage(Scope *S, + Expr *Receiver, + Selector Sel, SourceLocation LBracLoc, ArrayRef SelectorLocs, - SourceLocation RBracLoc, MultiExprArg Args); + SourceLocation RBracLoc, + MultiExprArg Args); ExprResult BuildObjCBridgedCast(SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, - TypeSourceInfo *TSInfo, Expr *SubExpr); + TypeSourceInfo *TSInfo, + Expr *SubExpr); - ExprResult ActOnObjCBridgedCast(Scope *S, SourceLocation LParenLoc, + ExprResult ActOnObjCBridgedCast(Scope *S, + SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, - ParsedType Type, SourceLocation RParenLoc, + ParsedType Type, + SourceLocation RParenLoc, Expr *SubExpr); void CheckTollFreeBridgeCast(QualType castType, Expr *castExpr); @@ -10037,17 +10388,17 @@ class Sema final { bool CheckTollFreeBridgeStaticCast(QualType castType, Expr *castExpr, CastKind &Kind); - bool checkObjCBridgeRelatedComponents(SourceLocation Loc, QualType DestType, - QualType SrcType, + bool checkObjCBridgeRelatedComponents(SourceLocation Loc, + QualType DestType, QualType SrcType, ObjCInterfaceDecl *&RelatedClass, ObjCMethodDecl *&ClassMethod, ObjCMethodDecl *&InstanceMethod, - TypedefNameDecl *&TDNDecl, bool CfToNs, - bool Diagnose = true); + TypedefNameDecl *&TDNDecl, + bool CfToNs, bool Diagnose = true); - bool CheckObjCBridgeRelatedConversions(SourceLocation Loc, QualType DestType, - QualType SrcType, Expr *&SrcExpr, - bool Diagnose = true); + bool CheckObjCBridgeRelatedConversions(SourceLocation Loc, + QualType DestType, QualType SrcType, + Expr *&SrcExpr, bool Diagnose = true); bool CheckConversionToObjCLiteral(QualType DstType, Expr *&SrcExpr, bool Diagnose = true); @@ -10085,8 +10436,7 @@ class Sema final { /// ActOnPragmaClangSection - Called on well formed \#pragma clang section void ActOnPragmaClangSection(SourceLocation PragmaLoc, PragmaClangSectionAction Action, - PragmaClangSectionKind SecKind, - StringRef SecName); + PragmaClangSectionKind SecKind, StringRef SecName); /// ActOnPragmaOptionsAlign - Called on well formed \#pragma options align. void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind, @@ -10128,7 +10478,8 @@ class Sema final { /// Called on well formed \#pragma vtordisp(). void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action, - SourceLocation PragmaLoc, MSVtorDispMode Value); + SourceLocation PragmaLoc, + MSVtorDispMode Value); enum PragmaSectionKind { PSK_DataSeg, @@ -10139,18 +10490,20 @@ class Sema final { bool UnifySection(StringRef SectionName, int SectionFlags, NamedDecl *TheDecl); - bool UnifySection(StringRef SectionName, int SectionFlags, + bool UnifySection(StringRef SectionName, + int SectionFlags, SourceLocation PragmaSectionLocation); /// Called on well formed \#pragma bss_seg/data_seg/const_seg/code_seg. void ActOnPragmaMSSeg(SourceLocation PragmaLocation, PragmaMsStackAction Action, llvm::StringRef StackSlotLabel, - StringLiteral *SegmentName, llvm::StringRef PragmaName); + StringLiteral *SegmentName, + llvm::StringRef PragmaName); /// Called on well formed \#pragma section(). - void ActOnPragmaMSSection(SourceLocation PragmaLocation, int SectionFlags, - StringLiteral *SegmentName); + void ActOnPragmaMSSection(SourceLocation PragmaLocation, + int SectionFlags, StringLiteral *SegmentName); /// Called on well-formed \#pragma init_seg(). void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation, @@ -10185,11 +10538,12 @@ class Sema final { PragmaFloatControlKind Value); /// ActOnPragmaUnused - Called on well-formed '\#pragma unused'. - void ActOnPragmaUnused(const Token &Identifier, Scope *curScope, + void ActOnPragmaUnused(const Token &Identifier, + Scope *curScope, SourceLocation PragmaLoc); /// ActOnPragmaVisibility - Called on well formed \#pragma GCC visibility... . - void ActOnPragmaVisibility(const IdentifierInfo *VisType, + void ActOnPragmaVisibility(const IdentifierInfo* VisType, SourceLocation PragmaLoc); NamedDecl *DeclClonePragmaWeak(NamedDecl *ND, const IdentifierInfo *II, @@ -10197,19 +10551,21 @@ class Sema final { void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W); /// ActOnPragmaWeakID - Called on well formed \#pragma weak ident. - void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc, + void ActOnPragmaWeakID(IdentifierInfo* WeakName, + SourceLocation PragmaLoc, SourceLocation WeakNameLoc); /// ActOnPragmaRedefineExtname - Called on well formed /// \#pragma redefine_extname oldname newname. - void ActOnPragmaRedefineExtname(IdentifierInfo *WeakName, - IdentifierInfo *AliasName, + void ActOnPragmaRedefineExtname(IdentifierInfo* WeakName, + IdentifierInfo* AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc); /// ActOnPragmaWeakAlias - Called on well formed \#pragma weak ident = ident. - void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName, + void ActOnPragmaWeakAlias(IdentifierInfo* WeakName, + IdentifierInfo* AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc); @@ -10366,7 +10722,7 @@ class Sema final { void AddParameterABIAttr(Decl *D, const AttributeCommonInfo &CI, ParameterABI ABI); - enum class RetainOwnershipKind { NS, CF, OS }; + enum class RetainOwnershipKind {NS, CF, OS}; void AddXConsumedAttr(Decl *D, const AttributeCommonInfo &CI, RetainOwnershipKind K, bool IsTemplateInstantiation); @@ -10653,8 +11009,9 @@ class Sema final { const DeclarationNameInfo &Id, OpenMPDirectiveKind Kind); /// Called on well-formed '#pragma omp threadprivate'. - DeclGroupPtrTy ActOnOpenMPThreadprivateDirective(SourceLocation Loc, - ArrayRef VarList); + DeclGroupPtrTy ActOnOpenMPThreadprivateDirective( + SourceLocation Loc, + ArrayRef VarList); /// Builds a new OpenMPThreadPrivateDecl and checks its correctness. OMPThreadPrivateDecl *CheckOMPThreadPrivateDecl(SourceLocation Loc, ArrayRef VarList); @@ -10804,7 +11161,8 @@ class Sema final { /// Called on well-formed '\#pragma omp parallel' after parsing /// of the associated statement. StmtResult ActOnOpenMPParallelDirective(ArrayRef Clauses, - Stmt *AStmt, SourceLocation StartLoc, + Stmt *AStmt, + SourceLocation StartLoc, SourceLocation EndLoc); using VarsWithInheritedDSAType = llvm::SmallDenseMap; @@ -10937,8 +11295,7 @@ class Sema final { /// Called on well-formed '\#pragma omp target data' after parsing of /// the associated statement. StmtResult ActOnOpenMPTargetDataDirective(ArrayRef Clauses, - Stmt *AStmt, - SourceLocation StartLoc, + Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc); /// Called on well-formed '\#pragma omp target enter data' after /// parsing of the associated statement. @@ -11206,7 +11563,8 @@ class Sema final { ArrayRef AppendArgs, SourceLocation AdjustArgsLoc, SourceLocation AppendArgsLoc, SourceRange SR); - OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr, + OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, + Expr *Expr, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc); @@ -11236,7 +11594,8 @@ class Sema final { SourceLocation LParenLoc, SourceLocation EndLoc); /// Called on well-formed 'safelen' clause. - OMPClause *ActOnOpenMPSafelenClause(Expr *Length, SourceLocation StartLoc, + OMPClause *ActOnOpenMPSafelenClause(Expr *Length, + SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc); /// Called on well-formed 'simdlen' clause. @@ -11282,7 +11641,8 @@ class Sema final { SourceLocation LParenLoc, SourceLocation EndLoc); - OMPClause *ActOnOpenMPSimpleClause(OpenMPClauseKind Kind, unsigned Argument, + OMPClause *ActOnOpenMPSimpleClause(OpenMPClauseKind Kind, + unsigned Argument, SourceLocation ArgumentLoc, SourceLocation StartLoc, SourceLocation LParenLoc, @@ -11519,7 +11879,8 @@ class Sema final { OpenMPLinearClauseKind LinKind, SourceLocation LinLoc, SourceLocation ColonLoc, SourceLocation EndLoc); /// Called on well-formed 'aligned' clause. - OMPClause *ActOnOpenMPAlignedClause(ArrayRef VarList, Expr *Alignment, + OMPClause *ActOnOpenMPAlignedClause(ArrayRef VarList, + Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, @@ -11887,7 +12248,8 @@ class Sema final { /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the /// assignment conversion type specified by ConvTy. This returns true if the /// conversion was invalid or false if the conversion was accepted. - bool DiagnoseAssignmentResult(AssignConvertType ConvTy, SourceLocation Loc, + bool DiagnoseAssignmentResult(AssignConvertType ConvTy, + SourceLocation Loc, QualType DstType, QualType SrcType, Expr *SrcExpr, AssignmentAction Action, bool *Complained = nullptr); @@ -11914,7 +12276,8 @@ class Sema final { /// the RHS to the LHS type. The conversion is prepared for if ConvertRHS /// is true. AssignConvertType CheckAssignmentConstraints(QualType LHSType, - ExprResult &RHS, CastKind &Kind, + ExprResult &RHS, + CastKind &Kind, bool ConvertRHS = true); /// Check assignment constraints for an assignment of RHS to LHSType. @@ -11947,13 +12310,13 @@ class Sema final { ExprResult PerformImplicitConversion(Expr *From, QualType ToType, AssignmentAction Action, bool AllowExplicit = false); - ExprResult - PerformImplicitConversion(Expr *From, QualType ToType, - const ImplicitConversionSequence &ICS, - AssignmentAction Action, - CheckedConversionKind CCK = CCK_ImplicitConversion); ExprResult PerformImplicitConversion(Expr *From, QualType ToType, - const StandardConversionSequence &SCS, + const ImplicitConversionSequence& ICS, + AssignmentAction Action, + CheckedConversionKind CCK + = CCK_ImplicitConversion); + ExprResult PerformImplicitConversion(Expr *From, QualType ToType, + const StandardConversionSequence& SCS, AssignmentAction Action, CheckedConversionKind CCK); @@ -11968,25 +12331,25 @@ class Sema final { QualType InvalidOperands(SourceLocation Loc, ExprResult &LHS, ExprResult &RHS); QualType InvalidLogicalVectorOperands(SourceLocation Loc, ExprResult &LHS, - ExprResult &RHS); + ExprResult &RHS); QualType CheckPointerToMemberOperands( // C++ 5.5 - ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, SourceLocation OpLoc, - bool isIndirect); + ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, + SourceLocation OpLoc, bool isIndirect); QualType CheckMultiplyDivideOperands( // C99 6.5.5 - ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, - bool IsDivide); + ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, + bool IsDivide); QualType CheckRemainderOperands( // C99 6.5.5 - ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, - bool IsCompAssign = false); + ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, + bool IsCompAssign = false); QualType CheckAdditionOperands( // C99 6.5.6 - ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, - BinaryOperatorKind Opc, QualType *CompLHSTy = nullptr); + ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, + BinaryOperatorKind Opc, QualType* CompLHSTy = nullptr); QualType CheckSubtractionOperands( // C99 6.5.6 - ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, - QualType *CompLHSTy = nullptr); + ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, + QualType* CompLHSTy = nullptr); QualType CheckShiftOperands( // C99 6.5.7 - ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, - BinaryOperatorKind Opc, bool IsCompAssign = false); + ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, + BinaryOperatorKind Opc, bool IsCompAssign = false); void CheckPtrComparisonWithNullChar(ExprResult &E, ExprResult &NullE); QualType CheckCompareOperands( // C99 6.5.8/9 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, @@ -11995,8 +12358,8 @@ class Sema final { ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc); QualType CheckLogicalOperands( // C99 6.5.[13,14] - ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, - BinaryOperatorKind Opc); + ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, + BinaryOperatorKind Opc); // CheckAssignmentOperands is used for both simple and compound assignment. // For simple assignment, pass both expressions and a null converted type. // For compound assignment, pass both expressions and the converted type. @@ -12007,17 +12370,17 @@ class Sema final { ExprResult checkPseudoObjectIncDec(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opcode, Expr *Op); ExprResult checkPseudoObjectAssignment(Scope *S, SourceLocation OpLoc, - BinaryOperatorKind Opcode, Expr *LHS, - Expr *RHS); + BinaryOperatorKind Opcode, + Expr *LHS, Expr *RHS); ExprResult checkPseudoObjectRValue(Expr *E); Expr *recreateSyntacticForm(PseudoObjectExpr *E); QualType CheckConditionalOperands( // C99 6.5.15 - ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, - ExprObjectKind &OK, SourceLocation QuestionLoc); + ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, + ExprValueKind &VK, ExprObjectKind &OK, SourceLocation QuestionLoc); QualType CXXCheckConditionalOperands( // C++ 5.16 - ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK, - ExprObjectKind &OK, SourceLocation questionLoc); + ExprResult &cond, ExprResult &lhs, ExprResult &rhs, + ExprValueKind &VK, ExprObjectKind &OK, SourceLocation questionLoc); QualType CheckVectorConditionalTypes(ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc); @@ -12027,8 +12390,9 @@ class Sema final { SourceLocation QuestionLoc); QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2, bool ConvertArgs = true); - QualType FindCompositePointerType(SourceLocation Loc, ExprResult &E1, - ExprResult &E2, bool ConvertArgs = true) { + QualType FindCompositePointerType(SourceLocation Loc, + ExprResult &E1, ExprResult &E2, + bool ConvertArgs = true) { Expr *E1Tmp = E1.get(), *E2Tmp = E2.get(); QualType Composite = FindCompositePointerType(Loc, E1Tmp, E2Tmp, ConvertArgs); @@ -12137,8 +12501,8 @@ class Sema final { /// Type-check an expression that's being passed to an /// __unknown_anytype parameter. - ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, - QualType ¶mType); + ExprResult checkUnknownAnyArg(SourceLocation callLoc, + Expr *result, QualType ¶mType); // CheckMatrixCast - Check type constraints for matrix casts. // We allow casting between matrixes of the same dimensions i.e. when they @@ -12180,7 +12544,8 @@ class Sema final { CheckedConversionKind CCK, bool Diagnose = true, bool DiagnoseCFAudited = false, - BinaryOperatorKind Opc = BO_PtrMemD); + BinaryOperatorKind Opc = BO_PtrMemD + ); Expr *stripARCUnbridgedCast(Expr *e); void diagnoseARCUnbridgedCast(Expr *e); @@ -12283,7 +12648,8 @@ class Sema final { DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D); ExprResult CheckConditionVariable(VarDecl *ConditionVar, - SourceLocation StmtLoc, ConditionKind CK); + SourceLocation StmtLoc, + ConditionKind CK); ExprResult CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond); /// CheckBooleanCondition - Diagnose problems involving the use of @@ -12334,7 +12700,7 @@ class Sema final { public: bool Suppress; - VerifyICEDiagnoser(bool Suppress = false) : Suppress(Suppress) {} + VerifyICEDiagnoser(bool Suppress = false) : Suppress(Suppress) { } virtual SemaDiagnosticBuilder diagnoseNotICEType(Sema &S, SourceLocation Loc, QualType T); @@ -12608,7 +12974,8 @@ class Sema final { bool inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl, CXXSpecialMember CSM, CXXMethodDecl *MemberDecl, - bool ConstRHS, bool Diagnose); + bool ConstRHS, + bool Diagnose); /// \return true if \p CD can be considered empty according to CUDA /// (E.2.3.1 in CUDA 7.5 Programming guide). @@ -12688,11 +13055,13 @@ class Sema final { void CodeCompleteModuleImport(SourceLocation ImportLoc, ModuleIdPath Path); void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext); - void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS, bool AllowNonIdentifiers, + void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS, + bool AllowNonIdentifiers, bool AllowNestedNameSpecifiers); struct CodeCompleteExpressionData; - void CodeCompleteExpression(Scope *S, const CodeCompleteExpressionData &Data); + void CodeCompleteExpression(Scope *S, + const CodeCompleteExpressionData &Data); void CodeCompleteExpression(Scope *S, QualType PreferredType, bool IsParenthesized = false); void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, Expr *OtherOpBase, @@ -12754,7 +13123,8 @@ class Sema final { void CodeCompleteNamespaceAliasDecl(Scope *S); void CodeCompleteOperatorName(Scope *S); void CodeCompleteConstructorInitializer( - Decl *Constructor, ArrayRef Initializers); + Decl *Constructor, + ArrayRef Initializers); void CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro, bool AfterAmpersand); @@ -12781,16 +13151,20 @@ class Sema final { ArrayRef SelIdents, bool AtArgumentExpression, ObjCInterfaceDecl *Super = nullptr); - void CodeCompleteObjCForCollection(Scope *S, DeclGroupPtrTy IterationVar); - void CodeCompleteObjCSelector(Scope *S, ArrayRef SelIdents); - void - CodeCompleteObjCProtocolReferences(ArrayRef Protocols); + void CodeCompleteObjCForCollection(Scope *S, + DeclGroupPtrTy IterationVar); + void CodeCompleteObjCSelector(Scope *S, + ArrayRef SelIdents); + void CodeCompleteObjCProtocolReferences( + ArrayRef Protocols); void CodeCompleteObjCProtocolDecl(Scope *S); void CodeCompleteObjCInterfaceDecl(Scope *S); - void CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName, + void CodeCompleteObjCSuperclass(Scope *S, + IdentifierInfo *ClassName, SourceLocation ClassNameLoc); void CodeCompleteObjCImplementationDecl(Scope *S); - void CodeCompleteObjCInterfaceCategory(Scope *S, IdentifierInfo *ClassName, + void CodeCompleteObjCInterfaceCategory(Scope *S, + IdentifierInfo *ClassName, SourceLocation ClassNameLoc); void CodeCompleteObjCImplementationCategory(Scope *S, IdentifierInfo *ClassName, @@ -12800,7 +13174,8 @@ class Sema final { IdentifierInfo *PropertyName); void CodeCompleteObjCMethodDecl(Scope *S, Optional IsInstanceMethod, ParsedType ReturnType); - void CodeCompleteObjCMethodDeclSelector(Scope *S, bool IsInstanceMethod, + void CodeCompleteObjCMethodDeclSelector(Scope *S, + bool IsInstanceMethod, bool AtParameterName, ParsedType ReturnType, ArrayRef SelIdents); @@ -12811,16 +13186,16 @@ class Sema final { void CodeCompleteInPreprocessorConditionalExclusion(Scope *S); void CodeCompletePreprocessorMacroName(bool IsDefinition); void CodeCompletePreprocessorExpression(); - void CodeCompletePreprocessorMacroArgument(Scope *S, IdentifierInfo *Macro, + void CodeCompletePreprocessorMacroArgument(Scope *S, + IdentifierInfo *Macro, MacroInfo *MacroInfo, unsigned Argument); void CodeCompleteIncludedFile(llvm::StringRef Dir, bool IsAngled); void CodeCompleteNaturalLanguage(); void CodeCompleteAvailabilityPlatformName(); - void - GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator, - CodeCompletionTUInfo &CCTUInfo, - SmallVectorImpl &Results); + void GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator, + CodeCompletionTUInfo &CCTUInfo, + SmallVectorImpl &Results); //@} //===--------------------------------------------------------------------===// @@ -12877,8 +13252,8 @@ class Sema final { bool CheckObjCString(Expr *Arg); ExprResult CheckOSLogFormatStringArg(Expr *Arg); - ExprResult CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, - CallExpr *TheCall); + ExprResult CheckBuiltinFunctionCall(FunctionDecl *FDecl, + unsigned BuiltinID, CallExpr *TheCall); bool CheckTSBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, CallExpr *TheCall); @@ -12926,7 +13301,7 @@ class Sema final { bool CheckRISCVBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, CallExpr *TheCall); bool CheckRISCVCOREVBuiltinFunctionCall(unsigned BuiltinID, - CallExpr *TheCall); + CallExpr *TheCall); bool SemaBuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall); bool SemaBuiltinVAStartARMMicrosoft(CallExpr *Call); bool SemaBuiltinUnorderedCompare(CallExpr *TheCall); @@ -13026,17 +13401,21 @@ class Sema final { void CheckMaxUnsignedZero(const CallExpr *Call, const FunctionDecl *FDecl); - void CheckMemaccessArguments(const CallExpr *Call, unsigned BId, + void CheckMemaccessArguments(const CallExpr *Call, + unsigned BId, IdentifierInfo *FnName); - void CheckStrlcpycatArguments(const CallExpr *Call, IdentifierInfo *FnName); + void CheckStrlcpycatArguments(const CallExpr *Call, + IdentifierInfo *FnName); - void CheckStrncatArguments(const CallExpr *Call, IdentifierInfo *FnName); + void CheckStrncatArguments(const CallExpr *Call, + IdentifierInfo *FnName); void CheckFreeArguments(const CallExpr *E); void CheckReturnValExpr(Expr *RetValExp, QualType lhsType, - SourceLocation ReturnLoc, bool isObjCMethod = false, + SourceLocation ReturnLoc, + bool isObjCMethod = false, const AttrVec *Attrs = nullptr, const FunctionDecl *FD = nullptr); @@ -13078,7 +13457,6 @@ class Sema final { void AnalyzeDeleteExprMismatch(const CXXDeleteExpr *DE); void AnalyzeDeleteExprMismatch(FieldDecl *Field, SourceLocation DeleteLoc, bool DeleteWasArrayForm); - public: /// Register a magic integral constant to be used as a type tag. void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind, @@ -13088,9 +13466,10 @@ class Sema final { struct TypeTagData { TypeTagData() {} - TypeTagData(QualType Type, bool LayoutCompatible, bool MustBeNull) - : Type(Type), LayoutCompatible(LayoutCompatible), - MustBeNull(MustBeNull) {} + TypeTagData(QualType Type, bool LayoutCompatible, bool MustBeNull) : + Type(Type), LayoutCompatible(LayoutCompatible), + MustBeNull(MustBeNull) + {} QualType Type; @@ -13209,8 +13588,8 @@ class Sema final { // Emitting members of dllexported classes is delayed until the class // (including field initializers) is fully parsed. - SmallVector DelayedDllExportClasses; - SmallVector DelayedDllExportMemberFunctions; + SmallVector DelayedDllExportClasses; + SmallVector DelayedDllExportMemberFunctions; private: int ParsingClassDepth = 0; diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 4fa78109021c..24fcf4c8b51d 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -372,8 +372,7 @@ static bool SemaBuiltinOverflow(Sema &S, CallExpr *TheCall, // First two arguments should be integers. for (unsigned I = 0; I < 2; ++I) { ExprResult Arg = S.DefaultFunctionArrayLvalueConversion(TheCall->getArg(I)); - if (Arg.isInvalid()) - return true; + if (Arg.isInvalid()) return true; TheCall->setArg(I, Arg.get()); QualType Ty = Arg.get()->getType(); @@ -389,17 +388,17 @@ static bool SemaBuiltinOverflow(Sema &S, CallExpr *TheCall, // the other qualifiers aren't possible. { ExprResult Arg = S.DefaultFunctionArrayLvalueConversion(TheCall->getArg(2)); - if (Arg.isInvalid()) - return true; + if (Arg.isInvalid()) return true; TheCall->setArg(2, Arg.get()); QualType Ty = Arg.get()->getType(); const auto *PtrTy = Ty->getAs(); - if (!PtrTy || !PtrTy->getPointeeType()->isIntegerType() || + if (!PtrTy || + !PtrTy->getPointeeType()->isIntegerType() || PtrTy->getPointeeType().isConstQualified()) { S.Diag(Arg.get()->getBeginLoc(), diag::err_overflow_builtin_must_be_ptr_int) - << Ty << Arg.get()->getSourceRange(); + << Ty << Arg.get()->getSourceRange(); return true; } } @@ -517,8 +516,7 @@ struct BuiltinDumpStructGenerator { } analyze_printf::PrintfSpecifier Specifier; - if (Specifier.fixType(T, S.getLangOpts(), S.Context, - /*IsObjCLiteral=*/false)) { + if (Specifier.fixType(T, S.getLangOpts(), S.Context, /*IsObjCLiteral=*/false)) { // We were able to guess how to format this. if (Specifier.getConversionSpecifier().getKind() == analyze_printf::PrintfConversionSpecifier::sArg) { @@ -774,7 +772,7 @@ static bool SemaBuiltinCallWithStaticChain(Sema &S, CallExpr *BuiltinCall) { } QualType ReturnTy = CE->getCallReturnType(S.Context); - QualType ArgTys[2] = {ReturnTy, ChainResult.get()->getType()}; + QualType ArgTys[2] = { ReturnTy, ChainResult.get()->getType() }; QualType BuiltinTy = S.Context.getFunctionType( ReturnTy, ArgTys, FunctionProtoType::ExtProtoInfo()); QualType BuiltinPtrTy = S.Context.getPointerType(BuiltinTy); @@ -1469,7 +1467,7 @@ static bool checkOpenCLEnqueueLocalSizeArgs(Sema &S, CallExpr *TheCall, bool IllegalParams = false; for (unsigned I = Start; I <= End; ++I) IllegalParams |= checkOpenCLEnqueueIntType(S, TheCall->getArg(I), - S.Context.getSizeType()); + S.Context.getSizeType()); return IllegalParams; } @@ -1574,8 +1572,7 @@ static bool SemaOpenCLBuiltinEnqueueKernel(Sema &S, CallExpr *TheCall) { // we have a block type, check the prototype const BlockPointerType *BPT = cast(Arg3->getType().getCanonicalType()); - if (BPT->getPointeeType()->castAs()->getNumParams() > - 0) { + if (BPT->getPointeeType()->castAs()->getNumParams() > 0) { S.Diag(Arg3->getBeginLoc(), diag::err_opencl_enqueue_kernel_blocks_no_args); return true; @@ -1646,7 +1643,7 @@ static bool SemaOpenCLBuiltinEnqueueKernel(Sema &S, CallExpr *TheCall) { /// Returns OpenCL access qual. static OpenCLAccessAttr *getOpenCLArgAccess(const Decl *D) { - return D->getAttr(); + return D->getAttr(); } /// Returns true if pipe element type is different from the pointer. @@ -1855,8 +1852,8 @@ static bool SemaOpenCLBuiltinToAddr(Sema &S, unsigned BuiltinID, return true; auto RT = Call->getArg(0)->getType(); - if (!RT->isPointerType() || - RT->getPointeeType().getAddressSpace() == LangAS::opencl_constant) { + if (!RT->isPointerType() || RT->getPointeeType() + .getAddressSpace() == LangAS::opencl_constant) { S.Diag(Call->getBeginLoc(), diag::err_opencl_builtin_to_addr_invalid_arg) << Call->getArg(0) << Call->getDirectCallee() << Call->getSourceRange(); return true; @@ -1884,8 +1881,8 @@ static bool SemaOpenCLBuiltinToAddr(Sema &S, unsigned BuiltinID, default: llvm_unreachable("Invalid builtin function"); } - Call->setType(S.Context.getPointerType( - S.Context.getQualifiedType(RT.getUnqualifiedType(), Qual))); + Call->setType(S.Context.getPointerType(S.Context.getQualifiedType( + RT.getUnqualifiedType(), Qual))); return false; } @@ -2023,13 +2020,13 @@ bool Sema::CheckTSBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case llvm::Triple::riscv32: case llvm::Triple::riscv64: return CheckRISCVBuiltinFunctionCall(TI, BuiltinID, TheCall) || - CheckRISCVCOREVBuiltinFunctionCall(BuiltinID, TheCall); + CheckRISCVCOREVBuiltinFunctionCall(BuiltinID, TheCall); } } -ExprResult Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, - unsigned BuiltinID, - CallExpr *TheCall) { +ExprResult +Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, + CallExpr *TheCall) { ExprResult TheCallResult(TheCall); // Find out if any arguments are required to be integer constant expressions. @@ -2037,13 +2034,12 @@ ExprResult Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, ASTContext::GetBuiltinTypeError Error; Context.GetBuiltinType(BuiltinID, Error, &ICEArguments); if (Error != ASTContext::GE_None) - ICEArguments = 0; // Don't diagnose previously diagnosed errors. + 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; + if ((ICEArguments & (1 << ArgNo)) == 0) continue; llvm::APSInt Result; // If we don't have enough arguments, continue so we can issue better @@ -2185,8 +2181,7 @@ ExprResult Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, return ExprError(); break; case Builtin::BI__builtin_classify_type: - if (checkArgCount(*this, TheCall, 1)) - return true; + if (checkArgCount(*this, TheCall, 1)) return true; TheCall->setType(Context.IntTy); break; case Builtin::BI__builtin_complex: @@ -2194,11 +2189,9 @@ ExprResult Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, return ExprError(); break; case Builtin::BI__builtin_constant_p: { - if (checkArgCount(*this, TheCall, 1)) - return true; + if (checkArgCount(*this, TheCall, 1)) return true; ExprResult Arg = DefaultFunctionArrayLvalueConversion(TheCall->getArg(0)); - if (Arg.isInvalid()) - return true; + if (Arg.isInvalid()) return true; TheCall->setArg(0, Arg.get()); TheCall->setType(Context.IntTy); break; @@ -2340,8 +2333,8 @@ ExprResult Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, break; } #define BUILTIN(ID, TYPE, ATTRS) -#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \ - case Builtin::BI##ID: \ +#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \ + case Builtin::BI##ID: \ return SemaAtomicOpsOverloaded(TheCallResult, AtomicExpr::AO##ID); #include "clang/Basic/Builtins.def" case Builtin::BI__annotation: @@ -2658,7 +2651,7 @@ ExprResult Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, const auto *TyA = Arg->getType()->getAs(); if (!TyA || !TyA->getElementType()->isIntegerType()) { Diag(Arg->getBeginLoc(), diag::err_builtin_invalid_arg_type) - << 1 << /* vector of integers */ 6 << Arg->getType(); + << 1 << /* vector of integers */ 6 << Arg->getType(); return ExprError(); } TheCall->setType(TyA->getElementType()); @@ -2793,7 +2786,7 @@ static QualType getNeonEltType(NeonTypeFlags Flags, ASTContext &Context, bool Sema::CheckSVEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { // Range check SVE intrinsics that take immediate values. - SmallVector, 3> ImmChecks; + SmallVector, 3> ImmChecks; switch (BuiltinID) { default: @@ -2809,7 +2802,7 @@ bool Sema::CheckSVEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { int ArgNum, CheckTy, ElementSizeInBits; std::tie(ArgNum, CheckTy, ElementSizeInBits) = I; - typedef bool (*OptionSetCheckFnTy)(int64_t Value); + typedef bool(*OptionSetCheckFnTy)(int64_t Value); // Function that checks whether the operand (ArgNum) is an immediate // that is one of the predefined values. @@ -2921,14 +2914,14 @@ bool Sema::CheckNeonBuiltinFunctionCall(const TargetInfo &TI, bool HasConstPtr = false; switch (BuiltinID) { #define GET_NEON_OVERLOAD_CHECK -#include "clang/Basic/arm_fp16.inc" #include "clang/Basic/arm_neon.inc" +#include "clang/Basic/arm_fp16.inc" #undef GET_NEON_OVERLOAD_CHECK } // For NEON intrinsics which are overloaded on vector element type, validate // the immediate which specifies which variant to emit. - unsigned ImmArg = TheCall->getNumArgs() - 1; + unsigned ImmArg = TheCall->getNumArgs()-1; if (mask) { if (SemaBuiltinConstantArg(TheCall, ImmArg, Result)) return true; @@ -2972,10 +2965,10 @@ bool Sema::CheckNeonBuiltinFunctionCall(const TargetInfo &TI, switch (BuiltinID) { default: return false; -#define GET_NEON_IMMEDIATE_CHECK -#include "clang/Basic/arm_fp16.inc" -#include "clang/Basic/arm_neon.inc" -#undef GET_NEON_IMMEDIATE_CHECK + #define GET_NEON_IMMEDIATE_CHECK + #include "clang/Basic/arm_neon.inc" + #include "clang/Basic/arm_fp16.inc" + #undef GET_NEON_IMMEDIATE_CHECK } return SemaBuiltinConstantArgRange(TheCall, i, l, u + l); @@ -2985,7 +2978,7 @@ bool Sema::CheckMVEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { switch (BuiltinID) { default: return false; -#include "clang/Basic/arm_mve_builtin_sema.inc" + #include "clang/Basic/arm_mve_builtin_sema.inc" } } @@ -3043,8 +3036,7 @@ bool Sema::CheckARMBuiltinExclusiveCall(unsigned BuiltinID, CallExpr *TheCall, BuiltinID == AArch64::BI__builtin_arm_ldrex || BuiltinID == AArch64::BI__builtin_arm_ldaex; - DeclRefExpr *DRE = - cast(TheCall->getCallee()->IgnoreParenCasts()); + DeclRefExpr *DRE =cast(TheCall->getCallee()->IgnoreParenCasts()); // Ensure that we have the proper number of arguments. if (checkArgCount(*this, TheCall, IsLdrex ? 1 : 2)) @@ -3154,7 +3146,7 @@ bool Sema::CheckARMBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, if (BuiltinID == ARM::BI__builtin_arm_prefetch) { return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1) || - SemaBuiltinConstantArgRange(TheCall, 2, 0, 1); + SemaBuiltinConstantArgRange(TheCall, 2, 0, 1); } if (BuiltinID == ARM::BI__builtin_arm_rsr64 || @@ -3178,8 +3170,7 @@ bool Sema::CheckARMBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, // range check them here. // FIXME: VFP Intrinsics should error if VFP not present. switch (BuiltinID) { - default: - return false; + default: return false; case ARM::BI__builtin_arm_ssat: return SemaBuiltinConstantArgRange(TheCall, 1, 1, 32); case ARM::BI__builtin_arm_usat: @@ -3232,9 +3223,9 @@ bool Sema::CheckAArch64BuiltinFunctionCall(const TargetInfo &TI, if (BuiltinID == AArch64::BI__builtin_arm_prefetch) { return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1) || - SemaBuiltinConstantArgRange(TheCall, 2, 0, 2) || - SemaBuiltinConstantArgRange(TheCall, 3, 0, 1) || - SemaBuiltinConstantArgRange(TheCall, 4, 0, 1); + SemaBuiltinConstantArgRange(TheCall, 2, 0, 2) || + SemaBuiltinConstantArgRange(TheCall, 3, 0, 1) || + SemaBuiltinConstantArgRange(TheCall, 4, 0, 1); } if (BuiltinID == AArch64::BI__builtin_arm_rsr64 || @@ -3280,18 +3271,11 @@ bool Sema::CheckAArch64BuiltinFunctionCall(const TargetInfo &TI, // range check them here. unsigned i = 0, l = 0, u = 0; switch (BuiltinID) { - default: - return false; + default: return false; case AArch64::BI__builtin_arm_dmb: case AArch64::BI__builtin_arm_dsb: - case AArch64::BI__builtin_arm_isb: - l = 0; - u = 15; - break; - case AArch64::BI__builtin_arm_tcancel: - l = 0; - u = 65535; - break; + case AArch64::BI__builtin_arm_isb: l = 0; u = 15; break; + case AArch64::BI__builtin_arm_tcancel: l = 0; u = 65535; break; } return SemaBuiltinConstantArgRange(TheCall, i, l, u + l); @@ -3381,7 +3365,8 @@ static bool isValidBPFPreserveEnumValueArg(Expr *Arg) { return llvm::is_contained(ET->getDecl()->enumerators(), Enumerator); } -bool Sema::CheckBPFBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { +bool Sema::CheckBPFBuiltinFunctionCall(unsigned BuiltinID, + CallExpr *TheCall) { assert((BuiltinID == BPF::BI__builtin_preserve_field_info || BuiltinID == BPF::BI__builtin_btf_type_id || BuiltinID == BPF::BI__builtin_preserve_type_info || @@ -3457,190 +3442,198 @@ bool Sema::CheckHexagonBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) { }; static BuiltinInfo Infos[] = { - {Hexagon::BI__builtin_circ_ldd, {{3, true, 4, 3}}}, - {Hexagon::BI__builtin_circ_ldw, {{3, true, 4, 2}}}, - {Hexagon::BI__builtin_circ_ldh, {{3, true, 4, 1}}}, - {Hexagon::BI__builtin_circ_lduh, {{3, true, 4, 1}}}, - {Hexagon::BI__builtin_circ_ldb, {{3, true, 4, 0}}}, - {Hexagon::BI__builtin_circ_ldub, {{3, true, 4, 0}}}, - {Hexagon::BI__builtin_circ_std, {{3, true, 4, 3}}}, - {Hexagon::BI__builtin_circ_stw, {{3, true, 4, 2}}}, - {Hexagon::BI__builtin_circ_sth, {{3, true, 4, 1}}}, - {Hexagon::BI__builtin_circ_sthhi, {{3, true, 4, 1}}}, - {Hexagon::BI__builtin_circ_stb, {{3, true, 4, 0}}}, - - {Hexagon::BI__builtin_HEXAGON_L2_loadrub_pci, {{1, true, 4, 0}}}, - {Hexagon::BI__builtin_HEXAGON_L2_loadrb_pci, {{1, true, 4, 0}}}, - {Hexagon::BI__builtin_HEXAGON_L2_loadruh_pci, {{1, true, 4, 1}}}, - {Hexagon::BI__builtin_HEXAGON_L2_loadrh_pci, {{1, true, 4, 1}}}, - {Hexagon::BI__builtin_HEXAGON_L2_loadri_pci, {{1, true, 4, 2}}}, - {Hexagon::BI__builtin_HEXAGON_L2_loadrd_pci, {{1, true, 4, 3}}}, - {Hexagon::BI__builtin_HEXAGON_S2_storerb_pci, {{1, true, 4, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_storerh_pci, {{1, true, 4, 1}}}, - {Hexagon::BI__builtin_HEXAGON_S2_storerf_pci, {{1, true, 4, 1}}}, - {Hexagon::BI__builtin_HEXAGON_S2_storeri_pci, {{1, true, 4, 2}}}, - {Hexagon::BI__builtin_HEXAGON_S2_storerd_pci, {{1, true, 4, 3}}}, - - {Hexagon::BI__builtin_HEXAGON_A2_combineii, {{1, true, 8, 0}}}, - {Hexagon::BI__builtin_HEXAGON_A2_tfrih, {{1, false, 16, 0}}}, - {Hexagon::BI__builtin_HEXAGON_A2_tfril, {{1, false, 16, 0}}}, - {Hexagon::BI__builtin_HEXAGON_A2_tfrpi, {{0, true, 8, 0}}}, - {Hexagon::BI__builtin_HEXAGON_A4_bitspliti, {{1, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_A4_cmpbeqi, {{1, false, 8, 0}}}, - {Hexagon::BI__builtin_HEXAGON_A4_cmpbgti, {{1, true, 8, 0}}}, - {Hexagon::BI__builtin_HEXAGON_A4_cround_ri, {{1, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_A4_round_ri, {{1, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_A4_round_ri_sat, {{1, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_A4_vcmpbeqi, {{1, false, 8, 0}}}, - {Hexagon::BI__builtin_HEXAGON_A4_vcmpbgti, {{1, true, 8, 0}}}, - {Hexagon::BI__builtin_HEXAGON_A4_vcmpbgtui, {{1, false, 7, 0}}}, - {Hexagon::BI__builtin_HEXAGON_A4_vcmpheqi, {{1, true, 8, 0}}}, - {Hexagon::BI__builtin_HEXAGON_A4_vcmphgti, {{1, true, 8, 0}}}, - {Hexagon::BI__builtin_HEXAGON_A4_vcmphgtui, {{1, false, 7, 0}}}, - {Hexagon::BI__builtin_HEXAGON_A4_vcmpweqi, {{1, true, 8, 0}}}, - {Hexagon::BI__builtin_HEXAGON_A4_vcmpwgti, {{1, true, 8, 0}}}, - {Hexagon::BI__builtin_HEXAGON_A4_vcmpwgtui, {{1, false, 7, 0}}}, - {Hexagon::BI__builtin_HEXAGON_C2_bitsclri, {{1, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_C2_muxii, {{2, true, 8, 0}}}, - {Hexagon::BI__builtin_HEXAGON_C4_nbitsclri, {{1, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_F2_dfclass, {{1, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_F2_dfimm_n, {{0, false, 10, 0}}}, - {Hexagon::BI__builtin_HEXAGON_F2_dfimm_p, {{0, false, 10, 0}}}, - {Hexagon::BI__builtin_HEXAGON_F2_sfclass, {{1, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_F2_sfimm_n, {{0, false, 10, 0}}}, - {Hexagon::BI__builtin_HEXAGON_F2_sfimm_p, {{0, false, 10, 0}}}, - {Hexagon::BI__builtin_HEXAGON_M4_mpyri_addi, {{2, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_M4_mpyri_addr_u2, {{1, false, 6, 2}}}, - {Hexagon::BI__builtin_HEXAGON_S2_addasl_rrri, {{2, false, 3, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_acc, {{2, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_and, {{2, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asl_i_p, {{1, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_nac, {{2, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_or, {{2, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_xacc, {{2, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_acc, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_and, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asl_i_r, {{1, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_nac, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_or, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_sat, {{1, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_xacc, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asl_i_vh, {{1, false, 4, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asl_i_vw, {{1, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_acc, {{2, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_and, {{2, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asr_i_p, {{1, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_nac, {{2, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_or, {{2, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd_goodsyntax, - {{1, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd, {{1, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_acc, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_and, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asr_i_r, {{1, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_nac, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_or, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd_goodsyntax, - {{1, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd, {{1, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asr_i_svw_trun, {{1, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asr_i_vh, {{1, false, 4, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_asr_i_vw, {{1, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_clrbit_i, {{1, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_extractu, - {{1, false, 5, 0}, {2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_extractup, - {{1, false, 6, 0}, {2, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_insert, - {{2, false, 5, 0}, {3, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_insertp, - {{2, false, 6, 0}, {3, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_acc, {{2, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_and, {{2, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p, {{1, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_nac, {{2, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_or, {{2, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_xacc, {{2, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_acc, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_and, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r, {{1, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_nac, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_or, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_xacc, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vh, {{1, false, 4, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vw, {{1, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_setbit_i, {{1, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_tableidxb_goodsyntax, - {{2, false, 4, 0}, {3, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_tableidxd_goodsyntax, - {{2, false, 4, 0}, {3, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_tableidxh_goodsyntax, - {{2, false, 4, 0}, {3, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_tableidxw_goodsyntax, - {{2, false, 4, 0}, {3, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_togglebit_i, {{1, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_tstbit_i, {{1, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_valignib, {{2, false, 3, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S2_vspliceib, {{2, false, 3, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S4_addi_asl_ri, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S4_addi_lsr_ri, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S4_andi_asl_ri, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S4_andi_lsr_ri, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S4_clbaddi, {{1, true, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S4_clbpaddi, {{1, true, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S4_extract, - {{1, false, 5, 0}, {2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S4_extractp, - {{1, false, 6, 0}, {2, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S4_lsli, {{0, true, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S4_ntstbit_i, {{1, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S4_ori_asl_ri, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S4_ori_lsr_ri, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S4_subi_asl_ri, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S4_subi_lsr_ri, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S4_vrcrotate_acc, {{3, false, 2, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S4_vrcrotate, {{2, false, 2, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S5_asrhub_rnd_sat_goodsyntax, - {{1, false, 4, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S5_asrhub_sat, {{1, false, 4, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S5_vasrhrnd_goodsyntax, {{1, false, 4, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S6_rol_i_p, {{1, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_acc, {{2, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_and, {{2, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_nac, {{2, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_or, {{2, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_xacc, {{2, false, 6, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S6_rol_i_r, {{1, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_acc, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_and, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_nac, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_or, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_xacc, {{2, false, 5, 0}}}, - {Hexagon::BI__builtin_HEXAGON_V6_valignbi, {{2, false, 3, 0}}}, - {Hexagon::BI__builtin_HEXAGON_V6_valignbi_128B, {{2, false, 3, 0}}}, - {Hexagon::BI__builtin_HEXAGON_V6_vlalignbi, {{2, false, 3, 0}}}, - {Hexagon::BI__builtin_HEXAGON_V6_vlalignbi_128B, {{2, false, 3, 0}}}, - {Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi, {{2, false, 1, 0}}}, - {Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_128B, {{2, false, 1, 0}}}, - {Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc, {{3, false, 1, 0}}}, - {Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc_128B, {{3, false, 1, 0}}}, - {Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi, {{2, false, 1, 0}}}, - {Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_128B, {{2, false, 1, 0}}}, - {Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc, {{3, false, 1, 0}}}, - {Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc_128B, {{3, false, 1, 0}}}, - {Hexagon::BI__builtin_HEXAGON_V6_vrsadubi, {{2, false, 1, 0}}}, - {Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_128B, {{2, false, 1, 0}}}, - {Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc, {{3, false, 1, 0}}}, - {Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc_128B, {{3, false, 1, 0}}}, + { Hexagon::BI__builtin_circ_ldd, {{ 3, true, 4, 3 }} }, + { Hexagon::BI__builtin_circ_ldw, {{ 3, true, 4, 2 }} }, + { Hexagon::BI__builtin_circ_ldh, {{ 3, true, 4, 1 }} }, + { Hexagon::BI__builtin_circ_lduh, {{ 3, true, 4, 1 }} }, + { Hexagon::BI__builtin_circ_ldb, {{ 3, true, 4, 0 }} }, + { Hexagon::BI__builtin_circ_ldub, {{ 3, true, 4, 0 }} }, + { Hexagon::BI__builtin_circ_std, {{ 3, true, 4, 3 }} }, + { Hexagon::BI__builtin_circ_stw, {{ 3, true, 4, 2 }} }, + { Hexagon::BI__builtin_circ_sth, {{ 3, true, 4, 1 }} }, + { Hexagon::BI__builtin_circ_sthhi, {{ 3, true, 4, 1 }} }, + { Hexagon::BI__builtin_circ_stb, {{ 3, true, 4, 0 }} }, + + { Hexagon::BI__builtin_HEXAGON_L2_loadrub_pci, {{ 1, true, 4, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_L2_loadrb_pci, {{ 1, true, 4, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_L2_loadruh_pci, {{ 1, true, 4, 1 }} }, + { Hexagon::BI__builtin_HEXAGON_L2_loadrh_pci, {{ 1, true, 4, 1 }} }, + { Hexagon::BI__builtin_HEXAGON_L2_loadri_pci, {{ 1, true, 4, 2 }} }, + { Hexagon::BI__builtin_HEXAGON_L2_loadrd_pci, {{ 1, true, 4, 3 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_storerb_pci, {{ 1, true, 4, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_storerh_pci, {{ 1, true, 4, 1 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_storerf_pci, {{ 1, true, 4, 1 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_storeri_pci, {{ 1, true, 4, 2 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_storerd_pci, {{ 1, true, 4, 3 }} }, + + { Hexagon::BI__builtin_HEXAGON_A2_combineii, {{ 1, true, 8, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_A2_tfrih, {{ 1, false, 16, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_A2_tfril, {{ 1, false, 16, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_A2_tfrpi, {{ 0, true, 8, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_A4_bitspliti, {{ 1, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_A4_cmpbeqi, {{ 1, false, 8, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_A4_cmpbgti, {{ 1, true, 8, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_A4_cround_ri, {{ 1, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_A4_round_ri, {{ 1, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_A4_round_ri_sat, {{ 1, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_A4_vcmpbeqi, {{ 1, false, 8, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_A4_vcmpbgti, {{ 1, true, 8, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_A4_vcmpbgtui, {{ 1, false, 7, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_A4_vcmpheqi, {{ 1, true, 8, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_A4_vcmphgti, {{ 1, true, 8, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_A4_vcmphgtui, {{ 1, false, 7, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_A4_vcmpweqi, {{ 1, true, 8, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_A4_vcmpwgti, {{ 1, true, 8, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_A4_vcmpwgtui, {{ 1, false, 7, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_C2_bitsclri, {{ 1, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_C2_muxii, {{ 2, true, 8, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_C4_nbitsclri, {{ 1, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_F2_dfclass, {{ 1, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_F2_dfimm_n, {{ 0, false, 10, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_F2_dfimm_p, {{ 0, false, 10, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_F2_sfclass, {{ 1, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_F2_sfimm_n, {{ 0, false, 10, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_F2_sfimm_p, {{ 0, false, 10, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_M4_mpyri_addi, {{ 2, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_M4_mpyri_addr_u2, {{ 1, false, 6, 2 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_addasl_rrri, {{ 2, false, 3, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_acc, {{ 2, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_and, {{ 2, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p, {{ 1, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_nac, {{ 2, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_or, {{ 2, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_xacc, {{ 2, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_acc, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_and, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r, {{ 1, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_nac, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_or, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_sat, {{ 1, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_xacc, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asl_i_vh, {{ 1, false, 4, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asl_i_vw, {{ 1, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_acc, {{ 2, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_and, {{ 2, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p, {{ 1, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_nac, {{ 2, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_or, {{ 2, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd_goodsyntax, + {{ 1, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd, {{ 1, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_acc, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_and, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r, {{ 1, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_nac, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_or, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd_goodsyntax, + {{ 1, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd, {{ 1, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asr_i_svw_trun, {{ 1, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asr_i_vh, {{ 1, false, 4, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_asr_i_vw, {{ 1, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_clrbit_i, {{ 1, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_extractu, {{ 1, false, 5, 0 }, + { 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_extractup, {{ 1, false, 6, 0 }, + { 2, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_insert, {{ 2, false, 5, 0 }, + { 3, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_insertp, {{ 2, false, 6, 0 }, + { 3, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_acc, {{ 2, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_and, {{ 2, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p, {{ 1, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_nac, {{ 2, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_or, {{ 2, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_xacc, {{ 2, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_acc, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_and, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r, {{ 1, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_nac, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_or, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_xacc, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vh, {{ 1, false, 4, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vw, {{ 1, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_setbit_i, {{ 1, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_tableidxb_goodsyntax, + {{ 2, false, 4, 0 }, + { 3, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_tableidxd_goodsyntax, + {{ 2, false, 4, 0 }, + { 3, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_tableidxh_goodsyntax, + {{ 2, false, 4, 0 }, + { 3, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_tableidxw_goodsyntax, + {{ 2, false, 4, 0 }, + { 3, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_togglebit_i, {{ 1, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_tstbit_i, {{ 1, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_valignib, {{ 2, false, 3, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S2_vspliceib, {{ 2, false, 3, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S4_addi_asl_ri, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S4_addi_lsr_ri, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S4_andi_asl_ri, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S4_andi_lsr_ri, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S4_clbaddi, {{ 1, true , 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S4_clbpaddi, {{ 1, true, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S4_extract, {{ 1, false, 5, 0 }, + { 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S4_extractp, {{ 1, false, 6, 0 }, + { 2, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S4_lsli, {{ 0, true, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S4_ntstbit_i, {{ 1, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S4_ori_asl_ri, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S4_ori_lsr_ri, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S4_subi_asl_ri, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S4_subi_lsr_ri, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S4_vrcrotate_acc, {{ 3, false, 2, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S4_vrcrotate, {{ 2, false, 2, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S5_asrhub_rnd_sat_goodsyntax, + {{ 1, false, 4, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S5_asrhub_sat, {{ 1, false, 4, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S5_vasrhrnd_goodsyntax, + {{ 1, false, 4, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p, {{ 1, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_acc, {{ 2, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_and, {{ 2, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_nac, {{ 2, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_or, {{ 2, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_xacc, {{ 2, false, 6, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r, {{ 1, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_acc, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_and, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_nac, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_or, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_xacc, {{ 2, false, 5, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_V6_valignbi, {{ 2, false, 3, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_V6_valignbi_128B, {{ 2, false, 3, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_V6_vlalignbi, {{ 2, false, 3, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_V6_vlalignbi_128B, {{ 2, false, 3, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi, {{ 2, false, 1, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_128B, {{ 2, false, 1, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc, {{ 3, false, 1, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc_128B, + {{ 3, false, 1, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi, {{ 2, false, 1, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_128B, {{ 2, false, 1, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc, {{ 3, false, 1, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc_128B, + {{ 3, false, 1, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi, {{ 2, false, 1, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_128B, {{ 2, false, 1, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc, {{ 3, false, 1, 0 }} }, + { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc_128B, + {{ 3, false, 1, 0 }} }, }; // Use a dynamically initialized static to sort the table exactly once on // first run. static const bool SortOnce = (llvm::sort(Infos, - [](const BuiltinInfo &LHS, const BuiltinInfo &RHS) { - return LHS.BuiltinID < RHS.BuiltinID; - }), + [](const BuiltinInfo &LHS, const BuiltinInfo &RHS) { + return LHS.BuiltinID < RHS.BuiltinID; + }), true); (void)SortOnce; @@ -3719,43 +3712,14 @@ bool Sema::CheckMipsBuiltinCpu(const TargetInfo &TI, unsigned BuiltinID, bool Sema::CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) { unsigned i = 0, l = 0, u = 0, m = 0; switch (BuiltinID) { - default: - return false; - case Mips::BI__builtin_mips_wrdsp: - i = 1; - l = 0; - u = 63; - break; - case Mips::BI__builtin_mips_rddsp: - i = 0; - l = 0; - u = 63; - break; - case Mips::BI__builtin_mips_append: - i = 2; - l = 0; - u = 31; - break; - case Mips::BI__builtin_mips_balign: - i = 2; - l = 0; - u = 3; - break; - case Mips::BI__builtin_mips_precr_sra_ph_w: - i = 2; - l = 0; - u = 31; - break; - case Mips::BI__builtin_mips_precr_sra_r_ph_w: - i = 2; - l = 0; - u = 31; - break; - case Mips::BI__builtin_mips_prepend: - i = 2; - l = 0; - u = 31; - break; + default: return false; + case Mips::BI__builtin_mips_wrdsp: i = 1; l = 0; u = 63; break; + case Mips::BI__builtin_mips_rddsp: i = 0; l = 0; u = 63; break; + case Mips::BI__builtin_mips_append: i = 2; l = 0; u = 31; break; + case Mips::BI__builtin_mips_balign: i = 2; l = 0; u = 3; break; + case Mips::BI__builtin_mips_precr_sra_ph_w: i = 2; l = 0; u = 31; break; + case Mips::BI__builtin_mips_precr_sra_r_ph_w: i = 2; l = 0; u = 31; break; + case Mips::BI__builtin_mips_prepend: i = 2; l = 0; u = 31; break; // MSA intrinsics. Instructions (which the intrinsics maps to) which use the // df/m field. // These intrinsics take an unsigned 3 bit immediate. @@ -3768,17 +3732,9 @@ bool Sema::CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) { case Mips::BI__builtin_msa_srai_b: case Mips::BI__builtin_msa_srari_b: case Mips::BI__builtin_msa_srli_b: - case Mips::BI__builtin_msa_srlri_b: - i = 1; - l = 0; - u = 7; - break; + case Mips::BI__builtin_msa_srlri_b: i = 1; l = 0; u = 7; break; case Mips::BI__builtin_msa_binsli_b: - case Mips::BI__builtin_msa_binsri_b: - i = 2; - l = 0; - u = 7; - break; + case Mips::BI__builtin_msa_binsri_b: i = 2; l = 0; u = 7; break; // These intrinsics take an unsigned 4 bit immediate. case Mips::BI__builtin_msa_bclri_h: case Mips::BI__builtin_msa_bnegi_h: @@ -3789,26 +3745,14 @@ bool Sema::CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) { case Mips::BI__builtin_msa_srai_h: case Mips::BI__builtin_msa_srari_h: case Mips::BI__builtin_msa_srli_h: - case Mips::BI__builtin_msa_srlri_h: - i = 1; - l = 0; - u = 15; - break; + case Mips::BI__builtin_msa_srlri_h: i = 1; l = 0; u = 15; break; case Mips::BI__builtin_msa_binsli_h: - case Mips::BI__builtin_msa_binsri_h: - i = 2; - l = 0; - u = 15; - break; + case Mips::BI__builtin_msa_binsri_h: i = 2; l = 0; u = 15; break; // These intrinsics take an unsigned 5 bit immediate. // The first block of intrinsics actually have an unsigned 5 bit field, // not a df/n field. case Mips::BI__builtin_msa_cfcmsa: - case Mips::BI__builtin_msa_ctcmsa: - i = 0; - l = 0; - u = 31; - break; + case Mips::BI__builtin_msa_ctcmsa: i = 0; l = 0; u = 31; break; case Mips::BI__builtin_msa_clei_u_b: case Mips::BI__builtin_msa_clei_u_h: case Mips::BI__builtin_msa_clei_u_w: @@ -3842,17 +3786,9 @@ bool Sema::CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) { case Mips::BI__builtin_msa_subvi_b: case Mips::BI__builtin_msa_subvi_h: case Mips::BI__builtin_msa_subvi_w: - case Mips::BI__builtin_msa_subvi_d: - i = 1; - l = 0; - u = 31; - break; + case Mips::BI__builtin_msa_subvi_d: i = 1; l = 0; u = 31; break; case Mips::BI__builtin_msa_binsli_w: - case Mips::BI__builtin_msa_binsri_w: - i = 2; - l = 0; - u = 31; - break; + case Mips::BI__builtin_msa_binsri_w: i = 2; l = 0; u = 31; break; // These intrinsics take an unsigned 6 bit immediate. case Mips::BI__builtin_msa_bclri_d: case Mips::BI__builtin_msa_bnegi_d: @@ -3863,17 +3799,9 @@ bool Sema::CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) { case Mips::BI__builtin_msa_srai_d: case Mips::BI__builtin_msa_srari_d: case Mips::BI__builtin_msa_srli_d: - case Mips::BI__builtin_msa_srlri_d: - i = 1; - l = 0; - u = 63; - break; + case Mips::BI__builtin_msa_srlri_d: i = 1; l = 0; u = 63; break; case Mips::BI__builtin_msa_binsli_d: - case Mips::BI__builtin_msa_binsri_d: - i = 2; - l = 0; - u = 63; - break; + case Mips::BI__builtin_msa_binsri_d: i = 2; l = 0; u = 63; break; // These intrinsics take a signed 5 bit immediate. case Mips::BI__builtin_msa_ceqi_b: case Mips::BI__builtin_msa_ceqi_h: @@ -3894,11 +3822,7 @@ bool Sema::CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) { case Mips::BI__builtin_msa_mini_s_b: case Mips::BI__builtin_msa_mini_s_h: case Mips::BI__builtin_msa_mini_s_w: - case Mips::BI__builtin_msa_mini_s_d: - i = 1; - l = -16; - u = 15; - break; + case Mips::BI__builtin_msa_mini_s_d: i = 1; l = -16; u = 15; break; // These intrinsics take an unsigned 8 bit immediate. case Mips::BI__builtin_msa_andi_b: case Mips::BI__builtin_msa_nori_b: @@ -3906,161 +3830,53 @@ bool Sema::CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) { case Mips::BI__builtin_msa_shf_b: case Mips::BI__builtin_msa_shf_h: case Mips::BI__builtin_msa_shf_w: - case Mips::BI__builtin_msa_xori_b: - i = 1; - l = 0; - u = 255; - break; + case Mips::BI__builtin_msa_xori_b: i = 1; l = 0; u = 255; break; case Mips::BI__builtin_msa_bseli_b: case Mips::BI__builtin_msa_bmnzi_b: - case Mips::BI__builtin_msa_bmzi_b: - i = 2; - l = 0; - u = 255; - break; + case Mips::BI__builtin_msa_bmzi_b: i = 2; l = 0; u = 255; break; // df/n format // These intrinsics take an unsigned 4 bit immediate. case Mips::BI__builtin_msa_copy_s_b: case Mips::BI__builtin_msa_copy_u_b: case Mips::BI__builtin_msa_insve_b: - case Mips::BI__builtin_msa_splati_b: - i = 1; - l = 0; - u = 15; - break; - case Mips::BI__builtin_msa_sldi_b: - i = 2; - l = 0; - u = 15; - break; + case Mips::BI__builtin_msa_splati_b: i = 1; l = 0; u = 15; break; + case Mips::BI__builtin_msa_sldi_b: i = 2; l = 0; u = 15; break; // These intrinsics take an unsigned 3 bit immediate. case Mips::BI__builtin_msa_copy_s_h: case Mips::BI__builtin_msa_copy_u_h: case Mips::BI__builtin_msa_insve_h: - case Mips::BI__builtin_msa_splati_h: - i = 1; - l = 0; - u = 7; - break; - case Mips::BI__builtin_msa_sldi_h: - i = 2; - l = 0; - u = 7; - break; + case Mips::BI__builtin_msa_splati_h: i = 1; l = 0; u = 7; break; + case Mips::BI__builtin_msa_sldi_h: i = 2; l = 0; u = 7; break; // These intrinsics take an unsigned 2 bit immediate. case Mips::BI__builtin_msa_copy_s_w: case Mips::BI__builtin_msa_copy_u_w: case Mips::BI__builtin_msa_insve_w: - case Mips::BI__builtin_msa_splati_w: - i = 1; - l = 0; - u = 3; - break; - case Mips::BI__builtin_msa_sldi_w: - i = 2; - l = 0; - u = 3; - break; + case Mips::BI__builtin_msa_splati_w: i = 1; l = 0; u = 3; break; + case Mips::BI__builtin_msa_sldi_w: i = 2; l = 0; u = 3; break; // These intrinsics take an unsigned 1 bit immediate. case Mips::BI__builtin_msa_copy_s_d: case Mips::BI__builtin_msa_copy_u_d: case Mips::BI__builtin_msa_insve_d: - case Mips::BI__builtin_msa_splati_d: - i = 1; - l = 0; - u = 1; - break; - case Mips::BI__builtin_msa_sldi_d: - i = 2; - l = 0; - u = 1; - break; + case Mips::BI__builtin_msa_splati_d: i = 1; l = 0; u = 1; break; + case Mips::BI__builtin_msa_sldi_d: i = 2; l = 0; u = 1; break; // Memory offsets and immediate loads. // These intrinsics take a signed 10 bit immediate. - case Mips::BI__builtin_msa_ldi_b: - i = 0; - l = -128; - u = 255; - break; + case Mips::BI__builtin_msa_ldi_b: i = 0; l = -128; u = 255; break; case Mips::BI__builtin_msa_ldi_h: case Mips::BI__builtin_msa_ldi_w: - case Mips::BI__builtin_msa_ldi_d: - i = 0; - l = -512; - u = 511; - break; - case Mips::BI__builtin_msa_ld_b: - i = 1; - l = -512; - u = 511; - m = 1; - break; - case Mips::BI__builtin_msa_ld_h: - i = 1; - l = -1024; - u = 1022; - m = 2; - break; - case Mips::BI__builtin_msa_ld_w: - i = 1; - l = -2048; - u = 2044; - m = 4; - break; - case Mips::BI__builtin_msa_ld_d: - i = 1; - l = -4096; - u = 4088; - m = 8; - break; - case Mips::BI__builtin_msa_ldr_d: - i = 1; - l = -4096; - u = 4088; - m = 8; - break; - case Mips::BI__builtin_msa_ldr_w: - i = 1; - l = -2048; - u = 2044; - m = 4; - break; - case Mips::BI__builtin_msa_st_b: - i = 2; - l = -512; - u = 511; - m = 1; - break; - case Mips::BI__builtin_msa_st_h: - i = 2; - l = -1024; - u = 1022; - m = 2; - break; - case Mips::BI__builtin_msa_st_w: - i = 2; - l = -2048; - u = 2044; - m = 4; - break; - case Mips::BI__builtin_msa_st_d: - i = 2; - l = -4096; - u = 4088; - m = 8; - break; - case Mips::BI__builtin_msa_str_d: - i = 2; - l = -4096; - u = 4088; - m = 8; - break; - case Mips::BI__builtin_msa_str_w: - i = 2; - l = -2048; - u = 2044; - m = 4; - break; + case Mips::BI__builtin_msa_ldi_d: i = 0; l = -512; u = 511; break; + case Mips::BI__builtin_msa_ld_b: i = 1; l = -512; u = 511; m = 1; break; + case Mips::BI__builtin_msa_ld_h: i = 1; l = -1024; u = 1022; m = 2; break; + case Mips::BI__builtin_msa_ld_w: i = 1; l = -2048; u = 2044; m = 4; break; + case Mips::BI__builtin_msa_ld_d: i = 1; l = -4096; u = 4088; m = 8; break; + case Mips::BI__builtin_msa_ldr_d: i = 1; l = -4096; u = 4088; m = 8; break; + case Mips::BI__builtin_msa_ldr_w: i = 1; l = -2048; u = 2044; m = 4; break; + case Mips::BI__builtin_msa_st_b: i = 2; l = -512; u = 511; m = 1; break; + case Mips::BI__builtin_msa_st_h: i = 2; l = -1024; u = 1022; m = 2; break; + case Mips::BI__builtin_msa_st_w: i = 2; l = -2048; u = 2044; m = 4; break; + case Mips::BI__builtin_msa_st_d: i = 2; l = -4096; u = 4088; m = 8; break; + case Mips::BI__builtin_msa_str_d: i = 2; l = -4096; u = 4088; m = 8; break; + case Mips::BI__builtin_msa_str_w: i = 2; l = -2048; u = 2044; m = 4; break; } if (!m) @@ -4099,13 +3915,10 @@ static QualType DecodePPCMMATypeFromStr(ASTContext &Context, const char *&Str, Str = End; QualType Type; switch (size) { -#define PPC_VECTOR_TYPE(typeName, Id, size) \ - case size: \ - Type = Context.Id##Ty; \ - break; -#include "clang/Basic/PPCTypes.def" - default: - llvm_unreachable("Invalid PowerPC MMA vector type"); + #define PPC_VECTOR_TYPE(typeName, Id, size) \ + case size: Type = Context.Id##Ty; break; + #include "clang/Basic/PPCTypes.def" + default: llvm_unreachable("Invalid PowerPC MMA vector type"); } bool CheckVectorArgs = false; while (!CheckVectorArgs) { @@ -4215,8 +4028,7 @@ bool Sema::CheckPPCBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, << TheCall->getSourceRange(); switch (BuiltinID) { - default: - return false; + default: return false; case PPC::BI__builtin_altivec_crypto_vshasigmaw: case PPC::BI__builtin_altivec_crypto_vshasigmad: return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1) || @@ -4302,15 +4114,15 @@ bool Sema::CheckPPCBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, return SemaFeatureCheck(*this, TheCall, "isa-v31-instructions", diag::err_ppc_builtin_only_on_arch, "10"); case PPC::BI__builtin_altivec_vgnb: - return SemaBuiltinConstantArgRange(TheCall, 1, 2, 7); + return SemaBuiltinConstantArgRange(TheCall, 1, 2, 7); case PPC::BI__builtin_vsx_xxeval: - return SemaBuiltinConstantArgRange(TheCall, 3, 0, 255); + return SemaBuiltinConstantArgRange(TheCall, 3, 0, 255); case PPC::BI__builtin_altivec_vsldbi: - return SemaBuiltinConstantArgRange(TheCall, 2, 0, 7); + return SemaBuiltinConstantArgRange(TheCall, 2, 0, 7); case PPC::BI__builtin_altivec_vsrdbi: - return SemaBuiltinConstantArgRange(TheCall, 2, 0, 7); + return SemaBuiltinConstantArgRange(TheCall, 2, 0, 7); case PPC::BI__builtin_vsx_xxpermx: - return SemaBuiltinConstantArgRange(TheCall, 3, 0, 7); + return SemaBuiltinConstantArgRange(TheCall, 3, 0, 7); case PPC::BI__builtin_ppc_tw: case PPC::BI__builtin_ppc_tdw: return SemaBuiltinConstantArgRange(TheCall, 2, 1, 31); @@ -4461,7 +4273,7 @@ bool Sema::CheckPPCMMAType(QualType Type, SourceLocation TypeLoc) { #define PPC_VECTOR_TYPE(Name, Id, Size) || CoreType == Context.Id##Ty if (false #include "clang/Basic/PPCTypes.def" - ) { + ) { Diag(TypeLoc, diag::err_ppc_invalid_use_mma_type); return true; } @@ -4595,7 +4407,8 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo &TI, // Error message FeatureMissing = true; Diag(TheCall->getBeginLoc(), diag::err_riscv_builtin_requires_extension) - << IsExtension << TheCall->getSourceRange() << StringRef(FeatureStrs); + << IsExtension + << TheCall->getSourceRange() << StringRef(FeatureStrs); } } @@ -4650,12 +4463,11 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo &TI, } bool Sema::CheckRISCVCOREVBuiltinFunctionCall(unsigned BuiltinID, - CallExpr *TheCall) { + CallExpr *TheCall) { // For intrinsics which take an immediate value as part of the instruction, // range check them here. switch (BuiltinID) { - default: - return false; + default: return false; case RISCVCOREV::BI__builtin_riscv_cv_simd_extract_h: case RISCVCOREV::BI__builtin_riscv_cv_simd_extractu_h: return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1); @@ -4683,21 +4495,12 @@ bool Sema::CheckSystemZBuiltinFunctionCall(unsigned BuiltinID, // range check them here. unsigned i = 0, l = 0, u = 0; switch (BuiltinID) { - default: - return false; - case SystemZ::BI__builtin_s390_lcbb: - i = 1; - l = 0; - u = 15; - break; + default: return false; + case SystemZ::BI__builtin_s390_lcbb: i = 1; l = 0; u = 15; break; case SystemZ::BI__builtin_s390_verimb: case SystemZ::BI__builtin_s390_verimh: case SystemZ::BI__builtin_s390_verimf: - case SystemZ::BI__builtin_s390_verimg: - i = 3; - l = 0; - u = 255; - break; + case SystemZ::BI__builtin_s390_verimg: i = 3; l = 0; u = 255; break; case SystemZ::BI__builtin_s390_vfaeb: case SystemZ::BI__builtin_s390_vfaeh: case SystemZ::BI__builtin_s390_vfaef: @@ -4709,36 +4512,16 @@ bool Sema::CheckSystemZBuiltinFunctionCall(unsigned BuiltinID, case SystemZ::BI__builtin_s390_vfaezf: case SystemZ::BI__builtin_s390_vfaezbs: case SystemZ::BI__builtin_s390_vfaezhs: - case SystemZ::BI__builtin_s390_vfaezfs: - i = 2; - l = 0; - u = 15; - break; + case SystemZ::BI__builtin_s390_vfaezfs: i = 2; l = 0; u = 15; break; case SystemZ::BI__builtin_s390_vfisb: case SystemZ::BI__builtin_s390_vfidb: return SemaBuiltinConstantArgRange(TheCall, 1, 0, 15) || SemaBuiltinConstantArgRange(TheCall, 2, 0, 15); case SystemZ::BI__builtin_s390_vftcisb: - case SystemZ::BI__builtin_s390_vftcidb: - i = 1; - l = 0; - u = 4095; - break; - case SystemZ::BI__builtin_s390_vlbb: - i = 1; - l = 0; - u = 15; - break; - case SystemZ::BI__builtin_s390_vpdi: - i = 2; - l = 0; - u = 15; - break; - case SystemZ::BI__builtin_s390_vsldb: - i = 2; - l = 0; - u = 15; - break; + case SystemZ::BI__builtin_s390_vftcidb: i = 1; l = 0; u = 4095; break; + case SystemZ::BI__builtin_s390_vlbb: i = 1; l = 0; u = 15; break; + case SystemZ::BI__builtin_s390_vpdi: i = 2; l = 0; u = 15; break; + case SystemZ::BI__builtin_s390_vsldb: i = 2; l = 0; u = 15; break; case SystemZ::BI__builtin_s390_vstrcb: case SystemZ::BI__builtin_s390_vstrch: case SystemZ::BI__builtin_s390_vstrcf: @@ -4750,47 +4533,19 @@ bool Sema::CheckSystemZBuiltinFunctionCall(unsigned BuiltinID, case SystemZ::BI__builtin_s390_vstrcfs: case SystemZ::BI__builtin_s390_vstrczbs: case SystemZ::BI__builtin_s390_vstrczhs: - case SystemZ::BI__builtin_s390_vstrczfs: - i = 3; - l = 0; - u = 15; - break; - case SystemZ::BI__builtin_s390_vmslg: - i = 3; - l = 0; - u = 15; - break; + case SystemZ::BI__builtin_s390_vstrczfs: i = 3; l = 0; u = 15; break; + case SystemZ::BI__builtin_s390_vmslg: i = 3; l = 0; u = 15; break; case SystemZ::BI__builtin_s390_vfminsb: case SystemZ::BI__builtin_s390_vfmaxsb: case SystemZ::BI__builtin_s390_vfmindb: - case SystemZ::BI__builtin_s390_vfmaxdb: - i = 2; - l = 0; - u = 15; - break; - case SystemZ::BI__builtin_s390_vsld: - i = 2; - l = 0; - u = 7; - break; - case SystemZ::BI__builtin_s390_vsrd: - i = 2; - l = 0; - u = 7; - break; + case SystemZ::BI__builtin_s390_vfmaxdb: i = 2; l = 0; u = 15; break; + case SystemZ::BI__builtin_s390_vsld: i = 2; l = 0; u = 7; break; + case SystemZ::BI__builtin_s390_vsrd: i = 2; l = 0; u = 7; break; case SystemZ::BI__builtin_s390_vclfnhs: case SystemZ::BI__builtin_s390_vclfnls: case SystemZ::BI__builtin_s390_vcfn: - case SystemZ::BI__builtin_s390_vcnf: - i = 1; - l = 0; - u = 15; - break; - case SystemZ::BI__builtin_s390_vcrnfs: - i = 2; - l = 0; - u = 15; - break; + case SystemZ::BI__builtin_s390_vcnf: i = 1; l = 0; u = 15; break; + case SystemZ::BI__builtin_s390_vcrnfs: i = 2; l = 0; u = 15; break; } return SemaBuiltinConstantArgRange(TheCall, i, l, u); } @@ -5122,8 +4877,9 @@ bool Sema::CheckX86BuiltinRoundingOrSAE(unsigned BuiltinID, CallExpr *TheCall) { // is set. If the intrinsic has rounding control(bits 1:0), make sure its only // combined with ROUND_NO_EXC. If the intrinsic does not have rounding // control, allow ROUND_NO_EXC and ROUND_CUR_DIRECTION together. - if (Result == 4 /*ROUND_CUR_DIRECTION*/ || Result == 8 /*ROUND_NO_EXC*/ || - (!HasRC && Result == 12 /*ROUND_CUR_DIRECTION|ROUND_NO_EXC*/) || + if (Result == 4/*ROUND_CUR_DIRECTION*/ || + Result == 8/*ROUND_NO_EXC*/ || + (!HasRC && Result == 12/*ROUND_CUR_DIRECTION|ROUND_NO_EXC*/) || (HasRC && Result.getZExtValue() >= 8 && Result.getZExtValue() <= 11)) return false; @@ -5351,9 +5107,7 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_extracti64x2_256_mask: case X86::BI__builtin_ia32_extractf32x4_256_mask: case X86::BI__builtin_ia32_extracti32x4_256_mask: - i = 1; - l = 0; - u = 1; + i = 1; l = 0; u = 1; break; case X86::BI__builtin_ia32_vec_set_v2di: case X86::BI__builtin_ia32_vinsertf128_pd256: @@ -5368,9 +5122,7 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_inserti64x2_256: case X86::BI__builtin_ia32_insertf32x4_256: case X86::BI__builtin_ia32_inserti32x4_256: - i = 2; - l = 0; - u = 1; + i = 2; l = 0; u = 1; break; case X86::BI__builtin_ia32_vpermilpd: case X86::BI__builtin_ia32_vec_ext_v4hi: @@ -5381,16 +5133,12 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_extracti32x4_mask: case X86::BI__builtin_ia32_extractf64x2_512_mask: case X86::BI__builtin_ia32_extracti64x2_512_mask: - i = 1; - l = 0; - u = 3; + i = 1; l = 0; u = 3; break; case X86::BI_mm_prefetch: case X86::BI__builtin_ia32_vec_ext_v8hi: case X86::BI__builtin_ia32_vec_ext_v8si: - i = 1; - l = 0; - u = 7; + i = 1; l = 0; u = 7; break; case X86::BI__builtin_ia32_sha1rnds4: case X86::BI__builtin_ia32_blendpd: @@ -5406,17 +5154,13 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_inserti64x2_512: case X86::BI__builtin_ia32_insertf32x4: case X86::BI__builtin_ia32_inserti32x4: - i = 2; - l = 0; - u = 3; + i = 2; l = 0; u = 3; break; case X86::BI__builtin_ia32_vpermil2pd: case X86::BI__builtin_ia32_vpermil2pd256: case X86::BI__builtin_ia32_vpermil2ps: case X86::BI__builtin_ia32_vpermil2ps256: - i = 3; - l = 0; - u = 3; + i = 3; l = 0; u = 3; break; case X86::BI__builtin_ia32_cmpb128_mask: case X86::BI__builtin_ia32_cmpw128_mask: @@ -5452,9 +5196,7 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_vpcomq: case X86::BI__builtin_ia32_vec_set_v8hi: case X86::BI__builtin_ia32_vec_set_v8si: - i = 2; - l = 0; - u = 7; + i = 2; l = 0; u = 7; break; case X86::BI__builtin_ia32_vpermilpd256: case X86::BI__builtin_ia32_roundps: @@ -5472,9 +5214,7 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_getmantph512_mask: case X86::BI__builtin_ia32_vec_ext_v16qi: case X86::BI__builtin_ia32_vec_ext_v16hi: - i = 1; - l = 0; - u = 15; + i = 1; l = 0; u = 15; break; case X86::BI__builtin_ia32_pblendd128: case X86::BI__builtin_ia32_blendps: @@ -5493,14 +5233,10 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_getmantsh_round_mask: case X86::BI__builtin_ia32_vec_set_v16qi: case X86::BI__builtin_ia32_vec_set_v16hi: - i = 2; - l = 0; - u = 15; + i = 2; l = 0; u = 15; break; case X86::BI__builtin_ia32_vec_ext_v32qi: - i = 1; - l = 0; - u = 31; + i = 1; l = 0; u = 31; break; case X86::BI__builtin_ia32_cmpps: case X86::BI__builtin_ia32_cmpss: @@ -5517,9 +5253,7 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_cmpsd_mask: case X86::BI__builtin_ia32_cmpss_mask: case X86::BI__builtin_ia32_vec_set_v32qi: - i = 2; - l = 0; - u = 31; + i = 2; l = 0; u = 31; break; case X86::BI__builtin_ia32_permdf256: case X86::BI__builtin_ia32_permdi256: @@ -5597,9 +5331,7 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_kshiftrihi: case X86::BI__builtin_ia32_kshiftrisi: case X86::BI__builtin_ia32_kshiftridi: - i = 1; - l = 0; - u = 255; + i = 1; l = 0; u = 255; break; case X86::BI__builtin_ia32_vperm2f128_pd256: case X86::BI__builtin_ia32_vperm2f128_ps256: @@ -5649,9 +5381,7 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_vpshrdw128: case X86::BI__builtin_ia32_vpshrdw256: case X86::BI__builtin_ia32_vpshrdw512: - i = 2; - l = 0; - u = 255; + i = 2; l = 0; u = 255; break; case X86::BI__builtin_ia32_fixupimmpd512_mask: case X86::BI__builtin_ia32_fixupimmpd512_maskz: @@ -5681,9 +5411,7 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_pternlogq128_maskz: case X86::BI__builtin_ia32_pternlogq256_mask: case X86::BI__builtin_ia32_pternlogq256_maskz: - i = 3; - l = 0; - u = 255; + i = 3; l = 0; u = 255; break; case X86::BI__builtin_ia32_gatherpfdpd: case X86::BI__builtin_ia32_gatherpfdps: @@ -5693,9 +5421,7 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_scatterpfdps: case X86::BI__builtin_ia32_scatterpfqpd: case X86::BI__builtin_ia32_scatterpfqps: - i = 4; - l = 2; - u = 3; + i = 4; l = 2; u = 3; break; case X86::BI__builtin_ia32_reducesd_mask: case X86::BI__builtin_ia32_reducess_mask: @@ -5703,15 +5429,11 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, case X86::BI__builtin_ia32_rndscaless_round_mask: case X86::BI__builtin_ia32_rndscalesh_round_mask: case X86::BI__builtin_ia32_reducesh_mask: - i = 4; - l = 0; - u = 255; + i = 4; l = 0; u = 255; break; case X86::BI__builtin_ia32_cmpccxadd32: case X86::BI__builtin_ia32_cmpccxadd64: - i = 3; - l = 0; - u = 15; + i = 3; l = 0; u = 15; break; } @@ -5742,7 +5464,7 @@ bool Sema::getFormatStringInfo(const FormatAttr *Format, bool IsCXXMember, // of member functions is counted. However, it doesn't appear in our own // lists, so decrement format_idx in that case. if (IsCXXMember) { - if (FSI->FormatIdx == 0) + if(FSI->FormatIdx == 0) return false; --FSI->FormatIdx; if (FSI->FirstDataArg != 0) @@ -5756,8 +5478,8 @@ bool Sema::getFormatStringInfo(const FormatAttr *Format, bool IsCXXMember, /// Returns true if the value evaluates to null. static bool CheckNonNullExpr(Sema &S, const Expr *Expr) { // If the expression has non-null type, it doesn't evaluate to null. - if (auto nullability = - Expr->IgnoreImplicit()->getType()->getNullability(S.Context)) { + if (auto nullability + = Expr->IgnoreImplicit()->getType()->getNullability(S.Context)) { if (*nullability == NullabilityKind::NonNull) return false; } @@ -5766,18 +5488,21 @@ static bool CheckNonNullExpr(Sema &S, const Expr *Expr) { // considered null for the purposes of the nonnull attribute. if (const RecordType *UT = Expr->getType()->getAsUnionType()) { if (UT->getDecl()->hasAttr()) - if (const CompoundLiteralExpr *CLE = dyn_cast(Expr)) + if (const CompoundLiteralExpr *CLE = + dyn_cast(Expr)) if (const InitListExpr *ILE = - dyn_cast(CLE->getInitializer())) + dyn_cast(CLE->getInitializer())) Expr = ILE->getInit(0); } bool Result; return (!Expr->isValueDependent() && - Expr->EvaluateAsBooleanCondition(Result, S.Context) && !Result); + Expr->EvaluateAsBooleanCondition(Result, S.Context) && + !Result); } -static void CheckNonNullArgument(Sema &S, const Expr *ArgExpr, +static void CheckNonNullArgument(Sema &S, + const Expr *ArgExpr, SourceLocation CallSiteLoc) { if (CheckNonNullExpr(S, ArgExpr)) S.DiagRuntimeBehavior(CallSiteLoc, ArgExpr, @@ -5797,17 +5522,19 @@ bool Sema::GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx) { /// Diagnose use of %s directive in an NSString which is being passed /// as formatting string to formatting method. -static void DiagnoseCStringFormatDirectiveInCFAPI(Sema &S, - const NamedDecl *FDecl, - Expr **Args, - unsigned NumArgs) { +static void +DiagnoseCStringFormatDirectiveInCFAPI(Sema &S, + const NamedDecl *FDecl, + Expr **Args, + unsigned NumArgs) { unsigned Idx = 0; bool Format = false; ObjCStringFormatFamily SFFamily = FDecl->getObjCFStringFormattingFamily(); if (SFFamily == ObjCStringFormatFamily::SFF_CFString) { Idx = 2; Format = true; - } else + } + else for (const auto *I : FDecl->specific_attrs()) { if (S.GetFormatNSStringIdx(I, Idx)) { Format = true; @@ -5821,7 +5548,7 @@ static void DiagnoseCStringFormatDirectiveInCFAPI(Sema &S, FormatExpr = CSCE->getSubExpr(); const StringLiteral *FormatString; if (const ObjCStringLiteral *OSL = - dyn_cast(FormatExpr->IgnoreParenImpCasts())) + dyn_cast(FormatExpr->IgnoreParenImpCasts())) FormatString = OSL->getString(); else FormatString = dyn_cast(FormatExpr->IgnoreParenImpCasts()); @@ -5829,9 +5556,9 @@ static void DiagnoseCStringFormatDirectiveInCFAPI(Sema &S, return; if (S.FormatStringHasSArg(FormatString)) { S.Diag(FormatExpr->getExprLoc(), diag::warn_objc_cdirective_format_string) - << "%s" << 1 << 1; + << "%s" << 1 << 1; S.Diag(FDecl->getLocation(), diag::note_entity_declared_at) - << FDecl->getDeclName(); + << FDecl->getDeclName(); } } @@ -5843,7 +5570,8 @@ static bool isNonNullType(ASTContext &ctx, QualType type) { return false; } -static void CheckNonNullArguments(Sema &S, const NamedDecl *FDecl, +static void CheckNonNullArguments(Sema &S, + const NamedDecl *FDecl, const FunctionProtoType *Proto, ArrayRef Args, SourceLocation CallSiteLoc) { @@ -5879,14 +5607,14 @@ static void CheckNonNullArguments(Sema &S, const NamedDecl *FDecl, if (FDecl && (isa(FDecl) || isa(FDecl))) { // Handle the nonnull attribute on the parameters of the // function/method. - ArrayRef parms; + ArrayRef parms; if (const FunctionDecl *FD = dyn_cast(FDecl)) parms = FD->parameters(); else parms = cast(FDecl)->parameters(); unsigned ParamIndex = 0; - for (ArrayRef::iterator I = parms.begin(), E = parms.end(); + for (ArrayRef::iterator I = parms.begin(), E = parms.end(); I != E; ++I, ++ParamIndex) { const ParmVarDecl *PVD = *I; if (PVD->hasAttr() || @@ -6041,11 +5769,11 @@ void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto, if (CallType != VariadicDoesNotApply && (!FD || FD->getBuiltinID() != Builtin::BI__noop)) { unsigned NumParams = Proto ? Proto->getNumParams() - : FDecl && isa(FDecl) - ? cast(FDecl)->getNumParams() - : FDecl && isa(FDecl) - ? cast(FDecl)->param_size() - : 0; + : FDecl && isa(FDecl) + ? cast(FDecl)->getNumParams() + : FDecl && isa(FDecl) + ? cast(FDecl)->param_size() + : 0; for (unsigned ArgIdx = NumParams; ArgIdx < Args.size(); ++ArgIdx) { // Args[ArgIdx] can be null in malformed code. @@ -6140,13 +5868,13 @@ void Sema::CheckConstructorCall(FunctionDecl *FDecl, QualType ThisType, /// and safety properties not strictly enforced by the C type system. bool Sema::CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall, const FunctionProtoType *Proto) { - bool IsMemberOperatorCall = - isa(TheCall) && isa(FDecl); - bool IsMemberFunction = - isa(TheCall) || IsMemberOperatorCall; - VariadicCallType CallType = - getVariadicCallType(FDecl, Proto, TheCall->getCallee()); - Expr **Args = TheCall->getArgs(); + bool IsMemberOperatorCall = isa(TheCall) && + isa(FDecl); + bool IsMemberFunction = isa(TheCall) || + IsMemberOperatorCall; + VariadicCallType CallType = getVariadicCallType(FDecl, Proto, + TheCall->getCallee()); + Expr** Args = TheCall->getArgs(); unsigned NumArgs = TheCall->getNumArgs(); Expr *ImplicitThis = nullptr; @@ -6268,8 +5996,8 @@ bool Sema::CheckPointerCall(NamedDecl *NDecl, CallExpr *TheCall, /// Checks function calls when a FunctionDecl or a NamedDecl is not available, /// such as function pointers returned from functions. bool Sema::CheckOtherCall(CallExpr *TheCall, const FunctionProtoType *Proto) { - VariadicCallType CallType = - getVariadicCallType(/*FDecl=*/nullptr, Proto, TheCall->getCallee()); + VariadicCallType CallType = getVariadicCallType(/*FDecl=*/nullptr, Proto, + TheCall->getCallee()); checkCall(/*FDecl=*/nullptr, Proto, /*ThisArg=*/nullptr, llvm::makeArrayRef(TheCall->getArgs(), TheCall->getNumArgs()), /*IsMemberFunction=*/false, TheCall->getRParenLoc(), @@ -6313,8 +6041,7 @@ static bool isValidOrderingForOp(int64_t Ordering, AtomicExpr::AtomicOp Op) { ExprResult Sema::SemaAtomicOpsOverloaded(ExprResult TheCallResult, AtomicExpr::AtomicOp Op) { CallExpr *TheCall = cast(TheCallResult.get()); - DeclRefExpr *DRE = - cast(TheCall->getCallee()->IgnoreParenCasts()); + DeclRefExpr *DRE =cast(TheCall->getCallee()->IgnoreParenCasts()); MultiExprArg Args{TheCall->getArgs(), TheCall->getNumArgs()}; return BuildAtomicExpr({TheCall->getBeginLoc(), TheCall->getEndLoc()}, DRE->getSourceRange(), TheCall->getRParenLoc(), Args, @@ -6358,8 +6085,8 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, } Form = Init; const unsigned NumForm = GNUCmpXchg + 1; - const unsigned NumArgs[] = {2, 2, 3, 3, 3, 3, 4, 5, 6}; - const unsigned NumVals[] = {1, 0, 1, 1, 1, 1, 2, 2, 3}; + const unsigned NumArgs[] = { 2, 2, 3, 3, 3, 3, 4, 5, 6 }; + const unsigned NumVals[] = { 1, 0, 1, 1, 1, 1, 2, 2, 3 }; // where: // C is an appropriate type, // A is volatile _Atomic(C) for __c11 builtins and is C for GNU builtins, @@ -6367,9 +6094,9 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, // M is C if C is an integer, and ptrdiff_t if C is a pointer, and // the int parameters are for orderings. - static_assert(sizeof(NumArgs) / sizeof(NumArgs[0]) == NumForm && - sizeof(NumVals) / sizeof(NumVals[0]) == NumForm, - "need to update code for modified forms"); + static_assert(sizeof(NumArgs)/sizeof(NumArgs[0]) == NumForm + && sizeof(NumVals)/sizeof(NumVals[0]) == NumForm, + "need to update code for modified forms"); static_assert(AtomicExpr::AO__c11_atomic_init == 0 && AtomicExpr::AO__c11_atomic_fetch_min + 1 == AtomicExpr::AO__atomic_load, @@ -6379,7 +6106,7 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, bool IsHIP = Op >= AtomicExpr::AO__hip_atomic_load && Op <= AtomicExpr::AO__hip_atomic_fetch_max; bool IsC11 = (Op >= AtomicExpr::AO__c11_atomic_init && - Op <= AtomicExpr::AO__c11_atomic_fetch_min) || + Op <= AtomicExpr::AO__c11_atomic_fetch_min) || IsOpenCL; bool IsN = Op == AtomicExpr::AO__atomic_load_n || Op == AtomicExpr::AO__atomic_store_n || @@ -6515,7 +6242,7 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, // For a __c11 builtin, this should be a pointer to an _Atomic type. QualType AtomTy = pointerType->getPointeeType(); // 'A' - QualType ValType = AtomTy; // 'C' + QualType ValType = AtomTy; // 'C' if (IsC11) { if (!AtomTy->isAtomicType()) { Diag(ExprRange.getBegin(), diag::err_atomic_op_needs_atomic) @@ -6613,7 +6340,8 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, ValType.removeLocalVolatile(); ValType.removeLocalConst(); QualType ResultType = ValType; - if (Form == Copy || Form == LoadCopy || Form == GNUXchg || Form == Init) + if (Form == Copy || Form == LoadCopy || Form == GNUXchg || + Form == Init) ResultType = Context.VoidTy; else if (Form == C11CmpXchg || Form == GNUCmpXchg) ResultType = Context.BoolTy; @@ -6737,7 +6465,7 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, } // Permute the arguments into a 'consistent' order. - SmallVector SubExprs; + SmallVector SubExprs; SubExprs.push_back(Ptr); switch (Form) { case Init: @@ -6833,7 +6561,7 @@ static bool checkBuiltinArgument(Sema &S, CallExpr *E, unsigned ArgIndex) { ParmVarDecl *Param = Fn->getParamDecl(ArgIndex); InitializedEntity Entity = - InitializedEntity::InitializeParameter(S.Context, Param); + InitializedEntity::InitializeParameter(S.Context, Param); ExprResult Arg = E->getArg(ArgIndex); Arg = S.PerformCopyInitialization(Entity, SourceLocation(), Arg); @@ -6851,7 +6579,8 @@ static bool checkBuiltinArgument(Sema &S, CallExpr *E, unsigned ArgIndex) { /// /// This function goes through and does final semantic checking for these /// builtins, as well as generating any warnings. -ExprResult Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { +ExprResult +Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { CallExpr *TheCall = static_cast(TheCallResult.get()); Expr *Callee = TheCall->getCallee(); DeclRefExpr *DRE = cast(Callee->IgnoreParenCasts()); @@ -6921,52 +6650,41 @@ ExprResult Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { // We need to figure out which concrete builtin this maps onto. For example, // __sync_fetch_and_add with a 2 byte object turns into // __sync_fetch_and_add_2. -#define BUILTIN_ROW(x) \ - { \ - Builtin::BI##x##_1, Builtin::BI##x##_2, Builtin::BI##x##_4, \ - Builtin::BI##x##_8, Builtin::BI##x##_16 \ - } +#define BUILTIN_ROW(x) \ + { Builtin::BI##x##_1, Builtin::BI##x##_2, Builtin::BI##x##_4, \ + Builtin::BI##x##_8, Builtin::BI##x##_16 } static const unsigned BuiltinIndices[][5] = { - BUILTIN_ROW(__sync_fetch_and_add), - BUILTIN_ROW(__sync_fetch_and_sub), - BUILTIN_ROW(__sync_fetch_and_or), - BUILTIN_ROW(__sync_fetch_and_and), - BUILTIN_ROW(__sync_fetch_and_xor), - BUILTIN_ROW(__sync_fetch_and_nand), - - BUILTIN_ROW(__sync_add_and_fetch), - BUILTIN_ROW(__sync_sub_and_fetch), - BUILTIN_ROW(__sync_and_and_fetch), - BUILTIN_ROW(__sync_or_and_fetch), - BUILTIN_ROW(__sync_xor_and_fetch), - BUILTIN_ROW(__sync_nand_and_fetch), - - BUILTIN_ROW(__sync_val_compare_and_swap), - BUILTIN_ROW(__sync_bool_compare_and_swap), - BUILTIN_ROW(__sync_lock_test_and_set), - BUILTIN_ROW(__sync_lock_release), - BUILTIN_ROW(__sync_swap)}; + BUILTIN_ROW(__sync_fetch_and_add), + BUILTIN_ROW(__sync_fetch_and_sub), + BUILTIN_ROW(__sync_fetch_and_or), + BUILTIN_ROW(__sync_fetch_and_and), + BUILTIN_ROW(__sync_fetch_and_xor), + BUILTIN_ROW(__sync_fetch_and_nand), + + BUILTIN_ROW(__sync_add_and_fetch), + BUILTIN_ROW(__sync_sub_and_fetch), + BUILTIN_ROW(__sync_and_and_fetch), + BUILTIN_ROW(__sync_or_and_fetch), + BUILTIN_ROW(__sync_xor_and_fetch), + BUILTIN_ROW(__sync_nand_and_fetch), + + BUILTIN_ROW(__sync_val_compare_and_swap), + BUILTIN_ROW(__sync_bool_compare_and_swap), + BUILTIN_ROW(__sync_lock_test_and_set), + BUILTIN_ROW(__sync_lock_release), + BUILTIN_ROW(__sync_swap) + }; #undef BUILTIN_ROW // Determine the index of the size. unsigned SizeIndex; switch (Context.getTypeSizeInChars(ValType).getQuantity()) { - case 1: - SizeIndex = 0; - break; - case 2: - SizeIndex = 1; - break; - case 4: - SizeIndex = 2; - break; - case 8: - SizeIndex = 3; - break; - case 16: - SizeIndex = 4; - break; + case 1: SizeIndex = 0; break; + case 2: SizeIndex = 1; break; + case 4: SizeIndex = 2; break; + case 8: SizeIndex = 3; break; + case 16: SizeIndex = 4; break; default: Diag(DRE->getBeginLoc(), diag::err_atomic_builtin_pointer_size) << FirstArg->getType() << FirstArg->getSourceRange(); @@ -6981,8 +6699,7 @@ ExprResult Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { unsigned BuiltinIndex, NumFixed = 1; bool WarnAboutSemanticsChange = false; switch (BuiltinID) { - default: - llvm_unreachable("Unknown overloaded atomic builtin!"); + default: llvm_unreachable("Unknown overloaded atomic builtin!"); case Builtin::BI__sync_fetch_and_add: case Builtin::BI__sync_fetch_and_add_1: case Builtin::BI__sync_fetch_and_add_2: @@ -7146,7 +6863,7 @@ ExprResult Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { // Now that we know how many fixed arguments we expect, first check that we // have at least that many. - if (TheCall->getNumArgs() < 1 + NumFixed) { + if (TheCall->getNumArgs() < 1+NumFixed) { Diag(TheCall->getEndLoc(), diag::err_typecheck_call_too_few_args_at_least) << 0 << 1 + NumFixed << TheCall->getNumArgs() << Callee->getSourceRange(); @@ -7183,13 +6900,13 @@ ExprResult Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { // deduce the types of the rest of the arguments accordingly. Walk // the remaining arguments, converting them to the deduced value type. for (unsigned i = 0; i != NumFixed; ++i) { - ExprResult Arg = TheCall->getArg(i + 1); + ExprResult Arg = TheCall->getArg(i+1); // GCC does an implicit conversion to the pointer or integer ValType. This // can fail in some cases (1i -> int**), check for this error case now. // Initialize the argument. - InitializedEntity Entity = InitializedEntity::InitializeParameter( - Context, ValType, /*consume*/ false); + InitializedEntity Entity = InitializedEntity::InitializeParameter(Context, + ValType, /*consume*/ false); Arg = PerformCopyInitialization(Entity, SourceLocation(), Arg); if (Arg.isInvalid()) return ExprError(); @@ -7200,7 +6917,7 @@ ExprResult Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { // pass in 42. The 42 gets converted to char. This is even more strange // for things like 45.123 -> char, etc. // FIXME: Do this check. - TheCall->setArg(i + 1, Arg.get()); + TheCall->setArg(i+1, Arg.get()); } // Create a new DeclRefExpr to refer to the new decl. @@ -7212,8 +6929,8 @@ ExprResult Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { // Set the callee in the CallExpr. // FIXME: This loses syntactic information. QualType CalleePtrTy = Context.getPointerType(NewBuiltinDecl->getType()); - ExprResult PromotedCall = - ImpCastExprToType(NewDRE, CalleePtrTy, CK_BuiltinFnToFnPtr); + ExprResult PromotedCall = ImpCastExprToType(NewDRE, CalleePtrTy, + CK_BuiltinFnToFnPtr); TheCall->setCallee(PromotedCall.get()); // Change the result type of the call to match the original value type. This @@ -7385,7 +7102,8 @@ static bool checkVAStartABI(Sema &S, unsigned BuiltinID, Expr *Fn) { // On x64 Windows, don't allow this in System V ABI functions. // (Yes, that means there's no corresponding way to support variadic // System V ABI functions on Windows.) - if ((IsWindows && CC == CC_X86_64SysV) || (!IsWindows && CC == CC_Win64)) + if ((IsWindows && CC == CC_X86_64SysV) || + (!IsWindows && CC == CC_Win64)) return S.Diag(Fn->getBeginLoc(), diag::err_va_start_used_in_wrong_abi_function) << !IsWindows; @@ -7398,9 +7116,8 @@ static bool checkVAStartABI(Sema &S, unsigned BuiltinID, Expr *Fn) { return false; } -static bool -checkVAStartIsInVariadicFunction(Sema &S, Expr *Fn, - ParmVarDecl **LastParam = nullptr) { +static bool checkVAStartIsInVariadicFunction(Sema &S, Expr *Fn, + ParmVarDecl **LastParam = nullptr) { // Determine whether the current function, block, or obj-c method is variadic // and get its parameter list. bool IsVariadic = false; @@ -7496,10 +7213,8 @@ bool Sema::SemaBuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall) { Context.typesAreCompatible(ED->getPromotionType(), Type)); }()) { unsigned Reason = 0; - if (Type->isReferenceType()) - Reason = 1; - else if (IsCRegister) - Reason = 2; + if (Type->isReferenceType()) Reason = 1; + else if (IsCRegister) Reason = 2; Diag(Arg->getBeginLoc(), diag::warn_va_start_type_is_undefined) << Reason; Diag(ParamLoc, diag::note_parameter_type) << Type; } @@ -7630,7 +7345,7 @@ bool Sema::SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs) { TheCall->setArg(i, Res.get()); } - Expr *OrigArg = TheCall->getArg(NumArgs - 1); + Expr *OrigArg = TheCall->getArg(NumArgs-1); if (OrigArg->isTypeDependent()) return false; @@ -7690,8 +7405,8 @@ bool Sema::SemaBuiltinComplex(CallExpr *TheCall) { if (!Context.hasSameType(Real->getType(), Imag->getType())) { return Diag(Real->getBeginLoc(), diag::err_typecheck_call_different_arg_types) - << Real->getType() << Imag->getType() << Real->getSourceRange() - << Imag->getSourceRange(); + << Real->getType() << Imag->getType() + << Real->getSourceRange() << Imag->getSourceRange(); } // We don't allow _Complex _Float16 nor _Complex __fp16 as type specifiers; @@ -7833,7 +7548,7 @@ ExprResult Sema::SemaBuiltinShuffleVector(CallExpr *TheCall) { << TheCall->getArg(i)->getSourceRange()); } - SmallVector exprs; + SmallVector exprs; for (unsigned i = 0, e = TheCall->getNumArgs(); i != e; i++) { exprs.push_back(TheCall->getArg(i)); @@ -7855,18 +7570,20 @@ ExprResult Sema::SemaConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, QualType SrcTy = E->getType(); if (!SrcTy->isVectorType() && !SrcTy->isDependentType()) - return ExprError(Diag(BuiltinLoc, diag::err_convertvector_non_vector) + return ExprError(Diag(BuiltinLoc, + diag::err_convertvector_non_vector) << E->getSourceRange()); if (!DstTy->isVectorType() && !DstTy->isDependentType()) - return ExprError(Diag(BuiltinLoc, diag::err_convertvector_non_vector_type)); + return ExprError(Diag(BuiltinLoc, + diag::err_convertvector_non_vector_type)); if (!SrcTy->isDependentType() && !DstTy->isDependentType()) { unsigned SrcElts = SrcTy->castAs()->getNumElements(); unsigned DstElts = DstTy->castAs()->getNumElements(); if (SrcElts != DstElts) - return ExprError( - Diag(BuiltinLoc, diag::err_convertvector_incompatible_vector) - << E->getSourceRange()); + return ExprError(Diag(BuiltinLoc, + diag::err_convertvector_incompatible_vector) + << E->getSourceRange()); } return new (Context) @@ -7921,8 +7638,7 @@ bool Sema::SemaBuiltinArithmeticFence(CallExpr *TheCall) { // has side effects. bool Sema::SemaBuiltinAssume(CallExpr *TheCall) { Expr *Arg = TheCall->getArg(0); - if (Arg->isInstantiationDependent()) - return false; + if (Arg->isInstantiationDependent()) return false; if (Arg->HasSideEffects(Context)) Diag(Arg->getBeginLoc(), diag::warn_assume_side_effects) @@ -7976,7 +7692,8 @@ bool Sema::SemaBuiltinAssumeAligned(CallExpr *TheCall) { Expr *FirstArg = TheCall->getArg(0); { - ExprResult FirstArgResult = DefaultFunctionArrayLvalueConversion(FirstArg); + ExprResult FirstArgResult = + DefaultFunctionArrayLvalueConversion(FirstArg); if (FirstArgResult.isInvalid()) return true; TheCall->setArg(0, FirstArgResult.get()); @@ -8095,12 +7812,10 @@ bool Sema::SemaBuiltinOSLogFormat(CallExpr *TheCall) { bool Sema::SemaBuiltinConstantArg(CallExpr *TheCall, int ArgNum, llvm::APSInt &Result) { Expr *Arg = TheCall->getArg(ArgNum); - DeclRefExpr *DRE = - cast(TheCall->getCallee()->IgnoreParenCasts()); + DeclRefExpr *DRE =cast(TheCall->getCallee()->IgnoreParenCasts()); FunctionDecl *FDecl = cast(DRE->getDecl()); - if (Arg->isTypeDependent() || Arg->isValueDependent()) - return false; + if (Arg->isTypeDependent() || Arg->isValueDependent()) return false; Optional R; if (!(R = Arg->getIntegerConstantExpr(Context))) @@ -8112,8 +7827,8 @@ bool Sema::SemaBuiltinConstantArg(CallExpr *TheCall, int ArgNum, /// SemaBuiltinConstantArgRange - Handle a check if argument ArgNum of CallExpr /// TheCall is a constant expression in the range [Low, High]. -bool Sema::SemaBuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low, - int High, bool RangeIsError) { +bool Sema::SemaBuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, + int Low, int High, bool RangeIsError) { if (isConstantEvaluated()) return false; llvm::APSInt Result; @@ -8143,8 +7858,8 @@ bool Sema::SemaBuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low, return false; } -/// SemaBuiltinConstantArgMultiple - Handle a check if argument ArgNum of -/// CallExpr TheCall is a constant expression is a multiple of Num.. +/// SemaBuiltinConstantArgMultiple - Handle a check if argument ArgNum of CallExpr +/// TheCall is a constant expression is a multiple of Num.. bool Sema::SemaBuiltinConstantArgMultiple(CallExpr *TheCall, int ArgNum, unsigned Num) { llvm::APSInt Result; @@ -8271,8 +7986,7 @@ bool Sema::SemaBuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall, } /// SemaBuiltinARMMemoryTaggingCall - Handle calls of memory tagging extensions -bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, - CallExpr *TheCall) { +bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall) { if (BuiltinID == AArch64::BI__builtin_arm_irg) { if (checkArgCount(*this, TheCall, 2)) return true; @@ -8285,7 +7999,7 @@ bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, QualType FirstArgType = FirstArg.get()->getType(); if (!FirstArgType->isAnyPointerType()) return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_must_be_pointer) - << "first" << FirstArgType << Arg0->getSourceRange(); + << "first" << FirstArgType << Arg0->getSourceRange(); TheCall->setArg(0, FirstArg.get()); ExprResult SecArg = DefaultLvalueConversion(Arg1); @@ -8294,7 +8008,7 @@ bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, QualType SecArgType = SecArg.get()->getType(); if (!SecArgType->isIntegerType()) return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_must_be_integer) - << "second" << SecArgType << Arg1->getSourceRange(); + << "second" << SecArgType << Arg1->getSourceRange(); // Derive the return type from the pointer argument. TheCall->setType(FirstArgType); @@ -8312,7 +8026,7 @@ bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, QualType FirstArgType = FirstArg.get()->getType(); if (!FirstArgType->isAnyPointerType()) return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_must_be_pointer) - << "first" << FirstArgType << Arg0->getSourceRange(); + << "first" << FirstArgType << Arg0->getSourceRange(); TheCall->setArg(0, FirstArg.get()); // Derive the return type from the pointer argument. @@ -8334,12 +8048,12 @@ bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, QualType FirstArgType = FirstArg.get()->getType(); if (!FirstArgType->isAnyPointerType()) return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_must_be_pointer) - << "first" << FirstArgType << Arg0->getSourceRange(); + << "first" << FirstArgType << Arg0->getSourceRange(); QualType SecArgType = Arg1->getType(); if (!SecArgType->isIntegerType()) return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_must_be_integer) - << "second" << SecArgType << Arg1->getSourceRange(); + << "second" << SecArgType << Arg1->getSourceRange(); TheCall->setType(Context.IntTy); return false; } @@ -8356,7 +8070,7 @@ bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, QualType FirstArgType = FirstArg.get()->getType(); if (!FirstArgType->isAnyPointerType()) return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_must_be_pointer) - << "first" << FirstArgType << Arg0->getSourceRange(); + << "first" << FirstArgType << Arg0->getSourceRange(); TheCall->setArg(0, FirstArg.get()); // Derive the return type from the pointer argument. @@ -8378,19 +8092,18 @@ bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, QualType ArgTypeA = ArgExprA.get()->getType(); QualType ArgTypeB = ArgExprB.get()->getType(); - auto isNull = [&](Expr *E) -> bool { - return E->isNullPointerConstant(Context, - Expr::NPC_ValueDependentIsNotNull); - }; + auto isNull = [&] (Expr *E) -> bool { + return E->isNullPointerConstant( + Context, Expr::NPC_ValueDependentIsNotNull); }; // argument should be either a pointer or null if (!ArgTypeA->isAnyPointerType() && !isNull(ArgA)) return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_null_or_pointer) - << "first" << ArgTypeA << ArgA->getSourceRange(); + << "first" << ArgTypeA << ArgA->getSourceRange(); if (!ArgTypeB->isAnyPointerType() && !isNull(ArgB)) return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_null_or_pointer) - << "second" << ArgTypeB << ArgB->getSourceRange(); + << "second" << ArgTypeB << ArgB->getSourceRange(); // Ensure Pointee types are compatible if (ArgTypeA->isAnyPointerType() && !isNull(ArgA) && @@ -8398,19 +8111,18 @@ bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, QualType pointeeA = ArgTypeA->getPointeeType(); QualType pointeeB = ArgTypeB->getPointeeType(); if (!Context.typesAreCompatible( - Context.getCanonicalType(pointeeA).getUnqualifiedType(), - Context.getCanonicalType(pointeeB).getUnqualifiedType())) { - return Diag(TheCall->getBeginLoc(), - diag::err_typecheck_sub_ptr_compatible) - << ArgTypeA << ArgTypeB << ArgA->getSourceRange() - << ArgB->getSourceRange(); + Context.getCanonicalType(pointeeA).getUnqualifiedType(), + Context.getCanonicalType(pointeeB).getUnqualifiedType())) { + return Diag(TheCall->getBeginLoc(), diag::err_typecheck_sub_ptr_compatible) + << ArgTypeA << ArgTypeB << ArgA->getSourceRange() + << ArgB->getSourceRange(); } } // at least one argument should be pointer type if (!ArgTypeA->isAnyPointerType() && !ArgTypeB->isAnyPointerType()) return Diag(TheCall->getBeginLoc(), diag::err_memtag_any2arg_pointer) - << ArgTypeA << ArgTypeB << ArgA->getSourceRange(); + << ArgTypeA << ArgTypeB << ArgA->getSourceRange(); if (isNull(ArgA)) // adopt type of the other pointer ArgExprA = ImpCastExprToType(ArgExprA.get(), ArgTypeB, CK_NullToPointer); @@ -8497,7 +8209,7 @@ bool Sema::SemaBuiltinARMSpecialReg(unsigned BuiltinID, CallExpr *TheCall, else Ranges.append({15, 7, 15}); - for (unsigned i = 0; i < Fields.size(); ++i) { + for (unsigned i=0; i= 0 && IntField <= Ranges[i]); @@ -8610,7 +8322,7 @@ bool Sema::SemaBuiltinPPCMMACall(CallExpr *TheCall, unsigned BuiltinID, // number of arguments in TheCall and if it is not the case, to display a // better error message. while (*TypeStr != '\0') { - (void)DecodePPCMMATypeFromStr(Context, TypeStr, Mask); + (void) DecodePPCMMATypeFromStr(Context, TypeStr, Mask); ArgNum++; } if (checkArgCount(*this, TheCall, ArgNum)) @@ -8661,7 +8373,9 @@ class UncoveredArgHandler { public: UncoveredArgHandler() = default; - bool hasUncoveredArg() const { return (FirstUncoveredArg >= 0); } + bool hasUncoveredArg() const { + return (FirstUncoveredArg >= 0); + } unsigned getUncoveredArg() const { assert(hasUncoveredArg() && "no uncovered argument"); @@ -8705,7 +8419,8 @@ enum StringLiteralCheckType { } // namespace static void sumOffsets(llvm::APSInt &Offset, llvm::APSInt Addend, - BinaryOperatorKind BinOpKind, bool AddendIsRight) { + BinaryOperatorKind BinOpKind, + bool AddendIsRight) { unsigned BitWidth = Offset.getBitWidth(); unsigned AddendBitWidth = Addend.getBitWidth(); // There might be negative interim results. @@ -8753,11 +8468,13 @@ class FormatStringLiteral { const StringLiteral *FExpr; int64_t Offset; -public: + public: FormatStringLiteral(const StringLiteral *fexpr, int64_t Offset = 0) : FExpr(fexpr), Offset(Offset) {} - StringRef getString() const { return FExpr->getString().drop_front(Offset); } + StringRef getString() const { + return FExpr->getString().drop_front(Offset); + } unsigned getByteLength() const { return FExpr->getByteLength() - getCharByteWidth() * Offset; @@ -8777,11 +8494,10 @@ class FormatStringLiteral { bool isUTF32() const { return FExpr->isUTF32(); } bool isPascal() const { return FExpr->isPascal(); } - SourceLocation - getLocationOfByte(unsigned ByteNo, const SourceManager &SM, - const LangOptions &Features, const TargetInfo &Target, - unsigned *StartToken = nullptr, - unsigned *StartTokenByteOffset = nullptr) const { + SourceLocation getLocationOfByte( + unsigned ByteNo, const SourceManager &SM, const LangOptions &Features, + const TargetInfo &Target, unsigned *StartToken = nullptr, + unsigned *StartTokenByteOffset = nullptr) const { return FExpr->getLocationOfByte(ByteNo + Offset, SM, Features, Target, StartToken, StartTokenByteOffset); } @@ -8840,7 +8556,8 @@ checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef Args, case Stmt::ConditionalOperatorClass: { // The expression is a literal if both sub-expressions were, and it was // completely checked only if both sub-expressions were checked. - const AbstractConditionalOperator *C = cast(E); + const AbstractConditionalOperator *C = + cast(E); // Determine whether it is necessary to check both sub-expressions, for // example, because the condition expression is a constant that can be @@ -9016,8 +8733,7 @@ checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef Args, case Stmt::CallExprClass: case Stmt::CXXMemberCallExprClass: { const CallExpr *CE = cast(E); - if (const NamedDecl *ND = - dyn_cast_or_null(CE->getCalleeDecl())) { + if (const NamedDecl *ND = dyn_cast_or_null(CE->getCalleeDecl())) { bool IsFirst = true; StringLiteralCheckType CommonResult; for (const auto *FA : ND->specific_attrs()) { @@ -9243,7 +8959,7 @@ bool Sema::CheckFormatArguments(ArrayRef Args, if (UncoveredArg.hasUncoveredArg()) { unsigned ArgIdx = UncoveredArg.getUncoveredArg() + firstDataArg; assert(ArgIdx < Args.size() && "ArgIdx outside bounds"); - UncoveredArg.Diagnose(*this, /*IsFunctionCall*/ true, Args[ArgIdx]); + UncoveredArg.Diagnose(*this, /*IsFunctionCall*/true, Args[ArgIdx]); } if (CT != SLCT_NotALiteral) @@ -9267,7 +8983,7 @@ bool Sema::CheckFormatArguments(ArrayRef Args, // warn only with -Wformat-nonliteral. if (Args.size() == firstDataArg) { Diag(FormatLoc, diag::warn_format_nonliteral_noargs) - << OrigFormatExpr->getSourceRange(); + << OrigFormatExpr->getSourceRange(); switch (Type) { default: break; @@ -9275,16 +8991,16 @@ bool Sema::CheckFormatArguments(ArrayRef Args, case FST_FreeBSDKPrintf: case FST_Printf: Diag(FormatLoc, diag::note_format_security_fixit) - << FixItHint::CreateInsertion(FormatLoc, "\"%s\", "); + << FixItHint::CreateInsertion(FormatLoc, "\"%s\", "); break; case FST_NSString: Diag(FormatLoc, diag::note_format_security_fixit) - << FixItHint::CreateInsertion(FormatLoc, "@\"%@\", "); + << FixItHint::CreateInsertion(FormatLoc, "@\"%@\", "); break; } } else { Diag(FormatLoc, diag::warn_format_nonliteral) - << OrigFormatExpr->getSourceRange(); + << OrigFormatExpr->getSourceRange(); } return false; } @@ -9336,21 +9052,23 @@ class CheckFormatHandler : public analyze_format_string::FormatStringHandler { unsigned specifierLen) override; void HandleInvalidLengthModifier( - const analyze_format_string::FormatSpecifier &FS, - const analyze_format_string::ConversionSpecifier &CS, - const char *startSpecifier, unsigned specifierLen, unsigned DiagID); + const analyze_format_string::FormatSpecifier &FS, + const analyze_format_string::ConversionSpecifier &CS, + const char *startSpecifier, unsigned specifierLen, + unsigned DiagID); void HandleNonStandardLengthModifier( - const analyze_format_string::FormatSpecifier &FS, - const char *startSpecifier, unsigned specifierLen); + const analyze_format_string::FormatSpecifier &FS, + const char *startSpecifier, unsigned specifierLen); void HandleNonStandardConversionSpecifier( - const analyze_format_string::ConversionSpecifier &CS, - const char *startSpecifier, unsigned specifierLen); + const analyze_format_string::ConversionSpecifier &CS, + const char *startSpecifier, unsigned specifierLen); void HandlePosition(const char *startPos, unsigned posLen) override; - void HandleInvalidPosition(const char *startSpecifier, unsigned specifierLen, + void HandleInvalidPosition(const char *startSpecifier, + unsigned specifierLen, analyze_format_string::PositionContext p) override; void HandleZeroPosition(const char *startPos, unsigned posLen) override; @@ -9398,11 +9116,10 @@ SourceRange CheckFormatHandler::getFormatStringRange() { return OrigFormatExpr->getSourceRange(); } -CharSourceRange -CheckFormatHandler::getSpecifierRange(const char *startSpecifier, - unsigned specifierLen) { +CharSourceRange CheckFormatHandler:: +getSpecifierRange(const char *startSpecifier, unsigned specifierLen) { SourceLocation Start = getLocationOfByte(startSpecifier); - SourceLocation End = getLocationOfByte(startSpecifier + specifierLen - 1); + SourceLocation End = getLocationOfByte(startSpecifier + specifierLen - 1); // Advance the end SourceLocation by one due to half-open ranges. End = End.getLocWithOffset(1); @@ -9416,10 +9133,10 @@ SourceLocation CheckFormatHandler::getLocationOfByte(const char *x) { } void CheckFormatHandler::HandleIncompleteSpecifier(const char *startSpecifier, - unsigned specifierLen) { + unsigned specifierLen){ EmitFormatDiagnostic(S.PDiag(diag::warn_printf_incomplete_specifier), getLocationOfByte(startSpecifier), - /*IsStringLocation*/ true, + /*IsStringLocation*/true, getSpecifierRange(startSpecifier, specifierLen)); } @@ -9437,12 +9154,12 @@ void CheckFormatHandler::HandleInvalidLengthModifier( if (FixedLM) { EmitFormatDiagnostic(S.PDiag(DiagID) << LM.toString() << CS.toString(), getLocationOfByte(LM.getStart()), - /*IsStringLocation*/ true, + /*IsStringLocation*/true, getSpecifierRange(startSpecifier, specifierLen)); S.Diag(getLocationOfByte(LM.getStart()), diag::note_format_fix_specifier) - << FixedLM->toString() - << FixItHint::CreateReplacement(LMRange, FixedLM->toString()); + << FixedLM->toString() + << FixItHint::CreateReplacement(LMRange, FixedLM->toString()); } else { FixItHint Hint; @@ -9451,8 +9168,9 @@ void CheckFormatHandler::HandleInvalidLengthModifier( EmitFormatDiagnostic(S.PDiag(DiagID) << LM.toString() << CS.toString(), getLocationOfByte(LM.getStart()), - /*IsStringLocation*/ true, - getSpecifierRange(startSpecifier, specifierLen), Hint); + /*IsStringLocation*/true, + getSpecifierRange(startSpecifier, specifierLen), + Hint); } } @@ -9468,20 +9186,20 @@ void CheckFormatHandler::HandleNonStandardLengthModifier( Optional FixedLM = FS.getCorrectedLengthModifier(); if (FixedLM) { EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard) - << LM.toString() << 0, + << LM.toString() << 0, getLocationOfByte(LM.getStart()), - /*IsStringLocation*/ true, + /*IsStringLocation*/true, getSpecifierRange(startSpecifier, specifierLen)); S.Diag(getLocationOfByte(LM.getStart()), diag::note_format_fix_specifier) - << FixedLM->toString() - << FixItHint::CreateReplacement(LMRange, FixedLM->toString()); + << FixedLM->toString() + << FixItHint::CreateReplacement(LMRange, FixedLM->toString()); } else { EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard) - << LM.toString() << 0, + << LM.toString() << 0, getLocationOfByte(LM.getStart()), - /*IsStringLocation*/ true, + /*IsStringLocation*/true, getSpecifierRange(startSpecifier, specifierLen)); } } @@ -9495,55 +9213,56 @@ void CheckFormatHandler::HandleNonStandardConversionSpecifier( Optional FixedCS = CS.getStandardSpecifier(); if (FixedCS) { EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard) - << CS.toString() << /*conversion specifier*/ 1, + << CS.toString() << /*conversion specifier*/1, getLocationOfByte(CS.getStart()), - /*IsStringLocation*/ true, + /*IsStringLocation*/true, getSpecifierRange(startSpecifier, specifierLen)); CharSourceRange CSRange = getSpecifierRange(CS.getStart(), CS.getLength()); S.Diag(getLocationOfByte(CS.getStart()), diag::note_format_fix_specifier) - << FixedCS->toString() - << FixItHint::CreateReplacement(CSRange, FixedCS->toString()); + << FixedCS->toString() + << FixItHint::CreateReplacement(CSRange, FixedCS->toString()); } else { EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard) - << CS.toString() << /*conversion specifier*/ 1, + << CS.toString() << /*conversion specifier*/1, getLocationOfByte(CS.getStart()), - /*IsStringLocation*/ true, + /*IsStringLocation*/true, getSpecifierRange(startSpecifier, specifierLen)); } } -void CheckFormatHandler::HandlePosition(const char *startPos, unsigned posLen) { +void CheckFormatHandler::HandlePosition(const char *startPos, + unsigned posLen) { EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg), - getLocationOfByte(startPos), - /*IsStringLocation*/ true, - getSpecifierRange(startPos, posLen)); + getLocationOfByte(startPos), + /*IsStringLocation*/true, + getSpecifierRange(startPos, posLen)); } -void CheckFormatHandler::HandleInvalidPosition( - const char *startPos, unsigned posLen, - analyze_format_string::PositionContext p) { +void +CheckFormatHandler::HandleInvalidPosition(const char *startPos, unsigned posLen, + analyze_format_string::PositionContext p) { EmitFormatDiagnostic(S.PDiag(diag::warn_format_invalid_positional_specifier) - << (unsigned)p, - getLocationOfByte(startPos), /*IsStringLocation*/ true, + << (unsigned) p, + getLocationOfByte(startPos), /*IsStringLocation*/true, getSpecifierRange(startPos, posLen)); } void CheckFormatHandler::HandleZeroPosition(const char *startPos, unsigned posLen) { EmitFormatDiagnostic(S.PDiag(diag::warn_format_zero_positional_specifier), - getLocationOfByte(startPos), - /*IsStringLocation*/ true, - getSpecifierRange(startPos, posLen)); + getLocationOfByte(startPos), + /*IsStringLocation*/true, + getSpecifierRange(startPos, posLen)); } void CheckFormatHandler::HandleNullChar(const char *nullCharacter) { if (!isa(OrigFormatExpr)) { // The presence of a null character is likely an error. EmitFormatDiagnostic( - S.PDiag(diag::warn_printf_format_string_contains_null_char), - getLocationOfByte(nullCharacter), /*IsStringLocation*/ true, - getFormatStringRange()); + S.PDiag(diag::warn_printf_format_string_contains_null_char), + getLocationOfByte(nullCharacter), /*IsStringLocation*/true, + getFormatStringRange()); } } @@ -9571,7 +9290,8 @@ void CheckFormatHandler::DoneProcessing() { void UncoveredArgHandler::Diagnose(Sema &S, bool IsFunctionCall, const Expr *ArgExpr) { - assert(hasUncoveredArg() && DiagnosticExprs.size() > 0 && "Invalid state"); + assert(hasUncoveredArg() && DiagnosticExprs.size() > 0 && + "Invalid state"); if (!ArgExpr) return; @@ -9586,19 +9306,25 @@ void UncoveredArgHandler::Diagnose(Sema &S, bool IsFunctionCall, PDiag << E->getSourceRange(); CheckFormatHandler::EmitFormatDiagnostic( - S, IsFunctionCall, DiagnosticExprs[0], PDiag, Loc, - /*IsStringLocation*/ false, DiagnosticExprs[0]->getSourceRange()); -} - -bool CheckFormatHandler::HandleInvalidConversionSpecifier( - unsigned argIndex, SourceLocation Loc, const char *startSpec, - unsigned specifierLen, const char *csStart, unsigned csLen) { + S, IsFunctionCall, DiagnosticExprs[0], + PDiag, Loc, /*IsStringLocation*/false, + DiagnosticExprs[0]->getSourceRange()); +} + +bool +CheckFormatHandler::HandleInvalidConversionSpecifier(unsigned argIndex, + SourceLocation Loc, + const char *startSpec, + unsigned specifierLen, + const char *csStart, + unsigned csLen) { bool keepGoing = true; if (argIndex < NumDataArgs) { // Consider the argument coverered, even though the specifier doesn't // make sense. CoveredArgs.set(argIndex); - } else { + } + else { // If argIndex exceeds the number of data arguments we // don't issue a warning because that is just a cascade of warnings (and // they may have intended '%%' anyway). We don't want to continue processing @@ -9616,7 +9342,8 @@ bool CheckFormatHandler::HandleInvalidConversionSpecifier( if (!llvm::sys::locale::isPrint(*csStart)) { llvm::UTF32 CodePoint; const llvm::UTF8 **B = reinterpret_cast(&csStart); - const llvm::UTF8 *E = reinterpret_cast(csStart + csLen); + const llvm::UTF8 *E = + reinterpret_cast(csStart + csLen); llvm::ConversionResult Result = llvm::convertUTF8Sequence(B, E, &CodePoint, llvm::strictConversion); @@ -9643,27 +9370,29 @@ bool CheckFormatHandler::HandleInvalidConversionSpecifier( return keepGoing; } -void CheckFormatHandler::HandlePositionalNonpositionalArgs( - SourceLocation Loc, const char *startSpec, unsigned specifierLen) { +void +CheckFormatHandler::HandlePositionalNonpositionalArgs(SourceLocation Loc, + const char *startSpec, + unsigned specifierLen) { EmitFormatDiagnostic( - S.PDiag(diag::warn_format_mix_positional_nonpositional_args), Loc, - /*isStringLoc*/ true, getSpecifierRange(startSpec, specifierLen)); + S.PDiag(diag::warn_format_mix_positional_nonpositional_args), + Loc, /*isStringLoc*/true, getSpecifierRange(startSpec, specifierLen)); } -bool CheckFormatHandler::CheckNumArgs( - const analyze_format_string::FormatSpecifier &FS, - const analyze_format_string::ConversionSpecifier &CS, - const char *startSpecifier, unsigned specifierLen, unsigned argIndex) { +bool +CheckFormatHandler::CheckNumArgs( + const analyze_format_string::FormatSpecifier &FS, + const analyze_format_string::ConversionSpecifier &CS, + const char *startSpecifier, unsigned specifierLen, unsigned argIndex) { if (argIndex >= NumDataArgs) { - PartialDiagnostic PDiag = - FS.usesPositionalArg() - ? (S.PDiag(diag::warn_printf_positional_arg_exceeds_data_args) - << (argIndex + 1) << NumDataArgs) - : S.PDiag(diag::warn_printf_insufficient_data_args); - EmitFormatDiagnostic(PDiag, getLocationOfByte(CS.getStart()), - /*IsStringLocation*/ true, - getSpecifierRange(startSpecifier, specifierLen)); + PartialDiagnostic PDiag = FS.usesPositionalArg() + ? (S.PDiag(diag::warn_printf_positional_arg_exceeds_data_args) + << (argIndex+1) << NumDataArgs) + : S.PDiag(diag::warn_printf_insufficient_data_args); + EmitFormatDiagnostic( + PDiag, getLocationOfByte(CS.getStart()), /*IsStringLocation*/true, + getSpecifierRange(startSpecifier, specifierLen)); // Since more arguments than conversion tokens are given, by extension // all arguments are covered, so mark this as so. @@ -9673,14 +9402,14 @@ bool CheckFormatHandler::CheckNumArgs( return true; } -template +template void CheckFormatHandler::EmitFormatDiagnostic(PartialDiagnostic PDiag, SourceLocation Loc, bool IsStringLocation, Range StringRange, ArrayRef FixIt) { - EmitFormatDiagnostic(S, inFunctionCall, Args[FormatIdx], PDiag, Loc, - IsStringLocation, StringRange, FixIt); + EmitFormatDiagnostic(S, inFunctionCall, Args[FormatIdx], PDiag, + Loc, IsStringLocation, StringRange, FixIt); } /// If the format string is not within the function call, emit a note @@ -9721,19 +9450,18 @@ void CheckFormatHandler::EmitFormatDiagnostic( D << FixIt; } else { S.Diag(IsStringLocation ? ArgumentExpr->getExprLoc() : Loc, PDiag) - << ArgumentExpr->getSourceRange(); + << ArgumentExpr->getSourceRange(); const Sema::SemaDiagnosticBuilder &Note = - S.Diag(IsStringLocation ? Loc : StringRange.getBegin(), - diag::note_format_string_defined); + S.Diag(IsStringLocation ? Loc : StringRange.getBegin(), + diag::note_format_string_defined); Note << StringRange; Note << FixIt; } } -//===--- CHECK: Printf format string checking -//------------------------------===// +//===--- CHECK: Printf format string checking ------------------------------===// namespace { @@ -9762,8 +9490,9 @@ class CheckPrintfHandler : public CheckFormatHandler { } bool HandleInvalidPrintfConversionSpecifier( - const analyze_printf::PrintfSpecifier &FS, const char *startSpecifier, - unsigned specifierLen) override; + const analyze_printf::PrintfSpecifier &FS, + const char *startSpecifier, + unsigned specifierLen) override; void handleInvalidMaskType(StringRef MaskType) override; @@ -9771,16 +9500,16 @@ class CheckPrintfHandler : public CheckFormatHandler { const char *startSpecifier, unsigned specifierLen, const TargetInfo &Target) override; bool checkFormatExpr(const analyze_printf::PrintfSpecifier &FS, - const char *StartSpecifier, unsigned SpecifierLen, + const char *StartSpecifier, + unsigned SpecifierLen, const Expr *E); - bool HandleAmount(const analyze_format_string::OptionalAmount &Amt, - unsigned k, const char *startSpecifier, - unsigned specifierLen); + bool HandleAmount(const analyze_format_string::OptionalAmount &Amt, unsigned k, + const char *startSpecifier, unsigned specifierLen); void HandleInvalidAmount(const analyze_printf::PrintfSpecifier &FS, const analyze_printf::OptionalAmount &Amt, - unsigned type, const char *startSpecifier, - unsigned specifierLen); + unsigned type, + const char *startSpecifier, unsigned specifierLen); void HandleFlag(const analyze_printf::PrintfSpecifier &FS, const analyze_printf::OptionalFlag &flag, const char *startSpecifier, unsigned specifierLen); @@ -9788,31 +9517,34 @@ class CheckPrintfHandler : public CheckFormatHandler { const analyze_printf::OptionalFlag &ignoredFlag, const analyze_printf::OptionalFlag &flag, const char *startSpecifier, unsigned specifierLen); - bool checkForCStrMembers(const analyze_printf::ArgType &AT, const Expr *E); + bool checkForCStrMembers(const analyze_printf::ArgType &AT, + const Expr *E); void HandleEmptyObjCModifierFlag(const char *startFlag, unsigned flagLen) override; void HandleInvalidObjCModifierFlag(const char *startFlag, - unsigned flagLen) override; + unsigned flagLen) override; - void - HandleObjCFlagsWithNonObjCConversion(const char *flagsStart, - const char *flagsEnd, - const char *conversionPosition) override; + void HandleObjCFlagsWithNonObjCConversion(const char *flagsStart, + const char *flagsEnd, + const char *conversionPosition) + override; }; } // namespace bool CheckPrintfHandler::HandleInvalidPrintfConversionSpecifier( - const analyze_printf::PrintfSpecifier &FS, const char *startSpecifier, - unsigned specifierLen) { + const analyze_printf::PrintfSpecifier &FS, + const char *startSpecifier, + unsigned specifierLen) { const analyze_printf::PrintfConversionSpecifier &CS = - FS.getConversionSpecifier(); + FS.getConversionSpecifier(); - return HandleInvalidConversionSpecifier( - FS.getArgIndex(), getLocationOfByte(CS.getStart()), startSpecifier, - specifierLen, CS.getStart(), CS.getLength()); + return HandleInvalidConversionSpecifier(FS.getArgIndex(), + getLocationOfByte(CS.getStart()), + startSpecifier, specifierLen, + CS.getStart(), CS.getLength()); } void CheckPrintfHandler::handleInvalidMaskType(StringRef MaskType) { @@ -9852,10 +9584,10 @@ bool CheckPrintfHandler::HandleAmount( if (!AT.matchesType(S.Context, T)) { EmitFormatDiagnostic(S.PDiag(diag::warn_printf_asterisk_wrong_type) - << k << AT.getRepresentativeTypeName(S.Context) - << T << Arg->getSourceRange(), + << k << AT.getRepresentativeTypeName(S.Context) + << T << Arg->getSourceRange(), getLocationOfByte(Amt.getStart()), - /*IsStringLocation*/ true, + /*IsStringLocation*/true, getSpecifierRange(startSpecifier, specifierLen)); // Don't do any more checking. We will just emit // spurious errors. @@ -9867,23 +9599,26 @@ bool CheckPrintfHandler::HandleAmount( } void CheckPrintfHandler::HandleInvalidAmount( - const analyze_printf::PrintfSpecifier &FS, - const analyze_printf::OptionalAmount &Amt, unsigned type, - const char *startSpecifier, unsigned specifierLen) { + const analyze_printf::PrintfSpecifier &FS, + const analyze_printf::OptionalAmount &Amt, + unsigned type, + const char *startSpecifier, + unsigned specifierLen) { const analyze_printf::PrintfConversionSpecifier &CS = - FS.getConversionSpecifier(); + FS.getConversionSpecifier(); FixItHint fixit = - Amt.getHowSpecified() == analyze_printf::OptionalAmount::Constant - ? FixItHint::CreateRemoval( - getSpecifierRange(Amt.getStart(), Amt.getConstantLength())) - : FixItHint(); + Amt.getHowSpecified() == analyze_printf::OptionalAmount::Constant + ? FixItHint::CreateRemoval(getSpecifierRange(Amt.getStart(), + Amt.getConstantLength())) + : FixItHint(); EmitFormatDiagnostic(S.PDiag(diag::warn_printf_nonsensical_optional_amount) - << type << CS.toString(), + << type << CS.toString(), getLocationOfByte(Amt.getStart()), - /*IsStringLocation*/ true, - getSpecifierRange(startSpecifier, specifierLen), fixit); + /*IsStringLocation*/true, + getSpecifierRange(startSpecifier, specifierLen), + fixit); } void CheckPrintfHandler::HandleFlag(const analyze_printf::PrintfSpecifier &FS, @@ -9892,37 +9627,39 @@ void CheckPrintfHandler::HandleFlag(const analyze_printf::PrintfSpecifier &FS, unsigned specifierLen) { // Warn about pointless flag with a fixit removal. const analyze_printf::PrintfConversionSpecifier &CS = - FS.getConversionSpecifier(); - EmitFormatDiagnostic( - S.PDiag(diag::warn_printf_nonsensical_flag) - << flag.toString() << CS.toString(), - getLocationOfByte(flag.getPosition()), - /*IsStringLocation*/ true, - getSpecifierRange(startSpecifier, specifierLen), - FixItHint::CreateRemoval(getSpecifierRange(flag.getPosition(), 1))); + FS.getConversionSpecifier(); + EmitFormatDiagnostic(S.PDiag(diag::warn_printf_nonsensical_flag) + << flag.toString() << CS.toString(), + getLocationOfByte(flag.getPosition()), + /*IsStringLocation*/true, + getSpecifierRange(startSpecifier, specifierLen), + FixItHint::CreateRemoval( + getSpecifierRange(flag.getPosition(), 1))); } void CheckPrintfHandler::HandleIgnoredFlag( - const analyze_printf::PrintfSpecifier &FS, - const analyze_printf::OptionalFlag &ignoredFlag, - const analyze_printf::OptionalFlag &flag, const char *startSpecifier, - unsigned specifierLen) { + const analyze_printf::PrintfSpecifier &FS, + const analyze_printf::OptionalFlag &ignoredFlag, + const analyze_printf::OptionalFlag &flag, + const char *startSpecifier, + unsigned specifierLen) { // Warn about ignored flag with a fixit removal. EmitFormatDiagnostic(S.PDiag(diag::warn_printf_ignored_flag) - << ignoredFlag.toString() << flag.toString(), + << ignoredFlag.toString() << flag.toString(), getLocationOfByte(ignoredFlag.getPosition()), - /*IsStringLocation*/ true, + /*IsStringLocation*/true, getSpecifierRange(startSpecifier, specifierLen), FixItHint::CreateRemoval( - getSpecifierRange(ignoredFlag.getPosition(), 1))); + getSpecifierRange(ignoredFlag.getPosition(), 1))); } void CheckPrintfHandler::HandleEmptyObjCModifierFlag(const char *startFlag, unsigned flagLen) { // Warn about an empty flag. - EmitFormatDiagnostic( - S.PDiag(diag::warn_printf_empty_objc_flag), getLocationOfByte(startFlag), - /*IsStringLocation*/ true, getSpecifierRange(startFlag, flagLen)); + EmitFormatDiagnostic(S.PDiag(diag::warn_printf_empty_objc_flag), + getLocationOfByte(startFlag), + /*IsStringLocation*/true, + getSpecifierRange(startFlag, flagLen)); } void CheckPrintfHandler::HandleInvalidObjCModifierFlag(const char *startFlag, @@ -9931,31 +9668,30 @@ void CheckPrintfHandler::HandleInvalidObjCModifierFlag(const char *startFlag, auto Range = getSpecifierRange(startFlag, flagLen); StringRef flag(startFlag, flagLen); EmitFormatDiagnostic(S.PDiag(diag::warn_printf_invalid_objc_flag) << flag, - getLocationOfByte(startFlag), - /*IsStringLocation*/ true, Range, - FixItHint::CreateRemoval(Range)); + getLocationOfByte(startFlag), + /*IsStringLocation*/true, + Range, FixItHint::CreateRemoval(Range)); } void CheckPrintfHandler::HandleObjCFlagsWithNonObjCConversion( - const char *flagsStart, const char *flagsEnd, - const char *conversionPosition) { - // Warn about using '[...]' without a '@' conversion. - auto Range = getSpecifierRange(flagsStart, flagsEnd - flagsStart + 1); - auto diag = diag::warn_printf_ObjCflags_without_ObjCConversion; - EmitFormatDiagnostic(S.PDiag(diag) << StringRef(conversionPosition, 1), - getLocationOfByte(conversionPosition), - /*IsStringLocation*/ true, Range, - FixItHint::CreateRemoval(Range)); + const char *flagsStart, const char *flagsEnd, const char *conversionPosition) { + // Warn about using '[...]' without a '@' conversion. + auto Range = getSpecifierRange(flagsStart, flagsEnd - flagsStart + 1); + auto diag = diag::warn_printf_ObjCflags_without_ObjCConversion; + EmitFormatDiagnostic(S.PDiag(diag) << StringRef(conversionPosition, 1), + getLocationOfByte(conversionPosition), + /*IsStringLocation*/true, + Range, FixItHint::CreateRemoval(Range)); } // Determines if the specified is a C++ class or struct containing // a member with the specified name and kind (e.g. a CXXMethodDecl named // "c_str()"). -template -static llvm::SmallPtrSet +template +static llvm::SmallPtrSet CXXRecordMembersNamed(StringRef Name, Sema &S, QualType Ty) { const RecordType *RT = Ty->getAs(); - llvm::SmallPtrSet Results; + llvm::SmallPtrSet Results; if (!RT) return Results; @@ -9987,8 +9723,8 @@ bool Sema::hasCStrMethod(const Expr *E) { MethodSet Results = CXXRecordMembersNamed("c_str", *this, E->getType()); - for (MethodSet::iterator MI = Results.begin(), ME = Results.end(); MI != ME; - ++MI) + for (MethodSet::iterator MI = Results.begin(), ME = Results.end(); + MI != ME; ++MI) if ((*MI)->getMinRequiredArguments() == 0) return true; return false; @@ -9997,15 +9733,15 @@ bool Sema::hasCStrMethod(const Expr *E) { // Check if a (w)string was passed when a (w)char* was needed, and offer a // better diagnostic if so. AT is assumed to be valid. // Returns true when a c_str() conversion method is found. -bool CheckPrintfHandler::checkForCStrMembers(const analyze_printf::ArgType &AT, - const Expr *E) { +bool CheckPrintfHandler::checkForCStrMembers( + const analyze_printf::ArgType &AT, const Expr *E) { using MethodSet = llvm::SmallPtrSet; MethodSet Results = CXXRecordMembersNamed("c_str", S, E->getType()); - for (MethodSet::iterator MI = Results.begin(), ME = Results.end(); MI != ME; - ++MI) { + for (MethodSet::iterator MI = Results.begin(), ME = Results.end(); + MI != ME; ++MI) { const CXXMethodDecl *Method = *MI; if (Method->getMinRequiredArguments() == 0 && AT.matchesType(S.Context, Method->getReturnType())) { @@ -10030,9 +9766,10 @@ bool CheckPrintfHandler::HandlePrintfSpecifier( if (FS.consumesDataArgument()) { if (atFirstArg) { - atFirstArg = false; - usesPositionalArgs = FS.usesPositionalArg(); - } else if (usesPositionalArgs != FS.usesPositionalArg()) { + atFirstArg = false; + usesPositionalArgs = FS.usesPositionalArg(); + } + else if (usesPositionalArgs != FS.usesPositionalArg()) { HandlePositionalNonpositionalArgs(getLocationOfByte(CS.getStart()), startSpecifier, specifierLen); return false; @@ -10041,13 +9778,13 @@ bool CheckPrintfHandler::HandlePrintfSpecifier( // First check if the field width, precision, and conversion specifier // have matching data arguments. - if (!HandleAmount(FS.getFieldWidth(), /* field width */ 0, startSpecifier, - specifierLen)) { + if (!HandleAmount(FS.getFieldWidth(), /* field width */ 0, + startSpecifier, specifierLen)) { return false; } - if (!HandleAmount(FS.getPrecision(), /* precision */ 1, startSpecifier, - specifierLen)) { + if (!HandleAmount(FS.getPrecision(), /* precision */ 1, + startSpecifier, specifierLen)) { return false; } @@ -10079,9 +9816,8 @@ bool CheckPrintfHandler::HandlePrintfSpecifier( // Type check the first argument (int for %b, pointer for %D) const Expr *Ex = getDataArg(argIndex); const analyze_printf::ArgType &AT = - (CS.getKind() == ConversionSpecifier::FreeBSDbArg) - ? ArgType(S.Context.IntTy) - : ArgType::CPointerTy; + (CS.getKind() == ConversionSpecifier::FreeBSDbArg) ? + ArgType(S.Context.IntTy) : ArgType::CPointerTy; if (AT.isValid() && !AT.matchesType(S.Context, Ex->getType())) EmitFormatDiagnostic( S.PDiag(diag::warn_format_conversion_argument_type_mismatch) @@ -10101,7 +9837,7 @@ bool CheckPrintfHandler::HandlePrintfSpecifier( Ex->getBeginLoc(), /*IsStringLocation*/ false, getSpecifierRange(startSpecifier, specifierLen)); - return true; + return true; } // Check for using an Objective-C specific conversion specifier @@ -10166,13 +9902,13 @@ bool CheckPrintfHandler::HandlePrintfSpecifier( // Check for invalid use of field width if (!FS.hasValidFieldWidth()) { HandleInvalidAmount(FS, FS.getFieldWidth(), /* field width */ 0, - startSpecifier, specifierLen); + startSpecifier, specifierLen); } // Check for invalid use of precision if (!FS.hasValidPrecision()) { HandleInvalidAmount(FS, FS.getPrecision(), /* precision */ 1, - startSpecifier, specifierLen); + startSpecifier, specifierLen); } // Precision is mandatory for %P specifier. @@ -10201,10 +9937,10 @@ bool CheckPrintfHandler::HandlePrintfSpecifier( // Check that flags are not ignored by another flag if (FS.hasSpacePrefix() && FS.hasPlusPrefix()) // ' ' ignored by '+' HandleIgnoredFlag(FS, FS.hasSpacePrefix(), FS.hasPlusPrefix(), - startSpecifier, specifierLen); + startSpecifier, specifierLen); if (FS.hasLeadingZeros() && FS.isLeftJustified()) // '0' ignored by '-' HandleIgnoredFlag(FS, FS.hasLeadingZeros(), FS.isLeftJustified(), - startSpecifier, specifierLen); + startSpecifier, specifierLen); // Check the length modifier is valid with the given conversion specifier. if (!FS.hasValidLengthModifier(S.getASTContext().getTargetInfo(), @@ -10271,19 +10007,20 @@ static bool requiresParensToAddCast(const Expr *E) { } static std::pair -shouldNotPrintDirectly(const ASTContext &Context, QualType IntendedTy, +shouldNotPrintDirectly(const ASTContext &Context, + QualType IntendedTy, const Expr *E) { // Use a 'while' to peel off layers of typedefs. QualType TyTy = IntendedTy; while (const TypedefType *UserTy = TyTy->getAs()) { StringRef Name = UserTy->getDecl()->getName(); QualType CastTy = llvm::StringSwitch(Name) - .Case("CFIndex", Context.getNSIntegerType()) - .Case("NSInteger", Context.getNSIntegerType()) - .Case("NSUInteger", Context.getNSUIntegerType()) - .Case("SInt32", Context.IntTy) - .Case("UInt32", Context.UnsignedIntTy) - .Default(QualType()); + .Case("CFIndex", Context.getNSIntegerType()) + .Case("NSInteger", Context.getNSIntegerType()) + .Case("NSUInteger", Context.getNSUIntegerType()) + .Case("SInt32", Context.IntTy) + .Case("UInt32", Context.UnsignedIntTy) + .Default(QualType()); if (!CastTy.isNull()) return std::make_pair(CastTy, Name); @@ -10293,7 +10030,8 @@ shouldNotPrintDirectly(const ASTContext &Context, QualType IntendedTy, // Strip parens if necessary. if (const ParenExpr *PE = dyn_cast(E)) - return shouldNotPrintDirectly(Context, PE->getSubExpr()->getType(), + return shouldNotPrintDirectly(Context, + PE->getSubExpr()->getType(), PE->getSubExpr()); // If this is a conditional expression, then its result type is constructed @@ -10304,10 +10042,14 @@ shouldNotPrintDirectly(const ASTContext &Context, QualType IntendedTy, QualType TrueTy, FalseTy; StringRef TrueName, FalseName; - std::tie(TrueTy, TrueName) = shouldNotPrintDirectly( - Context, CO->getTrueExpr()->getType(), CO->getTrueExpr()); - std::tie(FalseTy, FalseName) = shouldNotPrintDirectly( - Context, CO->getFalseExpr()->getType(), CO->getFalseExpr()); + std::tie(TrueTy, TrueName) = + shouldNotPrintDirectly(Context, + CO->getTrueExpr()->getType(), + CO->getTrueExpr()); + std::tie(FalseTy, FalseName) = + shouldNotPrintDirectly(Context, + CO->getFalseExpr()->getType(), + CO->getFalseExpr()); if (TrueTy == FalseTy) return std::make_pair(TrueTy, TrueName); @@ -10323,8 +10065,8 @@ shouldNotPrintDirectly(const ASTContext &Context, QualType IntendedTy, /// Return true if \p ICE is an implicit argument promotion of an arithmetic /// type. Bit-field 'promotions' from a higher ranked type to a lower ranked /// type do not count. -static bool isArithmeticArgumentPromotion(Sema &S, - const ImplicitCastExpr *ICE) { +static bool +isArithmeticArgumentPromotion(Sema &S, const ImplicitCastExpr *ICE) { QualType From = ICE->getSubExpr()->getType(); QualType To = ICE->getType(); // It's an integer promotion if the destination type is the promoted @@ -10344,9 +10086,11 @@ static bool isArithmeticArgumentPromotion(Sema &S, S.Context.getFloatingTypeOrder(From, To) < 0; } -bool CheckPrintfHandler::checkFormatExpr( - const analyze_printf::PrintfSpecifier &FS, const char *StartSpecifier, - unsigned SpecifierLen, const Expr *E) { +bool +CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS, + const char *StartSpecifier, + unsigned SpecifierLen, + const Expr *E) { using namespace analyze_format_string; using namespace analyze_printf; @@ -10483,12 +10227,10 @@ bool CheckPrintfHandler::checkFormatExpr( // Special-case some of Darwin's platform-independence types by suggesting // casts to primitive types that are known to be large enough. - bool ShouldNotPrintDirectly = false; - StringRef CastTyName; + bool ShouldNotPrintDirectly = false; StringRef CastTyName; if (S.Context.getTargetInfo().getTriple().isOSDarwin()) { QualType CastTy; - std::tie(CastTy, CastTyName) = - shouldNotPrintDirectly(S.Context, IntendedTy, E); + std::tie(CastTy, CastTyName) = shouldNotPrintDirectly(S.Context, IntendedTy, E); if (!CastTy.isNull()) { // %zi/%zu and %td/%tu are OK to use for NSInteger/NSUInteger of type int // (long in ASTContext). Only complain to pedants. @@ -10554,7 +10296,7 @@ bool CheckPrintfHandler::checkFormatExpr( IntendedTy.print(CastFix, S.Context.getPrintingPolicy()); CastFix << ")"; - SmallVector Hints; + SmallVector Hints; if (!AT.matchesType(S.Context, IntendedTy) || ShouldNotPrintDirectly) Hints.push_back(FixItHint::CreateReplacement(SpecRange, os.str())); @@ -10606,8 +10348,8 @@ bool CheckPrintfHandler::checkFormatExpr( } } } else { - const CharSourceRange &CSR = - getSpecifierRange(StartSpecifier, SpecifierLen); + const CharSourceRange &CSR = getSpecifierRange(StartSpecifier, + SpecifierLen); // Since the warning for passing non-POD types to variadic functions // was deferred until now, we emit a warning for non-POD // arguments here. @@ -10716,10 +10458,10 @@ class CheckScanfHandler : public CheckFormatHandler { const char *startSpecifier, unsigned specifierLen) override; - bool - HandleInvalidScanfConversionSpecifier(const analyze_scanf::ScanfSpecifier &FS, - const char *startSpecifier, - unsigned specifierLen) override; + bool HandleInvalidScanfConversionSpecifier( + const analyze_scanf::ScanfSpecifier &FS, + const char *startSpecifier, + unsigned specifierLen) override; void HandleIncompleteScanList(const char *start, const char *end) override; }; @@ -10729,24 +10471,27 @@ class CheckScanfHandler : public CheckFormatHandler { void CheckScanfHandler::HandleIncompleteScanList(const char *start, const char *end) { EmitFormatDiagnostic(S.PDiag(diag::warn_scanf_scanlist_incomplete), - getLocationOfByte(end), /*IsStringLocation*/ true, + getLocationOfByte(end), /*IsStringLocation*/true, getSpecifierRange(start, end - start)); } bool CheckScanfHandler::HandleInvalidScanfConversionSpecifier( - const analyze_scanf::ScanfSpecifier &FS, const char *startSpecifier, - unsigned specifierLen) { + const analyze_scanf::ScanfSpecifier &FS, + const char *startSpecifier, + unsigned specifierLen) { const analyze_scanf::ScanfConversionSpecifier &CS = - FS.getConversionSpecifier(); + FS.getConversionSpecifier(); - return HandleInvalidConversionSpecifier( - FS.getArgIndex(), getLocationOfByte(CS.getStart()), startSpecifier, - specifierLen, CS.getStart(), CS.getLength()); + return HandleInvalidConversionSpecifier(FS.getArgIndex(), + getLocationOfByte(CS.getStart()), + startSpecifier, specifierLen, + CS.getStart(), CS.getLength()); } bool CheckScanfHandler::HandleScanfSpecifier( - const analyze_scanf::ScanfSpecifier &FS, const char *startSpecifier, - unsigned specifierLen) { + const analyze_scanf::ScanfSpecifier &FS, + const char *startSpecifier, + unsigned specifierLen) { using namespace analyze_scanf; using namespace analyze_format_string; @@ -10758,7 +10503,8 @@ bool CheckScanfHandler::HandleScanfSpecifier( if (atFirstArg) { atFirstArg = false; usesPositionalArgs = FS.usesPositionalArg(); - } else if (usesPositionalArgs != FS.usesPositionalArg()) { + } + else if (usesPositionalArgs != FS.usesPositionalArg()) { HandlePositionalNonpositionalArgs(getLocationOfByte(CS.getStart()), startSpecifier, specifierLen); return false; @@ -10769,11 +10515,11 @@ bool CheckScanfHandler::HandleScanfSpecifier( const OptionalAmount &Amt = FS.getFieldWidth(); if (Amt.getHowSpecified() == OptionalAmount::Constant) { if (Amt.getConstantAmount() == 0) { - const CharSourceRange &R = - getSpecifierRange(Amt.getStart(), Amt.getConstantLength()); + const CharSourceRange &R = getSpecifierRange(Amt.getStart(), + Amt.getConstantLength()); EmitFormatDiagnostic(S.PDiag(diag::warn_scanf_nonzero_width), getLocationOfByte(Amt.getStart()), - /*IsStringLocation*/ true, R, + /*IsStringLocation*/true, R, FixItHint::CreateRemoval(R)); } } @@ -10787,9 +10533,9 @@ bool CheckScanfHandler::HandleScanfSpecifier( // Consume the argument. unsigned argIndex = FS.getArgIndex(); if (argIndex < NumDataArgs) { - // The check to see if the argIndex is valid will come later. - // We set the bit here because we may exit early from this - // function if we encounter some other error. + // The check to see if the argIndex is valid will come later. + // We set the bit here because we may exit early from this + // function if we encounter some other error. CoveredArgs.set(argIndex); } @@ -10886,7 +10632,7 @@ static void CheckFormatString( const char *Str = StrRef.data(); // Account for cases where the string literal is truncated in a declaration. const ConstantArrayType *T = - S.Context.getAsConstantArrayType(FExpr->getType()); + S.Context.getAsConstantArrayType(FExpr->getType()); assert(T && "String literal not of constant array type!"); size_t TypeSize = T->getSize().getZExtValue(); size_t StrLen = std::min(std::max(TypeSize, size_t(1)) - 1, StrRef.size()); @@ -10950,8 +10696,9 @@ bool Sema::FormatStringHasSArg(const StringLiteral *FExpr) { assert(T && "String literal not of constant array type!"); size_t TypeSize = T->getSize().getZExtValue(); size_t StrLen = std::min(std::max(TypeSize, size_t(1)) - 1, StrRef.size()); - return analyze_format_string::ParseFormatStringHasSArg( - Str, Str + StrLen, getLangOpts(), Context.getTargetInfo()); + return analyze_format_string::ParseFormatStringHasSArg(Str, Str + StrLen, + getLangOpts(), + Context.getTargetInfo()); } //===--- CHECK: Warn on use of wrong absolute value function. -------------===// @@ -10999,7 +10746,7 @@ static unsigned getLargerAbsoluteValueFunction(unsigned AbsFunction) { return 0; case Builtin::BIcabsf: - return Builtin::BIcabs; + return Builtin::BIcabs; case Builtin::BIcabs: return Builtin::BIcabsl; case Builtin::BIcabsl: @@ -11049,7 +10796,11 @@ static unsigned getBestAbsFunction(ASTContext &Context, QualType ArgType, return BestKind; } -enum AbsoluteValueKind { AVK_Integer, AVK_Floating, AVK_Complex }; +enum AbsoluteValueKind { + AVK_Integer, + AVK_Floating, + AVK_Complex +}; static AbsoluteValueKind getAbsoluteValueKind(QualType T) { if (T->isIntegralOrEnumerationType()) @@ -11239,8 +10990,8 @@ static void emitReplacement(Sema &S, SourceLocation Loc, SourceRange Range, if (!EmitHeaderHint) return; - S.Diag(Loc, diag::note_include_header_or_declare) - << HeaderName << FunctionName; + S.Diag(Loc, diag::note_include_header_or_declare) << HeaderName + << FunctionName; } template @@ -11339,44 +11090,32 @@ void Sema::CheckAbsoluteValueFunction(const CallExpr *Call, //===--- CHECK: Warn on use of std::max and unsigned zero. r---------------===// void Sema::CheckMaxUnsignedZero(const CallExpr *Call, const FunctionDecl *FDecl) { - if (!Call || !FDecl) - return; + if (!Call || !FDecl) return; // Ignore template specializations and macros. - if (inTemplateInstantiation()) - return; - if (Call->getExprLoc().isMacroID()) - return; + if (inTemplateInstantiation()) return; + if (Call->getExprLoc().isMacroID()) return; // Only care about the one template argument, two function parameter std::max - if (Call->getNumArgs() != 2) - return; - if (!IsStdFunction(FDecl, "max")) - return; - const auto *ArgList = FDecl->getTemplateSpecializationArgs(); - if (!ArgList) - return; - if (ArgList->size() != 1) - return; + if (Call->getNumArgs() != 2) return; + if (!IsStdFunction(FDecl, "max")) return; + const auto * ArgList = FDecl->getTemplateSpecializationArgs(); + if (!ArgList) return; + if (ArgList->size() != 1) return; // Check that template type argument is unsigned integer. - const auto &TA = ArgList->get(0); - if (TA.getKind() != TemplateArgument::Type) - return; + const auto& TA = ArgList->get(0); + if (TA.getKind() != TemplateArgument::Type) return; QualType ArgType = TA.getAsType(); - if (!ArgType->isUnsignedIntegerType()) - return; + if (!ArgType->isUnsignedIntegerType()) return; // See if either argument is a literal zero. - auto IsLiteralZeroArg = [](const Expr *E) -> bool { + auto IsLiteralZeroArg = [](const Expr* E) -> bool { const auto *MTE = dyn_cast(E); - if (!MTE) - return false; + if (!MTE) return false; const auto *Num = dyn_cast(MTE->getSubExpr()); - if (!Num) - return false; - if (Num->getValue() != 0) - return false; + if (!Num) return false; + if (Num->getValue() != 0) return false; return true; }; @@ -11386,8 +11125,7 @@ void Sema::CheckMaxUnsignedZero(const CallExpr *Call, const bool IsSecondArgZero = IsLiteralZeroArg(SecondArg); // Only warn when exactly one argument is zero. - if (IsFirstArgZero == IsSecondArgZero) - return; + if (IsFirstArgZero == IsSecondArgZero) return; SourceRange FirstRange = FirstArg->getSourceRange(); SourceRange SecondRange = SecondArg->getSourceRange(); @@ -11408,8 +11146,8 @@ void Sema::CheckMaxUnsignedZero(const CallExpr *Call, } Diag(Call->getExprLoc(), diag::note_remove_max_call) - << FixItHint::CreateRemoval(Call->getCallee()->getSourceRange()) - << FixItHint::CreateRemoval(RemovalRange); + << FixItHint::CreateRemoval(Call->getCallee()->getSourceRange()) + << FixItHint::CreateRemoval(RemovalRange); } //===--- CHECK: Standard memory functions ---------------------------------===// @@ -11590,7 +11328,7 @@ struct SearchNonTrivialToCopyField Sema &S; }; -} // namespace +} /// Detect if \c SizeofExpr is likely to calculate the sizeof an object. static bool doesExprLikelyComputeSize(const Expr *SizeofExpr) { @@ -11634,7 +11372,7 @@ static void CheckMemaccessSize(Sema &S, unsigned BId, const CallExpr *Call) { return; const Expr *SizeArg = - Call->getArg(BId == Builtin::BImemset ? 2 : 1)->IgnoreImpCasts(); + Call->getArg(BId == Builtin::BImemset ? 2 : 1)->IgnoreImpCasts(); auto isLiteralZero = [](const Expr *E) { return (isa(E) && @@ -11668,7 +11406,8 @@ static void CheckMemaccessSize(Sema &S, unsigned BId, const CallExpr *Call) { // If the second argument to a memset is a sizeof expression and the third // isn't, this is also likely an error. This should catch // 'memset(buf, sizeof(buf), 0xff)'. - if (BId == Builtin::BImemset && doesExprLikelyComputeSize(Call->getArg(1)) && + if (BId == Builtin::BImemset && + doesExprLikelyComputeSize(Call->getArg(1)) && !doesExprLikelyComputeSize(Call->getArg(2))) { SourceLocation DiagLoc = Call->getArg(1)->getExprLoc(); S.Diag(DiagLoc, diag::warn_suspicious_sizeof_memset) << 1; @@ -11684,7 +11423,8 @@ static void CheckMemaccessSize(Sema &S, unsigned BId, const CallExpr *Call) { /// function calls. /// /// \param Call The call expression to diagnose. -void Sema::CheckMemaccessArguments(const CallExpr *Call, unsigned BId, +void Sema::CheckMemaccessArguments(const CallExpr *Call, + unsigned BId, IdentifierInfo *FnName) { assert(BId != 0); @@ -11696,9 +11436,7 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call, unsigned BId, return; unsigned LastArg = (BId == Builtin::BImemset || BId == Builtin::BIbzero || - BId == Builtin::BIstrndup - ? 1 - : 2); + BId == Builtin::BIstrndup ? 1 : 2); unsigned LenArg = (BId == Builtin::BIbzero || BId == Builtin::BIstrndup ? 1 : 2); const Expr *LenExpr = Call->getArg(LenArg)->IgnoreParenImpCasts(); @@ -11774,19 +11512,22 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call, unsigned BId, ReadableName = Lexer::getImmediateMacroName(SL, SM, LangOpts); SL = SM.getSpellingLoc(SL); DSR = SourceRange(SM.getSpellingLoc(DSR.getBegin()), - SM.getSpellingLoc(DSR.getEnd())); + SM.getSpellingLoc(DSR.getEnd())); SSR = SourceRange(SM.getSpellingLoc(SSR.getBegin()), - SM.getSpellingLoc(SSR.getEnd())); + SM.getSpellingLoc(SSR.getEnd())); } DiagRuntimeBehavior(SL, SizeOfArg, PDiag(diag::warn_sizeof_pointer_expr_memaccess) - << ReadableName << PointeeTy << DestTy << DSR - << SSR); - DiagRuntimeBehavior( - SL, SizeOfArg, - PDiag(diag::warn_sizeof_pointer_expr_memaccess_note) - << ActionIdx << SSR); + << ReadableName + << PointeeTy + << DestTy + << DSR + << SSR); + DiagRuntimeBehavior(SL, SizeOfArg, + PDiag(diag::warn_sizeof_pointer_expr_memaccess_note) + << ActionIdx + << SSR); break; } @@ -11800,9 +11541,9 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call, unsigned BId, Context.typesAreCompatible(SizeOfArgTy, DestTy)) { DiagRuntimeBehavior(LenExpr->getExprLoc(), Dest, PDiag(diag::warn_sizeof_pointer_type_memaccess) - << FnName << SizeOfArgTy << ArgIdx - << PointeeTy << Dest->getSourceRange() - << LenExpr->getSourceRange()); + << FnName << SizeOfArgTy << ArgIdx + << PointeeTy << Dest->getSourceRange() + << LenExpr->getSourceRange()); break; } } @@ -11825,7 +11566,7 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call, unsigned BId, if (ArgIdx != 0 || IsCmp) { if (BId == Builtin::BImemcpy) OperationType = 1; - else if (BId == Builtin::BImemmove) + else if(BId == Builtin::BImemmove) OperationType = 2; else if (IsCmp) OperationType = 3; @@ -11837,11 +11578,12 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call, unsigned BId, << IsContained << ContainedRD << OperationType << Call->getCallee()->getSourceRange()); } else if (PointeeTy.hasNonTrivialObjCLifetime() && - BId != Builtin::BImemset) - DiagRuntimeBehavior(Dest->getExprLoc(), Dest, - PDiag(diag::warn_arc_object_memaccess) - << ArgIdx << FnName << PointeeTy - << Call->getCallee()->getSourceRange()); + BId != Builtin::BImemset) + DiagRuntimeBehavior( + Dest->getExprLoc(), Dest, + PDiag(diag::warn_arc_object_memaccess) + << ArgIdx << FnName << PointeeTy + << Call->getCallee()->getSourceRange()); else if (const auto *RT = PointeeTy->getAs()) { if ((BId == Builtin::BImemset || BId == Builtin::BIbzero) && RT->getDecl()->isNonTrivialToPrimitiveDefaultInitialize()) { @@ -11862,9 +11604,9 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call, unsigned BId, continue; DiagRuntimeBehavior( - Dest->getExprLoc(), Dest, - PDiag(diag::note_bad_memaccess_silence) - << FixItHint::CreateInsertion(ArgRange.getBegin(), "(void*)")); + Dest->getExprLoc(), Dest, + PDiag(diag::note_bad_memaccess_silence) + << FixItHint::CreateInsertion(ArgRange.getBegin(), "(void*)")); break; } } @@ -11876,7 +11618,7 @@ static const Expr *ignoreLiteralAdditions(const Expr *Ex, ASTContext &Ctx) { Ex = Ex->IgnoreParenCasts(); while (true) { - const BinaryOperator *BO = dyn_cast(Ex); + const BinaryOperator * BO = dyn_cast(Ex); if (!BO || !BO->isAdditiveOp()) break; @@ -11997,7 +11739,8 @@ static const Expr *getStrlenExprArg(const Expr *E) { // Warn on anti-patterns as the 'size' argument to strncat. // The correct size argument should look like following: // strncat(dst, src, sizeof(dst) - strlen(dest) - 1); -void Sema::CheckStrncatArguments(const CallExpr *CE, IdentifierInfo *FnName) { +void Sema::CheckStrncatArguments(const CallExpr *CE, + IdentifierInfo *FnName) { // Don't crash if the user has the wrong number of arguments. if (CE->getNumArgs() < 3) return; @@ -12050,8 +11793,8 @@ void Sema::CheckStrncatArguments(const CallExpr *CE, IdentifierInfo *FnName) { // Check if the destination is an array (rather than a pointer to an array). QualType DstTy = DstArg->getType(); - bool isKnownSizeArray = - isConstantSizeArrayWithMoreThanOneElement(DstTy, Context); + bool isKnownSizeArray = isConstantSizeArrayWithMoreThanOneElement(DstTy, + Context); if (!isKnownSizeArray) { if (PatternType == 1) Diag(SL, diag::warn_strncat_wrong_size) << SR; @@ -12075,7 +11818,7 @@ void Sema::CheckStrncatArguments(const CallExpr *CE, IdentifierInfo *FnName) { OS << ") - 1"; Diag(SL, diag::note_strncat_wrong_size) - << FixItHint::CreateReplacement(SR, OS.str()); + << FixItHint::CreateReplacement(SR, OS.str()); } namespace { @@ -12192,15 +11935,18 @@ void Sema::CheckFreeArguments(const CallExpr *E) { return CheckFreeArgumentsCast(*this, CalleeName, Cast); } -void Sema::CheckReturnValExpr(Expr *RetValExp, QualType lhsType, - SourceLocation ReturnLoc, bool isObjCMethod, - const AttrVec *Attrs, const FunctionDecl *FD) { +void +Sema::CheckReturnValExpr(Expr *RetValExp, QualType lhsType, + SourceLocation ReturnLoc, + bool isObjCMethod, + const AttrVec *Attrs, + const FunctionDecl *FD) { // Check if the return value is null but should not be. if (((Attrs && hasSpecificAttr(*Attrs)) || (!isObjCMethod && isNonNullType(Context, lhsType))) && CheckNonNullExpr(*this, RetValExp)) Diag(ReturnLoc, diag::warn_null_ret) - << (isObjCMethod ? 1 : 0) << RetValExp->getSourceRange(); + << (isObjCMethod ? 1 : 0) << RetValExp->getSourceRange(); // C++11 [basic.stc.dynamic.allocation]p4: // If an allocation function declared with a non-throwing @@ -12210,12 +11956,12 @@ void Sema::CheckReturnValExpr(Expr *RetValExp, QualType lhsType, if (FD) { OverloadedOperatorKind Op = FD->getOverloadedOperator(); if (Op == OO_New || Op == OO_Array_New) { - const FunctionProtoType *Proto = - FD->getType()->castAs(); - if (!Proto->isNothrow(/*ResultIfDependent*/ true) && + const FunctionProtoType *Proto + = FD->getType()->castAs(); + if (!Proto->isNothrow(/*ResultIfDependent*/true) && CheckNonNullExpr(*this, RetValExp)) Diag(ReturnLoc, diag::warn_operator_new_returns_null) - << FD << getLangOpts().CPlusPlus11; + << FD << getLangOpts().CPlusPlus11; } } @@ -12262,8 +12008,8 @@ void Sema::CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS, } // Match a more general floating-point equality comparison (-Wfloat-equal). - Expr *LeftExprSansParen = LHS->IgnoreParenImpCasts(); - Expr *RightExprSansParen = RHS->IgnoreParenImpCasts(); + Expr* LeftExprSansParen = LHS->IgnoreParenImpCasts(); + Expr* RightExprSansParen = RHS->IgnoreParenImpCasts(); // Special case: check for x == x (which is OK). // Do not emit warnings for such cases. @@ -12277,26 +12023,26 @@ void Sema::CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS, // is a heuristic: often comparison against such literals are used to // detect if a value in a variable has not changed. This clearly can // lead to false negatives. - if (FloatingLiteral *FLL = dyn_cast(LeftExprSansParen)) { + if (FloatingLiteral* FLL = dyn_cast(LeftExprSansParen)) { if (FLL->isExact()) return; - } else if (FloatingLiteral *FLR = - dyn_cast(RightExprSansParen)) - if (FLR->isExact()) - return; + } else + if (FloatingLiteral* FLR = dyn_cast(RightExprSansParen)) + if (FLR->isExact()) + return; // Check for comparisons with builtin types. - if (CallExpr *CL = dyn_cast(LeftExprSansParen)) + if (CallExpr* CL = dyn_cast(LeftExprSansParen)) if (CL->getBuiltinCallee()) return; - if (CallExpr *CR = dyn_cast(RightExprSansParen)) + if (CallExpr* CR = dyn_cast(RightExprSansParen)) if (CR->getBuiltinCallee()) return; // Emit the diagnostic. Diag(Loc, diag::warn_floatingpoint_eq) - << LHS->getSourceRange() << RHS->getSourceRange(); + << LHS->getSourceRange() << RHS->getSourceRange(); } //===--- CHECK: Integer mixed-sign comparisons (-Wsign-compare) --------===// @@ -12320,15 +12066,19 @@ struct IntRange { : Width(Width), NonNegative(NonNegative) {} /// Number of bits excluding the sign bit. - unsigned valueBits() const { return NonNegative ? Width : Width - 1; } + unsigned valueBits() const { + return NonNegative ? Width : Width - 1; + } /// Returns the range of the bool type. - static IntRange forBoolType() { return IntRange(1, true); } + static IntRange forBoolType() { + return IntRange(1, true); + } /// Returns the range of an opaque value of the given integral type. static IntRange forValueOfType(ASTContext &C, QualType T) { return forValueOfCanonicalType(C, - T->getCanonicalTypeInternal().getTypePtr()); + T->getCanonicalTypeInternal().getTypePtr()); } /// Returns the range of an opaque value of a canonical integral type. @@ -12360,10 +12110,10 @@ struct IntRange { unsigned NumNegative = Enum->getNumNegativeBits(); if (NumNegative == 0) - return IntRange(NumPositive, true /*NonNegative*/); + return IntRange(NumPositive, true/*NonNegative*/); else return IntRange(std::max(NumPositive + 1, NumNegative), - false /*NonNegative*/); + false/*NonNegative*/); } if (const auto *EIT = dyn_cast(T)) @@ -12574,15 +12324,13 @@ static IntRange GetExprRange(ASTContext &C, const Expr *E, unsigned MaxWidth, // GetExprRange requires an integer expression, but a throw expression // results in a void type. Expr *E = CO->getTrueExpr(); - IntRange L = - E->getType()->isVoidType() - ? IntRange{0, true} - : GetExprRange(C, E, MaxWidth, InConstantContext, Approximate); + IntRange L = E->getType()->isVoidType() + ? IntRange{0, true} + : GetExprRange(C, E, MaxWidth, InConstantContext, Approximate); E = CO->getFalseExpr(); - IntRange R = - E->getType()->isVoidType() - ? IntRange{0, true} - : GetExprRange(C, E, MaxWidth, InConstantContext, Approximate); + IntRange R = E->getType()->isVoidType() + ? IntRange{0, true} + : GetExprRange(C, E, MaxWidth, InConstantContext, Approximate); return IntRange::join(L, R); } @@ -12638,8 +12386,8 @@ static IntRange GetExprRange(ASTContext &C, const Expr *E, unsigned MaxWidth, case BO_Shl: // ...except that we want to treat '1 << (blah)' as logically // positive. It's an important idiom. - if (IntegerLiteral *I = - dyn_cast(BO->getLHS()->IgnoreParenCasts())) { + if (IntegerLiteral *I + = dyn_cast(BO->getLHS()->IgnoreParenCasts())) { if (I->getValue() == 1) { IntRange R = IntRange::forValueOfType(C, GetExprType(E)); return IntRange(R.Width, /*NonNegative*/ true); @@ -12822,7 +12570,8 @@ static void AnalyzeImplicitConversions(Sema &S, Expr *E, SourceLocation CC, static bool IsEnumConstOrFromMacro(Sema &S, Expr *E) { // Suppress cases where we are comparing against an enum constant. - if (const DeclRefExpr *DR = dyn_cast(E->IgnoreParenImpCasts())) + if (const DeclRefExpr *DR = + dyn_cast(E->IgnoreParenImpCasts())) if (isa(DR->getDecl())) return true; @@ -12833,8 +12582,8 @@ static bool IsEnumConstOrFromMacro(Sema &S, Expr *E) { if (BeginLoc.isMacroID()) { StringRef MacroName = Lexer::getImmediateMacroName( BeginLoc, S.getSourceManager(), S.getLangOpts()); - return MacroName != "YES" && MacroName != "NO" && MacroName != "true" && - MacroName != "false"; + return MacroName != "YES" && MacroName != "NO" && + MacroName != "true" && MacroName != "false"; } return false; @@ -12911,30 +12660,21 @@ struct PromotedRange { Value.isUnsigned() == PromotedMin.isUnsigned()); if (!isContiguous()) { assert(Value.isUnsigned() && "discontiguous range for signed compare"); - if (Value.isMinValue()) - return Min; - if (Value.isMaxValue()) - return Max; - if (Value >= PromotedMin) - return InRange; - if (Value <= PromotedMax) - return InRange; + if (Value.isMinValue()) return Min; + if (Value.isMaxValue()) return Max; + if (Value >= PromotedMin) return InRange; + if (Value <= PromotedMax) return InRange; return InHole; } switch (llvm::APSInt::compareValues(Value, PromotedMin)) { - case -1: - return Less; - case 0: - return PromotedMin == PromotedMax ? OnlyValue : Min; + case -1: return Less; + case 0: return PromotedMin == PromotedMax ? OnlyValue : Min; case 1: switch (llvm::APSInt::compareValues(Value, PromotedMax)) { - case -1: - return InRange; - case 0: - return Max; - case 1: - return Greater; + case -1: return InRange; + case 0: return Max; + case 1: return Greater; } } @@ -12945,15 +12685,11 @@ struct PromotedRange { constantValue(BinaryOperatorKind Op, ComparisonResult R, bool ConstantOnRHS) { if (Op == BO_Cmp) { ComparisonResult LTFlag = LT, GTFlag = GT; - if (ConstantOnRHS) - std::swap(LTFlag, GTFlag); - - if (R & EQ) - return StringRef("'std::strong_ordering::equal'"); - if (R & LTFlag) - return StringRef("'std::strong_ordering::less'"); - if (R & GTFlag) - return StringRef("'std::strong_ordering::greater'"); + if (ConstantOnRHS) std::swap(LTFlag, GTFlag); + + if (R & EQ) return StringRef("'std::strong_ordering::equal'"); + if (R & LTFlag) return StringRef("'std::strong_ordering::less'"); + if (R & GTFlag) return StringRef("'std::strong_ordering::greater'"); return llvm::None; } @@ -12982,12 +12718,13 @@ struct PromotedRange { return llvm::None; } }; -} // namespace +} static bool HasEnumType(Expr *E) { // Strip off implicit integral promotions. while (ImplicitCastExpr *ICE = dyn_cast(E)) { - if (ICE->getCastKind() != CK_IntegralCast && ICE->getCastKind() != CK_NoOp) + if (ICE->getCastKind() != CK_IntegralCast && + ICE->getCastKind() != CK_NoOp) break; E = ICE->getSubExpr(); } @@ -12998,7 +12735,11 @@ static bool HasEnumType(Expr *E) { static int classifyConstantValue(Expr *Constant) { // The values of this enumeration are used in the diagnostics // diag::warn_out_of_range_compare and diag::warn_tautological_bool_compare. - enum ConstantValueKind { Miscellaneous = 0, LiteralTrue, LiteralFalse }; + enum ConstantValueKind { + Miscellaneous = 0, + LiteralTrue, + LiteralFalse + }; if (auto *BL = dyn_cast(Constant)) return BL->getValue() ? ConstantValueKind::LiteralTrue : ConstantValueKind::LiteralFalse; @@ -13106,7 +12847,7 @@ static bool CheckTautologicalComparison(Sema &S, BinaryOperator *E, if (ED) { OS << '\'' << *ED << "' (" << Value << ")"; } else if (auto *BL = dyn_cast( - Constant->IgnoreParenImpCasts())) { + Constant->IgnoreParenImpCasts())) { OS << (BL->getValue() ? "YES" : "NO"); } else { OS << Value; @@ -13145,8 +12886,8 @@ static bool CheckTautologicalComparison(Sema &S, BinaryOperator *E, (isKnownToHaveUnsignedValue(OriginalOther) && Value == 0) ? (HasEnumType(OriginalOther) ? diag::warn_unsigned_enum_always_true_comparison - : IsCharTy ? diag::warn_unsigned_char_always_true_comparison - : diag::warn_unsigned_always_true_comparison) + : IsCharTy ? diag::warn_unsigned_char_always_true_comparison + : diag::warn_unsigned_always_true_comparison) : diag::warn_tautological_constant_compare; S.Diag(E->getOperatorLoc(), Diag) @@ -13290,7 +13031,7 @@ static bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init, // White-list bool bitfields. QualType BitfieldType = Bitfield->getType(); if (BitfieldType->isBooleanType()) - return false; + return false; if (BitfieldType->isEnumeralType()) { EnumDecl *BitfieldEnumDecl = BitfieldType->castAs()->getDecl(); @@ -13308,7 +13049,8 @@ static bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init, // Ignore value- or type-dependent expressions. if (Bitfield->getBitWidth()->isValueDependent() || - Bitfield->getBitWidth()->isTypeDependent() || Init->isValueDependent() || + Bitfield->getBitWidth()->isTypeDependent() || + Init->isValueDependent() || Init->isTypeDependent()) return false; @@ -13453,19 +13195,19 @@ static void DiagnoseImpCast(Sema &S, Expr *E, QualType SourceType, QualType T, return; } S.Diag(E->getExprLoc(), diag) - << SourceType << T << E->getSourceRange() << SourceRange(CContext); + << SourceType << T << E->getSourceRange() << SourceRange(CContext); } /// Diagnose an implicit cast; purely a helper for CheckImplicitConversion. static void DiagnoseImpCast(Sema &S, Expr *E, QualType T, - SourceLocation CContext, unsigned diag, - bool pruneControlFlow = false) { + SourceLocation CContext, + unsigned diag, bool pruneControlFlow = false) { DiagnoseImpCast(S, E, E->getType(), T, CContext, diag, pruneControlFlow); } static bool isObjCSignedCharBool(Sema &S, QualType Ty) { return Ty->isSpecificBuiltinType(BuiltinType::SChar) && - S.getLangOpts().ObjC && S.NSAPIObj->isObjCBOOLType(Ty); + S.getLangOpts().ObjC && S.NSAPIObj->isObjCBOOLType(Ty); } static void adornObjCBoolConversionDiagWithTernaryFixit( @@ -13500,7 +13242,7 @@ static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T, llvm::APFloat Value(0.0); bool IsConstant = - E->EvaluateAsFloat(Value, S.Context, Expr::SE_AllowSideEffects); + E->EvaluateAsFloat(Value, S.Context, Expr::SE_AllowSideEffects); if (!IsConstant) { if (isObjCSignedCharBool(S, T)) { return adornObjCBoolConversionDiagWithTernaryFixit( @@ -13509,8 +13251,8 @@ static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T, << E->getType()); } - return DiagnoseImpCast(S, E, T, CContext, diag::warn_impcast_float_integer, - PruneWarnings); + return DiagnoseImpCast(S, E, T, CContext, + diag::warn_impcast_float_integer, PruneWarnings); } bool isExact = false; @@ -13538,8 +13280,7 @@ static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T, } if (Result == llvm::APFloat::opOK && isExact) { - if (IsLiteral) - return; + if (IsLiteral) return; return DiagnoseImpCast(S, E, T, CContext, diag::warn_impcast_float_integer, PruneWarnings); } @@ -13558,7 +13299,7 @@ static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T, // Warn on floating point literal to integer. DiagID = diag::warn_impcast_literal_float_to_integer; } else if (IntegerValue == 0) { - if (Value.isZero()) { // Skip -0.0 to 0 conversion. + if (Value.isZero()) { // Skip -0.0 to 0 conversion. return DiagnoseImpCast(S, E, T, CContext, diag::warn_impcast_float_integer, PruneWarnings); } @@ -13570,7 +13311,7 @@ static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T, return DiagnoseImpCast(S, E, T, CContext, diag::warn_impcast_float_integer, PruneWarnings); } - } else { // IntegerValue.isSigned() + } else { // IntegerValue.isSigned() if (!IntegerValue.isMaxSignedValue() && !IntegerValue.isMinSignedValue()) { return DiagnoseImpCast(S, E, T, CContext, @@ -13619,8 +13360,7 @@ static void AnalyzeCompoundAssignment(Sema &S, BinaryOperator *E) { ->getAs(); // The below checks assume source is floating point. - if (!ResultBT || !RBT || !RBT->isFloatingPoint()) - return; + if (!ResultBT || !RBT || !RBT->isFloatingPoint()) return; // If source is floating point but target is an integer. if (ResultBT->isInteger()) @@ -13641,8 +13381,7 @@ static void AnalyzeCompoundAssignment(Sema &S, BinaryOperator *E) { static std::string PrettyPrintInRange(const llvm::APSInt &Value, IntRange Range) { - if (!Range.Width) - return "0"; + if (!Range.Width) return "0"; llvm::APSInt ValueInRange = Value; ValueInRange.setIsSigned(!Range.NonNegative); @@ -13657,12 +13396,12 @@ static bool IsImplicitBoolFloatConversion(Sema &S, Expr *Ex, bool ToBool) { Expr *InnerE = Ex->IgnoreParenImpCasts(); const Type *Target = S.Context.getCanonicalType(Ex->getType()).getTypePtr(); const Type *Source = - S.Context.getCanonicalType(InnerE->getType()).getTypePtr(); + S.Context.getCanonicalType(InnerE->getType()).getTypePtr(); if (Target->isDependentType()) return false; const BuiltinType *FloatCandidateBT = - dyn_cast(ToBool ? Source : Target); + dyn_cast(ToBool ? Source : Target); const Type *BoolCandidateType = ToBool ? Target : Source; return (BoolCandidateType->isSpecificBuiltinType(BuiltinType::Bool) && @@ -13677,13 +13416,14 @@ static void CheckImplicitArgumentConversions(Sema &S, CallExpr *TheCall, if (!IsImplicitBoolFloatConversion(S, CurrA, true)) continue; - bool IsSwapped = ((i > 0) && IsImplicitBoolFloatConversion( - S, TheCall->getArg(i - 1), false)); - IsSwapped |= ((i < (NumArgs - 1)) && IsImplicitBoolFloatConversion( - S, TheCall->getArg(i + 1), false)); + bool IsSwapped = ((i > 0) && + IsImplicitBoolFloatConversion(S, TheCall->getArg(i - 1), false)); + IsSwapped |= ((i < (NumArgs - 1)) && + IsImplicitBoolFloatConversion(S, TheCall->getArg(i + 1), false)); if (IsSwapped) { // Warn on this floating-point to bool conversion. - DiagnoseImpCast(S, CurrA->IgnoreParenImpCasts(), CurrA->getType(), CC, + DiagnoseImpCast(S, CurrA->IgnoreParenImpCasts(), + CurrA->getType(), CC, diag::warn_impcast_floating_point_to_bool); } } @@ -13760,8 +13500,10 @@ static void checkObjCCollectionLiteralElement(Sema &S, QualType ElementType = Element->getType(); ExprResult ElementResult(Element); if (ElementType->getAs() && - S.CheckSingleAssignmentConstraints(TargetElementType, ElementResult, - false, false) != Sema::Compatible) { + S.CheckSingleAssignmentConstraints(TargetElementType, + ElementResult, + false, false) + != Sema::Compatible) { S.Diag(Element->getBeginLoc(), diag::warn_objc_collection_literal_element) << ElementType << ElementKind << TargetElementType << Element->getSourceRange(); @@ -13785,8 +13527,8 @@ static void checkObjCArrayLiteral(Sema &S, QualType TargetType, return; if (TargetObjCPtr->isUnspecialized() || - TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl() != - S.NSArrayDecl->getCanonicalDecl()) + TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl() + != S.NSArrayDecl->getCanonicalDecl()) return; auto TypeArgs = TargetObjCPtr->getTypeArgs(); @@ -13796,7 +13538,8 @@ static void checkObjCArrayLiteral(Sema &S, QualType TargetType, QualType TargetElementType = TypeArgs[0]; for (unsigned I = 0, N = ArrayLiteral->getNumElements(); I != N; ++I) { checkObjCCollectionLiteralElement(S, TargetElementType, - ArrayLiteral->getElement(I), 0); + ArrayLiteral->getElement(I), + 0); } } @@ -13813,8 +13556,8 @@ checkObjCDictionaryLiteral(Sema &S, QualType TargetType, return; if (TargetObjCPtr->isUnspecialized() || - TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl() != - S.NSDictionaryDecl->getCanonicalDecl()) + TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl() + != S.NSDictionaryDecl->getCanonicalDecl()) return; auto TypeArgs = TargetObjCPtr->getTypeArgs(); @@ -13909,15 +13652,12 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T, SourceLocation CC, bool *ICContext = nullptr, bool IsListInit = false) { - if (E->isTypeDependent() || E->isValueDependent()) - return; + if (E->isTypeDependent() || E->isValueDependent()) return; const Type *Source = S.Context.getCanonicalType(E->getType()).getTypePtr(); const Type *Target = S.Context.getCanonicalType(T).getTypePtr(); - if (Source == Target) - return; - if (Target->isDependentType()) - return; + if (Source == Target) return; + if (Target->isDependentType()) return; // If the conversion context location is invalid don't complain. We also // don't want to emit a warning if the issue occurs from the expansion of @@ -14058,10 +13798,9 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T, Expr::EvalResult result; if (E->EvaluateAsRValue(result, S.Context)) { // Value might be a float, a float vector, or a float complex. - if (IsSameFloatAfterCast( - result.Val, - S.Context.getFloatTypeSemantics(QualType(TargetBT, 0)), - S.Context.getFloatTypeSemantics(QualType(SourceBT, 0)))) + if (IsSameFloatAfterCast(result.Val, + S.Context.getFloatTypeSemantics(QualType(TargetBT, 0)), + S.Context.getFloatTypeSemantics(QualType(SourceBT, 0)))) return; } @@ -14410,8 +14149,7 @@ static void CheckConditionalOperator(Sema &S, AbstractConditionalOperator *E, // If -Wconversion would have warned about either of the candidates // for a signedness conversion to the context type... - if (!Suspicious) - return; + if (!Suspicious) return; // ...but it's currently ignored... if (!S.Diags.isIgnored(diag::warn_impcast_integer_sign_conditional, CC)) @@ -14419,12 +14157,11 @@ static void CheckConditionalOperator(Sema &S, AbstractConditionalOperator *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; + if (E->getType() == T) return; Suspicious = false; - CheckImplicitConversion(S, TrueExpr->IgnoreParenImpCasts(), E->getType(), CC, - &Suspicious); + CheckImplicitConversion(S, TrueExpr->IgnoreParenImpCasts(), + E->getType(), CC, &Suspicious); if (!Suspicious) CheckImplicitConversion(S, E->getFalseExpr()->IgnoreParenImpCasts(), E->getType(), CC, &Suspicious); @@ -14446,7 +14183,7 @@ struct AnalyzeImplicitConversionsWorkItem { SourceLocation CC; bool IsListInit; }; -} // namespace +} /// Data recursive variant of AnalyzeImplicitConversions. Subexpressions /// that should be visited are added to WorkList. @@ -14552,12 +14289,10 @@ static void AnalyzeImplicitConversions( // we don't really need to recurse into them, because any internal // expressions should have been analyzed already when they were // built into statements. - if (isa(E)) - return; + if (isa(E)) return; // Don't descend into unevaluated contexts. - if (isa(E)) - return; + if (isa(E)) return; // Now just recurse over the expression's children. CC = E->getExprLoc(); @@ -14608,7 +14343,7 @@ static void AnalyzeImplicitConversions( /// implicit conversions in the given expression. There are a couple /// of competing diagnostics here, -Wconversion and -Wsign-compare. static void AnalyzeImplicitConversions(Sema &S, Expr *OrigE, SourceLocation CC, - bool IsListInit /*= false*/) { + bool IsListInit/*= false*/) { llvm::SmallVector WorkList; WorkList.push_back({OrigE, CC, IsListInit}); while (!WorkList.empty()) @@ -14721,8 +14456,8 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E, unsigned DiagID = IsCompare ? diag::warn_address_of_reference_null_compare : diag::warn_address_of_reference_bool_conversion; - PartialDiagnostic PD = PDiag(DiagID) - << E->getSourceRange() << Range << IsEqual; + PartialDiagnostic PD = PDiag(DiagID) << E->getSourceRange() << Range + << IsEqual; if (CheckForReference(*this, E, PD)) { return; } @@ -14735,8 +14470,8 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E, E->printPretty(S, nullptr, getPrintingPolicy()); unsigned DiagID = IsCompare ? diag::warn_nonnull_expr_compare : diag::warn_cast_nonnull_to_bool; - Diag(E->getExprLoc(), DiagID) - << IsParam << S.str() << E->getSourceRange() << Range << IsEqual; + Diag(E->getExprLoc(), DiagID) << IsParam << S.str() + << E->getSourceRange() << Range << IsEqual; Diag(NonnullAttr->getLocation(), diag::note_declared_nonnull) << IsParam; }; @@ -14763,7 +14498,7 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E, return; // Check for parameter decl with nonnull attribute - if (const auto *PV = dyn_cast(D)) { + if (const auto* PV = dyn_cast(D)) { if (getCurFunction() && !getCurFunction()->ModifiedNonNullParams.count(PV)) { if (const Attr *A = PV->getAttr()) { @@ -14781,8 +14516,8 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E, for (const auto *NonNull : FD->specific_attrs()) { if (!NonNull->args_size()) { - ComplainAboutNonnullParamOrCall(NonNull); - return; + ComplainAboutNonnullParamOrCall(NonNull); + return; } for (const ParamIdx &ArgNo : NonNull->args()) { @@ -14816,7 +14551,11 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E, unsigned DiagID = IsCompare ? diag::warn_null_pointer_compare : diag::warn_impcast_pointer_to_bool; - enum { AddressOf, FunctionPointer, ArrayPointer } DiagType; + enum { + AddressOf, + FunctionPointer, + ArrayPointer + } DiagType; if (IsAddressOf) DiagType = AddressOf; else if (IsFunction) @@ -14825,8 +14564,8 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E, DiagType = ArrayPointer; else llvm_unreachable("Could not determine diagnostic."); - Diag(E->getExprLoc(), DiagID) - << DiagType << S.str() << E->getSourceRange() << Range << IsEqual; + Diag(E->getExprLoc(), DiagID) << DiagType << S.str() << E->getSourceRange() + << Range << IsEqual; if (!IsFunction) return; @@ -14896,9 +14635,9 @@ void Sema::CheckBoolLikeConversion(Expr *E, SourceLocation CC) { ::CheckBoolLikeConversion(*this, E, CC); } -/// Diagnose when expression is an integer constant expression and its -/// evaluation results in integer overflow -void Sema::CheckForIntOverflow(Expr *E) { +/// Diagnose when expression is an integer constant expression and its evaluation +/// results in integer overflow +void Sema::CheckForIntOverflow (Expr *E) { // Use a work list to deal with nested struct initializers. SmallVector Exprs(1, E); @@ -14968,7 +14707,9 @@ class SequenceChecker : public ConstEvaluatedExprVisitor { } /// Merge a sequence of operations into its parent. - void merge(Seq S) { Values[S.Index].Merged = true; } + void merge(Seq S) { + Values[S.Index].Merged = true; + } /// Determine whether two operations are unsequenced. This operation /// is asymmetric: \p Cur should be the more recent sequence, and \p Old @@ -15059,7 +14800,7 @@ class SequenceChecker : public ConstEvaluatedExprVisitor { /// UK_ModAsValue. struct SequencedSubexpression { SequencedSubexpression(SequenceChecker &Self) - : Self(Self), OldModAsSideEffect(Self.ModAsSideEffect) { + : Self(Self), OldModAsSideEffect(Self.ModAsSideEffect) { Self.ModAsSideEffect = &ModAsSideEffect; } @@ -15794,8 +15535,9 @@ void Sema::CheckCompletedExpr(Expr *E, SourceLocation CheckLoc, } void Sema::CheckBitFieldInitialization(SourceLocation InitLoc, - FieldDecl *BitField, Expr *Init) { - (void)AnalyzeBitFieldAssignment(*this, BitField, Init, InitLoc); + FieldDecl *BitField, + Expr *Init) { + (void) AnalyzeBitFieldAssignment(*this, BitField, Init, InitLoc); } static void diagnoseArrayStarInParamType(Sema &S, QualType PType, @@ -15908,11 +15650,8 @@ bool Sema::CheckParmsForFunctionDef(ArrayRef Parameters, return HasInvalidParm; } -Optional> static getBaseAlignmentAndOffsetFromPtr(const Expr - *E, - ASTContext - &Ctx); +Optional> +static getBaseAlignmentAndOffsetFromPtr(const Expr *E, ASTContext &Ctx); /// Compute the alignment and offset of the base class object given the /// derived-to-base cast expression and the alignment and offset of the derived @@ -15977,10 +15716,8 @@ getAlignmentAndOffsetFromBinAddOrSub(const Expr *PtrE, const Expr *IntE, /// This helper function takes an lvalue expression and returns the alignment of /// a VarDecl and a constant offset from the VarDecl. -Optional> static getBaseAlignmentAndOffsetFromLValue(const Expr *E, - ASTContext &Ctx) { +Optional> +static getBaseAlignmentAndOffsetFromLValue(const Expr *E, ASTContext &Ctx) { E = E->IgnoreParens(); switch (E->getStmtClass()) { default: @@ -16067,11 +15804,8 @@ Optional> static getBaseAlignmentAndOffsetFromPtr(const Expr - *E, - ASTContext - &Ctx) { +Optional> +static getBaseAlignmentAndOffsetFromPtr(const Expr *E, ASTContext &Ctx) { E = E->IgnoreParens(); switch (E->getStmtClass()) { default: @@ -16159,44 +15893,39 @@ void Sema::CheckCastAlign(Expr *Op, QualType T, SourceRange TRange) { // Require that the destination be a pointer type. const PointerType *DestPtr = T->getAs(); - if (!DestPtr) - return; + if (!DestPtr) return; // If the destination has alignment 1, we're done. QualType DestPointee = DestPtr->getPointeeType(); - if (DestPointee->isIncompleteType()) - return; + if (DestPointee->isIncompleteType()) return; CharUnits DestAlign = Context.getTypeAlignInChars(DestPointee); - if (DestAlign.isOne()) - return; + if (DestAlign.isOne()) return; // Require that the source be a pointer type. const PointerType *SrcPtr = Op->getType()->getAs(); - if (!SrcPtr) - return; + if (!SrcPtr) return; QualType SrcPointee = SrcPtr->getPointeeType(); // Explicitly allow casts from cv void*. We already implicitly // allowed casts to cv void*, since they have alignment 1. // Also allow casts involving incomplete types, which implicitly // includes 'void'. - if (SrcPointee->isIncompleteType()) - return; + if (SrcPointee->isIncompleteType()) return; CharUnits SrcAlign = getPresumedAlignmentOfPointer(Op, *this); - if (SrcAlign >= DestAlign) - return; + if (SrcAlign >= DestAlign) return; Diag(TRange.getBegin(), diag::warn_cast_align) - << Op->getType() << T << static_cast(SrcAlign.getQuantity()) - << static_cast(DestAlign.getQuantity()) << TRange - << Op->getSourceRange(); + << Op->getType() << T + << static_cast(SrcAlign.getQuantity()) + << static_cast(DestAlign.getQuantity()) + << TRange << Op->getSourceRange(); } void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr, - const ArraySubscriptExpr *ASE, bool AllowOnePastEnd, - bool IndexNegated) { + const ArraySubscriptExpr *ASE, + bool AllowOnePastEnd, bool IndexNegated) { // Already diagnosed by the constant evaluator. if (isConstantEvaluated()) return; @@ -16211,8 +15940,8 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr, const ConstantArrayType *ArrayTy = Context.getAsConstantArrayType(BaseExpr->getType()); - LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = - getLangOpts().getStrictFlexArraysLevel(); + LangOptions::StrictFlexArraysLevelKind + StrictFlexArraysLevel = getLangOpts().getStrictFlexArraysLevel(); const Type *BaseType = ArrayTy == nullptr ? nullptr : ArrayTy->getElementType().getTypePtr(); @@ -16353,8 +16082,8 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr, // ']' location) and the index expression are both from macro expansions // within a system header. if (ASE) { - SourceLocation RBracketLoc = - SourceMgr.getSpellingLoc(ASE->getRBracketLoc()); + SourceLocation RBracketLoc = SourceMgr.getSpellingLoc( + ASE->getRBracketLoc()); if (SourceMgr.isInSystemHeader(RBracketLoc)) { SourceLocation IndexLoc = SourceMgr.getSpellingLoc(IndexExpr->getBeginLoc()); @@ -16376,8 +16105,7 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr, unsigned DiagID = diag::warn_array_index_precedes_bounds; if (!ASE) { DiagID = diag::warn_ptr_arith_precedes_bounds; - if (index.isNegative()) - index = -index; + if (index.isNegative()) index = -index; } DiagRuntimeBehavior(BaseExpr->getBeginLoc(), BaseExpr, @@ -16404,55 +16132,56 @@ void Sema::CheckArrayAccess(const Expr *expr) { while (expr) { expr = expr->IgnoreParenImpCasts(); switch (expr->getStmtClass()) { - case Stmt::ArraySubscriptExprClass: { - const ArraySubscriptExpr *ASE = cast(expr); - CheckArrayAccess(ASE->getBase(), ASE->getIdx(), ASE, AllowOnePastEnd > 0); - expr = ASE->getBase(); - break; - } - case Stmt::MemberExprClass: { - expr = cast(expr)->getBase(); - break; - } - case Stmt::OMPArraySectionExprClass: { - const OMPArraySectionExpr *ASE = cast(expr); - if (ASE->getLowerBound()) - CheckArrayAccess(ASE->getBase(), ASE->getLowerBound(), - /*ASE=*/nullptr, AllowOnePastEnd > 0); - return; - } - case Stmt::UnaryOperatorClass: { - // Only unwrap the * and & unary operators - const UnaryOperator *UO = cast(expr); - expr = UO->getSubExpr(); - switch (UO->getOpcode()) { - case UO_AddrOf: - AllowOnePastEnd++; + case Stmt::ArraySubscriptExprClass: { + const ArraySubscriptExpr *ASE = cast(expr); + CheckArrayAccess(ASE->getBase(), ASE->getIdx(), ASE, + AllowOnePastEnd > 0); + expr = ASE->getBase(); break; - case UO_Deref: - AllowOnePastEnd--; + } + case Stmt::MemberExprClass: { + expr = cast(expr)->getBase(); break; - default: + } + case Stmt::OMPArraySectionExprClass: { + const OMPArraySectionExpr *ASE = cast(expr); + if (ASE->getLowerBound()) + CheckArrayAccess(ASE->getBase(), ASE->getLowerBound(), + /*ASE=*/nullptr, AllowOnePastEnd > 0); return; } - break; - } - case Stmt::ConditionalOperatorClass: { - const ConditionalOperator *cond = cast(expr); - if (const Expr *lhs = cond->getLHS()) - CheckArrayAccess(lhs); - if (const Expr *rhs = cond->getRHS()) - CheckArrayAccess(rhs); - return; - } - case Stmt::CXXOperatorCallExprClass: { - const auto *OCE = cast(expr); - for (const auto *Arg : OCE->arguments()) - CheckArrayAccess(Arg); - return; - } - default: - return; + case Stmt::UnaryOperatorClass: { + // Only unwrap the * and & unary operators + const UnaryOperator *UO = cast(expr); + expr = UO->getSubExpr(); + switch (UO->getOpcode()) { + case UO_AddrOf: + AllowOnePastEnd++; + break; + case UO_Deref: + AllowOnePastEnd--; + break; + default: + return; + } + break; + } + case Stmt::ConditionalOperatorClass: { + const ConditionalOperator *cond = cast(expr); + if (const Expr *lhs = cond->getLHS()) + CheckArrayAccess(lhs); + if (const Expr *rhs = cond->getRHS()) + CheckArrayAccess(rhs); + return; + } + case Stmt::CXXOperatorCallExprClass: { + const auto *OCE = cast(expr); + for (const auto *Arg : OCE->arguments()) + CheckArrayAccess(Arg); + return; + } + default: + return; } } } @@ -16518,22 +16247,19 @@ static bool findRetainCycleOwner(Sema &S, Expr *e, RetainCycleOwner &owner) { if (!findRetainCycleOwner(S, ref->getBase(), owner)) return false; - if (ref->isFreeIvar()) - owner.setLocsFrom(ref); + if (ref->isFreeIvar()) owner.setLocsFrom(ref); owner.Indirect = true; return true; } if (DeclRefExpr *ref = dyn_cast(e)) { VarDecl *var = dyn_cast(ref->getDecl()); - if (!var) - return false; + if (!var) return false; return considerVariable(var, ref, owner); } if (MemberExpr *member = dyn_cast(e)) { - if (member->isArrow()) - return false; + if (member->isArrow()) return false; // Don't count this as an indirect ownership. e = member->getBase(); @@ -16542,18 +16268,17 @@ static bool findRetainCycleOwner(Sema &S, Expr *e, RetainCycleOwner &owner) { if (PseudoObjectExpr *pseudo = dyn_cast(e)) { // Only pay attention to pseudo-objects on property references. - ObjCPropertyRefExpr *pre = dyn_cast( - pseudo->getSyntacticForm()->IgnoreParens()); - if (!pre) - return false; - if (pre->isImplicitProperty()) - return false; + ObjCPropertyRefExpr *pre + = dyn_cast(pseudo->getSyntacticForm() + ->IgnoreParens()); + if (!pre) return false; + if (pre->isImplicitProperty()) return false; ObjCPropertyDecl *property = pre->getExplicitProperty(); if (!property->isRetaining() && !(property->getPropertyIvarDecl() && - property->getPropertyIvarDecl()->getType().getObjCLifetime() == - Qualifiers::OCL_Strong)) - return false; + property->getPropertyIvarDecl()->getType() + .getObjCLifetime() == Qualifiers::OCL_Strong)) + return false; owner.Indirect = true; if (pre->isSuperReceiver()) { @@ -16564,8 +16289,8 @@ static bool findRetainCycleOwner(Sema &S, Expr *e, RetainCycleOwner &owner) { owner.Range = pre->getSourceRange(); return true; } - e = const_cast( - cast(pre->getBase())->getSourceExpr()); + e = const_cast(cast(pre->getBase()) + ->getSourceExpr()); continue; } @@ -16577,59 +16302,57 @@ static bool findRetainCycleOwner(Sema &S, Expr *e, RetainCycleOwner &owner) { namespace { -struct FindCaptureVisitor : EvaluatedExprVisitor { - ASTContext &Context; - VarDecl *Variable; - Expr *Capturer = nullptr; - bool VarWillBeReased = false; + struct FindCaptureVisitor : EvaluatedExprVisitor { + ASTContext &Context; + VarDecl *Variable; + Expr *Capturer = nullptr; + bool VarWillBeReased = false; - FindCaptureVisitor(ASTContext &Context, VarDecl *variable) - : EvaluatedExprVisitor(Context), Context(Context), - Variable(variable) {} + FindCaptureVisitor(ASTContext &Context, VarDecl *variable) + : EvaluatedExprVisitor(Context), + Context(Context), Variable(variable) {} - void VisitDeclRefExpr(DeclRefExpr *ref) { - if (ref->getDecl() == Variable && !Capturer) - Capturer = ref; - } + void VisitDeclRefExpr(DeclRefExpr *ref) { + if (ref->getDecl() == Variable && !Capturer) + Capturer = ref; + } - void VisitObjCIvarRefExpr(ObjCIvarRefExpr *ref) { - if (Capturer) - return; - Visit(ref->getBase()); - if (Capturer && ref->isFreeIvar()) - Capturer = ref; - } + void VisitObjCIvarRefExpr(ObjCIvarRefExpr *ref) { + if (Capturer) return; + Visit(ref->getBase()); + if (Capturer && ref->isFreeIvar()) + Capturer = ref; + } - void VisitBlockExpr(BlockExpr *block) { - // Look inside nested blocks - if (block->getBlockDecl()->capturesVariable(Variable)) - Visit(block->getBlockDecl()->getBody()); - } + void VisitBlockExpr(BlockExpr *block) { + // Look inside nested blocks + if (block->getBlockDecl()->capturesVariable(Variable)) + Visit(block->getBlockDecl()->getBody()); + } - void VisitOpaqueValueExpr(OpaqueValueExpr *OVE) { - if (Capturer) - return; - if (OVE->getSourceExpr()) - Visit(OVE->getSourceExpr()); - } + void VisitOpaqueValueExpr(OpaqueValueExpr *OVE) { + if (Capturer) return; + if (OVE->getSourceExpr()) + Visit(OVE->getSourceExpr()); + } - void VisitBinaryOperator(BinaryOperator *BinOp) { - if (!Variable || VarWillBeReased || BinOp->getOpcode() != BO_Assign) - return; - Expr *LHS = BinOp->getLHS(); - if (const DeclRefExpr *DRE = dyn_cast_or_null(LHS)) { - if (DRE->getDecl() != Variable) + void VisitBinaryOperator(BinaryOperator *BinOp) { + if (!Variable || VarWillBeReased || BinOp->getOpcode() != BO_Assign) return; - if (Expr *RHS = BinOp->getRHS()) { - RHS = RHS->IgnoreParenCasts(); - Optional Value; - VarWillBeReased = - (RHS && (Value = RHS->getIntegerConstantExpr(Context)) && - *Value == 0); + Expr *LHS = BinOp->getLHS(); + if (const DeclRefExpr *DRE = dyn_cast_or_null(LHS)) { + if (DRE->getDecl() != Variable) + return; + if (Expr *RHS = BinOp->getRHS()) { + RHS = RHS->IgnoreParenCasts(); + Optional Value; + VarWillBeReased = + (RHS && (Value = RHS->getIntegerConstantExpr(Context)) && + *Value == 0); + } } } - } -}; + }; } // namespace @@ -16676,20 +16399,18 @@ static void diagnoseRetainCycle(Sema &S, Expr *capturer, assert(owner.Variable && owner.Loc.isValid()); S.Diag(capturer->getExprLoc(), diag::warn_arc_retain_cycle) - << owner.Variable << capturer->getSourceRange(); + << owner.Variable << capturer->getSourceRange(); S.Diag(owner.Loc, diag::note_arc_retain_cycle_owner) - << owner.Indirect << owner.Range; + << owner.Indirect << owner.Range; } /// Check for a keyword selector that starts with the word 'add' or /// 'set'. static bool isSetterLikeSelector(Selector sel) { - if (sel.isUnarySelector()) - return false; + if (sel.isUnarySelector()) return false; StringRef str = sel.getNameForSlot(0); - while (!str.empty() && str.front() == '_') - str = str.substr(1); + while (!str.empty() && str.front() == '_') str = str.substr(1); if (str.startswith("set")) str = str.substr(3); else if (str.startswith("add")) { @@ -16697,18 +16418,19 @@ static bool isSetterLikeSelector(Selector sel) { if (sel.getNumArgs() == 1 && str.startswith("addOperationWithBlock")) return false; str = str.substr(3); - } else + } + else return false; - if (str.empty()) - return true; + if (str.empty()) return true; return !isLowercase(str.front()); } static Optional GetNSMutableArrayArgumentIndex(Sema &S, ObjCMessageExpr *Message) { bool IsMutableArray = S.NSAPIObj->isSubclassOfNSClass( - Message->getReceiverInterface(), NSAPI::ClassId_NSMutableArray); + Message->getReceiverInterface(), + NSAPI::ClassId_NSMutableArray); if (!IsMutableArray) { return None; } @@ -16716,7 +16438,7 @@ static Optional GetNSMutableArrayArgumentIndex(Sema &S, Selector Sel = Message->getSelector(); Optional MKOpt = - S.NSAPIObj->getNSArrayMethodKind(Sel); + S.NSAPIObj->getNSArrayMethodKind(Sel); if (!MKOpt) { return None; } @@ -16724,24 +16446,26 @@ static Optional GetNSMutableArrayArgumentIndex(Sema &S, NSAPI::NSArrayMethodKind MK = *MKOpt; switch (MK) { - case NSAPI::NSMutableArr_addObject: - case NSAPI::NSMutableArr_insertObjectAtIndex: - case NSAPI::NSMutableArr_setObjectAtIndexedSubscript: - return 0; - case NSAPI::NSMutableArr_replaceObjectAtIndex: - return 1; + case NSAPI::NSMutableArr_addObject: + case NSAPI::NSMutableArr_insertObjectAtIndex: + case NSAPI::NSMutableArr_setObjectAtIndexedSubscript: + return 0; + case NSAPI::NSMutableArr_replaceObjectAtIndex: + return 1; - default: - return None; + default: + return None; } return None; } -static Optional -GetNSMutableDictionaryArgumentIndex(Sema &S, ObjCMessageExpr *Message) { +static +Optional GetNSMutableDictionaryArgumentIndex(Sema &S, + ObjCMessageExpr *Message) { bool IsMutableDictionary = S.NSAPIObj->isSubclassOfNSClass( - Message->getReceiverInterface(), NSAPI::ClassId_NSMutableDictionary); + Message->getReceiverInterface(), + NSAPI::ClassId_NSMutableDictionary); if (!IsMutableDictionary) { return None; } @@ -16749,7 +16473,7 @@ GetNSMutableDictionaryArgumentIndex(Sema &S, ObjCMessageExpr *Message) { Selector Sel = Message->getSelector(); Optional MKOpt = - S.NSAPIObj->getNSDictionaryMethodKind(Sel); + S.NSAPIObj->getNSDictionaryMethodKind(Sel); if (!MKOpt) { return None; } @@ -16757,13 +16481,13 @@ GetNSMutableDictionaryArgumentIndex(Sema &S, ObjCMessageExpr *Message) { NSAPI::NSDictionaryMethodKind MK = *MKOpt; switch (MK) { - case NSAPI::NSMutableDict_setObjectForKey: - case NSAPI::NSMutableDict_setValueForKey: - case NSAPI::NSMutableDict_setObjectForKeyedSubscript: - return 0; + case NSAPI::NSMutableDict_setObjectForKey: + case NSAPI::NSMutableDict_setValueForKey: + case NSAPI::NSMutableDict_setObjectForKeyedSubscript: + return 0; - default: - return None; + default: + return None; } return None; @@ -16771,10 +16495,12 @@ GetNSMutableDictionaryArgumentIndex(Sema &S, ObjCMessageExpr *Message) { static Optional GetNSSetArgumentIndex(Sema &S, ObjCMessageExpr *Message) { bool IsMutableSet = S.NSAPIObj->isSubclassOfNSClass( - Message->getReceiverInterface(), NSAPI::ClassId_NSMutableSet); + Message->getReceiverInterface(), + NSAPI::ClassId_NSMutableSet); bool IsMutableOrderedSet = S.NSAPIObj->isSubclassOfNSClass( - Message->getReceiverInterface(), NSAPI::ClassId_NSMutableOrderedSet); + Message->getReceiverInterface(), + NSAPI::ClassId_NSMutableOrderedSet); if (!IsMutableSet && !IsMutableOrderedSet) { return None; } @@ -16789,13 +16515,13 @@ static Optional GetNSSetArgumentIndex(Sema &S, ObjCMessageExpr *Message) { NSAPI::NSSetMethodKind MK = *MKOpt; switch (MK) { - case NSAPI::NSMutableSet_addObject: - case NSAPI::NSOrderedSet_setObjectAtIndex: - case NSAPI::NSOrderedSet_setObjectAtIndexedSubscript: - case NSAPI::NSOrderedSet_insertObjectAtIndex: - return 0; - case NSAPI::NSOrderedSet_replaceObjectAtIndexWithObject: - return 1; + case NSAPI::NSMutableSet_addObject: + case NSAPI::NSOrderedSet_setObjectAtIndex: + case NSAPI::NSOrderedSet_setObjectAtIndexedSubscript: + case NSAPI::NSOrderedSet_insertObjectAtIndex: + return 0; + case NSAPI::NSOrderedSet_replaceObjectAtIndexWithObject: + return 1; } return None; @@ -16826,7 +16552,7 @@ void Sema::CheckObjCCircularContainer(ObjCMessageExpr *Message) { if (ArgRE->isObjCSelfExpr()) { Diag(Message->getSourceRange().getBegin(), diag::warn_objc_circular_container) - << ArgRE->getDecl() << StringRef("'super'"); + << ArgRE->getDecl() << StringRef("'super'"); } } } else { @@ -16842,11 +16568,11 @@ void Sema::CheckObjCCircularContainer(ObjCMessageExpr *Message) { ValueDecl *Decl = ReceiverRE->getDecl(); Diag(Message->getSourceRange().getBegin(), diag::warn_objc_circular_container) - << Decl << Decl; + << Decl << Decl; if (!ArgRE->isObjCSelfExpr()) { Diag(Decl->getLocation(), diag::note_objc_circular_container_declared_here) - << Decl; + << Decl; } } } @@ -16856,10 +16582,10 @@ void Sema::CheckObjCCircularContainer(ObjCMessageExpr *Message) { ObjCIvarDecl *Decl = IvarRE->getDecl(); Diag(Message->getSourceRange().getBegin(), diag::warn_objc_circular_container) - << Decl << Decl; + << Decl << Decl; Diag(Decl->getLocation(), diag::note_objc_circular_container_declared_here) - << Decl; + << Decl; } } } @@ -16920,8 +16646,8 @@ void Sema::checkRetainCycles(VarDecl *Var, Expr *Init) { diagnoseRetainCycle(*this, Capturer, Owner); } -static bool checkUnsafeAssignLiteral(Sema &S, SourceLocation Loc, Expr *RHS, - bool isProperty) { +static bool checkUnsafeAssignLiteral(Sema &S, SourceLocation Loc, + Expr *RHS, bool isProperty) { // Check if RHS is an Objective-C object literal, which also can get // immediately zapped in a weak reference. Note that we explicitly // allow ObjCStringLiterals, since those are designed to never really die. @@ -16934,20 +16660,23 @@ static bool checkUnsafeAssignLiteral(Sema &S, SourceLocation Loc, Expr *RHS, return false; S.Diag(Loc, diag::warn_arc_literal_assign) - << (unsigned)Kind << (isProperty ? 0 : 1) << RHS->getSourceRange(); + << (unsigned) Kind + << (isProperty ? 0 : 1) + << RHS->getSourceRange(); return true; } static bool checkUnsafeAssignObject(Sema &S, SourceLocation Loc, - Qualifiers::ObjCLifetime LT, Expr *RHS, - bool isProperty) { + Qualifiers::ObjCLifetime LT, + Expr *RHS, bool isProperty) { // Strip off any implicit cast added to get to the one ARC-specific. while (ImplicitCastExpr *cast = dyn_cast(RHS)) { if (cast->getCastKind() == CK_ARCConsumeObject) { S.Diag(Loc, diag::warn_arc_retained_assign) - << (LT == Qualifiers::OCL_ExplicitNone) << (isProperty ? 0 : 1) - << RHS->getSourceRange(); + << (LT == Qualifiers::OCL_ExplicitNone) + << (isProperty ? 0 : 1) + << RHS->getSourceRange(); return true; } RHS = cast->getSubExpr(); @@ -16960,7 +16689,8 @@ static bool checkUnsafeAssignObject(Sema &S, SourceLocation Loc, return false; } -bool Sema::checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS) { +bool Sema::checkUnsafeAssigns(SourceLocation Loc, + QualType LHS, Expr *RHS) { Qualifiers::ObjCLifetime LT = LHS.getObjCLifetime(); if (LT != Qualifiers::OCL_Weak && LT != Qualifiers::OCL_ExplicitNone) @@ -16972,11 +16702,13 @@ bool Sema::checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS) { return false; } -void Sema::checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS) { +void Sema::checkUnsafeExprAssigns(SourceLocation Loc, + Expr *LHS, Expr *RHS) { QualType LHSType; // PropertyRef on LHS type need be directly obtained from // its declaration as it has a PseudoType. - ObjCPropertyRefExpr *PRE = dyn_cast(LHS->IgnoreParens()); + ObjCPropertyRefExpr *PRE + = dyn_cast(LHS->IgnoreParens()); if (PRE && !PRE->isImplicitProperty()) { const ObjCPropertyDecl *PD = PRE->getExplicitProperty(); if (PD) @@ -17020,7 +16752,7 @@ void Sema::checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS) { while (ImplicitCastExpr *cast = dyn_cast(RHS)) { if (cast->getCastKind() == CK_ARCConsumeObject) { Diag(Loc, diag::warn_arc_retained_property_assign) - << RHS->getSourceRange(); + << RHS->getSourceRange(); return; } RHS = cast->getSubExpr(); @@ -17047,14 +16779,14 @@ static bool ShouldDiagnoseEmptyStmtBody(const SourceManager &SourceMgr, // Get line numbers of statement and body. bool StmtLineInvalid; - unsigned StmtLine = - SourceMgr.getPresumedLineNumber(StmtLoc, &StmtLineInvalid); + unsigned StmtLine = SourceMgr.getPresumedLineNumber(StmtLoc, + &StmtLineInvalid); if (StmtLineInvalid) return false; bool BodyLineInvalid; - unsigned BodyLine = - SourceMgr.getSpellingLineNumber(Body->getSemiLoc(), &BodyLineInvalid); + unsigned BodyLine = SourceMgr.getSpellingLineNumber(Body->getSemiLoc(), + &BodyLineInvalid); if (BodyLineInvalid) return false; @@ -17065,7 +16797,8 @@ static bool ShouldDiagnoseEmptyStmtBody(const SourceManager &SourceMgr, return true; } -void Sema::DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body, +void Sema::DiagnoseEmptyStmtBody(SourceLocation StmtLoc, + const Stmt *Body, unsigned DiagID) { // Since this is a syntactic check, don't emit diagnostic for template // instantiations, this just adds noise. @@ -17085,7 +16818,8 @@ void Sema::DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body, Diag(NBody->getSemiLoc(), diag::note_empty_body_on_separate_line); } -void Sema::DiagnoseEmptyLoopBody(const Stmt *S, const Stmt *PossibleBody) { +void Sema::DiagnoseEmptyLoopBody(const Stmt *S, + const Stmt *PossibleBody) { assert(!CurrentInstantiationScope); // Ensured by caller SourceLocation StmtLoc; @@ -17154,7 +16888,7 @@ void Sema::DiagnoseEmptyLoopBody(const Stmt *S, const Stmt *PossibleBody) { /// DiagnoseSelfMove - Emits a warning if a value is moved to itself. void Sema::DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr, - SourceLocation OpLoc) { + SourceLocation OpLoc) { if (Diags.isIgnored(diag::warn_sizeof_pointer_expr_memaccess, OpLoc)) return; @@ -17291,10 +17025,12 @@ static bool isLayoutCompatibleStruct(ASTContext &C, RecordDecl *RD1, return false; // Check the base classes. - for (CXXRecordDecl::base_class_const_iterator Base1 = D1CXX->bases_begin(), - BaseEnd1 = D1CXX->bases_end(), - Base2 = D2CXX->bases_begin(); - Base1 != BaseEnd1; ++Base1, ++Base2) { + for (CXXRecordDecl::base_class_const_iterator + Base1 = D1CXX->bases_begin(), + BaseEnd1 = D1CXX->bases_end(), + Base2 = D2CXX->bases_begin(); + Base1 != BaseEnd1; + ++Base1, ++Base2) { if (!isLayoutCompatible(C, Base1->getType(), Base2->getType())) return false; } @@ -17309,7 +17045,7 @@ static bool isLayoutCompatibleStruct(ASTContext &C, RecordDecl *RD1, Field2End = RD2->field_end(), Field1 = RD1->field_begin(), Field1End = RD1->field_end(); - for (; Field1 != Field1End && Field2 != Field2End; ++Field1, ++Field2) { + for ( ; Field1 != Field1End && Field2 != Field2End; ++Field1, ++Field2) { if (!isLayoutCompatible(C, *Field1, *Field2)) return false; } @@ -17328,13 +17064,14 @@ static bool isLayoutCompatibleUnion(ASTContext &C, RecordDecl *RD1, UnmatchedFields.insert(Field2); for (auto *Field1 : RD1->fields()) { - llvm::SmallPtrSet::iterator I = UnmatchedFields.begin(), - E = UnmatchedFields.end(); + llvm::SmallPtrSet::iterator + I = UnmatchedFields.begin(), + E = UnmatchedFields.end(); - for (; I != E; ++I) { + for ( ; I != E; ++I) { if (isLayoutCompatible(C, Field1, *I)) { bool Result = UnmatchedFields.erase(*I); - (void)Result; + (void) Result; assert(Result); break; } @@ -17378,13 +17115,15 @@ static bool isLayoutCompatible(ASTContext &C, QualType T1, QualType T2) { return false; if (TC1 == Type::Enum) { - return isLayoutCompatible(C, cast(T1)->getDecl(), + return isLayoutCompatible(C, + cast(T1)->getDecl(), cast(T2)->getDecl()); } else if (TC1 == Type::Record) { if (!T1->isStandardLayoutType() || !T2->isStandardLayoutType()) return false; - return isLayoutCompatible(C, cast(T1)->getDecl(), + return isLayoutCompatible(C, + cast(T1)->getDecl(), cast(T2)->getDecl()); } @@ -17407,7 +17146,7 @@ static bool isLayoutCompatible(ASTContext &C, QualType T1, QualType T2) { static bool FindTypeTagExpr(const Expr *TypeExpr, const ASTContext &Ctx, const ValueDecl **VD, uint64_t *MagicValue, bool isConstantEvaluated) { - while (true) { + while(true) { if (!TypeExpr) return false; @@ -17519,7 +17258,8 @@ static bool GetMatchingCType( if (!MagicValues) return false; - llvm::DenseMap::const_iterator I = + llvm::DenseMap::const_iterator I = MagicValues->find(std::make_pair(ArgumentKind, MagicValue)); if (I == MagicValues->end()) return false; @@ -17530,7 +17270,8 @@ static bool GetMatchingCType( void Sema::RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind, uint64_t MagicValue, QualType Type, - bool LayoutCompatible, bool MustBeNull) { + bool LayoutCompatible, + bool MustBeNull) { if (!TypeTagForDatatypeMagicValues) TypeTagForDatatypeMagicValues.reset( new llvm::DenseMap); @@ -17552,8 +17293,8 @@ static bool IsSameCharType(QualType T1, QualType T2) { BuiltinType::Kind T1Kind = BT1->getKind(); BuiltinType::Kind T2Kind = BT2->getKind(); - return (T1Kind == BuiltinType::SChar && T2Kind == BuiltinType::Char_S) || - (T1Kind == BuiltinType::UChar && T2Kind == BuiltinType::Char_U) || + return (T1Kind == BuiltinType::SChar && T2Kind == BuiltinType::Char_S) || + (T1Kind == BuiltinType::UChar && T2Kind == BuiltinType::Char_U) || (T1Kind == BuiltinType::Char_U && T2Kind == BuiltinType::UChar) || (T1Kind == BuiltinType::Char_S && T2Kind == BuiltinType::SChar); } @@ -17580,7 +17321,7 @@ void Sema::CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr, if (FoundWrongKind) Diag(TypeTagExpr->getExprLoc(), diag::warn_type_tag_for_datatype_wrong_kind) - << TypeTagExpr->getSourceRange(); + << TypeTagExpr->getSourceRange(); return; } @@ -17607,11 +17348,12 @@ void Sema::CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr, if (TypeInfo.MustBeNull) { // Type tag with matching void type requires a null pointer. - if (!ArgumentExpr->isNullPointerConstant( - Context, Expr::NPC_ValueDependentIsNotNull)) { + if (!ArgumentExpr->isNullPointerConstant(Context, + Expr::NPC_ValueDependentIsNotNull)) { Diag(ArgumentExpr->getExprLoc(), diag::warn_type_safety_null_pointer_required) - << ArgumentKind->getName() << ArgumentExpr->getSourceRange() + << ArgumentKind->getName() + << ArgumentExpr->getSourceRange() << TypeTagExpr->getSourceRange(); } return; @@ -17635,16 +17377,19 @@ void Sema::CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr, RequiredType->getPointeeType())) || (!IsPointerAttr && IsSameCharType(ArgumentType, RequiredType))) mismatch = false; - } else if (IsPointerAttr) - mismatch = !isLayoutCompatible(Context, ArgumentType->getPointeeType(), - RequiredType->getPointeeType()); - else - mismatch = !isLayoutCompatible(Context, ArgumentType, RequiredType); + } else + if (IsPointerAttr) + mismatch = !isLayoutCompatible(Context, + ArgumentType->getPointeeType(), + RequiredType->getPointeeType()); + else + mismatch = !isLayoutCompatible(Context, ArgumentType, RequiredType); if (mismatch) Diag(ArgumentExpr->getExprLoc(), diag::warn_type_safety_type_mismatch) - << ArgumentType << ArgumentKind << TypeInfo.LayoutCompatible - << RequiredType << ArgumentExpr->getSourceRange() + << ArgumentType << ArgumentKind + << TypeInfo.LayoutCompatible << RequiredType + << ArgumentExpr->getSourceRange() << TypeTagExpr->getSourceRange(); } @@ -17737,7 +17482,7 @@ void Sema::RefersToMemberWithReducedAlignment( // For now, just disregard these cases. This is left for future // improvement. if (!DRE && !isa(TopBase)) - return; + return; // Alignment expected by the whole expression. CharUnits ExpectedAlignment = Context.getTypeAlignInChars(E->getType()); From 5e7346740cab5267b07ba8f6c6b360d42f6e355d Mon Sep 17 00:00:00 2001 From: adeel10x Date: Mon, 18 Dec 2023 16:51:43 +0500 Subject: [PATCH 5/6] [RISCV][Clang] Added tests to check the immediate operand range for the following intrinsics: - __builtin_riscv_cv_simd_extract_h - __builtin_riscv_cv_simd_extract_b - __builtin_riscv_cv_simd_extractu_h - __builtin_riscv_cv_simd_extractu_b - __builtin_riscv_cv_simd_insert_h - __builtin_riscv_cv_simd_insert_b --- .../RISCV/corev-intrinsics/simd-errors.c | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 clang/test/CodeGen/RISCV/corev-intrinsics/simd-errors.c diff --git a/clang/test/CodeGen/RISCV/corev-intrinsics/simd-errors.c b/clang/test/CodeGen/RISCV/corev-intrinsics/simd-errors.c new file mode 100644 index 000000000000..0a07309b2aa8 --- /dev/null +++ b/clang/test/CodeGen/RISCV/corev-intrinsics/simd-errors.c @@ -0,0 +1,50 @@ +// RUN: %clang_cc1 %s -triple=riscv32 -target-feature +xcvsimd -fsyntax-only -verify +#include + +uint32_t test_extract_h(uint32_t a) { + return __builtin_riscv_cv_simd_extract_h(a, 2); // expected-error {{argument value 2 is outside the valid range [0, 1]}} +} + +uint32_t test_extract_h_negative(uint32_t a) { + return __builtin_riscv_cv_simd_extract_h(a, -1); // expected-error {{argument value 255 is outside the valid range [0, 1]}} +} + +uint32_t test_extractu_h(uint32_t a) { + return __builtin_riscv_cv_simd_extractu_h(a, 2); // expected-error {{argument value 2 is outside the valid range [0, 1]}} +} + +uint32_t test_extractu_h_negative(uint32_t a) { + return __builtin_riscv_cv_simd_extractu_h(a, -1); // expected-error {{argument value 255 is outside the valid range [0, 1]}} +} + +uint32_t test_extract_b(uint32_t a) { + return __builtin_riscv_cv_simd_extract_b(a, 4); // expected-error {{argument value 4 is outside the valid range [0, 3]}} +} + +uint32_t test_extract_b_negative(uint32_t a) { + return __builtin_riscv_cv_simd_extract_b(a, -1); // expected-error {{argument value 255 is outside the valid range [0, 3]}} +} + +uint32_t test_extractu_b(uint32_t a) { + return __builtin_riscv_cv_simd_extractu_b(a, 4); // expected-error {{argument value 4 is outside the valid range [0, 3]}} +} + +uint32_t test_extractu_b_negative(uint32_t a) { + return __builtin_riscv_cv_simd_extractu_b(a, -1); // expected-error {{argument value 255 is outside the valid range [0, 3]}} +} + +uint32_t test_insert_h(uint32_t dst, uint8_t a) { + return __builtin_riscv_cv_simd_insert_h(dst, a, 2); // expected-error {{argument value 2 is outside the valid range [0, 1]}} +} + +uint32_t test_insert_h_negative(uint32_t dst, uint8_t a) { + return __builtin_riscv_cv_simd_insert_h(dst, a, -1); // expected-error {{argument value 255 is outside the valid range [0, 1]}} +} + +uint32_t test_insert_b(uint32_t dst, uint8_t a) { + return __builtin_riscv_cv_simd_insert_b(dst, a, 4); // expected-error {{argument value 4 is outside the valid range [0, 3]}} +} + +uint32_t test_insert_b_negative(uint32_t dst, uint8_t a) { + return __builtin_riscv_cv_simd_insert_b(dst, a, -1); // expected-error {{argument value 255 is outside the valid range [0, 3]}} +} From e6aa6efa612326ef8f6a8bbcc3c7063d68851b5a Mon Sep 17 00:00:00 2001 From: adeel10x Date: Sun, 24 Dec 2023 16:29:56 +0500 Subject: [PATCH 6/6] Modified tests for the following builtins: __builtin_riscv_cv_simd_extract_h __builtin_riscv_cv_simd_extract_b __builtin_riscv_cv_simd_extractu_h __builtin_riscv_cv_simd_extractu_b --- .../CodeGen/RISCV/corev-intrinsics/simd.c | 112 +++++++++++++----- 1 file changed, 80 insertions(+), 32 deletions(-) diff --git a/clang/test/CodeGen/RISCV/corev-intrinsics/simd.c b/clang/test/CodeGen/RISCV/corev-intrinsics/simd.c index d14e498806f0..607d3ec1ce4a 100644 --- a/clang/test/CodeGen/RISCV/corev-intrinsics/simd.c +++ b/clang/test/CodeGen/RISCV/corev-intrinsics/simd.c @@ -2256,100 +2256,148 @@ uint32_t test_sdotsp_sci_b_negative(uint32_t a, uint8_t b) { return __builtin_riscv_cv_simd_sdotsp_sc_b(a, -32, b); } -// CHECK-LABEL: @test_extract_h( +// CHECK-LABEL: @test_extract_h0( // CHECK-NEXT: entry: // CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 // CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 -// CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.cv.simd.extract.h(i32 [[TMP0]], i32 5) +// CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.cv.simd.extract.h(i32 [[TMP0]], i32 0) // CHECK-NEXT: ret i32 [[TMP1]] // -uint32_t test_extract_h(uint32_t a) { - return __builtin_riscv_cv_simd_extract_h(a, 5); +uint32_t test_extract_h0(uint32_t a) { + return __builtin_riscv_cv_simd_extract_h(a, 0); } -// CHECK-LABEL: @test_extract_h_negative( +// CHECK-LABEL: @test_extract_h1( // CHECK-NEXT: entry: // CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 // CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 -// CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.cv.simd.extract.h(i32 [[TMP0]], i32 224) +// CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.cv.simd.extract.h(i32 [[TMP0]], i32 1) // CHECK-NEXT: ret i32 [[TMP1]] // -uint32_t test_extract_h_negative(uint32_t a) { - return __builtin_riscv_cv_simd_extract_h(a, -32); +uint32_t test_extract_h1(uint32_t a) { + return __builtin_riscv_cv_simd_extract_h(a, 1); } -// CHECK-LABEL: @test_extract_b( +// CHECK-LABEL: @test_extract_b0( // CHECK-NEXT: entry: // CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 // CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 -// CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.cv.simd.extract.b(i32 [[TMP0]], i32 5) +// CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.cv.simd.extract.b(i32 [[TMP0]], i32 0) // CHECK-NEXT: ret i32 [[TMP1]] // -uint32_t test_extract_b(uint32_t a) { - return __builtin_riscv_cv_simd_extract_b(a, 5); +uint32_t test_extract_b0(uint32_t a) { + return __builtin_riscv_cv_simd_extract_b(a, 0); } -// CHECK-LABEL: @test_extract_b_negative( +// CHECK-LABEL: @test_extract_b1( // CHECK-NEXT: entry: // CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 // CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 -// CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.cv.simd.extract.b(i32 [[TMP0]], i32 224) +// CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.cv.simd.extract.b(i32 [[TMP0]], i32 1) // CHECK-NEXT: ret i32 [[TMP1]] // -uint32_t test_extract_b_negative(uint32_t a) { - return __builtin_riscv_cv_simd_extract_b(a, -32); +uint32_t test_extract_b1(uint32_t a) { + return __builtin_riscv_cv_simd_extract_b(a, 1); } -// CHECK-LABEL: @test_extractu_h( +// CHECK-LABEL: @test_extract_b2( // CHECK-NEXT: entry: // CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 // CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 -// CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.cv.simd.extractu.h(i32 [[TMP0]], i32 5) +// CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.cv.simd.extract.b(i32 [[TMP0]], i32 2) // CHECK-NEXT: ret i32 [[TMP1]] // -uint32_t test_extractu_h(uint32_t a) { - return __builtin_riscv_cv_simd_extractu_h(a, 5); +uint32_t test_extract_b2(uint32_t a) { + return __builtin_riscv_cv_simd_extract_b(a, 2); } -// CHECK-LABEL: @test_extractu_h_negative( +// CHECK-LABEL: @test_extract_b3( // CHECK-NEXT: entry: // CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 // CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 -// CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.cv.simd.extractu.h(i32 [[TMP0]], i32 224) +// CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.cv.simd.extract.b(i32 [[TMP0]], i32 3) // CHECK-NEXT: ret i32 [[TMP1]] // -uint32_t test_extractu_h_negative(uint32_t a) { - return __builtin_riscv_cv_simd_extractu_h(a, -32); +uint32_t test_extract_b3(uint32_t a) { + return __builtin_riscv_cv_simd_extract_b(a, 3); } -// CHECK-LABEL: @test_extractu_b( +// CHECK-LABEL: @test_extractu_h0( // CHECK-NEXT: entry: // CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 // CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 -// CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.cv.simd.extractu.b(i32 [[TMP0]], i32 5) +// CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.cv.simd.extractu.h(i32 [[TMP0]], i32 0) // CHECK-NEXT: ret i32 [[TMP1]] // -uint32_t test_extractu_b(uint32_t a) { - return __builtin_riscv_cv_simd_extractu_b(a, 5); +uint32_t test_extractu_h0(uint32_t a) { + return __builtin_riscv_cv_simd_extractu_h(a, 0); } -// CHECK-LABEL: @test_extractu_b_negative( +// CHECK-LABEL: @test_extractu_h1( // CHECK-NEXT: entry: // CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 // CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 -// CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.cv.simd.extractu.b(i32 [[TMP0]], i32 224) +// CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.cv.simd.extractu.h(i32 [[TMP0]], i32 1) // CHECK-NEXT: ret i32 [[TMP1]] // -uint32_t test_extractu_b_negative(uint32_t a) { - return __builtin_riscv_cv_simd_extractu_b(a, -32); +uint32_t test_extractu_h1(uint32_t a) { + return __builtin_riscv_cv_simd_extractu_h(a, 1); +} + +// CHECK-LABEL: @test_extractu_b0( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.cv.simd.extractu.b(i32 [[TMP0]], i32 0) +// CHECK-NEXT: ret i32 [[TMP1]] +// +uint32_t test_extractu_b0(uint32_t a) { + return __builtin_riscv_cv_simd_extractu_b(a, 0); +} + +// CHECK-LABEL: @test_extractu_b1( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.cv.simd.extractu.b(i32 [[TMP0]], i32 1) +// CHECK-NEXT: ret i32 [[TMP1]] +// +uint32_t test_extractu_b1(uint32_t a) { + return __builtin_riscv_cv_simd_extractu_b(a, 1); +} + +// CHECK-LABEL: @test_extractu_b2( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.cv.simd.extractu.b(i32 [[TMP0]], i32 2) +// CHECK-NEXT: ret i32 [[TMP1]] +// +uint32_t test_extractu_b2(uint32_t a) { + return __builtin_riscv_cv_simd_extractu_b(a, 2); +} + +// CHECK-LABEL: @test_extractu_b3( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4 +// CHECK-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4 +// CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.cv.simd.extractu.b(i32 [[TMP0]], i32 3) +// CHECK-NEXT: ret i32 [[TMP1]] +// +uint32_t test_extractu_b3(uint32_t a) { + return __builtin_riscv_cv_simd_extractu_b(a, 3); } // CHECK-LABEL: @test_shuffle_h(