This revision was automatically updated to reflect the committed changes.
Closed by commit rL316268: [Sema] Fixes for enum handling for tautological
comparison diagnostics (authored by lebedevri).
Changed prior to commit:
https://reviews.llvm.org/D39122?vs=119759&id=119760#toc
Repository:
rL
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.
LGTM!
Comment at: lib/Sema/SemaChecking.cpp:8619
+ if (OtherRange.Width == 0)
+return Value == 0 ? LimitType::Both : llvm::Optional();
+
l
lebedev.ri updated this revision to Diff 119759.
lebedev.ri marked an inline comment as done.
lebedev.ri added a comment.
Address review notes.
Repository:
rL LLVM
https://reviews.llvm.org/D39122
Files:
lib/Sema/SemaChecking.cpp
test/Sema/outof-range-enum-constant-compare.c
test/Sema/t
lebedev.ri added inline comments.
Comment at: lib/Sema/SemaChecking.cpp:8619
+ if (OtherRange.Width == 0)
+return Value == 0 ? LimitType::Both : llvm::Optional();
+
aaron.ballman wrote:
> Instead of default constructing the Optional, you should use `llvm::No
aaron.ballman added inline comments.
Comment at: lib/Sema/SemaChecking.cpp:8186
+ // For enum types, for C code, use underlying data type.
+ if (const EnumType *ET = dyn_cast(T))
+T = ET->getDecl()->getIntegerType().getDesugaredType(C).getTypePtr();
lebedev.ri added inline comments.
Comment at: lib/Sema/SemaChecking.cpp:8186
+ // For enum types, for C code, use underlying data type.
+ if (const EnumType *ET = dyn_cast(T))
+T = ET->getDecl()->getIntegerType().getDesugaredType(C).getTypePtr();
---
lebedev.ri updated this revision to Diff 119757.
lebedev.ri marked 2 inline comments as done.
lebedev.ri added a comment.
Address review notes.
Repository:
rL LLVM
https://reviews.llvm.org/D39122
Files:
lib/Sema/SemaChecking.cpp
test/Sema/outof-range-enum-constant-compare.c
test/Sema/t
aaron.ballman added inline comments.
Comment at: lib/Sema/SemaChecking.cpp:8185
+if (!C.getLangOpts().CPlusPlus) {
+ // For enum types, for C code, use underlying data type.
+ if (const EnumType *ET = dyn_cast(T))
For enum types in C code, use the u
lebedev.ri updated this revision to Diff 119705.
lebedev.ri marked 5 inline comments as done.
lebedev.ri added a comment.
Addressed review notes.
For C++, enum handling clearly needs more work, because not all tautological
comparisons are actually diagnosed,
so there is no `clang/test/Sema/outo
Rakete added inline comments.
Comment at: lib/Sema/SemaChecking.cpp:8610
+ if(!S.getLangOpts().CPlusPlus && OtherT->isEnumeralType()) {
+OtherT = OtherT->getAs()->getDecl()->getIntegerType();
Please drop the braces.
Comment at: lib/S
efriedma added inline comments.
Comment at: lib/Sema/SemaChecking.cpp:8612
+OtherT = OtherT->getAs()->getDecl()->getIntegerType();
+ }
+
Why are you changing this here, as opposed to changing
IntRange::forValueOfCanonicalType?
Repository:
rL LLVM
https
lebedev.ri created this revision.
lebedev.ri added a project: clang.
As Mattias Eriksson has reported in PR35009, in C, for enums, the underlying
type should
be used when checking for the tautological comparison, unlike C++, where the
enumerator
values define the value range. So if not in CPlus
12 matches
Mail list logo