[Lldb-commits] [lldb] [LLDB] Remove dead code (NFC) (PR #95713)

2024-06-16 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta created 
https://github.com/llvm/llvm-project/pull/95713

The dead code is caught by PVS studio analyzer -
https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment N12.

Warning message -
V523 The 'then' statement is equivalent to the 'else' statement. Options.cpp 
1212

>From 76b5728a9b938f2b0d689cd20d6ba43c2f0a3bfd Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sun, 16 Jun 2024 22:29:45 +0530
Subject: [PATCH] [LLDB] Remove dead code (NFC)

The dead code is caught by PVS studio analyzer -
https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment N12.

Warning message -
V523 The 'then' statement is equivalent to the 'else' statement. Options.cpp 
1212
---
 lldb/source/Interpreter/Options.cpp | 21 ++---
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/lldb/source/Interpreter/Options.cpp 
b/lldb/source/Interpreter/Options.cpp
index 4e7d074ace1b8..c5e75e0b9dced 100644
--- a/lldb/source/Interpreter/Options.cpp
+++ b/lldb/source/Interpreter/Options.cpp
@@ -1197,21 +1197,12 @@ OptionElementVector Options::ParseForCompletion(const 
Args &args,
 }
 break;
   case OptionParser::eOptionalArgument:
-if (OptionParser::GetOptionArgument() != nullptr) {
-  option_element_vector.push_back(OptionArgElement(
-  opt_defs_index,
-  FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 2],
-args),
-  FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 1],
-args)));
-} else {
-  option_element_vector.push_back(OptionArgElement(
-  opt_defs_index,
-  FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 2],
-args),
-  FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 1],
-args)));
-}
+option_element_vector.push_back(OptionArgElement(
+opt_defs_index,
+FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 2],
+  args),
+FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 1],
+  args)));
 break;
   default:
 // The options table is messed up.  Here we'll just continue

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


[Lldb-commits] [lldb] [LLDB] Remove dead code (NFC) (PR #95713)

2024-06-16 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Shivam Gupta (xgupta)


Changes

The dead code is caught by PVS studio analyzer -
https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment N12.

Warning message -
V523 The 'then' statement is equivalent to the 'else' statement. Options.cpp 
1212

---
Full diff: https://github.com/llvm/llvm-project/pull/95713.diff


1 Files Affected:

- (modified) lldb/source/Interpreter/Options.cpp (+6-15) 


``diff
diff --git a/lldb/source/Interpreter/Options.cpp 
b/lldb/source/Interpreter/Options.cpp
index 4e7d074ace1b8..c5e75e0b9dced 100644
--- a/lldb/source/Interpreter/Options.cpp
+++ b/lldb/source/Interpreter/Options.cpp
@@ -1197,21 +1197,12 @@ OptionElementVector Options::ParseForCompletion(const 
Args &args,
 }
 break;
   case OptionParser::eOptionalArgument:
-if (OptionParser::GetOptionArgument() != nullptr) {
-  option_element_vector.push_back(OptionArgElement(
-  opt_defs_index,
-  FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 2],
-args),
-  FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 1],
-args)));
-} else {
-  option_element_vector.push_back(OptionArgElement(
-  opt_defs_index,
-  FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 2],
-args),
-  FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 1],
-args)));
-}
+option_element_vector.push_back(OptionArgElement(
+opt_defs_index,
+FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 2],
+  args),
+FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 1],
+  args)));
 break;
   default:
 // The options table is messed up.  Here we'll just continue

``




https://github.com/llvm/llvm-project/pull/95713
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Remove dead code (NFC) (PR #95713)

2024-06-16 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere approved this pull request.


https://github.com/llvm/llvm-project/pull/95713
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Remove dead code (NFC) (PR #95713)

2024-06-16 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta closed https://github.com/llvm/llvm-project/pull/95713
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] e4e350e - [LLDB] Remove dead code (NFC) (#95713)

2024-06-16 Thread via lldb-commits

Author: Shivam Gupta
Date: 2024-06-17T09:56:01+05:30
New Revision: e4e350e85b377e424299d26937cc60ea6868900c

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

LOG: [LLDB] Remove dead code (NFC) (#95713)

The dead code is caught by PVS studio analyzer -
https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment N12.

Warning message -
V523 The 'then' statement is equivalent to the 'else' statement.
Options.cpp 1212

Added: 


Modified: 
lldb/source/Interpreter/Options.cpp

Removed: 




diff  --git a/lldb/source/Interpreter/Options.cpp 
b/lldb/source/Interpreter/Options.cpp
index 4e7d074ace1b8..c5e75e0b9dced 100644
--- a/lldb/source/Interpreter/Options.cpp
+++ b/lldb/source/Interpreter/Options.cpp
@@ -1197,21 +1197,12 @@ OptionElementVector Options::ParseForCompletion(const 
Args &args,
 }
 break;
   case OptionParser::eOptionalArgument:
-if (OptionParser::GetOptionArgument() != nullptr) {
-  option_element_vector.push_back(OptionArgElement(
-  opt_defs_index,
-  FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 2],
-args),
-  FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 1],
-args)));
-} else {
-  option_element_vector.push_back(OptionArgElement(
-  opt_defs_index,
-  FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 2],
-args),
-  FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 1],
-args)));
-}
+option_element_vector.push_back(OptionArgElement(
+opt_defs_index,
+FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 2],
+  args),
+FindOriginalIndex(dummy_vec[OptionParser::GetOptionIndex() - 1],
+  args)));
 break;
   default:
 // The options table is messed up.  Here we'll just continue



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


[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-06-16 Thread via lldb-commits

https://github.com/cmtice created 
https://github.com/llvm/llvm-project/pull/95738

…uage (DIL).

The Data Inspection Language (DIL), described in
https://discourse.llvm.org/t/rfc-data-inspection-language/69893 includes its 
own parser and expression evaluator.

This change defines the AST nodes, classes and functions which are used by the 
DIL parser and expression evaluator. It also adds the .ebnf file documenting 
the (current) expression language handled by the DIL parser and expression 
evaluator.

>From c703c473147e3e554a98014319294668a0ec790d Mon Sep 17 00:00:00 2001
From: Caroline Tice 
Date: Sun, 16 Jun 2024 16:32:47 -0700
Subject: [PATCH] [LLDB] Add AST node classes, functions, etc. for Data
 Inspection Language (DIL).

The Data Inspection Language (DIL), described in
https://discourse.llvm.org/t/rfc-data-inspection-language/69893 includes
its own parser and expression evaluator.

This change defines the AST nodes, classes and functions which are used by the
DIL parser and expression evaluator. It also adds the .ebnf file documenting
the (current) expression language handled by the DIL parser and expression
evaluator.
---
 lldb/docs/dil-expr-lang.ebnf| 165 
 lldb/include/lldb/Core/DILAST.h | 690 
 lldb/source/Core/CMakeLists.txt |   1 +
 lldb/source/Core/DILAST.cpp | 568 ++
 4 files changed, 1424 insertions(+)
 create mode 100644 lldb/docs/dil-expr-lang.ebnf
 create mode 100644 lldb/include/lldb/Core/DILAST.h
 create mode 100644 lldb/source/Core/DILAST.cpp

diff --git a/lldb/docs/dil-expr-lang.ebnf b/lldb/docs/dil-expr-lang.ebnf
new file mode 100644
index 0..40c678c25cda5
--- /dev/null
+++ b/lldb/docs/dil-expr-lang.ebnf
@@ -0,0 +1,165 @@
+(* LLDB Debug Expressions, a subset of C++ *)
+(* Insired by https://www.nongnu.org/hcb *)
+
+expression = assignment_expression ;
+
+assignment_expression = conditional_expression
+logical_or_expression assignment_operator 
assignment_expression ;
+
+assignment_operator = "="
+| "*="
+| "/="
+| "%="
+| "+="
+| "-="
+| ">>="
+| "<<="
+| "&="
+| "^="
+| "|=" ;
+
+conditional_expression = logical_or_expression
+   | logical_or_expression "?" expression ":" 
assignment_expression ;
+
+logical_or_expression = logical_and_expression {"||" logical_and_expression} ;
+
+logical_and_expression = inclusive_or_expression {"&&" 
inclusive_or_expression} ;
+
+inclusive_or_expression = exclusive_or_expression {"|" 
exclusive_or_expression} ;
+
+exclusive_or_expression = and_expression {"^" and_expression} ;
+
+and_expression = equality_expression {"&" equality_expression} ;
+
+equality_expression = relational_expression {"==" relational_expression}
+| relational_expression {"!=" relational_expression} ;
+
+relational_expression = shift_expression {"<" shift_expression}
+  | shift_expression {">" shift_expression}
+  | shift_expression {"<=" shift_expression}
+  | shift_expression {">=" shift_expression} ;
+
+shift_expression = additive_expression {"<<" additive_expression}
+ | additive_expression {">>" additive_expression} ;
+
+additive_expression = multiplicative_expression {"+" multiplicative_expression}
+| multiplicative_expression {"-" 
multiplicative_expression} ;
+
+multiplicative_expression = cast_expression {"*" cast_expression}
+  | cast_expression {"/" cast_expression}
+  | cast_expression {"%" cast_expression} ;
+
+cast_expression = unary_expression
+| "(" type_id ")" cast_expression ;
+
+unary_expression = postfix_expression
+ | "++" cast_expression
+ | "--" cast_expression
+ | unary_operator cast_expression
+ | "sizeof" unary_expression
+ | "sizeof" "(" type_id ")" ;
+
+unary_operator = "*" | "&" | "+" | "-" | "!" | "~" ;
+
+postfix_expression = primary_expression
+   | postfix_expression "[" expression "]"
+   | postfix_expression "." id_expression
+   | postfix_expression "->" id_expression
+   | postfix_expression "++"
+   | postfix_expression "--"
+   | static_cast "<" type_id ">" "(" expression ")" ;
+   | dynamic_cast "<" type_id ">" "(" expression ")" ;
+   | reinterpret_cast "<" type_id ">" "(" expression ")" ;
+
+primary_expression = numeric_literal
+   | boolean_literal
+   | pointer_literal
+   | id_expression
+   | "this"
+   | "(" expression ")"
+   | b

[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-06-16 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (cmtice)


Changes

…uage (DIL).

The Data Inspection Language (DIL), described in
https://discourse.llvm.org/t/rfc-data-inspection-language/69893 includes its 
own parser and expression evaluator.

This change defines the AST nodes, classes and functions which are used by the 
DIL parser and expression evaluator. It also adds the .ebnf file documenting 
the (current) expression language handled by the DIL parser and expression 
evaluator.

---

Patch is 50.21 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/95738.diff


4 Files Affected:

- (added) lldb/docs/dil-expr-lang.ebnf (+165) 
- (added) lldb/include/lldb/Core/DILAST.h (+690) 
- (modified) lldb/source/Core/CMakeLists.txt (+1) 
- (added) lldb/source/Core/DILAST.cpp (+568) 


``diff
diff --git a/lldb/docs/dil-expr-lang.ebnf b/lldb/docs/dil-expr-lang.ebnf
new file mode 100644
index 0..40c678c25cda5
--- /dev/null
+++ b/lldb/docs/dil-expr-lang.ebnf
@@ -0,0 +1,165 @@
+(* LLDB Debug Expressions, a subset of C++ *)
+(* Insired by https://www.nongnu.org/hcb *)
+
+expression = assignment_expression ;
+
+assignment_expression = conditional_expression
+logical_or_expression assignment_operator 
assignment_expression ;
+
+assignment_operator = "="
+| "*="
+| "/="
+| "%="
+| "+="
+| "-="
+| ">>="
+| "<<="
+| "&="
+| "^="
+| "|=" ;
+
+conditional_expression = logical_or_expression
+   | logical_or_expression "?" expression ":" 
assignment_expression ;
+
+logical_or_expression = logical_and_expression {"||" logical_and_expression} ;
+
+logical_and_expression = inclusive_or_expression {"&&" 
inclusive_or_expression} ;
+
+inclusive_or_expression = exclusive_or_expression {"|" 
exclusive_or_expression} ;
+
+exclusive_or_expression = and_expression {"^" and_expression} ;
+
+and_expression = equality_expression {"&" equality_expression} ;
+
+equality_expression = relational_expression {"==" relational_expression}
+| relational_expression {"!=" relational_expression} ;
+
+relational_expression = shift_expression {"<" shift_expression}
+  | shift_expression {">" shift_expression}
+  | shift_expression {"<=" shift_expression}
+  | shift_expression {">=" shift_expression} ;
+
+shift_expression = additive_expression {"<<" additive_expression}
+ | additive_expression {">>" additive_expression} ;
+
+additive_expression = multiplicative_expression {"+" multiplicative_expression}
+| multiplicative_expression {"-" 
multiplicative_expression} ;
+
+multiplicative_expression = cast_expression {"*" cast_expression}
+  | cast_expression {"/" cast_expression}
+  | cast_expression {"%" cast_expression} ;
+
+cast_expression = unary_expression
+| "(" type_id ")" cast_expression ;
+
+unary_expression = postfix_expression
+ | "++" cast_expression
+ | "--" cast_expression
+ | unary_operator cast_expression
+ | "sizeof" unary_expression
+ | "sizeof" "(" type_id ")" ;
+
+unary_operator = "*" | "&" | "+" | "-" | "!" | "~" ;
+
+postfix_expression = primary_expression
+   | postfix_expression "[" expression "]"
+   | postfix_expression "." id_expression
+   | postfix_expression "->" id_expression
+   | postfix_expression "++"
+   | postfix_expression "--"
+   | static_cast "<" type_id ">" "(" expression ")" ;
+   | dynamic_cast "<" type_id ">" "(" expression ")" ;
+   | reinterpret_cast "<" type_id ">" "(" expression ")" ;
+
+primary_expression = numeric_literal
+   | boolean_literal
+   | pointer_literal
+   | id_expression
+   | "this"
+   | "(" expression ")"
+   | builtin_func ;
+
+type_id = type_specifier_seq [abstract_declarator] ;
+
+type_specifier_seq = type_specifier [type_specifier_seq] ;
+
+type_specifier = simple_type_specifier
+   | cv_qualifier ;
+
+simple_type_specifier = ["::"] [nested_name_specifier] type_name
+  | "char"
+  | "char16_t"
+  | "char32_t"
+  | "wchar_t"
+  | "bool"
+  | "short"
+  | "int"
+  | "long"
+  | "signed"
+  | "unsigned"
+  | "float"
+  | "double"
+  | "