Index: tools/driver/cc1_main.cpp
===================================================================
--- tools/driver/cc1_main.cpp	(revision 170308)
+++ tools/driver/cc1_main.cpp	(working copy)
@@ -35,6 +35,9 @@
 #include <cstdio>
 using namespace clang;
 
+#define	ENABLE_STACKTRACE		0
+#include "llvm/Support/stacktrace.h"
+
 //===----------------------------------------------------------------------===//
 // Main driver
 //===----------------------------------------------------------------------===//
@@ -56,6 +59,7 @@
 
 int cc1_main(const char **ArgBegin, const char **ArgEnd,
              const char *Argv0, void *MainAddr) {
+  STACKTRACE_VERBOSE;
   OwningPtr<CompilerInstance> Clang(new CompilerInstance());
   IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
 
@@ -73,6 +77,11 @@
   bool Success;
   Success = CompilerInvocation::CreateFromArgs(Clang->getInvocation(),
                                                ArgBegin, ArgEnd, Diags);
+#if ENABLE_STACKTRACE
+  const TargetOptions& topt(Clang->getTargetOpts());
+  STACKTRACE_INDENT_PRINT("TargetOptions.Triple: " << topt.Triple << std::endl);
+  STACKTRACE_INDENT_PRINT("TargetOptions.CPU: " << topt.CPU << std::endl);
+#endif
 
   // Infer the builtin include path if unspecified.
   if (Clang->getHeaderSearchOpts().UseBuiltinIncludes &&
Index: tools/libclang/CMakeLists.txt
===================================================================
--- tools/libclang/CMakeLists.txt	(revision 170308)
+++ tools/libclang/CMakeLists.txt	(working copy)
@@ -88,8 +88,12 @@
   endif()
 
   if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+# for system gcc-4.0.1
     set(LIBCLANG_LINK_FLAGS
       "-Wl,-compatibility_version -Wl,1 -Wl,-dead_strip")
+# for gcc-fsf-4.6 only:
+#    set(LIBCLANG_LINK_FLAGS
+#      "-Wl,-dylib_compatibility_version -Wl,1 -Wl,-dead_strip -Wl,-seg1addr -Wl,0xE0000000")
     set_target_properties(libclang
       PROPERTIES
       LINK_FLAGS "${LIBCLANG_LINK_FLAGS}"
Index: tools/libclang/CIndex.cpp
===================================================================
--- tools/libclang/CIndex.cpp	(revision 170308)
+++ tools/libclang/CIndex.cpp	(working copy)
@@ -6134,7 +6134,8 @@
 
   // FIXME: Move to llvm/Support and make it cross-platform.
 #ifdef __APPLE__
-  setpriority(PRIO_DARWIN_THREAD, 0, PRIO_DARWIN_BG);
+// constants are not defined on darwin8
+//  setpriority(PRIO_DARWIN_THREAD, 0, PRIO_DARWIN_BG);
 #endif
 }
 
Index: lib/CodeGen/CGExpr.cpp
===================================================================
--- lib/CodeGen/CGExpr.cpp	(revision 170308)
+++ lib/CodeGen/CGExpr.cpp	(working copy)
@@ -31,6 +31,9 @@
 using namespace clang;
 using namespace CodeGen;
 
+#define	ENABLE_STACKTRACE		0
+#include "llvm/Support/stacktrace.h"
+
 //===--------------------------------------------------------------------===//
 //                        Miscellaneous Helper Methods
 //===--------------------------------------------------------------------===//
@@ -1078,7 +1081,7 @@
                                         QualType Ty,
                                         llvm::MDNode *TBAAInfo,
                                         bool isInit) {
-  
+  STACKTRACE_VERBOSE;
   // Handle vectors differently to get better performance.
   if (Ty->isVectorType()) {
     llvm::Type *SrcTy = Value->getType();
@@ -1127,6 +1130,7 @@
 
 void CodeGenFunction::EmitStoreOfScalar(llvm::Value *value, LValue lvalue,
     bool isInit) {
+  STACKTRACE_VERBOSE;
   EmitStoreOfScalar(value, lvalue.getAddress(), lvalue.isVolatile(),
                     lvalue.getAlignment().getQuantity(), lvalue.getType(),
                     lvalue.getTBAAInfo(), isInit);
@@ -1241,6 +1245,7 @@
 /// lvalue, where both are guaranteed to the have the same type, and that type
 /// is 'Ty'.
 void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit) {
+  STACKTRACE_VERBOSE;
   if (!Dst.isSimple()) {
     if (Dst.isVectorElt()) {
       // Read/modify/write the vector, inserting the new element.
Index: lib/Tooling/Tooling.cpp
===================================================================
--- lib/Tooling/Tooling.cpp	(revision 170308)
+++ lib/Tooling/Tooling.cpp	(working copy)
@@ -33,6 +33,9 @@
 #  include <unistd.h>
 #endif
 
+#define	ENABLE_STACKTRACE		0
+#include "llvm/Support/stacktrace.h"
+
 namespace clang {
 namespace tooling {
 
@@ -104,6 +107,7 @@
 bool runToolOnCodeWithArgs(clang::FrontendAction *ToolAction, const Twine &Code,
                            const std::vector<std::string> &Args,
                            const Twine &FileName) {
+  STACKTRACE_VERBOSE;
   SmallString<16> FileNameStorage;
   StringRef FileNameRef = FileName.toNullTerminatedStringRef(FileNameStorage);
   std::vector<std::string> Commands;
@@ -155,6 +159,7 @@
 }
 
 bool ToolInvocation::run() {
+  STACKTRACE_VERBOSE;
   std::vector<const char*> Argv;
   for (int I = 0, E = CommandLine.size(); I != E; ++I)
     Argv.push_back(CommandLine[I].c_str());
@@ -188,6 +193,7 @@
     clang::driver::Compilation *Compilation,
     clang::CompilerInvocation *Invocation,
     const clang::driver::ArgStringList &CC1Args) {
+  STACKTRACE_VERBOSE;
   // Show the invocation, with -v.
   if (Invocation->getHeaderSearchOpts().Verbose) {
     llvm::errs() << "clang Invocation:\n";
@@ -270,6 +276,7 @@
 }
 
 int ClangTool::run(FrontendActionFactory *ActionFactory) {
+  STACKTRACE_VERBOSE;
   // Exists solely for the purpose of lookup of the resource path.
   // This just needs to be some symbol in the binary.
   static int StaticSymbol;
Index: lib/Serialization/CMakeLists.txt
===================================================================
--- lib/Serialization/CMakeLists.txt	(revision 170308)
+++ lib/Serialization/CMakeLists.txt	(working copy)
@@ -31,3 +31,10 @@
 target_link_libraries(clangSerialization
   clangSema
   )
+
+# target_link_libraries(clangSerialization
+#  clangAST
+#  clangBasic
+#  clangSema
+#  LLVMSupport
+#)
Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp
===================================================================
--- lib/FrontendTool/ExecuteCompilerInvocation.cpp	(revision 170308)
+++ lib/FrontendTool/ExecuteCompilerInvocation.cpp	(working copy)
@@ -29,6 +29,9 @@
 #include "llvm/Support/ErrorHandling.h"
 using namespace clang;
 
+#define	ENABLE_STACKTRACE			0
+#include "llvm/Support/stacktrace.h"
+
 static FrontendAction *CreateFrontendBaseAction(CompilerInstance &CI) {
   using namespace clang::frontend;
   StringRef Action("unknown");
@@ -174,6 +177,7 @@
 }
 
 bool clang::ExecuteCompilerInvocation(CompilerInstance *Clang) {
+  STACKTRACE_VERBOSE;
   // Honor -help.
   if (Clang->getFrontendOpts().ShowHelp) {
     OwningPtr<driver::OptTable> Opts(driver::createDriverOptTable());
Index: lib/Frontend/ASTUnit.cpp
===================================================================
--- lib/Frontend/ASTUnit.cpp	(revision 170308)
+++ lib/Frontend/ASTUnit.cpp	(working copy)
@@ -49,6 +49,9 @@
 #include <sys/stat.h>
 using namespace clang;
 
+#define	ENABLE_STACKTRACE		0
+#include "llvm/Support/stacktrace.h"
+
 using llvm::TimeRecord;
 
 namespace {
@@ -1055,6 +1058,7 @@
 /// \returns True if a failure occurred that causes the ASTUnit not to
 /// contain any translation-unit information, false otherwise.
 bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) {
+  STACKTRACE_VERBOSE;
   delete SavedMainFileBuffer;
   SavedMainFileBuffer = 0;
   
@@ -1343,6 +1347,7 @@
                               const CompilerInvocation &PreambleInvocationIn,
                                                            bool AllowRebuild,
                                                            unsigned MaxLines) {
+  STACKTRACE_VERBOSE;
   
   IntrusiveRefCntPtr<CompilerInvocation>
     PreambleInvocation(new CompilerInvocation(PreambleInvocationIn));
@@ -1723,6 +1728,7 @@
                                     bool IncludeBriefCommentsInCodeCompletion,
                                              bool UserFilesAreVolatile,
                                              OwningPtr<ASTUnit> *ErrAST) {
+  STACKTRACE_VERBOSE;
   assert(CI && "A CompilerInvocation is required");
 
   OwningPtr<ASTUnit> OwnAST;
@@ -2323,6 +2329,7 @@
                            SourceManager &SourceMgr, FileManager &FileMgr,
                    SmallVectorImpl<StoredDiagnostic> &StoredDiagnostics,
              SmallVectorImpl<const llvm::MemoryBuffer *> &OwnedBuffers) {
+  STACKTRACE_VERBOSE;
   if (!Invocation)
     return;
 
Index: lib/Frontend/CompilerInstance.cpp
===================================================================
--- lib/Frontend/CompilerInstance.cpp	(revision 170308)
+++ lib/Frontend/CompilerInstance.cpp	(working copy)
@@ -47,8 +47,12 @@
 
 using namespace clang;
 
+#define	ENABLE_STACKTRACE		0
+#include "llvm/Support/stacktrace.h"
+
 CompilerInstance::CompilerInstance()
   : Invocation(new CompilerInvocation()), ModuleManager(0) {
+  STACKTRACE_VERBOSE;
 }
 
 CompilerInstance::~CompilerInstance() {
@@ -659,6 +663,7 @@
 // High-Level Operations
 
 bool CompilerInstance::ExecuteAction(FrontendAction &Act) {
+  STACKTRACE_VERBOSE;
   assert(hasDiagnostics() && "Diagnostics engine is not initialized!");
   assert(!getFrontendOpts().ShowHelp && "Client must handle '-help'!");
   assert(!getFrontendOpts().ShowVersion && "Client must handle '-version'!");
@@ -754,6 +759,7 @@
 /// \brief Helper function that executes the module-generating action under
 /// a crash recovery context.
 static void doCompileMapModule(void *UserData) {
+  STACKTRACE_VERBOSE;
   CompileModuleMapData &Data
     = *reinterpret_cast<CompileModuleMapData *>(UserData);
   Data.Instance.ExecuteAction(Data.CreateModuleAction);
@@ -765,6 +771,7 @@
                           SourceLocation ImportLoc,
                           Module *Module,
                           StringRef ModuleFileName) {
+  STACKTRACE_VERBOSE;
   llvm::LockFileManager Locked(ModuleFileName);
   switch (Locked) {
   case llvm::LockFileManager::LFS_Error:
@@ -894,6 +901,7 @@
                              ModuleIdPath Path,
                              Module::NameVisibilityKind Visibility,
                              bool IsInclusionDirective) {
+  STACKTRACE_VERBOSE;
   // If we've already handled this import, just return the cached result.
   // This one-element cache is important to eliminate redundant diagnostics
   // when both the preprocessor and parser see the same import declaration.
Index: lib/Frontend/ChainedIncludesSource.cpp
===================================================================
--- lib/Frontend/ChainedIncludesSource.cpp	(revision 170308)
+++ lib/Frontend/ChainedIncludesSource.cpp	(working copy)
@@ -25,6 +25,9 @@
 
 using namespace clang;
 
+#define	ENABLE_STACKTRACE		0
+#include "llvm/Support/stacktrace.h"
+
 static ASTReader *createASTReader(CompilerInstance &CI,
                                   StringRef pchFile,  
                                   SmallVector<llvm::MemoryBuffer *, 4> &memBufs,
@@ -62,6 +65,7 @@
 }
 
 ChainedIncludesSource *ChainedIncludesSource::create(CompilerInstance &CI) {
+  STACKTRACE_VERBOSE;
 
   std::vector<std::string> &includes = CI.getPreprocessorOpts().ChainedIncludes;
   assert(!includes.empty() && "No '-chain-include' in options!");
@@ -73,6 +77,7 @@
   SmallVector<std::string, 4> serialBufNames;
 
   for (unsigned i = 0, e = includes.size(); i != e; ++i) {
+    STACKTRACE_INDENT_PRINT("i = " << i << std::endl);
     bool firstInclude = (i == 0);
     OwningPtr<CompilerInvocation> CInvok;
     CInvok.reset(new CompilerInvocation(CI.getInvocation()));
Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp	(revision 170308)
+++ lib/Frontend/CompilerInvocation.cpp	(working copy)
@@ -32,6 +32,9 @@
 #include "llvm/Support/Path.h"
 using namespace clang;
 
+#define	ENABLE_STACKTRACE		0
+#include "llvm/Support/stacktrace.h"
+
 //===----------------------------------------------------------------------===//
 // Initialization.
 //===----------------------------------------------------------------------===//
@@ -40,7 +43,9 @@
   : LangOpts(new LangOptions()), TargetOpts(new TargetOptions()),
     DiagnosticOpts(new DiagnosticOptions()),
     HeaderSearchOpts(new HeaderSearchOptions()),
-    PreprocessorOpts(new PreprocessorOptions()) {}
+    PreprocessorOpts(new PreprocessorOptions()) {
+	STACKTRACE_VERBOSE;
+}
 
 CompilerInvocationBase::CompilerInvocationBase(const CompilerInvocationBase &X)
   : RefCountedBase<CompilerInvocation>(),
@@ -48,7 +53,9 @@
     TargetOpts(new TargetOptions(X.getTargetOpts())),
     DiagnosticOpts(new DiagnosticOptions(X.getDiagnosticOpts())),
     HeaderSearchOpts(new HeaderSearchOptions(X.getHeaderSearchOpts())),
-    PreprocessorOpts(new PreprocessorOptions(X.getPreprocessorOpts())) {}
+    PreprocessorOpts(new PreprocessorOptions(X.getPreprocessorOpts())) {
+	STACKTRACE_VERBOSE;
+}
 
 //===----------------------------------------------------------------------===//
 // Deserialization (from args)
@@ -1413,6 +1420,7 @@
 }
 
 static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args) {
+  STACKTRACE_VERBOSE;
   using namespace options;
   Opts.ABI = Args.getLastArgValue(OPT_target_abi);
   Opts.CXXABI = Args.getLastArgValue(OPT_cxx_abi);
@@ -1422,8 +1430,10 @@
   Opts.Triple = llvm::Triple::normalize(Args.getLastArgValue(OPT_triple));
 
   // Use the default target triple if unspecified.
-  if (Opts.Triple.empty())
+  if (Opts.Triple.empty()) {
+    STACKTRACE_INDENT_PRINT("getDefaultTargetTriple()" << std::endl);
     Opts.Triple = llvm::sys::getDefaultTargetTriple();
+  }
 }
 
 //
@@ -1432,6 +1442,7 @@
                                         const char *const *ArgBegin,
                                         const char *const *ArgEnd,
                                         DiagnosticsEngine &Diags) {
+  STACKTRACE_VERBOSE;
   bool Success = true;
 
   // Parse the arguments.
Index: lib/Frontend/InitHeaderSearch.cpp
===================================================================
--- lib/Frontend/InitHeaderSearch.cpp	(revision 170308)
+++ lib/Frontend/InitHeaderSearch.cpp	(working copy)
@@ -344,28 +344,35 @@
 
     case llvm::Triple::ppc:
     case llvm::Triple::ppc64:
+// This is a local hack-only, do not submit or commit.
+/**
       AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
-                                  "powerpc-apple-darwin10", "", "ppc64",
+                                  "powerpc-apple-darwin8", "", "ppc64",
                                   triple);
+**/
       AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0",
-                                  "powerpc-apple-darwin10", "", "ppc64",
+                                  "powerpc-apple-darwin8", "", "ppc64",
                                   triple);
       break;
 
     case llvm::Triple::x86:
     case llvm::Triple::x86_64:
+/**
       AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
-                                  "i686-apple-darwin10", "", "x86_64", triple);
+                                  "i686-apple-darwin8", "", "x86_64", triple);
+**/
       AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0",
                                   "i686-apple-darwin8", "", "", triple);
       break;
 
     case llvm::Triple::arm:
     case llvm::Triple::thumb:
+/**
       AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
-                                  "arm-apple-darwin10", "v7", "", triple);
+                                  "arm-apple-darwin8", "v7", "", triple);
       AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
-                                  "arm-apple-darwin10", "v6", "", triple);
+                                  "arm-apple-darwin8", "v6", "", triple);
+**/
       break;
     }
     return;
Index: lib/Basic/TargetInfo.cpp
===================================================================
--- lib/Basic/TargetInfo.cpp	(revision 170308)
+++ lib/Basic/TargetInfo.cpp	(working copy)
@@ -21,11 +21,15 @@
 #include <cstdlib>
 using namespace clang;
 
+#define	ENABLE_STACKTRACE		0
+#include "llvm/Support/stacktrace.h"
+
 static const LangAS::Map DefaultAddrSpaceMap = { 0 };
 
 // TargetInfo Constructor.
 TargetInfo::TargetInfo(const std::string &T) : TargetOpts(), Triple(T)
 {
+  STACKTRACE_VERBOSE;
   // Set defaults.  Defaults are set for a 32-bit RISC platform, like PPC or
   // SPARC.  These should be overridden by concrete targets as needed.
   BigEndian = true;
Index: lib/Basic/Targets.cpp
===================================================================
--- lib/Basic/Targets.cpp	(revision 170308)
+++ lib/Basic/Targets.cpp	(working copy)
@@ -31,6 +31,9 @@
 #include <algorithm>
 using namespace clang;
 
+#define	ENABLE_STACKTRACE		0
+#include "llvm/Support/stacktrace.h"
+
 //===----------------------------------------------------------------------===//
 //  Common code shared among targets.
 //===----------------------------------------------------------------------===//
@@ -4515,11 +4518,14 @@
 //===----------------------------------------------------------------------===//
 
 static TargetInfo *AllocateTarget(const std::string &T) {
+  STACKTRACE_VERBOSE;
+  STACKTRACE_INDENT_PRINT("arg: " << T << std::endl);
   llvm::Triple Triple(T);
   llvm::Triple::OSType os = Triple.getOS();
 
   switch (Triple.getArch()) {
   default:
+    STACKTRACE_INDENT_PRINT("default -> NULL" << std::endl);
     return NULL;
 
   case llvm::Triple::hexagon:
@@ -4777,6 +4783,8 @@
 /// triple.
 TargetInfo *TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags,
                                          TargetOptions *Opts) {
+  STACKTRACE_VERBOSE;
+  STACKTRACE_INDENT_PRINT("Opts.Triple: " << Opts.Triple << std::endl);
   llvm::Triple Triple(Opts->Triple);
 
   // Construct the target
Index: lib/AST/ExprConstant.cpp
===================================================================
--- lib/AST/ExprConstant.cpp	(revision 170308)
+++ lib/AST/ExprConstant.cpp	(working copy)
@@ -2674,7 +2674,8 @@
     if (E->isArrow()) {
       if (!EvaluatePointer(E->getBase(), Result, this->Info))
         return false;
-      BaseTy = E->getBase()->getType()->castAs<PointerType>()->getPointeeType();
+      BaseTy = E->getBase()->getType()->template castAs<PointerType>()
+		->getPointeeType();
     } else if (E->getBase()->isRValue()) {
       assert(E->getBase()->getType()->isRecordType());
       if (!EvaluateTemporary(E->getBase(), Result, this->Info))
Index: lib/Driver/Driver.cpp
===================================================================
--- lib/Driver/Driver.cpp	(revision 170308)
+++ lib/Driver/Driver.cpp	(working copy)
@@ -37,6 +37,9 @@
 // if it were included before system_error.h.
 #include "clang/Config/config.h"
 
+#define	ENABLE_STACKTRACE		0
+#include "llvm/Support/stacktrace.h"
+
 using namespace clang::driver;
 using namespace clang;
 
@@ -230,6 +233,7 @@
 }
 
 Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
+  STACKTRACE_VERBOSE;
   llvm::PrettyStackTraceString CrashInfo("Compilation construction");
 
   // FIXME: Handle environment options which affect driver behavior, somewhere
@@ -1317,6 +1321,7 @@
                                 bool AtTopLevel,
                                 const char *LinkingOutput,
                                 InputInfo &Result) const {
+  STACKTRACE_VERBOSE;
   llvm::PrettyStackTraceString CrashInfo("Building compilation jobs");
 
   if (const InputAction *IA = dyn_cast<InputAction>(A)) {
@@ -1611,6 +1616,7 @@
 static llvm::Triple computeTargetTriple(StringRef DefaultTargetTriple,
                                         const ArgList &Args,
                                         StringRef DarwinArchName) {
+  STACKTRACE_VERBOSE;
   // FIXME: Already done in Compilation *Driver::BuildCompilation
   if (const Arg *A = Args.getLastArg(options::OPT_target))
     DefaultTargetTriple = A->getValue();
@@ -1662,8 +1668,12 @@
 
 const ToolChain &Driver::getToolChain(const ArgList &Args,
                                       StringRef DarwinArchName) const {
+  STACKTRACE_VERBOSE;
+  STACKTRACE_INDENT_PRINT("DefaultTargetTriple: " << DefaultTargetTriple << std::endl);
+  STACKTRACE_INDENT_PRINT("DarwinArchName: " << DarwinArchName.str() << std::endl);
   llvm::Triple Target = computeTargetTriple(DefaultTargetTriple, Args,
                                             DarwinArchName);
+  STACKTRACE_INDENT_PRINT("computed Target: " << Target.str() << std::endl);
 
   ToolChain *&TC = ToolChains[Target.str()];
   if (!TC) {
@@ -1676,6 +1686,14 @@
     case llvm::Triple::IOS:
       if (Target.getArch() == llvm::Triple::x86 ||
           Target.getArch() == llvm::Triple::x86_64 ||
+#if 1
+	// uncomment this to use DarwinClang driver for ppc family
+          Target.getArch() == llvm::Triple::ppc ||
+          Target.getArch() == llvm::Triple::ppc64 ||
+	// see bugs:
+	// http://llvm.org/bugs/show_bug.cgi?id=14387
+	// http://llvm.org/bugs/show_bug.cgi?id=14275
+#endif
           Target.getArch() == llvm::Triple::arm ||
           Target.getArch() == llvm::Triple::thumb)
         TC = new toolchains::DarwinClang(*this, Target);
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp	(revision 170308)
+++ lib/Driver/Tools.cpp	(working copy)
@@ -37,6 +37,9 @@
 using namespace clang::driver::tools;
 using namespace clang;
 
+#define	ENABLE_STACKTRACE		0
+#include "llvm/Support/stacktrace.h"
+
 /// CheckPreprocessingOptions - Perform some validation of preprocessing
 /// arguments that is shared with gcc.
 static void CheckPreprocessingOptions(const Driver &D, const ArgList &Args) {
@@ -3744,6 +3747,7 @@
 // Hexagon tools end.
 
 llvm::Triple::ArchType darwin::getArchTypeForDarwinArchName(StringRef Str) {
+  STACKTRACE_VERBOSE;
   // See arch(3) and llvm-gcc's driver-driver.c. We don't implement support for
   // archs which Darwin doesn't use.
 
@@ -3873,6 +3877,14 @@
 
   // 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?
Index: lib/Driver/ToolChains.cpp
===================================================================
--- lib/Driver/ToolChains.cpp	(revision 170308)
+++ lib/Driver/ToolChains.cpp	(working copy)
@@ -40,6 +40,9 @@
 using namespace clang::driver::toolchains;
 using namespace clang;
 
+#define	ENABLE_STACKTRACE		0
+#include "llvm/Support/stacktrace.h"
+
 /// Darwin - Darwin tool chain for i386 and x86_64.
 
 Darwin::Darwin(const Driver &D, const llvm::Triple& Triple)
@@ -616,6 +619,7 @@
 
 DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args,
                                       const char *BoundArch) const {
+  STACKTRACE_VERBOSE;
   DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
   const OptTable &Opts = getDriver().getOpts();
 
@@ -758,6 +762,7 @@
     const Option MCpu = Opts.getOption(options::OPT_mcpu_EQ);
     const Option MArch = Opts.getOption(options::OPT_march_EQ);
 
+    STACKTRACE_INDENT_PRINT("switch-case(Name): " << Name.str() << std::endl);
     // This code must be kept in sync with LLVM's getArchTypeForDarwinArch,
     // which defines the list of which architectures we accept.
     if (Name == "ppc")
Index: lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
===================================================================
--- lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp	(revision 170308)
+++ lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp	(working copy)
@@ -17,6 +17,9 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 
+#define	ENABLE_STACKTRACE		0
+#include "llvm/Support/stacktrace.h"
+
 namespace clang {
 
 namespace ento {
Index: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===================================================================
--- lib/StaticAnalyzer/Core/RangeConstraintManager.cpp	(revision 170308)
+++ lib/StaticAnalyzer/Core/RangeConstraintManager.cpp	(working copy)
@@ -21,6 +21,9 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 
+#define	ENABLE_STACKTRACE		0
+#include "llvm/Support/stacktrace.h"
+
 using namespace clang;
 using namespace ento;
 
Index: lib/StaticAnalyzer/Core/APSIntType.cpp
===================================================================
--- lib/StaticAnalyzer/Core/APSIntType.cpp	(revision 170308)
+++ lib/StaticAnalyzer/Core/APSIntType.cpp	(working copy)
@@ -9,6 +9,9 @@
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h"
 
+#define	ENABLE_STACKTRACE		0
+#include "llvm/Support/stacktrace.h"
+
 using namespace clang;
 using namespace ento;
 
Index: include/clang/Serialization/ASTReader.h
===================================================================
--- include/clang/Serialization/ASTReader.h	(revision 170308)
+++ include/clang/Serialization/ASTReader.h	(working copy)
@@ -276,10 +276,12 @@
   FileManager &FileMgr;
   DiagnosticsEngine &Diags;
 
+public:	// workaround to grant access to classes nested within ASTDeclReader
   /// \brief The semantic analysis object that will be processing the
   /// AST files and the translation unit that uses it.
   Sema *SemaObj;
 
+private:
   /// \brief The preprocessor that will be loading the source file.
   Preprocessor &PP;
 
@@ -792,6 +794,7 @@
   /// since the last time the declaration chains were linked.
   llvm::SmallPtrSet<Decl *, 16> RedeclsDeserialized;
   
+public:	// workaround to grant access to classes nested within ASTDeclReader
   /// \brief The list of redeclaration chains that still need to be 
   /// reconstructed.
   ///
@@ -803,6 +806,7 @@
   /// \brief Keeps track of the elements added to PendingDeclChains.
   llvm::SmallSet<serialization::DeclID, 16> PendingDeclChainsKnown;
 
+private:
   /// \brief The set of Objective-C categories that have been deserialized
   /// since the last time the declaration chains were linked.
   llvm::SmallPtrSet<ObjCCategoryDecl *, 16> CategoriesDeserialized;
Index: include/clang/Serialization/ASTBitCodes.h
===================================================================
--- include/clang/Serialization/ASTBitCodes.h	(revision 170308)
+++ include/clang/Serialization/ASTBitCodes.h	(working copy)
@@ -83,21 +83,21 @@
 
     /// \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);
       }
Index: include/clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h
===================================================================
--- include/clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h	(revision 170308)
+++ include/clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h	(working copy)
@@ -21,11 +21,16 @@
   bool IsUnsigned;
 
 public:
+  /// \brief Sanity check for possible unreasonable values
+  void sane_BitWidth(void) const {
+//    assert(BitWidth <= 99999);	// disable when not debugging
+  }
+
   APSIntType(uint32_t Width, bool Unsigned)
-    : BitWidth(Width), IsUnsigned(Unsigned) {}
+    : BitWidth(Width), IsUnsigned(Unsigned) { sane_BitWidth(); }
 
   /* implicit */ APSIntType(const llvm::APSInt &Value)
-    : BitWidth(Value.getBitWidth()), IsUnsigned(Value.isUnsigned()) {}
+    : BitWidth(Value.getBitWidth()), IsUnsigned(Value.isUnsigned()) { sane_BitWidth(); }
 
   uint32_t getBitWidth() const { return BitWidth; }
   bool isUnsigned() const { return IsUnsigned; }
@@ -53,6 +58,7 @@
 
   /// Returns an all-zero value for this type.
   llvm::APSInt getZeroValue() const LLVM_READONLY {
+    sane_BitWidth();
     return llvm::APSInt(BitWidth, IsUnsigned);
   }
 
