Index: clang/include/clang/Basic/Attr.td =================================================================== --- clang/include/clang/Basic/Attr.td +++ clang/include/clang/Basic/Attr.td @@ -2565,6 +2565,7 @@ let AdditionalMembers = [{ bool isMutex() const { return getName().equals_lower("mutex"); } bool isRole() const { return getName().equals_lower("role"); } + bool isContext() const { return getName().equals_lower("context"); } }]; } Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -3196,7 +3196,8 @@ // Thread Safety Attributes def warn_invalid_capability_name : Warning< - "invalid capability name '%0'; capability name must be 'mutex' or 'role'">, + "invalid capability name '%0'; capability name must be 'mutex', 'role' or " + "'context'">, InGroup, DefaultIgnore; def warn_thread_attribute_ignored : Warning< "ignoring %0 attribute because its argument is invalid">, Index: clang/lib/Sema/SemaDeclAttr.cpp =================================================================== --- clang/lib/Sema/SemaDeclAttr.cpp +++ clang/lib/Sema/SemaDeclAttr.cpp @@ -6199,10 +6199,12 @@ !S.checkStringLiteralArgumentAttr(AL, 0, N, &LiteralLoc)) return; - // Currently, there are only two names allowed for a capability: role and - // mutex (case insensitive). Diagnose other capability names. - if (!N.equals_lower("mutex") && !N.equals_lower("role")) + // Currently, there are only 3 names allowed for a capability: role, + // mutex and context (case insensitive). Diagnose other capability names. + if (!N.equals_lower("mutex") && !N.equals_lower("role") && + !N.equals_lower("context")) { S.Diag(LiteralLoc, diag::warn_invalid_capability_name) << N; + } D->addAttr(::new (S.Context) CapabilityAttr(S.Context, AL, N)); }