https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/124397
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -11077,6 +11077,221 @@ TEST_F(FormatTest,
WrapsTemplateDeclarationsWithComments) {
Style);
}
+TEST_F(FormatTest, BreakBeforeTemplateClose) {
HazardyKnusperkeks wrote:
This one is still missing.
https://github.com/llvm/llvm-project/pull/118046
_
@@ -38,6 +40,10 @@ static bool mustBreakAfterAttributes(const FormatToken &Tok,
namespace {
+// TODO: Add new Type modifiers
HazardyKnusperkeks wrote:
```suggestion
// TODO: Add new Type modifiers.
```
https://github.com/llvm/llvm-project/pull/120904
__
@@ -2831,8 +2842,21 @@ class AnnotatingParser {
IsQualifiedPointerOrReference(BeforeRParen, LangOpts);
bool ParensCouldEndDecl =
AfterRParen->isOneOf(tok::equal, tok::semi, tok::l_brace,
tok::greater);
-if (ParensAreType && !ParensCouldEndDecl)
+if
@@ -11077,6 +11077,281 @@ TEST_F(FormatTest,
WrapsTemplateDeclarationsWithComments) {
Style);
}
+TEST_F(FormatTest, BreakBeforeTemplateClose) {
+ FormatStyle Style = getGoogleStyle(FormatStyle::LK_Cpp);
+ Style.ColumnLimit = 0;
+ verifyNoChange("template \n"
+
@@ -11077,6 +11077,221 @@ TEST_F(FormatTest,
WrapsTemplateDeclarationsWithComments) {
Style);
}
+TEST_F(FormatTest, BreakBeforeTemplateClose) {
HazardyKnusperkeks wrote:
Sorry missed that, didn't look for the lambda case.
https://github.com/llvm/llvm-
HazardyKnusperkeks wrote:
> > > I struggle with changes that encourage people to not be fully
> > > clang-formatted, I would prefer to ask why we need this feature, can we
> > > have some examples of where this would be used?
> >
> >
> > This makes it so only one line isn't formatted instead
https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/127306
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
HazardyKnusperkeks wrote:
Was there a change which I should look at again? I find the GitHub UI for
reviews terrible. If it was just a rebase my vote stands.
https://github.com/llvm/llvm-project/pull/108332
___
cfe-commits mailing list
cfe-commits@lis
@@ -1596,7 +1596,7 @@ static auto computeNewlines(const AnnotatedLine &Line,
if (Line.startsWith(TT_NamespaceRBrace)) {
if (Style.WrapNamespaceBodyWithEmptyLines == FormatStyle::WNBWELS_Never)
Newlines = 1;
- else if (!PreviousLine->startsWith(TT_Namespac
https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/127159
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -3353,7 +3353,12 @@ struct FormatStyle {
}
bool isTableGen() const { return Language == LK_TableGen; }
- /// Language, this format style is targeted at.
+ /// The language that this format style targets.
+ /// \note
+ /// You can also specify the language (``Cpp``
https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/127964
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/128287
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/128623
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/128410
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/128817
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/127545
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/129983
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -5091,8 +5091,10 @@ UnwrappedLineParser::parseMacroCall() {
void UnwrappedLineParser::pushToken(FormatToken *Tok) {
Line->Tokens.push_back(UnwrappedLineNode(Tok));
if (MustBreakBeforeNextToken) {
HazardyKnusperkeks wrote:
Good.
https://github.com/llvm/
https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/128988
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -1441,8 +1441,9 @@ TEST(ConfigParseTest, GetStyleOfFile) {
ASSERT_EQ(*Style9, SubSubStyle);
// Test 9.8: use inheritance from a file without BasedOnStyle
- ASSERT_TRUE(FS.addFile("/e/withoutbase/.clang-format", 0,
- llvm::MemoryBuffer::getMemBuf
https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/130471
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -3856,6 +3856,59 @@ TEST_F(TokenAnnotatorTest, AfterPPDirective) {
EXPECT_TOKEN(Tokens[2], tok::minusminus, TT_AfterPPDirective);
}
+TEST_F(TokenAnnotatorTest, UserDefinedConversionFunction) {
+ auto Tokens = annotate("operator int();");
+ ASSERT_EQ(Tokens.size(), 6u) <
HazardyKnusperkeks wrote:
I still think Google should have to say what their style in clang-format is,
extending to the default values of `AttributeMacros`.
I also wouldn't have such a big issue with adding it to the base style, because
of the prefix and I think it's nice that Boost or Qt most
@@ -2031,6 +2031,7 @@ class SourceManagerForFile {
// The order of these fields are important - they should be in the same order
// as they are created in `createSourceManagerForFile` so that they can be
// deleted in the reverse order as they are created.
+ std::string
@@ -29096,6 +29096,17 @@ TEST_F(FormatTest, BreakBeforeClassName) {
"ArenaSafeUniquePtr {};");
}
+TEST_F(FormatTest, DoesNotCrashOnNonNullTerminatedStringRefs) {
+ llvm::StringRef TwoLines = "namespace foo {}\n"
+ "namespace bar
@@ -2382,14 +2382,20 @@ size_t SourceManager::getDataStructureSizes() const {
SourceManagerForFile::SourceManagerForFile(StringRef FileName,
StringRef Content) {
+ // We copy to `std::string` for Context instead of StringRef because
@@ -1639,6 +1639,25 @@ class AnnotatingParser {
case tok::kw_operator:
if (Style.isProto())
break;
+ // C++ user-defined conversion function.
+ if (IsCpp && CurrentToken &&
+ (CurrentToken->is(tok::kw_auto) ||
+ CurrentToken->isTyp
@@ -2382,14 +2382,20 @@ size_t SourceManager::getDataStructureSizes() const {
SourceManagerForFile::SourceManagerForFile(StringRef FileName,
StringRef Content) {
+ // We copy to `std::string` for Context instead of StringRef because
@@ -148,6 +160,24 @@ class AnnotatingParser {
}
}
+ const FormatStyle::FunctionDeclarationWithKeywords *
+ isInsideFunctionWithKeywordedParameters(const FormatToken &Token) const {
+const FormatToken *Previous = &Token;
+while (auto Prev = Previous->getPrevious
@@ -148,6 +160,24 @@ class AnnotatingParser {
}
}
+ const FormatStyle::FunctionDeclarationWithKeywords *
+ isInsideFunctionWithKeywordedParameters(const FormatToken &Token) const {
HazardyKnusperkeks wrote:
The name is misleading, I'd expect a `bool`e
@@ -148,6 +160,24 @@ class AnnotatingParser {
}
}
+ const FormatStyle::FunctionDeclarationWithKeywords *
+ isInsideFunctionWithKeywordedParameters(const FormatToken &Token) const {
+const FormatToken *Previous = &Token;
+while (auto Prev = Previous->getPrevious
@@ -5435,7 +5470,10 @@ struct FormatStyle {
VerilogBreakBetweenInstancePorts ==
R.VerilogBreakBetweenInstancePorts &&
WhitespaceSensitiveMacros == R.WhitespaceSensitiveMacros &&
- WrapNamespaceBodyWithEmptyLines ==
R.WrapNamespace
@@ -116,6 +116,18 @@ static bool isCppAttribute(bool IsCpp, const FormatToken
&Tok) {
return AttrTok && AttrTok->startsSequence(tok::r_square, tok::r_square);
}
+static bool isParametersKeyword(
+const FormatToken &Tok,
+const FormatStyle::FunctionDeclarationWithKey
@@ -349,6 +349,10 @@ bool ContinuationIndenter::canBreak(const LineState
&State) {
}
}
+ // Don't break between function parameter keywords and parameter names
HazardyKnusperkeks wrote:
```suggestion
// Don't break between function parameter keyword
@@ -148,6 +160,24 @@ class AnnotatingParser {
}
}
+ const FormatStyle::FunctionDeclarationWithKeywords *
+ isInsideFunctionWithKeywordedParameters(const FormatToken &Token) const {
+const FormatToken *Previous = &Token;
+while (auto Prev = Previous->getPrevious
@@ -5247,6 +5247,41 @@ struct FormatStyle {
/// \version 20
WrapNamespaceBodyWithEmptyLinesStyle WrapNamespaceBodyWithEmptyLines;
+ struct FunctionDeclarationWithKeywords {
+std::string Name;
+std::vector Keywords;
+
+bool operator==(const FunctionDeclarationW
@@ -82,6 +82,7 @@ namespace format {
TYPE(FunctionAnnotationRParen)
\
TYPE(FunctionDeclarationName)
\
TYPE(FunctionDeclarationLParen)
@@ -1192,6 +1201,8 @@ template <> struct MappingTraits {
Style.WhitespaceSensitiveMacros);
IO.mapOptional("WrapNamespaceBodyWithEmptyLines",
Style.WrapNamespaceBodyWithEmptyLines);
+IO.mapOptional("FunctionDeclarationsWithKeywords",
https://github.com/HazardyKnusperkeks edited
https://github.com/llvm/llvm-project/pull/131605
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -148,6 +160,24 @@ class AnnotatingParser {
}
}
+ const FormatStyle::FunctionDeclarationWithKeywords *
+ isInsideFunctionWithKeywordedParameters(const FormatToken &Token) const {
+const FormatToken *Previous = &Token;
+while (auto Prev = Previous->getPrevious
https://github.com/HazardyKnusperkeks requested changes to this pull request.
You need to add a parsing test for your option and annotation tests for the
annotation.
https://github.com/llvm/llvm-project/pull/131605
___
cfe-commits mailing list
cfe-com
@@ -29096,6 +29096,63 @@ TEST_F(FormatTest, BreakBeforeClassName) {
"ArenaSafeUniquePtr {};");
}
+TEST_F(FormatTest, FunctionDeclarationWithKeywords) {
+ FormatStyle::FunctionDeclarationWithKeywords QPropertyDeclaration;
+ QPropertyDeclaration.Name = "Q_PR
@@ -148,6 +160,24 @@ class AnnotatingParser {
}
}
+ const FormatStyle::FunctionDeclarationWithKeywords *
+ isInsideFunctionWithKeywordedParameters(const FormatToken &Token) const {
+const FormatToken *Previous = &Token;
+while (auto Prev = Previous->getPrevious
https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/131434
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -2382,14 +2382,20 @@ size_t SourceManager::getDataStructureSizes() const {
SourceManagerForFile::SourceManagerForFile(StringRef FileName,
StringRef Content) {
+ // We copy to `std::string` for Context instead of StringRef because
https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/132042
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -1,3 +1,4 @@
Strings
+FunctionDeclarationWithKeywordes
HazardyKnusperkeks wrote:
I think you only need to fix this one?
https://github.com/llvm/llvm-project/pull/131605
___
cfe-commits mailing list
cfe-commits@list
@@ -1,3 +1,4 @@
Strings
+FunctionDeclarationWithKeywordes
HazardyKnusperkeks wrote:
Then I'd say we change that. I mean this is the fourth entry to the file and
apparently it does not match.
https://github.com/llvm/llvm-project/pull/131605
@@ -15120,6 +15120,85 @@ TEST_F(FormatTest,
PullInlineFunctionDefinitionsIntoSingleLine) {
MergeInlineOnly);
}
+TEST_F(FormatTest, PullStaticInlineFunctionDefinitionsIntoSingleLine) {
+ FormatStyle MergeStaticInlineOnly = getLLVMStyle();
+ MergeStaticInlineOn
https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/133576
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/133673
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
HazardyKnusperkeks wrote:
> > IMO, a boolean option, e.g. `AllowBreakBeforeQPropertyKeyword` should
> > suffice.
>
> I don't like to hardcode neither the macro name nor the keywords, which
> depend on Qt version. Implementation would not differ save for the source we
> fetch keywords from.
I
@@ -3926,6 +3926,39 @@ TEST_F(TokenAnnotatorTest,
UserDefinedConversionFunction) {
EXPECT_TOKEN(Tokens[5], tok::l_paren, TT_FunctionDeclarationLParen);
}
+TEST_F(TokenAnnotatorTest, KeywordedFunctionLikeMacro) {
+ auto Style = getLLVMStyle();
+ FormatStyle::KeywordedFunct
@@ -498,6 +498,8 @@ clang-format
top of the file.
- Add ``EnumTrailingComma`` option for inserting/removing commas at the end of
``enum`` enumerator lists.
+- Allow to apply parameters bin-packing options to function-like macros that
+ use keywords to delimit parameters (e
@@ -2031,6 +2031,7 @@ class SourceManagerForFile {
// The order of these fields are important - they should be in the same order
// as they are created in `createSourceManagerForFile` so that they can be
// deleted in the reverse order as they are created.
+ std::string
HazardyKnusperkeks wrote:
> FAIL: Clang :: Format/docs_updated.test (12079 of 22139)
You forgot to redo the documentation.
https://github.com/llvm/llvm-project/pull/131605
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/
https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/131605
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -335,6 +336,32 @@ class LineJoiner {
}
}
+ if (Style.AllowShortFunctionsOnASingleLine ==
+ FormatStyle::SFS_StaticInlineOnly ||
+ Style.AllowShortFunctionsOnASingleLine ==
+ FormatStyle::SFS_StaticInline) {
+// C
@@ -15120,6 +15120,85 @@ TEST_F(FormatTest,
PullInlineFunctionDefinitionsIntoSingleLine) {
MergeInlineOnly);
}
+TEST_F(FormatTest, PullStaticInlineFunctionDefinitionsIntoSingleLine) {
+ FormatStyle MergeStaticInlineOnly = getLLVMStyle();
+ MergeStaticInlineOn
@@ -863,6 +870,12 @@ struct FormatStyle {
/// void f() {}
/// \endcode
SFS_Inline,
+/// Only merge functions defined as static inline. Implies ``empty``.
HazardyKnusperkeks wrote:
This should have a different text.
https://github.com/llvm/ll
@@ -335,6 +336,32 @@ class LineJoiner {
}
}
+ if (Style.AllowShortFunctionsOnASingleLine ==
+ FormatStyle::SFS_StaticInlineOnly ||
+ Style.AllowShortFunctionsOnASingleLine ==
+ FormatStyle::SFS_StaticInline) {
+// C
@@ -335,6 +336,32 @@ class LineJoiner {
}
}
+ if (Style.AllowShortFunctionsOnASingleLine ==
+ FormatStyle::SFS_StaticInlineOnly ||
+ Style.AllowShortFunctionsOnASingleLine ==
+ FormatStyle::SFS_StaticInline) {
+// C
@@ -1067,6 +1076,8 @@ template <> struct MappingTraits {
IO.mapOptional("InsertNewlineAtEOF", Style.InsertNewlineAtEOF);
IO.mapOptional("InsertTrailingCommas", Style.InsertTrailingCommas);
IO.mapOptional("IntegerLiteralSeparator", Style.IntegerLiteralSeparator);
+
https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/132941
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -720,8 +720,9 @@ TEST_F(TokenAnnotatorTest,
UnderstandsNonTemplateAngleBrackets) {
Tokens = annotate("return A < B != A > B;");
ASSERT_EQ(Tokens.size(), 10u) << Tokens;
- EXPECT_TOKEN(Tokens[2], tok::less, TT_BinaryOperator);
- EXPECT_TOKEN(Tokens[6], tok::greater, T
https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/133033
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
HazardyKnusperkeks wrote:
Please recheck all your added comments, if the wording is still the best one,
after renaming the option.
https://github.com/llvm/llvm-project/pull/131605
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.l
@@ -3146,6 +3146,45 @@ struct FormatStyle {
/// \version 16
IntegerLiteralSeparatorStyle IntegerLiteralSeparator;
+ /// Function-like declaration with keyworded parameters.
+ /// Lists possible keywords for a named macro-like function
+ struct KeywordedFunctionLikeMacro
@@ -29102,6 +29102,65 @@ TEST_F(FormatTest, BreakBeforeClassName) {
"ArenaSafeUniquePtr {};");
}
+TEST_F(FormatTest, FunctionDeclarationWithKeywords) {
HazardyKnusperkeks wrote:
The test name should be changed, I'd refer directly to the opt
@@ -3146,6 +3146,45 @@ struct FormatStyle {
/// \version 16
IntegerLiteralSeparatorStyle IntegerLiteralSeparator;
+ /// Function-like declaration with keyworded parameters.
+ /// Lists possible keywords for a named macro-like function
HazardyKnusperkeks
https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/133033
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -3276,6 +3276,45 @@ struct FormatStyle {
/// \version 20
bool KeepFormFeed;
+ /// Function-like declaration with keyworded parameters.
+ /// Lists possible keywords for a named function-like macro.
+ struct KeywordedFunctionLikeMacro {
+std::string Name;
+std
@@ -5347,6 +5386,7 @@ struct FormatStyle {
InsertBraces == R.InsertBraces &&
InsertNewlineAtEOF == R.InsertNewlineAtEOF &&
IntegerLiteralSeparator == R.IntegerLiteralSeparator &&
+ KeywordedFunctionLikeMacros == R.KeywordedFunctionLike
https://github.com/HazardyKnusperkeks commented:
Nearly done. ;)
https://github.com/llvm/llvm-project/pull/131605
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/HazardyKnusperkeks edited
https://github.com/llvm/llvm-project/pull/131605
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -335,6 +336,32 @@ class LineJoiner {
}
}
+ if (Style.AllowShortFunctionsOnASingleLine ==
+ FormatStyle::SFS_StaticInlineOnly ||
+ Style.AllowShortFunctionsOnASingleLine ==
+ FormatStyle::SFS_StaticInline) {
+// C
https://github.com/HazardyKnusperkeks approved this pull request.
Should this get the same warning as the other non white space changes?
https://github.com/llvm/llvm-project/pull/133576
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://li
@@ -2214,6 +2214,21 @@ FormatStyle::GetLanguageStyle(FormatStyle::LanguageKind
Language) const {
namespace {
+void replaceToken(const FormatToken &Token, FormatToken *Next,
+ const SourceManager &SourceMgr, tooling::Replacements
&Result,
+
@@ -2214,6 +2214,21 @@ FormatStyle::GetLanguageStyle(FormatStyle::LanguageKind
Language) const {
namespace {
+void replaceToken(const FormatToken &Token, FormatToken *Next,
+ const SourceManager &SourceMgr, tooling::Replacements
&Result,
+
https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/133722
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request.
But why does this fix it?
https://github.com/llvm/llvm-project/pull/134472
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-com
https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/134473
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
801 - 884 of 884 matches
Mail list logo