[cfe-commits] r163931 - in /cfe/trunk: lib/Frontend/ASTUnit.cpp test/Index/index-pch.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Fri Sep 14 13:24:53 PDT 2012
Author: akirtzidis
Date: Fri Sep 14 15:24:53 2012
New Revision: 163931
URL: http://llvm.org/viewvc/llvm-project?rev=163931&view=rev
Log:
[libclang] When loading an AST file, make sure to apply the language options
to the target info.
Related to rdar://12069503.
Added:
cfe/trunk/test/Index/index-pch.cpp
Modified:
cfe/trunk/lib/Frontend/ASTUnit.cpp
Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=163931&r1=163930&r2=163931&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Fri Sep 14 15:24:53 2012
@@ -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 {
Added: cfe/trunk/test/Index/index-pch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-pch.cpp?rev=163931&view=auto
==============================================================================
--- cfe/trunk/test/Index/index-pch.cpp (added)
+++ cfe/trunk/test/Index/index-pch.cpp Fri Sep 14 15:24:53 2012
@@ -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
More information about the cfe-commits
mailing list