Updates for LLVM merge to r171906 on 20130108.

Change-Id: I4cf3718041d8876d4a23a412b6b4fa4226ec3b50
diff --git a/slang.cpp b/slang.cpp
index 1775563..d0a6744 100644
--- a/slang.cpp
+++ b/slang.cpp
@@ -25,6 +25,7 @@
 #include "clang/AST/ASTContext.h"
 
 #include "clang/Basic/DiagnosticIDs.h"
+#include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
 #include "clang/Basic/LangOptions.h"
@@ -33,14 +34,15 @@
 #include "clang/Basic/TargetOptions.h"
 
 #include "clang/Frontend/CodeGenOptions.h"
-#include "clang/Frontend/DiagnosticOptions.h"
 #include "clang/Frontend/DependencyOutputOptions.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Frontend/Utils.h"
 
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Lex/HeaderSearch.h"
+#include "clang/Lex/HeaderSearchOptions.h"
 
 #include "clang/Parse/ParseAST.h"
 
@@ -84,7 +86,7 @@
 
     // llvm-rs-cc need this.
     new clang::TextDiagnosticPrinter(llvm::errs(),
-                                     clang::DiagnosticOptions());
+                                     new clang::DiagnosticOptions());
   }
 } ForceSlangLinking;
 
@@ -174,18 +176,18 @@
 void Slang::createTarget(const std::string &Triple, const std::string &CPU,
                          const std::vector<std::string> &Features) {
   if (!Triple.empty())
-    mTargetOpts.Triple = Triple;
+    mTargetOpts->Triple = Triple;
   else
-    mTargetOpts.Triple = DEFAULT_TARGET_TRIPLE_STRING;
+    mTargetOpts->Triple = DEFAULT_TARGET_TRIPLE_STRING;
 
   if (!CPU.empty())
-    mTargetOpts.CPU = CPU;
+    mTargetOpts->CPU = CPU;
 
   if (!Features.empty())
-    mTargetOpts.Features = Features;
+    mTargetOpts->FeaturesAsWritten = Features;
 
   mTarget.reset(clang::TargetInfo::CreateTargetInfo(*mDiagEngine,
-                                                    mTargetOpts));
+                                                    mTargetOpts.getPtr()));
 }
 
 void Slang::createFileManager() {
@@ -199,12 +201,18 @@
 
 void Slang::createPreprocessor() {
   // Default only search header file in current dir
-  clang::HeaderSearch *HeaderInfo = new clang::HeaderSearch(*mFileMgr,
+  llvm::IntrusiveRefCntPtr<clang::HeaderSearchOptions> HSOpts =
+      new clang::HeaderSearchOptions();
+  clang::HeaderSearch *HeaderInfo = new clang::HeaderSearch(HSOpts,
+                                                            *mFileMgr,
                                                             *mDiagEngine,
                                                             LangOpts,
                                                             mTarget.get());
 
-  mPP.reset(new clang::Preprocessor(*mDiagEngine,
+  llvm::IntrusiveRefCntPtr<clang::PreprocessorOptions> PPOpts =
+      new clang::PreprocessorOptions();
+  mPP.reset(new clang::Preprocessor(PPOpts,
+                                    *mDiagEngine,
                                     LangOpts,
                                     mTarget.get(),
                                     *mSourceMgr,
@@ -249,11 +257,12 @@
 clang::ASTConsumer *
 Slang::createBackend(const clang::CodeGenOptions& CodeGenOpts,
                      llvm::raw_ostream *OS, OutputType OT) {
-  return new Backend(mDiagEngine, CodeGenOpts, mTargetOpts,
+  return new Backend(mDiagEngine, CodeGenOpts, getTargetOptions(),
                      &mPragmas, OS, OT);
 }
 
 Slang::Slang() : mInitialized(false), mDiagClient(NULL), mOT(OT_Default) {
+  mTargetOpts = new clang::TargetOptions();
   GlobalInitialization();
 }
 
@@ -277,12 +286,13 @@
   mInitialized = true;
 }
 
-clang::Module *Slang::loadModule(clang::SourceLocation ImportLoc,
-                                 clang::ModuleIdPath Path,
-                                 clang::Module::NameVisibilityKind Visibility,
-                                 bool IsInclusionDirective) {
+clang::ModuleLoadResult Slang::loadModule(
+    clang::SourceLocation ImportLoc,
+    clang::ModuleIdPath Path,
+    clang::Module::NameVisibilityKind Visibility,
+    bool IsInclusionDirective) {
   slangAssert(0 && "Not implemented");
-  return NULL;
+  return clang::ModuleLoadResult();
 }
 
 bool Slang::setInputSource(llvm::StringRef InputFile,
@@ -454,9 +464,9 @@
 
 void Slang::setDebugMetadataEmission(bool EmitDebug) {
   if (EmitDebug)
-    CodeGenOpts.DebugInfo = clang::CodeGenOptions::FullDebugInfo;
+    CodeGenOpts.setDebugInfo(clang::CodeGenOptions::FullDebugInfo);
   else
-    CodeGenOpts.DebugInfo = clang::CodeGenOptions::NoDebugInfo;
+    CodeGenOpts.setDebugInfo(clang::CodeGenOptions::NoDebugInfo);
 }
 
 void Slang::setOptimizationLevel(llvm::CodeGenOpt::Level OptimizationLevel) {