mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
For the options that specifies the output, it should be cache invariant. Fix the one remaining option that is not correctly labelled and add an unittest to make sure all the options with output path naming convertion are correctly marked as CacheInvariant. rdar://146155049
41 lines
1.5 KiB
C++
41 lines
1.5 KiB
C++
//===--- 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));
|
|
}
|
|
}
|