aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-09-14 20:24:53 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-09-14 20:24:53 +0000
commit7f1863326488813e7648845f3cec5225770b1a0b (patch)
tree9df3f62ed6078e5e704976cf187c7090160f1ad4
parentf8dcac5d6589414e646ae9cbf834f612510a08b1 (diff)
[libclang] When loading an AST file, make sure to apply the language options
to the target info. Related to rdar://12069503. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163931 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Frontend/ASTUnit.cpp15
-rw-r--r--test/Index/index-pch.cpp6
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp
index 42a67720c3..d0aadfd29e 100644
--- a/lib/Frontend/ASTUnit.cpp
+++ b/lib/Frontend/ASTUnit.cpp
@@ -525,6 +525,8 @@ public:
Context.InitBuiltinTypes(*Target);
InitializedLanguage = true;
+
+ applyLangOptsToTarget();
return false;
}
@@ -541,6 +543,8 @@ public:
TargetOpts.Features.clear();
TargetOpts.Triple = Triple;
Target = TargetInfo::CreateTargetInfo(PP.getDiagnostics(), TargetOpts);
+
+ applyLangOptsToTarget();
return false;
}
@@ -562,6 +566,17 @@ public:
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 {
diff --git a/test/Index/index-pch.cpp b/test/Index/index-pch.cpp
new file mode 100644
index 0000000000..c8da7b2fbf
--- /dev/null
+++ b/test/Index/index-pch.cpp
@@ -0,0 +1,6 @@
+// RUN: c-index-test -write-pch %t.pch -fshort-wchar %s
+// RUN: c-index-test -index-tu %t.pch | FileCheck %s
+
+const wchar_t *wideStr = L"123";
+
+// CHECK: [indexDeclaration]: kind: variable | name: wideStr