summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2019-09-30 11:04:12 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2019-09-30 11:04:12 +0000
commit3ca270f05b0bdd2f921498e0841618e697316d7b (patch)
tree03833f7b797c9701cbe160cdb420fa6b4ca92667
parentfdbe5b4b6fdc49619ed40f841df271a7c353a79d (diff)
downloadbcm5719-llvm-3ca270f05b0bdd2f921498e0841618e697316d7b.tar.gz
bcm5719-llvm-3ca270f05b0bdd2f921498e0841618e697316d7b.zip
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. llvm-svn: 373198
-rw-r--r--clang/include/clang/AST/DeclCXX.h6
-rw-r--r--clang/include/clang/AST/ExprCXX.h3
2 files changed, 4 insertions, 5 deletions
diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h
index 7ec391f4640..0b835ecd736 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -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
diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h
index e554968caba..bc7d7c0a320 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -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 {
OpenPOWER on IntegriCloud