diff options
-rw-r--r-- | clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp b/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp index 6e412e5..dbe5923 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. |