[PATCH] D14096: [clang-tidy] add new check cppcoreguidelines-pro-type-cstyle-cast

Matthias Gehre via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 2 13:43:04 PST 2015


mgehre added inline comments.

================
Comment at: clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp:80
@@ +79,3 @@
+      std::string CastText = ("dynamic_cast<" + DestTypeString + ">").str();
+      if (!isa<ParenExpr>(SubExpr)) {
+        CastText.push_back('(');
----------------
aaron.ballman wrote:
> Why do we need this check? Perhaps we want to use IgnoreParenImpCasts() instead?
If the cast looks like
```
Derived* D = (Derived*)B;
```
we need to add parenthesis around B to turn it into
```
Derived* D = dynamic_cast<Derived*>(B);
```
If instead we already had
```
Derived* D = (Derived*)(B);
```
adding the parenthesis can be skipped.


http://reviews.llvm.org/D14096





More information about the cfe-commits mailing list