Index: tools/libclang/CMakeLists.txt
===================================================================
--- tools/libclang/CMakeLists.txt	(revision 167161)
+++ 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 167161)
+++ tools/libclang/CIndex.cpp	(working copy)
@@ -6142,7 +6142,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/Serialization/CMakeLists.txt
===================================================================
--- lib/Serialization/CMakeLists.txt	(revision 167161)
+++ 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/ASTMatchers/CMakeLists.txt
===================================================================
--- lib/ASTMatchers/CMakeLists.txt	(revision 167161)
+++ lib/ASTMatchers/CMakeLists.txt	(working copy)
@@ -15,3 +15,6 @@
   ClangDiagnosticCommon
   ClangStmtNodes
   )
+target_link_libraries(clangASTMatchers
+  clangAST
+)
Index: lib/Frontend/InitHeaderSearch.cpp
===================================================================
--- lib/Frontend/InitHeaderSearch.cpp	(revision 167161)
+++ lib/Frontend/InitHeaderSearch.cpp	(working copy)
@@ -345,28 +345,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/Rewrite/Frontend/CMakeLists.txt
===================================================================
--- lib/Rewrite/Frontend/CMakeLists.txt	(revision 167161)
+++ lib/Rewrite/Frontend/CMakeLists.txt	(working copy)
@@ -25,4 +25,5 @@
   clangAST
   clangParse
   clangFrontend
+  clangRewriteCore
   )
Index: lib/AST/ExprConstant.cpp
===================================================================
--- lib/AST/ExprConstant.cpp	(revision 167161)
+++ lib/AST/ExprConstant.cpp	(working copy)
@@ -2673,7 +2673,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: include/clang/Serialization/ASTReader.h
===================================================================
--- include/clang/Serialization/ASTReader.h	(revision 167161)
+++ include/clang/Serialization/ASTReader.h	(working copy)
@@ -275,10 +275,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;
 
@@ -798,6 +800,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.
   ///
@@ -809,6 +812,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 167161)
+++ 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);
       }
