diff options
author | Po-yao Chang <poyaoc97@gmail.com> | 2023-07-13 23:42:51 +0800 |
---|---|---|
committer | Po-yao Chang <poyaoc97@gmail.com> | 2023-07-19 07:23:34 +0800 |
commit | 5ce5e983f82c802e44faa8ed42d605d70c045ba9 (patch) | |
tree | 9f23ade1a166729184db4ab6bde61f36eac1a48c /clang/lib/Basic/IdentifierTable.cpp | |
parent | ab9b3c84a588f86e7f66eeb577bea7155817ff06 (diff) | |
download | llvm-5ce5e983f82c802e44faa8ed42d605d70c045ba9.zip llvm-5ce5e983f82c802e44faa8ed42d605d70c045ba9.tar.gz llvm-5ce5e983f82c802e44faa8ed42d605d70c045ba9.tar.bz2 |
[Clang] Add warnings for CWG2521
1. Teach -Wuser-defined-literals to warn on using double underscores in
literal suffix identifiers.
2. Add -Wdeprecated-literal-operator to warn about the use of the first
grammar production of literal-operator-id, which defaults to off for now.
Differential Revision: https://reviews.llvm.org/D152632
Diffstat (limited to 'clang/lib/Basic/IdentifierTable.cpp')
-rw-r--r-- | clang/lib/Basic/IdentifierTable.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp index 661e9f7..0065a61 100644 --- a/clang/lib/Basic/IdentifierTable.cpp +++ b/clang/lib/Basic/IdentifierTable.cpp @@ -397,6 +397,19 @@ IdentifierInfo::isReserved(const LangOptions &LangOpts) const { return ReservedIdentifierStatus::NotReserved; } +ReservedLiteralSuffixIdStatus +IdentifierInfo::isReservedLiteralSuffixId() const { + StringRef Name = getName(); + + if (Name[0] != '_') + return ReservedLiteralSuffixIdStatus::NotStartsWithUnderscore; + + if (Name.contains("__")) + return ReservedLiteralSuffixIdStatus::ContainsDoubleUnderscore; + + return ReservedLiteralSuffixIdStatus::NotReserved; +} + StringRef IdentifierInfo::deuglifiedName() const { StringRef Name = getName(); if (Name.size() >= 2 && Name.front() == '_' && |