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

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