Skip to content

Commit 64f5b45

Browse files
authored
Merge pull request #12263 from modocache/remove-old-input-type-arg-code-and-fixme
2 parents 9497049 + 3f8e808 commit 64f5b45

File tree

3 files changed

+15
-26
lines changed

3 files changed

+15
-26
lines changed

include/swift/Driver/ToolChain.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ class ToolChain {
167167
const OutputInfo &OI) const;
168168

169169
/// Return the default language type to use for the given extension.
170+
/// If the extension is empty or is otherwise not recognized, return
171+
/// the invalid type \c TY_INVALID.
170172
virtual types::ID lookupTypeForExtension(StringRef Ext) const;
171173

172174
/// Check whether a clang library with a given name exists.

include/swift/Driver/Types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ namespace types {
3636
StringRef getTypeTempSuffix(ID Id);
3737

3838
/// Lookup the type to use for the file extension \p Ext.
39+
/// If the extension is empty or is otherwise not recognized, return
40+
/// the invalid type \c TY_INVALID.
3941
ID lookupTypeForExtension(StringRef Ext);
4042

4143
/// Lookup the type to use for the name \p Name.

lib/Driver/Driver.cpp

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -926,39 +926,26 @@ static bool checkInputExistence(const Driver &D, const DerivedArgList &Args,
926926
void Driver::buildInputs(const ToolChain &TC,
927927
const DerivedArgList &Args,
928928
InputFileList &Inputs) const {
929-
types::ID InputType = types::TY_Nothing;
930-
Arg *InputTypeArg = nullptr;
931-
932929
llvm::StringMap<StringRef> SourceFileNames;
933930

934931
for (Arg *A : Args) {
935932
if (A->getOption().getKind() == Option::InputClass) {
936933
StringRef Value = A->getValue();
937934
types::ID Ty = types::TY_INVALID;
938935

939-
if (InputType == types::TY_Nothing) {
940-
// If there was an explicit arg for this, claim it.
941-
if (InputTypeArg)
942-
InputTypeArg->claim();
943-
944-
// stdin must be handled specially.
945-
if (Value.equals("-")) {
946-
// By default, treat stdin as Swift input.
947-
// FIXME: should we limit this inference to specific modes?
948-
Ty = types::TY_Swift;
949-
} else {
950-
// Otherwise lookup by extension.
951-
Ty = TC.lookupTypeForExtension(llvm::sys::path::extension(Value));
936+
// stdin must be handled specially.
937+
if (Value.equals("-")) {
938+
// By default, treat stdin as Swift input.
939+
Ty = types::TY_Swift;
940+
} else {
941+
// Otherwise lookup by extension.
942+
Ty = TC.lookupTypeForExtension(llvm::sys::path::extension(Value));
952943

953-
if (Ty == types::TY_INVALID) {
954-
// FIXME: should we adjust this inference in certain modes?
955-
Ty = types::TY_Object;
956-
}
944+
if (Ty == types::TY_INVALID) {
945+
// By default, treat inputs with no extension, or with an
946+
// extension that isn't recognized, as object files.
947+
Ty = types::TY_Object;
957948
}
958-
} else {
959-
assert(InputTypeArg && "InputType set w/o InputTypeArg");
960-
InputTypeArg->claim();
961-
Ty = InputType;
962949
}
963950

964951
if (checkInputExistence(*this, Args, Diags, Value))
@@ -973,8 +960,6 @@ void Driver::buildInputs(const ToolChain &TC,
973960
}
974961
}
975962
}
976-
977-
// FIXME: add -x support (or equivalent)
978963
}
979964
}
980965

0 commit comments

Comments
 (0)