[clang-tidy] FunctionASTVisitor::TraverseStmt - use cast<> instead of dyn_cast<>...
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 12 Feb 2022 11:04:20 +0000 (11:04 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 12 Feb 2022 11:04:20 +0000 (11:04 +0000)
The pointer is referenced immediately, so assert the cast is correct instead of returning nullptr

clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp

index c27733c..40542cc 100644 (file)
@@ -444,8 +444,7 @@ public:
       // A little beautification.
       // For conditional operator "cond ? true : false" point at the "?"
       // symbol.
-      ConditionalOperator *COp = dyn_cast<ConditionalOperator>(Node);
-      Location = COp->getQuestionLoc();
+      Location = cast<ConditionalOperator>(Node)->getQuestionLoc();
     }
 
     // If we have found any reasons, let's account it.