This revision was automatically updated to reflect the committed changes. Closed by commit rL289970: [analyzer] Fix crash in MallocChecker. (authored by dcoughlin).
Changed prior to commit: https://reviews.llvm.org/D27849?vs=81751&id=81774#toc Repository: rL LLVM https://reviews.llvm.org/D27849 Files: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp cfe/trunk/test/Analysis/out-of-bounds-new.cpp Index: cfe/trunk/test/Analysis/out-of-bounds-new.cpp =================================================================== --- cfe/trunk/test/Analysis/out-of-bounds-new.cpp +++ cfe/trunk/test/Analysis/out-of-bounds-new.cpp @@ -148,3 +148,9 @@ int *buf = new int[s]; buf[0] = 1; // no-warning } +//Tests complex arithmetic +//in new expression +void test_dynamic_size2(unsigned m,unsigned n){ + unsigned *U = nullptr; + U = new unsigned[m + n + 1]; +} Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -1026,8 +1026,7 @@ ASTContext &AstContext = C.getASTContext(); CharUnits TypeSize = AstContext.getTypeSizeInChars(ElementType); - if (Optional<DefinedOrUnknownSVal> DefinedSize = - ElementCount.getAs<DefinedOrUnknownSVal>()) { + if (ElementCount.getAs<NonLoc>()) { DefinedOrUnknownSVal Extent = Region->getExtent(svalBuilder); // size in Bytes = ElementCount*TypeSize SVal SizeInBytes = svalBuilder.evalBinOpNN(
Index: cfe/trunk/test/Analysis/out-of-bounds-new.cpp =================================================================== --- cfe/trunk/test/Analysis/out-of-bounds-new.cpp +++ cfe/trunk/test/Analysis/out-of-bounds-new.cpp @@ -148,3 +148,9 @@ int *buf = new int[s]; buf[0] = 1; // no-warning } +//Tests complex arithmetic +//in new expression +void test_dynamic_size2(unsigned m,unsigned n){ + unsigned *U = nullptr; + U = new unsigned[m + n + 1]; +} Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -1026,8 +1026,7 @@ ASTContext &AstContext = C.getASTContext(); CharUnits TypeSize = AstContext.getTypeSizeInChars(ElementType); - if (Optional<DefinedOrUnknownSVal> DefinedSize = - ElementCount.getAs<DefinedOrUnknownSVal>()) { + if (ElementCount.getAs<NonLoc>()) { DefinedOrUnknownSVal Extent = Region->getExtent(svalBuilder); // size in Bytes = ElementCount*TypeSize SVal SizeInBytes = svalBuilder.evalBinOpNN(
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits