Skip to content

Commit 6e5aefc

Browse files
committed
Rename file_types::getTypeTempSuffix to getExtension
Let's be honest: this isn't just for temporary files. Also, it's not really a "suffix" if it doesn't include the leading dot. No functionality change.
1 parent 90ca430 commit 6e5aefc

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

include/swift/Frontend/FileTypes.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -21,7 +21,7 @@
2121
namespace swift {
2222
namespace file_types {
2323
enum ID : uint8_t {
24-
#define TYPE(NAME, ID, TEMP_SUFFIX, FLAGS) TY_##ID,
24+
#define TYPE(NAME, ID, EXTENSION, FLAGS) TY_##ID,
2525
#include "swift/Frontend/Types.def"
2626
#undef TYPE
2727
TY_INVALID
@@ -30,9 +30,9 @@ enum ID : uint8_t {
3030
/// Return the name of the type for \p Id.
3131
StringRef getTypeName(ID Id);
3232

33-
/// Return the suffix to use when creating a temp file of this type,
34-
/// or null if unspecified.
35-
StringRef getTypeTempSuffix(ID Id);
33+
/// Return the extension to use when creating a file of this type,
34+
/// or an empty string if unspecified.
35+
StringRef getExtension(ID Id);
3636

3737
/// Lookup the type to use for the file extension \p Ext.
3838
/// If the extension is empty or is otherwise not recognized, return

lib/Driver/Driver.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ createStatsReporter(const llvm::opt::InputArgList *ArgList,
724724
if (Inputs.size() == 1) {
725725
InputName = Inputs[0].second->getSpelling();
726726
}
727-
StringRef OutputType = file_types::getTypeTempSuffix(OI.CompilerOutputType);
727+
StringRef OutputType = file_types::getExtension(OI.CompilerOutputType);
728728
return llvm::make_unique<UnifiedStatsReporter>("swift-driver",
729729
OI.ModuleName,
730730
InputName,
@@ -2054,7 +2054,7 @@ static StringRef assignOutputName(Compilation &C, const JobAction *JA,
20542054
// We should output to a temporary file, since we're not at the top level
20552055
// (or are generating a bridging PCH, which is currently always a temp).
20562056
StringRef Stem = llvm::sys::path::stem(BaseName);
2057-
StringRef Suffix = file_types::getTypeTempSuffix(JA->getType());
2057+
StringRef Suffix = file_types::getExtension(JA->getType());
20582058
std::error_code EC = llvm::sys::fs::createTemporaryFile(Stem, Suffix, Buffer);
20592059
if (EC) {
20602060
Diags.diagnose(SourceLoc(), diag::error_unable_to_make_temporary_file,
@@ -2128,7 +2128,7 @@ static StringRef getOutputFilename(Compilation &C,
21282128
if (isa<GenerateDSYMJobAction>(JA)) {
21292129
Buffer = PrimaryInput;
21302130
Buffer.push_back('.');
2131-
Buffer.append(file_types::getTypeTempSuffix(JA->getType()));
2131+
Buffer.append(file_types::getExtension(JA->getType()));
21322132
return Buffer.str();
21332133
}
21342134

@@ -2171,7 +2171,7 @@ static StringRef getOutputFilename(Compilation &C,
21712171
return Buffer.str();
21722172
}
21732173

2174-
StringRef Suffix = file_types::getTypeTempSuffix(JA->getType());
2174+
StringRef Suffix = file_types::getExtension(JA->getType());
21752175
assert(Suffix.data() &&
21762176
"All types used for output should have a suffix.");
21772177

@@ -2241,7 +2241,7 @@ static void addAuxiliaryOutput(
22412241

22422242
bool isTempFile = C.isTemporaryFile(path);
22432243
llvm::sys::path::replace_extension(
2244-
path, file_types::getTypeTempSuffix(outputType));
2244+
path, file_types::getExtension(outputType));
22452245
output.setAdditionalOutputForType(outputType, path);
22462246
if (isTempFile)
22472247
C.addTemporaryFile(path);
@@ -2264,7 +2264,7 @@ static void addDiagFileOutputForPersistentPCHAction(
22642264
StringRef headerPath = output.getBaseInput(JA->getInputIndex());
22652265
StringRef stem = llvm::sys::path::stem(headerPath);
22662266
StringRef suffix =
2267-
file_types::getTypeTempSuffix(file_types::TY_SerializedDiagnostics);
2267+
file_types::getExtension(file_types::TY_SerializedDiagnostics);
22682268
SmallString<256> outPathBuf;
22692269

22702270
if (const Arg *A = C.getArgs().getLastArg(options::OPT_emit_module_path)) {
@@ -2724,7 +2724,8 @@ void Driver::chooseRemappingOutputPath(Compilation &C,
27242724
} else {
27252725
llvm::SmallString<128> Path(Output->getPrimaryOutputFilenames()[0]);
27262726
bool isTempFile = C.isTemporaryFile(Path);
2727-
llvm::sys::path::replace_extension(Path, "remap");
2727+
llvm::sys::path::replace_extension(Path,
2728+
file_types::getExtension(file_types::ID::TY_Remapping));
27282729
Output->setAdditionalOutputForType(file_types::ID::TY_Remapping, Path);
27292730
if (isTempFile)
27302731
C.addTemporaryFile(Path);

lib/Frontend/Types.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -22,7 +22,7 @@ using namespace swift::file_types;
2222
struct TypeInfo {
2323
const char *Name;
2424
const char *Flags;
25-
const char *TempSuffix;
25+
const char *Extension;
2626
};
2727

2828
static const TypeInfo TypeInfos[] = {
@@ -38,8 +38,8 @@ static const TypeInfo &getInfo(unsigned Id) {
3838

3939
StringRef file_types::getTypeName(ID Id) { return getInfo(Id).Name; }
4040

41-
StringRef file_types::getTypeTempSuffix(ID Id) {
42-
return getInfo(Id).TempSuffix;
41+
StringRef file_types::getExtension(ID Id) {
42+
return getInfo(Id).Extension;
4343
}
4444

4545
ID file_types::lookupTypeForExtension(StringRef Ext) {

0 commit comments

Comments
 (0)