Author: rksimon
Date: Mon Sep 30 04:04:12 2019
New Revision: 373198
URL: http://llvm.org/viewvc/llvm-project?rev=373198&view=rev
Log:
DeclCXX/ExprCXX - 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:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/ExprCXX.h
Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=373198&r1=373197&r2=373198&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Mon Sep 30 04:04:12 2019
@@ -2236,7 +2236,7 @@ public:
const CXXRecordDecl *Decl);
Qualifiers getMethodQualifiers() const {
- return getType()->getAs<FunctionProtoType>()->getMethodQuals();
+ return getType()->castAs<FunctionProtoType>()->getMethodQuals();
}
/// Retrieve the ref-qualifier associated with this method.
@@ -2251,7 +2251,7 @@ public:
/// };
/// @endcode
RefQualifierKind getRefQualifier() const {
- return getType()->getAs<FunctionProtoType>()->getRefQualifier();
+ return getType()->castAs<FunctionProtoType>()->getRefQualifier();
}
bool hasInlineBody() const;
@@ -2905,7 +2905,7 @@ public:
/// Returns the type that this conversion function is converting to.
QualType getConversionType() const {
- return getType()->getAs<FunctionType>()->getReturnType();
+ return getType()->castAs<FunctionType>()->getReturnType();
}
/// Determine whether this conversion function is a conversion from
Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=373198&r1=373197&r2=373198&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Mon Sep 30 04:04:12 2019
@@ -2096,8 +2096,7 @@ public:
bool IsParenTypeId);
QualType getAllocatedType() const {
- assert(getType()->isPointerType());
- return getType()->getAs<PointerType>()->getPointeeType();
+ return getType()->castAs<PointerType>()->getPointeeType();
}
TypeSourceInfo *getAllocatedTypeSourceInfo() const {
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits