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

to the target info.

Related to rdar://12069503.

llvm-svn: 163931
This commit is contained in:
Argyrios Kyrtzidis 2012-09-14 20:24:53 +00:00
parent 06fb5f0cc2
commit 9e1fb5632a
2 changed files with 21 additions and 0 deletions

View File

@ -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 {

View File

@ -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