================
@@ -1384,6 +1397,65 @@ TEST_F(QualifierFixerTest, TemplatesLeft) {
"TemplateType<Container const> t;", Style);
}
+TEST_F(QualifierFixerTest, NewQualifierSupport) {
+ FormatStyle Style = getLLVMStyle();
+ Style.QualifierAlignment = FormatStyle::QAS_Custom;
+
+ // Test typedef qualifier
+ Style.QualifierOrder = {"typedef", "type"};
+ verifyFormat("typedef int MyInt;", Style);
+
+ // Test consteval qualifier
+ Style.QualifierOrder = {"consteval", "type"};
+ verifyFormat("consteval int func();", "int consteval func();", Style);
+
+ // Test constinit qualifier
+ Style.QualifierOrder = {"constinit", "static", "type"};
+ verifyFormat("constinit static int var = 10;", "static constinit int var =
10;", Style);
+
+ // Test thread_local qualifier
+ Style.QualifierOrder = {"thread_local", "static", "type"};
+ verifyFormat("thread_local static int counter;", "static thread_local int
counter;", Style);
+
+ // Test extern qualifier
+ Style.QualifierOrder = {"extern", "type"};
+ verifyFormat("extern int global_var;", "int extern global_var;", Style);
+
+ // Test mutable qualifier
+ Style.QualifierOrder = {"mutable", "type"};
+ verifyFormat("mutable int cache;", "int mutable cache;", Style);
+
+ // Test signed/unsigned qualifiers
+ Style.QualifierOrder = {"signed", "type"};
+ verifyFormat("signed int num;", "int signed num;", Style);
+ Style.QualifierOrder = {"unsigned", "type"};
+ verifyFormat("unsigned int num;", "int unsigned num;", Style);
+
+ // Test long/short qualifiers
+ Style.QualifierOrder = {"long", "type"};
+ verifyFormat("long int num;", "int long num;", Style);
+ Style.QualifierOrder = {"short", "type"};
+ verifyFormat("short int num;", "int short num;", Style);
+
+ // Test decltype qualifier
+ Style.QualifierOrder = {"decltype", "type"};
+ // Note: decltype is typically used with parentheses and doesn't usually get
reordered
+ // This test mainly verifies it's recognized as a qualifier
----------------
HazardyKnusperkeks wrote:
I'd drop this as a configure option, and (in a different PR) try to handle
`decltype(...)` as type, because that's what it is.
https://github.com/llvm/llvm-project/pull/160853
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits