Skip to content

Commit 18049d7

Browse files
authored
Merge pull request #8330 from apple/jan_svoboda/reduce-upstream-diff
[clang] Reduce upstream diff
2 parents ad3bf04 + dba2a21 commit 18049d7

30 files changed

+224
-254
lines changed

clang/include/clang/APINotes/APINotesReader.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ class APINotesReader {
6161
llvm::SmallVector<std::pair<llvm::VersionTuple, T>, 1> Results;
6262

6363
/// The index of the result that is the "selected" set based on the desired
64-
/// Swift version, or \c Results.size() if nothing matched.
65-
unsigned Selected;
64+
/// Swift version, or null if nothing matched.
65+
std::optional<unsigned> Selected;
6666

6767
public:
6868
/// Form an empty set of versioned information.
69-
VersionedInfo(std::nullopt_t) : Selected(0) {}
69+
VersionedInfo(std::nullopt_t) : Selected(std::nullopt) {}
7070

7171
/// Form a versioned info set given the desired version and a set of
7272
/// results.
@@ -75,17 +75,14 @@ class APINotesReader {
7575
llvm::SmallVector<std::pair<llvm::VersionTuple, T>, 1> Results);
7676

7777
/// Retrieve the selected index in the result set.
78-
std::optional<unsigned> getSelected() const {
79-
if (Selected == Results.size())
80-
return std::nullopt;
81-
return Selected;
82-
}
78+
std::optional<unsigned> getSelected() const { return Selected; }
8379

8480
/// Return the number of versioned results we know about.
8581
unsigned size() const { return Results.size(); }
8682

8783
/// Access all versioned results.
8884
const std::pair<llvm::VersionTuple, T> *begin() const {
85+
assert(!Results.empty());
8986
return Results.begin();
9087
}
9188
const std::pair<llvm::VersionTuple, T> *end() const {
@@ -94,6 +91,7 @@ class APINotesReader {
9491

9592
/// Access a specific versioned result.
9693
const std::pair<llvm::VersionTuple, T> &operator[](unsigned index) const {
94+
assert(index < Results.size());
9795
return Results[index];
9896
}
9997
};

clang/include/clang/APINotes/APINotesWriter.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@
2222

2323
#include <memory>
2424

25-
namespace llvm {
26-
class raw_ostream;
27-
}
28-
2925
namespace clang {
3026
class FileEntry;
3127

clang/include/clang/APINotes/Types.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,10 @@ class CommonTypeInfo : public CommonEntityInfo {
148148
return SwiftBridge;
149149
}
150150

151-
void setSwiftBridge(const std::optional<std::string> &SwiftType) {
151+
void setSwiftBridge(std::optional<std::string> SwiftType) {
152152
SwiftBridge = SwiftType;
153153
}
154154

155-
void setSwiftBridge(const std::optional<llvm::StringRef> &SwiftType) {
156-
SwiftBridge = SwiftType
157-
? std::optional<std::string>(std::string(*SwiftType))
158-
: std::nullopt;
159-
}
160-
161155
const std::optional<std::string> &getNSErrorDomain() const {
162156
return NSErrorDomain;
163157
}
@@ -767,15 +761,9 @@ inline bool operator==(const TypedefInfo &LHS, const TypedefInfo &RHS) {
767761
inline bool operator!=(const TypedefInfo &LHS, const TypedefInfo &RHS) {
768762
return !(LHS == RHS);
769763
}
770-
} // namespace api_notes
771-
} // namespace clang
772764

773-
#include "llvm/ADT/ArrayRef.h"
774-
775-
namespace clang {
776-
namespace api_notes {
777765
/// The file extension used for the source representation of API notes.
778-
static const char SOURCE_APINOTES_EXTENSION[] = "apinotes";
766+
static const constexpr char SOURCE_APINOTES_EXTENSION[] = "apinotes";
779767

780768
/// Opaque context ID used to refer to an Objective-C class or protocol or a C++
781769
/// namespace.

clang/include/clang/Basic/Attr.td

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2653,47 +2653,6 @@ def Regparm : TypeAttr {
26532653
let ASTNode = 0;
26542654
}
26552655

2656-
def SwiftImportAsNonGeneric : InheritableAttr {
2657-
// This attribute has no spellings as it is only ever created implicitly
2658-
// from API notes.
2659-
let Spellings = [];
2660-
let SemaHandler = 0;
2661-
let Documentation = [InternalOnly];
2662-
}
2663-
2664-
def SwiftImportPropertyAsAccessors : InheritableAttr {
2665-
// This attribute has no spellings as it is only ever created implicitly
2666-
// from API notes.
2667-
let Spellings = [];
2668-
let SemaHandler = 0;
2669-
let Documentation = [InternalOnly];
2670-
}
2671-
2672-
def SwiftVersioned : Attr {
2673-
// This attribute has no spellings as it is only ever created implicitly
2674-
// from API notes.
2675-
let Spellings = [];
2676-
let Args = [VersionArgument<"Version">, AttrArgument<"AttrToAdd">,
2677-
BoolArgument<"IsReplacedByActive">];
2678-
let SemaHandler = 0;
2679-
let Documentation = [InternalOnly];
2680-
}
2681-
2682-
def SwiftVersionedRemoval : Attr {
2683-
// This attribute has no spellings as it is only ever created implicitly
2684-
// from API notes.
2685-
let Spellings = [];
2686-
let Args = [VersionArgument<"Version">, UnsignedArgument<"RawKind">,
2687-
BoolArgument<"IsReplacedByActive">];
2688-
let SemaHandler = 0;
2689-
let Documentation = [InternalOnly];
2690-
let AdditionalMembers = [{
2691-
attr::Kind getAttrKindToRemove() const {
2692-
return static_cast<attr::Kind>(getRawKind());
2693-
}
2694-
}];
2695-
}
2696-
26972656
def SwiftAsyncName : InheritableAttr {
26982657
let Spellings = [GNU<"swift_async_name">];
26992658
let Args = [StringArgument<"Name">];
@@ -2741,6 +2700,22 @@ def SwiftError : InheritableAttr {
27412700
let Documentation = [SwiftErrorDocs];
27422701
}
27432702

2703+
def SwiftImportAsNonGeneric : InheritableAttr {
2704+
// This attribute has no spellings as it is only ever created implicitly
2705+
// from API notes.
2706+
let Spellings = [];
2707+
let SemaHandler = 0;
2708+
let Documentation = [InternalOnly];
2709+
}
2710+
2711+
def SwiftImportPropertyAsAccessors : InheritableAttr {
2712+
// This attribute has no spellings as it is only ever created implicitly
2713+
// from API notes.
2714+
let Spellings = [];
2715+
let SemaHandler = 0;
2716+
let Documentation = [InternalOnly];
2717+
}
2718+
27442719
def SwiftName : InheritableAttr {
27452720
let Spellings = [GNU<"swift_name">];
27462721
let Args = [StringArgument<"Name">];
@@ -2762,6 +2737,31 @@ def SwiftPrivate : InheritableAttr {
27622737
let SimpleHandler = 1;
27632738
}
27642739

2740+
def SwiftVersioned : Attr {
2741+
// This attribute has no spellings as it is only ever created implicitly
2742+
// from API notes.
2743+
let Spellings = [];
2744+
let Args = [VersionArgument<"Version">, AttrArgument<"AttrToAdd">,
2745+
BoolArgument<"IsReplacedByActive">];
2746+
let SemaHandler = 0;
2747+
let Documentation = [InternalOnly];
2748+
}
2749+
2750+
def SwiftVersionedRemoval : Attr {
2751+
// This attribute has no spellings as it is only ever created implicitly
2752+
// from API notes.
2753+
let Spellings = [];
2754+
let Args = [VersionArgument<"Version">, UnsignedArgument<"RawKind">,
2755+
BoolArgument<"IsReplacedByActive">];
2756+
let SemaHandler = 0;
2757+
let Documentation = [InternalOnly];
2758+
let AdditionalMembers = [{
2759+
attr::Kind getAttrKindToRemove() const {
2760+
return static_cast<attr::Kind>(getRawKind());
2761+
}
2762+
}];
2763+
}
2764+
27652765
def NoDeref : TypeAttr {
27662766
let Spellings = [Clang<"noderef">];
27672767
let Documentation = [NoDerefDocs];

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4614,8 +4614,8 @@ def warn_attr_swift_name_decl_missing_params
46144614
InGroup<SwiftNameAttribute>;
46154615

46164616
def err_attr_swift_error_no_error_parameter : Error<
4617-
"%0 attribute can only be applied to a %select{function|method}1 "
4618-
"with an error parameter">;
4617+
"%0 attribute can only be applied to a %select{function|method}1 with an "
4618+
"error parameter">;
46194619
def err_attr_swift_error_return_type : Error<
46204620
"%0 attribute with '%1' convention can only be applied to a "
46214621
"%select{function|method}2 returning %select{an integral type|a pointer}3">;
@@ -10876,7 +10876,7 @@ let CategoryName = "API Notes Issue" in {
1087610876
def err_incompatible_replacement_type : Error<
1087710877
"API notes replacement type %0 has a different size from original type %1">;
1087810878

10879-
}
10879+
} // end of API Notes category
1088010880

1088110881
let CategoryName = "OpenMP Issue" in {
1088210882
// OpenMP support.

clang/include/clang/Basic/LangOptions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ LANGOPT(ApplePragmaPack, 1, 0, "Apple gcc-compatible #pragma pack handling")
423423
LANGOPT(XLPragmaPack, 1, 0, "IBM XL #pragma pack handling")
424424

425425
LANGOPT(RetainCommentsFromSystemHeaders, 1, 0, "retain documentation comments from system headers in the AST")
426+
426427
LANGOPT(APINotes, 1, 0, "use external API notes")
427428
LANGOPT(APINotesModules, 1, 0, "use module-based external API notes")
428429
LANGOPT(NeededByPCHOrCompilationUsesPCH, 1, 0, "compilation involves pch")

clang/include/clang/Basic/TokenKinds.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ KEYWORD(__objc_yes , KEYALL)
337337
KEYWORD(__objc_no , KEYALL)
338338
KEYWORD(__ptrauth , KEYALL)
339339

340+
340341
// C++ 2.11p1: Keywords.
341342
KEYWORD(asm , KEYCXX|KEYGNU)
342343
KEYWORD(bool , BOOLSUPPORT|KEYC23)

clang/include/clang/CodeGen/BackendUtil.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#include "clang/Basic/LLVM.h"
1313
#include "llvm/IR/ModuleSummaryIndex.h"
14-
#include "llvm/Support/VirtualFileSystem.h"
1514
#include <memory>
1615

1716
namespace llvm {

clang/include/clang/CodeGen/ConstantInitBuilder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class PointerAuthSchema;
3030
class QualType;
3131

3232
namespace CodeGen {
33+
3334
class CodeGenModule;
3435

3536
/// A convenience builder class for complex constant initializers,

clang/include/clang/Driver/Action.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class Action {
7777
LinkerWrapperJobClass,
7878
StaticLibJobClass,
7979
BinaryAnalyzeJobClass,
80+
8081
JobClassFirst = DepscanJobClass,
8182
JobClassLast = BinaryAnalyzeJobClass
8283
};

0 commit comments

Comments
 (0)