Updated to Clang 3.5a.

Change-Id: I8127eb568f674c2e72635b639a3295381fe8af82
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 84a5d2c..5d4b5fc 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,7 +1,10 @@
 if(NOT CLANG_BUILD_EXAMPLES)
   set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL ON)
+  set(EXCLUDE_FROM_ALL ON)
 endif()
 
+if(CLANG_ENABLE_STATIC_ANALYZER)
 add_subdirectory(analyzer-plugin)
+endif()
 add_subdirectory(clang-interpreter)
 add_subdirectory(PrintFunctionNames)
diff --git a/examples/PrintFunctionNames/CMakeLists.txt b/examples/PrintFunctionNames/CMakeLists.txt
index ba6a350..876b5da 100644
--- a/examples/PrintFunctionNames/CMakeLists.txt
+++ b/examples/PrintFunctionNames/CMakeLists.txt
@@ -1,24 +1,12 @@
-set(MODULE TRUE)
+# If we don't need RTTI or EH, there's no reason to export anything
+# from the plugin.
+if( NOT WIN32 ) # Win32 mangles symbols differently, and
+                # PrintFunctionNames.export contains C++ symbols.
+  if( NOT LLVM_REQUIRES_RTTI )
+    if( NOT LLVM_REQUIRES_EH )
+      set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/PrintFunctionNames.exports)
+    endif()
+  endif()
+endif()
 
-set( LLVM_LINK_COMPONENTS support mc)
-
-add_clang_library(PrintFunctionNames PrintFunctionNames.cpp)
-
-add_dependencies(PrintFunctionNames
-  ClangAttrClasses
-  ClangAttrList
-  ClangCommentNodes
-  ClangDeclNodes
-  ClangDiagnosticCommon
-  ClangStmtNodes
-  )
-
-target_link_libraries(PrintFunctionNames
-  clangFrontend
-  clangAST
-  )
-
-set_target_properties(PrintFunctionNames
-  PROPERTIES
-  LINKER_LANGUAGE CXX
-  PREFIX "")
+add_llvm_loadable_module(PrintFunctionNames PrintFunctionNames.cpp)
diff --git a/examples/PrintFunctionNames/Makefile b/examples/PrintFunctionNames/Makefile
index 23a5305..5865098 100644
--- a/examples/PrintFunctionNames/Makefile
+++ b/examples/PrintFunctionNames/Makefile
@@ -19,7 +19,7 @@
 endif
 
 LINK_LIBS_IN_SHARED = 0
-SHARED_LIBRARY = 1
+LOADABLE_MODULE = 1
 
 include $(CLANG_LEVEL)/Makefile
 
diff --git a/examples/PrintFunctionNames/PrintFunctionNames.cpp b/examples/PrintFunctionNames/PrintFunctionNames.cpp
index f6e75cc..3f18cd4 100644
--- a/examples/PrintFunctionNames/PrintFunctionNames.cpp
+++ b/examples/PrintFunctionNames/PrintFunctionNames.cpp
@@ -48,9 +48,9 @@
       // Example error handling.
       if (args[i] == "-an-error") {
         DiagnosticsEngine &D = CI.getDiagnostics();
-        unsigned DiagID = D.getCustomDiagID(
-          DiagnosticsEngine::Error, "invalid argument '" + args[i] + "'");
-        D.Report(DiagID);
+        unsigned DiagID = D.getCustomDiagID(DiagnosticsEngine::Error,
+                                            "invalid argument '%0'");
+        D.Report(DiagID) << args[i];
         return false;
       }
     }
diff --git a/examples/analyzer-plugin/CMakeLists.txt b/examples/analyzer-plugin/CMakeLists.txt
index ba73030..b2a20e1 100644
--- a/examples/analyzer-plugin/CMakeLists.txt
+++ b/examples/analyzer-plugin/CMakeLists.txt
@@ -1,23 +1 @@
-set(MODULE TRUE)
-
-set( LLVM_LINK_COMPONENTS support mc)
-
-add_clang_library(SampleAnalyzerPlugin MainCallChecker.cpp)
-
-add_dependencies(SampleAnalyzerPlugin
-  ClangAttrClasses
-  ClangAttrList
-  ClangCommentNodes
-  ClangDeclNodes
-  ClangDiagnosticCommon
-  ClangStmtNodes
-  )
-
-target_link_libraries(SampleAnalyzerPlugin
-  clangStaticAnalyzerCore
-  )
-
-set_target_properties(SampleAnalyzerPlugin
-  PROPERTIES
-  LINKER_LANGUAGE CXX
-  PREFIX "")
+add_llvm_loadable_module(SampleAnalyzerPlugin MainCallChecker.cpp)
diff --git a/examples/analyzer-plugin/MainCallChecker.cpp b/examples/analyzer-plugin/MainCallChecker.cpp
index 8801f9a..2ad8c84 100644
--- a/examples/analyzer-plugin/MainCallChecker.cpp
+++ b/examples/analyzer-plugin/MainCallChecker.cpp
@@ -8,7 +8,7 @@
 
 namespace {
 class MainCallChecker : public Checker < check::PreStmt<CallExpr> > {
-  mutable OwningPtr<BugType> BT;
+  mutable std::unique_ptr<BugType> BT;
 
 public:
   void checkPreStmt(const CallExpr *CE, CheckerContext &C) const;
@@ -35,7 +35,7 @@
       return;
 
     if (!BT)
-      BT.reset(new BugType("call to main", "example analyzer plugin"));
+      BT.reset(new BugType(this, "call to main", "example analyzer plugin"));
 
     BugReport *report = new BugReport(*BT, BT->getName(), N);
     report->addRange(Callee->getSourceRange());
diff --git a/examples/clang-interpreter/CMakeLists.txt b/examples/clang-interpreter/CMakeLists.txt
index 451b4b8..10df7e7 100644
--- a/examples/clang-interpreter/CMakeLists.txt
+++ b/examples/clang-interpreter/CMakeLists.txt
@@ -1,15 +1,9 @@
 set(LLVM_LINK_COMPONENTS
-  jit
-  interpreter
+  Core
+  ExecutionEngine
+  JIT
+  Support
   nativecodegen
-  asmparser
-  bitreader
-  bitwriter
-  irreader
-  codegen
-  ipo
-  linker
-  selectiondag
   )
 
 add_clang_executable(clang-interpreter
@@ -21,19 +15,8 @@
   )
 
 target_link_libraries(clang-interpreter
-  clangFrontend
-  clangSerialization
-  clangDriver
-  clangCodeGen
-  clangSema
-  clangStaticAnalyzerFrontend
-  clangStaticAnalyzerCheckers
-  clangStaticAnalyzerCore
-  clangAnalysis
-  clangRewriteCore
-  clangRewriteFrontend
-  clangAST
-  clangParse
-  clangLex
   clangBasic
+  clangCodeGen
+  clangDriver
+  clangFrontend
   )
diff --git a/examples/clang-interpreter/Makefile b/examples/clang-interpreter/Makefile
index 55a8e6f..6494e9a 100644
--- a/examples/clang-interpreter/Makefile
+++ b/examples/clang-interpreter/Makefile
@@ -16,7 +16,7 @@
 TOOL_NO_EXPORTS = 1
 
 LINK_COMPONENTS := jit interpreter nativecodegen bitreader bitwriter irreader \
-	ipo linker selectiondag asmparser instrumentation option
+	ipo linker selectiondag asmparser instrumentation objcarcopts option
 USEDLIBS = clangFrontend.a clangSerialization.a clangDriver.a clangCodeGen.a \
            clangParse.a clangSema.a clangStaticAnalyzerFrontend.a \
            clangStaticAnalyzerCheckers.a clangStaticAnalyzerCore.a \
diff --git a/examples/clang-interpreter/main.cpp b/examples/clang-interpreter/main.cpp
index e00583d..713a650 100644
--- a/examples/clang-interpreter/main.cpp
+++ b/examples/clang-interpreter/main.cpp
@@ -16,7 +16,6 @@
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
-#include "llvm/ADT/OwningPtr.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
 #include "llvm/ExecutionEngine/JIT.h"
@@ -27,6 +26,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/raw_ostream.h"
+#include <memory>
 using namespace clang;
 using namespace clang::driver;
 
@@ -46,8 +46,8 @@
   llvm::InitializeNativeTarget();
 
   std::string Error;
-  OwningPtr<llvm::ExecutionEngine> EE(
-    llvm::ExecutionEngine::createJIT(Mod, &Error));
+  std::unique_ptr<llvm::ExecutionEngine> EE(
+      llvm::ExecutionEngine::createJIT(Mod, &Error));
   if (!EE) {
     llvm::errs() << "unable to make execution engine: " << Error << "\n";
     return 255;
@@ -83,7 +83,7 @@
   // (basically, exactly one input, and the operation mode is hard wired).
   SmallVector<const char *, 16> Args(argv, argv + argc);
   Args.push_back("-fsyntax-only");
-  OwningPtr<Compilation> C(TheDriver.BuildCompilation(Args));
+  std::unique_ptr<Compilation> C(TheDriver.BuildCompilation(Args));
   if (!C)
     return 0;
 
@@ -108,7 +108,7 @@
 
   // Initialize a compiler invocation object from the clang (-cc1) arguments.
   const driver::ArgStringList &CCArgs = Cmd->getArguments();
-  OwningPtr<CompilerInvocation> CI(new CompilerInvocation);
+  std::unique_ptr<CompilerInvocation> CI(new CompilerInvocation);
   CompilerInvocation::CreateFromArgs(*CI,
                                      const_cast<const char **>(CCArgs.data()),
                                      const_cast<const char **>(CCArgs.data()) +
@@ -126,7 +126,7 @@
 
   // Create a compiler instance to handle the actual work.
   CompilerInstance Clang;
-  Clang.setInvocation(CI.take());
+  Clang.setInvocation(CI.release());
 
   // Create the compilers actual diagnostics engine.
   Clang.createDiagnostics();
@@ -140,7 +140,7 @@
       CompilerInvocation::GetResourcesPath(argv[0], MainAddr);
 
   // Create and execute the frontend to generate an LLVM bitcode module.
-  OwningPtr<CodeGenAction> Act(new EmitLLVMOnlyAction());
+  std::unique_ptr<CodeGenAction> Act(new EmitLLVMOnlyAction());
   if (!Clang.ExecuteAction(*Act))
     return 1;