Skip to content

[Caching] Mark -emit-module-source-info-path as CacheInvariant #79779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/swift/Option/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -730,12 +730,12 @@ def avoid_emit_module_source_info :
def emit_module_source_info_path :
Separate<["-"], "emit-module-source-info-path">,
Flags<[FrontendOption, NoInteractiveOption, ArgumentIsPath,
SupplementaryOutput]>,
SupplementaryOutput, CacheInvariant]>,
MetaVarName<"<path>">, HelpText<"Output module source info file to <path>">;
def emit_variant_module_source_info_path :
Separate<["-"], "emit-variant-module-source-info-path">,
Flags<[FrontendOption, NoInteractiveOption, ArgumentIsPath,
SupplementaryOutput, NewDriverOnlyOption]>,
SupplementaryOutput, NewDriverOnlyOption, CacheInvariant]>,
MetaVarName<"<path>">, HelpText<"Output module source info file for the target variant to <path>">;

def emit_parseable_module_interface :
Expand Down
3 changes: 3 additions & 0 deletions unittests/Basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ add_swift_unittest(SwiftBasicTests
ImmutablePointerSetTest.cpp
JSONSerialization.cpp
OptionSetTest.cpp
Options.cpp
OwnedStringTest.cpp
MultiMapCacheTest.cpp
PointerIntEnumTest.cpp
Expand All @@ -48,8 +49,10 @@ add_dependencies(SwiftBasicTests "${gyb_dependency_targets}")
target_link_libraries(SwiftBasicTests
PRIVATE
swiftBasic
swiftOption
swiftThreading
clangBasic
LLVMOption
LLVMTestingSupport
)

Expand Down
40 changes: 40 additions & 0 deletions unittests/Basic/Options.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//===--- Options.cpp ------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

#include "swift/Option/Options.h"
#include "llvm/Option/Option.h"
#include "gtest/gtest.h"

using namespace swift;
using namespace swift::options;

TEST(Options, outputPathCacheInvariant) {
auto optTable = createSwiftOptTable();
// 0 is OP_INVALD
for (auto id = 1; id < LastOption; ++id) {
auto opt = optTable->getOption(id);
// Only check the flag accepted by swift-frontend.
if (!opt.hasFlag(SwiftFlags::FrontendOption))
continue;

// The following two options are only accepted by migrator.
if (id == OPT_emit_migrated_file_path || id == OPT_emit_remap_file_path)
continue;

auto name = opt.getName();
// Check that if a flag matches the convention `-emit-*-path{=}`, it should
// be a path to an output file and should be marked as cache invariant.
if (name.starts_with("emit") &&
(name.ends_with("-path") || name.ends_with("-path=")))
ASSERT_TRUE(opt.hasFlag(SwiftFlags::CacheInvariant));
}
}