[clang-tools-extra] 5cfc37b - [clang-tidy][NFC]clean ConstCorrectnessCheck (#130493)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 10 23:53:09 PDT 2025
Author: Congcong Cai
Date: 2025-03-11T14:53:06+08:00
New Revision: 5cfc37b3458b89927e76950c9498152ab729803e
URL: https://github.com/llvm/llvm-project/commit/5cfc37b3458b89927e76950c9498152ab729803e
DIFF: https://github.com/llvm/llvm-project/commit/5cfc37b3458b89927e76950c9498152ab729803e.diff
LOG: [clang-tidy][NFC]clean ConstCorrectnessCheck (#130493)
Added:
Modified:
clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp b/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
index 6e412e576e5f9..dbe59233df699 100644
--- a/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
@@ -136,16 +136,14 @@ void ConstCorrectnessCheck::check(const MatchFinder::MatchResult &Result) {
return;
VariableCategory VC = VariableCategory::Value;
- if (Variable->getType()->isReferenceType())
+ const QualType VT = Variable->getType();
+ if (VT->isReferenceType())
VC = VariableCategory::Reference;
- if (Variable->getType()->isPointerType())
+ else if (VT->isPointerType())
VC = VariableCategory::Pointer;
- if (Variable->getType()->isArrayType()) {
- if (const auto *ArrayT = dyn_cast<ArrayType>(Variable->getType())) {
- if (ArrayT->getElementType()->isPointerType())
- VC = VariableCategory::Pointer;
- }
- }
+ else if (const auto *ArrayT = dyn_cast<ArrayType>(VT))
+ if (ArrayT->getElementType()->isPointerType())
+ VC = VariableCategory::Pointer;
// Each variable can only be in one category: Value, Pointer, Reference.
// Analysis can be controlled for every category.
More information about the cfe-commits
mailing list