Add CompilerInvocation::loadFromSerializedAST.

This is mainly for the debugger's use, to set up CompilerInvocations that
match how a particular app was compiled in certain important ways. Today
that's the target (which is also in the binary), the SDK path (which in
the long run should probably be an SDK name), and any random -Xcc options
we need to pass (which we should probably attempt to minimize).

Because there's only one target and SDK per context, and because -Xcc
options can easily conflict, this is only intended to be used once per
CompilerInvocation.

Note that search paths are not covered by this; they are already being
added at the time the module is loaded. See r24545.

Completes rdar://problem/17670778.

Swift SVN r25227
This commit is contained in:
Jordan Rose
2015-02-12 05:32:37 +00:00
parent dbd3b60f6b
commit 6e96e26a81
4 changed files with 66 additions and 2 deletions

View File

@@ -1008,3 +1008,24 @@ bool CompilerInvocation::parseArgs(ArrayRef<const char *> Args,
return false;
}
serialization::Status
CompilerInvocation::loadFromSerializedAST(StringRef data) {
serialization::ExtendedValidationInfo extendedInfo;
serialization::ValidationInfo info =
serialization::validateSerializedAST(data, &extendedInfo);
if (info.status != serialization::Status::Valid)
return info.status;
setTargetTriple(info.targetTriple);
if (!extendedInfo.getSDKPath().empty())
setSDKPath(extendedInfo.getSDKPath());
auto &extraClangArgs = getClangImporterOptions().ExtraArgs;
extraClangArgs.insert(extraClangArgs.end(),
extendedInfo.getExtraClangImporterOptions().begin(),
extendedInfo.getExtraClangImporterOptions().end());
return info.status;
}