mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
We had an exploded form of conformance attributes (@unchecked, @preconcurrency, @unsafe) at several different places in the compiler. Pull these into a single structure so it's easier to manage and extend. Should have done this a long time ago.
47 lines
1.4 KiB
C++
47 lines
1.4 KiB
C++
//===--- ConformanceLookup.h - Global conformance lookup --------*- C++ -*-===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2024 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SWIFT_AST_CONFORMANCEATTRIBUTES_H
|
|
#define SWIFT_AST_CONFORMANCEATTRIBUTES_H
|
|
|
|
#include "swift/Basic/SourceLoc.h"
|
|
|
|
namespace swift {
|
|
|
|
/// Describes all of the attributes that can occur on a conformance.
|
|
struct ConformanceAttributes {
|
|
/// The location of the "unchecked" attribute, if present.
|
|
SourceLoc uncheckedLoc;
|
|
|
|
/// The location of the "preconcurrency" attribute if present.
|
|
SourceLoc preconcurrencyLoc;
|
|
|
|
/// The location of the "unsafe" attribute if present.
|
|
SourceLoc unsafeLoc;
|
|
|
|
/// Merge other conformance attributes into this set.
|
|
ConformanceAttributes &
|
|
operator |=(const ConformanceAttributes &other) {
|
|
if (other.uncheckedLoc.isValid())
|
|
uncheckedLoc = other.uncheckedLoc;
|
|
if (other.preconcurrencyLoc.isValid())
|
|
preconcurrencyLoc = other.preconcurrencyLoc;
|
|
if (other.unsafeLoc.isValid())
|
|
unsafeLoc = other.unsafeLoc;
|
|
return *this;
|
|
}
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|