[PATCH] Removed unnecessary asserts from SemaDeclAttr.cpp
Eli Friedman
eli.friedman at gmail.com
Wed Aug 21 14:38:40 PDT 2013
LGTM.
-Eli
On Wed, Aug 21, 2013 at 2:31 PM, Christian Wailes <chriswailes at google.com>wrote:
> Hi dblaikie, delesley, aaron.ballman,
>
> Several asserts were unnecessarily testing the validity of attributes.
> This was already assured at an earlier state of the attribute processing
> pipeline. This patch removes them from several functions.
>
> http://llvm-reviews.chandlerc.com/D1466
>
> Files:
> lib/Sema/SemaDeclAttr.cpp
>
> Index: lib/Sema/SemaDeclAttr.cpp
> ===================================================================
> --- lib/Sema/SemaDeclAttr.cpp
> +++ lib/Sema/SemaDeclAttr.cpp
> @@ -497,8 +497,6 @@
>
> static bool checkGuardedVarAttrCommon(Sema &S, Decl *D,
> const AttributeList &Attr) {
> - assert(!Attr.isInvalid());
> -
> if (!checkAttributeNumArgs(S, Attr, 0))
> return false;
>
> @@ -537,8 +535,6 @@
> static bool checkGuardedByAttrCommon(Sema &S, Decl *D,
> const AttributeList &Attr,
> Expr* &Arg) {
> - assert(!Attr.isInvalid());
> -
> if (!checkAttributeNumArgs(S, Attr, 1))
> return false;
>
> @@ -584,8 +580,6 @@
>
> static bool checkLockableAttrCommon(Sema &S, Decl *D,
> const AttributeList &Attr) {
> - assert(!Attr.isInvalid());
> -
> if (!checkAttributeNumArgs(S, Attr, 0))
> return false;
>
> @@ -618,8 +612,6 @@
>
> static void handleNoThreadSafetyAnalysis(Sema &S, Decl *D,
> const AttributeList &Attr) {
> - assert(!Attr.isInvalid());
> -
> if (!checkAttributeNumArgs(S, Attr, 0))
> return;
>
> @@ -635,8 +627,6 @@
>
> static void handleNoSanitizeAddressAttr(Sema &S, Decl *D,
> const AttributeList &Attr) {
> - assert(!Attr.isInvalid());
> -
> if (!checkAttributeNumArgs(S, Attr, 0))
> return;
>
> @@ -653,8 +643,6 @@
>
> static void handleNoSanitizeMemory(Sema &S, Decl *D,
> const AttributeList &Attr) {
> - assert(!Attr.isInvalid());
> -
> if (!checkAttributeNumArgs(S, Attr, 0))
> return;
>
> @@ -670,8 +658,6 @@
>
> static void handleNoSanitizeThread(Sema &S, Decl *D,
> const AttributeList &Attr) {
> - assert(!Attr.isInvalid());
> -
> if (!checkAttributeNumArgs(S, Attr, 0))
> return;
>
> @@ -688,8 +674,6 @@
> static bool checkAcquireOrderAttrCommon(Sema &S, Decl *D,
> const AttributeList &Attr,
> SmallVectorImpl<Expr *> &Args) {
> - assert(!Attr.isInvalid());
> -
> if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
> return false;
>
> @@ -749,8 +733,6 @@
> static bool checkLockFunAttrCommon(Sema &S, Decl *D,
> const AttributeList &Attr,
> SmallVectorImpl<Expr *> &Args) {
> - assert(!Attr.isInvalid());
> -
> // zero or more arguments ok
>
> // check that the attribute is applied to a function
> @@ -824,8 +806,6 @@
> static bool checkTryLockFunAttrCommon(Sema &S, Decl *D,
> const AttributeList &Attr,
> SmallVectorImpl<Expr *> &Args) {
> - assert(!Attr.isInvalid());
> -
> if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
> return false;
>
> @@ -878,8 +858,6 @@
> static bool checkLocksRequiredCommon(Sema &S, Decl *D,
> const AttributeList &Attr,
> SmallVectorImpl<Expr *> &Args) {
> - assert(!Attr.isInvalid());
> -
> if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
> return false;
>
> @@ -925,8 +903,6 @@
>
> static void handleUnlockFunAttr(Sema &S, Decl *D,
> const AttributeList &Attr) {
> - assert(!Attr.isInvalid());
> -
> // zero or more arguments ok
>
> if (!isa<FunctionDecl>(D) && !isa<FunctionTemplateDecl>(D)) {
> @@ -948,8 +924,6 @@
>
> static void handleLockReturnedAttr(Sema &S, Decl *D,
> const AttributeList &Attr) {
> - assert(!Attr.isInvalid());
> -
> if (!checkAttributeNumArgs(S, Attr, 1))
> return;
>
> @@ -973,8 +947,6 @@
>
> static void handleLocksExcludedAttr(Sema &S, Decl *D,
> const AttributeList &Attr) {
> - assert(!Attr.isInvalid());
> -
> if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
> return;
>
> @@ -999,7 +971,6 @@
>
> static void handleConsumesAttr(Sema &S, Decl *D,
> const AttributeList &Attr) {
> - assert(!Attr.isInvalid());
> if (!checkAttributeNumArgs(S, Attr, 0)) return;
>
> if (!(isa<CXXMethodDecl>(D) || isa<CXXConstructorDecl>(D))) {
> @@ -1015,7 +986,6 @@
>
> static void handleCallableWhenUnconsumedAttr(Sema &S, Decl *D,
> const AttributeList &Attr) {
> - assert(!Attr.isInvalid());
> if (!checkAttributeNumArgs(S, Attr, 0)) return;
>
> if (!isa<CXXMethodDecl>(D)) {
> @@ -1031,7 +1001,6 @@
>
> static void handleTestsConsumedAttr(Sema &S, Decl *D,
> const AttributeList &Attr) {
> - assert(!Attr.isInvalid());
> if (!checkAttributeNumArgs(S, Attr, 0)) return;
>
> if (!isa<CXXMethodDecl>(D)) {
> @@ -1047,7 +1016,6 @@
>
> static void handleTestsUnconsumedAttr(Sema &S, Decl *D,
> const AttributeList &Attr) {
> - assert(!Attr.isInvalid());
> if (!checkAttributeNumArgs(S, Attr, 0)) return;
>
> if (!isa<CXXMethodDecl>(D)) {
> @@ -1714,7 +1682,6 @@
> }
>
> static void handleNoCommonAttr(Sema &S, Decl *D, const AttributeList
> &Attr) {
> - assert(!Attr.isInvalid());
> if (isa<VarDecl>(D))
> D->addAttr(::new (S.Context)
> NoCommonAttr(Attr.getRange(), S.Context,
> @@ -1725,8 +1692,6 @@
> }
>
> static void handleCommonAttr(Sema &S, Decl *D, const AttributeList &Attr)
> {
> - assert(!Attr.isInvalid());
> -
> if (S.LangOpts.CPlusPlus) {
> S.Diag(Attr.getLoc(), diag::err_common_not_supported_cplusplus);
> return;
> @@ -4020,13 +3985,10 @@
> }
>
> static void handleOpenCLKernelAttr(Sema &S, Decl *D, const AttributeList
> &Attr){
> - assert(!Attr.isInvalid());
> D->addAttr(::new (S.Context) OpenCLKernelAttr(Attr.getRange(),
> S.Context));
> }
>
> static void handleOpenCLImageAccessAttr(Sema &S, Decl *D, const
> AttributeList &Attr){
> - assert(!Attr.isInvalid());
> -
> Expr *E = Attr.getArg(0);
> llvm::APSInt ArgNum(32);
> if (E->isTypeDependent() || E->isValueDependent() ||
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130821/e170fd0a/attachment.html>
More information about the cfe-commits
mailing list