From: Douglas Gregor Date: Wed, 1 Jul 2009 15:12:53 +0000 (+0000) Subject: Two fixes to make Clang build on Visual C++ (again), from Alisdair Meredith. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a3844922f685620002412df0a88d22393e5c1241;p=clang Two fixes to make Clang build on Visual C++ (again), from Alisdair Meredith. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74606 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Parse/Ownership.h b/include/clang/Parse/Ownership.h index 59517930de..987edfa96d 100644 --- a/include/clang/Parse/Ownership.h +++ b/include/clang/Parse/Ownership.h @@ -574,6 +574,19 @@ namespace clang { #if !defined(DISABLE_SMART_POINTERS) friend class moving::ASTMultiMover; +#if defined(_MSC_VER) + // Last tested with Visual Studio 2008. + // Visual C++ appears to have a bug where it does not recognise + // the return value from ASTMultiMover::opeator-> as + // being a pointer to ASTMultiPtr. However, the diagnostics + // suggest it has the right name, simply that the pointer type + // is not convertible to itself. + // Either way, a classic C-style hard cast resolves any issue. + static ASTMultiPtr* hack(moving::ASTMultiMover & source) { + return (ASTMultiPtr*)source.operator->(); + } +#endif + ASTMultiPtr(ASTMultiPtr&); // DO NOT IMPLEMENT // Reference member prevents copy assignment. @@ -594,7 +607,13 @@ namespace clang { : Actions(actions), Nodes(nodes), Count(count) {} /// Move constructor ASTMultiPtr(moving::ASTMultiMover mover) +#if defined(_MSC_VER) + // Apply the visual C++ hack supplied above. + // Last tested with Visual Studio 2008. + : Actions(hack(mover)->Actions), Nodes(hack(mover)->Nodes), Count(hack(mover)->Count) { +#else : Actions(mover->Actions), Nodes(mover->Nodes), Count(mover->Count) { +#endif mover.release(); } #else diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 88dd6f797b..561dc57ef2 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -62,17 +62,17 @@ static void DefineStd(std::vector &Buf, const char *MacroName, // Defines specific to certain operating systems. //===----------------------------------------------------------------------===// namespace { -template -class OSTargetInfo : public TargetInfo { +template +class OSTargetInfo : public TgtInfo { protected: virtual void getOSDefines(const LangOptions &Opts, const char *Triple, std::vector &Defines) const=0; public: - OSTargetInfo(const std::string& triple) : TargetInfo(triple) {} + OSTargetInfo(const std::string& triple) : TgtInfo(triple) {} virtual void getTargetDefines(const LangOptions &Opts, std::vector &Defines) const { - TargetInfo::getTargetDefines(Opts, Defines); - getOSDefines(Opts, TargetInfo::getTargetTriple(), Defines); + TgtInfo::getTargetDefines(Opts, Defines); + getOSDefines(Opts, TgtInfo::getTargetTriple(), Defines); } };