File tree 2 files changed +14
-0
lines changed
include/clang/StaticAnalyzer/Core/PathSensitive
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,12 @@ class BasicValueFactory {
139
139
140
140
// / Returns the type of the APSInt used to store values of the given QualType.
141
141
APSIntType getAPSIntType (QualType T) const {
142
+ // For the purposes of the analysis and constraints, we treat atomics
143
+ // as their underlying types.
144
+ if (const AtomicType *AT = T->getAs <AtomicType>()) {
145
+ T = AT->getValueType ();
146
+ }
147
+
142
148
assert (T->isIntegralOrEnumerationType () || Loc::isLocType (T));
143
149
return APSIntType (Ctx.getIntWidth (T),
144
150
!T->isSignedIntegerOrEnumerationType ());
Original file line number Diff line number Diff line change @@ -93,3 +93,11 @@ void test_atomic_compare_exchange_weak(struct RefCountedStruct *s) {
93
93
clang_analyzer_eval (s -> refCount == 3 ); // expected-warning {{UNKNOWN}}
94
94
clang_analyzer_eval (expected == 2 ); // expected-warning {{UNKNOWN}}
95
95
}
96
+
97
+ // PR49422
98
+ void test_atomic_compare (int input ) {
99
+ _Atomic(int ) x = input ;
100
+ if (x > 0 ) {
101
+ // no crash
102
+ }
103
+ }
You can’t perform that action at this time.
0 commit comments