Skip to content

Commit 74e62f0

Browse files
committed
Merge from 'main' to 'sycl-web' (#2)
CONFLICT (content): Merge conflict in clang/lib/Sema/SemaDecl.cpp
2 parents 8d13123 + 419ef38 commit 74e62f0

File tree

16 files changed

+97
-438
lines changed

16 files changed

+97
-438
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4263,19 +4263,3 @@ def Builtin : InheritableAttr {
42634263
let SemaHandler = 0;
42644264
let Documentation = [Undocumented];
42654265
}
4266-
4267-
def EnforceTCB : InheritableAttr {
4268-
let Spellings = [Clang<"enforce_tcb">];
4269-
let Subjects = SubjectList<[Function]>;
4270-
let Args = [StringArgument<"TCBName">];
4271-
let Documentation = [EnforceTCBDocs];
4272-
bit InheritEvenIfAlreadyPresent = 1;
4273-
}
4274-
4275-
def EnforceTCBLeaf : InheritableAttr {
4276-
let Spellings = [Clang<"enforce_tcb_leaf">];
4277-
let Subjects = SubjectList<[Function]>;
4278-
let Args = [StringArgument<"TCBName">];
4279-
let Documentation = [EnforceTCBLeafDocs];
4280-
bit InheritEvenIfAlreadyPresent = 1;
4281-
}

clang/include/clang/Basic/AttrDocs.td

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6411,28 +6411,3 @@ Attribute docs`_, and `the GCC Inline docs`_.
64116411
}];
64126412
let Heading = "always_inline, __force_inline";
64136413
}
6414-
6415-
def EnforceTCBDocs : Documentation {
6416-
let Category = DocCatFunction;
6417-
let Content = [{
6418-
The ``enforce_tcb`` attribute can be placed on functions to enforce that a
6419-
trusted compute base (TCB) does not call out of the TCB. This generates a
6420-
warning every time a function not marked with an ``enforce_tcb`` attribute is
6421-
called from a function with the ``enforce_tcb`` attribute. A function may be a
6422-
part of multiple TCBs. Invocations through function pointers are currently
6423-
not checked. Builtins are considered to a part of every TCB.
6424-
6425-
- ``enforce_tcb(Name)`` indicates that this function is a part of the TCB named ``Name``
6426-
}];
6427-
}
6428-
6429-
def EnforceTCBLeafDocs : Documentation {
6430-
let Category = DocCatFunction;
6431-
let Content = [{
6432-
The ``enforce_tcb_leaf`` attribute satisfies the requirement enforced by
6433-
``enforce_tcb`` for the marked function to be in the named TCB but does not
6434-
continue to check the functions called from within the leaf function.
6435-
6436-
- ``enforce_tcb_leaf(Name)`` indicates that this function is a part of the TCB named ``Name``
6437-
}];
6438-
}

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11256,11 +11256,4 @@ def err_probability_not_constant_float : Error<
1125611256
def err_probability_out_of_range : Error<
1125711257
"probability argument to __builtin_expect_with_probability is outside the "
1125811258
"range [0.0, 1.0]">;
11259-
11260-
// TCB warnings
11261-
def err_tcb_conflicting_attributes : Error<
11262-
"attributes '%0(\"%2\")' and '%1(\"%2\")' are mutually exclusive">;
11263-
def warn_tcb_enforcement_violation : Warning<
11264-
"calling %0 is a violation of trusted computing base '%1'">,
11265-
InGroup<DiagGroup<"tcb-enforcement">>;
1126611259
} // end of sema component.

clang/include/clang/Sema/Sema.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3365,9 +3365,6 @@ class Sema final {
33653365
Decl *D, const WebAssemblyImportNameAttr &AL);
33663366
WebAssemblyImportModuleAttr *mergeImportModuleAttr(
33673367
Decl *D, const WebAssemblyImportModuleAttr &AL);
3368-
EnforceTCBAttr *mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL);
3369-
EnforceTCBLeafAttr *mergeEnforceTCBLeafAttr(Decl *D,
3370-
const EnforceTCBLeafAttr &AL);
33713368

33723369
SYCLIntelLoopFuseAttr *
33733370
mergeSYCLIntelLoopFuseAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E);
@@ -12628,8 +12625,6 @@ class Sema final {
1262812625
/// attempts to add itself into the container
1262912626
void CheckObjCCircularContainer(ObjCMessageExpr *Message);
1263012627

12631-
void CheckTCBEnforcement(const CallExpr *TheCall, const FunctionDecl *Callee);
12632-
1263312628
void AnalyzeDeleteExprMismatch(const CXXDeleteExpr *DE);
1263412629
void AnalyzeDeleteExprMismatch(FieldDecl *Field, SourceLocation DeleteLoc,
1263512630
bool DeleteWasArrayForm);

clang/lib/Sema/SemaChecking.cpp

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
#include "llvm/ADT/SmallString.h"
7676
#include "llvm/ADT/SmallVector.h"
7777
#include "llvm/ADT/StringRef.h"
78-
#include "llvm/ADT/StringSet.h"
7978
#include "llvm/ADT/StringSwitch.h"
8079
#include "llvm/ADT/Triple.h"
8180
#include "llvm/Support/AtomicOrdering.h"
@@ -4709,8 +4708,6 @@ bool Sema::CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall,
47094708
if (!FnInfo)
47104709
return false;
47114710

4712-
CheckTCBEnforcement(TheCall, FDecl);
4713-
47144711
CheckAbsoluteValueFunction(TheCall, FDecl);
47154712
CheckMaxUnsignedZero(TheCall, FDecl);
47164713

@@ -16201,37 +16198,3 @@ ExprResult Sema::SemaBuiltinMatrixColumnMajorStore(CallExpr *TheCall,
1620116198

1620216199
return CallResult;
1620316200
}
16204-
16205-
/// \brief Enforce the bounds of a TCB
16206-
/// CheckTCBEnforcement - Enforces that every function in a named TCB only
16207-
/// directly calls other functions in the same TCB as marked by the enforce_tcb
16208-
/// and enforce_tcb_leaf attributes.
16209-
void Sema::CheckTCBEnforcement(const CallExpr *TheCall,
16210-
const FunctionDecl *Callee) {
16211-
const FunctionDecl *Caller = getCurFunctionDecl();
16212-
16213-
// Calls to builtins are not enforced.
16214-
if (!Caller || !Caller->hasAttr<EnforceTCBAttr>() ||
16215-
Callee->getBuiltinID() != 0)
16216-
return;
16217-
16218-
// Search through the enforce_tcb and enforce_tcb_leaf attributes to find
16219-
// all TCBs the callee is a part of.
16220-
llvm::StringSet<> CalleeTCBs;
16221-
for_each(Callee->specific_attrs<EnforceTCBAttr>(),
16222-
[&](const auto *A) { CalleeTCBs.insert(A->getTCBName()); });
16223-
for_each(Callee->specific_attrs<EnforceTCBLeafAttr>(),
16224-
[&](const auto *A) { CalleeTCBs.insert(A->getTCBName()); });
16225-
16226-
// Go through the TCBs the caller is a part of and emit warnings if Caller
16227-
// is in a TCB that the Callee is not.
16228-
for_each(
16229-
Caller->specific_attrs<EnforceTCBAttr>(),
16230-
[&](const auto *A) {
16231-
StringRef CallerTCB = A->getTCBName();
16232-
if (CalleeTCBs.count(CallerTCB) == 0) {
16233-
Diag(TheCall->getExprLoc(), diag::warn_tcb_enforcement_violation)
16234-
<< Callee << CallerTCB;
16235-
}
16236-
});
16237-
}

clang/lib/Sema/SemaDecl.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2614,10 +2614,6 @@ static bool mergeDeclAttribute(Sema &S, NamedDecl *D,
26142614
NewAttr = S.mergeImportNameAttr(D, *INA);
26152615
else if (const auto *LFA = dyn_cast<SYCLIntelLoopFuseAttr>(Attr))
26162616
NewAttr = S.mergeSYCLIntelLoopFuseAttr(D, *LFA, LFA->getValue());
2617-
else if (const auto *TCBA = dyn_cast<EnforceTCBAttr>(Attr))
2618-
NewAttr = S.mergeEnforceTCBAttr(D, *TCBA);
2619-
else if (const auto *TCBLA = dyn_cast<EnforceTCBLeafAttr>(Attr))
2620-
NewAttr = S.mergeEnforceTCBLeafAttr(D, *TCBLA);
26212617
else if (Attr->shouldInheritEvenIfAlreadyPresent() || !DeclHasAttr(D, Attr))
26222618
NewAttr = cast<InheritableAttr>(Attr->clone(S.Context));
26232619

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -8328,75 +8328,6 @@ static void handleCFGuardAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
83288328
D->addAttr(::new (S.Context) CFGuardAttr(S.Context, AL, Arg));
83298329
}
83308330

8331-
8332-
template <typename AttrTy>
8333-
static const AttrTy *findEnforceTCBAttrByName(Decl *D, StringRef Name) {
8334-
auto Attrs = D->specific_attrs<AttrTy>();
8335-
auto I = llvm::find_if(Attrs,
8336-
[Name](const AttrTy *A) {
8337-
return A->getTCBName() == Name;
8338-
});
8339-
return I == Attrs.end() ? nullptr : *I;
8340-
}
8341-
8342-
template <typename AttrTy, typename ConflictingAttrTy>
8343-
static void handleEnforceTCBAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
8344-
StringRef Argument;
8345-
if (!S.checkStringLiteralArgumentAttr(AL, 0, Argument))
8346-
return;
8347-
8348-
// A function cannot be have both regular and leaf membership in the same TCB.
8349-
if (const ConflictingAttrTy *ConflictingAttr =
8350-
findEnforceTCBAttrByName<ConflictingAttrTy>(D, Argument)) {
8351-
// We could attach a note to the other attribute but in this case
8352-
// there's no need given how the two are very close to each other.
8353-
S.Diag(AL.getLoc(), diag::err_tcb_conflicting_attributes)
8354-
<< AL.getAttrName()->getName() << ConflictingAttr->getAttrName()->getName()
8355-
<< Argument;
8356-
8357-
// Error recovery: drop the non-leaf attribute so that to suppress
8358-
// all future warnings caused by erroneous attributes. The leaf attribute
8359-
// needs to be kept because it can only suppresses warnings, not cause them.
8360-
D->dropAttr<EnforceTCBAttr>();
8361-
return;
8362-
}
8363-
8364-
D->addAttr(AttrTy::Create(S.Context, Argument, AL));
8365-
}
8366-
8367-
template <typename AttrTy, typename ConflictingAttrTy>
8368-
static AttrTy *mergeEnforceTCBAttrImpl(Sema &S, Decl *D, const AttrTy &AL) {
8369-
// Check if the new redeclaration has different leaf-ness in the same TCB.
8370-
StringRef TCBName = AL.getTCBName();
8371-
if (const ConflictingAttrTy *ConflictingAttr =
8372-
findEnforceTCBAttrByName<ConflictingAttrTy>(D, TCBName)) {
8373-
S.Diag(ConflictingAttr->getLoc(), diag::err_tcb_conflicting_attributes)
8374-
<< ConflictingAttr->getAttrName()->getName()
8375-
<< AL.getAttrName()->getName() << TCBName;
8376-
8377-
// Add a note so that the user could easily find the conflicting attribute.
8378-
S.Diag(AL.getLoc(), diag::note_conflicting_attribute);
8379-
8380-
// More error recovery.
8381-
D->dropAttr<EnforceTCBAttr>();
8382-
return nullptr;
8383-
}
8384-
8385-
ASTContext &Context = S.getASTContext();
8386-
return ::new(Context) AttrTy(Context, AL, AL.getTCBName());
8387-
}
8388-
8389-
EnforceTCBAttr *Sema::mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL) {
8390-
return mergeEnforceTCBAttrImpl<EnforceTCBAttr, EnforceTCBLeafAttr>(
8391-
*this, D, AL);
8392-
}
8393-
8394-
EnforceTCBLeafAttr *Sema::mergeEnforceTCBLeafAttr(
8395-
Decl *D, const EnforceTCBLeafAttr &AL) {
8396-
return mergeEnforceTCBAttrImpl<EnforceTCBLeafAttr, EnforceTCBAttr>(
8397-
*this, D, AL);
8398-
}
8399-
84008331
//===----------------------------------------------------------------------===//
84018332
// Top Level Sema Entry Points
84028333
//===----------------------------------------------------------------------===//
@@ -9187,14 +9118,6 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
91879118
case ParsedAttr::AT_UseHandle:
91889119
handleHandleAttr<UseHandleAttr>(S, D, AL);
91899120
break;
9190-
9191-
case ParsedAttr::AT_EnforceTCB:
9192-
handleEnforceTCBAttr<EnforceTCBAttr, EnforceTCBLeafAttr>(S, D, AL);
9193-
break;
9194-
9195-
case ParsedAttr::AT_EnforceTCBLeaf:
9196-
handleEnforceTCBAttr<EnforceTCBLeafAttr, EnforceTCBAttr>(S, D, AL);
9197-
break;
91989121
}
91999122
}
92009123

clang/test/Sema/attr-enforce-tcb-errors.cpp

Lines changed: 0 additions & 80 deletions
This file was deleted.

clang/test/Sema/attr-enforce-tcb.c

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)