[clang-tools-extra] r375102 - clang-tidy - silence static analyzer getAs<> null dereference warnings. NFCI.

Simon Pilgrim via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 17 04:12:54 PDT 2019


Author: rksimon
Date: Thu Oct 17 04:12:53 2019
New Revision: 375102

URL: http://llvm.org/viewvc/llvm-project?rev=375102&view=rev
Log:
clang-tidy - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.

Modified:
    clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
    clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp?rev=375102&r1=375101&r2=375102&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp Thu Oct 17 04:12:53 2019
@@ -478,7 +478,7 @@ canOverloadedOperatorArgsBeModified(cons
   // These functions must be declared const in order to not be able to modify
   // the instance of the class they are called through.
   if (ParamCount == 1 &&
-      !OperatorDecl->getType()->getAs<FunctionType>()->isConst())
+      !OperatorDecl->getType()->castAs<FunctionType>()->isConst())
     return true;
 
   if (isNonConstReferenceType(OperatorDecl->getParamDecl(0)->getType()))

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp?rev=375102&r1=375101&r2=375102&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp Thu Oct 17 04:12:53 2019
@@ -29,7 +29,7 @@ static StringRef getValueOfValueInit(con
     return "false";
 
   case Type::STK_Integral:
-    switch (InitType->getAs<BuiltinType>()->getKind()) {
+    switch (InitType->castAs<BuiltinType>()->getKind()) {
     case BuiltinType::Char_U:
     case BuiltinType::UChar:
     case BuiltinType::Char_S:
@@ -47,7 +47,7 @@ static StringRef getValueOfValueInit(con
     }
 
   case Type::STK_Floating:
-    switch (InitType->getAs<BuiltinType>()->getKind()) {
+    switch (InitType->castAs<BuiltinType>()->getKind()) {
     case BuiltinType::Half:
     case BuiltinType::Float:
       return "0.0f";
@@ -58,10 +58,10 @@ static StringRef getValueOfValueInit(con
   case Type::STK_FloatingComplex:
   case Type::STK_IntegralComplex:
     return getValueOfValueInit(
-        InitType->getAs<ComplexType>()->getElementType());
+        InitType->castAs<ComplexType>()->getElementType());
 
   case Type::STK_FixedPoint:
-    switch (InitType->getAs<BuiltinType>()->getKind()) {
+    switch (InitType->castAs<BuiltinType>()->getKind()) {
     case BuiltinType::ShortAccum:
     case BuiltinType::SatShortAccum:
       return "0.0hk";




More information about the cfe-commits mailing list