aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp18
-rw-r--r--clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp2
-rw-r--r--clang-tools-extra/clang-doc/Representation.cpp4
-rw-r--r--clang-tools-extra/clang-doc/tool/ClangDocMain.cpp2
-rw-r--r--clang-tools-extra/clang-include-fixer/InMemorySymbolIndex.cpp4
-rw-r--r--clang-tools-extra/clang-include-fixer/IncludeFixer.cpp10
-rw-r--r--clang-tools-extra/clang-include-fixer/IncludeFixer.h4
-rw-r--r--clang-tools-extra/clang-include-fixer/IncludeFixerContext.cpp2
-rw-r--r--clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp3
-rw-r--r--clang-tools-extra/clang-include-fixer/find-all-symbols/HeaderMapCollector.h2
-rw-r--r--clang-tools-extra/clang-include-fixer/find-all-symbols/PathConfig.cpp2
-rw-r--r--clang-tools-extra/clang-include-fixer/find-all-symbols/SymbolInfo.h2
-rw-r--r--clang-tools-extra/clang-include-fixer/plugin/IncludeFixerPlugin.cpp3
-rw-r--r--clang-tools-extra/clang-move/Move.cpp8
-rw-r--r--clang-tools-extra/clang-move/tool/ClangMove.cpp3
-rw-r--r--clang-tools-extra/clang-query/QueryParser.cpp3
-rw-r--r--clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp5
-rw-r--r--clang-tools-extra/clang-tidy/ClangTidy.cpp2
-rw-r--r--clang-tools-extra/clang-tidy/ClangTidyCheck.cpp6
-rw-r--r--clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp10
-rw-r--r--clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h2
-rw-r--r--clang-tools-extra/clang-tidy/ClangTidyModule.cpp2
-rw-r--r--clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp2
-rw-r--r--clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp3
-rw-r--r--clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp14
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/InaccurateEraseCheck.cpp4
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp2
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp7
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp4
-rw-r--r--clang-tools-extra/clang-tidy/cert/MutatingCopyCheck.cpp3
-rw-r--r--clang-tools-extra/clang-tidy/google/AvoidNSObjectNewCheck.cpp5
-rw-r--r--clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp8
-rw-r--r--clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp2
-rw-r--r--clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp3
-rw-r--r--clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp8
-rw-r--r--clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp18
-rw-r--r--clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp3
-rw-r--r--clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp8
-rw-r--r--clang-tools-extra/clang-tidy/modernize/ShrinkToFitCheck.cpp8
-rw-r--r--clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp3
-rw-r--r--clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp4
-rw-r--r--clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp20
-rw-r--r--clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp4
-rw-r--r--clang-tools-extra/clang-tidy/plugin/ClangTidyPlugin.cpp2
-rw-r--r--clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp4
-rw-r--r--clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp2
-rw-r--r--clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp2
-rw-r--r--clang-tools-extra/clang-tidy/readability/RedundantPreprocessorCheck.cpp2
-rw-r--r--clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp4
-rw-r--r--clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp2
-rw-r--r--clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp2
-rw-r--r--clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp4
-rw-r--r--clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp2
-rw-r--r--clang-tools-extra/clang-tidy/utils/NamespaceAliaser.cpp10
-rw-r--r--clang-tools-extra/clang-tidy/utils/OptionsUtils.cpp2
-rw-r--r--clang-tools-extra/clang-tidy/utils/UsingInserter.cpp2
-rw-r--r--clang-tools-extra/clangd/ClangdLSPServer.cpp17
-rw-r--r--clang-tools-extra/clangd/ClangdServer.cpp6
-rw-r--r--clang-tools-extra/clangd/CodeComplete.cpp52
-rw-r--r--clang-tools-extra/clangd/CompileCommands.cpp6
-rw-r--r--clang-tools-extra/clangd/Diagnostics.cpp15
-rw-r--r--clang-tools-extra/clangd/DraftStore.cpp4
-rw-r--r--clang-tools-extra/clangd/ExpectedTypes.cpp2
-rw-r--r--clang-tools-extra/clangd/FS.cpp2
-rw-r--r--clang-tools-extra/clangd/FindSymbols.cpp8
-rw-r--r--clang-tools-extra/clangd/FindTarget.cpp2
-rw-r--r--clang-tools-extra/clangd/Format.cpp2
-rw-r--r--clang-tools-extra/clangd/GlobalCompilationDatabase.cpp6
-rw-r--r--clang-tools-extra/clangd/HeaderSourceSwitch.cpp2
-rw-r--r--clang-tools-extra/clangd/Headers.cpp4
-rw-r--r--clang-tools-extra/clangd/Hover.cpp11
-rw-r--r--clang-tools-extra/clangd/IncludeFixer.cpp10
-rw-r--r--clang-tools-extra/clangd/JSONTransport.cpp3
-rw-r--r--clang-tools-extra/clangd/ParsedAST.cpp5
-rw-r--r--clang-tools-extra/clangd/PathMapping.cpp2
-rw-r--r--clang-tools-extra/clangd/Protocol.cpp2
-rw-r--r--clang-tools-extra/clangd/QueryDriverDatabase.cpp6
-rw-r--r--clang-tools-extra/clangd/SourceCode.cpp10
-rw-r--r--clang-tools-extra/clangd/TUScheduler.cpp57
-rw-r--r--clang-tools-extra/clangd/URI.cpp2
-rw-r--r--clang-tools-extra/clangd/XRefs.cpp17
-rw-r--r--clang-tools-extra/clangd/index/Background.cpp2
-rw-r--r--clang-tools-extra/clangd/index/BackgroundIndexLoader.cpp2
-rw-r--r--clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp4
-rw-r--r--clang-tools-extra/clangd/index/CanonicalIncludes.cpp2
-rw-r--r--clang-tools-extra/clangd/index/FileIndex.cpp3
-rw-r--r--clang-tools-extra/clangd/index/Serialization.cpp4
-rw-r--r--clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp4
-rw-r--r--clang-tools-extra/clangd/refactor/Tweak.h2
-rw-r--r--clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp2
-rw-r--r--clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp5
-rw-r--r--clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp7
-rw-r--r--clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp4
-rw-r--r--clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp19
-rw-r--r--clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp3
-rw-r--r--clang-tools-extra/clangd/tool/ClangdMain.cpp2
-rw-r--r--clang-tools-extra/clangd/unittests/ClangdTests.cpp6
-rw-r--r--clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp2
-rw-r--r--clang-tools-extra/clangd/unittests/DexTests.cpp4
-rw-r--r--clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp12
-rw-r--r--clang-tools-extra/clangd/unittests/ExpectedTypeTest.cpp2
-rw-r--r--clang-tools-extra/clangd/unittests/FileIndexTests.cpp12
-rw-r--r--clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp4
-rw-r--r--clang-tools-extra/clangd/unittests/FindTargetTests.cpp6
-rw-r--r--clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp3
-rw-r--r--clang-tools-extra/clangd/unittests/HeadersTests.cpp2
-rw-r--r--clang-tools-extra/clangd/unittests/IndexActionTests.cpp4
-rw-r--r--clang-tools-extra/clangd/unittests/IndexTests.cpp4
-rw-r--r--clang-tools-extra/clangd/unittests/RenameTests.cpp10
-rw-r--r--clang-tools-extra/clangd/unittests/SelectionTests.cpp2
-rw-r--r--clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp7
-rw-r--r--clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp2
-rw-r--r--clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp4
-rw-r--r--clang-tools-extra/clangd/unittests/SyncAPI.cpp2
-rw-r--r--clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp4
-rw-r--r--clang-tools-extra/clangd/unittests/TestFS.cpp8
-rw-r--r--clang-tools-extra/clangd/unittests/TestTU.h4
-rw-r--r--clang-tools-extra/clangd/unittests/TweakTesting.cpp10
-rw-r--r--clang-tools-extra/clangd/unittests/TweakTests.cpp2
-rw-r--r--clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp2
-rw-r--r--clang-tools-extra/clangd/unittests/XRefsTests.cpp35
-rw-r--r--clang-tools-extra/modularize/CoverageChecker.cpp2
-rw-r--r--clang-tools-extra/modularize/Modularize.cpp6
-rw-r--r--clang-tools-extra/modularize/ModularizeUtilities.cpp8
-rw-r--r--clang-tools-extra/modularize/ModuleAssistant.cpp10
-rw-r--r--clang-tools-extra/unittests/clang-include-fixer/IncludeFixerTest.cpp5
-rw-r--r--clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h3
-rw-r--r--clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp7
-rw-r--r--clang/include/clang/AST/DeclObjC.h4
-rw-r--r--clang/include/clang/AST/JSONNodeDumper.h2
-rw-r--r--clang/include/clang/AST/PrettyPrinter.h4
-rw-r--r--clang/include/clang/AST/TextNodeDumper.h2
-rw-r--r--clang/include/clang/ASTMatchers/ASTMatchersInternal.h2
-rw-r--r--clang/include/clang/Analysis/PathDiagnostic.h4
-rw-r--r--clang/include/clang/Basic/Diagnostic.h8
-rw-r--r--clang/include/clang/Basic/FixedPoint.h2
-rw-r--r--clang/include/clang/Basic/Module.h2
-rw-r--r--clang/include/clang/Basic/PartialDiagnostic.h2
-rw-r--r--clang/include/clang/Driver/Driver.h4
-rw-r--r--clang/include/clang/Driver/Multilib.h2
-rw-r--r--clang/include/clang/Frontend/CommandLineSourceLoc.h2
-rw-r--r--clang/include/clang/Frontend/LogDiagnosticPrinter.h2
-rw-r--r--clang/include/clang/Lex/HeaderSearch.h4
-rw-r--r--clang/include/clang/Lex/HeaderSearchOptions.h4
-rw-r--r--clang/include/clang/Lex/Preprocessor.h2
-rw-r--r--clang/include/clang/Sema/Sema.h2
-rw-r--r--clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h3
-rw-r--r--clang/include/clang/Tooling/AllTUsExecution.h2
-rw-r--r--clang/include/clang/Tooling/Refactoring/AtomicChange.h2
-rw-r--r--clang/include/clang/Tooling/Transformer/RewriteRule.h3
-rw-r--r--clang/lib/ARCMigrate/ARCMT.cpp6
-rw-r--r--clang/lib/ARCMigrate/FileRemapper.cpp6
-rw-r--r--clang/lib/ARCMigrate/ObjCMT.cpp48
-rw-r--r--clang/lib/AST/ASTDiagnostic.cpp5
-rw-r--r--clang/lib/AST/DeclBase.cpp4
-rw-r--r--clang/lib/AST/Expr.cpp10
-rw-r--r--clang/lib/AST/ExternalASTSource.cpp2
-rw-r--r--clang/lib/AST/Mangle.cpp2
-rw-r--r--clang/lib/AST/MicrosoftMangle.cpp2
-rw-r--r--clang/lib/AST/Stmt.cpp2
-rw-r--r--clang/lib/AST/StmtPrinter.cpp7
-rw-r--r--clang/lib/AST/TypePrinter.cpp4
-rw-r--r--clang/lib/ASTMatchers/Dynamic/Registry.cpp2
-rw-r--r--clang/lib/Analysis/RetainSummaryManager.cpp3
-rw-r--r--clang/lib/Basic/FileManager.cpp2
-rw-r--r--clang/lib/Basic/IdentifierTable.cpp4
-rw-r--r--clang/lib/Basic/Targets/ARM.cpp2
-rw-r--r--clang/lib/Basic/Warnings.cpp5
-rw-r--r--clang/lib/CodeGen/BackendUtil.cpp8
-rw-r--r--clang/lib/CodeGen/CGCUDANV.cpp16
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp5
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp8
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp8
-rw-r--r--clang/lib/CodeGen/CGNonTrivialStruct.cpp2
-rw-r--r--clang/lib/CodeGen/CGObjCGNU.cpp8
-rw-r--r--clang/lib/CodeGen/CGObjCMac.cpp9
-rw-r--r--clang/lib/CodeGen/CGOpenMPRuntime.cpp6
-rw-r--r--clang/lib/CodeGen/CodeGenAction.cpp2
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp2
-rw-r--r--clang/lib/CrossTU/CrossTranslationUnit.cpp8
-rw-r--r--clang/lib/Driver/Driver.cpp39
-rw-r--r--clang/lib/Driver/Multilib.cpp8
-rw-r--r--clang/lib/Driver/SanitizerArgs.cpp2
-rw-r--r--clang/lib/Driver/ToolChain.cpp26
-rw-r--r--clang/lib/Driver/ToolChains/AVR.cpp2
-rw-r--r--clang/lib/Driver/ToolChains/Arch/AArch64.cpp4
-rw-r--r--clang/lib/Driver/ToolChains/Arch/ARM.cpp10
-rw-r--r--clang/lib/Driver/ToolChains/Arch/PPC.cpp2
-rw-r--r--clang/lib/Driver/ToolChains/Arch/RISCV.cpp8
-rw-r--r--clang/lib/Driver/ToolChains/Arch/SystemZ.cpp4
-rw-r--r--clang/lib/Driver/ToolChains/Arch/X86.cpp2
-rw-r--r--clang/lib/Driver/ToolChains/BareMetal.cpp2
-rw-r--r--clang/lib/Driver/ToolChains/CloudABI.cpp2
-rw-r--r--clang/lib/Driver/ToolChains/CommonArgs.cpp7
-rw-r--r--clang/lib/Driver/ToolChains/Cuda.cpp39
-rw-r--r--clang/lib/Driver/ToolChains/Darwin.cpp10
-rw-r--r--clang/lib/Driver/ToolChains/Fuchsia.cpp4
-rw-r--r--clang/lib/Driver/ToolChains/Gnu.cpp10
-rw-r--r--clang/lib/Driver/ToolChains/HIP.cpp9
-rw-r--r--clang/lib/Driver/ToolChains/Hurd.cpp2
-rw-r--r--clang/lib/Driver/ToolChains/Linux.cpp8
-rw-r--r--clang/lib/Driver/ToolChains/MSP430.cpp2
-rw-r--r--clang/lib/Driver/ToolChains/MSVC.cpp21
-rw-r--r--clang/lib/Driver/ToolChains/MinGW.cpp17
-rw-r--r--clang/lib/Driver/ToolChains/MipsLinux.cpp2
-rw-r--r--clang/lib/Driver/ToolChains/PS4CPU.cpp4
-rw-r--r--clang/lib/Driver/ToolChains/RISCVToolchain.cpp2
-rw-r--r--clang/lib/Driver/ToolChains/WebAssembly.cpp2
-rw-r--r--clang/lib/Driver/XRayArgs.cpp2
-rw-r--r--clang/lib/Format/BreakableToken.cpp2
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp4
-rw-r--r--clang/lib/Format/Format.cpp8
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp26
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp16
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp162
-rw-r--r--clang/lib/Frontend/DependencyFile.cpp2
-rw-r--r--clang/lib/Frontend/DependencyGraph.cpp3
-rw-r--r--clang/lib/Frontend/FrontendAction.cpp26
-rw-r--r--clang/lib/Frontend/FrontendActions.cpp8
-rw-r--r--clang/lib/Frontend/InitHeaderSearch.cpp8
-rw-r--r--clang/lib/Frontend/InitPreprocessor.cpp6
-rw-r--r--clang/lib/Frontend/LogDiagnosticPrinter.cpp9
-rw-r--r--clang/lib/Frontend/ModuleDependencyCollector.cpp2
-rw-r--r--clang/lib/Frontend/PrecompiledPreamble.cpp11
-rw-r--r--clang/lib/Frontend/Rewrite/FixItRewriter.cpp6
-rw-r--r--clang/lib/Frontend/Rewrite/FrontendActions.cpp12
-rw-r--r--clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp6
-rw-r--r--clang/lib/Frontend/Rewrite/RewriteObjC.cpp8
-rw-r--r--clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp6
-rw-r--r--clang/lib/Lex/HeaderSearch.cpp9
-rw-r--r--clang/lib/Lex/Lexer.cpp2
-rw-r--r--clang/lib/Lex/ModuleMap.cpp30
-rw-r--r--clang/lib/Lex/PPLexerChange.cpp2
-rw-r--r--clang/lib/Lex/Preprocessor.cpp2
-rw-r--r--clang/lib/Parse/ParseExprCXX.cpp2
-rw-r--r--clang/lib/Parse/ParsePragma.cpp10
-rw-r--r--clang/lib/Parse/ParseTemplate.cpp6
-rw-r--r--clang/lib/Sema/SemaAttr.cpp2
-rw-r--r--clang/lib/Sema/SemaAvailability.cpp8
-rw-r--r--clang/lib/Sema/SemaCodeComplete.cpp10
-rw-r--r--clang/lib/Sema/SemaDecl.cpp24
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp2
-rw-r--r--clang/lib/Sema/SemaExpr.cpp8
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp2
-rwxr-xr-xclang/lib/Sema/SemaTemplate.cpp2
-rw-r--r--clang/lib/Serialization/ASTReader.cpp46
-rw-r--r--clang/lib/Serialization/ASTWriter.cpp2
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp2
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp4
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp2
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp4
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp2
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp2
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp2
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp2
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/ReturnValueChecker.cpp4
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp4
-rw-r--r--clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp9
-rw-r--r--clang/lib/StaticAnalyzer/Core/ExprEngine.cpp5
-rw-r--r--clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp8
-rw-r--r--clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp2
-rw-r--r--clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp2
-rw-r--r--clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp5
-rw-r--r--clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp7
-rw-r--r--clang/lib/Tooling/ASTDiff/ASTDiff.cpp18
-rw-r--r--clang/lib/Tooling/CompilationDatabase.cpp8
-rw-r--r--clang/lib/Tooling/Core/Diagnostic.cpp2
-rw-r--r--clang/lib/Tooling/Core/Lookup.cpp9
-rw-r--r--clang/lib/Tooling/Core/Replacement.cpp12
-rw-r--r--clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp4
-rw-r--r--clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp2
-rw-r--r--clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp14
-rw-r--r--clang/lib/Tooling/FileMatchTrie.cpp2
-rw-r--r--clang/lib/Tooling/Inclusions/HeaderIncludes.cpp5
-rw-r--r--clang/lib/Tooling/InterpolatingCompilationDatabase.cpp6
-rw-r--r--clang/lib/Tooling/JSONCompilationDatabase.cpp2
-rw-r--r--clang/lib/Tooling/Refactoring/AtomicChange.cpp6
-rw-r--r--clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp3
-rw-r--r--clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp2
-rw-r--r--clang/lib/Tooling/RefactoringCallbacks.cpp22
-rw-r--r--clang/lib/Tooling/Syntax/BuildTree.cpp6
-rw-r--r--clang/lib/Tooling/Syntax/Tokens.cpp14
-rw-r--r--clang/lib/Tooling/Tooling.cpp2
-rw-r--r--clang/lib/Tooling/Transformer/Stencil.cpp18
-rw-r--r--clang/tools/c-index-test/core_main.cpp5
-rw-r--r--clang/tools/clang-diff/ClangDiff.cpp2
-rw-r--r--clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp4
-rw-r--r--clang/tools/clang-scan-deps/ClangScanDeps.cpp10
-rw-r--r--clang/tools/diagtool/DiagTool.cpp5
-rw-r--r--clang/tools/driver/cc1as_main.cpp23
-rw-r--r--clang/tools/driver/driver.cpp6
-rw-r--r--clang/tools/libclang/CIndexDiagnostic.cpp8
-rw-r--r--clang/tools/libclang/CIndexer.cpp5
-rw-r--r--clang/tools/libclang/CIndexer.h2
-rw-r--r--clang/tools/libclang/CLog.h2
-rw-r--r--clang/tools/libclang/Indexing.cpp4
-rw-r--r--clang/unittests/AST/ASTImporterFixtures.cpp4
-rw-r--r--clang/unittests/AST/ASTImporterTest.cpp4
-rw-r--r--clang/unittests/AST/DeclPrinterTest.cpp17
-rw-r--r--clang/unittests/AST/NamedDeclPrinterTest.cpp44
-rw-r--r--clang/unittests/AST/StmtPrinterTest.cpp2
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersTest.h12
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp16
-rw-r--r--clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp5
-rw-r--r--clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp2
-rw-r--r--clang/unittests/Basic/SourceManagerTest.cpp2
-rw-r--r--clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp4
-rw-r--r--clang/unittests/Frontend/ASTUnitTest.cpp2
-rw-r--r--clang/unittests/Frontend/CompilerInstanceTest.cpp4
-rw-r--r--clang/unittests/Frontend/FrontendActionTest.cpp3
-rw-r--r--clang/unittests/Index/IndexTests.cpp2
-rw-r--r--clang/unittests/Lex/LexerTest.cpp2
-rw-r--r--clang/unittests/Rename/ClangRenameTest.h4
-rw-r--r--clang/unittests/Sema/ExternalSemaSourceTest.cpp2
-rw-r--r--clang/unittests/StaticAnalyzer/Reusables.h2
-rw-r--r--clang/unittests/Tooling/CompilationDatabaseTest.cpp12
-rw-r--r--clang/unittests/Tooling/DependencyScannerTest.cpp27
-rw-r--r--clang/unittests/Tooling/ExecutionTest.cpp4
-rw-r--r--clang/unittests/Tooling/HeaderIncludesTest.cpp2
-rw-r--r--clang/unittests/Tooling/RangeSelectorTest.cpp64
-rw-r--r--clang/unittests/Tooling/RecursiveASTVisitorTestPostOrderVisitor.cpp4
-rw-r--r--clang/unittests/Tooling/RefactoringTest.cpp23
-rw-r--r--clang/unittests/Tooling/RewriterTestContext.h5
-rw-r--r--clang/unittests/Tooling/SourceCodeBuildersTest.cpp2
-rw-r--r--clang/unittests/Tooling/StencilTest.cpp13
-rw-r--r--clang/unittests/Tooling/Syntax/TreeTest.cpp3
-rw-r--r--clang/unittests/Tooling/ToolingTest.cpp9
-rw-r--r--clang/unittests/Tooling/TransformerTest.cpp71
-rw-r--r--clang/unittests/libclang/TestUtils.h6
-rw-r--r--clang/utils/TableGen/ClangASTNodesEmitter.cpp6
-rw-r--r--clang/utils/TableGen/ClangAttrEmitter.cpp125
-rw-r--r--clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp2
-rw-r--r--clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp2
-rw-r--r--clang/utils/TableGen/ClangCommentHTMLTagsEmitter.cpp2
-rw-r--r--clang/utils/TableGen/ClangDiagnosticsEmitter.cpp68
-rw-r--r--clang/utils/TableGen/ClangOptionDocEmitter.cpp12
-rw-r--r--clang/utils/TableGen/ClangSACheckersEmitter.cpp2
-rw-r--r--clang/utils/TableGen/MveEmitter.cpp41
-rw-r--r--clang/utils/TableGen/NeonEmitter.cpp61
-rw-r--r--lld/COFF/DebugTypes.cpp4
-rw-r--r--lld/COFF/Driver.cpp29
-rw-r--r--lld/COFF/DriverUtils.cpp16
-rw-r--r--lld/COFF/InputFiles.cpp8
-rw-r--r--lld/COFF/LTO.cpp9
-rw-r--r--lld/COFF/PDB.cpp2
-rw-r--r--lld/COFF/Symbols.cpp6
-rw-r--r--lld/Common/ErrorHandler.cpp4
-rw-r--r--lld/Common/Reproduce.cpp6
-rw-r--r--lld/Common/Strings.cpp4
-rw-r--r--lld/Common/Timer.cpp4
-rw-r--r--lld/ELF/DriverUtils.cpp4
-rw-r--r--lld/ELF/InputFiles.cpp10
-rw-r--r--lld/ELF/InputFiles.h6
-rw-r--r--lld/ELF/InputSection.cpp4
-rw-r--r--lld/ELF/LTO.cpp25
-rw-r--r--lld/ELF/LinkerScript.cpp4
-rw-r--r--lld/ELF/LinkerScript.h2
-rw-r--r--lld/ELF/Relocations.cpp2
-rw-r--r--lld/ELF/ScriptLexer.cpp2
-rw-r--r--lld/ELF/ScriptParser.cpp4
-rw-r--r--lld/ELF/Symbols.cpp2
-rw-r--r--lld/ELF/Target.cpp2
-rw-r--r--lld/include/lld/Core/File.h2
-rw-r--r--lld/lib/Core/Error.cpp3
-rw-r--r--lld/lib/Driver/DarwinLdDriver.cpp4
-rw-r--r--lld/lib/ReaderWriter/MachO/Atoms.h4
-rw-r--r--lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp6
-rw-r--r--lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp6
-rw-r--r--lld/unittests/DriverTests/DarwinLdDriverTest.cpp2
-rw-r--r--lld/wasm/Driver.cpp4
-rw-r--r--lld/wasm/InputFiles.cpp2
-rw-r--r--lld/wasm/InputFiles.h4
-rw-r--r--lld/wasm/OutputSections.cpp2
-rw-r--r--lld/wasm/Symbols.cpp2
-rw-r--r--lld/wasm/SyntheticSections.h3
-rw-r--r--lld/wasm/Writer.cpp17
-rw-r--r--lld/wasm/WriterUtils.cpp2
-rw-r--r--lldb/include/lldb/DataFormatters/FormatClasses.h4
-rw-r--r--lldb/include/lldb/Expression/DiagnosticManager.h2
-rw-r--r--lldb/include/lldb/Interpreter/CommandObject.h2
-rw-r--r--lldb/include/lldb/Target/Process.h4
-rw-r--r--lldb/include/lldb/Target/ThreadSpec.h6
-rw-r--r--lldb/include/lldb/Utility/AnsiTerminal.h2
-rw-r--r--lldb/include/lldb/Utility/Environment.h3
-rw-r--r--lldb/include/lldb/Utility/Reproducer.h2
-rw-r--r--lldb/include/lldb/Utility/StringExtractor.h2
-rw-r--r--lldb/include/lldb/Utility/StructuredData.h2
-rw-r--r--lldb/source/API/SBDebugger.cpp2
-rw-r--r--lldb/source/API/SBStream.cpp9
-rw-r--r--lldb/source/API/SBValue.cpp2
-rw-r--r--lldb/source/Breakpoint/BreakpointIDList.cpp2
-rw-r--r--lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp2
-rw-r--r--lldb/source/Breakpoint/BreakpointResolverName.cpp2
-rw-r--r--lldb/source/Breakpoint/BreakpointResolverScripted.cpp7
-rw-r--r--lldb/source/Commands/CommandCompletions.cpp4
-rw-r--r--lldb/source/Commands/CommandObjectBreakpoint.cpp28
-rw-r--r--lldb/source/Commands/CommandObjectBreakpointCommand.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectCommands.cpp28
-rw-r--r--lldb/source/Commands/CommandObjectDisassemble.cpp6
-rw-r--r--lldb/source/Commands/CommandObjectExpression.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectHelp.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectLog.cpp4
-rw-r--r--lldb/source/Commands/CommandObjectMultiword.cpp14
-rw-r--r--lldb/source/Commands/CommandObjectPlatform.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectProcess.cpp8
-rw-r--r--lldb/source/Commands/CommandObjectSettings.cpp4
-rw-r--r--lldb/source/Commands/CommandObjectSource.cpp8
-rw-r--r--lldb/source/Commands/CommandObjectTarget.cpp28
-rw-r--r--lldb/source/Commands/CommandObjectThread.cpp4
-rw-r--r--lldb/source/Commands/CommandObjectType.cpp16
-rw-r--r--lldb/source/Commands/CommandObjectWatchpoint.cpp4
-rw-r--r--lldb/source/Commands/CommandObjectWatchpointCommand.cpp4
-rw-r--r--lldb/source/Core/Disassembler.cpp2
-rw-r--r--lldb/source/Core/DumpRegisterValue.cpp2
-rw-r--r--lldb/source/Core/IOHandler.cpp7
-rw-r--r--lldb/source/Core/Module.cpp10
-rw-r--r--lldb/source/Core/PluginManager.cpp3
-rw-r--r--lldb/source/Core/ValueObject.cpp4
-rw-r--r--lldb/source/DataFormatters/TypeCategory.cpp2
-rw-r--r--lldb/source/DataFormatters/TypeFormat.cpp10
-rw-r--r--lldb/source/DataFormatters/TypeSummary.cpp12
-rw-r--r--lldb/source/DataFormatters/TypeSynthetic.cpp6
-rw-r--r--lldb/source/Expression/DiagnosticManager.cpp2
-rw-r--r--lldb/source/Expression/IRInterpreter.cpp4
-rw-r--r--lldb/source/Expression/UserExpression.cpp9
-rw-r--r--lldb/source/Host/common/Editline.cpp4
-rw-r--r--lldb/source/Host/common/OptionParser.cpp2
-rw-r--r--lldb/source/Host/common/ProcessLaunchInfo.cpp2
-rw-r--r--lldb/source/Host/common/Socket.cpp2
-rw-r--r--lldb/source/Host/common/TCPSocket.cpp4
-rw-r--r--lldb/source/Host/common/UDPSocket.cpp4
-rw-r--r--lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp12
-rw-r--r--lldb/source/Host/posix/DomainSocket.cpp8
-rw-r--r--lldb/source/Interpreter/CommandAlias.cpp2
-rw-r--r--lldb/source/Interpreter/CommandHistory.cpp2
-rw-r--r--lldb/source/Interpreter/CommandInterpreter.cpp82
-rw-r--r--lldb/source/Interpreter/CommandObject.cpp37
-rw-r--r--lldb/source/Interpreter/CommandReturnObject.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupArchitecture.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupPlatform.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp4
-rw-r--r--lldb/source/Interpreter/OptionValueFormatEntity.cpp2
-rw-r--r--lldb/source/Interpreter/OptionValueString.cpp4
-rw-r--r--lldb/source/Interpreter/Options.cpp6
-rw-r--r--lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp4
-rw-r--r--lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp13
-rw-r--r--lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp4
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp5
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp2
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp2
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp2
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp6
-rw-r--r--lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp8
-rw-r--r--lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp8
-rw-r--r--lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp42
-rw-r--r--lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp3
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp2
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp6
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp32
-rw-r--r--lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp2
-rw-r--r--lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp2
-rw-r--r--lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp2
-rw-r--r--lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp2
-rw-r--r--lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp2
-rw-r--r--lldb/source/Plugins/Platform/Android/AdbClient.cpp4
-rw-r--r--lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp2
-rw-r--r--lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp2
-rw-r--r--lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp2
-rw-r--r--lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp4
-rw-r--r--lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp13
-rw-r--r--lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/ThreadMemory.cpp3
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp2
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp2
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp35
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp2
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp2
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp47
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h2
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp4
-rw-r--r--lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp6
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp2
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp14
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp8
-rw-r--r--lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp24
-rw-r--r--lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp8
-rw-r--r--lldb/source/Symbol/TypeList.cpp3
-rw-r--r--lldb/source/Symbol/TypeMap.cpp3
-rw-r--r--lldb/source/Symbol/TypeSystemClang.cpp2
-rw-r--r--lldb/source/Symbol/Variable.cpp4
-rw-r--r--lldb/source/Target/Platform.cpp8
-rw-r--r--lldb/source/Target/StackFrameRecognizer.cpp5
-rw-r--r--lldb/source/Target/StopInfo.cpp10
-rw-r--r--lldb/source/Target/Thread.cpp2
-rw-r--r--lldb/source/Utility/Args.cpp6
-rw-r--r--lldb/source/Utility/Log.cpp2
-rw-r--r--lldb/source/Utility/ProcessInfo.cpp2
-rw-r--r--lldb/source/Utility/RegisterValue.cpp2
-rw-r--r--lldb/source/Utility/RegularExpression.cpp2
-rw-r--r--lldb/source/Utility/Status.cpp4
-rw-r--r--lldb/source/Utility/StringList.cpp2
-rw-r--r--lldb/tools/lldb-server/Acceptor.cpp2
-rw-r--r--lldb/tools/lldb-vscode/BreakpointBase.cpp6
-rw-r--r--lldb/tools/lldb-vscode/FunctionBreakpoint.cpp2
-rw-r--r--lldb/tools/lldb-vscode/lldb-vscode.cpp12
-rw-r--r--lldb/unittests/Host/FileSystemTest.cpp10
-rw-r--r--lldb/unittests/Interpreter/TestCompletion.cpp2
-rw-r--r--lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp2
-rw-r--r--lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp2
-rw-r--r--lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp2
-rw-r--r--lldb/unittests/Symbol/PostfixExpressionTest.cpp17
-rw-r--r--lldb/unittests/TestingSupport/TestUtilities.cpp2
-rw-r--r--lldb/unittests/TestingSupport/TestUtilities.h3
-rw-r--r--lldb/utils/TableGen/LLDBOptionDefEmitter.cpp8
-rw-r--r--llvm/include/llvm/ADT/StringRef.h4
-rw-r--r--llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h2
-rw-r--r--llvm/include/llvm/Analysis/RegionInfoImpl.h4
-rw-r--r--llvm/include/llvm/Analysis/TargetLibraryInfo.h2
-rw-r--r--llvm/include/llvm/CodeGen/CommandFlags.inc3
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h15
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h2
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h2
-rw-r--r--llvm/include/llvm/IR/InstrTypes.h2
-rw-r--r--llvm/include/llvm/IR/Module.h8
-rw-r--r--llvm/include/llvm/IR/ModuleSummaryIndex.h8
-rw-r--r--llvm/include/llvm/IR/ModuleSummaryIndexYAML.h2
-rw-r--r--llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h4
-rw-r--r--llvm/include/llvm/MC/MCAssembler.h2
-rw-r--r--llvm/include/llvm/MC/MCContext.h2
-rw-r--r--llvm/include/llvm/MC/MCDwarf.h8
-rw-r--r--llvm/include/llvm/MC/MCSymbolWasm.h12
-rw-r--r--llvm/include/llvm/MC/SubtargetFeature.h2
-rw-r--r--llvm/include/llvm/Object/MachO.h2
-rw-r--r--llvm/include/llvm/Object/TapiUniversal.h2
-rw-r--r--llvm/include/llvm/Option/Option.h2
-rw-r--r--llvm/include/llvm/ProfileData/InstrProf.h2
-rw-r--r--llvm/include/llvm/Support/DebugCounter.h2
-rw-r--r--llvm/include/llvm/Support/GraphWriter.h2
-rw-r--r--llvm/include/llvm/Support/JSON.h4
-rw-r--r--llvm/include/llvm/Support/SmallVectorMemoryBuffer.h2
-rw-r--r--llvm/include/llvm/Support/YAMLTraits.h2
-rw-r--r--llvm/include/llvm/TableGen/Record.h10
-rw-r--r--llvm/include/llvm/TableGen/StringToOffsetTable.h2
-rw-r--r--llvm/include/llvm/TextAPI/MachO/InterfaceFile.h6
-rw-r--r--llvm/lib/Analysis/CallPrinter.cpp2
-rw-r--r--llvm/lib/Analysis/LazyCallGraph.cpp5
-rw-r--r--llvm/lib/Analysis/VFABIDemangling.cpp2
-rw-r--r--llvm/lib/Analysis/VectorUtils.cpp2
-rw-r--r--llvm/lib/AsmParser/LLParser.cpp4
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp2
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp10
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp4
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp17
-rw-r--r--llvm/lib/CodeGen/FEntryInserter.cpp4
-rw-r--r--llvm/lib/CodeGen/GCMetadata.cpp2
-rw-r--r--llvm/lib/CodeGen/GlobalMerge.cpp2
-rw-r--r--llvm/lib/CodeGen/MIRParser/MIParser.cpp4
-rw-r--r--llvm/lib/CodeGen/MIRPrinter.cpp4
-rw-r--r--llvm/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp2
-rw-r--r--llvm/lib/CodeGen/MachineOutliner.cpp2
-rw-r--r--llvm/lib/CodeGen/MachineScheduler.cpp2
-rw-r--r--llvm/lib/CodeGen/ScheduleDAGPrinter.cpp2
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp2
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp2
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp4
-rw-r--r--llvm/lib/DWARFLinker/DWARFLinker.cpp4
-rw-r--r--llvm/lib/DebugInfo/CodeView/RecordName.cpp2
-rw-r--r--llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp39
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp5
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp4
-rw-r--r--llvm/lib/DebugInfo/GSYM/LookupResult.cpp4
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp6
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp4
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp6
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp2
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/NativeSymbolEnumerator.cpp4
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp2
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/NativeTypeTypedef.cpp4
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp2
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp3
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp2
-rw-r--r--llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp2
-rw-r--r--llvm/lib/DebugInfo/Symbolize/Symbolize.cpp20
-rw-r--r--llvm/lib/ExecutionEngine/ExecutionEngine.cpp26
-rw-r--r--llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp4
-rw-r--r--llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp4
-rw-r--r--llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp2
-rw-r--r--llvm/lib/ExecutionEngine/Orc/Core.cpp4
-rw-r--r--llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp2
-rw-r--r--llvm/lib/ExecutionEngine/Orc/OrcCBindingsStack.h4
-rw-r--r--llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h9
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h2
-rw-r--r--llvm/lib/FuzzMutate/FuzzerCLI.cpp4
-rw-r--r--llvm/lib/IR/AsmWriter.cpp2
-rw-r--r--llvm/lib/IR/AttributeImpl.h3
-rw-r--r--llvm/lib/IR/Attributes.cpp4
-rw-r--r--llvm/lib/IR/AutoUpgrade.cpp10
-rw-r--r--llvm/lib/IR/ConstantsContext.h4
-rw-r--r--llvm/lib/IR/DataLayout.cpp2
-rw-r--r--llvm/lib/IR/DiagnosticInfo.cpp29
-rw-r--r--llvm/lib/IR/Globals.cpp2
-rw-r--r--llvm/lib/IR/InlineAsm.cpp10
-rw-r--r--llvm/lib/IR/LegacyPassManager.cpp5
-rw-r--r--llvm/lib/IR/Module.cpp3
-rw-r--r--llvm/lib/LTO/Caching.cpp2
-rw-r--r--llvm/lib/LTO/LTO.cpp14
-rw-r--r--llvm/lib/LTO/LTOCodeGenerator.cpp2
-rw-r--r--llvm/lib/LTO/ThinLTOCodeGenerator.cpp6
-rw-r--r--llvm/lib/LineEditor/LineEditor.cpp4
-rw-r--r--llvm/lib/MC/MCContext.cpp6
-rw-r--r--llvm/lib/MC/MCDwarf.cpp4
-rw-r--r--llvm/lib/MC/MCParser/AsmParser.cpp2
-rw-r--r--llvm/lib/MC/MCParser/DarwinAsmParser.cpp2
-rw-r--r--llvm/lib/MC/MCSubtargetInfo.cpp20
-rw-r--r--llvm/lib/MC/SubtargetFeature.cpp4
-rw-r--r--llvm/lib/MC/WinCOFFObjectWriter.cpp2
-rw-r--r--llvm/lib/MCA/InstrBuilder.cpp2
-rw-r--r--llvm/lib/Object/Archive.cpp4
-rw-r--r--llvm/lib/Object/ArchiveWriter.cpp2
-rw-r--r--llvm/lib/Object/COFFImportFile.cpp2
-rw-r--r--llvm/lib/Object/COFFModuleDefinition.cpp8
-rw-r--r--llvm/lib/Object/IRSymtab.cpp2
-rw-r--r--llvm/lib/Object/WasmObjectFile.cpp2
-rw-r--r--llvm/lib/Object/WindowsResource.cpp4
-rw-r--r--llvm/lib/Option/Arg.cpp2
-rw-r--r--llvm/lib/Option/ArgList.cpp2
-rw-r--r--llvm/lib/Option/OptTable.cpp6
-rw-r--r--llvm/lib/Passes/StandardInstrumentations.cpp4
-rw-r--r--llvm/lib/ProfileData/GCOV.cpp4
-rw-r--r--llvm/lib/ProfileData/InstrProf.cpp4
-rw-r--r--llvm/lib/ProfileData/SampleProfReader.cpp8
-rw-r--r--llvm/lib/Remarks/BitstreamRemarkParser.cpp2
-rw-r--r--llvm/lib/Remarks/RemarkLinker.cpp2
-rw-r--r--llvm/lib/Remarks/YAMLRemarkParser.h2
-rw-r--r--llvm/lib/Support/APInt.cpp2
-rw-r--r--llvm/lib/Support/CommandLine.cpp6
-rw-r--r--llvm/lib/Support/Debug.cpp2
-rw-r--r--llvm/lib/Support/DebugCounter.cpp6
-rw-r--r--llvm/lib/Support/FileCheck.cpp4
-rw-r--r--llvm/lib/Support/FileCollector.cpp2
-rw-r--r--llvm/lib/Support/GraphWriter.cpp4
-rw-r--r--llvm/lib/Support/LockFileManager.cpp8
-rw-r--r--llvm/lib/Support/Path.cpp7
-rw-r--r--llvm/lib/Support/Process.cpp2
-rw-r--r--llvm/lib/Support/Regex.cpp2
-rw-r--r--llvm/lib/Support/Signals.cpp2
-rw-r--r--llvm/lib/Support/SourceMgr.cpp14
-rw-r--r--llvm/lib/Support/SpecialCaseList.cpp4
-rw-r--r--llvm/lib/Support/TarWriter.cpp3
-rw-r--r--llvm/lib/Support/TimeProfiler.cpp7
-rw-r--r--llvm/lib/Support/Timer.cpp3
-rw-r--r--llvm/lib/Support/ToolOutputFile.cpp2
-rw-r--r--llvm/lib/Support/Unix/Host.inc2
-rw-r--r--llvm/lib/Support/Unix/Program.inc11
-rw-r--r--llvm/lib/Support/VirtualFileSystem.cpp21
-rw-r--r--llvm/lib/Support/YAMLParser.cpp6
-rw-r--r--llvm/lib/TableGen/Record.cpp15
-rw-r--r--llvm/lib/TableGen/SetTheory.cpp2
-rw-r--r--llvm/lib/TableGen/TGParser.cpp2
-rw-r--r--llvm/lib/Target/AArch64/AArch64SIMDInstrOpt.cpp5
-rw-r--r--llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp11
-rw-r--r--llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp2
-rw-r--r--llvm/lib/Target/AMDGPU/AMDGPULibFunc.cpp4
-rw-r--r--llvm/lib/Target/AMDGPU/AMDGPULibFunc.h4
-rw-r--r--llvm/lib/Target/AMDGPU/AMDGPUPropagateAttributes.cpp2
-rw-r--r--llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp2
-rw-r--r--llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp2
-rw-r--r--llvm/lib/Target/ARM/ARMAsmPrinter.cpp5
-rw-r--r--llvm/lib/Target/ARM/ARMConstantPoolValue.cpp2
-rw-r--r--llvm/lib/Target/ARM/ARMISelLowering.cpp2
-rw-r--r--llvm/lib/Target/ARM/ARMSubtarget.cpp2
-rw-r--r--llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp28
-rw-r--r--llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp2
-rw-r--r--llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp4
-rw-r--r--llvm/lib/Target/BPF/BPFTargetMachine.cpp2
-rw-r--r--llvm/lib/Target/BPF/BTFDebug.cpp20
-rw-r--r--llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp4
-rw-r--r--llvm/lib/Target/Hexagon/HexagonSubtarget.cpp5
-rw-r--r--llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp2
-rw-r--r--llvm/lib/Target/Lanai/LanaiSubtarget.cpp2
-rw-r--r--llvm/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp2
-rw-r--r--llvm/lib/Target/MSP430/MSP430Subtarget.cpp2
-rw-r--r--llvm/lib/Target/MSP430/MSP430TargetMachine.cpp2
-rw-r--r--llvm/lib/Target/Mips/Mips16HardFloat.cpp4
-rw-r--r--llvm/lib/Target/Mips/MipsRegisterBankInfo.cpp2
-rw-r--r--llvm/lib/Target/Mips/MipsSubtarget.cpp2
-rw-r--r--llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp4
-rw-r--r--llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp2
-rw-r--r--llvm/lib/Target/NVPTX/NVPTXReplaceImageHandles.cpp2
-rw-r--r--llvm/lib/Target/NVPTX/NVPTXSubtarget.cpp10
-rw-r--r--llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp2
-rw-r--r--llvm/lib/Target/NVPTX/NVPTXUtilities.cpp6
-rw-r--r--llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp4
-rw-r--r--llvm/lib/Target/PowerPC/PPCSubtarget.cpp2
-rw-r--r--llvm/lib/Target/PowerPC/PPCTargetMachine.cpp2
-rw-r--r--llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp2
-rw-r--r--llvm/lib/Target/RISCV/RISCVSubtarget.cpp2
-rw-r--r--llvm/lib/Target/Sparc/SparcSubtarget.cpp2
-rw-r--r--llvm/lib/Target/Sparc/SparcTargetMachine.cpp3
-rw-r--r--llvm/lib/Target/SystemZ/SystemZSubtarget.cpp2
-rw-r--r--llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp2
-rw-r--r--llvm/lib/Target/TargetMachine.cpp8
-rw-r--r--llvm/lib/Target/TargetMachineC.cpp4
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyAddMissingPrototypes.cpp2
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp4
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp4
-rw-r--r--llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp2
-rw-r--r--llvm/lib/Target/X86/X86Subtarget.cpp4
-rw-r--r--llvm/lib/Target/XCore/XCoreTargetMachine.cpp2
-rw-r--r--llvm/lib/TextAPI/MachO/ArchitectureSet.cpp2
-rw-r--r--llvm/lib/TextAPI/MachO/InterfaceFile.cpp4
-rw-r--r--llvm/lib/TextAPI/MachO/TextStub.cpp4
-rw-r--r--llvm/lib/TextAPI/MachO/TextStubCommon.cpp2
-rw-r--r--llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp2
-rw-r--r--llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp2
-rw-r--r--llvm/lib/Transforms/IPO/ArgumentPromotion.cpp2
-rw-r--r--llvm/lib/Transforms/IPO/BlockExtractor.cpp3
-rw-r--r--llvm/lib/Transforms/IPO/FunctionImport.cpp7
-rw-r--r--llvm/lib/Transforms/IPO/LowerTypeTests.cpp11
-rw-r--r--llvm/lib/Transforms/IPO/SampleProfile.cpp2
-rw-r--r--llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp8
-rw-r--r--llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp2
-rw-r--r--llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp2
-rw-r--r--llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp13
-rw-r--r--llvm/lib/Transforms/Instrumentation/Instrumentation.cpp2
-rw-r--r--llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp6
-rw-r--r--llvm/lib/Transforms/Scalar/LoopDeletion.cpp2
-rw-r--r--llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp4
-rw-r--r--llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp4
-rw-r--r--llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp2
-rw-r--r--llvm/lib/Transforms/Utils/InjectTLIMappings.cpp7
-rw-r--r--llvm/lib/Transforms/Utils/InlineFunction.cpp2
-rw-r--r--llvm/lib/Transforms/Utils/NameAnonGlobals.cpp2
-rw-r--r--llvm/lib/Transforms/Utils/SSAUpdater.cpp2
-rw-r--r--llvm/lib/Transforms/Utils/SymbolRewriter.cpp30
-rw-r--r--llvm/lib/XRay/FDRTraceExpander.cpp6
-rw-r--r--llvm/tools/bugpoint/CrashDebugger.cpp2
-rw-r--r--llvm/tools/bugpoint/ExecutionDriver.cpp4
-rw-r--r--llvm/tools/bugpoint/Miscompilation.cpp21
-rw-r--r--llvm/tools/bugpoint/OptimizerDriver.cpp2
-rw-r--r--llvm/tools/bugpoint/ToolRunner.cpp4
-rw-r--r--llvm/tools/bugpoint/ToolRunner.h2
-rw-r--r--llvm/tools/bugpoint/bugpoint.cpp4
-rw-r--r--llvm/tools/dsymutil/BinaryHolder.cpp4
-rw-r--r--llvm/tools/dsymutil/DebugMap.cpp5
-rw-r--r--llvm/tools/dsymutil/DebugMap.h6
-rw-r--r--llvm/tools/dsymutil/MachODebugMapParser.cpp11
-rw-r--r--llvm/tools/dsymutil/MachOUtils.cpp2
-rw-r--r--llvm/tools/dsymutil/MachOUtils.h2
-rw-r--r--llvm/tools/dsymutil/dsymutil.cpp15
-rw-r--r--llvm/tools/gold/gold-plugin.cpp30
-rw-r--r--llvm/tools/llc/llc.cpp8
-rw-r--r--llvm/tools/lli/lli.cpp2
-rw-r--r--llvm/tools/llvm-ar/llvm-ar.cpp6
-rw-r--r--llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp11
-rw-r--r--llvm/tools/llvm-config/llvm-config.cpp7
-rw-r--r--llvm/tools/llvm-cov/CodeCoverage.cpp10
-rw-r--r--llvm/tools/llvm-cov/CoverageSummaryInfo.cpp2
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageView.cpp4
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp8
-rw-r--r--llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp4
-rw-r--r--llvm/tools/llvm-dwarfdump/Statistics.cpp2
-rw-r--r--llvm/tools/llvm-elfabi/ELFObjHandler.cpp6
-rw-r--r--llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp4
-rw-r--r--llvm/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp6
-rw-r--r--llvm/tools/llvm-exegesis/lib/SnippetGenerator.cpp3
-rw-r--r--llvm/tools/llvm-ifs/llvm-ifs.cpp2
-rw-r--r--llvm/tools/llvm-link/llvm-link.cpp2
-rw-r--r--llvm/tools/llvm-lipo/llvm-lipo.cpp7
-rw-r--r--llvm/tools/llvm-lto/llvm-lto.cpp4
-rw-r--r--llvm/tools/llvm-lto2/llvm-lto2.cpp15
-rw-r--r--llvm/tools/llvm-mc/llvm-mc.cpp2
-rw-r--r--llvm/tools/llvm-mca/llvm-mca.cpp2
-rw-r--r--llvm/tools/llvm-ml/llvm-ml.cpp2
-rw-r--r--llvm/tools/llvm-nm/llvm-nm.cpp6
-rw-r--r--llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp4
-rw-r--r--llvm/tools/llvm-objcopy/ELF/Object.cpp2
-rw-r--r--llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp2
-rw-r--r--llvm/tools/llvm-objcopy/MachO/Object.h4
-rw-r--r--llvm/tools/llvm-objdump/ELFDump.cpp2
-rw-r--r--llvm/tools/llvm-objdump/MachODump.cpp2
-rw-r--r--llvm/tools/llvm-objdump/llvm-objdump.cpp6
-rw-r--r--llvm/tools/llvm-opt-report/OptReport.cpp9
-rw-r--r--llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp4
-rw-r--r--llvm/tools/llvm-pdbutil/FormatUtil.cpp12
-rw-r--r--llvm/tools/llvm-pdbutil/MinimalSymbolDumper.cpp4
-rw-r--r--llvm/tools/llvm-pdbutil/MinimalTypeDumper.cpp5
-rw-r--r--llvm/tools/llvm-pdbutil/StreamUtil.cpp6
-rw-r--r--llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp2
-rw-r--r--llvm/tools/llvm-profdata/llvm-profdata.cpp21
-rw-r--r--llvm/tools/llvm-rc/llvm-rc.cpp2
-rw-r--r--llvm/tools/llvm-readobj/COFFDumper.cpp2
-rw-r--r--llvm/tools/llvm-readobj/ELFDumper.cpp30
-rw-r--r--llvm/tools/llvm-readobj/ObjDumper.cpp2
-rw-r--r--llvm/tools/llvm-readobj/llvm-readobj.cpp5
-rw-r--r--llvm/tools/llvm-reduce/deltas/Delta.cpp2
-rw-r--r--llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp2
-rw-r--r--llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp6
-rw-r--r--llvm/tools/llvm-undname/llvm-undname.cpp6
-rw-r--r--llvm/tools/llvm-xray/xray-color-helper.cpp4
-rw-r--r--llvm/tools/llvm-xray/xray-graph-diff.cpp12
-rw-r--r--llvm/tools/llvm-xray/xray-stacks.cpp9
-rw-r--r--llvm/tools/obj2yaml/elf2yaml.cpp4
-rw-r--r--llvm/tools/opt/PassPrinters.cpp10
-rw-r--r--llvm/tools/sancov/sancov.cpp8
-rw-r--r--llvm/unittests/ADT/TripleTest.cpp4
-rw-r--r--llvm/unittests/Analysis/LazyCallGraphTest.cpp22
-rw-r--r--llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp10
-rw-r--r--llvm/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp2
-rw-r--r--llvm/unittests/ExecutionEngine/Orc/LegacyRTDyldObjectLinkingLayerTest.cpp2
-rw-r--r--llvm/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp6
-rw-r--r--llvm/unittests/IR/PassBuilderCallbacksTest.cpp6
-rw-r--r--llvm/unittests/Passes/PluginsTest.cpp2
-rw-r--r--llvm/unittests/ProfileData/SampleProfTest.cpp3
-rw-r--r--llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp2
-rw-r--r--llvm/unittests/Support/FileCheckTest.cpp17
-rw-r--r--llvm/unittests/Support/FileCollectorTest.cpp12
-rw-r--r--llvm/unittests/Support/FileUtilitiesTest.cpp2
-rw-r--r--llvm/unittests/Support/FormatVariadicTest.cpp4
-rw-r--r--llvm/unittests/Support/JSONTest.cpp2
-rw-r--r--llvm/unittests/Support/Path.cpp16
-rw-r--r--llvm/unittests/Support/SpecialCaseListTest.cpp2
-rw-r--r--llvm/unittests/Support/VirtualFileSystemTest.cpp45
-rw-r--r--llvm/unittests/Support/raw_ostream_test.cpp2
-rw-r--r--llvm/unittests/Target/AArch64/InstSizes.cpp5
-rw-r--r--llvm/unittests/Target/ARM/MachineInstrTest.cpp10
-rw-r--r--llvm/unittests/TextAPI/TextStubV1Tests.cpp6
-rw-r--r--llvm/unittests/TextAPI/TextStubV2Tests.cpp6
-rw-r--r--llvm/unittests/TextAPI/TextStubV3Tests.cpp6
-rw-r--r--llvm/unittests/TextAPI/TextStubV4Tests.cpp4
-rw-r--r--llvm/unittests/tools/llvm-exegesis/PerfHelperTest.cpp4
-rw-r--r--llvm/utils/TableGen/AsmMatcherEmitter.cpp35
-rw-r--r--llvm/utils/TableGen/AsmWriterEmitter.cpp35
-rw-r--r--llvm/utils/TableGen/CodeEmitterGen.cpp4
-rw-r--r--llvm/utils/TableGen/CodeGenDAGPatterns.cpp15
-rw-r--r--llvm/utils/TableGen/CodeGenDAGPatterns.h7
-rw-r--r--llvm/utils/TableGen/CodeGenHwModes.cpp2
-rw-r--r--llvm/utils/TableGen/CodeGenInstruction.cpp57
-rw-r--r--llvm/utils/TableGen/CodeGenMapTable.cpp2
-rw-r--r--llvm/utils/TableGen/CodeGenRegisters.cpp29
-rw-r--r--llvm/utils/TableGen/CodeGenSchedule.cpp6
-rw-r--r--llvm/utils/TableGen/CodeGenSchedule.h2
-rw-r--r--llvm/utils/TableGen/CodeGenTarget.cpp17
-rw-r--r--llvm/utils/TableGen/DAGISelMatcherEmitter.cpp3
-rw-r--r--llvm/utils/TableGen/DAGISelMatcherGen.cpp2
-rw-r--r--llvm/utils/TableGen/DFAEmitter.cpp4
-rw-r--r--llvm/utils/TableGen/DFAPacketizerEmitter.cpp12
-rw-r--r--llvm/utils/TableGen/DisassemblerEmitter.cpp8
-rw-r--r--llvm/utils/TableGen/ExegesisEmitter.cpp2
-rw-r--r--llvm/utils/TableGen/FastISelEmitter.cpp28
-rw-r--r--llvm/utils/TableGen/FixedLenDecoderEmitter.cpp37
-rw-r--r--llvm/utils/TableGen/GICombinerEmitter.cpp3
-rw-r--r--llvm/utils/TableGen/GlobalISelEmitter.cpp14
-rw-r--r--llvm/utils/TableGen/InstrDocsEmitter.cpp2
-rw-r--r--llvm/utils/TableGen/InstrInfoEmitter.cpp6
-rw-r--r--llvm/utils/TableGen/OptParserEmitter.cpp7
-rw-r--r--llvm/utils/TableGen/RISCVCompressInstEmitter.cpp2
-rw-r--r--llvm/utils/TableGen/RegisterInfoEmitter.cpp10
-rw-r--r--llvm/utils/TableGen/SearchableTableEmitter.cpp25
-rw-r--r--llvm/utils/TableGen/SubtargetEmitter.cpp9
-rw-r--r--llvm/utils/TableGen/SubtargetFeatureInfo.cpp2
-rw-r--r--llvm/utils/TableGen/X86RecognizableInstr.cpp10
-rw-r--r--mlir/examples/toy/Ch1/toyc.cpp2
-rw-r--r--mlir/examples/toy/Ch2/toyc.cpp2
-rw-r--r--mlir/examples/toy/Ch3/toyc.cpp2
-rw-r--r--mlir/examples/toy/Ch4/toyc.cpp2
-rw-r--r--mlir/examples/toy/Ch5/toyc.cpp2
-rw-r--r--mlir/examples/toy/Ch6/toyc.cpp2
-rw-r--r--mlir/examples/toy/Ch7/toyc.cpp2
-rw-r--r--mlir/include/mlir/Quantizer/Support/Metadata.h2
-rw-r--r--mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp2
-rw-r--r--mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp4
-rw-r--r--mlir/lib/Dialect/SDBM/SDBM.cpp6
-rw-r--r--mlir/lib/Dialect/Traits.cpp3
-rw-r--r--mlir/lib/ExecutionEngine/ExecutionEngine.cpp2
-rw-r--r--mlir/lib/IR/Diagnostics.cpp3
-rw-r--r--mlir/lib/Parser/Parser.cpp2
-rw-r--r--mlir/lib/Pass/Pass.cpp2
-rw-r--r--mlir/lib/Pass/PassTiming.cpp2
-rw-r--r--mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp10
-rw-r--r--mlir/lib/TableGen/Constraint.cpp3
-rw-r--r--mlir/lib/TableGen/OpClass.cpp2
-rw-r--r--mlir/lib/TableGen/Operator.cpp8
-rw-r--r--mlir/lib/TableGen/Pattern.cpp44
-rw-r--r--mlir/lib/TableGen/Predicate.cpp13
-rw-r--r--mlir/lib/Transforms/ViewOpGraph.cpp2
-rw-r--r--mlir/tools/mlir-tblgen/EnumsGen.cpp18
-rw-r--r--mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp32
-rw-r--r--mlir/tools/mlir-tblgen/OpInterfacesGen.cpp2
-rw-r--r--mlir/tools/mlir-tblgen/RewriterGen.cpp45
-rw-r--r--mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp14
-rw-r--r--mlir/tools/mlir-tblgen/StructsGen.cpp2
-rw-r--r--mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp2
-rw-r--r--mlir/unittests/TableGen/FormatTest.cpp43
895 files changed, 3319 insertions, 3014 deletions
diff --git a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
index e80ba52c..a25e3e5 100644
--- a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
+++ b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
@@ -23,7 +23,7 @@ inline std::string
joinNamespaces(const llvm::SmallVectorImpl<StringRef> &Namespaces) {
if (Namespaces.empty())
return "";
- std::string Result = Namespaces.front();
+ std::string Result(Namespaces.front());
for (auto I = Namespaces.begin() + 1, E = Namespaces.end(); I != E; ++I)
Result += ("::" + *I).str();
return Result;
@@ -184,7 +184,7 @@ void addReplacementOrDie(
const SourceManager &SM,
std::map<std::string, tooling::Replacements> *FileToReplacements) {
const auto R = createReplacement(Start, End, ReplacementText, SM);
- auto Err = (*FileToReplacements)[R.getFilePath()].add(R);
+ auto Err = (*FileToReplacements)[std::string(R.getFilePath())].add(R);
if (Err)
llvm_unreachable(llvm::toString(std::move(Err)).c_str());
}
@@ -213,18 +213,18 @@ std::string getShortestQualifiedNameInNamespace(llvm::StringRef DeclName,
DeclName = DeclName.ltrim(':');
NsName = NsName.ltrim(':');
if (DeclName.find(':') == llvm::StringRef::npos)
- return DeclName;
+ return std::string(DeclName);
auto NsNameSplitted = splitSymbolName(NsName);
auto DeclNsSplitted = splitSymbolName(DeclName);
llvm::StringRef UnqualifiedDeclName = DeclNsSplitted.pop_back_val();
// If the Decl is in global namespace, there is no need to shorten it.
if (DeclNsSplitted.empty())
- return UnqualifiedDeclName;
+ return std::string(UnqualifiedDeclName);
// If NsName is the global namespace, we can simply use the DeclName sans
// leading "::".
if (NsNameSplitted.empty())
- return DeclName;
+ return std::string(DeclName);
if (NsNameSplitted.front() != DeclNsSplitted.front()) {
// The DeclName must be fully-qualified, but we still need to decide if a
@@ -233,7 +233,7 @@ std::string getShortestQualifiedNameInNamespace(llvm::StringRef DeclName,
// to avoid conflict.
if (llvm::is_contained(NsNameSplitted, DeclNsSplitted.front()))
return ("::" + DeclName).str();
- return DeclName;
+ return std::string(DeclName);
}
// Since there is already an overlap namespace, we know that `DeclName` can be
// shortened, so we reduce the longest common prefix.
@@ -711,7 +711,7 @@ void ChangeNamespaceTool::moveOldNamespace(
MoveNs.InsertionOffset = SM.getFileOffset(SM.getSpellingLoc(InsertionLoc));
MoveNs.FID = SM.getFileID(Start);
MoveNs.SourceMgr = Result.SourceManager;
- MoveNamespaces[SM.getFilename(Start)].push_back(MoveNs);
+ MoveNamespaces[std::string(SM.getFilename(Start))].push_back(MoveNs);
}
// Removes a class forward declaration from the code in the moved namespace and
@@ -762,7 +762,7 @@ void ChangeNamespaceTool::moveClassForwardDeclaration(
InsertForwardDeclaration InsertFwd;
InsertFwd.InsertionOffset = Insertion.getOffset();
InsertFwd.ForwardDeclText = Insertion.getReplacementText().str();
- InsertFwdDecls[Insertion.getFilePath()].push_back(InsertFwd);
+ InsertFwdDecls[std::string(Insertion.getFilePath())].push_back(InsertFwd);
}
// Replaces a qualified symbol (in \p DeclCtx) that refers to a declaration \p
@@ -816,7 +816,7 @@ void ChangeNamespaceTool::replaceQualifiedSymbolInDeclContext(
->getQualifiedNameAsString())) {
FromDeclNameRef = FromDeclNameRef.drop_front(2);
if (FromDeclNameRef.size() < ReplaceName.size())
- ReplaceName = FromDeclNameRef;
+ ReplaceName = std::string(FromDeclNameRef);
}
}
// Checks if there is any namespace alias declarations that can shorten the
diff --git a/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp b/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp
index a97be99..d54fe73 100644
--- a/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp
+++ b/clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp
@@ -91,7 +91,7 @@ llvm::ErrorOr<std::vector<std::string>> GetWhiteListedSymbolPatterns() {
llvm::StringRef Content = File.get()->getBuffer();
Content.split(Lines, '\n', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
for (auto Line : Lines)
- Patterns.push_back(Line.trim());
+ Patterns.push_back(std::string(Line.trim()));
return Patterns;
}
diff --git a/clang-tools-extra/clang-doc/Representation.cpp b/clang-tools-extra/clang-doc/Representation.cpp
index 29b6807..56d975a 100644
--- a/clang-tools-extra/clang-doc/Representation.cpp
+++ b/clang-tools-extra/clang-doc/Representation.cpp
@@ -286,9 +286,9 @@ ClangDocContext::ClangDocContext(tooling::ExecutionContext *ECtx,
if (SourceRoot.empty())
// If no SourceRoot was provided the current path is used as the default
llvm::sys::fs::current_path(SourceRootDir);
- this->SourceRoot = SourceRootDir.str();
+ this->SourceRoot = std::string(SourceRootDir.str());
if (!RepositoryUrl.empty()) {
- this->RepositoryUrl = RepositoryUrl;
+ this->RepositoryUrl = std::string(RepositoryUrl);
if (!RepositoryUrl.empty() && RepositoryUrl.find("http://") != 0 &&
RepositoryUrl.find("https://") != 0)
this->RepositoryUrl->insert(0, "https://");
diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index ed349d3..eae0d84 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -232,7 +232,7 @@ int main(int argc, const char **argv) {
llvm::sys::path::native(AssetsPath, IndexJS);
llvm::sys::path::append(IndexJS, "index.js");
CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(),
- DefaultStylesheet.str());
+ std::string(DefaultStylesheet.str()));
CDCtx.FilesToCopy.emplace_back(IndexJS.str());
}
diff --git a/clang-tools-extra/clang-include-fixer/InMemorySymbolIndex.cpp b/clang-tools-extra/clang-include-fixer/InMemorySymbolIndex.cpp
index e785893..93b534d 100644
--- a/clang-tools-extra/clang-include-fixer/InMemorySymbolIndex.cpp
+++ b/clang-tools-extra/clang-include-fixer/InMemorySymbolIndex.cpp
@@ -16,12 +16,12 @@ namespace include_fixer {
InMemorySymbolIndex::InMemorySymbolIndex(
const std::vector<SymbolAndSignals> &Symbols) {
for (const auto &Symbol : Symbols)
- LookupTable[Symbol.Symbol.getName()].push_back(Symbol);
+ LookupTable[std::string(Symbol.Symbol.getName())].push_back(Symbol);
}
std::vector<SymbolAndSignals>
InMemorySymbolIndex::search(llvm::StringRef Identifier) {
- auto I = LookupTable.find(Identifier);
+ auto I = LookupTable.find(std::string(Identifier));
if (I != LookupTable.end())
return I->second;
return {};
diff --git a/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp b/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
index 374fcf2..1a76566 100644
--- a/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
+++ b/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
@@ -302,7 +302,7 @@ std::string IncludeFixerSemaSource::minimizeInclude(
StringRef Include, const clang::SourceManager &SourceManager,
clang::HeaderSearch &HeaderSearch) const {
if (!MinimizeIncludePaths)
- return Include;
+ return std::string(Include);
// Get the FileEntry for the include.
StringRef StrippedInclude = Include.trim("\"<>");
@@ -311,7 +311,7 @@ std::string IncludeFixerSemaSource::minimizeInclude(
// If the file doesn't exist return the path from the database.
// FIXME: This should never happen.
if (!Entry)
- return Include;
+ return std::string(Include);
bool IsSystem = false;
std::string Suggestion =
@@ -352,7 +352,8 @@ IncludeFixerSemaSource::query(StringRef Query, StringRef ScopedQualifiers,
if (!GenerateDiagnostics && !QuerySymbolInfos.empty()) {
if (ScopedQualifiers == QuerySymbolInfos.front().ScopedQualifiers &&
Query == QuerySymbolInfos.front().RawIdentifier) {
- QuerySymbolInfos.push_back({Query.str(), ScopedQualifiers, Range});
+ QuerySymbolInfos.push_back(
+ {Query.str(), std::string(ScopedQualifiers), Range});
}
return {};
}
@@ -367,7 +368,8 @@ IncludeFixerSemaSource::query(StringRef Query, StringRef ScopedQualifiers,
CI->getSourceManager().getLocForStartOfFile(
CI->getSourceManager().getMainFileID()));
- QuerySymbolInfos.push_back({Query.str(), ScopedQualifiers, Range});
+ QuerySymbolInfos.push_back(
+ {Query.str(), std::string(ScopedQualifiers), Range});
// Query the symbol based on C++ name Lookup rules.
// Firstly, lookup the identifier with scoped namespace contexts;
diff --git a/clang-tools-extra/clang-include-fixer/IncludeFixer.h b/clang-tools-extra/clang-include-fixer/IncludeFixer.h
index ccab65d..1ec1c50 100644
--- a/clang-tools-extra/clang-include-fixer/IncludeFixer.h
+++ b/clang-tools-extra/clang-include-fixer/IncludeFixer.h
@@ -92,7 +92,9 @@ public:
GenerateDiagnostics(GenerateDiagnostics) {}
void setCompilerInstance(CompilerInstance *CI) { this->CI = CI; }
- void setFilePath(StringRef FilePath) { this->FilePath = FilePath; }
+ void setFilePath(StringRef FilePath) {
+ this->FilePath = std::string(FilePath);
+ }
/// Callback for incomplete types. If we encounter a forward declaration we
/// have the fully qualified name ready. Just query that.
diff --git a/clang-tools-extra/clang-include-fixer/IncludeFixerContext.cpp b/clang-tools-extra/clang-include-fixer/IncludeFixerContext.cpp
index 9bc20f1..073cee4 100644
--- a/clang-tools-extra/clang-include-fixer/IncludeFixerContext.cpp
+++ b/clang-tools-extra/clang-include-fixer/IncludeFixerContext.cpp
@@ -29,7 +29,7 @@ std::string createQualifiedNameForReplacement(
// No need to add missing qualifiers if SymbolIdentifier has a global scope
// operator "::".
if (RawSymbolName.startswith("::"))
- return RawSymbolName;
+ return std::string(RawSymbolName);
std::string QualifiedName = MatchedSymbol.getQualifiedName();
diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
index bb6a3fa..a2a98a2 100644
--- a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
+++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
@@ -251,7 +251,8 @@ void FindAllSymbols::run(const MatchFinder::MatchResult &Result) {
const SourceManager *SM = Result.SourceManager;
if (auto Symbol = CreateSymbolInfo(ND, *SM, Collector)) {
- Filename = SM->getFileEntryForID(SM->getMainFileID())->getName();
+ Filename =
+ std::string(SM->getFileEntryForID(SM->getMainFileID())->getName());
FileSymbols[*Symbol] += Signals;
}
}
diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/HeaderMapCollector.h b/clang-tools-extra/clang-include-fixer/find-all-symbols/HeaderMapCollector.h
index ed2a6d6..300e4f7 100644
--- a/clang-tools-extra/clang-include-fixer/find-all-symbols/HeaderMapCollector.h
+++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/HeaderMapCollector.h
@@ -29,7 +29,7 @@ public:
void addHeaderMapping(llvm::StringRef OrignalHeaderPath,
llvm::StringRef MappingHeaderPath) {
- HeaderMappingTable[OrignalHeaderPath] = MappingHeaderPath;
+ HeaderMappingTable[OrignalHeaderPath] = std::string(MappingHeaderPath);
};
/// Check if there is a mapping from \p Header or a regex pattern that matches
diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/PathConfig.cpp b/clang-tools-extra/clang-include-fixer/find-all-symbols/PathConfig.cpp
index 4f1ebc7..c12e4cf 100644
--- a/clang-tools-extra/clang-include-fixer/find-all-symbols/PathConfig.cpp
+++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/PathConfig.cpp
@@ -34,7 +34,7 @@ std::string getIncludePath(const SourceManager &SM, SourceLocation Loc,
SmallString<256> CleanedFilePath = FilePath;
llvm::sys::path::remove_dots(CleanedFilePath, /*remove_dot_dot=*/false);
- return CleanedFilePath.str();
+ return std::string(CleanedFilePath.str());
}
} // namespace find_all_symbols
diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/SymbolInfo.h b/clang-tools-extra/clang-include-fixer/find-all-symbols/SymbolInfo.h
index 9648d88..7f8fa90 100644
--- a/clang-tools-extra/clang-include-fixer/find-all-symbols/SymbolInfo.h
+++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/SymbolInfo.h
@@ -74,7 +74,7 @@ public:
SymbolInfo(llvm::StringRef Name, SymbolKind Type, llvm::StringRef FilePath,
const std::vector<Context> &Contexts);
- void SetFilePath(llvm::StringRef Path) { FilePath = Path; }
+ void SetFilePath(llvm::StringRef Path) { FilePath = std::string(Path); }
/// Get symbol name.
llvm::StringRef getName() const { return Name; }
diff --git a/clang-tools-extra/clang-include-fixer/plugin/IncludeFixerPlugin.cpp b/clang-tools-extra/clang-include-fixer/plugin/IncludeFixerPlugin.cpp
index 3406a25..7908a89 100644
--- a/clang-tools-extra/clang-include-fixer/plugin/IncludeFixerPlugin.cpp
+++ b/clang-tools-extra/clang-include-fixer/plugin/IncludeFixerPlugin.cpp
@@ -60,7 +60,8 @@ public:
Input = Arg.substr(strlen("-input="));
}
- std::string InputFile = CI.getFrontendOpts().Inputs[0].getFile();
+ std::string InputFile =
+ std::string(CI.getFrontendOpts().Inputs[0].getFile());
auto CreateYamlIdx = [=]() -> std::unique_ptr<include_fixer::SymbolIndex> {
llvm::ErrorOr<std::unique_ptr<include_fixer::YamlSymbolIndex>> SymbolIdx(
nullptr);
diff --git a/clang-tools-extra/clang-move/Move.cpp b/clang-tools-extra/clang-move/Move.cpp
index 1405217..ebeb5d0 100644
--- a/clang-tools-extra/clang-move/Move.cpp
+++ b/clang-tools-extra/clang-move/Move.cpp
@@ -65,7 +65,7 @@ std::string CleanPath(StringRef PathRef) {
llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
// FIXME: figure out why this is necessary.
llvm::sys::path::native(Path);
- return Path.str();
+ return std::string(Path.str());
}
// Make the Path absolute using the CurrentDir if the Path is not an absolute
@@ -785,13 +785,13 @@ void ClangMoveTool::removeDeclsInOldFiles() {
continue;
}
auto CleanReplacements = format::cleanupAroundReplacements(
- Code, Context->FileToReplacements[FilePath], *Style);
+ Code, Context->FileToReplacements[std::string(FilePath)], *Style);
if (!CleanReplacements) {
llvm::errs() << llvm::toString(CleanReplacements.takeError()) << "\n";
continue;
}
- Context->FileToReplacements[FilePath] = *CleanReplacements;
+ Context->FileToReplacements[std::string(FilePath)] = *CleanReplacements;
}
}
@@ -870,7 +870,7 @@ void ClangMoveTool::moveAll(SourceManager &SM, StringRef OldFile,
else if (Context->Spec.NewHeader == NewFile &&
OldHeaderIncludeRangeInHeader.isValid())
ReplaceOldInclude(OldHeaderIncludeRangeInHeader);
- Context->FileToReplacements[NewFile] = std::move(AllCode);
+ Context->FileToReplacements[std::string(NewFile)] = std::move(AllCode);
}
}
diff --git a/clang-tools-extra/clang-move/tool/ClangMove.cpp b/clang-tools-extra/clang-move/tool/ClangMove.cpp
index 214c4f6..7e16dc2 100644
--- a/clang-tools-extra/clang-move/tool/ClangMove.cpp
+++ b/clang-tools-extra/clang-move/tool/ClangMove.cpp
@@ -124,7 +124,8 @@ int main(int argc, const char **argv) {
Twine(EC.message()));
move::ClangMoveContext Context{Spec, Tool.getReplacements(),
- InitialDirectory.str(), Style, DumpDecls};
+ std::string(InitialDirectory.str()), Style,
+ DumpDecls};
move::DeclarationReporter Reporter;
move::ClangMoveActionFactory Factory(&Context, &Reporter);
diff --git a/clang-tools-extra/clang-query/QueryParser.cpp b/clang-tools-extra/clang-query/QueryParser.cpp
index 896145b..ecc189a 100644
--- a/clang-tools-extra/clang-query/QueryParser.cpp
+++ b/clang-tools-extra/clang-query/QueryParser.cpp
@@ -82,7 +82,8 @@ template <typename T> struct QueryParser::LexOrCompleteWord {
CaseStr.substr(0, WordCompletionPos) ==
Word.substr(0, WordCompletionPos))
P->Completions.push_back(LineEditor::Completion(
- (CaseStr.substr(WordCompletionPos) + " ").str(), CaseStr));
+ (CaseStr.substr(WordCompletionPos) + " ").str(),
+ std::string(CaseStr)));
return *this;
}
diff --git a/clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp b/clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp
index 714a214..f3bcc2a 100644
--- a/clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp
+++ b/clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp
@@ -36,7 +36,8 @@ using llvm::SmallSetVector;
static const RecordDecl *findDefinition(StringRef RecordName,
ASTContext &Context) {
auto Results =
- match(recordDecl(hasName(RecordName), isDefinition()).bind("recordDecl"),
+ match(recordDecl(hasName(std::string(RecordName)), isDefinition())
+ .bind("recordDecl"),
Context);
if (Results.empty()) {
llvm::errs() << "Definition of " << RecordName << " not found\n";
@@ -89,7 +90,7 @@ addReplacement(SourceRange Old, SourceRange New, const ASTContext &Context,
tooling::Replacement R(Context.getSourceManager(),
CharSourceRange::getTokenRange(Old), NewText,
Context.getLangOpts());
- consumeError(Replacements[R.getFilePath()].add(R));
+ consumeError(Replacements[std::string(R.getFilePath())].add(R));
}
/// Find all member fields used in the given init-list initializer expr
diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 40aaf40..4746b49 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -596,7 +596,7 @@ void exportReplacements(const llvm::StringRef MainFilePath,
const std::vector<ClangTidyError> &Errors,
raw_ostream &OS) {
TranslationUnitDiagnostics TUD;
- TUD.MainSourceFile = MainFilePath;
+ TUD.MainSourceFile = std::string(MainFilePath);
for (const auto &Error : Errors) {
tooling::Diagnostic Diag = Error;
TUD.Diagnostics.insert(TUD.Diagnostics.end(), Diag);
diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index fbf1176..cc817d8 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -39,7 +39,7 @@ std::string ClangTidyCheck::OptionsView::get(StringRef LocalName,
const auto &Iter = CheckOptions.find(NamePrefix + LocalName.str());
if (Iter != CheckOptions.end())
return Iter->second;
- return Default;
+ return std::string(Default);
}
std::string
@@ -52,13 +52,13 @@ ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName,
Iter = CheckOptions.find(LocalName.str());
if (Iter != CheckOptions.end())
return Iter->second;
- return Default;
+ return std::string(Default);
}
void ClangTidyCheck::OptionsView::store(ClangTidyOptions::OptionMap &Options,
StringRef LocalName,
StringRef Value) const {
- Options[NamePrefix + LocalName.str()] = Value;
+ Options[NamePrefix + LocalName.str()] = std::string(Value);
}
void ClangTidyCheck::OptionsView::store(ClangTidyOptions::OptionMap &Options,
diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index a5b6834..5a4021c 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -172,7 +172,7 @@ void ClangTidyContext::setSourceManager(SourceManager *SourceMgr) {
}
void ClangTidyContext::setCurrentFile(StringRef File) {
- CurrentFile = File;
+ CurrentFile = std::string(File);
CurrentOptions = getOptionsForFile(CurrentFile);
CheckFilter = std::make_unique<CachedGlobList>(*getOptions().Checks);
WarningAsErrorFilter =
@@ -202,7 +202,7 @@ ClangTidyOptions ClangTidyContext::getOptionsForFile(StringRef File) const {
void ClangTidyContext::setEnableProfiling(bool P) { Profile = P; }
void ClangTidyContext::setProfileStoragePrefix(StringRef Prefix) {
- ProfilePrefix = Prefix;
+ ProfilePrefix = std::string(Prefix);
}
llvm::Optional<ClangTidyProfiling::StorageParams>
@@ -224,8 +224,8 @@ bool ClangTidyContext::treatAsError(StringRef CheckName) const {
}
std::string ClangTidyContext::getCheckName(unsigned DiagnosticID) const {
- std::string ClangWarningOption =
- DiagEngine->getDiagnosticIDs()->getWarningOptionForDiag(DiagnosticID);
+ std::string ClangWarningOption = std::string(
+ DiagEngine->getDiagnosticIDs()->getWarningOptionForDiag(DiagnosticID));
if (!ClangWarningOption.empty())
return "clang-diagnostic-" + ClangWarningOption;
llvm::DenseMap<unsigned, std::string>::const_iterator I =
@@ -661,7 +661,7 @@ void ClangTidyDiagnosticConsumer::removeIncompatibleErrors() {
for (const auto &Replace : FileAndReplace.second) {
unsigned Begin = Replace.getOffset();
unsigned End = Begin + Replace.getLength();
- const std::string &FilePath = Replace.getFilePath();
+ const std::string &FilePath = std::string(Replace.getFilePath());
// FIXME: Handle empty intervals, such as those from insertions.
if (Begin == End)
continue;
diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
index 0d39296..28d923d 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -154,7 +154,7 @@ public:
/// Should be called when starting to process new translation unit.
void setCurrentBuildDirectory(StringRef BuildDirectory) {
- CurrentBuildDirectory = BuildDirectory;
+ CurrentBuildDirectory = std::string(BuildDirectory);
}
/// Returns build directory of the current translation unit.
diff --git a/clang-tools-extra/clang-tidy/ClangTidyModule.cpp b/clang-tools-extra/clang-tidy/ClangTidyModule.cpp
index ff83e7e..6e44f72 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyModule.cpp
@@ -17,7 +17,7 @@ namespace tidy {
void ClangTidyCheckFactories::registerCheckFactory(StringRef Name,
CheckFactory Factory) {
- Factories[Name] = std::move(Factory);
+ Factories[std::string(Name)] = std::move(Factory);
}
std::vector<std::unique_ptr<ClangTidyCheck>>
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
index c3b4191..6e678c9 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
@@ -31,7 +31,7 @@ getScaleForFactory(llvm::StringRef FactoryName) {
{"Minutes", DurationScale::Minutes},
{"Hours", DurationScale::Hours}});
- auto ScaleIter = ScaleMap.find(FactoryName);
+ auto ScaleIter = ScaleMap.find(std::string(FactoryName));
if (ScaleIter == ScaleMap.end())
return llvm::None;
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
index 3466cdbb..d4db021 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
@@ -91,7 +91,8 @@ rewriteInverseTimeCall(const MatchFinder::MatchResult &Result,
DurationScale Scale, const Expr &Node) {
llvm::StringRef InverseFunction = getTimeInverseForScale(Scale);
if (const auto *MaybeCallArg = selectFirst<const Expr>(
- "e", match(callExpr(callee(functionDecl(hasName(InverseFunction))),
+ "e", match(callExpr(callee(functionDecl(
+ hasName(std::string(InverseFunction)))),
hasArgument(0, expr().bind("e"))),
Node, *Result.Context))) {
return tooling::fixit::getText(*MaybeCallArg, *Result.Context).str();
diff --git a/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp b/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
index a386665..78ef1cc 100644
--- a/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
@@ -108,11 +108,11 @@ void TimeSubtractionCheck::registerMatchers(MatchFinder *Finder) {
// a 'Duration'. If we know the result is a 'Duration', we can then infer
// that the second operand must be a 'Time'.
auto CallMatcher =
- callExpr(
- callee(functionDecl(hasName(getDurationFactoryForScale(*Scale)))),
- hasArgument(0, binaryOperator(hasOperatorName("-"),
- hasLHS(TimeInverseMatcher))
- .bind("binop")))
+ callExpr(callee(functionDecl(
+ hasName(std::string(getDurationFactoryForScale(*Scale))))),
+ hasArgument(0, binaryOperator(hasOperatorName("-"),
+ hasLHS(TimeInverseMatcher))
+ .bind("binop")))
.bind("outer_call");
Finder->addMatcher(CallMatcher, this);
@@ -160,8 +160,8 @@ void TimeSubtractionCheck::check(const MatchFinder::MatchResult &Result) {
// latter case (addressed first), we also need to worry about parenthesis.
const auto *MaybeCallArg = selectFirst<const CallExpr>(
"arg", match(expr(hasAncestor(
- callExpr(callee(functionDecl(hasName(
- getDurationFactoryForScale(*Scale)))))
+ callExpr(callee(functionDecl(hasName(std::string(
+ getDurationFactoryForScale(*Scale))))))
.bind("arg"))),
*BinOp, *Result.Context));
if (MaybeCallArg && MaybeCallArg->getArg(0)->IgnoreImpCasts() == BinOp &&
diff --git a/clang-tools-extra/clang-tidy/bugprone/InaccurateEraseCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/InaccurateEraseCheck.cpp
index 95babc7..fffb8a5c 100644
--- a/clang-tools-extra/clang-tidy/bugprone/InaccurateEraseCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/InaccurateEraseCheck.cpp
@@ -58,9 +58,9 @@ void InaccurateEraseCheck::check(const MatchFinder::MatchResult &Result) {
if (!Loc.isMacroID() && EndExpr) {
const auto *AlgCall = Result.Nodes.getNodeAs<CallExpr>("alg");
- std::string ReplacementText = Lexer::getSourceText(
+ std::string ReplacementText = std::string(Lexer::getSourceText(
CharSourceRange::getTokenRange(EndExpr->getSourceRange()),
- *Result.SourceManager, getLangOpts());
+ *Result.SourceManager, getLangOpts()));
const SourceLocation EndLoc = Lexer::getLocForEndOfToken(
AlgCall->getEndLoc(), 0, *Result.SourceManager, getLangOpts());
Hint = FixItHint::CreateInsertion(EndLoc, ", " + ReplacementText);
diff --git a/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
index c771ba8..5a70537 100644
--- a/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
@@ -136,7 +136,7 @@ static bool isAtLeastOneCondVarChanged(const FunctionDecl *Func,
static std::string getCondVarNames(const Stmt *Cond) {
if (const auto *DRE = dyn_cast<DeclRefExpr>(Cond)) {
if (const auto *Var = dyn_cast<VarDecl>(DRE->getDecl()))
- return Var->getName();
+ return std::string(Var->getName());
}
std::string Result;
diff --git a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
index e49688b..9347dac 100644
--- a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
@@ -652,9 +652,10 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
anyOf(DestUnknownDecl, hasDescendant(DestUnknownDecl))));
auto NullTerminatorExpr = binaryOperator(
- hasLHS(anyOf(hasDescendant(declRefExpr(
- to(varDecl(equalsBoundNode(DestVarDeclName))))),
- hasDescendant(declRefExpr(equalsBoundNode(DestExprName))))),
+ hasLHS(anyOf(hasDescendant(declRefExpr(to(varDecl(
+ equalsBoundNode(std::string(DestVarDeclName)))))),
+ hasDescendant(declRefExpr(
+ equalsBoundNode(std::string(DestExprName)))))),
hasRHS(ignoringImpCasts(
anyOf(characterLiteral(equals(0U)), integerLiteral(equals(0))))));
diff --git a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
index c1b27a8..55d8884 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
@@ -119,7 +119,7 @@ getFailureInfoImpl(StringRef Name, bool IsInGlobalNamespace,
Optional<FailureInfo> Info;
auto AppendFailure = [&](StringRef Kind, std::string &&Fixup) {
if (!Info) {
- Info = FailureInfo{Kind, std::move(Fixup)};
+ Info = FailureInfo{std::string(Kind), std::move(Fixup)};
} else {
Info->KindName += Kind;
Info->Fixup = std::move(Fixup);
@@ -143,7 +143,7 @@ getFailureInfoImpl(StringRef Name, bool IsInGlobalNamespace,
if (!(hasReservedDoubleUnderscore(Name, LangOpts) ||
startsWithUnderscoreCapital(Name) ||
startsWithUnderscoreInGlobalNamespace(Name, IsInGlobalNamespace)))
- return FailureInfo{NonReservedTag, getNonReservedFixup(Name)};
+ return FailureInfo{NonReservedTag, getNonReservedFixup(std::string(Name))};
return None;
}
diff --git a/clang-tools-extra/clang-tidy/cert/MutatingCopyCheck.cpp b/clang-tools-extra/clang-tidy/cert/MutatingCopyCheck.cpp
index a20a890..6add035 100644
--- a/clang-tools-extra/clang-tidy/cert/MutatingCopyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cert/MutatingCopyCheck.cpp
@@ -25,7 +25,8 @@ void MutatingCopyCheck::registerMatchers(MatchFinder *Finder) {
return;
const auto MemberExprOrSourceObject = anyOf(
- memberExpr(), declRefExpr(to(decl(equalsBoundNode(SourceDeclName)))));
+ memberExpr(),
+ declRefExpr(to(decl(equalsBoundNode(std::string(SourceDeclName))))));
const auto IsPartOfSource =
allOf(unless(hasDescendant(expr(unless(MemberExprOrSourceObject)))),
diff --git a/clang-tools-extra/clang-tidy/google/AvoidNSObjectNewCheck.cpp b/clang-tools-extra/clang-tidy/google/AvoidNSObjectNewCheck.cpp
index 1b147ac..0186ed8 100644
--- a/clang-tools-extra/clang-tidy/google/AvoidNSObjectNewCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/AvoidNSObjectNewCheck.cpp
@@ -80,12 +80,13 @@ static FixItHint getCallFixItHint(const ObjCMessageExpr *Expr,
StringRef ClassName = FoundClassFactory->first;
StringRef FactorySelector = FoundClassFactory->second;
std::string NewCall =
- llvm::formatv("[{0} {1}]", ClassName, FactorySelector);
+ std::string(llvm::formatv("[{0} {1}]", ClassName, FactorySelector));
return FixItHint::CreateReplacement(Expr->getSourceRange(), NewCall);
}
if (isInitMethodAvailable(Expr->getReceiverInterface())) {
- std::string NewCall = llvm::formatv("[[{0} alloc] init]", Receiver);
+ std::string NewCall =
+ std::string(llvm::formatv("[[{0} alloc] init]", Receiver));
return FixItHint::CreateReplacement(Expr->getSourceRange(), NewCall);
}
diff --git a/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp b/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
index 27307c0..2db2300 100644
--- a/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
@@ -242,10 +242,10 @@ static bool
derivedTypeHasReplacementMethod(const MatchFinder::MatchResult &Result,
llvm::StringRef ReplacementMethod) {
const auto *Class = Result.Nodes.getNodeAs<CXXRecordDecl>("class");
- return !match(cxxRecordDecl(
- unless(isExpansionInFileMatching(
- "gtest/gtest(-typed-test)?\\.h$")),
- hasMethod(cxxMethodDecl(hasName(ReplacementMethod)))),
+ return !match(cxxRecordDecl(unless(isExpansionInFileMatching(
+ "gtest/gtest(-typed-test)?\\.h$")),
+ hasMethod(cxxMethodDecl(
+ hasName(std::string(ReplacementMethod))))),
*Class, *Result.Context)
.empty();
}
diff --git a/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp b/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
index 8b32d8d..27e29de 100644
--- a/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
@@ -36,7 +36,7 @@ std::string LLVMHeaderGuardCheck::getHeaderGuard(StringRef Filename,
// Unlike LLVM svn, LLVM git monorepo is named llvm-project, so we replace
// "/llvm-project/" with the cannonical "/llvm/".
const static StringRef LLVMProject = "/llvm-project/";
- size_t PosLLVMProject = Guard.rfind(LLVMProject);
+ size_t PosLLVMProject = Guard.rfind(std::string(LLVMProject));
if (PosLLVMProject != StringRef::npos)
Guard = Guard.replace(PosLLVMProject, LLVMProject.size(), "/llvm/");
diff --git a/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp b/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
index 009a5a6..834a49a 100644
--- a/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
@@ -81,7 +81,8 @@ void IncludeOrderPPCallbacks::InclusionDirective(
SrcMgr::CharacteristicKind FileType) {
// We recognize the first include as a special main module header and want
// to leave it in the top position.
- IncludeDirective ID = {HashLoc, FilenameRange, FileName, IsAngled, false};
+ IncludeDirective ID = {HashLoc, FilenameRange, std::string(FileName),
+ IsAngled, false};
if (LookForMainModule && !IsAngled) {
ID.IsMainModule = true;
LookForMainModule = false;
diff --git a/clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp b/clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp
index 9363fa901..8c24cb4 100644
--- a/clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp
@@ -104,12 +104,12 @@ void UniqueptrResetReleaseCheck::check(const MatchFinder::MatchResult &Result) {
const auto *ResetCall =
Result.Nodes.getNodeAs<CXXMemberCallExpr>("reset_call");
- std::string LeftText = clang::Lexer::getSourceText(
+ std::string LeftText = std::string(clang::Lexer::getSourceText(
CharSourceRange::getTokenRange(Left->getSourceRange()),
- *Result.SourceManager, getLangOpts());
- std::string RightText = clang::Lexer::getSourceText(
+ *Result.SourceManager, getLangOpts()));
+ std::string RightText = std::string(clang::Lexer::getSourceText(
CharSourceRange::getTokenRange(Right->getSourceRange()),
- *Result.SourceManager, getLangOpts());
+ *Result.SourceManager, getLangOpts()));
if (ResetMember->isArrow())
LeftText = "*" + LeftText;
diff --git a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
index c9313db..a80bad7 100644
--- a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
@@ -149,7 +149,8 @@ initializeBindArgumentForCallExpr(const MatchFinder::MatchResult &Result,
if (isCallExprNamed(CE, "boost::ref") || isCallExprNamed(CE, "std::ref")) {
B.Kind = BK_Other;
B.CM = CM_ByRef;
- B.UsageIdentifier = getSourceTextForExpr(Result, CE->getArg(0));
+ B.UsageIdentifier =
+ std::string(getSourceTextForExpr(Result, CE->getArg(0)));
} else {
B.Kind = BK_CallExpr;
B.CM = CM_InitExpression;
@@ -188,7 +189,7 @@ static bool tryCaptureAsLocalVariable(const MatchFinder::MatchResult &Result,
return false;
B.CM = CM_ByValue;
- B.UsageIdentifier = getSourceTextForExpr(Result, E);
+ B.UsageIdentifier = std::string(getSourceTextForExpr(Result, E));
B.CaptureIdentifier = B.UsageIdentifier;
return true;
}
@@ -204,7 +205,7 @@ static bool tryCaptureAsMemberVariable(const MatchFinder::MatchResult &Result,
E = E->IgnoreImplicit();
if (isa<CXXThisExpr>(E)) {
B.CM = CM_ByValue;
- B.UsageIdentifier = getSourceTextForExpr(Result, E);
+ B.UsageIdentifier = std::string(getSourceTextForExpr(Result, E));
B.CaptureIdentifier = "this";
return true;
}
@@ -217,7 +218,7 @@ static bool tryCaptureAsMemberVariable(const MatchFinder::MatchResult &Result,
return false;
B.CM = CM_ByValue;
- B.UsageIdentifier = getSourceTextForExpr(Result, E);
+ B.UsageIdentifier = std::string(getSourceTextForExpr(Result, E));
B.CaptureIdentifier = "this";
return true;
}
@@ -252,7 +253,7 @@ buildBindArguments(const MatchFinder::MatchResult &Result,
SmallVector<StringRef, 2> Matches;
if (MatchPlaceholder.match(B.SourceTokens, &Matches)) {
B.Kind = BK_Placeholder;
- B.PlaceHolderIndex = std::stoi(Matches[1]);
+ B.PlaceHolderIndex = std::stoi(std::string(Matches[1]));
B.UsageIdentifier = "PH" + llvm::utostr(B.PlaceHolderIndex);
B.CaptureIdentifier = B.UsageIdentifier;
continue;
@@ -503,9 +504,10 @@ getLambdaProperties(const MatchFinder::MatchResult &Result) {
LP.Callable.SourceTokens = getSourceTextForExpr(Result, CalleeExpr);
if (LP.Callable.Materialization == CMK_VariableRef) {
LP.Callable.CM = CM_ByValue;
- LP.Callable.UsageIdentifier = getSourceTextForExpr(Result, CalleeExpr);
- LP.Callable.CaptureIdentifier =
- getSourceTextForExpr(Result, ignoreTemporariesAndPointers(CalleeExpr));
+ LP.Callable.UsageIdentifier =
+ std::string(getSourceTextForExpr(Result, CalleeExpr));
+ LP.Callable.CaptureIdentifier = std::string(
+ getSourceTextForExpr(Result, ignoreTemporariesAndPointers(CalleeExpr)));
} else if (LP.Callable.Materialization == CMK_CallExpression) {
LP.Callable.CM = CM_InitExpression;
LP.Callable.UsageIdentifier = "Func";
diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
index f359702..7c0ae02 100644
--- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -748,7 +748,8 @@ void LoopConvertCheck::determineRangeDescriptor(
ASTContext *Context, const BoundNodes &Nodes, const ForStmt *Loop,
LoopFixerKind FixerKind, const Expr *ContainerExpr,
const UsageResult &Usages, RangeDescriptor &Descriptor) {
- Descriptor.ContainerString = getContainerString(Context, Loop, ContainerExpr);
+ Descriptor.ContainerString =
+ std::string(getContainerString(Context, Loop, ContainerExpr));
if (FixerKind == LFK_Iterator)
getIteratorLoopQualifiers(Context, Nodes, Descriptor);
diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
index 6cb4276..237b2bd 100644
--- a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
@@ -851,20 +851,20 @@ std::string VariableNamer::createIndexName() {
size_t Len = ContainerName.size();
if (Len > 1 && ContainerName.endswith(Style == NS_UpperCase ? "S" : "s")) {
- IteratorName = ContainerName.substr(0, Len - 1);
+ IteratorName = std::string(ContainerName.substr(0, Len - 1));
// E.g.: (auto thing : things)
if (!declarationExists(IteratorName) || IteratorName == OldIndex->getName())
return IteratorName;
}
if (Len > 2 && ContainerName.endswith(Style == NS_UpperCase ? "S_" : "s_")) {
- IteratorName = ContainerName.substr(0, Len - 2);
+ IteratorName = std::string(ContainerName.substr(0, Len - 2));
// E.g.: (auto thing : things_)
if (!declarationExists(IteratorName) || IteratorName == OldIndex->getName())
return IteratorName;
}
- return OldIndex->getName();
+ return std::string(OldIndex->getName());
}
/// Determines whether or not the name \a Symbol conflicts with
@@ -899,7 +899,7 @@ bool VariableNamer::declarationExists(StringRef Symbol) {
// of DeclContext::lookup()). Why is this?
// Finally, determine if the symbol was used in the loop or a child context.
- DeclFinderASTVisitor DeclFinder(Symbol, GeneratedDecls);
+ DeclFinderASTVisitor DeclFinder(std::string(Symbol), GeneratedDecls);
return DeclFinder.findUsages(SourceStmt);
}
diff --git a/clang-tools-extra/clang-tidy/modernize/ShrinkToFitCheck.cpp b/clang-tools-extra/clang-tidy/modernize/ShrinkToFitCheck.cpp
index 607dc5f..4b98f12 100644
--- a/clang-tools-extra/clang-tidy/modernize/ShrinkToFitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/ShrinkToFitCheck.cpp
@@ -62,15 +62,15 @@ void ShrinkToFitCheck::check(const MatchFinder::MatchResult &Result) {
const LangOptions &Opts = getLangOpts();
std::string ReplacementText;
if (const auto *UnaryOp = llvm::dyn_cast<UnaryOperator>(Container)) {
- ReplacementText =
+ ReplacementText = std::string(
Lexer::getSourceText(CharSourceRange::getTokenRange(
UnaryOp->getSubExpr()->getSourceRange()),
- *Result.SourceManager, Opts);
+ *Result.SourceManager, Opts));
ReplacementText += "->shrink_to_fit()";
} else {
- ReplacementText = Lexer::getSourceText(
+ ReplacementText = std::string(Lexer::getSourceText(
CharSourceRange::getTokenRange(Container->getSourceRange()),
- *Result.SourceManager, Opts);
+ *Result.SourceManager, Opts));
ReplacementText += ".shrink_to_fit()";
}
diff --git a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
index 4dc53dd..71cb030 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
@@ -464,7 +464,8 @@ void UseTrailingReturnTypeCheck::check(const MatchFinder::MatchResult &Result) {
CharAfterReturnType.empty() || !std::isspace(CharAfterReturnType[0]);
std::string Auto = NeedSpaceAfterAuto ? "auto " : "auto";
- std::string ReturnType = tooling::fixit::getText(ReturnTypeCVRange, Ctx);
+ std::string ReturnType =
+ std::string(tooling::fixit::getText(ReturnTypeCVRange, Ctx));
keepSpecifiers(ReturnType, Auto, ReturnTypeCVRange, *F, Fr, Ctx, SM,
LangOpts);
diff --git a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
index ce8d00f..164c9fe9 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -98,9 +98,9 @@ void UseUsingCheck::check(const MatchFinder::MatchResult &Result) {
// If typedef contains a full struct/class declaration, extract its full text.
if (LastCxxDeclRange.isValid() && ReplaceRange.fullyContains(LastCxxDeclRange)) {
bool Invalid;
- Type =
+ Type = std::string(
Lexer::getSourceText(CharSourceRange::getTokenRange(LastCxxDeclRange),
- *Result.SourceManager, getLangOpts(), &Invalid);
+ *Result.SourceManager, getLangOpts(), &Invalid));
if (Invalid)
return;
}
diff --git a/clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp b/clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp
index a9661e0..f305ddf 100644
--- a/clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp
+++ b/clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp
@@ -128,7 +128,7 @@ static bool isBuiltinTypeMatching(const BuiltinType *Builtin,
{BuiltinType::LongDouble, "MPI_LONG_DOUBLE"}};
if (!isMPITypeMatching(BuiltinMatches, Builtin->getKind(), MPIDatatype)) {
- BufferTypeName = Builtin->getName(LO);
+ BufferTypeName = std::string(Builtin->getName(LO));
return false;
}
@@ -219,7 +219,7 @@ static bool isTypedefTypeMatching(const TypedefType *const Typedef,
const auto it = FixedWidthMatches.find(Typedef->getDecl()->getName());
// Check if the typedef is known and not matching the MPI datatype.
if (it != FixedWidthMatches.end() && it->getValue() != MPIDatatype) {
- BufferTypeName = Typedef->getDecl()->getName();
+ BufferTypeName = std::string(Typedef->getDecl()->getName());
return false;
}
return true;
@@ -271,7 +271,8 @@ void TypeMismatchCheck::check(const MatchFinder::MatchResult &Result) {
const Type *ArgType = argumentType(CE, BufferIdx);
// Skip unknown MPI datatypes and void pointers.
- if (!isStandardMPIDatatype(MPIDatatype) || ArgType->isVoidType())
+ if (!isStandardMPIDatatype(std::string(MPIDatatype)) ||
+ ArgType->isVoidType())
return;
BufferTypes.push_back(ArgType);
@@ -309,16 +310,17 @@ void TypeMismatchCheck::checkArguments(ArrayRef<const Type *> BufferTypes,
bool Error = false;
if (const auto *Typedef = BT->getAs<TypedefType>()) {
- Error = !isTypedefTypeMatching(Typedef, BufferTypeName, MPIDatatypes[i]);
+ Error = !isTypedefTypeMatching(Typedef, BufferTypeName,
+ std::string(MPIDatatypes[i]));
} else if (const auto *Complex = BT->getAs<ComplexType>()) {
- Error =
- !isCComplexTypeMatching(Complex, BufferTypeName, MPIDatatypes[i], LO);
+ Error = !isCComplexTypeMatching(Complex, BufferTypeName,
+ std::string(MPIDatatypes[i]), LO);
} else if (const auto *Template = BT->getAs<TemplateSpecializationType>()) {
Error = !isCXXComplexTypeMatching(Template, BufferTypeName,
- MPIDatatypes[i], LO);
+ std::string(MPIDatatypes[i]), LO);
} else if (const auto *Builtin = BT->getAs<BuiltinType>()) {
- Error =
- !isBuiltinTypeMatching(Builtin, BufferTypeName, MPIDatatypes[i], LO);
+ Error = !isBuiltinTypeMatching(Builtin, BufferTypeName,
+ std::string(MPIDatatypes[i]), LO);
}
if (Error) {
diff --git a/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp b/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
index e985fe8..776a8ca 100644
--- a/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
@@ -94,7 +94,7 @@ void InefficientVectorOperationCheck::AddMatcher(
const auto TargetVarDecl =
varDecl(hasInitializer(DefaultConstructorCall)).bind(VarDeclName);
const auto TargetVarDefStmt =
- declStmt(hasSingleDecl(equalsBoundNode(VarDeclName)))
+ declStmt(hasSingleDecl(equalsBoundNode(std::string(VarDeclName))))
.bind(VarDeclStmtName);
const auto AppendCallExpr =
@@ -253,7 +253,7 @@ void InefficientVectorOperationCheck::check(
StringRef LoopEndSource = Lexer::getSourceText(
CharSourceRange::getTokenRange(LoopEndExpr->getSourceRange()), SM,
Context->getLangOpts());
- ReserveSize = LoopEndSource;
+ ReserveSize = std::string(LoopEndSource);
}
auto Diag = diag(AppendCall->getBeginLoc(),
diff --git a/clang-tools-extra/clang-tidy/plugin/ClangTidyPlugin.cpp b/clang-tools-extra/clang-tidy/plugin/ClangTidyPlugin.cpp
index aff11bd..cbd6fdd 100644
--- a/clang-tools-extra/clang-tidy/plugin/ClangTidyPlugin.cpp
+++ b/clang-tools-extra/clang-tidy/plugin/ClangTidyPlugin.cpp
@@ -65,7 +65,7 @@ public:
// FIXME: This is very limited at the moment.
for (StringRef Arg : Args)
if (Arg.startswith("-checks="))
- OverrideOptions.Checks = Arg.substr(strlen("-checks="));
+ OverrideOptions.Checks = std::string(Arg.substr(strlen("-checks=")));
auto Options = std::make_unique<FileOptionsProvider>(
GlobalOptions, DefaultOptions, OverrideOptions);
diff --git a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
index fe0e1c0..1086340 100644
--- a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
@@ -111,9 +111,9 @@ void ContainerSizeEmptyCheck::check(const MatchFinder::MatchResult &Result) {
? MemberCall->getImplicitObjectArgument()
: (Pointee ? Pointee : Result.Nodes.getNodeAs<Expr>("STLObject"));
FixItHint Hint;
- std::string ReplacementText =
+ std::string ReplacementText = std::string(
Lexer::getSourceText(CharSourceRange::getTokenRange(E->getSourceRange()),
- *Result.SourceManager, getLangOpts());
+ *Result.SourceManager, getLangOpts()));
if (BinCmp && IsBinaryOrTernary(E)) {
// Not just a DeclRefExpr, so parenthesize to be on the safe side.
ReplacementText = "(" + ReplacementText + ")";
diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index 119502e..0171964 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -256,7 +256,7 @@ static std::string fixupWithCase(StringRef Name,
}
if (Words.empty())
- return Name;
+ return std::string(Name);
std::string Fixup;
switch (Case) {
diff --git a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
index 4a7c456..9580373 100644
--- a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
@@ -72,7 +72,7 @@ getNamespaceNameAsWritten(SourceLocation &Loc, const SourceManager &Sources,
if (T->is(tok::raw_identifier)) {
StringRef ID = T->getRawIdentifier();
if (ID != "namespace" && ID != "inline")
- Result.append(ID);
+ Result.append(std::string(ID));
} else if (T->is(tok::coloncolon)) {
Result.append("::");
} else { // Any other kind of token is unexpected here.
diff --git a/clang-tools-extra/clang-tidy/readability/RedundantPreprocessorCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantPreprocessorCheck.cpp
index 295d22d..0870f2d 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantPreprocessorCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantPreprocessorCheck.cpp
@@ -83,7 +83,7 @@ private:
if (Store)
// This is an actual directive to be remembered.
- Stack.push_back({Loc, MacroName});
+ Stack.push_back({Loc, std::string(MacroName)});
}
ClangTidyCheck &Check;
diff --git a/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
index f7b0dfc..7883491 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -46,8 +46,8 @@ formatDereference(const ast_matchers::MatchFinder::MatchResult &Result,
if (const auto *Op = dyn_cast<clang::UnaryOperator>(&ExprNode)) {
if (Op->getOpcode() == UO_AddrOf) {
// Strip leading '&'.
- return tooling::fixit::getText(*Op->getSubExpr()->IgnoreParens(),
- *Result.Context);
+ return std::string(tooling::fixit::getText(
+ *Op->getSubExpr()->IgnoreParens(), *Result.Context));
}
}
StringRef Text = tooling::fixit::getText(ExprNode, *Result.Context);
diff --git a/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp b/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
index 38a6324..74ef565 100644
--- a/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
@@ -131,7 +131,7 @@ std::string asBool(StringRef text, bool NeedsStaticCast) {
if (NeedsStaticCast)
return ("static_cast<bool>(" + text + ")").str();
- return text;
+ return std::string(text);
}
bool needsNullPtrComparison(const Expr *E) {
diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index c6927cc..738766c 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -367,7 +367,7 @@ int clangTidyMain(int argc, const char **argv) {
FileName = PathList.front();
}
- SmallString<256> FilePath = MakeAbsolute(FileName);
+ SmallString<256> FilePath = MakeAbsolute(std::string(FileName));
ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FilePath);
std::vector<std::string> EnabledChecks =
diff --git a/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp b/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
index 4890a1c..13107c25 100644
--- a/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
+++ b/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
@@ -21,7 +21,7 @@ namespace utils {
static std::string cleanPath(StringRef Path) {
SmallString<256> Result = Path;
llvm::sys::path::remove_dots(Result, true);
- return Result.str();
+ return std::string(Result.str());
}
namespace {
@@ -186,7 +186,7 @@ public:
CPPVar));
return CPPVar;
}
- return CurHeaderGuard;
+ return std::string(CurHeaderGuard);
}
/// Checks the comment after the #endif of a header guard and fixes it
diff --git a/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp b/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
index e0d02f3..c267789 100644
--- a/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
+++ b/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
@@ -50,7 +50,7 @@ IncludeInserter::CreateIncludeInsertion(FileID FileID, StringRef Header,
bool IsAngled) {
// We assume the same Header will never be included both angled and not
// angled.
- if (!InsertedHeaders[FileID].insert(Header).second)
+ if (!InsertedHeaders[FileID].insert(std::string(Header)).second)
return llvm::None;
if (IncludeSorterByFile.find(FileID) == IncludeSorterByFile.end()) {
diff --git a/clang-tools-extra/clang-tidy/utils/NamespaceAliaser.cpp b/clang-tools-extra/clang-tidy/utils/NamespaceAliaser.cpp
index d1fc9bd..82f103a 100644
--- a/clang-tools-extra/clang-tidy/utils/NamespaceAliaser.cpp
+++ b/clang-tools-extra/clang-tidy/utils/NamespaceAliaser.cpp
@@ -43,11 +43,11 @@ NamespaceAliaser::createAlias(ASTContext &Context, const Stmt &Statement,
// FIXME: Also doesn't consider file or class-scope aliases.
const auto *ExistingAlias = selectFirst<NamedDecl>(
- "alias",
- match(functionDecl(hasBody(compoundStmt(has(declStmt(
- has(namespaceAliasDecl(hasTargetNamespace(hasName(Namespace)))
- .bind("alias"))))))),
- *Function, Context));
+ "alias", match(functionDecl(hasBody(compoundStmt(has(declStmt(
+ has(namespaceAliasDecl(hasTargetNamespace(hasName(
+ std::string(Namespace))))
+ .bind("alias"))))))),
+ *Function, Context));
if (ExistingAlias != nullptr) {
AddedAliases[Function][Namespace.str()] = ExistingAlias->getName().str();
diff --git a/clang-tools-extra/clang-tidy/utils/OptionsUtils.cpp b/clang-tools-extra/clang-tidy/utils/OptionsUtils.cpp
index 36f4b6f..8a7f1c30 100644
--- a/clang-tools-extra/clang-tidy/utils/OptionsUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/OptionsUtils.cpp
@@ -22,7 +22,7 @@ std::vector<std::string> parseStringList(StringRef Option) {
for (StringRef &Name : Names) {
Name = Name.trim();
if (!Name.empty())
- Result.push_back(Name);
+ Result.push_back(std::string(Name));
}
return Result;
}
diff --git a/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp b/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp
index e852532a..934bee2 100644
--- a/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp
+++ b/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp
@@ -58,7 +58,7 @@ Optional<FixItHint> UsingInserter::createUsingDeclaration(
return None;
}
// Find conflicting declarations and references.
- auto ConflictingDecl = namedDecl(hasName(UnqualifiedName));
+ auto ConflictingDecl = namedDecl(hasName(std::string(UnqualifiedName)));
bool HasConflictingDeclaration =
!match(findAll(ConflictingDecl), *Function, Context).empty();
bool HasConflictingDeclRef =
diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 982e05f..880359f 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -48,10 +48,10 @@ CodeAction toCodeAction(const ClangdServer::TweakRef &T, const URIForFile &File,
CA.title = T.Title;
switch (T.Intent) {
case Tweak::Refactor:
- CA.kind = CodeAction::REFACTOR_KIND;
+ CA.kind = std::string(CodeAction::REFACTOR_KIND);
break;
case Tweak::Info:
- CA.kind = CodeAction::INFO_KIND;
+ CA.kind = std::string(CodeAction::INFO_KIND);
break;
}
// This tweak may have an expensive second stage, we only run it if the user
@@ -61,7 +61,7 @@ CodeAction toCodeAction(const ClangdServer::TweakRef &T, const URIForFile &File,
// directly.
CA.command.emplace();
CA.command->title = T.Title;
- CA.command->command = Command::CLANGD_APPLY_TWEAK;
+ CA.command->command = std::string(Command::CLANGD_APPLY_TWEAK);
CA.command->tweakArgs.emplace();
CA.command->tweakArgs->file = File;
CA.command->tweakArgs->tweakID = T.ID;
@@ -100,7 +100,8 @@ std::vector<std::vector<std::string>> buildHighlightScopeLookupTable() {
// HighlightingKind is using as the index.
for (int KindValue = 0; KindValue <= (int)HighlightingKind::LastKind;
++KindValue)
- LookupTable.push_back({toTextMateScope((HighlightingKind)(KindValue))});
+ LookupTable.push_back(
+ {std::string(toTextMateScope((HighlightingKind)(KindValue)))});
return LookupTable;
}
@@ -471,7 +472,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
ClangdServerOpts.SemanticHighlighting =
Params.capabilities.SemanticHighlighting;
if (Params.rootUri && *Params.rootUri)
- ClangdServerOpts.WorkspaceRoot = Params.rootUri->file();
+ ClangdServerOpts.WorkspaceRoot = std::string(Params.rootUri->file());
else if (Params.rootPath && !Params.rootPath->empty())
ClangdServerOpts.WorkspaceRoot = *Params.rootPath;
if (Server)
@@ -764,7 +765,7 @@ void ClangdLSPServer::onPrepareRename(const TextDocumentPositionParams &Params,
void ClangdLSPServer::onRename(const RenameParams &Params,
Callback<WorkspaceEdit> Reply) {
- Path File = Params.textDocument.uri.file();
+ Path File = std::string(Params.textDocument.uri.file());
llvm::Optional<std::string> Code = DraftMgr.getDraft(File);
if (!Code)
return Reply(llvm::make_error<LSPError>(
@@ -867,7 +868,7 @@ flattenSymbolHierarchy(llvm::ArrayRef<DocumentSymbol> Symbols,
std::function<void(const DocumentSymbol &, llvm::StringRef)> Process =
[&](const DocumentSymbol &S, llvm::Optional<llvm::StringRef> ParentName) {
SymbolInformation SI;
- SI.containerName = ParentName ? "" : *ParentName;
+ SI.containerName = std::string(ParentName ? "" : *ParentName);
SI.name = S.name;
SI.kind = S.kind;
SI.location.range = S.range;
@@ -908,7 +909,7 @@ static llvm::Optional<Command> asCommand(const CodeAction &Action) {
if (Action.command) {
Cmd = *Action.command;
} else if (Action.edit) {
- Cmd.command = Command::CLANGD_APPLY_FIX_COMMAND;
+ Cmd.command = std::string(Command::CLANGD_APPLY_FIX_COMMAND);
Cmd.workspaceEdit = *Action.edit;
} else {
return None;
diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp
index fd2aded..7ead45c 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -174,7 +174,7 @@ void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents,
// Compile command is set asynchronously during update, as it can be slow.
ParseInputs Inputs;
Inputs.FS = FS;
- Inputs.Contents = Contents;
+ Inputs.Contents = std::string(Contents);
Inputs.Opts = std::move(Opts);
Inputs.Index = Index;
bool NewFile = WorkScheduler.update(File, Inputs, WantDiags);
@@ -478,8 +478,8 @@ void ClangdServer::switchSourceHeader(
// the same directory.
// 2) if 1) fails, we use the AST&Index approach, it is slower but supports
// different code layout.
- if (auto CorrespondingFile =
- getCorrespondingHeaderOrSource(Path, FSProvider.getFileSystem()))
+ if (auto CorrespondingFile = getCorrespondingHeaderOrSource(
+ std::string(Path), FSProvider.getFileSystem()))
return CB(std::move(CorrespondingFile));
auto Action = [Path = Path.str(), CB = std::move(CB),
this](llvm::Expected<InputsAndAST> InpAST) mutable {
diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp
index 045b78d..830d4b2 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -261,14 +261,14 @@ struct CodeCompletionBuilder {
if (C.SemaResult) {
assert(ASTCtx);
Completion.Origin |= SymbolOrigin::AST;
- Completion.Name = llvm::StringRef(SemaCCS->getTypedText());
+ Completion.Name = std::string(llvm::StringRef(SemaCCS->getTypedText()));
if (Completion.Scope.empty()) {
if ((C.SemaResult->Kind == CodeCompletionResult::RK_Declaration) ||
(C.SemaResult->Kind == CodeCompletionResult::RK_Pattern))
if (const auto *D = C.SemaResult->getDeclaration())
if (const auto *ND = dyn_cast<NamedDecl>(D))
- Completion.Scope =
- splitQualifiedName(printQualifiedName(*ND)).first;
+ Completion.Scope = std::string(
+ splitQualifiedName(printQualifiedName(*ND)).first);
}
Completion.Kind = toCompletionItemKind(
C.SemaResult->Kind, C.SemaResult->Declaration, ContextKind);
@@ -291,11 +291,11 @@ struct CodeCompletionBuilder {
if (C.IndexResult) {
Completion.Origin |= C.IndexResult->Origin;
if (Completion.Scope.empty())
- Completion.Scope = C.IndexResult->Scope;
+ Completion.Scope = std::string(C.IndexResult->Scope);
if (Completion.Kind == CompletionItemKind::Missing)
Completion.Kind = toCompletionItemKind(C.IndexResult->SymInfo.Kind);
if (Completion.Name.empty())
- Completion.Name = C.IndexResult->Name;
+ Completion.Name = std::string(C.IndexResult->Name);
// If the completion was visible to Sema, no qualifier is needed. This
// avoids unneeded qualifiers in cases like with `using ns::X`.
if (Completion.RequiredQualifier.empty() && !C.SemaResult) {
@@ -306,14 +306,14 @@ struct CodeCompletionBuilder {
Qualifier.size() < ShortestQualifier.size())
ShortestQualifier = Qualifier;
}
- Completion.RequiredQualifier = ShortestQualifier;
+ Completion.RequiredQualifier = std::string(ShortestQualifier);
}
Completion.Deprecated |= (C.IndexResult->Flags & Symbol::Deprecated);
}
if (C.IdentifierResult) {
Completion.Origin |= SymbolOrigin::Identifier;
Completion.Kind = CompletionItemKind::Text;
- Completion.Name = C.IdentifierResult->Name;
+ Completion.Name = std::string(C.IdentifierResult->Name);
}
// Turn absolute path into a literal string that can be #included.
@@ -367,13 +367,13 @@ struct CodeCompletionBuilder {
&Completion.RequiredQualifier, IsPattern);
S.ReturnType = getReturnType(*SemaCCS);
} else if (C.IndexResult) {
- S.Signature = C.IndexResult->Signature;
- S.SnippetSuffix = C.IndexResult->CompletionSnippetSuffix;
- S.ReturnType = C.IndexResult->ReturnType;
+ S.Signature = std::string(C.IndexResult->Signature);
+ S.SnippetSuffix = std::string(C.IndexResult->CompletionSnippetSuffix);
+ S.ReturnType = std::string(C.IndexResult->ReturnType);
}
if (ExtractDocumentation && Completion.Documentation.empty()) {
if (C.IndexResult)
- Completion.Documentation = C.IndexResult->Documentation;
+ Completion.Documentation = std::string(C.IndexResult->Documentation);
else if (C.SemaResult)
Completion.Documentation = getDocComment(*ASTCtx, *C.SemaResult,
/*CommentsFromHeader=*/false);
@@ -565,7 +565,7 @@ getQueryScopes(CodeCompletionContext &CCContext, const Sema &CCSema,
StringRef SpelledSpecifier = HeuristicPrefix.Qualifier;
if (SpelledSpecifier.consume_front("::"))
Scopes.AccessibleScopes = {""};
- Scopes.UnresolvedQualifier = SpelledSpecifier;
+ Scopes.UnresolvedQualifier = std::string(SpelledSpecifier);
return {Scopes.scopesForIndexQuery(), false};
}
// The enclosing namespace must be first, it gets a quality boost.
@@ -590,7 +590,7 @@ getQueryScopes(CodeCompletionContext &CCContext, const Sema &CCSema,
CCSema.SourceMgr, clang::LangOptions());
if (SpelledSpecifier.consume_front("::"))
Scopes.AccessibleScopes = {""};
- Scopes.UnresolvedQualifier = SpelledSpecifier;
+ Scopes.UnresolvedQualifier = std::string(SpelledSpecifier);
// Sema excludes the trailing "::".
if (!Scopes.UnresolvedQualifier->empty())
*Scopes.UnresolvedQualifier += "::";
@@ -859,7 +859,7 @@ public:
}
Index->lookup(IndexRequest, [&](const Symbol &S) {
if (!S.Documentation.empty())
- FetchedDocs[S.ID] = S.Documentation;
+ FetchedDocs[S.ID] = std::string(S.Documentation);
});
log("SigHelp: requested docs for {0} symbols from the index, got {1} "
"symbols with non-empty docs in the response",
@@ -925,7 +925,7 @@ private:
ParameterInformation Info;
Info.labelOffsets.emplace(ParamStartOffset, ParamEndOffset);
// FIXME: only set 'labelOffsets' when all clients migrate out of it.
- Info.labelString = ChunkText;
+ Info.labelString = std::string(ChunkText);
Signature.parameters.push_back(std::move(Info));
}
@@ -1054,7 +1054,7 @@ bool semaCodeComplete(std::unique_ptr<CodeCompleteConsumer> Consumer,
ParseInputs ParseInput;
ParseInput.CompileCommand = Input.Command;
ParseInput.FS = VFS;
- ParseInput.Contents = Input.Contents;
+ ParseInput.Contents = std::string(Input.Contents);
ParseInput.Opts = ParseOptions();
IgnoreDiagnostics IgnoreDiags;
@@ -1069,7 +1069,7 @@ bool semaCodeComplete(std::unique_ptr<CodeCompleteConsumer> Consumer,
CI->getLangOpts()->SpellChecking = false;
// Setup code completion.
FrontendOpts.CodeCompleteOpts = Options;
- FrontendOpts.CodeCompletionAt.FileName = Input.FileName;
+ FrontendOpts.CodeCompletionAt.FileName = std::string(Input.FileName);
std::tie(FrontendOpts.CodeCompletionAt.Line,
FrontendOpts.CodeCompletionAt.Column) =
offsetToClangLineColumn(Input.Contents, Input.Offset);
@@ -1167,7 +1167,7 @@ std::future<SymbolSlab> startAsyncFuzzyFind(const SymbolIndex &Index,
// source code.
FuzzyFindRequest speculativeFuzzyFindRequestForCompletion(
FuzzyFindRequest CachedReq, const CompletionPrefix &HeuristicPrefix) {
- CachedReq.Query = HeuristicPrefix.Name;
+ CachedReq.Query = std::string(HeuristicPrefix.Name);
return CachedReq;
}
@@ -1377,9 +1377,10 @@ public:
AllScopes = Opts.AllScopes;
else if (HeuristicPrefix.Qualifier.startswith("::")) {
Scopes.AccessibleScopes = {""};
- Scopes.UnresolvedQualifier = HeuristicPrefix.Qualifier.drop_front(2);
+ Scopes.UnresolvedQualifier =
+ std::string(HeuristicPrefix.Qualifier.drop_front(2));
} else
- Scopes.UnresolvedQualifier = HeuristicPrefix.Qualifier;
+ Scopes.UnresolvedQualifier = std::string(HeuristicPrefix.Qualifier);
// First scope is the (modified) enclosing scope.
QueryScopes = Scopes.scopesForIndexQuery();
ScopeProximity.emplace(QueryScopes);
@@ -1478,14 +1479,14 @@ private:
FuzzyFindRequest Req;
if (Opts.Limit)
Req.Limit = Opts.Limit;
- Req.Query = Filter->pattern();
+ Req.Query = std::string(Filter->pattern());
Req.RestrictForCodeCompletion = true;
Req.Scopes = QueryScopes;
Req.AnyScope = AllScopes;
// FIXME: we should send multiple weighted paths here.
- Req.ProximityPaths.push_back(FileName);
+ Req.ProximityPaths.push_back(std::string(FileName));
if (PreferredType)
- Req.PreferredTypes.push_back(PreferredType->raw());
+ Req.PreferredTypes.push_back(std::string(PreferredType->raw()));
vlog("Code complete: fuzzyFind({0:2})", toJSON(Req));
if (SpecFuzzyFind)
@@ -1807,8 +1808,9 @@ CompletionItem CodeCompletion::render(const CodeCompleteOptions &Opts) const {
RequiredQualifier + Name + Signature;
LSP.kind = Kind;
- LSP.detail = BundleSize > 1 ? llvm::formatv("[{0} overloads]", BundleSize)
- : ReturnType;
+ LSP.detail = BundleSize > 1
+ ? std::string(llvm::formatv("[{0} overloads]", BundleSize))
+ : ReturnType;
LSP.deprecated = Deprecated;
if (InsertInclude)
LSP.detail += "\n" + InsertInclude->Header;
diff --git a/clang-tools-extra/clangd/CompileCommands.cpp b/clang-tools-extra/clangd/CompileCommands.cpp
index f11b123..ae343d5 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -65,7 +65,7 @@ std::string resolve(std::string Path) {
log("Failed to resolve possible symlink {0}", Path);
return Path;
}
- return Resolved.str();
+ return std::string(Resolved.str());
}
// Get a plausible full `clang` path.
@@ -97,7 +97,7 @@ std::string detectClangPath() {
SmallString<128> ClangPath;
ClangPath = llvm::sys::path::parent_path(ClangdExecutable);
llvm::sys::path::append(ClangPath, "clang");
- return ClangPath.str();
+ return std::string(ClangPath.str());
}
// On mac, /usr/bin/clang sets SDKROOT and then invokes the real clang.
@@ -171,7 +171,7 @@ void CommandMangler::adjust(std::vector<std::string> &Cmd) const {
llvm::SmallString<128> QualifiedDriver =
llvm::sys::path::parent_path(*ClangPath);
llvm::sys::path::append(QualifiedDriver, Driver);
- Driver = QualifiedDriver.str();
+ Driver = std::string(QualifiedDriver.str());
}
}
}
diff --git a/clang-tools-extra/clangd/Diagnostics.cpp b/clang-tools-extra/clangd/Diagnostics.cpp
index ad8f6c8..380ce25 100644
--- a/clang-tools-extra/clangd/Diagnostics.cpp
+++ b/clang-tools-extra/clangd/Diagnostics.cpp
@@ -154,8 +154,8 @@ bool adjustDiagFromHeader(Diag &D, const clang::Diagnostic &Info,
const auto *FE = SM.getFileEntryForID(SM.getFileID(DiagLoc));
D.Notes.emplace_back();
Note &N = D.Notes.back();
- N.AbsFile = FE->tryGetRealPathName();
- N.File = FE->getName();
+ N.AbsFile = std::string(FE->tryGetRealPathName());
+ N.File = std::string(FE->getName());
N.Message = "error occurred here";
N.Range = diagnosticRange(Info, LangOpts);
@@ -320,7 +320,7 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Diag &D) {
CodeAction toCodeAction(const Fix &F, const URIForFile &File) {
CodeAction Action;
Action.title = F.Message;
- Action.kind = CodeAction::QUICKFIX_KIND;
+ Action.kind = std::string(CodeAction::QUICKFIX_KIND);
Action.edit.emplace();
Action.edit->changes.emplace();
(*Action.edit->changes)[File.uri()] = {F.Edits.begin(), F.Edits.end()};
@@ -430,7 +430,7 @@ std::vector<Diag> StoreDiags::take(const clang::tidy::ClangTidyContext *Tidy) {
// Almost always an error, with a name like err_enum_class_reference.
// Drop the err_ prefix for brevity.
Name.consume_front("err_");
- Diag.Name = Name;
+ Diag.Name = std::string(Name);
}
Diag.Source = Diag::Clang;
continue;
@@ -500,7 +500,7 @@ static void fillNonLocationData(DiagnosticsEngine::Level DiagLevel,
llvm::SmallString<64> Message;
Info.FormatDiagnostic(Message);
- D.Message = Message.str();
+ D.Message = std::string(Message.str());
D.Severity = DiagLevel;
D.Category = DiagnosticIDs::getCategoryNameFromID(
DiagnosticIDs::getCategoryNumberForDiag(Info.getID()))
@@ -544,7 +544,7 @@ void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
D.InsideMainFile = InsideMainFile;
D.Range = diagnosticRange(Info, *LangOpts);
- D.File = SM.getFilename(Info.getLocation());
+ D.File = std::string(SM.getFilename(Info.getLocation()));
D.AbsFile = getCanonicalPath(
SM.getFileEntryForID(SM.getFileID(Info.getLocation())), SM);
return D;
@@ -599,7 +599,8 @@ void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
}
if (Message.empty()) // either !SytheticMessage, or we failed to make one.
Info.FormatDiagnostic(Message);
- LastDiag->Fixes.push_back(Fix{Message.str(), std::move(Edits)});
+ LastDiag->Fixes.push_back(
+ Fix{std::string(Message.str()), std::move(Edits)});
return true;
};
diff --git a/clang-tools-extra/clangd/DraftStore.cpp b/clang-tools-extra/clangd/DraftStore.cpp
index dcf4813..d4a5d0c 100644
--- a/clang-tools-extra/clangd/DraftStore.cpp
+++ b/clang-tools-extra/clangd/DraftStore.cpp
@@ -28,7 +28,7 @@ std::vector<Path> DraftStore::getActiveFiles() const {
std::vector<Path> ResultVector;
for (auto DraftIt = Drafts.begin(); DraftIt != Drafts.end(); DraftIt++)
- ResultVector.push_back(DraftIt->getKey());
+ ResultVector.push_back(std::string(DraftIt->getKey()));
return ResultVector;
}
@@ -36,7 +36,7 @@ std::vector<Path> DraftStore::getActiveFiles() const {
void DraftStore::addDraft(PathRef File, llvm::StringRef Contents) {
std::lock_guard<std::mutex> Lock(Mutex);
- Drafts[File] = Contents;
+ Drafts[File] = std::string(Contents);
}
llvm::Expected<std::string> DraftStore::updateDraft(
diff --git a/clang-tools-extra/clangd/ExpectedTypes.cpp b/clang-tools-extra/clangd/ExpectedTypes.cpp
index a82a64c..e0a4e47 100644
--- a/clang-tools-extra/clangd/ExpectedTypes.cpp
+++ b/clang-tools-extra/clangd/ExpectedTypes.cpp
@@ -73,7 +73,7 @@ llvm::Optional<OpaqueType> OpaqueType::encode(ASTContext &Ctx, QualType T) {
llvm::SmallString<128> Encoded;
if (index::generateUSRForType(QualType(C, 0), Ctx, Encoded))
return None;
- return OpaqueType(Encoded.str());
+ return OpaqueType(std::string(Encoded.str()));
}
OpaqueType::OpaqueType(std::string Data) : Data(std::move(Data)) {}
diff --git a/clang-tools-extra/clangd/FS.cpp b/clang-tools-extra/clangd/FS.cpp
index 4f04fb0..6eea602 100644
--- a/clang-tools-extra/clangd/FS.cpp
+++ b/clang-tools-extra/clangd/FS.cpp
@@ -19,7 +19,7 @@ PreambleFileStatusCache::PreambleFileStatusCache(llvm::StringRef MainFilePath){
assert(llvm::sys::path::is_absolute(MainFilePath));
llvm::SmallString<256> MainFileCanonical(MainFilePath);
llvm::sys::path::remove_dots(MainFileCanonical, /*remove_dot_dot=*/true);
- this->MainFilePath = MainFileCanonical.str();
+ this->MainFilePath = std::string(MainFileCanonical.str());
}
void PreambleFileStatusCache::update(const llvm::vfs::FileSystem &FS,
diff --git a/clang-tools-extra/clangd/FindSymbols.cpp b/clang-tools-extra/clangd/FindSymbols.cpp
index 1ce4222..ee6e256 100644
--- a/clang-tools-extra/clangd/FindSymbols.cpp
+++ b/clang-tools-extra/clangd/FindSymbols.cpp
@@ -73,14 +73,14 @@ getWorkspaceSymbols(llvm::StringRef Query, int Limit,
auto Names = splitQualifiedName(Query);
FuzzyFindRequest Req;
- Req.Query = Names.second;
+ Req.Query = std::string(Names.second);
// FuzzyFind doesn't want leading :: qualifier
bool IsGlobalQuery = Names.first.consume_front("::");
// Restrict results to the scope in the query string if present (global or
// not).
if (IsGlobalQuery || !Names.first.empty())
- Req.Scopes = {Names.first};
+ Req.Scopes = {std::string(Names.first)};
else
Req.AnyScope = true;
if (Limit)
@@ -96,11 +96,11 @@ getWorkspaceSymbols(llvm::StringRef Query, int Limit,
}
SymbolKind SK = indexSymbolKindToSymbolKind(Sym.SymInfo.Kind);
- std::string Scope = Sym.Scope;
+ std::string Scope = std::string(Sym.Scope);
llvm::StringRef ScopeRef = Scope;
ScopeRef.consume_back("::");
SymbolInformation Info = {(Sym.Name + Sym.TemplateSpecializationArgs).str(),
- SK, *Loc, ScopeRef};
+ SK, *Loc, std::string(ScopeRef)};
SymbolQualitySignals Quality;
Quality.merge(Sym);
diff --git a/clang-tools-extra/clangd/FindTarget.cpp b/clang-tools-extra/clangd/FindTarget.cpp
index 352674eb..2392586 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -46,7 +46,7 @@ using ast_type_traits::DynTypedNode;
LLVM_ATTRIBUTE_UNUSED std::string
nodeToString(const ast_type_traits::DynTypedNode &N) {
- std::string S = N.getNodeKind().asStringRef();
+ std::string S = std::string(N.getNodeKind().asStringRef());
{
llvm::raw_string_ostream OS(S);
OS << ": ";
diff --git a/clang-tools-extra/clangd/Format.cpp b/clang-tools-extra/clangd/Format.cpp
index f34a16d..06b4b84 100644
--- a/clang-tools-extra/clangd/Format.cpp
+++ b/clang-tools-extra/clangd/Format.cpp
@@ -326,7 +326,7 @@ formatIncremental(llvm::StringRef OriginalCode, unsigned OriginalCursor,
tooling::Replacements Final;
unsigned FinalCursor = OriginalCursor;
#ifndef NDEBUG
- std::string FinalCode = OriginalCode;
+ std::string FinalCode = std::string(OriginalCode);
dlog("Initial code: {0}", FinalCode);
#endif
for (auto Pass :
diff --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index 34a0346..f2a6083 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -50,7 +50,7 @@ GlobalCompilationDatabase::getFallbackCommand(PathRef File) const {
auto FileExtension = llvm::sys::path::extension(File);
if (FileExtension.empty() || FileExtension == ".h")
Argv.push_back("-xobjective-c++-header");
- Argv.push_back(File);
+ Argv.push_back(std::string(File));
tooling::CompileCommand Cmd(llvm::sys::path::parent_path(File),
llvm::sys::path::filename(File), std::move(Argv),
/*Output=*/"");
@@ -95,7 +95,7 @@ static std::string maybeCaseFoldPath(PathRef Path) {
#if defined(_WIN32) || defined(__APPLE__)
return Path.lower();
#else
- return Path;
+ return std::string(Path);
#endif
}
@@ -117,7 +117,7 @@ DirectoryBasedGlobalCompilationDatabase::getCDBInDirLocked(PathRef Dir) const {
CachedCDB &Entry = R.first->second;
std::string Error = "";
Entry.CDB = tooling::CompilationDatabase::loadFromDirectory(Dir, Error);
- Entry.Path = Dir;
+ Entry.Path = std::string(Dir);
}
return R.first->second;
}
diff --git a/clang-tools-extra/clangd/HeaderSourceSwitch.cpp b/clang-tools-extra/clangd/HeaderSourceSwitch.cpp
index f90e46a..1490d3e 100644
--- a/clang-tools-extra/clangd/HeaderSourceSwitch.cpp
+++ b/clang-tools-extra/clangd/HeaderSourceSwitch.cpp
@@ -121,7 +121,7 @@ llvm::Optional<Path> getCorrespondingHeaderOrSource(const Path &OriginalFile,
// candidates.
Best = It;
}
- return Path(Best->first());
+ return Path(std::string(Best->first()));
}
std::vector<const Decl *> getIndexableLocalDecls(ParsedAST &AST) {
diff --git a/clang-tools-extra/clangd/Headers.cpp b/clang-tools-extra/clangd/Headers.cpp
index 525f770..e94a768 100644
--- a/clang-tools-extra/clangd/Headers.cpp
+++ b/clang-tools-extra/clangd/Headers.cpp
@@ -41,7 +41,7 @@ public:
Inc.R = halfOpenToRange(SM, FilenameRange);
Inc.Written =
(IsAngled ? "<" + FileName + ">" : "\"" + FileName + "\"").str();
- Inc.Resolved = File ? File->tryGetRealPathName() : "";
+ Inc.Resolved = std::string(File ? File->tryGetRealPathName() : "");
Inc.HashOffset = SM.getFileOffset(HashLoc);
Inc.FileKind = FileKind;
}
@@ -120,7 +120,7 @@ void IncludeStructure::recordInclude(llvm::StringRef IncludingName,
llvm::StringRef IncludedRealName) {
auto Child = fileIndex(IncludedName);
if (!IncludedRealName.empty() && RealPathNames[Child].empty())
- RealPathNames[Child] = IncludedRealName;
+ RealPathNames[Child] = std::string(IncludedRealName);
auto Parent = fileIndex(IncludingName);
IncludeChildren[Parent].push_back(Child);
}
diff --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp
index 834c9d0..803efdf 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -245,8 +245,9 @@ void enhanceFromIndex(HoverInfo &Hover, const NamedDecl &ND,
return;
LookupRequest Req;
Req.IDs.insert(*ID);
- Index->lookup(
- Req, [&](const Symbol &S) { Hover.Documentation = S.Documentation; });
+ Index->lookup(Req, [&](const Symbol &S) {
+ Hover.Documentation = std::string(S.Documentation);
+ });
}
// Populates Type, ReturnType, and Parameters for function-like decls.
@@ -410,7 +411,7 @@ HoverInfo getHoverContents(QualType T, ASTContext &ASTCtx,
HoverInfo getHoverContents(const DefinedMacro &Macro, ParsedAST &AST) {
HoverInfo HI;
SourceManager &SM = AST.getSourceManager();
- HI.Name = Macro.Name;
+ HI.Name = std::string(Macro.Name);
HI.Kind = index::SymbolKind::Macro;
// FIXME: Populate documentation
// FIXME: Pupulate parameters
@@ -473,7 +474,7 @@ llvm::Optional<HoverInfo> getHoverContents(const Expr *E, ParsedAST &AST) {
Policy.SuppressTagKeyword = true;
HI.Type = printType(E->getType(), Policy);
HI.Value = *Val;
- HI.Name = getNameForExpr(E);
+ HI.Name = std::string(getNameForExpr(E));
return HI;
}
return llvm::None;
@@ -545,7 +546,7 @@ markup::Document HoverInfo::present() const {
// https://github.com/microsoft/vscode/issues/88417 for details.
markup::Paragraph &Header = Output.addHeading(3);
if (Kind != index::SymbolKind::Unknown)
- Header.appendText(index::getSymbolKindString(Kind));
+ Header.appendText(std::string(index::getSymbolKindString(Kind)));
assert(!Name.empty() && "hover triggered on a nameless symbol");
Header.appendCode(Name);
diff --git a/clang-tools-extra/clangd/IncludeFixer.cpp b/clang-tools-extra/clangd/IncludeFixer.cpp
index 17280d6..45fb07a 100644
--- a/clang-tools-extra/clangd/IncludeFixer.cpp
+++ b/clang-tools-extra/clangd/IncludeFixer.cpp
@@ -173,10 +173,10 @@ std::vector<Fix> IncludeFixer::fixesForSymbols(const SymbolSlab &Syms) const {
if (!I.second)
continue;
if (auto Edit = Inserter->insert(ToInclude->first))
- Fixes.push_back(
- Fix{llvm::formatv("Add include {0} for symbol {1}{2}",
- ToInclude->first, Sym.Scope, Sym.Name),
- {std::move(*Edit)}});
+ Fixes.push_back(Fix{std::string(llvm::formatv(
+ "Add include {0} for symbol {1}{2}",
+ ToInclude->first, Sym.Scope, Sym.Name)),
+ {std::move(*Edit)}});
}
} else {
vlog("Failed to calculate include insertion for {0} into {1}: {2}", Inc,
@@ -295,7 +295,7 @@ llvm::Optional<CheapUnresolvedName> extractUnresolvedNameCheaply(
// it as extra scope. With "index" being a specifier, we append "index::"
// to the extra scope.
Result.UnresolvedScope->append((Result.Name + Split.first).str());
- Result.Name = Split.second;
+ Result.Name = std::string(Split.second);
}
}
return Result;
diff --git a/clang-tools-extra/clangd/JSONTransport.cpp b/clang-tools-extra/clangd/JSONTransport.cpp
index 6351b80..43be9f7 100644
--- a/clang-tools-extra/clangd/JSONTransport.cpp
+++ b/clang-tools-extra/clangd/JSONTransport.cpp
@@ -34,7 +34,8 @@ llvm::json::Object encodeError(llvm::Error E) {
}
llvm::Error decodeError(const llvm::json::Object &O) {
- std::string Msg = O.getString("message").getValueOr("Unspecified error");
+ std::string Msg =
+ std::string(O.getString("message").getValueOr("Unspecified error"));
if (auto Code = O.getInteger("code"))
return llvm::make_error<LSPError>(std::move(Msg), ErrorCode(*Code));
return llvm::make_error<llvm::StringError>(std::move(Msg),
diff --git a/clang-tools-extra/clangd/ParsedAST.cpp b/clang-tools-extra/clangd/ParsedAST.cpp
index 4236a97..c8c06fd 100644
--- a/clang-tools-extra/clangd/ParsedAST.cpp
+++ b/clang-tools-extra/clangd/ParsedAST.cpp
@@ -229,8 +229,9 @@ ParsedAST::build(std::unique_ptr<clang::CompilerInvocation> CI,
Preamble ? &Preamble->Preamble : nullptr;
StoreDiags ASTDiags;
- std::string Content = Buffer->getBuffer();
- std::string Filename = Buffer->getBufferIdentifier(); // Absolute.
+ std::string Content = std::string(Buffer->getBuffer());
+ std::string Filename =
+ std::string(Buffer->getBufferIdentifier()); // Absolute.
auto Clang = prepareCompilerInstance(std::move(CI), PreamblePCH,
std::move(Buffer), VFS, ASTDiags);
diff --git a/clang-tools-extra/clangd/PathMapping.cpp b/clang-tools-extra/clangd/PathMapping.cpp
index e130f38..8740d58 100644
--- a/clang-tools-extra/clangd/PathMapping.cpp
+++ b/clang-tools-extra/clangd/PathMapping.cpp
@@ -149,7 +149,7 @@ private:
llvm::Expected<std::string> parsePath(llvm::StringRef Path) {
namespace path = llvm::sys::path;
if (path::is_absolute(Path, path::Style::posix)) {
- return Path;
+ return std::string(Path);
} else if (path::is_absolute(Path, path::Style::windows)) {
std::string Converted = path::convert_to_slash(Path, path::Style::windows);
if (Converted.front() != '/')
diff --git a/clang-tools-extra/clangd/Protocol.cpp b/clang-tools-extra/clangd/Protocol.cpp
index 87f7656..aabf0fa 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -37,7 +37,7 @@ URIForFile URIForFile::canonicalize(llvm::StringRef AbsPath,
elog("URIForFile: failed to resolve path {0} with TU path {1}: "
"{2}.\nUsing unresolved path.",
AbsPath, TUPath, Resolved.takeError());
- return URIForFile(AbsPath);
+ return URIForFile(std::string(AbsPath));
}
return URIForFile(std::move(*Resolved));
}
diff --git a/clang-tools-extra/clangd/QueryDriverDatabase.cpp b/clang-tools-extra/clangd/QueryDriverDatabase.cpp
index 4953da5..e4f5c48 100644
--- a/clang-tools-extra/clangd/QueryDriverDatabase.cpp
+++ b/clang-tools-extra/clangd/QueryDriverDatabase.cpp
@@ -243,11 +243,13 @@ public:
{
std::lock_guard<std::mutex> Lock(Mu);
- auto It = DriverToIncludesCache.find(Key);
+ auto It = DriverToIncludesCache.find(
+ {std::string(Key.first), std::string(Key.second)});
if (It != DriverToIncludesCache.end())
SystemIncludes = It->second;
else
- DriverToIncludesCache[Key] = SystemIncludes =
+ DriverToIncludesCache[{std::string(Key.first),
+ std::string(Key.second)}] = SystemIncludes =
extractSystemIncludes(Key.first, Key.second, QueryDriverRegex);
}
diff --git a/clang-tools-extra/clangd/SourceCode.cpp b/clang-tools-extra/clangd/SourceCode.cpp
index 15403d2..67cea92 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -608,7 +608,7 @@ TextEdit replacementToEdit(llvm::StringRef Code,
Range ReplacementRange = {
offsetToPosition(Code, R.getOffset()),
offsetToPosition(Code, R.getOffset() + R.getLength())};
- return {ReplacementRange, R.getReplacementText()};
+ return {ReplacementRange, std::string(R.getReplacementText())};
}
std::vector<TextEdit> replacementsToEdits(llvm::StringRef Code,
@@ -801,12 +801,12 @@ void parseNamespaceEvents(llvm::StringRef Code,
switch (State) {
case UsingNamespace:
case UsingNamespaceName:
- NSName.append(Tok.getRawIdentifier());
+ NSName.append(std::string(Tok.getRawIdentifier()));
State = UsingNamespaceName;
break;
case Namespace:
case NamespaceName:
- NSName.append(Tok.getRawIdentifier());
+ NSName.append(std::string(Tok.getRawIdentifier()));
State = NamespaceName;
break;
case Using:
@@ -928,11 +928,11 @@ std::vector<std::string> visibleNamespaces(llvm::StringRef Code,
std::vector<std::string> Found;
for (llvm::StringRef Enclosing : ancestorNamespaces(Current)) {
- Found.push_back(Enclosing);
+ Found.push_back(std::string(Enclosing));
auto It = UsingDirectives.find(Enclosing);
if (It != UsingDirectives.end())
for (const auto &Used : It->second)
- Found.push_back(Used.getKey());
+ Found.push_back(std::string(Used.getKey()));
}
llvm::sort(Found, [&](const std::string &LHS, const std::string &RHS) {
diff --git a/clang-tools-extra/clangd/TUScheduler.cpp b/clang-tools-extra/clangd/TUScheduler.cpp
index c4f9e6e..9ea1582 100644
--- a/clang-tools-extra/clangd/TUScheduler.cpp
+++ b/clang-tools-extra/clangd/TUScheduler.cpp
@@ -644,7 +644,7 @@ void ASTWorker::startTask(llvm::StringRef Name,
std::lock_guard<std::mutex> Lock(Mutex);
assert(!Done && "running a task after stop()");
Requests.push_back(
- {std::move(Task), Name, steady_clock::now(),
+ {std::move(Task), std::string(Name), steady_clock::now(),
Context::current().derive(kFileBeingProcessed, FileName), UpdateType});
}
RequestsCV.notify_all();
@@ -986,31 +986,32 @@ void TUScheduler::runWithPreamble(llvm::StringRef Name, PathRef File,
}
std::shared_ptr<const ASTWorker> Worker = It->second->Worker.lock();
- auto Task = [Worker, Consistency, Name = Name.str(), File = File.str(),
- Contents = It->second->Contents,
- Command = Worker->getCurrentCompileCommand(),
- Ctx = Context::current().derive(kFileBeingProcessed, File),
- ConsistentPreamble = std::move(ConsistentPreamble),
- Action = std::move(Action), this]() mutable {
- std::shared_ptr<const PreambleData> Preamble;
- if (ConsistentPreamble.valid()) {
- Preamble = ConsistentPreamble.get();
- } else {
- if (Consistency != PreambleConsistency::StaleOrAbsent) {
- // Wait until the preamble is built for the first time, if preamble is
- // required. This avoids extra work of processing the preamble headers
- // in parallel multiple times.
- Worker->waitForFirstPreamble();
- }
- Preamble = Worker->getPossiblyStalePreamble();
- }
+ auto Task =
+ [Worker, Consistency, Name = Name.str(), File = File.str(),
+ Contents = It->second->Contents,
+ Command = Worker->getCurrentCompileCommand(),
+ Ctx = Context::current().derive(kFileBeingProcessed, std::string(File)),
+ ConsistentPreamble = std::move(ConsistentPreamble),
+ Action = std::move(Action), this]() mutable {
+ std::shared_ptr<const PreambleData> Preamble;
+ if (ConsistentPreamble.valid()) {
+ Preamble = ConsistentPreamble.get();
+ } else {
+ if (Consistency != PreambleConsistency::StaleOrAbsent) {
+ // Wait until the preamble is built for the first time, if preamble
+ // is required. This avoids extra work of processing the preamble
+ // headers in parallel multiple times.
+ Worker->waitForFirstPreamble();
+ }
+ Preamble = Worker->getPossiblyStalePreamble();
+ }
- std::lock_guard<Semaphore> BarrierLock(Barrier);
- WithContext Guard(std::move(Ctx));
- trace::Span Tracer(Name);
- SPAN_ATTACH(Tracer, "file", File);
- Action(InputsAndPreamble{Contents, Command, Preamble.get()});
- };
+ std::lock_guard<Semaphore> BarrierLock(Barrier);
+ WithContext Guard(std::move(Ctx));
+ trace::Span Tracer(Name);
+ SPAN_ATTACH(Tracer, "file", File);
+ Action(InputsAndPreamble{Contents, Command, Preamble.get()});
+ };
PreambleTasks->runAsync("task:" + llvm::sys::path::filename(File),
std::move(Task));
@@ -1021,8 +1022,8 @@ TUScheduler::getUsedBytesPerFile() const {
std::vector<std::pair<Path, std::size_t>> Result;
Result.reserve(Files.size());
for (auto &&PathAndFile : Files)
- Result.push_back(
- {PathAndFile.first(), PathAndFile.second->Worker->getUsedBytes()});
+ Result.push_back({std::string(PathAndFile.first()),
+ PathAndFile.second->Worker->getUsedBytes()});
return Result;
}
@@ -1031,7 +1032,7 @@ std::vector<Path> TUScheduler::getFilesWithCachedAST() const {
for (auto &&PathAndFile : Files) {
if (!PathAndFile.second->Worker->isASTCached())
continue;
- Result.push_back(PathAndFile.first());
+ Result.push_back(std::string(PathAndFile.first()));
}
return Result;
}
diff --git a/clang-tools-extra/clangd/URI.cpp b/clang-tools-extra/clangd/URI.cpp
index f8a9f59..1a125e7 100644
--- a/clang-tools-extra/clangd/URI.cpp
+++ b/clang-tools-extra/clangd/URI.cpp
@@ -255,7 +255,7 @@ llvm::Expected<std::string> URI::resolvePath(llvm::StringRef AbsPath,
return S->getAbsolutePath(U->Authority, U->Body, HintPath);
}
// Fallback to file: scheme which doesn't do any canonicalization.
- return AbsPath;
+ return std::string(AbsPath);
}
llvm::Expected<std::string> URI::includeSpelling(const URI &Uri) {
diff --git a/clang-tools-extra/clangd/XRefs.cpp b/clang-tools-extra/clangd/XRefs.cpp
index ac62393..6e625d8 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -201,7 +201,7 @@ std::vector<LocatedSymbol> locateSymbolAt(ParsedAST &AST, Position Pos,
for (auto &Inc : AST.getIncludeStructure().MainFileIncludes) {
if (!Inc.Resolved.empty() && Inc.R.start.line == Pos.line) {
LocatedSymbol File;
- File.Name = llvm::sys::path::filename(Inc.Resolved);
+ File.Name = std::string(llvm::sys::path::filename(Inc.Resolved));
File.PreferredDeclaration = {
URIForFile::canonicalize(Inc.Resolved, *MainFilePath), Range{}};
File.Definition = File.PreferredDeclaration;
@@ -219,7 +219,7 @@ std::vector<LocatedSymbol> locateSymbolAt(ParsedAST &AST, Position Pos,
if (auto Loc = makeLocation(AST.getASTContext(),
M->Info->getDefinitionLoc(), *MainFilePath)) {
LocatedSymbol Macro;
- Macro.Name = M->Name;
+ Macro.Name = std::string(M->Name);
Macro.PreferredDeclaration = *Loc;
Macro.Definition = Loc;
Result.push_back(std::move(Macro));
@@ -530,8 +530,9 @@ std::vector<SymbolDetails> getSymbolInfo(ParsedAST &AST, Position Pos) {
for (const NamedDecl *D : getDeclAtPosition(AST, Loc, Relations)) {
SymbolDetails NewSymbol;
std::string QName = printQualifiedName(*D);
- std::tie(NewSymbol.containerName, NewSymbol.name) =
- splitQualifiedName(QName);
+ auto SplitQName = splitQualifiedName(QName);
+ NewSymbol.containerName = std::string(SplitQName.first);
+ NewSymbol.name = std::string(SplitQName.second);
if (NewSymbol.containerName.empty()) {
if (const auto *ParentND =
@@ -540,7 +541,7 @@ std::vector<SymbolDetails> getSymbolInfo(ParsedAST &AST, Position Pos) {
}
llvm::SmallString<32> USR;
if (!index::generateUSRForDecl(D, USR)) {
- NewSymbol.USR = USR.str();
+ NewSymbol.USR = std::string(USR.str());
NewSymbol.ID = SymbolID(NewSymbol.USR);
}
Results.push_back(std::move(NewSymbol));
@@ -548,11 +549,11 @@ std::vector<SymbolDetails> getSymbolInfo(ParsedAST &AST, Position Pos) {
if (auto M = locateMacroAt(Loc, AST.getPreprocessor())) {
SymbolDetails NewMacro;
- NewMacro.name = M->Name;
+ NewMacro.name = std::string(M->Name);
llvm::SmallString<32> USR;
if (!index::generateUSRForMacro(NewMacro.name, M->Info->getDefinitionLoc(),
SM, USR)) {
- NewMacro.USR = USR.str();
+ NewMacro.USR = std::string(USR.str());
NewMacro.ID = SymbolID(NewMacro.USR);
}
Results.push_back(std::move(NewMacro));
@@ -624,7 +625,7 @@ symbolToTypeHierarchyItem(const Symbol &S, const SymbolIndex *Index,
return llvm::None;
}
TypeHierarchyItem THI;
- THI.name = S.Name;
+ THI.name = std::string(S.Name);
THI.kind = indexSymbolKindToSymbolKind(S.SymInfo.Kind);
THI.deprecated = (S.Flags & Symbol::Deprecated);
THI.selectionRange = Loc->range;
diff --git a/clang-tools-extra/clangd/index/Background.cpp b/clang-tools-extra/clangd/index/Background.cpp
index dd198f0..ab80113 100644
--- a/clang-tools-extra/clangd/index/Background.cpp
+++ b/clang-tools-extra/clangd/index/Background.cpp
@@ -202,7 +202,7 @@ BackgroundIndex::indexFileTask(tooling::CompileCommand Cmd) {
elog("Indexing {0} failed: {1}", FileName, std::move(Error));
});
T.QueuePri = IndexFile;
- T.Tag = filenameWithoutExtension(Cmd.Filename);
+ T.Tag = std::string(filenameWithoutExtension(Cmd.Filename));
return T;
}
diff --git a/clang-tools-extra/clangd/index/BackgroundIndexLoader.cpp b/clang-tools-extra/clangd/index/BackgroundIndexLoader.cpp
index ff690f9..08bf07d 100644
--- a/clang-tools-extra/clangd/index/BackgroundIndexLoader.cpp
+++ b/clang-tools-extra/clangd/index/BackgroundIndexLoader.cpp
@@ -59,7 +59,7 @@ BackgroundIndexLoader::loadShard(PathRef StartSourceFile, PathRef DependentTU) {
return {LS, Edges};
LS.AbsolutePath = StartSourceFile.str();
- LS.DependentTU = DependentTU;
+ LS.DependentTU = std::string(DependentTU);
BackgroundIndexStorage *Storage = IndexStorageFactory(LS.AbsolutePath);
auto Shard = Storage->loadShard(StartSourceFile);
if (!Shard || !Shard->Sources) {
diff --git a/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp b/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
index 48510e1..b07728e 100644
--- a/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
+++ b/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
@@ -33,7 +33,7 @@ std::string getShardPathFromFilePath(llvm::StringRef ShardRoot,
llvm::sys::path::append(ShardRootSS, llvm::sys::path::filename(FilePath) +
"." + llvm::toHex(digest(FilePath)) +
".idx");
- return ShardRootSS.str();
+ return std::string(ShardRootSS.str());
}
// Uses disk as a storage for index shards. Creates a directory called
@@ -47,7 +47,7 @@ public:
DiskBackedIndexStorage(llvm::StringRef Directory) {
llvm::SmallString<128> CDBDirectory(Directory);
llvm::sys::path::append(CDBDirectory, ".clangd", "index");
- DiskShardRoot = CDBDirectory.str();
+ DiskShardRoot = std::string(CDBDirectory.str());
std::error_code OK;
std::error_code EC = llvm::sys::fs::create_directories(DiskShardRoot);
if (EC != OK) {
diff --git a/clang-tools-extra/clangd/index/CanonicalIncludes.cpp b/clang-tools-extra/clangd/index/CanonicalIncludes.cpp
index 0025a7c..a3b1334 100644
--- a/clang-tools-extra/clangd/index/CanonicalIncludes.cpp
+++ b/clang-tools-extra/clangd/index/CanonicalIncludes.cpp
@@ -21,7 +21,7 @@ const char IWYUPragma[] = "// IWYU pragma: private, include ";
void CanonicalIncludes::addMapping(llvm::StringRef Path,
llvm::StringRef CanonicalPath) {
- FullPathMapping[Path] = CanonicalPath;
+ FullPathMapping[Path] = std::string(CanonicalPath);
}
/// The maximum number of path components in a key from StdSuffixHeaderMapping.
diff --git a/clang-tools-extra/clangd/index/FileIndex.cpp b/clang-tools-extra/clangd/index/FileIndex.cpp
index 179e143..7641aa5 100644
--- a/clang-tools-extra/clangd/index/FileIndex.cpp
+++ b/clang-tools-extra/clangd/index/FileIndex.cpp
@@ -67,7 +67,8 @@ static SlabTuple indexSymbols(ASTContext &AST, std::shared_ptr<Preprocessor> PP,
const auto &SM = AST.getSourceManager();
const auto *MainFileEntry = SM.getFileEntryForID(SM.getMainFileID());
- std::string FileName = MainFileEntry ? MainFileEntry->getName() : "";
+ std::string FileName =
+ std::string(MainFileEntry ? MainFileEntry->getName() : "");
auto Syms = Collector.takeSymbols();
auto Refs = Collector.takeRefs();
diff --git a/clang-tools-extra/clangd/index/Serialization.cpp b/clang-tools-extra/clangd/index/Serialization.cpp
index 219c896..440fdc6 100644
--- a/clang-tools-extra/clangd/index/Serialization.cpp
+++ b/clang-tools-extra/clangd/index/Serialization.cpp
@@ -169,7 +169,7 @@ public:
std::string RawTable;
for (llvm::StringRef S : Sorted) {
- RawTable.append(S);
+ RawTable.append(std::string(S));
RawTable.push_back(0);
}
if (llvm::zlib::isAvailable()) {
@@ -501,7 +501,7 @@ llvm::Expected<IndexFileIn> readRIFF(llvm::StringRef Data) {
InternedCompileCommand Cmd =
readCompileCommand(CmdReader, Strings->Strings);
Result.Cmd.emplace();
- Result.Cmd->Directory = Cmd.Directory;
+ Result.Cmd->Directory = std::string(Cmd.Directory);
Result.Cmd->CommandLine.reserve(Cmd.CommandLine.size());
for (llvm::StringRef C : Cmd.CommandLine)
Result.Cmd->CommandLine.emplace_back(C);
diff --git a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
index 81e435f..66477ad 100644
--- a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -55,13 +55,13 @@ std::vector<SymbolID> getSymbolIDsFromIndex(llvm::StringRef QualifiedName,
bool IsGlobalScope = QualifiedName.consume_front("::");
auto Names = splitQualifiedName(QualifiedName);
if (IsGlobalScope || !Names.first.empty())
- Request.Scopes = {Names.first};
+ Request.Scopes = {std::string(Names.first)};
else
// QualifiedName refers to a symbol in global scope (e.g. "GlobalSymbol"),
// add the global scope to the request.
Request.Scopes = {""};
- Request.Query = Names.second;
+ Request.Query = std::string(Names.second);
std::vector<SymbolID> SymIDs;
Index->fuzzyFind(Request, [&](const Symbol &Sym) {
std::string SymQualifiedName = (Sym.Scope + Sym.Name).str();
diff --git a/clang-tools-extra/clangd/refactor/Tweak.h b/clang-tools-extra/clangd/refactor/Tweak.h
index 14f9ffc..ca4d43d 100644
--- a/clang-tools-extra/clangd/refactor/Tweak.h
+++ b/clang-tools-extra/clangd/refactor/Tweak.h
@@ -81,7 +81,7 @@ public:
static Effect showMessage(StringRef S) {
Effect E;
- E.ShowMessage = S;
+ E.ShowMessage = std::string(S);
return E;
}
diff --git a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
index 3d345cd..8f396e3 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
@@ -250,7 +250,7 @@ renameParameters(const FunctionDecl *Dest, const FunctionDecl *Source) {
// with previous token, e.g. foo(int^) shouldn't turn into foo(intx).
NewName = " ";
}
- NewName.append(SourceParam->getName());
+ NewName.append(std::string(SourceParam->getName()));
ParamToNewName[DestParam->getCanonicalDecl()] = std::move(NewName);
};
diff --git a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
index a6fcc72..bdfd0e4 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -64,10 +64,11 @@ const FunctionDecl *getSelectedFunction(const SelectionTree::Node *SelNode) {
llvm::Optional<Path> getSourceFile(llvm::StringRef FileName,
const Tweak::Selection &Sel) {
if (auto Source = getCorrespondingHeaderOrSource(
- FileName,
+ std::string(FileName),
&Sel.AST->getSourceManager().getFileManager().getVirtualFileSystem()))
return *Source;
- return getCorrespondingHeaderOrSource(FileName, *Sel.AST, Sel.Index);
+ return getCorrespondingHeaderOrSource(std::string(FileName), *Sel.AST,
+ Sel.Index);
}
// Synthesize a DeclContext for TargetNS from CurContext. TargetNS must be empty
diff --git a/clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp b/clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
index f681400..616e100 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
@@ -42,7 +42,8 @@ public:
}
Expected<Effect> apply(const Selection &Inputs) override;
std::string title() const override {
- return llvm::formatv("Dump {0} AST", Node->getNodeKind().asStringRef());
+ return std::string(
+ llvm::formatv("Dump {0} AST", Node->getNodeKind().asStringRef()));
}
Intent intent() const override { return Info; }
bool hidden() const override { return true; }
@@ -148,9 +149,9 @@ public:
return Effect::showMessage(std::move(OS.str()));
}
std::string title() const override {
- return llvm::formatv(
+ return std::string(llvm::formatv(
"Show {0} layout",
- TypeWithKeyword::getTagTypeKindName(Record->getTagKind()));
+ TypeWithKeyword::getTagTypeKindName(Record->getTagKind())));
}
Intent intent() const override { return Info; }
// FIXME: this is interesting to most users. However:
diff --git a/clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp b/clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp
index eb15d03..59a53f97 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp
@@ -98,7 +98,7 @@ bool ExpandMacro::prepare(const Selection &Inputs) {
auto Expansion = Inputs.AST->getTokens().expansionStartingAt(T);
if (!Expansion)
return false;
- this->MacroName = T->text(Inputs.AST->getSourceManager());
+ this->MacroName = std::string(T->text(Inputs.AST->getSourceManager()));
this->Expansion = *Expansion;
return true;
}
@@ -126,7 +126,7 @@ Expected<Tweak::Effect> ExpandMacro::apply(const Selection &Inputs) {
}
std::string ExpandMacro::title() const {
- return llvm::formatv("Expand macro '{0}'", MacroName);
+ return std::string(llvm::formatv("Expand macro '{0}'", MacroName));
}
} // namespace
diff --git a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
index da8e6e0..52905c3 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -347,16 +347,16 @@ std::string NewFunction::renderParametersForCall() const {
}
std::string NewFunction::renderCall() const {
- return llvm::formatv(
- "{0}{1}({2}){3}", CallerReturnsValue ? "return " : "", Name,
- renderParametersForCall(),
- (SemicolonPolicy.isNeededInOriginalFunction() ? ";" : ""));
+ return std::string(
+ llvm::formatv("{0}{1}({2}){3}", CallerReturnsValue ? "return " : "", Name,
+ renderParametersForCall(),
+ (SemicolonPolicy.isNeededInOriginalFunction() ? ";" : "")));
}
std::string NewFunction::renderDefinition(const SourceManager &SM) const {
- return llvm::formatv("{0} {1}({2}) {\n{3}\n}\n",
- printType(ReturnType, *EnclosingFuncContext), Name,
- renderParametersForDefinition(), getFuncBody(SM));
+ return std::string(llvm::formatv(
+ "{0} {1}({2}) {\n{3}\n}\n", printType(ReturnType, *EnclosingFuncContext),
+ Name, renderParametersForDefinition(), getFuncBody(SM)));
}
std::string NewFunction::getFuncBody(const SourceManager &SM) const {
@@ -578,8 +578,9 @@ bool createParameters(NewFunction &ExtractedFunc,
// pointers, etc by reference.
bool IsPassedByReference = true;
// We use the index of declaration as the ordering priority for parameters.
- ExtractedFunc.Parameters.push_back(
- {VD->getName(), TypeInfo, IsPassedByReference, DeclInfo.DeclIndex});
+ ExtractedFunc.Parameters.push_back({std::string(VD->getName()), TypeInfo,
+ IsPassedByReference,
+ DeclInfo.DeclIndex});
}
llvm::sort(ExtractedFunc.Parameters);
return true;
diff --git a/clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp b/clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
index d2edde3..e054e33 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
@@ -199,7 +199,8 @@ Expected<Tweak::Effect> RemoveUsingNamespace::apply(const Selection &Inputs) {
}
std::string RemoveUsingNamespace::title() const {
- return llvm::formatv("Remove using namespace, re-qualify names instead.");
+ return std::string(
+ llvm::formatv("Remove using namespace, re-qualify names instead."));
}
} // namespace
} // namespace clangd
diff --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index c0c4c18..6dc6be3 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -591,7 +591,7 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
"--compile-commands-dir to an absolute path: "
<< EC.message() << ". The argument will be ignored.\n";
} else {
- CompileCommandsDirPath = Path.str();
+ CompileCommandsDirPath = std::string(Path.str());
}
} else {
llvm::errs()
diff --git a/clang-tools-extra/clangd/unittests/ClangdTests.cpp b/clang-tools-extra/clangd/unittests/ClangdTests.cpp
index fbc6e64..627b9b2 100644
--- a/clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -146,7 +146,8 @@ protected:
MockCompilationDatabase CDB;
ClangdServer Server(CDB, FS, ClangdServer::optsForTest(), &DiagConsumer);
for (const auto &FileWithContents : ExtraFiles)
- FS.Files[testPath(FileWithContents.first)] = FileWithContents.second;
+ FS.Files[testPath(FileWithContents.first)] =
+ std::string(FileWithContents.second);
auto SourceFilename = testPath(SourceFileRelPath);
Server.addDocument(SourceFilename, SourceContents);
@@ -1020,7 +1021,8 @@ TEST_F(ClangdVFSTest, FallbackWhenWaitingForCompileCommand) {
// something goes wrong.
CanReturnCommand.wait();
auto FileName = llvm::sys::path::filename(File);
- std::vector<std::string> CommandLine = {"clangd", "-ffreestanding", File};
+ std::vector<std::string> CommandLine = {"clangd", "-ffreestanding",
+ std::string(File)};
return {tooling::CompileCommand(llvm::sys::path::parent_path(File),
FileName, std::move(CommandLine), "")};
}
diff --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index b055d1c..1a9950ae 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1073,7 +1073,7 @@ MATCHER_P(SigDoc, Doc, "") { return arg.documentation == Doc; }
/// foo([[int p1]], [[double p2]]) -> void
Matcher<SignatureInformation> Sig(llvm::StringRef AnnotatedLabel) {
llvm::Annotations A(AnnotatedLabel);
- std::string Label = A.code();
+ std::string Label = std::string(A.code());
std::vector<ExpectedParameter> Parameters;
for (auto Range : A.ranges()) {
Parameters.emplace_back();
diff --git a/clang-tools-extra/clangd/unittests/DexTests.cpp b/clang-tools-extra/clangd/unittests/DexTests.cpp
index 9402c3c..53abb26 100644
--- a/clang-tools-extra/clangd/unittests/DexTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DexTests.cpp
@@ -739,10 +739,10 @@ TEST(DexTest, PreferredTypesBoosting) {
// The best candidate can change depending on the preferred type.
Req.Limit = 1;
- Req.PreferredTypes = {Sym1.Type};
+ Req.PreferredTypes = {std::string(Sym1.Type)};
EXPECT_THAT(match(I, Req), ElementsAre("t1"));
- Req.PreferredTypes = {Sym2.Type};
+ Req.PreferredTypes = {std::string(Sym2.Type)};
EXPECT_THAT(match(I, Req), ElementsAre("t2"));
}
diff --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index 79d51fa..1e3720a 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -208,7 +208,7 @@ TEST(DiagnosticsTest, DeduplicatedClangTidyDiagnostics) {
func(2.0);
}
)cpp");
- TU.Code = Test.code();
+ TU.Code = std::string(Test.code());
// The check doesn't handle template instantiations which ends up emitting
// duplicated messages, verify that we deduplicate them.
EXPECT_THAT(
@@ -433,7 +433,7 @@ TEST(DiagnosticsTest, ToLSP) {
D.InsideMainFile = true;
D.Severity = DiagnosticsEngine::Error;
D.File = "foo/bar/main.cpp";
- D.AbsFile = MainFile.file();
+ D.AbsFile = std::string(MainFile.file());
clangd::Note NoteInMain;
NoteInMain.Message = "declared somewhere in the main file";
@@ -441,7 +441,7 @@ TEST(DiagnosticsTest, ToLSP) {
NoteInMain.Severity = DiagnosticsEngine::Remark;
NoteInMain.File = "../foo/bar/main.cpp";
NoteInMain.InsideMainFile = true;
- NoteInMain.AbsFile = MainFile.file();
+ NoteInMain.AbsFile = std::string(MainFile.file());
D.Notes.push_back(NoteInMain);
@@ -451,7 +451,7 @@ TEST(DiagnosticsTest, ToLSP) {
NoteInHeader.Severity = DiagnosticsEngine::Note;
NoteInHeader.File = "../foo/baz/header.h";
NoteInHeader.InsideMainFile = false;
- NoteInHeader.AbsFile = HeaderFile.file();
+ NoteInHeader.AbsFile = std::string(HeaderFile.file());
D.Notes.push_back(NoteInHeader);
clangd::Fix F;
@@ -738,7 +738,7 @@ $insert[[]]namespace ns {
void g() { ns::$[[scope]]::X_Y(); }
)cpp");
TestTU TU;
- TU.Code = Test.code();
+ TU.Code = std::string(Test.code());
// FIXME: Figure out why this is needed and remove it, PR43662.
TU.ExtraArgs.push_back("-fno-ms-compatibility");
auto Index = buildIndexWithSymbol(
@@ -764,7 +764,7 @@ void f() {
}
)cpp");
TestTU TU;
- TU.Code = Test.code();
+ TU.Code = std::string(Test.code());
// FIXME: Figure out why this is needed and remove it, PR43662.
TU.ExtraArgs.push_back("-fno-ms-compatibility");
auto Index = buildIndexWithSymbol(
diff --git a/clang-tools-extra/clangd/unittests/ExpectedTypeTest.cpp b/clang-tools-extra/clangd/unittests/ExpectedTypeTest.cpp
index f9bfef3..7d62e83 100644
--- a/clang-tools-extra/clangd/unittests/ExpectedTypeTest.cpp
+++ b/clang-tools-extra/clangd/unittests/ExpectedTypeTest.cpp
@@ -66,7 +66,7 @@ protected:
std::map<std::string, EquivClass> Classes;
for (llvm::StringRef Name : DeclNames) {
auto Type = OpaqueType::fromType(ASTCtx(), typeOf(Name));
- Classes[Type->raw()].insert(Name);
+ Classes[std::string(Type->raw())].insert(std::string(Name));
}
return Classes;
}
diff --git a/clang-tools-extra/clangd/unittests/FileIndexTests.cpp b/clang-tools-extra/clangd/unittests/FileIndexTests.cpp
index a65352d..e472dd9 100644
--- a/clang-tools-extra/clangd/unittests/FileIndexTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FileIndexTests.cpp
@@ -149,7 +149,7 @@ void update(FileIndex &M, llvm::StringRef Basename, llvm::StringRef Code) {
TestTU File;
File.Filename = (Basename + ".cpp").str();
File.HeaderFilename = (Basename + ".h").str();
- File.HeaderCode = Code;
+ File.HeaderCode = std::string(Code);
auto AST = File.build();
M.updatePreamble(File.Filename, AST.getASTContext(), AST.getPreprocessorPtr(),
AST.getCanonicalIncludes());
@@ -326,14 +326,14 @@ TEST(FileIndexTest, Refs) {
// Add test.cc
TestTU Test;
Test.HeaderCode = HeaderCode;
- Test.Code = MainCode.code();
+ Test.Code = std::string(MainCode.code());
Test.Filename = "test.cc";
auto AST = Test.build();
Index.updateMain(Test.Filename, AST);
// Add test2.cc
TestTU Test2;
Test2.HeaderCode = HeaderCode;
- Test2.Code = MainCode.code();
+ Test2.Code = std::string(MainCode.code());
Test2.Filename = "test2.cc";
AST = Test2.build();
Index.updateMain(Test2.Filename, AST);
@@ -360,8 +360,8 @@ TEST(FileIndexTest, MacroRefs) {
FileIndex Index;
// Add test.cc
TestTU Test;
- Test.HeaderCode = HeaderCode.code();
- Test.Code = MainCode.code();
+ Test.HeaderCode = std::string(HeaderCode.code());
+ Test.Code = std::string(MainCode.code());
Test.Filename = "test.cc";
auto AST = Test.build();
Index.updateMain(Test.Filename, AST);
@@ -411,7 +411,7 @@ TEST(FileIndexTest, ReferencesInMainFileWithPreamble) {
[[Foo]] foo;
}
)cpp");
- TU.Code = Main.code();
+ TU.Code = std::string(Main.code());
auto AST = TU.build();
FileIndex Index;
Index.updateMain(testPath(TU.Filename), AST);
diff --git a/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp b/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
index f2e67d0..f934345 100644
--- a/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -72,7 +72,7 @@ protected:
void addFile(llvm::StringRef FileName, llvm::StringRef Contents) {
auto Path = testPath(FileName);
- FSProvider.Files[Path] = Contents;
+ FSProvider.Files[Path] = std::string(Contents);
Server.addDocument(Path, Contents);
}
};
@@ -324,7 +324,7 @@ protected:
}
void addFile(llvm::StringRef FilePath, llvm::StringRef Contents) {
- FSProvider.Files[FilePath] = Contents;
+ FSProvider.Files[FilePath] = std::string(Contents);
Server.addDocument(FilePath, Contents);
}
};
diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 3960ef1..22aeed6 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -42,7 +42,7 @@ struct PrintedDecl {
llvm::StringRef FirstLine =
llvm::StringRef(OS.str()).take_until([](char C) { return C == '\n'; });
FirstLine = FirstLine.rtrim(" {");
- Name = FirstLine.rtrim(" {");
+ Name = std::string(FirstLine.rtrim(" {"));
}
std::string Name;
@@ -584,7 +584,7 @@ protected:
/// See actual tests for examples of annotation format.
AllRefs annotateReferencesInFoo(llvm::StringRef Code) {
TestTU TU;
- TU.Code = Code;
+ TU.Code = std::string(Code);
// FIXME: Auto-completion in a template requires disabling delayed template
// parsing.
@@ -644,7 +644,7 @@ protected:
std::string DumpedReferences;
for (unsigned I = 0; I < Refs.size(); ++I)
- DumpedReferences += llvm::formatv("{0}: {1}\n", I, Refs[I]);
+ DumpedReferences += std::string(llvm::formatv("{0}: {1}\n", I, Refs[I]));
return AllRefs{std::move(AnnotatedCode), std::move(DumpedReferences)};
}
diff --git a/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp b/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
index 5e728a5..a6835a0 100644
--- a/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ b/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -55,7 +55,8 @@ TEST(GlobalCompilationDatabaseTest, FallbackCommand) {
}
static tooling::CompileCommand cmd(llvm::StringRef File, llvm::StringRef Arg) {
- return tooling::CompileCommand(testRoot(), File, {"clang", Arg, File}, "");
+ return tooling::CompileCommand(
+ testRoot(), File, {"clang", std::string(Arg), std::string(File)}, "");
}
class OverlayCDBTest : public ::testing::Test {
diff --git a/clang-tools-extra/clangd/unittests/HeadersTests.cpp b/clang-tools-extra/clangd/unittests/HeadersTests.cpp
index d07312c..1d7c828 100644
--- a/clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -85,7 +85,7 @@ protected:
if (Preferred.empty())
Preferred = Original;
auto ToHeaderFile = [](llvm::StringRef Header) {
- return HeaderFile{Header,
+ return HeaderFile{std::string(Header),
/*Verbatim=*/!llvm::sys::path::is_absolute(Header)};
};
diff --git a/clang-tools-extra/clangd/unittests/IndexActionTests.cpp b/clang-tools-extra/clangd/unittests/IndexActionTests.cpp
index 4ca86e8..235b60a 100644
--- a/clang-tools-extra/clangd/unittests/IndexActionTests.cpp
+++ b/clang-tools-extra/clangd/unittests/IndexActionTests.cpp
@@ -85,7 +85,7 @@ public:
"-xc++", "-std=c++11",
"-iquote", testRoot()};
Args.insert(Args.end(), ExtraArgs.begin(), ExtraArgs.end());
- Args.push_back(MainFilePath);
+ Args.push_back(std::string(MainFilePath));
tooling::ToolInvocation Invocation(
Args, std::move(Action), Files.get(),
@@ -100,7 +100,7 @@ public:
void addFile(llvm::StringRef Path, llvm::StringRef Content) {
InMemoryFileSystem->addFile(Path, 0,
llvm::MemoryBuffer::getMemBuffer(Content));
- FilePaths.push_back(Path);
+ FilePaths.push_back(std::string(Path));
}
protected:
diff --git a/clang-tools-extra/clangd/unittests/IndexTests.cpp b/clang-tools-extra/clangd/unittests/IndexTests.cpp
index dcbfc4c..f04ac8a 100644
--- a/clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ b/clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -364,7 +364,7 @@ TEST(MergeIndexTest, Refs) {
Annotations Test1Code(R"(class $Foo[[Foo]];)");
TestTU Test;
Test.HeaderCode = HeaderCode;
- Test.Code = Test1Code.code();
+ Test.Code = std::string(Test1Code.code());
Test.Filename = "test.cc";
auto AST = Test.build();
Dyn.updateMain(Test.Filename, AST);
@@ -381,7 +381,7 @@ TEST(MergeIndexTest, Refs) {
Annotations Test2Code(R"(class $Foo[[Foo]] {};)");
TestTU Test2;
Test2.HeaderCode = HeaderCode;
- Test2.Code = Test2Code.code();
+ Test2.Code = std::string(Test2Code.code());
Test2.Filename = "test2.cc";
StaticAST = Test2.build();
StaticIndex.updateMain(Test2.Filename, StaticAST);
diff --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp b/clang-tools-extra/clangd/unittests/RenameTests.cpp
index 620cdd0..95b9601 100644
--- a/clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -49,7 +49,7 @@ std::unique_ptr<RefSlab> buildRefSlab(const Annotations &Code,
llvm::StringRef Path) {
RefSlab::Builder Builder;
TestTU TU;
- TU.HeaderCode = Code.code();
+ TU.HeaderCode = std::string(Code.code());
auto Symbols = TU.headerSymbols();
const auto &SymbolID = findSymbol(Symbols, SymbolName).ID;
std::string PathURI = URI::create(Path).toString();
@@ -666,7 +666,7 @@ TEST(CrossFileRenameTests, DirtyBuffer) {
MainCode = Annotations("void [[Bar]]() { [[B^ar]](); }");
TU = TestTU::withCode(MainCode.code());
// Set a file "bar.cc" on disk.
- TU.AdditionalFiles["bar.cc"] = BarCode.code();
+ TU.AdditionalFiles["bar.cc"] = std::string(BarCode.code());
AST = TU.build();
Results = rename({MainCode.point(), NewName, AST, MainFilePath, Index.get(),
/*CrossFile=*/true, GetDirtyBuffer});
@@ -713,7 +713,7 @@ TEST(CrossFileRenameTests, DeduplicateRefsFromIndex) {
auto BarPath = testPath("bar.cc");
auto TU = TestTU::withCode(MainCode.code());
// Set a file "bar.cc" on disk.
- TU.AdditionalFiles["bar.cc"] = BarCode.code();
+ TU.AdditionalFiles["bar.cc"] = std::string(BarCode.code());
auto AST = TU.build();
std::string BarPathURI = URI::create(BarPath).toString();
Ref XRefInBarCC = refWithRange(BarCode.range(), BarPathURI);
@@ -895,8 +895,8 @@ TEST(CrossFileRenameTests, WithUpToDateIndex) {
std::string FooCCPath = testPath("foo.cc");
MockFSProvider FS;
- FS.Files[FooHPath] = FooH.code();
- FS.Files[FooCCPath] = FooCC.code();
+ FS.Files[FooHPath] = std::string(FooH.code());
+ FS.Files[FooCCPath] = std::string(FooCC.code());
auto ServerOpts = ClangdServer::optsForTest();
ServerOpts.CrossFileRename = true;
diff --git a/clang-tools-extra/clangd/unittests/SelectionTests.cpp b/clang-tools-extra/clangd/unittests/SelectionTests.cpp
index e8c2bd6..c74ce44 100644
--- a/clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -374,7 +374,7 @@ TEST(SelectionTest, CommonAncestor) {
Annotations Test(C.Code);
TestTU TU;
- TU.Code = Test.code();
+ TU.Code = std::string(Test.code());
// FIXME: Auto-completion in a template requires disabling delayed template
// parsing.
diff --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
index a74f75f..1bedc2f 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -90,8 +90,9 @@ std::string annotate(llvm::StringRef Input,
assert(NextChar <= StartOffset);
Result += Input.substr(NextChar, StartOffset - NextChar);
- Result += llvm::formatv("${0}[[{1}]]", T.Kind,
- Input.substr(StartOffset, EndOffset - StartOffset));
+ Result += std::string(
+ llvm::formatv("${0}[[{1}]]", T.Kind,
+ Input.substr(StartOffset, EndOffset - StartOffset)));
NextChar = EndOffset;
}
Result += Input.substr(NextChar);
@@ -104,7 +105,7 @@ void checkHighlightings(llvm::StringRef Code,
AdditionalFiles = {}) {
Annotations Test(Code);
TestTU TU;
- TU.Code = Test.code();
+ TU.Code = std::string(Test.code());
// FIXME: Auto-completion in a template requires disabling delayed template
// parsing.
diff --git a/clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp b/clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
index 8f580f8..3356a09 100644
--- a/clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
@@ -159,7 +159,7 @@ TEST(SemanticSelection, RunViaClangDServer) {
}]]]]
)cpp";
Annotations SourceAnnotations(SourceContents);
- FS.Files[FooCpp] = SourceAnnotations.code();
+ FS.Files[FooCpp] = std::string(SourceAnnotations.code());
Server.addDocument(FooCpp, SourceAnnotations.code());
auto Ranges = runSemanticRanges(Server, FooCpp, SourceAnnotations.point());
diff --git a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
index b5876b15..b3757d9 100644
--- a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -115,8 +115,8 @@ public:
void build(llvm::StringRef HeaderCode, llvm::StringRef Code = "") {
File.HeaderFilename = HeaderName;
File.Filename = FileName;
- File.HeaderCode = HeaderCode;
- File.Code = Code;
+ File.HeaderCode = std::string(HeaderCode);
+ File.Code = std::string(Code);
AST = File.build();
}
diff --git a/clang-tools-extra/clangd/unittests/SyncAPI.cpp b/clang-tools-extra/clangd/unittests/SyncAPI.cpp
index 130a76b..5e97927 100644
--- a/clang-tools-extra/clangd/unittests/SyncAPI.cpp
+++ b/clang-tools-extra/clangd/unittests/SyncAPI.cpp
@@ -125,7 +125,7 @@ runDocumentSymbols(ClangdServer &Server, PathRef File) {
SymbolSlab runFuzzyFind(const SymbolIndex &Index, llvm::StringRef Query) {
FuzzyFindRequest Req;
- Req.Query = Query;
+ Req.Query = std::string(Query);
Req.AnyScope = true;
return runFuzzyFind(Index, Req);
}
diff --git a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
index 5b8085e..1e1cef0 100644
--- a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -57,7 +57,7 @@ protected:
llvm::StringRef Contents, WantDiagnostics WD,
llvm::unique_function<void()> CB) {
WithContextValue Ctx(llvm::make_scope_exit(std::move(CB)));
- S.update(File, getInputs(File, Contents), WD);
+ S.update(File, getInputs(File, std::string(Contents)), WD);
}
static Key<llvm::unique_function<void(PathRef File, std::vector<Diag>)>>
@@ -112,7 +112,7 @@ protected:
void updateWithDiags(TUScheduler &S, PathRef File, llvm::StringRef Contents,
WantDiagnostics WD,
llvm::unique_function<void(std::vector<Diag>)> CB) {
- return updateWithDiags(S, File, getInputs(File, Contents), WD,
+ return updateWithDiags(S, File, getInputs(File, std::string(Contents)), WD,
std::move(CB));
}
diff --git a/clang-tools-extra/clangd/unittests/TestFS.cpp b/clang-tools-extra/clangd/unittests/TestFS.cpp
index 872b4d0..aad08f2 100644
--- a/clang-tools-extra/clangd/unittests/TestFS.cpp
+++ b/clang-tools-extra/clangd/unittests/TestFS.cpp
@@ -42,7 +42,7 @@ MockCompilationDatabase::MockCompilationDatabase(llvm::StringRef Directory,
llvm::Optional<ProjectInfo>
MockCompilationDatabase::getProjectInfo(PathRef File) const {
- return ProjectInfo{Directory};
+ return ProjectInfo{std::string(Directory)};
}
llvm::Optional<tooling::CompileCommand>
@@ -57,12 +57,12 @@ MockCompilationDatabase::getCompileCommand(PathRef File) const {
CommandLine.insert(CommandLine.begin(), "clang");
if (RelPathPrefix.empty()) {
// Use the absolute path in the compile command.
- CommandLine.push_back(File);
+ CommandLine.push_back(std::string(File));
} else {
// Build a relative path using RelPathPrefix.
llvm::SmallString<32> RelativeFilePath(RelPathPrefix);
llvm::sys::path::append(RelativeFilePath, FileName);
- CommandLine.push_back(RelativeFilePath.str());
+ CommandLine.push_back(std::string(RelativeFilePath.str()));
}
return {tooling::CompileCommand(Directory != llvm::StringRef()
@@ -86,7 +86,7 @@ std::string testPath(PathRef File) {
llvm::sys::path::native(NativeFile);
llvm::SmallString<32> Path;
llvm::sys::path::append(Path, testRoot(), NativeFile);
- return Path.str();
+ return std::string(Path.str());
}
/// unittest: is a scheme that refers to files relative to testRoot().
diff --git a/clang-tools-extra/clangd/unittests/TestTU.h b/clang-tools-extra/clangd/unittests/TestTU.h
index c535645..4668543 100644
--- a/clang-tools-extra/clangd/unittests/TestTU.h
+++ b/clang-tools-extra/clangd/unittests/TestTU.h
@@ -32,13 +32,13 @@ namespace clangd {
struct TestTU {
static TestTU withCode(llvm::StringRef Code) {
TestTU TU;
- TU.Code = Code;
+ TU.Code = std::string(Code);
return TU;
}
static TestTU withHeaderCode(llvm::StringRef HeaderCode) {
TestTU TU;
- TU.HeaderCode = HeaderCode;
+ TU.HeaderCode = std::string(HeaderCode);
return TU;
}
diff --git a/clang-tools-extra/clangd/unittests/TweakTesting.cpp b/clang-tools-extra/clangd/unittests/TweakTesting.cpp
index 7f9f75c..33779f4 100644
--- a/clang-tools-extra/clangd/unittests/TweakTesting.cpp
+++ b/clang-tools-extra/clangd/unittests/TweakTesting.cpp
@@ -70,9 +70,9 @@ MATCHER_P7(TweakIsAvailable, TweakID, Ctx, Header, ExtraArgs, ExtraFiles, Index,
Annotations Input(WrappedCode);
auto Selection = rangeOrPoint(Input);
TestTU TU;
- TU.Filename = FileName;
+ TU.Filename = std::string(FileName);
TU.HeaderCode = Header;
- TU.Code = Input.code();
+ TU.Code = std::string(Input.code());
TU.ExtraArgs = ExtraArgs;
TU.AdditionalFiles = std::move(ExtraFiles);
ParsedAST AST = TU.build();
@@ -93,10 +93,10 @@ std::string TweakTest::apply(llvm::StringRef MarkedCode,
auto Selection = rangeOrPoint(Input);
TestTU TU;
- TU.Filename = FileName;
+ TU.Filename = std::string(FileName);
TU.HeaderCode = Header;
TU.AdditionalFiles = std::move(ExtraFiles);
- TU.Code = Input.code();
+ TU.Code = std::string(Input.code());
TU.ExtraArgs = ExtraArgs;
ParsedAST AST = TU.build();
Tweak::Selection S(Index.get(), AST, Selection.first, Selection.second);
@@ -121,7 +121,7 @@ std::string TweakTest::apply(llvm::StringRef MarkedCode,
return "bad edits: " + llvm::toString(NewText.takeError());
llvm::StringRef Unwrapped = unwrap(Context, *NewText);
if (It.first() == testPath(TU.Filename))
- EditedMainFile = Unwrapped;
+ EditedMainFile = std::string(Unwrapped);
else {
if (!EditedFiles)
ADD_FAILURE() << "There were changes to additional files, but client "
diff --git a/clang-tools-extra/clangd/unittests/TweakTests.cpp b/clang-tools-extra/clangd/unittests/TweakTests.cpp
index 2a99521..68f87a7 100644
--- a/clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ b/clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -2214,7 +2214,7 @@ TEST_F(DefineOutlineTest, QualifyFunctionName) {
};
llvm::StringMap<std::string> EditedFiles;
for (auto &Case : Cases) {
- ExtraFiles["Test.cpp"] = Case.TestSource;
+ ExtraFiles["Test.cpp"] = std::string(Case.TestSource);
EXPECT_EQ(apply(Case.TestHeader, &EditedFiles), Case.ExpectedHeader);
EXPECT_THAT(EditedFiles, testing::ElementsAre(FileWithContents(
testPath("Test.cpp"), Case.ExpectedSource)))
diff --git a/clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp b/clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
index 6bbcfff..73e124d 100644
--- a/clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
+++ b/clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
@@ -527,7 +527,7 @@ SymbolID findSymbolIDByName(SymbolIndex *Index, llvm::StringRef Name,
llvm::StringRef TemplateArgs = "") {
SymbolID Result;
FuzzyFindRequest Request;
- Request.Query = Name;
+ Request.Query = std::string(Name);
Request.AnyScope = true;
bool GotResult = false;
Index->fuzzyFind(Request, [&](const Symbol &S) {
diff --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
index 617c5bc..1579765 100644
--- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -149,8 +149,8 @@ TEST(LocateSymbol, WithIndex) {
)cpp");
TestTU TU;
- TU.Code = SymbolCpp.code();
- TU.HeaderCode = SymbolHeader.code();
+ TU.Code = std::string(SymbolCpp.code());
+ TU.HeaderCode = std::string(SymbolHeader.code());
auto Index = TU.index();
auto LocateWithIndex = [&Index](const Annotations &Main) {
auto AST = TestTU::withCode(Main.code()).build();
@@ -197,7 +197,7 @@ TEST(LocateSymbol, WithIndexPreferredLocation) {
void $f[[func]]() {};
)cpp");
TestTU TU;
- TU.HeaderCode = SymbolHeader.code();
+ TU.HeaderCode = std::string(SymbolHeader.code());
TU.HeaderFilename = "x.proto"; // Prefer locations in codegen files.
auto Index = TU.index();
@@ -503,7 +503,7 @@ TEST(LocateSymbol, All) {
WantDef = T.range("def");
TestTU TU;
- TU.Code = T.code();
+ TU.Code = std::string(T.code());
// FIXME: Auto-completion in a template requires disabling delayed template
// parsing.
@@ -558,7 +558,7 @@ TEST(LocateSymbol, Warnings) {
WantDef = T.range("def");
TestTU TU;
- TU.Code = T.code();
+ TU.Code = std::string(T.code());
auto AST = TU.build();
auto Results = locateSymbolAt(AST, T.point());
@@ -694,9 +694,10 @@ int [[bar_not_preamble]];
auto FooCpp = testPath("src/foo.cpp");
FS.Files[FooCpp] = "";
auto HeaderInPreambleH = testPath("src/header_in_preamble.h");
- FS.Files[HeaderInPreambleH] = HeaderInPreambleAnnotations.code();
+ FS.Files[HeaderInPreambleH] = std::string(HeaderInPreambleAnnotations.code());
auto HeaderNotInPreambleH = testPath("src/header_not_in_preamble.h");
- FS.Files[HeaderNotInPreambleH] = HeaderNotInPreambleAnnotations.code();
+ FS.Files[HeaderNotInPreambleH] =
+ std::string(HeaderNotInPreambleAnnotations.code());
runAddDocument(Server, FooCpp, SourceAnnotations.code());
@@ -736,14 +737,14 @@ TEST(GoToInclude, All) {
#in$5^clude "$6^foo.h"$7^
)cpp";
Annotations SourceAnnotations(SourceContents);
- FS.Files[FooCpp] = SourceAnnotations.code();
+ FS.Files[FooCpp] = std::string(SourceAnnotations.code());
auto FooH = testPath("foo.h");
const char *HeaderContents = R"cpp([[]]#pragma once
int a;
)cpp";
Annotations HeaderAnnotations(HeaderContents);
- FS.Files[FooH] = HeaderAnnotations.code();
+ FS.Files[FooH] = std::string(HeaderAnnotations.code());
Server.addDocument(FooH, HeaderAnnotations.code());
Server.addDocument(FooCpp, SourceAnnotations.code());
@@ -785,7 +786,7 @@ TEST(GoToInclude, All) {
#import "^foo.h"
)objc");
auto FooM = testPath("foo.m");
- FS.Files[FooM] = ObjC.code();
+ FS.Files[FooM] = std::string(ObjC.code());
Server.addDocument(FooM, ObjC.code());
Locations = runLocateSymbolAt(Server, FooM, ObjC.point());
@@ -805,11 +806,11 @@ TEST(LocateSymbol, WithPreamble) {
Annotations FooWithHeader(R"cpp(#include "fo^o.h")cpp");
Annotations FooWithoutHeader(R"cpp(double [[fo^o]]();)cpp");
- FS.Files[FooCpp] = FooWithHeader.code();
+ FS.Files[FooCpp] = std::string(FooWithHeader.code());
auto FooH = testPath("foo.h");
Annotations FooHeader(R"cpp([[]])cpp");
- FS.Files[FooH] = FooHeader.code();
+ FS.Files[FooH] = std::string(FooHeader.code());
runAddDocument(Server, FooCpp, FooWithHeader.code());
// LocateSymbol goes to a #include file: the result comes from the preamble.
@@ -1010,7 +1011,7 @@ TEST(FindReferences, NeedsIndexForSymbols) {
const char *Header = "int foo();";
Annotations Main("int main() { [[f^oo]](); }");
TestTU TU;
- TU.Code = Main.code();
+ TU.Code = std::string(Main.code());
TU.HeaderCode = Header;
auto AST = TU.build();
@@ -1024,7 +1025,7 @@ TEST(FindReferences, NeedsIndexForSymbols) {
// References from indexed files are included.
TestTU IndexedTU;
- IndexedTU.Code = IndexedMain.code();
+ IndexedTU.Code = std::string(IndexedMain.code());
IndexedTU.Filename = "Indexed.cpp";
IndexedTU.HeaderCode = Header;
EXPECT_THAT(
@@ -1049,7 +1050,7 @@ TEST(FindReferences, NeedsIndexForMacro) {
}
)cpp");
TestTU TU;
- TU.Code = Main.code();
+ TU.Code = std::string(Main.code());
TU.HeaderCode = Header;
auto AST = TU.build();
@@ -1066,7 +1067,7 @@ TEST(FindReferences, NeedsIndexForMacro) {
// References from indexed files are included.
TestTU IndexedTU;
- IndexedTU.Code = IndexedMain.code();
+ IndexedTU.Code = std::string(IndexedMain.code());
IndexedTU.Filename = "Indexed.cpp";
IndexedTU.HeaderCode = Header;
EXPECT_THAT(
@@ -1198,7 +1199,7 @@ TEST(DocumentLinks, All) {
)cpp");
TestTU TU;
- TU.Code = MainCpp.code();
+ TU.Code = std::string(MainCpp.code());
TU.AdditionalFiles = {{"foo.h", ""}, {"bar.h", ""}};
auto AST = TU.build();
diff --git a/clang-tools-extra/modularize/CoverageChecker.cpp b/clang-tools-extra/modularize/CoverageChecker.cpp
index 6cfeb0e..9df53d2 100644
--- a/clang-tools-extra/modularize/CoverageChecker.cpp
+++ b/clang-tools-extra/modularize/CoverageChecker.cpp
@@ -282,7 +282,7 @@ CoverageChecker::collectUmbrellaHeaderHeaders(StringRef UmbrellaHeaderName) {
Compilations.reset(new FixedCompilationDatabase(Twine(PathBuf), CommandLine));
std::vector<std::string> HeaderPath;
- HeaderPath.push_back(UmbrellaHeaderName);
+ HeaderPath.push_back(std::string(UmbrellaHeaderName));
// Create the tool and run the compilation.
ClangTool Tool(*Compilations, HeaderPath);
diff --git a/clang-tools-extra/modularize/Modularize.cpp b/clang-tools-extra/modularize/Modularize.cpp
index 749afdf..5076bd9 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -813,7 +813,7 @@ int main(int Argc, const char **Argv) {
Argv0 = Argv[0];
// Save program arguments for use in module.modulemap comment.
- CommandLine = sys::path::stem(sys::path::filename(Argv0));
+ CommandLine = std::string(sys::path::stem(sys::path::filename(Argv0)));
for (int ArgIndex = 1; ArgIndex < Argc; ArgIndex++) {
CommandLine.append(" ");
CommandLine.append(Argv[ArgIndex]);
@@ -948,7 +948,7 @@ int main(int Argc, const char **Argv) {
for (LocationArray::iterator FE = DI->end(); FI != FE; ++FI) {
errs() << " " << FI->File->getName() << ":" << FI->Line << ":"
<< FI->Column << "\n";
- ModUtil->addUniqueProblemFile(FI->File->getName());
+ ModUtil->addUniqueProblemFile(std::string(FI->File->getName()));
}
HadErrors = 1;
}
@@ -978,7 +978,7 @@ int main(int Argc, const char **Argv) {
}
HadErrors = 1;
- ModUtil->addUniqueProblemFile(H->first->getName());
+ ModUtil->addUniqueProblemFile(std::string(H->first->getName()));
errs() << "error: header '" << H->first->getName()
<< "' has different contents depending on how it was included.\n";
for (unsigned I = 0, N = H->second.size(); I != N; ++I) {
diff --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp b/clang-tools-extra/modularize/ModularizeUtilities.cpp
index f11273d..200370c 100644
--- a/clang-tools-extra/modularize/ModularizeUtilities.cpp
+++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp
@@ -196,7 +196,7 @@ std::error_code ModularizeUtilities::loadSingleHeaderListsAndDependencies(
// Get canonical form.
HeaderFileName = getCanonicalPath(HeaderFileName);
// Save the resulting header file path and dependencies.
- HeaderFileNames.push_back(HeaderFileName.str());
+ HeaderFileNames.push_back(std::string(HeaderFileName.str()));
Dependencies[HeaderFileName.str()] = Dependents;
}
return std::error_code();
@@ -249,7 +249,7 @@ std::error_code ModularizeUtilities::loadProblemHeaderList(
// Get canonical form.
HeaderFileName = getCanonicalPath(HeaderFileName);
// Save the resulting header file path.
- ProblemFileNames.push_back(HeaderFileName.str());
+ ProblemFileNames.push_back(std::string(HeaderFileName.str()));
}
return std::error_code();
}
@@ -457,7 +457,7 @@ std::string ModularizeUtilities::getCanonicalPath(StringRef FilePath) {
std::replace(Tmp.begin(), Tmp.end(), '\\', '/');
StringRef Tmp2(Tmp);
if (Tmp2.startswith("./"))
- Tmp = Tmp2.substr(2);
+ Tmp = std::string(Tmp2.substr(2));
return Tmp;
}
@@ -487,7 +487,7 @@ std::string ModularizeUtilities::getDirectoryFromPath(StringRef Path) {
sys::path::remove_filename(Directory);
if (Directory.size() == 0)
return ".";
- return Directory.str();
+ return std::string(Directory.str());
}
// Add unique problem file.
diff --git a/clang-tools-extra/modularize/ModuleAssistant.cpp b/clang-tools-extra/modularize/ModuleAssistant.cpp
index 0cd7e9f0..1dba973 100644
--- a/clang-tools-extra/modularize/ModuleAssistant.cpp
+++ b/clang-tools-extra/modularize/ModuleAssistant.cpp
@@ -139,7 +139,7 @@ static const char *const ReservedNames[] = {
// Prepends a '_' to the name if and only if the name is a keyword.
static std::string
ensureNoCollisionWithReservedName(llvm::StringRef MightBeReservedName) {
- std::string SafeName = MightBeReservedName;
+ std::string SafeName(MightBeReservedName);
for (int Index = 0; ReservedNames[Index] != nullptr; ++Index) {
if (MightBeReservedName == ReservedNames[Index]) {
SafeName.insert(0, "_");
@@ -153,7 +153,7 @@ ensureNoCollisionWithReservedName(llvm::StringRef MightBeReservedName) {
// Prepends a '_' to the name if and only if the name is a keyword.
static std::string
ensureVaidModuleName(llvm::StringRef MightBeInvalidName) {
- std::string SafeName = MightBeInvalidName;
+ std::string SafeName(MightBeInvalidName);
std::replace(SafeName.begin(), SafeName.end(), '-', '_');
std::replace(SafeName.begin(), SafeName.end(), '.', '_');
if (isdigit(SafeName[0]))
@@ -176,9 +176,9 @@ static bool addModuleDescription(Module *RootModule,
llvm::sys::path::native(HeaderFilePath, NativePath);
llvm::sys::path::native(HeaderPrefix, NativePrefix);
if (NativePath.startswith(NativePrefix))
- FilePath = NativePath.substr(NativePrefix.size() + 1);
+ FilePath = std::string(NativePath.substr(NativePrefix.size() + 1));
else
- FilePath = HeaderFilePath;
+ FilePath = std::string(HeaderFilePath);
int Count = FileDependents.size();
// Headers that go into modules must not depend on other files being
// included first. If there are any dependents, warn user and omit.
@@ -197,7 +197,7 @@ static bool addModuleDescription(Module *RootModule,
I != E; ++I) {
if ((*I)[0] == '.')
continue;
- std::string Stem = llvm::sys::path::stem(*I);
+ std::string Stem(llvm::sys::path::stem(*I));
Stem = ensureNoCollisionWithReservedName(Stem);
Stem = ensureVaidModuleName(Stem);
Module *SubModule = CurrentModule->findSubModule(Stem);
diff --git a/clang-tools-extra/unittests/clang-include-fixer/IncludeFixerTest.cpp b/clang-tools-extra/unittests/clang-include-fixer/IncludeFixerTest.cpp
index b210171..c89b18f 100644
--- a/clang-tools-extra/unittests/clang-include-fixer/IncludeFixerTest.cpp
+++ b/clang-tools-extra/unittests/clang-include-fixer/IncludeFixerTest.cpp
@@ -29,7 +29,8 @@ static bool runOnCode(tooling::ToolAction *ToolAction, StringRef Code,
new FileManager(FileSystemOptions(), InMemoryFileSystem));
// FIXME: Investigate why -fms-compatibility breaks tests.
std::vector<std::string> Args = {"include_fixer", "-fsyntax-only",
- "-fno-ms-compatibility", FileName};
+ "-fno-ms-compatibility",
+ std::string(FileName)};
Args.insert(Args.end(), ExtraArgs.begin(), ExtraArgs.end());
tooling::ToolInvocation Invocation(
Args, ToolAction, Files.get(),
@@ -102,7 +103,7 @@ static std::string runIncludeFixer(
runOnCode(&Factory, Code, FakeFileName, ExtraArgs);
assert(FixerContexts.size() == 1);
if (FixerContexts.front().getHeaderInfos().empty())
- return Code;
+ return std::string(Code);
auto Replaces = createIncludeFixerReplacements(Code, FixerContexts.front());
EXPECT_TRUE(static_cast<bool>(Replaces))
<< llvm::toString(Replaces.takeError()) << "\n";
diff --git a/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h b/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
index 5e62a19..eb138b2 100644
--- a/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
+++ b/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
@@ -98,7 +98,8 @@ runCheckOnCode(StringRef Code, std::vector<ClangTidyError> *Errors = nullptr,
std::vector<std::string> Args(1, "clang-tidy");
Args.push_back("-fsyntax-only");
Args.push_back("-fno-delayed-template-parsing");
- std::string extension(llvm::sys::path::extension(Filename.str()));
+ std::string extension(
+ std::string(llvm::sys::path::extension(Filename.str())));
if (extension == ".m" || extension == ".mm") {
Args.push_back("-fobjc-abi-version=2");
Args.push_back("-fobjc-arc");
diff --git a/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp b/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
index 28ea7e2..ebf5f59 100644
--- a/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
@@ -33,9 +33,10 @@ RewriteRule invertIf() {
RewriteRule Rule = tooling::makeRule(
ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
hasElse(stmt().bind(E))),
- change(
- statement(RewriteRule::RootID),
- cat("if(!(", node(C), ")) ", statement(E), " else ", statement(T))),
+ change(statement(std::string(RewriteRule::RootID)),
+ cat("if(!(", node(std::string(C)), ")) ",
+ statement(std::string(E)), " else ",
+ statement(std::string(T)))),
cat("negate condition and reverse `then` and `else` branches"));
return Rule;
}
diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h
index b98aef6..73dc4dd 100644
--- a/clang/include/clang/AST/DeclObjC.h
+++ b/clang/include/clang/AST/DeclObjC.h
@@ -2692,9 +2692,7 @@ public:
/// Get the name of the class associated with this interface.
//
// FIXME: Move to StringRef API.
- std::string getNameAsString() const {
- return getName();
- }
+ std::string getNameAsString() const { return std::string(getName()); }
/// Produce a name to be used for class's metadata. It comes either via
/// class's objc_runtime_name attribute or class name.
diff --git a/clang/include/clang/AST/JSONNodeDumper.h b/clang/include/clang/AST/JSONNodeDumper.h
index 4023e02..ae7b4c9 100644
--- a/clang/include/clang/AST/JSONNodeDumper.h
+++ b/clang/include/clang/AST/JSONNodeDumper.h
@@ -64,7 +64,7 @@ public:
// We need to capture an owning-string in the lambda because the lambda
// is invoked in a deferred manner.
- std::string LabelStr = !Label.empty() ? Label : "inner";
+ std::string LabelStr(!Label.empty() ? Label : "inner");
bool WasFirstChild = FirstChild;
auto DumpWithIndent = [=](bool IsLastChild) {
if (WasFirstChild) {
diff --git a/clang/include/clang/AST/PrettyPrinter.h b/clang/include/clang/AST/PrettyPrinter.h
index 80eec6a..bbac930 100644
--- a/clang/include/clang/AST/PrettyPrinter.h
+++ b/clang/include/clang/AST/PrettyPrinter.h
@@ -36,7 +36,9 @@ protected:
public:
/// Remap a path to a form suitable for printing.
- virtual std::string remapPath(StringRef Path) const { return Path; }
+ virtual std::string remapPath(StringRef Path) const {
+ return std::string(Path);
+ }
};
/// Describes how types, statements, expressions, and declarations should be
diff --git a/clang/include/clang/AST/TextNodeDumper.h b/clang/include/clang/AST/TextNodeDumper.h
index d293ea1..5dc5022 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -68,7 +68,7 @@ public:
// We need to capture an owning-string in the lambda because the lambda
// is invoked in a deferred manner.
- std::string LabelStr = Label;
+ std::string LabelStr(Label);
auto DumpWithIndent = [this, DoAddChild, LabelStr](bool IsLastChild) {
// Print out the appropriate tree structure and work out the prefix for
// children of this node. For instance:
diff --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index c4b449f..55c8630 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -149,7 +149,7 @@ public:
///
/// The node's base type should be in NodeBaseType or it will be unaccessible.
void addNode(StringRef ID, const ast_type_traits::DynTypedNode& DynNode) {
- NodeMap[ID] = DynNode;
+ NodeMap[std::string(ID)] = DynNode;
}
/// Returns the AST node bound to \c ID.
diff --git a/clang/include/clang/Analysis/PathDiagnostic.h b/clang/include/clang/Analysis/PathDiagnostic.h
index 6730057..c4b042a 100644
--- a/clang/include/clang/Analysis/PathDiagnostic.h
+++ b/clang/include/clang/Analysis/PathDiagnostic.h
@@ -561,7 +561,7 @@ public:
void setCallee(const CallEnter &CE, const SourceManager &SM);
bool hasCallStackMessage() { return !CallStackMessage.empty(); }
- void setCallStackMessage(StringRef st) { CallStackMessage = st; }
+ void setCallStackMessage(StringRef st) { CallStackMessage = std::string(st); }
PathDiagnosticLocation getLocation() const override { return callEnter; }
@@ -806,7 +806,7 @@ public:
meta_iterator meta_begin() const { return OtherDesc.begin(); }
meta_iterator meta_end() const { return OtherDesc.end(); }
- void addMeta(StringRef s) { OtherDesc.push_back(s); }
+ void addMeta(StringRef s) { OtherDesc.push_back(std::string(s)); }
const FilesToLineNumsMap &getExecutedLines() const {
return *ExecutedLines;
diff --git a/clang/include/clang/Basic/Diagnostic.h b/clang/include/clang/Basic/Diagnostic.h
index ce996b6..377c3d5 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -95,7 +95,7 @@ public:
FixItHint Hint;
Hint.RemoveRange =
CharSourceRange::getCharRange(InsertionLoc, InsertionLoc);
- Hint.CodeToInsert = Code;
+ Hint.CodeToInsert = std::string(Code);
Hint.BeforePreviousInsertions = BeforePreviousInsertions;
return Hint;
}
@@ -130,7 +130,7 @@ public:
StringRef Code) {
FixItHint Hint;
Hint.RemoveRange = RemoveRange;
- Hint.CodeToInsert = Code;
+ Hint.CodeToInsert = std::string(Code);
return Hint;
}
@@ -1155,7 +1155,7 @@ public:
assert(NumArgs < DiagnosticsEngine::MaxArguments &&
"Too many arguments to diagnostic!");
DiagObj->DiagArgumentsKind[NumArgs] = DiagnosticsEngine::ak_std_string;
- DiagObj->DiagArgumentsStr[NumArgs++] = S;
+ DiagObj->DiagArgumentsStr[NumArgs++] = std::string(S);
}
void AddTaggedVal(intptr_t V, DiagnosticsEngine::ArgumentKind Kind) const {
@@ -1177,7 +1177,7 @@ public:
DiagObj->DiagFixItHints.push_back(Hint);
}
- void addFlagValue(StringRef V) const { DiagObj->FlagValue = V; }
+ void addFlagValue(StringRef V) const { DiagObj->FlagValue = std::string(V); }
};
struct AddFlagValue {
diff --git a/clang/include/clang/Basic/FixedPoint.h b/clang/include/clang/Basic/FixedPoint.h
index a931e21..fd8bae6 100644
--- a/clang/include/clang/Basic/FixedPoint.h
+++ b/clang/include/clang/Basic/FixedPoint.h
@@ -165,7 +165,7 @@ class APFixedPoint {
std::string toString() const {
llvm::SmallString<40> S;
toString(S);
- return S.str();
+ return std::string(S.str());
}
// If LHS > RHS, return 1. If LHS == RHS, return 0. If LHS < RHS, return -1.
diff --git a/clang/include/clang/Basic/Module.h b/clang/include/clang/Basic/Module.h
index 0f2549f0..953d183 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -506,7 +506,7 @@ public:
/// Add a top-level header filename associated with this module.
void addTopHeaderFilename(StringRef Filename) {
- TopHeaderNames.push_back(Filename);
+ TopHeaderNames.push_back(std::string(Filename));
}
/// The top-level headers associated with this module.
diff --git a/clang/include/clang/Basic/PartialDiagnostic.h b/clang/include/clang/Basic/PartialDiagnostic.h
index 799951b..c413cc2 100644
--- a/clang/include/clang/Basic/PartialDiagnostic.h
+++ b/clang/include/clang/Basic/PartialDiagnostic.h
@@ -285,7 +285,7 @@ public:
"Too many arguments to diagnostic!");
DiagStorage->DiagArgumentsKind[DiagStorage->NumDiagArgs]
= DiagnosticsEngine::ak_std_string;
- DiagStorage->DiagArgumentsStr[DiagStorage->NumDiagArgs++] = V;
+ DiagStorage->DiagArgumentsStr[DiagStorage->NumDiagArgs++] = std::string(V);
}
void Emit(const DiagnosticBuilder &DB) const {
diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h
index 6c3feab..90a0c871 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -340,9 +340,7 @@ public:
return InstalledDir.c_str();
return Dir.c_str();
}
- void setInstalledDir(StringRef Value) {
- InstalledDir = Value;
- }
+ void setInstalledDir(StringRef Value) { InstalledDir = std::string(Value); }
bool isSaveTempsEnabled() const { return SaveTemps != SaveTempsNone; }
bool isSaveTempsObj() const { return SaveTemps == SaveTempsObj; }
diff --git a/clang/include/clang/Driver/Multilib.h b/clang/include/clang/Driver/Multilib.h
index abf0d5f..cf2dbf6 100644
--- a/clang/include/clang/Driver/Multilib.h
+++ b/clang/include/clang/Driver/Multilib.h
@@ -91,7 +91,7 @@ public:
/// otherwise '-print-multi-lib' will not emit them correctly.
Multilib &flag(StringRef F) {
assert(F.front() == '+' || F.front() == '-');
- Flags.push_back(F);
+ Flags.push_back(std::string(F));
return *this;
}
diff --git a/clang/include/clang/Frontend/CommandLineSourceLoc.h b/clang/include/clang/Frontend/CommandLineSourceLoc.h
index e95d100..0827433 100644
--- a/clang/include/clang/Frontend/CommandLineSourceLoc.h
+++ b/clang/include/clang/Frontend/CommandLineSourceLoc.h
@@ -38,7 +38,7 @@ public:
// If both tail splits were valid integers, return success.
if (!ColSplit.second.getAsInteger(10, PSL.Column) &&
!LineSplit.second.getAsInteger(10, PSL.Line)) {
- PSL.FileName = LineSplit.first;
+ PSL.FileName = std::string(LineSplit.first);
// On the command-line, stdin may be specified via "-". Inside the
// compiler, stdin is called "<stdin>".
diff --git a/clang/include/clang/Frontend/LogDiagnosticPrinter.h b/clang/include/clang/Frontend/LogDiagnosticPrinter.h
index 4816275..ec22a8b 100644
--- a/clang/include/clang/Frontend/LogDiagnosticPrinter.h
+++ b/clang/include/clang/Frontend/LogDiagnosticPrinter.h
@@ -66,7 +66,7 @@ public:
std::unique_ptr<raw_ostream> StreamOwner);
void setDwarfDebugFlags(StringRef Value) {
- DwarfDebugFlags = Value;
+ DwarfDebugFlags = std::string(Value);
}
void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) override {
diff --git a/clang/include/clang/Lex/HeaderSearch.h b/clang/include/clang/Lex/HeaderSearch.h
index 0d20daf..b311337 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -302,7 +302,7 @@ public:
void AddIncludeAlias(StringRef Source, StringRef Dest) {
if (!IncludeAliases)
IncludeAliases.reset(new IncludeAliasMap);
- (*IncludeAliases)[Source] = Dest;
+ (*IncludeAliases)[Source] = std::string(Dest);
}
/// Maps one header file name to a different header
@@ -321,7 +321,7 @@ public:
/// Set the path to the module cache.
void setModuleCachePath(StringRef CachePath) {
- ModuleCachePath = CachePath;
+ ModuleCachePath = std::string(CachePath);
}
/// Retrieve the path to the module cache.
diff --git a/clang/include/clang/Lex/HeaderSearchOptions.h b/clang/include/clang/Lex/HeaderSearchOptions.h
index 5c19a41..30a9d75 100644
--- a/clang/include/clang/Lex/HeaderSearchOptions.h
+++ b/clang/include/clang/Lex/HeaderSearchOptions.h
@@ -239,11 +239,11 @@ public:
}
void AddVFSOverlayFile(StringRef Name) {
- VFSOverlayFiles.push_back(Name);
+ VFSOverlayFiles.push_back(std::string(Name));
}
void AddPrebuiltModulePath(StringRef Name) {
- PrebuiltModulePaths.push_back(Name);
+ PrebuiltModulePaths.push_back(std::string(Name));
}
};
diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h
index 11fe66f..81ed4ab 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -1184,7 +1184,7 @@ public:
///
/// These predefines are automatically injected when parsing the main file.
void setPredefines(const char *P) { Predefines = P; }
- void setPredefines(StringRef P) { Predefines = P; }
+ void setPredefines(StringRef P) { Predefines = std::string(P); }
/// Return information about the specified preprocessor
/// identifier token.
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index bc77989..a6234f7 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -9581,7 +9581,7 @@ public:
std::string getOpenCLExtensionsFromExtMap(T* FT, MapT &Map);
void setCurrentOpenCLExtension(llvm::StringRef Ext) {
- CurrOpenCLExtension = Ext;
+ CurrOpenCLExtension = std::string(Ext);
}
/// Set OpenCL extensions for a type which can only be used when these
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
index bd8760c..286b5b2 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
@@ -284,7 +284,8 @@ public:
/// bug path significantly shorter.
const NoteTag *getNoteTag(StringRef Note, bool IsPrunable = false) {
return getNoteTag(
- [Note](BugReporterContext &, BugReport &) { return Note; }, IsPrunable);
+ [Note](BugReporterContext &, BugReport &) { return std::string(Note); },
+ IsPrunable);
}
/// Returns the word that should be used to refer to the declaration
diff --git a/clang/include/clang/Tooling/AllTUsExecution.h b/clang/include/clang/Tooling/AllTUsExecution.h
index 1e618b5..43f2792 100644
--- a/clang/include/clang/Tooling/AllTUsExecution.h
+++ b/clang/include/clang/Tooling/AllTUsExecution.h
@@ -56,7 +56,7 @@ public:
ToolResults *getToolResults() override { return Results.get(); }
void mapVirtualFile(StringRef FilePath, StringRef Content) override {
- OverlayFiles[FilePath] = Content;
+ OverlayFiles[FilePath] = std::string(Content);
}
private:
diff --git a/clang/include/clang/Tooling/Refactoring/AtomicChange.h b/clang/include/clang/Tooling/Refactoring/AtomicChange.h
index 32e4624..7cb9987 100644
--- a/clang/include/clang/Tooling/Refactoring/AtomicChange.h
+++ b/clang/include/clang/Tooling/Refactoring/AtomicChange.h
@@ -70,7 +70,7 @@ public:
/// conflicts among replacements, use this to set an error description.
/// Thereby, places that cannot be fixed automatically can be gathered when
/// applying changes.
- void setError(llvm::StringRef Error) { this->Error = Error; }
+ void setError(llvm::StringRef Error) { this->Error = std::string(Error); }
/// Returns whether an error has been set on this list.
bool hasError() const { return !Error.empty(); }
diff --git a/clang/include/clang/Tooling/Transformer/RewriteRule.h b/clang/include/clang/Tooling/Transformer/RewriteRule.h
index 7daf6ea..4fca3bc 100644
--- a/clang/include/clang/Tooling/Transformer/RewriteRule.h
+++ b/clang/include/clang/Tooling/Transformer/RewriteRule.h
@@ -203,7 +203,8 @@ inline ASTEdit change(RangeSelector Target, TextGenerator Replacement) {
/// changeTo(cat("bar()")))
/// \endcode
inline ASTEdit changeTo(TextGenerator Replacement) {
- return changeTo(node(RewriteRule::RootID), std::move(Replacement));
+ return changeTo(node(std::string(RewriteRule::RootID)),
+ std::move(Replacement));
}
/// DEPRECATED: use \c changeTo.
inline ASTEdit change(TextGenerator Replacement) {
diff --git a/clang/lib/ARCMigrate/ARCMT.cpp b/clang/lib/ARCMigrate/ARCMT.cpp
index a9018c1..54c32c2 100644
--- a/clang/lib/ARCMigrate/ARCMT.cpp
+++ b/clang/lib/ARCMigrate/ARCMT.cpp
@@ -189,7 +189,7 @@ createInvocationForMigration(CompilerInvocation &origCI,
PPOpts.Includes.insert(PPOpts.Includes.begin(), OriginalFile);
PPOpts.ImplicitPCHInclude.clear();
}
- std::string define = getARCMTMacroName();
+ std::string define = std::string(getARCMTMacroName());
define += '=';
CInvok->getPreprocessorOpts().addMacroDef(define);
CInvok->getLangOpts()->ObjCAutoRefCount = true;
@@ -296,7 +296,7 @@ bool arcmt::checkForManualIssues(
for (CapturedDiagList::iterator
I = capturedDiags.begin(), E = capturedDiags.end(); I != E; ++I)
arcDiags.push_back(*I);
- writeARCDiagsToPlist(plistOut, arcDiags,
+ writeARCDiagsToPlist(std::string(plistOut), arcDiags,
Ctx.getSourceManager(), Ctx.getLangOpts());
}
@@ -598,7 +598,7 @@ bool MigrationProcess::applyTransform(TransformFn trans,
RewriteBuffer &buf = I->second;
const FileEntry *file = Ctx.getSourceManager().getFileEntryForID(FID);
assert(file);
- std::string newFname = file->getName();
+ std::string newFname = std::string(file->getName());
newFname += "-trans";
SmallString<512> newText;
llvm::raw_svector_ostream vecOS(newText);
diff --git a/clang/lib/ARCMigrate/FileRemapper.cpp b/clang/lib/ARCMigrate/FileRemapper.cpp
index a031fe2..0222583 100644
--- a/clang/lib/ARCMigrate/FileRemapper.cpp
+++ b/clang/lib/ARCMigrate/FileRemapper.cpp
@@ -43,7 +43,7 @@ std::string FileRemapper::getRemapInfoFile(StringRef outputDir) {
assert(!outputDir.empty());
SmallString<128> InfoFile = outputDir;
llvm::sys::path::append(InfoFile, "remap");
- return InfoFile.str();
+ return std::string(InfoFile.str());
}
bool FileRemapper::initFromDisk(StringRef outputDir, DiagnosticsEngine &Diag,
@@ -56,7 +56,7 @@ bool FileRemapper::initFromFile(StringRef filePath, DiagnosticsEngine &Diag,
bool ignoreIfFilesChanged) {
assert(FromToMappings.empty() &&
"initFromDisk should be called before any remap calls");
- std::string infoFile = filePath;
+ std::string infoFile = std::string(filePath);
if (!llvm::sys::fs::exists(infoFile))
return false;
@@ -120,7 +120,7 @@ bool FileRemapper::flushToFile(StringRef outputPath, DiagnosticsEngine &Diag) {
using namespace llvm::sys;
std::error_code EC;
- std::string infoFile = outputPath;
+ std::string infoFile = std::string(outputPath);
llvm::raw_fd_ostream infoOut(infoFile, EC, llvm::sys::fs::OF_None);
if (EC)
return report(EC.message(), Diag);
diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp
index 4c6e9f2..6ef0786 100644
--- a/clang/lib/ARCMigrate/ObjCMT.cpp
+++ b/clang/lib/ARCMigrate/ObjCMT.cpp
@@ -114,21 +114,15 @@ public:
return *Summaries;
}
- ObjCMigrateASTConsumer(StringRef migrateDir,
- unsigned astMigrateActions,
- FileRemapper &remapper,
- FileManager &fileMgr,
+ ObjCMigrateASTConsumer(StringRef migrateDir, unsigned astMigrateActions,
+ FileRemapper &remapper, FileManager &fileMgr,
const PPConditionalDirectiveRecord *PPRec,
- Preprocessor &PP,
- bool isOutputFile,
+ Preprocessor &PP, bool isOutputFile,
ArrayRef<std::string> WhiteList)
- : MigrateDir(migrateDir),
- ASTMigrateActions(astMigrateActions),
- NSIntegerTypedefed(nullptr), NSUIntegerTypedefed(nullptr),
- Remapper(remapper), FileMgr(fileMgr), PPRec(PPRec), PP(PP),
- IsOutputFile(isOutputFile),
- FoundationIncluded(false){
-
+ : MigrateDir(migrateDir), ASTMigrateActions(astMigrateActions),
+ NSIntegerTypedefed(nullptr), NSUIntegerTypedefed(nullptr),
+ Remapper(remapper), FileMgr(fileMgr), PPRec(PPRec), PP(PP),
+ IsOutputFile(isOutputFile), FoundationIncluded(false) {
// FIXME: StringSet should have insert(iter, iter) to use here.
for (const std::string &Val : WhiteList)
WhiteListFilenames.insert(Val);
@@ -191,12 +185,10 @@ protected:
} // end anonymous namespace
ObjCMigrateAction::ObjCMigrateAction(
- std::unique_ptr<FrontendAction> WrappedAction,
- StringRef migrateDir,
- unsigned migrateAction)
- : WrapperFrontendAction(std::move(WrappedAction)), MigrateDir(migrateDir),
- ObjCMigAction(migrateAction),
- CompInst(nullptr) {
+ std::unique_ptr<FrontendAction> WrappedAction, StringRef migrateDir,
+ unsigned migrateAction)
+ : WrapperFrontendAction(std::move(WrappedAction)), MigrateDir(migrateDir),
+ ObjCMigAction(migrateAction), CompInst(nullptr) {
if (MigrateDir.empty())
MigrateDir = "."; // user current directory if none is given.
}
@@ -533,7 +525,7 @@ static void rewriteToObjCProperty(const ObjCMethodDecl *Getter,
// after that; e.g. isContinuous will become continuous.
StringRef PropertyNameStringRef(PropertyNameString);
PropertyNameStringRef = PropertyNameStringRef.drop_front(LengthOfPrefix);
- PropertyNameString = PropertyNameStringRef;
+ PropertyNameString = std::string(PropertyNameStringRef);
bool NoLowering = (isUppercase(PropertyNameString[0]) &&
PropertyNameString.size() > 1 &&
isUppercase(PropertyNameString[1]));
@@ -994,7 +986,7 @@ static void ReplaceWithClasstype(const ObjCMigrateASTConsumer &ASTC,
if (TypeSourceInfo *TSInfo = OM->getReturnTypeSourceInfo()) {
TypeLoc TL = TSInfo->getTypeLoc();
R = SourceRange(TL.getBeginLoc(), TL.getEndLoc()); {
- ClassString = IDecl->getName();
+ ClassString = std::string(IDecl->getName());
ClassString += "*";
}
}
@@ -1320,7 +1312,7 @@ void ObjCMigrateASTConsumer::migrateFactoryMethod(ASTContext &Ctx,
if (!IDecl)
return;
- std::string StringClassName = IDecl->getName();
+ std::string StringClassName = std::string(IDecl->getName());
StringRef LoweredClassName(StringClassName);
std::string StringLoweredClassName = LoweredClassName.lower();
LoweredClassName = StringLoweredClassName;
@@ -1330,7 +1322,7 @@ void ObjCMigrateASTConsumer::migrateFactoryMethod(ASTContext &Ctx,
if (!MethodIdName)
return;
- std::string MethodName = MethodIdName->getName();
+ std::string MethodName = std::string(MethodIdName->getName());
if (OIT_Family == OIT_Singleton || OIT_Family == OIT_ReturnsSelf) {
StringRef STRefMethodName(MethodName);
size_t len = 0;
@@ -1342,7 +1334,7 @@ void ObjCMigrateASTConsumer::migrateFactoryMethod(ASTContext &Ctx,
len = strlen("default");
else
return;
- MethodName = STRefMethodName.substr(len);
+ MethodName = std::string(STRefMethodName.substr(len));
}
std::string MethodNameSubStr = MethodName.substr(0, 3);
StringRef MethodNamePrefix(MethodNameSubStr);
@@ -1351,7 +1343,7 @@ void ObjCMigrateASTConsumer::migrateFactoryMethod(ASTContext &Ctx,
size_t Ix = LoweredClassName.rfind(MethodNamePrefix);
if (Ix == StringRef::npos)
return;
- std::string ClassNamePostfix = LoweredClassName.substr(Ix);
+ std::string ClassNamePostfix = std::string(LoweredClassName.substr(Ix));
StringRef LoweredMethodName(MethodName);
std::string StringLoweredMethodName = LoweredMethodName.lower();
LoweredMethodName = StringLoweredMethodName;
@@ -2010,7 +2002,7 @@ static std::vector<std::string> getWhiteListFilenames(StringRef DirPath) {
directory_iterator DE;
for (; !EC && DI != DE; DI = DI.increment(EC)) {
if (is_regular_file(DI->path()))
- Filenames.push_back(filename(DI->path()));
+ Filenames.push_back(std::string(filename(DI->path())));
}
return Filenames;
@@ -2153,7 +2145,7 @@ private:
if (Val.getAsInteger(10, Entry.RemoveLen))
Ignore = true;
} else if (Key == "text") {
- Entry.Text = Val;
+ Entry.Text = std::string(Val);
}
}
@@ -2224,7 +2216,7 @@ static std::string applyEditsToTemp(const FileEntry *FE,
TmpOut.write(NewText.data(), NewText.size());
TmpOut.close();
- return TempPath.str();
+ return std::string(TempPath.str());
}
bool arcmt::getFileRemappingsFromFileList(
diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp
index ea4d0de..05adf22 100644
--- a/clang/lib/AST/ASTDiagnostic.cpp
+++ b/clang/lib/AST/ASTDiagnostic.cpp
@@ -1715,8 +1715,9 @@ class TemplateDiff {
bool FromDefault, bool ToDefault, bool Same) {
assert((FromTD || ToTD) && "Only one template argument may be missing.");
- std::string FromName = FromTD ? FromTD->getName() : "(no argument)";
- std::string ToName = ToTD ? ToTD->getName() : "(no argument)";
+ std::string FromName =
+ std::string(FromTD ? FromTD->getName() : "(no argument)");
+ std::string ToName = std::string(ToTD ? ToTD->getName() : "(no argument)");
if (FromTD && ToTD && FromName == ToName) {
FromName = FromTD->getQualifiedNameAsString();
ToName = ToTD->getQualifiedNameAsString();
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index cb4d61c..325a306 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -587,7 +587,7 @@ AvailabilityResult Decl::getAvailability(std::string *Message,
continue;
if (Message)
- ResultMessage = Deprecated->getMessage();
+ ResultMessage = std::string(Deprecated->getMessage());
Result = AR_Deprecated;
continue;
@@ -595,7 +595,7 @@ AvailabilityResult Decl::getAvailability(std::string *Message,
if (const auto *Unavailable = dyn_cast<UnavailableAttr>(A)) {
if (Message)
- *Message = Unavailable->getMessage();
+ *Message = std::string(Unavailable->getMessage());
return AR_Unavailable;
}
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 20505b2..a0d11ee 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -689,10 +689,10 @@ std::string PredefinedExpr::ComputeName(IdentKind IK, const Decl *CurrentDecl) {
MC->mangleName(ND, Out);
if (!Buffer.empty() && Buffer.front() == '\01')
- return Buffer.substr(1);
- return Buffer.str();
+ return std::string(Buffer.substr(1));
+ return std::string(Buffer.str());
} else
- return ND->getIdentifier()->getName();
+ return std::string(ND->getIdentifier()->getName());
}
return "";
}
@@ -711,7 +711,7 @@ std::string PredefinedExpr::ComputeName(IdentKind IK, const Decl *CurrentDecl) {
Out << ComputeName(IK, DCBlock);
else if (auto *DCDecl = dyn_cast<Decl>(DC))
Out << ComputeName(IK, DCDecl) << "_block_invoke";
- return Out.str();
+ return std::string(Out.str());
}
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurrentDecl)) {
if (IK != PrettyFunction && IK != PrettyFunctionNoVirtual &&
@@ -962,7 +962,7 @@ std::string FixedPointLiteral::getValueAsString(unsigned Radix) const {
SmallString<64> S;
FixedPointValueToString(
S, llvm::APSInt::getUnsigned(getValue().getZExtValue()), Scale);
- return S.str();
+ return std::string(S.str());
}
FloatingLiteral::FloatingLiteral(const ASTContext &C, const llvm::APFloat &V,
diff --git a/clang/lib/AST/ExternalASTSource.cpp b/clang/lib/AST/ExternalASTSource.cpp
index 837be55..aa896aa 100644
--- a/clang/lib/AST/ExternalASTSource.cpp
+++ b/clang/lib/AST/ExternalASTSource.cpp
@@ -50,7 +50,7 @@ std::string ExternalASTSource::ASTSourceDescriptor::getModuleName() const {
if (ClangModule)
return ClangModule->Name;
else
- return PCHModuleName;
+ return std::string(PCHModuleName);
}
void ExternalASTSource::FindFileRegionDecls(FileID File, unsigned Offset,
diff --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp
index e106b31..6fd1840 100644
--- a/clang/lib/AST/Mangle.cpp
+++ b/clang/lib/AST/Mangle.cpp
@@ -358,7 +358,7 @@ public:
SmallString<40> Mangled;
auto Prefix = getClassSymbolPrefix(Kind, OCD->getASTContext());
llvm::Mangler::getNameWithPrefix(Mangled, Prefix + ClassName, DL);
- return Mangled.str();
+ return std::string(Mangled.str());
};
return {
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp
index a286c53..fa84716 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -1301,7 +1301,7 @@ void MicrosoftCXXNameMangler::mangleSourceName(StringRef Name) {
BackRefVec::iterator Found = llvm::find(NameBackReferences, Name);
if (Found == NameBackReferences.end()) {
if (NameBackReferences.size() < 10)
- NameBackReferences.push_back(Name);
+ NameBackReferences.push_back(std::string(Name));
Out << Name << '@';
} else {
Out << (Found - NameBackReferences.begin());
diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp
index 7409ae7..1aea9ac 100644
--- a/clang/lib/AST/Stmt.cpp
+++ b/clang/lib/AST/Stmt.cpp
@@ -732,7 +732,7 @@ std::string GCCAsmStmt::generateAsmString(const ASTContext &C) const {
/// Assemble final IR asm string (MS-style).
std::string MSAsmStmt::generateAsmString(const ASTContext &C) const {
// FIXME: This needs to be translated into the IR string representation.
- return AsmStr;
+ return std::string(AsmStr);
}
Expr *MSAsmStmt::getOutputExpr(unsigned i) {
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index 45fd8ce..76295ae 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -75,14 +75,11 @@ namespace {
public:
StmtPrinter(raw_ostream &os, PrinterHelper *helper,
const PrintingPolicy &Policy, unsigned Indentation = 0,
- StringRef NL = "\n",
- const ASTContext *Context = nullptr)
+ StringRef NL = "\n", const ASTContext *Context = nullptr)
: OS(os), IndentLevel(Indentation), Helper(helper), Policy(Policy),
NL(NL), Context(Context) {}
- void PrintStmt(Stmt *S) {
- PrintStmt(S, Policy.Indentation);
- }
+ void PrintStmt(Stmt *S) { PrintStmt(S, Policy.Indentation); }
void PrintStmt(Stmt *S, int SubIndent) {
IndentLevel += SubIndent;
diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 1495162..6c6cd3c 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -1763,7 +1763,7 @@ std::string Qualifiers::getAsString(const PrintingPolicy &Policy) const {
SmallString<64> Buf;
llvm::raw_svector_ostream StrOS(Buf);
print(StrOS, Policy);
- return StrOS.str();
+ return std::string(StrOS.str());
}
bool Qualifiers::isEmptyWhenPrinted(const PrintingPolicy &Policy) const {
@@ -1921,6 +1921,6 @@ void QualType::getAsStringInternal(const Type *ty, Qualifiers qs,
SmallString<256> Buf;
llvm::raw_svector_ostream StrOS(Buf);
TypePrinter(policy).print(ty, qs, StrOS, buffer);
- std::string str = StrOS.str();
+ std::string str = std::string(StrOS.str());
buffer.swap(str);
}
diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index 67b61d0..cd3f346 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -653,7 +653,7 @@ Registry::getMatcherCompletions(ArrayRef<ArgKind> AcceptedTypes) {
OS << "...";
OS << ")";
- std::string TypedText = Name;
+ std::string TypedText = std::string(Name);
TypedText += "(";
if (ArgsKinds.empty())
TypedText += ")";
diff --git a/clang/lib/Analysis/RetainSummaryManager.cpp b/clang/lib/Analysis/RetainSummaryManager.cpp
index 6f46917..181ff1b 100644
--- a/clang/lib/Analysis/RetainSummaryManager.cpp
+++ b/clang/lib/Analysis/RetainSummaryManager.cpp
@@ -140,7 +140,8 @@ RetainSummaryManager::getPersistentSummary(const RetainSummary &OldSumm) {
static bool isSubclass(const Decl *D,
StringRef ClassName) {
using namespace ast_matchers;
- DeclarationMatcher SubclassM = cxxRecordDecl(isSameOrDerivedFrom(ClassName));
+ DeclarationMatcher SubclassM =
+ cxxRecordDecl(isSameOrDerivedFrom(std::string(ClassName)));
return !(match(SubclassM, *D, D->getASTContext()).empty());
}
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index 079a4bb..e4d019a 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -454,7 +454,7 @@ void FileManager::fillRealPathName(FileEntry *UFE, llvm::StringRef FileName) {
// misleading. We need to clean up the interface here.
makeAbsolutePath(AbsPath);
llvm::sys::path::remove_dots(AbsPath, /*remove_dot_dot=*/true);
- UFE->RealPathName = AbsPath.str();
+ UFE->RealPathName = std::string(AbsPath.str());
}
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp
index ee25bd8..54f449f 100644
--- a/clang/lib/Basic/IdentifierTable.cpp
+++ b/clang/lib/Basic/IdentifierTable.cpp
@@ -463,7 +463,7 @@ std::string MultiKeywordSelector::getName() const {
OS << ':';
}
- return OS.str();
+ return std::string(OS.str());
}
std::string Selector::getAsString() const {
@@ -476,7 +476,7 @@ std::string Selector::getAsString() const {
if (getNumArgs() == 0) {
assert(II && "If the number of arguments is 0 then II is guaranteed to "
"not be null.");
- return II->getName();
+ return std::string(II->getName());
}
if (!II)
diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index be088e8..c51a182 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -107,7 +107,7 @@ void ARMTargetInfo::setArchInfo() {
StringRef ArchName = getTriple().getArchName();
ArchISA = llvm::ARM::parseArchISA(ArchName);
- CPU = llvm::ARM::getDefaultCPU(ArchName);
+ CPU = std::string(llvm::ARM::getDefaultCPU(ArchName));
llvm::ARM::ArchKind AK = llvm::ARM::parseArch(ArchName);
if (AK != llvm::ARM::ArchKind::INVALID)
ArchKind = AK;
diff --git a/clang/lib/Basic/Warnings.cpp b/clang/lib/Basic/Warnings.cpp
index 88ef2ea..2c909d9 100644
--- a/clang/lib/Basic/Warnings.cpp
+++ b/clang/lib/Basic/Warnings.cpp
@@ -36,8 +36,9 @@ static void EmitUnknownDiagWarning(DiagnosticsEngine &Diags,
StringRef Opt) {
StringRef Suggestion = DiagnosticIDs::getNearestOption(Flavor, Opt);
Diags.Report(diag::warn_unknown_diag_option)
- << (Flavor == diag::Flavor::WarningOrError ? 0 : 1) << (Prefix.str() += Opt)
- << !Suggestion.empty() << (Prefix.str() += Suggestion);
+ << (Flavor == diag::Flavor::WarningOrError ? 0 : 1)
+ << (Prefix.str() += std::string(Opt)) << !Suggestion.empty()
+ << (Prefix.str() += std::string(Suggestion));
}
void clang::ProcessWarningOptions(DiagnosticsEngine &Diags,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 6eff6bd..48e2645 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -729,7 +729,7 @@ void EmitAssemblyHelper::CreatePasses(legacy::PassManager &MPM,
if (!CodeGenOpts.InstrProfileOutput.empty())
PMBuilder.PGOInstrGen = CodeGenOpts.InstrProfileOutput;
else
- PMBuilder.PGOInstrGen = DefaultProfileGenName;
+ PMBuilder.PGOInstrGen = std::string(DefaultProfileGenName);
}
if (CodeGenOpts.hasProfileIRUse()) {
PMBuilder.PGOInstrUse = CodeGenOpts.ProfileInstrumentUsePath;
@@ -1024,7 +1024,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
if (CodeGenOpts.hasProfileIRInstr())
// -fprofile-generate.
PGOOpt = PGOOptions(CodeGenOpts.InstrProfileOutput.empty()
- ? DefaultProfileGenName
+ ? std::string(DefaultProfileGenName)
: CodeGenOpts.InstrProfileOutput,
"", "", PGOOptions::IRInstr, PGOOptions::NoCSAction,
CodeGenOpts.DebugInfoForProfiling);
@@ -1057,13 +1057,13 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
"Cannot run CSProfileGen pass with ProfileGen or SampleUse "
" pass");
PGOOpt->CSProfileGenFile = CodeGenOpts.InstrProfileOutput.empty()
- ? DefaultProfileGenName
+ ? std::string(DefaultProfileGenName)
: CodeGenOpts.InstrProfileOutput;
PGOOpt->CSAction = PGOOptions::CSIRInstr;
} else
PGOOpt = PGOOptions("",
CodeGenOpts.InstrProfileOutput.empty()
- ? DefaultProfileGenName
+ ? std::string(DefaultProfileGenName)
: CodeGenOpts.InstrProfileOutput,
"", PGOOptions::NoAction, PGOOptions::CSIRInstr,
CodeGenOpts.DebugInfoForProfiling);
diff --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp
index 5c5cbaf..52324f4 100644
--- a/clang/lib/CodeGen/CGCUDANV.cpp
+++ b/clang/lib/CodeGen/CGCUDANV.cpp
@@ -211,9 +211,9 @@ std::string CGNVCUDARuntime::getDeviceSideName(const Decl *D) {
SmallString<256> Buffer;
llvm::raw_svector_ostream Out(Buffer);
DeviceMC->mangleName(ND, Out);
- DeviceSideName = Out.str();
+ DeviceSideName = std::string(Out.str());
} else
- DeviceSideName = ND->getIdentifier()->getName();
+ DeviceSideName = std::string(ND->getIdentifier()->getName());
return DeviceSideName;
}
@@ -551,8 +551,8 @@ llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() {
if (CudaGpuBinary) {
// If fatbin is available from early finalization, create a string
// literal containing the fat binary loaded from the given file.
- FatBinStr = makeConstantString(CudaGpuBinary->getBuffer(), "",
- FatbinConstantName, 8);
+ FatBinStr = makeConstantString(std::string(CudaGpuBinary->getBuffer()),
+ "", FatbinConstantName, 8);
} else {
// If fatbin is not available, create an external symbol
// __hip_fatbin in section .hip_fatbin. The external symbol is supposed
@@ -586,7 +586,7 @@ llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() {
// For CUDA, create a string literal containing the fat binary loaded from
// the given file.
- FatBinStr = makeConstantString(CudaGpuBinary->getBuffer(), "",
+ FatBinStr = makeConstantString(std::string(CudaGpuBinary->getBuffer()), "",
FatbinConstantName, 8);
FatMagic = CudaFatMagic;
}
@@ -691,8 +691,8 @@ llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() {
SmallString<64> ModuleID;
llvm::raw_svector_ostream OS(ModuleID);
OS << ModuleIDPrefix << llvm::format("%" PRIx64, FatbinWrapper->getGUID());
- llvm::Constant *ModuleIDConstant =
- makeConstantString(ModuleID.str(), "", ModuleIDSectionName, 32);
+ llvm::Constant *ModuleIDConstant = makeConstantString(
+ std::string(ModuleID.str()), "", ModuleIDSectionName, 32);
// Create an alias for the FatbinWrapper that nvcc will look for.
llvm::GlobalAlias::create(llvm::GlobalValue::ExternalLinkage,
@@ -799,7 +799,7 @@ llvm::Function *CGNVCUDARuntime::makeModuleDtorFunction() {
std::string CGNVCUDARuntime::getDeviceStubName(llvm::StringRef Name) const {
if (!CGM.getLangOpts().HIP)
- return Name;
+ return std::string(Name);
return (Name + ".stub").str();
}
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index fd2c61b..99af4e2 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -532,11 +532,12 @@ void CGDebugInfo::CreateCompileUnit() {
// file to determine the real absolute path for the file.
std::string MainFileDir;
if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
- MainFileDir = MainFile->getDir()->getName();
+ MainFileDir = std::string(MainFile->getDir()->getName());
if (!llvm::sys::path::is_absolute(MainFileName)) {
llvm::SmallString<1024> MainFileDirSS(MainFileDir);
llvm::sys::path::append(MainFileDirSS, MainFileName);
- MainFileName = llvm::sys::path::remove_leading_dotslash(MainFileDirSS);
+ MainFileName =
+ std::string(llvm::sys::path::remove_leading_dotslash(MainFileDirSS));
}
// If the main file name provided is identical to the input file name, and
// if the input file is a preprocessed source, use the module name for
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 60f1dba..589bd20 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -206,9 +206,9 @@ static std::string getStaticDeclName(CodeGenModule &CGM, const VarDecl &D) {
if (auto *CD = dyn_cast<CapturedDecl>(DC))
DC = cast<DeclContext>(CD->getNonClosureContext());
if (const auto *FD = dyn_cast<FunctionDecl>(DC))
- ContextName = CGM.getMangledName(FD);
+ ContextName = std::string(CGM.getMangledName(FD));
else if (const auto *BD = dyn_cast<BlockDecl>(DC))
- ContextName = CGM.getBlockMangledName(GlobalDecl(), BD);
+ ContextName = std::string(CGM.getBlockMangledName(GlobalDecl(), BD));
else if (const auto *OMD = dyn_cast<ObjCMethodDecl>(DC))
ContextName = OMD->getSelector().getAsString();
else
@@ -233,7 +233,7 @@ llvm::Constant *CodeGenModule::getOrCreateStaticVarDecl(
// Use the label if the variable is renamed with the asm-label extension.
std::string Name;
if (D.hasAttr<AsmLabelAttr>())
- Name = getMangledName(&D);
+ Name = std::string(getMangledName(&D));
else
Name = getStaticDeclName(*this, D);
@@ -1087,7 +1087,7 @@ Address CodeGenModule::createUnnamedGlobalFrom(const VarDecl &D,
return CC->getNameAsString();
if (const auto *CD = dyn_cast<CXXDestructorDecl>(FD))
return CD->getNameAsString();
- return getMangledName(FD);
+ return std::string(getMangledName(FD));
} else if (const auto *OM = dyn_cast<ObjCMethodDecl>(DC)) {
return OM->getNameAsString();
} else if (isa<BlockDecl>(DC)) {
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 8e06041..f1a5e3d 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -2779,7 +2779,7 @@ LValue CodeGenFunction::EmitPredefinedLValue(const PredefinedExpr *E) {
PredefinedExpr::getIdentKindName(E->getIdentKind()), FnName};
std::string GVName = llvm::join(NameItems, NameItems + 2, ".");
if (auto *BD = dyn_cast_or_null<BlockDecl>(CurCodeDecl)) {
- std::string Name = SL->getString();
+ std::string Name = std::string(SL->getString());
if (!Name.empty()) {
unsigned Discriminator =
CGM.getCXXABI().getMangleContext().getBlockId(BD, true);
@@ -2788,7 +2788,8 @@ LValue CodeGenFunction::EmitPredefinedLValue(const PredefinedExpr *E) {
auto C = CGM.GetAddrOfConstantCString(Name, GVName.c_str());
return MakeAddrLValue(C, E->getType(), AlignmentSource::Decl);
} else {
- auto C = CGM.GetAddrOfConstantCString(FnName, GVName.c_str());
+ auto C =
+ CGM.GetAddrOfConstantCString(std::string(FnName), GVName.c_str());
return MakeAddrLValue(C, E->getType(), AlignmentSource::Decl);
}
}
@@ -2918,7 +2919,8 @@ llvm::Constant *CodeGenFunction::EmitCheckSourceLocation(SourceLocation Loc) {
FilenameString = llvm::sys::path::filename(FilenameString);
}
- auto FilenameGV = CGM.GetAddrOfConstantCString(FilenameString, ".src");
+ auto FilenameGV =
+ CGM.GetAddrOfConstantCString(std::string(FilenameString), ".src");
CGM.getSanitizerMetadata()->disableSanitizerForGlobal(
cast<llvm::GlobalVariable>(FilenameGV.getPointer()));
Filename = FilenameGV.getPointer();
diff --git a/clang/lib/CodeGen/CGNonTrivialStruct.cpp b/clang/lib/CodeGen/CGNonTrivialStruct.cpp
index d5f378c..91303ce 100644
--- a/clang/lib/CodeGen/CGNonTrivialStruct.cpp
+++ b/clang/lib/CodeGen/CGNonTrivialStruct.cpp
@@ -439,7 +439,7 @@ template <class Derived> struct GenFuncBase {
}
if (WrongType) {
- std::string FuncName = F->getName();
+ std::string FuncName = std::string(F->getName());
SourceLocation Loc = QT->castAs<RecordType>()->getDecl()->getLocation();
CGM.Error(Loc, "special function " + FuncName +
" for non-trivial C struct has incorrect type");
diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index 4c40152..e93aca0 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -203,7 +203,8 @@ protected:
/// the start of the string. The result of this function can be used anywhere
/// where the C code specifies const char*.
llvm::Constant *MakeConstantString(StringRef Str, const char *Name = "") {
- ConstantAddress Array = CGM.GetAddrOfConstantCString(Str, Name);
+ ConstantAddress Array =
+ CGM.GetAddrOfConstantCString(std::string(Str), Name);
return llvm::ConstantExpr::getGetElementPtr(Array.getElementType(),
Array.getPointer(), Zeros);
}
@@ -1433,7 +1434,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
llvm::Constant *GetTypeString(llvm::StringRef TypeEncoding) {
if (TypeEncoding.empty())
return NULLPtr;
- std::string MangledTypes = TypeEncoding;
+ std::string MangledTypes = std::string(TypeEncoding);
std::replace(MangledTypes.begin(), MangledTypes.end(),
'@', '\1');
std::string TypesVarName = ".objc_sel_types_" + MangledTypes;
@@ -2412,7 +2413,8 @@ llvm::Constant *CGObjCGNUstep::GetEHType(QualType T) {
assert(PT && "Invalid @catch type.");
const ObjCInterfaceType *IT = PT->getInterfaceType();
assert(IT && "Invalid @catch type.");
- std::string className = IT->getDecl()->getIdentifier()->getName();
+ std::string className =
+ std::string(IT->getDecl()->getIdentifier()->getName());
std::string typeinfoName = "__objc_eh_typeinfo_" + className;
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index ab2dee1..f994ec9 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -3047,9 +3047,10 @@ llvm::Value *CGObjCCommonMac::EmitClassRefViaRuntime(
ObjCCommonTypesHelper &ObjCTypes) {
llvm::FunctionCallee lookUpClassFn = ObjCTypes.getLookUpClassFn();
- llvm::Value *className =
- CGF.CGM.GetAddrOfConstantCString(ID->getObjCRuntimeNameAsString())
- .getPointer();
+ llvm::Value *className = CGF.CGM
+ .GetAddrOfConstantCString(std::string(
+ ID->getObjCRuntimeNameAsString()))
+ .getPointer();
ASTContext &ctx = CGF.CGM.getContext();
className =
CGF.Builder.CreateBitCast(className,
@@ -6352,7 +6353,7 @@ llvm::GlobalVariable * CGObjCNonFragileABIMac::BuildClassRoTInitializer(
unsigned InstanceStart,
unsigned InstanceSize,
const ObjCImplementationDecl *ID) {
- std::string ClassName = ID->getObjCRuntimeNameAsString();
+ std::string ClassName = std::string(ID->getObjCRuntimeNameAsString());
CharUnits beginInstance = CharUnits::fromQuantity(InstanceStart);
CharUnits endInstance = CharUnits::fromQuantity(InstanceSize);
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index aecf150..9150d3b 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1344,7 +1344,7 @@ std::string CGOpenMPRuntime::getName(ArrayRef<StringRef> Parts) const {
OS << Sep << Part;
Sep = Separator;
}
- return OS.str();
+ return std::string(OS.str());
}
static llvm::Function *
@@ -5972,7 +5972,7 @@ static std::string generateUniqueName(CodeGenModule &CGM, StringRef Prefix,
{D->isLocalVarDeclOrParm() ? D->getName() : CGM.getMangledName(D)});
Out << Prefix << Name << "_"
<< D->getCanonicalDecl()->getBeginLoc().getRawEncoding();
- return Out.str();
+ return std::string(Out.str());
}
/// Emits reduction initializer function:
@@ -10502,7 +10502,7 @@ static std::string mangleVectorParameters(ArrayRef<ParamAttrTy> ParamAttrs) {
Out << 'a' << ParamAttr.Alignment;
}
- return Out.str();
+ return std::string(Out.str());
}
// Function used to add the attribute. The parameter `VLEN` is
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp
index 7065e78..b89b080 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -994,7 +994,7 @@ CodeGenAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
std::unique_ptr<BackendConsumer> Result(new BackendConsumer(
BA, CI.getDiagnostics(), CI.getHeaderSearchOpts(),
CI.getPreprocessorOpts(), CI.getCodeGenOpts(), CI.getTargetOpts(),
- CI.getLangOpts(), CI.getFrontendOpts().ShowTimers, InFile,
+ CI.getLangOpts(), CI.getFrontendOpts().ShowTimers, std::string(InFile),
std::move(LinkModules), std::move(OS), *VMContext, CoverageInfo));
BEConsumer = Result.get();
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 58bd040..03c3fec 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1052,7 +1052,7 @@ static std::string getMangledNameImpl(const CodeGenModule &CGM, GlobalDecl GD,
}
}
- return Out.str();
+ return std::string(Out.str());
}
void CodeGenModule::UpdateMultiVersionNames(GlobalDecl GD,
diff --git a/clang/lib/CrossTU/CrossTranslationUnit.cpp b/clang/lib/CrossTU/CrossTranslationUnit.cpp
index 7391d71..f182f5c 100644
--- a/clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ b/clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -130,7 +130,7 @@ std::error_code IndexError::convertToErrorCode() const {
llvm::Expected<llvm::StringMap<std::string>>
parseCrossTUIndex(StringRef IndexPath, StringRef CrossTUDir) {
- std::ifstream ExternalMapFile(IndexPath);
+ std::ifstream ExternalMapFile{std::string(IndexPath)};
if (!ExternalMapFile)
return llvm::make_error<IndexError>(index_error_code::missing_index_file,
IndexPath.str());
@@ -258,8 +258,8 @@ llvm::Expected<const T *> CrossTranslationUnitContext::getCrossTUDefinitionImpl(
// diagnostics.
++NumTripleMismatch;
return llvm::make_error<IndexError>(index_error_code::triple_mismatch,
- Unit->getMainFileName(), TripleTo.str(),
- TripleFrom.str());
+ std::string(Unit->getMainFileName()),
+ TripleTo.str(), TripleFrom.str());
}
const auto &LangTo = Context.getLangOpts();
@@ -356,7 +356,7 @@ CrossTranslationUnitContext::ASTFileLoader::operator()(StringRef ASTFilePath) {
new DiagnosticsEngine(DiagID, &*DiagOpts, DiagClient));
return ASTUnit::LoadFromASTFile(
- ASTFilePath, CI.getPCHContainerOperations()->getRawReader(),
+ std::string(ASTFilePath), CI.getPCHContainerOperations()->getRawReader(),
ASTUnit::LoadEverything, Diags, CI.getFileSystemOpts());
}
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 7ee3caa..0813146 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -99,7 +99,7 @@ std::string Driver::GetResourcesPath(StringRef BinaryPath,
// exact same string ("a/../b/" and "b/" get different hashes, for example).
// Dir is bin/ or lib/, depending on where BinaryPath is.
- std::string Dir = llvm::sys::path::parent_path(BinaryPath);
+ std::string Dir = std::string(llvm::sys::path::parent_path(BinaryPath));
SmallString<128> P(Dir);
if (CustomResourceDir != "") {
@@ -115,7 +115,7 @@ std::string Driver::GetResourcesPath(StringRef BinaryPath,
CLANG_VERSION_STRING);
}
- return P.str();
+ return std::string(P.str());
}
Driver::Driver(StringRef ClangExecutable, StringRef TargetTriple,
@@ -131,13 +131,12 @@ Driver::Driver(StringRef ClangExecutable, StringRef TargetTriple,
TargetTriple(TargetTriple), CCCGenericGCCName(""), Saver(Alloc),
CheckInputsExist(true), GenReproducer(false),
SuppressMissingInputWarning(false) {
-
// Provide a sane fallback if no VFS is specified.
if (!this->VFS)
this->VFS = llvm::vfs::getRealFileSystem();
- Name = llvm::sys::path::filename(ClangExecutable);
- Dir = llvm::sys::path::parent_path(ClangExecutable);
+ Name = std::string(llvm::sys::path::filename(ClangExecutable));
+ Dir = std::string(llvm::sys::path::parent_path(ClangExecutable));
InstalledDir = Dir; // Provide a sensible default installed dir.
#if defined(CLANG_CONFIG_FILE_SYSTEM_DIR)
@@ -769,7 +768,7 @@ bool Driver::readConfigFile(StringRef FileName) {
// Read options from config file.
llvm::SmallString<128> CfgFileName(FileName);
llvm::sys::path::native(CfgFileName);
- ConfigFile = CfgFileName.str();
+ ConfigFile = std::string(CfgFileName.str());
bool ContainErrors;
CfgOptions = std::make_unique<InputArgList>(
ParseArgStrings(NewCfgArgs, IsCLMode(), ContainErrors));
@@ -952,7 +951,7 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
while (!CompilerPath.empty()) {
std::pair<StringRef, StringRef> Split =
CompilerPath.split(llvm::sys::EnvPathSeparator);
- PrefixDirs.push_back(Split.first);
+ PrefixDirs.push_back(std::string(Split.first));
CompilerPath = Split.second;
}
}
@@ -1413,7 +1412,7 @@ void Driver::generateCompilationDiagnostics(
ScriptOS << "\n# Additional information: " << AdditionalInformation
<< "\n";
if (Report)
- Report->TemporaryFiles.push_back(Script.str());
+ Report->TemporaryFiles.push_back(std::string(Script.str()));
Diag(clang::diag::note_drv_command_failed_diag_msg) << Script;
}
@@ -1642,7 +1641,7 @@ void Driver::HandleAutocompletions(StringRef PassedFlags) const {
// this code.
for (StringRef S : DiagnosticIDs::getDiagnosticFlags())
if (S.startswith(Cur))
- SuggestedCompletions.push_back(S);
+ SuggestedCompletions.push_back(std::string(S));
}
// Sort the autocomplete candidates so that shells print them out in a
@@ -4662,17 +4661,17 @@ std::string Driver::GetFilePath(StringRef Name, const ToolChain &TC) const {
SmallString<128> R(ResourceDir);
llvm::sys::path::append(R, Name);
if (llvm::sys::fs::exists(Twine(R)))
- return R.str();
+ return std::string(R.str());
SmallString<128> P(TC.getCompilerRTPath());
llvm::sys::path::append(P, Name);
if (llvm::sys::fs::exists(Twine(P)))
- return P.str();
+ return std::string(P.str());
SmallString<128> D(Dir);
llvm::sys::path::append(D, "..", Name);
if (llvm::sys::fs::exists(Twine(D)))
- return D.str();
+ return std::string(D.str());
if (auto P = SearchPaths(TC.getLibraryPaths()))
return *P;
@@ -4680,7 +4679,7 @@ std::string Driver::GetFilePath(StringRef Name, const ToolChain &TC) const {
if (auto P = SearchPaths(TC.getFilePaths()))
return *P;
- return Name;
+ return std::string(Name);
}
void Driver::generatePrefixedToolNames(
@@ -4717,11 +4716,11 @@ std::string Driver::GetProgramPath(StringRef Name, const ToolChain &TC) const {
if (llvm::sys::fs::is_directory(PrefixDir)) {
SmallString<128> P(PrefixDir);
if (ScanDirForExecutable(P, TargetSpecificExecutables))
- return P.str();
+ return std::string(P.str());
} else {
SmallString<128> P((PrefixDir + Name).str());
if (llvm::sys::fs::can_execute(Twine(P)))
- return P.str();
+ return std::string(P.str());
}
}
@@ -4729,7 +4728,7 @@ std::string Driver::GetProgramPath(StringRef Name, const ToolChain &TC) const {
for (const auto &Path : List) {
SmallString<128> P(Path);
if (ScanDirForExecutable(P, TargetSpecificExecutables))
- return P.str();
+ return std::string(P.str());
}
// If all else failed, search the path.
@@ -4738,7 +4737,7 @@ std::string Driver::GetProgramPath(StringRef Name, const ToolChain &TC) const {
llvm::sys::findProgramByName(TargetSpecificExecutable))
return *P;
- return Name;
+ return std::string(Name);
}
std::string Driver::GetTemporaryPath(StringRef Prefix, StringRef Suffix) const {
@@ -4749,7 +4748,7 @@ std::string Driver::GetTemporaryPath(StringRef Prefix, StringRef Suffix) const {
return "";
}
- return Path.str();
+ return std::string(Path.str());
}
std::string Driver::GetTemporaryDirectory(StringRef Prefix) const {
@@ -4760,7 +4759,7 @@ std::string Driver::GetTemporaryDirectory(StringRef Prefix) const {
return "";
}
- return Path.str();
+ return std::string(Path.str());
}
std::string Driver::GetClPchPath(Compilation &C, StringRef BaseName) const {
@@ -4782,7 +4781,7 @@ std::string Driver::GetClPchPath(Compilation &C, StringRef BaseName) const {
Output = BaseName;
llvm::sys::path::replace_extension(Output, ".pch");
}
- return Output.str();
+ return std::string(Output.str());
}
const ToolChain &Driver::getToolChain(const ArgList &Args,
diff --git a/clang/lib/Driver/Multilib.cpp b/clang/lib/Driver/Multilib.cpp
index 303047e..5dd5555 100644
--- a/clang/lib/Driver/Multilib.cpp
+++ b/clang/lib/Driver/Multilib.cpp
@@ -46,7 +46,7 @@ static void normalizePathSegment(std::string &Segment) {
if (seg.front() != '/') {
Segment = "/" + seg.str();
} else {
- Segment = seg;
+ Segment = std::string(seg);
}
}
@@ -60,19 +60,19 @@ Multilib::Multilib(StringRef GCCSuffix, StringRef OSSuffix,
}
Multilib &Multilib::gccSuffix(StringRef S) {
- GCCSuffix = S;
+ GCCSuffix = std::string(S);
normalizePathSegment(GCCSuffix);
return *this;
}
Multilib &Multilib::osSuffix(StringRef S) {
- OSSuffix = S;
+ OSSuffix = std::string(S);
normalizePathSegment(OSSuffix);
return *this;
}
Multilib &Multilib::includeSuffix(StringRef S) {
- IncludeSuffix = S;
+ IncludeSuffix = std::string(S);
normalizePathSegment(IncludeSuffix);
return *this;
}
diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp
index c2fa514..c52febe 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -142,7 +142,7 @@ static void addDefaultBlacklists(const Driver &D, SanitizerMask Kinds,
clang::SmallString<64> Path(D.ResourceDir);
llvm::sys::path::append(Path, "share", BL.File);
if (D.getVFS().exists(Path))
- BlacklistFiles.push_back(Path.str());
+ BlacklistFiles.push_back(std::string(Path.str()));
else if (BL.Mask == SanitizerKind::CFI)
// If cfi_blacklist.txt cannot be found in the resource dir, driver
// should fail.
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index cab97b1..8aef74f 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -168,7 +168,7 @@ static const DriverSuffix *FindDriverSuffix(StringRef ProgName, size_t &Pos) {
/// Normalize the program name from argv[0] by stripping the file extension if
/// present and lower-casing the string on Windows.
static std::string normalizeProgramName(llvm::StringRef Argv0) {
- std::string ProgName = llvm::sys::path::stem(Argv0);
+ std::string ProgName = std::string(llvm::sys::path::stem(Argv0));
#ifdef _WIN32
// Transform to lowercase for case insensitive file systems.
std::transform(ProgName.begin(), ProgName.end(), ProgName.begin(), ::tolower);
@@ -221,8 +221,10 @@ ToolChain::getTargetAndModeFromProgramName(StringRef PN) {
StringRef Prefix(ProgName);
Prefix = Prefix.slice(0, LastComponent);
std::string IgnoredError;
- bool IsRegistered = llvm::TargetRegistry::lookupTarget(Prefix, IgnoredError);
- return ParsedClangName{Prefix, ModeSuffix, DS->ModeFlag, IsRegistered};
+ bool IsRegistered =
+ llvm::TargetRegistry::lookupTarget(std::string(Prefix), IgnoredError);
+ return ParsedClangName{std::string(Prefix), ModeSuffix, DS->ModeFlag,
+ IsRegistered};
}
StringRef ToolChain::getDefaultUniversalArchName() const {
@@ -385,7 +387,7 @@ std::string ToolChain::getCompilerRTPath() const {
} else {
llvm::sys::path::append(Path, "lib", getOSLibName());
}
- return Path.str();
+ return std::string(Path.str());
}
std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component,
@@ -415,7 +417,7 @@ std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component,
SmallString<128> P(LibPath);
llvm::sys::path::append(P, Prefix + Twine("clang_rt.") + Component + Suffix);
if (getVFS().exists(P))
- return P.str();
+ return std::string(P.str());
}
StringRef Arch = getArchNameForCompilerRTLib(*this, Args);
@@ -423,7 +425,7 @@ std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component,
SmallString<128> Path(getCompilerRTPath());
llvm::sys::path::append(Path, Prefix + Twine("clang_rt.") + Component + "-" +
Arch + Env + Suffix);
- return Path.str();
+ return std::string(Path.str());
}
const char *ToolChain::getCompilerRTArgString(const llvm::opt::ArgList &Args,
@@ -440,13 +442,13 @@ Optional<std::string> ToolChain::getRuntimePath() const {
P.assign(D.ResourceDir);
llvm::sys::path::append(P, "lib", D.getTargetTriple());
if (getVFS().exists(P))
- return llvm::Optional<std::string>(P.str());
+ return llvm::Optional<std::string>(std::string(P.str()));
// Second try the normalized triple.
P.assign(D.ResourceDir);
llvm::sys::path::append(P, "lib", Triple.str());
if (getVFS().exists(P))
- return llvm::Optional<std::string>(P.str());
+ return llvm::Optional<std::string>(std::string(P.str()));
return None;
}
@@ -458,13 +460,13 @@ Optional<std::string> ToolChain::getCXXStdlibPath() const {
P.assign(D.Dir);
llvm::sys::path::append(P, "..", "lib", D.getTargetTriple(), "c++");
if (getVFS().exists(P))
- return llvm::Optional<std::string>(P.str());
+ return llvm::Optional<std::string>(std::string(P.str()));
// Second try the normalized triple.
P.assign(D.Dir);
llvm::sys::path::append(P, "..", "lib", Triple.str(), "c++");
if (getVFS().exists(P))
- return llvm::Optional<std::string>(P.str());
+ return llvm::Optional<std::string>(std::string(P.str()));
return None;
}
@@ -473,7 +475,7 @@ std::string ToolChain::getArchSpecificLibPath() const {
SmallString<128> Path(getDriver().ResourceDir);
llvm::sys::path::append(Path, "lib", getOSLibName(),
llvm::Triple::getArchTypeName(getArch()));
- return Path.str();
+ return std::string(Path.str());
}
bool ToolChain::needsProfileRT(const ArgList &Args) {
@@ -525,7 +527,7 @@ std::string ToolChain::GetLinkerPath() const {
// If we're passed what looks like an absolute path, don't attempt to
// second-guess that.
if (llvm::sys::fs::can_execute(UseLinker))
- return UseLinker;
+ return std::string(UseLinker);
} else if (UseLinker.empty() || UseLinker == "ld") {
// If we're passed -fuse-ld= with no argument, or with the argument ld,
// then use whatever the default system linker is.
diff --git a/clang/lib/Driver/ToolChains/AVR.cpp b/clang/lib/Driver/ToolChains/AVR.cpp
index e8a3a7b..6405db1 100644
--- a/clang/lib/Driver/ToolChains/AVR.cpp
+++ b/clang/lib/Driver/ToolChains/AVR.cpp
@@ -74,7 +74,7 @@ AVRToolChain::AVRToolChain(const Driver &D, const llvm::Triple &Triple,
// No avr-libc found and so no runtime linked.
D.Diag(diag::warn_drv_avr_libc_not_found);
} else { // We have enough information to link stdlibs
- std::string GCCRoot = GCCInstallation.getInstallPath();
+ std::string GCCRoot = std::string(GCCInstallation.getInstallPath());
std::string LibcRoot = AVRLibcRoot.getValue();
getFilePaths().push_back(LibcRoot + std::string("/lib/") +
diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 9c27504..dc31a5a 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -39,7 +39,7 @@ std::string aarch64::getAArch64TargetCPU(const ArgList &Args,
// Handle CPU name is 'native'.
if (CPU == "native")
- return llvm::sys::getHostCPUName();
+ return std::string(llvm::sys::getHostCPUName());
else if (CPU.size())
return CPU;
@@ -139,7 +139,7 @@ getAArch64MicroArchFeaturesFromMtune(const Driver &D, StringRef Mtune,
// Handle CPU name is 'native'.
if (MtuneLowerCase == "native")
- MtuneLowerCase = llvm::sys::getHostCPUName();
+ MtuneLowerCase = std::string(llvm::sys::getHostCPUName());
if (MtuneLowerCase == "cyclone" || MtuneLowerCase.find("apple") == 0) {
Features.push_back("+zcm");
Features.push_back("+zcz");
diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index a1923e7..e713360 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -612,14 +612,14 @@ fp16_fml_fallthrough:
const std::string arm::getARMArch(StringRef Arch, const llvm::Triple &Triple) {
std::string MArch;
if (!Arch.empty())
- MArch = Arch;
+ MArch = std::string(Arch);
else
- MArch = Triple.getArchName();
+ MArch = std::string(Triple.getArchName());
MArch = StringRef(MArch).split("+").first.lower();
// Handle -march=native.
if (MArch == "native") {
- std::string CPU = llvm::sys::getHostCPUName();
+ std::string CPU = std::string(llvm::sys::getHostCPUName());
if (CPU != "generic") {
// Translate the native cpu into the architecture suffix for that CPU.
StringRef Suffix = arm::getLLVMArchSuffixForARM(CPU, MArch, Triple);
@@ -657,12 +657,12 @@ std::string arm::getARMTargetCPU(StringRef CPU, StringRef Arch,
std::string MCPU = StringRef(CPU).split("+").first.lower();
// Handle -mcpu=native.
if (MCPU == "native")
- return llvm::sys::getHostCPUName();
+ return std::string(llvm::sys::getHostCPUName());
else
return MCPU;
}
- return getARMCPUForMArch(Arch, Triple);
+ return std::string(getARMCPUForMArch(Arch, Triple));
}
/// getLLVMArchSuffixForARM - Get the LLVM ArchKind value to use for a
diff --git a/clang/lib/Driver/ToolChains/Arch/PPC.cpp b/clang/lib/Driver/ToolChains/Arch/PPC.cpp
index f1baada..e5130a9 100644
--- a/clang/lib/Driver/ToolChains/Arch/PPC.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/PPC.cpp
@@ -26,7 +26,7 @@ std::string ppc::getPPCTargetCPU(const ArgList &Args) {
StringRef CPUName = A->getValue();
if (CPUName == "native") {
- std::string CPU = llvm::sys::getHostCPUName();
+ std::string CPU = std::string(llvm::sys::getHostCPUName());
if (!CPU.empty() && CPU != "generic")
return CPU;
else
diff --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index 8c343b8..5f69fdd 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -55,13 +55,13 @@ static bool isSupportedExtension(StringRef Ext) {
static bool getExtensionVersion(const Driver &D, StringRef MArch,
StringRef Ext, StringRef In,
std::string &Major, std::string &Minor) {
- Major = In.take_while(isDigit);
+ Major = std::string(In.take_while(isDigit));
In = In.substr(Major.size());
if (Major.empty())
return true;
if (In.consume_front("p")) {
- Minor = In.take_while(isDigit);
+ Minor = std::string(In.take_while(isDigit));
In = In.substr(Major.size());
// Expected 'p' to be followed by minor version number.
@@ -133,7 +133,7 @@ static void getExtensionFeatures(const Driver &D,
++I;
if (I == E) {
- std::string Error = Desc;
+ std::string Error = std::string(Desc);
Error += " not given in canonical order";
D.Diag(diag::err_drv_invalid_riscv_ext_arch_name)
<< MArch << Error << Ext;
@@ -144,7 +144,7 @@ static void getExtensionFeatures(const Driver &D,
// to allow repeated extension type, e.g.: rv32ixabc_xdef.
if (Name.empty()) {
- std::string Error = Desc;
+ std::string Error = std::string(Desc);
Error += " name missing after";
D.Diag(diag::err_drv_invalid_riscv_ext_arch_name)
<< MArch << Error << Ext;
diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
index 2b77d59..2a2fe6b 100644
--- a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
@@ -21,14 +21,14 @@ std::string systemz::getSystemZTargetCPU(const ArgList &Args) {
llvm::StringRef CPUName = A->getValue();
if (CPUName == "native") {
- std::string CPU = llvm::sys::getHostCPUName();
+ std::string CPU = std::string(llvm::sys::getHostCPUName());
if (!CPU.empty() && CPU != "generic")
return CPU;
else
return "";
}
- return CPUName;
+ return std::string(CPUName);
}
return "z10";
}
diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index d1e0c82..44a636d 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -31,7 +31,7 @@ const char *x86::getX86TargetCPU(const ArgList &Args,
//
// FIXME: We should also incorporate the detected target features for use
// with -native.
- std::string CPU = llvm::sys::getHostCPUName();
+ std::string CPU = std::string(llvm::sys::getHostCPUName());
if (!CPU.empty() && CPU != "generic")
return Args.MakeArgString(CPU);
}
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp
index dff0e04..7c30272 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -67,7 +67,7 @@ Tool *BareMetal::buildLinker() const {
std::string BareMetal::getRuntimesDir() const {
SmallString<128> Dir(getDriver().ResourceDir);
llvm::sys::path::append(Dir, "lib", "baremetal");
- return Dir.str();
+ return std::string(Dir.str());
}
void BareMetal::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
diff --git a/clang/lib/Driver/ToolChains/CloudABI.cpp b/clang/lib/Driver/ToolChains/CloudABI.cpp
index cf1d0d5..77672a9 100644
--- a/clang/lib/Driver/ToolChains/CloudABI.cpp
+++ b/clang/lib/Driver/ToolChains/CloudABI.cpp
@@ -102,7 +102,7 @@ CloudABI::CloudABI(const Driver &D, const llvm::Triple &Triple,
: Generic_ELF(D, Triple, Args) {
SmallString<128> P(getDriver().Dir);
llvm::sys::path::append(P, "..", getTriple().str(), "lib");
- getFilePaths().push_back(P.str());
+ getFilePaths().push_back(std::string(P.str()));
}
void CloudABI::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index bdf72a02..9d3dcd6 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -278,7 +278,7 @@ std::string tools::getCPUName(const ArgList &Args, const llvm::Triple &T,
StringRef CPUName;
StringRef ABIName;
mips::getMipsCPUAndABI(Args, T, CPUName, ABIName);
- return CPUName;
+ return std::string(CPUName);
}
case llvm::Triple::nvptx:
@@ -334,7 +334,7 @@ std::string tools::getCPUName(const ArgList &Args, const llvm::Triple &T,
case llvm::Triple::wasm32:
case llvm::Triple::wasm64:
- return getWebAssemblyTargetCPU(Args);
+ return std::string(getWebAssemblyTargetCPU(Args));
}
}
@@ -1298,7 +1298,8 @@ void tools::AddHIPLinkerScript(const ToolChain &TC, Compilation &C,
// Create temporary linker script. Keep it if save-temps is enabled.
const char *LKS;
- std::string Name = llvm::sys::path::filename(Output.getFilename());
+ std::string Name =
+ std::string(llvm::sys::path::filename(Output.getFilename()));
if (C.getDriver().isSaveTempsEnabled()) {
LKS = C.getArgs().MakeArgString(Name + ".lk");
} else {
diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp
index 5aeaa97..438d5e1 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -94,8 +94,9 @@ CudaInstallationDetector::CudaInstallationDetector(
StringRef ptxasDir = llvm::sys::path::parent_path(ptxasAbsolutePath);
if (llvm::sys::path::filename(ptxasDir) == "bin")
- Candidates.emplace_back(llvm::sys::path::parent_path(ptxasDir),
- /*StrictChecking=*/true);
+ Candidates.emplace_back(
+ std::string(llvm::sys::path::parent_path(ptxasDir)),
+ /*StrictChecking=*/true);
}
}
@@ -182,27 +183,27 @@ CudaInstallationDetector::CudaInstallationDetector(
// capability. NVCC's choice of the libdevice library version is
// rather peculiar and depends on the CUDA version.
if (GpuArch == "compute_20") {
- LibDeviceMap["sm_20"] = FilePath;
- LibDeviceMap["sm_21"] = FilePath;
- LibDeviceMap["sm_32"] = FilePath;
+ LibDeviceMap["sm_20"] = std::string(FilePath);
+ LibDeviceMap["sm_21"] = std::string(FilePath);
+ LibDeviceMap["sm_32"] = std::string(FilePath);
} else if (GpuArch == "compute_30") {
- LibDeviceMap["sm_30"] = FilePath;
+ LibDeviceMap["sm_30"] = std::string(FilePath);
if (Version < CudaVersion::CUDA_80) {
- LibDeviceMap["sm_50"] = FilePath;
- LibDeviceMap["sm_52"] = FilePath;
- LibDeviceMap["sm_53"] = FilePath;
+ LibDeviceMap["sm_50"] = std::string(FilePath);
+ LibDeviceMap["sm_52"] = std::string(FilePath);
+ LibDeviceMap["sm_53"] = std::string(FilePath);
}
- LibDeviceMap["sm_60"] = FilePath;
- LibDeviceMap["sm_61"] = FilePath;
- LibDeviceMap["sm_62"] = FilePath;
+ LibDeviceMap["sm_60"] = std::string(FilePath);
+ LibDeviceMap["sm_61"] = std::string(FilePath);
+ LibDeviceMap["sm_62"] = std::string(FilePath);
} else if (GpuArch == "compute_35") {
- LibDeviceMap["sm_35"] = FilePath;
- LibDeviceMap["sm_37"] = FilePath;
+ LibDeviceMap["sm_35"] = std::string(FilePath);
+ LibDeviceMap["sm_37"] = std::string(FilePath);
} else if (GpuArch == "compute_50") {
if (Version >= CudaVersion::CUDA_80) {
- LibDeviceMap["sm_50"] = FilePath;
- LibDeviceMap["sm_52"] = FilePath;
- LibDeviceMap["sm_53"] = FilePath;
+ LibDeviceMap["sm_50"] = std::string(FilePath);
+ LibDeviceMap["sm_52"] = std::string(FilePath);
+ LibDeviceMap["sm_53"] = std::string(FilePath);
}
}
}
@@ -567,7 +568,7 @@ CudaToolChain::CudaToolChain(const Driver &D, const llvm::Triple &Triple,
: ToolChain(D, Triple, Args), HostTC(HostTC),
CudaInstallation(D, HostTC.getTriple(), Args), OK(OK) {
if (CudaInstallation.isValid())
- getProgramPaths().push_back(CudaInstallation.getBinPath());
+ getProgramPaths().push_back(std::string(CudaInstallation.getBinPath()));
// Lookup binaries into the driver directory, this is used to
// discover the clang-offload-bundler executable.
getProgramPaths().push_back(getDriver().Dir);
@@ -584,7 +585,7 @@ std::string CudaToolChain::getInputFilename(const InputInfo &Input) const {
// these particular file names.
SmallString<256> Filename(ToolChain::getInputFilename(Input));
llvm::sys::path::replace_extension(Filename, "cubin");
- return Filename.str();
+ return std::string(Filename.str());
}
void CudaToolChain::addClangTargetOptions(
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index 344a14f..5588f89 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1270,17 +1270,17 @@ static std::string getSystemOrSDKMacOSVersion(StringRef MacOSSDKVersion) {
unsigned Major, Minor, Micro;
llvm::Triple SystemTriple(llvm::sys::getProcessTriple());
if (!SystemTriple.isMacOSX())
- return MacOSSDKVersion;
+ return std::string(MacOSSDKVersion);
SystemTriple.getMacOSXVersion(Major, Minor, Micro);
VersionTuple SystemVersion(Major, Minor, Micro);
bool HadExtra;
if (!Driver::GetReleaseVersion(MacOSSDKVersion, Major, Minor, Micro,
HadExtra))
- return MacOSSDKVersion;
+ return std::string(MacOSSDKVersion);
VersionTuple SDKVersion(Major, Minor, Micro);
if (SDKVersion > SystemVersion)
return SystemVersion.getAsString();
- return MacOSSDKVersion;
+ return std::string(MacOSSDKVersion);
}
namespace {
@@ -1320,7 +1320,7 @@ struct DarwinPlatform {
void setOSVersion(StringRef S) {
assert(Kind == TargetArg && "Unexpected kind!");
- OSVersion = S;
+ OSVersion = std::string(S);
}
bool hasOSVersion() const { return HasOSVersion; }
@@ -1577,7 +1577,7 @@ inferDeploymentTargetFromSDK(DerivedArgList &Args,
size_t StartVer = SDK.find_first_of("0123456789");
size_t EndVer = SDK.find_last_of("0123456789");
if (StartVer != StringRef::npos && EndVer > StartVer)
- Version = SDK.slice(StartVer, EndVer + 1);
+ Version = std::string(SDK.slice(StartVer, EndVer + 1));
}
if (Version.empty())
return None;
diff --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index daaaa25..1e1f003 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -174,7 +174,7 @@ Fuchsia::Fuchsia(const Driver &D, const llvm::Triple &Triple,
if (!D.SysRoot.empty()) {
SmallString<128> P(D.SysRoot);
llvm::sys::path::append(P, "lib");
- getFilePaths().push_back(P.str());
+ getFilePaths().push_back(std::string(P.str()));
}
auto FilePaths = [&](const Multilib &M) -> std::vector<std::string> {
@@ -183,7 +183,7 @@ Fuchsia::Fuchsia(const Driver &D, const llvm::Triple &Triple,
if (auto CXXStdlibPath = getCXXStdlibPath()) {
SmallString<128> P(*CXXStdlibPath);
llvm::sys::path::append(P, M.gccSuffix());
- FP.push_back(P.str());
+ FP.push_back(std::string(P.str()));
}
}
return FP;
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index da197e4..79a7461 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1767,7 +1767,7 @@ Generic_GCC::GCCVersion Generic_GCC::GCCVersion::Parse(StringRef VersionText) {
StringRef MinorStr = Second.first;
if (Second.second.empty()) {
if (size_t EndNumber = MinorStr.find_first_not_of("0123456789")) {
- GoodVersion.PatchSuffix = MinorStr.substr(EndNumber);
+ GoodVersion.PatchSuffix = std::string(MinorStr.substr(EndNumber));
MinorStr = MinorStr.slice(0, EndNumber);
}
}
@@ -1793,7 +1793,7 @@ Generic_GCC::GCCVersion Generic_GCC::GCCVersion::Parse(StringRef VersionText) {
if (PatchText.slice(0, EndNumber).getAsInteger(10, GoodVersion.Patch) ||
GoodVersion.Patch < 0)
return BadVersion;
- GoodVersion.PatchSuffix = PatchText.substr(EndNumber);
+ GoodVersion.PatchSuffix = std::string(PatchText.substr(EndNumber));
}
}
@@ -1848,7 +1848,7 @@ void Generic_GCC::GCCInstallationDetector::init(
if (GCCToolchainDir.back() == '/')
GCCToolchainDir = GCCToolchainDir.drop_back(); // remove the /
- Prefixes.push_back(GCCToolchainDir);
+ Prefixes.push_back(std::string(GCCToolchainDir));
} else {
// If we have a SysRoot, try that first.
if (!D.SysRoot.empty()) {
@@ -2460,7 +2460,7 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
StringRef VersionText = llvm::sys::path::filename(LI->path());
GCCVersion CandidateVersion = GCCVersion::Parse(VersionText);
if (CandidateVersion.Major != -1) // Filter obviously bad entries.
- if (!CandidateGCCInstallPaths.insert(LI->path()).second)
+ if (!CandidateGCCInstallPaths.insert(std::string(LI->path())).second)
continue; // Saw this path before; no need to look at it again.
if (CandidateVersion.isOlderThan(4, 1, 1))
continue;
@@ -2696,7 +2696,7 @@ static std::string DetectLibcxxIncludePath(llvm::vfs::FileSystem &vfs,
!VersionText.slice(1, StringRef::npos).getAsInteger(10, Version)) {
if (Version > MaxVersion) {
MaxVersion = Version;
- MaxVersionString = VersionText;
+ MaxVersionString = std::string(VersionText);
}
}
}
diff --git a/clang/lib/Driver/ToolChains/HIP.cpp b/clang/lib/Driver/ToolChains/HIP.cpp
index 07af734..f761659 100644
--- a/clang/lib/Driver/ToolChains/HIP.cpp
+++ b/clang/lib/Driver/ToolChains/HIP.cpp
@@ -220,8 +220,8 @@ void AMDGCN::constructHIPFatbinCommand(Compilation &C, const JobAction &JA,
BundlerArgs.push_back(Args.MakeArgString(BundlerTargetArg));
BundlerArgs.push_back(Args.MakeArgString(BundlerInputArg));
- auto BundlerOutputArg =
- Args.MakeArgString(std::string("-outputs=").append(OutputFileName));
+ auto BundlerOutputArg = Args.MakeArgString(
+ std::string("-outputs=").append(std::string(OutputFileName)));
BundlerArgs.push_back(BundlerOutputArg);
const char *Bundler = Args.MakeArgString(
@@ -356,10 +356,11 @@ void HIPToolChain::addClangTargetOptions(
WaveFrontSizeBC = "oclc_wavefrontsize64_off.amdgcn.bc";
BCLibs.append({"hip.amdgcn.bc", "ocml.amdgcn.bc", "ockl.amdgcn.bc",
- "oclc_finite_only_off.amdgcn.bc", FlushDenormalControlBC,
+ "oclc_finite_only_off.amdgcn.bc",
+ std::string(FlushDenormalControlBC),
"oclc_correctly_rounded_sqrt_on.amdgcn.bc",
"oclc_unsafe_math_off.amdgcn.bc", ISAVerBC,
- WaveFrontSizeBC});
+ std::string(WaveFrontSizeBC)});
}
for (auto Lib : BCLibs)
addBCLib(getDriver(), DriverArgs, CC1Args, LibraryPaths, Lib);
diff --git a/clang/lib/Driver/ToolChains/Hurd.cpp b/clang/lib/Driver/ToolChains/Hurd.cpp
index 72166ca..51d9c28 100644
--- a/clang/lib/Driver/ToolChains/Hurd.cpp
+++ b/clang/lib/Driver/ToolChains/Hurd.cpp
@@ -67,7 +67,7 @@ Hurd::Hurd(const Driver &D, const llvm::Triple &Triple,
std::string SysRoot = computeSysRoot();
path_list &Paths = getFilePaths();
- const std::string OSLibDir = getOSLibDir(Triple, Args);
+ const std::string OSLibDir = std::string(getOSLibDir(Triple, Args));
const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
#ifdef ENABLE_LINKER_BUILD_ID
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index bff1ab1..0006f11 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -314,13 +314,14 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
// to the link paths.
path_list &Paths = getFilePaths();
- const std::string OSLibDir = getOSLibDir(Triple, Args);
+ const std::string OSLibDir = std::string(getOSLibDir(Triple, Args));
const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
// Add the multilib suffixed paths where they are available.
if (GCCInstallation.isValid()) {
const llvm::Triple &GCCTriple = GCCInstallation.getTriple();
- const std::string &LibPath = GCCInstallation.getParentLibPath();
+ const std::string &LibPath =
+ std::string(GCCInstallation.getParentLibPath());
// Add toolchain / multilib specific file paths.
addMultilibsFilePaths(D, Multilibs, SelectedMultilib,
@@ -429,7 +430,8 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
// See comments above on the multilib variant for details of why this is
// included even from outside the sysroot.
- const std::string &LibPath = GCCInstallation.getParentLibPath();
+ const std::string &LibPath =
+ std::string(GCCInstallation.getParentLibPath());
const llvm::Triple &GCCTriple = GCCInstallation.getTriple();
const Multilib &Multilib = GCCInstallation.getMultilib();
addPathIfExists(D, LibPath + "/../" + GCCTriple.str() + "/lib" +
diff --git a/clang/lib/Driver/ToolChains/MSP430.cpp b/clang/lib/Driver/ToolChains/MSP430.cpp
index bc77f01..1c50765 100644
--- a/clang/lib/Driver/ToolChains/MSP430.cpp
+++ b/clang/lib/Driver/ToolChains/MSP430.cpp
@@ -143,7 +143,7 @@ std::string MSP430ToolChain::computeSysRoot() const {
else
llvm::sys::path::append(Dir, getDriver().Dir, "..", getTriple().str());
- return Dir.str();
+ return std::string(Dir.str());
}
void MSP430ToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
diff --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp
index 4e143f6..83e37be8 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -128,13 +128,13 @@ static bool findVCToolChainViaEnvironment(std::string &Path,
llvm::StringRef ParentPath = llvm::sys::path::parent_path(TestPath);
llvm::StringRef ParentFilename = llvm::sys::path::filename(ParentPath);
if (ParentFilename == "VC") {
- Path = ParentPath;
+ Path = std::string(ParentPath);
VSLayout = MSVCToolChain::ToolsetLayout::OlderVS;
return true;
}
if (ParentFilename == "x86ret" || ParentFilename == "x86chk"
|| ParentFilename == "amd64ret" || ParentFilename == "amd64chk") {
- Path = ParentPath;
+ Path = std::string(ParentPath);
VSLayout = MSVCToolChain::ToolsetLayout::DevDivInternal;
return true;
}
@@ -163,7 +163,7 @@ static bool findVCToolChainViaEnvironment(std::string &Path,
for (int i = 0; i < 3; ++i)
ToolChainPath = llvm::sys::path::parent_path(ToolChainPath);
- Path = ToolChainPath;
+ Path = std::string(ToolChainPath);
VSLayout = MSVCToolChain::ToolsetLayout::VS2017OrNewer;
return true;
}
@@ -282,7 +282,7 @@ static bool findVCToolChainViaRegistry(std::string &Path,
VSInstallPath.c_str(), VSInstallPath.find(R"(\Common7\IDE)")));
llvm::sys::path::append(VCPath, "VC");
- Path = VCPath.str();
+ Path = std::string(VCPath.str());
VSLayout = MSVCToolChain::ToolsetLayout::OlderVS;
return true;
}
@@ -300,7 +300,8 @@ static std::string FindVisualStudioExecutable(const ToolChain &TC,
SmallString<128> FilePath(MSVC.getSubDirectoryPath(
toolchains::MSVCToolChain::SubDirectoryType::Bin));
llvm::sys::path::append(FilePath, Exe);
- return llvm::sys::fs::can_execute(FilePath) ? FilePath.str() : Exe;
+ return std::string(llvm::sys::fs::can_execute(FilePath) ? FilePath.str()
+ : Exe);
}
void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA,
@@ -892,7 +893,7 @@ MSVCToolChain::getSubDirectoryPath(SubDirectoryType Type,
llvm::sys::path::append(Path, "lib", SubdirName);
break;
}
- return Path.str();
+ return std::string(Path.str());
}
#ifdef _WIN32
@@ -1046,7 +1047,7 @@ static bool getWindows10SDKVersionFromPath(const std::string &SDKPath,
if (!CandidateName.startswith("10."))
continue;
if (CandidateName > SDKVersion)
- SDKVersion = CandidateName;
+ SDKVersion = std::string(CandidateName);
}
return !SDKVersion.empty();
@@ -1129,7 +1130,7 @@ bool MSVCToolChain::getWindowsSDKLibraryPath(std::string &path) const {
}
}
- path = libPath.str();
+ path = std::string(libPath.str());
return true;
}
@@ -1168,7 +1169,7 @@ bool MSVCToolChain::getUniversalCRTLibraryPath(std::string &Path) const {
llvm::SmallString<128> LibPath(UniversalCRTSdkPath);
llvm::sys::path::append(LibPath, "Lib", UCRTVersion, "ucrt", ArchName);
- Path = LibPath.str();
+ Path = std::string(LibPath.str());
return true;
}
@@ -1475,7 +1476,7 @@ static void TranslateDArg(Arg *A, llvm::opt::DerivedArgList &DAL,
return;
}
- std::string NewVal = Val;
+ std::string NewVal = std::string(Val);
NewVal[Hash] = '=';
DAL.AddJoinedArg(A, Opts.getOption(options::OPT_D), NewVal);
}
diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp
index 8f24384..fac2892 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -323,7 +323,7 @@ static bool findGccVersion(StringRef LibDir, std::string &GccLibDir,
continue;
if (CandidateVersion <= Version)
continue;
- Ver = VersionText;
+ Ver = std::string(VersionText);
GccLibDir = LI->path();
}
return Ver.size();
@@ -335,7 +335,7 @@ void toolchains::MinGW::findGccLibDir() {
Archs[0] += "-w64-mingw32";
Archs.emplace_back("mingw32");
if (Arch.empty())
- Arch = Archs[0].str();
+ Arch = std::string(Archs[0].str());
// lib: Arch Linux, Ubuntu, Windows
// lib64: openSUSE Linux
for (StringRef CandidateLib : {"lib", "lib64"}) {
@@ -343,7 +343,7 @@ void toolchains::MinGW::findGccLibDir() {
llvm::SmallString<1024> LibDir(Base);
llvm::sys::path::append(LibDir, CandidateLib, "gcc", CandidateArch);
if (findGccVersion(LibDir, GccLibDir, Ver)) {
- Arch = CandidateArch;
+ Arch = std::string(CandidateArch);
return;
}
}
@@ -372,7 +372,7 @@ llvm::ErrorOr<std::string> toolchains::MinGW::findClangRelativeSysroot() {
StringRef Sep = llvm::sys::path::get_separator();
for (StringRef CandidateSubdir : Subdirs) {
if (llvm::sys::fs::is_directory(ClangRoot + Sep + CandidateSubdir)) {
- Arch = CandidateSubdir;
+ Arch = std::string(CandidateSubdir);
return (ClangRoot + Sep + CandidateSubdir).str();
}
}
@@ -389,12 +389,13 @@ toolchains::MinGW::MinGW(const Driver &D, const llvm::Triple &Triple,
// Look for <clang-bin>/../<triplet>; if found, use <clang-bin>/.. as the
// base as it could still be a base for a gcc setup with libgcc.
else if (llvm::ErrorOr<std::string> TargetSubdir = findClangRelativeSysroot())
- Base = llvm::sys::path::parent_path(TargetSubdir.get());
+ Base = std::string(llvm::sys::path::parent_path(TargetSubdir.get()));
else if (llvm::ErrorOr<std::string> GPPName = findGcc())
- Base = llvm::sys::path::parent_path(
- llvm::sys::path::parent_path(GPPName.get()));
+ Base = std::string(llvm::sys::path::parent_path(
+ llvm::sys::path::parent_path(GPPName.get())));
else
- Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
+ Base = std::string(
+ llvm::sys::path::parent_path(getDriver().getInstalledDir()));
Base += llvm::sys::path::get_separator();
findGccLibDir();
diff --git a/clang/lib/Driver/ToolChains/MipsLinux.cpp b/clang/lib/Driver/ToolChains/MipsLinux.cpp
index cfda7f4..41b7b83 100644
--- a/clang/lib/Driver/ToolChains/MipsLinux.cpp
+++ b/clang/lib/Driver/ToolChains/MipsLinux.cpp
@@ -136,5 +136,5 @@ std::string MipsLLVMToolChain::getCompilerRT(const ArgList &Args,
}
llvm::sys::path::append(
Path, Twine("libclang_rt." + Component + "-" + "mips" + Suffix));
- return Path.str();
+ return std::string(Path.str());
}
diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index 4e88402..93d86e6 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -382,7 +382,7 @@ toolchains::PS4CPU::PS4CPU(const Driver &D, const llvm::Triple &Triple,
if (!llvm::sys::fs::exists(PrefixDir))
getDriver().Diag(clang::diag::warn_missing_sysroot) << PrefixDir;
} else
- PrefixDir = PS4SDKDir.str();
+ PrefixDir = std::string(PS4SDKDir.str());
SmallString<512> PS4SDKIncludeDir(PrefixDir);
llvm::sys::path::append(PS4SDKIncludeDir, "target/include");
@@ -407,7 +407,7 @@ toolchains::PS4CPU::PS4CPU(const Driver &D, const llvm::Triple &Triple,
<< "PS4 system libraries" << PS4SDKLibDir;
return;
}
- getFilePaths().push_back(PS4SDKLibDir.str());
+ getFilePaths().push_back(std::string(PS4SDKLibDir.str()));
}
Tool *toolchains::PS4CPU::buildAssembler() const {
diff --git a/clang/lib/Driver/ToolChains/RISCVToolchain.cpp b/clang/lib/Driver/ToolChains/RISCVToolchain.cpp
index ddc329e..24c2b37 100644
--- a/clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ b/clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -119,7 +119,7 @@ std::string RISCVToolChain::computeSysRoot() const {
if (!llvm::sys::fs::exists(SysRootDir))
return std::string();
- return SysRootDir.str();
+ return std::string(SysRootDir.str());
}
void RISCV::Linker::ConstructJob(Compilation &C, const JobAction &JA,
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 907f86b..adf8eb0 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -40,7 +40,7 @@ std::string wasm::Linker::getLinkerPath(const ArgList &Args) const {
if (!UseLinker.empty()) {
if (llvm::sys::path::is_absolute(UseLinker) &&
llvm::sys::fs::can_execute(UseLinker))
- return UseLinker;
+ return std::string(UseLinker);
// Accept 'lld', and 'ld' as aliases for the default linker
if (UseLinker != "lld" && UseLinker != "ld")
diff --git a/clang/lib/Driver/XRayArgs.cpp b/clang/lib/Driver/XRayArgs.cpp
index e62b1f1..66c3959 100644
--- a/clang/lib/Driver/XRayArgs.cpp
+++ b/clang/lib/Driver/XRayArgs.cpp
@@ -176,7 +176,7 @@ XRayArgs::XRayArgs(const ToolChain &TC, const ArgList &Args) {
else if (M == "all")
llvm::copy(XRaySupportedModes, std::back_inserter(Modes));
else
- Modes.push_back(M);
+ Modes.push_back(std::string(M));
}
// Then we want to sort and unique the modes we've collected.
diff --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp
index cd0eb0b..1d2fefe 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -587,7 +587,7 @@ void BreakableBlockComment::insertBreak(unsigned LineIndex, unsigned TailOffset,
Text.data() - tokenAt(LineIndex).TokenText.data() + Split.first;
unsigned CharsToRemove = Split.second;
assert(LocalIndentAtLineBreak >= Prefix.size());
- std::string PrefixWithTrailingIndent = Prefix;
+ std::string PrefixWithTrailingIndent = std::string(Prefix);
for (unsigned I = 0; I < ContentIndent; ++I)
PrefixWithTrailingIndent += " ";
Whitespaces.replaceWhitespaceInToken(
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 2ff6e5e..ec2de35 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1513,8 +1513,8 @@ unsigned ContinuationIndenter::reformatRawStringLiteral(
unsigned OldSuffixSize = 2 + OldDelimiter.size();
// We create a virtual text environment which expects a null-terminated
// string, so we cannot use StringRef.
- std::string RawText =
- Current.TokenText.substr(OldPrefixSize).drop_back(OldSuffixSize);
+ std::string RawText = std::string(
+ Current.TokenText.substr(OldPrefixSize).drop_back(OldSuffixSize));
if (NewDelimiter != OldDelimiter) {
// Don't update to the canonical delimiter 'deli' if ')deli"' occurs in the
// raw string.
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index bc95517..dd131a9 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1977,8 +1977,8 @@ static void sortCppIncludes(const FormatStyle &Style,
// If the #includes are out of order, we generate a single replacement fixing
// the entire range of blocks. Otherwise, no replacement is generated.
- if (replaceCRLF(result) ==
- replaceCRLF(Code.substr(IncludesBeginOffset, IncludesBlockSize)))
+ if (replaceCRLF(result) == replaceCRLF(std::string(Code.substr(
+ IncludesBeginOffset, IncludesBlockSize))))
return;
auto Err = Replaces.add(tooling::Replacement(
@@ -2146,8 +2146,8 @@ static void sortJavaImports(const FormatStyle &Style,
// If the imports are out of order, we generate a single replacement fixing
// the entire block. Otherwise, no replacement is generated.
- if (replaceCRLF(result) ==
- replaceCRLF(Code.substr(Imports.front().Offset, ImportsBlockSize)))
+ if (replaceCRLF(result) == replaceCRLF(std::string(Code.substr(
+ Imports.front().Offset, ImportsBlockSize))))
return;
auto Err = Replaces.add(tooling::Replacement(FileName, Imports.front().Offset,
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index b326495..7920aa2 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -784,7 +784,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
UserFilesAreVolatile);
AST->ModuleCache = new InMemoryModuleCache;
AST->HSOpts = std::make_shared<HeaderSearchOptions>();
- AST->HSOpts->ModuleFormat = PCHContainerRdr.getFormat();
+ AST->HSOpts->ModuleFormat = std::string(PCHContainerRdr.getFormat());
AST->HeaderInfo.reset(new HeaderSearch(AST->HSOpts,
AST->getSourceManager(),
AST->getDiagnostics(),
@@ -847,7 +847,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
return nullptr;
}
- AST->OriginalSourceFile = AST->Reader->getOriginalSourceFile();
+ AST->OriginalSourceFile = std::string(AST->Reader->getOriginalSourceFile());
PP.setCounterValue(Counter);
@@ -1131,7 +1131,8 @@ bool ASTUnit::Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
CICleanup(Clang.get());
Clang->setInvocation(CCInvocation);
- OriginalSourceFile = Clang->getFrontendOpts().Inputs[0].getFile();
+ OriginalSourceFile =
+ std::string(Clang->getFrontendOpts().Inputs[0].getFile());
// Set up diagnostics, capturing any diagnostics that would
// otherwise be dropped.
@@ -1260,13 +1261,13 @@ makeStandaloneDiagnostic(const LangOptions &LangOpts,
ASTUnit::StandaloneDiagnostic OutDiag;
OutDiag.ID = InDiag.getID();
OutDiag.Level = InDiag.getLevel();
- OutDiag.Message = InDiag.getMessage();
+ OutDiag.Message = std::string(InDiag.getMessage());
OutDiag.LocOffset = 0;
if (InDiag.getLocation().isInvalid())
return OutDiag;
const SourceManager &SM = InDiag.getLocation().getManager();
SourceLocation FileLoc = SM.getFileLoc(InDiag.getLocation());
- OutDiag.Filename = SM.getFilename(FileLoc);
+ OutDiag.Filename = std::string(SM.getFilename(FileLoc));
if (OutDiag.Filename.empty())
return OutDiag;
OutDiag.LocOffset = SM.getFileOffset(FileLoc);
@@ -1532,7 +1533,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(
if (!ResourceFilesPath.empty()) {
// Override the resources path.
- CI->getHeaderSearchOpts().ResourceDir = ResourceFilesPath;
+ CI->getHeaderSearchOpts().ResourceDir = std::string(ResourceFilesPath);
}
AST->OnlyLocalDecls = OnlyLocalDecls;
AST->CaptureDiagnostics = CaptureDiagnostics;
@@ -1564,7 +1565,8 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(
CICleanup(Clang.get());
Clang->setInvocation(std::move(CI));
- AST->OriginalSourceFile = Clang->getFrontendOpts().Inputs[0].getFile();
+ AST->OriginalSourceFile =
+ std::string(Clang->getFrontendOpts().Inputs[0].getFile());
// Set up diagnostics, capturing any diagnostics that would
// otherwise be dropped.
@@ -1767,13 +1769,14 @@ ASTUnit *ASTUnit::LoadFromCommandLine(
PPOpts.RetainExcludedConditionalBlocks = RetainExcludedConditionalBlocks;
// Override the resources path.
- CI->getHeaderSearchOpts().ResourceDir = ResourceFilesPath;
+ CI->getHeaderSearchOpts().ResourceDir = std::string(ResourceFilesPath);
CI->getFrontendOpts().SkipFunctionBodies =
SkipFunctionBodies == SkipFunctionBodiesScope::PreambleAndMainFile;
if (ModuleFormat)
- CI->getHeaderSearchOpts().ModuleFormat = ModuleFormat.getValue();
+ CI->getHeaderSearchOpts().ModuleFormat =
+ std::string(ModuleFormat.getValue());
// Create the AST unit.
std::unique_ptr<ASTUnit> AST;
@@ -2165,7 +2168,7 @@ void ASTUnit::CodeComplete(
assert(IncludeBriefComments == this->IncludeBriefCommentsInCodeCompletion);
- FrontendOpts.CodeCompletionAt.FileName = File;
+ FrontendOpts.CodeCompletionAt.FileName = std::string(File);
FrontendOpts.CodeCompletionAt.Line = Line;
FrontendOpts.CodeCompletionAt.Column = Column;
@@ -2185,7 +2188,8 @@ void ASTUnit::CodeComplete(
auto &Inv = *CCInvocation;
Clang->setInvocation(std::move(CCInvocation));
- OriginalSourceFile = Clang->getFrontendOpts().Inputs[0].getFile();
+ OriginalSourceFile =
+ std::string(Clang->getFrontendOpts().Inputs[0].getFile());
// Set up diagnostics, capturing any diagnostics produced.
Clang->setDiagnostics(&Diag);
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 688f21d..0715232 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -474,7 +474,7 @@ std::string CompilerInstance::getSpecificModuleCachePath() {
if (!SpecificModuleCache.empty() && !getHeaderSearchOpts().DisableModuleHash)
llvm::sys::path::append(SpecificModuleCache,
getInvocation().getModuleHash());
- return SpecificModuleCache.str();
+ return std::string(SpecificModuleCache.str());
}
// ASTContext
@@ -713,13 +713,13 @@ std::unique_ptr<llvm::raw_pwrite_stream> CompilerInstance::createOutputFile(
std::string OutFile, TempFile;
if (!OutputPath.empty()) {
- OutFile = OutputPath;
+ OutFile = std::string(OutputPath);
} else if (InFile == "-") {
OutFile = "-";
} else if (!Extension.empty()) {
SmallString<128> Path(InFile);
llvm::sys::path::replace_extension(Path, Extension);
- OutFile = Path.str();
+ OutFile = std::string(Path.str());
} else {
OutFile = "-";
}
@@ -774,7 +774,7 @@ std::unique_ptr<llvm::raw_pwrite_stream> CompilerInstance::createOutputFile(
if (!EC) {
OS.reset(new llvm::raw_fd_ostream(fd, /*shouldClose=*/true));
- OSFile = TempFile = TempPath.str();
+ OSFile = TempFile = std::string(TempPath.str());
}
// If we failed to create the temporary, fallback to writing to the file
// directly. This handles the corner case where we cannot write to the
@@ -1073,7 +1073,7 @@ compileModuleImpl(CompilerInstance &ImportingInstance, SourceLocation ImportLoc,
ImportingInstance.getInvocation().getLangOpts()->ModuleName;
// Note the name of the module we're building.
- Invocation->getLangOpts()->CurrentModule = ModuleName;
+ Invocation->getLangOpts()->CurrentModule = std::string(ModuleName);
// Make sure that the failed-module structure has been allocated in
// the importing instance, and propagate the pointer to the newly-created
@@ -1093,7 +1093,7 @@ compileModuleImpl(CompilerInstance &ImportingInstance, SourceLocation ImportLoc,
FrontendOpts.DisableFree = false;
FrontendOpts.GenerateGlobalModuleIndex = false;
FrontendOpts.BuildingImplicitModule = true;
- FrontendOpts.OriginalModuleMap = OriginalModuleMapFile;
+ FrontendOpts.OriginalModuleMap = std::string(OriginalModuleMapFile);
// Force implicitly-built modules to hash the content of the module file.
HSOpts.ModulesHashContent = true;
FrontendOpts.Inputs = {Input};
@@ -1638,7 +1638,7 @@ selectModuleSource(Module *M, StringRef ModuleName, std::string &ModuleFilename,
// Check to see if the module has been built as part of this compilation
// via a module build pragma.
- auto BuiltModuleIt = BuiltModules.find(ModuleName);
+ auto BuiltModuleIt = BuiltModules.find(std::string(ModuleName));
if (BuiltModuleIt != BuiltModules.end()) {
ModuleFilename = BuiltModuleIt->second;
return MS_ModuleBuildPragma;
@@ -2077,7 +2077,7 @@ void CompilerInstance::createModuleFromSource(SourceLocation ImportLoc,
// Build the module, inheriting any modules that we've built locally.
if (compileModuleImpl(*this, ImportLoc, ModuleName, Input, StringRef(),
ModuleFileName, PreBuildStep, PostBuildStep)) {
- BuiltModules[ModuleName] = ModuleFileName.str();
+ BuiltModules[std::string(ModuleName)] = std::string(ModuleFileName.str());
llvm::sys::RemoveFileOnSignal(ModuleFileName);
}
}
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index b3733a2..194cbd3 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -171,10 +171,12 @@ static void addDiagnosticArgs(ArgList &Args, OptSpecifier Group,
if (A->getOption().getKind() == Option::FlagClass) {
// The argument is a pure flag (such as OPT_Wall or OPT_Wdeprecated). Add
// its name (minus the "W" or "R" at the beginning) to the warning list.
- Diagnostics.push_back(A->getOption().getName().drop_front(1));
+ Diagnostics.push_back(
+ std::string(A->getOption().getName().drop_front(1)));
} else if (A->getOption().matches(GroupWithValue)) {
// This is -Wfoo= or -Rfoo=, where foo is the name of the diagnostic group.
- Diagnostics.push_back(A->getOption().getName().drop_front(1).rtrim("=-"));
+ Diagnostics.push_back(
+ std::string(A->getOption().getName().drop_front(1).rtrim("=-")));
} else {
// Otherwise, add its value (for OPT_W_Joined and similar).
for (const auto *Arg : A->getValues())
@@ -308,14 +310,16 @@ static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
Opts.visualizeExplodedGraphWithGraphViz =
Args.hasArg(OPT_analyzer_viz_egraph_graphviz);
- Opts.DumpExplodedGraphTo = Args.getLastArgValue(OPT_analyzer_dump_egraph);
+ Opts.DumpExplodedGraphTo =
+ std::string(Args.getLastArgValue(OPT_analyzer_dump_egraph));
Opts.NoRetryExhausted = Args.hasArg(OPT_analyzer_disable_retry_exhausted);
Opts.AnalyzerWerror = Args.hasArg(OPT_analyzer_werror);
Opts.AnalyzeAll = Args.hasArg(OPT_analyzer_opt_analyze_headers);
Opts.AnalyzerDisplayProgress = Args.hasArg(OPT_analyzer_display_progress);
Opts.AnalyzeNestedBlocks =
Args.hasArg(OPT_analyzer_opt_analyze_nested_blocks);
- Opts.AnalyzeSpecificFunction = Args.getLastArgValue(OPT_analyze_function);
+ Opts.AnalyzeSpecificFunction =
+ std::string(Args.getLastArgValue(OPT_analyze_function));
Opts.UnoptimizedCFG = Args.hasArg(OPT_analysis_UnoptimizedCFG);
Opts.TrimGraph = Args.hasArg(OPT_trim_egraph);
Opts.maxBlockVisitOnPath =
@@ -373,7 +377,7 @@ static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
}
A->claim();
- Opts.Config[key] = val;
+ Opts.Config[key] = std::string(val);
}
}
@@ -395,7 +399,7 @@ static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
static StringRef getStringOption(AnalyzerOptions::ConfigTable &Config,
StringRef OptionName, StringRef DefaultVal) {
- return Config.insert({OptionName, DefaultVal}).first->second;
+ return Config.insert({OptionName, std::string(DefaultVal)}).first->second;
}
static void initOption(AnalyzerOptions::ConfigTable &Config,
@@ -763,8 +767,9 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.VirtualFunctionElimination =
Args.hasArg(OPT_fvirtual_function_elimination);
Opts.LTOVisibilityPublicStd = Args.hasArg(OPT_flto_visibility_public_std);
- Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file);
- Opts.SplitDwarfOutput = Args.getLastArgValue(OPT_split_dwarf_output);
+ Opts.SplitDwarfFile = std::string(Args.getLastArgValue(OPT_split_dwarf_file));
+ Opts.SplitDwarfOutput =
+ std::string(Args.getLastArgValue(OPT_split_dwarf_output));
Opts.SplitDwarfInlining = !Args.hasArg(OPT_fno_split_dwarf_inlining);
Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
Opts.DebugExplicitImport = Args.hasArg(OPT_dwarf_explicit_import);
@@ -806,8 +811,10 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.FineGrainedBitfieldAccesses =
Args.hasFlag(OPT_ffine_grained_bitfield_accesses,
OPT_fno_fine_grained_bitfield_accesses, false);
- Opts.DwarfDebugFlags = Args.getLastArgValue(OPT_dwarf_debug_flags);
- Opts.RecordCommandLine = Args.getLastArgValue(OPT_record_command_line);
+ Opts.DwarfDebugFlags =
+ std::string(Args.getLastArgValue(OPT_dwarf_debug_flags));
+ Opts.RecordCommandLine =
+ std::string(Args.getLastArgValue(OPT_record_command_line));
Opts.MergeAllConstants = Args.hasArg(OPT_fmerge_all_constants);
Opts.NoCommon = Args.hasArg(OPT_fno_common);
Opts.NoInlineLineTables = Args.hasArg(OPT_gno_inline_line_tables);
@@ -824,7 +831,8 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
Opts.Autolink = !Args.hasArg(OPT_fno_autolink);
- Opts.SampleProfileFile = Args.getLastArgValue(OPT_fprofile_sample_use_EQ);
+ Opts.SampleProfileFile =
+ std::string(Args.getLastArgValue(OPT_fprofile_sample_use_EQ));
Opts.DebugInfoForProfiling = Args.hasFlag(
OPT_fdebug_info_for_profiling, OPT_fno_debug_info_for_profiling, false);
Opts.DebugNameTable = static_cast<unsigned>(
@@ -837,13 +845,13 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
setPGOInstrumentor(Opts, Args, Diags);
Opts.InstrProfileOutput =
- Args.getLastArgValue(OPT_fprofile_instrument_path_EQ);
+ std::string(Args.getLastArgValue(OPT_fprofile_instrument_path_EQ));
Opts.ProfileInstrumentUsePath =
- Args.getLastArgValue(OPT_fprofile_instrument_use_path_EQ);
+ std::string(Args.getLastArgValue(OPT_fprofile_instrument_use_path_EQ));
if (!Opts.ProfileInstrumentUsePath.empty())
setPGOUseInstrumentor(Opts, Opts.ProfileInstrumentUsePath);
Opts.ProfileRemappingFile =
- Args.getLastArgValue(OPT_fprofile_remapping_file_EQ);
+ std::string(Args.getLastArgValue(OPT_fprofile_remapping_file_EQ));
if (!Opts.ProfileRemappingFile.empty() && !Opts.ExperimentalNewPassManager) {
Diags.Report(diag::err_drv_argument_only_allowed_with)
<< Args.getLastArg(OPT_fprofile_remapping_file_EQ)->getAsString(Args)
@@ -862,7 +870,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Args.hasArg(OPT_fregister_global_dtors_with_atexit);
Opts.CXXCtorDtorAliases = Args.hasArg(OPT_mconstructor_aliases);
Opts.CodeModel = TargetOpts.CodeModel;
- Opts.DebugPass = Args.getLastArgValue(OPT_mdebug_pass);
+ Opts.DebugPass = std::string(Args.getLastArgValue(OPT_mdebug_pass));
// Handle -mframe-pointer option.
if (Arg *A = Args.getLastArg(OPT_mframe_pointer_EQ)) {
@@ -894,11 +902,12 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
Opts.NoEscapingBlockTailCalls =
Args.hasArg(OPT_fno_escaping_block_tail_calls);
- Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
+ Opts.FloatABI = std::string(Args.getLastArgValue(OPT_mfloat_abi));
Opts.LessPreciseFPMAD = Args.hasArg(OPT_cl_mad_enable) ||
Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
Args.hasArg(OPT_cl_fast_relaxed_math);
- Opts.LimitFloatPrecision = Args.getLastArgValue(OPT_mlimit_float_precision);
+ Opts.LimitFloatPrecision =
+ std::string(Args.getLastArgValue(OPT_mlimit_float_precision));
Opts.NoInfsFPMath = (Args.hasArg(OPT_menable_no_infinities) ||
Args.hasArg(OPT_cl_finite_math_only) ||
Args.hasArg(OPT_cl_fast_relaxed_math));
@@ -945,12 +954,13 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Args.hasArg(OPT_cl_fast_relaxed_math);
Opts.UnwindTables = Args.hasArg(OPT_munwind_tables);
Opts.RelocationModel = getRelocModel(Args, Diags);
- Opts.ThreadModel = Args.getLastArgValue(OPT_mthread_model, "posix");
+ Opts.ThreadModel =
+ std::string(Args.getLastArgValue(OPT_mthread_model, "posix"));
if (Opts.ThreadModel != "posix" && Opts.ThreadModel != "single")
Diags.Report(diag::err_drv_invalid_value)
<< Args.getLastArg(OPT_mthread_model)->getAsString(Args)
<< Opts.ThreadModel;
- Opts.TrapFuncName = Args.getLastArgValue(OPT_ftrap_function_EQ);
+ Opts.TrapFuncName = std::string(Args.getLastArgValue(OPT_ftrap_function_EQ));
Opts.UseInitArray = !Args.hasArg(OPT_fno_use_init_array);
Opts.FunctionSections = Args.hasArg(OPT_ffunction_sections);
@@ -981,7 +991,8 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
if (IK.getLanguage() != Language::LLVM_IR)
Diags.Report(diag::err_drv_argument_only_allowed_with)
<< A->getAsString(Args) << "-x ir";
- Opts.ThinLTOIndexFile = Args.getLastArgValue(OPT_fthinlto_index_EQ);
+ Opts.ThinLTOIndexFile =
+ std::string(Args.getLastArgValue(OPT_fthinlto_index_EQ));
}
if (Arg *A = Args.getLastArg(OPT_save_temps_EQ))
Opts.SaveTempsFilePrefix =
@@ -989,16 +1000,18 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
.Case("obj", FrontendOpts.OutputFile)
.Default(llvm::sys::path::filename(FrontendOpts.OutputFile).str());
- Opts.ThinLinkBitcodeFile = Args.getLastArgValue(OPT_fthin_link_bitcode_EQ);
+ Opts.ThinLinkBitcodeFile =
+ std::string(Args.getLastArgValue(OPT_fthin_link_bitcode_EQ));
Opts.MSVolatile = Args.hasArg(OPT_fms_volatile);
Opts.VectorizeLoop = Args.hasArg(OPT_vectorize_loops);
Opts.VectorizeSLP = Args.hasArg(OPT_vectorize_slp);
- Opts.PreferVectorWidth = Args.getLastArgValue(OPT_mprefer_vector_width_EQ);
+ Opts.PreferVectorWidth =
+ std::string(Args.getLastArgValue(OPT_mprefer_vector_width_EQ));
- Opts.MainFileName = Args.getLastArgValue(OPT_main_file_name);
+ Opts.MainFileName = std::string(Args.getLastArgValue(OPT_main_file_name));
Opts.VerifyModule = !Args.hasArg(OPT_disable_llvm_verifier);
Opts.ControlFlowGuardNoChecks = Args.hasArg(OPT_cfguard_no_checks);
@@ -1008,15 +1021,17 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.EmitGcovArcs = Args.hasArg(OPT_femit_coverage_data);
Opts.EmitGcovNotes = Args.hasArg(OPT_femit_coverage_notes);
if (Opts.EmitGcovArcs || Opts.EmitGcovNotes) {
- Opts.CoverageDataFile = Args.getLastArgValue(OPT_coverage_data_file);
- Opts.CoverageNotesFile = Args.getLastArgValue(OPT_coverage_notes_file);
+ Opts.CoverageDataFile =
+ std::string(Args.getLastArgValue(OPT_coverage_data_file));
+ Opts.CoverageNotesFile =
+ std::string(Args.getLastArgValue(OPT_coverage_notes_file));
Opts.CoverageExtraChecksum = Args.hasArg(OPT_coverage_cfg_checksum);
Opts.CoverageNoFunctionNamesInData =
Args.hasArg(OPT_coverage_no_function_names_in_data);
Opts.ProfileFilterFiles =
- Args.getLastArgValue(OPT_fprofile_filter_files_EQ);
+ std::string(Args.getLastArgValue(OPT_fprofile_filter_files_EQ));
Opts.ProfileExcludeFiles =
- Args.getLastArgValue(OPT_fprofile_exclude_files_EQ);
+ std::string(Args.getLastArgValue(OPT_fprofile_exclude_files_EQ));
Opts.CoverageExitBlockBeforeBody =
Args.hasArg(OPT_coverage_exit_block_before_body);
if (Args.hasArg(OPT_coverage_version_EQ)) {
@@ -1139,7 +1154,8 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
}
Opts.RelaxELFRelocations = Args.hasArg(OPT_mrelax_relocations);
- Opts.DebugCompilationDir = Args.getLastArgValue(OPT_fdebug_compilation_dir);
+ Opts.DebugCompilationDir =
+ std::string(Args.getLastArgValue(OPT_fdebug_compilation_dir));
for (auto *A :
Args.filtered(OPT_mlink_bitcode_file, OPT_mlink_builtin_bitcode)) {
CodeGenOptions::BitcodeFileToLink F;
@@ -1295,7 +1311,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.LinkerOptions = Args.getAllArgValues(OPT_linker_option);
bool NeedLocTracking = false;
- Opts.OptRecordFile = Args.getLastArgValue(OPT_opt_record_file);
+ Opts.OptRecordFile = std::string(Args.getLastArgValue(OPT_opt_record_file));
if (!Opts.OptRecordFile.empty())
NeedLocTracking = true;
@@ -1368,7 +1384,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.SanitizeTrap);
Opts.CudaGpuBinaryFileName =
- Args.getLastArgValue(OPT_fcuda_include_gpubinary);
+ std::string(Args.getLastArgValue(OPT_fcuda_include_gpubinary));
Opts.Backchain = Args.hasArg(OPT_mbackchain);
@@ -1419,20 +1435,22 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.PassPlugins = Args.getAllArgValues(OPT_fpass_plugin_EQ);
- Opts.SymbolPartition = Args.getLastArgValue(OPT_fsymbol_partition_EQ);
+ Opts.SymbolPartition =
+ std::string(Args.getLastArgValue(OPT_fsymbol_partition_EQ));
return Success;
}
static void ParseDependencyOutputArgs(DependencyOutputOptions &Opts,
ArgList &Args) {
- Opts.OutputFile = Args.getLastArgValue(OPT_dependency_file);
+ Opts.OutputFile = std::string(Args.getLastArgValue(OPT_dependency_file));
Opts.Targets = Args.getAllArgValues(OPT_MT);
Opts.IncludeSystemHeaders = Args.hasArg(OPT_sys_header_deps);
Opts.IncludeModuleFiles = Args.hasArg(OPT_module_file_deps);
Opts.UsePhonyTargets = Args.hasArg(OPT_MP);
Opts.ShowHeaderIncludes = Args.hasArg(OPT_H);
- Opts.HeaderIncludeOutputFile = Args.getLastArgValue(OPT_header_include_file);
+ Opts.HeaderIncludeOutputFile =
+ std::string(Args.getLastArgValue(OPT_header_include_file));
Opts.AddMissingHeaderDeps = Args.hasArg(OPT_MG);
if (Args.hasArg(OPT_show_includes)) {
// Writing both /showIncludes and preprocessor output to stdout
@@ -1445,9 +1463,9 @@ static void ParseDependencyOutputArgs(DependencyOutputOptions &Opts,
} else {
Opts.ShowIncludesDest = ShowIncludesDestination::None;
}
- Opts.DOTOutputFile = Args.getLastArgValue(OPT_dependency_dot);
+ Opts.DOTOutputFile = std::string(Args.getLastArgValue(OPT_dependency_dot));
Opts.ModuleDependencyOutputDir =
- Args.getLastArgValue(OPT_module_dependency_dir);
+ std::string(Args.getLastArgValue(OPT_module_dependency_dir));
if (Args.hasArg(OPT_MV))
Opts.OutputFormat = DependencyOutputFormat::NMake;
// Add sanitizer blacklists as extra dependencies.
@@ -1457,13 +1475,13 @@ static void ParseDependencyOutputArgs(DependencyOutputOptions &Opts,
for (const auto *A : Args.filtered(OPT_fsanitize_blacklist)) {
StringRef Val = A->getValue();
if (Val.find('=') == StringRef::npos)
- Opts.ExtraDeps.push_back(Val);
+ Opts.ExtraDeps.push_back(std::string(Val));
}
if (Opts.IncludeSystemHeaders) {
for (const auto *A : Args.filtered(OPT_fsanitize_system_blacklist)) {
StringRef Val = A->getValue();
if (Val.find('=') == StringRef::npos)
- Opts.ExtraDeps.push_back(Val);
+ Opts.ExtraDeps.push_back(std::string(Val));
}
}
}
@@ -1477,7 +1495,7 @@ static void ParseDependencyOutputArgs(DependencyOutputOptions &Opts,
for (const auto *A : Args.filtered(OPT_fmodule_file)) {
StringRef Val = A->getValue();
if (Val.find('=') == StringRef::npos)
- Opts.ExtraDeps.push_back(Val);
+ Opts.ExtraDeps.push_back(std::string(Val));
}
}
@@ -1539,7 +1557,8 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
bool DefaultDiagColor, bool DefaultShowOpt) {
bool Success = true;
- Opts.DiagnosticLogFile = Args.getLastArgValue(OPT_diagnostic_log_file);
+ Opts.DiagnosticLogFile =
+ std::string(Args.getLastArgValue(OPT_diagnostic_log_file));
if (Arg *A =
Args.getLastArg(OPT_diagnostic_serialized_file, OPT__serialize_diags))
Opts.DiagnosticSerializationFile = A->getValue();
@@ -1671,7 +1690,7 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
}
static void ParseFileSystemArgs(FileSystemOptions &Opts, ArgList &Args) {
- Opts.WorkingDir = Args.getLastArgValue(OPT_working_directory);
+ Opts.WorkingDir = std::string(Args.getLastArgValue(OPT_working_directory));
}
/// Parse the argument to the -ftest-module-file-extension
@@ -1689,12 +1708,12 @@ static bool parseTestModuleFileExtensionArg(StringRef Arg,
if (Args.size() < 5)
return true;
- BlockName = Args[0];
+ BlockName = std::string(Args[0]);
if (Args[1].getAsInteger(10, MajorVersion)) return true;
if (Args[2].getAsInteger(10, MinorVersion)) return true;
if (Args[3].getAsInteger(2, Hashed)) return true;
if (Args.size() > 4)
- UserInfo = Args[4];
+ UserInfo = std::string(Args[4]);
return false;
}
@@ -1862,7 +1881,7 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
}
Opts.DisableFree = Args.hasArg(OPT_disable_free);
- Opts.OutputFile = Args.getLastArgValue(OPT_o);
+ Opts.OutputFile = std::string(Args.getLastArgValue(OPT_o));
Opts.Plugins = Args.getAllArgValues(OPT_load);
Opts.RelocatablePCH = Args.hasArg(OPT_relocatable_pch);
Opts.ShowHelp = Args.hasArg(OPT_help);
@@ -1881,7 +1900,7 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
Opts.FixToTemporaries = Args.hasArg(OPT_fixit_to_temp);
Opts.ASTDumpDecls = Args.hasArg(OPT_ast_dump, OPT_ast_dump_EQ);
Opts.ASTDumpAll = Args.hasArg(OPT_ast_dump_all, OPT_ast_dump_all_EQ);
- Opts.ASTDumpFilter = Args.getLastArgValue(OPT_ast_dump_filter);
+ Opts.ASTDumpFilter = std::string(Args.getLastArgValue(OPT_ast_dump_filter));
Opts.ASTDumpLookups = Args.hasArg(OPT_ast_dump_lookups);
Opts.UseGlobalModuleIndex = !Args.hasArg(OPT_fno_modules_global_index);
Opts.GenerateGlobalModuleIndex = Opts.UseGlobalModuleIndex;
@@ -1890,7 +1909,7 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
for (const auto *A : Args.filtered(OPT_fmodule_file)) {
StringRef Val = A->getValue();
if (Val.find('=') == StringRef::npos)
- Opts.ModuleFiles.push_back(Val);
+ Opts.ModuleFiles.push_back(std::string(Val));
}
Opts.ModulesEmbedFiles = Args.getAllArgValues(OPT_fmodules_embed_file_EQ);
Opts.ModulesEmbedAllFiles = Args.hasArg(OPT_fmodules_embed_all_files);
@@ -1910,10 +1929,10 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
Opts.CodeCompleteOpts.IncludeFixIts
= Args.hasArg(OPT_code_completion_with_fixits);
- Opts.OverrideRecordLayoutsFile
- = Args.getLastArgValue(OPT_foverride_record_layout_EQ);
- Opts.AuxTriple = Args.getLastArgValue(OPT_aux_triple);
- Opts.StatsFile = Args.getLastArgValue(OPT_stats_file);
+ Opts.OverrideRecordLayoutsFile =
+ std::string(Args.getLastArgValue(OPT_foverride_record_layout_EQ));
+ Opts.AuxTriple = std::string(Args.getLastArgValue(OPT_aux_triple));
+ Opts.StatsFile = std::string(Args.getLastArgValue(OPT_stats_file));
if (const Arg *A = Args.getLastArg(OPT_arcmt_check,
OPT_arcmt_modify,
@@ -1932,9 +1951,10 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
break;
}
}
- Opts.MTMigrateDir = Args.getLastArgValue(OPT_mt_migrate_directory);
- Opts.ARCMTMigrateReportOut
- = Args.getLastArgValue(OPT_arcmt_migrate_report_output);
+ Opts.MTMigrateDir =
+ std::string(Args.getLastArgValue(OPT_mt_migrate_directory));
+ Opts.ARCMTMigrateReportOut =
+ std::string(Args.getLastArgValue(OPT_arcmt_migrate_report_output));
Opts.ARCMTMigrateEmitARCErrors
= Args.hasArg(OPT_arcmt_migrate_emit_arc_errors);
@@ -1969,7 +1989,8 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
if (Args.hasArg(OPT_objcmt_migrate_all))
Opts.ObjCMTAction |= FrontendOptions::ObjCMT_MigrateDecls;
- Opts.ObjCMTWhiteListPath = Args.getLastArgValue(OPT_objcmt_whitelist_dir_path);
+ Opts.ObjCMTWhiteListPath =
+ std::string(Args.getLastArgValue(OPT_objcmt_whitelist_dir_path));
if (Opts.ARCMTAction != FrontendOptions::ARCMT_None &&
Opts.ObjCMTAction != FrontendOptions::ObjCMT_None) {
@@ -2066,14 +2087,14 @@ std::string CompilerInvocation::GetResourcesPath(const char *Argv0,
static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
const std::string &WorkingDir) {
- Opts.Sysroot = Args.getLastArgValue(OPT_isysroot, "/");
+ Opts.Sysroot = std::string(Args.getLastArgValue(OPT_isysroot, "/"));
Opts.Verbose = Args.hasArg(OPT_v);
Opts.UseBuiltinIncludes = !Args.hasArg(OPT_nobuiltininc);
Opts.UseStandardSystemIncludes = !Args.hasArg(OPT_nostdsysteminc);
Opts.UseStandardCXXIncludes = !Args.hasArg(OPT_nostdincxx);
if (const Arg *A = Args.getLastArg(OPT_stdlib_EQ))
Opts.UseLibcxx = (strcmp(A->getValue(), "libc++") == 0);
- Opts.ResourceDir = Args.getLastArgValue(OPT_resource_dir);
+ Opts.ResourceDir = std::string(Args.getLastArgValue(OPT_resource_dir));
// Canonicalize -fmodules-cache-path before storing it.
SmallString<128> P(Args.getLastArgValue(OPT_fmodules_cache_path));
@@ -2084,9 +2105,10 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
llvm::sys::fs::make_absolute(WorkingDir, P);
}
llvm::sys::path::remove_dots(P);
- Opts.ModuleCachePath = P.str();
+ Opts.ModuleCachePath = std::string(P.str());
- Opts.ModuleUserBuildPath = Args.getLastArgValue(OPT_fmodules_user_build_path);
+ Opts.ModuleUserBuildPath =
+ std::string(Args.getLastArgValue(OPT_fmodules_user_build_path));
// Only the -fmodule-file=<name>=<file> form.
for (const auto *A : Args.filtered(OPT_fmodule_file)) {
StringRef Val = A->getValue();
@@ -2144,7 +2166,7 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
SmallString<32> Buffer;
llvm::sys::path::append(Buffer, Opts.Sysroot,
llvm::StringRef(A->getValue()).substr(1));
- Path = Buffer.str();
+ Path = std::string(Buffer.str());
}
Opts.AddPath(Path, Group, IsFramework,
@@ -2702,7 +2724,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
Opts.setSignedOverflowBehavior(LangOptions::SOB_Trapping);
// Set the handler, if one is specified.
Opts.OverflowHandler =
- Args.getLastArgValue(OPT_ftrapv_handler);
+ std::string(Args.getLastArgValue(OPT_ftrapv_handler));
}
else if (Args.hasArg(OPT_fwrapv))
Opts.setSignedOverflowBehavior(LangOptions::SOB_Defined);
@@ -2879,7 +2901,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
getLastArgIntValue(Args, OPT_Wlarge_by_value_copy_EQ, 0, Diags);
Opts.MSBitfields = Args.hasArg(OPT_mms_bitfields);
Opts.ObjCConstantStringClass =
- Args.getLastArgValue(OPT_fconstant_string_class);
+ std::string(Args.getLastArgValue(OPT_fconstant_string_class));
Opts.ObjCDefaultSynthProperties =
!Args.hasArg(OPT_disable_objc_default_synthesize_properties);
Opts.EncodeExtendedBlockSig =
@@ -2912,7 +2934,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
Opts.DebuggerCastResultToId = Args.hasArg(OPT_fdebugger_cast_result_to_id);
Opts.DebuggerObjCLiteral = Args.hasArg(OPT_fdebugger_objc_literal);
Opts.ApplePragmaPack = Args.hasArg(OPT_fapple_pragma_pack);
- Opts.ModuleName = Args.getLastArgValue(OPT_fmodule_name_EQ);
+ Opts.ModuleName = std::string(Args.getLastArgValue(OPT_fmodule_name_EQ));
Opts.CurrentModule = Opts.ModuleName;
Opts.AppExt = Args.hasArg(OPT_fapplication_extension);
Opts.ModuleFeatures = Args.getAllArgValues(OPT_fmodule_feature);
@@ -3344,11 +3366,12 @@ static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {
static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
DiagnosticsEngine &Diags,
frontend::ActionKind Action) {
- Opts.ImplicitPCHInclude = Args.getLastArgValue(OPT_include_pch);
+ Opts.ImplicitPCHInclude = std::string(Args.getLastArgValue(OPT_include_pch));
Opts.PCHWithHdrStop = Args.hasArg(OPT_pch_through_hdrstop_create) ||
Args.hasArg(OPT_pch_through_hdrstop_use);
Opts.PCHWithHdrStopCreate = Args.hasArg(OPT_pch_through_hdrstop_create);
- Opts.PCHThroughHeader = Args.getLastArgValue(OPT_pch_through_header_EQ);
+ Opts.PCHThroughHeader =
+ std::string(Args.getLastArgValue(OPT_pch_through_header_EQ));
Opts.UsePredefines = !Args.hasArg(OPT_undef);
Opts.DetailedRecord = Args.hasArg(OPT_detailed_preprocessing_record);
Opts.DisablePCHValidation = Args.hasArg(OPT_fno_validate_pch);
@@ -3458,8 +3481,8 @@ static void ParsePreprocessorOutputArgs(PreprocessorOutputOptions &Opts,
static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args,
DiagnosticsEngine &Diags) {
- Opts.CodeModel = getCodeModel(Args, Diags);
- Opts.ABI = Args.getLastArgValue(OPT_target_abi);
+ Opts.CodeModel = std::string(getCodeModel(Args, Diags));
+ Opts.ABI = std::string(Args.getLastArgValue(OPT_target_abi));
if (Arg *A = Args.getLastArg(OPT_meabi)) {
StringRef Value = A->getValue();
llvm::EABI EABIVersion = llvm::StringSwitch<llvm::EABI>(Value)
@@ -3474,11 +3497,12 @@ static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args,
else
Opts.EABIVersion = EABIVersion;
}
- Opts.CPU = Args.getLastArgValue(OPT_target_cpu);
- Opts.FPMath = Args.getLastArgValue(OPT_mfpmath);
+ Opts.CPU = std::string(Args.getLastArgValue(OPT_target_cpu));
+ Opts.FPMath = std::string(Args.getLastArgValue(OPT_mfpmath));
Opts.FeaturesAsWritten = Args.getAllArgValues(OPT_target_feature);
- Opts.LinkerVersion = Args.getLastArgValue(OPT_target_linker_version);
- Opts.Triple = Args.getLastArgValue(OPT_triple);
+ Opts.LinkerVersion =
+ std::string(Args.getLastArgValue(OPT_target_linker_version));
+ Opts.Triple = std::string(Args.getLastArgValue(OPT_triple));
// Use the default target triple if unspecified.
if (Opts.Triple.empty())
Opts.Triple = llvm::sys::getDefaultTargetTriple();
diff --git a/clang/lib/Frontend/DependencyFile.cpp b/clang/lib/Frontend/DependencyFile.cpp
index 4bb0167..f39ffd8 100644
--- a/clang/lib/Frontend/DependencyFile.cpp
+++ b/clang/lib/Frontend/DependencyFile.cpp
@@ -146,7 +146,7 @@ void DependencyCollector::maybeAddDependency(StringRef Filename, bool FromModule
bool DependencyCollector::addDependency(StringRef Filename) {
if (Seen.insert(Filename).second) {
- Dependencies.push_back(Filename);
+ Dependencies.push_back(std::string(Filename));
return true;
}
return false;
diff --git a/clang/lib/Frontend/DependencyGraph.cpp b/clang/lib/Frontend/DependencyGraph.cpp
index ccf7a27..8a6e491 100644
--- a/clang/lib/Frontend/DependencyGraph.cpp
+++ b/clang/lib/Frontend/DependencyGraph.cpp
@@ -119,8 +119,7 @@ void DependencyGraphCallback::OutputGraphFile() {
if (FileName.startswith(SysRoot))
FileName = FileName.substr(SysRoot.size());
- OS << DOT::EscapeString(FileName)
- << "\"];\n";
+ OS << DOT::EscapeString(std::string(FileName)) << "\"];\n";
}
// Write the edges
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp
index 934d17b..99f02278 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -201,7 +201,8 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI,
}
if ((ActionType == PluginASTAction::AddBeforeMainAction ||
ActionType == PluginASTAction::AddAfterMainAction) &&
- P->ParseArgs(CI, CI.getFrontendOpts().PluginArgs[it->getName()])) {
+ P->ParseArgs(
+ CI, CI.getFrontendOpts().PluginArgs[std::string(it->getName())])) {
std::unique_ptr<ASTConsumer> PluginConsumer = P->CreateASTConsumer(CI, InFile);
if (ActionType == PluginASTAction::AddBeforeMainAction) {
Consumers.push_back(std::move(PluginConsumer));
@@ -564,8 +565,9 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
StringRef InputFile = Input.getFile();
std::unique_ptr<ASTUnit> AST = ASTUnit::LoadFromASTFile(
- InputFile, CI.getPCHContainerReader(), ASTUnit::LoadPreprocessorOnly,
- ASTDiags, CI.getFileSystemOpts(), CI.getCodeGenOpts().DebugTypeExtRefs);
+ std::string(InputFile), CI.getPCHContainerReader(),
+ ASTUnit::LoadPreprocessorOnly, ASTDiags, CI.getFileSystemOpts(),
+ CI.getCodeGenOpts().DebugTypeExtRefs);
if (!AST)
goto failure;
@@ -592,10 +594,11 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
if (&MF != &PrimaryModule)
CI.getFrontendOpts().ModuleFiles.push_back(MF.FileName);
- ASTReader->visitTopLevelModuleMaps(PrimaryModule,
- [&](const FileEntry *FE) {
- CI.getFrontendOpts().ModuleMapFiles.push_back(FE->getName());
- });
+ ASTReader->visitTopLevelModuleMaps(
+ PrimaryModule, [&](const FileEntry *FE) {
+ CI.getFrontendOpts().ModuleMapFiles.push_back(
+ std::string(FE->getName()));
+ });
}
// Set up the input file for replay purposes.
@@ -630,8 +633,9 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
StringRef InputFile = Input.getFile();
std::unique_ptr<ASTUnit> AST = ASTUnit::LoadFromASTFile(
- InputFile, CI.getPCHContainerReader(), ASTUnit::LoadEverything, Diags,
- CI.getFileSystemOpts(), CI.getCodeGenOpts().DebugTypeExtRefs);
+ std::string(InputFile), CI.getPCHContainerReader(),
+ ASTUnit::LoadEverything, Diags, CI.getFileSystemOpts(),
+ CI.getCodeGenOpts().DebugTypeExtRefs);
if (!AST)
goto failure;
@@ -725,7 +729,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
Dir->path(), FileMgr, CI.getPCHContainerReader(),
CI.getLangOpts(), CI.getTargetOpts(), CI.getPreprocessorOpts(),
SpecificModuleCachePath)) {
- PPOpts.ImplicitPCHInclude = Dir->path();
+ PPOpts.ImplicitPCHInclude = std::string(Dir->path());
Found = true;
break;
}
@@ -817,7 +821,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
// For preprocessed files, check if the first line specifies the original
// source file name with a linemarker.
- std::string PresumedInputFile = getCurrentFileOrBufferName();
+ std::string PresumedInputFile = std::string(getCurrentFileOrBufferName());
if (Input.isPreprocessed())
ReadOriginalFileName(CI, PresumedInputFile);
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp
index 935c64a..1331a41 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -115,7 +115,7 @@ GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
CI.getPreprocessorOpts().AllowPCHWithCompilerErrors,
FrontendOpts.IncludeTimestamps, +CI.getLangOpts().CacheGeneratedPCH));
Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator(
- CI, InFile, OutputFile, std::move(OS), Buffer));
+ CI, std::string(InFile), OutputFile, std::move(OS), Buffer));
return std::make_unique<MultiplexConsumer>(std::move(Consumers));
}
@@ -181,7 +181,7 @@ GenerateModuleAction::CreateASTConsumer(CompilerInstance &CI,
/*ShouldCacheASTInMemory=*/
+CI.getFrontendOpts().BuildingImplicitModule));
Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator(
- CI, InFile, OutputFile, std::move(OS), Buffer));
+ CI, std::string(InFile), OutputFile, std::move(OS), Buffer));
return std::make_unique<MultiplexConsumer>(std::move(Consumers));
}
@@ -266,7 +266,7 @@ bool GenerateHeaderModuleAction::PrepareToExecuteAction(
HeaderContents += "#include \"";
HeaderContents += FIF.getFile();
HeaderContents += "\"\n";
- ModuleHeaders.push_back(FIF.getFile());
+ ModuleHeaders.push_back(std::string(FIF.getFile()));
}
Buffer = llvm::MemoryBuffer::getMemBufferCopy(
HeaderContents, Module::getModuleInputBufferName());
@@ -295,7 +295,7 @@ bool GenerateHeaderModuleAction::BeginSourceFileAction(
<< Name;
continue;
}
- Headers.push_back({Name, &FE->getFileEntry()});
+ Headers.push_back({std::string(Name), &FE->getFileEntry()});
}
HS.getModuleMap().createHeaderModule(CI.getLangOpts().CurrentModule, Headers);
diff --git a/clang/lib/Frontend/InitHeaderSearch.cpp b/clang/lib/Frontend/InitHeaderSearch.cpp
index 5d877ee..6050ea0 100644
--- a/clang/lib/Frontend/InitHeaderSearch.cpp
+++ b/clang/lib/Frontend/InitHeaderSearch.cpp
@@ -47,11 +47,9 @@ class InitHeaderSearch {
bool HasSysroot;
public:
-
InitHeaderSearch(HeaderSearch &HS, bool verbose, StringRef sysroot)
- : Headers(HS), Verbose(verbose), IncludeSysroot(sysroot),
- HasSysroot(!(sysroot.empty() || sysroot == "/")) {
- }
+ : Headers(HS), Verbose(verbose), IncludeSysroot(std::string(sysroot)),
+ HasSysroot(!(sysroot.empty() || sysroot == "/")) {}
/// AddPath - Add the specified path to the specified group list, prefixing
/// the sysroot if used.
@@ -355,7 +353,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
// files is <SDK_DIR>/host_tools/lib/clang
SmallString<128> P = StringRef(HSOpts.ResourceDir);
llvm::sys::path::append(P, "../../..");
- BaseSDKPath = P.str();
+ BaseSDKPath = std::string(P.str());
}
}
AddPath(BaseSDKPath + "/target/include", System, false);
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
index 8a0ff55..e214bd1 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -80,9 +80,9 @@ static void AddImplicitIncludeMacros(MacroBuilder &Builder, StringRef File) {
static void AddImplicitIncludePCH(MacroBuilder &Builder, Preprocessor &PP,
const PCHContainerReader &PCHContainerRdr,
StringRef ImplicitIncludePCH) {
- std::string OriginalFile =
- ASTReader::getOriginalSourceFile(ImplicitIncludePCH, PP.getFileManager(),
- PCHContainerRdr, PP.getDiagnostics());
+ std::string OriginalFile = ASTReader::getOriginalSourceFile(
+ std::string(ImplicitIncludePCH), PP.getFileManager(), PCHContainerRdr,
+ PP.getDiagnostics());
if (OriginalFile.empty())
return;
diff --git a/clang/lib/Frontend/LogDiagnosticPrinter.cpp b/clang/lib/Frontend/LogDiagnosticPrinter.cpp
index 4bac175..df8b236 100644
--- a/clang/lib/Frontend/LogDiagnosticPrinter.cpp
+++ b/clang/lib/Frontend/LogDiagnosticPrinter.cpp
@@ -120,7 +120,7 @@ void LogDiagnosticPrinter::HandleDiagnostic(DiagnosticsEngine::Level Level,
if (FID.isValid()) {
const FileEntry *FE = SM.getFileEntryForID(FID);
if (FE && FE->isValid())
- MainFilename = FE->getName();
+ MainFilename = std::string(FE->getName());
}
}
@@ -129,12 +129,13 @@ void LogDiagnosticPrinter::HandleDiagnostic(DiagnosticsEngine::Level Level,
DE.DiagnosticID = Info.getID();
DE.DiagnosticLevel = Level;
- DE.WarningOption = DiagnosticIDs::getWarningOptionForDiag(DE.DiagnosticID);
+ DE.WarningOption =
+ std::string(DiagnosticIDs::getWarningOptionForDiag(DE.DiagnosticID));
// Format the message.
SmallString<100> MessageStr;
Info.FormatDiagnostic(MessageStr);
- DE.Message = MessageStr.str();
+ DE.Message = std::string(MessageStr.str());
// Set the location information.
DE.Filename = "";
@@ -149,7 +150,7 @@ void LogDiagnosticPrinter::HandleDiagnostic(DiagnosticsEngine::Level Level,
if (FID.isValid()) {
const FileEntry *FE = SM.getFileEntryForID(FID);
if (FE && FE->isValid())
- DE.Filename = FE->getName();
+ DE.Filename = std::string(FE->getName());
}
} else {
DE.Filename = PLoc.getFilename();
diff --git a/clang/lib/Frontend/ModuleDependencyCollector.cpp b/clang/lib/Frontend/ModuleDependencyCollector.cpp
index fd22433..b54eb97 100644
--- a/clang/lib/Frontend/ModuleDependencyCollector.cpp
+++ b/clang/lib/Frontend/ModuleDependencyCollector.cpp
@@ -170,7 +170,7 @@ bool ModuleDependencyCollector::getRealPath(StringRef SrcPath,
if (DirWithSymLink == SymLinkMap.end()) {
if (llvm::sys::fs::real_path(Dir, RealPath))
return false;
- SymLinkMap[Dir] = RealPath.str();
+ SymLinkMap[Dir] = std::string(RealPath.str());
} else {
RealPath = DirWithSymLink->second;
}
diff --git a/clang/lib/Frontend/PrecompiledPreamble.cpp b/clang/lib/Frontend/PrecompiledPreamble.cpp
index 0e5a8e5..909ac54 100644
--- a/clang/lib/Frontend/PrecompiledPreamble.cpp
+++ b/clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -269,8 +269,9 @@ llvm::ErrorOr<PrecompiledPreamble> PrecompiledPreamble::Build(
// Tell the compiler invocation to generate a temporary precompiled header.
FrontendOpts.ProgramAction = frontend::GeneratePCH;
- FrontendOpts.OutputFile = StoreInMemory ? getInMemoryPreamblePath()
- : Storage.asFile().getFilePath();
+ FrontendOpts.OutputFile =
+ std::string(StoreInMemory ? getInMemoryPreamblePath()
+ : Storage.asFile().getFilePath());
PreprocessorOpts.PrecompiledPreambleBytes.first = 0;
PreprocessorOpts.PrecompiledPreambleBytes.second = false;
// Inform preprocessor to record conditional stack when building the preamble.
@@ -548,7 +549,7 @@ PrecompiledPreamble::TempPCHFile::CreateNewPreamblePCHFile() {
return EC;
// We only needed to make sure the file exists, close the file right away.
llvm::sys::Process::SafelyCloseFileDescriptor(FD);
- return TempPCHFile(std::move(File).str());
+ return TempPCHFile(std::string(std::move(File).str()));
}
PrecompiledPreamble::TempPCHFile::TempPCHFile(std::string FilePath)
@@ -715,7 +716,7 @@ void PrecompiledPreamble::setupPreambleStorage(
IntrusiveRefCntPtr<llvm::vfs::FileSystem> &VFS) {
if (Storage.getKind() == PCHStorage::Kind::TempFile) {
const TempPCHFile &PCHFile = Storage.asFile();
- PreprocessorOpts.ImplicitPCHInclude = PCHFile.getFilePath();
+ PreprocessorOpts.ImplicitPCHInclude = std::string(PCHFile.getFilePath());
// Make sure we can access the PCH file even if we're using a VFS
IntrusiveRefCntPtr<llvm::vfs::FileSystem> RealFS =
@@ -739,7 +740,7 @@ void PrecompiledPreamble::setupPreambleStorage(
// For in-memory preamble, we have to provide a VFS overlay that makes it
// accessible.
StringRef PCHPath = getInMemoryPreamblePath();
- PreprocessorOpts.ImplicitPCHInclude = PCHPath;
+ PreprocessorOpts.ImplicitPCHInclude = std::string(PCHPath);
auto Buf = llvm::MemoryBuffer::getMemBuffer(Storage.asMemory().Data);
VFS = createVFSOverlayForPreamblePCH(PCHPath, std::move(Buf), VFS);
diff --git a/clang/lib/Frontend/Rewrite/FixItRewriter.cpp b/clang/lib/Frontend/Rewrite/FixItRewriter.cpp
index 0217b33..4fe64b9 100644
--- a/clang/lib/Frontend/Rewrite/FixItRewriter.cpp
+++ b/clang/lib/Frontend/Rewrite/FixItRewriter.cpp
@@ -95,7 +95,8 @@ bool FixItRewriter::WriteFixedFiles(
for (iterator I = buffer_begin(), E = buffer_end(); I != E; ++I) {
const FileEntry *Entry = Rewrite.getSourceMgr().getFileEntryForID(I->first);
int fd;
- std::string Filename = FixItOpts->RewriteFilename(Entry->getName(), fd);
+ std::string Filename =
+ FixItOpts->RewriteFilename(std::string(Entry->getName()), fd);
std::error_code EC;
std::unique_ptr<llvm::raw_fd_ostream> OS;
if (fd != -1) {
@@ -113,7 +114,8 @@ bool FixItRewriter::WriteFixedFiles(
OS->flush();
if (RewrittenFiles)
- RewrittenFiles->push_back(std::make_pair(Entry->getName(), Filename));
+ RewrittenFiles->push_back(
+ std::make_pair(std::string(Entry->getName()), Filename));
}
return false;
diff --git a/clang/lib/Frontend/Rewrite/FrontendActions.cpp b/clang/lib/Frontend/Rewrite/FrontendActions.cpp
index aaffbde..5351ff0 100644
--- a/clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ b/clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -77,7 +77,7 @@ public:
SmallString<128> Path(Filename);
llvm::sys::path::replace_extension(Path,
NewSuffix + llvm::sys::path::extension(Path));
- return Path.str();
+ return std::string(Path.str());
}
};
@@ -88,7 +88,7 @@ public:
llvm::sys::fs::createTemporaryFile(llvm::sys::path::filename(Filename),
llvm::sys::path::extension(Filename).drop_front(), fd,
Path);
- return Path.str();
+ return std::string(Path.str());
}
};
} // end anonymous namespace
@@ -166,11 +166,11 @@ RewriteObjCAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
CI.createDefaultOutputFile(false, InFile, "cpp")) {
if (CI.getLangOpts().ObjCRuntime.isNonFragile())
return CreateModernObjCRewriter(
- InFile, std::move(OS), CI.getDiagnostics(), CI.getLangOpts(),
- CI.getDiagnosticOpts().NoRewriteMacros,
+ std::string(InFile), std::move(OS), CI.getDiagnostics(),
+ CI.getLangOpts(), CI.getDiagnosticOpts().NoRewriteMacros,
(CI.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo));
- return CreateObjCRewriter(InFile, std::move(OS), CI.getDiagnostics(),
- CI.getLangOpts(),
+ return CreateObjCRewriter(std::string(InFile), std::move(OS),
+ CI.getDiagnostics(), CI.getLangOpts(),
CI.getDiagnosticOpts().NoRewriteMacros);
}
return nullptr;
diff --git a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
index 831f95e..f3a2780 100644
--- a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
+++ b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
@@ -860,7 +860,7 @@ RewriteModernObjC::getIvarAccessString(ObjCIvarDecl *D) {
// ivar in class extensions requires special treatment.
if (ObjCCategoryDecl *CatDecl = dyn_cast<ObjCCategoryDecl>(CDecl))
CDecl = CatDecl->getClassInterface();
- std::string RecName = CDecl->getName();
+ std::string RecName = std::string(CDecl->getName());
RecName += "_IMPL";
RecordDecl *RD =
RecordDecl::Create(*Context, TTK_Struct, TUDecl, SourceLocation(),
@@ -4442,7 +4442,7 @@ void RewriteModernObjC::InsertBlockLiteralsWithinFunction(FunctionDecl *FD) {
static void BuildUniqueMethodName(std::string &Name,
ObjCMethodDecl *MD) {
ObjCInterfaceDecl *IFace = MD->getClassInterface();
- Name = IFace->getName();
+ Name = std::string(IFace->getName());
Name += "__" + MD->getSelector().getAsString();
// Convert colons to underscores.
std::string::size_type loc = 0;
@@ -7506,7 +7506,7 @@ Stmt *RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
// ivar in class extensions requires special treatment.
if (ObjCCategoryDecl *CatDecl = dyn_cast<ObjCCategoryDecl>(CDecl))
CDecl = CatDecl->getClassInterface();
- std::string RecName = CDecl->getName();
+ std::string RecName = std::string(CDecl->getName());
RecName += "_IMPL";
RecordDecl *RD = RecordDecl::Create(
*Context, TTK_Struct, TUDecl, SourceLocation(), SourceLocation(),
diff --git a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
index 0cb7592..0302156 100644
--- a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
+++ b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
@@ -3631,7 +3631,7 @@ void RewriteObjC::InsertBlockLiteralsWithinFunction(FunctionDecl *FD) {
static void BuildUniqueMethodName(std::string &Name,
ObjCMethodDecl *MD) {
ObjCInterfaceDecl *IFace = MD->getClassInterface();
- Name = IFace->getName();
+ Name = std::string(IFace->getName());
Name += "__" + MD->getSelector().getAsString();
// Convert colons to underscores.
std::string::size_type loc = 0;
@@ -5819,7 +5819,8 @@ Stmt *RewriteObjCFragileABI::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
assert(clsDeclared && "RewriteObjCIvarRefExpr(): Can't find class");
// Synthesize an explicit cast to gain access to the ivar.
- std::string RecName = clsDeclared->getIdentifier()->getName();
+ std::string RecName =
+ std::string(clsDeclared->getIdentifier()->getName());
RecName += "_IMPL";
IdentifierInfo *II = &Context->Idents.get(RecName);
RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
@@ -5859,7 +5860,8 @@ Stmt *RewriteObjCFragileABI::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
assert(clsDeclared && "RewriteObjCIvarRefExpr(): Can't find class");
// Synthesize an explicit cast to gain access to the ivar.
- std::string RecName = clsDeclared->getIdentifier()->getName();
+ std::string RecName =
+ std::string(clsDeclared->getIdentifier()->getName());
RecName += "_IMPL";
IdentifierInfo *II = &Context->Idents.get(RecName);
RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
diff --git a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
index 9bf70b7..70735ab 100644
--- a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -80,7 +80,9 @@ CreateFrontendBaseAction(CompilerInstance &CI) {
std::unique_ptr<PluginASTAction> P(it->instantiate());
if ((P->getActionType() != PluginASTAction::ReplaceAction &&
P->getActionType() != PluginASTAction::Cmdline) ||
- !P->ParseArgs(CI, CI.getFrontendOpts().PluginArgs[it->getName()]))
+ !P->ParseArgs(
+ CI,
+ CI.getFrontendOpts().PluginArgs[std::string(it->getName())]))
return nullptr;
return std::move(P);
}
@@ -218,7 +220,7 @@ bool ExecuteCompilerInvocation(CompilerInstance *Clang) {
std::unique_ptr<PluginASTAction> P(it->instantiate());
if (P->getActionType() == PluginASTAction::ReplaceAction) {
Clang->getFrontendOpts().ProgramAction = clang::frontend::PluginAction;
- Clang->getFrontendOpts().ActionName = it->getName();
+ Clang->getFrontendOpts().ActionName = std::string(it->getName());
break;
}
}
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index f0c5900..ff9272e 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -133,7 +133,7 @@ const HeaderMap *HeaderSearch::CreateHeaderMap(const FileEntry *FE) {
void HeaderSearch::getHeaderMapFileNames(
SmallVectorImpl<std::string> &Names) const {
for (auto &HM : HeaderMaps)
- Names.push_back(HM.first->getName());
+ Names.push_back(std::string(HM.first->getName()));
}
std::string HeaderSearch::getCachedModuleFileName(Module *Module) {
@@ -145,7 +145,7 @@ std::string HeaderSearch::getCachedModuleFileName(Module *Module) {
std::string HeaderSearch::getPrebuiltModuleFileName(StringRef ModuleName,
bool FileMapOnly) {
// First check the module name to pcm file map.
- auto i (HSOpts->PrebuiltModuleFiles.find(ModuleName));
+ auto i(HSOpts->PrebuiltModuleFiles.find(std::string(ModuleName)));
if (i != HSOpts->PrebuiltModuleFiles.end())
return i->second;
@@ -184,7 +184,8 @@ std::string HeaderSearch::getCachedModuleFileName(StringRef ModuleName,
//
// To avoid false-negatives, we form as canonical a path as we can, and map
// to lower-case in case we're on a case-insensitive file system.
- std::string Parent = llvm::sys::path::parent_path(ModuleMapPath);
+ std::string Parent =
+ std::string(llvm::sys::path::parent_path(ModuleMapPath));
if (Parent.empty())
Parent = ".";
auto Dir = FileMgr.getDirectory(Parent);
@@ -468,7 +469,7 @@ getTopFrameworkDir(FileManager &FileMgr, StringRef DirName,
// If this is a framework directory, then we're a subframework of this
// framework.
if (llvm::sys::path::extension(DirName) == ".framework") {
- SubmodulePath.push_back(llvm::sys::path::stem(DirName));
+ SubmodulePath.push_back(std::string(llvm::sys::path::stem(DirName)));
TopFrameworkDir = *Dir;
}
} while (true);
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 648bda2..90347265 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -253,7 +253,7 @@ template <typename T> static void StringifyImpl(T &Str, char Quote) {
}
std::string Lexer::Stringify(StringRef Str, bool Charify) {
- std::string Result = Str;
+ std::string Result = std::string(Str);
char Quote = Charify ? '\'' : '"';
StringifyImpl(Result, Quote);
return Result;
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index fe20a35..6622339 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -262,7 +262,7 @@ void ModuleMap::resolveHeader(Module *Mod,
// Record this umbrella header.
setUmbrellaHeader(Mod, File, RelativePathName.str());
} else {
- Module::Header H = {RelativePathName.str(), File};
+ Module::Header H = {std::string(RelativePathName.str()), File};
if (Header.Kind == Module::HK_Excluded)
excludeHeader(Mod, H);
else
@@ -305,7 +305,7 @@ bool ModuleMap::resolveAsBuiltinHeader(
return false;
auto Role = headerKindToRole(Header.Kind);
- Module::Header H = {Path.str(), *File};
+ Module::Header H = {std::string(Path.str()), *File};
addHeader(Mod, H, Role);
return true;
}
@@ -1681,7 +1681,8 @@ bool ModuleMapParser::parseModuleId(ModuleId &Id) {
Id.clear();
do {
if (Tok.is(MMToken::Identifier) || Tok.is(MMToken::StringLiteral)) {
- Id.push_back(std::make_pair(Tok.getString(), Tok.getLocation()));
+ Id.push_back(
+ std::make_pair(std::string(Tok.getString()), Tok.getLocation()));
consumeToken();
} else {
Diags.Report(Tok.getLocation(), diag::err_mmap_expected_module_name);
@@ -2129,7 +2130,7 @@ void ModuleMapParser::parseExternModuleDecl() {
HadError = true;
return;
}
- std::string FileName = Tok.getString();
+ std::string FileName = std::string(Tok.getString());
consumeToken(); // filename
StringRef FileNameRef = FileName;
@@ -2209,7 +2210,7 @@ void ModuleMapParser::parseRequiresDecl() {
}
// Consume the feature name.
- std::string Feature = Tok.getString();
+ std::string Feature = std::string(Tok.getString());
consumeToken();
bool IsRequiresExcludedHack = false;
@@ -2283,7 +2284,7 @@ void ModuleMapParser::parseHeaderDecl(MMToken::TokenKind LeadingToken,
return;
}
Module::UnresolvedHeaderDirective Header;
- Header.FileName = Tok.getString();
+ Header.FileName = std::string(Tok.getString());
Header.FileNameLoc = consumeToken();
Header.IsUmbrella = LeadingToken == MMToken::UmbrellaKeyword;
Header.Kind =
@@ -2380,7 +2381,7 @@ void ModuleMapParser::parseUmbrellaDirDecl(SourceLocation UmbrellaLoc) {
return;
}
- std::string DirName = Tok.getString();
+ std::string DirName = std::string(Tok.getString());
SourceLocation DirNameLoc = consumeToken();
// Check whether we already have an umbrella.
@@ -2422,8 +2423,7 @@ void ModuleMapParser::parseUmbrellaDirDecl(SourceLocation UmbrellaLoc) {
for (llvm::vfs::recursive_directory_iterator I(FS, Dir->getName(), EC), E;
I != E && !EC; I.increment(EC)) {
if (auto FE = SourceMgr.getFileManager().getFile(I->path())) {
-
- Module::Header Header = {I->path(), *FE};
+ Module::Header Header = {std::string(I->path()), *FE};
Headers.push_back(std::move(Header));
}
}
@@ -2466,8 +2466,8 @@ void ModuleMapParser::parseExportDecl() {
do {
// FIXME: Support string-literal module names here.
if (Tok.is(MMToken::Identifier)) {
- ParsedModuleId.push_back(std::make_pair(Tok.getString(),
- Tok.getLocation()));
+ ParsedModuleId.push_back(
+ std::make_pair(std::string(Tok.getString()), Tok.getLocation()));
consumeToken();
if (Tok.is(MMToken::Period)) {
@@ -2526,7 +2526,7 @@ void ModuleMapParser::parseExportAsDecl() {
}
}
- ActiveModule->ExportAsModule = Tok.getString();
+ ActiveModule->ExportAsModule = std::string(Tok.getString());
Map.addLinkAsDependency(ActiveModule);
consumeToken();
@@ -2572,7 +2572,7 @@ void ModuleMapParser::parseLinkDecl() {
return;
}
- std::string LibraryName = Tok.getString();
+ std::string LibraryName = std::string(Tok.getString());
consumeToken();
ActiveModule->LinkLibraries.push_back(Module::LinkLibrary(LibraryName,
IsFramework));
@@ -2794,8 +2794,8 @@ void ModuleMapParser::parseInferredModuleDecl(bool Framework, bool Explicit) {
break;
}
- Map.InferredDirectories[Directory].ExcludedModules
- .push_back(Tok.getString());
+ Map.InferredDirectories[Directory].ExcludedModules.push_back(
+ std::string(Tok.getString()));
consumeToken();
break;
diff --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp
index 8021726..aee1311 100644
--- a/clang/lib/Lex/PPLexerChange.cpp
+++ b/clang/lib/Lex/PPLexerChange.cpp
@@ -81,7 +81,7 @@ bool Preprocessor::EnterSourceFile(FileID FID, const DirectoryLookup *CurDir,
if (Invalid) {
SourceLocation FileStart = SourceMgr.getLocForStartOfFile(FID);
Diag(Loc, diag::err_pp_error_opening_file)
- << std::string(SourceMgr.getBufferName(FileStart)) << "";
+ << std::string(SourceMgr.getBufferName(FileStart)) << "";
return true;
}
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index 3bbd5ef..890a9bb 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -1355,7 +1355,7 @@ bool Preprocessor::FinishLexStringLiteral(Token &Result, std::string &String,
return false;
}
- String = Literal.GetString();
+ String = std::string(Literal.GetString());
return true;
}
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index 1a8e034..617c291 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -2324,7 +2324,7 @@ bool Parser::ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS,
// before 'getAs' and treat this as a dependent template name.
std::string Name;
if (Id.getKind() == UnqualifiedIdKind::IK_Identifier)
- Name = Id.Identifier->getName();
+ Name = std::string(Id.Identifier->getName());
else {
Name = "operator ";
if (Id.getKind() == UnqualifiedIdKind::IK_OperatorFunctionId)
diff --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp
index ec50847b..f2b0d39 100644
--- a/clang/lib/Parse/ParsePragma.cpp
+++ b/clang/lib/Parse/ParsePragma.cpp
@@ -1032,11 +1032,11 @@ struct PragmaLoopHintInfo {
static std::string PragmaLoopHintString(Token PragmaName, Token Option) {
StringRef Str = PragmaName.getIdentifierInfo()->getName();
std::string ClangLoopStr = (llvm::Twine("clang loop ") + Str).str();
- return llvm::StringSwitch<StringRef>(Str)
- .Case("loop", ClangLoopStr)
- .Case("unroll_and_jam", Str)
- .Case("unroll", Str)
- .Default("");
+ return std::string(llvm::StringSwitch<StringRef>(Str)
+ .Case("loop", ClangLoopStr)
+ .Case("unroll_and_jam", Str)
+ .Case("unroll", Str)
+ .Default(""));
}
bool Parser::HandlePragmaLoopHint(LoopHint &Hint) {
diff --git a/clang/lib/Parse/ParseTemplate.cpp b/clang/lib/Parse/ParseTemplate.cpp
index 3bc4e35..8debebc 100644
--- a/clang/lib/Parse/ParseTemplate.cpp
+++ b/clang/lib/Parse/ParseTemplate.cpp
@@ -253,9 +253,9 @@ Decl *Parser::ParseSingleDeclarationAfterTemplate(
}
llvm::TimeTraceScope TimeScope("ParseTemplate", [&]() {
- return DeclaratorInfo.getIdentifier() != nullptr
- ? DeclaratorInfo.getIdentifier()->getName()
- : "<unknown>";
+ return std::string(DeclaratorInfo.getIdentifier() != nullptr
+ ? DeclaratorInfo.getIdentifier()->getName()
+ : "<unknown>");
});
LateParsedAttrList LateParsedAttrs(true);
diff --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp
index 9b8dc148..6a2f744 100644
--- a/clang/lib/Sema/SemaAttr.cpp
+++ b/clang/lib/Sema/SemaAttr.cpp
@@ -282,7 +282,7 @@ void Sema::ActOnPragmaClangSection(SourceLocation PragmaLoc, PragmaClangSectionA
}
CSec->Valid = true;
- CSec->SectionName = SecName;
+ CSec->SectionName = std::string(SecName);
CSec->PragmaLocation = PragmaLoc;
}
diff --git a/clang/lib/Sema/SemaAvailability.cpp b/clang/lib/Sema/SemaAvailability.cpp
index 0c0275d..bb3334a 100644
--- a/clang/lib/Sema/SemaAvailability.cpp
+++ b/clang/lib/Sema/SemaAvailability.cpp
@@ -368,8 +368,8 @@ static void DoEmitAvailabilityWarning(Sema &S, AvailabilityResult K,
unsigned Warning = UseNewWarning ? diag::warn_unguarded_availability_new
: diag::warn_unguarded_availability;
- std::string PlatformName = AvailabilityAttr::getPrettyPlatformName(
- S.getASTContext().getTargetInfo().getPlatformName());
+ std::string PlatformName(AvailabilityAttr::getPrettyPlatformName(
+ S.getASTContext().getTargetInfo().getPlatformName()));
S.Diag(Loc, Warning) << OffendingDecl << PlatformName
<< Introduced.getAsString();
@@ -767,8 +767,8 @@ void DiagnoseUnguardedAvailability::DiagnoseDeclAvailability(
? diag::warn_unguarded_availability_new
: diag::warn_unguarded_availability;
- std::string PlatformName = AvailabilityAttr::getPrettyPlatformName(
- SemaRef.getASTContext().getTargetInfo().getPlatformName());
+ std::string PlatformName(AvailabilityAttr::getPrettyPlatformName(
+ SemaRef.getASTContext().getTargetInfo().getPlatformName()));
SemaRef.Diag(Range.getBegin(), DiagKind)
<< Range << D << PlatformName << Introduced.getAsString();
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index 18b1172..487ba46 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -2755,7 +2755,7 @@ FormatFunctionParameter(const PrintingPolicy &Policy, const ParmVarDecl *Param,
std::string Result;
if (Param->getIdentifier() && !ObjCMethodParam && !SuppressName)
- Result = Param->getIdentifier()->getName();
+ Result = std::string(Param->getIdentifier()->getName());
QualType Type = Param->getType();
if (ObjCSubsts)
@@ -2794,7 +2794,7 @@ FormatFunctionParameter(const PrintingPolicy &Policy, const ParmVarDecl *Param,
// for the block; just use the parameter type as a placeholder.
std::string Result;
if (!ObjCMethodParam && Param->getIdentifier())
- Result = Param->getIdentifier()->getName();
+ Result = std::string(Param->getIdentifier()->getName());
QualType Type = Param->getType().getUnqualifiedType();
@@ -3009,7 +3009,7 @@ static void AddTemplateParameterChunks(
} else if (NonTypeTemplateParmDecl *NTTP =
dyn_cast<NonTypeTemplateParmDecl>(*P)) {
if (NTTP->getIdentifier())
- PlaceholderStr = NTTP->getIdentifier()->getName();
+ PlaceholderStr = std::string(NTTP->getIdentifier()->getName());
NTTP->getType().getAsStringInternal(PlaceholderStr, Policy);
HasDefaultArg = NTTP->hasDefaultArgument();
} else {
@@ -4339,7 +4339,7 @@ static void AddLambdaCompletion(ResultBuilder &Results,
First = false;
constexpr llvm::StringLiteral NamePlaceholder = "!#!NAME_GOES_HERE!#!";
- std::string Type = NamePlaceholder;
+ std::string Type = std::string(NamePlaceholder);
Parameter.getAsStringInternal(Type, PrintingPolicy(LangOpts));
llvm::StringRef Prefix, Suffix;
std::tie(Prefix, Suffix) = llvm::StringRef(Type).split(NamePlaceholder);
@@ -7655,7 +7655,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
} Key(Allocator, PropName->getName());
// The uppercased name of the property name.
- std::string UpperKey = PropName->getName();
+ std::string UpperKey = std::string(PropName->getName());
if (!UpperKey.empty())
UpperKey[0] = toUppercase(UpperKey[0]);
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index d70e85a..e8589d3 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2741,21 +2741,19 @@ static void diagnoseMissingConstinit(Sema &S, const VarDecl *InitDecl,
// heroics.
std::string SuitableSpelling;
if (S.getLangOpts().CPlusPlus2a)
- SuitableSpelling =
- S.PP.getLastMacroWithSpelling(InsertLoc, {tok::kw_constinit});
+ SuitableSpelling = std::string(
+ S.PP.getLastMacroWithSpelling(InsertLoc, {tok::kw_constinit}));
if (SuitableSpelling.empty() && S.getLangOpts().CPlusPlus11)
- SuitableSpelling = S.PP.getLastMacroWithSpelling(
- InsertLoc,
- {tok::l_square, tok::l_square, S.PP.getIdentifierInfo("clang"),
- tok::coloncolon,
- S.PP.getIdentifierInfo("require_constant_initialization"),
- tok::r_square, tok::r_square});
+ SuitableSpelling = std::string(S.PP.getLastMacroWithSpelling(
+ InsertLoc, {tok::l_square, tok::l_square,
+ S.PP.getIdentifierInfo("clang"), tok::coloncolon,
+ S.PP.getIdentifierInfo("require_constant_initialization"),
+ tok::r_square, tok::r_square}));
if (SuitableSpelling.empty())
- SuitableSpelling = S.PP.getLastMacroWithSpelling(
- InsertLoc,
- {tok::kw___attribute, tok::l_paren, tok::r_paren,
- S.PP.getIdentifierInfo("require_constant_initialization"),
- tok::r_paren, tok::r_paren});
+ SuitableSpelling = std::string(S.PP.getLastMacroWithSpelling(
+ InsertLoc, {tok::kw___attribute, tok::l_paren, tok::r_paren,
+ S.PP.getIdentifierInfo("require_constant_initialization"),
+ tok::r_paren, tok::r_paren}));
if (SuitableSpelling.empty() && S.getLangOpts().CPlusPlus2a)
SuitableSpelling = "constinit";
if (SuitableSpelling.empty() && S.getLangOpts().CPlusPlus11)
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 523daf37..814a3c6 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -952,7 +952,7 @@ static std::string printTemplateArgs(const PrintingPolicy &PrintingPolicy,
Arg.getArgument().print(PrintingPolicy, OS);
First = false;
}
- return OS.str();
+ return std::string(OS.str());
}
static bool lookupStdTypeTraitMember(Sema &S, LookupResult &TraitMemberLookup,
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 5b00e55..b063247 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -11328,12 +11328,12 @@ static void diagnoseXorMisusedAsPow(Sema &S, const ExprResult &XorLHS,
if (XorStr == "xor")
return;
- std::string LHSStr = Lexer::getSourceText(
+ std::string LHSStr = std::string(Lexer::getSourceText(
CharSourceRange::getTokenRange(LHSInt->getSourceRange()),
- S.getSourceManager(), S.getLangOpts());
- std::string RHSStr = Lexer::getSourceText(
+ S.getSourceManager(), S.getLangOpts()));
+ std::string RHSStr = std::string(Lexer::getSourceText(
CharSourceRange::getTokenRange(RHSInt->getSourceRange()),
- S.getSourceManager(), S.getLangOpts());
+ S.getSourceManager(), S.getLangOpts()));
if (Negative) {
RightSideValue = -RightSideValue;
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 64e7b9d..5d253cd 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -11979,7 +11979,7 @@ getListOfPossibleValues(OpenMPClauseKind K, unsigned First, unsigned Last,
else if (I + Skipped + 1 != Last)
Out << ", ";
}
- return Out.str();
+ return std::string(Out.str());
}
OMPClause *Sema::ActOnOpenMPDefaultClause(OpenMPDefaultClauseKind Kind,
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 4d38d07..1188017 100755
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -10627,7 +10627,7 @@ Sema::getTemplateArgumentBindingsText(const TemplateParameterList *Params,
}
Out << ']';
- return Out.str();
+ return std::string(Out.str());
}
void Sema::MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD,
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 5351ac3..3a3af77 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -1411,7 +1411,7 @@ resolveFileRelativeToOriginalDir(const std::string &Filename,
path::append(currPCHPath, "..");
path::append(currPCHPath, fileDirI, fileDirE);
path::append(currPCHPath, path::filename(Filename));
- return currPCHPath.str();
+ return std::string(currPCHPath.str());
}
bool ASTReader::ReadSLocEntry(int ID) {
@@ -1838,7 +1838,7 @@ bool HeaderFileInfoTrait::EqualKey(internal_key_ref a, internal_key_ref b) {
return nullptr;
}
- std::string Resolved = Key.Filename;
+ std::string Resolved = std::string(Key.Filename);
Reader.ResolveImportedPath(M, Resolved);
if (auto File = FileMgr.getFile(Resolved))
return *File;
@@ -1913,13 +1913,13 @@ HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d,
ModuleMap &ModMap =
Reader.getPreprocessor().getHeaderSearchInfo().getModuleMap();
- std::string Filename = key.Filename;
+ std::string Filename = std::string(key.Filename);
if (key.Imported)
Reader.ResolveImportedPath(M, Filename);
// FIXME: This is not always the right filename-as-written, but we're not
// going to use this information to rebuild the module, so it doesn't make
// a lot of difference.
- Module::Header H = { key.Filename, *FileMgr.getFile(Filename) };
+ Module::Header H = {std::string(key.Filename), *FileMgr.getFile(Filename)};
ModMap.addHeader(Mod, H, HeaderRole, /*Imported*/true);
HFI.isModuleHeader |= !(HeaderRole & ModuleMap::TextualHeader);
}
@@ -2248,7 +2248,7 @@ ASTReader::readInputFileInfo(ModuleFile &F, unsigned ID) {
R.Overridden = static_cast<bool>(Record[3]);
R.Transient = static_cast<bool>(Record[4]);
R.TopLevelModuleMap = static_cast<bool>(Record[5]);
- R.Filename = Blob;
+ R.Filename = std::string(Blob);
ResolveImportedPath(F, R.Filename);
Expected<llvm::BitstreamEntry> MaybeEntry = Cursor.advance();
@@ -2309,7 +2309,7 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
if (File == nullptr && !F.OriginalDir.empty() && !F.BaseDirectory.empty() &&
F.OriginalDir != F.BaseDirectory) {
std::string Resolved = resolveFileRelativeToOriginalDir(
- Filename, F.OriginalDir, F.BaseDirectory);
+ std::string(Filename), F.OriginalDir, F.BaseDirectory);
if (!Resolved.empty())
if (auto FE = FileMgr.getFile(Resolved))
File = *FE;
@@ -2844,7 +2844,7 @@ ASTReader::ReadControlBlock(ModuleFile &F,
case ORIGINAL_FILE:
F.OriginalSourceFileID = FileID::get(Record[0]);
- F.ActualOriginalSourceFileName = Blob;
+ F.ActualOriginalSourceFileName = std::string(Blob);
F.OriginalSourceFileName = F.ActualOriginalSourceFileName;
ResolveImportedPath(F, F.OriginalSourceFileName);
break;
@@ -2854,11 +2854,11 @@ ASTReader::ReadControlBlock(ModuleFile &F,
break;
case ORIGINAL_PCH_DIR:
- F.OriginalDir = Blob;
+ F.OriginalDir = std::string(Blob);
break;
case MODULE_NAME:
- F.ModuleName = Blob;
+ F.ModuleName = std::string(Blob);
Diag(diag::remark_module_import)
<< F.ModuleName << F.FileName << (ImportedBy ? true : false)
<< (ImportedBy ? StringRef(ImportedBy->ModuleName) : StringRef());
@@ -2897,9 +2897,9 @@ ASTReader::ReadControlBlock(ModuleFile &F,
return OutOfDate;
}
}
- F.BaseDirectory = M->Directory->getName();
+ F.BaseDirectory = std::string(M->Directory->getName());
} else {
- F.BaseDirectory = Blob;
+ F.BaseDirectory = std::string(Blob);
}
break;
}
@@ -3819,7 +3819,7 @@ void ASTReader::ReadModuleOffsetMap(ModuleFile &F) const {
if (!OM) {
std::string Msg =
"SourceLocation remap refers to unknown module, cannot find ";
- Msg.append(Name);
+ Msg.append(std::string(Name));
Error(Msg);
return;
}
@@ -5071,13 +5071,11 @@ namespace {
SimplePCHValidator(const LangOptions &ExistingLangOpts,
const TargetOptions &ExistingTargetOpts,
const PreprocessorOptions &ExistingPPOpts,
- StringRef ExistingModuleCachePath,
- FileManager &FileMgr)
- : ExistingLangOpts(ExistingLangOpts),
- ExistingTargetOpts(ExistingTargetOpts),
- ExistingPPOpts(ExistingPPOpts),
- ExistingModuleCachePath(ExistingModuleCachePath),
- FileMgr(FileMgr) {}
+ StringRef ExistingModuleCachePath, FileManager &FileMgr)
+ : ExistingLangOpts(ExistingLangOpts),
+ ExistingTargetOpts(ExistingTargetOpts),
+ ExistingPPOpts(ExistingPPOpts),
+ ExistingModuleCachePath(ExistingModuleCachePath), FileMgr(FileMgr) {}
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
bool AllowCompatibleDifferences) override {
@@ -5221,7 +5219,7 @@ bool ASTReader::readASTFileControlBlock(
Listener.ReadModuleName(Blob);
break;
case MODULE_DIRECTORY:
- ModuleDir = Blob;
+ ModuleDir = std::string(Blob);
break;
case MODULE_MAP_FILE: {
unsigned Idx = 0;
@@ -5273,7 +5271,7 @@ bool ASTReader::readASTFileControlBlock(
break;
case INPUT_FILE:
bool Overridden = static_cast<bool>(Record[3]);
- std::string Filename = Blob;
+ std::string Filename = std::string(Blob);
ResolveImportedPath(Filename, ModuleDir);
shouldContinue = Listener.visitInputFile(
Filename, isSystemFile, Overridden, /*IsExplicitModule*/false);
@@ -5539,7 +5537,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
}
case SUBMODULE_UMBRELLA_HEADER: {
- std::string Filename = Blob;
+ std::string Filename = std::string(Blob);
ResolveImportedPath(F, Filename);
if (auto Umbrella = PP.getFileManager().getFile(Filename)) {
if (!CurrentModule->getUmbrellaHeader())
@@ -5572,7 +5570,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
break;
case SUBMODULE_UMBRELLA_DIR: {
- std::string Dirname = Blob;
+ std::string Dirname = std::string(Blob);
ResolveImportedPath(F, Dirname);
if (auto Umbrella = PP.getFileManager().getDirectory(Dirname)) {
if (!CurrentModule->getUmbrellaDir())
@@ -5642,7 +5640,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
case SUBMODULE_LINK_LIBRARY:
ModMap.resolveLinkAsDependencies(CurrentModule);
CurrentModule->LinkLibraries.push_back(
- Module::LinkLibrary(Blob, Record[0]));
+ Module::LinkLibrary(std::string(Blob), Record[0]));
break;
case SUBMODULE_CONFIG_MACRO:
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 79f7d57..47aea9a 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1132,7 +1132,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
BaseDirectory.assign(BaseDir.begin(), BaseDir.end());
} else if (!isysroot.empty()) {
// Write out paths relative to the sysroot if possible.
- BaseDirectory = isysroot;
+ BaseDirectory = std::string(isysroot);
}
// Module map file
diff --git a/clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
index 20f3008..6344926 100644
--- a/clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
@@ -103,7 +103,7 @@ void AnalyzerStatsChecker::checkEndAnalysis(ExplodedGraph &G,
NumBlocksUnreachable += unreachable;
NumBlocks += total;
- std::string NameOfRootFunction = output.str();
+ std::string NameOfRootFunction = std::string(output.str());
output << " -> Total CFGBlocks: " << total << " | Unreachable CFGBlocks: "
<< unreachable << " | Exhausted Block: "
diff --git a/clang/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
index 01f5b9c..f7cee71 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
@@ -57,7 +57,7 @@ void CXXSelfAssignmentChecker::checkBeginFunction(CheckerContext &C) const {
SmallString<256> Msg;
llvm::raw_svector_ostream Out(Msg);
Out << "Assuming " << MD->getParamDecl(0)->getName() << " == *this";
- return Out.str();
+ return std::string(Out.str());
});
C.addTransition(SelfAssignState, SelfAssignTag);
@@ -67,7 +67,7 @@ void CXXSelfAssignmentChecker::checkBeginFunction(CheckerContext &C) const {
SmallString<256> Msg;
llvm::raw_svector_ostream Out(Msg);
Out << "Assuming " << MD->getParamDecl(0)->getName() << " != *this";
- return Out.str();
+ return std::string(Out.str());
});
C.addTransition(NonSelfAssignState, NonSelfAssignTag);
}
diff --git a/clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
index cc1c9a6..1c3ff3e 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
@@ -129,7 +129,7 @@ static const NoteTag *getNoteTag(CheckerContext &C,
Out << ' ' << (CastSucceeds ? "is a" : "is not a") << " '" << CastToName
<< '\'';
- return Out.str();
+ return std::string(Out.str());
},
/*IsPrunable=*/true);
}
diff --git a/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp b/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
index 48fee4a..3b336d6 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
@@ -99,10 +99,10 @@ void PlacementNewChecker::checkPreStmt(const CXXNewExpr *NE,
if (SizeOfPlaceCI->getValue() < SizeOfTargetCI->getValue()) {
if (ExplodedNode *N = C.generateErrorNode(State)) {
- std::string Msg =
+ std::string Msg = std::string(
llvm::formatv("Storage provided to placement new is only {0} bytes, "
"whereas the allocated type requires {1} bytes",
- SizeOfPlaceCI->getValue(), SizeOfTargetCI->getValue());
+ SizeOfPlaceCI->getValue(), SizeOfTargetCI->getValue()));
auto R = std::make_unique<PathSensitiveBugReport>(BT, Msg, N);
bugreporter::trackExpressionValue(N, Place, *R);
diff --git a/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
index 302d5bb..fd6eabe 100644
--- a/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -396,7 +396,7 @@ void GenericTaintChecker::parseConfiguration(CheckerManager &Mgr,
template <typename T>
auto GenericTaintChecker::findFunctionInConfig(const ConfigDataMap<T> &Map,
const FunctionData &FData) {
- auto Range = Map.equal_range(FData.Name);
+ auto Range = Map.equal_range(std::string(FData.Name));
auto It =
std::find_if(Range.first, Range.second, [&FData](const auto &Entry) {
const auto &Value = Entry.second;
diff --git a/clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
index d73e2eb..2259c12 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
@@ -217,7 +217,7 @@ void MIGChecker::checkPostCall(const CallEvent &Call, CheckerContext &C) const {
llvm::raw_svector_ostream OS(Str);
OS << "Value passed through parameter '" << PVD->getName()
<< "\' is deallocated";
- return OS.str();
+ return std::string(OS.str());
});
C.addTransition(State->set<ReleasedParameter>(true), T);
}
diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index 0930638..6c89e7d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -782,7 +782,7 @@ private:
os << "Reallocation of " << ArgIndex << llvm::getOrdinalSuffix(ArgIndex)
<< " parameter failed";
- return os.str();
+ return std::string(os.str());
}
std::string getMessageForReturn(const CallExpr *CallExpr) override {
diff --git a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
index 9853758..cfad476 100644
--- a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
@@ -84,7 +84,7 @@ static std::string getPrettyTypeName(QualType QT) {
QualType PT = QT->getPointeeType();
if (!PT.isNull() && !QT->getAs<TypedefType>())
if (const auto *RD = PT->getAsCXXRecordDecl())
- return RD->getName();
+ return std::string(RD->getName());
return QT.getAsString();
}
diff --git a/clang/lib/StaticAnalyzer/Checkers/ReturnValueChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/ReturnValueChecker.cpp
index 103208d8..7352f3e 100644
--- a/clang/lib/StaticAnalyzer/Checkers/ReturnValueChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/ReturnValueChecker.cpp
@@ -105,7 +105,7 @@ void ReturnValueChecker::checkPostCall(const CallEvent &Call,
Out << '\'' << Name << "' returns "
<< (ExpectedValue ? "true" : "false");
- return Out.str();
+ return std::string(Out.str());
},
/*IsPrunable=*/true);
@@ -154,7 +154,7 @@ void ReturnValueChecker::checkEndFunction(const ReturnStmt *RS,
Out << '\'' << Name << "' returns "
<< (ExpectedValue ? "false" : "true");
- return Out.str();
+ return std::string(Out.str());
},
/*IsPrunable=*/false);
diff --git a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
index 020df8a..14f5514 100644
--- a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
@@ -602,7 +602,7 @@ std::string clang::ento::getVariableName(const FieldDecl *Field) {
llvm_unreachable("No other capture type is expected!");
}
- return Field->getName();
+ return std::string(Field->getName());
}
void ento::registerUninitializedObjectChecker(CheckerManager &Mgr) {
@@ -617,7 +617,7 @@ void ento::registerUninitializedObjectChecker(CheckerManager &Mgr) {
ChOpts.CheckPointeeInitialization = AnOpts.getCheckerBooleanOption(
Chk, "CheckPointeeInitialization");
ChOpts.IgnoredRecordsWithFieldPattern =
- AnOpts.getCheckerStringOption(Chk, "IgnoreRecordsWithField");
+ std::string(AnOpts.getCheckerStringOption(Chk, "IgnoreRecordsWithField"));
ChOpts.IgnoreGuardedFields =
AnOpts.getCheckerBooleanOption(Chk, "IgnoreGuardedFields");
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index 0525b5c..363e5fb 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -813,7 +813,7 @@ public:
const SourceManager &SMgr = BRC.getSourceManager();
if (auto Loc = matchAssignment(N)) {
if (isFunctionMacroExpansion(*Loc, SMgr)) {
- std::string MacroName = getMacroName(*Loc, BRC);
+ std::string MacroName = std::string(getMacroName(*Loc, BRC));
SourceLocation BugLoc = BugPoint->getStmt()->getBeginLoc();
if (!BugLoc.isMacroID() || getMacroName(BugLoc, BRC) != MacroName)
BR.markInvalid(getTag(), MacroName.c_str());
@@ -1735,10 +1735,9 @@ constructDebugPieceForTrackedCondition(const Expr *Cond,
!BRC.getAnalyzerOptions().ShouldTrackConditionsDebug)
return nullptr;
- std::string ConditionText = Lexer::getSourceText(
+ std::string ConditionText = std::string(Lexer::getSourceText(
CharSourceRange::getTokenRange(Cond->getSourceRange()),
- BRC.getSourceManager(),
- BRC.getASTContext().getLangOpts());
+ BRC.getSourceManager(), BRC.getASTContext().getLangOpts()));
return std::make_shared<PathDiagnosticEventPiece>(
PathDiagnosticLocation::createBegin(
@@ -2494,7 +2493,7 @@ PathDiagnosticPieceRef ConditionBRVisitor::VisitTrueTest(
Out << WillBeUsedForACondition;
// Convert 'field ...' to 'Field ...' if it is a MemberExpr.
- std::string Message = Out.str();
+ std::string Message = std::string(Out.str());
Message[0] = toupper(Message[0]);
// If we know the value create a pop-up note to the value part of 'BExpr'.
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index b542cf2..eb32a32 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3161,7 +3161,8 @@ std::string ExprEngine::DumpGraph(bool trim, StringRef Filename) {
return DumpGraph(Src, Filename);
} else {
return llvm::WriteGraph(&G, "ExprEngine", /*ShortNames=*/false,
- /*Title=*/"Exploded Graph", /*Filename=*/Filename);
+ /*Title=*/"Exploded Graph",
+ /*Filename=*/std::string(Filename));
}
#endif
llvm::errs() << "Warning: dumping graph requires assertions" << "\n";
@@ -3179,7 +3180,7 @@ std::string ExprEngine::DumpGraph(ArrayRef<const ExplodedNode*> Nodes,
return llvm::WriteGraph(TrimmedG.get(), "TrimmedExprEngine",
/*ShortNames=*/false,
/*Title=*/"Trimmed Exploded Graph",
- /*Filename=*/Filename);
+ /*Filename=*/std::string(Filename));
}
#endif
llvm::errs() << "Warning: dumping graph requires assertions" << "\n";
diff --git a/clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp b/clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
index 1a09a52..6bc9375 100644
--- a/clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
+++ b/clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
@@ -130,10 +130,10 @@ static internal::Matcher<Stmt> hasSuspiciousStmt(StringRef NodeName) {
// Escaping and not known mutation of the loop counter is handled
// by exclusion of assigning and address-of operators and
// pass-by-ref function calls on the loop counter from the body.
- changeIntBoundNode(equalsBoundNode(NodeName)),
- callByRef(equalsBoundNode(NodeName)),
- getAddrTo(equalsBoundNode(NodeName)),
- assignedToRef(equalsBoundNode(NodeName)))));
+ changeIntBoundNode(equalsBoundNode(std::string(NodeName))),
+ callByRef(equalsBoundNode(std::string(NodeName))),
+ getAddrTo(equalsBoundNode(std::string(NodeName))),
+ assignedToRef(equalsBoundNode(std::string(NodeName))))));
}
static internal::Matcher<Stmt> forLoopMatcher() {
diff --git a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
index 3a3942a..babd140 100644
--- a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -939,7 +939,7 @@ getExpandedMacro(SourceLocation MacroLoc, const Preprocessor &PP,
std::string MacroName = getMacroNameAndPrintExpansion(
Printer, MacroLoc, *PPToUse, MacroArgMap{}, AlreadyProcessedTokens);
- return { MacroName, OS.str() };
+ return {MacroName, std::string(OS.str())};
}
static std::string getMacroNameAndPrintExpansion(
diff --git a/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
index 12332aa..fb7758b 100644
--- a/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
@@ -322,7 +322,7 @@ static json::Object createRule(const PathDiagnostic &Diag) {
{"name", CheckName},
{"id", CheckName}};
- std::string RuleURI = getRuleHelpURIStr(CheckName);
+ std::string RuleURI = std::string(getRuleHelpURIStr(CheckName));
if (!RuleURI.empty())
Ret["helpUri"] = RuleURI;
diff --git a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
index fea8100..9f69e53 100644
--- a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -68,8 +68,9 @@ void ento::createPlistHTMLDiagnosticConsumer(
AnalyzerOptions &AnalyzerOpts, PathDiagnosticConsumers &C,
const std::string &prefix, const Preprocessor &PP,
const cross_tu::CrossTranslationUnitContext &CTU) {
- createHTMLDiagnosticConsumer(AnalyzerOpts, C,
- llvm::sys::path::parent_path(prefix), PP, CTU);
+ createHTMLDiagnosticConsumer(
+ AnalyzerOpts, C, std::string(llvm::sys::path::parent_path(prefix)), PP,
+ CTU);
createPlistMultiFileDiagnosticConsumer(AnalyzerOpts, C, prefix, PP, CTU);
}
diff --git a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
index f5c0528..2f713a1 100644
--- a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
+++ b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
@@ -316,7 +316,8 @@ static void insertAndValidate(StringRef FullName,
std::string FullOption = (FullName + ":" + Option.OptionName).str();
- auto It = AnOpts.Config.insert({FullOption, Option.DefaultValStr});
+ auto It =
+ AnOpts.Config.insert({FullOption, std::string(Option.DefaultValStr)});
// Insertation was successful -- CmdLineOption's constructor will validate
// whether values received from plugins or TableGen files are correct.
@@ -337,7 +338,7 @@ static void insertAndValidate(StringRef FullName,
<< FullOption << "a boolean value";
}
- It.first->setValue(Option.DefaultValStr);
+ It.first->setValue(std::string(Option.DefaultValStr));
}
return;
}
@@ -351,7 +352,7 @@ static void insertAndValidate(StringRef FullName,
<< FullOption << "an integer value";
}
- It.first->setValue(Option.DefaultValStr);
+ It.first->setValue(std::string(Option.DefaultValStr));
}
return;
}
diff --git a/clang/lib/Tooling/ASTDiff/ASTDiff.cpp b/clang/lib/Tooling/ASTDiff/ASTDiff.cpp
index 34e56f6..df00183 100644
--- a/clang/lib/Tooling/ASTDiff/ASTDiff.cpp
+++ b/clang/lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -398,7 +398,7 @@ static const DeclContext *getEnclosingDeclContext(ASTContext &AST,
static std::string getInitializerValue(const CXXCtorInitializer *Init,
const PrintingPolicy &TypePP) {
if (Init->isAnyMemberInitializer())
- return Init->getAnyMember()->getName();
+ return std::string(Init->getAnyMember()->getName());
if (Init->isBaseInitializer())
return QualType(Init->getBaseClass(), 0).getAsString(TypePP);
if (Init->isDelegatingInitializer())
@@ -435,36 +435,36 @@ std::string SyntaxTree::Impl::getDeclValue(const Decl *D) const {
T->getTypeForDecl()->getCanonicalTypeInternal().getAsString(TypePP) +
";";
if (auto *U = dyn_cast<UsingDirectiveDecl>(D))
- return U->getNominatedNamespace()->getName();
+ return std::string(U->getNominatedNamespace()->getName());
if (auto *A = dyn_cast<AccessSpecDecl>(D)) {
CharSourceRange Range(A->getSourceRange(), false);
- return Lexer::getSourceText(Range, AST.getSourceManager(),
- AST.getLangOpts());
+ return std::string(
+ Lexer::getSourceText(Range, AST.getSourceManager(), AST.getLangOpts()));
}
return Value;
}
std::string SyntaxTree::Impl::getStmtValue(const Stmt *S) const {
if (auto *U = dyn_cast<UnaryOperator>(S))
- return UnaryOperator::getOpcodeStr(U->getOpcode());
+ return std::string(UnaryOperator::getOpcodeStr(U->getOpcode()));
if (auto *B = dyn_cast<BinaryOperator>(S))
- return B->getOpcodeStr();
+ return std::string(B->getOpcodeStr());
if (auto *M = dyn_cast<MemberExpr>(S))
return getRelativeName(M->getMemberDecl());
if (auto *I = dyn_cast<IntegerLiteral>(S)) {
SmallString<256> Str;
I->getValue().toString(Str, /*Radix=*/10, /*Signed=*/false);
- return Str.str();
+ return std::string(Str.str());
}
if (auto *F = dyn_cast<FloatingLiteral>(S)) {
SmallString<256> Str;
F->getValue().toString(Str);
- return Str.str();
+ return std::string(Str.str());
}
if (auto *D = dyn_cast<DeclRefExpr>(S))
return getRelativeName(D->getDecl(), getEnclosingDeclContext(AST, S));
if (auto *String = dyn_cast<StringLiteral>(S))
- return String->getString();
+ return std::string(String->getString());
if (auto *B = dyn_cast<CXXBoolLiteralExpr>(S))
return B->getValue() ? "true" : "false";
return "";
diff --git a/clang/lib/Tooling/CompilationDatabase.cpp b/clang/lib/Tooling/CompilationDatabase.cpp
index c453e8d..3590f19 100644
--- a/clang/lib/Tooling/CompilationDatabase.cpp
+++ b/clang/lib/Tooling/CompilationDatabase.cpp
@@ -164,7 +164,7 @@ private:
case driver::Action::InputClass:
if (Collect) {
const auto *IA = cast<driver::InputAction>(A);
- Inputs.push_back(IA->getInputArg().getSpelling());
+ Inputs.push_back(std::string(IA->getInputArg().getSpelling()));
}
break;
@@ -233,7 +233,7 @@ std::string GetClangToolCommand() {
SmallString<128> ClangToolPath;
ClangToolPath = llvm::sys::path::parent_path(ClangExecutable);
llvm::sys::path::append(ClangToolPath, "clang-tool");
- return ClangToolPath.str();
+ return std::string(ClangToolPath.str());
}
} // namespace
@@ -387,8 +387,8 @@ FixedCompilationDatabase(Twine Directory, ArrayRef<std::string> CommandLine) {
std::vector<CompileCommand>
FixedCompilationDatabase::getCompileCommands(StringRef FilePath) const {
std::vector<CompileCommand> Result(CompileCommands);
- Result[0].CommandLine.push_back(FilePath);
- Result[0].Filename = FilePath;
+ Result[0].CommandLine.push_back(std::string(FilePath));
+ Result[0].Filename = std::string(FilePath);
return Result;
}
diff --git a/clang/lib/Tooling/Core/Diagnostic.cpp b/clang/lib/Tooling/Core/Diagnostic.cpp
index 235bd7f..34677bf 100644
--- a/clang/lib/Tooling/Core/Diagnostic.cpp
+++ b/clang/lib/Tooling/Core/Diagnostic.cpp
@@ -25,7 +25,7 @@ DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message,
SourceLocation Loc)
: Message(Message), FileOffset(0) {
assert(Loc.isValid() && Loc.isFileID());
- FilePath = Sources.getFilename(Loc);
+ FilePath = std::string(Sources.getFilename(Loc));
// Don't store offset in the scratch space. It doesn't tell anything to the
// user. Moreover, it depends on the history of macro expansions and thus
diff --git a/clang/lib/Tooling/Core/Lookup.cpp b/clang/lib/Tooling/Core/Lookup.cpp
index 735a5df..624a55c 100644
--- a/clang/lib/Tooling/Core/Lookup.cpp
+++ b/clang/lib/Tooling/Core/Lookup.cpp
@@ -129,7 +129,7 @@ static std::string disambiguateSpellingInScope(StringRef Spelling,
assert(QName.startswith("::"));
assert(QName.endswith(Spelling));
if (Spelling.startswith("::"))
- return Spelling;
+ return std::string(Spelling);
auto UnspelledSpecifier = QName.drop_back(Spelling.size());
llvm::SmallVector<llvm::StringRef, 2> UnspelledScopes;
@@ -168,7 +168,7 @@ static std::string disambiguateSpellingInScope(StringRef Spelling,
};
// Add more qualifiers until the spelling is not ambiguous.
- std::string Disambiguated = Spelling;
+ std::string Disambiguated = std::string(Spelling);
while (IsAmbiguousSpelling(Disambiguated)) {
if (UnspelledScopes.empty()) {
Disambiguated = "::" + Disambiguated;
@@ -206,8 +206,9 @@ std::string tooling::replaceNestedName(const NestedNameSpecifier *Use,
!usingFromDifferentCanonicalNamespace(FromDecl->getDeclContext(),
UseContext)) {
auto Pos = ReplacementString.rfind("::");
- return Pos != StringRef::npos ? ReplacementString.substr(Pos + 2)
- : ReplacementString;
+ return std::string(Pos != StringRef::npos
+ ? ReplacementString.substr(Pos + 2)
+ : ReplacementString);
}
// We did not match this because of a using statement, so we will need to
// figure out how good a namespace match we have with our destination type.
diff --git a/clang/lib/Tooling/Core/Replacement.cpp b/clang/lib/Tooling/Core/Replacement.cpp
index 9ed0365..ab8e205 100644
--- a/clang/lib/Tooling/Core/Replacement.cpp
+++ b/clang/lib/Tooling/Core/Replacement.cpp
@@ -46,8 +46,8 @@ Replacement::Replacement() : FilePath(InvalidLocation) {}
Replacement::Replacement(StringRef FilePath, unsigned Offset, unsigned Length,
StringRef ReplacementText)
- : FilePath(FilePath), ReplacementRange(Offset, Length),
- ReplacementText(ReplacementText) {}
+ : FilePath(std::string(FilePath)), ReplacementRange(Offset, Length),
+ ReplacementText(std::string(ReplacementText)) {}
Replacement::Replacement(const SourceManager &Sources, SourceLocation Start,
unsigned Length, StringRef ReplacementText) {
@@ -123,9 +123,9 @@ void Replacement::setFromSourceLocation(const SourceManager &Sources,
const std::pair<FileID, unsigned> DecomposedLocation =
Sources.getDecomposedLoc(Start);
const FileEntry *Entry = Sources.getFileEntryForID(DecomposedLocation.first);
- this->FilePath = Entry ? Entry->getName() : InvalidLocation;
+ this->FilePath = std::string(Entry ? Entry->getName() : InvalidLocation);
this->ReplacementRange = Range(DecomposedLocation.second, Length);
- this->ReplacementText = ReplacementText;
+ this->ReplacementText = std::string(ReplacementText);
}
// FIXME: This should go into the Lexer, but we need to figure out how
@@ -367,8 +367,8 @@ class MergedReplacement {
public:
MergedReplacement(const Replacement &R, bool MergeSecond, int D)
: MergeSecond(MergeSecond), Delta(D), FilePath(R.getFilePath()),
- Offset(R.getOffset() + (MergeSecond ? 0 : Delta)), Length(R.getLength()),
- Text(R.getReplacementText()) {
+ Offset(R.getOffset() + (MergeSecond ? 0 : Delta)),
+ Length(R.getLength()), Text(std::string(R.getReplacementText())) {
Delta += MergeSecond ? 0 : Text.size() - Length;
DeltaFirst = MergeSecond ? Text.size() - Length : 0;
}
diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
index 31b8346..16040c2 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -37,7 +37,7 @@ llvm::Expected<std::string> DependencyScanningTool::getDependencyFile(
StringRef File) override {
if (!this->Opts)
this->Opts = std::make_unique<DependencyOutputOptions>(Opts);
- Dependencies.push_back(File);
+ Dependencies.push_back(std::string(File));
}
void handleModuleDependency(ModuleDeps MD) override {
@@ -105,7 +105,7 @@ DependencyScanningTool::getFullDependencies(
void handleFileDependency(const DependencyOutputOptions &Opts,
StringRef File) override {
- Dependencies.push_back(File);
+ Dependencies.push_back(std::string(File));
}
void handleModuleDependency(ModuleDeps MD) override {
diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
index 73135dd..32bbc57 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -118,7 +118,7 @@ public:
.ExcludedConditionalDirectiveSkipMappings = PPSkipMappings;
}
- FileMgr->getFileSystemOpts().WorkingDir = WorkingDirectory;
+ FileMgr->getFileSystemOpts().WorkingDir = std::string(WorkingDirectory);
Compiler.setFileManager(FileMgr);
Compiler.createSourceManager(*FileMgr);
diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index 9d2d2a1..4f6eff7 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -85,7 +85,7 @@ void ModuleDepCollectorPP::FileChanged(SourceLocation Loc,
StringRef FileName =
llvm::sys::path::remove_leading_dotslash(File->getName());
- MDC.MainDeps.push_back(FileName);
+ MDC.MainDeps.push_back(std::string(FileName));
}
void ModuleDepCollectorPP::InclusionDirective(
@@ -96,7 +96,7 @@ void ModuleDepCollectorPP::InclusionDirective(
if (!File && !Imported) {
// This is a non-modular include that HeaderSearch failed to find. Add it
// here as `FileChanged` will never see it.
- MDC.MainDeps.push_back(FileName);
+ MDC.MainDeps.push_back(std::string(FileName));
}
handleImport(Imported);
}
@@ -118,8 +118,8 @@ void ModuleDepCollectorPP::handleImport(const Module *Imported) {
void ModuleDepCollectorPP::EndOfMainFile() {
FileID MainFileID = Instance.getSourceManager().getMainFileID();
- MDC.MainFile =
- Instance.getSourceManager().getFileEntryForID(MainFileID)->getName();
+ MDC.MainFile = std::string(
+ Instance.getSourceManager().getFileEntryForID(MainFileID)->getName());
for (const Module *M : DirectDeps) {
handleTopLevelModule(M);
@@ -148,9 +148,9 @@ void ModuleDepCollectorPP::handleTopLevelModule(const Module *M) {
.getModuleMap()
.getContainingModuleMapFile(M);
- MD.ClangModuleMapFile = ModuleMap ? ModuleMap->getName() : "";
+ MD.ClangModuleMapFile = std::string(ModuleMap ? ModuleMap->getName() : "");
MD.ModuleName = M->getFullModuleName();
- MD.ImplicitModulePCMPath = M->getASTFile()->getName();
+ MD.ImplicitModulePCMPath = std::string(M->getASTFile()->getName());
MD.ContextHash = MDC.ContextHash;
serialization::ModuleFile *MF =
MDC.Instance.getASTReader()->getModuleManager().lookup(M->getASTFile());
@@ -179,7 +179,7 @@ void ModuleDepCollectorPP::addModuleDep(
if (Import->getTopLevelModule() != M->getTopLevelModule()) {
if (AddedModules.insert(Import->getTopLevelModule()).second)
MD.ClangModuleDeps.push_back(
- {Import->getTopLevelModuleName(),
+ {std::string(Import->getTopLevelModuleName()),
Instance.getInvocation().getModuleHash()});
handleTopLevelModule(Import->getTopLevelModule());
}
diff --git a/clang/lib/Tooling/FileMatchTrie.cpp b/clang/lib/Tooling/FileMatchTrie.cpp
index 7df5a16..88dea6b 100644
--- a/clang/lib/Tooling/FileMatchTrie.cpp
+++ b/clang/lib/Tooling/FileMatchTrie.cpp
@@ -63,7 +63,7 @@ public:
return;
if (Path.empty()) {
// This is an empty leaf. Store NewPath and return.
- Path = NewPath;
+ Path = std::string(NewPath);
return;
}
if (Children.empty()) {
diff --git a/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp b/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
index 37a0816..818eb59 100644
--- a/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ b/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -319,7 +319,7 @@ HeaderIncludes::insert(llvm::StringRef IncludeName, bool IsAngled) const {
(!IsAngled && StringRef(Inc.Name).startswith("\"")))
return llvm::None;
std::string Quoted =
- llvm::formatv(IsAngled ? "<{0}>" : "\"{0}\"", IncludeName);
+ std::string(llvm::formatv(IsAngled ? "<{0}>" : "\"{0}\"", IncludeName));
StringRef QuotedName = Quoted;
int Priority = Categories.getIncludePriority(
QuotedName, /*CheckMainHeader=*/FirstIncludeOffset < 0);
@@ -336,7 +336,8 @@ HeaderIncludes::insert(llvm::StringRef IncludeName, bool IsAngled) const {
}
}
assert(InsertOffset <= Code.size());
- std::string NewInclude = llvm::formatv("#include {0}\n", QuotedName);
+ std::string NewInclude =
+ std::string(llvm::formatv("#include {0}\n", QuotedName));
// When inserting headers at end of the code, also append '\n' to the code
// if it does not end with '\n'.
// FIXME: when inserting multiple #includes at the end of code, only one
diff --git a/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp b/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
index 2cc819a..db4efc0 100644
--- a/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ b/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -203,7 +203,7 @@ struct TransferableCommand {
// Produce a CompileCommand for \p filename, based on this one.
CompileCommand transferTo(StringRef Filename) const {
CompileCommand Result = Cmd;
- Result.Filename = Filename;
+ Result.Filename = std::string(Filename);
bool TypeCertain;
auto TargetType = guessType(Filename, &TypeCertain);
// If the filename doesn't determine the language (.h), transfer with -x.
@@ -217,7 +217,7 @@ struct TransferableCommand {
if (ClangCLMode) {
const StringRef Flag = toCLFlag(TargetType);
if (!Flag.empty())
- Result.CommandLine.push_back(Flag);
+ Result.CommandLine.push_back(std::string(Flag));
} else {
Result.CommandLine.push_back("-x");
Result.CommandLine.push_back(types::getTypeName(TargetType));
@@ -230,7 +230,7 @@ struct TransferableCommand {
llvm::Twine(ClangCLMode ? "/std:" : "-std=") +
LangStandard::getLangStandardForKind(Std).getName()).str());
}
- Result.CommandLine.push_back(Filename);
+ Result.CommandLine.push_back(std::string(Filename));
Result.Heuristic = "inferred from " + Cmd.Filename;
return Result;
}
diff --git a/clang/lib/Tooling/JSONCompilationDatabase.cpp b/clang/lib/Tooling/JSONCompilationDatabase.cpp
index 04dd4db..4af361f 100644
--- a/clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ b/clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -305,7 +305,7 @@ nodeToCommandLine(JSONCommandLineSyntax Syntax,
Arguments = unescapeCommandLine(Syntax, Nodes[0]->getValue(Storage));
else
for (const auto *Node : Nodes)
- Arguments.push_back(Node->getValue(Storage));
+ Arguments.push_back(std::string(Node->getValue(Storage)));
// There may be multiple wrappers: using distcc and ccache together is common.
while (unwrapCommand(Arguments))
;
diff --git a/clang/lib/Tooling/Refactoring/AtomicChange.cpp b/clang/lib/Tooling/Refactoring/AtomicChange.cpp
index 4cf6330..3be15b7 100644
--- a/clang/lib/Tooling/Refactoring/AtomicChange.cpp
+++ b/clang/lib/Tooling/Refactoring/AtomicChange.cpp
@@ -200,7 +200,7 @@ AtomicChange::AtomicChange(const SourceManager &SM,
FullKeyPosition.getSpellingLoc().getDecomposedLoc();
const FileEntry *FE = SM.getFileEntryForID(FileIDAndOffset.first);
assert(FE && "Cannot create AtomicChange with invalid location.");
- FilePath = FE->getName();
+ FilePath = std::string(FE->getName());
Key = FilePath + ":" + std::to_string(FileIDAndOffset.second);
}
@@ -284,11 +284,11 @@ llvm::Error AtomicChange::insert(const SourceManager &SM, SourceLocation Loc,
}
void AtomicChange::addHeader(llvm::StringRef Header) {
- InsertedHeaders.push_back(Header);
+ InsertedHeaders.push_back(std::string(Header));
}
void AtomicChange::removeHeader(llvm::StringRef Header) {
- RemovedHeaders.push_back(Header);
+ RemovedHeaders.push_back(std::string(Header));
}
llvm::Expected<std::string>
diff --git a/clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp b/clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
index b063491..7259860 100644
--- a/clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
+++ b/clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
@@ -170,7 +170,8 @@ static void convertChangesToFileReplacements(
std::map<std::string, tooling::Replacements> *FileToReplaces) {
for (const auto &AtomicChange : AtomicChanges) {
for (const auto &Replace : AtomicChange.getReplacements()) {
- llvm::Error Err = (*FileToReplaces)[Replace.getFilePath()].add(Replace);
+ llvm::Error Err =
+ (*FileToReplaces)[std::string(Replace.getFilePath())].add(Replace);
if (Err) {
llvm::errs() << "Renaming failed in " << Replace.getFilePath() << "! "
<< llvm::toString(std::move(Err)) << "\n";
diff --git a/clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp b/clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
index 97b4d10..4d749d3 100644
--- a/clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ b/clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -537,7 +537,7 @@ createRenameAtomicChanges(llvm::ArrayRef<std::string> USRs,
// Get the name without prefix qualifiers from NewName.
size_t LastColonPos = NewName.find_last_of(':');
if (LastColonPos != std::string::npos)
- ReplacedName = NewName.substr(LastColonPos + 1);
+ ReplacedName = std::string(NewName.substr(LastColonPos + 1));
} else {
if (RenameInfo.FromDecl && RenameInfo.Context) {
if (!llvm::isa<clang::TranslationUnitDecl>(
diff --git a/clang/lib/Tooling/RefactoringCallbacks.cpp b/clang/lib/Tooling/RefactoringCallbacks.cpp
index 919b83b..e3fc91a 100644
--- a/clang/lib/Tooling/RefactoringCallbacks.cpp
+++ b/clang/lib/Tooling/RefactoringCallbacks.cpp
@@ -50,8 +50,8 @@ public:
for (const auto &Callback : Refactoring.Callbacks) {
for (const auto &Replacement : Callback->getReplacements()) {
llvm::Error Err =
- Refactoring.FileToReplaces[Replacement.getFilePath()].add(
- Replacement);
+ Refactoring.FileToReplaces[std::string(Replacement.getFilePath())]
+ .add(Replacement);
if (Err) {
llvm::errs() << "Skipping replacement " << Replacement.toString()
<< " due to this error:\n"
@@ -83,7 +83,7 @@ static Replacement replaceStmtWithStmt(SourceManager &Sources, const Stmt &From,
}
ReplaceStmtWithText::ReplaceStmtWithText(StringRef FromId, StringRef ToText)
- : FromId(FromId), ToText(ToText) {}
+ : FromId(std::string(FromId)), ToText(std::string(ToText)) {}
void ReplaceStmtWithText::run(
const ast_matchers::MatchFinder::MatchResult &Result) {
@@ -101,7 +101,7 @@ void ReplaceStmtWithText::run(
}
ReplaceStmtWithStmt::ReplaceStmtWithStmt(StringRef FromId, StringRef ToId)
- : FromId(FromId), ToId(ToId) {}
+ : FromId(std::string(FromId)), ToId(std::string(ToId)) {}
void ReplaceStmtWithStmt::run(
const ast_matchers::MatchFinder::MatchResult &Result) {
@@ -121,7 +121,7 @@ void ReplaceStmtWithStmt::run(
ReplaceIfStmtWithItsBody::ReplaceIfStmtWithItsBody(StringRef Id,
bool PickTrueBranch)
- : Id(Id), PickTrueBranch(PickTrueBranch) {}
+ : Id(std::string(Id)), PickTrueBranch(PickTrueBranch) {}
void ReplaceIfStmtWithItsBody::run(
const ast_matchers::MatchFinder::MatchResult &Result) {
@@ -153,7 +153,7 @@ void ReplaceIfStmtWithItsBody::run(
ReplaceNodeWithTemplate::ReplaceNodeWithTemplate(
llvm::StringRef FromId, std::vector<TemplateElement> Template)
- : FromId(FromId), Template(std::move(Template)) {}
+ : FromId(std::string(FromId)), Template(std::move(Template)) {}
llvm::Expected<std::unique_ptr<ReplaceNodeWithTemplate>>
ReplaceNodeWithTemplate::create(StringRef FromId, StringRef ToTemplate) {
@@ -172,8 +172,8 @@ ReplaceNodeWithTemplate::create(StringRef FromId, StringRef ToTemplate) {
ToTemplate.substr(Index),
llvm::inconvertibleErrorCode());
}
- std::string SourceNodeName =
- ToTemplate.substr(Index + 2, EndOfIdentifier - Index - 2);
+ std::string SourceNodeName = std::string(
+ ToTemplate.substr(Index + 2, EndOfIdentifier - Index - 2));
ParsedTemplate.push_back(
TemplateElement{TemplateElement::Identifier, SourceNodeName});
Index = EndOfIdentifier + 1;
@@ -185,9 +185,9 @@ ReplaceNodeWithTemplate::create(StringRef FromId, StringRef ToTemplate) {
}
} else {
size_t NextIndex = ToTemplate.find('$', Index + 1);
- ParsedTemplate.push_back(
- TemplateElement{TemplateElement::Literal,
- ToTemplate.substr(Index, NextIndex - Index)});
+ ParsedTemplate.push_back(TemplateElement{
+ TemplateElement::Literal,
+ std::string(ToTemplate.substr(Index, NextIndex - Index))});
Index = NextIndex;
}
}
diff --git a/clang/lib/Tooling/Syntax/BuildTree.cpp b/clang/lib/Tooling/Syntax/BuildTree.cpp
index aa88447..2430394 100644
--- a/clang/lib/Tooling/Syntax/BuildTree.cpp
+++ b/clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -243,9 +243,9 @@ private:
? (std::next(It)->first - It->first)
: A.tokenBuffer().expandedTokens().end() - It->first;
- R += llvm::formatv("- '{0}' covers '{1}'+{2} tokens\n",
- It->second.Node->kind(),
- It->first->text(A.sourceManager()), CoveredTokens);
+ R += std::string(llvm::formatv(
+ "- '{0}' covers '{1}'+{2} tokens\n", It->second.Node->kind(),
+ It->first->text(A.sourceManager()), CoveredTokens));
R += It->second.Node->dump(A);
}
return R;
diff --git a/clang/lib/Tooling/Syntax/Tokens.cpp b/clang/lib/Tooling/Syntax/Tokens.cpp
index 3df1c06..dca491e 100644
--- a/clang/lib/Tooling/Syntax/Tokens.cpp
+++ b/clang/lib/Tooling/Syntax/Tokens.cpp
@@ -183,8 +183,9 @@ llvm::ArrayRef<syntax::Token> TokenBuffer::spelledTokens(FileID FID) const {
}
std::string TokenBuffer::Mapping::str() const {
- return llvm::formatv("spelled tokens: [{0},{1}), expanded tokens: [{2},{3})",
- BeginSpelled, EndSpelled, BeginExpanded, EndExpanded);
+ return std::string(
+ llvm::formatv("spelled tokens: [{0},{1}), expanded tokens: [{2},{3})",
+ BeginSpelled, EndSpelled, BeginExpanded, EndExpanded));
}
llvm::Optional<llvm::ArrayRef<syntax::Token>>
@@ -604,19 +605,20 @@ TokenBuffer TokenCollector::consume() && {
}
std::string syntax::Token::str() const {
- return llvm::formatv("Token({0}, length = {1})", tok::getTokenName(kind()),
- length());
+ return std::string(llvm::formatv("Token({0}, length = {1})",
+ tok::getTokenName(kind()), length()));
}
std::string syntax::Token::dumpForTests(const SourceManager &SM) const {
- return llvm::formatv("{0} {1}", tok::getTokenName(kind()), text(SM));
+ return std::string(
+ llvm::formatv("{0} {1}", tok::getTokenName(kind()), text(SM)));
}
std::string TokenBuffer::dumpForTests() const {
auto PrintToken = [this](const syntax::Token &T) -> std::string {
if (T.kind() == tok::eof)
return "<eof>";
- return T.text(*SourceMgr);
+ return std::string(T.text(*SourceMgr));
};
auto DumpTokens = [this, &PrintToken](llvm::raw_ostream &OS,
diff --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp
index 4a0618c..be200f2 100644
--- a/clang/lib/Tooling/Tooling.cpp
+++ b/clang/lib/Tooling/Tooling.cpp
@@ -234,7 +234,7 @@ llvm::Expected<std::string> getAbsolutePath(llvm::vfs::FileSystem &FS,
if (auto EC = FS.makeAbsolute(AbsolutePath))
return llvm::errorCodeToError(EC);
llvm::sys::path::native(AbsolutePath);
- return AbsolutePath.str();
+ return std::string(AbsolutePath.str());
}
std::string getAbsolutePath(StringRef File) {
diff --git a/clang/lib/Tooling/Transformer/Stencil.cpp b/clang/lib/Tooling/Transformer/Stencil.cpp
index 00d8be7..9282063 100644
--- a/clang/lib/Tooling/Transformer/Stencil.cpp
+++ b/clang/lib/Tooling/Transformer/Stencil.cpp
@@ -81,14 +81,14 @@ struct SelectorData {
// A stencil operation to build a member access `e.m` or `e->m`, as appropriate.
struct AccessData {
AccessData(StringRef BaseId, Stencil Member)
- : BaseId(BaseId), Member(std::move(Member)) {}
+ : BaseId(std::string(BaseId)), Member(std::move(Member)) {}
std::string BaseId;
Stencil Member;
};
struct IfBoundData {
IfBoundData(StringRef Id, Stencil TrueStencil, Stencil FalseStencil)
- : Id(Id), TrueStencil(std::move(TrueStencil)),
+ : Id(std::string(Id)), TrueStencil(std::move(TrueStencil)),
FalseStencil(std::move(FalseStencil)) {}
std::string Id;
Stencil TrueStencil;
@@ -303,7 +303,7 @@ Stencil transformer::detail::makeStencil(RangeSelector Selector) {
}
Stencil transformer::text(StringRef Text) {
- return std::make_shared<StencilImpl<RawTextData>>(Text);
+ return std::make_shared<StencilImpl<RawTextData>>(std::string(Text));
}
Stencil transformer::selection(RangeSelector Selector) {
@@ -311,32 +311,32 @@ Stencil transformer::selection(RangeSelector Selector) {
}
Stencil transformer::dPrint(StringRef Id) {
- return std::make_shared<StencilImpl<DebugPrintNodeData>>(Id);
+ return std::make_shared<StencilImpl<DebugPrintNodeData>>(std::string(Id));
}
Stencil transformer::expression(llvm::StringRef Id) {
return std::make_shared<StencilImpl<UnaryOperationData>>(
- UnaryNodeOperator::Parens, Id);
+ UnaryNodeOperator::Parens, std::string(Id));
}
Stencil transformer::deref(llvm::StringRef ExprId) {
return std::make_shared<StencilImpl<UnaryOperationData>>(
- UnaryNodeOperator::Deref, ExprId);
+ UnaryNodeOperator::Deref, std::string(ExprId));
}
Stencil transformer::maybeDeref(llvm::StringRef ExprId) {
return std::make_shared<StencilImpl<UnaryOperationData>>(
- UnaryNodeOperator::MaybeDeref, ExprId);
+ UnaryNodeOperator::MaybeDeref, std::string(ExprId));
}
Stencil transformer::addressOf(llvm::StringRef ExprId) {
return std::make_shared<StencilImpl<UnaryOperationData>>(
- UnaryNodeOperator::AddressOf, ExprId);
+ UnaryNodeOperator::AddressOf, std::string(ExprId));
}
Stencil transformer::maybeAddressOf(llvm::StringRef ExprId) {
return std::make_shared<StencilImpl<UnaryOperationData>>(
- UnaryNodeOperator::MaybeAddressOf, ExprId);
+ UnaryNodeOperator::MaybeAddressOf, std::string(ExprId));
}
Stencil transformer::access(StringRef BaseId, Stencil Member) {
diff --git a/clang/tools/c-index-test/core_main.cpp b/clang/tools/c-index-test/core_main.cpp
index c402508..b03783b 100644
--- a/clang/tools/c-index-test/core_main.cpp
+++ b/clang/tools/c-index-test/core_main.cpp
@@ -260,10 +260,9 @@ static bool printSourceSymbolsFromModule(StringRef modulePath,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
CompilerInstance::createDiagnostics(new DiagnosticOptions());
std::unique_ptr<ASTUnit> AU = ASTUnit::LoadFromASTFile(
- modulePath, *pchRdr, ASTUnit::LoadASTOnly, Diags,
+ std::string(modulePath), *pchRdr, ASTUnit::LoadASTOnly, Diags,
FileSystemOpts, /*UseDebugInfo=*/false,
- /*OnlyLocalDecls=*/true, None,
- CaptureDiagsKind::None,
+ /*OnlyLocalDecls=*/true, None, CaptureDiagsKind::None,
/*AllowPCHWithCompilerErrors=*/true,
/*UserFilesAreVolatile=*/false);
if (!AU) {
diff --git a/clang/tools/clang-diff/ClangDiff.cpp b/clang/tools/clang-diff/ClangDiff.cpp
index 502409e..6d1f4b9 100644
--- a/clang/tools/clang-diff/ClangDiff.cpp
+++ b/clang/tools/clang-diff/ClangDiff.cpp
@@ -102,7 +102,7 @@ getAST(const std::unique_ptr<CompilationDatabase> &CommonCompilations,
}
}
addExtraArgs(Compilations);
- std::array<std::string, 1> Files = {{Filename}};
+ std::array<std::string, 1> Files = {{std::string(Filename)}};
ClangTool Tool(Compilations ? *Compilations : *CommonCompilations, Files);
std::vector<std::unique_ptr<ASTUnit>> ASTs;
Tool.buildASTs(ASTs);
diff --git a/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp b/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
index 0047aa4..dabcd6a 100644
--- a/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
+++ b/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
@@ -83,8 +83,8 @@ void MapExtDefNamesConsumer::addIfInMain(const DeclaratorDecl *DD,
assert(!LookupName->empty() && "Lookup name should be non-empty.");
if (CurrentFileName.empty()) {
- CurrentFileName =
- SM.getFileEntryForID(SM.getMainFileID())->tryGetRealPathName();
+ CurrentFileName = std::string(
+ SM.getFileEntryForID(SM.getMainFileID())->tryGetRealPathName());
if (CurrentFileName.empty())
CurrentFileName = "invalid_file";
}
diff --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index 70e546b..50788cb 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -57,7 +57,7 @@ public:
return "";
const std::string &ClangBinaryName =
- llvm::sys::path::filename(ClangBinaryPath);
+ std::string(llvm::sys::path::filename(ClangBinaryPath));
std::unique_lock<std::mutex> LockGuard(CacheLock);
const auto &CachedResourceDir = Cache.find(ClangBinaryPath);
@@ -170,7 +170,7 @@ llvm::cl::opt<bool> Verbose("v", llvm::cl::Optional,
static std::string getObjFilePath(StringRef SrcFile) {
SmallString<128> ObjFileName(SrcFile);
llvm::sys::path::replace_extension(ObjFileName, "o");
- return ObjFileName.str();
+ return std::string(ObjFileName.str());
}
class SingleCommandCompilationDatabase : public tooling::CompilationDatabase {
@@ -243,7 +243,7 @@ public:
const FullDependencies &FD = FDR.FullDeps;
InputDeps ID;
- ID.FileName = Input;
+ ID.FileName = std::string(Input);
ID.ContextHash = std::move(FD.ContextHash);
ID.FileDeps = std::move(FD.FileDeps);
ID.ModuleDeps = std::move(FD.ClangModuleDeps);
@@ -456,7 +456,7 @@ int main(int argc, const char **argv) {
AdjustedArgs.push_back(!LastO.empty() ? LastO
: getObjFilePath(FileName));
} else {
- AdjustedArgs.push_back(FileName);
+ AdjustedArgs.push_back(std::string(FileName));
}
}
AdjustedArgs.push_back("-Xclang");
@@ -470,7 +470,7 @@ int main(int argc, const char **argv) {
ResourceDirCache.findResourceDir(Args);
if (!ResourceDir.empty()) {
AdjustedArgs.push_back("-resource-dir");
- AdjustedArgs.push_back(ResourceDir);
+ AdjustedArgs.push_back(std::string(ResourceDir));
}
}
return AdjustedArgs;
diff --git a/clang/tools/diagtool/DiagTool.cpp b/clang/tools/diagtool/DiagTool.cpp
index 6cd67cc..81d4e7e 100644
--- a/clang/tools/diagtool/DiagTool.cpp
+++ b/clang/tools/diagtool/DiagTool.cpp
@@ -16,9 +16,8 @@
using namespace diagtool;
-DiagTool::DiagTool(llvm::StringRef toolCmd,
- llvm::StringRef toolDesc)
- : cmd(toolCmd), description(toolDesc) {}
+DiagTool::DiagTool(llvm::StringRef toolCmd, llvm::StringRef toolDesc)
+ : cmd(std::string(toolCmd)), description(std::string(toolDesc)) {}
DiagTool::~DiagTool() {}
diff --git a/clang/tools/driver/cc1as_main.cpp b/clang/tools/driver/cc1as_main.cpp
index 53c8a9d..87ba867 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -206,7 +206,7 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
// Target Options
Opts.Triple = llvm::Triple::normalize(Args.getLastArgValue(OPT_triple));
- Opts.CPU = Args.getLastArgValue(OPT_target_cpu);
+ Opts.CPU = std::string(Args.getLastArgValue(OPT_target_cpu));
Opts.Features = Args.getAllArgValues(OPT_target_feature);
// Use the default target triple if unspecified.
@@ -237,10 +237,13 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
Opts.RelaxELFRelocations = Args.hasArg(OPT_mrelax_relocations);
Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 2, Diags);
- Opts.DwarfDebugFlags = Args.getLastArgValue(OPT_dwarf_debug_flags);
- Opts.DwarfDebugProducer = Args.getLastArgValue(OPT_dwarf_debug_producer);
- Opts.DebugCompilationDir = Args.getLastArgValue(OPT_fdebug_compilation_dir);
- Opts.MainFileName = Args.getLastArgValue(OPT_main_file_name);
+ Opts.DwarfDebugFlags =
+ std::string(Args.getLastArgValue(OPT_dwarf_debug_flags));
+ Opts.DwarfDebugProducer =
+ std::string(Args.getLastArgValue(OPT_dwarf_debug_producer));
+ Opts.DebugCompilationDir =
+ std::string(Args.getLastArgValue(OPT_fdebug_compilation_dir));
+ Opts.MainFileName = std::string(Args.getLastArgValue(OPT_main_file_name));
for (const auto &Arg : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ))
Opts.DebugPrefixMap.insert(StringRef(Arg).split('='));
@@ -259,8 +262,9 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
}
}
Opts.LLVMArgs = Args.getAllArgValues(OPT_mllvm);
- Opts.OutputPath = Args.getLastArgValue(OPT_o);
- Opts.SplitDwarfOutput = Args.getLastArgValue(OPT_split_dwarf_output);
+ Opts.OutputPath = std::string(Args.getLastArgValue(OPT_o));
+ Opts.SplitDwarfOutput =
+ std::string(Args.getLastArgValue(OPT_split_dwarf_output));
if (Arg *A = Args.getLastArg(OPT_filetype)) {
StringRef Name = A->getValue();
unsigned OutputType = StringSwitch<unsigned>(Name)
@@ -288,8 +292,9 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
Opts.NoExecStack = Args.hasArg(OPT_mno_exec_stack);
Opts.FatalWarnings = Args.hasArg(OPT_massembler_fatal_warnings);
Opts.NoWarn = Args.hasArg(OPT_massembler_no_warn);
- Opts.RelocationModel = Args.getLastArgValue(OPT_mrelocation_model, "pic");
- Opts.TargetABI = Args.getLastArgValue(OPT_target_abi);
+ Opts.RelocationModel =
+ std::string(Args.getLastArgValue(OPT_mrelocation_model, "pic"));
+ Opts.TargetABI = std::string(Args.getLastArgValue(OPT_target_abi));
Opts.IncrementalLinkerCompatible =
Args.hasArg(OPT_mincremental_linker_compatible);
Opts.SymbolDefs = Args.getAllArgValues(OPT_defsym);
diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index 4457e40..843fa4b 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -60,7 +60,7 @@ std::string GetExecutablePath(const char *Argv0, bool CanonicalPrefixes) {
if (llvm::ErrorOr<std::string> P =
llvm::sys::findProgramByName(ExecutablePath))
ExecutablePath = *P;
- return ExecutablePath.str();
+ return std::string(ExecutablePath.str());
}
// This just needs to be some symbol in the binary; C++ doesn't
@@ -71,7 +71,7 @@ std::string GetExecutablePath(const char *Argv0, bool CanonicalPrefixes) {
static const char *GetStableCStr(std::set<std::string> &SavedStrings,
StringRef S) {
- return SavedStrings.insert(S).first->c_str();
+ return SavedStrings.insert(std::string(S)).first->c_str();
}
/// ApplyQAOverride - Apply a list of edits to the input argument lists.
@@ -265,7 +265,7 @@ static void FixupDiagPrefixExeName(TextDiagnosticPrinter *DiagClient,
StringRef ExeBasename(llvm::sys::path::stem(Path));
if (ExeBasename.equals_lower("cl"))
ExeBasename = "clang-cl";
- DiagClient->setPrefix(ExeBasename);
+ DiagClient->setPrefix(std::string(ExeBasename));
}
// This lets us create the DiagnosticsEngine with a properly-filled-out
diff --git a/clang/tools/libclang/CIndexDiagnostic.cpp b/clang/tools/libclang/CIndexDiagnostic.cpp
index 624e926..34792d5 100644
--- a/clang/tools/libclang/CIndexDiagnostic.cpp
+++ b/clang/tools/libclang/CIndexDiagnostic.cpp
@@ -42,8 +42,8 @@ class CXDiagnosticCustomNoteImpl : public CXDiagnosticImpl {
CXSourceLocation Loc;
public:
CXDiagnosticCustomNoteImpl(StringRef Msg, CXSourceLocation L)
- : CXDiagnosticImpl(CustomNoteDiagnosticKind),
- Message(Msg), Loc(L) {}
+ : CXDiagnosticImpl(CustomNoteDiagnosticKind), Message(std::string(Msg)),
+ Loc(L) {}
~CXDiagnosticCustomNoteImpl() override {}
@@ -51,9 +51,7 @@ public:
return CXDiagnostic_Note;
}
- CXSourceLocation getLocation() const override {
- return Loc;
- }
+ CXSourceLocation getLocation() const override { return Loc; }
CXString getSpelling() const override {
return cxstring::createRef(Message.c_str());
diff --git a/clang/tools/libclang/CIndexer.cpp b/clang/tools/libclang/CIndexer.cpp
index f784092..57acb4d 100644
--- a/clang/tools/libclang/CIndexer.cpp
+++ b/clang/tools/libclang/CIndexer.cpp
@@ -142,8 +142,9 @@ StringRef CIndexer::getClangToolchainPath() {
if (!ToolchainPath.empty())
return ToolchainPath;
StringRef ResourcePath = getClangResourcesPath();
- ToolchainPath = llvm::sys::path::parent_path(
- llvm::sys::path::parent_path(llvm::sys::path::parent_path(ResourcePath)));
+ ToolchainPath =
+ std::string(llvm::sys::path::parent_path(llvm::sys::path::parent_path(
+ llvm::sys::path::parent_path(ResourcePath))));
return ToolchainPath;
}
diff --git a/clang/tools/libclang/CIndexer.h b/clang/tools/libclang/CIndexer.h
index 8a926fd..de15cc3 100644
--- a/clang/tools/libclang/CIndexer.h
+++ b/clang/tools/libclang/CIndexer.h
@@ -78,7 +78,7 @@ public:
StringRef getClangToolchainPath();
void setInvocationEmissionPath(StringRef Str) {
- InvocationEmissionPath = Str;
+ InvocationEmissionPath = std::string(Str);
}
StringRef getInvocationEmissionPath() const { return InvocationEmissionPath; }
diff --git a/clang/tools/libclang/CLog.h b/clang/tools/libclang/CLog.h
index c25dbc0..ffd0940 100644
--- a/clang/tools/libclang/CLog.h
+++ b/clang/tools/libclang/CLog.h
@@ -61,7 +61,7 @@ public:
}
explicit Logger(llvm::StringRef name, bool trace)
- : Name(name), Trace(trace), LogOS(Msg) { }
+ : Name(std::string(name)), Trace(trace), LogOS(Msg) {}
~Logger();
Logger &operator<<(CXTranslationUnit);
diff --git a/clang/tools/libclang/Indexing.cpp b/clang/tools/libclang/Indexing.cpp
index 75b83d7..05852f3 100644
--- a/clang/tools/libclang/Indexing.cpp
+++ b/clang/tools/libclang/Indexing.cpp
@@ -547,8 +547,8 @@ static CXErrorCode clang_indexSourceFile_Impl(
CInvok->getDiagnosticOpts().IgnoreWarnings = true;
// Make sure to use the raw module format.
- CInvok->getHeaderSearchOpts().ModuleFormat =
- CXXIdx->getPCHContainerOperations()->getRawReader().getFormat();
+ CInvok->getHeaderSearchOpts().ModuleFormat = std::string(
+ CXXIdx->getPCHContainerOperations()->getRawReader().getFormat());
auto Unit = ASTUnit::create(CInvok, Diags, CaptureDiagnostics,
/*UserFilesAreVolatile=*/true);
diff --git a/clang/unittests/AST/ASTImporterFixtures.cpp b/clang/unittests/AST/ASTImporterFixtures.cpp
index 80fcd1f..36732ee 100644
--- a/clang/unittests/AST/ASTImporterFixtures.cpp
+++ b/clang/unittests/AST/ASTImporterFixtures.cpp
@@ -41,7 +41,7 @@ void createVirtualFileIfNeeded(ASTUnit *ToAST, StringRef FileName,
ASTImporterTestBase::TU::TU(StringRef Code, StringRef FileName, ArgVector Args,
ImporterConstructor C,
ASTImporter::ODRHandlingType ODRHandling)
- : Code(Code), FileName(FileName),
+ : Code(std::string(Code)), FileName(std::string(FileName)),
Unit(tooling::buildASTFromCodeWithArgs(this->Code, Args, this->FileName)),
TUDecl(Unit->getASTContext().getTranslationUnitDecl()), Creator(C),
ODRHandling(ODRHandling) {
@@ -118,7 +118,7 @@ void ASTImporterTestBase::lazyInitToAST(Language ToLang, StringRef ToSrcCode,
return;
ArgVector ToArgs = getArgVectorForLanguage(ToLang);
// Source code must be a valid live buffer through the tests lifetime.
- ToCode = ToSrcCode;
+ ToCode = std::string(ToSrcCode);
// Build the AST from an empty file.
ToAST = tooling::buildASTFromCodeWithArgs(ToCode, ToArgs, FileName);
ToAST->enableSourceFileDiagnostics();
diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp
index 3e8f804..8c3dc6c 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -115,8 +115,8 @@ class TestImportBase : public CompilerOptionSpecificTest,
const BindableMatcher<NodeType> &VerificationMatcher) {
return testImport(
FromCode, FromArgs, ToCode, ToArgs, Verifier,
- translationUnitDecl(
- has(namedDecl(hasName(DeclToImportID)).bind(DeclToImportID))),
+ translationUnitDecl(has(namedDecl(hasName(std::string(DeclToImportID)))
+ .bind(DeclToImportID))),
VerificationMatcher);
}
diff --git a/clang/unittests/AST/DeclPrinterTest.cpp b/clang/unittests/AST/DeclPrinterTest.cpp
index 5a0a804..3bb17ab 100644
--- a/clang/unittests/AST/DeclPrinterTest.cpp
+++ b/clang/unittests/AST/DeclPrinterTest.cpp
@@ -108,12 +108,9 @@ PrintedDeclCXX98Matches(StringRef Code, StringRef DeclName,
StringRef ExpectedPrinted,
PrintingPolicyModifier PolicyModifier = nullptr) {
std::vector<std::string> Args(1, "-std=c++98");
- return PrintedDeclMatches(Code,
- Args,
- namedDecl(hasName(DeclName)).bind("id"),
- ExpectedPrinted,
- "input.cc",
- PolicyModifier);
+ return PrintedDeclMatches(
+ Code, Args, namedDecl(hasName(std::string(DeclName))).bind("id"),
+ ExpectedPrinted, "input.cc", PolicyModifier);
}
::testing::AssertionResult
@@ -133,11 +130,9 @@ PrintedDeclCXX98Matches(StringRef Code, const DeclarationMatcher &NodeMatch,
StringRef DeclName,
StringRef ExpectedPrinted) {
std::vector<std::string> Args(1, "-std=c++11");
- return PrintedDeclMatches(Code,
- Args,
- namedDecl(hasName(DeclName)).bind("id"),
- ExpectedPrinted,
- "input.cc");
+ return PrintedDeclMatches(
+ Code, Args, namedDecl(hasName(std::string(DeclName))).bind("id"),
+ ExpectedPrinted, "input.cc");
}
::testing::AssertionResult PrintedDeclCXX11Matches(
diff --git a/clang/unittests/AST/NamedDeclPrinterTest.cpp b/clang/unittests/AST/NamedDeclPrinterTest.cpp
index a5c3e19..d5077b8 100644
--- a/clang/unittests/AST/NamedDeclPrinterTest.cpp
+++ b/clang/unittests/AST/NamedDeclPrinterTest.cpp
@@ -112,47 +112,45 @@ PrintedNamedDeclMatches(StringRef Code, const std::vector<std::string> &Args,
PrintedNamedDeclCXX98Matches(StringRef Code, StringRef DeclName,
StringRef ExpectedPrinted) {
std::vector<std::string> Args(1, "-std=c++98");
- return PrintedNamedDeclMatches(Code,
- Args,
- /*SuppressUnwrittenScope*/ false,
- namedDecl(hasName(DeclName)).bind("id"),
- ExpectedPrinted,
- "input.cc");
+ return PrintedNamedDeclMatches(
+ Code, Args,
+ /*SuppressUnwrittenScope*/ false,
+ namedDecl(hasName(std::string(DeclName))).bind("id"), ExpectedPrinted,
+ "input.cc");
}
::testing::AssertionResult
PrintedWrittenNamedDeclCXX11Matches(StringRef Code, StringRef DeclName,
StringRef ExpectedPrinted) {
std::vector<std::string> Args(1, "-std=c++11");
- return PrintedNamedDeclMatches(Code,
- Args,
- /*SuppressUnwrittenScope*/ true,
- namedDecl(hasName(DeclName)).bind("id"),
- ExpectedPrinted,
- "input.cc");
+ return PrintedNamedDeclMatches(
+ Code, Args,
+ /*SuppressUnwrittenScope*/ true,
+ namedDecl(hasName(std::string(DeclName))).bind("id"), ExpectedPrinted,
+ "input.cc");
}
::testing::AssertionResult
PrintedWrittenPropertyDeclObjCMatches(StringRef Code, StringRef DeclName,
StringRef ExpectedPrinted) {
std::vector<std::string> Args{"-std=c++11", "-xobjective-c++"};
- return PrintedNamedDeclMatches(Code,
- Args,
- /*SuppressUnwrittenScope*/ true,
- objcPropertyDecl(hasName(DeclName)).bind("id"),
- ExpectedPrinted,
- "input.m");
+ return PrintedNamedDeclMatches(
+ Code, Args,
+ /*SuppressUnwrittenScope*/ true,
+ objcPropertyDecl(hasName(std::string(DeclName))).bind("id"),
+ ExpectedPrinted, "input.m");
}
::testing::AssertionResult
PrintedNestedNameSpecifierMatches(StringRef Code, StringRef DeclName,
StringRef ExpectedPrinted) {
std::vector<std::string> Args{"-std=c++11"};
- return PrintedDeclMatches(Code, Args, namedDecl(hasName(DeclName)).bind("id"),
- ExpectedPrinted, "input.cc",
- [](llvm::raw_ostream &Out, const NamedDecl *D) {
- D->printNestedNameSpecifier(Out);
- });
+ return PrintedDeclMatches(
+ Code, Args, namedDecl(hasName(std::string(DeclName))).bind("id"),
+ ExpectedPrinted, "input.cc",
+ [](llvm::raw_ostream &Out, const NamedDecl *D) {
+ D->printNestedNameSpecifier(Out);
+ });
}
} // unnamed namespace
diff --git a/clang/unittests/AST/StmtPrinterTest.cpp b/clang/unittests/AST/StmtPrinterTest.cpp
index 080c18b..76195af 100644
--- a/clang/unittests/AST/StmtPrinterTest.cpp
+++ b/clang/unittests/AST/StmtPrinterTest.cpp
@@ -34,7 +34,7 @@ namespace {
enum class StdVer { CXX98, CXX11, CXX14, CXX17, CXX2a };
DeclarationMatcher FunctionBodyMatcher(StringRef ContainingFunction) {
- return functionDecl(hasName(ContainingFunction),
+ return functionDecl(hasName(std::string(ContainingFunction)),
has(compoundStmt(has(stmt().bind("id")))));
}
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.h b/clang/unittests/ASTMatchers/ASTMatchersTest.h
index 745122a..6af039e 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTest.h
+++ b/clang/unittests/ASTMatchers/ASTMatchersTest.h
@@ -268,8 +268,8 @@ testing::AssertionResult matchesConditionallyWithCuda(
// unknown-unknown triple is good for a large speedup, because it lets us
// avoid constructing a full system triple.
std::vector<std::string> Args = {
- "-xcuda", "-fno-ms-extensions", "--cuda-host-only", "-nocudainc",
- "-target", "x86_64-unknown-unknown", CompileArg};
+ "-xcuda", "-fno-ms-extensions", "--cuda-host-only", "-nocudainc",
+ "-target", "x86_64-unknown-unknown", std::string(CompileArg)};
if (!runToolOnCodeWithArgs(Factory->create(),
CudaHeader + Code, Args)) {
return testing::AssertionFailure() << "Parsing error in \"" << Code << "\"";
@@ -385,20 +385,20 @@ public:
// Create an object that checks that a node of type \c T was bound to \c Id.
// Does not check for a certain number of matches.
explicit VerifyIdIsBoundTo(llvm::StringRef Id)
- : Id(Id), ExpectedCount(-1), Count(0) {}
+ : Id(std::string(Id)), ExpectedCount(-1), Count(0) {}
// Create an object that checks that a node of type \c T was bound to \c Id.
// Checks that there were exactly \c ExpectedCount matches.
VerifyIdIsBoundTo(llvm::StringRef Id, int ExpectedCount)
- : Id(Id), ExpectedCount(ExpectedCount), Count(0) {}
+ : Id(std::string(Id)), ExpectedCount(ExpectedCount), Count(0) {}
// Create an object that checks that a node of type \c T was bound to \c Id.
// Checks that there was exactly one match with the name \c ExpectedName.
// Note that \c T must be a NamedDecl for this to work.
VerifyIdIsBoundTo(llvm::StringRef Id, llvm::StringRef ExpectedName,
int ExpectedCount = 1)
- : Id(Id), ExpectedCount(ExpectedCount), Count(0),
- ExpectedName(ExpectedName) {}
+ : Id(std::string(Id)), ExpectedCount(ExpectedCount), Count(0),
+ ExpectedName(std::string(ExpectedName)) {}
void onEndOfTranslationUnit() override {
if (ExpectedCount != -1) {
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
index b1f070bd..29f30cb 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1572,7 +1572,7 @@ TEST(IgnoringImplicit, MatchesImplicit) {
}
TEST(IgnoringImplicit, MatchesNestedImplicit) {
- StringRef Code = R"(
+ const char *Code = R"(
struct OtherType;
@@ -1617,7 +1617,7 @@ TEST(IgnoringImplicit, DoesNotMatchIncorrectly) {
TEST(Traversal, traverseMatcher) {
- StringRef VarDeclCode = R"cpp(
+ const char *VarDeclCode = R"cpp(
void foo()
{
int i = 3.0;
@@ -1692,7 +1692,7 @@ void foo()
functionDecl(traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
hasAnyName("foo", "bar")))));
- llvm::StringRef Code = R"cpp(
+ const char *Code = R"cpp(
void foo(int a)
{
int i = 3.0 + a;
@@ -1759,7 +1759,7 @@ const char *SomeString{"str"};
template <typename MatcherT>
bool matcherTemplateWithBinding(StringRef Code, const MatcherT &M) {
return matchAndVerifyResultTrue(
- Code, M.bind("matchedStmt"),
+ std::string(Code), M.bind("matchedStmt"),
std::make_unique<VerifyIdIsBoundTo<ReturnStmt>>("matchedStmt", 1));
}
@@ -1781,7 +1781,7 @@ int foo()
TEST(Traversal, traverseMatcherNesting) {
- StringRef Code = R"cpp(
+ const char *Code = R"cpp(
float bar(int i)
{
return i;
@@ -1802,7 +1802,7 @@ void foo()
}
TEST(Traversal, traverseMatcherThroughImplicit) {
- StringRef Code = R"cpp(
+ const char *Code = R"cpp(
struct S {
S(int x);
};
@@ -1822,7 +1822,7 @@ void constructImplicit() {
TEST(Traversal, traverseMatcherThroughMemoization) {
- StringRef Code = R"cpp(
+ const char *Code = R"cpp(
void foo()
{
int i = 3.0;
@@ -1847,7 +1847,7 @@ void foo()
TEST(Traversal, traverseUnlessSpelledInSource) {
- StringRef Code = R"cpp(
+ const char *Code = R"cpp(
struct A
{
diff --git a/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp b/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
index 6c07c83..d98e319 100644
--- a/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ b/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -43,7 +43,7 @@ public:
llvm::Optional<MatcherCtor>
lookupMatcherCtor(StringRef MatcherName) override {
const ExpectedMatchersTy::value_type *Matcher =
- &*ExpectedMatchers.find(MatcherName);
+ &*ExpectedMatchers.find(std::string(MatcherName));
return reinterpret_cast<MatcherCtor>(Matcher);
}
@@ -54,7 +54,8 @@ public:
Diagnostics *Error) override {
const ExpectedMatchersTy::value_type *Matcher =
reinterpret_cast<const ExpectedMatchersTy::value_type *>(Ctor);
- MatcherInfo ToStore = { Matcher->first, NameRange, Args, BindID };
+ MatcherInfo ToStore = {Matcher->first, NameRange, Args,
+ std::string(BindID)};
Matchers.push_back(ToStore);
return VariantMatcher::SingleMatcher(Matcher->second);
}
diff --git a/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp b/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
index 1c3e00c..b24ec07f3 100644
--- a/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ b/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -44,7 +44,7 @@ std::unique_ptr<ASTUnit> buildASTFromCode(const Twine &Code) {
}
ExprMatcher declRefTo(StringRef Name) {
- return declRefExpr(to(namedDecl(hasName(Name))));
+ return declRefExpr(to(namedDecl(hasName(std::string(Name)))));
}
StmtMatcher withEnclosingCompound(ExprMatcher Matcher) {
diff --git a/clang/unittests/Basic/SourceManagerTest.cpp b/clang/unittests/Basic/SourceManagerTest.cpp
index 07c72e2..f4bdd9c 100644
--- a/clang/unittests/Basic/SourceManagerTest.cpp
+++ b/clang/unittests/Basic/SourceManagerTest.cpp
@@ -347,7 +347,7 @@ struct MacroAction {
unsigned MAKind : 3;
MacroAction(SourceLocation Loc, StringRef Name, unsigned K)
- : Loc(Loc), Name(Name), MAKind(K) { }
+ : Loc(Loc), Name(std::string(Name)), MAKind(K) {}
bool isExpansion() const { return MAKind == kExpansion; }
bool isDefinition() const { return MAKind & kDefinition; }
diff --git a/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp b/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
index 7a898cd..510ade4 100644
--- a/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
+++ b/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -45,9 +45,9 @@ struct DirectoryWatcherTestFixture {
#endif
createUniqueDirectory("dirwatcher", pathBuf);
assert(!UniqDirRes);
- TestRootDir = pathBuf.str();
+ TestRootDir = std::string(pathBuf.str());
path::append(pathBuf, "watch");
- TestWatchedDir = pathBuf.str();
+ TestWatchedDir = std::string(pathBuf.str());
#ifndef NDEBUG
std::error_code CreateDirRes =
#endif
diff --git a/clang/unittests/Frontend/ASTUnitTest.cpp b/clang/unittests/Frontend/ASTUnitTest.cpp
index 5cb2087..fbc641e 100644
--- a/clang/unittests/Frontend/ASTUnitTest.cpp
+++ b/clang/unittests/Frontend/ASTUnitTest.cpp
@@ -87,7 +87,7 @@ TEST_F(ASTUnitTest, SaveLoadPreservesLangOptionsInPrintingPolicy) {
EXPECT_TRUE(llvm::sys::fs::exists(ASTFileName));
std::unique_ptr<ASTUnit> AU = ASTUnit::LoadFromASTFile(
- ASTFileName.str(), PCHContainerOps->getRawReader(),
+ std::string(ASTFileName.str()), PCHContainerOps->getRawReader(),
ASTUnit::LoadEverything, Diags, FileSystemOptions(),
/*UseDebugInfo=*/false);
diff --git a/clang/unittests/Frontend/CompilerInstanceTest.cpp b/clang/unittests/Frontend/CompilerInstanceTest.cpp
index d2377d0..eeae2e9 100644
--- a/clang/unittests/Frontend/CompilerInstanceTest.cpp
+++ b/clang/unittests/Frontend/CompilerInstanceTest.cpp
@@ -32,8 +32,8 @@ TEST(CompilerInstance, DefaultVFSOverlayFromInvocation) {
// Mount the VFS file itself on the path 'virtual.file'. Makes this test
// a bit shorter than creating a new dummy file just for this purpose.
- const std::string CurrentPathStr = CurrentPath.str();
- const std::string FileNameStr = FileName.str();
+ const std::string CurrentPathStr = std::string(CurrentPath.str());
+ const std::string FileNameStr = std::string(FileName.str());
const char *VFSYaml = "{ 'version': 0, 'roots': [\n"
" { 'name': '%s',\n"
" 'type': 'directory',\n"
diff --git a/clang/unittests/Frontend/FrontendActionTest.cpp b/clang/unittests/Frontend/FrontendActionTest.cpp
index d0a3020..9f8a746 100644
--- a/clang/unittests/Frontend/FrontendActionTest.cpp
+++ b/clang/unittests/Frontend/FrontendActionTest.cpp
@@ -272,7 +272,8 @@ TEST(GeneratePCHFrontendAction, CacheGeneratedPCH) {
MemoryBuffer::getMemBuffer("int foo(void) { return 1; }\n").release());
Invocation->getFrontendOpts().Inputs.push_back(
FrontendInputFile("test.h", Language::C));
- Invocation->getFrontendOpts().OutputFile = StringRef(PCHFilename);
+ Invocation->getFrontendOpts().OutputFile =
+ std::string(StringRef(PCHFilename));
Invocation->getFrontendOpts().ProgramAction = frontend::GeneratePCH;
Invocation->getTargetOpts().Triple = "x86_64-apple-darwin19.0.0";
CompilerInstance Compiler;
diff --git a/clang/unittests/Index/IndexTests.cpp b/clang/unittests/Index/IndexTests.cpp
index 3ccec683..a279f48 100644
--- a/clang/unittests/Index/IndexTests.cpp
+++ b/clang/unittests/Index/IndexTests.cpp
@@ -95,7 +95,7 @@ public:
SymbolRoleSet Roles, SourceLocation Loc) override {
TestSymbol S;
S.SymInfo = getSymbolInfoForMacro(*MI);
- S.QName = Name->getName();
+ S.QName = std::string(Name->getName());
S.WrittenPos = Position::fromSourceLocation(Loc, AST->getSourceManager());
S.DeclPos = Position::fromSourceLocation(MI->getDefinitionLoc(),
AST->getSourceManager());
diff --git a/clang/unittests/Lex/LexerTest.cpp b/clang/unittests/Lex/LexerTest.cpp
index ad9010e..c68eed9 100644
--- a/clang/unittests/Lex/LexerTest.cpp
+++ b/clang/unittests/Lex/LexerTest.cpp
@@ -98,7 +98,7 @@ protected:
SourceMgr, LangOpts, &Invalid);
if (Invalid)
return "<INVALID>";
- return Str;
+ return std::string(Str);
}
FileSystemOptions FileMgrOpts;
diff --git a/clang/unittests/Rename/ClangRenameTest.h b/clang/unittests/Rename/ClangRenameTest.h
index 9dfa6d9..6403365 100644
--- a/clang/unittests/Rename/ClangRenameTest.h
+++ b/clang/unittests/Rename/ClangRenameTest.h
@@ -58,7 +58,7 @@ protected:
Context.createInMemoryFile(HeaderName, HeaderContent);
clang::FileID InputFileID = Context.createInMemoryFile(CCName, NewCode);
- tooling::USRFindingAction FindingAction({}, {OldName}, false);
+ tooling::USRFindingAction FindingAction({}, {std::string(OldName)}, false);
std::unique_ptr<tooling::FrontendActionFactory> USRFindingActionFactory =
tooling::newFrontendActionFactory(&FindingAction);
@@ -70,7 +70,7 @@ protected:
const std::vector<std::vector<std::string>> &USRList =
FindingAction.getUSRList();
- std::vector<std::string> NewNames = {NewName};
+ std::vector<std::string> NewNames = {std::string(NewName)};
std::map<std::string, tooling::Replacements> FileToReplacements;
tooling::QualifiedRenamingAction RenameAction(NewNames, USRList,
FileToReplacements);
diff --git a/clang/unittests/Sema/ExternalSemaSourceTest.cpp b/clang/unittests/Sema/ExternalSemaSourceTest.cpp
index 44006e3..842eb83 100644
--- a/clang/unittests/Sema/ExternalSemaSourceTest.cpp
+++ b/clang/unittests/Sema/ExternalSemaSourceTest.cpp
@@ -48,7 +48,7 @@ class DiagnosticWatcher : public clang::DiagnosticConsumer {
public:
DiagnosticWatcher(StringRef From, StringRef To)
: Chained(nullptr), FromName(From), ToName("'"), SeenCount(0) {
- ToName.append(To);
+ ToName.append(std::string(To));
ToName.append("'");
}
diff --git a/clang/unittests/StaticAnalyzer/Reusables.h b/clang/unittests/StaticAnalyzer/Reusables.h
index bac2808..db9c085 100644
--- a/clang/unittests/StaticAnalyzer/Reusables.h
+++ b/clang/unittests/StaticAnalyzer/Reusables.h
@@ -34,7 +34,7 @@ const T *findNode(const Decl *Where, MatcherT What) {
template <typename T>
const T *findDeclByName(const Decl *Where, StringRef Name) {
using namespace ast_matchers;
- return findNode<T>(Where, namedDecl(hasName(Name)));
+ return findNode<T>(Where, namedDecl(hasName(std::string(Name))));
}
// A re-usable consumer that constructs ExprEngine out of CompilerInvocation.
diff --git a/clang/unittests/Tooling/CompilationDatabaseTest.cpp b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
index 56ebadc..cc948b8 100644
--- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -87,11 +87,11 @@ TEST(JSONCompilationDatabase, GetAllFiles) {
std::vector<std::string> expected_files;
SmallString<16> PathStorage;
llvm::sys::path::native("//net/dir/file1", PathStorage);
- expected_files.push_back(PathStorage.str());
+ expected_files.push_back(std::string(PathStorage.str()));
llvm::sys::path::native("//net/dir/file2", PathStorage);
- expected_files.push_back(PathStorage.str());
+ expected_files.push_back(std::string(PathStorage.str()));
llvm::sys::path::native("//net/file1", PathStorage);
- expected_files.push_back(PathStorage.str());
+ expected_files.push_back(std::string(PathStorage.str()));
EXPECT_EQ(expected_files,
getAllFiles("[{\"directory\":\"//net/dir\","
"\"command\":\"command\","
@@ -654,7 +654,7 @@ struct MemCDB : public CompilationDatabase {
std::vector<std::string> getAllFiles() const override {
std::vector<std::string> Result;
for (const auto &Entry : Entries)
- Result.push_back(Entry.first());
+ Result.push_back(std::string(Entry.first()));
return Result;
}
};
@@ -682,7 +682,7 @@ protected:
llvm::sys::path::native(File);
llvm::SmallString<64> Result;
llvm::sys::path::append(Result, Dir, File);
- return Result.str();
+ return std::string(Result.str());
}
MemCDB::EntryMap Entries;
@@ -723,7 +723,7 @@ protected:
Proxy.consume_front(llvm::sys::path::get_separator());
llvm::SmallString<32> Result = Proxy;
llvm::sys::path::native(Result, llvm::sys::path::Style::posix);
- return Result.str();
+ return std::string(Result.str());
}
};
diff --git a/clang/unittests/Tooling/DependencyScannerTest.cpp b/clang/unittests/Tooling/DependencyScannerTest.cpp
index 60f6566..5a9c514 100644
--- a/clang/unittests/Tooling/DependencyScannerTest.cpp
+++ b/clang/unittests/Tooling/DependencyScannerTest.cpp
@@ -83,9 +83,11 @@ TEST(DependencyScanner, ScanDepsReuseFilemanager) {
auto VFS = new llvm::vfs::InMemoryFileSystem();
VFS->setCurrentWorkingDirectory(CWD);
auto Sept = llvm::sys::path::get_separator();
- std::string HeaderPath = llvm::formatv("{0}root{0}header.h", Sept);
- std::string SymlinkPath = llvm::formatv("{0}root{0}symlink.h", Sept);
- std::string TestPath = llvm::formatv("{0}root{0}test.cpp", Sept);
+ std::string HeaderPath =
+ std::string(llvm::formatv("{0}root{0}header.h", Sept));
+ std::string SymlinkPath =
+ std::string(llvm::formatv("{0}root{0}symlink.h", Sept));
+ std::string TestPath = std::string(llvm::formatv("{0}root{0}test.cpp", Sept));
VFS->addFile(HeaderPath, 0, llvm::MemoryBuffer::getMemBuffer("\n"));
VFS->addHardLink(SymlinkPath, HeaderPath);
@@ -130,10 +132,13 @@ TEST(DependencyScanner, ScanDepsReuseFilemanagerSkippedFile) {
auto VFS = new llvm::vfs::InMemoryFileSystem();
VFS->setCurrentWorkingDirectory(CWD);
auto Sept = llvm::sys::path::get_separator();
- std::string HeaderPath = llvm::formatv("{0}root{0}header.h", Sept);
- std::string SymlinkPath = llvm::formatv("{0}root{0}symlink.h", Sept);
- std::string TestPath = llvm::formatv("{0}root{0}test.cpp", Sept);
- std::string Test2Path = llvm::formatv("{0}root{0}test2.cpp", Sept);
+ std::string HeaderPath =
+ std::string(llvm::formatv("{0}root{0}header.h", Sept));
+ std::string SymlinkPath =
+ std::string(llvm::formatv("{0}root{0}symlink.h", Sept));
+ std::string TestPath = std::string(llvm::formatv("{0}root{0}test.cpp", Sept));
+ std::string Test2Path =
+ std::string(llvm::formatv("{0}root{0}test2.cpp", Sept));
VFS->addFile(HeaderPath, 0,
llvm::MemoryBuffer::getMemBuffer("#pragma once\n"));
@@ -169,9 +174,11 @@ TEST(DependencyScanner, ScanDepsReuseFilemanagerHasInclude) {
auto VFS = new llvm::vfs::InMemoryFileSystem();
VFS->setCurrentWorkingDirectory(CWD);
auto Sept = llvm::sys::path::get_separator();
- std::string HeaderPath = llvm::formatv("{0}root{0}header.h", Sept);
- std::string SymlinkPath = llvm::formatv("{0}root{0}symlink.h", Sept);
- std::string TestPath = llvm::formatv("{0}root{0}test.cpp", Sept);
+ std::string HeaderPath =
+ std::string(llvm::formatv("{0}root{0}header.h", Sept));
+ std::string SymlinkPath =
+ std::string(llvm::formatv("{0}root{0}symlink.h", Sept));
+ std::string TestPath = std::string(llvm::formatv("{0}root{0}test.cpp", Sept));
VFS->addFile(HeaderPath, 0, llvm::MemoryBuffer::getMemBuffer("\n"));
VFS->addHardLink(SymlinkPath, HeaderPath);
diff --git a/clang/unittests/Tooling/ExecutionTest.cpp b/clang/unittests/Tooling/ExecutionTest.cpp
index 16455fb..91ab859 100644
--- a/clang/unittests/Tooling/ExecutionTest.cpp
+++ b/clang/unittests/Tooling/ExecutionTest.cpp
@@ -112,7 +112,7 @@ public:
}
void mapVirtualFile(StringRef FilePath, StringRef Content) override {
- VFS[FilePath] = Content;
+ VFS[std::string(FilePath)] = std::string(Content);
}
private:
@@ -289,7 +289,7 @@ TEST(AllTUsToolTest, ManyFiles) {
ASSERT_TRUE(!Err);
std::vector<std::string> Results;
Executor.getToolResults()->forEachResult(
- [&](StringRef Name, StringRef) { Results.push_back(Name); });
+ [&](StringRef Name, StringRef) { Results.push_back(std::string(Name)); });
EXPECT_THAT(ExpectedSymbols, ::testing::UnorderedElementsAreArray(Results));
}
diff --git a/clang/unittests/Tooling/HeaderIncludesTest.cpp b/clang/unittests/Tooling/HeaderIncludesTest.cpp
index 635d7eb..9f86d2e 100644
--- a/clang/unittests/Tooling/HeaderIncludesTest.cpp
+++ b/clang/unittests/Tooling/HeaderIncludesTest.cpp
@@ -25,7 +25,7 @@ protected:
assert(Header.startswith("\"") || Header.startswith("<"));
auto R = Includes.insert(Header.trim("\"<>"), Header.startswith("<"));
if (!R)
- return Code;
+ return std::string(Code);
auto Result = applyAllReplacements(Code, Replacements(*R));
EXPECT_TRUE(static_cast<bool>(Result));
return *Result;
diff --git a/clang/unittests/Tooling/RangeSelectorTest.cpp b/clang/unittests/Tooling/RangeSelectorTest.cpp
index 8a7d555..a84b0b9 100644
--- a/clang/unittests/Tooling/RangeSelectorTest.cpp
+++ b/clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -108,7 +108,7 @@ Expected<CharSourceRange> selectFromAssorted(RangeSelector Selector) {
}
// Matches the message expected for type-error failures.
-testing::Matcher<StringError> withTypeErrorMessage(StringRef NodeID) {
+testing::Matcher<StringError> withTypeErrorMessage(const std::string &NodeID) {
return testing::Property(
&StringError::getMessage,
AllOf(HasSubstr(NodeID), HasSubstr("mismatched type")));
@@ -131,7 +131,7 @@ TEST(RangeSelectorTest, BeforeOp) {
int f(int x, int y, int z) { return 3; }
int g() { return f(/* comment */ 3, 7 /* comment */, 9); }
)cc";
- StringRef Call = "call";
+ const char *Call = "call";
TestMatch Match = matchCode(Code, callExpr().bind(Call));
const auto* E = Match.Result.Nodes.getNodeAs<Expr>(Call);
assert(E != nullptr);
@@ -173,8 +173,8 @@ TEST(RangeSelectorTest, RangeOp) {
int f(int x, int y, int z) { return 3; }
int g() { return f(/* comment */ 3, 7 /* comment */, 9); }
)cc";
- StringRef Arg0 = "a0";
- StringRef Arg1 = "a1";
+ const char *Arg0 = "a0";
+ const char *Arg1 = "a1";
StringRef Call = "call";
auto Matcher = callExpr(hasArgument(0, expr().bind(Arg0)),
hasArgument(1, expr().bind(Arg1)))
@@ -190,21 +190,21 @@ TEST(RangeSelectorTest, RangeOp) {
TEST(RangeSelectorTest, NodeOpStatement) {
StringRef Code = "int f() { return 3; }";
- StringRef ID = "id";
+ const char *ID = "id";
TestMatch Match = matchCode(Code, returnStmt().bind(ID));
EXPECT_THAT_EXPECTED(select(node(ID), Match), HasValue("return 3;"));
}
TEST(RangeSelectorTest, NodeOpExpression) {
StringRef Code = "int f() { return 3; }";
- StringRef ID = "id";
+ const char *ID = "id";
TestMatch Match = matchCode(Code, expr().bind(ID));
EXPECT_THAT_EXPECTED(select(node(ID), Match), HasValue("3"));
}
TEST(RangeSelectorTest, StatementOp) {
StringRef Code = "int f() { return 3; }";
- StringRef ID = "id";
+ const char *ID = "id";
TestMatch Match = matchCode(Code, expr().bind(ID));
EXPECT_THAT_EXPECTED(select(statement(ID), Match), HasValue("3;"));
}
@@ -219,7 +219,7 @@ TEST(RangeSelectorTest, MemberOp) {
return s.member;
}
)cc";
- StringRef ID = "id";
+ const char *ID = "id";
TestMatch Match = matchCode(Code, memberExpr().bind(ID));
EXPECT_THAT_EXPECTED(select(member(ID), Match), HasValue("member"));
}
@@ -238,7 +238,7 @@ TEST(RangeSelectorTest, MemberOpQualified) {
return t.S::member;
}
)cc";
- StringRef ID = "id";
+ const char *ID = "id";
TestMatch Match = matchCode(Code, memberExpr().bind(ID));
EXPECT_THAT_EXPECTED(select(member(ID), Match), HasValue("member"));
}
@@ -254,7 +254,7 @@ TEST(RangeSelectorTest, MemberOpTemplate) {
}
)cc";
- StringRef ID = "id";
+ const char *ID = "id";
TestMatch Match = matchCode(Code, memberExpr().bind(ID));
EXPECT_THAT_EXPECTED(select(member(ID), Match), HasValue("foo"));
}
@@ -270,7 +270,7 @@ TEST(RangeSelectorTest, MemberOpOperator) {
}
)cc";
- StringRef ID = "id";
+ const char *ID = "id";
TestMatch Match = matchCode(Code, memberExpr().bind(ID));
EXPECT_THAT_EXPECTED(select(member(ID), Match), HasValue("operator *"));
}
@@ -281,7 +281,7 @@ TEST(RangeSelectorTest, NameOpNamedDecl) {
return 3;
}
)cc";
- StringRef ID = "id";
+ const char *ID = "id";
TestMatch Match = matchCode(Code, functionDecl().bind(ID));
EXPECT_THAT_EXPECTED(select(name(ID), Match), HasValue("myfun"));
}
@@ -293,7 +293,7 @@ TEST(RangeSelectorTest, NameOpDeclRef) {
}
int g(int x) { return foo(x) * x; }
)cc";
- StringRef Ref = "ref";
+ const char *Ref = "ref";
TestMatch Match = matchCode(Code, declRefExpr(to(functionDecl())).bind(Ref));
EXPECT_THAT_EXPECTED(select(name(Ref), Match), HasValue("foo"));
}
@@ -306,7 +306,7 @@ TEST(RangeSelectorTest, NameOpCtorInitializer) {
int field;
};
)cc";
- StringRef Init = "init";
+ const char *Init = "init";
TestMatch Match = matchCode(Code, cxxCtorInitializer().bind(Init));
EXPECT_THAT_EXPECTED(select(name(Init), Match), HasValue("field"));
}
@@ -328,7 +328,7 @@ TEST(RangeSelectorTest, NameOpDeclRefError) {
return *s + x;
}
)cc";
- StringRef Ref = "ref";
+ const char *Ref = "ref";
TestMatch Match = matchCode(Code, declRefExpr(to(functionDecl())).bind(Ref));
EXPECT_THAT_EXPECTED(
name(Ref)(Match.Result),
@@ -347,7 +347,7 @@ TEST(RangeSelectorTest, CallArgsOp) {
return x.bar(3, 4);
}
)cc";
- StringRef ID = "id";
+ const char *ID = "id";
TestMatch Match = matchCode(Code, callExpr().bind(ID));
EXPECT_THAT_EXPECTED(select(callArgs(ID), Match), HasValue("3, 4"));
}
@@ -362,7 +362,7 @@ TEST(RangeSelectorTest, CallArgsOpNoArgs) {
return x.bar();
}
)cc";
- StringRef ID = "id";
+ const char *ID = "id";
TestMatch Match = matchCode(Code, callExpr().bind(ID));
EXPECT_THAT_EXPECTED(select(callArgs(ID), Match), HasValue(""));
}
@@ -377,7 +377,7 @@ TEST(RangeSelectorTest, CallArgsOpNoArgsWithComments) {
return x.bar(/*empty*/);
}
)cc";
- StringRef ID = "id";
+ const char *ID = "id";
TestMatch Match = matchCode(Code, callExpr().bind(ID));
EXPECT_THAT_EXPECTED(select(callArgs(ID), Match), HasValue("/*empty*/"));
}
@@ -394,7 +394,7 @@ TEST(RangeSelectorTest, CallArgsOpWithParens) {
return C().bar(3, 4);
}
)cc";
- StringRef ID = "id";
+ const char *ID = "id";
TestMatch Match =
matchCode(Code, callExpr(callee(functionDecl(hasName("bar")))).bind(ID));
EXPECT_THAT_EXPECTED(select(callArgs(ID), Match), HasValue("3, 4"));
@@ -410,7 +410,7 @@ TEST(RangeSelectorTest, CallArgsOpLeadingComments) {
return x.bar(/*leading*/ 3, 4);
}
)cc";
- StringRef ID = "id";
+ const char *ID = "id";
TestMatch Match = matchCode(Code, callExpr().bind(ID));
EXPECT_THAT_EXPECTED(select(callArgs(ID), Match),
HasValue("/*leading*/ 3, 4"));
@@ -426,7 +426,7 @@ TEST(RangeSelectorTest, CallArgsOpTrailingComments) {
return x.bar(3 /*trailing*/, 4);
}
)cc";
- StringRef ID = "id";
+ const char *ID = "id";
TestMatch Match = matchCode(Code, callExpr().bind(ID));
EXPECT_THAT_EXPECTED(select(callArgs(ID), Match),
HasValue("3 /*trailing*/, 4"));
@@ -445,7 +445,7 @@ TEST(RangeSelectorTest, CallArgsOpEolComments) {
);
}
)cc";
- StringRef ID = "id";
+ const char *ID = "id";
TestMatch Match = matchCode(Code, callExpr().bind(ID));
std::string ExpectedString = R"( // Header
1, // foo
@@ -466,7 +466,7 @@ TEST(RangeSelectorTest, StatementsOp) {
void g();
void f() { /* comment */ g(); /* comment */ g(); /* comment */ }
)cc";
- StringRef ID = "id";
+ const char *ID = "id";
TestMatch Match = matchCode(Code, compoundStmt().bind(ID));
EXPECT_THAT_EXPECTED(
select(statements(ID), Match),
@@ -475,7 +475,7 @@ TEST(RangeSelectorTest, StatementsOp) {
TEST(RangeSelectorTest, StatementsOpEmptyList) {
StringRef Code = "void f() {}";
- StringRef ID = "id";
+ const char *ID = "id";
TestMatch Match = matchCode(Code, compoundStmt().bind(ID));
EXPECT_THAT_EXPECTED(select(statements(ID), Match), HasValue(""));
}
@@ -494,7 +494,7 @@ TEST(RangeSelectorTest, ElementsOp) {
(void)v;
}
)cc";
- StringRef ID = "id";
+ const char *ID = "id";
TestMatch Match = matchCode(Code, initListExpr().bind(ID));
EXPECT_THAT_EXPECTED(
select(initListElements(ID), Match),
@@ -508,7 +508,7 @@ TEST(RangeSelectorTest, ElementsOpEmptyList) {
(void)v;
}
)cc";
- StringRef ID = "id";
+ const char *ID = "id";
TestMatch Match = matchCode(Code, initListExpr().bind(ID));
EXPECT_THAT_EXPECTED(select(initListElements(ID), Match), HasValue(""));
}
@@ -529,7 +529,7 @@ TEST(RangeSelectorTest, ElseBranchOpSingleStatement) {
return x + 5;
}
)cc";
- StringRef ID = "id";
+ const char *ID = "id";
TestMatch Match = matchCode(Code, ifStmt().bind(ID));
EXPECT_THAT_EXPECTED(select(elseBranch(ID), Match), HasValue("else x = 4;"));
}
@@ -543,7 +543,7 @@ TEST(RangeSelectorTest, ElseBranchOpCompoundStatement) {
return x + 5;
}
)cc";
- StringRef ID = "id";
+ const char *ID = "id";
TestMatch Match = matchCode(Code, ifStmt().bind(ID));
EXPECT_THAT_EXPECTED(select(elseBranch(ID), Match),
HasValue("else { x = 4; }"));
@@ -556,7 +556,7 @@ TEST(RangeSelectorTest, ExpansionOp) {
BADDECL(x * x)
)cc";
- StringRef Fun = "Fun";
+ const char *Fun = "Fun";
TestMatch Match = matchCode(Code, functionDecl(hasName("bad")).bind(Fun));
EXPECT_THAT_EXPECTED(select(expansion(node(Fun)), Match),
HasValue("BADDECL(x * x)"));
@@ -569,7 +569,7 @@ TEST(RangeSelectorTest, ExpansionOpPartial) {
BADDECL(x * x)
)cc";
- StringRef Ret = "Ret";
+ const char *Ret = "Ret";
TestMatch Match = matchCode(Code, returnStmt().bind(Ret));
EXPECT_THAT_EXPECTED(select(expansion(node(Ret)), Match),
HasValue("BADDECL(x * x)"));
@@ -581,7 +581,7 @@ TEST(RangeSelectorTest, IfBoundOpBound) {
return 3 + 5;
}
)cc";
- StringRef ID = "id", Op = "op";
+ const char *ID = "id", *Op = "op";
TestMatch Match =
matchCode(Code, binaryOperator(hasLHS(expr().bind(ID))).bind(Op));
EXPECT_THAT_EXPECTED(select(ifBound(ID, node(ID), node(Op)), Match),
@@ -594,7 +594,7 @@ TEST(RangeSelectorTest, IfBoundOpUnbound) {
return 3 + 5;
}
)cc";
- StringRef ID = "id", Op = "op";
+ const char *ID = "id", *Op = "op";
TestMatch Match = matchCode(Code, binaryOperator().bind(Op));
EXPECT_THAT_EXPECTED(select(ifBound(ID, node(ID), node(Op)), Match),
HasValue("3 + 5"));
diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTestPostOrderVisitor.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTestPostOrderVisitor.cpp
index 965bb3d..9fd075e 100644
--- a/clang/unittests/Tooling/RecursiveASTVisitorTestPostOrderVisitor.cpp
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTestPostOrderVisitor.cpp
@@ -31,12 +31,12 @@ public:
bool shouldTraversePostOrder() const { return VisitPostOrder; }
bool VisitUnaryOperator(UnaryOperator *Op) {
- VisitedNodes.push_back(Op->getOpcodeStr(Op->getOpcode()));
+ VisitedNodes.push_back(std::string(Op->getOpcodeStr(Op->getOpcode())));
return true;
}
bool VisitBinaryOperator(BinaryOperator *Op) {
- VisitedNodes.push_back(Op->getOpcodeStr());
+ VisitedNodes.push_back(std::string(Op->getOpcodeStr()));
return true;
}
diff --git a/clang/unittests/Tooling/RefactoringTest.cpp b/clang/unittests/Tooling/RefactoringTest.cpp
index 5949c53..d65c6db 100644
--- a/clang/unittests/Tooling/RefactoringTest.cpp
+++ b/clang/unittests/Tooling/RefactoringTest.cpp
@@ -528,12 +528,12 @@ TEST_F(ReplacementTest, MultipleFilesReplaceAndFormat) {
// Scrambled the order of replacements.
std::map<std::string, Replacements> FileToReplaces;
- FileToReplaces[File1] = toReplacements(
+ FileToReplaces[std::string(File1)] = toReplacements(
{tooling::Replacement(Context.Sources, Context.getLocation(ID1, 1, 1), 6,
"auto "),
tooling::Replacement(Context.Sources, Context.getLocation(ID1, 3, 10), 1,
"12345678901")});
- FileToReplaces[File2] = toReplacements(
+ FileToReplaces[std::string(File2)] = toReplacements(
{tooling::Replacement(Context.Sources, Context.getLocation(ID2, 1, 12), 0,
"4567890123"),
tooling::Replacement(Context.Sources, Context.getLocation(ID2, 2, 9), 1,
@@ -612,7 +612,8 @@ public:
assert(File);
StringRef Found =
- TemporaryFiles.insert(std::make_pair(Name, Path.str())).first->second;
+ TemporaryFiles.insert(std::make_pair(Name, std::string(Path.str())))
+ .first->second;
assert(Found == Path);
(void)Found;
return Context.Sources.createFileID(*File, SourceLocation(),
@@ -628,7 +629,7 @@ public:
// FIXME: Figure out whether there is a way to get the SourceManger to
// reopen the file.
auto FileBuffer = Context.Files.getBufferForFile(Path);
- return (*FileBuffer)->getBuffer();
+ return std::string((*FileBuffer)->getBuffer());
}
llvm::StringMap<std::string> TemporaryFiles;
@@ -1044,8 +1045,8 @@ TEST(DeduplicateByFileTest, PathsWithDots) {
#endif
EXPECT_TRUE(VFS->addFile(Path1, 0, llvm::MemoryBuffer::getMemBuffer("")));
EXPECT_TRUE(VFS->addFile(Path2, 0, llvm::MemoryBuffer::getMemBuffer("")));
- FileToReplaces[Path1] = Replacements();
- FileToReplaces[Path2] = Replacements();
+ FileToReplaces[std::string(Path1)] = Replacements();
+ FileToReplaces[std::string(Path2)] = Replacements();
FileToReplaces = groupReplacementsByFile(FileMgr, FileToReplaces);
EXPECT_EQ(1u, FileToReplaces.size());
EXPECT_EQ(Path1, FileToReplaces.begin()->first);
@@ -1065,8 +1066,8 @@ TEST(DeduplicateByFileTest, PathWithDotSlash) {
#endif
EXPECT_TRUE(VFS->addFile(Path1, 0, llvm::MemoryBuffer::getMemBuffer("")));
EXPECT_TRUE(VFS->addFile(Path2, 0, llvm::MemoryBuffer::getMemBuffer("")));
- FileToReplaces[Path1] = Replacements();
- FileToReplaces[Path2] = Replacements();
+ FileToReplaces[std::string(Path1)] = Replacements();
+ FileToReplaces[std::string(Path2)] = Replacements();
FileToReplaces = groupReplacementsByFile(FileMgr, FileToReplaces);
EXPECT_EQ(1u, FileToReplaces.size());
EXPECT_EQ(Path1, FileToReplaces.begin()->first);
@@ -1084,8 +1085,8 @@ TEST(DeduplicateByFileTest, NonExistingFilePath) {
StringRef Path1 = ".\\a\\b\\c.h";
StringRef Path2 = "a\\b\\c.h";
#endif
- FileToReplaces[Path1] = Replacements();
- FileToReplaces[Path2] = Replacements();
+ FileToReplaces[std::string(Path1)] = Replacements();
+ FileToReplaces[std::string(Path2)] = Replacements();
FileToReplaces = groupReplacementsByFile(FileMgr, FileToReplaces);
EXPECT_TRUE(FileToReplaces.empty());
}
@@ -1306,7 +1307,7 @@ protected:
~ApplyAtomicChangesTest() override {}
void setInput(llvm::StringRef Input) {
- Code = Input;
+ Code = std::string(Input);
FID = Context.createInMemoryFile(FilePath, Code);
}
diff --git a/clang/unittests/Tooling/RewriterTestContext.h b/clang/unittests/Tooling/RewriterTestContext.h
index cfe5577a..99f7a11 100644
--- a/clang/unittests/Tooling/RewriterTestContext.h
+++ b/clang/unittests/Tooling/RewriterTestContext.h
@@ -77,7 +77,8 @@ class RewriterTestContext {
assert(File);
StringRef Found =
- TemporaryFiles.insert(std::make_pair(Name, Path.str())).first->second;
+ TemporaryFiles.insert(std::make_pair(Name, std::string(Path.str())))
+ .first->second;
assert(Found == Path);
(void)Found;
return Sources.createFileID(*File, SourceLocation(), SrcMgr::C_User);
@@ -107,7 +108,7 @@ class RewriterTestContext {
// FIXME: Figure out whether there is a way to get the SourceManger to
// reopen the file.
auto FileBuffer = Files.getBufferForFile(Path);
- return (*FileBuffer)->getBuffer();
+ return std::string((*FileBuffer)->getBuffer());
}
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
diff --git a/clang/unittests/Tooling/SourceCodeBuildersTest.cpp b/clang/unittests/Tooling/SourceCodeBuildersTest.cpp
index 9b5e7bf..b6f6aba 100644
--- a/clang/unittests/Tooling/SourceCodeBuildersTest.cpp
+++ b/clang/unittests/Tooling/SourceCodeBuildersTest.cpp
@@ -133,7 +133,7 @@ static void testBuilder(
ASSERT_TRUE(StmtMatch);
EXPECT_THAT(Builder(*StmtMatch->Result.Nodes.getNodeAs<Expr>("expr"),
*StmtMatch->Result.Context),
- ValueIs(Expected));
+ ValueIs(std::string(Expected)));
}
TEST(SourceCodeBuildersTest, BuildParensUnaryOp) {
diff --git a/clang/unittests/Tooling/StencilTest.cpp b/clang/unittests/Tooling/StencilTest.cpp
index b248a5a..bd35f0d 100644
--- a/clang/unittests/Tooling/StencilTest.cpp
+++ b/clang/unittests/Tooling/StencilTest.cpp
@@ -111,7 +111,8 @@ protected:
// Tests failures caused by references to unbound nodes. `unbound_id` is the
// id that will cause the failure.
void testUnboundNodeError(const Stencil &Stencil, StringRef UnboundId) {
- testError(Stencil, AllOf(HasSubstr(UnboundId), HasSubstr("not bound")));
+ testError(Stencil,
+ AllOf(HasSubstr(std::string(UnboundId)), HasSubstr("not bound")));
}
};
@@ -128,8 +129,9 @@ TEST_F(StencilTest, SingleStatement) {
hasThen(stmt().bind(Then)), hasElse(stmt().bind(Else))));
ASSERT_TRUE(StmtMatch);
// Invert the if-then-else.
- auto Stencil = cat("if (!", node(Condition), ") ", statement(Else), " else ",
- statement(Then));
+ auto Stencil =
+ cat("if (!", node(std::string(Condition)), ") ",
+ statement(std::string(Else)), " else ", statement(std::string(Then)));
EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result),
HasValue("if (!true) return 0; else return 1;"));
}
@@ -156,7 +158,8 @@ void testExpr(StringRef Id, StringRef Snippet, const Stencil &Stencil,
StringRef Expected) {
auto StmtMatch = matchStmt(Snippet, expr().bind(Id));
ASSERT_TRUE(StmtMatch);
- EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result), HasValue(Expected));
+ EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result),
+ HasValue(std::string(Expected)));
}
void testFailure(StringRef Id, StringRef Snippet, const Stencil &Stencil,
@@ -170,7 +173,7 @@ void testFailure(StringRef Id, StringRef Snippet, const Stencil &Stencil,
TEST_F(StencilTest, SelectionOp) {
StringRef Id = "id";
- testExpr(Id, "3;", cat(node(Id)), "3");
+ testExpr(Id, "3;", cat(node(std::string(Id))), "3");
}
TEST_F(StencilTest, IfBoundOpBound) {
diff --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp b/clang/unittests/Tooling/Syntax/TreeTest.cpp
index 42d77d8..1749e66 100644
--- a/clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -862,7 +862,8 @@ void test() {
auto *Root = buildTree(T.first);
std::string Expected = llvm::StringRef(T.second).trim().str();
- std::string Actual = llvm::StringRef(Root->dump(*Arena)).trim();
+ std::string Actual =
+ std::string(llvm::StringRef(Root->dump(*Arena)).trim());
EXPECT_EQ(Expected, Actual) << "the resulting dump is:\n" << Actual;
}
}
diff --git a/clang/unittests/Tooling/ToolingTest.cpp b/clang/unittests/Tooling/ToolingTest.cpp
index 1358134..59c9b4f 100644
--- a/clang/unittests/Tooling/ToolingTest.cpp
+++ b/clang/unittests/Tooling/ToolingTest.cpp
@@ -325,9 +325,9 @@ TEST(runToolOnCodeWithArgs, TestNoDepFile) {
std::vector<std::string> Args;
Args.push_back("-MMD");
Args.push_back("-MT");
- Args.push_back(DepFilePath.str());
+ Args.push_back(std::string(DepFilePath.str()));
Args.push_back("-MF");
- Args.push_back(DepFilePath.str());
+ Args.push_back(std::string(DepFilePath.str()));
EXPECT_TRUE(runToolOnCodeWithArgs(std::make_unique<SkipBodyAction>(), "", Args));
EXPECT_FALSE(llvm::sys::fs::exists(DepFilePath.str()));
EXPECT_FALSE(llvm::sys::fs::remove(DepFilePath.str()));
@@ -552,8 +552,9 @@ std::string getAnyTarget() {
StringRef TargetName(Target.getName());
if (TargetName == "x86-64")
TargetName = "x86_64";
- if (llvm::TargetRegistry::lookupTarget(TargetName, Error) == &Target) {
- return TargetName;
+ if (llvm::TargetRegistry::lookupTarget(std::string(TargetName), Error) ==
+ &Target) {
+ return std::string(TargetName);
}
}
return "";
diff --git a/clang/unittests/Tooling/TransformerTest.cpp b/clang/unittests/Tooling/TransformerTest.cpp
index c382783..454615c 100644
--- a/clang/unittests/Tooling/TransformerTest.cpp
+++ b/clang/unittests/Tooling/TransformerTest.cpp
@@ -174,7 +174,7 @@ TEST_F(TransformerTest, Flag) {
hasName("proto::ProtoCommandLineFlag"))))
.bind(Flag)),
unless(callee(cxxMethodDecl(hasName("GetProto"))))),
- changeTo(node(Flag), cat("EXPR")));
+ changeTo(node(std::string(Flag)), cat("EXPR")));
std::string Input = R"cc(
proto::ProtoCommandLineFlag flag;
@@ -229,7 +229,7 @@ TEST_F(TransformerTest, AddIncludeAngled) {
TEST_F(TransformerTest, NodePartNameNamedDecl) {
StringRef Fun = "fun";
RewriteRule Rule = makeRule(functionDecl(hasName("bad")).bind(Fun),
- changeTo(name(Fun), cat("good")));
+ changeTo(name(std::string(Fun)), cat("good")));
std::string Input = R"cc(
int bad(int x);
@@ -261,7 +261,7 @@ TEST_F(TransformerTest, NodePartNameDeclRef) {
StringRef Ref = "ref";
testRule(makeRule(declRefExpr(to(functionDecl(hasName("bad")))).bind(Ref),
- changeTo(name(Ref), cat("good"))),
+ changeTo(name(std::string(Ref)), cat("good"))),
Input, Expected);
}
@@ -279,7 +279,7 @@ TEST_F(TransformerTest, NodePartNameDeclRefFailure) {
StringRef Ref = "ref";
Transformer T(makeRule(declRefExpr(to(functionDecl())).bind(Ref),
- changeTo(name(Ref), cat("good"))),
+ changeTo(name(std::string(Ref)), cat("good"))),
consumer());
T.registerMatchers(&MatchFinder);
EXPECT_FALSE(rewrite(Input));
@@ -288,7 +288,7 @@ TEST_F(TransformerTest, NodePartNameDeclRefFailure) {
TEST_F(TransformerTest, NodePartMember) {
StringRef E = "expr";
RewriteRule Rule = makeRule(memberExpr(member(hasName("bad"))).bind(E),
- changeTo(member(E), cat("good")));
+ changeTo(member(std::string(E)), cat("good")));
std::string Input = R"cc(
struct S {
@@ -341,7 +341,8 @@ TEST_F(TransformerTest, NodePartMemberQualified) {
)cc";
StringRef E = "expr";
- testRule(makeRule(memberExpr().bind(E), changeTo(member(E), cat("good"))),
+ testRule(makeRule(memberExpr().bind(E),
+ changeTo(member(std::string(E)), cat("good"))),
Input, Expected);
}
@@ -373,7 +374,7 @@ TEST_F(TransformerTest, NodePartMemberMultiToken) {
StringRef MemExpr = "member";
testRule(makeRule(memberExpr().bind(MemExpr),
- changeTo(member(MemExpr), cat("good"))),
+ changeTo(member(std::string(MemExpr)), cat("good"))),
Input, Expected);
}
@@ -391,9 +392,10 @@ TEST_F(TransformerTest, InsertBeforeEdit) {
)cc";
StringRef Ret = "return";
- testRule(makeRule(returnStmt().bind(Ret),
- insertBefore(statement(Ret), cat("int y = 3;"))),
- Input, Expected);
+ testRule(
+ makeRule(returnStmt().bind(Ret),
+ insertBefore(statement(std::string(Ret)), cat("int y = 3;"))),
+ Input, Expected);
}
TEST_F(TransformerTest, InsertAfterEdit) {
@@ -412,9 +414,10 @@ TEST_F(TransformerTest, InsertAfterEdit) {
)cc";
StringRef Decl = "decl";
- testRule(makeRule(declStmt().bind(Decl),
- insertAfter(statement(Decl), cat("int y = 3;"))),
- Input, Expected);
+ testRule(
+ makeRule(declStmt().bind(Decl),
+ insertAfter(statement(std::string(Decl)), cat("int y = 3;"))),
+ Input, Expected);
}
TEST_F(TransformerTest, RemoveEdit) {
@@ -431,8 +434,9 @@ TEST_F(TransformerTest, RemoveEdit) {
)cc";
StringRef Decl = "decl";
- testRule(makeRule(declStmt().bind(Decl), remove(statement(Decl))), Input,
- Expected);
+ testRule(
+ makeRule(declStmt().bind(Decl), remove(statement(std::string(Decl)))),
+ Input, Expected);
}
TEST_F(TransformerTest, MultiChange) {
@@ -452,12 +456,13 @@ TEST_F(TransformerTest, MultiChange) {
)";
StringRef C = "C", T = "T", E = "E";
- testRule(makeRule(ifStmt(hasCondition(expr().bind(C)),
- hasThen(stmt().bind(T)), hasElse(stmt().bind(E))),
- {changeTo(node(C), cat("true")),
- changeTo(statement(T), cat("{ /* then */ }")),
- changeTo(statement(E), cat("{ /* else */ }"))}),
- Input, Expected);
+ testRule(
+ makeRule(ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
+ hasElse(stmt().bind(E))),
+ {changeTo(node(std::string(C)), cat("true")),
+ changeTo(statement(std::string(T)), cat("{ /* then */ }")),
+ changeTo(statement(std::string(E)), cat("{ /* else */ }"))}),
+ Input, Expected);
}
TEST_F(TransformerTest, OrderedRuleUnrelated) {
@@ -467,7 +472,7 @@ TEST_F(TransformerTest, OrderedRuleUnrelated) {
hasName("proto::ProtoCommandLineFlag"))))
.bind(Flag)),
unless(callee(cxxMethodDecl(hasName("GetProto"))))),
- changeTo(node(Flag), cat("PROTO")));
+ changeTo(node(std::string(Flag)), cat("PROTO")));
std::string Input = R"cc(
proto::ProtoCommandLineFlag flag;
@@ -582,9 +587,10 @@ TEST_F(TransformerTest, TextGeneratorFailure) {
}
std::string toString() const override { return "AlwaysFail"; }
};
- Transformer T(makeRule(binaryOperator().bind(O),
- changeTo(node(O), std::make_shared<AlwaysFail>())),
- consumer());
+ Transformer T(
+ makeRule(binaryOperator().bind(O),
+ changeTo(node(std::string(O)), std::make_shared<AlwaysFail>())),
+ consumer());
T.registerMatchers(&MatchFinder);
EXPECT_FALSE(rewrite(Input));
EXPECT_THAT(Changes, IsEmpty());
@@ -597,8 +603,8 @@ TEST_F(TransformerTest, OverlappingEditsInRule) {
// Try to change the whole binary-operator expression AND one its operands:
StringRef O = "O", L = "L";
Transformer T(makeRule(binaryOperator(hasLHS(expr().bind(L))).bind(O),
- {changeTo(node(O), cat("DELETE_OP")),
- changeTo(node(L), cat("DELETE_LHS"))}),
+ {changeTo(node(std::string(O)), cat("DELETE_OP")),
+ changeTo(node(std::string(L)), cat("DELETE_LHS"))}),
consumer());
T.registerMatchers(&MatchFinder);
EXPECT_FALSE(rewrite(Input));
@@ -611,7 +617,8 @@ TEST_F(TransformerTest, OverlappingEditsMultipleMatches) {
std::string Input = "int conflictOneRule() { return -7; }";
// Try to change the whole binary-operator expression AND one its operands:
StringRef E = "E";
- Transformer T(makeRule(expr().bind(E), changeTo(node(E), cat("DELETE_EXPR"))),
+ Transformer T(makeRule(expr().bind(E),
+ changeTo(node(std::string(E)), cat("DELETE_EXPR"))),
consumer());
T.registerMatchers(&MatchFinder);
// The rewrite process fails because the changes conflict with each other...
@@ -649,7 +656,7 @@ TEST_F(TransformerTest, SimpleMacro) {
StringRef zero = "zero";
RewriteRule R = makeRule(integerLiteral(equals(0)).bind(zero),
- changeTo(node(zero), cat("999")));
+ changeTo(node(std::string(zero)), cat("999")));
testRule(R, Input, Expected);
}
@@ -746,7 +753,7 @@ TEST_F(TransformerTest, MatchSpansMacroTextButChangeDoesNot) {
StringRef E = "expr";
testRule(makeRule(binaryOperator(hasLHS(expr().bind(E))),
- changeTo(node(E), cat("LIT"))),
+ changeTo(node(std::string(E)), cat("LIT"))),
Input, Expected);
}
@@ -764,7 +771,7 @@ TEST_F(TransformerTest, MatchSpansMacroTextButChangeDoesNotAnchoredInMacro) {
StringRef E = "expr";
testRule(makeRule(binaryOperator(hasRHS(expr().bind(E))),
- changeTo(node(E), cat("LIT"))),
+ changeTo(node(std::string(E)), cat("LIT"))),
Input, Expected);
}
@@ -779,7 +786,7 @@ TEST_F(TransformerTest, NoPartialRewriteOMacroExpansion) {
StringRef zero = "zero";
RewriteRule R = makeRule(integerLiteral(equals(0)).bind(zero),
- changeTo(node(zero), cat("0")));
+ changeTo(node(std::string(zero)), cat("0")));
testRule(R, Input, Input);
}
diff --git a/clang/unittests/libclang/TestUtils.h b/clang/unittests/libclang/TestUtils.h
index 883155e..347fa46 100644
--- a/clang/unittests/libclang/TestUtils.h
+++ b/clang/unittests/libclang/TestUtils.h
@@ -34,7 +34,7 @@ public:
void SetUp() override {
llvm::SmallString<256> Dir;
ASSERT_FALSE(llvm::sys::fs::createUniqueDirectory("libclang-test", Dir));
- TestDir = Dir.str();
+ TestDir = std::string(Dir.str());
TUFlags = CXTranslationUnit_DetailedPreprocessingRecord |
clang_defaultEditingTranslationUnitOptions();
Index = clang_createIndex(0, 0);
@@ -51,7 +51,7 @@ public:
if (!llvm::sys::path::is_absolute(Filename)) {
llvm::SmallString<256> Path(TestDir);
llvm::sys::path::append(Path, Filename);
- Filename = Path.str();
+ Filename = std::string(Path.str());
Files.insert(Filename);
}
llvm::sys::fs::create_directories(llvm::sys::path::parent_path(Filename));
@@ -63,7 +63,7 @@ public:
if (!llvm::sys::path::is_absolute(Filename)) {
llvm::SmallString<256> Path(TestDir);
llvm::sys::path::append(Path, Filename);
- Filename = Path.str();
+ Filename = std::string(Path.str());
}
auto it = UnsavedFileContents.insert(std::make_pair(
fixed_addr_string(new std::string(Filename)),
diff --git a/clang/utils/TableGen/ClangASTNodesEmitter.cpp b/clang/utils/TableGen/ClangASTNodesEmitter.cpp
index 1cc46cb..2b8d7a9 100644
--- a/clang/utils/TableGen/ClangASTNodesEmitter.cpp
+++ b/clang/utils/TableGen/ClangASTNodesEmitter.cpp
@@ -51,7 +51,7 @@ class ClangASTNodesEmitter {
const std::string &macroHierarchyName() {
assert(Root && "root node not yet derived!");
if (MacroHierarchyName.empty())
- MacroHierarchyName = macroName(Root.getName());
+ MacroHierarchyName = macroName(std::string(Root.getName()));
return MacroHierarchyName;
}
@@ -86,7 +86,7 @@ public:
// Called recursively to ensure that nodes remain contiguous
std::pair<ASTNode, ASTNode> ClangASTNodesEmitter::EmitNode(raw_ostream &OS,
ASTNode Base) {
- std::string BaseName = macroName(Base.getName());
+ std::string BaseName = macroName(std::string(Base.getName()));
ChildIterator i = Tree.lower_bound(Base), e = Tree.upper_bound(Base);
bool HasChildren = (i != e);
@@ -98,7 +98,7 @@ std::pair<ASTNode, ASTNode> ClangASTNodesEmitter::EmitNode(raw_ostream &OS,
for (; i != e; ++i) {
ASTNode Child = i->second;
bool Abstract = Child.isAbstract();
- std::string NodeName = macroName(Child.getName());
+ std::string NodeName = macroName(std::string(Child.getName()));
OS << "#ifndef " << NodeName << "\n";
OS << "# define " << NodeName << "(Type, Base) "
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 4c3742c..92792bb 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -54,14 +54,13 @@ public:
FlattenedSpelling(const std::string &Variety, const std::string &Name,
const std::string &Namespace, bool KnownToGCC) :
V(Variety), N(Name), NS(Namespace), K(KnownToGCC) {}
- explicit FlattenedSpelling(const Record &Spelling) :
- V(Spelling.getValueAsString("Variety")),
- N(Spelling.getValueAsString("Name")) {
-
+ explicit FlattenedSpelling(const Record &Spelling)
+ : V(std::string(Spelling.getValueAsString("Variety"))),
+ N(std::string(Spelling.getValueAsString("Name"))) {
assert(V != "GCC" && V != "Clang" &&
"Given a GCC spelling, which means this hasn't been flattened!");
if (V == "CXX11" || V == "C2x" || V == "Pragma")
- NS = Spelling.getValueAsString("Namespace");
+ NS = std::string(Spelling.getValueAsString("Namespace"));
bool Unset;
K = Spelling.getValueAsBitOrUnset("KnownToGCC", Unset);
}
@@ -84,13 +83,13 @@ GetFlattenedSpellings(const Record &Attr) {
StringRef Name = Spelling->getValueAsString("Name");
if (Variety == "GCC") {
// Gin up two new spelling objects to add into the list.
- Ret.emplace_back("GNU", Name, "", true);
- Ret.emplace_back("CXX11", Name, "gnu", true);
+ Ret.emplace_back("GNU", std::string(Name), "", true);
+ Ret.emplace_back("CXX11", std::string(Name), "gnu", true);
} else if (Variety == "Clang") {
- Ret.emplace_back("GNU", Name, "", false);
- Ret.emplace_back("CXX11", Name, "clang", false);
+ Ret.emplace_back("GNU", std::string(Name), "", false);
+ Ret.emplace_back("CXX11", std::string(Name), "clang", false);
if (Spelling->getValueAsBit("AllowInC"))
- Ret.emplace_back("C2x", Name, "clang", false);
+ Ret.emplace_back("C2x", std::string(Name), "clang", false);
} else
Ret.push_back(FlattenedSpelling(*Spelling));
}
@@ -100,14 +99,15 @@ GetFlattenedSpellings(const Record &Attr) {
static std::string ReadPCHRecord(StringRef type) {
return StringSwitch<std::string>(type)
- .EndsWith("Decl *", "Record.GetLocalDeclAs<"
- + std::string(type, 0, type.size()-1) + ">(Record.readInt())")
- .Case("TypeSourceInfo *", "Record.readTypeSourceInfo()")
- .Case("Expr *", "Record.readExpr()")
- .Case("IdentifierInfo *", "Record.readIdentifier()")
- .Case("StringRef", "Record.readString()")
- .Case("ParamIdx", "ParamIdx::deserialize(Record.readInt())")
- .Default("Record.readInt()");
+ .EndsWith("Decl *", "Record.GetLocalDeclAs<" +
+ std::string(type.data(), 0, type.size() - 1) +
+ ">(Record.readInt())")
+ .Case("TypeSourceInfo *", "Record.readTypeSourceInfo()")
+ .Case("Expr *", "Record.readExpr()")
+ .Case("IdentifierInfo *", "Record.readIdentifier()")
+ .Case("StringRef", "Record.readString()")
+ .Case("ParamIdx", "ParamIdx::deserialize(Record.readInt())")
+ .Default("Record.readInt()");
}
// Get a type that is suitable for storing an object of the specified type.
@@ -119,14 +119,18 @@ static StringRef getStorageType(StringRef type) {
// Assumes that the way to get the value is SA->getname()
static std::string WritePCHRecord(StringRef type, StringRef name) {
- return "Record." + StringSwitch<std::string>(type)
- .EndsWith("Decl *", "AddDeclRef(" + std::string(name) + ");\n")
- .Case("TypeSourceInfo *", "AddTypeSourceInfo(" + std::string(name) + ");\n")
- .Case("Expr *", "AddStmt(" + std::string(name) + ");\n")
- .Case("IdentifierInfo *", "AddIdentifierRef(" + std::string(name) + ");\n")
- .Case("StringRef", "AddString(" + std::string(name) + ");\n")
- .Case("ParamIdx", "push_back(" + std::string(name) + ".serialize());\n")
- .Default("push_back(" + std::string(name) + ");\n");
+ return "Record." +
+ StringSwitch<std::string>(type)
+ .EndsWith("Decl *", "AddDeclRef(" + std::string(name) + ");\n")
+ .Case("TypeSourceInfo *",
+ "AddTypeSourceInfo(" + std::string(name) + ");\n")
+ .Case("Expr *", "AddStmt(" + std::string(name) + ");\n")
+ .Case("IdentifierInfo *",
+ "AddIdentifierRef(" + std::string(name) + ");\n")
+ .Case("StringRef", "AddString(" + std::string(name) + ");\n")
+ .Case("ParamIdx",
+ "push_back(" + std::string(name) + ".serialize());\n")
+ .Default("push_back(" + std::string(name) + ");\n");
}
// Normalize attribute name by removing leading and trailing
@@ -167,7 +171,7 @@ static ParsedAttrMap getParsedAttrList(const RecordKeeper &Records,
std::string AN;
if (Attr->isSubClassOf("TargetSpecificAttr") &&
!Attr->isValueUnset("ParseKind")) {
- AN = Attr->getValueAsString("ParseKind");
+ AN = std::string(Attr->getValueAsString("ParseKind"));
// If this attribute has already been handled, it does not need to be
// handled again.
@@ -196,8 +200,8 @@ namespace {
public:
Argument(const Record &Arg, StringRef Attr)
- : lowerName(Arg.getValueAsString("Name")), upperName(lowerName),
- attrName(Attr), isOpt(false), Fake(false) {
+ : lowerName(std::string(Arg.getValueAsString("Name"))),
+ upperName(lowerName), attrName(Attr), isOpt(false), Fake(false) {
if (!lowerName.empty()) {
lowerName[0] = std::tolower(lowerName[0]);
upperName[0] = std::toupper(upperName[0]);
@@ -299,8 +303,9 @@ namespace {
}
void writePCHWrite(raw_ostream &OS) const override {
- OS << " " << WritePCHRecord(type, "SA->get" +
- std::string(getUpperName()) + "()");
+ OS << " "
+ << WritePCHRecord(type,
+ "SA->get" + std::string(getUpperName()) + "()");
}
std::string getIsOmitted() const override {
@@ -642,7 +647,7 @@ namespace {
VariadicArgument(const Record &Arg, StringRef Attr, std::string T)
: Argument(Arg, Attr), Type(std::move(T)),
ArgName(getLowerName().str() + "_"), ArgSizeName(ArgName + "Size"),
- RangeName(getLowerName()) {}
+ RangeName(std::string(getLowerName())) {}
const std::string &getType() const { return Type; }
const std::string &getArgName() const { return ArgName; }
@@ -719,8 +724,8 @@ namespace {
// If we can't store the values in the current type (if it's something
// like StringRef), store them in a different type and convert the
// container afterwards.
- std::string StorageType = getStorageType(getType());
- std::string StorageName = getLowerName();
+ std::string StorageType = std::string(getStorageType(getType()));
+ std::string StorageName = std::string(getLowerName());
if (StorageType != getType()) {
StorageName += "Storage";
OS << " SmallVector<" << StorageType << ", 4> "
@@ -805,11 +810,10 @@ namespace {
public:
EnumArgument(const Record &Arg, StringRef Attr)
- : Argument(Arg, Attr), type(Arg.getValueAsString("Type")),
- values(Arg.getValueAsListOfStrings("Values")),
- enums(Arg.getValueAsListOfStrings("Enums")),
- uniques(uniqueEnumsInOrder(enums))
- {
+ : Argument(Arg, Attr), type(std::string(Arg.getValueAsString("Type"))),
+ values(Arg.getValueAsListOfStrings("Values")),
+ enums(Arg.getValueAsListOfStrings("Enums")),
+ uniques(uniqueEnumsInOrder(enums)) {
// FIXME: Emit a proper error
assert(!uniques.empty());
}
@@ -934,12 +938,12 @@ namespace {
public:
VariadicEnumArgument(const Record &Arg, StringRef Attr)
- : VariadicArgument(Arg, Attr, Arg.getValueAsString("Type")),
- type(Arg.getValueAsString("Type")),
- values(Arg.getValueAsListOfStrings("Values")),
- enums(Arg.getValueAsListOfStrings("Enums")),
- uniques(uniqueEnumsInOrder(enums))
- {
+ : VariadicArgument(Arg, Attr,
+ std::string(Arg.getValueAsString("Type"))),
+ type(std::string(Arg.getValueAsString("Type"))),
+ values(Arg.getValueAsListOfStrings("Values")),
+ enums(Arg.getValueAsListOfStrings("Enums")),
+ uniques(uniqueEnumsInOrder(enums)) {
QualifiedTypeName = getAttrName().str() + "Attr::" + type;
// FIXME: Emit a proper error
@@ -1241,8 +1245,9 @@ namespace {
}
void writePCHWrite(raw_ostream &OS) const override {
- OS << " " << WritePCHRecord(
- getType(), "SA->get" + std::string(getUpperName()) + "Loc()");
+ OS << " "
+ << WritePCHRecord(getType(),
+ "SA->get" + std::string(getUpperName()) + "Loc()");
}
};
@@ -1577,11 +1582,12 @@ static void writeAttrAccessorDefinition(const Record &R, raw_ostream &OS) {
static bool
SpellingNamesAreCommon(const std::vector<FlattenedSpelling>& Spellings) {
assert(!Spellings.empty() && "An empty list of spellings was provided");
- std::string FirstName = NormalizeNameForSpellingComparison(
- Spellings.front().name());
+ std::string FirstName =
+ std::string(NormalizeNameForSpellingComparison(Spellings.front().name()));
for (const auto &Spelling :
llvm::make_range(std::next(Spellings.begin()), Spellings.end())) {
- std::string Name = NormalizeNameForSpellingComparison(Spelling.name());
+ std::string Name =
+ std::string(NormalizeNameForSpellingComparison(Spelling.name()));
if (Name != FirstName)
return false;
}
@@ -1727,7 +1733,7 @@ struct AttributeSubjectMatchRule {
}
std::string getSpelling() const {
- std::string Result = MetaSubject->getValueAsString("Name");
+ std::string Result = std::string(MetaSubject->getValueAsString("Name"));
if (isSubRule()) {
Result += '(';
if (isNegatedSubRule())
@@ -1752,7 +1758,7 @@ struct AttributeSubjectMatchRule {
}
if (isAbstractRule())
Result += "_abstract";
- return Result.str();
+ return std::string(Result.str());
}
std::string getEnumValue() const { return "attr::" + getEnumValueName(); }
@@ -2258,7 +2264,7 @@ void clang::EmitClangAttrClass(RecordKeeper &Records, raw_ostream &OS) {
const Record *R = Super.first;
if (R->getName() != "TargetSpecificAttr" &&
R->getName() != "DeclOrTypeAttr" && SuperName.empty())
- SuperName = R->getName();
+ SuperName = std::string(R->getName());
if (R->getName() == "InheritableAttr")
Inheritable = true;
}
@@ -3298,7 +3304,7 @@ static void GenerateDefaultAppertainsTo(raw_ostream &OS) {
}
static std::string GetDiagnosticSpelling(const Record &R) {
- std::string Ret = R.getValueAsString("DiagSpelling");
+ std::string Ret = std::string(R.getValueAsString("DiagSpelling"));
if (!Ret.empty())
return Ret;
@@ -3334,7 +3340,7 @@ static std::string CalculateDiagnostic(const Record &S) {
SmallVector<StringRef, 2> Frags;
llvm::SplitString(V, Frags, ",");
for (auto Str : Frags) {
- DiagList.push_back(Str.trim());
+ DiagList.push_back(std::string(Str.trim()));
}
}
}
@@ -3365,7 +3371,7 @@ static std::string CalculateDiagnostic(const Record &S) {
}
static std::string GetSubjectWithSuffix(const Record *R) {
- const std::string &B = R->getName();
+ const std::string &B = std::string(R->getName());
if (B == "DeclBase")
return "Decl";
return B + "Decl";
@@ -3740,7 +3746,7 @@ void EmitClangAttrParsedAttrKinds(RecordKeeper &Records, raw_ostream &OS) {
std::string AttrName;
if (Attr.isSubClassOf("TargetSpecificAttr") &&
!Attr.isValueUnset("ParseKind")) {
- AttrName = Attr.getValueAsString("ParseKind");
+ AttrName = std::string(Attr.getValueAsString("ParseKind"));
if (Seen.find(AttrName) != Seen.end())
continue;
Seen.insert(AttrName);
@@ -3980,7 +3986,7 @@ GetAttributeHeadingAndSpellings(const Record &Documentation,
"documented");
// Determine the heading to be used for this attribute.
- std::string Heading = Documentation.getValueAsString("Heading");
+ std::string Heading = std::string(Documentation.getValueAsString("Heading"));
if (Heading.empty()) {
// If there's only one spelling, we can simply use that.
if (Spellings.size() == 1)
@@ -3989,7 +3995,8 @@ GetAttributeHeadingAndSpellings(const Record &Documentation,
std::set<std::string> Uniques;
for (auto I = Spellings.begin(), E = Spellings.end();
I != E && Uniques.size() <= 1; ++I) {
- std::string Spelling = NormalizeNameForSpellingComparison(I->name());
+ std::string Spelling =
+ std::string(NormalizeNameForSpellingComparison(I->name()));
Uniques.insert(Spelling);
}
// If the semantic map has only one spelling, that is sufficient for our
diff --git a/clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp b/clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp
index fc79d59..eb2f231 100644
--- a/clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp
+++ b/clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp
@@ -63,7 +63,7 @@ void clang::EmitClangCommentCommandInfo(RecordKeeper &Records, raw_ostream &OS)
std::vector<StringMatcher::StringPair> Matches;
for (size_t i = 0, e = Tags.size(); i != e; ++i) {
Record &Tag = *Tags[i];
- std::string Name = Tag.getValueAsString("Name");
+ std::string Name = std::string(Tag.getValueAsString("Name"));
std::string Return;
raw_string_ostream(Return) << "return &Commands[" << i << "];";
Matches.emplace_back(std::move(Name), std::move(Return));
diff --git a/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp b/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp
index ed3f4bd..a25ab11 100644
--- a/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp
+++ b/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp
@@ -54,7 +54,7 @@ void clang::EmitClangCommentHTMLNamedCharacterReferences(RecordKeeper &Records,
for (std::vector<Record *>::iterator I = Tags.begin(), E = Tags.end();
I != E; ++I) {
Record &Tag = **I;
- std::string Spelling = Tag.getValueAsString("Spelling");
+ std::string Spelling = std::string(Tag.getValueAsString("Spelling"));
uint64_t CodePoint = Tag.getValueAsInt("CodePoint");
CLiteral.clear();
CLiteral.append("return ");
diff --git a/clang/utils/TableGen/ClangCommentHTMLTagsEmitter.cpp b/clang/utils/TableGen/ClangCommentHTMLTagsEmitter.cpp
index 7b9fdfc..1c15029 100644
--- a/clang/utils/TableGen/ClangCommentHTMLTagsEmitter.cpp
+++ b/clang/utils/TableGen/ClangCommentHTMLTagsEmitter.cpp
@@ -40,7 +40,7 @@ void clang::EmitClangCommentHTMLTagsProperties(RecordKeeper &Records,
std::vector<StringMatcher::StringPair> MatchesEndTagOptional;
std::vector<StringMatcher::StringPair> MatchesEndTagForbidden;
for (Record *Tag : Tags) {
- std::string Spelling = Tag->getValueAsString("Spelling");
+ std::string Spelling = std::string(Tag->getValueAsString("Spelling"));
StringMatcher::StringPair Match(Spelling, "return true;");
if (Tag->getValueAsBit("EndTagOptional"))
MatchesEndTagOptional.push_back(Match);
diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
index f694c3e..eb1fb8d 100644
--- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -62,7 +62,7 @@ static std::string
getCategoryFromDiagGroup(const Record *Group,
DiagGroupParentMap &DiagGroupParents) {
// If the DiagGroup has a category, return it.
- std::string CatName = Group->getValueAsString("CategoryName");
+ std::string CatName = std::string(Group->getValueAsString("CategoryName"));
if (!CatName.empty()) return CatName;
// The diag group may the subgroup of one or more other diagnostic groups,
@@ -88,7 +88,7 @@ static std::string getDiagnosticCategory(const Record *R,
}
// If the diagnostic itself has a category, get it.
- return R->getValueAsString("CategoryName");
+ return std::string(R->getValueAsString("CategoryName"));
}
namespace {
@@ -168,7 +168,8 @@ static void groupDiagnostics(const std::vector<Record*> &Diags,
continue;
assert(R->getValueAsDef("Class")->getName() != "CLASS_NOTE" &&
"Note can't be in a DiagGroup");
- std::string GroupName = DI->getDef()->getValueAsString("GroupName");
+ std::string GroupName =
+ std::string(DI->getDef()->getValueAsString("GroupName"));
DiagsInGroup[GroupName].DiagsInGroup.push_back(R);
}
@@ -179,7 +180,8 @@ static void groupDiagnostics(const std::vector<Record*> &Diags,
// groups (these are warnings that GCC supports that clang never produces).
for (unsigned i = 0, e = DiagGroups.size(); i != e; ++i) {
Record *Group = DiagGroups[i];
- GroupInfo &GI = DiagsInGroup[Group->getValueAsString("GroupName")];
+ GroupInfo &GI =
+ DiagsInGroup[std::string(Group->getValueAsString("GroupName"))];
if (Group->isAnonymous()) {
if (GI.DiagsInGroup.size() > 1)
ImplicitGroups.insert(&GI);
@@ -192,7 +194,8 @@ static void groupDiagnostics(const std::vector<Record*> &Diags,
std::vector<Record*> SubGroups = Group->getValueAsListOfDefs("SubGroups");
for (unsigned j = 0, e = SubGroups.size(); j != e; ++j)
- GI.SubGroups.push_back(SubGroups[j]->getValueAsString("GroupName"));
+ GI.SubGroups.push_back(
+ std::string(SubGroups[j]->getValueAsString("GroupName")));
}
// Assign unique ID numbers to the groups.
@@ -219,7 +222,8 @@ static void groupDiagnostics(const std::vector<Record*> &Diags,
ArrayRef<const Record *> GroupDiags = (*I)->DiagsInGroup;
if ((*I)->ExplicitDef) {
- std::string Name = (*I)->ExplicitDef->getValueAsString("GroupName");
+ std::string Name =
+ std::string((*I)->ExplicitDef->getValueAsString("GroupName"));
for (ArrayRef<const Record *>::const_iterator DI = GroupDiags.begin(),
DE = GroupDiags.end();
DI != DE; ++DI) {
@@ -244,7 +248,8 @@ static void groupDiagnostics(const std::vector<Record*> &Diags,
const DefInit *GroupInit = cast<DefInit>((*DI)->getValueInit("Group"));
const Record *NextDiagGroup = GroupInit->getDef();
- std::string Name = NextDiagGroup->getValueAsString("GroupName");
+ std::string Name =
+ std::string(NextDiagGroup->getValueAsString("GroupName"));
SrcMgr.PrintMessage((*DI)->getLoc().front(),
SourceMgr::DK_Error,
@@ -315,8 +320,8 @@ private:
bool InferPedantic::isSubGroupOfGroup(const Record *Group,
llvm::StringRef GName) {
-
- const std::string &GroupName = Group->getValueAsString("GroupName");
+ const std::string &GroupName =
+ std::string(Group->getValueAsString("GroupName"));
if (GName == GroupName)
return true;
@@ -330,13 +335,14 @@ bool InferPedantic::isSubGroupOfGroup(const Record *Group,
/// Determine if the diagnostic is an extension.
bool InferPedantic::isExtension(const Record *Diag) {
- const std::string &ClsName = Diag->getValueAsDef("Class")->getName();
+ const std::string &ClsName =
+ std::string(Diag->getValueAsDef("Class")->getName());
return ClsName == "CLASS_EXTENSION";
}
bool InferPedantic::isOffByDefault(const Record *Diag) {
- const std::string &DefSeverity =
- Diag->getValueAsDef("DefaultSeverity")->getValueAsString("Name");
+ const std::string &DefSeverity = std::string(
+ Diag->getValueAsDef("DefaultSeverity")->getValueAsString("Name"));
return DefSeverity == "Ignored";
}
@@ -344,7 +350,8 @@ bool InferPedantic::groupInPedantic(const Record *Group, bool increment) {
GMap::mapped_type &V = GroupCount[Group];
// Lazily compute the threshold value for the group count.
if (!V.second.hasValue()) {
- const GroupInfo &GI = DiagsInGroup[Group->getValueAsString("GroupName")];
+ const GroupInfo &GI =
+ DiagsInGroup[std::string(Group->getValueAsString("GroupName"))];
V.second = GI.SubGroups.size() + GI.DiagsInGroup.size();
}
@@ -1176,12 +1183,14 @@ std::string DiagnosticTextBuilder::buildForDefinition(const Record *R) {
//===----------------------------------------------------------------------===//
static bool isError(const Record &Diag) {
- const std::string &ClsName = Diag.getValueAsDef("Class")->getName();
+ const std::string &ClsName =
+ std::string(Diag.getValueAsDef("Class")->getName());
return ClsName == "CLASS_ERROR";
}
static bool isRemark(const Record &Diag) {
- const std::string &ClsName = Diag.getValueAsDef("Class")->getName();
+ const std::string &ClsName =
+ std::string(Diag.getValueAsDef("Class")->getName());
return ClsName == "CLASS_REMARK";
}
@@ -1226,7 +1235,8 @@ void clang::EmitClangDiagsDefs(RecordKeeper &Records, raw_ostream &OS,
if (isError(R)) {
if (DefInit *Group = dyn_cast<DefInit>(R.getValueInit("Group"))) {
const Record *GroupRec = Group->getDef();
- const std::string &GroupName = GroupRec->getValueAsString("GroupName");
+ const std::string &GroupName =
+ std::string(GroupRec->getValueAsString("GroupName"));
PrintFatalError(R.getLoc(), "Error " + R.getName() +
" cannot be in a warning group [" + GroupName + "]");
}
@@ -1256,8 +1266,8 @@ void clang::EmitClangDiagsDefs(RecordKeeper &Records, raw_ostream &OS,
// Warning associated with the diagnostic. This is stored as an index into
// the alphabetically sorted warning table.
if (DefInit *DI = dyn_cast<DefInit>(R.getValueInit("Group"))) {
- std::map<std::string, GroupInfo>::iterator I =
- DiagsInGroup.find(DI->getDef()->getValueAsString("GroupName"));
+ std::map<std::string, GroupInfo>::iterator I = DiagsInGroup.find(
+ std::string(DI->getDef()->getValueAsString("GroupName")));
assert(I != DiagsInGroup.end());
OS << ", " << I->second.IDNo;
} else if (DiagsInPedantic.count(&R)) {
@@ -1299,7 +1309,7 @@ static std::string getDiagCategoryEnum(llvm::StringRef name) {
SmallString<256> enumName = llvm::StringRef("DiagCat_");
for (llvm::StringRef::iterator I = name.begin(), E = name.end(); I != E; ++I)
enumName += isalnum(*I) ? *I : '_';
- return enumName.str();
+ return std::string(enumName.str());
}
/// Emit the array of diagnostic subgroups.
@@ -1335,7 +1345,8 @@ static void emitDiagSubGroups(std::map<std::string, GroupInfo> &DiagsInGroup,
// Emit the groups implicitly in "pedantic".
if (IsPedantic) {
for (auto const &Group : GroupsInPedantic) {
- const std::string &GroupName = Group->getValueAsString("GroupName");
+ const std::string &GroupName =
+ std::string(Group->getValueAsString("GroupName"));
std::map<std::string, GroupInfo>::const_iterator RI =
DiagsInGroup.find(GroupName);
assert(RI != DiagsInGroup.end() && "Referenced without existing?");
@@ -1572,8 +1583,8 @@ namespace {
struct RecordIndexElement
{
RecordIndexElement() {}
- explicit RecordIndexElement(Record const &R):
- Name(R.getName()) {}
+ explicit RecordIndexElement(Record const &R)
+ : Name(std::string(R.getName())) {}
std::string Name;
};
@@ -1614,7 +1625,7 @@ bool isRemarkGroup(const Record *DiagGroup,
bool AnyRemarks = false, AnyNonRemarks = false;
std::function<void(StringRef)> Visit = [&](StringRef GroupName) {
- auto &GroupInfo = DiagsInGroup.find(GroupName)->second;
+ auto &GroupInfo = DiagsInGroup.find(std::string(GroupName))->second;
for (const Record *Diag : GroupInfo.DiagsInGroup)
(isRemark(*Diag) ? AnyRemarks : AnyNonRemarks) = true;
for (const auto &Name : GroupInfo.SubGroups)
@@ -1630,7 +1641,8 @@ bool isRemarkGroup(const Record *DiagGroup,
}
std::string getDefaultSeverity(const Record *Diag) {
- return Diag->getValueAsDef("DefaultSeverity")->getValueAsString("Name");
+ return std::string(
+ Diag->getValueAsDef("DefaultSeverity")->getValueAsString("Name"));
}
std::set<std::string>
@@ -1639,7 +1651,7 @@ getDefaultSeverities(const Record *DiagGroup,
std::set<std::string> States;
std::function<void(StringRef)> Visit = [&](StringRef GroupName) {
- auto &GroupInfo = DiagsInGroup.find(GroupName)->second;
+ auto &GroupInfo = DiagsInGroup.find(std::string(GroupName))->second;
for (const Record *Diag : GroupInfo.DiagsInGroup)
States.insert(getDefaultSeverity(Diag));
for (const auto &Name : GroupInfo.SubGroups)
@@ -1714,7 +1726,8 @@ void clang::EmitClangDiagDocs(RecordKeeper &Records, raw_ostream &OS) {
DiagsInPedantic.begin(),
DiagsInPedantic.end());
for (auto *Group : GroupsInPedantic)
- PedDiags.SubGroups.push_back(Group->getValueAsString("GroupName"));
+ PedDiags.SubGroups.push_back(
+ std::string(Group->getValueAsString("GroupName")));
}
// FIXME: Write diagnostic categories and link to diagnostic groups in each.
@@ -1722,7 +1735,8 @@ void clang::EmitClangDiagDocs(RecordKeeper &Records, raw_ostream &OS) {
// Write out the diagnostic groups.
for (const Record *G : DiagGroups) {
bool IsRemarkGroup = isRemarkGroup(G, DiagsInGroup);
- auto &GroupInfo = DiagsInGroup[G->getValueAsString("GroupName")];
+ auto &GroupInfo =
+ DiagsInGroup[std::string(G->getValueAsString("GroupName"))];
bool IsSynonym = GroupInfo.DiagsInGroup.empty() &&
GroupInfo.SubGroups.size() == 1;
diff --git a/clang/utils/TableGen/ClangOptionDocEmitter.cpp b/clang/utils/TableGen/ClangOptionDocEmitter.cpp
index b944ad9..23aa31c 100644
--- a/clang/utils/TableGen/ClangOptionDocEmitter.cpp
+++ b/clang/utils/TableGen/ClangOptionDocEmitter.cpp
@@ -48,7 +48,7 @@ Documentation extractDocumentation(RecordKeeper &Records) {
std::map<std::string, Record*> OptionsByName;
for (Record *R : Records.getAllDerivedDefinitions("Option"))
- OptionsByName[R->getValueAsString("Name")] = R;
+ OptionsByName[std::string(R->getValueAsString("Name"))] = R;
auto Flatten = [](Record *R) {
return R->getValue("DocFlatten") && R->getValueAsBit("DocFlatten");
@@ -81,7 +81,7 @@ Documentation extractDocumentation(RecordKeeper &Records) {
}
// Pretend no-X and Xno-Y options are aliases of X and XY.
- std::string Name = R->getValueAsString("Name");
+ std::string Name = std::string(R->getValueAsString("Name"));
if (Name.size() >= 4) {
if (Name.substr(0, 3) == "no-" && OptionsByName[Name.substr(3)]) {
Aliases[OptionsByName[Name.substr(3)]].push_back(R);
@@ -223,7 +223,7 @@ std::string getRSTStringWithTextFallback(const Record *R, StringRef Primary,
return Field == Primary ? Value.str() : escapeRST(Value);
}
}
- return StringRef();
+ return std::string(StringRef());
}
void emitOptionWithArgs(StringRef Prefix, const Record *Option,
@@ -247,7 +247,7 @@ void emitOptionName(StringRef Prefix, const Record *Option, raw_ostream &OS) {
std::vector<std::string> Args;
if (HasMetaVarName)
- Args.push_back(Option->getValueAsString("MetaVarName"));
+ Args.push_back(std::string(Option->getValueAsString("MetaVarName")));
else if (NumArgs == 1)
Args.push_back("<arg>");
@@ -316,8 +316,8 @@ void emitOption(const DocumentedOption &Option, const Record *DocInfo,
std::vector<std::string> SphinxOptionIDs;
forEachOptionName(Option, DocInfo, [&](const Record *Option) {
for (auto &Prefix : Option->getValueAsListOfStrings("Prefixes"))
- SphinxOptionIDs.push_back(
- getSphinxOptionID((Prefix + Option->getValueAsString("Name")).str()));
+ SphinxOptionIDs.push_back(std::string(getSphinxOptionID(
+ (Prefix + Option->getValueAsString("Name")).str())));
});
assert(!SphinxOptionIDs.empty() && "no flags for option");
static std::map<std::string, int> NextSuffix;
diff --git a/clang/utils/TableGen/ClangSACheckersEmitter.cpp b/clang/utils/TableGen/ClangSACheckersEmitter.cpp
index feefbeb..50725ae 100644
--- a/clang/utils/TableGen/ClangSACheckersEmitter.cpp
+++ b/clang/utils/TableGen/ClangSACheckersEmitter.cpp
@@ -53,7 +53,7 @@ static std::string getCheckerFullName(const Record *R) {
static std::string getStringValue(const Record &R, StringRef field) {
if (StringInit *SI = dyn_cast<StringInit>(R.getValueInit(field)))
- return SI->getValue();
+ return std::string(SI->getValue());
return std::string();
}
diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp
index 664787f..d3af74f 100644
--- a/clang/utils/TableGen/MveEmitter.cpp
+++ b/clang/utils/TableGen/MveEmitter.cpp
@@ -242,7 +242,7 @@ public:
.Case("u", ScalarTypeKind::UnsignedInt)
.Case("f", ScalarTypeKind::Float);
Bits = Record->getValueAsInt("size");
- NameOverride = Record->getValueAsString("nameOverride");
+ NameOverride = std::string(Record->getValueAsString("nameOverride"));
}
unsigned sizeInBits() const override { return Bits; }
ScalarTypeKind kind() const { return Kind; }
@@ -423,16 +423,16 @@ struct CodeGenParamAllocator {
// variable we should be keeping things in.
int MapValue = (*ParamNumberMap)[nparams++];
if (MapValue < 0)
- return Value;
+ return std::string(Value);
ParamNumber = MapValue;
}
// If we've allocated a new parameter variable for the first time, store
// its type and value to be retrieved after codegen.
if (ParamTypes && ParamTypes->size() == ParamNumber)
- ParamTypes->push_back(Type);
+ ParamTypes->push_back(std::string(Type));
if (ParamValues && ParamValues->size() == ParamNumber)
- ParamValues->push_back(Value);
+ ParamValues->push_back(std::string(Value));
// Unimaginative naming scheme for parameter variables.
return "Param" + utostr(ParamNumber);
@@ -515,7 +515,7 @@ public:
VarNameUsed = true;
return VarName;
}
- void setVarname(const StringRef s) { VarName = s; }
+ void setVarname(const StringRef s) { VarName = std::string(s); }
bool varnameUsed() const { return VarNameUsed; }
// Emit code to generate this result as a Value *.
@@ -714,7 +714,8 @@ public:
std::vector<Ptr> Args;
IRIntrinsicResult(StringRef IntrinsicID, std::vector<const Type *> ParamTypes,
std::vector<Ptr> Args)
- : IntrinsicID(IntrinsicID), ParamTypes(ParamTypes), Args(Args) {}
+ : IntrinsicID(std::string(IntrinsicID)), ParamTypes(ParamTypes),
+ Args(Args) {}
void genCode(raw_ostream &OS,
CodeGenParamAllocator &ParamAlloc) const override {
std::string IntNo = ParamAlloc.allocParam(
@@ -866,7 +867,7 @@ public:
llvm::APInt i = iOrig.trunc(64);
SmallString<40> s;
i.toString(s, 16, true, true);
- return s.str();
+ return std::string(s.str());
}
std::string genSema() const {
@@ -955,7 +956,7 @@ public:
// maps stored in this object.
const VoidType *getVoidType() { return &Void; }
const ScalarType *getScalarType(StringRef Name) {
- return ScalarTypes[Name].get();
+ return ScalarTypes[std::string(Name)].get();
}
const ScalarType *getScalarType(Record *R) {
return getScalarType(R->getName());
@@ -1132,7 +1133,7 @@ Result::Ptr MveEmitter::getCodeForDag(DagInit *D, const Result::Scope &Scope,
getCodeForDag(cast<DagInit>(D->getArg(i)), SubScope, Param);
StringRef ArgName = D->getArgNameStr(i);
if (!ArgName.empty())
- SubScope[ArgName] = V;
+ SubScope[std::string(ArgName)] = V;
if (PrevV)
V->setPredecessor(PrevV);
PrevV = V;
@@ -1190,7 +1191,7 @@ Result::Ptr MveEmitter::getCodeForDag(DagInit *D, const Result::Scope &Scope,
if (sp->isSubClassOf("IRBuilderAddrParam")) {
AddressArgs.insert(Index);
} else if (sp->isSubClassOf("IRBuilderIntParam")) {
- IntegerArgs[Index] = sp->getValueAsString("type");
+ IntegerArgs[Index] = std::string(sp->getValueAsString("type"));
}
}
return std::make_shared<IRBuilderResult>(Op->getValueAsString("prefix"),
@@ -1199,7 +1200,7 @@ Result::Ptr MveEmitter::getCodeForDag(DagInit *D, const Result::Scope &Scope,
std::vector<const Type *> ParamTypes;
for (Record *RParam : Op->getValueAsListOfDefs("params"))
ParamTypes.push_back(getType(RParam, Param));
- std::string IntName = Op->getValueAsString("intname");
+ std::string IntName = std::string(Op->getValueAsString("intname"));
if (Op->getValueAsBit("appendKind"))
IntName += "_" + toLetter(cast<ScalarType>(Param)->kind());
return std::make_shared<IRIntrinsicResult>(IntName, ParamTypes, Args);
@@ -1219,7 +1220,7 @@ Result::Ptr MveEmitter::getCodeForDagArg(DagInit *D, unsigned ArgNum,
if (!isa<UnsetInit>(Arg))
PrintFatalError(
"dag operator argument should not have both a value and a name");
- auto it = Scope.find(Name);
+ auto it = Scope.find(std::string(Name));
if (it == Scope.end())
PrintFatalError("unrecognized variable name '" + Name + "'");
return it->second;
@@ -1274,7 +1275,8 @@ ACLEIntrinsic::ACLEIntrinsic(MveEmitter &ME, Record *R, const Type *Param)
(R->isSubClassOf("NameOverride") ? R->getValueAsString("basename")
: R->getName());
StringRef overrideLetter = R->getValueAsString("overrideKindLetter");
- FullName = (Twine(BaseName) + Param->acleSuffix(overrideLetter)).str();
+ FullName =
+ (Twine(BaseName) + Param->acleSuffix(std::string(overrideLetter))).str();
// Derive the intrinsic's polymorphic name, by removing components from the
// full name as specified by its 'pnt' member ('polymorphic name type'),
@@ -1364,7 +1366,8 @@ ACLEIntrinsic::ACLEIntrinsic(MveEmitter &ME, Record *R, const Type *Param)
// into the variable-name scope that the code gen will refer to.
StringRef ArgName = ArgsDag->getArgNameStr(i);
if (!ArgName.empty())
- Scope[ArgName] = ME.getCodeForArg(i, ArgType, Promote, Immediate);
+ Scope[std::string(ArgName)] =
+ ME.getCodeForArg(i, ArgType, Promote, Immediate);
}
// Finally, go through the codegen dag and translate it into a Result object
@@ -1382,9 +1385,9 @@ ACLEIntrinsic::ACLEIntrinsic(MveEmitter &ME, Record *R, const Type *Param)
if (Name.empty()) {
PrintFatalError("Operands to CustomCodegen should have names");
} else if (auto *II = dyn_cast<IntInit>(CodeDag->getArg(i))) {
- CustomCodeGenArgs[Name] = itostr(II->getValue());
+ CustomCodeGenArgs[std::string(Name)] = itostr(II->getValue());
} else if (auto *SI = dyn_cast<StringInit>(CodeDag->getArg(i))) {
- CustomCodeGenArgs[Name] = SI->getValue();
+ CustomCodeGenArgs[std::string(Name)] = std::string(SI->getValue());
} else {
PrintFatalError("Operands to CustomCodegen should be integers");
}
@@ -1403,7 +1406,7 @@ MveEmitter::MveEmitter(RecordKeeper &Records) {
// use it for operations such as 'find the unsigned version of this signed
// integer type'.
for (Record *R : Records.getAllDerivedDefinitions("PrimitiveType"))
- ScalarTypes[R->getName()] = std::make_unique<ScalarType>(R);
+ ScalarTypes[std::string(R->getName())] = std::make_unique<ScalarType>(R);
// Now go through the instances of Intrinsic, and for each one, iterate
// through its list of type parameters making an ACLEIntrinsic for each one.
@@ -1645,12 +1648,12 @@ void MveEmitter::EmitBuiltinDef(raw_ostream &OS) {
const ACLEIntrinsic &Int = *kv.second;
if (Int.polymorphic()) {
StringRef Name = Int.shortName();
- if (ShortNamesSeen.find(Name) == ShortNamesSeen.end()) {
+ if (ShortNamesSeen.find(std::string(Name)) == ShortNamesSeen.end()) {
OS << "BUILTIN(__builtin_arm_mve_" << Name << ", \"vi.\", \"nt";
if (Int.nonEvaluating())
OS << "u"; // indicate that this builtin doesn't evaluate its args
OS << "\")\n";
- ShortNamesSeen.insert(Name);
+ ShortNamesSeen.insert(std::string(Name));
}
}
}
diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp
index a0f3fb2..59ea154 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -1257,7 +1257,7 @@ void Intrinsic::emitBodyAsBuiltinCall() {
if (!getReturnType().isVoid() && !SRet)
S += "(" + RetVar.getType().str() + ") ";
- S += "__builtin_neon_" + mangleName(N, LocalCK) + "(";
+ S += "__builtin_neon_" + mangleName(std::string(N), LocalCK) + "(";
if (SRet)
S += "&" + RetVar.getName() + ", ";
@@ -1398,14 +1398,14 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagOp(DagInit *DI) {
if (DI->getNumArgs() == 2) {
// Unary op.
std::pair<Type, std::string> R =
- emitDagArg(DI->getArg(1), DI->getArgNameStr(1));
+ emitDagArg(DI->getArg(1), std::string(DI->getArgNameStr(1)));
return std::make_pair(R.first, Op + R.second);
} else {
assert(DI->getNumArgs() == 3 && "Can only handle unary and binary ops!");
std::pair<Type, std::string> R1 =
- emitDagArg(DI->getArg(1), DI->getArgNameStr(1));
+ emitDagArg(DI->getArg(1), std::string(DI->getArgNameStr(1)));
std::pair<Type, std::string> R2 =
- emitDagArg(DI->getArg(2), DI->getArgNameStr(2));
+ emitDagArg(DI->getArg(2), std::string(DI->getArgNameStr(2)));
assert_with_loc(R1.first == R2.first, "Argument type mismatch!");
return std::make_pair(R1.first, R1.second + " " + Op + " " + R2.second);
}
@@ -1416,7 +1416,7 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagCall(DagInit *DI) {
std::vector<std::string> Values;
for (unsigned I = 0; I < DI->getNumArgs() - 1; ++I) {
std::pair<Type, std::string> R =
- emitDagArg(DI->getArg(I + 1), DI->getArgNameStr(I + 1));
+ emitDagArg(DI->getArg(I + 1), std::string(DI->getArgNameStr(I + 1)));
Types.push_back(R.first);
Values.push_back(R.second);
}
@@ -1451,9 +1451,9 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagCall(DagInit *DI) {
std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagCast(DagInit *DI,
bool IsBitCast){
// (cast MOD* VAL) -> cast VAL to type given by MOD.
- std::pair<Type, std::string> R = emitDagArg(
- DI->getArg(DI->getNumArgs() - 1),
- DI->getArgNameStr(DI->getNumArgs() - 1));
+ std::pair<Type, std::string> R =
+ emitDagArg(DI->getArg(DI->getNumArgs() - 1),
+ std::string(DI->getArgNameStr(DI->getNumArgs() - 1)));
Type castToType = R.first;
for (unsigned ArgIdx = 0; ArgIdx < DI->getNumArgs() - 1; ++ArgIdx) {
@@ -1465,10 +1465,11 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagCast(DagInit *DI,
// 5. The value "H" or "D" to half or double the bitwidth.
// 6. The value "8" to convert to 8-bit (signed) integer lanes.
if (!DI->getArgNameStr(ArgIdx).empty()) {
- assert_with_loc(Intr.Variables.find(DI->getArgNameStr(ArgIdx)) !=
- Intr.Variables.end(),
+ assert_with_loc(Intr.Variables.find(std::string(
+ DI->getArgNameStr(ArgIdx))) != Intr.Variables.end(),
"Variable not found");
- castToType = Intr.Variables[DI->getArgNameStr(ArgIdx)].getType();
+ castToType =
+ Intr.Variables[std::string(DI->getArgNameStr(ArgIdx))].getType();
} else {
StringInit *SI = dyn_cast<StringInit>(DI->getArg(ArgIdx));
assert_with_loc(SI, "Expected string type or $Name for cast type");
@@ -1583,9 +1584,9 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagShuffle(DagInit *DI){
// (shuffle arg1, arg2, sequence)
std::pair<Type, std::string> Arg1 =
- emitDagArg(DI->getArg(0), DI->getArgNameStr(0));
+ emitDagArg(DI->getArg(0), std::string(DI->getArgNameStr(0)));
std::pair<Type, std::string> Arg2 =
- emitDagArg(DI->getArg(1), DI->getArgNameStr(1));
+ emitDagArg(DI->getArg(1), std::string(DI->getArgNameStr(1)));
assert_with_loc(Arg1.first == Arg2.first,
"Different types in arguments to shuffle!");
@@ -1627,8 +1628,8 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagShuffle(DagInit *DI){
std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagDup(DagInit *DI) {
assert_with_loc(DI->getNumArgs() == 1, "dup() expects one argument");
- std::pair<Type, std::string> A = emitDagArg(DI->getArg(0),
- DI->getArgNameStr(0));
+ std::pair<Type, std::string> A =
+ emitDagArg(DI->getArg(0), std::string(DI->getArgNameStr(0)));
assert_with_loc(A.first.isScalar(), "dup() expects a scalar argument");
Type T = Intr.getBaseType();
@@ -1646,10 +1647,10 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagDup(DagInit *DI) {
std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagDupTyped(DagInit *DI) {
assert_with_loc(DI->getNumArgs() == 2, "dup_typed() expects two arguments");
- std::pair<Type, std::string> A = emitDagArg(DI->getArg(0),
- DI->getArgNameStr(0));
- std::pair<Type, std::string> B = emitDagArg(DI->getArg(1),
- DI->getArgNameStr(1));
+ std::pair<Type, std::string> A =
+ emitDagArg(DI->getArg(0), std::string(DI->getArgNameStr(0)));
+ std::pair<Type, std::string> B =
+ emitDagArg(DI->getArg(1), std::string(DI->getArgNameStr(1)));
assert_with_loc(B.first.isScalar(),
"dup_typed() requires a scalar as the second argument");
@@ -1668,10 +1669,10 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagDupTyped(DagInit *DI)
std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagSplat(DagInit *DI) {
assert_with_loc(DI->getNumArgs() == 2, "splat() expects two arguments");
- std::pair<Type, std::string> A = emitDagArg(DI->getArg(0),
- DI->getArgNameStr(0));
- std::pair<Type, std::string> B = emitDagArg(DI->getArg(1),
- DI->getArgNameStr(1));
+ std::pair<Type, std::string> A =
+ emitDagArg(DI->getArg(0), std::string(DI->getArgNameStr(0)));
+ std::pair<Type, std::string> B =
+ emitDagArg(DI->getArg(1), std::string(DI->getArgNameStr(1)));
assert_with_loc(B.first.isScalar(),
"splat() requires a scalar int as the second argument");
@@ -1687,13 +1688,13 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagSplat(DagInit *DI) {
std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagSaveTemp(DagInit *DI) {
assert_with_loc(DI->getNumArgs() == 2, "save_temp() expects two arguments");
- std::pair<Type, std::string> A = emitDagArg(DI->getArg(1),
- DI->getArgNameStr(1));
+ std::pair<Type, std::string> A =
+ emitDagArg(DI->getArg(1), std::string(DI->getArgNameStr(1)));
assert_with_loc(!A.first.isVoid(),
"Argument to save_temp() must have non-void type!");
- std::string N = DI->getArgNameStr(0);
+ std::string N = std::string(DI->getArgNameStr(0));
assert_with_loc(!N.empty(),
"save_temp() expects a name as the first argument");
@@ -1883,13 +1884,13 @@ Intrinsic &NeonEmitter::getIntrinsic(StringRef Name, ArrayRef<Type> Types) {
void NeonEmitter::createIntrinsic(Record *R,
SmallVectorImpl<Intrinsic *> &Out) {
- std::string Name = R->getValueAsString("Name");
- std::string Proto = R->getValueAsString("Prototype");
- std::string Types = R->getValueAsString("Types");
+ std::string Name = std::string(R->getValueAsString("Name"));
+ std::string Proto = std::string(R->getValueAsString("Prototype"));
+ std::string Types = std::string(R->getValueAsString("Types"));
Record *OperationRec = R->getValueAsDef("Operation");
bool CartesianProductOfTypes = R->getValueAsBit("CartesianProductOfTypes");
bool BigEndianSafe = R->getValueAsBit("BigEndianSafe");
- std::string Guard = R->getValueAsString("ArchGuard");
+ std::string Guard = std::string(R->getValueAsString("ArchGuard"));
bool IsUnavailable = OperationRec->getValueAsBit("Unavailable");
// Set the global current record. This allows assert_with_loc to produce
diff --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp
index 0960f16..cd59b431 100644
--- a/lld/COFF/DebugTypes.cpp
+++ b/lld/COFF/DebugTypes.cpp
@@ -137,7 +137,7 @@ static std::string getPdbBaseName(const ObjFile *file, StringRef tSPath) {
// Currently, type server PDBs are only created by MSVC cl, which only runs
// on Windows, so we can assume type server paths are Windows style.
sys::path::append(path, sys::path::filename(tSPath, sys::path::Style::windows));
- return path.str();
+ return std::string(path.str());
}
// The casing of the PDB path stamped in the OBJ can differ from the actual path
@@ -147,7 +147,7 @@ static std::string normalizePdbPath(StringRef path) {
#if defined(_WIN32)
return path.lower();
#else // LINUX
- return path;
+ return std::string(path);
#endif
}
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 9dc7d28..f161907 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -237,9 +237,9 @@ void LinkerDriver::addBuffer(std::unique_ptr<MemoryBuffer> mb,
}
void LinkerDriver::enqueuePath(StringRef path, bool wholeArchive, bool lazy) {
- auto future =
- std::make_shared<std::future<MBErrPair>>(createFutureForFile(path));
- std::string pathStr = path;
+ auto future = std::make_shared<std::future<MBErrPair>>(
+ createFutureForFile(std::string(path)));
+ std::string pathStr = std::string(path);
enqueueTask([=]() {
auto mbOrErr = future->get();
if (mbOrErr.second) {
@@ -452,7 +452,7 @@ Optional<StringRef> LinkerDriver::findFile(StringRef filename) {
}
if (path.endswith_lower(".lib"))
- visitedLibs.insert(sys::path::filename(path));
+ visitedLibs.insert(std::string(sys::path::filename(path)));
return path;
}
@@ -641,7 +641,7 @@ static std::string createResponseFile(const opt::InputArgList &args,
for (StringRef path : filePaths)
os << quote(relativeToRoot(path)) << "\n";
- return data.str();
+ return std::string(data.str());
}
enum class DebugKind { Unknown, None, Full, FastLink, GHash, Dwarf, Symtab };
@@ -721,10 +721,10 @@ static std::string getMapFile(const opt::InputArgList &args) {
static std::string getImplibPath() {
if (!config->implib.empty())
- return config->implib;
+ return std::string(config->implib);
SmallString<128> out = StringRef(config->outputFile);
sys::path::replace_extension(out, ".lib");
- return out.str();
+ return std::string(out.str());
}
// The import name is calculated as follows:
@@ -748,16 +748,16 @@ static std::string getImportName(bool asLib) {
(config->dll || asLib) ? ".dll" : ".exe");
}
- return out.str();
+ return std::string(out.str());
}
static void createImportLibrary(bool asLib) {
std::vector<COFFShortExport> exports;
for (Export &e1 : config->exports) {
COFFShortExport e2;
- e2.Name = e1.name;
- e2.SymbolName = e1.symbolName;
- e2.ExtName = e1.extName;
+ e2.Name = std::string(e1.name);
+ e2.SymbolName = std::string(e1.symbolName);
+ e2.ExtName = std::string(e1.extName);
e2.Ordinal = e1.ordinal;
e2.Noname = e1.noname;
e2.Data = e1.data;
@@ -818,8 +818,8 @@ static void parseModuleDefs(StringRef path) {
mb->getMemBufferRef(), config->machine, config->mingw));
if (config->outputFile.empty())
- config->outputFile = saver.save(m.OutputFile);
- config->importName = saver.save(m.ImportName);
+ config->outputFile = std::string(saver.save(m.OutputFile));
+ config->importName = std::string(saver.save(m.ImportName));
if (m.ImageBase)
config->imageBase = m.ImageBase;
if (m.StackReserve)
@@ -904,7 +904,8 @@ static void parseOrderFile(StringRef arg) {
// All symbols that were not present in a given order file are
// considered to have the lowest priority 0 and are placed at
// end of an output section.
- for (std::string s : args::getLines(mb->getMemBufferRef())) {
+ for (StringRef arg : args::getLines(mb->getMemBufferRef())) {
+ std::string s(arg);
if (config->machine == I386 && !isDecorated(s))
s = "_" + s;
diff --git a/lld/COFF/DriverUtils.cpp b/lld/COFF/DriverUtils.cpp
index 301a5c5..f1b50e6 100644
--- a/lld/COFF/DriverUtils.cpp
+++ b/lld/COFF/DriverUtils.cpp
@@ -220,7 +220,8 @@ void parseAligncomm(StringRef s) {
error("/aligncomm: invalid argument: " + s);
return;
}
- config->alignComm[name] = std::max(config->alignComm[name], 1 << v);
+ config->alignComm[std::string(name)] =
+ std::max(config->alignComm[std::string(name)], 1 << v);
}
// Parses /functionpadmin option argument.
@@ -318,7 +319,7 @@ public:
SmallString<128> s;
if (auto ec = sys::fs::createTemporaryFile("lld-" + prefix, extn, s))
fatal("cannot create a temporary file: " + ec.message());
- path = s.str();
+ path = std::string(s.str());
if (!contents.empty()) {
std::error_code ec;
@@ -403,7 +404,7 @@ static std::string createManifestXmlWithInternalMt(StringRef defaultXml) {
toString(std::move(e)));
}
- return merger.getMergedManifest().get()->getBuffer();
+ return std::string(merger.getMergedManifest().get()->getBuffer());
}
static std::string createManifestXmlWithExternalMt(StringRef defaultXml) {
@@ -431,9 +432,10 @@ static std::string createManifestXmlWithExternalMt(StringRef defaultXml) {
e.add("/out:" + StringRef(user.path));
e.run();
- return CHECK(MemoryBuffer::getFile(user.path), "could not open " + user.path)
- .get()
- ->getBuffer();
+ return std::string(
+ CHECK(MemoryBuffer::getFile(user.path), "could not open " + user.path)
+ .get()
+ ->getBuffer());
}
static std::string createManifestXml() {
@@ -507,7 +509,7 @@ std::unique_ptr<MemoryBuffer> createManifestRes() {
}
void createSideBySideManifest() {
- std::string path = config->manifestFile;
+ std::string path = std::string(config->manifestFile);
if (path == "")
path = config->outputFile + ".manifest";
std::error_code ec;
diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp
index 272f9c0..58b0c97 100644
--- a/lld/COFF/InputFiles.cpp
+++ b/lld/COFF/InputFiles.cpp
@@ -60,7 +60,7 @@ std::string toString(const coff::InputFile *file) {
if (!file)
return "<internal>";
if (file->parentName.empty() || file->kind() == coff::InputFile::ImportKind)
- return file->getName();
+ return std::string(file->getName());
return (getBasename(file->parentName) + "(" + getBasename(file->getName()) +
")")
@@ -849,7 +849,7 @@ void ImportFile::parse() {
StringRef name = saver.save(StringRef(buf + sizeof(*hdr)));
StringRef impName = saver.save("__imp_" + name);
const char *nameStart = buf + sizeof(coff_import_header) + name.size() + 1;
- dllName = StringRef(nameStart);
+ dllName = std::string(StringRef(nameStart));
StringRef extName;
switch (hdr->getNameType()) {
case IMPORT_ORDINAL:
@@ -932,7 +932,7 @@ void BitcodeFile::parse() {
} else if (objSym.isWeak() && objSym.isIndirect()) {
// Weak external.
sym = symtab->addUndefined(symName, this, true);
- std::string fallback = objSym.getCOFFWeakExternalFallback();
+ std::string fallback = std::string(objSym.getCOFFWeakExternalFallback());
Symbol *alias = symtab->addUndefined(saver.save(fallback));
checkAndSetWeakAlias(symtab, this, sym, alias);
} else if (comdatIndex != -1) {
@@ -973,7 +973,7 @@ std::string replaceThinLTOSuffix(StringRef path) {
if (path.consume_back(suffix))
return (path + repl).str();
- return path;
+ return std::string(path);
}
} // namespace coff
diff --git a/lld/COFF/LTO.cpp b/lld/COFF/LTO.cpp
index 1c21236d..609871d 100644
--- a/lld/COFF/LTO.cpp
+++ b/lld/COFF/LTO.cpp
@@ -55,9 +55,9 @@ static std::unique_ptr<raw_fd_ostream> openFile(StringRef file) {
}
static std::string getThinLTOOutputFile(StringRef path) {
- return lto::getThinLTOOutputFile(path,
- config->thinLTOPrefixReplace.first,
- config->thinLTOPrefixReplace.second);
+ return lto::getThinLTOOutputFile(
+ std::string(path), std::string(config->thinLTOPrefixReplace.first),
+ std::string(config->thinLTOPrefixReplace.second));
}
static lto::Config createConfig() {
@@ -99,7 +99,8 @@ BitcodeCompiler::BitcodeCompiler() {
if (config->thinLTOIndexOnly) {
auto OnIndexWrite = [&](StringRef S) { thinIndices.erase(S); };
backend = lto::createWriteIndexesThinBackend(
- config->thinLTOPrefixReplace.first, config->thinLTOPrefixReplace.second,
+ std::string(config->thinLTOPrefixReplace.first),
+ std::string(config->thinLTOPrefixReplace.second),
config->thinLTOEmitImportsFiles, indexFile.get(), OnIndexWrite);
} else if (config->thinLTOJobs != 0) {
backend = lto::createInProcessThinBackend(config->thinLTOJobs);
diff --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp
index c65a9876..52740ae 100644
--- a/lld/COFF/PDB.cpp
+++ b/lld/COFF/PDB.cpp
@@ -1471,7 +1471,7 @@ static std::string quote(ArrayRef<StringRef> args) {
a.split(s, '"');
r.append(join(s, "\"\""));
} else {
- r.append(a);
+ r.append(std::string(a));
}
if (hasWS || hasQ)
r.push_back('"');
diff --git a/lld/COFF/Symbols.cpp b/lld/COFF/Symbols.cpp
index 938c9c52..290a29d 100644
--- a/lld/COFF/Symbols.cpp
+++ b/lld/COFF/Symbols.cpp
@@ -36,12 +36,12 @@ static std::string maybeDemangleSymbol(StringRef symName) {
StringRef demangleInput = prefixless;
if (config->machine == I386)
demangleInput.consume_front("_");
- std::string demangled = demangle(demangleInput);
+ std::string demangled = demangle(std::string(demangleInput));
if (demangled != demangleInput)
- return prefix + demangle(demangleInput);
+ return prefix + demangle(std::string(demangleInput));
return (prefix + prefixless).str();
}
- return symName;
+ return std::string(symName);
}
std::string toString(coff::Symbol &b) {
return maybeDemangleSymbol(b.getName());
diff --git a/lld/Common/ErrorHandler.cpp b/lld/Common/ErrorHandler.cpp
index fb84832..c8f8339 100644
--- a/lld/Common/ErrorHandler.cpp
+++ b/lld/Common/ErrorHandler.cpp
@@ -117,7 +117,7 @@ void lld::checkError(Error e) {
// extracted from an error message using regexps.
std::string ErrorHandler::getLocation(const Twine &msg) {
if (!vsDiagnostics)
- return logName;
+ return std::string(logName);
static std::regex regexes[] = {
std::regex(
@@ -149,7 +149,7 @@ std::string ErrorHandler::getLocation(const Twine &msg) {
return m.str(1) + "(" + m.str(2) + ")";
}
- return logName;
+ return std::string(logName);
}
void ErrorHandler::log(const Twine &msg) {
diff --git a/lld/Common/Reproduce.cpp b/lld/Common/Reproduce.cpp
index 24210c4..00309f5 100644
--- a/lld/Common/Reproduce.cpp
+++ b/lld/Common/Reproduce.cpp
@@ -24,7 +24,7 @@ using namespace llvm::sys;
std::string lld::relativeToRoot(StringRef path) {
SmallString<128> abs = path;
if (fs::make_absolute(abs))
- return path;
+ return std::string(path);
path::remove_dots(abs, /*remove_dot_dot=*/true);
// This is Windows specific. root_name() returns a drive letter
@@ -45,13 +45,13 @@ std::string lld::relativeToRoot(StringRef path) {
std::string lld::quote(StringRef s) {
if (s.contains(' '))
return ("\"" + s + "\"").str();
- return s;
+ return std::string(s);
}
// Converts an Arg to a string representation suitable for a response file.
// To show an Arg in a diagnostic, use Arg::getAsString() instead.
std::string lld::toString(const opt::Arg &arg) {
- std::string k = arg.getSpelling();
+ std::string k = std::string(arg.getSpelling());
if (arg.getNumValues() == 0)
return k;
std::string v = quote(arg.getValue());
diff --git a/lld/Common/Strings.cpp b/lld/Common/Strings.cpp
index c5ddcc2..605d9de 100644
--- a/lld/Common/Strings.cpp
+++ b/lld/Common/Strings.cpp
@@ -26,9 +26,9 @@ std::string lld::demangleItanium(StringRef name) {
// does not look like a C++ symbol name to avoid getting unexpected
// result for a C symbol that happens to match a mangled type name.
if (!name.startswith("_Z"))
- return name;
+ return std::string(name);
- return demangle(name);
+ return demangle(std::string(name));
}
SingleStringMatcher::SingleStringMatcher(StringRef Pattern) {
diff --git a/lld/Common/Timer.cpp b/lld/Common/Timer.cpp
index 4b7d110..3848b6d 100644
--- a/lld/Common/Timer.cpp
+++ b/lld/Common/Timer.cpp
@@ -24,9 +24,9 @@ void ScopedTimer::stop() {
ScopedTimer::~ScopedTimer() { stop(); }
-Timer::Timer(llvm::StringRef name) : name(name), parent(nullptr) {}
+Timer::Timer(llvm::StringRef name) : name(std::string(name)), parent(nullptr) {}
Timer::Timer(llvm::StringRef name, Timer &parent)
- : name(name), parent(&parent) {}
+ : name(std::string(name)), parent(&parent) {}
void Timer::start() {
if (parent && total.count() == 0)
diff --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp
index 9fcb36e..6b90c06 100644
--- a/lld/ELF/DriverUtils.cpp
+++ b/lld/ELF/DriverUtils.cpp
@@ -160,7 +160,7 @@ void printHelp() {
static std::string rewritePath(StringRef s) {
if (fs::exists(s))
return relativeToRoot(s);
- return s;
+ return std::string(s);
}
// Reconstructs command line arguments so that so that you can re-run
@@ -199,7 +199,7 @@ std::string createResponseFile(const opt::InputArgList &args) {
os << toString(*arg) << "\n";
}
}
- return data.str();
+ return std::string(data.str());
}
// Find a file by concatenating given paths. If a resulting path
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 43978cd..b3f8984 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -45,7 +45,7 @@ std::string toString(const elf::InputFile *f) {
if (f->toStringCache.empty()) {
if (f->archiveName.empty())
- f->toStringCache = f->getName();
+ f->toStringCache = std::string(f->getName());
else
f->toStringCache = (f->archiveName + "(" + f->getName() + ")").str();
}
@@ -222,7 +222,7 @@ void parseFile(InputFile *file) {
// Concatenates arguments to construct a string representing an error location.
static std::string createFileLineMsg(StringRef path, unsigned line) {
- std::string filename = path::filename(path);
+ std::string filename = std::string(path::filename(path));
std::string lineno = ":" + std::to_string(line);
if (filename == path)
return filename + lineno;
@@ -243,7 +243,7 @@ static std::string getSrcMsgAux(ObjFile<ELFT> &file, const Symbol &sym,
return createFileLineMsg(fileLine->first, fileLine->second);
// File.sourceFile contains STT_FILE symbol, and that is a last resort.
- return file.sourceFile;
+ return std::string(file.sourceFile);
}
std::string InputFile::getSrcMsg(const Symbol &sym, InputSectionBase &sec,
@@ -1405,7 +1405,7 @@ static uint8_t getBitcodeMachineKind(StringRef path, const Triple &t) {
BitcodeFile::BitcodeFile(MemoryBufferRef mb, StringRef archiveName,
uint64_t offsetInArchive)
: InputFile(BitcodeKind, mb) {
- this->archiveName = archiveName;
+ this->archiveName = std::string(archiveName);
std::string path = mb.getBufferIdentifier().str();
if (config->thinLTOIndexOnly)
@@ -1607,7 +1607,7 @@ std::string replaceThinLTOSuffix(StringRef path) {
if (path.consume_back(suffix))
return (path + repl).str();
- return path;
+ return std::string(path);
}
template void BitcodeFile::parse<ELF32LE>();
diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h
index a310ba5..7927810 100644
--- a/lld/ELF/InputFiles.h
+++ b/lld/ELF/InputFiles.h
@@ -200,7 +200,7 @@ public:
ArrayRef<Symbol *> getGlobalSymbols();
ObjFile(MemoryBufferRef m, StringRef archiveName) : ELFFileBase(ObjKind, m) {
- this->archiveName = archiveName;
+ this->archiveName = std::string(archiveName);
}
void parse(bool ignoreComdats = false);
@@ -298,7 +298,7 @@ public:
LazyObjFile(MemoryBufferRef m, StringRef archiveName,
uint64_t offsetInArchive)
: InputFile(LazyObjKind, m), offsetInArchive(offsetInArchive) {
- this->archiveName = archiveName;
+ this->archiveName = std::string(archiveName);
}
static bool classof(const InputFile *f) { return f->kind() == LazyObjKind; }
@@ -341,7 +341,7 @@ public:
class SharedFile : public ELFFileBase {
public:
SharedFile(MemoryBufferRef m, StringRef defaultSoName)
- : ELFFileBase(SharedKind, m), soName(defaultSoName),
+ : ELFFileBase(SharedKind, m), soName(std::string(defaultSoName)),
isNeeded(!config->asNeeded) {}
// This is actually a vector of Elf_Verdef pointers.
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 7c79879c..dc544fa 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -307,7 +307,7 @@ std::string InputSectionBase::getLocation(uint64_t offset) {
// File->sourceFile contains STT_FILE symbol that contains a
// source file name. If it's missing, we use an object file name.
- std::string srcFile = getFile<ELFT>()->sourceFile;
+ std::string srcFile = std::string(getFile<ELFT>()->sourceFile);
if (srcFile.empty())
srcFile = toString(file);
@@ -338,7 +338,7 @@ std::string InputSectionBase::getSrcMsg(const Symbol &sym, uint64_t offset) {
//
// path/to/foo.o:(function bar) in archive path/to/bar.a
std::string InputSectionBase::getObjMsg(uint64_t off) {
- std::string filename = file->getName();
+ std::string filename = std::string(file->getName());
std::string archive;
if (!file->archiveName.empty())
diff --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp
index d8e343c..9067d7c 100644
--- a/lld/ELF/LTO.cpp
+++ b/lld/ELF/LTO.cpp
@@ -59,9 +59,9 @@ static std::unique_ptr<raw_fd_ostream> openFile(StringRef file) {
}
static std::string getThinLTOOutputFile(StringRef modulePath) {
- return lto::getThinLTOOutputFile(modulePath,
- config->thinLTOPrefixReplace.first,
- config->thinLTOPrefixReplace.second);
+ return lto::getThinLTOOutputFile(
+ std::string(modulePath), std::string(config->thinLTOPrefixReplace.first),
+ std::string(config->thinLTOPrefixReplace.second));
}
static lto::Config createConfig() {
@@ -97,23 +97,23 @@ static lto::Config createConfig() {
c.PTO.SLPVectorization = c.OptLevel > 1;
// Set up a custom pipeline if we've been asked to.
- c.OptPipeline = config->ltoNewPmPasses;
- c.AAPipeline = config->ltoAAPipeline;
+ c.OptPipeline = std::string(config->ltoNewPmPasses);
+ c.AAPipeline = std::string(config->ltoAAPipeline);
// Set up optimization remarks if we've been asked to.
- c.RemarksFilename = config->optRemarksFilename;
- c.RemarksPasses = config->optRemarksPasses;
+ c.RemarksFilename = std::string(config->optRemarksFilename);
+ c.RemarksPasses = std::string(config->optRemarksPasses);
c.RemarksWithHotness = config->optRemarksWithHotness;
- c.RemarksFormat = config->optRemarksFormat;
+ c.RemarksFormat = std::string(config->optRemarksFormat);
- c.SampleProfile = config->ltoSampleProfile;
+ c.SampleProfile = std::string(config->ltoSampleProfile);
c.UseNewPM = config->ltoNewPassManager;
c.DebugPassManager = config->ltoDebugPassManager;
- c.DwoDir = config->dwoDir;
+ c.DwoDir = std::string(config->dwoDir);
c.HasWholeProgramVisibility = config->ltoWholeProgramVisibility;
- c.CSIRProfile = config->ltoCSProfileFile;
+ c.CSIRProfile = std::string(config->ltoCSProfileFile);
c.RunCSIRInstr = config->ltoCSProfileGenerate;
if (config->emitLLVM) {
@@ -140,7 +140,8 @@ BitcodeCompiler::BitcodeCompiler() {
if (config->thinLTOIndexOnly) {
auto onIndexWrite = [&](StringRef s) { thinIndices.erase(s); };
backend = lto::createWriteIndexesThinBackend(
- config->thinLTOPrefixReplace.first, config->thinLTOPrefixReplace.second,
+ std::string(config->thinLTOPrefixReplace.first),
+ std::string(config->thinLTOPrefixReplace.second),
config->thinLTOEmitImportsFiles, indexFile.get(), onIndexWrite);
} else if (config->thinLTOJobs != -1U) {
backend = lto::createInProcessThinBackend(config->thinLTOJobs);
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index db97943..b5f4644 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -88,7 +88,7 @@ OutputSection *LinkerScript::createOutputSection(StringRef name,
if (!secRef)
secRef = sec;
}
- sec->location = location;
+ sec->location = std::string(location);
return sec;
}
@@ -324,7 +324,7 @@ static std::string getFilename(InputFile *file) {
if (!file)
return "";
if (file->archiveName.empty())
- return file->getName();
+ return std::string(file->getName());
return (file->archiveName + "(" + file->getName() + ")").str();
}
diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h
index f43a660..f020552 100644
--- a/lld/ELF/LinkerScript.h
+++ b/lld/ELF/LinkerScript.h
@@ -128,7 +128,7 @@ enum class ConstraintKind { NoConstraint, ReadOnly, ReadWrite };
struct MemoryRegion {
MemoryRegion(StringRef name, uint64_t origin, uint64_t length, uint32_t flags,
uint32_t negFlags)
- : name(name), origin(origin), length(length), flags(flags),
+ : name(std::string(name)), origin(origin), length(length), flags(flags),
negFlags(negFlags) {}
std::string name;
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 93ec066..888bec3 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -761,7 +761,7 @@ static const Symbol *getAlternativeSpelling(const Undefined &sym,
break;
// Substitute name[i].
- newName = name;
+ newName = std::string(name);
for (char c = '0'; c <= 'z'; ++c) {
newName[i] = c;
if (const Symbol *s = suggest(newName))
diff --git a/lld/ELF/ScriptLexer.cpp b/lld/ELF/ScriptLexer.cpp
index e0ff56f..7453acf 100644
--- a/lld/ELF/ScriptLexer.cpp
+++ b/lld/ELF/ScriptLexer.cpp
@@ -64,7 +64,7 @@ size_t ScriptLexer::getColumnNumber() {
}
std::string ScriptLexer::getCurrentLocation() {
- std::string filename = getCurrentMB().getBufferIdentifier();
+ std::string filename = std::string(getCurrentMB().getBufferIdentifier());
return (filename + ":" + Twine(getLineNumber())).str();
}
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index a0d763e..27e1ae1 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -871,11 +871,11 @@ OutputSection *ScriptParser::readOutputSectionDescription(StringRef outSec) {
}
if (consume(">"))
- cmd->memoryRegionName = next();
+ cmd->memoryRegionName = std::string(next());
if (consume("AT")) {
expect(">");
- cmd->lmaRegionName = next();
+ cmd->lmaRegionName = std::string(next());
}
if (cmd->lmaExpr && !cmd->lmaRegionName.empty())
diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index 4956e27..f5d5ca1 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -28,7 +28,7 @@ namespace lld {
static std::string demangle(StringRef symName) {
if (elf::config->demangle)
return demangleItanium(symName);
- return symName;
+ return std::string(symName);
}
std::string toString(const elf::Symbol &b) { return demangle(b.getName()); }
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp
index 7b0824a..597db1f 100644
--- a/lld/ELF/Target.cpp
+++ b/lld/ELF/Target.cpp
@@ -41,7 +41,7 @@ std::string toString(elf::RelType type) {
StringRef s = getELFRelocationTypeName(elf::config->emachine, type);
if (s == "Unknown")
return ("Unknown (" + Twine(type) + ")").str();
- return s;
+ return std::string(s);
}
namespace elf {
diff --git a/lld/include/lld/Core/File.h b/lld/include/lld/Core/File.h
index df01466..bb4ca9c 100644
--- a/lld/include/lld/Core/File.h
+++ b/lld/include/lld/Core/File.h
@@ -78,7 +78,7 @@ public:
/// Returns the path of the archive file name if this file is instantiated
/// from an archive file. Otherwise returns the empty string.
StringRef archivePath() const { return _archivePath; }
- void setArchivePath(StringRef path) { _archivePath = path; }
+ void setArchivePath(StringRef path) { _archivePath = std::string(path); }
/// Returns the path name of this file. It doesn't include archive file name.
StringRef memberPath() const { return _path; }
diff --git a/lld/lib/Core/Error.cpp b/lld/lib/Core/Error.cpp
index f138a81..dc846db 100644
--- a/lld/lib/Core/Error.cpp
+++ b/lld/lib/Core/Error.cpp
@@ -78,7 +78,8 @@ private:
static dynamic_error_category categorySingleton;
std::error_code make_dynamic_error_code(StringRef msg) {
- return std::error_code(categorySingleton.add(msg), categorySingleton);
+ return std::error_code(categorySingleton.add(std::string(msg)),
+ categorySingleton);
}
char GenericError::ID = 0;
diff --git a/lld/lib/Driver/DarwinLdDriver.cpp b/lld/lib/Driver/DarwinLdDriver.cpp
index 062e945..b1659b9 100644
--- a/lld/lib/Driver/DarwinLdDriver.cpp
+++ b/lld/lib/Driver/DarwinLdDriver.cpp
@@ -147,11 +147,11 @@ std::vector<std::unique_ptr<File>> loadFile(MachOLinkingContext &ctx,
static std::string canonicalizePath(StringRef path) {
char sep = llvm::sys::path::get_separator().front();
if (sep != '/') {
- std::string fixedPath = path;
+ std::string fixedPath = std::string(path);
std::replace(fixedPath.begin(), fixedPath.end(), sep, '/');
return fixedPath;
} else {
- return path;
+ return std::string(path);
}
}
diff --git a/lld/lib/ReaderWriter/MachO/Atoms.h b/lld/lib/ReaderWriter/MachO/Atoms.h
index b8bca19..c61aaa8 100644
--- a/lld/lib/ReaderWriter/MachO/Atoms.h
+++ b/lld/lib/ReaderWriter/MachO/Atoms.h
@@ -112,8 +112,8 @@ class MachOTentativeDefAtom : public SimpleDefinedAtom {
public:
MachOTentativeDefAtom(const File &f, const StringRef name, Scope scope,
uint64_t size, DefinedAtom::Alignment align)
- : SimpleDefinedAtom(f), _name(name), _scope(scope), _size(size),
- _align(align) {}
+ : SimpleDefinedAtom(f), _name(std::string(name)), _scope(scope),
+ _size(size), _align(align) {}
~MachOTentativeDefAtom() override = default;
diff --git a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
index 0be1c10..4152ecb 100644
--- a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
@@ -863,11 +863,11 @@ bool MachOLinkingContext::exportSymbolNamed(StringRef sym) const {
std::string MachOLinkingContext::demangle(StringRef symbolName) const {
// Only try to demangle symbols if -demangle on command line
if (!demangleSymbols())
- return symbolName;
+ return std::string(symbolName);
// Only try to demangle symbols that look like C++ symbols
if (!symbolName.startswith("__Z"))
- return symbolName;
+ return std::string(symbolName);
SmallString<256> symBuff;
StringRef nullTermSym = Twine(symbolName).toNullTerminatedStringRef(symBuff);
@@ -882,7 +882,7 @@ std::string MachOLinkingContext::demangle(StringRef symbolName) const {
return result;
}
- return symbolName;
+ return std::string(symbolName);
}
static void addDependencyInfoHelper(llvm::raw_fd_ostream *DepInfo,
diff --git a/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp b/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
index 23c20aa..279ffe5 100644
--- a/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
+++ b/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
@@ -89,7 +89,7 @@ public:
llvm::raw_string_ostream buffer(storage);
buffer << llvm::format("L%03d", _unnamedCounter++);
StringRef newName = copyString(buffer.str());
- _refNames[target] = newName;
+ _refNames[target] = std::string(newName);
DEBUG_WITH_TYPE("WriterYAML",
llvm::dbgs() << "unnamed atom: creating ref-name: '"
<< newName << "' ("
@@ -119,7 +119,7 @@ public:
llvm::raw_string_ostream buffer(Storage);
buffer << atom.name() << llvm::format(".%03d", ++_collisionCount);
StringRef newName = copyString(buffer.str());
- _refNames[&atom] = newName;
+ _refNames[&atom] = std::string(newName);
DEBUG_WITH_TYPE("WriterYAML",
llvm::dbgs() << "name collision: creating ref-name: '"
<< newName << "' ("
@@ -133,7 +133,7 @@ public:
llvm::raw_string_ostream buffer2(Storage2);
buffer2 << prevAtom->name() << llvm::format(".%03d", ++_collisionCount);
StringRef newName2 = copyString(buffer2.str());
- _refNames[prevAtom] = newName2;
+ _refNames[prevAtom] = std::string(newName2);
DEBUG_WITH_TYPE("WriterYAML",
llvm::dbgs() << "name collision: creating ref-name: '"
<< newName2 << "' ("
diff --git a/lld/unittests/DriverTests/DarwinLdDriverTest.cpp b/lld/unittests/DriverTests/DarwinLdDriverTest.cpp
index 8066670..af0fbbe 100644
--- a/lld/unittests/DriverTests/DarwinLdDriverTest.cpp
+++ b/lld/unittests/DriverTests/DarwinLdDriverTest.cpp
@@ -31,7 +31,7 @@ class DarwinLdParserTest : public testing::Test {
protected:
int inputFileCount() { return _ctx.getNodes().size(); }
- std::string inputFile(int index) {
+ StringRef inputFile(int index) {
Node &node = *_ctx.getNodes()[index];
if (node.kind() == Node::Kind::File)
return cast<FileNode>(&node)->getFile()->path();
diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index 90c26f8..9462018 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -361,7 +361,7 @@ static void readConfigs(opt::InputArgList &args) {
config->features =
llvm::Optional<std::vector<std::string>>(std::vector<std::string>());
for (StringRef s : arg->getValues())
- config->features->push_back(s);
+ config->features->push_back(std::string(s));
}
}
@@ -572,7 +572,7 @@ static std::string createResponseFile(const opt::InputArgList &args) {
os << toString(*arg) << "\n";
}
}
- return data.str();
+ return std::string(data.str());
}
// The --wrap option is a feature to rename symbols so that you can write
diff --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp
index 0ea9a37..2d96062 100644
--- a/lld/wasm/InputFiles.cpp
+++ b/lld/wasm/InputFiles.cpp
@@ -34,7 +34,7 @@ std::string toString(const wasm::InputFile *file) {
return "<internal>";
if (file->archiveName.empty())
- return file->getName();
+ return std::string(file->getName());
return (file->archiveName + "(" + file->getName() + ")").str();
}
diff --git a/lld/wasm/InputFiles.h b/lld/wasm/InputFiles.h
index 077c14d..d5aebf4 100644
--- a/lld/wasm/InputFiles.h
+++ b/lld/wasm/InputFiles.h
@@ -91,7 +91,7 @@ class ObjFile : public InputFile {
public:
explicit ObjFile(MemoryBufferRef m, StringRef archiveName)
: InputFile(ObjectKind, m) {
- this->archiveName = archiveName;
+ this->archiveName = std::string(archiveName);
}
static bool classof(const InputFile *f) { return f->kind() == ObjectKind; }
@@ -154,7 +154,7 @@ class BitcodeFile : public InputFile {
public:
explicit BitcodeFile(MemoryBufferRef m, StringRef archiveName)
: InputFile(BitcodeKind, m) {
- this->archiveName = archiveName;
+ this->archiveName = std::string(archiveName);
}
static bool classof(const InputFile *f) { return f->kind() == BitcodeKind; }
diff --git a/lld/wasm/OutputSections.cpp b/lld/wasm/OutputSections.cpp
index 0403f1d..519305f 100644
--- a/lld/wasm/OutputSections.cpp
+++ b/lld/wasm/OutputSections.cpp
@@ -27,7 +27,7 @@ namespace lld {
std::string toString(const wasm::OutputSection &sec) {
if (!sec.name.empty())
return (sec.getSectionName() + "(" + sec.name + ")").str();
- return sec.getSectionName();
+ return std::string(sec.getSectionName());
}
namespace wasm {
diff --git a/lld/wasm/Symbols.cpp b/lld/wasm/Symbols.cpp
index e43ecc6..3d8fec4 100644
--- a/lld/wasm/Symbols.cpp
+++ b/lld/wasm/Symbols.cpp
@@ -31,7 +31,7 @@ std::string toString(const wasm::Symbol &sym) {
std::string maybeDemangleSymbol(StringRef name) {
if (wasm::config->demangle)
return demangleItanium(name);
- return name;
+ return std::string(name);
}
std::string toString(wasm::Symbol::Kind kind) {
diff --git a/lld/wasm/SyntheticSections.h b/lld/wasm/SyntheticSections.h
index 23f9711..c33c9f5 100644
--- a/lld/wasm/SyntheticSections.h
+++ b/lld/wasm/SyntheticSections.h
@@ -324,7 +324,8 @@ public:
class RelocSection : public SyntheticSection {
public:
RelocSection(StringRef name, OutputSection *sec)
- : SyntheticSection(llvm::wasm::WASM_SEC_CUSTOM, name), sec(sec) {}
+ : SyntheticSection(llvm::wasm::WASM_SEC_CUSTOM, std::string(name)),
+ sec(sec) {}
void writeBody() override;
bool isNeeded() const override { return sec->getNumRelocations() > 0; };
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index bd7bd7e..366ca01 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -128,7 +128,7 @@ void Writer::createCustomSections() {
StringRef name = pair.first();
LLVM_DEBUG(dbgs() << "createCustomSection: " << name << "\n");
- OutputSection *sec = make<CustomSection>(name, pair.second);
+ OutputSection *sec = make<CustomSection>(std::string(name), pair.second);
if (config->relocatable || config->emitRelocs) {
auto *sym = make<OutputSectionSymbol>(sec);
out.linkingSec->addToSymtab(sym);
@@ -389,14 +389,14 @@ void Writer::populateTargetFeatures() {
for (auto &feature : file->getWasmObj()->getTargetFeatures()) {
switch (feature.Prefix) {
case WASM_FEATURE_PREFIX_USED:
- used.insert({feature.Name, fileName});
+ used.insert({feature.Name, std::string(fileName)});
break;
case WASM_FEATURE_PREFIX_REQUIRED:
- used.insert({feature.Name, fileName});
- required.insert({feature.Name, fileName});
+ used.insert({feature.Name, std::string(fileName)});
+ required.insert({feature.Name, std::string(fileName)});
break;
case WASM_FEATURE_PREFIX_DISALLOWED:
- disallowed.insert({feature.Name, fileName});
+ disallowed.insert({feature.Name, std::string(fileName)});
break;
default:
error("Unrecognized feature policy prefix " +
@@ -415,7 +415,8 @@ void Writer::populateTargetFeatures() {
}
if (inferFeatures)
- allowed.insert(used.keys().begin(), used.keys().end());
+ for (const auto &key : used.keys())
+ allowed.insert(std::string(key));
if (allowed.count("atomics") && !config->sharedMemory) {
if (inferFeatures)
@@ -447,7 +448,7 @@ void Writer::populateTargetFeatures() {
// Validate that used features are allowed in output
if (!inferFeatures) {
for (auto &feature : used.keys()) {
- if (!allowed.count(feature))
+ if (!allowed.count(std::string(feature)))
error(Twine("Target feature '") + feature + "' used by " +
used[feature] + " is not allowed.");
}
@@ -467,7 +468,7 @@ void Writer::populateTargetFeatures() {
". Use --no-check-features to suppress.");
}
for (auto &feature : required.keys()) {
- if (!objectFeatures.count(feature))
+ if (!objectFeatures.count(std::string(feature)))
error(Twine("Missing target feature '") + feature + "' in " + fileName +
", required by " + required[feature] +
". Use --no-check-features to suppress.");
diff --git a/lld/wasm/WriterUtils.cpp b/lld/wasm/WriterUtils.cpp
index 00e92a6..d0733d8 100644
--- a/lld/wasm/WriterUtils.cpp
+++ b/lld/wasm/WriterUtils.cpp
@@ -48,7 +48,7 @@ std::string toString(const WasmSignature &sig) {
s += "void";
else
s += toString(sig.Returns[0]);
- return s.str();
+ return std::string(s.str());
}
std::string toString(const WasmGlobalType &type) {
diff --git a/lldb/include/lldb/DataFormatters/FormatClasses.h b/lldb/include/lldb/DataFormatters/FormatClasses.h
index 91ce444..344a2d7 100644
--- a/lldb/include/lldb/DataFormatters/FormatClasses.h
+++ b/lldb/include/lldb/DataFormatters/FormatClasses.h
@@ -112,14 +112,14 @@ public:
TypeNameSpecifierImpl(llvm::StringRef name, bool is_regex)
: m_is_regex(is_regex), m_type() {
- m_type.m_type_name = name;
+ m_type.m_type_name = std::string(name);
}
// if constructing with a given type, is_regex cannot be true since we are
// giving an exact type to match
TypeNameSpecifierImpl(lldb::TypeSP type) : m_is_regex(false), m_type() {
if (type) {
- m_type.m_type_name = type->GetName().GetStringRef();
+ m_type.m_type_name = std::string(type->GetName().GetStringRef());
m_type.m_compiler_type = type->GetForwardCompilerType();
}
}
diff --git a/lldb/include/lldb/Expression/DiagnosticManager.h b/lldb/include/lldb/Expression/DiagnosticManager.h
index e5aecce0..2c72f7c 100644
--- a/lldb/include/lldb/Expression/DiagnosticManager.h
+++ b/lldb/include/lldb/Expression/DiagnosticManager.h
@@ -78,7 +78,7 @@ public:
bool precede_with_newline = true) {
if (precede_with_newline)
m_message.push_back('\n');
- m_message.append(message);
+ m_message += message;
}
protected:
diff --git a/lldb/include/lldb/Interpreter/CommandObject.h b/lldb/include/lldb/Interpreter/CommandObject.h
index f4dc2d6..4b0a7d6 100644
--- a/lldb/include/lldb/Interpreter/CommandObject.h
+++ b/lldb/include/lldb/Interpreter/CommandObject.h
@@ -40,7 +40,7 @@ int AddNamesMatchingPartialString(
const bool add_all = cmd_str.empty();
for (auto iter = in_map.begin(), end = in_map.end(); iter != end; iter++) {
- if (add_all || (iter->first.find(cmd_str, 0) == 0)) {
+ if (add_all || (iter->first.find(std::string(cmd_str), 0) == 0)) {
++number_added;
matches.AppendString(iter->first.c_str());
if (descriptions)
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index 2ba996d..cf5bdb3 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -139,7 +139,9 @@ public:
return (m_plugin_name.empty() ? nullptr : m_plugin_name.c_str());
}
- void SetProcessPluginName(llvm::StringRef plugin) { m_plugin_name = plugin; }
+ void SetProcessPluginName(llvm::StringRef plugin) {
+ m_plugin_name = std::string(plugin);
+ }
void Clear() {
ProcessInstanceInfo::Clear();
diff --git a/lldb/include/lldb/Target/ThreadSpec.h b/lldb/include/lldb/Target/ThreadSpec.h
index 05e7dcd..7a8a28f 100644
--- a/lldb/include/lldb/Target/ThreadSpec.h
+++ b/lldb/include/lldb/Target/ThreadSpec.h
@@ -46,9 +46,11 @@ public:
void SetTID(lldb::tid_t tid) { m_tid = tid; }
- void SetName(llvm::StringRef name) { m_name = name; }
+ void SetName(llvm::StringRef name) { m_name = std::string(name); }
- void SetQueueName(llvm::StringRef queue_name) { m_queue_name = queue_name; }
+ void SetQueueName(llvm::StringRef queue_name) {
+ m_queue_name = std::string(queue_name);
+ }
uint32_t GetIndex() const { return m_index; }
diff --git a/lldb/include/lldb/Utility/AnsiTerminal.h b/lldb/include/lldb/Utility/AnsiTerminal.h
index 21375e3..c92a75b 100644
--- a/lldb/include/lldb/Utility/AnsiTerminal.h
+++ b/lldb/include/lldb/Utility/AnsiTerminal.h
@@ -111,7 +111,7 @@ inline std::string FormatAnsiTerminalCodes(llvm::StringRef format,
llvm::StringRef left, right;
std::tie(left, right) = format.split(tok_hdr);
- fmt.append(left);
+ fmt += left;
if (left == format && right.empty()) {
// The header was not found. Just exit.
diff --git a/lldb/include/lldb/Utility/Environment.h b/lldb/include/lldb/Utility/Environment.h
index 398b3ba..0d126f8 100644
--- a/lldb/include/lldb/Utility/Environment.h
+++ b/lldb/include/lldb/Utility/Environment.h
@@ -68,7 +68,8 @@ public:
}
std::pair<iterator, bool> insert(llvm::StringRef KeyEqValue) {
- return insert(KeyEqValue.split('='));
+ auto Split = KeyEqValue.split('=');
+ return insert(std::make_pair(Split.first, std::string(Split.second)));
}
void insert(const_iterator first, const_iterator last);
diff --git a/lldb/include/lldb/Utility/Reproducer.h b/lldb/include/lldb/Utility/Reproducer.h
index 873ec3c..bffb0f7 100644
--- a/lldb/include/lldb/Utility/Reproducer.h
+++ b/lldb/include/lldb/Utility/Reproducer.h
@@ -142,7 +142,7 @@ public:
llvm::SmallString<128> cwd;
if (std::error_code EC = llvm::sys::fs::current_path(cwd))
return;
- m_cwd = cwd.str();
+ m_cwd = std::string(cwd.str());
}
struct Info {
static const char *name;
diff --git a/lldb/include/lldb/Utility/StringExtractor.h b/lldb/include/lldb/Utility/StringExtractor.h
index 293fef2..09202a4 100644
--- a/lldb/include/lldb/Utility/StringExtractor.h
+++ b/lldb/include/lldb/Utility/StringExtractor.h
@@ -26,7 +26,7 @@ public:
virtual ~StringExtractor();
void Reset(llvm::StringRef str) {
- m_packet = str;
+ m_packet = std::string(str);
m_index = 0;
}
diff --git a/lldb/include/lldb/Utility/StructuredData.h b/lldb/include/lldb/Utility/StructuredData.h
index 01b14fc..278b76d 100644
--- a/lldb/include/lldb/Utility/StructuredData.h
+++ b/lldb/include/lldb/Utility/StructuredData.h
@@ -339,7 +339,7 @@ public:
explicit String(llvm::StringRef S)
: Object(lldb::eStructuredDataTypeString), m_value(S) {}
- void SetValue(llvm::StringRef S) { m_value = S; }
+ void SetValue(llvm::StringRef S) { m_value = std::string(S); }
llvm::StringRef GetValue() { return m_value; }
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index d8e90fc..4a093b1e 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1282,7 +1282,7 @@ SBDebugger::GetInternalVariableValue(const char *var_name,
if (value_sp) {
StreamString value_strm;
value_sp->DumpValue(&exe_ctx, value_strm, OptionValue::eDumpOptionValue);
- const std::string &value_str = value_strm.GetString();
+ const std::string &value_str = std::string(value_strm.GetString());
if (!value_str.empty()) {
StringList string_list;
string_list.SplitIntoLines(value_str);
diff --git a/lldb/source/API/SBStream.cpp b/lldb/source/API/SBStream.cpp
index 4082af4..9aacfe8 100644
--- a/lldb/source/API/SBStream.cpp
+++ b/lldb/source/API/SBStream.cpp
@@ -81,7 +81,8 @@ void SBStream::RedirectToFile(const char *path, bool append) {
// See if we have any locally backed data. If so, copy it so we can then
// redirect it to the file so we don't lose the data
if (!m_is_file)
- local_data = static_cast<StreamString *>(m_opaque_up.get())->GetString();
+ local_data = std::string(
+ static_cast<StreamString *>(m_opaque_up.get())->GetString());
}
auto open_options = File::eOpenOptionWrite | File::eOpenOptionCanCreate;
if (append)
@@ -129,7 +130,8 @@ void SBStream::RedirectToFile(FileSP file_sp) {
// See if we have any locally backed data. If so, copy it so we can then
// redirect it to the file so we don't lose the data
if (!m_is_file)
- local_data = static_cast<StreamString *>(m_opaque_up.get())->GetString();
+ local_data = std::string(
+ static_cast<StreamString *>(m_opaque_up.get())->GetString());
}
m_opaque_up = std::make_unique<StreamFile>(file_sp);
@@ -150,7 +152,8 @@ void SBStream::RedirectToFileDescriptor(int fd, bool transfer_fh_ownership) {
// See if we have any locally backed data. If so, copy it so we can then
// redirect it to the file so we don't lose the data
if (!m_is_file)
- local_data = static_cast<StreamString *>(m_opaque_up.get())->GetString();
+ local_data = std::string(
+ static_cast<StreamString *>(m_opaque_up.get())->GetString());
}
m_opaque_up = std::make_unique<StreamFile>(fd, transfer_fh_ownership);
diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp
index 62f8c0c..23827aa 100644
--- a/lldb/source/API/SBValue.cpp
+++ b/lldb/source/API/SBValue.cpp
@@ -1493,7 +1493,7 @@ lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write,
StreamString ss;
// True to show fullpath for declaration file.
decl.DumpStopContext(&ss, true);
- watchpoint_sp->SetDeclInfo(ss.GetString());
+ watchpoint_sp->SetDeclInfo(std::string(ss.GetString()));
}
}
}
diff --git a/lldb/source/Breakpoint/BreakpointIDList.cpp b/lldb/source/Breakpoint/BreakpointIDList.cpp
index f297b3f..705bc5e 100644
--- a/lldb/source/Breakpoint/BreakpointIDList.cpp
+++ b/lldb/source/Breakpoint/BreakpointIDList.cpp
@@ -144,7 +144,7 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target,
result.SetStatus(eReturnStatusFailed);
return;
} else
- names_found.insert(current_arg);
+ names_found.insert(std::string(current_arg));
} else if ((i + 2 < old_args.size()) &&
BreakpointID::IsRangeIdentifier(old_args[i + 1].ref()) &&
BreakpointID::IsValidIDExpression(current_arg) &&
diff --git a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
index 268fb93..7725e8d 100644
--- a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
@@ -65,7 +65,7 @@ BreakpointResolver *BreakpointResolverFileRegex::CreateFromStructuredData(
"BRFR::CFSD: Malformed element %zu in the names array.", i);
return nullptr;
}
- names_set.insert(name);
+ names_set.insert(std::string(name));
}
}
diff --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp b/lldb/source/Breakpoint/BreakpointResolverName.cpp
index e2fdcd4..3e5a22a 100644
--- a/lldb/source/Breakpoint/BreakpointResolverName.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp
@@ -173,7 +173,7 @@ BreakpointResolver *BreakpointResolverName::CreateFromStructuredData(
error.SetErrorString("BRN::CFSD: name mask entry is not an integer.");
return nullptr;
}
- names.push_back(name);
+ names.push_back(std::string(name));
name_masks.push_back(static_cast<FunctionNameType>(fnt));
}
diff --git a/lldb/source/Breakpoint/BreakpointResolverScripted.cpp b/lldb/source/Breakpoint/BreakpointResolverScripted.cpp
index 3dcf90c..bf8cc16 100644
--- a/lldb/source/Breakpoint/BreakpointResolverScripted.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverScripted.cpp
@@ -26,12 +26,11 @@ using namespace lldb_private;
// BreakpointResolverScripted:
BreakpointResolverScripted::BreakpointResolverScripted(
- Breakpoint *bkpt,
- const llvm::StringRef class_name,
- lldb::SearchDepth depth,
+ Breakpoint *bkpt, const llvm::StringRef class_name, lldb::SearchDepth depth,
StructuredDataImpl *args_data)
: BreakpointResolver(bkpt, BreakpointResolver::PythonResolver),
- m_class_name(class_name), m_depth(depth), m_args_ptr(args_data) {
+ m_class_name(std::string(class_name)), m_depth(depth),
+ m_args_ptr(args_data) {
CreateImplementationIfNeeded();
}
diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp
index ea494af..e5f2911 100644
--- a/lldb/source/Commands/CommandCompletions.cpp
+++ b/lldb/source/Commands/CommandCompletions.cpp
@@ -295,7 +295,7 @@ void CommandCompletions::SettingsNames(CommandInterpreter &interpreter,
if (properties_sp) {
StreamString strm;
properties_sp->DumpValue(nullptr, strm, OptionValue::eDumpOptionName);
- const std::string &str = strm.GetString();
+ const std::string &str = std::string(strm.GetString());
g_property_names.SplitIntoLines(str.c_str(), str.size());
}
}
@@ -414,7 +414,7 @@ CommandCompletions::SymbolCompleter::SymbolCompleter(
std::string regex_str;
if (!m_request.GetCursorArgumentPrefix().empty()) {
regex_str.append("^");
- regex_str.append(m_request.GetCursorArgumentPrefix());
+ regex_str.append(std::string(m_request.GetCursorArgumentPrefix()));
} else {
// Match anything since the completion string is empty
regex_str.append(".");
diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index b6c9c2b..3c5d8f0 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -70,7 +70,7 @@ public:
m_bp_opts.m_set_flags.Set(BreakpointOptions::eCondition);
break;
case 'C':
- m_commands.push_back(option_arg);
+ m_commands.push_back(std::string(option_arg));
break;
case 'd':
m_bp_opts.SetEnabled(false);
@@ -270,7 +270,7 @@ public:
break;
case 'b':
- m_func_names.push_back(option_arg);
+ m_func_names.push_back(std::string(option_arg));
m_func_name_type_mask |= eFunctionNameTypeBase;
break;
@@ -320,7 +320,7 @@ public:
break;
case 'F':
- m_func_names.push_back(option_arg);
+ m_func_names.push_back(std::string(option_arg));
m_func_name_type_mask |= eFunctionNameTypeFull;
break;
@@ -383,18 +383,18 @@ public:
}
case 'M':
- m_func_names.push_back(option_arg);
+ m_func_names.push_back(std::string(option_arg));
m_func_name_type_mask |= eFunctionNameTypeMethod;
break;
case 'n':
- m_func_names.push_back(option_arg);
+ m_func_names.push_back(std::string(option_arg));
m_func_name_type_mask |= eFunctionNameTypeAuto;
break;
case 'N': {
if (BreakpointID::StringIsBreakpointName(option_arg, error))
- m_breakpoint_names.push_back(option_arg);
+ m_breakpoint_names.push_back(std::string(option_arg));
else
error.SetErrorStringWithFormat("Invalid breakpoint name: %s",
option_arg.str().c_str());
@@ -415,11 +415,11 @@ public:
break;
case 'p':
- m_source_text_regexp.assign(option_arg);
+ m_source_text_regexp.assign(std::string(option_arg));
break;
case 'r':
- m_func_regexp.assign(option_arg);
+ m_func_regexp.assign(std::string(option_arg));
break;
case 's':
@@ -427,7 +427,7 @@ public:
break;
case 'S':
- m_func_names.push_back(option_arg);
+ m_func_names.push_back(std::string(option_arg));
m_func_name_type_mask |= eFunctionNameTypeSelector;
break;
@@ -441,7 +441,7 @@ public:
} break;
case 'X':
- m_source_regex_func_names.insert(option_arg);
+ m_source_regex_func_names.insert(std::string(option_arg));
break;
default:
@@ -1231,7 +1231,7 @@ public:
switch (short_option) {
case 'f':
- m_filename.assign(option_arg);
+ m_filename.assign(std::string(option_arg));
break;
case 'l':
@@ -2004,7 +2004,7 @@ public:
switch (short_option) {
case 'f':
- m_filename.assign(option_arg);
+ m_filename.assign(std::string(option_arg));
break;
case 'N': {
Status name_error;
@@ -2013,7 +2013,7 @@ public:
error.SetErrorStringWithFormat("Invalid breakpoint name: %s",
name_error.AsCString());
}
- m_names.push_back(option_arg);
+ m_names.push_back(std::string(option_arg));
break;
}
default:
@@ -2122,7 +2122,7 @@ public:
switch (short_option) {
case 'f':
- m_filename.assign(option_arg);
+ m_filename.assign(std::string(option_arg));
break;
case 'a':
m_append = true;
diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
index 2229619..45df865 100644
--- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -292,7 +292,7 @@ are no syntax errors may indicate that a function was declared but never called.
switch (short_option) {
case 'o':
m_use_one_liner = true;
- m_one_liner = option_arg;
+ m_one_liner = std::string(option_arg);
break;
case 's':
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp
index 83f6239..cf5125d 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -652,8 +652,8 @@ protected:
}
// Save these in std::strings since we're going to shift them off.
- const std::string alias_command(args[0].ref());
- const std::string actual_command(args[1].ref());
+ const std::string alias_command(std::string(args[0].ref()));
+ const std::string actual_command(std::string(args[1].ref()));
args.Shift(); // Shift the alias command word off the argument vector.
args.Shift(); // Shift the old command word off the argument vector.
@@ -1114,12 +1114,12 @@ protected:
}
if (!check_only) {
- std::string regex(regex_sed.substr(first_separator_char_pos + 1,
- second_separator_char_pos -
- first_separator_char_pos - 1));
- std::string subst(regex_sed.substr(second_separator_char_pos + 1,
- third_separator_char_pos -
- second_separator_char_pos - 1));
+ std::string regex(std::string(regex_sed.substr(
+ first_separator_char_pos + 1,
+ second_separator_char_pos - first_separator_char_pos - 1)));
+ std::string subst(std::string(regex_sed.substr(
+ second_separator_char_pos + 1,
+ third_separator_char_pos - second_separator_char_pos - 1)));
m_regex_cmd_up->AddRegexCommand(regex.c_str(), subst.c_str());
}
return error;
@@ -1150,10 +1150,10 @@ private:
switch (short_option) {
case 'h':
- m_help.assign(option_arg);
+ m_help.assign(std::string(option_arg));
break;
case 's':
- m_syntax.assign(option_arg);
+ m_syntax.assign(std::string(option_arg));
break;
default:
llvm_unreachable("Unimplemented option");
@@ -1526,15 +1526,15 @@ protected:
switch (short_option) {
case 'f':
if (!option_arg.empty())
- m_funct_name = option_arg;
+ m_funct_name = std::string(option_arg);
break;
case 'c':
if (!option_arg.empty())
- m_class_name = option_arg;
+ m_class_name = std::string(option_arg);
break;
case 'h':
if (!option_arg.empty())
- m_short_help = option_arg;
+ m_short_help = std::string(option_arg);
break;
case 's':
m_synchronicity =
@@ -1643,7 +1643,7 @@ protected:
}
// Store the options in case we get multi-line input
- m_cmd_name = command[0].ref();
+ m_cmd_name = std::string(command[0].ref());
m_short_help.assign(m_options.m_short_help);
m_synchronicity = m_options.m_synchronicity;
diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp
index 9e80640..d513133 100644
--- a/lldb/source/Commands/CommandObjectDisassemble.cpp
+++ b/lldb/source/Commands/CommandObjectDisassemble.cpp
@@ -83,7 +83,7 @@ Status CommandObjectDisassemble::CommandOptions::SetOptionValue(
} break;
case 'n':
- func_name.assign(option_arg);
+ func_name.assign(std::string(option_arg));
some_location_specified = true;
break;
@@ -101,7 +101,7 @@ Status CommandObjectDisassemble::CommandOptions::SetOptionValue(
break;
case 'P':
- plugin_name.assign(option_arg);
+ plugin_name.assign(std::string(option_arg));
break;
case 'F': {
@@ -111,7 +111,7 @@ Status CommandObjectDisassemble::CommandOptions::SetOptionValue(
llvm::Triple::x86 ||
target_sp->GetArchitecture().GetTriple().getArch() ==
llvm::Triple::x86_64)) {
- flavor_string.assign(option_arg);
+ flavor_string.assign(std::string(option_arg));
} else
error.SetErrorStringWithFormat("Disassembler flavors are currently only "
"supported for x86 and x86_64 targets.");
diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp
index fabc496..fd01cec 100644
--- a/lldb/source/Commands/CommandObjectExpression.cpp
+++ b/lldb/source/Commands/CommandObjectExpression.cpp
@@ -657,7 +657,7 @@ bool CommandObjectExpression::DoExecute(llvm::StringRef command,
std::string fixed_command("expression ");
if (args.HasArgs()) {
// Add in any options that might have been in the original command:
- fixed_command.append(args.GetArgStringWithDelimiter());
+ fixed_command.append(std::string(args.GetArgStringWithDelimiter()));
fixed_command.append(m_fixed_expression);
} else
fixed_command.append(m_fixed_expression);
diff --git a/lldb/source/Commands/CommandObjectHelp.cpp b/lldb/source/Commands/CommandObjectHelp.cpp
index 7e984f9..6dc1868 100644
--- a/lldb/source/Commands/CommandObjectHelp.cpp
+++ b/lldb/source/Commands/CommandObjectHelp.cpp
@@ -107,7 +107,7 @@ bool CommandObjectHelp::DoExecute(Args &command, CommandReturnObject &result) {
// object that corresponds to the help command entered.
std::string sub_command;
for (auto &entry : command.entries().drop_front()) {
- sub_command = entry.ref();
+ sub_command = std::string(entry.ref());
matches.Clear();
if (sub_cmd_obj->IsAlias())
sub_cmd_obj =
diff --git a/lldb/source/Commands/CommandObjectLog.cpp b/lldb/source/Commands/CommandObjectLog.cpp
index 330379b..233831f 100644
--- a/lldb/source/Commands/CommandObjectLog.cpp
+++ b/lldb/source/Commands/CommandObjectLog.cpp
@@ -156,7 +156,7 @@ protected:
}
// Store into a std::string since we're about to shift the channel off.
- const std::string channel = args[0].ref();
+ const std::string channel = std::string(args[0].ref());
args.Shift(); // Shift off the channel
char log_file[PATH_MAX];
if (m_options.log_file)
@@ -229,7 +229,7 @@ protected:
return false;
}
- const std::string channel = args[0].ref();
+ const std::string channel = std::string(args[0].ref());
args.Shift(); // Shift off the channel
if (channel == "all") {
Log::DisableAllLogChannels();
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp
index 5bba156..ca0e058 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -32,7 +32,7 @@ CommandObjectSP CommandObjectMultiword::GetSubcommandSP(llvm::StringRef sub_cmd,
CommandObject::CommandMap::iterator pos;
if (!m_subcommand_dict.empty()) {
- pos = m_subcommand_dict.find(sub_cmd);
+ pos = m_subcommand_dict.find(std::string(sub_cmd));
if (pos != m_subcommand_dict.end()) {
// An exact match; append the sub_cmd to the 'matches' string list.
if (matches)
@@ -50,7 +50,7 @@ CommandObjectSP CommandObjectMultiword::GetSubcommandSP(llvm::StringRef sub_cmd,
// function, since I now know I have an exact match...
sub_cmd = matches->GetStringAtIndex(0);
- pos = m_subcommand_dict.find(sub_cmd);
+ pos = m_subcommand_dict.find(std::string(sub_cmd));
if (pos != m_subcommand_dict.end())
return_cmd_sp = pos->second;
}
@@ -74,9 +74,9 @@ bool CommandObjectMultiword::LoadSubCommand(llvm::StringRef name,
CommandMap::iterator pos;
bool success = true;
- pos = m_subcommand_dict.find(name);
+ pos = m_subcommand_dict.find(std::string(name));
if (pos == m_subcommand_dict.end()) {
- m_subcommand_dict[name] = cmd_obj;
+ m_subcommand_dict[std::string(name)] = cmd_obj;
} else
success = false;
@@ -130,9 +130,9 @@ bool CommandObjectMultiword::Execute(const char *args_string,
error_msg.assign("invalid command ");
error_msg.append("'");
- error_msg.append(GetCommandName());
+ error_msg.append(std::string(GetCommandName()));
error_msg.append(" ");
- error_msg.append(sub_command);
+ error_msg.append(std::string(sub_command));
error_msg.append("'.");
if (num_subcmd_matches > 0) {
@@ -165,7 +165,7 @@ void CommandObjectMultiword::GenerateHelpText(Stream &output_stream) {
std::string indented_command(" ");
indented_command.append(pos->first);
if (pos->second->WantsRawCommandString()) {
- std::string help_text(pos->second->GetHelp());
+ std::string help_text(std::string(pos->second->GetHelp()));
help_text.append(" Expects 'raw' input (see 'help raw-input'.)");
m_interpreter.OutputFormattedHelpText(output_stream,
indented_command.c_str(), "--",
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index fe0d842..e473756 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -709,7 +709,7 @@ protected:
option_arg.str().c_str());
break;
case 'd':
- m_data.assign(option_arg);
+ m_data.assign(std::string(option_arg));
break;
default:
llvm_unreachable("Unimplemented option");
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index f76f35c..0145122 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -759,7 +759,7 @@ public:
switch (short_option) {
case 'p':
- plugin_name.assign(option_arg);
+ plugin_name.assign(std::string(option_arg));
break;
default:
@@ -1252,13 +1252,13 @@ public:
switch (short_option) {
case 's':
- stop = option_arg;
+ stop = std::string(option_arg);
break;
case 'n':
- notify = option_arg;
+ notify = std::string(option_arg);
break;
case 'p':
- pass = option_arg;
+ pass = std::string(option_arg);
break;
default:
llvm_unreachable("Unimplemented option");
diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp
index b9cc5e3..4d64ae4 100644
--- a/lldb/source/Commands/CommandObjectSettings.cpp
+++ b/lldb/source/Commands/CommandObjectSettings.cpp
@@ -343,7 +343,7 @@ public:
switch (short_option) {
case 'f':
- m_filename.assign(option_arg);
+ m_filename.assign(std::string(option_arg));
break;
case 'a':
m_append = true;
@@ -444,7 +444,7 @@ public:
switch (short_option) {
case 'f':
- m_filename.assign(option_arg);
+ m_filename.assign(std::string(option_arg));
break;
default:
llvm_unreachable("Unimplemented option");
diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp
index 429c401..1ccfd3a 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -63,11 +63,11 @@ class CommandObjectSourceInfo : public CommandObjectParsed {
break;
case 'f':
- file_name = option_arg;
+ file_name = std::string(option_arg);
break;
case 'n':
- symbol_name = option_arg;
+ symbol_name = std::string(option_arg);
break;
case 'a': {
@@ -646,11 +646,11 @@ class CommandObjectSourceList : public CommandObjectParsed {
break;
case 'f':
- file_name = option_arg;
+ file_name = std::string(option_arg);
break;
case 'n':
- symbol_name = option_arg;
+ symbol_name = std::string(option_arg);
break;
case 'a': {
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index 603354d..1b51fbe 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -1292,7 +1292,7 @@ static void DumpModuleArchitecture(Stream &strm, Module *module,
module->GetArchitecture().DumpTriple(arch_strm.AsRawOstream());
else
arch_strm.PutCString(module->GetArchitecture().GetArchitectureName());
- std::string arch_str = arch_strm.GetString();
+ std::string arch_str = std::string(arch_strm.GetString());
if (width)
strm.Printf("%-*s", width, arch_str.c_str());
@@ -3268,7 +3268,7 @@ public:
switch (short_option) {
case 'a': {
- m_str = option_arg;
+ m_str = std::string(option_arg);
m_type = eLookupTypeAddress;
m_addr = OptionArgParser::ToAddress(execution_context, option_arg,
LLDB_INVALID_ADDRESS, &error);
@@ -3279,7 +3279,7 @@ public:
}
case 'n':
- m_str = option_arg;
+ m_str = std::string(option_arg);
m_type = eLookupTypeFunctionOrSymbol;
break;
@@ -3603,7 +3603,7 @@ public:
break;
case 's':
- m_str = option_arg;
+ m_str = std::string(option_arg);
m_type = eLookupTypeSymbol;
break;
@@ -3626,17 +3626,17 @@ public:
break;
case 'F':
- m_str = option_arg;
+ m_str = std::string(option_arg);
m_type = eLookupTypeFunction;
break;
case 'n':
- m_str = option_arg;
+ m_str = std::string(option_arg);
m_type = eLookupTypeFunctionOrSymbol;
break;
case 't':
- m_str = option_arg;
+ m_str = std::string(option_arg);
m_type = eLookupTypeType;
break;
@@ -4427,7 +4427,7 @@ public:
switch (short_option) {
case 'c':
- m_class_name = option_arg;
+ m_class_name = std::string(option_arg);
m_sym_ctx_specified = true;
break;
@@ -4464,18 +4464,18 @@ public:
break;
case 'n':
- m_function_name = option_arg;
+ m_function_name = std::string(option_arg);
m_func_name_type_mask |= eFunctionNameTypeAuto;
m_sym_ctx_specified = true;
break;
case 'f':
- m_file_name = option_arg;
+ m_file_name = std::string(option_arg);
m_sym_ctx_specified = true;
break;
case 's':
- m_module_name = option_arg;
+ m_module_name = std::string(option_arg);
m_sym_ctx_specified = true;
break;
@@ -4487,12 +4487,12 @@ public:
break;
case 'T':
- m_thread_name = option_arg;
+ m_thread_name = std::string(option_arg);
m_thread_specified = true;
break;
case 'q':
- m_queue_name = option_arg;
+ m_queue_name = std::string(option_arg);
m_thread_specified = true;
break;
@@ -4505,7 +4505,7 @@ public:
case 'o':
m_use_one_liner = true;
- m_one_liner.push_back(option_arg);
+ m_one_liner.push_back(std::string(option_arg));
break;
default:
diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index bf75224..3117c96 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -464,12 +464,12 @@ public:
case 'r':
m_avoid_regexp.clear();
- m_avoid_regexp.assign(option_arg);
+ m_avoid_regexp.assign(std::string(option_arg));
break;
case 't':
m_step_in_target.clear();
- m_step_in_target.assign(option_arg);
+ m_step_in_target.assign(std::string(option_arg));
break;
default:
diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp
index 329006a..d6dd406 100644
--- a/lldb/source/Commands/CommandObjectType.cpp
+++ b/lldb/source/Commands/CommandObjectType.cpp
@@ -531,7 +531,7 @@ private:
m_skip_pointers = true;
break;
case 'w':
- m_category.assign(option_value);
+ m_category.assign(std::string(option_value));
break;
case 'r':
m_skip_references = true;
@@ -540,7 +540,7 @@ private:
m_regex = true;
break;
case 't':
- m_custom_type_name.assign(option_value);
+ m_custom_type_name.assign(std::string(option_value));
break;
default:
llvm_unreachable("Unimplemented option");
@@ -1206,11 +1206,11 @@ Status CommandObjectTypeSummaryAdd::CommandOptions::SetOptionValue(
m_name.SetString(option_arg);
break;
case 'o':
- m_python_script = option_arg;
+ m_python_script = std::string(option_arg);
m_is_add_script = true;
break;
case 'F':
- m_python_function = option_arg;
+ m_python_function = std::string(option_arg);
m_is_add_script = true;
break;
case 'P':
@@ -1326,7 +1326,7 @@ bool CommandObjectTypeSummaryAdd::Execute_ScriptSummary(
return false;
}
- options->m_target_types << entry.ref();
+ options->m_target_types << std::string(entry.ref());
}
m_interpreter.GetPythonCommandsFromIOHandler(
@@ -2225,7 +2225,7 @@ bool CommandObjectTypeSynthAdd::Execute_HandwritePython(
return false;
}
- options->m_target_types << entry.ref();
+ options->m_target_types << std::string(entry.ref());
}
m_interpreter.GetPythonCommandsFromIOHandler(
@@ -2390,7 +2390,7 @@ private:
option_arg.str().c_str());
break;
case 'c':
- m_expr_paths.push_back(option_arg);
+ m_expr_paths.push_back(std::string(option_arg));
has_child_list = true;
break;
case 'p':
@@ -2705,7 +2705,7 @@ public:
return true;
});
- m_cmd_help_long = stream.GetString();
+ m_cmd_help_long = std::string(stream.GetString());
return m_cmd_help_long;
}
diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp
index 84d2cf6..2eadcd6 100644
--- a/lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -692,7 +692,7 @@ public:
switch (short_option) {
case 'c':
- m_condition = option_arg;
+ m_condition = std::string(option_arg);
m_condition_passed = true;
break;
default:
@@ -934,7 +934,7 @@ protected:
StreamString ss;
// True to show fullpath for declaration file.
var_sp->GetDeclaration().DumpStopContext(&ss, true);
- wp->SetDeclInfo(ss.GetString());
+ wp->SetDeclInfo(std::string(ss.GetString()));
}
output_stream.Printf("Watchpoint created: ");
wp->GetDescription(&output_stream, lldb::eDescriptionLevelFull);
diff --git a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
index 082f081..d86f4a3 100644
--- a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
@@ -327,7 +327,7 @@ are no syntax errors may indicate that a function was declared but never called.
switch (short_option) {
case 'o':
m_use_one_liner = true;
- m_one_liner = option_arg;
+ m_one_liner = std::string(option_arg);
break;
case 's':
@@ -359,7 +359,7 @@ are no syntax errors may indicate that a function was declared but never called.
case 'F':
m_use_one_liner = false;
- m_function_name.assign(option_arg);
+ m_function_name.assign(std::string(option_arg));
break;
default:
diff --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp
index f7977ea..26ff056 100644
--- a/lldb/source/Core/Disassembler.cpp
+++ b/lldb/source/Core/Disassembler.cpp
@@ -1346,7 +1346,7 @@ void PseudoInstruction::SetOpcode(size_t opcode_size, void *opcode_data) {
}
void PseudoInstruction::SetDescription(llvm::StringRef description) {
- m_description = description;
+ m_description = std::string(description);
}
Instruction::Operand Instruction::Operand::BuildRegister(ConstString &r) {
diff --git a/lldb/source/Core/DumpRegisterValue.cpp b/lldb/source/Core/DumpRegisterValue.cpp
index 29a67d8..2018d61 100644
--- a/lldb/source/Core/DumpRegisterValue.cpp
+++ b/lldb/source/Core/DumpRegisterValue.cpp
@@ -33,7 +33,7 @@ bool lldb_private::DumpRegisterValue(const RegisterValue &reg_val, Stream *s,
format_string.Printf("%%%us", reg_name_right_align_at);
else
format_string.Printf("%%s");
- std::string fmt = format_string.GetString();
+ std::string fmt = std::string(format_string.GetString());
if (prefix_with_name) {
if (reg_info->name) {
s->Printf(fmt.c_str(), reg_info->name);
diff --git a/lldb/source/Core/IOHandler.cpp b/lldb/source/Core/IOHandler.cpp
index e069f1f..939c87c 100644
--- a/lldb/source/Core/IOHandler.cpp
+++ b/lldb/source/Core/IOHandler.cpp
@@ -292,7 +292,8 @@ static Optional<std::string> SplitLine(std::string &line_buffer) {
size_t pos = line_buffer.find('\n');
if (pos == std::string::npos)
return None;
- std::string line = StringRef(line_buffer.c_str(), pos).rtrim("\n\r");
+ std::string line =
+ std::string(StringRef(line_buffer.c_str(), pos).rtrim("\n\r"));
line_buffer = line_buffer.substr(pos + 1);
return line;
}
@@ -443,7 +444,7 @@ const char *IOHandlerEditline::GetPrompt() {
}
bool IOHandlerEditline::SetPrompt(llvm::StringRef prompt) {
- m_prompt = prompt;
+ m_prompt = std::string(prompt);
#if LLDB_ENABLE_LIBEDIT
if (m_editline_up)
@@ -458,7 +459,7 @@ const char *IOHandlerEditline::GetContinuationPrompt() {
}
void IOHandlerEditline::SetContinuationPrompt(llvm::StringRef prompt) {
- m_continuation_prompt = prompt;
+ m_continuation_prompt = std::string(prompt);
#if LLDB_ENABLE_LIBEDIT
if (m_editline_up)
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index c9bf294..1dd83a5 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -977,7 +977,8 @@ void Module::FindTypes(
FindTypes_Impl(type_basename_const_str, nullptr, max_matches,
searched_symbol_files, typesmap);
if (typesmap.GetSize())
- typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class,
+ typesmap.RemoveMismatchedTypes(std::string(type_scope),
+ std::string(type_basename), type_class,
exact_match);
} else {
// The type is not in a namespace/class scope, just search for it by
@@ -987,14 +988,15 @@ void Module::FindTypes(
// class prefix (like "struct", "class", "union", "typedef" etc).
FindTypes_Impl(ConstString(type_basename), nullptr, UINT_MAX,
searched_symbol_files, typesmap);
- typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class,
+ typesmap.RemoveMismatchedTypes(std::string(type_scope),
+ std::string(type_basename), type_class,
exact_match);
} else {
FindTypes_Impl(name, nullptr, UINT_MAX, searched_symbol_files, typesmap);
if (exact_match) {
std::string name_str(name.AsCString(""));
- typesmap.RemoveMismatchedTypes(type_scope, name_str, type_class,
- exact_match);
+ typesmap.RemoveMismatchedTypes(std::string(type_scope), name_str,
+ type_class, exact_match);
}
}
}
diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp
index 03d911e..94dc44e 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -299,7 +299,8 @@ void PluginManager::RegisterPlugin(ConstString name,
llvm::StringRef description,
ArchitectureCreateInstance create_callback) {
std::lock_guard<std::mutex> guard(GetArchitectureMutex());
- GetArchitectureInstances().push_back({name, description, create_callback});
+ GetArchitectureInstances().push_back(
+ {name, std::string(description), create_callback});
}
void PluginManager::UnregisterPlugin(
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index f6e7dcc..f3fa09c 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -416,7 +416,7 @@ const char *ValueObject::GetLocationAsCStringImpl(const Value &value,
uint32_t addr_nibble_size = data.GetAddressByteSize() * 2;
sstr.Printf("0x%*.*llx", addr_nibble_size, addr_nibble_size,
value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS));
- m_location_str = sstr.GetString();
+ m_location_str = std::string(sstr.GetString());
} break;
}
}
@@ -1120,7 +1120,7 @@ const char *ValueObject::GetObjectDescription() {
if (LanguageRuntime *runtime = process->GetLanguageRuntime(language)) {
StreamString s;
if (runtime->GetObjectDescription(s, *this)) {
- m_object_desc_str.append(s.GetString());
+ m_object_desc_str.append(std::string(s.GetString()));
return m_object_desc_str.c_str();
}
}
diff --git a/lldb/source/DataFormatters/TypeCategory.cpp b/lldb/source/DataFormatters/TypeCategory.cpp
index d2d626a..7bfbb30a 100644
--- a/lldb/source/DataFormatters/TypeCategory.cpp
+++ b/lldb/source/DataFormatters/TypeCategory.cpp
@@ -492,5 +492,5 @@ std::string TypeCategoryImpl::GetDescription() {
if (print_lang)
stream.PutCString(lang_stream.GetString());
stream.PutChar(')');
- return stream.GetString();
+ return std::string(stream.GetString());
}
diff --git a/lldb/source/DataFormatters/TypeFormat.cpp b/lldb/source/DataFormatters/TypeFormat.cpp
index ae3e60f..b9a9447 100644
--- a/lldb/source/DataFormatters/TypeFormat.cpp
+++ b/lldb/source/DataFormatters/TypeFormat.cpp
@@ -60,7 +60,7 @@ bool TypeFormatImpl_Format::FormatObject(ValueObject *valobj,
DumpDataExtractor(data, &reg_sstr, 0, GetFormat(), reg_info->byte_size,
1, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0,
exe_ctx.GetBestExecutionContextScope());
- dest = reg_sstr.GetString();
+ dest = std::string(reg_sstr.GetString());
}
} else {
CompilerType compiler_type = value.GetCompilerType();
@@ -114,7 +114,7 @@ bool TypeFormatImpl_Format::FormatObject(ValueObject *valobj,
// here, but that's about as severe as we get
// CompilerType::DumpTypeValue() should always return something, even
// if that something is an error message
- dest = sstr.GetString();
+ dest = std::string(sstr.GetString());
}
}
return !dest.empty();
@@ -128,7 +128,7 @@ std::string TypeFormatImpl_Format::GetDescription() {
Cascades() ? "" : " (not cascading)",
SkipsPointers() ? " (skip pointers)" : "",
SkipsReferences() ? " (skip references)" : "");
- return sstr.GetString();
+ return std::string(sstr.GetString());
}
TypeFormatImpl_EnumType::TypeFormatImpl_EnumType(
@@ -191,7 +191,7 @@ bool TypeFormatImpl_EnumType::FormatObject(ValueObject *valobj,
data.GetByteSize(), 0, 0,
exe_ctx.GetBestExecutionContextScope());
if (!sstr.GetString().empty())
- dest = sstr.GetString();
+ dest = std::string(sstr.GetString());
return !dest.empty();
}
@@ -201,5 +201,5 @@ std::string TypeFormatImpl_EnumType::GetDescription() {
Cascades() ? "" : " (not cascading)",
SkipsPointers() ? " (skip pointers)" : "",
SkipsReferences() ? " (skip references)" : "");
- return sstr.GetString();
+ return std::string(sstr.GetString());
}
diff --git a/lldb/source/DataFormatters/TypeSummary.cpp b/lldb/source/DataFormatters/TypeSummary.cpp
index ab33045..5d4fe2e 100644
--- a/lldb/source/DataFormatters/TypeSummary.cpp
+++ b/lldb/source/DataFormatters/TypeSummary.cpp
@@ -83,13 +83,13 @@ bool StringSummaryFormat::FormatObject(ValueObject *valobj, std::string &retval,
if (IsOneLiner()) {
ValueObjectPrinter printer(valobj, &s, DumpValueObjectOptions());
printer.PrintChildrenOneLiner(HideNames(valobj));
- retval = s.GetString();
+ retval = std::string(s.GetString());
return true;
} else {
if (FormatEntity::Format(m_format, s, &sc, &exe_ctx,
&sc.line_entry.range.GetBaseAddress(), valobj,
false, false)) {
- retval.assign(s.GetString());
+ retval.assign(std::string(s.GetString()));
return true;
} else {
retval.assign("error: summary string parsing error");
@@ -111,7 +111,7 @@ std::string StringSummaryFormat::GetDescription() {
SkipsPointers() ? " (skip pointers)" : "",
SkipsReferences() ? " (skip references)" : "",
HideNames(nullptr) ? " (hide member names)" : "");
- return sstr.GetString();
+ return std::string(sstr.GetString());
}
CXXFunctionSummaryFormat::CXXFunctionSummaryFormat(
@@ -126,7 +126,7 @@ bool CXXFunctionSummaryFormat::FormatObject(ValueObject *valobj,
StreamString stream;
if (!m_impl || !m_impl(*valobj, stream, options))
return false;
- dest = stream.GetString();
+ dest = std::string(stream.GetString());
return true;
}
@@ -140,7 +140,7 @@ std::string CXXFunctionSummaryFormat::GetDescription() {
SkipsReferences() ? " (skip references)" : "",
HideNames(nullptr) ? " (hide member names)" : "",
m_description.c_str());
- return sstr.GetString();
+ return std::string(sstr.GetString());
}
ScriptSummaryFormat::ScriptSummaryFormat(const TypeSummaryImpl::Flags &flags,
@@ -197,5 +197,5 @@ std::string ScriptSummaryFormat::GetDescription() {
} else {
sstr.PutCString(m_python_script);
}
- return sstr.GetString();
+ return std::string(sstr.GetString());
}
diff --git a/lldb/source/DataFormatters/TypeSynthetic.cpp b/lldb/source/DataFormatters/TypeSynthetic.cpp
index c38a102..75388a9 100644
--- a/lldb/source/DataFormatters/TypeSynthetic.cpp
+++ b/lldb/source/DataFormatters/TypeSynthetic.cpp
@@ -81,7 +81,7 @@ std::string TypeFilterImpl::GetDescription() {
}
sstr.Printf("}");
- return sstr.GetString();
+ return std::string(sstr.GetString());
}
std::string CXXSyntheticChildren::GetDescription() {
@@ -91,7 +91,7 @@ std::string CXXSyntheticChildren::GetDescription() {
SkipsReferences() ? " (skip references)" : "",
m_description.c_str());
- return sstr.GetString();
+ return std::string(sstr.GetString());
}
lldb::ValueObjectSP SyntheticChildrenFrontEnd::CreateValueObjectFromExpression(
@@ -212,5 +212,5 @@ std::string ScriptedSyntheticChildren::GetDescription() {
SkipsReferences() ? " (skip references)" : "",
m_python_class.c_str());
- return sstr.GetString();
+ return std::string(sstr.GetString());
}
diff --git a/lldb/source/Expression/DiagnosticManager.cpp b/lldb/source/Expression/DiagnosticManager.cpp
index 5c3040b..0897706 100644
--- a/lldb/source/Expression/DiagnosticManager.cpp
+++ b/lldb/source/Expression/DiagnosticManager.cpp
@@ -49,7 +49,7 @@ std::string DiagnosticManager::GetString(char separator) {
for (const auto &diagnostic : Diagnostics()) {
ret.append(StringForSeverity(diagnostic->GetSeverity()));
- ret.append(diagnostic->GetMessage());
+ ret.append(std::string(diagnostic->GetMessage()));
ret.push_back(separator);
}
diff --git a/lldb/source/Expression/IRInterpreter.cpp b/lldb/source/Expression/IRInterpreter.cpp
index fd066ae..d734ce1 100644
--- a/lldb/source/Expression/IRInterpreter.cpp
+++ b/lldb/source/Expression/IRInterpreter.cpp
@@ -144,7 +144,7 @@ public:
ss.Printf(" 0x%llx", (unsigned long long)addr);
}
- return ss.GetString();
+ return std::string(ss.GetString());
}
bool AssignToMatchType(lldb_private::Scalar &scalar, uint64_t u64value,
@@ -403,7 +403,7 @@ public:
ss.Printf("%02hhx ", buf.GetBytes()[i]);
}
- return ss.GetString();
+ return std::string(ss.GetString());
}
lldb::addr_t ResolveValue(const Value *value, Module &module) {
diff --git a/lldb/source/Expression/UserExpression.cpp b/lldb/source/Expression/UserExpression.cpp
index 0157241..b5af597 100644
--- a/lldb/source/Expression/UserExpression.cpp
+++ b/lldb/source/Expression/UserExpression.cpp
@@ -53,8 +53,9 @@ UserExpression::UserExpression(ExecutionContextScope &exe_scope,
lldb::LanguageType language,
ResultType desired_type,
const EvaluateExpressionOptions &options)
- : Expression(exe_scope), m_expr_text(expr), m_expr_prefix(prefix),
- m_language(language), m_desired_type(desired_type), m_options(options) {}
+ : Expression(exe_scope), m_expr_text(std::string(expr)),
+ m_expr_prefix(std::string(prefix)), m_language(language),
+ m_desired_type(desired_type), m_options(options) {}
UserExpression::~UserExpression() {}
@@ -201,8 +202,8 @@ lldb::ExpressionResults UserExpression::Evaluate(
llvm::StringRef option_prefix(options.GetPrefix());
std::string full_prefix_storage;
if (!prefix.empty() && !option_prefix.empty()) {
- full_prefix_storage = prefix;
- full_prefix_storage.append(option_prefix);
+ full_prefix_storage = std::string(prefix);
+ full_prefix_storage.append(std::string(option_prefix));
full_prefix = full_prefix_storage;
} else if (!prefix.empty())
full_prefix = prefix;
diff --git a/lldb/source/Host/common/Editline.cpp b/lldb/source/Host/common/Editline.cpp
index 61a955c..6d82a98 100644
--- a/lldb/source/Host/common/Editline.cpp
+++ b/lldb/source/Host/common/Editline.cpp
@@ -214,7 +214,7 @@ private:
std::string filename = m_prefix + "-history";
#endif
llvm::sys::path::append(lldb_history_file, filename);
- m_path = lldb_history_file.str();
+ m_path = std::string(lldb_history_file.str());
}
}
@@ -327,7 +327,7 @@ std::string Editline::PromptForIndex(int line_index) {
prompt_stream.Printf(
"%*d%s", m_line_number_digits, m_base_line_number + line_index,
(line_index == 0) ? prompt.c_str() : continuation_prompt.c_str());
- return std::move(prompt_stream.GetString());
+ return std::string(std::move(prompt_stream.GetString()));
}
return (line_index == 0) ? prompt : continuation_prompt;
}
diff --git a/lldb/source/Host/common/OptionParser.cpp b/lldb/source/Host/common/OptionParser.cpp
index 3bfa4b8..b5c7ea6 100644
--- a/lldb/source/Host/common/OptionParser.cpp
+++ b/lldb/source/Host/common/OptionParser.cpp
@@ -41,7 +41,7 @@ int OptionParser::Parse(llvm::MutableArrayRef<char *> argv,
++longopts;
}
opts.push_back(option());
- std::string opt_cstr = optstring;
+ std::string opt_cstr = std::string(optstring);
return getopt_long_only(argv.size() - 1, argv.data(), opt_cstr.c_str(),
&opts[0], longindex);
}
diff --git a/lldb/source/Host/common/ProcessLaunchInfo.cpp b/lldb/source/Host/common/ProcessLaunchInfo.cpp
index 2851d28..63615b3 100644
--- a/lldb/source/Host/common/ProcessLaunchInfo.cpp
+++ b/lldb/source/Host/common/ProcessLaunchInfo.cpp
@@ -133,7 +133,7 @@ const char *ProcessLaunchInfo::GetProcessPluginName() const {
}
void ProcessLaunchInfo::SetProcessPluginName(llvm::StringRef plugin) {
- m_plugin_name = plugin;
+ m_plugin_name = std::string(plugin);
}
const FileSpec &ProcessLaunchInfo::GetShell() const { return m_shell; }
diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp
index 0b51eda..45c2f9e 100644
--- a/lldb/source/Host/common/Socket.cpp
+++ b/lldb/source/Host/common/Socket.cpp
@@ -309,7 +309,7 @@ bool Socket::DecodeHostAndPort(llvm::StringRef host_and_port,
host_str.clear();
port_str.clear();
if (to_integer(host_and_port, port, 10) && port < UINT16_MAX) {
- port_str = host_and_port;
+ port_str = std::string(host_and_port);
if (error_ptr)
error_ptr->Clear();
return true;
diff --git a/lldb/source/Host/common/TCPSocket.cpp b/lldb/source/Host/common/TCPSocket.cpp
index 45c2a63..821574e 100644
--- a/lldb/source/Host/common/TCPSocket.cpp
+++ b/lldb/source/Host/common/TCPSocket.cpp
@@ -120,8 +120,8 @@ std::string TCPSocket::GetRemoteIPAddress() const {
std::string TCPSocket::GetRemoteConnectionURI() const {
if (m_socket != kInvalidSocketValue) {
- return llvm::formatv("connect://[{0}]:{1}", GetRemoteIPAddress(),
- GetRemotePortNumber());
+ return std::string(llvm::formatv(
+ "connect://[{0}]:{1}", GetRemoteIPAddress(), GetRemotePortNumber()));
}
return "";
}
diff --git a/lldb/source/Host/common/UDPSocket.cpp b/lldb/source/Host/common/UDPSocket.cpp
index f03fd33..75fb483 100644
--- a/lldb/source/Host/common/UDPSocket.cpp
+++ b/lldb/source/Host/common/UDPSocket.cpp
@@ -136,8 +136,8 @@ Status UDPSocket::Connect(llvm::StringRef name, bool child_processes_inherit,
std::string UDPSocket::GetRemoteConnectionURI() const {
if (m_socket != kInvalidSocketValue) {
- return llvm::formatv("udp://[{0}]:{1}", m_sockaddr.GetIPAddress(),
- m_sockaddr.GetPort());
+ return std::string(llvm::formatv(
+ "udp://[{0}]:{1}", m_sockaddr.GetIPAddress(), m_sockaddr.GetPort()));
}
return "";
}
diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
index cd3f750..011e1fb 100644
--- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -223,7 +223,7 @@ ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path,
m_write_sp =
std::make_shared<NativeFile>(fd, File::eOpenOptionWrite, false);
}
- m_uri = *addr;
+ m_uri = std::string(*addr);
return eConnectionStatusSuccess;
}
}
@@ -652,7 +652,7 @@ ConnectionFileDescriptor::NamedSocketAccept(llvm::StringRef socket_name,
if (error.Fail()) {
return eConnectionStatusError;
}
- m_uri.assign(socket_name);
+ m_uri.assign(std::string(socket_name));
return eConnectionStatusSuccess;
}
@@ -669,7 +669,7 @@ ConnectionFileDescriptor::NamedSocketConnect(llvm::StringRef socket_name,
if (error.Fail()) {
return eConnectionStatusError;
}
- m_uri.assign(socket_name);
+ m_uri.assign(std::string(socket_name));
return eConnectionStatusSuccess;
}
@@ -686,7 +686,7 @@ ConnectionFileDescriptor::UnixAbstractSocketConnect(llvm::StringRef socket_name,
if (error.Fail()) {
return eConnectionStatusError;
}
- m_uri.assign(socket_name);
+ m_uri.assign(std::string(socket_name));
return eConnectionStatusSuccess;
}
@@ -730,7 +730,7 @@ ConnectionStatus ConnectionFileDescriptor::ConnectTCP(llvm::StringRef s,
if (error.Fail()) {
return eConnectionStatusError;
}
- m_uri.assign(s);
+ m_uri.assign(std::string(s));
return eConnectionStatusSuccess;
}
@@ -745,7 +745,7 @@ ConnectionStatus ConnectionFileDescriptor::ConnectUDP(llvm::StringRef s,
if (error.Fail()) {
return eConnectionStatusError;
}
- m_uri.assign(s);
+ m_uri.assign(std::string(s));
return eConnectionStatusSuccess;
}
diff --git a/lldb/source/Host/posix/DomainSocket.cpp b/lldb/source/Host/posix/DomainSocket.cpp
index c3a7591..5a39690 100644
--- a/lldb/source/Host/posix/DomainSocket.cpp
+++ b/lldb/source/Host/posix/DomainSocket.cpp
@@ -146,10 +146,10 @@ std::string DomainSocket::GetSocketName() const {
std::string DomainSocket::GetRemoteConnectionURI() const {
if (m_socket != kInvalidSocketValue) {
- return llvm::formatv("{0}://{1}",
- GetNameOffset() == 0 ? "unix-connect"
- : "unix-abstract-connect",
- GetSocketName());
+ return std::string(llvm::formatv(
+ "{0}://{1}",
+ GetNameOffset() == 0 ? "unix-connect" : "unix-abstract-connect",
+ GetSocketName()));
}
return "";
}
diff --git a/lldb/source/Interpreter/CommandAlias.cpp b/lldb/source/Interpreter/CommandAlias.cpp
index bf6ddb9..5192cab 100644
--- a/lldb/source/Interpreter/CommandAlias.cpp
+++ b/lldb/source/Interpreter/CommandAlias.cpp
@@ -79,7 +79,7 @@ CommandAlias::CommandAlias(CommandInterpreter &interpreter,
llvm::StringRef help, llvm::StringRef syntax,
uint32_t flags)
: CommandObject(interpreter, name, help, syntax, flags),
- m_underlying_command_sp(), m_option_string(options_args),
+ m_underlying_command_sp(), m_option_string(std::string(options_args)),
m_option_args_sp(new OptionArgVector),
m_is_dashdash_alias(eLazyBoolCalculate), m_did_set_help(false),
m_did_set_help_long(false) {
diff --git a/lldb/source/Interpreter/CommandHistory.cpp b/lldb/source/Interpreter/CommandHistory.cpp
index acbf4a1..9c7919e 100644
--- a/lldb/source/Interpreter/CommandHistory.cpp
+++ b/lldb/source/Interpreter/CommandHistory.cpp
@@ -87,7 +87,7 @@ void CommandHistory::AppendString(llvm::StringRef str, bool reject_if_dupe) {
return;
}
}
- m_history.push_back(str);
+ m_history.push_back(std::string(str));
}
void CommandHistory::Clear() {
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index aedd71b..c2c70dc 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -571,7 +571,8 @@ void CommandInterpreter::LoadCommandDictionary() {
if (success) {
CommandObjectSP break_regex_cmd_sp(break_regex_cmd_up.release());
- m_command_dict[break_regex_cmd_sp->GetCommandName()] = break_regex_cmd_sp;
+ m_command_dict[std::string(break_regex_cmd_sp->GetCommandName())] =
+ break_regex_cmd_sp;
}
}
@@ -631,7 +632,7 @@ void CommandInterpreter::LoadCommandDictionary() {
if (success) {
CommandObjectSP tbreak_regex_cmd_sp(tbreak_regex_cmd_up.release());
- m_command_dict[tbreak_regex_cmd_sp->GetCommandName()] =
+ m_command_dict[std::string(tbreak_regex_cmd_sp->GetCommandName())] =
tbreak_regex_cmd_sp;
}
}
@@ -651,7 +652,7 @@ void CommandInterpreter::LoadCommandDictionary() {
"process attach --name '%1'") &&
attach_regex_cmd_up->AddRegexCommand("^$", "process attach")) {
CommandObjectSP attach_regex_cmd_sp(attach_regex_cmd_up.release());
- m_command_dict[attach_regex_cmd_sp->GetCommandName()] =
+ m_command_dict[std::string(attach_regex_cmd_sp->GetCommandName())] =
attach_regex_cmd_sp;
}
}
@@ -667,7 +668,8 @@ void CommandInterpreter::LoadCommandDictionary() {
down_regex_cmd_up->AddRegexCommand("^([0-9]+)$",
"frame select -r -%1")) {
CommandObjectSP down_regex_cmd_sp(down_regex_cmd_up.release());
- m_command_dict[down_regex_cmd_sp->GetCommandName()] = down_regex_cmd_sp;
+ m_command_dict[std::string(down_regex_cmd_sp->GetCommandName())] =
+ down_regex_cmd_sp;
}
}
@@ -681,7 +683,8 @@ void CommandInterpreter::LoadCommandDictionary() {
if (up_regex_cmd_up->AddRegexCommand("^$", "frame select -r 1") &&
up_regex_cmd_up->AddRegexCommand("^([0-9]+)$", "frame select -r %1")) {
CommandObjectSP up_regex_cmd_sp(up_regex_cmd_up.release());
- m_command_dict[up_regex_cmd_sp->GetCommandName()] = up_regex_cmd_sp;
+ m_command_dict[std::string(up_regex_cmd_sp->GetCommandName())] =
+ up_regex_cmd_sp;
}
}
@@ -694,7 +697,7 @@ void CommandInterpreter::LoadCommandDictionary() {
if (display_regex_cmd_up->AddRegexCommand(
"^(.+)$", "target stop-hook add -o \"expr -- %1\"")) {
CommandObjectSP display_regex_cmd_sp(display_regex_cmd_up.release());
- m_command_dict[display_regex_cmd_sp->GetCommandName()] =
+ m_command_dict[std::string(display_regex_cmd_sp->GetCommandName())] =
display_regex_cmd_sp;
}
}
@@ -709,7 +712,7 @@ void CommandInterpreter::LoadCommandDictionary() {
if (undisplay_regex_cmd_up->AddRegexCommand("^([0-9]+)$",
"target stop-hook delete %1")) {
CommandObjectSP undisplay_regex_cmd_sp(undisplay_regex_cmd_up.release());
- m_command_dict[undisplay_regex_cmd_sp->GetCommandName()] =
+ m_command_dict[std::string(undisplay_regex_cmd_sp->GetCommandName())] =
undisplay_regex_cmd_sp;
}
}
@@ -728,7 +731,7 @@ void CommandInterpreter::LoadCommandDictionary() {
"^([[:digit:]]+)$",
"process connect --plugin gdb-remote connect://localhost:%1")) {
CommandObjectSP command_sp(connect_gdb_remote_cmd_up.release());
- m_command_dict[command_sp->GetCommandName()] = command_sp;
+ m_command_dict[std::string(command_sp->GetCommandName())] = command_sp;
}
}
@@ -746,7 +749,7 @@ void CommandInterpreter::LoadCommandDictionary() {
connect_kdp_remote_cmd_up->AddRegexCommand(
"^(.+)$", "process connect --plugin kdp-remote udp://%1:41139")) {
CommandObjectSP command_sp(connect_kdp_remote_cmd_up.release());
- m_command_dict[command_sp->GetCommandName()] = command_sp;
+ m_command_dict[std::string(command_sp->GetCommandName())] = command_sp;
}
}
@@ -771,7 +774,7 @@ void CommandInterpreter::LoadCommandDictionary() {
bt_regex_cmd_up->AddRegexCommand("^all[[:space:]]*$", "thread backtrace all") &&
bt_regex_cmd_up->AddRegexCommand("^[[:space:]]*$", "thread backtrace")) {
CommandObjectSP command_sp(bt_regex_cmd_up.release());
- m_command_dict[command_sp->GetCommandName()] = command_sp;
+ m_command_dict[std::string(command_sp->GetCommandName())] = command_sp;
}
}
@@ -807,7 +810,8 @@ void CommandInterpreter::LoadCommandDictionary() {
"source list --name \"%1\"") &&
list_regex_cmd_up->AddRegexCommand("^$", "source list")) {
CommandObjectSP list_regex_cmd_sp(list_regex_cmd_up.release());
- m_command_dict[list_regex_cmd_sp->GetCommandName()] = list_regex_cmd_sp;
+ m_command_dict[std::string(list_regex_cmd_sp->GetCommandName())] =
+ list_regex_cmd_sp;
}
}
@@ -825,7 +829,8 @@ void CommandInterpreter::LoadCommandDictionary() {
env_regex_cmd_up->AddRegexCommand("^([A-Za-z_][A-Za-z_0-9]*=.*)$",
"settings set target.env-vars %1")) {
CommandObjectSP env_regex_cmd_sp(env_regex_cmd_up.release());
- m_command_dict[env_regex_cmd_sp->GetCommandName()] = env_regex_cmd_sp;
+ m_command_dict[std::string(env_regex_cmd_sp->GetCommandName())] =
+ env_regex_cmd_sp;
}
}
@@ -848,7 +853,8 @@ void CommandInterpreter::LoadCommandDictionary() {
jump_regex_cmd_up->AddRegexCommand("^([+\\-][0-9]+)$",
"thread jump --by %1")) {
CommandObjectSP jump_regex_cmd_sp(jump_regex_cmd_up.release());
- m_command_dict[jump_regex_cmd_sp->GetCommandName()] = jump_regex_cmd_sp;
+ m_command_dict[std::string(jump_regex_cmd_sp->GetCommandName())] =
+ jump_regex_cmd_sp;
}
}
}
@@ -873,7 +879,7 @@ CommandInterpreter::GetCommandSP(llvm::StringRef cmd_str, bool include_aliases,
StringList *descriptions) const {
CommandObjectSP command_sp;
- std::string cmd = cmd_str;
+ std::string cmd = std::string(cmd_str);
if (HasCommands()) {
auto pos = m_command_dict.find(cmd);
@@ -1002,18 +1008,18 @@ bool CommandInterpreter::AddUserCommand(llvm::StringRef name,
if (CommandExists(name)) {
if (!can_replace)
return false;
- if (!m_command_dict[name]->IsRemovable())
+ if (!m_command_dict[std::string(name)]->IsRemovable())
return false;
}
if (UserCommandExists(name)) {
if (!can_replace)
return false;
- if (!m_user_dict[name]->IsRemovable())
+ if (!m_user_dict[std::string(name)]->IsRemovable())
return false;
}
- m_user_dict[name] = cmd_sp;
+ m_user_dict[std::string(name)] = cmd_sp;
return true;
}
return false;
@@ -1099,14 +1105,15 @@ CommandInterpreter::GetCommandObject(llvm::StringRef cmd_str,
}
bool CommandInterpreter::CommandExists(llvm::StringRef cmd) const {
- return m_command_dict.find(cmd) != m_command_dict.end();
+ return m_command_dict.find(std::string(cmd)) != m_command_dict.end();
}
bool CommandInterpreter::GetAliasFullName(llvm::StringRef cmd,
std::string &full_name) const {
- bool exact_match = (m_alias_dict.find(cmd) != m_alias_dict.end());
+ bool exact_match =
+ (m_alias_dict.find(std::string(cmd)) != m_alias_dict.end());
if (exact_match) {
- full_name.assign(cmd);
+ full_name.assign(std::string(cmd));
return exact_match;
} else {
StringList matches;
@@ -1132,11 +1139,11 @@ bool CommandInterpreter::GetAliasFullName(llvm::StringRef cmd,
}
bool CommandInterpreter::AliasExists(llvm::StringRef cmd) const {
- return m_alias_dict.find(cmd) != m_alias_dict.end();
+ return m_alias_dict.find(std::string(cmd)) != m_alias_dict.end();
}
bool CommandInterpreter::UserCommandExists(llvm::StringRef cmd) const {
- return m_user_dict.find(cmd) != m_user_dict.end();
+ return m_user_dict.find(std::string(cmd)) != m_user_dict.end();
}
CommandAlias *
@@ -1151,7 +1158,8 @@ CommandInterpreter::AddAlias(llvm::StringRef alias_name,
new CommandAlias(*this, command_obj_sp, args_string, alias_name));
if (command_alias_up && command_alias_up->IsValid()) {
- m_alias_dict[alias_name] = CommandObjectSP(command_alias_up.get());
+ m_alias_dict[std::string(alias_name)] =
+ CommandObjectSP(command_alias_up.get());
return command_alias_up.release();
}
@@ -1159,7 +1167,7 @@ CommandInterpreter::AddAlias(llvm::StringRef alias_name,
}
bool CommandInterpreter::RemoveAlias(llvm::StringRef alias_name) {
- auto pos = m_alias_dict.find(alias_name);
+ auto pos = m_alias_dict.find(std::string(alias_name));
if (pos != m_alias_dict.end()) {
m_alias_dict.erase(pos);
return true;
@@ -1168,7 +1176,7 @@ bool CommandInterpreter::RemoveAlias(llvm::StringRef alias_name) {
}
bool CommandInterpreter::RemoveCommand(llvm::StringRef cmd) {
- auto pos = m_command_dict.find(cmd);
+ auto pos = m_command_dict.find(std::string(cmd));
if (pos != m_command_dict.end()) {
if (pos->second->IsRemovable()) {
// Only regular expression objects or python commands are removable
@@ -1179,7 +1187,8 @@ bool CommandInterpreter::RemoveCommand(llvm::StringRef cmd) {
return false;
}
bool CommandInterpreter::RemoveUser(llvm::StringRef alias_name) {
- CommandObject::CommandMap::iterator pos = m_user_dict.find(alias_name);
+ CommandObject::CommandMap::iterator pos =
+ m_user_dict.find(std::string(alias_name));
if (pos != m_user_dict.end()) {
m_user_dict.erase(pos);
return true;
@@ -1263,7 +1272,8 @@ CommandObject *CommandInterpreter::GetCommandObjectForCommand(
end = command_string.find_first_of(k_white_space, start);
if (end == std::string::npos)
end = command_string.size();
- std::string cmd_word = command_string.substr(start, end - start);
+ std::string cmd_word =
+ std::string(command_string.substr(start, end - start));
if (cmd_obj == nullptr)
// Since cmd_obj is NULL we are on our first time through this loop.
@@ -1404,7 +1414,7 @@ CommandObject *CommandInterpreter::BuildAliasResult(
((CommandAlias *)alias_cmd_obj)->Desugar();
OptionArgVectorSP option_arg_vector_sp = desugared.second;
alias_cmd_obj = desugared.first.get();
- std::string alias_name_str = alias_name;
+ std::string alias_name_str = std::string(alias_name);
if ((cmd_args.GetArgumentCount() == 0) ||
(alias_name_str != cmd_args.GetArgumentAtIndex(0)))
cmd_args.Unshift(alias_name_str);
@@ -1412,7 +1422,7 @@ CommandObject *CommandInterpreter::BuildAliasResult(
result_str.Printf("%s", alias_cmd_obj->GetCommandName().str().c_str());
if (!option_arg_vector_sp.get()) {
- alias_result = result_str.GetString();
+ alias_result = std::string(result_str.GetString());
return alias_cmd_obj;
}
OptionArgVector *option_arg_vector = option_arg_vector_sp.get();
@@ -1453,7 +1463,7 @@ CommandObject *CommandInterpreter::BuildAliasResult(
}
}
- alias_result = result_str.GetString();
+ alias_result = std::string(result_str.GetString());
return alias_cmd_obj;
}
@@ -1537,7 +1547,7 @@ Status CommandInterpreter::PreprocessCommand(std::string &command) {
scalar.GetValue(&value_strm, show_type);
size_t value_string_size = value_strm.GetSize();
if (value_string_size) {
- command.insert(start_backtick, value_strm.GetString());
+ command.insert(start_backtick, std::string(value_strm.GetString()));
pos = start_backtick + value_string_size;
continue;
} else {
@@ -1662,8 +1672,8 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
search_str = search_str.drop_front(non_space);
if (auto hist_str = m_command_history.FindString(search_str)) {
add_to_history = false;
- command_string = *hist_str;
- original_command_string = *hist_str;
+ command_string = std::string(*hist_str);
+ original_command_string = std::string(*hist_str);
} else {
result.AppendErrorWithFormat("Could not find entry: %s in history",
command_string.c_str());
@@ -1872,7 +1882,7 @@ const CommandAlias *
CommandInterpreter::GetAlias(llvm::StringRef alias_name) const {
OptionArgVectorSP ret_val;
- auto pos = m_alias_dict.find(alias_name);
+ auto pos = m_alias_dict.find(std::string(alias_name));
if (pos != m_alias_dict.end())
return (CommandAlias *)pos->second.get();
@@ -3083,7 +3093,7 @@ CommandInterpreter::ResolveCommandImpl(std::string &command_line,
std::string gdb_format_option("--gdb-format=");
gdb_format_option += (suffix.c_str() + 1);
- std::string cmd = revised_command_line.GetString();
+ std::string cmd = std::string(revised_command_line.GetString());
size_t arg_terminator_idx = FindArgumentTerminator(cmd);
if (arg_terminator_idx != std::string::npos) {
// Insert the gdb format option before the "--" that terminates
@@ -3124,7 +3134,7 @@ CommandInterpreter::ResolveCommandImpl(std::string &command_line,
revised_command_line.Printf(" %s", scratch_command.c_str());
if (cmd_obj != nullptr)
- command_line = revised_command_line.GetString();
+ command_line = std::string(revised_command_line.GetString());
return cmd_obj;
}
diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp
index d7084c8..b87ca44 100644
--- a/lldb/source/Interpreter/CommandObject.cpp
+++ b/lldb/source/Interpreter/CommandObject.cpp
@@ -37,14 +37,15 @@ using namespace lldb_private;
// CommandObject
-CommandObject::CommandObject(CommandInterpreter &interpreter, llvm::StringRef name,
- llvm::StringRef help, llvm::StringRef syntax, uint32_t flags)
- : m_interpreter(interpreter), m_cmd_name(name),
+CommandObject::CommandObject(CommandInterpreter &interpreter,
+ llvm::StringRef name, llvm::StringRef help,
+ llvm::StringRef syntax, uint32_t flags)
+ : m_interpreter(interpreter), m_cmd_name(std::string(name)),
m_cmd_help_short(), m_cmd_help_long(), m_cmd_syntax(), m_flags(flags),
m_arguments(), m_deprecated_command_override_callback(nullptr),
m_command_override_callback(nullptr), m_command_override_baton(nullptr) {
- m_cmd_help_short = help;
- m_cmd_syntax = syntax;
+ m_cmd_help_short = std::string(help);
+ m_cmd_syntax = std::string(syntax);
}
CommandObject::~CommandObject() {}
@@ -73,20 +74,28 @@ llvm::StringRef CommandObject::GetSyntax() {
syntax_str.PutCString("-- ");
GetFormattedCommandArguments(syntax_str);
}
- m_cmd_syntax = syntax_str.GetString();
+ m_cmd_syntax = std::string(syntax_str.GetString());
return m_cmd_syntax;
}
llvm::StringRef CommandObject::GetCommandName() const { return m_cmd_name; }
-void CommandObject::SetCommandName(llvm::StringRef name) { m_cmd_name = name; }
+void CommandObject::SetCommandName(llvm::StringRef name) {
+ m_cmd_name = std::string(name);
+}
-void CommandObject::SetHelp(llvm::StringRef str) { m_cmd_help_short = str; }
+void CommandObject::SetHelp(llvm::StringRef str) {
+ m_cmd_help_short = std::string(str);
+}
-void CommandObject::SetHelpLong(llvm::StringRef str) { m_cmd_help_long = str; }
+void CommandObject::SetHelpLong(llvm::StringRef str) {
+ m_cmd_help_long = std::string(str);
+}
-void CommandObject::SetSyntax(llvm::StringRef str) { m_cmd_syntax = str; }
+void CommandObject::SetSyntax(llvm::StringRef str) {
+ m_cmd_syntax = std::string(str);
+}
Options *CommandObject::GetOptions() {
// By default commands don't have options unless this virtual function is
@@ -485,7 +494,7 @@ void CommandObject::GetFormattedCommandArguments(Stream &str,
names.Printf("%s", GetArgumentName(arg_entry[j].arg_type));
}
- std::string name_str = names.GetString();
+ std::string name_str = std::string(names.GetString());
switch (arg_entry[0].arg_repetition) {
case eArgRepeatPlain:
str.Printf("<%s>", name_str.c_str());
@@ -673,7 +682,7 @@ static llvm::StringRef FormatHelpTextCallback() {
sstr.Flush();
- help_text = sstr.GetString();
+ help_text = std::string(sstr.GetString());
return help_text;
}
@@ -691,7 +700,7 @@ static llvm::StringRef LanguageTypeHelpTextCallback() {
sstr.Flush();
- help_text = sstr.GetString();
+ help_text = std::string(sstr.GetString());
return help_text;
}
@@ -809,7 +818,7 @@ static llvm::StringRef ExprPathHelpTextCallback() {
void CommandObject::FormatLongHelpText(Stream &output_strm,
llvm::StringRef long_help) {
CommandInterpreter &interpreter = GetCommandInterpreter();
- std::stringstream lineStream(long_help);
+ std::stringstream lineStream{std::string(long_help)};
std::string line;
while (std::getline(lineStream, line)) {
if (line.empty()) {
diff --git a/lldb/source/Interpreter/CommandReturnObject.cpp b/lldb/source/Interpreter/CommandReturnObject.cpp
index 41caa9c..efeac6d 100644
--- a/lldb/source/Interpreter/CommandReturnObject.cpp
+++ b/lldb/source/Interpreter/CommandReturnObject.cpp
@@ -46,7 +46,7 @@ void CommandReturnObject::AppendErrorWithFormat(const char *format, ...) {
sstrm.PrintfVarArg(format, args);
va_end(args);
- const std::string &s = sstrm.GetString();
+ const std::string &s = std::string(sstrm.GetString());
if (!s.empty()) {
Stream &error_strm = GetErrorStream();
error_strm.PutCString("error: ");
diff --git a/lldb/source/Interpreter/OptionGroupArchitecture.cpp b/lldb/source/Interpreter/OptionGroupArchitecture.cpp
index 36dd9a3..baca1c6 100644
--- a/lldb/source/Interpreter/OptionGroupArchitecture.cpp
+++ b/lldb/source/Interpreter/OptionGroupArchitecture.cpp
@@ -42,7 +42,7 @@ OptionGroupArchitecture::SetOptionValue(uint32_t option_idx,
switch (short_option) {
case 'a':
- m_arch_str.assign(option_arg);
+ m_arch_str.assign(std::string(option_arg));
break;
default:
diff --git a/lldb/source/Interpreter/OptionGroupPlatform.cpp b/lldb/source/Interpreter/OptionGroupPlatform.cpp
index 3120583..4242e01 100644
--- a/lldb/source/Interpreter/OptionGroupPlatform.cpp
+++ b/lldb/source/Interpreter/OptionGroupPlatform.cpp
@@ -95,7 +95,7 @@ OptionGroupPlatform::SetOptionValue(uint32_t option_idx,
switch (short_option) {
case 'p':
- m_platform_name.assign(option_arg);
+ m_platform_name.assign(std::string(option_arg));
break;
case 'v':
diff --git a/lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp b/lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp
index 1b7478b..217dab2 100644
--- a/lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp
+++ b/lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp
@@ -91,13 +91,13 @@ Status OptionGroupPythonClassWithDict::SetOptionValue(
switch (option_idx) {
case 0:
case 3: {
- m_name.assign(option_arg);
+ m_name.assign(std::string(option_arg));
} break;
case 1: {
if (!m_dict_sp)
m_dict_sp = std::make_shared<StructuredData::Dictionary>();
if (m_current_key.empty())
- m_current_key.assign(option_arg);
+ m_current_key.assign(std::string(option_arg));
else
error.SetErrorStringWithFormat("Key: \"%s\" missing value.",
m_current_key.c_str());
diff --git a/lldb/source/Interpreter/OptionValueFormatEntity.cpp b/lldb/source/Interpreter/OptionValueFormatEntity.cpp
index 335fb1f..6b36bd57 100644
--- a/lldb/source/Interpreter/OptionValueFormatEntity.cpp
+++ b/lldb/source/Interpreter/OptionValueFormatEntity.cpp
@@ -95,7 +95,7 @@ Status OptionValueFormatEntity::SetValueFromString(llvm::StringRef value_str,
error = FormatEntity::Parse(value_str, entry);
if (error.Success()) {
m_current_entry = std::move(entry);
- m_current_format = value_str;
+ m_current_format = std::string(value_str);
m_value_was_set = true;
NotifyValueChanged();
}
diff --git a/lldb/source/Interpreter/OptionValueString.cpp b/lldb/source/Interpreter/OptionValueString.cpp
index 3d39e85..22f5d08 100644
--- a/lldb/source/Interpreter/OptionValueString.cpp
+++ b/lldb/source/Interpreter/OptionValueString.cpp
@@ -82,7 +82,7 @@ Status OptionValueString::SetValueFromString(llvm::StringRef value,
Args::EncodeEscapeSequences(value_str.c_str(), str);
new_value.append(str);
} else
- new_value.append(value);
+ new_value.append(std::string(value));
}
if (m_validator) {
error = m_validator(new_value.c_str(), m_validator_baton);
@@ -127,7 +127,7 @@ Status OptionValueString::SetCurrentValue(llvm::StringRef value) {
if (error.Fail())
return error;
}
- m_current_value.assign(value);
+ m_current_value.assign(std::string(value));
return Status();
}
diff --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp
index 352941b..56d63e4 100644
--- a/lldb/source/Interpreter/Options.cpp
+++ b/lldb/source/Interpreter/Options.cpp
@@ -932,7 +932,7 @@ static size_t FindArgumentIndexForOption(const Args &args,
const Option &long_option) {
std::string short_opt = llvm::formatv("-{0}", char(long_option.val)).str();
std::string long_opt =
- llvm::formatv("--{0}", long_option.definition->long_option);
+ std::string(llvm::formatv("--{0}", long_option.definition->long_option));
for (const auto &entry : llvm::enumerate(args)) {
if (entry.value().ref().startswith(short_opt) ||
entry.value().ref().startswith(long_opt))
@@ -1075,7 +1075,7 @@ llvm::Expected<Args> Options::ParseAlias(const Args &args,
if (!input_line.empty()) {
auto tmp_arg = args_copy[idx].ref();
- size_t pos = input_line.find(tmp_arg);
+ size_t pos = input_line.find(std::string(tmp_arg));
if (pos != std::string::npos)
input_line.erase(pos, tmp_arg.size());
}
@@ -1087,7 +1087,7 @@ llvm::Expected<Args> Options::ParseAlias(const Args &args,
(args_copy[idx].ref() == OptionParser::GetOptionArgument())) {
if (input_line.size() > 0) {
auto tmp_arg = args_copy[idx].ref();
- size_t pos = input_line.find(tmp_arg);
+ size_t pos = input_line.find(std::string(tmp_arg));
if (pos != std::string::npos)
input_line.erase(pos, tmp_arg.size());
}
diff --git a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
index 0cf0c63..e9399c3 100644
--- a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
+++ b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
@@ -367,7 +367,7 @@ public:
}
break;
}
- m_mnemonics = mnemonic_strm.GetString();
+ m_mnemonics = std::string(mnemonic_strm.GetString());
return;
} else {
if (m_does_branch == eLazyBoolCalculate) {
@@ -1414,7 +1414,7 @@ const char *DisassemblerLLVMC::SymbolLookup(uint64_t value, uint64_t *type_ptr,
// If Address::Dump returned a multi-line description, most commonly
// seen when we have multiple levels of inlined functions at an
// address, only show the first line.
- std::string str = ss.GetString();
+ std::string str = std::string(ss.GetString());
size_t first_eol_char = str.find_first_of("\r\n");
if (first_eol_char != std::string::npos) {
str.erase(first_eol_char);
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index f6f2203..4940564 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -383,9 +383,10 @@ bool DynamicLoaderDarwin::JSONImageInformationIntoImageInfo(
mh->GetValueForKey("filetype")->GetAsInteger()->GetValue();
if (image->HasKey("min_version_os_name")) {
- std::string os_name = image->GetValueForKey("min_version_os_name")
- ->GetAsString()
- ->GetValue();
+ std::string os_name =
+ std::string(image->GetValueForKey("min_version_os_name")
+ ->GetAsString()
+ ->GetValue());
if (os_name == "macosx")
image_infos[i].os_type = llvm::Triple::MacOSX;
else if (os_name == "ios" || os_name == "iphoneos")
@@ -403,9 +404,9 @@ bool DynamicLoaderDarwin::JSONImageInformationIntoImageInfo(
}
if (image->HasKey("min_version_os_sdk")) {
image_infos[i].min_version_os_sdk =
- image->GetValueForKey("min_version_os_sdk")
- ->GetAsString()
- ->GetValue();
+ std::string(image->GetValueForKey("min_version_os_sdk")
+ ->GetAsString()
+ ->GetValue());
}
// Fields that aren't used by DynamicLoaderDarwin so debugserver doesn't
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
index 1563279..a9e674e 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
@@ -481,8 +481,8 @@ bool DynamicLoaderMacOS::GetSharedCacheInformation(
info_dict->HasKey("shared_cache_base_address")) {
base_address = info_dict->GetValueForKey("shared_cache_base_address")
->GetIntegerValue(LLDB_INVALID_ADDRESS);
- std::string uuid_str =
- info_dict->GetValueForKey("shared_cache_uuid")->GetStringValue();
+ std::string uuid_str = std::string(
+ info_dict->GetValueForKey("shared_cache_uuid")->GetStringValue());
if (!uuid_str.empty())
uuid.SetFromStringRef(uuid_str);
if (!info_dict->GetValueForKey("no_shared_cache")->GetBooleanValue())
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index bc481aa..eeab419 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -207,7 +207,8 @@ public:
if (make_new_diagnostic) {
// ClangDiagnostic messages are expected to have no whitespace/newlines
// around them.
- std::string stripped_output = llvm::StringRef(m_output).trim();
+ std::string stripped_output =
+ std::string(llvm::StringRef(m_output).trim());
auto new_diagnostic = std::make_unique<ClangDiagnostic>(
stripped_output, severity, Info.getID());
@@ -255,7 +256,7 @@ static void SetupModuleHeaderPaths(CompilerInstance *compiler,
llvm::SmallString<128> module_cache;
const auto &props = ModuleList::GetGlobalModuleListProperties();
props.GetClangModulesCachePath().GetPath(module_cache);
- search_opts.ModuleCachePath = module_cache.str();
+ search_opts.ModuleCachePath = std::string(module_cache.str());
LLDB_LOG(log, "Using module cache path: {0}", module_cache.c_str());
search_opts.ResourceDir = GetClangResourceDir().GetPath();
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
index b4b4ec3..8d4da62f 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
@@ -478,7 +478,7 @@ bool ClangExpressionSourceCode::GetText(
break;
}
- text = wrap_stream.GetString();
+ text = std::string(wrap_stream.GetString());
} else {
text.append(m_body);
}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index 75f32c3..c6eb451 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -606,7 +606,7 @@ ClangModulesDeclVendor::Create(Target &target) {
const auto &props = ModuleList::GetGlobalModuleListProperties();
props.GetClangModulesCachePath().GetPath(path);
std::string module_cache_argument("-fmodules-cache-path=");
- module_cache_argument.append(path.str());
+ module_cache_argument.append(std::string(path.str()));
compiler_invocation_arguments.push_back(module_cache_argument);
}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp b/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
index 51ae7328..f1272c6 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
@@ -73,7 +73,7 @@ CppModuleConfiguration::CppModuleConfiguration(
llvm::SmallString<256> resource_dir;
llvm::sys::path::append(resource_dir, GetClangResourceDir().GetPath(),
"include");
- m_resource_inc = resource_dir.str();
+ m_resource_inc = std::string(resource_dir.str());
// This order matches the way Clang orders these directories.
m_include_dirs = {m_std_inc.Get(), m_resource_inc, m_c_inc.Get()};
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index 19df34d..0a0314d 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -823,7 +823,8 @@ bool IRForTarget::RewriteObjCSelector(Instruction *selector_load) {
if (!omvn_initializer_array->isString())
return false;
- std::string omvn_initializer_string = omvn_initializer_array->getAsString();
+ std::string omvn_initializer_string =
+ std::string(omvn_initializer_array->getAsString());
LLDB_LOG(log, "Found Objective-C selector reference \"{0}\"",
omvn_initializer_string);
@@ -981,7 +982,8 @@ bool IRForTarget::RewriteObjCClassReference(Instruction *class_load) {
if (!ocn_initializer_array->isString())
return false;
- std::string ocn_initializer_string = ocn_initializer_array->getAsString();
+ std::string ocn_initializer_string =
+ std::string(ocn_initializer_array->getAsString());
LLDB_LOG(log, "Found Objective-C class reference \"{0}\"",
ocn_initializer_string);
diff --git a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
index 178a361..6cba7ef 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
+++ b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
@@ -190,10 +190,10 @@ StructuredData::ObjectSP InstrumentationRuntimeASan::RetrieveReportData() {
std::string
InstrumentationRuntimeASan::FormatDescription(StructuredData::ObjectSP report) {
- std::string description = report->GetAsDictionary()
- ->GetValueForKey("description")
- ->GetAsString()
- ->GetValue();
+ std::string description = std::string(report->GetAsDictionary()
+ ->GetValueForKey("description")
+ ->GetAsString()
+ ->GetValue());
return llvm::StringSwitch<std::string>(description)
.Case("heap-use-after-free", "Use of deallocated memory")
.Case("heap-buffer-overflow", "Heap buffer overflow")
diff --git a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp
index 065a85b..4c2173f 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp
+++ b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp
@@ -178,10 +178,10 @@ bool InstrumentationRuntimeMainThreadChecker::NotifyBreakpointHit(
instance->RetrieveReportData(context->exe_ctx_ref);
if (report) {
- std::string description = report->GetAsDictionary()
- ->GetValueForKey("description")
- ->GetAsString()
- ->GetValue();
+ std::string description = std::string(report->GetAsDictionary()
+ ->GetValueForKey("description")
+ ->GetAsString()
+ ->GetValue());
thread_sp->SetStopInfo(
InstrumentationRuntimeStopInfo::CreateStopReasonWithInstrumentationData(
*thread_sp, description, report));
diff --git a/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
index 24f1a9a..2f93b51 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
+++ b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
@@ -487,10 +487,10 @@ StructuredData::ObjectSP InstrumentationRuntimeTSan::RetrieveReportData(
std::string
InstrumentationRuntimeTSan::FormatDescription(StructuredData::ObjectSP report) {
- std::string description = report->GetAsDictionary()
- ->GetValueForKey("issue_type")
- ->GetAsString()
- ->GetValue();
+ std::string description = std::string(report->GetAsDictionary()
+ ->GetValueForKey("issue_type")
+ ->GetAsString()
+ ->GetValue());
if (description == "data-race") {
return "Data race";
@@ -536,7 +536,7 @@ static std::string Sprintf(const char *format, ...) {
va_start(args, format);
s.PrintfVarArg(format, args);
va_end(args);
- return s.GetString();
+ return std::string(s.GetString());
}
static std::string GetSymbolNameFromAddress(ProcessSP process_sp, addr_t addr) {
@@ -612,10 +612,10 @@ std::string
InstrumentationRuntimeTSan::GenerateSummary(StructuredData::ObjectSP report) {
ProcessSP process_sp = GetProcessSP();
- std::string summary = report->GetAsDictionary()
- ->GetValueForKey("description")
- ->GetAsString()
- ->GetValue();
+ std::string summary = std::string(report->GetAsDictionary()
+ ->GetValueForKey("description")
+ ->GetAsString()
+ ->GetValue());
bool skip_one_frame =
report->GetObjectForDotSeparatedPath("issue_type")->GetStringValue() ==
"external-race";
@@ -657,10 +657,10 @@ InstrumentationRuntimeTSan::GenerateSummary(StructuredData::ObjectSP report) {
->GetValueForKey("locs")
->GetAsArray()
->GetItemAtIndex(0);
- std::string object_type = loc->GetAsDictionary()
- ->GetValueForKey("object_type")
- ->GetAsString()
- ->GetValue();
+ std::string object_type = std::string(loc->GetAsDictionary()
+ ->GetValueForKey("object_type")
+ ->GetAsString()
+ ->GetValue());
if (!object_type.empty()) {
summary = "Race on " + object_type + " object";
}
@@ -726,8 +726,8 @@ std::string InstrumentationRuntimeTSan::GetLocationDescription(
->GetValueForKey("locs")
->GetAsArray()
->GetItemAtIndex(0);
- std::string type =
- loc->GetAsDictionary()->GetValueForKey("type")->GetStringValue();
+ std::string type = std::string(
+ loc->GetAsDictionary()->GetValueForKey("type")->GetStringValue());
if (type == "global") {
global_addr = loc->GetAsDictionary()
->GetValueForKey("address")
@@ -756,10 +756,10 @@ std::string InstrumentationRuntimeTSan::GetLocationDescription(
->GetValueForKey("size")
->GetAsInteger()
->GetValue();
- std::string object_type = loc->GetAsDictionary()
- ->GetValueForKey("object_type")
- ->GetAsString()
- ->GetValue();
+ std::string object_type = std::string(loc->GetAsDictionary()
+ ->GetValueForKey("object_type")
+ ->GetAsString()
+ ->GetValue());
if (!object_type.empty()) {
result = Sprintf("Location is a %ld-byte %s object at 0x%llx", size,
object_type.c_str(), addr);
@@ -978,8 +978,8 @@ static std::string GenerateThreadName(const std::string &path,
}
if (path == "locs") {
- std::string type =
- o->GetAsDictionary()->GetValueForKey("type")->GetStringValue();
+ std::string type = std::string(
+ o->GetAsDictionary()->GetValueForKey("type")->GetStringValue());
int thread_id =
o->GetObjectForDotSeparatedPath("thread_id")->GetIntegerValue();
int fd =
diff --git a/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp b/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp
index 3c0e22e..94611e8 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp
+++ b/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp
@@ -183,7 +183,8 @@ static std::string GetStopReasonDescription(StructuredData::ObjectSP report) {
llvm::StringRef stop_reason_description_ref;
report->GetAsDictionary()->GetValueForKeyAsString(
"description", stop_reason_description_ref);
- std::string stop_reason_description = stop_reason_description_ref;
+ std::string stop_reason_description =
+ std::string(stop_reason_description_ref);
if (!stop_reason_description.size()) {
stop_reason_description = "Undefined behavior detected";
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 9267c61..b5992ba 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -230,7 +230,7 @@ std::string CPlusPlusLanguage::MethodName::GetScopeQualifiedName() {
if (!m_parsed)
Parse();
if (m_context.empty())
- return m_basename;
+ return std::string(m_basename);
std::string res;
res += m_context;
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
index 2565e01..7e72f94 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
@@ -32,7 +32,7 @@ std::string AppleObjCTypeEncodingParser::ReadStructName(StringLexer &type) {
StreamString buffer;
while (type.HasAtLeast(1) && type.Peek() != '=')
buffer.Printf("%c", type.Next());
- return buffer.GetString();
+ return std::string(buffer.GetString());
}
std::string AppleObjCTypeEncodingParser::ReadQuotedString(StringLexer &type) {
@@ -42,7 +42,7 @@ std::string AppleObjCTypeEncodingParser::ReadQuotedString(StringLexer &type) {
StringLexer::Character next = type.Next();
UNUSED_IF_ASSERT_DISABLED(next);
assert(next == '"');
- return buffer.GetString();
+ return std::string(buffer.GetString());
}
uint32_t AppleObjCTypeEncodingParser::ReadNumber(StringLexer &type) {
@@ -131,7 +131,7 @@ clang::QualType AppleObjCTypeEncodingParser::BuildAggregate(
if (element.name.empty()) {
StreamString elem_name;
elem_name.Printf("__unnamed_%u", count);
- element.name = elem_name.GetString();
+ element.name = std::string(elem_name.GetString());
}
TypeSystemClang::AddFieldToRecordType(
union_type, element.name.c_str(), ast_ctx.GetType(element.type),
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
index 03fdffb..6ed04dd 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
@@ -220,22 +220,22 @@ bool AppleThreadPlanStepThroughObjCTrampoline::WillStop() { return true; }
// since we can't just return control to the plan that's controlling us on the
// first step.
-AppleThreadPlanStepThroughDirectDispatch
- ::AppleThreadPlanStepThroughDirectDispatch(
- Thread &thread, AppleObjCTrampolineHandler &handler,
- llvm::StringRef dispatch_func_name, bool stop_others,
- LazyBool step_in_avoids_code_without_debug_info)
- : ThreadPlanStepOut(thread, nullptr, true /* first instruction */,
- stop_others,
- eVoteNoOpinion, eVoteNoOpinion,
- 0 /* Step out of zeroth frame */,
- eLazyBoolNo /* Our parent plan will decide this
- when we are done */,
- true /* Run to branch for inline step out */,
- false /* Don't gather the return value */),
- m_trampoline_handler(handler),
- m_dispatch_func_name(dispatch_func_name), m_at_msg_send(false),
- m_stop_others(stop_others) {
+AppleThreadPlanStepThroughDirectDispatch ::
+ AppleThreadPlanStepThroughDirectDispatch(
+ Thread &thread, AppleObjCTrampolineHandler &handler,
+ llvm::StringRef dispatch_func_name, bool stop_others,
+ LazyBool step_in_avoids_code_without_debug_info)
+ : ThreadPlanStepOut(thread, nullptr, true /* first instruction */,
+ stop_others, eVoteNoOpinion, eVoteNoOpinion,
+ 0 /* Step out of zeroth frame */,
+ eLazyBoolNo /* Our parent plan will decide this
+ when we are done */
+ ,
+ true /* Run to branch for inline step out */,
+ false /* Don't gather the return value */),
+ m_trampoline_handler(handler),
+ m_dispatch_func_name(std::string(dispatch_func_name)),
+ m_at_msg_send(false), m_stop_others(stop_others) {
// Set breakpoints on the dispatch functions:
auto bkpt_callback = [&] (lldb::addr_t addr,
const AppleObjCTrampolineHandler
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
index f96065d..6858c71 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
@@ -86,7 +86,7 @@ bool RenderScriptRuntimeModulePass::runOnModule(llvm::Module &module) {
llvm::StringRef real_triple =
m_process_ptr->GetTarget().GetArchitecture().GetTriple().getTriple();
const llvm::Target *target_info =
- llvm::TargetRegistry::lookupTarget(real_triple, err);
+ llvm::TargetRegistry::lookupTarget(std::string(real_triple), err);
if (!target_info) {
if (log)
log->Warning("couldn't determine real target architecture: '%s'",
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
index affceea..ad58f8c 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -1513,7 +1513,7 @@ void RenderScriptRuntime::CaptureScriptInit(RuntimeHook *hook,
script->type = ScriptDetails::eScriptC;
script->cache_dir = cache_dir;
script->res_name = res_name;
- script->shared_lib = strm.GetString();
+ script->shared_lib = std::string(strm.GetString());
script->context = addr_t(args[eRsContext]);
}
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index bb0bd04..f5bca5b 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1696,7 +1696,7 @@ class VMAddressProvider {
public:
VMAddressProvider(ObjectFile::Type Type, llvm::StringRef SegmentName)
- : ObjectType(Type), SegmentName(SegmentName) {}
+ : ObjectType(Type), SegmentName(std::string(SegmentName)) {}
std::string GetNextSegmentName() const {
return llvm::formatv("{0}[{1}]", SegmentName, SegmentCount).str();
diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index a934ac8..8f10531 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -1169,7 +1169,7 @@ void ObjectFilePECOFF::DumpOptCOFFHeader(Stream *s,
// Dump a single ELF section header to the specified output stream
void ObjectFilePECOFF::DumpSectionHeader(Stream *s,
const section_header_t &sh) {
- std::string name = GetSectionName(sh);
+ std::string name = std::string(GetSectionName(sh));
s->Printf("%-16s 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x 0x%4.4x "
"0x%4.4x 0x%8.8x\n",
name.c_str(), sh.vmaddr, sh.vmsize, sh.offset, sh.size, sh.reloff,
diff --git a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
index 442e31c..c24af00 100644
--- a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
+++ b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
@@ -337,7 +337,7 @@ OperatingSystemPython::CreateRegisterContextForThread(Thread *thread,
m_interpreter->OSPlugin_RegisterContextData(m_python_object_sp,
thread->GetID());
if (reg_context_data) {
- std::string value = reg_context_data->GetValue();
+ std::string value = std::string(reg_context_data->GetValue());
DataBufferSP data_sp(new DataBufferHeap(value.c_str(), value.length()));
if (data_sp->GetByteSize()) {
RegisterContextMemory *reg_ctx_memory = new RegisterContextMemory(
diff --git a/lldb/source/Plugins/Platform/Android/AdbClient.cpp b/lldb/source/Plugins/Platform/Android/AdbClient.cpp
index 9ef9691..81698b7 100644
--- a/lldb/source/Plugins/Platform/Android/AdbClient.cpp
+++ b/lldb/source/Plugins/Platform/Android/AdbClient.cpp
@@ -166,7 +166,7 @@ Status AdbClient::GetDevices(DeviceIDList &device_list) {
response.split(devices, "\n", -1, false);
for (const auto &device : devices)
- device_list.push_back(device.split('\t').first);
+ device_list.push_back(std::string(device.split('\t').first));
// Force disconnect since ADB closes connection after host:devices response
// is sent.
@@ -365,7 +365,7 @@ Status AdbClient::internalShell(const char *command, milliseconds timeout,
StreamString adb_command;
adb_command.Printf("shell:%s", command);
- error = SendMessage(adb_command.GetString(), false);
+ error = SendMessage(std::string(adb_command.GetString()), false);
if (error.Fail())
return error;
diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
index e68c5e8..25fbc5c 100644
--- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -170,7 +170,7 @@ Status PlatformAndroid::ConnectRemote(Args &args) {
if (!UriParser::Parse(url, scheme, host, port, path))
return Status("Invalid URL: %s", url);
if (host != "localhost")
- m_device_id = host;
+ m_device_id = std::string(host);
auto error = PlatformLinux::ConnectRemote(args);
if (error.Success()) {
diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
index 5954d33..a94ead1 100644
--- a/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
@@ -117,7 +117,7 @@ Status PlatformAndroidRemoteGDBServer::ConnectRemote(Args &args) {
if (!UriParser::Parse(url, scheme, host, remote_port, path))
return Status("Invalid URL: %s", url);
if (host != "localhost")
- m_device_id = host;
+ m_device_id = std::string(host);
m_socket_namespace.reset();
if (scheme == ConnectionFileDescriptor::UNIX_CONNECT_SCHEME)
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 16602dd..2a745f7 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1562,7 +1562,7 @@ void PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(
minimum_version_option.PutCString("-mmacosx-version-min=");
minimum_version_option.PutCString(version.getAsString());
}
- options.push_back(minimum_version_option.GetString());
+ options.push_back(std::string(minimum_version_option.GetString()));
}
FileSpec sysroot_spec;
diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index ee89aca..0185ba4 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -429,7 +429,7 @@ std::string PlatformPOSIX::GetPlatformSpecificConnectionInformation() {
if (GetLocalCacheDirectory() && *GetLocalCacheDirectory())
stream.Printf("cache dir: %s", GetLocalCacheDirectory());
if (stream.GetSize())
- return stream.GetString();
+ return std::string(stream.GetString());
else
return "";
}
@@ -679,7 +679,7 @@ PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
static const char *dlopen_wrapper_name = "__lldb_dlopen_wrapper";
Process *process = exe_ctx.GetProcessSP().get();
// Insert the dlopen shim defines into our generic expression:
- std::string expr(GetLibdlFunctionDeclarations(process));
+ std::string expr(std::string(GetLibdlFunctionDeclarations(process)));
expr.append(dlopen_wrapper_code);
Status utility_error;
DiagnosticManager diagnostics;
diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index 74e5548..8af55ab 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -298,9 +298,9 @@ Status PlatformRemoteGDBServer::ConnectRemote(Args &args) {
llvm::StringRef scheme, hostname, pathname;
if (!UriParser::Parse(url, scheme, hostname, port, pathname))
return Status("Invalid URL: %s", url);
- m_platform_scheme = scheme;
- m_platform_hostname = hostname;
- path = pathname;
+ m_platform_scheme = std::string(scheme);
+ m_platform_hostname = std::string(hostname);
+ path = std::string(pathname);
const ConnectionStatus status = m_gdb_client.Connect(url, &error);
if (status == eConnectionStatusSuccess) {
@@ -725,7 +725,8 @@ const UnixSignalsSP &PlatformRemoteGDBServer::GetRemoteUnixSignals() {
response.GetResponseType() != response.eResponse)
return m_remote_signals_sp;
- auto object_sp = StructuredData::ParseJSON(response.GetStringRef());
+ auto object_sp =
+ StructuredData::ParseJSON(std::string(response.GetStringRef()));
if (!object_sp || !object_sp->IsValid())
return m_remote_signals_sp;
@@ -772,7 +773,7 @@ const UnixSignalsSP &PlatformRemoteGDBServer::GetRemoteUnixSignals() {
std::string description{""};
object_sp = dict->GetValueForKey("description");
if (object_sp && object_sp->IsValid())
- description = object_sp->GetStringValue();
+ description = std::string(object_sp->GetStringValue());
remote_signals_sp->AddSignal(signo, name.str().c_str(), suppress, stop,
notify, description.c_str());
@@ -811,7 +812,7 @@ std::string PlatformRemoteGDBServer::MakeUrl(const char *scheme,
result.Printf(":%u", port);
if (path)
result.Write(path, strlen(path));
- return result.GetString();
+ return std::string(result.GetString());
}
lldb::ProcessSP PlatformRemoteGDBServer::ConnectProcess(
diff --git a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
index 3edef53..14eea2d 100644
--- a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
@@ -99,7 +99,7 @@ std::string NativeThreadLinux::GetName() {
auto BufferOrError = getProcFile(process.GetID(), GetID(), "comm");
if (!BufferOrError)
return "";
- return BufferOrError.get()->getBuffer().rtrim('\n');
+ return std::string(BufferOrError.get()->getBuffer().rtrim('\n'));
}
lldb::StateType NativeThreadLinux::GetState() { return m_state; }
diff --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
index 7331fc1..2d8e8ef 100644
--- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -290,7 +290,7 @@ const char *StopInfoMachException::GetDescription() {
if (m_exc_data_count > 0)
strm.PutChar(')');
- m_description = strm.GetString();
+ m_description = std::string(strm.GetString());
return m_description.c_str();
}
diff --git a/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp b/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp
index d3e0656..9016e14 100644
--- a/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp
+++ b/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp
@@ -29,7 +29,8 @@ ThreadMemory::ThreadMemory(Process &process, lldb::tid_t tid,
llvm::StringRef name, llvm::StringRef queue,
lldb::addr_t register_data_addr)
: Thread(process, tid), m_backing_thread_sp(), m_thread_info_valobj_sp(),
- m_name(name), m_queue(queue), m_register_data_addr(register_data_addr) {}
+ m_name(std::string(name)), m_queue(std::string(queue)),
+ m_register_data_addr(register_data_addr) {}
ThreadMemory::~ThreadMemory() { DestroyThread(); }
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
index 10362b6..fdaa60e 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
@@ -41,7 +41,7 @@ StateType GDBRemoteClientBase::SendContinuePacketAndWaitForResponse(
{
std::lock_guard<std::mutex> lock(m_mutex);
- m_continue_packet = payload;
+ m_continue_packet = std::string(payload);
m_should_stop = false;
}
ContinueLock cont_lock(*this);
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 6e6576e..5440367 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -125,7 +125,7 @@ GDBRemoteCommunication::SendPacketNoLock(llvm::StringRef payload) {
packet.Write(payload.data(), payload.size());
packet.PutChar('#');
packet.PutHex8(CalculcateChecksum(payload));
- std::string packet_str = packet.GetString();
+ std::string packet_str = std::string(packet.GetString());
return SendRawPacketNoLock(packet_str);
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index 939cc2b..12b05e7 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -573,7 +573,8 @@ StructuredData::ObjectSP GDBRemoteCommunicationClient::GetThreadsInfo() {
if (response.IsUnsupportedResponse()) {
m_supports_jThreadsInfo = false;
} else if (!response.Empty()) {
- object_sp = StructuredData::ParseJSON(response.GetStringRef());
+ object_sp =
+ StructuredData::ParseJSON(std::string(response.GetStringRef()));
}
}
}
@@ -685,7 +686,7 @@ GDBRemoteCommunicationClient::SendPacketsAndConcatenateResponses(
if (result != PacketResult::Success)
return result;
- const std::string &this_string = this_response.GetStringRef();
+ const std::string &this_string = std::string(this_response.GetStringRef());
// Check for m or l as first character; l seems to mean this is the last
// chunk
@@ -757,7 +758,7 @@ bool GDBRemoteCommunicationClient::GetLaunchSuccess(std::string &error_str) {
return true;
if (response.GetChar() == 'E') {
// A string the describes what failed when launching...
- error_str = response.GetStringRef().substr(1);
+ error_str = std::string(response.GetStringRef().substr(1));
} else {
error_str.assign("unknown error occurred launching process");
}
@@ -1000,7 +1001,7 @@ bool GDBRemoteCommunicationClient::GetGDBServerVersion() {
while (response.GetNameColonValue(name, value)) {
if (name.equals("name")) {
success = true;
- m_gdb_server_name = value;
+ m_gdb_server_name = std::string(value);
} else if (name.equals("version")) {
llvm::StringRef major, minor;
std::tie(major, minor) = value.split('.');
@@ -1158,7 +1159,7 @@ bool GDBRemoteCommunicationClient::GetHostInfo(bool force) {
if (!value.getAsInteger(0, sub))
++num_keys_decoded;
} else if (name.equals("arch")) {
- arch_name = value;
+ arch_name = std::string(value);
++num_keys_decoded;
} else if (name.equals("triple")) {
StringExtractor extractor(value);
@@ -1185,10 +1186,10 @@ bool GDBRemoteCommunicationClient::GetHostInfo(bool force) {
os_name = "ios";
environment = "macabi";
} else
- os_name = value;
+ os_name = std::string(value);
++num_keys_decoded;
} else if (name.equals("vendor")) {
- vendor_name = value;
+ vendor_name = std::string(value);
++num_keys_decoded;
} else if (name.equals("endian")) {
byte_order = llvm::StringSwitch<lldb::ByteOrder>(value)
@@ -1956,9 +1957,9 @@ bool GDBRemoteCommunicationClient::DecodeProcessInfoResponse(
} else if (name.equals("cpusubtype")) {
value.getAsInteger(0, sub);
} else if (name.equals("vendor")) {
- vendor = value;
+ vendor = std::string(value);
} else if (name.equals("ostype")) {
- os_type = value;
+ os_type = std::string(value);
}
}
@@ -2049,10 +2050,10 @@ bool GDBRemoteCommunicationClient::GetCurrentProcessInfo(bool allow_lazy) {
os_name = "ios";
environment = "macabi";
} else
- os_name = value;
+ os_name = std::string(value);
++num_keys_decoded;
} else if (name.equals("vendor")) {
- vendor_name = value;
+ vendor_name = std::string(value);
++num_keys_decoded;
} else if (name.equals("endian")) {
byte_order = llvm::StringSwitch<lldb::ByteOrder>(value)
@@ -2069,7 +2070,7 @@ bool GDBRemoteCommunicationClient::GetCurrentProcessInfo(bool allow_lazy) {
if (!value.getAsInteger(16, pid))
++num_keys_decoded;
} else if (name.equals("elf_abi")) {
- elf_abi = value;
+ elf_abi = std::string(value);
++num_keys_decoded;
}
}
@@ -2536,7 +2537,7 @@ size_t GDBRemoteCommunicationClient::QueryGDBServer(
return 0;
StructuredData::ObjectSP data =
- StructuredData::ParseJSON(response.GetStringRef());
+ StructuredData::ParseJSON(std::string(response.GetStringRef()));
if (!data)
return 0;
@@ -2557,7 +2558,7 @@ size_t GDBRemoteCommunicationClient::QueryGDBServer(
std::string socket_name;
if (StructuredData::ObjectSP socket_name_osp =
element->GetValueForKey(llvm::StringRef("socket_name")))
- socket_name = socket_name_osp->GetStringValue();
+ socket_name = std::string(socket_name_osp->GetStringValue());
if (port != 0 || !socket_name.empty())
connection_urls.emplace_back(port, socket_name);
@@ -3667,7 +3668,7 @@ GDBRemoteCommunicationClient::GetModulesInfo(
}
StructuredData::ObjectSP response_object_sp =
- StructuredData::ParseJSON(response.GetStringRef());
+ StructuredData::ParseJSON(std::string(response.GetStringRef()));
if (!response_object_sp)
return llvm::None;
@@ -3722,7 +3723,7 @@ bool GDBRemoteCommunicationClient::ReadExtFeature(
return false;
}
- const std::string &str = chunk.GetStringRef();
+ const std::string &str = std::string(chunk.GetStringRef());
if (str.length() == 0) {
// should have some data in chunk
err.SetErrorString("Empty response from $qXfer packet");
@@ -3936,7 +3937,7 @@ GDBRemoteCommunicationClient::GetSupportedStructuredDataPlugins() {
if (SendPacketAndWaitForResponse("qStructuredDataPlugins", response,
send_async) == PacketResult::Success) {
m_supported_async_json_packets_sp =
- StructuredData::ParseJSON(response.GetStringRef());
+ StructuredData::ParseJSON(std::string(response.GetStringRef()));
if (m_supported_async_json_packets_sp &&
!m_supported_async_json_packets_sp->GetAsArray()) {
// We were returned something other than a JSON array. This is
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
index 52bc85a..cac2674 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -1237,7 +1237,7 @@ void GDBRemoteCommunicationServerCommon::
response.PutStringAsRawHex8(proc_triple.getTriple());
response.PutChar(';');
#endif
- std::string ostype = proc_triple.getOSName();
+ std::string ostype = std::string(proc_triple.getOSName());
// Adjust so ostype reports ios for Apple/ARM and Apple/ARM64.
if (proc_triple.getVendor() == llvm::Triple::Apple) {
switch (proc_triple.getArch()) {
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
index bd9e4d1..d14b79a 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
@@ -173,7 +173,7 @@ GDBRemoteCommunicationServerPlatform::Handle_qLaunchGDBServer(
uint16_t port = UINT16_MAX;
while (packet.GetNameColonValue(name, value)) {
if (name.equals("host"))
- hostname = value;
+ hostname = std::string(value);
else if (name.equals("port"))
value.getAsInteger(0, port);
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 3624e3b..b715d5e 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -359,7 +359,8 @@ bool ProcessGDBRemote::ParsePythonTargetDefinition(
StructuredData::ObjectSP triple_value =
host_info_dict->GetValueForKey("triple");
if (auto triple_string_value = triple_value->GetAsString()) {
- std::string triple_string = triple_string_value->GetValue();
+ std::string triple_string =
+ std::string(triple_string_value->GetValue());
ArchSpec host_arch(triple_string.c_str());
if (!host_arch.IsCompatibleMatch(GetTarget().GetArchitecture())) {
GetTarget().SetArchitecture(host_arch);
@@ -1576,7 +1577,8 @@ bool ProcessGDBRemote::UpdateThreadIDList() {
for (int i = 0; i < nItems; i++) {
// Get the thread stop info
StringExtractorGDBRemote &stop_info = m_stop_packet_stack[i];
- const std::string &stop_info_str = stop_info.GetStringRef();
+ const std::string &stop_info_str =
+ std::string(stop_info.GetStringRef());
m_thread_pcs.clear();
const size_t thread_pcs_pos = stop_info_str.find(";thread-pcs:");
@@ -2040,14 +2042,14 @@ ProcessGDBRemote::SetThreadStopInfo(StructuredData::Dictionary *thread_dict) {
});
}
} else if (key == g_key_name) {
- thread_name = object->GetStringValue();
+ thread_name = std::string(object->GetStringValue());
} else if (key == g_key_qaddr) {
thread_dispatch_qaddr = object->GetIntegerValue(LLDB_INVALID_ADDRESS);
} else if (key == g_key_queue_name) {
queue_vars_valid = true;
- queue_name = object->GetStringValue();
+ queue_name = std::string(object->GetStringValue());
} else if (key == g_key_queue_kind) {
- std::string queue_kind_str = object->GetStringValue();
+ std::string queue_kind_str = std::string(object->GetStringValue());
if (queue_kind_str == "serial") {
queue_vars_valid = true;
queue_kind = eQueueKindSerial;
@@ -2071,9 +2073,9 @@ ProcessGDBRemote::SetThreadStopInfo(StructuredData::Dictionary *thread_dict) {
else
associated_with_dispatch_queue = eLazyBoolNo;
} else if (key == g_key_reason) {
- reason = object->GetStringValue();
+ reason = std::string(object->GetStringValue());
} else if (key == g_key_description) {
- description = object->GetStringValue();
+ description = std::string(object->GetStringValue());
} else if (key == g_key_registers) {
StructuredData::Dictionary *registers_dict = object->GetAsDictionary();
@@ -2084,7 +2086,8 @@ ProcessGDBRemote::SetThreadStopInfo(StructuredData::Dictionary *thread_dict) {
const uint32_t reg =
StringConvert::ToUInt32(key.GetCString(), UINT32_MAX, 10);
if (reg != UINT32_MAX)
- expedited_register_map[reg] = object->GetStringValue();
+ expedited_register_map[reg] =
+ std::string(object->GetStringValue());
return true; // Keep iterating through all array items
});
}
@@ -2227,7 +2230,7 @@ StateType ProcessGDBRemote::SetThreadStopInfo(StringExtractor &stop_packet) {
// Now convert the HEX bytes into a string value
name_extractor.GetHexByteString(thread_name);
} else if (key.compare("name") == 0) {
- thread_name = value;
+ thread_name = std::string(value);
} else if (key.compare("qaddr") == 0) {
value.getAsInteger(16, thread_dispatch_qaddr);
} else if (key.compare("dispatch_queue_t") == 0) {
@@ -2248,7 +2251,7 @@ StateType ProcessGDBRemote::SetThreadStopInfo(StringExtractor &stop_packet) {
if (!value.getAsInteger(0, queue_serial_number))
queue_vars_valid = true;
} else if (key.compare("reason") == 0) {
- reason = value;
+ reason = std::string(value);
} else if (key.compare("description") == 0) {
StringExtractor desc_extractor(value);
// Now convert the HEX bytes into a string value
@@ -2297,7 +2300,7 @@ StateType ProcessGDBRemote::SetThreadStopInfo(StringExtractor &stop_packet) {
reason = "watchpoint";
StreamString ostr;
ostr.Printf("%" PRIu64 " %" PRIu32, wp_addr, wp_index);
- description = ostr.GetString();
+ description = std::string(ostr.GetString());
} else if (key.compare("library") == 0) {
auto error = LoadModules();
if (error) {
@@ -2308,7 +2311,7 @@ StateType ProcessGDBRemote::SetThreadStopInfo(StringExtractor &stop_packet) {
} else if (key.size() == 2 && ::isxdigit(key[0]) && ::isxdigit(key[1])) {
uint32_t reg = UINT32_MAX;
if (!key.getAsInteger(16, reg))
- expedited_register_map[reg] = std::move(value);
+ expedited_register_map[reg] = std::string(std::move(value));
}
}
@@ -2585,7 +2588,7 @@ Status ProcessGDBRemote::DoDestroy() {
"to k packet: %s",
response.GetStringRef().data());
exit_string.assign("got unexpected response to k packet: ");
- exit_string.append(response.GetStringRef());
+ exit_string.append(std::string(response.GetStringRef()));
}
} else {
LLDB_LOGF(log, "ProcessGDBRemote::DoDestroy - failed to send k packet");
@@ -3648,7 +3651,7 @@ void ProcessGDBRemote::StopAsyncThread() {
bool ProcessGDBRemote::HandleNotifyPacket(StringExtractorGDBRemote &packet) {
// get the packet at a string
- const std::string &pkt = packet.GetStringRef();
+ const std::string &pkt = std::string(packet.GetStringRef());
// skip %stop:
StringExtractorGDBRemote stop_info(pkt.c_str() + 5);
@@ -4030,7 +4033,8 @@ ProcessGDBRemote::GetExtendedInfoForThread(lldb::tid_t tid) {
response.GetResponseType();
if (response_type == StringExtractorGDBRemote::eResponse) {
if (!response.Empty()) {
- object_sp = StructuredData::ParseJSON(response.GetStringRef());
+ object_sp =
+ StructuredData::ParseJSON(std::string(response.GetStringRef()));
}
}
}
@@ -4102,7 +4106,8 @@ ProcessGDBRemote::GetLoadedDynamicLibrariesInfos_sender(
response.GetResponseType();
if (response_type == StringExtractorGDBRemote::eResponse) {
if (!response.Empty()) {
- object_sp = StructuredData::ParseJSON(response.GetStringRef());
+ object_sp =
+ StructuredData::ParseJSON(std::string(response.GetStringRef()));
}
}
}
@@ -4135,7 +4140,8 @@ StructuredData::ObjectSP ProcessGDBRemote::GetSharedCacheInfo() {
response.GetResponseType();
if (response_type == StringExtractorGDBRemote::eResponse) {
if (!response.Empty()) {
- object_sp = StructuredData::ParseJSON(response.GetStringRef());
+ object_sp =
+ StructuredData::ParseJSON(std::string(response.GetStringRef()));
}
}
}
@@ -5069,7 +5075,8 @@ ParseStructuredDataPacket(llvm::StringRef packet) {
}
// This is an asynchronous JSON packet, destined for a StructuredDataPlugin.
- StructuredData::ObjectSP json_sp = StructuredData::ParseJSON(packet);
+ StructuredData::ObjectSP json_sp =
+ StructuredData::ParseJSON(std::string(packet));
if (log) {
if (json_sp) {
StreamString json_str;
@@ -5276,7 +5283,7 @@ public:
result.SetStatus(eReturnStatusSuccessFinishResult);
Stream &output_strm = result.GetOutputStream();
output_strm.Printf(" packet: %s\n", packet_cstr);
- std::string response_str = response.GetStringRef();
+ std::string response_str = std::string(response.GetStringRef());
if (strstr(packet_cstr, "qGetProfileData") != nullptr) {
response_str = process->HarmonizeThreadIdsForProfileData(response);
@@ -5329,7 +5336,7 @@ public:
[&output_strm](llvm::StringRef output) { output_strm << output; });
result.SetStatus(eReturnStatusSuccessFinishResult);
output_strm.Printf(" packet: %s\n", packet.GetData());
- const std::string &response_str = response.GetStringRef();
+ const std::string &response_str = std::string(response.GetStringRef());
if (response_str.empty())
output_strm.PutCString("response: \nerror: UNIMPLEMENTED\n");
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
index b75045b..2bab326 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
@@ -595,7 +595,7 @@ public:
// safe, returns invalid on error;
static PythonModule ImportModule(llvm::StringRef name) {
- std::string s = name;
+ std::string s = std::string(name);
auto mod = Import(s.c_str());
if (!mod) {
llvm::consumeError(mod.takeError());
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index ce4fb30..95a686d 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -853,7 +853,7 @@ static std::string GenerateUniqueName(const char *base_name_wanted,
else
sstr.Printf("%s_%p", base_name_wanted, name_token);
- return sstr.GetString();
+ return std::string(sstr.GetString());
}
bool ScriptInterpreterPythonImpl::GetEmbeddedInterpreterModuleObjects() {
@@ -3035,7 +3035,7 @@ bool ScriptInterpreterPythonImpl::GetDocumentationForItem(const char *item,
StreamString str_stream;
str_stream.Printf(
"Function %s was not found. Containing module might be missing.", item);
- dest = str_stream.GetString();
+ dest = std::string(str_stream.GetString());
return false;
}
}
diff --git a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
index a3d1144..ad75bcc 100644
--- a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
+++ b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
@@ -706,9 +706,9 @@ private:
attribute_end_pos + 1, operation_end_pos - (attribute_end_pos + 1));
// add filter spec
- auto rule_sp =
- FilterRule::CreateRule(accept, attribute_index, ConstString(operation),
- rule_text.substr(operation_end_pos + 1), error);
+ auto rule_sp = FilterRule::CreateRule(
+ accept, attribute_index, ConstString(operation),
+ std::string(rule_text.substr(operation_end_pos + 1)), error);
if (rule_sp && error.Success())
m_filter_rules.push_back(rule_sp);
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp
index 8b1a573..f25dc84 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp
@@ -154,7 +154,7 @@ CompilandIndexItem &CompileUnitIndex::GetOrCreateCompiland(uint16_t modi) {
// name until we find it, and we can cache that one since the memory is backed
// by a contiguous chunk inside the mapped PDB.
llvm::SmallString<64> main_file = GetMainSourceFile(*cci);
- std::string s = main_file.str();
+ std::string s = std::string(main_file.str());
llvm::sys::path::native(main_file);
uint32_t file_count = modules.getSourceFileCount(modi);
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
index f80d45b..d06d542 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -178,7 +178,7 @@ GetNestedTagDefinition(const NestedTypeRecord &Record,
// single component of a mangled name. So we can inject it into the parent's
// mangled name to see if it matches.
CVTagRecord child = CVTagRecord::create(cvt);
- std::string qname = parent.asTag().getUniqueName();
+ std::string qname = std::string(parent.asTag().getUniqueName());
if (qname.size() < 4 || child.asTag().getUniqueName().size() < 4)
return llvm::None;
@@ -221,7 +221,7 @@ PdbAstBuilder::CreateDeclInfoForType(const TagRecord &record, TypeIndex ti) {
StringView sv(record.UniqueName.begin(), record.UniqueName.size());
llvm::ms_demangle::TagTypeNode *ttn = demangler.parseTagUniqueName(sv);
if (demangler.Error)
- return {m_clang.GetTranslationUnitDecl(), record.UniqueName};
+ return {m_clang.GetTranslationUnitDecl(), std::string(record.UniqueName)};
llvm::ms_demangle::IdentifierNode *idn =
ttn->QualifiedName->getUnqualifiedIdentifier();
@@ -248,7 +248,7 @@ PdbAstBuilder::CreateDeclInfoForType(const TagRecord &record, TypeIndex ti) {
// a NamespaceDecl and a CXXRecordDecl, so instead we create a class at
// global scope with the fully qualified name.
if (AnyScopesHaveTemplateParams(scopes))
- return {context, record.Name};
+ return {context, std::string(record.Name)};
for (llvm::ms_demangle::Node *scope : scopes) {
auto *nii = static_cast<llvm::ms_demangle::NamedIdentifierNode *>(scope);
@@ -507,7 +507,7 @@ PdbAstBuilder::CreateDeclInfoForUndecoratedName(llvm::StringRef name) {
llvm::StringRef uname = specs.back().GetBaseName();
specs = specs.drop_back();
if (specs.empty())
- return {context, name};
+ return {context, std::string(name)};
llvm::StringRef scope_name = specs.back().GetFullName();
@@ -517,7 +517,7 @@ PdbAstBuilder::CreateDeclInfoForUndecoratedName(llvm::StringRef name) {
clang::QualType qt = GetOrCreateType(types.back());
clang::TagDecl *tag = qt->getAsTagDecl();
if (tag)
- return {clang::TagDecl::castToDeclContext(tag), uname};
+ return {clang::TagDecl::castToDeclContext(tag), std::string(uname)};
types.pop_back();
}
@@ -526,7 +526,7 @@ PdbAstBuilder::CreateDeclInfoForUndecoratedName(llvm::StringRef name) {
std::string ns_name = spec.GetBaseName().str();
context = GetOrCreateNamespaceDecl(ns_name.c_str(), *context);
}
- return {context, uname};
+ return {context, std::string(uname)};
}
clang::DeclContext *
@@ -876,7 +876,7 @@ PdbAstBuilder::GetOrCreateTypedefDecl(PdbGlobalSymId id) {
PdbTypeSymId real_type_id{udt.Type, false};
clang::QualType qt = GetOrCreateType(real_type_id);
- std::string uname = DropNameScope(udt.Name);
+ std::string uname = std::string(DropNameScope(udt.Name));
CompilerType ct = m_clang.CreateTypedefType(ToCompilerType(qt), uname.c_str(),
ToCompilerDeclContext(*scope));
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index 9ecaa04..85ce87e 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -139,7 +139,7 @@ loadMatchingPDBFile(std::string exe_path, llvm::BumpPtrAllocator &allocator) {
ec = llvm::identify_magic(pdb_file, magic);
if (ec || magic != llvm::file_magic::pdb)
return nullptr;
- std::unique_ptr<PDBFile> pdb = loadPDBFile(pdb_file, allocator);
+ std::unique_ptr<PDBFile> pdb = loadPDBFile(std::string(pdb_file), allocator);
if (!pdb)
return nullptr;
@@ -452,7 +452,7 @@ lldb::TypeSP SymbolFileNativePDB::CreateModifierType(PdbTypeSymId type_id,
std::string name;
if (mr.ModifiedType.isSimple())
- name = GetSimpleTypeName(mr.ModifiedType.getSimpleKind());
+ name = std::string(GetSimpleTypeName(mr.ModifiedType.getSimpleKind()));
else
name = computeTypeName(stream.typeCollection(), mr.ModifiedType);
Declaration decl;
@@ -532,14 +532,14 @@ static std::string GetUnqualifiedTypeName(const TagRecord &record) {
MSVCUndecoratedNameParser parser(record.Name);
llvm::ArrayRef<MSVCUndecoratedNameSpecifier> specs = parser.GetSpecifiers();
- return specs.back().GetBaseName();
+ return std::string(specs.back().GetBaseName());
}
llvm::ms_demangle::Demangler demangler;
StringView sv(record.UniqueName.begin(), record.UniqueName.size());
llvm::ms_demangle::TagTypeNode *ttn = demangler.parseTagUniqueName(sv);
if (demangler.Error)
- return record.Name;
+ return std::string(record.Name);
llvm::ms_demangle::IdentifierNode *idn =
ttn->QualifiedName->getUnqualifiedIdentifier();
diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
index 593e156..010a9ea 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -386,7 +386,8 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
return nullptr;
// Ignore unnamed-tag UDTs.
- std::string name = MSVCUndecoratedNameParser::DropScope(udt->getName());
+ std::string name =
+ std::string(MSVCUndecoratedNameParser::DropScope(udt->getName()));
if (name.empty())
return nullptr;
@@ -465,7 +466,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
assert(enum_type);
std::string name =
- MSVCUndecoratedNameParser::DropScope(enum_type->getName());
+ std::string(MSVCUndecoratedNameParser::DropScope(enum_type->getName()));
auto decl_context = GetDeclContextContainingSymbol(type);
uint64_t bytes = enum_type->getLength();
@@ -538,7 +539,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
return nullptr;
std::string name =
- MSVCUndecoratedNameParser::DropScope(type_def->getName());
+ std::string(MSVCUndecoratedNameParser::DropScope(type_def->getName()));
auto decl_ctx = GetDeclContextContainingSymbol(type);
// Check if such a typedef already exists in the current context
@@ -587,7 +588,8 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
return nullptr;
func_sig = sig.release();
// Function type is named.
- name = MSVCUndecoratedNameParser::DropScope(pdb_func->getName());
+ name = std::string(
+ MSVCUndecoratedNameParser::DropScope(pdb_func->getName()));
} else if (auto pdb_func_sig =
llvm::dyn_cast<PDBSymbolTypeFunctionSig>(&type)) {
func_sig = const_cast<PDBSymbolTypeFunctionSig *>(pdb_func_sig);
@@ -887,7 +889,8 @@ PDBASTParser::GetDeclForSymbol(const llvm::pdb::PDBSymbol &symbol) {
if (auto parent_decl = llvm::dyn_cast_or_null<clang::TagDecl>(decl_context))
m_ast.GetCompleteDecl(parent_decl);
- std::string name = MSVCUndecoratedNameParser::DropScope(data->getName());
+ std::string name =
+ std::string(MSVCUndecoratedNameParser::DropScope(data->getName()));
// Check if the current context already contains the symbol with the name.
clang::Decl *decl =
@@ -913,7 +916,8 @@ PDBASTParser::GetDeclForSymbol(const llvm::pdb::PDBSymbol &symbol) {
auto decl_context = GetDeclContextContainingSymbol(symbol);
assert(decl_context);
- std::string name = MSVCUndecoratedNameParser::DropScope(func->getName());
+ std::string name =
+ std::string(MSVCUndecoratedNameParser::DropScope(func->getName()));
Type *type = symbol_file->ResolveTypeUID(sym_id);
if (!type)
@@ -1047,7 +1051,7 @@ clang::DeclContext *PDBASTParser::GetDeclContextContainingSymbol(
// or a type. We check it to avoid fake namespaces such as `__l2':
// `N0::N1::CClass::PrivateFunc::__l2::InnerFuncStruct'
if (!has_type_or_function_parent) {
- std::string namespace_name = specs[i].GetBaseName();
+ std::string namespace_name = std::string(specs[i].GetBaseName());
const char *namespace_name_c_str =
IsAnonymousNamespaceName(namespace_name) ? nullptr
: namespace_name.data();
@@ -1119,7 +1123,8 @@ bool PDBASTParser::AddEnumValue(CompilerType enum_type,
const PDBSymbolData &enum_value) {
Declaration decl;
Variant v = enum_value.getValue();
- std::string name = MSVCUndecoratedNameParser::DropScope(enum_value.getName());
+ std::string name =
+ std::string(MSVCUndecoratedNameParser::DropScope(enum_value.getName()));
int64_t raw_value;
switch (v.Type) {
case PDB_VariantType::Int8:
@@ -1333,7 +1338,8 @@ clang::CXXMethodDecl *
PDBASTParser::AddRecordMethod(lldb_private::SymbolFile &symbol_file,
lldb_private::CompilerType &record_type,
const llvm::pdb::PDBSymbolFunc &method) const {
- std::string name = MSVCUndecoratedNameParser::DropScope(method.getName());
+ std::string name =
+ std::string(MSVCUndecoratedNameParser::DropScope(method.getName()));
Type *method_type = symbol_file.ResolveTypeUID(method.getSymIndexId());
// MSVC specific __vecDelDtor.
diff --git a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
index c2e356e..11cfb3c 100644
--- a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
+++ b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
@@ -199,9 +199,9 @@ SymbolVendorMacOSX::CreateInstance(const lldb::ModuleSP &module_sp,
DBGSourcePath;
if (plist_sp->GetAsDictionary()->HasKey("DBGVersion")) {
std::string version_string =
- plist_sp->GetAsDictionary()
- ->GetValueForKey("DBGVersion")
- ->GetStringValue("");
+ std::string(plist_sp->GetAsDictionary()
+ ->GetValueForKey("DBGVersion")
+ ->GetStringValue(""));
if (!version_string.empty() &&
isdigit(version_string[0])) {
int version_number = atoi(version_string.c_str());
@@ -228,7 +228,7 @@ SymbolVendorMacOSX::CreateInstance(const lldb::ModuleSP &module_sp,
// key is DBGBuildSourcePath
// object is DBGSourcePath
std::string DBGSourcePath =
- object->GetStringValue();
+ std::string(object->GetStringValue());
if (!new_style_source_remapping_dictionary &&
!original_DBGSourcePath_value.empty()) {
DBGSourcePath = original_DBGSourcePath_value;
diff --git a/lldb/source/Symbol/TypeList.cpp b/lldb/source/Symbol/TypeList.cpp
index 769dc51..f0506c7 100644
--- a/lldb/source/Symbol/TypeList.cpp
+++ b/lldb/source/Symbol/TypeList.cpp
@@ -107,7 +107,8 @@ void TypeList::RemoveMismatchedTypes(const char *qualified_typename,
type_basename = qualified_typename;
type_scope = "";
}
- return RemoveMismatchedTypes(type_scope, type_basename, type_class,
+ return RemoveMismatchedTypes(std::string(type_scope),
+ std::string(type_basename), type_class,
exact_match);
}
diff --git a/lldb/source/Symbol/TypeMap.cpp b/lldb/source/Symbol/TypeMap.cpp
index 73551ed..a7a29a3 100644
--- a/lldb/source/Symbol/TypeMap.cpp
+++ b/lldb/source/Symbol/TypeMap.cpp
@@ -137,7 +137,8 @@ void TypeMap::RemoveMismatchedTypes(const char *qualified_typename,
type_basename = qualified_typename;
type_scope = "";
}
- return RemoveMismatchedTypes(type_scope, type_basename, type_class,
+ return RemoveMismatchedTypes(std::string(type_scope),
+ std::string(type_basename), type_class,
exact_match);
}
diff --git a/lldb/source/Symbol/TypeSystemClang.cpp b/lldb/source/Symbol/TypeSystemClang.cpp
index 7a49fba..d1bb2fe 100644
--- a/lldb/source/Symbol/TypeSystemClang.cpp
+++ b/lldb/source/Symbol/TypeSystemClang.cpp
@@ -6074,7 +6074,7 @@ CompilerType TypeSystemClang::GetChildCompilerTypeAtIndex(
if (array) {
CompilerType element_type = GetType(array->getElementType());
if (element_type.GetCompleteType()) {
- child_name = llvm::formatv("[{0}]", idx);
+ child_name = std::string(llvm::formatv("[{0}]", idx));
if (Optional<uint64_t> size =
element_type.GetByteSize(get_exe_scope())) {
child_byte_size = *size;
diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp
index b0ac248..3fc2f89 100644
--- a/lldb/source/Symbol/Variable.cpp
+++ b/lldb/source/Symbol/Variable.cpp
@@ -684,8 +684,8 @@ static void PrivateAutoComplete(
break;
}
- std::string token(partial_path, 0, pos);
- remaining_partial_path = partial_path.substr(pos);
+ std::string token(std::string(partial_path), 0, pos);
+ remaining_partial_path = std::string(partial_path.substr(pos));
if (compiler_type.IsValid()) {
PrivateAutoCompleteMembers(frame, token, remaining_partial_path,
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index 484a586..0ad3f36 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -1400,11 +1400,11 @@ OptionGroupPlatformRSync::SetOptionValue(uint32_t option_idx,
break;
case 'R':
- m_rsync_opts.assign(option_arg);
+ m_rsync_opts.assign(std::string(option_arg));
break;
case 'P':
- m_rsync_prefix.assign(option_arg);
+ m_rsync_prefix.assign(std::string(option_arg));
break;
case 'i':
@@ -1446,7 +1446,7 @@ OptionGroupPlatformSSH::SetOptionValue(uint32_t option_idx,
break;
case 'S':
- m_ssh_opts.assign(option_arg);
+ m_ssh_opts.assign(std::string(option_arg));
break;
default:
@@ -1473,7 +1473,7 @@ lldb_private::Status OptionGroupPlatformCaching::SetOptionValue(
char short_option = (char)GetDefinitions()[option_idx].short_option;
switch (short_option) {
case 'c':
- m_cache_dir.assign(option_arg);
+ m_cache_dir.assign(std::string(option_arg));
break;
default:
diff --git a/lldb/source/Target/StackFrameRecognizer.cpp b/lldb/source/Target/StackFrameRecognizer.cpp
index fa71ef7..57d1b3d 100644
--- a/lldb/source/Target/StackFrameRecognizer.cpp
+++ b/lldb/source/Target/StackFrameRecognizer.cpp
@@ -70,8 +70,9 @@ public:
std::string symbol, bool regexp)> const &callback) {
for (auto entry : m_recognizers) {
if (entry.is_regexp) {
- callback(entry.recognizer_id, entry.recognizer->GetName(), entry.module_regexp->GetText(),
- entry.symbol_regexp->GetText(), true);
+ callback(entry.recognizer_id, entry.recognizer->GetName(),
+ std::string(entry.module_regexp->GetText()),
+ std::string(entry.symbol_regexp->GetText()), true);
} else {
callback(entry.recognizer_id, entry.recognizer->GetName(), entry.module.GetCString(),
entry.symbol.GetCString(), false);
diff --git a/lldb/source/Target/StopInfo.cpp b/lldb/source/Target/StopInfo.cpp
index 4738074..7c920ae 100644
--- a/lldb/source/Target/StopInfo.cpp
+++ b/lldb/source/Target/StopInfo.cpp
@@ -206,7 +206,7 @@ public:
strm.Printf("breakpoint ");
bp_site_sp->GetDescription(&strm, eDescriptionLevelBrief);
- m_description = strm.GetString();
+ m_description = std::string(strm.GetString());
} else {
StreamString strm;
if (m_break_id != LLDB_INVALID_BREAK_ID) {
@@ -239,7 +239,7 @@ public:
" which has been deleted - was at 0x%" PRIx64,
m_value, m_address);
- m_description = strm.GetString();
+ m_description = std::string(strm.GetString());
}
}
}
@@ -631,7 +631,7 @@ public:
if (m_description.empty()) {
StreamString strm;
strm.Printf("watchpoint %" PRIi64, m_value);
- m_description = strm.GetString();
+ m_description = std::string(strm.GetString());
}
return m_description.c_str();
}
@@ -969,7 +969,7 @@ public:
strm.Printf("signal %s", signal_name);
else
strm.Printf("signal %" PRIi64, m_value);
- m_description = strm.GetString();
+ m_description = std::string(strm.GetString());
}
}
return m_description.c_str();
@@ -1034,7 +1034,7 @@ public:
if (m_description.empty()) {
StreamString strm;
m_plan_sp->GetDescription(&strm, eDescriptionLevelBrief);
- m_description = strm.GetString();
+ m_description = std::string(strm.GetString());
}
return m_description.c_str();
}
diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp
index 82930de..331bbed 100644
--- a/lldb/source/Target/Thread.cpp
+++ b/lldb/source/Target/Thread.cpp
@@ -1773,7 +1773,7 @@ Status Thread::JumpToLine(const FileSpec &file, uint32_t line,
"first location:\n",
file.GetFilename().AsCString(), line);
DumpAddressList(sstr, candidates, target);
- *warnings = sstr.GetString();
+ *warnings = std::string(sstr.GetString());
}
if (!reg_ctx->SetPC(dest))
diff --git a/lldb/source/Utility/Args.cpp b/lldb/source/Utility/Args.cpp
index 0ee9891..443f9bf 100644
--- a/lldb/source/Utility/Args.cpp
+++ b/lldb/source/Utility/Args.cpp
@@ -635,7 +635,7 @@ void OptionsWithRaw::SetFromString(llvm::StringRef arg_string) {
// If the string doesn't start with a dash, we just have no options and just
// a raw part.
if (!arg_string.startswith("-")) {
- m_suffix = original_args;
+ m_suffix = std::string(original_args);
return;
}
@@ -655,7 +655,7 @@ void OptionsWithRaw::SetFromString(llvm::StringRef arg_string) {
// The remaining line is the raw suffix, and the line we parsed so far
// needs to be interpreted as arguments.
m_has_args = true;
- m_suffix = arg_string;
+ m_suffix = std::string(arg_string);
found_suffix = true;
// The length of the prefix after parsing.
@@ -681,6 +681,6 @@ void OptionsWithRaw::SetFromString(llvm::StringRef arg_string) {
// If we didn't find a suffix delimiter, the whole string is the raw suffix.
if (!found_suffix) {
found_suffix = true;
- m_suffix = original_args;
+ m_suffix = std::string(original_args);
}
}
diff --git a/lldb/source/Utility/Log.cpp b/lldb/source/Utility/Log.cpp
index c8f32f4..4df82f2 100644
--- a/lldb/source/Utility/Log.cpp
+++ b/lldb/source/Utility/Log.cpp
@@ -138,7 +138,7 @@ void Log::VAPrintf(const char *format, va_list args) {
Stream << Content << "\n";
- WriteMessage(FinalMessage.str());
+ WriteMessage(std::string(FinalMessage.str()));
}
// Printing of errors that are not fatal.
diff --git a/lldb/source/Utility/ProcessInfo.cpp b/lldb/source/Utility/ProcessInfo.cpp
index 0a9ae6a..c78e62c 100644
--- a/lldb/source/Utility/ProcessInfo.cpp
+++ b/lldb/source/Utility/ProcessInfo.cpp
@@ -75,7 +75,7 @@ void ProcessInfo::SetExecutableFile(const FileSpec &exe_file,
llvm::StringRef ProcessInfo::GetArg0() const { return m_arg0; }
-void ProcessInfo::SetArg0(llvm::StringRef arg) { m_arg0 = arg; }
+void ProcessInfo::SetArg0(llvm::StringRef arg) { m_arg0 = std::string(arg); }
void ProcessInfo::SetArguments(char const **argv,
bool first_arg_is_executable) {
diff --git a/lldb/source/Utility/RegisterValue.cpp b/lldb/source/Utility/RegisterValue.cpp
index 9078e2a..bb56ade 100644
--- a/lldb/source/Utility/RegisterValue.cpp
+++ b/lldb/source/Utility/RegisterValue.cpp
@@ -441,7 +441,7 @@ Status RegisterValue::SetValueFromString(const RegisterInfo *reg_info,
break;
case eEncodingIEEE754: {
- std::string value_string = value_str;
+ std::string value_string = std::string(value_str);
if (byte_size == sizeof(float)) {
if (::sscanf(value_string.c_str(), "%f", &flt_val) != 1) {
error.SetErrorStringWithFormat("'%s' is not a valid float string value",
diff --git a/lldb/source/Utility/RegularExpression.cpp b/lldb/source/Utility/RegularExpression.cpp
index ffe0550..3736a25 100644
--- a/lldb/source/Utility/RegularExpression.cpp
+++ b/lldb/source/Utility/RegularExpression.cpp
@@ -13,7 +13,7 @@
using namespace lldb_private;
RegularExpression::RegularExpression(llvm::StringRef str)
- : m_regex_text(str),
+ : m_regex_text(std::string(str)),
// m_regex does not reference str anymore after it is constructed.
m_regex(llvm::Regex(str)) {}
diff --git a/lldb/source/Utility/Status.cpp b/lldb/source/Utility/Status.cpp
index 5eabffc..c8ca485 100644
--- a/lldb/source/Utility/Status.cpp
+++ b/lldb/source/Utility/Status.cpp
@@ -241,7 +241,7 @@ void Status::SetErrorString(llvm::StringRef err_str) {
if (Success())
SetErrorToGenericError();
}
- m_string = err_str;
+ m_string = std::string(err_str);
}
/// Set the current error string to a formatted error string.
@@ -270,7 +270,7 @@ int Status::SetErrorStringWithVarArg(const char *format, va_list args) {
llvm::SmallString<1024> buf;
VASprintf(buf, format, args);
- m_string = buf.str();
+ m_string = std::string(buf.str());
return buf.size();
} else {
m_string.clear();
diff --git a/lldb/source/Utility/StringList.cpp b/lldb/source/Utility/StringList.cpp
index 9384689..809c5a0 100644
--- a/lldb/source/Utility/StringList.cpp
+++ b/lldb/source/Utility/StringList.cpp
@@ -199,7 +199,7 @@ std::string StringList::CopyList(const char *item_preamble,
strm << item_preamble;
strm << GetStringAtIndex(i);
}
- return strm.GetString();
+ return std::string(strm.GetString());
}
StringList &StringList::operator<<(const char *str) {
diff --git a/lldb/tools/lldb-server/Acceptor.cpp b/lldb/tools/lldb-server/Acceptor.cpp
index 2cfb34d..b8be9c5 100644
--- a/lldb/tools/lldb-server/Acceptor.cpp
+++ b/lldb/tools/lldb-server/Acceptor.cpp
@@ -118,7 +118,7 @@ std::unique_ptr<Acceptor> Acceptor::Create(StringRef name,
return (local_port != 0) ? llvm::to_string(local_port) : "";
};
} else {
- const std::string socket_name = name;
+ const std::string socket_name = std::string(name);
local_socket_id = [socket_name]() { return socket_name; };
}
diff --git a/lldb/tools/lldb-vscode/BreakpointBase.cpp b/lldb/tools/lldb-vscode/BreakpointBase.cpp
index af77525..5d70c81 100644
--- a/lldb/tools/lldb-vscode/BreakpointBase.cpp
+++ b/lldb/tools/lldb-vscode/BreakpointBase.cpp
@@ -12,9 +12,9 @@
using namespace lldb_vscode;
BreakpointBase::BreakpointBase(const llvm::json::Object &obj)
- : condition(GetString(obj, "condition")),
- hitCondition(GetString(obj, "hitCondition")),
- logMessage(GetString(obj, "logMessage")) {}
+ : condition(std::string(GetString(obj, "condition"))),
+ hitCondition(std::string(GetString(obj, "hitCondition"))),
+ logMessage(std::string(GetString(obj, "logMessage"))) {}
void BreakpointBase::SetCondition() { bp.SetCondition(condition.c_str()); }
diff --git a/lldb/tools/lldb-vscode/FunctionBreakpoint.cpp b/lldb/tools/lldb-vscode/FunctionBreakpoint.cpp
index 1ac2e85..2eae62c 100644
--- a/lldb/tools/lldb-vscode/FunctionBreakpoint.cpp
+++ b/lldb/tools/lldb-vscode/FunctionBreakpoint.cpp
@@ -12,7 +12,7 @@
namespace lldb_vscode {
FunctionBreakpoint::FunctionBreakpoint(const llvm::json::Object &obj)
- : BreakpointBase(obj), functionName(GetString(obj, "name")) {}
+ : BreakpointBase(obj), functionName(std::string(GetString(obj, "name"))) {}
void FunctionBreakpoint::SetBreakpoint() {
if (functionName.empty())
diff --git a/lldb/tools/lldb-vscode/lldb-vscode.cpp b/lldb/tools/lldb-vscode/lldb-vscode.cpp
index 6d638a6..8fad2a5 100644
--- a/lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ b/lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -923,7 +923,7 @@ void request_completions(const llvm::json::Object &request) {
FillResponse(request, response);
llvm::json::Object body;
auto arguments = request.getObject("arguments");
- std::string text = GetString(arguments, "text");
+ std::string text = std::string(GetString(arguments, "text"));
auto original_column = GetSigned(arguments, "column", text.size());
auto actual_column = original_column - 1;
llvm::json::Array targets;
@@ -1077,8 +1077,8 @@ void request_evaluate(const llvm::json::Object &request) {
const auto expression = GetString(arguments, "expression");
if (!expression.empty() && expression[0] == '`') {
- auto result = RunLLDBCommands(llvm::StringRef(),
- {expression.substr(1)});
+ auto result =
+ RunLLDBCommands(llvm::StringRef(), {std::string(expression.substr(1))});
EmplaceSafeString(body, "result", result);
body.try_emplace("variablesReference", (int64_t)0);
} else {
@@ -1853,10 +1853,10 @@ void request_setExceptionBreakpoints(const llvm::json::Object &request) {
for (const auto &value : *filters) {
const auto filter = GetAsString(value);
- auto exc_bp = g_vsc.GetExceptionBreakpoint(filter);
+ auto exc_bp = g_vsc.GetExceptionBreakpoint(std::string(filter));
if (exc_bp) {
exc_bp->SetBreakpoint();
- unset_filters.erase(filter);
+ unset_filters.erase(std::string(filter));
}
}
for (const auto &filter : unset_filters) {
@@ -2798,7 +2798,7 @@ int main(int argc, char *argv[]) {
const auto packet_type = GetString(object, "type");
if (packet_type == "request") {
const auto command = GetString(object, "command");
- auto handler_pos = request_handlers.find(command);
+ auto handler_pos = request_handlers.find(std::string(command));
if (handler_pos != request_handlers.end()) {
handler_pos->second(*object);
} else {
diff --git a/lldb/unittests/Host/FileSystemTest.cpp b/lldb/unittests/Host/FileSystemTest.cpp
index e628b1f..d8db2c1 100644
--- a/lldb/unittests/Host/FileSystemTest.cpp
+++ b/lldb/unittests/Host/FileSystemTest.cpp
@@ -101,8 +101,8 @@ public:
Path(_Path.str()) {
for (; I != FilesAndDirs.end(); ++I) {
if (isInPath(I->first)) {
- CurrentEntry =
- vfs::directory_entry(I->second.getName(), I->second.getType());
+ CurrentEntry = vfs::directory_entry(std::string(I->second.getName()),
+ I->second.getType());
break;
}
}
@@ -111,8 +111,8 @@ public:
++I;
for (; I != FilesAndDirs.end(); ++I) {
if (isInPath(I->first)) {
- CurrentEntry =
- vfs::directory_entry(I->second.getName(), I->second.getType());
+ CurrentEntry = vfs::directory_entry(std::string(I->second.getName()),
+ I->second.getType());
break;
}
}
@@ -129,7 +129,7 @@ public:
}
void addEntry(StringRef Path, const vfs::Status &Status) {
- FilesAndDirs[Path] = Status;
+ FilesAndDirs[std::string(Path)] = Status;
}
void addRegularFile(StringRef Path, sys::fs::perms Perms = sys::fs::all_all) {
diff --git a/lldb/unittests/Interpreter/TestCompletion.cpp b/lldb/unittests/Interpreter/TestCompletion.cpp
index 60b5f52..361b31e1 100644
--- a/lldb/unittests/Interpreter/TestCompletion.cpp
+++ b/lldb/unittests/Interpreter/TestCompletion.cpp
@@ -233,7 +233,7 @@ TEST_F(CompletionTest, DirCompletionUsername) {
Resolver.AddKnownUser("Lars", DirFooC);
Resolver.AddKnownUser("Jason", DirFoo);
Resolver.AddKnownUser("Larry", DirFooA);
- std::string sep = path::get_separator();
+ std::string sep = std::string(path::get_separator());
// Just resolving current user's home directory by itself should return the
// directory.
diff --git a/lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp b/lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
index 47628545..4928534 100644
--- a/lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
+++ b/lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
@@ -178,7 +178,7 @@ static std::set<std::string> FindAlternate(llvm::StringRef Name) {
EXPECT_EQ(Count, Results.size());
std::set<std::string> Strings;
for (ConstString Str : Results)
- Strings.insert(Str.GetStringRef());
+ Strings.insert(std::string(Str.GetStringRef()));
return Strings;
}
diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp
index 057f889..5bbcfdf 100644
--- a/lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp
+++ b/lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp
@@ -34,7 +34,7 @@ struct MockDelegate : public GDBRemoteClientBase::ContinueDelegate {
void HandleStopReply() override { ++stop_reply_called; }
void HandleAsyncStructuredDataPacket(llvm::StringRef data) override {
- structured_data_packets.push_back(data);
+ structured_data_packets.push_back(std::string(data));
}
};
diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
index b90e779..42cca09 100644
--- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
@@ -288,7 +288,7 @@ TEST_F(GDBRemoteCommunicationClientTest, TestPacketSpeedJSON) {
server_thread.join();
GTEST_LOG_(INFO) << "Formatted output: " << ss.GetData();
- auto object_sp = StructuredData::ParseJSON(ss.GetString());
+ auto object_sp = StructuredData::ParseJSON(std::string(ss.GetString()));
ASSERT_TRUE(bool(object_sp));
auto dict_sp = object_sp->GetAsDictionary();
ASSERT_TRUE(bool(dict_sp));
diff --git a/lldb/unittests/Symbol/PostfixExpressionTest.cpp b/lldb/unittests/Symbol/PostfixExpressionTest.cpp
index a9183e6..1dad83e 100644
--- a/lldb/unittests/Symbol/PostfixExpressionTest.cpp
+++ b/lldb/unittests/Symbol/PostfixExpressionTest.cpp
@@ -41,27 +41,28 @@ static std::string ToString(UnaryOpNode::OpType type) {
struct ASTPrinter : public Visitor<std::string> {
protected:
std::string Visit(BinaryOpNode &binary, Node *&) override {
- return llvm::formatv("{0}({1}, {2})", ToString(binary.GetOpType()),
- Dispatch(binary.Left()), Dispatch(binary.Right()));
+ return std::string(
+ llvm::formatv("{0}({1}, {2})", ToString(binary.GetOpType()),
+ Dispatch(binary.Left()), Dispatch(binary.Right())));
}
std::string Visit(InitialValueNode &, Node *&) override { return "InitialValue"; }
std::string Visit(IntegerNode &integer, Node *&) override {
- return llvm::formatv("int({0})", integer.GetValue());
+ return std::string(llvm::formatv("int({0})", integer.GetValue()));
}
std::string Visit(RegisterNode &reg, Node *&) override {
- return llvm::formatv("reg({0})", reg.GetRegNum());
+ return std::string(llvm::formatv("reg({0})", reg.GetRegNum()));
}
std::string Visit(SymbolNode &symbol, Node *&) override {
- return symbol.GetName();
+ return std::string(symbol.GetName());
}
std::string Visit(UnaryOpNode &unary, Node *&) override {
- return llvm::formatv("{0}({1})", ToString(unary.GetOpType()),
- Dispatch(unary.Operand()));
+ return std::string(llvm::formatv("{0}({1})", ToString(unary.GetOpType()),
+ Dispatch(unary.Operand())));
}
public:
@@ -161,7 +162,7 @@ static std::string ParseAndGenerateDWARF(llvm::StringRef expr) {
return "DWARF printing failed.";
}
- return result.GetString();
+ return std::string(result.GetString());
}
TEST(PostfixExpression, ToDWARF) {
diff --git a/lldb/unittests/TestingSupport/TestUtilities.cpp b/lldb/unittests/TestingSupport/TestUtilities.cpp
index 58c691c..d40ae9d 100644
--- a/lldb/unittests/TestingSupport/TestUtilities.cpp
+++ b/lldb/unittests/TestingSupport/TestUtilities.cpp
@@ -23,7 +23,7 @@ std::string lldb_private::GetInputFilePath(const llvm::Twine &name) {
llvm::SmallString<128> result = llvm::sys::path::parent_path(TestMainArgv0);
llvm::sys::fs::make_absolute(result);
llvm::sys::path::append(result, "Inputs", name);
- return result.str();
+ return std::string(result.str());
}
llvm::Expected<TestFile> TestFile::fromYaml(llvm::StringRef Yaml) {
diff --git a/lldb/unittests/TestingSupport/TestUtilities.h b/lldb/unittests/TestingSupport/TestUtilities.h
index 407ff4a..7d2ef26 100644
--- a/lldb/unittests/TestingSupport/TestUtilities.h
+++ b/lldb/unittests/TestingSupport/TestUtilities.h
@@ -43,7 +43,8 @@ public:
llvm::StringRef name() { return *Name; }
private:
- TestFile(llvm::StringRef Name, llvm::FileRemover &&Remover) : Name(Name) {
+ TestFile(llvm::StringRef Name, llvm::FileRemover &&Remover)
+ : Name(std::string(Name)) {
Remover.releaseFile();
}
void operator=(const TestFile &) = delete;
diff --git a/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp b/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
index 6e73d0c5..ccf4827 100644
--- a/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
+++ b/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
@@ -55,18 +55,18 @@ struct CommandOption {
Required = Option->getValue("Required");
// Add the full and short name for this option.
- FullName = Option->getValueAsString("FullName");
- ShortName = Option->getValueAsString("ShortName");
+ FullName = std::string(Option->getValueAsString("FullName"));
+ ShortName = std::string(Option->getValueAsString("ShortName"));
if (auto A = Option->getValue("ArgType"))
ArgType = A->getValue()->getAsUnquotedString();
OptionalArg = Option->getValue("OptionalArg") != nullptr;
if (Option->getValue("Validator"))
- Validator = Option->getValueAsString("Validator");
+ Validator = std::string(Option->getValueAsString("Validator"));
if (Option->getValue("ArgEnum"))
- ArgEnum = Option->getValueAsString("ArgEnum");
+ ArgEnum = std::string(Option->getValueAsString("ArgEnum"));
if (Option->getValue("Completions"))
Completions = Option->getValueAsListOfStrings("Completions");
diff --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h
index 4a5d1ae..9d6e203 100644
--- a/llvm/include/llvm/ADT/StringRef.h
+++ b/llvm/include/llvm/ADT/StringRef.h
@@ -272,9 +272,7 @@ namespace llvm {
/// @name Type Conversions
/// @{
- operator std::string() const {
- return str();
- }
+ operator std::string() const { return str(); }
#if __cplusplus > 201402L
operator std::string_view() const {
diff --git a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
index bfe4fb1..1b8832a 100644
--- a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
+++ b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
@@ -1375,7 +1375,7 @@ struct BFIDOTGraphTraitsBase : public DefaultDOTGraphTraits {
explicit BFIDOTGraphTraitsBase(bool isSimple = false)
: DefaultDOTGraphTraits(isSimple) {}
- static std::string getGraphName(const BlockFrequencyInfoT *G) {
+ static StringRef getGraphName(const BlockFrequencyInfoT *G) {
return G->getFunction()->getName();
}
diff --git a/llvm/include/llvm/Analysis/RegionInfoImpl.h b/llvm/include/llvm/Analysis/RegionInfoImpl.h
index 6b59366..539f15d 100644
--- a/llvm/include/llvm/Analysis/RegionInfoImpl.h
+++ b/llvm/include/llvm/Analysis/RegionInfoImpl.h
@@ -236,7 +236,7 @@ std::string RegionBase<Tr>::getNameStr() const {
getEntry()->printAsOperand(OS, false);
} else
- entryName = getEntry()->getName();
+ entryName = std::string(getEntry()->getName());
if (getExit()) {
if (getExit()->getName().empty()) {
@@ -244,7 +244,7 @@ std::string RegionBase<Tr>::getNameStr() const {
getExit()->printAsOperand(OS, false);
} else
- exitName = getExit()->getName();
+ exitName = std::string(getExit()->getName());
} else
exitName = "<Function Return>";
diff --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.h b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
index 19efbb7..fdcb448 100644
--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h
+++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
@@ -129,7 +129,7 @@ public:
void setAvailableWithName(LibFunc F, StringRef Name) {
if (StandardNames[F] != Name) {
setState(F, CustomName);
- CustomNames[F] = Name;
+ CustomNames[F] = std::string(Name);
assert(CustomNames.find(F) != CustomNames.end());
} else {
setState(F, StandardName);
diff --git a/llvm/include/llvm/CodeGen/CommandFlags.inc b/llvm/include/llvm/CodeGen/CommandFlags.inc
index b65f7bb..e122934 100644
--- a/llvm/include/llvm/CodeGen/CommandFlags.inc
+++ b/llvm/include/llvm/CodeGen/CommandFlags.inc
@@ -331,8 +331,7 @@ LLVM_ATTRIBUTE_UNUSED static std::string getCPUStr() {
// If user asked for the 'native' CPU, autodetect here. If autodection fails,
// this will set the CPU to an empty string which tells the target to
// pick a basic default.
- if (MCPU == "native")
- return sys::getHostCPUName();
+ if (MCPU == "native") return std::string(sys::getHostCPUName());
return MCPU;
}
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h b/llvm/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
index 7946b5b..7d9dd04 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
@@ -338,12 +338,13 @@ public:
for (auto &KV : LogicalDylibs) {
if (auto Sym = KV.second.StubsMgr->findStub(Name, ExportedSymbolsOnly))
return Sym;
- if (auto Sym = findSymbolIn(KV.first, Name, ExportedSymbolsOnly))
+ if (auto Sym =
+ findSymbolIn(KV.first, std::string(Name), ExportedSymbolsOnly))
return Sym;
else if (auto Err = Sym.takeError())
return std::move(Err);
}
- return BaseLayer.findSymbol(Name, ExportedSymbolsOnly);
+ return BaseLayer.findSymbol(std::string(Name), ExportedSymbolsOnly);
}
/// Get the address of a symbol provided by this layer, or some layer
@@ -511,11 +512,11 @@ private:
}
// Build a resolver for the globals module and add it to the base layer.
- auto LegacyLookup = [this, &LD](const std::string &Name) -> JITSymbol {
+ auto LegacyLookup = [this, &LD](StringRef Name) -> JITSymbol {
if (auto Sym = LD.StubsMgr->findStub(Name, false))
return Sym;
- if (auto Sym = LD.findSymbol(BaseLayer, Name, false))
+ if (auto Sym = LD.findSymbol(BaseLayer, std::string(Name), false))
return Sym;
else if (auto Err = Sym.takeError())
return std::move(Err);
@@ -631,7 +632,7 @@ private:
Module &SrcM = LD.getSourceModule(LMId);
// Create the module.
- std::string NewName = SrcM.getName();
+ std::string NewName(SrcM.getName());
for (auto *F : Part) {
NewName += ".";
NewName += F->getName();
@@ -688,8 +689,8 @@ private:
auto K = ES.allocateVModule();
- auto LegacyLookup = [this, &LD](const std::string &Name) -> JITSymbol {
- return LD.findSymbol(BaseLayer, Name, false);
+ auto LegacyLookup = [this, &LD](StringRef Name) -> JITSymbol {
+ return LD.findSymbol(BaseLayer, std::string(Name), false);
};
// Create memory manager and symbol resolver.
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h b/llvm/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h
index b67a9fe..84f5e03 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h
@@ -78,7 +78,7 @@ private:
// RuntimeDyld that did the lookup), so just return a nullptr here.
return nullptr;
case Emitted:
- return B.findSymbolIn(K, Name, ExportedSymbolsOnly);
+ return B.findSymbolIn(K, std::string(Name), ExportedSymbolsOnly);
}
llvm_unreachable("Invalid emit-state.");
}
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h b/llvm/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h
index 0913947..435c882 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h
@@ -170,7 +170,7 @@ protected:
if (!SymEntry->second.getFlags().isExported() && ExportedSymbolsOnly)
return nullptr;
if (!Finalized)
- return JITSymbol(getSymbolMaterializer(Name),
+ return JITSymbol(getSymbolMaterializer(std::string(Name)),
SymEntry->second.getFlags());
return JITSymbol(SymEntry->second);
}
diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h
index 31c526e..2828a7d 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -1066,7 +1066,7 @@ public:
: Tag(std::move(Tag)), Inputs(Inputs) {}
explicit OperandBundleDefT(const OperandBundleUse &OBU) {
- Tag = OBU.getTagName();
+ Tag = std::string(OBU.getTagName());
Inputs.insert(Inputs.end(), OBU.Inputs.begin(), OBU.Inputs.end());
}
diff --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h
index bdc1ea9..71e67b4 100644
--- a/llvm/include/llvm/IR/Module.h
+++ b/llvm/include/llvm/IR/Module.h
@@ -273,22 +273,22 @@ public:
/// @{
/// Set the module identifier.
- void setModuleIdentifier(StringRef ID) { ModuleID = ID; }
+ void setModuleIdentifier(StringRef ID) { ModuleID = std::string(ID); }
/// Set the module's original source file name.
- void setSourceFileName(StringRef Name) { SourceFileName = Name; }
+ void setSourceFileName(StringRef Name) { SourceFileName = std::string(Name); }
/// Set the data layout
void setDataLayout(StringRef Desc);
void setDataLayout(const DataLayout &Other);
/// Set the target triple.
- void setTargetTriple(StringRef T) { TargetTriple = T; }
+ void setTargetTriple(StringRef T) { TargetTriple = std::string(T); }
/// Set the module-scope inline assembly blocks.
/// A trailing newline is added if the input doesn't have one.
void setModuleInlineAsm(StringRef Asm) {
- GlobalScopeAsm = Asm;
+ GlobalScopeAsm = std::string(Asm);
if (!GlobalScopeAsm.empty() && GlobalScopeAsm.back() != '\n')
GlobalScopeAsm += '\n';
}
diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index 5304071..1296de7 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -1295,7 +1295,7 @@ public:
NewName += ".llvm.";
NewName += utostr((uint64_t(ModHash[0]) << 32) |
ModHash[1]); // Take the first 64 bits
- return NewName.str();
+ return std::string(NewName.str());
}
/// Helper to obtain the unpromoted name for a global value (or the original
@@ -1341,7 +1341,7 @@ public:
if (It->second.first == TypeId)
return It->second.second;
auto It = TypeIdMap.insert(
- {GlobalValue::getGUID(TypeId), {TypeId, TypeIdSummary()}});
+ {GlobalValue::getGUID(TypeId), {std::string(TypeId), TypeIdSummary()}});
return It->second.second;
}
@@ -1371,14 +1371,14 @@ public:
/// the ThinLTO backends.
TypeIdCompatibleVtableInfo &
getOrInsertTypeIdCompatibleVtableSummary(StringRef TypeId) {
- return TypeIdCompatibleVtableMap[TypeId];
+ return TypeIdCompatibleVtableMap[std::string(TypeId)];
}
/// For the given \p TypeId, this returns the TypeIdCompatibleVtableMap
/// entry if present in the summary map. This may be used when importing.
Optional<TypeIdCompatibleVtableInfo>
getTypeIdCompatibleVtableSummary(StringRef TypeId) const {
- auto I = TypeIdCompatibleVtableMap.find(TypeId);
+ auto I = TypeIdCompatibleVtableMap.find(std::string(TypeId));
if (I == TypeIdCompatibleVtableMap.end())
return None;
return I->second;
diff --git a/llvm/include/llvm/IR/ModuleSummaryIndexYAML.h b/llvm/include/llvm/IR/ModuleSummaryIndexYAML.h
index 4d4a67c..7dcb455 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndexYAML.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndexYAML.h
@@ -262,7 +262,7 @@ template <> struct CustomMappingTraits<TypeIdSummaryMapTy> {
static void inputOne(IO &io, StringRef Key, TypeIdSummaryMapTy &V) {
TypeIdSummary TId;
io.mapRequired(Key.str().c_str(), TId);
- V.insert({GlobalValue::getGUID(Key), {Key, TId}});
+ V.insert({GlobalValue::getGUID(Key), {std::string(Key), TId}});
}
static void output(IO &io, TypeIdSummaryMapTy &V) {
for (auto TidIter = V.begin(); TidIter != V.end(); TidIter++)
diff --git a/llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h b/llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
index 114ba85..5bcfaee 100644
--- a/llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
+++ b/llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
@@ -92,8 +92,8 @@ struct LTOCodeGenerator {
/// The default is CGFT_ObjectFile.
void setFileType(CodeGenFileType FT) { FileType = FT; }
- void setCpu(StringRef MCpu) { this->MCpu = MCpu; }
- void setAttr(StringRef MAttr) { this->MAttr = MAttr; }
+ void setCpu(StringRef MCpu) { this->MCpu = std::string(MCpu); }
+ void setAttr(StringRef MAttr) { this->MAttr = std::string(MAttr); }
void setOptLevel(unsigned OptLevel);
void setShouldInternalize(bool Value) { ShouldInternalize = Value; }
diff --git a/llvm/include/llvm/MC/MCAssembler.h b/llvm/include/llvm/MC/MCAssembler.h
index 8c76f30..791ebcd 100644
--- a/llvm/include/llvm/MC/MCAssembler.h
+++ b/llvm/include/llvm/MC/MCAssembler.h
@@ -440,7 +440,7 @@ public:
void addFileName(StringRef FileName) {
if (!is_contained(FileNames, FileName))
- FileNames.push_back(FileName);
+ FileNames.push_back(std::string(FileName));
}
/// Write the necessary bundle padding to \p OS.
diff --git a/llvm/include/llvm/MC/MCContext.h b/llvm/include/llvm/MC/MCContext.h
index b925f32..2f9e477 100644
--- a/llvm/include/llvm/MC/MCContext.h
+++ b/llvm/include/llvm/MC/MCContext.h
@@ -541,7 +541,7 @@ namespace llvm {
const std::string &getMainFileName() const { return MainFileName; }
/// Set the main file name and override the default.
- void setMainFileName(StringRef S) { MainFileName = S; }
+ void setMainFileName(StringRef S) { MainFileName = std::string(S); }
/// Creates an entry in the dwarf file and directory tables.
Expected<unsigned> getDwarfFile(StringRef Directory, StringRef FileName,
diff --git a/llvm/include/llvm/MC/MCDwarf.h b/llvm/include/llvm/MC/MCDwarf.h
index b8ee585..9dead61 100644
--- a/llvm/include/llvm/MC/MCDwarf.h
+++ b/llvm/include/llvm/MC/MCDwarf.h
@@ -252,8 +252,8 @@ public:
void setRootFile(StringRef Directory, StringRef FileName,
Optional<MD5::MD5Result> Checksum,
Optional<StringRef> Source) {
- CompilationDir = Directory;
- RootFile.Name = FileName;
+ CompilationDir = std::string(Directory);
+ RootFile.Name = std::string(FileName);
RootFile.DirIndex = 0;
RootFile.Checksum = Checksum;
RootFile.Source = Source;
@@ -325,8 +325,8 @@ public:
void setRootFile(StringRef Directory, StringRef FileName,
Optional<MD5::MD5Result> Checksum, Optional<StringRef> Source) {
- Header.CompilationDir = Directory;
- Header.RootFile.Name = FileName;
+ Header.CompilationDir = std::string(Directory);
+ Header.RootFile.Name = std::string(FileName);
Header.RootFile.DirIndex = 0;
Header.RootFile.Checksum = Checksum;
Header.RootFile.Source = Source;
diff --git a/llvm/include/llvm/MC/MCSymbolWasm.h b/llvm/include/llvm/MC/MCSymbolWasm.h
index ba2068a..a260d5d 100644
--- a/llvm/include/llvm/MC/MCSymbolWasm.h
+++ b/llvm/include/llvm/MC/MCSymbolWasm.h
@@ -77,7 +77,9 @@ public:
}
return "env";
}
- void setImportModule(StringRef Name) { ImportModule = Name; }
+ void setImportModule(StringRef Name) {
+ ImportModule = std::string(std::string(Name));
+ }
bool hasImportName() const { return ImportName.hasValue(); }
const StringRef getImportName() const {
@@ -86,11 +88,15 @@ public:
}
return getName();
}
- void setImportName(StringRef Name) { ImportName = Name; }
+ void setImportName(StringRef Name) {
+ ImportName = std::string(std::string(Name));
+ }
bool hasExportName() const { return ExportName.hasValue(); }
const StringRef getExportName() const { return ExportName.getValue(); }
- void setExportName(StringRef Name) { ExportName = Name; }
+ void setExportName(StringRef Name) {
+ ExportName = std::string(std::string(Name));
+ }
void setUsedInGOT() const { IsUsedInGOT = true; }
bool isUsedInGOT() const { return IsUsedInGOT; }
diff --git a/llvm/include/llvm/MC/SubtargetFeature.h b/llvm/include/llvm/MC/SubtargetFeature.h
index defbc3c64..01ea794 100644
--- a/llvm/include/llvm/MC/SubtargetFeature.h
+++ b/llvm/include/llvm/MC/SubtargetFeature.h
@@ -214,7 +214,7 @@ public:
}
/// Return string stripped of flag.
- static std::string StripFlag(StringRef Feature) {
+ static StringRef StripFlag(StringRef Feature) {
return hasFlag(Feature) ? Feature.substr(1) : Feature;
}
diff --git a/llvm/include/llvm/Object/MachO.h b/llvm/include/llvm/Object/MachO.h
index c3ecdd9..8f6e2ff 100644
--- a/llvm/include/llvm/Object/MachO.h
+++ b/llvm/include/llvm/Object/MachO.h
@@ -644,7 +644,7 @@ public:
Version = utostr(major) + "." + utostr(minor);
if (update != 0)
Version += "." + utostr(update);
- return Version.str();
+ return std::string(std::string(Version.str()));
}
private:
diff --git a/llvm/include/llvm/Object/TapiUniversal.h b/llvm/include/llvm/Object/TapiUniversal.h
index 4931183..923a9a2 100644
--- a/llvm/include/llvm/Object/TapiUniversal.h
+++ b/llvm/include/llvm/Object/TapiUniversal.h
@@ -51,7 +51,7 @@ public:
return Result.second;
}
- std::string getArchFlagName() const {
+ StringRef getArchFlagName() const {
return MachO::getArchitectureName(Parent->Architectures[Index]);
}
diff --git a/llvm/include/llvm/Option/Option.h b/llvm/include/llvm/Option/Option.h
index 33813d2..e598798 100644
--- a/llvm/include/llvm/Option/Option.h
+++ b/llvm/include/llvm/Option/Option.h
@@ -130,7 +130,7 @@ public:
/// Get the name of this option with the default prefix.
std::string getPrefixedName() const {
- std::string Ret = getPrefix();
+ std::string Ret(getPrefix());
Ret += getName();
return Ret;
}
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h
index c6b6059..78ee2cd 100644
--- a/llvm/include/llvm/ProfileData/InstrProf.h
+++ b/llvm/include/llvm/ProfileData/InstrProf.h
@@ -562,7 +562,7 @@ StringRef InstrProfSymtab::getFuncName(uint64_t FuncMD5Hash) {
finalizeSymtab();
auto Result =
std::lower_bound(MD5NameMap.begin(), MD5NameMap.end(), FuncMD5Hash,
- [](const std::pair<uint64_t, std::string> &LHS,
+ [](const std::pair<uint64_t, StringRef> &LHS,
uint64_t RHS) { return LHS.first < RHS; });
if (Result != MD5NameMap.end() && Result->first == FuncMD5Hash)
return Result->second;
diff --git a/llvm/include/llvm/Support/DebugCounter.h b/llvm/include/llvm/Support/DebugCounter.h
index e7d1fa6..2ea050f 100644
--- a/llvm/include/llvm/Support/DebugCounter.h
+++ b/llvm/include/llvm/Support/DebugCounter.h
@@ -68,7 +68,7 @@ public:
// line option parsing. The main reason to register counters is to produce a
// nice list of them on the command line, but i'm not sure this is worth it.
static unsigned registerCounter(StringRef Name, StringRef Desc) {
- return instance().addCounter(Name, Desc);
+ return instance().addCounter(std::string(Name), std::string(Desc));
}
inline static bool shouldExecute(unsigned CounterName) {
if (!isCountingEnabled())
diff --git a/llvm/include/llvm/Support/GraphWriter.h b/llvm/include/llvm/Support/GraphWriter.h
index 466a044..0179670 100644
--- a/llvm/include/llvm/Support/GraphWriter.h
+++ b/llvm/include/llvm/Support/GraphWriter.h
@@ -126,7 +126,7 @@ public:
}
void writeHeader(const std::string &Title) {
- std::string GraphName = DTraits.getGraphName(G);
+ std::string GraphName(DTraits.getGraphName(G));
if (!Title.empty())
O << "digraph \"" << DOT::EscapeString(Title) << "\" {\n";
diff --git a/llvm/include/llvm/Support/JSON.h b/llvm/include/llvm/Support/JSON.h
index 56d26d2..f0bab51 100644
--- a/llvm/include/llvm/Support/JSON.h
+++ b/llvm/include/llvm/Support/JSON.h
@@ -565,7 +565,7 @@ inline bool Object::erase(StringRef K) {
// See comments on Value.
inline bool fromJSON(const Value &E, std::string &Out) {
if (auto S = E.getAsString()) {
- Out = *S;
+ Out = std::string(*S);
return true;
}
return false;
@@ -632,7 +632,7 @@ bool fromJSON(const Value &E, std::map<std::string, T> &Out) {
if (auto *O = E.getAsObject()) {
Out.clear();
for (const auto &KV : *O)
- if (!fromJSON(KV.second, Out[llvm::StringRef(KV.first)]))
+ if (!fromJSON(KV.second, Out[std::string(llvm::StringRef(KV.first))]))
return false;
return true;
}
diff --git a/llvm/include/llvm/Support/SmallVectorMemoryBuffer.h b/llvm/include/llvm/Support/SmallVectorMemoryBuffer.h
index b63b58e..62900b7 100644
--- a/llvm/include/llvm/Support/SmallVectorMemoryBuffer.h
+++ b/llvm/include/llvm/Support/SmallVectorMemoryBuffer.h
@@ -44,7 +44,7 @@ public:
/// Construct a named SmallVectorMemoryBuffer from the given
/// SmallVector r-value and StringRef.
SmallVectorMemoryBuffer(SmallVectorImpl<char> &&SV, StringRef Name)
- : SV(std::move(SV)), BufferName(Name) {
+ : SV(std::move(SV)), BufferName(std::string(Name)) {
init(this->SV.begin(), this->SV.end(), false);
}
diff --git a/llvm/include/llvm/Support/YAMLTraits.h b/llvm/include/llvm/Support/YAMLTraits.h
index 8642069..757dc8e 100644
--- a/llvm/include/llvm/Support/YAMLTraits.h
+++ b/llvm/include/llvm/Support/YAMLTraits.h
@@ -1936,7 +1936,7 @@ template <typename T> struct StdMapStringCustomMappingTraitsImpl {
using map_type = std::map<std::string, T>;
static void inputOne(IO &io, StringRef key, map_type &v) {
- io.mapRequired(key.str().c_str(), v[key]);
+ io.mapRequired(key.str().c_str(), v[std::string(key)]);
}
static void output(IO &io, map_type &v) {
diff --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h
index a553ec9..041156e 100644
--- a/llvm/include/llvm/TableGen/Record.h
+++ b/llvm/include/llvm/TableGen/Record.h
@@ -614,7 +614,9 @@ public:
bool isConcrete() const override { return true; }
std::string getAsString() const override { return "\"" + Value.str() + "\""; }
- std::string getAsUnquotedString() const override { return Value; }
+ std::string getAsUnquotedString() const override {
+ return std::string(Value);
+ }
Init *getBit(unsigned Bit) const override {
llvm_unreachable("Illegal bit reference off string");
@@ -649,7 +651,9 @@ public:
return "[{" + Value.str() + "}]";
}
- std::string getAsUnquotedString() const override { return Value; }
+ std::string getAsUnquotedString() const override {
+ return std::string(Value);
+ }
Init *getBit(unsigned Bit) const override {
llvm_unreachable("Illegal bit reference off string");
@@ -1098,7 +1102,7 @@ public:
Init *getBit(unsigned Bit) const override;
- std::string getAsString() const override { return getName(); }
+ std::string getAsString() const override { return std::string(getName()); }
};
/// Opcode{0} - Represent access to one bit of a variable or field.
diff --git a/llvm/include/llvm/TableGen/StringToOffsetTable.h b/llvm/include/llvm/TableGen/StringToOffsetTable.h
index 76ce518..7fcf20a 100644
--- a/llvm/include/llvm/TableGen/StringToOffsetTable.h
+++ b/llvm/include/llvm/TableGen/StringToOffsetTable.h
@@ -45,7 +45,7 @@ public:
// Escape the string.
SmallString<256> Str;
raw_svector_ostream(Str).write_escaped(AggregateString);
- AggregateString = Str.str();
+ AggregateString = std::string(Str.str());
O << " \"";
unsigned CharsPrinted = 0;
diff --git a/llvm/include/llvm/TextAPI/MachO/InterfaceFile.h b/llvm/include/llvm/TextAPI/MachO/InterfaceFile.h
index bd434e0..1a9711c 100644
--- a/llvm/include/llvm/TextAPI/MachO/InterfaceFile.h
+++ b/llvm/include/llvm/TextAPI/MachO/InterfaceFile.h
@@ -158,7 +158,7 @@ public:
/// Set the path from which this file was generated (if applicable).
///
/// \param Path_ The path to the source file.
- void setPath(StringRef Path_) { Path = Path_; }
+ void setPath(StringRef Path_) { Path = std::string(Path_); }
/// Get the path from which this file was generated (if applicable).
///
@@ -217,7 +217,9 @@ public:
const_filtered_target_range targets(ArchitectureSet Archs) const;
/// Set the install name of the library.
- void setInstallName(StringRef InstallName_) { InstallName = InstallName_; }
+ void setInstallName(StringRef InstallName_) {
+ InstallName = std::string(InstallName_);
+ }
/// Get the install name of the library.
StringRef getInstallName() const { return InstallName; }
diff --git a/llvm/lib/Analysis/CallPrinter.cpp b/llvm/lib/Analysis/CallPrinter.cpp
index 7246b73..0eac5d4 100644
--- a/llvm/lib/Analysis/CallPrinter.cpp
+++ b/llvm/lib/Analysis/CallPrinter.cpp
@@ -29,7 +29,7 @@ template <> struct DOTGraphTraits<CallGraph *> : public DefaultDOTGraphTraits {
std::string getNodeLabel(CallGraphNode *Node, CallGraph *Graph) {
if (Function *Func = Node->getFunction())
- return Func->getName();
+ return std::string(Func->getName());
return "external node";
}
diff --git a/llvm/lib/Analysis/LazyCallGraph.cpp b/llvm/lib/Analysis/LazyCallGraph.cpp
index ee1e9a3..b54ef31 100644
--- a/llvm/lib/Analysis/LazyCallGraph.cpp
+++ b/llvm/lib/Analysis/LazyCallGraph.cpp
@@ -1801,11 +1801,12 @@ LazyCallGraphDOTPrinterPass::LazyCallGraphDOTPrinterPass(raw_ostream &OS)
: OS(OS) {}
static void printNodeDOT(raw_ostream &OS, LazyCallGraph::Node &N) {
- std::string Name = "\"" + DOT::EscapeString(N.getFunction().getName()) + "\"";
+ std::string Name =
+ "\"" + DOT::EscapeString(std::string(N.getFunction().getName())) + "\"";
for (LazyCallGraph::Edge &E : N.populate()) {
OS << " " << Name << " -> \""
- << DOT::EscapeString(E.getFunction().getName()) << "\"";
+ << DOT::EscapeString(std::string(E.getFunction().getName())) << "\"";
if (!E.isCall()) // It is a ref edge.
OS << " [style=dashed,label=\"ref\"]";
OS << ";\n";
diff --git a/llvm/lib/Analysis/VFABIDemangling.cpp b/llvm/lib/Analysis/VFABIDemangling.cpp
index a331b95..84cad1a 100644
--- a/llvm/lib/Analysis/VFABIDemangling.cpp
+++ b/llvm/lib/Analysis/VFABIDemangling.cpp
@@ -403,7 +403,7 @@ Optional<VFInfo> VFABI::tryDemangleForVFABI(StringRef MangledName) {
"The global predicate must be the last parameter");
const VFShape Shape({VF, IsScalable, Parameters});
- return VFInfo({Shape, ScalarName, VectorName, ISA});
+ return VFInfo({Shape, std::string(ScalarName), std::string(VectorName), ISA});
}
VFParamKind VFABI::getVFParamKindFromString(const StringRef Token) {
diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp
index a83dda1..8cee54b 100644
--- a/llvm/lib/Analysis/VectorUtils.cpp
+++ b/llvm/lib/Analysis/VectorUtils.cpp
@@ -1180,7 +1180,7 @@ void VFABI::getVectorVariantNames(
assert(CI.getModule()->getFunction(Info.getValue().VectorName) &&
"Vector function is missing.");
#endif
- VariantMappings.push_back(S);
+ VariantMappings.push_back(std::string(S));
}
}
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 4446a9f..708b02f 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -3695,7 +3695,7 @@ bool LLParser::parseOptionalComdat(StringRef GlobalName, Comdat *&C) {
} else {
if (GlobalName.empty())
return TokError("comdat cannot be unnamed");
- C = getComdat(GlobalName, KwLoc);
+ C = getComdat(std::string(GlobalName), KwLoc);
}
return false;
@@ -5546,7 +5546,7 @@ bool LLParser::PerFunctionState::resolveForwardRefBlockAddresses() {
ValID ID;
if (FunctionNumber == -1) {
ID.Kind = ValID::t_GlobalName;
- ID.StrVal = F.getName();
+ ID.StrVal = std::string(F.getName());
} else {
ID.Kind = ValID::t_GlobalID;
ID.UIntVal = FunctionNumber;
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 6baa64a..b547606 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -859,7 +859,7 @@ BitcodeReader::BitcodeReader(BitstreamCursor Stream, StringRef Strtab,
LLVMContext &Context)
: BitcodeReaderBase(std::move(Stream), Strtab), Context(Context),
ValueList(Context, Stream.SizeInBytes()) {
- this->ProducerIdentification = ProducerIdentification;
+ this->ProducerIdentification = std::string(ProducerIdentification);
}
Error BitcodeReader::materializeForwardReferencedFunctions() {
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 3f45dfe..540a623 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -1174,7 +1174,7 @@ void ModuleBitcodeWriter::writeModuleInfo() {
MaxGlobalType = std::max(MaxGlobalType, VE.getTypeID(GV.getValueType()));
if (GV.hasSection()) {
// Give section names unique ID's.
- unsigned &Entry = SectionMap[GV.getSection()];
+ unsigned &Entry = SectionMap[std::string(GV.getSection())];
if (!Entry) {
writeStringRecord(Stream, bitc::MODULE_CODE_SECTIONNAME, GV.getSection(),
0 /*TODO*/);
@@ -1186,7 +1186,7 @@ void ModuleBitcodeWriter::writeModuleInfo() {
MaxAlignment = std::max(MaxAlignment, F.getAlignment());
if (F.hasSection()) {
// Give section names unique ID's.
- unsigned &Entry = SectionMap[F.getSection()];
+ unsigned &Entry = SectionMap[std::string(F.getSection())];
if (!Entry) {
writeStringRecord(Stream, bitc::MODULE_CODE_SECTIONNAME, F.getSection(),
0 /*TODO*/);
@@ -1276,7 +1276,8 @@ void ModuleBitcodeWriter::writeModuleInfo() {
(VE.getValueID(GV.getInitializer()) + 1));
Vals.push_back(getEncodedLinkage(GV));
Vals.push_back(Log2_32(GV.getAlignment())+1);
- Vals.push_back(GV.hasSection() ? SectionMap[GV.getSection()] : 0);
+ Vals.push_back(GV.hasSection() ? SectionMap[std::string(GV.getSection())]
+ : 0);
if (GV.isThreadLocal() ||
GV.getVisibility() != GlobalValue::DefaultVisibility ||
GV.getUnnamedAddr() != GlobalValue::UnnamedAddr::None ||
@@ -1321,7 +1322,8 @@ void ModuleBitcodeWriter::writeModuleInfo() {
Vals.push_back(getEncodedLinkage(F));
Vals.push_back(VE.getAttributeListID(F.getAttributes()));
Vals.push_back(Log2_32(F.getAlignment())+1);
- Vals.push_back(F.hasSection() ? SectionMap[F.getSection()] : 0);
+ Vals.push_back(F.hasSection() ? SectionMap[std::string(F.getSection())]
+ : 0);
Vals.push_back(getEncodedVisibility(F));
Vals.push_back(F.hasGC() ? GCMap[F.getGC()] : 0);
Vals.push_back(getEncodedUnnamedAddr(F));
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index f38c3f3..6793b7a 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -3152,7 +3152,7 @@ void AsmPrinter::emitXRayTable() {
std::string GroupName;
if (F.hasComdat()) {
Flags |= ELF::SHF_GROUP;
- GroupName = F.getComdat()->getName();
+ GroupName = std::string(F.getComdat()->getName());
}
auto UniqueID = ++XRayFnUniqueID;
@@ -3232,7 +3232,7 @@ void AsmPrinter::emitPatchableFunctionEntries() {
std::string GroupName;
if (F.hasComdat()) {
Flags |= ELF::SHF_GROUP;
- GroupName = F.getComdat()->getName();
+ GroupName = std::string(F.getComdat()->getName());
}
MCSection *Section = getObjFileLowering().SectionForGlobal(&F, TM);
unsigned UniqueID =
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 62ad356e..6038677 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -119,9 +119,9 @@ public:
std::string TypeName;
if (!TI.isNoneType()) {
if (TI.isSimple())
- TypeName = TypeIndex::simpleTypeName(TI);
+ TypeName = std::string(TypeIndex::simpleTypeName(TI));
else
- TypeName = TypeTable.getTypeName(TI);
+ TypeName = std::string(TypeTable.getTypeName(TI));
}
return TypeName;
}
@@ -183,7 +183,7 @@ StringRef CodeViewDebug::getFullFilepath(const DIFile *File) {
if (Dir.startswith("/") || Filename.startswith("/")) {
if (llvm::sys::path::is_absolute(Filename, llvm::sys::path::Style::posix))
return Filename;
- Filepath = Dir;
+ Filepath = std::string(Dir);
if (Dir.back() != '/')
Filepath += '/';
Filepath += Filename;
@@ -195,7 +195,7 @@ StringRef CodeViewDebug::getFullFilepath(const DIFile *File) {
// that would increase the IR size and probably not needed for other users.
// For now, just concatenate and canonicalize the path here.
if (Filename.find(':') == 1)
- Filepath = Filename;
+ Filepath = std::string(Filename);
else
Filepath = (Dir + "\\" + Filename).str();
@@ -322,10 +322,10 @@ static std::string getQualifiedName(ArrayRef<StringRef> QualifiedNameComponents,
std::string FullyQualifiedName;
for (StringRef QualifiedNameComponent :
llvm::reverse(QualifiedNameComponents)) {
- FullyQualifiedName.append(QualifiedNameComponent);
+ FullyQualifiedName.append(std::string(QualifiedNameComponent));
FullyQualifiedName.append("::");
}
- FullyQualifiedName.append(TypeName);
+ FullyQualifiedName.append(std::string(TypeName));
return FullyQualifiedName;
}
@@ -943,7 +943,8 @@ void CodeViewDebug::switchToDebugSectionForSymbol(const MCSymbol *GVSym) {
void CodeViewDebug::emitDebugInfoForThunk(const Function *GV,
FunctionInfo &FI,
const MCSymbol *Fn) {
- std::string FuncName = GlobalValue::dropLLVMManglingEscape(GV->getName());
+ std::string FuncName =
+ std::string(GlobalValue::dropLLVMManglingEscape(GV->getName()));
const ThunkOrdinal ordinal = ThunkOrdinal::Standard; // Only supported kind.
OS.AddComment("Symbol subsection for " + Twine(FuncName));
@@ -1006,7 +1007,7 @@ void CodeViewDebug::emitDebugInfoForFunction(const Function *GV,
// If our DISubprogram name is empty, use the mangled name.
if (FuncName.empty())
- FuncName = GlobalValue::dropLLVMManglingEscape(GV->getName());
+ FuncName = std::string(GlobalValue::dropLLVMManglingEscape(GV->getName()));
// Emit FPO data, but only on 32-bit x86. No other platforms use it.
if (Triple(MMI->getModule()->getTargetTriple()).getArch() == Triple::x86)
diff --git a/llvm/lib/CodeGen/FEntryInserter.cpp b/llvm/lib/CodeGen/FEntryInserter.cpp
index 4c0f30b..c219492 100644
--- a/llvm/lib/CodeGen/FEntryInserter.cpp
+++ b/llvm/lib/CodeGen/FEntryInserter.cpp
@@ -35,8 +35,8 @@ struct FEntryInserter : public MachineFunctionPass {
}
bool FEntryInserter::runOnMachineFunction(MachineFunction &MF) {
- const std::string FEntryName =
- MF.getFunction().getFnAttribute("fentry-call").getValueAsString();
+ const std::string FEntryName = std::string(
+ MF.getFunction().getFnAttribute("fentry-call").getValueAsString());
if (FEntryName != "true")
return false;
diff --git a/llvm/lib/CodeGen/GCMetadata.cpp b/llvm/lib/CodeGen/GCMetadata.cpp
index 600d662..7c96d83 100644
--- a/llvm/lib/CodeGen/GCMetadata.cpp
+++ b/llvm/lib/CodeGen/GCMetadata.cpp
@@ -153,7 +153,7 @@ GCStrategy *GCModuleInfo::getGCStrategy(const StringRef Name) {
for (auto& Entry : GCRegistry::entries()) {
if (Name == Entry.getName()) {
std::unique_ptr<GCStrategy> S = Entry.instantiate();
- S->Name = Name;
+ S->Name = std::string(Name);
GCStrategyMap[Name] = S.get();
GCStrategyList.push_back(std::move(S));
return GCStrategyList.back().get();
diff --git a/llvm/lib/CodeGen/GlobalMerge.cpp b/llvm/lib/CodeGen/GlobalMerge.cpp
index 6e5593a..600c717 100644
--- a/llvm/lib/CodeGen/GlobalMerge.cpp
+++ b/llvm/lib/CodeGen/GlobalMerge.cpp
@@ -523,7 +523,7 @@ bool GlobalMerge::doMerge(const SmallVectorImpl<GlobalVariable *> &Globals,
const StructLayout *MergedLayout = DL.getStructLayout(MergedTy);
for (ssize_t k = i, idx = 0; k != j; k = GlobalSet.find_next(k), ++idx) {
GlobalValue::LinkageTypes Linkage = Globals[k]->getLinkage();
- std::string Name = Globals[k]->getName();
+ std::string Name(Globals[k]->getName());
GlobalValue::VisibilityTypes Visibility = Globals[k]->getVisibility();
GlobalValue::DLLStorageClassTypes DLLStorage =
Globals[k]->getDLLStorageClass();
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
index 076ca94..2a220c0 100644
--- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
@@ -2334,7 +2334,7 @@ bool MIParser::parseIntrinsicOperand(MachineOperand &Dest) {
if (Token.isNot(MIToken::NamedGlobalValue))
return error("expected syntax intrinsic(@llvm.whatever)");
- std::string Name = Token.stringValue();
+ std::string Name = std::string(Token.stringValue());
lex();
if (expectAndConsume(MIToken::rparen))
@@ -3149,7 +3149,7 @@ MCSymbol *MIParser::getOrCreateMCSymbol(StringRef Name) {
bool MIParser::parseStringConstant(std::string &Result) {
if (Token.isNot(MIToken::StringConstant))
return error("expected string constant");
- Result = Token.stringValue();
+ Result = std::string(Token.stringValue());
lex();
return false;
}
diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp
index 0f8e036..284b904 100644
--- a/llvm/lib/CodeGen/MIRPrinter.cpp
+++ b/llvm/lib/CodeGen/MIRPrinter.cpp
@@ -390,8 +390,8 @@ void MIRPrinter::convertStackObjects(yaml::MachineFunction &YMF,
yaml::MachineStackObject YamlObject;
YamlObject.ID = ID;
if (const auto *Alloca = MFI.getObjectAllocation(I))
- YamlObject.Name.Value =
- Alloca->hasName() ? Alloca->getName() : "<unnamed alloca>";
+ YamlObject.Name.Value = std::string(
+ Alloca->hasName() ? Alloca->getName() : "<unnamed alloca>");
YamlObject.Type = MFI.isSpillSlotObjectIndex(I)
? yaml::MachineStackObject::SpillSlot
: MFI.isVariableSizedObjectIndex(I)
diff --git a/llvm/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp b/llvm/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp
index d656953..dcb8e40 100644
--- a/llvm/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp
+++ b/llvm/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp
@@ -24,7 +24,7 @@ using namespace llvm;
DiagnosticInfoMIROptimization::MachineArgument::MachineArgument(
StringRef MKey, const MachineInstr &MI)
: Argument() {
- Key = MKey;
+ Key = std::string(MKey);
raw_string_ostream OS(Val);
MI.print(OS, /*IsStandalone=*/true, /*SkipOpers=*/false,
diff --git a/llvm/lib/CodeGen/MachineOutliner.cpp b/llvm/lib/CodeGen/MachineOutliner.cpp
index 3a9104b..46a6e86 100644
--- a/llvm/lib/CodeGen/MachineOutliner.cpp
+++ b/llvm/lib/CodeGen/MachineOutliner.cpp
@@ -1377,7 +1377,7 @@ void MachineOutliner::emitInstrCountChangedRemark(
if (!MF)
continue;
- std::string Fname = F.getName();
+ std::string Fname = std::string(F.getName());
unsigned FnCountAfter = MF->getInstructionCount();
unsigned FnCountBefore = 0;
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp
index 2bd48ab..aaa189e 100644
--- a/llvm/lib/CodeGen/MachineScheduler.cpp
+++ b/llvm/lib/CodeGen/MachineScheduler.cpp
@@ -3695,7 +3695,7 @@ struct DOTGraphTraits<ScheduleDAGMI*> : public DefaultDOTGraphTraits {
DOTGraphTraits(bool isSimple = false) : DefaultDOTGraphTraits(isSimple) {}
static std::string getGraphName(const ScheduleDAG *G) {
- return G->MF.getName();
+ return std::string(G->MF.getName());
}
static bool renderGraphFromBottomUp() {
diff --git a/llvm/lib/CodeGen/ScheduleDAGPrinter.cpp b/llvm/lib/CodeGen/ScheduleDAGPrinter.cpp
index 8d04711f..a113c30 100644
--- a/llvm/lib/CodeGen/ScheduleDAGPrinter.cpp
+++ b/llvm/lib/CodeGen/ScheduleDAGPrinter.cpp
@@ -28,7 +28,7 @@ namespace llvm {
DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {}
static std::string getGraphName(const ScheduleDAG *G) {
- return G->MF.getName();
+ return std::string(G->MF.getName());
}
static bool renderGraphFromBottomUp() {
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
index 6a46fb4..8736ee23 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
@@ -65,7 +65,7 @@ std::string SDNode::getOperationName(const SelectionDAG *G) const {
if (G)
if (const TargetInstrInfo *TII = G->getSubtarget().getInstrInfo())
if (getMachineOpcode() < TII->getNumOpcodes())
- return TII->getName(getMachineOpcode());
+ return std::string(TII->getName(getMachineOpcode()));
return "<<Unknown Machine Node #" + utostr(getOpcode()) + ">>";
}
if (G) {
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
index cdc09d5..038b4ac 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
@@ -70,7 +70,7 @@ namespace llvm {
}
static std::string getGraphName(const SelectionDAG *G) {
- return G->getMachineFunction().getName();
+ return std::string(G->getMachineFunction().getName());
}
static bool renderGraphFromBottomUp() {
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 3b5c917..3e9e0fc 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -888,7 +888,7 @@ void TargetLoweringObjectFileMachO::emitModuleMetadata(MCStreamer &Streamer,
for (const auto *Option : LinkerOptions->operands()) {
SmallVector<std::string, 4> StrOptions;
for (const auto &Piece : cast<MDNode>(Option)->operands())
- StrOptions.push_back(cast<MDString>(Piece)->getString());
+ StrOptions.push_back(std::string(cast<MDString>(Piece)->getString()));
Streamer.EmitLinkerOptions(StrOptions);
}
}
@@ -1453,7 +1453,7 @@ void TargetLoweringObjectFileCOFF::emitModuleMetadata(MCStreamer &Streamer,
for (const auto &Piece : cast<MDNode>(Option)->operands()) {
// Lead with a space for consistency with our dllexport implementation.
std::string Directive(" ");
- Directive.append(cast<MDString>(Piece)->getString());
+ Directive.append(std::string(cast<MDString>(Piece)->getString()));
Streamer.EmitBytes(Directive);
}
}
diff --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp b/llvm/lib/DWARFLinker/DWARFLinker.cpp
index 92e785d..0fa83b3 100644
--- a/llvm/lib/DWARFLinker/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp
@@ -185,7 +185,7 @@ static void analyzeImportedModule(
Twine("Conflicting parseable interfaces for Swift Module ") +
*Name + ": " + Entry + " and " + Path,
DIE);
- Entry = ResolvedPath.str();
+ Entry = std::string(ResolvedPath.str());
}
}
@@ -1180,7 +1180,7 @@ void DWARFLinker::DIECloner::addObjCAccelerator(CompileUnit &Unit,
std::string MethodNameNoCategory(Name.getString().data(), OpenParens + 2);
// FIXME: The missing space here may be a bug, but
// dsymutil-classic also does it this way.
- MethodNameNoCategory.append(SelectorStart);
+ MethodNameNoCategory.append(std::string(SelectorStart));
Unit.addNameAccelerator(Die, StringPool.getEntry(MethodNameNoCategory),
SkipPubSection);
}
diff --git a/llvm/lib/DebugInfo/CodeView/RecordName.cpp b/llvm/lib/DebugInfo/CodeView/RecordName.cpp
index cfaad15..47b5498 100644
--- a/llvm/lib/DebugInfo/CodeView/RecordName.cpp
+++ b/llvm/lib/DebugInfo/CodeView/RecordName.cpp
@@ -253,7 +253,7 @@ std::string llvm::codeview::computeTypeName(TypeCollection &Types,
consumeError(std::move(EC));
return "<unknown UDT>";
}
- return Computer.name();
+ return std::string(Computer.name());
}
static int getSymbolNameOffset(CVSymbol Sym) {
diff --git a/llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp b/llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp
index 1aded58..bb71c86a 100644
--- a/llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp
+++ b/llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp
@@ -99,12 +99,12 @@ static std::string getMemberAttributes(CodeViewRecordIO &IO,
MethodOptions Options) {
if (!IO.isStreaming())
return "";
- std::string AccessSpecifier =
- getEnumName(IO, uint8_t(Access), makeArrayRef(getMemberAccessNames()));
+ std::string AccessSpecifier = std::string(
+ getEnumName(IO, uint8_t(Access), makeArrayRef(getMemberAccessNames())));
std::string MemberAttrs(AccessSpecifier);
if (Kind != MethodKind::Vanilla) {
- std::string MethodKind =
- getEnumName(IO, unsigned(Kind), makeArrayRef(getMemberKindNames()));
+ std::string MethodKind = std::string(
+ getEnumName(IO, unsigned(Kind), makeArrayRef(getMemberKindNames())));
MemberAttrs += ", " + MethodKind;
}
if (Options != MethodOptions::None) {
@@ -201,8 +201,8 @@ Error TypeRecordMapping::visitTypeBegin(CVType &CVR) {
if (IO.isStreaming()) {
auto RecordKind = CVR.kind();
uint16_t RecordLen = CVR.length() - 2;
- std::string RecordKindName =
- getEnumName(IO, unsigned(RecordKind), makeArrayRef(LeafTypeNames));
+ std::string RecordKindName = std::string(
+ getEnumName(IO, unsigned(RecordKind), makeArrayRef(LeafTypeNames)));
error(IO.mapInteger(RecordLen, "Record length"));
error(IO.mapEnum(RecordKind, "Record kind: " + RecordKindName));
}
@@ -241,7 +241,7 @@ Error TypeRecordMapping::visitMemberBegin(CVMemberRecord &Record) {
MemberKind = Record.Kind;
if (IO.isStreaming()) {
- std::string MemberKindName = getLeafTypeName(Record.Kind);
+ std::string MemberKindName = std::string(getLeafTypeName(Record.Kind));
MemberKindName +=
" ( " +
(getEnumName(IO, unsigned(Record.Kind), makeArrayRef(LeafTypeNames)))
@@ -277,8 +277,8 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, ModifierRecord &Record) {
Error TypeRecordMapping::visitKnownRecord(CVType &CVR,
ProcedureRecord &Record) {
- std::string CallingConvName = getEnumName(
- IO, uint8_t(Record.CallConv), makeArrayRef(getCallingConventions()));
+ std::string CallingConvName = std::string(getEnumName(
+ IO, uint8_t(Record.CallConv), makeArrayRef(getCallingConventions())));
std::string FuncOptionNames =
getFlagNames(IO, static_cast<uint16_t>(Record.Options),
makeArrayRef(getFunctionOptionEnum()));
@@ -293,8 +293,8 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR,
Error TypeRecordMapping::visitKnownRecord(CVType &CVR,
MemberFunctionRecord &Record) {
- std::string CallingConvName = getEnumName(
- IO, uint8_t(Record.CallConv), makeArrayRef(getCallingConventions()));
+ std::string CallingConvName = std::string(getEnumName(
+ IO, uint8_t(Record.CallConv), makeArrayRef(getCallingConventions())));
std::string FuncOptionNames =
getFlagNames(IO, static_cast<uint16_t>(Record.Options),
makeArrayRef(getFunctionOptionEnum()));
@@ -337,12 +337,13 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, PointerRecord &Record) {
SmallString<128> Attr("Attrs: ");
if (IO.isStreaming()) {
- std::string PtrType = getEnumName(IO, unsigned(Record.getPointerKind()),
- makeArrayRef(getPtrKindNames()));
+ std::string PtrType =
+ std::string(getEnumName(IO, unsigned(Record.getPointerKind()),
+ makeArrayRef(getPtrKindNames())));
Attr += "[ Type: " + PtrType;
- std::string PtrMode = getEnumName(IO, unsigned(Record.getMode()),
- makeArrayRef(getPtrModeNames()));
+ std::string PtrMode = std::string(getEnumName(
+ IO, unsigned(Record.getMode()), makeArrayRef(getPtrModeNames())));
Attr += ", Mode: " + PtrMode;
auto PtrSizeOf = Record.getSize();
@@ -374,8 +375,8 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, PointerRecord &Record) {
MemberPointerInfo &M = *Record.MemberInfo;
error(IO.mapInteger(M.ContainingType, "ClassType"));
- std::string PtrMemberGetRepresentation = getEnumName(
- IO, uint16_t(M.Representation), makeArrayRef(getPtrMemberRepNames()));
+ std::string PtrMemberGetRepresentation = std::string(getEnumName(
+ IO, uint16_t(M.Representation), makeArrayRef(getPtrMemberRepNames())));
error(IO.mapEnum(M.Representation,
"Representation: " + PtrMemberGetRepresentation));
}
@@ -581,8 +582,8 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR,
}
Error TypeRecordMapping::visitKnownRecord(CVType &CVR, LabelRecord &Record) {
- std::string ModeName =
- getEnumName(IO, uint16_t(Record.Mode), makeArrayRef(getLabelTypeEnum()));
+ std::string ModeName = std::string(
+ getEnumName(IO, uint16_t(Record.Mode), makeArrayRef(getLabelTypeEnum())));
error(IO.mapEnum(Record.Mode, "Mode: " + ModeName));
return Error::success();
}
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
index afd5190..a5f257f 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
@@ -871,13 +871,14 @@ void DWARFDebugNames::ValueIterator::next() {
DWARFDebugNames::ValueIterator::ValueIterator(const DWARFDebugNames &AccelTable,
StringRef Key)
- : CurrentIndex(AccelTable.NameIndices.begin()), IsLocal(false), Key(Key) {
+ : CurrentIndex(AccelTable.NameIndices.begin()), IsLocal(false),
+ Key(std::string(Key)) {
searchFromStartOfCurrentIndex();
}
DWARFDebugNames::ValueIterator::ValueIterator(
const DWARFDebugNames::NameIndex &NI, StringRef Key)
- : CurrentIndex(&NI), IsLocal(true), Key(Key) {
+ : CurrentIndex(&NI), IsLocal(true), Key(std::string(Key)) {
if (!findInCurrentIndex())
setEnd();
}
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
index b97753e..84803c8 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -1063,7 +1063,7 @@ bool DWARFDebugLine::Prologue::getFileNameByIndex(
StringRef FileName = *Name;
if (Kind != FileLineInfoKind::AbsoluteFilePath ||
isPathAbsoluteOnWindowsOrPosix(FileName)) {
- Result = FileName;
+ Result = std::string(FileName);
return true;
}
@@ -1087,7 +1087,7 @@ bool DWARFDebugLine::Prologue::getFileNameByIndex(
// sys::path::append skips empty strings.
sys::path::append(FilePath, Style, IncludeDir, FileName);
- Result = FilePath.str();
+ Result = std::string(FilePath.str());
return true;
}
diff --git a/llvm/lib/DebugInfo/GSYM/LookupResult.cpp b/llvm/lib/DebugInfo/GSYM/LookupResult.cpp
index c54b166..0d9ad8b 100644
--- a/llvm/lib/DebugInfo/GSYM/LookupResult.cpp
+++ b/llvm/lib/DebugInfo/GSYM/LookupResult.cpp
@@ -21,7 +21,7 @@ std::string LookupResult::getSourceFile(uint32_t Index) const {
if (Index < Locations.size()) {
if (!Locations[Index].Dir.empty()) {
if (Locations[Index].Base.empty()) {
- Fullpath = Locations[Index].Dir;
+ Fullpath = std::string(Locations[Index].Dir);
} else {
llvm::SmallString<64> Storage;
llvm::sys::path::append(Storage, Locations[Index].Dir,
@@ -29,7 +29,7 @@ std::string LookupResult::getSourceFile(uint32_t Index) const {
Fullpath.assign(Storage.begin(), Storage.end());
}
} else if (!Locations[Index].Base.empty())
- Fullpath = Locations[Index].Base;
+ Fullpath = std::string(Locations[Index].Base);
}
return Fullpath;
}
diff --git a/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp
index 4197347..06bbbde 100644
--- a/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp
@@ -39,7 +39,7 @@ static uint32_t calculateDiSymbolStreamSize(uint32_t SymbolByteSize,
DbiModuleDescriptorBuilder::DbiModuleDescriptorBuilder(StringRef ModuleName,
uint32_t ModIndex,
msf::MSFBuilder &Msf)
- : MSF(Msf), ModuleName(ModuleName) {
+ : MSF(Msf), ModuleName(std::string(ModuleName)) {
::memset(&Layout, 0, sizeof(Layout));
Layout.Mod = ModIndex;
}
@@ -51,7 +51,7 @@ uint16_t DbiModuleDescriptorBuilder::getStreamIndex() const {
}
void DbiModuleDescriptorBuilder::setObjFileName(StringRef Name) {
- ObjFileName = Name;
+ ObjFileName = std::string(Name);
}
void DbiModuleDescriptorBuilder::setPdbFilePathNI(uint32_t NI) {
@@ -83,7 +83,7 @@ void DbiModuleDescriptorBuilder::addSymbolsInBulk(
}
void DbiModuleDescriptorBuilder::addSourceFile(StringRef Path) {
- SourceFiles.push_back(Path);
+ SourceFiles.push_back(std::string(Path));
}
uint32_t DbiModuleDescriptorBuilder::calculateC13DebugInfoSize() const {
diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp
index 39ae84a..7717f06 100644
--- a/llvm/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp
@@ -49,11 +49,11 @@ SymIndexId NativeCompilandSymbol::getLexicalParentId() const { return 0; }
// this potential confusion.
std::string NativeCompilandSymbol::getLibraryName() const {
- return Module.getObjFileName();
+ return std::string(Module.getObjFileName());
}
std::string NativeCompilandSymbol::getName() const {
- return Module.getModuleName();
+ return std::string(Module.getModuleName());
}
} // namespace pdb
diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp
index 2f6a5bc..7a258ac 100644
--- a/llvm/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp
@@ -48,19 +48,19 @@ public:
std::string getFileName() const override {
StringRef Ret = cantFail(Strings.getStringForID(Entry.FileNI),
"InjectedSourceStream should have rejected this");
- return Ret;
+ return std::string(Ret);
}
std::string getObjectFileName() const override {
StringRef Ret = cantFail(Strings.getStringForID(Entry.ObjNI),
"InjectedSourceStream should have rejected this");
- return Ret;
+ return std::string(Ret);
}
std::string getVirtualFileName() const override {
StringRef Ret = cantFail(Strings.getStringForID(Entry.VFileNI),
"InjectedSourceStream should have rejected this");
- return Ret;
+ return std::string(Ret);
}
uint32_t getCompression() const override { return Entry.Compression; }
diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp
index 3f39340..895f894 100644
--- a/llvm/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp
@@ -73,7 +73,7 @@ uint32_t NativeExeSymbol::getAge() const {
}
std::string NativeExeSymbol::getSymbolsFileName() const {
- return Session.getPDBFile().getFilePath();
+ return std::string(Session.getPDBFile().getFilePath());
}
codeview::GUID NativeExeSymbol::getGuid() const {
diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeSymbolEnumerator.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeSymbolEnumerator.cpp
index 704c125..e5f1dca 100644
--- a/llvm/lib/DebugInfo/PDB/Native/NativeSymbolEnumerator.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/NativeSymbolEnumerator.cpp
@@ -51,7 +51,9 @@ SymIndexId NativeSymbolEnumerator::getClassParentId() const {
SymIndexId NativeSymbolEnumerator::getLexicalParentId() const { return 0; }
-std::string NativeSymbolEnumerator::getName() const { return Record.Name; }
+std::string NativeSymbolEnumerator::getName() const {
+ return std::string(Record.Name);
+}
SymIndexId NativeSymbolEnumerator::getTypeId() const {
return Parent.getTypeId();
diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp
index 26ccb7d..aaec3a5 100644
--- a/llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp
@@ -305,7 +305,7 @@ std::string NativeTypeEnum::getName() const {
if (UnmodifiedType)
return UnmodifiedType->getName();
- return Record->getName();
+ return std::string(Record->getName());
}
bool NativeTypeEnum::isNested() const {
diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeTypeTypedef.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeTypeTypedef.cpp
index 60b3732..72964a9 100644
--- a/llvm/lib/DebugInfo/PDB/Native/NativeTypeTypedef.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/NativeTypeTypedef.cpp
@@ -20,7 +20,9 @@ void NativeTypeTypedef::dump(raw_ostream &OS, int Indent,
PdbSymbolIdField::Type, ShowIdFields, RecurseIdFields);
}
-std::string NativeTypeTypedef::getName() const { return Record.Name; }
+std::string NativeTypeTypedef::getName() const {
+ return std::string(Record.Name);
+}
SymIndexId NativeTypeTypedef::getTypeId() const {
return Session.getSymbolCache().findSymbolByTypeIndex(Record.Type);
diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp
index be67846..b0be7f7 100644
--- a/llvm/lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp
@@ -74,7 +74,7 @@ std::string NativeTypeUDT::getName() const {
if (UnmodifiedType)
return UnmodifiedType->getName();
- return Tag->getName();
+ return std::string(Tag->getName());
}
SymIndexId NativeTypeUDT::getLexicalParentId() const { return 0; }
diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp
index 9ac226b..cde6452 100644
--- a/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp
@@ -41,7 +41,8 @@ typedef FixedStreamArray<support::ulittle32_t> ulittle_array;
PDBFile::PDBFile(StringRef Path, std::unique_ptr<BinaryStream> PdbFileBuffer,
BumpPtrAllocator &Allocator)
- : FilePath(Path), Allocator(Allocator), Buffer(std::move(PdbFileBuffer)) {}
+ : FilePath(std::string(Path)), Allocator(Allocator),
+ Buffer(std::move(PdbFileBuffer)) {}
PDBFile::~PDBFile() = default;
diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
index aa32887..d6f7e28 100644
--- a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
@@ -95,7 +95,7 @@ Error PDBFileBuilder::addNamedStream(StringRef Name, StringRef Data) {
if (!ExpectedIndex)
return ExpectedIndex.takeError();
assert(NamedStreamData.count(*ExpectedIndex) == 0);
- NamedStreamData[*ExpectedIndex] = Data;
+ NamedStreamData[*ExpectedIndex] = std::string(Data);
return Error::success();
}
diff --git a/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp b/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
index 2f3a250..c5b71ba 100644
--- a/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
@@ -74,7 +74,7 @@ void DIPrinter::print(const DILineInfo &Info, bool Inlined) {
if (Filename == DILineInfo::BadString)
Filename = DILineInfo::Addr2LineBadString;
else if (Basenames)
- Filename = llvm::sys::path::filename(Filename);
+ Filename = std::string(llvm::sys::path::filename(Filename));
if (!Verbose) {
OS << Filename << ":" << Info.Line;
if (Style == OutputStyle::LLVM)
diff --git a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
index ebb4a0c..ed6f908 100644
--- a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
@@ -62,7 +62,7 @@ Expected<DILineInfo>
LLVMSymbolizer::symbolizeCode(const ObjectFile &Obj,
object::SectionedAddress ModuleOffset) {
StringRef ModuleName = Obj.getFileName();
- auto I = Modules.find(ModuleName);
+ auto I = Modules.find(std::string(ModuleName));
if (I != Modules.end())
return symbolizeCodeCommon(I->second.get(), ModuleOffset);
@@ -184,7 +184,7 @@ std::string getDarwinDWARFResourceForPath(
}
sys::path::append(ResourceName, "Contents", "Resources", "DWARF");
sys::path::append(ResourceName, Basename);
- return ResourceName.str();
+ return std::string(ResourceName.str());
}
bool checkFileCRC(StringRef Path, uint32_t CRCHash) {
@@ -205,14 +205,14 @@ bool findDebugBinary(const std::string &OrigPath,
// Try relative/path/to/original_binary/debuglink_name
llvm::sys::path::append(DebugPath, DebuglinkName);
if (checkFileCRC(DebugPath, CRCHash)) {
- Result = DebugPath.str();
+ Result = std::string(DebugPath.str());
return true;
}
// Try relative/path/to/original_binary/.debug/debuglink_name
DebugPath = OrigDir;
llvm::sys::path::append(DebugPath, ".debug", DebuglinkName);
if (checkFileCRC(DebugPath, CRCHash)) {
- Result = DebugPath.str();
+ Result = std::string(DebugPath.str());
return true;
}
// Make the path absolute so that lookups will go to
@@ -234,7 +234,7 @@ bool findDebugBinary(const std::string &OrigPath,
llvm::sys::path::append(DebugPath, llvm::sys::path::relative_path(OrigDir),
DebuglinkName);
if (checkFileCRC(DebugPath, CRCHash)) {
- Result = DebugPath.str();
+ Result = std::string(DebugPath.str());
return true;
}
return false;
@@ -342,7 +342,7 @@ bool findDebugBinary(const std::vector<std::string> &DebugFileDirectory,
#endif
);
if (llvm::sys::fs::exists(Path)) {
- Result = Path.str();
+ Result = std::string(Path.str());
return true;
}
} else {
@@ -350,7 +350,7 @@ bool findDebugBinary(const std::vector<std::string> &DebugFileDirectory,
// Try <debug-file-directory>/.build-id/../...
SmallString<128> Path = getDebugPath(Directory);
if (llvm::sys::fs::exists(Path)) {
- Result = Path.str();
+ Result = std::string(Path.str());
return true;
}
}
@@ -366,9 +366,11 @@ ObjectFile *LLVMSymbolizer::lookUpDsymFile(const std::string &ExePath,
// resource directory.
std::vector<std::string> DsymPaths;
StringRef Filename = sys::path::filename(ExePath);
- DsymPaths.push_back(getDarwinDWARFResourceForPath(ExePath, Filename));
+ DsymPaths.push_back(
+ getDarwinDWARFResourceForPath(ExePath, std::string(Filename)));
for (const auto &Path : Opts.DsymHints) {
- DsymPaths.push_back(getDarwinDWARFResourceForPath(Path, Filename));
+ DsymPaths.push_back(
+ getDarwinDWARFResourceForPath(Path, std::string(Filename)));
}
for (const auto &Path : DsymPaths) {
auto DbgObjOrErr = getOrCreateObject(Path, ArchName);
diff --git a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
index ee7a7cb..77f9d70 100644
--- a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -200,7 +200,7 @@ std::string ExecutionEngine::getMangledName(const GlobalValue *GV) {
: GV->getParent()->getDataLayout();
Mangler::getNameWithPrefix(FullName, GV->getName(), DL);
- return FullName.str();
+ return std::string(FullName.str());
}
void ExecutionEngine::addGlobalMapping(const GlobalValue *GV, void *Addr) {
@@ -223,7 +223,7 @@ void ExecutionEngine::addGlobalMapping(StringRef Name, uint64_t Addr) {
std::string &V = EEState.getGlobalAddressReverseMap()[CurVal];
assert((!V.empty() || !Name.empty()) &&
"GlobalMapping already established!");
- V = Name;
+ V = std::string(Name);
}
}
@@ -269,7 +269,7 @@ uint64_t ExecutionEngine::updateGlobalMapping(StringRef Name, uint64_t Addr) {
std::string &V = EEState.getGlobalAddressReverseMap()[CurVal];
assert((!V.empty() || !Name.empty()) &&
"GlobalMapping already established!");
- V = Name;
+ V = std::string(Name);
}
return OldVal;
}
@@ -1200,8 +1200,8 @@ void ExecutionEngine::emitGlobals() {
GV.hasAppendingLinkage() || !GV.hasName())
continue;// Ignore external globals and globals with internal linkage.
- const GlobalValue *&GVEntry =
- LinkedGlobalsMap[std::make_pair(GV.getName(), GV.getType())];
+ const GlobalValue *&GVEntry = LinkedGlobalsMap[std::make_pair(
+ std::string(GV.getName()), GV.getType())];
// If this is the first time we've seen this global, it is the canonical
// version.
@@ -1228,8 +1228,8 @@ void ExecutionEngine::emitGlobals() {
for (const auto &GV : M.globals()) {
// In the multi-module case, see what this global maps to.
if (!LinkedGlobalsMap.empty()) {
- if (const GlobalValue *GVEntry =
- LinkedGlobalsMap[std::make_pair(GV.getName(), GV.getType())]) {
+ if (const GlobalValue *GVEntry = LinkedGlobalsMap[std::make_pair(
+ std::string(GV.getName()), GV.getType())]) {
// If something else is the canonical global, ignore this one.
if (GVEntry != &GV) {
NonCanonicalGlobals.push_back(&GV);
@@ -1243,8 +1243,8 @@ void ExecutionEngine::emitGlobals() {
} else {
// External variable reference. Try to use the dynamic loader to
// get a pointer to it.
- if (void *SymAddr =
- sys::DynamicLibrary::SearchForAddressOfSymbol(GV.getName()))
+ if (void *SymAddr = sys::DynamicLibrary::SearchForAddressOfSymbol(
+ std::string(GV.getName())))
addGlobalMapping(&GV, SymAddr);
else {
report_fatal_error("Could not resolve external global address: "
@@ -1258,8 +1258,8 @@ void ExecutionEngine::emitGlobals() {
if (!NonCanonicalGlobals.empty()) {
for (unsigned i = 0, e = NonCanonicalGlobals.size(); i != e; ++i) {
const GlobalValue *GV = NonCanonicalGlobals[i];
- const GlobalValue *CGV =
- LinkedGlobalsMap[std::make_pair(GV->getName(), GV->getType())];
+ const GlobalValue *CGV = LinkedGlobalsMap[std::make_pair(
+ std::string(GV->getName()), GV->getType())];
void *Ptr = getPointerToGlobalIfAvailable(CGV);
assert(Ptr && "Canonical global wasn't codegen'd!");
addGlobalMapping(GV, Ptr);
@@ -1271,8 +1271,8 @@ void ExecutionEngine::emitGlobals() {
for (const auto &GV : M.globals()) {
if (!GV.isDeclaration()) {
if (!LinkedGlobalsMap.empty()) {
- if (const GlobalValue *GVEntry =
- LinkedGlobalsMap[std::make_pair(GV.getName(), GV.getType())])
+ if (const GlobalValue *GVEntry = LinkedGlobalsMap[std::make_pair(
+ std::string(GV.getName()), GV.getType())])
if (GVEntry != &GV) // Not the canonical variable.
continue;
}
diff --git a/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp b/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp
index 701f108..89eef578 100644
--- a/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp
@@ -47,8 +47,8 @@ Expected<std::unique_ptr<LinkGraph>> MachOLinkGraphBuilder::buildGraph() {
MachOLinkGraphBuilder::MachOLinkGraphBuilder(const object::MachOObjectFile &Obj)
: Obj(Obj),
- G(std::make_unique<LinkGraph>(Obj.getFileName(), getPointerSize(Obj),
- getEndianness(Obj))) {}
+ G(std::make_unique<LinkGraph>(std::string(Obj.getFileName()),
+ getPointerSize(Obj), getEndianness(Obj))) {}
void MachOLinkGraphBuilder::addCustomSectionParser(
StringRef SectionName, SectionParserFunction Parser) {
diff --git a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
index 94741f5..9c3d0d5 100644
--- a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
+++ b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
@@ -609,7 +609,7 @@ GenericValue MCJIT::runFunction(Function *F, ArrayRef<GenericValue> ArgValues) {
void *MCJIT::getPointerToNamedFunction(StringRef Name, bool AbortOnFailure) {
if (!isSymbolSearchingDisabled()) {
- if (auto Sym = Resolver.findSymbol(Name)) {
+ if (auto Sym = Resolver.findSymbol(std::string(Name))) {
if (auto AddrOrErr = Sym.getAddress())
return reinterpret_cast<void*>(
static_cast<uintptr_t>(*AddrOrErr));
@@ -619,7 +619,7 @@ void *MCJIT::getPointerToNamedFunction(StringRef Name, bool AbortOnFailure) {
/// If a LazyFunctionCreator is installed, use it to get/create the function.
if (LazyFunctionCreator)
- if (void *RP = LazyFunctionCreator(Name))
+ if (void *RP = LazyFunctionCreator(std::string(Name)))
return RP;
if (AbortOnFailure) {
diff --git a/llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp b/llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp
index 9c504da..29d18b6 100644
--- a/llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp
@@ -35,7 +35,7 @@ static ThreadSafeModule extractSubModule(ThreadSafeModule &TSM,
Constant *Aliasee = A.getAliasee();
assert(A.hasName() && "Anonymous alias?");
assert(Aliasee->hasName() && "Anonymous aliasee");
- std::string AliasName = A.getName();
+ std::string AliasName = std::string(A.getName());
if (isa<Function>(Aliasee)) {
auto *F = cloneFunctionDecl(*A.getParent(), *cast<Function>(Aliasee));
diff --git a/llvm/lib/ExecutionEngine/Orc/Core.cpp b/llvm/lib/ExecutionEngine/Orc/Core.cpp
index ec706cf..f2b161c 100644
--- a/llvm/lib/ExecutionEngine/Orc/Core.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Core.cpp
@@ -838,7 +838,7 @@ JITDylib::defineMaterializing(SymbolFlagsMap SymbolFlags) {
Symbols.erase(SI);
// FIXME: Return all duplicates.
- return make_error<DuplicateDefinition>(*Name);
+ return make_error<DuplicateDefinition>(std::string(*Name));
}
// Otherwise just make a note to discard this symbol after the loop.
@@ -1815,7 +1815,7 @@ Error JITDylib::defineImpl(MaterializationUnit &MU) {
// If there were any duplicate definitions then bail out.
if (!Duplicates.empty())
- return make_error<DuplicateDefinition>(**Duplicates.begin());
+ return make_error<DuplicateDefinition>(std::string(**Duplicates.begin()));
// Discard any overridden defs in this MU.
for (auto &S : MUDefsOverridden)
diff --git a/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp b/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp
index 114e81e..3eda0fa 100644
--- a/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp
@@ -33,7 +33,7 @@ Expected<JITTargetMachineBuilder> JITTargetMachineBuilder::detectHost() {
for (auto &Feature : FeatureMap)
TMBuilder.getFeatures().AddFeature(Feature.first(), Feature.second);
- TMBuilder.setCPU(llvm::sys::getHostCPUName());
+ TMBuilder.setCPU(std::string(llvm::sys::getHostCPUName()));
return TMBuilder;
}
diff --git a/llvm/lib/ExecutionEngine/Orc/OrcCBindingsStack.h b/llvm/lib/ExecutionEngine/Orc/OrcCBindingsStack.h
index e0af3df..87bb439 100644
--- a/llvm/lib/ExecutionEngine/Orc/OrcCBindingsStack.h
+++ b/llvm/lib/ExecutionEngine/Orc/OrcCBindingsStack.h
@@ -133,7 +133,7 @@ private:
orc::SymbolNameSet Result;
for (auto &S : Symbols) {
- if (auto Sym = findSymbol(*S)) {
+ if (auto Sym = findSymbol(std::string(*S))) {
if (!Sym.getFlags().isStrong())
Result.insert(S);
} else if (auto Err = Sym.takeError()) {
@@ -151,7 +151,7 @@ private:
orc::SymbolNameSet UnresolvedSymbols;
for (auto &S : Symbols) {
- if (auto Sym = findSymbol(*S)) {
+ if (auto Sym = findSymbol(std::string(*S))) {
if (auto Addr = Sym.getAddress()) {
Query->notifySymbolMetRequiredState(
S, JITEvaluatedSymbol(*Addr, Sym.getFlags()));
diff --git a/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h b/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
index 169dc8f..139572b 100644
--- a/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
+++ b/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
@@ -154,7 +154,8 @@ class OrcMCJITReplacement : public ExecutionEngine {
M.reportError(std::move(Err));
return SymbolNameSet();
} else {
- if (auto Sym2 = M.ClientResolver->findSymbolInLogicalDylib(*S)) {
+ if (auto Sym2 =
+ M.ClientResolver->findSymbolInLogicalDylib(std::string(*S))) {
if (!Sym2.getFlags().isStrong())
Result.insert(S);
} else if (auto Err = Sym2.takeError()) {
@@ -187,7 +188,7 @@ class OrcMCJITReplacement : public ExecutionEngine {
M.ES.legacyFailQuery(*Query, std::move(Err));
return SymbolNameSet();
} else {
- if (auto Sym2 = M.ClientResolver->findSymbol(*S)) {
+ if (auto Sym2 = M.ClientResolver->findSymbol(std::string(*S))) {
if (auto Addr = Sym2.getAddress()) {
Query->notifySymbolMetRequiredState(
S, JITEvaluatedSymbol(*Addr, Sym2.getFlags()));
@@ -378,9 +379,9 @@ public:
private:
JITSymbol findMangledSymbol(StringRef Name) {
- if (auto Sym = LazyEmitLayer.findSymbol(Name, false))
+ if (auto Sym = LazyEmitLayer.findSymbol(std::string(Name), false))
return Sym;
- if (auto Sym = ClientResolver->findSymbol(Name))
+ if (auto Sym = ClientResolver->findSymbol(std::string(Name)))
return Sym;
if (auto Sym = scanArchives(Name))
return Sym;
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
index cec7b92..a2f6df3 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
@@ -74,7 +74,7 @@ class SectionEntry {
public:
SectionEntry(StringRef name, uint8_t *address, size_t size,
size_t allocationSize, uintptr_t objAddress)
- : Name(name), Address(address), Size(size),
+ : Name(std::string(name)), Address(address), Size(size),
LoadAddress(reinterpret_cast<uintptr_t>(address)), StubOffset(size),
AllocationSize(allocationSize), ObjAddress(objAddress) {
// AllocationSize is used only in asserts, prevent an "unused private field"
diff --git a/llvm/lib/FuzzMutate/FuzzerCLI.cpp b/llvm/lib/FuzzMutate/FuzzerCLI.cpp
index f2368ea..b77a0e0 100644
--- a/llvm/lib/FuzzMutate/FuzzerCLI.cpp
+++ b/llvm/lib/FuzzMutate/FuzzerCLI.cpp
@@ -36,7 +36,7 @@ void llvm::parseFuzzerCLOpts(int ArgC, char *ArgV[]) {
}
void llvm::handleExecNameEncodedBEOpts(StringRef ExecName) {
- std::vector<std::string> Args{ExecName};
+ std::vector<std::string> Args{std::string(ExecName)};
auto NameAndArgs = ExecName.split("--");
if (NameAndArgs.second.empty())
@@ -73,7 +73,7 @@ void llvm::handleExecNameEncodedBEOpts(StringRef ExecName) {
void llvm::handleExecNameEncodedOptimizerOpts(StringRef ExecName) {
// TODO: Refactor parts common with the 'handleExecNameEncodedBEOpts'
- std::vector<std::string> Args{ExecName};
+ std::vector<std::string> Args{std::string(ExecName)};
auto NameAndArgs = ExecName.split("--");
if (NameAndArgs.second.empty())
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 86bb7ba..953d7ae 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -2693,7 +2693,7 @@ void AssemblyWriter::printModuleSummaryIndex() {
// A module id of -1 is a special entry for a regular LTO module created
// during the thin link.
ModPath.second.first == -1u ? RegularLTOModuleName
- : (std::string)ModPath.first(),
+ : (std::string)std::string(ModPath.first()),
ModPath.second.second);
unsigned i = 0;
diff --git a/llvm/lib/IR/AttributeImpl.h b/llvm/lib/IR/AttributeImpl.h
index 15e488b..da6e993 100644
--- a/llvm/lib/IR/AttributeImpl.h
+++ b/llvm/lib/IR/AttributeImpl.h
@@ -152,7 +152,8 @@ class StringAttributeImpl : public AttributeImpl {
public:
StringAttributeImpl(StringRef Kind, StringRef Val = StringRef())
- : AttributeImpl(StringAttrEntry), Kind(Kind), Val(Val) {}
+ : AttributeImpl(StringAttrEntry), Kind(std::string(Kind)),
+ Val(std::string(Val)) {}
StringRef getStringKind() const { return Kind; }
StringRef getStringValue() const { return Val; }
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index 10b6828..efc7168 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -466,7 +466,7 @@ std::string Attribute::getAsString(bool InAttrGrp) const {
std::string Result;
Result += (Twine('"') + getKindAsString() + Twine('"')).str();
- std::string AttrVal = pImpl->getValueAsString();
+ std::string AttrVal = std::string(pImpl->getValueAsString());
if (AttrVal.empty()) return Result;
// Since some attribute strings contain special characters that cannot be
@@ -1481,7 +1481,7 @@ AttrBuilder &AttrBuilder::addAttribute(Attribute Attr) {
}
AttrBuilder &AttrBuilder::addAttribute(StringRef A, StringRef V) {
- TargetDepAttrs[A] = V;
+ TargetDepAttrs[std::string(A)] = std::string(V);
return *this;
}
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 857e264..a14bcef9 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -3663,7 +3663,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
// Replace the original call result with the first result of the new call.
Value *TSC = Builder.CreateExtractValue(NewCall, 0);
- std::string Name = CI->getName();
+ std::string Name = std::string(CI->getName());
if (!Name.empty()) {
CI->setName(Name + ".old");
NewCall->setName(Name);
@@ -3738,7 +3738,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
}
assert(NewCall && "Should have either set this variable or returned through "
"the default case");
- std::string Name = CI->getName();
+ std::string Name = std::string(CI->getName());
if (!Name.empty()) {
CI->setName(Name + ".old");
NewCall->setName(Name);
@@ -4080,7 +4080,7 @@ void llvm::UpgradeSectionAttributes(Module &M) {
for (auto Component : Components)
OS << ',' << Component.trim();
- return OS.str().substr(1);
+ return std::string(OS.str().substr(1));
};
for (auto &GV : M.globals()) {
@@ -4166,12 +4166,12 @@ std::string llvm::UpgradeDataLayoutString(StringRef DL, StringRef TT) {
// If X86, and the datalayout matches the expected format, add pointer size
// address spaces to the datalayout.
if (!Triple(TT).isX86() || DL.contains(AddrSpaces))
- return DL;
+ return std::string(DL);
SmallVector<StringRef, 4> Groups;
Regex R("(e-m:[a-z](-p:32:32)?)(-[if]64:.*$)");
if (!R.match(DL, &Groups))
- return DL;
+ return std::string(DL);
SmallString<1024> Buf;
std::string Res = (Groups[1] + AddrSpaces + Groups[3]).toStringRef(Buf).str();
diff --git a/llvm/lib/IR/ConstantsContext.h b/llvm/lib/IR/ConstantsContext.h
index f5e2481f..9ecbb61 100644
--- a/llvm/lib/IR/ConstantsContext.h
+++ b/llvm/lib/IR/ConstantsContext.h
@@ -454,8 +454,8 @@ struct InlineAsmKeyType {
InlineAsm *create(TypeClass *Ty) const {
assert(PointerType::getUnqual(FTy) == Ty);
- return new InlineAsm(FTy, AsmString, Constraints, HasSideEffects,
- IsAlignStack, AsmDialect);
+ return new InlineAsm(FTy, std::string(AsmString), std::string(Constraints),
+ HasSideEffects, IsAlignStack, AsmDialect);
}
};
diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp
index 26ec6db..c2ac1c3 100644
--- a/llvm/lib/IR/DataLayout.cpp
+++ b/llvm/lib/IR/DataLayout.cpp
@@ -229,7 +229,7 @@ static unsigned getAddrSpace(StringRef R) {
}
void DataLayout::parseSpecifier(StringRef Desc) {
- StringRepresentation = Desc;
+ StringRepresentation = std::string(Desc);
while (!Desc.empty()) {
// Split at '-'.
std::pair<StringRef, StringRef> Split = split(Desc, '-');
diff --git a/llvm/lib/IR/DiagnosticInfo.cpp b/llvm/lib/IR/DiagnosticInfo.cpp
index 99d5aec..1a4957d 100644
--- a/llvm/lib/IR/DiagnosticInfo.cpp
+++ b/llvm/lib/IR/DiagnosticInfo.cpp
@@ -132,7 +132,7 @@ StringRef DiagnosticLocation::getRelativePath() const {
std::string DiagnosticLocation::getAbsolutePath() const {
StringRef Name = File->getFilename();
if (sys::path::is_absolute(Name))
- return Name;
+ return std::string(Name);
SmallString<128> Path;
sys::path::append(Path, File->getDirectory(), Name);
@@ -160,8 +160,9 @@ const std::string DiagnosticInfoWithLocationBase::getLocationStr() const {
return (Filename + ":" + Twine(Line) + ":" + Twine(Column)).str();
}
-DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, const Value *V)
- : Key(Key) {
+DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key,
+ const Value *V)
+ : Key(std::string(Key)) {
if (auto *F = dyn_cast<Function>(V)) {
if (DISubprogram *SP = F->getSubprogram())
Loc = SP;
@@ -172,7 +173,7 @@ DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, const Value *V
// Only include names that correspond to user variables. FIXME: We should use
// debug info if available to get the name of the user variable.
if (isa<llvm::Argument>(V) || isa<GlobalValue>(V))
- Val = GlobalValue::dropLLVMManglingEscape(V->getName());
+ Val = std::string(GlobalValue::dropLLVMManglingEscape(V->getName()));
else if (isa<Constant>(V)) {
raw_string_ostream OS(Val);
V->printAsOperand(OS, /*PrintType=*/false);
@@ -181,39 +182,39 @@ DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, const Value *V
}
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, const Type *T)
- : Key(Key) {
+ : Key(std::string(Key)) {
raw_string_ostream OS(Val);
OS << *T;
}
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, StringRef S)
- : Key(Key), Val(S.str()) {}
+ : Key(std::string(Key)), Val(S.str()) {}
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, int N)
- : Key(Key), Val(itostr(N)) {}
+ : Key(std::string(Key)), Val(itostr(N)) {}
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, float N)
- : Key(Key), Val(llvm::to_string(N)) {}
+ : Key(std::string(Key)), Val(llvm::to_string(N)) {}
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, long N)
- : Key(Key), Val(itostr(N)) {}
+ : Key(std::string(Key)), Val(itostr(N)) {}
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, long long N)
- : Key(Key), Val(itostr(N)) {}
+ : Key(std::string(Key)), Val(itostr(N)) {}
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, unsigned N)
- : Key(Key), Val(utostr(N)) {}
+ : Key(std::string(Key)), Val(utostr(N)) {}
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key,
unsigned long N)
- : Key(Key), Val(utostr(N)) {}
+ : Key(std::string(Key)), Val(utostr(N)) {}
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key,
unsigned long long N)
- : Key(Key), Val(utostr(N)) {}
+ : Key(std::string(Key)), Val(utostr(N)) {}
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, DebugLoc Loc)
- : Key(Key), Loc(Loc) {
+ : Key(std::string(Key)), Loc(Loc) {
if (Loc) {
Val = (Loc->getFilename() + ":" + Twine(Loc.getLine()) + ":" +
Twine(Loc.getCol())).str();
diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 46a9696..9a07a68 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -143,7 +143,7 @@ std::string GlobalValue::getGlobalIdentifier(StringRef Name,
if (Name[0] == '\1')
Name = Name.substr(1);
- std::string NewName = Name;
+ std::string NewName = std::string(Name);
if (llvm::GlobalValue::isLocalLinkage(Linkage)) {
// For local symbols, prepend the main file name to distinguish them.
// Do not include the full path in the file name since there's no guarantee
diff --git a/llvm/lib/IR/InlineAsm.cpp b/llvm/lib/IR/InlineAsm.cpp
index fd732f9..ee30b925 100644
--- a/llvm/lib/IR/InlineAsm.cpp
+++ b/llvm/lib/IR/InlineAsm.cpp
@@ -136,14 +136,14 @@ bool InlineAsm::ConstraintInfo::Parse(StringRef Str,
// Find the end of the register name.
StringRef::iterator ConstraintEnd = std::find(I+1, E, '}');
if (ConstraintEnd == E) return true; // "{foo"
- pCodes->push_back(StringRef(I, ConstraintEnd+1 - I));
+ pCodes->push_back(std::string(StringRef(I, ConstraintEnd + 1 - I)));
I = ConstraintEnd+1;
} else if (isdigit(static_cast<unsigned char>(*I))) { // Matching Constraint
// Maximal munch numbers.
StringRef::iterator NumStart = I;
while (I != E && isdigit(static_cast<unsigned char>(*I)))
++I;
- pCodes->push_back(StringRef(NumStart, I - NumStart));
+ pCodes->push_back(std::string(StringRef(NumStart, I - NumStart)));
unsigned N = atoi(pCodes->back().c_str());
// Check that this is a valid matching constraint!
if (N >= ConstraintsSoFar.size() || ConstraintsSoFar[N].Type != isOutput||
@@ -179,7 +179,7 @@ bool InlineAsm::ConstraintInfo::Parse(StringRef Str,
} else if (*I == '^') {
// Multi-letter constraint
// FIXME: For now assuming these are 2-character constraints.
- pCodes->push_back(StringRef(I+1, 2));
+ pCodes->push_back(std::string(StringRef(I + 1, 2)));
I += 3;
} else if (*I == '@') {
// Multi-letter constraint
@@ -189,11 +189,11 @@ bool InlineAsm::ConstraintInfo::Parse(StringRef Str,
int N = C - '0';
assert(N > 0 && "Found a zero letter constraint!");
++I;
- pCodes->push_back(StringRef(I, N));
+ pCodes->push_back(std::string(StringRef(I, N)));
I += N;
} else {
// Single letter constraint.
- pCodes->push_back(StringRef(I, 1));
+ pCodes->push_back(std::string(StringRef(I, 1)));
++I;
}
}
diff --git a/llvm/lib/IR/LegacyPassManager.cpp b/llvm/lib/IR/LegacyPassManager.cpp
index 90239bb..d5c7e28 100644
--- a/llvm/lib/IR/LegacyPassManager.cpp
+++ b/llvm/lib/IR/LegacyPassManager.cpp
@@ -132,7 +132,8 @@ bool llvm::forcePrintModuleIR() { return PrintModuleScope; }
bool llvm::isFunctionInPrintList(StringRef FunctionName) {
static std::unordered_set<std::string> PrintFuncNames(PrintFuncsList.begin(),
PrintFuncsList.end());
- return PrintFuncNames.empty() || PrintFuncNames.count(FunctionName);
+ return PrintFuncNames.empty() ||
+ PrintFuncNames.count(std::string(FunctionName));
}
/// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions
/// or higher is specified.
@@ -239,7 +240,7 @@ void PMDataManager::emitInstrCountChangedRemark(
// Helper lambda that emits a remark when the size of a function has changed.
auto EmitFunctionSizeChangedRemark = [&FunctionToInstrCount, &F, &BB,
- &PassName](const std::string &Fname) {
+ &PassName](StringRef Fname) {
unsigned FnCountBefore, FnCountAfter;
std::pair<unsigned, unsigned> &Change = FunctionToInstrCount[Fname];
std::tie(FnCountBefore, FnCountAfter) = Change;
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp
index eb23b12..3b35176 100644
--- a/llvm/lib/IR/Module.cpp
+++ b/llvm/lib/IR/Module.cpp
@@ -72,7 +72,8 @@ template class llvm::SymbolTableListTraits<GlobalIFunc>;
Module::Module(StringRef MID, LLVMContext &C)
: Context(C), ValSymTab(std::make_unique<ValueSymbolTable>()),
- Materializer(), ModuleID(MID), SourceFileName(MID), DL("") {
+ Materializer(), ModuleID(std::string(MID)),
+ SourceFileName(std::string(MID)), DL("") {
Context.addModule(this);
}
diff --git a/llvm/lib/LTO/Caching.cpp b/llvm/lib/LTO/Caching.cpp
index 12dcd18..46cac3f 100644
--- a/llvm/lib/LTO/Caching.cpp
+++ b/llvm/lib/LTO/Caching.cpp
@@ -144,7 +144,7 @@ Expected<NativeObjectCache> lto::localCache(StringRef CacheDirectoryPath,
// This CacheStream will move the temporary file into the cache when done.
return std::make_unique<CacheStream>(
std::make_unique<raw_fd_ostream>(Temp->FD, /* ShouldClose */ false),
- AddBuffer, std::move(*Temp), EntryPath.str(), Task);
+ AddBuffer, std::move(*Temp), std::string(EntryPath.str()), Task);
};
};
}
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index e8f0fd6..5d03be1 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -513,7 +513,7 @@ void LTO::addModuleToGlobalRes(ArrayRef<InputFile::Symbol> Syms,
assert(!GlobalRes.Prevailing &&
"Multiple prevailing defs are not allowed");
GlobalRes.Prevailing = true;
- GlobalRes.IRName = Sym.getIRName();
+ GlobalRes.IRName = std::string(Sym.getIRName());
} else if (!GlobalRes.Prevailing && GlobalRes.IRName.empty()) {
// Sometimes it can be two copies of symbol in a module and prevailing
// symbol can have no IR name. That might happen if symbol is defined in
@@ -521,7 +521,7 @@ void LTO::addModuleToGlobalRes(ArrayRef<InputFile::Symbol> Syms,
// the same symbol we want to use IR name of the prevailing symbol.
// Otherwise, if we haven't seen a prevailing symbol, set the name so that
// we can later use it to check if there is any prevailing copy in IR.
- GlobalRes.IRName = Sym.getIRName();
+ GlobalRes.IRName = std::string(Sym.getIRName());
}
// Set the partition to external if we know it is re-defined by the linker
@@ -762,7 +762,7 @@ LTO::addRegularLTO(BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms,
if (Sym.isCommon()) {
// FIXME: We should figure out what to do about commons defined by asm.
// For now they aren't reported correctly by ModuleSymbolTable.
- auto &CommonRes = RegularLTO.Commons[Sym.getIRName()];
+ auto &CommonRes = RegularLTO.Commons[std::string(Sym.getIRName())];
CommonRes.Size = std::max(CommonRes.Size, Sym.getCommonSize());
CommonRes.Align =
std::max(CommonRes.Align, MaybeAlign(Sym.getCommonAlignment()));
@@ -1191,7 +1191,7 @@ std::string lto::getThinLTOOutputFile(const std::string &Path,
llvm::errs() << "warning: could not create directory '" << ParentPath
<< "': " << EC.message() << '\n';
}
- return NewPath.str();
+ return std::string(NewPath.str());
}
namespace {
@@ -1220,7 +1220,7 @@ public:
MapVector<StringRef, BitcodeModule> &ModuleMap) override {
StringRef ModulePath = BM.getModuleIdentifier();
std::string NewModulePath =
- getThinLTOOutputFile(ModulePath, OldPrefix, NewPrefix);
+ getThinLTOOutputFile(std::string(ModulePath), OldPrefix, NewPrefix);
if (LinkedObjectsFile)
*LinkedObjectsFile << NewModulePath << '\n';
@@ -1244,7 +1244,7 @@ public:
}
if (OnWrite)
- OnWrite(ModulePath);
+ OnWrite(std::string(ModulePath));
return Error::success();
}
@@ -1391,7 +1391,7 @@ Expected<std::unique_ptr<ToolOutputFile>>
lto::setupOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename,
StringRef RemarksPasses, StringRef RemarksFormat,
bool RemarksWithHotness, int Count) {
- std::string Filename = RemarksFilename;
+ std::string Filename = std::string(RemarksFilename);
// For ThinLTO, file.opt.<format> becomes
// file.opt.<format>.thin.<num>.<format>.
if (!Filename.empty() && Count != -1)
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index b3bc727..bbc1f40 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -632,7 +632,7 @@ bool LTOCodeGenerator::compileOptimized(ArrayRef<raw_pwrite_stream *> Out) {
void LTOCodeGenerator::setCodeGenDebugOptions(ArrayRef<const char *> Options) {
for (StringRef Option : Options)
- CodegenOptions.push_back(Option);
+ CodegenOptions.push_back(std::string(Option));
}
void LTOCodeGenerator::parseCodeGenDebugOptions() {
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
index f4099e6..2fa1cdd 100644
--- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -870,11 +870,11 @@ ThinLTOCodeGenerator::writeGeneratedObject(int count, StringRef CacheEntryPath,
// Cache is enabled, hard-link the entry (or copy if hard-link fails).
auto Err = sys::fs::create_hard_link(CacheEntryPath, OutputPath);
if (!Err)
- return OutputPath.str();
+ return std::string(OutputPath.str());
// Hard linking failed, try to copy.
Err = sys::fs::copy_file(CacheEntryPath, OutputPath);
if (!Err)
- return OutputPath.str();
+ return std::string(OutputPath.str());
// Copy failed (could be because the CacheEntry was removed from the cache
// in the meantime by another process), fall back and try to write down the
// buffer to the output.
@@ -887,7 +887,7 @@ ThinLTOCodeGenerator::writeGeneratedObject(int count, StringRef CacheEntryPath,
if (Err)
report_fatal_error("Can't open output '" + OutputPath + "'\n");
OS << OutputBuffer.getBuffer();
- return OutputPath.str();
+ return std::string(OutputPath.str());
}
// Main entry point for the ThinLTO processing
diff --git a/llvm/lib/LineEditor/LineEditor.cpp b/llvm/lib/LineEditor/LineEditor.cpp
index 57e62bd6..1aa3476 100644
--- a/llvm/lib/LineEditor/LineEditor.cpp
+++ b/llvm/lib/LineEditor/LineEditor.cpp
@@ -24,7 +24,7 @@ std::string LineEditor::getDefaultHistoryPath(StringRef ProgName) {
SmallString<32> Path;
if (sys::path::home_directory(Path)) {
sys::path::append(Path, "." + ProgName + "-history");
- return Path.str();
+ return std::string(Path.str());
}
return std::string();
}
@@ -197,7 +197,7 @@ unsigned char ElCompletionFn(EditLine *EL, int ch) {
LineEditor::LineEditor(StringRef ProgName, StringRef HistoryPath, FILE *In,
FILE *Out, FILE *Err)
- : Prompt((ProgName + "> ").str()), HistoryPath(HistoryPath),
+ : Prompt((ProgName + "> ").str()), HistoryPath(std::string(HistoryPath)),
Data(new InternalData) {
if (HistoryPath.empty())
this->HistoryPath = getDefaultHistoryPath(ProgName);
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index a641711..ff4f636 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -68,8 +68,8 @@ MCContext::MCContext(const MCAsmInfo *mai, const MCRegisterInfo *mri,
SecureLogFile = AsSecureLogFileName;
if (SrcMgr && SrcMgr->getNumBuffers())
- MainFileName =
- SrcMgr->getMemoryBuffer(SrcMgr->getMainFileID())->getBufferIdentifier();
+ MainFileName = std::string(SrcMgr->getMemoryBuffer(SrcMgr->getMainFileID())
+ ->getBufferIdentifier());
}
MCContext::~MCContext() {
@@ -593,7 +593,7 @@ void MCContext::RemapDebugPaths() {
};
// Remap compilation directory.
- std::string CompDir = CompilationDir.str();
+ std::string CompDir = std::string(CompilationDir.str());
RemapDebugPath(CompDir);
CompilationDir = CompDir;
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index b4b3c99..1a32822 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -620,7 +620,7 @@ MCDwarfLineTableHeader::tryGetFile(StringRef &Directory,
} else {
DirIndex = llvm::find(MCDwarfDirs, Directory) - MCDwarfDirs.begin();
if (DirIndex >= MCDwarfDirs.size())
- MCDwarfDirs.push_back(Directory);
+ MCDwarfDirs.push_back(std::string(Directory));
// The DirIndex is one based, as DirIndex of 0 is used for FileNames with
// no directories. MCDwarfDirs[] is unlike MCDwarfFiles[] in that the
// directory names are stored at MCDwarfDirs[DirIndex-1] where FileNames
@@ -628,7 +628,7 @@ MCDwarfLineTableHeader::tryGetFile(StringRef &Directory,
DirIndex++;
}
- File.Name = FileName;
+ File.Name = std::string(FileName);
File.DirIndex = DirIndex;
File.Checksum = Checksum;
trackMD5Usage(Checksum.hasValue());
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index c5938b8..30f1147f 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -2358,7 +2358,7 @@ void AsmParser::DiagHandler(const SMDiagnostic &Diag, void *Context) {
// Use the CppHashFilename and calculate a line number based on the
// CppHashInfo.Loc and CppHashInfo.LineNumber relative to this Diag's SMLoc
// for the diagnostic.
- const std::string &Filename = Parser->CppHashInfo.Filename;
+ const std::string &Filename = std::string(Parser->CppHashInfo.Filename);
int DiagLocLineNo = DiagSrcMgr.FindLineNumber(DiagLoc, DiagBuf);
int CppHashLocLineNo =
diff --git a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
index bd66e5f..1d1feaa 100644
--- a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
@@ -672,7 +672,7 @@ bool DarwinAsmParser::parseDirectiveSection(StringRef, SMLoc) {
if (!getLexer().is(AsmToken::Comma))
return TokError("unexpected token in '.section' directive");
- std::string SectionSpec = SectionName;
+ std::string SectionSpec = std::string(SectionName);
SectionSpec += ",";
// Add all the tokens until the end of the line, ParseSectionSpecifier will
diff --git a/llvm/lib/MC/MCSubtargetInfo.cpp b/llvm/lib/MC/MCSubtargetInfo.cpp
index c8678df..7d38cd0 100644
--- a/llvm/lib/MC/MCSubtargetInfo.cpp
+++ b/llvm/lib/MC/MCSubtargetInfo.cpp
@@ -206,15 +206,17 @@ void MCSubtargetInfo::setDefaultFeatures(StringRef CPU, StringRef FS) {
FeatureBits = getFeatures(CPU, FS, ProcDesc, ProcFeatures);
}
-MCSubtargetInfo::MCSubtargetInfo(
- const Triple &TT, StringRef C, StringRef FS,
- ArrayRef<SubtargetFeatureKV> PF, ArrayRef<SubtargetSubTypeKV> PD,
- const MCWriteProcResEntry *WPR,
- const MCWriteLatencyEntry *WL, const MCReadAdvanceEntry *RA,
- const InstrStage *IS, const unsigned *OC, const unsigned *FP)
- : TargetTriple(TT), CPU(C), ProcFeatures(PF), ProcDesc(PD),
- WriteProcResTable(WPR), WriteLatencyTable(WL),
- ReadAdvanceTable(RA), Stages(IS), OperandCycles(OC), ForwardingPaths(FP) {
+MCSubtargetInfo::MCSubtargetInfo(const Triple &TT, StringRef C, StringRef FS,
+ ArrayRef<SubtargetFeatureKV> PF,
+ ArrayRef<SubtargetSubTypeKV> PD,
+ const MCWriteProcResEntry *WPR,
+ const MCWriteLatencyEntry *WL,
+ const MCReadAdvanceEntry *RA,
+ const InstrStage *IS, const unsigned *OC,
+ const unsigned *FP)
+ : TargetTriple(TT), CPU(std::string(C)), ProcFeatures(PF), ProcDesc(PD),
+ WriteProcResTable(WPR), WriteLatencyTable(WL), ReadAdvanceTable(RA),
+ Stages(IS), OperandCycles(OC), ForwardingPaths(FP) {
InitMCProcessorInfo(CPU, FS);
}
diff --git a/llvm/lib/MC/SubtargetFeature.cpp b/llvm/lib/MC/SubtargetFeature.cpp
index c4dd773..3155adc 100644
--- a/llvm/lib/MC/SubtargetFeature.cpp
+++ b/llvm/lib/MC/SubtargetFeature.cpp
@@ -33,7 +33,9 @@ using namespace llvm;
void SubtargetFeatures::Split(std::vector<std::string> &V, StringRef S) {
SmallVector<StringRef, 3> Tmp;
S.split(Tmp, ',', -1, false /* KeepEmpty */);
- V.assign(Tmp.begin(), Tmp.end());
+ V.reserve(Tmp.size());
+ for (StringRef T : Tmp)
+ V.push_back(std::string(T));
}
void SubtargetFeatures::AddFeature(StringRef String, bool Enable) {
diff --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp
index 749ed8b..cf755dc 100644
--- a/llvm/lib/MC/WinCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp
@@ -118,7 +118,7 @@ public:
COFFSymbol *Symbol = nullptr;
relocations Relocations;
- COFFSection(StringRef Name) : Name(Name) {}
+ COFFSection(StringRef Name) : Name(std::string(Name)) {}
};
class WinCOFFObjectWriter : public MCObjectWriter {
diff --git a/llvm/lib/MCA/InstrBuilder.cpp b/llvm/lib/MCA/InstrBuilder.cpp
index c137f1d..f3c7134 100644
--- a/llvm/lib/MCA/InstrBuilder.cpp
+++ b/llvm/lib/MCA/InstrBuilder.cpp
@@ -502,7 +502,7 @@ Error InstrBuilder::verifyInstrDesc(const InstrDesc &ID,
"resources.";
}
- return make_error<InstructionError<MCInst>>(Message, MCI);
+ return make_error<InstructionError<MCInst>>(std::string(Message), MCI);
}
Expected<const InstrDesc &>
diff --git a/llvm/lib/Object/Archive.cpp b/llvm/lib/Object/Archive.cpp
index 148c011..17d5eec 100644
--- a/llvm/lib/Object/Archive.cpp
+++ b/llvm/lib/Object/Archive.cpp
@@ -423,12 +423,12 @@ Expected<std::string> Archive::Child::getFullName() const {
return NameOrErr.takeError();
StringRef Name = *NameOrErr;
if (sys::path::is_absolute(Name))
- return Name;
+ return std::string(Name);
SmallString<128> FullName = sys::path::parent_path(
Parent->getMemoryBufferRef().getBufferIdentifier());
sys::path::append(FullName, Name);
- return StringRef(FullName);
+ return std::string(FullName.str());
}
Expected<StringRef> Archive::Child::getBuffer() const {
diff --git a/llvm/lib/Object/ArchiveWriter.cpp b/llvm/lib/Object/ArchiveWriter.cpp
index 5234b0e..13dafb5 100644
--- a/llvm/lib/Object/ArchiveWriter.cpp
+++ b/llvm/lib/Object/ArchiveWriter.cpp
@@ -545,7 +545,7 @@ Expected<std::string> computeArchiveRelativePath(StringRef From, StringRef To) {
for (auto ToE = sys::path::end(PathTo); ToI != ToE; ++ToI)
sys::path::append(Relative, sys::path::Style::posix, *ToI);
- return Relative.str();
+ return std::string(Relative.str());
}
Error writeArchive(StringRef ArcName, ArrayRef<NewArchiveMember> NewMembers,
diff --git a/llvm/lib/Object/COFFImportFile.cpp b/llvm/lib/Object/COFFImportFile.cpp
index ff4a799..69bbf70 100644
--- a/llvm/lib/Object/COFFImportFile.cpp
+++ b/llvm/lib/Object/COFFImportFile.cpp
@@ -600,7 +600,7 @@ Error writeImportLibrary(StringRef ImportName, StringRef Path,
: getNameType(SymbolName, E.Name,
Machine, MinGW);
Expected<std::string> Name = E.ExtName.empty()
- ? SymbolName
+ ? std::string(SymbolName)
: replace(SymbolName, E.Name, E.ExtName);
if (!Name)
diff --git a/llvm/lib/Object/COFFModuleDefinition.cpp b/llvm/lib/Object/COFFModuleDefinition.cpp
index 64d4cf0..8f29f7a 100644
--- a/llvm/lib/Object/COFFModuleDefinition.cpp
+++ b/llvm/lib/Object/COFFModuleDefinition.cpp
@@ -229,14 +229,14 @@ private:
Error parseExport() {
COFFShortExport E;
- E.Name = Tok.Value;
+ E.Name = std::string(Tok.Value);
read();
if (Tok.K == Equal) {
read();
if (Tok.K != Identifier)
return createError("identifier expected, but got " + Tok.Value);
E.ExtName = E.Name;
- E.Name = Tok.Value;
+ E.Name = std::string(Tok.Value);
} else {
unget();
}
@@ -285,7 +285,7 @@ private:
}
if (Tok.K == EqualEqual) {
read();
- E.AliasTarget = Tok.Value;
+ E.AliasTarget = std::string(Tok.Value);
if (Machine == IMAGE_FILE_MACHINE_I386 && !isDecorated(E.AliasTarget, MingwDef))
E.AliasTarget = std::string("_").append(E.AliasTarget);
continue;
@@ -315,7 +315,7 @@ private:
Error parseName(std::string *Out, uint64_t *Baseaddr) {
read();
if (Tok.K == Identifier) {
- *Out = Tok.Value;
+ *Out = std::string(Tok.Value);
} else {
*Out = "";
unget();
diff --git a/llvm/lib/Object/IRSymtab.cpp b/llvm/lib/Object/IRSymtab.cpp
index e4282b9..a92cb02 100644
--- a/llvm/lib/Object/IRSymtab.cpp
+++ b/llvm/lib/Object/IRSymtab.cpp
@@ -181,7 +181,7 @@ Expected<int> Builder::getComdatIndex(const Comdat *C, const Module *M) {
llvm::raw_string_ostream OS(Name);
Mang.getNameWithPrefix(OS, GV, false);
} else {
- Name = C->getName();
+ Name = std::string(C->getName());
}
storage::Comdat Comdat;
diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp
index 813ced1..1a69258 100644
--- a/llvm/lib/Object/WasmObjectFile.cpp
+++ b/llvm/lib/Object/WasmObjectFile.cpp
@@ -732,7 +732,7 @@ Error WasmObjectFile::parseTargetFeaturesSection(ReadContext &Ctx) {
return make_error<GenericBinaryError>("Unknown feature policy prefix",
object_error::parse_failed);
}
- Feature.Name = readString(Ctx);
+ Feature.Name = std::string(readString(Ctx));
if (!FeaturesSeen.insert(Feature.Name).second)
return make_error<GenericBinaryError>(
"Target features section contains repeated feature \"" +
diff --git a/llvm/lib/Object/WindowsResource.cpp b/llvm/lib/Object/WindowsResource.cpp
index 1071771..0cf9da4 100644
--- a/llvm/lib/Object/WindowsResource.cpp
+++ b/llvm/lib/Object/WindowsResource.cpp
@@ -346,7 +346,7 @@ Error WindowsResourceParser::parse(WindowsResource *WR,
ResourceEntryRef Entry = EntryOrErr.get();
uint32_t Origin = InputFilenames.size();
- InputFilenames.push_back(WR->getFileName());
+ InputFilenames.push_back(std::string(WR->getFileName()));
bool End = false;
while (!End) {
@@ -368,7 +368,7 @@ Error WindowsResourceParser::parse(ResourceSectionRef &RSR, StringRef Filename,
std::vector<std::string> &Duplicates) {
UNWRAP_REF_OR_RETURN(BaseTable, RSR.getBaseTable());
uint32_t Origin = InputFilenames.size();
- InputFilenames.push_back(Filename);
+ InputFilenames.push_back(std::string(Filename));
std::vector<StringOrID> Context;
return addChildren(Root, RSR, BaseTable, Origin, Context, Duplicates);
}
diff --git a/llvm/lib/Option/Arg.cpp b/llvm/lib/Option/Arg.cpp
index ea382b3..2da32bf 100644
--- a/llvm/lib/Option/Arg.cpp
+++ b/llvm/lib/Option/Arg.cpp
@@ -81,7 +81,7 @@ std::string Arg::getAsString(const ArgList &Args) const {
OS << *it;
}
- return OS.str();
+ return std::string(OS.str());
}
void Arg::renderAsInput(const ArgList &Args, ArgStringList &Output) const {
diff --git a/llvm/lib/Option/ArgList.cpp b/llvm/lib/Option/ArgList.cpp
index 09e9215..ad7be5f 100644
--- a/llvm/lib/Option/ArgList.cpp
+++ b/llvm/lib/Option/ArgList.cpp
@@ -209,7 +209,7 @@ unsigned InputArgList::MakeIndex(StringRef String0) const {
unsigned Index = ArgStrings.size();
// Tuck away so we have a reliable const char *.
- SynthesizedStrings.push_back(String0);
+ SynthesizedStrings.push_back(std::string(String0));
ArgStrings.push_back(SynthesizedStrings.back().c_str());
return Index;
diff --git a/llvm/lib/Option/OptTable.cpp b/llvm/lib/Option/OptTable.cpp
index 5833d03..926eb8e 100644
--- a/llvm/lib/Option/OptTable.cpp
+++ b/llvm/lib/Option/OptTable.cpp
@@ -219,7 +219,7 @@ OptTable::suggestValueCompletions(StringRef Option, StringRef Arg) const {
std::vector<std::string> Result;
for (StringRef Val : Candidates)
if (Val.startswith(Arg) && Arg.compare(Val))
- Result.push_back(Val);
+ Result.push_back(std::string(Val));
return Result;
}
return {};
@@ -283,10 +283,10 @@ unsigned OptTable::findNearest(StringRef Option, std::string &NearestString,
StringRef LHS, RHS;
char Last = CandidateName.back();
bool CandidateHasDelimiter = Last == '=' || Last == ':';
- std::string NormalizedName = Option;
+ std::string NormalizedName = std::string(Option);
if (CandidateHasDelimiter) {
std::tie(LHS, RHS) = Option.split(Last);
- NormalizedName = LHS;
+ NormalizedName = std::string(LHS);
if (Option.find(Last) == LHS.size())
NormalizedName += Last;
}
diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp
index 5cf0ca8..2d3440c 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -98,7 +98,7 @@ void printIR(const Loop *L, StringRef Banner) {
const Function *F = L->getHeader()->getParent();
if (!llvm::isFunctionInPrintList(F->getName()))
return;
- llvm::printLoop(const_cast<Loop &>(*L), dbgs(), Banner);
+ llvm::printLoop(const_cast<Loop &>(*L), dbgs(), std::string(Banner));
}
/// Generic IR-printing helper that unpacks a pointer to IRUnit wrapped into
@@ -127,7 +127,7 @@ void unwrapAndPrint(Any IR, StringRef Banner, bool ForceModule = false) {
if (any_isa<const LazyCallGraph::SCC *>(IR)) {
const LazyCallGraph::SCC *C = any_cast<const LazyCallGraph::SCC *>(IR);
assert(C && "scc should be valid for printing");
- std::string Extra = formatv(" (scc: {0})", C->getName());
+ std::string Extra = std::string(formatv(" (scc: {0})", C->getName()));
printIR(C, Banner, Extra);
return;
}
diff --git a/llvm/lib/ProfileData/GCOV.cpp b/llvm/lib/ProfileData/GCOV.cpp
index 228c1b3..e0f33fb 100644
--- a/llvm/lib/ProfileData/GCOV.cpp
+++ b/llvm/lib/ProfileData/GCOV.cpp
@@ -672,7 +672,7 @@ static std::string mangleCoveragePath(StringRef Filename, bool PreservePaths) {
if (S < I)
Result.append(S, I);
- return Result.str();
+ return std::string(Result.str());
}
std::string FileInfo::getCoveragePath(StringRef Filename,
@@ -681,7 +681,7 @@ std::string FileInfo::getCoveragePath(StringRef Filename,
// This is probably a bug in gcov, but when -n is specified, paths aren't
// mangled at all, and the -l and -p options are ignored. Here, we do the
// same.
- return Filename;
+ return std::string(Filename);
std::string CoveragePath;
if (Options.LongFileNames && !Filename.equals(MainFilename))
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index 57d4fbc..1859127 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -286,7 +286,7 @@ StringRef getFuncNameWithoutPrefix(StringRef PGOFuncName, StringRef FileName) {
// symbol is created to hold the name. Return the legalized symbol name.
std::string getPGOFuncNameVarName(StringRef FuncName,
GlobalValue::LinkageTypes Linkage) {
- std::string VarName = getInstrProfNameVarPrefix();
+ std::string VarName = std::string(getInstrProfNameVarPrefix());
VarName += FuncName;
if (!GlobalValue::isLocalLinkage(Linkage))
@@ -427,7 +427,7 @@ Error collectPGOFuncNameStrings(ArrayRef<GlobalVariable *> NameVars,
std::string &Result, bool doCompression) {
std::vector<std::string> NameStrs;
for (auto *NameVar : NameVars) {
- NameStrs.push_back(getPGOFuncNameVarInitializer(NameVar));
+ NameStrs.push_back(std::string(getPGOFuncNameVarInitializer(NameVar)));
}
return collectPGOFuncNameStrings(
NameStrs, zlib::isAvailable() && doCompression, Result);
diff --git a/llvm/lib/ProfileData/SampleProfReader.cpp b/llvm/lib/ProfileData/SampleProfReader.cpp
index 001aafc..6f74cec 100644
--- a/llvm/lib/ProfileData/SampleProfReader.cpp
+++ b/llvm/lib/ProfileData/SampleProfReader.cpp
@@ -245,7 +245,7 @@ std::error_code SampleProfileReaderText::readImpl() {
InlineStack.pop_back();
}
FunctionSamples &FSamples = InlineStack.back()->functionSamplesAt(
- LineLocation(LineOffset, Discriminator))[FName];
+ LineLocation(LineOffset, Discriminator))[std::string(FName)];
FSamples.setName(FName);
MergeResult(Result, FSamples.addTotalSamples(NumSamples));
InlineStack.push_back(&FSamples);
@@ -430,7 +430,7 @@ SampleProfileReaderBinary::readProfile(FunctionSamples &FProfile) {
return EC;
FunctionSamples &CalleeProfile = FProfile.functionSamplesAt(
- LineLocation(*LineOffset, *Discriminator))[*FName];
+ LineLocation(*LineOffset, *Discriminator))[std::string(*FName)];
CalleeProfile.setName(*FName);
if (std::error_code EC = readProfile(CalleeProfile))
return EC;
@@ -1043,7 +1043,7 @@ std::error_code SampleProfileReaderGCC::readNameTable() {
StringRef Str;
if (!GcovBuffer.readString(Str))
return sampleprof_error::truncated;
- Names.push_back(Str);
+ Names.push_back(std::string(Str));
}
return sampleprof_error::success;
@@ -1107,7 +1107,7 @@ std::error_code SampleProfileReaderGCC::readOneFunctionProfile(
uint32_t LineOffset = Offset >> 16;
uint32_t Discriminator = Offset & 0xffff;
FProfile = &CallerProfile->functionSamplesAt(
- LineLocation(LineOffset, Discriminator))[Name];
+ LineLocation(LineOffset, Discriminator))[std::string(Name)];
}
FProfile->setName(Name);
diff --git a/llvm/lib/Remarks/BitstreamRemarkParser.cpp b/llvm/lib/Remarks/BitstreamRemarkParser.cpp
index 4c45088..25fbea7 100644
--- a/llvm/lib/Remarks/BitstreamRemarkParser.cpp
+++ b/llvm/lib/Remarks/BitstreamRemarkParser.cpp
@@ -323,7 +323,7 @@ remarks::createBitstreamParserFromMeta(
: std::make_unique<BitstreamRemarkParser>(Buf);
if (ExternalFilePrependPath)
- Parser->ExternalFilePrependPath = *ExternalFilePrependPath;
+ Parser->ExternalFilePrependPath = std::string(*ExternalFilePrependPath);
return std::move(Parser);
}
diff --git a/llvm/lib/Remarks/RemarkLinker.cpp b/llvm/lib/Remarks/RemarkLinker.cpp
index 617ce77..dd1bba3 100644
--- a/llvm/lib/Remarks/RemarkLinker.cpp
+++ b/llvm/lib/Remarks/RemarkLinker.cpp
@@ -57,7 +57,7 @@ Remark &RemarkLinker::keep(std::unique_ptr<Remark> Remark) {
}
void RemarkLinker::setExternalFilePrependPath(StringRef PrependPathIn) {
- PrependPath = PrependPathIn;
+ PrependPath = std::string(PrependPathIn);
}
// Discard remarks with no source location.
diff --git a/llvm/lib/Remarks/YAMLRemarkParser.h b/llvm/lib/Remarks/YAMLRemarkParser.h
index 0370743..df3b908 100644
--- a/llvm/lib/Remarks/YAMLRemarkParser.h
+++ b/llvm/lib/Remarks/YAMLRemarkParser.h
@@ -35,7 +35,7 @@ public:
YAMLParseError(StringRef Message, SourceMgr &SM, yaml::Stream &Stream,
yaml::Node &Node);
- YAMLParseError(StringRef Message) : Message(Message) {}
+ YAMLParseError(StringRef Message) : Message(std::string(Message)) {}
void log(raw_ostream &OS) const override { OS << Message; }
std::error_code convertToErrorCode() const override {
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp
index 9b9cd70..c07fc6d 100644
--- a/llvm/lib/Support/APInt.cpp
+++ b/llvm/lib/Support/APInt.cpp
@@ -2283,7 +2283,7 @@ void APInt::toString(SmallVectorImpl<char> &Str, unsigned Radix,
std::string APInt::toString(unsigned Radix = 10, bool Signed = true) const {
SmallString<40> S;
toString(S, Radix, Signed, /* formatAsCLiteral = */false);
- return S.str();
+ return std::string(S.str());
}
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index cb73380..f78c4bf 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -606,7 +606,7 @@ static Option *LookupNearestOption(StringRef Arg,
Best = O;
BestDistance = Distance;
if (RHS.empty() || !PermitValue)
- NearestString = Name;
+ NearestString = std::string(Name);
else
NearestString = (Twine(Name) + "=" + RHS).str();
}
@@ -1324,7 +1324,7 @@ bool CommandLineParser::ParseCommandLineOptions(int argc,
argc = static_cast<int>(newArgv.size());
// Copy the program name into ProgName, making sure not to overflow it.
- ProgramName = sys::path::filename(StringRef(argv[0]));
+ ProgramName = std::string(sys::path::filename(StringRef(argv[0])));
ProgramOverview = Overview;
bool IgnoreErrors = Errs;
@@ -2482,7 +2482,7 @@ public:
OS << " with assertions";
#endif
#if LLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO
- std::string CPU = sys::getHostCPUName();
+ std::string CPU = std::string(sys::getHostCPUName());
if (CPU == "generic")
CPU = "(unknown)";
OS << ".\n"
diff --git a/llvm/lib/Support/Debug.cpp b/llvm/lib/Support/Debug.cpp
index 737cd57..73b25d5 100644
--- a/llvm/lib/Support/Debug.cpp
+++ b/llvm/lib/Support/Debug.cpp
@@ -105,7 +105,7 @@ struct DebugOnlyOpt {
SmallVector<StringRef,8> dbgTypes;
StringRef(Val).split(dbgTypes, ',', -1, false);
for (auto dbgType : dbgTypes)
- CurrentDebugType->push_back(dbgType);
+ CurrentDebugType->push_back(std::string(dbgType));
}
};
diff --git a/llvm/lib/Support/DebugCounter.cpp b/llvm/lib/Support/DebugCounter.cpp
index 1e3ec30..713b419 100644
--- a/llvm/lib/Support/DebugCounter.cpp
+++ b/llvm/lib/Support/DebugCounter.cpp
@@ -85,7 +85,7 @@ void DebugCounter::push_back(const std::string &Val) {
// add it to the counter values.
if (CounterPair.first.endswith("-skip")) {
auto CounterName = CounterPair.first.drop_back(5);
- unsigned CounterID = getCounterId(CounterName);
+ unsigned CounterID = getCounterId(std::string(CounterName));
if (!CounterID) {
errs() << "DebugCounter Error: " << CounterName
<< " is not a registered counter\n";
@@ -98,7 +98,7 @@ void DebugCounter::push_back(const std::string &Val) {
Counter.IsSet = true;
} else if (CounterPair.first.endswith("-count")) {
auto CounterName = CounterPair.first.drop_back(6);
- unsigned CounterID = getCounterId(CounterName);
+ unsigned CounterID = getCounterId(std::string(CounterName));
if (!CounterID) {
errs() << "DebugCounter Error: " << CounterName
<< " is not a registered counter\n";
@@ -123,7 +123,7 @@ void DebugCounter::print(raw_ostream &OS) const {
auto &Us = instance();
OS << "Counters and values:\n";
for (auto &CounterName : CounterNames) {
- unsigned CounterID = getCounterId(CounterName);
+ unsigned CounterID = getCounterId(std::string(CounterName));
OS << left_justify(RegisteredCounters[CounterID], 32) << ": {"
<< Us.Counters[CounterID].Count << "," << Us.Counters[CounterID].Skip
<< "," << Us.Counters[CounterID].StopAfter << "}\n";
diff --git a/llvm/lib/Support/FileCheck.cpp b/llvm/lib/Support/FileCheck.cpp
index d6351e8..23e1ece 100644
--- a/llvm/lib/Support/FileCheck.cpp
+++ b/llvm/lib/Support/FileCheck.cpp
@@ -1069,7 +1069,7 @@ std::string Check::FileCheckType::getDescription(StringRef Prefix) const {
case Check::CheckPlain:
if (Count > 1)
return Prefix.str() + "-COUNT";
- return Prefix;
+ return std::string(Prefix);
case Check::CheckNext:
return Prefix.str() + "-NEXT";
case Check::CheckSame:
@@ -1901,7 +1901,7 @@ Error FileCheckPatternContext::defineCmdlineVariables(
// format as in the input file to be able to reuse
// parseNumericSubstitutionBlock.
CmdlineDefsDiag += (DefPrefix + CmdlineDef + " (parsed as: [[").str();
- std::string SubstitutionStr = CmdlineDef;
+ std::string SubstitutionStr = std::string(CmdlineDef);
SubstitutionStr[EqIdx] = ':';
CmdlineDefsIndices.push_back(
std::make_pair(CmdlineDefsDiag.size(), SubstitutionStr.size()));
diff --git a/llvm/lib/Support/FileCollector.cpp b/llvm/lib/Support/FileCollector.cpp
index 47fca64..3a8bc99 100644
--- a/llvm/lib/Support/FileCollector.cpp
+++ b/llvm/lib/Support/FileCollector.cpp
@@ -51,7 +51,7 @@ bool FileCollector::getRealPath(StringRef SrcPath,
auto EC = sys::fs::real_path(Directory, RealPath);
if (EC)
return false;
- SymlinkMap[Directory] = RealPath.str();
+ SymlinkMap[Directory] = std::string(RealPath.str());
} else {
RealPath = DirWithSymlink->second;
}
diff --git a/llvm/lib/Support/GraphWriter.cpp b/llvm/lib/Support/GraphWriter.cpp
index c689a81..214a903 100644
--- a/llvm/lib/Support/GraphWriter.cpp
+++ b/llvm/lib/Support/GraphWriter.cpp
@@ -86,7 +86,7 @@ std::string llvm::createGraphFilename(const Twine &Name, int &FD) {
}
errs() << "Writing '" << Filename << "'... ";
- return Filename.str();
+ return std::string(Filename.str());
}
// Execute the graph viewer. Return true if there were errors.
@@ -147,7 +147,7 @@ static const char *getProgramName(GraphProgram::Name program) {
bool llvm::DisplayGraph(StringRef FilenameRef, bool wait,
GraphProgram::Name program) {
- std::string Filename = FilenameRef;
+ std::string Filename = std::string(FilenameRef);
std::string ErrMsg;
std::string ViewerPath;
GraphSession S;
diff --git a/llvm/lib/Support/LockFileManager.cpp b/llvm/lib/Support/LockFileManager.cpp
index 5c6508c..a4793aa 100644
--- a/llvm/lib/Support/LockFileManager.cpp
+++ b/llvm/lib/Support/LockFileManager.cpp
@@ -158,7 +158,7 @@ LockFileManager::LockFileManager(StringRef FileName)
this->FileName = FileName;
if (std::error_code EC = sys::fs::make_absolute(this->FileName)) {
std::string S("failed to obtain absolute path for ");
- S.append(this->FileName.str());
+ S.append(std::string(this->FileName.str()));
setError(EC, S);
return;
}
@@ -177,7 +177,7 @@ LockFileManager::LockFileManager(StringRef FileName)
if (std::error_code EC = sys::fs::createUniqueFile(
UniqueLockFileName, UniqueLockFileID, UniqueLockFileName)) {
std::string S("failed to create unique file ");
- S.append(UniqueLockFileName.str());
+ S.append(std::string(UniqueLockFileName.str()));
setError(EC, S);
return;
}
@@ -203,7 +203,7 @@ LockFileManager::LockFileManager(StringRef FileName)
// We failed to write out PID, so report the error, remove the
// unique lock file, and fail.
std::string S("failed to write to ");
- S.append(UniqueLockFileName.str());
+ S.append(std::string(UniqueLockFileName.str()));
setError(Out.error(), S);
sys::fs::remove(UniqueLockFileName);
return;
@@ -249,7 +249,7 @@ LockFileManager::LockFileManager(StringRef FileName)
// ownership.
if ((EC = sys::fs::remove(LockFileName))) {
std::string S("failed to remove lockfile ");
- S.append(UniqueLockFileName.str());
+ S.append(std::string(UniqueLockFileName.str()));
setError(EC, S);
return;
}
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp
index 3c9a08c..fa3bf47 100644
--- a/llvm/lib/Support/Path.cpp
+++ b/llvm/lib/Support/Path.cpp
@@ -578,7 +578,7 @@ void native(SmallVectorImpl<char> &Path, Style style) {
std::string convert_to_slash(StringRef path, Style style) {
if (real_style(style) != Style::windows)
- return path;
+ return std::string(path);
std::string s = path.str();
std::replace(s.begin(), s.end(), '\\', '/');
@@ -1114,7 +1114,7 @@ void directory_entry::replace_filename(const Twine &Filename, file_type Type,
basic_file_status Status) {
SmallString<128> PathStr = path::parent_path(Path);
path::append(PathStr, Filename);
- this->Path = PathStr.str();
+ this->Path = std::string(PathStr.str());
this->Type = Type;
this->Status = Status;
}
@@ -1142,7 +1142,8 @@ ErrorOr<perms> getPermissions(const Twine &Path) {
namespace llvm {
namespace sys {
namespace fs {
-TempFile::TempFile(StringRef Name, int FD) : TmpName(Name), FD(FD) {}
+TempFile::TempFile(StringRef Name, int FD)
+ : TmpName(std::string(Name)), FD(FD) {}
TempFile::TempFile(TempFile &&Other) { *this = std::move(Other); }
TempFile &TempFile::operator=(TempFile &&Other) {
TmpName = std::move(Other.TmpName);
diff --git a/llvm/lib/Support/Process.cpp b/llvm/lib/Support/Process.cpp
index 5b64710..0b2d41b 100644
--- a/llvm/lib/Support/Process.cpp
+++ b/llvm/lib/Support/Process.cpp
@@ -55,7 +55,7 @@ Optional<std::string> Process::FindInEnvPath(StringRef EnvName,
SmallString<128> FilePath(Dir);
path::append(FilePath, FileName);
if (fs::exists(Twine(FilePath))) {
- FoundPath = FilePath.str();
+ FoundPath = std::string(FilePath.str());
break;
}
}
diff --git a/llvm/lib/Support/Regex.cpp b/llvm/lib/Support/Regex.cpp
index 8da345d..615e48a 100644
--- a/llvm/lib/Support/Regex.cpp
+++ b/llvm/lib/Support/Regex.cpp
@@ -135,7 +135,7 @@ std::string Regex::sub(StringRef Repl, StringRef String,
// Return the input if there was no match.
if (!match(String, &Matches, Error))
- return String;
+ return std::string(String);
// Otherwise splice in the replacement string, starting with the prefix before
// the match.
diff --git a/llvm/lib/Support/Signals.cpp b/llvm/lib/Support/Signals.cpp
index add6fde..2cfdf2d 100644
--- a/llvm/lib/Support/Signals.cpp
+++ b/llvm/lib/Support/Signals.cpp
@@ -131,7 +131,7 @@ static bool printSymbolizedStackTrace(StringRef Argv0, void **StackTrace,
// If we don't know argv0 or the address of main() at this point, try
// to guess it anyway (it's possible on some platforms).
std::string MainExecutableName =
- sys::fs::exists(Argv0) ? (std::string)Argv0
+ sys::fs::exists(Argv0) ? (std::string)std::string(Argv0)
: sys::fs::getMainExecutable(nullptr, nullptr);
BumpPtrAllocator Allocator;
StringSaver StrPool(Allocator);
diff --git a/llvm/lib/Support/SourceMgr.cpp b/llvm/lib/Support/SourceMgr.cpp
index 2a241f1..acb7101b 100644
--- a/llvm/lib/Support/SourceMgr.cpp
+++ b/llvm/lib/Support/SourceMgr.cpp
@@ -256,14 +256,14 @@ void SourceMgr::PrintMessage(SMLoc Loc, SourceMgr::DiagKind Kind,
// SMDiagnostic Implementation
//===----------------------------------------------------------------------===//
-SMDiagnostic::SMDiagnostic(const SourceMgr &sm, SMLoc L, StringRef FN,
- int Line, int Col, SourceMgr::DiagKind Kind,
- StringRef Msg, StringRef LineStr,
- ArrayRef<std::pair<unsigned,unsigned>> Ranges,
+SMDiagnostic::SMDiagnostic(const SourceMgr &sm, SMLoc L, StringRef FN, int Line,
+ int Col, SourceMgr::DiagKind Kind, StringRef Msg,
+ StringRef LineStr,
+ ArrayRef<std::pair<unsigned, unsigned>> Ranges,
ArrayRef<SMFixIt> Hints)
- : SM(&sm), Loc(L), Filename(FN), LineNo(Line), ColumnNo(Col), Kind(Kind),
- Message(Msg), LineContents(LineStr), Ranges(Ranges.vec()),
- FixIts(Hints.begin(), Hints.end()) {
+ : SM(&sm), Loc(L), Filename(std::string(FN)), LineNo(Line), ColumnNo(Col),
+ Kind(Kind), Message(std::string(Msg)), LineContents(std::string(LineStr)),
+ Ranges(Ranges.vec()), FixIts(Hints.begin(), Hints.end()) {
llvm::sort(FixIts);
}
diff --git a/llvm/lib/Support/SpecialCaseList.cpp b/llvm/lib/Support/SpecialCaseList.cpp
index d1ff44c..e465451 100644
--- a/llvm/lib/Support/SpecialCaseList.cpp
+++ b/llvm/lib/Support/SpecialCaseList.cpp
@@ -172,14 +172,14 @@ bool SpecialCaseList::parse(const MemoryBuffer *MB,
}
std::pair<StringRef, StringRef> SplitRegexp = SplitLine.second.split("=");
- std::string Regexp = SplitRegexp.first;
+ std::string Regexp = std::string(SplitRegexp.first);
StringRef Category = SplitRegexp.second;
// Create this section if it has not been seen before.
if (SectionsMap.find(Section) == SectionsMap.end()) {
std::unique_ptr<Matcher> M = std::make_unique<Matcher>();
std::string REError;
- if (!M->insert(Section, LineNo, REError)) {
+ if (!M->insert(std::string(Section), LineNo, REError)) {
Error = (Twine("malformed section ") + Section + ": '" + REError).str();
return false;
}
diff --git a/llvm/lib/Support/TarWriter.cpp b/llvm/lib/Support/TarWriter.cpp
index 6136e92..6c62f88 100644
--- a/llvm/lib/Support/TarWriter.cpp
+++ b/llvm/lib/Support/TarWriter.cpp
@@ -167,7 +167,8 @@ Expected<std::unique_ptr<TarWriter>> TarWriter::create(StringRef OutputPath,
}
TarWriter::TarWriter(int FD, StringRef BaseDir)
- : OS(FD, /*shouldClose=*/true, /*unbuffered=*/false), BaseDir(BaseDir) {}
+ : OS(FD, /*shouldClose=*/true, /*unbuffered=*/false),
+ BaseDir(std::string(BaseDir)) {}
// Append a given file to an archive.
void TarWriter::append(StringRef Path, StringRef Data) {
diff --git a/llvm/lib/Support/TimeProfiler.cpp b/llvm/lib/Support/TimeProfiler.cpp
index 24da35c..4e48477 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/llvm/lib/Support/TimeProfiler.cpp
@@ -166,7 +166,7 @@ struct TimeTraceProfiler {
// Combine all CountAndTotalPerName from threads into one.
StringMap<CountAndDurationType> AllCountAndTotalPerName;
auto combineStat = [&](const auto &Stat) {
- std::string Key = Stat.getKey();
+ StringRef Key = Stat.getKey();
auto Value = Stat.getValue();
auto &CountAndTotal = AllCountAndTotalPerName[Key];
CountAndTotal.first += Value.first;
@@ -275,13 +275,14 @@ void timeTraceProfilerWrite(raw_pwrite_stream &OS) {
void timeTraceProfilerBegin(StringRef Name, StringRef Detail) {
if (TimeTraceProfilerInstance != nullptr)
- TimeTraceProfilerInstance->begin(Name, [&]() { return Detail; });
+ TimeTraceProfilerInstance->begin(std::string(Name),
+ [&]() { return std::string(Detail); });
}
void timeTraceProfilerBegin(StringRef Name,
llvm::function_ref<std::string()> Detail) {
if (TimeTraceProfilerInstance != nullptr)
- TimeTraceProfilerInstance->begin(Name, Detail);
+ TimeTraceProfilerInstance->begin(std::string(Name), Detail);
}
void timeTraceProfilerEnd() {
diff --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp
index 613d2ea..dcb96d1 100644
--- a/llvm/lib/Support/Timer.cpp
+++ b/llvm/lib/Support/Timer.cpp
@@ -247,7 +247,8 @@ TimerGroup::TimerGroup(StringRef Name, StringRef Description,
: TimerGroup(Name, Description) {
TimersToPrint.reserve(Records.size());
for (const auto &P : Records)
- TimersToPrint.emplace_back(P.getValue(), P.getKey(), P.getKey());
+ TimersToPrint.emplace_back(P.getValue(), std::string(P.getKey()),
+ std::string(P.getKey()));
assert(TimersToPrint.size() == Records.size() && "Size mismatch");
}
diff --git a/llvm/lib/Support/ToolOutputFile.cpp b/llvm/lib/Support/ToolOutputFile.cpp
index ed3a247..1051af3 100644
--- a/llvm/lib/Support/ToolOutputFile.cpp
+++ b/llvm/lib/Support/ToolOutputFile.cpp
@@ -16,7 +16,7 @@
using namespace llvm;
ToolOutputFile::CleanupInstaller::CleanupInstaller(StringRef Filename)
- : Filename(Filename), Keep(false) {
+ : Filename(std::string(Filename)), Keep(false) {
// Arrange for the file to be deleted if the process is killed.
if (Filename != "-")
sys::RemoveFileOnSignal(Filename);
diff --git a/llvm/lib/Support/Unix/Host.inc b/llvm/lib/Support/Unix/Host.inc
index 17d78dc..dfcfdd0 100644
--- a/llvm/lib/Support/Unix/Host.inc
+++ b/llvm/lib/Support/Unix/Host.inc
@@ -56,7 +56,7 @@ static std::string updateTripleOSVersion(std::string TargetTripleString) {
if (TT.getOS() == Triple::AIX && !TT.getOSMajorVersion()) {
struct utsname name;
if (uname(&name) != -1) {
- std::string NewOSName = Triple::getOSTypeName(Triple::AIX);
+ std::string NewOSName = std::string(Triple::getOSTypeName(Triple::AIX));
NewOSName += name.version;
NewOSName += '.';
NewOSName += name.release;
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc
index 520685a..c1b5d0c 100644
--- a/llvm/lib/Support/Unix/Program.inc
+++ b/llvm/lib/Support/Unix/Program.inc
@@ -70,8 +70,7 @@ ErrorOr<std::string> sys::findProgramByName(StringRef Name,
assert(!Name.empty() && "Must have a name!");
// Use the given path verbatim if it contains any slashes; this matches
// the behavior of sh(1) and friends.
- if (Name.find('/') != StringRef::npos)
- return std::string(Name);
+ if (Name.find('/') != StringRef::npos) return std::string(Name);
SmallVector<StringRef, 16> EnvironmentPaths;
if (Paths.empty())
@@ -88,7 +87,7 @@ ErrorOr<std::string> sys::findProgramByName(StringRef Name,
SmallString<128> FilePath(Path);
sys::path::append(FilePath, Name);
if (sys::fs::can_execute(FilePath.c_str()))
- return std::string(FilePath.str()); // Found the executable!
+ return std::string(FilePath.str()); // Found the executable!
}
return errc::no_such_file_or_directory;
}
@@ -101,7 +100,7 @@ static bool RedirectIO(Optional<StringRef> Path, int FD, std::string* ErrMsg) {
// Redirect empty paths to /dev/null
File = "/dev/null";
else
- File = *Path;
+ File = std::string(*Path);
// Open the file
int InFD = open(File.c_str(), FD == 0 ? O_RDONLY : O_WRONLY|O_CREAT, 0666);
@@ -213,7 +212,7 @@ static bool Execute(ProcessInfo &PI, StringRef Program,
std::string *RedirectsStr[3] = {nullptr, nullptr, nullptr};
for (int I = 0; I < 3; ++I) {
if (Redirects[I]) {
- RedirectsStorage[I] = *Redirects[I];
+ RedirectsStorage[I] = std::string(*Redirects[I]);
RedirectsStr[I] = &RedirectsStorage[I];
}
}
@@ -304,7 +303,7 @@ static bool Execute(ProcessInfo &PI, StringRef Program,
}
// Execute!
- std::string PathStr = Program;
+ std::string PathStr = std::string(Program);
if (Envp != nullptr)
execve(PathStr.c_str(), const_cast<char **>(Argv),
const_cast<char **>(Envp));
diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp
index edd4234..321ce14 100644
--- a/llvm/lib/Support/VirtualFileSystem.cpp
+++ b/llvm/lib/Support/VirtualFileSystem.cpp
@@ -306,12 +306,12 @@ RealFileSystem::openFileForRead(const Twine &Name) {
llvm::ErrorOr<std::string> RealFileSystem::getCurrentWorkingDirectory() const {
if (WD)
- return WD->Specified.str();
+ return std::string(WD->Specified.str());
SmallString<128> Dir;
if (std::error_code EC = llvm::sys::fs::current_path(Dir))
return EC;
- return Dir.str();
+ return std::string(Dir.str());
}
std::error_code RealFileSystem::setCurrentWorkingDirectory(const Twine &Path) {
@@ -535,7 +535,8 @@ class InMemoryNode {
public:
InMemoryNode(llvm::StringRef FileName, InMemoryNodeKind Kind)
- : Kind(Kind), FileName(llvm::sys::path::filename(FileName)) {}
+ : Kind(Kind), FileName(std::string(llvm::sys::path::filename(FileName))) {
+ }
virtual ~InMemoryNode() = default;
/// Get the filename of this node (the name without the directory part).
@@ -904,7 +905,7 @@ class InMemoryDirIterator : public llvm::vfs::detail::DirIterImpl {
Type = sys::fs::file_type::directory_file;
break;
}
- CurrentEntry = directory_entry(Path.str(), Type);
+ CurrentEntry = directory_entry(std::string(Path.str()), Type);
} else {
// When we're at the end, make CurrentEntry invalid and DirIterImpl will
// do the rest.
@@ -960,7 +961,7 @@ std::error_code InMemoryFileSystem::setCurrentWorkingDirectory(const Twine &P) {
llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
if (!Path.empty())
- WorkingDirectory = Path.str();
+ WorkingDirectory = std::string(Path.str());
return {};
}
@@ -1064,7 +1065,7 @@ RedirectingFileSystem::setCurrentWorkingDirectory(const Twine &Path) {
Path.toVector(AbsolutePath);
if (std::error_code EC = makeAbsolute(AbsolutePath))
return EC;
- WorkingDirectory = AbsolutePath.str();
+ WorkingDirectory = std::string(AbsolutePath.str());
return {};
}
@@ -1347,9 +1348,9 @@ class llvm::vfs::RedirectingFileSystemParser {
// are properly canonicalized before read into the VFS.
Path = sys::path::remove_leading_dotslash(Path);
sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
- Name = Path.str();
+ Name = std::string(Path.str());
} else {
- Name = Value;
+ Name = std::string(Value);
}
} else if (Key == "type") {
if (!parseScalarString(I.getValue(), Value, Buffer))
@@ -1409,7 +1410,7 @@ class llvm::vfs::RedirectingFileSystemParser {
FullPath = sys::path::remove_leading_dotslash(FullPath);
sys::path::remove_dots(FullPath, /*remove_dot_dot=*/true);
}
- ExternalContentsPath = FullPath.str();
+ ExternalContentsPath = std::string(FullPath.str());
} else if (Key == "use-external-name") {
bool Val;
if (!parseScalarBool(I.getValue(), Val))
@@ -2104,7 +2105,7 @@ std::error_code VFSFromYamlDirIterImpl::incrementContent(bool IsFirstTime) {
Type = sys::fs::file_type::regular_file;
break;
}
- CurrentEntry = directory_entry(PathStr.str(), Type);
+ CurrentEntry = directory_entry(std::string(PathStr.str()), Type);
return {};
}
return incrementExternal();
diff --git a/llvm/lib/Support/YAMLParser.cpp b/llvm/lib/Support/YAMLParser.cpp
index d17e7b2..db1eb66 100644
--- a/llvm/lib/Support/YAMLParser.cpp
+++ b/llvm/lib/Support/YAMLParser.cpp
@@ -1819,11 +1819,11 @@ std::string Node::getVerbatimTag() const {
if (!Raw.empty() && Raw != "!") {
std::string Ret;
if (Raw.find_last_of('!') == 0) {
- Ret = Doc->getTagMap().find("!")->second;
+ Ret = std::string(Doc->getTagMap().find("!")->second);
Ret += Raw.substr(1);
return Ret;
} else if (Raw.startswith("!!")) {
- Ret = Doc->getTagMap().find("!!")->second;
+ Ret = std::string(Doc->getTagMap().find("!!")->second);
Ret += Raw.substr(2);
return Ret;
} else {
@@ -1831,7 +1831,7 @@ std::string Node::getVerbatimTag() const {
std::map<StringRef, StringRef>::const_iterator It =
Doc->getTagMap().find(TagHandle);
if (It != Doc->getTagMap().end())
- Ret = It->second;
+ Ret = std::string(It->second);
else {
Token T;
T.Kind = Token::TK_Tag;
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index 9db842d..54ff9ae 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -1183,21 +1183,22 @@ Init *TernOpInit::Fold(Record *CurRec) const {
return DefInit::get(Val);
}
if (LHSv && MHSv && RHSv) {
- std::string Val = RHSv->getName();
+ std::string Val = std::string(RHSv->getName());
if (LHSv->getAsString() == RHSv->getAsString())
- Val = MHSv->getName();
+ Val = std::string(MHSv->getName());
return VarInit::get(Val, getType());
}
if (LHSs && MHSs && RHSs) {
- std::string Val = RHSs->getValue();
+ std::string Val = std::string(RHSs->getValue());
std::string::size_type found;
std::string::size_type idx = 0;
while (true) {
- found = Val.find(LHSs->getValue(), idx);
+ found = Val.find(std::string(LHSs->getValue()), idx);
if (found == std::string::npos)
break;
- Val.replace(found, LHSs->getValue().size(), MHSs->getValue());
+ Val.replace(found, LHSs->getValue().size(),
+ std::string(MHSs->getValue()));
idx = found + MHSs->getValue().size();
}
@@ -1612,9 +1613,7 @@ RecTy *DefInit::getFieldType(StringInit *FieldName) const {
return nullptr;
}
-std::string DefInit::getAsString() const {
- return Def->getName();
-}
+std::string DefInit::getAsString() const { return std::string(Def->getName()); }
static void ProfileVarDefInit(FoldingSetNodeID &ID,
Record *Class,
diff --git a/llvm/lib/TableGen/SetTheory.cpp b/llvm/lib/TableGen/SetTheory.cpp
index 5a30ee9..0389bd3 100644
--- a/llvm/lib/TableGen/SetTheory.cpp
+++ b/llvm/lib/TableGen/SetTheory.cpp
@@ -191,7 +191,7 @@ struct SequenceOp : public SetTheory::Operator {
std::string Format;
if (StringInit *SI = dyn_cast<StringInit>(Expr->arg_begin()[0]))
- Format = SI->getValue();
+ Format = std::string(SI->getValue());
else
PrintFatalError(Loc, "Format must be a string: " + Expr->getAsString());
diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp
index 01cc1af..1b2809a 100644
--- a/llvm/lib/TableGen/TGParser.cpp
+++ b/llvm/lib/TableGen/TGParser.cpp
@@ -3294,7 +3294,7 @@ bool TGParser::ParseDefm(MultiClass *CurMultiClass) {
// To instantiate a multiclass, we need to first get the multiclass, then
// instantiate each def contained in the multiclass with the SubClassRef
// template parameters.
- MultiClass *MC = MultiClasses[Ref.Rec->getName()].get();
+ MultiClass *MC = MultiClasses[std::string(Ref.Rec->getName())].get();
assert(MC && "Didn't lookup multiclass correctly?");
ArrayRef<Init*> TemplateVals = Ref.TemplateArgs;
diff --git a/llvm/lib/Target/AArch64/AArch64SIMDInstrOpt.cpp b/llvm/lib/Target/AArch64/AArch64SIMDInstrOpt.cpp
index 28a7e68..fc31e70 100644
--- a/llvm/lib/Target/AArch64/AArch64SIMDInstrOpt.cpp
+++ b/llvm/lib/Target/AArch64/AArch64SIMDInstrOpt.cpp
@@ -219,7 +219,7 @@ shouldReplaceInst(MachineFunction *MF, const MCInstrDesc *InstDesc,
SmallVectorImpl<const MCInstrDesc*> &InstDescRepl) {
// Check if replacement decision is already available in the cached table.
// if so, return it.
- std::string Subtarget = SchedModel.getSubtargetInfo()->getCPU();
+ std::string Subtarget = std::string(SchedModel.getSubtargetInfo()->getCPU());
auto InstID = std::make_pair(InstDesc->getOpcode(), Subtarget);
if (SIMDInstrTable.find(InstID) != SIMDInstrTable.end())
return SIMDInstrTable[InstID];
@@ -288,7 +288,8 @@ bool AArch64SIMDInstrOpt::shouldExitEarly(MachineFunction *MF, Subpass SP) {
// For this optimization, check for all concerned instructions.
case Interleave:
- std::string Subtarget = SchedModel.getSubtargetInfo()->getCPU();
+ std::string Subtarget =
+ std::string(SchedModel.getSubtargetInfo()->getCPU());
if (InterlEarlyExit.find(Subtarget) != InterlEarlyExit.end())
return InterlEarlyExit[Subtarget];
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp b/llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp
index 511d629..4a39d9e 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp
@@ -47,7 +47,7 @@ void MetadataStreamerV2::verify(StringRef HSAMetadataString) const {
errs() << "AMDGPU HSA Metadata Parser Test: ";
HSAMD::Metadata FromHSAMetadataString;
- if (fromString(HSAMetadataString, FromHSAMetadataString)) {
+ if (fromString(std::string(HSAMetadataString), FromHSAMetadataString)) {
errs() << "FAIL\n";
return;
}
@@ -259,7 +259,8 @@ void MetadataStreamerV2::emitPrintf(const Module &Mod) {
for (auto Op : Node->operands())
if (Op->getNumOperands())
- Printf.push_back(cast<MDString>(Op->getOperand(0))->getString());
+ Printf.push_back(
+ std::string(cast<MDString>(Op->getOperand(0))->getString()));
}
void MetadataStreamerV2::emitKernelLanguage(const Function &Func) {
@@ -367,8 +368,8 @@ void MetadataStreamerV2::emitKernelArg(const DataLayout &DL, Type *Ty,
HSAMetadata.mKernels.back().mArgs.push_back(Kernel::Arg::Metadata());
auto &Arg = HSAMetadata.mKernels.back().mArgs.back();
- Arg.mName = Name;
- Arg.mTypeName = TypeName;
+ Arg.mName = std::string(Name);
+ Arg.mTypeName = std::string(TypeName);
Arg.mSize = DL.getTypeAllocSize(Ty);
Arg.mAlign = DL.getABITypeAlignment(Ty);
Arg.mValueKind = ValueKind;
@@ -479,7 +480,7 @@ void MetadataStreamerV2::emitKernel(const MachineFunction &MF,
HSAMetadata.mKernels.push_back(Kernel::Metadata());
auto &Kernel = HSAMetadata.mKernels.back();
- Kernel.mName = Func.getName();
+ Kernel.mName = std::string(Func.getName());
Kernel.mSymbolName = (Twine(Func.getName()) + Twine("@kd")).str();
emitKernelLanguage(Func);
emitKernelAttrs(Func);
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp b/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
index 0c56927..98931c7 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
@@ -585,7 +585,7 @@ bool AMDGPULibCalls::fold_read_write_pipe(CallInst *CI, IRBuilder<> &B,
assert(Callee->hasName() && "Invalid read_pipe/write_pipe function");
auto *M = Callee->getParent();
auto &Ctx = M->getContext();
- std::string Name = Callee->getName();
+ std::string Name = std::string(Callee->getName());
auto NumArg = CI->getNumArgOperands();
if (NumArg != 4 && NumArg != 6)
return false;
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULibFunc.cpp b/llvm/lib/Target/AMDGPU/AMDGPULibFunc.cpp
index e1ae496..1f14eb3 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULibFunc.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULibFunc.cpp
@@ -863,7 +863,7 @@ std::string AMDGPUMangledLibFunc::mangleNameItanium() const {
Param P;
while ((P = I.getNextParam()).ArgType != 0)
Mangler(S, P);
- return S.str();
+ return std::string(S.str());
}
///////////////////////////////////////////////////////////////////////////////
@@ -936,7 +936,7 @@ std::string AMDGPUMangledLibFunc::getName() const {
SmallString<128> Buf;
raw_svector_ostream OS(Buf);
writeName(OS);
- return OS.str();
+ return std::string(OS.str());
}
Function *AMDGPULibFunc::getFunction(Module *M, const AMDGPULibFunc &fInfo) {
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULibFunc.h b/llvm/lib/Target/AMDGPU/AMDGPULibFunc.h
index 2354ed7..f43b88f 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULibFunc.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPULibFunc.h
@@ -341,7 +341,7 @@ public:
/// and unmangled function name for unmangled library functions.
virtual std::string mangle() const = 0;
- void setName(StringRef N) { Name = N; }
+ void setName(StringRef N) { Name = std::string(N); }
void setPrefix(ENamePrefix pfx) { FKind = pfx; }
virtual FunctionType *getFunctionType(Module &M) const = 0;
@@ -438,7 +438,7 @@ class AMDGPUUnmangledLibFunc : public AMDGPULibFuncImpl {
public:
explicit AMDGPUUnmangledLibFunc();
explicit AMDGPUUnmangledLibFunc(StringRef FName, FunctionType *FT) {
- Name = FName;
+ Name = std::string(FName);
FuncTy = FT;
}
std::string getName() const override { return Name; }
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPropagateAttributes.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPropagateAttributes.cpp
index 7a7addd..68fa5ba 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUPropagateAttributes.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUPropagateAttributes.cpp
@@ -273,7 +273,7 @@ AMDGPUPropagateAttributes::cloneWithFeatures(Function &F,
// Swap names. If that is the only clone it will retain the name of now
// dead value.
if (F.hasName()) {
- std::string NewName = NewF->getName();
+ std::string NewName = std::string(NewF->getName());
NewF->takeName(&F);
F.setName(NewName);
diff --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index f3aa1a5..ea70307 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -6499,7 +6499,7 @@ OperandMatchResultTy AMDGPUAsmParser::parseDim(OperandVector &Operands) {
std::string Token;
if (getLexer().is(AsmToken::Integer)) {
SMLoc Loc = getLexer().getTok().getEndLoc();
- Token = getLexer().getTok().getString();
+ Token = std::string(getLexer().getTok().getString());
Parser.Lex();
if (getLexer().getTok().getLoc() != Loc)
return MatchOperand_ParseFail;
diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
index fef665c..31a9b4b 100644
--- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
+++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
@@ -43,7 +43,7 @@ using namespace llvm::AMDGPU::HSAMD;
bool AMDGPUTargetStreamer::EmitHSAMetadataV2(StringRef HSAMetadataString) {
HSAMD::Metadata HSAMetadata;
- if (HSAMD::fromString(HSAMetadataString, HSAMetadata))
+ if (HSAMD::fromString(std::string(HSAMetadataString), HSAMetadata))
return false;
return EmitHSAMetadata(HSAMetadata);
diff --git a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp
index 6f26ca1..14d4018 100644
--- a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp
+++ b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp
@@ -606,11 +606,12 @@ void ARMAsmPrinter::emitAttributes() {
if (!ArchFS.empty())
ArchFS = (Twine(ArchFS) + "," + FS).str();
else
- ArchFS = FS;
+ ArchFS = std::string(FS);
}
const ARMBaseTargetMachine &ATM =
static_cast<const ARMBaseTargetMachine &>(TM);
- const ARMSubtarget STI(TT, CPU, ArchFS, ATM, ATM.isLittleEndian());
+ const ARMSubtarget STI(TT, std::string(CPU), ArchFS, ATM,
+ ATM.isLittleEndian());
// Emit build attributes for the available hardware.
ATS.emitTargetAttributes(STI);
diff --git a/llvm/lib/Target/ARM/ARMConstantPoolValue.cpp b/llvm/lib/Target/ARM/ARMConstantPoolValue.cpp
index 72c95f4..a7706a18 100644
--- a/llvm/lib/Target/ARM/ARMConstantPoolValue.cpp
+++ b/llvm/lib/Target/ARM/ARMConstantPoolValue.cpp
@@ -228,7 +228,7 @@ ARMConstantPoolSymbol::ARMConstantPoolSymbol(LLVMContext &C, StringRef s,
bool AddCurrentAddress)
: ARMConstantPoolValue(C, id, ARMCP::CPExtSymbol, PCAdj, Modifier,
AddCurrentAddress),
- S(s) {}
+ S(std::string(s)) {}
ARMConstantPoolSymbol *ARMConstantPoolSymbol::Create(LLVMContext &C,
StringRef s, unsigned ID,
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index b6e631e..24bb764f 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -15958,7 +15958,7 @@ bool ARMTargetLowering::ExpandInlineAsm(CallInst *CI) const {
switch (AsmPieces.size()) {
default: return false;
case 1:
- AsmStr = AsmPieces[0];
+ AsmStr = std::string(AsmPieces[0]);
AsmPieces.clear();
SplitString(AsmStr, AsmPieces, " \t,");
diff --git a/llvm/lib/Target/ARM/ARMSubtarget.cpp b/llvm/lib/Target/ARM/ARMSubtarget.cpp
index eb4d39b..e87b248 100644
--- a/llvm/lib/Target/ARM/ARMSubtarget.cpp
+++ b/llvm/lib/Target/ARM/ARMSubtarget.cpp
@@ -183,7 +183,7 @@ void ARMSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
if (!ArchFS.empty())
ArchFS = (Twine(ArchFS) + "," + FS).str();
else
- ArchFS = FS;
+ ArchFS = std::string(FS);
}
ParseSubtargetFeatures(CPUString, ArchFS);
diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
index f558ca8..276ff26 100644
--- a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
+++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
@@ -328,12 +328,8 @@ private:
}
// Create new attribute item
- AttributeItem Item = {
- AttributeItem::NumericAttribute,
- Attribute,
- Value,
- StringRef("")
- };
+ AttributeItem Item = {AttributeItem::NumericAttribute, Attribute, Value,
+ std::string(StringRef(""))};
Contents.push_back(Item);
}
@@ -344,17 +340,13 @@ private:
if (!OverwriteExisting)
return;
Item->Type = AttributeItem::TextAttribute;
- Item->StringValue = Value;
+ Item->StringValue = std::string(Value);
return;
}
// Create new attribute item
- AttributeItem Item = {
- AttributeItem::TextAttribute,
- Attribute,
- 0,
- Value
- };
+ AttributeItem Item = {AttributeItem::TextAttribute, Attribute, 0,
+ std::string(Value)};
Contents.push_back(Item);
}
@@ -366,17 +358,13 @@ private:
return;
Item->Type = AttributeItem::NumericAndTextAttributes;
Item->IntValue = IntValue;
- Item->StringValue = StringValue;
+ Item->StringValue = std::string(StringValue);
return;
}
// Create new attribute item
- AttributeItem Item = {
- AttributeItem::NumericAndTextAttributes,
- Attribute,
- IntValue,
- StringValue
- };
+ AttributeItem Item = {AttributeItem::NumericAndTextAttributes, Attribute,
+ IntValue, std::string(StringValue)};
Contents.push_back(Item);
}
diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
index 9f60e70..1540796 100644
--- a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
+++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
@@ -168,7 +168,7 @@ MCSubtargetInfo *ARM_MC::createARMMCSubtargetInfo(const Triple &TT,
if (!ArchFS.empty())
ArchFS = (Twine(ArchFS) + "," + FS).str();
else
- ArchFS = FS;
+ ArchFS = std::string(FS);
}
return createARMMCSubtargetInfoImpl(TT, CPU, ArchFS);
diff --git a/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp b/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
index a28816c..4379d49 100644
--- a/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
+++ b/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
@@ -731,7 +731,7 @@ Value *BPFAbstractMemberAccess::computeBaseAndAccessKey(CallInst *Call,
if (CInfo.Kind == BPFPreserveUnionAI ||
CInfo.Kind == BPFPreserveStructAI) {
// struct or union type
- TypeName = Ty->getName();
+ TypeName = std::string(Ty->getName());
TypeMeta = Ty;
PatchImm += FirstIndex * (Ty->getSizeInBits() >> 3);
break;
@@ -782,7 +782,7 @@ Value *BPFAbstractMemberAccess::computeBaseAndAccessKey(CallInst *Call,
unsigned CTag = CTy->getTag();
if (CTag == dwarf::DW_TAG_structure_type || CTag == dwarf::DW_TAG_union_type) {
- TypeName = CTy->getName();
+ TypeName = std::string(CTy->getName());
} else {
if (HasPreserveFieldInfoCall(CallStack))
report_fatal_error("Invalid field access for llvm.preserve.field.info intrinsic");
diff --git a/llvm/lib/Target/BPF/BPFTargetMachine.cpp b/llvm/lib/Target/BPF/BPFTargetMachine.cpp
index 40375bc..d2a332c 100644
--- a/llvm/lib/Target/BPF/BPFTargetMachine.cpp
+++ b/llvm/lib/Target/BPF/BPFTargetMachine.cpp
@@ -63,7 +63,7 @@ BPFTargetMachine::BPFTargetMachine(const Target &T, const Triple &TT,
getEffectiveRelocModel(RM),
getEffectiveCodeModel(CM, CodeModel::Small), OL),
TLOF(std::make_unique<TargetLoweringObjectFileELF>()),
- Subtarget(TT, CPU, FS, *this) {
+ Subtarget(TT, std::string(CPU), std::string(FS), *this) {
initAsmInfo();
BPFMCAsmInfo *MAI =
diff --git a/llvm/lib/Target/BPF/BTFDebug.cpp b/llvm/lib/Target/BPF/BTFDebug.cpp
index a9fb04f..e868cca 100644
--- a/llvm/lib/Target/BPF/BTFDebug.cpp
+++ b/llvm/lib/Target/BPF/BTFDebug.cpp
@@ -259,7 +259,7 @@ void BTFTypeStruct::emitType(MCStreamer &OS) {
}
}
-std::string BTFTypeStruct::getName() { return STy->getName(); }
+std::string BTFTypeStruct::getName() { return std::string(STy->getName()); }
/// The Func kind represents both subprogram and pointee of function
/// pointers. If the FuncName is empty, it represents a pointee of function
@@ -374,7 +374,7 @@ uint32_t BTFStringTable::addString(StringRef S) {
// Not find, add to the string table.
uint32_t Offset = Size;
OffsetToIdMap[Offset] = Table.size();
- Table.push_back(S);
+ Table.push_back(std::string(S));
Size += S.size() + 1;
return Offset;
}
@@ -667,7 +667,7 @@ std::string BTFDebug::populateFileContent(const DISubprogram *SP) {
if (!File->getFilename().startswith("/") && File->getDirectory().size())
FileName = File->getDirectory().str() + "/" + File->getFilename().str();
else
- FileName = File->getFilename();
+ FileName = std::string(File->getFilename());
// No need to populate the contends if it has been populated!
if (FileContent.find(FileName) != FileContent.end())
@@ -686,7 +686,7 @@ std::string BTFDebug::populateFileContent(const DISubprogram *SP) {
Buf = std::move(*BufOrErr);
if (Buf)
for (line_iterator I(*Buf, false), E; I != E; ++I)
- Content.push_back(*I);
+ Content.push_back(std::string(*I));
FileContent[FileName] = Content;
return FileName;
@@ -955,8 +955,8 @@ void BTFDebug::generateFieldReloc(const MCSymbol *ORSym, DIType *RootTy,
FieldReloc.Label = ORSym;
FieldReloc.OffsetNameOff = addString(IndexPattern);
FieldReloc.TypeID = RootId;
- FieldReloc.RelocKind = std::stoull(RelocKindStr);
- PatchImms[AccessPattern.str()] = std::stoul(PatchImmStr);
+ FieldReloc.RelocKind = std::stoull(std::string(RelocKindStr));
+ PatchImms[AccessPattern.str()] = std::stoul(std::string(PatchImmStr));
FieldRelocTable[SecNameOff].push_back(FieldReloc);
}
@@ -1119,15 +1119,17 @@ void BTFDebug::processGlobals(bool ProcessingMapDef) {
assert(!SecName.empty());
// Find or create a DataSec
- if (DataSecEntries.find(SecName) == DataSecEntries.end()) {
- DataSecEntries[SecName] = std::make_unique<BTFKindDataSec>(Asm, SecName);
+ if (DataSecEntries.find(std::string(SecName)) == DataSecEntries.end()) {
+ DataSecEntries[std::string(SecName)] =
+ std::make_unique<BTFKindDataSec>(Asm, std::string(SecName));
}
// Calculate symbol size
const DataLayout &DL = Global.getParent()->getDataLayout();
uint32_t Size = DL.getTypeAllocSize(Global.getType()->getElementType());
- DataSecEntries[SecName]->addVar(VarId, Asm->getSymbol(&Global), Size);
+ DataSecEntries[std::string(SecName)]->addVar(VarId, Asm->getSymbol(&Global),
+ Size);
}
}
diff --git a/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp b/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
index 2f12ea6a..5976a81 100644
--- a/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
+++ b/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
@@ -942,7 +942,7 @@ bool HexagonAsmParser::isLabel(AsmToken &Token) {
assert(Second.is(AsmToken::Colon));
StringRef Raw(String.data(), Third.getString().data() - String.data() +
Third.getString().size());
- std::string Collapsed = Raw;
+ std::string Collapsed = std::string(Raw);
Collapsed.erase(llvm::remove_if(Collapsed, isspace), Collapsed.end());
StringRef Whole = Collapsed;
std::pair<StringRef, StringRef> DotSplit = Whole.split('.');
@@ -988,7 +988,7 @@ bool HexagonAsmParser::ParseRegister(unsigned &RegNo, SMLoc &StartLoc,
Again = (Contigious && Type) || (Workaround && Type);
NeededWorkaround = NeededWorkaround || (Again && !(Contigious && Type));
}
- std::string Collapsed = RawString;
+ std::string Collapsed = std::string(RawString);
Collapsed.erase(llvm::remove_if(Collapsed, isspace), Collapsed.end());
StringRef FullString = Collapsed;
std::pair<StringRef, StringRef> DotSplit = FullString.split('.');
diff --git a/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp b/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp
index adeb3e0c..7bcc956 100644
--- a/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp
@@ -75,12 +75,11 @@ static cl::opt<bool> EnableCheckBankConflict("hexagon-check-bank-conflict",
cl::Hidden, cl::ZeroOrMore, cl::init(true),
cl::desc("Enable checking for cache bank conflicts"));
-
HexagonSubtarget::HexagonSubtarget(const Triple &TT, StringRef CPU,
StringRef FS, const TargetMachine &TM)
: HexagonGenSubtargetInfo(TT, CPU, FS), OptLevel(TM.getOptLevel()),
- CPUString(Hexagon_MC::selectHexagonCPU(CPU)), TargetTriple(TT),
- InstrInfo(initializeSubtargetDependencies(CPU, FS)),
+ CPUString(std::string(Hexagon_MC::selectHexagonCPU(CPU))),
+ TargetTriple(TT), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
RegInfo(getHwMode()), TLInfo(TM, *this),
InstrItins(getInstrItineraryForCPU(CPUString)) {
Hexagon_MC::addArchSubtarget(this, FS);
diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
index aa03857..ac5ba87 100644
--- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
+++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
@@ -390,7 +390,7 @@ namespace {
std::pair<std::string, std::string> selectCPUAndFS(StringRef CPU,
StringRef FS) {
std::pair<std::string, std::string> Result;
- Result.first = Hexagon_MC::selectHexagonCPU(CPU);
+ Result.first = std::string(Hexagon_MC::selectHexagonCPU(CPU));
Result.second = selectHexagonFS(Result.first, FS);
return Result;
}
diff --git a/llvm/lib/Target/Lanai/LanaiSubtarget.cpp b/llvm/lib/Target/Lanai/LanaiSubtarget.cpp
index 9a872c7..ebf91e0 100644
--- a/llvm/lib/Target/Lanai/LanaiSubtarget.cpp
+++ b/llvm/lib/Target/Lanai/LanaiSubtarget.cpp
@@ -23,7 +23,7 @@
using namespace llvm;
void LanaiSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
- std::string CPUName = CPU;
+ std::string CPUName = std::string(CPU);
if (CPUName.empty())
CPUName = "generic";
diff --git a/llvm/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp b/llvm/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp
index 9de15bf..2ff8932 100644
--- a/llvm/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp
+++ b/llvm/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp
@@ -52,7 +52,7 @@ static MCRegisterInfo *createLanaiMCRegisterInfo(const Triple & /*TT*/) {
static MCSubtargetInfo *
createLanaiMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
- std::string CPUName = CPU;
+ std::string CPUName = std::string(CPU);
if (CPUName.empty())
CPUName = "generic";
diff --git a/llvm/lib/Target/MSP430/MSP430Subtarget.cpp b/llvm/lib/Target/MSP430/MSP430Subtarget.cpp
index 2016877..1f3c1d3 100644
--- a/llvm/lib/Target/MSP430/MSP430Subtarget.cpp
+++ b/llvm/lib/Target/MSP430/MSP430Subtarget.cpp
@@ -43,7 +43,7 @@ MSP430Subtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
ExtendedInsts = false;
HWMultMode = NoHWMult;
- std::string CPUName = CPU;
+ StringRef CPUName = CPU;
if (CPUName.empty())
CPUName = "msp430";
diff --git a/llvm/lib/Target/MSP430/MSP430TargetMachine.cpp b/llvm/lib/Target/MSP430/MSP430TargetMachine.cpp
index 8185142..827f24d 100644
--- a/llvm/lib/Target/MSP430/MSP430TargetMachine.cpp
+++ b/llvm/lib/Target/MSP430/MSP430TargetMachine.cpp
@@ -47,7 +47,7 @@ MSP430TargetMachine::MSP430TargetMachine(const Target &T, const Triple &TT,
Options, getEffectiveRelocModel(RM),
getEffectiveCodeModel(CM, CodeModel::Small), OL),
TLOF(std::make_unique<TargetLoweringObjectFileELF>()),
- Subtarget(TT, CPU, FS, *this) {
+ Subtarget(TT, std::string(CPU), std::string(FS), *this) {
initAsmInfo();
}
diff --git a/llvm/lib/Target/Mips/Mips16HardFloat.cpp b/llvm/lib/Target/Mips/Mips16HardFloat.cpp
index e9a3c7e..10a7451 100644
--- a/llvm/lib/Target/Mips/Mips16HardFloat.cpp
+++ b/llvm/lib/Target/Mips/Mips16HardFloat.cpp
@@ -260,7 +260,7 @@ static void assureFPCallStub(Function &F, Module *M,
return;
LLVMContext &Context = M->getContext();
bool LE = TM.isLittleEndian();
- std::string Name = F.getName();
+ std::string Name(F.getName());
std::string SectionName = ".mips16.call.fp." + Name;
std::string StubName = "__call_stub_fp_" + Name;
//
@@ -448,7 +448,7 @@ static void createFPFnStub(Function *F, Module *M, FPParamVariant PV,
bool PicMode = TM.isPositionIndependent();
bool LE = TM.isLittleEndian();
LLVMContext &Context = M->getContext();
- std::string Name = F->getName();
+ std::string Name(F->getName());
std::string SectionName = ".mips16.fn." + Name;
std::string StubName = "__fn_stub_" + Name;
std::string LocalName = "$$__fn_local_" + Name;
diff --git a/llvm/lib/Target/Mips/MipsRegisterBankInfo.cpp b/llvm/lib/Target/Mips/MipsRegisterBankInfo.cpp
index 3b96738..225cfa0 100644
--- a/llvm/lib/Target/Mips/MipsRegisterBankInfo.cpp
+++ b/llvm/lib/Target/Mips/MipsRegisterBankInfo.cpp
@@ -362,7 +362,7 @@ MipsRegisterBankInfo::TypeInfoForMF::determineInstType(const MachineInstr *MI) {
void MipsRegisterBankInfo::TypeInfoForMF::cleanupIfNewFunction(
llvm::StringRef FunctionName) {
if (MFName != FunctionName) {
- MFName = FunctionName;
+ MFName = std::string(FunctionName);
WaitingQueues.clear();
Types.clear();
}
diff --git a/llvm/lib/Target/Mips/MipsSubtarget.cpp b/llvm/lib/Target/Mips/MipsSubtarget.cpp
index 133b8181..ef4191c 100644
--- a/llvm/lib/Target/Mips/MipsSubtarget.cpp
+++ b/llvm/lib/Target/Mips/MipsSubtarget.cpp
@@ -237,7 +237,7 @@ CodeGenOpt::Level MipsSubtarget::getOptLevelToEnablePostRAScheduler() const {
MipsSubtarget &
MipsSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS,
const TargetMachine &TM) {
- std::string CPUName = MIPS_MC::selectMipsCPU(TM.getTargetTriple(), CPU);
+ StringRef CPUName = MIPS_MC::selectMipsCPU(TM.getTargetTriple(), CPU);
// Parse features string.
ParseSubtargetFeatures(CPUName, FS);
diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
index 7117438..4bb3ef8 100644
--- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -982,7 +982,7 @@ void NVPTXAsmPrinter::emitLinkageDirective(const GlobalValue *V,
msg.append("Error: ");
msg.append("Symbol ");
if (V->hasName())
- msg.append(V->getName());
+ msg.append(std::string(V->getName()));
msg.append("has unsupported appending linkage type");
llvm_unreachable(msg.c_str());
} else if (!V->hasInternalLinkage() &&
@@ -1439,7 +1439,7 @@ void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) {
if (isKernelFunction(*F)) {
if (isSampler(*I) || isImage(*I)) {
if (isImage(*I)) {
- std::string sname = I->getName();
+ std::string sname = std::string(I->getName());
if (isImageWriteOnly(*I) || isImageReadWrite(*I)) {
if (hasImageHandles)
O << "\t.param .u64 .ptr .surfref ";
diff --git a/llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp b/llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp
index b36d9b2..9078ff8 100644
--- a/llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp
@@ -144,7 +144,7 @@ bool GenericToNVVM::runOnModule(Module &M) {
// variable initializers, as other uses have been already been removed
// while walking through the instructions in function definitions.
GV->replaceAllUsesWith(BitCastNewGV);
- std::string Name = GV->getName();
+ std::string Name = std::string(GV->getName());
GV->eraseFromParent();
NewGV->setName(Name);
}
diff --git a/llvm/lib/Target/NVPTX/NVPTXReplaceImageHandles.cpp b/llvm/lib/Target/NVPTX/NVPTXReplaceImageHandles.cpp
index e213089e..8ae5421 100644
--- a/llvm/lib/Target/NVPTX/NVPTXReplaceImageHandles.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXReplaceImageHandles.cpp
@@ -152,7 +152,7 @@ findIndexForHandle(MachineOperand &Op, MachineFunction &MF, unsigned &Idx) {
assert(TexHandleDef.getOperand(6).isSymbol() && "Load is not a symbol!");
StringRef Sym = TexHandleDef.getOperand(6).getSymbolName();
- std::string ParamBaseName = MF.getName();
+ std::string ParamBaseName = std::string(MF.getName());
ParamBaseName += "_param_";
assert(Sym.startswith(ParamBaseName) && "Invalid symbol reference");
unsigned Param = atoi(Sym.data()+ParamBaseName.size());
diff --git a/llvm/lib/Target/NVPTX/NVPTXSubtarget.cpp b/llvm/lib/Target/NVPTX/NVPTXSubtarget.cpp
index 357826c..f1fa641 100644
--- a/llvm/lib/Target/NVPTX/NVPTXSubtarget.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXSubtarget.cpp
@@ -33,13 +33,13 @@ void NVPTXSubtarget::anchor() {}
NVPTXSubtarget &NVPTXSubtarget::initializeSubtargetDependencies(StringRef CPU,
StringRef FS) {
// Provide the default CPU if we don't have one.
- TargetName = CPU.empty() ? "sm_20" : CPU;
+ TargetName = std::string(CPU.empty() ? "sm_20" : CPU);
- ParseSubtargetFeatures(TargetName, FS);
+ ParseSubtargetFeatures(TargetName, FS);
- // Set default to PTX 3.2 (CUDA 5.5)
- if (PTXVersion == 0) {
- PTXVersion = 32;
+ // Set default to PTX 3.2 (CUDA 5.5)
+ if (PTXVersion == 0) {
+ PTXVersion = 32;
}
return *this;
diff --git a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
index 0778706..77487d1 100644
--- a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
@@ -117,7 +117,7 @@ NVPTXTargetMachine::NVPTXTargetMachine(const Target &T, const Triple &TT,
getEffectiveCodeModel(CM, CodeModel::Small), OL),
is64bit(is64bit), UseShortPointers(UseShortPointersOpt),
TLOF(std::make_unique<NVPTXTargetObjectFile>()),
- Subtarget(TT, CPU, FS, *this) {
+ Subtarget(TT, std::string(CPU), std::string(FS), *this) {
if (TT.getOS() == Triple::NVCL)
drvInterface = NVPTX::NVCL;
else
diff --git a/llvm/lib/Target/NVPTX/NVPTXUtilities.cpp b/llvm/lib/Target/NVPTX/NVPTXUtilities.cpp
index 43c2e99..74d129d 100644
--- a/llvm/lib/Target/NVPTX/NVPTXUtilities.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXUtilities.cpp
@@ -226,17 +226,17 @@ bool isManaged(const Value &val) {
std::string getTextureName(const Value &val) {
assert(val.hasName() && "Found texture variable with no name");
- return val.getName();
+ return std::string(val.getName());
}
std::string getSurfaceName(const Value &val) {
assert(val.hasName() && "Found surface variable with no name");
- return val.getName();
+ return std::string(val.getName());
}
std::string getSamplerName(const Value &val) {
assert(val.hasName() && "Found sampler variable with no name");
- return val.getName();
+ return std::string(val.getName());
}
bool getMaxNTIDx(const Function &F, unsigned &x) {
diff --git a/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp b/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
index 2d9ba02..343c0eb 100644
--- a/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
+++ b/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
@@ -1570,12 +1570,12 @@ bool PPCAsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
// instruction name, to match what TableGen is doing.
std::string NewOpcode;
if (parseOptionalToken(AsmToken::Plus)) {
- NewOpcode = Name;
+ NewOpcode = std::string(Name);
NewOpcode += '+';
Name = NewOpcode;
}
if (parseOptionalToken(AsmToken::Minus)) {
- NewOpcode = Name;
+ NewOpcode = std::string(Name);
NewOpcode += '-';
Name = NewOpcode;
}
diff --git a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp
index 1d0ed7e..0549df1 100644
--- a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -123,7 +123,7 @@ void PPCSubtarget::initializeEnvironment() {
void PPCSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
// Determine default and user specified characteristics
- std::string CPUName = CPU;
+ std::string CPUName = std::string(CPU);
if (CPUName.empty() || CPU == "generic") {
// If cross-compiling with -march=ppc64le without -mcpu
if (TargetTriple.getArch() == Triple::ppc64le)
diff --git a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
index 71bad1a..8aa1f1b 100644
--- a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -158,7 +158,7 @@ static std::string getDataLayoutString(const Triple &T) {
static std::string computeFSAdditions(StringRef FS, CodeGenOpt::Level OL,
const Triple &TT) {
- std::string FullFS = FS;
+ std::string FullFS = std::string(FS);
// Make sure 64-bit features are available when CPUname is generic
if (TT.getArch() == Triple::ppc64 || TT.getArch() == Triple::ppc64le) {
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp
index c37482b..d231280 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp
@@ -64,7 +64,7 @@ static MCAsmInfo *createRISCVMCAsmInfo(const MCRegisterInfo &MRI,
static MCSubtargetInfo *createRISCVMCSubtargetInfo(const Triple &TT,
StringRef CPU, StringRef FS) {
- std::string CPUName = CPU;
+ std::string CPUName = std::string(CPU);
if (CPUName.empty())
CPUName = TT.isArch64Bit() ? "generic-rv64" : "generic-rv32";
return createRISCVMCSubtargetInfoImpl(TT, CPUName, FS);
diff --git a/llvm/lib/Target/RISCV/RISCVSubtarget.cpp b/llvm/lib/Target/RISCV/RISCVSubtarget.cpp
index 83e7e2d52..47a48c8 100644
--- a/llvm/lib/Target/RISCV/RISCVSubtarget.cpp
+++ b/llvm/lib/Target/RISCV/RISCVSubtarget.cpp
@@ -33,7 +33,7 @@ RISCVSubtarget &RISCVSubtarget::initializeSubtargetDependencies(
const Triple &TT, StringRef CPU, StringRef FS, StringRef ABIName) {
// Determine default and user-specified characteristics
bool Is64Bit = TT.isArch64Bit();
- std::string CPUName = CPU;
+ std::string CPUName = std::string(CPU);
if (CPUName.empty())
CPUName = Is64Bit ? "generic-rv64" : "generic-rv32";
ParseSubtargetFeatures(CPUName, FS);
diff --git a/llvm/lib/Target/Sparc/SparcSubtarget.cpp b/llvm/lib/Target/Sparc/SparcSubtarget.cpp
index 075a002..dbc6cf8 100644
--- a/llvm/lib/Target/Sparc/SparcSubtarget.cpp
+++ b/llvm/lib/Target/Sparc/SparcSubtarget.cpp
@@ -50,7 +50,7 @@ SparcSubtarget &SparcSubtarget::initializeSubtargetDependencies(StringRef CPU,
HasLeonCycleCounter = false;
// Determine default and user specified characteristics
- std::string CPUName = CPU;
+ std::string CPUName = std::string(CPU);
if (CPUName.empty())
CPUName = (Is64Bit) ? "v9" : "v8";
diff --git a/llvm/lib/Target/Sparc/SparcTargetMachine.cpp b/llvm/lib/Target/Sparc/SparcTargetMachine.cpp
index 76f3878..d48d94e 100644
--- a/llvm/lib/Target/Sparc/SparcTargetMachine.cpp
+++ b/llvm/lib/Target/Sparc/SparcTargetMachine.cpp
@@ -99,7 +99,8 @@ SparcTargetMachine::SparcTargetMachine(
CM, getEffectiveRelocModel(RM), is64bit, JIT),
OL),
TLOF(std::make_unique<SparcELFTargetObjectFile>()),
- Subtarget(TT, CPU, FS, *this, is64bit), is64Bit(is64bit) {
+ Subtarget(TT, std::string(CPU), std::string(FS), *this, is64bit),
+ is64Bit(is64bit) {
initAsmInfo();
}
diff --git a/llvm/lib/Target/SystemZ/SystemZSubtarget.cpp b/llvm/lib/Target/SystemZ/SystemZSubtarget.cpp
index 5e8af81..a4fdc00 100644
--- a/llvm/lib/Target/SystemZ/SystemZSubtarget.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZSubtarget.cpp
@@ -28,7 +28,7 @@ void SystemZSubtarget::anchor() {}
SystemZSubtarget &
SystemZSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
- std::string CPUName = CPU;
+ StringRef CPUName = CPU;
if (CPUName.empty())
CPUName = "generic";
// Parse features string.
diff --git a/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp b/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
index dfcdb53..3e0a9f8 100644
--- a/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
@@ -155,7 +155,7 @@ SystemZTargetMachine::SystemZTargetMachine(const Target &T, const Triple &TT,
getEffectiveSystemZCodeModel(CM, getEffectiveRelocModel(RM), JIT),
OL),
TLOF(std::make_unique<TargetLoweringObjectFileELF>()),
- Subtarget(TT, CPU, FS, *this) {
+ Subtarget(TT, std::string(CPU), std::string(FS), *this) {
initAsmInfo();
}
diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp
index 88ed6a7..4844a95 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -34,10 +34,10 @@ using namespace llvm;
TargetMachine::TargetMachine(const Target &T, StringRef DataLayoutString,
const Triple &TT, StringRef CPU, StringRef FS,
const TargetOptions &Options)
- : TheTarget(T), DL(DataLayoutString), TargetTriple(TT), TargetCPU(CPU),
- TargetFS(FS), AsmInfo(nullptr), MRI(nullptr), MII(nullptr), STI(nullptr),
- RequireStructuredCFG(false), O0WantsFastISel(false),
- DefaultOptions(Options), Options(Options) {}
+ : TheTarget(T), DL(DataLayoutString), TargetTriple(TT),
+ TargetCPU(std::string(CPU)), TargetFS(std::string(FS)), AsmInfo(nullptr),
+ MRI(nullptr), MII(nullptr), STI(nullptr), RequireStructuredCFG(false),
+ O0WantsFastISel(false), DefaultOptions(Options), Options(Options) {}
TargetMachine::~TargetMachine() = default;
diff --git a/llvm/lib/Target/TargetMachineC.cpp b/llvm/lib/Target/TargetMachineC.cpp
index a38633e..60fe84c 100644
--- a/llvm/lib/Target/TargetMachineC.cpp
+++ b/llvm/lib/Target/TargetMachineC.cpp
@@ -164,12 +164,12 @@ char* LLVMGetTargetMachineTriple(LLVMTargetMachineRef T) {
}
char* LLVMGetTargetMachineCPU(LLVMTargetMachineRef T) {
- std::string StringRep = unwrap(T)->getTargetCPU();
+ std::string StringRep = std::string(unwrap(T)->getTargetCPU());
return strdup(StringRep.c_str());
}
char* LLVMGetTargetMachineFeatureString(LLVMTargetMachineRef T) {
- std::string StringRep = unwrap(T)->getTargetFeatureString();
+ std::string StringRep = std::string(unwrap(T)->getTargetFeatureString());
return strdup(StringRep.c_str());
}
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyAddMissingPrototypes.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyAddMissingPrototypes.cpp
index b7a701f..530a55c 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyAddMissingPrototypes.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyAddMissingPrototypes.cpp
@@ -132,7 +132,7 @@ bool WebAssemblyAddMissingPrototypes::runOnModule(Module &M) {
for (auto &Pair : Replacements) {
Function *OldF = Pair.first;
Function *NewF = Pair.second;
- std::string Name = OldF->getName();
+ std::string Name = std::string(OldF->getName());
M.getFunctionList().push_back(NewF);
OldF->replaceAllUsesWith(
ConstantExpr::getPointerBitCastOrAddrSpaceCast(NewF, OldF->getType()));
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
index 3e905c1..8072770 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
@@ -744,8 +744,8 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runEHOnFunction(Function &F) {
bool Changed = false;
SmallVector<Instruction *, 64> ToErase;
SmallPtrSet<LandingPadInst *, 32> LandingPads;
- bool AllowExceptions =
- areAllExceptionsAllowed() || EHWhitelistSet.count(F.getName());
+ bool AllowExceptions = areAllExceptionsAllowed() ||
+ EHWhitelistSet.count(std::string(F.getName()));
for (BasicBlock &BB : F) {
auto *II = dyn_cast<InvokeInst>(BB.getTerminator());
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
index 4291b48..07b00b6 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -210,8 +210,8 @@ private:
FeatureBitset coalesceFeatures(const Module &M) {
FeatureBitset Features =
WasmTM
- ->getSubtargetImpl(WasmTM->getTargetCPU(),
- WasmTM->getTargetFeatureString())
+ ->getSubtargetImpl(std::string(WasmTM->getTargetCPU()),
+ std::string(WasmTM->getTargetFeatureString()))
->getFeatureBits();
for (auto &F : M)
Features |= WasmTM->getSubtargetImpl(F)->getFeatureBits();
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
index 049a3a8..5594f34 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
@@ -294,7 +294,7 @@ MCSubtargetInfo *X86_MC::createX86MCSubtargetInfo(const Triple &TT,
if (!FS.empty())
ArchFS = (Twine(ArchFS) + "," + FS).str();
- std::string CPUName = CPU;
+ std::string CPUName = std::string(CPU);
if (CPUName.empty())
CPUName = "generic";
diff --git a/llvm/lib/Target/X86/X86Subtarget.cpp b/llvm/lib/Target/X86/X86Subtarget.cpp
index 75c3a70..82687de 100644
--- a/llvm/lib/Target/X86/X86Subtarget.cpp
+++ b/llvm/lib/Target/X86/X86Subtarget.cpp
@@ -227,11 +227,11 @@ bool X86Subtarget::isLegalToCallImmediateAddr() const {
}
void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
- std::string CPUName = CPU;
+ std::string CPUName = std::string(CPU);
if (CPUName.empty())
CPUName = "generic";
- std::string FullFS = FS;
+ std::string FullFS = std::string(FS);
if (In64BitMode) {
// SSE2 should default to enabled in 64-bit mode, but can be turned off
// explicitly.
diff --git a/llvm/lib/Target/XCore/XCoreTargetMachine.cpp b/llvm/lib/Target/XCore/XCoreTargetMachine.cpp
index 736bc414..1eea1e3 100644
--- a/llvm/lib/Target/XCore/XCoreTargetMachine.cpp
+++ b/llvm/lib/Target/XCore/XCoreTargetMachine.cpp
@@ -54,7 +54,7 @@ XCoreTargetMachine::XCoreTargetMachine(const Target &T, const Triple &TT,
TT, CPU, FS, Options, getEffectiveRelocModel(RM),
getEffectiveXCoreCodeModel(CM), OL),
TLOF(std::make_unique<XCoreTargetObjectFile>()),
- Subtarget(TT, CPU, FS, *this) {
+ Subtarget(TT, std::string(CPU), std::string(FS), *this) {
initAsmInfo();
}
diff --git a/llvm/lib/TextAPI/MachO/ArchitectureSet.cpp b/llvm/lib/TextAPI/MachO/ArchitectureSet.cpp
index c589671..a05d3eb 100644
--- a/llvm/lib/TextAPI/MachO/ArchitectureSet.cpp
+++ b/llvm/lib/TextAPI/MachO/ArchitectureSet.cpp
@@ -40,7 +40,7 @@ ArchitectureSet::operator std::string() const {
std::string result;
auto size = count();
for (auto arch : *this) {
- result.append(getArchitectureName(arch));
+ result.append(std::string(getArchitectureName(arch)));
size -= 1;
if (size)
result.append(" ");
diff --git a/llvm/lib/TextAPI/MachO/InterfaceFile.cpp b/llvm/lib/TextAPI/MachO/InterfaceFile.cpp
index c40a952..9f08456 100644
--- a/llvm/lib/TextAPI/MachO/InterfaceFile.cpp
+++ b/llvm/lib/TextAPI/MachO/InterfaceFile.cpp
@@ -63,7 +63,7 @@ void InterfaceFile::addParentUmbrella(const Target &Target_, StringRef Parent) {
Target RHS) { return LHS.first < RHS; });
if ((Iter != ParentUmbrellas.end()) && !(Target_ < Iter->first)) {
- Iter->second = Parent;
+ Iter->second = std::string(Parent);
return;
}
@@ -77,7 +77,7 @@ void InterfaceFile::addUUID(const Target &Target_, StringRef UUID) {
Target RHS) { return LHS.first < RHS; });
if ((Iter != UUIDs.end()) && !(Target_ < Iter->first)) {
- Iter->second = UUID;
+ Iter->second = std::string(UUID);
return;
}
diff --git a/llvm/lib/TextAPI/MachO/TextStub.cpp b/llvm/lib/TextAPI/MachO/TextStub.cpp
index 0584e43..cdfe7f4 100644
--- a/llvm/lib/TextAPI/MachO/TextStub.cpp
+++ b/llvm/lib/TextAPI/MachO/TextStub.cpp
@@ -1107,7 +1107,7 @@ static void DiagHandler(const SMDiagnostic &Diag, void *Context) {
Expected<std::unique_ptr<InterfaceFile>>
TextAPIReader::get(MemoryBufferRef InputBuffer) {
TextAPIContext Ctx;
- Ctx.Path = InputBuffer.getBufferIdentifier();
+ Ctx.Path = std::string(InputBuffer.getBufferIdentifier());
yaml::Input YAMLIn(InputBuffer.getBuffer(), &Ctx, DiagHandler, &Ctx);
// Fill vector with interface file objects created by parsing the YAML file.
@@ -1127,7 +1127,7 @@ TextAPIReader::get(MemoryBufferRef InputBuffer) {
Error TextAPIWriter::writeToStream(raw_ostream &OS, const InterfaceFile &File) {
TextAPIContext Ctx;
- Ctx.Path = File.getPath();
+ Ctx.Path = std::string(File.getPath());
Ctx.FileKind = File.getFileType();
llvm::yaml::Output YAMLOut(OS, &Ctx, /*WrapColumn=*/80);
diff --git a/llvm/lib/TextAPI/MachO/TextStubCommon.cpp b/llvm/lib/TextAPI/MachO/TextStubCommon.cpp
index a7fd58f..e4e58cd 100644
--- a/llvm/lib/TextAPI/MachO/TextStubCommon.cpp
+++ b/llvm/lib/TextAPI/MachO/TextStubCommon.cpp
@@ -215,7 +215,7 @@ StringRef ScalarTraits<UUID>::input(StringRef Scalar, void *, UUID &Value) {
auto UUID = Split.second.trim();
if (UUID.empty())
return "invalid uuid string pair";
- Value.second = UUID;
+ Value.second = std::string(UUID);
Value.first = Target{getArchitectureFromName(Arch), PlatformKind::unknown};
return {};
}
diff --git a/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp b/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
index 19f253b..a4fd62e 100644
--- a/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
+++ b/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
@@ -146,7 +146,7 @@ int llvm::dlltoolDriverMain(llvm::ArrayRef<const char *> ArgsArr) {
return 1;
}
- std::string Path = Args.getLastArgValue(OPT_l);
+ std::string Path = std::string(Args.getLastArgValue(OPT_l));
// If ExtName is set (if the "ExtName = Name" syntax was used), overwrite
// Name with ExtName and clear ExtName. When only creating an import
diff --git a/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp b/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
index 286191a..16b231f 100644
--- a/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
+++ b/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
@@ -65,7 +65,7 @@ static std::string getOutputPath(opt::InputArgList *Args,
return Arg->getValue();
SmallString<128> Val = StringRef(FirstMember.Buf->getBufferIdentifier());
sys::path::replace_extension(Val, ".lib");
- return Val.str();
+ return std::string(Val.str());
}
static std::vector<StringRef> getSearchPaths(opt::InputArgList *Args,
diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
index cdf8a2e..c9c8d0a 100644
--- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -453,7 +453,7 @@ doPromotion(Function *F, SmallPtrSetImpl<Argument *> &ArgsToPromote,
assert(It != ArgIndices.end() && "GEP not handled??");
}
- std::string NewName = I->getName();
+ std::string NewName = std::string(I->getName());
for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
NewName += "." + utostr(Operands[i]);
}
diff --git a/llvm/lib/Transforms/IPO/BlockExtractor.cpp b/llvm/lib/Transforms/IPO/BlockExtractor.cpp
index aec470f..1d1300c 100644
--- a/llvm/lib/Transforms/IPO/BlockExtractor.cpp
+++ b/llvm/lib/Transforms/IPO/BlockExtractor.cpp
@@ -127,7 +127,8 @@ void BlockExtractor::loadFile() {
/*KeepEmpty=*/false);
if (BBNames.empty())
report_fatal_error("Missing bbs name");
- BlocksByName.push_back({LineSplit[0], {BBNames.begin(), BBNames.end()}});
+ BlocksByName.push_back(
+ {std::string(LineSplit[0]), {BBNames.begin(), BBNames.end()}});
}
}
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp
index be0446a..abaacb9 100644
--- a/llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -913,11 +913,12 @@ void llvm::gatherImportedSummariesForModule(
const FunctionImporter::ImportMapTy &ImportList,
std::map<std::string, GVSummaryMapTy> &ModuleToSummariesForIndex) {
// Include all summaries from the importing module.
- ModuleToSummariesForIndex[ModulePath] =
+ ModuleToSummariesForIndex[std::string(ModulePath)] =
ModuleToDefinedGVSummaries.lookup(ModulePath);
// Include summaries for imports.
for (auto &ILI : ImportList) {
- auto &SummariesForIndex = ModuleToSummariesForIndex[ILI.first()];
+ auto &SummariesForIndex =
+ ModuleToSummariesForIndex[std::string(ILI.first())];
const auto &DefinedGVSummaries =
ModuleToDefinedGVSummaries.lookup(ILI.first());
for (auto &GI : ILI.second) {
@@ -1291,7 +1292,7 @@ static bool doImportingForModule(Module &M) {
// Perform the import now.
auto ModuleLoader = [&M](StringRef Identifier) {
- return loadFile(Identifier, M.getContext());
+ return loadFile(std::string(Identifier), M.getContext());
};
FunctionImporter Importer(*Index, ModuleLoader);
Expected<bool> Result = Importer.importFunctions(M, ImportList);
diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
index 6eba35a..6f38a31 100644
--- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -1055,7 +1055,7 @@ void LowerTypeTestsModule::importFunction(
assert(F->getType()->getAddressSpace() == 0);
GlobalValue::VisibilityTypes Visibility = F->getVisibility();
- std::string Name = F->getName();
+ std::string Name = std::string(F->getName());
if (F->isDeclarationForLinker() && isJumpTableCanonical) {
// Non-dso_local functions may be overriden at run time,
@@ -1523,13 +1523,13 @@ void LowerTypeTestsModule::buildBitSetsFromFunctionsNative(
F->getType());
if (Functions[I]->isExported()) {
if (IsJumpTableCanonical) {
- ExportSummary->cfiFunctionDefs().insert(F->getName());
+ ExportSummary->cfiFunctionDefs().insert(std::string(F->getName()));
} else {
GlobalAlias *JtAlias = GlobalAlias::create(
F->getValueType(), 0, GlobalValue::ExternalLinkage,
F->getName() + ".cfi_jt", CombinedGlobalElemPtr, &M);
JtAlias->setVisibility(GlobalValue::HiddenVisibility);
- ExportSummary->cfiFunctionDecls().insert(F->getName());
+ ExportSummary->cfiFunctionDecls().insert(std::string(F->getName()));
}
}
if (!IsJumpTableCanonical) {
@@ -1821,9 +1821,10 @@ bool LowerTypeTestsModule::lower() {
// have the same name, but it's not the one we are looking for.
if (F.hasLocalLinkage())
continue;
- if (ImportSummary->cfiFunctionDefs().count(F.getName()))
+ if (ImportSummary->cfiFunctionDefs().count(std::string(F.getName())))
Defs.push_back(&F);
- else if (ImportSummary->cfiFunctionDecls().count(F.getName()))
+ else if (ImportSummary->cfiFunctionDecls().count(
+ std::string(F.getName())))
Decls.push_back(&F);
}
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index 8bfb2fd..719b18c 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -310,7 +310,7 @@ public:
std::function<TargetTransformInfo &(Function &)> GetTargetTransformInfo)
: GetAC(std::move(GetAssumptionCache)),
GetTTI(std::move(GetTargetTransformInfo)), CoverageTracker(*this),
- Filename(Name), RemappingFilename(RemapName),
+ Filename(std::string(Name)), RemappingFilename(std::string(RemapName)),
IsThinLTOPreLink(IsThinLTOPreLink) {}
bool doInitialization(Module &M);
diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
index 5c5ddf4..bbc1433 100644
--- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -1083,7 +1083,7 @@ bool DevirtModule::trySingleImplDevirt(
AddCalls(SlotInfo, TheFnVI);
Res->TheKind = WholeProgramDevirtResolution::SingleImpl;
- Res->SingleImplName = TheFn->getName();
+ Res->SingleImplName = std::string(TheFn->getName());
return true;
}
@@ -1132,10 +1132,10 @@ bool DevirtIndex::trySingleImplDevirt(MutableArrayRef<ValueInfo> TargetsForSlot,
TheFn.name(), ExportSummary.getModuleHash(S->modulePath()));
else {
LocalWPDTargetsMap[TheFn].push_back(SlotSummary);
- Res->SingleImplName = TheFn.name();
+ Res->SingleImplName = std::string(TheFn.name());
}
} else
- Res->SingleImplName = TheFn.name();
+ Res->SingleImplName = std::string(TheFn.name());
// Name will be empty if this thin link driven off of serialized combined
// index (e.g. llvm-lto). However, WPD is not supported/invoked for the
@@ -2003,7 +2003,7 @@ bool DevirtModule::run() {
if (RemarksEnabled)
for (const auto &T : TargetsForSlot)
if (T.WasDevirt)
- DevirtTargets[T.Fn->getName()] = T.Fn;
+ DevirtTargets[std::string(T.Fn->getName())] = T.Fn;
}
// CFI-specific: if we are exporting and any llvm.type.checked.load
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 73a0e10..75b4c8b 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1993,7 +1993,7 @@ void ModuleAddressSanitizer::SetComdatForGlobalMetadata(
}
if (!InternalSuffix.empty() && G->hasLocalLinkage()) {
- std::string Name = G->getName();
+ std::string Name = std::string(G->getName());
Name += InternalSuffix;
C = M.getOrInsertComdat(Name);
} else {
diff --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
index 8053474..388a7d4 100644
--- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -628,7 +628,7 @@ DataFlowSanitizer::WrapperKind DataFlowSanitizer::getWrapperKind(Function *F) {
}
void DataFlowSanitizer::addGlobalNamePrefix(GlobalValue *GV) {
- std::string GVName = GV->getName(), Prefix = "dfs$";
+ std::string GVName = std::string(GV->getName()), Prefix = "dfs$";
GV->setName(Prefix + GVName);
// Try to change the name of the function in module inline asm. We only do
diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
index bf3e4ed..2a302b5 100644
--- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -268,8 +268,7 @@ namespace {
write(Lines[i]);
}
- GCOVLines(StringRef F, raw_ostream *os)
- : Filename(F) {
+ GCOVLines(StringRef F, raw_ostream *os) : Filename(std::string(F)) {
this->os = os;
}
@@ -537,7 +536,8 @@ std::string GCOVProfiler::mangleName(const DICompileUnit *CU,
MDString *DataFile = dyn_cast<MDString>(N->getOperand(1));
if (!NotesFile || !DataFile)
continue;
- return Notes ? NotesFile->getString() : DataFile->getString();
+ return std::string(Notes ? NotesFile->getString()
+ : DataFile->getString());
}
MDString *GCovFile = dyn_cast<MDString>(N->getOperand(0));
@@ -546,7 +546,7 @@ std::string GCOVProfiler::mangleName(const DICompileUnit *CU,
SmallString<128> Filename = GCovFile->getString();
sys::path::replace_extension(Filename, Notes ? "gcno" : "gcda");
- return Filename.str();
+ return std::string(Filename.str());
}
}
@@ -554,9 +554,10 @@ std::string GCOVProfiler::mangleName(const DICompileUnit *CU,
sys::path::replace_extension(Filename, Notes ? "gcno" : "gcda");
StringRef FName = sys::path::filename(Filename);
SmallString<128> CurPath;
- if (sys::fs::current_path(CurPath)) return FName;
+ if (sys::fs::current_path(CurPath))
+ return std::string(FName);
sys::path::append(CurPath, FName);
- return CurPath.str();
+ return std::string(CurPath.str());
}
bool GCOVProfiler::runOnModule(
diff --git a/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp b/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
index f675e26..6462622 100644
--- a/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
+++ b/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
@@ -78,7 +78,7 @@ Comdat *llvm::GetOrCreateFunctionComdat(Function &F, Triple &T,
if (auto Comdat = F.getComdat()) return Comdat;
assert(F.hasName());
Module *M = F.getParent();
- std::string Name = F.getName();
+ std::string Name = std::string(F.getName());
// Make a unique comdat name for internal linkage things on ELF. On COFF, the
// name of the comdat group identifies the leader symbol of the comdat group.
diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
index 8ef6908..b5f0a36 100644
--- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
+++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
@@ -469,7 +469,7 @@ INITIALIZE_PASS(PGOInstrumentationGenCreateVarLegacyPass,
ModulePass *
llvm::createPGOInstrumentationGenCreateVarLegacyPass(StringRef CSInstrName) {
- return new PGOInstrumentationGenCreateVarLegacyPass(CSInstrName);
+ return new PGOInstrumentationGenCreateVarLegacyPass(std::string(CSInstrName));
}
namespace {
@@ -1731,7 +1731,7 @@ bool PGOInstrumentationUseLegacyPass::runOnModule(Module &M) {
static std::string getSimpleNodeName(const BasicBlock *Node) {
if (!Node->getName().empty())
- return Node->getName();
+ return std::string(Node->getName());
std::string SimpleNodeName;
raw_string_ostream OS(SimpleNodeName);
@@ -1822,7 +1822,7 @@ template <> struct DOTGraphTraits<PGOUseFunc *> : DefaultDOTGraphTraits {
: DefaultDOTGraphTraits(isSimple) {}
static std::string getGraphName(const PGOUseFunc *G) {
- return G->getFunc().getName();
+ return std::string(G->getFunc().getName());
}
std::string getNodeLabel(const BasicBlock *Node, const PGOUseFunc *Graph) {
diff --git a/llvm/lib/Transforms/Scalar/LoopDeletion.cpp b/llvm/lib/Transforms/Scalar/LoopDeletion.cpp
index cca7c24..1949340 100644
--- a/llvm/lib/Transforms/Scalar/LoopDeletion.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopDeletion.cpp
@@ -214,7 +214,7 @@ PreservedAnalyses LoopDeletionPass::run(Loop &L, LoopAnalysisManager &AM,
LLVM_DEBUG(dbgs() << "Analyzing Loop for deletion: ");
LLVM_DEBUG(L.dump());
- std::string LoopName = L.getName();
+ std::string LoopName = std::string(L.getName());
auto Result = deleteLoopIfDead(&L, AR.DT, AR.SE, AR.LI, AR.MSSA);
if (Result == LoopDeletionResult::Unmodified)
return PreservedAnalyses::all();
diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
index 75310fc..da1a818 100644
--- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -1327,7 +1327,7 @@ PreservedAnalyses LoopFullUnrollPass::run(Loop &L, LoopAnalysisManager &AM,
else
OldLoops.insert(AR.LI.begin(), AR.LI.end());
- std::string LoopName = L.getName();
+ std::string LoopName = std::string(L.getName());
bool Changed = tryToUnrollLoop(&L, AR.DT, &AR.LI, AR.SE, AR.TTI, AR.AC, *ORE,
/*BFI*/ nullptr, /*PSI*/ nullptr,
@@ -1470,7 +1470,7 @@ PreservedAnalyses LoopUnrollPass::run(Function &F,
Optional<bool> LocalAllowPeeling = UnrollOpts.AllowPeeling;
if (PSI && PSI->hasHugeWorkingSetSize())
LocalAllowPeeling = false;
- std::string LoopName = L.getName();
+ std::string LoopName = std::string(L.getName());
// The API here is quite complex to call and we allow to select some
// flavors of unrolling during construction time (by setting UnrollOpts).
LoopUnrollResult Result = tryToUnrollLoop(
diff --git a/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp b/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
index efef286..4047de1 100644
--- a/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
+++ b/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
@@ -983,7 +983,7 @@ public:
indent(Indent);
}
- void write(const std::string &S) {
+ void write(StringRef S) {
LineLength += S.size();
Stream << S;
}
@@ -1110,7 +1110,7 @@ public:
TmpStream << "scalar";
}
TmpStream.flush();
- Tmp = StringRef(Tmp).trim();
+ Tmp = std::string(StringRef(Tmp).trim());
LineLength += Tmp.size();
Stream << Tmp;
}
diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
index 79e99d0..b184f0f 100644
--- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -2868,7 +2868,7 @@ PreservedAnalyses SimpleLoopUnswitchPass::run(Loop &L, LoopAnalysisManager &AM,
// Save the current loop name in a variable so that we can report it even
// after it has been deleted.
- std::string LoopName = L.getName();
+ std::string LoopName = std::string(L.getName());
auto UnswitchCB = [&L, &U, &LoopName](bool CurrentLoopValid,
ArrayRef<Loop *> NewLoops) {
diff --git a/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp b/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
index 360ed1c..c8407ef 100644
--- a/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
+++ b/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
@@ -55,7 +55,7 @@ static std::string mangleTLIName(StringRef VectorName, const CallInst &CI,
for (unsigned I = 0; I < CI.getNumArgOperands(); ++I)
Out << "v";
Out << "_" << CI.getCalledFunction()->getName() << "(" << VectorName << ")";
- return Out.str();
+ return std::string(Out.str());
}
/// A helper function for converting Scalar types to vector types.
@@ -110,7 +110,7 @@ static void addMappingsFromTLI(const TargetLibraryInfo &TLI, CallInst &CI) {
if (CI.isNoBuiltin() || !CI.getCalledFunction())
return;
- const std::string ScalarName = CI.getCalledFunction()->getName();
+ const std::string ScalarName = std::string(CI.getCalledFunction()->getName());
// Nothing to be done if the TLI thinks the function is not
// vectorizable.
if (!TLI.isFunctionVectorizable(ScalarName))
@@ -123,7 +123,8 @@ static void addMappingsFromTLI(const TargetLibraryInfo &TLI, CallInst &CI) {
// All VFs in the TLI are powers of 2.
for (unsigned VF = 2, WidestVF = TLI.getWidestVF(ScalarName); VF <= WidestVF;
VF *= 2) {
- const std::string TLIName = TLI.getVectorizedFunction(ScalarName, VF);
+ const std::string TLIName =
+ std::string(TLI.getVectorizedFunction(ScalarName, VF));
if (!TLIName.empty()) {
std::string MangledName = mangleTLIName(TLIName, CI, VF);
if (!OriginalSetOfMappings.count(MangledName)) {
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index b708067..35ce5ba 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -951,7 +951,7 @@ static void AddAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap,
for (unsigned i = 0, e = NoAliasArgs.size(); i != e; ++i) {
const Argument *A = NoAliasArgs[i];
- std::string Name = CalledFunc->getName();
+ std::string Name = std::string(CalledFunc->getName());
if (A->hasName()) {
Name += ": %";
Name += A->getName();
diff --git a/llvm/lib/Transforms/Utils/NameAnonGlobals.cpp b/llvm/lib/Transforms/Utils/NameAnonGlobals.cpp
index 1c5c41a..7083789 100644
--- a/llvm/lib/Transforms/Utils/NameAnonGlobals.cpp
+++ b/llvm/lib/Transforms/Utils/NameAnonGlobals.cpp
@@ -55,7 +55,7 @@ public:
Hasher.final(Hash);
SmallString<32> Result;
MD5::stringifyResult(Hash, Result);
- TheHash = Result.str();
+ TheHash = std::string(Result.str());
return TheHash;
}
};
diff --git a/llvm/lib/Transforms/Utils/SSAUpdater.cpp b/llvm/lib/Transforms/Utils/SSAUpdater.cpp
index 36a17ce..57df233 100644
--- a/llvm/lib/Transforms/Utils/SSAUpdater.cpp
+++ b/llvm/lib/Transforms/Utils/SSAUpdater.cpp
@@ -56,7 +56,7 @@ void SSAUpdater::Initialize(Type *Ty, StringRef Name) {
else
getAvailableVals(AV).clear();
ProtoType = Ty;
- ProtoName = Name;
+ ProtoName = std::string(Name);
}
bool SSAUpdater::HasValueForBlock(BasicBlock *BB) const {
diff --git a/llvm/lib/Transforms/Utils/SymbolRewriter.cpp b/llvm/lib/Transforms/Utils/SymbolRewriter.cpp
index aacf81d..ec4ea84 100644
--- a/llvm/lib/Transforms/Utils/SymbolRewriter.cpp
+++ b/llvm/lib/Transforms/Utils/SymbolRewriter.cpp
@@ -117,8 +117,9 @@ public:
const std::string Target;
ExplicitRewriteDescriptor(StringRef S, StringRef T, const bool Naked)
- : RewriteDescriptor(DT), Source(Naked ? StringRef("\01" + S.str()) : S),
- Target(T) {}
+ : RewriteDescriptor(DT),
+ Source(std::string(Naked ? StringRef("\01" + S.str()) : S)),
+ Target(std::string(T)) {}
bool performOnModule(Module &M) override;
@@ -159,7 +160,8 @@ public:
const std::string Transform;
PatternRewriteDescriptor(StringRef P, StringRef T)
- : RewriteDescriptor(DT), Pattern(P), Transform(T) { }
+ : RewriteDescriptor(DT), Pattern(std::string(P)),
+ Transform(std::string(T)) {}
bool performOnModule(Module &M) override;
@@ -189,7 +191,7 @@ performOnModule(Module &M) {
continue;
if (GlobalObject *GO = dyn_cast<GlobalObject>(&C))
- rewriteComdat(M, GO, C.getName(), Name);
+ rewriteComdat(M, GO, std::string(C.getName()), Name);
if (Value *V = (M.*Get)(Name))
C.setValueName(V->getValueName());
@@ -352,19 +354,19 @@ parseRewriteFunctionDescriptor(yaml::Stream &YS, yaml::ScalarNode *K,
if (KeyValue.equals("source")) {
std::string Error;
- Source = Value->getValue(ValueStorage);
+ Source = std::string(Value->getValue(ValueStorage));
if (!Regex(Source).isValid(Error)) {
YS.printError(Field.getKey(), "invalid regex: " + Error);
return false;
}
} else if (KeyValue.equals("target")) {
- Target = Value->getValue(ValueStorage);
+ Target = std::string(Value->getValue(ValueStorage));
} else if (KeyValue.equals("transform")) {
- Transform = Value->getValue(ValueStorage);
+ Transform = std::string(Value->getValue(ValueStorage));
} else if (KeyValue.equals("naked")) {
std::string Undecorated;
- Undecorated = Value->getValue(ValueStorage);
+ Undecorated = std::string(Value->getValue(ValueStorage));
Naked = StringRef(Undecorated).lower() == "true" || Undecorated == "1";
} else {
YS.printError(Field.getKey(), "unknown key for function");
@@ -421,15 +423,15 @@ parseRewriteGlobalVariableDescriptor(yaml::Stream &YS, yaml::ScalarNode *K,
if (KeyValue.equals("source")) {
std::string Error;
- Source = Value->getValue(ValueStorage);
+ Source = std::string(Value->getValue(ValueStorage));
if (!Regex(Source).isValid(Error)) {
YS.printError(Field.getKey(), "invalid regex: " + Error);
return false;
}
} else if (KeyValue.equals("target")) {
- Target = Value->getValue(ValueStorage);
+ Target = std::string(Value->getValue(ValueStorage));
} else if (KeyValue.equals("transform")) {
- Transform = Value->getValue(ValueStorage);
+ Transform = std::string(Value->getValue(ValueStorage));
} else {
YS.printError(Field.getKey(), "unknown Key for Global Variable");
return false;
@@ -484,15 +486,15 @@ parseRewriteGlobalAliasDescriptor(yaml::Stream &YS, yaml::ScalarNode *K,
if (KeyValue.equals("source")) {
std::string Error;
- Source = Value->getValue(ValueStorage);
+ Source = std::string(Value->getValue(ValueStorage));
if (!Regex(Source).isValid(Error)) {
YS.printError(Field.getKey(), "invalid regex: " + Error);
return false;
}
} else if (KeyValue.equals("target")) {
- Target = Value->getValue(ValueStorage);
+ Target = std::string(Value->getValue(ValueStorage));
} else if (KeyValue.equals("transform")) {
- Transform = Value->getValue(ValueStorage);
+ Transform = std::string(Value->getValue(ValueStorage));
} else {
YS.printError(Field.getKey(), "unknown key for Global Alias");
return false;
diff --git a/llvm/lib/XRay/FDRTraceExpander.cpp b/llvm/lib/XRay/FDRTraceExpander.cpp
index cb7f66b..b68e997 100644
--- a/llvm/lib/XRay/FDRTraceExpander.cpp
+++ b/llvm/lib/XRay/FDRTraceExpander.cpp
@@ -44,7 +44,7 @@ Error TraceExpander::visit(CustomEventRecord &R) {
CurrentRecord.PId = PID;
CurrentRecord.TId = TID;
CurrentRecord.Type = RecordTypes::CUSTOM_EVENT;
- CurrentRecord.Data = R.data();
+ CurrentRecord.Data = std::string(R.data());
BuildingRecord = true;
}
return Error::success();
@@ -59,7 +59,7 @@ Error TraceExpander::visit(CustomEventRecordV5 &R) {
CurrentRecord.PId = PID;
CurrentRecord.TId = TID;
CurrentRecord.Type = RecordTypes::CUSTOM_EVENT;
- CurrentRecord.Data = R.data();
+ CurrentRecord.Data = std::string(R.data());
BuildingRecord = true;
}
return Error::success();
@@ -75,7 +75,7 @@ Error TraceExpander::visit(TypedEventRecord &R) {
CurrentRecord.TId = TID;
CurrentRecord.RecordType = R.eventType();
CurrentRecord.Type = RecordTypes::TYPED_EVENT;
- CurrentRecord.Data = R.data();
+ CurrentRecord.Data = std::string(R.data());
BuildingRecord = true;
}
return Error::success();
diff --git a/llvm/tools/bugpoint/CrashDebugger.cpp b/llvm/tools/bugpoint/CrashDebugger.cpp
index aa88a06..73ff1dc 100644
--- a/llvm/tools/bugpoint/CrashDebugger.cpp
+++ b/llvm/tools/bugpoint/CrashDebugger.cpp
@@ -1216,7 +1216,7 @@ static Error DebugACrash(BugDriver &BD, BugTester TestFn) {
// For each remaining function, try to reduce that function's attributes.
std::vector<std::string> FunctionNames;
for (Function &F : BD.getProgram())
- FunctionNames.push_back(F.getName());
+ FunctionNames.push_back(std::string(F.getName()));
if (!FunctionNames.empty() && !BugpointIsInterrupted) {
outs() << "\n*** Attempting to reduce the number of function attributes"
diff --git a/llvm/tools/bugpoint/ExecutionDriver.cpp b/llvm/tools/bugpoint/ExecutionDriver.cpp
index 40f198b..4c83a95 100644
--- a/llvm/tools/bugpoint/ExecutionDriver.cpp
+++ b/llvm/tools/bugpoint/ExecutionDriver.cpp
@@ -311,7 +311,7 @@ Expected<std::string> BugDriver::executeProgram(const Module &Program,
<< "!\n";
exit(1);
}
- BitcodeFile = UniqueFilename.str();
+ BitcodeFile = std::string(UniqueFilename.str());
if (writeProgramToFile(BitcodeFile, UniqueFD, Program)) {
errs() << ToolName << ": Error emitting bitcode to file '" << BitcodeFile
@@ -336,7 +336,7 @@ Expected<std::string> BugDriver::executeProgram(const Module &Program,
<< "\n";
exit(1);
}
- OutputFile = UniqueFile.str();
+ OutputFile = std::string(UniqueFile.str());
// Figure out which shared objects to run, if any.
std::vector<std::string> SharedObjs(AdditionalSOs);
diff --git a/llvm/tools/bugpoint/Miscompilation.cpp b/llvm/tools/bugpoint/Miscompilation.cpp
index 1621a51..c5c51c8 100644
--- a/llvm/tools/bugpoint/Miscompilation.cpp
+++ b/llvm/tools/bugpoint/Miscompilation.cpp
@@ -953,7 +953,8 @@ static Expected<bool> TestCodeGenerator(BugDriver &BD,
<< "Error making unique filename: " << EC.message() << "\n";
exit(1);
}
- if (BD.writeProgramToFile(TestModuleBC.str(), TestModuleFD, *Test)) {
+ if (BD.writeProgramToFile(std::string(TestModuleBC.str()), TestModuleFD,
+ *Test)) {
errs() << "Error writing bitcode to `" << TestModuleBC.str()
<< "'\nExiting.";
exit(1);
@@ -972,7 +973,8 @@ static Expected<bool> TestCodeGenerator(BugDriver &BD,
exit(1);
}
- if (BD.writeProgramToFile(SafeModuleBC.str(), SafeModuleFD, *Safe)) {
+ if (BD.writeProgramToFile(std::string(SafeModuleBC.str()), SafeModuleFD,
+ *Safe)) {
errs() << "Error writing bitcode to `" << SafeModuleBC << "'\nExiting.";
exit(1);
}
@@ -980,7 +982,7 @@ static Expected<bool> TestCodeGenerator(BugDriver &BD,
FileRemover SafeModuleBCRemover(SafeModuleBC.str(), !SaveTemps);
Expected<std::string> SharedObject =
- BD.compileSharedObject(SafeModuleBC.str());
+ BD.compileSharedObject(std::string(SafeModuleBC.str()));
if (Error E = SharedObject.takeError())
return std::move(E);
@@ -988,8 +990,8 @@ static Expected<bool> TestCodeGenerator(BugDriver &BD,
// Run the code generator on the `Test' code, loading the shared library.
// The function returns whether or not the new output differs from reference.
- Expected<bool> Result =
- BD.diffProgram(BD.getProgram(), TestModuleBC.str(), *SharedObject, false);
+ Expected<bool> Result = BD.diffProgram(
+ BD.getProgram(), std::string(TestModuleBC.str()), *SharedObject, false);
if (Error E = Result.takeError())
return std::move(E);
@@ -1046,7 +1048,8 @@ Error BugDriver::debugCodeGenerator() {
exit(1);
}
- if (writeProgramToFile(TestModuleBC.str(), TestModuleFD, *ToCodeGen)) {
+ if (writeProgramToFile(std::string(TestModuleBC.str()), TestModuleFD,
+ *ToCodeGen)) {
errs() << "Error writing bitcode to `" << TestModuleBC << "'\nExiting.";
exit(1);
}
@@ -1062,11 +1065,13 @@ Error BugDriver::debugCodeGenerator() {
exit(1);
}
- if (writeProgramToFile(SafeModuleBC.str(), SafeModuleFD, *ToNotCodeGen)) {
+ if (writeProgramToFile(std::string(SafeModuleBC.str()), SafeModuleFD,
+ *ToNotCodeGen)) {
errs() << "Error writing bitcode to `" << SafeModuleBC << "'\nExiting.";
exit(1);
}
- Expected<std::string> SharedObject = compileSharedObject(SafeModuleBC.str());
+ Expected<std::string> SharedObject =
+ compileSharedObject(std::string(SafeModuleBC.str()));
if (Error E = SharedObject.takeError())
return E;
diff --git a/llvm/tools/bugpoint/OptimizerDriver.cpp b/llvm/tools/bugpoint/OptimizerDriver.cpp
index 64af81f..25a970b 100644
--- a/llvm/tools/bugpoint/OptimizerDriver.cpp
+++ b/llvm/tools/bugpoint/OptimizerDriver.cpp
@@ -141,7 +141,7 @@ bool BugDriver::runPasses(Module &Program,
<< ": Error making unique filename: " << EC.message() << "\n";
return 1;
}
- OutputFilename = UniqueFilename.str();
+ OutputFilename = std::string(UniqueFilename.str());
// set up the input file name
Expected<sys::fs::TempFile> Temp =
diff --git a/llvm/tools/bugpoint/ToolRunner.cpp b/llvm/tools/bugpoint/ToolRunner.cpp
index 19b2ea2..d880aca 100644
--- a/llvm/tools/bugpoint/ToolRunner.cpp
+++ b/llvm/tools/bugpoint/ToolRunner.cpp
@@ -442,7 +442,7 @@ Expected<CC::FileType> LLC::OutputCode(const std::string &Bitcode,
errs() << "Error making unique filename: " << EC.message() << "\n";
exit(1);
}
- OutputAsmFile = UniqueFile.str();
+ OutputAsmFile = std::string(UniqueFile.str());
std::vector<StringRef> LLCArgs;
LLCArgs.push_back(LLCPath);
@@ -772,7 +772,7 @@ Error CC::MakeSharedObject(const std::string &InputFile, FileType fileType,
errs() << "Error making unique filename: " << EC.message() << "\n";
exit(1);
}
- OutputFile = UniqueFilename.str();
+ OutputFile = std::string(UniqueFilename.str());
std::vector<StringRef> CCArgs;
diff --git a/llvm/tools/bugpoint/ToolRunner.h b/llvm/tools/bugpoint/ToolRunner.h
index dde4ec5..f6b5f26 100644
--- a/llvm/tools/bugpoint/ToolRunner.h
+++ b/llvm/tools/bugpoint/ToolRunner.h
@@ -40,7 +40,7 @@ class CC {
std::vector<std::string> ccArgs; // CC-specific arguments.
CC(StringRef ccPath, StringRef RemotePath,
const std::vector<std::string> *CCArgs)
- : CCPath(ccPath), RemoteClientPath(RemotePath) {
+ : CCPath(std::string(ccPath)), RemoteClientPath(std::string(RemotePath)) {
if (CCArgs)
ccArgs = *CCArgs;
}
diff --git a/llvm/tools/bugpoint/bugpoint.cpp b/llvm/tools/bugpoint/bugpoint.cpp
index d29a79e..937ec232 100644
--- a/llvm/tools/bugpoint/bugpoint.cpp
+++ b/llvm/tools/bugpoint/bugpoint.cpp
@@ -110,7 +110,7 @@ public:
void add(Pass *P) override {
const void *ID = P->getPassID();
const PassInfo *PI = PassRegistry::getPassRegistry()->getPassInfo(ID);
- D.addPass(PI->getPassArgument());
+ D.addPass(std::string(PI->getPassArgument()));
}
};
}
@@ -221,7 +221,7 @@ int main(int argc, char **argv) {
AddOptimizationPasses(PM, 2, 2);
for (const PassInfo *PI : PassList)
- D.addPass(PI->getPassArgument());
+ D.addPass(std::string(PI->getPassArgument()));
// Bugpoint has the ability of generating a plethora of core files, so to
// avoid filling up the disk, we prevent it
diff --git a/llvm/tools/dsymutil/BinaryHolder.cpp b/llvm/tools/dsymutil/BinaryHolder.cpp
index da4ed8a..31d32d8 100644
--- a/llvm/tools/dsymutil/BinaryHolder.cpp
+++ b/llvm/tools/dsymutil/BinaryHolder.cpp
@@ -66,7 +66,7 @@ Error BinaryHolder::ArchiveEntry::load(StringRef Filename,
ArchiveBuffers.push_back(MemBuffer->getMemBufferRef());
} else {
FatBinary = std::move(*ErrOrFat);
- FatBinaryName = ArchiveFilename;
+ FatBinaryName = std::string(ArchiveFilename);
ArchiveBuffers =
getMachOFatMemoryBuffers(FatBinaryName, *MemBuffer, *FatBinary);
}
@@ -105,7 +105,7 @@ Error BinaryHolder::ObjectEntry::load(StringRef Filename, bool Verbose) {
ObjectBuffers.push_back(MemBuffer->getMemBufferRef());
} else {
FatBinary = std::move(*ErrOrFat);
- FatBinaryName = Filename;
+ FatBinaryName = std::string(Filename);
ObjectBuffers =
getMachOFatMemoryBuffers(FatBinaryName, *MemBuffer, *FatBinary);
}
diff --git a/llvm/tools/dsymutil/DebugMap.cpp b/llvm/tools/dsymutil/DebugMap.cpp
index 83dddfe..4106710 100644
--- a/llvm/tools/dsymutil/DebugMap.cpp
+++ b/llvm/tools/dsymutil/DebugMap.cpp
@@ -41,7 +41,7 @@ using namespace llvm::object;
DebugMapObject::DebugMapObject(StringRef ObjectFilename,
sys::TimePoint<std::chrono::seconds> Timestamp,
uint8_t Type)
- : Filename(ObjectFilename), Timestamp(Timestamp), Type(Type) {}
+ : Filename(std::string(ObjectFilename)), Timestamp(Timestamp), Type(Type) {}
bool DebugMapObject::addSymbol(StringRef Name, Optional<uint64_t> ObjectAddress,
uint64_t LinkedAddress, uint32_t Size) {
@@ -228,7 +228,8 @@ MappingTraits<dsymutil::DebugMapObject>::YamlDMO::YamlDMO(
Timestamp = sys::toTimeT(Obj.getTimestamp());
Entries.reserve(Obj.Symbols.size());
for (auto &Entry : Obj.Symbols)
- Entries.push_back(std::make_pair(Entry.getKey(), Entry.getValue()));
+ Entries.push_back(
+ std::make_pair(std::string(Entry.getKey()), Entry.getValue()));
}
dsymutil::DebugMapObject
diff --git a/llvm/tools/dsymutil/DebugMap.h b/llvm/tools/dsymutil/DebugMap.h
index 6c0cb8b..ee552ed 100644
--- a/llvm/tools/dsymutil/DebugMap.h
+++ b/llvm/tools/dsymutil/DebugMap.h
@@ -90,7 +90,7 @@ class DebugMap {
public:
DebugMap(const Triple &BinaryTriple, StringRef BinaryPath,
ArrayRef<uint8_t> BinaryUUID = ArrayRef<uint8_t>())
- : BinaryTriple(BinaryTriple), BinaryPath(BinaryPath),
+ : BinaryTriple(BinaryTriple), BinaryPath(std::string(BinaryPath)),
BinaryUUID(BinaryUUID.begin(), BinaryUUID.end()) {}
using const_iterator = ObjectContainer::const_iterator;
@@ -183,7 +183,9 @@ public:
bool empty() const { return Symbols.empty(); }
- void addWarning(StringRef Warning) { Warnings.push_back(Warning); }
+ void addWarning(StringRef Warning) {
+ Warnings.push_back(std::string(Warning));
+ }
const std::vector<std::string> &getWarnings() const { return Warnings; }
void print(raw_ostream &OS) const;
diff --git a/llvm/tools/dsymutil/MachODebugMapParser.cpp b/llvm/tools/dsymutil/MachODebugMapParser.cpp
index 3292e94..83703fb 100644
--- a/llvm/tools/dsymutil/MachODebugMapParser.cpp
+++ b/llvm/tools/dsymutil/MachODebugMapParser.cpp
@@ -26,9 +26,10 @@ public:
MachODebugMapParser(StringRef BinaryPath, ArrayRef<std::string> Archs,
StringRef PathPrefix = "",
bool PaperTrailWarnings = false, bool Verbose = false)
- : BinaryPath(BinaryPath), Archs(Archs.begin(), Archs.end()),
- PathPrefix(PathPrefix), PaperTrailWarnings(PaperTrailWarnings),
- BinHolder(Verbose), CurrentDebugMapObject(nullptr) {}
+ : BinaryPath(std::string(BinaryPath)), Archs(Archs.begin(), Archs.end()),
+ PathPrefix(std::string(PathPrefix)),
+ PaperTrailWarnings(PaperTrailWarnings), BinHolder(Verbose),
+ CurrentDebugMapObject(nullptr) {}
/// Parses and returns the DebugMaps of the input binary. The binary contains
/// multiple maps in case it is a universal binary.
@@ -181,7 +182,7 @@ void MachODebugMapParser::switchToNewDebugMapObject(
static std::string getArchName(const object::MachOObjectFile &Obj) {
Triple T = Obj.getArchTriple();
- return T.getArchName();
+ return std::string(T.getArchName());
}
std::unique_ptr<DebugMap>
@@ -497,7 +498,7 @@ void MachODebugMapParser::loadCurrentObjectFileSymbols(
CurrentObjectAddresses[*Name] = None;
} else if (Flags & SymbolRef::SF_Common) {
CurrentObjectAddresses[*Name] = None;
- CommonSymbols.push_back(*Name);
+ CommonSymbols.push_back(std::string(*Name));
} else {
CurrentObjectAddresses[*Name] = Addr;
}
diff --git a/llvm/tools/dsymutil/MachOUtils.cpp b/llvm/tools/dsymutil/MachOUtils.cpp
index 149905f..f9219dc 100644
--- a/llvm/tools/dsymutil/MachOUtils.cpp
+++ b/llvm/tools/dsymutil/MachOUtils.cpp
@@ -50,7 +50,7 @@ ArchAndFile::~ArchAndFile() {
std::string getArchName(StringRef Arch) {
if (Arch.startswith("thumb"))
return (llvm::Twine("arm") + Arch.drop_front(5)).str();
- return Arch;
+ return std::string(Arch);
}
static bool runLipo(StringRef SDKPath, SmallVectorImpl<StringRef> &Args) {
diff --git a/llvm/tools/dsymutil/MachOUtils.h b/llvm/tools/dsymutil/MachOUtils.h
index 3dda747..f64fc68 100644
--- a/llvm/tools/dsymutil/MachOUtils.h
+++ b/llvm/tools/dsymutil/MachOUtils.h
@@ -30,7 +30,7 @@ struct ArchAndFile {
llvm::Error createTempFile();
llvm::StringRef path() const;
- ArchAndFile(StringRef Arch) : Arch(Arch) {}
+ ArchAndFile(StringRef Arch) : Arch(std::string(Arch)) {}
ArchAndFile(ArchAndFile &&A) = default;
ArchAndFile &operator=(ArchAndFile &&A) = default;
~ArchAndFile();
diff --git a/llvm/tools/dsymutil/dsymutil.cpp b/llvm/tools/dsymutil/dsymutil.cpp
index 2801178..6b26081 100644
--- a/llvm/tools/dsymutil/dsymutil.cpp
+++ b/llvm/tools/dsymutil/dsymutil.cpp
@@ -299,9 +299,9 @@ static Error createPlistFile(StringRef Bin, StringRef BundleRoot,
if (BI.IDStr.empty()) {
StringRef BundleID = *sys::path::rbegin(BundleRoot);
if (sys::path::extension(BundleRoot) == ".dSYM")
- BI.IDStr = sys::path::stem(BundleID);
+ BI.IDStr = std::string(sys::path::stem(BundleID));
else
- BI.IDStr = BundleID;
+ BI.IDStr = std::string(BundleID);
}
// Print out information to the plist file.
@@ -405,7 +405,7 @@ getOutputFileName(StringRef InputFile, const DsymutilOptions &Options) {
// When updating, do in place replacement.
if (Options.OutputFile.empty() &&
(Options.LinkOpts.Update || !Options.SymbolMap.empty()))
- return OutputLocation(InputFile);
+ return OutputLocation(std::string(InputFile));
// If a flat dSYM has been requested, things are pretty simple.
if (Options.Flat) {
@@ -426,7 +426,8 @@ getOutputFileName(StringRef InputFile, const DsymutilOptions &Options) {
// Resources/
// DWARF/
// <DWARF file(s)>
- std::string DwarfFile = InputFile == "-" ? StringRef("a.out") : InputFile;
+ std::string DwarfFile =
+ std::string(InputFile == "-" ? StringRef("a.out") : InputFile);
SmallString<128> Path(Options.OutputFile);
if (Path.empty())
Path = DwarfFile + ".dSYM";
@@ -438,9 +439,9 @@ getOutputFileName(StringRef InputFile, const DsymutilOptions &Options) {
}
sys::path::append(Path, "Contents", "Resources");
- std::string ResourceDir = Path.str();
+ std::string ResourceDir = std::string(Path.str());
sys::path::append(Path, "DWARF", sys::path::filename(DwarfFile));
- return OutputLocation(Path.str(), ResourceDir);
+ return OutputLocation(std::string(Path.str()), ResourceDir);
}
int main(int argc, char **argv) {
@@ -455,7 +456,7 @@ int main(int argc, char **argv) {
void *P = (void *)(intptr_t)getOutputFileName;
std::string SDKPath = sys::fs::getMainExecutable(argv[0], P);
- SDKPath = sys::path::parent_path(SDKPath);
+ SDKPath = std::string(sys::path::parent_path(SDKPath));
for (auto *Arg : Args.filtered(OPT_UNKNOWN)) {
WithColor::warning() << "ignoring unknown option: " << Arg->getSpelling()
diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp
index 93e9b60..f5d47d6 100644
--- a/llvm/tools/gold/gold-plugin.cpp
+++ b/llvm/tools/gold/gold-plugin.cpp
@@ -224,13 +224,14 @@ namespace options {
llvm::StringRef opt = opt_;
if (opt.startswith("mcpu=")) {
- mcpu = opt.substr(strlen("mcpu="));
+ mcpu = std::string(opt.substr(strlen("mcpu=")));
} else if (opt.startswith("extra-library-path=")) {
- extra_library_path = opt.substr(strlen("extra_library_path="));
+ extra_library_path =
+ std::string(opt.substr(strlen("extra_library_path=")));
} else if (opt.startswith("mtriple=")) {
- triple = opt.substr(strlen("mtriple="));
+ triple = std::string(opt.substr(strlen("mtriple=")));
} else if (opt.startswith("obj-path=")) {
- obj_path = opt.substr(strlen("obj-path="));
+ obj_path = std::string(opt.substr(strlen("obj-path=")));
} else if (opt == "emit-llvm") {
TheOutputType = OT_BC_ONLY;
} else if (opt == "save-temps") {
@@ -245,23 +246,25 @@ namespace options {
thinlto_index_only = true;
} else if (opt.startswith("thinlto-index-only=")) {
thinlto_index_only = true;
- thinlto_linked_objects_file = opt.substr(strlen("thinlto-index-only="));
+ thinlto_linked_objects_file =
+ std::string(opt.substr(strlen("thinlto-index-only=")));
} else if (opt == "thinlto-emit-imports-files") {
thinlto_emit_imports_files = true;
} else if (opt.startswith("thinlto-prefix-replace=")) {
- thinlto_prefix_replace = opt.substr(strlen("thinlto-prefix-replace="));
+ thinlto_prefix_replace =
+ std::string(opt.substr(strlen("thinlto-prefix-replace=")));
if (thinlto_prefix_replace.find(';') == std::string::npos)
message(LDPL_FATAL, "thinlto-prefix-replace expects 'old;new' format");
} else if (opt.startswith("thinlto-object-suffix-replace=")) {
thinlto_object_suffix_replace =
- opt.substr(strlen("thinlto-object-suffix-replace="));
+ std::string(opt.substr(strlen("thinlto-object-suffix-replace=")));
if (thinlto_object_suffix_replace.find(';') == std::string::npos)
message(LDPL_FATAL,
"thinlto-object-suffix-replace expects 'old;new' format");
} else if (opt.startswith("cache-dir=")) {
- cache_dir = opt.substr(strlen("cache-dir="));
+ cache_dir = std::string(opt.substr(strlen("cache-dir=")));
} else if (opt.startswith("cache-policy=")) {
- cache_policy = opt.substr(strlen("cache-policy="));
+ cache_policy = std::string(opt.substr(strlen("cache-policy=")));
} else if (opt.size() == 2 && opt[0] == 'O') {
if (opt[1] < '0' || opt[1] > '3')
message(LDPL_FATAL, "Optimization level must be between 0 and 3");
@@ -689,7 +692,7 @@ static std::string getThinLTOObjectFileName(StringRef Path, StringRef OldSuffix,
StringRef NewSuffix) {
if (Path.consume_back(OldSuffix))
return (Path + NewSuffix).str();
- return Path;
+ return std::string(Path);
}
// Returns true if S is valid as a C language identifier.
@@ -1074,8 +1077,9 @@ static std::vector<std::pair<SmallString<128>, bool>> runLTO() {
if (options::thinlto_index_only)
for (auto &Identifier : ObjectToIndexFileState)
if (!Identifier.getValue())
- writeEmptyDistributedBuildOutputs(Identifier.getKey(), OldPrefix,
- NewPrefix, /* SkipModule */ false);
+ writeEmptyDistributedBuildOutputs(std::string(Identifier.getKey()),
+ OldPrefix, NewPrefix,
+ /* SkipModule */ false);
return Files;
}
@@ -1105,7 +1109,7 @@ static ld_plugin_status allSymbolsReadHook() {
for (const auto &F : Files)
if (!F.first.empty())
- recordFile(F.first.str(), F.second);
+ recordFile(std::string(F.first.str()), F.second);
if (!options::extra_library_path.empty() &&
set_extra_library_path(options::extra_library_path.c_str()) != LDPS_OK)
diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp
index 0cf6513..50942df 100644
--- a/llvm/tools/llc/llc.cpp
+++ b/llvm/tools/llc/llc.cpp
@@ -171,7 +171,7 @@ struct RunPassOption {
SmallVector<StringRef, 8> PassNames;
StringRef(Val).split(PassNames, ',', -1, false);
for (auto PassName : PassNames)
- RunPassNames->push_back(PassName);
+ RunPassNames->push_back(std::string(PassName));
}
};
}
@@ -196,11 +196,11 @@ static std::unique_ptr<ToolOutputFile> GetOutputStream(const char *TargetName,
// If InputFilename ends in .bc or .ll, remove it.
StringRef IFN = InputFilename;
if (IFN.endswith(".bc") || IFN.endswith(".ll"))
- OutputFilename = IFN.drop_back(3);
+ OutputFilename = std::string(IFN.drop_back(3));
else if (IFN.endswith(".mir"))
- OutputFilename = IFN.drop_back(4);
+ OutputFilename = std::string(IFN.drop_back(4));
else
- OutputFilename = IFN;
+ OutputFilename = std::string(IFN);
switch (FileType) {
case CGFT_AssemblyFile:
diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp
index 3bf694ab..a0d7a8c 100644
--- a/llvm/tools/lli/lli.cpp
+++ b/llvm/tools/lli/lli.cpp
@@ -714,7 +714,7 @@ static std::function<void(Module &)> createDebugDumper() {
continue;
if (F.hasName()) {
- std::string Name(F.getName());
+ std::string Name(std::string(F.getName()));
printf("%s ", Name.c_str());
} else
printf("<anon> ");
diff --git a/llvm/tools/llvm-ar/llvm-ar.cpp b/llvm/tools/llvm-ar/llvm-ar.cpp
index c339dfe..61ab805 100644
--- a/llvm/tools/llvm-ar/llvm-ar.cpp
+++ b/llvm/tools/llvm-ar/llvm-ar.cpp
@@ -650,7 +650,7 @@ static void addChildMember(std::vector<NewArchiveMember> &Members,
// the archive it's in, so the file resolves correctly.
if (Thin && FlattenArchive) {
StringSaver Saver(Alloc);
- Expected<std::string> FileNameOrErr = M.getName();
+ Expected<std::string> FileNameOrErr(M.getName());
failIfError(FileNameOrErr.takeError());
if (sys::path::is_absolute(*FileNameOrErr)) {
NMOrErr->MemberName = Saver.save(sys::path::convert_to_slash(*FileNameOrErr));
@@ -792,7 +792,7 @@ computeNewArchiveMembers(ArchiveOperation Operation,
int Pos = Ret.size();
Expected<StringRef> NameOrErr = Child.getName();
failIfError(NameOrErr.takeError());
- std::string Name = NameOrErr.get();
+ std::string Name = std::string(NameOrErr.get());
if (comparePaths(Name, RelPos)) {
assert(AddAfter || AddBefore);
if (AddBefore)
@@ -1058,7 +1058,7 @@ static void runMRIScript() {
fail("editing multiple archives not supported");
if (Saved)
fail("file already saved");
- ArchiveName = Rest;
+ ArchiveName = std::string(Rest);
break;
case MRICommand::Delete: {
llvm::erase_if(NewMembers, [=](NewArchiveMember &M) {
diff --git a/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp b/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
index 7ae4d0d..d2b4db3b5 100644
--- a/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
+++ b/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
@@ -274,7 +274,8 @@ Expected<DIInliningInfo>
FileAnalysis::symbolizeInlinedCode(object::SectionedAddress Address) {
assert(Symbolizer != nullptr && "Symbolizer is invalid.");
- return Symbolizer->symbolizeInlinedCode(Object->getFileName(), Address);
+ return Symbolizer->symbolizeInlinedCode(std::string(Object->getFileName()),
+ Address);
}
CFIProtectionStatus
@@ -515,8 +516,9 @@ void FileAnalysis::parseSectionContents(ArrayRef<uint8_t> SectionBytes,
// Check if this instruction exists in the range of the DWARF metadata.
if (!IgnoreDWARFFlag) {
- auto LineInfo = Symbolizer->symbolizeCode(
- Object->getFileName(), {VMAddress, Address.SectionIndex});
+ auto LineInfo =
+ Symbolizer->symbolizeCode(std::string(Object->getFileName()),
+ {VMAddress, Address.SectionIndex});
if (!LineInfo) {
handleAllErrors(LineInfo.takeError(), [](const ErrorInfoBase &E) {
errs() << "Symbolizer failed to get line: " << E.message() << "\n";
@@ -577,7 +579,8 @@ Error FileAnalysis::parseSymbolTable() {
return Error::success();
}
-UnsupportedDisassembly::UnsupportedDisassembly(StringRef Text) : Text(Text) {}
+UnsupportedDisassembly::UnsupportedDisassembly(StringRef Text)
+ : Text(std::string(Text)) {}
char UnsupportedDisassembly::ID;
void UnsupportedDisassembly::log(raw_ostream &OS) const {
diff --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp
index 6c31df3..df45c38 100644
--- a/llvm/tools/llvm-config/llvm-config.cpp
+++ b/llvm/tools/llvm-config/llvm-config.cpp
@@ -338,7 +338,7 @@ int main(int argc, char **argv) {
ActiveIncludeDir = ActivePrefix + "/include";
SmallString<256> path(StringRef(LLVM_TOOLS_INSTALL_DIR));
sys::fs::make_absolute(ActivePrefix, path);
- ActiveBinDir = path.str();
+ ActiveBinDir = std::string(path.str());
ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
ActiveIncludeOption = "-I" + ActiveIncludeDir;
@@ -352,7 +352,8 @@ int main(int argc, char **argv) {
/// in the first place. This can't be done at configure/build time.
StringRef SharedExt, SharedVersionedExt, SharedDir, SharedPrefix, StaticExt,
- StaticPrefix, StaticDir = "lib", DirSep = "/";
+ StaticPrefix, StaticDir = "lib";
+ std::string DirSep = "/";
const Triple HostTriple(Triple::normalize(LLVM_HOST_TRIPLE));
if (HostTriple.isOSWindows()) {
SharedExt = "dll";
@@ -449,7 +450,7 @@ int main(int argc, char **argv) {
// already has the necessary prefix and suffix (e.g. `.so`) added so
// just return it unmodified.
assert(Lib.endswith(SharedExt) && "DyLib is missing suffix");
- LibFileName = Lib;
+ LibFileName = std::string(Lib);
} else {
LibFileName = (SharedPrefix + Lib + "." + SharedExt).str();
}
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp
index 5f1e23f2..4444fe6 100644
--- a/llvm/tools/llvm-cov/CodeCoverage.cpp
+++ b/llvm/tools/llvm-cov/CodeCoverage.cpp
@@ -413,7 +413,8 @@ void CodeCoverageTool::remapPathNames(const CoverageMapping &Coverage) {
// Convert input files from local paths to coverage data file paths.
StringMap<std::string> InvRemappedFilenames;
for (const auto &RemappedFilename : RemappedFilenames)
- InvRemappedFilenames[RemappedFilename.getValue()] = RemappedFilename.getKey();
+ InvRemappedFilenames[RemappedFilename.getValue()] =
+ std::string(RemappedFilename.getKey());
for (std::string &Filename : SourceFiles) {
SmallString<128> NativeFilename;
@@ -510,7 +511,7 @@ void CodeCoverageTool::demangleSymbols(const CoverageMapping &Coverage) {
for (const auto &Function : Coverage.getCoveredFunctions())
// On Windows, lines in the demangler's output file end with "\r\n".
// Splitting by '\n' keeps '\r's, so cut them now.
- DC.DemangledNames[Function.Name] = Symbols[I++].rtrim();
+ DC.DemangledNames[Function.Name] = std::string(Symbols[I++].rtrim());
}
void CodeCoverageTool::writeSourceFileView(StringRef SourceFile,
@@ -688,7 +689,8 @@ int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) {
// PathRemapping.
auto EquivPair = StringRef(PathRemap).split(',');
if (!(EquivPair.first.empty() && EquivPair.second.empty()))
- PathRemapping = EquivPair;
+ PathRemapping = {std::string(EquivPair.first),
+ std::string(EquivPair.second)};
// If a demangler is supplied, check if it exists and register it.
if (!DemanglerOpts.empty()) {
@@ -886,7 +888,7 @@ int CodeCoverageTool::doShow(int argc, const char **argv,
// Get the source files from the function coverage mapping.
for (StringRef Filename : Coverage->getUniqueSourceFiles()) {
if (!IgnoreFilenameFilters.matchesFilename(Filename))
- SourceFiles.push_back(Filename);
+ SourceFiles.push_back(std::string(Filename));
}
// Create an index out of the source files.
diff --git a/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp b/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp
index 1029f77..929529c 100644
--- a/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp
+++ b/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp
@@ -51,7 +51,7 @@ FunctionCoverageSummary::get(const InstantiationGroup &Group,
ArrayRef<FunctionCoverageSummary> Summaries) {
std::string Name;
if (Group.hasName()) {
- Name = Group.getName();
+ Name = std::string(Group.getName());
} else {
llvm::raw_string_ostream OS(Name);
OS << "Definition at line " << Group.getLine() << ", column "
diff --git a/llvm/tools/llvm-cov/SourceCoverageView.cpp b/llvm/tools/llvm-cov/SourceCoverageView.cpp
index 0e20ea6..cd7395a 100644
--- a/llvm/tools/llvm-cov/SourceCoverageView.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageView.cpp
@@ -48,7 +48,7 @@ std::string CoveragePrinter::getOutputPath(StringRef Path, StringRef Extension,
sys::path::append(FullPath, PathFilename);
sys::path::native(FullPath);
- return FullPath.str();
+ return std::string(FullPath.str());
}
Expected<CoveragePrinter::OwnedStream>
@@ -158,7 +158,7 @@ std::string SourceCoverageView::getSourceName() const {
SmallString<128> SourceText(SourceName);
sys::path::remove_dots(SourceText, /*remove_dot_dots=*/true);
sys::path::native(SourceText);
- return SourceText.str();
+ return std::string(SourceText.str());
}
void SourceCoverageView::addExpansion(
diff --git a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
index e333224..1363e0a 100644
--- a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
@@ -250,7 +250,7 @@ const char *CreatedTimeTag = "h4";
std::string getPathToStyle(StringRef ViewPath) {
std::string PathToStyle = "";
- std::string PathSep = sys::path::get_separator();
+ std::string PathSep = std::string(sys::path::get_separator());
unsigned NumSeps = ViewPath.count(PathSep);
for (unsigned I = 0, E = NumSeps; I < E; ++I)
PathToStyle += ".." + PathSep;
@@ -359,7 +359,7 @@ void CoveragePrinterHTML::emitFileSummary(raw_ostream &OS, StringRef SF,
// Simplify the display file path, and wrap it in a link if requested.
std::string Filename;
if (IsTotals) {
- Filename = SF;
+ Filename = std::string(SF);
} else {
Filename = buildLinkToFile(SF, FCS);
}
@@ -507,7 +507,7 @@ void SourceCoverageViewHTML::renderLine(raw_ostream &OS, LineRef L,
unsigned LCol = 1;
auto Snip = [&](unsigned Start, unsigned Len) {
- Snippets.push_back(Line.substr(Start, Len));
+ Snippets.push_back(std::string(Line.substr(Start, Len)));
LCol += Len;
};
@@ -533,7 +533,7 @@ void SourceCoverageViewHTML::renderLine(raw_ostream &OS, LineRef L,
auto Highlight = [&](const std::string &Snippet, unsigned LC, unsigned RC) {
if (getOptions().Debug)
HighlightedRanges.emplace_back(LC, RC);
- return tag("span", Snippet, Color.getValue());
+ return tag("span", Snippet, std::string(Color.getValue()));
};
auto CheckIfUncovered = [&](const CoverageSegment *S) {
diff --git a/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp b/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
index 6de512f..93d6322 100644
--- a/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
+++ b/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
@@ -145,9 +145,9 @@ static void demangleLine(llvm::raw_ostream &OS, StringRef Mangled, bool Split) {
SmallVector<std::pair<StringRef, StringRef>, 16> Words;
SplitStringDelims(Mangled, Words, IsLegalItaniumChar);
for (const auto &Word : Words)
- Result += ::demangle(Word.first) + Word.second.str();
+ Result += ::demangle(std::string(Word.first)) + Word.second.str();
} else
- Result = ::demangle(Mangled);
+ Result = ::demangle(std::string(Mangled));
OS << Result << '\n';
OS.flush();
}
diff --git a/llvm/tools/llvm-dwarfdump/Statistics.cpp b/llvm/tools/llvm-dwarfdump/Statistics.cpp
index f0656c1..b4683bb 100644
--- a/llvm/tools/llvm-dwarfdump/Statistics.cpp
+++ b/llvm/tools/llvm-dwarfdump/Statistics.cpp
@@ -180,7 +180,7 @@ static std::string constructDieID(DWARFDie Die,
if (LT->getFileNameByIndex(
dwarf::toUnsigned(DeclFile, 0), U->getCompilationDir(),
DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath, File))
- File = sys::path::filename(File);
+ File = std::string(sys::path::filename(File));
}
ID << ":" << (File.empty() ? "/" : File);
ID << ":"
diff --git a/llvm/tools/llvm-elfabi/ELFObjHandler.cpp b/llvm/tools/llvm-elfabi/ELFObjHandler.cpp
index b886a8d..124fffb 100644
--- a/llvm/tools/llvm-elfabi/ELFObjHandler.cpp
+++ b/llvm/tools/llvm-elfabi/ELFObjHandler.cpp
@@ -233,7 +233,7 @@ static ELFSymbolType convertInfoToType(uint8_t Info) {
template <class ELFT>
static ELFSymbol createELFSym(StringRef SymName,
const typename ELFT::Sym &RawSym) {
- ELFSymbol TargetSym(SymName);
+ ELFSymbol TargetSym{std::string(SymName)};
uint8_t Binding = RawSym.getBinding();
if (Binding == STB_WEAK)
TargetSym.Weak = true;
@@ -331,7 +331,7 @@ buildStub(const ELFObjectFile<ELFT> &ElfObj) {
if (!NameOrErr) {
return appendToError(NameOrErr.takeError(), "when reading DT_SONAME");
}
- DestStub->SoName = *NameOrErr;
+ DestStub->SoName = std::string(*NameOrErr);
}
// Populate NeededLibs from .dynamic entries and dynamic string table.
@@ -341,7 +341,7 @@ buildStub(const ELFObjectFile<ELFT> &ElfObj) {
if (!LibNameOrErr) {
return appendToError(LibNameOrErr.takeError(), "when reading DT_NEEDED");
}
- DestStub->NeededLibs.push_back(*LibNameOrErr);
+ DestStub->NeededLibs.push_back(std::string(*LibNameOrErr));
}
// Populate Symbols from .dynsym table and dynamic string table.
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index 452cebf..b4a1c62 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
@@ -84,7 +84,7 @@ InstructionBenchmark BenchmarkRunner::runConfiguration(
const SnippetRepetitor &Repetitor, bool DumpObjectToDisk) const {
InstructionBenchmark InstrBenchmark;
InstrBenchmark.Mode = Mode;
- InstrBenchmark.CpuName = State.getTargetMachine().getTargetCPU();
+ InstrBenchmark.CpuName = std::string(State.getTargetMachine().getTargetCPU());
InstrBenchmark.LLVMTriple =
State.getTargetMachine().getTargetTriple().normalize();
InstrBenchmark.NumRepetitions = NumRepetitions;
@@ -165,7 +165,7 @@ BenchmarkRunner::writeObjectFile(const BenchmarkCode &BC,
raw_fd_ostream OFS(ResultFD, true /*ShouldClose*/);
assembleToStream(State.getExegesisTarget(), State.createTargetMachine(),
BC.LiveIns, BC.Key.RegisterInitialValues, FillFunction, OFS);
- return ResultPath.str();
+ return std::string(ResultPath.str());
}
BenchmarkRunner::FunctionExecutor::~FunctionExecutor() {}
diff --git a/llvm/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp b/llvm/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp
index 3451edf..fea6dc9 100644
--- a/llvm/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp
+++ b/llvm/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp
@@ -102,7 +102,7 @@ static void appendCodeTemplates(const LLVMState &State,
// serial.
CodeTemplate CT;
CT.Execution = ExecutionModeBit;
- CT.Info = ExecutionClassDescription;
+ CT.Info = std::string(ExecutionClassDescription);
CT.Instructions.push_back(Instr);
CodeTemplates.push_back(std::move(CT));
return;
@@ -124,7 +124,7 @@ static void appendCodeTemplates(const LLVMState &State,
setRandomAliasing(SelfAliasing, IT, IT);
CodeTemplate CT;
CT.Execution = ExecutionModeBit;
- CT.Info = ExecutionClassDescription;
+ CT.Info = std::string(ExecutionClassDescription);
CT.Instructions.push_back(std::move(IT));
CodeTemplates.push_back(std::move(CT));
return;
@@ -143,7 +143,7 @@ static void appendCodeTemplates(const LLVMState &State,
setRandomAliasing(Back, OtherIT, ThisIT);
CodeTemplate CT;
CT.Execution = ExecutionModeBit;
- CT.Info = ExecutionClassDescription;
+ CT.Info = std::string(ExecutionClassDescription);
CT.Instructions.push_back(std::move(ThisIT));
CT.Instructions.push_back(std::move(OtherIT));
CodeTemplates.push_back(std::move(CT));
diff --git a/llvm/tools/llvm-exegesis/lib/SnippetGenerator.cpp b/llvm/tools/llvm-exegesis/lib/SnippetGenerator.cpp
index af37094..21932f4 100644
--- a/llvm/tools/llvm-exegesis/lib/SnippetGenerator.cpp
+++ b/llvm/tools/llvm-exegesis/lib/SnippetGenerator.cpp
@@ -160,7 +160,8 @@ generateUnconstrainedCodeTemplates(const Instruction &Instr, StringRef Msg) {
std::vector<CodeTemplate> Result;
Result.emplace_back();
CodeTemplate &CT = Result.back();
- CT.Info = formatv("{0}, repeating an unconstrained assignment", Msg);
+ CT.Info =
+ std::string(formatv("{0}, repeating an unconstrained assignment", Msg));
CT.Instructions.emplace_back(&Instr);
return std::move(Result);
}
diff --git a/llvm/tools/llvm-ifs/llvm-ifs.cpp b/llvm/tools/llvm-ifs/llvm-ifs.cpp
index d5816f4..3b0d2ee 100644
--- a/llvm/tools/llvm-ifs/llvm-ifs.cpp
+++ b/llvm/tools/llvm-ifs/llvm-ifs.cpp
@@ -346,7 +346,7 @@ int writeElfStub(const llvm::Triple &T, const std::set<IFSSymbol> &Symbols,
}
OS << "...\n";
- std::string YamlStr = OS.str();
+ std::string YamlStr = std::string(OS.str());
// Only or debugging. Not an offical format.
LLVM_DEBUG({
diff --git a/llvm/tools/llvm-link/llvm-link.cpp b/llvm/tools/llvm-link/llvm-link.cpp
index fa36e08..d0c2b45 100644
--- a/llvm/tools/llvm-link/llvm-link.cpp
+++ b/llvm/tools/llvm-link/llvm-link.cpp
@@ -264,7 +264,7 @@ static bool importFunctions(const char *argv0, Module &DestModule) {
Entry.insert(F->getGUID());
}
auto CachedModuleLoader = [&](StringRef Identifier) {
- return ModuleLoaderCache.takeModule(Identifier);
+ return ModuleLoaderCache.takeModule(std::string(Identifier));
};
FunctionImporter Importer(*Index, CachedModuleLoader);
ExitOnErr(Importer.importFunctions(DestModule, ImportList));
diff --git a/llvm/tools/llvm-lipo/llvm-lipo.cpp b/llvm/tools/llvm-lipo/llvm-lipo.cpp
index a82030b1..e75327e 100644
--- a/llvm/tools/llvm-lipo/llvm-lipo.cpp
+++ b/llvm/tools/llvm-lipo/llvm-lipo.cpp
@@ -169,7 +169,8 @@ public:
Slice(const MachOObjectFile *O, uint32_t Align)
: B(O), CPUType(O->getHeader().cputype),
CPUSubType(O->getHeader().cpusubtype),
- ArchName(O->getArchTriple().getArchName()), P2Alignment(Align) {}
+ ArchName(std::string(O->getArchTriple().getArchName())),
+ P2Alignment(Align) {}
explicit Slice(const MachOObjectFile *O) : Slice(O, calculateAlignment(O)){};
@@ -214,7 +215,7 @@ public:
.str());
CPUType = FO->getHeader().cputype;
CPUSubType = FO->getHeader().cpusubtype;
- ArchName = FO->getArchTriple().getArchName();
+ ArchName = std::string(FO->getArchTriple().getArchName());
// Replicate the behavior of cctools lipo.
P2Alignment = FO->is64Bit() ? 3 : 2;
}
@@ -316,7 +317,7 @@ static Config parseLipoOptions(ArrayRef<const char *> ArgsArr) {
reportError("at least one input file should be specified");
if (InputArgs.hasArg(LIPO_output))
- C.OutputFile = InputArgs.getLastArgValue(LIPO_output);
+ C.OutputFile = std::string(InputArgs.getLastArgValue(LIPO_output));
for (auto Segalign : InputArgs.filtered(LIPO_segalign)) {
if (!Segalign->getValue(1))
diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp
index b47e68e..1285179 100644
--- a/llvm/tools/llvm-lto/llvm-lto.cpp
+++ b/llvm/tools/llvm-lto/llvm-lto.cpp
@@ -454,7 +454,7 @@ static std::string getThinLTOOutputFile(const std::string &Path,
if (std::error_code EC = llvm::sys::fs::create_directories(ParentPath))
error(EC, "error creating the directory '" + ParentPath + "'");
}
- return NewPath.str();
+ return std::string(NewPath.str());
}
namespace thinlto {
@@ -957,7 +957,7 @@ int main(int argc, char **argv) {
lto_symbol_attributes Attrs = Module->getSymbolAttributes(I);
unsigned Scope = Attrs & LTO_SYMBOL_SCOPE_MASK;
if (Scope != LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN)
- KeptDSOSyms.push_back(Name);
+ KeptDSOSyms.push_back(std::string(Name));
}
// We use the first input module as the destination module when
diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index 67a677d..8deedd4 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -203,7 +203,8 @@ static int run(int argc, char **argv) {
return 1;
}
}
- CommandLineResolutions[{FileName, SymbolName}].push_back(Res);
+ CommandLineResolutions[{std::string(FileName), std::string(SymbolName)}]
+ .push_back(Res);
}
std::vector<std::unique_ptr<MemoryBuffer>> MBs;
@@ -292,14 +293,14 @@ static int run(int argc, char **argv) {
std::vector<SymbolResolution> Res;
for (const InputFile::Symbol &Sym : Input->symbols()) {
- auto I = CommandLineResolutions.find({F, Sym.getName()});
+ auto I = CommandLineResolutions.find({F, std::string(Sym.getName())});
// If it isn't found, look for "$", which would have been added
// (followed by a hash) when the symbol was promoted during module
// splitting if it was defined in one part and used in the other.
// Try looking up the symbol name before the "$".
if (I == CommandLineResolutions.end()) {
auto SplitName = Sym.getName().rsplit("$");
- I = CommandLineResolutions.find({F, SplitName.first});
+ I = CommandLineResolutions.find({F, std::string(SplitName.first)});
}
if (I == CommandLineResolutions.end()) {
llvm::errs() << argv[0] << ": missing symbol resolution for " << F
@@ -354,8 +355,10 @@ static int run(int argc, char **argv) {
static int dumpSymtab(int argc, char **argv) {
for (StringRef F : make_range(argv + 1, argv + argc)) {
- std::unique_ptr<MemoryBuffer> MB = check(MemoryBuffer::getFile(F), F);
- BitcodeFileContents BFC = check(getBitcodeFileContents(*MB), F);
+ std::unique_ptr<MemoryBuffer> MB =
+ check(MemoryBuffer::getFile(F), std::string(F));
+ BitcodeFileContents BFC =
+ check(getBitcodeFileContents(*MB), std::string(F));
if (BFC.Symtab.size() >= sizeof(irsymtab::storage::Header)) {
auto *Hdr = reinterpret_cast<const irsymtab::storage::Header *>(
@@ -367,7 +370,7 @@ static int dumpSymtab(int argc, char **argv) {
}
std::unique_ptr<InputFile> Input =
- check(InputFile::create(MB->getMemBufferRef()), F);
+ check(InputFile::create(MB->getMemBufferRef()), std::string(F));
outs() << "target triple: " << Input->getTargetTriple() << '\n';
Triple TT(Input->getTargetTriple());
diff --git a/llvm/tools/llvm-mc/llvm-mc.cpp b/llvm/tools/llvm-mc/llvm-mc.cpp
index 6aa347d..25f02b9 100644
--- a/llvm/tools/llvm-mc/llvm-mc.cpp
+++ b/llvm/tools/llvm-mc/llvm-mc.cpp
@@ -399,7 +399,7 @@ int main(int argc, char **argv) {
}
for (const auto &Arg : DebugPrefixMap) {
const auto &KV = StringRef(Arg).split('=');
- Ctx.addDebugPrefixMapEntry(KV.first, KV.second);
+ Ctx.addDebugPrefixMapEntry(std::string(KV.first), std::string(KV.second));
}
if (!MainFileName.empty())
Ctx.setMainFileName(MainFileName);
diff --git a/llvm/tools/llvm-mca/llvm-mca.cpp b/llvm/tools/llvm-mca/llvm-mca.cpp
index fff5906..06c1ce9 100644
--- a/llvm/tools/llvm-mca/llvm-mca.cpp
+++ b/llvm/tools/llvm-mca/llvm-mca.cpp
@@ -324,7 +324,7 @@ int main(int argc, char **argv) {
processViewOptions();
if (!MCPU.compare("native"))
- MCPU = llvm::sys::getHostCPUName();
+ MCPU = std::string(llvm::sys::getHostCPUName());
std::unique_ptr<MCSubtargetInfo> STI(
TheTarget->createMCSubtargetInfo(TripleName, MCPU, MATTR));
diff --git a/llvm/tools/llvm-ml/llvm-ml.cpp b/llvm/tools/llvm-ml/llvm-ml.cpp
index 38c4861..1b30f3e 100644
--- a/llvm/tools/llvm-ml/llvm-ml.cpp
+++ b/llvm/tools/llvm-ml/llvm-ml.cpp
@@ -278,7 +278,7 @@ int main(int argc, char **argv) {
}
for (const auto &Arg : DebugPrefixMap) {
const auto &KV = StringRef(Arg).split('=');
- Ctx.addDebugPrefixMapEntry(KV.first, KV.second);
+ Ctx.addDebugPrefixMapEntry(std::string(KV.first), std::string(KV.second));
}
if (!MainFileName.empty())
Ctx.setMainFileName(MainFileName);
diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp
index 2cd74af..e048551 100644
--- a/llvm/tools/llvm-nm/llvm-nm.cpp
+++ b/llvm/tools/llvm-nm/llvm-nm.cpp
@@ -1903,7 +1903,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
if (SymbolicFile *O =
dyn_cast<SymbolicFile>(&*ChildOrErr.get())) {
if (PrintFileName) {
- ArchiveName = A->getFileName();
+ ArchiveName = std::string(A->getFileName());
if (ArchFlags.size() > 1)
ArchitectureName = I->getArchFlagName();
} else {
@@ -1972,7 +1972,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
if (SymbolicFile *O =
dyn_cast<SymbolicFile>(&*ChildOrErr.get())) {
if (PrintFileName)
- ArchiveName = A->getFileName();
+ ArchiveName = std::string(A->getFileName());
else
outs() << "\n" << A->getFileName() << "(" << O->getFileName()
<< ")"
@@ -2037,7 +2037,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
}
if (SymbolicFile *F = dyn_cast<SymbolicFile>(&*ChildOrErr.get())) {
if (PrintFileName) {
- ArchiveName = A->getFileName();
+ ArchiveName = std::string(A->getFileName());
if (isa<MachOObjectFile>(F) && moreThanOneArch)
ArchitectureName = O.getArchFlagName();
} else {
diff --git a/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp b/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
index fcf2109..d12eff7 100644
--- a/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
+++ b/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
@@ -390,7 +390,7 @@ static Error updateAndRemoveSymbols(const CopyConfig &Config, Object &Obj) {
const auto I = Config.SymbolsToRename.find(Sym.Name);
if (I != Config.SymbolsToRename.end())
- Sym.Name = I->getValue();
+ Sym.Name = std::string(I->getValue());
if (!Config.SymbolsPrefix.empty() && Sym.Type != STT_SECTION)
Sym.Name = (Config.SymbolsPrefix + Sym.Name).str();
@@ -627,7 +627,7 @@ static Error handleArgs(const CopyConfig &Config, Object &Obj,
const auto Iter = Config.SectionsToRename.find(Sec.Name);
if (Iter != Config.SectionsToRename.end()) {
const SectionRename &SR = Iter->second;
- Sec.Name = SR.NewName;
+ Sec.Name = std::string(SR.NewName);
if (SR.NewFlags.hasValue())
setSectionFlagsAndType(Sec, SR.NewFlags.getValue());
}
diff --git a/llvm/tools/llvm-objcopy/ELF/Object.cpp b/llvm/tools/llvm-objcopy/ELF/Object.cpp
index ad53c756..14ac7bb 100644
--- a/llvm/tools/llvm-objcopy/ELF/Object.cpp
+++ b/llvm/tools/llvm-objcopy/ELF/Object.cpp
@@ -1520,7 +1520,7 @@ template <class ELFT> void ELFBuilder<ELFT>::readSectionHeaders() {
continue;
}
auto &Sec = makeSection(Shdr);
- Sec.Name = unwrapOrError(ElfFile.getSectionName(&Shdr));
+ Sec.Name = std::string(unwrapOrError(ElfFile.getSectionName(&Shdr)));
Sec.Type = Sec.OriginalType = Shdr.sh_type;
Sec.Flags = Sec.OriginalFlags = Shdr.sh_flags;
Sec.Addr = Shdr.sh_addr;
diff --git a/llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp b/llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
index 4578d0b..a4b771e 100644
--- a/llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
+++ b/llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
@@ -60,7 +60,7 @@ static void updateAndRemoveSymbols(const CopyConfig &Config, Object &Obj) {
for (SymbolEntry &Sym : Obj.SymTable) {
auto I = Config.SymbolsToRename.find(Sym.Name);
if (I != Config.SymbolsToRename.end())
- Sym.Name = I->getValue();
+ Sym.Name = std::string(I->getValue());
}
auto RemovePred = [Config](const std::unique_ptr<SymbolEntry> &N) {
diff --git a/llvm/tools/llvm-objcopy/MachO/Object.h b/llvm/tools/llvm-objcopy/MachO/Object.h
index dc2606e..eb8db57 100644
--- a/llvm/tools/llvm-objcopy/MachO/Object.h
+++ b/llvm/tools/llvm-objcopy/MachO/Object.h
@@ -55,11 +55,11 @@ struct Section {
std::vector<RelocationInfo> Relocations;
Section(StringRef SegName, StringRef SectName)
- : Segname(SegName), Sectname(SectName),
+ : Segname(std::string(SegName)), Sectname(std::string(SectName)),
CanonicalName((Twine(SegName) + Twine(',') + SectName).str()) {}
Section(StringRef SegName, StringRef SectName, StringRef Content)
- : Segname(SegName), Sectname(SectName),
+ : Segname(std::string(SegName)), Sectname(std::string(SectName)),
CanonicalName((Twine(SegName) + Twine(',') + SectName).str()),
Content(Content) {}
diff --git a/llvm/tools/llvm-objdump/ELFDump.cpp b/llvm/tools/llvm-objdump/ELFDump.cpp
index f2d6754..d2543df 100644
--- a/llvm/tools/llvm-objdump/ELFDump.cpp
+++ b/llvm/tools/llvm-objdump/ELFDump.cpp
@@ -98,7 +98,7 @@ static Error getRelocationValueString(const ELFObjectFile<ELFT> *Obj,
if (!SymName)
return SymName.takeError();
if (Demangle)
- Fmt << demangle(*SymName);
+ Fmt << demangle(std::string(*SymName));
else
Fmt << *SymName;
}
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp
index 87c7a92..a55ddb7 100644
--- a/llvm/tools/llvm-objdump/MachODump.cpp
+++ b/llvm/tools/llvm-objdump/MachODump.cpp
@@ -7346,7 +7346,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
SmallString<1024> FullPath(DSYMPath);
llvm::sys::path::append(FullPath, "Contents", "Resources", "DWARF",
ShortName);
- DSYMPath = FullPath.str();
+ DSYMPath = std::string(FullPath.str());
}
// Load the file.
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 6bd37a1..984b3f5 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -397,7 +397,7 @@ std::string getFileNameForError(const object::Archive::Child &C,
unsigned Index) {
Expected<StringRef> NameOrErr = C.getName();
if (NameOrErr)
- return NameOrErr.get();
+ return std::string(NameOrErr.get());
// If we have an error getting the name then we print the index of the archive
// member. Since we are already in an error state, we just ignore this error.
consumeError(NameOrErr.takeError());
@@ -562,7 +562,7 @@ public:
symbolize::LLVMSymbolizer::Options SymbolizerOpts;
SymbolizerOpts.PrintFunctions = DILineInfoSpecifier::FunctionNameKind::None;
SymbolizerOpts.Demangle = false;
- SymbolizerOpts.DefaultArch = DefaultArch;
+ SymbolizerOpts.DefaultArch = std::string(DefaultArch);
Symbolizer.reset(new symbolize::LLVMSymbolizer(SymbolizerOpts));
}
virtual ~SourcePrinter() = default;
@@ -1927,7 +1927,7 @@ void printSymbolTable(const ObjectFile *O, StringRef ArchiveName,
}
if (Demangle)
- outs() << ' ' << demangle(Name) << '\n';
+ outs() << ' ' << demangle(std::string(Name)) << '\n';
else
outs() << ' ' << Name << '\n';
}
diff --git a/llvm/tools/llvm-opt-report/OptReport.cpp b/llvm/tools/llvm-opt-report/OptReport.cpp
index 4aecec2..8d7ecfb 100644
--- a/llvm/tools/llvm-opt-report/OptReport.cpp
+++ b/llvm/tools/llvm-opt-report/OptReport.cpp
@@ -225,14 +225,17 @@ static bool readLocationInfo(LocationInfoTy &LocationInfo) {
};
if (Remark.PassName == "inline") {
- auto &LI = LocationInfo[File][Line][Remark.FunctionName][Column];
+ auto &LI = LocationInfo[std::string(File)][Line]
+ [std::string(Remark.FunctionName)][Column];
UpdateLLII(LI.Inlined);
} else if (Remark.PassName == "loop-unroll") {
- auto &LI = LocationInfo[File][Line][Remark.FunctionName][Column];
+ auto &LI = LocationInfo[std::string(File)][Line]
+ [std::string(Remark.FunctionName)][Column];
LI.UnrollCount = UnrollCount;
UpdateLLII(LI.Unrolled);
} else if (Remark.PassName == "loop-vectorize") {
- auto &LI = LocationInfo[File][Line][Remark.FunctionName][Column];
+ auto &LI = LocationInfo[std::string(File)][Line]
+ [std::string(Remark.FunctionName)][Column];
LI.VectorizationFactor = VectorizationFactor;
LI.InterleaveCount = InterleaveCount;
UpdateLLII(LI.Vectorized);
diff --git a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp
index bf725ad..32448ce 100644
--- a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp
+++ b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp
@@ -896,7 +896,7 @@ Error DumpOutputStyle::dumpUdtStats() {
return L.Stat.Size > R.Stat.Size;
});
for (const auto &Stat : NamespacedStatsSorted) {
- std::string Label = formatv("namespace '{0}'", Stat.Key);
+ std::string Label = std::string(formatv("namespace '{0}'", Stat.Key));
P.formatLine("{0} | {1:N} {2:N}",
fmt_align(Label, AlignStyle::Right, FieldWidth),
fmt_align(Stat.Stat.Count, AlignStyle::Right, CD),
@@ -1039,7 +1039,7 @@ Error DumpOutputStyle::dumpXmi() {
}
std::vector<std::string> TIs;
for (const auto I : Xmi.Imports)
- TIs.push_back(formatv("{0,+10:X+}", fmtle(I)));
+ TIs.push_back(std::string(formatv("{0,+10:X+}", fmtle(I))));
std::string Result =
typesetItemList(TIs, P.getIndentLevel() + 35, 12, " ");
P.formatLine("{0,+32} | {1}", Module, Result);
diff --git a/llvm/tools/llvm-pdbutil/FormatUtil.cpp b/llvm/tools/llvm-pdbutil/FormatUtil.cpp
index 1a13f38..c9ef196 100644
--- a/llvm/tools/llvm-pdbutil/FormatUtil.cpp
+++ b/llvm/tools/llvm-pdbutil/FormatUtil.cpp
@@ -20,7 +20,7 @@ using namespace llvm::pdb;
std::string llvm::pdb::truncateStringBack(StringRef S, uint32_t MaxLen) {
if (MaxLen == 0 || S.size() <= MaxLen || S.size() <= 3)
- return S;
+ return std::string(S);
assert(MaxLen >= 3);
uint32_t FinalLen = std::min<size_t>(S.size(), MaxLen - 3);
@@ -30,7 +30,7 @@ std::string llvm::pdb::truncateStringBack(StringRef S, uint32_t MaxLen) {
std::string llvm::pdb::truncateStringMiddle(StringRef S, uint32_t MaxLen) {
if (MaxLen == 0 || S.size() <= MaxLen || S.size() <= 3)
- return S;
+ return std::string(S);
assert(MaxLen >= 3);
uint32_t FinalLen = std::min<size_t>(S.size(), MaxLen - 3);
@@ -41,7 +41,7 @@ std::string llvm::pdb::truncateStringMiddle(StringRef S, uint32_t MaxLen) {
std::string llvm::pdb::truncateStringFront(StringRef S, uint32_t MaxLen) {
if (MaxLen == 0 || S.size() <= MaxLen || S.size() <= 3)
- return S;
+ return std::string(S);
assert(MaxLen >= 3);
S = S.take_back(MaxLen - 3);
@@ -82,7 +82,7 @@ std::string llvm::pdb::typesetItemList(ArrayRef<std::string> Opts,
if (!Opts.empty()) {
Result += Sep;
Result += "\n";
- Result += formatv("{0}", fmt_repeat(' ', IndentLevel));
+ Result += std::string(formatv("{0}", fmt_repeat(' ', IndentLevel)));
}
}
return Result;
@@ -92,7 +92,7 @@ std::string llvm::pdb::typesetStringList(uint32_t IndentLevel,
ArrayRef<StringRef> Strings) {
std::string Result = "[";
for (const auto &S : Strings) {
- Result += formatv("\n{0}{1}", fmt_repeat(' ', IndentLevel), S);
+ Result += std::string(formatv("\n{0}{1}", fmt_repeat(' ', IndentLevel), S));
}
Result += "]";
return Result;
@@ -169,7 +169,7 @@ StringRef llvm::pdb::formatTypeLeafKind(TypeLeafKind K) {
}
std::string llvm::pdb::formatSegmentOffset(uint16_t Segment, uint32_t Offset) {
- return formatv("{0:4}:{1:4}", Segment, Offset);
+ return std::string(formatv("{0:4}:{1:4}", Segment, Offset));
}
#define PUSH_CHARACTERISTIC_FLAG(Enum, TheOpt, Value, Style, Descriptive) \
diff --git a/llvm/tools/llvm-pdbutil/MinimalSymbolDumper.cpp b/llvm/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
index ebfa506..7a06140 100644
--- a/llvm/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
+++ b/llvm/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
@@ -371,9 +371,9 @@ std::string MinimalSymbolDumper::typeOrIdIndex(codeview::TypeIndex TI,
StringRef Name = Container.getTypeName(TI);
if (Name.size() > 32) {
Name = Name.take_front(32);
- return formatv("{0} ({1}...)", TI, Name);
+ return std::string(formatv("{0} ({1}...)", TI, Name));
} else
- return formatv("{0} ({1})", TI, Name);
+ return std::string(formatv("{0} ({1})", TI, Name));
}
std::string MinimalSymbolDumper::idIndex(codeview::TypeIndex TI) const {
diff --git a/llvm/tools/llvm-pdbutil/MinimalTypeDumper.cpp b/llvm/tools/llvm-pdbutil/MinimalTypeDumper.cpp
index 3fdef08..8e46a97 100644
--- a/llvm/tools/llvm-pdbutil/MinimalTypeDumper.cpp
+++ b/llvm/tools/llvm-pdbutil/MinimalTypeDumper.cpp
@@ -201,8 +201,9 @@ static std::string formatPointerAttrs(const PointerRecord &Record) {
PointerMode Mode = Record.getMode();
PointerOptions Opts = Record.getOptions();
PointerKind Kind = Record.getPointerKind();
- return formatv("mode = {0}, opts = {1}, kind = {2}", formatPointerMode(Mode),
- pointerOptions(Opts), pointerKind(Kind));
+ return std::string(formatv("mode = {0}, opts = {1}, kind = {2}",
+ formatPointerMode(Mode), pointerOptions(Opts),
+ pointerKind(Kind)));
}
static std::string formatFunctionOptions(FunctionOptions Options) {
diff --git a/llvm/tools/llvm-pdbutil/StreamUtil.cpp b/llvm/tools/llvm-pdbutil/StreamUtil.cpp
index 7dfc2be..d0d0a9fb 100644
--- a/llvm/tools/llvm-pdbutil/StreamUtil.cpp
+++ b/llvm/tools/llvm-pdbutil/StreamUtil.cpp
@@ -32,7 +32,7 @@ std::string StreamInfo::getLongName() const {
StreamInfo StreamInfo::createStream(StreamPurpose Purpose, StringRef Name,
uint32_t StreamIndex) {
StreamInfo Result;
- Result.Name = Name;
+ Result.Name = std::string(Name);
Result.StreamIndex = StreamIndex;
Result.Purpose = Purpose;
return Result;
@@ -41,7 +41,7 @@ StreamInfo StreamInfo::createStream(StreamPurpose Purpose, StringRef Name,
StreamInfo StreamInfo::createModuleStream(StringRef Module,
uint32_t StreamIndex, uint32_t Modi) {
StreamInfo Result;
- Result.Name = Module;
+ Result.Name = std::string(Module);
Result.StreamIndex = StreamIndex;
Result.ModuleIndex = Modi;
Result.Purpose = StreamPurpose::ModuleStream;
@@ -90,7 +90,7 @@ void llvm::pdb::discoverStreamPurposes(PDBFile &File,
if (Info) {
for (auto &NSE : Info->named_streams()) {
if (NSE.second != kInvalidStreamIndex)
- NamedStreams[NSE.second] = NSE.first();
+ NamedStreams[NSE.second] = std::string(NSE.first());
}
}
diff --git a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
index 9307300..5dc666e 100644
--- a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
+++ b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
@@ -1507,7 +1507,7 @@ int main(int Argc, const char **Argv) {
if (opts::yaml2pdb::YamlPdbOutputFile.empty()) {
SmallString<16> OutputFilename(opts::yaml2pdb::InputFilename.getValue());
sys::path::replace_extension(OutputFilename, ".pdb");
- opts::yaml2pdb::YamlPdbOutputFile = OutputFilename.str();
+ opts::yaml2pdb::YamlPdbOutputFile = std::string(OutputFilename.str());
}
yamlToPdb(opts::yaml2pdb::InputFilename);
} else if (opts::DiaDumpSubcommand) {
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index d98934b..424edf4 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -73,15 +73,15 @@ static void exitWithError(Error E, StringRef Whence = "") {
// Hint for common error of forgetting --sample for sample profiles.
Hint = "Perhaps you forgot to use the --sample option?";
}
- exitWithError(IPE.message(), Whence, Hint);
+ exitWithError(IPE.message(), std::string(Whence), std::string(Hint));
});
}
- exitWithError(toString(std::move(E)), Whence);
+ exitWithError(toString(std::move(E)), std::string(Whence));
}
static void exitWithErrorCode(std::error_code EC, StringRef Whence = "") {
- exitWithError(EC.message(), Whence);
+ exitWithError(EC.message(), std::string(Whence));
}
namespace {
@@ -94,7 +94,7 @@ static void warnOrExitGivenError(FailureMode FailMode, std::error_code EC,
if (FailMode == failIfAnyAreInvalid)
exitWithErrorCode(EC, Whence);
else
- warn(EC.message(), Whence);
+ warn(EC.message(), std::string(Whence));
}
static void handleMergeWriterError(Error E, StringRef WhenceFile = "",
@@ -401,7 +401,8 @@ remapSamples(const sampleprof::FunctionSamples &Samples,
for (const auto &Callsite : CallsiteSamples.second) {
sampleprof::FunctionSamples Remapped =
remapSamples(Callsite.second, Remapper, Error);
- MergeResult(Error, Target[Remapped.getName()].merge(Remapped));
+ MergeResult(Error,
+ Target[std::string(Remapped.getName())].merge(Remapped));
}
}
return Result;
@@ -537,7 +538,7 @@ static WeightedFile parseWeightedFile(const StringRef &WeightedFilename) {
if (WeightStr.getAsInteger(10, Weight) || Weight < 1)
exitWithError("Input weight must be a positive integer.");
- return {FileName, Weight};
+ return {std::string(FileName), Weight};
}
static void addWeightedInput(WeightedFileVector &WNI, const WeightedFile &WF) {
@@ -546,7 +547,7 @@ static void addWeightedInput(WeightedFileVector &WNI, const WeightedFile &WF) {
// If it's STDIN just pass it on.
if (Filename == "-") {
- WNI.push_back({Filename, Weight});
+ WNI.push_back({std::string(Filename), Weight});
return;
}
@@ -557,7 +558,7 @@ static void addWeightedInput(WeightedFileVector &WNI, const WeightedFile &WF) {
Filename);
// If it's a source file, collect it.
if (llvm::sys::fs::is_regular_file(Status)) {
- WNI.push_back({Filename, Weight});
+ WNI.push_back({std::string(Filename), Weight});
return;
}
@@ -589,7 +590,7 @@ static void parseInputFilenamesFile(MemoryBuffer *Buffer,
continue;
// If there's no comma, it's an unweighted profile.
else if (SanitizedEntry.find(',') == StringRef::npos)
- addWeightedInput(WFV, {SanitizedEntry, 1});
+ addWeightedInput(WFV, {std::string(SanitizedEntry), 1});
else
addWeightedInput(WFV, parseWeightedFile(SanitizedEntry));
}
@@ -658,7 +659,7 @@ static int merge_main(int argc, const char *argv[]) {
WeightedFileVector WeightedInputs;
for (StringRef Filename : InputFilenames)
- addWeightedInput(WeightedInputs, {Filename, 1});
+ addWeightedInput(WeightedInputs, {std::string(Filename), 1});
for (StringRef WeightedFilename : WeightedInputFilenames)
addWeightedInput(WeightedInputs, parseWeightedFile(WeightedFilename));
diff --git a/llvm/tools/llvm-rc/llvm-rc.cpp b/llvm/tools/llvm-rc/llvm-rc.cpp
index 97cc7c8..a09960d 100644
--- a/llvm/tools/llvm-rc/llvm-rc.cpp
+++ b/llvm/tools/llvm-rc/llvm-rc.cpp
@@ -168,7 +168,7 @@ int main(int Argc, const char **Argv) {
if (OutArgsInfo.empty()) {
SmallString<128> OutputFile = InputFile;
llvm::sys::path::replace_extension(OutputFile, "res");
- OutArgsInfo.push_back(OutputFile.str());
+ OutArgsInfo.push_back(std::string(OutputFile.str()));
}
if (OutArgsInfo.size() != 1)
diff --git a/llvm/tools/llvm-readobj/COFFDumper.cpp b/llvm/tools/llvm-readobj/COFFDumper.cpp
index 9b2c6ad..ffe331a 100644
--- a/llvm/tools/llvm-readobj/COFFDumper.cpp
+++ b/llvm/tools/llvm-readobj/COFFDumper.cpp
@@ -1135,7 +1135,7 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
return;
}
- std::string PC = formatv("+{0:X}", uint32_t(Line.Offset));
+ std::string PC = std::string(formatv("+{0:X}", uint32_t(Line.Offset)));
ListScope PCScope(W, PC);
codeview::LineInfo LI(Line.Flags);
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index f321bab..626ac41 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -490,7 +490,7 @@ ELFDumper<ELFT>::getVersionDefinitions(const Elf_Shdr *Sec) const {
VerdAux Aux;
Aux.Offset = VerdauxBuf - Start;
if (Verdaux->vda_name <= StrTabOrErr->size())
- Aux.Name = StrTabOrErr->drop_front(Verdaux->vda_name);
+ Aux.Name = std::string(StrTabOrErr->drop_front(Verdaux->vda_name));
else
Aux.Name = "<invalid vda_name: " + to_string(Verdaux->vda_name) + ">";
return Aux;
@@ -600,7 +600,7 @@ ELFDumper<ELFT>::getVersionDependencies(const Elf_Shdr *Sec) const {
VN.Offset = VerneedBuf - Start;
if (Verneed->vn_file < StrTab.size())
- VN.File = StrTab.drop_front(Verneed->vn_file);
+ VN.File = std::string(StrTab.drop_front(Verneed->vn_file));
else
VN.File = "<corrupt vn_file: " + to_string(Verneed->vn_file) + ">";
@@ -630,7 +630,7 @@ ELFDumper<ELFT>::getVersionDependencies(const Elf_Shdr *Sec) const {
if (StrTab.size() <= Vernaux->vna_name)
Aux.Name = "<corrupt>";
else
- Aux.Name = StrTab.drop_front(Vernaux->vna_name);
+ Aux.Name = std::string(StrTab.drop_front(Vernaux->vna_name));
VernauxBuf += Vernaux->vna_next;
}
@@ -806,7 +806,7 @@ private:
std::string Str;
unsigned Column;
- Field(StringRef S, unsigned Col) : Str(S), Column(Col) {}
+ Field(StringRef S, unsigned Col) : Str(std::string(S)), Column(Col) {}
Field(unsigned Col) : Column(Col) {}
};
@@ -814,7 +814,7 @@ private:
std::string printEnum(T Value, ArrayRef<EnumEntry<TEnum>> EnumValues) {
for (const auto &EnumItem : EnumValues)
if (EnumItem.Value == Value)
- return EnumItem.AltName;
+ return std::string(EnumItem.AltName);
return to_hexString(Value, false);
}
@@ -988,7 +988,7 @@ template <class ELFT> Error ELFDumper<ELFT>::LoadVersionMap() const {
auto InsertEntry = [this](unsigned N, StringRef Version, bool IsVerdef) {
if (N >= VersionMap.size())
VersionMap.resize(N + 1);
- VersionMap[N] = {Version, IsVerdef};
+ VersionMap[N] = {std::string(Version), IsVerdef};
};
if (SymbolVersionDefSection) {
@@ -1036,7 +1036,7 @@ Expected<StringRef> ELFDumper<ELFT>::getSymbolVersion(const Elf_Sym *Sym,
}
static std::string maybeDemangle(StringRef Name) {
- return opts::Demangle ? demangle(Name) : Name.str();
+ return opts::Demangle ? demangle(std::string(Name)) : Name.str();
}
template <typename ELFT>
@@ -1106,7 +1106,7 @@ std::string ELFDumper<ELFT>::getFullSymbolName(const Elf_Sym *Symbol,
ELFDumperStyle->reportUniqueWarning(NameOrErr.takeError());
return ("<section " + Twine(*SectionIndex) + ">").str();
}
- return *NameOrErr;
+ return std::string(*NameOrErr);
}
if (!IsDynamic)
@@ -3211,7 +3211,8 @@ void GNUStyle<ELFT>::printRelocation(const ELFO *Obj, const Elf_Shdr *SymTab,
const Elf_Shdr *Sec = unwrapOrError(
this->FileName,
Obj->getSection(Sym, SymTab, this->dumper()->getShndxTable()));
- TargetName = unwrapOrError(this->FileName, Obj->getSectionName(Sec));
+ TargetName =
+ std::string(unwrapOrError(this->FileName, Obj->getSectionName(Sec)));
} else if (Sym) {
StringRef StrTable =
unwrapOrError(this->FileName, Obj->getStringTableForSymtab(*SymTab));
@@ -3240,7 +3241,7 @@ void GNUStyle<ELFT>::printRelocation(const ELFO *Obj, const Elf_Sym *Sym,
if (Sym && (!SymbolName.empty() || Sym->getValue() != 0))
Fields[3].Str = to_string(format_hex_no_prefix(Sym->getValue(), Width));
- Fields[4].Str = SymbolName;
+ Fields[4].Str = std::string(SymbolName);
for (const Field &F : Fields)
printField(F);
@@ -3524,8 +3525,8 @@ void GNUStyle<ELFT>::printSectionHeaders(const ELFO *Obj) {
if (SecStrTable.empty())
Fields[1].Str = "<no-strings>";
else
- Fields[1].Str = unwrapOrError<StringRef>(
- ElfObj->getFileName(), Obj->getSectionName(&Sec, SecStrTable));
+ Fields[1].Str = std::string(unwrapOrError<StringRef>(
+ ElfObj->getFileName(), Obj->getSectionName(&Sec, SecStrTable)));
Fields[2].Str =
getSectionTypeString(Obj->getHeader()->e_machine, Sec.sh_type);
Fields[3].Str =
@@ -4732,7 +4733,7 @@ template <typename ELFT> static GNUAbiTag getGNUAbiTag(ArrayRef<uint8_t> Desc) {
std::string str;
raw_string_ostream ABI(str);
ABI << Major << "." << Minor << "." << Patch;
- return {OSName, ABI.str(), /*IsValid=*/true};
+ return {std::string(OSName), ABI.str(), /*IsValid=*/true};
}
static std::string getGNUBuildId(ArrayRef<uint8_t> Desc) {
@@ -5626,7 +5627,8 @@ void LLVMStyle<ELFT>::printRelocation(const ELFO *Obj, Elf_Rela Rel,
const Elf_Shdr *Sec = unwrapOrError(
this->FileName,
Obj->getSection(Sym, SymTab, this->dumper()->getShndxTable()));
- TargetName = unwrapOrError(this->FileName, Obj->getSectionName(Sec));
+ TargetName =
+ std::string(unwrapOrError(this->FileName, Obj->getSectionName(Sec)));
} else if (Sym) {
StringRef StrTable =
unwrapOrError(this->FileName, Obj->getStringTableForSymtab(*SymTab));
diff --git a/llvm/tools/llvm-readobj/ObjDumper.cpp b/llvm/tools/llvm-readobj/ObjDumper.cpp
index 6229b52..2359699 100644
--- a/llvm/tools/llvm-readobj/ObjDumper.cpp
+++ b/llvm/tools/llvm-readobj/ObjDumper.cpp
@@ -54,7 +54,7 @@ getSectionRefsByNameOrIndex(const object::ObjectFile *Obj,
SecIndex = Obj->isELF() ? 0 : 1;
for (object::SectionRef SecRef : Obj->sections()) {
StringRef SecName = unwrapOrError(Obj->getFileName(), SecRef.getName());
- auto NameIt = SecNames.find(SecName);
+ auto NameIt = SecNames.find(std::string(SecName));
if (NameIt != SecNames.end())
NameIt->second = true;
auto IndexIt = SecIndices.find(SecIndex);
diff --git a/llvm/tools/llvm-readobj/llvm-readobj.cpp b/llvm/tools/llvm-readobj/llvm-readobj.cpp
index fadeec1..869292a 100644
--- a/llvm/tools/llvm-readobj/llvm-readobj.cpp
+++ b/llvm/tools/llvm-readobj/llvm-readobj.cpp
@@ -456,8 +456,9 @@ static void dumpObject(const ObjectFile *Obj, ScopedPrinter &Writer,
Writer.printString("Format", Obj->getFileFormatName());
Writer.printString("Arch", Triple::getArchTypeName(
(llvm::Triple::ArchType)Obj->getArch()));
- Writer.printString("AddressSize",
- formatv("{0}bit", 8 * Obj->getBytesInAddress()));
+ Writer.printString(
+ "AddressSize",
+ std::string(formatv("{0}bit", 8 * Obj->getBytesInAddress())));
Dumper->printLoadName();
}
diff --git a/llvm/tools/llvm-reduce/deltas/Delta.cpp b/llvm/tools/llvm-reduce/deltas/Delta.cpp
index 0642241..3c55adf 100644
--- a/llvm/tools/llvm-reduce/deltas/Delta.cpp
+++ b/llvm/tools/llvm-reduce/deltas/Delta.cpp
@@ -47,7 +47,7 @@ bool IsReduced(Module &M, TestRunner &Test, SmallString<128> &CurrentFilepath) {
static int getLines(StringRef Filepath) {
int Lines = 0;
std::string CurrLine;
- std::ifstream FileStream(Filepath);
+ std::ifstream FileStream{std::string(Filepath)};
while (std::getline(FileStream, CurrLine))
++Lines;
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp b/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
index f5f14b8..d5f60aa 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
@@ -93,7 +93,7 @@ static void extractArgumentsFromModule(std::vector<Chunk> ChunksToKeep,
replaceFunctionCalls(*F, *ClonedFunc, ArgIndexesToKeep);
// Rename Cloned Function to Old's name
- std::string FName = F->getName();
+ std::string FName = std::string(F->getName());
F->eraseFromParent();
ClonedFunc->setName(FName);
}
diff --git a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
index 9b84c46..be5dbdd 100644
--- a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
+++ b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
@@ -189,7 +189,7 @@ class TrivialMemoryManager : public RTDyldMemoryManager {
public:
struct SectionInfo {
SectionInfo(StringRef Name, sys::MemoryBlock MB, unsigned SectionID)
- : Name(Name), MB(std::move(MB)), SectionID(SectionID) {}
+ : Name(std::string(Name)), MB(std::move(MB)), SectionID(SectionID) {}
std::string Name;
sys::MemoryBlock MB;
unsigned SectionID = ~0U;
@@ -599,7 +599,7 @@ void applySpecificSectionMappings(RuntimeDyld &Dyld,
for (StringRef Mapping : SpecificSectionMappings) {
size_t EqualsIdx = Mapping.find_first_of("=");
- std::string SectionIDStr = Mapping.substr(0, EqualsIdx);
+ std::string SectionIDStr = std::string(Mapping.substr(0, EqualsIdx));
size_t ComaIdx = Mapping.find_first_of(",");
if (ComaIdx == StringRef::npos)
@@ -612,7 +612,7 @@ void applySpecificSectionMappings(RuntimeDyld &Dyld,
ExitOnErr(getSectionId(FileToSecIDMap, FileName, SectionName));
auto* OldAddr = Dyld.getSectionContent(SectionID).data();
- std::string NewAddrStr = Mapping.substr(EqualsIdx + 1);
+ std::string NewAddrStr = std::string(Mapping.substr(EqualsIdx + 1));
uint64_t NewAddr;
if (StringRef(NewAddrStr).getAsInteger(0, NewAddr))
diff --git a/llvm/tools/llvm-undname/llvm-undname.cpp b/llvm/tools/llvm-undname/llvm-undname.cpp
index aee9946..7c36825 100644
--- a/llvm/tools/llvm-undname/llvm-undname.cpp
+++ b/llvm/tools/llvm-undname/llvm-undname.cpp
@@ -87,7 +87,7 @@ int main(int argc, char **argv) {
<< "\': " << EC.message() << '\n';
return 1;
}
- return msDemangle(FileOrErr->get()->getBuffer()) ? 0 : 1;
+ return msDemangle(std::string(FileOrErr->get()->getBuffer())) ? 0 : 1;
}
bool Success = true;
@@ -111,7 +111,7 @@ int main(int argc, char **argv) {
outs() << Line << "\n";
outs().flush();
}
- if (!msDemangle(Line))
+ if (!msDemangle(std::string(Line)))
Success = false;
outs() << "\n";
}
@@ -119,7 +119,7 @@ int main(int argc, char **argv) {
for (StringRef S : Symbols) {
outs() << S << "\n";
outs().flush();
- if (!msDemangle(S))
+ if (!msDemangle(std::string(S)))
Success = false;
outs() << "\n";
}
diff --git a/llvm/tools/llvm-xray/xray-color-helper.cpp b/llvm/tools/llvm-xray/xray-color-helper.cpp
index c09cad3..ea7ff35 100644
--- a/llvm/tools/llvm-xray/xray-color-helper.cpp
+++ b/llvm/tools/llvm-xray/xray-color-helper.cpp
@@ -208,8 +208,8 @@ ColorHelper::getColorTuple(double Point) const {
// string.
std::string
ColorHelper::getColorString(std::tuple<uint8_t, uint8_t, uint8_t> t) {
- return llvm::formatv("#{0:X-2}{1:X-2}{2:X-2}", std::get<0>(t), std::get<1>(t),
- std::get<2>(t));
+ return std::string(llvm::formatv("#{0:X-2}{1:X-2}{2:X-2}", std::get<0>(t),
+ std::get<1>(t), std::get<2>(t)));
}
// Gets a color in a gradient given a number in the interval [0,1], it does this
diff --git a/llvm/tools/llvm-xray/xray-graph-diff.cpp b/llvm/tools/llvm-xray/xray-graph-diff.cpp
index a1bca32..11210e2 100644
--- a/llvm/tools/llvm-xray/xray-graph-diff.cpp
+++ b/llvm/tools/llvm-xray/xray-graph-diff.cpp
@@ -314,7 +314,7 @@ static std::string getLabel(const GraphDiffRenderer::GraphT::EdgeValueType &E,
const auto &RightStat = EdgeAttr.CorrEdgePtr[1]->second.S;
double RelDiff = statRelDiff(LeftStat, RightStat, EL);
- return formatv(R"({0:P})", RelDiff);
+ return std::string(formatv(R"({0:P})", RelDiff));
}
}
@@ -324,17 +324,19 @@ static std::string getLabel(const GraphDiffRenderer::GraphT::VertexValueType &V,
const auto &VertexAttr = V.second;
switch (VL) {
case GraphDiffRenderer::StatType::NONE:
- return formatv(R"({0})", truncateString(VertexId, TrunLen).str());
+ return std::string(
+ formatv(R"({0})", truncateString(VertexId, TrunLen).str()));
default:
if (containsNullptr(VertexAttr.CorrVertexPtr))
- return formatv(R"({0})", truncateString(VertexId, TrunLen).str());
+ return std::string(
+ formatv(R"({0})", truncateString(VertexId, TrunLen).str()));
const auto &LeftStat = VertexAttr.CorrVertexPtr[0]->second.S;
const auto &RightStat = VertexAttr.CorrVertexPtr[1]->second.S;
double RelDiff = statRelDiff(LeftStat, RightStat, VL);
- return formatv(R"({{{0}|{1:P}})", truncateString(VertexId, TrunLen).str(),
- RelDiff);
+ return std::string(formatv(
+ R"({{{0}|{1:P}})", truncateString(VertexId, TrunLen).str(), RelDiff));
}
}
diff --git a/llvm/tools/llvm-xray/xray-stacks.cpp b/llvm/tools/llvm-xray/xray-stacks.cpp
index cf29288..1e44902 100644
--- a/llvm/tools/llvm-xray/xray-stacks.cpp
+++ b/llvm/tools/llvm-xray/xray-stacks.cpp
@@ -674,11 +674,12 @@ std::string CreateErrorMessage(StackTrie::AccountRecordStatus Error,
const FuncIdConversionHelper &Converter) {
switch (Error) {
case StackTrie::AccountRecordStatus::ENTRY_NOT_FOUND:
- return formatv("Found record {0} with no matching function entry\n",
- format_xray_record(Record, Converter));
+ return std::string(
+ formatv("Found record {0} with no matching function entry\n",
+ format_xray_record(Record, Converter)));
default:
- return formatv("Unknown error type for record {0}\n",
- format_xray_record(Record, Converter));
+ return std::string(formatv("Unknown error type for record {0}\n",
+ format_xray_record(Record, Converter)));
}
}
diff --git a/llvm/tools/obj2yaml/elf2yaml.cpp b/llvm/tools/obj2yaml/elf2yaml.cpp
index 904d1ad..199a482 100644
--- a/llvm/tools/obj2yaml/elf2yaml.cpp
+++ b/llvm/tools/obj2yaml/elf2yaml.cpp
@@ -115,7 +115,7 @@ ELFDumper<ELFT>::getUniquedSectionName(const Elf_Shdr *Sec) {
if (!It.second)
Ret = (Name + " [" + Twine(++It.first->second) + "]").str();
else
- Ret = Name;
+ Ret = std::string(Name);
return Ret;
}
@@ -147,7 +147,7 @@ ELFDumper<ELFT>::getUniquedSymbolName(const Elf_Sym *Sym, StringRef StrTable,
SymbolNames[Index] =
(Name + " [" + Twine(++It.first->second) + "]").str();
else
- SymbolNames[Index] = Name;
+ SymbolNames[Index] = std::string(Name);
return SymbolNames[Index];
}
diff --git a/llvm/tools/opt/PassPrinters.cpp b/llvm/tools/opt/PassPrinters.cpp
index a877d9d..ed4fc1a 100644
--- a/llvm/tools/opt/PassPrinters.cpp
+++ b/llvm/tools/opt/PassPrinters.cpp
@@ -37,7 +37,7 @@ struct FunctionPassPrinter : public FunctionPass {
FunctionPassPrinter(const PassInfo *PI, raw_ostream &out, bool Quiet)
: FunctionPass(ID), PassToPrint(PI), Out(out), QuietPass(Quiet) {
- std::string PassToPrintName = PassToPrint->getPassName();
+ std::string PassToPrintName = std::string(PassToPrint->getPassName());
PassName = "FunctionPass Printer: " + PassToPrintName;
}
@@ -70,7 +70,7 @@ struct CallGraphSCCPassPrinter : public CallGraphSCCPass {
CallGraphSCCPassPrinter(const PassInfo *PI, raw_ostream &out, bool Quiet)
: CallGraphSCCPass(ID), PassToPrint(PI), Out(out), QuietPass(Quiet) {
- std::string PassToPrintName = PassToPrint->getPassName();
+ std::string PassToPrintName = std::string(PassToPrint->getPassName());
PassName = "CallGraphSCCPass Printer: " + PassToPrintName;
}
@@ -107,7 +107,7 @@ struct ModulePassPrinter : public ModulePass {
ModulePassPrinter(const PassInfo *PI, raw_ostream &out, bool Quiet)
: ModulePass(ID), PassToPrint(PI), Out(out), QuietPass(Quiet) {
- std::string PassToPrintName = PassToPrint->getPassName();
+ std::string PassToPrintName = std::string(PassToPrint->getPassName());
PassName = "ModulePass Printer: " + PassToPrintName;
}
@@ -139,7 +139,7 @@ struct LoopPassPrinter : public LoopPass {
LoopPassPrinter(const PassInfo *PI, raw_ostream &out, bool Quiet)
: LoopPass(ID), PassToPrint(PI), Out(out), QuietPass(Quiet) {
- std::string PassToPrintName = PassToPrint->getPassName();
+ std::string PassToPrintName = std::string(PassToPrint->getPassName());
PassName = "LoopPass Printer: " + PassToPrintName;
}
@@ -172,7 +172,7 @@ struct RegionPassPrinter : public RegionPass {
RegionPassPrinter(const PassInfo *PI, raw_ostream &out, bool Quiet)
: RegionPass(ID), PassToPrint(PI), Out(out), QuietPass(Quiet) {
- std::string PassToPrintName = PassToPrint->getPassName();
+ std::string PassToPrintName = std::string(PassToPrint->getPassName());
PassName = "RegionPass Printer: " + PassToPrintName;
}
diff --git a/llvm/tools/sancov/sancov.cpp b/llvm/tools/sancov/sancov.cpp
index 5523174..d404660 100644
--- a/llvm/tools/sancov/sancov.cpp
+++ b/llvm/tools/sancov/sancov.cpp
@@ -358,7 +358,7 @@ static std::string parseScalarString(yaml::Node *N) {
SmallString<64> StringStorage;
yaml::ScalarNode *S = dyn_cast<yaml::ScalarNode>(N);
failIf(!S, "expected string");
- return S->getValue(StringStorage);
+ return std::string(S->getValue(StringStorage));
}
std::unique_ptr<SymbolizedCoverage>
@@ -1070,11 +1070,11 @@ readSymbolizeAndMergeCmdArguments(std::vector<std::string> FileNames) {
CovFiles.insert(FileName);
} else {
auto ShortFileName = llvm::sys::path::filename(FileName);
- if (ObjFiles.find(ShortFileName) != ObjFiles.end()) {
+ if (ObjFiles.find(std::string(ShortFileName)) != ObjFiles.end()) {
fail("Duplicate binary file with a short name: " + ShortFileName);
}
- ObjFiles[ShortFileName] = FileName;
+ ObjFiles[std::string(ShortFileName)] = FileName;
if (FirstObjFile.empty())
FirstObjFile = FileName;
}
@@ -1093,7 +1093,7 @@ readSymbolizeAndMergeCmdArguments(std::vector<std::string> FileNames) {
FileName);
}
- auto Iter = ObjFiles.find(Components[1]);
+ auto Iter = ObjFiles.find(std::string(Components[1]));
if (Iter == ObjFiles.end()) {
fail("Object file for coverage not found: " + FileName);
}
diff --git a/llvm/unittests/ADT/TripleTest.cpp b/llvm/unittests/ADT/TripleTest.cpp
index ef7f82d..ca00837 100644
--- a/llvm/unittests/ADT/TripleTest.cpp
+++ b/llvm/unittests/ADT/TripleTest.cpp
@@ -584,7 +584,7 @@ TEST(TripleTest, ParsedIDs) {
}
static std::string Join(StringRef A, StringRef B, StringRef C) {
- std::string Str = A;
+ std::string Str = std::string(A);
Str += '-';
Str += B;
Str += '-';
@@ -593,7 +593,7 @@ static std::string Join(StringRef A, StringRef B, StringRef C) {
}
static std::string Join(StringRef A, StringRef B, StringRef C, StringRef D) {
- std::string Str = A;
+ std::string Str = std::string(A);
Str += '-';
Str += B;
Str += '-';
diff --git a/llvm/unittests/Analysis/LazyCallGraphTest.cpp b/llvm/unittests/Analysis/LazyCallGraphTest.cpp
index 42bdcfb..0da34eb 100644
--- a/llvm/unittests/Analysis/LazyCallGraphTest.cpp
+++ b/llvm/unittests/Analysis/LazyCallGraphTest.cpp
@@ -264,7 +264,7 @@ TEST(LazyCallGraphTest, BasicGraphFormation) {
std::vector<std::string> Nodes;
for (LazyCallGraph::Edge &E : A1.populate())
- Nodes.push_back(E.getFunction().getName());
+ Nodes.push_back(std::string(E.getFunction().getName()));
llvm::sort(Nodes);
EXPECT_EQ("a2", Nodes[0]);
EXPECT_EQ("b2", Nodes[1]);
@@ -279,7 +279,7 @@ TEST(LazyCallGraphTest, BasicGraphFormation) {
EXPECT_EQ("a1", A3->begin()->getFunction().getName());
for (LazyCallGraph::Edge &E : B1.populate())
- Nodes.push_back(E.getFunction().getName());
+ Nodes.push_back(std::string(E.getFunction().getName()));
llvm::sort(Nodes);
EXPECT_EQ("b2", Nodes[0]);
EXPECT_EQ("d3", Nodes[1]);
@@ -293,7 +293,7 @@ TEST(LazyCallGraphTest, BasicGraphFormation) {
EXPECT_EQ("b1", B3->begin()->getFunction().getName());
for (LazyCallGraph::Edge &E : C1.populate())
- Nodes.push_back(E.getFunction().getName());
+ Nodes.push_back(std::string(E.getFunction().getName()));
llvm::sort(Nodes);
EXPECT_EQ("c2", Nodes[0]);
EXPECT_EQ("d2", Nodes[1]);
@@ -323,7 +323,7 @@ TEST(LazyCallGraphTest, BasicGraphFormation) {
LazyCallGraph::RefSCC &D = *J++;
ASSERT_EQ(1, D.size());
for (LazyCallGraph::Node &N : *D.begin())
- Nodes.push_back(N.getFunction().getName());
+ Nodes.push_back(std::string(N.getFunction().getName()));
llvm::sort(Nodes);
EXPECT_EQ(3u, Nodes.size());
EXPECT_EQ("d1", Nodes[0]);
@@ -339,7 +339,7 @@ TEST(LazyCallGraphTest, BasicGraphFormation) {
LazyCallGraph::RefSCC &C = *J++;
ASSERT_EQ(1, C.size());
for (LazyCallGraph::Node &N : *C.begin())
- Nodes.push_back(N.getFunction().getName());
+ Nodes.push_back(std::string(N.getFunction().getName()));
llvm::sort(Nodes);
EXPECT_EQ(3u, Nodes.size());
EXPECT_EQ("c1", Nodes[0]);
@@ -355,7 +355,7 @@ TEST(LazyCallGraphTest, BasicGraphFormation) {
LazyCallGraph::RefSCC &B = *J++;
ASSERT_EQ(1, B.size());
for (LazyCallGraph::Node &N : *B.begin())
- Nodes.push_back(N.getFunction().getName());
+ Nodes.push_back(std::string(N.getFunction().getName()));
llvm::sort(Nodes);
EXPECT_EQ(3u, Nodes.size());
EXPECT_EQ("b1", Nodes[0]);
@@ -373,7 +373,7 @@ TEST(LazyCallGraphTest, BasicGraphFormation) {
LazyCallGraph::RefSCC &A = *J++;
ASSERT_EQ(1, A.size());
for (LazyCallGraph::Node &N : *A.begin())
- Nodes.push_back(N.getFunction().getName());
+ Nodes.push_back(std::string(N.getFunction().getName()));
llvm::sort(Nodes);
EXPECT_EQ(3u, Nodes.size());
EXPECT_EQ("a1", Nodes[0]);
@@ -477,7 +477,7 @@ TEST(LazyCallGraphTest, InnerSCCFormation) {
auto J = RC.begin();
LazyCallGraph::SCC &D = *J++;
for (LazyCallGraph::Node &N : D)
- Nodes.push_back(N.getFunction().getName());
+ Nodes.push_back(std::string(N.getFunction().getName()));
llvm::sort(Nodes);
EXPECT_EQ(3u, Nodes.size());
EXPECT_EQ("d1", Nodes[0]);
@@ -487,7 +487,7 @@ TEST(LazyCallGraphTest, InnerSCCFormation) {
LazyCallGraph::SCC &B = *J++;
for (LazyCallGraph::Node &N : B)
- Nodes.push_back(N.getFunction().getName());
+ Nodes.push_back(std::string(N.getFunction().getName()));
llvm::sort(Nodes);
EXPECT_EQ(3u, Nodes.size());
EXPECT_EQ("b1", Nodes[0]);
@@ -497,7 +497,7 @@ TEST(LazyCallGraphTest, InnerSCCFormation) {
LazyCallGraph::SCC &C = *J++;
for (LazyCallGraph::Node &N : C)
- Nodes.push_back(N.getFunction().getName());
+ Nodes.push_back(std::string(N.getFunction().getName()));
llvm::sort(Nodes);
EXPECT_EQ(3u, Nodes.size());
EXPECT_EQ("c1", Nodes[0]);
@@ -507,7 +507,7 @@ TEST(LazyCallGraphTest, InnerSCCFormation) {
LazyCallGraph::SCC &A = *J++;
for (LazyCallGraph::Node &N : A)
- Nodes.push_back(N.getFunction().getName());
+ Nodes.push_back(std::string(N.getFunction().getName()));
llvm::sort(Nodes);
EXPECT_EQ(3u, Nodes.size());
EXPECT_EQ("a1", Nodes[0]);
diff --git a/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp b/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
index bee1d409..5bd076e 100644
--- a/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
+++ b/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
@@ -160,7 +160,7 @@ TEST(GSYMTest, TestFunctionInfo) {
}
static void TestFunctionInfoDecodeError(llvm::support::endianness ByteOrder,
- std::string Bytes,
+ StringRef Bytes,
const uint64_t BaseAddr,
std::string ExpectedErrorMsg) {
uint8_t AddressSize = 4;
@@ -335,8 +335,7 @@ static void TestInlineInfoEncodeDecode(llvm::support::endianness ByteOrder,
}
static void TestInlineInfoDecodeError(llvm::support::endianness ByteOrder,
- std::string Bytes,
- const uint64_t BaseAddr,
+ StringRef Bytes, const uint64_t BaseAddr,
std::string ExpectedErrorMsg) {
uint8_t AddressSize = 4;
DataExtractor Data(Bytes, ByteOrder == llvm::support::little, AddressSize);
@@ -874,8 +873,7 @@ TEST(GSYMTest, TestLineTable) {
}
static void TestLineTableDecodeError(llvm::support::endianness ByteOrder,
- std::string Bytes,
- const uint64_t BaseAddr,
+ StringRef Bytes, const uint64_t BaseAddr,
std::string ExpectedErrorMsg) {
uint8_t AddressSize = 4;
DataExtractor Data(Bytes, ByteOrder == llvm::support::little, AddressSize);
@@ -962,7 +960,7 @@ static void TestHeaderEncodeError(const Header &H,
checkError(ExpectedErrorMsg, std::move(Err));
}
-static void TestHeaderDecodeError(std::string Bytes,
+static void TestHeaderDecodeError(StringRef Bytes,
std::string ExpectedErrorMsg) {
const support::endianness ByteOrder = llvm::support::little;
uint8_t AddressSize = 4;
diff --git a/llvm/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp b/llvm/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp
index 7b6d4b0..4b0d67c 100644
--- a/llvm/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp
@@ -72,7 +72,7 @@ TEST_F(LegacyAPIsStandardTest, LegacyLookupHelpersFn) {
bool BarMaterialized = false;
BarSym.setFlags(BarSym.getFlags() | JITSymbolFlags::Weak);
- auto LegacyLookup = [&](const std::string &Name) -> JITSymbol {
+ auto LegacyLookup = [&](StringRef Name) -> JITSymbol {
if (Name == "foo")
return FooSym;
diff --git a/llvm/unittests/ExecutionEngine/Orc/LegacyRTDyldObjectLinkingLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/LegacyRTDyldObjectLinkingLayerTest.cpp
index 896914d..c1eb455 100644
--- a/llvm/unittests/ExecutionEngine/Orc/LegacyRTDyldObjectLinkingLayerTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/LegacyRTDyldObjectLinkingLayerTest.cpp
@@ -185,7 +185,7 @@ TEST_F(LegacyRTDyldObjectLinkingLayerExecutionTest, NoDuplicateFinalization) {
cantFail(ObjLayer.addObject(K1, std::move(Obj1)));
auto K2 = ES.allocateVModule();
- auto LegacyLookup = [&](const std::string &Name) {
+ auto LegacyLookup = [&](StringRef Name) {
return ObjLayer.findSymbol(Name, true);
};
diff --git a/llvm/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp
index 429d917..31a4247 100644
--- a/llvm/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp
@@ -354,7 +354,7 @@ TEST(RemoteObjectLayer, FindSymbol) {
if (Name == "foobar")
return JITSymbol(0x12348765, JITSymbolFlags::Exported);
if (Name == "badsymbol")
- return make_error<JITSymbolNotFound>(Name);
+ return make_error<JITSymbolNotFound>(std::string(Name));
return nullptr;
};
return 42;
@@ -435,7 +435,7 @@ TEST(RemoteObjectLayer, FindSymbolIn) {
[](StringRef Name, bool ExportedSymbolsOnly) -> JITSymbol {
if (Name == "foobar")
return JITSymbol(0x12348765, JITSymbolFlags::Exported);
- return make_error<JITSymbolNotFound>(Name);
+ return make_error<JITSymbolNotFound>(std::string(Name));
};
// Dummy symbol table entry - this should not be visible to
// findSymbolIn.
@@ -443,7 +443,7 @@ TEST(RemoteObjectLayer, FindSymbolIn) {
[](StringRef Name, bool ExportedSymbolsOnly) -> JITSymbol {
if (Name == "barbaz")
return JITSymbol(0xdeadbeef, JITSymbolFlags::Exported);
- return make_error<JITSymbolNotFound>(Name);
+ return make_error<JITSymbolNotFound>(std::string(Name));
};
return 42;
diff --git a/llvm/unittests/IR/PassBuilderCallbacksTest.cpp b/llvm/unittests/IR/PassBuilderCallbacksTest.cpp
index 3f800b3..1f17a4f 100644
--- a/llvm/unittests/IR/PassBuilderCallbacksTest.cpp
+++ b/llvm/unittests/IR/PassBuilderCallbacksTest.cpp
@@ -270,10 +270,12 @@ static std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) {
/// Helper for HasName matcher that returns getName both for IRUnit and
/// for IRUnit pointer wrapper into llvm::Any (wrapped by PassInstrumentation).
template <typename IRUnitT> std::string getName(const IRUnitT &IR) {
- return IR.getName();
+ return std::string(IR.getName());
}
-template <> std::string getName(const StringRef &name) { return name; }
+template <> std::string getName(const StringRef &name) {
+ return std::string(name);
+}
template <> std::string getName(const llvm::Any &WrappedIR) {
if (any_isa<const Module *>(WrappedIR))
diff --git a/llvm/unittests/Passes/PluginsTest.cpp b/llvm/unittests/Passes/PluginsTest.cpp
index dd889e6..e250f196 100644
--- a/llvm/unittests/Passes/PluginsTest.cpp
+++ b/llvm/unittests/Passes/PluginsTest.cpp
@@ -34,7 +34,7 @@ static std::string LibPath(const std::string Name = "TestPlugin") {
std::string Path = sys::fs::getMainExecutable(Argv0, Ptr);
llvm::SmallString<256> Buf{sys::path::parent_path(Path)};
sys::path::append(Buf, (Name + LTDL_SHLIB_EXT).c_str());
- return Buf.str();
+ return std::string(Buf.str());
}
TEST(PluginsTests, LoadPlugin) {
diff --git a/llvm/unittests/ProfileData/SampleProfTest.cpp b/llvm/unittests/ProfileData/SampleProfTest.cpp
index 816f403..4c58d25 100644
--- a/llvm/unittests/ProfileData/SampleProfTest.cpp
+++ b/llvm/unittests/ProfileData/SampleProfTest.cpp
@@ -52,7 +52,8 @@ struct SampleProfTest : ::testing::Test {
void readProfile(const Module &M, StringRef Profile,
StringRef RemapFile = "") {
- auto ReaderOrErr = SampleProfileReader::create(Profile, Context, RemapFile);
+ auto ReaderOrErr = SampleProfileReader::create(
+ std::string(Profile), Context, std::string(RemapFile));
ASSERT_TRUE(NoError(ReaderOrErr.getError()));
Reader = std::move(ReaderOrErr.get());
Reader->collectFuncsFrom(M);
diff --git a/llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp b/llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
index d1afd50..3fa3ea9 100644
--- a/llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
+++ b/llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
@@ -27,7 +27,7 @@ std::string LibPath(const std::string Name = "PipSqueak") {
std::string Path = fs::getMainExecutable(Argv0, Ptr);
llvm::SmallString<256> Buf(path::parent_path(Path));
path::append(Buf, (Name + LTDL_SHLIB_EXT).c_str());
- return Buf.str();
+ return std::string(Buf.str());
}
#if defined(_WIN32) || (defined(HAVE_DLFCN_H) && defined(HAVE_DLOPEN))
diff --git a/llvm/unittests/Support/FileCheckTest.cpp b/llvm/unittests/Support/FileCheckTest.cpp
index a329d8c..a451e0b 100644
--- a/llvm/unittests/Support/FileCheckTest.cpp
+++ b/llvm/unittests/Support/FileCheckTest.cpp
@@ -262,12 +262,13 @@ TEST_F(FileCheckTest, Expression) {
static void
expectUndefErrors(std::unordered_set<std::string> ExpectedUndefVarNames,
Error Err) {
- EXPECT_THAT_ERROR(
- handleErrors(std::move(Err),
- [&](const UndefVarError &E) {
- EXPECT_EQ(ExpectedUndefVarNames.erase(E.getVarName()), 1U);
- }),
- Succeeded());
+ EXPECT_THAT_ERROR(handleErrors(std::move(Err),
+ [&](const UndefVarError &E) {
+ EXPECT_EQ(ExpectedUndefVarNames.erase(
+ std::string(E.getVarName())),
+ 1U);
+ }),
+ Succeeded());
EXPECT_TRUE(ExpectedUndefVarNames.empty()) << toString(ExpectedUndefVarNames);
}
@@ -936,12 +937,12 @@ TEST_F(FileCheckTest, FileCheckContext) {
EXPECT_EQ(*ExpressionVal, 12U);
ASSERT_THAT_EXPECTED(EmptyVar, Succeeded());
EXPECT_EQ(*EmptyVar, "");
- expectUndefErrors({UnknownVarStr}, UnknownVar.takeError());
+ expectUndefErrors({std::string(UnknownVarStr)}, UnknownVar.takeError());
// Clear local variables and check they become absent.
Cxt.clearLocalVars();
LocalVar = Cxt.getPatternVarValue(LocalVarStr);
- expectUndefErrors({LocalVarStr}, LocalVar.takeError());
+ expectUndefErrors({std::string(LocalVarStr)}, LocalVar.takeError());
// Check a numeric expression's evaluation fails if called after clearing of
// local variables, if it was created before. This is important because local
// variable clearing due to --enable-var-scope happens after numeric
diff --git a/llvm/unittests/Support/FileCollectorTest.cpp b/llvm/unittests/Support/FileCollectorTest.cpp
index c6aeedd..42a4877 100644
--- a/llvm/unittests/Support/FileCollectorTest.cpp
+++ b/llvm/unittests/Support/FileCollectorTest.cpp
@@ -101,7 +101,7 @@ struct ScopedFile {
TEST(FileCollectorTest, addFile) {
ScopedDir root("add_file_root", true);
- std::string root_fs = root.Path.str();
+ std::string root_fs = std::string(root.Path.str());
TestingFileCollector FileCollector(root_fs, root_fs);
FileCollector.addFile("/path/to/a");
@@ -128,7 +128,7 @@ TEST(FileCollectorTest, copyFiles) {
// Create file collector and add files.
ScopedDir root("copy_files_root", true);
- std::string root_fs = root.Path.str();
+ std::string root_fs = std::string(root.Path.str());
TestingFileCollector FileCollector(root_fs, root_fs);
FileCollector.addFile(a.Path);
FileCollector.addFile(b.Path);
@@ -156,7 +156,7 @@ TEST(FileCollectorTest, recordAndConstructDirectory) {
// Create file collector and add files.
ScopedDir root("copy_files_root", true);
- std::string root_fs = root.Path.str();
+ std::string root_fs = std::string(root.Path.str());
TestingFileCollector FileCollector(root_fs, root_fs);
FileCollector.addFile(a.Path);
@@ -194,7 +194,7 @@ TEST(FileCollectorTest, recordVFSAccesses) {
// Create file collector and add files.
ScopedDir root("copy_files_root", true);
- std::string root_fs = root.Path.str();
+ std::string root_fs = std::string(root.Path.str());
auto Collector = std::make_shared<TestingFileCollector>(root_fs, root_fs);
auto VFS =
FileCollector::createCollectorVFS(vfs::getRealFileSystem(), Collector);
@@ -241,7 +241,7 @@ TEST(FileCollectorTest, Symlinks) {
// Root where files are copied to.
ScopedDir reproducer_root("reproducer_root", true);
- std::string root_fs = reproducer_root.Path.str();
+ std::string root_fs = std::string(reproducer_root.Path.str());
TestingFileCollector FileCollector(root_fs, root_fs);
// Add all the files to the collector.
@@ -287,7 +287,7 @@ TEST(FileCollectorTest, recordVFSSymlinkAccesses) {
// Create file collector and add files.
ScopedDir root("copy_files_root", true);
- std::string root_fs = root.Path.str();
+ std::string root_fs = std::string(root.Path.str());
auto Collector = std::make_shared<TestingFileCollector>(root_fs, root_fs);
auto VFS =
FileCollector::createCollectorVFS(vfs::getRealFileSystem(), Collector);
diff --git a/llvm/unittests/Support/FileUtilitiesTest.cpp b/llvm/unittests/Support/FileUtilitiesTest.cpp
index 2bf9dc5..7fbb601 100644
--- a/llvm/unittests/Support/FileUtilitiesTest.cpp
+++ b/llvm/unittests/Support/FileUtilitiesTest.cpp
@@ -44,7 +44,7 @@ TEST(writeFileAtomicallyTest, Test) {
llvm::Error Err = llvm::writeFileAtomically(TempUniqTestFileModel, FinalTestfilePath, TestfileContent);
ASSERT_FALSE(static_cast<bool>(Err));
- std::ifstream FinalFileStream(FinalTestfilePath.str());
+ std::ifstream FinalFileStream(std::string(FinalTestfilePath.str()));
std::string FinalFileContent;
FinalFileStream >> FinalFileContent;
ASSERT_EQ(FinalFileContent, TestfileContent);
diff --git a/llvm/unittests/Support/FormatVariadicTest.cpp b/llvm/unittests/Support/FormatVariadicTest.cpp
index e9565c1..a4e8826 100644
--- a/llvm/unittests/Support/FormatVariadicTest.cpp
+++ b/llvm/unittests/Support/FormatVariadicTest.cpp
@@ -618,11 +618,11 @@ TEST(FormatVariadicTest, Adapter) {
TEST(FormatVariadicTest, MoveConstructor) {
auto fmt = formatv("{0} {1}", 1, 2);
auto fmt2 = std::move(fmt);
- std::string S = fmt2;
+ std::string S = std::string(fmt2);
EXPECT_EQ("1 2", S);
}
TEST(FormatVariadicTest, ImplicitConversions) {
- std::string S = formatv("{0} {1}", 1, 2);
+ std::string S = std::string(formatv("{0} {1}", 1, 2));
EXPECT_EQ("1 2", S);
SmallString<4> S2 = formatv("{0} {1}", 1, 2);
diff --git a/llvm/unittests/Support/JSONTest.cpp b/llvm/unittests/Support/JSONTest.cpp
index 93efcf2..0357e21 100644
--- a/llvm/unittests/Support/JSONTest.cpp
+++ b/llvm/unittests/Support/JSONTest.cpp
@@ -196,7 +196,7 @@ TEST(JSONTest, ParseErrors) {
FAIL() << "Parsed JSON >>> " << S << " <<< but wanted error: " << Msg;
} else {
handleAllErrors(E.takeError(), [S, Msg](const llvm::ErrorInfoBase &E) {
- EXPECT_THAT(E.message(), testing::HasSubstr(Msg)) << S;
+ EXPECT_THAT(E.message(), testing::HasSubstr(std::string(Msg))) << S;
});
}
};
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp
index b143ea6..601223b 100644
--- a/llvm/unittests/Support/Path.cpp
+++ b/llvm/unittests/Support/Path.cpp
@@ -849,7 +849,7 @@ TEST_F(FileSystemTest, DirectoryIteration) {
}
if (path::filename(i->path()) == "dontlookhere")
i.no_push();
- visited.push_back(path::filename(i->path()));
+ visited.push_back(std::string(path::filename(i->path())));
}
v_t::const_iterator a0 = find(visited, "a0");
v_t::const_iterator aa1 = find(visited, "aa1");
@@ -939,10 +939,10 @@ TEST_F(FileSystemTest, BrokenSymlinkDirectoryIteration) {
ASSERT_NO_ERROR(ec);
if (i->status().getError() ==
std::make_error_code(std::errc::no_such_file_or_directory)) {
- VisitedBrokenSymlinks.push_back(path::filename(i->path()));
+ VisitedBrokenSymlinks.push_back(std::string(path::filename(i->path())));
continue;
}
- VisitedNonBrokenSymlinks.push_back(path::filename(i->path()));
+ VisitedNonBrokenSymlinks.push_back(std::string(path::filename(i->path())));
}
EXPECT_THAT(VisitedNonBrokenSymlinks, UnorderedElementsAre("b", "d"));
VisitedNonBrokenSymlinks.clear();
@@ -956,10 +956,10 @@ TEST_F(FileSystemTest, BrokenSymlinkDirectoryIteration) {
ASSERT_NO_ERROR(ec);
if (i->status().getError() ==
std::make_error_code(std::errc::no_such_file_or_directory)) {
- VisitedBrokenSymlinks.push_back(path::filename(i->path()));
+ VisitedBrokenSymlinks.push_back(std::string(path::filename(i->path())));
continue;
}
- VisitedNonBrokenSymlinks.push_back(path::filename(i->path()));
+ VisitedNonBrokenSymlinks.push_back(std::string(path::filename(i->path())));
}
EXPECT_THAT(VisitedNonBrokenSymlinks,
UnorderedElementsAre("b", "bb", "d", "da", "dd", "ddd", "ddd"));
@@ -975,10 +975,10 @@ TEST_F(FileSystemTest, BrokenSymlinkDirectoryIteration) {
ASSERT_NO_ERROR(ec);
if (i->status().getError() ==
std::make_error_code(std::errc::no_such_file_or_directory)) {
- VisitedBrokenSymlinks.push_back(path::filename(i->path()));
+ VisitedBrokenSymlinks.push_back(std::string(path::filename(i->path())));
continue;
}
- VisitedNonBrokenSymlinks.push_back(path::filename(i->path()));
+ VisitedNonBrokenSymlinks.push_back(std::string(path::filename(i->path())));
}
EXPECT_THAT(VisitedNonBrokenSymlinks,
UnorderedElementsAreArray({"a", "b", "ba", "bb", "bc", "c", "d",
@@ -1187,7 +1187,7 @@ static std::string remove_dots(StringRef path, bool remove_dot_dot,
path::Style style) {
SmallString<256> buffer(path);
path::remove_dots(buffer, remove_dot_dot, style);
- return buffer.str();
+ return std::string(buffer.str());
}
TEST(Support, RemoveDots) {
diff --git a/llvm/unittests/Support/SpecialCaseListTest.cpp b/llvm/unittests/Support/SpecialCaseListTest.cpp
index de1f058..4be143d 100644
--- a/llvm/unittests/Support/SpecialCaseListTest.cpp
+++ b/llvm/unittests/Support/SpecialCaseListTest.cpp
@@ -39,7 +39,7 @@ protected:
raw_fd_ostream OF(FD, true, true);
OF << Contents;
OF.close();
- return Path.str();
+ return std::string(Path.str());
}
};
diff --git a/llvm/unittests/Support/VirtualFileSystemTest.cpp b/llvm/unittests/Support/VirtualFileSystemTest.cpp
index d61652b..ef92111 100644
--- a/llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ b/llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -107,8 +107,8 @@ public:
Path(_Path.str()) {
for (; I != FilesAndDirs.end(); ++I) {
if (isInPath(I->first)) {
- CurrentEntry =
- vfs::directory_entry(I->second.getName(), I->second.getType());
+ CurrentEntry = vfs::directory_entry(std::string(I->second.getName()),
+ I->second.getType());
break;
}
}
@@ -117,8 +117,8 @@ public:
++I;
for (; I != FilesAndDirs.end(); ++I) {
if (isInPath(I->first)) {
- CurrentEntry =
- vfs::directory_entry(I->second.getName(), I->second.getType());
+ CurrentEntry = vfs::directory_entry(std::string(I->second.getName()),
+ I->second.getType());
break;
}
}
@@ -135,7 +135,7 @@ public:
}
void addEntry(StringRef Path, const vfs::Status &Status) {
- FilesAndDirs[Path] = Status;
+ FilesAndDirs[std::string(Path)] = Status;
}
const_iterator findEntry(const Twine &Path) const {
@@ -144,7 +144,7 @@ public:
std::error_code EC = makeAbsolute(P);
assert(!EC);
(void)EC;
- return FilesAndDirs.find(P.str());
+ return FilesAndDirs.find(std::string(P.str()));
}
void addRegularFile(StringRef Path, sys::fs::perms Perms = sys::fs::all_all) {
@@ -179,7 +179,7 @@ class ErrorDummyFileSystem : public DummyFileSystem {
std::string getPosixPath(std::string S) {
SmallString<128> Result;
llvm::sys::path::native(S, Result, llvm::sys::path::Style::posix);
- return Result.str();
+ return std::string(Result.str());
}
} // end anonymous namespace
@@ -419,7 +419,7 @@ struct ScopedDir {
EC = llvm::sys::fs::createUniqueDirectory(Name, Path);
if (!EC) {
// Resolve any symlinks in the new directory.
- std::string UnresolvedPath = Path.str();
+ std::string UnresolvedPath = std::string(Path.str());
EC = llvm::sys::fs::real_path(UnresolvedPath, Path);
}
} else {
@@ -579,7 +579,7 @@ TEST(VirtualFileSystemTest, BrokenSymlinkRealFSIteration) {
for (vfs::directory_iterator I = FS->dir_begin(Twine(TestDirectory), EC), E;
I != E; I.increment(EC)) {
EXPECT_FALSE(EC);
- StatResults[sys::path::filename(I->path())] =
+ StatResults[std::string(sys::path::filename(I->path()))] =
FS->status(I->path()).getError();
}
EXPECT_THAT(
@@ -613,7 +613,7 @@ TEST(VirtualFileSystemTest, BasicRealFSRecursiveIteration) {
std::vector<std::string> Contents;
for (auto E = vfs::recursive_directory_iterator(); !EC && I != E;
I.increment(EC)) {
- Contents.push_back(I->path());
+ Contents.push_back(std::string(I->path()));
}
// Check contents, which may be in any order
@@ -653,7 +653,7 @@ TEST(VirtualFileSystemTest, BasicRealFSRecursiveIterationNoPush) {
std::vector<std::string> Contents;
for (auto E = vfs::recursive_directory_iterator(); !EC && I != E;
I.increment(EC)) {
- Contents.push_back(I->path());
+ Contents.push_back(std::string(I->path()));
char last = I->path().back();
switch (last) {
case 'b':
@@ -678,7 +678,7 @@ TEST(VirtualFileSystemTest, BasicRealFSRecursiveIterationNoPush) {
std::vector<std::string> Contents;
for (auto E = vfs::recursive_directory_iterator(); !EC && I != E;
I.increment(EC)) {
- Contents.push_back(I->path());
+ Contents.push_back(std::string(I->path()));
char last = I->path().back();
switch (last) {
case 'a':
@@ -733,17 +733,18 @@ TEST(VirtualFileSystemTest, BrokenSymlinkRealFSRecursiveIteration) {
I != E; I.increment(EC)) {
EXPECT_FALSE(EC);
(FS->status(I->path()) ? VisitedNonBrokenSymlinks : VisitedBrokenSymlinks)
- .push_back(I->path());
+ .push_back(std::string(I->path()));
}
// Check visited file names.
EXPECT_THAT(VisitedBrokenSymlinks,
- UnorderedElementsAre(StringRef(_a), StringRef(_ba),
- StringRef(_bc), StringRef(_c),
- StringRef(_e)));
+ UnorderedElementsAre(StringRef(_a).str(), StringRef(_ba).str(),
+ StringRef(_bc).str(), StringRef(_c).str(),
+ StringRef(_e).str()));
EXPECT_THAT(VisitedNonBrokenSymlinks,
- UnorderedElementsAre(StringRef(_b), StringRef(_bb), StringRef(_d),
- StringRef(_dd), StringRef(_ddd)));
+ UnorderedElementsAre(StringRef(_b).str(), StringRef(_bb).str(),
+ StringRef(_d).str(), StringRef(_dd).str(),
+ StringRef(_ddd).str()));
}
#endif
@@ -756,7 +757,7 @@ static void checkContents(DirIter I, ArrayRef<StringRef> ExpectedOut) {
// Do not rely on iteration order to check for contents, sort both
// content vectors before comparison.
for (DirIter E; !EC && I != E; I.increment(EC))
- InputToCheck.push_back(I->path());
+ InputToCheck.push_back(std::string(I->path()));
llvm::sort(InputToCheck);
llvm::sort(Expected);
@@ -1048,7 +1049,7 @@ TEST_F(InMemoryFileSystemTest, DirectoryIteration) {
ASSERT_FALSE(EC);
// When on Windows, we end up with "/b\\c" as the name. Convert to Posix
// path for the sake of the comparison.
- ASSERT_EQ("/b/c", getPosixPath(I->path()));
+ ASSERT_EQ("/b/c", getPosixPath(std::string(I->path())));
I.increment(EC);
ASSERT_FALSE(EC);
ASSERT_EQ(vfs::directory_iterator(), I);
@@ -1224,7 +1225,7 @@ TEST_F(InMemoryFileSystemTest, StatusName) {
llvm::vfs::directory_iterator It = NormalizedFS.dir_begin("../b", EC);
// When on Windows, we end up with "../b\\c" as the name. Convert to Posix
// path for the sake of the comparison.
- ASSERT_EQ("../b/c", getPosixPath(It->path()));
+ ASSERT_EQ("../b/c", getPosixPath(std::string(It->path())));
}
TEST_F(InMemoryFileSystemTest, AddHardLinkToFile) {
@@ -1324,7 +1325,7 @@ TEST_F(InMemoryFileSystemTest, RecursiveIterationWithHardLink) {
std::vector<std::string> Nodes;
for (auto E = vfs::recursive_directory_iterator(); !EC && I != E;
I.increment(EC)) {
- Nodes.push_back(getPosixPath(I->path()));
+ Nodes.push_back(getPosixPath(std::string(I->path())));
}
EXPECT_THAT(Nodes, testing::UnorderedElementsAre("/a", "/a/b", "/c", "/c/d"));
}
diff --git a/llvm/unittests/Support/raw_ostream_test.cpp b/llvm/unittests/Support/raw_ostream_test.cpp
index 0e56464..49685ef 100644
--- a/llvm/unittests/Support/raw_ostream_test.cpp
+++ b/llvm/unittests/Support/raw_ostream_test.cpp
@@ -35,7 +35,7 @@ template<typename T> std::string printToString(const T &Value,
for (unsigned i = 0; i != StartIndex; ++i)
OS << '?';
OS << Value;
- return OS.str().substr(StartIndex);
+ return std::string(OS.str().substr(StartIndex));
}
template<typename T> std::string printToStringUnbuffered(const T &Value) {
diff --git a/llvm/unittests/Target/AArch64/InstSizes.cpp b/llvm/unittests/Target/AArch64/InstSizes.cpp
index 74c5d38..01ec44e 100644
--- a/llvm/unittests/Target/AArch64/InstSizes.cpp
+++ b/llvm/unittests/Target/AArch64/InstSizes.cpp
@@ -28,8 +28,9 @@ std::unique_ptr<LLVMTargetMachine> createTargetMachine() {
}
std::unique_ptr<AArch64InstrInfo> createInstrInfo(TargetMachine *TM) {
- AArch64Subtarget ST(TM->getTargetTriple(), TM->getTargetCPU(),
- TM->getTargetFeatureString(), *TM, /* isLittle */ false);
+ AArch64Subtarget ST(TM->getTargetTriple(), std::string(TM->getTargetCPU()),
+ std::string(TM->getTargetFeatureString()), *TM,
+ /* isLittle */ false);
return std::make_unique<AArch64InstrInfo>(ST);
}
diff --git a/llvm/unittests/Target/ARM/MachineInstrTest.cpp b/llvm/unittests/Target/ARM/MachineInstrTest.cpp
index 2510011..284eb76 100644
--- a/llvm/unittests/Target/ARM/MachineInstrTest.cpp
+++ b/llvm/unittests/Target/ARM/MachineInstrTest.cpp
@@ -493,9 +493,9 @@ TEST(MachineInstrValidTailPredication, IsCorrect) {
static_cast<LLVMTargetMachine*>(
T->createTargetMachine(TT, "generic", "", Options, None, None,
CodeGenOpt::Default)));
- ARMSubtarget ST(TM->getTargetTriple(), TM->getTargetCPU(),
- TM->getTargetFeatureString(),
- *static_cast<const ARMBaseTargetMachine*>(TM.get()), false);
+ ARMSubtarget ST(TM->getTargetTriple(), std::string(TM->getTargetCPU()),
+ std::string(TM->getTargetFeatureString()),
+ *static_cast<const ARMBaseTargetMachine *>(TM.get()), false);
const ARMBaseInstrInfo *TII = ST.getInstrInfo();
auto MII = TM->getMCInstrInfo();
@@ -591,8 +591,8 @@ TEST(MachineInstr, HasSideEffects) {
auto TM = std::unique_ptr<LLVMTargetMachine>(
static_cast<LLVMTargetMachine *>(T->createTargetMachine(
TT, "generic", "", Options, None, None, CodeGenOpt::Default)));
- ARMSubtarget ST(TM->getTargetTriple(), TM->getTargetCPU(),
- TM->getTargetFeatureString(),
+ ARMSubtarget ST(TM->getTargetTriple(), std::string(TM->getTargetCPU()),
+ std::string(TM->getTargetFeatureString()),
*static_cast<const ARMBaseTargetMachine *>(TM.get()), false);
const ARMBaseInstrInfo *TII = ST.getInstrInfo();
auto MII = TM->getMCInstrInfo();
diff --git a/llvm/unittests/TextAPI/TextStubV1Tests.cpp b/llvm/unittests/TextAPI/TextStubV1Tests.cpp
index 4472b1c..68baac1 100644
--- a/llvm/unittests/TextAPI/TextStubV1Tests.cpp
+++ b/llvm/unittests/TextAPI/TextStubV1Tests.cpp
@@ -113,9 +113,9 @@ TEST(TBDv1, ReadFile) {
for (const auto *Sym : File->symbols()) {
EXPECT_FALSE(Sym->isWeakReferenced());
EXPECT_FALSE(Sym->isUndefined());
- Exports.emplace_back(ExportedSymbol{Sym->getKind(), Sym->getName(),
- Sym->isWeakDefined(),
- Sym->isThreadLocalValue()});
+ Exports.emplace_back(
+ ExportedSymbol{Sym->getKind(), std::string(Sym->getName()),
+ Sym->isWeakDefined(), Sym->isThreadLocalValue()});
}
llvm::sort(Exports.begin(), Exports.end());
diff --git a/llvm/unittests/TextAPI/TextStubV2Tests.cpp b/llvm/unittests/TextAPI/TextStubV2Tests.cpp
index dfe3afb..31de7fd 100644
--- a/llvm/unittests/TextAPI/TextStubV2Tests.cpp
+++ b/llvm/unittests/TextAPI/TextStubV2Tests.cpp
@@ -115,9 +115,9 @@ TEST(TBDv2, ReadFile) {
for (const auto *Sym : File->symbols()) {
EXPECT_FALSE(Sym->isWeakReferenced());
EXPECT_FALSE(Sym->isUndefined());
- Exports.emplace_back(ExportedSymbol{Sym->getKind(), Sym->getName(),
- Sym->isWeakDefined(),
- Sym->isThreadLocalValue()});
+ Exports.emplace_back(
+ ExportedSymbol{Sym->getKind(), std::string(Sym->getName()),
+ Sym->isWeakDefined(), Sym->isThreadLocalValue()});
}
llvm::sort(Exports.begin(), Exports.end());
diff --git a/llvm/unittests/TextAPI/TextStubV3Tests.cpp b/llvm/unittests/TextAPI/TextStubV3Tests.cpp
index 4a05920..0180989 100644
--- a/llvm/unittests/TextAPI/TextStubV3Tests.cpp
+++ b/llvm/unittests/TextAPI/TextStubV3Tests.cpp
@@ -129,9 +129,9 @@ TEST(TBDv3, ReadFile) {
for (const auto *Sym : File->symbols()) {
EXPECT_FALSE(Sym->isWeakReferenced());
EXPECT_FALSE(Sym->isUndefined());
- Exports.emplace_back(ExportedSymbol{Sym->getKind(), Sym->getName(),
- Sym->isWeakDefined(),
- Sym->isThreadLocalValue()});
+ Exports.emplace_back(
+ ExportedSymbol{Sym->getKind(), std::string(Sym->getName()),
+ Sym->isWeakDefined(), Sym->isThreadLocalValue()});
}
llvm::sort(Exports.begin(), Exports.end());
diff --git a/llvm/unittests/TextAPI/TextStubV4Tests.cpp b/llvm/unittests/TextAPI/TextStubV4Tests.cpp
index c007482..3ffb668 100644
--- a/llvm/unittests/TextAPI/TextStubV4Tests.cpp
+++ b/llvm/unittests/TextAPI/TextStubV4Tests.cpp
@@ -144,8 +144,8 @@ TEST(TBDv4, ReadFile) {
ExampleSymbolSeq Exports, Reexports, Undefineds;
ExampleSymbol temp;
for (const auto *Sym : File->symbols()) {
- temp = ExampleSymbol{Sym->getKind(), Sym->getName(), Sym->isWeakDefined(),
- Sym->isThreadLocalValue()};
+ temp = ExampleSymbol{Sym->getKind(), std::string(Sym->getName()),
+ Sym->isWeakDefined(), Sym->isThreadLocalValue()};
EXPECT_FALSE(Sym->isWeakReferenced());
if (Sym->isUndefined())
Undefineds.emplace_back(std::move(temp));
diff --git a/llvm/unittests/tools/llvm-exegesis/PerfHelperTest.cpp b/llvm/unittests/tools/llvm-exegesis/PerfHelperTest.cpp
index 7ff256f..5332b84 100644
--- a/llvm/unittests/tools/llvm-exegesis/PerfHelperTest.cpp
+++ b/llvm/unittests/tools/llvm-exegesis/PerfHelperTest.cpp
@@ -30,8 +30,8 @@ TEST(PerfHelperTest, FunctionalTest) {
Measure(
makeArrayRef(SingleEvent),
[&](const PerfEvent &Event, int64_t Value) {
- CallbackEventName = Event.name();
- CallbackEventNameFullyQualifed = Event.getPfmEventString();
+ CallbackEventName = std::string(Event.name());
+ CallbackEventNameFullyQualifed = std::string(Event.getPfmEventString());
CallbackEventCycles = Value;
},
EmptyFn);
diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
index ccf0959..ce824f7 100644
--- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
@@ -1085,7 +1085,7 @@ bool MatchableInfo::validate(StringRef CommentDelimiter, bool IsAlias) const {
// Verify that any operand is only mentioned once.
// We reject aliases and ignore instructions for now.
if (!IsAlias && TheDef->getValueAsString("AsmMatchConverter").empty() &&
- Tok[0] == '$' && !OperandNames.insert(Tok).second) {
+ Tok[0] == '$' && !OperandNames.insert(std::string(Tok)).second) {
LLVM_DEBUG({
errs() << "warning: '" << TheDef->getName() << "': "
<< "ignoring instruction with tied operand '"
@@ -1126,7 +1126,7 @@ static std::string getEnumNameForToken(StringRef Str) {
}
ClassInfo *AsmMatcherInfo::getTokenClass(StringRef Token) {
- ClassInfo *&Entry = TokenClasses[Token];
+ ClassInfo *&Entry = TokenClasses[std::string(Token)];
if (!Entry) {
Classes.emplace_front();
@@ -1134,7 +1134,7 @@ ClassInfo *AsmMatcherInfo::getTokenClass(StringRef Token) {
Entry->Kind = ClassInfo::Token;
Entry->ClassName = "Token";
Entry->Name = "MCK_" + getEnumNameForToken(Token);
- Entry->ValueName = Token;
+ Entry->ValueName = std::string(Token);
Entry->PredicateMethod = "<invalid>";
Entry->RenderMethod = "<invalid>";
Entry->ParserMethod = "";
@@ -1310,11 +1310,11 @@ buildRegisterClasses(SmallPtrSetImpl<Record*> &SingletonRegisters) {
Init *DiagnosticType = Def->getValueInit("DiagnosticType");
if (StringInit *SI = dyn_cast<StringInit>(DiagnosticType))
- CI->DiagnosticType = SI->getValue();
+ CI->DiagnosticType = std::string(SI->getValue());
Init *DiagnosticString = Def->getValueInit("DiagnosticString");
if (StringInit *SI = dyn_cast<StringInit>(DiagnosticString))
- CI->DiagnosticString = SI->getValue();
+ CI->DiagnosticString = std::string(SI->getValue());
// If we have a diagnostic string but the diagnostic type is not specified
// explicitly, create an anonymous diagnostic type.
@@ -1335,9 +1335,9 @@ buildRegisterClasses(SmallPtrSetImpl<Record*> &SingletonRegisters) {
assert(CI && "Missing singleton register class info!");
if (CI->ValueName.empty()) {
- CI->ClassName = Rec->getName();
+ CI->ClassName = std::string(Rec->getName());
CI->Name = "MCK_" + Rec->getName().str();
- CI->ValueName = Rec->getName();
+ CI->ValueName = std::string(Rec->getName());
} else
CI->ValueName = CI->ValueName + "," + Rec->getName().str();
}
@@ -1372,14 +1372,14 @@ void AsmMatcherInfo::buildOperandClasses() {
else
CI->SuperClasses.push_back(SC);
}
- CI->ClassName = Rec->getValueAsString("Name");
+ CI->ClassName = std::string(Rec->getValueAsString("Name"));
CI->Name = "MCK_" + CI->ClassName;
- CI->ValueName = Rec->getName();
+ CI->ValueName = std::string(Rec->getName());
// Get or construct the predicate method name.
Init *PMName = Rec->getValueInit("PredicateMethod");
if (StringInit *SI = dyn_cast<StringInit>(PMName)) {
- CI->PredicateMethod = SI->getValue();
+ CI->PredicateMethod = std::string(SI->getValue());
} else {
assert(isa<UnsetInit>(PMName) && "Unexpected PredicateMethod field!");
CI->PredicateMethod = "is" + CI->ClassName;
@@ -1388,7 +1388,7 @@ void AsmMatcherInfo::buildOperandClasses() {
// Get or construct the render method name.
Init *RMName = Rec->getValueInit("RenderMethod");
if (StringInit *SI = dyn_cast<StringInit>(RMName)) {
- CI->RenderMethod = SI->getValue();
+ CI->RenderMethod = std::string(SI->getValue());
} else {
assert(isa<UnsetInit>(RMName) && "Unexpected RenderMethod field!");
CI->RenderMethod = "add" + CI->ClassName + "Operands";
@@ -1397,15 +1397,15 @@ void AsmMatcherInfo::buildOperandClasses() {
// Get the parse method name or leave it as empty.
Init *PRMName = Rec->getValueInit("ParserMethod");
if (StringInit *SI = dyn_cast<StringInit>(PRMName))
- CI->ParserMethod = SI->getValue();
+ CI->ParserMethod = std::string(SI->getValue());
// Get the diagnostic type and string or leave them as empty.
Init *DiagnosticType = Rec->getValueInit("DiagnosticType");
if (StringInit *SI = dyn_cast<StringInit>(DiagnosticType))
- CI->DiagnosticType = SI->getValue();
+ CI->DiagnosticType = std::string(SI->getValue());
Init *DiagnosticString = Rec->getValueInit("DiagnosticString");
if (StringInit *SI = dyn_cast<StringInit>(DiagnosticString))
- CI->DiagnosticString = SI->getValue();
+ CI->DiagnosticString = std::string(SI->getValue());
// If we have a DiagnosticString, we need a DiagnosticType for use within
// the matcher.
if (!CI->DiagnosticString.empty() && CI->DiagnosticType.empty())
@@ -1418,7 +1418,7 @@ void AsmMatcherInfo::buildOperandClasses() {
// Get or construct the default method name.
Init *DMName = Rec->getValueInit("DefaultMethod");
if (StringInit *SI = dyn_cast<StringInit>(DMName)) {
- CI->DefaultMethod = SI->getValue();
+ CI->DefaultMethod = std::string(SI->getValue());
} else {
assert(isa<UnsetInit>(DMName) && "Unexpected DefaultMethod field!");
CI->DefaultMethod = "default" + CI->ClassName + "Operands";
@@ -2729,7 +2729,8 @@ static void emitMnemonicAliasVariant(raw_ostream &OS,const AsmMatcherInfo &Info,
StringRef AsmVariantName = R->getValueAsString("AsmVariantName");
if (AsmVariantName != AsmParserVariantName)
continue;
- AliasesFromMnemonic[R->getValueAsString("FromMnemonic")].push_back(R);
+ AliasesFromMnemonic[std::string(R->getValueAsString("FromMnemonic"))]
+ .push_back(R);
}
if (AliasesFromMnemonic.empty())
return;
@@ -3001,7 +3002,7 @@ static void emitAsmTiedOperandConstraints(CodeGenTarget &Target,
AsmMatcherInfo &Info,
raw_ostream &OS) {
std::string AsmParserName =
- Info.AsmParser->getValueAsString("AsmParserClassName");
+ std::string(Info.AsmParser->getValueAsString("AsmParserClassName"));
OS << "static bool ";
OS << "checkAsmTiedOperandConstraints(const " << Target.getName()
<< AsmParserName << "&AsmParser,\n";
diff --git a/llvm/utils/TableGen/AsmWriterEmitter.cpp b/llvm/utils/TableGen/AsmWriterEmitter.cpp
index c65a8ea..f2700b4 100644
--- a/llvm/utils/TableGen/AsmWriterEmitter.cpp
+++ b/llvm/utils/TableGen/AsmWriterEmitter.cpp
@@ -185,7 +185,7 @@ FindUniqueOperandCommands(std::vector<std::string> &UniqueOperandCommands,
InstIdxs[idx].push_back(i);
} else {
UniqueOperandCommands.push_back(std::move(Command));
- InstrsForCase.push_back(Inst.CGI->TheDef->getName());
+ InstrsForCase.push_back(std::string(Inst.CGI->TheDef->getName()));
InstIdxs.emplace_back();
InstIdxs.back().push_back(i);
@@ -507,9 +507,9 @@ emitRegisterNameString(raw_ostream &O, StringRef AltName,
// "NoRegAltName" is special. We don't need to do a lookup for that,
// as it's just a reference to the default register name.
if (AltName == "" || AltName == "NoRegAltName") {
- AsmName = Reg.TheDef->getValueAsString("AsmName");
+ AsmName = std::string(Reg.TheDef->getValueAsString("AsmName"));
if (AsmName.empty())
- AsmName = Reg.getName();
+ AsmName = std::string(Reg.getName());
} else {
// Make sure the register has an alternate name for this index.
std::vector<Record*> AltNameList =
@@ -528,7 +528,7 @@ emitRegisterNameString(raw_ostream &O, StringRef AltName,
PrintFatalError(Reg.TheDef->getLoc(),
"Register definition missing alt name for '" +
AltName + "'.");
- AsmName = AltNames[Idx];
+ AsmName = std::string(AltNames[Idx]);
}
}
StringTable.add(AsmName);
@@ -859,7 +859,7 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
PrintMethodIdx =
llvm::find(PrintMethods, PrintMethod) - PrintMethods.begin();
if (static_cast<unsigned>(PrintMethodIdx) == PrintMethods.size())
- PrintMethods.push_back(PrintMethod);
+ PrintMethods.push_back(std::string(PrintMethod));
}
}
@@ -871,12 +871,12 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
Record *R = CGA.ResultOperands[i].getRecord();
if (R->isSubClassOf("RegisterOperand"))
R = R->getValueAsDef("RegClass");
- IAP.addCond(formatv(
- "AliasPatternCond::K_RegClass, {0}::{1}RegClassID", Namespace,
- R->getName()));
+ IAP.addCond(std::string(
+ formatv("AliasPatternCond::K_RegClass, {0}::{1}RegClassID",
+ Namespace, R->getName())));
} else {
- IAP.addCond(formatv("AliasPatternCond::K_TiedReg, {0}",
- IAP.getOpIndex(ROName)));
+ IAP.addCond(std::string(formatv(
+ "AliasPatternCond::K_TiedReg, {0}", IAP.getOpIndex(ROName))));
}
} else {
// Assume all printable operands are desired for now. This can be
@@ -893,7 +893,8 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
} else
break; // No conditions on this operand at all
}
- IAP.addCond(formatv("AliasPatternCond::K_Custom, {0}", Entry));
+ IAP.addCond(
+ std::string(formatv("AliasPatternCond::K_Custom, {0}", Entry)));
}
break;
}
@@ -905,7 +906,8 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
if (Imm != Imm32)
PrintFatalError("Matching an alias with an immediate out of the "
"range of int32_t is not supported");
- IAP.addCond(formatv("AliasPatternCond::K_Imm, uint32_t({0})", Imm32));
+ IAP.addCond(std::string(
+ formatv("AliasPatternCond::K_Imm, uint32_t({0})", Imm32)));
break;
}
case CodeGenInstAlias::ResultOperand::K_Reg:
@@ -917,8 +919,8 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
}
StringRef Reg = CGA.ResultOperands[i].getRegister()->getName();
- IAP.addCond(
- formatv("AliasPatternCond::K_Reg, {0}::{1}", Namespace, Reg));
+ IAP.addCond(std::string(
+ formatv("AliasPatternCond::K_Reg, {0}::{1}", Namespace, Reg)));
break;
}
@@ -950,8 +952,9 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
assert(!Op.empty() && "Empty operator");
bool IsNeg = Op[0] == '!';
StringRef Feature = Op.drop_front(IsNeg ? 1 : 0);
- IAP.addCond(formatv("AliasPatternCond::K_{0}Feature, {1}::{2}",
- IsNeg ? "Neg" : "", Namespace, Feature));
+ IAP.addCond(
+ std::string(formatv("AliasPatternCond::K_{0}Feature, {1}::{2}",
+ IsNeg ? "Neg" : "", Namespace, Feature)));
}
}
diff --git a/llvm/utils/TableGen/CodeEmitterGen.cpp b/llvm/utils/TableGen/CodeEmitterGen.cpp
index 68cb8f1..6338d44 100644
--- a/llvm/utils/TableGen/CodeEmitterGen.cpp
+++ b/llvm/utils/TableGen/CodeEmitterGen.cpp
@@ -313,8 +313,8 @@ std::string CodeEmitterGen::getInstructionCaseForEncoding(Record *R, Record *Enc
// bits<5> RST = { ?, ?, ?, ?, ? };
if (RV.getPrefix() || RV.getValue()->isComplete())
continue;
-
- AddCodeToMergeInOperand(R, BI, RV.getName(), NumberedOp,
+
+ AddCodeToMergeInOperand(R, BI, std::string(RV.getName()), NumberedOp,
NamedOpIndices, Case, Target);
}
diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
index 7e0ba98..043cb38 100644
--- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
+++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
@@ -1091,7 +1091,8 @@ std::string TreePredicateFn::getPredCode() const {
.str();
}
- std::string PredicateCode = PatFragRec->getRecord()->getValueAsString("PredicateCode");
+ std::string PredicateCode =
+ std::string(PatFragRec->getRecord()->getValueAsString("PredicateCode"));
Code += PredicateCode;
@@ -1106,7 +1107,8 @@ bool TreePredicateFn::hasImmCode() const {
}
std::string TreePredicateFn::getImmCode() const {
- return PatFragRec->getRecord()->getValueAsString("ImmediateCode");
+ return std::string(
+ PatFragRec->getRecord()->getValueAsString("ImmediateCode"));
}
bool TreePredicateFn::immCodeUsesAPInt() const {
@@ -1223,7 +1225,8 @@ bool TreePredicateFn::hasGISelPredicateCode() const {
.empty();
}
std::string TreePredicateFn::getGISelPredicateCode() const {
- return PatFragRec->getRecord()->getValueAsString("GISelPredicateCode");
+ return std::string(
+ PatFragRec->getRecord()->getValueAsString("GISelPredicateCode"));
}
StringRef TreePredicateFn::getImmType() const {
@@ -2741,7 +2744,7 @@ TreePatternNodePtr TreePattern::ParseTreePattern(Init *TheInit,
if (R->getName() == "node" && !OpName.empty()) {
if (OpName.empty())
error("'node' argument requires a name to match with operand list");
- Args.push_back(OpName);
+ Args.push_back(std::string(OpName));
}
Res->setName(OpName);
@@ -2753,7 +2756,7 @@ TreePatternNodePtr TreePattern::ParseTreePattern(Init *TheInit,
if (OpName.empty())
error("'?' argument requires a name to match with operand list");
TreePatternNodePtr Res = std::make_shared<TreePatternNode>(TheInit, 1);
- Args.push_back(OpName);
+ Args.push_back(std::string(OpName));
Res->setName(OpName);
return Res;
}
@@ -3173,7 +3176,7 @@ void CodeGenDAGPatterns::ParsePatternFragments(bool OutFrags) {
P->error("'" + ArgNameStr +
"' does not occur in pattern or was multiply specified!");
OperandsSet.erase(ArgNameStr);
- Args.push_back(ArgNameStr);
+ Args.push_back(std::string(ArgNameStr));
}
if (!OperandsSet.empty())
diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.h b/llvm/utils/TableGen/CodeGenDAGPatterns.h
index 2c081b6..a3b84d7 100644
--- a/llvm/utils/TableGen/CodeGenDAGPatterns.h
+++ b/llvm/utils/TableGen/CodeGenDAGPatterns.h
@@ -430,7 +430,7 @@ class ScopedName {
std::string Identifier;
public:
ScopedName(unsigned Scope, StringRef Identifier)
- : Scope(Scope), Identifier(Identifier) {
+ : Scope(Scope), Identifier(std::string(Identifier)) {
assert(Scope != 0 &&
"Scope == 0 is used to indicate predicates without arguments");
}
@@ -1075,8 +1075,9 @@ public:
// The string will excute in a subclass of SelectionDAGISel.
// Cast to std::string explicitly to avoid ambiguity with StringRef.
std::string C = IsHwMode
- ? std::string("MF->getSubtarget().checkFeatures(\"" + Features + "\")")
- : std::string(Def->getValueAsString("CondString"));
+ ? std::string("MF->getSubtarget().checkFeatures(\"" +
+ Features + "\")")
+ : std::string(Def->getValueAsString("CondString"));
if (C.empty())
return "";
return IfCond ? C : "!("+C+')';
diff --git a/llvm/utils/TableGen/CodeGenHwModes.cpp b/llvm/utils/TableGen/CodeGenHwModes.cpp
index 9052cdd..2fec46c 100644
--- a/llvm/utils/TableGen/CodeGenHwModes.cpp
+++ b/llvm/utils/TableGen/CodeGenHwModes.cpp
@@ -20,7 +20,7 @@ StringRef CodeGenHwModes::DefaultModeName = "DefaultMode";
HwMode::HwMode(Record *R) {
Name = R->getName();
- Features = R->getValueAsString("Features");
+ Features = std::string(R->getValueAsString("Features"));
}
LLVM_DUMP_METHOD
diff --git a/llvm/utils/TableGen/CodeGenInstruction.cpp b/llvm/utils/TableGen/CodeGenInstruction.cpp
index 6bb4dbb..b97193d 100644
--- a/llvm/utils/TableGen/CodeGenInstruction.cpp
+++ b/llvm/utils/TableGen/CodeGenInstruction.cpp
@@ -80,16 +80,16 @@ CGIOperandList::CGIOperandList(Record *R) : TheDef(R) {
unsigned NumOps = 1;
DagInit *MIOpInfo = nullptr;
if (Rec->isSubClassOf("RegisterOperand")) {
- PrintMethod = Rec->getValueAsString("PrintMethod");
- OperandType = Rec->getValueAsString("OperandType");
- OperandNamespace = Rec->getValueAsString("OperandNamespace");
- EncoderMethod = Rec->getValueAsString("EncoderMethod");
+ PrintMethod = std::string(Rec->getValueAsString("PrintMethod"));
+ OperandType = std::string(Rec->getValueAsString("OperandType"));
+ OperandNamespace = std::string(Rec->getValueAsString("OperandNamespace"));
+ EncoderMethod = std::string(Rec->getValueAsString("EncoderMethod"));
} else if (Rec->isSubClassOf("Operand")) {
- PrintMethod = Rec->getValueAsString("PrintMethod");
- OperandType = Rec->getValueAsString("OperandType");
- OperandNamespace = Rec->getValueAsString("OperandNamespace");
+ PrintMethod = std::string(Rec->getValueAsString("PrintMethod"));
+ OperandType = std::string(Rec->getValueAsString("OperandType"));
+ OperandNamespace = std::string(Rec->getValueAsString("OperandNamespace"));
// If there is an explicit encoder method, use it.
- EncoderMethod = Rec->getValueAsString("EncoderMethod");
+ EncoderMethod = std::string(Rec->getValueAsString("EncoderMethod"));
MIOpInfo = Rec->getValueAsDag("MIOperandInfo");
// Verify that MIOpInfo has an 'ops' root value.
@@ -124,15 +124,16 @@ CGIOperandList::CGIOperandList(Record *R) : TheDef(R) {
PrintFatalError(R->getLoc(), "In instruction '" + R->getName() +
"', operand #" + Twine(i) +
" has no name!");
- if (!OperandNames.insert(ArgName).second)
+ if (!OperandNames.insert(std::string(ArgName)).second)
PrintFatalError(R->getLoc(),
"In instruction '" + R->getName() + "', operand #" +
Twine(i) +
" has the same name as a previous operand!");
- OperandList.emplace_back(Rec, ArgName, PrintMethod, EncoderMethod,
- OperandNamespace + "::" + OperandType, MIOperandNo,
- NumOps, MIOpInfo);
+ OperandList.emplace_back(
+ Rec, std::string(ArgName), std::string(PrintMethod),
+ std::string(EncoderMethod), OperandNamespace + "::" + OperandType,
+ MIOperandNo, NumOps, MIOpInfo);
MIOperandNo += NumOps;
}
@@ -265,7 +266,8 @@ static void ParseConstraint(const std::string &CStr, CGIOperandList &Ops,
PrintFatalError(
Rec->getLoc(), "Illegal format for tied-to constraint in '" +
Rec->getName() + "': '" + CStr + "'");
- std::string LHSOpName = StringRef(CStr).substr(start, wpos - start);
+ std::string LHSOpName =
+ std::string(StringRef(CStr).substr(start, wpos - start));
std::pair<unsigned,unsigned> LHSOp = Ops.ParseOperandName(LHSOpName, false);
wpos = CStr.find_first_not_of(" \t", pos + 1);
@@ -273,7 +275,7 @@ static void ParseConstraint(const std::string &CStr, CGIOperandList &Ops,
PrintFatalError(
Rec->getLoc(), "Illegal format for tied-to constraint: '" + CStr + "'");
- std::string RHSOpName = StringRef(CStr).substr(wpos);
+ std::string RHSOpName = std::string(StringRef(CStr).substr(wpos));
std::pair<unsigned,unsigned> RHSOp = Ops.ParseOperandName(RHSOpName, false);
// Sort the operands into order, which should put the output one
@@ -339,8 +341,8 @@ static void ParseConstraints(const std::string &CStr, CGIOperandList &Ops,
void CGIOperandList::ProcessDisableEncoding(std::string DisableEncoding) {
while (1) {
std::pair<StringRef, StringRef> P = getToken(DisableEncoding, " ,\t");
- std::string OpName = P.first;
- DisableEncoding = P.second;
+ std::string OpName = std::string(P.first);
+ DisableEncoding = std::string(P.second);
if (OpName.empty()) break;
// Figure out which operand this is.
@@ -361,7 +363,7 @@ void CGIOperandList::ProcessDisableEncoding(std::string DisableEncoding) {
CodeGenInstruction::CodeGenInstruction(Record *R)
: TheDef(R), Operands(R), InferredFrom(nullptr) {
Namespace = R->getValueAsString("Namespace");
- AsmString = R->getValueAsString("AsmString");
+ AsmString = std::string(R->getValueAsString("AsmString"));
isPreISelOpcode = R->getValueAsBit("isPreISelOpcode");
isReturn = R->getValueAsBit("isReturn");
@@ -420,15 +422,18 @@ CodeGenInstruction::CodeGenInstruction(Record *R)
hasChain_Inferred = false;
// Parse Constraints.
- ParseConstraints(R->getValueAsString("Constraints"), Operands, R);
+ ParseConstraints(std::string(R->getValueAsString("Constraints")), Operands,
+ R);
// Parse the DisableEncoding field.
- Operands.ProcessDisableEncoding(R->getValueAsString("DisableEncoding"));
+ Operands.ProcessDisableEncoding(
+ std::string(R->getValueAsString("DisableEncoding")));
// First check for a ComplexDeprecationPredicate.
if (R->getValue("ComplexDeprecationPredicate")) {
HasComplexDeprecationPredicate = true;
- DeprecatedReason = R->getValueAsString("ComplexDeprecationPredicate");
+ DeprecatedReason =
+ std::string(R->getValueAsString("ComplexDeprecationPredicate"));
} else if (RecordVal *Dep = R->getValue("DeprecatedFeatureMask")) {
// Check if we have a Subtarget feature mask.
HasComplexDeprecationPredicate = false;
@@ -541,7 +546,8 @@ bool CodeGenInstAlias::tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo,
if (!Result->getArgName(AliasOpNo))
PrintFatalError(Loc, "result argument #" + Twine(AliasOpNo) +
" must have a name!");
- ResOp = ResultOperand(Result->getArgNameStr(AliasOpNo), ResultRecord);
+ ResOp = ResultOperand(std::string(Result->getArgNameStr(AliasOpNo)),
+ ResultRecord);
return true;
}
@@ -559,7 +565,8 @@ bool CodeGenInstAlias::tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo,
if (!T.getRegisterClass(InstOpRec)
.hasSubClass(&T.getRegisterClass(ADI->getDef())))
return false;
- ResOp = ResultOperand(Result->getArgNameStr(AliasOpNo), ResultRecord);
+ ResOp = ResultOperand(std::string(Result->getArgNameStr(AliasOpNo)),
+ ResultRecord);
return true;
}
@@ -641,7 +648,8 @@ bool CodeGenInstAlias::tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo,
// MIOperandInfo perhaps?
if (InstOpRec->getValueInit("Type") != ADI->getDef()->getValueInit("Type"))
return false;
- ResOp = ResultOperand(Result->getArgNameStr(AliasOpNo), ADI->getDef());
+ ResOp = ResultOperand(std::string(Result->getArgNameStr(AliasOpNo)),
+ ADI->getDef());
return true;
}
@@ -668,8 +676,7 @@ unsigned CodeGenInstAlias::ResultOperand::getMINumOperands() const {
CodeGenInstAlias::CodeGenInstAlias(Record *R, CodeGenTarget &T)
: TheDef(R) {
Result = R->getValueAsDag("ResultInst");
- AsmString = R->getValueAsString("AsmString");
-
+ AsmString = std::string(R->getValueAsString("AsmString"));
// Verify that the root of the result is an instruction.
DefInit *DI = dyn_cast<DefInit>(Result->getOperator());
diff --git a/llvm/utils/TableGen/CodeGenMapTable.cpp b/llvm/utils/TableGen/CodeGenMapTable.cpp
index 793bb61..baca076 100644
--- a/llvm/utils/TableGen/CodeGenMapTable.cpp
+++ b/llvm/utils/TableGen/CodeGenMapTable.cpp
@@ -98,7 +98,7 @@ private:
public:
InstrMap(Record* MapRec) {
- Name = MapRec->getName();
+ Name = std::string(MapRec->getName());
// FilterClass - It's used to reduce the search space only to the
// instructions that define the kind of relationship modeled by
diff --git a/llvm/utils/TableGen/CodeGenRegisters.cpp b/llvm/utils/TableGen/CodeGenRegisters.cpp
index 9df09fd..66a37aa 100644
--- a/llvm/utils/TableGen/CodeGenRegisters.cpp
+++ b/llvm/utils/TableGen/CodeGenRegisters.cpp
@@ -52,18 +52,18 @@ using namespace llvm;
CodeGenSubRegIndex::CodeGenSubRegIndex(Record *R, unsigned Enum)
: TheDef(R), EnumValue(Enum), AllSuperRegsCovered(true), Artificial(true) {
- Name = R->getName();
+ Name = std::string(R->getName());
if (R->getValue("Namespace"))
- Namespace = R->getValueAsString("Namespace");
+ Namespace = std::string(R->getValueAsString("Namespace"));
Size = R->getValueAsInt("Size");
Offset = R->getValueAsInt("Offset");
}
CodeGenSubRegIndex::CodeGenSubRegIndex(StringRef N, StringRef Nspace,
unsigned Enum)
- : TheDef(nullptr), Name(N), Namespace(Nspace), Size(-1), Offset(-1),
- EnumValue(Enum), AllSuperRegsCovered(true), Artificial(true) {
-}
+ : TheDef(nullptr), Name(std::string(N)), Namespace(std::string(Nspace)),
+ Size(-1), Offset(-1), EnumValue(Enum), AllSuperRegsCovered(true),
+ Artificial(true) {}
std::string CodeGenSubRegIndex::getQualifiedName() const {
std::string N = getNamespace();
@@ -739,11 +739,8 @@ static void sortAndUniqueRegisters(CodeGenRegister::Vec &M) {
}
CodeGenRegisterClass::CodeGenRegisterClass(CodeGenRegBank &RegBank, Record *R)
- : TheDef(R),
- Name(R->getName()),
- TopoSigs(RegBank.getNumTopoSigs()),
- EnumValue(-1) {
-
+ : TheDef(R), Name(std::string(R->getName())),
+ TopoSigs(RegBank.getNumTopoSigs()), EnumValue(-1) {
std::vector<Record*> TypeList = R->getValueAsListOfDefs("RegTypes");
for (unsigned i = 0, e = TypeList.size(); i != e; ++i) {
Record *Type = TypeList[i];
@@ -816,15 +813,9 @@ CodeGenRegisterClass::CodeGenRegisterClass(CodeGenRegBank &RegBank, Record *R)
// class structure has been computed.
CodeGenRegisterClass::CodeGenRegisterClass(CodeGenRegBank &RegBank,
StringRef Name, Key Props)
- : Members(*Props.Members),
- TheDef(nullptr),
- Name(Name),
- TopoSigs(RegBank.getNumTopoSigs()),
- EnumValue(-1),
- RSI(Props.RSI),
- CopyCost(0),
- Allocatable(true),
- AllocationPriority(0) {
+ : Members(*Props.Members), TheDef(nullptr), Name(std::string(Name)),
+ TopoSigs(RegBank.getNumTopoSigs()), EnumValue(-1), RSI(Props.RSI),
+ CopyCost(0), Allocatable(true), AllocationPriority(0) {
Artificial = true;
for (const auto R : Members) {
TopoSigs.set(R->getTopoSig());
diff --git a/llvm/utils/TableGen/CodeGenSchedule.cpp b/llvm/utils/TableGen/CodeGenSchedule.cpp
index f12d7d4..09cbb23 100644
--- a/llvm/utils/TableGen/CodeGenSchedule.cpp
+++ b/llvm/utils/TableGen/CodeGenSchedule.cpp
@@ -106,7 +106,7 @@ struct InstRegexOp : public SetTheory::Operator {
StringRef PatStr = Original.substr(FirstMeta);
if (!PatStr.empty()) {
// For the rest use a python-style prefix match.
- std::string pat = PatStr;
+ std::string pat = std::string(PatStr);
if (pat[0] != '^') {
pat.insert(0, "^(");
pat.insert(pat.end(), ')');
@@ -546,7 +546,7 @@ void CodeGenSchedModels::addProcModel(Record *ProcDef) {
if (!ProcModelMap.insert(std::make_pair(ModelKey, ProcModels.size())).second)
return;
- std::string Name = ModelKey->getName();
+ std::string Name = std::string(ModelKey->getName());
if (ModelKey->isSubClassOf("SchedMachineModel")) {
Record *ItinsDef = ModelKey->getValueAsDef("Itineraries");
ProcModels.emplace_back(ProcModels.size(), Name, ModelKey, ItinsDef);
@@ -977,7 +977,7 @@ CodeGenSchedModels::createSchedClassName(Record *ItinClassDef,
std::string Name;
if (ItinClassDef && ItinClassDef->getName() != "NoItinerary")
- Name = ItinClassDef->getName();
+ Name = std::string(ItinClassDef->getName());
for (unsigned Idx : OperWrites) {
if (!Name.empty())
Name += '_';
diff --git a/llvm/utils/TableGen/CodeGenSchedule.h b/llvm/utils/TableGen/CodeGenSchedule.h
index c26fb1f..c487d14 100644
--- a/llvm/utils/TableGen/CodeGenSchedule.h
+++ b/llvm/utils/TableGen/CodeGenSchedule.h
@@ -58,7 +58,7 @@ struct CodeGenSchedRW {
HasVariants(false), IsVariadic(false), IsSequence(false) {}
CodeGenSchedRW(unsigned Idx, Record *Def)
: Index(Idx), TheDef(Def), IsAlias(false), IsVariadic(false) {
- Name = Def->getName();
+ Name = std::string(Def->getName());
IsRead = Def->isSubClassOf("SchedRead");
HasVariants = Def->isSubClassOf("SchedVariant");
if (HasVariants)
diff --git a/llvm/utils/TableGen/CodeGenTarget.cpp b/llvm/utils/TableGen/CodeGenTarget.cpp
index acfb143..de41692 100644
--- a/llvm/utils/TableGen/CodeGenTarget.cpp
+++ b/llvm/utils/TableGen/CodeGenTarget.cpp
@@ -206,8 +206,9 @@ StringRef llvm::getEnumName(MVT::SimpleValueType T) {
std::string llvm::getQualifiedName(const Record *R) {
std::string Namespace;
if (R->getValue("Namespace"))
- Namespace = R->getValueAsString("Namespace");
- if (Namespace.empty()) return R->getName();
+ Namespace = std::string(R->getValueAsString("Namespace"));
+ if (Namespace.empty())
+ return std::string(R->getName());
return Namespace + "::" + R->getName().str();
}
@@ -526,7 +527,7 @@ bool CodeGenTarget::guessInstructionProperties() const {
ComplexPattern::ComplexPattern(Record *R) {
Ty = ::getValueType(R->getValueAsDef("Ty"));
NumOperands = R->getValueAsInt("NumOperands");
- SelectFunc = R->getValueAsString("SelectFunc");
+ SelectFunc = std::string(R->getValueAsString("SelectFunc"));
RootNodes = R->getValueAsListOfDefs("RootNodes");
// FIXME: This is a hack to statically increase the priority of patterns which
@@ -598,7 +599,7 @@ CodeGenIntrinsicTable::CodeGenIntrinsicTable(const RecordKeeper &RC) {
CodeGenIntrinsic::CodeGenIntrinsic(Record *R) {
TheDef = R;
- std::string DefName = R->getName();
+ std::string DefName = std::string(R->getName());
ArrayRef<SMLoc> DefLoc = R->getLoc();
ModRef = ReadWriteMem;
Properties = 0;
@@ -621,12 +622,12 @@ CodeGenIntrinsic::CodeGenIntrinsic(Record *R) {
EnumName = std::string(DefName.begin()+4, DefName.end());
if (R->getValue("GCCBuiltinName")) // Ignore a missing GCCBuiltinName field.
- GCCBuiltinName = R->getValueAsString("GCCBuiltinName");
+ GCCBuiltinName = std::string(R->getValueAsString("GCCBuiltinName"));
if (R->getValue("MSBuiltinName")) // Ignore a missing MSBuiltinName field.
- MSBuiltinName = R->getValueAsString("MSBuiltinName");
+ MSBuiltinName = std::string(R->getValueAsString("MSBuiltinName"));
- TargetPrefix = R->getValueAsString("TargetPrefix");
- Name = R->getValueAsString("LLVMName");
+ TargetPrefix = std::string(R->getValueAsString("TargetPrefix"));
+ Name = std::string(R->getValueAsString("LLVMName"));
if (Name == "") {
// If an explicit name isn't specified, derive one from the DefName.
diff --git a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
index e9f1fb9..60f501c 100644
--- a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
@@ -960,7 +960,8 @@ void MatcherTableEmitter::EmitPredicateFunctions(raw_ostream &OS) {
OS << "// " << NodeXForms[i]->getName();
OS << '\n';
- std::string ClassName = CGP.getSDNodeInfo(SDNode).getSDClassName();
+ std::string ClassName =
+ std::string(CGP.getSDNodeInfo(SDNode).getSDClassName());
if (ClassName == "SDNode")
OS << " SDNode *N = V.getNode();\n";
else
diff --git a/llvm/utils/TableGen/DAGISelMatcherGen.cpp b/llvm/utils/TableGen/DAGISelMatcherGen.cpp
index 6a86868..cce9383 100644
--- a/llvm/utils/TableGen/DAGISelMatcherGen.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherGen.cpp
@@ -311,7 +311,7 @@ void MatcherGen::EmitOperatorMatchCode(const TreePatternNode *N,
// The "name" of a non-leaf complex pattern (MY_PAT $op1, $op2) is
// "MY_PAT:op1:op2". We should already have validated that the uses are
// consistent.
- std::string PatternName = N->getOperator()->getName();
+ std::string PatternName = std::string(N->getOperator()->getName());
for (unsigned i = 0; i < N->getNumChildren(); ++i) {
PatternName += ":";
PatternName += N->getChild(i)->getName();
diff --git a/llvm/utils/TableGen/DFAEmitter.cpp b/llvm/utils/TableGen/DFAEmitter.cpp
index dd3db7c..6521dc1 100644
--- a/llvm/utils/TableGen/DFAEmitter.cpp
+++ b/llvm/utils/TableGen/DFAEmitter.cpp
@@ -345,7 +345,7 @@ Transition::Transition(Record *R, Automaton *Parent) {
Types.emplace_back("unsigned");
} else if (isa<StringRecTy>(SymbolV->getType()) ||
isa<CodeRecTy>(SymbolV->getType())) {
- Actions.emplace_back(nullptr, 0, R->getValueAsString(A));
+ Actions.emplace_back(nullptr, 0, std::string(R->getValueAsString(A)));
Types.emplace_back("std::string");
} else {
report_fatal_error("Unhandled symbol type!");
@@ -353,7 +353,7 @@ Transition::Transition(Record *R, Automaton *Parent) {
StringRef TypeOverride = Parent->getActionSymbolType(A);
if (!TypeOverride.empty())
- Types.back() = TypeOverride;
+ Types.back() = std::string(TypeOverride);
}
}
diff --git a/llvm/utils/TableGen/DFAPacketizerEmitter.cpp b/llvm/utils/TableGen/DFAPacketizerEmitter.cpp
index 018bda1..b4100fc 100644
--- a/llvm/utils/TableGen/DFAPacketizerEmitter.cpp
+++ b/llvm/utils/TableGen/DFAPacketizerEmitter.cpp
@@ -93,7 +93,7 @@ public:
} // end anonymous namespace
DFAPacketizerEmitter::DFAPacketizerEmitter(RecordKeeper &R)
- : TargetName(CodeGenTarget(R).getName()), Records(R) {}
+ : TargetName(std::string(CodeGenTarget(R).getName())), Records(R) {}
int DFAPacketizerEmitter::collectAllFuncUnits(
ArrayRef<const CodeGenProcModel *> ProcModels) {
@@ -120,7 +120,7 @@ int DFAPacketizerEmitter::collectAllFuncUnits(
assert((j < DFA_MAX_RESOURCES) &&
"Exceeded maximum number of representable resources");
uint64_t FuncResources = 1ULL << j;
- FUNameToBitsMap[FUs[j]->getName()] = FuncResources;
+ FUNameToBitsMap[std::string(FUs[j]->getName())] = FuncResources;
LLVM_DEBUG(dbgs() << " " << FUs[j]->getName() << ":0x"
<< Twine::utohexstr(FuncResources));
}
@@ -152,13 +152,13 @@ int DFAPacketizerEmitter::collectAllComboFuncs(ArrayRef<Record *> ComboFuncList)
Record *ComboFunc = FuncData->getValueAsDef("TheComboFunc");
const std::vector<Record *> &FuncList =
FuncData->getValueAsListOfDefs("FuncList");
- const std::string &ComboFuncName = ComboFunc->getName();
+ const std::string &ComboFuncName = std::string(ComboFunc->getName());
uint64_t ComboBit = FUNameToBitsMap[ComboFuncName];
uint64_t ComboResources = ComboBit;
LLVM_DEBUG(dbgs() << " combo: " << ComboFuncName << ":0x"
<< Twine::utohexstr(ComboResources) << "\n");
for (unsigned k = 0, M = FuncList.size(); k < M; ++k) {
- std::string FuncName = FuncList[k]->getName();
+ std::string FuncName = std::string(FuncList[k]->getName());
uint64_t FuncResources = FUNameToBitsMap[FuncName];
LLVM_DEBUG(dbgs() << " " << FuncName << ":0x"
<< Twine::utohexstr(FuncResources) << "\n");
@@ -181,7 +181,7 @@ DFAPacketizerEmitter::getResourcesForItinerary(Record *Itinerary) {
for (Record *StageDef : Itinerary->getValueAsListOfDefs("Stages")) {
uint64_t StageResources = 0;
for (Record *Unit : StageDef->getValueAsListOfDefs("Units")) {
- StageResources |= FUNameToBitsMap[Unit->getName()];
+ StageResources |= FUNameToBitsMap[std::string(Unit->getName())];
}
if (StageResources != 0)
Resources.push_back(StageResources);
@@ -219,7 +219,7 @@ void DFAPacketizerEmitter::run(raw_ostream &OS) {
for (const CodeGenProcModel &ProcModel : CGS.procModels()) {
if (ProcModel.hasItineraries()) {
auto NS = ProcModel.ItinsDef->getValueAsString("PacketizerNamespace");
- ItinsByNamespace[NS].push_back(&ProcModel);
+ ItinsByNamespace[std::string(NS)].push_back(&ProcModel);
}
}
diff --git a/llvm/utils/TableGen/DisassemblerEmitter.cpp b/llvm/utils/TableGen/DisassemblerEmitter.cpp
index 0002b0e..7c3f53b 100644
--- a/llvm/utils/TableGen/DisassemblerEmitter.cpp
+++ b/llvm/utils/TableGen/DisassemblerEmitter.cpp
@@ -136,7 +136,7 @@ void EmitDisassembler(RecordKeeper &Records, raw_ostream &OS) {
// ARM and Thumb have a CHECK() macro to deal with DecodeStatuses.
if (Target.getName() == "ARM" || Target.getName() == "Thumb" ||
Target.getName() == "AArch64" || Target.getName() == "ARM64") {
- std::string PredicateNamespace = Target.getName();
+ std::string PredicateNamespace = std::string(Target.getName());
if (PredicateNamespace == "Thumb")
PredicateNamespace = "ARM";
@@ -148,9 +148,9 @@ void EmitDisassembler(RecordKeeper &Records, raw_ostream &OS) {
return;
}
- EmitFixedLenDecoder(Records, OS, Target.getName(),
- "if (", " == MCDisassembler::Fail)",
- "MCDisassembler::Success", "MCDisassembler::Fail", "");
+ EmitFixedLenDecoder(Records, OS, std::string(Target.getName()), "if (",
+ " == MCDisassembler::Fail)", "MCDisassembler::Success",
+ "MCDisassembler::Fail", "");
}
} // end namespace llvm
diff --git a/llvm/utils/TableGen/ExegesisEmitter.cpp b/llvm/utils/TableGen/ExegesisEmitter.cpp
index 976d5f5..8f784e4 100644
--- a/llvm/utils/TableGen/ExegesisEmitter.cpp
+++ b/llvm/utils/TableGen/ExegesisEmitter.cpp
@@ -101,7 +101,7 @@ ExegesisEmitter::ExegesisEmitter(RecordKeeper &RK)
PrintFatalError("ERROR: No 'Target' subclasses defined!");
if (Targets.size() != 1)
PrintFatalError("ERROR: Multiple subclasses of Target defined!");
- Target = Targets[0]->getName();
+ Target = std::string(Targets[0]->getName());
}
void ExegesisEmitter::emitPfmCountersInfo(const Record &Def,
diff --git a/llvm/utils/TableGen/FastISelEmitter.cpp b/llvm/utils/TableGen/FastISelEmitter.cpp
index b399568..0729ab70 100644
--- a/llvm/utils/TableGen/FastISelEmitter.cpp
+++ b/llvm/utils/TableGen/FastISelEmitter.cpp
@@ -414,7 +414,7 @@ private:
} // End anonymous namespace
static std::string getOpcodeName(Record *Op, CodeGenDAGPatterns &CGP) {
- return CGP.getSDNodeInfo(Op).getEnumName();
+ return std::string(CGP.getSDNodeInfo(Op).getEnumName());
}
static std::string getLegalCName(std::string OpName) {
@@ -719,22 +719,20 @@ void FastISelMap::printFunctionDefinitions(raw_ostream &OS) {
MVT::SimpleValueType RetVT = RI->first;
const PredMap &PM = RI->second;
- OS << "unsigned fastEmit_"
- << getLegalCName(Opcode)
- << "_" << getLegalCName(getName(VT))
- << "_" << getLegalCName(getName(RetVT)) << "_";
+ OS << "unsigned fastEmit_" << getLegalCName(Opcode) << "_"
+ << getLegalCName(std::string(getName(VT))) << "_"
+ << getLegalCName(std::string(getName(RetVT))) << "_";
Operands.PrintManglingSuffix(OS, ImmediatePredicates);
OS << "(";
Operands.PrintParameters(OS);
OS << ") {\n";
- emitInstructionCode(OS, Operands, PM, getName(RetVT));
+ emitInstructionCode(OS, Operands, PM, std::string(getName(RetVT)));
}
// Emit one function for the type that demultiplexes on return type.
- OS << "unsigned fastEmit_"
- << getLegalCName(Opcode) << "_"
- << getLegalCName(getName(VT)) << "_";
+ OS << "unsigned fastEmit_" << getLegalCName(Opcode) << "_"
+ << getLegalCName(std::string(getName(VT))) << "_";
Operands.PrintManglingSuffix(OS, ImmediatePredicates);
OS << "(MVT RetVT";
if (!Operands.empty())
@@ -745,8 +743,9 @@ void FastISelMap::printFunctionDefinitions(raw_ostream &OS) {
RI != RE; ++RI) {
MVT::SimpleValueType RetVT = RI->first;
OS << " case " << getName(RetVT) << ": return fastEmit_"
- << getLegalCName(Opcode) << "_" << getLegalCName(getName(VT))
- << "_" << getLegalCName(getName(RetVT)) << "_";
+ << getLegalCName(Opcode) << "_"
+ << getLegalCName(std::string(getName(VT))) << "_"
+ << getLegalCName(std::string(getName(RetVT))) << "_";
Operands.PrintManglingSuffix(OS, ImmediatePredicates);
OS << "(";
Operands.PrintArguments(OS);
@@ -756,9 +755,8 @@ void FastISelMap::printFunctionDefinitions(raw_ostream &OS) {
} else {
// Non-variadic return type.
- OS << "unsigned fastEmit_"
- << getLegalCName(Opcode) << "_"
- << getLegalCName(getName(VT)) << "_";
+ OS << "unsigned fastEmit_" << getLegalCName(Opcode) << "_"
+ << getLegalCName(std::string(getName(VT))) << "_";
Operands.PrintManglingSuffix(OS, ImmediatePredicates);
OS << "(MVT RetVT";
if (!Operands.empty())
@@ -788,7 +786,7 @@ void FastISelMap::printFunctionDefinitions(raw_ostream &OS) {
for (TypeRetPredMap::const_iterator TI = TM.begin(), TE = TM.end();
TI != TE; ++TI) {
MVT::SimpleValueType VT = TI->first;
- std::string TypeName = getName(VT);
+ std::string TypeName = std::string(getName(VT));
OS << " case " << TypeName << ": return fastEmit_"
<< getLegalCName(Opcode) << "_" << getLegalCName(TypeName) << "_";
Operands.PrintManglingSuffix(OS, ImmediatePredicates);
diff --git a/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp b/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
index 21ec589..b587029 100644
--- a/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
+++ b/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
@@ -1772,7 +1772,7 @@ static std::string findOperandDecoderMethod(TypedInit *TI) {
StringInit *String = DecoderString ?
dyn_cast<StringInit>(DecoderString->getValue()) : nullptr;
if (String) {
- Decoder = String->getValue();
+ Decoder = std::string(String->getValue());
if (!Decoder.empty())
return Decoder;
}
@@ -1809,7 +1809,8 @@ populateInstruction(CodeGenTarget &Target, const Record &EncodingDef,
StringRef InstDecoder = EncodingDef.getValueAsString("DecoderMethod");
if (InstDecoder != "") {
bool HasCompleteInstDecoder = EncodingDef.getValueAsBit("hasCompleteDecoder");
- InsnOperands.push_back(OperandInfo(InstDecoder, HasCompleteInstDecoder));
+ InsnOperands.push_back(
+ OperandInfo(std::string(InstDecoder), HasCompleteInstDecoder));
Operands[Opc] = InsnOperands;
return true;
}
@@ -1839,8 +1840,10 @@ populateInstruction(CodeGenTarget &Target, const Record &EncodingDef,
if (tiedTo != -1) {
std::pair<unsigned, unsigned> SO =
CGI.Operands.getSubOperandNumber(tiedTo);
- TiedNames[InOutOperands[i].second] = InOutOperands[SO.first].second;
- TiedNames[InOutOperands[SO.first].second] = InOutOperands[i].second;
+ TiedNames[std::string(InOutOperands[i].second)] =
+ std::string(InOutOperands[SO.first].second);
+ TiedNames[std::string(InOutOperands[SO.first].second)] =
+ std::string(InOutOperands[i].second);
}
}
@@ -1936,7 +1939,7 @@ populateInstruction(CodeGenTarget &Target, const Record &EncodingDef,
StringInit *String = DecoderString ?
dyn_cast<StringInit>(DecoderString->getValue()) : nullptr;
if (String && String->getValue() != "")
- Decoder = String->getValue();
+ Decoder = std::string(String->getValue());
if (Decoder == "" &&
CGI.Operands[SO.first].MIOperandInfo &&
@@ -1963,7 +1966,7 @@ populateInstruction(CodeGenTarget &Target, const Record &EncodingDef,
String = DecoderString ?
dyn_cast<StringInit>(DecoderString->getValue()) : nullptr;
if (!isReg && String && String->getValue() != "")
- Decoder = String->getValue();
+ Decoder = std::string(String->getValue());
RecordVal *HasCompleteDecoderVal =
TypeRecord->getValue("hasCompleteDecoder");
@@ -1989,16 +1992,17 @@ populateInstruction(CodeGenTarget &Target, const Record &EncodingDef,
// For each operand, see if we can figure out where it is encoded.
for (const auto &Op : InOutOperands) {
- if (!NumberedInsnOperands[Op.second].empty()) {
+ if (!NumberedInsnOperands[std::string(Op.second)].empty()) {
InsnOperands.insert(InsnOperands.end(),
- NumberedInsnOperands[Op.second].begin(),
- NumberedInsnOperands[Op.second].end());
+ NumberedInsnOperands[std::string(Op.second)].begin(),
+ NumberedInsnOperands[std::string(Op.second)].end());
continue;
}
- if (!NumberedInsnOperands[TiedNames[Op.second]].empty()) {
- if (!NumberedInsnOperandsNoTie.count(TiedNames[Op.second])) {
+ if (!NumberedInsnOperands[TiedNames[std::string(Op.second)]].empty()) {
+ if (!NumberedInsnOperandsNoTie.count(TiedNames[std::string(Op.second)])) {
// Figure out to which (sub)operand we're tied.
- unsigned i = CGI.Operands.getOperandNamed(TiedNames[Op.second]);
+ unsigned i =
+ CGI.Operands.getOperandNamed(TiedNames[std::string(Op.second)]);
int tiedTo = CGI.Operands[i].getTiedRegister();
if (tiedTo == -1) {
i = CGI.Operands.getOperandNamed(Op.second);
@@ -2009,8 +2013,9 @@ populateInstruction(CodeGenTarget &Target, const Record &EncodingDef,
std::pair<unsigned, unsigned> SO =
CGI.Operands.getSubOperandNumber(tiedTo);
- InsnOperands.push_back(NumberedInsnOperands[TiedNames[Op.second]]
- [SO.second]);
+ InsnOperands.push_back(
+ NumberedInsnOperands[TiedNames[std::string(Op.second)]]
+ [SO.second]);
}
}
continue;
@@ -2065,7 +2070,7 @@ populateInstruction(CodeGenTarget &Target, const Record &EncodingDef,
}
if (Var->getName() != Op.second &&
- Var->getName() != TiedNames[Op.second]) {
+ Var->getName() != TiedNames[std::string(Op.second)]) {
if (Base != ~0U) {
OpInfo.addField(Base, Width, Offset);
Base = ~0U;
@@ -2460,7 +2465,7 @@ void FixedLenDecoderEmitter::run(raw_ostream &o) {
if (populateInstruction(Target, *EncodingDef, *Inst, i, Operands)) {
std::string DecoderNamespace =
- EncodingDef->getValueAsString("DecoderNamespace");
+ std::string(EncodingDef->getValueAsString("DecoderNamespace"));
if (!NumberedEncodings[i].HwModeName.empty())
DecoderNamespace +=
std::string("_") + NumberedEncodings[i].HwModeName.str();
diff --git a/llvm/utils/TableGen/GICombinerEmitter.cpp b/llvm/utils/TableGen/GICombinerEmitter.cpp
index 34eb4ed..8c70ed1 100644
--- a/llvm/utils/TableGen/GICombinerEmitter.cpp
+++ b/llvm/utils/TableGen/GICombinerEmitter.cpp
@@ -636,7 +636,8 @@ void GICombinerEmitter::emitNameMatcher(raw_ostream &OS) const {
std::string Code;
raw_string_ostream SS(Code);
SS << "return " << EnumeratedRule.getID() << ";\n";
- Cases.push_back(std::make_pair(EnumeratedRule.getName(), SS.str()));
+ Cases.push_back(
+ std::make_pair(std::string(EnumeratedRule.getName()), SS.str()));
}
OS << "static Optional<uint64_t> getRuleIdxForIdentifier(StringRef "
diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp
index d7949da..9a2f1a1 100644
--- a/llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -448,7 +448,6 @@ public:
: LabelID(LabelID_.hasValue() ? LabelID_.getValue() : ~0u),
EmitStr(EmitStr), NumElements(NumElements), Flags(Flags),
RawValue(RawValue) {
-
assert((!LabelID_.hasValue() || LabelID != ~0u) &&
"This value is reserved for non-labels");
}
@@ -1498,7 +1497,7 @@ public:
const StringRef getSymbolicName() const { return SymbolicName; }
void setSymbolicName(StringRef Name) {
assert(SymbolicName.empty() && "Operand already has a symbolic name");
- SymbolicName = Name;
+ SymbolicName = std::string(Name);
}
/// Construct a new operand predicate and add it to the matcher.
@@ -2790,7 +2789,7 @@ private:
std::string S;
public:
- DebugCommentAction(StringRef S) : S(S) {}
+ DebugCommentAction(StringRef S) : S(std::string(S)) {}
void emitActionOpcodes(MatchTable &Table, RuleMatcher &Rule) const override {
Table << MatchTable::Comment(S) << MatchTable::LineBreak;
@@ -3764,7 +3763,7 @@ Expected<InstructionMatcher &> GlobalISelEmitter::createAndImportSelDAGMatcher(
CCDef->getValueAsString("ICmpPredicate");
if (!PredType.empty()) {
- OM.addPredicate<CmpPredicateOperandMatcher>(PredType);
+ OM.addPredicate<CmpPredicateOperandMatcher>(std::string(PredType));
// Process the other 2 operands normally.
--NumChildren;
}
@@ -3863,9 +3862,10 @@ Error GlobalISelEmitter::importChildMatcher(
Record *PhysReg = nullptr;
StringRef SrcChildName = getSrcChildName(SrcChild, PhysReg);
- OperandMatcher &OM = PhysReg ?
- InsnMatcher.addPhysRegInput(PhysReg, OpIdx, TempOpIdx) :
- InsnMatcher.addOperand(OpIdx, SrcChildName, TempOpIdx);
+ OperandMatcher &OM =
+ PhysReg
+ ? InsnMatcher.addPhysRegInput(PhysReg, OpIdx, TempOpIdx)
+ : InsnMatcher.addOperand(OpIdx, std::string(SrcChildName), TempOpIdx);
if (OM.isSameAsAnotherOperand())
return Error::success();
diff --git a/llvm/utils/TableGen/InstrDocsEmitter.cpp b/llvm/utils/TableGen/InstrDocsEmitter.cpp
index 07efa18..66744bf 100644
--- a/llvm/utils/TableGen/InstrDocsEmitter.cpp
+++ b/llvm/utils/TableGen/InstrDocsEmitter.cpp
@@ -61,7 +61,7 @@ void EmitInstrDocs(RecordKeeper &RK, raw_ostream &OS) {
unsigned VariantCount = Target.getAsmParserVariantCount();
// Page title.
- std::string Title = Target.getName();
+ std::string Title = std::string(Target.getName());
Title += " Instructions";
writeTitle(Title, OS);
OS << "\n";
diff --git a/llvm/utils/TableGen/InstrInfoEmitter.cpp b/llvm/utils/TableGen/InstrInfoEmitter.cpp
index 36d9e66..c857d36 100644
--- a/llvm/utils/TableGen/InstrInfoEmitter.cpp
+++ b/llvm/utils/TableGen/InstrInfoEmitter.cpp
@@ -524,7 +524,7 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
OS << "namespace llvm {\n\n";
CodeGenTarget &Target = CDP.getTargetInfo();
- const std::string &TargetName = Target.getName();
+ const std::string &TargetName = std::string(Target.getName());
Record *InstrInfo = Target.getInstructionSet();
// Keep track of all of the def lists we have emitted already.
@@ -561,7 +561,7 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
unsigned Num = 0;
for (const CodeGenInstruction *Inst : NumberedInstructions) {
// Keep a list of the instruction names.
- InstrNames.add(Inst->TheDef->getName());
+ InstrNames.add(std::string(Inst->TheDef->getName()));
// Emit the record into the table.
emitRecord(*Inst, Num++, InstrInfo, EmittedLists, OperandInfoIDs, OS);
}
@@ -578,7 +578,7 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
// Newline every eight entries.
if (Num % 8 == 0)
OS << "\n ";
- OS << InstrNames.get(Inst->TheDef->getName()) << "U, ";
+ OS << InstrNames.get(std::string(Inst->TheDef->getName())) << "U, ";
++Num;
}
diff --git a/llvm/utils/TableGen/OptParserEmitter.cpp b/llvm/utils/TableGen/OptParserEmitter.cpp
index c1978ac..bbc7891 100644
--- a/llvm/utils/TableGen/OptParserEmitter.cpp
+++ b/llvm/utils/TableGen/OptParserEmitter.cpp
@@ -21,9 +21,9 @@ using namespace llvm;
static const std::string getOptionName(const Record &R) {
// Use the record name unless EnumName is defined.
if (isa<UnsetInit>(R.getValueInit("EnumName")))
- return R.getName();
+ return std::string(R.getName());
- return R.getValueAsString("EnumName");
+ return std::string(R.getValueAsString("EnumName"));
}
static raw_ostream &write_cstring(raw_ostream &OS, llvm::StringRef Str) {
@@ -241,8 +241,9 @@ void EmitOptParser(RecordKeeper &Records, raw_ostream &OS) {
OS << "bool ValuesWereAdded;\n";
OS << R.getValueAsString("ValuesCode");
OS << "\n";
- for (std::string S : R.getValueAsListOfStrings("Prefixes")) {
+ for (StringRef Prefix : R.getValueAsListOfStrings("Prefixes")) {
OS << "ValuesWereAdded = Opt.addValues(";
+ std::string S(Prefix);
S += R.getValueAsString("Name");
write_cstring(OS, S);
OS << ", Values);\n";
diff --git a/llvm/utils/TableGen/RISCVCompressInstEmitter.cpp b/llvm/utils/TableGen/RISCVCompressInstEmitter.cpp
index 01cb659..7f30b60 100644
--- a/llvm/utils/TableGen/RISCVCompressInstEmitter.cpp
+++ b/llvm/utils/TableGen/RISCVCompressInstEmitter.cpp
@@ -547,7 +547,7 @@ void RISCVCompressInstEmitter::emitCompressInstEmitter(raw_ostream &o,
"'PassSubtarget' is false. SubTargetInfo object is needed "
"for target features.\n");
- std::string Namespace = Target.getName();
+ std::string Namespace = std::string(Target.getName());
// Sort entries in CompressPatterns to handle instructions that can have more
// than one candidate for compression\uncompression, e.g ADD can be
diff --git a/llvm/utils/TableGen/RegisterInfoEmitter.cpp b/llvm/utils/TableGen/RegisterInfoEmitter.cpp
index bf4ebca..944c97d 100644
--- a/llvm/utils/TableGen/RegisterInfoEmitter.cpp
+++ b/llvm/utils/TableGen/RegisterInfoEmitter.cpp
@@ -897,7 +897,7 @@ RegisterInfoEmitter::runMCDesc(raw_ostream &OS, CodeGenTarget &Target,
unsigned i = 0;
for (auto I = Regs.begin(), E = Regs.end(); I != E; ++I, ++i) {
const auto &Reg = *I;
- RegStrings.add(Reg.getName());
+ RegStrings.add(std::string(Reg.getName()));
// Compute the ordered sub-register list.
SetVector<const CodeGenRegister*> SR;
@@ -963,7 +963,7 @@ RegisterInfoEmitter::runMCDesc(raw_ostream &OS, CodeGenTarget &Target,
OS << "namespace llvm {\n\n";
- const std::string &TargetName = Target.getName();
+ const std::string &TargetName = std::string(Target.getName());
// Emit the shared table of differential lists.
OS << "extern const MCPhysReg " << TargetName << "RegDiffLists[] = {\n";
@@ -1002,7 +1002,7 @@ RegisterInfoEmitter::runMCDesc(raw_ostream &OS, CodeGenTarget &Target,
// Emit the register descriptors now.
i = 0;
for (const auto &Reg : Regs) {
- OS << " { " << RegStrings.get(Reg.getName()) << ", "
+ OS << " { " << RegStrings.get(std::string(Reg.getName())) << ", "
<< DiffSeqs.get(SubRegLists[i]) << ", " << DiffSeqs.get(SuperRegLists[i])
<< ", " << SubRegIdxSeqs.get(SubRegIdxLists[i]) << ", "
<< (DiffSeqs.get(RegUnitLists[i]) * 16 + RegUnitInitScale[i]) << ", "
@@ -1132,7 +1132,7 @@ RegisterInfoEmitter::runTargetHeader(raw_ostream &OS, CodeGenTarget &Target,
OS << "\n#ifdef GET_REGINFO_HEADER\n";
OS << "#undef GET_REGINFO_HEADER\n\n";
- const std::string &TargetName = Target.getName();
+ const std::string &TargetName = std::string(Target.getName());
std::string ClassName = TargetName + "GenRegisterInfo";
OS << "#include \"llvm/CodeGen/TargetRegisterInfo.h\"\n\n";
@@ -1428,7 +1428,7 @@ RegisterInfoEmitter::runTargetDesc(raw_ostream &OS, CodeGenTarget &Target,
OS << "} // end anonymous namespace\n";
// Emit extra information about registers.
- const std::string &TargetName = Target.getName();
+ const std::string &TargetName = std::string(Target.getName());
OS << "\nstatic const TargetRegisterInfoDesc "
<< TargetName << "RegInfoDesc[] = { // Extra Descriptors\n";
OS << " { 0, false },\n";
diff --git a/llvm/utils/TableGen/SearchableTableEmitter.cpp b/llvm/utils/TableGen/SearchableTableEmitter.cpp
index cfe48eb..2ac34bb 100644
--- a/llvm/utils/TableGen/SearchableTableEmitter.cpp
+++ b/llvm/utils/TableGen/SearchableTableEmitter.cpp
@@ -57,7 +57,7 @@ struct GenericField {
bool IsInstruction = false;
GenericEnum *Enum = nullptr;
- GenericField(StringRef Name) : Name(Name) {}
+ GenericField(StringRef Name) : Name(std::string(Name)) {}
};
struct SearchIndex {
@@ -114,13 +114,14 @@ private:
else if (BitInit *BI = dyn_cast<BitInit>(I))
return BI->getValue() ? "true" : "false";
else if (CodeInit *CI = dyn_cast<CodeInit>(I))
- return CI->getValue();
+ return std::string(CI->getValue());
else if (Field.IsIntrinsic)
return "Intrinsic::" + getIntrinsic(I).EnumName;
else if (Field.IsInstruction)
return I->getAsString();
else if (Field.Enum)
- return Field.Enum->EntryMap[cast<DefInit>(I)->getDef()]->first;
+ return std::string(
+ Field.Enum->EntryMap[cast<DefInit>(I)->getDef()]->first);
PrintFatalError(Twine("invalid field type for field '") + Field.Name +
"', expected: string, bits, bit or code");
}
@@ -274,7 +275,7 @@ bool SearchableTableEmitter::compareBy(Record *LHS, Record *RHS,
void SearchableTableEmitter::emitIfdef(StringRef Guard, raw_ostream &OS) {
OS << "#ifdef " << Guard << "\n";
- PreprocessorGuards.insert(Guard);
+ PreprocessorGuards.insert(std::string(Guard));
}
/// Emit a generic enum.
@@ -542,7 +543,7 @@ SearchableTableEmitter::parseSearchIndex(GenericTable &Table, StringRef Name,
const std::vector<StringRef> &Key,
bool EarlyOut) {
auto Index = std::make_unique<SearchIndex>();
- Index->Name = Name;
+ Index->Name = std::string(Name);
Index->EarlyOut = EarlyOut;
for (const auto &FieldName : Key) {
@@ -648,8 +649,8 @@ void SearchableTableEmitter::run(raw_ostream &OS) {
ValueField = EnumRec->getValueAsString("ValueField");
auto Enum = std::make_unique<GenericEnum>();
- Enum->Name = EnumRec->getName();
- Enum->PreprocessorGuard = EnumRec->getName();
+ Enum->Name = std::string(EnumRec->getName());
+ Enum->PreprocessorGuard = std::string(EnumRec->getName());
StringRef FilterClass = EnumRec->getValueAsString("FilterClass");
Enum->Class = Records.getClass(FilterClass);
@@ -665,9 +666,9 @@ void SearchableTableEmitter::run(raw_ostream &OS) {
for (auto TableRec : Records.getAllDerivedDefinitions("GenericTable")) {
auto Table = std::make_unique<GenericTable>();
- Table->Name = TableRec->getName();
- Table->PreprocessorGuard = TableRec->getName();
- Table->CppTypeName = TableRec->getValueAsString("CppTypeName");
+ Table->Name = std::string(TableRec->getName());
+ Table->PreprocessorGuard = std::string(TableRec->getName());
+ Table->CppTypeName = std::string(TableRec->getValueAsString("CppTypeName"));
std::vector<StringRef> Fields = TableRec->getValueAsListOfStrings("Fields");
for (const auto &FieldName : Fields) {
@@ -746,10 +747,10 @@ void SearchableTableEmitter::run(raw_ostream &OS) {
auto Table = std::make_unique<GenericTable>();
Table->Name = (Twine(Class->getName()) + "sList").str();
Table->PreprocessorGuard = Class->getName().upper();
- Table->CppTypeName = Class->getName();
+ Table->CppTypeName = std::string(Class->getName());
for (const RecordVal &Field : Class->getValues()) {
- std::string FieldName = Field.getName();
+ std::string FieldName = std::string(Field.getName());
// Skip uninteresting fields: either special to us, or injected
// template parameters (if they contain a ':').
diff --git a/llvm/utils/TableGen/SubtargetEmitter.cpp b/llvm/utils/TableGen/SubtargetEmitter.cpp
index 9b094ad..4585644 100644
--- a/llvm/utils/TableGen/SubtargetEmitter.cpp
+++ b/llvm/utils/TableGen/SubtargetEmitter.cpp
@@ -128,8 +128,8 @@ class SubtargetEmitter {
public:
SubtargetEmitter(RecordKeeper &R, CodeGenTarget &TGT)
- : TGT(TGT), Records(R), SchedModels(TGT.getSchedModels()),
- Target(TGT.getName()) {}
+ : TGT(TGT), Records(R), SchedModels(TGT.getSchedModels()),
+ Target(TGT.getName()) {}
void run(raw_ostream &o);
};
@@ -460,7 +460,8 @@ EmitStageAndOperandCycleData(raw_ostream &OS,
std::string ItinStageString;
unsigned NStages = 0;
if (ItinData)
- FormItineraryStageString(Name, ItinData, ItinStageString, NStages);
+ FormItineraryStageString(std::string(Name), ItinData, ItinStageString,
+ NStages);
// Get string and operand cycle count
std::string ItinOperandCycleString;
@@ -470,7 +471,7 @@ EmitStageAndOperandCycleData(raw_ostream &OS,
FormItineraryOperandCycleString(ItinData, ItinOperandCycleString,
NOperandCycles);
- FormItineraryBypassString(Name, ItinData, ItinBypassString,
+ FormItineraryBypassString(std::string(Name), ItinData, ItinBypassString,
NOperandCycles);
}
diff --git a/llvm/utils/TableGen/SubtargetFeatureInfo.cpp b/llvm/utils/TableGen/SubtargetFeatureInfo.cpp
index 5430f73d..e18ae47 100644
--- a/llvm/utils/TableGen/SubtargetFeatureInfo.cpp
+++ b/llvm/utils/TableGen/SubtargetFeatureInfo.cpp
@@ -120,7 +120,7 @@ void SubtargetFeatureInfo::emitComputeAssemblerAvailableFeatures(
OS << " if (";
std::string CondStorage =
- SFI.TheDef->getValueAsString("AssemblerCondString");
+ std::string(SFI.TheDef->getValueAsString("AssemblerCondString"));
StringRef Conds = CondStorage;
std::pair<StringRef, StringRef> Comma = Conds.split(',');
bool First = true;
diff --git a/llvm/utils/TableGen/X86RecognizableInstr.cpp b/llvm/utils/TableGen/X86RecognizableInstr.cpp
index 1048ef8..ff3a111 100644
--- a/llvm/utils/TableGen/X86RecognizableInstr.cpp
+++ b/llvm/utils/TableGen/X86RecognizableInstr.cpp
@@ -65,7 +65,7 @@ RecognizableInstr::RecognizableInstr(DisassemblerTables &tables,
UID = uid;
Rec = insn.TheDef;
- Name = Rec->getName();
+ Name = std::string(Rec->getName());
Spec = &tables.specForUID(UID);
if (!Rec->isSubClassOf("X86Inst")) {
@@ -94,7 +94,7 @@ RecognizableInstr::RecognizableInstr(DisassemblerTables &tables,
ForceDisassemble = Rec->getValueAsBit("ForceDisassemble");
CD8_Scale = byteFromRec(Rec, "CD8_Scale");
- Name = Rec->getName();
+ Name = std::string(Rec->getName());
Operands = &insn.Operands.OperandList;
@@ -383,12 +383,12 @@ void RecognizableInstr::handleOperand(bool optional, unsigned &operandIndex,
StringRef typeName = (*Operands)[operandIndex].Rec->getName();
- OperandEncoding encoding = encodingFromString(typeName, OpSize);
+ OperandEncoding encoding = encodingFromString(std::string(typeName), OpSize);
// Adjust the encoding type for an operand based on the instruction.
adjustOperandEncoding(encoding);
Spec->operands[operandIndex].encoding = encoding;
- Spec->operands[operandIndex].type = typeFromString(typeName,
- HasREX_WPrefix, OpSize);
+ Spec->operands[operandIndex].type =
+ typeFromString(std::string(typeName), HasREX_WPrefix, OpSize);
++operandIndex;
++physicalOperandIndex;
diff --git a/mlir/examples/toy/Ch1/toyc.cpp b/mlir/examples/toy/Ch1/toyc.cpp
index fb824c6..b89fe0e 100644
--- a/mlir/examples/toy/Ch1/toyc.cpp
+++ b/mlir/examples/toy/Ch1/toyc.cpp
@@ -42,7 +42,7 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
return nullptr;
}
auto buffer = fileOrErr.get()->getBuffer();
- LexerBuffer lexer(buffer.begin(), buffer.end(), filename);
+ LexerBuffer lexer(buffer.begin(), buffer.end(), std::string(filename));
Parser parser(lexer);
return parser.parseModule();
}
diff --git a/mlir/examples/toy/Ch2/toyc.cpp b/mlir/examples/toy/Ch2/toyc.cpp
index 563ae7b..a558f64 100644
--- a/mlir/examples/toy/Ch2/toyc.cpp
+++ b/mlir/examples/toy/Ch2/toyc.cpp
@@ -61,7 +61,7 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
return nullptr;
}
auto buffer = fileOrErr.get()->getBuffer();
- LexerBuffer lexer(buffer.begin(), buffer.end(), filename);
+ LexerBuffer lexer(buffer.begin(), buffer.end(), std::string(filename));
Parser parser(lexer);
return parser.parseModule();
}
diff --git a/mlir/examples/toy/Ch3/toyc.cpp b/mlir/examples/toy/Ch3/toyc.cpp
index b3940e3..d9ae7aa 100644
--- a/mlir/examples/toy/Ch3/toyc.cpp
+++ b/mlir/examples/toy/Ch3/toyc.cpp
@@ -65,7 +65,7 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
return nullptr;
}
auto buffer = fileOrErr.get()->getBuffer();
- LexerBuffer lexer(buffer.begin(), buffer.end(), filename);
+ LexerBuffer lexer(buffer.begin(), buffer.end(), std::string(filename));
Parser parser(lexer);
return parser.parseModule();
}
diff --git a/mlir/examples/toy/Ch4/toyc.cpp b/mlir/examples/toy/Ch4/toyc.cpp
index 5570ed3..51ff330 100644
--- a/mlir/examples/toy/Ch4/toyc.cpp
+++ b/mlir/examples/toy/Ch4/toyc.cpp
@@ -66,7 +66,7 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
return nullptr;
}
auto buffer = fileOrErr.get()->getBuffer();
- LexerBuffer lexer(buffer.begin(), buffer.end(), filename);
+ LexerBuffer lexer(buffer.begin(), buffer.end(), std::string(filename));
Parser parser(lexer);
return parser.parseModule();
}
diff --git a/mlir/examples/toy/Ch5/toyc.cpp b/mlir/examples/toy/Ch5/toyc.cpp
index cdfe933..d3a83a9 100644
--- a/mlir/examples/toy/Ch5/toyc.cpp
+++ b/mlir/examples/toy/Ch5/toyc.cpp
@@ -68,7 +68,7 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
return nullptr;
}
auto buffer = fileOrErr.get()->getBuffer();
- LexerBuffer lexer(buffer.begin(), buffer.end(), filename);
+ LexerBuffer lexer(buffer.begin(), buffer.end(), std::string(filename));
Parser parser(lexer);
return parser.parseModule();
}
diff --git a/mlir/examples/toy/Ch6/toyc.cpp b/mlir/examples/toy/Ch6/toyc.cpp
index 2598d82..f33f739 100644
--- a/mlir/examples/toy/Ch6/toyc.cpp
+++ b/mlir/examples/toy/Ch6/toyc.cpp
@@ -87,7 +87,7 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
return nullptr;
}
auto buffer = fileOrErr.get()->getBuffer();
- LexerBuffer lexer(buffer.begin(), buffer.end(), filename);
+ LexerBuffer lexer(buffer.begin(), buffer.end(), std::string(filename));
Parser parser(lexer);
return parser.parseModule();
}
diff --git a/mlir/examples/toy/Ch7/toyc.cpp b/mlir/examples/toy/Ch7/toyc.cpp
index e872ec1..199fff9 100644
--- a/mlir/examples/toy/Ch7/toyc.cpp
+++ b/mlir/examples/toy/Ch7/toyc.cpp
@@ -87,7 +87,7 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
return nullptr;
}
auto buffer = fileOrErr.get()->getBuffer();
- LexerBuffer lexer(buffer.begin(), buffer.end(), filename);
+ LexerBuffer lexer(buffer.begin(), buffer.end(), std::string(filename));
Parser parser(lexer);
return parser.parseModule();
}
diff --git a/mlir/include/mlir/Quantizer/Support/Metadata.h b/mlir/include/mlir/Quantizer/Support/Metadata.h
index 0b45c81..1a80ac0 100644
--- a/mlir/include/mlir/Quantizer/Support/Metadata.h
+++ b/mlir/include/mlir/Quantizer/Support/Metadata.h
@@ -35,7 +35,7 @@ public:
// Optional path to write a debug DOT file for the CAG.
StringRef getDebugCAGDotPath() const { return debugCAGDotPath; }
- void setDebugCAGDotPath(StringRef p) { debugCAGDotPath = p; }
+ void setDebugCAGDotPath(StringRef p) { debugCAGDotPath = std::string(p); }
private:
MLIRContext &mlirContext;
diff --git a/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp b/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp
index 8d1b74d..bff5dfb 100644
--- a/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp
+++ b/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp
@@ -307,7 +307,7 @@ Value GpuLaunchFuncToCudaCallsPass::generateKernelNameConstant(
std::vector<char> kernelName(name.begin(), name.end());
kernelName.push_back('\0');
- std::string globalName = llvm::formatv("{0}_kernel_name", name);
+ std::string globalName = std::string(llvm::formatv("{0}_kernel_name", name));
return LLVM::createGlobalString(
loc, builder, globalName, StringRef(kernelName.data(), kernelName.size()),
LLVM::Linkage::Internal, llvmDialect);
diff --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
index 4bd2b94..a2c4ec6 100644
--- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
+++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
@@ -548,8 +548,8 @@ struct GPUFuncOpLowering : LLVMOpLowering {
auto elementType =
lowering.convertType(type.getElementType()).cast<LLVM::LLVMType>();
auto arrayType = LLVM::LLVMType::getArrayTy(elementType, numElements);
- std::string name =
- llvm::formatv("__wg_{0}_{1}", gpuFuncOp.getName(), en.index());
+ std::string name = std::string(
+ llvm::formatv("__wg_{0}_{1}", gpuFuncOp.getName(), en.index()));
auto globalOp = rewriter.create<LLVM::GlobalOp>(
gpuFuncOp.getLoc(), arrayType, /*isConstant=*/false,
LLVM::Linkage::Internal, name, /*value=*/Attribute(),
diff --git a/mlir/lib/Dialect/SDBM/SDBM.cpp b/mlir/lib/Dialect/SDBM/SDBM.cpp
index f14818b..77f81fe 100644
--- a/mlir/lib/Dialect/SDBM/SDBM.cpp
+++ b/mlir/lib/Dialect/SDBM/SDBM.cpp
@@ -512,12 +512,12 @@ void SDBM::print(raw_ostream &os) {
return "cst";
matrixPos -= 1;
if (matrixPos < numDims)
- return llvm::formatv("d{0}", matrixPos);
+ return std::string(llvm::formatv("d{0}", matrixPos));
matrixPos -= numDims;
if (matrixPos < numSymbols)
- return llvm::formatv("s{0}", matrixPos);
+ return std::string(llvm::formatv("s{0}", matrixPos));
matrixPos -= numSymbols;
- return llvm::formatv("t{0}", matrixPos);
+ return std::string(llvm::formatv("t{0}", matrixPos));
};
// Header row.
diff --git a/mlir/lib/Dialect/Traits.cpp b/mlir/lib/Dialect/Traits.cpp
index b8336f7..352e26f 100644
--- a/mlir/lib/Dialect/Traits.cpp
+++ b/mlir/lib/Dialect/Traits.cpp
@@ -165,7 +165,8 @@ static bool areCompatibleShapes(ArrayRef<int64_t> shape1,
static std::string getShapeString(ArrayRef<int64_t> shape) {
// TODO: should replace with printing shape more uniformly across here and
// when in type.
- return formatv("'{0:$[x]}'", llvm::make_range(shape.begin(), shape.end()));
+ return std::string(
+ formatv("'{0:$[x]}'", llvm::make_range(shape.begin(), shape.end())));
}
LogicalResult OpTrait::impl::verifyCompatibleOperandBroadcast(Operation *op) {
diff --git a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp
index b3c60df..3b54281 100644
--- a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -238,7 +238,7 @@ Expected<std::unique_ptr<ExecutionEngine>> ExecutionEngine::create(
errs() << "Fail to create MemoryBuffer for: " << libPath << "\n";
continue;
}
- auto &JD = session.createJITDylib(libPath);
+ auto &JD = session.createJITDylib(std::string(libPath));
auto loaded = DynamicLibrarySearchGenerator::Load(
libPath.data(), dataLayout.getGlobalPrefix());
if (!loaded) {
diff --git a/mlir/lib/IR/Diagnostics.cpp b/mlir/lib/IR/Diagnostics.cpp
index d92a1a8..f3cded0 100644
--- a/mlir/lib/IR/Diagnostics.cpp
+++ b/mlir/lib/IR/Diagnostics.cpp
@@ -352,7 +352,8 @@ struct SourceMgrDiagnosticHandlerImpl {
// Otherwise, try to load the source file.
const llvm::MemoryBuffer *newBuf = nullptr;
std::string ignored;
- if (auto newBufID = mgr.AddIncludeFile(filename, llvm::SMLoc(), ignored))
+ if (auto newBufID =
+ mgr.AddIncludeFile(std::string(filename), llvm::SMLoc(), ignored))
newBuf = mgr.getMemoryBuffer(newBufID);
return filenameToBuf[filename] = newBuf;
}
diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp
index 94ced24..50bb84c 100644
--- a/mlir/lib/Parser/Parser.cpp
+++ b/mlir/lib/Parser/Parser.cpp
@@ -1434,7 +1434,7 @@ static std::string extractSymbolReference(Token tok) {
// Check to see if the reference is a string literal, or a bare identifier.
if (nameStr.front() == '"')
return tok.getStringValue();
- return nameStr;
+ return std::string(nameStr);
}
/// Parse an arbitrary attribute.
diff --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp
index 9e7301f..fc40ff1 100644
--- a/mlir/lib/Pass/Pass.cpp
+++ b/mlir/lib/Pass/Pass.cpp
@@ -601,7 +601,7 @@ void PassManager::disableMultithreading(bool disable) {
/// of a crash or a pass failure. `outputFile` is a .mlir filename used to write
/// the generated reproducer.
void PassManager::enableCrashReproducerGeneration(StringRef outputFile) {
- crashReproducerFileName = outputFile;
+ crashReproducerFileName = std::string(outputFile);
}
/// Add the provided instrumentation to the pass manager.
diff --git a/mlir/lib/Pass/PassTiming.cpp b/mlir/lib/Pass/PassTiming.cpp
index f3965d3..f86a4a5 100644
--- a/mlir/lib/Pass/PassTiming.cpp
+++ b/mlir/lib/Pass/PassTiming.cpp
@@ -281,7 +281,7 @@ void PassTiming::startPassTimer(Pass *pass) {
Timer *timer = getTimer(pass, kind, [pass]() -> std::string {
if (auto *adaptor = getAdaptorPassBase(pass))
return adaptor->getName();
- return pass->getName();
+ return std::string(pass->getName());
});
// We don't actually want to time the adaptor passes, they gather their total
diff --git a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp
index a93e79b..dac67fb 100644
--- a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp
+++ b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp
@@ -141,11 +141,11 @@ void InferQuantizedTypesPass::runWithConfig(SolverContext &solverContext,
// TODO: Only dump the GraphViz if a flag is set and move to a utility.
// GraphViz.
if (!solverContext.getDebugCAGDotPath().empty()) {
- auto actFileName =
- llvm::WriteGraph(const_cast<const CAGSlice *>(&cag), "CAG",
- /*ShortNames=*/false,
- /*Title=*/"CAG",
- /*Filename=*/solverContext.getDebugCAGDotPath());
+ auto actFileName = llvm::WriteGraph(
+ const_cast<const CAGSlice *>(&cag), "CAG",
+ /*ShortNames=*/false,
+ /*Title=*/"CAG",
+ /*Filename=*/std::string(solverContext.getDebugCAGDotPath()));
llvm::errs() << "Wrote graphviz file: " << actFileName << "\n";
}
diff --git a/mlir/lib/TableGen/Constraint.cpp b/mlir/lib/TableGen/Constraint.cpp
index 9f3fe65..251d15a 100644
--- a/mlir/lib/TableGen/Constraint.cpp
+++ b/mlir/lib/TableGen/Constraint.cpp
@@ -57,4 +57,5 @@ llvm::StringRef Constraint::getDescription() const {
AppliedConstraint::AppliedConstraint(Constraint &&constraint,
llvm::StringRef self,
std::vector<std::string> &&entities)
- : constraint(constraint), self(self), entities(std::move(entities)) {}
+ : constraint(constraint), self(std::string(self)),
+ entities(std::move(entities)) {}
diff --git a/mlir/lib/TableGen/OpClass.cpp b/mlir/lib/TableGen/OpClass.cpp
index 1e202df..4fb21fc 100644
--- a/mlir/lib/TableGen/OpClass.cpp
+++ b/mlir/lib/TableGen/OpClass.cpp
@@ -39,7 +39,7 @@ void tblgen::OpMethodSignature::writeDefTo(raw_ostream &os,
while (!params.empty()) {
parts = params.split("=");
result.append(result.empty() ? "" : ", ");
- result.append(parts.first);
+ result += parts.first;
params = parts.second.split(",").second;
}
return result;
diff --git a/mlir/lib/TableGen/Operator.cpp b/mlir/lib/TableGen/Operator.cpp
index a14ea2d..5e338b37 100644
--- a/mlir/lib/TableGen/Operator.cpp
+++ b/mlir/lib/TableGen/Operator.cpp
@@ -50,8 +50,8 @@ std::string tblgen::Operator::getOperationName() const {
auto prefix = dialect.getName();
auto opName = def.getValueAsString("opName");
if (prefix.empty())
- return opName;
- return llvm::formatv("{0}.{1}", prefix, opName);
+ return std::string(opName);
+ return std::string(llvm::formatv("{0}.{1}", prefix, opName));
}
StringRef tblgen::Operator::getDialectName() const { return dialect.getName(); }
@@ -61,8 +61,8 @@ StringRef tblgen::Operator::getCppClassName() const { return cppClassName; }
std::string tblgen::Operator::getQualCppClassName() const {
auto prefix = dialect.getCppNamespace();
if (prefix.empty())
- return cppClassName;
- return llvm::formatv("{0}::{1}", prefix, cppClassName);
+ return std::string(cppClassName);
+ return std::string(llvm::formatv("{0}::{1}", prefix, cppClassName));
}
int tblgen::Operator::getNumResults() const {
diff --git a/mlir/lib/TableGen/Pattern.cpp b/mlir/lib/TableGen/Pattern.cpp
index 5be2399..4df05e2 100644
--- a/mlir/lib/TableGen/Pattern.cpp
+++ b/mlir/lib/TableGen/Pattern.cpp
@@ -207,19 +207,20 @@ tblgen::SymbolInfoMap::SymbolInfo::getVarDecl(StringRef name) const {
case Kind::Attr: {
auto type =
op->getArg(*argIndex).get<NamedAttribute *>()->attr.getStorageType();
- return formatv("{0} {1};\n", type, name);
+ return std::string(formatv("{0} {1};\n", type, name));
}
case Kind::Operand: {
// Use operand range for captured operands (to support potential variadic
// operands).
- return formatv("Operation::operand_range {0}(op0->getOperands());\n", name);
+ return std::string(
+ formatv("Operation::operand_range {0}(op0->getOperands());\n", name));
}
case Kind::Value: {
- return formatv("ArrayRef<Value> {0};\n", name);
+ return std::string(formatv("ArrayRef<Value> {0};\n", name));
}
case Kind::Result: {
// Use the op itself for captured results.
- return formatv("{0} {1};\n", op->getQualCppClassName(), name);
+ return std::string(formatv("{0} {1};\n", op->getQualCppClassName(), name));
}
}
llvm_unreachable("unknown kind");
@@ -233,7 +234,7 @@ std::string tblgen::SymbolInfoMap::SymbolInfo::getValueAndRangeUse(
assert(index < 0);
auto repl = formatv(fmt, name);
LLVM_DEBUG(llvm::dbgs() << repl << " (Attr)\n");
- return repl;
+ return std::string(repl);
}
case Kind::Operand: {
assert(index < 0);
@@ -243,29 +244,30 @@ std::string tblgen::SymbolInfoMap::SymbolInfo::getValueAndRangeUse(
if (operand->isVariadic()) {
auto repl = formatv(fmt, name);
LLVM_DEBUG(llvm::dbgs() << repl << " (VariadicOperand)\n");
- return repl;
+ return std::string(repl);
}
auto repl = formatv(fmt, formatv("(*{0}.begin())", name));
LLVM_DEBUG(llvm::dbgs() << repl << " (SingleOperand)\n");
- return repl;
+ return std::string(repl);
}
case Kind::Result: {
// If `index` is greater than zero, then we are referencing a specific
// result of a multi-result op. The result can still be variadic.
if (index >= 0) {
- std::string v = formatv("{0}.getODSResults({1})", name, index);
+ std::string v =
+ std::string(formatv("{0}.getODSResults({1})", name, index));
if (!op->getResult(index).isVariadic())
- v = formatv("(*{0}.begin())", v);
+ v = std::string(formatv("(*{0}.begin())", v));
auto repl = formatv(fmt, v);
LLVM_DEBUG(llvm::dbgs() << repl << " (SingleResult)\n");
- return repl;
+ return std::string(repl);
}
// If this op has no result at all but still we bind a symbol to it, it
// means we want to capture the op itself.
if (op->getNumResults() == 0) {
LLVM_DEBUG(llvm::dbgs() << name << " (Op)\n");
- return name;
+ return std::string(name);
}
// We are referencing all results of the multi-result op. A specific result
@@ -274,11 +276,11 @@ std::string tblgen::SymbolInfoMap::SymbolInfo::getValueAndRangeUse(
values.reserve(op->getNumResults());
for (int i = 0, e = op->getNumResults(); i < e; ++i) {
- std::string v = formatv("{0}.getODSResults({1})", name, i);
+ std::string v = std::string(formatv("{0}.getODSResults({1})", name, i));
if (!op->getResult(i).isVariadic()) {
- v = formatv("(*{0}.begin())", v);
+ v = std::string(formatv("(*{0}.begin())", v));
}
- values.push_back(formatv(fmt, v));
+ values.push_back(std::string(formatv(fmt, v)));
}
auto repl = llvm::join(values, separator);
LLVM_DEBUG(llvm::dbgs() << repl << " (VariadicResult)\n");
@@ -289,7 +291,7 @@ std::string tblgen::SymbolInfoMap::SymbolInfo::getValueAndRangeUse(
assert(op == nullptr);
auto repl = formatv(fmt, name);
LLVM_DEBUG(llvm::dbgs() << repl << " (Value)\n");
- return repl;
+ return std::string(repl);
}
}
llvm_unreachable("unknown kind");
@@ -304,13 +306,13 @@ std::string tblgen::SymbolInfoMap::SymbolInfo::getAllRangeUse(
assert(index < 0 && "only allowed for symbol bound to result");
auto repl = formatv(fmt, name);
LLVM_DEBUG(llvm::dbgs() << repl << " (Operand/Attr)\n");
- return repl;
+ return std::string(repl);
}
case Kind::Result: {
if (index >= 0) {
auto repl = formatv(fmt, formatv("{0}.getODSResults({1})", name, index));
LLVM_DEBUG(llvm::dbgs() << repl << " (SingleResult)\n");
- return repl;
+ return std::string(repl);
}
// We are referencing all results of the multi-result op. Each result should
@@ -319,8 +321,8 @@ std::string tblgen::SymbolInfoMap::SymbolInfo::getAllRangeUse(
values.reserve(op->getNumResults());
for (int i = 0, e = op->getNumResults(); i < e; ++i) {
- values.push_back(
- formatv(fmt, formatv("{0}.getODSResults({1})", name, i)));
+ values.push_back(std::string(
+ formatv(fmt, formatv("{0}.getODSResults({1})", name, i))));
}
auto repl = llvm::join(values, separator);
LLVM_DEBUG(llvm::dbgs() << repl << " (VariadicResult)\n");
@@ -331,7 +333,7 @@ std::string tblgen::SymbolInfoMap::SymbolInfo::getAllRangeUse(
assert(op == nullptr);
auto repl = formatv(fmt, formatv("{{{0}}", name));
LLVM_DEBUG(llvm::dbgs() << repl << " (Value)\n");
- return repl;
+ return std::string(repl);
}
}
llvm_unreachable("unknown kind");
@@ -478,7 +480,7 @@ std::vector<tblgen::AppliedConstraint> tblgen::Pattern::getConstraints() const {
def.getLoc(),
"operands to additional constraints can only be symbol references");
}
- entities.push_back(argName->getValue());
+ entities.push_back(std::string(argName->getValue()));
}
ret.emplace_back(cast<llvm::DefInit>(dagInit->getOperator())->getDef(),
diff --git a/mlir/lib/TableGen/Predicate.cpp b/mlir/lib/TableGen/Predicate.cpp
index 7929b17..59bb0c5 100644
--- a/mlir/lib/TableGen/Predicate.cpp
+++ b/mlir/lib/TableGen/Predicate.cpp
@@ -60,7 +60,7 @@ tblgen::CPred::CPred(const llvm::Init *init) : Pred(init) {
// Get condition of the C Predicate.
std::string tblgen::CPred::getConditionImpl() const {
assert(!isNull() && "null predicate does not have a condition");
- return def->getValueAsString("predExpr");
+ return std::string(def->getValueAsString("predExpr"));
}
tblgen::CombinedPred::CombinedPred(const llvm::Record *record) : Pred(record) {
@@ -147,14 +147,15 @@ static PredNode *buildPredicateTree(const tblgen::Pred &root,
rootNode->expr = root.getCondition();
// Apply all parent substitutions from innermost to outermost.
for (const auto &subst : llvm::reverse(substitutions)) {
- auto pos = rootNode->expr.find(subst.first);
+ auto pos = rootNode->expr.find(std::string(subst.first));
while (pos != std::string::npos) {
- rootNode->expr.replace(pos, subst.first.size(), subst.second);
+ rootNode->expr.replace(pos, subst.first.size(),
+ std::string(subst.second));
// Skip the newly inserted substring, which itself may consider the
// pattern to match.
pos += subst.second.size();
// Find the next possible match position.
- pos = rootNode->expr.find(subst.first, pos);
+ pos = rootNode->expr.find(std::string(subst.first), pos);
}
}
return rootNode;
@@ -171,8 +172,8 @@ static PredNode *buildPredicateTree(const tblgen::Pred &root,
// If the current predicate is a ConcatPred, record the prefix and suffix.
else if (rootNode->kind == PredCombinerKind::Concat) {
const auto &concatPred = static_cast<const tblgen::ConcatPred &>(root);
- rootNode->prefix = concatPred.getPrefix();
- rootNode->suffix = concatPred.getSuffix();
+ rootNode->prefix = std::string(concatPred.getPrefix());
+ rootNode->suffix = std::string(concatPred.getSuffix());
}
// Build child subtrees.
diff --git a/mlir/lib/Transforms/ViewOpGraph.cpp b/mlir/lib/Transforms/ViewOpGraph.cpp
index 719eb38..e5083b5 100644
--- a/mlir/lib/Transforms/ViewOpGraph.cpp
+++ b/mlir/lib/Transforms/ViewOpGraph.cpp
@@ -109,7 +109,7 @@ struct PrintOpPass : public ModulePass<PrintOpPass> {
auto symbolAttr =
op.getAttrOfType<StringAttr>(SymbolTable::getSymbolAttrName());
if (symbolAttr)
- return symbolAttr.getValue();
+ return std::string(symbolAttr.getValue());
++unnamedOpCtr;
return (op.getName().getStringRef() + llvm::utostr(unnamedOpCtr)).str();
}
diff --git a/mlir/tools/mlir-tblgen/EnumsGen.cpp b/mlir/tools/mlir-tblgen/EnumsGen.cpp
index ad2556a..c25f5fe 100644
--- a/mlir/tools/mlir-tblgen/EnumsGen.cpp
+++ b/mlir/tools/mlir-tblgen/EnumsGen.cpp
@@ -62,9 +62,11 @@ static void emitEnumClass(const Record &enumDef, StringRef enumName,
static void emitDenseMapInfo(StringRef enumName, std::string underlyingType,
StringRef cppNamespace, raw_ostream &os) {
- std::string qualName = formatv("{0}::{1}", cppNamespace, enumName);
+ std::string qualName =
+ std::string(formatv("{0}::{1}", cppNamespace, enumName));
if (underlyingType.empty())
- underlyingType = formatv("std::underlying_type<{0}>::type", qualName);
+ underlyingType =
+ std::string(formatv("std::underlying_type<{0}>::type", qualName));
const char *const mapInfo = R"(
namespace llvm {
@@ -133,7 +135,7 @@ getAllBitsUnsetCase(llvm::ArrayRef<EnumAttrCase> cases) {
static void emitOperators(const Record &enumDef, raw_ostream &os) {
EnumAttr enumAttr(enumDef);
StringRef enumName = enumAttr.getEnumClassName();
- std::string underlyingType = enumAttr.getUnderlyingType();
+ std::string underlyingType = std::string(enumAttr.getUnderlyingType());
os << formatv("inline {0} operator|({0} lhs, {0} rhs) {{\n", enumName)
<< formatv(" return static_cast<{0}>("
"static_cast<{1}>(lhs) | static_cast<{1}>(rhs));\n",
@@ -227,7 +229,7 @@ static void emitStrToSymFnForIntEnum(const Record &enumDef, raw_ostream &os) {
static void emitStrToSymFnForBitEnum(const Record &enumDef, raw_ostream &os) {
EnumAttr enumAttr(enumDef);
StringRef enumName = enumAttr.getEnumClassName();
- std::string underlyingType = enumAttr.getUnderlyingType();
+ std::string underlyingType = std::string(enumAttr.getUnderlyingType());
StringRef strToSymFnName = enumAttr.getStringToSymbolFnName();
StringRef separator = enumDef.getValueAsString("separator");
auto enumerants = enumAttr.getAllCases();
@@ -273,7 +275,7 @@ static void emitUnderlyingToSymFnForIntEnum(const Record &enumDef,
raw_ostream &os) {
EnumAttr enumAttr(enumDef);
StringRef enumName = enumAttr.getEnumClassName();
- std::string underlyingType = enumAttr.getUnderlyingType();
+ std::string underlyingType = std::string(enumAttr.getUnderlyingType());
StringRef underlyingToSymFnName = enumAttr.getUnderlyingToSymbolFnName();
auto enumerants = enumAttr.getAllCases();
@@ -304,7 +306,7 @@ static void emitUnderlyingToSymFnForBitEnum(const Record &enumDef,
raw_ostream &os) {
EnumAttr enumAttr(enumDef);
StringRef enumName = enumAttr.getEnumClassName();
- std::string underlyingType = enumAttr.getUnderlyingType();
+ std::string underlyingType = std::string(enumAttr.getUnderlyingType());
StringRef underlyingToSymFnName = enumAttr.getUnderlyingToSymbolFnName();
auto enumerants = enumAttr.getAllCases();
auto allBitsUnsetCase = getAllBitsUnsetCase(enumerants);
@@ -319,7 +321,7 @@ static void emitUnderlyingToSymFnForBitEnum(const Record &enumDef,
llvm::SmallVector<std::string, 8> values;
for (const auto &enumerant : enumerants) {
if (auto val = enumerant.getValue())
- values.push_back(formatv("{0}u", val));
+ values.push_back(std::string(formatv("{0}u", val)));
}
os << formatv(" if (value & ~({0})) return llvm::None;\n",
llvm::join(values, " | "));
@@ -331,7 +333,7 @@ static void emitEnumDecl(const Record &enumDef, raw_ostream &os) {
EnumAttr enumAttr(enumDef);
StringRef enumName = enumAttr.getEnumClassName();
StringRef cppNamespace = enumAttr.getCppNamespace();
- std::string underlyingType = enumAttr.getUnderlyingType();
+ std::string underlyingType = std::string(enumAttr.getUnderlyingType());
StringRef description = enumAttr.getDescription();
StringRef strToSymFnName = enumAttr.getStringToSymbolFnName();
StringRef symToStrFnName = enumAttr.getSymbolToStringFnName();
diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index 2081fb7..599c771 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -114,9 +114,9 @@ static inline bool hasStringAttribute(const Record &record,
static std::string getArgumentName(const Operator &op, int index) {
const auto &operand = op.getOperand(index);
if (!operand.name.empty())
- return operand.name;
+ return std::string(operand.name);
else
- return formatv("{0}_{1}", generatedArgName, index);
+ return std::string(formatv("{0}_{1}", generatedArgName, index));
}
// Returns true if we can use unwrapped value for the given `attr` in builders.
@@ -340,8 +340,8 @@ void OpEmitter::genAttrGetters() {
// Returns the default value if not set.
// TODO: this is inefficient, we are recreating the attribute for every
// call. This should be set instead.
- std::string defaultValue =
- tgfmt(attr.getConstBuilderTemplate(), &fctx, attr.getDefaultValue());
+ std::string defaultValue = std::string(
+ tgfmt(attr.getConstBuilderTemplate(), &fctx, attr.getDefaultValue()));
body << " if (!attr)\n return "
<< tgfmt(attr.getConvertFromStorageCall(),
&fctx.withSelf(defaultValue))
@@ -867,9 +867,9 @@ void OpEmitter::buildParamList(std::string &paramList,
// Add parameters for all return types
for (int i = 0; i < numResults; ++i) {
const auto &result = op.getResult(i);
- std::string resultName = result.name;
+ std::string resultName = std::string(result.name);
if (resultName.empty())
- resultName = formatv("resultType{0}", i);
+ resultName = std::string(formatv("resultType{0}", i));
paramList.append(result.isVariadic() ? ", ArrayRef<Type> " : ", Type ");
paramList.append(resultName);
@@ -930,18 +930,18 @@ void OpEmitter::buildParamList(std::string &paramList,
switch (attrParamKind) {
case AttrParamKind::WrappedAttr:
- paramList.append(attr.getStorageType());
+ paramList.append(std::string(attr.getStorageType()));
break;
case AttrParamKind::UnwrappedValue:
if (canUseUnwrappedRawValue(attr)) {
- paramList.append(attr.getReturnType());
+ paramList.append(std::string(attr.getReturnType()));
} else {
- paramList.append(attr.getStorageType());
+ paramList.append(std::string(attr.getStorageType()));
}
break;
}
paramList.append(" ");
- paramList.append(namedAttr.name);
+ paramList.append(std::string(namedAttr.name));
// Attach default value if requested and possible.
if (attrParamKind == AttrParamKind::UnwrappedValue &&
@@ -950,7 +950,7 @@ void OpEmitter::buildParamList(std::string &paramList,
paramList.append(" = ");
if (isString)
paramList.append("\"");
- paramList.append(attr.getDefaultValue());
+ paramList.append(std::string(attr.getDefaultValue()));
if (isString)
paramList.append("\"");
}
@@ -981,7 +981,8 @@ void OpEmitter::genCodeForAddingArgAndRegionForBuilder(OpMethodBody &body,
FmtContext fctx;
fctx.withBuilder("(*odsBuilder)");
- std::string builderTemplate = attr.getConstBuilderTemplate();
+ std::string builderTemplate =
+ std::string(attr.getConstBuilderTemplate());
// For StringAttr, its constant builder call will wrap the input in
// quotes, which is correct for normal string literals, but incorrect
@@ -990,7 +991,8 @@ void OpEmitter::genCodeForAddingArgAndRegionForBuilder(OpMethodBody &body,
if (StringRef(builderTemplate).contains("\"$0\""))
builderTemplate = replaceAllSubstrs(builderTemplate, "\"$0\"", "$0");
- std::string value = tgfmt(builderTemplate, &fctx, namedAttr.name);
+ std::string value =
+ std::string(tgfmt(builderTemplate, &fctx, namedAttr.name));
body << formatv(" {0}.addAttribute(\"{1}\", {2});\n", builderOpState,
namedAttr.name, value);
} else {
@@ -1251,9 +1253,9 @@ void OpEmitter::genRegionVerifier(OpMethodBody &body) {
for (unsigned i = 0; i < numRegions; ++i) {
const auto &region = op.getRegion(i);
- std::string name = formatv("#{0}", i);
+ std::string name = std::string(formatv("#{0}", i));
if (!region.name.empty()) {
- name += formatv(" ('{0}')", region.name);
+ name += std::string(formatv(" ('{0}')", region.name));
}
auto getRegion = formatv("this->getOperation()->getRegion({0})", i).str();
diff --git a/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp b/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
index 7bc0959..938c1c2 100644
--- a/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
@@ -173,7 +173,7 @@ static void emitTraitDecl(OpInterface &interface, raw_ostream &os,
traitCtx.withOp("op");
if (auto verify = interface.getVerify()) {
os << " static LogicalResult verifyTrait(Operation* op) {\n"
- << tblgen::tgfmt(*verify, &traitCtx) << "\n }\n";
+ << std::string(tblgen::tgfmt(*verify, &traitCtx)) << "\n }\n";
}
os << " };\n";
diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp
index adbd47f..fa57219 100644
--- a/mlir/tools/mlir-tblgen/RewriterGen.cpp
+++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp
@@ -198,7 +198,7 @@ std::string PatternEmitter::handleConstantAttr(Attribute attr,
" does not have the 'constBuilderCall' field");
// TODO(jpienaar): Verify the constants here
- return tgfmt(attr.getConstBuilderTemplate(), &fmtCtx, value);
+ return std::string(tgfmt(attr.getConstBuilderTemplate(), &fmtCtx, value));
}
// Helper function to match patterns.
@@ -298,8 +298,8 @@ void PatternEmitter::emitOperandMatch(DagNode tree, int argIndex, int depth,
formatv("(*castedOp{0}.getODSOperands({1}).begin()).getType()", depth,
argIndex);
os.indent(indent) << "if (!("
- << tgfmt(matcher.getConditionTemplate(),
- &fmtCtx.withSelf(self))
+ << std::string(tgfmt(matcher.getConditionTemplate(),
+ &fmtCtx.withSelf(self)))
<< ")) return matchFailure();\n";
}
}
@@ -336,8 +336,8 @@ void PatternEmitter::emitAttributeMatch(DagNode tree, int argIndex, int depth,
// TODO(antiagainst): This should use getter method to avoid duplication.
if (attr.hasDefaultValue()) {
os.indent(indent) << "if (!tblgen_attr) tblgen_attr = "
- << tgfmt(attr.getConstBuilderTemplate(), &fmtCtx,
- attr.getDefaultValue())
+ << std::string(tgfmt(attr.getConstBuilderTemplate(),
+ &fmtCtx, attr.getDefaultValue()))
<< ";\n";
} else if (attr.isOptional()) {
// For a missing attribute that is optional according to definition, we
@@ -358,8 +358,8 @@ void PatternEmitter::emitAttributeMatch(DagNode tree, int argIndex, int depth,
// If a constraint is specified, we need to generate C++ statements to
// check the constraint.
os.indent(indent) << "if (!("
- << tgfmt(matcher.getConditionTemplate(),
- &fmtCtx.withSelf("tblgen_attr"))
+ << std::string(tgfmt(matcher.getConditionTemplate(),
+ &fmtCtx.withSelf("tblgen_attr")))
<< ")) return matchFailure();\n";
}
@@ -593,7 +593,8 @@ void PatternEmitter::emitRewriteLogic() {
}
std::string PatternEmitter::getUniqueSymbol(const Operator *op) {
- return formatv("tblgen_{0}_{1}", op->getCppClassName(), nextValueId++);
+ return std::string(
+ formatv("tblgen_{0}_{1}", op->getCppClassName(), nextValueId++));
}
std::string PatternEmitter::handleResultPattern(DagNode resultTree,
@@ -634,7 +635,7 @@ std::string PatternEmitter::handleReplaceWithValue(DagNode tree) {
PrintFatalError(loc, "cannot bind symbol to replaceWithValue");
}
- return tree.getArgName(0);
+ return std::string(tree.getArgName(0));
}
std::string PatternEmitter::handleOpArgument(DagLeaf leaf,
@@ -665,7 +666,7 @@ std::string PatternEmitter::handleOpArgument(DagLeaf leaf,
auto repl = tgfmt(leaf.getNativeCodeTemplate(), &fmtCtx.withSelf(argName));
LLVM_DEBUG(llvm::dbgs() << "replace " << patArgName << " with '" << repl
<< "' (via NativeCodeCall)\n");
- return repl;
+ return std::string(repl);
}
PrintFatalError(loc, "unhandled case when rewriting op");
}
@@ -687,8 +688,8 @@ std::string PatternEmitter::handleReplaceWithNativeCodeCall(DagNode tree) {
LLVM_DEBUG(llvm::dbgs() << "NativeCodeCall argument #" << i
<< " replacement: " << attrs[i] << "\n");
}
- return tgfmt(fmt, &fmtCtx, attrs[0], attrs[1], attrs[2], attrs[3], attrs[4],
- attrs[5], attrs[6], attrs[7]);
+ return std::string(tgfmt(fmt, &fmtCtx, attrs[0], attrs[1], attrs[2], attrs[3],
+ attrs[4], attrs[5], attrs[6], attrs[7]));
}
int PatternEmitter::getNodeValueCount(DagNode node) {
@@ -748,10 +749,10 @@ std::string PatternEmitter::handleOpCreation(DagNode tree, int resultIndex,
// unique name.
valuePackName = resultValue = getUniqueSymbol(&resultOp);
} else {
- resultValue = tree.getSymbol();
+ resultValue = std::string(tree.getSymbol());
// Strip the index to get the name for the value pack and use it to name the
// local variable for the op.
- valuePackName = SymbolInfoMap::getValuePackName(resultValue);
+ valuePackName = std::string(SymbolInfoMap::getValuePackName(resultValue));
}
// Create the local variable for this op.
@@ -855,13 +856,13 @@ void PatternEmitter::createSeparateLocalVarsForOpArgs(
std::string varName;
if (operand->isVariadic()) {
- varName = formatv("tblgen_values_{0}", valueIndex++);
+ varName = std::string(formatv("tblgen_values_{0}", valueIndex++));
os.indent(6) << formatv("SmallVector<Value, 4> {0};\n", varName);
std::string range;
if (node.isNestedDagArg(argIndex)) {
range = childNodeNames[argIndex];
} else {
- range = node.getArgName(argIndex);
+ range = std::string(node.getArgName(argIndex));
}
// Resolve the symbol for all range use so that we have a uniform way of
// capturing the values.
@@ -869,7 +870,7 @@ void PatternEmitter::createSeparateLocalVarsForOpArgs(
os.indent(6) << formatv("for (auto v : {0}) {1}.push_back(v);\n", range,
varName);
} else {
- varName = formatv("tblgen_value_{0}", valueIndex++);
+ varName = std::string(formatv("tblgen_value_{0}", valueIndex++));
os.indent(6) << formatv("Value {0} = ", varName);
if (node.isNestedDagArg(argIndex)) {
os << symbolInfoMap.getValueAndRangeUse(childNodeNames[argIndex]);
@@ -878,7 +879,8 @@ void PatternEmitter::createSeparateLocalVarsForOpArgs(
auto symbol =
symbolInfoMap.getValueAndRangeUse(node.getArgName(argIndex));
if (leaf.isNativeCodeCall()) {
- os << tgfmt(leaf.getNativeCodeTemplate(), &fmtCtx.withSelf(symbol));
+ os << std::string(
+ tgfmt(leaf.getNativeCodeTemplate(), &fmtCtx.withSelf(symbol)));
} else {
os << symbol;
}
@@ -974,7 +976,7 @@ void PatternEmitter::createAggregateLocalVarsForOpArgs(
if (node.isNestedDagArg(argIndex)) {
range = childNodeNames.lookup(argIndex);
} else {
- range = node.getArgName(argIndex);
+ range = std::string(node.getArgName(argIndex));
}
// Resolve the symbol for all range use so that we have a uniform way of
// capturing the values.
@@ -991,7 +993,8 @@ void PatternEmitter::createAggregateLocalVarsForOpArgs(
auto symbol =
symbolInfoMap.getValueAndRangeUse(node.getArgName(argIndex));
if (leaf.isNativeCodeCall()) {
- os << tgfmt(leaf.getNativeCodeTemplate(), &fmtCtx.withSelf(symbol));
+ os << std::string(
+ tgfmt(leaf.getNativeCodeTemplate(), &fmtCtx.withSelf(symbol)));
} else {
os << symbol;
}
@@ -1023,7 +1026,7 @@ static void emitRewriters(const RecordKeeper &recordKeeper, raw_ostream &os) {
// appending unique suffix.
name = baseRewriterName + llvm::utostr(rewriterIndex++);
} else {
- name = p->getName();
+ name = std::string(p->getName());
}
LLVM_DEBUG(llvm::dbgs()
<< "=== start generating pattern '" << name << "' ===\n");
diff --git a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
index 69a9f14..52c87cc 100644
--- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
+++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
@@ -222,7 +222,8 @@ static void emitModelDecl(const Availability &availability, raw_ostream &os) {
static void emitInterfaceDecl(const Availability &availability,
raw_ostream &os) {
StringRef interfaceName = availability.getInterfaceClassName();
- std::string interfaceTraitsName = formatv("{0}Traits", interfaceName);
+ std::string interfaceTraitsName =
+ std::string(formatv("{0}Traits", interfaceName));
// Emit the traits struct containing the concept and model declarations.
os << "namespace detail {\n"
@@ -337,7 +338,7 @@ static void emitAvailabilityQueryForBitEnum(const Record &enumDef,
raw_ostream &os) {
EnumAttr enumAttr(enumDef);
StringRef enumName = enumAttr.getEnumClassName();
- std::string underlyingType = enumAttr.getUnderlyingType();
+ std::string underlyingType = std::string(enumAttr.getUnderlyingType());
std::vector<EnumAttrCase> enumerants = enumAttr.getAllCases();
// Mapping from availability class name to (enumerant, availability
@@ -1201,8 +1202,9 @@ static void emitAvailabilityImpl(const Operator &srcOp, raw_ostream &os) {
for (const Availability &avail : opAvailabilities)
if (avail.getClass() == availClassName) {
os << " "
- << tgfmt(avail.getMergeActionCode(),
- &fctx.addSubst("instance", avail.getMergeInstance()))
+ << std::string(
+ tgfmt(avail.getMergeActionCode(),
+ &fctx.addSubst("instance", avail.getMergeInstance())))
<< ";\n";
}
@@ -1251,8 +1253,8 @@ static void emitAvailabilityImpl(const Operator &srcOp, raw_ostream &os) {
// TODO(antiagainst): use `avail.getMergeCode()` here once ODS supports
// dialect-specific contents so that we can use not implementing the
// availability interface as indication of no requirements.
- << tgfmt(caseSpecs.front().second.getMergeActionCode(),
- &fctx.addSubst("instance", "*instance"))
+ << std::string(tgfmt(caseSpecs.front().second.getMergeActionCode(),
+ &fctx.addSubst("instance", "*instance")))
<< ";\n";
os << " }\n";
}
diff --git a/mlir/tools/mlir-tblgen/StructsGen.cpp b/mlir/tools/mlir-tblgen/StructsGen.cpp
index 439f7bee..133f2e9 100644
--- a/mlir/tools/mlir-tblgen/StructsGen.cpp
+++ b/mlir/tools/mlir-tblgen/StructsGen.cpp
@@ -174,7 +174,7 @@ bool {0}::classof(mlir::Attribute attr))";
auto name = field.getName();
auto type = field.getType();
std::string condition =
- tgfmt(type.getConditionTemplate(), &fctx.withSelf(name));
+ std::string(tgfmt(type.getConditionTemplate(), &fctx.withSelf(name)));
os << llvm::formatv(classofArgInfo, name, condition);
}
diff --git a/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp b/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp
index fe51460..bcc3d1c 100644
--- a/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp
+++ b/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp
@@ -51,7 +51,7 @@ protected:
ASSERT_NE(nullptr, diagnostic.get());
// TODO(antiagainst): check error location too.
- EXPECT_THAT(diagnostic->str(), StrEq(errorMessage));
+ EXPECT_THAT(diagnostic->str(), StrEq(std::string(errorMessage)));
}
//===--------------------------------------------------------------------===//
diff --git a/mlir/unittests/TableGen/FormatTest.cpp b/mlir/unittests/TableGen/FormatTest.cpp
index 401aa49..ee60929 100644
--- a/mlir/unittests/TableGen/FormatTest.cpp
+++ b/mlir/unittests/TableGen/FormatTest.cpp
@@ -15,14 +15,14 @@ using ::testing::StrEq;
TEST(FormatTest, EmptyFmtStr) {
FmtContext ctx;
- std::string result = tgfmt("", &ctx);
+ std::string result = std::string(tgfmt("", &ctx));
EXPECT_TRUE(result.empty());
}
// Allow extra unused positional parameters
TEST(FormatTest, EmptyFmtStrExtraParams) {
FmtContext ctx;
- std::string result = tgfmt("", &ctx, "a", "b", "c");
+ std::string result = std::string(tgfmt("", &ctx, "a", "b", "c"));
EXPECT_TRUE(result.empty());
}
@@ -30,27 +30,27 @@ TEST(FormatTest, EmptyFmtStrExtraParams) {
TEST(FormatTest, EmptyFmtStrPopulatedCtx) {
FmtContext ctx;
ctx.withBuilder("builder");
- std::string result = tgfmt("", &ctx);
+ std::string result = std::string(tgfmt("", &ctx));
EXPECT_TRUE(result.empty());
}
TEST(FormatTest, LiteralFmtStr) {
FmtContext ctx;
- std::string result = tgfmt("void foo {}", &ctx);
+ std::string result = std::string(tgfmt("void foo {}", &ctx));
EXPECT_THAT(result, StrEq("void foo {}"));
}
// Print single dollar literally
TEST(FormatTest, AdjacentDollar) {
FmtContext ctx;
- std::string result = tgfmt("$", &ctx);
+ std::string result = std::string(tgfmt("$", &ctx));
EXPECT_THAT(result, StrEq("$"));
}
// Print dangling dollar literally
TEST(FormatTest, DanglingDollar) {
FmtContext ctx;
- std::string result = tgfmt("foo bar baz$", &ctx);
+ std::string result = std::string(tgfmt("foo bar baz$", &ctx));
EXPECT_THAT(result, StrEq("foo bar baz$"));
}
@@ -58,7 +58,7 @@ TEST(FormatTest, DanglingDollar) {
TEST(FormatTest, EscapeDollars) {
FmtContext ctx;
std::string result =
- tgfmt("$$ $$$$ $$$0 $$$_self", &ctx.withSelf("self"), "-0");
+ std::string(tgfmt("$$ $$$$ $$$0 $$$_self", &ctx.withSelf("self"), "-0"));
EXPECT_THAT(result, StrEq("$ $$ $-0 $self"));
}
@@ -67,57 +67,58 @@ TEST(FormatTest, PositionalFmtStr) {
std::string b = "b";
int c = 42;
char d = 'd';
- std::string result = tgfmt("$0 $1 $2 $3", &ctx, "a", b, c + 1, d);
+ std::string result =
+ std::string(tgfmt("$0 $1 $2 $3", &ctx, "a", b, c + 1, d));
EXPECT_THAT(result, StrEq("a b 43 d"));
}
// Output the placeholder if missing substitution
TEST(FormatTest, PositionalFmtStrMissingParams) {
FmtContext ctx;
- std::string result = tgfmt("$0 %1 $2", &ctx);
+ std::string result = std::string(tgfmt("$0 %1 $2", &ctx));
EXPECT_THAT(result, StrEq("$0<no-subst-found> %1 $2<no-subst-found>"));
}
// Allow flexible reference of positional parameters
TEST(FormatTest, PositionalFmtStrFlexibleRef) {
FmtContext ctx;
- std::string result = tgfmt("$2 $0 $2", &ctx, "a", "b", "c");
+ std::string result = std::string(tgfmt("$2 $0 $2", &ctx, "a", "b", "c"));
EXPECT_THAT(result, StrEq("c a c"));
}
TEST(FormatTest, PositionalFmtStrNoWhitespace) {
FmtContext ctx;
- std::string result = tgfmt("foo$0bar", &ctx, "-");
+ std::string result = std::string(tgfmt("foo$0bar", &ctx, "-"));
EXPECT_THAT(result, StrEq("foo-bar"));
}
TEST(FormatTest, PlaceHolderFmtStrWithSelf) {
FmtContext ctx;
- std::string result = tgfmt("$_self", &ctx.withSelf("sss"));
+ std::string result = std::string(tgfmt("$_self", &ctx.withSelf("sss")));
EXPECT_THAT(result, StrEq("sss"));
}
TEST(FormatTest, PlaceHolderFmtStrWithBuilder) {
FmtContext ctx;
- std::string result = tgfmt("$_builder", &ctx.withBuilder("bbb"));
+ std::string result = std::string(tgfmt("$_builder", &ctx.withBuilder("bbb")));
EXPECT_THAT(result, StrEq("bbb"));
}
TEST(FormatTest, PlaceHolderFmtStrWithOp) {
FmtContext ctx;
- std::string result = tgfmt("$_op", &ctx.withOp("ooo"));
+ std::string result = std::string(tgfmt("$_op", &ctx.withOp("ooo")));
EXPECT_THAT(result, StrEq("ooo"));
}
TEST(FormatTest, PlaceHolderMissingCtx) {
- std::string result = tgfmt("$_op", nullptr);
+ std::string result = std::string(tgfmt("$_op", nullptr));
EXPECT_THAT(result, StrEq("$_op<no-subst-found>"));
}
TEST(FormatTest, PlaceHolderMissingSubst) {
FmtContext ctx;
- std::string result = tgfmt("$_op", &ctx.withBuilder("builder"));
+ std::string result = std::string(tgfmt("$_op", &ctx.withBuilder("builder")));
EXPECT_THAT(result, StrEq("$_op<no-subst-found>"));
}
@@ -125,7 +126,7 @@ TEST(FormatTest, PlaceHolderMissingSubst) {
TEST(FormatTest, PlaceHolderFmtStrDelimiter) {
FmtContext ctx;
ctx.addSubst("m", "");
- std::string result = tgfmt("$m{$m($m[$m]$m)$m}$m|", &ctx);
+ std::string result = std::string(tgfmt("$m{$m($m[$m]$m)$m}$m|", &ctx));
EXPECT_THAT(result, StrEq("{([])}|"));
}
@@ -136,13 +137,13 @@ TEST(FormatTest, CustomPlaceHolderFmtStrPlaceHolderChars) {
ctx.addSubst("m1", "1 ");
ctx.addSubst("m2C", "2 ");
ctx.addSubst("M_3", "3 ");
- std::string result = tgfmt("$m$m1$m2C$M_3", &ctx);
+ std::string result = std::string(tgfmt("$m$m1$m2C$M_3", &ctx));
EXPECT_THAT(result, StrEq("0 1 2 3 "));
}
TEST(FormatTest, CustomPlaceHolderFmtStrUnregisteredPlaceHolders) {
FmtContext ctx;
- std::string result = tgfmt("foo($awesome, $param)", &ctx);
+ std::string result = std::string(tgfmt("foo($awesome, $param)", &ctx));
EXPECT_THAT(result,
StrEq("foo($awesome<no-subst-found>, $param<no-subst-found>)"));
}
@@ -151,7 +152,7 @@ TEST(FormatTest, MixedFmtStr) {
FmtContext ctx;
ctx.withBuilder("bbb");
- std::string result = tgfmt("$_builder.build($_self, {$0, $1})",
- &ctx.withSelf("sss"), "a", "b");
+ std::string result = std::string(tgfmt("$_builder.build($_self, {$0, $1})",
+ &ctx.withSelf("sss"), "a", "b"));
EXPECT_THAT(result, StrEq("bbb.build(sss, {a, b})"));
}