mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
FrontendInputs data structure redo.
- Outlaw duplicate input files, fix driver, fix tests, and add test. - Reflect that no buffer is present without a (possibly pseudo) named file. - Reflect fact that every input has a (possible pseudo) name. - Break up CompilerInstance::setup. Don't bail on dups.
This commit is contained in:
@@ -771,13 +771,14 @@ private:
|
||||
|
||||
static bool makeParserAST(CompilerInstance &CI, StringRef Text,
|
||||
CompilerInvocation Invocation) {
|
||||
Invocation.clearInputs();
|
||||
Invocation.getFrontendOptions().Inputs.clearInputs();
|
||||
Invocation.setModuleName("main");
|
||||
Invocation.setInputKind(InputFileKind::IFK_Swift);
|
||||
|
||||
std::unique_ptr<llvm::MemoryBuffer> Buf;
|
||||
Buf = llvm::MemoryBuffer::getMemBuffer(Text, "<module-interface>");
|
||||
Invocation.addInputBuffer(Buf.get());
|
||||
Invocation.getFrontendOptions().Inputs.addInput(
|
||||
InputFile(Buf.get()->getBufferIdentifier(), false, Buf.get()));
|
||||
if (CI.setup(Invocation))
|
||||
return true;
|
||||
CI.performParseOnly();
|
||||
@@ -1091,8 +1092,8 @@ static bool reportSourceDocInfo(CompilerInvocation Invocation,
|
||||
|
||||
EditorDiagConsumer DiagConsumer;
|
||||
CI.addDiagnosticConsumer(&DiagConsumer);
|
||||
|
||||
Invocation.addInputBuffer(InputBuf);
|
||||
Invocation.getFrontendOptions().Inputs.addInput(
|
||||
InputFile(InputBuf->getBufferIdentifier(), false, InputBuf));
|
||||
if (CI.setup(Invocation))
|
||||
return true;
|
||||
DiagConsumer.setInputBufferIDs(CI.getInputBufferIDs());
|
||||
@@ -1364,7 +1365,8 @@ SourceFile *SwiftLangSupport::getSyntacticSourceFile(
|
||||
return nullptr;
|
||||
}
|
||||
Invocation.setInputKind(InputFileKind::IFK_Swift);
|
||||
Invocation.addInputBuffer(InputBuf);
|
||||
Invocation.getFrontendOptions().Inputs.addInput(
|
||||
InputFile(InputBuf->getBufferIdentifier(), false, InputBuf));
|
||||
|
||||
if (ParseCI.setup(Invocation)) {
|
||||
Error = "Compiler invocation set up failed";
|
||||
@@ -1439,7 +1441,7 @@ findModuleGroups(StringRef ModuleName, ArrayRef<const char *> Args,
|
||||
StringRef Error)> Receiver) {
|
||||
CompilerInvocation Invocation;
|
||||
Invocation.getClangImporterOptions().ImportForwardDeclarations = true;
|
||||
Invocation.clearInputs();
|
||||
Invocation.getFrontendOptions().Inputs.clearInputs();
|
||||
|
||||
CompilerInstance CI;
|
||||
// Display diagnostics to stderr.
|
||||
|
||||
Reference in New Issue
Block a user