[Lldb-commits] [PATCH] D156020: [lldb][PlatformDarwin] Parse SDK path for module compilation from debug-info

2023-07-22 Thread Michael Buch via Phabricator via lldb-commits
Michael137 created this revision.
Michael137 added a reviewer: aprantl.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

When we build the Clang module compilation command (e.g., when
a user requests import of a module via `expression @import Foundation`),
LLDB will try to determine which SDK directory to use as the `sysroot`.
However, it currently does so by simply enumerating the `SDKs` directory
and picking the last one that's appropriate for module compilation
(see `PlatformDarwin::GetSDKDirectoryForModules`). That means if we have
multiple platform SDKs installed (e.g., a public and internal one), we
may pick the wrong one by chance.

On Darwin platforms we emit the SDK path that a object
file was compiled against into DWARF (using `DW_AT_LLVM_sysroot`
and `DW_AT_APPLE_sdk`). For Swift debugging, we already parse the SDK
path from debug-info if we can.

This patch mimicks the Swift behaviour for non-Swift languages. I.e.,
if we can get the SDK path from debug-info, do so. Otherwise, fall back
to the old heuristic.

rdar://110407148


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156020

Files:
  lldb/include/lldb/Target/Platform.h
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/source/Target/Platform.cpp
  lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp

Index: lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp
===
--- lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp
+++ lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp
@@ -12,6 +12,7 @@
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 #include "TestingSupport/Symbol/YAMLModuleTester.h"
 #include "lldb/Core/PluginManager.h"
+#include "llvm/Support/Error.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -72,4 +73,174 @@
   ASSERT_EQ(sdk.GetType(), XcodeSDK::Type::MacOSX);
   ASSERT_EQ(module->GetSourceMappingList().GetSize(), 1u);
 }
+
+TEST_F(XcodeSDKModuleTests, TestSDKPathFromDebugInfo_InternalAndPublicSDK) {
+  // Tests that we can parse the SDK path from debug-info.
+  // In the presence of multiple compile units, one of which
+  // points to an internal SDK, we should pick the internal SDK.
+
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debug_abbrev:
+- Table:
+- Code:0x0001
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:   DW_AT_language
+  Form:DW_FORM_data2
+- Attribute:   DW_AT_APPLE_sdk
+  Form:DW_FORM_string
+- Attribute:   DW_AT_LLVM_sysroot
+  Form:DW_FORM_string
+- Code:0x0002
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:   DW_AT_language
+  Form:DW_FORM_data2
+- Attribute:   DW_AT_APPLE_sdk
+  Form:DW_FORM_string
+- Attribute:   DW_AT_LLVM_sysroot
+  Form:DW_FORM_string
+  debug_info:
+- Version: 2
+  AddrSize:8
+  AbbrevTableID:   0
+  AbbrOffset:  0x0
+  Entries:
+- AbbrCode:0x0001
+  Values:
+- Value:   0x000C
+- CStr:"MacOSX10.9.sdk"
+- CStr:"/Library/Developer/CommandLineTools/SDKs/MacOSX10.9.sdk"
+- AbbrCode:0x
+- Version: 2
+  AddrSize:8
+  AbbrevTableID:   0
+  AbbrOffset:  0x0
+  Entries:
+- AbbrCode:0x0002
+  Values:
+- Value:   0x0010
+- CStr:"iPhoneOS14.0.Internal.sdk"
+- CStr:"/Library/Developer/CommandLineTools/SDKs/iPhoneOS14.0.Internal.sdk"
+- AbbrCode:0x
+...
+)";
+
+  YAMLModuleTester t(yamldata);
+  DWARFUnit *dwarf_unit = t.GetDwarfUnit();
+  auto *dwarf_cu = llvm::cast(dwarf_unit);
+  ASSERT_TRUE(static_cast(dwarf_cu));
+  SymbolFileDWARF &sym_file = dwarf_cu->GetSymbolFileDWARF();
+  ASSERT_EQ(sym_file.GetNumCompileUnits(), 2U);
+  ModuleSP module = t.GetModule();
+  ASSERT_NE(module, nullptr);
+
+  auto path_or_err = Platform::GetSDKPathFromDebugInfo(*module);
+  ASSERT_TRUE(!!path_or_err);
+
+  auto [sdk_path, found_internal, found_public] = *path_or_err;
+
+  ASSERT_TRUE(found_internal);
+  ASSERT_TRUE(found_public);
+  ASSERT_NE(sdk_path.find("Internal.sdk"), std::string::npos);
+}
+
+TEST_F(XcodeSDKModuleTests, TestSDKPathFromDebugInfo_InvalidSDKPath) {
+  // Tests that parsing a CU with an invalid SDK directory 

[Lldb-commits] [PATCH] D156020: [lldb][PlatformDarwin] Parse SDK path for module compilation from debug-info

2023-07-22 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added inline comments.
Herald added a subscriber: JDevlieghere.



Comment at: lldb/include/lldb/Target/Platform.h:492
+  static llvm::Expected
+  GetSDKPathFromDebugInfo(Module &module);
+

I'm open to suggestions on where to put this API. `Platform` seems a bit too 
generic. But the intention is to share it with the Swift plugin. I could put it 
into `PlatformDarwin`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156020/new/

https://reviews.llvm.org/D156020

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D156020: [lldb][PlatformDarwin] Parse SDK path for module compilation from debug-info

2023-07-22 Thread Michael Buch via Phabricator via lldb-commits
Michael137 updated this revision to Diff 543160.
Michael137 added a comment.

- Remove redundant headers


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156020/new/

https://reviews.llvm.org/D156020

Files:
  lldb/include/lldb/Target/Platform.h
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/source/Target/Platform.cpp
  lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp

Index: lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp
===
--- lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp
+++ lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp
@@ -12,6 +12,7 @@
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 #include "TestingSupport/Symbol/YAMLModuleTester.h"
 #include "lldb/Core/PluginManager.h"
+#include "llvm/Support/Error.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -72,4 +73,174 @@
   ASSERT_EQ(sdk.GetType(), XcodeSDK::Type::MacOSX);
   ASSERT_EQ(module->GetSourceMappingList().GetSize(), 1u);
 }
+
+TEST_F(XcodeSDKModuleTests, TestSDKPathFromDebugInfo_InternalAndPublicSDK) {
+  // Tests that we can parse the SDK path from debug-info.
+  // In the presence of multiple compile units, one of which
+  // points to an internal SDK, we should pick the internal SDK.
+
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debug_abbrev:
+- Table:
+- Code:0x0001
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:   DW_AT_language
+  Form:DW_FORM_data2
+- Attribute:   DW_AT_APPLE_sdk
+  Form:DW_FORM_string
+- Attribute:   DW_AT_LLVM_sysroot
+  Form:DW_FORM_string
+- Code:0x0002
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:   DW_AT_language
+  Form:DW_FORM_data2
+- Attribute:   DW_AT_APPLE_sdk
+  Form:DW_FORM_string
+- Attribute:   DW_AT_LLVM_sysroot
+  Form:DW_FORM_string
+  debug_info:
+- Version: 2
+  AddrSize:8
+  AbbrevTableID:   0
+  AbbrOffset:  0x0
+  Entries:
+- AbbrCode:0x0001
+  Values:
+- Value:   0x000C
+- CStr:"MacOSX10.9.sdk"
+- CStr:"/Library/Developer/CommandLineTools/SDKs/MacOSX10.9.sdk"
+- AbbrCode:0x
+- Version: 2
+  AddrSize:8
+  AbbrevTableID:   0
+  AbbrOffset:  0x0
+  Entries:
+- AbbrCode:0x0002
+  Values:
+- Value:   0x0010
+- CStr:"iPhoneOS14.0.Internal.sdk"
+- CStr:"/Library/Developer/CommandLineTools/SDKs/iPhoneOS14.0.Internal.sdk"
+- AbbrCode:0x
+...
+)";
+
+  YAMLModuleTester t(yamldata);
+  DWARFUnit *dwarf_unit = t.GetDwarfUnit();
+  auto *dwarf_cu = llvm::cast(dwarf_unit);
+  ASSERT_TRUE(static_cast(dwarf_cu));
+  SymbolFileDWARF &sym_file = dwarf_cu->GetSymbolFileDWARF();
+  ASSERT_EQ(sym_file.GetNumCompileUnits(), 2U);
+  ModuleSP module = t.GetModule();
+  ASSERT_NE(module, nullptr);
+
+  auto path_or_err = Platform::GetSDKPathFromDebugInfo(*module);
+  ASSERT_TRUE(!!path_or_err);
+
+  auto [sdk_path, found_internal, found_public] = *path_or_err;
+
+  ASSERT_TRUE(found_internal);
+  ASSERT_TRUE(found_public);
+  ASSERT_NE(sdk_path.find("Internal.sdk"), std::string::npos);
+}
+
+TEST_F(XcodeSDKModuleTests, TestSDKPathFromDebugInfo_InvalidSDKPath) {
+  // Tests that parsing a CU with an invalid SDK directory name fails.
+
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debug_abbrev:
+- Table:
+- Code:0x0001
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:   DW_AT_language
+  Form:DW_FORM_data2
+- Attribute:   DW_AT_APPLE_sdk
+  Form:DW_FORM_string
+  debug_info:
+- Version: 2
+  AddrSize:8
+  AbbrevTableID:   0
+  AbbrOffset:  0x0
+  Entries:
+- AbbrCode:0x0001
+  Values:
+- Value:   0x000C
+- CStr:"1abc@defgh2"
+- AbbrCode:0x
+...
+)";
+
+  YAMLModuleTester t(yamldata);
+  ModuleSP module = t.GetModule();
+  ASSERT_NE(module, nullptr);
+
+  auto p

[Lldb-commits] [PATCH] D156020: [lldb][PlatformDarwin] Parse SDK path for module compilation from debug-info

2023-07-22 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added inline comments.



Comment at: lldb/include/lldb/Target/Platform.h:492
+  static llvm::Expected
+  GetSDKPathFromDebugInfo(Module &module);
+

Michael137 wrote:
> I'm open to suggestions on where to put this API. `Platform` seems a bit too 
> generic. But the intention is to share it with the Swift plugin. I could put 
> it into `PlatformDarwin`.
See how I intend to use it from the Swift plugin [[ 
https://github.com/apple/llvm-project/pull/7094/files#diff-35515cd82b78e2f7bbeff1d175f83a9dbe48066615f29cd377bd9cbf4591cb70
 | here ]]


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156020/new/

https://reviews.llvm.org/D156020

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 874217f - [clang] Enable C++11-style attributes in all language modes

2023-07-22 Thread Nikolas Klauser via lldb-commits

Author: Nikolas Klauser
Date: 2023-07-22T09:34:15-07:00
New Revision: 874217f99b99ab3c9026dc3b7bd84cd2beebde6e

URL: 
https://github.com/llvm/llvm-project/commit/874217f99b99ab3c9026dc3b7bd84cd2beebde6e
DIFF: 
https://github.com/llvm/llvm-project/commit/874217f99b99ab3c9026dc3b7bd84cd2beebde6e.diff

LOG: [clang] Enable C++11-style attributes in all language modes

This also ignores and deprecates the `-fdouble-square-bracket-attributes` 
command line flag, which seems to not be used anywhere. At least a code search 
exclusively found mentions of it in documentation: 
https://sourcegraph.com/search?q=context:global+-fdouble-square-bracket-attributes+-file:clang/*+-file:test/Sema/*+-file:test/Parser/*+-file:test/AST/*+-file:test/Preprocessor/*+-file:test/Misc/*+archived:yes&patternType=standard&sm=0&groupBy=repo

RFC: 
https://discourse.llvm.org/t/rfc-enable-c-11-c2x-attributes-in-all-standard-modes-as-an-extension-and-remove-fdouble-square-bracket-attributes

This enables `[[]]` attributes in all C and C++ language modes without warning 
by default. `-Wc++-extensions` does warn. GCC has enabled this extension in all 
C modes since GCC 10.

Reviewed By: aaron.ballman, MaskRay

Spies: #clang-vendors, beanz, JDevlieghere, Michael137, MaskRay, sstefan1, 
jplehr, cfe-commits, lldb-commits, dmgreen, jdoerfert, wenlei, wlei

Differential Revision: https://reviews.llvm.org/D151683

Added: 
clang/test/Sema/c2x-attr.c

Modified: 
clang/docs/LanguageExtensions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/Features.def
clang/include/clang/Driver/Options.td
clang/include/clang/Parse/Parser.h
clang/lib/Basic/Attributes.cpp
clang/lib/Lex/Lexer.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/test/AST/ast-dump-attr.m
clang/test/AST/ast-dump-c-attr.c
clang/test/AST/attr-annotate-type.c
clang/test/CodeGen/attr-btf_type_tag-func.c
clang/test/CodeGen/attr-btf_type_tag-var.c
clang/test/Frontend/noderef.c
clang/test/OpenMP/assumes_messages_attr.c
clang/test/OpenMP/openmp_attribute_compat.cpp
clang/test/Parser/asm.c
clang/test/Parser/c2x-attributes.c
clang/test/Parser/c2x-attributes.m
clang/test/Parser/cxx-decl.cpp
clang/test/Parser/objc-attr.m
clang/test/ParserHLSL/group_shared.hlsl
clang/test/Preprocessor/has_c_attribute.c
clang/test/Sema/annotate-type.c
clang/test/Sema/annotate.c
clang/test/Sema/attr-availability-square-brackets.c
clang/test/Sema/attr-external-source-symbol-cxx.cpp
clang/test/Sema/attr-external-source-symbol.c
clang/test/Sema/attr-likelihood.c
clang/test/Sema/attr-objc-bridge-related.m
clang/test/Sema/attr-regparm.c
clang/test/Sema/attr-type-safety.c
clang/test/Sema/c2x-noreturn.c
clang/test/Sema/internal_linkage.c
clang/test/Sema/matrix-type-builtins.c
clang/test/Sema/neon-vector-types.c
clang/test/Sema/overload-arm-mve.c
clang/test/Sema/overloadable.c
clang/test/Sema/vector-gcc-compat.c
clang/test/SemaCXX/cxx98-compat.cpp
clang/test/SemaCXX/warn-c++11-extensions.cpp
clang/test/SemaObjC/attr-objc-gc.m
clang/unittests/AST/AttrTest.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Removed: 
clang/test/SemaCXX/attr-cxx-disabled.cpp



diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 38a73f31064874..6705ee176196cc 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1429,15 +1429,15 @@ More information could be found `here 

 Language Extensions Back-ported to Previous Standards
 =
 
-==  
= = ==
-FeatureFeature Test Macro   
Introduced In Backported To Required Flags
-==  
= = ==
+==  
= =
+FeatureFeature Test Macro   
Introduced In Backported To
+==  
= =
 variadic templates __cpp_variadic_templates C++11  
   C++03
 Alias templates__cpp_alias_templatesC++11  
   C++03
 Non-static data member initializers__cpp_nsdmi  C++11  
   C++03
 Range-based ``for`` loop   __cpp_range_based_forC++11  
   C++03
 RValue references 

[Lldb-commits] [PATCH] D151683: [clang] Enable C++11-style attributes in all language modes

2023-07-22 Thread Nikolas Klauser via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG874217f99b99: [clang] Enable C++11-style attributes in all 
language modes (authored by philnik).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151683/new/

https://reviews.llvm.org/D151683

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/Features.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Parse/Parser.h
  clang/lib/Basic/Attributes.cpp
  clang/lib/Lex/Lexer.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/AST/ast-dump-attr.m
  clang/test/AST/ast-dump-c-attr.c
  clang/test/AST/attr-annotate-type.c
  clang/test/CodeGen/attr-btf_type_tag-func.c
  clang/test/CodeGen/attr-btf_type_tag-var.c
  clang/test/Frontend/noderef.c
  clang/test/OpenMP/assumes_messages_attr.c
  clang/test/OpenMP/openmp_attribute_compat.cpp
  clang/test/Parser/asm.c
  clang/test/Parser/c2x-attributes.c
  clang/test/Parser/c2x-attributes.m
  clang/test/Parser/cxx-decl.cpp
  clang/test/Parser/objc-attr.m
  clang/test/ParserHLSL/group_shared.hlsl
  clang/test/Preprocessor/has_c_attribute.c
  clang/test/Sema/annotate-type.c
  clang/test/Sema/annotate.c
  clang/test/Sema/attr-availability-square-brackets.c
  clang/test/Sema/attr-external-source-symbol-cxx.cpp
  clang/test/Sema/attr-external-source-symbol.c
  clang/test/Sema/attr-likelihood.c
  clang/test/Sema/attr-objc-bridge-related.m
  clang/test/Sema/attr-regparm.c
  clang/test/Sema/attr-type-safety.c
  clang/test/Sema/c2x-attr.c
  clang/test/Sema/c2x-noreturn.c
  clang/test/Sema/internal_linkage.c
  clang/test/Sema/matrix-type-builtins.c
  clang/test/Sema/neon-vector-types.c
  clang/test/Sema/overload-arm-mve.c
  clang/test/Sema/overloadable.c
  clang/test/Sema/vector-gcc-compat.c
  clang/test/SemaCXX/attr-cxx-disabled.cpp
  clang/test/SemaCXX/cxx98-compat.cpp
  clang/test/SemaCXX/warn-c++11-extensions.cpp
  clang/test/SemaObjC/attr-objc-gc.m
  clang/unittests/AST/AttrTest.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -575,7 +575,6 @@
 // FIXME: We should ask the driver for the appropriate default flags.
 lang_opts.GNUMode = true;
 lang_opts.GNUKeywords = true;
-lang_opts.DoubleSquareBracketAttributes = true;
 lang_opts.CPlusPlus11 = true;
 
 // The Darwin libc expects this macro to be set.
Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3394,14 +3394,10 @@
   // If this is the C++11 variety, also add in the LangOpts test.
   if (Variety == "CXX11")
 Test += " && LangOpts.CPlusPlus11";
-  else if (Variety == "C2x")
-Test += " && LangOpts.DoubleSquareBracketAttributes";
 } else if (Variety == "CXX11")
   // C++11 mode should be checked against LangOpts, which is presumed to be
   // present in the caller.
   Test = "LangOpts.CPlusPlus11";
-else if (Variety == "C2x")
-  Test = "LangOpts.DoubleSquareBracketAttributes";
 
 std::string TestStr = !Test.empty()
   ? Test + " ? " + llvm::itostr(Version) + " : 0"
Index: clang/unittests/AST/AttrTest.cpp
===
--- clang/unittests/AST/AttrTest.cpp
+++ clang/unittests/AST/AttrTest.cpp
@@ -157,7 +157,7 @@
   AST = buildASTFromCodeWithArgs(R"c(
 __auto_type [[clang::annotate_type("auto")]] auto_var = 1;
   )c",
- {"-fdouble-square-bracket-attributes"},
+ {},
  "input.c");
 
   {
Index: clang/test/SemaObjC/attr-objc-gc.m
===
--- clang/test/SemaObjC/attr-objc-gc.m
+++ clang/test/SemaObjC/attr-objc-gc.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fdouble-square-bracket-attributes -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
 static id __attribute((objc_gc(weak))) a;
 static id __attribute((objc_gc(strong))) b;
 
Index: clang/test/SemaCXX/warn-c++11-extensions.cpp
===
--- clang/test/SemaCXX/warn-c++11-extensions.cpp
+++ clang/test/SemaCXX/warn-c++11-extensions.cpp
@@ -7,3 +7,5 @@
 
 enum struct E1 { A, B }; // expected-warning {{scoped enumerations

[Lldb-commits] [lldb] 5d66f9f - [gdb-remote] Sort entries in QEnvironment*

2023-07-22 Thread Fangrui Song via lldb-commits

Author: Fangrui Song
Date: 2023-07-22T16:45:32-07:00
New Revision: 5d66f9fd8e97c05a5dba317d3ad2566e61ead1ff

URL: 
https://github.com/llvm/llvm-project/commit/5d66f9fd8e97c05a5dba317d3ad2566e61ead1ff
DIFF: 
https://github.com/llvm/llvm-project/commit/5d66f9fd8e97c05a5dba317d3ad2566e61ead1ff.diff

LOG: [gdb-remote] Sort entries in QEnvironment*

Similar to ae316ac66430997e342772fc4629c1acece0 for
QEMU_(UN)SET_ENV.
The iteration order of StringMap is not guaranteed to be deterministic.
Sort the entries to give deterministic packets for the tests added by
D108018.

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index 36e046d7466ebb..c6503129685ab4 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -35,6 +35,7 @@
 #include "lldb/Host/Config.h"
 #include "lldb/Utility/StringExtractorGDBRemote.h"
 
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/JSON.h"
 
@@ -826,8 +827,12 @@ llvm::Error 
GDBRemoteCommunicationClient::LaunchProcess(const Args &args) {
 }
 
 int GDBRemoteCommunicationClient::SendEnvironment(const Environment &env) {
-  for (const auto &KV : env) {
-int r = SendEnvironmentPacket(Environment::compose(KV).c_str());
+  llvm::SmallVector, 0> vec;
+  for (const auto &kv : env)
+vec.emplace_back(kv.first(), kv.second);
+  llvm::sort(vec, llvm::less_first());
+  for (const auto &[k, v] : vec) {
+int r = SendEnvironmentPacket((k + "=" + v).str().c_str());
 if (r != 0)
   return r;
   }

diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
index 65281044d93b47..2f4c8d799a6f02 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
@@ -371,12 +371,12 @@ def vRun(self, packet):
 
 self.assertPacketLogContains(
 [
+"QEnvironment:EQUALS=foo=bar",
+"QEnvironmentHexEncoded:4e45454453454e433d66726f6224",
+"QEnvironmentHexEncoded:4e45454453454e43323d66722a6f62",
 "QEnvironmentHexEncoded:4e45454453454e4d66726f7d62",
 "QEnvironmentHexEncoded:4e45454453454e43343d6623726f62",
 "QEnvironment:PLAIN=foo",
-"QEnvironmentHexEncoded:4e45454453454e43323d66722a6f62",
-"QEnvironmentHexEncoded:4e45454453454e433d66726f6224",
-"QEnvironment:EQUALS=foo=bar",
 ]
 )
 
@@ -425,12 +425,12 @@ def QEnvironment(self, packet):
 
 self.assertPacketLogContains(
 [
+"QEnvironmentHexEncoded:455155414c533d666f6f3d626172",
+"QEnvironmentHexEncoded:4e45454453454e433d66726f6224",
+"QEnvironmentHexEncoded:4e45454453454e43323d66722a6f62",
 "QEnvironmentHexEncoded:4e45454453454e4d66726f7d62",
 "QEnvironmentHexEncoded:4e45454453454e43343d6623726f62",
 "QEnvironmentHexEncoded:504c41494e3d666f6f",
-"QEnvironmentHexEncoded:4e45454453454e43323d66722a6f62",
-"QEnvironmentHexEncoded:4e45454453454e433d66726f6224",
-"QEnvironmentHexEncoded:455155414c533d666f6f3d626172",
 ]
 )
 



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] e126fa2 - [unittest] Fix HighlighterTest.cpp after D151683

2023-07-22 Thread Fangrui Song via lldb-commits

Author: Fangrui Song
Date: 2023-07-22T18:30:02-07:00
New Revision: e126fa27c07c83997fcdee2bd45996ffc860317b

URL: 
https://github.com/llvm/llvm-project/commit/e126fa27c07c83997fcdee2bd45996ffc860317b
DIFF: 
https://github.com/llvm/llvm-project/commit/e126fa27c07c83997fcdee2bd45996ffc860317b.diff

LOG: [unittest] Fix HighlighterTest.cpp after D151683

:: is now parsed as tok::coloncolon even in C mode.

Added: 


Modified: 
lldb/unittests/Language/Highlighting/HighlighterTest.cpp

Removed: 




diff  --git a/lldb/unittests/Language/Highlighting/HighlighterTest.cpp 
b/lldb/unittests/Language/Highlighting/HighlighterTest.cpp
index d17fddadf96741..150b356efe5955 100644
--- a/lldb/unittests/Language/Highlighting/HighlighterTest.cpp
+++ b/lldb/unittests/Language/Highlighting/HighlighterTest.cpp
@@ -160,7 +160,7 @@ TEST_F(HighlighterTest, Colons) {
   HighlightStyle s;
   s.colon.Set("", "");
 
-  EXPECT_EQ("foo::bar:", highlightC("foo::bar:", s));
+  EXPECT_EQ("foo::bar:", highlightC("foo::bar:", s));
 }
 
 TEST_F(HighlighterTest, ClangBraces) {



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits