diff options
author | smanna12 <soumi.manna@intel.com> | 2024-11-21 07:15:02 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-21 09:15:02 -0600 |
commit | 7b61ff2c263b7122c23783385662f6ff67764352 (patch) | |
tree | 58088f2040235dbfc7a95d2c6acd1061a9c38aa5 /clang/lib/Sema/SemaExprMember.cpp | |
parent | e8b5c009b68715434bcd4942bab08ca4b0a5abbb (diff) | |
download | llvm-7b61ff2c263b7122c23783385662f6ff67764352.zip llvm-7b61ff2c263b7122c23783385662f6ff67764352.tar.gz llvm-7b61ff2c263b7122c23783385662f6ff67764352.tar.bz2 |
[Clang] Prevent null dereferences (#115502)
This commit addresses several Static Analyzer issues related to
potential null dereference by replacing dyn_cast<> with cast<> and
getAs<> with castAs<> in various parts of the codes.
The cast function asserts that the cast is valid, ensuring that the
pointer is not null and preventing null dereference errors.
The changes are made in the following files:
CGBuiltin.cpp: Ensure vector types have exactly 3 elements.
CGExpr.cpp: Ensure member declarations are field declarations.
AnalysisBasedWarnings.cpp: Ensure operations are member expressions.
SemaExprMember.cpp: Ensure base types are extended vector types.
These changes ensure that the types are correctly cast and prevent
potential null dereference issues, improving the robustness and safety
of the code.
Diffstat (limited to 'clang/lib/Sema/SemaExprMember.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExprMember.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExprMember.cpp b/clang/lib/Sema/SemaExprMember.cpp index c32df60..434768b9 100644 --- a/clang/lib/Sema/SemaExprMember.cpp +++ b/clang/lib/Sema/SemaExprMember.cpp @@ -377,7 +377,7 @@ CheckExtVectorComponent(Sema &S, QualType baseType, ExprValueKind &VK, // // FIXME: This logic can be greatly simplified by splitting it along // halving/not halving and reworking the component checking. - const ExtVectorType *vecType = baseType->getAs<ExtVectorType>(); + const ExtVectorType *vecType = baseType->castAs<ExtVectorType>(); // The vector accessor can't exceed the number of elements. const char *compStr = CompName->getNameStart(); |