From owner-svn-src-vendor@freebsd.org Wed May 3 20:26:26 2017 Return-Path: Delivered-To: svn-src-vendor@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 08AADD5C657; Wed, 3 May 2017 20:26:26 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B31A21B23; Wed, 3 May 2017 20:26:25 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v43KQOVR048784; Wed, 3 May 2017 20:26:24 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v43KQNrW048771; Wed, 3 May 2017 20:26:23 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201705032026.v43KQNrW048771@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Wed, 3 May 2017 20:26:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r317762 - in vendor/clang/dist: docs include/clang/Basic include/clang/Sema include/clang/StaticAnalyzer/Core/BugReporter lib/AST lib/Basic lib/CodeGen lib/Driver lib/Parse lib/Sema lib... X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 May 2017 20:26:26 -0000 Author: dim Date: Wed May 3 20:26:23 2017 New Revision: 317762 URL: https://svnweb.freebsd.org/changeset/base/317762 Log: Vendor import of clang trunk r302069: https://llvm.org/svn/llvm-project/cfe/trunk@302069 Added: vendor/clang/dist/test/CodeGen/PR32874.c (contents, props changed) Deleted: vendor/clang/dist/test/SemaCXX/constexpr-array-unknown-bound.cpp Modified: vendor/clang/dist/docs/UndefinedBehaviorSanitizer.rst vendor/clang/dist/include/clang/Basic/Diagnostic.h vendor/clang/dist/include/clang/Basic/DiagnosticASTKinds.td vendor/clang/dist/include/clang/Basic/DiagnosticIDs.h vendor/clang/dist/include/clang/Basic/DiagnosticSemaKinds.td vendor/clang/dist/include/clang/Basic/DiagnosticSerializationKinds.td vendor/clang/dist/include/clang/Sema/Sema.h vendor/clang/dist/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h vendor/clang/dist/lib/AST/ExprConstant.cpp vendor/clang/dist/lib/AST/ODRHash.cpp vendor/clang/dist/lib/Basic/Diagnostic.cpp vendor/clang/dist/lib/Basic/DiagnosticIDs.cpp vendor/clang/dist/lib/CodeGen/CGCall.cpp vendor/clang/dist/lib/CodeGen/CGExprScalar.cpp vendor/clang/dist/lib/CodeGen/CGObjCGNU.cpp vendor/clang/dist/lib/CodeGen/CodeGenModule.cpp vendor/clang/dist/lib/CodeGen/TargetInfo.cpp vendor/clang/dist/lib/Driver/SanitizerArgs.cpp vendor/clang/dist/lib/Parse/ParseOpenMP.cpp vendor/clang/dist/lib/Sema/SemaChecking.cpp vendor/clang/dist/lib/Sema/SemaDecl.cpp vendor/clang/dist/lib/Sema/SemaExpr.cpp vendor/clang/dist/lib/Sema/SemaExprCXX.cpp vendor/clang/dist/lib/Serialization/ASTReader.cpp vendor/clang/dist/lib/Serialization/ASTWriter.cpp vendor/clang/dist/lib/StaticAnalyzer/Checkers/MallocChecker.cpp vendor/clang/dist/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp vendor/clang/dist/lib/StaticAnalyzer/Checkers/ValistChecker.cpp vendor/clang/dist/lib/StaticAnalyzer/Core/CommonBugCategories.cpp vendor/clang/dist/test/Analysis/MismatchedDeallocator-path-notes.cpp vendor/clang/dist/test/Analysis/NewDelete-path-notes.cpp vendor/clang/dist/test/Analysis/diagnostics/report-issues-within-main-file.cpp vendor/clang/dist/test/Analysis/edges-new.mm vendor/clang/dist/test/Analysis/malloc-plist.c vendor/clang/dist/test/Analysis/plist-macros.cpp vendor/clang/dist/test/CodeGen/aarch64-neon-2velem.c vendor/clang/dist/test/CodeGen/aarch64-neon-intrinsics.c vendor/clang/dist/test/CodeGen/aarch64-neon-misc.c vendor/clang/dist/test/CodeGen/aarch64-neon-scalar-x-indexed-elem.c vendor/clang/dist/test/CodeGen/arm_neon_intrinsics.c vendor/clang/dist/test/CodeGen/libcalls.c vendor/clang/dist/test/Driver/arch-specific-libdir-rpath.c vendor/clang/dist/test/Driver/fsanitize-coverage.c vendor/clang/dist/test/Index/keep-going.cpp vendor/clang/dist/test/Modules/diag-flags.cpp vendor/clang/dist/test/Modules/odr_hash.cpp vendor/clang/dist/test/OpenMP/target_ast_print.cpp vendor/clang/dist/test/OpenMP/target_map_messages.cpp vendor/clang/dist/test/Sema/varargs.c vendor/clang/dist/test/SemaCXX/cxx1z-lambda-star-this.cpp vendor/clang/dist/test/SemaCXX/warn-thread-safety-parsing.cpp vendor/clang/dist/test/SemaObjCXX/arc-overloading.mm vendor/clang/dist/tools/libclang/CIndex.cpp vendor/clang/dist/unittests/Basic/DiagnosticTest.cpp Modified: vendor/clang/dist/docs/UndefinedBehaviorSanitizer.rst ============================================================================== --- vendor/clang/dist/docs/UndefinedBehaviorSanitizer.rst Wed May 3 20:26:18 2017 (r317761) +++ vendor/clang/dist/docs/UndefinedBehaviorSanitizer.rst Wed May 3 20:26:23 2017 (r317762) @@ -157,8 +157,6 @@ will need to: ``UBSAN_OPTIONS=print_stacktrace=1``. #. Make sure ``llvm-symbolizer`` binary is in ``PATH``. -Stacktrace printing for UBSan issues is currently not supported on Darwin. - Issue Suppression ================= Modified: vendor/clang/dist/include/clang/Basic/Diagnostic.h ============================================================================== --- vendor/clang/dist/include/clang/Basic/Diagnostic.h Wed May 3 20:26:18 2017 (r317761) +++ vendor/clang/dist/include/clang/Basic/Diagnostic.h Wed May 3 20:26:23 2017 (r317762) @@ -178,12 +178,7 @@ public: private: unsigned char AllExtensionsSilenced; // Used by __extension__ - bool IgnoreAllWarnings; // Ignore all warnings: -w - bool WarningsAsErrors; // Treat warnings like errors. - bool EnableAllWarnings; // Enable all warnings. - bool ErrorsAsFatal; // Treat errors like fatal errors. - bool FatalsAsError; // Treat fatal errors like errors. - bool SuppressSystemWarnings; // Suppress warnings in system headers. + bool SuppressAfterFatalError; // Suppress diagnostics after a fatal error? bool SuppressAllDiagnostics; // Suppress all diagnostics. bool ElideType; // Elide common types of templates. bool PrintTemplateTree; // Print a tree when comparing templates. @@ -194,7 +189,6 @@ private: // 0 -> no limit. unsigned ConstexprBacktraceLimit; // Cap on depth of constexpr evaluation // backtrace stack, 0 -> no limit. - diag::Severity ExtBehavior; // Map extensions to warnings or errors? IntrusiveRefCntPtr Diags; IntrusiveRefCntPtr DiagOpts; DiagnosticConsumer *Client; @@ -216,6 +210,19 @@ private: llvm::DenseMap DiagMap; public: + // "Global" configuration state that can actually vary between modules. + unsigned IgnoreAllWarnings : 1; // Ignore all warnings: -w + unsigned EnableAllWarnings : 1; // Enable all warnings. + unsigned WarningsAsErrors : 1; // Treat warnings like errors. + unsigned ErrorsAsFatal : 1; // Treat errors like fatal errors. + unsigned SuppressSystemWarnings : 1; // Suppress warnings in system headers. + diag::Severity ExtBehavior; // Map extensions to warnings or errors? + + DiagState() + : IgnoreAllWarnings(false), EnableAllWarnings(false), + WarningsAsErrors(false), ErrorsAsFatal(false), + SuppressSystemWarnings(false), ExtBehavior(diag::Severity::Ignored) {} + typedef llvm::DenseMap::iterator iterator; typedef llvm::DenseMap::const_iterator const_iterator; @@ -493,33 +500,47 @@ public: /// \brief When set to true, any unmapped warnings are ignored. /// /// If this and WarningsAsErrors are both set, then this one wins. - void setIgnoreAllWarnings(bool Val) { IgnoreAllWarnings = Val; } - bool getIgnoreAllWarnings() const { return IgnoreAllWarnings; } + void setIgnoreAllWarnings(bool Val) { + GetCurDiagState()->IgnoreAllWarnings = Val; + } + bool getIgnoreAllWarnings() const { + return GetCurDiagState()->IgnoreAllWarnings; + } /// \brief When set to true, any unmapped ignored warnings are no longer /// ignored. /// /// If this and IgnoreAllWarnings are both set, then that one wins. - void setEnableAllWarnings(bool Val) { EnableAllWarnings = Val; } - bool getEnableAllWarnings() const { return EnableAllWarnings; } + void setEnableAllWarnings(bool Val) { + GetCurDiagState()->EnableAllWarnings = Val; + } + bool getEnableAllWarnings() const { + return GetCurDiagState()->EnableAllWarnings; + } /// \brief When set to true, any warnings reported are issued as errors. - void setWarningsAsErrors(bool Val) { WarningsAsErrors = Val; } - bool getWarningsAsErrors() const { return WarningsAsErrors; } + void setWarningsAsErrors(bool Val) { + GetCurDiagState()->WarningsAsErrors = Val; + } + bool getWarningsAsErrors() const { + return GetCurDiagState()->WarningsAsErrors; + } /// \brief When set to true, any error reported is made a fatal error. - void setErrorsAsFatal(bool Val) { ErrorsAsFatal = Val; } - bool getErrorsAsFatal() const { return ErrorsAsFatal; } + void setErrorsAsFatal(bool Val) { GetCurDiagState()->ErrorsAsFatal = Val; } + bool getErrorsAsFatal() const { return GetCurDiagState()->ErrorsAsFatal; } - /// \brief When set to true, any fatal error reported is made an error. - /// - /// This setting takes precedence over the setErrorsAsFatal setting above. - void setFatalsAsError(bool Val) { FatalsAsError = Val; } - bool getFatalsAsError() const { return FatalsAsError; } + /// \brief When set to true (the default), suppress further diagnostics after + /// a fatal error. + void setSuppressAfterFatalError(bool Val) { SuppressAfterFatalError = Val; } /// \brief When set to true mask warnings that come from system headers. - void setSuppressSystemWarnings(bool Val) { SuppressSystemWarnings = Val; } - bool getSuppressSystemWarnings() const { return SuppressSystemWarnings; } + void setSuppressSystemWarnings(bool Val) { + GetCurDiagState()->SuppressSystemWarnings = Val; + } + bool getSuppressSystemWarnings() const { + return GetCurDiagState()->SuppressSystemWarnings; + } /// \brief Suppress all diagnostics, to silence the front end when we /// know that we don't want any more diagnostics to be passed along to the @@ -571,11 +592,15 @@ public: } /// \brief Controls whether otherwise-unmapped extension diagnostics are - /// mapped onto ignore/warning/error. + /// mapped onto ignore/warning/error. /// /// This corresponds to the GCC -pedantic and -pedantic-errors option. - void setExtensionHandlingBehavior(diag::Severity H) { ExtBehavior = H; } - diag::Severity getExtensionHandlingBehavior() const { return ExtBehavior; } + void setExtensionHandlingBehavior(diag::Severity H) { + GetCurDiagState()->ExtBehavior = H; + } + diag::Severity getExtensionHandlingBehavior() const { + return GetCurDiagState()->ExtBehavior; + } /// \brief Counter bumped when an __extension__ block is/ encountered. /// Modified: vendor/clang/dist/include/clang/Basic/DiagnosticASTKinds.td ============================================================================== --- vendor/clang/dist/include/clang/Basic/DiagnosticASTKinds.td Wed May 3 20:26:18 2017 (r317761) +++ vendor/clang/dist/include/clang/Basic/DiagnosticASTKinds.td Wed May 3 20:26:23 2017 (r317762) @@ -154,14 +154,12 @@ def note_constexpr_baa_insufficient_alig def note_constexpr_baa_value_insufficient_alignment : Note< "value of the aligned pointer (%0) is not a multiple of the asserted %1 " "%plural{1:byte|:bytes}1">; -def note_constexpr_array_unknown_bound_arithmetic : Note< - "cannot perform pointer arithmetic on pointer to array without constant bound">; def warn_integer_constant_overflow : Warning< "overflow in expression; result is %0 with type %1">, InGroup>; -// This is a temporary diagnostic, and shall be removed once our +// This is a temporary diagnostic, and shall be removed once our // implementation is complete, and like the preceding constexpr notes belongs // in Sema. def note_unimplemented_constexpr_lambda_feature_ast : Note< Modified: vendor/clang/dist/include/clang/Basic/DiagnosticIDs.h ============================================================================== --- vendor/clang/dist/include/clang/Basic/DiagnosticIDs.h Wed May 3 20:26:18 2017 (r317761) +++ vendor/clang/dist/include/clang/Basic/DiagnosticIDs.h Wed May 3 20:26:23 2017 (r317762) @@ -122,15 +122,21 @@ public: bool wasUpgradedFromWarning() const { return WasUpgradedFromWarning; } void setUpgradedFromWarning(bool Value) { WasUpgradedFromWarning = Value; } - /// Serialize the bits that aren't based on context. - unsigned serializeBits() const { - return (WasUpgradedFromWarning << 3) | Severity; + /// Serialize this mapping as a raw integer. + unsigned serialize() const { + return (IsUser << 7) | (IsPragma << 6) | (HasNoWarningAsError << 5) | + (HasNoErrorAsFatal << 4) | (WasUpgradedFromWarning << 3) | Severity; } - static diag::Severity deserializeSeverity(unsigned Bits) { - return (diag::Severity)(Bits & 0x7); - } - static bool deserializeUpgradedFromWarning(unsigned Bits) { - return Bits >> 3; + /// Deserialize a mapping. + static DiagnosticMapping deserialize(unsigned Bits) { + DiagnosticMapping Result; + Result.IsUser = (Bits >> 7) & 1; + Result.IsPragma = (Bits >> 6) & 1; + Result.HasNoWarningAsError = (Bits >> 5) & 1; + Result.HasNoErrorAsFatal = (Bits >> 4) & 1; + Result.WasUpgradedFromWarning = (Bits >> 3) & 1; + Result.Severity = Bits & 0x7; + return Result; } }; Modified: vendor/clang/dist/include/clang/Basic/DiagnosticSemaKinds.td ============================================================================== --- vendor/clang/dist/include/clang/Basic/DiagnosticSemaKinds.td Wed May 3 20:26:18 2017 (r317761) +++ vendor/clang/dist/include/clang/Basic/DiagnosticSemaKinds.td Wed May 3 20:26:23 2017 (r317762) @@ -2820,9 +2820,6 @@ def warn_cconv_structors : Warning< def err_regparm_mismatch : Error<"function declared with regparm(%0) " "attribute was previously declared " "%plural{0:without the regparm|:with the regparm(%1)}1 attribute">; -def err_returns_retained_mismatch : Error< - "function declared with the ns_returns_retained attribute " - "was previously declared without the ns_returns_retained attribute">; def err_function_attribute_mismatch : Error< "function declared with %0 attribute " "was previously declared without the %0 attribute">; @@ -8048,7 +8045,7 @@ def err_64_bit_builtin_32_bit_tgt : Erro "this builtin is only available on 64-bit targets">; def err_ppc_builtin_only_on_pwr7 : Error< "this builtin is only valid on POWER7 or later CPUs">; -def err_x86_builtin_32_bit_tgt : Error< +def err_x86_builtin_64_only : Error< "this builtin is only available on x86-64 targets">; def err_x86_builtin_invalid_rounding : Error< "invalid rounding argument">; Modified: vendor/clang/dist/include/clang/Basic/DiagnosticSerializationKinds.td ============================================================================== --- vendor/clang/dist/include/clang/Basic/DiagnosticSerializationKinds.td Wed May 3 20:26:18 2017 (r317761) +++ vendor/clang/dist/include/clang/Basic/DiagnosticSerializationKinds.td Wed May 3 20:26:23 2017 (r317762) @@ -146,7 +146,10 @@ def err_module_odr_violation_mismatch_de "method %4 is %select{not static|static}5|" "method %4 is %select{not volatile|volatile}5|" "method %4 is %select{not const|const}5|" - "method %4 is %select{not inline|inline}5}3">; + "method %4 is %select{not inline|inline}5|" + "method %4 that has %5 parameter%s5|" + "method %4 with %ordinal5 parameter of type %6%select{| decayed from %8}7|" + "method %4 with %ordinal5 parameter named %6}3">; def note_module_odr_violation_mismatch_decl_diff : Note<"but in '%0' found " "%select{" @@ -166,7 +169,10 @@ def note_module_odr_violation_mismatch_d "method %2 is %select{not static|static}3|" "method %2 is %select{not volatile|volatile}3|" "method %2 is %select{not const|const}3|" - "method %2 is %select{not inline|inline}3}1">; + "method %2 is %select{not inline|inline}3|" + "method %2 that has %3 parameter%s3|" + "method %2 with %ordinal3 parameter of type %4%select{| decayed from %6}5|" + "method %2 with %ordinal3 parameter named %4}1">; def warn_module_uses_date_time : Warning< "%select{precompiled header|module}0 uses __DATE__ or __TIME__">, Modified: vendor/clang/dist/include/clang/Sema/Sema.h ============================================================================== --- vendor/clang/dist/include/clang/Sema/Sema.h Wed May 3 20:26:18 2017 (r317761) +++ vendor/clang/dist/include/clang/Sema/Sema.h Wed May 3 20:26:23 2017 (r317762) @@ -10068,9 +10068,7 @@ private: bool CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall); bool CheckPPCBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall); - bool SemaBuiltinVAStartImpl(CallExpr *TheCall); - bool SemaBuiltinVAStart(CallExpr *TheCall); - bool SemaBuiltinMSVAStart(CallExpr *TheCall); + bool SemaBuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall); bool SemaBuiltinVAStartARM(CallExpr *Call); bool SemaBuiltinUnorderedCompare(CallExpr *TheCall); bool SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs); Modified: vendor/clang/dist/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h ============================================================================== --- vendor/clang/dist/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h Wed May 3 20:26:18 2017 (r317761) +++ vendor/clang/dist/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h Wed May 3 20:26:23 2017 (r317762) @@ -17,6 +17,7 @@ namespace clang { extern const char * const CoreFoundationObjectiveC; extern const char * const LogicError; extern const char * const MemoryCoreFoundationObjectiveC; + extern const char * const MemoryError; extern const char * const UnixAPI; } } Modified: vendor/clang/dist/lib/AST/ExprConstant.cpp ============================================================================== --- vendor/clang/dist/lib/AST/ExprConstant.cpp Wed May 3 20:26:18 2017 (r317761) +++ vendor/clang/dist/lib/AST/ExprConstant.cpp Wed May 3 20:26:23 2017 (r317762) @@ -148,8 +148,7 @@ namespace { static unsigned findMostDerivedSubobject(ASTContext &Ctx, APValue::LValueBase Base, ArrayRef Path, - uint64_t &ArraySize, QualType &Type, bool &IsArray, - bool &IsUnsizedArray) { + uint64_t &ArraySize, QualType &Type, bool &IsArray) { // This only accepts LValueBases from APValues, and APValues don't support // arrays that lack size info. assert(!isBaseAnAllocSizeCall(Base) && @@ -158,34 +157,28 @@ namespace { Type = getType(Base); for (unsigned I = 0, N = Path.size(); I != N; ++I) { - if (auto AT = Ctx.getAsArrayType(Type)) { + if (Type->isArrayType()) { + const ConstantArrayType *CAT = + cast(Ctx.getAsArrayType(Type)); + Type = CAT->getElementType(); + ArraySize = CAT->getSize().getZExtValue(); MostDerivedLength = I + 1; IsArray = true; - if (auto CAT = Ctx.getAsConstantArrayType(Type)) - ArraySize = CAT->getSize().getZExtValue(); - else { - ArraySize = 0; - IsUnsizedArray = true; - } - Type = AT->getElementType(); } else if (Type->isAnyComplexType()) { const ComplexType *CT = Type->castAs(); Type = CT->getElementType(); ArraySize = 2; MostDerivedLength = I + 1; IsArray = true; - IsUnsizedArray = false; } else if (const FieldDecl *FD = getAsField(Path[I])) { Type = FD->getType(); ArraySize = 0; MostDerivedLength = I + 1; IsArray = false; - IsUnsizedArray = false; } else { // Path[I] describes a base class. ArraySize = 0; IsArray = false; - IsUnsizedArray = false; } } return MostDerivedLength; @@ -207,9 +200,8 @@ namespace { /// Is this a pointer one past the end of an object? unsigned IsOnePastTheEnd : 1; - /// Indicator of whether the most-derived object is an unsized array (e.g. - /// of unknown bound). - unsigned MostDerivedIsAnUnsizedArray : 1; + /// Indicator of whether the first entry is an unsized array. + unsigned FirstEntryIsAnUnsizedArray : 1; /// Indicator of whether the most-derived object is an array element. unsigned MostDerivedIsArrayElement : 1; @@ -239,28 +231,25 @@ namespace { explicit SubobjectDesignator(QualType T) : Invalid(false), IsOnePastTheEnd(false), - MostDerivedIsAnUnsizedArray(false), MostDerivedIsArrayElement(false), + FirstEntryIsAnUnsizedArray(false), MostDerivedIsArrayElement(false), MostDerivedPathLength(0), MostDerivedArraySize(0), MostDerivedType(T) {} SubobjectDesignator(ASTContext &Ctx, const APValue &V) : Invalid(!V.isLValue() || !V.hasLValuePath()), IsOnePastTheEnd(false), - MostDerivedIsAnUnsizedArray(false), MostDerivedIsArrayElement(false), + FirstEntryIsAnUnsizedArray(false), MostDerivedIsArrayElement(false), MostDerivedPathLength(0), MostDerivedArraySize(0) { assert(V.isLValue() && "Non-LValue used to make an LValue designator?"); if (!Invalid) { IsOnePastTheEnd = V.isLValueOnePastTheEnd(); ArrayRef VEntries = V.getLValuePath(); Entries.insert(Entries.end(), VEntries.begin(), VEntries.end()); - if (auto Base = V.getLValueBase()) { - if (auto Decl = Base.dyn_cast()) - Base = cast(Decl->getMostRecentDecl()); - bool IsArray = false, IsUnsizedArray = false; + if (V.getLValueBase()) { + bool IsArray = false; MostDerivedPathLength = findMostDerivedSubobject( - Ctx, Base, V.getLValuePath(), MostDerivedArraySize, - MostDerivedType, IsArray, IsUnsizedArray); - MostDerivedIsArrayElement = IsArray; - MostDerivedIsAnUnsizedArray = IsUnsizedArray; + Ctx, V.getLValueBase(), V.getLValuePath(), MostDerivedArraySize, + MostDerivedType, IsArray); + MostDerivedIsArrayElement = IsArray; } } } @@ -274,7 +263,7 @@ namespace { /// known bound. bool isMostDerivedAnUnsizedArray() const { assert(!Invalid && "Calling this makes no sense on invalid designators"); - return MostDerivedIsAnUnsizedArray; + return Entries.size() == 1 && FirstEntryIsAnUnsizedArray; } /// Determine what the most derived array's size is. Results in an assertion @@ -314,7 +303,6 @@ namespace { // This is a most-derived object. MostDerivedType = CAT->getElementType(); MostDerivedIsArrayElement = true; - MostDerivedIsAnUnsizedArray = false; MostDerivedArraySize = CAT->getSize().getZExtValue(); MostDerivedPathLength = Entries.size(); } @@ -327,7 +315,6 @@ namespace { MostDerivedType = ElemTy; MostDerivedIsArrayElement = true; - MostDerivedIsAnUnsizedArray = true; // The value in MostDerivedArraySize is undefined in this case. So, set it // to an arbitrary value that's likely to loudly break things if it's // used. @@ -346,7 +333,6 @@ namespace { if (const FieldDecl *FD = dyn_cast(D)) { MostDerivedType = FD->getType(); MostDerivedIsArrayElement = false; - MostDerivedIsAnUnsizedArray = false; MostDerivedArraySize = 0; MostDerivedPathLength = Entries.size(); } @@ -361,14 +347,53 @@ namespace { // is unlikely to matter. MostDerivedType = EltTy; MostDerivedIsArrayElement = true; - MostDerivedIsAnUnsizedArray = false; MostDerivedArraySize = 2; MostDerivedPathLength = Entries.size(); } void diagnosePointerArithmetic(EvalInfo &Info, const Expr *E, const APSInt &N); /// Add N to the address of this subobject. - void adjustIndex(EvalInfo &Info, const Expr *E, APSInt N); + void adjustIndex(EvalInfo &Info, const Expr *E, APSInt N) { + if (Invalid || !N) return; + uint64_t TruncatedN = N.extOrTrunc(64).getZExtValue(); + if (isMostDerivedAnUnsizedArray()) { + // Can't verify -- trust that the user is doing the right thing (or if + // not, trust that the caller will catch the bad behavior). + // FIXME: Should we reject if this overflows, at least? + Entries.back().ArrayIndex += TruncatedN; + return; + } + + // [expr.add]p4: For the purposes of these operators, a pointer to a + // nonarray object behaves the same as a pointer to the first element of + // an array of length one with the type of the object as its element type. + bool IsArray = MostDerivedPathLength == Entries.size() && + MostDerivedIsArrayElement; + uint64_t ArrayIndex = + IsArray ? Entries.back().ArrayIndex : (uint64_t)IsOnePastTheEnd; + uint64_t ArraySize = + IsArray ? getMostDerivedArraySize() : (uint64_t)1; + + if (N < -(int64_t)ArrayIndex || N > ArraySize - ArrayIndex) { + // Calculate the actual index in a wide enough type, so we can include + // it in the note. + N = N.extend(std::max(N.getBitWidth() + 1, 65)); + (llvm::APInt&)N += ArrayIndex; + assert(N.ugt(ArraySize) && "bounds check failed for in-bounds index"); + diagnosePointerArithmetic(Info, E, N); + setInvalid(); + return; + } + + ArrayIndex += TruncatedN; + assert(ArrayIndex <= ArraySize && + "bounds check succeeded for out-of-bounds index"); + + if (IsArray) + Entries.back().ArrayIndex = ArrayIndex; + else + IsOnePastTheEnd = (ArrayIndex != 0); + } }; /// A stack frame in the constexpr call stack. @@ -470,7 +495,7 @@ namespace { // FIXME: Force the precision of the source value down so we don't // print digits which are usually useless (we don't really care here if // we truncate a digit by accident in edge cases). Ideally, - // APFloat::toString would automatically print the shortest + // APFloat::toString would automatically print the shortest // representation which rounds to the correct value, but it's a bit // tricky to implement. unsigned precision = @@ -695,7 +720,7 @@ namespace { private: OptionalDiagnostic Diag(SourceLocation Loc, diag::kind DiagId, unsigned ExtraNotes, bool IsCCEDiag) { - + if (EvalStatus.Diag) { // If we have a prior diagnostic, it will be noting that the expression // isn't a constant expression. This diagnostic is more important, @@ -748,7 +773,7 @@ namespace { unsigned ExtraNotes = 0) { return Diag(Loc, DiagId, ExtraNotes, false); } - + OptionalDiagnostic FFDiag(const Expr *E, diag::kind DiagId = diag::note_invalid_subexpr_in_const_expr, unsigned ExtraNotes = 0) { @@ -1061,53 +1086,6 @@ void SubobjectDesignator::diagnosePointe setInvalid(); } -void SubobjectDesignator::adjustIndex(EvalInfo &Info, const Expr *E, APSInt N) { - if (Invalid || !N) return; - - uint64_t TruncatedN = N.extOrTrunc(64).getZExtValue(); - if (isMostDerivedAnUnsizedArray()) { - // If we're dealing with an array without constant bound, the expression is - // not a constant expression. - if (!Info.checkingPotentialConstantExpression()) - Info.CCEDiag(E, diag::note_constexpr_array_unknown_bound_arithmetic); - // Can't verify -- trust that the user is doing the right thing (or if - // not, trust that the caller will catch the bad behavior). - // FIXME: Should we reject if this overflows, at least? - Entries.back().ArrayIndex += TruncatedN; - return; - } - - // [expr.add]p4: For the purposes of these operators, a pointer to a - // nonarray object behaves the same as a pointer to the first element of - // an array of length one with the type of the object as its element type. - bool IsArray = MostDerivedPathLength == Entries.size() && - MostDerivedIsArrayElement; - uint64_t ArrayIndex = - IsArray ? Entries.back().ArrayIndex : (uint64_t)IsOnePastTheEnd; - uint64_t ArraySize = - IsArray ? getMostDerivedArraySize() : (uint64_t)1; - - if (N < -(int64_t)ArrayIndex || N > ArraySize - ArrayIndex) { - // Calculate the actual index in a wide enough type, so we can include - // it in the note. - N = N.extend(std::max(N.getBitWidth() + 1, 65)); - (llvm::APInt&)N += ArrayIndex; - assert(N.ugt(ArraySize) && "bounds check failed for in-bounds index"); - diagnosePointerArithmetic(Info, E, N); - setInvalid(); - return; - } - - ArrayIndex += TruncatedN; - assert(ArrayIndex <= ArraySize && - "bounds check succeeded for out-of-bounds index"); - - if (IsArray) - Entries.back().ArrayIndex = ArrayIndex; - else - IsOnePastTheEnd = (ArrayIndex != 0); -} - CallStackFrame::CallStackFrame(EvalInfo &Info, SourceLocation CallLoc, const FunctionDecl *Callee, const LValue *This, APValue *Arguments) @@ -1236,6 +1214,8 @@ namespace { IsNullPtr); else { assert(!InvalidBase && "APValues can't handle invalid LValue bases"); + assert(!Designator.FirstEntryIsAnUnsizedArray && + "Unsized array with a valid base?"); V = APValue(Base, Offset, Designator.Entries, Designator.IsOnePastTheEnd, CallIndex, IsNullPtr); } @@ -1300,9 +1280,12 @@ namespace { if (checkSubobject(Info, E, isa(D) ? CSK_Field : CSK_Base)) Designator.addDeclUnchecked(D, Virtual); } - void addUnsizedArray(EvalInfo &Info, const Expr *E, QualType ElemTy) { - if (checkSubobject(Info, E, CSK_ArrayToPointer)) - Designator.addUnsizedArrayUnchecked(ElemTy); + void addUnsizedArray(EvalInfo &Info, QualType ElemTy) { + assert(Designator.Entries.empty() && getType(Base)->isPointerType()); + assert(isBaseAnAllocSizeCall(Base) && + "Only alloc_size bases can have unsized arrays"); + Designator.FirstEntryIsAnUnsizedArray = true; + Designator.addUnsizedArrayUnchecked(ElemTy); } void addArray(EvalInfo &Info, const Expr *E, const ConstantArrayType *CAT) { if (checkSubobject(Info, E, CSK_ArrayToPointer)) @@ -3033,15 +3016,6 @@ static CompleteObject findCompleteObject if (!evaluateVarDeclInit(Info, E, VD, Frame, BaseVal)) return CompleteObject(); - - // The complete object can be an array of unknown bound, in which case we - // have to find the most recent declaration and adjust the type accordingly. - if (Info.Ctx.getAsIncompleteArrayType(BaseType)) { - QualType MostRecentType = - cast(D->getMostRecentDecl())->getType(); - if (Info.Ctx.getAsConstantArrayType(MostRecentType)) - BaseType = MostRecentType; - } } else { const Expr *Base = LVal.Base.dyn_cast(); @@ -4124,13 +4098,13 @@ static bool CheckConstexprFunction(EvalI if (Info.getLangOpts().CPlusPlus11) { const FunctionDecl *DiagDecl = Definition ? Definition : Declaration; - + // If this function is not constexpr because it is an inherited // non-constexpr constructor, diagnose that directly. auto *CD = dyn_cast(DiagDecl); if (CD && CD->isInheritingConstructor()) { auto *Inherited = CD->getInheritedConstructor().getConstructor(); - if (!Inherited->isConstexpr()) + if (!Inherited->isConstexpr()) DiagDecl = CD = Inherited; } @@ -4667,7 +4641,7 @@ public: return false; This = &ThisVal; Args = Args.slice(1); - } else if (MD && MD->isLambdaStaticInvoker()) { + } else if (MD && MD->isLambdaStaticInvoker()) { // Map the static invoker for the lambda back to the call operator. // Conveniently, we don't have to slice out the 'this' argument (as is // being done for the non-static case), since a static member function @@ -4702,7 +4676,7 @@ public: FD = LambdaCallOp; } - + } else return Error(E); @@ -5462,7 +5436,7 @@ static bool evaluateLValueAsAllocSize(Ev Result.setInvalid(E); QualType Pointee = E->getType()->castAs()->getPointeeType(); - Result.addUnsizedArray(Info, E, Pointee); + Result.addUnsizedArray(Info, Pointee); return true; } @@ -5541,7 +5515,7 @@ public: // Update 'Result' to refer to the data member/field of the closure object // that represents the '*this' capture. if (!HandleLValueMember(Info, E, Result, - Info.CurrentCall->LambdaThisCaptureField)) + Info.CurrentCall->LambdaThisCaptureField)) return false; // If we captured '*this' by reference, replace the field with its referent. if (Info.CurrentCall->LambdaThisCaptureField->getType() @@ -5682,18 +5656,12 @@ bool PointerExprEvaluator::VisitCastExpr Info, Result, SubExpr)) return false; } - // The result is a pointer to the first element of the array. if (const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(SubExpr->getType())) Result.addArray(Info, E, CAT); - // If the array hasn't been given a bound yet, add it as an unsized one. - else { - auto AT = Info.Ctx.getAsArrayType(SubExpr->getType()); - assert(AT && "Array to pointer decay on non-array object?"); - Result.addUnsizedArray(Info, E, AT->getElementType()); - } - + else + Result.Designator.setInvalid(); return true; case CK_FunctionToPointerDecay: @@ -5761,7 +5729,7 @@ bool PointerExprEvaluator::visitNonBuilt Result.setInvalid(E); QualType PointeeTy = E->getType()->castAs()->getPointeeType(); - Result.addUnsizedArray(Info, E, PointeeTy); + Result.addUnsizedArray(Info, PointeeTy); return true; } @@ -6395,7 +6363,7 @@ bool RecordExprEvaluator::VisitLambdaExp if (ClosureClass->isInvalidDecl()) return false; if (Info.checkingPotentialConstantExpression()) return true; - + const size_t NumFields = std::distance(ClosureClass->field_begin(), ClosureClass->field_end()); @@ -6414,7 +6382,7 @@ bool RecordExprEvaluator::VisitLambdaExp assert(CaptureInitIt != E->capture_init_end()); // Get the initializer for this field Expr *const CurFieldInit = *CaptureInitIt++; - + // If there is no initializer, either this is a VLA or an error has // occurred. if (!CurFieldInit) @@ -6615,18 +6583,18 @@ VectorExprEvaluator::VisitInitListExpr(c // The number of initializers can be less than the number of // vector elements. For OpenCL, this can be due to nested vector - // initialization. For GCC compatibility, missing trailing elements + // initialization. For GCC compatibility, missing trailing elements // should be initialized with zeroes. unsigned CountInits = 0, CountElts = 0; while (CountElts < NumElements) { // Handle nested vector initialization. - if (CountInits < NumInits + if (CountInits < NumInits && E->getInit(CountInits)->getType()->isVectorType()) { APValue v; if (!EvaluateVector(E->getInit(CountInits), v, Info)) return Error(E); unsigned vlen = v.getVectorLength(); - for (unsigned j = 0; j < vlen; j++) + for (unsigned j = 0; j < vlen; j++) Elements.push_back(v.getVectorElt(j)); CountElts += vlen; } else if (EltTy->isIntegerType()) { @@ -6902,7 +6870,7 @@ public: } bool Success(const llvm::APInt &I, const Expr *E, APValue &Result) { - assert(E->getType()->isIntegralOrEnumerationType() && + assert(E->getType()->isIntegralOrEnumerationType() && "Invalid evaluation result."); assert(I.getBitWidth() == Info.Ctx.getIntWidth(E->getType()) && "Invalid evaluation result."); @@ -6916,7 +6884,7 @@ public: } bool Success(uint64_t Value, const Expr *E, APValue &Result) { - assert(E->getType()->isIntegralOrEnumerationType() && + assert(E->getType()->isIntegralOrEnumerationType() && "Invalid evaluation result."); Result = APValue(Info.Ctx.MakeIntValue(Value, E->getType())); return true; @@ -6992,7 +6960,7 @@ public: } return Success(Info.ArrayInitIndex, E); } - + // Note, GNU defines __null as an integer, not a pointer. bool VisitGNUNullExpr(const GNUNullExpr *E) { return ZeroInitialization(E); @@ -7356,8 +7324,10 @@ static bool isDesignatorAtObjectEnd(cons unsigned I = 0; QualType BaseType = getType(Base); - // If this is an alloc_size base, we should ignore the initial array index - if (isBaseAnAllocSizeCall(Base)) { + if (LVal.Designator.FirstEntryIsAnUnsizedArray) { + assert(isBaseAnAllocSizeCall(Base) && + "Unsized array in non-alloc_size call?"); + // If this is an alloc_size base, we should ignore the initial array index ++I; BaseType = BaseType->castAs()->getPointeeType(); } @@ -8144,12 +8114,12 @@ bool DataRecursiveIntBinOpEvaluator:: Result = RHSResult.Val; return true; } - + if (E->isLogicalOp()) { bool lhsResult, rhsResult; bool LHSIsOK = HandleConversionToBool(LHSResult.Val, lhsResult); bool RHSIsOK = HandleConversionToBool(RHSResult.Val, rhsResult); - + if (LHSIsOK) { if (RHSIsOK) { if (E->getOpcode() == BO_LOr) @@ -8165,26 +8135,26 @@ bool DataRecursiveIntBinOpEvaluator:: return Success(rhsResult, E, Result); } } - + return false; } - + assert(E->getLHS()->getType()->isIntegralOrEnumerationType() && E->getRHS()->getType()->isIntegralOrEnumerationType()); - + if (LHSResult.Failed || RHSResult.Failed) return false; - + const APValue &LHSVal = LHSResult.Val; const APValue &RHSVal = RHSResult.Val; - + // Handle cases like (unsigned long)&a + 4. if (E->isAdditiveOp() && LHSVal.isLValue() && RHSVal.isInt()) { Result = LHSVal; addOrSubLValueAsInteger(Result, RHSVal.getInt(), E->getOpcode() == BO_Sub); return true; } - + // Handle cases like 4 + (unsigned long)&a if (E->getOpcode() == BO_Add && RHSVal.isLValue() && LHSVal.isInt()) { @@ -8192,7 +8162,7 @@ bool DataRecursiveIntBinOpEvaluator:: addOrSubLValueAsInteger(Result, LHSVal.getInt(), /*IsSub*/false); return true; } - + if (E->getOpcode() == BO_Sub && LHSVal.isLValue() && RHSVal.isLValue()) { // Handle (intptr_t)&&A - (intptr_t)&&B. if (!LHSVal.getLValueOffset().isZero() || @@ -8231,7 +8201,7 @@ bool DataRecursiveIntBinOpEvaluator:: void DataRecursiveIntBinOpEvaluator::process(EvalResult &Result) { Job &job = Queue.back(); - + switch (job.Kind) { case Job::AnyExprKind: { if (const BinaryOperator *Bop = dyn_cast(job.E)) { @@ -8241,12 +8211,12 @@ void DataRecursiveIntBinOpEvaluator::pro return; } } - + EvaluateExpr(job.E, Result); Queue.pop_back(); return; } - + case Job::BinOpKind: { const BinaryOperator *Bop = cast(job.E); bool SuppressRHSDiags = false; @@ -8261,7 +8231,7 @@ void DataRecursiveIntBinOpEvaluator::pro enqueue(Bop->getRHS()); return; } - + case Job::BinOpVisitedLHSKind: { const BinaryOperator *Bop = cast(job.E); EvalResult RHS; @@ -8271,7 +8241,7 @@ void DataRecursiveIntBinOpEvaluator::pro return; } } - + llvm_unreachable("Invalid Job::Kind!"); } @@ -8783,7 +8753,7 @@ bool IntExprEvaluator::VisitOffsetOfExpr const RecordType *BaseRT = CurrentType->getAs(); if (!BaseRT) return Error(OOE); - + // Add the offset to the base. Result += RL.getBaseClassOffset(cast(BaseRT->getDecl())); break; @@ -9978,7 +9948,7 @@ static bool FastEvaluateAsRValue(const E IsConst = false; return true; } - + // FIXME: Evaluating values of large array and record types can cause // performance problems. Only do so in C++11 for now. if (Exp->isRValue() && (Exp->getType()->isArrayType() || @@ -10000,7 +9970,7 @@ bool Expr::EvaluateAsRValue(EvalResult & bool IsConst; if (FastEvaluateAsRValue(this, Result, Ctx, IsConst, false)) return IsConst; - + EvalInfo Info(Ctx, Result, EvalInfo::EM_IgnoreSideEffects); return ::EvaluateAsRValue(Info, this, Result.Val); } Modified: vendor/clang/dist/lib/AST/ODRHash.cpp ============================================================================== --- vendor/clang/dist/lib/AST/ODRHash.cpp Wed May 3 20:26:18 2017 (r317761) +++ vendor/clang/dist/lib/AST/ODRHash.cpp Wed May 3 20:26:23 2017 (r317762) @@ -169,6 +169,11 @@ public: Inherited::VisitValueDecl(D); } + void VisitParmVarDecl(const ParmVarDecl *D) { + // TODO: Handle default arguments. + Inherited::VisitParmVarDecl(D); + } + void VisitAccessSpecDecl(const AccessSpecDecl *D) { ID.AddInteger(D->getAccess()); Inherited::VisitAccessSpecDecl(D); @@ -202,6 +207,12 @@ public: Hash.AddBoolean(D->isPure()); Hash.AddBoolean(D->isDeletedAsWritten()); + ID.AddInteger(D->param_size()); + + for (auto *Param : D->parameters()) { + Hash.AddSubDecl(Param); + } + Inherited::VisitFunctionDecl(D); } @@ -256,6 +267,11 @@ void ODRHash::AddSubDecl(const Decl *D) void ODRHash::AddCXXRecordDecl(const CXXRecordDecl *Record) { assert(Record && Record->hasDefinition() && "Expected non-null record to be a definition."); + + if (isa(Record)) { + return; + } + AddDecl(Record); // Filter out sub-Decls which will not be processed in order to get an @@ -315,6 +331,14 @@ public: } } + void AddQualType(QualType T) { + Hash.AddQualType(T); + } + + void VisitQualifiers(Qualifiers Quals) { + ID.AddInteger(Quals.getAsOpaqueValue()); + } + void Visit(const Type *T) { ID.AddInteger(T->getTypeClass()); Inherited::Visit(T); @@ -322,11 +346,69 @@ public: void VisitType(const Type *T) {} + void VisitAdjustedType(const AdjustedType *T) { + AddQualType(T->getOriginalType()); + AddQualType(T->getAdjustedType()); + VisitType(T); + } + + void VisitDecayedType(const DecayedType *T) { + AddQualType(T->getDecayedType()); + AddQualType(T->getPointeeType()); + VisitAdjustedType(T); + } + + void VisitArrayType(const ArrayType *T) { + AddQualType(T->getElementType()); + ID.AddInteger(T->getSizeModifier()); + VisitQualifiers(T->getIndexTypeQualifiers()); + VisitType(T); + } + void VisitConstantArrayType(const ConstantArrayType *T) { + T->getSize().Profile(ID); + VisitArrayType(T); + } + + void VisitDependentSizedArrayType(const DependentSizedArrayType *T) { + AddStmt(T->getSizeExpr()); + VisitArrayType(T); + } + + void VisitIncompleteArrayType(const IncompleteArrayType *T) { + VisitArrayType(T); + } + + void VisitVariableArrayType(const VariableArrayType *T) { + AddStmt(T->getSizeExpr()); + VisitArrayType(T); + } + void VisitBuiltinType(const BuiltinType *T) { ID.AddInteger(T->getKind()); VisitType(T); } + void VisitFunctionType(const FunctionType *T) { + AddQualType(T->getReturnType()); + T->getExtInfo().Profile(ID); + Hash.AddBoolean(T->isConst()); + Hash.AddBoolean(T->isVolatile()); + Hash.AddBoolean(T->isRestrict()); + VisitType(T); + } + + void VisitFunctionNoProtoType(const FunctionNoProtoType *T) { + VisitFunctionType(T); + } + + void VisitFunctionProtoType(const FunctionProtoType *T) { + ID.AddInteger(T->getNumParams()); + for (auto ParamType : T->getParamTypes()) + AddQualType(ParamType); + + VisitFunctionType(T); + } + void VisitTypedefType(const TypedefType *T) { AddDecl(T->getDecl()); Hash.AddQualType(T->getDecl()->getUnderlyingType()); Modified: vendor/clang/dist/lib/Basic/Diagnostic.cpp ============================================================================== --- vendor/clang/dist/lib/Basic/Diagnostic.cpp Wed May 3 20:26:18 2017 (r317761) +++ vendor/clang/dist/lib/Basic/Diagnostic.cpp Wed May 3 20:26:23 2017 (r317762) @@ -67,18 +67,12 @@ DiagnosticsEngine::DiagnosticsEngine(Int ArgToStringCookie = nullptr; AllExtensionsSilenced = 0; - IgnoreAllWarnings = false; - WarningsAsErrors = false; - EnableAllWarnings = false; - ErrorsAsFatal = false; - FatalsAsError = false; - SuppressSystemWarnings = false; + SuppressAfterFatalError = true; SuppressAllDiagnostics = false; ElideType = true; PrintTemplateTree = false; ShowColors = false; ShowOverloads = Ovl_All; - ExtBehavior = diag::Severity::Ignored; *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***