[PATCH] D19084: [clang-analyzer] fix warnings emitted on clang code base
Apelete Seketeli via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 13 16:52:48 PDT 2016
apelete created this revision.
apelete added a subscriber: cfe-commits.
The following warnings were reported while running clang analyzer on Clang code base:
API: argument with 'nonnull' attribute passed null, on file:
- lib/AST/NestedNameSpecifier.cpp.
Logic error: called C++ object pointer is null, on files:
- lib/Sema/SemaInit.cpp,
- lib/Driver/Tools.cpp,
- lib/AST/ASTDiagnostic.cpp.
Fixes T123 (please note that first revision was sent only to
cfe-commits mailing list, not reviewed yet).
Signed-off-by: Apelete Seketeli <apelete at seketeli.net>
http://reviews.llvm.org/D19084
Files:
lib/AST/ASTDiagnostic.cpp
lib/AST/NestedNameSpecifier.cpp
lib/Driver/Tools.cpp
lib/Sema/SemaInit.cpp
Index: lib/Sema/SemaInit.cpp
===================================================================
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -4862,6 +4862,8 @@
InitializationSequence &Sequence,
const InitializedEntity &Entity,
Expr *Initializer) {
+ assert(Initializer && "Initializer needs to be not NULL");
+
bool ArrayDecay = false;
QualType ArgType = Initializer->getType();
QualType ArgPointee;
@@ -5237,11 +5239,11 @@
DeclAccessPair dap;
if (isLibstdcxxPointerReturnFalseHack(S, Entity, Initializer)) {
AddZeroInitializationStep(Entity.getType());
- } else if (Initializer->getType() == Context.OverloadTy &&
+ } else if (Initializer && Initializer->getType() == Context.OverloadTy &&
!S.ResolveAddressOfOverloadedFunction(Initializer, DestType,
false, dap))
SetFailed(InitializationSequence::FK_AddressOfOverloadFailed);
- else if (Initializer->getType()->isFunctionType() &&
+ else if (Initializer && Initializer->getType()->isFunctionType() &&
isExprAnUnaddressableFunction(S, Initializer))
SetFailed(InitializationSequence::FK_AddressOfUnaddressableFunction);
else
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2339,7 +2339,7 @@
success = getAArch64MicroArchFeaturesFromMcpu(D, getAArch64TargetCPU(Args),
Args, Features);
- if (!success)
+ if (!success && A)
D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
if (Args.getLastArg(options::OPT_mgeneral_regs_only)) {
Index: lib/AST/NestedNameSpecifier.cpp
===================================================================
--- lib/AST/NestedNameSpecifier.cpp
+++ lib/AST/NestedNameSpecifier.cpp
@@ -456,7 +456,9 @@
Buffer = NewBuffer;
BufferCapacity = NewCapacity;
}
-
+
+ assert(Buffer && "Buffer cannot be NULL");
+
memcpy(Buffer + BufferSize, Start, End - Start);
BufferSize += End-Start;
}
Index: lib/AST/ASTDiagnostic.cpp
===================================================================
--- lib/AST/ASTDiagnostic.cpp
+++ lib/AST/ASTDiagnostic.cpp
@@ -1683,7 +1683,7 @@
ToName = ToTD->getQualifiedNameAsString();
}
- if (Same) {
+ if (Same && FromTD) {
OS << "template " << FromTD->getNameAsString();
} else if (!PrintTree) {
OS << (FromDefault ? "(default) template " : "template ");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19084.53642.patch
Type: text/x-patch
Size: 2691 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160413/cf54f7f1/attachment.bin>
More information about the cfe-commits
mailing list