[Lldb-commits] [PATCH] D136844: [libclang] Expose completion result kind in `CXCompletionResult`

2022-10-30 Thread Egor Zhdan via Phabricator via lldb-commits
egorzhdan updated this revision to Diff 471838.
egorzhdan added a comment.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Fix clangd compilation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136844

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CodeCompletionStrings.cpp
  clang-tools-extra/clangd/Quality.cpp
  clang/include/clang-c/Index.h
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Sema/CodeCompleteConsumer.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/Index/arc-complete.m
  clang/test/Index/code-completion.cpp
  clang/test/Index/complete-at-directives.m
  clang/test/Index/complete-at-exprstmt.m
  clang/test/Index/complete-declarators.cpp
  clang/test/Index/complete-declarators.m
  clang/test/Index/complete-exprs.c
  clang/test/Index/complete-exprs.cpp
  clang/test/Index/complete-exprs.m
  clang/test/Index/complete-lambdas.cpp
  clang/test/Index/complete-lambdas.mm
  clang/test/Index/complete-memfunc-cvquals.cpp
  clang/test/Index/complete-method-decls.m
  clang/test/Index/complete-modules.m
  clang/test/Index/complete-preprocessor.m
  clang/test/Index/complete-recovery.m
  clang/test/Index/complete-stmt.c
  clang/test/Index/complete-super.cpp
  clang/test/Index/complete-synthesized.m
  clang/test/Index/complete-type-factors.m
  clang/tools/c-index-test/c-index-test.c
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CIndexCodeCompletion.cpp
  clang/tools/libclang/libclang.map
  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
@@ -859,15 +859,15 @@
CodeCompletionResult Result) override {
 // This code is mostly copied from CodeCompleteConsumer.
 switch (Result.Kind) {
-case CodeCompletionResult::RK_Declaration:
+case CXCompletionResult_Declaration:
   return !(
   Result.Declaration->getIdentifier() &&
   Result.Declaration->getIdentifier()->getName().startswith(Filter));
-case CodeCompletionResult::RK_Keyword:
+case CXCompletionResult_Keyword:
   return !StringRef(Result.Keyword).startswith(Filter);
-case CodeCompletionResult::RK_Macro:
+case CXCompletionResult_Macro:
   return !Result.Macro->getName().startswith(Filter);
-case CodeCompletionResult::RK_Pattern:
+case CXCompletionResult_Pattern:
   return !StringRef(Result.Pattern->getAsString()).startswith(Filter);
 }
 // If we trigger this assert or the above switch yields a warning, then
@@ -894,7 +894,7 @@
 std::string Description;
 // Handle the different completion kinds that come from the Sema.
 switch (R.Kind) {
-case CodeCompletionResult::RK_Declaration: {
+case CXCompletionResult_Declaration: {
   const NamedDecl *D = R.Declaration;
   ToInsert = R.Declaration->getNameAsString();
   // If we have a function decl that has no arguments we want to
@@ -920,13 +920,13 @@
   }
   break;
 }
-case CodeCompletionResult::RK_Keyword:
+case CXCompletionResult_Keyword:
   ToInsert = R.Keyword;
   break;
-case CodeCompletionResult::RK_Macro:
+case CXCompletionResult_Macro:
   ToInsert = R.Macro->getName().str();
   break;
-case CodeCompletionResult::RK_Pattern:
+case CXCompletionResult_Pattern:
   ToInsert = R.Pattern->getTypedText();
   break;
 }
Index: clang/tools/libclang/libclang.map
===
--- clang/tools/libclang/libclang.map
+++ clang/tools/libclang/libclang.map
@@ -4,6 +4,10 @@
 # On platforms where versions scripts are not used, this file will be used to
 # generate a list of exports for libclang.so
 
+LLVM_15 {
+  global:
+clang_getCompletionResultKindSpelling;
+}
 LLVM_13 {
   global:
 clang_BlockCommandComment_getArgText;
Index: clang/tools/libclang/CIndexCodeCompletion.cpp
===
--- clang/tools/libclang/CIndexCodeCompletion.cpp
+++ clang/tools/libclang/CIndexCodeCompletion.cpp
@@ -586,6 +586,7 @@
   includeBriefComments());
 
 CXCompletionResult R;
+R.ResultKind = Results[I].Kind;
 R.CursorKind = Results[I].CursorKind;
 R.CompletionString = StoredCompletion;
 StoredResults.push_back(R);
@@ -666,6 +667,7 @@
 includeBriefComments(), Braced);
 
 CXCompletionResult R;
+R.ResultKind = CXCompletionResult_Declaration;
 R.CursorKind = CXCursor_Over

[Lldb-commits] [PATCH] D136844: [libclang] Expose completion result kind in `CXCompletionResult`

2022-10-30 Thread Egor Zhdan via Phabricator via lldb-commits
egorzhdan added inline comments.
Herald added subscribers: Michael137, JDevlieghere.



Comment at: clang/include/clang/Sema/CodeCompleteConsumer.h:755
-  /// Describes the kind of result generated.
-  enum ResultKind {
-/// Refers to a declaration.

kadircet wrote:
> i don't follow the reason for replacing this struct with 
> `CXCompletionResultKind` and renaming occurrences in half of the codebase. 
> can we keep this around, introduce the new enum type into `Index.h` and have 
> `clang/tools/libclang/CIndexCodeCompletion.cpp` do the conversion from Sema 
> type to Index type instead?
> 
> Unless I am missing some other requirement for doing so. i feel like the 
> conceptual dependency from Sema to Index is one we should get rid of, rather 
> than make tighter.
This was mostly done to be consistent with the way `CXCursorKind` and 
`CXAvailabilityKind` are declared in `Index.h` and used as fields of 
`CodeCompletionResult`. I think updating the enum name in a few source files 
shouldn't be a major problem, but I can avoid it if you feel strongly against 
this approach.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136844

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


[Lldb-commits] [PATCH] D137045: [lldb] Don't crash when printing static enum members with bool as underlying type

2022-10-30 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks created this revision.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Extends D135169  to work with enums with bool 
as the underlying type.

Fixes #58383.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137045

Files:
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  
lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
  lldb/test/API/lang/cpp/const_static_integral_member/main.cpp


Index: lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
===
--- lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
+++ lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
@@ -5,6 +5,11 @@
   enum_case2 = 2,
 };
 
+enum EnumBool : bool {
+  enum_bool_case1 = false,
+  enum_bool_case2 = true,
+};
+
 enum class ScopedEnum {
   scoped_enum_case1 = 1,
   scoped_enum_case2 = 2,
@@ -51,6 +56,7 @@
   const static auto wchar_min = std::numeric_limits::min();
 
   const static Enum enum_val = enum_case2;
+  const static EnumBool enum_bool_val = enum_bool_case2;
   const static ScopedEnum scoped_enum_val = ScopedEnum::scoped_enum_case2;
   const static ScopedEnum not_enumerator_scoped_enum_val = 
static_cast(5);
   const static ScopedEnum not_enumerator_scoped_enum_val_2 =
Index: 
lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
===
--- 
lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
+++ 
lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
@@ -57,6 +57,8 @@
 
 # Test an unscoped enum.
 self.expect_expr("A::enum_val", result_value="enum_case2")
+# Test an unscoped enum with bool as the underlying type.
+self.expect_expr("A::enum_bool_val", result_value="enum_bool_case2")
 
 # Test a scoped enum.
 self.expect_expr("A::scoped_enum_val", 
result_value="scoped_enum_case2")
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3234,6 +3234,14 @@
   const clang::BuiltinType *builtin_type =
   
llvm::dyn_cast(qual_type->getCanonicalTypeInternal());
 
+  if (!builtin_type) {
+if (const clang::EnumType *enum_type = llvm::dyn_cast(
+qual_type->getCanonicalTypeInternal())) {
+  builtin_type = llvm::dyn_cast(
+  enum_type->getDecl()->getIntegerType());
+}
+  }
+
   if (!builtin_type)
 return false;
 
@@ -7597,7 +7605,11 @@
   assert(!var->hasInit() && "variable already initialized");
 
   QualType qt = var->getType();
-  assert(qt->isSpecificBuiltinType(BuiltinType::Bool) &&
+  assert((qt->isSpecificBuiltinType(BuiltinType::Bool) ||
+  cast(qt)
+  ->getDecl()
+  ->getIntegerType()
+  ->isSpecificBuiltinType(BuiltinType::Bool)) &&
  "only boolean supported");
 
   clang::ASTContext &ast = var->getASTContext();


Index: lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
===
--- lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
+++ lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
@@ -5,6 +5,11 @@
   enum_case2 = 2,
 };
 
+enum EnumBool : bool {
+  enum_bool_case1 = false,
+  enum_bool_case2 = true,
+};
+
 enum class ScopedEnum {
   scoped_enum_case1 = 1,
   scoped_enum_case2 = 2,
@@ -51,6 +56,7 @@
   const static auto wchar_min = std::numeric_limits::min();
 
   const static Enum enum_val = enum_case2;
+  const static EnumBool enum_bool_val = enum_bool_case2;
   const static ScopedEnum scoped_enum_val = ScopedEnum::scoped_enum_case2;
   const static ScopedEnum not_enumerator_scoped_enum_val = static_cast(5);
   const static ScopedEnum not_enumerator_scoped_enum_val_2 =
Index: lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
===
--- lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
+++ lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
@@ -57,6 +57,8 @@
 
 # Test an unscoped enum.
 self.expect_expr("A::enum_val", result_value="enum_case2")
+# Test an unscoped enum with bool as the underlying type.
+self.expect_expr("A::enum_bool_val", result_value="enum_bool_case2")
 
 # Test a scoped enum.
 self.expect_expr("A::scoped_enum_val", result_value="scoped_enum_case2")
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
==

[Lldb-commits] [PATCH] D136362: [LLDB][RISCV] Add RV64C instruction support for EmulateInstructionRISCV

2022-10-30 Thread Tiezhu Yang via Phabricator via lldb-commits
seehearfeel added a comment.

I can reproduce this issue on x86_64 used with the latest gcc.

(1) Install Fedora36
https://download.fedoraproject.org/pub/fedora/linux/releases/36/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-36-1.5.iso

$ uname -a
Linux fedora 5.17.5-300.fc36.x86_64 #1 SMP PREEMPT Thu Apr 28 15:51:30 UTC 2022 
x86_64 x86_64 x86_64 GNU/Linux

(2) Install some packages
sudo yum -y install llvm clang g++ cmake ninja-build bison flex texinfo

$ gcc --version
gcc (GCC) 12.2.1 20220819 (Red Hat 12.2.1-2)
$ c++ --version
c++ (GCC) 12.2.1 20220819 (Red Hat 12.2.1-2)
$ clang --version
clang version 14.0.5 (Fedora 14.0.5-1.fc36)
$ clang++ --version
clang version 14.0.5 (Fedora 14.0.5-1.fc36)

(3) Build llvm

  git clone https://github.com/llvm/llvm-project.git
  mkdir -p llvm-project/llvm/build
  cd llvm-project/llvm/build
  cmake .. -G "Ninja" -DLLVM_TARGETS_TO_BUILD="X86" \
   -DLLVM_ENABLE_PROJECTS="clang;lldb" \
   -DCMAKE_BUILD_TYPE=Release \
   -DLLVM_BUILD_RUNTIME=OFF
  ninja
  ninja check-lldb

This is OK used with gcc/c++ 12.

(4) Update gcc to the latest version
git clone git://gcc.gnu.org/git/gcc.git
cd gcc
./contrib/download_prerequisites
mkdir -p build
cd build
../configure --prefix=/usr/local/gcc --enable-checking=release 
--enable-languages=c,c++ --disable-multilib
make
sudo make install
export PATH=/usr/local/gcc/bin/:$PATH
export LD_LIBRARY_PATH=/usr/local/gcc/lib64:$LD_LIBRARY_PATH

$ gcc --version
gcc (GCC) 13.0.0 20221029 (experimental)
$ c++ --version
c++ (GCC) 13.0.0 20221029 (experimental)

(5) Do the above (3) again used with gcc/c++ 13

  git clone https://github.com/llvm/llvm-project.git
  mkdir -p llvm-project/llvm/build
  cd llvm-project/llvm/build
  cmake .. -G "Ninja" -DLLVM_TARGETS_TO_BUILD="X86" \
   -DLLVM_ENABLE_PROJECTS="clang;lldb" \
   -DCMAKE_BUILD_TYPE=Release \
   -DLLVM_BUILD_RUNTIME=OFF \
   -DCMAKE_C_COMPILER="/usr/local/gcc/bin/gcc" \
   -DCMAKE_CXX_COMPILER="/usr/local/gcc/bin/c++"
  ninja
  ninja check-lldb

We can see that "ninja check-lldb" failed due to OOM
used with gcc/c++ 13.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136362

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