================
@@ -141,6 +168,67 @@ void UseStdBitCheck::check(const MatchFinder::MatchResult 
&Result) {
            << IncludeInserter.createIncludeInsertion(
                   Source.getFileID(MatchedExpr->getBeginLoc()), "<bit>");
     }
+  } else if (const auto *MatchedExpr =
+                 Result.Nodes.getNodeAs<Expr>("rotate_expr")) {
+    // Detect if the expression is an explicit cast. If that's the case we 
don't
+    // need to insert a cast.
+    const Expr *ParentExprOrSelf = getParentExprOrSelf(MatchedExpr, Context);
+    bool HasExplicitIntegerCast = false;
+    if (const auto *CE = dyn_cast<CastExpr>(ParentExprOrSelf)) {
+      HasExplicitIntegerCast =
+          CE->getType()->isIntegerType() && !isa<ImplicitCastExpr>(CE);
+    }
----------------
zwuis wrote:

Can be implemented in matchers.

```cpp
expr(
    ...,
    optionally(hasParent(implicitCastExpr(/* is integer type? */).bind("...")))
)
```

Then we can check if the `ImplicitCastExpr` is bound.

https://github.com/llvm/llvm-project/pull/186324
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to