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:
David Ungar
2017-12-03 14:39:01 -08:00
parent 2cda5a91c5
commit 28b206008f
30 changed files with 585 additions and 591 deletions

View File

@@ -228,13 +228,14 @@ public:
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();
@@ -401,7 +402,7 @@ SwiftInterfaceGenContext::create(StringRef DocumentName,
// Display diagnostics to stderr.
CI.addDiagnosticConsumer(&IFaceGenCtx->Impl.DiagConsumer);
Invocation.clearInputs();
Invocation.getFrontendOptions().Inputs.clearInputs();
if (CI.setup(Invocation)) {
ErrMsg = "Error during invocation setup";
return nullptr;