aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/IdentifierTable.cpp
diff options
context:
space:
mode:
authorPo-yao Chang <poyaoc97@gmail.com>2023-07-13 23:42:51 +0800
committerPo-yao Chang <poyaoc97@gmail.com>2023-07-19 07:23:34 +0800
commit5ce5e983f82c802e44faa8ed42d605d70c045ba9 (patch)
tree9f23ade1a166729184db4ab6bde61f36eac1a48c /clang/lib/Basic/IdentifierTable.cpp
parentab9b3c84a588f86e7f66eeb577bea7155817ff06 (diff)
downloadllvm-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.cpp13
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() == '_' &&