aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Format/UnwrappedLineParser.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-07-13[clang-format] Add MacrosSkippedByRemoveParentheses option (#148345)Owen Pan1-5/+9
This allows RemoveParentheses to skip the invocations of function-like macros. Fixes #68354. Fixes #147780.
2025-07-06[clang-format][NFC] Use `empty()` instead of comparing size() to 0 or 1Owen Pan1-1/+1
2025-06-26[clang-format][NFC] Remove `\brief` from comments (#145853)Owen Pan1-6/+6
This was done before in https://reviews.llvm.org/D46320
2025-06-09[clang-format] Parse JSON outermost l_brace as braced list brace (#143327)Owen Pan1-1/+1
See https://github.com/llvm/llvm-project/issues/65400#issuecomment-2922181979.
2025-06-05[clang-format] Handle requires clause following a pointer type (#142893)Owen Pan1-0/+1
Fix #142818
2025-05-31[Format] Remove unused includes (NFC) (#142296)Kazu Hirata1-2/+0
These are identified by misc-include-cleaner. I've filtered out those that break builds. Also, I'm staying away from llvm-config.h, config.h, and Compiler.h, which likely cause platform- or compiler-specific build failures.
2025-05-09[clang-format] Handle Java record (#139215)Owen Pan1-3/+10
Fix #62089
2025-05-02[clang-format] Fix a crash on formatting missing r_paren/r_brace (#138230)Owen Pan1-2/+2
Fix #138097
2025-05-02[clang-format] RemoveParentheses shouldn't remove empty parentheses (#138229)Owen Pan1-1/+2
Fix #138124
2025-04-26[clang-format] Correctly handle C# new modifier (#137430)Owen Pan1-1/+7
Fix #75815
2025-04-25[clang-format][NFC] Use UnwrappedLineParser::eof() whenever possibleOwen Pan1-2/+2
2025-04-25[clang-format] Correctly handle C# where clause (#137295)Owen Pan1-0/+1
Fix #74947
2025-04-24[clang-format] Correctly identify include guards (#137112)Owen Pan1-0/+7
Fix #136814
2025-04-22[clang-format] Fix a bug in parsing C-style cast of lambdas (#136099)Owen Pan1-6/+18
Fix #135959
2025-04-16[clang-format] Fix a bug in BWACS_MultiLine (#135906)Owen Pan1-2/+9
Fix #51940
2025-04-12[clang-format][NFC] Add isJava() and isTextProto() in FormatStyle (#135466)Owen Pan1-28/+19
Also remove redundant name qualifiers format::, FormatStyle::, and LanguageKind::.
2025-04-10[clang-format] Recognize TableGen paste operator on separate line (#133722)sstwcw1-2/+9
Formatting this piece of code made the program crash. ``` class TypedVecListRegOperand<RegisterClass Reg, int lanes, string eltsize> : RegisterOperand<Reg, "printTypedVectorList<" # lanes # ", '" # eltsize # "'>">; ``` The line starting with the `#` was treated as a separate preprocessor directive line. Then the code dereferenced a null pointer when it tried to continue parsing the first line that did not end in a semicolon. Now the 2 problems are fixed.
2025-04-09[clang-format][NFC] Add FormatToken::is(tok::ObjCKeywordKind) (#134973)Owen Pan1-28/+15
This allows simplification of code that checks if a token is an Objective-C keyword. Also, delete the following in UnwrappedLineParser::parseStructuralElement(): - an else-after-break in the tok::at case - the copypasted code in the tok::objc_autoreleasepool case
2025-04-05[clang-format] Set C11 instead of C17 for LK_C (#134472)Owen Pan1-3/+1
Fix #134453
2025-04-02[clang-format] Fix a bug in annotating braces (#134039)Owen Pan1-1/+5
Fix #133873
2025-03-25[clang-format] Correctly annotate requires clause in `&& requires(` (#132882)Owen Pan1-3/+5
Fix #132334
2025-03-10[clang-format] Don't remove parentheses separated from ellipsis by comma ↵Owen Pan1-35/+51
(#130471) Also clean up `case tok::r_paren` in `UnwrappedLineParser::parseParens()`. Fix #130359
2025-03-06[clang-format] Remove special handling of C++ access specifiers in C (#129983)Owen Pan1-62/+2
This effectively reverts d1aed486efc6d35a81ca4acbabb4203c4b91cda9 because of #129426.
2025-03-05[clang-format][NFC] Use better names for a couple of data membersOwen Pan1-7/+7
2025-03-03[clang-format] Fix a bug in wrapping function return type (#129374)Owen Pan1-2/+4
Fixes #113766
2025-02-26[clang-format] Fix a bug that changes keyword `or` to an identifier (#128410)Owen Pan1-6/+0
Fixes #105482
2025-02-23[clang-format] Add the C language instead of treating it like C++ (#128287)Owen Pan1-1/+1
Closes #128120
2025-02-16[clang-format] Fix a bug in annotating braces (#127306)Owen Pan1-1/+1
Fixes #107616.
2025-02-01[clang-format] Fix a bug in annotating ClassHeadName (#125326)Owen Pan1-1/+1
2025-01-30[clang-format] Add ClassHeadName to help annotating StartOfName (#124891)Owen Pan1-5/+10
Fixes #124574.
2025-01-30[clang-format] Fix a crash on parsing requires clause (#125021)Owen Pan1-1/+1
Fixes #124921.
2025-01-27[clang-format] Treat uppercase identifiers after struct as macros (#124397)Owen Pan1-1/+2
This restores the behavior before llvmorg-20-init. Fixes #94184. Fixes #117477. Fixes #122690. Fixes #123142.
2025-01-21[clang-format] Rename ExportBlockIndentation -> IndentExportBlock (#123493)Sirraide1-2/+1
This renames the `ExportBlockIndentation` option and adds a config parse test, as requested in #110381.
2025-01-19[clang-format] Improve brace wrapping and add an option to control ↵Sirraide1-19/+30
indentation of `export { ... }` (#110381) `export { ... }` blocks can get a bit long, so I thought it would make sense to have an option that makes it so their contents are not indented (basically the same argument as for namespaces). This is based on the `NamespaceIndentation` option, except that there is no option to control the behaviour of `export` blocks when nested because nesting them doesn’t really make sense. Additionally, brace wrapping of short `export { ... }` blocks is now controlled by the `AllowShortBlocksOnASingleLine` option. There is no separate option just for `export` blocks because you can just write e.g. `export int x;` instead of `export { int x; }`. This closes #121723.
2025-01-17[clang-format] Correctly annotate braces in macro definitions (#123279)Owen Pan1-3/+3
Fixes #123179.
2025-01-04[clang-format] Add `TT_CompoundRequirementLBrace` for better annotation ↵Owen Pan1-2/+3
(#121539) Also, add `ST_CompoundRequirement` to help annotating */&/&& in compound requirement expressions as `TT_BinaryOperator`. Fixes #121471.
2025-01-04[clang-format] Don't break short macro call followed by l_paren (#121626)Owen Pan1-1/+3
Fixes #105658.
2025-01-04[clang-format] Add TT_AfterPPDirective for better annotation (#121622)Owen Pan1-2/+7
For now, we only need to annotate the token after #error or #warning. Fixes #117706.
2025-01-04[clang-format][NFC] Replace SmallVectorImpl with ArrayRef (#121621)Owen Pan1-6/+3
2024-12-18[clang-format] Fix a bug in annotating arrows after init braces (#119958)Owen Pan1-2/+3
Fixes #59066.
2024-12-10[clang-format] Fix idempotent format of hash in macro body (#118513)Owen Pan1-1/+1
Fixes #118334.
2024-11-20[clang-format] Stop crashing on slightly off Verilog module headers (#116000)sstwcw1-1/+2
This piece of code made the program crash. ```Verilog function pkg::t get (int t = 2, int f = 2); ``` The way the code is supposed to be parsed is that UnwrappedLineParser should identify the function header, and then TokenAnnotator should recognize the result. But the code in UnwrappedLineParser would mistakenly not recognize it due to the `::`. Then TokenAnnotator would recognize the comma both as TT_VerilogInstancePortComma and TT_VerilogTypeComma. The code for annotating the instance port comma used `setFinalizedType`. The program would crash when it tried to set it to another type. The code in UnwrappedLineParser now recognizes the `::` token. The are other cases in which TokenAnnotator would recognize the comma as both of those types, for example if the `function` keyword is removed. The type is now set using `setType` instead so that the program does not crash. The developer no longer knows why he used `setFinalizedType` back then.
2024-11-01[clang-format] Fix a regression in parsing `switch` in macro call (#114506)Owen Pan1-2/+6
Fixes #114408.
2024-10-22[clang-format] Handle C# `goto case` constructs (#113257)Owen Pan1-0/+5
Fixes #113256.
2024-10-22[clang-format] Make bitwise and imply requires clause (#110942)Emilia Kond1-1/+1
This patch adjusts the requires clause/expression parser to imply a requires clause if it is preceded by a bitwise and operator `&`, and assume it is a reference qualifier. The justification is that bitwise operations should not be used for requires expressions. This is a band-aid fix. The real problems lie in the lookahead heuristic in the same method. It may be worth it to rewrite that whole heuristic to track more state in the future, instead of just blindly marching forward across multiple unrelated definitions, since right now, the definition following the one with the requires clause can influence whether the heuristic chooses clause or expression. Fixes https://github.com/llvm/llvm-project/issues/110485
2024-10-21[clang-format] Fix a crash on C# `goto case` (#113056)Owen Pan1-1/+1
Fixes #113011.
2024-10-17[clang-format] Handle template opener/closer in braced list (#112494)Owen Pan1-0/+5
Fixes #112487.
2024-10-11[clang-format] Introduce "ReflowComments: IndentOnly" to re-indent comments ↵Iuri Chaer1-5/+5
without breaking internal structure (think Doxygen). (#96804) * Convert `ReflowComments` from boolean into a new `enum` which can take on the value `RCS_Never`, `RCS_IndentOnly`, or `RCS_Always`. The first one is equivalent to the old `false`, the third one is `true`, and the middle one means that multiline comments should only have their indentation corrected, which is what Doxygen users will want. * Preserve backward compatibility while parsing `ReflowComments`.
2024-10-04[clang-format] Handle template closer followed by braces (#110971)Owen Pan1-0/+5
Fixes #110968.
2024-10-02[clang-format] Handle template closer followed by empty paretheses (#110408)Owen Pan1-4/+8
Fixes #109925.