[CLANG] Fix potential null pointer dereference bugs
authorManna, Soumi <soumi.manna@intel.com>
Thu, 22 Jun 2023 19:52:25 +0000 (12:52 -0700)
committerManna, Soumi <soumi.manna@intel.com>
Thu, 22 Jun 2023 19:58:38 +0000 (12:58 -0700)
commit982a87ab74d8d050ae56164fcead7cf19038b077
tree2a0180e3b0a0c805802772a2fb87a4be6e4e21df
parent30ac031dd5731fab02739ebe8a7dc9a013d008dc
[CLANG] Fix potential null pointer dereference bugs

This patch uses castAs instead of getAs which will assert if the type doesn't match and adds nullptr check if needed.

Also this patch improves the codes and passes I.getData() instead of doing a lookup in dumpVarDefinitionName()
since we're iterating over the same map in LocalVariableMap::dumpContex().

Reviewed By: aaron.ballman, aaronpuchert

Differential Revision: https://reviews.llvm.org/D153033
clang/lib/AST/ASTContext.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/Analysis/ThreadSafety.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp