[clang-tools-extra] [clang-tidy][NFC]clean ConstCorrectnessCheck (PR #130493)
Carlos Galvez via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 11 02:19:37 PDT 2025
================
@@ -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))
----------------
carlosgalvezp wrote:
My reading of the [guidelines](https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements) is that we should use braces in the outer `if` if there is a nested `if`.
https://github.com/llvm/llvm-project/pull/130493
More information about the cfe-commits
mailing list