Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -1100,6 +1100,18 @@ ->getAs() ->getSuperRegion() ->getAs(); + // FIXME: Since 'ExprEngine::VisitCXXNewAllocator' has not yet been fully + // implemented, the custom operator new[] may return Non-ElementRegion after + // its inline call. When 'ExprEngine::VisitCXXNewAllocator' is fully + // implemented, the following 'if' statement should be deleted. + if (!Region) { + assert(NE->isArray() && + !C.getSourceManager().isInSystemHeader( + NE->getOperatorNew()->getLocStart()) && + "The operator new[] can return non-ElementRegion only when it is " + "a custom version and be inlined."); + return nullptr; + } } else { ElementCount = svalBuilder.makeIntVal(1, true); Region = (State->getSVal(NE, LCtx)).getAsRegion()->getAs(); Index: test/Analysis/NewDelete-custom.cpp =================================================================== --- test/Analysis/NewDelete-custom.cpp +++ test/Analysis/NewDelete-custom.cpp @@ -1,5 +1,6 @@ // RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,unix.Malloc -std=c++11 -fblocks -verify %s // RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -DLEAKS -fblocks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.NewDelete -analyzer-config c++-allocator-inlining=true -std=c++11 -fblocks -verify %s #include "Inputs/system-header-simulator-cxx.h" #ifndef LEAKS