r305480 - [analyzer]: Improve test handling with multiple constraint managers
Author: ddcc Date: Thu Jun 15 12:05:07 2017 New Revision: 305480 URL: http://llvm.org/viewvc/llvm-project?rev=305480&view=rev Log: [analyzer]: Improve test handling with multiple constraint managers Summary: Modify the test infrastructure to properly handle tests that require z3, and merge together the output of all tests on success. This is required for D28954. Reviewers: dcoughlin, zaks.anna, NoQ, xazax.hun Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33308 Modified: cfe/trunk/test/Analysis/analyzer_test.py Modified: cfe/trunk/test/Analysis/analyzer_test.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/analyzer_test.py?rev=305480&r1=305479&r2=305480&view=diff == --- cfe/trunk/test/Analysis/analyzer_test.py (original) +++ cfe/trunk/test/Analysis/analyzer_test.py Thu Jun 15 12:05:07 2017 @@ -5,24 +5,39 @@ import lit.TestRunner class AnalyzerTest(lit.formats.ShTest): def execute(self, test, litConfig): -result = self.executeWithAnalyzeSubstitution( -test, litConfig, '-analyzer-constraints=range') +results = [] -if result.code == lit.Test.FAIL: -return result +# Parse any test requirements ('REQUIRES: ') +saved_test = test +lit.TestRunner.parseIntegratedTestScript(test) + +if 'z3' not in test.requires: +results.append(self.executeWithAnalyzeSubstitution( +saved_test, litConfig, '-analyzer-constraints=range')) + +if results[-1].code == lit.Test.FAIL: +return results[-1] # If z3 backend available, add an additional run line for it if test.config.clang_staticanalyzer_z3 == '1': -result = self.executeWithAnalyzeSubstitution( -test, litConfig, '-analyzer-constraints=z3 -DANALYZER_CM_Z3') +results.append(self.executeWithAnalyzeSubstitution( +saved_test, litConfig, '-analyzer-constraints=z3 -DANALYZER_CM_Z3')) -return result +# Combine all result outputs into the last element +for x in results: +if x != results[-1]: +results[-1].output = x.output + results[-1].output + +if results: +return results[-1] +return lit.Test.Result(lit.Test.UNSUPPORTED, +"Test requires the following unavailable features: z3") def executeWithAnalyzeSubstitution(self, test, litConfig, substitution): saved_substitutions = list(test.config.substitutions) test.config.substitutions.append(('%analyze', substitution)) result = lit.TestRunner.executeShTest(test, litConfig, - self.execute_external) +self.execute_external) test.config.substitutions = saved_substitutions return result ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r333704 - [analyzer] fix bug with 1-bit APSInt types in Z3ConstraintManager
Author: ddcc Date: Thu May 31 15:23:07 2018 New Revision: 333704 URL: http://llvm.org/viewvc/llvm-project?rev=333704&view=rev Log: [analyzer] fix bug with 1-bit APSInt types in Z3ConstraintManager Summary: Clang does not have a corresponding QualType for a 1-bit APSInt, so use the BoolTy and extend the APSInt. Split from D35450. Fixes PR37622. Reviewers: george.karpenkov, NoQ Subscribers: mikhail.ramalho, xazax.hun, szepet, rnkovacs, cfe-commits, a.sidorin Differential Revision: https://reviews.llvm.org/D47603 Added: cfe/trunk/test/Analysis/apsint.c Modified: cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp?rev=333704&r1=333703&r2=333704&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp Thu May 31 15:23:07 2018 @@ -987,6 +987,9 @@ private: // TODO: Refactor to put elsewhere QualType getAPSIntType(const llvm::APSInt &Int) const; + // Get the QualTy for the input APSInt, and fix it if it has a bitwidth of 1. + std::pair fixAPSInt(const llvm::APSInt &Int) const; + // Perform implicit type conversion on binary symbolic expressions. // May modify all input parameters. // TODO: Refactor to use built-in conversion functions @@ -1038,27 +1041,31 @@ ProgramStateRef Z3ConstraintManager::ass // The expression may be casted, so we cannot call getZ3DataExpr() directly Z3Expr Exp = getZ3Expr(Sym, &RetTy); - assert((getAPSIntType(From) == getAPSIntType(To)) && - "Range values have different types!"); - QualType RTy = getAPSIntType(From); - bool isSignedTy = RetTy->isSignedIntegerOrEnumerationType(); - Z3Expr FromExp = Z3Expr::fromAPSInt(From); - Z3Expr ToExp = Z3Expr::fromAPSInt(To); + QualType FromTy; + llvm::APSInt NewFromInt; + std::tie(NewFromInt, FromTy) = fixAPSInt(From); + Z3Expr FromExp = Z3Expr::fromAPSInt(NewFromInt); // Construct single (in)equality if (From == To) return assumeZ3Expr(State, Sym, getZ3BinExpr(Exp, RetTy, InRange ? BO_EQ : BO_NE, - FromExp, RTy, nullptr)); + FromExp, FromTy, nullptr)); + QualType ToTy; + llvm::APSInt NewToInt; + std::tie(NewToInt, ToTy) = fixAPSInt(To); + Z3Expr ToExp = Z3Expr::fromAPSInt(NewToInt); + assert(FromTy == ToTy && "Range values have different types!"); // Construct two (in)equalities, and a logical and/or - Z3Expr LHS = - getZ3BinExpr(Exp, RetTy, InRange ? BO_GE : BO_LT, FromExp, RTy, nullptr); + Z3Expr LHS = getZ3BinExpr(Exp, RetTy, InRange ? BO_GE : BO_LT, FromExp, +FromTy, nullptr); Z3Expr RHS = - getZ3BinExpr(Exp, RetTy, InRange ? BO_LE : BO_GT, ToExp, RTy, nullptr); + getZ3BinExpr(Exp, RetTy, InRange ? BO_LE : BO_GT, ToExp, ToTy, nullptr); return assumeZ3Expr( State, Sym, - Z3Expr::fromBinOp(LHS, InRange ? BO_LAnd : BO_LOr, RHS, isSignedTy)); + Z3Expr::fromBinOp(LHS, InRange ? BO_LAnd : BO_LOr, RHS, +RetTy->isSignedIntegerOrEnumerationType())); } ProgramStateRef Z3ConstraintManager::assumeSymUnsupported(ProgramStateRef State, @@ -1145,8 +1152,8 @@ ConditionTruthVal Z3ConstraintManager::c const llvm::APSInt *Z3ConstraintManager::getSymVal(ProgramStateRef State, SymbolRef Sym) const { - BasicValueFactory &BV = getBasicVals(); - ASTContext &Ctx = BV.getContext(); + BasicValueFactory &BVF = getBasicVals(); + ASTContext &Ctx = BVF.getContext(); if (const SymbolData *SD = dyn_cast(Sym)) { QualType Ty = Sym->getType(); @@ -1180,7 +1187,7 @@ const llvm::APSInt *Z3ConstraintManager: return nullptr; // This is the only solution, store it -return &BV.getValue(Value); +return &BVF.getValue(Value); } else if (const SymbolCast *SC = dyn_cast(Sym)) { SymbolRef CastSym = SC->getOperand(); QualType CastTy = SC->getType(); @@ -1191,7 +1198,7 @@ const llvm::APSInt *Z3ConstraintManager: const llvm::APSInt *Value; if (!(Value = getSymVal(State, CastSym))) return nullptr; -return &BV.Convert(SC->getType(), *Value); +return &BVF.Convert(SC->getType(), *Value); } else if (const BinarySymExpr *BSE = dyn_cast(Sym)) { const llvm::APSInt *LHS, *RHS; if (const SymIntExpr *SIE = dyn_cast(BSE)) { @@ -1215,7 +1222,7 @@ const llvm::APSInt *Z3ConstraintManager: QualType LTy = getAPSIntType(*LHS), RTy = getAPSIntType(*RHS); doIntTypeConversion( ConvertedLHS, LTy, ConvertedRHS, RTy); -return BV.evalAPSInt(BSE->getOpcode(), ConvertedLHS, ConvertedRHS); +return BVF.evalAPSInt(BSE->getOpcode(), ConvertedLHS, Convert
[clang] ac77b3f - [clang][ARM][NFC] Clean up signed conversion and undefined macros in builtin header
Author: Dominic Chen Date: 2022-09-08T12:46:08-07:00 New Revision: ac77b3fde120d1c871b770fade67a413c418b94e URL: https://github.com/llvm/llvm-project/commit/ac77b3fde120d1c871b770fade67a413c418b94e DIFF: https://github.com/llvm/llvm-project/commit/ac77b3fde120d1c871b770fade67a413c418b94e.diff LOG: [clang][ARM][NFC] Clean up signed conversion and undefined macros in builtin header These warnings were identified while debugging modules with Wsystem-headers. Differential Revision: https://reviews.llvm.org/D132003 Added: Modified: clang/lib/Headers/arm_acle.h Removed: diff --git a/clang/lib/Headers/arm_acle.h b/clang/lib/Headers/arm_acle.h index a26c12ec4d58d..fc347f760d828 100644 --- a/clang/lib/Headers/arm_acle.h +++ b/clang/lib/Headers/arm_acle.h @@ -64,7 +64,7 @@ static __inline__ void __attribute__((__always_inline__, __nodebug__)) __yield(v } #endif -#if __ARM_32BIT_STATE +#if defined(__ARM_32BIT_STATE) && __ARM_32BIT_STATE #define __dbg(t) __builtin_arm_dbg(t) #endif @@ -82,7 +82,7 @@ __swp(uint32_t __x, volatile uint32_t *__p) { /* 8.6.1 Data prefetch */ #define __pld(addr) __pldx(0, 0, 0, addr) -#if __ARM_32BIT_STATE +#if defined(__ARM_32BIT_STATE) && __ARM_32BIT_STATE #define __pldx(access_kind, cache_level, retention_policy, addr) \ __builtin_arm_prefetch(addr, access_kind, 1) #else @@ -93,7 +93,7 @@ __swp(uint32_t __x, volatile uint32_t *__p) { /* 8.6.2 Instruction prefetch */ #define __pli(addr) __plix(0, 0, addr) -#if __ARM_32BIT_STATE +#if defined(__ARM_32BIT_STATE) && __ARM_32BIT_STATE #define __plix(cache_level, retention_policy, addr) \ __builtin_arm_prefetch(addr, 0, 0) #else @@ -140,17 +140,17 @@ __rorl(unsigned long __x, uint32_t __y) { /* CLZ */ static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) __clz(uint32_t __t) { - return __builtin_clz(__t); + return (uint32_t)__builtin_clz(__t); } static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__)) __clzl(unsigned long __t) { - return __builtin_clzl(__t); + return (unsigned long)__builtin_clzl(__t); } static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) __clzll(uint64_t __t) { - return __builtin_clzll(__t); + return (uint64_t)__builtin_clzll(__t); } /* CLS */ @@ -201,7 +201,7 @@ __rev16(uint32_t __t) { static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) __rev16ll(uint64_t __t) { - return (((uint64_t)__rev16(__t >> 32)) << 32) | __rev16(__t); + return (((uint64_t)__rev16(__t >> 32)) << 32) | (uint64_t)__rev16((uint32_t)__t); } static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__)) @@ -216,7 +216,7 @@ __rev16l(unsigned long __t) { /* REVSH */ static __inline__ int16_t __attribute__((__always_inline__, __nodebug__)) __revsh(int16_t __t) { - return __builtin_bswap16(__t); + return (int16_t)__builtin_bswap16((uint16_t)__t); } /* RBIT */ @@ -227,7 +227,7 @@ __rbit(uint32_t __t) { static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) __rbitll(uint64_t __t) { -#if __ARM_32BIT_STATE +#if defined(__ARM_32BIT_STATE) && __ARM_32BIT_STATE return (((uint64_t)__builtin_arm_rbit(__t)) << 32) | __builtin_arm_rbit(__t >> 32); #else @@ -247,7 +247,7 @@ __rbitl(unsigned long __t) { /* * 9.3 16-bit multiplications */ -#if __ARM_FEATURE_DSP +#if defined(__ARM_FEATURE_DSP) && __ARM_FEATURE_DSP static __inline__ int32_t __attribute__((__always_inline__,__nodebug__)) __smulbb(int32_t __a, int32_t __b) { return __builtin_arm_smulbb(__a, __b); @@ -281,13 +281,13 @@ __smulwt(int32_t __a, int32_t __b) { * intrinsics are implemented and the flag is enabled. */ /* 9.4.1 Width-specified saturation intrinsics */ -#if __ARM_FEATURE_SAT +#if defined(__ARM_FEATURE_SAT) && __ARM_FEATURE_SAT #define __ssat(x, y) __builtin_arm_ssat(x, y) #define __usat(x, y) __builtin_arm_usat(x, y) #endif /* 9.4.2 Saturating addition and subtraction intrinsics */ -#if __ARM_FEATURE_DSP +#if defined(__ARM_FEATURE_DSP) && __ARM_FEATURE_DSP static __inline__ int32_t __attribute__((__always_inline__, __nodebug__)) __qadd(int32_t __t, int32_t __v) { return __builtin_arm_qadd(__t, __v); @@ -305,7 +305,7 @@ __qdbl(int32_t __t) { #endif /* 9.4.3 Accumultating multiplications */ -#if __ARM_FEATURE_DSP +#if defined(__ARM_FEATURE_DSP) && __ARM_FEATURE_DSP static __inline__ int32_t __attribute__((__always_inline__, __nodebug__)) __smlabb(int32_t __a, int32_t __b, int32_t __c) { return __builtin_arm_smlabb(__a, __b, __c); @@ -334,13 +334,13 @@ __smlawt(int32_t __a, int32_t __b, int32_t __c) { /* 9.5.4 Parallel 16-bit saturation */ -#if __ARM_FEATURE_SIMD32 +#if defined(__ARM_FEATURE_SIMD32) && __ARM_FEATURE_SIMD32 #define __ssat16(x, y) __builtin_arm_ssat16(x, y) #define __usat16(x, y) __builtin_arm_usat16(x, y) #endif /* 9.5.5 Packing
[clang] bbf1900 - [clang][Headers] Avoid compiler warnings in builtin headers
Author: Dominic Chen Date: 2022-08-03T17:56:17-07:00 New Revision: bbf19005714b2f6f957cac25e44d381167843732 URL: https://github.com/llvm/llvm-project/commit/bbf19005714b2f6f957cac25e44d381167843732 DIFF: https://github.com/llvm/llvm-project/commit/bbf19005714b2f6f957cac25e44d381167843732.diff LOG: [clang][Headers] Avoid compiler warnings in builtin headers While debugging module support using -Wsystem-headers, we discovered that if -Werror, and -Wundef or -Wmacro-redefined are specified, they can cause errors to be generated in these builtin headers. Differential Revision: https://reviews.llvm.org/D130800 Added: Modified: clang/lib/Headers/float.h clang/lib/Headers/limits.h clang/lib/Headers/stdarg.h clang/lib/Headers/stdatomic.h clang/lib/Headers/stdbool.h clang/lib/Headers/stddef.h clang/lib/Headers/stdint.h clang/lib/Headers/stdnoreturn.h clang/lib/Headers/velintrin.h Removed: diff --git a/clang/lib/Headers/float.h b/clang/lib/Headers/float.h index c6a6cc08462da..5dace7a47c9fa 100644 --- a/clang/lib/Headers/float.h +++ b/clang/lib/Headers/float.h @@ -38,9 +38,10 @@ # undef FLT_MANT_DIG # undef DBL_MANT_DIG # undef LDBL_MANT_DIG -# if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || \ - __cplusplus >= 201103L || \ - (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE)) +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ +!defined(__STRICT_ANSI__) || \ +(defined(__cplusplus) && __cplusplus >= 201103L) || \ +(__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE)) #undef DECIMAL_DIG # endif # undef FLT_DIG @@ -67,9 +68,10 @@ # undef FLT_MIN # undef DBL_MIN # undef LDBL_MIN -# if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || \ - __cplusplus >= 201703L || \ - (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE)) +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ +!defined(__STRICT_ANSI__) || \ +(defined(__cplusplus) && __cplusplus >= 201703L) || \ +(__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE)) #undef FLT_TRUE_MIN #undef DBL_TRUE_MIN #undef LDBL_TRUE_MIN @@ -92,8 +94,9 @@ #define DBL_MANT_DIG __DBL_MANT_DIG__ #define LDBL_MANT_DIG __LDBL_MANT_DIG__ -#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || \ -__cplusplus >= 201103L || \ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ +!defined(__STRICT_ANSI__) || \ +(defined(__cplusplus) && __cplusplus >= 201103L) || \ (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE)) # define DECIMAL_DIG __DECIMAL_DIG__ #endif @@ -130,8 +133,9 @@ #define DBL_MIN __DBL_MIN__ #define LDBL_MIN __LDBL_MIN__ -#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || \ -__cplusplus >= 201703L || \ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ +!defined(__STRICT_ANSI__) || \ +(defined(__cplusplus) && __cplusplus >= 201703L) || \ (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE)) # define FLT_TRUE_MIN __FLT_DENORM_MIN__ # define DBL_TRUE_MIN __DBL_DENORM_MIN__ diff --git a/clang/lib/Headers/limits.h b/clang/lib/Headers/limits.h index cfd23a219ee55..32cc901b26be6 100644 --- a/clang/lib/Headers/limits.h +++ b/clang/lib/Headers/limits.h @@ -65,7 +65,7 @@ /* C2x 5.2.4.2.1 */ /* FIXME: This is using the placeholder dates Clang produces for these macros in C2x mode; switch to the correct values once they've been published. */ -#if __STDC_VERSION__ >= 202000L +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L #define BOOL_WIDTH __BOOL_WIDTH__ #define CHAR_WIDTH CHAR_BIT #define SCHAR_WIDTH CHAR_BIT @@ -93,7 +93,8 @@ /* C99 5.2.4.2.1: Added long long. C++11 18.3.3.2: same contents as the Standard C Library header . */ -#if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ +(defined(__cplusplus) && __cplusplus >= 201103L) #undef LLONG_MIN #undef LLONG_MAX diff --git a/clang/lib/Headers/stdarg.h b/clang/lib/Headers/stdarg.h index 0bc39408c1e5f..dc7becff670f4 100644 --- a/clang/lib/Headers/stdarg.h +++ b/clang/lib/Headers/stdarg.h @@ -23,7 +23,9 @@ typede
[clang] c102488 - Add test for disabling Dead Virtual Function Elimination
Author: Dominic Chen Date: 2020-10-07T19:20:16-04:00 New Revision: c10248829357fd90030ba091e01b6c253e5848f1 URL: https://github.com/llvm/llvm-project/commit/c10248829357fd90030ba091e01b6c253e5848f1 DIFF: https://github.com/llvm/llvm-project/commit/c10248829357fd90030ba091e01b6c253e5848f1.diff LOG: Add test for disabling Dead Virtual Function Elimination Differential Revision: https://reviews.llvm.org/D88349 Added: Modified: clang/test/CodeGenCXX/virtual-function-elimination.cpp Removed: diff --git a/clang/test/CodeGenCXX/virtual-function-elimination.cpp b/clang/test/CodeGenCXX/virtual-function-elimination.cpp index a89e6ebceeaf..543537baff90 100644 --- a/clang/test/CodeGenCXX/virtual-function-elimination.cpp +++ b/clang/test/CodeGenCXX/virtual-function-elimination.cpp @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-unknown-linux -flto -flto-unit -fvirtual-function-elimination -fwhole-program-vtables -emit-llvm -o - %s | FileCheck %s - +// RUN: %clang -target x86_64-unknown-linux -flto -fvirtual-function-elimination -fno-virtual-function-elimination -fwhole-program-vtables -S -emit-llvm -o - %s | FileCheck %s -check-prefix=NOVFE struct __attribute__((visibility("default"))) A { virtual void foo(); @@ -8,9 +8,13 @@ struct __attribute__((visibility("default"))) A { void test_1(A *p) { // A has default visibility, so no need for type.checked.load. // CHECK-LABEL: define void @_Z6test_1P1A +// NOVFE-LABEL: define dso_local void @_Z6test_1P1A // CHECK: [[FN_PTR_ADDR:%.+]] = getelementptr inbounds void (%struct.A*)*, void (%struct.A*)** {{%.+}}, i64 0 +// NOVFE: [[FN_PTR_ADDR:%.+]] = getelementptr inbounds void (%struct.A*)*, void (%struct.A*)** {{%.+}}, i64 0 // CHECK: [[FN_PTR:%.+]] = load void (%struct.A*)*, void (%struct.A*)** [[FN_PTR_ADDR]] +// NOVFE: [[FN_PTR:%.+]] = load void (%struct.A*)*, void (%struct.A*)** [[FN_PTR_ADDR]] // CHECK: call void [[FN_PTR]]( +// NOVFE: call void [[FN_PTR]]( p->foo(); } @@ -22,9 +26,13 @@ struct __attribute__((visibility("hidden"))) [[clang::lto_visibility_public]] B void test_2(B *p) { // B has public LTO visibility, so no need for type.checked.load. // CHECK-LABEL: define void @_Z6test_2P1B +// NOVFE-LABEL: define dso_local void @_Z6test_2P1B // CHECK: [[FN_PTR_ADDR:%.+]] = getelementptr inbounds void (%struct.B*)*, void (%struct.B*)** {{%.+}}, i64 0 +// NOVFE: [[FN_PTR_ADDR:%.+]] = getelementptr inbounds void (%struct.B*)*, void (%struct.B*)** {{%.+}}, i64 0 // CHECK: [[FN_PTR:%.+]] = load void (%struct.B*)*, void (%struct.B*)** [[FN_PTR_ADDR]] +// NOVFE: [[FN_PTR:%.+]] = load void (%struct.B*)*, void (%struct.B*)** [[FN_PTR_ADDR]] // CHECK: call void [[FN_PTR]]( +// NOVFE: call void [[FN_PTR]]( p->foo(); } @@ -37,10 +45,14 @@ struct __attribute__((visibility("hidden"))) C { void test_3(C *p) { // C has hidden visibility, so we generate type.checked.load to allow VFE. // CHECK-LABEL: define void @_Z6test_3P1C +// NOVFE-LABEL: define dso_local void @_Z6test_3P1C // CHECK: [[LOAD:%.+]] = call { i8*, i1 } @llvm.type.checked.load(i8* {{%.+}}, i32 0, metadata !"_ZTS1C") +// NOVFE: call i1 @llvm.type.test(i8* {{%.+}}, metadata !"_ZTS1C") // CHECK: [[FN_PTR_I8:%.+]] = extractvalue { i8*, i1 } [[LOAD]], 0 +// NOVFE: [[FN_PTR:%.+]] = load void (%struct.C*)*, void (%struct.C*)** {{%.+}}, align 8 // CHECK: [[FN_PTR:%.+]] = bitcast i8* [[FN_PTR_I8]] to void (%struct.C*)* // CHECK: call void [[FN_PTR]]( +// NOVFE: call void [[FN_PTR]]( p->foo(); } @@ -48,10 +60,14 @@ void test_4(C *p) { // When using type.checked.load, we pass the vtable offset to the intrinsic, // rather than adding it to the pointer with a GEP. // CHECK-LABEL: define void @_Z6test_4P1C +// NOVFE-LABEL: define dso_local void @_Z6test_4P1C // CHECK: [[LOAD:%.+]] = call { i8*, i1 } @llvm.type.checked.load(i8* {{%.+}}, i32 8, metadata !"_ZTS1C") +// NOVFE: call i1 @llvm.type.test(i8* {{%.+}}, metadata !"_ZTS1C") // CHECK: [[FN_PTR_I8:%.+]] = extractvalue { i8*, i1 } [[LOAD]], 0 +// NOVFE: [[FN_PTR:%.+]] = load void (%struct.C*)*, void (%struct.C*)** {{%.+}}, align 8 // CHECK: [[FN_PTR:%.+]] = bitcast i8* [[FN_PTR_I8]] to void (%struct.C*)* // CHECK: call void [[FN_PTR]]( +// NOVFE: call void [[FN_PTR]]( p->bar(); } @@ -64,12 +80,17 @@ void test_5(C *p, void (C::*q)(void)) { // function pointer to the intrinsic, this information would be lost. No // codegen changes on the non-virtual side. // CHECK-LABEL: define void @_Z6test_5P1CMS_FvvE( +// NOVFE-LABEL: define dso_local void @_Z6test_5P1CMS_FvvE( // CHECK: [[FN_PTR_ADDR:%.+]] = getelementptr i8, i8* %vtable, i64 {{%.+}} // CHECK: [[LOAD:%.+]] = call { i8*, i1 } @llvm.type.checked.load(i8* [[FN_PTR_ADDR]], i32 0, metadata !"_ZTSM1CFvvE.virtual") +// NOVFE-NOT: call { i8*, i1 } @llvm.type.checked.load(i8* {{%.+}}, i32 0, metadata !"_ZTSM1CFvvE.virtual") // CHECK: [
r299463 - [analyzer] Add new Z3 constraint manager backend
Author: ddcc Date: Tue Apr 4 14:52:25 2017 New Revision: 299463 URL: http://llvm.org/viewvc/llvm-project?rev=299463&view=rev Log: [analyzer] Add new Z3 constraint manager backend Summary: Implement new Z3 constraint manager backend. Reviewers: zaks.anna, dcoughlin, NoQ, xazax.hun Subscribers: mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D28952 Added: cfe/trunk/cmake/modules/FindZ3.cmake cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp cfe/trunk/test/Analysis/unsupported-types.c Modified: cfe/trunk/CMakeLists.txt cfe/trunk/include/clang/Config/config.h.cmake cfe/trunk/include/clang/StaticAnalyzer/Core/Analyses.def cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt cfe/trunk/test/Analysis/expr-inspection.c cfe/trunk/test/Analysis/lit.local.cfg cfe/trunk/test/lit.cfg cfe/trunk/test/lit.site.cfg.in Modified: cfe/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=299463&r1=299462&r2=299463&view=diff == --- cfe/trunk/CMakeLists.txt (original) +++ cfe/trunk/CMakeLists.txt Tue Apr 4 14:52:25 2017 @@ -186,6 +186,8 @@ if (LIBXML2_FOUND) set(CLANG_HAVE_LIBXML 1) endif() +find_package(Z3 4.5) + include(CheckIncludeFile) check_include_file(sys/resource.h CLANG_HAVE_RLIMITS) @@ -330,10 +332,6 @@ if (APPLE) endif() endif() -configure_file( - ${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake - ${CLANG_BINARY_DIR}/include/clang/Config/config.h) - include(CMakeParseArguments) include(AddClang) @@ -371,8 +369,19 @@ option(CLANG_BUILD_TOOLS option(CLANG_ENABLE_ARCMT "Build ARCMT." ON) option(CLANG_ENABLE_STATIC_ANALYZER "Build static analyzer." ON) -if (NOT CLANG_ENABLE_STATIC_ANALYZER AND CLANG_ENABLE_ARCMT) - message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT") +option(CLANG_ANALYZER_BUILD_Z3 + "Build the static analyzer with the Z3 constraint manager." OFF) + +if(NOT CLANG_ENABLE_STATIC_ANALYZER AND (CLANG_ENABLE_ARCMT OR CLANG_ANALYZER_BUILD_Z3)) + message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or Z3") +endif() + +if(CLANG_ANALYZER_BUILD_Z3) + if(Z3_FOUND) +set(CLANG_ANALYZER_WITH_Z3 1) + else() +message(FATAL_ERROR "Cannot find Z3 header file or shared library") + endif() endif() if(CLANG_ENABLE_ARCMT) @@ -687,3 +696,7 @@ endif() if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION) add_subdirectory(utils/ClangVisualizers) endif() + +configure_file( + ${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake + ${CLANG_BINARY_DIR}/include/clang/Config/config.h) Added: cfe/trunk/cmake/modules/FindZ3.cmake URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/FindZ3.cmake?rev=299463&view=auto == --- cfe/trunk/cmake/modules/FindZ3.cmake (added) +++ cfe/trunk/cmake/modules/FindZ3.cmake Tue Apr 4 14:52:25 2017 @@ -0,0 +1,28 @@ +find_path(Z3_INCLUDE_DIR NAMES z3.h + PATH_SUFFIXES libz3 + ) + +find_library(Z3_LIBRARIES NAMES z3 libz3 + ) + +find_program(Z3_EXECUTABLE z3) + +if(Z3_INCLUDE_DIR AND Z3_EXECUTABLE) +execute_process (COMMAND ${Z3_EXECUTABLE} -version + OUTPUT_VARIABLE libz3_version_str + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + +string(REGEX REPLACE "^Z3 version ([0-9.]+)" "\\1" + Z3_VERSION_STRING "${libz3_version_str}") +unset(libz3_version_str) +endif() + +# handle the QUIETLY and REQUIRED arguments and set Z3_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Z3 + REQUIRED_VARS Z3_LIBRARIES Z3_INCLUDE_DIR + VERSION_VAR Z3_VERSION_STRING) + +mark_as_advanced(Z3_INCLUDE_DIR Z3_LIBRARIES) Modified: cfe/trunk/include/clang/Config/config.h.cmake URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Config/config.h.cmake?rev=299463&r1=299462&r2=299463&view=diff == --- cfe/trunk/include/clang/Config/config.h.cmake (original) +++ cfe/trunk/include/clang/Config/config.h.cmake Tue Apr 4 14:52:25 2017 @@ -38,6 +38,9 @@ /* Define if we have libxml2 */ #cmakedefine CLANG_HAVE_LIBXML ${CLANG_HAVE_LIBXML} +/* Define if we have z3 and want to build it */ +#cmakedefine CLANG_ANALYZER_WITH_Z3 ${CLANG_ANALYZER_WITH_Z3} + /* Define if we have sys/resource.h (rlimits) */ #cmakedefine CLANG_HAVE_RLIMITS ${CLANG_HAVE_RLIMITS} Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/Analyses.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/Analyses.def?rev=299463&r1=299462&r2=299463&view=diff ===
r307833 - [analyzer] Support generating and reasoning over more symbolic constraint types
Author: ddcc Date: Wed Jul 12 12:37:57 2017 New Revision: 307833 URL: http://llvm.org/viewvc/llvm-project?rev=307833&view=rev Log: [analyzer] Support generating and reasoning over more symbolic constraint types Summary: Generate more IntSymExpr constraints, perform SVal simplification for IntSymExpr and SymbolCast constraints, and create fully symbolic SymExprs Reviewers: zaks.anna, dcoughlin, NoQ, xazax.hun Subscribers: mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D28953 Added: cfe/trunk/test/Analysis/plist-macros-z3.cpp - copied, changed from r307830, cfe/trunk/test/Analysis/plist-macros.cpp Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp cfe/trunk/test/Analysis/analyzer_test.py cfe/trunk/test/Analysis/bitwise-ops.c cfe/trunk/test/Analysis/bool-assignment.c cfe/trunk/test/Analysis/conditional-path-notes.c cfe/trunk/test/Analysis/explain-svals.cpp cfe/trunk/test/Analysis/plist-macros.cpp cfe/trunk/test/Analysis/range_casts.c cfe/trunk/test/Analysis/std-c-library-functions.c Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h?rev=307833&r1=307832&r2=307833&view=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h Wed Jul 12 12:37:57 2017 @@ -125,8 +125,14 @@ public: return OS.str(); } - // TODO: IntSymExpr doesn't appear in practice. - // Add the relevant code once it does. + std::string VisitIntSymExpr(const IntSymExpr *S) { +std::string Str; +llvm::raw_string_ostream OS(Str); +OS << S->getLHS() + << std::string(BinaryOperator::getOpcodeStr(S->getOpcode())) << " " + << "(" << Visit(S->getRHS()) << ") "; +return OS.str(); + } std::string VisitSymSymExpr(const SymSymExpr *S) { return "(" + Visit(S->getLHS()) + ") " + @@ -134,8 +140,10 @@ public: " (" + Visit(S->getRHS()) + ")"; } - // TODO: SymbolCast doesn't appear in practice. - // Add the relevant code once it does. + std::string VisitSymbolCast(const SymbolCast *S) { +return "cast of type '" + S->getType().getAsString() + "' of " + + Visit(S->getOperand()); + } std::string VisitSymbolicRegion(const SymbolicRegion *R) { // Explain 'this' object here. Modified: cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp?rev=307833&r1=307832&r2=307833&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp Wed Jul 12 12:37:57 2017 @@ -100,7 +100,7 @@ SValBuilder::getRegionValueSymbolVal(con if (T->isNullPtrType()) return makeZeroVal(T); - + if (!SymbolManager::canSymbolicate(T)) return UnknownVal(); @@ -354,9 +354,6 @@ SVal SValBuilder::makeSymExprValNN(Progr BinaryOperator::Opcode Op, NonLoc LHS, NonLoc RHS, QualType ResultTy) { - if (!State->isTainted(RHS) && !State->isTainted(LHS)) -return UnknownVal(); - const SymExpr *symLHS = LHS.getAsSymExpr(); const SymExpr *symRHS = RHS.getAsSymExpr(); // TODO: When the Max Complexity is reached, we should conjure a symbol @@ -364,7 +361,7 @@ SVal SValBuilder::makeSymExprValNN(Progr const unsigned MaxComp = 1; // 10 28X if (symLHS && symRHS && - (symLHS->computeComplexity() + symRHS->computeComplexity()) < MaxComp) + (symLHS->computeComplexity() + symRHS->computeComplexity()) < MaxComp) return makeNonLoc(symLHS, Op, symRHS, ResultTy); if (symLHS && symLHS->computeComplexity() < MaxComp) Modified: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp?rev=307833&r1=307832&r2=307833&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp Wed Jul 12 12:37:57 2017 @@ -669,12 +669,12 @@ SVal SimpleSValBuilder::evalBinOpLL(Prog // If one of the operands is a symbol and the other is a constant, // build an expression for use by the constraint manager. if (SymbolRef rSym = rhs.getAsLocSymbol()) { - // We can only build expressions with symbols on the left, - /
r307853 - Revert "[analyzer] Support generating and reasoning over more symbolic constraint types"
Author: ddcc Date: Wed Jul 12 14:43:42 2017 New Revision: 307853 URL: http://llvm.org/viewvc/llvm-project?rev=307853&view=rev Log: Revert "[analyzer] Support generating and reasoning over more symbolic constraint types" Assertion `Loc::isLocType(SSE->getLHS()->getType())' failed in Analysis/PR3991.m This reverts commit e469ff2759275e67f9072b3d67fac90f647c0fe6. Removed: cfe/trunk/test/Analysis/plist-macros-z3.cpp Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp cfe/trunk/test/Analysis/analyzer_test.py cfe/trunk/test/Analysis/bitwise-ops.c cfe/trunk/test/Analysis/bool-assignment.c cfe/trunk/test/Analysis/conditional-path-notes.c cfe/trunk/test/Analysis/explain-svals.cpp cfe/trunk/test/Analysis/plist-macros.cpp cfe/trunk/test/Analysis/range_casts.c cfe/trunk/test/Analysis/std-c-library-functions.c Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h?rev=307853&r1=307852&r2=307853&view=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h Wed Jul 12 14:43:42 2017 @@ -125,14 +125,8 @@ public: return OS.str(); } - std::string VisitIntSymExpr(const IntSymExpr *S) { -std::string Str; -llvm::raw_string_ostream OS(Str); -OS << S->getLHS() - << std::string(BinaryOperator::getOpcodeStr(S->getOpcode())) << " " - << "(" << Visit(S->getRHS()) << ") "; -return OS.str(); - } + // TODO: IntSymExpr doesn't appear in practice. + // Add the relevant code once it does. std::string VisitSymSymExpr(const SymSymExpr *S) { return "(" + Visit(S->getLHS()) + ") " + @@ -140,10 +134,8 @@ public: " (" + Visit(S->getRHS()) + ")"; } - std::string VisitSymbolCast(const SymbolCast *S) { -return "cast of type '" + S->getType().getAsString() + "' of " + - Visit(S->getOperand()); - } + // TODO: SymbolCast doesn't appear in practice. + // Add the relevant code once it does. std::string VisitSymbolicRegion(const SymbolicRegion *R) { // Explain 'this' object here. Modified: cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp?rev=307853&r1=307852&r2=307853&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp Wed Jul 12 14:43:42 2017 @@ -100,7 +100,7 @@ SValBuilder::getRegionValueSymbolVal(con if (T->isNullPtrType()) return makeZeroVal(T); - + if (!SymbolManager::canSymbolicate(T)) return UnknownVal(); @@ -354,6 +354,9 @@ SVal SValBuilder::makeSymExprValNN(Progr BinaryOperator::Opcode Op, NonLoc LHS, NonLoc RHS, QualType ResultTy) { + if (!State->isTainted(RHS) && !State->isTainted(LHS)) +return UnknownVal(); + const SymExpr *symLHS = LHS.getAsSymExpr(); const SymExpr *symRHS = RHS.getAsSymExpr(); // TODO: When the Max Complexity is reached, we should conjure a symbol @@ -361,7 +364,7 @@ SVal SValBuilder::makeSymExprValNN(Progr const unsigned MaxComp = 1; // 10 28X if (symLHS && symRHS && - (symLHS->computeComplexity() + symRHS->computeComplexity()) < MaxComp) + (symLHS->computeComplexity() + symRHS->computeComplexity()) < MaxComp) return makeNonLoc(symLHS, Op, symRHS, ResultTy); if (symLHS && symLHS->computeComplexity() < MaxComp) Modified: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp?rev=307853&r1=307852&r2=307853&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp Wed Jul 12 14:43:42 2017 @@ -669,12 +669,12 @@ SVal SimpleSValBuilder::evalBinOpLL(Prog // If one of the operands is a symbol and the other is a constant, // build an expression for use by the constraint manager. if (SymbolRef rSym = rhs.getAsLocSymbol()) { - const llvm::APSInt &lVal = lhs.castAs().getValue(); - - // Prefer expressions with symbols on the left + // We can only build expressions with symbols on the left, + // so we need a reversible operator. if (!BinaryOperator::isComparisonOp(op)) -return m
r296242 - [analyzer] Refactor and simplify SimpleConstraintManager
Author: ddcc Date: Fri Feb 24 22:51:31 2017 New Revision: 296242 URL: http://llvm.org/viewvc/llvm-project?rev=296242&view=rev Log: [analyzer] Refactor and simplify SimpleConstraintManager Summary: SimpleConstraintManager is difficult to use, and makes assumptions about capabilities of the constraint manager. This patch refactors out those portions into a new RangedConstraintManager, and also fixes some issues with camel case, formatting, and confusing naming. Reviewers: zaks.anna, dcoughlin Subscribers: mgorny, xazax.hun, NoQ, rgov, cfe-commits Differential Revision: https://reviews.llvm.org/D26061 Added: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h cfe/trunk/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp cfe/trunk/lib/StaticAnalyzer/Core/RangedConstraintManager.h - copied, changed from r296241, cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.h Removed: cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.h Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt cfe/trunk/lib/StaticAnalyzer/Core/ConstraintManager.cpp cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h?rev=296242&r1=296241&r2=296242&view=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h Fri Feb 24 22:51:31 2017 @@ -139,6 +139,8 @@ public: return nullptr; } + /// Scan all symbols referenced by the constraints. If the symbol is not + /// alive, remove it. virtual ProgramStateRef removeDeadBindings(ProgramStateRef state, SymbolReaper& SymReaper) = 0; Added: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h?rev=296242&view=auto == --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h (added) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h Fri Feb 24 22:51:31 2017 @@ -0,0 +1,92 @@ +//== SimpleConstraintManager.h --*- C++ -*--==// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// +// +// Simplified constraint manager backend. +// +//===--===// + +#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SIMPLECONSTRAINTMANAGER_H +#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SIMPLECONSTRAINTMANAGER_H + +#include "clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" + +namespace clang { + +namespace ento { + +class SimpleConstraintManager : public ConstraintManager { + SubEngine *SU; + SValBuilder &SVB; + +public: + SimpleConstraintManager(SubEngine *subengine, SValBuilder &SB) + : SU(subengine), SVB(SB) {} + + ~SimpleConstraintManager() override; + + //===--===// + // Implementation for interface from ConstraintManager. + //===--===// + + /// Ensures that the DefinedSVal conditional is expressed as a NonLoc by + /// creating boolean casts to handle Loc's. + ProgramStateRef assume(ProgramStateRef State, DefinedSVal Cond, + bool Assumption) override; + + ProgramStateRef assumeInclusiveRange(ProgramStateRef State, NonLoc Value, + const llvm::APSInt &From, + const llvm::APSInt &To, + bool InRange) override; + +protected: + //===--===// + // Interface that subclasses must implement. + //===--===// + + /// Given a symbolic expression that can be reasoned about, assume that it is + /// true/false and generate the new program state. + virtual ProgramStateRef assumeSym(ProgramStateRef State, SymbolRef Sym, +
[PATCH] D26642: [analyzer] Minor optimizaiton: avoid setting state if unchanged
ddcc created this revision. ddcc added reviewers: zaks.anna, dcoughlin. ddcc added a subscriber: cfe-commits. Split out optimization from https://reviews.llvm.org/D26061 https://reviews.llvm.org/D26642 Files: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp Index: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp === --- lib/StaticAnalyzer/Core/RangeConstraintManager.cpp +++ lib/StaticAnalyzer/Core/RangeConstraintManager.cpp @@ -398,17 +398,19 @@ ProgramStateRef RangeConstraintManager::removeDeadBindings(ProgramStateRef state, SymbolReaper& SymReaper) { - + bool Changed = false; ConstraintRangeTy CR = state->get(); - ConstraintRangeTy::Factory& CRFactory = state->get_context(); + ConstraintRangeTy::Factory &CRFactory = state->get_context(); for (ConstraintRangeTy::iterator I = CR.begin(), E = CR.end(); I != E; ++I) { SymbolRef sym = I.getKey(); -if (SymReaper.maybeDead(sym)) +if (SymReaper.maybeDead(sym)) { + Changed = true; CR = CRFactory.remove(CR, sym); +} } - return state->set(CR); + return Changed ? state->set(CR) : state; } RangeSet Index: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp === --- lib/StaticAnalyzer/Core/RangeConstraintManager.cpp +++ lib/StaticAnalyzer/Core/RangeConstraintManager.cpp @@ -398,17 +398,19 @@ ProgramStateRef RangeConstraintManager::removeDeadBindings(ProgramStateRef state, SymbolReaper& SymReaper) { - + bool Changed = false; ConstraintRangeTy CR = state->get(); - ConstraintRangeTy::Factory& CRFactory = state->get_context(); + ConstraintRangeTy::Factory &CRFactory = state->get_context(); for (ConstraintRangeTy::iterator I = CR.begin(), E = CR.end(); I != E; ++I) { SymbolRef sym = I.getKey(); -if (SymReaper.maybeDead(sym)) +if (SymReaper.maybeDead(sym)) { + Changed = true; CR = CRFactory.remove(CR, sym); +} } - return state->set(CR); + return Changed ? state->set(CR) : state; } RangeSet ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26644: [analyzer] Rename assumeWithinInclusiveRange*()
ddcc created this revision. ddcc added reviewers: zaks.anna, dcoughlin. ddcc added a subscriber: cfe-commits. The name is slightly confusing, since the constraint is not necessarily within the range unless `Assumption` is true. Split out renaming for ConstraintManager.h from https://reviews.llvm.org/D26061 https://reviews.llvm.org/D26644 Files: include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp lib/StaticAnalyzer/Core/ExprEngine.cpp lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp lib/StaticAnalyzer/Core/SimpleConstraintManager.h Index: lib/StaticAnalyzer/Core/SimpleConstraintManager.h === --- lib/StaticAnalyzer/Core/SimpleConstraintManager.h +++ lib/StaticAnalyzer/Core/SimpleConstraintManager.h @@ -38,7 +38,7 @@ ProgramStateRef assume(ProgramStateRef state, NonLoc Cond, bool Assumption); - ProgramStateRef assumeWithinInclusiveRange(ProgramStateRef State, + ProgramStateRef assumeInclusiveRange(ProgramStateRef State, NonLoc Value, const llvm::APSInt &From, const llvm::APSInt &To, Index: lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp === --- lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp +++ lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp @@ -190,7 +190,7 @@ } // end switch } -ProgramStateRef SimpleConstraintManager::assumeWithinInclusiveRange( +ProgramStateRef SimpleConstraintManager::assumeInclusiveRange( ProgramStateRef State, NonLoc Value, const llvm::APSInt &From, const llvm::APSInt &To, bool InRange) { @@ -207,7 +207,7 @@ switch (Value.getSubKind()) { default: -llvm_unreachable("'assumeWithinInclusiveRange' is not implemented" +llvm_unreachable("'assumeInclusiveRange' is not implemented" "for this NonLoc"); case nonloc::LocAsIntegerKind: Index: lib/StaticAnalyzer/Core/ExprEngine.cpp === --- lib/StaticAnalyzer/Core/ExprEngine.cpp +++ lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -1836,7 +1836,7 @@ ProgramStateRef StateCase; if (Optional NL = CondV.getAs()) std::tie(StateCase, DefaultSt) = - DefaultSt->assumeWithinInclusiveRange(*NL, V1, V2); + DefaultSt->assumeInclusiveRange(*NL, V1, V2); else // UnknownVal StateCase = DefaultSt; Index: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp === --- lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp +++ lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp @@ -254,7 +254,7 @@ const llvm::APSInt &Min = BVF.getValue(R[I].first, T); const llvm::APSInt &Max = BVF.getValue(R[I].second, T); assert(Min <= Max); - State = CM.assumeWithinInclusiveRange(State, *N, Min, Max, false); + State = CM.assumeInclusiveRange(State, *N, Min, Max, false); if (!State) break; } @@ -288,24 +288,24 @@ const llvm::APSInt &Left = BVF.getValue(R[0].first - 1ULL, T); if (Left != PlusInf) { assert(MinusInf <= Left); - State = CM.assumeWithinInclusiveRange(State, *N, MinusInf, Left, false); + State = CM.assumeInclusiveRange(State, *N, MinusInf, Left, false); if (!State) return nullptr; } const llvm::APSInt &Right = BVF.getValue(R[E - 1].second + 1ULL, T); if (Right != MinusInf) { assert(Right <= PlusInf); - State = CM.assumeWithinInclusiveRange(State, *N, Right, PlusInf, false); + State = CM.assumeInclusiveRange(State, *N, Right, PlusInf, false); if (!State) return nullptr; } for (size_t I = 1; I != E; ++I) { const llvm::APSInt &Min = BVF.getValue(R[I - 1].second + 1ULL, T); const llvm::APSInt &Max = BVF.getValue(R[I].first - 1ULL, T); assert(Min <= Max); - State = CM.assumeWithinInclusiveRange(State, *N, Min, Max, false); + State = CM.assumeInclusiveRange(State, *N, Min, Max, false); if (!State) return nullptr; } Index: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h === --- include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h @@ -98,18 +98,18 @@ /// This ctor is used when creating the first ProgramState object. ProgramState(ProgramStateManager *mgr, const Environment& env, StoreRef st, GenericDataMap gdm); - + /// Copy ctor - We must explicitly define this or else the "Next" ptr /// in FoldingSetNode will also
r286925 - [analyzer] Minor optimization: avoid setting state if unchanged
Author: ddcc Date: Mon Nov 14 19:40:58 2016 New Revision: 286925 URL: http://llvm.org/viewvc/llvm-project?rev=286925&view=rev Log: [analyzer] Minor optimization: avoid setting state if unchanged Summary: Split out optimization from D26061 Reviewers: zaks.anna, dcoughlin Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26642 Modified: cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp?rev=286925&r1=286924&r2=286925&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp Mon Nov 14 19:40:58 2016 @@ -398,17 +398,19 @@ ConditionTruthVal RangeConstraintManager ProgramStateRef RangeConstraintManager::removeDeadBindings(ProgramStateRef state, SymbolReaper& SymReaper) { - + bool Changed = false; ConstraintRangeTy CR = state->get(); - ConstraintRangeTy::Factory& CRFactory = state->get_context(); + ConstraintRangeTy::Factory &CRFactory = state->get_context(); for (ConstraintRangeTy::iterator I = CR.begin(), E = CR.end(); I != E; ++I) { SymbolRef sym = I.getKey(); -if (SymReaper.maybeDead(sym)) +if (SymReaper.maybeDead(sym)) { + Changed = true; CR = CRFactory.remove(CR, sym); +} } - return state->set(CR); + return Changed ? state->set(CR) : state; } RangeSet ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26642: [analyzer] Minor optimization: avoid setting state if unchanged
This revision was automatically updated to reflect the committed changes. Closed by commit rL286925: [analyzer] Minor optimization: avoid setting state if unchanged (authored by ddcc). Changed prior to commit: https://reviews.llvm.org/D26642?vs=77897&id=77929#toc Repository: rL LLVM https://reviews.llvm.org/D26642 Files: cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp Index: cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp === --- cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp @@ -398,17 +398,19 @@ ProgramStateRef RangeConstraintManager::removeDeadBindings(ProgramStateRef state, SymbolReaper& SymReaper) { - + bool Changed = false; ConstraintRangeTy CR = state->get(); - ConstraintRangeTy::Factory& CRFactory = state->get_context(); + ConstraintRangeTy::Factory &CRFactory = state->get_context(); for (ConstraintRangeTy::iterator I = CR.begin(), E = CR.end(); I != E; ++I) { SymbolRef sym = I.getKey(); -if (SymReaper.maybeDead(sym)) +if (SymReaper.maybeDead(sym)) { + Changed = true; CR = CRFactory.remove(CR, sym); +} } - return state->set(CR); + return Changed ? state->set(CR) : state; } RangeSet Index: cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp === --- cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp @@ -398,17 +398,19 @@ ProgramStateRef RangeConstraintManager::removeDeadBindings(ProgramStateRef state, SymbolReaper& SymReaper) { - + bool Changed = false; ConstraintRangeTy CR = state->get(); - ConstraintRangeTy::Factory& CRFactory = state->get_context(); + ConstraintRangeTy::Factory &CRFactory = state->get_context(); for (ConstraintRangeTy::iterator I = CR.begin(), E = CR.end(); I != E; ++I) { SymbolRef sym = I.getKey(); -if (SymReaper.maybeDead(sym)) +if (SymReaper.maybeDead(sym)) { + Changed = true; CR = CRFactory.remove(CR, sym); +} } - return state->set(CR); + return Changed ? state->set(CR) : state; } RangeSet ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26644: [analyzer] Rename assumeWithinInclusiveRange*()
ddcc updated this revision to Diff 77930. ddcc added a comment. Fix formatting https://reviews.llvm.org/D26644 Files: include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp lib/StaticAnalyzer/Core/ExprEngine.cpp lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp lib/StaticAnalyzer/Core/SimpleConstraintManager.h Index: lib/StaticAnalyzer/Core/SimpleConstraintManager.h === --- lib/StaticAnalyzer/Core/SimpleConstraintManager.h +++ lib/StaticAnalyzer/Core/SimpleConstraintManager.h @@ -38,7 +38,7 @@ ProgramStateRef assume(ProgramStateRef state, NonLoc Cond, bool Assumption); - ProgramStateRef assumeWithinInclusiveRange(ProgramStateRef State, + ProgramStateRef assumeInclusiveRange(ProgramStateRef State, NonLoc Value, const llvm::APSInt &From, const llvm::APSInt &To, Index: lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp === --- lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp +++ lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp @@ -190,7 +190,7 @@ } // end switch } -ProgramStateRef SimpleConstraintManager::assumeWithinInclusiveRange( +ProgramStateRef SimpleConstraintManager::assumeInclusiveRange( ProgramStateRef State, NonLoc Value, const llvm::APSInt &From, const llvm::APSInt &To, bool InRange) { @@ -207,7 +207,7 @@ switch (Value.getSubKind()) { default: -llvm_unreachable("'assumeWithinInclusiveRange' is not implemented" +llvm_unreachable("'assumeInclusiveRange' is not implemented" "for this NonLoc"); case nonloc::LocAsIntegerKind: Index: lib/StaticAnalyzer/Core/ExprEngine.cpp === --- lib/StaticAnalyzer/Core/ExprEngine.cpp +++ lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -1836,7 +1836,7 @@ ProgramStateRef StateCase; if (Optional NL = CondV.getAs()) std::tie(StateCase, DefaultSt) = - DefaultSt->assumeWithinInclusiveRange(*NL, V1, V2); + DefaultSt->assumeInclusiveRange(*NL, V1, V2); else // UnknownVal StateCase = DefaultSt; Index: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp === --- lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp +++ lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp @@ -254,7 +254,7 @@ const llvm::APSInt &Min = BVF.getValue(R[I].first, T); const llvm::APSInt &Max = BVF.getValue(R[I].second, T); assert(Min <= Max); - State = CM.assumeWithinInclusiveRange(State, *N, Min, Max, false); + State = CM.assumeInclusiveRange(State, *N, Min, Max, false); if (!State) break; } @@ -288,24 +288,24 @@ const llvm::APSInt &Left = BVF.getValue(R[0].first - 1ULL, T); if (Left != PlusInf) { assert(MinusInf <= Left); - State = CM.assumeWithinInclusiveRange(State, *N, MinusInf, Left, false); + State = CM.assumeInclusiveRange(State, *N, MinusInf, Left, false); if (!State) return nullptr; } const llvm::APSInt &Right = BVF.getValue(R[E - 1].second + 1ULL, T); if (Right != MinusInf) { assert(Right <= PlusInf); - State = CM.assumeWithinInclusiveRange(State, *N, Right, PlusInf, false); + State = CM.assumeInclusiveRange(State, *N, Right, PlusInf, false); if (!State) return nullptr; } for (size_t I = 1; I != E; ++I) { const llvm::APSInt &Min = BVF.getValue(R[I - 1].second + 1ULL, T); const llvm::APSInt &Max = BVF.getValue(R[I].first - 1ULL, T); assert(Min <= Max); - State = CM.assumeWithinInclusiveRange(State, *N, Min, Max, false); + State = CM.assumeInclusiveRange(State, *N, Min, Max, false); if (!State) return nullptr; } Index: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h === --- include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h @@ -98,18 +98,18 @@ /// This ctor is used when creating the first ProgramState object. ProgramState(ProgramStateManager *mgr, const Environment& env, StoreRef st, GenericDataMap gdm); - + /// Copy ctor - We must explicitly define this or else the "Next" ptr /// in FoldingSetNode will also get copied. ProgramState(const ProgramState &RHS); - + ~ProgramState(); /// Return the ProgramStateManager associated with this state. ProgramStateManager &getStateManager() const { return *stateMgr; } - +
r286927 - [analyzer] Rename assumeWithinInclusiveRange*()
Author: ddcc Date: Mon Nov 14 19:54:41 2016 New Revision: 286927 URL: http://llvm.org/viewvc/llvm-project?rev=286927&view=rev Log: [analyzer] Rename assumeWithinInclusiveRange*() Summary: The name is slightly confusing, since the constraint is not necessarily within the range unless `Assumption` is true. Split out renaming for ConstraintManager.h from D26061 Reviewers: zaks.anna, dcoughlin Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26644 Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.h Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h?rev=286927&r1=286926&r2=286927&view=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h Mon Nov 14 19:54:41 2016 @@ -36,7 +36,7 @@ public: /// Construct a ConstraintVal indicating the constraint is underconstrained. ConditionTruthVal() {} - + /// Return true if the constraint is perfectly constrained to 'true'. bool isConstrainedTrue() const { return Val.hasValue() && Val.getValue(); @@ -58,11 +58,11 @@ public: return !Val.hasValue(); } }; - + class ConstraintManager { public: ConstraintManager() : NotifyAssumeClients(true) {} - + virtual ~ConstraintManager(); virtual ProgramStateRef assume(ProgramStateRef state, DefinedSVal Cond, @@ -99,25 +99,26 @@ public: return ProgramStatePair(StTrue, StFalse); } - virtual ProgramStateRef assumeWithinInclusiveRange(ProgramStateRef State, - NonLoc Value, - const llvm::APSInt &From, - const llvm::APSInt &To, - bool InBound) = 0; - - virtual ProgramStatePair assumeWithinInclusiveRangeDual( - ProgramStateRef State, NonLoc Value, const llvm::APSInt &From, - const llvm::APSInt &To) { -ProgramStateRef StInRange = assumeWithinInclusiveRange(State, Value, From, - To, true); + virtual ProgramStateRef assumeInclusiveRange(ProgramStateRef State, + NonLoc Value, + const llvm::APSInt &From, + const llvm::APSInt &To, + bool InBound) = 0; + + virtual ProgramStatePair assumeInclusiveRangeDual(ProgramStateRef State, +NonLoc Value, +const llvm::APSInt &From, +const llvm::APSInt &To) { +ProgramStateRef StInRange = +assumeInclusiveRange(State, Value, From, To, true); // If StTrue is infeasible, asserting the falseness of Cond is unnecessary // because the existing constraints already establish this. if (!StInRange) return ProgramStatePair((ProgramStateRef)nullptr, State); -ProgramStateRef StOutOfRange = assumeWithinInclusiveRange(State, Value, - From, To, false); +ProgramStateRef StOutOfRange = +assumeInclusiveRange(State, Value, From, To, false); if (!StOutOfRange) { // We are careful to return the original state, /not/ StTrue, // because we want to avoid having callers generate a new node @@ -147,7 +148,7 @@ public: const char *sep) = 0; virtual void EndPath(ProgramStateRef state) {} - + /// Convenience method to query the state to see if a symbol is null or /// not null, or if neither assumption can be made. ConditionTruthVal isNull(ProgramStateRef State, SymbolRef Sym) { @@ -173,7 +174,7 @@ protected: virtual bool canReasonAbout(SVal X) const = 0; /// Returns whether or not a symbol is known to be null ("true"), known to be - /// non-null ("false"), or may be either ("underconstrained"). + /// non-null ("false"), or may be either ("underconstrained"). virtual ConditionTruthVal checkNull(ProgramStateRef State, SymbolRef Sym); }; Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/P
[PATCH] D26644: [analyzer] Rename assumeWithinInclusiveRange*()
This revision was automatically updated to reflect the committed changes. Closed by commit rL286927: [analyzer] Rename assumeWithinInclusiveRange*() (authored by ddcc). Changed prior to commit: https://reviews.llvm.org/D26644?vs=77930&id=77933#toc Repository: rL LLVM https://reviews.llvm.org/D26644 Files: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.h Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp === --- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -1836,7 +1836,7 @@ ProgramStateRef StateCase; if (Optional NL = CondV.getAs()) std::tie(StateCase, DefaultSt) = - DefaultSt->assumeWithinInclusiveRange(*NL, V1, V2); + DefaultSt->assumeInclusiveRange(*NL, V1, V2); else // UnknownVal StateCase = DefaultSt; Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.h === --- cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.h +++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.h @@ -38,7 +38,7 @@ ProgramStateRef assume(ProgramStateRef state, NonLoc Cond, bool Assumption); - ProgramStateRef assumeWithinInclusiveRange(ProgramStateRef State, + ProgramStateRef assumeInclusiveRange(ProgramStateRef State, NonLoc Value, const llvm::APSInt &From, const llvm::APSInt &To, Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp === --- cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp @@ -190,7 +190,7 @@ } // end switch } -ProgramStateRef SimpleConstraintManager::assumeWithinInclusiveRange( +ProgramStateRef SimpleConstraintManager::assumeInclusiveRange( ProgramStateRef State, NonLoc Value, const llvm::APSInt &From, const llvm::APSInt &To, bool InRange) { @@ -207,7 +207,7 @@ switch (Value.getSubKind()) { default: -llvm_unreachable("'assumeWithinInclusiveRange' is not implemented" +llvm_unreachable("'assumeInclusiveRange' is not implemented" "for this NonLoc"); case nonloc::LocAsIntegerKind: Index: cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp === --- cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp @@ -254,7 +254,7 @@ const llvm::APSInt &Min = BVF.getValue(R[I].first, T); const llvm::APSInt &Max = BVF.getValue(R[I].second, T); assert(Min <= Max); - State = CM.assumeWithinInclusiveRange(State, *N, Min, Max, false); + State = CM.assumeInclusiveRange(State, *N, Min, Max, false); if (!State) break; } @@ -288,24 +288,24 @@ const llvm::APSInt &Left = BVF.getValue(R[0].first - 1ULL, T); if (Left != PlusInf) { assert(MinusInf <= Left); - State = CM.assumeWithinInclusiveRange(State, *N, MinusInf, Left, false); + State = CM.assumeInclusiveRange(State, *N, MinusInf, Left, false); if (!State) return nullptr; } const llvm::APSInt &Right = BVF.getValue(R[E - 1].second + 1ULL, T); if (Right != MinusInf) { assert(Right <= PlusInf); - State = CM.assumeWithinInclusiveRange(State, *N, Right, PlusInf, false); + State = CM.assumeInclusiveRange(State, *N, Right, PlusInf, false); if (!State) return nullptr; } for (size_t I = 1; I != E; ++I) { const llvm::APSInt &Min = BVF.getValue(R[I - 1].second + 1ULL, T); const llvm::APSInt &Max = BVF.getValue(R[I].first - 1ULL, T); assert(Min <= Max); - State = CM.assumeWithinInclusiveRange(State, *N, Min, Max, false); + State = CM.assumeInclusiveRange(State, *N, Min, Max, false); if (!State) return nullptr; } Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h === --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h @@ -36,7 +36,7 @@ /// Construct a ConstraintVal indicating the constraint is underconstrained. ConditionTruthVal() {} -
[PATCH] D26061: [analyzer] Refactor and simplify SimpleConstraintManager
ddcc updated this revision to Diff 78049. ddcc added a comment. Rebase on recent changes https://reviews.llvm.org/D26061 Files: include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h include/clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h lib/StaticAnalyzer/Core/CMakeLists.txt lib/StaticAnalyzer/Core/ConstraintManager.cpp lib/StaticAnalyzer/Core/RangeConstraintManager.cpp lib/StaticAnalyzer/Core/RangedConstraintManager.cpp lib/StaticAnalyzer/Core/RangedConstraintManager.h lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp lib/StaticAnalyzer/Core/SimpleConstraintManager.h Index: lib/StaticAnalyzer/Core/SimpleConstraintManager.h === --- lib/StaticAnalyzer/Core/SimpleConstraintManager.h +++ /dev/null @@ -1,121 +0,0 @@ -//== SimpleConstraintManager.h --*- C++ -*--==// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===--===// -// -// Code shared between BasicConstraintManager and RangeConstraintManager. -// -//===--===// - -#ifndef LLVM_CLANG_LIB_STATICANALYZER_CORE_SIMPLECONSTRAINTMANAGER_H -#define LLVM_CLANG_LIB_STATICANALYZER_CORE_SIMPLECONSTRAINTMANAGER_H - -#include "clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h" -#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" - -namespace clang { - -namespace ento { - -class SimpleConstraintManager : public ConstraintManager { - SubEngine *SU; - SValBuilder &SVB; -public: - SimpleConstraintManager(SubEngine *subengine, SValBuilder &SB) -: SU(subengine), SVB(SB) {} - ~SimpleConstraintManager() override; - - //===--===// - // Common implementation for the interface provided by ConstraintManager. - //===--===// - - ProgramStateRef assume(ProgramStateRef state, DefinedSVal Cond, -bool Assumption) override; - - ProgramStateRef assume(ProgramStateRef state, NonLoc Cond, bool Assumption); - - ProgramStateRef assumeInclusiveRange(ProgramStateRef State, - NonLoc Value, - const llvm::APSInt &From, - const llvm::APSInt &To, - bool InRange) override; - - ProgramStateRef assumeSymRel(ProgramStateRef state, - const SymExpr *LHS, - BinaryOperator::Opcode op, - const llvm::APSInt& Int); - - ProgramStateRef assumeSymWithinInclusiveRange(ProgramStateRef State, -SymbolRef Sym, -const llvm::APSInt &From, -const llvm::APSInt &To, -bool InRange); - - -protected: - - //===--===// - // Interface that subclasses must implement. - //===--===// - - // Each of these is of the form "$sym+Adj <> V", where "<>" is the comparison - // operation for the method being invoked. - virtual ProgramStateRef assumeSymNE(ProgramStateRef state, SymbolRef sym, - const llvm::APSInt& V, - const llvm::APSInt& Adjustment) = 0; - - virtual ProgramStateRef assumeSymEQ(ProgramStateRef state, SymbolRef sym, - const llvm::APSInt& V, - const llvm::APSInt& Adjustment) = 0; - - virtual ProgramStateRef assumeSymLT(ProgramStateRef state, SymbolRef sym, - const llvm::APSInt& V, - const llvm::APSInt& Adjustment) = 0; - - virtual ProgramStateRef assumeSymGT(ProgramStateRef state, SymbolRef sym, - const llvm::APSInt& V, - const llvm::APSInt& Adjustment) = 0; - - virtual ProgramStateRef assumeSymLE(ProgramStateRef state, SymbolRef sym, - const llvm::APSInt& V, - const llvm::APSInt& Adjustment) = 0; - - virtual ProgramStateRef assumeSymGE(ProgramStateRef state, SymbolRef sym, - const llvm::APSInt& V, - const llvm::APSInt& Adjustment) = 0; - - - virtual ProgramStateRef assumeSymbolWithinInclusiveRange( -
[PATCH] D26691: [analyzer] Run clang-format and fix style
ddcc created this revision. ddcc added reviewers: zaks.anna, dcoughlin. ddcc added a subscriber: cfe-commits. Split out formatting and style changes from https://reviews.llvm.org/D26061 https://reviews.llvm.org/D26691 Files: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp lib/StaticAnalyzer/Core/SimpleConstraintManager.h Index: lib/StaticAnalyzer/Core/SimpleConstraintManager.h === --- lib/StaticAnalyzer/Core/SimpleConstraintManager.h +++ lib/StaticAnalyzer/Core/SimpleConstraintManager.h @@ -24,77 +24,72 @@ class SimpleConstraintManager : public ConstraintManager { SubEngine *SU; SValBuilder &SVB; + public: - SimpleConstraintManager(SubEngine *subengine, SValBuilder &SB) -: SU(subengine), SVB(SB) {} + SimpleConstraintManager(SubEngine *SE, SValBuilder &SB) : SU(SE), SVB(SB) {} ~SimpleConstraintManager() override; //===--===// // Common implementation for the interface provided by ConstraintManager. //===--===// - ProgramStateRef assume(ProgramStateRef state, DefinedSVal Cond, -bool Assumption) override; + ProgramStateRef assume(ProgramStateRef State, DefinedSVal Cond, + bool Assumption) override; - ProgramStateRef assume(ProgramStateRef state, NonLoc Cond, bool Assumption); + ProgramStateRef assume(ProgramStateRef State, NonLoc Cond, bool Assumption); - ProgramStateRef assumeInclusiveRange(ProgramStateRef State, - NonLoc Value, - const llvm::APSInt &From, - const llvm::APSInt &To, - bool InRange) override; + ProgramStateRef assumeInclusiveRange(ProgramStateRef State, NonLoc Value, + const llvm::APSInt &From, + const llvm::APSInt &To, + bool InRange) override; - ProgramStateRef assumeSymRel(ProgramStateRef state, - const SymExpr *LHS, - BinaryOperator::Opcode op, - const llvm::APSInt& Int); + ProgramStateRef assumeSymRel(ProgramStateRef State, const SymExpr *LHS, + BinaryOperator::Opcode Op, + const llvm::APSInt &Int); ProgramStateRef assumeSymWithinInclusiveRange(ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From, const llvm::APSInt &To, bool InRange); - protected: - //===--===// // Interface that subclasses must implement. //===--===// - // Each of these is of the form "$sym+Adj <> V", where "<>" is the comparison + // Each of these is of the form "$Sym+Adj <> V", where "<>" is the comparison // operation for the method being invoked. - virtual ProgramStateRef assumeSymNE(ProgramStateRef state, SymbolRef sym, - const llvm::APSInt& V, - const llvm::APSInt& Adjustment) = 0; + virtual ProgramStateRef assumeSymNE(ProgramStateRef State, SymbolRef Sym, + const llvm::APSInt &V, + const llvm::APSInt &Adjustment) = 0; - virtual ProgramStateRef assumeSymEQ(ProgramStateRef state, SymbolRef sym, - const llvm::APSInt& V, - const llvm::APSInt& Adjustment) = 0; + virtual ProgramStateRef assumeSymEQ(ProgramStateRef State, SymbolRef Sym, + const llvm::APSInt &V, + const llvm::APSInt &Adjustment) = 0; - virtual ProgramStateRef assumeSymLT(ProgramStateRef state, SymbolRef sym, - const llvm::APSInt& V, - const llvm::APSInt& Adjustment) = 0; + virtual ProgramStateRef assumeSymLT(ProgramStateRef State, SymbolRef Sym, + const llvm::APSInt &V, + const llvm::APSInt &Adjustment) = 0; - virtual ProgramStateRef assumeSymGT(ProgramStateRef state, SymbolRef sym, - const llvm::APSInt& V, - const llvm::APSInt& Adjustment) = 0; + virtual ProgramStateRef assumeSymGT(ProgramStateRef State, SymbolRef Sy
[PATCH] D26694: [analyzer] Drop explicit mention of range constraint solver
ddcc created this revision. ddcc added reviewers: zaks.anna, dcoughlin. ddcc added a subscriber: cfe-commits. The basic constraint solver was dropped in https://reviews.llvm.org/rL162384, leaving the range constraint solver as the default and only constraint solver. Explicitly specifying it is unnecessary, and makes it difficult to test with other solver backends. https://reviews.llvm.org/D26694 Files: test/Analysis/CFDateGC.m test/Analysis/CFNumber.c test/Analysis/CFRetainRelease_NSAssertionHandler.m test/Analysis/CGColorSpace.c test/Analysis/CheckNSError.m test/Analysis/NSPanel.m test/Analysis/NSString.m test/Analysis/NSWindow.m test/Analysis/ObjCProperties.m test/Analysis/PR2599.m test/Analysis/PR3991.m test/Analysis/additive-folding-range-constraints.c test/Analysis/additive-folding.cpp test/Analysis/array-struct-region.c test/Analysis/array-struct.c test/Analysis/cfref_PR2519.c test/Analysis/cfref_rdar6080742.c test/Analysis/comparison-implicit-casts.cpp test/Analysis/complex.c test/Analysis/dead-stores.c test/Analysis/dead-stores.cpp test/Analysis/misc-ps-64.m test/Analysis/misc-ps-eager-assume.m test/Analysis/misc-ps-ranges.m test/Analysis/misc-ps.m test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m test/Analysis/null-deref-ps.c test/Analysis/rdar-6562655.m test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m test/Analysis/reference.cpp test/Analysis/unions-region.m Index: test/Analysis/unions-region.m === --- test/Analysis/unions-region.m +++ test/Analysis/unions-region.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -analyzer-constraints=range %s -verify +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region %s -verify // expected-no-diagnostics //===-- unions-region.m ---===// Index: test/Analysis/reference.cpp === --- test/Analysis/reference.cpp +++ test/Analysis/reference.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -analyzer-constraints=range -verify -Wno-null-dereference -Wno-tautological-undefined-compare %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -verify -Wno-null-dereference -Wno-tautological-undefined-compare %s void clang_analyzer_eval(bool); Index: test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m === --- test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m +++ test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-constraints=range -analyzer-store=region -verify -Wno-objc-root-class %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s // expected-no-diagnostics typedef struct Foo { int x; } Bar; Index: test/Analysis/rdar-6562655.m === --- test/Analysis/rdar-6562655.m +++ test/Analysis/rdar-6562655.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-constraints=range -analyzer-store=region -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -verify %s // expected-no-diagnostics // // This test case mainly checks that the retain/release checker doesn't crash Index: test/Analysis/null-deref-ps.c === --- test/Analysis/null-deref-ps.c +++ test/Analysis/null-deref-ps.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode,alpha.core -std=gnu99 -analyzer-store=region -analyzer-constraints=range -analyzer-purge=none -verify %s -Wno-error=return-type -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode,alpha.core -std=gnu99 -analyzer-store=region -analyzer-constraints=range -verify %s -Wno-error=return-type +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode,alpha.core -std=gnu99 -analyzer-store=region -analyzer-purge=none -verify %s -Wno-error=return-type +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode,alpha.core -std=gnu99 -analyzer-store=region -verify %s -Wno-error=return-type typedef unsigned uintptr_t; Index: test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m === --- test/Analysis/nil-rec
[PATCH] D26773: [analyzer] Refactor recursive symbol reachability check to use symbol_iterator
ddcc created this revision. ddcc added reviewers: zaks.anna, dcoughlin. ddcc added a subscriber: cfe-commits. https://reviews.llvm.org/D26773 Files: lib/StaticAnalyzer/Core/ProgramState.cpp Index: lib/StaticAnalyzer/Core/ProgramState.cpp === --- lib/StaticAnalyzer/Core/ProgramState.cpp +++ lib/StaticAnalyzer/Core/ProgramState.cpp @@ -527,33 +527,22 @@ } bool ScanReachableSymbols::scan(const SymExpr *sym) { - bool wasVisited = !visited.insert(sym).second; - if (wasVisited) -return true; + bool Result = true; + for (SymExpr::symbol_iterator SI = sym->symbol_begin(), +SE = sym->symbol_end(); + SI != SE; ++SI) { +if (!isa(*SI)) + continue; - if (!visitor.VisitSymbol(sym)) -return false; +bool wasVisited = !visited.insert(*SI).second; +if (wasVisited) + continue; - // TODO: should be rewritten using SymExpr::symbol_iterator. - switch (sym->getKind()) { -case SymExpr::SymbolRegionValueKind: -case SymExpr::SymbolConjuredKind: -case SymExpr::SymbolDerivedKind: -case SymExpr::SymbolExtentKind: -case SymExpr::SymbolMetadataKind: - break; -case SymExpr::SymbolCastKind: - return scan(cast(sym)->getOperand()); -case SymExpr::SymIntExprKind: - return scan(cast(sym)->getLHS()); -case SymExpr::IntSymExprKind: - return scan(cast(sym)->getRHS()); -case SymExpr::SymSymExprKind: { - const SymSymExpr *x = cast(sym); - return scan(x->getLHS()) && scan(x->getRHS()); -} +if (!visitor.VisitSymbol(*SI)) + Result = false; } - return true; + + return Result; } bool ScanReachableSymbols::scan(SVal val) { Index: lib/StaticAnalyzer/Core/ProgramState.cpp === --- lib/StaticAnalyzer/Core/ProgramState.cpp +++ lib/StaticAnalyzer/Core/ProgramState.cpp @@ -527,33 +527,22 @@ } bool ScanReachableSymbols::scan(const SymExpr *sym) { - bool wasVisited = !visited.insert(sym).second; - if (wasVisited) -return true; + bool Result = true; + for (SymExpr::symbol_iterator SI = sym->symbol_begin(), +SE = sym->symbol_end(); + SI != SE; ++SI) { +if (!isa(*SI)) + continue; - if (!visitor.VisitSymbol(sym)) -return false; +bool wasVisited = !visited.insert(*SI).second; +if (wasVisited) + continue; - // TODO: should be rewritten using SymExpr::symbol_iterator. - switch (sym->getKind()) { -case SymExpr::SymbolRegionValueKind: -case SymExpr::SymbolConjuredKind: -case SymExpr::SymbolDerivedKind: -case SymExpr::SymbolExtentKind: -case SymExpr::SymbolMetadataKind: - break; -case SymExpr::SymbolCastKind: - return scan(cast(sym)->getOperand()); -case SymExpr::SymIntExprKind: - return scan(cast(sym)->getLHS()); -case SymExpr::IntSymExprKind: - return scan(cast(sym)->getRHS()); -case SymExpr::SymSymExprKind: { - const SymSymExpr *x = cast(sym); - return scan(x->getLHS()) && scan(x->getRHS()); -} +if (!visitor.VisitSymbol(*SI)) + Result = false; } - return true; + + return Result; } bool ScanReachableSymbols::scan(SVal val) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26773: [analyzer] Refactor recursive symbol reachability check to use symbol_iterator
ddcc updated this revision to Diff 78392. ddcc added a comment. Fix visitation, add early termination, add comments https://reviews.llvm.org/D26773 Files: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h lib/StaticAnalyzer/Core/ProgramState.cpp Index: lib/StaticAnalyzer/Core/ProgramState.cpp === --- lib/StaticAnalyzer/Core/ProgramState.cpp +++ lib/StaticAnalyzer/Core/ProgramState.cpp @@ -527,32 +527,17 @@ } bool ScanReachableSymbols::scan(const SymExpr *sym) { - bool wasVisited = !visited.insert(sym).second; - if (wasVisited) -return true; - - if (!visitor.VisitSymbol(sym)) -return false; + for (SymExpr::symbol_iterator SI = sym->symbol_begin(), +SE = sym->symbol_end(); + SI != SE; ++SI) { +bool wasVisited = !visited.insert(*SI).second; +if (wasVisited) + continue; - // TODO: should be rewritten using SymExpr::symbol_iterator. - switch (sym->getKind()) { -case SymExpr::SymbolRegionValueKind: -case SymExpr::SymbolConjuredKind: -case SymExpr::SymbolDerivedKind: -case SymExpr::SymbolExtentKind: -case SymExpr::SymbolMetadataKind: - break; -case SymExpr::SymbolCastKind: - return scan(cast(sym)->getOperand()); -case SymExpr::SymIntExprKind: - return scan(cast(sym)->getLHS()); -case SymExpr::IntSymExprKind: - return scan(cast(sym)->getRHS()); -case SymExpr::SymSymExprKind: { - const SymSymExpr *x = cast(sym); - return scan(x->getLHS()) && scan(x->getRHS()); -} +if (!visitor.VisitSymbol(*SI)) + return false; } + return true; } Index: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h === --- include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h @@ -824,8 +824,9 @@ } /// \class ScanReachableSymbols -/// A Utility class that allows to visit the reachable symbols using a custom -/// SymbolVisitor. +/// A utility class that visits the reachable symbols using a custom +/// SymbolVisitor. Terminates recursive traversal when the visitor function +/// returns false. class ScanReachableSymbols { typedef llvm::DenseSet VisitedItems; Index: lib/StaticAnalyzer/Core/ProgramState.cpp === --- lib/StaticAnalyzer/Core/ProgramState.cpp +++ lib/StaticAnalyzer/Core/ProgramState.cpp @@ -527,32 +527,17 @@ } bool ScanReachableSymbols::scan(const SymExpr *sym) { - bool wasVisited = !visited.insert(sym).second; - if (wasVisited) -return true; - - if (!visitor.VisitSymbol(sym)) -return false; + for (SymExpr::symbol_iterator SI = sym->symbol_begin(), +SE = sym->symbol_end(); + SI != SE; ++SI) { +bool wasVisited = !visited.insert(*SI).second; +if (wasVisited) + continue; - // TODO: should be rewritten using SymExpr::symbol_iterator. - switch (sym->getKind()) { -case SymExpr::SymbolRegionValueKind: -case SymExpr::SymbolConjuredKind: -case SymExpr::SymbolDerivedKind: -case SymExpr::SymbolExtentKind: -case SymExpr::SymbolMetadataKind: - break; -case SymExpr::SymbolCastKind: - return scan(cast(sym)->getOperand()); -case SymExpr::SymIntExprKind: - return scan(cast(sym)->getLHS()); -case SymExpr::IntSymExprKind: - return scan(cast(sym)->getRHS()); -case SymExpr::SymSymExprKind: { - const SymSymExpr *x = cast(sym); - return scan(x->getLHS()) && scan(x->getRHS()); -} +if (!visitor.VisitSymbol(*SI)) + return false; } + return true; } Index: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h === --- include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h @@ -824,8 +824,9 @@ } /// \class ScanReachableSymbols -/// A Utility class that allows to visit the reachable symbols using a custom -/// SymbolVisitor. +/// A utility class that visits the reachable symbols using a custom +/// SymbolVisitor. Terminates recursive traversal when the visitor function +/// returns false. class ScanReachableSymbols { typedef llvm::DenseSet VisitedItems; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26773: [analyzer] Refactor recursive symbol reachability check to use symbol_iterator
ddcc added a comment. I believe you're correct, the original code terminates early because of the short circuit evaluation on line 553, and visits all reachable nodes but doesn't recurse on non-SymbolData. https://reviews.llvm.org/D26773 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26773: [analyzer] Refactor recursive symbol reachability check to use symbol_iterator
This revision was automatically updated to reflect the committed changes. Closed by commit rL287380: [analyzer] Refactor recursive symbol reachability check to use symbol_iterator (authored by ddcc). Changed prior to commit: https://reviews.llvm.org/D26773?vs=78392&id=78575#toc Repository: rL LLVM https://reviews.llvm.org/D26773 Files: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h === --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h @@ -824,8 +824,9 @@ } /// \class ScanReachableSymbols -/// A Utility class that allows to visit the reachable symbols using a custom -/// SymbolVisitor. +/// A utility class that visits the reachable symbols using a custom +/// SymbolVisitor. Terminates recursive traversal when the visitor function +/// returns false. class ScanReachableSymbols { typedef llvm::DenseSet VisitedItems; Index: cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp === --- cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp @@ -527,32 +527,17 @@ } bool ScanReachableSymbols::scan(const SymExpr *sym) { - bool wasVisited = !visited.insert(sym).second; - if (wasVisited) -return true; - - if (!visitor.VisitSymbol(sym)) -return false; + for (SymExpr::symbol_iterator SI = sym->symbol_begin(), +SE = sym->symbol_end(); + SI != SE; ++SI) { +bool wasVisited = !visited.insert(*SI).second; +if (wasVisited) + continue; - // TODO: should be rewritten using SymExpr::symbol_iterator. - switch (sym->getKind()) { -case SymExpr::SymbolRegionValueKind: -case SymExpr::SymbolConjuredKind: -case SymExpr::SymbolDerivedKind: -case SymExpr::SymbolExtentKind: -case SymExpr::SymbolMetadataKind: - break; -case SymExpr::SymbolCastKind: - return scan(cast(sym)->getOperand()); -case SymExpr::SymIntExprKind: - return scan(cast(sym)->getLHS()); -case SymExpr::IntSymExprKind: - return scan(cast(sym)->getRHS()); -case SymExpr::SymSymExprKind: { - const SymSymExpr *x = cast(sym); - return scan(x->getLHS()) && scan(x->getRHS()); -} +if (!visitor.VisitSymbol(*SI)) + return false; } + return true; } Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h === --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h @@ -824,8 +824,9 @@ } /// \class ScanReachableSymbols -/// A Utility class that allows to visit the reachable symbols using a custom -/// SymbolVisitor. +/// A utility class that visits the reachable symbols using a custom +/// SymbolVisitor. Terminates recursive traversal when the visitor function +/// returns false. class ScanReachableSymbols { typedef llvm::DenseSet VisitedItems; Index: cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp === --- cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp @@ -527,32 +527,17 @@ } bool ScanReachableSymbols::scan(const SymExpr *sym) { - bool wasVisited = !visited.insert(sym).second; - if (wasVisited) -return true; - - if (!visitor.VisitSymbol(sym)) -return false; + for (SymExpr::symbol_iterator SI = sym->symbol_begin(), +SE = sym->symbol_end(); + SI != SE; ++SI) { +bool wasVisited = !visited.insert(*SI).second; +if (wasVisited) + continue; - // TODO: should be rewritten using SymExpr::symbol_iterator. - switch (sym->getKind()) { -case SymExpr::SymbolRegionValueKind: -case SymExpr::SymbolConjuredKind: -case SymExpr::SymbolDerivedKind: -case SymExpr::SymbolExtentKind: -case SymExpr::SymbolMetadataKind: - break; -case SymExpr::SymbolCastKind: - return scan(cast(sym)->getOperand()); -case SymExpr::SymIntExprKind: - return scan(cast(sym)->getLHS()); -case SymExpr::IntSymExprKind: - return scan(cast(sym)->getRHS()); -case SymExpr::SymSymExprKind: { - const SymSymExpr *x = cast(sym); - return scan(x->getLHS()) && scan(x->getRHS()); -} +if (!visitor.VisitSymbol(*SI)) + return false; } + return true; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r287380 - [analyzer] Refactor recursive symbol reachability check to use symbol_iterator
Author: ddcc Date: Fri Nov 18 15:07:03 2016 New Revision: 287380 URL: http://llvm.org/viewvc/llvm-project?rev=287380&view=rev Log: [analyzer] Refactor recursive symbol reachability check to use symbol_iterator Reviewers: zaks.anna, dcoughlin Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26773 Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h?rev=287380&r1=287379&r2=287380&view=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h Fri Nov 18 15:07:03 2016 @@ -824,8 +824,9 @@ CB ProgramState::scanReachableSymbols(co } /// \class ScanReachableSymbols -/// A Utility class that allows to visit the reachable symbols using a custom -/// SymbolVisitor. +/// A utility class that visits the reachable symbols using a custom +/// SymbolVisitor. Terminates recursive traversal when the visitor function +/// returns false. class ScanReachableSymbols { typedef llvm::DenseSet VisitedItems; Modified: cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp?rev=287380&r1=287379&r2=287380&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp Fri Nov 18 15:07:03 2016 @@ -527,32 +527,17 @@ bool ScanReachableSymbols::scan(nonloc:: } bool ScanReachableSymbols::scan(const SymExpr *sym) { - bool wasVisited = !visited.insert(sym).second; - if (wasVisited) -return true; + for (SymExpr::symbol_iterator SI = sym->symbol_begin(), +SE = sym->symbol_end(); + SI != SE; ++SI) { +bool wasVisited = !visited.insert(*SI).second; +if (wasVisited) + continue; - if (!visitor.VisitSymbol(sym)) -return false; - - // TODO: should be rewritten using SymExpr::symbol_iterator. - switch (sym->getKind()) { -case SymExpr::SymbolRegionValueKind: -case SymExpr::SymbolConjuredKind: -case SymExpr::SymbolDerivedKind: -case SymExpr::SymbolExtentKind: -case SymExpr::SymbolMetadataKind: - break; -case SymExpr::SymbolCastKind: - return scan(cast(sym)->getOperand()); -case SymExpr::SymIntExprKind: - return scan(cast(sym)->getLHS()); -case SymExpr::IntSymExprKind: - return scan(cast(sym)->getRHS()); -case SymExpr::SymSymExprKind: { - const SymSymExpr *x = cast(sym); - return scan(x->getLHS()) && scan(x->getRHS()); -} +if (!visitor.VisitSymbol(*SI)) + return false; } + return true; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26955: Fix bitwidth for x87 extended-precision floating-point type
ddcc created this revision. ddcc added a reviewer: rsmith. ddcc added a subscriber: cfe-commits. llvm::APFloat::x87DoubleExtended is defined as having 80 bits of size https://reviews.llvm.org/D26955 Files: lib/Basic/TargetInfo.cpp Index: lib/Basic/TargetInfo.cpp === --- lib/Basic/TargetInfo.cpp +++ lib/Basic/TargetInfo.cpp @@ -226,7 +226,7 @@ return Double; switch (BitWidth) { - case 96: + case 80: if (&getLongDoubleFormat() == &llvm::APFloat::x87DoubleExtended) return LongDouble; break; Index: lib/Basic/TargetInfo.cpp === --- lib/Basic/TargetInfo.cpp +++ lib/Basic/TargetInfo.cpp @@ -226,7 +226,7 @@ return Double; switch (BitWidth) { - case 96: + case 80: if (&getLongDoubleFormat() == &llvm::APFloat::x87DoubleExtended) return LongDouble; break; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26955: Fix bitwidth for x87 extended-precision floating-point type
ddcc added a comment. I could be completely mistaken here, but currently `Ctx.getRealTypeForBitwidth(llvm::APFloat::getSizeInBits(llvm::APFloat::x87DoubleExtended))` with a `ASTContext Ctx` does not round-trip correctly. https://reviews.llvm.org/D26955 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r288372 - [analyzer] Drop explicit mention of range constraint solver
Author: ddcc Date: Thu Dec 1 11:06:39 2016 New Revision: 288372 URL: http://llvm.org/viewvc/llvm-project?rev=288372&view=rev Log: [analyzer] Drop explicit mention of range constraint solver Summary: The basic constraint solver was dropped in rL162384, leaving the range constraint solver as the default and only constraint solver. Explicitly specifying it is unnecessary, and makes it difficult to test with other solver backends. Reviewers: zaks.anna, dcoughlin Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26694 Modified: cfe/trunk/test/Analysis/CFDateGC.m cfe/trunk/test/Analysis/CFNumber.c cfe/trunk/test/Analysis/CFRetainRelease_NSAssertionHandler.m cfe/trunk/test/Analysis/CGColorSpace.c cfe/trunk/test/Analysis/CheckNSError.m cfe/trunk/test/Analysis/NSPanel.m cfe/trunk/test/Analysis/NSString.m cfe/trunk/test/Analysis/NSWindow.m cfe/trunk/test/Analysis/ObjCProperties.m cfe/trunk/test/Analysis/PR2599.m cfe/trunk/test/Analysis/PR3991.m cfe/trunk/test/Analysis/additive-folding-range-constraints.c cfe/trunk/test/Analysis/additive-folding.cpp cfe/trunk/test/Analysis/array-struct-region.c cfe/trunk/test/Analysis/array-struct.c cfe/trunk/test/Analysis/cfref_PR2519.c cfe/trunk/test/Analysis/cfref_rdar6080742.c cfe/trunk/test/Analysis/comparison-implicit-casts.cpp cfe/trunk/test/Analysis/complex.c cfe/trunk/test/Analysis/dead-stores.c cfe/trunk/test/Analysis/dead-stores.cpp cfe/trunk/test/Analysis/misc-ps-64.m cfe/trunk/test/Analysis/misc-ps-eager-assume.m cfe/trunk/test/Analysis/misc-ps-ranges.m cfe/trunk/test/Analysis/misc-ps.m cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m cfe/trunk/test/Analysis/null-deref-ps.c cfe/trunk/test/Analysis/rdar-6562655.m cfe/trunk/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m cfe/trunk/test/Analysis/reference.cpp cfe/trunk/test/Analysis/unions-region.m Modified: cfe/trunk/test/Analysis/CFDateGC.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/CFDateGC.m?rev=288372&r1=288371&r2=288372&view=diff == --- cfe/trunk/test/Analysis/CFDateGC.m (original) +++ cfe/trunk/test/Analysis/CFDateGC.m Thu Dec 1 11:06:39 2016 @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -analyzer-constraints=range -verify -fobjc-gc %s -Wno-implicit-function-declaration +// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify -fobjc-gc %s -Wno-implicit-function-declaration //===--===// // The following code is reduced using delta-debugging from Modified: cfe/trunk/test/Analysis/CFNumber.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/CFNumber.c?rev=288372&r1=288371&r2=288372&view=diff == --- cfe/trunk/test/Analysis/CFNumber.c (original) +++ cfe/trunk/test/Analysis/CFNumber.c Thu Dec 1 11:06:39 2016 @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.coreFoundation.CFNumber,osx.cocoa.RetainCount -analyzer-store=region -analyzer-constraints=range -verify -triple x86_64-apple-darwin9 %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.coreFoundation.CFNumber,osx.cocoa.RetainCount -analyzer-store=region -verify -triple x86_64-apple-darwin9 %s typedef signed long CFIndex; typedef const struct __CFAllocator * CFAllocatorRef; Modified: cfe/trunk/test/Analysis/CFRetainRelease_NSAssertionHandler.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/CFRetainRelease_NSAssertionHandler.m?rev=288372&r1=288371&r2=288372&view=diff == --- cfe/trunk/test/Analysis/CFRetainRelease_NSAssertionHandler.m (original) +++ cfe/trunk/test/Analysis/CFRetainRelease_NSAssertionHandler.m Thu Dec 1 11:06:39 2016 @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -verify %s -analyzer-constraints=range -analyzer-store=region +// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -verify %s -analyzer-store=region // expected-no-diagnostics typedef struct objc_selector *SEL; Modified: cfe/trunk/test/Analysis/CGColorSpace.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/CGColorSpace.c?rev=288372&r1=288371&r2=288372&view=diff == --- cfe/trunk/test/Analysis/CGColorSpace.c (original) +++ cfe/trunk/test/Analysis/CGColorSpace.c Thu Dec 1 11:06:39 2016 @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -a
r288696 - [analyzer] Print type for SymbolRegionValues when dumping to stream
Author: ddcc Date: Mon Dec 5 14:30:11 2016 New Revision: 288696 URL: http://llvm.org/viewvc/llvm-project?rev=288696&view=rev Log: [analyzer] Print type for SymbolRegionValues when dumping to stream Reviewers: NoQ, dcoughlin, zaks.anna Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27365 Modified: cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp cfe/trunk/test/Analysis/expr-inspection.c Modified: cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp?rev=288696&r1=288695&r2=288696&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp Mon Dec 5 14:30:11 2016 @@ -85,7 +85,8 @@ void SymbolMetadata::dumpToStream(raw_os void SymbolData::anchor() { } void SymbolRegionValue::dumpToStream(raw_ostream &os) const { - os << "reg_$" << getSymbolID() << "<" << R << ">"; + os << "reg_$" << getSymbolID() + << '<' << getType().getAsString() << ' ' << R << '>'; } bool SymExpr::symbol_iterator::operator==(const symbol_iterator &X) const { Modified: cfe/trunk/test/Analysis/expr-inspection.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/expr-inspection.c?rev=288696&r1=288695&r2=288696&view=diff == --- cfe/trunk/test/Analysis/expr-inspection.c (original) +++ cfe/trunk/test/Analysis/expr-inspection.c Mon Dec 5 14:30:11 2016 @@ -7,7 +7,7 @@ void clang_analyzer_printState(); void clang_analyzer_numTimesReached(); void foo(int x) { - clang_analyzer_dump(x); // expected-warning{{reg_$0}} + clang_analyzer_dump(x); // expected-warning{{reg_$0}} int y = 1; clang_analyzer_printState(); for (; y < 3; ++y) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r289511 - [analyzer] Run clang-format and fix style
Author: ddcc Date: Mon Dec 12 19:40:41 2016 New Revision: 289511 URL: http://llvm.org/viewvc/llvm-project?rev=289511&view=rev Log: [analyzer] Run clang-format and fix style Summary: Split out formatting and style changes from D26061 Reviewers: zaks.anna, dcoughlin Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26691 Modified: cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.h Modified: cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp?rev=289511&r1=289510&r2=289511&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp Mon Dec 12 19:40:41 2016 @@ -27,22 +27,17 @@ using namespace ento; /// guarantee that from <= to. Note that Range is immutable, so as not /// to subvert RangeSet's immutability. namespace { -class Range : public std::pair { +class Range : public std::pair { public: Range(const llvm::APSInt &from, const llvm::APSInt &to) -: std::pair(&from, &to) { + : std::pair(&from, &to) { assert(from <= to); } bool Includes(const llvm::APSInt &v) const { return *first <= v && v <= *second; } - const llvm::APSInt &From() const { -return *first; - } - const llvm::APSInt &To() const { -return *second; - } + const llvm::APSInt &From() const { return *first; } + const llvm::APSInt &To() const { return *second; } const llvm::APSInt *getConcreteValue() const { return &From() == &To() ? &From() : nullptr; } @@ -53,7 +48,6 @@ public: } }; - class RangeTrait : public llvm::ImutContainerInfo { public: // When comparing if one Range is less than another, we should compare @@ -61,8 +55,8 @@ public: // consistent (instead of comparing by pointer values) and can potentially // be used to speed up some of the operations in RangeSet. static inline bool isLess(key_type_ref lhs, key_type_ref rhs) { -return *lhs.first < *rhs.first || (!(*rhs.first < *lhs.first) && - *lhs.second < *rhs.second); +return *lhs.first < *rhs.first || + (!(*rhs.first < *lhs.first) && *lhs.second < *rhs.second); } }; @@ -96,7 +90,7 @@ public: /// Construct a new RangeSet representing '{ [from, to] }'. RangeSet(Factory &F, const llvm::APSInt &from, const llvm::APSInt &to) -: ranges(F.add(F.getEmptySet(), Range(from, to))) {} + : ranges(F.add(F.getEmptySet(), Range(from, to))) {} /// Profile - Generates a hash profile of this RangeSet for use /// by FoldingSet. @@ -105,16 +99,14 @@ public: /// getConcreteValue - If a symbol is contrained to equal a specific integer /// constant then this method returns that value. Otherwise, it returns /// NULL. - const llvm::APSInt* getConcreteValue() const { + const llvm::APSInt *getConcreteValue() const { return ranges.isSingleton() ? ranges.begin()->getConcreteValue() : nullptr; } private: void IntersectInRange(BasicValueFactory &BV, Factory &F, -const llvm::APSInt &Lower, -const llvm::APSInt &Upper, -PrimRangeSet &newRanges, -PrimRangeSet::iterator &i, +const llvm::APSInt &Lower, const llvm::APSInt &Upper, +PrimRangeSet &newRanges, PrimRangeSet::iterator &i, PrimRangeSet::iterator &e) const { // There are six cases for each range R in the set: // 1. R is entirely before the intersection range. @@ -134,8 +126,8 @@ private: if (i->Includes(Lower)) { if (i->Includes(Upper)) { - newRanges = F.add(newRanges, Range(BV.getValue(Lower), - BV.getValue(Upper))); + newRanges = + F.add(newRanges, Range(BV.getValue(Lower), BV.getValue(Upper))); break; } else newRanges = F.add(newRanges, Range(BV.getValue(Lower), i->To())); @@ -243,8 +235,8 @@ public: // range is taken to wrap around. This is equivalent to taking the // intersection with the two ranges [Min, Upper] and [Lower, Max], // or, alternatively, /removing/ all integers between Upper and Lower. - RangeSet Intersect(BasicValueFactory &BV, Factory &F, - llvm::APSInt Lower, llvm::APSInt Upper) const { + RangeSet Intersect(BasicValueFactory &BV, Factory &F, llvm::APSInt Lower, + llvm::APSInt Upper) const { if (!pin(Lower, Upper)) return F.getEmptySet(); @@ -290,53 +282,54 @@ REGISTER_TRAIT_WITH_PROGRAMSTATE(Constra
[PATCH] D25663: [analyzer] Update alpha and potential checker documentation, esp. alpha.valist
This revision was automatically updated to reflect the committed changes. Closed by commit rL284445: [analyzer] Update alpha and potential checker documentation, esp. alpha.valist (authored by ddcc). Changed prior to commit: https://reviews.llvm.org/D25663?vs=74807&id=74941#toc Repository: rL LLVM https://reviews.llvm.org/D25663 Files: cfe/trunk/www/analyzer/alpha_checks.html cfe/trunk/www/analyzer/potential_checkers.html Index: cfe/trunk/www/analyzer/potential_checkers.html === --- cfe/trunk/www/analyzer/potential_checkers.html +++ cfe/trunk/www/analyzer/potential_checkers.html @@ -180,64 +180,6 @@ - -va_list - - -Name, DescriptionExampleProgress - - -valist.Uninitialized -(C) -Calls to the va_arg, va_copy, or -va_end macro must happen after calling va_start and -before calling va_end. - - -#include- -void test(int x, ...) { - va_list args; - int y = va_arg(args, int); // warn -} - - -#include - -void test(int x, ...) { - va_list args; - va_start(args, x); - va_end(args); - int z = va_arg(args, int); // warn -} - -http://llvm.org/bugs/show_bug.cgi?id=16812";> -PR16811 - - -valist.Unterminated -(C) -Every va_start must be matched by a va_end. A va_list -can only be ended once. - -This should be folded into the generalized "ownership checker" -described on the -Open Projects page. - - -#include - -void test(int x, ...) { - va_list args; - va_start(args, x); - int y = x + va_arg(args, int); -} // warn: missing va_end - -http://llvm.org/bugs/show_bug.cgi?id=16812";> -PR16812 - - - exceptions @@ -384,7 +326,8 @@ // warn: the right operand to '-' is always 0 } -removed from alpha.deadcode.* at r198476 +removed from alpha.deadcode.* at +https://reviews.llvm.org/rL198476";>r198476 Index: cfe/trunk/www/analyzer/alpha_checks.html === --- cfe/trunk/www/analyzer/alpha_checks.html +++ cfe/trunk/www/analyzer/alpha_checks.html @@ -26,13 +26,14 @@ Core Alpha Checkers C++ Alpha Checkers +Variable Argument Alpha Checkers Dead Code Alpha Checkers OS X Alpha Checkers Security Alpha Checkers Unix Alpha Checkers - + Core Alpha Checkers @@ -179,7 +180,7 @@ - + C++ Alpha Checkers @@ -226,7 +227,76 @@ - + + + +Variable Argument Alpha Checkers + + +Name, DescriptionExample + + + +alpha.valist.CopyToSelf +(C) +Calls to the va_copy macro should not copy onto itself. + + +#include + +void test(int x, ...) { + va_list args; + va_start(args, x); + va_copy(args, args); // warn + va_end(args); +} + + + +alpha.valist.Uninitialized +(C) +Calls to the va_arg, va_copy, or +va_end macro must happen after calling va_start and +before calling va_end. + + +#include + +void test(int x, ...) { + va_list args; + int y = va_arg(args, int); // warn +} + + +#include + +void test(int x, ...) { + va_list args; + va_start(args, x); + va_end(args); + int z = va_arg(args, int); // warn +} + + + +alpha.valist.Unterminated +(C) +Every va_start must be matched by a va_end. A va_list +can only be ended once. + + +#include + +void test(int x, ...) { + va_list args; + va_start(args, x); + int y = x + va_arg(args, int); +} // warn: missing va_end + + + + + Dead Code Alpha Checkers @@ -267,7 +337,7 @@ - + OS X Alpha Checkers @@ -433,7 +503,7 @@ - + Security Alpha Checkers @@ -584,7 +654,7 @@ - + Unix Alpha Checkers ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r284445 - [analyzer] Update alpha and potential checker documentation, esp. alpha.valist
Author: ddcc Date: Mon Oct 17 20:15:19 2016 New Revision: 284445 URL: http://llvm.org/viewvc/llvm-project?rev=284445&view=rev Log: [analyzer] Update alpha and potential checker documentation, esp. alpha.valist Summary: Move alpha.valist from potential to alpha since it was implemented in D15227 Cleanup some HTML comments, add a missing link Reviewers: jordan_rose, zaks.anna Subscribers: cfe-commits, xazax.hun Differential Revision: https://reviews.llvm.org/D25663 Modified: cfe/trunk/www/analyzer/alpha_checks.html cfe/trunk/www/analyzer/potential_checkers.html Modified: cfe/trunk/www/analyzer/alpha_checks.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/analyzer/alpha_checks.html?rev=284445&r1=28&r2=284445&view=diff == --- cfe/trunk/www/analyzer/alpha_checks.html (original) +++ cfe/trunk/www/analyzer/alpha_checks.html Mon Oct 17 20:15:19 2016 @@ -26,13 +26,14 @@ Patches welcome! Core Alpha Checkers C++ Alpha Checkers +Variable Argument Alpha Checkers Dead Code Alpha Checkers OS X Alpha Checkers Security Alpha Checkers Unix Alpha Checkers - + Core Alpha Checkers @@ -179,7 +180,7 @@ int test(struct s *p) { - + C++ Alpha Checkers @@ -226,7 +227,76 @@ public: - + + + +Variable Argument Alpha Checkers + + +Name, DescriptionExample + + + +alpha.valist.CopyToSelf +(C) +Calls to the va_copy macro should not copy onto itself. + + +#include+ +void test(int x, ...) { + va_list args; + va_start(args, x); + va_copy(args, args); // warn + va_end(args); +} + + + +alpha.valist.Uninitialized +(C) +Calls to the va_arg, va_copy, or +va_end macro must happen after calling va_start and +before calling va_end. + + +#include + +void test(int x, ...) { + va_list args; + int y = va_arg(args, int); // warn +} + + +#include + +void test(int x, ...) { + va_list args; + va_start(args, x); + va_end(args); + int z = va_arg(args, int); // warn +} + + + +alpha.valist.Unterminated +(C) +Every va_start must be matched by a va_end. A va_list +can only be ended once. + + +#include + +void test(int x, ...) { + va_list args; + va_start(args, x); + int y = x + va_arg(args, int); +} // warn: missing va_end + + + + + Dead Code Alpha Checkers @@ -267,7 +337,7 @@ void test(id x) { - + OS X Alpha Checkers @@ -433,7 +503,7 @@ invalidatable instance variables.< - + Security Alpha Checkers @@ -584,7 +654,7 @@ void test() { - + Unix Alpha Checkers Modified: cfe/trunk/www/analyzer/potential_checkers.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/analyzer/potential_checkers.html?rev=284445&r1=28&r2=284445&view=diff == --- cfe/trunk/www/analyzer/potential_checkers.html (original) +++ cfe/trunk/www/analyzer/potential_checkers.html Mon Oct 17 20:15:19 2016 @@ -180,64 +180,6 @@ void test(A *dst, A *src) { - -va_list - - -Name, DescriptionExampleProgress - - -valist.Uninitialized -(C) -Calls to the va_arg, va_copy, or -va_end macro must happen after calling va_start and -before calling va_end. - - -#include - -void test(int x, ...) { - va_list args; - int y = va_arg(args, int); // warn -} - - -#include - -void test(int x, ...) { - va_list args; - va_start(args, x); - va_end(args); - int z = va_arg(args, int); // warn -} - -http://llvm.org/bugs/show_bug.cgi?id=16812";> -PR16811 - - -valist.Unterminated -(C) -Every va_start must be matched by a va_end. A va_list -can only be ended once. - -This should be folded into the generalized "ownership checker" -described on the -Open Projects page. - - -#include - -void test(int x, ...) { - va_list args; - va_start(args, x); - int y = x + va_arg(args, int); -} // warn: missing va_end - -http://llvm.org/bugs/show_bug.cgi?id=16812";> -PR16812 - - - exceptions @@ -384,7 +326,8 @@ void test() { // warn: the right operand to '-' is always 0 } -removed from alpha.deadcode.* at r198476 +removed from alpha.deadcode.* at +https://reviews.llvm.org/rL198476";>r198476 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26061: [analyzer] Refactor and simplify SimpleConstraintManager
ddcc created this revision. ddcc added reviewers: zaks.anna, dcoughlin. ddcc added subscribers: cfe-commits, rgov, NoQ, xazax.hun. Herald added a subscriber: mgorny. SimpleConstraintManager is difficult to use, and makes assumptions about capabilities of the constraint manager. This patch refactors out those portions into a new RangedConstraintManager, and also fixes some issues with camel case, formatting, and confusing naming. https://reviews.llvm.org/D26061 Files: include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h include/clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp lib/StaticAnalyzer/Core/CMakeLists.txt lib/StaticAnalyzer/Core/ConstraintManager.cpp lib/StaticAnalyzer/Core/ExprEngine.cpp lib/StaticAnalyzer/Core/RangeConstraintManager.cpp lib/StaticAnalyzer/Core/RangedConstraintManager.cpp lib/StaticAnalyzer/Core/RangedConstraintManager.h lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp lib/StaticAnalyzer/Core/SimpleConstraintManager.h Index: lib/StaticAnalyzer/Core/SimpleConstraintManager.h === --- lib/StaticAnalyzer/Core/SimpleConstraintManager.h +++ /dev/null @@ -1,121 +0,0 @@ -//== SimpleConstraintManager.h --*- C++ -*--==// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===--===// -// -// Code shared between BasicConstraintManager and RangeConstraintManager. -// -//===--===// - -#ifndef LLVM_CLANG_LIB_STATICANALYZER_CORE_SIMPLECONSTRAINTMANAGER_H -#define LLVM_CLANG_LIB_STATICANALYZER_CORE_SIMPLECONSTRAINTMANAGER_H - -#include "clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h" -#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" - -namespace clang { - -namespace ento { - -class SimpleConstraintManager : public ConstraintManager { - SubEngine *SU; - SValBuilder &SVB; -public: - SimpleConstraintManager(SubEngine *subengine, SValBuilder &SB) -: SU(subengine), SVB(SB) {} - ~SimpleConstraintManager() override; - - //===--===// - // Common implementation for the interface provided by ConstraintManager. - //===--===// - - ProgramStateRef assume(ProgramStateRef state, DefinedSVal Cond, -bool Assumption) override; - - ProgramStateRef assume(ProgramStateRef state, NonLoc Cond, bool Assumption); - - ProgramStateRef assumeWithinInclusiveRange(ProgramStateRef State, - NonLoc Value, - const llvm::APSInt &From, - const llvm::APSInt &To, - bool InRange) override; - - ProgramStateRef assumeSymRel(ProgramStateRef state, - const SymExpr *LHS, - BinaryOperator::Opcode op, - const llvm::APSInt& Int); - - ProgramStateRef assumeSymWithinInclusiveRange(ProgramStateRef State, -SymbolRef Sym, -const llvm::APSInt &From, -const llvm::APSInt &To, -bool InRange); - - -protected: - - //===--===// - // Interface that subclasses must implement. - //===--===// - - // Each of these is of the form "$sym+Adj <> V", where "<>" is the comparison - // operation for the method being invoked. - virtual ProgramStateRef assumeSymNE(ProgramStateRef state, SymbolRef sym, - const llvm::APSInt& V, - const llvm::APSInt& Adjustment) = 0; - - virtual ProgramStateRef assumeSymEQ(ProgramStateRef state, SymbolRef sym, - const llvm::APSInt& V, - const llvm::APSInt& Adjustment) = 0; - - virtual ProgramStateRef assumeSymLT(ProgramStateRef state, SymbolRef sym, - const llvm::APSInt& V, - const llvm::APSInt& Adjustment) = 0; - - virtual ProgramStateRef assumeSymGT(ProgramStateRef state, SymbolRef sym, - const llvm::APSInt& V, - const llvm::APSInt&
[PATCH] D26061: [analyzer] Refactor and simplify SimpleConstraintManager
ddcc added a comment. To summarize, here is a list of changes: - General - Fixed some issues with formatting (`clang-format`) - Fixed inconsistent capitalization following camel case style guidelines - `ConstraintManager.h` - Renamed `assumeWithinInclusiveRange*()` to `assumeInclusiveRange*()`, since the range is not necessarily inclusive unless `Assumption` is true, to match `assume()` - `RangedConstraintManager.h` (inherits `SimpleConstraintManager`) - Moved `assumeSym*` and `canReasonAbout()` from `SimpleConstraintManager` to here - Renamed `assumeSymbolWithinInclusiveRange`/`assumeSymbolOutOfInclusiveRange` to `assumeSymWithinInclusiveRange`/`assumeSymOutsideInclusiveRange` to match the above, and moved to here - This is now inherited by `RangeConstraintManager`, and essentially provides the current interface in `SimpleConstraintManager` - `SimpleConstraintManager.h` (inherits `ConstraintManager`) - Implemented a new interface that internally converts the `DefinedSVal` in `assume(...)` from `ConstraintManager.h` to `NonLoc` to `SymbolRef`. Subclasses only need to override `ProgramStateRef assumeSym(ProgramStateRef State, SymbolRef Sym, bool Assumption)` - For inclusive ranges, implemented a new interface that internally converts from `NonLoc` to `SymbolRef`. Subclasses only need to override `ProgramStateRef assumeSymInclusiveRange(ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From, const llvm::APSInt &To, bool InRange)` - Implemented a new interface that internally handles expressions that fail `canReasonAbout()` by adding them directly to the constraint manager state. Subclasses only need to expose `ProgramStateRef assumeSymRel(ProgramStateRef State, SymbolRef Sym, BinaryOperator::Opcode op, const llvm::APSInt &Int)` - `RangeConstraintManager.cpp` - Minor optimization to avoid updating the state if nothing is pruned in `removeDeadBindings()` https://reviews.llvm.org/D26061 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26061: [analyzer] Refactor and simplify SimpleConstraintManager
ddcc added a comment. Yes, I've been writing a Z3 solver interface, which motivated this patch. However, this patch has snowballed into something that it's a little too convoluted, so I'll split it up. I'm not sure whether the RangedConstraintManager interface is useful or not; I preserved it because it's currently in the code, but since RangeConstraintManager is the only user, it is possible to merge the two together and eliminate the interface. In the past, BasicConstraintManager was the other class that used this interface, but that was deleted quite a while back, and I'm not sure if there are plans for anything else? https://reviews.llvm.org/D26061 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26373: [analyzer] Provide Contains() on ImmutableMap program state partial trait.
ddcc created this revision. ddcc added reviewers: zaks.anna, dcoughlin. ddcc added a subscriber: cfe-commits. https://reviews.llvm.org/D26373 Files: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h Index: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h === --- include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h @@ -8,7 +8,7 @@ //===--===// // // This file defines partial implementations of template specializations of -// the class ProgramStateTrait<>. ProgramStateTrait<> is used by ProgramState +// the class ProgramStateTrait<>. ProgramStateTrait<> is used by ProgramState // to implement set/get methods for manipulating a ProgramState's // generic data map. // @@ -81,6 +81,10 @@ return F.remove(B, K); } +static bool Contains(data_type B, key_type K) { + return B.contains(K); +} + static inline context_type MakeContext(void *p) { return *((typename data_type::Factory*) p); } @@ -185,7 +189,7 @@ } }; - + // Partial specialization for bool. template <> struct ProgramStatePartialTrait { typedef bool data_type; @@ -198,7 +202,7 @@ return (void*) (uintptr_t) d; } }; - + // Partial specialization for unsigned. template <> struct ProgramStatePartialTrait { typedef unsigned data_type; Index: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h === --- include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h @@ -8,7 +8,7 @@ //===--===// // // This file defines partial implementations of template specializations of -// the class ProgramStateTrait<>. ProgramStateTrait<> is used by ProgramState +// the class ProgramStateTrait<>. ProgramStateTrait<> is used by ProgramState // to implement set/get methods for manipulating a ProgramState's // generic data map. // @@ -81,6 +81,10 @@ return F.remove(B, K); } +static bool Contains(data_type B, key_type K) { + return B.contains(K); +} + static inline context_type MakeContext(void *p) { return *((typename data_type::Factory*) p); } @@ -185,7 +189,7 @@ } }; - + // Partial specialization for bool. template <> struct ProgramStatePartialTrait { typedef bool data_type; @@ -198,7 +202,7 @@ return (void*) (uintptr_t) d; } }; - + // Partial specialization for unsigned. template <> struct ProgramStatePartialTrait { typedef unsigned data_type; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26373: [analyzer] Provide Contains() on ImmutableMap program state partial trait.
ddcc added a comment. Even though there isn't a performance difference, I think it is semantically clearer since it is explicit that the value is unneeded. The interface of ProgramState provides a `contains()` function that calls into `Contains()` of the underlying partial traits as part of its implementation. That function is present for `ImmutableSet` and `ImmutableList`, so it is inconsistent that `ImmutableMap` doesn't have it. I've been working on a Z3 constraint backend that uses this, though the implementation has been trickier than I expected. https://reviews.llvm.org/D26373 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286306 - [analyzer] Provide Contains() on ImmutableMap program state partial trait.
Author: ddcc Date: Tue Nov 8 16:39:14 2016 New Revision: 286306 URL: http://llvm.org/viewvc/llvm-project?rev=286306&view=rev Log: [analyzer] Provide Contains() on ImmutableMap program state partial trait. Reviewers: zaks.anna, dcoughlin Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26373 Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h?rev=286306&r1=286305&r2=286306&view=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h Tue Nov 8 16:39:14 2016 @@ -8,7 +8,7 @@ //===--===// // // This file defines partial implementations of template specializations of -// the class ProgramStateTrait<>. ProgramStateTrait<> is used by ProgramState +// the class ProgramStateTrait<>. ProgramStateTrait<> is used by ProgramState // to implement set/get methods for manipulating a ProgramState's // generic data map. // @@ -81,6 +81,10 @@ namespace ento { return F.remove(B, K); } +static bool Contains(data_type B, key_type K) { + return B.contains(K); +} + static inline context_type MakeContext(void *p) { return *((typename data_type::Factory*) p); } @@ -185,7 +189,7 @@ namespace ento { } }; - + // Partial specialization for bool. template <> struct ProgramStatePartialTrait { typedef bool data_type; @@ -198,7 +202,7 @@ namespace ento { return (void*) (uintptr_t) d; } }; - + // Partial specialization for unsigned. template <> struct ProgramStatePartialTrait { typedef unsigned data_type; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26373: [analyzer] Provide Contains() on ImmutableMap program state partial trait.
This revision was automatically updated to reflect the committed changes. Closed by commit rL286306: [analyzer] Provide Contains() on ImmutableMap program state partial trait. (authored by ddcc). Changed prior to commit: https://reviews.llvm.org/D26373?vs=77109&id=77269#toc Repository: rL LLVM https://reviews.llvm.org/D26373 Files: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h === --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h @@ -8,7 +8,7 @@ //===--===// // // This file defines partial implementations of template specializations of -// the class ProgramStateTrait<>. ProgramStateTrait<> is used by ProgramState +// the class ProgramStateTrait<>. ProgramStateTrait<> is used by ProgramState // to implement set/get methods for manipulating a ProgramState's // generic data map. // @@ -81,6 +81,10 @@ return F.remove(B, K); } +static bool Contains(data_type B, key_type K) { + return B.contains(K); +} + static inline context_type MakeContext(void *p) { return *((typename data_type::Factory*) p); } @@ -185,7 +189,7 @@ } }; - + // Partial specialization for bool. template <> struct ProgramStatePartialTrait { typedef bool data_type; @@ -198,7 +202,7 @@ return (void*) (uintptr_t) d; } }; - + // Partial specialization for unsigned. template <> struct ProgramStatePartialTrait { typedef unsigned data_type; Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h === --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h @@ -8,7 +8,7 @@ //===--===// // // This file defines partial implementations of template specializations of -// the class ProgramStateTrait<>. ProgramStateTrait<> is used by ProgramState +// the class ProgramStateTrait<>. ProgramStateTrait<> is used by ProgramState // to implement set/get methods for manipulating a ProgramState's // generic data map. // @@ -81,6 +81,10 @@ return F.remove(B, K); } +static bool Contains(data_type B, key_type K) { + return B.contains(K); +} + static inline context_type MakeContext(void *p) { return *((typename data_type::Factory*) p); } @@ -185,7 +189,7 @@ } }; - + // Partial specialization for bool. template <> struct ProgramStatePartialTrait { typedef bool data_type; @@ -198,7 +202,7 @@ return (void*) (uintptr_t) d; } }; - + // Partial specialization for unsigned. template <> struct ProgramStatePartialTrait { typedef unsigned data_type; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23244: [Driver] Enable CFI for WebAssembly
ddcc added a comment. Can you land it? I don't have commit access. https://reviews.llvm.org/D23244 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits