diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2014-05-11 18:26:10 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2014-05-11 18:26:10 +0000 |
commit | f73d5f23a889b93d89ddef61ac0995df40286bb8 (patch) | |
tree | c89fa0adefb99f464eba263b447f84c2ceb663ce /lib | |
parent | 33fa48314f06936f83859852feb3c0ce68b08c0c (diff) | |
download | src-f73d5f23a889b93d89ddef61ac0995df40286bb8.tar.gz src-f73d5f23a889b93d89ddef61ac0995df40286bb8.zip |
Notes
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/ASTDumper.cpp | 13 | ||||
-rw-r--r-- | lib/AST/ExprConstant.cpp | 35 | ||||
-rw-r--r-- | lib/AST/StmtPrinter.cpp | 4 | ||||
-rw-r--r-- | lib/Analysis/Consumed.cpp | 14 | ||||
-rw-r--r-- | lib/Basic/Targets.cpp | 12 | ||||
-rw-r--r-- | lib/Basic/Version.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/CGCXX.cpp | 6 | ||||
-rw-r--r-- | lib/Driver/Driver.cpp | 4 | ||||
-rw-r--r-- | lib/Driver/ToolChain.cpp | 23 | ||||
-rw-r--r-- | lib/Driver/ToolChains.cpp | 28 | ||||
-rw-r--r-- | lib/Driver/ToolChains.h | 4 | ||||
-rw-r--r-- | lib/Driver/Tools.cpp | 17 | ||||
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 13 |
13 files changed, 106 insertions, 69 deletions
diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp index 2f402559f4da..670fd0ed3a93 100644 --- a/lib/AST/ASTDumper.cpp +++ b/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/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 390cfe9cd235..4cac4fab8476 100644 --- a/lib/AST/ExprConstant.cpp +++ b/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/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index 0ecb5b52c24f..ae2cdf757461 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/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/lib/Analysis/Consumed.cpp b/lib/Analysis/Consumed.cpp index b33c8d8930f8..e5ec3e6b927d 100644 --- a/lib/Analysis/Consumed.cpp +++ b/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/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index bccd0d72d8f5..c8bfda7e6658 100644 --- a/lib/Basic/Targets.cpp +++ b/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/lib/Basic/Version.cpp b/lib/Basic/Version.cpp index 77e4ad5bc4aa..2006878349a1 100644 --- a/lib/Basic/Version.cpp +++ b/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/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index cfb2d6291b8a..2f8a17afbcd1 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -92,7 +92,13 @@ bool CodeGenModule::TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D) { if (!ClassLayout.getBaseClassOffset(UniqueBase).isZero()) return true; + // Give up if the calling conventions don't match. We could update the call, + // but it is probably not worth it. const CXXDestructorDecl *BaseD = UniqueBase->getDestructor(); + if (BaseD->getType()->getAs<FunctionType>()->getCallConv() != + D->getType()->getAs<FunctionType>()->getCallConv()) + return true; + return TryEmitDefinitionAsAlias(GlobalDecl(D, Dtor_Base), GlobalDecl(BaseD, Dtor_Base), false); diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 530791072fa0..588e8dfb47ac 100644 --- a/lib/Driver/Driver.cpp +++ b/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/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp index efd3945b3dd4..36aae33ec838 100644 --- a/lib/Driver/ToolChain.cpp +++ b/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/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index e5528f0a646b..46883357e229 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -1622,6 +1622,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) { @@ -2536,19 +2551,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/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index 50d370003bac..c758fbb999fa 100644 --- a/lib/Driver/ToolChains.h +++ b/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; @@ -579,8 +581,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/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 29713ed1b4ce..b013eb510c4e 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -1995,13 +1995,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)) { @@ -4611,8 +4604,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/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 07e465766b74..20118b57126d 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/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); } |