diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index 26eea64..22d56b0 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -1640,6 +1640,9 @@ private: void buildLookupImpl(DeclContext *DCtx); void makeDeclVisibleInContextWithFlags(NamedDecl *D, bool Internal, bool Rediscoverable); +#if !__GNUC_PREREQ(4, 2) +public: // gcc-4.0 accessibility bug workaround +#endif void makeDeclVisibleInContextImpl(NamedDecl *D, bool Internal); }; diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index fb829e4..dab99b5 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -147,7 +147,7 @@ public: OCL_Autoreleasing }; - enum { + enum MaskEnum { /// The maximum supported address space number. /// 24 bits should be enough for anyone. MaxAddressSpace = 0xffffffu, diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 9e7dc78..f1a3fd1 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -197,7 +197,8 @@ def _HASH_HASH_HASH : Flag<["-"], "###">, Flags<[DriverOption, CoreOption]>, def _DASH_DASH : Option<["--"], "", KIND_REMAINING_ARGS>, Flags<[DriverOption, CoreOption]>; def A : JoinedOrSeparate<["-"], "A">, Flags<[RenderJoined]>; -def B : JoinedOrSeparate<["-"], "B">; +def B : JoinedOrSeparate<["-"], "B">, Flags<[RenderJoined]>, + HelpText<"Add search paths for compiler executables (ld,as)">; def CC : Flag<["-"], "CC">, Flags<[CC1Option]>; def C : Flag<["-"], "C">, Flags<[CC1Option]>; def D : JoinedOrSeparate<["-"], "D">, Group, Flags<[CC1Option]>; diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h index 03d9050..56e737a 100644 --- a/include/clang/Serialization/ASTBitCodes.h +++ b/include/clang/Serialization/ASTBitCodes.h @@ -83,21 +83,21 @@ namespace clang { /// \brief A type index; the type ID with the qualifier bits removed. class TypeIdx { - uint32_t Idx; + TypeID Idx; public: TypeIdx() : Idx(0) { } - explicit TypeIdx(uint32_t index) : Idx(index) { } + explicit TypeIdx(TypeID index) : Idx(index) { } - uint32_t getIndex() const { return Idx; } + TypeID getIndex() const { return Idx; } TypeID asTypeID(unsigned FastQuals) const { - if (Idx == uint32_t(-1)) + if (Idx == TypeID(-1)) return TypeID(-1); return (Idx << Qualifiers::FastWidth) | FastQuals; } static TypeIdx fromTypeID(TypeID ID) { if (ID == TypeID(-1)) - return TypeIdx(-1); + return TypeIdx(TypeID(-1)); return TypeIdx(ID >> Qualifiers::FastWidth); } diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index d3cca1a..57822ed 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -294,10 +294,16 @@ private: FileManager &FileMgr; DiagnosticsEngine &Diags; +#if !__GNUC_PREREQ(4, 2) +public: // workaround to grant access to classes nested within ASTDeclReader +#endif /// \brief The semantic analysis object that will be processing the /// AST files and the translation unit that uses it. Sema *SemaObj; +#if !__GNUC_PREREQ(4, 2) +private: +#endif /// \brief The preprocessor that will be loading the source file. Preprocessor &PP; @@ -849,6 +855,9 @@ private: /// since the last time the declaration chains were linked. llvm::SmallPtrSet RedeclsDeserialized; +#if !__GNUC_PREREQ(4, 2) +public: // workaround to grant access to classes nested within ASTDeclReader +#endif /// \brief The list of redeclaration chains that still need to be /// reconstructed. /// @@ -860,6 +869,9 @@ private: /// \brief Keeps track of the elements added to PendingDeclChains. llvm::SmallSet PendingDeclChainsKnown; +#if !__GNUC_PREREQ(4, 2) +private: +#endif /// \brief The Decl IDs for the Sema/Lexical DeclContext of a Decl that has /// been loaded but its DeclContext was not set yet. struct PendingDeclContextInfo { diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index a03cf9e..fc5bd8f 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -5107,6 +5107,7 @@ static char getObjCEncodingForPrimitiveKind(const ASTContext *C, llvm_unreachable("invalid builtin type for @encode"); } llvm_unreachable("invalid BuiltinType::Kind value"); + return '\0'; // unreachable, just to suppress warning } static char ObjCEncodingForEnumType(const ASTContext *C, const EnumType *ET) { diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 4cac4fa..ad2affd 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -2123,7 +2123,7 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj, assert(I == N - 1 && "extracting subobject of character?"); assert(!O->hasLValuePath() || O->getLValuePath().empty()); if (handler.AccessKind != AK_Read) - expandStringLiteral(Info, O->getLValueBase().get(), + expandStringLiteral(Info, O->getLValueBase().template get(), *O); else return handler.foundString(*O, ObjType, Index); @@ -4188,7 +4188,8 @@ public: if (E->isArrow()) { if (!EvaluatePointer(E->getBase(), Result, this->Info)) return false; - BaseTy = E->getBase()->getType()->castAs()->getPointeeType(); + BaseTy = E->getBase()->getType()->template castAs() + ->getPointeeType(); } else if (E->getBase()->isRValue()) { assert(E->getBase()->getType()->isRecordType()); if (!EvaluateTemporary(E->getBase(), Result, this->Info)) diff --git a/lib/ASTMatchers/Dynamic/Marshallers.h b/lib/ASTMatchers/Dynamic/Marshallers.h index ae0c300..05eca32 100644 --- a/lib/ASTMatchers/Dynamic/Marshallers.h +++ b/lib/ASTMatchers/Dynamic/Marshallers.h @@ -61,10 +61,10 @@ template struct ArgTypeTraits > { ">").str(); } static bool is(const VariantValue &Value) { - return Value.isMatcher() && Value.getMatcher().hasTypedMatcher(); + return Value.isMatcher() && Value.getMatcher().template hasTypedMatcher(); } static ast_matchers::internal::Matcher get(const VariantValue &Value) { - return Value.getMatcher().getTypedMatcher(); + return Value.getMatcher().template getTypedMatcher(); } }; diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 588e8df..734fb3d 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -1929,10 +1929,11 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, if (Target.getArch() == llvm::Triple::x86 || Target.getArch() == llvm::Triple::x86_64 || Target.getArch() == llvm::Triple::arm || - Target.getArch() == llvm::Triple::thumb) + Target.getArch() == llvm::Triple::thumb || + Target.getArch() == llvm::Triple::ppc) TC = new toolchains::DarwinClang(*this, Target, Args); else - TC = new toolchains::Darwin_Generic_GCC(*this, Target, Args); + TC = new toolchains::DarwinLegacy(*this, Target, Args); break; case llvm::Triple::DragonFly: TC = new toolchains::DragonFly(*this, Target, Args); diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 4688335..b839421 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -139,6 +139,12 @@ StringRef Darwin::getDarwinArchName(const ArgList &Args) const { default: return getArchName(); + case llvm::Triple::ppc: + return "ppc"; + + case llvm::Triple::ppc64: + return "ppc64"; + case llvm::Triple::thumb: case llvm::Triple::arm: { if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) @@ -358,8 +364,19 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args, // We currently always need a static runtime library for iOS. AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.ios.a"); } else { + // darwin8 also has symbols defined in libSystemStubs.a + // does darwin9 need this too? + if (isMacosxVersionLT(10, 5)) + CmdArgs.push_back("-lSystemStubs"); + // use runtime functions from compiler-rt first + // does darwin9 need this too? probably. x86? + if (isMacosxVersionLT(10, 6)) + if (getTriple().getArch() == llvm::Triple::ppc) + AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.ppc.a"); + // The dynamic runtime library was merged with libSystem for 10.6 and // beyond; only 10.4 and 10.5 need an additional runtime library. + // These include the system libunwind. if (isMacosxVersionLT(10, 5)) CmdArgs.push_back("-lgcc_s.10.4"); else if (isMacosxVersionLT(10, 6)) @@ -543,6 +560,11 @@ void DarwinClang::AddCXXStdlibLibArgs(const ArgList &Args, switch (Type) { case ToolChain::CST_Libcxx: CmdArgs.push_back("-lc++"); + // darwin8: now libc++ is statically linked to libsupc++.a + // instead of libc++abi.dylib, which appeared in darwin11+ + if (DarwinVersion[0] < 11) { + CmdArgs.push_back("-lsupc++"); + } break; case ToolChain::CST_Libstdcxx: { @@ -921,10 +943,8 @@ void Darwin::CheckObjCARC() const { getDriver().Diag(diag::err_arc_unsupported_on_toolchain); } -std::string -Darwin_Generic_GCC::ComputeEffectiveClangTriple(const ArgList &Args, - types::ID InputType) const { - return ComputeLLVMTriple(Args, InputType); +Tool *DarwinLegacy::buildAssembler() const { + return new tools::darwin::AssembleWithAs(*this); } /// Generic_GCC - A tool chain using the 'gcc' command to perform diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index c758fbb..c0fddec 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -344,8 +344,9 @@ public: } virtual bool IsObjCNonFragileABIDefault() const { - // Non-fragile ABI is default for everything but i386. - return getTriple().getArch() != llvm::Triple::x86; + // Non-fragile ABI is default for everything but i386 and ppc. + return (getTriple().getArch() != llvm::Triple::x86 + && getTriple().getArch() != llvm::Triple::ppc); } virtual bool UseObjCMixedDispatch() const { @@ -409,17 +410,16 @@ public: /// } }; -/// Darwin_Generic_GCC - Generic Darwin tool chain using gcc. -class LLVM_LIBRARY_VISIBILITY Darwin_Generic_GCC : public Generic_GCC { +/// Darwin_Legacy - Toolchain using the older 'as' and 'ld' installation. +class LLVM_LIBRARY_VISIBILITY DarwinLegacy : public DarwinClang { public: - Darwin_Generic_GCC(const Driver &D, const llvm::Triple &Triple, + DarwinLegacy(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args) - : Generic_GCC(D, Triple, Args) {} + : DarwinClang(D, Triple, Args) {} - std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args, - types::ID InputType) const; +protected: + virtual Tool *buildAssembler() const; - virtual bool isPICDefault() const { return false; } }; class LLVM_LIBRARY_VISIBILITY Generic_ELF : public Generic_GCC { diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index b013eb5..2f98f87 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -1360,8 +1360,8 @@ static std::string getCPUName(const ArgList &Args, const llvm::Triple &T) { std::string TargetCPUName = getPPCTargetCPU(Args); // LLVM may default to generating code for the native CPU, // but, like gcc, we default to a more generic option for - // each architecture. (except on Darwin) - if (TargetCPUName.empty() && !T.isOSDarwin()) { + // each architecture. + if (TargetCPUName.empty()) { if (T.getArch() == llvm::Triple::ppc64) TargetCPUName = "ppc64"; else if (T.getArch() == llvm::Triple::ppc64le) @@ -4608,8 +4608,8 @@ void darwin::Assemble::ConstructJob(Compilation &C, const JobAction &JA, // 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))) + const llvm::Triple &T(getToolChain().getTriple()); + if (!(T.isMacOSX() && T.isMacOSXVersionLT(10, 7))) CmdArgs.push_back("-Q"); } @@ -4625,6 +4625,76 @@ void darwin::Assemble::ConstructJob(Compilation &C, const JobAction &JA, // Derived from asm spec. AddDarwinArch(Args, CmdArgs); + // We probably want to allow use of newer assemblers. + // Args.AddAllArgs(CmdArgs, options::OPT_B); + + // Use -force_cpusubtype_ALL on x86 by default. + if (getToolChain().getArch() == llvm::Triple::x86 || + getToolChain().getArch() == llvm::Triple::x86_64 || + Args.hasArg(options::OPT_force__cpusubtype__ALL)) + CmdArgs.push_back("-force_cpusubtype_ALL"); + + if (getToolChain().getArch() != llvm::Triple::x86_64 && + (((Args.hasArg(options::OPT_mkernel) || + Args.hasArg(options::OPT_fapple_kext)) && + (!getDarwinToolChain().isTargetIPhoneOS() || + getDarwinToolChain().isIPhoneOSVersionLT(6, 0))) || + Args.hasArg(options::OPT_static))) + CmdArgs.push_back("-static"); + + Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, + options::OPT_Xassembler); + + assert(Output.isFilename() && "Unexpected lipo output."); + CmdArgs.push_back("-o"); + CmdArgs.push_back(Output.getFilename()); + + assert(Input.isFilename() && "Invalid input."); + CmdArgs.push_back(Input.getFilename()); + + // asm_final spec is empty. + + const char *Exec = + Args.MakeArgString(getToolChain().GetProgramPath("as")); + C.addCommand(new Command(JA, *this, Exec, CmdArgs)); +} + +// Placeholder for cases where we need to modify which command lines are +// accepted or generated (perhaps this should not be needed). +void darwin::AssembleWithAs::ConstructJob(Compilation &C, const JobAction &JA, + const InputInfo &Output, + const InputInfoList &Inputs, + const ArgList &Args, + const char *LinkingOutput) const { + ArgStringList CmdArgs; + + assert(Inputs.size() == 1 && "Unexpected number of inputs."); + const InputInfo &Input = Inputs[0]; + + // Determine the original source input. + const Action *SourceAction = &JA; + while (SourceAction->getKind() != Action::InputClass) { + assert(!SourceAction->getInputs().empty() && "unexpected root action!"); + SourceAction = SourceAction->getInputs()[0]; + } + + // 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"); + + // Forward -g, assuming we are dealing with an actual assembly file. + if (SourceAction->getType() == types::TY_Asm || + SourceAction->getType() == types::TY_PP_Asm) { + if (Args.hasArg(options::OPT_gstabs)) + CmdArgs.push_back("--gstabs"); + else if (Args.hasArg(options::OPT_g_Group)) + CmdArgs.push_back("-g"); + } + + // Derived from asm spec. + AddDarwinArch(Args, CmdArgs); + // Use -force_cpusubtype_ALL on x86 by default. if (getToolChain().getArch() == llvm::Triple::x86 || getToolChain().getArch() == llvm::Triple::x86_64 || @@ -4664,6 +4734,14 @@ void darwin::DarwinTool::AddDarwinArch(const ArgList &Args, // Derived from darwin_arch spec. CmdArgs.push_back("-arch"); +#if 1 +// suggested patch from http://llvm.org/bugs/show_bug.cgi?id=3830 + if (ArchName == "powerpc") + CmdArgs.push_back("ppc"); + else if (ArchName == "powerpc64") + CmdArgs.push_back("ppc64"); + else +#endif CmdArgs.push_back(Args.MakeArgString(ArchName)); // FIXME: Is this needed anymore? @@ -4806,6 +4884,7 @@ void darwin::Link::AddLinkArgs(Compilation &C, // Add the deployment target. VersionTuple TargetVersion = DarwinTC.getTargetVersion(); + const std::string mmvs1(TargetVersion.getAsString()); // If we had an explicit -mios-simulator-version-min argument, honor that, // otherwise use the traditional deployment targets. We can't just check the @@ -4814,13 +4893,25 @@ void darwin::Link::AddLinkArgs(Compilation &C, // // FIXME: We may be able to remove this, once we can verify no one depends on // it. - if (Args.hasArg(options::OPT_mios_simulator_version_min_EQ)) + if (Args.hasArg(options::OPT_mios_simulator_version_min_EQ)) { CmdArgs.push_back("-ios_simulator_version_min"); - else if (DarwinTC.isTargetIPhoneOS()) + CmdArgs.push_back(Args.MakeArgString(mmvs1)); + } else if (DarwinTC.isTargetIPhoneOS()) { CmdArgs.push_back("-iphoneos_version_min"); - else + CmdArgs.push_back(Args.MakeArgString(mmvs1)); + } else { CmdArgs.push_back("-macosx_version_min"); - CmdArgs.push_back(Args.MakeArgString(TargetVersion.getAsString())); + const unsigned vmin = *TargetVersion.getMinor(); + if (vmin <= 4) { + const VersionTuple + MmTargetVersion(TargetVersion.getMajor(), vmin); + // for darwin8 ld: omit subminor number, so we get 10.4 instead of 10.4.0 + const std::string mmvs2(MmTargetVersion.getAsString()); + CmdArgs.push_back(Args.MakeArgString(mmvs2)); + } else { + CmdArgs.push_back(Args.MakeArgString(mmvs1)); + } + } Args.AddLastArg(CmdArgs, options::OPT_nomultidefs); Args.AddLastArg(CmdArgs, options::OPT_multi__module); @@ -4917,6 +5008,8 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA, // we follow suite for ease of comparison. AddLinkArgs(C, Args, CmdArgs, Inputs); + // if 'gcc/g++' are used to drive the linker, but not if ld is called directly + // Args.AddAllArgs(CmdArgs, options::OPT_B); Args.AddAllArgs(CmdArgs, options::OPT_d_Flag); Args.AddAllArgs(CmdArgs, options::OPT_s); Args.AddAllArgs(CmdArgs, options::OPT_t); diff --git a/lib/Driver/Tools.h b/lib/Driver/Tools.h index d5b2848..da6be35 100644 --- a/lib/Driver/Tools.h +++ b/lib/Driver/Tools.h @@ -257,6 +257,20 @@ namespace darwin { const char *LinkingOutput) const; }; + class LLVM_LIBRARY_VISIBILITY AssembleWithAs: public DarwinTool { + public: + AssembleWithAs(const ToolChain &TC) : DarwinTool("darwin::AssembleWithAs", + "assembler", TC) {} + + virtual bool hasIntegratedCPP() const { return false; } + + virtual void ConstructJob(Compilation &C, const JobAction &JA, + const InputInfo &Output, + const InputInfoList &Inputs, + const llvm::opt::ArgList &TCArgs, + const char *LinkingOutput) const; + }; + class LLVM_LIBRARY_VISIBILITY Link : public DarwinTool { bool NeedsTempPath(const InputInfoList &Inputs) const; void AddLinkArgs(Compilation &C, const llvm::opt::ArgList &Args, diff --git a/lib/Index/USRGeneration.cpp b/lib/Index/USRGeneration.cpp index 16d89f8..cb30a3c 100644 --- a/lib/Index/USRGeneration.cpp +++ b/lib/Index/USRGeneration.cpp @@ -22,7 +22,7 @@ using namespace clang::index; // USR generation. //===----------------------------------------------------------------------===// -namespace { +// namespace { class USRGenerator : public ConstDeclVisitor { SmallVectorImpl &Buf; llvm::raw_svector_ostream Out; @@ -128,7 +128,7 @@ public: bool EmitDeclName(const NamedDecl *D); }; -} // end anonymous namespace +// } // end anonymous namespace //===----------------------------------------------------------------------===// // Generating USRs from ASTS. @@ -763,6 +763,7 @@ void USRGenerator::VisitTemplateArgument(const TemplateArgument &Arg) { //===----------------------------------------------------------------------===// // USR generation functions. //===----------------------------------------------------------------------===// +namespace clang { void clang::index::generateUSRForObjCClass(StringRef Cls, raw_ostream &OS) { OS << "objc(cs)" << Cls; @@ -801,3 +802,5 @@ bool clang::index::generateUSRForDecl(const Decl *D, UG.Visit(D); return UG.ignoreResults(); } + +} // end namespace clang diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp index 93e3ecf..f280959 100644 --- a/lib/Sema/AnalysisBasedWarnings.cpp +++ b/lib/Sema/AnalysisBasedWarnings.cpp @@ -55,6 +55,20 @@ using namespace clang; +// enums that were lifted from local scope and given names + enum FunctionKindEnum { + Function, + Method, + Block, + Lambda + }; + enum ObjectKindEnum { + Variable, + Property, + ImplicitProperty, + Ivar + }; + //===----------------------------------------------------------------------===// // Unreachable code analysis. //===----------------------------------------------------------------------===// @@ -1095,12 +1109,7 @@ static void diagnoseRepeatedUseOfWeak(Sema &S, // warn_arc_repeated_use_of_weak and warn_arc_possible_repeated_use_of_weak. // FIXME: Should we use a common classification enum and the same set of // possibilities all throughout Sema? - enum { - Function, - Method, - Block, - Lambda - } FunctionKind; + FunctionKindEnum FunctionKind; if (isa(CurFn)) FunctionKind = Block; @@ -1133,12 +1142,7 @@ static void diagnoseRepeatedUseOfWeak(Sema &S, // Classify the weak object being accessed for better warning text. // This enum should stay in sync with the cases in // warn_arc_repeated_use_of_weak and warn_arc_possible_repeated_use_of_weak. - enum { - Variable, - Property, - ImplicitProperty, - Ivar - } ObjectKind; + ObjectKindEnum ObjectKind; const NamedDecl *D = Key.getProperty(); if (isa(D)) diff --git a/lib/Sema/SemaCast.cpp b/lib/Sema/SemaCast.cpp index ba00b71..1c86c95 100644 --- a/lib/Sema/SemaCast.cpp +++ b/lib/Sema/SemaCast.cpp @@ -704,6 +704,12 @@ void CastOperation::CheckConstCast() { } } +// gcc-4.0 doesn't jive with local anonymous enums + enum ReinterpretKindEnum { + ReinterpretUpcast, + ReinterpretDowncast + }; + /// Check that a reinterpret_cast\(SrcExpr) is not used as upcast /// or downcast between respective pointers or references. static void DiagnoseReinterpretUpDownCast(Sema &Self, const Expr *SrcExpr, @@ -727,10 +733,7 @@ static void DiagnoseReinterpretUpDownCast(Sema &Self, const Expr *SrcExpr, if (!DestRD || !DestRD->isCompleteDefinition() || DestRD->isInvalidDecl()) return; - enum { - ReinterpretUpcast, - ReinterpretDowncast - } ReinterpretKind; + ReinterpretKindEnum ReinterpretKind; CXXBasePaths BasePaths; diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index f44fb32..00f80ad 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -1446,6 +1446,11 @@ static bool CheckMethodOverrideParam(Sema &S, return false; } +// gcc-4.0 wants non-local enum + enum FamilySelector { + F_alloc, F_copy, F_mutableCopy = F_copy, F_init, F_new + }; + enum ReasonSelector { R_NonObjectReturn, R_UnrelatedReturn }; /// In ARC, check whether the conventional meanings of the two methods /// match. If they don't, it's a hard error. static bool checkMethodFamilyMismatch(Sema &S, ObjCMethodDecl *impl, @@ -1474,9 +1479,6 @@ static bool checkMethodFamilyMismatch(Sema &S, ObjCMethodDecl *impl, } // Indexes into a %select clause in the diagnostic. - enum FamilySelector { - F_alloc, F_copy, F_mutableCopy = F_copy, F_init, F_new - }; FamilySelector familySelector = FamilySelector(); switch (family) { @@ -1500,7 +1502,6 @@ static bool checkMethodFamilyMismatch(Sema &S, ObjCMethodDecl *impl, case OMF_new: familySelector = F_new; break; } - enum ReasonSelector { R_NonObjectReturn, R_UnrelatedReturn }; ReasonSelector reasonSelector; // The only reason these methods don't fall within their families is diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index e1f65f4..c661b3d 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -329,6 +329,8 @@ std::string Sema::getDeletedOrUnavailableSuffix(const FunctionDecl *FD) { return std::string(); } +// gcc-4.0 needs non-local enums + enum CalleeType { CT_Function, CT_Method, CT_Block }; /// DiagnoseSentinelCalls - This routine checks whether a call or /// message-send is to a declaration with the sentinel attribute, and /// if so, it checks that the requirements of the sentinel are @@ -344,7 +346,7 @@ void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, // The kind of declaration. This is also an index into a %select in // the diagnostic. - enum CalleeType { CT_Function, CT_Method, CT_Block } calleeType; + CalleeType calleeType; if (ObjCMethodDecl *MD = dyn_cast(D)) { numFormalParams = MD->param_size(); diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index 4351c25..fa55bc6 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -8322,7 +8322,7 @@ TreeTransform::TransformLambdaExpr(LambdaExpr *E) { TypeSourceInfo *OldCallOpTSI = E->getCallOperator()->getTypeSourceInfo(); FunctionProtoTypeLoc OldCallOpFPTL = - OldCallOpTSI->getTypeLoc().getAs(); + OldCallOpTSI->getTypeLoc().template getAs(); TypeSourceInfo *NewCallOpTSI = 0; const bool CallOpWasAlreadyTransformed = @@ -8351,7 +8351,7 @@ TreeTransform::TransformLambdaExpr(LambdaExpr *E) { SmallVector Params; { FunctionProtoTypeLoc NewCallOpFPTL = - NewCallOpTSI->getTypeLoc().castAs(); + NewCallOpTSI->getTypeLoc().template castAs(); ParmVarDecl **NewParamDeclArray = NewCallOpFPTL.getParmArray(); const unsigned NewNumArgs = NewCallOpFPTL.getNumArgs(); diff --git a/lib/Sema/TypeLocBuilder.h b/lib/Sema/TypeLocBuilder.h index b1e9098..15a4f21 100644 --- a/lib/Sema/TypeLocBuilder.h +++ b/lib/Sema/TypeLocBuilder.h @@ -97,7 +97,7 @@ class TypeLocBuilder { TyLocType Loc = TypeLoc(T, 0).castAs(); size_t LocalSize = Loc.getLocalDataSize(); unsigned LocalAlign = Loc.getLocalDataAlignment(); - return pushImpl(T, LocalSize, LocalAlign).castAs(); + return pushImpl(T, LocalSize, LocalAlign).template castAs(); } /// Creates a TypeSourceInfo for the given type. diff --git a/test/CodeGen/target-data.c b/test/CodeGen/target-data.c index 7b285de..5622bec 100644 --- a/test/CodeGen/target-data.c +++ b/test/CodeGen/target-data.c @@ -4,6 +4,7 @@ // RUN: grep 'target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32-S128"' %t // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o %t %s // RUN: grep 'target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"' %t + // RUN: %clang_cc1 -triple powerpc-darwin -o - -emit-llvm %s | \ // RUN: FileCheck %s -check-prefix=PPC32-DARWIN // PPC32-DARWIN: target datalayout = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v128:128:128-n32" diff --git a/test/Driver/target-triple-deployment.c b/test/Driver/target-triple-deployment.c index 8e4824a..a41938e 100644 --- a/test/Driver/target-triple-deployment.c +++ b/test/Driver/target-triple-deployment.c @@ -12,7 +12,7 @@ // CHECK: {{ld(.exe)?"}} // CHECK: -macosx_version_min -// CHECK: 10.4.0 +// CHECK: 10.4 // CHECK: {{ld(.exe)?"}} // CHECK: -macosx_version_min // CHECK: 10.5.0 diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index f53e5c1..d14d90b 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -6519,8 +6519,11 @@ void clang::setThreadBackgroundPriority() { // FIXME: Move to llvm/Support and make it cross-platform. #ifdef __APPLE__ +// constants are not defined on darwin8, expected in +#if defined(PRIO_DARWIN_THREAD) && defined(PRIO_DARWIN_BG) setpriority(PRIO_DARWIN_THREAD, 0, PRIO_DARWIN_BG); #endif +#endif } void cxindex::printDiagsToStderr(ASTUnit *Unit) { diff --git a/unittests/ASTMatchers/Dynamic/RegistryTest.cpp b/unittests/ASTMatchers/Dynamic/RegistryTest.cpp index e716484..884a4f0 100644 --- a/unittests/ASTMatchers/Dynamic/RegistryTest.cpp +++ b/unittests/ASTMatchers/Dynamic/RegistryTest.cpp @@ -36,6 +36,29 @@ public: return Out; } +#if 0 + template + Matcher constructMatcher(StringRef MatcherName, Diagnostics *Error) { + return Registry::constructMatcher(MatcherName, SourceRange(), Args(), Error) + .template getTypedMatcher(); + } + + template + Matcher constructMatcher(StringRef MatcherName, const VariantValue &Arg1, + Diagnostics *Error) { + return Registry::constructMatcher(MatcherName, SourceRange(), Args(Arg1), + Error).template getTypedMatcher(); + } + + template + Matcher constructMatcher(StringRef MatcherName, const VariantValue &Arg1, + const VariantValue &Arg2, Diagnostics *Error) { + return Registry::constructMatcher(MatcherName, SourceRange(), + Args(Arg1, Arg2), Error) + .template getTypedMatcher(); + } +#endif + VariantMatcher constructMatcher(StringRef MatcherName, Diagnostics *Error = NULL) { Diagnostics DummyError;