Date: Sat, 31 Jan 2015 19:29:00 +0000 (UTC) From: Dimitry Andric <dim@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r277994 - in vendor/clang/dist: docs include/clang/Basic include/clang/Driver include/clang/Sema lib/Basic lib/CodeGen lib/Driver lib/Sema lib/Tooling test/CodeGen test/CodeGenCXX test/... Message-ID: <201501311929.t0VJT0dO048628@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dim Date: Sat Jan 31 19:28:59 2015 New Revision: 277994 URL: https://svnweb.freebsd.org/changeset/base/277994 Log: Vendor import of clang RELEASE_360/rc2 tag r227651 (effectively, 3.6.0 RC2): https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_360/rc2@227651 Added: vendor/clang/dist/test/Driver/aarch64-fixed-x18.c (contents, props changed) vendor/clang/dist/test/Modules/Inputs/System/usr/include/malloc.h (contents, props changed) vendor/clang/dist/test/Modules/Inputs/System/usr/include/stdlib.h (contents, props changed) Deleted: vendor/clang/dist/test/Sema/attr-flag-enum.c vendor/clang/dist/test/SemaCXX/attr-flag-enum-reject.cpp Modified: vendor/clang/dist/docs/ReleaseNotes.rst vendor/clang/dist/include/clang/Basic/Attr.td vendor/clang/dist/include/clang/Basic/AttrDocs.td vendor/clang/dist/include/clang/Basic/DiagnosticGroups.td vendor/clang/dist/include/clang/Basic/DiagnosticSemaKinds.td vendor/clang/dist/include/clang/Driver/Options.td vendor/clang/dist/include/clang/Sema/AttributeList.h vendor/clang/dist/include/clang/Sema/Sema.h vendor/clang/dist/include/clang/Sema/SemaInternal.h vendor/clang/dist/lib/Basic/Targets.cpp vendor/clang/dist/lib/CodeGen/CGDecl.cpp vendor/clang/dist/lib/CodeGen/CGDeclCXX.cpp vendor/clang/dist/lib/CodeGen/CodeGenModule.cpp vendor/clang/dist/lib/CodeGen/ItaniumCXXABI.cpp vendor/clang/dist/lib/CodeGen/MicrosoftCXXABI.cpp vendor/clang/dist/lib/Driver/Tools.cpp vendor/clang/dist/lib/Driver/Tools.h vendor/clang/dist/lib/Sema/SemaChecking.cpp vendor/clang/dist/lib/Sema/SemaDecl.cpp vendor/clang/dist/lib/Sema/SemaDeclAttr.cpp vendor/clang/dist/lib/Sema/SemaExpr.cpp vendor/clang/dist/lib/Sema/SemaExprCXX.cpp vendor/clang/dist/lib/Sema/SemaLookup.cpp vendor/clang/dist/lib/Sema/SemaStmt.cpp vendor/clang/dist/lib/Sema/SemaStmtAsm.cpp vendor/clang/dist/lib/Tooling/ArgumentsAdjusters.cpp vendor/clang/dist/test/CodeGen/ms-declspecs.c vendor/clang/dist/test/CodeGenCXX/cxx11-exception-spec.cpp vendor/clang/dist/test/CodeGenCXX/dllexport-members.cpp vendor/clang/dist/test/CodeGenCXX/dllexport.cpp vendor/clang/dist/test/CodeGenCXX/dllimport.cpp vendor/clang/dist/test/CodeGenCXX/microsoft-abi-virtual-member-pointers.cpp vendor/clang/dist/test/CodeGenCXX/ms-integer-static-data-members-exported.cpp vendor/clang/dist/test/CodeGenCXX/ms-integer-static-data-members.cpp vendor/clang/dist/test/CodeGenCXX/split-stacks.cpp vendor/clang/dist/test/CodeGenCXX/static-init.cpp vendor/clang/dist/test/Driver/linux-ld.c vendor/clang/dist/test/Driver/netbsd.c vendor/clang/dist/test/FixIt/typo-location-bugs.cpp vendor/clang/dist/test/Modules/compiler_builtins.m vendor/clang/dist/test/Preprocessor/init.c vendor/clang/dist/test/Preprocessor/stdint.c vendor/clang/dist/test/Sema/atomic-ops.c vendor/clang/dist/test/Sema/inline-asm-validate-x86.c vendor/clang/dist/test/Sema/typo-correction.c vendor/clang/dist/test/SemaCXX/typo-correction-delayed.cpp vendor/clang/dist/utils/TableGen/ClangAttrEmitter.cpp Modified: vendor/clang/dist/docs/ReleaseNotes.rst ============================================================================== --- vendor/clang/dist/docs/ReleaseNotes.rst Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/docs/ReleaseNotes.rst Sat Jan 31 19:28:59 2015 (r277994) @@ -12,7 +12,7 @@ Written by the `LLVM Team <http://llvm.o These are in-progress notes for the upcoming Clang 3.6 release. You may prefer the `Clang 3.5 Release Notes - <http://llvm.org/releases/3.5/tools/clang/docs/ReleaseNotes.html>`_. + <http://llvm.org/releases/3.5.0/tools/clang/docs/ReleaseNotes.html>`_. Introduction ============ @@ -53,9 +53,11 @@ Major New Features __has_declspec_attribute, this allows for more precise coverage of attribute syntax querying. +- clang-format now supports formatting Java code. + Improvements to Clang's diagnostics -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +----------------------------------- Clang's diagnostics are constantly being improved to catch more issues, explain them more clearly, and provide more accurate source information @@ -68,6 +70,21 @@ New Compiler Flags The option .... +The __EXCEPTIONS macro +---------------------- +``__EXCEPTIONS`` is now defined when landing pads are emitted, not when c++ exceptions are enabled. The two can be different in Objective-C files: If C++ exceptions are disabled but Objective-C exceptions are enabled, landing pads will be emitted. Clang 3.6 is switching the behavior of ``__EXCEPTIONS``. Clang 3.5 confusingly changed the behavior of ``has_feature(cxx_exceptions)``, which used to be set if landing pads were emitted, but is now set if C++ exceptions are enabled. So there are 3 cases: + +Clang before 3.5: + ``__EXCEPTIONS`` is set if C++ exceptions are enabled, ``cxx_exceptions`` enabled if C++ or ObjC exceptions are enabled + +Clang 3.5: + ``__EXCEPTIONS`` is set if C++ exceptions are enabled, ``cxx_exceptions`` enabled if C++ exceptions are enabled + +Clang 3.6: + ``__EXCEPTIONS`` is set if C++ or ObjC exceptions are enabled, ``cxx_exceptions`` enabled if C++ exceptions are enabled + +To reliably test if C++ exceptions are enabled, use ``__EXCEPTIONS && __has_feature(cxx_exceptions)``, else things won't work in all versions of clang in Objective-C++ files. + New Pragmas in Clang ----------------------- @@ -77,7 +94,9 @@ Clang now supports the ... Windows Support --------------- -Clang's support for building native Windows programs ... +- Many, many bug fixes + +- Basic support for DWARF debug information in COFF files C Language Changes in Clang @@ -93,7 +112,11 @@ C11 Feature Support C++ Language Changes in Clang ----------------------------- -- ... +- Clang now supports putting identical constructors and destructors in + the C5/D5 comdat, reducing code duplication. + +- Clang will put individual ``.init_array/.ctors`` sections in + comdats, reducing code duplication and speeding up startup. C++11 Feature Support ^^^^^^^^^^^^^^^^^^^^^ Modified: vendor/clang/dist/include/clang/Basic/Attr.td ============================================================================== --- vendor/clang/dist/include/clang/Basic/Attr.td Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/include/clang/Basic/Attr.td Sat Jan 31 19:28:59 2015 (r277994) @@ -224,14 +224,12 @@ class SubjectList<list<AttrSubject> subj string CustomDiag = customDiag; } -class LangOpt<string name, bit negated = 0> { +class LangOpt<string name> { string Name = name; - bit Negated = negated; } def MicrosoftExt : LangOpt<"MicrosoftExt">; def Borland : LangOpt<"Borland">; def CUDA : LangOpt<"CUDA">; -def COnly : LangOpt<"CPlusPlus", 1>; // Defines targets for target-specific attributes. The list of strings should // specify architectures for which the target applies, based off the ArchType @@ -709,25 +707,6 @@ def MinSize : InheritableAttr { let Documentation = [Undocumented]; } -def FlagEnum : InheritableAttr { - let Spellings = [GNU<"flag_enum">]; - let Subjects = SubjectList<[Enum]>; - let Documentation = [FlagEnumDocs]; - let LangOpts = [COnly]; - let AdditionalMembers = [{ -private: - llvm::APInt FlagBits; -public: - llvm::APInt &getFlagBits() { - return FlagBits; - } - - const llvm::APInt &getFlagBits() const { - return FlagBits; - } -}]; -} - def Flatten : InheritableAttr { let Spellings = [GCC<"flatten">]; let Subjects = SubjectList<[Function], ErrorDiag>; Modified: vendor/clang/dist/include/clang/Basic/AttrDocs.td ============================================================================== --- vendor/clang/dist/include/clang/Basic/AttrDocs.td Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/include/clang/Basic/AttrDocs.td Sat Jan 31 19:28:59 2015 (r277994) @@ -1196,16 +1196,6 @@ behavior of the program is undefined. }]; } -def FlagEnumDocs : Documentation { - let Category = DocCatType; - let Content = [{ -This attribute can be added to an enumerator to signal to the compiler that it -is intended to be used as a flag type. This will cause the compiler to assume -that the range of the type includes all of the values that you can get by -manipulating bits of the enumerator when issuing warnings. - }]; -} - def MSInheritanceDocs : Documentation { let Category = DocCatType; let Heading = "__single_inhertiance, __multiple_inheritance, __virtual_inheritance"; Modified: vendor/clang/dist/include/clang/Basic/DiagnosticGroups.td ============================================================================== --- vendor/clang/dist/include/clang/Basic/DiagnosticGroups.td Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/include/clang/Basic/DiagnosticGroups.td Sat Jan 31 19:28:59 2015 (r277994) @@ -190,7 +190,6 @@ def OverloadedShiftOpParentheses: DiagGr def DanglingElse: DiagGroup<"dangling-else">; def DanglingField : DiagGroup<"dangling-field">; def DistributedObjectModifiers : DiagGroup<"distributed-object-modifiers">; -def FlagEnum : DiagGroup<"flag-enum">; def InfiniteRecursion : DiagGroup<"infinite-recursion">; def GNUImaginaryConstant : DiagGroup<"gnu-imaginary-constant">; def IgnoredQualifiers : DiagGroup<"ignored-qualifiers">; Modified: vendor/clang/dist/include/clang/Basic/DiagnosticSemaKinds.td ============================================================================== --- vendor/clang/dist/include/clang/Basic/DiagnosticSemaKinds.td Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/include/clang/Basic/DiagnosticSemaKinds.td Sat Jan 31 19:28:59 2015 (r277994) @@ -2236,7 +2236,7 @@ def warn_attribute_wrong_decl_type : War "%0 attribute only applies to %select{functions|unions|" "variables and functions|functions and methods|parameters|" "functions, methods and blocks|functions, methods, and classes|" - "functions, methods, and parameters|classes|enums|variables|methods|" + "functions, methods, and parameters|classes|variables|methods|" "variables, functions and labels|fields and global variables|structs|" "variables and typedefs|thread-local variables|" "variables and fields|variables, data members and tag types|" @@ -4059,9 +4059,6 @@ def ext_enum_too_large : ExtWarn< def ext_enumerator_increment_too_large : ExtWarn< "incremented enumerator value %0 is not representable in the " "largest integer type">, InGroup<EnumTooLarge>; -def warn_flag_enum_constant_out_of_range : Warning< - "enumeration value %0 is out of range of flags in enumeration type %1">, - InGroup<FlagEnum>; def warn_illegal_constant_array_size : Extension< "size of static array must be an integer constant expression">; @@ -6162,6 +6159,8 @@ let CategoryName = "Inline Assembly Issu "invalid lvalue in asm input for constraint '%0'">; def err_asm_invalid_input_constraint : Error< "invalid input constraint '%0' in asm">; + def err_asm_immediate_expected : Error<"constraint '%0' expects " + "an integer constant expression">; def err_asm_invalid_type_in_input : Error< "invalid type %0 in asm input for constraint '%1'">; def err_asm_tying_incompatible_types : Error< Modified: vendor/clang/dist/include/clang/Driver/Options.td ============================================================================== --- vendor/clang/dist/include/clang/Driver/Options.td Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/include/clang/Driver/Options.td Sat Jan 31 19:28:59 2015 (r277994) @@ -1209,6 +1209,8 @@ def mfix_cortex_a53_835769 : Flag<["-"], def mno_fix_cortex_a53_835769 : Flag<["-"], "mno-fix-cortex-a53-835769">, Group<m_aarch64_Features_Group>, HelpText<"Don't workaround Cortex-A53 erratum 835769 (AArch64 only)">; +def ffixed_x18 : Flag<["-"], "ffixed-x18">, Group<m_aarch64_Features_Group>, + HelpText<"Reserve the x18 register (AArch64 only)">; def mvsx : Flag<["-"], "mvsx">, Group<m_ppc_Features_Group>; def mno_vsx : Flag<["-"], "mno-vsx">, Group<m_ppc_Features_Group>; Modified: vendor/clang/dist/include/clang/Sema/AttributeList.h ============================================================================== --- vendor/clang/dist/include/clang/Sema/AttributeList.h Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/include/clang/Sema/AttributeList.h Sat Jan 31 19:28:59 2015 (r277994) @@ -822,7 +822,6 @@ enum AttributeDeclKind { ExpectedFunctionMethodOrClass, ExpectedFunctionMethodOrParameter, ExpectedClass, - ExpectedEnum, ExpectedVariable, ExpectedMethod, ExpectedVariableFunctionOrLabel, Modified: vendor/clang/dist/include/clang/Sema/Sema.h ============================================================================== --- vendor/clang/dist/include/clang/Sema/Sema.h Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/include/clang/Sema/Sema.h Sat Jan 31 19:28:59 2015 (r277994) @@ -7971,12 +7971,6 @@ public: Expr *SrcExpr, AssignmentAction Action, bool *Complained = nullptr); - /// IsValueInFlagEnum - Determine if a value is allowed as part of a flag - /// enum. If AllowMask is true, then we also allow the complement of a valid - /// value, to be used as a mask. - bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val, - bool AllowMask) const; - /// DiagnoseAssignmentEnum - Warn if assignment to enum is a constant /// integer not in the range of enum values. void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType, Modified: vendor/clang/dist/include/clang/Sema/SemaInternal.h ============================================================================== --- vendor/clang/dist/include/clang/Sema/SemaInternal.h Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/include/clang/Sema/SemaInternal.h Sat Jan 31 19:28:59 2015 (r277994) @@ -101,7 +101,7 @@ public: DeclContext *MemberContext, bool EnteringContext) : Typo(TypoName.getName().getAsIdentifierInfo()), CurrentTCIndex(0), - SemaRef(SemaRef), S(S), + SavedTCIndex(0), SemaRef(SemaRef), S(S), SS(SS ? llvm::make_unique<CXXScopeSpec>(*SS) : nullptr), CorrectionValidator(std::move(CCC)), MemberContext(MemberContext), Result(SemaRef, TypoName, LookupKind), @@ -187,6 +187,17 @@ public: CurrentTCIndex >= ValidatedCorrections.size(); } + /// \brief Save the current position in the correction stream (overwriting any + /// previously saved position). + void saveCurrentPosition() { + SavedTCIndex = CurrentTCIndex; + } + + /// \brief Restore the saved position in the correction stream. + void restoreSavedPosition() { + CurrentTCIndex = SavedTCIndex; + } + ASTContext &getContext() const { return SemaRef.Context; } const LookupResult &getLookupResult() const { return Result; } @@ -267,6 +278,7 @@ private: SmallVector<TypoCorrection, 4> ValidatedCorrections; size_t CurrentTCIndex; + size_t SavedTCIndex; Sema &SemaRef; Scope *S; Modified: vendor/clang/dist/lib/Basic/Targets.cpp ============================================================================== --- vendor/clang/dist/lib/Basic/Targets.cpp Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/lib/Basic/Targets.cpp Sat Jan 31 19:28:59 2015 (r277994) @@ -5901,6 +5901,8 @@ public: : MipsTargetInfoBase(Triple, "o32", "mips32r2") { SizeType = UnsignedInt; PtrDiffType = SignedInt; + Int64Type = SignedLongLong; + IntMaxType = Int64Type; MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32; } bool setABI(const std::string &Name) override { @@ -5922,6 +5924,8 @@ public: Builder.defineMacro("__mips_isa_rev", "1"); else if (CPUStr == "mips32r2") Builder.defineMacro("__mips_isa_rev", "2"); + else if (CPUStr == "mips32r6") + Builder.defineMacro("__mips_isa_rev", "6"); if (ABI == "o32") { Builder.defineMacro("__mips_o32"); @@ -6028,6 +6032,8 @@ public: PointerWidth = PointerAlign = 64; SizeType = UnsignedLong; PtrDiffType = SignedLong; + Int64Type = SignedLong; + IntMaxType = Int64Type; } void setN32ABITypes() { @@ -6035,6 +6041,8 @@ public: PointerWidth = PointerAlign = 32; SizeType = UnsignedInt; PtrDiffType = SignedInt; + Int64Type = SignedLongLong; + IntMaxType = Int64Type; } bool setABI(const std::string &Name) override { @@ -6065,6 +6073,8 @@ public: Builder.defineMacro("__mips_isa_rev", "1"); else if (CPUStr == "mips64r2") Builder.defineMacro("__mips_isa_rev", "2"); + else if (CPUStr == "mips64r6") + Builder.defineMacro("__mips_isa_rev", "6"); if (ABI == "n32") { Builder.defineMacro("__mips_n32"); Modified: vendor/clang/dist/lib/CodeGen/CGDecl.cpp ============================================================================== --- vendor/clang/dist/lib/CodeGen/CGDecl.cpp Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/lib/CodeGen/CGDecl.cpp Sat Jan 31 19:28:59 2015 (r277994) @@ -206,9 +206,6 @@ llvm::Constant *CodeGenModule::getOrCrea GV->setAlignment(getContext().getDeclAlign(&D).getQuantity()); setGlobalVisibility(GV, &D); - if (supportsCOMDAT() && GV->isWeakForLinker()) - GV->setComdat(TheModule.getOrInsertComdat(GV->getName())); - if (D.getTLSKind()) setTLSMode(GV, D); Modified: vendor/clang/dist/lib/CodeGen/CGDeclCXX.cpp ============================================================================== --- vendor/clang/dist/lib/CodeGen/CGDeclCXX.cpp Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/lib/CodeGen/CGDeclCXX.cpp Sat Jan 31 19:28:59 2015 (r277994) @@ -267,7 +267,15 @@ void CodeGenModule::EmitPointerToInitFun addUsedGlobal(PtrArray); // If the GV is already in a comdat group, then we have to join it. - if (llvm::Comdat *C = GV->getComdat()) + llvm::Comdat *C = GV->getComdat(); + + // LinkOnce and Weak linkage are lowered down to a single-member comdat group. + // Make an explicit group so we can join it. + if (!C && (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage())) { + C = TheModule.getOrInsertComdat(GV->getName()); + GV->setComdat(C); + } + if (C) PtrArray->setComdat(C); } Modified: vendor/clang/dist/lib/CodeGen/CodeGenModule.cpp ============================================================================== --- vendor/clang/dist/lib/CodeGen/CodeGenModule.cpp Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/lib/CodeGen/CodeGenModule.cpp Sat Jan 31 19:28:59 2015 (r277994) @@ -1928,31 +1928,6 @@ void CodeGenModule::MaybeHandleStaticInE R.first->second = nullptr; } -static bool shouldBeInCOMDAT(CodeGenModule &CGM, const Decl &D) { - if (!CGM.supportsCOMDAT()) - return false; - - if (D.hasAttr<SelectAnyAttr>()) - return true; - - GVALinkage Linkage; - if (auto *VD = dyn_cast<VarDecl>(&D)) - Linkage = CGM.getContext().GetGVALinkageForVariable(VD); - else - Linkage = CGM.getContext().GetGVALinkageForFunction(cast<FunctionDecl>(&D)); - - switch (Linkage) { - case GVA_Internal: - case GVA_AvailableExternally: - case GVA_StrongExternal: - return false; - case GVA_DiscardableODR: - case GVA_StrongODR: - return true; - } - llvm_unreachable("No such linkage"); -} - void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) { llvm::Constant *Init = nullptr; QualType ASTTy = D->getType(); @@ -2096,9 +2071,6 @@ void CodeGenModule::EmitGlobalVarDefinit setTLSMode(GV, *D); } - if (shouldBeInCOMDAT(*this, *D)) - GV->setComdat(TheModule.getOrInsertComdat(GV->getName())); - // Emit the initializer function if necessary. if (NeedsGlobalCtor || NeedsGlobalDtor) EmitCXXGlobalVarDeclInitFunc(D, GV, NeedsGlobalCtor); @@ -2433,9 +2405,6 @@ void CodeGenModule::EmitGlobalFunctionDe MaybeHandleStaticInExternC(D, Fn); - if (shouldBeInCOMDAT(*this, *D)) - Fn->setComdat(TheModule.getOrInsertComdat(Fn->getName())); - CodeGenFunction(*this).GenerateCode(D, Fn, FI); setFunctionDefinitionAttributes(D, Fn); Modified: vendor/clang/dist/lib/CodeGen/ItaniumCXXABI.cpp ============================================================================== --- vendor/clang/dist/lib/CodeGen/ItaniumCXXABI.cpp Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/lib/CodeGen/ItaniumCXXABI.cpp Sat Jan 31 19:28:59 2015 (r277994) @@ -1711,12 +1711,11 @@ void ItaniumCXXABI::EmitGuardedInit(Code // The ABI says: It is suggested that it be emitted in the same COMDAT group // as the associated data object - llvm::Comdat *C = var->getComdat(); - if (!D.isLocalVarDecl() && C) { + if (!D.isLocalVarDecl() && var->isWeakForLinker() && CGM.supportsCOMDAT()) { + llvm::Comdat *C = CGM.getModule().getOrInsertComdat(var->getName()); guard->setComdat(C); + var->setComdat(C); CGF.CurFn->setComdat(C); - } else if (CGM.supportsCOMDAT() && guard->isWeakForLinker()) { - guard->setComdat(CGM.getModule().getOrInsertComdat(guard->getName())); } CGM.setStaticLocalDeclGuardAddress(&D, guard); Modified: vendor/clang/dist/lib/CodeGen/MicrosoftCXXABI.cpp ============================================================================== --- vendor/clang/dist/lib/CodeGen/MicrosoftCXXABI.cpp Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/lib/CodeGen/MicrosoftCXXABI.cpp Sat Jan 31 19:28:59 2015 (r277994) @@ -1534,6 +1534,12 @@ llvm::Function *MicrosoftCXXABI::EmitVir CGM.SetLLVMFunctionAttributes(MD, FnInfo, ThunkFn); CGM.SetLLVMFunctionAttributesForDefinition(MD, ThunkFn); + // Add the "thunk" attribute so that LLVM knows that the return type is + // meaningless. These thunks can be used to call functions with differing + // return types, and the caller is required to cast the prototype + // appropriately to extract the correct value. + ThunkFn->addFnAttr("thunk"); + // These thunks can be compared, so they are not unnamed. ThunkFn->setUnnamedAddr(false); @@ -1829,10 +1835,18 @@ void MicrosoftCXXABI::EmitThreadLocalIni llvm::Function *F = CXXThreadLocalInits[I]; // If the GV is already in a comdat group, then we have to join it. - if (llvm::Comdat *C = GV->getComdat()) + llvm::Comdat *C = GV->getComdat(); + + // LinkOnce and Weak linkage are lowered down to a single-member comdat + // group. + // Make an explicit group so we can join it. + if (!C && (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage())) { + C = CGM.getModule().getOrInsertComdat(GV->getName()); + GV->setComdat(C); AddToXDU(F)->setComdat(C); - else + } else { NonComdatInits.push_back(F); + } } if (!NonComdatInits.empty()) { Modified: vendor/clang/dist/lib/Driver/Tools.cpp ============================================================================== --- vendor/clang/dist/lib/Driver/Tools.cpp Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/lib/Driver/Tools.cpp Sat Jan 31 19:28:59 2015 (r277994) @@ -958,6 +958,11 @@ void Clang::AddAArch64TargetArgs(const A if (A->getOption().matches(options::OPT_mno_global_merge)) CmdArgs.push_back("-mno-global-merge"); } + + if (Args.hasArg(options::OPT_ffixed_x18)) { + CmdArgs.push_back("-backend-option"); + CmdArgs.push_back("-aarch64-reserve-x18"); + } } // Get CPU and ABI names. They are not independent @@ -5418,6 +5423,20 @@ const char *arm::getLLVMArchSuffixForARM .Default(""); } +void arm::appendEBLinkFlags(const ArgList &Args, ArgStringList &CmdArgs, const llvm::Triple &Triple) { + if (Args.hasArg(options::OPT_r)) + return; + + StringRef Suffix = getLLVMArchSuffixForARM(getARMCPUForMArch(Args, Triple)); + const char *LinkFlag = llvm::StringSwitch<const char *>(Suffix) + .Cases("v4", "v4t", "v5", "v5e", nullptr) + .Cases("v6", "v6t2", nullptr) + .Default("--be8"); + + if (LinkFlag) + CmdArgs.push_back(LinkFlag); +} + bool mips::hasMipsAbiArg(const ArgList &Args, const char *Value) { Arg *A = Args.getLastArg(options::OPT_mabi_EQ); return A && (A->getValue() == StringRef(Value)); @@ -6881,6 +6900,7 @@ void netbsd::Link::ConstructJob(Compilat break; case llvm::Triple::armeb: case llvm::Triple::thumbeb: + arm::appendEBLinkFlags(Args, CmdArgs, getToolChain().getTriple()); CmdArgs.push_back("-m"); switch (getToolChain().getTriple().getEnvironment()) { case llvm::Triple::EABI: @@ -7431,6 +7451,10 @@ void gnutools::Link::ConstructJob(Compil if (Args.hasArg(options::OPT_s)) CmdArgs.push_back("-s"); + if (ToolChain.getArch() == llvm::Triple::armeb || + ToolChain.getArch() == llvm::Triple::thumbeb) + arm::appendEBLinkFlags(Args, CmdArgs, getToolChain().getTriple()); + for (const auto &Opt : ToolChain.ExtraOpts) CmdArgs.push_back(Opt.c_str()); Modified: vendor/clang/dist/lib/Driver/Tools.h ============================================================================== --- vendor/clang/dist/lib/Driver/Tools.h Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/lib/Driver/Tools.h Sat Jan 31 19:28:59 2015 (r277994) @@ -228,6 +228,8 @@ namespace arm { const char* getARMCPUForMArch(const llvm::opt::ArgList &Args, const llvm::Triple &Triple); const char* getLLVMArchSuffixForARM(StringRef CPU); + + void appendEBLinkFlags(const llvm::opt::ArgList &Args, ArgStringList &CmdArgs, const llvm::Triple &Triple); } namespace mips { Modified: vendor/clang/dist/lib/Sema/SemaChecking.cpp ============================================================================== --- vendor/clang/dist/lib/Sema/SemaChecking.cpp Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/lib/Sema/SemaChecking.cpp Sat Jan 31 19:28:59 2015 (r277994) @@ -1340,6 +1340,11 @@ ExprResult Sema::SemaAtomicOpsOverloaded << IsC11 << Ptr->getType() << Ptr->getSourceRange(); return ExprError(); } + if (IsC11 && ValType->isPointerType() && + RequireCompleteType(Ptr->getLocStart(), ValType->getPointeeType(), + diag::err_incomplete_type)) { + return ExprError(); + } } else if (IsN && !ValType->isIntegerType() && !ValType->isPointerType()) { // For __atomic_*_n operations, the value type must be a scalar integral or // pointer type which is 1, 2, 4, 8 or 16 bytes in length. Modified: vendor/clang/dist/lib/Sema/SemaDecl.cpp ============================================================================== --- vendor/clang/dist/lib/Sema/SemaDecl.cpp Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/lib/Sema/SemaDecl.cpp Sat Jan 31 19:28:59 2015 (r277994) @@ -8828,11 +8828,12 @@ void Sema::AddInitializerToDecl(Decl *Re }); if (Res.isInvalid()) { VDecl->setInvalidDecl(); - return; - } - if (Res.get() != Args[Idx]) + } else if (Res.get() != Args[Idx]) { Args[Idx] = Res.get(); + } } + if (VDecl->isInvalidDecl()) + return; InitializationSequence InitSeq(*this, Entity, Kind, Args); ExprResult Result = InitSeq.Perform(*this, Entity, Kind, Args, &DclT); @@ -13519,49 +13520,6 @@ static void CheckForDuplicateEnumValues( } } -bool -Sema::IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val, - bool AllowMask) const { - FlagEnumAttr *FEAttr = ED->getAttr<FlagEnumAttr>(); - assert(FEAttr && "looking for value in non-flag enum"); - - llvm::APInt FlagMask = ~FEAttr->getFlagBits(); - unsigned Width = FlagMask.getBitWidth(); - - // We will try a zero-extended value for the regular check first. - llvm::APInt ExtVal = Val.zextOrSelf(Width); - - // A value is in a flag enum if either its bits are a subset of the enum's - // flag bits (the first condition) or we are allowing masks and the same is - // true of its complement (the second condition). When masks are allowed, we - // allow the common idiom of ~(enum1 | enum2) to be a valid enum value. - // - // While it's true that any value could be used as a mask, the assumption is - // that a mask will have all of the insignificant bits set. Anything else is - // likely a logic error. - if (!(FlagMask & ExtVal)) - return true; - - if (AllowMask) { - // Try a one-extended value instead. This can happen if the enum is wider - // than the constant used, in C with extensions to allow for wider enums. - // The mask will still have the correct behaviour, so we give the user the - // benefit of the doubt. - // - // FIXME: This heuristic can cause weird results if the enum was extended - // to a larger type and is signed, because then bit-masks of smaller types - // that get extended will fall out of range (e.g. ~0x1u). We currently don't - // detect that case and will get a false positive for it. In most cases, - // though, it can be fixed by making it a signed type (e.g. ~0x1), so it may - // be fine just to accept this as a warning. - ExtVal |= llvm::APInt::getHighBitsSet(Width, Width - Val.getBitWidth()); - if (!(FlagMask & ~ExtVal)) - return true; - } - - return false; -} - void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc, SourceLocation RBraceLoc, Decl *EnumDeclX, ArrayRef<Decl *> Elements, @@ -13647,8 +13605,10 @@ void Sema::ActOnEnumBody(SourceLocation BestPromotionType = Context.getPromotedIntegerType(BestType); else BestPromotionType = BestType; - - BestWidth = Context.getIntWidth(BestType); + // We don't need to set BestWidth, because BestType is going to be the type + // of the enumerators, but we do anyway because otherwise some compilers + // warn that it might be used uninitialized. + BestWidth = CharWidth; } else if (NumNegativeBits) { // If there is a negative value, figure out the smallest integer type (of @@ -13713,15 +13673,10 @@ void Sema::ActOnEnumBody(SourceLocation } } - FlagEnumAttr *FEAttr = Enum->getAttr<FlagEnumAttr>(); - if (FEAttr) - FEAttr->getFlagBits() = llvm::APInt(BestWidth, 0); - // Loop over all of the enumerator constants, changing their types to match - // the type of the enum if needed. If we have a flag type, we also prepare the - // FlagBits cache. - for (auto *D : Elements) { - auto *ECD = cast_or_null<EnumConstantDecl>(D); + // the type of the enum if needed. + for (unsigned i = 0, e = Elements.size(); i != e; ++i) { + EnumConstantDecl *ECD = cast_or_null<EnumConstantDecl>(Elements[i]); if (!ECD) continue; // Already issued a diagnostic. // Standard C says the enumerators have int type, but we allow, as an @@ -13751,7 +13706,7 @@ void Sema::ActOnEnumBody(SourceLocation // enum-specifier, each enumerator has the type of its // enumeration. ECD->setType(EnumType); - goto flagbits; + continue; } else { NewTy = BestType; NewWidth = BestWidth; @@ -13778,32 +13733,8 @@ void Sema::ActOnEnumBody(SourceLocation ECD->setType(EnumType); else ECD->setType(NewTy); - -flagbits: - // Check to see if we have a constant with exactly one bit set. Note that x - // & (x - 1) will be nonzero if and only if x has more than one bit set. - if (FEAttr) { - llvm::APInt ExtVal = InitVal.zextOrSelf(BestWidth); - if (ExtVal != 0 && !(ExtVal & (ExtVal - 1))) { - FEAttr->getFlagBits() |= ExtVal; - } - } - } - - if (FEAttr) { - for (Decl *D : Elements) { - EnumConstantDecl *ECD = cast_or_null<EnumConstantDecl>(D); - if (!ECD) continue; // Already issued a diagnostic. - - llvm::APSInt InitVal = ECD->getInitVal(); - if (InitVal != 0 && !IsValueInFlagEnum(Enum, InitVal, true)) - Diag(ECD->getLocation(), diag::warn_flag_enum_constant_out_of_range) - << ECD << Enum; - } } - - Enum->completeDefinition(BestType, BestPromotionType, NumPositiveBits, NumNegativeBits); Modified: vendor/clang/dist/lib/Sema/SemaDeclAttr.cpp ============================================================================== --- vendor/clang/dist/lib/Sema/SemaDeclAttr.cpp Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/lib/Sema/SemaDeclAttr.cpp Sat Jan 31 19:28:59 2015 (r277994) @@ -4395,9 +4395,6 @@ static void ProcessDeclAttribute(Sema &S case AttributeList::AT_OptimizeNone: handleOptimizeNoneAttr(S, D, Attr); break; - case AttributeList::AT_FlagEnum: - handleSimpleAttribute<FlagEnumAttr>(S, D, Attr); - break; case AttributeList::AT_Flatten: handleSimpleAttribute<FlattenAttr>(S, D, Attr); break; Modified: vendor/clang/dist/lib/Sema/SemaExpr.cpp ============================================================================== --- vendor/clang/dist/lib/Sema/SemaExpr.cpp Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/lib/Sema/SemaExpr.cpp Sat Jan 31 19:28:59 2015 (r277994) @@ -4762,12 +4762,8 @@ Sema::BuildResolvedCallExpr(Expr *Fn, Na VK_RValue, RParenLoc); // Bail out early if calling a builtin with custom typechecking. - if (BuiltinID && Context.BuiltinInfo.hasCustomTypechecking(BuiltinID)) { - ExprResult Res = CorrectDelayedTyposInExpr(TheCall); - if (!Res.isUsable() || !isa<CallExpr>(Res.get())) - return Res; - return CheckBuiltinFunctionCall(FDecl, BuiltinID, cast<CallExpr>(Res.get())); - } + if (BuiltinID && Context.BuiltinInfo.hasCustomTypechecking(BuiltinID)) + return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall); retry: const FunctionType *FuncT; @@ -5785,15 +5781,6 @@ QualType Sema::CheckConditionalOperands( ExprObjectKind &OK, SourceLocation QuestionLoc) { - if (!getLangOpts().CPlusPlus) { - // C cannot handle TypoExpr nodes on either side of a binop because it - // doesn't handle dependent types properly, so make sure any TypoExprs have - // been dealt with before checking the operands. - ExprResult CondResult = CorrectDelayedTyposInExpr(Cond); - if (!CondResult.isUsable()) return QualType(); - Cond = CondResult; - } - ExprResult LHSResult = CheckPlaceholderExpr(LHS.get()); if (!LHSResult.isUsable()) return QualType(); LHS = LHSResult; @@ -6173,6 +6160,15 @@ ExprResult Sema::ActOnConditionalOp(Sour SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr) { + if (!getLangOpts().CPlusPlus) { + // C cannot handle TypoExpr nodes in the condition because it + // doesn't handle dependent types properly, so make sure any TypoExprs have + // been dealt with before checking the operands. + ExprResult CondResult = CorrectDelayedTyposInExpr(CondExpr); + if (!CondResult.isUsable()) return ExprError(); + CondExpr = CondResult.get(); + } + // If this is the gnu "x ?: y" extension, analyze the types as though the LHS // was the condition. OpaqueValueExpr *opaqueValue = nullptr; @@ -9457,6 +9453,18 @@ static void checkObjCPointerIntrospectio } } +static NamedDecl *getDeclFromExpr(Expr *E) { + if (!E) + return nullptr; + if (auto *DRE = dyn_cast<DeclRefExpr>(E)) + return DRE->getDecl(); + if (auto *ME = dyn_cast<MemberExpr>(E)) + return ME->getMemberDecl(); + if (auto *IRE = dyn_cast<ObjCIvarRefExpr>(E)) + return IRE->getDecl(); + return nullptr; +} + /// CreateBuiltinBinOp - Creates a new built-in binary operation with /// operator @p Opc at location @c TokLoc. This routine only supports /// built-in operations; ActOnBinOp handles overloaded operators. @@ -9494,7 +9502,13 @@ ExprResult Sema::CreateBuiltinBinOp(Sour // doesn't handle dependent types properly, so make sure any TypoExprs have // been dealt with before checking the operands. LHS = CorrectDelayedTyposInExpr(LHSExpr); - RHS = CorrectDelayedTyposInExpr(RHSExpr); + RHS = CorrectDelayedTyposInExpr(RHSExpr, [Opc, LHS](Expr *E) { + if (Opc != BO_Assign) + return ExprResult(E); + // Avoid correcting the RHS to the same Expr as the LHS. + Decl *D = getDeclFromExpr(E); + return (D && D == getDeclFromExpr(LHS.get())) ? ExprError() : E; + }); if (!LHS.isUsable() || !RHS.isUsable()) return ExprError(); } Modified: vendor/clang/dist/lib/Sema/SemaExprCXX.cpp ============================================================================== --- vendor/clang/dist/lib/Sema/SemaExprCXX.cpp Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/lib/Sema/SemaExprCXX.cpp Sat Jan 31 19:28:59 2015 (r277994) @@ -6143,12 +6143,6 @@ public: ExprResult TransformLambdaExpr(LambdaExpr *E) { return Owned(E); } - ExprResult TransformOpaqueValueExpr(OpaqueValueExpr *E) { - if (Expr *SE = E->getSourceExpr()) - return TransformExpr(SE); - return BaseTransform::TransformOpaqueValueExpr(E); - } - ExprResult Transform(Expr *E) { ExprResult Res; while (true) { @@ -6168,15 +6162,18 @@ public: while (!AmbiguousTypoExprs.empty()) { auto TE = AmbiguousTypoExprs.back(); auto Cached = TransformCache[TE]; - AmbiguousTypoExprs.pop_back(); + auto &State = SemaRef.getTypoExprState(TE); + State.Consumer->saveCurrentPosition(); TransformCache.erase(TE); if (!TryTransform(E).isInvalid()) { - SemaRef.getTypoExprState(TE).Consumer->resetCorrectionStream(); + State.Consumer->resetCorrectionStream(); TransformCache.erase(TE); Res = ExprError(); break; - } else - TransformCache[TE] = Cached; + } + AmbiguousTypoExprs.remove(TE); + State.Consumer->restoreSavedPosition(); + TransformCache[TE] = Cached; } // Ensure that all of the TypoExprs within the current Expr have been found. @@ -6235,8 +6232,12 @@ ExprResult Sema::CorrectDelayedTyposInEx if (E && !ExprEvalContexts.empty() && ExprEvalContexts.back().NumTypos && (E->isTypeDependent() || E->isValueDependent() || E->isInstantiationDependent())) { + auto TyposInContext = ExprEvalContexts.back().NumTypos; + assert(TyposInContext < ~0U && "Recursive call of CorrectDelayedTyposInExpr"); + ExprEvalContexts.back().NumTypos = ~0U; auto TyposResolved = DelayedTypos.size(); auto Result = TransformTypos(*this, Filter).Transform(E); + ExprEvalContexts.back().NumTypos = TyposInContext; TyposResolved -= DelayedTypos.size(); if (Result.isInvalid() || Result.get() != E) { ExprEvalContexts.back().NumTypos -= TyposResolved; Modified: vendor/clang/dist/lib/Sema/SemaLookup.cpp ============================================================================== --- vendor/clang/dist/lib/Sema/SemaLookup.cpp Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/lib/Sema/SemaLookup.cpp Sat Jan 31 19:28:59 2015 (r277994) @@ -3587,7 +3587,7 @@ retry_lookup: QualifiedResults.push_back(Candidate); break; } - Candidate.setCorrectionRange(TempSS, Result.getLookupNameInfo()); + Candidate.setCorrectionRange(SS.get(), Result.getLookupNameInfo()); return true; } return false; Modified: vendor/clang/dist/lib/Sema/SemaStmt.cpp ============================================================================== --- vendor/clang/dist/lib/Sema/SemaStmt.cpp Sat Jan 31 19:28:41 2015 (r277993) +++ vendor/clang/dist/lib/Sema/SemaStmt.cpp Sat Jan 31 19:28:59 2015 (r277994) @@ -687,39 +687,26 @@ static void checkCaseValue(Sema &S, Sour } } -typedef SmallVector<std::pair<llvm::APSInt, EnumConstantDecl*>, 64> EnumValsTy; - /// Returns true if we should emit a diagnostic about this case expression not /// being a part of the enum used in the switch controlling expression. -static bool ShouldDiagnoseSwitchCaseNotInEnum(const Sema &S, +static bool ShouldDiagnoseSwitchCaseNotInEnum(const ASTContext &Ctx, const EnumDecl *ED, - const Expr *CaseExpr, - EnumValsTy::iterator &EI, - EnumValsTy::iterator &EIEnd, - const llvm::APSInt &Val) { - bool FlagType = ED->hasAttr<FlagEnumAttr>(); - - if (const DeclRefExpr *DRE = - dyn_cast<DeclRefExpr>(CaseExpr->IgnoreParenImpCasts())) { + const Expr *CaseExpr) { + // Don't warn if the 'case' expression refers to a static const variable of + // the enum type. + CaseExpr = CaseExpr->IgnoreParenImpCasts(); + if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CaseExpr)) { if (const VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl())) { + if (!VD->hasGlobalStorage()) + return true; QualType VarType = VD->getType(); - QualType EnumType = S.Context.getTypeDeclType(ED); - if (VD->hasGlobalStorage() && VarType.isConstQualified() && - S.Context.hasSameUnqualifiedType(EnumType, VarType)) + if (!VarType.isConstQualified()) + return true; + QualType EnumType = Ctx.getTypeDeclType(ED); + if (Ctx.hasSameUnqualifiedType(EnumType, VarType)) return false; } } - - if (FlagType) { - return !S.IsValueInFlagEnum(ED, Val, false); - } else { - while (EI != EIEnd && EI->first < Val) - EI++; - - if (EI != EIEnd && EI->first == Val) - return false; - } - return true; } @@ -1059,6 +1046,8 @@ Sema::ActOnFinishSwitchStmt(SourceLocati // If switch has default case, then ignore it. if (!CaseListIsErroneous && !HasConstantCond && ET) { const EnumDecl *ED = ET->getDecl(); + typedef SmallVector<std::pair<llvm::APSInt, EnumConstantDecl*>, 64> + EnumValsTy; EnumValsTy EnumVals; // Gather all enum values, set their type and sort them, @@ -1069,48 +1058,57 @@ Sema::ActOnFinishSwitchStmt(SourceLocati EnumVals.push_back(std::make_pair(Val, EDI)); } std::stable_sort(EnumVals.begin(), EnumVals.end(), CmpEnumVals); - auto EI = EnumVals.begin(), EIEnd = + EnumValsTy::iterator EIend = std::unique(EnumVals.begin(), EnumVals.end(), EqEnumVals); // See which case values aren't in enum. + EnumValsTy::const_iterator EI = EnumVals.begin(); for (CaseValsTy::const_iterator CI = CaseVals.begin(); - CI != CaseVals.end(); CI++) { - Expr *CaseExpr = CI->second->getLHS(); - if (ShouldDiagnoseSwitchCaseNotInEnum(*this, ED, CaseExpr, EI, EIEnd, - CI->first)) - Diag(CaseExpr->getExprLoc(), diag::warn_not_in_enum) - << CondTypeBeforePromotion; + CI != CaseVals.end(); CI++) { + while (EI != EIend && EI->first < CI->first) + EI++; + if (EI == EIend || EI->first > CI->first) { + Expr *CaseExpr = CI->second->getLHS(); + if (ShouldDiagnoseSwitchCaseNotInEnum(Context, ED, CaseExpr)) + Diag(CaseExpr->getExprLoc(), diag::warn_not_in_enum) + << CondTypeBeforePromotion; + } } - // See which of case ranges aren't in enum EI = EnumVals.begin(); for (CaseRangesTy::const_iterator RI = CaseRanges.begin(); - RI != CaseRanges.end(); RI++) { - Expr *CaseExpr = RI->second->getLHS(); - if (ShouldDiagnoseSwitchCaseNotInEnum(*this, ED, CaseExpr, EI, EIEnd, - RI->first)) - Diag(CaseExpr->getExprLoc(), diag::warn_not_in_enum) - << CondTypeBeforePromotion; + RI != CaseRanges.end() && EI != EIend; RI++) { + while (EI != EIend && EI->first < RI->first) + EI++; + + if (EI == EIend || EI->first != RI->first) { + Expr *CaseExpr = RI->second->getLHS(); + if (ShouldDiagnoseSwitchCaseNotInEnum(Context, ED, CaseExpr)) + Diag(CaseExpr->getExprLoc(), diag::warn_not_in_enum) + << CondTypeBeforePromotion; + } llvm::APSInt Hi = RI->second->getRHS()->EvaluateKnownConstInt(Context); AdjustAPSInt(Hi, CondWidth, CondIsSigned); - - CaseExpr = RI->second->getRHS(); - if (ShouldDiagnoseSwitchCaseNotInEnum(*this, ED, CaseExpr, EI, EIEnd, - Hi)) - Diag(CaseExpr->getExprLoc(), diag::warn_not_in_enum) - << CondTypeBeforePromotion; + while (EI != EIend && EI->first < Hi) + EI++; + if (EI == EIend || EI->first != Hi) { + Expr *CaseExpr = RI->second->getRHS(); + if (ShouldDiagnoseSwitchCaseNotInEnum(Context, ED, CaseExpr)) + Diag(CaseExpr->getExprLoc(), diag::warn_not_in_enum) + << CondTypeBeforePromotion; + } } // Check which enum vals aren't in switch - auto CI = CaseVals.begin(); - auto RI = CaseRanges.begin(); + CaseValsTy::const_iterator CI = CaseVals.begin(); + CaseRangesTy::const_iterator RI = CaseRanges.begin(); bool hasCasesNotInSwitch = false; SmallVector<DeclarationName,8> UnhandledNames; - for (EI = EnumVals.begin(); EI != EIEnd; EI++){ + for (EI = EnumVals.begin(); EI != EIend; EI++){ // Drop unneeded case values while (CI != CaseVals.end() && CI->first < EI->first) CI++; @@ -1197,37 +1195,30 @@ Sema::DiagnoseAssignmentEnum(QualType Ds llvm::APSInt RhsVal = SrcExpr->EvaluateKnownConstInt(Context); AdjustAPSInt(RhsVal, DstWidth, DstIsSigned); const EnumDecl *ED = ET->getDecl(); - - if (ED->hasAttr<FlagEnumAttr>()) { - if (!IsValueInFlagEnum(ED, RhsVal, true)) - Diag(SrcExpr->getExprLoc(), diag::warn_not_in_enum_assignment) + typedef SmallVector<std::pair<llvm::APSInt, EnumConstantDecl *>, 64> + EnumValsTy; + EnumValsTy EnumVals; + + // Gather all enum values, set their type and sort them, + // allowing easier comparison with rhs constant. + for (auto *EDI : ED->enumerators()) { + llvm::APSInt Val = EDI->getInitVal(); + AdjustAPSInt(Val, DstWidth, DstIsSigned); + EnumVals.push_back(std::make_pair(Val, EDI)); + } + if (EnumVals.empty()) + return; + std::stable_sort(EnumVals.begin(), EnumVals.end(), CmpEnumVals); + EnumValsTy::iterator EIend = + std::unique(EnumVals.begin(), EnumVals.end(), EqEnumVals); + + // See which values aren't in the enum. + EnumValsTy::const_iterator EI = EnumVals.begin(); + while (EI != EIend && EI->first < RhsVal) + EI++; + if (EI == EIend || EI->first != RhsVal) { + Diag(SrcExpr->getExprLoc(), diag::warn_not_in_enum_assignment) << DstType.getUnqualifiedType(); - } else { - typedef SmallVector<std::pair<llvm::APSInt, EnumConstantDecl *>, 64> - EnumValsTy; - EnumValsTy EnumVals; - - // Gather all enum values, set their type and sort them, - // allowing easier comparison with rhs constant. - for (auto *EDI : ED->enumerators()) { - llvm::APSInt Val = EDI->getInitVal(); - AdjustAPSInt(Val, DstWidth, DstIsSigned); - EnumVals.push_back(std::make_pair(Val, EDI)); - } - if (EnumVals.empty()) - return; *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201501311929.t0VJT0dO048628>