diff --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -1372,9 +1372,9 @@ CharKind CK) const { // void *memcpy(void *restrict dst, const void *restrict src, size_t n); // The return value is the address of the destination buffer. - DestinationArgExpr Dest = {CE->getArg(0), 0}; - SourceArgExpr Src = {CE->getArg(1), 1}; - SizeArgExpr Size = {CE->getArg(2), 2}; + DestinationArgExpr Dest = {{CE->getArg(0), 0}}; + SourceArgExpr Src = {{CE->getArg(1), 1}}; + SizeArgExpr Size = {{CE->getArg(2), 2}}; ProgramStateRef State = C.getState(); @@ -1387,9 +1387,9 @@ CharKind CK) const { // void *mempcpy(void *restrict dst, const void *restrict src, size_t n); // The return value is a pointer to the byte following the last written byte. - DestinationArgExpr Dest = {CE->getArg(0), 0}; - SourceArgExpr Src = {CE->getArg(1), 1}; - SizeArgExpr Size = {CE->getArg(2), 2}; + DestinationArgExpr Dest = {{CE->getArg(0), 0}}; + SourceArgExpr Src = {{CE->getArg(1), 1}}; + SizeArgExpr Size = {{CE->getArg(2), 2}}; constexpr bool IsRestricted = true; constexpr bool IsMempcpy = true; @@ -1401,9 +1401,9 @@ CharKind CK) const { // void *memmove(void *dst, const void *src, size_t n); // The return value is the address of the destination buffer. - DestinationArgExpr Dest = {CE->getArg(0), 0}; - SourceArgExpr Src = {CE->getArg(1), 1}; - SizeArgExpr Size = {CE->getArg(2), 2}; + DestinationArgExpr Dest = {{CE->getArg(0), 0}}; + SourceArgExpr Src = {{CE->getArg(1), 1}}; + SizeArgExpr Size = {{CE->getArg(2), 2}}; constexpr bool IsRestricted = false; constexpr bool IsMempcpy = false; @@ -1413,9 +1413,9 @@ void CStringChecker::evalBcopy(CheckerContext &C, const CallExpr *CE) const { // void bcopy(const void *src, void *dst, size_t n); - SourceArgExpr Src{CE->getArg(0), 0}; - DestinationArgExpr Dest = {CE->getArg(1), 1}; - SizeArgExpr Size = {CE->getArg(2), 2}; + SourceArgExpr Src{{CE->getArg(0), 0}}; + DestinationArgExpr Dest = {{CE->getArg(1), 1}}; + SizeArgExpr Size = {{CE->getArg(2), 2}}; constexpr bool IsRestricted = false; constexpr bool IsMempcpy = false; @@ -1430,7 +1430,7 @@ AnyArgExpr Left = {CE->getArg(0), 0}; AnyArgExpr Right = {CE->getArg(1), 1}; - SizeArgExpr Size = {CE->getArg(2), 2}; + SizeArgExpr Size = {{CE->getArg(2), 2}}; ProgramStateRef State = C.getState(); SValBuilder &Builder = C.getSValBuilder(); @@ -1698,14 +1698,14 @@ const LocationContext *LCtx = C.getLocationContext(); // Check that the destination is non-null. - DestinationArgExpr Dst = {CE->getArg(0), 0}; + DestinationArgExpr Dst = {{CE->getArg(0), 0}}; SVal DstVal = state->getSVal(Dst.Expression, LCtx); state = checkNonNull(C, state, Dst, DstVal); if (!state) return; // Check that the source is non-null. - SourceArgExpr srcExpr = {CE->getArg(1), 1}; + SourceArgExpr srcExpr = {{CE->getArg(1), 1}}; SVal srcVal = state->getSVal(srcExpr.Expression, LCtx); state = checkNonNull(C, state, srcExpr, srcVal); if (!state) @@ -1736,10 +1736,11 @@ // FIXME: Why do we choose the srcExpr if the access has no size? // Note that the 3rd argument of the call would be the size parameter. - SizeArgExpr SrcExprAsSizeDummy = {srcExpr.Expression, srcExpr.ArgumentIndex}; + SizeArgExpr SrcExprAsSizeDummy = { + {srcExpr.Expression, srcExpr.ArgumentIndex}}; state = CheckOverlap( C, state, - (IsBounded ? SizeArgExpr{CE->getArg(2), 2} : SrcExprAsSizeDummy), Dst, + (IsBounded ? SizeArgExpr{{CE->getArg(2), 2}} : SrcExprAsSizeDummy), Dst, srcExpr); if (!state) @@ -1748,7 +1749,7 @@ // If the function is strncpy, strncat, etc... it is bounded. if (IsBounded) { // Get the max number of characters to copy. - SizeArgExpr lenExpr = {CE->getArg(2), 2}; + SizeArgExpr lenExpr = {{CE->getArg(2), 2}}; SVal lenVal = state->getSVal(lenExpr.Expression, LCtx); // Protect against misdeclared strncpy(). @@ -2222,7 +2223,7 @@ void CStringChecker::evalStrsep(CheckerContext &C, const CallExpr *CE) const { // char *strsep(char **stringp, const char *delim); // Verify whether the search string parameter matches the return type. - SourceArgExpr SearchStrPtr = {CE->getArg(0), 0}; + SourceArgExpr SearchStrPtr = {{CE->getArg(0), 0}}; QualType CharPtrTy = SearchStrPtr.Expression->getType()->getPointeeType(); if (CharPtrTy.isNull() || @@ -2323,9 +2324,9 @@ // void *memset(void *s, int c, size_t n); CurrentFunctionDescription = "memory set function"; - DestinationArgExpr Buffer = {CE->getArg(0), 0}; + DestinationArgExpr Buffer = {{CE->getArg(0), 0}}; AnyArgExpr CharE = {CE->getArg(1), 1}; - SizeArgExpr Size = {CE->getArg(2), 2}; + SizeArgExpr Size = {{CE->getArg(2), 2}}; ProgramStateRef State = C.getState(); @@ -2372,8 +2373,8 @@ void CStringChecker::evalBzero(CheckerContext &C, const CallExpr *CE) const { CurrentFunctionDescription = "memory clearance function"; - DestinationArgExpr Buffer = {CE->getArg(0), 0}; - SizeArgExpr Size = {CE->getArg(1), 1}; + DestinationArgExpr Buffer = {{CE->getArg(0), 0}}; + SizeArgExpr Size = {{CE->getArg(1), 1}}; SVal Zero = C.getSValBuilder().makeZeroVal(C.getASTContext().IntTy); ProgramStateRef State = C.getState(); @@ -2427,7 +2428,7 @@ void CStringChecker::evalSprintfCommon(CheckerContext &C, const CallExpr *CE, bool IsBounded, bool IsBuiltin) const { ProgramStateRef State = C.getState(); - DestinationArgExpr Dest = {CE->getArg(0), 0}; + DestinationArgExpr Dest = {{CE->getArg(0), 0}}; const auto NumParams = CE->getCalleeDecl()->getAsFunction()->getNumParams(); assert(CE->getNumArgs() >= NumParams); @@ -2442,14 +2443,15 @@ !type->isAnyPointerType() || !type->getPointeeType()->isAnyCharacterType()) continue; - SourceArgExpr Source = {ArgExpr, unsigned(ArgIdx)}; + SourceArgExpr Source = {{ArgExpr, unsigned(ArgIdx)}}; // Ensure the buffers do not overlap. - SizeArgExpr SrcExprAsSizeDummy = {Source.Expression, Source.ArgumentIndex}; + SizeArgExpr SrcExprAsSizeDummy = { + {Source.Expression, Source.ArgumentIndex}}; State = CheckOverlap( C, State, - (IsBounded ? SizeArgExpr{CE->getArg(1), 1} : SrcExprAsSizeDummy), Dest, - Source); + (IsBounded ? SizeArgExpr{{CE->getArg(1), 1}} : SrcExprAsSizeDummy), + Dest, Source); if (!State) return; }