[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 3 10:54:34 PST 2024


================
@@ -34,9 +34,15 @@ const char *getTokenTypeName(TokenType Type) {
   return nullptr;
 }
 
+// Sorted common C++ non-keyword types.
+static SmallVector<StringRef> CppNonKeywordTypes = {
+    "byte",   "int16_t",  "int32_t",  "int64_t",  "int8_t",
+    "size_t", "uint16_t", "uint32_t", "uint64_t", "uint8_t",
----------------
zygoloid wrote:

Maybe also `ptrdiff_t`, `intptr_t`, `uintptr_t`. And there's also `float_t`, `double_t`, `uint_least32_t`, ...

I wonder if the best heuristic to use here would be simply to look for an identifier that matches `[a-z0-9_]*_t`.

https://github.com/llvm/llvm-project/pull/83709


More information about the cfe-commits mailing list