-
Notifications
You must be signed in to change notification settings - Fork 14.5k
[clang] improve consistency with GCC vector comparison #148954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -876,6 +876,15 @@ class ASTContext : public RefCountedBase<ASTContext> { | |||||||||||||||||
QualType getIntTypeForBitwidth(unsigned DestWidth, | ||||||||||||||||||
unsigned Signed) const; | ||||||||||||||||||
|
||||||||||||||||||
/// getGCCCompatibleIntTypeForBitwidth - | ||||||||||||||||||
/// sets integer QualTy according to specified details: | ||||||||||||||||||
/// bitwidth, signed/unsigned. | ||||||||||||||||||
/// this function is compatible with GCC's preference: | ||||||||||||||||||
/// int > signed char > short > long > long long > int128_t | ||||||||||||||||||
/// Returns empty type if there is no appropriate target types. | ||||||||||||||||||
QualType getGCCCompatibleIntTypeForBitwidth(unsigned DestWidth, | ||||||||||||||||||
unsigned Signed) const; | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The parameters are intentionally the same as the parameters of llvm-project/clang/include/clang/AST/ASTContext.h Lines 877 to 882 in abce4e9
Is this a tradition in LLVM? Or I should just use |
||||||||||||||||||
|
||||||||||||||||||
/// getRealTypeForBitwidth - | ||||||||||||||||||
/// sets floating point QualTy according to specified bitwidth. | ||||||||||||||||||
/// Returns empty type if there is no appropriate target types. | ||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -13206,6 +13206,30 @@ QualType ASTContext::getIntTypeForBitwidth(unsigned DestWidth, | |||||
return QualTy; | ||||||
} | ||||||
|
||||||
/// getGCCCompatibleIntTypeForBitwidth - | ||||||
/// sets integer QualTy according to specified details: | ||||||
/// bitwidth, signed/unsigned. | ||||||
/// this function is compatible with GCC's preference: | ||||||
/// int > signed char > short > long > long long > int128_t | ||||||
/// Returns empty type if there is no appropriate target types. | ||||||
QualType ASTContext::getGCCCompatibleIntTypeForBitwidth(unsigned DestWidth, | ||||||
unsigned Signed) const { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
const TargetInfo &Target = getTargetInfo(); | ||||||
if (Target.getIntWidth() == DestWidth) | ||||||
return Signed ? IntTy : UnsignedIntTy; | ||||||
if (Target.getCharWidth() == DestWidth) | ||||||
return Signed ? SignedCharTy : UnsignedCharTy; | ||||||
if (Target.getShortWidth() == DestWidth) | ||||||
return Signed ? ShortTy : UnsignedShortTy; | ||||||
if (Target.getLongWidth() == DestWidth) | ||||||
return Signed ? LongTy : UnsignedLongTy; | ||||||
if (Target.getLongLongWidth() == DestWidth) | ||||||
return Signed ? LongLongTy : UnsignedLongLongTy; | ||||||
if (DestWidth == 128) | ||||||
return Signed ? Int128Ty : UnsignedInt128Ty; | ||||||
return {}; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably assert if we don't find one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The behavior of returning an |
||||||
} | ||||||
|
||||||
/// getRealTypeForBitwidth - | ||||||
/// sets floating point QualTy according to specified bitwidth. | ||||||
/// Returns empty type if there is no appropriate target types. | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The term
empty type
is also used in documentation ofgetIntTypeForBitwidth
andgetRealTypeForBitwidth
series. I guess keeping them unified is probably better?llvm-project/clang/include/clang/AST/ASTContext.h
Lines 877 to 888 in abce4e9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah okay, that's pre-existing inconsistency (because in QualType itself we call this state 'Null'), so leaving it as 'empty' here is fine.