diff options
author | dim <dim@FreeBSD.org> | 2014-05-12 18:45:56 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2014-05-12 18:45:56 +0000 |
commit | 2f29f665c9ba510d8c9d2fab818bfe63d74f0ba2 (patch) | |
tree | 35d5a050f878d9a554807408b0128b0347abf2c1 /contrib/llvm/tools/clang/lib | |
parent | d71c133cadfe28aaac02dddebb466b72bf312739 (diff) | |
download | FreeBSD-src-2f29f665c9ba510d8c9d2fab818bfe63d74f0ba2.zip FreeBSD-src-2f29f665c9ba510d8c9d2fab818bfe63d74f0ba2.tar.gz |
Upgrade our copy of llvm/clang to 3.4.1 release. This release contains
mostly fixes, for the following upstream bugs:
http://llvm.org/PR16365 http://llvm.org/PR17473 http://llvm.org/PR18000
http://llvm.org/PR18068 http://llvm.org/PR18102 http://llvm.org/PR18165
http://llvm.org/PR18260 http://llvm.org/PR18290 http://llvm.org/PR18316
http://llvm.org/PR18460 http://llvm.org/PR18473 http://llvm.org/PR18515
http://llvm.org/PR18526 http://llvm.org/PR18600 http://llvm.org/PR18762
http://llvm.org/PR18773 http://llvm.org/PR18860 http://llvm.org/PR18994
http://llvm.org/PR19007 http://llvm.org/PR19010 http://llvm.org/PR19033
http://llvm.org/PR19059 http://llvm.org/PR19144 http://llvm.org/PR19326
MFC after: 2 weeks
Diffstat (limited to 'contrib/llvm/tools/clang/lib')
-rw-r--r-- | contrib/llvm/tools/clang/lib/AST/ASTDumper.cpp | 13 | ||||
-rw-r--r-- | contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp | 35 | ||||
-rw-r--r-- | contrib/llvm/tools/clang/lib/AST/StmtPrinter.cpp | 4 | ||||
-rw-r--r-- | contrib/llvm/tools/clang/lib/Analysis/Consumed.cpp | 14 | ||||
-rw-r--r-- | contrib/llvm/tools/clang/lib/Basic/Targets.cpp | 12 | ||||
-rw-r--r-- | contrib/llvm/tools/clang/lib/Basic/Version.cpp | 2 | ||||
-rw-r--r-- | contrib/llvm/tools/clang/lib/Driver/Driver.cpp | 4 | ||||
-rw-r--r-- | contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp | 23 | ||||
-rw-r--r-- | contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp | 28 | ||||
-rw-r--r-- | contrib/llvm/tools/clang/lib/Driver/ToolChains.h | 4 | ||||
-rw-r--r-- | contrib/llvm/tools/clang/lib/Driver/Tools.cpp | 17 | ||||
-rw-r--r-- | contrib/llvm/tools/clang/lib/Sema/SemaExprCXX.cpp | 13 |
12 files changed, 100 insertions, 69 deletions
diff --git a/contrib/llvm/tools/clang/lib/AST/ASTDumper.cpp b/contrib/llvm/tools/clang/lib/AST/ASTDumper.cpp index 2f40255..670fd0e 100644 --- a/contrib/llvm/tools/clang/lib/AST/ASTDumper.cpp +++ b/contrib/llvm/tools/clang/lib/AST/ASTDumper.cpp @@ -32,12 +32,23 @@ using namespace clang::comments; namespace { // Colors used for various parts of the AST dump + // Do not use bold yellow for any text. It is hard to read on white screens. struct TerminalColor { raw_ostream::Colors Color; bool Bold; }; + // Red - CastColor + // Green - TypeColor + // Bold Green - DeclKindNameColor, UndeserializedColor + // Yellow - AddressColor, LocationColor + // Blue - CommentColor, NullColor, IndentColor + // Bold Blue - AttrColor + // Bold Magenta - StmtColor + // Cyan - ValueKindColor, ObjectKindColor + // Bold Cyan - ValueColor, DeclNameColor + // Decl kind names (VarDecl, FunctionDecl, etc) static const TerminalColor DeclKindNameColor = { raw_ostream::GREEN, true }; // Attr names (CleanupAttr, GuardedByAttr, etc) @@ -45,7 +56,7 @@ namespace { // Statement names (DeclStmt, ImplicitCastExpr, etc) static const TerminalColor StmtColor = { raw_ostream::MAGENTA, true }; // Comment names (FullComment, ParagraphComment, TextComment, etc) - static const TerminalColor CommentColor = { raw_ostream::YELLOW, true }; + static const TerminalColor CommentColor = { raw_ostream::BLUE, false }; // Type names (int, float, etc, plus user defined types) static const TerminalColor TypeColor = { raw_ostream::GREEN, false }; diff --git a/contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp b/contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp index 390cfe9..4cac4fa 100644 --- a/contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp +++ b/contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp @@ -5089,16 +5089,15 @@ bool RecordExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E) { if (!Result.isUninit()) return true; - if (ZeroInit) - return ZeroInitialization(E); - - const CXXRecordDecl *RD = FD->getParent(); - if (RD->isUnion()) - Result = APValue((FieldDecl*)0); - else - Result = APValue(APValue::UninitStruct(), RD->getNumBases(), - std::distance(RD->field_begin(), RD->field_end())); - return true; + // We can get here in two different ways: + // 1) We're performing value-initialization, and should zero-initialize + // the object, or + // 2) We're performing default-initialization of an object with a trivial + // constexpr default constructor, in which case we should start the + // lifetimes of all the base subobjects (there can be no data member + // subobjects in this case) per [basic.life]p1. + // Either way, ZeroInitialization is appropriate. + return ZeroInitialization(E); } const FunctionDecl *Definition = 0; @@ -5578,19 +5577,9 @@ bool ArrayExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E, if (HadZeroInit) return true; - if (ZeroInit) { - ImplicitValueInitExpr VIE(Type); - return EvaluateInPlace(*Value, Info, Subobject, &VIE); - } - - const CXXRecordDecl *RD = FD->getParent(); - if (RD->isUnion()) - *Value = APValue((FieldDecl*)0); - else - *Value = - APValue(APValue::UninitStruct(), RD->getNumBases(), - std::distance(RD->field_begin(), RD->field_end())); - return true; + // See RecordExprEvaluator::VisitCXXConstructExpr for explanation. + ImplicitValueInitExpr VIE(Type); + return EvaluateInPlace(*Value, Info, Subobject, &VIE); } const FunctionDecl *Definition = 0; diff --git a/contrib/llvm/tools/clang/lib/AST/StmtPrinter.cpp b/contrib/llvm/tools/clang/lib/AST/StmtPrinter.cpp index 0ecb5b5..ae2cdf7 100644 --- a/contrib/llvm/tools/clang/lib/AST/StmtPrinter.cpp +++ b/contrib/llvm/tools/clang/lib/AST/StmtPrinter.cpp @@ -709,9 +709,11 @@ void StmtPrinter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) { void StmtPrinter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) { if (Node->isSuperReceiver()) OS << "super."; - else if (Node->getBase()) { + else if (Node->isObjectReceiver() && Node->getBase()) { PrintExpr(Node->getBase()); OS << "."; + } else if (Node->isClassReceiver() && Node->getClassReceiver()) { + OS << Node->getClassReceiver()->getName() << "."; } if (Node->isImplicitProperty()) diff --git a/contrib/llvm/tools/clang/lib/Analysis/Consumed.cpp b/contrib/llvm/tools/clang/lib/Analysis/Consumed.cpp index b33c8d8..e5ec3e6 100644 --- a/contrib/llvm/tools/clang/lib/Analysis/Consumed.cpp +++ b/contrib/llvm/tools/clang/lib/Analysis/Consumed.cpp @@ -605,13 +605,25 @@ void ConsumedStmtVisitor::VisitBinaryOperator(const BinaryOperator *BinOp) { } } +static bool isStdNamespace(const DeclContext *DC) { + if (!DC->isNamespace()) return false; + while (DC->getParent()->isNamespace()) + DC = DC->getParent(); + const NamespaceDecl *ND = dyn_cast<NamespaceDecl>(DC); + + return ND && ND->getName() == "std" && + ND->getDeclContext()->isTranslationUnit(); +} + void ConsumedStmtVisitor::VisitCallExpr(const CallExpr *Call) { if (const FunctionDecl *FunDecl = dyn_cast_or_null<FunctionDecl>(Call->getDirectCallee())) { // Special case for the std::move function. // TODO: Make this more specific. (Deferred) - if (FunDecl->getNameAsString() == "move") { + if (Call->getNumArgs() == 1 && + FunDecl->getNameAsString() == "move" && + isStdNamespace(FunDecl->getDeclContext())) { forwardInfo(Call->getArg(0), Call); return; } diff --git a/contrib/llvm/tools/clang/lib/Basic/Targets.cpp b/contrib/llvm/tools/clang/lib/Basic/Targets.cpp index af9221b..b538792 100644 --- a/contrib/llvm/tools/clang/lib/Basic/Targets.cpp +++ b/contrib/llvm/tools/clang/lib/Basic/Targets.cpp @@ -358,6 +358,16 @@ public: LinuxTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) { this->UserLabelPrefix = ""; this->WIntType = TargetInfo::UnsignedInt; + + switch (Triple.getArch()) { + default: + break; + case llvm::Triple::ppc: + case llvm::Triple::ppc64: + case llvm::Triple::ppc64le: + this->MCountName = "_mcount"; + break; + } } virtual const char *getStaticInitSectionSpecifier() const { @@ -1271,7 +1281,7 @@ public: LongLongAlign = 32; SuitableAlign = 128; DescriptionString = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" - "i64:32:64-f32:32:32-f64:64:64-v128:128:128-n32"; + "i64:32:64-f32:32:32-f64:32:64-v128:128:128-n32"; } virtual BuiltinVaListKind getBuiltinVaListKind() const { return TargetInfo::CharPtrBuiltinVaList; diff --git a/contrib/llvm/tools/clang/lib/Basic/Version.cpp b/contrib/llvm/tools/clang/lib/Basic/Version.cpp index 17a8e35..bc09880 100644 --- a/contrib/llvm/tools/clang/lib/Basic/Version.cpp +++ b/contrib/llvm/tools/clang/lib/Basic/Version.cpp @@ -36,7 +36,7 @@ std::string getClangRepositoryPath() { // If the SVN_REPOSITORY is empty, try to use the SVN keyword. This helps us // pick up a tag in an SVN export, for example. - StringRef SVNRepository("$URL: https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_34/final/lib/Basic/Version.cpp $"); + StringRef SVNRepository("$URL: https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_34/dot1-final/lib/Basic/Version.cpp $"); if (URL.empty()) { URL = SVNRepository.slice(SVNRepository.find(':'), SVNRepository.find("/lib/Basic")); diff --git a/contrib/llvm/tools/clang/lib/Driver/Driver.cpp b/contrib/llvm/tools/clang/lib/Driver/Driver.cpp index 49beb93..1c76509 100644 --- a/contrib/llvm/tools/clang/lib/Driver/Driver.cpp +++ b/contrib/llvm/tools/clang/lib/Driver/Driver.cpp @@ -2055,3 +2055,7 @@ std::pair<unsigned, unsigned> Driver::getIncludeExcludeOptionFlagMasks() const { return std::make_pair(IncludedFlagsBitmask, ExcludedFlagsBitmask); } + +bool clang::driver::isOptimizationLevelFast(const llvm::opt::ArgList &Args) { + return Args.hasFlag(options::OPT_Ofast, options::OPT_O_Group, false); +} diff --git a/contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp b/contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp index efd3945..36aae33 100644 --- a/contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp +++ b/contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp @@ -430,16 +430,19 @@ void ToolChain::AddCCKextLibArgs(const ArgList &Args, bool ToolChain::AddFastMathRuntimeIfAvailable(const ArgList &Args, ArgStringList &CmdArgs) const { - // Check if -ffast-math or -funsafe-math is enabled. - Arg *A = Args.getLastArg(options::OPT_ffast_math, - options::OPT_fno_fast_math, - options::OPT_funsafe_math_optimizations, - options::OPT_fno_unsafe_math_optimizations); - - if (!A || A->getOption().getID() == options::OPT_fno_fast_math || - A->getOption().getID() == options::OPT_fno_unsafe_math_optimizations) - return false; - + // Do not check for -fno-fast-math or -fno-unsafe-math when -Ofast passed + // (to keep the linker options consistent with gcc and clang itself). + if (!isOptimizationLevelFast(Args)) { + // Check if -ffast-math or -funsafe-math. + Arg *A = + Args.getLastArg(options::OPT_ffast_math, options::OPT_fno_fast_math, + options::OPT_funsafe_math_optimizations, + options::OPT_fno_unsafe_math_optimizations); + + if (!A || A->getOption().getID() == options::OPT_fno_fast_math || + A->getOption().getID() == options::OPT_fno_unsafe_math_optimizations) + return false; + } // If crtfastmath.o exists add it to the arguments. std::string Path = GetFilePath("crtfastmath.o"); if (Path == "crtfastmath.o") // Not found. diff --git a/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp b/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp index d98c654..b568593 100644 --- a/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp +++ b/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp @@ -1650,6 +1650,21 @@ bool Generic_GCC::isPICDefaultForced() const { return false; } +void Generic_GCC::addClangTargetOptions(const ArgList &DriverArgs, + ArgStringList &CC1Args) const { + const Generic_GCC::GCCVersion &V = GCCInstallation.getVersion(); + bool UseInitArrayDefault = + getTriple().getArch() == llvm::Triple::aarch64 || + (getTriple().getOS() == llvm::Triple::Linux && ( + !V.isOlderThan(4, 7, 0) || + getTriple().getEnvironment() == llvm::Triple::Android)); + + if (DriverArgs.hasFlag(options::OPT_fuse_init_array, + options::OPT_fno_use_init_array, + UseInitArrayDefault)) + CC1Args.push_back("-fuse-init-array"); +} + /// Hexagon Toolchain std::string Hexagon_TC::GetGnuDir(const std::string &InstalledDir) { @@ -2566,19 +2581,6 @@ Tool *Linux::buildAssembler() const { return new tools::gnutools::Assemble(*this); } -void Linux::addClangTargetOptions(const ArgList &DriverArgs, - ArgStringList &CC1Args) const { - const Generic_GCC::GCCVersion &V = GCCInstallation.getVersion(); - bool UseInitArrayDefault = - !V.isOlderThan(4, 7, 0) || - getTriple().getArch() == llvm::Triple::aarch64 || - getTriple().getEnvironment() == llvm::Triple::Android; - if (DriverArgs.hasFlag(options::OPT_fuse_init_array, - options::OPT_fno_use_init_array, - UseInitArrayDefault)) - CC1Args.push_back("-fuse-init-array"); -} - std::string Linux::computeSysRoot() const { if (!getDriver().SysRoot.empty()) return getDriver().SysRoot; diff --git a/contrib/llvm/tools/clang/lib/Driver/ToolChains.h b/contrib/llvm/tools/clang/lib/Driver/ToolChains.h index ba794a7..50e745a 100644 --- a/contrib/llvm/tools/clang/lib/Driver/ToolChains.h +++ b/contrib/llvm/tools/clang/lib/Driver/ToolChains.h @@ -164,6 +164,8 @@ public: virtual bool isPICDefault() const; virtual bool isPIEDefault() const; virtual bool isPICDefaultForced() const; + virtual void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) const; protected: virtual Tool *getTool(Action::ActionClass AC) const; @@ -584,8 +586,6 @@ public: virtual void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const; - virtual void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, - llvm::opt::ArgStringList &CC1Args) const; virtual void AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const; diff --git a/contrib/llvm/tools/clang/lib/Driver/Tools.cpp b/contrib/llvm/tools/clang/lib/Driver/Tools.cpp index 83ce2af..8b68869 100644 --- a/contrib/llvm/tools/clang/lib/Driver/Tools.cpp +++ b/contrib/llvm/tools/clang/lib/Driver/Tools.cpp @@ -2003,13 +2003,6 @@ static void SplitDebugInfo(const ToolChain &TC, Compilation &C, C.addCommand(new Command(JA, T, Exec, StripArgs)); } -static bool isOptimizationLevelFast(const ArgList &Args) { - if (Arg *A = Args.getLastArg(options::OPT_O_Group)) - if (A->getOption().matches(options::OPT_Ofast)) - return true; - return false; -} - /// \brief Vectorize at all optimization levels greater than 1 except for -Oz. static bool shouldEnableVectorizerAtOLevel(const ArgList &Args) { if (Arg *A = Args.getLastArg(options::OPT_O_Group)) { @@ -4621,8 +4614,14 @@ void darwin::Assemble::ConstructJob(Compilation &C, const JobAction &JA, // If -no_integrated_as is used add -Q to the darwin assember driver to make // sure it runs its system assembler not clang's integrated assembler. - if (Args.hasArg(options::OPT_no_integrated_as)) - CmdArgs.push_back("-Q"); + // Applicable to darwin11+ and Xcode 4+. darwin<10 lacked integrated-as. + // FIXME: at run-time detect assembler capabilities or rely on version + // information forwarded by -target-assembler-version (future) + if (Args.hasArg(options::OPT_no_integrated_as)) { + const llvm::Triple& t(getToolChain().getTriple()); + if (!(t.isMacOSX() && t.isMacOSXVersionLT(10, 7))) + CmdArgs.push_back("-Q"); + } // Forward -g, assuming we are dealing with an actual assembly file. if (SourceAction->getType() == types::TY_Asm || diff --git a/contrib/llvm/tools/clang/lib/Sema/SemaExprCXX.cpp b/contrib/llvm/tools/clang/lib/Sema/SemaExprCXX.cpp index 07e4657..20118b5 100644 --- a/contrib/llvm/tools/clang/lib/Sema/SemaExprCXX.cpp +++ b/contrib/llvm/tools/clang/lib/Sema/SemaExprCXX.cpp @@ -5836,17 +5836,16 @@ static inline bool VariableCanNeverBeAConstantExpression(VarDecl *Var, assert(DefVD); if (DefVD->isWeak()) return false; EvaluatedStmt *Eval = DefVD->ensureEvaluatedStmt(); - + Expr *Init = cast<Expr>(Eval->Value); if (Var->getType()->isDependentType() || Init->isValueDependent()) { - if (!Init->isValueDependent()) - return !DefVD->checkInitIsICE(); - // FIXME: We might still be able to do some analysis of Init here - // to conclude that even in a dependent setting, Init can never - // be a constexpr - but for now admit agnosticity. + // FIXME: Teach the constant evaluator to deal with the non-dependent parts + // of value-dependent expressions, and use it here to determine whether the + // initializer is a potential constant expression. return false; - } + } + return !IsVariableAConstantExpression(Var, Context); } |