[libclang] When loading an AST file, make sure to apply the language options
to the target info.

Related to rdar://12069503.

llvm-svn: 163931
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 42a6772..d0aadfd 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -525,6 +525,8 @@
     Context.InitBuiltinTypes(*Target);
     
     InitializedLanguage = true;
+
+    applyLangOptsToTarget();
     return false;
   }
 
@@ -541,6 +543,8 @@
     TargetOpts.Features.clear();
     TargetOpts.Triple = Triple;
     Target = TargetInfo::CreateTargetInfo(PP.getDiagnostics(), TargetOpts);
+
+    applyLangOptsToTarget();
     return false;
   }
 
@@ -562,6 +566,17 @@
   virtual void ReadCounter(unsigned Value) {
     Counter = Value;
   }
+
+private:
+  void applyLangOptsToTarget() {
+    if (Target && InitializedLanguage) {
+      // Inform the target of the language options.
+      //
+      // FIXME: We shouldn't need to do this, the target should be immutable once
+      // created. This complexity should be lifted elsewhere.
+      Target->setForcedLangOptions(LangOpt);
+    }
+  }
 };
 
 class StoredDiagnosticConsumer : public DiagnosticConsumer {