[Lldb-commits] [lldb] 9c0a422 - Use Optional::getValueOr (NFC)
Author: Kazu Hirata Date: 2021-12-24T20:57:40-08:00 New Revision: 9c0a4227a9ca7a2e4dc63ae27ee3868efdedb7ea URL: https://github.com/llvm/llvm-project/commit/9c0a4227a9ca7a2e4dc63ae27ee3868efdedb7ea DIFF: https://github.com/llvm/llvm-project/commit/9c0a4227a9ca7a2e4dc63ae27ee3868efdedb7ea.diff LOG: Use Optional::getValueOr (NFC) Added: Modified: clang/include/clang/APINotes/Types.h clang/include/clang/AST/AbstractBasicReader.h clang/include/clang/AST/DeclTemplate.h clang/lib/ASTMatchers/Dynamic/Parser.cpp clang/lib/CodeGen/CGObjC.cpp lld/ELF/LinkerScript.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h lldb/source/Plugins/TraceExporter/ctf/CommandObjectThreadTraceExportCTF.cpp llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp llvm/lib/IR/Instructions.cpp llvm/lib/MC/MachObjectWriter.cpp Removed: diff --git a/clang/include/clang/APINotes/Types.h b/clang/include/clang/APINotes/Types.h index d9bf2f07291f5..0d97e9ad86231 100644 --- a/clang/include/clang/APINotes/Types.h +++ b/clang/include/clang/APINotes/Types.h @@ -240,7 +240,7 @@ class ObjCContextInfo : public CommonTypeInfo { } void setSwiftImportAsNonGeneric(llvm::Optional Value) { SwiftImportAsNonGenericSpecified = Value.hasValue(); -SwiftImportAsNonGeneric = Value.hasValue() ? *Value : false; +SwiftImportAsNonGeneric = Value.getValueOr(false); } llvm::Optional getSwiftObjCMembers() const { @@ -249,7 +249,7 @@ class ObjCContextInfo : public CommonTypeInfo { } void setSwiftObjCMembers(llvm::Optional Value) { SwiftObjCMembersSpecified = Value.hasValue(); -SwiftObjCMembers = Value.hasValue() ? *Value : false; +SwiftObjCMembers = Value.getValueOr(false); } /// Strip off any information within the class information structure that is @@ -368,7 +368,7 @@ class ObjCPropertyInfo : public VariableInfo { } void setSwiftImportAsAccessors(llvm::Optional Value) { SwiftImportAsAccessorsSpecified = Value.hasValue(); -SwiftImportAsAccessors = Value.hasValue() ? *Value : false; +SwiftImportAsAccessors = Value.getValueOr(false); } friend bool operator==(const ObjCPropertyInfo &, const ObjCPropertyInfo &); @@ -433,7 +433,7 @@ class ParamInfo : public VariableInfo { } void setNoEscape(llvm::Optional Value) { NoEscapeSpecified = Value.hasValue(); -NoEscape = Value.hasValue() ? *Value : false; +NoEscape = Value.getValueOr(false); } llvm::Optional getRetainCountConvention() const { @@ -671,7 +671,7 @@ class TagInfo : public CommonTypeInfo { } void setFlagEnum(llvm::Optional Value) { HasFlagEnum = Value.hasValue(); -IsFlagEnum = Value.hasValue() ? *Value : false; +IsFlagEnum = Value.getValueOr(false); } TagInfo &operator|=(const TagInfo &RHS) { diff --git a/clang/include/clang/AST/AbstractBasicReader.h b/clang/include/clang/AST/AbstractBasicReader.h index 5505d661b44e2..442039044cfe5 100644 --- a/clang/include/clang/AST/AbstractBasicReader.h +++ b/clang/include/clang/AST/AbstractBasicReader.h @@ -21,7 +21,7 @@ inline T makeNullableFromOptional(const Optional &value) { template inline T *makePointerFromOptional(Optional value) { - return (value ? *value : nullptr); + return value.getValueOr(nullptr); } // PropertyReader is a class concept that requires the following method: diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index d33babef958ea..f7a2e3146d061 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -1211,13 +1211,12 @@ class TemplateTypeParmDecl final : public TypeDecl, DefArgStorage DefaultArgument; TemplateTypeParmDecl(DeclContext *DC, SourceLocation KeyLoc, - SourceLocation IdLoc, IdentifierInfo *Id, - bool Typename, bool HasTypeConstraint, - Optional NumExpanded) + SourceLocation IdLoc, IdentifierInfo *Id, bool Typename, + bool HasTypeConstraint, Optional NumExpanded) : TypeDecl(TemplateTypeParm, DC, IdLoc, Id, KeyLoc), Typename(Typename), - HasTypeConstraint(HasTypeConstraint), TypeConstraintInitialized(false), - ExpandedParameterPack(NumExpanded), - NumExpanded(NumExpanded ? *NumExpanded : 0) {} +HasTypeConstraint(HasTypeConstraint), TypeConstraintInitialized(false), +ExpandedParameterPack(NumExpanded), +NumExpanded(NumExpanded.getValueOr(0)) {} public: static TemplateTypeParmDecl *Create(const ASTContext &C, DeclContext *DC, diff --git a/clang/lib/ASTMatchers/Dynamic/Parser.cpp b/clang/lib/ASTMatchers/Dynamic/Parser.cpp index c6a77bb6c2e00..cab1476acf946 100644 --- a/clang/lib/ASTMatchers/Dynamic/Parser.cpp +++ b/clang/lib/ASTMatchers/Dynamic/Parser.cpp @@ -645,7 +645,7 @@ bool Parser::parseMatcherExpressionImpl(const
[Lldb-commits] [lldb] 62e48ed - Use isa instead of dyn_cast (NFC)
Author: Kazu Hirata Date: 2021-12-24T21:22:27-08:00 New Revision: 62e48ed10f9d2328331378f7c070487e58346a7e URL: https://github.com/llvm/llvm-project/commit/62e48ed10f9d2328331378f7c070487e58346a7e DIFF: https://github.com/llvm/llvm-project/commit/62e48ed10f9d2328331378f7c070487e58346a7e.diff LOG: Use isa instead of dyn_cast (NFC) Added: Modified: clang-tools-extra/clang-doc/Mapper.cpp clang-tools-extra/clang-doc/Serialize.cpp clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h clang/lib/Sema/SemaExprCXX.cpp lld/COFF/Driver.cpp lld/ELF/Symbols.cpp lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp Removed: diff --git a/clang-tools-extra/clang-doc/Mapper.cpp b/clang-tools-extra/clang-doc/Mapper.cpp index 790f11bb69c5b..de7e4c3410866 100644 --- a/clang-tools-extra/clang-doc/Mapper.cpp +++ b/clang-tools-extra/clang-doc/Mapper.cpp @@ -68,7 +68,7 @@ bool MapASTVisitor::VisitCXXMethodDecl(const CXXMethodDecl *D) { bool MapASTVisitor::VisitFunctionDecl(const FunctionDecl *D) { // Don't visit CXXMethodDecls twice - if (dyn_cast(D)) + if (isa(D)) return true; return mapDecl(D); } diff --git a/clang-tools-extra/clang-doc/Serialize.cpp b/clang-tools-extra/clang-doc/Serialize.cpp index e132c56cb0001..29762b6b54b1e 100644 --- a/clang-tools-extra/clang-doc/Serialize.cpp +++ b/clang-tools-extra/clang-doc/Serialize.cpp @@ -382,7 +382,7 @@ populateParentNamespaces(llvm::SmallVector &Namespaces, // corresponds to a Record and if it doesn't have any namespace (because this // means it's in the global namespace). Also if its outermost namespace is a // record because that record matches the previous condition mentioned. - if ((Namespaces.empty() && dyn_cast(D)) || + if ((Namespaces.empty() && isa(D)) || (!Namespaces.empty() && Namespaces.back().RefType == InfoType::IT_record)) Namespaces.emplace_back(SymbolID(), "GlobalNamespace", InfoType::IT_namespace); @@ -419,10 +419,10 @@ static void populateFunctionInfo(FunctionInfo &I, const FunctionDecl *D, populateSymbolInfo(I, D, FC, LineNumber, Filename, IsFileInRootDir, IsInAnonymousNamespace); if (const auto *T = getDeclForType(D->getReturnType())) { -if (dyn_cast(T)) +if (isa(T)) I.ReturnType = TypeInfo(getUSRForDecl(T), T->getNameAsString(), InfoType::IT_enum, getInfoRelativePath(T)); -else if (dyn_cast(T)) +else if (isa(T)) I.ReturnType = TypeInfo(getUSRForDecl(T), T->getNameAsString(), InfoType::IT_record, getInfoRelativePath(T)); } else { diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp index 432d929057d14..b0b882be1a6c7 100644 --- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp @@ -829,7 +829,7 @@ bool LoopConvertCheck::isConvertible(ASTContext *Context, } else if (FixerKind == LFK_PseudoArray) { // This call is required to obtain the container. const auto *EndCall = Nodes.getNodeAs(EndCallName); -if (!EndCall || !dyn_cast(EndCall->getCallee())) +if (!EndCall || !isa(EndCall->getCallee())) return false; } return true; diff --git a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h index 4a58fe8709442..a0ae44131b45a 100644 --- a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h +++ b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h @@ -155,7 +155,7 @@ class CFGWalker { return false; // Ignore anonymous functions. -if (!dyn_cast_or_null(AC.getDecl())) +if (!isa_and_nonnull(AC.getDecl())) return false; SortedGraph = AC.getAnalysis(); diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index d25f329f85e45..54f0242d2ca12 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1346,7 +1346,7 @@ bool Sema::CheckCXXThisCapture(SourceLocation Loc, const bool Explicit, // implicitly capturing the *enclosing object* by reference (see loop // above)). assert((!ByCopy || - dyn_cast(FunctionScopes[MaxFunctionScopesIndex])) && + isa(FunctionScopes[MaxFunctionScopesIndex])) && "Only a lambda can capture the enclosing object (referred to by " "*this) by copy"); QualType ThisTy = getCurrentThisType(); di
[Lldb-commits] [lldb] 76f0f1c - Use {DenseSet, SetVector, SmallPtrSet}::contains (NFC)
Author: Kazu Hirata Date: 2021-12-24T21:43:06-08:00 New Revision: 76f0f1cc5c52359da5dd6d0c00a1bca1 URL: https://github.com/llvm/llvm-project/commit/76f0f1cc5c52359da5dd6d0c00a1bca1 DIFF: https://github.com/llvm/llvm-project/commit/76f0f1cc5c52359da5dd6d0c00a1bca1.diff LOG: Use {DenseSet,SetVector,SmallPtrSet}::contains (NFC) Added: Modified: clang/lib/AST/ASTContext.cpp clang/lib/CodeGen/CGOpenMPRuntime.cpp clang/lib/Frontend/CompilerInstance.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp llvm/lib/Transforms/Vectorize/LoopVectorize.cpp polly/lib/Support/SCEVValidator.cpp polly/lib/Transform/ScopInliner.cpp Removed: diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 58bd7b6a4a8cc..008b703d4c1a9 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -9272,7 +9272,7 @@ void getIntersectionOfProtocols(ASTContext &Context, // Remove any implied protocols from the list of inherited protocols. if (!ImpliedProtocols.empty()) { llvm::erase_if(IntersectionSet, [&](ObjCProtocolDecl *proto) -> bool { - return ImpliedProtocols.count(proto) > 0; + return ImpliedProtocols.contains(proto); }); } diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 0c71fee140259..e35c154215203 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -12788,7 +12788,7 @@ void CGOpenMPRuntime::checkAndEmitSharedLastprivateConditional( const CapturedStmt *CS = D.getCapturedStmt(CaptureRegions.back()); for (const auto &Pair : It->DeclToUniqueName) { const auto *VD = cast(Pair.first->getCanonicalDecl()); -if (!CS->capturesVariable(VD) || IgnoredDecls.count(VD) > 0) +if (!CS->capturesVariable(VD) || IgnoredDecls.contains(VD)) continue; auto I = LPCI->getSecond().find(Pair.first); assert(I != LPCI->getSecond().end() && diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 1432607204bdd..31e7ea3d243d2 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -1154,12 +1154,12 @@ compileModuleImpl(CompilerInstance &ImportingInstance, SourceLocation ImportLoc, // Remove any macro definitions that are explicitly ignored by the module. // They aren't supposed to affect how the module is built anyway. HeaderSearchOptions &HSOpts = Invocation->getHeaderSearchOpts(); - llvm::erase_if( - PPOpts.Macros, [&HSOpts](const std::pair &def) { -StringRef MacroDef = def.first; -return HSOpts.ModulesIgnoreMacros.count( - llvm::CachedHashString(MacroDef.split('=').first)) > 0; - }); + llvm::erase_if(PPOpts.Macros, + [&HSOpts](const std::pair &def) { + StringRef MacroDef = def.first; + return HSOpts.ModulesIgnoreMacros.contains( + llvm::CachedHashString(MacroDef.split('=').first)); + }); // If the original compiler invocation had -fmodule-name, pass it through. Invocation->getLangOpts()->ModuleName = diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp index 80469e2925801..719b35689feb6 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -293,7 +293,7 @@ class CompleteTagDeclsScope : public ClangASTImporter::NewDeclListener { NamedDecl *to_named_decl = dyn_cast(to); // Check if we already completed this type. -if (m_decls_already_completed.count(to_named_decl) != 0) +if (m_decls_already_completed.contains(to_named_decl)) return; // Queue this type to be completed. m_decls_to_complete.insert(to_named_decl); diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index 7668b68650b4d..e72d55dd2aba8 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -4647,7 +4647,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) { // Add symbols from the trie to the symbol table. for (auto &e : external_sym_trie_entries) { -if (symbols_added.find(e.entry.address) != symbols_added.end()) +if (symbols_added.contains(e.entry.address)) continue; // Find the section that this trie address is in, use that to annotate diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/Nativ
[Lldb-commits] [lldb] 2d303e6 - Remove redundant return and continue statements (NFC)
Author: Kazu Hirata Date: 2021-12-24T23:17:54-08:00 New Revision: 2d303e678152fddb88dea4199c8872223232b406 URL: https://github.com/llvm/llvm-project/commit/2d303e678152fddb88dea4199c8872223232b406 DIFF: https://github.com/llvm/llvm-project/commit/2d303e678152fddb88dea4199c8872223232b406.diff LOG: Remove redundant return and continue statements (NFC) Identified with readability-redundant-control-flow. Added: Modified: 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 Removed: diff --git a/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp index aa839beddac6..c9f3a7db0346 100644 --- a/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp +++ b/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp @@ -221,7 +221,6 @@ void DurationFactoryScaleCheck::check(const MatchFinder::MatchResult &Result) { tooling::fixit::getText(*Remainder, *Result.Context) + ")") .str()); } - return; } } // namespace abseil diff --git a/clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.cpp b/clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.cpp index 42b697076b35..842bf43b2c45 100644 --- a/clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.cpp +++ b/clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.cpp @@ -41,7 +41,6 @@ void ImplementationInNamespaceCheck::check( diag(MatchedDecl->getLocation(), "declaration must be declared within the '%0' namespace") << RequiredNamespace; - return; } } // namespace llvm_libc diff --git a/clang/lib/ASTMatchers/Dynamic/Marshallers.h b/clang/lib/ASTMatchers/Dynamic/Marshallers.h index 783fb203c408..fa9d42247e24 100644 --- a/clang/lib/ASTMatchers/Dynamic/Marshallers.h +++ b/clang/lib/ASTMatchers/Dynamic/Marshallers.h @@ -1035,7 +1035,6 @@ class MapAnyOfBuilderDescriptor : public MatcherDescriptor { void getArgKinds(ASTNodeKind ThisKind, unsigned, std::vector &ArgKinds) const override { ArgKinds.push_back(ArgKind::MakeNodeArg(ThisKind)); -return; } bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity = nullptr, ASTNodeKind *LeastDerivedKind = nullptr) const override { diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index abf65e3efce9..9ef3b5b6277a 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -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 diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp