This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Rename StringLiteral::isAscii() => isOrdinary() [NFC]
ClosedPublic

Authored by cor3ntin on Jun 28 2022, 2:55 PM.

Details

Summary

"Ascii" StringLiteral instances are actually narrow strings
that are UTF-8 encoded and do not have an encoding prefix.
(UTF8 StringLiteral are also UTF-8 encoded strings, but with
the u8 prefix.

To avoid possible confusion both with actuall ASCII strings,
and with future works extending the set of literal encodings
supported by clang, this rename StringLiteral::isAscii() to
isOrdinary(), matching C++ standard terminology.

Diff Detail

Event Timeline

cor3ntin created this revision.Jun 28 2022, 2:55 PM
Herald added a project: Restricted Project. · View Herald Transcript
cor3ntin requested review of this revision.Jun 28 2022, 2:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 28 2022, 2:55 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
aaron.ballman added inline comments.Jun 29 2022, 6:06 AM
clang/include/clang/AST/Expr.h
1789–1886

I like the idea of renaming both of these -- isASCII() can be a bit confusing with containsNonAscii() as well. However, instead of "ordinary", would it make more sense to go with "narrow" as the term of art? That also goes nicely with the use of "wide" in this interface.

Also, precommit CI pointed out that you need to make some additional changes in clang-tools-extra to avoid build errors.

cor3ntin updated this revision to Diff 440994.Jun 29 2022, 7:00 AM
  • fix clang-tidy build
  • apply the same change in StringLiteralParser/CharLiteralParser
cor3ntin added inline comments.Jun 29 2022, 7:03 AM
clang/include/clang/AST/Expr.h
1789–1886

narrow encompass ordinary and u8 literals in standard terminology.
And, I think narrow is too easilly mistaken as a synonym for getByteLength() == 1

aaron.ballman accepted this revision.Jun 29 2022, 8:01 AM

Assuming precommit CI comes back clean, this LGTM!

clang/include/clang/AST/Expr.h
1789–1886

Ah, okay, I didn't remember correctly that narrow included UTF-8 literals. "Ordinary" is fine by me, thank you!

This revision is now accepted and ready to land.Jun 29 2022, 8:01 AM

Just stopping by to say, thank you @cor3ntin!