Remove redundant return and continue statements (NFC)
authorKazu Hirata <kazu@google.com>
Sat, 25 Dec 2021 07:17:53 +0000 (23:17 -0800)
committerKazu Hirata <kazu@google.com>
Sat, 25 Dec 2021 07:17:54 +0000 (23:17 -0800)
Identified with readability-redundant-control-flow.

41 files changed:
clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.h
clang/lib/Analysis/CFG.cpp
clang/lib/Basic/Targets/PPC.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenAction.cpp
clang/lib/Driver/ToolChains/HIPAMD.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/lib/Sema/SemaCUDA.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Sema/SemaType.cpp
clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
lldb/include/lldb/Core/ValueObject.h
lldb/include/lldb/Target/LanguageRuntime.h
lldb/include/lldb/Utility/RangeMap.h
lldb/source/Core/IOHandlerCursesGUI.cpp
lldb/source/Expression/IRExecutionUnit.cpp
lldb/source/Expression/IRMemoryMap.cpp
lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/source/Symbol/SymbolFile.cpp
lldb/source/Target/ThreadPlanStack.cpp
lldb/source/Target/UnwindLLDB.cpp
llvm/examples/OrcV2Examples/OrcV2CBindingsVeryLazy/OrcV2CBindingsVeryLazy.c
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
llvm/lib/IR/Instructions.cpp
llvm/lib/Target/AMDGPU/AMDGPUCombinerHelper.cpp
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
llvm/lib/Target/AVR/AVRInstrInfo.cpp
polly/lib/External/isl/isl_int_sioimath.h
polly/lib/Transform/ManualOptimizer.cpp

index aa839be..c9f3a7d 100644 (file)
@@ -221,7 +221,6 @@ void DurationFactoryScaleCheck::check(const MatchFinder::MatchResult &Result) {
                 tooling::fixit::getText(*Remainder, *Result.Context) + ")")
                    .str());
   }
-  return;
 }
 
 } // namespace abseil
index 42b6970..842bf43 100644 (file)
@@ -41,7 +41,6 @@ void ImplementationInNamespaceCheck::check(
   diag(MatchedDecl->getLocation(),
        "declaration must be declared within the '%0' namespace")
       << RequiredNamespace;
-  return;
 }
 
 } // namespace llvm_libc
index 783fb20..fa9d422 100644 (file)
@@ -1035,7 +1035,6 @@ public:
   void getArgKinds(ASTNodeKind ThisKind, unsigned,
                    std::vector<ArgKind> &ArgKinds) const override {
     ArgKinds.push_back(ArgKind::MakeNodeArg(ThisKind));
-    return;
   }
   bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity = nullptr,
                        ASTNodeKind *LeastDerivedKind = nullptr) const override {
index abf65e3..9ef3b5b 100644 (file)
@@ -1820,8 +1820,6 @@ void CFGBuilder::addScopesEnd(LocalScope::const_iterator B,
 
   for (VarDecl *VD : llvm::reverse(DeclsWithEndedScope))
     appendScopeEnd(Block, VD, S);
-
-  return;
 }
 
 /// addAutomaticObjDtors - Add to current block automatic objects destructors
index c3c61ed..7f7b44b 100644 (file)
@@ -623,14 +623,11 @@ void PPCTargetInfo::addP10SpecificFeatures(
   Features["pcrelative-memops"] = true;
   Features["prefix-instrs"] = true;
   Features["isa-v31-instructions"] = true;
-  return;
 }
 
 // Add features specific to the "Future" CPU.
 void PPCTargetInfo::addFutureSpecificFeatures(
-    llvm::StringMap<bool> &Features) const {
-  return;
-}
+    llvm::StringMap<bool> &Features) const {}
 
 bool PPCTargetInfo::hasFeature(StringRef Feature) const {
   return llvm::StringSwitch<bool>(Feature)
index 564c3a5..4c11f7d 100644 (file)
@@ -4301,10 +4301,10 @@ public:
           PrivateDecls.push_back(VD);
     }
   }
-  void VisitOMPExecutableDirective(const OMPExecutableDirective *) { return; }
-  void VisitCapturedStmt(const CapturedStmt *) { return; }
-  void VisitLambdaExpr(const LambdaExpr *) { return; }
-  void VisitBlockExpr(const BlockExpr *) { return; }
+  void VisitOMPExecutableDirective(const OMPExecutableDirective *) {}
+  void VisitCapturedStmt(const CapturedStmt *) {}
+  void VisitLambdaExpr(const LambdaExpr *) {}
+  void VisitBlockExpr(const BlockExpr *) {}
   void VisitStmt(const Stmt *S) {
     if (!S)
       return;
index 52c54d3..b72b16c 100644 (file)
@@ -571,7 +571,6 @@ void BackendConsumer::SrcMgrDiagHandler(const llvm::DiagnosticInfoSrcMgr &DI) {
   // If Loc is invalid, we still need to report the issue, it just gets no
   // location info.
   Diags.Report(Loc, DiagID).AddString(Message);
-  return;
 }
 
 bool
index c08f825..6d55379 100644 (file)
@@ -365,5 +365,4 @@ void HIPAMDToolChain::checkTargetID(
     getDriver().Diag(clang::diag::err_drv_bad_target_id)
         << PTID.OptionalTargetID.getValue();
   }
-  return;
 }
index 4f300bb..b6e55aa 100644 (file)
@@ -1138,7 +1138,6 @@ void UnwrappedLineParser::parseModuleImport() {
   }
 
   addUnwrappedLine();
-  return;
 }
 
 // readTokenWithJavaScriptASI reads the next token and terminates the current
index 840b3da..59601c5 100644 (file)
@@ -886,7 +886,6 @@ void Sema::CUDACheckLambdaCapture(CXXMethodDecl *Callee,
                           diag::warn_maybe_capture_bad_target_this_ptr, Callee,
                           *this);
   }
-  return;
 }
 
 void Sema::CUDASetLambdaAttrs(CXXMethodDecl *Method) {
index 083a67d..93c07cc 100644 (file)
@@ -569,7 +569,6 @@ void PreferredTypeBuilder::enterMemAccess(Sema &S, SourceLocation Tok,
     return;
   // Keep the expected type, only update the location.
   ExpectedLoc = Tok;
-  return;
 }
 
 void PreferredTypeBuilder::enterUnary(Sema &S, SourceLocation Tok,
index 0607d3a..7a03830 100644 (file)
@@ -6541,7 +6541,6 @@ static void HandleBTFTypeTagAttribute(QualType &Type, const ParsedAttr &Attr,
   StringRef BTFTypeTag = StrLiteral->getString();
   Type = State.getAttributedType(
       ::new (Ctx) BTFTypeTagAttr(Ctx, Attr, BTFTypeTag), Type, Type);
-  return;
 }
 
 /// HandleAddressSpaceTypeAttribute - Process an address_space attribute on the
index bf694e5..aa38b5e 100644 (file)
@@ -227,6 +227,4 @@ void clang_fuzzer::HandleLLVM(const std::string &IR,
 
   if (memcmp(OptArrays, UnoptArrays, kTotalSize))
     ErrorAndExit("!!!BUG!!!");
-
-  return;
 }
index 5f1cbc6..192149f 100644 (file)
@@ -1000,7 +1000,7 @@ protected:
   void SetPreferredDisplayLanguageIfNeeded(lldb::LanguageType);
 
 protected:
-  virtual void DoUpdateChildrenAddressType(ValueObject &valobj) { return; };
+  virtual void DoUpdateChildrenAddressType(ValueObject &valobj){};
 
 private:
   virtual CompilerType MaybeCalculateCompleteType();
index 2f95c26..ba96d08 100644 (file)
@@ -141,7 +141,7 @@ public:
     return false;
   }
 
-  virtual void SymbolsDidLoad(const ModuleList &module_list) { return; }
+  virtual void SymbolsDidLoad(const ModuleList &module_list) {}
 
   virtual lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
                                                           bool stop_others) = 0;
index 118fdfd..422f90d 100644 (file)
@@ -360,7 +360,6 @@ protected:
           m_entries.erase(next);
       }
     }
-    return;
   }
 
   Collection m_entries;
index 9122117..60207f7 100644 (file)
@@ -1034,7 +1034,7 @@ public:
   // navigates to the next or the previous field. This is particularly useful to
   // do in-field validation and error setting. Fields with internal navigation
   // should call this method on their fields.
-  virtual void FieldDelegateExitCallback() { return; }
+  virtual void FieldDelegateExitCallback() {}
 
   // Fields may have internal navigation, for instance, a List Field have
   // multiple internal elements, which needs to be navigated. To allow for this
@@ -1055,10 +1055,10 @@ public:
   virtual bool FieldDelegateOnLastOrOnlyElement() { return true; }
 
   // Select the first element in the field if multiple elements exists.
-  virtual void FieldDelegateSelectFirstElement() { return; }
+  virtual void FieldDelegateSelectFirstElement() {}
 
   // Select the last element in the field if multiple elements exists.
-  virtual void FieldDelegateSelectLastElement() { return; }
+  virtual void FieldDelegateSelectLastElement() {}
 
   // Returns true if the field has an error, false otherwise.
   virtual bool FieldDelegateHasError() { return false; }
@@ -2000,7 +2000,6 @@ public:
 
   void FieldDelegateSelectLastElement() override {
     m_selection_type = SelectionType::NewButton;
-    return;
   }
 
   int GetNumberOfFields() { return m_fields.size(); }
@@ -2292,7 +2291,7 @@ public:
 
   virtual std::string GetName() = 0;
 
-  virtual void UpdateFieldsVisibility() { return; }
+  virtual void UpdateFieldsVisibility() {}
 
   FieldDelegate *GetField(uint32_t field_index) {
     if (field_index < m_fields.size())
@@ -3765,13 +3764,11 @@ public:
   void SelectNext() {
     if (m_selected_match != m_delegate_sp->GetNumberOfMatches() - 1)
       m_selected_match++;
-    return;
   }
 
   void SelectPrevious() {
     if (m_selected_match != 0)
       m_selected_match--;
-    return;
   }
 
   void ExecuteCallback(Window &window) {
@@ -4608,9 +4605,7 @@ public:
   virtual void TreeDelegateDrawTreeItem(TreeItem &item, Window &window) = 0;
   virtual void TreeDelegateGenerateChildren(TreeItem &item) = 0;
   virtual void TreeDelegateUpdateSelection(TreeItem &root, int &selection_index,
-                                           TreeItem *&selected_item) {
-    return;
-  }
+                                           TreeItem *&selected_item) {}
   // This is invoked when a tree item is selected. If true is returned, the
   // views are updated.
   virtual bool TreeDelegateItemSelected(TreeItem &item) = 0;
index f2d22f7..3c4a87c 100644 (file)
@@ -483,8 +483,6 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, lldb::addr_t &func_addr,
 
   func_addr = m_function_load_addr;
   func_end = m_function_end_load_addr;
-
-  return;
 }
 
 IRExecutionUnit::~IRExecutionUnit() {
index 4ae2724..9eee5cf 100644 (file)
@@ -609,7 +609,6 @@ void IRMemoryMap::WriteScalarToMemory(lldb::addr_t process_address,
     error.SetErrorToGenericError();
     error.SetErrorString("Couldn't write scalar: its size was zero");
   }
-  return;
 }
 
 void IRMemoryMap::WritePointerToMemory(lldb::addr_t process_address,
@@ -757,7 +756,6 @@ void IRMemoryMap::ReadScalarFromMemory(Scalar &scalar,
     error.SetErrorToGenericError();
     error.SetErrorString("Couldn't read scalar: its size was zero");
   }
-  return;
 }
 
 void IRMemoryMap::ReadPointerFromMemory(lldb::addr_t *address,
@@ -773,8 +771,6 @@ void IRMemoryMap::ReadPointerFromMemory(lldb::addr_t *address,
     return;
 
   *address = pointer_scalar.ULongLong();
-
-  return;
 }
 
 void IRMemoryMap::GetMemoryData(DataExtractor &extractor,
index 63178e6..2f08b9f 100644 (file)
@@ -86,7 +86,6 @@ static void DupDescriptor(int error_fd, const FileSpec &file_spec, int fd,
     ExitWithError(error_fd, "DupDescriptor-dup2");
 
   ::close(target_fd);
-  return;
 }
 
 [[noreturn]] static void ChildFunc(int error_fd,
index 301bf94..bd03f18 100644 (file)
@@ -2216,7 +2216,6 @@ void CommandInterpreter::BuildAliasCommandArgs(CommandObject *alias_cmd_obj,
   }
 
   result.SetStatus(eReturnStatusSuccessFinishNoResult);
-  return;
 }
 
 int CommandInterpreter::GetOptionArgumentPosition(const char *in_string) {
@@ -2563,8 +2562,6 @@ void CommandInterpreter::HandleCommands(const StringList &commands,
 
   result.SetStatus(eReturnStatusSuccessFinishResult);
   m_debugger.SetAsyncExecution(old_async_execution);
-
-  return;
 }
 
 // Make flags that we can pass into the IOHandler so our delegates can do the
index c3cfd0a..866b89f 100644 (file)
@@ -242,7 +242,6 @@ void DynamicLoaderMacOSXDYLD::DoInitialImageFetch() {
       ReadDYLDInfoFromMemoryAndSetNotificationCallback(0x8fe00000);
     }
   }
-  return;
 }
 
 // Assume that dyld is in memory at ADDR and try to parse it's load commands
index 719b356..6ed3cc9 100644 (file)
@@ -806,7 +806,7 @@ void ClangASTImporter::ForgetSource(clang::ASTContext *dst_ast,
   md->removeOriginsWithContext(src_ast);
 }
 
-ClangASTImporter::MapCompleter::~MapCompleter() { return; }
+ClangASTImporter::MapCompleter::~MapCompleter() {}
 
 llvm::Expected<Decl *>
 ClangASTImporter::ASTImporterDelegate::ImportImpl(Decl *From) {
index 410d8a9..510352e 100644 (file)
@@ -513,8 +513,6 @@ void ClangASTSource::FindExternalLexicalDecls(
     // is consulted again when a clang::DeclContext::lookup is called.
     const_cast<DeclContext *>(decl_context)->setMustBuildLookupTable();
   }
-
-  return;
 }
 
 void ClangASTSource::FindExternalVisibleDecls(NameSearchContext &context) {
index 3afd1fd..f3fec3f 100644 (file)
@@ -59,7 +59,7 @@ public:
   GetExternalCXXBaseSpecifiers(uint64_t Offset) override {
     return nullptr;
   }
-  void MaterializeVisibleDecls(const clang::DeclContext *DC) { return; }
+  void MaterializeVisibleDecls(const clang::DeclContext *DC) {}
 
   void InstallASTContext(TypeSystemClang &ast_context);
 
index 846c159..4af5d41 100644 (file)
@@ -1954,8 +1954,6 @@ void ClangExpressionDeclMap::AddContextClassType(NameSearchContext &context,
     return;
 
   context.AddNamedDecl(typedef_decl);
-
-  return;
 }
 
 void ClangExpressionDeclMap::AddOneType(NameSearchContext &context,
index 9bc40c1..af11109 100644 (file)
@@ -80,8 +80,6 @@ public:
     LLDB_LOG(log, "  AOEAS::CT Before:\n{1}", ClangUtil::DumpDecl(tag_decl));
 
     LLDB_LOG(log, "  AOEAS::CT After:{1}", ClangUtil::DumpDecl(tag_decl));
-
-    return;
   }
 
   void CompleteType(clang::ObjCInterfaceDecl *interface_decl) override {
@@ -107,7 +105,6 @@ public:
       LLDB_LOGF(log, "  [CT] After:");
       LLDB_LOG(log, "    [CT] {0}", ClangUtil::DumpDecl(interface_decl));
     }
-    return;
   }
 
   bool layoutRecordType(
index bf101ac..e859b1d 100644 (file)
@@ -900,7 +900,7 @@ lldb::LanguageType SymbolFileNativePDB::ParseLanguage(CompileUnit &comp_unit) {
   return TranslateLanguage(item->m_compile_opts->getLanguage());
 }
 
-void SymbolFileNativePDB::AddSymbols(Symtab &symtab) { return; }
+void SymbolFileNativePDB::AddSymbols(Symtab &symtab) {}
 
 size_t SymbolFileNativePDB::ParseFunctions(CompileUnit &comp_unit) {
   std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
index c054793..a40b6ec 100644 (file)
@@ -239,7 +239,6 @@ void SymbolFilePDB::GetCompileUnitIndex(
     }
   }
   index = UINT32_MAX;
-  return;
 }
 
 std::unique_ptr<llvm::pdb::PDBSymbolCompiland>
index 557c556..b85901a 100644 (file)
@@ -125,9 +125,7 @@ void SymbolFile::FindFunctions(const RegularExpression &regex,
 
 void SymbolFile::GetMangledNamesForFunction(
     const std::string &scope_qualified_name,
-    std::vector<ConstString> &mangled_names) {
-  return;
-}
+    std::vector<ConstString> &mangled_names) {}
 
 void SymbolFile::FindTypes(
     ConstString name, const CompilerDeclContext &parent_decl_ctx,
index f09583c..8063464 100644 (file)
@@ -210,7 +210,6 @@ void ThreadPlanStack::DiscardAllPlans() {
   for (int i = stack_size - 1; i > 0; i--) {
     DiscardPlan();
   }
-  return;
 }
 
 void ThreadPlanStack::DiscardConsultingControllingPlans() {
index 0471471..77dd19b 100644 (file)
@@ -312,7 +312,6 @@ void UnwindLLDB::UpdateUnwindPlanForFirstFrameIfInvalid(ABI *abi) {
   // Restore status after calling AddOneMoreFrame
   m_unwind_complete = old_m_unwind_complete;
   m_candidate_frame = old_m_candidate_frame;
-  return;
 }
 
 bool UnwindLLDB::AddOneMoreFrame(ABI *abi) {
index 93d36a4..c557fc7 100644 (file)
@@ -159,7 +159,6 @@ cleanup:
     LLVMOrcIRTransformLayerRef IRLayer = LLVMOrcLLJITGetIRTransformLayer(J);
     LLVMOrcIRTransformLayerEmit(IRLayer, MR, TSM);
   }
-  return;
 }
 
 int main(int argc, char *argv[]) {
index 262dc16..e8a8efd 100644 (file)
@@ -302,7 +302,6 @@ void LegalizerHelper::mergeMixedSubvectors(Register DstReg,
     appendVectorElts(AllElts, Leftover);
 
   MIRBuilder.buildMerge(DstReg, AllElts);
-  return;
 }
 
 /// Append the result registers of G_UNMERGE_VALUES \p MI to \p Regs.
index 906a48d..5421b2d 100644 (file)
@@ -89,7 +89,6 @@ static void dumpLocationList(raw_ostream &OS, const DWARFFormValue &FormValue,
   U->getLocationTable().dumpLocationList(&Offset, OS, U->getBaseAddress(), MRI,
                                          Ctx.getDWARFObj(), U, DumpOpts,
                                          Indent);
-  return;
 }
 
 static void dumpLocationExpr(raw_ostream &OS, const DWARFFormValue &FormValue,
@@ -105,7 +104,6 @@ static void dumpLocationExpr(raw_ostream &OS, const DWARFFormValue &FormValue,
                      Ctx.isLittleEndian(), 0);
   DWARFExpression(Data, U->getAddressByteSize(), U->getFormParams().Format)
       .print(OS, DumpOpts, MRI, U);
-  return;
 }
 
 static DWARFDie resolveReferencedType(DWARFDie D,
index fb61057..b40fe0c 100644 (file)
@@ -2324,7 +2324,6 @@ bool ShuffleVectorInst::isInsertSubvectorMask(ArrayRef<int> Mask,
     }
     Src1Elts.setBit(i);
     Src1Identity &= (M == (i + NumSrcElts));
-    continue;
   }
   assert((Src0Elts | Src1Elts | UndefElts).isAllOnes() &&
          "unknown shuffle elements");
index 301e6f6..e79ff9b 100644 (file)
@@ -378,5 +378,4 @@ void AMDGPUCombinerHelper::applyFoldableFneg(MachineInstr &MI,
   }
 
   MI.eraseFromParent();
-  return;
 }
index 4ce2c8a..1755b93 100644 (file)
@@ -2395,8 +2395,6 @@ void SIInstrInfo::insertIndirectBranch(MachineBasicBlock &MBB,
   OffsetLo->setVariableValue(MCBinaryExpr::createAnd(Offset, Mask, MCCtx));
   auto *ShAmt = MCConstantExpr::create(32, MCCtx);
   OffsetHi->setVariableValue(MCBinaryExpr::createAShr(Offset, ShAmt, MCCtx));
-
-  return;
 }
 
 unsigned SIInstrInfo::getBranchOpcode(SIInstrInfo::BranchPredicate Cond) {
index 798d083..5106001 100644 (file)
@@ -571,8 +571,6 @@ void AVRInstrInfo::insertIndirectBranch(MachineBasicBlock &MBB,
   // See lib/CodeGen/RegisterRelaxation.cpp for details.
   // We end up here when a jump is too long for a RJMP instruction.
   BuildMI(&MBB, DL, get(AVR::JMPk)).addMBB(&NewDestBB);
-
-  return;
 }
 
 } // end of namespace llvm
index a2112cd..dc691b8 100644 (file)
@@ -868,7 +868,6 @@ inline void isl_sioimath_tdiv_q(isl_sioimath_ptr dst, isl_sioimath_src lhs,
            isl_sioimath_bigarg_src(rhs, &rhsscratch),
            isl_sioimath_reinit_big(dst), NULL);
        isl_sioimath_try_demote(dst);
-       return;
 }
 
 /* Divide lhs by an unsigned long rhs, rounding to zero (Truncate).
index 2c05927..ec4c584 100644 (file)
@@ -271,7 +271,6 @@ public:
       }
 
       // not a loop transformation; look for next property
-      continue;
     }
   }