[clang-tools-extra] [clang-tidy] Improved cppcoreguidelines-pro-type-const-cast (PR #69501)
Congcong Cai via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 19 22:13:46 PDT 2023
================
@@ -14,13 +14,42 @@ using namespace clang::ast_matchers;
namespace clang::tidy::cppcoreguidelines {
+static bool hasConstQualifier(QualType Type) {
+ const QualType PtrType = Type->getPointeeType();
+ if (!PtrType.isNull())
+ return hasConstQualifier(PtrType);
+
+ return Type.isConstQualified();
----------------
HerrCai0907 wrote:
In cppreference, `const_cast` means converting between types with different cv-qualification.
So `isConstQualified` is not enough, `isVolatileQualified` is also needed.
https://github.com/llvm/llvm-project/pull/69501
More information about the cfe-commits
mailing list