[Lldb-commits] [PATCH] D129078: [LLDB][ClangExpression] Allow expression evaluation from within C++ Lambdas

2022-07-17 Thread Michael Buch via Phabricator via lldb-commits
Michael137 updated this revision to Diff 445307.
Michael137 added a comment.

- Remove redundant moves


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129078

Files:
  lldb/include/lldb/Expression/Materializer.h
  lldb/include/lldb/Expression/UserExpression.h
  lldb/include/lldb/lldb-private-types.h
  lldb/source/Expression/Materializer.cpp
  lldb/source/Expression/UserExpression.cpp
  lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionUtil.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionUtil.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
  lldb/test/API/commands/expression/expr_inside_lambda/Makefile
  lldb/test/API/commands/expression/expr_inside_lambda/TestExprInsideLambdas.py
  lldb/test/API/commands/expression/expr_inside_lambda/main.cpp
  lldb/test/API/functionalities/breakpoint/breakpoint_on_lambda_capture/Makefile
  
lldb/test/API/functionalities/breakpoint/breakpoint_on_lambda_capture/TestBreakOnLambdaCapture.py
  lldb/test/API/functionalities/breakpoint/breakpoint_on_lambda_capture/main.cpp

Index: lldb/test/API/functionalities/breakpoint/breakpoint_on_lambda_capture/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/breakpoint_on_lambda_capture/main.cpp
@@ -0,0 +1,32 @@
+#include 
+#include 
+#include 
+
+struct Foo {
+  bool enable = true;
+  uint32_t offset = 0;
+
+  void usleep_helper(uint32_t usec) {
+[this, &usec] {
+  puts("Break here in the helper");
+  std::this_thread::sleep_for(
+  std::chrono::duration(offset + usec));
+}();
+  }
+};
+
+void *background_thread(void *) {
+  Foo f;
+  for (;;) {
+f.usleep_helper(2);
+  }
+}
+
+int main() {
+  std::puts("First break");
+  std::thread main_thread(background_thread, nullptr);
+  Foo f;
+  for (;;) {
+f.usleep_helper(1);
+  }
+}
Index: lldb/test/API/functionalities/breakpoint/breakpoint_on_lambda_capture/TestBreakOnLambdaCapture.py
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/breakpoint_on_lambda_capture/TestBreakOnLambdaCapture.py
@@ -0,0 +1,54 @@
+"""
+Test that if we hit a breakpoint on a lambda capture
+on two threads at the same time we stop only for
+the correct one.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+
+class TestBreakOnLambdaCapture(TestBase):
+
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_break_on_lambda_capture(self):
+self.build()
+self.main_source_file = lldb.SBFileSpec("main.cpp")
+
+(target, process, main_thread, _) = lldbutil.run_to_source_breakpoint(self,
+"First break", self.main_source_file)
+
+# FIXME: This is working around a separate bug. If you hit a breakpoint and
+# run an expression and it is the first expression you've ever run, on
+# Darwin that will involve running the ObjC runtime parsing code, and we'll
+# be in the middle of that when we do PerformAction on the other thread,
+# which will cause the condition expression to fail.  Calling another
+# expression first works around this.
+val_obj = main_thread.frame[0].EvaluateExpression("true")
+self.assertSuccess(val_obj.GetError(), "Ran our expression successfully")
+self.assertEqual(val_obj.value, "true", "Value was true.")
+
+bkpt = target.BreakpointCreateBySourceRegex("Break here in the helper",
+self.main_source_file);
+
+bkpt.SetCondition("enable && usec == 1")
+process.Continue()
+
+# This is hard to test definitively, becuase it requires hitting
+# a breakpoint on multiple threads at the same time.  On Darwin, this
+# will happen pretty much ever time we continue.  What we are really
+# asserting is that we only ever stop on one thread, so we approximate that
+# by continuing 20 times and assert we only ever hit the first thread.  Either
+# this is a platform that only reports one hit at a time, in which case all
+# this code is unused, or we actually didn't hit the other thread.
+
+for idx in range(0, 20):
+process.Continue()
+for th

[Lldb-commits] [PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-07-17 Thread Kim Gräsman via Phabricator via lldb-commits
kimgr added a comment.

In D112374#3657640 , @mizvekov wrote:

> In D112374#3657472 , @kimgr wrote:
>
>> I'm coming at this from pretty far away, so there's very likely lots of 
>> details that I'm overlooking. But it seems to me the mainline had only had 
>> an `ElaboratedType` node if there was elaboration, and not otherwise. And 
>> that makes a lot more sense to me than having 2 `ElaboratedType*` nodes _for 
>> every type in the AST_, just to express that "hey, by the way, this type had 
>> no elaboration".
>
> There are no 2 `ElaboratedType` nodes, there is only one. If you are seeing 
> something like an ElaboratedType wrapping directly over another 
> ElaboratedType, that would seem to be a bug.

I meant the `ElaboratedTypeLoc` + `ElaboratedType`, but yeah, those are 
parallel, not nested.

>> That sounds good at face value, but if you're planning to remove these nodes 
>> again, that would create enormous churn for out-of-tree tools to re-adjust 
>> to the new shape of the tree.
>>
>> I can't say what the best solution is, but this patch generates quite a lot 
>> of work for me, and I would really hope that catching up with the new AST 
>> does not generate even more work down the line.
>
> That part I don't understand why. Before this patch, clang can produce a 
> bunch of type nodes wrapped in an ElTy, or not. After this patch, we add 
> ElTys in more cases, but the basic situation remains the same.
>
> Why IWYU would even care about ElaboratedTypes at all? I would have expected 
> a `git grep ElaboratedType` on IWYU sources to have no matches.
>
> Can you elaborate on that?

Haha. Pun intended? :-)

> In general, I would not expect external tools to care about the shape of the 
> AST. I would expect the type API would be used in a way where we ignore a 
> type sugar node we have no reason to acknowledge.
> Ie you query if some type is a (possible sugar to) X, and you would either 
> get X or nothing. The type sugar over it would just be skipped over and you 
> would have no reason to know what was in there or what shape it had.
>
> Of course that was not what happened in practice. A lot of code used 
> `dyn_cast` where it should have used `getAs`. Just look at all the fixes in 
> this patch for examples.
> And fixing that, besides making that code compatible with this patch, also 
> fixed other bugs where it would not properly ignore other pre-existing type 
> sugar.

As you noticed, it's not our tests that care about the AST, it's the tool 
itself. IWYU has been around since 2010-11, so there's probably lots of code in 
there to work around bugs and idiosyncrasies in the Clang AST that have since 
been fixed. I've inherited the project, so I don't have much information on how 
or why the implementation ended up the way it did.

Anyway, thanks for the heads-up about `getAs` vs `dyn_cast`, that seems like an 
easy transformation for us to do. Though I'm not sure where -- everywhere a 
`Type*` is processed?

Also, I suspect we have a few open-ended searches where we're looking for the 
first desugared type in the tree, but I guess that's where `getCanonicalType` 
would be used?

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

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


[Lldb-commits] [PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-07-17 Thread Matheus Izvekov via Phabricator via lldb-commits
mizvekov added a comment.

In D112374#3658059 , @kimgr wrote:

> Haha. Pun intended? :-)

Yes :-)

> As you noticed, it's not our tests that care about the AST, it's the tool 
> itself. IWYU has been around since 2010-11, so there's probably lots of code 
> in there to work around bugs and idiosyncrasies in the Clang AST that have 
> since been fixed. I've inherited the project, so I don't have much 
> information on how or why the implementation ended up the way it did.
>
> Anyway, thanks for the heads-up about `getAs` vs `dyn_cast`, that seems like 
> an easy transformation for us to do. Though I'm not sure where -- everywhere 
> a `Type*` is processed?
>
> Also, I suspect we have a few open-ended searches where we're looking for the 
> first desugared type in the tree, but I guess that's where `getCanonicalType` 
> would be used?

I think for IWYU getCanonicalType could be problematic. It would be fine for 
quickly testing what kind of node you have under all that sugar and such, but 
if for example you try to get a Decl represented by some canonical type, you 
would likely get a canonical decl, but it seems to me that would not be useful 
because you might need to know the exact (re)-declaration used, which has 
source location information and you could pin down to a specific file.

There is `getDesugaredType`, which will just pull off all top level sugar 
without really canonicalizing the whole thing.

If instead you want to search down a type for the first thing of interest, then 
you can in that case have a main switch case on the type class, or even perhaps 
keep an if else chain of dyn_casts, but on your default or else case you could 
just test that the current type node is sugar with `getSingleStepDesugaredType` 
on it, see if you get a different result and try again with it in that case.
That way this mechanism does not get poisoned by clang introducing some new 
type sugar, which could not even be relevant to IWYU.

> Thanks!

Thank you for your patience as well, and sorry for the trouble!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

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


[Lldb-commits] [PATCH] D129962: [LLDB][DataFormatter] Add support for std::__map_const_iterator

2022-07-17 Thread Michael Buch via Phabricator via lldb-commits
Michael137 created this revision.
Michael137 added reviewers: aprantl, jingham.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This patch adds support for formatting `std::map::const_iterator`.
It's just a matter of adding `const_` to the existing regex.

**Testing**

- Added test case to existing API tests


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129962

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp


Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp
@@ -24,7 +24,12 @@
 
 ii[0] = 0; // Set break point at this line.
 ii[1] = 1;
-   thefoo_rw(1);  // Set break point at this line.
+
+intint_map::iterator it = ii.begin();
+intint_map::const_iterator const_it = ii.cbegin();
+std::printf("%d %d", it->second, const_it->second);
+
+thefoo_rw(1); // Set break point at this line.
 ii[2] = 0;
 ii[3] = 1;
thefoo_rw(1);  // Set break point at this line.
Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
@@ -116,6 +116,16 @@
 substrs=['first =',
  'second ='])
 
+# (Non-)const key/val iterators
+self.expect_expr("it", result_children=[
+ValueCheck(name="first", value="0"),
+ValueCheck(name="second", value="0")
+])
+self.expect_expr("const_it", result_children=[
+ValueCheck(name="first", value="0"),
+ValueCheck(name="second", value="0")
+])
+
 # check that MightHaveChildren() gets it right
 self.assertTrue(
 self.frame().FindVariable("ii").MightHaveChildren(),
Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -909,7 +909,7 @@
   cpp_category_sp,
   lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEndCreator,
   "std::map iterator synthetic children",
-  ConstString("^std::__[[:alnum:]]+::__map_iterator<.+>$"), 
stl_synth_flags,
+  ConstString("^std::__[[:alnum:]]+::__map_(const_)?iterator<.+>$"), 
stl_synth_flags,
   true);
 
   AddCXXSynthetic(


Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp
@@ -24,7 +24,12 @@
 
 ii[0] = 0; // Set break point at this line.
 ii[1] = 1;
-	thefoo_rw(1);  // Set break point at this line.
+
+intint_map::iterator it = ii.begin();
+intint_map::const_iterator const_it = ii.cbegin();
+std::printf("%d %d", it->second, const_it->second);
+
+thefoo_rw(1); // Set break point at this line.
 ii[2] = 0;
 ii[3] = 1;
 	thefoo_rw(1);  // Set break point at this line.
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
@@ -116,6 +116,16 @@
 substrs=['first =',
  'second ='])
 
+# (Non-)const key/val iterators
+self.expect_expr("it", result_children=[
+ValueCheck(name="first", value="0"),
+ValueCheck(name="second", value="0")
+])
+self.expect_expr("const_it", result_children=[
+ValueCheck(name="first", value="0"),
+ValueCheck(name="second", value="0")
+])
+
 # check that MightHaveChildren() gets it right
 self.assertTrue(
 self.frame().FindVariable("ii").MightHaveChildren(),
I

[Lldb-commits] [PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-07-17 Thread Matheus Izvekov via Phabricator via lldb-commits
mizvekov edited the summary of this revision.
mizvekov updated this revision to Diff 445319.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

Files:
  clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
  clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp
  clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp
  clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
  clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/ASTTests.cpp
  clang-tools-extra/clangd/unittests/DumpASTTests.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone/copy-constructor-init.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/shared-ptr-array-mismatch.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-memory-comparison-32bits.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-memory-comparison.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
  clang-tools-extra/unittests/clang-change-namespace/ChangeNamespaceTests.cpp
  clang/bindings/python/tests/cindex/test_type.py
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/lib/ARCMigrate/ObjCMT.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTDiagnostic.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/FormatString.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/QualTypeNames.cpp
  clang/lib/AST/ScanfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Analysis/RetainSummaryManager.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Sema/TypeLocBuilder.cpp
  clang/lib/Sema/TypeLocBuilder.h
  clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/test/AST/ast-dump-APValue-anon-union.cpp
  clang/test/AST/ast-dump-APValue-struct.cpp
  clang/test/AST/ast-dump-APValue-union.cpp
  clang/test/AST/ast-dump-decl.cpp
  clang/test/AST/ast-dump-expr-json.cpp
  clang/test/AST/ast-dump-expr.cpp
  clang/test/AST/ast-dump-funcs.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
  clang/test/AST/ast-dump-overloaded-operators.cpp
  clang/test/AST/ast-dump-records-json.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/AST/ast-dump-stmt-json.cpp
  clang/test/AST/ast-dump-stmt.cpp
  clang/test/AST/ast-dump-template-decls-json.cpp
  clang/test/AST/ast-dump-temporaries-json.cpp
  clang/test/AST/ast-dump-using-template.cpp
  clang/test/AST/ast-dump-using.cpp
  clang/test/AST/coroutine-locals-cleanup-exp-namespace.cpp
  clang/test/AST/coroutine-locals-cleanup.cpp
  clang/test/AST/float16.cpp
  clang/test/AST/sourceranges.cpp
  clang/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
  clang/test/Analysis/Inputs/expected-plists/cxx-for-range.cpp.plist
  clang/test/Analysis/Inputs/expected-plists/method-call-path-notes.cpp.plist
  clang/test/Analysis/analyzer-display-progress.cpp
  clang/test/Analysis/auto-obj-dtors-cfg-output.cpp
  clang/test/Analysis/blocks.mm
  clang/test/Analysis/bug_hash_test.cpp
  clang/test/Analysis/cast-value-notes.cpp
  clang/test/Analysis/cast-value-state-dump.cpp
  clang/test/Analysis/cfg-rich-constructors.cpp
  clang/test/Analysis/cfg-rich-constructors.mm
  clang/test/Analysis/cfg.cpp
  clang/test/Analysis/copy-elision.cpp
  clang/test/Analysis/cxx-uninitialized-object-inheritance.cpp
  clang/test/Analysis/dump_egraph.cpp
  clang/test/Analysis/exploded-graph-rewriter/dynamic_types.cpp
  clang/test/Analysis/initializers-cfg-output.cpp
  clang/test/Analysis/inlining/Inputs/expected-plists/path-notes.cpp.plist
  clang/test/Analysis/lambdas.cpp
  clang/test/Analysis/lifetime-cfg-ou

[Lldb-commits] [PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-07-17 Thread Matheus Izvekov via Phabricator via lldb-commits
mizvekov marked an inline comment as done.
mizvekov added inline comments.



Comment at: clang/lib/Sema/TypeLocBuilder.cpp:159
 
-  assert(Capacity - Index == TypeLoc::getFullDataSizeForType(T) &&
+  unsigned FDSz = TypeLoc::getFullDataSizeForType(T);
+  assert(Capacity - Index == FDSz &&

chapuni wrote:
> It causes a warning with -Asserts. May be rolled back.
Thanks! fixed in latest rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

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


[Lldb-commits] [lldb] 8b3ed1f - Remove redundant return statements (NFC)

2022-07-17 Thread Kazu Hirata via lldb-commits

Author: Kazu Hirata
Date: 2022-07-17T15:37:46-07:00
New Revision: 8b3ed1fa984b07c88f218d0ddc6b3e2c0629a9fa

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

LOG: Remove redundant return statements (NFC)

Identified with readability-redundant-control-flow.

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp
flang/lib/Frontend/TextDiagnosticPrinter.cpp
flang/lib/Lower/Allocatable.cpp
flang/lib/Lower/ConvertType.cpp
flang/lib/Optimizer/Transforms/AffinePromotion.cpp
flang/lib/Semantics/check-directive-structure.h
lldb/include/lldb/Symbol/SymbolFile.h
llvm/lib/Transforms/Scalar/LoopInterchange.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index c04186dea43eb..0b4c450f76e0d 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -19721,7 +19721,6 @@ class EvaluatedExprMarker : public 
UsedDeclVisitor {
   void VisitConstantExpr(ConstantExpr *E) {
 // Don't mark declarations within a ConstantExpression, as this expression
 // will be evaluated and folded to a value.
-return;
   }
 
   void VisitDeclRefExpr(DeclRefExpr *E) {

diff  --git a/flang/lib/Frontend/TextDiagnosticPrinter.cpp 
b/flang/lib/Frontend/TextDiagnosticPrinter.cpp
index 5ee4122af1053..12c41d77ba467 100644
--- a/flang/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/flang/lib/Frontend/TextDiagnosticPrinter.cpp
@@ -56,5 +56,4 @@ void TextDiagnosticPrinter::HandleDiagnostic(
   diagMessageStream.str(), diagOpts->ShowColors);
 
   os.flush();
-  return;
 }

diff  --git a/flang/lib/Lower/Allocatable.cpp b/flang/lib/Lower/Allocatable.cpp
index 01a13b8555fa8..08a90f168 100644
--- a/flang/lib/Lower/Allocatable.cpp
+++ b/flang/lib/Lower/Allocatable.cpp
@@ -500,7 +500,6 @@ void Fortran::lower::genAllocateStmt(
 Fortran::lower::AbstractConverter &converter,
 const Fortran::parser::AllocateStmt &stmt, mlir::Location loc) {
   AllocateStmtHelper{converter, stmt, loc}.lower();
-  return;
 }
 
 
//===--===//

diff  --git a/flang/lib/Lower/ConvertType.cpp b/flang/lib/Lower/ConvertType.cpp
index 0ab9d2d1b48e0..772c8508b7c05 100644
--- a/flang/lib/Lower/ConvertType.cpp
+++ b/flang/lib/Lower/ConvertType.cpp
@@ -368,7 +368,6 @@ struct TypeBuilder {
   params.push_back(getCharacterLength(exprOrSym));
 else if (category == Fortran::common::TypeCategory::Derived)
   TODO(converter.getCurrentLocation(), "derived type length parameters");
-return;
   }
   Fortran::lower::LenParameterTy
   getCharacterLength(const Fortran::semantics::Symbol &symbol) {

diff  --git a/flang/lib/Optimizer/Transforms/AffinePromotion.cpp 
b/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
index c6df98769a64b..90b4364866c96 100644
--- a/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
+++ b/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
@@ -242,7 +242,6 @@ struct AffineIfCondition {
 integerSet = mlir::IntegerSet::get(dimCount, symCount,
{constraintPair.getValue().first},
{constraintPair.getValue().second});
-return;
   }
 
   llvm::Optional>
@@ -392,7 +391,6 @@ static void populateIndexArgs(fir::ArrayCoorOp acoOp,
 return populateIndexArgs(acoOp, shapeShift, indexArgs, rewriter);
   if (auto slice = acoOp.getShape().getDefiningOp())
 return populateIndexArgs(acoOp, slice, indexArgs, rewriter);
-  return;
 }
 
 /// Returns affine.apply and fir.convert from array_coor and gendims

diff  --git a/flang/lib/Semantics/check-directive-structure.h 
b/flang/lib/Semantics/check-directive-structure.h
index 6444e839967df..3fdcbf2b88ec4 100644
--- a/flang/lib/Semantics/check-directive-structure.h
+++ b/flang/lib/Semantics/check-directive-structure.h
@@ -142,7 +142,6 @@ template  class NoBranchingEnforce {
 // did not found an enclosing looping construct within the OpenMP/OpenACC
 // directive
 EmitUnlabelledBranchOutError(stmt);
-return;
   }
 
   SemanticsContext &context_;

diff  --git a/lldb/include/lldb/Symbol/SymbolFile.h 
b/lldb/include/lldb/Symbol/SymbolFile.h
index 1470b96f24917..ed0de1b5bce6b 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -132,7 +132,7 @@ class SymbolFile : public PluginInterface {
   /// Specify debug info should be loaded.
   ///
   /// It will be no-op for most implementations except SymbolFileOnDemand.
-  virtual void SetLoadDebugInfoEnabled() { return; }
+  virtual void SetLoadDebugInfoEnabled() {}
 
   // Compile Unit function calls
   // Approach 1 - iterator

diff  --git a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp 
b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
index 1d302

[Lldb-commits] [PATCH] D111509: [clang] use getCommonSugar in an assortment of places

2022-07-17 Thread Matheus Izvekov via Phabricator via lldb-commits
mizvekov updated this revision to Diff 445365.
mizvekov marked 2 inline comments as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111509

Files:
  clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/narrowing-conversions-ignoreconversionfromtypes-option.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/AST/ast-dump-fpfeatures.cpp
  clang/test/CodeGen/compound-assign-overflow.c
  clang/test/Sema/matrix-type-operators.c
  clang/test/Sema/nullability.c
  clang/test/Sema/sugar-common-types.c
  clang/test/SemaCXX/matrix-type-operators.cpp
  clang/test/SemaCXX/sugar-common-types.cpp
  clang/test/SemaCXX/sugared-auto.cpp
  clang/test/SemaObjC/format-strings-objc.m
  compiler-rt/test/ubsan/TestCases/Integer/add-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/no-recover.cpp
  compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
  libcxx/DELETE.ME

Index: libcxx/DELETE.ME
===
--- libcxx/DELETE.ME
+++ libcxx/DELETE.ME
@@ -1 +1,2 @@
 D111283
+D111509
Index: compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
@@ -12,12 +12,12 @@
 
 #ifdef SUB_I32
   (void)(uint32_t(1) - uint32_t(2));
-  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type 'unsigned int'
+  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 #endif
 
 #ifdef SUB_I64
   (void)(uint64_t(800ll) - uint64_t(900ll));
-  // CHECK-SUB_I64: 800 - 900 cannot be represented in type 'unsigned {{long( long)?}}'
+  // CHECK-SUB_I64: 800 - 900 cannot be represented in type '{{uint64_t|unsigned long( long)?}}'
 #endif
 
 #ifdef SUB_I128
@@ -26,6 +26,6 @@
 # else
   puts("__int128 not supported\n");
 # endif
-  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type 'unsigned __int128'|__int128 not supported}}
+  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type '__uint128_t'|__int128 not supported}}
 #endif
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
@@ -13,7 +13,7 @@
   (void)(uint16_t(0x) * uint16_t(0x8001));
 
   (void)(uint32_t(0x) * uint32_t(0x2));
-  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type 'unsigned int'
+  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 
   return 0;
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
@@ -18,7 +18,7 @@
 
 #ifdef ADD_I64
   (void)(uint64_t(1000ull) + uint64_t(900ull));
-  // CHECK-ADD_I64: 1000 + 900 cannot be represented in type 'unsigned {{long( long)?}}'
+  // CHECK-ADD_I64: 1000 + 900 cannot be represented in type '{{uint64_t|unsigned long( long)?}}'
 #endif
 
 #ifdef ADD_I128
@@ -27,6 +27,6 @@
 # else
   puts("__int128 not supported");
 # endif
-  // CHECK-ADD_I128: {{0x8000 \+ 0x8000 cannot be represented in type 'unsigned __int128'|__int128 not supported}}
+  // CHECK-ADD_I128: {{0x8000 \+ 0x8000 cannot be represented in type '__uint128_t'|__int128 not supported}}
 #endif
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
@@ -12,12 +12,12 @@
 
 #ifdef SUB_I32
   (void)(int32_t(-2) - int32_t(0x7fff));
-  // CHECK-SUB_I32: sub-overflow