Skip to content

Commit 99147a8

Browse files
authored
Merge pull request swiftlang#33917 from CodaFi/taking-a-header
(Re)-Disable End Of Pipeline Actions for ObjC Actions
2 parents 3c49e46 + 618b0b9 commit 99147a8

12 files changed

+71
-10
lines changed

include/swift/Basic/SourceManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class SourceManager {
169169

170170
/// Returns a buffer ID for a previously added buffer with the given
171171
/// buffer identifier, or None if there is no such buffer.
172-
Optional<unsigned> getIDForBufferIdentifier(StringRef BufIdentifier);
172+
Optional<unsigned> getIDForBufferIdentifier(StringRef BufIdentifier) const;
173173

174174
/// Returns the identifier for the buffer with the given ID.
175175
///

include/swift/Frontend/FrontendInputsAndOutputs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ class FrontendInputsAndOutputs {
153153
bool shouldTreatAsLLVM() const;
154154
bool shouldTreatAsSIL() const;
155155
bool shouldTreatAsModuleInterface() const;
156+
bool shouldTreatAsObjCHeader() const;
156157

157158
bool areAllNonPrimariesSIB() const;
158159

include/swift/Frontend/FrontendOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ class FrontendOptions {
304304
/// \return true if the given action requires input files to be provided.
305305
static bool doesActionRequireInputs(ActionType action);
306306

307+
/// \return true if the given action requires input files to be provided.
308+
static bool doesActionPerformEndOfPipelineActions(ActionType action);
309+
307310
/// Return a hash code of any components from these options that should
308311
/// contribute to a Swift Bridging PCH hash.
309312
llvm::hash_code getPCHHashComponents() const {

include/swift/Frontend/InputFile.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ enum class InputFileKind {
2626
SwiftLibrary,
2727
SwiftModuleInterface,
2828
SIL,
29-
LLVM
29+
LLVM,
30+
ObjCHeader,
3031
};
3132

3233
// Inputs may include buffers that override contents, and eventually should

lib/Basic/SourceLoc.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,8 @@ SourceManager::getVirtualFile(SourceLoc Loc) const {
152152
return nullptr;
153153
}
154154

155-
156-
Optional<unsigned> SourceManager::getIDForBufferIdentifier(
157-
StringRef BufIdentifier) {
155+
Optional<unsigned>
156+
SourceManager::getIDForBufferIdentifier(StringRef BufIdentifier) const {
158157
auto It = BufIdentIDMap.find(BufIdentifier);
159158
if (It == BufIdentIDMap.end())
160159
return None;

lib/Frontend/ArgsToFrontendOptionsConverter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,8 @@ bool ArgsToFrontendOptionsConverter::setUpInputKindAndImmediateArgs() {
423423
Opts.InputKind = InputFileKind::SIL;
424424
else if (Opts.InputsAndOutputs.shouldTreatAsLLVM())
425425
Opts.InputKind = InputFileKind::LLVM;
426+
else if (Opts.InputsAndOutputs.shouldTreatAsObjCHeader())
427+
Opts.InputKind = InputFileKind::ObjCHeader;
426428
else if (Opts.InputsAndOutputs.shouldTreatAsModuleInterface())
427429
Opts.InputKind = InputFileKind::SwiftModuleInterface;
428430
else if (Args.hasArg(OPT_parse_as_library))

lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ SourceFileKind CompilerInvocation::getSourceFileKind() const {
238238
return SourceFileKind::SIL;
239239
case InputFileKind::None:
240240
case InputFileKind::LLVM:
241+
case InputFileKind::ObjCHeader:
241242
llvm_unreachable("Trying to convert from unsupported InputFileKind");
242243
}
243244

lib/Frontend/Frontend.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,7 @@ static bool shouldTreatSingleInputAsMain(InputFileKind inputKind) {
586586
return true;
587587
case InputFileKind::SwiftLibrary:
588588
case InputFileKind::LLVM:
589+
case InputFileKind::ObjCHeader:
589590
case InputFileKind::None:
590591
return false;
591592
}

lib/Frontend/FrontendInputsAndOutputs.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,19 @@ bool FrontendInputsAndOutputs::shouldTreatAsSIL() const {
199199
llvm_unreachable("Either all primaries or none must end with .sil");
200200
}
201201

202+
bool FrontendInputsAndOutputs::shouldTreatAsObjCHeader() const {
203+
if (hasSingleInput()) {
204+
StringRef InputExt = llvm::sys::path::extension(getFilenameOfFirstInput());
205+
switch (file_types::lookupTypeForExtension(InputExt)) {
206+
case file_types::TY_ObjCHeader:
207+
return true;
208+
default:
209+
return false;
210+
}
211+
}
212+
return false;
213+
}
214+
202215
bool FrontendInputsAndOutputs::areAllNonPrimariesSIB() const {
203216
for (const InputFile &input : AllInputs) {
204217
if (input.isPrimary())

lib/Frontend/FrontendOptions.cpp

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ bool FrontendOptions::needsProperModuleName(ActionType action) {
4242
case ActionType::DumpScopeMaps:
4343
case ActionType::DumpTypeRefinementContexts:
4444
case ActionType::DumpPCM:
45-
return false;
4645
case ActionType::EmitPCH:
46+
return false;
4747
case ActionType::EmitSILGen:
4848
case ActionType::EmitSIL:
4949
case ActionType::EmitSIBGen:
@@ -171,6 +171,47 @@ bool FrontendOptions::doesActionRequireInputs(ActionType action) {
171171
llvm_unreachable("Unknown ActionType");
172172
}
173173

174+
bool FrontendOptions::doesActionPerformEndOfPipelineActions(ActionType action) {
175+
switch (action) {
176+
case ActionType::NoneAction:
177+
case ActionType::PrintVersion:
178+
case ActionType::EmitPCH:
179+
case ActionType::EmitPCM:
180+
case ActionType::DumpPCM:
181+
return false;
182+
case ActionType::REPL:
183+
case ActionType::Parse:
184+
case ActionType::DumpParse:
185+
case ActionType::EmitSyntax:
186+
case ActionType::DumpInterfaceHash:
187+
case ActionType::EmitImportedModules:
188+
case ActionType::ScanDependencies:
189+
case ActionType::ScanClangDependencies:
190+
case ActionType::CompileModuleFromInterface:
191+
case ActionType::TypecheckModuleFromInterface:
192+
case ActionType::ResolveImports:
193+
case ActionType::Typecheck:
194+
case ActionType::DumpAST:
195+
case ActionType::PrintAST:
196+
case ActionType::DumpScopeMaps:
197+
case ActionType::DumpTypeRefinementContexts:
198+
case ActionType::EmitSILGen:
199+
case ActionType::EmitSIL:
200+
case ActionType::EmitModuleOnly:
201+
case ActionType::MergeModules:
202+
case ActionType::EmitSIBGen:
203+
case ActionType::EmitSIB:
204+
case ActionType::Immediate:
205+
case ActionType::EmitAssembly:
206+
case ActionType::EmitIR:
207+
case ActionType::EmitBC:
208+
case ActionType::EmitObject:
209+
case ActionType::DumpTypeInfo:
210+
return true;
211+
}
212+
llvm_unreachable("Unknown ActionType");
213+
}
214+
174215
void FrontendOptions::forAllOutputPaths(
175216
const InputFile &input, llvm::function_ref<void(StringRef)> fn) const {
176217
if (RequestedAction != FrontendOptions::ActionType::EmitModuleOnly &&

0 commit comments

Comments
 (0)