Skip to content

Commit 440b174

Browse files
authored
[APINotes] Upstream Sema logic to apply API Notes to decls
This upstreams more of the Clang API Notes functionality that is currently implemented in the Apple fork: https://github.com/apple/llvm-project/tree/next/clang/lib/APINotes This was extracted from a larger PR: #73017
1 parent 046682e commit 440b174

File tree

10 files changed

+1030
-1
lines changed

10 files changed

+1030
-1
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10760,6 +10760,13 @@ def warn_imp_cast_drops_unaligned : Warning<
1076010760

1076110761
} // end of sema category
1076210762

10763+
let CategoryName = "API Notes Issue" in {
10764+
10765+
def err_incompatible_replacement_type : Error<
10766+
"API notes replacement type %0 has a different size from original type %1">;
10767+
10768+
} // end of API Notes category
10769+
1076310770
let CategoryName = "OpenMP Issue" in {
1076410771
// OpenMP support.
1076510772
def err_omp_expected_var_arg : Error<

clang/include/clang/Sema/Sema.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4883,6 +4883,12 @@ class Sema final {
48834883
bool checkCommonAttributeFeatures(const Stmt *S, const ParsedAttr &A,
48844884
bool SkipArgCountCheck = false);
48854885

4886+
/// Map any API notes provided for this declaration to attributes on the
4887+
/// declaration.
4888+
///
4889+
/// Triggered by declaration-attribute processing.
4890+
void ProcessAPINotes(Decl *D);
4891+
48864892
/// Determine if type T is a valid subject for a nonnull and similar
48874893
/// attributes. By default, we look through references (the behavior used by
48884894
/// nonnull), but if the second parameter is true, then we treat a reference

clang/lib/Sema/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ add_clang_library(clangSema
2727
Sema.cpp
2828
SemaAccess.cpp
2929
SemaAttr.cpp
30+
SemaAPINotes.cpp
3031
SemaAvailability.cpp
3132
SemaCXXScopeSpec.cpp
3233
SemaCast.cpp

0 commit comments

Comments
 (0)