Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp =================================================================== --- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp +++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp @@ -571,7 +571,11 @@ // add 1 to a LocAsInteger, we'd better unpack the Loc and add to it, // then pack it back into a LocAsInteger. llvm::APSInt i = rhs.castAs().getValue(); - BasicVals.getAPSIntType(Context.VoidPtrTy).apply(i); + // FIXME: Handle non-default address spaces for non-symbolic regions. + if (SymbolRef lSym = lhs.getAsLocSymbol(true)) + BasicVals.getAPSIntType(lSym->getType()).apply(i); + else + BasicVals.getAPSIntType(Context.VoidPtrTy).apply(i); return evalBinOpLL(state, op, lhsL, makeLoc(i), resultTy); } default: Index: test/Analysis/ptr-cmp-const-trunc.cl =================================================================== --- /dev/null +++ test/Analysis/ptr-cmp-const-trunc.cl @@ -0,0 +1,11 @@ +//RUN: %clang_analyze_cc1 -triple amdgcn-unknown-unknown -analyze -analyzer-checker=core -verify %s +// expected-no-diagnostics + +#include + +void bar(__global int *p) __attribute__((nonnull(1))); + +void foo(__global int *p) { + if ((uint64_t)p <= 1UL << 32) + bar(p); +}