It looks like on some host-triples the result of a valist related expr can be
a LazyCompoundVal. Handle that case in the check.
Patch by Abramo Bagnara!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@297619
91177308-0d34-0410-b5e6-
96231b3b80d8
const MemRegion *ValistChecker::getVAListAsRegion(SVal SV, const Expr *E,
bool &IsSymbolic,
CheckerContext &C) const {
- // FIXME: on some platforms CallAndMessage checker finds some instances of
- // the uninitialized va_list usages. CallAndMessage checker is disabled in
- // the tests so they can verify platform independently those issues. As a
- // side effect, this check is required here.
- if (SV.isUnknownOrUndef())
+ const MemRegion *Reg = SV.getAsRegion();
+ if (!Reg)
return nullptr;
// TODO: In the future this should be abstracted away by the analyzer.
bool VaListModelledAsArray = false;
VaListModelledAsArray =
Ty->isPointerType() && Ty->getPointeeType()->isRecordType();
}
- const MemRegion *Reg = SV.getAsRegion();
if (const auto *DeclReg = Reg->getAs<DeclRegion>()) {
if (isa<ParmVarDecl>(DeclReg->getDecl()))
Reg = C.getState()->getSVal(SV.castAs<Loc>()).getAsRegion();
--- /dev/null
+// RUN: %clang_analyze_cc1 -triple gcc-linaro-arm-linux-gnueabihf -analyzer-checker=core,valist.Uninitialized,valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s
+// expected-no-diagnostics
+
+typedef unsigned int size_t;
+typedef __builtin_va_list __gnuc_va_list;
+typedef __gnuc_va_list va_list;
+
+extern int vsprintf(char *__restrict __s,
+ const char *__restrict __format, __gnuc_va_list
+ __arg);
+
+void _dprintf(const char *function, int flen, int line, int level,
+ const char *prefix, const char *fmt, ...) {
+ char raw[10];
+ int err;
+ va_list ap;
+
+ __builtin_va_start(ap, fmt);
+ err = vsprintf(raw, fmt, ap);
+ __builtin_va_end(ap);
+}
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze -analyzer-checker=core,valist.Uninitialized,valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s
+// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core,valist.Uninitialized,valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s
#include "Inputs/system-header-simulator-for-valist.h"