mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user