[clang] [clang] Improve diagnostics with incompatible VLA types (PR #101261)
https://github.com/sookach updated https://github.com/llvm/llvm-project/pull/101261 >From 1b598a5f3b158ec231b96281e4e0edc6fa819389 Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Tue, 30 Jul 2024 19:31:41 -0400 Subject: [PATCH] [clang] Improve diagnostics with incompatible VLA types --- clang/lib/AST/ASTDiagnostic.cpp | 21 +++ .../test/Sema/incompatible-vla-assignment.cpp | 13 2 files changed, 34 insertions(+) create mode 100644 clang/test/Sema/incompatible-vla-assignment.cpp diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp index 0680ff5e3a3851..367378a0d3df25 100644 --- a/clang/lib/AST/ASTDiagnostic.cpp +++ b/clang/lib/AST/ASTDiagnostic.cpp @@ -424,6 +424,27 @@ void clang::FormatASTNodeDiagnosticArgument( Val = TDT.PrintFromType ? TDT.FromType : TDT.ToType; Modifier = StringRef(); Argument = StringRef(); + + if (FromType->isVariablyModifiedType() && + ToType->isVariablyModifiedType() && + ConvertTypeToDiagnosticString(Context, FromType, PrevArgs, +QualTypeVals) == + ConvertTypeToDiagnosticString(Context, ToType, PrevArgs, +QualTypeVals)) { +assert(Modifier.empty() && Argument.empty() && + "Invalid modifier for QualType argument"); + +QualType Ty(QualType::getFromOpaquePtr(reinterpret_cast(Val))); +OS << ConvertTypeToDiagnosticString(Context, Ty, PrevArgs, +QualTypeVals); +NeedQuotes = false; + +if (!TDT.PrintFromType) + OS << "; VLA types differ despite using the same array size " +"expression"; + +break; + } // Fall through [[fallthrough]]; } diff --git a/clang/test/Sema/incompatible-vla-assignment.cpp b/clang/test/Sema/incompatible-vla-assignment.cpp new file mode 100644 index 00..af97ec554d02c8 --- /dev/null +++ b/clang/test/Sema/incompatible-vla-assignment.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +void func(int n) { +int grp[n][n]; +int (*ptr)[n]; + +for (int i = 0; i < n; i++) +ptr = &grp[i]; // expected-error {{incompatible pointer types assigning to 'int (*)[n]' from 'int (*)[n]'; VLA types differ despite using the same array size expression}} +} + +void func(int n, int (&array)[n]) { + int (&other)[n] = array; // expected-error {{non-const lvalue reference to type 'int[n]' cannot bind to a value of unrelated type 'int[n]'; VLA types differ despite using the same array size expression}} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Improve diagnostics with incompatible VLA types (PR #101261)
https://github.com/sookach updated https://github.com/llvm/llvm-project/pull/101261 >From 54e4912ebcee4a54b05367f52a0e83b36a792c81 Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Tue, 30 Jul 2024 19:31:41 -0400 Subject: [PATCH] [clang] Improve diagnostics with incompatible VLA types --- clang/lib/AST/ASTDiagnostic.cpp | 20 +++ .../test/Sema/incompatible-vla-assignment.cpp | 13 2 files changed, 33 insertions(+) create mode 100644 clang/test/Sema/incompatible-vla-assignment.cpp diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp index 0680ff5e3a3851..9fcae664960054 100644 --- a/clang/lib/AST/ASTDiagnostic.cpp +++ b/clang/lib/AST/ASTDiagnostic.cpp @@ -424,6 +424,26 @@ void clang::FormatASTNodeDiagnosticArgument( Val = TDT.PrintFromType ? TDT.FromType : TDT.ToType; Modifier = StringRef(); Argument = StringRef(); + + if (FromType->isVariableArrayType() && ToType->isVariableArrayType() && + ConvertTypeToDiagnosticString(Context, FromType, PrevArgs, +QualTypeVals) == + ConvertTypeToDiagnosticString(Context, ToType, PrevArgs, +QualTypeVals)) { +assert(Modifier.empty() && Argument.empty() && + "Invalid modifier for QualType argument"); + +QualType Ty(QualType::getFromOpaquePtr(reinterpret_cast(Val))); +OS << ConvertTypeToDiagnosticString(Context, Ty, PrevArgs, +QualTypeVals); +NeedQuotes = false; + +if (!TDT.PrintFromType) + OS << "; VLA types differ despite using the same array size " +"expression"; + +break; + } // Fall through [[fallthrough]]; } diff --git a/clang/test/Sema/incompatible-vla-assignment.cpp b/clang/test/Sema/incompatible-vla-assignment.cpp new file mode 100644 index 00..af97ec554d02c8 --- /dev/null +++ b/clang/test/Sema/incompatible-vla-assignment.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +void func(int n) { +int grp[n][n]; +int (*ptr)[n]; + +for (int i = 0; i < n; i++) +ptr = &grp[i]; // expected-error {{incompatible pointer types assigning to 'int (*)[n]' from 'int (*)[n]'; VLA types differ despite using the same array size expression}} +} + +void func(int n, int (&array)[n]) { + int (&other)[n] = array; // expected-error {{non-const lvalue reference to type 'int[n]' cannot bind to a value of unrelated type 'int[n]'; VLA types differ despite using the same array size expression}} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Improve diagnostics with incompatible VLA types (PR #101261)
https://github.com/sookach updated https://github.com/llvm/llvm-project/pull/101261 >From 7c6109ea5133941baf32ec57e48c770ad015b883 Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Tue, 30 Jul 2024 19:31:41 -0400 Subject: [PATCH] [clang] Improve diagnostics with incompatible VLA types --- clang/lib/AST/ASTDiagnostic.cpp | 22 +++ .../test/Sema/incompatible-vla-assignment.cpp | 9 2 files changed, 31 insertions(+) create mode 100644 clang/test/Sema/incompatible-vla-assignment.cpp diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp index 0680ff5e3a3851..0f5e8ae600f235 100644 --- a/clang/lib/AST/ASTDiagnostic.cpp +++ b/clang/lib/AST/ASTDiagnostic.cpp @@ -422,8 +422,30 @@ void clang::FormatASTNodeDiagnosticArgument( // Attempting to do a template diff on non-templates. Set the variables // and continue with regular type printing of the appropriate type. Val = TDT.PrintFromType ? TDT.FromType : TDT.ToType; + Modifier = StringRef(); Argument = StringRef(); + + if ((FromType->isVariableArrayType() || FromType->isPointerType()) && + (ToType->isVariableArrayType() || ToType->isPointerType()) && + ConvertTypeToDiagnosticString(Context, FromType, PrevArgs, +QualTypeVals) == + ConvertTypeToDiagnosticString(Context, ToType, PrevArgs, +QualTypeVals)) { +assert(Modifier.empty() && Argument.empty() && + "Invalid modifier for QualType argument"); + +QualType Ty(QualType::getFromOpaquePtr(reinterpret_cast(Val))); +OS << ConvertTypeToDiagnosticString(Context, Ty, PrevArgs, +QualTypeVals); +NeedQuotes = false; + +if (!TDT.PrintFromType) + OS << "; VLA types differ despite using the same array size " +"expression"; + +break; + } // Fall through [[fallthrough]]; } diff --git a/clang/test/Sema/incompatible-vla-assignment.cpp b/clang/test/Sema/incompatible-vla-assignment.cpp new file mode 100644 index 00..9df97a1223150a --- /dev/null +++ b/clang/test/Sema/incompatible-vla-assignment.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +void func(int n) { +int grp[n][n]; +int (*ptr)[n]; + +for (int i = 0; i < n; i++) +ptr = &grp[i]; // expected-error {{incompatible pointer types assigning to 'int (*)[n]' from 'int (*)[n]'; VLA types differ despite using the same array size expression}} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Improve diagnostics with incompatible VLA types (PR #101261)
https://github.com/sookach updated https://github.com/llvm/llvm-project/pull/101261 >From 1de106f82720ea6c470ce6c974c19f966599b9cc Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Tue, 30 Jul 2024 19:31:41 -0400 Subject: [PATCH] [clang] Improve diagnostics with incompatible VLA types --- clang/lib/Basic/Diagnostic.cpp| 45 --- .../test/Sema/incompatible-vla-assignment.cpp | 9 2 files changed, 38 insertions(+), 16 deletions(-) create mode 100644 clang/test/Sema/incompatible-vla-assignment.cpp diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp index 66776daa5e1493..9e1d2f996147a9 100644 --- a/clang/lib/Basic/Diagnostic.cpp +++ b/clang/lib/Basic/Diagnostic.cpp @@ -1099,37 +1099,50 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, const char *FirstDollar = ScanFormat(Argument, ArgumentEnd, '$'); const char *SecondDollar = ScanFormat(FirstDollar + 1, ArgumentEnd, '$'); - // Append before text - FormatDiagnostic(Argument, FirstDollar, OutStr); - - // Append first type + // Get first type text TDT.PrintTree = false; TDT.PrintFromType = true; + SmallString<64> FromTypeStr, ToTypeStr; getDiags()->ConvertArgToString(Kind, val, StringRef(Modifier, ModifierLen), StringRef(Argument, ArgumentLen), - FormattedArgs, - OutStr, QualTypeVals); + FormattedArgs, FromTypeStr, QualTypeVals); if (!TDT.TemplateDiffUsed) -FormattedArgs.push_back(std::make_pair(DiagnosticsEngine::ak_qualtype, - TDT.FromType)); +FormattedArgs.push_back( +std::make_pair(DiagnosticsEngine::ak_qualtype, TDT.FromType)); - // Append middle text - FormatDiagnostic(FirstDollar + 1, SecondDollar, OutStr); - - // Append second type + // Get second type text TDT.PrintFromType = false; getDiags()->ConvertArgToString(Kind, val, StringRef(Modifier, ModifierLen), StringRef(Argument, ArgumentLen), - FormattedArgs, - OutStr, QualTypeVals); + FormattedArgs, ToTypeStr, QualTypeVals); if (!TDT.TemplateDiffUsed) -FormattedArgs.push_back(std::make_pair(DiagnosticsEngine::ak_qualtype, - TDT.ToType)); +FormattedArgs.push_back( +std::make_pair(DiagnosticsEngine::ak_qualtype, TDT.ToType)); + + // Append before text + FormatDiagnostic(Argument, FirstDollar, OutStr); + + // Append first type + OutStr.append(FromTypeStr); + + // Append middle text + FormatDiagnostic(FirstDollar + 1, SecondDollar, OutStr); + + // Append second type + OutStr.append(ToTypeStr); // Append end text FormatDiagnostic(SecondDollar + 1, Pipe, OutStr); + + if (FromTypeStr == ToTypeStr) { +SmallString<88> IncompatibleVLADiag( +"; consider using a typedef to use the same variable-length array " +"type for both operands"); +OutStr.append(IncompatibleVLADiag); + } + break; } } diff --git a/clang/test/Sema/incompatible-vla-assignment.cpp b/clang/test/Sema/incompatible-vla-assignment.cpp new file mode 100644 index 00..8be063631b7a8a --- /dev/null +++ b/clang/test/Sema/incompatible-vla-assignment.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +void func(int n) { +int grp[n][n]; +int (*ptr)[n]; + +for (int i = 0; i < n; i++) +ptr = &grp[i]; // expected-error {{incompatible pointer types assigning to 'int (*)[n]' from 'int (*)[n]'; consider using a typedef to use the same variable-length array type for both operands}} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Improve diagnostics with incompatible VLA types (PR #101261)
@@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +void func(int n) { +int grp[n][n]; +int (*ptr)[n]; + +for (int i = 0; i < n; i++) +ptr = &grp[i]; // expected-error {{incompatible assignment of pointers of variable-length array type 'int (*)[n]'; consider using a typedef to use the same variable-length array type for both operands}} +} sookach wrote: Just out of curiosity, what does the new line do? or is it just a formatting thing? https://github.com/llvm/llvm-project/pull/101261 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Improve diagnostics with incompatible VLA types (PR #101261)
sookach wrote: Sorry for taking so long, but the new commit handles the diagnostic a little differently. I store the text types in temporary strings and then append a message to the diagnostic if the texts are identical. https://github.com/llvm/llvm-project/pull/101261 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Improve diagnostics with incompatible VLA types (PR #101261)
https://github.com/sookach updated https://github.com/llvm/llvm-project/pull/101261 >From 6f1868ec7aebf24cfd61472a1a33f6bd65ebeeb5 Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Tue, 30 Jul 2024 19:31:41 -0400 Subject: [PATCH] [clang] Improve diagnostics with incompatible VLA types --- clang/lib/Basic/Diagnostic.cpp| 45 --- .../test/Sema/incompatible-vla-assignment.cpp | 9 2 files changed, 38 insertions(+), 16 deletions(-) create mode 100644 clang/test/Sema/incompatible-vla-assignment.cpp diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp index 66776daa5e1493..cba350b4727547 100644 --- a/clang/lib/Basic/Diagnostic.cpp +++ b/clang/lib/Basic/Diagnostic.cpp @@ -1099,37 +1099,50 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, const char *FirstDollar = ScanFormat(Argument, ArgumentEnd, '$'); const char *SecondDollar = ScanFormat(FirstDollar + 1, ArgumentEnd, '$'); - // Append before text - FormatDiagnostic(Argument, FirstDollar, OutStr); - - // Append first type + // Get first type text TDT.PrintTree = false; TDT.PrintFromType = true; + SmallString<64> FromTypeStr, ToTypeStr; getDiags()->ConvertArgToString(Kind, val, StringRef(Modifier, ModifierLen), StringRef(Argument, ArgumentLen), - FormattedArgs, - OutStr, QualTypeVals); + FormattedArgs, FromTypeStr, QualTypeVals); if (!TDT.TemplateDiffUsed) -FormattedArgs.push_back(std::make_pair(DiagnosticsEngine::ak_qualtype, - TDT.FromType)); +FormattedArgs.push_back( +std::make_pair(DiagnosticsEngine::ak_qualtype, TDT.FromType)); - // Append middle text - FormatDiagnostic(FirstDollar + 1, SecondDollar, OutStr); - - // Append second type + // Get second type text TDT.PrintFromType = false; getDiags()->ConvertArgToString(Kind, val, StringRef(Modifier, ModifierLen), StringRef(Argument, ArgumentLen), - FormattedArgs, - OutStr, QualTypeVals); + FormattedArgs, ToTypeStr, QualTypeVals); if (!TDT.TemplateDiffUsed) -FormattedArgs.push_back(std::make_pair(DiagnosticsEngine::ak_qualtype, - TDT.ToType)); +FormattedArgs.push_back( +std::make_pair(DiagnosticsEngine::ak_qualtype, TDT.ToType)); + + // Append before text + FormatDiagnostic(Argument, FirstDollar, OutStr); + + // Append first type + OutStr.append(FromTypeStr); + + // Append middle text + FormatDiagnostic(FirstDollar + 1, SecondDollar, OutStr); + + // Append second type + OutStr.append(ToTypeStr); // Append end text FormatDiagnostic(SecondDollar + 1, Pipe, OutStr); + + if (FromTypeStr == ToTypeStr) { +SmallString<86> IncompatibleVLADiag( +"; consider using a typedef to use the same variable-length array " +"type for both operands"); +OutStr.append(IncompatibleVLADiag); + } + break; } } diff --git a/clang/test/Sema/incompatible-vla-assignment.cpp b/clang/test/Sema/incompatible-vla-assignment.cpp new file mode 100644 index 00..8be063631b7a8a --- /dev/null +++ b/clang/test/Sema/incompatible-vla-assignment.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +void func(int n) { +int grp[n][n]; +int (*ptr)[n]; + +for (int i = 0; i < n; i++) +ptr = &grp[i]; // expected-error {{incompatible pointer types assigning to 'int (*)[n]' from 'int (*)[n]'; consider using a typedef to use the same variable-length array type for both operands}} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Improve diagnostics with incompatible VLA types (PR #101261)
https://github.com/sookach updated https://github.com/llvm/llvm-project/pull/101261 >From 5df72d9e8e89079b2c5312583e66756c048e5abe Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Tue, 30 Jul 2024 19:31:41 -0400 Subject: [PATCH] [clang] Improve diagnostics with incompatible VLA types --- clang/lib/Basic/Diagnostic.cpp| 35 +-- .../test/Sema/incompatible-vla-assignment.cpp | 9 + 2 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 clang/test/Sema/incompatible-vla-assignment.cpp diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp index 66776daa5e1493..b7029dd6472e7c 100644 --- a/clang/lib/Basic/Diagnostic.cpp +++ b/clang/lib/Basic/Diagnostic.cpp @@ -1099,37 +1099,52 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, const char *FirstDollar = ScanFormat(Argument, ArgumentEnd, '$'); const char *SecondDollar = ScanFormat(FirstDollar + 1, ArgumentEnd, '$'); - // Append before text - FormatDiagnostic(Argument, FirstDollar, OutStr); - - // Append first type + // Get first type text TDT.PrintTree = false; TDT.PrintFromType = true; + SmallString<64> FromTypeStr, ToTypeStr; getDiags()->ConvertArgToString(Kind, val, StringRef(Modifier, ModifierLen), StringRef(Argument, ArgumentLen), FormattedArgs, - OutStr, QualTypeVals); + FromTypeStr, QualTypeVals); if (!TDT.TemplateDiffUsed) FormattedArgs.push_back(std::make_pair(DiagnosticsEngine::ak_qualtype, TDT.FromType)); - // Append middle text - FormatDiagnostic(FirstDollar + 1, SecondDollar, OutStr); - - // Append second type + // Get second type text TDT.PrintFromType = false; getDiags()->ConvertArgToString(Kind, val, StringRef(Modifier, ModifierLen), StringRef(Argument, ArgumentLen), FormattedArgs, - OutStr, QualTypeVals); + ToTypeStr, QualTypeVals); if (!TDT.TemplateDiffUsed) FormattedArgs.push_back(std::make_pair(DiagnosticsEngine::ak_qualtype, TDT.ToType)); + // Append before text + FormatDiagnostic(Argument, FirstDollar, OutStr); + + // Append first type + OutStr.append(FromTypeStr); + + // Append middle text + FormatDiagnostic(FirstDollar + 1, SecondDollar, OutStr); + + // Append second type + OutStr.append(ToTypeStr); + // Append end text FormatDiagnostic(SecondDollar + 1, Pipe, OutStr); + + if (FromTypeStr == ToTypeStr) { +SmallString<86> IncompatibleVLADiag( +"; consider using a typedef to use the same variable-length array " +"type for both operands"); +OutStr.append(IncompatibleVLADiag); + } + break; } } diff --git a/clang/test/Sema/incompatible-vla-assignment.cpp b/clang/test/Sema/incompatible-vla-assignment.cpp new file mode 100644 index 00..8be063631b7a8a --- /dev/null +++ b/clang/test/Sema/incompatible-vla-assignment.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +void func(int n) { +int grp[n][n]; +int (*ptr)[n]; + +for (int i = 0; i < n; i++) +ptr = &grp[i]; // expected-error {{incompatible pointer types assigning to 'int (*)[n]' from 'int (*)[n]'; consider using a typedef to use the same variable-length array type for both operands}} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Improve diagnostics with incompatible VLA types (PR #101261)
https://github.com/sookach updated https://github.com/llvm/llvm-project/pull/101261 >From 2666871e019dee2314933cc60bcb4ca27d7555ba Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Tue, 30 Jul 2024 19:31:41 -0400 Subject: [PATCH] [clang] Improve diagnostics with incompatible VLA types --- .../clang/Basic/DiagnosticSemaKinds.td| 3 ++ clang/lib/Basic/Diagnostic.cpp| 35 +-- .../test/Sema/incompatible-vla-assignment.cpp | 9 + 3 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 clang/test/Sema/incompatible-vla-assignment.cpp diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 9e6d85c469d641..5533ffb4b991c3 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -8643,6 +8643,9 @@ def err_typecheck_convert_incompatible_pointer : Error< "; take the address with &|" "; remove *|" "; remove &}3">; +def err_typecheck_convert_incompatible_vla : Error< + "incompatible assignment of pointers of variable-length array type %0" + "; consider using a typedef to use the same variable-length array type for both operands">; def err_typecheck_convert_incompatible_function_pointer : Error< "incompatible function pointer types " "%select{%diff{assigning to $ from $|assigning to different types}0,1" diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp index 66776daa5e1493..b7029dd6472e7c 100644 --- a/clang/lib/Basic/Diagnostic.cpp +++ b/clang/lib/Basic/Diagnostic.cpp @@ -1099,37 +1099,52 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, const char *FirstDollar = ScanFormat(Argument, ArgumentEnd, '$'); const char *SecondDollar = ScanFormat(FirstDollar + 1, ArgumentEnd, '$'); - // Append before text - FormatDiagnostic(Argument, FirstDollar, OutStr); - - // Append first type + // Get first type text TDT.PrintTree = false; TDT.PrintFromType = true; + SmallString<64> FromTypeStr, ToTypeStr; getDiags()->ConvertArgToString(Kind, val, StringRef(Modifier, ModifierLen), StringRef(Argument, ArgumentLen), FormattedArgs, - OutStr, QualTypeVals); + FromTypeStr, QualTypeVals); if (!TDT.TemplateDiffUsed) FormattedArgs.push_back(std::make_pair(DiagnosticsEngine::ak_qualtype, TDT.FromType)); - // Append middle text - FormatDiagnostic(FirstDollar + 1, SecondDollar, OutStr); - - // Append second type + // Get second type text TDT.PrintFromType = false; getDiags()->ConvertArgToString(Kind, val, StringRef(Modifier, ModifierLen), StringRef(Argument, ArgumentLen), FormattedArgs, - OutStr, QualTypeVals); + ToTypeStr, QualTypeVals); if (!TDT.TemplateDiffUsed) FormattedArgs.push_back(std::make_pair(DiagnosticsEngine::ak_qualtype, TDT.ToType)); + // Append before text + FormatDiagnostic(Argument, FirstDollar, OutStr); + + // Append first type + OutStr.append(FromTypeStr); + + // Append middle text + FormatDiagnostic(FirstDollar + 1, SecondDollar, OutStr); + + // Append second type + OutStr.append(ToTypeStr); + // Append end text FormatDiagnostic(SecondDollar + 1, Pipe, OutStr); + + if (FromTypeStr == ToTypeStr) { +SmallString<86> IncompatibleVLADiag( +"; consider using a typedef to use the same variable-length array " +"type for both operands"); +OutStr.append(IncompatibleVLADiag); + } + break; } } diff --git a/clang/test/Sema/incompatible-vla-assignment.cpp b/clang/test/Sema/incompatible-vla-assignment.cpp new file mode 100644 index 00..8be063631b7a8a --- /dev/null +++ b/clang/test/Sema/incompatible-vla-assignment.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +void func(int n) { +int grp[n][n]; +int (*ptr)[n]; + +for (int i = 0; i < n; i++) +ptr = &grp[i]; // expected-error {{incompatible pointer types assigning to 'int (*)[n]' from 'int (*)[n]'; consider using a typedef to use the same variable-length array type for both operands}} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Improve diagnostics with incompatible VLA types (PR #101261)
https://github.com/sookach updated https://github.com/llvm/llvm-project/pull/101261 >From e7d15a3d29715e4922eb542d46cdc6d081ad740e Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Tue, 30 Jul 2024 19:31:41 -0400 Subject: [PATCH] [clang] Improve diagnostics with incompatible VLA types --- .../clang/Basic/DiagnosticSemaKinds.td| 3 +++ clang/lib/Sema/SemaExpr.cpp | 27 ++- .../test/Sema/incompatible-vla-assignment.cpp | 9 +++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 clang/test/Sema/incompatible-vla-assignment.cpp diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 9e6d85c469d64..5533ffb4b991c 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -8643,6 +8643,9 @@ def err_typecheck_convert_incompatible_pointer : Error< "; take the address with &|" "; remove *|" "; remove &}3">; +def err_typecheck_convert_incompatible_vla : Error< + "incompatible assignment of pointers of variable-length array type %0" + "; consider using a typedef to use the same variable-length array type for both operands">; def err_typecheck_convert_incompatible_function_pointer : Error< "incompatible function pointer types " "%select{%diff{assigning to $ from $|assigning to different types}0,1" diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 74c0e01705905..84129a0f1c833 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -16644,7 +16644,32 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy, if (Action == AA_Passing_CFAudited) { DiagKind = diag::err_arc_typecheck_convert_incompatible_pointer; } else if (getLangOpts().CPlusPlus) { - DiagKind = diag::err_typecheck_convert_incompatible_pointer; + DiagKind = [this, &SrcType, &DstType] { +const VariableArrayType *SrcTypeVLA = nullptr, *DstTypeVLA = nullptr; +if (const PointerType *P = SrcType->getAs()) + SrcTypeVLA = Context.getAsVariableArrayType(P->getPointeeType()); +if (const PointerType *P = DstType->getAs()) + DstTypeVLA = Context.getAsVariableArrayType(P->getPointeeType()); + +if (SrcTypeVLA == nullptr || DstTypeVLA == nullptr) + return diag::err_typecheck_convert_incompatible_pointer; + +DeclRefExpr *SrcSizeExpr = nullptr, *DstSizeExpr = nullptr; +if (ImplicitCastExpr *I = +dyn_cast(SrcTypeVLA->getSizeExpr())) + SrcSizeExpr = dyn_cast(I->getSubExpr()); +if (ImplicitCastExpr *I = +dyn_cast(DstTypeVLA->getSizeExpr())) + DstSizeExpr = dyn_cast(I->getSubExpr()); + +if (SrcSizeExpr == nullptr || DstSizeExpr == nullptr) + return diag::err_typecheck_convert_incompatible_pointer; + +return SrcSizeExpr->getDecl()->getName() == + DstSizeExpr->getDecl()->getName() + ? diag::err_typecheck_convert_incompatible_vla + : diag::err_typecheck_convert_incompatible_pointer; + }(); isInvalid = true; } else { DiagKind = diag::ext_typecheck_convert_incompatible_pointer; diff --git a/clang/test/Sema/incompatible-vla-assignment.cpp b/clang/test/Sema/incompatible-vla-assignment.cpp new file mode 100644 index 0..9cecaacb6c250 --- /dev/null +++ b/clang/test/Sema/incompatible-vla-assignment.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +void func(int n) { +int grp[n][n]; +int (*ptr)[n]; + +for (int i = 0; i < n; i++) +ptr = &grp[i]; // expected-error {{incompatible assignment of pointers of variable-length array type 'int (*)[n]'; consider using a typedef to use the same variable-length array type for both operands}} +} \ No newline at end of file ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Improve diagnostics with incompatible VLA types (PR #101261)
https://github.com/sookach created https://github.com/llvm/llvm-project/pull/101261 This PR addresses #99914, by emitting a separate diagnostic for VLA's with the same bounds. @AaronBallman Let me know what you think. Thanks >From 667894f8e4e334e7fc32418bee95803138dfad40 Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Tue, 30 Jul 2024 19:31:41 -0400 Subject: [PATCH] [clang] Improve diagnostics with incompatible VLA types --- .../clang/Basic/DiagnosticSemaKinds.td| 3 +++ clang/lib/Sema/SemaExpr.cpp | 25 ++- .../test/Sema/incompatible-vla-assignment.cpp | 9 +++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 clang/test/Sema/incompatible-vla-assignment.cpp diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 9e6d85c469d64..5533ffb4b991c 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -8643,6 +8643,9 @@ def err_typecheck_convert_incompatible_pointer : Error< "; take the address with &|" "; remove *|" "; remove &}3">; +def err_typecheck_convert_incompatible_vla : Error< + "incompatible assignment of pointers of variable-length array type %0" + "; consider using a typedef to use the same variable-length array type for both operands">; def err_typecheck_convert_incompatible_function_pointer : Error< "incompatible function pointer types " "%select{%diff{assigning to $ from $|assigning to different types}0,1" diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 74c0e01705905..e93fb869e840d 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -16644,7 +16644,30 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy, if (Action == AA_Passing_CFAudited) { DiagKind = diag::err_arc_typecheck_convert_incompatible_pointer; } else if (getLangOpts().CPlusPlus) { - DiagKind = diag::err_typecheck_convert_incompatible_pointer; + DiagKind = [this, &SrcType, &DstType] { +const VariableArrayType *SrcTypeVLA = nullptr, *DstTypeVLA = nullptr; +if (const PointerType *P = SrcType->getAs()) + SrcTypeVLA = Context.getAsVariableArrayType(P->getPointeeType()); +if (const PointerType *P = DstType->getAs()) + DstTypeVLA = Context.getAsVariableArrayType(P->getPointeeType()); + +if (SrcTypeVLA == nullptr || DstTypeVLA == nullptr) + return diag::err_typecheck_convert_incompatible_pointer; + +DeclRefExpr *SrcSizeExpr = nullptr, *DstSizeExpr = nullptr; +if (ImplicitCastExpr* I = dyn_cast(SrcTypeVLA->getSizeExpr())) +SrcSizeExpr = dyn_cast(I->getSubExpr()); +if (ImplicitCastExpr* I = dyn_cast(DstTypeVLA->getSizeExpr())) +DstSizeExpr = dyn_cast(I->getSubExpr()); + +if (SrcSizeExpr == nullptr || DstSizeExpr == nullptr) + return diag::err_typecheck_convert_incompatible_pointer; + +return SrcSizeExpr->getDecl()->getName() == + DstSizeExpr->getDecl()->getName() + ? diag::err_typecheck_convert_incompatible_vla + : diag::err_typecheck_convert_incompatible_pointer; + }(); isInvalid = true; } else { DiagKind = diag::ext_typecheck_convert_incompatible_pointer; diff --git a/clang/test/Sema/incompatible-vla-assignment.cpp b/clang/test/Sema/incompatible-vla-assignment.cpp new file mode 100644 index 0..9cecaacb6c250 --- /dev/null +++ b/clang/test/Sema/incompatible-vla-assignment.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +void func(int n) { +int grp[n][n]; +int (*ptr)[n]; + +for (int i = 0; i < n; i++) +ptr = &grp[i]; // expected-error {{incompatible assignment of pointers of variable-length array type 'int (*)[n]'; consider using a typedef to use the same variable-length array type for both operands}} +} \ No newline at end of file ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][analyzer] Ignore try-statements in UnreachableCode checker (PR #91675)
soukatch wrote: Thanks for the review! https://github.com/llvm/llvm-project/pull/91675 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][analyzer] Ignore try-statements in dead code checker (PR #91675)
https://github.com/soukatch updated https://github.com/llvm/llvm-project/pull/91675 >From 846be0552bd2da608fc1729e5928d85650e1ce06 Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Thu, 9 May 2024 18:49:41 -0400 Subject: [PATCH] [clang][static analyzer] ignore try statements in dead code checker --- .../Checkers/UnreachableCodeChecker.cpp | 4 +++- clang/test/Analysis/unreachable-code-exceptions.cpp | 12 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 clang/test/Analysis/unreachable-code-exceptions.cpp diff --git a/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp index d24a124f5ffee..7ce9a5b5bb6dc 100644 --- a/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp @@ -159,6 +159,8 @@ void UnreachableCodeChecker::checkEndAnalysis(ExplodedGraph &G, SL = DL.asLocation(); if (SR.isInvalid() || !SL.isValid()) continue; + if (isa(S)) +continue; } else continue; @@ -254,4 +256,4 @@ void ento::registerUnreachableCodeChecker(CheckerManager &mgr) { bool ento::shouldRegisterUnreachableCodeChecker(const CheckerManager &mgr) { return true; -} +} \ No newline at end of file diff --git a/clang/test/Analysis/unreachable-code-exceptions.cpp b/clang/test/Analysis/unreachable-code-exceptions.cpp new file mode 100644 index 0..aad7625b92d71 --- /dev/null +++ b/clang/test/Analysis/unreachable-code-exceptions.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_analyze_cc1 -verify %s -fcxx-exceptions -fexceptions -analyzer-checker=core -analyzer-checker=alpha.deadcode.UnreachableCode + +// expected-no-diagnostics + +void foo(); + +void f4() { + try { +foo(); + } catch (int) { + } +} \ No newline at end of file ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][analyzer] Ignore try-statements in dead code checker (PR #91675)
soukatch wrote: > To find which file you need to add your test, I created a new file altogether since I don't think any of the current one would fit the test. https://github.com/llvm/llvm-project/pull/91675 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][analyzer] Ignore try-statements in dead code checker (PR #91675)
https://github.com/soukatch updated https://github.com/llvm/llvm-project/pull/91675 >From 4ed555c81ae5b773361da22c0736f82fbf14c90d Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Thu, 9 May 2024 18:49:41 -0400 Subject: [PATCH] [clang][static analyzer] ignore try statements in dead code checker --- .../Checkers/UnreachableCodeChecker.cpp | 4 +++- .../Analysis/unreachable-code-exceptions.cpp| 17 + 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 clang/test/Analysis/unreachable-code-exceptions.cpp diff --git a/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp index d24a124f5ffee..7ce9a5b5bb6dc 100644 --- a/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp @@ -159,6 +159,8 @@ void UnreachableCodeChecker::checkEndAnalysis(ExplodedGraph &G, SL = DL.asLocation(); if (SR.isInvalid() || !SL.isValid()) continue; + if (isa(S)) +continue; } else continue; @@ -254,4 +256,4 @@ void ento::registerUnreachableCodeChecker(CheckerManager &mgr) { bool ento::shouldRegisterUnreachableCodeChecker(const CheckerManager &mgr) { return true; -} +} \ No newline at end of file diff --git a/clang/test/Analysis/unreachable-code-exceptions.cpp b/clang/test/Analysis/unreachable-code-exceptions.cpp new file mode 100644 index 0..db4c87bc3bad6 --- /dev/null +++ b/clang/test/Analysis/unreachable-code-exceptions.cpp @@ -0,0 +1,17 @@ +// RUN: %clang_analyze_cc1 -verify %s -fcxx-exceptions -fexceptions -analyzer-checker=core -analyzer-checker=alpha.deadcode.UnreachableCode + +// expected-no-diagnostics + +class BaseException {}; + +class DerivedException : public BaseException {}; + +void foo(); + +void f4() { + try { +foo(); + } catch (BaseException &b) { + } catch (DerivedException &d) { + } +} \ No newline at end of file ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][static analyzer] ignore try statements in dead code checker (PR #91675)
https://github.com/soukatch deleted https://github.com/llvm/llvm-project/pull/91675 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][static analyzer] ignore try statements in dead code checker (PR #91675)
@@ -159,8 +159,10 @@ void UnreachableCodeChecker::checkEndAnalysis(ExplodedGraph &G, SL = DL.asLocation(); if (SR.isInvalid() || !SL.isValid()) continue; -} -else + + if (isa(S)) soukatch wrote: everything besides this if statement is just a clang-format change https://github.com/llvm/llvm-project/pull/91675 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][static analyzer] ignore try statements in dead code checker (PR #91675)
https://github.com/soukatch deleted https://github.com/llvm/llvm-project/pull/91675 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][static analyzer] ignore try statements in dead code checker (PR #91675)
soukatch wrote: @steakhal I believe you're the best person to tag :). https://github.com/llvm/llvm-project/pull/91675 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][static analyzer] ignore try statements in dead code checker (PR #91675)
@@ -159,8 +159,10 @@ void UnreachableCodeChecker::checkEndAnalysis(ExplodedGraph &G, SL = DL.asLocation(); if (SR.isInvalid() || !SL.isValid()) continue; -} -else + + if (isa(S)) soukatch wrote: everything above this point is just clang-format changes https://github.com/llvm/llvm-project/pull/91675 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][static analyzer] ignore try statements in dead code checker (PR #91675)
https://github.com/soukatch created https://github.com/llvm/llvm-project/pull/91675 Fixes #90162. Simplest approach I could come up with was to skip cxxtry statements. Let me know if you have any suggestions. Thanks! >From e1fcdc37e52189abcdf8ce84ada463491d8b6c04 Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Thu, 9 May 2024 18:49:41 -0400 Subject: [PATCH] [clang][static analyzer] ignore try statements in dead code checker --- .../Checkers/UnreachableCodeChecker.cpp | 30 ++- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp index d24a124f5ffee..205f646194f58 100644 --- a/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp @@ -12,10 +12,10 @@ // A similar flow-sensitive only check exists in Analysis/ReachableCode.cpp //===--===// -#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include "clang/AST/ParentMap.h" #include "clang/Basic/Builtins.h" #include "clang/Basic/SourceManager.h" +#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" #include "clang/StaticAnalyzer/Core/Checker.h" #include "clang/StaticAnalyzer/Core/CheckerManager.h" @@ -34,6 +34,7 @@ class UnreachableCodeChecker : public Checker { public: void checkEndAnalysis(ExplodedGraph &G, BugReporter &B, ExprEngine &Eng) const; + private: typedef llvm::SmallSet CFGBlocksSet; @@ -44,10 +45,9 @@ class UnreachableCodeChecker : public Checker { static bool isInvalidPath(const CFGBlock *CB, const ParentMap &PM); static inline bool isEmptyCFGBlock(const CFGBlock *CB); }; -} +} // namespace -void UnreachableCodeChecker::checkEndAnalysis(ExplodedGraph &G, - BugReporter &B, +void UnreachableCodeChecker::checkEndAnalysis(ExplodedGraph &G, BugReporter &B, ExprEngine &Eng) const { CFGBlocksSet reachable, visited; @@ -126,8 +126,8 @@ void UnreachableCodeChecker::checkEndAnalysis(ExplodedGraph &G, // such as llvm_unreachable. if (!CB->empty()) { bool foundUnreachable = false; - for (CFGBlock::const_iterator ci = CB->begin(), ce = CB->end(); - ci != ce; ++ci) { + for (CFGBlock::const_iterator ci = CB->begin(), ce = CB->end(); ci != ce; + ++ci) { if (std::optional S = (*ci).getAs()) if (const CallExpr *CE = dyn_cast(S->getStmt())) { if (CE->getBuiltinCallee() == Builtin::BI__builtin_unreachable || @@ -159,8 +159,10 @@ void UnreachableCodeChecker::checkEndAnalysis(ExplodedGraph &G, SL = DL.asLocation(); if (SR.isInvalid() || !SL.isValid()) continue; -} -else + + if (isa(S)) +continue; +} else continue; // Check if the SourceLocation is in a system header @@ -229,9 +231,9 @@ bool UnreachableCodeChecker::isInvalidPath(const CFGBlock *CB, // Get the predecessor block's terminator condition const Stmt *cond = pred->getTerminatorCondition(); - //assert(cond && "CFGBlock's predecessor has a terminator condition"); - // The previous assertion is invalid in some cases (eg do/while). Leaving - // reporting of these situations on at the moment to help triage these cases. + // assert(cond && "CFGBlock's predecessor has a terminator condition"); + // The previous assertion is invalid in some cases (eg do/while). Leaving + // reporting of these situations on at the moment to help triage these cases. if (!cond) return false; @@ -243,9 +245,9 @@ bool UnreachableCodeChecker::isInvalidPath(const CFGBlock *CB, // Returns true if the given CFGBlock is empty bool UnreachableCodeChecker::isEmptyCFGBlock(const CFGBlock *CB) { - return CB->getLabel() == nullptr // No labels - && CB->size() == 0 // No statements - && !CB->getTerminatorStmt(); // No terminator + return CB->getLabel() == nullptr// No labels + && CB->size() == 0 // No statements + && !CB->getTerminatorStmt(); // No terminator } void ento::registerUnreachableCodeChecker(CheckerManager &mgr) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] MangledSymbol: remove pointless copy of vector (PR #90012)
soukatch wrote: Thank you everyone for the reviews! https://github.com/llvm/llvm-project/pull/90012 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [flang] [libc] [libclc] [libcxx] [libcxxabi] [lld] [lldb] [llvm] [mlir] [libc++] implement ranges::find_last (PR #91081)
https://github.com/soukatch closed https://github.com/llvm/llvm-project/pull/91081 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] MangledSymbol: remove pointless copy of vector (PR #90012)
soukatch wrote: @AaronBallman would it be possible to get an approval while all the checks are green? Thanks! https://github.com/llvm/llvm-project/pull/90012 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] MangledSymbol: remove pointless copy of vector (PR #90012)
https://github.com/soukatch updated https://github.com/llvm/llvm-project/pull/90012 >From 9007597af4f138d2744405bb7980fce4555d7508 Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Wed, 24 Apr 2024 22:50:50 -0400 Subject: [PATCH 1/3] [clang] MangledSymbol: remove pointless copy of vector --- clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp index d58f5bb0919906..81a827dba26b90 100644 --- a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp +++ b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp @@ -33,7 +33,8 @@ class InterfaceStubFunctionsConsumer : public ASTConsumer { MangledSymbol(const std::string &ParentName, uint8_t Type, uint8_t Binding, std::vector Names) -: ParentName(ParentName), Type(Type), Binding(Binding), Names(Names) {} +: ParentName(ParentName), Type(Type), Binding(Binding), + Names(std::move(Names)) {} }; using MangledSymbols = std::map; >From 7774ca198e84946f45ae9301769f53ee91aaddac Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Fri, 26 Apr 2024 01:29:28 -0400 Subject: [PATCH 2/3] >From f215551cda763e96c1a7096f86b6d5c1cc0b6bea Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Wed, 1 May 2024 23:16:16 -0400 Subject: [PATCH 3/3] ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] MangledSymbol: remove pointless copy of vector (PR #90012)
https://github.com/soukatch updated https://github.com/llvm/llvm-project/pull/90012 >From 9007597af4f138d2744405bb7980fce4555d7508 Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Wed, 24 Apr 2024 22:50:50 -0400 Subject: [PATCH 1/3] [clang] MangledSymbol: remove pointless copy of vector --- clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp index d58f5bb0919906..81a827dba26b90 100644 --- a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp +++ b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp @@ -33,7 +33,8 @@ class InterfaceStubFunctionsConsumer : public ASTConsumer { MangledSymbol(const std::string &ParentName, uint8_t Type, uint8_t Binding, std::vector Names) -: ParentName(ParentName), Type(Type), Binding(Binding), Names(Names) {} +: ParentName(ParentName), Type(Type), Binding(Binding), + Names(std::move(Names)) {} }; using MangledSymbols = std::map; >From 7774ca198e84946f45ae9301769f53ee91aaddac Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Fri, 26 Apr 2024 01:29:28 -0400 Subject: [PATCH 2/3] >From f215551cda763e96c1a7096f86b6d5c1cc0b6bea Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Wed, 1 May 2024 23:16:16 -0400 Subject: [PATCH 3/3] ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] MangledSymbol: remove pointless copy of vector (PR #90012)
https://github.com/soukatch updated https://github.com/llvm/llvm-project/pull/90012 >From 9007597af4f138d2744405bb7980fce4555d7508 Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Wed, 24 Apr 2024 22:50:50 -0400 Subject: [PATCH 1/2] [clang] MangledSymbol: remove pointless copy of vector --- clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp index d58f5bb0919906..81a827dba26b90 100644 --- a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp +++ b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp @@ -33,7 +33,8 @@ class InterfaceStubFunctionsConsumer : public ASTConsumer { MangledSymbol(const std::string &ParentName, uint8_t Type, uint8_t Binding, std::vector Names) -: ParentName(ParentName), Type(Type), Binding(Binding), Names(Names) {} +: ParentName(ParentName), Type(Type), Binding(Binding), + Names(std::move(Names)) {} }; using MangledSymbols = std::map; >From 7774ca198e84946f45ae9301769f53ee91aaddac Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Fri, 26 Apr 2024 01:29:28 -0400 Subject: [PATCH 2/2] ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] MangledSymbol: remove pointless copy of vector (PR #90012)
https://github.com/soukatch updated https://github.com/llvm/llvm-project/pull/90012 >From 9007597af4f138d2744405bb7980fce4555d7508 Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Wed, 24 Apr 2024 22:50:50 -0400 Subject: [PATCH] [clang] MangledSymbol: remove pointless copy of vector --- clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp index d58f5bb0919906..81a827dba26b90 100644 --- a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp +++ b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp @@ -33,7 +33,8 @@ class InterfaceStubFunctionsConsumer : public ASTConsumer { MangledSymbol(const std::string &ParentName, uint8_t Type, uint8_t Binding, std::vector Names) -: ParentName(ParentName), Type(Type), Binding(Binding), Names(Names) {} +: ParentName(ParentName), Type(Type), Binding(Binding), + Names(std::move(Names)) {} }; using MangledSymbols = std::map; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] MangledSymbol: remove pointless copy of vector (PR #90012)
https://github.com/soukatch updated https://github.com/llvm/llvm-project/pull/90012 >From b8e20a5a3e37ab9a657ac640b848f638387215fa Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Wed, 24 Apr 2024 22:50:50 -0400 Subject: [PATCH 1/2] [clang] MangledSymbol: remove pointless copy of vector --- clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp index d58f5bb0919906..81a827dba26b90 100644 --- a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp +++ b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp @@ -33,7 +33,8 @@ class InterfaceStubFunctionsConsumer : public ASTConsumer { MangledSymbol(const std::string &ParentName, uint8_t Type, uint8_t Binding, std::vector Names) -: ParentName(ParentName), Type(Type), Binding(Binding), Names(Names) {} +: ParentName(ParentName), Type(Type), Binding(Binding), + Names(std::move(Names)) {} }; using MangledSymbols = std::map; >From c2195e410896f626c9119b407acba512c273720f Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Fri, 26 Apr 2024 01:27:10 -0400 Subject: [PATCH 2/2] ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] MangledSymbol: remove pointless copy of vector (PR #90012)
soukatch wrote: Looking at the logs, and the error seems to be unrelated to the changes made https://buildkite.com/llvm-project/clang-ci/builds/16430#018f132d-506e-440c-b18b-fed98237def9/54-5446 https://github.com/llvm/llvm-project/pull/90012 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] MangledSymbol: remove pointless copy of vector (PR #90012)
soukatch wrote: @dcb314 @shafik @EugeneZelenko Please let me know if this change looks good. Thanks! https://github.com/llvm/llvm-project/pull/90012 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] MangledSymbol: remove pointless copy of vector (PR #90012)
https://github.com/soukatch created https://github.com/llvm/llvm-project/pull/90012 This pr addresses #87255 adds a std::move call to the names in MangledSymbol's constructor. >From b8e20a5a3e37ab9a657ac640b848f638387215fa Mon Sep 17 00:00:00 2001 From: Andrew Sukach Date: Wed, 24 Apr 2024 22:50:50 -0400 Subject: [PATCH] [clang] MangledSymbol: remove pointless copy of vector --- clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp index d58f5bb0919906..81a827dba26b90 100644 --- a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp +++ b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp @@ -33,7 +33,8 @@ class InterfaceStubFunctionsConsumer : public ASTConsumer { MangledSymbol(const std::string &ParentName, uint8_t Type, uint8_t Binding, std::vector Names) -: ParentName(ParentName), Type(Type), Binding(Binding), Names(Names) {} +: ParentName(ParentName), Type(Type), Binding(Binding), + Names(std::move(Names)) {} }; using MangledSymbols = std::map; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits