An AtomicType might be hidden behind arbitrary levels of typedefs.
getAs<> will reliably walk through the sugar to get the underlying
AtomicType.
This fixes PR23638.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@238083
91177308-0d34-0410-b5e6-
96231b3b80d8
// TODO: Investigate using GetExprRange() to get tighter bounds
// on the bit ranges.
QualType OtherT = Other->getType();
- if (const AtomicType *AT = dyn_cast<AtomicType>(OtherT))
+ if (const auto *AT = OtherT->getAs<AtomicType>())
OtherT = AT->getValueType();
IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
unsigned OtherWidth = OtherRange.Width;
if (!a > b) {} // no warning
if (!a > -1) {} // expected-warning {{comparison of constant -1 with boolean expression is always true}}
}
+
+typedef _Atomic(int) Ty;
+void PR23638(Ty *a) {
+ if (*a == 1) {} // no warning
+}