From e3c609c5d85882ea0cd32bea47453661c501f65f Mon Sep 17 00:00:00 2001 From: Alexey Bader Date: Thu, 7 Nov 2024 14:06:25 -0800 Subject: [PATCH] Revert "LLVM and SPIRV-LLVM-Translator pulldown (WW41 2024)" --- .github/new-prs-labeler.yml | 7 +- .github/workflows/commit-access-review.py | 5 +- .github/workflows/libcxx-build-and-test.yaml | 7 - .github/workflows/release-binaries.yml | 15 +- .../include/bolt/Profile/ProfileYAMLMapping.h | 81 +- bolt/include/bolt/Profile/YAMLProfileWriter.h | 52 +- bolt/include/bolt/Utils/Utils.h | 5 - bolt/lib/Passes/ADRRelaxationPass.cpp | 9 +- bolt/lib/Profile/DataAggregator.cpp | 51 +- bolt/lib/Profile/YAMLProfileReader.cpp | 6 +- bolt/lib/Profile/YAMLProfileWriter.cpp | 189 +- bolt/lib/Rewrite/PseudoProbeRewriter.cpp | 56 +- bolt/lib/Utils/Utils.cpp | 12 +- .../test/X86/pseudoprobe-decoding-inline.test | 36 +- .../X86/pseudoprobe-decoding-noinline.test | 41 +- bolt/test/X86/yaml-unknown-keys.test | 50 - bolt/test/lit.local.cfg | 4 +- bolt/test/perf2bolt/lit.local.cfg | 5 +- bolt/tools/merge-fdata/merge-fdata.cpp | 1 - clang-tools-extra/CMakeLists.txt | 1 + clang-tools-extra/CODE_OWNERS.TXT | 2 +- .../ClangTidyDiagnosticConsumer.cpp | 2 + clang-tools-extra/clang-tidy/add_new_check.py | 91 +- .../bugprone/CastingThroughVoidCheck.cpp | 4 +- .../ForwardingReferenceOverloadCheck.cpp | 15 +- .../bugprone/SizeofExpressionCheck.cpp | 103 +- .../bugprone/SizeofExpressionCheck.h | 2 +- .../clang-tidy/cert/CERTTidyModule.cpp | 10 - .../clang-tidy/cert/FloatLoopCounter.cpp | 22 +- .../PreferMemberInitializerCheck.cpp | 6 +- .../misc/DefinitionsInHeadersCheck.cpp | 2 +- .../UnconventionalAssignOperatorCheck.cpp | 15 +- .../modernize/AvoidCArraysCheck.cpp | 27 +- .../clang-tidy/modernize/LoopConvertCheck.cpp | 6 +- .../MinMaxUseInitializerListCheck.cpp | 23 +- .../clang-tidy/performance/AvoidEndlCheck.cpp | 33 +- .../AvoidUnconditionalPreprocessorIfCheck.cpp | 3 +- .../readability/ContainerContainsCheck.cpp | 56 +- .../readability/ContainerContainsCheck.h | 12 +- .../readability/EnumInitialValueCheck.cpp | 16 +- .../clang-tidy/tool/run-clang-tidy.py | 7 +- clang-tools-extra/clangd/CMakeLists.txt | 1 + clang-tools-extra/clangd/Diagnostics.cpp | 27 +- clang-tools-extra/clangd/Diagnostics.h | 8 +- clang-tools-extra/clangd/DumpAST.cpp | 1 - clang-tools-extra/clangd/Feature.cpp | 1 - clang-tools-extra/clangd/ParsedAST.cpp | 6 +- clang-tools-extra/clangd/Preamble.cpp | 4 +- .../clangd/SemanticHighlighting.cpp | 1 - .../clangd/SemanticSelection.cpp | 32 +- clang-tools-extra/clangd/TidyFastChecks.inc | 669 +- .../clangd/support/CMakeLists.txt | 10 - .../clangd/unittests/ClangdTests.cpp | 1 - .../clangd/unittests/CompileCommandsTests.cpp | 1 - .../clangd/unittests/ConfigCompileTests.cpp | 47 +- .../clangd/unittests/SerializationTests.cpp | 1 - clang-tools-extra/docs/ReleaseNotes.rst | 70 +- clang-tools-extra/docs/clang-rename.rst | 168 + .../docs/clang-tidy/Contributing.rst | 26 +- .../checks/bugprone/casting-through-void.rst | 21 +- ...inter-arithmetic-on-polymorphic-object.rst | 28 +- .../return-const-ref-from-parameter.rst | 9 - .../checks/bugprone/sizeof-expression.rst | 97 - .../docs/clang-tidy/checks/cert/arr39-c.rst | 10 - .../docs/clang-tidy/checks/list.rst | 1 - .../checks/misc/const-correctness.rst | 3 +- .../misc/unconventional-assign-operator.rst | 3 + .../checks/modernize/avoid-c-arrays.rst | 17 +- .../checks/modernize/use-std-format.rst | 2 +- .../checks/modernize/use-std-print.rst | 2 +- .../avoid-nested-conditional-operator.rst | 3 + .../checks/readability/container-contains.rst | 38 +- clang-tools-extra/docs/index.rst | 1 + .../include-cleaner/lib/WalkAST.cpp | 27 +- .../test/tool-ignores-warnings.cpp | 5 - .../include-cleaner/tool/IncludeCleaner.cpp | 12 +- .../include-cleaner/unittests/WalkASTTest.cpp | 3 - clang-tools-extra/pseudo/CMakeLists.txt | 12 + clang-tools-extra/pseudo/DesignNotes.md | 123 + clang-tools-extra/pseudo/Disambiguation.md | 367 + clang-tools-extra/pseudo/README.md | 37 + .../pseudo/benchmarks/Benchmark.cpp | 156 + .../pseudo/benchmarks/CMakeLists.txt | 9 + .../pseudo/fuzzer/CMakeLists.txt | 16 + clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp | 82 + clang-tools-extra/pseudo/fuzzer/Main.cpp | 16 + clang-tools-extra/pseudo/gen/CMakeLists.txt | 11 + clang-tools-extra/pseudo/gen/Main.cpp | 172 + .../pseudo/include/CMakeLists.txt | 32 + .../include/clang-pseudo}/Bracket.h | 12 +- .../include/clang-pseudo}/DirectiveTree.h | 12 +- .../include/clang-pseudo/Disambiguate.h | 64 + .../pseudo/include/clang-pseudo/Forest.h | 236 + .../pseudo/include/clang-pseudo/GLR.h | 170 + .../pseudo/include/clang-pseudo/Language.h | 64 + .../include/clang-pseudo}/Token.h | 10 +- .../pseudo/include/clang-pseudo/cli/CLI.h | 35 + .../pseudo/include/clang-pseudo/cxx/CXX.h | 91 + .../include/clang-pseudo/grammar/Grammar.h | 230 + .../include/clang-pseudo/grammar/LRGraph.h | 196 + .../include/clang-pseudo/grammar/LRTable.h | 278 + .../support => pseudo/lib}/Bracket.cpp | 8 +- clang-tools-extra/pseudo/lib/CMakeLists.txt | 31 + .../support => pseudo/lib}/DirectiveTree.cpp | 6 +- clang-tools-extra/pseudo/lib/Disambiguate.cpp | 48 + clang-tools-extra/pseudo/lib/Forest.cpp | 199 + clang-tools-extra/pseudo/lib/GLR.cpp | 772 ++ .../{clangd/support => pseudo/lib}/Lex.cpp | 6 +- .../{clangd/support => pseudo/lib}/Token.cpp | 6 +- clang-tools-extra/pseudo/lib/cli/CLI.cpp | 54 + .../pseudo/lib/cli/CMakeLists.txt | 15 + .../pseudo/lib/cxx/CMakeLists.txt | 19 + clang-tools-extra/pseudo/lib/cxx/CXX.cpp | 452 + clang-tools-extra/pseudo/lib/cxx/cxx.bnf | 776 ++ .../pseudo/lib/grammar/CMakeLists.txt | 10 + .../pseudo/lib/grammar/Grammar.cpp | 190 + .../pseudo/lib/grammar/GrammarBNF.cpp | 362 + .../pseudo/lib/grammar/LRGraph.cpp | 265 + .../pseudo/lib/grammar/LRTable.cpp | 79 + .../pseudo/lib/grammar/LRTableBuild.cpp | 121 + clang-tools-extra/pseudo/test/.clang-format | 1 + clang-tools-extra/pseudo/test/CMakeLists.txt | 29 + clang-tools-extra/pseudo/test/Unit/lit.cfg.py | 25 + .../pseudo/test/Unit/lit.site.cfg.py.in | 11 + .../pseudo/test/check-cxx-bnf.test | 2 + .../pseudo/test/crash/backslashes.c | 4 + .../pseudo/test/cxx/capture-list.cpp | 23 + .../pseudo/test/cxx/contextual-keywords.cpp | 9 + .../pseudo/test/cxx/dangling-else.cpp | 22 + .../pseudo/test/cxx/decl-specfier-seq.cpp | 27 + .../pseudo/test/cxx/declarator-function.cpp | 9 + .../pseudo/test/cxx/declarator-var.cpp | 9 + .../test/cxx/declator-member-function.cpp | 9 + .../test/cxx/empty-member-declaration.cpp | 7 + .../pseudo/test/cxx/empty-member-spec.cpp | 13 + clang-tools-extra/pseudo/test/cxx/keyword.cpp | 12 + .../pseudo/test/cxx/literals.cpp | 43 + .../pseudo/test/cxx/mixed-designator.cpp | 27 + .../pseudo/test/cxx/nested-name-specifier.cpp | 28 + .../pseudo/test/cxx/parameter-decl-clause.cpp | 14 + .../pseudo/test/cxx/predefined-identifier.cpp | 5 + .../test/cxx/recovery-func-parameters.cpp | 13 + .../pseudo/test/cxx/recovery-init-list.cpp | 13 + .../pseudo/test/cxx/structured-binding.cpp | 6 + .../cxx/template-empty-type-parameter.cpp | 3 + .../pseudo/test/cxx/unsized-array.cpp | 7 + clang-tools-extra/pseudo/test/fuzzer.cpp | 4 + .../pseudo/test/glr-variant-start.cpp | 9 + clang-tools-extra/pseudo/test/glr.cpp | 30 + clang-tools-extra/pseudo/test/html-forest.c | 8 + clang-tools-extra/pseudo/test/lex.c | 42 + clang-tools-extra/pseudo/test/lit.cfg.py | 20 + clang-tools-extra/pseudo/test/lit.local.cfg | 2 + .../pseudo/test/lit.site.cfg.py.in | 14 + .../pseudo/test/lr-build-basic.test | 32 + .../pseudo/test/lr-build-conflicts.test | 49 + .../pseudo/test/strip-directives.c | 49 + clang-tools-extra/pseudo/tool/CMakeLists.txt | 30 + clang-tools-extra/pseudo/tool/ClangPseudo.cpp | 243 + clang-tools-extra/pseudo/tool/HTMLForest.cpp | 192 + clang-tools-extra/pseudo/tool/HTMLForest.css | 93 + clang-tools-extra/pseudo/tool/HTMLForest.html | 15 + clang-tools-extra/pseudo/tool/HTMLForest.js | 290 + .../pseudo/unittests/BracketTest.cpp | 117 + .../pseudo/unittests/CMakeLists.txt | 32 + .../pseudo/unittests/CXXTest.cpp | 30 + .../pseudo/unittests/DirectiveTreeTest.cpp | 357 + .../pseudo/unittests/DisambiguateTest.cpp | 111 + .../pseudo/unittests/ForestTest.cpp | 180 + .../pseudo/unittests/GLRTest.cpp | 789 ++ .../pseudo/unittests/GrammarTest.cpp | 213 + .../pseudo/unittests/LRTableTest.cpp | 76 + .../pseudo/unittests/TokenTest.cpp | 224 + clang-tools-extra/test/CMakeLists.txt | 3 + .../ClangRenameClassReplacements.cpp | 11 + .../bugprone/casting-through-void.cpp | 40 +- .../forwarding-reference-overload.cpp | 6 - ...eof-expression.c => sizeof-expression-2.c} | 0 ...izeof-expression-pointer-arithmetics-c11.c | 22 - .../sizeof-expression-pointer-arithmetics.c | 372 - .../checkers/bugprone/sizeof-expression.cpp | 31 +- .../test/clang-tidy/checkers/cert/flp30-c.c | 23 +- .../cppcoreguidelines/missing-std-forward.cpp | 6 +- .../prefer-member-initializer.cpp | 11 - .../checkers/misc/definitions-in-headers.hpp | 2 +- .../unconventional-assign-operator-cxx23.cpp | 10 - .../modernize/avoid-c-arrays-c++20.cpp | 11 - .../modernize/avoid-c-arrays-ignores-main.cpp | 12 +- .../avoid-c-arrays-ignores-strings.cpp | 6 +- .../avoid-c-arrays-ignores-three-arg-main.cpp | 16 +- .../checkers/modernize/avoid-c-arrays.cpp | 34 +- .../min-max-use-initializer-list.cpp | 6 - .../checkers/performance/avoid-endl.cpp | 11 - .../unnecessary-value-param-crash.cpp | 23 - .../readability/container-contains.cpp | 214 +- .../checkers/readability/enum-initial-value.c | 49 +- .../readability/enum-initial-value.cpp | 2 +- .../test/clang-tidy/infrastructure/nolint.cpp | 4 +- .../infrastructure/nolintbeginend.cpp | 4 +- .../infrastructure/nolintnextline.cpp | 4 +- clang/cmake/caches/Fuchsia-stage2.cmake | 2 - clang/cmake/caches/Release.cmake | 12 +- clang/docs/ClangFormattedStatus.rst | 10 + clang/docs/DebuggingCoroutines.rst | 8 +- clang/docs/ExternalClangExamples.rst | 5 +- clang/docs/LanguageExtensions.rst | 3 - clang/docs/Multilib.rst | 6 - clang/docs/OpenMPSupport.rst | 2 +- clang/docs/RealtimeSanitizer.rst | 50 - clang/docs/ReleaseNotes.rst | 74 +- clang/docs/StandardCPlusPlusModules.rst | 38 - clang/docs/UsersManual.rst | 33 - clang/docs/analyzer/checkers.rst | 36 +- clang/docs/tools/clang-formatted-files.txt | 6 + clang/examples/Attribute/CMakeLists.txt | 6 +- clang/include/clang/AST/ASTContext.h | 40 +- clang/include/clang/AST/ASTImporter.h | 5 - .../clang/AST/CXXRecordDeclDefinitionBits.def | 4 - clang/include/clang/AST/DeclCXX.h | 4 - clang/include/clang/AST/DependenceFlags.h | 5 - clang/include/clang/AST/Expr.h | 3 - clang/include/clang/AST/PropertiesBase.td | 17 - clang/include/clang/AST/RecursiveASTVisitor.h | 6 +- clang/include/clang/AST/Stmt.h | 5 +- clang/include/clang/AST/StmtDataCollectors.td | 1 + clang/include/clang/AST/TemplateName.h | 63 +- clang/include/clang/AST/Type.h | 35 +- clang/include/clang/AST/TypeLoc.h | 12 - clang/include/clang/AST/TypeProperties.td | 10 +- .../Analysis/Analyses/ExprMutationAnalyzer.h | 7 +- .../Analysis/Analyses/UnsafeBufferUsage.h | 19 - .../Analyses/UnsafeBufferUsageGadgets.def | 13 +- .../clang/Basic/AArch64SVEACLETypes.def | 177 +- clang/include/clang/Basic/AMDGPUTypes.def | 4 +- clang/include/clang/Basic/Attr.td | 77 +- clang/include/clang/Basic/AttrDocs.td | 98 +- clang/include/clang/Basic/Builtins.td | 37 - clang/include/clang/Basic/BuiltinsAMDGPU.def | 2 - clang/include/clang/Basic/BuiltinsPPC.def | 6 + clang/include/clang/Basic/BuiltinsSystemZ.def | 4 + .../clang/Basic/BuiltinsWebAssembly.def | 24 +- clang/include/clang/Basic/BuiltinsX86.def | 106 +- clang/include/clang/Basic/BuiltinsX86_64.def | 6 - clang/include/clang/Basic/CMakeLists.txt | 3 - clang/include/clang/Basic/Diagnostic.h | 278 +- .../include/clang/Basic/DiagnosticASTKinds.td | 14 +- .../clang/Basic/DiagnosticCategories.h | 5 +- .../clang/Basic/DiagnosticCommonKinds.td | 5 + .../clang/Basic/DiagnosticDriverKinds.td | 2 - .../clang/Basic/DiagnosticFrontendKinds.td | 4 - clang/include/clang/Basic/DiagnosticGroups.td | 7 +- clang/include/clang/Basic/DiagnosticIDs.h | 162 +- .../include/clang/Basic/DiagnosticLexKinds.td | 5 - .../clang/Basic/DiagnosticParseKinds.td | 22 +- .../clang/Basic/DiagnosticSemaKinds.td | 63 +- clang/include/clang/Basic/Features.def | 2 - clang/include/clang/Basic/LangOptions.h | 3 +- clang/include/clang/Basic/LangStandards.def | 16 +- clang/include/clang/Basic/OpenMPKinds.h | 5 - clang/include/clang/Basic/PartialDiagnostic.h | 5 +- clang/include/clang/Basic/SourceManager.h | 2 +- clang/include/clang/Basic/TargetBuiltins.h | 35 +- clang/include/clang/Basic/TargetCXXABI.def | 12 +- clang/include/clang/Basic/TargetInfo.h | 3 +- clang/include/clang/Basic/TokenKinds.def | 6 +- clang/include/clang/Basic/arm_fp16.td | 20 +- .../include/clang/Basic/arm_immcheck_incl.td | 43 - clang/include/clang/Basic/arm_neon.td | 656 +- clang/include/clang/Basic/arm_neon_incl.td | 17 +- clang/include/clang/Basic/arm_sve.td | 30 - clang/include/clang/Basic/arm_sve_sme_incl.td | 36 +- clang/include/clang/CodeGen/CGFunctionInfo.h | 33 +- clang/include/clang/CodeGen/CodeGenAction.h | 2 +- clang/include/clang/Driver/Multilib.h | 17 +- clang/include/clang/Driver/Options.td | 67 +- clang/include/clang/Driver/Types.def | 12 +- .../include/clang/Frontend/FrontendActions.h | 4 +- clang/include/clang/Interpreter/Value.h | 1 - clang/include/clang/Lex/Preprocessor.h | 43 +- clang/include/clang/Parse/Parser.h | 3 - clang/include/clang/Sema/Overload.h | 6 +- clang/include/clang/Sema/Sema.h | 43 +- clang/include/clang/Sema/SemaARM.h | 16 +- clang/include/clang/Sema/SemaHLSL.h | 26 +- clang/include/clang/Sema/SemaRISCV.h | 1 - .../include/clang/Serialization/ModuleFile.h | 10 +- .../clang/StaticAnalyzer/Checkers/Checkers.td | 8 +- .../Core/BugReporter/BugReporterVisitors.h | 85 - .../StaticAnalyzer/Core/CheckerManager.h | 2 + .../Core/PathSensitive/CheckerContext.h | 1 - .../Core/PathSensitive/DynamicExtent.h | 2 +- .../Core/PathSensitive/SMTConstraintManager.h | 5 - .../Core/PathSensitive/SValBuilder.h | 12 +- .../StaticAnalyzer/Core/PathSensitive/SVals.h | 2 - .../clang/Tooling/CompilationDatabase.h | 6 - .../DependencyScanningService.h | 6 +- .../DependencyScanningTool.h | 2 - .../DependencyScanningWorker.h | 2 - .../Tooling/Inclusions/StandardLibrary.h | 1 - clang/lib/APINotes/APINotesWriter.cpp | 20 +- clang/lib/AST/APValue.cpp | 1 + clang/lib/AST/ASTContext.cpp | 373 +- clang/lib/AST/ASTDiagnostic.cpp | 45 +- clang/lib/AST/ASTImporter.cpp | 120 +- clang/lib/AST/ASTStructuralEquivalence.cpp | 7 +- clang/lib/AST/ByteCode/ByteCodeEmitter.h | 2 +- clang/lib/AST/ByteCode/Compiler.cpp | 436 +- clang/lib/AST/ByteCode/Compiler.h | 16 +- clang/lib/AST/ByteCode/Context.cpp | 23 +- clang/lib/AST/ByteCode/Context.h | 3 +- clang/lib/AST/ByteCode/DynamicAllocator.cpp | 15 +- clang/lib/AST/ByteCode/DynamicAllocator.h | 27 +- clang/lib/AST/ByteCode/EvalEmitter.cpp | 5 +- clang/lib/AST/ByteCode/EvalEmitter.h | 5 +- clang/lib/AST/ByteCode/EvaluationResult.cpp | 4 +- clang/lib/AST/ByteCode/Function.cpp | 3 +- clang/lib/AST/ByteCode/Function.h | 4 +- clang/lib/AST/ByteCode/Interp.cpp | 307 +- clang/lib/AST/ByteCode/Interp.h | 436 +- clang/lib/AST/ByteCode/InterpBuiltin.cpp | 168 +- clang/lib/AST/ByteCode/InterpFrame.cpp | 78 +- clang/lib/AST/ByteCode/InterpFrame.h | 3 + clang/lib/AST/ByteCode/InterpStack.cpp | 25 - clang/lib/AST/ByteCode/InterpStack.h | 1 - clang/lib/AST/ByteCode/InterpState.h | 4 - clang/lib/AST/ByteCode/Opcodes.td | 13 +- clang/lib/AST/ByteCode/Pointer.cpp | 25 +- clang/lib/AST/ByteCode/Pointer.h | 6 +- clang/lib/AST/ByteCode/Program.cpp | 40 +- clang/lib/AST/ByteCode/Program.h | 4 +- clang/lib/AST/ByteCode/State.h | 3 - clang/lib/AST/DataCollection.cpp | 1 + clang/lib/AST/Decl.cpp | 3 +- clang/lib/AST/DeclCXX.cpp | 17 +- clang/lib/AST/DeclPrinter.cpp | 2 + clang/lib/AST/Expr.cpp | 20 +- clang/lib/AST/ExprConstant.cpp | 151 +- clang/lib/AST/ItaniumMangle.cpp | 24 +- clang/lib/AST/Mangle.cpp | 8 +- clang/lib/AST/MicrosoftMangle.cpp | 2 +- clang/lib/AST/ODRHash.cpp | 2 - clang/lib/AST/OpenMPClause.cpp | 10 +- clang/lib/AST/StmtViz.cpp | 5 +- clang/lib/AST/TemplateName.cpp | 164 +- clang/lib/AST/TextNodeDumper.cpp | 12 - clang/lib/AST/Type.cpp | 10 +- clang/lib/AST/TypePrinter.cpp | 28 +- clang/lib/ASTMatchers/ASTMatchFinder.cpp | 5 +- clang/lib/ASTMatchers/Dynamic/Registry.cpp | 2 +- clang/lib/Analysis/CFG.cpp | 7 +- clang/lib/Analysis/ThreadSafety.cpp | 11 +- clang/lib/Analysis/UnsafeBufferUsage.cpp | 585 +- clang/lib/Basic/Diagnostic.cpp | 107 +- clang/lib/Basic/DiagnosticIDs.cpp | 301 +- clang/lib/Basic/FileManager.cpp | 11 - clang/lib/Basic/LangOptions.cpp | 2 - clang/lib/Basic/LangStandards.cpp | 3 +- clang/lib/Basic/Module.cpp | 1 + clang/lib/Basic/OpenMPKinds.cpp | 5 +- clang/lib/Basic/OperatorPrecedence.cpp | 1 + clang/lib/Basic/SourceManager.cpp | 23 +- clang/lib/Basic/Targets/AArch64.cpp | 8 +- clang/lib/Basic/Targets/BPF.cpp | 5 +- clang/lib/Basic/Targets/Mips.h | 2 +- clang/lib/Basic/Targets/PPC.cpp | 19 +- clang/lib/Basic/Targets/PPC.h | 2 - clang/lib/Basic/Targets/RISCV.cpp | 10 +- clang/lib/Basic/Targets/RISCV.h | 1 - clang/lib/Basic/Targets/SystemZ.h | 6 +- clang/lib/Basic/Targets/X86.cpp | 5 - clang/lib/CodeGen/BackendUtil.cpp | 40 +- clang/lib/CodeGen/CGBlocks.cpp | 5 +- clang/lib/CodeGen/CGBuilder.h | 6 +- clang/lib/CodeGen/CGBuiltin.cpp | 410 +- clang/lib/CodeGen/CGCUDANV.cpp | 19 +- clang/lib/CodeGen/CGCUDARuntime.cpp | 5 +- clang/lib/CodeGen/CGCUDARuntime.h | 8 +- clang/lib/CodeGen/CGCXXABI.h | 10 +- clang/lib/CodeGen/CGCall.cpp | 10 +- clang/lib/CodeGen/CGCall.h | 4 +- clang/lib/CodeGen/CGClass.cpp | 16 +- clang/lib/CodeGen/CGDebugInfo.cpp | 11 +- clang/lib/CodeGen/CGDeclCXX.cpp | 55 +- clang/lib/CodeGen/CGExpr.cpp | 55 +- clang/lib/CodeGen/CGExprCXX.cpp | 60 +- clang/lib/CodeGen/CGExprComplex.cpp | 29 +- clang/lib/CodeGen/CGExprScalar.cpp | 63 +- clang/lib/CodeGen/CGHLSLRuntime.cpp | 17 +- clang/lib/CodeGen/CGHLSLRuntime.h | 3 - clang/lib/CodeGen/CGObjCGNU.cpp | 11 +- clang/lib/CodeGen/CGOpenMPRuntime.cpp | 62 +- clang/lib/CodeGen/CGStmt.cpp | 4 +- clang/lib/CodeGen/CGStmtOpenMP.cpp | 26 - clang/lib/CodeGen/CMakeLists.txt | 2 - clang/lib/CodeGen/CodeGenAction.cpp | 11 +- clang/lib/CodeGen/CodeGenFunction.cpp | 134 +- clang/lib/CodeGen/CodeGenFunction.h | 86 +- clang/lib/CodeGen/CodeGenModule.cpp | 27 +- clang/lib/CodeGen/CodeGenPGO.cpp | 2 + clang/lib/CodeGen/CodeGenTypes.cpp | 84 +- clang/lib/CodeGen/CoverageMappingGen.cpp | 7 +- clang/lib/CodeGen/ItaniumCXXABI.cpp | 35 +- clang/lib/CodeGen/MacroPPCallbacks.cpp | 2 +- clang/lib/CodeGen/MicrosoftCXXABI.cpp | 18 +- clang/lib/CodeGen/SanitizerMetadata.cpp | 2 +- clang/lib/CodeGen/TargetInfo.h | 3 - clang/lib/CodeGen/Targets/AArch64.cpp | 8 +- clang/lib/CodeGen/Targets/ARM.cpp | 5 +- clang/lib/CodeGen/Targets/DirectX.cpp | 52 - clang/lib/CodeGen/Targets/RISCV.cpp | 56 +- clang/lib/CodeGen/Targets/SystemZ.cpp | 16 +- clang/lib/CodeGen/Targets/X86.cpp | 8 +- clang/lib/Driver/Driver.cpp | 21 +- clang/lib/Driver/Job.cpp | 1 + clang/lib/Driver/Multilib.cpp | 46 +- clang/lib/Driver/OffloadBundler.cpp | 12 +- clang/lib/Driver/SanitizerArgs.cpp | 14 +- clang/lib/Driver/ToolChain.cpp | 2 +- clang/lib/Driver/ToolChains/AIX.cpp | 3 +- clang/lib/Driver/ToolChains/AMDGPU.cpp | 38 +- clang/lib/Driver/ToolChains/AMDGPU.h | 6 - .../lib/Driver/ToolChains/Arch/LoongArch.cpp | 2 - clang/lib/Driver/ToolChains/Arch/Mips.cpp | 2 +- clang/lib/Driver/ToolChains/Arch/SystemZ.cpp | 5 +- clang/lib/Driver/ToolChains/Arch/SystemZ.h | 3 +- clang/lib/Driver/ToolChains/BareMetal.cpp | 9 +- clang/lib/Driver/ToolChains/Clang.cpp | 59 +- clang/lib/Driver/ToolChains/CommonArgs.cpp | 44 +- clang/lib/Driver/ToolChains/CommonArgs.h | 3 + clang/lib/Driver/ToolChains/Cuda.cpp | 3 +- clang/lib/Driver/ToolChains/Darwin.cpp | 36 +- clang/lib/Driver/ToolChains/DragonFly.cpp | 3 +- clang/lib/Driver/ToolChains/FreeBSD.cpp | 3 +- clang/lib/Driver/ToolChains/Fuchsia.cpp | 2 +- clang/lib/Driver/ToolChains/Gnu.cpp | 69 +- clang/lib/Driver/ToolChains/HIPAMD.cpp | 37 + clang/lib/Driver/ToolChains/HIPUtility.cpp | 1 + clang/lib/Driver/ToolChains/Haiku.cpp | 3 +- clang/lib/Driver/ToolChains/Linux.cpp | 3 - clang/lib/Driver/ToolChains/MSVC.cpp | 29 +- clang/lib/Driver/ToolChains/MinGW.cpp | 4 +- clang/lib/Driver/ToolChains/NetBSD.cpp | 3 +- clang/lib/Driver/ToolChains/OHOS.cpp | 7 +- clang/lib/Driver/ToolChains/OpenBSD.cpp | 3 +- clang/lib/Driver/ToolChains/PS4CPU.cpp | 99 +- clang/lib/Driver/ToolChains/PS4CPU.h | 7 +- clang/lib/Driver/ToolChains/Solaris.cpp | 3 +- clang/lib/Driver/ToolChains/WebAssembly.cpp | 1 - clang/lib/ExtractAPI/DeclarationFragments.cpp | 14 +- clang/lib/ExtractAPI/ExtractAPIConsumer.cpp | 2 +- clang/lib/Format/ContinuationIndenter.cpp | 17 +- clang/lib/Format/FormatTokenLexer.cpp | 7 - clang/lib/Format/MacroExpander.cpp | 5 +- .../ObjCPropertyAttributeOrderFixer.cpp | 7 +- clang/lib/Format/TokenAnnotator.cpp | 110 +- clang/lib/Format/TokenAnnotator.h | 8 +- clang/lib/Format/UnwrappedLineParser.cpp | 5 +- clang/lib/Frontend/ASTConsumers.cpp | 3 +- clang/lib/Frontend/ChainedIncludesSource.cpp | 2 +- clang/lib/Frontend/CompilerInstance.cpp | 4 +- clang/lib/Frontend/CompilerInvocation.cpp | 4 +- clang/lib/Frontend/FrontendActions.cpp | 16 +- clang/lib/Frontend/InitPreprocessor.cpp | 7 +- clang/lib/Frontend/LogDiagnosticPrinter.cpp | 4 +- clang/lib/Frontend/Rewrite/FixItRewriter.cpp | 4 +- .../Frontend/Rewrite/RewriteModernObjC.cpp | 162 +- clang/lib/Frontend/Rewrite/RewriteObjC.cpp | 12 +- .../Frontend/SerializedDiagnosticPrinter.cpp | 12 +- clang/lib/Frontend/TextDiagnosticPrinter.cpp | 12 +- clang/lib/Headers/CMakeLists.txt | 6 - clang/lib/Headers/altivec.h | 16 +- clang/lib/Headers/arm_acle.h | 39 +- clang/lib/Headers/avx10_2_512bf16intrin.h | 565 - clang/lib/Headers/avx10_2_512satcvtdsintrin.h | 303 - clang/lib/Headers/avx10_2bf16intrin.h | 1091 -- clang/lib/Headers/avx10_2copyintrin.h | 34 - clang/lib/Headers/avx10_2satcvtdsintrin.h | 496 - clang/lib/Headers/avx512bitalgintrin.h | 4 +- clang/lib/Headers/avx512vlbitalgintrin.h | 8 +- clang/lib/Headers/avx512vpopcntdqintrin.h | 4 +- clang/lib/Headers/avx512vpopcntdqvlintrin.h | 8 +- clang/lib/Headers/hexagon_types.h | 12 +- clang/lib/Headers/hlsl/hlsl_detail.h | 38 - clang/lib/Headers/hlsl/hlsl_intrinsics.h | 241 - clang/lib/Headers/immintrin.h | 5 - clang/lib/Headers/llvm_libc_wrappers/ctype.h | 38 - clang/lib/Headers/module.modulemap | 6 +- clang/lib/Headers/vecintrin.h | 44 +- clang/lib/Headers/wasm_simd128.h | 55 +- clang/lib/Lex/Lexer.cpp | 9 +- clang/lib/Parse/ParseDecl.cpp | 150 +- clang/lib/Parse/ParseDeclCXX.cpp | 13 +- clang/lib/Parse/ParseExpr.cpp | 4 + clang/lib/Parse/ParseExprCXX.cpp | 10 +- clang/lib/Parse/ParseStmt.cpp | 2 +- clang/lib/Parse/ParseTemplate.cpp | 2 +- clang/lib/Sema/AnalysisBasedWarnings.cpp | 23 +- clang/lib/Sema/CheckExprLifetime.cpp | 267 +- clang/lib/Sema/CheckExprLifetime.h | 1 - clang/lib/Sema/DeclSpec.cpp | 6 +- clang/lib/Sema/HLSLExternalSemaSource.cpp | 57 +- clang/lib/Sema/Sema.cpp | 28 +- clang/lib/Sema/SemaARM.cpp | 339 +- clang/lib/Sema/SemaAttr.cpp | 10 - clang/lib/Sema/SemaAvailability.cpp | 33 +- clang/lib/Sema/SemaBase.cpp | 2 +- clang/lib/Sema/SemaCUDA.cpp | 4 +- clang/lib/Sema/SemaCast.cpp | 7 +- clang/lib/Sema/SemaChecking.cpp | 60 +- clang/lib/Sema/SemaCodeComplete.cpp | 1 + clang/lib/Sema/SemaCoroutine.cpp | 38 +- clang/lib/Sema/SemaDecl.cpp | 65 +- clang/lib/Sema/SemaDeclAttr.cpp | 96 +- clang/lib/Sema/SemaDeclCXX.cpp | 29 +- clang/lib/Sema/SemaExpr.cpp | 100 +- clang/lib/Sema/SemaExprCXX.cpp | 57 +- clang/lib/Sema/SemaHLSL.cpp | 776 +- clang/lib/Sema/SemaInit.cpp | 25 +- clang/lib/Sema/SemaLambda.cpp | 1 + clang/lib/Sema/SemaLookup.cpp | 3 +- clang/lib/Sema/SemaModule.cpp | 8 - clang/lib/Sema/SemaOpenACC.cpp | 12 - clang/lib/Sema/SemaOpenMP.cpp | 320 +- clang/lib/Sema/SemaOverload.cpp | 114 +- clang/lib/Sema/SemaRISCV.cpp | 13 +- clang/lib/Sema/SemaTemplate.cpp | 122 +- clang/lib/Sema/SemaTemplateDeduction.cpp | 487 +- clang/lib/Sema/SemaTemplateInstantiate.cpp | 4 - .../lib/Sema/SemaTemplateInstantiateDecl.cpp | 42 +- clang/lib/Sema/SemaTemplateVariadic.cpp | 38 +- clang/lib/Sema/SemaType.cpp | 33 +- clang/lib/Sema/SemaX86.cpp | 35 - clang/lib/Sema/TreeTransform.h | 61 +- clang/lib/Serialization/ASTReader.cpp | 17 +- clang/lib/Serialization/ASTWriter.cpp | 2 +- .../Checkers/CStringChecker.cpp | 13 +- .../StaticAnalyzer/Checkers/MallocChecker.cpp | 470 +- .../StaticAnalyzer/Checkers/MoveChecker.cpp | 1 - .../Checkers/OSObjectCStyleCast.cpp | 2 +- .../Checkers/ObjCSuperDeallocChecker.cpp | 2 +- .../Checkers/PointerIterationChecker.cpp | 2 +- .../RetainCountDiagnostics.cpp | 5 +- .../Checkers/SmartPtrModeling.cpp | 4 +- .../Checkers/StackAddrEscapeChecker.cpp | 8 +- .../Checkers/StdVariantChecker.cpp | 4 +- .../StaticAnalyzer/Checkers/StreamChecker.cpp | 52 +- .../Checkers/VLASizeChecker.cpp | 3 +- .../Checkers/WebKit/ASTUtils.cpp | 15 +- .../Checkers/WebKit/PtrTypesSemantics.cpp | 24 +- .../Checkers/WebKit/PtrTypesSemantics.h | 9 +- .../WebKit/RefCntblBaseVirtualDtorChecker.cpp | 33 - .../WebKit/UncountedCallArgsChecker.cpp | 3 +- .../StaticAnalyzer/Core/BasicValueFactory.cpp | 2 +- clang/lib/StaticAnalyzer/Core/BugReporter.cpp | 18 +- .../Core/BugReporterVisitors.cpp | 89 + .../StaticAnalyzer/Core/CheckerManager.cpp | 11 + .../lib/StaticAnalyzer/Core/DynamicExtent.cpp | 2 +- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | 14 +- .../Core/ExprEngineCallAndReturn.cpp | 3 +- .../StaticAnalyzer/Core/HTMLDiagnostics.cpp | 7 +- .../lib/StaticAnalyzer/Core/LoopUnrolling.cpp | 6 +- .../StaticAnalyzer/Core/PlistDiagnostics.cpp | 1 + .../Core/RangeConstraintManager.cpp | 4 +- clang/lib/StaticAnalyzer/Core/RegionStore.cpp | 8 +- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp | 22 +- clang/lib/StaticAnalyzer/Core/SVals.cpp | 17 - .../StaticAnalyzer/Core/TextDiagnostics.cpp | 1 + .../Frontend/CreateCheckerManager.cpp | 1 + clang/lib/Tooling/CMakeLists.txt | 1 - clang/lib/Tooling/CommonOptionsParser.cpp | 1 + clang/lib/Tooling/Core/Replacement.cpp | 1 + .../DependencyScanningService.cpp | 4 +- .../DependencyScanningWorker.cpp | 7 +- .../DependencyScanning/ModuleDepCollector.cpp | 11 +- .../Tooling/LocateToolCompilationDatabase.cpp | 71 - .../lib/Tooling/Refactoring/AtomicChange.cpp | 1 + clang/lib/Tooling/Transformer/Stencil.cpp | 9 +- clang/test/AST/ByteCode/builtin-functions.cpp | 36 +- clang/test/AST/ByteCode/codegen.c | 7 - clang/test/AST/ByteCode/codegen.cpp | 18 - clang/test/AST/ByteCode/const-base-cast.cpp | 19 - .../AST/ByteCode/constexpr-frame-describe.cpp | 4 +- clang/test/AST/ByteCode/constexpr-vectors.cpp | 302 +- clang/test/AST/ByteCode/cxx11.cpp | 5 - clang/test/AST/ByteCode/cxx20.cpp | 2 +- clang/test/AST/ByteCode/cxx2a.cpp | 76 - clang/test/AST/ByteCode/extern.cpp | 13 - clang/test/AST/ByteCode/hlsl.hlsl | 16 +- clang/test/AST/ByteCode/initializer_list.cpp | 71 - clang/test/AST/ByteCode/invalid.cpp | 3 - clang/test/AST/ByteCode/literals.cpp | 8 +- clang/test/AST/ByteCode/ms.cpp | 15 +- clang/test/AST/ByteCode/new-delete.cpp | 147 - clang/test/AST/ByteCode/references.cpp | 12 +- clang/test/AST/ByteCode/shifts.cpp | 1 - clang/test/AST/ByteCode/weak.cpp | 8 - clang/test/AST/HLSL/RWBuffer-AST.hlsl | 23 +- clang/test/AST/HLSL/StructuredBuffer-AST.hlsl | 78 - clang/test/AST/HLSL/vector-constructors.hlsl | 3 +- clang/test/AST/ast-dump-concepts.cpp | 19 +- clang/test/AST/ast-dump-default-init-json.cpp | 6 +- clang/test/AST/ast-dump-default-init.cpp | 2 +- .../ref-cntbl-crtp-base-no-virtual-dtor.cpp | 250 - .../Checkers/WebKit/uncounted-obj-arg.cpp | 11 - .../Checkers/WebKit/uncounted-obj-arg.mm | 43 - clang/test/Analysis/NewDelete-atomics.cpp | 46 - .../test/Analysis/NewDelete-checker-test.cpp | 17 + .../test/Analysis/NewDelete-intersections.mm | 4 +- clang/test/Analysis/asm.cpp | 12 - .../test/Analysis/cstring-uninitread-notes.c | 25 - clang/test/Analysis/ctor-array.cpp | 66 +- clang/test/Analysis/embed.c | 12 - clang/test/Analysis/fread.c | 30 - .../Analysis/lifetime-extended-regions.cpp | 9 +- clang/test/Analysis/malloc-interprocedural.c | 35 + clang/test/Analysis/malloc-refcounted.c | 80 - clang/test/Analysis/mmap-writeexec.c | 4 +- clang/test/Analysis/nullability-nocrash.c | 13 - clang/test/Analysis/nullptr.cpp | 16 - clang/test/Analysis/stack-addr-ps.cpp | 57 +- clang/test/Analysis/stream-error.c | 22 +- clang/test/Analysis/stream-note.c | 9 - clang/test/Analysis/stream.c | 10 +- clang/test/Analysis/z3-unarysymexpr.c | 15 - clang/test/C/C23/n3029.c | 65 - clang/test/C/C23/n3030.c | 93 - clang/test/CMakeLists.txt | 1 + clang/test/CXX/drs/cwg14xx.cpp | 22 - clang/test/CXX/drs/cwg16xx.cpp | 23 +- clang/test/CXX/drs/cwg1818.cpp | 34 - clang/test/CXX/drs/cwg18xx.cpp | 21 +- clang/test/CXX/drs/cwg19xx.cpp | 12 - clang/test/CXX/drs/cwg1xx.cpp | 74 - clang/test/CXX/drs/cwg24xx.cpp | 43 +- clang/test/CXX/drs/cwg27xx.cpp | 48 +- clang/test/CXX/drs/cwg29xx.cpp | 8 - clang/test/CXX/drs/cwg3xx.cpp | 72 - clang/test/CXX/drs/cwg563.cpp | 16 - clang/test/CXX/drs/cwg5xx.cpp | 1 - clang/test/CXX/expr/expr.const/p2-0x.cpp | 11 +- clang/test/CXX/module/module.import/p2.cpp | 3 +- clang/test/CXX/special/class.temporary/p6.cpp | 34 - clang/test/ClangScanDeps/implicit-target.c | 31 - .../ClangScanDeps/modules-extern-submodule.c | 3 +- .../modules-full-output-tu-order.c | 6 +- .../modules-has-include-umbrella-header.c | 3 +- .../ClangScanDeps/modules-header-sharing.m | 3 +- .../modules-implementation-module-map.c | 3 +- .../modules-implementation-private.m | 3 +- .../ClangScanDeps/modules-priv-fw-from-pub.m | 3 +- .../ClangScanDeps/resolve-executable-path.c | 32 - clang/test/ClangScanDeps/verbose.test | 28 - clang/test/CodeGen/2005-01-02-ConstantInits.c | 4 +- .../test/CodeGen/AMDGPU/amdgpu-atomic-float.c | 112 +- .../PowerPC/builtins-ppc-build-pair-mma.c | 68 - .../PowerPC/builtins-ppc-pair-mma-types.c | 204 +- clang/test/CodeGen/PowerPC/ppc-emmintrin.c | 12 +- clang/test/CodeGen/PowerPC/ppc-xmmintrin.c | 16 +- .../test/CodeGen/PowerPC/transparent_union.c | 67 + .../CodeGen/SystemZ/builtins-systemz-i128.c | 165 - .../CodeGen/SystemZ/builtins-systemz-vector.c | 9 + .../test/CodeGen/SystemZ/systemz-abi-vector.c | 10 +- clang/test/CodeGen/SystemZ/systemz-abi.c | 12 +- clang/test/CodeGen/SystemZ/systemz-abi.cpp | 10 +- .../CodeGen/X86/avx10_2_512bf16-builtins.c | 1085 -- .../X86/avx10_2_512satcvtds-builtins-errors.c | 52 - .../avx10_2_512satcvtds-builtins-x64-error.c | 76 - .../X86/avx10_2_512satcvtds-builtins-x64.c | 184 - .../X86/avx10_2_512satcvtds-builtins.c | 151 - clang/test/CodeGen/X86/avx10_2bf16-builtins.c | 2082 --- .../X86/avx10_2satcvtds-builtins-errors.c | 57 - .../X86/avx10_2satcvtds-builtins-x64.c | 262 - .../CodeGen/X86/avx10_2satcvtds-builtins.c | 225 - .../test/CodeGen/X86/avx512bitalg-builtins.c | 8 +- clang/test/CodeGen/X86/avx512copy-builtins.c | 17 - .../CodeGen/X86/avx512vlbitalg-builtins.c | 16 +- .../CodeGen/X86/avx512vpopcntdq-builtins.c | 8 +- .../CodeGen/X86/avx512vpopcntdqvl-builtins.c | 16 +- .../test/CodeGen/X86/bfloat16-convert-half.c | 25 - clang/test/CodeGen/X86/x86-atomic-double.c | 88 +- .../test/CodeGen/X86/x86-atomic-long_double.c | 293 +- .../aarch64-neon-faminmax-intrinsics.c | 107 - clang/test/CodeGen/aarch64-neon-luti.c | 507 - .../aarch64-sme2-intrinsics/acle_sme2_add.c | 328 +- .../acle_sme2_add_sub_za16.c | 112 +- .../aarch64-sme2-intrinsics/acle_sme2_clamp.c | 1056 +- .../aarch64-sme2-intrinsics/acle_sme2_cvt.c | 518 +- .../aarch64-sme2-intrinsics/acle_sme2_cvtl.c | 10 +- .../aarch64-sme2-intrinsics/acle_sme2_cvtn.c | 120 +- .../acle_sme2_faminmax.c | 404 - .../acle_sme2_fmlas16.c | 384 +- .../acle_sme2_fp_dots.c | 144 +- .../aarch64-sme2-intrinsics/acle_sme2_frint.c | 352 +- .../acle_sme2_int_dots.c | 576 +- .../acle_sme2_luti2_lane_zt_x2.c | 90 +- .../acle_sme2_luti2_lane_zt_x4.c | 90 +- .../acle_sme2_luti4_lane_zt_x2.c | 90 +- .../acle_sme2_luti4_lane_zt_x4.c | 98 +- .../aarch64-sme2-intrinsics/acle_sme2_max.c | 2256 ++-- .../aarch64-sme2-intrinsics/acle_sme2_maxnm.c | 752 +- .../aarch64-sme2-intrinsics/acle_sme2_min.c | 2256 ++-- .../aarch64-sme2-intrinsics/acle_sme2_minnm.c | 752 +- .../aarch64-sme2-intrinsics/acle_sme2_mla.c | 144 +- .../aarch64-sme2-intrinsics/acle_sme2_mlal.c | 288 +- .../aarch64-sme2-intrinsics/acle_sme2_mlall.c | 720 +- .../aarch64-sme2-intrinsics/acle_sme2_mls.c | 144 +- .../aarch64-sme2-intrinsics/acle_sme2_mlsl.c | 288 +- .../aarch64-sme2-intrinsics/acle_sme2_read.c | 721 +- .../acle_sme2_sqdmulh.c | 752 +- .../aarch64-sme2-intrinsics/acle_sme2_sub.c | 328 +- .../acle_sme2_unpkx2.c | 60 +- .../acle_sme2_unpkx4.c | 300 +- .../aarch64-sme2-intrinsics/acle_sme2_vdot.c | 104 +- .../acle_sme2_vector_add.c | 704 +- .../acle_sme2_vector_qrshr.c | 228 +- .../acle_sme2_vector_rshl.c | 1504 ++- .../acle_sme2_vector_selx2.c | 456 +- .../acle_sme2_vector_selx4.c | 744 +- .../acle_sme2_vector_uzpx2.c | 816 +- .../acle_sme2_vector_uzpx4.c | 1296 +- .../acle_sme2_vector_zipx2.c | 816 +- .../acle_sme2_vector_zipx4.c | 1296 +- .../aarch64-sme2-intrinsics/acle_sme2_write.c | 720 +- .../acle_sme2p1_movaz.c | 1016 +- .../acle_sve_create2-bfloat.c | 12 +- .../aarch64-sve-intrinsics/acle_sve_create2.c | 132 +- .../acle_sve_create3-bfloat.c | 16 +- .../aarch64-sve-intrinsics/acle_sve_create3.c | 176 +- .../acle_sve_create4-bfloat.c | 20 +- .../aarch64-sve-intrinsics/acle_sve_create4.c | 220 +- .../acle_sve_get2-bfloat.c | 24 +- .../aarch64-sve-intrinsics/acle_sve_get2.c | 132 +- .../acle_sve_get3-bfloat.c | 42 +- .../aarch64-sve-intrinsics/acle_sve_get3.c | 154 +- .../acle_sve_get4-bfloat.c | 64 +- .../aarch64-sve-intrinsics/acle_sve_get4.c | 176 +- .../acle_sve_ld2-bfloat.c | 24 +- .../aarch64-sve-intrinsics/acle_sve_ld2.c | 264 +- .../acle_sve_ld3-bfloat.c | 32 +- .../aarch64-sve-intrinsics/acle_sve_ld3.c | 352 +- .../acle_sve_ld4-bfloat.c | 40 +- .../aarch64-sve-intrinsics/acle_sve_ld4.c | 440 +- .../acle_sve_reinterpret-bfloat.c | 2046 +-- .../acle_sve_reinterpret.c | 10437 ++------------ .../acle_sve_set2-bfloat.c | 24 +- .../aarch64-sve-intrinsics/acle_sve_set2.c | 132 +- .../acle_sve_set3-bfloat.c | 42 +- .../aarch64-sve-intrinsics/acle_sve_set3.c | 154 +- .../acle_sve_set4-bfloat.c | 64 +- .../aarch64-sve-intrinsics/acle_sve_set4.c | 176 +- .../acle_sve_st2-bfloat.c | 44 +- .../aarch64-sve-intrinsics/acle_sve_st2.c | 468 +- .../acle_sve_st3-bfloat.c | 56 +- .../aarch64-sve-intrinsics/acle_sve_st3.c | 600 +- .../acle_sve_st4-bfloat.c | 68 +- .../aarch64-sve-intrinsics/acle_sve_st4.c | 732 +- .../acle_sve_undef2-bfloat.c | 4 +- .../aarch64-sve-intrinsics/acle_sve_undef2.c | 44 +- .../acle_sve_undef3-bfloat.c | 4 +- .../aarch64-sve-intrinsics/acle_sve_undef3.c | 44 +- .../acle_sve_undef4-bfloat.c | 4 +- .../aarch64-sve-intrinsics/acle_sve_undef4.c | 44 +- .../acle_sve2_faminmax.c | 775 -- .../aarch64-sve2-intrinsics/acle_sve2_luti.c | 321 - .../acle_sve2_tbl2-bfloat.c | 12 +- .../aarch64-sve2-intrinsics/acle_sve2_tbl2.c | 132 +- .../acle_sve2p1_create2_bool.c | 12 +- .../acle_sve2p1_create4_bool.c | 20 +- .../acle_sve2p1_get2_bool.c | 24 +- .../acle_sve2p1_get4_bool.c | 48 +- .../acle_sve2p1_ld1.c | 704 +- .../acle_sve2p1_ldnt1.c | 704 +- .../acle_sve2p1_loads.c | 1132 +- .../acle_sve2p1_pext.c | 80 +- .../acle_sve2p1_qcvtn.c | 36 +- .../acle_sve2p1_qrshr.c | 36 +- .../acle_sve2p1_set2_bool.c | 24 +- .../acle_sve2p1_set4_bool.c | 48 +- .../acle_sve2p1_st1.c | 792 +- .../acle_sve2p1_stnt1.c | 792 +- .../acle_sve2p1_store.c | 1536 ++- .../acle_sve2p1_undef_bool.c | 22 +- .../acle_sve2p1_while_x2.c | 448 +- .../acle_neon_sve_bridge_get_neonq.c | 2 +- clang/test/CodeGen/arm-neon-range-checks.c | 426 + clang/test/CodeGen/arm_acle.c | 76 +- clang/test/CodeGen/attr-counted-by.c | 56 +- .../attr-target-clones-riscv-invalid.c | 8 - clang/test/CodeGen/attr-target-clones-riscv.c | 441 - .../test/CodeGen/builtins-elementwise-math.c | 37 - clang/test/CodeGen/builtins-wasm.c | 120 +- ...d-nonzero-offset-when-nullptr-is-defined.c | 2 +- .../catch-nullptr-and-nonzero-offset.c | 64 +- .../CodeGen/catch-pointer-overflow-volatile.c | 2 +- clang/test/CodeGen/catch-pointer-overflow.c | 6 +- .../CodeGen/debug-info-codeview-buildinfo.c | 4 +- clang/test/CodeGen/ext-int.c | 2 +- .../test/CodeGen/hexagon-brev-ld-ptr-incdec.c | 6 +- clang/test/CodeGen/integer-overflow.c | 6 +- clang/test/CodeGen/ms-intrinsics.c | 12 +- .../test/CodeGen/pgo-force-function-attrs.ll | 6 +- clang/test/CodeGen/ptrauth-init-fini.c | 20 +- clang/test/CodeGen/svboolx2_t.cpp | 37 +- clang/test/CodeGen/svboolx4_t.cpp | 43 +- clang/test/CodeGen/target-builtin-noerror.c | 1 - clang/test/CodeGen/transparent-union-type.c | 108 - clang/test/CodeGen/ubsan-pointer-overflow.m | 2 +- clang/test/CodeGen/vla.c | 2 +- clang/test/CodeGenCUDA/device-stub.cu | 2 +- .../CodeGenCXX/aarch64-mangle-sve-vectors.cpp | 1064 +- .../CodeGenCXX/aarch64-sve-vector-init.cpp | 836 +- .../attr-likelihood-iteration-stmt.cpp | 36 +- .../CodeGenCXX/attr-target-clones-riscv.cpp | 439 - clang/test/CodeGenCXX/const-base-cast.cpp | 2 +- .../CodeGenCXX/debug-info-lambda-this.cpp | 3 +- clang/test/CodeGenCXX/for-range.cpp | 12 +- .../microsoft-abi-template-static-init.cpp | 5 +- .../CodeGenCXX/pr45964-decomp-transform.cpp | 2 +- clang/test/CodeGenCXX/vla.cpp | 4 +- .../vtable-available-externally.cpp | 25 +- clang/test/CodeGenCoroutines/Inputs/utility.h | 13 - .../CodeGenCoroutines/coro-await-elidable.cpp | 127 - .../BasicFeatures/OutputArguments.hlsl | 2 +- .../standard_conversion_sequences.hlsl | 24 - .../GlobalConstructorFunction.hlsl | 31 +- .../CodeGenHLSL/GlobalConstructorLib.hlsl | 23 +- clang/test/CodeGenHLSL/GlobalDestructors.hlsl | 51 +- .../CodeGenHLSL/buffer-array-operator.hlsl | 4 +- .../builtins/RWBuffer-constructor.hlsl | 1 - .../builtins/RWBuffer-subscript.hlsl | 5 +- .../StructuredBuffer-annotations.hlsl | 22 - .../StructuredBuffer-constructor.hlsl | 12 - .../StructuredBuffer-elementtype.hlsl | 52 - .../builtins/StructuredBuffer-subscript.hlsl | 17 - clang/test/CodeGenHLSL/builtins/asfloat.hlsl | 40 - clang/test/CodeGenHLSL/builtins/asuint.hlsl | 41 - .../test/CodeGenHLSL/builtins/countbits.hlsl | 80 - clang/test/CodeGenHLSL/builtins/dot.hlsl | 12 + .../CodeGenHLSL/builtins/hlsl_resource_t.hlsl | 9 - clang/test/CodeGenHLSL/builtins/lerp.hlsl | 18 + clang/test/CodeGenHLSL/builtins/mad.hlsl | 18 + clang/test/CodeGenHLSL/builtins/select.hlsl | 54 - clang/test/CodeGenHLSL/builtins/sign.hlsl | 157 - clang/test/CodeGenHLSL/builtins/step.hlsl | 84 - .../builtins/wave_is_first_lane.hlsl | 34 - .../CodeGenHLSL/convergence/cf.for.plain.hlsl | 44 - .../test/CodeGenHLSL/inline-constructors.hlsl | 76 - clang/test/CodeGenHLSL/inline-functions.hlsl | 116 - clang/test/CodeGenHLSL/loops/unroll.hlsl | 46 +- clang/test/CodeGenHLSL/this-assignment.hlsl | 30 +- clang/test/CodeGenHLSL/wavesize.hlsl | 34 - clang/test/CodeGenObjC/boxing.m | 1 - clang/test/CodeGenObjC/dllstorage.m | 4 +- .../atomics-cas-remarks-gfx90a.cl | 7 +- .../atomics-unsafe-hw-remarks-gfx90a.cl | 5 +- .../builtins-amdgcn-gfx12-param-err.cl | 5 - .../CodeGenOpenCL/builtins-amdgcn-gfx12.cl | 43 - .../CodeGenSYCL/address-space-deduction.cpp | 48 +- clang/test/CodeGenSYCL/address-space-new.cpp | 2 +- .../CodeGenSYCL/kernel-param-acc-array.cpp | 4 +- .../kernel-param-member-acc-array.cpp | 4 +- .../CodeGenSYCL/kernel-param-pod-array.cpp | 8 +- clang/test/Driver/Ofast.c | 18 +- .../baremetal-multilib-custom-error.yaml | 63 - clang/test/Driver/cl-link.c | 14 +- clang/test/Driver/clang_f_opts.c | 10 +- clang/test/Driver/codegen-data.c | 38 - clang/test/Driver/debug-options-as.c | 17 +- .../test/Driver/fmodules-embed-all-files.cpp | 5 - clang/test/Driver/fsanitize.c | 4 +- clang/test/Driver/fuchsia.c | 2 +- clang/test/Driver/hip-cuid.hip | 40 - clang/test/Driver/mcmodel.c | 1 + clang/test/Driver/openmp-offload-gpu.c | 2 +- clang/test/Driver/ps4-linker.c | 9 - clang/test/Driver/ps4-ps5-header-search.c | 4 +- clang/test/Driver/ps4-ps5-toolchain.c | 5 - clang/test/Driver/ps4-sdk-root.c | 105 +- clang/test/Driver/ps5-linker.c | 9 - clang/test/Driver/ps5-sdk-root.c | 105 +- clang/test/Driver/riscv-cpus.c | 26 - clang/test/Driver/riscv-mcmodel.c | 23 - clang/test/Driver/windows-cross.c | 2 +- clang/test/Driver/x86-march.c | 4 - clang/test/ExtractAPI/attributed-typedef.m | 24 - .../FixIt/fixit-availability-maccatalyst.m | 7 +- clang/test/FixIt/fixit-availability.mm | 3 +- clang/test/Frontend/x86-target-cpu.c | 1 - clang/test/Headers/__clang_hip_math.hip | 70 +- clang/test/Interpreter/multiline.cpp | 11 +- clang/test/Lexer/cxx-features.cpp | 2 +- .../Lexer/has_feature_realtime_sanitizer.cpp | 12 - ...a-attribute-supported-attributes-list.test | 4 +- clang/test/Misc/print-stats-vfs.test | 17 - .../test/Misc/target-invalid-cpu-note/riscv.c | 2 - clang/test/Misc/target-invalid-cpu-note/x86.c | 4 - clang/test/Misc/warning-flags.c | 5 +- clang/test/Modules/cxx20-10-3-ex1.cpp | 1 - .../Modules/no-local-decl-in-reduced-bmi.cppm | 8 +- clang/test/Modules/pr107673.cppm | 12 - clang/test/Modules/pr108732.cppm | 14 - .../reduced-bmi-empty-module-purview-std.cppm | 4 +- .../reduced-bmi-empty-module-purview.cppm | 6 +- .../Modules/unreached-static-entities.cppm | 7 +- clang/test/OpenMP/bug57757.cpp | 4 +- clang/test/OpenMP/bug60602.cpp | 8 +- clang/test/OpenMP/declare_mapper_codegen.cpp | 4 +- clang/test/OpenMP/distribute_codegen.cpp | 32 +- ...te_parallel_for_reduction_task_codegen.cpp | 24 +- clang/test/OpenMP/distribute_simd_codegen.cpp | 96 +- clang/test/OpenMP/error_unsupport_feature.c | 8 + clang/test/OpenMP/for_linear_codegen.cpp | 2 +- clang/test/OpenMP/for_reduction_codegen.cpp | 64 +- .../test/OpenMP/for_reduction_codegen_UDR.cpp | 32 +- .../OpenMP/for_reduction_task_codegen.cpp | 24 +- clang/test/OpenMP/for_scan_codegen.cpp | 40 +- clang/test/OpenMP/for_simd_scan_codegen.cpp | 40 +- clang/test/OpenMP/irbuilder_for_iterator.cpp | 6 +- clang/test/OpenMP/irbuilder_for_rangefor.cpp | 6 +- clang/test/OpenMP/irbuilder_for_unsigned.c | 8 +- .../test/OpenMP/irbuilder_for_unsigned_auto.c | 8 +- .../test/OpenMP/irbuilder_for_unsigned_down.c | 2 +- .../OpenMP/irbuilder_for_unsigned_dynamic.c | 8 +- .../irbuilder_for_unsigned_dynamic_chunked.c | 8 +- .../OpenMP/irbuilder_for_unsigned_runtime.c | 8 +- .../irbuilder_for_unsigned_static_chunked.c | 8 +- clang/test/OpenMP/map_struct_ordering.cpp | 2 +- .../master_taskloop_in_reduction_codegen.cpp | 10 +- .../master_taskloop_reduction_codegen.cpp | 12 +- ...ter_taskloop_simd_in_reduction_codegen.cpp | 10 +- ...master_taskloop_simd_reduction_codegen.cpp | 12 +- clang/test/OpenMP/ordered_codegen.cpp | 80 +- clang/test/OpenMP/parallel_for_codegen.cpp | 144 +- .../OpenMP/parallel_for_linear_codegen.cpp | 2 +- .../parallel_for_reduction_task_codegen.cpp | 24 +- .../test/OpenMP/parallel_for_scan_codegen.cpp | 44 +- .../OpenMP/parallel_for_simd_scan_codegen.cpp | 40 +- ...parallel_master_reduction_task_codegen.cpp | 24 +- ...llel_master_taskloop_reduction_codegen.cpp | 12 +- ...master_taskloop_simd_reduction_codegen.cpp | 12 +- .../OpenMP/parallel_reduction_codegen.cpp | 12 +- .../parallel_reduction_task_codegen.cpp | 24 +- ...rallel_sections_reduction_task_codegen.cpp | 24 +- clang/test/OpenMP/reduction_implicit_map.cpp | 50 +- clang/test/OpenMP/scope_codegen.cpp | 2267 ---- .../sections_reduction_task_codegen.cpp | 24 +- .../target_data_use_device_addr_codegen.cpp | 10 +- .../target_data_use_device_ptr_codegen.cpp | 82 +- .../OpenMP/target_has_device_addr_codegen.cpp | 24 +- .../OpenMP/target_in_reduction_codegen.cpp | 10 +- .../OpenMP/target_is_device_ptr_codegen.cpp | 208 +- ...arget_map_both_pointer_pointee_codegen.cpp | 2 +- clang/test/OpenMP/target_map_codegen_01.cpp | 2 +- clang/test/OpenMP/target_map_codegen_21.cpp | 6 +- clang/test/OpenMP/target_map_codegen_27.cpp | 2 +- clang/test/OpenMP/target_map_codegen_28.cpp | 6 +- clang/test/OpenMP/target_map_codegen_29.cpp | 4 +- .../OpenMP/target_map_deref_array_codegen.cpp | 2 +- ..._map_member_expr_array_section_codegen.cpp | 8 +- .../OpenMP/target_map_member_expr_codegen.cpp | 6 +- ...target_map_nest_defalut_mapper_codegen.cpp | 2 +- ...et_parallel_for_reduction_task_codegen.cpp | 24 +- ...target_parallel_reduction_task_codegen.cpp | 24 +- .../OpenMP/target_task_affinity_codegen.cpp | 24 +- ...te_parallel_for_reduction_task_codegen.cpp | 44 +- clang/test/OpenMP/target_update_codegen.cpp | 34 +- clang/test/OpenMP/task_codegen.c | 2 +- clang/test/OpenMP/task_codegen.cpp | 248 +- .../test/OpenMP/task_in_reduction_codegen.cpp | 10 +- .../taskgroup_task_reduction_codegen.cpp | 10 +- .../OpenMP/taskloop_in_reduction_codegen.cpp | 10 +- .../OpenMP/taskloop_reduction_codegen.cpp | 12 +- .../taskloop_simd_in_reduction_codegen.cpp | 10 +- .../taskloop_simd_reduction_codegen.cpp | 12 +- ...te_parallel_for_reduction_task_codegen.cpp | 44 +- clang/test/PCH/race-condition.cpp | 41 - .../cxx-bad-cast-diagnose-broken-template.cpp | 26 - .../Parser/cxx11-user-defined-literals.cpp | 3 +- ...xx1z-class-template-argument-deduction.cpp | 12 - clang/test/Parser/static_assert.cpp | 6 - clang/test/ParserHLSL/group_shared.hlsl | 10 +- clang/test/ParserHLSL/group_shared_202x.hlsl | 28 +- .../ParserHLSL/hlsl_contained_type_attr.hlsl | 28 - .../hlsl_contained_type_attr_error.hlsl | 24 - clang/test/ParserHLSL/hlsl_is_rov_attr.hlsl | 26 +- .../ParserHLSL/hlsl_is_rov_attr_error.hlsl | 21 +- .../test/ParserHLSL/hlsl_raw_buffer_attr.hlsl | 25 - .../hlsl_raw_buffer_attr_error.hlsl | 13 - .../ParserHLSL/hlsl_resource_class_attr.hlsl | 58 +- .../hlsl_resource_class_attr_error.hlsl | 27 +- .../hlsl_resource_handle_attrs.hlsl | 24 +- clang/test/ParserHLSL/invalid_inside_cb.hlsl | 5 +- .../Preprocessor/aarch64-target-features.c | 1 + .../test/Preprocessor/bpf-predefined-macros.c | 4 +- clang/test/Preprocessor/init-aarch64.c | 15 +- clang/test/Preprocessor/init-ppc.c | 18 - clang/test/Preprocessor/init-ppc64.c | 18 - .../Preprocessor/predefined-arch-macros.c | 158 - .../Preprocessor/predefined-macros-hlsl.hlsl | 7 +- clang/test/Preprocessor/riscv-cmodel.c | 9 - clang/test/Sema/aarch64-neon-bf16-ranges.c | 49 + .../Sema/aarch64-neon-faminmax-no-faminmax.c | 35 - .../test/Sema/aarch64-neon-faminmax-no-neon.c | 34 - clang/test/Sema/aarch64-neon-fp16-ranges.c | 66 + .../aarch64-neon-immediate-ranges/bfloat16.c | 237 - .../conversions.c | 144 - .../copy-vector-lane.c | 498 - .../aarch64-neon-immediate-ranges/dotprod.c | 50 - .../extract-elt-from-vector.c | 301 - .../extract-vector-from-vectors.c | 170 - .../fp16-scalar.c | 79 - .../aarch64-neon-immediate-ranges/fp16-v84.c | 89 - .../fp16-vector.c | 181 - .../fused-multiply-accumulate.c | 126 - .../Sema/aarch64-neon-immediate-ranges/luti.c | 283 - .../matrix-multiplication.c | 50 - .../multiply-extended.c | 69 - .../saturating-multiply-accumulate.c | 132 - .../saturating-multiply-by-scalar-and-widen.c | 193 - .../set-lanes-to-value.c | 297 - .../set-vector-lane.c | 162 - .../sqrdmlah-ranges.c | 130 - .../aarch64-neon-immediate-ranges/vcmla.c | 203 - .../vector-load.c | 692 - .../vector-multiply-accumulate-by-scalar.c | 200 - .../vector-multiply-by-scalar-and-widen.c | 98 - .../vector-multiply-by-scalar.c | 160 - .../vector-multiply-subtract-by-scalar.c | 201 - .../vector-shift-left.c | 542 - .../vector-shift-right.c | 1083 -- .../vector-store.c | 620 - clang/test/Sema/aarch64-neon-ranges.c | 220 + .../acle_sve2_imm_lane.cpp | 32 - clang/test/Sema/attr-btf_type_tag.cpp | 11 - clang/test/Sema/attr-target-riscv.c | 12 - clang/test/Sema/builtin-unary-fp.c | 4 - clang/test/Sema/builtins-elementwise-math.c | 37 +- clang/test/Sema/complex-arithmetic.c | 9 +- clang/test/Sema/countbits-errors.hlsl | 28 - clang/test/Sema/diagnose_if.c | 8 +- clang/test/Sema/enum.c | 59 +- clang/test/Sema/fixed-enum.c | 25 +- clang/test/Sema/pre-c2x-compat.c | 1 - clang/test/Sema/static-assert.c | 8 +- .../Sema/warn-lifetime-analysis-nocfg.cpp | 88 - clang/test/SemaCXX/PR97308.cpp | 21 - clang/test/SemaCXX/attr-lifetimebound.cpp | 20 - .../test/SemaCXX/attr-target-clones-riscv.cpp | 47 - .../SemaCXX/builtin-is-within-lifetime.cpp | 431 - .../SemaCXX/builtins-elementwise-math.cpp | 8 - clang/test/SemaCXX/builtins.cpp | 18 +- clang/test/SemaCXX/consteval-builtin.cpp | 93 - clang/test/SemaCXX/constexpr-default-arg.cpp | 4 +- .../cxx11-default-member-initializers.cpp | 97 - clang/test/SemaCXX/cxx20-default-compare.cpp | 50 - clang/test/SemaCXX/cxx23-assume.cpp | 9 - clang/test/SemaCXX/cxx2a-consteval.cpp | 24 - clang/test/SemaCXX/cxx2a-template-lambdas.cpp | 34 - clang/test/SemaCXX/cxx2c-pack-indexing.cpp | 12 - clang/test/SemaCXX/cxx2c-placeholder-vars.cpp | 6 +- .../SemaCXX/diagnose_if-warning-group.cpp | 63 - clang/test/SemaCXX/eval-crashes.cpp | 6 +- clang/test/SemaCXX/extern-c.cpp | 19 - clang/test/SemaCXX/lambda-pack-expansion.cpp | 26 - clang/test/SemaCXX/pr61460.cpp | 13 + clang/test/SemaCXX/source_location.cpp | 83 - clang/test/SemaCXX/static-assert-ext.cpp | 28 - clang/test/SemaCXX/sugar-common-types.cpp | 7 + clang/test/SemaCXX/type-traits.cpp | 19 +- .../SemaCXX/warn-thread-safety-analysis.cpp | 20 +- ...-usage-libc-functions-inline-namespace.cpp | 60 - ...arn-unsafe-buffer-usage-libc-functions.cpp | 142 - ...n-unsafe-buffer-usage-test-unreachable.cpp | 4 +- clang/test/SemaCXX/weak-init.cpp | 1 - clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl | 2 +- .../SemaHLSL/BuiltIns/StructuredBuffers.hlsl | 19 - .../SemaHLSL/BuiltIns/asfloat-errors.hlsl | 35 - .../test/SemaHLSL/BuiltIns/asuint-errors.hlsl | 25 - .../SemaHLSL/BuiltIns/countbits-errors.hlsl | 21 - .../test/SemaHLSL/BuiltIns/select-errors.hlsl | 119 - clang/test/SemaHLSL/BuiltIns/sign-errors.hlsl | 16 - clang/test/SemaHLSL/BuiltIns/step-errors.hlsl | 31 - .../TruncationOverloadResolution.hlsl | 64 +- .../Arithmetic/literal_suffixes_202x.hlsl | 2 +- .../BuiltinVector/ScalarSwizzleErrors.hlsl | 6 +- .../BuiltinVector/TruncationConstantExpr.hlsl | 20 - .../Types/Traits/IsIntangibleType.hlsl | 78 - .../Types/Traits/IsIntangibleTypeErrors.hlsl | 12 - .../ScalarizedLayoutCompatibleErrors.hlsl | 5 +- clang/test/SemaHLSL/group_shared.hlsl | 7 +- clang/test/SemaHLSL/group_shared_202x.hlsl | 27 +- clang/test/SemaHLSL/prohibit_reference.hlsl | 1 + .../SemaHLSL/resource_binding_attr_error.hlsl | 19 +- .../resource_binding_attr_error_basic.hlsl | 21 +- .../resource_binding_attr_error_resource.hlsl | 10 +- .../resource_binding_attr_error_space.hlsl | 62 - .../resource_binding_attr_error_udt.hlsl | 17 +- clang/test/SemaObjC/ivar-access-tests.m | 10 - clang/test/SemaObjC/non-trivial-c-union.m | 1 - .../SemaOpenACC/compute-construct-ast.cpp | 23 +- clang/test/SemaOpenCL/unsupported.cl | 4 +- clang/test/SemaTemplate/GH18291.cpp | 36 +- .../SemaTemplate/concepts-out-of-line-def.cpp | 44 - clang/test/SemaTemplate/cwg2398.cpp | 60 +- clang/test/SemaTemplate/pack-deduction.cpp | 14 - .../clang-rename/ClassAsTemplateArgument.cpp | 21 + clang/test/clang-rename/ClassFindByName.cpp | 10 + .../test/clang-rename/ClassSimpleRenaming.cpp | 14 + clang/test/clang-rename/ClassTestMulti.cpp | 11 + .../clang-rename/ClassTestMultiByName.cpp | 8 + .../clang-rename/ComplexFunctionOverride.cpp | 47 + .../clang-rename/ComplicatedClassType.cpp | 63 + clang/test/clang-rename/Ctor.cpp | 14 + clang/test/clang-rename/CtorInitializer.cpp | 17 + clang/test/clang-rename/DeclRefExpr.cpp | 24 + clang/test/clang-rename/ForceMulti.cpp | 8 + clang/test/clang-rename/ForwardClassDecl.cpp | 4 + clang/test/clang-rename/FunctionMacro.cpp | 20 + clang/test/clang-rename/FunctionOverride.cpp | 13 + clang/test/clang-rename/FunctionTemplate.cpp | 19 + .../FunctionWithClassFindByName.cpp | 12 + .../clang-rename/IncludeHeaderWithSymbol.cpp | 10 + .../clang-rename/Inputs/HeaderWithSymbol.h | 1 + .../clang-rename/Inputs/OffsetToNewName.yaml | 6 + .../Inputs/QualifiedNameToNewName.yaml | 6 + clang/test/clang-rename/InvalidNewName.cpp | 2 + clang/test/clang-rename/InvalidOffset.cpp | 9 + .../clang-rename/InvalidQualifiedName.cpp | 4 + clang/test/clang-rename/MemberExprMacro.cpp | 22 + clang/test/clang-rename/Namespace.cpp | 13 + clang/test/clang-rename/NoNewName.cpp | 4 + clang/test/clang-rename/NonExistFile.cpp | 2 + .../TemplateClassInstantiation.cpp | 42 + clang/test/clang-rename/TemplateCtor.cpp | 10 + clang/test/clang-rename/TemplateTypename.cpp | 24 + .../clang-rename/TemplatedClassFunction.cpp | 27 + clang/test/clang-rename/Typedef.cpp | 8 + .../clang-rename/UserDefinedConversion.cpp | 26 + clang/test/clang-rename/Variable.cpp | 33 + clang/test/clang-rename/VariableMacro.cpp | 21 + clang/test/clang-rename/VariableTemplate.cpp | 32 + clang/test/clang-rename/YAMLInput.cpp | 10 + clang/tools/CMakeLists.txt | 2 + clang/tools/c-arcmt-test/c-arcmt-test.c | 4 +- clang/tools/c-index-test/c-index-test.c | 4 +- clang/tools/clang-format-vs/.gitignore | 11 + clang/tools/clang-format-vs/CMakeLists.txt | 33 + clang/tools/clang-format-vs/ClangFormat.sln | 22 + .../ClangFormat/ClangFormat.csproj | 261 + .../ClangFormat/ClangFormat.vsct | 127 + .../ClangFormat/ClangFormatPackage.cs | 464 + .../ClangFormat/GlobalSuppressions.cs | 11 + .../clang-format-vs/ClangFormat/Guids.cs | 12 + .../clang-format-vs/ClangFormat/PkgCmdID.cs | 8 + .../ClangFormat/Properties/AssemblyInfo.cs | 33 + .../ClangFormat/Resources.Designer.cs | 63 + .../ClangFormat/Resources.resx | 129 + .../ClangFormat/Resources/Images_32bit.bmp | Bin 0 -> 5176 bytes .../ClangFormat/Resources/Package.ico | Bin 0 -> 1078 bytes .../RunningDocTableEventsDispatcher.cs | 79 + .../ClangFormat/VSPackage.resx | 140 + .../tools/clang-format-vs/ClangFormat/Vsix.cs | 96 + .../clang-format-vs/ClangFormat/license.txt | 261 + .../ClangFormat/packages.config | 21 + clang/tools/clang-format-vs/README.txt | 51 + .../source.extension.vsixmanifest.in | 19 + clang/tools/clang-format/git-clang-format.bat | 2 +- clang/tools/clang-refactor/ClangRefactor.cpp | 2 + clang/tools/clang-rename/CMakeLists.txt | 26 + clang/tools/clang-rename/ClangRename.cpp | 242 + clang/tools/clang-rename/clang-rename.el | 80 + clang/tools/clang-rename/clang-rename.py | 70 + clang/tools/clang-repl/ClangRepl.cpp | 4 +- clang/tools/clang-scan-deps/CMakeLists.txt | 1 - clang/tools/clang-scan-deps/ClangScanDeps.cpp | 44 +- clang/tools/diagtool/ListWarnings.cpp | 7 +- clang/tools/diagtool/ShowEnabledWarnings.cpp | 6 +- clang/tools/driver/CMakeLists.txt | 2 - clang/tools/driver/cc1gen_reproducer_main.cpp | 4 +- clang/tools/driver/driver.cpp | 2 - clang/tools/include-mapping/gen_std.py | 2 +- clang/tools/libclang/CIndex.cpp | 3 - clang/tools/libclang/CXStoredDiagnostic.cpp | 17 +- clang/unittests/AST/ASTImporterTest.cpp | 334 +- clang/unittests/AST/CMakeLists.txt | 1 - clang/unittests/AST/RawCommentForDeclTest.cpp | 98 - clang/unittests/AST/SourceLocationTest.cpp | 2 +- clang/unittests/AST/TemplateNameTest.cpp | 2 +- .../ASTMatchers/ASTMatchersTraversalTest.cpp | 13 - .../Analysis/ExprMutationAnalyzerTest.cpp | 2 +- clang/unittests/Basic/DiagnosticTest.cpp | 19 +- clang/unittests/Basic/SarifTest.cpp | 1 + clang/unittests/CMakeLists.txt | 1 + clang/unittests/Driver/CMakeLists.txt | 1 - clang/unittests/Driver/DXCModeTest.cpp | 5 + clang/unittests/Driver/GCCVersionTest.cpp | 1 - .../unittests/Driver/MultilibBuilderTest.cpp | 9 +- clang/unittests/Driver/MultilibTest.cpp | 86 +- .../Driver/SimpleDiagnosticConsumer.h | 17 - clang/unittests/Format/FormatTest.cpp | 12 - clang/unittests/Format/FormatTestBase.h | 14 +- clang/unittests/Format/FormatTestJS.cpp | 29 +- clang/unittests/Format/FormatTestProto.cpp | 2 + .../unittests/Format/FormatTestTextProto.cpp | 90 +- clang/unittests/Format/TokenAnnotatorTest.cpp | 98 +- clang/unittests/Frontend/OutputStreamTest.cpp | 2 +- .../unittests/Frontend/TextDiagnosticTest.cpp | 1 + clang/unittests/Rename/CMakeLists.txt | 29 + clang/unittests/Rename/ClangRenameTest.h | 116 + clang/unittests/Rename/RenameAliasTest.cpp | 303 + clang/unittests/Rename/RenameClassTest.cpp | 820 ++ clang/unittests/Rename/RenameEnumTest.cpp | 189 + clang/unittests/Rename/RenameFunctionTest.cpp | 573 + clang/unittests/Rename/RenameMemberTest.cpp | 228 + .../unittests/StaticAnalyzer/RangeSetTest.cpp | 2 +- clang/unittests/Tooling/ASTSelectionTest.cpp | 2 +- .../DependencyScanningFilesystemTest.cpp | 36 +- .../unittests/Tooling/DiagnosticsYamlTest.cpp | 2 +- .../RecursiveASTVisitorTestDeclVisitor.cpp | 2 +- .../TemplateArgumentLocTraverser.cpp | 2 +- clang/unittests/Tooling/RefactoringTest.cpp | 1 + clang/unittests/Tooling/RewriterTestContext.h | 1 + clang/unittests/Tooling/StencilTest.cpp | 22 - clang/utils/TableGen/ASTTableGen.cpp | 21 +- clang/utils/TableGen/ASTTableGen.h | 37 +- clang/utils/TableGen/ClangASTNodesEmitter.cpp | 90 +- .../TableGen/ClangASTPropertiesEmitter.cpp | 107 +- clang/utils/TableGen/ClangAttrEmitter.cpp | 367 +- clang/utils/TableGen/ClangBuiltinsEmitter.cpp | 20 +- .../ClangCommentCommandInfoEmitter.cpp | 14 +- ...mentHTMLNamedCharacterReferenceEmitter.cpp | 16 +- .../TableGen/ClangCommentHTMLTagsEmitter.cpp | 13 +- .../TableGen/ClangDataCollectorsEmitter.cpp | 2 +- .../TableGen/ClangDiagnosticsEmitter.cpp | 153 +- clang/utils/TableGen/ClangOpcodesEmitter.cpp | 10 +- .../utils/TableGen/ClangOptionDocEmitter.cpp | 52 +- .../TableGen/ClangProgModelBuiltinEmitter.cpp | 81 +- .../utils/TableGen/ClangSACheckersEmitter.cpp | 17 +- clang/utils/TableGen/ClangSyntaxEmitter.cpp | 67 +- .../utils/TableGen/ClangTypeNodesEmitter.cpp | 13 +- clang/utils/TableGen/MveEmitter.cpp | 85 +- clang/utils/TableGen/NeonEmitter.cpp | 271 +- clang/utils/TableGen/RISCVVEmitter.cpp | 29 +- clang/utils/TableGen/SveEmitter.cpp | 148 +- clang/utils/TableGen/TableGen.cpp | 8 - clang/utils/TableGen/TableGenBackends.h | 208 +- clang/utils/check_cfc/obj_diff.py | 2 +- clang/utils/module-deps-to-rsp.py | 2 +- clang/www/c_status.html | 16 +- clang/www/cxx_dr_status.html | 116 +- clang/www/cxx_status.html | 26 +- clang/www/make_cxx_dr_status | 2 +- cmake/Modules/HandleCompilerRT.cmake | 16 +- compiler-rt/CMakeLists.txt | 4 +- compiler-rt/cmake/base-config-ix.cmake | 2 - compiler-rt/cmake/config-ix.cmake | 9 +- compiler-rt/include/CMakeLists.txt | 1 - .../include/sanitizer/rtsan_interface.h | 75 - compiler-rt/lib/asan/CMakeLists.txt | 170 +- compiler-rt/lib/asan/asan_flags.cpp | 96 +- compiler-rt/lib/asan/asan_globals_win.cpp | 4 +- compiler-rt/lib/asan/asan_linux.cpp | 5 +- compiler-rt/lib/asan/asan_malloc_linux.cpp | 5 +- compiler-rt/lib/asan/asan_malloc_win.cpp | 97 +- .../lib/asan/asan_malloc_win_thunk.cpp | 229 - compiler-rt/lib/asan/asan_posix.cpp | 14 +- compiler-rt/lib/asan/asan_rtl.cpp | 9 +- compiler-rt/lib/asan/asan_thread.cpp | 9 +- .../asan/asan_win_common_runtime_thunk.cpp | 112 - .../lib/asan/asan_win_common_runtime_thunk.h | 38 - compiler-rt/lib/asan/asan_win_dll_thunk.cpp | 165 + .../asan/asan_win_dynamic_runtime_thunk.cpp | 104 +- .../asan/asan_win_static_runtime_thunk.cpp | 110 - .../lib/asan/asan_win_weak_interception.cpp | 22 + compiler-rt/lib/asan/tests/CMakeLists.txt | 3 +- compiler-rt/lib/builtins/CMakeLists.txt | 1 - compiler-rt/lib/builtins/cpu_model/aarch64.c | 2 +- compiler-rt/lib/builtins/cpu_model/aarch64.h | 2 +- compiler-rt/lib/builtins/cpu_model/x86.c | 20 - compiler-rt/lib/builtins/divsc3.c | 2 +- compiler-rt/lib/builtins/fp_lib.h | 9 + compiler-rt/lib/builtins/fp_trunc.h | 12 - compiler-rt/lib/builtins/truncxfbf2.c | 19 - .../lib/ctx_profile/CtxInstrContextNode.h | 25 +- .../lib/ctx_profile/CtxInstrProfiling.cpp | 41 +- .../lib/ctx_profile/CtxInstrProfiling.h | 4 +- compiler-rt/lib/dfsan/dfsan.cpp | 2 - compiler-rt/lib/dfsan/dfsan_interceptors.cpp | 5 +- compiler-rt/lib/dfsan/dfsan_thread.cpp | 9 +- compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp | 4 + compiler-rt/lib/hwasan/hwasan.cpp | 4 +- .../hwasan/hwasan_allocation_functions.cpp | 6 +- compiler-rt/lib/hwasan/hwasan_linux.cpp | 8 +- compiler-rt/lib/interception/CMakeLists.txt | 8 - .../lib/interception/interception_win.cpp | 181 +- compiler-rt/lib/lsan/lsan.cpp | 2 +- compiler-rt/lib/lsan/lsan_interceptors.cpp | 7 +- compiler-rt/lib/lsan/lsan_posix.cpp | 8 +- .../lib/memprof/memprof_malloc_linux.cpp | 4 +- compiler-rt/lib/memprof/memprof_rtl.cpp | 3 + compiler-rt/lib/memprof/memprof_thread.cpp | 8 +- compiler-rt/lib/msan/msan.cpp | 3 +- compiler-rt/lib/msan/msan_interceptors.cpp | 6 +- compiler-rt/lib/msan/msan_thread.cpp | 9 +- compiler-rt/lib/nsan/nsan.cpp | 9 +- compiler-rt/lib/nsan/nsan_thread.cpp | 9 +- compiler-rt/lib/orc/adt.h | 4 +- compiler-rt/lib/orc/bitmask_enum.h | 4 +- compiler-rt/lib/orc/coff_platform.cpp | 22 +- compiler-rt/lib/orc/coff_platform.h | 6 +- compiler-rt/lib/orc/debug.cpp | 5 +- compiler-rt/lib/orc/debug.h | 10 +- compiler-rt/lib/orc/dlfcn_wrapper.cpp | 15 +- compiler-rt/lib/orc/elfnix_platform.cpp | 19 +- compiler-rt/lib/orc/elfnix_platform.h | 6 +- compiler-rt/lib/orc/endianness.h | 4 +- compiler-rt/lib/orc/error.h | 4 +- compiler-rt/lib/orc/executor_address.h | 10 +- compiler-rt/lib/orc/executor_symbol_def.h | 4 +- compiler-rt/lib/orc/extensible_rtti.cpp | 4 +- compiler-rt/lib/orc/extensible_rtti.h | 4 +- compiler-rt/lib/orc/interval_map.h | 4 +- compiler-rt/lib/orc/interval_set.h | 4 +- compiler-rt/lib/orc/jit_dispatch.h | 50 - compiler-rt/lib/orc/macho_platform.cpp | 110 +- compiler-rt/lib/orc/macho_platform.h | 7 +- compiler-rt/lib/orc/run_program_wrapper.cpp | 2 +- .../lib/orc/simple_packed_serialization.h | 6 +- compiler-rt/lib/orc/stl_extras.h | 4 +- compiler-rt/lib/orc/string_pool.h | 10 +- compiler-rt/lib/orc/tests/unit/adt_test.cpp | 2 +- .../lib/orc/tests/unit/bitmask_enum_test.cpp | 6 +- .../lib/orc/tests/unit/endian_test.cpp | 2 +- compiler-rt/lib/orc/tests/unit/error_test.cpp | 2 +- .../orc/tests/unit/executor_address_test.cpp | 2 +- .../tests/unit/executor_symbol_def_test.cpp | 2 +- .../orc/tests/unit/extensible_rtti_test.cpp | 2 +- .../lib/orc/tests/unit/interval_map_test.cpp | 2 +- .../lib/orc/tests/unit/interval_set_test.cpp | 2 +- .../unit/simple_packed_serialization_test.cpp | 2 +- .../unit/simple_packed_serialization_utils.h | 6 +- .../lib/orc/tests/unit/string_pool_test.cpp | 2 +- .../unit/wrapper_function_utils_test.cpp | 12 +- compiler-rt/lib/orc/wrapper_function_utils.h | 32 +- compiler-rt/lib/profile/CMakeLists.txt | 6 - compiler-rt/lib/profile/InstrProfilingFile.c | 12 +- .../profile/InstrProfilingPlatformFuchsia.c | 2 +- compiler-rt/lib/rtsan/CMakeLists.txt | 8 +- compiler-rt/lib/rtsan/rtsan.cpp | 9 +- compiler-rt/lib/rtsan/rtsan.h | 6 +- compiler-rt/lib/rtsan/rtsan_context.cpp | 48 +- compiler-rt/lib/rtsan/rtsan_context.h | 20 +- compiler-rt/lib/rtsan/rtsan_flags.cpp | 59 - compiler-rt/lib/rtsan/rtsan_flags.h | 28 - compiler-rt/lib/rtsan/rtsan_flags.inc | 20 - compiler-rt/lib/rtsan/rtsan_stack.cpp | 15 +- compiler-rt/lib/rtsan/rtsan_stack.h | 4 +- compiler-rt/lib/rtsan/tests/CMakeLists.txt | 10 +- .../lib/rtsan/tests/rtsan_test_context.cpp | 40 +- .../rtsan/tests/rtsan_test_interceptors.cpp | 11 +- .../lib/rtsan/tests/rtsan_test_main.cpp | 17 - .../lib/rtsan/tests/rtsan_test_utilities.h | 11 +- .../lib/sanitizer_common/CMakeLists.txt | 63 +- .../sanitizer_allocator_dlsym.h | 13 +- .../lib/sanitizer_common/sanitizer_common.h | 4 +- .../sanitizer_common_interface.inc | 7 - .../sanitizer_common_libcdep.cpp | 2 +- .../sanitizer_common_nolibc.cpp | 7 +- .../sanitizer_coverage_win_dll_thunk.cpp | 20 + ...er_coverage_win_dynamic_runtime_thunk.cpp} | 21 +- ...nitizer_coverage_win_weak_interception.cpp | 23 + .../sanitizer_common/sanitizer_fuchsia.cpp | 1 + .../sanitizer_interface_internal.h | 5 - .../sanitizer_internal_defs.h | 22 +- .../sanitizer_common/sanitizer_libignore.cpp | 28 +- .../sanitizer_common/sanitizer_libignore.h | 35 +- .../lib/sanitizer_common/sanitizer_linux.cpp | 16 +- .../sanitizer_linux_libcdep.cpp | 247 +- .../lib/sanitizer_common/sanitizer_mac.cpp | 30 +- .../sanitizer_platform_interceptors.h | 5 - .../sanitizer_redefine_builtins.h | 8 +- .../sanitizer_common/sanitizer_symbolizer.h | 8 +- .../sanitizer_tls_get_addr.cpp | 51 +- .../sanitizer_common/sanitizer_tls_get_addr.h | 4 + .../lib/sanitizer_common/sanitizer_win.cpp | 30 +- .../sanitizer_win_dll_thunk.cpp | 101 + .../sanitizer_win_dll_thunk.h | 181 + .../sanitizer_win_dynamic_runtime_thunk.cpp | 26 + .../sanitizer_win_immortalize.h | 71 - .../sanitizer_win_interception.cpp | 156 - .../sanitizer_win_interception.h | 32 - .../sanitizer_win_thunk_interception.cpp | 110 - .../sanitizer_win_thunk_interception.h | 88 - .../sanitizer_win_weak_interception.cpp | 94 + .../sanitizer_win_weak_interception.h | 32 + .../tests/sanitizer_common_test.cpp | 37 +- .../tests/sanitizer_linux_test.cpp | 60 +- .../lib/sanitizer_common/weak_symbols.txt | 1 - .../lib/scudo/standalone/allocator_common.h | 7 +- compiler-rt/lib/scudo/standalone/combined.h | 3 - compiler-rt/lib/scudo/standalone/common.cpp | 10 +- compiler-rt/lib/scudo/standalone/common.h | 30 +- compiler-rt/lib/scudo/standalone/linux.cpp | 3 - compiler-rt/lib/scudo/standalone/platform.h | 5 - compiler-rt/lib/scudo/standalone/primary32.h | 24 +- compiler-rt/lib/scudo/standalone/primary64.h | 92 +- compiler-rt/lib/scudo/standalone/release.h | 46 +- compiler-rt/lib/scudo/standalone/secondary.h | 28 +- .../scudo/standalone/tests/primary_test.cpp | 1 - .../lib/tsan/rtl/tsan_interceptors_posix.cpp | 36 +- compiler-rt/lib/tsan/rtl/tsan_mman.cpp | 2 +- .../lib/tsan/rtl/tsan_platform_linux.cpp | 1 + compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp | 10 +- compiler-rt/lib/ubsan/CMakeLists.txt | 27 +- compiler-rt/lib/ubsan/ubsan_init.cpp | 2 +- compiler-rt/lib/ubsan/ubsan_win_dll_thunk.cpp | 20 + ...pp => ubsan_win_dynamic_runtime_thunk.cpp} | 11 +- .../lib/ubsan/ubsan_win_weak_interception.cpp | 23 + .../Darwin/interface_symbols_darwin.cpp | 3 - .../Linux/interface_symbols_linux.cpp | 3 - .../test/asan/TestCases/Linux/odr_c_test.c | 3 - .../TestCases/Posix/strndup_oob_test2.cpp | 42 +- .../asan/TestCases/Windows/double_free.cpp | 6 +- .../TestCases/Windows/free_hook_realloc.cpp | 3 + .../TestCases/Windows/malloc_left_oob.cpp | 2 +- .../TestCases/Windows/malloc_right_oob.cpp | 2 +- .../asan/TestCases/Windows/malloc_uaf.cpp | 4 +- .../TestCases/Windows/msvc/dll_and_lib.cpp | 5 +- .../Windows/msvc/dll_large_function.cpp | 3 +- .../TestCases/Windows/realloc_left_oob.cpp | 2 +- .../TestCases/Windows/realloc_right_oob.cpp | 2 +- .../asan/TestCases/Windows/realloc_uaf.cpp | 4 +- .../asan/TestCases/Windows/symbols_path.cpp | 2 +- .../asan/TestCases/Windows/unsymbolized.cpp | 2 +- .../TestCases/Windows/use_after_realloc.cpp | 4 +- .../test/asan/TestCases/debug_double_free.cpp | 3 + .../test/asan/TestCases/debug_report.cpp | 3 + .../test/asan/TestCases/default_options.cpp | 4 + .../test/asan/TestCases/global-overflow.cpp | 3 - .../test/asan/TestCases/large_func_test.cpp | 3 - compiler-rt/test/asan/TestCases/leaks.cpp | 8 +- .../test/asan/TestCases/on_error_callback.cpp | 3 + .../asan/TestCases/report_error_summary.cpp | 3 + compiler-rt/test/asan/lit.cfg.py | 23 +- .../builtins/Unit/compiler_rt_fmaxf_test.c | 39 + compiler-rt/test/builtins/Unit/divsc3_test.c | 302 +- compiler-rt/test/fuzzer/compressed.test | 4 +- compiler-rt/test/lit.common.cfg.py | 5 - compiler-rt/test/lit.common.configured.in | 2 - .../test/lsan/TestCases/use_registers.cpp | 14 +- .../runtime-counter-relocation.c | 2 +- .../ContinuousSyncMode/set-file-object.c | 2 +- ...nstrprof-debug-info-correlate-debuginfod.c | 24 - .../instrprof-binary-correlate-debuginfod.c | 41 - compiler-rt/test/profile/lit.cfg.py | 3 - compiler-rt/test/rtsan/basic.cpp | 5 +- compiler-rt/test/rtsan/disabler.cpp | 53 - compiler-rt/test/rtsan/lit.cfg.py | 16 - compiler-rt/test/rtsan/sanity_check_pure_c.c | 28 - compiler-rt/test/rtsan/unrecognized_flags.cpp | 11 - .../Linux/soft_rss_limit_mb_test.cpp | 1 + .../TestCases/Linux/tls_get_addr.c | 56 - .../TestCases/Linux/tls_malloc_hook.c | 56 - .../TestCases/Posix/fork_threaded.c | 3 - .../sanitizer_common/TestCases/dlsym_alloc.c | 58 - .../sanitizer_coverage_trace_pc_guard-dso.cpp | 3 +- .../sanitizer_coverage_trace_pc_guard.cpp | 2 +- compiler-rt/test/tsan/ignore_lib3.cpp | 30 +- compiler-rt/test/tsan/signal_block.cpp | 4 - compiler-rt/test/tsan/signal_reset.cpp | 5 - compiler-rt/test/tsan/signal_thread2.cpp | 3 +- compiler-rt/www/index.html | 2 +- .../dexter/dex/debugger/lldb/LLDB.py | 27 - flang/docs/Extensions.md | 8 +- flang/include/flang/Common/Fortran-features.h | 5 +- flang/include/flang/Common/float128.h | 15 +- flang/include/flang/Common/float80.h | 43 - flang/include/flang/Evaluate/expression.h | 3 - flang/include/flang/Evaluate/integer.h | 6 +- flang/include/flang/Evaluate/tools.h | 18 +- flang/include/flang/Evaluate/traverse.h | 2 +- flang/include/flang/Frontend/TargetOptions.h | 6 - flang/include/flang/Lower/SymbolMap.h | 10 - .../flang/Optimizer/Builder/FIRBuilder.h | 21 - .../Optimizer/Builder/LowLevelIntrinsics.h | 6 + .../Optimizer/Builder/Runtime/RTBuilder.h | 13 +- .../flang/Optimizer/CodeGen/CGPasses.td | 2 +- .../include/flang/Optimizer/Dialect/FIRType.h | 7 - .../include/flang/Optimizer/OpenMP/Passes.td | 2 +- .../flang/Optimizer/Support/DataLayout.h | 1 + .../flang/Optimizer/Transforms/Passes.h | 3 + .../flang/Optimizer/Transforms/Passes.td | 2 +- flang/include/flang/Parser/dump-parse-tree.h | 2 +- .../include/flang/Runtime/CUDA/allocatable.h | 34 - flang/include/flang/Runtime/CUDA/allocator.h | 11 + flang/include/flang/Runtime/CUDA/common.h | 30 - flang/include/flang/Runtime/CUDA/descriptor.h | 13 +- flang/include/flang/Runtime/CUDA/memory.h | 43 - flang/include/flang/Runtime/complex.h | 33 - flang/include/flang/Runtime/cpp-type.h | 45 +- flang/include/flang/Runtime/descriptor.h | 2 +- .../flang/Runtime/matmul-instances.inc | 12 +- flang/include/flang/Runtime/numeric.h | 79 +- flang/include/flang/Runtime/reduce.h | 218 +- flang/include/flang/Runtime/reduction.h | 130 +- .../include/flang/Runtime/transformational.h | 28 +- flang/include/flang/Semantics/expression.h | 4 +- flang/include/flang/Semantics/scope.h | 2 - flang/include/flang/Semantics/semantics.h | 2 - flang/include/flang/Semantics/type.h | 12 +- flang/include/flang/Tools/CLOptions.inc | 2 +- flang/include/flang/Tools/TargetSetup.h | 30 +- flang/lib/Evaluate/characteristics.cpp | 5 +- flang/lib/Evaluate/check-expression.cpp | 21 +- flang/lib/Evaluate/expression.cpp | 22 +- flang/lib/Evaluate/fold-implementation.h | 50 +- flang/lib/Evaluate/formatting.cpp | 4 +- flang/lib/Evaluate/intrinsics-library.cpp | 7 +- flang/lib/Evaluate/intrinsics.cpp | 12 +- flang/lib/Evaluate/real.cpp | 6 +- flang/lib/Evaluate/tools.cpp | 5 +- flang/lib/Evaluate/type.cpp | 4 +- flang/lib/Frontend/CompilerInvocation.cpp | 21 +- flang/lib/Frontend/FrontendActions.cpp | 9 +- flang/lib/Frontend/TextDiagnosticPrinter.cpp | 6 +- flang/lib/Lower/Bridge.cpp | 88 +- flang/lib/Lower/ConvertCall.cpp | 49 +- flang/lib/Lower/ConvertExpr.cpp | 3 +- flang/lib/Lower/DirectivesCommon.h | 2 +- flang/lib/Lower/Mangler.cpp | 10 - flang/lib/Lower/OpenMP/ClauseProcessor.cpp | 198 +- flang/lib/Lower/OpenMP/ClauseProcessor.h | 84 +- .../lib/Lower/OpenMP/DataSharingProcessor.cpp | 72 +- flang/lib/Lower/OpenMP/DataSharingProcessor.h | 8 + flang/lib/Lower/OpenMP/OpenMP.cpp | 213 +- flang/lib/Lower/OpenMP/Utils.cpp | 7 - flang/lib/Lower/PFTBuilder.cpp | 9 +- flang/lib/Optimizer/Builder/FIRBuilder.cpp | 49 +- flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 2 +- .../Optimizer/Builder/LowLevelIntrinsics.cpp | 19 + .../lib/Optimizer/Builder/Runtime/Numeric.cpp | 13 +- flang/lib/Optimizer/CodeGen/CMakeLists.txt | 1 - flang/lib/Optimizer/CodeGen/CodeGen.cpp | 16 +- flang/lib/Optimizer/CodeGen/TargetRewrite.cpp | 16 +- flang/lib/Optimizer/Dialect/FIRType.cpp | 7 +- .../HLFIR/Transforms/ConvertToFIR.cpp | 3 +- .../Optimizer/OpenMP/FunctionFiltering.cpp | 4 +- .../Optimizer/OpenMP/MapInfoFinalization.cpp | 37 +- .../lib/Optimizer/Transforms/AddAliasTags.cpp | 4 +- .../lib/Optimizer/Transforms/AddDebugInfo.cpp | 154 +- .../Optimizer/Transforms/CufOpConversion.cpp | 241 +- .../Transforms/DebugTypeGenerator.cpp | 74 +- .../lib/Optimizer/Transforms/StackArrays.cpp | 29 +- .../lib/Optimizer/Transforms/StackReclaim.cpp | 21 +- flang/lib/Parser/parsing.cpp | 4 +- flang/lib/Parser/preprocessor.cpp | 2 +- flang/lib/Parser/prescan.cpp | 105 +- flang/lib/Parser/prescan.h | 3 +- flang/lib/Semantics/check-call.cpp | 8 - flang/lib/Semantics/check-cuda.cpp | 7 +- flang/lib/Semantics/check-cuda.h | 2 - flang/lib/Semantics/check-declarations.cpp | 30 +- flang/lib/Semantics/check-do-forall.cpp | 97 +- flang/lib/Semantics/check-do-forall.h | 2 +- flang/lib/Semantics/check-io.cpp | 6 - flang/lib/Semantics/check-omp-structure.cpp | 15 +- flang/lib/Semantics/compute-offsets.cpp | 7 - flang/lib/Semantics/expression.cpp | 72 +- flang/lib/Semantics/pointer-assignment.cpp | 2 +- flang/lib/Semantics/resolve-directives.cpp | 38 +- flang/lib/Semantics/resolve-names.cpp | 180 +- flang/lib/Semantics/scope.cpp | 2 +- flang/lib/Semantics/semantics.cpp | 6 +- flang/lib/Semantics/symbol.cpp | 3 +- flang/lib/Semantics/tools.cpp | 4 +- flang/lib/Semantics/type.cpp | 28 +- flang/module/__fortran_builtins.f90 | 6 +- flang/module/__fortran_ieee_exceptions.f90 | 2 +- flang/module/ieee_arithmetic.f90 | 51 +- flang/module/iso_fortran_env.f90 | 2 +- flang/runtime/CMakeLists.txt | 7 - flang/runtime/CUDA/CMakeLists.txt | 2 - flang/runtime/CUDA/allocatable.cpp | 70 - flang/runtime/CUDA/allocator.cpp | 1 - flang/runtime/CUDA/descriptor.cpp | 22 - flang/runtime/CUDA/memory.cpp | 46 - flang/runtime/Float128Math/CMakeLists.txt | 3 - flang/runtime/Float128Math/acos.cpp | 2 +- flang/runtime/Float128Math/acosh.cpp | 2 +- flang/runtime/Float128Math/asin.cpp | 2 +- flang/runtime/Float128Math/asinh.cpp | 2 +- flang/runtime/Float128Math/atan.cpp | 2 +- flang/runtime/Float128Math/atan2.cpp | 2 +- flang/runtime/Float128Math/atanh.cpp | 2 +- flang/runtime/Float128Math/ceil.cpp | 2 +- flang/runtime/Float128Math/complex-math.c | 4 +- flang/runtime/Float128Math/complex-math.h | 2 +- flang/runtime/Float128Math/cos.cpp | 2 +- flang/runtime/Float128Math/cosh.cpp | 2 +- flang/runtime/Float128Math/erf.cpp | 2 +- flang/runtime/Float128Math/erfc.cpp | 2 +- flang/runtime/Float128Math/exp.cpp | 2 +- flang/runtime/Float128Math/exponent.cpp | 2 +- flang/runtime/Float128Math/floor.cpp | 2 +- flang/runtime/Float128Math/fma.cpp | 2 +- flang/runtime/Float128Math/fraction.cpp | 2 +- flang/runtime/Float128Math/hypot.cpp | 2 +- flang/runtime/Float128Math/j0.cpp | 2 +- flang/runtime/Float128Math/j1.cpp | 2 +- flang/runtime/Float128Math/jn.cpp | 2 +- flang/runtime/Float128Math/lgamma.cpp | 2 +- flang/runtime/Float128Math/llround.cpp | 2 +- flang/runtime/Float128Math/log.cpp | 2 +- flang/runtime/Float128Math/log10.cpp | 2 +- flang/runtime/Float128Math/lround.cpp | 2 +- flang/runtime/Float128Math/math-entries.h | 2 +- flang/runtime/Float128Math/mod-real.cpp | 2 +- flang/runtime/Float128Math/modulo-real.cpp | 2 +- flang/runtime/Float128Math/nearest.cpp | 2 +- flang/runtime/Float128Math/norm2.cpp | 2 +- flang/runtime/Float128Math/pow.cpp | 2 +- flang/runtime/Float128Math/random.cpp | 2 +- flang/runtime/Float128Math/round.cpp | 2 +- flang/runtime/Float128Math/rrspacing.cpp | 2 +- flang/runtime/Float128Math/scale.cpp | 2 +- flang/runtime/Float128Math/set-exponent.cpp | 2 +- flang/runtime/Float128Math/sin.cpp | 2 +- flang/runtime/Float128Math/sinh.cpp | 2 +- flang/runtime/Float128Math/spacing.cpp | 2 +- flang/runtime/Float128Math/sqrt.cpp | 2 +- flang/runtime/Float128Math/tan.cpp | 2 +- flang/runtime/Float128Math/tanh.cpp | 2 +- flang/runtime/Float128Math/tgamma.cpp | 2 +- flang/runtime/Float128Math/trunc.cpp | 2 +- flang/runtime/Float128Math/y0.cpp | 2 +- flang/runtime/Float128Math/y1.cpp | 2 +- flang/runtime/Float128Math/yn.cpp | 2 +- flang/runtime/assign.cpp | 2 +- flang/runtime/complex-powi.cpp | 29 +- flang/runtime/complex-reduction.c | 20 +- flang/runtime/complex-reduction.h | 10 +- flang/runtime/dot-product.cpp | 25 +- flang/runtime/edit-input.cpp | 24 +- flang/runtime/extrema.cpp | 18 +- flang/runtime/format-implementation.h | 5 +- flang/runtime/io-api.cpp | 2 +- flang/runtime/io-stmt.cpp | 7 +- flang/runtime/io-stmt.h | 5 +- flang/runtime/matmul-transpose.cpp | 17 + flang/runtime/matmul.cpp | 34 +- flang/runtime/numeric-templates.h | 26 +- flang/runtime/numeric.cpp | 72 +- flang/runtime/product.cpp | 19 +- flang/runtime/random.cpp | 4 +- flang/runtime/reduce.cpp | 184 +- flang/runtime/reduction-templates.h | 12 +- flang/runtime/sum.cpp | 26 +- flang/runtime/time-intrinsic.cpp | 18 +- flang/runtime/transformational.cpp | 16 +- flang/test/CMakeLists.txt | 10 - flang/test/Driver/fno-openmp.f90 | 12 - flang/test/Driver/fopenmp.f90 | 9 - flang/test/Driver/include-header.f90 | 2 +- flang/test/Driver/nostdlib.f90 | 29 - flang/test/Driver/q-unused-arguments.f90 | 5 - flang/test/Driver/save-temps-use-module.f90 | 26 - flang/test/Driver/w-option.f90 | 3 - flang/test/Driver/xlinker.f90 | 21 - .../test/Evaluate/fold-assumed-rank-kind.f90 | 6 - flang/test/Evaluate/fold-out_of_range.f90 | 1 - flang/test/Evaluate/fold-spacing.f90 | 4 +- flang/test/Evaluate/folding07.f90 | 1 - flang/test/Fir/CUDA/cuda-allocate.fir | 65 +- flang/test/Fir/CUDA/cuda-data-transfer.fir | 140 - .../struct-passing-x86-64-one-field-inreg.fir | 4 +- ...ct-passing-x86-64-several-fields-inreg.fir | 4 +- flang/test/Fir/target-rewrite-complex16.fir | 18 +- .../order_assignments/where-scheduling.f90 | 2 +- .../Integration/debug-assumed-shape-array.f90 | 4 +- flang/test/Integration/debug-module-2.f90 | 2 +- .../Integration/debug-target-region-vars.f90 | 28 - flang/test/Lower/CUDA/cuda-data-transfer.cuf | 42 - flang/test/Lower/CUDA/cuda-devptr.cuf | 48 - .../Lower/CUDA/cuda-kernel-loop-directive.cuf | 20 - flang/test/Lower/HLFIR/block_bindc_pocs.f90 | 4 +- .../test/Lower/HLFIR/elemental-array-ops.f90 | 2 + .../elemental-user-procedure-stacksave.f90 | 22 - .../Lower/HLFIR/ignore-type-f77-character.f90 | 35 - .../Lower/HLFIR/proc-pointer-comp-pass.f90 | 2 +- .../HLFIR/procedure-pointer-in-generics.f90 | 46 - flang/test/Lower/HLFIR/where-nonelemental.f90 | 16 +- .../Lower/Intrinsics/ieee_class_queries.f90 | 1 - .../test/Lower/Intrinsics/ieee_unordered.f90 | 1 - flang/test/Lower/Intrinsics/spacing.f90 | 28 +- .../DelayedPrivatization/equivalence.f90 | 2 +- flang/test/Lower/OpenMP/array-bounds.f90 | 2 +- flang/test/Lower/OpenMP/atomic-read.f90 | 4 +- flang/test/Lower/OpenMP/atomic-update.f90 | 8 +- flang/test/Lower/OpenMP/copyin-order.f90 | 4 +- flang/test/Lower/OpenMP/copyin.f90 | 114 +- flang/test/Lower/OpenMP/copyprivate.f90 | 2 +- flang/test/Lower/OpenMP/copyprivate2.f90 | 9 +- .../Lower/OpenMP/default-clause-byref.f90 | 6 +- ...elayed-privatization-allocatable-array.f90 | 2 +- ...privatization-allocatable-firstprivate.f90 | 2 +- .../OpenMP/delayed-privatization-array.f90 | 4 +- .../delayed-privatization-firstprivate.f90 | 2 +- .../Lower/OpenMP/distribute-parallel-do.f90 | 10 +- flang/test/Lower/OpenMP/implicit-dsa.f90 | 26 +- .../Lower/OpenMP/lastprivate-allocatable.f90 | 57 +- .../Lower/OpenMP/lastprivate-commonblock.f90 | 4 +- flang/test/Lower/OpenMP/lastprivate-iv.f90 | 6 +- flang/test/Lower/OpenMP/math-amdgpu.f90 | 184 - .../parallel-lastprivate-clause-scalar.f90 | 22 +- .../OpenMP/parallel-wsloop-firstpriv.f90 | 6 +- .../Lower/OpenMP/parallel-wsloop-lastpriv.f90 | 10 +- flang/test/Lower/OpenMP/parallel-wsloop.f90 | 8 +- flang/test/Lower/OpenMP/parallel.f90 | 6 +- flang/test/Lower/OpenMP/sections.f90 | 20 +- flang/test/Lower/OpenMP/shared-loop.f90 | 120 - flang/test/Lower/OpenMP/simd.f90 | 18 - flang/test/Lower/OpenMP/single.f90 | 4 +- .../test/Lower/OpenMP/statement-function.f90 | 4 +- flang/test/Lower/OpenMP/target.f90 | 14 +- flang/test/Lower/OpenMP/task.f90 | 6 +- flang/test/Lower/OpenMP/task2.f90 | 9 +- .../use-device-ptr-to-use-device-addr.f90 | 96 +- flang/test/Lower/OpenMP/wsloop-chunks.f90 | 6 +- flang/test/Lower/OpenMP/wsloop-monotonic.f90 | 2 +- .../test/Lower/OpenMP/wsloop-nonmonotonic.f90 | 2 +- flang/test/Lower/OpenMP/wsloop-schedule.f90 | 2 +- flang/test/Lower/OpenMP/wsloop.f90 | 2 +- .../test/Lower/array-elemental-calls-char.f90 | 4 +- flang/test/Lower/block.f90 | 22 +- flang/test/Lower/call-suspect.f90 | 13 +- flang/test/Lower/common-block.f90 | 2 +- flang/test/Lower/computed-goto.f90 | 24 +- .../test/Lower/dummy-procedure-character.f90 | 2 +- .../Lower/explicit-interface-results-2.f90 | 4 +- flang/test/Lower/forall/array-constructor.f90 | 4 +- .../test/Lower/host-associated-functions.f90 | 6 +- flang/test/Lower/host-associated.f90 | 8 +- flang/test/Lower/implicit-call-mismatch.f90 | 3 +- flang/test/Lower/io-write.f90 | 4 +- .../module-generic-with-specific-mangling.f90 | 60 - flang/test/Parser/non-breaking-space.f90 | 6 - flang/test/Preprocessing/include-file.h | 1 - flang/test/Preprocessing/include-line.F90 | 6 - flang/test/Preprocessing/pp134.F90 | 12 +- flang/test/Semantics/Inputs/modfile66.cuf | 4 - flang/test/Semantics/Inputs/modfile67.mod | 16 - .../OpenMP/bad_module_subroutine.f90 | 6 - flang/test/Semantics/OpenMP/clause-order.f90 | 19 - .../Semantics/OpenMP/combined-constructs.f90 | 1 - flang/test/Semantics/OpenMP/default.f90 | 9 - flang/test/Semantics/OpenMP/do20.f90 | 2 +- flang/test/Semantics/OpenMP/implicit-dsa.f90 | 4 +- flang/test/Semantics/OpenMP/ordered03.f90 | 1 - flang/test/Semantics/OpenMP/private-assoc.f90 | 32 - flang/test/Semantics/OpenMP/symbol01.f90 | 2 +- flang/test/Semantics/OpenMP/symbol02.f90 | 4 +- flang/test/Semantics/OpenMP/symbol03.f90 | 4 +- flang/test/Semantics/OpenMP/symbol07.f90 | 2 +- flang/test/Semantics/OpenMP/symbol09.f90 | 2 +- flang/test/Semantics/OpenMP/workshare02.f90 | 1 - flang/test/Semantics/call11.f90 | 36 +- flang/test/Semantics/elemental02.f90 | 13 - flang/test/Semantics/expr-errors06.f90 | 8 +- flang/test/Semantics/generic09.f90 | 47 - flang/test/Semantics/generic10.f90 | 17 - flang/test/Semantics/get_team.f90 | 2 +- flang/test/Semantics/implicit16.f90 | 12 - flang/test/Semantics/kinds03.f90 | 1 - flang/test/Semantics/kinds06.f90 | 4 - flang/test/Semantics/local-vs-global.f90 | 8 +- flang/test/Semantics/modfile26.f90 | 1 - flang/test/Semantics/modfile66.f90 | 3 - flang/test/Semantics/modfile67.f90 | 35 - flang/test/Semantics/modfile68.f90 | 42 - flang/test/Semantics/modproc01.f90 | 8 +- flang/test/Semantics/realkinds-aarch64-01.f90 | 1 - flang/test/Semantics/resolve24.f90 | 8 +- flang/test/Semantics/resolve69.f90 | 6 +- flang/test/Semantics/resolve77.f90 | 1 - flang/test/Semantics/smp-proc-ref.f90 | 20 - flang/test/Semantics/spec-expr.f90 | 2 +- flang/test/Transforms/debug-107988.fir | 23 - flang/test/Transforms/debug-90683.fir | 2 +- .../Transforms/debug-assumed-shape-array.fir | 4 +- .../Transforms/debug-assumed-size-array.fir | 5 +- flang/test/Transforms/debug-fn-info.fir | 16 +- .../test/Transforms/debug-imported-entity.fir | 30 - .../Transforms/debug-line-table-inc-file.fir | 4 +- .../debug-local-global-storage-1.fir | 2 +- flang/test/Transforms/stack-arrays.fir | 12 +- flang/test/lit.cfg.py | 3 +- flang/test/lit.site.cfg.py.in | 1 - flang/tools/bbc/bbc.cpp | 5 +- flang/tools/f18/CMakeLists.txt | 31 +- flang/unittests/Evaluate/real.cpp | 14 +- .../unittests/Frontend/CodeGenActionTest.cpp | 2 +- .../Frontend/CompilerInstanceTest.cpp | 2 +- flang/unittests/Runtime/CUDA/Allocatable.cpp | 60 - flang/unittests/Runtime/CUDA/CMakeLists.txt | 8 - flang/unittests/Runtime/Namelist.cpp | 29 - flang/unittests/Runtime/Numeric.cpp | 11 +- flang/unittests/Runtime/Reduction.cpp | 10 +- flang/unittests/Runtime/Transformational.cpp | 28 +- libc/CMakeLists.txt | 32 +- libc/benchmarks/MemorySizeDistributions.cpp | 2 +- .../automemcpy/unittests/CodeGenTest.cpp | 2 +- .../cmake/modules/LLVMLibCArchitectures.cmake | 10 +- .../modules/LLVMLibCCheckCpuFeatures.cmake | 4 - libc/cmake/modules/LLVMLibCCheckMPFR.cmake | 4 +- .../modules/LLVMLibCCompileOptionRules.cmake | 22 +- libc/cmake/modules/LLVMLibCHeaderRules.cmake | 4 +- libc/cmake/modules/LLVMLibCTestRules.cmake | 13 +- .../modules/prepare_libc_gpu_build.cmake | 4 +- libc/config/baremetal/arm/entrypoints.txt | 2 - libc/config/baremetal/config.json | 3 - libc/config/baremetal/riscv/entrypoints.txt | 2 - libc/config/config.json | 10 - libc/config/darwin/arm/entrypoints.txt | 15 +- libc/config/gpu/config.json | 3 - libc/config/linux/aarch64/entrypoints.txt | 2 - libc/config/linux/api.td | 4 - libc/config/linux/riscv/entrypoints.txt | 2 - libc/config/linux/x86_64/entrypoints.txt | 11 +- libc/docs/configure.rst | 3 - libc/docs/date_and_time.rst | 4 - libc/docs/dev/printf_behavior.rst | 12 - libc/hdr/CMakeLists.txt | 31 - libc/hdr/link_macros.h | 22 - libc/hdr/sys_auxv_macros.h | 22 - libc/hdr/types/CMakeLists.txt | 76 - libc/hdr/types/jmp_buf.h | 22 - libc/hdr/types/sighandler_t.h | 24 - libc/hdr/types/socklen_t.h | 21 - libc/hdr/types/ssize_t.h | 23 - libc/hdr/types/stack_t.h | 23 - libc/hdr/types/struct_msghdr.h | 21 - libc/hdr/types/struct_sockaddr.h | 21 - libc/hdr/types/wchar_t.h | 23 - libc/hdr/types/wint_t.h | 23 - libc/hdr/wchar_macros.h | 22 - libc/hdr/wchar_overlay.h | 47 - libc/include/CMakeLists.txt | 3 - .../include/llvm-libc-macros/float16-macros.h | 3 +- .../llvm-libc-macros/stdckdint-macros.h | 6 +- libc/include/llvm-libc-types/CMakeLists.txt | 6 +- libc/include/llvm-libc-types/struct_iovec.h | 19 - libc/include/llvm-libc-types/struct_msghdr.h | 26 - .../include/llvm-libc-types/struct_sockaddr.h | 2 +- libc/include/llvm-libc-types/wchar_t.h | 7 +- libc/include/llvm-libc-types/wint_t.h | 7 +- libc/newhdrgen/yaml/sys/socket.yaml | 92 - libc/newhdrgen/yaml/time.yaml | 13 - libc/spec/posix.td | 56 - libc/spec/stdc.td | 13 - libc/src/__support/CMakeLists.txt | 5 - libc/src/__support/CPP/CMakeLists.txt | 1 - libc/src/__support/CPP/new.cpp | 16 +- libc/src/__support/CPP/new.h | 9 - libc/src/__support/OSUtil/io.h | 2 - .../src/__support/OSUtil/linux/CMakeLists.txt | 30 - .../OSUtil/linux/aarch64/CMakeLists.txt | 10 - .../src/__support/OSUtil/linux/aarch64/vdso.h | 37 - .../__support/OSUtil/linux/arm/CMakeLists.txt | 10 - libc/src/__support/OSUtil/linux/arm/vdso.h | 37 - .../OSUtil/linux/riscv/CMakeLists.txt | 10 - libc/src/__support/OSUtil/linux/riscv/vdso.h | 43 - libc/src/__support/OSUtil/linux/vdso.cpp | 239 - libc/src/__support/OSUtil/linux/vdso.h | 81 - libc/src/__support/OSUtil/linux/vdso_sym.h | 70 - .../OSUtil/linux/x86_64/CMakeLists.txt | 10 - libc/src/__support/OSUtil/linux/x86_64/vdso.h | 43 - .../__support/OSUtil/windows/CMakeLists.txt | 10 - libc/src/__support/OSUtil/windows/exit.cpp | 23 - libc/src/__support/OSUtil/windows/io.cpp | 25 - libc/src/__support/OSUtil/windows/io.h | 21 - .../__support/StringUtil/error_to_string.cpp | 11 +- .../__support/StringUtil/error_to_string.h | 3 - .../tables/linux_extension_errors.h | 55 - .../StringUtil/tables/linux_platform_errors.h | 3 - .../tables/minimal_platform_errors.h | 2 - .../StringUtil/tables/posix_errors.h | 79 - .../__support/StringUtil/tables/stdc_errors.h | 7 - libc/src/__support/macros/CMakeLists.txt | 10 - libc/src/__support/macros/null_check.h | 33 - libc/src/__support/macros/properties/types.h | 2 +- libc/src/__support/macros/sanitizer.h | 21 +- libc/src/__support/str_to_float.h | 4 - libc/src/__support/time/linux/CMakeLists.txt | 1 - libc/src/__support/time/linux/clock_gettime.h | 35 +- libc/src/__support/wctype_utils.h | 5 +- libc/src/math/generic/CMakeLists.txt | 4 +- libc/src/math/generic/fmul.cpp | 103 +- libc/src/setjmp/aarch64/CMakeLists.txt | 4 +- libc/src/setjmp/aarch64/longjmp.cpp | 2 +- libc/src/setjmp/aarch64/setjmp.cpp | 3 +- libc/src/setjmp/arm/CMakeLists.txt | 4 +- libc/src/setjmp/arm/longjmp.cpp | 8 +- libc/src/setjmp/arm/setjmp.cpp | 7 +- libc/src/setjmp/longjmp.h | 4 +- libc/src/setjmp/riscv/CMakeLists.txt | 4 +- libc/src/setjmp/riscv/longjmp.cpp | 4 +- libc/src/setjmp/riscv/setjmp.cpp | 4 +- libc/src/setjmp/setjmp_impl.h | 4 +- libc/src/setjmp/x86_64/CMakeLists.txt | 4 +- libc/src/setjmp/x86_64/longjmp.cpp | 2 +- libc/src/setjmp/x86_64/setjmp.cpp | 2 +- libc/src/signal/linux/CMakeLists.txt | 2 - libc/src/signal/linux/sigaltstack.cpp | 2 +- libc/src/signal/linux/signal.cpp | 1 - libc/src/signal/sigaltstack.h | 2 +- libc/src/signal/signal.h | 4 +- libc/src/stdio/printf_core/CMakeLists.txt | 5 - libc/src/stdio/printf_core/converter.cpp | 5 - libc/src/stdio/printf_core/converter_atlas.h | 5 - libc/src/stdio/printf_core/parser.h | 14 +- .../stdio/printf_core/strerror_converter.h | 74 - libc/src/stdlib/atexit.cpp | 6 +- libc/src/stdlib/quick_exit.cpp | 3 - libc/src/string/memory_utils/op_x86.h | 86 +- .../string/memory_utils/x86_64/inline_bcmp.h | 32 +- libc/src/sys/auxv/getauxval.h | 2 +- libc/src/sys/socket/CMakeLists.txt | 49 - libc/src/sys/socket/bind.h | 5 +- libc/src/sys/socket/linux/CMakeLists.txt | 94 - libc/src/sys/socket/linux/bind.cpp | 8 +- libc/src/sys/socket/linux/recv.cpp | 47 - libc/src/sys/socket/linux/recvfrom.cpp | 49 - libc/src/sys/socket/linux/recvmsg.cpp | 42 - libc/src/sys/socket/linux/send.cpp | 46 - libc/src/sys/socket/linux/sendmsg.cpp | 42 - libc/src/sys/socket/linux/sendto.cpp | 49 - libc/src/sys/socket/linux/socketpair.cpp | 43 - libc/src/sys/socket/recv.h | 21 - libc/src/sys/socket/recvfrom.h | 25 - libc/src/sys/socket/recvmsg.h | 22 - libc/src/sys/socket/send.h | 21 - libc/src/sys/socket/sendmsg.h | 22 - libc/src/sys/socket/sendto.h | 25 - libc/src/sys/socket/socketpair.h | 20 - libc/src/time/CMakeLists.txt | 24 - libc/src/time/ctime.cpp | 28 - libc/src/time/ctime.h | 21 - libc/src/time/ctime_r.cpp | 29 - libc/src/time/ctime_r.h | 21 - libc/src/time/time_utils.h | 7 - libc/src/wchar/CMakeLists.txt | 3 +- libc/src/wchar/btowc.cpp | 1 - libc/src/wchar/btowc.h | 2 +- libc/src/wchar/wctob.cpp | 1 - libc/src/wchar/wctob.h | 2 +- libc/startup/gpu/amdgpu/start.cpp | 3 - libc/startup/gpu/nvptx/start.cpp | 3 - libc/startup/linux/do_start.cpp | 11 +- libc/test/UnitTest/CMakeLists.txt | 26 +- libc/test/integration/startup/CMakeLists.txt | 2 +- libc/test/src/__support/CMakeLists.txt | 7 +- libc/test/src/__support/FPUtil/CMakeLists.txt | 1 - .../test/src/__support/FPUtil/fpbits_test.cpp | 6 +- .../src/__support/OSUtil/linux/CMakeLists.txt | 18 - .../src/__support/OSUtil/linux/vdso_test.cpp | 162 - libc/test/src/__support/arg_list_test.cpp | 3 +- libc/test/src/compiler/CMakeLists.txt | 1 - .../src/compiler/stack_chk_guard_test.cpp | 6 +- libc/test/src/fenv/CMakeLists.txt | 1 - libc/test/src/fenv/getenv_and_setenv_test.cpp | 5 +- libc/test/src/math/exp2f_test.cpp | 1 + libc/test/src/math/fmul_test.cpp | 23 - .../math/performance_testing/CMakeLists.txt | 2 - .../math/performance_testing/fmul_perf.cpp | 3 +- libc/test/src/math/smoke/AddTest.h | 3 - libc/test/src/math/smoke/CMakeLists.txt | 32 +- libc/test/src/math/smoke/SubTest.h | 3 - libc/test/src/math/smoke/exp2f_test.cpp | 1 + libc/test/src/math/smoke/fmul_test.cpp | 19 - libc/test/src/math/smoke/nan_test.cpp | 7 +- libc/test/src/math/smoke/nanf128_test.cpp | 7 +- libc/test/src/math/smoke/nanf16_test.cpp | 7 +- libc/test/src/math/smoke/nanf_test.cpp | 7 +- libc/test/src/math/smoke/nanl_test.cpp | 7 +- libc/test/src/setjmp/CMakeLists.txt | 1 + libc/test/src/signal/CMakeLists.txt | 2 +- libc/test/src/signal/signal_test.cpp | 4 +- libc/test/src/stdio/CMakeLists.txt | 3 - libc/test/src/stdio/sprintf_test.cpp | 182 - .../src/string/memory_utils/CMakeLists.txt | 1 - .../test/src/string/memory_utils/op_tests.cpp | 3 +- libc/test/src/sys/socket/linux/CMakeLists.txt | 59 +- .../src/sys/socket/linux/send_recv_test.cpp | 73 - .../sys/socket/linux/sendmsg_recvmsg_test.cpp | 125 - .../sys/socket/linux/sendto_recvfrom_test.cpp | 75 - .../src/sys/socket/linux/socketpair_test.cpp | 37 - libc/test/src/time/CMakeLists.txt | 36 - libc/test/src/time/ctime_r_test.cpp | 58 - libc/test/src/time/ctime_test.cpp | 42 - libc/test/src/wchar/btowc_test.cpp | 4 +- libc/utils/HdrGen/Command.h | 2 +- libc/utils/HdrGen/Generator.cpp | 15 +- libc/utils/HdrGen/Generator.h | 4 +- libc/utils/HdrGen/IncludeFileCommand.cpp | 2 +- libc/utils/HdrGen/IncludeFileCommand.h | 2 +- .../PrototypeTestGen/PrototypeTestGen.cpp | 3 +- libc/utils/HdrGen/PublicAPICommand.cpp | 41 +- libc/utils/HdrGen/PublicAPICommand.h | 2 +- libc/utils/LibcTableGenUtil/APIIndexer.cpp | 26 +- libc/utils/LibcTableGenUtil/APIIndexer.h | 48 +- libc/utils/MPFRWrapper/CMakeLists.txt | 6 +- libc/utils/gpu/server/CMakeLists.txt | 1 - libclc/CMakeLists.txt | 26 +- libcxx/.clang-format | 2 + libcxx/cmake/caches/AMDGPU.cmake | 2 +- libcxx/cmake/caches/NVPTX.cmake | 2 +- libcxx/docs/Contributing.rst | 2 +- libcxx/docs/ReleaseNotes/19.rst | 1 - libcxx/docs/ReleaseNotes/20.rst | 49 +- libcxx/docs/Status/Cxx17Issues.csv | 2 +- libcxx/docs/Status/Cxx17Papers.csv | 2 +- libcxx/docs/Status/Cxx20Issues.csv | 4 +- libcxx/docs/Status/Cxx20Papers.csv | 8 +- libcxx/docs/Status/Cxx23Papers.csv | 2 +- libcxx/docs/Status/Cxx2cIssues.csv | 2 +- libcxx/docs/TestingLibcxx.rst | 2 +- libcxx/docs/UserDocumentation.rst | 6 +- libcxx/include/CMakeLists.txt | 12 +- libcxx/include/__algorithm/adjacent_find.h | 6 +- libcxx/include/__algorithm/all_of.h | 2 +- libcxx/include/__algorithm/any_of.h | 2 +- libcxx/include/__algorithm/binary_search.h | 4 +- libcxx/include/__algorithm/copy.h | 2 - libcxx/include/__algorithm/copy_backward.h | 2 - libcxx/include/__algorithm/count.h | 5 +- libcxx/include/__algorithm/count_if.h | 2 +- libcxx/include/__algorithm/equal.h | 18 +- libcxx/include/__algorithm/equal_range.h | 6 +- libcxx/include/__algorithm/find.h | 6 +- libcxx/include/__algorithm/find_end.h | 8 +- libcxx/include/__algorithm/find_first_of.h | 4 +- libcxx/include/__algorithm/find_if.h | 2 +- libcxx/include/__algorithm/find_if_not.h | 2 +- libcxx/include/__algorithm/fold.h | 1 - libcxx/include/__algorithm/includes.h | 6 +- libcxx/include/__algorithm/inplace_merge.h | 24 +- libcxx/include/__algorithm/is_heap.h | 4 +- libcxx/include/__algorithm/is_heap_until.h | 4 +- libcxx/include/__algorithm/is_partitioned.h | 2 +- libcxx/include/__algorithm/is_permutation.h | 14 +- libcxx/include/__algorithm/is_sorted.h | 4 +- libcxx/include/__algorithm/is_sorted_until.h | 4 +- .../__algorithm/lexicographical_compare.h | 5 +- libcxx/include/__algorithm/lower_bound.h | 12 +- libcxx/include/__algorithm/make_projected.h | 1 - libcxx/include/__algorithm/max.h | 8 +- libcxx/include/__algorithm/max_element.h | 4 +- libcxx/include/__algorithm/min.h | 8 +- libcxx/include/__algorithm/min_element.h | 6 +- libcxx/include/__algorithm/minmax.h | 8 +- libcxx/include/__algorithm/minmax_element.h | 6 +- libcxx/include/__algorithm/mismatch.h | 24 +- libcxx/include/__algorithm/move.h | 2 - libcxx/include/__algorithm/move_backward.h | 2 - libcxx/include/__algorithm/none_of.h | 2 +- .../include/__algorithm/partial_sort_copy.h | 2 +- libcxx/include/__algorithm/partition.h | 1 - libcxx/include/__algorithm/pstl.h | 2 +- libcxx/include/__algorithm/ranges_ends_with.h | 1 - libcxx/include/__algorithm/ranges_find_last.h | 1 - libcxx/include/__algorithm/ranges_generate.h | 2 +- .../include/__algorithm/ranges_generate_n.h | 2 +- libcxx/include/__algorithm/ranges_minmax.h | 1 - libcxx/include/__algorithm/ranges_partition.h | 1 - libcxx/include/__algorithm/remove.h | 2 +- libcxx/include/__algorithm/remove_if.h | 2 +- libcxx/include/__algorithm/search.h | 6 +- libcxx/include/__algorithm/search_n.h | 7 +- libcxx/include/__algorithm/set_difference.h | 1 + libcxx/include/__algorithm/set_intersection.h | 7 +- libcxx/include/__algorithm/simd_utils.h | 8 +- libcxx/include/__algorithm/sort.h | 3 - libcxx/include/__algorithm/stable_partition.h | 23 +- libcxx/include/__algorithm/stable_sort.h | 12 +- .../uniform_random_bit_generator_adaptor.h | 2 +- libcxx/include/__algorithm/unique.h | 6 +- libcxx/include/__algorithm/upper_bound.h | 5 +- libcxx/include/__assert | 56 +- libcxx/include/__atomic/atomic.h | 2 - libcxx/include/__atomic/atomic_ref.h | 1 - libcxx/include/__bit/bit_cast.h | 2 +- libcxx/include/__bit/countl.h | 6 +- libcxx/include/__bit/countr.h | 8 +- libcxx/include/__charconv/to_chars_integral.h | 1 - libcxx/include/__chrono/day.h | 2 +- libcxx/include/__chrono/exception.h | 4 +- libcxx/include/__chrono/formatter.h | 169 +- libcxx/include/__chrono/leap_second.h | 4 +- libcxx/include/__chrono/month.h | 2 +- libcxx/include/__chrono/monthday.h | 2 +- libcxx/include/__chrono/ostream.h | 75 +- .../include/__chrono/parser_std_format_spec.h | 27 +- libcxx/include/__chrono/tzdb.h | 3 - libcxx/include/__chrono/tzdb_list.h | 1 - libcxx/include/__chrono/year.h | 2 +- libcxx/include/__chrono/year_month.h | 2 +- libcxx/include/__chrono/year_month_day.h | 2 +- libcxx/include/__chrono/zoned_time.h | 4 +- libcxx/include/__compare/ordering.h | 45 +- libcxx/include/__concepts/predicate.h | 2 +- libcxx/include/__config | 55 +- libcxx/include/__configuration/abi.h | 31 - libcxx/include/__cstddef/byte.h | 85 - libcxx/include/__cstddef/max_align_t.h | 27 - libcxx/include/__cstddef/nullptr_t.h | 25 - libcxx/include/__cstddef/ptrdiff_t.h | 25 - libcxx/include/__cstddef/size_t.h | 25 - libcxx/include/__exception/exception_ptr.h | 2 +- libcxx/include/__exception/nested_exception.h | 10 +- libcxx/include/__exception/operations.h | 4 +- libcxx/include/__exception/terminate.h | 2 +- libcxx/include/__expected/expected.h | 2 - libcxx/include/__filesystem/directory_entry.h | 45 +- .../include/__filesystem/filesystem_error.h | 4 +- libcxx/include/__filesystem/path.h | 3 +- libcxx/include/__format/format_arg_store.h | 1 - libcxx/include/__format/format_error.h | 2 +- .../include/__format/parser_std_format_spec.h | 4 +- libcxx/include/__format/write_escaped.h | 1 - libcxx/include/__functional/bind.h | 2 +- libcxx/include/__functional/function.h | 29 +- libcxx/include/__functional/hash.h | 1 - libcxx/include/__functional/identity.h | 2 +- libcxx/include/__functional/invoke.h | 1 - libcxx/include/__functional/mem_fn.h | 2 +- libcxx/include/__functional/perfect_forward.h | 1 - .../include/__functional/reference_wrapper.h | 2 +- .../include/__functional/weak_result_type.h | 2 +- libcxx/include/__fwd/array.h | 9 +- libcxx/include/__fwd/byte.h | 26 - libcxx/include/__fwd/complex.h | 2 +- libcxx/include/__fwd/get.h | 24 - libcxx/include/__fwd/pair.h | 2 +- libcxx/include/__fwd/span.h | 2 +- libcxx/include/__fwd/subrange.h | 2 +- libcxx/include/__fwd/tuple.h | 2 +- libcxx/include/__fwd/variant.h | 77 - libcxx/include/__hash_table | 173 +- libcxx/include/__iterator/common_iterator.h | 3 +- libcxx/include/__iterator/concepts.h | 3 +- libcxx/include/__iterator/counted_iterator.h | 4 +- libcxx/include/__iterator/iterator_traits.h | 2 - .../include/__iterator/ostreambuf_iterator.h | 5 +- libcxx/include/__iterator/wrap_iter.h | 1 - .../__locale_dir/locale_base_api/ibm.h | 4 +- libcxx/include/__math/abs.h | 8 +- libcxx/include/__math/copysign.h | 7 +- libcxx/include/__math/hypot.h | 5 +- libcxx/include/__math/min_max.h | 16 +- libcxx/include/__math/remainder.h | 1 + libcxx/include/__math/roots.h | 8 +- libcxx/include/__math/rounding_functions.h | 48 +- libcxx/include/__math/traits.h | 73 +- libcxx/include/__mdspan/extents.h | 2 +- libcxx/include/__mdspan/layout_left.h | 1 - libcxx/include/__mdspan/layout_right.h | 1 - libcxx/include/__mdspan/layout_stride.h | 5 - libcxx/include/__memory/allocate_at_least.h | 2 +- libcxx/include/__memory/allocator.h | 4 +- libcxx/include/__memory/allocator_traits.h | 7 +- libcxx/include/__memory/assume_aligned.h | 2 +- libcxx/include/__memory/compressed_pair.h | 203 +- libcxx/include/__memory/inout_ptr.h | 1 - libcxx/include/__memory/out_ptr.h | 1 - libcxx/include/__memory/pointer_traits.h | 2 - libcxx/include/__memory/shared_ptr.h | 48 +- libcxx/include/__memory/temporary_buffer.h | 53 +- .../__memory/uninitialized_algorithms.h | 1 - libcxx/include/__memory/unique_ptr.h | 125 +- .../__memory/unique_temporary_buffer.h | 92 - libcxx/include/__memory/uses_allocator.h | 1 - libcxx/include/__mutex/lock_guard.h | 4 +- libcxx/include/__mutex/unique_lock.h | 16 +- libcxx/include/__ostream/basic_ostream.h | 247 +- libcxx/include/__ostream/print.h | 79 +- libcxx/include/__pstl/backend.h | 24 +- libcxx/include/__pstl/backend_fwd.h | 16 +- libcxx/include/__pstl/backends/default.h | 4 - libcxx/include/__pstl/backends/libdispatch.h | 12 +- libcxx/include/__pstl/backends/serial.h | 4 - libcxx/include/__pstl/backends/std_thread.h | 4 - libcxx/include/__pstl/cpu_algos/any_of.h | 4 - libcxx/include/__pstl/cpu_algos/cpu_traits.h | 4 - libcxx/include/__pstl/cpu_algos/fill.h | 4 - libcxx/include/__pstl/cpu_algos/find_if.h | 4 - libcxx/include/__pstl/cpu_algos/for_each.h | 4 - libcxx/include/__pstl/cpu_algos/merge.h | 4 - libcxx/include/__pstl/cpu_algos/stable_sort.h | 4 - libcxx/include/__pstl/cpu_algos/transform.h | 4 - .../__pstl/cpu_algos/transform_reduce.h | 4 - libcxx/include/__pstl/dispatch.h | 4 - libcxx/include/__pstl/handle_exception.h | 4 - .../__random/mersenne_twister_engine.h | 1 - libcxx/include/__random/seed_seq.h | 2 - .../__random/subtract_with_carry_engine.h | 1 - .../__random/uniform_random_bit_generator.h | 2 +- libcxx/include/__ranges/elements_view.h | 3 +- libcxx/include/__ranges/range_adaptor.h | 2 - libcxx/include/__ranges/subrange.h | 1 - libcxx/include/__ranges/transform_view.h | 1 - libcxx/include/__split_buffer | 27 +- libcxx/include/__std_clang_module | 44 +- .../include/__stop_token/atomic_unique_lock.h | 8 +- libcxx/include/__stop_token/stop_callback.h | 6 +- libcxx/include/__stop_token/stop_source.h | 6 +- libcxx/include/__stop_token/stop_token.h | 4 +- libcxx/include/__string/char_traits.h | 1 - .../include/__string/constexpr_c_functions.h | 2 - .../__support/xlocale/__nop_locale_mgmt.h | 6 +- libcxx/include/__system_error/system_error.h | 4 +- libcxx/include/__thread/jthread.h | 8 +- libcxx/include/__thread/this_thread.h | 5 - libcxx/include/__thread/thread.h | 21 +- libcxx/include/__tree | 76 +- libcxx/include/__tuple/find_index.h | 2 +- libcxx/include/__tuple/make_tuple_types.h | 2 +- libcxx/include/__tuple/sfinae_helpers.h | 2 +- libcxx/include/__tuple/tuple_element.h | 2 +- libcxx/include/__tuple/tuple_indices.h | 2 +- libcxx/include/__tuple/tuple_like_ext.h | 2 +- .../include/__tuple/tuple_like_no_subrange.h | 2 +- libcxx/include/__tuple/tuple_size.h | 4 +- .../include/__type_traits/aligned_storage.h | 2 +- libcxx/include/__type_traits/aligned_union.h | 2 +- libcxx/include/__type_traits/alignment_of.h | 2 +- libcxx/include/__type_traits/datasizeof.h | 30 +- libcxx/include/__type_traits/extent.h | 2 +- libcxx/include/__type_traits/is_allocator.h | 2 +- libcxx/include/__type_traits/is_array.h | 2 +- .../include/__type_traits/is_bounded_array.h | 2 +- .../__type_traits/is_nothrow_destructible.h | 2 +- .../include/__type_traits/is_null_pointer.h | 2 +- libcxx/include/__type_traits/is_swappable.h | 3 +- ...s_trivially_lexicographically_comparable.h | 2 +- .../noexcept_move_assign_container.h | 6 +- libcxx/include/__type_traits/rank.h | 2 +- .../__type_traits/remove_all_extents.h | 2 +- libcxx/include/__type_traits/remove_extent.h | 2 +- libcxx/include/__type_traits/result_of.h | 2 +- libcxx/include/__type_traits/type_list.h | 2 +- libcxx/include/__utility/forward.h | 4 +- libcxx/include/__utility/in_place.h | 1 - libcxx/include/__utility/move.h | 4 +- libcxx/include/__utility/pair.h | 1 - libcxx/include/__utility/swap.h | 1 - libcxx/include/__utility/unreachable.h | 2 +- libcxx/include/__verbose_abort | 2 +- libcxx/include/algorithm | 9 - libcxx/include/any | 3 +- libcxx/include/array | 5 +- libcxx/include/atomic | 4 + libcxx/include/barrier | 4 +- libcxx/include/bitset | 1 - libcxx/include/chrono | 2 +- libcxx/include/complex | 56 +- libcxx/include/condition_variable | 8 +- libcxx/include/cstddef | 83 +- libcxx/include/cstdio | 2 +- libcxx/include/cstdlib | 2 +- libcxx/include/cstring | 2 +- libcxx/include/ctime | 2 +- libcxx/include/cuchar | 2 +- libcxx/include/cwchar | 2 +- libcxx/include/deque | 60 +- libcxx/include/experimental/__config | 45 + .../include/experimental/__simd/aligned_tag.h | 2 +- .../include/experimental/__simd/declaration.h | 9 +- .../include/experimental/__simd/reference.h | 3 +- libcxx/include/experimental/__simd/scalar.h | 3 +- libcxx/include/experimental/__simd/simd.h | 3 +- .../include/experimental/__simd/simd_mask.h | 3 +- libcxx/include/experimental/__simd/traits.h | 2 +- libcxx/include/experimental/__simd/utility.h | 2 +- libcxx/include/experimental/__simd/vec_ext.h | 7 +- libcxx/include/experimental/iterator | 4 +- libcxx/include/experimental/memory | 2 +- libcxx/include/experimental/propagate_const | 2 +- libcxx/include/experimental/simd | 2 +- libcxx/include/experimental/type_traits | 2 +- libcxx/include/experimental/utility | 2 +- libcxx/include/forward_list | 52 +- libcxx/include/fstream | 10 +- libcxx/include/future | 44 +- libcxx/include/iomanip | 53 +- libcxx/include/ios | 2 +- libcxx/include/istream | 235 +- libcxx/include/limits | 126 +- libcxx/include/list | 165 +- libcxx/include/map | 11 +- libcxx/include/math.h | 8 +- libcxx/include/memory | 4 +- libcxx/include/module.modulemap | 172 +- libcxx/include/new | 26 +- libcxx/include/optional | 5 +- libcxx/include/ostream | 20 +- libcxx/include/queue | 8 +- libcxx/include/regex | 4 +- libcxx/include/scoped_allocator | 4 +- libcxx/include/set | 13 +- libcxx/include/span | 2 +- libcxx/include/sstream | 177 +- libcxx/include/stack | 4 +- libcxx/include/stdatomic.h | 14 +- libcxx/include/stdexcept | 18 +- libcxx/include/stdlib.h | 10 +- libcxx/include/streambuf | 37 +- libcxx/include/string | 168 +- libcxx/include/string_view | 2 +- libcxx/include/syncstream | 91 +- libcxx/include/tuple | 5 +- libcxx/include/type_traits | 1 + libcxx/include/typeinfo | 3 +- libcxx/include/unordered_map | 13 +- libcxx/include/unordered_set | 15 +- libcxx/include/variant | 35 +- libcxx/include/vector | 117 +- libcxx/include/version | 2 +- libcxx/include/wchar.h | 15 +- libcxx/include/wctype.h | 5 + libcxx/modules/std.compat.cppm.in | 8 +- libcxx/modules/std.cppm.in | 36 +- libcxx/modules/std/stop_token.inc | 4 +- libcxx/modules/std/thread.inc | 2 + libcxx/modules/std/type_traits.inc | 6 - libcxx/src/any.cpp | 2 +- libcxx/src/atomic.cpp | 4 +- libcxx/src/filesystem/directory_iterator.cpp | 12 +- libcxx/src/filesystem/error.h | 2 +- libcxx/src/filesystem/file_descriptor.h | 17 +- libcxx/src/filesystem/format_string.h | 2 +- libcxx/src/filesystem/operations.cpp | 6 +- libcxx/src/filesystem/posix_compat.h | 2 +- libcxx/src/filesystem/time_utils.h | 2 +- libcxx/src/include/atomic_support.h | 2 +- libcxx/src/include/config_elast.h | 2 - libcxx/src/include/overridable_function.h | 5 - libcxx/src/locale.cpp | 2 +- libcxx/src/memory_resource.cpp | 2 +- libcxx/src/optional.cpp | 2 +- libcxx/src/stdexcept.cpp | 2 +- libcxx/src/string.cpp | 4 +- libcxx/src/support/ibm/mbsnrtowcs.cpp | 4 +- libcxx/src/support/ibm/wcsnrtombs.cpp | 4 +- libcxx/src/support/ibm/xlocale_zos.cpp | 16 +- .../support/runtime/exception_fallback.ipp | 15 +- libcxx/src/support/runtime/exception_msvc.ipp | 13 +- .../runtime/exception_pointer_cxxabi.ipp | 4 +- .../runtime/exception_pointer_glibcxx.ipp | 6 +- .../runtime/exception_pointer_msvc.ipp | 4 +- .../exception_pointer_unimplemented.ipp | 28 +- libcxx/src/support/win32/support.cpp | 12 +- libcxx/src/support/win32/thread_win32.cpp | 2 +- libcxx/src/system_error.cpp | 2 +- libcxx/src/vector.cpp | 4 +- libcxx/test/benchmarks/ContainerBenchmarks.h | 2 +- libcxx/test/benchmarks/VariantBenchmarks.h | 2 +- libcxx/test/benchmarks/format.bench.cpp | 12 +- libcxx/test/benchmarks/format_to.bench.cpp | 44 +- libcxx/test/benchmarks/format_to_n.bench.cpp | 44 +- .../test/benchmarks/formatted_size.bench.cpp | 12 +- .../test/benchmarks/formatter_int.bench.cpp | 16 +- ...exicographical_compare_three_way.bench.cpp | 18 +- .../std_format_spec_string_unicode.bench.cpp | 33 +- ...ormat_spec_string_unicode_escape.bench.cpp | 33 +- libcxx/test/benchmarks/to_chars.bench.cpp | 8 +- .../test/benchmarks/variant_visit_1.bench.cpp | 38 +- .../test/benchmarks/variant_visit_2.bench.cpp | 28 +- .../test/benchmarks/variant_visit_3.bench.cpp | 24 +- .../make.heap/complexity.pass.cpp | 1 - ...obust_against_copying_comparators.pass.cpp | 1 - ...obust_against_copying_projections.pass.cpp | 1 - ...obust_against_copying_comparators.pass.cpp | 1 - ...t_cpp20_hostile_iterators.compile.pass.cpp | 1 - ...compatible_with_stdatomic.compile.pass.cpp | 22 - .../incompatible_with_stdatomic.verify.cpp | 22 + .../dont_hijack_header.compile.pass.cpp | 23 + .../test/libcxx/clang_modules_include.gen.py | 4 +- libcxx/test/libcxx/clang_tidy.gen.py | 4 +- .../unord.map/abi.compile.pass.cpp | 135 - .../unord.set/abi.compile.pass.cpp | 133 - .../sequences/deque/abi.compile.pass.cpp | 2 - .../vector.bool/abi.compile.pass.cpp | 3 - .../sequences/vector/abi.compile.pass.cpp | 1 - .../containers/unord/next_pow2.pass.cpp | 3 +- .../containers/unord/next_prime.pass.cpp | 1 - .../missing_hash_specialization.verify.cpp | 9 +- .../depr.adaptors.cxx1z.pass.cpp | 1 - .../diagnostics/chrono.nodiscard.verify.cpp | 6 +- .../diagnostics/memory.nodiscard.verify.cpp | 1 - .../diagnostics/ranges.nodiscard.verify.cpp | 1 - libcxx/test/libcxx/double_include.gen.py | 4 +- .../fexperimental-library.compile.pass.cpp | 4 + .../feature_test_macro/ftm_metadata.sh.py | 5 - .../feature_test_macro/implemented_ftms.sh.py | 5 - .../feature_test_macro/standard_ftms.sh.py | 6 - .../libcxx/feature_test_macro/test_data.json | 30 - .../feature_test_macro/version_header.sh.py | 9 +- .../version_header_implementation.sh.py | 209 +- libcxx/test/libcxx/header_inclusions.gen.py | 4 +- .../cpp20_iter_concepts.pass.cpp | 5 +- libcxx/test/libcxx/libcpp_version.gen.py | 4 +- .../compressed_pair/compressed_pair.pass.cpp | 52 + libcxx/test/libcxx/no_assert_include.gen.py | 4 +- .../c.math/constexpr-cxx23-clang.pass.cpp | 7 - .../c.math/constexpr-cxx23-gcc.pass.cpp | 6 +- .../has_arrow.compile.pass.cpp | 1 - .../basic.string/alignof.compile.pass.cpp | 1 - .../basic.string/sizeof.compile.pass.cpp | 1 - .../test/libcxx/system_reserved_names.gen.py | 4 +- libcxx/test/libcxx/transitive_includes.gen.py | 4 +- .../test/libcxx/transitive_includes/cxx03.csv | 1633 +-- .../test/libcxx/transitive_includes/cxx11.csv | 1626 +-- .../test/libcxx/transitive_includes/cxx14.csv | 1677 +-- .../test/libcxx/transitive_includes/cxx17.csv | 1642 +-- .../test/libcxx/transitive_includes/cxx20.csv | 1615 +-- .../test/libcxx/transitive_includes/cxx23.csv | 616 +- .../test/libcxx/transitive_includes/cxx26.csv | 617 +- .../test/libcxx/transitive_includes_to_csv.py | 12 +- .../type_traits/datasizeof.compile.pass.cpp | 24 +- .../format.arg/arg_t.compile.pass.cpp | 1 - .../format.string.std/escaped_output.pass.cpp | 5 +- .../func.require/bullet_1_2_3.pass.cpp | 3 +- .../func.require/bullet_4_5_6.pass.cpp | 3 +- .../function_type_default_deleter.verify.cpp | 1 - .../libcxx.control_block_layout.pass.cpp | 121 +- .../libcxx/utilities/meta/meta_base.pass.cpp | 1 - .../__murmur2_or_cityhash.abi-v1.pass.cpp | 1 - .../alg.partitions/stable_partition.pass.cpp | 6 +- .../random_shuffle_urng.pass.cpp | 3 +- .../mismatch/mismatch.pass.cpp | 2 - .../sort.heap/complexity.pass.cpp | 1 - .../sort.heap/ranges_sort_heap.pass.cpp | 2 - .../alg.merge/inplace_merge_comp.pass.cpp | 3 +- .../alg.sorting/alg.merge/pstl.merge.pass.cpp | 1 - .../alg.sort/sort/pstl.sort.pass.cpp | 1 - .../alg.sort/stable.sort/stable_sort.pass.cpp | 1 - ...es_robust_against_omitting_invoke.pass.cpp | 2 - ...nst_proxy_iterators_lifetime_bugs.pass.cpp | 2 - ...robust_re_difference_type.compile.pass.cpp | 1 - .../atomics.ref/bitwise_and_assign.pass.cpp | 1 - .../atomics.ref/bitwise_or_assign.pass.cpp | 1 - .../atomics.ref/bitwise_xor_assign.pass.cpp | 1 - .../atomics/atomics.ref/fetch_add.pass.cpp | 1 - .../atomics/atomics.ref/fetch_and.pass.cpp | 1 - .../std/atomics/atomics.ref/fetch_or.pass.cpp | 3 +- .../atomics/atomics.ref/fetch_sub.pass.cpp | 1 - .../atomics/atomics.ref/fetch_xor.pass.cpp | 3 +- .../atomics.ref/increment_decrement.pass.cpp | 1 - .../atomics.ref/member_types.compile.pass.cpp | 58 +- .../operator_minus_equals.pass.cpp | 1 - .../atomics.ref/operator_plus_equals.pass.cpp | 3 +- .../atomics.types.float/assign.pass.cpp | 1 - .../atomics.types.float/exchange.pass.cpp | 1 - .../atomics.types.float/fetch_add.pass.cpp | 1 - .../atomics.types.float/fetch_sub.pass.cpp | 1 - .../atomics.types.float/load.pass.cpp | 3 +- .../operator.float.pass.cpp | 1 - .../operator.minus_equals.pass.cpp | 1 - .../operator.plus_equals.pass.cpp | 1 - .../atomics.types.float/wait.pass.cpp | 1 - .../cstdint_typedefs.pass.cpp | 3 +- .../integral_typedefs.pass.cpp | 1 - .../stdatomic.h.syn/types.compile.pass.cpp | 2 - libcxx/test/std/atomics/types.pass.cpp | 1 - .../associative/map/map.cons/move.pass.cpp | 4 +- .../map.modifiers/insert_node_type.pass.cpp | 25 - .../map.modifiers/insert_or_assign.pass.cpp | 1 - .../map/map.modifiers/try.emplace.pass.cpp | 1 - .../multimap/multimap.cons/move.pass.cpp | 4 +- .../multiset/multiset.cons/copy.pass.cpp | 1 - .../multiset.cons/copy_alloc.pass.cpp | 1 - .../multiset.cons/copy_assign.pass.cpp | 1 - .../initializer_list_compare.pass.cpp | 2 - .../initializer_list_compare_alloc.pass.cpp | 2 - .../multiset/multiset.cons/move.pass.cpp | 4 +- .../associative/set/insert_node_type.pass.cpp | 25 - .../associative/set/set.cons/copy.pass.cpp | 1 - .../set/set.cons/copy_alloc.pass.cpp | 1 - .../set/set.cons/copy_assign.pass.cpp | 1 - .../initializer_list_compare.pass.cpp | 2 - .../initializer_list_compare_alloc.pass.cpp | 2 - .../associative/set/set.cons/move.pass.cpp | 4 +- .../priqueue.cons/dtor_noexcept.pass.cpp | 1 - .../queue/queue.cons/dtor_noexcept.pass.cpp | 1 - .../stack/stack.cons/dtor_noexcept.pass.cpp | 1 - .../allocator_move.pass.cpp | 17 +- .../sequences/deque/deque.cons/move.pass.cpp | 2 +- .../vector.bool/enabled_hash.pass.cpp | 4 +- .../sequences/vector.bool/move.pass.cpp | 17 +- .../vector/vector.cons/move.pass.cpp | 17 +- .../insert_node_type.pass.cpp | 25 - .../unord/unord.set/insert_node_type.pass.cpp | 25 - .../views/mdspan/CustomTestLayouts.h | 1 - .../views/mdspan/extents/comparison.pass.cpp | 5 +- .../views/mdspan/extents/conversion.pass.cpp | 5 +- .../views/mdspan/extents/ctad.pass.cpp | 1 - .../views/mdspan/extents/dextents.pass.cpp | 1 - .../views/mdspan/extents/dims.pass.cpp | 1 - .../mdspan/extents/index_type.verify.cpp | 1 - .../views/mdspan/extents/obs_static.pass.cpp | 1 - .../views/mdspan/extents/types.pass.cpp | 5 +- .../mdspan/layout_left/comparison.pass.cpp | 5 +- .../mdspan/layout_left/ctor.default.pass.cpp | 1 - .../mdspan/layout_left/ctor.extents.pass.cpp | 1 - .../layout_left/ctor.layout_right.pass.cpp | 3 +- .../layout_left/ctor.layout_stride.pass.cpp | 4 +- .../mdspan/layout_left/ctor.mapping.pass.cpp | 3 +- .../layout_left/index_operator.pass.cpp | 2 - .../mdspan/layout_left/properties.pass.cpp | 6 +- .../layout_left/required_span_size.pass.cpp | 2 +- .../layout_left/static_requirements.pass.cpp | 6 +- .../views/mdspan/layout_left/stride.pass.cpp | 4 +- .../mdspan/layout_right/comparison.pass.cpp | 5 +- .../mdspan/layout_right/ctor.default.pass.cpp | 1 - .../mdspan/layout_right/ctor.extents.pass.cpp | 1 - .../layout_right/ctor.layout_left.pass.cpp | 3 +- .../layout_right/ctor.layout_stride.pass.cpp | 4 +- .../mdspan/layout_right/ctor.mapping.pass.cpp | 3 +- .../layout_right/index_operator.pass.cpp | 2 - .../mdspan/layout_right/properties.pass.cpp | 6 +- .../layout_right/required_span_size.pass.cpp | 1 - .../layout_right/static_requirements.pass.cpp | 6 +- .../views/mdspan/layout_right/stride.pass.cpp | 4 +- .../mdspan/layout_stride/comparison.pass.cpp | 5 +- .../layout_stride/ctor.default.pass.cpp | 1 - .../layout_stride/ctor.extents_array.pass.cpp | 3 - .../layout_stride/ctor.extents_span.pass.cpp | 3 - .../ctor.strided_mapping.pass.cpp | 3 +- .../mdspan/layout_stride/deduction.pass.cpp | 12 +- .../layout_stride/index_operator.pass.cpp | 3 - .../is_exhaustive_corner_case.pass.cpp | 6 +- .../mdspan/layout_stride/properties.pass.cpp | 6 +- .../layout_stride/required_span_size.pass.cpp | 2 - .../static_requirements.pass.cpp | 6 +- .../mdspan/layout_stride/stride.pass.cpp | 4 +- .../views/mdspan/mdspan/assign.pass.cpp | 5 +- .../views/mdspan/mdspan/conversion.pass.cpp | 5 +- .../views/mdspan/mdspan/ctor.copy.pass.cpp | 5 +- .../views/mdspan/mdspan/ctor.default.pass.cpp | 5 +- .../mdspan/mdspan/ctor.dh_array.pass.cpp | 3 +- .../mdspan/mdspan/ctor.dh_extents.pass.cpp | 5 +- .../mdspan/mdspan/ctor.dh_integers.pass.cpp | 3 +- .../views/mdspan/mdspan/ctor.dh_map.pass.cpp | 5 +- .../mdspan/mdspan/ctor.dh_map_acc.pass.cpp | 5 +- .../views/mdspan/mdspan/ctor.dh_span.pass.cpp | 3 +- .../views/mdspan/mdspan/ctor.move.pass.cpp | 5 +- .../views/mdspan/mdspan/deduction.pass.cpp | 5 +- .../mdspan/mdspan/index_operator.pass.cpp | 1 - .../views/mdspan/mdspan/move.pass.cpp | 5 +- .../views/mdspan/mdspan/properties.pass.cpp | 5 +- .../views/mdspan/mdspan/swap.pass.cpp | 5 +- .../views/mdspan/mdspan/types.pass.cpp | 5 +- .../std/depr/depr.c.headers/math_h.pass.cpp | 2 +- .../std/depr/depr.c.headers/stdlib_h.pass.cpp | 3 +- .../depr.c.headers/wchar_h.compile.pass.cpp | 2 +- .../depr.c.headers/wctype_h.compile.pass.cpp | 2 +- .../syserr/syserr.hash/enabled_hash.pass.cpp | 4 +- .../syserr/syserr.hash/error_code.pass.cpp | 13 +- .../syserr.hash/error_condition.pass.cpp | 13 +- .../memory/memory.observer.ptr/hash.pass.cpp | 3 +- .../reference_arith_operators.pass.cpp | 4 +- .../reference_bitwise_operators.pass.cpp | 4 +- .../move_assign.pass.cpp | 4 +- .../move_assign_convertible.pass.cpp | 4 +- ...ssign_convertible_propagate_const.pass.cpp | 4 +- ...ertible_propagate_const.move_ctor.pass.cpp | 4 +- .../propagate_const.ctors/move_ctor.pass.cpp | 4 +- .../propagate_const.nonmembers/hash.pass.cpp | 5 +- .../equal_to.pass.cpp | 4 +- .../greater.pass.cpp | 4 +- .../greater_equal.pass.cpp | 4 +- .../less.pass.cpp | 4 +- .../less_equal.pass.cpp | 4 +- .../not_equal_to.pass.cpp | 4 +- .../propagate_const.relops/equal.pass.cpp | 4 +- .../propagate_const.relops/not_equal.pass.cpp | 4 +- .../path.member/path.hash_enabled.pass.cpp | 2 +- .../cache_refresh_iter.pass.cpp | 187 - .../last_write_time.pass.cpp | 2 +- .../iterator.basic/iterator.pass.cpp | 1 - .../iterator.traits/const_pointer.pass.cpp | 1 - .../const_volatile_pointer.pass.cpp | 1 - .../iterator.traits/empty.compile.pass.cpp | 132 - .../iterator.traits/empty.verify.cpp | 123 + .../iterator.traits/pointer.pass.cpp | 1 - .../iterator.traits/volatile_pointer.pass.cpp | 1 - .../incrementable_traits.compile.pass.cpp | 1 - .../sentinel_for.compile.pass.cpp | 1 - .../reverse.iter.cmp/sfinae.compile.pass.cpp | 1 - .../three_way_comparable.compile.pass.cpp | 1 - ...three_way_comparable_with.compile.pass.cpp | 1 - .../coroutine.handle.con/assign.pass.cpp | 3 +- .../coroutine.handle.con/construct.pass.cpp | 3 +- .../destroying_delete_t_declaration.pass.cpp | 2 - .../stop_token.version.compile.pass.cpp | 12 +- .../thread.version.compile.pass.cpp | 12 +- .../version.version.compile.pass.cpp | 12 +- .../support.runtime/cstdlib.pass.cpp | 3 +- .../support.types/nullptr_t.pass.cpp | 3 +- .../niebloid.compile.pass.cpp | 2 - .../put_double.hex.pass.cpp | 402 +- .../put_long_double.hex.pass.cpp | 402 +- .../conversions.string/ctor_codecvt.pass.cpp | 3 +- .../bit/bit.pow.two/bit_ceil.pass.cpp | 1 - .../bit/bit.pow.two/bit_floor.pass.cpp | 1 - .../bit/bit.pow.two/bit_width.pass.cpp | 1 - .../bit/bit.pow.two/has_single_bit.pass.cpp | 1 - .../bit/bitops.count/countl_one.pass.cpp | 1 - .../bit/bitops.count/countl_zero.pass.cpp | 1 - .../bit/bitops.count/countr_one.pass.cpp | 1 - .../bit/bitops.count/countr_zero.pass.cpp | 1 - .../bit/bitops.count/popcount.pass.cpp | 1 - .../std/numerics/bit/bitops.rot/rotl.pass.cpp | 1 - .../std/numerics/bit/bitops.rot/rotr.pass.cpp | 1 - .../test/std/numerics/c.math/cmath.pass.cpp | 5 +- .../test/std/numerics/c.math/signbit.pass.cpp | 91 - .../rand.adapt.disc/result_type.pass.cpp | 1 - .../rand.dist.bern.bernoulli/eval.pass.cpp | 5 +- .../eval_param.pass.cpp | 5 +- .../rand.dist.bern.bin/eval.PR44847.pass.cpp | 5 +- .../rand.dist.bern.bin/eval.pass.cpp | 1 - .../rand.dist.bern.bin/eval_param.pass.cpp | 3 +- .../rand.dist.bern.geo/eval.pass.cpp | 3 +- .../rand.dist.bern.geo/eval_param.pass.cpp | 3 +- .../rand.dist.bern.negbin/eval.pass.cpp | 3 +- .../rand.dist.bern.negbin/eval_param.pass.cpp | 3 +- .../rand.dist.norm.chisq/eval.pass.cpp | 5 +- .../rand.dist.norm.chisq/eval_param.pass.cpp | 5 +- .../rand.dist.norm.lognormal/eval.pass.cpp | 3 +- .../eval_param.pass.cpp | 3 +- .../rand.dist.norm.normal/eval.pass.cpp | 5 +- .../rand.dist.norm.normal/eval_param.pass.cpp | 5 +- .../rand.dist.norm.t/eval.pass.cpp | 3 +- .../rand.dist.norm.t/eval_param.pass.cpp | 3 +- .../rand.dist.pois.exp/eval.pass.cpp | 5 +- .../rand.dist.pois.exp/eval_param.pass.cpp | 5 +- .../rand.dist.pois.extreme/eval.pass.cpp | 3 +- .../eval_param.pass.cpp | 3 +- .../rand.dist.pois.gamma/eval.pass.cpp | 3 +- .../rand.dist.pois.gamma/eval_param.pass.cpp | 3 +- .../eval_param.pass.cpp | 3 +- .../rand.dist.pois.weibull/eval.pass.cpp | 5 +- .../eval_param.pass.cpp | 5 +- .../rand.dist.samp.pconst/eval.pass.cpp | 7 +- .../rand.dist.samp.pconst/eval_param.pass.cpp | 7 +- .../rand.dist.samp.plinear/eval.pass.cpp | 7 +- .../eval_param.pass.cpp | 7 +- .../rand.dist.uni.int/eval.pass.cpp | 3 +- .../rand.dist.uni.int/eval_param.pass.cpp | 5 +- .../rand.dist.uni.real/eval.pass.cpp | 5 +- .../rand.dist.uni.real/eval_param.pass.cpp | 5 +- .../rand.eng/rand.eng.lcong/copy.pass.cpp | 1 - .../rand.eng/rand.eng.lcong/default.pass.cpp | 1 - .../rand.eng/rand.eng.lcong/values.pass.cpp | 3 +- .../rand.eng.mers/result_type.pass.cpp | 1 - .../rand.eng.sub/result_type.pass.cpp | 1 - .../generate.mandates.verify.cpp | 1 - .../rand.util.seedseq/types.pass.cpp | 1 - .../basic.string.hash/enabled_hashes.pass.cpp | 16 +- .../std/strings/c.strings/cwchar.pass.cpp | 2 +- .../cwchar_include_order1.compile.verify.cpp | 2 +- .../cwchar_include_order2.compile.verify.cpp | 2 +- .../std/strings/c.strings/cwctype.pass.cpp | 2 +- .../string.view.hash/enabled_hashes.pass.cpp | 14 +- .../ctor2.compile.pass.cpp | 19 +- .../wait_for_token_pred.pass.cpp | 1 - .../wait_terminates.sh.cpp | 4 +- .../wait_token_pred.pass.cpp | 1 - .../wait_until_token_pred.pass.cpp | 1 - .../thread.jthread/cons.func.token.pass.cpp | 1 - .../stopcallback/dtor.pass.cpp | 1 - .../thread.thread.id/enabled_hashes.pass.cpp | 2 +- .../time.cal.day.members/decrement.pass.cpp | 3 +- .../time.cal.day.members/increment.pass.cpp | 3 +- .../time.cal.day.members/ok.pass.cpp | 3 +- .../plus_minus_equal.pass.cpp | 3 +- .../time.cal.day.nonmembers/minus.pass.cpp | 3 +- .../time.cal.day.nonmembers/plus.pass.cpp | 3 +- .../time.cal.md.members/day.pass.cpp | 3 +- .../time.cal.md.members/month.pass.cpp | 3 +- .../time.cal.md.members/ok.pass.cpp | 3 +- .../time.cal/time.cal.mdlast/month.pass.cpp | 3 +- .../time/time.cal/time.cal.mdlast/ok.pass.cpp | 3 +- .../time.cal.month.members/decrement.pass.cpp | 3 +- .../time.cal.month.members/increment.pass.cpp | 3 +- .../time.cal.month.members/ok.pass.cpp | 3 +- .../plus_minus_equal.pass.cpp | 3 +- .../time.cal.month.nonmembers/minus.pass.cpp | 3 +- .../time.cal.month.nonmembers/plus.pass.cpp | 3 +- .../time.cal.mwd.members/month.pass.cpp | 3 +- .../time.cal.mwd.members/ok.pass.cpp | 3 +- .../weekday_indexed.pass.cpp | 3 +- .../time.cal.mwdlast.members/month.pass.cpp | 3 +- .../time.cal.mwdlast.members/ok.pass.cpp | 3 +- .../weekday_last.pass.cpp | 3 +- .../time.cal.wdidx.members/index.pass.cpp | 3 +- .../time.cal.wdidx.members/ok.pass.cpp | 3 +- .../time.cal.wdidx.members/weekday.pass.cpp | 3 +- .../time.cal.wdlast.members/ok.pass.cpp | 3 +- .../time.cal.wdlast.members/weekday.pass.cpp | 3 +- .../c_encoding.pass.cpp | 3 +- .../ctor.local_days.pass.cpp | 3 +- .../ctor.sys_days.pass.cpp | 3 +- .../decrement.pass.cpp | 3 +- .../increment.pass.cpp | 3 +- .../iso_encoding.pass.cpp | 3 +- .../time.cal.weekday.members/ok.pass.cpp | 3 +- .../operator[].pass.cpp | 3 +- .../plus_minus_equal.pass.cpp | 3 +- .../minus.pass.cpp | 3 +- .../time.cal.weekday.nonmembers/plus.pass.cpp | 3 +- .../time.cal.year.members/decrement.pass.cpp | 3 +- .../time.cal.year.members/increment.pass.cpp | 3 +- .../time.cal.year.members/ok.pass.cpp | 3 +- .../time.cal.year.members/plus_minus.pass.cpp | 3 +- .../plus_minus_equal.pass.cpp | 3 +- .../time.cal.year.nonmembers/minus.pass.cpp | 3 +- .../time.cal.year.nonmembers/plus.pass.cpp | 3 +- .../time.cal.ym.members/month.pass.cpp | 3 +- .../time.cal.ym.members/ok.pass.cpp | 3 +- .../plus_minus_equal_month.pass.cpp | 3 +- .../plus_minus_equal_year.pass.cpp | 3 +- .../time.cal.ym.members/year.pass.cpp | 3 +- .../time.cal.ym.nonmembers/minus.pass.cpp | 3 +- .../time.cal.ym.nonmembers/plus.pass.cpp | 3 +- .../ctor.local_days.pass.cpp | 3 +- .../ctor.sys_days.pass.cpp | 3 +- .../ctor.year_month_day_last.pass.cpp | 3 +- .../time.cal.ymd.members/day.pass.cpp | 3 +- .../time.cal.ymd.members/month.pass.cpp | 3 +- .../time.cal.ymd.members/ok.pass.cpp | 3 +- .../op.local_days.pass.cpp | 3 +- .../time.cal.ymd.members/op.sys_days.pass.cpp | 3 +- .../plus_minus_equal_month.pass.cpp | 3 +- .../plus_minus_equal_year.pass.cpp | 3 +- .../time.cal.ymd.members/year.pass.cpp | 3 +- .../time.cal.ymd.nonmembers/minus.pass.cpp | 3 +- .../time.cal.ymd.nonmembers/plus.pass.cpp | 3 +- .../time.cal.ymdlast.members/day.pass.cpp | 3 +- .../time.cal.ymdlast.members/month.pass.cpp | 3 +- .../month_day_last.pass.cpp | 3 +- .../time.cal.ymdlast.members/ok.pass.cpp | 3 +- .../op_local_days.pass.cpp | 3 +- .../op_sys_days.pass.cpp | 3 +- .../plus_minus_equal_month.pass.cpp | 3 +- .../plus_minus_equal_year.pass.cpp | 3 +- .../time.cal.ymdlast.members/year.pass.cpp | 3 +- .../minus.pass.cpp | 3 +- .../time.cal.ymdlast.nonmembers/plus.pass.cpp | 3 +- .../ctor.local_days.pass.cpp | 3 +- .../ctor.sys_days.pass.cpp | 3 +- .../time.cal.ymwd.members/index.pass.cpp | 3 +- .../time.cal.ymwd.members/month.pass.cpp | 3 +- .../time.cal.ymwd.members/ok.pass.cpp | 3 +- .../op.local_days.pass.cpp | 3 +- .../op.sys_days.pass.cpp | 3 +- .../plus_minus_equal_month.pass.cpp | 3 +- .../plus_minus_equal_year.pass.cpp | 3 +- .../time.cal.ymwd.members/weekday.pass.cpp | 3 +- .../weekday_indexed.pass.cpp | 3 +- .../time.cal.ymwd.members/year.pass.cpp | 3 +- .../time.cal.ymwd.nonmembers/minus.pass.cpp | 3 +- .../time.cal.ymwd.nonmembers/plus.pass.cpp | 3 +- .../time.cal.ymwdlast.members/month.pass.cpp | 3 +- .../time.cal.ymwdlast.members/ok.pass.cpp | 3 +- .../op_local_days.pass.cpp | 3 +- .../op_sys_days.pass.cpp | 3 +- .../plus_minus_equal_month.pass.cpp | 3 +- .../plus_minus_equal_year.pass.cpp | 3 +- .../weekday.pass.cpp | 3 +- .../time.cal.ymwdlast.members/year.pass.cpp | 3 +- .../minus.pass.cpp | 3 +- .../plus.pass.cpp | 3 +- .../time.zone.db.access/current_zone.pass.cpp | 5 +- .../remote_version.pass.cpp | 2 +- .../types.pass.cpp | 1 - .../time.zone.leap/members/date.pass.cpp | 1 - .../time.zone.members/sys_info.zdump.pass.cpp | 5 +- .../test_offset_time_zone.h | 1 - .../string_view.pass.cpp | 2 - .../string_view_local_time.pass.cpp | 2 - .../string_view_local_time_choose.pass.cpp | 2 +- .../string_view_sys_time.pass.cpp | 2 - ...ned_time_duration2_time_zone_ptr2.pass.cpp | 2 +- ...e_duration2_time_zone_ptr2_choose.pass.cpp | 2 +- .../sys_time.pass.cpp | 1 - .../time_zone_pointer.pass.cpp | 1 - .../time_zone_pointer_local_time.pass.cpp | 2 +- ...me_zone_pointer_local_time_choose.pass.cpp | 2 +- .../time_zone_pointer_sys_time.pass.cpp | 2 +- .../get_local_time.pass.cpp | 1 - .../get_sys_time.pass.cpp | 1 - .../get_time_zone.pass.cpp | 1 - .../operator_local_time.pass.cpp | 1 - .../operator_sys_time.pass.cpp | 1 - .../const_time_zone_default_zone.pass.cpp | 1 - .../const_time_zone_locate_zone.pass.cpp | 1 - .../charconv.from.chars/integral.pass.cpp | 2 - .../integral.roundtrip.pass.cpp | 2 - .../utilities/charconv/charconv.msvc/test.hpp | 2 +- .../from_chars_result.operator_bool.pass.cpp | 1 - .../charconv.syn/from_chars_result.pass.cpp | 2 - .../to_chars_result.operator_bool.pass.cpp | 1 - .../charconv.syn/to_chars_result.pass.cpp | 2 - .../charconv.to.chars/integral.pass.cpp | 1 - .../formatter.pointer.pass.cpp | 3 +- .../formatter.signed_integral.pass.cpp | 1 - .../escaped_output.unicode.pass.cpp | 1 - .../format_to.locale.pass.cpp | 1 - .../format_to_n.locale.pass.cpp | 1 - .../formatted_size.locale.pass.cpp | 1 - .../is_bind_expression.pass.cpp | 2 - .../func.bind.isplace/is_placeholder.pass.cpp | 2 - .../func.wrap.func.con/copy_move.pass.cpp | 4 + .../function.objects/unord.hash/enum.pass.cpp | 8 +- .../unord.hash/integral.pass.cpp | 3 +- .../difference_type.pass.cpp | 1 - .../allocator.traits.types/size_type.pass.cpp | 1 - .../difference_type.compile.pass.cpp | 1 - .../temporary.buffer/overaligned.pass.cpp | 1 - .../temporary_buffer.pass.cpp | 1 - .../hash_shared_ptr.pass.cpp | 4 +- .../hash_unique_ptr.pass.cpp | 8 +- .../util.smartptr.shared/types.pass.cpp | 1 - .../reset_pointer.pass.cpp | 1 - .../meta.trans.other/underlying_type.pass.cpp | 1 - .../meta.unary.comp/is_bounded_array.pass.cpp | 1 - .../is_unbounded_array.pass.cpp | 1 - .../meta.unary.prop/is_signed.pass.cpp | 2 - .../meta.unary.prop/is_swappable.pass.cpp | 2 +- .../meta.unary.prop/is_unsigned.pass.cpp | 2 - .../optional/optional.hash/hash.pass.cpp | 16 +- .../bitset.cons/char_ptr_ctor.pass.cpp | 3 +- .../bitset.hash/enabled_hash.pass.cpp | 8 +- .../tuple.tuple/tuple.apply/apply.pass.cpp | 2 +- .../tuple.apply/make_from_tuple.pass.cpp | 13 +- .../hash_type_index.pass.cpp | 2 +- .../default_type.compile.pass.cpp | 1 - .../special_member_generation_test.pass.cpp | 1 - .../cmp_greater_equal.pass.cpp | 3 +- .../variant/variant.hash/hash.pass.cpp | 14 +- libcxx/test/support/archetypes.h | 8 +- libcxx/test/support/assert_macros.h | 2 +- libcxx/test/support/check_assertion.h | 4 +- libcxx/test/support/container_test_types.h | 4 +- libcxx/test/support/count_new.h | 7 +- libcxx/test/support/filesystem_test_helper.h | 2 +- libcxx/test/support/format.functions.common.h | 3 +- libcxx/test/support/hexfloat.h | 3 +- libcxx/test/support/make_test_thread.h | 10 +- libcxx/test/support/operator_hijacker.h | 3 +- libcxx/test/support/parse_integer.h | 2 +- libcxx/test/support/poisoned_hash_helper.h | 185 +- .../test_poisoned_hash_helper.pass.cpp | 33 + .../c1xx_broken_za_ctor_check.pass.cpp | 1 - libcxx/test/support/test_allocator.h | 1 + libcxx/test/support/test_convertible.h | 2 +- libcxx/test/support/test_macros.h | 6 + libcxx/test/support/uses_alloc_types.h | 2 +- .../header_exportable_declarations.cpp | 4 +- libcxx/utils/adb_run.py | 4 +- libcxx/utils/ci/Dockerfile | 4 +- libcxx/utils/ci/apple-install-libcxx.sh | 4 +- libcxx/utils/ci/build-picolibc.sh | 4 +- libcxx/utils/ci/buildkite-pipeline.yml | 4 +- libcxx/utils/ci/docker-compose.yml | 2 +- libcxx/utils/ci/run-buildbot | 27 +- .../ci/vendor/android/Dockerfile.emulator | 4 +- .../vendor/android/build-emulator-images.sh | 4 +- .../ci/vendor/android/container-setup.sh | 4 +- .../ci/vendor/android/emulator-entrypoint.sh | 4 +- .../ci/vendor/android/emulator-functions.sh | 4 +- .../vendor/android/emulator-wait-for-ready.sh | 4 +- .../vendor/android/setup-env-for-emulator.sh | 4 +- .../utils/ci/vendor/android/start-emulator.sh | 4 +- .../utils/ci/vendor/android/stop-emulator.sh | 4 +- libcxx/utils/gdb/libcxx/printers.py | 62 +- .../generate_feature_test_macro_components.py | 16 +- libcxx/utils/generate_iwyu_mapping.py | 2 - libcxx/utils/graph_header_deps.py | 46 + libcxx/utils/libcxx/header_information.py | 16 + libcxx/utils/libcxx/test/android.py | 4 +- libcxx/utils/libcxx/test/features.py | 2 - libcxx/utils/libcxx/test/modules.py | 11 +- libcxx/utils/synchronize_csv_status_files.py | 29 +- libcxxabi/src/cxa_guard_impl.h | 4 +- libcxxabi/src/cxa_personality.cpp | 2 +- libcxxabi/src/demangle/ItaniumDemangle.h | 129 +- libcxxabi/test/test_demangle.pass.cpp | 28 +- lld/COFF/Chunks.cpp | 39 +- lld/COFF/Chunks.h | 44 +- lld/COFF/Config.h | 1 - lld/COFF/DLL.cpp | 58 +- lld/COFF/DLL.h | 2 - lld/COFF/Driver.cpp | 9 +- lld/COFF/Driver.h | 2 - lld/COFF/DriverUtils.cpp | 2 +- lld/COFF/InputFiles.cpp | 100 +- lld/COFF/InputFiles.h | 20 +- lld/COFF/MapFile.cpp | 23 +- lld/COFF/MarkLive.cpp | 22 +- lld/COFF/PDB.cpp | 4 +- lld/COFF/SymbolTable.cpp | 64 +- lld/COFF/SymbolTable.h | 12 +- lld/COFF/Symbols.cpp | 20 +- lld/COFF/Symbols.h | 18 +- lld/COFF/Writer.cpp | 77 +- lld/ELF/Arch/AArch64.cpp | 24 +- lld/ELF/Arch/ARM.cpp | 10 +- lld/ELF/Arch/Hexagon.cpp | 10 +- lld/ELF/Arch/LoongArch.cpp | 6 +- lld/ELF/Arch/Mips.cpp | 8 +- lld/ELF/Arch/PPC.cpp | 12 +- lld/ELF/Arch/PPC64.cpp | 4 +- lld/ELF/Arch/RISCV.cpp | 10 +- lld/ELF/Arch/SPARCV9.cpp | 2 +- lld/ELF/Arch/SystemZ.cpp | 10 +- lld/ELF/Arch/X86.cpp | 24 +- lld/ELF/Arch/X86_64.cpp | 16 +- lld/ELF/Config.h | 65 - lld/ELF/Driver.cpp | 835 +- lld/ELF/ICF.cpp | 6 +- lld/ELF/InputFiles.cpp | 28 +- lld/ELF/InputSection.cpp | 83 +- lld/ELF/InputSection.h | 6 +- lld/ELF/LTO.cpp | 1 - lld/ELF/LinkerScript.cpp | 13 +- lld/ELF/MarkLive.cpp | 6 +- lld/ELF/OutputSections.cpp | 13 +- lld/ELF/Relocations.cpp | 56 +- lld/ELF/Symbols.cpp | 12 +- lld/ELF/SyntheticSections.cpp | 234 +- lld/ELF/SyntheticSections.h | 42 +- lld/ELF/Thunks.cpp | 21 +- lld/ELF/Writer.cpp | 134 +- lld/MachO/Arch/ARM64.cpp | 23 - lld/MachO/BPSectionOrderer.cpp | 147 +- lld/MachO/BPSectionOrderer.h | 2 +- lld/MachO/CMakeLists.txt | 1 - lld/MachO/Config.h | 3 - lld/MachO/Driver.cpp | 73 +- lld/MachO/ICF.cpp | 92 +- lld/MachO/InputSection.cpp | 5 +- lld/MachO/InputSection.h | 4 +- lld/MachO/MapFile.cpp | 2 +- lld/MachO/Options.td | 9 - lld/MachO/OutputSegment.cpp | 6 - lld/MachO/SectionPriorities.cpp | 1 - lld/MachO/Symbols.cpp | 4 +- lld/MachO/Symbols.h | 44 +- lld/MachO/SyntheticSections.cpp | 3 +- lld/MachO/Target.h | 10 - lld/include/lld/Common/CommonLinkerContext.h | 4 +- lld/test/CMakeLists.txt | 1 - lld/test/COFF/Inputs/loadconfig-arm64ec.s | 6 +- lld/test/COFF/arm64ec-import.test | 234 - lld/test/COFF/arm64ec-lib.test | 47 - lld/test/COFF/export-imp.test | 11 - lld/test/COFF/import_weak_alias.test | 20 - .../ELF/aarch64-reloc-implicit-addend.test | 23 +- lld/test/ELF/hexagon-eflag.s | 5 - lld/test/ELF/icf10.s | 3 - lld/test/ELF/partitions.s | 2 +- lld/test/MachO/bp-section-orderer-errs.s | 3 - lld/test/MachO/bp-section-orderer-stress.s | 4 +- lld/test/MachO/cgdata-generate.s | 89 - lld/test/MachO/icf-safe-thunks.ll | 254 - lld/test/MachO/segprot.s | 41 +- lld/test/lit.cfg.py | 1 - .../wasm/Inputs/allow-multiple-definition.s | 6 - lld/test/wasm/allow-multiple-definition.s | 38 - lld/test/wasm/static-error.s | 12 - lld/test/wasm/unsupported-pic-relocations.s | 39 - lld/test/wasm/unsupported-pic-relocations64.s | 39 - lld/wasm/Config.h | 5 - lld/wasm/Driver.cpp | 34 +- lld/wasm/Options.td | 7 - lld/wasm/OutputSections.cpp | 5 + lld/wasm/Relocations.cpp | 16 - lld/wasm/SymbolTable.cpp | 9 +- lld/wasm/SyntheticSections.cpp | 4 +- lld/wasm/SyntheticSections.h | 1 + lld/wasm/Writer.cpp | 1 + lldb/bindings/python/python-swigsafecast.swig | 4 +- lldb/docs/conf.py | 4 +- lldb/docs/resources/sbapi.rst | 11 - lldb/docs/resources/test.rst | 2 +- lldb/docs/use/python-reference.rst | 6 - lldb/examples/python/cmdtemplate.py | 3 - lldb/examples/synthetic/gnu_libstdcpp.py | 6 +- lldb/examples/synthetic/libcxx.py | 28 +- lldb/include/lldb/API/SBError.h | 4 +- lldb/include/lldb/API/SBMemoryRegionInfo.h | 2 +- lldb/include/lldb/API/SBSaveCoreOptions.h | 11 - lldb/include/lldb/API/SBValue.h | 2 - lldb/include/lldb/API/SBValueList.h | 2 +- lldb/include/lldb/Core/SourceManager.h | 7 - .../lldb/Core/ValueObjectConstResult.h | 4 +- .../include/lldb/DataFormatters/TypeSummary.h | 15 - lldb/include/lldb/Host/Socket.h | 28 +- lldb/include/lldb/Host/common/TCPSocket.h | 7 +- lldb/include/lldb/Host/common/UDPSocket.h | 8 +- lldb/include/lldb/Host/posix/DomainSocket.h | 8 +- .../Interfaces/ScriptedInterface.h | 17 +- lldb/include/lldb/Symbol/SaveCoreOptions.h | 11 +- .../lldb/Target/CoreFileMemoryRanges.h | 61 - lldb/include/lldb/Target/Process.h | 27 +- lldb/include/lldb/Target/Statistics.h | 80 - lldb/include/lldb/Target/Target.h | 5 - lldb/include/lldb/Utility/Instrumentation.h | 2 +- lldb/include/lldb/Utility/RangeMap.h | 6 - lldb/include/lldb/Utility/Scalar.h | 10 +- lldb/include/lldb/Utility/Status.h | 115 +- lldb/include/lldb/Utility/SupportFile.h | 4 +- lldb/include/lldb/lldb-enumerations.h | 1 - lldb/include/lldb/lldb-forward.h | 1 - lldb/include/lldb/lldb-private-interfaces.h | 1 + lldb/packages/Python/lldbsuite/test/bench.py | 77 + .../Python/lldbsuite/test/builders/builder.py | 98 +- .../Python/lldbsuite/test/decorators.py | 12 + .../Python/lldbsuite/test/lldbplatformutil.py | 16 - .../Python/lldbsuite/test/lldbtest.py | 13 +- .../Python/lldbsuite/test/lldbutil.py | 13 +- .../Python/lldbsuite/test/make/Makefile.rules | 92 +- .../compressed_pair.h | 49 +- .../test/tools/lldb-dap/dap_server.py | 37 - .../test/tools/lldb-dap/lldbdap_testcase.py | 13 +- lldb/source/API/SBBreakpoint.cpp | 6 +- lldb/source/API/SBBreakpointLocation.cpp | 4 +- lldb/source/API/SBBreakpointName.cpp | 17 +- lldb/source/API/SBDebugger.cpp | 5 +- lldb/source/API/SBError.cpp | 15 +- lldb/source/API/SBFile.cpp | 15 +- lldb/source/API/SBFormat.cpp | 2 +- lldb/source/API/SBFrame.cpp | 9 +- lldb/source/API/SBPlatform.cpp | 4 +- lldb/source/API/SBProcess.cpp | 2 +- lldb/source/API/SBSaveCoreOptions.cpp | 14 +- lldb/source/API/SBStructuredData.cpp | 2 +- lldb/source/API/SBTarget.cpp | 7 +- lldb/source/API/SBThread.cpp | 2 +- lldb/source/API/SBValue.cpp | 20 +- lldb/source/API/SBValueList.cpp | 13 +- lldb/source/API/SBWatchpoint.cpp | 2 +- lldb/source/Breakpoint/Breakpoint.cpp | 2 +- .../Commands/CommandObjectBreakpoint.cpp | 103 +- .../source/Commands/CommandObjectCommands.cpp | 4 +- lldb/source/Commands/CommandObjectLog.cpp | 8 +- .../Commands/CommandObjectMemoryTag.cpp | 10 +- lldb/source/Commands/CommandObjectProcess.cpp | 1 - .../Commands/CommandObjectRegexCommand.cpp | 2 +- lldb/source/Commands/CommandObjectSource.cpp | 4 +- lldb/source/Commands/CommandObjectStats.cpp | 6 +- lldb/source/Commands/CommandObjectTrace.cpp | 2 +- lldb/source/Core/Debugger.cpp | 2 +- lldb/source/Core/Module.cpp | 4 +- lldb/source/Core/ModuleList.cpp | 5 +- lldb/source/Core/PluginManager.cpp | 2 +- lldb/source/Core/Progress.cpp | 10 - lldb/source/Core/SourceManager.cpp | 27 +- lldb/source/Core/ThreadedCommunication.cpp | 2 +- lldb/source/Core/ValueObject.cpp | 16 +- lldb/source/Core/ValueObjectCast.cpp | 2 +- lldb/source/Core/ValueObjectConstResult.cpp | 9 +- lldb/source/Core/ValueObjectDynamicValue.cpp | 2 +- .../Core/ValueObjectSyntheticFilter.cpp | 2 +- lldb/source/Core/ValueObjectVTable.cpp | 2 +- lldb/source/Core/ValueObjectVariable.cpp | 2 +- lldb/source/DataFormatters/TypeSummary.cpp | 33 +- lldb/source/DataFormatters/VectorType.cpp | 2 +- lldb/source/Expression/FunctionCaller.cpp | 3 +- lldb/source/Expression/IRExecutionUnit.cpp | 2 + lldb/source/Expression/IRInterpreter.cpp | 4 + lldb/source/Expression/LLVMUserExpression.cpp | 6 +- lldb/source/Expression/Materializer.cpp | 2 +- lldb/source/Expression/UserExpression.cpp | 8 +- lldb/source/Host/common/FileCache.cpp | 2 +- lldb/source/Host/common/Host.cpp | 1 - lldb/source/Host/common/LockFileBase.cpp | 4 +- .../Host/common/NativeProcessProtocol.cpp | 10 +- lldb/source/Host/common/Socket.cpp | 50 +- lldb/source/Host/common/TCPSocket.cpp | 125 +- lldb/source/Host/common/UDPSocket.cpp | 4 + lldb/source/Host/macosx/objcxx/Host.mm | 2 +- .../posix/ConnectionFileDescriptorPosix.cpp | 18 +- lldb/source/Host/posix/DomainSocket.cpp | 42 +- .../windows/ConnectionGenericFileWindows.cpp | 4 +- lldb/source/Host/windows/MainLoopWindows.cpp | 3 +- lldb/source/Host/windows/PipeWindows.cpp | 1 + .../source/Interpreter/CommandInterpreter.cpp | 2 +- lldb/source/Interpreter/CommandObject.cpp | 2 +- lldb/source/Interpreter/OptionValueRegex.cpp | 2 +- lldb/source/Interpreter/Options.cpp | 2 +- lldb/source/Interpreter/ScriptInterpreter.cpp | 2 +- .../Disassembler/LLVMC/DisassemblerLLVMC.cpp | 2 + .../ExpressionParser/Clang/ClangASTSource.cpp | 2 +- .../Clang/ClangExpressionParser.cpp | 2 + .../Clang/ClangModulesDeclVendor.cpp | 1 + .../Clang/IRDynamicChecks.cpp | 3 + .../ExpressionParser/Clang/IRForTarget.cpp | 9 + .../RISCV/EmulateInstructionRISCV.cpp | 8 +- .../Language/CPlusPlus/BlockPointer.cpp | 2 +- .../Language/CPlusPlus/GenericOptional.cpp | 2 - .../Plugins/Language/CPlusPlus/LibCxx.cpp | 85 +- .../Plugins/Language/CPlusPlus/LibCxx.h | 3 +- .../Plugins/Language/CPlusPlus/LibCxxList.cpp | 72 +- .../Plugins/Language/CPlusPlus/LibCxxMap.cpp | 39 +- .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 166 +- .../Language/CPlusPlus/LibCxxVector.cpp | 38 +- .../AppleObjCRuntime/AppleObjCRuntimeV2.cpp | 2 +- .../ObjectFile/Mach-O/ObjectFileMachO.cpp | 8 +- .../ObjectFile/Mach-O/ObjectFileMachO.h | 1 - .../Minidump/MinidumpFileBuilder.cpp | 58 +- .../ObjectFile/Minidump/MinidumpFileBuilder.h | 13 +- .../Minidump/ObjectFileMinidump.cpp | 20 +- .../ObjectFile/Minidump/ObjectFileMinidump.h | 1 - .../ObjectFile/PECOFF/ObjectFilePECOFF.cpp | 1 - .../ObjectFile/PECOFF/ObjectFilePECOFF.h | 1 - .../Plugins/Platform/Android/AdbClient.cpp | 8 +- .../PlatformAndroidRemoteGDBServer.cpp | 4 +- ...PlatformiOSSimulatorCoreSimulatorSupport.h | 2 +- ...latformiOSSimulatorCoreSimulatorSupport.mm | 14 +- .../Plugins/Platform/POSIX/PlatformPOSIX.cpp | 4 +- .../Platform/Windows/PlatformWindows.cpp | 4 +- .../Process/FreeBSD/NativeProcessFreeBSD.cpp | 5 +- .../Process/Linux/NativeProcessLinux.cpp | 72 +- .../NativeRegisterContextLinux_riscv64.cpp | 57 +- .../NativeRegisterContextLinux_riscv64.h | 2 - .../NativeRegisterContextDBReg_arm64.cpp | 10 +- .../Utility/RegisterContextPOSIX_riscv64.cpp | 3 +- .../Utility/RegisterInfoPOSIX_riscv64.cpp | 132 +- .../Utility/RegisterInfoPOSIX_riscv64.h | 38 +- .../Process/Utility/RegisterInfos_riscv64.h | 54 +- .../Process/Windows/Common/DebuggerThread.cpp | 4 +- .../Windows/Common/NativeProcessWindows.cpp | 2 +- .../Windows/Common/ProcessDebugger.cpp | 29 +- .../Process/Windows/Common/ProcessWindows.cpp | 8 +- .../Process/elf-core/ProcessElfCore.cpp | 2 +- .../RegisterContextPOSIXCore_riscv64.cpp | 25 +- .../RegisterContextPOSIXCore_riscv64.h | 3 + .../gdb-remote/GDBRemoteCommunication.cpp | 49 +- .../gdb-remote/GDBRemoteCommunication.h | 8 +- .../GDBRemoteCommunicationClient.cpp | 10 +- .../GDBRemoteCommunicationServer.cpp | 9 +- .../GDBRemoteCommunicationServerLLGS.cpp | 30 +- .../GDBRemoteCommunicationServerPlatform.cpp | 7 +- .../Process/gdb-remote/ProcessGDBRemote.cpp | 6 +- .../Process/minidump/MinidumpParser.cpp | 11 +- .../Plugins/Process/minidump/MinidumpParser.h | 4 +- .../Process/minidump/ProcessMinidump.cpp | 120 +- .../Process/minidump/ProcessMinidump.h | 3 +- .../RegisterContextMinidump_x86_64.cpp | 8 - .../minidump/RegisterContextMinidump_x86_64.h | 8 +- .../Lua/ScriptInterpreterLua.cpp | 20 +- .../OperatingSystemPythonInterface.h | 5 +- .../ScriptedPlatformPythonInterface.h | 11 +- .../ScriptedProcessPythonInterface.cpp | 6 +- .../ScriptedProcessPythonInterface.h | 9 +- .../Interfaces/ScriptedPythonInterface.h | 170 +- .../ScriptedThreadPlanPythonInterface.h | 3 +- .../ScriptedThreadPythonInterface.h | 7 +- .../Python/PythonDataObjects.cpp | 35 +- .../Python/SWIGPythonBridge.h | 2 +- .../Python/ScriptInterpreterPython.cpp | 10 +- .../DarwinLog/StructuredDataDarwinLog.cpp | 2 +- .../Plugins/SymbolFile/CTF/SymbolFileCTF.cpp | 1 - .../Plugins/SymbolFile/DWARF/DWARFASTParser.h | 2 +- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 95 +- .../SymbolFile/DWARF/DWARFASTParserClang.h | 66 +- .../Plugins/SymbolFile/DWARF/DWARFDIE.cpp | 24 +- .../SymbolFile/DWARF/DWARFDebugInfoEntry.cpp | 78 +- .../SymbolFile/DWARF/DWARFDebugInfoEntry.h | 57 +- .../Plugins/SymbolFile/DWARF/DWARFUnit.h | 2 +- .../SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 2 +- .../SymbolFile/DWARF/ManualDWARFIndex.cpp | 2 +- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 9 +- .../DWARF/SymbolFileDWARFDebugMap.cpp | 2 +- .../Plugins/SymbolFile/PDB/SymbolFilePDB.cpp | 1 - .../CommandObjectTraceStartIntelPT.cpp | 4 +- .../intel-pt/TraceIntelPTBundleLoader.cpp | 2 +- lldb/source/Symbol/LineTable.cpp | 4 +- lldb/source/Symbol/SaveCoreOptions.cpp | 14 - lldb/source/Symbol/Symtab.cpp | 2 +- lldb/source/Target/CMakeLists.txt | 1 - lldb/source/Target/CoreFileMemoryRanges.cpp | 86 - lldb/source/Target/ModuleCache.cpp | 4 +- lldb/source/Target/Platform.cpp | 6 +- lldb/source/Target/Process.cpp | 191 +- lldb/source/Target/StackFrame.cpp | 4 +- lldb/source/Target/Statistics.cpp | 22 +- lldb/source/Target/Target.cpp | 24 +- lldb/source/Target/TargetProperties.td | 2 +- lldb/source/Target/Thread.cpp | 3 +- .../Target/VerboseTrapFrameRecognizer.cpp | 35 +- lldb/source/Utility/Instrumentation.cpp | 2 +- lldb/source/Utility/LLDBAssert.cpp | 2 +- lldb/source/Utility/Log.cpp | 2 +- lldb/source/Utility/Scalar.cpp | 51 +- lldb/source/Utility/Status.cpp | 273 +- lldb/source/Utility/StructuredData.cpp | 2 +- .../TestMultipleDebuggers.py | 1 - .../holes => benchmarks/continue}/Makefile | 0 .../continue/TestBenchmarkContinue.py | 65 + lldb/test/API/benchmarks/continue/main.cpp | 36 + .../fpnan => benchmarks/expression}/Makefile | 0 .../expression/TestExpressionCmd.py | 74 + .../expression/TestRepeatedExprs.py | 131 + lldb/test/API/benchmarks/expression/main.cpp | 43 + .../TestFrameVariableResponse.py | 68 + .../libcxxlist}/Makefile | 0 .../libcxxlist/TestBenchmarkLibcxxList.py | 58 + lldb/test/API/benchmarks/libcxxlist/main.cpp | 11 + .../cpp => benchmarks/libcxxmap}/Makefile | 0 .../libcxxmap/TestBenchmarkLibcxxMap.py | 58 + lldb/test/API/benchmarks/libcxxmap/main.cpp | 11 + .../benchmarks/startup/TestStartupDelays.py | 78 + .../benchmarks/stepping/TestSteppingSpeed.py | 69 + .../TestCompileRunToBreakpointTurnaround.py | 122 + .../deque-dbg-info-content/Makefile | 4 +- .../list-dbg-info-content/Makefile | 4 +- .../vector-dbg-info-content/Makefile | 4 +- .../TestDbgInfoContentVectorFromStdModule.py | 1 - .../commands/statistics/basic/BoxFormatter.py | 15 - .../API/commands/statistics/basic/Makefile | 2 +- .../commands/statistics/basic/TestStats.py | 72 +- .../test/API/commands/statistics/basic/main.c | 7 + .../API/commands/statistics/basic/main.cpp | 35 - .../breakpoint/breakpoint_ids/Makefile | 2 +- .../breakpoint/breakpoint_locations/Makefile | 2 +- .../consecutive_breakpoints/Makefile | 2 +- .../functionalities/breakpoint/cpp/Makefile | 2 +- .../dummy_target_breakpoints/Makefile | 2 +- .../require_hw_breakpoints/Makefile | 2 +- .../breakpoint/step_over_breakpoint/Makefile | 2 +- .../thread_plan_user_breakpoint/Makefile | 2 +- .../ObjCDataFormatterTestCase.py | 4 +- .../list/TestDataFormatterGenericList.py | 4 +- .../TestDataFormatterGenericOptional.py | 12 - .../generic/optional/main.cpp | 5 - .../TestDataFormatterLibcxxStringSimulator.py | 22 +- .../libcxx-simulators/string/main.cpp | 52 +- ...stDataFormatterLibcxxUniquePtrSimulator.py | 15 +- .../libcxx-simulators/unique_ptr/main.cpp | 5 - .../string/TestDataFormatterLibcxxString.py | 10 - .../TestNSDictionarySynthetic.py | 4 +- .../nssetsynth/TestNSSetSynthetic.py | 4 +- .../poarray/TestPrintObjectArray.py | 4 +- .../functionalities/inline-stepping/Makefile | 2 +- .../big-read/TestMemoryReadMaximumSize.py | 2 - .../memory/holes/TestMemoryHoles.py | 73 - .../API/functionalities/memory/holes/main.cpp | 88 - .../postmortem/elf-core/TestLinuxCore.py | 133 +- ...iscv64.gpr_fpr.core => linux-riscv64.core} | Bin 20480 -> 20480 bytes .../elf-core/linux-riscv64.gpr_fpr.out | Bin 3480 -> 0 bytes .../elf-core/linux-riscv64.gpr_only.core | Bin 28672 -> 0 bytes .../elf-core/linux-riscv64.gpr_only.out | Bin 3520 -> 0 bytes .../postmortem/elf-core/linux-riscv64.out | Bin 0 -> 3328 bytes .../postmortem/elf-core/main_fpr.c | 14 - .../minidump-new/TestMiniDumpNew.py | 22 +- .../postmortem/minidump-new/makefile.txt | 1 - .../minidump-new/multiple-sigsev.yaml | 39 - .../TestProcessSaveCoreMinidump.py | 190 - .../API/functionalities/watchpoint/categories | 2 - lldb/test/API/lang/cpp/fpnan/TestFPNaN.py | 130 - lldb/test/API/lang/cpp/fpnan/main.cpp | 8 - .../no_unique_address/TestNoUniqueAddress.py | 67 - .../API/lang/cpp/no_unique_address/main.cpp | 35 - .../lang/objc/orderedset/TestOrderedSet.py | 4 +- .../TestObjCSingleEntryDictionary.py | 4 +- lldb/test/API/macosx/macCatalyst/Makefile | 1 - .../macCatalystAppMacOSFramework/Makefile | 1 - .../macosx/simulator/TestSimulatorPlatform.py | 4 +- .../API/python_api/frame/inlines/Makefile | 2 +- .../tools/lldb-dap/attach/TestDAP_attach.py | 11 +- .../API/tools/lldb-dap/exception/Makefile | 2 +- .../lldb-dap/exception/TestDAP_exception.py | 8 +- .../exception/cpp/TestDAP_exception_cpp.py | 26 - .../API/tools/lldb-dap/exception/cpp/main.cpp | 6 - .../lldb-dap/exception/{main.c => main.cpp} | 2 +- .../tools/lldb-dap/exception/objc/Makefile | 9 - .../exception/objc/TestDAP_exception_objc.py | 27 - .../API/tools/lldb-dap/exception/objc/main.m | 8 - .../lldb-dap/extendedStackTrace/Makefile | 5 - .../TestDAP_extendedStackTrace.py | 104 - .../tools/lldb-dap/extendedStackTrace/main.m | 28 - .../TestDAP_instruction_breakpoint.py | 2 +- .../API/tools/lldb-dap/locations/Makefile | 3 - .../lldb-dap/locations/TestDAP_locations.py | 40 - lldb/test/API/tools/lldb-dap/locations/main.c | 5 - lldb/test/API/tools/lldb-dap/memory/Makefile | 3 - .../tools/lldb-dap/memory/TestDAP_memory.py | 112 - lldb/test/API/tools/lldb-dap/memory/main.cpp | 6 - .../lldb-dap/stackTrace/TestDAP_stackTrace.py | 29 +- .../test/API/tools/lldb-dap/stackTrace/main.c | 2 +- .../lldb-dap/stackTrace/subtleFrames/Makefile | 1 - .../TestDAP_stackTraceMissingFunctionName.py | 5 + .../lldb-server/TestAppleSimulatorOSType.py | 4 +- .../tools/lldb-server/TestGdbRemoteLaunch.py | 1 - .../tools/lldb-server/TestLldbGdbServer.py | 1 - .../test/API/tools/lldb-server/TestNonStop.py | 1 - ...verbose_trap-in-stl-callback-user-leaf.cpp | 22 - .../Inputs/verbose_trap-in-stl-callback.cpp | 22 - .../Inputs/verbose_trap-in-stl-max-depth.cpp | 13 - .../Inputs/verbose_trap-in-stl-nested.cpp | 21 - .../Recognizer/Inputs/verbose_trap-in-stl.cpp | 17 - ...erbose_trap-in-stl-callback-user-leaf.test | 22 - .../verbose_trap-in-stl-callback.test | 21 - .../verbose_trap-in-stl-max-depth.test | 16 - .../verbose_trap-in-stl-nested.test | 13 - .../Shell/Recognizer/verbose_trap-in-stl.test | 13 - .../no_unique_address-with-bitfields.cpp | 110 - .../DWARF/x86/type-definition-search.cpp | 23 +- .../DWARF/x86/type-unit-same-basename.cpp | 45 - lldb/test/Shell/SymbolFile/Inputs/main.c | 4 - .../Shell/SymbolFile/checksum-mismatch.test | 9 - .../MacOSX/x86_64/DNBArchImplX86_64.cpp | 67 +- .../source/MacOSX/x86_64/DNBArchImplX86_64.h | 4 +- .../MacOSX/x86_64/MachRegisterStatesX86_64.h | 5 - lldb/tools/lldb-dap/DAP.cpp | 23 +- lldb/tools/lldb-dap/DAP.h | 10 +- lldb/tools/lldb-dap/JSONUtils.cpp | 180 +- lldb/tools/lldb-dap/JSONUtils.h | 57 +- lldb/tools/lldb-dap/LLDBUtils.cpp | 1 + lldb/tools/lldb-dap/README.md | 6 - lldb/tools/lldb-dap/lldb-dap.cpp | 634 +- lldb/tools/lldb-dap/package-lock.json | 4 +- lldb/tools/lldb-dap/package.json | 35 +- lldb/tools/lldb-dap/src-ts/extension.ts | 11 +- lldb/tools/lldb-instr/Instrument.cpp | 4 +- .../tools/lldb-server/LLDBServerUtilities.cpp | 2 +- lldb/tools/lldb-server/lldb-gdbserver.cpp | 14 +- lldb/tools/lldb-test/lldb-test.cpp | 2 +- lldb/unittests/Host/MainLoopTest.cpp | 40 - lldb/unittests/Host/SocketTest.cpp | 75 - lldb/unittests/Process/Utility/CMakeLists.txt | 1 - .../Utility/CoreFileMemoryRangesTest.cpp | 205 - .../GDBRemoteCommunicationClientTest.cpp | 9 - .../GDBRemoteCommunicationServerTest.cpp | 3 +- .../Process/minidump/MinidumpParserTest.cpp | 13 +- .../Python/PythonTestSuite.cpp | 2 +- .../Symbol/PostfixExpressionTest.cpp | 2 +- .../PdbFPOProgramToDWARFExpressionTests.cpp | 2 +- lldb/unittests/Target/CMakeLists.txt | 1 - .../Target/RemoteAwarePlatformTest.cpp | 8 +- .../Target/SummaryStatisticsTest.cpp | 58 - .../Host/NativeProcessTestUtils.h | 4 +- lldb/unittests/Utility/StatusTest.cpp | 22 +- .../tools/lldb-server/tests/LLGSTest.cpp | 4 + .../tools/lldb-server/tests/TestClient.cpp | 4 + .../tools/lldb-server/tests/TestClient.h | 4 - lldb/utils/TableGen/LLDBOptionDefEmitter.cpp | 13 +- .../utils/TableGen/LLDBPropertyDefEmitter.cpp | 21 +- lldb/utils/TableGen/LLDBTableGen.cpp | 2 +- lldb/utils/TableGen/LLDBTableGenBackends.h | 6 +- lldb/utils/TableGen/LLDBTableGenUtils.cpp | 4 +- lldb/utils/TableGen/LLDBTableGenUtils.h | 5 +- llvm-spirv/include/LLVMSPIRVOpts.h | 12 - llvm-spirv/lib/SPIRV/LLVMSPIRVOpts.cpp | 4 +- llvm-spirv/lib/SPIRV/LLVMToSPIRVDbgTran.cpp | 4 +- llvm-spirv/lib/SPIRV/OCLToSPIRV.cpp | 11 +- llvm-spirv/lib/SPIRV/OCLUtil.h | 26 +- llvm-spirv/lib/SPIRV/SPIRVInternal.h | 15 +- llvm-spirv/lib/SPIRV/SPIRVReader.cpp | 183 +- llvm-spirv/lib/SPIRV/SPIRVReader.h | 3 +- llvm-spirv/lib/SPIRV/SPIRVRegularizeLLVM.cpp | 27 +- llvm-spirv/lib/SPIRV/SPIRVUtil.cpp | 30 +- llvm-spirv/lib/SPIRV/SPIRVWriter.cpp | 226 +- llvm-spirv/lib/SPIRV/libSPIRV/SPIRVDebug.h | 4 +- llvm-spirv/lib/SPIRV/libSPIRV/SPIRVEntry.h | 1 - .../lib/SPIRV/libSPIRV/SPIRVErrorEnum.h | 6 +- .../lib/SPIRV/libSPIRV/SPIRVInstruction.cpp | 9 - .../lib/SPIRV/libSPIRV/SPIRVInstruction.h | 60 +- .../SPIRV/libSPIRV/SPIRVMemAliasingINTEL.h | 5 +- llvm-spirv/lib/SPIRV/libSPIRV/SPIRVModule.cpp | 26 +- llvm-spirv/lib/SPIRV/libSPIRV/SPIRVModule.h | 24 +- .../lib/SPIRV/libSPIRV/SPIRVOpCodeEnum.h | 4 - llvm-spirv/test/AtomicCompareExchange.ll | 6 +- llvm-spirv/test/DebugInfo/X86/header.ll | 2 +- ...DecorateString_UserSemantic_Builtin.spvasm | 45 - llvm-spirv/test/atomic-load-store.ll | 17 +- llvm-spirv/test/atomicrmw.ll | 23 +- .../builtin_printf.ll | 3 +- .../atomicrmw_fadd_double.ll | 4 +- .../atomicrmw_fadd_float.ll | 4 +- .../atomicrmw_fadd_half.ll | 4 +- .../atomicrmw_fsub_double.ll | 4 +- .../atomicrmw_fsub_float.ll | 4 +- .../atomicrmw_fsub_half.ll | 4 +- .../atomicrmw_fminfmax_double.ll | 6 +- .../atomicrmw_fminfmax_float.ll | 6 +- .../atomicrmw_fminfmax_half.ll | 6 +- .../function_attributes.ll | 2 +- .../CodeSectionINTEL/alias.ll | 49 - .../CodeSectionINTEL/bitcast.ll | 53 - .../const-function-pointer.ll | 67 - .../decor-func-ptr-arg-attr.ll | 67 - .../CodeSectionINTEL/fp-from-host.ll | 69 - .../function-pointer-as-function-arg.ll | 177 - .../function-pointer-dedicated-as.ll | 107 - .../CodeSectionINTEL/function-pointer.ll | 92 - .../global-function-pointer.ll | 25 - .../CodeSectionINTEL/global_ctor_dtor.ll | 77 - .../global_ctor_dtor_addrspace.ll | 34 - .../CodeSectionINTEL/gv-func-ptr.ll | 40 - .../non-uniform-function-pointer.ll | 138 - .../CodeSectionINTEL/referenced-indirectly.ll | 82 - .../CodeSectionINTEL/select.ll | 142 - .../KHR/SPV_KHR_shader_clock/shader_clock.cl | 2 +- .../KHR/SPV_KHR_untyped_pointers/globals.ll | 32 +- .../SPV_KHR_untyped_pointers/infinite-phi.ll | 3 +- .../KHR/SPV_KHR_untyped_pointers/store.ll | 3 +- .../untyped_ptr_access_chain.ll | 46 - .../untyped_ptr_type.ll | 3 +- .../untyped_var.spvasm | 3 + llvm-spirv/test/llvm-intrinsics/lifetime.ll | 6 - .../test/llvm-intrinsics/memset-align.ll | 38 - llvm-spirv/test/llvm-intrinsics/scmp.ll | 335 - llvm-spirv/test/llvm-intrinsics/ucmp.ll | 335 - .../test/phi-multiple-predecessors.spvasm | 37 - llvm-spirv/test/transcoding/BuiltinPrintf.cl | 3 +- .../OpenCL/atomic_syncscope_test.ll | 8 +- llvm-spirv/test/transcoding/Printf.cl | 3 +- llvm-spirv/test/transcoding/fence_inst.ll | 2 +- llvm-spirv/test/transcoding/float16.ll | 31 +- .../transcoding/multiple_user_semantic.ll | 20 +- llvm-spirv/tools/llvm-spirv/llvm-spirv.cpp | 7 - llvm/CMakeLists.txt | 42 +- llvm/RELEASE_TESTERS.TXT | 2 +- llvm/benchmarks/CMakeLists.txt | 5 - .../GetIntrinsicInfoTableEntriesBM.cpp | 30 - llvm/benchmarks/SandboxIRBench.cpp | 241 - llvm/bindings/ocaml/llvm/llvm.ml | 2 - llvm/bindings/ocaml/llvm/llvm.mli | 2 - llvm/cmake/config-ix.cmake | 4 +- llvm/cmake/modules/AddLLVM.cmake | 45 - llvm/cmake/modules/HandleLLVMOptions.cmake | 6 - .../modules/LLVMExternalProjectUtils.cmake | 27 - llvm/cmake/modules/VersionFromVCS.cmake | 24 - ...arfExtensionsForHeterogeneousDebugging.rst | 2 +- llvm/docs/AMDGPUUsage.rst | 2280 +--- llvm/docs/AssignmentTracking.md | 20 +- llvm/docs/CodeReview.rst | 6 +- llvm/docs/CommandGuide/llvm-profdata.rst | 19 - llvm/docs/CommandGuide/tblgen.rst | 4 - llvm/docs/Contributing.rst | 2 +- llvm/docs/Coroutines.rst | 18 - llvm/docs/DeveloperPolicy.rst | 149 +- llvm/docs/DirectX/DXILResources.rst | 198 +- llvm/docs/Extensions.rst | 6 - llvm/docs/FAQ.rst | 7 - llvm/docs/GlobalISel/GenericOpcode.rst | 11 +- llvm/docs/GlobalISel/MIRPatterns.rst | 19 +- llvm/docs/HowToReleaseLLVM.rst | 12 +- llvm/docs/HowToUpdateDebugInfo.rst | 16 +- llvm/docs/JITLink.rst | 20 +- llvm/docs/LangRef.rst | 65 +- llvm/docs/RISCVUsage.rst | 89 +- llvm/docs/ReleaseNotes.rst | 3 - llvm/docs/TestSuiteGuide.md | 21 +- llvm/docs/conf.py | 4 +- llvm/examples/IRTransforms/SimplifyCFG.cpp | 7 +- llvm/include/llvm/ADT/Any.h | 2 +- llvm/include/llvm/ADT/DenseMap.h | 256 +- llvm/include/llvm/ADT/DenseSet.h | 55 +- llvm/include/llvm/ADT/PagedVector.h | 2 +- llvm/include/llvm/ADT/STLExtras.h | 3 +- llvm/include/llvm/ADT/SmallVector.h | 13 + llvm/include/llvm/ADT/SmallVectorExtras.h | 2 +- llvm/include/llvm/ADT/StableHashing.h | 6 - llvm/include/llvm/ADT/TinyPtrVector.h | 4 +- .../llvm/Analysis/BranchProbabilityInfo.h | 2 +- llvm/include/llvm/Analysis/CtxProfAnalysis.h | 24 +- .../llvm/Analysis/DOTGraphTraitsPass.h | 7 +- .../include/llvm/Analysis/DominanceFrontier.h | 20 + .../llvm/Analysis/DominanceFrontierImpl.h | 78 + llvm/include/llvm/Analysis/IVDescriptors.h | 3 + .../Analysis/IndirectCallPromotionAnalysis.h | 5 +- llvm/include/llvm/Analysis/LazyCallGraph.h | 2 +- .../llvm/Analysis/LoopAccessAnalysis.h | 1 - llvm/include/llvm/Analysis/LoopInfo.h | 2 +- llvm/include/llvm/Analysis/LoopNestAnalysis.h | 2 +- llvm/include/llvm/Analysis/MLModelRunner.h | 4 +- llvm/include/llvm/Analysis/MemorySSA.h | 30 +- llvm/include/llvm/Analysis/ScalarEvolution.h | 53 +- .../llvm/Analysis/SyntheticCountsUtils.h | 1 - .../llvm/Analysis/TargetLibraryInfo.def | 30 - .../include/llvm/Analysis/TargetLibraryInfo.h | 6 - .../llvm/Analysis/TargetTransformInfo.h | 21 +- .../llvm/Analysis/TargetTransformInfoImpl.h | 26 +- llvm/include/llvm/Analysis/ValueTracking.h | 3 - llvm/include/llvm/AsmParser/LLParser.h | 4 +- llvm/include/llvm/AsmParser/LLToken.h | 2 - llvm/include/llvm/BinaryFormat/ELF.h | 1 - llvm/include/llvm/BinaryFormat/Wasm.h | 8 - llvm/include/llvm/Bitcode/LLVMBitCodes.h | 7 +- llvm/include/llvm/CodeGen/AsmPrinter.h | 4 - llvm/include/llvm/CodeGen/BasicTTIImpl.h | 48 +- llvm/include/llvm/CodeGen/CodeGenCommonISel.h | 6 +- llvm/include/llvm/CodeGen/DebugHandlerBase.h | 2 +- .../llvm/CodeGen/GlobalISel/CallLowering.h | 21 +- .../llvm/CodeGen/GlobalISel/CombinerHelper.h | 21 +- .../CodeGen/GlobalISel/GenericMachineInstrs.h | 12 - .../llvm/CodeGen/GlobalISel/LegalizerHelper.h | 2 - .../CodeGen/GlobalISel/MachineIRBuilder.h | 45 - llvm/include/llvm/CodeGen/GlobalISel/Utils.h | 78 - llvm/include/llvm/CodeGen/ISDOpcodes.h | 4 +- llvm/include/llvm/CodeGen/LiveRangeEdit.h | 2 +- llvm/include/llvm/CodeGen/MachineBasicBlock.h | 12 +- llvm/include/llvm/CodeGen/MachineCSE.h | 29 - .../llvm/CodeGen/MachineDominanceFrontier.h | 24 + llvm/include/llvm/CodeGen/MachineFunction.h | 2 +- llvm/include/llvm/CodeGen/MachineInstr.h | 13 +- llvm/include/llvm/CodeGen/MachineLICM.h | 34 - llvm/include/llvm/CodeGen/MachineOutliner.h | 40 +- llvm/include/llvm/CodeGen/MachinePipeliner.h | 70 +- .../llvm/CodeGen/MachineTraceMetrics.h | 6 +- llvm/include/llvm/CodeGen/Passes.h | 2 +- llvm/include/llvm/CodeGen/Register.h | 11 +- llvm/include/llvm/CodeGen/SDPatternMatch.h | 4 - llvm/include/llvm/CodeGen/SelectionDAG.h | 15 +- llvm/include/llvm/CodeGen/SelectionDAGNodes.h | 40 +- .../llvm/CodeGen/SwitchLoweringUtils.h | 8 +- llvm/include/llvm/CodeGen/TargetCallingConv.h | 8 +- llvm/include/llvm/CodeGen/TargetInstrInfo.h | 31 +- llvm/include/llvm/CodeGen/TargetLowering.h | 21 +- .../include/llvm/CodeGen/TargetRegisterInfo.h | 22 + .../llvm/CodeGen/TargetSubtargetInfo.h | 12 +- llvm/include/llvm/CodeGen/VirtRegMap.h | 43 +- llvm/include/llvm/Config/config.h.cmake | 12 +- llvm/include/llvm/Demangle/ItaniumDemangle.h | 128 +- .../llvm/Demangle/MicrosoftDemangleNodes.h | 2 - llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h | 2 - llvm/include/llvm/Frontend/OpenMP/OMP.td | 11 +- llvm/include/llvm/IR/Attributes.td | 12 - llvm/include/llvm/IR/Constant.h | 4 +- llvm/include/llvm/IR/Constants.h | 37 +- llvm/include/llvm/IR/DIBuilder.h | 2 +- llvm/include/llvm/IR/DebugInfoMetadata.h | 9 +- llvm/include/llvm/IR/DerivedTypes.h | 24 +- llvm/include/llvm/IR/DerivedUser.h | 4 +- llvm/include/llvm/IR/DiagnosticInfo.h | 17 - llvm/include/llvm/IR/Function.h | 16 +- .../llvm/IR/GenericConvergenceVerifierImpl.h | 5 +- llvm/include/llvm/IR/GlobalAlias.h | 4 +- llvm/include/llvm/IR/GlobalIFunc.h | 4 +- llvm/include/llvm/IR/GlobalObject.h | 7 +- llvm/include/llvm/IR/GlobalValue.h | 6 +- llvm/include/llvm/IR/GlobalVariable.h | 31 +- llvm/include/llvm/IR/IRBuilder.h | 51 +- llvm/include/llvm/IR/InstrTypes.h | 182 +- llvm/include/llvm/IR/Instruction.h | 8 +- llvm/include/llvm/IR/Instructions.h | 324 +- llvm/include/llvm/IR/IntrinsicInst.h | 8 - llvm/include/llvm/IR/Intrinsics.h | 6 +- llvm/include/llvm/IR/Intrinsics.td | 13 +- llvm/include/llvm/IR/IntrinsicsAArch64.td | 74 - llvm/include/llvm/IR/IntrinsicsAMDGPU.td | 64 +- llvm/include/llvm/IR/IntrinsicsDirectX.td | 41 +- llvm/include/llvm/IR/IntrinsicsSPIRV.td | 5 - llvm/include/llvm/IR/IntrinsicsX86.td | 353 - llvm/include/llvm/IR/Mangler.h | 5 - llvm/include/llvm/IR/Metadata.h | 2 +- llvm/include/llvm/IR/Module.h | 2 +- llvm/include/llvm/IR/ModuleSummaryIndex.h | 67 +- llvm/include/llvm/IR/ModuleSummaryIndexYAML.h | 17 +- llvm/include/llvm/IR/OperandTraits.h | 4 +- llvm/include/llvm/IR/Operator.h | 4 +- llvm/include/llvm/IR/RuntimeLibcalls.def | 1 - llvm/include/llvm/IR/User.h | 106 +- llvm/include/llvm/IR/VPIntrinsics.def | 1 - llvm/include/llvm/IR/VectorBuilder.h | 6 +- llvm/include/llvm/InitializePasses.h | 3 +- llvm/include/llvm/LTO/Config.h | 5 - llvm/include/llvm/LTO/LTO.h | 26 +- .../llvm/LTO/SummaryBasedOptimizations.h | 18 + llvm/include/llvm/LinkAllPasses.h | 1 - llvm/include/llvm/MC/MCExpr.h | 1 - .../llvm/MC/MCParser/MCTargetAsmParser.h | 14 +- llvm/include/llvm/MC/MCPseudoProbe.h | 4 - llvm/include/llvm/MC/MCRegister.h | 7 +- llvm/include/llvm/MC/MCRegisterInfo.h | 4 +- llvm/include/llvm/MC/MCStreamer.h | 2 +- llvm/include/llvm/MC/MCTargetOptions.h | 5 +- .../llvm/MCA/HardwareUnits/ResourceManager.h | 31 +- llvm/include/llvm/Object/COFFImportFile.h | 8 +- llvm/include/llvm/Object/ELF.h | 6 - llvm/include/llvm/Object/IRSymtab.h | 3 +- llvm/include/llvm/Object/Minidump.h | 83 +- llvm/include/llvm/Object/XCOFFObjectFile.h | 8 - llvm/include/llvm/Passes/CodeGenPassBuilder.h | 6 - .../llvm/Passes/MachinePassRegistry.def | 7 +- llvm/include/llvm/Passes/PassBuilder.h | 1 + .../ProfileData/Coverage/CoverageMapping.h | 4 +- .../llvm/ProfileData/CtxInstrContextNode.h | 25 +- llvm/include/llvm/ProfileData/InstrProf.h | 2 +- .../llvm/ProfileData/InstrProfCorrelator.h | 6 +- .../llvm/ProfileData/InstrProfReader.h | 47 +- .../llvm/ProfileData/PGOCtxProfReader.h | 22 +- llvm/include/llvm/ProfileData/ProfileCommon.h | 6 +- .../llvm/ProfileData/SampleProfReader.h | 21 - llvm/include/llvm/SandboxIR/Pass.h | 57 - llvm/include/llvm/SandboxIR/PassManager.h | 110 - llvm/include/llvm/SandboxIR/SandboxIR.h | 1237 +- .../llvm/SandboxIR/SandboxIRValues.def | 16 - llvm/include/llvm/SandboxIR/Tracker.h | 15 +- llvm/include/llvm/SandboxIR/Type.h | 186 +- llvm/include/llvm/Support/AMDGPUAddrSpace.h | 14 - llvm/include/llvm/Support/AutoConvert.h | 14 +- llvm/include/llvm/Support/Casting.h | 2 +- llvm/include/llvm/Support/Compiler.h | 81 +- llvm/include/llvm/Support/FormatCommon.h | 20 +- llvm/include/llvm/Support/FormatVariadic.h | 37 +- llvm/include/llvm/Support/GlobPattern.h | 9 +- llvm/include/llvm/Support/OptionStrCmp.h | 32 - llvm/include/llvm/Support/TargetOpcodes.def | 15 +- llvm/include/llvm/Support/VirtualFileSystem.h | 54 - llvm/include/llvm/Support/raw_ostream.h | 19 - llvm/include/llvm/TableGen/AArch64ImmCheck.h | 37 - llvm/include/llvm/TableGen/DirectiveEmitter.h | 65 +- llvm/include/llvm/TableGen/Error.h | 8 +- llvm/include/llvm/TableGen/Record.h | 61 +- llvm/include/llvm/TableGen/SetTheory.h | 4 +- llvm/include/llvm/Target/GenericOpcodes.td | 16 +- .../include/llvm/Target/GlobalISel/Combine.td | 205 +- .../Target/GlobalISel/SelectionDAGCompat.td | 4 - llvm/include/llvm/Target/Target.td | 7 - llvm/include/llvm/Target/TargetOptions.h | 7 - .../include/llvm/Target/TargetSelectionDAG.td | 6 - llvm/include/llvm/TargetParser/Triple.h | 14 - .../llvm/TargetParser/X86TargetParser.def | 3 - .../llvm/TargetParser/X86TargetParser.h | 1 - .../Coroutines/CoroAnnotationElide.h | 32 - llvm/include/llvm/Transforms/IPO/Attributor.h | 5 +- .../llvm/Transforms/IPO/FunctionImport.h | 35 +- .../llvm/Transforms/IPO/ProfiledCallGraph.h | 6 +- .../Transforms/IPO/SampleProfileMatcher.h | 1 - .../IPO/SyntheticCountsPropagation.h | 23 + .../Transforms/InstCombine/InstCombiner.h | 8 +- .../Transforms/{Utils => }/Instrumentation.h | 0 .../llvm/Transforms/Instrumentation/CFGMST.h | 4 +- .../Transforms/Instrumentation/GCOVProfiler.h | 2 +- .../Instrumentation/InstrProfiling.h | 2 +- .../Instrumentation/PGOCtxProfFlattening.h | 25 - .../Instrumentation/SanitizerBinaryMetadata.h | 2 +- .../Instrumentation/SanitizerCoverage.h | 2 +- llvm/include/llvm/Transforms/Scalar/GVN.h | 2 +- .../llvm/Transforms/Scalar/Scalarizer.h | 5 - llvm/include/llvm/Transforms/Utils/Cloning.h | 12 - .../include/llvm/Transforms/Utils/LoopUtils.h | 38 +- .../llvm/Transforms/Utils/SCCPSolver.h | 7 +- .../llvm/Transforms/Utils/SSAUpdaterImpl.h | 9 +- .../Utils/SampleProfileLoaderBaseImpl.h | 4 +- .../llvm/Transforms/Utils/SimplifyLibCalls.h | 8 +- .../Vectorize/LoopVectorizationLegality.h | 62 - .../SandboxVectorizer/DependencyGraph.h | 86 - .../SandboxVectorizer/InstrInterval.h | 111 - .../Vectorize/SandboxVectorizer/Legality.h | 62 - .../SandboxVectorizer/Passes/BottomUpVec.h | 35 - .../Vectorize/SandboxVectorizer/Region.h | 104 - .../SandboxVectorizer/SandboxVectorizer.h | 28 - llvm/include/llvm/XRay/Graph.h | 15 +- llvm/lib/Analysis/BasicAliasAnalysis.cpp | 31 +- llvm/lib/Analysis/CtxProfAnalysis.cpp | 61 +- .../Analysis/FunctionPropertiesAnalysis.cpp | 4 +- llvm/lib/Analysis/IRSimilarityIdentifier.cpp | 28 +- llvm/lib/Analysis/IVDescriptors.cpp | 59 +- llvm/lib/Analysis/LazyValueInfo.cpp | 3 +- llvm/lib/Analysis/Lint.cpp | 27 +- llvm/lib/Analysis/Loads.cpp | 34 +- llvm/lib/Analysis/MLInlineAdvisor.cpp | 6 +- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | 46 +- llvm/lib/Analysis/ScalarEvolution.cpp | 119 +- llvm/lib/Analysis/TargetLibraryInfo.cpp | 2 - llvm/lib/Analysis/TargetTransformInfo.cpp | 5 - llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp | 9 +- llvm/lib/Analysis/ValueTracking.cpp | 97 +- llvm/lib/Analysis/VectorUtils.cpp | 4 - llvm/lib/AsmParser/LLLexer.cpp | 2 - llvm/lib/AsmParser/LLParser.cpp | 30 +- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 86 +- llvm/lib/Bitcode/Reader/MetadataLoader.cpp | 12 +- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 13 +- llvm/lib/CGData/CodeGenData.cpp | 26 +- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 63 - llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 45 +- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 67 +- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 6 +- llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp | 16 +- llvm/lib/CodeGen/AsmPrinter/DwarfFile.h | 4 - .../CodeGen/AssignmentTrackingAnalysis.cpp | 8 +- llvm/lib/CodeGen/AtomicExpandPass.cpp | 32 +- llvm/lib/CodeGen/CMakeLists.txt | 1 - llvm/lib/CodeGen/CodeGen.cpp | 2 +- llvm/lib/CodeGen/CodeGenCommonISel.cpp | 10 +- .../CodeGen/DeadMachineInstructionElim.cpp | 34 +- llvm/lib/CodeGen/EarlyIfConversion.cpp | 297 +- llvm/lib/CodeGen/ExpandVectorPredication.cpp | 49 +- llvm/lib/CodeGen/GlobalISel/CMakeLists.txt | 1 - .../GlobalISel/CombinerHelperCasts.cpp | 46 - .../GlobalISel/CombinerHelperCompares.cpp | 145 - .../GlobalISel/CombinerHelperVectorOps.cpp | 62 +- llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 41 +- .../CodeGen/GlobalISel/LegalizerHelper.cpp | 174 - .../CodeGen/GlobalISel/MachineIRBuilder.cpp | 2 +- llvm/lib/CodeGen/GlobalISel/Utils.cpp | 107 +- llvm/lib/CodeGen/ImplicitNullChecks.cpp | 2 +- llvm/lib/CodeGen/InitUndef.cpp | 49 +- llvm/lib/CodeGen/InlineSpiller.cpp | 2 +- .../LiveDebugValues/InstrRefBasedImpl.cpp | 8 +- .../LiveDebugValues/InstrRefBasedImpl.h | 22 +- llvm/lib/CodeGen/MIRParser/MIParser.cpp | 4 +- llvm/lib/CodeGen/MIRParser/MIRParser.cpp | 2 +- llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp | 36 +- llvm/lib/CodeGen/MachineCSE.cpp | 289 +- llvm/lib/CodeGen/MachineCopyPropagation.cpp | 8 +- llvm/lib/CodeGen/MachineInstr.cpp | 26 +- llvm/lib/CodeGen/MachineLICM.cpp | 171 +- llvm/lib/CodeGen/MachineOperand.cpp | 2 +- llvm/lib/CodeGen/MachineOutliner.cpp | 264 +- llvm/lib/CodeGen/MachinePipeliner.cpp | 45 +- llvm/lib/CodeGen/MachineVerifier.cpp | 62 +- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 300 +- .../lib/CodeGen/SelectionDAG/InstrEmitter.cpp | 10 +- .../SelectionDAG/LegalizeFloatTypes.cpp | 76 +- .../SelectionDAG/LegalizeIntegerTypes.cpp | 23 +- llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h | 1 - .../SelectionDAG/LegalizeTypesGeneric.cpp | 9 - .../SelectionDAG/LegalizeVectorOps.cpp | 189 +- .../SelectionDAG/LegalizeVectorTypes.cpp | 26 +- .../lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 111 +- .../SelectionDAG/SelectionDAGBuilder.cpp | 91 +- .../SelectionDAG/SelectionDAGBuilder.h | 10 +- .../SelectionDAG/SelectionDAGDumper.cpp | 5 - .../CodeGen/SelectionDAG/SelectionDAGISel.cpp | 8 +- .../CodeGen/SelectionDAG/TargetLowering.cpp | 116 +- llvm/lib/CodeGen/SplitKit.cpp | 2 +- llvm/lib/CodeGen/StackMaps.cpp | 2 +- llvm/lib/CodeGen/StackSlotColoring.cpp | 4 +- llvm/lib/CodeGen/SwitchLoweringUtils.cpp | 4 +- llvm/lib/CodeGen/TargetLoweringBase.cpp | 2 - llvm/lib/CodeGen/TargetPassConfig.cpp | 6 +- llvm/lib/CodeGen/VirtRegMap.cpp | 20 +- .../lib/DWARFLinker/Parallel/OutputSections.h | 13 +- llvm/lib/DebugInfo/DWARF/DWARFDie.cpp | 13 +- llvm/lib/DebugInfo/GSYM/GsymCreator.cpp | 3 +- .../LogicalView/Readers/LVDWARFReader.cpp | 2 +- llvm/lib/DebugInfo/PDB/PDBSymbolFunc.cpp | 7 +- llvm/lib/Demangle/MicrosoftDemangle.cpp | 4 - llvm/lib/Demangle/MicrosoftDemangleNodes.cpp | 2 - llvm/lib/ExecutionEngine/ExecutionEngine.cpp | 2 +- .../Interpreter/Interpreter.cpp | 2 +- llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp | 2 +- llvm/lib/ExecutionEngine/Orc/Core.cpp | 15 - llvm/lib/ExecutionEngine/Orc/LLJIT.cpp | 27 +- .../lib/ExecutionEngine/Orc/MachOPlatform.cpp | 1 - .../Orc/ObjectLinkingLayer.cpp | 7 +- .../Orc/TargetProcess/JITLoaderPerf.cpp | 4 +- .../PerfJITEvents/PerfJITEventListener.cpp | 7 +- .../RuntimeDyld/RuntimeDyld.cpp | 5 +- .../RuntimeDyld/RuntimeDyldCOFF.cpp | 10 - .../RuntimeDyld/RuntimeDyldCOFF.h | 7 - .../RuntimeDyld/RuntimeDyldChecker.cpp | 10 +- .../RuntimeDyld/RuntimeDyldELF.cpp | 4 +- .../RuntimeDyld/RuntimeDyldImpl.h | 10 - .../Targets/RuntimeDyldCOFFThumb.h | 2 +- llvm/lib/Frontend/OpenMP/OMP.cpp | 2 +- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 47 +- llvm/lib/IR/AutoUpgrade.cpp | 3 +- llvm/lib/IR/ConstantRange.cpp | 6 +- llvm/lib/IR/Constants.cpp | 38 +- llvm/lib/IR/ConstantsContext.h | 50 +- llvm/lib/IR/DebugInfo.cpp | 6 +- llvm/lib/IR/DebugInfoMetadata.cpp | 2 +- llvm/lib/IR/DebugProgramInstruction.cpp | 5 +- llvm/lib/IR/DiagnosticInfo.cpp | 4 - llvm/lib/IR/Function.cpp | 24 +- llvm/lib/IR/Globals.cpp | 11 +- llvm/lib/IR/IRBuilder.cpp | 4 +- llvm/lib/IR/Instruction.cpp | 4 +- llvm/lib/IR/Instructions.cpp | 239 +- llvm/lib/IR/LLVMContext.cpp | 8 +- llvm/lib/IR/MDBuilder.cpp | 4 +- llvm/lib/IR/Mangler.cpp | 39 +- llvm/lib/IR/Metadata.cpp | 6 +- llvm/lib/IR/ModuleSummaryIndex.cpp | 11 +- llvm/lib/IR/Type.cpp | 47 +- llvm/lib/IR/TypeFinder.cpp | 14 - llvm/lib/IR/User.cpp | 32 +- llvm/lib/IR/VectorBuilder.cpp | 8 +- llvm/lib/IR/Verifier.cpp | 14 - llvm/lib/LTO/CMakeLists.txt | 1 + llvm/lib/LTO/LTO.cpp | 40 +- llvm/lib/LTO/SummaryBasedOptimizations.cpp | 88 + llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 6 +- llvm/lib/MC/ELFObjectWriter.cpp | 65 +- llvm/lib/MC/MCAsmStreamer.cpp | 2 +- llvm/lib/MC/MCCodeView.cpp | 4 +- llvm/lib/MC/MCDwarf.cpp | 2 +- llvm/lib/MC/MCExpr.cpp | 264 +- llvm/lib/MC/MCParser/AsmParser.cpp | 8 +- llvm/lib/MC/MCParser/ELFAsmParser.cpp | 2 - llvm/lib/MC/MCParser/MasmParser.cpp | 12 +- llvm/lib/MC/MCRegisterInfo.cpp | 8 +- llvm/lib/MC/MCSectionELF.cpp | 2 - .../lib/MCA/HardwareUnits/ResourceManager.cpp | 87 +- llvm/lib/Object/BuildID.cpp | 2 +- llvm/lib/Object/ELF.cpp | 10 +- llvm/lib/Object/MachOObjectFile.cpp | 26 +- llvm/lib/Object/Minidump.cpp | 17 +- llvm/lib/Object/XCOFFObjectFile.cpp | 23 +- llvm/lib/ObjectYAML/MinidumpYAML.cpp | 2 +- llvm/lib/Option/ArgList.cpp | 2 +- llvm/lib/Option/OptTable.cpp | 52 +- llvm/lib/Option/Option.cpp | 3 +- llvm/lib/Passes/PassBuilder.cpp | 8 +- llvm/lib/Passes/PassBuilderPipelines.cpp | 55 +- llvm/lib/Passes/PassRegistry.def | 4 +- .../Coverage/CoverageMappingReader.cpp | 4 +- llvm/lib/ProfileData/InstrProfCorrelator.cpp | 26 +- llvm/lib/ProfileData/InstrProfReader.cpp | 50 +- llvm/lib/ProfileData/PGOCtxProfReader.cpp | 8 + llvm/lib/SandboxIR/CMakeLists.txt | 2 - llvm/lib/SandboxIR/Pass.cpp | 20 - llvm/lib/SandboxIR/PassManager.cpp | 60 - llvm/lib/SandboxIR/SandboxIR.cpp | 574 +- llvm/lib/SandboxIR/Tracker.cpp | 10 - llvm/lib/SandboxIR/Type.cpp | 74 +- llvm/lib/Support/APInt.cpp | 19 +- llvm/lib/Support/AutoConvert.cpp | 20 +- llvm/lib/Support/CMakeLists.txt | 1 - llvm/lib/Support/FormatVariadic.cpp | 148 +- llvm/lib/Support/InitLLVM.cpp | 10 +- llvm/lib/Support/MemoryBuffer.cpp | 2 +- llvm/lib/Support/OptionStrCmp.cpp | 43 - llvm/lib/Support/SmallVector.cpp | 16 +- llvm/lib/Support/Unix/Path.inc | 10 +- llvm/lib/Support/Unix/Program.inc | 2 +- llvm/lib/Support/Unix/Threading.inc | 44 +- llvm/lib/Support/VirtualFileSystem.cpp | 26 - llvm/lib/Support/YAMLParser.cpp | 5 +- llvm/lib/Support/raw_ostream.cpp | 8 +- llvm/lib/TableGen/DetailedRecordsBackend.cpp | 17 +- llvm/lib/TableGen/Error.cpp | 52 +- llvm/lib/TableGen/Parser.cpp | 2 +- llvm/lib/TableGen/Record.cpp | 249 +- llvm/lib/TableGen/TGParser.cpp | 2 +- llvm/lib/Target/AArch64/AArch64.td | 4 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 11 +- llvm/lib/Target/AArch64/AArch64Combine.td | 26 +- .../Target/AArch64/AArch64FrameLowering.cpp | 27 +- .../Target/AArch64/AArch64ISelDAGToDAG.cpp | 28 - .../Target/AArch64/AArch64ISelLowering.cpp | 385 +- llvm/lib/Target/AArch64/AArch64ISelLowering.h | 8 +- .../lib/Target/AArch64/AArch64InstrFormats.td | 19 +- llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 4 + llvm/lib/Target/AArch64/AArch64InstrInfo.td | 381 +- .../AArch64/AArch64LoadStoreOptimizer.cpp | 120 +- .../Target/AArch64/AArch64MIPeepholeOpt.cpp | 58 - llvm/lib/Target/AArch64/AArch64Processors.td | 4 +- .../lib/Target/AArch64/AArch64SVEInstrInfo.td | 126 +- .../Target/AArch64/AArch64SchedNeoverseN2.td | 1517 ++- .../Target/AArch64/AArch64SchedNeoverseN3.td | 2333 ---- .../Target/AArch64/AArch64SchedNeoverseV2.td | 1774 +-- .../AArch64/AArch64StorePairSuppress.cpp | 4 +- .../AArch64/AArch64TargetTransformInfo.cpp | 88 +- .../AArch64/AArch64TargetTransformInfo.h | 5 +- .../AArch64/AsmParser/AArch64AsmParser.cpp | 117 +- .../AArch64/GISel/AArch64CallLowering.cpp | 3 +- .../GISel/AArch64InstructionSelector.cpp | 116 +- .../AArch64/GISel/AArch64LegalizerInfo.cpp | 77 +- .../GISel/AArch64PostLegalizerLowering.cpp | 34 - .../AArch64/GISel/AArch64RegisterBankInfo.cpp | 4 - .../MCTargetDesc/AArch64AsmBackend.cpp | 8 +- llvm/lib/Target/AArch64/SVEInstrFormats.td | 159 +- llvm/lib/Target/AMDGPU/AMDGPU.h | 26 +- .../Target/AMDGPU/AMDGPUAtomicOptimizer.cpp | 18 +- llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp | 28 +- llvm/lib/Target/AMDGPU/AMDGPUCallingConv.td | 10 +- llvm/lib/Target/AMDGPU/AMDGPUGISel.td | 1 - llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp | 19 +- llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp | 36 +- llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h | 3 +- .../AMDGPU/AMDGPUInstCombineIntrinsic.cpp | 85 +- .../AMDGPU/AMDGPUInstructionSelector.cpp | 24 +- .../Target/AMDGPU/AMDGPUInstructionSelector.h | 1 - .../lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp | 28 +- llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.h | 2 - .../AMDGPU/AMDGPULowerBufferFatPointers.cpp | 3 - .../AMDGPU/AMDGPULowerModuleLDSPass.cpp | 15 +- .../lib/Target/AMDGPU/AMDGPUMachineFunction.h | 5 - llvm/lib/Target/AMDGPU/AMDGPUPassRegistry.def | 2 - .../lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp | 8 +- .../Target/AMDGPU/AMDGPURegisterBankInfo.cpp | 30 +- .../Target/AMDGPU/AMDGPUSearchableTables.td | 1 - llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp | 1792 +-- llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp | 5 +- .../lib/Target/AMDGPU/AMDGPUTargetMachine.cpp | 20 +- .../Target/AMDGPU/AMDGPUTargetTransformInfo.h | 5 +- .../AMDGPU/AsmParser/AMDGPUAsmParser.cpp | 54 +- llvm/lib/Target/AMDGPU/BUFInstructions.td | 5 +- .../Disassembler/AMDGPUDisassembler.cpp | 28 +- llvm/lib/Target/AMDGPU/GCNDPPCombine.cpp | 4 +- .../lib/Target/AMDGPU/GCNHazardRecognizer.cpp | 288 +- llvm/lib/Target/AMDGPU/GCNHazardRecognizer.h | 4 - .../Target/AMDGPU/GCNPreRAOptimizations.cpp | 2 +- llvm/lib/Target/AMDGPU/GCNSubtarget.cpp | 2 +- llvm/lib/Target/AMDGPU/GCNSubtarget.h | 8 - llvm/lib/Target/AMDGPU/InstCombineTables.td | 3 +- .../MCTargetDesc/AMDGPUMCTargetDesc.cpp | 6 +- llvm/lib/Target/AMDGPU/MIMGInstructions.td | 4 - llvm/lib/Target/AMDGPU/R600Subtarget.h | 6 - llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp | 4 +- llvm/lib/Target/AMDGPU/SIFrameLowering.cpp | 20 +- llvm/lib/Target/AMDGPU/SIISelLowering.cpp | 341 +- llvm/lib/Target/AMDGPU/SIISelLowering.h | 3 +- llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp | 192 +- llvm/lib/Target/AMDGPU/SIInstrInfo.cpp | 154 +- llvm/lib/Target/AMDGPU/SIInstrInfo.h | 3 - llvm/lib/Target/AMDGPU/SIInstrInfo.td | 217 +- llvm/lib/Target/AMDGPU/SIInstructions.td | 57 +- .../Target/AMDGPU/SILoadStoreOptimizer.cpp | 2 +- llvm/lib/Target/AMDGPU/SILowerWWMCopies.cpp | 5 +- .../Target/AMDGPU/SIMachineFunctionInfo.cpp | 2 +- .../lib/Target/AMDGPU/SIMachineFunctionInfo.h | 25 +- llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp | 185 +- llvm/lib/Target/AMDGPU/SIModeRegister.cpp | 14 +- llvm/lib/Target/AMDGPU/SIPeepholeSDWA.cpp | 56 +- llvm/lib/Target/AMDGPU/SIPeepholeSDWA.h | 24 - .../Target/AMDGPU/SIPreAllocateWWMRegs.cpp | 3 +- llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp | 6 +- llvm/lib/Target/AMDGPU/SIRegisterInfo.td | 45 +- .../Target/AMDGPU/SIShrinkInstructions.cpp | 52 +- llvm/lib/Target/AMDGPU/SIShrinkInstructions.h | 25 - llvm/lib/Target/AMDGPU/SIWholeQuadMode.cpp | 115 +- llvm/lib/Target/AMDGPU/SMInstructions.td | 33 - llvm/lib/Target/AMDGPU/VOP1Instructions.td | 27 +- llvm/lib/Target/AMDGPU/VOP2Instructions.td | 17 +- llvm/lib/Target/ARM/ARMAsmPrinter.cpp | 8 +- llvm/lib/Target/ARM/ARMBaseInstrInfo.h | 13 + llvm/lib/Target/ARM/ARMBaseRegisterInfo.h | 27 + llvm/lib/Target/ARM/ARMCallLowering.cpp | 2 +- llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp | 24 +- llvm/lib/Target/ARM/ARMISelLowering.cpp | 34 +- llvm/lib/Target/ARM/ARMInstrInfo.td | 12 + llvm/lib/Target/ARM/ARMMachineFunctionInfo.h | 10 +- llvm/lib/Target/ARM/ARMSubtarget.h | 7 + .../lib/Target/ARM/ARMTargetTransformInfo.cpp | 16 - llvm/lib/Target/ARM/ARMTargetTransformInfo.h | 5 +- .../lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 123 +- .../Target/ARM/MCTargetDesc/ARMAsmBackend.cpp | 20 +- .../lib/Target/ARM/MCTargetDesc/ARMBaseInfo.h | 48 +- .../ARM/MCTargetDesc/ARMELFStreamer.cpp | 26 +- .../ARM/MCTargetDesc/ARMInstPrinter.cpp | 38 +- .../ARM/MCTargetDesc/ARMMCCodeEmitter.cpp | 19 +- .../ARM/MCTargetDesc/ARMMCTargetDesc.cpp | 2 +- .../ARM/MCTargetDesc/ARMTargetStreamer.cpp | 2 +- .../lib/Target/AVR/AsmParser/AVRAsmParser.cpp | 99 +- .../Target/AVR/MCTargetDesc/AVRAsmBackend.cpp | 6 +- .../lib/Target/BPF/AsmParser/BPFAsmParser.cpp | 11 +- llvm/lib/Target/BPF/BPFInstrInfo.td | 2 +- llvm/lib/Target/BPF/BPFSubtarget.cpp | 2 - llvm/lib/Target/BPF/BPFTargetTransformInfo.h | 3 +- .../Target/CSKY/AsmParser/CSKYAsmParser.cpp | 8 +- llvm/lib/Target/DirectX/CMakeLists.txt | 1 - .../lib/Target/DirectX/DXContainerGlobals.cpp | 85 +- llvm/lib/Target/DirectX/DXIL.td | 57 +- .../Target/DirectX/DXILFinalizeLinkage.cpp | 5 - llvm/lib/Target/DirectX/DXILFinalizeLinkage.h | 1 - .../Target/DirectX/DXILIntrinsicExpansion.cpp | 62 +- .../Target/DirectX/DXILIntrinsicExpansion.h | 1 - llvm/lib/Target/DirectX/DXILOpBuilder.cpp | 40 +- llvm/lib/Target/DirectX/DXILOpBuilder.h | 5 +- llvm/lib/Target/DirectX/DXILOpLowering.cpp | 257 +- llvm/lib/Target/DirectX/DXILPrepare.cpp | 4 - llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp | 1 - .../Target/DirectX/DXILTranslateMetadata.cpp | 2 - .../DirectX/DXILWriter/DXILBitcodeWriter.cpp | 2 +- .../Target/DirectX/DirectXTargetMachine.cpp | 6 - .../DirectX/DirectXTargetTransformInfo.cpp | 25 - .../DirectX/DirectXTargetTransformInfo.h | 1 - .../Hexagon/AsmParser/HexagonAsmParser.cpp | 10 +- .../Target/Hexagon/HexagonExpandCondsets.cpp | 6 +- .../lib/Target/Hexagon/HexagonOptAddrMode.cpp | 298 +- .../Hexagon/HexagonTargetTransformInfo.h | 6 +- llvm/lib/Target/Hexagon/HexagonTfrCleanup.cpp | 6 +- .../Target/Hexagon/HexagonVectorCombine.cpp | 30 +- .../Target/Lanai/AsmParser/LanaiAsmParser.cpp | 8 +- .../Target/Lanai/LanaiTargetTransformInfo.h | 3 +- .../AsmParser/LoongArchAsmParser.cpp | 10 +- .../Target/LoongArch/LoongArchAsmPrinter.cpp | 43 - .../Target/LoongArch/LoongArchAsmPrinter.h | 2 - .../LoongArch/LoongArchISelLowering.cpp | 60 +- .../Target/LoongArch/LoongArchISelLowering.h | 2 - .../Target/LoongArch/LoongArchInstrInfo.cpp | 21 +- .../Target/LoongArch/LoongArchInstrInfo.td | 5 +- .../LoongArch/LoongArchLASXInstrInfo.td | 6 - .../Target/LoongArch/LoongArchLSXInstrInfo.td | 4 - .../Target/LoongArch/LoongArchOptWInstrs.cpp | 15 - .../LoongArchTargetTransformInfo.cpp | 6 - .../LoongArch/LoongArchTargetTransformInfo.h | 1 - .../MCTargetDesc/LoongArchBaseInfo.cpp | 2 - .../Target/M68k/AsmParser/M68kAsmParser.cpp | 8 +- llvm/lib/Target/M68k/M68kCallingConv.td | 4 +- llvm/lib/Target/M68k/M68kInstrInfo.cpp | 62 +- .../MSP430/AsmParser/MSP430AsmParser.cpp | 8 +- .../Target/Mips/AsmParser/MipsAsmParser.cpp | 17 +- .../Target/Mips/MCTargetDesc/MipsABIInfo.cpp | 3 +- llvm/lib/Target/Mips/Mips32r6InstrInfo.td | 37 - llvm/lib/Target/Mips/MipsCallingConv.td | 3 +- llvm/lib/Target/Mips/MipsFastISel.cpp | 30 +- llvm/lib/Target/Mips/MipsISelLowering.cpp | 84 +- llvm/lib/Target/Mips/MipsInstrInfo.h | 17 - llvm/lib/Target/Mips/MipsSEISelLowering.cpp | 5 - llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp | 60 +- llvm/lib/Target/NVPTX/NVPTXISelLowering.h | 3 - llvm/lib/Target/NVPTX/NVPTXIntrinsics.td | 16 - llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp | 52 +- llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp | 235 +- llvm/lib/Target/NVPTX/NVPTXSubtarget.h | 1 - llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp | 2 +- .../Target/NVPTX/NVPTXTargetTransformInfo.h | 3 +- .../Target/PowerPC/AsmParser/PPCAsmParser.cpp | 123 +- llvm/lib/Target/PowerPC/PPCCallingConv.td | 6 +- llvm/lib/Target/PowerPC/PPCFrameLowering.cpp | 3 +- llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 138 +- llvm/lib/Target/PowerPC/PPCISelLowering.h | 1 - .../Target/PowerPC/PPCTargetTransformInfo.h | 6 +- .../Target/RISCV/AsmParser/RISCVAsmParser.cpp | 98 +- llvm/lib/Target/RISCV/CMakeLists.txt | 6 - .../RISCV/Disassembler/RISCVDisassembler.cpp | 9 +- .../Target/RISCV/GISel/RISCVCallLowering.cpp | 127 +- .../Target/RISCV/GISel/RISCVLegalizerInfo.cpp | 75 +- .../GISel/RISCVPostLegalizerLowering.cpp | 154 - .../Target/RISCV/MCTargetDesc/RISCVBaseInfo.h | 8 - .../RISCV/MCTargetDesc/RISCVInstPrinter.cpp | 2 + .../RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp | 10 +- llvm/lib/Target/RISCV/RISCV.h | 6 - llvm/lib/Target/RISCV/RISCV.td | 1 - llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp | 28 +- llvm/lib/Target/RISCV/RISCVCallingConv.cpp | 686 - llvm/lib/Target/RISCV/RISCVCallingConv.h | 44 - llvm/lib/Target/RISCV/RISCVCombine.td | 7 - .../Target/RISCV/RISCVConstantPoolValue.cpp | 81 - .../lib/Target/RISCV/RISCVConstantPoolValue.h | 63 - llvm/lib/Target/RISCV/RISCVFeatures.td | 8 +- llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp | 99 +- llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h | 2 +- llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 1585 ++- llvm/lib/Target/RISCV/RISCVISelLowering.h | 46 +- llvm/lib/Target/RISCV/RISCVInstrFormats.td | 12 - llvm/lib/Target/RISCV/RISCVInstrInfo.cpp | 38 +- llvm/lib/Target/RISCV/RISCVInstrInfo.h | 19 +- llvm/lib/Target/RISCV/RISCVInstrInfo.td | 26 +- llvm/lib/Target/RISCV/RISCVInstrInfoD.td | 8 +- llvm/lib/Target/RISCV/RISCVInstrInfoF.td | 36 +- llvm/lib/Target/RISCV/RISCVInstrInfoV.td | 57 +- .../Target/RISCV/RISCVInstrInfoVPseudos.td | 19 +- .../Target/RISCV/RISCVInstrInfoVSDPatterns.td | 13 +- .../Target/RISCV/RISCVInstrInfoVVLPatterns.td | 19 +- llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td | 12 +- llvm/lib/Target/RISCV/RISCVInstrInfoXSf.td | 19 +- llvm/lib/Target/RISCV/RISCVInstrInfoZfa.td | 15 - .../lib/Target/RISCV/RISCVInstrInfoZfbfmin.td | 69 +- llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td | 48 +- llvm/lib/Target/RISCV/RISCVInstrInfoZvfbf.td | 5 +- llvm/lib/Target/RISCV/RISCVInstrInfoZvk.td | 3 +- llvm/lib/Target/RISCV/RISCVProcessors.td | 19 - llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp | 2 +- llvm/lib/Target/RISCV/RISCVRegisterInfo.h | 18 + llvm/lib/Target/RISCV/RISCVRegisterInfo.td | 4 +- llvm/lib/Target/RISCV/RISCVSchedSiFive7.td | 11 +- .../Target/RISCV/RISCVSchedSyntacoreSCR7.td | 379 - llvm/lib/Target/RISCV/RISCVSubtarget.h | 2 + llvm/lib/Target/RISCV/RISCVTargetMachine.cpp | 3 - .../Target/RISCV/RISCVTargetObjectFile.cpp | 2 +- .../Target/RISCV/RISCVTargetTransformInfo.cpp | 74 +- .../Target/RISCV/RISCVTargetTransformInfo.h | 5 +- llvm/lib/Target/RISCV/RISCVVectorPeephole.cpp | 173 +- llvm/lib/Target/RISCV/RISCVZacasABIFix.cpp | 96 - .../SPIRVConvergenceRegionAnalysis.cpp | 5 +- .../Analysis/SPIRVConvergenceRegionAnalysis.h | 3 - llvm/lib/Target/SPIRV/CMakeLists.txt | 2 - llvm/lib/Target/SPIRV/SPIRV.h | 1 - llvm/lib/Target/SPIRV/SPIRVAPI.cpp | 181 - llvm/lib/Target/SPIRV/SPIRVAPI.h | 24 - llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp | 12 - llvm/lib/Target/SPIRV/SPIRVCommandLine.h | 10 - .../Target/SPIRV/SPIRVDuplicatesTracker.cpp | 14 - .../Target/SPIRV/SPIRVEmitNonSemanticDI.cpp | 147 +- llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp | 8 +- llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.h | 6 +- llvm/lib/Target/SPIRV/SPIRVISelLowering.cpp | 16 - llvm/lib/Target/SPIRV/SPIRVInstrInfo.td | 10 +- .../Target/SPIRV/SPIRVInstructionSelector.cpp | 164 +- .../SPIRV/SPIRVMergeRegionExitTargets.cpp | 20 +- llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp | 8 +- llvm/lib/Target/SPIRV/SPIRVPostLegalizer.cpp | 18 + llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp | 163 +- .../Target/SPIRV/SPIRVPrepareFunctions.cpp | 4 +- .../SPIRV/SPIRVStripConvergentIntrinsics.cpp | 53 +- llvm/lib/Target/SPIRV/SPIRVStructurizer.cpp | 1245 -- llvm/lib/Target/SPIRV/SPIRVSubtarget.cpp | 7 - llvm/lib/Target/SPIRV/SPIRVSubtarget.h | 6 - .../lib/Target/SPIRV/SPIRVSymbolicOperands.td | 1 - llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp | 10 +- llvm/lib/Target/SPIRV/SPIRVUtils.cpp | 157 - llvm/lib/Target/SPIRV/SPIRVUtils.h | 75 - .../Target/Sparc/AsmParser/SparcAsmParser.cpp | 10 +- .../SystemZ/AsmParser/SystemZAsmParser.cpp | 64 +- .../MCTargetDesc/SystemZELFObjectWriter.cpp | 1 - llvm/lib/Target/SystemZ/SystemZCallingConv.td | 4 +- .../Target/SystemZ/SystemZISelLowering.cpp | 67 +- llvm/lib/Target/SystemZ/SystemZISelLowering.h | 6 +- .../SystemZ/SystemZTargetTransformInfo.h | 5 +- llvm/lib/Target/VE/AsmParser/VEAsmParser.cpp | 8 +- .../AsmParser/WebAssemblyAsmParser.cpp | 203 +- .../AsmParser/WebAssemblyAsmTypeCheck.cpp | 103 +- .../AsmParser/WebAssemblyAsmTypeCheck.h | 11 +- .../Disassembler/WebAssemblyDisassembler.cpp | 18 - .../MCTargetDesc/WebAssemblyInstPrinter.cpp | 108 +- .../MCTargetDesc/WebAssemblyInstPrinter.h | 3 +- .../MCTargetDesc/WebAssemblyMCCodeEmitter.cpp | 70 +- .../MCTargetDesc/WebAssemblyMCTargetDesc.h | 30 - .../MCTargetDesc/WebAssemblyMCTypeUtilities.h | 14 +- .../WebAssembly/WebAssemblyAsmPrinter.cpp | 11 - .../WebAssembly/WebAssemblyCFGStackify.cpp | 491 +- .../WebAssembly/WebAssemblyISelDAGToDAG.cpp | 5 +- .../WebAssembly/WebAssemblyISelLowering.cpp | 19 - .../WebAssembly/WebAssemblyInstrControl.td | 68 +- .../WebAssembly/WebAssemblyInstrSIMD.td | 6 +- .../WebAssembly/WebAssemblyLateEHPrepare.cpp | 76 +- .../WebAssemblyLowerEmscriptenEHSjLj.cpp | 4 +- .../WebAssembly/WebAssemblyMCInstLower.cpp | 22 +- .../WebAssemblyTargetTransformInfo.h | 3 +- .../WebAssembly/WebAssemblyUtilities.cpp | 2 - .../lib/Target/X86/AsmParser/X86AsmParser.cpp | 135 +- llvm/lib/Target/X86/AsmParser/X86Operand.h | 42 +- .../X86/GISel/X86InstructionSelector.cpp | 16 +- .../X86/MCTargetDesc/X86ATTInstPrinter.cpp | 17 +- .../Target/X86/MCTargetDesc/X86AsmBackend.cpp | 8 +- .../lib/Target/X86/MCTargetDesc/X86BaseInfo.h | 60 +- .../MCTargetDesc/X86EncodingOptimization.cpp | 6 +- .../X86/MCTargetDesc/X86InstComments.cpp | 52 +- .../X86/MCTargetDesc/X86InstPrinterCommon.cpp | 11 - .../X86/MCTargetDesc/X86IntelInstPrinter.cpp | 17 +- .../X86/MCTargetDesc/X86MCCodeEmitter.cpp | 22 +- .../X86/MCTargetDesc/X86MCTargetDesc.cpp | 22 +- .../X86/MCTargetDesc/X86TargetStreamer.h | 4 +- .../MCTargetDesc/X86WinCOFFTargetStreamer.cpp | 16 +- llvm/lib/Target/X86/X86.td | 15 - llvm/lib/Target/X86/X86CallingConv.td | 8 +- llvm/lib/Target/X86/X86CompressEVEX.cpp | 4 +- llvm/lib/Target/X86/X86DomainReassignment.cpp | 181 +- .../Target/X86/X86FixupVectorConstants.cpp | 8 +- llvm/lib/Target/X86/X86FrameLowering.cpp | 5 +- llvm/lib/Target/X86/X86ISelDAGToDAG.cpp | 34 +- llvm/lib/Target/X86/X86ISelLowering.cpp | 836 +- llvm/lib/Target/X86/X86ISelLowering.h | 24 +- llvm/lib/Target/X86/X86ISelLoweringCall.cpp | 9 +- llvm/lib/Target/X86/X86InstrAVX10.td | 737 - llvm/lib/Target/X86/X86InstrAVX512.td | 284 +- llvm/lib/Target/X86/X86InstrFMA3Info.cpp | 35 +- llvm/lib/Target/X86/X86InstrFragmentsSIMD.td | 20 +- llvm/lib/Target/X86/X86InstrInfo.cpp | 90 +- llvm/lib/Target/X86/X86InstrMMX.td | 6 +- llvm/lib/Target/X86/X86InstrSSE.td | 142 +- llvm/lib/Target/X86/X86InstrUtils.td | 6 +- llvm/lib/Target/X86/X86InstrVecCompiler.td | 30 +- llvm/lib/Target/X86/X86IntrinsicsInfo.h | 119 - llvm/lib/Target/X86/X86LowerAMXType.cpp | 38 +- llvm/lib/Target/X86/X86MCInstLower.cpp | 26 +- llvm/lib/Target/X86/X86PfmCounters.td | 1 - llvm/lib/Target/X86/X86ReplaceableInstrs.def | 72 +- llvm/lib/Target/X86/X86SchedAlderlakeP.td | 14 +- llvm/lib/Target/X86/X86SchedBroadwell.td | 4 +- llvm/lib/Target/X86/X86SchedHaswell.td | 4 +- llvm/lib/Target/X86/X86SchedIceLake.td | 56 +- llvm/lib/Target/X86/X86SchedSandyBridge.td | 6 +- llvm/lib/Target/X86/X86SchedSapphireRapids.td | 66 +- llvm/lib/Target/X86/X86SchedSkylakeClient.td | 4 +- llvm/lib/Target/X86/X86SchedSkylakeServer.td | 54 +- llvm/lib/Target/X86/X86ScheduleBdVer2.td | 8 +- llvm/lib/Target/X86/X86ScheduleBtVer2.td | 6 +- llvm/lib/Target/X86/X86ScheduleZnver1.td | 28 +- llvm/lib/Target/X86/X86ScheduleZnver2.td | 28 +- llvm/lib/Target/X86/X86ScheduleZnver3.td | 10 +- llvm/lib/Target/X86/X86ScheduleZnver4.td | 109 +- .../lib/Target/X86/X86TargetTransformInfo.cpp | 71 +- llvm/lib/Target/X86/X86TargetTransformInfo.h | 5 +- llvm/lib/Target/X86/X86TileConfig.cpp | 5 +- llvm/lib/Target/X86/X86WinEHState.cpp | 4 +- .../Xtensa/AsmParser/XtensaAsmParser.cpp | 8 +- llvm/lib/Target/Xtensa/XtensaISelLowering.cpp | 47 - llvm/lib/Target/Xtensa/XtensaISelLowering.h | 4 - llvm/lib/TargetParser/Host.cpp | 19 - llvm/lib/TargetParser/Triple.cpp | 12 - llvm/lib/TargetParser/X86TargetParser.cpp | 5 - llvm/lib/Transforms/Coroutines/CMakeLists.txt | 4 - .../Coroutines/CoroAnnotationElide.cpp | 154 - llvm/lib/Transforms/Coroutines/CoroEarly.cpp | 1 - llvm/lib/Transforms/Coroutines/CoroFrame.cpp | 1252 +- llvm/lib/Transforms/Coroutines/CoroInternal.h | 236 +- llvm/lib/Transforms/Coroutines/CoroShape.h | 287 - llvm/lib/Transforms/Coroutines/CoroSplit.cpp | 220 +- llvm/lib/Transforms/Coroutines/Coroutines.cpp | 182 +- .../Coroutines/MaterializationUtils.cpp | 308 - .../Coroutines/MaterializationUtils.h | 30 - llvm/lib/Transforms/Coroutines/SpillUtils.cpp | 627 - llvm/lib/Transforms/Coroutines/SpillUtils.h | 58 - .../Coroutines/SuspendCrossingInfo.cpp | 207 - .../Coroutines/SuspendCrossingInfo.h | 184 - llvm/lib/Transforms/IPO/Attributor.cpp | 16 + .../Transforms/IPO/AttributorAttributes.cpp | 263 +- llvm/lib/Transforms/IPO/CMakeLists.txt | 1 + llvm/lib/Transforms/IPO/FunctionImport.cpp | 3 +- llvm/lib/Transforms/IPO/IROutliner.cpp | 9 +- .../IPO/MemProfContextDisambiguation.cpp | 183 +- llvm/lib/Transforms/IPO/ModuleInliner.cpp | 11 +- llvm/lib/Transforms/IPO/OpenMPOpt.cpp | 17 +- llvm/lib/Transforms/IPO/SCCP.cpp | 43 +- llvm/lib/Transforms/IPO/SampleProfile.cpp | 2 +- .../Transforms/IPO/SampleProfileMatcher.cpp | 90 +- .../lib/Transforms/IPO/SampleProfileProbe.cpp | 2 +- .../IPO/SyntheticCountsPropagation.cpp | 139 + .../lib/Transforms/IPO/WholeProgramDevirt.cpp | 4 +- .../InstCombine/InstCombineCalls.cpp | 6 +- .../InstCombine/InstCombineCasts.cpp | 5 - .../InstCombine/InstCombineCompares.cpp | 94 +- .../InstCombine/InstCombineInternal.h | 5 - .../Transforms/InstCombine/InstCombinePHI.cpp | 64 +- .../InstCombine/InstCombineSelect.cpp | 42 +- .../InstCombine/InstCombineShifts.cpp | 10 - .../InstCombine/InstCombineVectorOps.cpp | 5 +- .../InstCombine/InstructionCombining.cpp | 176 +- .../Instrumentation/AddressSanitizer.cpp | 12 +- .../Transforms/Instrumentation/CGProfile.cpp | 2 +- .../Transforms/Instrumentation/CMakeLists.txt | 2 +- .../Instrumentation/DataFlowSanitizer.cpp | 4 +- .../Instrumentation/GCOVProfiling.cpp | 2 +- .../Instrumentation/HWAddressSanitizer.cpp | 49 +- .../Instrumentation/IndirectCallPromotion.cpp | 2 +- .../Instrumentation/InstrOrderFile.cpp | 2 +- .../Instrumentation/InstrProfiling.cpp | 6 +- .../Instrumentation.cpp | 21 +- .../Instrumentation/MemorySanitizer.cpp | 131 +- .../NumericalStabilitySanitizer.cpp | 2 +- .../Instrumentation/PGOCtxProfFlattening.cpp | 422 - .../Instrumentation/PGOCtxProfLowering.cpp | 50 +- .../Instrumentation/PGOInstrumentation.cpp | 12 +- .../SanitizerBinaryMetadata.cpp | 3 - .../Instrumentation/SanitizerCoverage.cpp | 3 - .../Instrumentation/ThreadSanitizer.cpp | 2 +- .../Transforms/ObjCARC/ObjCARCContract.cpp | 4 +- llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp | 2 +- .../Scalar/CorrelatedValuePropagation.cpp | 22 - .../Transforms/Scalar/DFAJumpThreading.cpp | 6 +- .../Scalar/DeadStoreElimination.cpp | 4 +- llvm/lib/Transforms/Scalar/Float2Int.cpp | 6 +- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | 45 +- llvm/lib/Transforms/Scalar/LICM.cpp | 36 +- .../Transforms/Scalar/LoopIdiomRecognize.cpp | 1 + .../Transforms/Scalar/LoopStrengthReduce.cpp | 31 +- .../Scalar/LowerMatrixIntrinsics.cpp | 4 +- .../lib/Transforms/Scalar/MemCpyOptimizer.cpp | 57 +- .../Scalar/RewriteStatepointsForGC.cpp | 2 +- llvm/lib/Transforms/Scalar/SCCP.cpp | 8 - llvm/lib/Transforms/Scalar/SROA.cpp | 26 +- llvm/lib/Transforms/Scalar/Scalar.cpp | 1 - llvm/lib/Transforms/Scalar/Scalarizer.cpp | 68 +- .../Transforms/Scalar/SimpleLoopUnswitch.cpp | 3 +- llvm/lib/Transforms/Scalar/StructurizeCFG.cpp | 3 +- llvm/lib/Transforms/Utils/BuildLibCalls.cpp | 15 - llvm/lib/Transforms/Utils/CMakeLists.txt | 1 - llvm/lib/Transforms/Utils/CodeExtractor.cpp | 6 +- llvm/lib/Transforms/Utils/Debugify.cpp | 3 +- .../Transforms/Utils/FunctionImportUtils.cpp | 18 +- llvm/lib/Transforms/Utils/InlineFunction.cpp | 239 +- llvm/lib/Transforms/Utils/Local.cpp | 13 +- .../lib/Transforms/Utils/LoopUnrollAndJam.cpp | 4 +- llvm/lib/Transforms/Utils/LoopUtils.cpp | 86 +- llvm/lib/Transforms/Utils/LowerAtomic.cpp | 8 - llvm/lib/Transforms/Utils/SCCPSolver.cpp | 72 +- .../Utils/ScalarEvolutionExpander.cpp | 48 +- llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 83 +- llvm/lib/Transforms/Utils/SimplifyIndVar.cpp | 6 +- .../lib/Transforms/Utils/SimplifyLibCalls.cpp | 47 +- llvm/lib/Transforms/Utils/ValueMapper.cpp | 5 +- llvm/lib/Transforms/Vectorize/CMakeLists.txt | 6 - .../Vectorize/LoopIdiomVectorize.cpp | 4 +- .../Vectorize/LoopVectorizationLegality.cpp | 182 +- .../Vectorize/LoopVectorizationPlanner.h | 37 +- .../Transforms/Vectorize/LoopVectorize.cpp | 629 +- .../Transforms/Vectorize/SLPVectorizer.cpp | 493 +- .../SandboxVectorizer/DependencyGraph.cpp | 64 - .../SandboxVectorizer/Passes/BottomUpVec.cpp | 64 - .../Vectorize/SandboxVectorizer/Region.cpp | 45 - .../SandboxVectorizer/SandboxVectorizer.cpp | 86 - .../Transforms/Vectorize/VPRecipeBuilder.h | 5 + llvm/lib/Transforms/Vectorize/VPlan.cpp | 83 +- llvm/lib/Transforms/Vectorize/VPlan.h | 159 +- .../Transforms/Vectorize/VPlanAnalysis.cpp | 6 +- llvm/lib/Transforms/Vectorize/VPlanAnalysis.h | 5 +- .../lib/Transforms/Vectorize/VPlanRecipes.cpp | 208 +- .../Transforms/Vectorize/VPlanTransforms.cpp | 225 +- .../Transforms/Vectorize/VPlanTransforms.h | 5 +- llvm/lib/Transforms/Vectorize/VPlanUtils.cpp | 12 - llvm/lib/Transforms/Vectorize/VPlanUtils.h | 11 +- llvm/lib/Transforms/Vectorize/VPlanValue.h | 6 +- .../Transforms/Vectorize/VPlanVerifier.cpp | 86 +- .../Transforms/Vectorize/VectorCombine.cpp | 187 +- llvm/test/Analysis/BasicAA/gep-nuw-alias.ll | 103 - llvm/test/Analysis/CostModel/AArch64/cmp.ll | 24 +- llvm/test/Analysis/CostModel/AArch64/div.ll | 43 - .../CostModel/AArch64/extract_float.ll | 205 - .../fp-conversions-odd-vector-types.ll | 227 - .../Analysis/CostModel/AArch64/reduce-fadd.ll | 42 - .../Analysis/CostModel/AArch64/sve-fptoi.ll | 147 +- .../CostModel/AArch64/sve-intrinsics.ll | 18 +- llvm/test/Analysis/CostModel/RISCV/abs.ll | 2 +- .../test/Analysis/CostModel/RISCV/arith-fp.ll | 820 +- llvm/test/Analysis/CostModel/RISCV/cast.ll | 3577 +---- llvm/test/Analysis/CostModel/RISCV/cmp.ll | 660 - .../CostModel/RISCV/fca-load-store.ll | 2 +- .../CostModel/RISCV/fixed-vector-gather.ll | 2 +- .../CostModel/RISCV/fixed-vector-scatter.ll | 2 +- .../CostModel/RISCV/fp-min-max-abs.ll | 412 +- .../Analysis/CostModel/RISCV/fp-sqrt-pow.ll | 2 +- .../CostModel/RISCV/fp-trig-log-exp.ll | 2 +- llvm/test/Analysis/CostModel/RISCV/fround.ll | 907 +- .../Analysis/CostModel/RISCV/int-bit-manip.ll | 4 +- .../Analysis/CostModel/RISCV/int-min-max.ll | 2 +- .../Analysis/CostModel/RISCV/int-sat-math.ll | 2 +- .../Analysis/CostModel/RISCV/reduce-add.ll | 32 +- .../Analysis/CostModel/RISCV/reduce-and.ll | 44 +- .../Analysis/CostModel/RISCV/reduce-fadd.ll | 40 +- .../CostModel/RISCV/reduce-fmaximum.ll | 36 +- .../CostModel/RISCV/reduce-fminimum.ll | 28 +- .../Analysis/CostModel/RISCV/reduce-max.ll | 56 +- .../Analysis/CostModel/RISCV/reduce-min.ll | 56 +- .../Analysis/CostModel/RISCV/reduce-or.ll | 44 +- .../Analysis/CostModel/RISCV/reduce-xor.ll | 32 +- llvm/test/Analysis/CostModel/RISCV/rvv-cmp.ll | 2 +- .../CostModel/RISCV/rvv-extractelement.ll | 52 - .../CostModel/RISCV/rvv-insertelement.ll | 52 - .../CostModel/RISCV/rvv-intrinsics.ll | 64 +- .../Analysis/CostModel/RISCV/rvv-select.ll | 2 +- .../CostModel/RISCV/scalable-gather.ll | 153 +- .../CostModel/RISCV/scalable-scatter.ll | 154 +- .../CostModel/RISCV/shuffle-broadcast.ll | 2 - .../RISCV/shuffle-extract_subvector.ll | 4 +- .../RISCV/shuffle-insert_subvector.ll | 4 +- .../CostModel/RISCV/shuffle-permute.ll | 2 - .../CostModel/RISCV/shuffle-reverse.ll | 6 +- .../CostModel/RISCV/shuffle-transpose.ll | 6 +- llvm/test/Analysis/CostModel/RISCV/splice.ll | 58 +- .../X86/interleaved-load-f32-stride-5.ll | 115 +- .../X86/interleaved-load-f32-stride-7.ll | 160 +- .../X86/interleaved-load-f32-stride-8.ll | 181 +- .../X86/interleaved-load-f64-stride-2.ll | 38 +- .../X86/interleaved-load-f64-stride-3.ll | 60 +- .../X86/interleaved-load-f64-stride-4.ll | 82 +- .../X86/interleaved-load-f64-stride-5.ll | 100 +- .../X86/interleaved-load-f64-stride-6.ll | 115 +- .../X86/interleaved-load-f64-stride-7.ll | 142 +- .../X86/interleaved-load-f64-stride-8.ll | 156 +- .../X86/interleaved-load-i16-stride-5.ll | 161 +- .../X86/interleaved-load-i16-stride-7.ll | 233 +- .../X86/interleaved-load-i16-stride-8.ll | 269 +- ...erleaved-load-i32-stride-4-indices-01uu.ll | 36 +- .../X86/interleaved-load-i32-stride-5.ll | 115 +- .../X86/interleaved-load-i32-stride-7.ll | 160 +- .../X86/interleaved-load-i32-stride-8.ll | 181 +- .../X86/interleaved-load-i64-stride-2.ll | 38 +- .../X86/interleaved-load-i64-stride-3.ll | 60 +- .../X86/interleaved-load-i64-stride-4.ll | 82 +- .../X86/interleaved-load-i64-stride-5.ll | 100 +- .../X86/interleaved-load-i64-stride-6.ll | 115 +- .../X86/interleaved-load-i64-stride-7.ll | 142 +- .../X86/interleaved-load-i64-stride-8.ll | 156 +- .../X86/interleaved-load-i8-stride-5.ll | 161 +- .../X86/interleaved-load-i8-stride-6.ll | 187 +- .../X86/interleaved-load-i8-stride-7.ll | 233 +- .../X86/interleaved-load-i8-stride-8.ll | 269 +- .../X86/interleaved-store-f32-stride-8.ll | 4 - .../X86/interleaved-store-f64-stride-8.ll | 149 +- .../X86/interleaved-store-i64-stride-8.ll | 149 +- .../X86/masked-interleaved-store-i16.ll | 18 +- .../flatten-always-removes-instrumentation.ll | 12 - .../CtxProfAnalysis/flatten-and-annotate.ll | 112 - .../CtxProfAnalysis/flatten-check-path.ll | 85 - .../CtxProfAnalysis/flatten-zero-path.ll | 55 - .../Analysis/CtxProfAnalysis/full-cycle.ll | 10 +- llvm/test/Analysis/CtxProfAnalysis/inline.ll | 126 - .../Analysis/CtxProfAnalysis/json_equals.py | 15 - .../CtxProfAnalysis/load-unapplicable.ll | 65 - llvm/test/Analysis/CtxProfAnalysis/load.ll | 13 +- llvm/test/Analysis/Lint/noalias-null.ll | 14 - llvm/test/Analysis/Lint/scalable.ll | 27 - .../ScalarEvolution/exit-count-non-strict.ll | 22 - .../max-backedge-taken-count-guard-info.ll | 139 - .../ScalarEvolution/predicated-exit-count.ll | 65 - ...cated-symbolic-max-backedge-taken-count.ll | 16 - .../udiv-of-x-xsmaxone-fold.ll | 96 - .../TypeBasedAliasAnalysis/aggregates.ll | 23 +- ...nbits.ll => shift-recurrence-knownbits.ll} | 100 - llvm/test/Assembler/atomic.ll | 10 - .../Assembler/target-type-param-errors.ll | 12 - llvm/test/Bitcode/attributes.ll | 6 - llvm/test/Bitcode/compatibility.ll | 36 +- .../intrinsics-struct-upgrade-attributes.ll | 18 - .../Bitcode/thinlto-synthetic-count-flag.ll | 21 + llvm/test/CMakeLists.txt | 2 - .../GlobalISel/combine-cannonicalize-fcmp.mir | 119 - .../GlobalISel/combine-canonicalize-icmp.mir | 95 - .../GlobalISel/combine-extract-vec-elt.mir | 27 - .../GlobalISel/combine-narrow-binop.mir | 136 - .../AArch64/GlobalISel/inline-memset.mir | 165 +- .../legalize-shuffle-vector-widen-crash.ll | 12 +- .../GlobalISel/legalizer-info-validation.mir | 17 +- .../GlobalISel/machine-cse-mid-pipeline.mir | 1 - ...legalizer-lowering-build-vector-to-dup.mir | 24 +- .../postlegalizer-lowering-shuffle-splat.mir | 51 +- ...izer-combiner-divrem-insertpt-conflict.mir | 9 +- .../CodeGen/AArch64/GlobalISel/vararg.mir | 56 - .../CodeGen/AArch64/PHIElimination-crash.mir | 2 +- .../AArch64/PHIElimination-debugloc.mir | 2 +- llvm/test/CodeGen/AArch64/aarch64-bif-gen.ll | 2 +- llvm/test/CodeGen/AArch64/aarch64-bit-gen.ll | 2 +- llvm/test/CodeGen/AArch64/aarch64-smull.ll | 116 +- .../CodeGen/AArch64/aarch64-sve2-faminmax.ll | 661 - llvm/test/CodeGen/AArch64/abds-neg.ll | 21 +- llvm/test/CodeGen/AArch64/abds.ll | 105 +- llvm/test/CodeGen/AArch64/abdu-neg.ll | 22 +- llvm/test/CodeGen/AArch64/abdu.ll | 107 +- llvm/test/CodeGen/AArch64/abs.ll | 42 +- llvm/test/CodeGen/AArch64/add.ll | 100 +- llvm/test/CodeGen/AArch64/addp-shuffle.ll | 30 +- .../test/CodeGen/AArch64/addsub-24bit-imm.mir | 12 +- llvm/test/CodeGen/AArch64/andorxor.ll | 300 +- .../CodeGen/AArch64/arm64-bitfield-extract.ll | 2 +- llvm/test/CodeGen/AArch64/arm64-ccmp.ll | 60 +- llvm/test/CodeGen/AArch64/arm64-dup.ll | 61 +- .../AArch64/arm64-extract-insert-varidx.ll | 45 +- llvm/test/CodeGen/AArch64/arm64-fp128.ll | 1710 +-- .../AArch64/arm64-indexed-vector-ldst.ll | 82 +- llvm/test/CodeGen/AArch64/arm64-ld-from-st.ll | 8 +- llvm/test/CodeGen/AArch64/arm64-ldxr-stxr.ll | 287 +- llvm/test/CodeGen/AArch64/arm64-neon-copy.ll | 318 +- .../CodeGen/AArch64/arm64-subvector-extend.ll | 372 +- llvm/test/CodeGen/AArch64/arm64-tbl.ll | 159 +- llvm/test/CodeGen/AArch64/arm64-vector-imm.ll | 147 +- llvm/test/CodeGen/AArch64/arm64_32.ll | 2 +- .../AArch64/atomicrmw-cond-sub-clamp.ll | 140 - llvm/test/CodeGen/AArch64/atomicrmw-fadd.ll | 373 +- llvm/test/CodeGen/AArch64/atomicrmw-fmax.ll | 373 +- llvm/test/CodeGen/AArch64/atomicrmw-fmin.ll | 373 +- llvm/test/CodeGen/AArch64/atomicrmw-fsub.ll | 373 +- llvm/test/CodeGen/AArch64/bitcast.ll | 106 +- llvm/test/CodeGen/AArch64/bitfield-extract.ll | 10 +- llvm/test/CodeGen/AArch64/bswap.ll | 84 +- llvm/test/CodeGen/AArch64/build-one-lane.ll | 2 +- .../CodeGen/AArch64/build-vector-two-dup.ll | 2 +- .../CodeGen/AArch64/cgdata-global-hash.ll | 40 - .../CodeGen/AArch64/cgdata-outlined-name.ll | 41 - .../AArch64/cgdata-read-double-outline.ll | 57 - .../AArch64/cgdata-read-lto-outline.ll | 96 - .../CodeGen/AArch64/cgdata-read-priority.ll | 68 - .../cgdata-read-single-outline-suffix.ll | 100 - .../AArch64/cgdata-read-single-outline.ll | 42 - .../CodeGen/AArch64/cgdata-write-outline.ll | 51 - .../complex-deinterleaving-uniform-cases.ll | 104 +- llvm/test/CodeGen/AArch64/concat-vector.ll | 178 +- llvm/test/CodeGen/AArch64/cpus.ll | 1 - llvm/test/CodeGen/AArch64/ctlo.ll | 132 - llvm/test/CodeGen/AArch64/expand-select.ll | 22 +- llvm/test/CodeGen/AArch64/extbinopload.ll | 303 +- llvm/test/CodeGen/AArch64/fabs-fp128.ll | 170 - llvm/test/CodeGen/AArch64/fabs.ll | 32 +- llvm/test/CodeGen/AArch64/faddsub.ll | 80 +- .../CodeGen/AArch64/fast-isel-int-ext3.ll | 2 +- llvm/test/CodeGen/AArch64/fast-isel-shift.ll | 6 +- llvm/test/CodeGen/AArch64/fcmp.ll | 572 +- llvm/test/CodeGen/AArch64/fcopysign.ll | 34 +- llvm/test/CodeGen/AArch64/fcvt.ll | 224 +- llvm/test/CodeGen/AArch64/fdiv.ll | 40 +- llvm/test/CodeGen/AArch64/fexplog.ll | 315 +- .../AArch64/fixed-vector-interleave.ll | 14 +- llvm/test/CodeGen/AArch64/fminimummaximum.ll | 80 +- llvm/test/CodeGen/AArch64/fminmax.ll | 80 +- llvm/test/CodeGen/AArch64/fmla.ll | 168 +- llvm/test/CodeGen/AArch64/fmul.ll | 40 +- llvm/test/CodeGen/AArch64/fneg.ll | 32 +- .../CodeGen/AArch64/fp-conversion-to-tbl.ll | 175 - llvm/test/CodeGen/AArch64/fpow.ll | 12 +- llvm/test/CodeGen/AArch64/fpowi.ll | 12 +- llvm/test/CodeGen/AArch64/fptoi.ll | 70 +- .../test/CodeGen/AArch64/fptosi-sat-scalar.ll | 1060 +- .../test/CodeGen/AArch64/fptosi-sat-vector.ll | 7033 ++++------ .../test/CodeGen/AArch64/fptoui-sat-scalar.ll | 783 +- .../test/CodeGen/AArch64/fptoui-sat-vector.ll | 5524 +++----- llvm/test/CodeGen/AArch64/fptrunc.ll | 12 +- llvm/test/CodeGen/AArch64/frem.ll | 12 +- llvm/test/CodeGen/AArch64/fsincos.ll | 126 +- llvm/test/CodeGen/AArch64/fsqrt.ll | 32 +- llvm/test/CodeGen/AArch64/icmp.ll | 74 +- llvm/test/CodeGen/AArch64/init-undef.mir | 27 - llvm/test/CodeGen/AArch64/insertextract.ll | 75 +- llvm/test/CodeGen/AArch64/isinf.ll | 12 +- llvm/test/CodeGen/AArch64/itofp.ll | 180 +- llvm/test/CodeGen/AArch64/llvm.exp10.ll | 10 +- .../test/CodeGen/AArch64/load-insert-undef.ll | 1078 -- llvm/test/CodeGen/AArch64/load-insert-zero.ll | 315 +- llvm/test/CodeGen/AArch64/load.ll | 48 +- .../AArch64/machine-outliner-bundle.mir | 54 - .../AArch64/machine_cse_impdef_killflags.ll | 2 +- .../CodeGen/AArch64/merge-scoped-aa-store.ll | 4 +- .../AArch64/mlicm-stack-write-check.mir | 1 - llvm/test/CodeGen/AArch64/mul.ll | 134 +- .../AArch64/neon-bitwise-instructions.ll | 34 +- .../AArch64/neon-compare-instructions.ll | 12 +- llvm/test/CodeGen/AArch64/neon-dotreduce.ll | 1024 +- llvm/test/CodeGen/AArch64/neon-extadd.ll | 358 +- llvm/test/CodeGen/AArch64/neon-extmul.ll | 28 +- llvm/test/CodeGen/AArch64/neon-famin-famax.ll | 96 - llvm/test/CodeGen/AArch64/neon-luti.ll | 253 - .../neon-partial-reduce-dot-product.ll | 244 - llvm/test/CodeGen/AArch64/neon-perm.ll | 13 +- .../no-reorder-cfi-merge-back-load.mir | 83 - .../no-reorder-cfi-merge-back-store.mir | 79 - .../AArch64/no-reorder-cfi-merge-fwd-load.mir | 86 - .../AArch64/no-reorder-cfi-merge-fwd.mir | 82 - .../AArch64/no-reorder-cfi-no-merge.mir | 86 - llvm/test/CodeGen/AArch64/no-reorder-cfi.ll | 26 - llvm/test/CodeGen/AArch64/ptradd.ll | 52 +- llvm/test/CodeGen/AArch64/ptrauth-call.ll | 21 - llvm/test/CodeGen/AArch64/rem.ll | 632 +- llvm/test/CodeGen/AArch64/sadd_sat_vec.ll | 38 +- llvm/test/CodeGen/AArch64/scmp.ll | 281 +- llvm/test/CodeGen/AArch64/sext.ll | 206 +- llvm/test/CodeGen/AArch64/shift.ll | 352 +- llvm/test/CodeGen/AArch64/shufflevector.ll | 70 +- .../CodeGen/AArch64/sme-machine-licm-vg.mir | 1 - llvm/test/CodeGen/AArch64/sme-vg-to-stack.ll | 68 +- .../AArch64/sme2-intrinsics-faminmax.ll | 241 - .../CodeGen/AArch64/sme2-intrinsics-ld1.ll | 1456 +- .../CodeGen/AArch64/sme2-intrinsics-ldnt1.ll | 1456 +- llvm/test/CodeGen/AArch64/spillfill-sve.mir | 37 +- llvm/test/CodeGen/AArch64/ssub_sat_vec.ll | 38 +- .../CodeGen/AArch64/statepoint-twoaddr.mir | 2 +- llvm/test/CodeGen/AArch64/sub.ll | 100 +- .../test/CodeGen/AArch64/sve-bf16-converts.ll | 89 - .../AArch64/sve-callee-save-restore-pairs.ll | 84 +- llvm/test/CodeGen/AArch64/sve-ld-post-inc.ll | 3 +- .../AArch64/sve-partial-reduce-dot-product.ll | 231 - .../AArch64/sve-pfalse-machine-cse.mir | 1 - llvm/test/CodeGen/AArch64/sve-scmp.ll | 160 - ...treaming-mode-fixed-length-bit-counting.ll | 18 +- ...ing-mode-fixed-length-insert-vector-elt.ll | 6 +- llvm/test/CodeGen/AArch64/sve-ucmp.ll | 160 - .../AArch64/sve2-intrinsics-faminmax.ll | 115 - .../CodeGen/AArch64/sve2-intrinsics-luti.ll | 107 - llvm/test/CodeGen/AArch64/trunc-to-tbl.ll | 22 +- llvm/test/CodeGen/AArch64/uadd_sat_vec.ll | 38 +- llvm/test/CodeGen/AArch64/ucmp.ll | 281 +- llvm/test/CodeGen/AArch64/usub_sat_vec.ll | 38 +- llvm/test/CodeGen/AArch64/vararg.ll | 384 - llvm/test/CodeGen/AArch64/vecreduce-add.ll | 528 +- llvm/test/CodeGen/AArch64/vecreduce-bitext.ll | 1202 -- llvm/test/CodeGen/AArch64/vector-compress.ll | 20 +- llvm/test/CodeGen/AArch64/xbfiz.ll | 8 - llvm/test/CodeGen/AArch64/xtn.ll | 77 +- llvm/test/CodeGen/AArch64/zext-shuffle.ll | 545 - llvm/test/CodeGen/AArch64/zext-to-tbl.ll | 152 +- llvm/test/CodeGen/AArch64/zext.ll | 150 +- .../AMDGPU/GlobalISel/atomicrmw_fmax.ll | 24 +- .../AMDGPU/GlobalISel/atomicrmw_fmin.ll | 24 +- .../AMDGPU/GlobalISel/combine-itofp.mir | 16 +- .../AMDGPU/GlobalISel/combine-zext-trunc.mir | 26 +- ...-divergent-i1-phis-no-lane-mask-merging.ll | 7 +- .../CodeGen/AMDGPU/GlobalISel/fdiv.f64.ll | 18 +- .../AMDGPU/GlobalISel/flat-scratch-init.ll | 7 +- .../CodeGen/AMDGPU/GlobalISel/flat-scratch.ll | 2 - llvm/test/CodeGen/AMDGPU/GlobalISel/fshl.ll | 3021 ++--- llvm/test/CodeGen/AMDGPU/GlobalISel/fshr.ll | 2942 ++-- .../global-atomic-fadd.f32-no-rtn.ll | 21 +- .../GlobalISel/global-atomic-fadd.f32-rtn.ll | 36 +- .../inst-select-amdgcn.fcmp.constants.w32.mir | 12 +- .../inst-select-amdgcn.fcmp.constants.w64.mir | 12 +- .../AMDGPU/GlobalISel/inst-select-fptosi.mir | 24 +- .../AMDGPU/GlobalISel/inst-select-fptoui.mir | 148 +- .../AMDGPU/GlobalISel/inst-select-sitofp.mir | 32 +- .../AMDGPU/GlobalISel/inst-select-uitofp.mir | 32 +- .../AMDGPU/GlobalISel/llvm.amdgcn.div.fmas.ll | 854 +- .../GlobalISel/llvm.amdgcn.set.inactive.ll | 392 +- .../no-cse-nonlocal-convergent-instrs.mir | 1 - .../CodeGen/AMDGPU/GlobalISel/sdiv.i64.ll | 73 +- .../AMDGPU/GlobalISel/shl-ext-reduce.ll | 3 - .../CodeGen/AMDGPU/GlobalISel/srem.i64.ll | 64 +- .../GlobalISel/twoaddr-extract-dyn-v7f64.mir | 2 +- .../CodeGen/AMDGPU/GlobalISel/udiv.i64.ll | 18 +- .../CodeGen/AMDGPU/GlobalISel/urem.i64.ll | 14 +- .../AMDGPU/GlobalISel/vni8-across-blocks.ll | 6 +- llvm/test/CodeGen/AMDGPU/aa-as-infer.ll | 245 - llvm/test/CodeGen/AMDGPU/addrspacecast.ll | 120 +- .../AMDGPU/agpr-copy-no-free-registers.ll | 6 +- ...amdgpu-codegenprepare-fold-binop-select.ll | 7 +- .../amdgpu-codegenprepare-i16-to-i32.ll | 4 +- .../test/CodeGen/AMDGPU/amdgpu-cs-chain-cc.ll | 30 +- .../AMDGPU/amdgpu-cs-chain-preserve-cc.ll | 29 +- ...gpu-sw-lower-lds-non-kernel-declaration.ll | 97 - .../CodeGen/AMDGPU/amdgpu.private-memory.ll | 2 +- .../AMDGPU/annotate-kernel-features-hsa.ll | 36 +- .../AMDGPU/atomic_optimizations_buffer.ll | 68 +- .../atomic_optimizations_global_pointer.ll | 1394 +- .../atomic_optimizations_local_pointer.ll | 5284 ++++---- .../atomic_optimizations_pixelshader.ll | 64 +- .../AMDGPU/atomic_optimizations_raw_buffer.ll | 57 +- .../atomic_optimizations_struct_buffer.ll | 57 +- .../branch-folding-implicit-def-subreg.ll | 4 +- .../buffer-fat-pointer-atomicrmw-fadd.ll | 125 +- .../buffer-fat-pointer-atomicrmw-fmax.ll | 167 +- .../buffer-fat-pointer-atomicrmw-fmin.ll | 167 +- .../AMDGPU/bug-sdag-emitcopyfromreg.ll | 64 +- .../callee-special-input-sgprs-fixed-abi.ll | 10 +- .../CodeGen/AMDGPU/calling-conventions.ll | 1658 ++- .../CodeGen/AMDGPU/cgp-bitfield-extract.ll | 4 +- llvm/test/CodeGen/AMDGPU/cmp_shrink.mir | 1 - llvm/test/CodeGen/AMDGPU/collapse-endcf.ll | 8 +- llvm/test/CodeGen/AMDGPU/constrained-shift.ll | 2 + llvm/test/CodeGen/AMDGPU/copy-illegal-type.ll | 2 +- .../copyprop_regsequence_with_undef.mir | 1 - llvm/test/CodeGen/AMDGPU/cse-convergent.ll | 14 +- llvm/test/CodeGen/AMDGPU/ctlz.ll | 4 +- llvm/test/CodeGen/AMDGPU/ctlz_zero_undef.ll | 19 +- llvm/test/CodeGen/AMDGPU/cttz.ll | 5 +- llvm/test/CodeGen/AMDGPU/cttz_zero_undef.ll | 28 +- llvm/test/CodeGen/AMDGPU/dagcombine-select.ll | 5 +- llvm/test/CodeGen/AMDGPU/div_i128.ll | 349 +- .../early-lis-two-address-partial-def.mir | 2 +- ...minate-frame-index-v-add-co-u32-wave32.mir | 442 - .../CodeGen/AMDGPU/extract_vector_dynelt.ll | 452 +- .../CodeGen/AMDGPU/extract_vector_elt-i8.ll | 20 +- llvm/test/CodeGen/AMDGPU/fcopysign.f16.ll | 101 +- llvm/test/CodeGen/AMDGPU/fdiv_flags.f32.ll | 44 +- .../AMDGPU/fix-sgpr-copies-f16-fake16.mir | 18 - .../AMDGPU/fix-sgpr-copies-f16-true16.mir | 20 - .../CodeGen/AMDGPU/fix-sgpr-copies-f16.mir | 17 + llvm/test/CodeGen/AMDGPU/fix-wwm-vgpr-copy.ll | 18 +- .../CodeGen/AMDGPU/flat-atomicrmw-fadd.ll | 104 +- .../CodeGen/AMDGPU/flat-atomicrmw-fmax.ll | 176 +- .../CodeGen/AMDGPU/flat-atomicrmw-fmin.ll | 176 +- .../CodeGen/AMDGPU/flat-atomicrmw-fsub.ll | 232 +- llvm/test/CodeGen/AMDGPU/flat-scratch.ll | 18 +- llvm/test/CodeGen/AMDGPU/fmaximum.ll | 3 +- llvm/test/CodeGen/AMDGPU/fmaximum3.ll | 4 +- llvm/test/CodeGen/AMDGPU/fminimum.ll | 3 +- llvm/test/CodeGen/AMDGPU/fminimum3.ll | 4 +- llvm/test/CodeGen/AMDGPU/fold-imm-f16-f32.mir | 1 - llvm/test/CodeGen/AMDGPU/fold-multiple.mir | 1 - llvm/test/CodeGen/AMDGPU/fsqrt.f32.ll | 132 +- llvm/test/CodeGen/AMDGPU/fsqrt.f64.ll | 532 + .../AMDGPU/gfx-callable-argument-types.ll | 33 +- .../test/CodeGen/AMDGPU/gfx10-twoaddr-fma.mir | 142 +- .../test/CodeGen/AMDGPU/gfx11-twoaddr-fma.mir | 2 +- .../AMDGPU/global-atomic-fadd.f32-no-rtn.ll | 14 +- .../AMDGPU/global-atomic-fadd.f32-rtn.ll | 47 +- .../CodeGen/AMDGPU/global-atomicrmw-fadd.ll | 106 +- .../CodeGen/AMDGPU/global-atomicrmw-fmax.ll | 176 +- .../CodeGen/AMDGPU/global-atomicrmw-fmin.ll | 176 +- .../CodeGen/AMDGPU/global-atomicrmw-fsub.ll | 232 +- .../test/CodeGen/AMDGPU/global_atomics_i64.ll | 48 +- .../AMDGPU/global_atomics_scan_fadd.ll | 1157 +- .../AMDGPU/global_atomics_scan_fmax.ll | 737 +- .../AMDGPU/global_atomics_scan_fmin.ll | 737 +- .../AMDGPU/global_atomics_scan_fsub.ll | 1157 +- .../hazard-recognizer-src-shared-base.ll | 23 - llvm/test/CodeGen/AMDGPU/idiv-licm.ll | 450 +- .../AMDGPU/illegal-sgpr-to-vgpr-copy.ll | 4 +- llvm/test/CodeGen/AMDGPU/imm16.ll | 18 +- .../CodeGen/AMDGPU/indirect-addressing-si.ll | 47 +- .../AMDGPU/indirect-call-known-callees.ll | 15 +- .../CodeGen/AMDGPU/insert-delay-alu-bug.ll | 106 +- .../CodeGen/AMDGPU/insert_vector_dynelt.ll | 1903 +-- llvm/test/CodeGen/AMDGPU/insert_vector_elt.ll | 160 +- .../AMDGPU/insert_vector_elt.v2bf16.ll | 10 +- .../insert_waitcnt_for_precise_memory.ll | 43 +- llvm/test/CodeGen/AMDGPU/licm-regpressure.mir | 1 - llvm/test/CodeGen/AMDGPU/licm-valu.mir | 1 - .../AMDGPU/llvm.amdgcn.atomic.cond.sub.ll | 6 - .../AMDGPU/llvm.amdgcn.image.atomic.dim.ll | 13 - .../AMDGPU/llvm.amdgcn.init.whole.wave-w32.ll | 1127 -- .../AMDGPU/llvm.amdgcn.init.whole.wave-w64.ll | 140 - .../CodeGen/AMDGPU/llvm.amdgcn.permlane.ll | 44 +- ...mdgcn.raw.ptr.buffer.atomic.fadd.v2bf16.ll | 10 +- ...m.amdgcn.raw.ptr.buffer.load.format.d16.ll | 76 +- .../AMDGPU/llvm.amdgcn.s.barrier.wait.ll | 19 +- .../llvm.amdgcn.s.buffer.prefetch.data.ll | 50 - .../AMDGPU/llvm.amdgcn.s.prefetch.data.ll | 127 - .../llvm.amdgcn.set.inactive.chain.arg.ll | 390 +- .../AMDGPU/llvm.amdgcn.set.inactive.ll | 357 +- ...cn.struct.ptr.buffer.atomic.fadd.v2bf16.ll | 20 +- ...gcn.struct.ptr.buffer.atomic.fadd_nortn.ll | 20 +- ...mdgcn.struct.ptr.buffer.atomic.fadd_rtn.ll | 20 +- ...mdgcn.struct.ptr.buffer.atomic.fmax.f32.ll | 16 +- ...mdgcn.struct.ptr.buffer.atomic.fmin.f32.ll | 16 +- ...mdgcn.struct.ptr.buffer.load.format.d16.ll | 100 +- .../llvm.amdgcn.struct.ptr.buffer.load.ll | 282 +- ...dgcn.struct.ptr.buffer.store.format.d16.ll | 152 +- ...m.amdgcn.struct.ptr.buffer.store.format.ll | 102 +- .../llvm.amdgcn.struct.ptr.buffer.store.ll | 209 +- .../CodeGen/AMDGPU/llvm.amdgcn.wave.id.ll | 2 +- .../CodeGen/AMDGPU/llvm.fptrunc.round.err.ll | 55 +- .../test/CodeGen/AMDGPU/llvm.fptrunc.round.ll | 39 - .../CodeGen/AMDGPU/llvm.is.fpclass.bf16.ll | 40 +- llvm/test/CodeGen/AMDGPU/llvm.log.ll | 68 +- llvm/test/CodeGen/AMDGPU/llvm.log10.ll | 68 +- llvm/test/CodeGen/AMDGPU/llvm.maximum.f16.ll | 4 +- llvm/test/CodeGen/AMDGPU/llvm.maximum.f32.ll | 2 - llvm/test/CodeGen/AMDGPU/llvm.minimum.f16.ll | 4 +- llvm/test/CodeGen/AMDGPU/llvm.minimum.f32.ll | 2 - .../AMDGPU/load-constant-always-uniform.ll | 60 - llvm/test/CodeGen/AMDGPU/load-constant-i1.ll | 6716 ++++----- llvm/test/CodeGen/AMDGPU/load-constant-i16.ll | 37 +- llvm/test/CodeGen/AMDGPU/load-constant-i32.ll | 1 - llvm/test/CodeGen/AMDGPU/load-constant-i8.ll | 4864 ++++--- llvm/test/CodeGen/AMDGPU/load-global-i16.ll | 33 +- llvm/test/CodeGen/AMDGPU/load-global-i32.ll | 14 +- llvm/test/CodeGen/AMDGPU/load-global-i8.ll | 15 +- llvm/test/CodeGen/AMDGPU/load-local-i8.ll | 15 +- .../CodeGen/AMDGPU/local-atomicrmw-fadd.ll | 113 +- .../CodeGen/AMDGPU/local-atomicrmw-fmax.ll | 80 +- .../CodeGen/AMDGPU/local-atomicrmw-fmin.ll | 80 +- .../CodeGen/AMDGPU/local-atomicrmw-fsub.ll | 120 +- .../test/CodeGen/AMDGPU/loop-prefetch-data.ll | 3 +- .../AMDGPU/lower-lds-struct-aa-memcpy.ll | 4 +- .../AMDGPU/lower-module-lds-zero-size-arr.ll | 17 +- .../lower-work-group-id-intrinsics-hsa.ll | 5 +- .../lower-work-group-id-intrinsics-pal.ll | 5 +- llvm/test/CodeGen/AMDGPU/machine-cse-ssa.mir | 8 +- .../CodeGen/AMDGPU/machinelicm-convergent.mir | 1 - .../AMDGPU/machinelicm-copy-like-instrs.mir | 1 - .../CodeGen/AMDGPU/machinelicm-undef-use.mir | 1 - .../materialize-frame-index-sgpr.gfx10.ll | 34 - .../AMDGPU/materialize-frame-index-sgpr.ll | 17 +- llvm/test/CodeGen/AMDGPU/maximumnum.ll | 1736 --- .../memory-legalizer-fence-mmra-global.ll | 20 + .../CodeGen/AMDGPU/memory-legalizer-fence.ll | 20 + .../AMDGPU/memory-legalizer-flat-agent.ll | 196 +- .../AMDGPU/memory-legalizer-flat-lastuse.ll | 8 - .../memory-legalizer-flat-nontemporal.ll | 26 - .../memory-legalizer-flat-singlethread.ll | 156 - .../AMDGPU/memory-legalizer-flat-system.ll | 196 +- .../AMDGPU/memory-legalizer-flat-volatile.ll | 28 +- .../AMDGPU/memory-legalizer-flat-wavefront.ll | 154 - .../AMDGPU/memory-legalizer-flat-workgroup.ll | 168 +- .../AMDGPU/memory-legalizer-global-agent.ll | 190 +- .../AMDGPU/memory-legalizer-global-lastuse.ll | 8 - .../memory-legalizer-global-nontemporal.ll | 18 - .../memory-legalizer-global-singlethread.ll | 152 - .../AMDGPU/memory-legalizer-global-system.ll | 182 +- .../memory-legalizer-global-volatile.ll | 22 +- .../memory-legalizer-global-wavefront.ll | 152 - .../memory-legalizer-global-workgroup.ll | 172 +- .../memory-legalizer-invalid-syncscope.ll | 1 - .../AMDGPU/memory-legalizer-local-agent.ll | 120 - .../memory-legalizer-local-nontemporal.ll | 16 - .../memory-legalizer-local-singlethread.ll | 120 - .../AMDGPU/memory-legalizer-local-system.ll | 120 - .../AMDGPU/memory-legalizer-local-volatile.ll | 14 - .../memory-legalizer-local-wavefront.ll | 120 - .../memory-legalizer-local-workgroup.ll | 120 - .../memory-legalizer-private-lastuse.ll | 6 - .../memory-legalizer-private-nontemporal.ll | 18 - .../memory-legalizer-private-volatile.ll | 16 - llvm/test/CodeGen/AMDGPU/min.ll | 150 +- llvm/test/CodeGen/AMDGPU/minimumnum.ll | 1690 --- .../CodeGen/AMDGPU/mode-register-fptrunc.mir | 8 +- ...uf-legalize-operands-non-ptr-intrinsics.ll | 48 +- .../CodeGen/AMDGPU/mubuf-legalize-operands.ll | 52 +- llvm/test/CodeGen/AMDGPU/mul.ll | 51 +- .../CodeGen/AMDGPU/pei-amdgpu-cs-chain.mir | 29 - llvm/test/CodeGen/AMDGPU/permute_i8.ll | 73 +- .../CodeGen/AMDGPU/phi-elimination-end-cf.mir | 2 +- .../CodeGen/AMDGPU/phi-vgpr-input-moveimm.mir | 105 +- llvm/test/CodeGen/AMDGPU/preload-kernargs.ll | 227 +- .../AMDGPU/preserve-wwm-copy-dst-reg.ll | 8 +- .../AMDGPU/pseudo-scalar-transcendental.ll | 39 +- llvm/test/CodeGen/AMDGPU/rem_i128.ll | 251 +- .../AMDGPU/remove-no-kernel-id-attribute.ll | 37 +- llvm/test/CodeGen/AMDGPU/rsq.f64.ll | 46 +- llvm/test/CodeGen/AMDGPU/s-getpc-b64-remat.ll | 8 +- llvm/test/CodeGen/AMDGPU/scalar_to_vector.ll | 35 +- ...schedule-regpressure-ilp-metric-spills.mir | 256 +- llvm/test/CodeGen/AMDGPU/sdwa-gfx9.mir | 3 - llvm/test/CodeGen/AMDGPU/sdwa-ops.mir | 2 - llvm/test/CodeGen/AMDGPU/sdwa-peephole.ll | 180 +- llvm/test/CodeGen/AMDGPU/sdwa-preserve.mir | 2 - llvm/test/CodeGen/AMDGPU/select-i1.ll | 13 +- llvm/test/CodeGen/AMDGPU/select-vectors.ll | 5 +- .../AMDGPU/set-inactive-wwm-overwrite.ll | 12 +- llvm/test/CodeGen/AMDGPU/setcc-opt.ll | 17 +- .../AMDGPU/sgpr-spill-overlap-wwm-reserve.mir | 4 +- .../AMDGPU/sgpr-spills-split-regalloc.ll | 1 + .../AMDGPU/should-not-hoist-set-inactive.ll | 5 +- llvm/test/CodeGen/AMDGPU/shrink-i32-kimm.mir | 1 - .../AMDGPU/shrink-instructions-flags.mir | 1 - .../shrink-instructions-illegal-fold.mir | 1 - .../AMDGPU/shrink-insts-scalar-bit-ops.mir | 1 - llvm/test/CodeGen/AMDGPU/shrink-true16.mir | 1 - .../CodeGen/AMDGPU/shrink-vop3-carry-out.mir | 1 - .../CodeGen/AMDGPU/si-init-whole-wave.mir | 135 - llvm/test/CodeGen/AMDGPU/sign_extend.ll | 19 +- llvm/test/CodeGen/AMDGPU/sminmax.v2i16.ll | 22 +- .../AMDGPU/spill-offset-calculation.ll | 8 +- .../CodeGen/AMDGPU/spill-scavenge-offset.ll | 334 + llvm/test/CodeGen/AMDGPU/spill-wait.mir | 89 - .../CodeGen/AMDGPU/split-mbb-lis-subrange.mir | 2 +- llvm/test/CodeGen/AMDGPU/srem.ll | 34 +- .../AMDGPU/stale-livevar-in-twoaddr-pass.mir | 2 +- llvm/test/CodeGen/AMDGPU/trunc-combine.ll | 4 +- llvm/test/CodeGen/AMDGPU/trunc-store.ll | 136 +- llvm/test/CodeGen/AMDGPU/twoaddr-fma-f64.mir | 2 +- llvm/test/CodeGen/AMDGPU/twoaddr-fma.mir | 4 +- llvm/test/CodeGen/AMDGPU/twoaddr-mad.mir | 2 +- llvm/test/CodeGen/AMDGPU/twoaddr-wmma.mir | 2 +- llvm/test/CodeGen/AMDGPU/uaddo.ll | 12 +- llvm/test/CodeGen/AMDGPU/unsupported-calls.ll | 4 +- llvm/test/CodeGen/AMDGPU/usubo.ll | 12 +- llvm/test/CodeGen/AMDGPU/v_swap_b16.ll | 10 +- llvm/test/CodeGen/AMDGPU/v_swap_b32.mir | 1 - .../CodeGen/AMDGPU/valu-mask-write-hazard.mir | 168 +- .../CodeGen/AMDGPU/valu-read-sgpr-hazard.mir | 862 -- .../CodeGen/AMDGPU/vcmpx-permlane-hazard.mir | 5 +- .../CodeGen/AMDGPU/vector-alloca-bitcast.ll | 3 +- .../AMDGPU/vgpr-spill-placement-issue61083.ll | 6 +- .../test/CodeGen/AMDGPU/vni8-across-blocks.ll | 4 +- .../CodeGen/AMDGPU/vop-shrink-frame-index.mir | 1 - .../CodeGen/AMDGPU/vop-shrink-non-ssa.mir | 1 - llvm/test/CodeGen/AMDGPU/wave32.ll | 64 +- llvm/test/CodeGen/AMDGPU/widen-smrd-loads.ll | 44 +- llvm/test/CodeGen/AMDGPU/wqm.ll | 52 +- llvm/test/CodeGen/AMDGPU/wqm.mir | 23 +- .../test/CodeGen/AMDGPU/wwm-reserved-spill.ll | 842 +- llvm/test/CodeGen/AMDGPU/wwm-reserved.ll | 640 +- .../CodeGen/ARM/GlobalISel/arm-unsupported.ll | 22 +- llvm/test/CodeGen/ARM/arm-vld1.ll | 545 +- llvm/test/CodeGen/ARM/arm-vst1.ll | 193 +- .../CodeGen/ARM/atomicrmw-cond-sub-clamp.ll | 180 - .../test/CodeGen/ARM/bf16-intrinsics-ld-st.ll | 32 +- .../ARM/big-endian-neon-fp16-bitconv.ll | 3 +- llvm/test/CodeGen/ARM/big-endian-vmov.ll | 84 +- llvm/test/CodeGen/ARM/vmov.ll | 48 +- .../CodeGen/BPF/32-bit-subreg-cond-select.ll | 2 +- .../BPF/CORE/field-reloc-bitfield-1-bpfeb.ll | 4 +- .../BPF/CORE/field-reloc-bitfield-1.ll | 4 +- .../BPF/CORE/field-reloc-bitfield-2-bpfeb.ll | 4 +- .../BPF/CORE/field-reloc-bitfield-2.ll | 4 +- .../CORE/intrinsic-fieldinfo-byte-size-1.ll | 4 +- .../CORE/intrinsic-fieldinfo-byte-size-2.ll | 4 +- .../CORE/intrinsic-fieldinfo-byte-size-3.ll | 4 +- .../CORE/intrinsic-fieldinfo-existence-1.ll | 4 +- .../CORE/intrinsic-fieldinfo-existence-2.ll | 4 +- .../CORE/intrinsic-fieldinfo-existence-3.ll | 4 +- .../intrinsic-fieldinfo-lshift-1-bpfeb.ll | 4 +- .../BPF/CORE/intrinsic-fieldinfo-lshift-1.ll | 4 +- .../BPF/CORE/intrinsic-fieldinfo-lshift-2.ll | 4 +- .../BPF/CORE/intrinsic-fieldinfo-rshift-1.ll | 4 +- .../BPF/CORE/intrinsic-fieldinfo-rshift-2.ll | 4 +- .../BPF/CORE/intrinsic-fieldinfo-rshift-3.ll | 4 +- .../CORE/intrinsic-fieldinfo-signedness-1.ll | 4 +- .../CORE/intrinsic-fieldinfo-signedness-2.ll | 4 +- .../CORE/intrinsic-fieldinfo-signedness-3.ll | 4 +- llvm/test/CodeGen/BPF/CORE/no-narrow-load.ll | 2 +- .../CodeGen/BPF/CORE/offset-reloc-end-load.ll | 4 +- .../BPF/CORE/offset-reloc-fieldinfo-1.ll | 4 +- .../CORE/offset-reloc-fieldinfo-2-bpfeb.ll | 4 +- .../BPF/CORE/offset-reloc-fieldinfo-2.ll | 4 +- llvm/test/CodeGen/BPF/adjust-opt-icmp1.ll | 8 +- llvm/test/CodeGen/BPF/adjust-opt-icmp2.ll | 4 +- llvm/test/CodeGen/BPF/adjust-opt-icmp3.ll | 2 +- llvm/test/CodeGen/BPF/adjust-opt-icmp4.ll | 2 +- llvm/test/CodeGen/BPF/adjust-opt-icmp5.ll | 2 +- llvm/test/CodeGen/BPF/adjust-opt-icmp6.ll | 2 +- .../CodeGen/BPF/adjust-opt-speculative1.ll | 4 +- .../CodeGen/BPF/adjust-opt-speculative2.ll | 4 +- llvm/test/CodeGen/BPF/alu8.ll | 2 +- llvm/test/CodeGen/BPF/atomics.ll | 2 +- llvm/test/CodeGen/BPF/basictest.ll | 2 +- llvm/test/CodeGen/BPF/bpf-fastcall-2.ll | 2 +- llvm/test/CodeGen/BPF/cc_args.ll | 2 +- llvm/test/CodeGen/BPF/cc_args_be.ll | 2 +- llvm/test/CodeGen/BPF/cc_ret.ll | 2 +- llvm/test/CodeGen/BPF/cmp.ll | 2 +- llvm/test/CodeGen/BPF/cttz-ctlz.ll | 2 +- llvm/test/CodeGen/BPF/ex1.ll | 2 +- llvm/test/CodeGen/BPF/fi_ri.ll | 2 +- llvm/test/CodeGen/BPF/i128.ll | 4 +- llvm/test/CodeGen/BPF/intrinsics.ll | 4 +- llvm/test/CodeGen/BPF/load.ll | 2 +- llvm/test/CodeGen/BPF/loops.ll | 2 +- llvm/test/CodeGen/BPF/many_args1.ll | 2 +- llvm/test/CodeGen/BPF/objdump_atomics.ll | 2 +- llvm/test/CodeGen/BPF/objdump_cond_op.ll | 2 +- llvm/test/CodeGen/BPF/objdump_cond_op_2.ll | 2 +- llvm/test/CodeGen/BPF/objdump_imm_hex.ll | 4 +- llvm/test/CodeGen/BPF/objdump_intrinsics.ll | 4 +- llvm/test/CodeGen/BPF/objdump_nop.ll | 2 +- llvm/test/CodeGen/BPF/objdump_static_var.ll | 4 +- llvm/test/CodeGen/BPF/objdump_trivial.ll | 2 +- llvm/test/CodeGen/BPF/pr57872.ll | 2 +- llvm/test/CodeGen/BPF/reloc-2.ll | 4 +- llvm/test/CodeGen/BPF/remove_truncate_1.ll | 2 +- llvm/test/CodeGen/BPF/remove_truncate_2.ll | 2 +- llvm/test/CodeGen/BPF/remove_truncate_3.ll | 2 +- llvm/test/CodeGen/BPF/remove_truncate_6.ll | 4 +- llvm/test/CodeGen/BPF/remove_truncate_8.ll | 2 +- llvm/test/CodeGen/BPF/rodata_1.ll | 4 +- llvm/test/CodeGen/BPF/rodata_2.ll | 4 +- llvm/test/CodeGen/BPF/rodata_3.ll | 4 +- llvm/test/CodeGen/BPF/rodata_4.ll | 4 +- llvm/test/CodeGen/BPF/rodata_6.ll | 2 +- llvm/test/CodeGen/BPF/rodata_7.ll | 2 +- llvm/test/CodeGen/BPF/sanity.ll | 2 +- llvm/test/CodeGen/BPF/setcc.ll | 2 +- llvm/test/CodeGen/BPF/shifts.ll | 2 +- llvm/test/CodeGen/BPF/sockex2.ll | 2 +- llvm/test/CodeGen/BPF/undef.ll | 4 +- llvm/test/CodeGen/BPF/xadd.ll | 4 +- llvm/test/CodeGen/BPF/xadd_legal.ll | 8 +- llvm/test/CodeGen/DirectX/BufferLoad.ll | 193 - .../CodeGen/DirectX/BufferStore-errors.ll | 37 - llvm/test/CodeGen/DirectX/BufferStore.ll | 92 - .../DirectX/ContainerData/PSVResources.ll | 93 - .../DirectX/ContainerData/RuntimeInfoCS.ll | 41 - .../DirectX/CreateHandleFromBinding.ll | 12 +- llvm/test/CodeGen/DirectX/acos.ll | 25 +- llvm/test/CodeGen/DirectX/asin.ll | 25 +- llvm/test/CodeGen/DirectX/atan.ll | 25 +- llvm/test/CodeGen/DirectX/ceil.ll | 21 +- llvm/test/CodeGen/DirectX/cos.ll | 21 +- llvm/test/CodeGen/DirectX/cosh.ll | 25 +- llvm/test/CodeGen/DirectX/countbits.ll | 47 - llvm/test/CodeGen/DirectX/exp2.ll | 50 +- llvm/test/CodeGen/DirectX/fabs.ll | 22 +- llvm/test/CodeGen/DirectX/floor.ll | 25 +- llvm/test/CodeGen/DirectX/frac.ll | 64 +- llvm/test/CodeGen/DirectX/isinf.ll | 24 +- llvm/test/CodeGen/DirectX/llc-pipeline.ll | 25 - llvm/test/CodeGen/DirectX/reversebits.ll | 21 +- llvm/test/CodeGen/DirectX/round.ll | 22 +- llvm/test/CodeGen/DirectX/rsqrt.ll | 50 +- llvm/test/CodeGen/DirectX/saturate.ll | 17 +- llvm/test/CodeGen/DirectX/scalar-store.ll | 17 - .../CodeGen/DirectX/scalarize-two-calls.ll | 25 - llvm/test/CodeGen/DirectX/sign.ll | 212 - llvm/test/CodeGen/DirectX/sin.ll | 44 +- llvm/test/CodeGen/DirectX/sin_vector_error.ll | 11 - llvm/test/CodeGen/DirectX/sinh.ll | 25 +- llvm/test/CodeGen/DirectX/sqrt.ll | 25 +- llvm/test/CodeGen/DirectX/step.ll | 78 - llvm/test/CodeGen/DirectX/tan.ll | 21 +- llvm/test/CodeGen/DirectX/tanh.ll | 21 +- llvm/test/CodeGen/DirectX/trunc.ll | 21 +- .../CodeGen/DirectX/wave_is_first_lane.ll | 13 - .../Hexagon/atomicrmw-cond-sub-clamp.ll | 341 - .../autohvx/addi-offset-opt-addr-mode.ll | 41 - .../autohvx/addi-opt-predicated-def-bug.ll | 36 - .../CodeGen/Hexagon/two-addr-tied-subregs.mir | 2 +- llvm/test/CodeGen/Hexagon/vgather-opt-addr.ll | 18 +- .../LoongArch/atomicrmw-cond-sub-clamp.ll | 356 - .../test/CodeGen/LoongArch/ctlz-cttz-ctpop.ll | 24 +- llvm/test/CodeGen/LoongArch/ctpop-with-lsx.ll | 99 - llvm/test/CodeGen/LoongArch/fp16-promote.ll | 198 +- .../ir-instruction/sdiv-udiv-srem-urem.ll | 61 - .../CodeGen/LoongArch/lasx/issue107355.ll | 35 - .../LoongArch/statepoint-call-lowering-r1.ll | 13 - .../LoongArch/statepoint-call-lowering.ll | 228 - llvm/test/CodeGen/M68k/Arith/add.ll | 3 +- .../CodeGen/M68k/{Data => Arith}/sext-i1.ll | 0 llvm/test/CodeGen/M68k/CConv/fastcc-call.ll | 4 +- llvm/test/CodeGen/M68k/Data/load-imm.ll | 149 - .../CodeGen/M68k/{Data => }/link-unlnk.ll | 0 .../CodeGen/M68k/{Data => }/load-extend.ll | 0 llvm/test/CodeGen/M68k/pipeline.ll | 1 - .../AMDGPU/long-branch-reg-all-sgpr-used.ll | 2 - .../AMDGPU/machine-function-info-after-pei.ll | 1 - ...ine-function-info-long-branch-reg-debug.ll | 1 - .../machine-function-info-long-branch-reg.ll | 1 - .../AMDGPU/machine-function-info-no-ir.mir | 4 - .../MIR/AMDGPU/machine-function-info.ll | 11 +- .../MIR/Hexagon/addrmode-opt-nonreaching.mir | 233 - .../dev-mode-extra-features-logging.ll | 2 +- llvm/test/CodeGen/Mips/2008-07-06-fadd64.ll | 18 +- .../Mips/Fast-ISel/underaligned-load-store.ll | 109 - llvm/test/CodeGen/Mips/ins.ll | 60 - llvm/test/CodeGen/Mips/is_fpclass.ll | 246 - llvm/test/CodeGen/Mips/xor-and.ll | 17 - .../test/CodeGen/NVPTX/LoadStoreVectorizer.ll | 456 +- llvm/test/CodeGen/NVPTX/atomics-sm70.ll | 16 +- llvm/test/CodeGen/NVPTX/atomics-sm90.ll | 100 +- llvm/test/CodeGen/NVPTX/call_bitcast_byval.ll | 4 +- .../CodeGen/NVPTX/convert-call-to-indirect.ll | 89 - llvm/test/CodeGen/NVPTX/copysign.ll | 132 - llvm/test/CodeGen/NVPTX/lower-alloca.ll | 20 - .../CodeGen/NVPTX/lower-args-gridconstant.ll | 568 +- llvm/test/CodeGen/NVPTX/lower-byval-args.ll | 590 +- llvm/test/CodeGen/NVPTX/math-intrins.ll | 19 +- llvm/test/CodeGen/NVPTX/sext-setcc.ll | 72 - llvm/test/CodeGen/NVPTX/vector-loads.ll | 9 - .../CodeGen/PowerPC/2013-07-01-PHIElimBug.mir | 2 +- ...HoistingDueToBlockHotnessNoProfileData.mir | 18 +- ...leHoistingDueToBlockHotnessProfileData.mir | 17 +- .../aix-xcoff-exception-section-debug.ll | 8 +- llvm/test/CodeGen/PowerPC/all-atomics.ll | 88 +- .../PowerPC/atomicrmw-cond-sub-clamp.ll | 384 - .../build-vector-from-load-and-zeros.ll | 119 +- .../PowerPC/canonical-merge-shuffles.ll | 53 +- llvm/test/CodeGen/PowerPC/f128-bitcast.ll | 22 - llvm/test/CodeGen/PowerPC/fp-classify.ll | 28 +- llvm/test/CodeGen/PowerPC/frounds.ll | 286 +- llvm/test/CodeGen/PowerPC/livevars-crash1.mir | 2 +- llvm/test/CodeGen/PowerPC/livevars-crash2.mir | 2 +- llvm/test/CodeGen/PowerPC/load-and-splat.ll | 117 +- .../CodeGen/PowerPC/machine-cse-rm-pre.mir | 1 - .../PowerPC/machinelicm-cse-dead-flag.mir | 3 +- llvm/test/CodeGen/PowerPC/ppc64-P9-vabsd.ll | 20 +- llvm/test/CodeGen/PowerPC/pre-inc-disable.ll | 21 +- .../CodeGen/PowerPC/scalar_vector_test_4.ll | 42 +- llvm/test/CodeGen/PowerPC/sms-recmii.ll | 48 - .../CodeGen/PowerPC/test-vector-insert.ll | 92 +- .../PowerPC/v16i8_scalar_to_vector_shuffle.ll | 28 +- .../PowerPC/v2i64_scalar_to_vector_shuffle.ll | 44 +- .../PowerPC/v4i32_scalar_to_vector_shuffle.ll | 134 +- .../PowerPC/v8i16_scalar_to_vector_shuffle.ll | 94 +- .../CodeGen/RISCV/GlobalISel/alu-roundtrip.ll | 20 +- .../RISCV/GlobalISel/double-intrinsics.ll | 264 - .../RISCV/GlobalISel/float-intrinsics.ll | 441 - .../GlobalISel/gisel-commandline-option.ll | 1 - llvm/test/CodeGen/RISCV/GlobalISel/iabs.ll | 2 +- .../instruction-select/alu_m-rv64.mir | 135 - .../irtranslator/calling-conv-half.ll | 9 +- .../GlobalISel/irtranslator/splat_vector.ll | 821 -- .../irtranslator/vec-args-bf16-err.ll | 2 +- .../irtranslator/vec-args-f16-err.ll | 2 +- .../legalizer/legalize-abs-rv64.mir | 8 +- .../legalizer/legalize-div-rv64.mir | 128 +- .../legalizer/legalize-fp-ceil-floor.mir | 98 + .../legalizer/legalize-load-rv32.mir | 84 +- .../legalizer/legalize-load-rv64.mir | 114 +- .../legalizer/legalize-rem-rv64.mir | 128 +- .../legalizer/legalize-store-rv32.mir | 72 +- .../legalizer/legalize-store-rv64.mir | 90 +- .../GlobalISel/stacksave-stackrestore.ll | 64 - llvm/test/CodeGen/RISCV/O0-pipeline.ll | 1 - llvm/test/CodeGen/RISCV/O3-pipeline.ll | 1 - llvm/test/CodeGen/RISCV/abds-neg.ll | 233 +- llvm/test/CodeGen/RISCV/abds.ll | 677 +- llvm/test/CodeGen/RISCV/abdu-neg.ll | 366 +- llvm/test/CodeGen/RISCV/abdu.ll | 752 +- .../RISCV/atomic-cmpxchg-branch-on-result.ll | 5 - llvm/test/CodeGen/RISCV/atomic-cmpxchg.ll | 14 - llvm/test/CodeGen/RISCV/atomic-rmw.ll | 14 - llvm/test/CodeGen/RISCV/atomic-signext.ll | 2 - .../CodeGen/RISCV/atomicrmw-cond-sub-clamp.ll | 1265 -- llvm/test/CodeGen/RISCV/bfloat-arith.ll | 184 +- llvm/test/CodeGen/RISCV/bfloat-convert.ll | 57 +- llvm/test/CodeGen/RISCV/bfloat-select-fcmp.ll | 102 +- llvm/test/CodeGen/RISCV/bfloat-select-icmp.ll | 60 +- llvm/test/CodeGen/RISCV/calls.ll | 524 - llvm/test/CodeGen/RISCV/codemodel-lowering.ll | 161 - .../test/CodeGen/RISCV/compress-opt-select.ll | 753 +- llvm/test/CodeGen/RISCV/copysign-casts.ll | 120 +- llvm/test/CodeGen/RISCV/double-arith.ll | 12 +- .../RISCV/double-bitmanip-dagcombines.ll | 10 +- llvm/test/CodeGen/RISCV/double-convert.ll | 36 +- llvm/test/CodeGen/RISCV/double-fcmp-strict.ll | 96 +- llvm/test/CodeGen/RISCV/double-imm.ll | 12 +- llvm/test/CodeGen/RISCV/double-intrinsics.ll | 27 +- llvm/test/CodeGen/RISCV/double-round-conv.ll | 20 +- llvm/test/CodeGen/RISCV/double-zfa.ll | 69 - llvm/test/CodeGen/RISCV/fastcc-bf16.ll | 71 - llvm/test/CodeGen/RISCV/fastcc-half.ll | 71 - .../CodeGen/RISCV/fastcc-without-f-reg.ll | 372 +- llvm/test/CodeGen/RISCV/float-arith.ll | 39 +- .../RISCV/float-bitmanip-dagcombines.ll | 9 +- llvm/test/CodeGen/RISCV/float-convert.ll | 32 +- llvm/test/CodeGen/RISCV/float-fcmp-strict.ll | 48 +- llvm/test/CodeGen/RISCV/float-intrinsics.ll | 3 +- .../CodeGen/RISCV/float-round-conv-sat.ll | 228 +- llvm/test/CodeGen/RISCV/float-zfa.ll | 58 - .../test/CodeGen/RISCV/fold-addi-loadstore.ll | 209 - llvm/test/CodeGen/RISCV/half-arith.ll | 583 +- .../RISCV/half-bitmanip-dagcombines.ll | 66 +- .../test/CodeGen/RISCV/half-convert-strict.ll | 453 +- llvm/test/CodeGen/RISCV/half-convert.ll | 535 +- llvm/test/CodeGen/RISCV/half-fcmp-strict.ll | 96 +- llvm/test/CodeGen/RISCV/half-imm.ll | 8 +- llvm/test/CodeGen/RISCV/half-intrinsics.ll | 90 +- .../test/CodeGen/RISCV/half-round-conv-sat.ll | 648 +- llvm/test/CodeGen/RISCV/half-round-conv.ll | 340 +- llvm/test/CodeGen/RISCV/half-select-fcmp.ll | 212 +- llvm/test/CodeGen/RISCV/half-select-icmp.ll | 138 +- llvm/test/CodeGen/RISCV/half-zfa.ll | 201 - .../RISCV/inline-asm-mem-constraint.ll | 675 - .../RISCV/machine-sink-load-immediate.ll | 27 - .../RISCV/machineoutliner-pcrel-lo.mir | 104 +- .../CodeGen/RISCV/make-compressible-zbc.mir | 9 +- .../redundant-copy-from-tail-duplicate.ll | 2 +- ...regalloc-last-chance-recoloring-failure.ll | 4 +- llvm/test/CodeGen/RISCV/rv64zba.ll | 199 +- .../RISCV/rv64zfhmin-half-convert-strict.ll | 36 +- .../CodeGen/RISCV/rv64zfhmin-half-convert.ll | 36 +- .../CodeGen/RISCV/rvv/calling-conv-fastcc.ll | 116 - llvm/test/CodeGen/RISCV/rvv/ceil-vp.ll | 1167 +- llvm/test/CodeGen/RISCV/rvv/copyprop.mir | 2 +- llvm/test/CodeGen/RISCV/rvv/ctlz-vp.ll | 147 - llvm/test/CodeGen/RISCV/rvv/ctpop-vp.ll | 157 +- llvm/test/CodeGen/RISCV/rvv/cttz-vp.ll | 196 +- llvm/test/CodeGen/RISCV/rvv/fceil-sdnode.ll | 460 +- llvm/test/CodeGen/RISCV/rvv/ffloor-sdnode.ll | 466 +- .../rvv/fixed-vectors-buildvec-of-binop.ll | 13 +- .../rvv/fixed-vectors-fp-buildvec-bf16.ll | 175 - .../RISCV/rvv/fixed-vectors-fp-buildvec.ll | 281 +- .../RISCV/rvv/fixed-vectors-fp-setcc.ll | 160 +- .../RISCV/rvv/fixed-vectors-fp-splat-bf16.ll | 45 +- .../RISCV/rvv/fixed-vectors-fp-splat.ll | 89 +- .../CodeGen/RISCV/rvv/fixed-vectors-fp.ll | 5091 ++++--- .../CodeGen/RISCV/rvv/fixed-vectors-insert.ll | 1 + .../rvv/fixed-vectors-interleaved-access.ll | 640 +- .../CodeGen/RISCV/rvv/fixed-vectors-llrint.ll | 16 +- .../CodeGen/RISCV/rvv/fixed-vectors-load.ll | 10 +- .../RISCV/rvv/fixed-vectors-masked-gather.ll | 96 +- .../rvv/fixed-vectors-masked-load-int.ll | 56 +- .../rvv/fixed-vectors-masked-store-int.ll | 122 +- .../rvv/fixed-vectors-reduction-formation.ll | 49 +- .../RISCV/rvv/fixed-vectors-setcc-fp-vp.ll | 196 +- .../CodeGen/RISCV/rvv/fixed-vectors-store.ll | 8 +- .../RISCV/rvv/fixed-vectors-vadd-vp.ll | 174 +- .../RISCV/rvv/fixed-vectors-vand-vp.ll | 36 +- .../RISCV/rvv/fixed-vectors-vfadd-vp.ll | 80 +- .../RISCV/rvv/fixed-vectors-vfdiv-vp.ll | 80 +- .../RISCV/rvv/fixed-vectors-vfma-vp.ll | 104 +- .../CodeGen/RISCV/rvv/fixed-vectors-vfmax.ll | 80 +- .../CodeGen/RISCV/rvv/fixed-vectors-vfmin.ll | 80 +- .../RISCV/rvv/fixed-vectors-vfmul-vp.ll | 80 +- ...fixed-vectors-vfptoi-constrained-sdnode.ll | 4 +- .../RISCV/rvv/fixed-vectors-vfsub-vp.ll | 80 +- .../RISCV/rvv/fixed-vectors-vfwmaccbf16.ll | 467 - .../RISCV/rvv/fixed-vectors-vmax-vp.ll | 66 +- .../RISCV/rvv/fixed-vectors-vmaxu-vp.ll | 66 +- .../RISCV/rvv/fixed-vectors-vmin-vp.ll | 66 +- .../RISCV/rvv/fixed-vectors-vminu-vp.ll | 66 +- .../RISCV/rvv/fixed-vectors-vpmerge-bf16.ll | 40 +- .../RISCV/rvv/fixed-vectors-vpmerge.ll | 40 +- .../RISCV/rvv/fixed-vectors-vsadd-vp.ll | 189 +- .../RISCV/rvv/fixed-vectors-vsaddu-vp.ll | 189 +- .../RISCV/rvv/fixed-vectors-vssub-vp.ll | 197 +- .../RISCV/rvv/fixed-vectors-vssubu-vp.ll | 197 +- llvm/test/CodeGen/RISCV/rvv/floor-vp.ll | 1167 +- .../test/CodeGen/RISCV/rvv/fmaximum-sdnode.ll | 195 +- llvm/test/CodeGen/RISCV/rvv/fmaximum-vp.ll | 562 +- .../test/CodeGen/RISCV/rvv/fminimum-sdnode.ll | 195 +- llvm/test/CodeGen/RISCV/rvv/fminimum-vp.ll | 562 +- .../CodeGen/RISCV/rvv/fnearbyint-sdnode.ll | 488 +- llvm/test/CodeGen/RISCV/rvv/frint-sdnode.ll | 424 +- llvm/test/CodeGen/RISCV/rvv/fround-sdnode.ll | 460 +- .../CodeGen/RISCV/rvv/froundeven-sdnode.ll | 461 +- llvm/test/CodeGen/RISCV/rvv/ftrunc-sdnode.ll | 424 +- .../rvv/handle-noreg-with-implicit-def.mir | 4 +- llvm/test/CodeGen/RISCV/rvv/load-bf16.ll | 71 - .../RISCV/rvv/named-vector-shuffle-reverse.ll | 84 +- llvm/test/CodeGen/RISCV/rvv/nearbyint-vp.ll | 530 +- llvm/test/CodeGen/RISCV/rvv/pr107950.ll | 30 - llvm/test/CodeGen/RISCV/rvv/remat.ll | 398 - llvm/test/CodeGen/RISCV/rvv/rint-vp.ll | 507 +- llvm/test/CodeGen/RISCV/rvv/round-vp.ll | 538 +- llvm/test/CodeGen/RISCV/rvv/roundeven-vp.ll | 538 +- llvm/test/CodeGen/RISCV/rvv/roundtozero-vp.ll | 538 +- .../RISCV/rvv/rvv-peephole-vmerge-to-vmv.mir | 92 +- llvm/test/CodeGen/RISCV/rvv/setcc-fp-vp.ll | 2553 +--- llvm/test/CodeGen/RISCV/rvv/setcc-fp.ll | 1498 +- llvm/test/CodeGen/RISCV/rvv/store-bf16.ll | 71 - .../rvv/subregister-undef-early-clobber.mir | 176 +- .../RISCV/rvv/undef-earlyclobber-chain.mir | 4 +- llvm/test/CodeGen/RISCV/rvv/vadd-vp.ll | 1 + .../RISCV/rvv/vector-deinterleave-load.ll | 22 +- .../CodeGen/RISCV/rvv/vector-deinterleave.ll | 59 +- .../RISCV/rvv/vector-interleave-store.ll | 21 +- .../CodeGen/RISCV/rvv/vector-interleave.ll | 114 +- llvm/test/CodeGen/RISCV/rvv/vfabs-sdnode.ll | 157 +- .../RISCV/rvv/vfadd-constrained-sdnode.ll | 318 +- llvm/test/CodeGen/RISCV/rvv/vfadd-sdnode.ll | 338 +- llvm/test/CodeGen/RISCV/rvv/vfadd-vp.ll | 933 +- llvm/test/CodeGen/RISCV/rvv/vfclass-sdnode.ll | 55 +- .../CodeGen/RISCV/rvv/vfcopysign-sdnode.ll | 843 +- .../RISCV/rvv/vfdiv-constrained-sdnode.ll | 345 +- llvm/test/CodeGen/RISCV/rvv/vfdiv-sdnode.ll | 326 +- llvm/test/CodeGen/RISCV/rvv/vfdiv-vp.ll | 867 +- llvm/test/CodeGen/RISCV/rvv/vfma-vp.ll | 11248 ++-------------- .../RISCV/rvv/vfmadd-constrained-sdnode.ll | 536 +- llvm/test/CodeGen/RISCV/rvv/vfmadd-sdnode.ll | 693 +- llvm/test/CodeGen/RISCV/rvv/vfmax-sdnode.ll | 321 +- llvm/test/CodeGen/RISCV/rvv/vfmax-vp.ll | 291 +- llvm/test/CodeGen/RISCV/rvv/vfmin-sdnode.ll | 321 +- llvm/test/CodeGen/RISCV/rvv/vfmin-vp.ll | 291 +- .../RISCV/rvv/vfmsub-constrained-sdnode.ll | 360 +- .../RISCV/rvv/vfmul-constrained-sdnode.ll | 318 +- llvm/test/CodeGen/RISCV/rvv/vfmul-sdnode.ll | 338 +- llvm/test/CodeGen/RISCV/rvv/vfmul-vp.ll | 224 +- llvm/test/CodeGen/RISCV/rvv/vfneg-sdnode.ll | 145 +- .../RISCV/rvv/vfnmadd-constrained-sdnode.ll | 454 +- .../RISCV/rvv/vfnmsub-constrained-sdnode.ll | 374 +- llvm/test/CodeGen/RISCV/rvv/vfptoi-sdnode.ll | 738 +- .../test/CodeGen/RISCV/rvv/vfptosi-vp-mask.ll | 34 +- llvm/test/CodeGen/RISCV/rvv/vfptosi-vp.ll | 134 +- .../test/CodeGen/RISCV/rvv/vfptoui-vp-mask.ll | 34 +- llvm/test/CodeGen/RISCV/rvv/vfptoui-vp.ll | 134 +- .../RISCV/rvv/vfsqrt-constrained-sdnode.ll | 114 +- llvm/test/CodeGen/RISCV/rvv/vfsqrt-sdnode.ll | 109 +- llvm/test/CodeGen/RISCV/rvv/vfsqrt-vp.ll | 257 +- .../RISCV/rvv/vfsub-constrained-sdnode.ll | 345 +- llvm/test/CodeGen/RISCV/rvv/vfsub-sdnode.ll | 338 +- llvm/test/CodeGen/RISCV/rvv/vfsub-vp.ll | 867 +- llvm/test/CodeGen/RISCV/rvv/vfwadd-vp.ll | 42 +- llvm/test/CodeGen/RISCV/rvv/vfwmacc-vp.ll | 184 +- llvm/test/CodeGen/RISCV/rvv/vfwmsac-vp.ll | 144 +- llvm/test/CodeGen/RISCV/rvv/vfwnmacc-vp.ll | 174 +- llvm/test/CodeGen/RISCV/rvv/vfwnmsac-vp.ll | 174 +- llvm/test/CodeGen/RISCV/rvv/vitofp-sdnode.ll | 726 +- llvm/test/CodeGen/RISCV/rvv/vl-opt-no-prop.ll | 80 - llvm/test/CodeGen/RISCV/rvv/vl-opt-op-info.ll | 83 - llvm/test/CodeGen/RISCV/rvv/vl-opt.ll | 106 - llvm/test/CodeGen/RISCV/rvv/vmax-vp.ll | 1 + llvm/test/CodeGen/RISCV/rvv/vmaxu-vp.ll | 1 + llvm/test/CodeGen/RISCV/rvv/vmin-vp.ll | 1 + llvm/test/CodeGen/RISCV/rvv/vminu-vp.ll | 1 + .../CodeGen/RISCV/rvv/vmv.v.v-peephole.ll | 12 - .../CodeGen/RISCV/rvv/vmv.v.v-peephole.mir | 71 - llvm/test/CodeGen/RISCV/rvv/vmv.v.v.ll | 430 +- .../CodeGen/RISCV/rvv/vpmerge-sdnode-bf16.ll | 61 +- llvm/test/CodeGen/RISCV/rvv/vpmerge-sdnode.ll | 122 +- .../CodeGen/RISCV/rvv/vreductions-fp-vp.ll | 396 +- llvm/test/CodeGen/RISCV/rvv/vselect-bf16.ll | 60 +- llvm/test/CodeGen/RISCV/rvv/vselect-fp.ll | 95 +- .../test/CodeGen/RISCV/rvv/vsitofp-vp-mask.ll | 33 +- llvm/test/CodeGen/RISCV/rvv/vsitofp-vp.ll | 146 +- llvm/test/CodeGen/RISCV/rvv/vsplats-bf16.ll | 44 +- llvm/test/CodeGen/RISCV/rvv/vsplats-f16.ll | 20 - llvm/test/CodeGen/RISCV/rvv/vsplats-fp.ll | 8 +- .../test/CodeGen/RISCV/rvv/vuitofp-vp-mask.ll | 33 +- llvm/test/CodeGen/RISCV/rvv/vuitofp-vp.ll | 138 +- llvm/test/CodeGen/RISCV/rvv/vwadd-sdnode.ll | 2 + llvm/test/CodeGen/RISCV/select.ll | 332 +- .../CodeGen/RISCV/srem-seteq-illegal-types.ll | 61 +- llvm/test/CodeGen/RISCV/xcvalu.ll | 4 +- .../CodeGen/RISCV/zdinx-boundary-check.ll | 64 - .../SPIRV/branching/OpSwitchBranches.ll | 18 +- .../CodeGen/SPIRV/branching/OpSwitchEmpty.ll | 6 +- .../SPIRV/branching/OpSwitchUnreachable.ll | 10 +- .../branching/Two_OpSwitch_same_register.ll | 13 +- .../CodeGen/SPIRV/branching/if-merging.ll | 12 +- .../CodeGen/SPIRV/branching/if-non-merging.ll | 4 +- .../SPIRV/branching/switch-range-check.ll | 13 +- ...compilation-unit.ll => basic-global-di.ll} | 2 +- .../SPIRV/debug-info/debug-type-basic.ll | 233 - .../debug-info/no-misplaced-opextinst.ll | 36 - .../SPIRV/hlsl-intrinsics/WaveIsFirstLane.ll | 27 - .../SPIRV/hlsl-intrinsics/countbits.ll | 21 - .../CodeGen/SPIRV/hlsl-intrinsics/sign.ll | 143 - .../CodeGen/SPIRV/hlsl-intrinsics/step.ll | 33 - .../CodeGen/SPIRV/instructions/ret-type.ll | 4 - llvm/test/CodeGen/SPIRV/lit.local.cfg | 11 - .../CodeGen/SPIRV/opt-gepoperator-of-gvar.ll | 64 - .../CodeGen/SPIRV/phi-ptrcast-dominate.ll | 34 +- .../CodeGen/SPIRV/scfg-add-pre-headers.ll | 87 + .../CodeGen/SPIRV/structurizer/cf.cond-op.ll | 168 - .../CodeGen/SPIRV/structurizer/cf.do.break.ll | 169 - .../SPIRV/structurizer/cf.do.continue.ll | 167 - .../SPIRV/structurizer/cf.do.nested.ll | 138 - .../SPIRV/structurizer/cf.for.break.ll | 178 - .../SPIRV/structurizer/cf.for.continue.ll | 221 - .../SPIRV/structurizer/cf.for.nested.ll | 188 - .../SPIRV/structurizer/cf.for.plain.ll | 103 - .../cf.for.short-circuited-cond.ll | 397 - .../SPIRV/structurizer/cf.if.const-cond.ll | 101 - .../CodeGen/SPIRV/structurizer/cf.if.for.ll | 292 - .../SPIRV/structurizer/cf.if.nested.ll | 163 - .../CodeGen/SPIRV/structurizer/cf.if.plain.ll | 183 - .../SPIRV/structurizer/cf.logical-and.ll | 194 - .../SPIRV/structurizer/cf.logical-or.ll | 223 - .../SPIRV/structurizer/cf.return.early.ll | 237 - .../structurizer/cf.return.early.simple.ll | 128 - .../SPIRV/structurizer/cf.return.void.ll | 68 - .../SPIRV/structurizer/cf.switch.ifstmt.ll | 507 - .../structurizer/cf.switch.ifstmt.simple.ll | 127 - .../structurizer/cf.switch.ifstmt.simple2.ll | 243 - .../cf.switch.opswitch.literal.ll | 70 - .../SPIRV/structurizer/cf.switch.opswitch.ll | 717 - .../structurizer/cf.switch.opswitch.simple.ll | 165 - .../SPIRV/structurizer/cf.while.break.ll | 190 - .../SPIRV/structurizer/cf.while.continue.ll | 198 - .../SPIRV/structurizer/cf.while.nested.ll | 157 - .../SPIRV/structurizer/cf.while.plain.ll | 137 - .../cf.while.short-circuited-cond.ll | 287 - .../SPIRV/structurizer/condition-linear.ll | 126 - .../CodeGen/SPIRV/structurizer/do-break.ll | 89 - .../CodeGen/SPIRV/structurizer/do-continue.ll | 124 - .../CodeGen/SPIRV/structurizer/do-nested.ll | 102 - .../CodeGen/SPIRV/structurizer/do-plain.ll | 98 - .../CodeGen/SPIRV/structurizer/logical-or.ll | 95 - .../SPIRV/structurizer/merge-exit-break.ll | 33 +- .../merge-exit-convergence-in-break.ll | 53 +- .../structurizer/merge-exit-multiple-break.ll | 65 +- .../merge-exit-simple-while-identity.ll | 6 +- .../SPIRV/structurizer/return-early.ll | 131 - .../SPIRV/transcoding/GlobalFunAnnotate.ll | 2 +- llvm/test/CodeGen/SystemZ/args-14.ll | 39 - llvm/test/CodeGen/SystemZ/args-15.ll | 11 - llvm/test/CodeGen/SystemZ/args-16.ll | 12 - llvm/test/CodeGen/SystemZ/args-17.ll | 11 - llvm/test/CodeGen/SystemZ/args-18.ll | 14 - llvm/test/CodeGen/SystemZ/args-19.ll | 14 - llvm/test/CodeGen/SystemZ/args-20.ll | 14 - llvm/test/CodeGen/SystemZ/args-21.ll | 19 - .../CodeGen/Thumb/machine-cse-deadreg.mir | 1 - .../CodeGen/Thumb/machine-cse-physreg.mir | 1 - llvm/test/CodeGen/Thumb2/mve-be.ll | 2 + .../Thumb2/mve-intrinsics/bitwise-imm.ll | 495 +- .../CodeGen/Thumb2/mve-intrinsics/vcaddq.ll | 13 - .../Thumb2/mve-laneinterleaving-cost.ll | 4 +- llvm/test/CodeGen/Thumb2/mve-masked-ldst.ll | 22 +- llvm/test/CodeGen/Thumb2/mve-pred-bitcast.ll | 2 + .../test/CodeGen/Thumb2/mve-pred-loadstore.ll | 8 +- llvm/test/CodeGen/Thumb2/mve-pred-spill.ll | 18 +- llvm/test/CodeGen/Thumb2/mve-satmul-loops.ll | 10 +- llvm/test/CodeGen/Thumb2/mve-scmp.ll | 344 - llvm/test/CodeGen/Thumb2/mve-ucmp.ll | 343 - llvm/test/CodeGen/Thumb2/mve-vmovimm.ll | 117 +- .../Thumb2/pipeliner-preserve-ties.mir | 2 +- llvm/test/CodeGen/Thumb2/pr52817.ll | 3 +- .../VE/Scalar/atomicrmw-cond-sub-clamp.ll | 235 - .../WebAssembly/atomicrmw-cond-sub-clamp.ll | 363 - .../WebAssembly/cfg-stackify-eh-legacy.ll | 122 +- ...kify-eh-legacy.mir => cfg-stackify-eh.mir} | 23 +- .../CodeGen/WebAssembly/exception-legacy.ll | 42 +- llvm/test/CodeGen/WebAssembly/exception.ll | 471 - .../{exception-legacy.mir => exception.mir} | 4 +- .../CodeGen/WebAssembly/function-info.mir | 4 +- .../CodeGen/WebAssembly/half-precision.ll | 29 +- .../CodeGen/WinEH/wineh-empty-seh-scope.ll | 18 - .../X86/GlobalISel/select-extract-vec256.mir | 4 +- .../X86/GlobalISel/select-extract-vec512.mir | 4 +- .../X86/GlobalISel/select-insert-vec256.mir | 12 +- .../X86/GlobalISel/select-insert-vec512.mir | 24 +- .../X86/GlobalISel/select-merge-vec256.mir | 8 +- .../X86/GlobalISel/select-merge-vec512.mir | 12 +- .../X86/GlobalISel/select-unmerge-vec256.mir | 21 +- .../X86/GlobalISel/select-unmerge-vec512.mir | 8 +- llvm/test/CodeGen/X86/abds-neg.ll | 315 +- llvm/test/CodeGen/X86/abds.ll | 429 +- llvm/test/CodeGen/X86/abdu-neg.ll | 329 +- llvm/test/CodeGen/X86/abdu.ll | 456 +- .../any_extend_vector_inreg_of_broadcast.ll | 4 +- .../CodeGen/X86/apx/domain-reassignment.mir | 78 +- llvm/test/CodeGen/X86/atomic6432.ll | 56 +- .../CodeGen/X86/atomicrmw-cond-sub-clamp.ll | 436 - llvm/test/CodeGen/X86/avx10.2-fma-commute.ll | 1244 -- .../test/CodeGen/X86/avx10_2_512bf16-arith.ll | 587 - .../CodeGen/X86/avx10_2_512bf16-intrinsics.ll | 230 - .../X86/avx10_2_512satcvtds-intrinsics.ll | 526 - llvm/test/CodeGen/X86/avx10_2bf16-arith.ll | 1168 -- .../CodeGen/X86/avx10_2bf16-intrinsics.ll | 602 - .../CodeGen/X86/avx10_2fptosi_satcvtds.ll | 115 - .../CodeGen/X86/avx10_2satcvtds-intrinsics.ll | 1066 -- .../X86/avx10_2satcvtds-x64-intrinsics.ll | 58 - llvm/test/CodeGen/X86/avx512-calling-conv.ll | 214 +- .../avx512-extract-subvector-load-store.ll | 32 +- .../test/CodeGen/X86/avx512-insert-extract.ll | 6 +- .../X86/avx512-shuffles/partial_permute.ll | 30 +- .../test/CodeGen/X86/avx512copy-intrinsics.ll | 35 - llvm/test/CodeGen/X86/bfloat.ll | 22 - llvm/test/CodeGen/X86/buildvec-insertvec.ll | 4 +- .../CodeGen/X86/bypass-slow-division-64.ll | 1 - llvm/test/CodeGen/X86/clobber_frame_ptr.ll | 43 - llvm/test/CodeGen/X86/cmov-promotion.ll | 140 +- llvm/test/CodeGen/X86/cmp-shiftX-maskX.ll | 24 - llvm/test/CodeGen/X86/cmp16.ll | 1 - llvm/test/CodeGen/X86/comi-flags.ll | 237 +- llvm/test/CodeGen/X86/cpus-amd.ll | 1 - llvm/test/CodeGen/X86/cse-two-preds.mir | 1 - llvm/test/CodeGen/X86/ctlo.ll | 14 +- llvm/test/CodeGen/X86/distancemap.mir | 2 +- llvm/test/CodeGen/X86/domain-reassignment.mir | 78 +- .../test/CodeGen/X86/evex-to-vex-compress.mir | 176 +- llvm/test/CodeGen/X86/fsafdo_test1.ll | 4 +- llvm/test/CodeGen/X86/fsafdo_test4.ll | 4 +- llvm/test/CodeGen/X86/is_fpclass.ll | 92 +- .../CodeGen/X86/jump-table-size-section.ll | 210 - .../test/CodeGen/X86/known-signbits-vector.ll | 7 +- .../test/CodeGen/X86/load-scalar-as-vector.ll | 18 +- .../CodeGen/X86/machine-licm-vs-wineh.mir | 1 - .../CodeGen/X86/masked_compressstore_isel.ll | 8 +- .../CodeGen/X86/masked_expandload_isel.ll | 8 +- llvm/test/CodeGen/X86/movmsk-cmp.ll | 77 +- llvm/test/CodeGen/X86/opt_phis2.mir | 12 +- llvm/test/CodeGen/X86/phielim-undef.mir | 2 +- llvm/test/CodeGen/X86/pr108728.ll | 14 - llvm/test/CodeGen/X86/pr29222.ll | 4 +- llvm/test/CodeGen/X86/pr43507.ll | 8 +- llvm/test/CodeGen/X86/pr44915.ll | 15 +- llvm/test/CodeGen/X86/pr5145.ll | 16 +- llvm/test/CodeGen/X86/pseudo_cmov_lower2.ll | 2 - .../pull-conditional-binop-through-shift.ll | 742 +- llvm/test/CodeGen/X86/rdpru.ll | 1 - llvm/test/CodeGen/X86/scmp.ll | 1917 +-- llvm/test/CodeGen/X86/select.ll | 426 +- llvm/test/CodeGen/X86/select_const.ll | 92 +- llvm/test/CodeGen/X86/setcc-lowering.ll | 23 +- llvm/test/CodeGen/X86/shuffle-as-shifts.ll | 1 - llvm/test/CodeGen/X86/shuffle-half.ll | 2 +- llvm/test/CodeGen/X86/slow-unaligned-mem.ll | 1 - llvm/test/CodeGen/X86/sqrt-fastmath-tune.ll | 1 - .../X86/tuning-shuffle-permilpd-avx512.ll | 1 - .../X86/tuning-shuffle-permilps-avx512.ll | 1 - .../X86/tuning-shuffle-unpckpd-avx512.ll | 1 - .../X86/tuning-shuffle-unpckps-avx512.ll | 1 - llvm/test/CodeGen/X86/twoaddr-mul2.mir | 2 +- llvm/test/CodeGen/X86/ucmp.ll | 2905 +--- llvm/test/CodeGen/X86/unfoldMemoryOperand.mir | 3 +- llvm/test/CodeGen/X86/vec_insert-5.ll | 7 +- llvm/test/CodeGen/X86/vec_shift5.ll | 16 +- llvm/test/CodeGen/X86/vector-compress.ll | 1213 -- .../vector-interleaved-load-i32-stride-7.ll | 40 +- .../vector-interleaved-load-i32-stride-8.ll | 16 +- .../vector-interleaved-load-i8-stride-7.ll | 402 +- .../CodeGen/X86/vector-reduce-add-mask.ll | 6 +- .../CodeGen/X86/vector-reduce-fmax-nnan.ll | 14 +- .../CodeGen/X86/vector-reduce-fmin-nnan.ll | 10 +- llvm/test/CodeGen/X86/vector-sext.ll | 83 +- .../test/CodeGen/X86/vector-shift-ashr-128.ll | 255 - .../test/CodeGen/X86/vector-shift-ashr-256.ll | 295 - .../test/CodeGen/X86/vector-shift-ashr-512.ll | 75 - .../test/CodeGen/X86/vector-shift-lshr-128.ll | 155 - .../test/CodeGen/X86/vector-shift-lshr-256.ll | 224 - .../test/CodeGen/X86/vector-shift-lshr-512.ll | 48 - llvm/test/CodeGen/X86/vector-shift-shl-128.ll | 155 - llvm/test/CodeGen/X86/vector-shift-shl-256.ll | 212 - llvm/test/CodeGen/X86/vector-shift-shl-512.ll | 44 - .../CodeGen/X86/vector-shuffle-combining.ll | 20 +- .../X86/vector-shuffle-fast-per-lane.ll | 1 - llvm/test/CodeGen/X86/vmaskmov-offset.ll | 2 +- llvm/test/CodeGen/X86/vpdpwssd.ll | 1 - .../CodeGen/X86/x86-64-double-shifts-var.ll | 1 - .../CodeGen/X86/zero_extend_vector_inreg.ll | 5 +- .../zero_extend_vector_inreg_of_broadcast.ll | 4 +- .../CodeGen/Xtensa/frameaddr-returnaddr.ll | 38 - llvm/test/DebugInfo/COFF/build-info.ll | 4 +- .../test/DebugInfo/COFF/global-type-hashes.ll | 4 +- llvm/test/DebugInfo/COFF/types-basic.ll | 4 +- .../test/DebugInfo/COFF/types-data-members.ll | 4 +- .../Generic/debug-ranges-duplication.ll | 73 - llvm/test/DebugInfo/MIR/X86/empty-inline.mir | 2 + llvm/test/DebugInfo/MIR/X86/machine-cse.mir | 1 - .../MIR/X86/mlicm-hoist-pre-regalloc.mir | 1 - llvm/test/DebugInfo/X86/discriminator.ll | 2 +- llvm/test/DebugInfo/X86/empty-line-info.ll | 65 - .../DebugInfo/X86/is_stmt-at-block-start.ll | 37 + .../DebugInfo/type-finder-w-dbg-records.ll | 51 - .../Demangle/ms-placeholder-return-type.test | 18 - .../AddressSanitizer/instrument_global.ll | 21 - .../HWAddressSanitizer/RISCV/alloca.ll | 138 +- .../HWAddressSanitizer/RISCV/basic.ll | 242 +- .../HWAddressSanitizer/alloca.ll | 138 +- .../HWAddressSanitizer/basic.ll | 180 +- .../HWAddressSanitizer/mem-attr.ll | 10 +- .../PGOForceFunctionAttrs/basic.ll | 1 + llvm/test/Instrumentation/sanitizers-naked.ll | 91 - .../MC/AArch64/SVE/directive-arch-negative.s | 8 - .../SVE/directive-arch_extension-negative.s | 7 +- .../MC/AArch64/SVE/directive-cpu-negative.s | 7 +- llvm/test/MC/AArch64/SVE2p1/bfadd.s | 20 +- llvm/test/MC/AArch64/SVE2p1/bfclamp.s | 10 +- llvm/test/MC/AArch64/SVE2p1/bfmax.s | 12 +- llvm/test/MC/AArch64/SVE2p1/bfmaxnm.s | 12 +- llvm/test/MC/AArch64/SVE2p1/bfmin.s | 12 +- llvm/test/MC/AArch64/SVE2p1/bfminnm.s | 12 +- llvm/test/MC/AArch64/SVE2p1/bfmla.s | 22 +- llvm/test/MC/AArch64/SVE2p1/bfmls.s | 22 +- llvm/test/MC/AArch64/SVE2p1/bfmul.s | 28 +- llvm/test/MC/AArch64/SVE2p1/bfsub.s | 20 +- .../test/MC/AArch64/directive-arch-negative.s | 7 +- .../directive-arch_extension-negative.s | 14 +- llvm/test/MC/AArch64/directive-cpu-err.s | 7 +- llvm/test/MC/AMDGPU/gfx11_asm_vop1.s | 44 +- llvm/test/MC/AMDGPU/gfx11_asm_vop1_dpp16.s | 64 +- llvm/test/MC/AMDGPU/gfx11_asm_vop1_dpp8.s | 26 +- .../MC/AMDGPU/gfx11_asm_vop1_t16_promote.s | 114 +- llvm/test/MC/AMDGPU/gfx11_asm_vop2_t16_err.s | 40 +- .../AMDGPU/gfx11_asm_vop3_dpp16_from_vop1.s | 62 +- .../MC/AMDGPU/gfx11_asm_vop3_dpp8_from_vop1.s | 22 +- .../test/MC/AMDGPU/gfx11_asm_vop3_from_vop1.s | 40 +- llvm/test/MC/AMDGPU/gfx12_asm_vimage_alias.s | 6 - llvm/test/MC/AMDGPU/gfx12_asm_vop1.s | 82 +- llvm/test/MC/AMDGPU/gfx12_asm_vop1_dpp16.s | 68 +- llvm/test/MC/AMDGPU/gfx12_asm_vop1_dpp8.s | 24 +- llvm/test/MC/AMDGPU/gfx12_asm_vop1_t16_err.s | 68 +- .../MC/AMDGPU/gfx12_asm_vop1_t16_promote.s | 73 +- .../test/MC/AMDGPU/gfx12_asm_vop3_from_vop1.s | 14 +- .../AMDGPU/gfx12_asm_vop3_from_vop1_dpp16.s | 62 +- .../MC/AMDGPU/gfx12_asm_vop3_from_vop1_dpp8.s | 22 +- llvm/test/MC/AVR/hex-immediates.s | 2 +- llvm/test/MC/AVR/inst-adc.s | 4 +- llvm/test/MC/AVR/inst-add.s | 4 +- llvm/test/MC/AVR/inst-adiw.s | 2 + llvm/test/MC/AVR/inst-and.s | 4 +- llvm/test/MC/AVR/inst-andi.s | 4 +- llvm/test/MC/AVR/inst-asr.s | 4 +- llvm/test/MC/AVR/inst-bld.s | 4 +- llvm/test/MC/AVR/inst-brbc.s | 2 +- llvm/test/MC/AVR/inst-brbs.s | 2 +- llvm/test/MC/AVR/inst-brcc.s | 2 +- llvm/test/MC/AVR/inst-brcs.s | 2 +- llvm/test/MC/AVR/inst-break.s | 4 +- llvm/test/MC/AVR/inst-breq.s | 2 +- llvm/test/MC/AVR/inst-brge.s | 2 +- llvm/test/MC/AVR/inst-brhc.s | 2 +- llvm/test/MC/AVR/inst-brhs.s | 2 +- llvm/test/MC/AVR/inst-brid.s | 2 +- llvm/test/MC/AVR/inst-brie.s | 2 +- llvm/test/MC/AVR/inst-brlo.s | 2 +- llvm/test/MC/AVR/inst-brlt.s | 2 +- llvm/test/MC/AVR/inst-brmi.s | 2 +- llvm/test/MC/AVR/inst-brne.s | 2 +- llvm/test/MC/AVR/inst-brpl.s | 2 +- llvm/test/MC/AVR/inst-brsh.s | 2 +- llvm/test/MC/AVR/inst-brtc.s | 2 +- llvm/test/MC/AVR/inst-brts.s | 2 +- llvm/test/MC/AVR/inst-brvc.s | 2 +- llvm/test/MC/AVR/inst-brvs.s | 2 +- llvm/test/MC/AVR/inst-bst.s | 4 +- llvm/test/MC/AVR/inst-call.s | 2 + llvm/test/MC/AVR/inst-cbi.s | 4 +- llvm/test/MC/AVR/inst-cbr.s | 4 +- llvm/test/MC/AVR/inst-clr.s | 4 +- llvm/test/MC/AVR/inst-com.s | 4 +- llvm/test/MC/AVR/inst-cp.s | 4 +- llvm/test/MC/AVR/inst-cpc.s | 4 +- llvm/test/MC/AVR/inst-cpi.s | 4 +- llvm/test/MC/AVR/inst-cpse.s | 4 +- llvm/test/MC/AVR/inst-dec.s | 4 +- llvm/test/MC/AVR/inst-des.s | 4 +- llvm/test/MC/AVR/inst-eicall.s | 4 +- llvm/test/MC/AVR/inst-eijmp.s | 4 +- llvm/test/MC/AVR/inst-elpm.s | 4 +- llvm/test/MC/AVR/inst-eor.s | 4 +- llvm/test/MC/AVR/inst-family-set-clr-flag.s | 2 +- llvm/test/MC/AVR/inst-fmul.s | 4 +- llvm/test/MC/AVR/inst-fmuls.s | 4 +- llvm/test/MC/AVR/inst-fmulsu.s | 4 +- llvm/test/MC/AVR/inst-icall.s | 4 +- llvm/test/MC/AVR/inst-ijmp.s | 4 +- llvm/test/MC/AVR/inst-in.s | 4 +- llvm/test/MC/AVR/inst-inc.s | 4 +- llvm/test/MC/AVR/inst-jmp.s | 2 + llvm/test/MC/AVR/inst-lac.s | 4 +- llvm/test/MC/AVR/inst-las.s | 4 +- llvm/test/MC/AVR/inst-lat.s | 4 +- llvm/test/MC/AVR/inst-ld.s | 4 +- llvm/test/MC/AVR/inst-ldd.s | 2 +- llvm/test/MC/AVR/inst-ldi.s | 3 +- llvm/test/MC/AVR/inst-lds.s | 1 + llvm/test/MC/AVR/inst-lpm.s | 4 +- llvm/test/MC/AVR/inst-lsl.s | 4 +- llvm/test/MC/AVR/inst-lsr.s | 4 +- llvm/test/MC/AVR/inst-mov.s | 4 +- llvm/test/MC/AVR/inst-movw.s | 4 +- llvm/test/MC/AVR/inst-mul.s | 3 +- llvm/test/MC/AVR/inst-muls.s | 4 +- llvm/test/MC/AVR/inst-mulsu.s | 4 +- llvm/test/MC/AVR/inst-neg.s | 2 +- llvm/test/MC/AVR/inst-nop.s | 4 +- llvm/test/MC/AVR/inst-or.s | 3 +- llvm/test/MC/AVR/inst-ori.s | 4 +- llvm/test/MC/AVR/inst-out.s | 4 +- llvm/test/MC/AVR/inst-pop.s | 4 +- llvm/test/MC/AVR/inst-push.s | 4 +- llvm/test/MC/AVR/inst-rcall.s | 2 +- llvm/test/MC/AVR/inst-ret.s | 4 +- llvm/test/MC/AVR/inst-reti.s | 4 +- llvm/test/MC/AVR/inst-rjmp.s | 42 +- llvm/test/MC/AVR/inst-rol.s | 4 +- llvm/test/MC/AVR/inst-ror.s | 4 +- llvm/test/MC/AVR/inst-sbc.s | 4 +- llvm/test/MC/AVR/inst-sbci.s | 4 +- llvm/test/MC/AVR/inst-sbi.s | 4 +- llvm/test/MC/AVR/inst-sbic.s | 4 +- llvm/test/MC/AVR/inst-sbis.s | 3 +- llvm/test/MC/AVR/inst-sbiw.s | 2 + llvm/test/MC/AVR/inst-sbr.s | 3 +- llvm/test/MC/AVR/inst-sbrc.s | 4 +- llvm/test/MC/AVR/inst-sbrs.s | 4 +- llvm/test/MC/AVR/inst-ser.s | 3 +- llvm/test/MC/AVR/inst-sleep.s | 4 +- llvm/test/MC/AVR/inst-spm.s | 4 +- llvm/test/MC/AVR/inst-st.s | 3 +- llvm/test/MC/AVR/inst-std.s | 3 +- llvm/test/MC/AVR/inst-sts.s | 2 + llvm/test/MC/AVR/inst-sub.s | 3 +- llvm/test/MC/AVR/inst-subi.s | 3 +- llvm/test/MC/AVR/inst-swap.s | 4 +- llvm/test/MC/AVR/inst-tst.s | 4 +- llvm/test/MC/AVR/inst-wdr.s | 4 +- llvm/test/MC/AVR/inst-xch.s | 4 +- llvm/test/MC/AVR/modifiers.s | 14 + llvm/test/MC/AVR/registers.s | 2 +- llvm/test/MC/AVR/relocations-abs.s | 2 +- llvm/test/MC/AVR/relocations.s | 1 - llvm/test/MC/AVR/separator.s | 3 +- llvm/test/MC/AVR/syntax-reg-int-literal.s | 1 + llvm/test/MC/AVR/syntax-reg-pair.s | 1 + .../Disassembler/AMDGPU/gfx11_dasm_vop1.txt | 65 +- .../AMDGPU/gfx11_dasm_vop1_dpp16.txt | 96 +- .../AMDGPU/gfx11_dasm_vop1_dpp8.txt | 32 +- .../gfx11_dasm_vop3_dpp16_from_vop1.txt | 92 +- .../AMDGPU/gfx11_dasm_vop3_dpp8_from_vop1.txt | 32 +- .../AMDGPU/gfx11_dasm_vop3_from_vop1.txt | 59 +- .../AMDGPU/gfx12_dasm_vop1_dpp16.txt | 108 +- .../AMDGPU/gfx12_dasm_vop1_dpp8.txt | 28 +- .../AMDGPU/gfx12_dasm_vop3_from_vop1.txt | 59 +- .../gfx12_dasm_vop3_from_vop1_dpp16.txt | 92 +- .../AMDGPU/gfx12_dasm_vop3_from_vop1_dpp8.txt | 32 +- .../test/MC/Disassembler/WebAssembly/wasm.txt | 7 - .../MC/Disassembler/X86/avx10.2-bf16-32.txt | 3015 ----- .../MC/Disassembler/X86/avx10.2-bf16-64.txt | 3015 ----- .../MC/Disassembler/X86/avx10.2-com-ef-32.txt | 195 - .../MC/Disassembler/X86/avx10.2-com-ef-64.txt | 195 - .../MC/Disassembler/X86/avx10.2-copy-32.txt | 34 - .../MC/Disassembler/X86/avx10.2-copy-64.txt | 34 - .../Disassembler/X86/avx10.2-satcvtds-32.txt | 1043 -- .../Disassembler/X86/avx10.2-satcvtds-64.txt | 1171 -- .../test/MC/Mips/cnmips/invalid-wrong-error.s | 10 +- .../MC/Mips/eva/invalid-noeva-wrong-error.s | 100 +- llvm/test/MC/Mips/eva/invalid_R6.s | 24 +- .../Mips/micromips32r6/invalid-wrong-error.s | 11 +- .../MC/Mips/mips1/invalid-mips2-wrong-error.s | 20 +- .../MC/Mips/mips1/invalid-mips3-wrong-error.s | 26 +- llvm/test/MC/Mips/mips1/invalid-mips3.s | 4 +- .../MC/Mips/mips1/invalid-mips4-wrong-error.s | 26 +- llvm/test/MC/Mips/mips1/invalid-mips4.s | 4 +- llvm/test/MC/Mips/mips1/invalid-mips5.s | 4 +- .../MC/Mips/mips2/invalid-mips3-wrong-error.s | 12 +- llvm/test/MC/Mips/mips2/invalid-mips3.s | 6 +- .../MC/Mips/mips2/invalid-mips4-wrong-error.s | 10 +- llvm/test/MC/Mips/mips2/invalid-mips4.s | 2 +- .../Mips/mips32r6/invalid-mips1-wrong-error.s | 14 +- .../Mips/mips64r6/invalid-mips1-wrong-error.s | 12 +- .../Mips/mips64r6/invalid-mips3-wrong-error.s | 16 +- llvm/test/MC/Mips/target-soft-float.s | 12 +- llvm/test/MC/RISCV/corev/XCValu-valid.s | 32 +- llvm/test/MC/RISCV/csr-aliases.s | 26 +- llvm/test/MC/RISCV/fp-default-rounding-mode.s | 5 +- llvm/test/MC/RISCV/rv32ih-aliases-valid.s | 30 +- llvm/test/MC/RISCV/rv32zdinx-invalid.s | 8 +- llvm/test/MC/RISCV/rv32zfbfmin-valid.s | 5 +- llvm/test/MC/RISCV/rv32zfinx-invalid.s | 7 +- llvm/test/MC/RISCV/rvf-aliases-valid.s | 3 +- llvm/test/MC/RISCV/rvi-aliases-valid.s | 4 +- llvm/test/MC/RISCV/rvzdinx-aliases-valid.s | 21 - llvm/test/MC/RISCV/rvzfinx-aliases-valid.s | 68 +- llvm/test/MC/RISCV/rvzhinx-aliases-valid.s | 3 - llvm/test/MC/SystemZ/fixups.s | 6 - llvm/test/MC/SystemZ/regs-bad.s | 3 + llvm/test/MC/SystemZ/regs-good.s | 128 - llvm/test/MC/WebAssembly/annotations.s | 75 +- .../MC/WebAssembly/basic-assembly-errors.s | 32 +- llvm/test/MC/WebAssembly/basic-assembly.s | 14 +- llvm/test/MC/WebAssembly/eh-assembly-legacy.s | 99 - llvm/test/MC/WebAssembly/eh-assembly.s | 157 - llvm/test/MC/WebAssembly/func-end-errors.s | 10 +- llvm/test/MC/WebAssembly/funcref-from-table.s | 2 +- llvm/test/MC/WebAssembly/type-checker-br.s | 2 +- .../test/MC/WebAssembly/type-checker-errors.s | 18 +- llvm/test/MC/X86/avx10.2-bf16-32-att.s | 3014 ----- llvm/test/MC/X86/avx10.2-bf16-32-intel.s | 3014 ----- llvm/test/MC/X86/avx10.2-bf16-64-att.s | 3014 ----- llvm/test/MC/X86/avx10.2-bf16-64-intel.s | 3014 ----- llvm/test/MC/X86/avx10.2-com-ef-32-att.s | 194 - llvm/test/MC/X86/avx10.2-com-ef-32-intel.s | 194 - llvm/test/MC/X86/avx10.2-com-ef-64-att.s | 194 - llvm/test/MC/X86/avx10.2-com-ef-64-intel.s | 194 - llvm/test/MC/X86/avx10.2-copy-32-att.s | 82 - llvm/test/MC/X86/avx10.2-copy-32-intel.s | 81 - llvm/test/MC/X86/avx10.2-copy-64-att.s | 97 - llvm/test/MC/X86/avx10.2-copy-64-intel.s | 97 - llvm/test/MC/X86/avx10_2satcvtds-32-att.s | 1042 -- llvm/test/MC/X86/avx10_2satcvtds-32-intel.s | 1042 -- llvm/test/MC/X86/avx10_2satcvtds-64-att.s | 1170 -- llvm/test/MC/X86/avx10_2satcvtds-64-intel.s | 1170 -- llvm/test/MC/X86/x86_long_nop.s | 2 - .../AMDGPU/fix-illegal-vector-copies.mir | 59 - .../test/MachineVerifier/AMDGPU/lit.local.cfg | 2 - .../register-killed-inside-loop.mir | 1 + .../{AMDGPU => }/test_g_bitcast.mir | 1 + .../test_g_extract_subvector.mir | 35 +- .../test_g_insert_subvector.mir | 29 +- .../{AMDGPU => }/test_g_intrinsic.mir | 1 + .../test_g_intrinsic_w_side_effects.mir | 1 + ...ndef-should-only-be-set-on-subreg-defs.mir | 1 + .../undef-virt-reg-entry-block.mir | 1 + .../undef-virt-reg-nonentry-block.mir | 1 + .../verifier-ec-subreg-liveness.mir | 1 + ...licit-virtreg-invalid-physreg-liveness.mir | 1 + .../verifier-pseudo-terminators.mir | 1 + .../{AMDGPU => }/verify-implicit-def.mir | 1 + .../{AMDGPU => }/verify-reg-sequence.mir | 1 + .../{AMDGPU => }/writelane_m0.mir | 2 + llvm/test/Other/new-pm-defaults.ll | 1 - .../Other/new-pm-thinlto-postlink-defaults.ll | 1 - .../new-pm-thinlto-postlink-pgo-defaults.ll | 1 - ...-pm-thinlto-postlink-samplepgo-defaults.ll | 2 - .../new-pm-thinlto-prelink-pgo-defaults.ll | 1 - ...w-pm-thinlto-prelink-samplepgo-defaults.ll | 1 - llvm/test/Other/spirv-sim/branch.spv | 42 - llvm/test/Other/spirv-sim/call.spv | 36 - llvm/test/Other/spirv-sim/constant.spv | 36 - llvm/test/Other/spirv-sim/lit.local.cfg | 8 - llvm/test/Other/spirv-sim/loop.spv | 58 - .../Other/spirv-sim/simple-bad-result.spv | 26 - llvm/test/Other/spirv-sim/simple.spv | 22 - llvm/test/Other/spirv-sim/simulator-args.spv | 36 - llvm/test/Other/spirv-sim/switch.spv | 42 - .../Other/spirv-sim/wave-get-lane-index.spv | 30 - .../Other/spirv-sim/wave-read-lane-first.spv | 83 - .../match-table-imms.td | 2 +- .../GlobalISelCombinerEmitter/match-table.td | 54 +- llvm/test/TableGen/GlobalISelEmitter.td | 2 +- llvm/test/TableGen/directive1.td | 19 +- llvm/test/TableGen/directive2.td | 15 +- llvm/test/TableGen/intrinsic-attrs.td | 52 +- .../test/TableGen/intrinsic-duplicate-name.td | 9 - llvm/test/TableGen/intrinsic-long-name.td | 36 +- llvm/test/TableGen/intrinsic-prefix-error.td | 14 - llvm/test/TableGen/intrinsic-struct.td | 50 +- .../TableGen/searchabletables-intrinsic.td | 37 +- llvm/test/TableGen/x86-fold-tables.inc | 814 +- llvm/test/ThinLTO/X86/ctxprof.ll | 25 +- llvm/test/ThinLTO/X86/function_entry_count.ll | 45 + .../Attributor/ArgumentPromotion/byval.ll | 8 +- .../IPConstantProp/2009-09-24-byval-ptr.ll | 8 +- .../Attributor/IPConstantProp/PR26044.ll | 34 +- .../Attributor/IPConstantProp/pthreads.ll | 8 +- .../IPConstantProp/return-constants.ll | 12 +- llvm/test/Transforms/Attributor/align.ll | 34 +- .../Transforms/Attributor/assumes_info.ll | 2 - .../Attributor/cb_liveness_disabled.ll | 1 - .../Attributor/cb_liveness_enabled.ll | 1 - .../Transforms/Attributor/memory_locations.ll | 2 +- .../Attributor/phi_bug_pointer_info.ll | 26 - llvm/test/Transforms/Attributor/range.ll | 2 +- .../read_write_returned_arguments_scc.ll | 28 +- llvm/test/Transforms/Attributor/returned.ll | 112 +- .../Attributor/value-simplify-local-remote.ll | 47 +- .../Attributor/value-simplify-pointer-info.ll | 215 - .../monotonic-pointer-phis-chain-of-exits.ll | 340 - .../Transforms/Coroutines/coro-split-00.ll | 15 - .../Coroutines/coro-transform-must-elide.ll | 75 - .../Coroutines/gh107139-split-in-scc.ll | 38 - .../Transforms/Coroutines/swift-async-dbg.ll | 20 +- .../CorrelatedValuePropagation/add.ll | 2 +- .../CorrelatedValuePropagation/ashr.ll | 8 +- .../CorrelatedValuePropagation/basic.ll | 18 +- .../cond-using-block-value.ll | 2 +- .../CorrelatedValuePropagation/select.ll | 4 +- .../CorrelatedValuePropagation/vectors.ll | 32 +- .../EarlyCSE/materialize-align-assumptions.ll | 100 - .../discover-transitive-phis.ll | 2 +- .../rewrite-loop-exit-values-phi.ll | 13 +- .../Transforms/InferFunctionAttrs/annotate.ll | 19 - ...-intrinsic-comb-no-active-lanes-to-zero.ll | 232 - .../InstCombine/AArch64/sve-intrinsic-sdiv.ll | 23 - .../InstCombine/AMDGPU/amdgcn-intrinsics.ll | 79 - .../InstCombine/ARM/neon-intrinsics.ll | 68 +- llvm/test/Transforms/InstCombine/ashr-lshr.ll | 203 - .../Transforms/InstCombine/assume-align.ll | 51 +- llvm/test/Transforms/InstCombine/bitcast.ll | 23 - llvm/test/Transforms/InstCombine/cttz.ll | 21 - llvm/test/Transforms/InstCombine/fmod.ll | 140 - .../Transforms/InstCombine/fp-floor-ceil.ll | 260 - .../Transforms/InstCombine/getelementptr.ll | 114 - .../Transforms/InstCombine/icmp-shl-nuw.ll | 106 - llvm/test/Transforms/InstCombine/icmp.ll | 39 - .../InstCombine/phi-select-constant.ll | 8 +- ...phi-with-multiple-unsimplifiable-values.ll | 135 - llvm/test/Transforms/InstCombine/phi.ll | 51 - llvm/test/Transforms/InstCombine/pow-1.ll | 36 - llvm/test/Transforms/InstCombine/rem.ll | 135 - llvm/test/Transforms/JumpThreading/pr22086.ll | 12 +- llvm/test/Transforms/LICM/hoist-binop.ll | 292 +- llvm/test/Transforms/LICM/hoist-deref-load.ll | 81 +- llvm/test/Transforms/LICM/sink-foldable.ll | 3 +- .../LICM/update-scev-after-hoist.ll | 34 +- llvm/test/Transforms/LoopDeletion/noalias.ll | 28 - .../LoopIdiom/LoongArch/lit.local.cfg | 2 - .../Transforms/LoopIdiom/LoongArch/popcnt.ll | 320 - .../2011-10-03-CritEdgeMerge.ll | 19 +- .../AMDGPU/lsr-invalid-ptr-extend.ll | 2 +- .../AMDGPU/preserve-addrspace-assert.ll | 68 +- .../ARM/illegal-addr-modes.ll | 8 +- .../X86/2011-11-29-postincphi.ll | 11 +- .../X86/expander-crashes.ll | 2 +- .../X86/missing-phi-operand-update.ll | 25 +- .../LoopStrengthReduce/duplicated-phis.ll | 86 - .../Transforms/LoopUnroll/X86/call-remark.ll | 1 - .../X86/runtime-unroll-addrec-cost.ll | 91 +- .../Transforms/LoopUnroll/unroll-cleanup.ll | 121 +- .../LoopVectorize/AArch64/call-costs.ll | 241 - .../AArch64/clamped-trip-count.ll | 8 +- .../AArch64/conditional-branches-cost.ll | 295 +- .../AArch64/divs-with-scalable-vfs.ll | 12 +- .../extractvalue-no-scalarization-required.ll | 54 +- .../AArch64/force-target-instruction-cost.ll | 461 - .../LoopVectorize/AArch64/induction-costs.ll | 2 +- .../AArch64/interleaved-vs-scalar.ll | 4 +- .../LoopVectorize/AArch64/interleaved_cost.ll | 4 +- .../AArch64/mul-simplification.ll | 64 - .../AArch64/outer_loop_prefer_scalable.ll | 4 +- .../AArch64/pr60831-sve-inv-store-crash.ll | 2 +- .../AArch64/reduction-recurrence-costs-sve.ll | 40 +- .../AArch64/scalable-avoid-scalarization.ll | 4 +- .../LoopVectorize/AArch64/scalable-call.ll | 4 +- .../AArch64/scalable-reduction-inloop-cond.ll | 4 +- .../AArch64/scalable-reductions.ll | 4 +- .../LoopVectorize/AArch64/store-costs-sve.ll | 6 +- .../AArch64/sve-cond-inv-loads.ll | 6 +- .../AArch64/sve-gather-scatter.ll | 3 +- .../AArch64/sve-inductions-unusual-types.ll | 12 +- .../LoopVectorize/AArch64/sve-inductions.ll | 4 +- .../AArch64/sve-interleaved-accesses.ll | 44 +- .../sve-interleaved-masked-accesses.ll | 24 +- .../LoopVectorize/AArch64/sve-inv-loads.ll | 4 +- .../AArch64/sve-tail-folding-option.ll | 14 +- .../LoopVectorize/AArch64/sve-tail-folding.ll | 4 +- .../AArch64/sve-widen-extractvalue.ll | 2 +- .../LoopVectorize/AArch64/sve-widen-gep.ll | 72 +- .../LoopVectorize/AArch64/sve-widen-phi.ll | 16 +- .../LoopVectorize/AMDGPU/packed-math.ll | 4 +- .../LoopVectorize/ARM/mve-interleaved-cost.ll | 696 +- .../ARM/mve-reduction-predselect.ll | 2 +- .../LoopVectorize/ARM/mve-reduction-types.ll | 2 +- .../LoopVectorize/ARM/mve-selectandorcost.ll | 2 +- .../Transforms/LoopVectorize/ARM/sphinx.ll | 2 +- .../PowerPC/vplan-force-tail-with-evl.ll | 3 +- .../PowerPC/widened-massv-call.ll | 2 +- .../PowerPC/widened-massv-vfabi-attr.ll | 2 +- .../RISCV/blocks-with-dead-instructions.ll | 28 +- .../LoopVectorize/RISCV/dead-ops-cost.ll | 183 +- .../Transforms/LoopVectorize/RISCV/divrem.ll | 12 +- .../LoopVectorize/RISCV/induction-costs.ll | 4 +- .../LoopVectorize/RISCV/inloop-reduction.ll | 61 - .../LoopVectorize/RISCV/mask-index-type.ll | 4 +- .../RISCV/masked_gather_scatter.ll | 8 +- ...ruction-or-drop-poison-generating-flags.ll | 4 +- .../Transforms/LoopVectorize/RISCV/pr88802.ll | 4 +- .../LoopVectorize/RISCV/reg-usage-bf16.ll | 32 - .../LoopVectorize/RISCV/reg-usage-f16.ll | 38 - .../RISCV/riscv-vector-reverse.ll | 4 - .../RISCV/scalable-reductions.ll | 4 +- .../LoopVectorize/RISCV/strided-accesses.ll | 32 +- .../truncate-to-minimal-bitwidth-cost.ll | 140 - .../LoopVectorize/RISCV/uniform-load-store.ll | 22 +- ...-force-tail-with-evl-bin-unary-ops-args.ll | 1763 --- ...rize-force-tail-with-evl-cond-reduction.ll | 12 +- ...ze-force-tail-with-evl-inloop-reduction.ll | 4 +- ...ectorize-force-tail-with-evl-interleave.ll | 9 +- ...ze-force-tail-with-evl-masked-loadstore.ll | 60 +- ...-force-tail-with-evl-reverse-load-store.ll | 148 +- .../RISCV/vectorize-vp-intrinsics.ll | 22 +- .../RISCV/vplan-vp-intrinsics-reduction.ll | 9 +- .../RISCV/vplan-vp-intrinsics.ll | 2 +- .../SystemZ/mem-interleaving-costs-03.ll | 3 +- .../LoopVectorize/SystemZ/pr47665.ll | 2 +- .../LoopVectorize/X86/amdlibm-calls.ll | 58 +- .../LoopVectorize/X86/cost-model.ll | 145 +- .../X86/divs-with-tail-folding.ll | 2 +- .../X86/fixed-order-recurrence.ll | 56 +- .../X86/imprecise-through-phis.ll | 4 +- .../X86/invariant-load-gather.ll | 4 +- .../LoopVectorize/X86/reduction-fastmath.ll | 2 +- .../LoopVectorize/X86/uniform_mem_op.ll | 6 +- .../X86/vectorization-remarks-missed.ll | 10 +- .../LoopVectorize/blend-in-header.ll | 2 +- .../LoopVectorize/check-no-vectorize.ll | 32 - .../Transforms/LoopVectorize/control-flow.ll | 2 +- .../epilog-vectorization-reductions.ll | 4 +- ...t-order-recurrence-multiply-recurrences.ll | 39 - ...-order-recurrence-sink-replicate-region.ll | 22 +- .../LoopVectorize/first-order-recurrence.ll | 402 +- .../Transforms/LoopVectorize/icmp-uniforms.ll | 3 +- .../Transforms/LoopVectorize/induction.ll | 10 +- .../LoopVectorize/interleaved-accesses.ll | 2 +- .../Transforms/LoopVectorize/is_fpclass.ll | 9 +- .../Transforms/LoopVectorize/opaque-ptr.ll | 99 +- .../LoopVectorize/outer_loop_scalable.ll | 4 +- .../LoopVectorize/pointer-induction.ll | 32 +- llvm/test/Transforms/LoopVectorize/pr36983.ll | 4 +- llvm/test/Transforms/LoopVectorize/pr45259.ll | 5 +- .../pr55167-fold-tail-live-out.ll | 6 +- .../LoopVectorize/reduction-inloop-cond.ll | 4 +- .../LoopVectorize/reduction-inloop-pred.ll | 2 +- .../LoopVectorize/reduction-inloop-uf4.ll | 12 +- .../LoopVectorize/reduction-inloop.ll | 2 +- .../LoopVectorize/reduction-predselect.ll | 2 +- .../Transforms/LoopVectorize/reduction.ll | 2 +- .../LoopVectorize/remarks-multi-exit-loops.ll | 2 +- .../runtime-checks-difference.ll | 50 +- .../scalable-first-order-recurrence.ll | 1 + .../LoopVectorize/scalable-inductions.ll | 14 +- .../scalable-trunc-min-bitwidth.ll | 2 +- .../LoopVectorize/scev-predicate-reasoning.ll | 6 +- .../Transforms/LoopVectorize/select-cmp.ll | 4 +- .../LoopVectorize/simple_early_exit.ll | 1942 --- .../LoopVectorize/skeleton-lcssa-crash.ll | 2 +- .../trip-count-expansion-may-introduce-ub.ll | 392 +- .../LoopVectorize/trunc-extended-icmps.ll | 2 +- .../LoopVectorize/trunc-loads-p16.ll | 2 +- .../Transforms/LoopVectorize/trunc-shifts.ll | 6 +- .../LoopVectorize/use-iv-start-value.ll | 74 - .../Transforms/LoopVectorize/vector-freeze.ll | 3 +- .../Transforms/LoopVectorize/vector-geps.ll | 6 +- .../vector-intrinsic-call-cost.ll | 11 +- .../LoopVectorize/vector-to-scalar-cast.ll | 40 - .../version-stride-with-integer-casts.ll | 11 +- .../LoopVectorize/vplan-iv-transforms.ll | 3 +- .../vplan-printing-before-execute.ll | 2 - .../LoopVectorize/vplan-printing.ll | 111 +- .../vplan-sink-scalars-and-merge.ll | 32 +- .../widen-gep-all-indices-invariant.ll | 6 +- llvm/test/Transforms/MemCpyOpt/memcpy.ll | 51 +- .../OpenMP/replace_globalization.ll | 4 +- .../PGOProfile/ctx-instrumentation.ll | 21 - .../PGOProfile/ctx-prof-use-prelink.ll | 1 - .../PhaseOrdering/X86/vector-reductions.ll | 4 +- .../icmp-ashr-breaking-select-idiom.ll | 4 +- llvm/test/Transforms/SCCP/exact-flags.ll | 4 +- .../Transforms/SCCP/ip-add-range-to-call.ll | 4 +- .../Transforms/SCCP/ip-constant-ranges.ll | 16 +- llvm/test/Transforms/SCCP/ip-ranges-casts.ll | 14 +- llvm/test/Transforms/SCCP/ip-ranges-phis.ll | 6 +- llvm/test/Transforms/SCCP/ip-ranges-select.ll | 4 +- llvm/test/Transforms/SCCP/loadtest2.ll | 8 +- llvm/test/Transforms/SCCP/musttail-call.ll | 2 +- llvm/test/Transforms/SCCP/phis.ll | 4 +- llvm/test/Transforms/SCCP/pointer-nonnull.ll | 44 +- .../SCCP/resolvedundefsin-tracked-fn.ll | 4 +- llvm/test/Transforms/SCCP/select.ll | 36 +- llvm/test/Transforms/SCCP/switch.ll | 2 +- llvm/test/Transforms/SCCP/widening.ll | 8 +- ...ccelerate-vector-functions-inseltpoison.ll | 72 +- .../AArch64/accelerate-vector-functions.ll | 72 +- .../SLPVectorizer/AArch64/reduce-fadd.ll | 865 -- .../AArch64/vec3-reorder-reshuffle.ll | 15 +- .../SLPVectorizer/AMDGPU/reduction.ll | 10 +- .../SLPVectorizer/RISCV/complex-loads.ll | 214 +- .../{ => RISCV}/reduction-whole-regs-loads.ll | 17 +- .../SLPVectorizer/RISCV/vec3-base.ll | 143 +- .../SLPVectorizer/X86/arith-scmp.ll | 646 - .../SLPVectorizer/X86/arith-ucmp.ll | 681 - .../buildvector-postpone-for-dependency.ll | 46 - .../SLPVectorizer/X86/dot-product.ll | 4 +- .../X86/extractelements-vector-ops-shuffle.ll | 2 +- .../SLPVectorizer/X86/horizontal-list.ll | 52 +- .../SLPVectorizer/X86/horizontal.ll | 20 +- .../X86/minbitwidth-user-not-min.ll | 2 +- .../X86/minbw-user-non-sizable.ll | 31 - .../X86/multi-extracts-bv-combined.ll | 38 - .../X86/multi-tracked-reduced-value.ll | 47 - .../X86/phi-node-reshuffled-part.ll | 54 - .../Transforms/SLPVectorizer/X86/pr63668.ll | 1 - ...duced-val-extracted-and-externally-used.ll | 68 - .../X86/redux-feed-buildvector.ll | 4 +- .../X86/redux-feed-insertelement.ll | 2 +- .../X86/reverse_extract_elements.ll | 8 +- .../SLPVectorizer/X86/slp-fma-loss.ll | 4 +- .../SLPVectorizer/X86/trunc-node-reused.ll | 74 - .../X86/vec3-reorder-reshuffle.ll | 9 +- .../Transforms/SLPVectorizer/empty-struct.ll | 14 - .../SLPVectorizer/revec-shufflevector.ll | 37 +- llvm/test/Transforms/SLPVectorizer/revec.ll | 4 +- ...seudo-probe-stale-profile-toplev-func.prof | 23 - .../pseudo-probe-stale-profile-toplev-func.ll | 169 - .../X86/no_implicit_float.ll | 23 - .../SandboxVectorizer/boilerplate.ll | 11 - .../default_pass_pipeline.ll | 11 - .../SandboxVectorizer/user_pass_pipeline.ll | 12 - .../SimplifyCFG/UnreachableEliminate.ll | 274 - .../X86/hoist-loads-stores-with-cf.ll | 74 +- .../SimplifyCFG/patchpoint-invalid-sink.ll | 35 - .../SimplifyCFG/sink-and-convert-switch.ll | 101 - .../SimplifyCFG/speculate-derefable-load.ll | 189 - .../switch-branch-fold-indirectbr-102351.ll | 104 - .../SyntheticCountsPropagation/initial.ll | 79 + .../SyntheticCountsPropagation/prop.ll | 50 + .../SyntheticCountsPropagation/scc.ll | 19 + llvm/test/Transforms/Util/assume-builder.ll | 42 +- .../VectorCombine/AArch64/shrink-types.ll | 116 - .../RISCV/shuffle-of-intrinsics.ll | 82 - .../X86/shuffle-of-intrinsics.ll | 98 - llvm/test/Unit/lit.cfg.py | 1 - .../Verifier/AMDGPU/intrinsic-prefetch.ll | 8 - llvm/test/Verifier/intrinsic-immarg.ll | 31 - llvm/test/Verifier/rtsan-attrs.ll | 9 - llvm/test/lit.cfg.py | 2 +- .../Inputs/lanai_isel.ll.expected | 4 +- llvm/test/tools/dxil-dis/metadata.ll | 10 +- llvm/test/tools/llc/new-pm/pipeline.mir | 2 +- llvm/test/tools/llc/new-pm/verify.mir | 2 +- .../llvm-dwp/X86/cu_tu_units_manual_v4.s | 2 +- .../llvm-dwp/X86/cu_tu_units_manual_v5.s | 2 +- .../X86/cu_tu_units_manual_v5_invalid.s | 2 +- llvm/test/tools/llvm-dwp/X86/debug_macro_v5.s | 2 +- llvm/test/tools/llvm-dwp/X86/type_dedup.test | 4 +- .../llvm-mca/AArch64/Neoverse/N2-writeback.s | 50 +- .../AArch64/Neoverse/N3-basic-instructions.s | 3725 ----- .../AArch64/Neoverse/N3-mte-instructions.s | 350 - .../AArch64/Neoverse/N3-neon-instructions.s | 3236 ----- .../AArch64/Neoverse/N3-sve-instructions.s | 10262 -------------- .../llvm-mca/AArch64/Neoverse/N3-writeback.s | 5321 -------- .../llvm-mca/RISCV/SyntacoreSCR/SCR7-ALU.s | 65 - .../RISCV/SyntacoreSCR/SCR7-FPALU_D.s | 75 - .../RISCV/SyntacoreSCR/SCR7-FPALU_S.s | 75 - .../llvm-mca/RISCV/SyntacoreSCR/SCR7-LSU.s | 53 - .../partially-overlapping-group-resources.s | 91 - .../llvm-mca/X86/Znver4/resources-avx512.s | 26 +- .../llvm-mca/X86/Znver4/resources-avx512bw.s | 18 +- .../tools/llvm-mca/X86/Znver4/zero-idioms.s | 714 +- .../tools/llvm-ml/rip_relative_addressing.asm | 12 +- llvm/test/tools/llvm-ml/run.asm | 1 - .../BPF/interleaved-source-test.ll | 4 +- .../address-taken-externalize-with-call.ll | 36 +- .../AMDGPU/address-taken-externalize.ll | 2 +- .../llvm-split/AMDGPU/debug-name-hiding.ll | 20 + .../AMDGPU/debug-non-kernel-root.ll | 36 + .../tools/llvm-split/AMDGPU/declarations.ll | 9 +- .../AMDGPU/kernels-alias-dependencies.ll | 18 +- .../llvm-split/AMDGPU/kernels-cost-ranking.ll | 12 +- .../AMDGPU/kernels-dependency-external.ll | 33 +- .../AMDGPU/kernels-dependency-indirect.ll | 30 +- .../AMDGPU/kernels-dependency-overridable.ll | 28 +- .../kernels-global-variables-noexternal.ll | 12 +- .../AMDGPU/kernels-global-variables.ll | 12 +- .../AMDGPU/large-kernels-merging.ll | 26 +- .../AMDGPU/non-kernels-dependency-indirect.ll | 30 +- .../llvm-split/AMDGPU/recursive-search-2.ll | 125 - .../llvm-split/AMDGPU/recursive-search-8.ll | 124 - .../tools/llvm-tli-checker/ps4-tli-check.yaml | 32 +- llvm/tools/dsymutil/MachODebugMapParser.cpp | 2 +- llvm/tools/dsymutil/Options.td | 14 +- llvm/tools/dxil-dis/CMakeLists.txt | 4 +- llvm/tools/llc/NewPMDriver.cpp | 12 +- llvm/tools/llc/NewPMDriver.h | 4 +- llvm/tools/llc/llc.cpp | 15 +- llvm/tools/lli/lli.cpp | 1 + llvm/tools/llvm-as/CMakeLists.txt | 2 - llvm/tools/llvm-as/llvm-as.cpp | 5 +- llvm/tools/llvm-cat/llvm-cat.cpp | 2 +- .../llvm-debuginfo-analyzer.cpp | 2 +- .../tools/llvm-debuginfod-find/CMakeLists.txt | 12 +- llvm/tools/llvm-debuginfod-find/Opts.td | 17 - .../llvm-debuginfod-find.cpp | 109 +- llvm/tools/llvm-dis/llvm-dis.cpp | 18 +- llvm/tools/llvm-dwarfdump/Statistics.cpp | 4 +- llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp | 4 +- .../llvm-exegesis/lib/BenchmarkResult.cpp | 50 +- llvm/tools/llvm-exegesis/lib/LlvmState.cpp | 12 +- llvm/tools/llvm-exegesis/lib/LlvmState.h | 11 +- llvm/tools/llvm-exegesis/lib/SnippetFile.cpp | 28 +- .../llvm-libtool-darwin.cpp | 2 +- llvm/tools/llvm-link/CMakeLists.txt | 2 - llvm/tools/llvm-lipo/llvm-lipo.cpp | 4 +- llvm/tools/llvm-ml/Opts.td | 1 - llvm/tools/llvm-objdump/SourcePrinter.cpp | 2 +- llvm/tools/llvm-profdata/CMakeLists.txt | 4 - llvm/tools/llvm-profdata/llvm-profdata.cpp | 69 +- llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp | 14 +- llvm/tools/llvm-readobj/ELFDumper.cpp | 42 +- .../llvm-reduce/deltas/ReduceOpcodes.cpp | 2 +- llvm/tools/llvm-shlib/CMakeLists.txt | 33 +- llvm/tools/llvm-size/llvm-size.cpp | 31 +- llvm/tools/llvm-xray/xray-graph.cpp | 2 +- llvm/tools/lto/lto.cpp | 9 +- llvm/tools/opt/CMakeLists.txt | 3 +- llvm/tools/opt/NewPMDriver.cpp | 6 +- llvm/tools/opt/NewPMDriver.h | 2 +- llvm/tools/opt/optdriver.cpp | 7 +- llvm/tools/spirv-tools/CMakeLists.txt | 16 +- llvm/unittests/ADT/APFloatTest.cpp | 7 +- llvm/unittests/ADT/APIntTest.cpp | 180 +- llvm/unittests/ADT/APSIntTest.cpp | 8 +- llvm/unittests/ADT/Interleave.cpp | 4 +- llvm/unittests/ADT/RewriteBufferTest.cpp | 1 + llvm/unittests/ADT/StringExtrasTest.cpp | 10 +- .../Analysis/AssumeBundleQueriesTest.cpp | 2 +- llvm/unittests/Analysis/CFGTest.cpp | 2 +- llvm/unittests/Analysis/CMakeLists.txt | 7 +- .../Analysis/CtxProfAnalysisTest.cpp | 26 - llvm/unittests/Analysis/DXILResourceTest.cpp | 4 +- llvm/unittests/Analysis/IVDescriptorsTest.cpp | 8 + llvm/unittests/Analysis/LazyCallGraphTest.cpp | 2 +- .../Analysis/ScalarEvolutionTest.cpp | 2 +- .../Analysis/TargetLibraryInfoTest.cpp | 8 +- llvm/unittests/Analysis/ValueTrackingTest.cpp | 4 +- llvm/unittests/Analysis/VectorUtilsTest.cpp | 2 +- llvm/unittests/Bitcode/BitReaderTest.cpp | 2 +- .../CodeGen/GlobalISel/GISelMITest.cpp | 4 +- .../CodeGen/GlobalISel/LegalizerTest.cpp | 2 +- .../GlobalISel/MachineIRBuilderTest.cpp | 25 - llvm/unittests/CodeGen/MachineInstrTest.cpp | 5 +- llvm/unittests/CodeGen/MachineOperandTest.cpp | 42 +- .../CodeGen/SelectionDAGPatternMatchTest.cpp | 4 - .../DebugInfo/DWARF/DWARFDebugFrameTest.cpp | 4 + .../DebugInfo/DWARF/DWARFDebugLineTest.cpp | 2 + .../DebugInfo/DWARF/DWARFDieTest.cpp | 61 - .../DWARFExpressionCompactPrinterTest.cpp | 2 +- .../DebugInfo/DWARF/DWARFFormValueTest.cpp | 1 + llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp | 6 + .../Frontend/OpenMPIRBuilderTest.cpp | 4 - llvm/unittests/IR/AsmWriterTest.cpp | 10 +- llvm/unittests/IR/ConstantRangeTest.cpp | 240 +- llvm/unittests/IR/ConstantsTest.cpp | 1 + llvm/unittests/IR/InstructionsTest.cpp | 14 - llvm/unittests/IR/ManglerTest.cpp | 2 + llvm/unittests/IR/MetadataTest.cpp | 30 +- llvm/unittests/IR/ModuleSummaryIndexTest.cpp | 1 + llvm/unittests/IR/PatternMatch.cpp | 202 +- llvm/unittests/IR/ValueTest.cpp | 8 +- llvm/unittests/IR/VectorTypesTest.cpp | 4 - llvm/unittests/IR/VerifierTest.cpp | 76 +- llvm/unittests/InterfaceStub/ELFYAMLTest.cpp | 2 + llvm/unittests/MC/MCInstPrinter.cpp | 1 + llvm/unittests/MIR/MachineMetadata.cpp | 1 + llvm/unittests/MIR/MachineStableHashTest.cpp | 70 - llvm/unittests/Object/MinidumpTest.cpp | 11 +- llvm/unittests/Object/SymbolicFileTest.cpp | 1 + .../unittests/ObjectYAML/MinidumpYAMLTest.cpp | 61 +- llvm/unittests/Passes/Plugins/CMakeLists.txt | 3 +- llvm/unittests/ProfileData/InstrProfTest.cpp | 1 + llvm/unittests/ProfileData/MemProfTest.cpp | 4 + .../PGOCtxProfReaderWriterTest.cpp | 9 +- llvm/unittests/SandboxIR/CMakeLists.txt | 1 - llvm/unittests/SandboxIR/PassTest.cpp | 195 - llvm/unittests/SandboxIR/SandboxIRTest.cpp | 1287 +- llvm/unittests/SandboxIR/TrackerTest.cpp | 237 +- llvm/unittests/SandboxIR/TypesTest.cpp | 226 +- llvm/unittests/Support/ARMAttributeParser.cpp | 4 +- .../Support/CSKYAttributeParserTest.cpp | 12 +- llvm/unittests/Support/Chrono.cpp | 4 +- llvm/unittests/Support/CommandLineTest.cpp | 29 +- llvm/unittests/Support/CrashRecoveryTest.cpp | 3 +- .../Support/DivisionByConstantTest.cpp | 2 +- .../Support/DynamicLibrary/CMakeLists.txt | 19 +- llvm/unittests/Support/ErrorTest.cpp | 16 +- llvm/unittests/Support/FormatVariadicTest.cpp | 117 +- llvm/unittests/Support/JSONTest.cpp | 4 +- llvm/unittests/Support/LEB128Test.cpp | 2 + llvm/unittests/Support/ModRefTest.cpp | 1 + llvm/unittests/Support/NativeFormatTests.cpp | 3 + .../Support/RISCVAttributeParserTest.cpp | 4 +- llvm/unittests/Support/ScopedPrinterTest.cpp | 14 +- llvm/unittests/Support/SourceMgrTest.cpp | 1 + .../Support/VirtualFileSystemTest.cpp | 118 +- llvm/unittests/Support/WithColorTest.cpp | 6 +- llvm/unittests/Support/YAMLIOTest.cpp | 25 +- llvm/unittests/Support/raw_ostream_test.cpp | 13 - .../AArch64/AArch64SVESchedPseudoTest.cpp | 4 - llvm/unittests/Target/LoongArch/InstSizes.cpp | 15 - .../Target/RISCV/RISCVInstrInfoTest.cpp | 24 +- llvm/unittests/Target/SPIRV/CMakeLists.txt | 2 - llvm/unittests/Target/SPIRV/SPIRVAPITest.cpp | 191 - .../WebAssemblyExceptionInfoTest.cpp | 16 +- llvm/unittests/TargetParser/Host.cpp | 12 - llvm/unittests/TargetParser/TripleTest.cpp | 108 - .../Transforms/Coroutines/ExtraRematTest.cpp | 2 +- .../PGOInstrumentationTest.cpp | 2 +- .../Utils/CallPromotionUtilsTest.cpp | 3 +- .../Transforms/Utils/MemTransferLowering.cpp | 2 +- .../Transforms/Vectorize/CMakeLists.txt | 2 - .../SandboxVectorizer/CMakeLists.txt | 15 - .../SandboxVectorizer/DependencyGraphTest.cpp | 63 - .../SandboxVectorizer/InstrIntervalTest.cpp | 71 - .../SandboxVectorizer/LegalityTest.cpp | 56 - .../SandboxVectorizer/RegionTest.cpp | 81 - .../Transforms/Vectorize/VPlanHCFGTest.cpp | 7 +- .../Transforms/Vectorize/VPlanTest.cpp | 3 + .../Transforms/Vectorize/VPlanTestBase.h | 18 +- .../XRay/FDRProducerConsumerTest.cpp | 4 + llvm/unittests/XRay/FDRRecordPrinterTest.cpp | 5 + llvm/unittests/XRay/FDRRecordsTest.cpp | 1 + llvm/unittests/XRay/FDRTraceWriterTest.cpp | 4 + .../tools/llvm-exegesis/ProgressMeterTest.cpp | 1 + llvm/unittests/tools/llvm-mca/MCATestBase.h | 2 +- llvm/utils/TableGen/ARMTargetDefEmitter.cpp | 30 +- llvm/utils/TableGen/AsmMatcherEmitter.cpp | 311 +- llvm/utils/TableGen/AsmWriterEmitter.cpp | 45 +- llvm/utils/TableGen/Attributes.cpp | 13 +- llvm/utils/TableGen/Basic/CMakeLists.txt | 2 +- .../TableGen/Basic/CodeGenIntrinsics.cpp | 110 +- llvm/utils/TableGen/Basic/CodeGenIntrinsics.h | 28 +- llvm/utils/TableGen/CTagsEmitter.cpp | 4 +- llvm/utils/TableGen/CallingConvEmitter.cpp | 45 +- llvm/utils/TableGen/CodeEmitterGen.cpp | 83 +- llvm/utils/TableGen/CodeGenMapTable.cpp | 181 +- llvm/utils/TableGen/Common/CMakeLists.txt | 2 +- .../TableGen/Common/CodeGenDAGPatterns.cpp | 160 +- .../TableGen/Common/CodeGenDAGPatterns.h | 102 +- llvm/utils/TableGen/Common/CodeGenHwModes.cpp | 17 +- llvm/utils/TableGen/Common/CodeGenHwModes.h | 20 +- .../TableGen/Common/CodeGenInstAlias.cpp | 17 +- llvm/utils/TableGen/Common/CodeGenInstAlias.h | 21 +- .../TableGen/Common/CodeGenInstruction.cpp | 20 +- .../TableGen/Common/CodeGenInstruction.h | 18 +- .../TableGen/Common/CodeGenRegisters.cpp | 72 +- llvm/utils/TableGen/Common/CodeGenRegisters.h | 46 +- .../utils/TableGen/Common/CodeGenSchedule.cpp | 349 +- llvm/utils/TableGen/Common/CodeGenSchedule.h | 119 +- llvm/utils/TableGen/Common/CodeGenTarget.cpp | 45 +- llvm/utils/TableGen/Common/CodeGenTarget.h | 40 +- llvm/utils/TableGen/Common/DAGISelMatcher.cpp | 192 +- llvm/utils/TableGen/Common/DAGISelMatcher.h | 84 +- .../GlobalISel/GlobalISelMatchTable.cpp | 14 +- .../Common/GlobalISel/GlobalISelMatchTable.h | 21 +- .../GlobalISelMatchTableExecutorEmitter.cpp | 6 +- .../Common/GlobalISel/PatternParser.cpp | 14 +- llvm/utils/TableGen/Common/InfoByHwMode.cpp | 20 +- llvm/utils/TableGen/Common/InfoByHwMode.h | 19 +- llvm/utils/TableGen/Common/OptEmitter.cpp | 81 +- llvm/utils/TableGen/Common/OptEmitter.h | 5 +- .../TableGen/Common/PredicateExpander.cpp | 23 +- .../utils/TableGen/Common/PredicateExpander.h | 13 +- .../TableGen/Common/SubtargetFeatureInfo.cpp | 8 +- .../TableGen/Common/SubtargetFeatureInfo.h | 12 +- llvm/utils/TableGen/Common/Utils.cpp | 2 +- llvm/utils/TableGen/Common/Utils.h | 2 +- .../TableGen/Common/VarLenCodeEmitterGen.cpp | 85 +- .../TableGen/Common/VarLenCodeEmitterGen.h | 2 +- llvm/utils/TableGen/CompressInstEmitter.cpp | 105 +- llvm/utils/TableGen/DAGISelEmitter.cpp | 14 +- llvm/utils/TableGen/DAGISelMatcherEmitter.cpp | 18 +- llvm/utils/TableGen/DAGISelMatcherGen.cpp | 36 +- llvm/utils/TableGen/DAGISelMatcherOpt.cpp | 5 +- llvm/utils/TableGen/DFAEmitter.cpp | 28 +- llvm/utils/TableGen/DFAPacketizerEmitter.cpp | 47 +- llvm/utils/TableGen/DXILEmitter.cpp | 64 +- llvm/utils/TableGen/DecoderEmitter.cpp | 269 +- llvm/utils/TableGen/DirectiveEmitter.cpp | 262 +- llvm/utils/TableGen/DisassemblerEmitter.cpp | 14 +- llvm/utils/TableGen/ExegesisEmitter.cpp | 15 +- llvm/utils/TableGen/FastISelEmitter.cpp | 23 +- .../TableGen/GlobalISelCombinerEmitter.cpp | 71 +- llvm/utils/TableGen/GlobalISelEmitter.cpp | 42 +- llvm/utils/TableGen/InstrDocsEmitter.cpp | 22 +- llvm/utils/TableGen/InstrInfoEmitter.cpp | 73 +- llvm/utils/TableGen/IntrinsicEmitter.cpp | 303 +- .../TableGen/MacroFusionPredicatorEmitter.cpp | 58 +- llvm/utils/TableGen/OptParserEmitter.cpp | 8 +- llvm/utils/TableGen/OptRSTEmitter.cpp | 30 +- llvm/utils/TableGen/PseudoLoweringEmitter.cpp | 56 +- llvm/utils/TableGen/RISCVTargetDefEmitter.cpp | 27 +- llvm/utils/TableGen/RegisterBankEmitter.cpp | 19 +- llvm/utils/TableGen/RegisterInfoEmitter.cpp | 128 +- .../utils/TableGen/SearchableTableEmitter.cpp | 23 +- llvm/utils/TableGen/SubtargetEmitter.cpp | 230 +- llvm/utils/TableGen/TableGen.cpp | 8 +- llvm/utils/TableGen/TableGenBackends.h | 6 +- llvm/utils/TableGen/VTEmitter.cpp | 10 +- .../WebAssemblyDisassemblerEmitter.cpp | 39 +- .../TableGen/WebAssemblyDisassemblerEmitter.h | 3 +- llvm/utils/TableGen/X86FoldTablesEmitter.cpp | 34 +- .../utils/TableGen/X86InstrMappingEmitter.cpp | 33 +- llvm/utils/TableGen/X86ManualFoldTables.def | 38 +- llvm/utils/TableGen/X86ManualInstrMapping.def | 33 +- llvm/utils/TableGen/X86MnemonicTables.cpp | 10 +- llvm/utils/TableGen/X86RecognizableInstr.cpp | 9 +- llvm/utils/count/count.c | 4 +- llvm/utils/git/requirements.txt | 156 +- llvm/utils/git/requirements.txt.in | 3 +- llvm/utils/gn/build/BUILD.gn | 12 +- llvm/utils/gn/build/mac_sdk.gni | 4 - .../utils/gn/build/toolchain/target_flags.gni | 4 +- llvm/utils/gn/secondary/BUILD.gn | 1 + .../clang-tools-extra/clangd/BUILD.gn | 4 + .../clang-tools-extra/clangd/support/BUILD.gn | 4 - .../clang-tools-extra/pseudo/gen/BUILD.gn | 9 + .../clang-tools-extra/pseudo/include/BUILD.gn | 39 + .../clang-tools-extra/pseudo/lib/BUILD.gn | 20 + .../clang-tools-extra/pseudo/lib/cli/BUILD.gn | 11 + .../clang-tools-extra/pseudo/lib/cxx/BUILD.gn | 13 + .../pseudo/lib/grammar/BUILD.gn | 16 + .../clang-tools-extra/pseudo/test/BUILD.gn | 93 + .../test/clang_pseudo_lit_site_cfg_files.gni | 4 + .../clang-tools-extra/pseudo/tool/BUILD.gn | 32 + .../pseudo/unittests/BUILD.gn | 27 + .../secondary/clang-tools-extra/test/BUILD.gn | 1 + .../clang/include/clang/Basic/BUILD.gn | 5 - .../clang/include/clang/Config/BUILD.gn | 2 +- .../gn/secondary/clang/lib/Basic/BUILD.gn | 1 - .../gn/secondary/clang/lib/CodeGen/BUILD.gn | 1 - .../gn/secondary/clang/lib/Headers/BUILD.gn | 6 - .../gn/secondary/clang/lib/Tooling/BUILD.gn | 1 - llvm/utils/gn/secondary/clang/test/BUILD.gn | 1 + .../clang/tools/clang-rename/BUILD.gn | 14 + .../gn/secondary/clang/unittests/AST/BUILD.gn | 1 - .../gn/secondary/clang/unittests/BUILD.gn | 1 + .../secondary/clang/unittests/Rename/BUILD.gn | 28 + .../gn/secondary/compiler-rt/include/BUILD.gn | 1 - .../gn/secondary/compiler-rt/lib/BUILD.gn | 10 +- .../secondary/compiler-rt/lib/asan/BUILD.gn | 54 +- .../compiler-rt/lib/builtins/BUILD.gn | 3 +- .../compiler-rt/lib/sanitizer_common/BUILD.gn | 38 +- .../secondary/compiler-rt/lib/ubsan/BUILD.gn | 23 +- .../gn/secondary/compiler-rt/test/BUILD.gn | 13 +- .../gn/secondary/libcxx/include/BUILD.gn | 12 +- llvm/utils/gn/secondary/lld/test/BUILD.gn | 2 - .../gn/secondary/lldb/source/Target/BUILD.gn | 1 - .../llvm/include/llvm/Config/BUILD.gn | 5 +- .../gn/secondary/llvm/lib/CodeGen/BUILD.gn | 1 - .../llvm/lib/CodeGen/GlobalISel/BUILD.gn | 1 - llvm/utils/gn/secondary/llvm/lib/LTO/BUILD.gn | 1 + .../gn/secondary/llvm/lib/SandboxIR/BUILD.gn | 2 - .../gn/secondary/llvm/lib/Support/BUILD.gn | 1 - .../secondary/llvm/lib/Target/RISCV/BUILD.gn | 14 - .../llvm/lib/Transforms/Coroutines/BUILD.gn | 4 - .../llvm/lib/Transforms/IPO/BUILD.gn | 1 + .../lib/Transforms/Instrumentation/BUILD.gn | 2 +- .../llvm/lib/Transforms/Utils/BUILD.gn | 1 - .../llvm/lib/Transforms/Vectorize/BUILD.gn | 5 - .../llvm/tools/llvm-debuginfod-find/BUILD.gn | 11 +- .../llvm/tools/llvm-profdata/BUILD.gn | 1 - .../gn/secondary/llvm/unittests/BUILD.gn | 1 - .../llvm/unittests/SandboxIR/BUILD.gn | 1 - .../llvm/unittests/Target/SPIRV/BUILD.gn | 5 +- .../Vectorize/SandboxVectorizer/BUILD.gn | 18 - .../gn/secondary/llvm/utils/llvm-lit/BUILD.gn | 11 + llvm/utils/indirect_calls.py | 2 +- llvm/utils/lit/lit/TestRunner.py | 28 +- llvm/utils/lit/lit/TestingConfig.py | 1 - llvm/utils/lit/lit/llvm/config.py | 1 - llvm/utils/lit/lit/run.py | 5 +- llvm/utils/lit/lit/util.py | 5 +- .../Inputs/escape-color/color-escaped.txt | 10 - .../lit/tests/Inputs/escape-color/color.txt | 6 - .../lit/tests/Inputs/escape-color/lit.cfg | 8 - .../Inputs/shtest-glob/example_file1.input | 2 - .../Inputs/shtest-glob/example_file2.input | 2 - .../tests/Inputs/shtest-glob/glob-echo.txt | 2 - .../tests/Inputs/shtest-glob/glob-mkdir.txt | 2 - .../lit/tests/Inputs/shtest-glob/lit.cfg | 8 - llvm/utils/lit/tests/escape-color.py | 4 - llvm/utils/lit/tests/shtest-glob.py | 12 - .../mlgo/corpus/combine_training_corpus.py | 12 - .../mlgo-utils/mlgo/corpus/extract_ir.py | 29 +- .../tests/corpus/extract_ir_test.py | 1 + llvm/utils/release/build_llvm_release.bat | 2 +- llvm/utils/spirv-sim/instructions.py | 381 - llvm/utils/spirv-sim/spirv-sim.py | 658 - llvm/utils/yaml-bench/YAMLBench.cpp | 11 + mlir/cmake/modules/MLIRDetectPythonEnv.cmake | 2 +- mlir/docs/DialectConversion.md | 5 - mlir/docs/Dialects/Affine.md | 2 +- mlir/docs/Dialects/Linalg/OpDSL.md | 4 +- mlir/docs/Dialects/OpenMPDialect/ODS.md | 3 - mlir/docs/Dialects/OpenMPDialect/_index.md | 458 - .../Tutorials/UnderstandingTheIRStructure.md | 9 +- mlir/include/mlir-c/BuiltinAttributes.h | 9 - mlir/include/mlir-c/BuiltinTypes.h | 20 - mlir/include/mlir-c/Dialect/LLVM.h | 28 +- mlir/include/mlir-c/Pass.h | 8 +- mlir/include/mlir/Analysis/Presburger/Utils.h | 50 - mlir/include/mlir/Conversion/Passes.h | 1 - mlir/include/mlir/Conversion/Passes.td | 14 - .../Conversion/VectorToXeGPU/VectorToXeGPU.h | 29 - mlir/include/mlir/Dialect/AMDGPU/IR/AMDGPU.td | 10 +- .../mlir/Dialect/AMDGPU/Transforms/Passes.td | 1 - .../mlir/Dialect/AMDGPU/Utils/Chipset.h | 43 +- .../mlir/Dialect/ArmSME/IR/ArmSMEOps.td | 38 +- .../IR/BufferizableOpInterface.h | 2 +- mlir/include/mlir/Dialect/EmitC/IR/EmitC.td | 2 +- mlir/include/mlir/Dialect/Func/IR/FuncOps.td | 2 +- mlir/include/mlir/Dialect/GPU/IR/GPUOps.td | 32 +- .../mlir/Dialect/GPU/Transforms/Passes.h | 18 +- .../mlir/Dialect/LLVMIR/LLVMAttrDefs.td | 102 +- mlir/include/mlir/Dialect/LLVMIR/LLVMEnums.td | 6 +- .../mlir/Dialect/LLVMIR/LLVMInterfaces.td | 59 +- .../mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td | 4 - .../include/mlir/Dialect/LLVMIR/LLVMOpBase.td | 37 +- mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td | 27 +- mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td | 88 +- mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td | 66 +- .../Dialect/Linalg/IR/LinalgStructuredOps.td | 1 - .../include/mlir/Dialect/Linalg/Utils/Utils.h | 11 +- .../mlir/Dialect/OpenMP/CMakeLists.txt | 1 - .../Dialect/OpenMP/OpenMPClauseOperands.h | 292 +- .../mlir/Dialect/OpenMP/OpenMPClauses.td | 256 +- .../mlir/Dialect/OpenMP/OpenMPOpBase.td | 62 +- mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | 88 +- .../SCF/Transforms/TileUsingInterface.h | 33 +- .../mlir/Dialect/Tosa/IR/CMakeLists.txt | 4 +- .../mlir/Dialect/Tosa/IR/TosaOpBase.td | 10 - mlir/include/mlir/Dialect/Tosa/IR/TosaOps.h | 6 - mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td | 65 +- .../mlir/Dialect/Tosa/IR/TosaTypesBase.td | 64 +- .../mlir/Dialect/Tosa/Transforms/Passes.td | 21 - .../mlir/Dialect/Tosa/Utils/ConversionUtils.h | 150 - .../Dialect/Transform/IR/TransformDialect.h | 11 +- .../include/mlir/Dialect/Transform/IR/Utils.h | 2 +- .../Interfaces/TransformInterfaces.h | 20 +- .../Dialect/Vector/IR/VectorAttributes.td | 28 +- .../mlir/Dialect/Vector/IR/VectorOps.h | 5 + .../mlir/Dialect/Vector/IR/VectorOps.td | 14 +- mlir/include/mlir/IR/Builders.h | 2 - mlir/include/mlir/IR/BuiltinTypes.h | 20 +- mlir/include/mlir/IR/BuiltinTypes.td | 42 - mlir/include/mlir/IR/CommonAttrConstraints.td | 8 - mlir/include/mlir/IR/CommonTypeConstraints.td | 9 +- mlir/include/mlir/IR/OpImplementation.h | 6 - mlir/include/mlir/IR/Types.h | 2 - mlir/include/mlir/Interfaces/CallInterfaces.h | 20 +- .../include/mlir/Interfaces/CallInterfaces.td | 32 +- .../include/mlir/Interfaces/TilingInterface.h | 7 +- mlir/include/mlir/TableGen/CodeGenHelpers.h | 4 +- .../mlir/Transforms/DialectConversion.h | 10 - mlir/lib/Analysis/CallGraph.cpp | 2 +- .../Analysis/DataFlow/DeadCodeAnalysis.cpp | 2 +- mlir/lib/Analysis/DataFlow/DenseAnalysis.cpp | 2 +- mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp | 2 +- .../Analysis/Presburger/IntegerRelation.cpp | 26 +- mlir/lib/Analysis/Presburger/Matrix.cpp | 12 +- mlir/lib/Analysis/Presburger/Simplex.cpp | 11 +- mlir/lib/AsmParser/AsmParserImpl.h | 10 - mlir/lib/AsmParser/Parser.cpp | 7 +- mlir/lib/AsmParser/Parser.h | 8 +- mlir/lib/AsmParser/TokenKinds.def | 2 - mlir/lib/AsmParser/TypeParser.cpp | 8 - mlir/lib/Bindings/Python/IRAttributes.cpp | 26 +- mlir/lib/Bindings/Python/IRTypes.cpp | 44 - mlir/lib/Bindings/Python/Pass.cpp | 13 +- mlir/lib/Bytecode/Reader/BytecodeReader.cpp | 3 +- mlir/lib/CAPI/Dialect/LLVM.cpp | 39 +- mlir/lib/CAPI/IR/BuiltinAttributes.cpp | 9 - mlir/lib/CAPI/IR/BuiltinTypes.cpp | 24 - mlir/lib/CAPI/IR/Pass.cpp | 17 +- .../AMDGPUToROCDL/AMDGPUToROCDL.cpp | 130 +- .../ArithToAMDGPU/ArithToAMDGPU.cpp | 2 +- .../ArithToArmSME/ArithToArmSME.cpp | 6 +- .../Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp | 60 +- .../Conversion/ArmSMEToSCF/ArmSMEToSCF.cpp | 10 +- mlir/lib/Conversion/CMakeLists.txt | 1 - .../GPUCommon/IndexIntrinsicsOpLowering.h | 6 +- .../GPUToNVVM/LowerGpuOpsToNVVMOps.cpp | 54 +- .../GPUToROCDL/LowerGpuOpsToROCDLOps.cpp | 15 +- .../Conversion/LLVMCommon/TypeConverter.cpp | 3 +- .../Conversion/MathToROCDL/MathToROCDL.cpp | 14 +- .../SCFToControlFlow/SCFToControlFlow.cpp | 5 +- .../TensorToSPIRV/TensorToSPIRV.cpp | 2 - .../Conversion/TosaToLinalg/TosaToLinalg.cpp | 39 +- .../TosaToLinalg/TosaToLinalgNamed.cpp | 21 +- .../VectorToArmSME/VectorToArmSME.cpp | 65 +- .../VectorToLLVM/ConvertVectorToLLVM.cpp | 5 +- .../VectorToLLVM/ConvertVectorToLLVMPass.cpp | 2 - .../Conversion/VectorToXeGPU/CMakeLists.txt | 16 - .../VectorToXeGPU/VectorToXeGPU.cpp | 257 - mlir/lib/Debug/Observers/ActionProfiler.cpp | 2 +- mlir/lib/Dialect/AMDGPU/IR/AMDGPUDialect.cpp | 7 +- .../Dialect/AMDGPU/Transforms/CMakeLists.txt | 1 - .../AMDGPU/Transforms/EmulateAtomics.cpp | 41 +- mlir/lib/Dialect/AMDGPU/Utils/Chipset.cpp | 8 +- mlir/lib/Dialect/Affine/IR/AffineOps.cpp | 3 - mlir/lib/Dialect/Affine/Utils/Utils.cpp | 3 +- .../Transforms/EmulateUnsupportedFloats.cpp | 2 - mlir/lib/Dialect/Async/IR/CMakeLists.txt | 1 - .../IR/BufferizableOpInterface.cpp | 3 +- .../Transforms/BufferResultsToOutParams.cpp | 3 +- .../Bufferization/Transforms/CMakeLists.txt | 2 +- .../Transforms/OneShotAnalysis.cpp | 5 +- .../OwnershipBasedBufferDeallocation.cpp | 2 +- mlir/lib/Dialect/Func/IR/FuncOps.cpp | 5 +- mlir/lib/Dialect/GPU/IR/GPUDialect.cpp | 13 +- .../GPU/Transforms/SubgroupReduceLowering.cpp | 131 +- mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp | 72 +- mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp | 39 +- mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp | 5 +- .../Transforms/DIScopeForLLVMFuncOp.cpp | 8 +- mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp | 118 +- .../Linalg/TransformOps/LinalgMatchOps.cpp | 4 +- .../Linalg/Transforms/DropUnitDims.cpp | 7 +- .../Linalg/Transforms/ElementwiseOpFusion.cpp | 2 +- .../Linalg/Transforms/TilingInterfaceImpl.cpp | 26 +- .../Dialect/Linalg/Transforms/Transforms.cpp | 7 +- .../Linalg/Transforms/Vectorization.cpp | 57 +- .../Linalg/Transforms/WinogradConv2D.cpp | 57 +- mlir/lib/Dialect/Linalg/Utils/Utils.cpp | 20 +- .../Transforms/PipelineGlobalOps.cpp | 4 +- mlir/lib/Dialect/Mesh/IR/MeshOps.cpp | 22 - mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp | 6 +- mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp | 36 +- mlir/lib/Dialect/PDL/IR/PDL.cpp | 7 +- mlir/lib/Dialect/SCF/IR/SCF.cpp | 4 +- .../Dialect/SCF/Transforms/ForallToFor.cpp | 2 + .../Dialect/SCF/Transforms/LoopPipelining.cpp | 127 +- .../SCF/Transforms/ParallelLoopFusion.cpp | 2 +- .../SCF/Transforms/TileUsingInterface.cpp | 441 +- .../Transforms/OutlineShapeComputation.cpp | 4 +- .../Dialect/SparseTensor/IR/Detail/Var.cpp | 2 +- .../Transforms/SparseAssembler.cpp | 14 +- mlir/lib/Dialect/Tensor/IR/TensorOps.cpp | 98 +- .../Tensor/IR/TensorTilingInterfaceImpl.cpp | 75 +- .../Transforms/PackAndUnpackPatterns.cpp | 13 +- .../Dialect/Tosa/IR/TosaCanonicalizations.cpp | 64 +- mlir/lib/Dialect/Tosa/IR/TosaOps.cpp | 172 +- .../Dialect/Tosa/Transforms/CMakeLists.txt | 1 - .../Transforms/TosaDecomposeTransposeConv.cpp | 93 +- .../Tosa/Transforms/TosaReduceTransposes.cpp | 693 - .../Dialect/Tosa/Utils/ConversionUtils.cpp | 12 +- mlir/lib/Dialect/Traits.cpp | 2 +- .../DebugExtension/DebugExtensionOps.cpp | 4 +- .../lib/Dialect/Transform/IR/TransformOps.cpp | 6 +- .../Interfaces/TransformInterfaces.cpp | 22 +- mlir/lib/Dialect/Vector/IR/VectorOps.cpp | 78 +- .../Vector/Transforms/VectorLinearize.cpp | 4 - mlir/lib/ExecutionEngine/ExecutionEngine.cpp | 2 +- mlir/lib/IR/AffineExpr.cpp | 5 +- mlir/lib/IR/AsmPrinter.cpp | 12 +- mlir/lib/IR/AttrTypeSubElements.cpp | 6 +- mlir/lib/IR/Builders.cpp | 8 - mlir/lib/IR/BuiltinTypes.cpp | 23 +- mlir/lib/IR/Diagnostics.cpp | 12 +- mlir/lib/IR/MLIRContext.cpp | 10 - mlir/lib/IR/Types.cpp | 2 - mlir/lib/Interfaces/CallInterfaces.cpp | 13 +- mlir/lib/Interfaces/DataLayoutInterfaces.cpp | 2 +- .../RuntimeVerifiableOpInterface.cpp | 2 +- .../lib/Interfaces/ValueBoundsOpInterface.cpp | 3 +- mlir/lib/Pass/Pass.cpp | 11 +- mlir/lib/Pass/PassCrashRecovery.cpp | 4 +- mlir/lib/Query/Matcher/RegistryManager.cpp | 2 +- mlir/lib/Query/QueryParser.cpp | 2 +- mlir/lib/TableGen/CodeGenHelpers.cpp | 14 +- mlir/lib/TableGen/Pattern.cpp | 9 +- mlir/lib/TableGen/Predicate.cpp | 2 +- mlir/lib/Target/LLVM/ModuleToObject.cpp | 2 +- mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp | 2 +- mlir/lib/Target/LLVMIR/DebugImporter.cpp | 18 +- mlir/lib/Target/LLVMIR/DebugTranslation.cpp | 98 +- mlir/lib/Target/LLVMIR/DebugTranslation.h | 18 +- .../LLVMIR/LLVMToLLVMIRTranslation.cpp | 2 +- .../Dialect/NVVM/LLVMIRToNVVMTranslation.cpp | 1 - .../OpenMP/OpenMPToLLVMIRTranslation.cpp | 358 +- .../Target/LLVMIR/Dialect/OpenMPCommon.cpp | 2 +- .../ROCDL/ROCDLToLLVMIRTranslation.cpp | 35 +- mlir/lib/Target/LLVMIR/ModuleImport.cpp | 9 +- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | 3 +- .../SPIRV/Serialization/SerializeOps.cpp | 2 +- .../Target/SPIRV/Serialization/Serializer.cpp | 4 +- mlir/lib/Tools/PDLL/Parser/Parser.cpp | 18 +- .../Tools/lsp-server-support/Transport.cpp | 2 +- mlir/lib/Tools/mlir-opt/MlirOptMain.cpp | 3 +- mlir/lib/Tools/mlir-tblgen/MlirTblgenMain.cpp | 2 +- mlir/lib/Transforms/Mem2Reg.cpp | 3 +- mlir/lib/Transforms/PrintIR.cpp | 2 +- mlir/lib/Transforms/RemoveDeadValues.cpp | 4 +- mlir/lib/Transforms/SROA.cpp | 4 +- mlir/lib/Transforms/Utils/CMakeLists.txt | 1 - .../Transforms/Utils/DialectConversion.cpp | 502 +- mlir/lib/Transforms/Utils/RegionUtils.cpp | 9 - mlir/lib/Transforms/ViewOpGraph.cpp | 6 +- mlir/python/mlir/_mlir_libs/_mlir/ir.pyi | 44 - .../mlir/_mlir_libs/_mlir/passmanager.pyi | 9 +- mlir/python/mlir/dialects/scf.py | 2 +- mlir/python/mlir/extras/types.py | 4 - mlir/python/mlir/ir.py | 5 - mlir/test/CAPI/llvm.c | 23 +- mlir/test/CMakeLists.txt | 4 - .../AMDGPUToROCDL/amdgpu-to-rocdl.mlir | 23 - .../Conversion/AMDGPUToROCDL/wmma-gfx12.mlir | 9 - mlir/test/Conversion/AMDGPUToROCDL/wmma.mlir | 6 +- .../ArithToArmSME/arith-to-arm-sme.mlir | 4 +- .../ArmSMEToLLVM/arm-sme-to-llvm.mlir | 76 +- .../ArmSMEToSCF/arm-sme-to-scf.mlir | 2 +- .../Conversion/GPUToNVVM/gpu-to-nvvm.mlir | 53 +- .../Conversion/GPUToROCDL/gpu-to-rocdl.mlir | 156 +- .../Conversion/MathToROCDL/math-to-rocdl.mlir | 44 +- .../Conversion/NVGPUToNVVM/nvgpu-to-nvvm.mlir | 5 +- .../OpenMPToLLVM/convert-to-llvmir.mlir | 2 +- .../TensorToSPIRV/tensor-ops-to-spirv.mlir | 18 - .../TosaToLinalg/tosa-to-linalg-named.mlir | 10 +- .../TosaToLinalg/tosa-to-linalg-pipeline.mlir | 2 +- .../TosaToLinalg/tosa-to-linalg.mlir | 13 +- .../VectorToArmSME/vector-to-arm-sme.mlir | 106 +- .../VectorToLLVM/vector-to-llvm.mlir | 183 +- .../VectorToSPIRV/vector-to-spirv.mlir | 4 +- .../VectorToXeGPU/transfer-read-to-xegpu.mlir | 200 - .../transfer-write-to-xegpu.mlir | 159 - .../AMDGPU/amdgpu-emulate-atomics.mlir | 22 - mlir/test/Dialect/Affine/invalid.mlir | 32 - mlir/test/Dialect/Affine/scalrep.mlir | 21 - mlir/test/Dialect/ArmSME/invalid.mlir | 16 +- mlir/test/Dialect/ArmSME/roundtrip.mlir | 124 +- .../ArmSME/tile-allocation-copies.mlir | 4 +- .../ArmSME/tile-allocation-liveness.mlir | 56 +- .../Transforms/finalizing-bufferize.mlir | 1 - mlir/test/Dialect/GPU/canonicalize.mlir | 2 +- .../GPU/indirect-device-func-call.mlir | 21 - mlir/test/Dialect/GPU/invalid.mlir | 21 +- .../Dialect/GPU/subgroup-reduce-lowering.mlir | 47 +- .../test/Dialect/LLVMIR/constant-folding.mlir | 13 - mlir/test/Dialect/LLVMIR/roundtrip.mlir | 22 - .../fuse-with-reshape-by-collapsing.mlir | 42 +- .../Dialect/Linalg/transform-lower-pack.mlir | 14 +- .../transform-tile-and-winograd-rewrite.mlir | 137 +- .../Linalg/vectorization-scalable.mlir | 9 +- .../vectorize-tensor-extract-masked.mlir | 129 +- .../Linalg/winograd-conv2d-rewrite.mlir | 58 +- mlir/test/Dialect/Linalg/winograd-conv2d.mlir | 71 +- mlir/test/Dialect/Mesh/inlining.mlir | 15 - mlir/test/Dialect/OpenMP/ops.mlir | 20 +- mlir/test/Dialect/SCF/loop-pipelining.mlir | 103 +- mlir/test/Dialect/Tensor/canonicalize.mlir | 95 - .../Tensor/fold-into-pack-and-unpack.mlir | 35 +- mlir/test/Dialect/Tensor/invalid.mlir | 80 +- mlir/test/Dialect/Tosa/constant-op-fold.mlir | 4 +- mlir/test/Dialect/Tosa/invalid.mlir | 124 +- mlir/test/Dialect/Tosa/ops.mlir | 16 - .../Dialect/Tosa/tosa-reduce-transposes.mlir | 649 - ...transform-state-extension-initializer.mlir | 19 - mlir/test/Dialect/Vector/canonicalize.mlir | 12 +- mlir/test/Dialect/Vector/invalid.mlir | 8 - mlir/test/Dialect/Vector/linearize.mlir | 12 - mlir/test/Dialect/Vector/ops.mlir | 20 - .../vector-transfer-to-vector-load-store.mlir | 252 +- mlir/test/IR/attribute.mlir | 8 - mlir/test/IR/print-attr-type-aliases.mlir | 27 +- mlir/test/IR/print-ir-nesting.mlir | 9 +- .../Linalg/CPU/ArmSME/matmul-transpose-a.mlir | 8 - .../Dialect/Linalg/CPU/ArmSME/matmul.mlir | 8 - .../Dialect/SparseTensor/python/test_SDDMM.py | 5 +- .../Dialect/SparseTensor/python/test_SpMM.py | 2 +- .../SparseTensor/python/test_all_dense.py | 94 - .../SparseTensor/python/test_output.py | 2 +- .../SparseTensor/python/test_stress.py | 5 +- .../SparseTensor/python/tools/sparsifier.py | 13 +- .../tile-and-fuse-consumer.mlir | 81 +- .../tile-and-fuse-using-interface.mlir | 45 - mlir/test/Target/Cpp/common-cpp.mlir | 7 - mlir/test/Target/LLVMIR/Import/basic.ll | 8 +- mlir/test/Target/LLVMIR/Import/debug-info.ll | 53 +- .../test/Target/LLVMIR/Import/instructions.ll | 6 +- mlir/test/Target/LLVMIR/Import/intrinsic.ll | 12 - mlir/test/Target/LLVMIR/Import/nvvmir.ll | 3 - mlir/test/Target/LLVMIR/llvmir-debug.mlir | 41 +- .../test/Target/LLVMIR/llvmir-intrinsics.mlir | 16 - mlir/test/Target/LLVMIR/llvmir.mlir | 25 +- mlir/test/Target/LLVMIR/nvvmir.mlir | 15 +- mlir/test/Target/LLVMIR/omptarget-debug.mlir | 29 - mlir/test/Target/LLVMIR/omptarget-debug2.mlir | 31 - mlir/test/Target/LLVMIR/omptarget-llvm.mlir | 16 +- .../openmp-target-use-device-nested.mlir | 39 - mlir/test/Target/LLVMIR/rocdl.mlir | 14 +- .../buffer-results-to-out-params-elim.mlir | 16 +- .../Transforms/canonicalize-block-merge.mlir | 28 - .../loop-invariant-code-motion.mlir | 91 - mlir/test/Transforms/remove-dead-values.mlir | 5 - .../test-legalize-erased-op-with-uses.mlir | 4 +- .../test-legalize-type-conversion.mlir | 6 +- mlir/test/Transforms/test-legalizer.mlir | 11 - mlir/test/lib/Dialect/GPU/TestGpuRewrite.cpp | 13 +- mlir/test/lib/Dialect/SCF/TestSCFUtils.cpp | 4 +- mlir/test/lib/Dialect/Test/TestPatterns.cpp | 34 +- .../test/lib/Dialect/Transform/CMakeLists.txt | 1 - .../TestPassStateExtensionCommunication.cpp | 101 - .../TestTransformDialectExtension.cpp | 22 - .../TestTransformDialectExtension.td | 9 - .../Transform/TestTransformStateExtension.h | 28 - .../TestTilingInterfaceTransformOps.cpp | 12 +- mlir/test/mlir-tblgen/openmp-clause-ops.td | 84 - mlir/test/mlir-tblgen/openmp-ops-verify.td | 19 +- mlir/test/mlir-tblgen/openmp-ops.td | 61 +- mlir/test/python/dialects/scf.py | 26 - mlir/test/python/execution_engine.py | 16 +- mlir/test/python/ir/attributes.py | 18 - mlir/test/python/ir/builtin_types.py | 18 - mlir/test/python/pass_manager.py | 30 +- mlir/test/tblgen-to-irdl/CMathDialect.td | 13 +- mlir/test/tblgen-to-irdl/TestDialect.td | 76 +- .../mlir-linalg-ods-yaml-gen.cpp | 10 +- mlir/tools/mlir-opt/mlir-opt.cpp | 2 - mlir/tools/mlir-pdll/mlir-pdll.cpp | 4 +- .../mlir-src-sharder/mlir-src-sharder.cpp | 2 +- mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp | 19 +- mlir/tools/mlir-tblgen/BytecodeDialectGen.cpp | 5 +- mlir/tools/mlir-tblgen/DirectiveCommonGen.cpp | 7 +- .../mlir-tblgen/EnumPythonBindingGen.cpp | 5 +- mlir/tools/mlir-tblgen/EnumsGen.cpp | 8 +- mlir/tools/mlir-tblgen/OmpOpGen.cpp | 261 +- mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | 24 +- mlir/tools/mlir-tblgen/OpDocGen.cpp | 58 +- mlir/tools/mlir-tblgen/OpGenHelpers.cpp | 10 +- mlir/tools/mlir-tblgen/OpGenHelpers.h | 7 +- mlir/tools/mlir-tblgen/OpInterfacesGen.cpp | 12 +- mlir/tools/mlir-tblgen/RewriterGen.cpp | 16 +- .../tools/tblgen-to-irdl/OpDefinitionsGen.cpp | 230 +- mlir/unittests/Bytecode/BytecodeTest.cpp | 3 +- .../Dialect/AMDGPU/AMDGPUUtilsTest.cpp | 31 +- mlir/unittests/IR/AffineExprTest.cpp | 17 - mlir/unittests/IR/AttributeTest.cpp | 2 +- mlir/unittests/IR/OpPropertiesTest.cpp | 57 +- mlir/unittests/Parser/CMakeLists.txt | 2 - mlir/unittests/Parser/ParserTest.cpp | 81 - .../unittests/Support/IndentedOstreamTest.cpp | 12 +- mlir/utils/lldb-scripts/mlirDataFormatters.py | 2 - mlir/utils/tree-sitter-mlir/grammar.js | 2 +- offload/CMakeLists.txt | 6 +- offload/DeviceRTL/CMakeLists.txt | 10 +- offload/DeviceRTL/include/Allocator.h | 2 +- offload/DeviceRTL/include/Configuration.h | 2 +- offload/DeviceRTL/include/DeviceUtils.h | 54 - offload/DeviceRTL/include/Interface.h | 2 +- offload/DeviceRTL/include/LibC.h | 2 +- offload/DeviceRTL/include/Mapping.h | 2 +- offload/DeviceRTL/include/State.h | 4 +- offload/DeviceRTL/include/Synchronization.h | 2 +- .../include/{DeviceTypes.h => Types.h} | 35 +- offload/DeviceRTL/include/Utils.h | 100 + offload/DeviceRTL/src/Allocator.cpp | 4 +- offload/DeviceRTL/src/Configuration.cpp | 2 +- offload/DeviceRTL/src/Debug.cpp | 2 +- offload/DeviceRTL/src/Kernel.cpp | 2 +- offload/DeviceRTL/src/Mapping.cpp | 4 +- offload/DeviceRTL/src/Misc.cpp | 2 +- offload/DeviceRTL/src/Parallelism.cpp | 4 +- offload/DeviceRTL/src/Reduction.cpp | 4 +- offload/DeviceRTL/src/State.cpp | 16 +- offload/DeviceRTL/src/Synchronization.cpp | 4 +- offload/DeviceRTL/src/Tasking.cpp | 6 +- .../src/{DeviceUtils.cpp => Utils.cpp} | 16 +- offload/DeviceRTL/src/Workshare.cpp | 6 +- offload/include/Shared/Environment.h | 6 +- offload/include/Shared/RefCnt.h | 56 - offload/include/Shared/Utils.h | 100 +- offload/plugins-nextgen/amdgpu/src/rtl.cpp | 88 +- .../amdgpu/utils/UtilitiesRTL.h | 5 +- .../common/include/PluginInterface.h | 18 +- .../common/src/GlobalHandler.cpp | 4 +- offload/plugins-nextgen/common/src/JIT.cpp | 4 +- .../common/src/PluginInterface.cpp | 26 +- offload/plugins-nextgen/cuda/src/rtl.cpp | 2 +- offload/plugins-nextgen/host/CMakeLists.txt | 2 +- offload/src/DeviceImage.cpp | 5 +- offload/src/omptarget.cpp | 4 +- offload/test/api/is_initial_device.c | 6 +- offload/test/lit.cfg | 11 +- ...re_mapper_nested_default_mappers_array.cpp | 2 +- ...nested_default_mappers_array_subscript.cpp | 2 +- ...sted_default_mappers_complex_structure.cpp | 2 +- ...r_nested_default_mappers_ptr_subscript.cpp | 2 +- ...lare_mapper_nested_default_mappers_var.cpp | 2 +- .../test/mapping/map_both_pointer_pointee.c | 2 +- .../mapping/target_pointers_members_map.cpp | 2 +- offload/test/offloading/CUDA/basic_launch.cu | 4 +- .../CUDA/basic_launch_blocks_and_threads.cu | 4 +- .../offloading/CUDA/basic_launch_multi_arg.cu | 4 +- offload/test/offloading/CUDA/launch_tu.cu | 4 +- .../offloading/dynamic-schedule-non-spmd.cpp | 4 +- offload/test/offloading/dynamic-schedule.cpp | 4 +- .../dtype-array-constant-index-map.f90 | 4 +- .../offloading/fortran/dump_map_tables.f90 | 4 +- .../test/offloading/fortran/target-depend.f90 | 4 +- .../target-map-all-common-block-members.f90 | 4 +- .../fortran/target-map-common-block.f90 | 4 +- ...t-map-declare-target-link-common-block.f90 | 4 +- .../offloading/fortran/target-map-dynamic.f90 | 33 - .../target-map-first-common-block-member.f90 | 4 +- ...t-map-mix-imp-exp-common-block-members.f90 | 4 +- .../target-map-second-common-block-member.f90 | 4 +- .../high_trip_count_block_limit.cpp | 4 +- offload/test/offloading/schedule.c | 4 +- offload/test/sanitizer/double_free.c | 6 +- offload/test/sanitizer/double_free_racy.c | 4 +- offload/test/sanitizer/free_host_ptr.c | 6 +- offload/test/sanitizer/free_wrong_ptr_kind.c | 10 +- .../test/sanitizer/free_wrong_ptr_kind.cpp | 8 +- offload/test/sanitizer/kernel_crash.c | 17 +- offload/test/sanitizer/kernel_crash_async.c | 9 +- offload/test/sanitizer/kernel_crash_many.c | 25 +- offload/test/sanitizer/kernel_crash_single.c | 13 +- offload/test/sanitizer/kernel_trap.c | 4 +- offload/test/sanitizer/kernel_trap.cpp | 4 +- offload/test/sanitizer/kernel_trap_async.c | 4 +- offload/test/sanitizer/kernel_trap_many.c | 9 +- offload/test/sanitizer/ptr_outside_alloc_1.c | 4 +- offload/test/sanitizer/ptr_outside_alloc_2.c | 4 +- offload/test/sanitizer/use_after_free_1.c | 4 +- offload/test/sanitizer/use_after_free_2.c | 4 +- openmp/docs/SupportAndFAQ.rst | 8 +- openmp/runtime/src/CMakeLists.txt | 6 +- .../lib/Analysis/ScopDetectionDiagnostic.cpp | 3 +- polly/lib/Analysis/ScopInfo.cpp | 2 + polly/lib/CodeGen/BlockGenerators.cpp | 2 +- polly/lib/Exchange/JSONExporter.cpp | 8 +- sycl-jit/passes/target/TargetFusionInfo.cpp | 4 +- .../bindless_images/mipmap/mipmap_read_3D.cpp | 3 +- sycl/test/check_device_code/group_load.cpp | 28 +- sycl/test/check_device_code/group_store.cpp | 44 +- .../vector/vector_math_ops.cpp | 22 +- utils/bazel/.bazelrc | 4 - .../clang-tools-extra/clangd/BUILD.bazel | 1 - .../llvm-project-overlay/clang/BUILD.bazel | 52 +- .../clang/unittests/BUILD.bazel | 26 + .../compiler-rt/BUILD.bazel | 1 - .../llvm-project-overlay/libc/BUILD.bazel | 1354 +- .../libc/libc_configure_options.bzl | 2 +- .../libc/test/src/__support/BUILD.bazel | 1 - .../test/src/__support/FPUtil/BUILD.bazel | 3 +- .../libc/test/src/fenv/BUILD.bazel | 1 - .../libc/test/src/math/BUILD.bazel | 872 +- .../test/src/math/libc_math_test_rules.bzl | 23 +- .../libc/test/src/math/smoke/BUILD.bazel | 1265 +- .../libc/test/src/sys/epoll/BUILD.bazel | 34 +- .../libc/test/src/sys/socket/BUILD.bazel | 62 - .../llvm-project-overlay/lld/BUILD.bazel | 1 - .../lldb/source/Plugins/BUILD.bazel | 3 - .../llvm-project-overlay/llvm/BUILD.bazel | 110 +- .../llvm-project-overlay/llvm/driver.bzl | 2 - .../llvm/include/llvm/Config/config.h | 6 + .../llvm/unittests/BUILD.bazel | 18 - .../llvm-project-overlay/mlir/BUILD.bazel | 28 - utils/bazel/llvm_configs/config.h.cmake | 12 +- 6845 files changed, 145070 insertions(+), 389767 deletions(-) delete mode 100644 bolt/test/X86/yaml-unknown-keys.test create mode 100644 clang-tools-extra/docs/clang-rename.rst delete mode 100644 clang-tools-extra/docs/clang-tidy/checks/cert/arr39-c.rst delete mode 100644 clang-tools-extra/include-cleaner/test/tool-ignores-warnings.cpp create mode 100644 clang-tools-extra/pseudo/CMakeLists.txt create mode 100644 clang-tools-extra/pseudo/DesignNotes.md create mode 100644 clang-tools-extra/pseudo/Disambiguation.md create mode 100644 clang-tools-extra/pseudo/README.md create mode 100644 clang-tools-extra/pseudo/benchmarks/Benchmark.cpp create mode 100644 clang-tools-extra/pseudo/benchmarks/CMakeLists.txt create mode 100644 clang-tools-extra/pseudo/fuzzer/CMakeLists.txt create mode 100644 clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp create mode 100644 clang-tools-extra/pseudo/fuzzer/Main.cpp create mode 100644 clang-tools-extra/pseudo/gen/CMakeLists.txt create mode 100644 clang-tools-extra/pseudo/gen/Main.cpp create mode 100644 clang-tools-extra/pseudo/include/CMakeLists.txt rename clang-tools-extra/{clangd/support => pseudo/include/clang-pseudo}/Bracket.h (87%) rename clang-tools-extra/{clangd/support => pseudo/include/clang-pseudo}/DirectiveTree.h (95%) create mode 100644 clang-tools-extra/pseudo/include/clang-pseudo/Disambiguate.h create mode 100644 clang-tools-extra/pseudo/include/clang-pseudo/Forest.h create mode 100644 clang-tools-extra/pseudo/include/clang-pseudo/GLR.h create mode 100644 clang-tools-extra/pseudo/include/clang-pseudo/Language.h rename clang-tools-extra/{clangd/support => pseudo/include/clang-pseudo}/Token.h (98%) create mode 100644 clang-tools-extra/pseudo/include/clang-pseudo/cli/CLI.h create mode 100644 clang-tools-extra/pseudo/include/clang-pseudo/cxx/CXX.h create mode 100644 clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h create mode 100644 clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRGraph.h create mode 100644 clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h rename clang-tools-extra/{clangd/support => pseudo/lib}/Bracket.cpp (97%) create mode 100644 clang-tools-extra/pseudo/lib/CMakeLists.txt rename clang-tools-extra/{clangd/support => pseudo/lib}/DirectiveTree.cpp (99%) create mode 100644 clang-tools-extra/pseudo/lib/Disambiguate.cpp create mode 100644 clang-tools-extra/pseudo/lib/Forest.cpp create mode 100644 clang-tools-extra/pseudo/lib/GLR.cpp rename clang-tools-extra/{clangd/support => pseudo/lib}/Lex.cpp (98%) rename clang-tools-extra/{clangd/support => pseudo/lib}/Token.cpp (98%) create mode 100644 clang-tools-extra/pseudo/lib/cli/CLI.cpp create mode 100644 clang-tools-extra/pseudo/lib/cli/CMakeLists.txt create mode 100644 clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt create mode 100644 clang-tools-extra/pseudo/lib/cxx/CXX.cpp create mode 100644 clang-tools-extra/pseudo/lib/cxx/cxx.bnf create mode 100644 clang-tools-extra/pseudo/lib/grammar/CMakeLists.txt create mode 100644 clang-tools-extra/pseudo/lib/grammar/Grammar.cpp create mode 100644 clang-tools-extra/pseudo/lib/grammar/GrammarBNF.cpp create mode 100644 clang-tools-extra/pseudo/lib/grammar/LRGraph.cpp create mode 100644 clang-tools-extra/pseudo/lib/grammar/LRTable.cpp create mode 100644 clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp create mode 100644 clang-tools-extra/pseudo/test/.clang-format create mode 100644 clang-tools-extra/pseudo/test/CMakeLists.txt create mode 100644 clang-tools-extra/pseudo/test/Unit/lit.cfg.py create mode 100644 clang-tools-extra/pseudo/test/Unit/lit.site.cfg.py.in create mode 100644 clang-tools-extra/pseudo/test/check-cxx-bnf.test create mode 100644 clang-tools-extra/pseudo/test/crash/backslashes.c create mode 100644 clang-tools-extra/pseudo/test/cxx/capture-list.cpp create mode 100644 clang-tools-extra/pseudo/test/cxx/contextual-keywords.cpp create mode 100644 clang-tools-extra/pseudo/test/cxx/dangling-else.cpp create mode 100644 clang-tools-extra/pseudo/test/cxx/decl-specfier-seq.cpp create mode 100644 clang-tools-extra/pseudo/test/cxx/declarator-function.cpp create mode 100644 clang-tools-extra/pseudo/test/cxx/declarator-var.cpp create mode 100644 clang-tools-extra/pseudo/test/cxx/declator-member-function.cpp create mode 100644 clang-tools-extra/pseudo/test/cxx/empty-member-declaration.cpp create mode 100644 clang-tools-extra/pseudo/test/cxx/empty-member-spec.cpp create mode 100644 clang-tools-extra/pseudo/test/cxx/keyword.cpp create mode 100644 clang-tools-extra/pseudo/test/cxx/literals.cpp create mode 100644 clang-tools-extra/pseudo/test/cxx/mixed-designator.cpp create mode 100644 clang-tools-extra/pseudo/test/cxx/nested-name-specifier.cpp create mode 100644 clang-tools-extra/pseudo/test/cxx/parameter-decl-clause.cpp create mode 100644 clang-tools-extra/pseudo/test/cxx/predefined-identifier.cpp create mode 100644 clang-tools-extra/pseudo/test/cxx/recovery-func-parameters.cpp create mode 100644 clang-tools-extra/pseudo/test/cxx/recovery-init-list.cpp create mode 100644 clang-tools-extra/pseudo/test/cxx/structured-binding.cpp create mode 100644 clang-tools-extra/pseudo/test/cxx/template-empty-type-parameter.cpp create mode 100644 clang-tools-extra/pseudo/test/cxx/unsized-array.cpp create mode 100644 clang-tools-extra/pseudo/test/fuzzer.cpp create mode 100644 clang-tools-extra/pseudo/test/glr-variant-start.cpp create mode 100644 clang-tools-extra/pseudo/test/glr.cpp create mode 100644 clang-tools-extra/pseudo/test/html-forest.c create mode 100644 clang-tools-extra/pseudo/test/lex.c create mode 100644 clang-tools-extra/pseudo/test/lit.cfg.py create mode 100644 clang-tools-extra/pseudo/test/lit.local.cfg create mode 100644 clang-tools-extra/pseudo/test/lit.site.cfg.py.in create mode 100644 clang-tools-extra/pseudo/test/lr-build-basic.test create mode 100644 clang-tools-extra/pseudo/test/lr-build-conflicts.test create mode 100644 clang-tools-extra/pseudo/test/strip-directives.c create mode 100644 clang-tools-extra/pseudo/tool/CMakeLists.txt create mode 100644 clang-tools-extra/pseudo/tool/ClangPseudo.cpp create mode 100644 clang-tools-extra/pseudo/tool/HTMLForest.cpp create mode 100644 clang-tools-extra/pseudo/tool/HTMLForest.css create mode 100644 clang-tools-extra/pseudo/tool/HTMLForest.html create mode 100644 clang-tools-extra/pseudo/tool/HTMLForest.js create mode 100644 clang-tools-extra/pseudo/unittests/BracketTest.cpp create mode 100644 clang-tools-extra/pseudo/unittests/CMakeLists.txt create mode 100644 clang-tools-extra/pseudo/unittests/CXXTest.cpp create mode 100644 clang-tools-extra/pseudo/unittests/DirectiveTreeTest.cpp create mode 100644 clang-tools-extra/pseudo/unittests/DisambiguateTest.cpp create mode 100644 clang-tools-extra/pseudo/unittests/ForestTest.cpp create mode 100644 clang-tools-extra/pseudo/unittests/GLRTest.cpp create mode 100644 clang-tools-extra/pseudo/unittests/GrammarTest.cpp create mode 100644 clang-tools-extra/pseudo/unittests/LRTableTest.cpp create mode 100644 clang-tools-extra/pseudo/unittests/TokenTest.cpp create mode 100644 clang-tools-extra/test/clang-apply-replacements/ClangRenameClassReplacements.cpp rename clang-tools-extra/test/clang-tidy/checkers/bugprone/{sizeof-expression.c => sizeof-expression-2.c} (100%) delete mode 100644 clang-tools-extra/test/clang-tidy/checkers/bugprone/sizeof-expression-pointer-arithmetics-c11.c delete mode 100644 clang-tools-extra/test/clang-tidy/checkers/bugprone/sizeof-expression-pointer-arithmetics.c delete mode 100644 clang-tools-extra/test/clang-tidy/checkers/misc/unconventional-assign-operator-cxx23.cpp delete mode 100644 clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-c++20.cpp delete mode 100644 clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-value-param-crash.cpp delete mode 100644 clang/include/clang/Basic/arm_immcheck_incl.td delete mode 100644 clang/lib/CodeGen/Targets/DirectX.cpp delete mode 100644 clang/lib/Headers/avx10_2_512bf16intrin.h delete mode 100644 clang/lib/Headers/avx10_2_512satcvtdsintrin.h delete mode 100644 clang/lib/Headers/avx10_2bf16intrin.h delete mode 100644 clang/lib/Headers/avx10_2copyintrin.h delete mode 100644 clang/lib/Headers/avx10_2satcvtdsintrin.h delete mode 100644 clang/lib/Headers/hlsl/hlsl_detail.h delete mode 100644 clang/lib/Tooling/LocateToolCompilationDatabase.cpp delete mode 100644 clang/test/AST/ByteCode/const-base-cast.cpp delete mode 100644 clang/test/AST/ByteCode/extern.cpp delete mode 100644 clang/test/AST/ByteCode/initializer_list.cpp delete mode 100644 clang/test/AST/HLSL/StructuredBuffer-AST.hlsl delete mode 100644 clang/test/Analysis/Checkers/WebKit/ref-cntbl-crtp-base-no-virtual-dtor.cpp delete mode 100644 clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.mm delete mode 100644 clang/test/Analysis/cstring-uninitread-notes.c delete mode 100644 clang/test/Analysis/embed.c delete mode 100644 clang/test/Analysis/malloc-refcounted.c delete mode 100644 clang/test/Analysis/nullability-nocrash.c delete mode 100644 clang/test/Analysis/z3-unarysymexpr.c delete mode 100644 clang/test/C/C23/n3029.c delete mode 100644 clang/test/C/C23/n3030.c delete mode 100644 clang/test/CXX/drs/cwg1818.cpp delete mode 100644 clang/test/CXX/drs/cwg563.cpp delete mode 100644 clang/test/ClangScanDeps/implicit-target.c delete mode 100644 clang/test/ClangScanDeps/resolve-executable-path.c delete mode 100644 clang/test/ClangScanDeps/verbose.test create mode 100644 clang/test/CodeGen/PowerPC/transparent_union.c delete mode 100644 clang/test/CodeGen/SystemZ/builtins-systemz-i128.c delete mode 100644 clang/test/CodeGen/X86/avx10_2_512bf16-builtins.c delete mode 100644 clang/test/CodeGen/X86/avx10_2_512satcvtds-builtins-errors.c delete mode 100755 clang/test/CodeGen/X86/avx10_2_512satcvtds-builtins-x64-error.c delete mode 100644 clang/test/CodeGen/X86/avx10_2_512satcvtds-builtins-x64.c delete mode 100644 clang/test/CodeGen/X86/avx10_2_512satcvtds-builtins.c delete mode 100644 clang/test/CodeGen/X86/avx10_2bf16-builtins.c delete mode 100644 clang/test/CodeGen/X86/avx10_2satcvtds-builtins-errors.c delete mode 100644 clang/test/CodeGen/X86/avx10_2satcvtds-builtins-x64.c delete mode 100644 clang/test/CodeGen/X86/avx10_2satcvtds-builtins.c delete mode 100644 clang/test/CodeGen/X86/avx512copy-builtins.c delete mode 100644 clang/test/CodeGen/X86/bfloat16-convert-half.c delete mode 100644 clang/test/CodeGen/aarch64-neon-faminmax-intrinsics.c delete mode 100644 clang/test/CodeGen/aarch64-neon-luti.c delete mode 100644 clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_faminmax.c delete mode 100644 clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_faminmax.c delete mode 100644 clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_luti.c create mode 100644 clang/test/CodeGen/arm-neon-range-checks.c delete mode 100644 clang/test/CodeGen/attr-target-clones-riscv-invalid.c delete mode 100644 clang/test/CodeGen/attr-target-clones-riscv.c delete mode 100644 clang/test/CodeGen/transparent-union-type.c delete mode 100644 clang/test/CodeGenCXX/attr-target-clones-riscv.cpp delete mode 100644 clang/test/CodeGenCoroutines/Inputs/utility.h delete mode 100644 clang/test/CodeGenCoroutines/coro-await-elidable.cpp delete mode 100644 clang/test/CodeGenHLSL/builtins/StructuredBuffer-annotations.hlsl delete mode 100644 clang/test/CodeGenHLSL/builtins/StructuredBuffer-constructor.hlsl delete mode 100644 clang/test/CodeGenHLSL/builtins/StructuredBuffer-elementtype.hlsl delete mode 100644 clang/test/CodeGenHLSL/builtins/StructuredBuffer-subscript.hlsl delete mode 100644 clang/test/CodeGenHLSL/builtins/asfloat.hlsl delete mode 100644 clang/test/CodeGenHLSL/builtins/asuint.hlsl delete mode 100644 clang/test/CodeGenHLSL/builtins/countbits.hlsl delete mode 100644 clang/test/CodeGenHLSL/builtins/hlsl_resource_t.hlsl delete mode 100644 clang/test/CodeGenHLSL/builtins/select.hlsl delete mode 100644 clang/test/CodeGenHLSL/builtins/sign.hlsl delete mode 100644 clang/test/CodeGenHLSL/builtins/step.hlsl delete mode 100644 clang/test/CodeGenHLSL/builtins/wave_is_first_lane.hlsl delete mode 100644 clang/test/CodeGenHLSL/convergence/cf.for.plain.hlsl delete mode 100644 clang/test/CodeGenHLSL/inline-constructors.hlsl delete mode 100644 clang/test/CodeGenHLSL/inline-functions.hlsl delete mode 100644 clang/test/CodeGenHLSL/wavesize.hlsl delete mode 100644 clang/test/Driver/baremetal-multilib-custom-error.yaml delete mode 100644 clang/test/Driver/codegen-data.c delete mode 100644 clang/test/Driver/fmodules-embed-all-files.cpp delete mode 100644 clang/test/Driver/riscv-mcmodel.c delete mode 100644 clang/test/ExtractAPI/attributed-typedef.m delete mode 100644 clang/test/Lexer/has_feature_realtime_sanitizer.cpp delete mode 100644 clang/test/Misc/print-stats-vfs.test delete mode 100644 clang/test/Modules/pr107673.cppm delete mode 100644 clang/test/Modules/pr108732.cppm create mode 100644 clang/test/OpenMP/error_unsupport_feature.c delete mode 100644 clang/test/OpenMP/scope_codegen.cpp delete mode 100644 clang/test/PCH/race-condition.cpp delete mode 100644 clang/test/Parser/cxx-bad-cast-diagnose-broken-template.cpp delete mode 100644 clang/test/Parser/static_assert.cpp delete mode 100644 clang/test/ParserHLSL/hlsl_contained_type_attr.hlsl delete mode 100644 clang/test/ParserHLSL/hlsl_contained_type_attr_error.hlsl delete mode 100644 clang/test/ParserHLSL/hlsl_raw_buffer_attr.hlsl delete mode 100644 clang/test/ParserHLSL/hlsl_raw_buffer_attr_error.hlsl create mode 100644 clang/test/Sema/aarch64-neon-bf16-ranges.c delete mode 100644 clang/test/Sema/aarch64-neon-faminmax-no-faminmax.c delete mode 100644 clang/test/Sema/aarch64-neon-faminmax-no-neon.c create mode 100644 clang/test/Sema/aarch64-neon-fp16-ranges.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/bfloat16.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/conversions.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/copy-vector-lane.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/dotprod.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/extract-elt-from-vector.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/extract-vector-from-vectors.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/fp16-scalar.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/fp16-v84.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/fp16-vector.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/fused-multiply-accumulate.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/luti.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/matrix-multiplication.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/multiply-extended.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/saturating-multiply-accumulate.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/saturating-multiply-by-scalar-and-widen.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/set-lanes-to-value.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/set-vector-lane.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/sqrdmlah-ranges.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/vcmla.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/vector-load.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/vector-multiply-accumulate-by-scalar.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/vector-multiply-by-scalar-and-widen.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/vector-multiply-by-scalar.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/vector-multiply-subtract-by-scalar.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/vector-shift-left.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/vector-shift-right.c delete mode 100644 clang/test/Sema/aarch64-neon-immediate-ranges/vector-store.c create mode 100644 clang/test/Sema/aarch64-neon-ranges.c delete mode 100644 clang/test/Sema/attr-btf_type_tag.cpp delete mode 100644 clang/test/Sema/countbits-errors.hlsl delete mode 100644 clang/test/SemaCXX/PR97308.cpp delete mode 100644 clang/test/SemaCXX/attr-target-clones-riscv.cpp delete mode 100644 clang/test/SemaCXX/builtin-is-within-lifetime.cpp delete mode 100644 clang/test/SemaCXX/consteval-builtin.cpp delete mode 100644 clang/test/SemaCXX/diagnose_if-warning-group.cpp create mode 100644 clang/test/SemaCXX/pr61460.cpp delete mode 100644 clang/test/SemaCXX/static-assert-ext.cpp delete mode 100644 clang/test/SemaCXX/warn-unsafe-buffer-usage-libc-functions-inline-namespace.cpp delete mode 100644 clang/test/SemaCXX/warn-unsafe-buffer-usage-libc-functions.cpp delete mode 100644 clang/test/SemaHLSL/BuiltIns/StructuredBuffers.hlsl delete mode 100644 clang/test/SemaHLSL/BuiltIns/asfloat-errors.hlsl delete mode 100644 clang/test/SemaHLSL/BuiltIns/asuint-errors.hlsl delete mode 100644 clang/test/SemaHLSL/BuiltIns/countbits-errors.hlsl delete mode 100644 clang/test/SemaHLSL/BuiltIns/select-errors.hlsl delete mode 100644 clang/test/SemaHLSL/BuiltIns/sign-errors.hlsl delete mode 100644 clang/test/SemaHLSL/BuiltIns/step-errors.hlsl delete mode 100644 clang/test/SemaHLSL/Types/BuiltinVector/TruncationConstantExpr.hlsl delete mode 100644 clang/test/SemaHLSL/Types/Traits/IsIntangibleType.hlsl delete mode 100644 clang/test/SemaHLSL/Types/Traits/IsIntangibleTypeErrors.hlsl delete mode 100644 clang/test/SemaHLSL/resource_binding_attr_error_space.hlsl create mode 100644 clang/test/clang-rename/ClassAsTemplateArgument.cpp create mode 100644 clang/test/clang-rename/ClassFindByName.cpp create mode 100644 clang/test/clang-rename/ClassSimpleRenaming.cpp create mode 100644 clang/test/clang-rename/ClassTestMulti.cpp create mode 100644 clang/test/clang-rename/ClassTestMultiByName.cpp create mode 100644 clang/test/clang-rename/ComplexFunctionOverride.cpp create mode 100644 clang/test/clang-rename/ComplicatedClassType.cpp create mode 100644 clang/test/clang-rename/Ctor.cpp create mode 100644 clang/test/clang-rename/CtorInitializer.cpp create mode 100644 clang/test/clang-rename/DeclRefExpr.cpp create mode 100644 clang/test/clang-rename/ForceMulti.cpp create mode 100644 clang/test/clang-rename/ForwardClassDecl.cpp create mode 100644 clang/test/clang-rename/FunctionMacro.cpp create mode 100644 clang/test/clang-rename/FunctionOverride.cpp create mode 100644 clang/test/clang-rename/FunctionTemplate.cpp create mode 100644 clang/test/clang-rename/FunctionWithClassFindByName.cpp create mode 100644 clang/test/clang-rename/IncludeHeaderWithSymbol.cpp create mode 100644 clang/test/clang-rename/Inputs/HeaderWithSymbol.h create mode 100644 clang/test/clang-rename/Inputs/OffsetToNewName.yaml create mode 100644 clang/test/clang-rename/Inputs/QualifiedNameToNewName.yaml create mode 100644 clang/test/clang-rename/InvalidNewName.cpp create mode 100644 clang/test/clang-rename/InvalidOffset.cpp create mode 100644 clang/test/clang-rename/InvalidQualifiedName.cpp create mode 100644 clang/test/clang-rename/MemberExprMacro.cpp create mode 100644 clang/test/clang-rename/Namespace.cpp create mode 100644 clang/test/clang-rename/NoNewName.cpp create mode 100644 clang/test/clang-rename/NonExistFile.cpp create mode 100644 clang/test/clang-rename/TemplateClassInstantiation.cpp create mode 100644 clang/test/clang-rename/TemplateCtor.cpp create mode 100644 clang/test/clang-rename/TemplateTypename.cpp create mode 100644 clang/test/clang-rename/TemplatedClassFunction.cpp create mode 100644 clang/test/clang-rename/Typedef.cpp create mode 100644 clang/test/clang-rename/UserDefinedConversion.cpp create mode 100644 clang/test/clang-rename/Variable.cpp create mode 100644 clang/test/clang-rename/VariableMacro.cpp create mode 100644 clang/test/clang-rename/VariableTemplate.cpp create mode 100644 clang/test/clang-rename/YAMLInput.cpp create mode 100644 clang/tools/clang-format-vs/.gitignore create mode 100644 clang/tools/clang-format-vs/CMakeLists.txt create mode 100644 clang/tools/clang-format-vs/ClangFormat.sln create mode 100644 clang/tools/clang-format-vs/ClangFormat/ClangFormat.csproj create mode 100644 clang/tools/clang-format-vs/ClangFormat/ClangFormat.vsct create mode 100644 clang/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs create mode 100644 clang/tools/clang-format-vs/ClangFormat/GlobalSuppressions.cs create mode 100644 clang/tools/clang-format-vs/ClangFormat/Guids.cs create mode 100644 clang/tools/clang-format-vs/ClangFormat/PkgCmdID.cs create mode 100644 clang/tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs create mode 100644 clang/tools/clang-format-vs/ClangFormat/Resources.Designer.cs create mode 100644 clang/tools/clang-format-vs/ClangFormat/Resources.resx create mode 100644 clang/tools/clang-format-vs/ClangFormat/Resources/Images_32bit.bmp create mode 100644 clang/tools/clang-format-vs/ClangFormat/Resources/Package.ico create mode 100644 clang/tools/clang-format-vs/ClangFormat/RunningDocTableEventsDispatcher.cs create mode 100644 clang/tools/clang-format-vs/ClangFormat/VSPackage.resx create mode 100644 clang/tools/clang-format-vs/ClangFormat/Vsix.cs create mode 100644 clang/tools/clang-format-vs/ClangFormat/license.txt create mode 100644 clang/tools/clang-format-vs/ClangFormat/packages.config create mode 100644 clang/tools/clang-format-vs/README.txt create mode 100644 clang/tools/clang-format-vs/source.extension.vsixmanifest.in create mode 100644 clang/tools/clang-rename/CMakeLists.txt create mode 100644 clang/tools/clang-rename/ClangRename.cpp create mode 100644 clang/tools/clang-rename/clang-rename.el create mode 100644 clang/tools/clang-rename/clang-rename.py delete mode 100644 clang/unittests/AST/RawCommentForDeclTest.cpp create mode 100644 clang/unittests/Rename/CMakeLists.txt create mode 100644 clang/unittests/Rename/ClangRenameTest.h create mode 100644 clang/unittests/Rename/RenameAliasTest.cpp create mode 100644 clang/unittests/Rename/RenameClassTest.cpp create mode 100644 clang/unittests/Rename/RenameEnumTest.cpp create mode 100644 clang/unittests/Rename/RenameFunctionTest.cpp create mode 100644 clang/unittests/Rename/RenameMemberTest.cpp delete mode 100644 compiler-rt/include/sanitizer/rtsan_interface.h delete mode 100644 compiler-rt/lib/asan/asan_malloc_win_thunk.cpp delete mode 100644 compiler-rt/lib/asan/asan_win_common_runtime_thunk.cpp delete mode 100644 compiler-rt/lib/asan/asan_win_common_runtime_thunk.h create mode 100644 compiler-rt/lib/asan/asan_win_dll_thunk.cpp delete mode 100644 compiler-rt/lib/asan/asan_win_static_runtime_thunk.cpp create mode 100644 compiler-rt/lib/asan/asan_win_weak_interception.cpp delete mode 100644 compiler-rt/lib/builtins/truncxfbf2.c delete mode 100644 compiler-rt/lib/orc/jit_dispatch.h delete mode 100644 compiler-rt/lib/rtsan/rtsan_flags.cpp delete mode 100644 compiler-rt/lib/rtsan/rtsan_flags.h delete mode 100644 compiler-rt/lib/rtsan/rtsan_flags.inc create mode 100644 compiler-rt/lib/sanitizer_common/sanitizer_coverage_win_dll_thunk.cpp rename compiler-rt/lib/sanitizer_common/{sanitizer_coverage_win_runtime_thunk.cpp => sanitizer_coverage_win_dynamic_runtime_thunk.cpp} (59%) create mode 100644 compiler-rt/lib/sanitizer_common/sanitizer_coverage_win_weak_interception.cpp create mode 100644 compiler-rt/lib/sanitizer_common/sanitizer_win_dll_thunk.cpp create mode 100644 compiler-rt/lib/sanitizer_common/sanitizer_win_dll_thunk.h create mode 100644 compiler-rt/lib/sanitizer_common/sanitizer_win_dynamic_runtime_thunk.cpp delete mode 100644 compiler-rt/lib/sanitizer_common/sanitizer_win_immortalize.h delete mode 100644 compiler-rt/lib/sanitizer_common/sanitizer_win_interception.cpp delete mode 100644 compiler-rt/lib/sanitizer_common/sanitizer_win_interception.h delete mode 100644 compiler-rt/lib/sanitizer_common/sanitizer_win_thunk_interception.cpp delete mode 100644 compiler-rt/lib/sanitizer_common/sanitizer_win_thunk_interception.h create mode 100644 compiler-rt/lib/sanitizer_common/sanitizer_win_weak_interception.cpp create mode 100644 compiler-rt/lib/sanitizer_common/sanitizer_win_weak_interception.h create mode 100644 compiler-rt/lib/ubsan/ubsan_win_dll_thunk.cpp rename compiler-rt/lib/ubsan/{ubsan_win_runtime_thunk.cpp => ubsan_win_dynamic_runtime_thunk.cpp} (62%) create mode 100644 compiler-rt/lib/ubsan/ubsan_win_weak_interception.cpp create mode 100644 compiler-rt/test/builtins/Unit/compiler_rt_fmaxf_test.c delete mode 100644 compiler-rt/test/profile/Linux/instrprof-debug-info-correlate-debuginfod.c delete mode 100644 compiler-rt/test/profile/instrprof-binary-correlate-debuginfod.c delete mode 100644 compiler-rt/test/rtsan/disabler.cpp delete mode 100644 compiler-rt/test/rtsan/sanity_check_pure_c.c delete mode 100644 compiler-rt/test/rtsan/unrecognized_flags.cpp delete mode 100644 compiler-rt/test/sanitizer_common/TestCases/Linux/tls_get_addr.c delete mode 100644 compiler-rt/test/sanitizer_common/TestCases/Linux/tls_malloc_hook.c delete mode 100644 compiler-rt/test/sanitizer_common/TestCases/dlsym_alloc.c delete mode 100644 flang/include/flang/Common/float80.h delete mode 100644 flang/include/flang/Runtime/CUDA/allocatable.h delete mode 100644 flang/include/flang/Runtime/CUDA/common.h delete mode 100644 flang/include/flang/Runtime/CUDA/memory.h delete mode 100644 flang/include/flang/Runtime/complex.h delete mode 100644 flang/runtime/CUDA/allocatable.cpp delete mode 100644 flang/runtime/CUDA/memory.cpp delete mode 100644 flang/test/Driver/fno-openmp.f90 delete mode 100644 flang/test/Driver/nostdlib.f90 delete mode 100644 flang/test/Driver/q-unused-arguments.f90 delete mode 100644 flang/test/Driver/save-temps-use-module.f90 delete mode 100644 flang/test/Driver/xlinker.f90 delete mode 100644 flang/test/Evaluate/fold-assumed-rank-kind.f90 delete mode 100644 flang/test/Fir/CUDA/cuda-data-transfer.fir delete mode 100644 flang/test/Integration/debug-target-region-vars.f90 delete mode 100644 flang/test/Lower/CUDA/cuda-devptr.cuf delete mode 100644 flang/test/Lower/HLFIR/elemental-user-procedure-stacksave.f90 delete mode 100644 flang/test/Lower/HLFIR/ignore-type-f77-character.f90 delete mode 100644 flang/test/Lower/HLFIR/procedure-pointer-in-generics.f90 delete mode 100644 flang/test/Lower/OpenMP/math-amdgpu.f90 delete mode 100644 flang/test/Lower/OpenMP/shared-loop.f90 delete mode 100644 flang/test/Lower/module-generic-with-specific-mangling.f90 delete mode 100644 flang/test/Parser/non-breaking-space.f90 delete mode 100644 flang/test/Preprocessing/include-file.h delete mode 100644 flang/test/Preprocessing/include-line.F90 delete mode 100644 flang/test/Semantics/Inputs/modfile66.cuf delete mode 100644 flang/test/Semantics/Inputs/modfile67.mod delete mode 100644 flang/test/Semantics/OpenMP/bad_module_subroutine.f90 delete mode 100644 flang/test/Semantics/OpenMP/clause-order.f90 delete mode 100644 flang/test/Semantics/OpenMP/private-assoc.f90 delete mode 100644 flang/test/Semantics/elemental02.f90 delete mode 100644 flang/test/Semantics/generic09.f90 delete mode 100644 flang/test/Semantics/generic10.f90 delete mode 100644 flang/test/Semantics/implicit16.f90 delete mode 100644 flang/test/Semantics/kinds06.f90 delete mode 100644 flang/test/Semantics/modfile66.f90 delete mode 100644 flang/test/Semantics/modfile67.f90 delete mode 100644 flang/test/Semantics/modfile68.f90 delete mode 100644 flang/test/Semantics/smp-proc-ref.f90 delete mode 100644 flang/test/Transforms/debug-107988.fir delete mode 100644 flang/test/Transforms/debug-imported-entity.fir delete mode 100644 flang/unittests/Runtime/CUDA/Allocatable.cpp delete mode 100644 libc/hdr/link_macros.h delete mode 100644 libc/hdr/sys_auxv_macros.h delete mode 100644 libc/hdr/types/jmp_buf.h delete mode 100644 libc/hdr/types/sighandler_t.h delete mode 100644 libc/hdr/types/socklen_t.h delete mode 100644 libc/hdr/types/ssize_t.h delete mode 100644 libc/hdr/types/stack_t.h delete mode 100644 libc/hdr/types/struct_msghdr.h delete mode 100644 libc/hdr/types/struct_sockaddr.h delete mode 100644 libc/hdr/types/wchar_t.h delete mode 100644 libc/hdr/types/wint_t.h delete mode 100644 libc/hdr/wchar_macros.h delete mode 100644 libc/hdr/wchar_overlay.h delete mode 100644 libc/include/llvm-libc-types/struct_iovec.h delete mode 100644 libc/include/llvm-libc-types/struct_msghdr.h delete mode 100644 libc/src/__support/OSUtil/linux/aarch64/vdso.h delete mode 100644 libc/src/__support/OSUtil/linux/arm/vdso.h delete mode 100644 libc/src/__support/OSUtil/linux/riscv/vdso.h delete mode 100644 libc/src/__support/OSUtil/linux/vdso.cpp delete mode 100644 libc/src/__support/OSUtil/linux/vdso.h delete mode 100644 libc/src/__support/OSUtil/linux/vdso_sym.h delete mode 100644 libc/src/__support/OSUtil/linux/x86_64/vdso.h delete mode 100644 libc/src/__support/OSUtil/windows/CMakeLists.txt delete mode 100644 libc/src/__support/OSUtil/windows/exit.cpp delete mode 100644 libc/src/__support/OSUtil/windows/io.cpp delete mode 100644 libc/src/__support/OSUtil/windows/io.h delete mode 100644 libc/src/__support/macros/null_check.h delete mode 100644 libc/src/stdio/printf_core/strerror_converter.h delete mode 100644 libc/src/sys/socket/linux/recv.cpp delete mode 100644 libc/src/sys/socket/linux/recvfrom.cpp delete mode 100644 libc/src/sys/socket/linux/recvmsg.cpp delete mode 100644 libc/src/sys/socket/linux/send.cpp delete mode 100644 libc/src/sys/socket/linux/sendmsg.cpp delete mode 100644 libc/src/sys/socket/linux/sendto.cpp delete mode 100644 libc/src/sys/socket/linux/socketpair.cpp delete mode 100644 libc/src/sys/socket/recv.h delete mode 100644 libc/src/sys/socket/recvfrom.h delete mode 100644 libc/src/sys/socket/recvmsg.h delete mode 100644 libc/src/sys/socket/send.h delete mode 100644 libc/src/sys/socket/sendmsg.h delete mode 100644 libc/src/sys/socket/sendto.h delete mode 100644 libc/src/sys/socket/socketpair.h delete mode 100644 libc/src/time/ctime.cpp delete mode 100644 libc/src/time/ctime.h delete mode 100644 libc/src/time/ctime_r.cpp delete mode 100644 libc/src/time/ctime_r.h delete mode 100644 libc/test/src/__support/OSUtil/linux/vdso_test.cpp delete mode 100644 libc/test/src/sys/socket/linux/send_recv_test.cpp delete mode 100644 libc/test/src/sys/socket/linux/sendmsg_recvmsg_test.cpp delete mode 100644 libc/test/src/sys/socket/linux/sendto_recvfrom_test.cpp delete mode 100644 libc/test/src/sys/socket/linux/socketpair_test.cpp delete mode 100644 libc/test/src/time/ctime_r_test.cpp delete mode 100644 libc/test/src/time/ctime_test.cpp delete mode 100644 libcxx/include/__cstddef/byte.h delete mode 100644 libcxx/include/__cstddef/max_align_t.h delete mode 100644 libcxx/include/__cstddef/nullptr_t.h delete mode 100644 libcxx/include/__cstddef/ptrdiff_t.h delete mode 100644 libcxx/include/__cstddef/size_t.h delete mode 100644 libcxx/include/__fwd/byte.h delete mode 100644 libcxx/include/__fwd/get.h delete mode 100644 libcxx/include/__fwd/variant.h delete mode 100644 libcxx/include/__memory/unique_temporary_buffer.h rename libcxx/include/{__memory => __type_traits}/noexcept_move_assign_container.h (85%) create mode 100644 libcxx/include/experimental/__config delete mode 100644 libcxx/test/libcxx/atomics/atomics.syn/compatible_with_stdatomic.compile.pass.cpp create mode 100644 libcxx/test/libcxx/atomics/atomics.syn/incompatible_with_stdatomic.verify.cpp create mode 100644 libcxx/test/libcxx/atomics/stdatomic.h.syn/dont_hijack_header.compile.pass.cpp delete mode 100644 libcxx/test/libcxx/containers/associative/unord.map/abi.compile.pass.cpp delete mode 100644 libcxx/test/libcxx/containers/associative/unord.set/abi.compile.pass.cpp create mode 100644 libcxx/test/libcxx/memory/compressed_pair/compressed_pair.pass.cpp delete mode 100644 libcxx/test/std/input.output/filesystems/class.rec.dir.itr/cache_refresh_iter.pass.cpp delete mode 100644 libcxx/test/std/iterators/iterator.primitives/iterator.traits/empty.compile.pass.cpp create mode 100644 libcxx/test/std/iterators/iterator.primitives/iterator.traits/empty.verify.cpp delete mode 100644 libcxx/test/std/numerics/c.math/signbit.pass.cpp create mode 100644 libcxx/test/support/test.support/test_poisoned_hash_helper.pass.cpp create mode 100755 libcxx/utils/graph_header_deps.py delete mode 100644 lld/test/COFF/arm64ec-import.test delete mode 100644 lld/test/COFF/arm64ec-lib.test delete mode 100644 lld/test/COFF/export-imp.test delete mode 100644 lld/test/COFF/import_weak_alias.test delete mode 100644 lld/test/MachO/cgdata-generate.s delete mode 100644 lld/test/MachO/icf-safe-thunks.ll delete mode 100644 lld/test/wasm/Inputs/allow-multiple-definition.s delete mode 100644 lld/test/wasm/allow-multiple-definition.s delete mode 100644 lld/test/wasm/static-error.s delete mode 100644 lld/test/wasm/unsupported-pic-relocations.s delete mode 100644 lld/test/wasm/unsupported-pic-relocations64.s delete mode 100644 lldb/include/lldb/Target/CoreFileMemoryRanges.h create mode 100644 lldb/packages/Python/lldbsuite/test/bench.py delete mode 100644 lldb/source/Target/CoreFileMemoryRanges.cpp rename lldb/test/API/{functionalities/memory/holes => benchmarks/continue}/Makefile (100%) create mode 100644 lldb/test/API/benchmarks/continue/TestBenchmarkContinue.py create mode 100644 lldb/test/API/benchmarks/continue/main.cpp rename lldb/test/API/{lang/cpp/fpnan => benchmarks/expression}/Makefile (100%) create mode 100644 lldb/test/API/benchmarks/expression/TestExpressionCmd.py create mode 100644 lldb/test/API/benchmarks/expression/TestRepeatedExprs.py create mode 100644 lldb/test/API/benchmarks/expression/main.cpp create mode 100644 lldb/test/API/benchmarks/frame_variable/TestFrameVariableResponse.py rename lldb/test/API/{lang/cpp/no_unique_address => benchmarks/libcxxlist}/Makefile (100%) create mode 100644 lldb/test/API/benchmarks/libcxxlist/TestBenchmarkLibcxxList.py create mode 100644 lldb/test/API/benchmarks/libcxxlist/main.cpp rename lldb/test/API/{tools/lldb-dap/exception/cpp => benchmarks/libcxxmap}/Makefile (100%) create mode 100644 lldb/test/API/benchmarks/libcxxmap/TestBenchmarkLibcxxMap.py create mode 100644 lldb/test/API/benchmarks/libcxxmap/main.cpp create mode 100644 lldb/test/API/benchmarks/startup/TestStartupDelays.py create mode 100644 lldb/test/API/benchmarks/stepping/TestSteppingSpeed.py create mode 100644 lldb/test/API/benchmarks/turnaround/TestCompileRunToBreakpointTurnaround.py delete mode 100644 lldb/test/API/commands/statistics/basic/BoxFormatter.py create mode 100644 lldb/test/API/commands/statistics/basic/main.c delete mode 100644 lldb/test/API/commands/statistics/basic/main.cpp delete mode 100644 lldb/test/API/functionalities/memory/holes/TestMemoryHoles.py delete mode 100644 lldb/test/API/functionalities/memory/holes/main.cpp rename lldb/test/API/functionalities/postmortem/elf-core/{linux-riscv64.gpr_fpr.core => linux-riscv64.core} (76%) delete mode 100755 lldb/test/API/functionalities/postmortem/elf-core/linux-riscv64.gpr_fpr.out delete mode 100644 lldb/test/API/functionalities/postmortem/elf-core/linux-riscv64.gpr_only.core delete mode 100755 lldb/test/API/functionalities/postmortem/elf-core/linux-riscv64.gpr_only.out create mode 100755 lldb/test/API/functionalities/postmortem/elf-core/linux-riscv64.out delete mode 100644 lldb/test/API/functionalities/postmortem/elf-core/main_fpr.c delete mode 100644 lldb/test/API/functionalities/postmortem/minidump-new/multiple-sigsev.yaml delete mode 100644 lldb/test/API/functionalities/watchpoint/categories delete mode 100644 lldb/test/API/lang/cpp/fpnan/TestFPNaN.py delete mode 100644 lldb/test/API/lang/cpp/fpnan/main.cpp delete mode 100644 lldb/test/API/lang/cpp/no_unique_address/TestNoUniqueAddress.py delete mode 100644 lldb/test/API/lang/cpp/no_unique_address/main.cpp delete mode 100644 lldb/test/API/tools/lldb-dap/exception/cpp/TestDAP_exception_cpp.py delete mode 100644 lldb/test/API/tools/lldb-dap/exception/cpp/main.cpp rename lldb/test/API/tools/lldb-dap/exception/{main.c => main.cpp} (56%) delete mode 100644 lldb/test/API/tools/lldb-dap/exception/objc/Makefile delete mode 100644 lldb/test/API/tools/lldb-dap/exception/objc/TestDAP_exception_objc.py delete mode 100644 lldb/test/API/tools/lldb-dap/exception/objc/main.m delete mode 100644 lldb/test/API/tools/lldb-dap/extendedStackTrace/Makefile delete mode 100644 lldb/test/API/tools/lldb-dap/extendedStackTrace/TestDAP_extendedStackTrace.py delete mode 100644 lldb/test/API/tools/lldb-dap/extendedStackTrace/main.m delete mode 100644 lldb/test/API/tools/lldb-dap/locations/Makefile delete mode 100644 lldb/test/API/tools/lldb-dap/locations/TestDAP_locations.py delete mode 100644 lldb/test/API/tools/lldb-dap/locations/main.c delete mode 100644 lldb/test/API/tools/lldb-dap/memory/Makefile delete mode 100644 lldb/test/API/tools/lldb-dap/memory/TestDAP_memory.py delete mode 100644 lldb/test/API/tools/lldb-dap/memory/main.cpp delete mode 100644 lldb/test/Shell/Recognizer/Inputs/verbose_trap-in-stl-callback-user-leaf.cpp delete mode 100644 lldb/test/Shell/Recognizer/Inputs/verbose_trap-in-stl-callback.cpp delete mode 100644 lldb/test/Shell/Recognizer/Inputs/verbose_trap-in-stl-max-depth.cpp delete mode 100644 lldb/test/Shell/Recognizer/Inputs/verbose_trap-in-stl-nested.cpp delete mode 100644 lldb/test/Shell/Recognizer/Inputs/verbose_trap-in-stl.cpp delete mode 100644 lldb/test/Shell/Recognizer/verbose_trap-in-stl-callback-user-leaf.test delete mode 100644 lldb/test/Shell/Recognizer/verbose_trap-in-stl-callback.test delete mode 100644 lldb/test/Shell/Recognizer/verbose_trap-in-stl-max-depth.test delete mode 100644 lldb/test/Shell/Recognizer/verbose_trap-in-stl-nested.test delete mode 100644 lldb/test/Shell/Recognizer/verbose_trap-in-stl.test delete mode 100644 lldb/test/Shell/SymbolFile/DWARF/no_unique_address-with-bitfields.cpp delete mode 100644 lldb/test/Shell/SymbolFile/DWARF/x86/type-unit-same-basename.cpp delete mode 100644 lldb/test/Shell/SymbolFile/Inputs/main.c delete mode 100644 lldb/test/Shell/SymbolFile/checksum-mismatch.test delete mode 100644 lldb/unittests/Process/Utility/CoreFileMemoryRangesTest.cpp delete mode 100644 lldb/unittests/Target/SummaryStatisticsTest.cpp delete mode 100644 llvm-spirv/test/OpDecorateString_UserSemantic_Builtin.spvasm delete mode 100644 llvm-spirv/test/extensions/INTEL/SPV_INTEL_function_pointers/CodeSectionINTEL/alias.ll delete mode 100644 llvm-spirv/test/extensions/INTEL/SPV_INTEL_function_pointers/CodeSectionINTEL/bitcast.ll delete mode 100644 llvm-spirv/test/extensions/INTEL/SPV_INTEL_function_pointers/CodeSectionINTEL/const-function-pointer.ll delete mode 100644 llvm-spirv/test/extensions/INTEL/SPV_INTEL_function_pointers/CodeSectionINTEL/decor-func-ptr-arg-attr.ll delete mode 100644 llvm-spirv/test/extensions/INTEL/SPV_INTEL_function_pointers/CodeSectionINTEL/fp-from-host.ll delete mode 100644 llvm-spirv/test/extensions/INTEL/SPV_INTEL_function_pointers/CodeSectionINTEL/function-pointer-as-function-arg.ll delete mode 100644 llvm-spirv/test/extensions/INTEL/SPV_INTEL_function_pointers/CodeSectionINTEL/function-pointer-dedicated-as.ll delete mode 100644 llvm-spirv/test/extensions/INTEL/SPV_INTEL_function_pointers/CodeSectionINTEL/function-pointer.ll delete mode 100644 llvm-spirv/test/extensions/INTEL/SPV_INTEL_function_pointers/CodeSectionINTEL/global-function-pointer.ll delete mode 100644 llvm-spirv/test/extensions/INTEL/SPV_INTEL_function_pointers/CodeSectionINTEL/global_ctor_dtor.ll delete mode 100644 llvm-spirv/test/extensions/INTEL/SPV_INTEL_function_pointers/CodeSectionINTEL/global_ctor_dtor_addrspace.ll delete mode 100644 llvm-spirv/test/extensions/INTEL/SPV_INTEL_function_pointers/CodeSectionINTEL/gv-func-ptr.ll delete mode 100644 llvm-spirv/test/extensions/INTEL/SPV_INTEL_function_pointers/CodeSectionINTEL/non-uniform-function-pointer.ll delete mode 100644 llvm-spirv/test/extensions/INTEL/SPV_INTEL_function_pointers/CodeSectionINTEL/referenced-indirectly.ll delete mode 100644 llvm-spirv/test/extensions/INTEL/SPV_INTEL_function_pointers/CodeSectionINTEL/select.ll delete mode 100644 llvm-spirv/test/extensions/KHR/SPV_KHR_untyped_pointers/untyped_ptr_access_chain.ll delete mode 100644 llvm-spirv/test/llvm-intrinsics/memset-align.ll delete mode 100644 llvm-spirv/test/llvm-intrinsics/scmp.ll delete mode 100644 llvm-spirv/test/llvm-intrinsics/ucmp.ll delete mode 100644 llvm-spirv/test/phi-multiple-predecessors.spvasm delete mode 100644 llvm/benchmarks/GetIntrinsicInfoTableEntriesBM.cpp delete mode 100644 llvm/benchmarks/SandboxIRBench.cpp delete mode 100644 llvm/include/llvm/CodeGen/MachineCSE.h delete mode 100644 llvm/include/llvm/CodeGen/MachineLICM.h create mode 100644 llvm/include/llvm/LTO/SummaryBasedOptimizations.h delete mode 100644 llvm/include/llvm/SandboxIR/Pass.h delete mode 100644 llvm/include/llvm/SandboxIR/PassManager.h delete mode 100644 llvm/include/llvm/Support/OptionStrCmp.h delete mode 100644 llvm/include/llvm/TableGen/AArch64ImmCheck.h delete mode 100644 llvm/include/llvm/Transforms/Coroutines/CoroAnnotationElide.h create mode 100644 llvm/include/llvm/Transforms/IPO/SyntheticCountsPropagation.h rename llvm/include/llvm/Transforms/{Utils => }/Instrumentation.h (100%) delete mode 100644 llvm/include/llvm/Transforms/Instrumentation/PGOCtxProfFlattening.h delete mode 100644 llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h delete mode 100644 llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/InstrInterval.h delete mode 100644 llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h delete mode 100644 llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h delete mode 100644 llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Region.h delete mode 100644 llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h delete mode 100644 llvm/lib/CodeGen/GlobalISel/CombinerHelperCompares.cpp create mode 100644 llvm/lib/LTO/SummaryBasedOptimizations.cpp delete mode 100644 llvm/lib/SandboxIR/Pass.cpp delete mode 100644 llvm/lib/SandboxIR/PassManager.cpp delete mode 100644 llvm/lib/Support/OptionStrCmp.cpp delete mode 100644 llvm/lib/Target/AArch64/AArch64SchedNeoverseN3.td mode change 100755 => 100644 llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp delete mode 100644 llvm/lib/Target/AMDGPU/SIPeepholeSDWA.h delete mode 100644 llvm/lib/Target/AMDGPU/SIShrinkInstructions.h delete mode 100644 llvm/lib/Target/DirectX/DirectXTargetTransformInfo.cpp delete mode 100644 llvm/lib/Target/RISCV/GISel/RISCVPostLegalizerLowering.cpp delete mode 100644 llvm/lib/Target/RISCV/RISCVCallingConv.cpp delete mode 100644 llvm/lib/Target/RISCV/RISCVCallingConv.h delete mode 100644 llvm/lib/Target/RISCV/RISCVConstantPoolValue.cpp delete mode 100644 llvm/lib/Target/RISCV/RISCVConstantPoolValue.h delete mode 100644 llvm/lib/Target/RISCV/RISCVSchedSyntacoreSCR7.td delete mode 100644 llvm/lib/Target/RISCV/RISCVZacasABIFix.cpp delete mode 100644 llvm/lib/Target/SPIRV/SPIRVAPI.cpp delete mode 100644 llvm/lib/Target/SPIRV/SPIRVAPI.h delete mode 100644 llvm/lib/Target/SPIRV/SPIRVStructurizer.cpp delete mode 100644 llvm/lib/Transforms/Coroutines/CoroAnnotationElide.cpp delete mode 100644 llvm/lib/Transforms/Coroutines/CoroShape.h delete mode 100644 llvm/lib/Transforms/Coroutines/MaterializationUtils.cpp delete mode 100644 llvm/lib/Transforms/Coroutines/MaterializationUtils.h delete mode 100644 llvm/lib/Transforms/Coroutines/SpillUtils.cpp delete mode 100644 llvm/lib/Transforms/Coroutines/SpillUtils.h delete mode 100644 llvm/lib/Transforms/Coroutines/SuspendCrossingInfo.cpp delete mode 100644 llvm/lib/Transforms/Coroutines/SuspendCrossingInfo.h create mode 100644 llvm/lib/Transforms/IPO/SyntheticCountsPropagation.cpp rename llvm/lib/Transforms/{Utils => Instrumentation}/Instrumentation.cpp (88%) delete mode 100644 llvm/lib/Transforms/Instrumentation/PGOCtxProfFlattening.cpp delete mode 100644 llvm/lib/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.cpp delete mode 100644 llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp delete mode 100644 llvm/lib/Transforms/Vectorize/SandboxVectorizer/Region.cpp delete mode 100644 llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp delete mode 100644 llvm/test/Analysis/CostModel/AArch64/extract_float.ll delete mode 100644 llvm/test/Analysis/CostModel/AArch64/fp-conversions-odd-vector-types.ll delete mode 100644 llvm/test/Analysis/CostModel/RISCV/cmp.ll delete mode 100644 llvm/test/Analysis/CtxProfAnalysis/flatten-always-removes-instrumentation.ll delete mode 100644 llvm/test/Analysis/CtxProfAnalysis/flatten-and-annotate.ll delete mode 100644 llvm/test/Analysis/CtxProfAnalysis/flatten-check-path.ll delete mode 100644 llvm/test/Analysis/CtxProfAnalysis/flatten-zero-path.ll delete mode 100644 llvm/test/Analysis/CtxProfAnalysis/inline.ll delete mode 100644 llvm/test/Analysis/CtxProfAnalysis/json_equals.py delete mode 100644 llvm/test/Analysis/CtxProfAnalysis/load-unapplicable.ll delete mode 100644 llvm/test/Analysis/Lint/noalias-null.ll delete mode 100644 llvm/test/Analysis/Lint/scalable.ll delete mode 100644 llvm/test/Analysis/ScalarEvolution/predicated-exit-count.ll delete mode 100644 llvm/test/Analysis/ScalarEvolution/udiv-of-x-xsmaxone-fold.ll rename llvm/test/Analysis/ValueTracking/{recurrence-knownbits.ll => shift-recurrence-knownbits.ll} (65%) delete mode 100644 llvm/test/Assembler/target-type-param-errors.ll delete mode 100644 llvm/test/Bitcode/intrinsics-struct-upgrade-attributes.ll create mode 100644 llvm/test/Bitcode/thinlto-synthetic-count-flag.ll delete mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/combine-cannonicalize-fcmp.mir delete mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/combine-canonicalize-icmp.mir delete mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/combine-narrow-binop.mir delete mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/vararg.mir delete mode 100644 llvm/test/CodeGen/AArch64/aarch64-sve2-faminmax.ll delete mode 100644 llvm/test/CodeGen/AArch64/atomicrmw-cond-sub-clamp.ll delete mode 100644 llvm/test/CodeGen/AArch64/cgdata-global-hash.ll delete mode 100644 llvm/test/CodeGen/AArch64/cgdata-outlined-name.ll delete mode 100644 llvm/test/CodeGen/AArch64/cgdata-read-double-outline.ll delete mode 100644 llvm/test/CodeGen/AArch64/cgdata-read-lto-outline.ll delete mode 100644 llvm/test/CodeGen/AArch64/cgdata-read-priority.ll delete mode 100644 llvm/test/CodeGen/AArch64/cgdata-read-single-outline-suffix.ll delete mode 100644 llvm/test/CodeGen/AArch64/cgdata-read-single-outline.ll delete mode 100644 llvm/test/CodeGen/AArch64/cgdata-write-outline.ll delete mode 100644 llvm/test/CodeGen/AArch64/ctlo.ll delete mode 100644 llvm/test/CodeGen/AArch64/fabs-fp128.ll delete mode 100644 llvm/test/CodeGen/AArch64/init-undef.mir delete mode 100644 llvm/test/CodeGen/AArch64/load-insert-undef.ll delete mode 100644 llvm/test/CodeGen/AArch64/machine-outliner-bundle.mir delete mode 100644 llvm/test/CodeGen/AArch64/neon-famin-famax.ll delete mode 100644 llvm/test/CodeGen/AArch64/neon-luti.ll delete mode 100644 llvm/test/CodeGen/AArch64/neon-partial-reduce-dot-product.ll delete mode 100644 llvm/test/CodeGen/AArch64/no-reorder-cfi-merge-back-load.mir delete mode 100644 llvm/test/CodeGen/AArch64/no-reorder-cfi-merge-back-store.mir delete mode 100644 llvm/test/CodeGen/AArch64/no-reorder-cfi-merge-fwd-load.mir delete mode 100644 llvm/test/CodeGen/AArch64/no-reorder-cfi-merge-fwd.mir delete mode 100644 llvm/test/CodeGen/AArch64/no-reorder-cfi-no-merge.mir delete mode 100644 llvm/test/CodeGen/AArch64/no-reorder-cfi.ll delete mode 100644 llvm/test/CodeGen/AArch64/sme2-intrinsics-faminmax.ll delete mode 100644 llvm/test/CodeGen/AArch64/sve-bf16-converts.ll delete mode 100644 llvm/test/CodeGen/AArch64/sve-partial-reduce-dot-product.ll delete mode 100644 llvm/test/CodeGen/AArch64/sve-scmp.ll delete mode 100644 llvm/test/CodeGen/AArch64/sve-ucmp.ll delete mode 100644 llvm/test/CodeGen/AArch64/sve2-intrinsics-faminmax.ll delete mode 100644 llvm/test/CodeGen/AArch64/sve2-intrinsics-luti.ll delete mode 100644 llvm/test/CodeGen/AArch64/vararg.ll delete mode 100644 llvm/test/CodeGen/AArch64/vecreduce-bitext.ll delete mode 100644 llvm/test/CodeGen/AArch64/zext-shuffle.ll delete mode 100644 llvm/test/CodeGen/AMDGPU/aa-as-infer.ll delete mode 100644 llvm/test/CodeGen/AMDGPU/amdgpu-sw-lower-lds-non-kernel-declaration.ll delete mode 100644 llvm/test/CodeGen/AMDGPU/eliminate-frame-index-v-add-co-u32-wave32.mir delete mode 100644 llvm/test/CodeGen/AMDGPU/fix-sgpr-copies-f16-fake16.mir delete mode 100644 llvm/test/CodeGen/AMDGPU/fix-sgpr-copies-f16-true16.mir delete mode 100644 llvm/test/CodeGen/AMDGPU/hazard-recognizer-src-shared-base.ll delete mode 100644 llvm/test/CodeGen/AMDGPU/llvm.amdgcn.init.whole.wave-w32.ll delete mode 100644 llvm/test/CodeGen/AMDGPU/llvm.amdgcn.init.whole.wave-w64.ll delete mode 100644 llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.buffer.prefetch.data.ll delete mode 100644 llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.prefetch.data.ll delete mode 100644 llvm/test/CodeGen/AMDGPU/load-constant-always-uniform.ll delete mode 100644 llvm/test/CodeGen/AMDGPU/maximumnum.ll delete mode 100644 llvm/test/CodeGen/AMDGPU/minimumnum.ll delete mode 100644 llvm/test/CodeGen/AMDGPU/si-init-whole-wave.mir delete mode 100644 llvm/test/CodeGen/AMDGPU/spill-wait.mir delete mode 100644 llvm/test/CodeGen/AMDGPU/valu-read-sgpr-hazard.mir delete mode 100644 llvm/test/CodeGen/ARM/atomicrmw-cond-sub-clamp.ll delete mode 100644 llvm/test/CodeGen/DirectX/BufferLoad.ll delete mode 100644 llvm/test/CodeGen/DirectX/BufferStore-errors.ll delete mode 100644 llvm/test/CodeGen/DirectX/BufferStore.ll delete mode 100644 llvm/test/CodeGen/DirectX/ContainerData/PSVResources.ll delete mode 100644 llvm/test/CodeGen/DirectX/ContainerData/RuntimeInfoCS.ll delete mode 100644 llvm/test/CodeGen/DirectX/countbits.ll delete mode 100644 llvm/test/CodeGen/DirectX/llc-pipeline.ll delete mode 100644 llvm/test/CodeGen/DirectX/scalar-store.ll delete mode 100644 llvm/test/CodeGen/DirectX/scalarize-two-calls.ll delete mode 100644 llvm/test/CodeGen/DirectX/sign.ll delete mode 100644 llvm/test/CodeGen/DirectX/sin_vector_error.ll delete mode 100644 llvm/test/CodeGen/DirectX/step.ll delete mode 100644 llvm/test/CodeGen/DirectX/wave_is_first_lane.ll delete mode 100644 llvm/test/CodeGen/Hexagon/atomicrmw-cond-sub-clamp.ll delete mode 100644 llvm/test/CodeGen/Hexagon/autohvx/addi-offset-opt-addr-mode.ll delete mode 100644 llvm/test/CodeGen/Hexagon/autohvx/addi-opt-predicated-def-bug.ll delete mode 100644 llvm/test/CodeGen/LoongArch/atomicrmw-cond-sub-clamp.ll delete mode 100644 llvm/test/CodeGen/LoongArch/ctpop-with-lsx.ll delete mode 100644 llvm/test/CodeGen/LoongArch/lasx/issue107355.ll delete mode 100644 llvm/test/CodeGen/LoongArch/statepoint-call-lowering-r1.ll delete mode 100644 llvm/test/CodeGen/LoongArch/statepoint-call-lowering.ll rename llvm/test/CodeGen/M68k/{Data => Arith}/sext-i1.ll (100%) delete mode 100644 llvm/test/CodeGen/M68k/Data/load-imm.ll rename llvm/test/CodeGen/M68k/{Data => }/link-unlnk.ll (100%) rename llvm/test/CodeGen/M68k/{Data => }/load-extend.ll (100%) delete mode 100644 llvm/test/CodeGen/MIR/Hexagon/addrmode-opt-nonreaching.mir delete mode 100644 llvm/test/CodeGen/Mips/Fast-ISel/underaligned-load-store.ll delete mode 100644 llvm/test/CodeGen/Mips/ins.ll delete mode 100644 llvm/test/CodeGen/Mips/is_fpclass.ll delete mode 100644 llvm/test/CodeGen/Mips/xor-and.ll delete mode 100644 llvm/test/CodeGen/NVPTX/convert-call-to-indirect.ll delete mode 100644 llvm/test/CodeGen/NVPTX/copysign.ll delete mode 100644 llvm/test/CodeGen/NVPTX/sext-setcc.ll delete mode 100644 llvm/test/CodeGen/PowerPC/atomicrmw-cond-sub-clamp.ll delete mode 100644 llvm/test/CodeGen/PowerPC/sms-recmii.ll delete mode 100644 llvm/test/CodeGen/RISCV/GlobalISel/double-intrinsics.ll delete mode 100644 llvm/test/CodeGen/RISCV/GlobalISel/float-intrinsics.ll delete mode 100644 llvm/test/CodeGen/RISCV/GlobalISel/irtranslator/splat_vector.ll create mode 100644 llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-fp-ceil-floor.mir delete mode 100644 llvm/test/CodeGen/RISCV/GlobalISel/stacksave-stackrestore.ll delete mode 100644 llvm/test/CodeGen/RISCV/atomicrmw-cond-sub-clamp.ll delete mode 100644 llvm/test/CodeGen/RISCV/fastcc-bf16.ll delete mode 100644 llvm/test/CodeGen/RISCV/fastcc-half.ll delete mode 100644 llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp-buildvec-bf16.ll delete mode 100644 llvm/test/CodeGen/RISCV/rvv/fixed-vectors-vfwmaccbf16.ll delete mode 100644 llvm/test/CodeGen/RISCV/rvv/load-bf16.ll delete mode 100644 llvm/test/CodeGen/RISCV/rvv/pr107950.ll delete mode 100644 llvm/test/CodeGen/RISCV/rvv/store-bf16.ll delete mode 100644 llvm/test/CodeGen/RISCV/rvv/vl-opt-no-prop.ll delete mode 100644 llvm/test/CodeGen/RISCV/rvv/vl-opt-op-info.ll delete mode 100644 llvm/test/CodeGen/RISCV/rvv/vl-opt.ll delete mode 100644 llvm/test/CodeGen/RISCV/rvv/vsplats-f16.ll rename llvm/test/CodeGen/SPIRV/debug-info/{debug-compilation-unit.ll => basic-global-di.ll} (94%) delete mode 100644 llvm/test/CodeGen/SPIRV/debug-info/debug-type-basic.ll delete mode 100644 llvm/test/CodeGen/SPIRV/debug-info/no-misplaced-opextinst.ll delete mode 100644 llvm/test/CodeGen/SPIRV/hlsl-intrinsics/WaveIsFirstLane.ll delete mode 100644 llvm/test/CodeGen/SPIRV/hlsl-intrinsics/countbits.ll delete mode 100644 llvm/test/CodeGen/SPIRV/hlsl-intrinsics/sign.ll delete mode 100644 llvm/test/CodeGen/SPIRV/hlsl-intrinsics/step.ll delete mode 100644 llvm/test/CodeGen/SPIRV/opt-gepoperator-of-gvar.ll create mode 100644 llvm/test/CodeGen/SPIRV/scfg-add-pre-headers.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.cond-op.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.do.break.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.do.continue.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.do.nested.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.for.break.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.for.continue.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.for.nested.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.for.plain.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.for.short-circuited-cond.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.if.const-cond.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.if.for.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.if.nested.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.if.plain.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.logical-and.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.logical-or.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.return.early.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.return.early.simple.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.return.void.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.switch.ifstmt.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.switch.ifstmt.simple.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.switch.ifstmt.simple2.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.switch.opswitch.literal.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.switch.opswitch.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.switch.opswitch.simple.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.while.break.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.while.continue.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.while.nested.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.while.plain.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/cf.while.short-circuited-cond.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/condition-linear.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/do-break.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/do-continue.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/do-nested.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/do-plain.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/logical-or.ll delete mode 100644 llvm/test/CodeGen/SPIRV/structurizer/return-early.ll delete mode 100644 llvm/test/CodeGen/SystemZ/args-14.ll delete mode 100644 llvm/test/CodeGen/SystemZ/args-15.ll delete mode 100644 llvm/test/CodeGen/SystemZ/args-16.ll delete mode 100644 llvm/test/CodeGen/SystemZ/args-17.ll delete mode 100644 llvm/test/CodeGen/SystemZ/args-18.ll delete mode 100644 llvm/test/CodeGen/SystemZ/args-19.ll delete mode 100644 llvm/test/CodeGen/SystemZ/args-20.ll delete mode 100644 llvm/test/CodeGen/SystemZ/args-21.ll delete mode 100644 llvm/test/CodeGen/Thumb2/mve-scmp.ll delete mode 100644 llvm/test/CodeGen/Thumb2/mve-ucmp.ll delete mode 100644 llvm/test/CodeGen/VE/Scalar/atomicrmw-cond-sub-clamp.ll delete mode 100644 llvm/test/CodeGen/WebAssembly/atomicrmw-cond-sub-clamp.ll rename llvm/test/CodeGen/WebAssembly/{cfg-stackify-eh-legacy.mir => cfg-stackify-eh.mir} (83%) delete mode 100644 llvm/test/CodeGen/WebAssembly/exception.ll rename llvm/test/CodeGen/WebAssembly/{exception-legacy.mir => exception.mir} (96%) delete mode 100644 llvm/test/CodeGen/WinEH/wineh-empty-seh-scope.ll delete mode 100644 llvm/test/CodeGen/X86/atomicrmw-cond-sub-clamp.ll delete mode 100644 llvm/test/CodeGen/X86/avx10.2-fma-commute.ll delete mode 100644 llvm/test/CodeGen/X86/avx10_2_512bf16-arith.ll delete mode 100644 llvm/test/CodeGen/X86/avx10_2_512bf16-intrinsics.ll delete mode 100644 llvm/test/CodeGen/X86/avx10_2_512satcvtds-intrinsics.ll delete mode 100644 llvm/test/CodeGen/X86/avx10_2bf16-arith.ll delete mode 100644 llvm/test/CodeGen/X86/avx10_2bf16-intrinsics.ll delete mode 100644 llvm/test/CodeGen/X86/avx10_2fptosi_satcvtds.ll delete mode 100644 llvm/test/CodeGen/X86/avx10_2satcvtds-intrinsics.ll delete mode 100644 llvm/test/CodeGen/X86/avx10_2satcvtds-x64-intrinsics.ll delete mode 100644 llvm/test/CodeGen/X86/avx512copy-intrinsics.ll delete mode 100644 llvm/test/CodeGen/X86/jump-table-size-section.ll delete mode 100644 llvm/test/CodeGen/X86/pr108728.ll delete mode 100644 llvm/test/CodeGen/X86/vector-compress.ll delete mode 100644 llvm/test/CodeGen/Xtensa/frameaddr-returnaddr.ll delete mode 100644 llvm/test/DebugInfo/Generic/debug-ranges-duplication.ll delete mode 100644 llvm/test/DebugInfo/X86/empty-line-info.ll create mode 100644 llvm/test/DebugInfo/X86/is_stmt-at-block-start.ll delete mode 100644 llvm/test/DebugInfo/type-finder-w-dbg-records.ll delete mode 100644 llvm/test/Demangle/ms-placeholder-return-type.test delete mode 100644 llvm/test/Instrumentation/sanitizers-naked.ll delete mode 100644 llvm/test/MC/AArch64/SVE/directive-arch-negative.s delete mode 100644 llvm/test/MC/Disassembler/X86/avx10.2-bf16-32.txt delete mode 100644 llvm/test/MC/Disassembler/X86/avx10.2-bf16-64.txt delete mode 100644 llvm/test/MC/Disassembler/X86/avx10.2-com-ef-32.txt delete mode 100644 llvm/test/MC/Disassembler/X86/avx10.2-com-ef-64.txt delete mode 100644 llvm/test/MC/Disassembler/X86/avx10.2-copy-32.txt delete mode 100644 llvm/test/MC/Disassembler/X86/avx10.2-copy-64.txt delete mode 100644 llvm/test/MC/Disassembler/X86/avx10.2-satcvtds-32.txt delete mode 100644 llvm/test/MC/Disassembler/X86/avx10.2-satcvtds-64.txt delete mode 100644 llvm/test/MC/WebAssembly/eh-assembly-legacy.s delete mode 100644 llvm/test/MC/WebAssembly/eh-assembly.s delete mode 100644 llvm/test/MC/X86/avx10.2-bf16-32-att.s delete mode 100644 llvm/test/MC/X86/avx10.2-bf16-32-intel.s delete mode 100644 llvm/test/MC/X86/avx10.2-bf16-64-att.s delete mode 100644 llvm/test/MC/X86/avx10.2-bf16-64-intel.s delete mode 100644 llvm/test/MC/X86/avx10.2-com-ef-32-att.s delete mode 100644 llvm/test/MC/X86/avx10.2-com-ef-32-intel.s delete mode 100644 llvm/test/MC/X86/avx10.2-com-ef-64-att.s delete mode 100644 llvm/test/MC/X86/avx10.2-com-ef-64-intel.s delete mode 100644 llvm/test/MC/X86/avx10.2-copy-32-att.s delete mode 100644 llvm/test/MC/X86/avx10.2-copy-32-intel.s delete mode 100644 llvm/test/MC/X86/avx10.2-copy-64-att.s delete mode 100644 llvm/test/MC/X86/avx10.2-copy-64-intel.s delete mode 100644 llvm/test/MC/X86/avx10_2satcvtds-32-att.s delete mode 100644 llvm/test/MC/X86/avx10_2satcvtds-32-intel.s delete mode 100644 llvm/test/MC/X86/avx10_2satcvtds-64-att.s delete mode 100644 llvm/test/MC/X86/avx10_2satcvtds-64-intel.s delete mode 100644 llvm/test/MachineVerifier/AMDGPU/fix-illegal-vector-copies.mir delete mode 100644 llvm/test/MachineVerifier/AMDGPU/lit.local.cfg rename llvm/test/MachineVerifier/{AMDGPU => }/register-killed-inside-loop.mir (95%) rename llvm/test/MachineVerifier/{AMDGPU => }/test_g_bitcast.mir (96%) rename llvm/test/MachineVerifier/{AMDGPU => }/test_g_intrinsic.mir (96%) rename llvm/test/MachineVerifier/{AMDGPU => }/test_g_intrinsic_w_side_effects.mir (96%) rename llvm/test/MachineVerifier/{AMDGPU => }/undef-should-only-be-set-on-subreg-defs.mir (93%) rename llvm/test/MachineVerifier/{AMDGPU => }/undef-virt-reg-entry-block.mir (87%) rename llvm/test/MachineVerifier/{AMDGPU => }/undef-virt-reg-nonentry-block.mir (91%) rename llvm/test/MachineVerifier/{AMDGPU => }/verifier-ec-subreg-liveness.mir (96%) rename llvm/test/MachineVerifier/{AMDGPU => }/verifier-implicit-virtreg-invalid-physreg-liveness.mir (94%) rename llvm/test/MachineVerifier/{AMDGPU => }/verifier-pseudo-terminators.mir (95%) rename llvm/test/MachineVerifier/{AMDGPU => }/verify-implicit-def.mir (96%) rename llvm/test/MachineVerifier/{AMDGPU => }/verify-reg-sequence.mir (98%) rename llvm/test/MachineVerifier/{AMDGPU => }/writelane_m0.mir (96%) delete mode 100644 llvm/test/Other/spirv-sim/branch.spv delete mode 100644 llvm/test/Other/spirv-sim/call.spv delete mode 100644 llvm/test/Other/spirv-sim/constant.spv delete mode 100644 llvm/test/Other/spirv-sim/lit.local.cfg delete mode 100644 llvm/test/Other/spirv-sim/loop.spv delete mode 100644 llvm/test/Other/spirv-sim/simple-bad-result.spv delete mode 100644 llvm/test/Other/spirv-sim/simple.spv delete mode 100644 llvm/test/Other/spirv-sim/simulator-args.spv delete mode 100644 llvm/test/Other/spirv-sim/switch.spv delete mode 100644 llvm/test/Other/spirv-sim/wave-get-lane-index.spv delete mode 100644 llvm/test/Other/spirv-sim/wave-read-lane-first.spv delete mode 100644 llvm/test/TableGen/intrinsic-duplicate-name.td delete mode 100644 llvm/test/TableGen/intrinsic-prefix-error.td create mode 100644 llvm/test/ThinLTO/X86/function_entry_count.ll delete mode 100644 llvm/test/Transforms/ConstraintElimination/monotonic-pointer-phis-chain-of-exits.ll delete mode 100644 llvm/test/Transforms/Coroutines/coro-transform-must-elide.ll delete mode 100644 llvm/test/Transforms/Coroutines/gh107139-split-in-scc.ll delete mode 100644 llvm/test/Transforms/EarlyCSE/materialize-align-assumptions.ll delete mode 100644 llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-comb-no-active-lanes-to-zero.ll delete mode 100644 llvm/test/Transforms/InstCombine/fmod.ll delete mode 100644 llvm/test/Transforms/InstCombine/fp-floor-ceil.ll delete mode 100644 llvm/test/Transforms/InstCombine/phi-with-multiple-unsimplifiable-values.ll delete mode 100644 llvm/test/Transforms/LoopDeletion/noalias.ll delete mode 100644 llvm/test/Transforms/LoopIdiom/LoongArch/lit.local.cfg delete mode 100644 llvm/test/Transforms/LoopIdiom/LoongArch/popcnt.ll delete mode 100644 llvm/test/Transforms/LoopStrengthReduce/duplicated-phis.ll delete mode 100644 llvm/test/Transforms/LoopVectorize/AArch64/call-costs.ll delete mode 100644 llvm/test/Transforms/LoopVectorize/AArch64/force-target-instruction-cost.ll delete mode 100644 llvm/test/Transforms/LoopVectorize/AArch64/mul-simplification.ll delete mode 100644 llvm/test/Transforms/LoopVectorize/RISCV/reg-usage-bf16.ll delete mode 100644 llvm/test/Transforms/LoopVectorize/RISCV/reg-usage-f16.ll delete mode 100644 llvm/test/Transforms/LoopVectorize/RISCV/vectorize-force-tail-with-evl-bin-unary-ops-args.ll delete mode 100644 llvm/test/Transforms/LoopVectorize/check-no-vectorize.ll delete mode 100644 llvm/test/Transforms/LoopVectorize/simple_early_exit.ll delete mode 100644 llvm/test/Transforms/LoopVectorize/use-iv-start-value.ll delete mode 100644 llvm/test/Transforms/LoopVectorize/vector-to-scalar-cast.ll delete mode 100644 llvm/test/Transforms/SLPVectorizer/AArch64/reduce-fadd.ll rename llvm/test/Transforms/SLPVectorizer/{ => RISCV}/reduction-whole-regs-loads.ll (53%) delete mode 100644 llvm/test/Transforms/SLPVectorizer/X86/arith-scmp.ll delete mode 100644 llvm/test/Transforms/SLPVectorizer/X86/arith-ucmp.ll delete mode 100644 llvm/test/Transforms/SLPVectorizer/X86/buildvector-postpone-for-dependency.ll delete mode 100644 llvm/test/Transforms/SLPVectorizer/X86/minbw-user-non-sizable.ll delete mode 100644 llvm/test/Transforms/SLPVectorizer/X86/multi-extracts-bv-combined.ll delete mode 100644 llvm/test/Transforms/SLPVectorizer/X86/multi-tracked-reduced-value.ll delete mode 100644 llvm/test/Transforms/SLPVectorizer/X86/phi-node-reshuffled-part.ll delete mode 100644 llvm/test/Transforms/SLPVectorizer/X86/reduced-val-extracted-and-externally-used.ll delete mode 100644 llvm/test/Transforms/SLPVectorizer/X86/trunc-node-reused.ll delete mode 100644 llvm/test/Transforms/SLPVectorizer/empty-struct.ll delete mode 100644 llvm/test/Transforms/SampleProfile/Inputs/pseudo-probe-stale-profile-toplev-func.prof delete mode 100644 llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-toplev-func.ll delete mode 100644 llvm/test/Transforms/SandboxVectorizer/X86/no_implicit_float.ll delete mode 100644 llvm/test/Transforms/SandboxVectorizer/boilerplate.ll delete mode 100644 llvm/test/Transforms/SandboxVectorizer/default_pass_pipeline.ll delete mode 100644 llvm/test/Transforms/SandboxVectorizer/user_pass_pipeline.ll delete mode 100644 llvm/test/Transforms/SimplifyCFG/patchpoint-invalid-sink.ll delete mode 100644 llvm/test/Transforms/SimplifyCFG/speculate-derefable-load.ll delete mode 100644 llvm/test/Transforms/SimplifyCFG/switch-branch-fold-indirectbr-102351.ll create mode 100644 llvm/test/Transforms/SyntheticCountsPropagation/initial.ll create mode 100644 llvm/test/Transforms/SyntheticCountsPropagation/prop.ll create mode 100644 llvm/test/Transforms/SyntheticCountsPropagation/scc.ll delete mode 100644 llvm/test/Transforms/VectorCombine/AArch64/shrink-types.ll delete mode 100644 llvm/test/Transforms/VectorCombine/RISCV/shuffle-of-intrinsics.ll delete mode 100644 llvm/test/Transforms/VectorCombine/X86/shuffle-of-intrinsics.ll delete mode 100644 llvm/test/Verifier/AMDGPU/intrinsic-prefetch.ll delete mode 100644 llvm/test/Verifier/rtsan-attrs.ll delete mode 100644 llvm/test/tools/llvm-mca/AArch64/Neoverse/N3-basic-instructions.s delete mode 100644 llvm/test/tools/llvm-mca/AArch64/Neoverse/N3-mte-instructions.s delete mode 100644 llvm/test/tools/llvm-mca/AArch64/Neoverse/N3-neon-instructions.s delete mode 100644 llvm/test/tools/llvm-mca/AArch64/Neoverse/N3-sve-instructions.s delete mode 100644 llvm/test/tools/llvm-mca/AArch64/Neoverse/N3-writeback.s delete mode 100644 llvm/test/tools/llvm-mca/RISCV/SyntacoreSCR/SCR7-ALU.s delete mode 100644 llvm/test/tools/llvm-mca/RISCV/SyntacoreSCR/SCR7-FPALU_D.s delete mode 100644 llvm/test/tools/llvm-mca/RISCV/SyntacoreSCR/SCR7-FPALU_S.s delete mode 100644 llvm/test/tools/llvm-mca/RISCV/SyntacoreSCR/SCR7-LSU.s delete mode 100644 llvm/test/tools/llvm-mca/X86/Znver4/partially-overlapping-group-resources.s create mode 100644 llvm/test/tools/llvm-split/AMDGPU/debug-name-hiding.ll create mode 100644 llvm/test/tools/llvm-split/AMDGPU/debug-non-kernel-root.ll delete mode 100644 llvm/test/tools/llvm-split/AMDGPU/recursive-search-2.ll delete mode 100644 llvm/test/tools/llvm-split/AMDGPU/recursive-search-8.ll delete mode 100644 llvm/tools/llvm-debuginfod-find/Opts.td delete mode 100644 llvm/unittests/SandboxIR/PassTest.cpp delete mode 100644 llvm/unittests/Target/SPIRV/SPIRVAPITest.cpp delete mode 100644 llvm/unittests/Transforms/Vectorize/SandboxVectorizer/CMakeLists.txt delete mode 100644 llvm/unittests/Transforms/Vectorize/SandboxVectorizer/DependencyGraphTest.cpp delete mode 100644 llvm/unittests/Transforms/Vectorize/SandboxVectorizer/InstrIntervalTest.cpp delete mode 100644 llvm/unittests/Transforms/Vectorize/SandboxVectorizer/LegalityTest.cpp delete mode 100644 llvm/unittests/Transforms/Vectorize/SandboxVectorizer/RegionTest.cpp create mode 100644 llvm/utils/gn/secondary/clang/tools/clang-rename/BUILD.gn create mode 100644 llvm/utils/gn/secondary/clang/unittests/Rename/BUILD.gn delete mode 100644 llvm/utils/gn/secondary/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/BUILD.gn delete mode 100644 llvm/utils/lit/tests/Inputs/escape-color/color-escaped.txt delete mode 100644 llvm/utils/lit/tests/Inputs/escape-color/color.txt delete mode 100644 llvm/utils/lit/tests/Inputs/escape-color/lit.cfg delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-glob/example_file1.input delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-glob/example_file2.input delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-glob/glob-echo.txt delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-glob/glob-mkdir.txt delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-glob/lit.cfg delete mode 100644 llvm/utils/lit/tests/escape-color.py delete mode 100644 llvm/utils/lit/tests/shtest-glob.py delete mode 100644 llvm/utils/spirv-sim/instructions.py delete mode 100755 llvm/utils/spirv-sim/spirv-sim.py delete mode 100644 mlir/docs/Dialects/OpenMPDialect/ODS.md delete mode 100644 mlir/docs/Dialects/OpenMPDialect/_index.md delete mode 100644 mlir/include/mlir/Conversion/VectorToXeGPU/VectorToXeGPU.h delete mode 100644 mlir/lib/Conversion/VectorToXeGPU/CMakeLists.txt delete mode 100644 mlir/lib/Conversion/VectorToXeGPU/VectorToXeGPU.cpp delete mode 100644 mlir/lib/Dialect/Tosa/Transforms/TosaReduceTransposes.cpp delete mode 100644 mlir/test/Conversion/AMDGPUToROCDL/wmma-gfx12.mlir delete mode 100644 mlir/test/Conversion/VectorToXeGPU/transfer-read-to-xegpu.mlir delete mode 100644 mlir/test/Conversion/VectorToXeGPU/transfer-write-to-xegpu.mlir delete mode 100644 mlir/test/Dialect/GPU/indirect-device-func-call.mlir delete mode 100644 mlir/test/Dialect/Mesh/inlining.mlir delete mode 100644 mlir/test/Dialect/Tosa/tosa-reduce-transposes.mlir delete mode 100644 mlir/test/Dialect/Transform/transform-state-extension-initializer.mlir delete mode 100644 mlir/test/Integration/Dialect/SparseTensor/python/test_all_dense.py delete mode 100644 mlir/test/Target/LLVMIR/omptarget-debug.mlir delete mode 100644 mlir/test/Target/LLVMIR/omptarget-debug2.mlir delete mode 100644 mlir/test/Target/LLVMIR/openmp-target-use-device-nested.mlir delete mode 100644 mlir/test/lib/Dialect/Transform/TestPassStateExtensionCommunication.cpp delete mode 100644 mlir/test/mlir-tblgen/openmp-clause-ops.td delete mode 100644 offload/DeviceRTL/include/DeviceUtils.h rename offload/DeviceRTL/include/{DeviceTypes.h => Types.h} (86%) create mode 100644 offload/DeviceRTL/include/Utils.h rename offload/DeviceRTL/src/{DeviceUtils.cpp => Utils.cpp} (90%) delete mode 100644 offload/include/Shared/RefCnt.h delete mode 100644 offload/test/offloading/fortran/target-map-dynamic.f90 delete mode 100644 utils/bazel/llvm-project-overlay/libc/test/src/sys/socket/BUILD.bazel diff --git a/.github/new-prs-labeler.yml b/.github/new-prs-labeler.yml index 8cc6c36fa945b..30ff1a4cf4868 100644 --- a/.github/new-prs-labeler.yml +++ b/.github/new-prs-labeler.yml @@ -668,7 +668,7 @@ mlgo: - llvm/lib/CodeGen/ML* - llvm/unittests/CodeGen/ML* - llvm/test/CodeGen/MLRegAlloc/** - - llvm/utils/mlgo-utils/** + - llvm/utils/mlgo-utils/* tools:llvm-exegesis: - llvm/tools/llvm-exegesis/** @@ -1008,8 +1008,3 @@ bazel: offload: - offload/** - -tablegen: - - llvm/include/TableGen/** - - llvm/lib/TableGen/** - - llvm/utils/TableGen/** diff --git a/.github/workflows/commit-access-review.py b/.github/workflows/commit-access-review.py index 8ea9b1fcc2fb0..97589c138c0b7 100644 --- a/.github/workflows/commit-access-review.py +++ b/.github/workflows/commit-access-review.py @@ -358,10 +358,11 @@ def main(): gh = github.Github(login_or_token=token) org = gh.get_organization("llvm") repo = org.get_repo("llvm-project") + team = org.get_team_by_slug("llvm-committers") one_year_ago = datetime.datetime.now() - datetime.timedelta(days=365) triage_list = {} - for collaborator in repo.get_collaborators(permission="push"): - triage_list[collaborator.login] = User(collaborator.login, triage_list) + for member in team.get_members(): + triage_list[member.login] = User(member.login, triage_list) print("Start:", len(triage_list), "triagers") # Step 0 Check if users have requested commit access in the last year. diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml index b5e60781e0006..1a26a699db8e0 100644 --- a/.github/workflows/libcxx-build-and-test.yaml +++ b/.github/workflows/libcxx-build-and-test.yaml @@ -242,7 +242,6 @@ jobs: - { config: mingw-dll, mingw: true } - { config: mingw-static, mingw: true } - { config: mingw-dll-i686, mingw: true } - - { config: mingw-incomplete-sysroot, mingw: true } steps: - uses: actions/checkout@v4 - name: Install dependencies @@ -261,12 +260,6 @@ jobs: del llvm-mingw*.zip mv llvm-mingw* c:\llvm-mingw echo "c:\llvm-mingw\bin" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append - - name: Simulate a from-scratch build of llvm-mingw - if: ${{ matrix.config == 'mingw-incomplete-sysroot' }} - run: | - rm -r c:\llvm-mingw\include\c++ - rm -r c:\llvm-mingw\*-w64-mingw32\lib\libc++* - rm -r c:\llvm-mingw\*-w64-mingw32\lib\libunwind* - name: Add Git Bash to the path run: | echo "c:\Program Files\Git\usr\bin" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append diff --git a/.github/workflows/release-binaries.yml b/.github/workflows/release-binaries.yml index 2341d5743e62d..bc83da221adb8 100644 --- a/.github/workflows/release-binaries.yml +++ b/.github/workflows/release-binaries.yml @@ -442,22 +442,11 @@ jobs: name: ${{ needs.prepare.outputs.release-binary-filename }}-attestation path: ${{ needs.prepare.outputs.release-binary-filename }}.jsonl - - name: Checkout Release Scripts - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - with: - sparse-checkout: | - llvm/utils/release/github-upload-release.py - llvm/utils/git/requirements.txt - sparse-checkout-cone-mode: false - - - name: Install Python Requirements - run: | - pip install --require-hashes -r ./llvm/utils/git/requirements.txt - - name: Upload Release shell: bash run: | - ./llvm/utils/release/github-upload-release.py \ + sudo apt install python3-github + ./llvm-project/llvm/utils/release/github-upload-release.py \ --token ${{ github.token }} \ --release ${{ needs.prepare.outputs.release-version }} \ upload \ diff --git a/bolt/include/bolt/Profile/ProfileYAMLMapping.h b/bolt/include/bolt/Profile/ProfileYAMLMapping.h index 9865118f2696d..2a0514d7d9304 100644 --- a/bolt/include/bolt/Profile/ProfileYAMLMapping.h +++ b/bolt/include/bolt/Profile/ProfileYAMLMapping.h @@ -95,29 +95,24 @@ template <> struct MappingTraits { namespace bolt { struct PseudoProbeInfo { - uint32_t InlineTreeIndex = 0; - uint64_t BlockMask = 0; // bitset with probe indices from 1 to 64 - std::vector BlockProbes; // block probes with indices above 64 - std::vector CallProbes; - std::vector IndCallProbes; - std::vector InlineTreeNodes; + llvm::yaml::Hex64 GUID; + uint64_t Index; + uint8_t Type; bool operator==(const PseudoProbeInfo &Other) const { - return InlineTreeIndex == Other.InlineTreeIndex && - BlockProbes == Other.BlockProbes && CallProbes == Other.CallProbes && - IndCallProbes == Other.IndCallProbes; + return GUID == Other.GUID && Index == Other.Index; + } + bool operator!=(const PseudoProbeInfo &Other) const { + return !(*this == Other); } }; } // end namespace bolt template <> struct MappingTraits { static void mapping(IO &YamlIO, bolt::PseudoProbeInfo &PI) { - YamlIO.mapOptional("blx", PI.BlockMask, 0); - YamlIO.mapOptional("blk", PI.BlockProbes, std::vector()); - YamlIO.mapOptional("call", PI.CallProbes, std::vector()); - YamlIO.mapOptional("icall", PI.IndCallProbes, std::vector()); - YamlIO.mapOptional("id", PI.InlineTreeIndex, 0); - YamlIO.mapOptional("ids", PI.InlineTreeNodes, std::vector()); + YamlIO.mapRequired("guid", PI.GUID); + YamlIO.mapRequired("id", PI.Index); + YamlIO.mapRequired("type", PI.Type); } static const bool flow = true; @@ -163,35 +158,15 @@ template <> struct MappingTraits { std::vector()); YamlIO.mapOptional("succ", BBP.Successors, std::vector()); - YamlIO.mapOptional("probes", BBP.PseudoProbes, + YamlIO.mapOptional("pseudo_probes", BBP.PseudoProbes, std::vector()); } }; -namespace bolt { -struct InlineTreeNode { - uint32_t ParentIndexDelta; - uint32_t CallSiteProbe; - // Index in PseudoProbeDesc.GUID, UINT32_MAX for same as previous (omitted) - uint32_t GUIDIndex; - bool operator==(const InlineTreeNode &) const { return false; } -}; -} // end namespace bolt - -template <> struct MappingTraits { - static void mapping(IO &YamlIO, bolt::InlineTreeNode &ITI) { - YamlIO.mapOptional("g", ITI.GUIDIndex, UINT32_MAX); - YamlIO.mapOptional("p", ITI.ParentIndexDelta, 0); - YamlIO.mapOptional("cs", ITI.CallSiteProbe, 0); - } - - static const bool flow = true; -}; } // end namespace yaml } // end namespace llvm LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::bolt::BinaryBasicBlockProfile) -LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(llvm::yaml::bolt::InlineTreeNode) namespace llvm { namespace yaml { @@ -204,7 +179,8 @@ struct BinaryFunctionProfile { llvm::yaml::Hex64 Hash{0}; uint64_t ExecCount{0}; std::vector Blocks; - std::vector InlineTree; + llvm::yaml::Hex64 GUID{0}; + llvm::yaml::Hex64 PseudoProbeDescHash{0}; bool Used{false}; }; } // end namespace bolt @@ -218,8 +194,9 @@ template <> struct MappingTraits { YamlIO.mapRequired("nblocks", BFP.NumBasicBlocks); YamlIO.mapOptional("blocks", BFP.Blocks, std::vector()); - YamlIO.mapOptional("inline_tree", BFP.InlineTree, - std::vector()); + YamlIO.mapOptional("guid", BFP.GUID, (uint64_t)0); + YamlIO.mapOptional("pseudo_probe_desc_hash", BFP.PseudoProbeDescHash, + (uint64_t)0); } }; @@ -269,33 +246,10 @@ template <> struct MappingTraits { } }; -namespace bolt { -struct ProfilePseudoProbeDesc { - std::vector GUID; - std::vector Hash; - std::vector GUIDHashIdx; // Index of hash for that GUID in Hash - - bool operator==(const ProfilePseudoProbeDesc &Other) const { - // Only treat empty Desc as equal - return GUID.empty() && Other.GUID.empty() && Hash.empty() && - Other.Hash.empty() && GUIDHashIdx.empty() && - Other.GUIDHashIdx.empty(); - } -}; -} // end namespace bolt - -template <> struct MappingTraits { - static void mapping(IO &YamlIO, bolt::ProfilePseudoProbeDesc &PD) { - YamlIO.mapRequired("gs", PD.GUID); - YamlIO.mapRequired("gh", PD.GUIDHashIdx); - YamlIO.mapRequired("hs", PD.Hash); - } -}; } // end namespace yaml } // end namespace llvm LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::bolt::BinaryFunctionProfile) -LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::bolt::ProfilePseudoProbeDesc) namespace llvm { namespace yaml { @@ -304,7 +258,6 @@ namespace bolt { struct BinaryProfile { BinaryProfileHeader Header; std::vector Functions; - ProfilePseudoProbeDesc PseudoProbeDesc; }; } // namespace bolt @@ -312,8 +265,6 @@ template <> struct MappingTraits { static void mapping(IO &YamlIO, bolt::BinaryProfile &BP) { YamlIO.mapRequired("header", BP.Header); YamlIO.mapRequired("functions", BP.Functions); - YamlIO.mapOptional("pseudo_probe_desc", BP.PseudoProbeDesc, - bolt::ProfilePseudoProbeDesc()); } }; diff --git a/bolt/include/bolt/Profile/YAMLProfileWriter.h b/bolt/include/bolt/Profile/YAMLProfileWriter.h index d4d7217464cc8..4a9355dfceac9 100644 --- a/bolt/include/bolt/Profile/YAMLProfileWriter.h +++ b/bolt/include/bolt/Profile/YAMLProfileWriter.h @@ -32,27 +32,8 @@ class YAMLProfileWriter { /// Save execution profile for that instance. std::error_code writeProfile(const RewriteInstance &RI); - using InlineTreeMapTy = - DenseMap; - struct InlineTreeDesc { - template using GUIDMapTy = std::unordered_map; - using GUIDNodeMap = GUIDMapTy; - using GUIDNumMap = GUIDMapTy; - GUIDNodeMap TopLevelGUIDToInlineTree; - GUIDNumMap GUIDIdxMap; - GUIDNumMap HashIdxMap; - }; - - static std::tuple, InlineTreeMapTy> - convertBFInlineTree(const MCPseudoProbeDecoder &Decoder, - const InlineTreeDesc &InlineTree, uint64_t GUID); - - static std::tuple - convertPseudoProbeDesc(const MCPseudoProbeDecoder &PseudoProbeDecoder); - static yaml::bolt::BinaryFunctionProfile convert(const BinaryFunction &BF, bool UseDFS, - const InlineTreeDesc &InlineTree, const BoltAddressTranslation *BAT = nullptr); /// Set CallSiteInfo destination fields from \p Symbol and return a target @@ -61,39 +42,8 @@ class YAMLProfileWriter { setCSIDestination(const BinaryContext &BC, yaml::bolt::CallSiteInfo &CSI, const MCSymbol *Symbol, const BoltAddressTranslation *BAT, uint32_t Offset = 0); - -private: - struct InlineTreeNode { - const MCDecodedPseudoProbeInlineTree *InlineTree; - uint64_t GUID; - uint64_t Hash; - uint32_t ParentId; - uint32_t InlineSite; - }; - static std::vector - collectInlineTree(const MCPseudoProbeDecoder &Decoder, - const MCDecodedPseudoProbeInlineTree &Root); - - // 0 - block probe, 1 - indirect call, 2 - direct call - using ProbeList = std::array, 3>; - using NodeIdToProbes = DenseMap; - static std::vector - convertNodeProbes(NodeIdToProbes &NodeProbes); - -public: - template - static std::vector - writeBlockProbes(T Probes, const InlineTreeMapTy &InlineTreeNodeId) { - NodeIdToProbes NodeProbes; - for (const MCDecodedPseudoProbe &Probe : Probes) { - auto It = InlineTreeNodeId.find(Probe.getInlineTreeNode()); - if (It == InlineTreeNodeId.end()) - continue; - NodeProbes[It->second][Probe.getType()].emplace_back(Probe.getIndex()); - } - return convertNodeProbes(NodeProbes); - } }; + } // namespace bolt } // namespace llvm diff --git a/bolt/include/bolt/Utils/Utils.h b/bolt/include/bolt/Utils/Utils.h index 9baee7d94066d..3886c5f8757c0 100644 --- a/bolt/include/bolt/Utils/Utils.h +++ b/bolt/include/bolt/Utils/Utils.h @@ -41,11 +41,6 @@ std::string getEscapedName(const StringRef &Name); /// Return the unescaped name std::string getUnescapedName(const StringRef &Name); -/// Return a common part for a given \p Name wrt a given \p Suffixes list. -/// Preserve the suffix if \p KeepSuffix is set, only dropping characters -/// following it, otherwise drop the suffix as well. -std::optional getCommonName(const StringRef Name, bool KeepSuffix, - ArrayRef Suffixes); /// LTO-generated function names take a form: /// /// .lto_priv./... diff --git a/bolt/lib/Passes/ADRRelaxationPass.cpp b/bolt/lib/Passes/ADRRelaxationPass.cpp index 256034a841c70..24fddbc764cbe 100644 --- a/bolt/lib/Passes/ADRRelaxationPass.cpp +++ b/bolt/lib/Passes/ADRRelaxationPass.cpp @@ -59,15 +59,10 @@ void ADRRelaxationPass::runOnFunction(BinaryFunction &BF) { // Don't relax adr if it points to the same function and it is not split // and BF initial size is < 1MB. const unsigned OneMB = 0x100000; - if (BF.getSize() < OneMB) { + if (!BF.isSplit() && BF.getSize() < OneMB) { BinaryFunction *TargetBF = BC.getFunctionForSymbol(Symbol); - if (TargetBF == &BF && !BF.isSplit()) + if (TargetBF && TargetBF == &BF) continue; - // No relaxation needed if ADR references a basic block in the same - // fragment. - if (BinaryBasicBlock *TargetBB = BF.getBasicBlockForLabel(Symbol)) - if (BB.getFragmentNum() == TargetBB->getFragmentNum()) - continue; } MCPhysReg Reg; diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp index fcde6f5f4642c..813d825f8b570 100644 --- a/bolt/lib/Profile/DataAggregator.cpp +++ b/bolt/lib/Profile/DataAggregator.cpp @@ -88,7 +88,7 @@ MaxSamples("max-samples", cl::cat(AggregatorCategory)); extern cl::opt ProfileFormat; -extern cl::opt ProfileWritePseudoProbes; +extern cl::opt ProfileUsePseudoProbes; extern cl::opt SaveProfile; cl::opt ReadPreAggregated( @@ -2300,7 +2300,7 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC, yaml::bolt::BinaryProfile BP; const MCPseudoProbeDecoder *PseudoProbeDecoder = - opts::ProfileWritePseudoProbes ? BC.getPseudoProbeDecoder() : nullptr; + opts::ProfileUsePseudoProbes ? BC.getPseudoProbeDecoder() : nullptr; // Fill out the header info. BP.Header.Version = 1; @@ -2321,12 +2321,6 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC, BP.Header.Flags = opts::BasicAggregation ? BinaryFunction::PF_SAMPLE : BinaryFunction::PF_LBR; - // Add probe inline tree nodes. - YAMLProfileWriter::InlineTreeDesc InlineTree; - if (PseudoProbeDecoder) - std::tie(BP.PseudoProbeDesc, InlineTree) = - YAMLProfileWriter::convertPseudoProbeDesc(*PseudoProbeDecoder); - if (!opts::BasicAggregation) { // Convert profile for functions not covered by BAT for (auto &BFI : BC.getBinaryFunctions()) { @@ -2335,8 +2329,8 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC, continue; if (BAT->isBATFunction(Function.getAddress())) continue; - BP.Functions.emplace_back(YAMLProfileWriter::convert( - Function, /*UseDFS=*/false, InlineTree, BAT)); + BP.Functions.emplace_back( + YAMLProfileWriter::convert(Function, /*UseDFS=*/false, BAT)); } for (const auto &KV : NamesToBranches) { @@ -2409,22 +2403,16 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC, YamlBF.Blocks[BlockIndex].ExecCount += BI.Branches; } if (PseudoProbeDecoder) { - DenseMap - InlineTreeNodeId; - if (BF->getGUID()) { - std::tie(YamlBF.InlineTree, InlineTreeNodeId) = - YAMLProfileWriter::convertBFInlineTree(*PseudoProbeDecoder, - InlineTree, BF->getGUID()); + if ((YamlBF.GUID = BF->getGUID())) { + const MCPseudoProbeFuncDesc *FuncDesc = + PseudoProbeDecoder->getFuncDescForGUID(YamlBF.GUID); + YamlBF.PseudoProbeDescHash = FuncDesc->FuncHash; } // Fetch probes belonging to all fragments const AddressProbesMap &ProbeMap = PseudoProbeDecoder->getAddress2ProbesMap(); BinaryFunction::FragmentsSetTy Fragments(BF->Fragments); Fragments.insert(BF); - DenseMap< - uint32_t, - std::vector>> - BlockProbes; for (const BinaryFunction *F : Fragments) { const uint64_t FuncAddr = F->getAddress(); for (const MCDecodedPseudoProbe &Probe : @@ -2433,24 +2421,17 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC, const uint32_t InputOffset = BAT->translate( FuncAddr, OutputAddress - FuncAddr, /*IsBranchSrc=*/true); const unsigned BlockIndex = getBlock(InputOffset).second; - BlockProbes[BlockIndex].emplace_back(Probe); + YamlBF.Blocks[BlockIndex].PseudoProbes.emplace_back( + yaml::bolt::PseudoProbeInfo{Probe.getGuid(), Probe.getIndex(), + Probe.getType()}); } } - - for (auto &[Block, Probes] : BlockProbes) { - YamlBF.Blocks[Block].PseudoProbes = - YAMLProfileWriter::writeBlockProbes(Probes, InlineTreeNodeId); - } } - // Skip printing if there's no profile data - llvm::erase_if( - YamlBF.Blocks, [](const yaml::bolt::BinaryBasicBlockProfile &YamlBB) { - auto HasCount = [](const auto &SI) { return SI.Count; }; - bool HasAnyCount = YamlBB.ExecCount || - llvm::any_of(YamlBB.Successors, HasCount) || - llvm::any_of(YamlBB.CallSites, HasCount); - return !HasAnyCount; - }); + // Drop blocks without a hash, won't be useful for stale matching. + llvm::erase_if(YamlBF.Blocks, + [](const yaml::bolt::BinaryBasicBlockProfile &YamlBB) { + return YamlBB.Hash == (yaml::Hex64)0; + }); BP.Functions.emplace_back(YamlBF); } } diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 67ed32017667d..3eca5e972fa5b 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -49,6 +49,11 @@ llvm::cl::opt llvm::cl::opt ProfileUseDFS("profile-use-dfs", cl::desc("use DFS order for YAML profile"), cl::Hidden, cl::cat(BoltOptCategory)); + +llvm::cl::opt ProfileUsePseudoProbes( + "profile-use-pseudo-probes", + cl::desc("Use pseudo probes for profile generation and matching"), + cl::Hidden, cl::cat(BoltOptCategory)); } // namespace opts namespace llvm { @@ -368,7 +373,6 @@ Error YAMLProfileReader::preprocessProfile(BinaryContext &BC) { return errorCodeToError(EC); } yaml::Input YamlInput(MB.get()->getBuffer()); - YamlInput.setAllowUnknownKeys(true); // Consume YAML file. YamlInput >> YamlBP; diff --git a/bolt/lib/Profile/YAMLProfileWriter.cpp b/bolt/lib/Profile/YAMLProfileWriter.cpp index 4437be423ff43..f74cf60e076d0 100644 --- a/bolt/lib/Profile/YAMLProfileWriter.cpp +++ b/bolt/lib/Profile/YAMLProfileWriter.cpp @@ -13,8 +13,6 @@ #include "bolt/Profile/DataAggregator.h" #include "bolt/Profile/ProfileReaderBase.h" #include "bolt/Rewrite/RewriteInstance.h" -#include "bolt/Utils/CommandLineOpts.h" -#include "llvm/MC/MCPseudoProbe.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/raw_ostream.h" @@ -23,12 +21,8 @@ #define DEBUG_TYPE "bolt-prof" namespace opts { -using namespace llvm; -extern cl::opt ProfileUseDFS; -cl::opt ProfileWritePseudoProbes( - "profile-write-pseudo-probes", - cl::desc("Use pseudo probes in profile generation"), cl::Hidden, - cl::cat(BoltOptCategory)); +extern llvm::cl::opt ProfileUseDFS; +extern llvm::cl::opt ProfileUsePseudoProbes; } // namespace opts namespace llvm { @@ -59,164 +53,13 @@ const BinaryFunction *YAMLProfileWriter::setCSIDestination( return nullptr; } -std::vector -YAMLProfileWriter::collectInlineTree( - const MCPseudoProbeDecoder &Decoder, - const MCDecodedPseudoProbeInlineTree &Root) { - auto getHash = [&](const MCDecodedPseudoProbeInlineTree &Node) { - return Decoder.getFuncDescForGUID(Node.Guid)->FuncHash; - }; - std::vector InlineTree( - {InlineTreeNode{&Root, Root.Guid, getHash(Root), 0, 0}}); - uint32_t ParentId = 0; - while (ParentId != InlineTree.size()) { - const MCDecodedPseudoProbeInlineTree *Cur = InlineTree[ParentId].InlineTree; - for (const MCDecodedPseudoProbeInlineTree &Child : Cur->getChildren()) - InlineTree.emplace_back( - InlineTreeNode{&Child, Child.Guid, getHash(Child), ParentId, - std::get<1>(Child.getInlineSite())}); - ++ParentId; - } - - return InlineTree; -} - -std::tuple -YAMLProfileWriter::convertPseudoProbeDesc(const MCPseudoProbeDecoder &Decoder) { - yaml::bolt::ProfilePseudoProbeDesc Desc; - InlineTreeDesc InlineTree; - - for (const MCDecodedPseudoProbeInlineTree &TopLev : - Decoder.getDummyInlineRoot().getChildren()) - InlineTree.TopLevelGUIDToInlineTree[TopLev.Guid] = &TopLev; - - for (const auto &FuncDesc : Decoder.getGUID2FuncDescMap()) - ++InlineTree.HashIdxMap[FuncDesc.FuncHash]; - - InlineTree.GUIDIdxMap.reserve(Decoder.getGUID2FuncDescMap().size()); - for (const auto &Node : Decoder.getInlineTreeVec()) - ++InlineTree.GUIDIdxMap[Node.Guid]; - - std::vector> GUIDFreqVec; - GUIDFreqVec.reserve(InlineTree.GUIDIdxMap.size()); - for (const auto [GUID, Cnt] : InlineTree.GUIDIdxMap) - GUIDFreqVec.emplace_back(Cnt, GUID); - llvm::sort(GUIDFreqVec); - - std::vector> HashFreqVec; - HashFreqVec.reserve(InlineTree.HashIdxMap.size()); - for (const auto [Hash, Cnt] : InlineTree.HashIdxMap) - HashFreqVec.emplace_back(Cnt, Hash); - llvm::sort(HashFreqVec); - - uint32_t Index = 0; - Desc.Hash.reserve(HashFreqVec.size()); - for (uint64_t Hash : llvm::make_second_range(llvm::reverse(HashFreqVec))) { - Desc.Hash.emplace_back(Hash); - InlineTree.HashIdxMap[Hash] = Index++; - } - - Index = 0; - Desc.GUID.reserve(GUIDFreqVec.size()); - for (uint64_t GUID : llvm::make_second_range(llvm::reverse(GUIDFreqVec))) { - Desc.GUID.emplace_back(GUID); - InlineTree.GUIDIdxMap[GUID] = Index++; - uint64_t Hash = Decoder.getFuncDescForGUID(GUID)->FuncHash; - Desc.GUIDHashIdx.emplace_back(InlineTree.HashIdxMap[Hash]); - } - - return {Desc, InlineTree}; -} - -std::vector -YAMLProfileWriter::convertNodeProbes(NodeIdToProbes &NodeProbes) { - struct BlockProbeInfoHasher { - size_t operator()(const yaml::bolt::PseudoProbeInfo &BPI) const { - auto HashCombine = [](auto &Range) { - return llvm::hash_combine_range(Range.begin(), Range.end()); - }; - return llvm::hash_combine(HashCombine(BPI.BlockProbes), - HashCombine(BPI.CallProbes), - HashCombine(BPI.IndCallProbes)); - } - }; - - // Check identical BlockProbeInfo structs and merge them - std::unordered_map, - BlockProbeInfoHasher> - BPIToNodes; - for (auto &[NodeId, Probes] : NodeProbes) { - yaml::bolt::PseudoProbeInfo BPI; - BPI.BlockProbes = std::vector(Probes[0].begin(), Probes[0].end()); - BPI.IndCallProbes = std::vector(Probes[1].begin(), Probes[1].end()); - BPI.CallProbes = std::vector(Probes[2].begin(), Probes[2].end()); - BPIToNodes[BPI].push_back(NodeId); - } - - auto handleMask = [](const auto &Ids, auto &Vec, auto &Mask) { - for (auto Id : Ids) - if (Id > 64) - Vec.emplace_back(Id); - else - Mask |= 1ull << (Id - 1); - }; - - // Add to YAML with merged nodes/block mask optimizations - std::vector YamlProbes; - YamlProbes.reserve(BPIToNodes.size()); - for (const auto &[BPI, Nodes] : BPIToNodes) { - auto &YamlBPI = YamlProbes.emplace_back(yaml::bolt::PseudoProbeInfo()); - YamlBPI.CallProbes = BPI.CallProbes; - YamlBPI.IndCallProbes = BPI.IndCallProbes; - if (Nodes.size() == 1) - YamlBPI.InlineTreeIndex = Nodes.front(); - else - YamlBPI.InlineTreeNodes = Nodes; - handleMask(BPI.BlockProbes, YamlBPI.BlockProbes, YamlBPI.BlockMask); - } - return YamlProbes; -} - -std::tuple, - YAMLProfileWriter::InlineTreeMapTy> -YAMLProfileWriter::convertBFInlineTree(const MCPseudoProbeDecoder &Decoder, - const InlineTreeDesc &InlineTree, - uint64_t GUID) { - DenseMap InlineTreeNodeId; - std::vector YamlInlineTree; - auto It = InlineTree.TopLevelGUIDToInlineTree.find(GUID); - if (It == InlineTree.TopLevelGUIDToInlineTree.end()) - return {YamlInlineTree, InlineTreeNodeId}; - const MCDecodedPseudoProbeInlineTree *Root = It->second; - assert(Root && "Malformed TopLevelGUIDToInlineTree"); - uint32_t Index = 0; - uint32_t PrevParent = 0; - uint32_t PrevGUIDIdx = 0; - for (const auto &Node : collectInlineTree(Decoder, *Root)) { - InlineTreeNodeId[Node.InlineTree] = Index++; - auto GUIDIdxIt = InlineTree.GUIDIdxMap.find(Node.GUID); - assert(GUIDIdxIt != InlineTree.GUIDIdxMap.end() && "Malformed GUIDIdxMap"); - uint32_t GUIDIdx = GUIDIdxIt->second; - if (GUIDIdx == PrevGUIDIdx) - GUIDIdx = UINT32_MAX; - else - PrevGUIDIdx = GUIDIdx; - YamlInlineTree.emplace_back(yaml::bolt::InlineTreeNode{ - Node.ParentId - PrevParent, Node.InlineSite, GUIDIdx}); - PrevParent = Node.ParentId; - } - return {YamlInlineTree, InlineTreeNodeId}; -} - yaml::bolt::BinaryFunctionProfile YAMLProfileWriter::convert(const BinaryFunction &BF, bool UseDFS, - const InlineTreeDesc &InlineTree, const BoltAddressTranslation *BAT) { yaml::bolt::BinaryFunctionProfile YamlBF; const BinaryContext &BC = BF.getBinaryContext(); const MCPseudoProbeDecoder *PseudoProbeDecoder = - opts::ProfileWritePseudoProbes ? BC.getPseudoProbeDecoder() : nullptr; + opts::ProfileUsePseudoProbes ? BC.getPseudoProbeDecoder() : nullptr; const uint16_t LBRProfile = BF.getProfileFlags() & BinaryFunction::PF_LBR; @@ -229,10 +72,12 @@ YAMLProfileWriter::convert(const BinaryFunction &BF, bool UseDFS, YamlBF.Hash = BF.getHash(); YamlBF.NumBasicBlocks = BF.size(); YamlBF.ExecCount = BF.getKnownExecutionCount(); - DenseMap InlineTreeNodeId; - if (PseudoProbeDecoder && BF.getGUID()) { - std::tie(YamlBF.InlineTree, InlineTreeNodeId) = - convertBFInlineTree(*PseudoProbeDecoder, InlineTree, BF.getGUID()); + if (PseudoProbeDecoder) { + if ((YamlBF.GUID = BF.getGUID())) { + const MCPseudoProbeFuncDesc *FuncDesc = + PseudoProbeDecoder->getFuncDescForGUID(YamlBF.GUID); + YamlBF.PseudoProbeDescHash = FuncDesc->FuncHash; + } } BinaryFunction::BasicBlockOrderType Order; @@ -348,10 +193,10 @@ YAMLProfileWriter::convert(const BinaryFunction &BF, bool UseDFS, const uint64_t FuncAddr = BF.getAddress(); const std::pair &BlockRange = BB->getInputAddressRange(); - const std::pair BlockAddrRange = { - FuncAddr + BlockRange.first, FuncAddr + BlockRange.second}; - auto Probes = ProbeMap.find(BlockAddrRange.first, BlockAddrRange.second); - YamlBB.PseudoProbes = writeBlockProbes(Probes, InlineTreeNodeId); + for (const MCDecodedPseudoProbe &Probe : ProbeMap.find( + FuncAddr + BlockRange.first, FuncAddr + BlockRange.second)) + YamlBB.PseudoProbes.emplace_back(yaml::bolt::PseudoProbeInfo{ + Probe.getGuid(), Probe.getIndex(), Probe.getType()}); } YamlBF.Blocks.emplace_back(YamlBB); @@ -406,12 +251,6 @@ std::error_code YAMLProfileWriter::writeProfile(const RewriteInstance &RI) { } BP.Header.Flags = ProfileFlags; - // Add probe inline tree nodes. - InlineTreeDesc InlineTree; - if (const MCPseudoProbeDecoder *Decoder = - opts::ProfileWritePseudoProbes ? BC.getPseudoProbeDecoder() : nullptr) - std::tie(BP.PseudoProbeDesc, InlineTree) = convertPseudoProbeDesc(*Decoder); - // Add all function objects. for (const auto &BFI : Functions) { const BinaryFunction &BF = BFI.second; @@ -419,7 +258,7 @@ std::error_code YAMLProfileWriter::writeProfile(const RewriteInstance &RI) { if (!BF.hasValidProfile() && !RI.getProfileReader()->isTrustedSource()) continue; - BP.Functions.emplace_back(convert(BF, opts::ProfileUseDFS, InlineTree)); + BP.Functions.emplace_back(convert(BF, opts::ProfileUseDFS)); } } diff --git a/bolt/lib/Rewrite/PseudoProbeRewriter.cpp b/bolt/lib/Rewrite/PseudoProbeRewriter.cpp index 8647df4b0edf8..4925b4b385d9b 100644 --- a/bolt/lib/Rewrite/PseudoProbeRewriter.cpp +++ b/bolt/lib/Rewrite/PseudoProbeRewriter.cpp @@ -14,7 +14,6 @@ #include "bolt/Rewrite/MetadataRewriter.h" #include "bolt/Rewrite/MetadataRewriters.h" #include "bolt/Utils/CommandLineOpts.h" -#include "bolt/Utils/Utils.h" #include "llvm/IR/Function.h" #include "llvm/MC/MCPseudoProbe.h" #include "llvm/Support/CommandLine.h" @@ -50,7 +49,7 @@ static cl::opt PrintPseudoProbes( clEnumValN(PPP_All, "all", "enable all debugging printout")), cl::Hidden, cl::cat(BoltCategory)); -extern cl::opt ProfileWritePseudoProbes; +extern cl::opt ProfileUsePseudoProbes; } // namespace opts namespace { @@ -72,8 +71,7 @@ class PseudoProbeRewriter final : public MetadataRewriter { /// Parse .pseudo_probe_desc section and .pseudo_probe section /// Setup Pseudo probe decoder - /// If \p ProfiledOnly is set, only parse records for functions with profile. - void parsePseudoProbe(bool ProfiledOnly = false); + void parsePseudoProbe(); /// PseudoProbe decoder std::shared_ptr ProbeDecoderPtr; @@ -92,21 +90,21 @@ class PseudoProbeRewriter final : public MetadataRewriter { }; Error PseudoProbeRewriter::preCFGInitializer() { - if (opts::ProfileWritePseudoProbes) - parsePseudoProbe(true); + if (opts::ProfileUsePseudoProbes) + parsePseudoProbe(); return Error::success(); } Error PseudoProbeRewriter::postEmitFinalizer() { - if (!opts::ProfileWritePseudoProbes) + if (!opts::ProfileUsePseudoProbes) parsePseudoProbe(); updatePseudoProbes(); return Error::success(); } -void PseudoProbeRewriter::parsePseudoProbe(bool ProfiledOnly) { +void PseudoProbeRewriter::parsePseudoProbe() { MCPseudoProbeDecoder &ProbeDecoder(*ProbeDecoderPtr); PseudoProbeDescSection = BC.getUniqueSectionByName(".pseudo_probe_desc"); PseudoProbeSection = BC.getUniqueSectionByName(".pseudo_probe"); @@ -135,22 +133,10 @@ void PseudoProbeRewriter::parsePseudoProbe(bool ProfiledOnly) { MCPseudoProbeDecoder::Uint64Set GuidFilter; MCPseudoProbeDecoder::Uint64Map FuncStartAddrs; - SmallVector Suffixes( - {".destroy", ".resume", ".llvm.", ".cold", ".warm"}); for (const BinaryFunction *F : BC.getAllBinaryFunctions()) { - bool HasProfile = F->hasProfileAvailable(); for (const MCSymbol *Sym : F->getSymbols()) { - StringRef SymName = Sym->getName(); - for (auto Name : {std::optional(NameResolver::restore(SymName)), - getCommonName(SymName, false, Suffixes)}) { - if (!Name) - continue; - SymName = *Name; - uint64_t GUID = Function::getGUID(SymName); - FuncStartAddrs[GUID] = F->getAddress(); - if (ProfiledOnly && HasProfile) - GuidFilter.insert(GUID); - } + FuncStartAddrs[Function::getGUID(NameResolver::restore(Sym->getName()))] = + F->getAddress(); } } Contents = PseudoProbeSection->getContents(); @@ -169,25 +155,13 @@ void PseudoProbeRewriter::parsePseudoProbe(bool ProfiledOnly) { ProbeDecoder.printProbesForAllAddresses(outs()); } - const GUIDProbeFunctionMap &GUID2Func = ProbeDecoder.getGUID2FuncDescMap(); - // Checks GUID in GUID2Func and returns it if it's present or null otherwise. - auto checkGUID = [&](StringRef SymName) -> uint64_t { - uint64_t GUID = Function::getGUID(SymName); - if (GUID2Func.find(GUID) == GUID2Func.end()) - return 0; - return GUID; - }; - for (BinaryFunction *F : BC.getAllBinaryFunctions()) { - for (const MCSymbol *Sym : F->getSymbols()) { - StringRef SymName = NameResolver::restore(Sym->getName()); - uint64_t GUID = checkGUID(SymName); - std::optional CommonName = - getCommonName(SymName, false, Suffixes); - if (!GUID && CommonName) - GUID = checkGUID(*CommonName); - if (GUID) - F->setGUID(GUID); - } + for (const auto &FuncDesc : ProbeDecoder.getGUID2FuncDescMap()) { + uint64_t GUID = FuncDesc.FuncGUID; + if (!FuncStartAddrs.contains(GUID)) + continue; + BinaryFunction *BF = BC.getBinaryFunctionAtAddress(FuncStartAddrs[GUID]); + assert(BF); + BF->setGUID(GUID); } } diff --git a/bolt/lib/Utils/Utils.cpp b/bolt/lib/Utils/Utils.cpp index ecc2f1010a985..718e97535fd22 100644 --- a/bolt/lib/Utils/Utils.cpp +++ b/bolt/lib/Utils/Utils.cpp @@ -66,21 +66,15 @@ std::string getUnescapedName(const StringRef &Name) { return Output; } -std::optional getCommonName(const StringRef Name, bool KeepSuffix, - ArrayRef Suffixes) { - for (StringRef Suffix : Suffixes) { +std::optional getLTOCommonName(const StringRef Name) { + for (StringRef Suffix : {".__uniq.", ".lto_priv.", ".constprop.", ".llvm."}) { size_t LTOSuffixPos = Name.find(Suffix); if (LTOSuffixPos != StringRef::npos) - return Name.substr(0, LTOSuffixPos + (KeepSuffix ? Suffix.size() : 0)); + return Name.substr(0, LTOSuffixPos + Suffix.size()); } return std::nullopt; } -std::optional getLTOCommonName(const StringRef Name) { - return getCommonName(Name, true, - {".__uniq.", ".lto_priv.", ".constprop.", ".llvm."}); -} - std::optional readDWARFExpressionTargetReg(StringRef ExprBytes) { uint8_t Opcode = ExprBytes[0]; if (Opcode == dwarf::DW_CFA_def_cfa_expression) diff --git a/bolt/test/X86/pseudoprobe-decoding-inline.test b/bolt/test/X86/pseudoprobe-decoding-inline.test index e5e8aadc18f9e..b361551e5711e 100644 --- a/bolt/test/X86/pseudoprobe-decoding-inline.test +++ b/bolt/test/X86/pseudoprobe-decoding-inline.test @@ -6,39 +6,37 @@ # PREAGG: B X:0 #main# 1 0 ## Check pseudo-probes in regular YAML profile (non-BOLTed binary) # RUN: link_fdata %s %S/../../../llvm/test/tools/llvm-profgen/Inputs/inline-cs-pseudoprobe.perfbin %t.preagg PREAGG -# RUN: perf2bolt %S/../../../llvm/test/tools/llvm-profgen/Inputs/inline-cs-pseudoprobe.perfbin -p %t.preagg --pa -w %t.yaml -o %t.fdata --profile-write-pseudo-probes +# RUN: perf2bolt %S/../../../llvm/test/tools/llvm-profgen/Inputs/inline-cs-pseudoprobe.perfbin -p %t.preagg --pa -w %t.yaml -o %t.fdata --profile-use-pseudo-probes # RUN: FileCheck --input-file %t.yaml %s --check-prefix CHECK-YAML ## Check pseudo-probes in BAT YAML profile (BOLTed binary) # RUN: link_fdata %s %t.bolt %t.preagg2 PREAGG -# RUN: perf2bolt %t.bolt -p %t.preagg2 --pa -w %t.yaml2 -o %t.fdata2 --profile-write-pseudo-probes +# RUN: perf2bolt %t.bolt -p %t.preagg2 --pa -w %t.yaml2 -o %t.fdata2 --profile-use-pseudo-probes # RUN: FileCheck --input-file %t.yaml2 %s --check-prefix CHECK-YAML # CHECK-YAML: name: bar # CHECK-YAML: - bid: 0 -# CHECK-YAML: probes: [ { blx: 9 } ] -# CHECK-YAML: inline_tree: [ { } ] +# CHECK-YAML: pseudo_probes: [ { guid: 0xE413754A191DB537, id: 1, type: 0 }, { guid: 0xE413754A191DB537, id: 4, type: 0 } ] +# CHECK-YAML: guid: 0xE413754A191DB537 +# CHECK-YAML: pseudo_probe_desc_hash: 0x10E852DA94 # # CHECK-YAML: name: foo # CHECK-YAML: - bid: 0 -# CHECK-YAML: probes: [ { blx: 3 } ] -# CHECK-YAML: inline_tree: [ { g: 1 }, { g: 0, cs: 8 } ] +# CHECK-YAML: pseudo_probes: [ { guid: 0x5CF8C24CDB18BDAC, id: 1, type: 0 }, { guid: 0x5CF8C24CDB18BDAC, id: 2, type: 0 } ] +# CHECK-YAML: guid: 0x5CF8C24CDB18BDAC +# CHECK-YAML: pseudo_probe_desc_hash: 0x200205A19C5B4 # # CHECK-YAML: name: main # CHECK-YAML: - bid: 0 -# CHECK-YAML: probes: [ { blx: 3, id: 1 }, { blx: 1 } ] -# CHECK-YAML: inline_tree: [ { g: 2 }, { g: 1, cs: 2 }, { g: 0, p: 1, cs: 8 } ] +# CHECK-YAML: pseudo_probes: [ { guid: 0xDB956436E78DD5FA, id: 1, type: 0 }, { guid: 0x5CF8C24CDB18BDAC, id: 1, type: 0 }, { guid: 0x5CF8C24CDB18BDAC, id: 2, type: 0 } ] +# CHECK-YAML: guid: 0xDB956436E78DD5FA +# CHECK-YAML: pseudo_probe_desc_hash: 0x10000FFFFFFFF # -# CHECK-YAML: pseudo_probe_desc: -# CHECK-YAML-NEXT: gs: [ 0xE413754A191DB537, 0x5CF8C24CDB18BDAC, 0xDB956436E78DD5FA ] -# CHECK-YAML-NEXT: gh: [ 2, 0, 1 ] -# CHECK-YAML-NEXT: hs: [ 0x200205A19C5B4, 0x10000FFFFFFFF, 0x10E852DA94 ] -# -## Check that without --profile-write-pseudo-probes option, no pseudo probes are +## Check that without --profile-use-pseudo-probes option, no pseudo probes are ## generated -# RUN: perf2bolt %S/../../../llvm/test/tools/llvm-profgen/Inputs/inline-cs-pseudoprobe.perfbin -p %t.preagg --pa -w %t.yaml3 -o %t.fdata -# RUN: FileCheck --input-file %t.yaml3 %s --check-prefix CHECK-NO-OPT -# CHECK-NO-OPT-NOT: probes: -# CHECK-NO-OPT-NOT: inline_tree: -# CHECK-NO-OPT-NOT: pseudo_probe_desc: +# RUN: perf2bolt %S/../../../llvm/test/tools/llvm-profgen/Inputs/inline-cs-pseudoprobe.perfbin -p %t.preagg --pa -w %t.yaml -o %t.fdata +# RUN: FileCheck --input-file %t.yaml %s --check-prefix CHECK-NO-OPT +# CHECK-NO-OPT-NOT: pseudo_probes +# CHECK-NO-OPT-NOT: guid +# CHECK-NO-OPT-NOT: pseudo_probe_desc_hash CHECK: Report of decoding input pseudo probe binaries diff --git a/bolt/test/X86/pseudoprobe-decoding-noinline.test b/bolt/test/X86/pseudoprobe-decoding-noinline.test index 36a2fab74e857..5dd6c2e25bcfe 100644 --- a/bolt/test/X86/pseudoprobe-decoding-noinline.test +++ b/bolt/test/X86/pseudoprobe-decoding-noinline.test @@ -1,45 +1,6 @@ # REQUIRES: system-linux -# RUN: llvm-bolt %S/../../../llvm/test/tools/llvm-profgen/Inputs/noinline-cs-pseudoprobe.perfbin --print-pseudo-probes=all -o %t.bolt --lite=0 --enable-bat 2>&1 | FileCheck %s +# RUN: llvm-bolt %S/../../../llvm/test/tools/llvm-profgen/Inputs/noinline-cs-pseudoprobe.perfbin --print-pseudo-probes=all -o %t.bolt 2>&1 | FileCheck %s -# PREAGG: B X:0 #foo# 1 0 -# PREAGG: B X:0 #bar# 1 0 -# PREAGG: B X:0 #main# 1 0 - -## Check pseudo-probes in regular YAML profile (non-BOLTed binary) -# RUN: link_fdata %s %S/../../../llvm/test/tools/llvm-profgen/Inputs/noinline-cs-pseudoprobe.perfbin %t.preagg PREAGG -# RUN: perf2bolt %S/../../../llvm/test/tools/llvm-profgen/Inputs/noinline-cs-pseudoprobe.perfbin -p %t.preagg --pa -w %t.yaml -o %t.fdata --profile-write-pseudo-probes -# RUN: FileCheck --input-file %t.yaml %s --check-prefix CHECK-YAML -## Check pseudo-probes in BAT YAML profile (BOLTed binary) -# RUN: link_fdata %s %t.bolt %t.preagg2 PREAGG -# RUN: perf2bolt %t.bolt -p %t.preagg2 --pa -w %t.yaml2 -o %t.fdata2 --profile-write-pseudo-probes -# RUN: FileCheck --input-file %t.yaml2 %s --check-prefix CHECK-YAML -# CHECK-YAML: name: bar -# CHECK-YAML: - bid: 0 -# CHECK-YAML: probes: [ { blx: 9 } ] -# CHECK-YAML: inline_tree: [ { } ] -# -# CHECK-YAML: name: foo -# CHECK-YAML: - bid: 0 -# CHECK-YAML: probes: [ { blx: 3 } ] -# CHECK-YAML: inline_tree: [ { g: 2 } ] -# -# CHECK-YAML: name: main -# CHECK-YAML: - bid: 0 -# CHECK-YAML: probes: [ { blx: 1, call: [ 2 ] } ] -# CHECK-YAML: inline_tree: [ { g: 1 } ] -# -# CHECK-YAML: pseudo_probe_desc: -# CHECK-YAML-NEXT: gs: [ 0xE413754A191DB537, 0xDB956436E78DD5FA, 0x5CF8C24CDB18BDAC ] -# CHECK-YAML-NEXT: gh: [ 2, 1, 0 ] -# CHECK-YAML-NEXT: hs: [ 0x200205A19C5B4, 0x10000FFFFFFFF, 0x10E852DA94 ] -# -## Check that without --profile-write-pseudo-probes option, no pseudo probes are -## generated -# RUN: perf2bolt %S/../../../llvm/test/tools/llvm-profgen/Inputs/noinline-cs-pseudoprobe.perfbin -p %t.preagg --pa -w %t.yaml3 -o %t.fdata -# RUN: FileCheck --input-file %t.yaml3 %s --check-prefix CHECK-NO-OPT -# CHECK-NO-OPT-NOT: probes: -# CHECK-NO-OPT-NOT: inline_tree: -# CHECK-NO-OPT-NOT: pseudo_probe_desc: ;; Report of decoding input pseudo probe binaries ; CHECK: GUID: 6699318081062747564 Name: foo diff --git a/bolt/test/X86/yaml-unknown-keys.test b/bolt/test/X86/yaml-unknown-keys.test deleted file mode 100644 index cbcf9a4d30441..0000000000000 --- a/bolt/test/X86/yaml-unknown-keys.test +++ /dev/null @@ -1,50 +0,0 @@ -## Test that BOLT gracefully handles a YAML profile with unknown keys. - -# REQUIRES: system-linux -# RUN: split-file %s %t -# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %t/main.s -o %t.o -# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib -# RUN: llvm-bolt %t.exe -o %t.null --data %t/profile.yaml \ -# RUN: --profile-ignore-hash -v=1 2>&1 | FileCheck %s -# CHECK: warning: unknown key 'unknown-header-key' -# CHECK: warning: unknown key 'unknown_succ_key' -# CHECK: warning: unknown key 'unknown_block_key' -# CHECK: warning: unknown key 'unknown_function_key' -# CHECK: warning: unknown key 'unknown_toplev_key' -#--- main.s - .globl main - .type main, %function -main: - .cfi_startproc - cmpl $0x0, %eax - jne .LBB0 -.LBB0: - retq - .cfi_endproc -.size main, .-main -#--- profile.yaml ---- -header: - profile-version: 1 - binary-name: 'yaml-multiple-profiles.test.tmp.exe' - binary-build-id: '' - profile-flags: [ lbr ] - profile-origin: branch profile reader - profile-events: '' - dfs-order: false - unknown-header-key: true -functions: - - name: 'main' - fid: 1 - hash: 0x50BBA3441D436491 - exec: 1 - nblocks: 1 - blocks: - - bid: 0 - insns: 2 - hash: 0x4D4D8FAF7D4C0000 - succ: [ { bid: 1, cnt: 0, unknown_succ_key: 0x10 } ] - unknown_block_key: [ ] - unknown_function_key: 1 -unknown_toplev_key: '' -... diff --git a/bolt/test/lit.local.cfg b/bolt/test/lit.local.cfg index e2fa0a4a2210f..8aa5f15d5ccfb 100644 --- a/bolt/test/lit.local.cfg +++ b/bolt/test/lit.local.cfg @@ -1,6 +1,6 @@ host_linux_triple = config.target_triple.split("-")[0] + "-unknown-linux-gnu" -common_linker_flags = "-fuse-ld=lld -Wl,--unresolved-symbols=ignore-all -pie" -flags = f"--target={host_linux_triple} -fPIE {common_linker_flags}" +common_linker_flags = "-fuse-ld=lld -Wl,--unresolved-symbols=ignore-all" +flags = f"--target={host_linux_triple} {common_linker_flags}" config.substitutions.insert(0, ("%cflags", f"%cflags {flags}")) config.substitutions.insert(0, ("%cxxflags", f"%cxxflags {flags}")) diff --git a/bolt/test/perf2bolt/lit.local.cfg b/bolt/test/perf2bolt/lit.local.cfg index 0fecf913aa98b..4ee9ad08cc78a 100644 --- a/bolt/test/perf2bolt/lit.local.cfg +++ b/bolt/test/perf2bolt/lit.local.cfg @@ -1,5 +1,4 @@ import shutil -import subprocess -if shutil.which("perf") is not None and subprocess.run(["perf", "record", "-e", "cycles:u", "-o", "/dev/null", "--", "perf", "--version"], capture_output=True).returncode == 0: - config.available_features.add("perf") +if shutil.which("perf") is not None: + config.available_features.add("perf") \ No newline at end of file diff --git a/bolt/tools/merge-fdata/merge-fdata.cpp b/bolt/tools/merge-fdata/merge-fdata.cpp index b640aae808f56..f2ac5ad4492ee 100644 --- a/bolt/tools/merge-fdata/merge-fdata.cpp +++ b/bolt/tools/merge-fdata/merge-fdata.cpp @@ -392,7 +392,6 @@ int main(int argc, char **argv) { if (std::error_code EC = MB.getError()) report_error(InputDataFilename, EC); yaml::Input YamlInput(MB.get()->getBuffer()); - YamlInput.setAllowUnknownKeys(true); errs() << "Merging data from " << InputDataFilename << "...\n"; diff --git a/clang-tools-extra/CMakeLists.txt b/clang-tools-extra/CMakeLists.txt index 6b6f2b1ca2276..f6a6b57b5ef0b 100644 --- a/clang-tools-extra/CMakeLists.txt +++ b/clang-tools-extra/CMakeLists.txt @@ -27,6 +27,7 @@ add_subdirectory(clang-move) add_subdirectory(clang-query) add_subdirectory(include-cleaner) add_subdirectory(pp-trace) +add_subdirectory(pseudo) add_subdirectory(tool-template) option(CLANG_TOOLS_EXTRA_INCLUDE_DOCS "Generate build targets for the Clang Extra Tools docs." diff --git a/clang-tools-extra/CODE_OWNERS.TXT b/clang-tools-extra/CODE_OWNERS.TXT index 2831ec7e25f59..4cf80aa2b0b82 100644 --- a/clang-tools-extra/CODE_OWNERS.TXT +++ b/clang-tools-extra/CODE_OWNERS.TXT @@ -23,7 +23,7 @@ D: clang-tidy N: Manuel Klimek E: klimek@google.com -D: all parts of clang-tools-extra not covered by someone else +D: clang-rename, all parts of clang-tools-extra not covered by someone else N: Sam McCall E: sammccall@google.com diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp index 4c75b42270114..200bb87a5ac3c 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp @@ -380,6 +380,7 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic( ++Context.Stats.ErrorsIgnoredNOLINT; // Ignored a warning, should ignore related notes as well LastErrorWasIgnored = true; + Context.DiagEngine->Clear(); for (const auto &Error : SuppressionErrors) Context.diag(Error); return; @@ -456,6 +457,7 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic( if (Info.hasSourceManager()) checkFilters(Info.getLocation(), Info.getSourceManager()); + Context.DiagEngine->Clear(); for (const auto &Error : SuppressionErrors) Context.diag(Error); } diff --git a/clang-tools-extra/clang-tidy/add_new_check.py b/clang-tools-extra/clang-tidy/add_new_check.py index e366f10053535..bd69bddcc6825 100755 --- a/clang-tools-extra/clang-tidy/add_new_check.py +++ b/clang-tools-extra/clang-tidy/add_new_check.py @@ -8,6 +8,9 @@ # # ===-----------------------------------------------------------------------===# +from __future__ import print_function +from __future__ import unicode_literals + import argparse import io import itertools @@ -16,13 +19,10 @@ import sys import textwrap -# FIXME Python 3.9: Replace typing.Tuple with builtins.tuple. -from typing import Optional, Tuple, Match - # Adapts the module's CMakelist file. Returns 'True' if it could add a new # entry and 'False' if the entry already existed. -def adapt_cmake(module_path: str, check_name_camel: str) -> bool: +def adapt_cmake(module_path, check_name_camel): filename = os.path.join(module_path, "CMakeLists.txt") # The documentation files are encoded using UTF-8, however on Windows the @@ -57,14 +57,14 @@ def adapt_cmake(module_path: str, check_name_camel: str) -> bool: # Adds a header for the new check. def write_header( - module_path: str, - module: str, - namespace: str, - check_name: str, - check_name_camel: str, - description: str, - lang_restrict: str, -) -> None: + module_path, + module, + namespace, + check_name, + check_name_camel, + description, + lang_restrict, +): wrapped_desc = "\n".join( textwrap.wrap( description, width=80, initial_indent="/// ", subsequent_indent="/// " @@ -139,9 +139,7 @@ class %(check_name_camel)s : public ClangTidyCheck { # Adds the implementation of the new check. -def write_implementation( - module_path: str, module: str, namespace: str, check_name_camel: str -) -> None: +def write_implementation(module_path, module, namespace, check_name_camel): filename = os.path.join(module_path, check_name_camel) + ".cpp" print("Creating %s..." % filename) with io.open(filename, "w", encoding="utf8", newline="\n") as f: @@ -189,7 +187,7 @@ def write_implementation( # Returns the source filename that implements the module. -def get_module_filename(module_path: str, module: str) -> str: +def get_module_filename(module_path, module): modulecpp = list( filter( lambda p: p.lower() == module.lower() + "tidymodule.cpp", @@ -200,9 +198,7 @@ def get_module_filename(module_path: str, module: str) -> str: # Modifies the module to include the new check. -def adapt_module( - module_path: str, module: str, check_name: str, check_name_camel: str -) -> None: +def adapt_module(module_path, module, check_name, check_name_camel): filename = get_module_filename(module_path, module) with io.open(filename, "r", encoding="utf8") as f: lines = f.readlines() @@ -221,10 +217,10 @@ def adapt_module( + '");\n' ) - lines_iter = iter(lines) + lines = iter(lines) try: while True: - line = next(lines_iter) + line = next(lines) if not header_added: match = re.search('#include "(.*)"', line) if match: @@ -251,11 +247,10 @@ def adapt_module( # If we didn't find the check name on this line, look on the # next one. prev_line = line - line = next(lines_iter) + line = next(lines) match = re.search(' *"([^"]*)"', line) if match: current_check_name = match.group(1) - assert current_check_name if current_check_name > check_fq_name: check_added = True f.write(check_decl) @@ -267,9 +262,7 @@ def adapt_module( # Adds a release notes entry. -def add_release_notes( - module_path: str, module: str, check_name: str, description: str -) -> None: +def add_release_notes(module_path, module, check_name, description): wrapped_desc = "\n".join( textwrap.wrap( description, width=80, initial_indent=" ", subsequent_indent=" " @@ -331,14 +324,9 @@ def add_release_notes( # Adds a test for the check. -def write_test( - module_path: str, - module: str, - check_name: str, - test_extension: str, - test_standard: Optional[str], -) -> None: - test_standard = f"-std={test_standard}-or-later " if test_standard else "" +def write_test(module_path, module, check_name, test_extension, test_standard): + if test_standard: + test_standard = f"-std={test_standard}-or-later " check_name_dashes = module + "-" + check_name filename = os.path.normpath( os.path.join( @@ -374,7 +362,7 @@ def write_test( ) -def get_actual_filename(dirname: str, filename: str) -> str: +def get_actual_filename(dirname, filename): if not os.path.isdir(dirname): return "" name = os.path.join(dirname, filename) @@ -388,7 +376,7 @@ def get_actual_filename(dirname: str, filename: str) -> str: # Recreates the list of checks in the docs/clang-tidy/checks directory. -def update_checks_list(clang_tidy_path: str) -> None: +def update_checks_list(clang_tidy_path): docs_dir = os.path.join(clang_tidy_path, "../docs/clang-tidy/checks") filename = os.path.normpath(os.path.join(docs_dir, "list.rst")) # Read the content of the current list.rst file @@ -402,12 +390,12 @@ def update_checks_list(clang_tidy_path: str) -> None: for file in filter( lambda s: s.endswith(".rst"), os.listdir(os.path.join(docs_dir, subdir)) ): - doc_files.append((subdir, file)) + doc_files.append([subdir, file]) doc_files.sort() # We couldn't find the source file from the check name, so try to find the # class name that corresponds to the check in the module file. - def filename_from_module(module_name: str, check_name: str) -> str: + def filename_from_module(module_name, check_name): module_path = os.path.join(clang_tidy_path, module_name) if not os.path.isdir(module_path): return "" @@ -445,7 +433,7 @@ def filename_from_module(module_name: str, check_name: str) -> str: return "" # Examine code looking for a c'tor definition to get the base class name. - def get_base_class(code: str, check_file: str) -> str: + def get_base_class(code, check_file): check_class_name = os.path.splitext(os.path.basename(check_file))[0] ctor_pattern = check_class_name + r"\([^:]*\)\s*:\s*([A-Z][A-Za-z0-9]*Check)\(" matches = re.search(r"\s+" + check_class_name + "::" + ctor_pattern, code) @@ -464,7 +452,7 @@ def get_base_class(code: str, check_file: str) -> str: return "" # Some simple heuristics to figure out if a check has an autofix or not. - def has_fixits(code: str) -> bool: + def has_fixits(code): for needle in [ "FixItHint", "ReplacementText", @@ -476,7 +464,7 @@ def has_fixits(code: str) -> bool: return False # Try to figure out of the check supports fixits. - def has_auto_fix(check_name: str) -> str: + def has_auto_fix(check_name): dirname, _, check_name = check_name.partition("-") check_file = get_actual_filename( @@ -511,7 +499,7 @@ def has_auto_fix(check_name: str) -> str: return "" - def process_doc(doc_file: Tuple[str, str]) -> Tuple[str, Optional[Match[str]]]: + def process_doc(doc_file): check_name = doc_file[0] + "-" + doc_file[1].replace(".rst", "") with io.open(os.path.join(docs_dir, *doc_file), "r", encoding="utf8") as doc: @@ -520,13 +508,13 @@ def process_doc(doc_file: Tuple[str, str]) -> Tuple[str, Optional[Match[str]]]: if match: # Orphan page, don't list it. - return "", None + return "", "" match = re.search(r".*:http-equiv=refresh: \d+;URL=(.*).html(.*)", content) # Is it a redirect? return check_name, match - def format_link(doc_file: Tuple[str, str]) -> str: + def format_link(doc_file): check_name, match = process_doc(doc_file) if not match and check_name and not check_name.startswith("clang-analyzer-"): return " :doc:`%(check_name)s <%(module)s/%(check)s>`,%(autofix)s\n" % { @@ -538,7 +526,7 @@ def format_link(doc_file: Tuple[str, str]) -> str: else: return "" - def format_link_alias(doc_file: Tuple[str, str]) -> str: + def format_link_alias(doc_file): check_name, match = process_doc(doc_file) if (match or (check_name.startswith("clang-analyzer-"))) and check_name: module = doc_file[0] @@ -555,7 +543,6 @@ def format_link_alias(doc_file: Tuple[str, str]) -> str: ref_end = "_" else: redirect_parts = re.search(r"^\.\./([^/]*)/([^/]*)$", match.group(1)) - assert redirect_parts title = redirect_parts[1] + "-" + redirect_parts[2] target = redirect_parts[1] + "/" + redirect_parts[2] autofix = has_auto_fix(title) @@ -612,7 +599,7 @@ def format_link_alias(doc_file: Tuple[str, str]) -> str: # Adds a documentation for the check. -def write_docs(module_path: str, module: str, check_name: str) -> None: +def write_docs(module_path, module, check_name): check_name_dashes = module + "-" + check_name filename = os.path.normpath( os.path.join( @@ -636,15 +623,15 @@ def write_docs(module_path: str, module: str, check_name: str) -> None: ) -def get_camel_name(check_name: str) -> str: +def get_camel_name(check_name): return "".join(map(lambda elem: elem.capitalize(), check_name.split("-"))) -def get_camel_check_name(check_name: str) -> str: +def get_camel_check_name(check_name): return get_camel_name(check_name) + "Check" -def main() -> None: +def main(): language_to_extension = { "c": "c", "c++": "cpp", @@ -769,8 +756,6 @@ def main() -> None: ) elif language in ["objc", "objc++"]: language_restrict = "%(lang)s.ObjC" - else: - raise ValueError(f"Unsupported language '{language}' was specified") write_header( module_path, @@ -784,7 +769,7 @@ def main() -> None: write_implementation(module_path, module, namespace, check_name_camel) adapt_module(module_path, module, check_name, check_name_camel) add_release_notes(module_path, module, check_name, description) - test_extension = language_to_extension[language] + test_extension = language_to_extension.get(language) write_test(module_path, module, check_name, test_extension, args.standard) write_docs(module_path, module, check_name) update_checks_list(clang_tidy_path) diff --git a/clang-tools-extra/clang-tidy/bugprone/CastingThroughVoidCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/CastingThroughVoidCheck.cpp index f0a9ace229740..9e714b4be4dfe 100644 --- a/clang-tools-extra/clang-tidy/bugprone/CastingThroughVoidCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/CastingThroughVoidCheck.cpp @@ -38,9 +38,7 @@ void CastingThroughVoidCheck::check(const MatchFinder::MatchResult &Result) { const auto ST = *Result.Nodes.getNodeAs("source_type"); const auto VT = *Result.Nodes.getNodeAs("void_type"); const auto *CE = Result.Nodes.getNodeAs("cast"); - diag(CE->getExprLoc(), - "do not cast %0 to %1 through %2; use reinterpret_cast instead") - << ST << TT << VT; + diag(CE->getExprLoc(), "do not cast %0 to %1 through %2") << ST << TT << VT; } } // namespace clang::tidy::bugprone diff --git a/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp index 00e8f7e514368..c87b3ea7e2616 100644 --- a/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp @@ -9,6 +9,7 @@ #include "ForwardingReferenceOverloadCheck.h" #include "clang/AST/ASTContext.h" #include "clang/ASTMatchers/ASTMatchFinder.h" +#include using namespace clang::ast_matchers; @@ -18,14 +19,14 @@ namespace { // Check if the given type is related to std::enable_if. AST_MATCHER(QualType, isEnableIf) { auto CheckTemplate = [](const TemplateSpecializationType *Spec) { - if (!Spec) + if (!Spec || !Spec->getTemplateName().getAsTemplateDecl()) { return false; - - const TemplateDecl *TDecl = Spec->getTemplateName().getAsTemplateDecl(); - - return TDecl && TDecl->isInStdNamespace() && - (TDecl->getName() == "enable_if" || - TDecl->getName() == "enable_if_t"); + } + const NamedDecl *TypeDecl = + Spec->getTemplateName().getAsTemplateDecl()->getTemplatedDecl(); + return TypeDecl->isInStdNamespace() && + (TypeDecl->getName() == "enable_if" || + TypeDecl->getName() == "enable_if_t"); }; const Type *BaseType = Node.getTypePtr(); // Case: pointer or reference to enable_if. diff --git a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp index a30e63f9b0fd6..d517e8473d94a 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp @@ -48,8 +48,6 @@ AST_MATCHER_P2(Expr, hasSizeOfDescendant, int, Depth, return false; } -AST_MATCHER(Expr, offsetOfExpr) { return isa(Node); } - CharUnits getSizeOfType(const ASTContext &Ctx, const Type *Ty) { if (!Ty || Ty->isIncompleteType() || Ty->isDependentType() || isa(Ty) || !Ty->isConstantSizeType()) @@ -223,15 +221,17 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) { const auto ElemType = arrayType(hasElementType(recordType().bind("elem-type"))); const auto ElemPtrType = pointerType(pointee(type().bind("elem-ptr-type"))); - const auto SizeofDivideExpr = binaryOperator( - hasOperatorName("/"), - hasLHS( - ignoringParenImpCasts(sizeOfExpr(hasArgumentOfType(hasCanonicalType( - type(anyOf(ElemType, ElemPtrType, type())).bind("num-type")))))), - hasRHS(ignoringParenImpCasts(sizeOfExpr( - hasArgumentOfType(hasCanonicalType(type().bind("denom-type"))))))); - Finder->addMatcher(SizeofDivideExpr.bind("sizeof-divide-expr"), this); + Finder->addMatcher( + binaryOperator( + hasOperatorName("/"), + hasLHS(ignoringParenImpCasts(sizeOfExpr(hasArgumentOfType( + hasCanonicalType(type(anyOf(ElemType, ElemPtrType, type())) + .bind("num-type")))))), + hasRHS(ignoringParenImpCasts(sizeOfExpr( + hasArgumentOfType(hasCanonicalType(type().bind("denom-type"))))))) + .bind("sizeof-divide-expr"), + this); // Detect expression like: sizeof(...) * sizeof(...)); most likely an error. Finder->addMatcher(binaryOperator(hasOperatorName("*"), @@ -257,9 +257,8 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) { .bind("sizeof-sizeof-expr"), this); - // Detect sizeof usage in comparisons involving pointer arithmetics, such as - // N * sizeof(T) == P1 - P2 or (P1 - P2) / sizeof(T), where P1 and P2 are - // pointers to a type T. + // Detect sizeof in pointer arithmetic like: N * sizeof(S) == P1 - P2 or + // (P1 - P2) / sizeof(S) where P1 and P2 are pointers to type S. const auto PtrDiffExpr = binaryOperator( hasOperatorName("-"), hasLHS(hasType(hasUnqualifiedDesugaredType(pointerType(pointee( @@ -286,47 +285,6 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) { hasRHS(ignoringParenImpCasts(SizeOfExpr.bind("sizeof-ptr-div-expr")))) .bind("sizeof-in-ptr-arithmetic-div"), this); - - // SEI CERT ARR39-C. Do not add or subtract a scaled integer to a pointer. - // Detect sizeof, alignof and offsetof usage in pointer arithmetics where - // they are used to scale the numeric distance, which is scaled again by - // the pointer arithmetic operator. This can result in forming invalid - // offsets. - // - // Examples, where P is a pointer, N is some integer (both compile-time and - // run-time): P + sizeof(T), P + sizeof(*P), P + N * sizeof(*P). - // - // This check does not warn on cases where the pointee type is "1 byte", - // as those cases can often come from generics and also do not constitute a - // problem because the size does not affect the scale used. - const auto InterestingPtrTyForPtrArithmetic = - pointerType(pointee(qualType().bind("pointee-type"))); - const auto SizeofLikeScaleExpr = - expr(anyOf(unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)), - unaryExprOrTypeTraitExpr(ofKind(UETT_AlignOf)), - offsetOfExpr())) - .bind("sizeof-in-ptr-arithmetic-scale-expr"); - const auto PtrArithmeticIntegerScaleExpr = binaryOperator( - hasAnyOperatorName("*", "/"), - // sizeof(...) * sizeof(...) and sizeof(...) / sizeof(...) is handled - // by this check on another path. - hasOperands(expr(hasType(isInteger()), unless(SizeofLikeScaleExpr)), - SizeofLikeScaleExpr)); - const auto PtrArithmeticScaledIntegerExpr = - expr(anyOf(SizeofLikeScaleExpr, PtrArithmeticIntegerScaleExpr), - unless(SizeofDivideExpr)); - - Finder->addMatcher( - expr(anyOf( - binaryOperator(hasAnyOperatorName("+", "-"), - hasOperands(hasType(InterestingPtrTyForPtrArithmetic), - PtrArithmeticScaledIntegerExpr)) - .bind("sizeof-in-ptr-arithmetic-plusminus"), - binaryOperator(hasAnyOperatorName("+=", "-="), - hasLHS(hasType(InterestingPtrTyForPtrArithmetic)), - hasRHS(PtrArithmeticScaledIntegerExpr)) - .bind("sizeof-in-ptr-arithmetic-plusminus"))), - this); } void SizeofExpressionCheck::check(const MatchFinder::MatchResult &Result) { @@ -451,43 +409,6 @@ void SizeofExpressionCheck::check(const MatchFinder::MatchResult &Result) { << SizeOfExpr->getSourceRange() << E->getOperatorLoc() << E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange(); } - } else if (const auto *E = Result.Nodes.getNodeAs( - "sizeof-in-ptr-arithmetic-plusminus")) { - const auto *PointeeTy = Result.Nodes.getNodeAs("pointee-type"); - const auto *ScaleExpr = - Result.Nodes.getNodeAs("sizeof-in-ptr-arithmetic-scale-expr"); - const CharUnits PointeeSize = getSizeOfType(Ctx, PointeeTy->getTypePtr()); - const int ScaleKind = [ScaleExpr]() { - if (const auto *UTTE = dyn_cast(ScaleExpr)) - switch (UTTE->getKind()) { - case UETT_SizeOf: - return 0; - case UETT_AlignOf: - return 1; - default: - return -1; - } - - if (isa(ScaleExpr)) - return 2; - - return -1; - }(); - - if (ScaleKind != -1 && PointeeSize > CharUnits::One()) { - diag(E->getExprLoc(), - "suspicious usage of '%select{sizeof|alignof|offsetof}0(...)' in " - "pointer arithmetic; this scaled value will be scaled again by the " - "'%1' operator") - << ScaleKind << E->getOpcodeStr() << ScaleExpr->getSourceRange(); - diag(E->getExprLoc(), - "'%0' in pointer arithmetic internally scales with 'sizeof(%1)' == " - "%2", - DiagnosticIDs::Note) - << E->getOpcodeStr() - << PointeeTy->getAsString(Ctx.getPrintingPolicy()) - << PointeeSize.getQuantity(); - } } } diff --git a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.h b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.h index 66d7c34cc9e94..9ca17bc9e6f12 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.h +++ b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.h @@ -13,7 +13,7 @@ namespace clang::tidy::bugprone { -/// Find suspicious usages of sizeof expressions. +/// Find suspicious usages of sizeof expression. /// /// For the user-facing documentation see: /// http://clang.llvm.org/extra/clang-tidy/checks/bugprone/sizeof-expression.html diff --git a/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp b/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp index 26befe0de59ae..8b5be9cd95f76 100644 --- a/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp @@ -14,7 +14,6 @@ #include "../bugprone/ReservedIdentifierCheck.h" #include "../bugprone/SignalHandlerCheck.h" #include "../bugprone/SignedCharMisuseCheck.h" -#include "../bugprone/SizeofExpressionCheck.h" #include "../bugprone/SpuriouslyWakeUpFunctionsCheck.h" #include "../bugprone/SuspiciousMemoryComparisonCheck.h" #include "../bugprone/UnhandledSelfAssignmentCheck.h" @@ -282,9 +281,6 @@ class CERTModule : public ClangTidyModule { "cert-oop58-cpp"); // C checkers - // ARR - CheckFactories.registerCheck( - "cert-arr39-c"); // CON CheckFactories.registerCheck( "cert-con36-c"); @@ -336,12 +332,6 @@ class CERTModule : public ClangTidyModule { ClangTidyOptions getModuleOptions() override { ClangTidyOptions Options; ClangTidyOptions::OptionMap &Opts = Options.CheckOptions; - Opts["cert-arr39-c.WarnOnSizeOfConstant"] = "false"; - Opts["cert-arr39-c.WarnOnSizeOfIntegerExpression"] = "false"; - Opts["cert-arr39-c.WarnOnSizeOfThis"] = "false"; - Opts["cert-arr39-c.WarnOnSizeOfCompareToConstant"] = "false"; - Opts["cert-arr39-c.WarnOnSizeOfPointer"] = "false"; - Opts["cert-arr39-c.WarnOnSizeOfPointerToAggregate"] = "false"; Opts["cert-dcl16-c.NewSuffixes"] = "L;LL;LU;LLU"; Opts["cert-err33-c.CheckedFunctions"] = CertErr33CCheckedFunctions; Opts["cert-err33-c.AllowCastToVoid"] = "true"; diff --git a/clang-tools-extra/clang-tidy/cert/FloatLoopCounter.cpp b/clang-tools-extra/clang-tidy/cert/FloatLoopCounter.cpp index 46acc9f4716c5..a936383759786 100644 --- a/clang-tools-extra/clang-tidy/cert/FloatLoopCounter.cpp +++ b/clang-tools-extra/clang-tidy/cert/FloatLoopCounter.cpp @@ -9,7 +9,6 @@ #include "FloatLoopCounter.h" #include "clang/AST/ASTContext.h" #include "clang/ASTMatchers/ASTMatchFinder.h" -#include "clang/ASTMatchers/ASTMatchers.h" using namespace clang::ast_matchers; @@ -17,30 +16,15 @@ namespace clang::tidy::cert { void FloatLoopCounter::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( - forStmt(hasIncrement(forEachDescendant( - declRefExpr(hasType(realFloatingPointType()), - to(varDecl().bind("var"))) - .bind("inc"))), - hasCondition(forEachDescendant( - declRefExpr(hasType(realFloatingPointType()), - to(varDecl(equalsBoundNode("var")))) - .bind("cond")))) - .bind("for"), + forStmt(hasIncrement(expr(hasType(realFloatingPointType())))).bind("for"), this); } void FloatLoopCounter::check(const MatchFinder::MatchResult &Result) { const auto *FS = Result.Nodes.getNodeAs("for"); - diag(FS->getInc()->getBeginLoc(), "loop induction expression should not have " - "floating-point type") - << Result.Nodes.getNodeAs("inc")->getSourceRange() - << Result.Nodes.getNodeAs("cond")->getSourceRange(); - - if (!FS->getInc()->getType()->isRealFloatingType()) - if (const auto *V = Result.Nodes.getNodeAs("var")) - diag(V->getBeginLoc(), "floating-point type loop induction variable", - DiagnosticIDs::Note); + diag(FS->getInc()->getExprLoc(), "loop induction expression should not have " + "floating-point type"); } } // namespace clang::tidy::cert diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp index 593a4f85d1309..5f046c502eb38 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp @@ -67,7 +67,9 @@ static bool canAdvanceAssignment(AssignedLevel Level) { static void updateAssignmentLevel( const FieldDecl *Field, const Expr *Init, const CXXConstructorDecl *Ctor, llvm::DenseMap &AssignedFields) { - auto It = AssignedFields.try_emplace(Field, AssignedLevel::None).first; + auto It = AssignedFields.find(Field); + if (It == AssignedFields.end()) + It = AssignedFields.insert({Field, AssignedLevel::None}).first; if (!canAdvanceAssignment(It->second)) // fast path for already decided field. @@ -83,7 +85,7 @@ static void updateAssignmentLevel( memberExpr(hasObjectExpression(cxxThisExpr()), member(fieldDecl(indexNotLessThan(Field->getFieldIndex())))); auto DeclMatcher = declRefExpr( - to(valueDecl(unless(parmVarDecl()), hasDeclContext(equalsNode(Ctor))))); + to(varDecl(unless(parmVarDecl()), hasDeclContext(equalsNode(Ctor))))); const bool HasDependence = !match(expr(anyOf(MemberMatcher, DeclMatcher, hasDescendant(MemberMatcher), hasDescendant(DeclMatcher))), diff --git a/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp b/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp index ee86925689898..21008bc144b91 100644 --- a/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp @@ -102,7 +102,7 @@ void DefinitionsInHeadersCheck::check(const MatchFinder::MatchResult &Result) { // inline is not allowed for main function. if (FD->isMain()) return; - diag(FD->getLocation(), "mark the definition as 'inline'", + diag(FD->getLocation(), /*Description=*/"make as 'inline'", DiagnosticIDs::Note) << FixItHint::CreateInsertion(FD->getInnerLocStart(), "inline "); } else if (const auto *VD = dyn_cast(ND)) { diff --git a/clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp index afc4897eeb2ae..42c4b6edb6d20 100644 --- a/clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp @@ -14,16 +14,6 @@ using namespace clang::ast_matchers; namespace clang::tidy::misc { -namespace { - -AST_MATCHER_P(CXXMethodDecl, firstParameter, - ast_matchers::internal::Matcher, InnerMatcher) { - unsigned N = Node.isExplicitObjectMemberFunction() ? 1 : 0; - return (N < Node.parameters().size() && - InnerMatcher.matches(*Node.parameters()[N], Finder, Builder)); -} -} // namespace - void UnconventionalAssignOperatorCheck::registerMatchers( ast_matchers::MatchFinder *Finder) { const auto HasGoodReturnType = @@ -39,7 +29,7 @@ void UnconventionalAssignOperatorCheck::registerMatchers( hasName("operator="), ofClass(recordDecl().bind("class"))) .bind("method"); const auto IsSelfAssign = - cxxMethodDecl(IsAssign, firstParameter(parmVarDecl(hasType(IsSelf)))) + cxxMethodDecl(IsAssign, hasParameter(0, parmVarDecl(hasType(IsSelf)))) .bind("method"); Finder->addMatcher( @@ -51,7 +41,8 @@ void UnconventionalAssignOperatorCheck::registerMatchers( rValueReferenceType(pointee(isConstQualified())))))); Finder->addMatcher( - cxxMethodDecl(IsSelfAssign, firstParameter(parmVarDecl(hasType(BadSelf)))) + cxxMethodDecl(IsSelfAssign, + hasParameter(0, parmVarDecl(hasType(BadSelf)))) .bind("ArgumentType"), this); diff --git a/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp b/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp index 0804aa76d953c..89790ea70cf22 100644 --- a/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp @@ -9,7 +9,6 @@ #include "AvoidCArraysCheck.h" #include "clang/AST/ASTContext.h" #include "clang/ASTMatchers/ASTMatchFinder.h" -#include "clang/ASTMatchers/ASTMatchers.h" using namespace clang::ast_matchers; @@ -61,7 +60,6 @@ void AvoidCArraysCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( typeLoc(hasValidBeginLoc(), hasType(arrayType()), - optionally(hasParent(parmVarDecl().bind("param_decl"))), unless(anyOf(hasParent(parmVarDecl(isArgvOfMain())), hasParent(varDecl(isExternC())), hasParent(fieldDecl( @@ -74,28 +72,11 @@ void AvoidCArraysCheck::registerMatchers(MatchFinder *Finder) { void AvoidCArraysCheck::check(const MatchFinder::MatchResult &Result) { const auto *ArrayType = Result.Nodes.getNodeAs("typeloc"); - const bool IsInParam = - Result.Nodes.getNodeAs("param_decl") != nullptr; - const bool IsVLA = ArrayType->getTypePtr()->isVariableArrayType(); - enum class RecommendType { Array, Vector, Span }; - llvm::SmallVector RecommendTypes{}; - if (IsVLA) { - RecommendTypes.push_back("'std::vector'"); - } else if (ArrayType->getTypePtr()->isIncompleteArrayType() && IsInParam) { - // in function parameter, we also don't know the size of - // IncompleteArrayType. - if (Result.Context->getLangOpts().CPlusPlus20) - RecommendTypes.push_back("'std::span'"); - else { - RecommendTypes.push_back("'std::array'"); - RecommendTypes.push_back("'std::vector'"); - } - } else { - RecommendTypes.push_back("'std::array'"); - } + diag(ArrayType->getBeginLoc(), - "do not declare %select{C-style|C VLA}0 arrays, use %1 instead") - << IsVLA << llvm::join(RecommendTypes, " or "); + "do not declare %select{C-style|C VLA}0 arrays, use " + "%select{std::array<>|std::vector<>}0 instead") + << ArrayType->getTypePtr()->isVariableArrayType(); } } // namespace clang::tidy::modernize diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp index 1c6a1618ebbc4..a1786ba5acfdf 100644 --- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp @@ -262,7 +262,7 @@ StatementMatcher makeIteratorLoopMatcher(bool IsReverse) { /// EndVarName: 'j' (as a VarDecl) /// In the second example only: /// EndCallName: 'container.size()' (as a CXXMemberCallExpr) or -/// 'size(container)' (as a CallExpr) +/// 'size(contaner)' (as a CallExpr) /// /// Client code will need to make sure that: /// - The containers on which 'size()' is called is the container indexed. @@ -491,7 +491,7 @@ static bool isDirectMemberExpr(const Expr *E) { } /// Given an expression that represents an usage of an element from the -/// container that we are iterating over, returns false when it can be +/// containter that we are iterating over, returns false when it can be /// guaranteed this element cannot be modified as a result of this usage. static bool canBeModified(ASTContext *Context, const Expr *E) { if (E->getType().isConstQualified()) @@ -922,7 +922,7 @@ bool LoopConvertCheck::isConvertible(ASTContext *Context, const ast_matchers::BoundNodes &Nodes, const ForStmt *Loop, LoopFixerKind FixerKind) { - // In self contained diagnostic mode we don't want dependencies on other + // In self contained diagnosics mode we don't want dependancies on other // loops, otherwise, If we already modified the range of this for loop, don't // do any further updates on this iteration. if (areDiagsSelfContained()) diff --git a/clang-tools-extra/clang-tidy/modernize/MinMaxUseInitializerListCheck.cpp b/clang-tools-extra/clang-tidy/modernize/MinMaxUseInitializerListCheck.cpp index 9861f4681db1b..418699ffbc4d1 100644 --- a/clang-tools-extra/clang-tidy/modernize/MinMaxUseInitializerListCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/MinMaxUseInitializerListCheck.cpp @@ -72,11 +72,7 @@ static FindArgsResult findArgs(const CallExpr *Call) { return Result; } -// Returns `true` as `first` only if a nested call to `std::min` or -// `std::max` was found. Checking if `FixItHint`s were generated is not enough, -// as the explicit casts that the check introduces may be generated without a -// nested `std::min` or `std::max` call. -static std::pair> +static SmallVector generateReplacements(const MatchFinder::MatchResult &Match, const CallExpr *TopCall, const FindArgsResult &Result, const bool IgnoreNonTrivialTypes, @@ -95,15 +91,13 @@ generateReplacements(const MatchFinder::MatchResult &Match, const bool IsResultTypeTrivial = ResultType.isTrivialType(*Match.Context); if ((!IsResultTypeTrivial && IgnoreNonTrivialTypes)) - return {false, FixItHints}; + return FixItHints; if (IsResultTypeTrivial && static_cast( Match.Context->getTypeSizeInChars(ResultType).getQuantity()) > IgnoreTrivialTypesOfSizeAbove) - return {false, FixItHints}; - - bool FoundNestedCall = false; + return FixItHints; for (const Expr *Arg : Result.Args) { const auto *InnerCall = dyn_cast(Arg->IgnoreParenImpCasts()); @@ -152,9 +146,6 @@ generateReplacements(const MatchFinder::MatchResult &Match, *Match.Context)) continue; - // We have found a nested call - FoundNestedCall = true; - // remove the function call FixItHints.push_back( FixItHint::CreateRemoval(InnerCall->getCallee()->getSourceRange())); @@ -177,7 +168,7 @@ generateReplacements(const MatchFinder::MatchResult &Match, CharSourceRange::getTokenRange(InnerResult.First->getEndLoc()))); } - const auto [_, InnerReplacements] = generateReplacements( + const SmallVector InnerReplacements = generateReplacements( Match, InnerCall, InnerResult, IgnoreNonTrivialTypes, IgnoreTrivialTypesOfSizeAbove); @@ -198,7 +189,7 @@ generateReplacements(const MatchFinder::MatchResult &Match, } } - return {FoundNestedCall, FixItHints}; + return FixItHints; } MinMaxUseInitializerListCheck::MinMaxUseInitializerListCheck( @@ -247,11 +238,11 @@ void MinMaxUseInitializerListCheck::check( const auto *TopCall = Match.Nodes.getNodeAs("topCall"); const FindArgsResult Result = findArgs(TopCall); - const auto [FoundNestedCall, Replacements] = + const SmallVector Replacements = generateReplacements(Match, TopCall, Result, IgnoreNonTrivialTypes, IgnoreTrivialTypesOfSizeAbove); - if (!FoundNestedCall) + if (Replacements.empty()) return; const DiagnosticBuilder Diagnostic = diff --git a/clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp b/clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp index a394f5c6efa2a..8ecaa41754fb2 100644 --- a/clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp @@ -46,41 +46,38 @@ void AvoidEndlCheck::check(const MatchFinder::MatchResult &Result) { // Handle the more common streaming '... << std::endl' case const CharSourceRange TokenRange = CharSourceRange::getTokenRange(Expression->getSourceRange()); - StringRef SourceText = Lexer::getSourceText( + const StringRef SourceText = Lexer::getSourceText( TokenRange, *Result.SourceManager, Result.Context->getLangOpts()); - if (SourceText.empty()) - SourceText = "std::endl"; + auto Diag = diag(Expression->getBeginLoc(), "do not use '%0' with streams; use '\\n' instead") << SourceText; - if (TokenRange.isValid()) - Diag << FixItHint::CreateReplacement(TokenRange, "'\\n'"); + + Diag << FixItHint::CreateReplacement(TokenRange, "'\\n'"); } else { // Handle the less common function call 'std::endl(...)' case const auto *CallExpression = llvm::cast(Expression); assert(CallExpression->getNumArgs() == 1); - StringRef SourceText = Lexer::getSourceText( + const StringRef SourceText = Lexer::getSourceText( CharSourceRange::getTokenRange( CallExpression->getCallee()->getSourceRange()), *Result.SourceManager, Result.Context->getLangOpts()); - if (SourceText.empty()) - SourceText = "std::endl"; - auto Diag = diag(CallExpression->getBeginLoc(), - "do not use '%0' with streams; use '\\n' instead") - << SourceText; const CharSourceRange ArgTokenRange = CharSourceRange::getTokenRange( CallExpression->getArg(0)->getSourceRange()); const StringRef ArgSourceText = Lexer::getSourceText( ArgTokenRange, *Result.SourceManager, Result.Context->getLangOpts()); - const CharSourceRange ReplacementRange = - CharSourceRange::getTokenRange(CallExpression->getSourceRange()); - if (!ArgSourceText.empty() && ReplacementRange.isValid()) { - const std::string ReplacementString = - std::string(ArgSourceText) + " << '\\n'"; - Diag << FixItHint::CreateReplacement(ReplacementRange, ReplacementString); - } + + const std::string ReplacementString = + std::string(ArgSourceText) + " << '\\n'"; + + diag(CallExpression->getBeginLoc(), + "do not use '%0' with streams; use '\\n' instead") + << SourceText + << FixItHint::CreateReplacement( + CharSourceRange::getTokenRange(CallExpression->getSourceRange()), + ReplacementString); } } diff --git a/clang-tools-extra/clang-tidy/readability/AvoidUnconditionalPreprocessorIfCheck.cpp b/clang-tools-extra/clang-tidy/readability/AvoidUnconditionalPreprocessorIfCheck.cpp index ca5fc358ce290..d92d0e8f2dbf7 100644 --- a/clang-tools-extra/clang-tidy/readability/AvoidUnconditionalPreprocessorIfCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/AvoidUnconditionalPreprocessorIfCheck.cpp @@ -84,8 +84,7 @@ struct AvoidUnconditionalPreprocessorIfPPCallbacks : public PPCallbacks { return (Tok.getRawIdentifier() == "true" || Tok.getRawIdentifier() == "false"); default: - return Tok.getKind() >= tok::l_square && - Tok.getKind() <= tok::greatergreatergreater; + return Tok.getKind() >= tok::l_square && Tok.getKind() <= tok::caretcaret; } } diff --git a/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp b/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp index 05d4c87bc73ce..dbb50a060e596 100644 --- a/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp @@ -13,40 +13,30 @@ using namespace clang::ast_matchers; namespace clang::tidy::readability { + void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) { - const auto HasContainsMatchingParamType = hasMethod( - cxxMethodDecl(isConst(), parameterCountIs(1), returns(booleanType()), - hasName("contains"), unless(isDeleted()), isPublic(), - hasParameter(0, hasType(hasUnqualifiedDesugaredType( - equalsBoundNode("parameterType")))))); + const auto SupportedContainers = hasType( + hasUnqualifiedDesugaredType(recordType(hasDeclaration(cxxRecordDecl( + hasAnyName("::std::set", "::std::unordered_set", "::std::map", + "::std::unordered_map", "::std::multiset", + "::std::unordered_multiset", "::std::multimap", + "::std::unordered_multimap")))))); const auto CountCall = - cxxMemberCallExpr( - argumentCountIs(1), - callee(cxxMethodDecl( - hasName("count"), - hasParameter(0, hasType(hasUnqualifiedDesugaredType( - type().bind("parameterType")))), - ofClass(cxxRecordDecl(HasContainsMatchingParamType))))) + cxxMemberCallExpr(on(SupportedContainers), + callee(cxxMethodDecl(hasName("count"))), + argumentCountIs(1)) .bind("call"); const auto FindCall = - cxxMemberCallExpr( - argumentCountIs(1), - callee(cxxMethodDecl( - hasName("find"), - hasParameter(0, hasType(hasUnqualifiedDesugaredType( - type().bind("parameterType")))), - ofClass(cxxRecordDecl(HasContainsMatchingParamType))))) + cxxMemberCallExpr(on(SupportedContainers), + callee(cxxMethodDecl(hasName("find"))), + argumentCountIs(1)) .bind("call"); - const auto EndCall = cxxMemberCallExpr( - argumentCountIs(0), - callee( - cxxMethodDecl(hasName("end"), - // In the matchers below, FindCall should always appear - // before EndCall so 'parameterType' is properly bound. - ofClass(cxxRecordDecl(HasContainsMatchingParamType))))); + const auto EndCall = cxxMemberCallExpr(on(SupportedContainers), + callee(cxxMethodDecl(hasName("end"))), + argumentCountIs(0)); const auto Literal0 = integerLiteral(equals(0)); const auto Literal1 = integerLiteral(equals(1)); @@ -62,7 +52,10 @@ void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) { .bind("positiveComparison"), this); AddSimpleMatcher( - binaryOperator(hasOperatorName("!="), hasOperands(CountCall, Literal0)) + binaryOperator(hasLHS(CountCall), hasOperatorName("!="), hasRHS(Literal0)) + .bind("positiveComparison")); + AddSimpleMatcher( + binaryOperator(hasLHS(Literal0), hasOperatorName("!="), hasRHS(CountCall)) .bind("positiveComparison")); AddSimpleMatcher( binaryOperator(hasLHS(CountCall), hasOperatorName(">"), hasRHS(Literal0)) @@ -79,7 +72,10 @@ void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) { // Find inverted membership tests which use `count()`. AddSimpleMatcher( - binaryOperator(hasOperatorName("=="), hasOperands(CountCall, Literal0)) + binaryOperator(hasLHS(CountCall), hasOperatorName("=="), hasRHS(Literal0)) + .bind("negativeComparison")); + AddSimpleMatcher( + binaryOperator(hasLHS(Literal0), hasOperatorName("=="), hasRHS(CountCall)) .bind("negativeComparison")); AddSimpleMatcher( binaryOperator(hasLHS(CountCall), hasOperatorName("<="), hasRHS(Literal0)) @@ -96,10 +92,10 @@ void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) { // Find membership tests based on `find() == end()`. AddSimpleMatcher( - binaryOperator(hasOperatorName("!="), hasOperands(FindCall, EndCall)) + binaryOperator(hasLHS(FindCall), hasOperatorName("!="), hasRHS(EndCall)) .bind("positiveComparison")); AddSimpleMatcher( - binaryOperator(hasOperatorName("=="), hasOperands(FindCall, EndCall)) + binaryOperator(hasLHS(FindCall), hasOperatorName("=="), hasRHS(EndCall)) .bind("negativeComparison")); } diff --git a/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.h b/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.h index 753603ed82537..2e8276d684cd7 100644 --- a/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.h +++ b/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.h @@ -13,9 +13,8 @@ namespace clang::tidy::readability { -/// Finds usages of `container.count()` and -/// `container.find() == container.end()` which should be replaced by a call -/// to the `container.contains()` method. +/// Finds usages of `container.count()` and `find() == end()` which should be +/// replaced by a call to the `container.contains()` method introduced in C++20. /// /// For the user-facing documentation see: /// http://clang.llvm.org/extra/clang-tidy/checks/readability/container-contains.html @@ -25,11 +24,10 @@ class ContainerContainsCheck : public ClangTidyCheck { : ClangTidyCheck(Name, Context) {} void registerMatchers(ast_matchers::MatchFinder *Finder) final; void check(const ast_matchers::MatchFinder::MatchResult &Result) final; + +protected: bool isLanguageVersionSupported(const LangOptions &LO) const final { - return LO.CPlusPlus; - } - std::optional getCheckTraversalKind() const override { - return TK_AsIs; + return LO.CPlusPlus20; } }; diff --git a/clang-tools-extra/clang-tidy/readability/EnumInitialValueCheck.cpp b/clang-tools-extra/clang-tidy/readability/EnumInitialValueCheck.cpp index 1cb95c2b2347b..8f2841c32259a 100644 --- a/clang-tools-extra/clang-tidy/readability/EnumInitialValueCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/EnumInitialValueCheck.cpp @@ -141,18 +141,16 @@ void EnumInitialValueCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { } void EnumInitialValueCheck::registerMatchers(MatchFinder *Finder) { - Finder->addMatcher(enumDecl(isDefinition(), unless(isMacro()), - unless(hasConsistentInitialValues())) - .bind("inconsistent"), - this); + Finder->addMatcher( + enumDecl(unless(isMacro()), unless(hasConsistentInitialValues())) + .bind("inconsistent"), + this); if (!AllowExplicitZeroFirstInitialValue) Finder->addMatcher( - enumDecl(isDefinition(), hasZeroInitialValueForFirstEnumerator()) - .bind("zero_first"), + enumDecl(hasZeroInitialValueForFirstEnumerator()).bind("zero_first"), this); if (!AllowExplicitSequentialInitialValues) - Finder->addMatcher(enumDecl(isDefinition(), unless(isMacro()), - hasSequentialInitialValues()) + Finder->addMatcher(enumDecl(unless(isMacro()), hasSequentialInitialValues()) .bind("sequential"), this); } @@ -161,7 +159,7 @@ void EnumInitialValueCheck::check(const MatchFinder::MatchResult &Result) { if (const auto *Enum = Result.Nodes.getNodeAs("inconsistent")) { DiagnosticBuilder Diag = diag(Enum->getBeginLoc(), - "initial values in enum %0 are not consistent, consider explicit " + "inital values in enum %0 are not consistent, consider explicit " "initialization of all, none or only the first enumerator") << Enum; for (const EnumConstantDecl *ECD : Enum->enumerators()) diff --git a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py index f1b934f7139e9..b702eece37002 100755 --- a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py +++ b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py @@ -49,7 +49,7 @@ import time import traceback from types import ModuleType -from typing import Any, Awaitable, Callable, List, Optional, TypeVar +from typing import Any, Awaitable, Callable, List, Optional, Tuple, TypeVar yaml: Optional[ModuleType] = None @@ -621,7 +621,4 @@ async def main() -> None: if __name__ == "__main__": - try: - asyncio.run(main()) - except KeyboardInterrupt: - pass + asyncio.run(main()) diff --git a/clang-tools-extra/clangd/CMakeLists.txt b/clang-tools-extra/clangd/CMakeLists.txt index 8dcbf5f47e056..c21d277d2ffcb 100644 --- a/clang-tools-extra/clangd/CMakeLists.txt +++ b/clang-tools-extra/clangd/CMakeLists.txt @@ -183,6 +183,7 @@ target_link_libraries(clangDaemon ${LLVM_PTHREAD_LIB} clangIncludeCleaner + clangPseudo clangTidy clangTidyUtils diff --git a/clang-tools-extra/clangd/Diagnostics.cpp b/clang-tools-extra/clangd/Diagnostics.cpp index 552dd36b6900b..d5eca083eb651 100644 --- a/clang-tools-extra/clangd/Diagnostics.cpp +++ b/clang-tools-extra/clangd/Diagnostics.cpp @@ -579,17 +579,7 @@ std::vector StoreDiags::take(const clang::tidy::ClangTidyContext *Tidy) { for (auto &Diag : Output) { if (const char *ClangDiag = getDiagnosticCode(Diag.ID)) { // Warnings controlled by -Wfoo are better recognized by that name. - const StringRef Warning = [&] { - if (OrigSrcMgr) { - return OrigSrcMgr->getDiagnostics() - .getDiagnosticIDs() - ->getWarningOptionForDiag(Diag.ID); - } - if (!DiagnosticIDs::IsCustomDiag(Diag.ID)) - return DiagnosticIDs{}.getWarningOptionForDiag(Diag.ID); - return StringRef{}; - }(); - + StringRef Warning = DiagnosticIDs::getWarningOptionForDiag(Diag.ID); if (!Warning.empty()) { Diag.Name = ("-W" + Warning).str(); } else { @@ -906,23 +896,20 @@ void StoreDiags::flushLastDiag() { Output.push_back(std::move(*LastDiag)); } -bool isDiagnosticSuppressed(const clang::Diagnostic &Diag, - const llvm::StringSet<> &Suppress, - const LangOptions &LangOpts) { +bool isBuiltinDiagnosticSuppressed(unsigned ID, + const llvm::StringSet<> &Suppress, + const LangOptions &LangOpts) { // Don't complain about header-only stuff in mainfiles if it's a header. // FIXME: would be cleaner to suppress in clang, once we decide whether the // behavior should be to silently-ignore or respect the pragma. - if (Diag.getID() == diag::pp_pragma_sysheader_in_main_file && - LangOpts.IsHeaderFile) + if (ID == diag::pp_pragma_sysheader_in_main_file && LangOpts.IsHeaderFile) return true; - if (const char *CodePtr = getDiagnosticCode(Diag.getID())) { + if (const char *CodePtr = getDiagnosticCode(ID)) { if (Suppress.contains(normalizeSuppressedCode(CodePtr))) return true; } - StringRef Warning = - Diag.getDiags()->getDiagnosticIDs()->getWarningOptionForDiag( - Diag.getID()); + StringRef Warning = DiagnosticIDs::getWarningOptionForDiag(ID); if (!Warning.empty() && Suppress.contains(Warning)) return true; return false; diff --git a/clang-tools-extra/clangd/Diagnostics.h b/clang-tools-extra/clangd/Diagnostics.h index c45d8dc3aa6ce..d4c0478c63a5c 100644 --- a/clang-tools-extra/clangd/Diagnostics.h +++ b/clang-tools-extra/clangd/Diagnostics.h @@ -181,11 +181,11 @@ class StoreDiags : public DiagnosticConsumer { }; /// Determine whether a (non-clang-tidy) diagnostic is suppressed by config. -bool isDiagnosticSuppressed(const clang::Diagnostic &Diag, - const llvm::StringSet<> &Suppressed, - const LangOptions &); +bool isBuiltinDiagnosticSuppressed(unsigned ID, + const llvm::StringSet<> &Suppressed, + const LangOptions &); /// Take a user-specified diagnostic code, and convert it to a normalized form -/// stored in the config and consumed by isDiagnosticsSuppressed. +/// stored in the config and consumed by isBuiltinDiagnosticsSuppressed. /// /// (This strips err_ and -W prefix so we can match with or without them.) llvm::StringRef normalizeSuppressedCode(llvm::StringRef); diff --git a/clang-tools-extra/clangd/DumpAST.cpp b/clang-tools-extra/clangd/DumpAST.cpp index e605f82e91fe4..9a525efb938e8 100644 --- a/clang-tools-extra/clangd/DumpAST.cpp +++ b/clang-tools-extra/clangd/DumpAST.cpp @@ -187,7 +187,6 @@ class DumpVisitor : public RecursiveASTVisitor { TEMPLATE_KIND(SubstTemplateTemplateParm); TEMPLATE_KIND(SubstTemplateTemplateParmPack); TEMPLATE_KIND(UsingTemplate); - TEMPLATE_KIND(DeducedTemplate); #undef TEMPLATE_KIND } llvm_unreachable("Unhandled NameKind enum"); diff --git a/clang-tools-extra/clangd/Feature.cpp b/clang-tools-extra/clangd/Feature.cpp index ec707a33f656b..859618a7470ac 100644 --- a/clang-tools-extra/clangd/Feature.cpp +++ b/clang-tools-extra/clangd/Feature.cpp @@ -8,7 +8,6 @@ #include "Feature.h" #include "clang/Basic/Version.h" -#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX #include "llvm/Support/Compiler.h" #include "llvm/TargetParser/Host.h" diff --git a/clang-tools-extra/clangd/ParsedAST.cpp b/clang-tools-extra/clangd/ParsedAST.cpp index 4491be9aa0362..a8b6cc8dd0a46 100644 --- a/clang-tools-extra/clangd/ParsedAST.cpp +++ b/clang-tools-extra/clangd/ParsedAST.cpp @@ -340,7 +340,7 @@ void applyWarningOptions(llvm::ArrayRef ExtraArgs, if (Enable) { if (Diags.getDiagnosticLevel(ID, SourceLocation()) < DiagnosticsEngine::Warning) { - auto Group = Diags.getDiagnosticIDs()->getGroupForDiag(ID); + auto Group = DiagnosticIDs::getGroupForDiag(ID); if (!Group || !EnabledGroups(*Group)) continue; Diags.setSeverity(ID, diag::Severity::Warning, SourceLocation()); @@ -583,8 +583,8 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs, ASTDiags.setLevelAdjuster([&](DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &Info) { if (Cfg.Diagnostics.SuppressAll || - isDiagnosticSuppressed(Info, Cfg.Diagnostics.Suppress, - Clang->getLangOpts())) + isBuiltinDiagnosticSuppressed(Info.getID(), Cfg.Diagnostics.Suppress, + Clang->getLangOpts())) return DiagnosticsEngine::Ignored; auto It = OverriddenSeverity.find(Info.getID()); diff --git a/clang-tools-extra/clangd/Preamble.cpp b/clang-tools-extra/clangd/Preamble.cpp index 84e8fec342829..dd13b1a9e5613 100644 --- a/clang-tools-extra/clangd/Preamble.cpp +++ b/clang-tools-extra/clangd/Preamble.cpp @@ -621,8 +621,8 @@ buildPreamble(PathRef FileName, CompilerInvocation CI, PreambleDiagnostics.setLevelAdjuster([&](DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &Info) { if (Cfg.Diagnostics.SuppressAll || - isDiagnosticSuppressed(Info, Cfg.Diagnostics.Suppress, - CI.getLangOpts())) + isBuiltinDiagnosticSuppressed(Info.getID(), Cfg.Diagnostics.Suppress, + CI.getLangOpts())) return DiagnosticsEngine::Ignored; switch (Info.getID()) { case diag::warn_no_newline_eof: diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp index e6d16af2495fe..a366f1331c2d3 100644 --- a/clang-tools-extra/clangd/SemanticHighlighting.cpp +++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp @@ -1120,7 +1120,6 @@ class CollectExtraHighlightings case TemplateName::SubstTemplateTemplateParm: case TemplateName::SubstTemplateTemplateParmPack: case TemplateName::UsingTemplate: - case TemplateName::DeducedTemplate: // Names that could be resolved to a TemplateDecl are handled elsewhere. break; } diff --git a/clang-tools-extra/clangd/SemanticSelection.cpp b/clang-tools-extra/clangd/SemanticSelection.cpp index dd7116e619e6d..3d687173b2be9 100644 --- a/clang-tools-extra/clangd/SemanticSelection.cpp +++ b/clang-tools-extra/clangd/SemanticSelection.cpp @@ -11,6 +11,9 @@ #include "Protocol.h" #include "Selection.h" #include "SourceCode.h" +#include "clang-pseudo/Bracket.h" +#include "clang-pseudo/DirectiveTree.h" +#include "clang-pseudo/Token.h" #include "clang/AST/DeclBase.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/SourceManager.h" @@ -22,9 +25,6 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/Casting.h" #include "llvm/Support/Error.h" -#include "support/Bracket.h" -#include "support/DirectiveTree.h" -#include "support/Token.h" #include #include #include @@ -181,16 +181,16 @@ llvm::Expected> getFoldingRanges(ParsedAST &AST) { // Related issue: https://github.com/clangd/clangd/issues/310 llvm::Expected> getFoldingRanges(const std::string &Code, bool LineFoldingOnly) { - auto OrigStream = lex(Code, genericLangOpts()); + auto OrigStream = pseudo::lex(Code, clang::pseudo::genericLangOpts()); - auto DirectiveStructure = DirectiveTree::parse(OrigStream); - chooseConditionalBranches(DirectiveStructure, OrigStream); + auto DirectiveStructure = pseudo::DirectiveTree::parse(OrigStream); + pseudo::chooseConditionalBranches(DirectiveStructure, OrigStream); // FIXME: Provide ranges in the disabled-PP regions as well. auto Preprocessed = DirectiveStructure.stripDirectives(OrigStream); - auto ParseableStream = cook(Preprocessed, genericLangOpts()); - pairBrackets(ParseableStream); + auto ParseableStream = cook(Preprocessed, clang::pseudo::genericLangOpts()); + pseudo::pairBrackets(ParseableStream); std::vector Result; auto AddFoldingRange = [&](Position Start, Position End, @@ -205,19 +205,19 @@ getFoldingRanges(const std::string &Code, bool LineFoldingOnly) { FR.kind = Kind.str(); Result.push_back(FR); }; - auto OriginalToken = [&](const Token &T) { + auto OriginalToken = [&](const pseudo::Token &T) { return OrigStream.tokens()[T.OriginalIndex]; }; - auto StartOffset = [&](const Token &T) { + auto StartOffset = [&](const pseudo::Token &T) { return OriginalToken(T).text().data() - Code.data(); }; - auto StartPosition = [&](const Token &T) { + auto StartPosition = [&](const pseudo::Token &T) { return offsetToPosition(Code, StartOffset(T)); }; - auto EndOffset = [&](const Token &T) { + auto EndOffset = [&](const pseudo::Token &T) { return StartOffset(T) + OriginalToken(T).Length; }; - auto EndPosition = [&](const Token &T) { + auto EndPosition = [&](const pseudo::Token &T) { return offsetToPosition(Code, EndOffset(T)); }; auto Tokens = ParseableStream.tokens(); @@ -235,7 +235,7 @@ getFoldingRanges(const std::string &Code, bool LineFoldingOnly) { } } } - auto IsBlockComment = [&](const Token &T) { + auto IsBlockComment = [&](const pseudo::Token &T) { assert(T.Kind == tok::comment); return OriginalToken(T).Length >= 2 && Code.substr(StartOffset(T), 2) == "/*"; @@ -246,10 +246,10 @@ getFoldingRanges(const std::string &Code, bool LineFoldingOnly) { T++; continue; } - Token *FirstComment = T; + pseudo::Token *FirstComment = T; // Show starting sentinals (// and /*) of the comment. Position Start = offsetToPosition(Code, 2 + StartOffset(*FirstComment)); - Token *LastComment = T; + pseudo::Token *LastComment = T; Position End = EndPosition(*T); while (T != Tokens.end() && T->Kind == tok::comment && StartPosition(*T).line <= End.line + 1) { diff --git a/clang-tools-extra/clangd/TidyFastChecks.inc b/clang-tools-extra/clangd/TidyFastChecks.inc index de1a025602fa9..9050ce16127ff 100644 --- a/clang-tools-extra/clangd/TidyFastChecks.inc +++ b/clang-tools-extra/clangd/TidyFastChecks.inc @@ -7,435 +7,370 @@ #define SLOW(CHECK, DELTA) #endif -FAST(abseil-cleanup-ctad, -2.0) +FAST(abseil-cleanup-ctad, -1.0) FAST(abseil-duration-addition, 0.0) -FAST(abseil-duration-comparison, -1.0) -FAST(abseil-duration-conversion-cast, -1.0) -FAST(abseil-duration-division, 0.0) -FAST(abseil-duration-factory-float, 2.0) -FAST(abseil-duration-factory-scale, 1.0) -FAST(abseil-duration-subtraction, -1.0) -FAST(abseil-duration-unnecessary-conversion, -0.0) -FAST(abseil-faster-strsplit-delimiter, 3.0) -FAST(abseil-no-internal-dependencies, 1.0) -FAST(abseil-no-namespace, -0.0) -FAST(abseil-redundant-strcat-calls, 1.0) -FAST(abseil-str-cat-append, -0.0) -FAST(abseil-string-find-startswith, -1.0) -FAST(abseil-string-find-str-contains, 4.0) -FAST(abseil-time-comparison, -1.0) -FAST(abseil-time-subtraction, 1.0) +FAST(abseil-duration-comparison, 1.0) +FAST(abseil-duration-conversion-cast, 3.0) +FAST(abseil-duration-division, -0.0) +FAST(abseil-duration-factory-float, 1.0) +FAST(abseil-duration-factory-scale, -0.0) +FAST(abseil-duration-subtraction, 1.0) +FAST(abseil-duration-unnecessary-conversion, 4.0) +FAST(abseil-faster-strsplit-delimiter, 2.0) +FAST(abseil-no-internal-dependencies, -1.0) +FAST(abseil-no-namespace, -1.0) +FAST(abseil-redundant-strcat-calls, 2.0) +FAST(abseil-str-cat-append, 1.0) +FAST(abseil-string-find-startswith, 1.0) +FAST(abseil-string-find-str-contains, 1.0) +FAST(abseil-time-comparison, -0.0) +FAST(abseil-time-subtraction, 0.0) FAST(abseil-upgrade-duration-conversions, 2.0) SLOW(altera-id-dependent-backward-branch, 13.0) -FAST(altera-kernel-name-restriction, 4.0) -FAST(altera-single-work-item-barrier, 1.0) -FAST(altera-struct-pack-align, -0.0) +FAST(altera-kernel-name-restriction, -1.0) +FAST(altera-single-work-item-barrier, -1.0) +FAST(altera-struct-pack-align, -1.0) FAST(altera-unroll-loops, 2.0) -FAST(android-cloexec-accept, 0.0) -FAST(android-cloexec-accept4, 1.0) -FAST(android-cloexec-creat, 1.0) -FAST(android-cloexec-dup, 0.0) -FAST(android-cloexec-epoll-create, 2.0) -FAST(android-cloexec-epoll-create1, 0.0) -FAST(android-cloexec-fopen, -1.0) -FAST(android-cloexec-inotify-init, 2.0) -FAST(android-cloexec-inotify-init1, -0.0) -FAST(android-cloexec-memfd-create, -1.0) -FAST(android-cloexec-open, 1.0) -FAST(android-cloexec-pipe, -0.0) +FAST(android-cloexec-accept, -1.0) +FAST(android-cloexec-accept4, 3.0) +FAST(android-cloexec-creat, 0.0) +FAST(android-cloexec-dup, 3.0) +FAST(android-cloexec-epoll-create, -2.0) +FAST(android-cloexec-epoll-create1, -1.0) +FAST(android-cloexec-fopen, -0.0) +FAST(android-cloexec-inotify-init, 1.0) +FAST(android-cloexec-inotify-init1, 2.0) +FAST(android-cloexec-memfd-create, 2.0) +FAST(android-cloexec-open, -1.0) +FAST(android-cloexec-pipe, -1.0) FAST(android-cloexec-pipe2, 0.0) FAST(android-cloexec-socket, 1.0) -FAST(android-comparison-in-temp-failure-retry, 1.0) -FAST(boost-use-ranges, 2.0) -FAST(boost-use-to-string, 2.0) -FAST(bugprone-argument-comment, 4.0) +FAST(android-comparison-in-temp-failure-retry, 0.0) +FAST(boost-use-to-string, 1.0) +FAST(bugprone-argument-comment, 2.0) FAST(bugprone-assert-side-effect, 1.0) -FAST(bugprone-assignment-in-if-condition, 2.0) -FAST(bugprone-bad-signal-to-kill-thread, 1.0) +FAST(bugprone-assignment-in-if-condition, -0.0) +FAST(bugprone-bad-signal-to-kill-thread, -1.0) FAST(bugprone-bool-pointer-implicit-conversion, 0.0) -FAST(bugprone-branch-clone, 1.0) -FAST(bugprone-casting-through-void, 1.0) -FAST(bugprone-chained-comparison, 1.0) -FAST(bugprone-compare-pointer-to-member-virtual-function, -0.0) +FAST(bugprone-branch-clone, -0.0) FAST(bugprone-copy-constructor-init, 1.0) -FAST(bugprone-crtp-constructor-accessibility, 0.0) -FAST(bugprone-dangling-handle, -0.0) -FAST(bugprone-dynamic-static-initializers, 0.0) +FAST(bugprone-dangling-handle, 0.0) +FAST(bugprone-dynamic-static-initializers, 1.0) FAST(bugprone-easily-swappable-parameters, 2.0) -FAST(bugprone-empty-catch, 1.0) -FAST(bugprone-exception-escape, 0.0) -FAST(bugprone-fold-init-type, 1.0) +FAST(bugprone-exception-escape, 1.0) +FAST(bugprone-fold-init-type, 2.0) FAST(bugprone-forward-declaration-namespace, 0.0) -FAST(bugprone-forwarding-reference-overload, -1.0) -FAST(bugprone-implicit-widening-of-multiplication-result, 2.0) +FAST(bugprone-forwarding-reference-overload, -0.0) +FAST(bugprone-implicit-widening-of-multiplication-result, 3.0) FAST(bugprone-inaccurate-erase, -0.0) -FAST(bugprone-inc-dec-in-conditions, 3.0) -FAST(bugprone-incorrect-enable-if, -1.0) FAST(bugprone-incorrect-roundings, 1.0) -FAST(bugprone-infinite-loop, 1.0) -FAST(bugprone-integer-division, -0.0) -FAST(bugprone-lambda-function-name, 0.0) -FAST(bugprone-macro-parentheses, 1.0) +FAST(bugprone-infinite-loop, 4.0) +FAST(bugprone-integer-division, -3.0) +FAST(bugprone-lambda-function-name, 1.0) +FAST(bugprone-macro-parentheses, 8.0) FAST(bugprone-macro-repeated-side-effects, 1.0) -FAST(bugprone-misplaced-operator-in-strlen-in-alloc, 0.0) -FAST(bugprone-misplaced-pointer-arithmetic-in-alloc, -0.0) -FAST(bugprone-misplaced-widening-cast, -1.0) -FAST(bugprone-move-forwarding-reference, -1.0) -FAST(bugprone-multi-level-implicit-pointer-conversion, -1.0) -FAST(bugprone-multiple-new-in-one-expression, 0.0) -FAST(bugprone-multiple-statement-macro, 2.0) -FAST(bugprone-narrowing-conversions, 2.0) -FAST(bugprone-no-escape, 1.0) -FAST(bugprone-non-zero-enum-to-bool-conversion, 0.0) -FAST(bugprone-not-null-terminated-result, 0.0) -FAST(bugprone-optional-value-conversion, 1.0) -FAST(bugprone-parent-virtual-call, 1.0) -FAST(bugprone-pointer-arithmetic-on-polymorphic-object, 0.0) -FAST(bugprone-posix-return, -0.0) -FAST(bugprone-redundant-branch-condition, -0.0) -FAST(bugprone-reserved-identifier, -1.0) -FAST(bugprone-return-const-ref-from-parameter, -2.0) +FAST(bugprone-misplaced-operator-in-strlen-in-alloc, -0.0) +FAST(bugprone-misplaced-pointer-arithmetic-in-alloc, 2.0) +FAST(bugprone-misplaced-widening-cast, -2.0) +FAST(bugprone-move-forwarding-reference, -2.0) +FAST(bugprone-multiple-statement-macro, 1.0) +FAST(bugprone-narrowing-conversions, -1.0) +FAST(bugprone-no-escape, 3.0) +FAST(bugprone-not-null-terminated-result, 4.0) +FAST(bugprone-parent-virtual-call, 2.0) +FAST(bugprone-posix-return, 0.0) +FAST(bugprone-redundant-branch-condition, 0.0) +FAST(bugprone-reserved-identifier, 2.0) FAST(bugprone-shared-ptr-array-mismatch, 0.0) -FAST(bugprone-signal-handler, -1.0) -FAST(bugprone-signed-char-misuse, -2.0) -FAST(bugprone-sizeof-container, -1.0) -FAST(bugprone-sizeof-expression, 1.0) -FAST(bugprone-spuriously-wake-up-functions, 1.0) -FAST(bugprone-standalone-empty, 7.0) -FAST(bugprone-string-constructor, 3.0) -FAST(bugprone-string-integer-assignment, -0.0) -FAST(bugprone-string-literal-with-embedded-nul, 1.0) -FAST(bugprone-stringview-nullptr, 4.0) -FAST(bugprone-suspicious-enum-usage, 2.0) -FAST(bugprone-suspicious-include, 0.0) +FAST(bugprone-signal-handler, -0.0) +FAST(bugprone-signed-char-misuse, 1.0) +FAST(bugprone-sizeof-container, -0.0) +FAST(bugprone-sizeof-expression, 0.0) +FAST(bugprone-spuriously-wake-up-functions, 3.0) +FAST(bugprone-string-constructor, 1.0) +FAST(bugprone-string-integer-assignment, 1.0) +FAST(bugprone-string-literal-with-embedded-nul, 0.0) +FAST(bugprone-stringview-nullptr, 2.0) +FAST(bugprone-suspicious-enum-usage, -0.0) +FAST(bugprone-suspicious-include, 1.0) FAST(bugprone-suspicious-memory-comparison, 0.0) -FAST(bugprone-suspicious-memset-usage, 0.0) -FAST(bugprone-suspicious-missing-comma, -2.0) -FAST(bugprone-suspicious-realloc-usage, -0.0) -FAST(bugprone-suspicious-semicolon, 6.0) -FAST(bugprone-suspicious-string-compare, 1.0) -FAST(bugprone-suspicious-stringview-data-usage, 1.0) -FAST(bugprone-swapped-arguments, 1.0) -FAST(bugprone-switch-missing-default-case, 2.0) -FAST(bugprone-terminating-continue, -1.0) -FAST(bugprone-throw-keyword-missing, 0.0) +FAST(bugprone-suspicious-memset-usage, 2.0) +FAST(bugprone-suspicious-missing-comma, 0.0) +FAST(bugprone-suspicious-realloc-usage, 1.0) +FAST(bugprone-suspicious-semicolon, 0.0) +FAST(bugprone-suspicious-string-compare, 2.0) +FAST(bugprone-swapped-arguments, 0.0) +FAST(bugprone-terminating-continue, 2.0) +FAST(bugprone-throw-keyword-missing, -1.0) FAST(bugprone-too-small-loop-variable, 0.0) -FAST(bugprone-unchecked-optional-access, 2.0) +FAST(bugprone-unchecked-optional-access, 1.0) FAST(bugprone-undefined-memory-manipulation, 1.0) -FAST(bugprone-undelegated-constructor, 1.0) -FAST(bugprone-unhandled-exception-at-new, -1.0) +FAST(bugprone-undelegated-constructor, 0.0) +FAST(bugprone-unhandled-exception-at-new, 0.0) FAST(bugprone-unhandled-self-assignment, 0.0) -FAST(bugprone-unique-ptr-array-mismatch, 0.0) -FAST(bugprone-unsafe-functions, 1.0) -FAST(bugprone-unused-local-non-trivial-variable, -1.0) -FAST(bugprone-unused-raii, 1.0) -FAST(bugprone-unused-return-value, 4.0) -FAST(bugprone-use-after-move, 4.0) +FAST(bugprone-unused-raii, 2.0) +FAST(bugprone-unused-return-value, 0.0) +FAST(bugprone-use-after-move, 5.0) FAST(bugprone-virtual-near-miss, 0.0) -FAST(cert-con36-c, 1.0) -FAST(cert-con54-cpp, 2.0) -FAST(cert-ctr56-cpp, 0.0) -FAST(cert-dcl03-c, 0.0) -FAST(cert-dcl16-c, 1.0) -FAST(cert-dcl37-c, 1.0) +FAST(cert-con36-c, 2.0) +FAST(cert-con54-cpp, 3.0) +FAST(cert-dcl03-c, 2.0) +FAST(cert-dcl16-c, -1.0) +FAST(cert-dcl37-c, 3.0) FAST(cert-dcl50-cpp, -1.0) -FAST(cert-dcl51-cpp, -1.0) +FAST(cert-dcl51-cpp, 1.0) FAST(cert-dcl54-cpp, 0.0) -FAST(cert-dcl58-cpp, -0.0) -FAST(cert-dcl59-cpp, 1.0) -FAST(cert-env33-c, 1.0) -FAST(cert-err09-cpp, -0.0) +FAST(cert-dcl58-cpp, 1.0) +FAST(cert-dcl59-cpp, 0.0) +FAST(cert-env33-c, -1.0) +FAST(cert-err09-cpp, 1.0) FAST(cert-err33-c, 4.0) -FAST(cert-err34-c, -1.0) -FAST(cert-err52-cpp, -1.0) -FAST(cert-err58-cpp, -0.0) -FAST(cert-err60-cpp, -0.0) -FAST(cert-err61-cpp, 2.0) -FAST(cert-exp42-c, 1.0) +FAST(cert-err34-c, 0.0) +FAST(cert-err52-cpp, 1.0) +FAST(cert-err58-cpp, 0.0) +FAST(cert-err60-cpp, 0.0) +FAST(cert-err61-cpp, -0.0) +FAST(cert-exp42-c, 0.0) FAST(cert-fio38-c, 1.0) -FAST(cert-flp30-c, 3.0) +FAST(cert-flp30-c, 0.0) FAST(cert-flp37-c, 1.0) -FAST(cert-int09-c, -1.0) FAST(cert-mem57-cpp, 0.0) -FAST(cert-msc24-c, 0.0) -FAST(cert-msc30-c, 0.0) -FAST(cert-msc32-c, -0.0) -FAST(cert-msc33-c, 2.0) -FAST(cert-msc50-cpp, -0.0) -FAST(cert-msc51-cpp, 2.0) -FAST(cert-msc54-cpp, -0.0) -FAST(cert-oop11-cpp, -0.0) -FAST(cert-oop54-cpp, 2.0) -FAST(cert-oop57-cpp, -0.0) +FAST(cert-msc30-c, -0.0) +FAST(cert-msc32-c, 1.0) +FAST(cert-msc50-cpp, -1.0) +FAST(cert-msc51-cpp, 1.0) +FAST(cert-msc54-cpp, -1.0) +FAST(cert-oop11-cpp, 1.0) +FAST(cert-oop54-cpp, -0.0) +FAST(cert-oop57-cpp, 1.0) FAST(cert-oop58-cpp, 0.0) -FAST(cert-pos44-c, 2.0) -FAST(cert-pos47-c, 0.0) -FAST(cert-sig30-c, 1.0) -FAST(cert-str34-c, 2.0) +FAST(cert-pos44-c, 0.0) +FAST(cert-pos47-c, -0.0) +FAST(cert-sig30-c, 2.0) +FAST(cert-str34-c, 0.0) FAST(concurrency-mt-unsafe, 3.0) FAST(concurrency-thread-canceltype-asynchronous, 1.0) -FAST(cppcoreguidelines-avoid-c-arrays, 0.0) -FAST(cppcoreguidelines-avoid-capturing-lambda-coroutines, -1.0) -FAST(cppcoreguidelines-avoid-const-or-ref-data-members, -2.0) -FAST(cppcoreguidelines-avoid-do-while, -1.0) -FAST(cppcoreguidelines-avoid-goto, -1.0) -FAST(cppcoreguidelines-avoid-magic-numbers, -2.0) +FAST(cppcoreguidelines-avoid-c-arrays, 2.0) +FAST(cppcoreguidelines-avoid-const-or-ref-data-members, 1.0) +FAST(cppcoreguidelines-avoid-do-while, -2.0) +FAST(cppcoreguidelines-avoid-goto, 2.0) +FAST(cppcoreguidelines-avoid-magic-numbers, 1.0) FAST(cppcoreguidelines-avoid-non-const-global-variables, -0.0) -FAST(cppcoreguidelines-avoid-reference-coroutine-parameters, -0.0) FAST(cppcoreguidelines-c-copy-assignment-signature, 1.0) -FAST(cppcoreguidelines-explicit-virtual-functions, 0.0) -FAST(cppcoreguidelines-init-variables, 1.0) -FAST(cppcoreguidelines-interfaces-global-init, 1.0) -FAST(cppcoreguidelines-macro-to-enum, 0.0) -FAST(cppcoreguidelines-macro-usage, -0.0) -FAST(cppcoreguidelines-misleading-capture-default-by-value, -1.0) -FAST(cppcoreguidelines-missing-std-forward, 0.0) -FAST(cppcoreguidelines-narrowing-conversions, 2.0) +FAST(cppcoreguidelines-explicit-virtual-functions, -1.0) +FAST(cppcoreguidelines-init-variables, 2.0) +FAST(cppcoreguidelines-interfaces-global-init, -1.0) +FAST(cppcoreguidelines-macro-usage, 2.0) +FAST(cppcoreguidelines-narrowing-conversions, -2.0) FAST(cppcoreguidelines-no-malloc, -1.0) -FAST(cppcoreguidelines-no-suspend-with-lock, 1.0) -FAST(cppcoreguidelines-noexcept-destructor, -0.0) -FAST(cppcoreguidelines-noexcept-move-operations, 2.0) -FAST(cppcoreguidelines-noexcept-swap, -2.0) -FAST(cppcoreguidelines-non-private-member-variables-in-classes, 1.0) +FAST(cppcoreguidelines-non-private-member-variables-in-classes, -0.0) FAST(cppcoreguidelines-owning-memory, 3.0) -FAST(cppcoreguidelines-prefer-member-initializer, 2.0) -FAST(cppcoreguidelines-pro-bounds-array-to-pointer-decay, 2.0) -FAST(cppcoreguidelines-pro-bounds-constant-array-index, 1.0) +FAST(cppcoreguidelines-prefer-member-initializer, 1.0) +FAST(cppcoreguidelines-pro-bounds-array-to-pointer-decay, 3.0) +FAST(cppcoreguidelines-pro-bounds-constant-array-index, 3.0) FAST(cppcoreguidelines-pro-bounds-pointer-arithmetic, 0.0) -FAST(cppcoreguidelines-pro-type-const-cast, -1.0) -FAST(cppcoreguidelines-pro-type-cstyle-cast, 2.0) +FAST(cppcoreguidelines-pro-type-const-cast, 1.0) +FAST(cppcoreguidelines-pro-type-cstyle-cast, -1.0) FAST(cppcoreguidelines-pro-type-member-init, 1.0) -FAST(cppcoreguidelines-pro-type-reinterpret-cast, -1.0) +FAST(cppcoreguidelines-pro-type-reinterpret-cast, 2.0) FAST(cppcoreguidelines-pro-type-static-cast-downcast, 0.0) -FAST(cppcoreguidelines-pro-type-union-access, 0.0) -FAST(cppcoreguidelines-pro-type-vararg, -1.0) -FAST(cppcoreguidelines-rvalue-reference-param-not-moved, 1.0) -FAST(cppcoreguidelines-slicing, 1.0) +FAST(cppcoreguidelines-pro-type-union-access, 1.0) +FAST(cppcoreguidelines-pro-type-vararg, 1.0) +FAST(cppcoreguidelines-slicing, 3.0) FAST(cppcoreguidelines-special-member-functions, -1.0) -FAST(cppcoreguidelines-use-default-member-init, 0.0) -FAST(cppcoreguidelines-virtual-class-destructor, -0.0) -FAST(darwin-avoid-spinlock, 2.0) -FAST(darwin-dispatch-once-nonstatic, 0.0) -FAST(fuchsia-default-arguments-calls, 1.0) +FAST(cppcoreguidelines-virtual-class-destructor, 0.0) +FAST(darwin-avoid-spinlock, 1.0) +FAST(darwin-dispatch-once-nonstatic, -0.0) +FAST(fuchsia-default-arguments-calls, 2.0) FAST(fuchsia-default-arguments-declarations, -0.0) FAST(fuchsia-header-anon-namespaces, -0.0) -FAST(fuchsia-multiple-inheritance, 0.0) -FAST(fuchsia-overloaded-operator, 4.0) +FAST(fuchsia-multiple-inheritance, -1.0) +FAST(fuchsia-overloaded-operator, -0.0) FAST(fuchsia-statically-constructed-objects, -0.0) -FAST(fuchsia-trailing-return, 1.0) +FAST(fuchsia-trailing-return, 2.0) FAST(fuchsia-virtual-inheritance, 1.0) -FAST(google-build-explicit-make-pair, 3.0) +FAST(google-build-explicit-make-pair, 2.0) FAST(google-build-namespaces, -1.0) -FAST(google-build-using-namespace, -0.0) -FAST(google-default-arguments, 0.0) +FAST(google-build-using-namespace, 0.0) +FAST(google-default-arguments, 1.0) FAST(google-explicit-constructor, 2.0) -FAST(google-global-names-in-headers, 0.0) +FAST(google-global-names-in-headers, -1.0) FAST(google-objc-avoid-nsobject-new, 1.0) -FAST(google-objc-avoid-throwing-exception, -0.0) -FAST(google-objc-function-naming, -1.0) -FAST(google-objc-global-variable-declaration, 0.0) -FAST(google-readability-avoid-underscore-in-googletest-name, 1.0) -FAST(google-readability-braces-around-statements, 0.0) -FAST(google-readability-casting, -0.0) -FAST(google-readability-function-size, 3.0) -FAST(google-readability-namespace-comments, -0.0) +FAST(google-objc-avoid-throwing-exception, 1.0) +FAST(google-objc-function-naming, 1.0) +FAST(google-objc-global-variable-declaration, -0.0) +FAST(google-readability-avoid-underscore-in-googletest-name, -0.0) +FAST(google-readability-braces-around-statements, 1.0) +FAST(google-readability-casting, 1.0) +FAST(google-readability-function-size, 0.0) +FAST(google-readability-namespace-comments, 0.0) FAST(google-readability-todo, 1.0) -FAST(google-runtime-int, 0.0) -FAST(google-runtime-operator, 0.0) -FAST(google-upgrade-googletest-case, 1.0) +FAST(google-runtime-int, -1.0) +FAST(google-runtime-operator, -0.0) +FAST(google-upgrade-googletest-case, 0.0) FAST(hicpp-avoid-c-arrays, 1.0) -FAST(hicpp-avoid-goto, -0.0) -FAST(hicpp-braces-around-statements, 0.0) -FAST(hicpp-deprecated-headers, 1.0) -FAST(hicpp-exception-baseclass, -1.0) -FAST(hicpp-explicit-conversions, 1.0) +FAST(hicpp-avoid-goto, 0.0) +FAST(hicpp-braces-around-statements, 1.0) +FAST(hicpp-deprecated-headers, -1.0) +FAST(hicpp-exception-baseclass, 0.0) +FAST(hicpp-explicit-conversions, -1.0) FAST(hicpp-function-size, 1.0) -FAST(hicpp-ignored-remove-result, 3.0) -FAST(hicpp-invalid-access-moved, 4.0) +FAST(hicpp-invalid-access-moved, 6.0) FAST(hicpp-member-init, 2.0) -FAST(hicpp-move-const-arg, 3.0) -FAST(hicpp-multiway-paths-covered, 0.0) -FAST(hicpp-named-parameter, 2.0) -FAST(hicpp-new-delete-operators, -0.0) -FAST(hicpp-no-array-decay, 4.0) -FAST(hicpp-no-assembler, 1.0) -FAST(hicpp-no-malloc, 2.0) +FAST(hicpp-move-const-arg, 1.0) +FAST(hicpp-multiway-paths-covered, 3.0) +FAST(hicpp-named-parameter, 1.0) +FAST(hicpp-new-delete-operators, 0.0) +FAST(hicpp-no-array-decay, 3.0) +FAST(hicpp-no-assembler, -0.0) +FAST(hicpp-no-malloc, 1.0) FAST(hicpp-noexcept-move, -0.0) -FAST(hicpp-signed-bitwise, -1.0) -FAST(hicpp-special-member-functions, -2.0) -FAST(hicpp-static-assert, 4.0) -FAST(hicpp-undelegated-constructor, 6.0) -FAST(hicpp-uppercase-literal-suffix, 5.0) -FAST(hicpp-use-auto, 0.0) -FAST(hicpp-use-emplace, 3.0) -FAST(hicpp-use-equals-default, 2.0) -FAST(hicpp-use-equals-delete, 1.0) -FAST(hicpp-use-noexcept, -0.0) -FAST(hicpp-use-nullptr, 1.0) -FAST(hicpp-use-override, -1.0) -FAST(hicpp-vararg, 0.0) -FAST(linuxkernel-must-check-errs, -0.0) -FAST(llvm-else-after-return, -1.0) -FAST(llvm-header-guard, 3.0) -FAST(llvm-include-order, 0.0) -FAST(llvm-namespace-comment, 0.0) -FAST(llvm-prefer-isa-or-dyn-cast-in-conditionals, 3.0) -FAST(llvm-prefer-register-over-unsigned, -0.0) -FAST(llvm-qualified-auto, 4.0) -FAST(llvm-twine-local, -0.0) -FAST(llvmlibc-callee-namespace, -0.0) -FAST(llvmlibc-implementation-in-namespace, 1.0) -FAST(llvmlibc-inline-function-decl, 3.0) -FAST(llvmlibc-restrict-system-libc-headers, 0.0) -FAST(misc-confusable-identifiers, -1.0) -SLOW(misc-const-correctness, 67.0) -FAST(misc-coroutine-hostile-raii, 1.0) +FAST(hicpp-signed-bitwise, 0.0) +FAST(hicpp-special-member-functions, 0.0) +FAST(hicpp-static-assert, 1.0) +FAST(hicpp-undelegated-constructor, 3.0) +FAST(hicpp-uppercase-literal-suffix, 3.0) +FAST(hicpp-use-auto, 3.0) +FAST(hicpp-use-emplace, 1.0) +FAST(hicpp-use-equals-default, 1.0) +FAST(hicpp-use-equals-delete, 0.0) +FAST(hicpp-use-noexcept, -1.0) +FAST(hicpp-use-nullptr, 2.0) +FAST(hicpp-use-override, -0.0) +FAST(hicpp-vararg, -2.0) +FAST(linuxkernel-must-check-errs, 1.0) +FAST(llvm-else-after-return, 0.0) +FAST(llvm-header-guard, 2.0) +FAST(llvm-include-order, 3.0) +FAST(llvm-namespace-comment, 1.0) +FAST(llvm-prefer-isa-or-dyn-cast-in-conditionals, 0.0) +FAST(llvm-prefer-register-over-unsigned, 1.0) +FAST(llvm-qualified-auto, 0.0) +FAST(llvm-twine-local, -2.0) +FAST(llvmlibc-callee-namespace, 2.0) +FAST(llvmlibc-implementation-in-namespace, 2.0) +FAST(llvmlibc-restrict-system-libc-headers, -0.0) +FAST(misc-confusable-identifiers, 1.0) +SLOW(misc-const-correctness, 261.0) FAST(misc-definitions-in-headers, -1.0) -SLOW(misc-header-include-cycle, 10.0) -FAST(misc-include-cleaner, 5.0) -FAST(misc-misleading-bidirectional, 1.0) -FAST(misc-misleading-identifier, 3.0) -FAST(misc-misplaced-const, -2.0) -FAST(misc-new-delete-overloads, 1.0) -FAST(misc-no-recursion, 0.0) -FAST(misc-non-copyable-objects, 0.0) -FAST(misc-non-private-member-variables-in-classes, -1.0) -FAST(misc-redundant-expression, 1.0) -FAST(misc-static-assert, 3.0) -FAST(misc-throw-by-value-catch-by-reference, -0.0) +FAST(misc-misleading-bidirectional, -0.0) +FAST(misc-misleading-identifier, -1.0) +FAST(misc-misplaced-const, 1.0) +FAST(misc-new-delete-overloads, -1.0) +FAST(misc-no-recursion, -2.0) +FAST(misc-non-copyable-objects, 1.0) +FAST(misc-non-private-member-variables-in-classes, 2.0) +FAST(misc-redundant-expression, 0.0) +FAST(misc-static-assert, 1.0) +FAST(misc-throw-by-value-catch-by-reference, -1.0) FAST(misc-unconventional-assign-operator, 1.0) -FAST(misc-uniqueptr-reset-release, 2.0) -FAST(misc-unused-alias-decls, 2.0) -FAST(misc-unused-parameters, 3.0) -FAST(misc-unused-using-decls, 1.0) -FAST(misc-use-anonymous-namespace, 1.0) -FAST(misc-use-internal-linkage, 1.0) +FAST(misc-uniqueptr-reset-release, 0.0) +FAST(misc-unused-alias-decls, 1.0) +FAST(misc-unused-parameters, 0.0) +FAST(misc-unused-using-decls, 4.0) FAST(modernize-avoid-bind, 1.0) FAST(modernize-avoid-c-arrays, 2.0) -FAST(modernize-concat-nested-namespaces, -0.0) -FAST(modernize-deprecated-headers, 0.0) -FAST(modernize-deprecated-ios-base-aliases, 0.0) +FAST(modernize-concat-nested-namespaces, -1.0) +FAST(modernize-deprecated-headers, -0.0) +FAST(modernize-deprecated-ios-base-aliases, 1.0) FAST(modernize-loop-convert, 2.0) -FAST(modernize-macro-to-enum, 0.0) -FAST(modernize-make-shared, 2.0) -FAST(modernize-make-unique, 1.0) -FAST(modernize-min-max-use-initializer-list, 1.0) -FAST(modernize-pass-by-value, 0.0) -FAST(modernize-raw-string-literal, 2.0) -FAST(modernize-redundant-void-arg, 1.0) -FAST(modernize-replace-auto-ptr, 0.0) -FAST(modernize-replace-disallow-copy-and-assign-macro, -0.0) -FAST(modernize-replace-random-shuffle, 1.0) -FAST(modernize-return-braced-init-list, 1.0) -FAST(modernize-shrink-to-fit, 1.0) -FAST(modernize-type-traits, 1.0) -FAST(modernize-unary-static-assert, 1.0) -FAST(modernize-use-auto, 0.0) +FAST(modernize-macro-to-enum, 1.0) +FAST(modernize-make-shared, -0.0) +FAST(modernize-make-unique, 0.0) +FAST(modernize-pass-by-value, 1.0) +FAST(modernize-raw-string-literal, 1.0) +FAST(modernize-redundant-void-arg, -1.0) +FAST(modernize-replace-auto-ptr, -1.0) +FAST(modernize-replace-disallow-copy-and-assign-macro, -2.0) +FAST(modernize-replace-random-shuffle, 0.0) +FAST(modernize-return-braced-init-list, -1.0) +FAST(modernize-shrink-to-fit, 2.0) +FAST(modernize-unary-static-assert, -1.0) +FAST(modernize-use-auto, 2.0) FAST(modernize-use-bool-literals, 1.0) -FAST(modernize-use-constraints, 1.0) -FAST(modernize-use-default-member-init, -0.0) -FAST(modernize-use-designated-initializers, 1.0) -FAST(modernize-use-emplace, 2.0) -FAST(modernize-use-equals-default, 1.0) -FAST(modernize-use-equals-delete, 2.0) -FAST(modernize-use-nodiscard, -2.0) -FAST(modernize-use-noexcept, -2.0) -FAST(modernize-use-nullptr, 1.0) -FAST(modernize-use-override, 0.0) -FAST(modernize-use-ranges, 0.0) -FAST(modernize-use-starts-ends-with, 0.0) -FAST(modernize-use-std-format, -1.0) -FAST(modernize-use-std-numbers, 0.0) -FAST(modernize-use-std-print, -0.0) -FAST(modernize-use-trailing-return-type, 3.0) -FAST(modernize-use-transparent-functors, 0.0) -FAST(modernize-use-uncaught-exceptions, 0.0) +FAST(modernize-use-default-member-init, 2.0) +FAST(modernize-use-emplace, 1.0) +FAST(modernize-use-equals-default, 2.0) +FAST(modernize-use-equals-delete, 0.0) +FAST(modernize-use-nodiscard, 1.0) +FAST(modernize-use-noexcept, 1.0) +FAST(modernize-use-nullptr, 2.0) +FAST(modernize-use-override, 1.0) +FAST(modernize-use-trailing-return-type, -0.0) +FAST(modernize-use-transparent-functors, -1.0) +FAST(modernize-use-uncaught-exceptions, 1.0) FAST(modernize-use-using, 1.0) -FAST(objc-assert-equals, 1.0) -FAST(objc-avoid-nserror-init, -0.0) -FAST(objc-dealloc-in-category, 0.0) -FAST(objc-forbidden-subclassing, 2.0) -FAST(objc-missing-hash, -0.0) -FAST(objc-nsdate-formatter, 0.0) -FAST(objc-nsinvocation-argument-lifetime, 0.0) -FAST(objc-property-declaration, -0.0) -FAST(objc-super-self, -2.0) -FAST(openmp-exception-escape, -1.0) -FAST(openmp-use-default-none, 2.0) -FAST(performance-avoid-endl, 2.0) -FAST(performance-enum-size, -1.0) -FAST(performance-faster-string-find, 1.0) -FAST(performance-for-range-copy, 1.0) -FAST(performance-implicit-conversion-in-loop, 0.0) -FAST(performance-inefficient-algorithm, 1.0) -FAST(performance-inefficient-string-concatenation, 1.0) -FAST(performance-inefficient-vector-operation, -0.0) -FAST(performance-move-const-arg, 2.0) -FAST(performance-move-constructor-init, 2.0) -FAST(performance-no-automatic-move, 2.0) -FAST(performance-no-int-to-ptr, 0.0) -FAST(performance-noexcept-destructor, -2.0) +FAST(objc-assert-equals, -1.0) +FAST(objc-avoid-nserror-init, -2.0) +FAST(objc-dealloc-in-category, -0.0) +FAST(objc-forbidden-subclassing, 0.0) +FAST(objc-missing-hash, 1.0) +FAST(objc-nsdate-formatter, 1.0) +FAST(objc-nsinvocation-argument-lifetime, -2.0) +FAST(objc-property-declaration, -1.0) +FAST(objc-super-self, -0.0) +FAST(openmp-exception-escape, 1.0) +FAST(openmp-use-default-none, 1.0) +FAST(performance-faster-string-find, 2.0) +FAST(performance-for-range-copy, 2.0) +FAST(performance-implicit-conversion-in-loop, 1.0) +FAST(performance-inefficient-algorithm, 0.0) +FAST(performance-inefficient-string-concatenation, -0.0) +FAST(performance-inefficient-vector-operation, 1.0) +FAST(performance-move-const-arg, 3.0) +FAST(performance-move-constructor-init, 1.0) +FAST(performance-no-automatic-move, -1.0) +FAST(performance-no-int-to-ptr, 2.0) FAST(performance-noexcept-move-constructor, 1.0) -FAST(performance-noexcept-swap, -2.0) -FAST(performance-trivially-destructible, 3.0) -FAST(performance-type-promotion-in-math-fn, 2.0) -FAST(performance-unnecessary-copy-initialization, 2.0) +FAST(performance-trivially-destructible, -1.0) +FAST(performance-type-promotion-in-math-fn, 4.0) +FAST(performance-unnecessary-copy-initialization, 4.0) FAST(performance-unnecessary-value-param, 2.0) -FAST(portability-restrict-system-includes, 1.0) -FAST(portability-simd-intrinsics, 1.0) -FAST(portability-std-allocator-const, 3.0) +FAST(portability-restrict-system-includes, 2.0) +FAST(portability-simd-intrinsics, 2.0) +FAST(portability-std-allocator-const, 2.0) FAST(readability-avoid-const-params-in-decls, -0.0) -FAST(readability-avoid-nested-conditional-operator, -1.0) -FAST(readability-avoid-return-with-void-value, 0.0) -FAST(readability-avoid-unconditional-preprocessor-if, -1.0) -FAST(readability-braces-around-statements, 1.0) -FAST(readability-const-return-type, -1.0) -FAST(readability-container-contains, 3.0) -FAST(readability-container-data-pointer, -1.0) -SLOW(readability-container-size-empty, 13.0) -FAST(readability-convert-member-functions-to-static, 4.0) -FAST(readability-delete-null-pointer, -1.0) -FAST(readability-duplicate-include, 2.0) -FAST(readability-else-after-return, 0.0) -FAST(readability-enum-initial-value, 0.0) +FAST(readability-braces-around-statements, 2.0) +FAST(readability-const-return-type, -0.0) +FAST(readability-container-contains, -0.0) +FAST(readability-container-data-pointer, 0.0) +SLOW(readability-container-size-empty, 16.0) +FAST(readability-convert-member-functions-to-static, 0.0) +FAST(readability-delete-null-pointer, 0.0) +FAST(readability-duplicate-include, -0.0) +FAST(readability-else-after-return, 1.0) FAST(readability-function-cognitive-complexity, 0.0) -FAST(readability-function-size, 0.0) -FAST(readability-identifier-length, 2.0) -FAST(readability-identifier-naming, 1.0) -FAST(readability-implicit-bool-conversion, 3.0) -FAST(readability-inconsistent-declaration-parameter-name, -0.0) -FAST(readability-isolate-declaration, 0.0) -FAST(readability-magic-numbers, 4.0) -FAST(readability-make-member-function-const, 1.0) -FAST(readability-math-missing-parentheses, 1.0) -FAST(readability-misleading-indentation, 1.0) -FAST(readability-misplaced-array-index, 0.0) +FAST(readability-function-size, 3.0) +FAST(readability-identifier-length, -1.0) +FAST(readability-identifier-naming, 5.0) +FAST(readability-implicit-bool-conversion, 2.0) +FAST(readability-inconsistent-declaration-parameter-name, 1.0) +FAST(readability-isolate-declaration, 1.0) +FAST(readability-magic-numbers, -1.0) +FAST(readability-make-member-function-const, 2.0) +FAST(readability-misleading-indentation, 0.0) +FAST(readability-misplaced-array-index, -0.0) FAST(readability-named-parameter, -0.0) -FAST(readability-non-const-parameter, 2.0) -FAST(readability-operators-representation, 0.0) -FAST(readability-qualified-auto, 0.0) -FAST(readability-redundant-access-specifiers, 1.0) -FAST(readability-redundant-casting, -0.0) -FAST(readability-redundant-control-flow, 1.0) -FAST(readability-redundant-declaration, 1.0) -FAST(readability-redundant-function-ptr-dereference, 0.0) -FAST(readability-redundant-inline-specifier, 0.0) -FAST(readability-redundant-member-init, 1.0) -FAST(readability-redundant-preprocessor, -0.0) -FAST(readability-redundant-smartptr-get, 4.0) -FAST(readability-redundant-string-cstr, 1.0) -FAST(readability-redundant-string-init, -0.0) -FAST(readability-reference-to-constructed-temporary, 3.0) -FAST(readability-simplify-boolean-expr, -0.0) -FAST(readability-simplify-subscript-expr, 1.0) -FAST(readability-static-accessed-through-instance, 0.0) -FAST(readability-static-definition-in-anonymous-namespace, 0.0) +FAST(readability-non-const-parameter, 1.0) +FAST(readability-qualified-auto, -0.0) +FAST(readability-redundant-access-specifiers, -1.0) +FAST(readability-redundant-control-flow, -1.0) +FAST(readability-redundant-declaration, -0.0) +FAST(readability-redundant-function-ptr-dereference, -1.0) +FAST(readability-redundant-member-init, 0.0) +FAST(readability-redundant-preprocessor, 0.0) +FAST(readability-redundant-smartptr-get, 6.0) +FAST(readability-redundant-string-cstr, 0.0) +FAST(readability-redundant-string-init, 1.0) +FAST(readability-simplify-boolean-expr, 1.0) +FAST(readability-simplify-subscript-expr, -0.0) +FAST(readability-static-accessed-through-instance, 1.0) +FAST(readability-static-definition-in-anonymous-namespace, -0.0) FAST(readability-string-compare, -0.0) -FAST(readability-suspicious-call-argument, -1.0) -FAST(readability-uniqueptr-delete-release, 3.0) -FAST(readability-uppercase-literal-suffix, 0.0) -FAST(readability-use-anyofallof, 2.0) -FAST(readability-use-std-min-max, -1.0) +FAST(readability-suspicious-call-argument, 0.0) +FAST(readability-uniqueptr-delete-release, 1.0) +FAST(readability-uppercase-literal-suffix, 3.0) +FAST(readability-use-anyofallof, 1.0) FAST(zircon-temporary-objects, 1.0) #undef FAST diff --git a/clang-tools-extra/clangd/support/CMakeLists.txt b/clang-tools-extra/clangd/support/CMakeLists.txt index 506a3f2c8551d..0c8c199dd4a4c 100644 --- a/clang-tools-extra/clangd/support/CMakeLists.txt +++ b/clang-tools-extra/clangd/support/CMakeLists.txt @@ -16,12 +16,9 @@ if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB OR NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB) endif() add_clang_library(clangdSupport - Bracket.cpp Cancellation.cpp Context.cpp - DirectiveTree.cpp FileCache.cpp - Lex.cpp Logger.cpp Markup.cpp MemoryTree.cpp @@ -30,16 +27,9 @@ add_clang_library(clangdSupport ThreadCrashReporter.cpp Threading.cpp ThreadsafeFS.cpp - Token.cpp Trace.cpp LINK_LIBS ${LLVM_PTHREAD_LIB} ${CLANGD_ATOMIC_LIB} ) - -clang_target_link_libraries(clangdSupport - PRIVATE - clangBasic - clangLex - ) diff --git a/clang-tools-extra/clangd/unittests/ClangdTests.cpp b/clang-tools-extra/clangd/unittests/ClangdTests.cpp index 643b8e9f12d75..c324643498d94 100644 --- a/clang-tools-extra/clangd/unittests/ClangdTests.cpp +++ b/clang-tools-extra/clangd/unittests/ClangdTests.cpp @@ -29,7 +29,6 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" -#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX #include "llvm/Support/Allocator.h" #include "llvm/Support/Error.h" #include "llvm/Support/Path.h" diff --git a/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp b/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp index 2ce2975bd962b..b64dd4acad4c2 100644 --- a/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp +++ b/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp @@ -18,7 +18,6 @@ #include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" -#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" diff --git a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp index cf9b42828568d..4ecfdf0184ab4 100644 --- a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp +++ b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp @@ -298,41 +298,20 @@ TEST_F(ConfigCompileTests, DiagnosticSuppression) { "unreachable-code", "unused-variable", "typecheck_bool_condition", "unexpected_friend", "warn_alloca")); - clang::DiagnosticsEngine DiagEngine(new DiagnosticIDs, nullptr, - new clang::IgnoringDiagConsumer); - - using Diag = clang::Diagnostic; - { - auto D = DiagEngine.Report(diag::warn_unreachable); - EXPECT_TRUE(isDiagnosticSuppressed( - Diag{&DiagEngine, D}, Conf.Diagnostics.Suppress, LangOptions())); - } + EXPECT_TRUE(isBuiltinDiagnosticSuppressed( + diag::warn_unreachable, Conf.Diagnostics.Suppress, LangOptions())); // Subcategory not respected/suppressed. - { - auto D = DiagEngine.Report(diag::warn_unreachable_break); - EXPECT_FALSE(isDiagnosticSuppressed( - Diag{&DiagEngine, D}, Conf.Diagnostics.Suppress, LangOptions())); - } - { - auto D = DiagEngine.Report(diag::warn_unused_variable); - EXPECT_TRUE(isDiagnosticSuppressed( - Diag{&DiagEngine, D}, Conf.Diagnostics.Suppress, LangOptions())); - } - { - auto D = DiagEngine.Report(diag::err_typecheck_bool_condition); - EXPECT_TRUE(isDiagnosticSuppressed( - Diag{&DiagEngine, D}, Conf.Diagnostics.Suppress, LangOptions())); - } - { - auto D = DiagEngine.Report(diag::err_unexpected_friend); - EXPECT_TRUE(isDiagnosticSuppressed( - Diag{&DiagEngine, D}, Conf.Diagnostics.Suppress, LangOptions())); - } - { - auto D = DiagEngine.Report(diag::warn_alloca); - EXPECT_TRUE(isDiagnosticSuppressed( - Diag{&DiagEngine, D}, Conf.Diagnostics.Suppress, LangOptions())); - } + EXPECT_FALSE(isBuiltinDiagnosticSuppressed( + diag::warn_unreachable_break, Conf.Diagnostics.Suppress, LangOptions())); + EXPECT_TRUE(isBuiltinDiagnosticSuppressed( + diag::warn_unused_variable, Conf.Diagnostics.Suppress, LangOptions())); + EXPECT_TRUE(isBuiltinDiagnosticSuppressed(diag::err_typecheck_bool_condition, + Conf.Diagnostics.Suppress, + LangOptions())); + EXPECT_TRUE(isBuiltinDiagnosticSuppressed( + diag::err_unexpected_friend, Conf.Diagnostics.Suppress, LangOptions())); + EXPECT_TRUE(isBuiltinDiagnosticSuppressed( + diag::warn_alloca, Conf.Diagnostics.Suppress, LangOptions())); Frag.Diagnostics.Suppress.emplace_back("*"); EXPECT_TRUE(compileAndApply()); diff --git a/clang-tools-extra/clangd/unittests/SerializationTests.cpp b/clang-tools-extra/clangd/unittests/SerializationTests.cpp index 2a7a6c36d3d17..35a2e2ba77a65 100644 --- a/clang-tools-extra/clangd/unittests/SerializationTests.cpp +++ b/clang-tools-extra/clangd/unittests/SerializationTests.cpp @@ -12,7 +12,6 @@ #include "support/Logger.h" #include "clang/Tooling/CompilationDatabase.h" #include "llvm/ADT/StringExtras.h" -#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX #include "llvm/Support/Compression.h" #include "llvm/Support/Error.h" #include "llvm/Support/ScopedPrinter.h" diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index d032cef6b7616..b001a6ad44669 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -43,11 +43,6 @@ infrastructure are described first, followed by tool-specific sections. Major New Features ------------------ -- The ``clang-pseudo`` tool is incomplete and does not have active maintainers, - so it has been removed. See - `the RFC `_ for - more details. - ... Improvements to clangd @@ -92,89 +87,32 @@ Improvements to clang-doc Improvements to clang-query --------------------------- +Improvements to clang-rename +---------------------------- + The improvements are... Improvements to clang-tidy -------------------------- -- Improved :program:`run-clang-tidy.py` script. Fixed minor shutdown noise - happening on certain platforms when interrupting the script. - New checks ^^^^^^^^^^ New check aliases ^^^^^^^^^^^^^^^^^ -- New alias :doc:`cert-arr39-c ` to - :doc:`bugprone-sizeof-expression - ` was added. - Changes in existing checks ^^^^^^^^^^^^^^^^^^^^^^^^^^ -- Improved :doc:`bugprone-casting-through-void - ` check to suggest replacing - the offending code with ``reinterpret_cast``, to more clearly express intent. - -- Improved :doc:`bugprone-forwarding-reference-overload - ` check by fixing - a crash when determining if an ``enable_if[_t]`` was found. - -- Improved :doc:`bugprone-sizeof-expression - ` check to find suspicious - usages of ``sizeof()``, ``alignof()``, and ``offsetof()`` when adding or - subtracting from a pointer. - -- Improved :doc:`cert-flp30-c ` check to - fix false positive that floating point variable is only used in increment - expression. - -- Improved :doc:`cppcoreguidelines-prefer-member-initializer - ` check to - avoid false positive when member initialization depends on a structured - binding variable. - -- Improved :doc:`misc-definitions-in-headers - ` check by rewording the - diagnostic note that suggests adding ``inline``. - -- Improved :doc:`modernize-avoid-c-arrays - ` check to suggest using ``std::span`` - as a replacement for parameters of incomplete C array type in C++20 and - ``std::array`` or ``std::vector`` before C++20. - - Improved :doc:`modernize-use-std-format ` check to support replacing member function calls too. -- Improved :doc:`misc-unconventional-assign-operator - ` check to avoid - false positive for C++23 deducing this. - -- Improved :doc:`modernize-min-max-use-initializer-list - ` check by fixing - a false positive when only an implicit conversion happened inside an - initializer list. - - Improved :doc:`modernize-use-std-print ` check to support replacing member function calls too. -- Improved :doc:`readability-enum-initial-value - ` check by only issuing - diagnostics for the definition of an ``enum``, and by fixing a typo in the - diagnostic. - -- Improved :doc:`performance-avoid-endl - ` check to use ``std::endl`` as - placeholder when lexer cannot get source text. - -- Improved :doc:`readability-container-contains - ` check to let it work on - any class that has a ``contains`` method. - -- Improved :doc:`readability-implicit-bool-conversion +- Improved :doc:`readablility-implicit-bool-conversion ` check by adding the option `UseUpperCaseLiteralSuffix` to select the case of the literal suffix in fixes. diff --git a/clang-tools-extra/docs/clang-rename.rst b/clang-tools-extra/docs/clang-rename.rst new file mode 100644 index 0000000000000..e13d8c3ad25f9 --- /dev/null +++ b/clang-tools-extra/docs/clang-rename.rst @@ -0,0 +1,168 @@ +============ +Clang-Rename +============ + +.. contents:: + +See also: + +.. toctree:: + :maxdepth: 1 + + +:program:`clang-rename` is a C++ refactoring tool. Its purpose is to perform +efficient renaming actions in large-scale projects such as renaming classes, +functions, variables, arguments, namespaces etc. + +The tool is in a very early development stage, so you might encounter bugs and +crashes. Submitting reports with information about how to reproduce the issue +to `the LLVM bugtracker `_ will definitely help the +project. If you have any ideas or suggestions, you might want to put a feature +request there. + +Using Clang-Rename +================== + +:program:`clang-rename` is a `LibTooling +`_-based tool, and it's easier to +work with if you set up a compile command database for your project (for an +example of how to do this see `How To Setup Tooling For LLVM +`_). You can also +specify compilation options on the command line after `--`: + +.. code-block:: console + + $ clang-rename -offset=42 -new-name=foo test.cpp -- -Imy_project/include -DMY_DEFINES ... + + +To get an offset of a symbol in a file run + +.. code-block:: console + + $ grep -FUbo 'foo' file.cpp + + +The tool currently supports renaming actions inside a single translation unit +only. It is planned to extend the tool's functionality to support multi-TU +renaming actions in the future. + +:program:`clang-rename` also aims to be easily integrated into popular text +editors, such as Vim and Emacs, and improve the workflow of users. + +Although a command line interface exists, it is highly recommended to use the +text editor interface instead for better experience. + +You can also identify one or more symbols to be renamed by giving the fully +qualified name: + +.. code-block:: console + + $ clang-rename -qualified-name=foo -new-name=bar test.cpp + +Renaming multiple symbols at once is supported, too. However, +:program:`clang-rename` doesn't accept both `-offset` and `-qualified-name` at +the same time. So, you can either specify multiple `-offset` or +`-qualified-name`. + +.. code-block:: console + + $ clang-rename -offset=42 -new-name=bar1 -offset=150 -new-name=bar2 test.cpp + +or + +.. code-block:: console + + $ clang-rename -qualified-name=foo1 -new-name=bar1 -qualified-name=foo2 -new-name=bar2 test.cpp + + +Alternatively, {offset | qualified-name} / new-name pairs can be put into a YAML +file: + +.. code-block:: yaml + + --- + - Offset: 42 + NewName: bar1 + - Offset: 150 + NewName: bar2 + ... + +or + +.. code-block:: yaml + + --- + - QualifiedName: foo1 + NewName: bar1 + - QualifiedName: foo2 + NewName: bar2 + ... + +That way you can avoid spelling out all the names as command line arguments: + +.. code-block:: console + + $ clang-rename -input=test.yaml test.cpp + +:program:`clang-rename` offers the following options: + +.. code-block:: console + + $ clang-rename --help + USAGE: clang-rename [subcommand] [options] [... ] + + OPTIONS: + + Generic Options: + + -help - Display available options (-help-hidden for more) + -help-list - Display list of available options (-help-list-hidden for more) + -version - Display the version of this program + + clang-rename common options: + + -export-fixes= - YAML file to store suggested fixes in. + -extra-arg= - Additional argument to append to the compiler command line + Can be used several times. + -extra-arg-before= - Additional argument to prepend to the compiler command line + Can be used several times. + -force - Ignore nonexistent qualified names. + -i - Overwrite edited s. + -input= - YAML file to load oldname-newname pairs from. + -new-name= - The new name to change the symbol to. + -offset= - Locates the symbol by offset as opposed to :. + -p - Build path + -pl - Print the locations affected by renaming to stderr. + -pn - Print the found symbol's name prior to renaming to stderr. + -qualified-name= - The fully qualified name of the symbol. + +Vim Integration +=============== + +You can call :program:`clang-rename` directly from Vim! To set up +:program:`clang-rename` integration for Vim see +`clang/tools/clang-rename/clang-rename.py +`_. + +Please note that **you have to save all buffers, in which the replacement will +happen before running the tool**. + +Once installed, you can point your cursor to symbols you want to rename, press +`cr` and type new desired name. The ` key +`_ +is a reference to a specific key defined by the mapleader variable and is bound +to backslash by default. + +Emacs Integration +================= + +You can also use :program:`clang-rename` while using Emacs! To set up +:program:`clang-rename` integration for Emacs see +`clang-rename/tool/clang-rename.el +`_. + +Once installed, you can point your cursor to symbols you want to rename, press +`M-X`, type `clang-rename` and new desired name. + +Please note that **you have to save all buffers, in which the replacement will +happen before running the tool**. diff --git a/clang-tools-extra/docs/clang-tidy/Contributing.rst b/clang-tools-extra/docs/clang-tidy/Contributing.rst index ff8b05ff263c1..d5303418b859b 100644 --- a/clang-tools-extra/docs/clang-tidy/Contributing.rst +++ b/clang-tools-extra/docs/clang-tidy/Contributing.rst @@ -344,20 +344,18 @@ matching expressions to simplify your matcher. clang-query> let c1 cxxRecordDecl() clang-query> match c1 -Alternatively, pressing the tab key after a previous matcher's open parentheses -would also show which matchers can be chained with the previous matcher, -though some matchers that work may not be listed. Note that tab completion -does not currently work on Windows. - -Just like breaking up a huge function into smaller chunks with -intention-revealing names can help you understand a complex algorithm, breaking -up a matcher into smaller matchers with intention-revealing names can help -you understand a complicated matcher. - -Once you have a working :program:`clang-query` matcher, the C++ API matchers -will be the same or similar to your interactively constructed matcher (there -can be cases where they differ slightly). You can use local variables to preserve -your intention-revealing names that you applied to nested matchers. +Alternatively, pressing the tab key after a previous matcher's open parentheses would also +show which matchers can be chained with the previous matcher, though some matchers that work +may not be listed. + +Just like breaking up a huge function into smaller chunks with intention-revealing names +can help you understand a complex algorithm, breaking up a matcher into smaller matchers +with intention-revealing names can help you understand a complicated matcher. + +Once you have a working clang-query matcher, the C++ API matchers will be the same or similar +to your interactively constructed matcher (there can be cases where they differ slightly). +You can use local variables to preserve your intention-revealing names that you applied +to nested matchers. Creating private matchers ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/casting-through-void.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/casting-through-void.rst index d9f94b6a3f20b..a9ab478b9a82e 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/casting-through-void.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/casting-through-void.rst @@ -3,9 +3,7 @@ bugprone-casting-through-void ============================= -Detects unsafe or redundant two-step casting operations involving ``void*``, -which is equivalent to ``reinterpret_cast`` as per the -`C++ Standard `_. +Detects unsafe or redundant two-step casting operations involving ``void*``. Two-step type conversions via ``void*`` are discouraged for several reasons. @@ -18,17 +16,7 @@ Two-step type conversions via ``void*`` are discouraged for several reasons. In summary, avoiding two-step type conversions through ``void*`` ensures clearer code, maintains essential compiler warnings, and prevents ambiguity and potential runtime -errors, particularly in complex inheritance scenarios. If such a cast is wanted, -it shall be done via ``reinterpret_cast``, to express the intent more clearly. - -Note: it is expected that, after applying the suggested fix and using -``reinterpret_cast``, the check :doc:`cppcoreguidelines-pro-type-reinterpret-cast -<../cppcoreguidelines/pro-type-reinterpret-cast>` will emit a warning. -This is intentional: ``reinterpret_cast`` is a dangerous operation that can -easily break the strict aliasing rules when dereferencing the casted pointer, -invoking Undefined Behavior. The warning is there to prompt users to carefuly -analyze whether the usage of ``reinterpret_cast`` is safe, in which case the -warning may be suppressed. +errors, particularly in complex inheritance scenarios. Examples: @@ -41,8 +29,3 @@ Examples: reinterpret_cast(reinterpret_cast(ptr)); // WRONG (IntegerPointer)(void *)ptr; // WRONG IntegerPointer(static_cast(ptr)); // WRONG - - reinterpret_cast(ptr); // OK, clearly expresses intent. - // NOTE: dereferencing this pointer violates - // the strict aliasing rules, invoking - // Undefined Behavior. diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/pointer-arithmetic-on-polymorphic-object.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/pointer-arithmetic-on-polymorphic-object.rst index 95509ef3c724d..1884acd5f12b3 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/pointer-arithmetic-on-polymorphic-object.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/pointer-arithmetic-on-polymorphic-object.rst @@ -19,28 +19,20 @@ Example: .. code-block:: c++ struct Base { - virtual ~Base(); - int i; + virtual void ~Base(); }; struct Derived : public Base {}; - void foo(Base* b) { + void foo() { + Base *b = new Derived[10]; + b += 1; // warning: pointer arithmetic on class that declares a virtual function can // result in undefined behavior if the dynamic type differs from the // pointer type - } - - int bar(const Derived d[]) { - return d[1].i; // warning due to pointer arithmetic on polymorphic object - } - // Making Derived final suppresses the warning - struct FinalDerived final : public Base {}; - - int baz(const FinalDerived d[]) { - return d[1].i; // no warning as FinalDerived is final + delete[] static_cast(b); } Options @@ -55,9 +47,17 @@ Options .. code-block:: c++ - void bar(Base b[], Derived d[]) { + void bar() { + Base *b = new Base[10]; b += 1; // warning, as Base declares a virtual destructor + + delete[] b; + + Derived *d = new Derived[10]; // Derived overrides the destructor, and + // declares no other virtual functions d += 1; // warning only if IgnoreVirtualDeclarationsOnly is set to false + + delete[] d; } References diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst index 2349e51477b7d..f007dfe549990 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst @@ -12,15 +12,6 @@ after the call. When the function returns such a parameter also as constant refe then the returned reference can be used after the object it refers to has been destroyed. -This issue can be resolved by declaring an overload of the problematic function -where the ``const &`` parameter is instead declared as ``&&``. The developer has -to ensure that the implementation of that function does not produce a -use-after-free, the exact error that this check is warning against. -Marking such an ``&&`` overload as ``deleted``, will silence the warning as -well. In the case of different ``const &`` parameters being returned depending -on the control flow of the function, an overload where all problematic -``const &`` parameters have been declared as ``&&`` will resolve the issue. - Example ------- diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/sizeof-expression.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/sizeof-expression.rst index 89c88d2740dba..ed5bb4fbb89ba 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/sizeof-expression.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/sizeof-expression.rst @@ -164,103 +164,6 @@ hidden through macros. memcpy(dst, buf, sizeof(INT_SZ)); // sizeof(sizeof(int)) is suspicious. } -Suspicious usages of 'sizeof(...)' in pointer arithmetic --------------------------------------------------------- - -Arithmetic operators on pointers automatically scale the result with the size -of the pointed typed. -Further use of ``sizeof`` around pointer arithmetic will typically result in an -unintended result. - -Scaling the result of pointer difference -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Subtracting two pointers results in an integer expression (of type -``ptrdiff_t``) which expresses the distance between the two pointed objects in -"number of objects between". -A common mistake is to think that the result is "number of bytes between", and -scale the difference with ``sizeof``, such as ``P1 - P2 == N * sizeof(T)`` -(instead of ``P1 - P2 == N``) or ``(P1 - P2) / sizeof(T)`` instead of -``P1 - P2``. - -.. code-block:: c++ - - void splitFour(const Obj* Objs, size_t N, Obj Delimiter) { - const Obj *P = Objs; - while (P < Objs + N) { - if (*P == Delimiter) { - break; - } - } - - if (P - Objs != 4 * sizeof(Obj)) { // Expecting a distance multiplied by sizeof is suspicious. - error(); - } - } - -.. code-block:: c++ - - void iterateIfEvenLength(int *Begin, int *End) { - auto N = (Begin - End) / sizeof(int); // Dividing by sizeof() is suspicious. - if (N % 2) - return; - - // ... - } - -Stepping a pointer with a scaled integer -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Conversely, when performing pointer arithmetics to add or subtract from a -pointer, the arithmetic operator implicitly scales the value actually added to -the pointer with the size of the pointee, as ``Ptr + N`` expects ``N`` to be -"number of objects to step", and not "number of bytes to step". - -Seeing the calculation of a pointer where ``sizeof`` appears is suspicious, -and the result is typically unintended, often out of bounds. -``Ptr + sizeof(T)`` will offset the pointer by ``sizeof(T)`` elements, -effectively exponentiating the scaling factor to the power of 2. - -This case also checks suspicious ``alignof`` and ``offsetof`` usages in -pointer arithmetic, as both return the "size" in bytes and not elements, -potentially resulting in doubly-scaled offsets. - -.. code-block:: c++ - - void printEveryEvenIndexElement(int *Array, size_t N) { - int *P = Array; - while (P <= Array + N * sizeof(int)) { // Suspicious pointer arithmetic using sizeof()! - printf("%d ", *P); - - P += 2 * sizeof(int); // Suspicious pointer arithmetic using sizeof()! - } - } - -.. code-block:: c++ - - struct Message { /* ... */; char Flags[8]; }; - void clearFlags(Message *Array, size_t N) { - const Message *End = Array + N; - while (Array < End) { - memset(Array + offsetof(Message, Flags), // Suspicious pointer arithmetic using offsetof()! - 0, sizeof(Message::Flags)); - ++Array; - } - } - -For this checked bogus pattern, `cert-arr39-c` redirects here as an alias of -this check. - -This check corresponds to the CERT C Coding Standard rule -`ARR39-C. Do not add or subtract a scaled integer to a pointer -`_. - -Limitations -""""""""""" - -Cases where the pointee type has a size of `1` byte (such as, and most -importantly, ``char``) are excluded. - Options ------- diff --git a/clang-tools-extra/docs/clang-tidy/checks/cert/arr39-c.rst b/clang-tools-extra/docs/clang-tidy/checks/cert/arr39-c.rst deleted file mode 100644 index 21353c61eede8..0000000000000 --- a/clang-tools-extra/docs/clang-tidy/checks/cert/arr39-c.rst +++ /dev/null @@ -1,10 +0,0 @@ -.. title:: clang-tidy - cert-arr39-c -.. meta:: - :http-equiv=refresh: 5;URL=../bugprone/sizeof-expression.html - -cert-arr39-c -============ - -The `cert-arr39-c` check is an alias, please see -:doc:`bugprone-sizeof-expression <../bugprone/sizeof-expression>` -for more information. diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst index 1909d7b8d8e24..a931ebf025a10 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/list.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst @@ -407,7 +407,6 @@ Check aliases :header: "Name", "Redirect", "Offers fixes" :doc:`bugprone-narrowing-conversions `, :doc:`cppcoreguidelines-narrowing-conversions `, - :doc:`cert-arr39-c `, :doc:`bugprone-sizeof-expression `, :doc:`cert-con36-c `, :doc:`bugprone-spuriously-wake-up-functions `, :doc:`cert-con54-cpp `, :doc:`bugprone-spuriously-wake-up-functions `, :doc:`cert-ctr56-cpp `, :doc:`bugprone-pointer-arithmetic-on-polymorphic-object `, diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst b/clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst index 8ac1ad56bc8cf..86fba6c7e4f7c 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst @@ -7,7 +7,8 @@ This check implements detection of local variables which could be declared as ``const`` but are not. Declaring variables as ``const`` is required or recommended by many coding guidelines, such as: `ES.25 `_ -from the C++ Core Guidelines. +from the C++ Core Guidelines and `AUTOSAR C++14 Rule A7-1-1 (6.7.1 Specifiers) +`_. Please note that this check's analysis is type-based only. Variables that are not modified but used to create a non-const handle that might escape the scope are not diagnosed diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc/unconventional-assign-operator.rst b/clang-tools-extra/docs/clang-tidy/checks/misc/unconventional-assign-operator.rst index 49e3fd5b6ee42..3b4b65a5cb683 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc/unconventional-assign-operator.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/misc/unconventional-assign-operator.rst @@ -13,3 +13,6 @@ types and definitions with good return type but wrong ``return`` statements. type (e.g. ``int``). * Private and deleted operators are ignored. * The operator must always return ``*this``. + +This check implements `AUTOSAR C++14 Rule A13-2-1 +`_. diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-c-arrays.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-c-arrays.rst index 6a386ecd0fd4b..8f13ca4466a31 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-c-arrays.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-c-arrays.rst @@ -10,32 +10,29 @@ modernize-avoid-c-arrays Finds C-style array types and recommend to use ``std::array<>`` / ``std::vector<>``. All types of C arrays are diagnosed. -For parameters of incomplete C-style array type, it would be better to -use ``std::span`` / ``gsl::span`` as replacement. - However, fix-it are potentially dangerous in header files and are therefore not emitted right now. .. code:: c++ - int a[] = {1, 2}; // warning: do not declare C-style arrays, use 'std::array' instead + int a[] = {1, 2}; // warning: do not declare C-style arrays, use std::array<> instead - int b[1]; // warning: do not declare C-style arrays, use 'std::array' instead + int b[1]; // warning: do not declare C-style arrays, use std::array<> instead void foo() { - int c[b[0]]; // warning: do not declare C VLA arrays, use 'std::vector' instead + int c[b[0]]; // warning: do not declare C VLA arrays, use std::vector<> instead } template class array { - T d[Size]; // warning: do not declare C-style arrays, use 'std::array' instead + T d[Size]; // warning: do not declare C-style arrays, use std::array<> instead - int e[1]; // warning: do not declare C-style arrays, use 'std::array' instead + int e[1]; // warning: do not declare C-style arrays, use std::array<> instead }; - array d; // warning: do not declare C-style arrays, use 'std::array' instead + array d; // warning: do not declare C-style arrays, use std::array<> instead - using k = int[4]; // warning: do not declare C-style arrays, use 'std::array' instead + using k = int[4]; // warning: do not declare C-style arrays, use std::array<> instead However, the ``extern "C"`` code is ignored, since it is common to share diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-format.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-format.rst index b88fde5162e28..1ec753ef090de 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-format.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-format.rst @@ -43,7 +43,7 @@ Options extern std::string strprintf(const char *format, ...); int i = -42; unsigned int u = 0xffffffff; - return strprintf("%u %d\n", i, u); + return strprintf("%d %u\n", i, u); would be converted to diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst index e70402ad8b334..59bb722e2c24f 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst @@ -103,7 +103,7 @@ Options int i = -42; unsigned int u = 0xffffffff; - printf("%u %d\n", i, u); + printf("%d %u\n", i, u); would be converted to: diff --git a/clang-tools-extra/docs/clang-tidy/checks/readability/avoid-nested-conditional-operator.rst b/clang-tools-extra/docs/clang-tidy/checks/readability/avoid-nested-conditional-operator.rst index cd3906855d497..44b74283292ce 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/readability/avoid-nested-conditional-operator.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/readability/avoid-nested-conditional-operator.rst @@ -16,3 +16,6 @@ Examples: int NestInConditional = (condition1 ? true1 : false1) ? true2 : false2; int NestInTrue = condition1 ? (condition2 ? true1 : false1) : false2; int NestInFalse = condition1 ? true1 : condition2 ? true2 : false1; + +This check implements part of `AUTOSAR C++14 Rule A5-16-1 +`_. diff --git a/clang-tools-extra/docs/clang-tidy/checks/readability/container-contains.rst b/clang-tools-extra/docs/clang-tidy/checks/readability/container-contains.rst index 1cfbf4c511c58..b28daecf7a2cf 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/readability/container-contains.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/readability/container-contains.rst @@ -3,31 +3,23 @@ readability-container-contains ============================== -Finds usages of ``container.count()`` and -``container.find() == container.end()`` which should be replaced by a call to -the ``container.contains()`` method. +Finds usages of ``container.count()`` and ``container.find() == container.end()`` which should be replaced by a call to the ``container.contains()`` method introduced in C++20. -Whether an element is contained inside a container should be checked with -``contains`` instead of ``count``/``find`` because ``contains`` conveys the -intent more clearly. Furthermore, for containers which permit multiple entries -per key (``multimap``, ``multiset``, ...), ``contains`` is more efficient than -``count`` because ``count`` has to do unnecessary additional work. +Whether an element is contained inside a container should be checked with ``contains`` instead of ``count``/``find`` because ``contains`` conveys the intent more clearly. Furthermore, for containers which permit multiple entries per key (``multimap``, ``multiset``, ...), ``contains`` is more efficient than ``count`` because ``count`` has to do unnecessary additional work. Examples: -====================================== ===================================== -Initial expression Result --------------------------------------- ------------------------------------- -``myMap.find(x) == myMap.end()`` ``!myMap.contains(x)`` -``myMap.find(x) != myMap.end()`` ``myMap.contains(x)`` -``if (myMap.count(x))`` ``if (myMap.contains(x))`` -``bool exists = myMap.count(x)`` ``bool exists = myMap.contains(x)`` -``bool exists = myMap.count(x) > 0`` ``bool exists = myMap.contains(x)`` -``bool exists = myMap.count(x) >= 1`` ``bool exists = myMap.contains(x)`` -``bool missing = myMap.count(x) == 0`` ``bool missing = !myMap.contains(x)`` -====================================== ===================================== +=========================================== ============================== +Initial expression Result +------------------------------------------- ------------------------------ +``myMap.find(x) == myMap.end()`` ``!myMap.contains(x)`` +``myMap.find(x) != myMap.end()`` ``myMap.contains(x)`` +``if (myMap.count(x))`` ``if (myMap.contains(x))`` +``bool exists = myMap.count(x)`` ``bool exists = myMap.contains(x)`` +``bool exists = myMap.count(x) > 0`` ``bool exists = myMap.contains(x)`` +``bool exists = myMap.count(x) >= 1`` ``bool exists = myMap.contains(x)`` +``bool missing = myMap.count(x) == 0`` ``bool missing = !myMap.contains(x)`` +=========================================== ============================== -This check will apply to any class that has a ``contains`` method, notably -including ``std::set``, ``std::unordered_set``, ``std::map``, and -``std::unordered_map`` as of C++20, and ``std::string`` and ``std::string_view`` -as of C++23. +This check applies to ``std::set``, ``std::unordered_set``, ``std::map``, ``std::unordered_map`` and the corresponding multi-key variants. +It is only active for C++20 and later, as the ``contains`` method was only added in C++20. diff --git a/clang-tools-extra/docs/index.rst b/clang-tools-extra/docs/index.rst index 9f7324fcf7419..d5c00b89a1555 100644 --- a/clang-tools-extra/docs/index.rst +++ b/clang-tools-extra/docs/index.rst @@ -19,6 +19,7 @@ Contents clang-include-fixer modularize pp-trace + clang-rename clangd clang-doc diff --git a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp index aae3eda519ffd..f7a2ebd526068 100644 --- a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp +++ b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp @@ -15,7 +15,6 @@ #include "clang/AST/DeclTemplate.h" #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" -#include "clang/AST/NestedNameSpecifier.h" #include "clang/AST/RecursiveASTVisitor.h" #include "clang/AST/TemplateBase.h" #include "clang/AST/TemplateName.h" @@ -24,11 +23,9 @@ #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/Specifiers.h" -#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLFunctionalExtras.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Casting.h" -#include "llvm/Support/ErrorHandling.h" namespace clang::include_cleaner { namespace { @@ -128,24 +125,6 @@ class ASTWalker : public RecursiveASTVisitor { return true; } - bool qualifierIsNamespaceOrNone(DeclRefExpr *DRE) { - const auto *Qual = DRE->getQualifier(); - if (!Qual) - return true; - switch (Qual->getKind()) { - case NestedNameSpecifier::Namespace: - case NestedNameSpecifier::NamespaceAlias: - case NestedNameSpecifier::Global: - return true; - case NestedNameSpecifier::TypeSpec: - case NestedNameSpecifier::TypeSpecWithTemplate: - case NestedNameSpecifier::Super: - case NestedNameSpecifier::Identifier: - return false; - } - llvm_unreachable("Unknown value for NestedNameSpecifierKind"); - } - bool VisitDeclRefExpr(DeclRefExpr *DRE) { auto *FD = DRE->getFoundDecl(); // Prefer the underlying decl if FoundDecl isn't a shadow decl, e.g: @@ -167,8 +146,10 @@ class ASTWalker : public RecursiveASTVisitor { // // If it's an enum constant, it must be due to prior decl. Report references // to it when qualifier isn't a type. - if (llvm::isa(FD) && qualifierIsNamespaceOrNone(DRE)) - report(DRE->getLocation(), FD); + if (llvm::isa(FD)) { + if (!DRE->getQualifier() || DRE->getQualifier()->getAsNamespace()) + report(DRE->getLocation(), FD); + } return true; } diff --git a/clang-tools-extra/include-cleaner/test/tool-ignores-warnings.cpp b/clang-tools-extra/include-cleaner/test/tool-ignores-warnings.cpp deleted file mode 100644 index e207a32c950d5..0000000000000 --- a/clang-tools-extra/include-cleaner/test/tool-ignores-warnings.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// RUN: clang-include-cleaner %s -- -Wunused 2>&1 | FileCheck --allow-empty %s -static void foo() {} - -// Make sure that we don't get an unused warning -// CHECK-NOT: unused function diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp index afae4365587ae..d8a44ab9b6e12 100644 --- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp +++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp @@ -139,17 +139,7 @@ class Action : public clang::ASTFrontendAction { } void ExecuteAction() override { - const auto &CI = getCompilerInstance(); - - // Disable all warnings when running include-cleaner, as we are only - // interested in include-cleaner related findings. This makes the tool both - // more resilient around in-development code, and possibly faster as we - // skip some extra analysis. - auto &Diags = CI.getDiagnostics(); - Diags.setEnableAllWarnings(false); - Diags.setSeverityForAll(clang::diag::Flavor::WarningOrError, - clang::diag::Severity::Ignored); - auto &P = CI.getPreprocessor(); + auto &P = getCompilerInstance().getPreprocessor(); P.addPPCallbacks(PP.record(P)); PI.record(getCompilerInstance()); ASTFrontendAction::ExecuteAction(); diff --git a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp index e45ea36f7938e..9286758cab081 100644 --- a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp +++ b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp @@ -534,9 +534,6 @@ TEST(WalkAST, Enums) { testWalk(R"(namespace ns { enum E { A = 42 }; } struct S { using ns::E::A; };)", "int e = S::^A;"); - testWalk(R"(namespace ns { enum E { $explicit^A = 42 }; })", - "namespace z = ns; int e = z::^A;"); - testWalk(R"(enum E { $explicit^A = 42 };)", "int e = ::^A;"); } TEST(WalkAST, InitializerList) { diff --git a/clang-tools-extra/pseudo/CMakeLists.txt b/clang-tools-extra/pseudo/CMakeLists.txt new file mode 100644 index 0000000000000..24bc1530bb7d6 --- /dev/null +++ b/clang-tools-extra/pseudo/CMakeLists.txt @@ -0,0 +1,12 @@ +include_directories(include) +include_directories(${CMAKE_CURRENT_BINARY_DIR}/include) +add_subdirectory(include) +add_subdirectory(gen) +add_subdirectory(lib) +add_subdirectory(tool) +add_subdirectory(fuzzer) +add_subdirectory(benchmarks) +if(CLANG_INCLUDE_TESTS) + add_subdirectory(unittests) + add_subdirectory(test) +endif() diff --git a/clang-tools-extra/pseudo/DesignNotes.md b/clang-tools-extra/pseudo/DesignNotes.md new file mode 100644 index 0000000000000..421cc02aef757 --- /dev/null +++ b/clang-tools-extra/pseudo/DesignNotes.md @@ -0,0 +1,123 @@ +# Error recovery (2022-05-07) + +Problem: we have two fairly generic cases of recovery bounded within a range: + - sequences: `int x; this is absolute garbage; x++;` + - brackets: `void foo() { this is garbage too }` + +So far, we've thought of these as different, and had precise ideas about +brackets ("lazy parsing") and vague ones about sequences. +Con we unify them instead? + +In both cases we want to recognize the bounds of the garbage item based on +basic token-level features of the surrounding code, and avoid any interference +with the surrounding code. + +## Brackets + +Consider a rule like `compound-stmt := { stmt-seq }`. + +The desired recovery is: +- if we fail at `{ . stmt-seq }` +- ... and we can find for the matching `}` +- then consume up to that token as an opaque broken `stmt-seq` +- ... and advance state to `{ stmt-seq . }` + +We can annotate the rule to describe this: `{ stmt-seq [recovery] }`. +We can generalize as `{ stmt-seq [recovery=rbrace] }`, allowing for different +**strategies** to find the resume point. + +(It's OK to assume we're skipping over one RHS nonterminal, we can always +introduce a nonterminal for the bracket contents if necessary). + +## Sequences + +Can we apply the same technique to sequences? +Simplest case: delimited right-recursive sequence. + +``` +param-list := param +param-list := param , param-list +``` + +We need recovery in **both** rules. +`param` in the first rule matches the *last* param in a list, +in the second rule it matches all others. We want to recover in any position. + +If we want to be able to recovery `int x int y` as two parameters, then we +should extract a `param-and-comma` rule that recovery could operate on. + +### Last vs not-last elements + +Sequences will usually have two rules with recovery, we discussed: + - how to pick the correct one to recover with + - in a left-recursive rule they correspond to last & not-last elements + - the recovery strategy knows whether we're recoverying last or not-last + - we could have the strategy return (pos, symbol parsed), and artificially + require distinct symbols (e.g. `stmt` vs `last_stmt`). + - we can rewrite left-recursion in the grammar as right-recursion + +However, on reflection I think we can simply allow recovery according to both +rules. The "wrong" recovery will produce a parse head that dies. + +## How recovery fits into GLR + +Recovery should kick in at the point where we would otherwise abandon all +variants of an high-level parse. + +e.g. Suppose we're parsing `static_cast(1)` and are up to `bar`. +Our GSS looks something like: + +``` + "the static cast's type starts at foo" +---> {expr := static_cast < . type > ( expr )} + | "foo... is a class name" + +---- {type := identifier .} + | "foo... is a template ID" + +---- {type := identifier . < template-arg-list >} +``` + +Since `foo bar baz` isn't a valid class name or template ID, both active heads +will soon die, as will the parent GSS Node - the latter should trigger recovery. + +- we need a refcount in GSS nodes so we can recognize never-reduced node death +- when a node dies, we look up its recovery actions (symbol, strategy). + These are the union of the recovery actions for each item. + They can be stored in the action table. + Here: `actions[State, death] = Recovery(type, matching-angle-bracket)` +- we try each strategy: feeding in the start position = token of the dying node + (`foo`) getting out the end position (`>`). +- We form an opaque forest node with the correct symbol (`type`) spanning + [start, end) +- We create a GSS node to represent the state after recovery. + The new state is found in the Goto table in the usual way. + +``` + "the static cast's type starts at foo" +---> {expr := static_cast < . type > ( expr )} + | "`foo bar baz` is an unparseable type" + +---- {expr := static_cast < type . > (expr)} +``` + +## Which recovery heads to activate + +We probably shouldn't *always* create active recovery heads when a recoverable +node dies (and thus keep it alive). +By design GLR creates multiple speculative parse heads and lets incorrect heads +disappear. + +Concretely, the expression `(int *)(x)` is a valid cast, we probably shouldn't +also parse it as a call whose callee is a broken expr. + +The simplest solution is to only create recovery heads if there are no normal +heads remaining, i.e. if parsing is completely stuck. This is vulnerable if the +"wrong" parse makes slightly more progress than the "right" parse which has +better error recovery. + +A sophisticated variant might record recovery opportunities and pick the one +with the rightmost *endpoint* when the last parse head dies. + +We should consider whether including every recovery in the parse forest might +work after all - this would let disambiguation choose "broken" but likely parses +over "valid" but unlikely ones. + + diff --git a/clang-tools-extra/pseudo/Disambiguation.md b/clang-tools-extra/pseudo/Disambiguation.md new file mode 100644 index 0000000000000..39e246a523beb --- /dev/null +++ b/clang-tools-extra/pseudo/Disambiguation.md @@ -0,0 +1,367 @@ +# Disambiguation + +The C++ grammar is highly ambiguous, so the GLR parser produces a forest of +parses, represented compactly by a DAG. +A real C++ parser finds the correct parse through semantic analysis: mostly +resolving names. But we can't do that, as we don't parse the headers. + +Our disambiguation phase should take the parse forest, and choose a single parse +tree that is most likely. +It might **optionally** use some other hints (e.g. coding style, or what +specific names tend to mean in this codebase). + +There are some grammatical ambiguities that can be resolved without semantic +analysis, e.g. whether `int {}` is a function-definition. +We eliminate these earlier e.g., with rule guards. By "disambiguation" we mean +choosing between interpretations that we can't reject confidently and locally. + +## Types of evidence + +We have limited information to go on, and strive to use similar heuristics a +human reader might. + +### Likely and unlikely structure + +In some cases, the shape of a particular interpretation is unlikely but not +impossible. For example, the statement `x(a);` might: + +- call a function `x` (likely) +- construct a temporary of class type `x` (less likely) +- define a variable `a` of type `x`, which is an alias for e.g. `int` + (unlikely!) + +We model this as a bonus/penalty for including a particular forest node in the +chosen parse. For each rule we want to apply, we can write some code to +recognize the corresponding pattern in the parse tree, and run these recognizers +at each node to assign the bonuses. + +### Interpreting names + +Just as resolving names allows a C++ parser to choose the right parse (rejecting +others), chunks of a parse tree imply things about how names resolve. + +Because the same name often means the same thing in different contexts, we can +apply knowledge from elsewhere. This can be as simple as knowing "`vector` is +usually a type", and adding bonuses to nodes that include that interpretation. + +However we can also transfer knowlegde across the same file we're parsing: + +```cpp +// Is `Builder` a class or a namespace? +void Builder::build() { ... } +// ... +// `Builder` is a type. +Builder b; +``` + +We can use this to understand more-ambiguous code based on names in a section +we're more sure about. It also pushes us to provide a consistent parse, rather +than interpreting each occurrence of an unclear name differently. + +Again, we can define bonuses/penalties for forest nodes that interpret names, +but this time those bonuses change as we disambiguate. Specifically: + +- we can group identifiers into **classes**, most importantly "all identifiers + with text 'foo'" but also "all snake_case identifiers". +- clusters of nodes immediately above the identifiers in the parse forest are + **interpretations**, they bind the identifier to a **kind** such "type", + "value", "namespace", "other". +- for each class we can query information once from an external source (such as + an index or hard-coded list), yielding a vector of weights (one per kind) +- at each point we can compute metrics based on interpretations in the forest: + - the number of identifiers in the class that are interpreted as each kind + (e.g. *all* remaining interpretations of 'foo' at 3:7 are 'type') + - the number of identifiers in the class that *may* be interpereted as each + kind (e.g. 'foo' at 3:7 might be a 'type'). +- we can mash these metrics together into a vector of bonuses for a class (e.g. + for identifiers with text 'bar', 'type'=>+5, 'namespace'=>+1, 'value'=>-2). +- these bonuses are assigned to corresponding interpretations in the graph + +### Templates + +Another aspect of a name is whether it names a template (type or value). This +is ambiguous in many more cases since CTAD allowed template arguments to be +omitted. + +A fairly simple heuristic appears sufficient here: things that look like +templates usually are, so if a node for certain rules exists in the forest +(e.g. `template-id := template-name < template-argument-list >`) then we treat +the template name as a probable template, and apply a bonus to every node that +interprets it that way. We do this even if alternate parses are possible +(`a < b > :: c` might be a comparison, but is still evidence `a` is a template). + +## Algorithm sketch + +With static node scores, finding the best tree is a very tractable problem +with an efficient solution. +With dynamic scores it becomes murky and we have to settle for approximations. +These build on the same idea, so we'll look at the simple version first. + +### Naive version (static scores) + +At a high level, we want to assign bonuses to nodes, and find the tree that +maximizes the total score. If bonuses were fixed, independent of other +disambiguation decisions, then we could simply walk bottom-up, aggregating +scores and replacing each ambiguous node with the top-scoring alternative +subtree. This could happen directly on the parse tree. + +Given this tree as input: + +```mermaid +flowchart TB + subgraph   + idA["a"] + open["("] + idB["b"] + close[")"] + semi[";"] + end + class idA,open,idB,close,semi token; + + typeA["type := IDENTIFIER"] --- idA + exprA["expr := IDENTIFIER"] --- idA + exprB["expr := IDENTIFIER"] --- idB + declB["declarator := IDENTIFIER"] --- idB + stmtExpr --- semi + stmtDecl --- semi + + stmtAmbig["stmt?"]:::ambig + stmtAmbig === stmtExpr["stmt := expr ;"] + stmtExpr --- exprAmbig["expr?"]:::ambig + exprAmbig === funcall["expr := expr ( expr )"]:::good + funcall --- exprA + funcall --- open + funcall --- exprB["expr := IDENTIFIER"] + funcall --- close + exprAmbig -.- construct["expr := type ( expr )"]:::bad + construct --- typeA + construct --- open + construct --- exprB + construct --- close + stmtAmbig -.- stmtDecl["stmt := decl"] + stmtDecl --- decl["decl := type declarator ;"] + decl --- typeA + decl --- declParens["declarator := ( declarator )"]:::bad + declParens --- open + declParens --- declB + declParens --- close + + classDef ambig fill:blue,color:white; + classDef token fill:yellow; + classDef good fill:lightgreen + classDef bad fill:pink +``` + +A post-order traversal reaches the ambiguous node `expr?` first. +The left alternative has a total score of +1 (green bonus for +`expr := expr (expr)`) and the right alternative has a total bonus of -1 +(red penalty for `expr := type (expr)`). So we replace `expr?` with its left +alternative. + +As we continue traversing, we reach `stmt?` next: again we have +1 in the left +subtree and -1 in the right subtree, so we pick the left one. Result: + +```mermaid +flowchart TB + subgraph   + idA["a"] + open["("] + idB["b"] + close[")"] + semi[";"] + end + class idA,open,idB,close,semi token; + + typeA["type := IDENTIFIER"] --- idA + exprA["expr := IDENTIFIER"] --- idA + exprB["expr := IDENTIFIER"] --- idB + declB["declarator := IDENTIFIER"] --- idB + stmtExpr --- semi + stmtDecl --- semi + + stmtExpr["stmt := expr ;"] + stmtExpr --- funcall["expr := expr ( expr )"] + funcall --- exprA + funcall --- open + funcall --- exprB["expr := IDENTIFIER"] + funcall --- close + + classDef token fill:yellow; +``` + +### Degrees of freedom + +We must traverse the DAG bottom-up in order to make score-based decisions: +if an ambiguous node has ambiguous descendants then we can't calculate the score +for that subtree. + +This gives us a topological **partial** order, but we don't have to go from +left-to-right. At any given point there is a "frontier" of ambiguous nodes with +no ambiguous descendants. The sequence we choose matters: each choice adds +more interpretations that should affect future choices. + +Initially, most of the ambiguous nodes in the frontier will be e.g. "is this +identifier a type or a value". If we had to work left-to-right then we'd +immediately be forced to resolve the first name in the file, likely with +little to go on and high chance of a mistake. +But there are probably names where we have strong evidence, e.g. we've seen an +(unambiguous) declaration of a variable `foo`, so other occurrences of `foo` +are very likely to be values rather than types. We can disambiguate these with +high confidence, and these choices are likely to "unlock" other conclusions that +we can use for further disambiguation. + +This is intuitively similar to how people decipher ambiguous code: they find a +piece that's easy to understand, read that to learn what names mean, and use +the knowledge gained to study the more difficult parts. + +To formalize this a little: +- we prioritize making the **highest confidence** decisions first +- we define **confidence** as the score of the accepted alternative, minus the + score of the best rejected alternative. + +### Removing the bottom-up restriction + +Strictly only resolving "frontier" ambiguities may cause problems. +Consider the following example: + +```mermaid +flowchart TB + subgraph   + a:::token + b:::token + end + + ambig1:::ambig + ambig1 --- choice1:::good + ambig1 --- choice2 + choice1 --- ambig2:::ambig + ambig2 --- aType["a is class"] --- a + ambig2 --- aTemplate["a is CTAD"] --- a + choice1 --- bValue["b is variable"] --- b + + classDef ambig fill:blue,color:white; + classDef token fill:yellow; + classDef good fill:lightgreen + classDef bad fill:pink +``` + +We have some evidence that `choice1` is good. If we selected it, we would know +that `b` is a variable and could use this in disambiguating the rest of the +file. However we can't select `choice1` until we decide exactly how to interpret +`a`, and there might be little info to do so. Gating higher-confidence decisions +on lower-confidence ones increases our chance of making an error. + +A possible fix would be to generalize to a **range** of possible scores for +nodes above the frontier, and rank by **minimum confidence**, i.e. the highest +min-score of the accepted alternative, minus the highest max-score among the +rejected alternative. + +## Details + +The remaining challenges are mainly: +- defining the score function for an alternative. This is TBD, pending + experiments. +- finding a data structure and algorithm to efficiently resolve/re-evaluate + in a loop until we've resolved all ambiguities. + +### Disambiguation DAG + +Rather than operate on the forest directly, it's simpler to consider a reduced +view that hides complexity unrelated to disambiguation: + +**Forest:** + +```mermaid +flowchart TB + subgraph   + open["{"] + a + star["*"] + b + semi[";"] + close["}"] + end + class open,a,star,b,semi,close token + + compound-stmt --- open + compound-stmt --- stmt? + compound-stmt --- close + + stmt?:::ambig --- decl-stmt + decl-stmt --- type-name + type-name --a is type--- a + decl-stmt --- declarator + declarator --- star + declarator --- declarator_b["declarator"] + declarator_b --b is value--- b + decl-stmt --- semi + + stmt?:::ambig --- expr-stmt + expr-stmt --- expr1["expr"] + expr-stmt --- star + expr-stmt --- expr_b["expr"] + expr-stmt --- semi + expr_a --a is value--- a + expr_b --b is value--- b + + classDef ambig fill:blue,color:white; + classDef token fill:yellow; +``` + +**Ambiguity graph:** + +```mermaid +flowchart TB + subgraph   + a + b + end + class a,b token + + root --- stmt? + + stmt?:::ambig --- decl-stmt + decl-stmt --a is type--- a + decl-stmt --b is value--- b + + stmt?:::ambig --- expr-stmt + expr-stmt --a is value--- a + expr-stmt --b is value--- b + + classDef ambig fill:blue,color:white; + classDef token fill:yellow; +``` + +Here the clusters of non-ambiguous forest nodes are grouped together, so that the DAG is bipartite with ambiguous/cluster nodes, and interpretation edges at the bottom. + +Scoring the clusters and selecting which to include is equivalent to disambiguating the full graph. + +### Resolving the ambiguity DAG + +The static scores of the forest nodes are aggregated into static scores for the clusters. +The interpretation edges of the frontier clusters can be scored based on the context available so far, and the scores "bubble up" to parent nodes, with ambiguous nodes creating score ranges as described above. + +The main dynamic signal is when a token has been fully resolved, which happens when all the interpretations leading to it have the same label. + +The naive algorithm is to score all clusters, choose the best to resolve and repeat. +However this is very slow: + - there are **many** ambiguities available at first, therefore many clusters to score + - each time we resolve an ambiguity, we invalidate previously computed scores + - while the clusters become fewer over time, there are more interpretations per cluster + +It's tempting to use a priority queue to avoid repeatedly scanning clusters. However if we invalidate a large fraction of a heap's elements each round, we lose the efficiency benefits it brings. +We could reuse scores if the resolved cluster doesn't tell us much about the target cluster. +The simplest idea is to only recalculate clusters with an overlapping word, this may not save much (consider `std`) as clusters get larger. +A heuristic to estimate how much a cluster affects another may help. + +To stop the clusters having too many interpretation edges (and thus take too long to score), we can drop the edges for any token that is fully resolved. We need to track these anyway (for scoring of interpretations of other identifiers with the same text). And once only a single interpretation exists, removing it has no impact on scores. + +So for now the sketch is: +- build the ambiguity DAG +- compute scores for all clusters +- place confidences (score difference) for each cluster in a priority queue +- while there is still ambiguity: + - take the most confident cluster C and resolve it + - propagate the score change to all of C's ancestors + - work out which identifiers are now resolved, record that and remove the interpretations from the graph + - recompute scores for the K clusters most affected by resolving those identifiers, and their ancestors diff --git a/clang-tools-extra/pseudo/README.md b/clang-tools-extra/pseudo/README.md new file mode 100644 index 0000000000000..0958f5d500e7f --- /dev/null +++ b/clang-tools-extra/pseudo/README.md @@ -0,0 +1,37 @@ +# clang pseudoparser + +This directory implements an approximate heuristic parser for C++, based on the +clang lexer, the C++ grammar, and the GLR parsing algorithm. + +It parses a file in isolation, without reading its included headers. +The result is a strict syntactic tree whose structure follows the C++ grammar. +There is no semantic analysis, apart from guesses to disambiguate the parse. +Disambiguation can optionally be guided by an AST or a symbol index. + +For now, the best reference on intended scope is the [design proposal], +with further discussion on the [RFC]. + +## Dependencies between pseudoparser and clang + +Dependencies are limited because they don't make sense, but also to avoid +placing a burden on clang mantainers. + +The pseudoparser reuses the clang lexer (clangLex and clangBasic libraries) but +not the higher-level libraries (Parse, Sema, AST, Frontend...). + +When the pseudoparser should be used together with an AST (e.g. to guide +disambiguation), this is a separate "bridge" library that depends on both. + +Clang does not depend on the pseudoparser at all. If this seems useful in future +it should be discussed by RFC. + +## Parity between pseudoparser and clang + +The pseudoparser aims to understand real-world code, and particularly the +languages and extensions supported by Clang. + +However we don't try to keep these in lockstep: there's no expectation that +Clang parser changes are accompanied by pseudoparser changes or vice versa. + +[design proposal]: https://docs.google.com/document/d/1eGkTOsFja63wsv8v0vd5JdoTonj-NlN3ujGF0T7xDbM/edit +[RFC]: https://discourse.llvm.org/t/rfc-a-c-pseudo-parser-for-tooling/59217/49 diff --git a/clang-tools-extra/pseudo/benchmarks/Benchmark.cpp b/clang-tools-extra/pseudo/benchmarks/Benchmark.cpp new file mode 100644 index 0000000000000..087ab6c250e39 --- /dev/null +++ b/clang-tools-extra/pseudo/benchmarks/Benchmark.cpp @@ -0,0 +1,156 @@ +//===--- Benchmark.cpp - clang pseudoparser benchmarks ---------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Benchmark for the overall pseudoparser performance, it also includes other +// important pieces of the pseudoparser (grammar compliation, LR table build +// etc). +// +// Note: make sure to build the benchmark in Release mode. +// +// Usage: +// tools/clang/tools/extra/pseudo/benchmarks/ClangPseudoBenchmark \ +// --grammar=../clang-tools-extra/pseudo/lib/cxx.bnf \ +// --source=../clang/lib/Sema/SemaDecl.cpp +// +//===----------------------------------------------------------------------===// + +#include "benchmark/benchmark.h" +#include "clang-pseudo/Bracket.h" +#include "clang-pseudo/DirectiveTree.h" +#include "clang-pseudo/Forest.h" +#include "clang-pseudo/GLR.h" +#include "clang-pseudo/Token.h" +#include "clang-pseudo/cli/CLI.h" +#include "clang-pseudo/grammar/Grammar.h" +#include "clang-pseudo/grammar/LRTable.h" +#include "clang/Basic/LangOptions.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/ErrorOr.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/raw_ostream.h" +#include + +using llvm::cl::desc; +using llvm::cl::opt; +using llvm::cl::Required; + +static opt Source("source", desc("Source file"), Required); + +namespace clang { +namespace pseudo { +namespace bench { +namespace { + +const std::string *SourceText = nullptr; +const Language *Lang = nullptr; + +void setup() { + auto ReadFile = [](llvm::StringRef FilePath) -> std::string { + llvm::ErrorOr> GrammarText = + llvm::MemoryBuffer::getFile(FilePath); + if (std::error_code EC = GrammarText.getError()) { + llvm::errs() << "Error: can't read file '" << FilePath + << "': " << EC.message() << "\n"; + std::exit(1); + } + return GrammarText.get()->getBuffer().str(); + }; + SourceText = new std::string(ReadFile(Source)); + Lang = &getLanguageFromFlags(); +} + +static void buildSLR(benchmark::State &State) { + for (auto _ : State) + LRTable::buildSLR(Lang->G); +} +BENCHMARK(buildSLR); + +TokenStream lexAndPreprocess() { + clang::LangOptions LangOpts = genericLangOpts(); + TokenStream RawStream = pseudo::lex(*SourceText, LangOpts); + auto DirectiveStructure = DirectiveTree::parse(RawStream); + chooseConditionalBranches(DirectiveStructure, RawStream); + TokenStream Cook = + cook(DirectiveStructure.stripDirectives(RawStream), LangOpts); + auto Stream = stripComments(Cook); + pairBrackets(Stream); + return Stream; +} + +static void lex(benchmark::State &State) { + clang::LangOptions LangOpts = genericLangOpts(); + for (auto _ : State) + clang::pseudo::lex(*SourceText, LangOpts); + State.SetBytesProcessed(static_cast(State.iterations()) * + SourceText->size()); +} +BENCHMARK(lex); + +static void pairBrackets(benchmark::State &State) { + clang::LangOptions LangOpts = genericLangOpts(); + auto Stream = clang::pseudo::lex(*SourceText, LangOpts); + for (auto _ : State) + pairBrackets(Stream); + State.SetBytesProcessed(static_cast(State.iterations()) * + SourceText->size()); +} +BENCHMARK(pairBrackets); + +static void preprocess(benchmark::State &State) { + clang::LangOptions LangOpts = genericLangOpts(); + TokenStream RawStream = clang::pseudo::lex(*SourceText, LangOpts); + for (auto _ : State) { + auto DirectiveStructure = DirectiveTree::parse(RawStream); + chooseConditionalBranches(DirectiveStructure, RawStream); + stripComments( + cook(DirectiveStructure.stripDirectives(RawStream), LangOpts)); + } + State.SetBytesProcessed(static_cast(State.iterations()) * + SourceText->size()); +} +BENCHMARK(preprocess); + +static void glrParse(benchmark::State &State) { + SymbolID StartSymbol = *Lang->G.findNonterminal("translation-unit"); + TokenStream Stream = lexAndPreprocess(); + for (auto _ : State) { + pseudo::ForestArena Forest; + pseudo::GSS GSS; + pseudo::glrParse(ParseParams{Stream, Forest, GSS}, StartSymbol, *Lang); + } + State.SetBytesProcessed(static_cast(State.iterations()) * + SourceText->size()); +} +BENCHMARK(glrParse); + +static void full(benchmark::State &State) { + SymbolID StartSymbol = *Lang->G.findNonterminal("translation-unit"); + for (auto _ : State) { + TokenStream Stream = lexAndPreprocess(); + pseudo::ForestArena Forest; + pseudo::GSS GSS; + pseudo::glrParse(ParseParams{Stream, Forest, GSS}, StartSymbol, *Lang); + } + State.SetBytesProcessed(static_cast(State.iterations()) * + SourceText->size()); +} +BENCHMARK(full); + +} // namespace +} // namespace bench +} // namespace pseudo +} // namespace clang + +int main(int argc, char *argv[]) { + benchmark::Initialize(&argc, argv); + llvm::cl::ParseCommandLineOptions(argc, argv); + clang::pseudo::bench::setup(); + benchmark::RunSpecifiedBenchmarks(); + return 0; +} diff --git a/clang-tools-extra/pseudo/benchmarks/CMakeLists.txt b/clang-tools-extra/pseudo/benchmarks/CMakeLists.txt new file mode 100644 index 0000000000000..859db991403cd --- /dev/null +++ b/clang-tools-extra/pseudo/benchmarks/CMakeLists.txt @@ -0,0 +1,9 @@ +add_benchmark(ClangPseudoBenchmark Benchmark.cpp) + +target_link_libraries(ClangPseudoBenchmark + PRIVATE + clangPseudo + clangPseudoCLI + clangPseudoGrammar + LLVMSupport + ) diff --git a/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt b/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt new file mode 100644 index 0000000000000..e1d79873471f0 --- /dev/null +++ b/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt @@ -0,0 +1,16 @@ +set(LLVM_LINK_COMPONENTS + FuzzerCLI + Support + ) + +add_llvm_fuzzer(clang-pseudo-fuzzer + Fuzzer.cpp + DUMMY_MAIN Main.cpp + ) + +target_link_libraries(clang-pseudo-fuzzer + PRIVATE + clangPseudo + clangPseudoCLI + clangPseudoGrammar + ) diff --git a/clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp b/clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp new file mode 100644 index 0000000000000..87b9d15480cc3 --- /dev/null +++ b/clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp @@ -0,0 +1,82 @@ +//===-- Fuzzer.cpp - Fuzz the pseudoparser --------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/DirectiveTree.h" +#include "clang-pseudo/Forest.h" +#include "clang-pseudo/GLR.h" +#include "clang-pseudo/Token.h" +#include "clang-pseudo/cli/CLI.h" +#include "clang-pseudo/grammar/Grammar.h" +#include "clang-pseudo/grammar/LRTable.h" +#include "clang/Basic/LangOptions.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/raw_ostream.h" +#include + +namespace clang { +namespace pseudo { +namespace { + +class Fuzzer { + clang::LangOptions LangOpts = clang::pseudo::genericLangOpts(); + bool Print; + +public: + Fuzzer(bool Print) : Print(Print) {} + + void operator()(llvm::StringRef Code) { + std::string CodeStr = Code.str(); // Must be null-terminated. + auto RawStream = lex(CodeStr, LangOpts); + auto DirectiveStructure = DirectiveTree::parse(RawStream); + clang::pseudo::chooseConditionalBranches(DirectiveStructure, RawStream); + // FIXME: strip preprocessor directives + auto ParseableStream = + clang::pseudo::stripComments(cook(RawStream, LangOpts)); + + clang::pseudo::ForestArena Arena; + clang::pseudo::GSS GSS; + const Language &Lang = getLanguageFromFlags(); + auto &Root = + glrParse(clang::pseudo::ParseParams{ParseableStream, Arena, GSS}, + *Lang.G.findNonterminal("translation-unit"), Lang); + if (Print) + llvm::outs() << Root.dumpRecursive(Lang.G); + } +}; + +Fuzzer *Fuzz = nullptr; + +} // namespace +} // namespace pseudo +} // namespace clang + +extern "C" { + +// Set up the fuzzer from command line flags: +// -print - used for testing the fuzzer +int LLVMFuzzerInitialize(int *Argc, char ***Argv) { + bool PrintForest = false; + auto ConsumeArg = [&](llvm::StringRef Arg) -> bool { + if (Arg == "-print") { + PrintForest = true; + return true; + } + return false; + }; + *Argc = std::remove_if(*Argv + 1, *Argv + *Argc, ConsumeArg) - *Argv; + + clang::pseudo::Fuzz = new clang::pseudo::Fuzzer(PrintForest); + return 0; +} + +int LLVMFuzzerTestOneInput(uint8_t *Data, size_t Size) { + (*clang::pseudo::Fuzz)(llvm::StringRef(reinterpret_cast(Data), Size)); + return 0; +} +} diff --git a/clang-tools-extra/pseudo/fuzzer/Main.cpp b/clang-tools-extra/pseudo/fuzzer/Main.cpp new file mode 100644 index 0000000000000..542a3007a399f --- /dev/null +++ b/clang-tools-extra/pseudo/fuzzer/Main.cpp @@ -0,0 +1,16 @@ +//===--- Main.cpp - Entry point to sanity check the fuzzer ----------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "llvm/FuzzMutate/FuzzerCLI.h" + +extern "C" int LLVMFuzzerInitialize(int *, char ***); +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *, size_t); +int main(int argc, char *argv[]) { + return llvm::runFuzzerOnInputs(argc, argv, LLVMFuzzerTestOneInput, + LLVMFuzzerInitialize); +} diff --git a/clang-tools-extra/pseudo/gen/CMakeLists.txt b/clang-tools-extra/pseudo/gen/CMakeLists.txt new file mode 100644 index 0000000000000..3dd615a558751 --- /dev/null +++ b/clang-tools-extra/pseudo/gen/CMakeLists.txt @@ -0,0 +1,11 @@ +set(LLVM_LINK_COMPONENTS Support) +list(REMOVE_ITEM LLVM_COMMON_DEPENDS clang-tablegen-targets) + +add_clang_executable(clang-pseudo-gen + Main.cpp + ) + +target_link_libraries(clang-pseudo-gen + PRIVATE + clangPseudoGrammar + ) diff --git a/clang-tools-extra/pseudo/gen/Main.cpp b/clang-tools-extra/pseudo/gen/Main.cpp new file mode 100644 index 0000000000000..25cb26563837a --- /dev/null +++ b/clang-tools-extra/pseudo/gen/Main.cpp @@ -0,0 +1,172 @@ +//===--- Main.cpp - Compile BNF grammar -----------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This is a tool to compile a BNF grammar, it is used by the build system to +// generate a necessary data bits to statically construct core pieces (Grammar, +// LRTable etc) of the LR parser. +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/grammar/Grammar.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/ToolOutputFile.h" +#include + +using llvm::cl::desc; +using llvm::cl::init; +using llvm::cl::opt; +using llvm::cl::Required; +using llvm::cl::value_desc; +using llvm::cl::values; + +namespace { +enum EmitType { + EmitSymbolList, + EmitGrammarContent, +}; + +opt Grammar("grammar", desc("Parse a BNF grammar file."), + Required); +opt + Emit(desc("which information to emit:"), + values(clEnumValN(EmitSymbolList, "emit-symbol-list", + "Print nonterminal symbols (default)"), + clEnumValN(EmitGrammarContent, "emit-grammar-content", + "Print the BNF grammar content as a string"))); + +opt OutputFilename("o", init("-"), desc("Output"), + value_desc("file")); + +std::string readOrDie(llvm::StringRef Path) { + llvm::ErrorOr> Text = + llvm::MemoryBuffer::getFile(Path); + if (std::error_code EC = Text.getError()) { + llvm::errs() << "Error: can't read grammar file '" << Path + << "': " << EC.message() << "\n"; + ::exit(1); + } + return Text.get()->getBuffer().str(); +} +} // namespace + +namespace clang { +namespace pseudo { +namespace { + +// Mangles a symbol name into a valid identifier. +// +// These follow names in the grammar fairly closely: +// nonterminal: `ptr-declarator` becomes `ptr_declarator`; +// punctuator: `,` becomes `COMMA`; +// keyword: `INT` becomes `INT`; +// terminal: `IDENTIFIER` becomes `IDENTIFIER`; +std::string mangleSymbol(SymbolID SID, const Grammar &G) { + static auto &TokNames = *new std::vector{ +#define TOK(X) llvm::StringRef(#X).upper(), +#define KEYWORD(Keyword, Condition) llvm::StringRef(#Keyword).upper(), +#include "clang/Basic/TokenKinds.def" + }; + if (isToken(SID)) + return TokNames[symbolToToken(SID)]; + std::string Name = G.symbolName(SID).str(); + // translation-unit -> translation_unit + std::replace(Name.begin(), Name.end(), '-', '_'); + return Name; +} + +// Mangles the RHS of a rule definition into a valid identifier. +// +// These are unique only for a fixed LHS. +// e.g. for the grammar rule `ptr-declarator := ptr-operator ptr-declarator`, +// it is `ptr_operator__ptr_declarator`. +std::string mangleRule(RuleID RID, const Grammar &G) { + const auto &R = G.lookupRule(RID); + std::string MangleName = mangleSymbol(R.seq().front(), G); + for (SymbolID S : R.seq().drop_front()) { + MangleName.append("__"); + MangleName.append(mangleSymbol(S, G)); + } + return MangleName; +} + +} // namespace +} // namespace pseudo +} // namespace clang + +int main(int argc, char *argv[]) { + llvm::cl::ParseCommandLineOptions(argc, argv, ""); + + std::string GrammarText = readOrDie(Grammar); + std::vector Diags; + auto G = clang::pseudo::Grammar::parseBNF(GrammarText, Diags); + + if (!Diags.empty()) { + llvm::errs() << llvm::join(Diags, "\n"); + return 1; + } + + std::error_code EC; + llvm::ToolOutputFile Out{OutputFilename, EC, llvm::sys::fs::OF_None}; + if (EC) { + llvm::errs() << EC.message() << '\n'; + return 1; + } + + switch (Emit) { + case EmitSymbolList: + Out.os() << R"cpp( +#ifndef NONTERMINAL +#define NONTERMINAL(NAME, ID) +#endif +#ifndef RULE +#define RULE(LHS, RHS, ID) +#endif +#ifndef EXTENSION +#define EXTENSION(NAME, ID) +#endif +)cpp"; + for (clang::pseudo::SymbolID ID = 0; ID < G.table().Nonterminals.size(); + ++ID) { + Out.os() << llvm::formatv("NONTERMINAL({0}, {1})\n", + clang::pseudo::mangleSymbol(ID, G), ID); + for (const clang::pseudo::Rule &R : G.rulesFor(ID)) { + clang::pseudo::RuleID RID = &R - G.table().Rules.data(); + Out.os() << llvm::formatv("RULE({0}, {1}, {2})\n", + clang::pseudo::mangleSymbol(R.Target, G), + clang::pseudo::mangleRule(RID, G), RID); + } + } + for (clang::pseudo::ExtensionID EID = 1 /*skip the sentinel 0 value*/; + EID < G.table().AttributeValues.size(); ++EID) { + llvm::StringRef Name = G.table().AttributeValues[EID]; + assert(!Name.empty()); + Out.os() << llvm::formatv("EXTENSION({0}, {1})\n", Name, EID); + } + Out.os() << R"cpp( +#undef NONTERMINAL +#undef RULE +#undef EXTENSION +)cpp"; + break; + case EmitGrammarContent: + for (llvm::StringRef Line : llvm::split(GrammarText, '\n')) { + Out.os() << '"'; + Out.os().write_escaped((Line + "\n").str()); + Out.os() << "\"\n"; + } + break; + } + + Out.keep(); + + return 0; +} diff --git a/clang-tools-extra/pseudo/include/CMakeLists.txt b/clang-tools-extra/pseudo/include/CMakeLists.txt new file mode 100644 index 0000000000000..619b00f34a5ca --- /dev/null +++ b/clang-tools-extra/pseudo/include/CMakeLists.txt @@ -0,0 +1,32 @@ +# The cxx.bnf grammar file +set(cxx_bnf ${CMAKE_CURRENT_SOURCE_DIR}/../lib/cxx/cxx.bnf) + +setup_host_tool(clang-pseudo-gen CLANG_PSEUDO_GEN pseudo_gen pseudo_gen_target) + +# Generate inc files. +set(cxx_symbols_inc ${CMAKE_CURRENT_BINARY_DIR}/CXXSymbols.inc) +add_custom_command(OUTPUT ${cxx_symbols_inc} + COMMAND "${pseudo_gen}" + --grammar ${cxx_bnf} + --emit-symbol-list + -o ${cxx_symbols_inc} + COMMENT "Generating nonterminal symbol file for cxx grammar..." + DEPENDS ${pseudo_gen_target} ${cxx_bnf} + VERBATIM) + +set(cxx_bnf_inc ${CMAKE_CURRENT_BINARY_DIR}/CXXBNF.inc) +add_custom_command(OUTPUT ${cxx_bnf_inc} + COMMAND "${pseudo_gen}" + --grammar ${cxx_bnf} + --emit-grammar-content + -o ${cxx_bnf_inc} + COMMENT "Generating bnf string file for cxx grammar..." + DEPENDS ${pseudo_gen_target} ${cxx_bnf} + VERBATIM) + +# add_custom_command does not create a new target, we need to deine a target +# explicitly, so that other targets can depend on it. +add_custom_target(cxx_gen + DEPENDS ${cxx_symbols_inc} ${cxx_bnf_inc} + VERBATIM) +set_target_properties(cxx_gen PROPERTIES FOLDER "Clang Tools Extra/Sourcegenning") diff --git a/clang-tools-extra/clangd/support/Bracket.h b/clang-tools-extra/pseudo/include/clang-pseudo/Bracket.h similarity index 87% rename from clang-tools-extra/clangd/support/Bracket.h rename to clang-tools-extra/pseudo/include/clang-pseudo/Bracket.h index b43c22cea06d0..268cfff1ab07a 100644 --- a/clang-tools-extra/clangd/support/Bracket.h +++ b/clang-tools-extra/pseudo/include/clang-pseudo/Bracket.h @@ -23,19 +23,19 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_BRACKET_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_BRACKET_H +#ifndef CLANG_PSEUDO_BRACKET_H +#define CLANG_PSEUDO_BRACKET_H -#include "Token.h" +#include "clang-pseudo/Token.h" namespace clang { -namespace clangd { +namespace pseudo { /// Identifies bracket token in the stream which should be paired. /// Sets Token::Pair accordingly. void pairBrackets(TokenStream &); -} // namespace clangd +} // namespace pseudo } // namespace clang -#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_BRACKET_H +#endif diff --git a/clang-tools-extra/clangd/support/DirectiveTree.h b/clang-tools-extra/pseudo/include/clang-pseudo/DirectiveTree.h similarity index 95% rename from clang-tools-extra/clangd/support/DirectiveTree.h rename to clang-tools-extra/pseudo/include/clang-pseudo/DirectiveTree.h index 34f5a888863f2..2b6cb63297915 100644 --- a/clang-tools-extra/clangd/support/DirectiveTree.h +++ b/clang-tools-extra/pseudo/include/clang-pseudo/DirectiveTree.h @@ -25,17 +25,17 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_DIRECTIVETREE_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_DIRECTIVETREE_H +#ifndef CLANG_PSEUDO_DIRECTIVETREE_H +#define CLANG_PSEUDO_DIRECTIVETREE_H -#include "Token.h" +#include "clang-pseudo/Token.h" #include "clang/Basic/TokenKinds.h" #include #include #include namespace clang { -namespace clangd { +namespace pseudo { /// Describes the structure of a source file, as seen by the preprocessor. /// @@ -124,7 +124,7 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &, /// The choices are stored in Conditional::Taken nodes. void chooseConditionalBranches(DirectiveTree &, const TokenStream &Code); -} // namespace clangd +} // namespace pseudo } // namespace clang -#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_DIRECTIVETREE_H +#endif // CLANG_PSEUDO_DIRECTIVETREE_H diff --git a/clang-tools-extra/pseudo/include/clang-pseudo/Disambiguate.h b/clang-tools-extra/pseudo/include/clang-pseudo/Disambiguate.h new file mode 100644 index 0000000000000..5f3a22c9cabb3 --- /dev/null +++ b/clang-tools-extra/pseudo/include/clang-pseudo/Disambiguate.h @@ -0,0 +1,64 @@ +//===--- Disambiguate.h - Find the best tree in the forest -------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// A GLR parse forest represents every possible parse tree for the source code. +// +// Before we can do useful analysis/editing of the code, we need to pick a +// single tree which we think is accurate. We use three main types of clues: +// +// A) Semantic language rules may restrict which parses are allowed. +// For example, `string string string X` is *grammatical* C++, but only a +// single type-name is allowed in a decl-specifier-sequence. +// Where possible, these interpretations are forbidden by guards. +// Sometimes this isn't possible, or we want our parser to be lenient. +// +// B) Some constructs are rarer, while others are common. +// For example `a::c` is often a template specialization, and rarely a +// double comparison between a, b, and c. +// +// C) Identifier text hints whether they name types/values/templates etc. +// "std" is usually a namespace, a project index may also guide us. +// Hints may be within the document: if one occurrence of 'foo' is a variable +// then the others probably are too. +// (Text need not match: similar CaseStyle can be a weak hint, too). +// +//----------------------------------------------------------------------------// +// +// Mechanically, we replace each ambiguous node with its best alternative. +// +// "Best" is determined by assigning bonuses/penalties to nodes, to express +// the clues of type A and B above. A forest node representing an unlikely +// parse would apply a penalty to every subtree is is present in. +// Disambiguation proceeds bottom-up, so that the score of each alternative +// is known when a decision is made. +// +// Identifier-based hints within the document mean some nodes should be +// *correlated*. Rather than resolve these simultaneously, we make the most +// certain decisions first and use these results to update bonuses elsewhere. +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/Forest.h" + +namespace clang::pseudo { + +struct DisambiguateParams {}; + +// Maps ambiguous nodes onto the index of their preferred alternative. +using Disambiguation = llvm::DenseMap; + +// Resolve each ambiguous node in the forest. +// Maps each ambiguous node to the index of the chosen alternative. +// FIXME: current implementation is a placeholder and chooses arbitrarily. +Disambiguation disambiguate(const ForestNode *Root, + const DisambiguateParams &Params); + +// Remove all ambiguities from the forest, resolving them according to Disambig. +void removeAmbiguities(ForestNode *&Root, const Disambiguation &Disambig); + +} // namespace clang::pseudo diff --git a/clang-tools-extra/pseudo/include/clang-pseudo/Forest.h b/clang-tools-extra/pseudo/include/clang-pseudo/Forest.h new file mode 100644 index 0000000000000..e9edb40e02b64 --- /dev/null +++ b/clang-tools-extra/pseudo/include/clang-pseudo/Forest.h @@ -0,0 +1,236 @@ +//===--- Forest.h - Parse forest, the output of the GLR parser ---*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// A parse forest represents a set of possible parse trees efficiently, it is +// produced by the GLR parser. +// +// Despite the name, its data structure is a tree-like DAG with a single root. +// Multiple ways to parse the same tokens are presented as an ambiguous node +// with all possible interpretations as children. +// Common sub-parses are shared: if two interpretations both parse "1 + 1" as +// "expr := expr + expr", they will share a Sequence node representing the expr. +// +//===----------------------------------------------------------------------===// + +#ifndef CLANG_PSEUDO_FOREST_H +#define CLANG_PSEUDO_FOREST_H + +#include "clang-pseudo/Token.h" +#include "clang-pseudo/grammar/Grammar.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/Support/Allocator.h" +#include + +namespace clang { +namespace pseudo { + +// A node represents ways to parse a sequence of tokens, it interprets a fixed +// range of tokens as a fixed grammar symbol. +// +// There are different kinds of nodes, some nodes have "children" (stored in a +// trailing array) and have pointers to them. "Children" has different semantics +// depending on the node kinds. For an Ambiguous node, it means all +// possible interpretations; for a Sequence node, it means each symbol on the +// right hand side of the production rule. +// +// Since this is a node in a DAG, a node may have multiple parents. And a node +// doesn't have parent pointers. +class alignas(class ForestNode *) ForestNode { +public: + class RecursiveIterator; + enum Kind { + // A Terminal node is a single terminal symbol bound to a token. + Terminal, + // A Sequence node is a nonterminal symbol parsed from a grammar rule, + // elements() are the parses of each symbol on the RHS of the rule. + // If the rule is A := X Y Z, the node is for nonterminal A, and elements() + // are [X, Y, Z]. + Sequence, + // An Ambiguous node exposes multiple ways to interpret the code as the + // same symbol, alternatives() are all possible parses. + Ambiguous, + // An Opaque node is a placeholder. It asserts that tokens match a symbol, + // without saying how. + // It is used for lazy-parsing (not parsed yet), or error-recovery (invalid + // code). + Opaque, + }; + Kind kind() const { return K; } + + SymbolID symbol() const { return Symbol; } + + // The start of the token range, it is a poistion within a token stream. + Token::Index startTokenIndex() const { return StartIndex; } + + // Returns the corresponding grammar rule. + // REQUIRES: this is a Sequence node. + RuleID rule() const { + assert(kind() == Sequence); + return Data & ((1 << RuleBits) - 1); + } + // Returns the parses of each element on the RHS of the rule. + // REQUIRES: this is a Sequence node; + llvm::ArrayRef elements() const { + assert(kind() == Sequence); + return children(Data >> RuleBits); + } + llvm::MutableArrayRef elements() { + assert(kind() == Sequence); + return children(Data >> RuleBits); + } + + // Returns all possible interpretations of the code. + // REQUIRES: this is an Ambiguous node. + llvm::ArrayRef alternatives() const { + assert(kind() == Ambiguous); + return children(Data); + } + llvm::MutableArrayRef alternatives() { + assert(kind() == Ambiguous); + return children(Data); + } + + llvm::ArrayRef children() const { + switch (kind()) { + case Sequence: + return elements(); + case Ambiguous: + return alternatives(); + case Terminal: + case Opaque: + return {}; + } + llvm_unreachable("Bad kind"); + } + + // Iteration over all nodes in the forest, including this. + llvm::iterator_range descendants() const; + + std::string dump(const Grammar &) const; + std::string dumpRecursive(const Grammar &, bool Abbreviated = false) const; + +private: + friend class ForestArena; + + ForestNode(Kind K, SymbolID Symbol, Token::Index StartIndex, uint16_t Data) + : StartIndex(StartIndex), K(K), Symbol(Symbol), Data(Data) {} + + ForestNode(const ForestNode &) = delete; + ForestNode &operator=(const ForestNode &) = delete; + ForestNode(ForestNode &&) = delete; + ForestNode &operator=(ForestNode &&) = delete; + + static uint16_t sequenceData(RuleID Rule, + llvm::ArrayRef Elements) { + assert(Rule < (1 << RuleBits)); + assert(Elements.size() < (1 << (16 - RuleBits))); + return Rule | Elements.size() << RuleBits; + } + static uint16_t + ambiguousData(llvm::ArrayRef Alternatives) { + return Alternatives.size(); + } + + // Retrieves the trailing array. + llvm::ArrayRef children(uint16_t Num) const { + return llvm::ArrayRef(reinterpret_cast(this + 1), Num); + } + llvm::MutableArrayRef children(uint16_t Num) { + return llvm::MutableArrayRef(reinterpret_cast(this + 1), + Num); + } + + Token::Index StartIndex; + Kind K : 4; + SymbolID Symbol : SymbolBits; + // Sequence - child count : 4 | RuleID : RuleBits (12) + // Ambiguous - child count : 16 + // Terminal, Opaque - unused + uint16_t Data; + // An array of ForestNode* following the object. +}; +// ForestNode may not be destroyed (for BumpPtrAllocator). +static_assert(std::is_trivially_destructible()); + +// A memory arena for the parse forest. +class ForestArena { +public: + llvm::ArrayRef createTerminals(const TokenStream &Code); + ForestNode &createSequence(SymbolID SID, RuleID RID, + llvm::ArrayRef Elements) { + assert(!Elements.empty()); + return create(ForestNode::Sequence, SID, + Elements.front()->startTokenIndex(), + ForestNode::sequenceData(RID, Elements), Elements); + } + ForestNode &createAmbiguous(SymbolID SID, + llvm::ArrayRef Alternatives) { + assert(!Alternatives.empty()); + assert(llvm::all_of(Alternatives, + [SID](const ForestNode *Alternative) { + return SID == Alternative->symbol(); + }) && + "Ambiguous alternatives must represent the same symbol!"); + return create(ForestNode::Ambiguous, SID, + Alternatives.front()->startTokenIndex(), + ForestNode::ambiguousData(Alternatives), Alternatives); + } + ForestNode &createOpaque(SymbolID SID, Token::Index Start) { + return create(ForestNode::Opaque, SID, Start, 0, {}); + } + + ForestNode &createTerminal(tok::TokenKind TK, Token::Index Start) { + return create(ForestNode::Terminal, tokenSymbol(TK), Start, 0, {}); + } + + size_t nodeCount() const { return NodeCount; } + size_t bytes() const { return Arena.getBytesAllocated() + sizeof(*this); } + +private: + ForestNode &create(ForestNode::Kind K, SymbolID SID, Token::Index Start, + uint16_t Data, + llvm::ArrayRef Elements) { + ++NodeCount; + ForestNode *New = new (Arena.Allocate( + sizeof(ForestNode) + Elements.size() * sizeof(ForestNode *), + alignof(ForestNode))) ForestNode(K, SID, Start, Data); + if (!Elements.empty()) + llvm::copy(Elements, reinterpret_cast(New + 1)); + return *New; + } + + llvm::BumpPtrAllocator Arena; + uint32_t NodeCount = 0; +}; + +class ForestNode::RecursiveIterator + : public llvm::iterator_facade_base { + llvm::DenseSet Seen; + struct StackFrame { + const ForestNode *Parent; + unsigned ChildIndex; + }; + std::vector Stack; + const ForestNode *Cur; + +public: + RecursiveIterator(const ForestNode *N = nullptr) : Cur(N) {} + + const ForestNode &operator*() const { return *Cur; } + void operator++(); + bool operator==(const RecursiveIterator &I) const { return Cur == I.Cur; } + bool operator!=(const RecursiveIterator &I) const { return !(*this == I); } +}; + +} // namespace pseudo +} // namespace clang + +#endif // CLANG_PSEUDO_FOREST_H diff --git a/clang-tools-extra/pseudo/include/clang-pseudo/GLR.h b/clang-tools-extra/pseudo/include/clang-pseudo/GLR.h new file mode 100644 index 0000000000000..0100f818d4ed7 --- /dev/null +++ b/clang-tools-extra/pseudo/include/clang-pseudo/GLR.h @@ -0,0 +1,170 @@ +//===--- GLR.h - Implement a GLR parsing algorithm ---------------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This implements a standard Generalized LR (GLR) parsing algorithm. +// +// The GLR parser behaves as a normal LR parser until it encounters a conflict. +// To handle a conflict (where there are multiple actions could perform), the +// parser will simulate nondeterminism by doing a breadth-first search +// over all the possibilities. +// +// Basic mechanisims of the GLR parser: +// - A number of processes are operated in parallel. +// - Each process has its own parsing stack and behaves as a standard +// determinism LR parser. +// - When a process encounters a conflict, it will be fork (one for each +// avaiable action). +// - When a process encounters an error, it is abandoned. +// - All process are synchronized by the lookahead token: they perfrom shift +// action at the same time, which means some processes need wait until other +// processes have performed all reduce actions. +// +//===----------------------------------------------------------------------===// + +#ifndef CLANG_PSEUDO_GLR_H +#define CLANG_PSEUDO_GLR_H + +#include "clang-pseudo/Forest.h" +#include "clang-pseudo/Language.h" +#include "clang-pseudo/grammar/Grammar.h" +#include "clang-pseudo/grammar/LRTable.h" +#include "llvm/Support/Allocator.h" +#include + +namespace clang { +namespace pseudo { + +// A Graph-Structured Stack efficiently represents all parse stacks of a GLR +// parser. +// +// Each node stores a parse state, the last parsed ForestNode, and the parent +// node. There may be several heads (top of stack), and the parser operates by: +// - shift: pushing terminal symbols on top of the stack +// - reduce: replace N symbols on top of the stack with one nonterminal +// +// The structure is a DAG rather than a linear stack: +// - GLR allows multiple actions (conflicts) on the same head, producing forks +// where several nodes have the same parent +// - The parser merges nodes with the same (state, ForestNode), producing joins +// where one node has multiple parents +// +// The parser is responsible for creating nodes and keeping track of the set of +// heads. The GSS class is mostly an arena for them. +struct GSS { + // A node represents a partial parse of the input up to some point. + // + // It is the equivalent of a frame in an LR parse stack. + // Like such a frame, it has an LR parse state and a syntax-tree node + // representing the last parsed symbol (a ForestNode in our case). + // Unlike a regular LR stack frame, it may have multiple parents. + // + // Nodes are not exactly pushed and popped on the stack: pushing is just + // allocating a new head node with a parent pointer to the old head. Popping + // is just forgetting about a node and remembering its parent instead. + struct alignas(struct Node *) Node { + // LR state describing how parsing should continue from this head. + LRTable::StateID State; + // Used internally to track reachability during garbage collection. + bool GCParity; + // Have we already used this node for error recovery? (prevents loops) + mutable bool Recovered = false; + // Number of the parents of this node. + // The parents hold previous parsed symbols, and may resume control after + // this node is reduced. + unsigned ParentCount; + // The parse node for the last parsed symbol. + // This symbol appears on the left of the dot in the parse state's items. + // (In the literature, the node is attached to the *edge* to the parent). + const ForestNode *Payload = nullptr; + + llvm::ArrayRef parents() const { + return llvm::ArrayRef(reinterpret_cast(this + 1), + ParentCount); + }; + // Parents are stored as a trailing array of Node*. + }; + + // Allocates a new node in the graph. + const Node *addNode(LRTable::StateID State, const ForestNode *Symbol, + llvm::ArrayRef Parents); + // Frees all nodes not reachable as ancestors of Roots, and returns the count. + // Calling this periodically prevents steady memory growth of the GSS. + unsigned gc(std::vector &&Roots); + + size_t bytes() const { return Arena.getTotalMemory() + sizeof(*this); } + size_t nodesCreated() const { return NodesCreated; } + +private: + // Nodes are recycled using freelists. + // They are variable size, so use one free-list per distinct #parents. + std::vector> FreeList; + Node *allocate(unsigned Parents); + void destroy(Node *N); + // The list of nodes created and not destroyed - our candidates for gc(). + std::vector Alive; + bool GCParity = false; // All nodes should match this, except during GC. + + llvm::BumpPtrAllocator Arena; + unsigned NodesCreated = 0; +}; +llvm::raw_ostream &operator<<(llvm::raw_ostream &, const GSS::Node &); + +// Parameters for the GLR parsing. +struct ParseParams { + // The token stream to parse. + const TokenStream &Code; + + // Arena for data structure used by the GLR algorithm. + ForestArena &Forest; // Storage for the output forest. + GSS &GSStack; // Storage for parsing stacks. +}; + +// Parses the given token stream as the start symbol with the GLR algorithm, +// and returns a forest node of the start symbol. +// +// A rule `_ := StartSymbol` must exit for the chosen start symbol. +// +// If the parsing fails, we model it as an opaque node in the forest. +ForestNode &glrParse(const ParseParams &Params, SymbolID StartSymbol, + const Language &Lang); + +// Shift a token onto all OldHeads, placing the results into NewHeads. +// +// Exposed for testing only. +void glrShift(llvm::ArrayRef OldHeads, + const ForestNode &NextTok, const ParseParams &Params, + const Language &Lang, std::vector &NewHeads); +// Applies available reductions on Heads, appending resulting heads to the list. +// +// Exposed for testing only. +void glrReduce(std::vector &Heads, SymbolID Lookahead, + const ParseParams &Params, const Language &Lang); + +// Heuristically recover from a state where no further parsing is possible. +// +// OldHeads is the parse state at TokenIndex. +// This function consumes zero or more tokens by advancing TokenIndex, +// and places any recovery states created in NewHeads. +// +// On failure, NewHeads is empty and TokenIndex is unchanged. +// +// WARNING: glrRecover acts as a "fallback shift". If it consumes no tokens, +// there is a risk of the parser falling into an infinite loop, creating an +// endless sequence of recovery nodes. +// Generally it is safe for recovery to match 0 tokens against sequence symbols +// like `statement-seq`, as the grammar won't permit another statement-seq +// immediately afterwards. However recovery strategies for `statement` should +// consume at least one token, as statements may be adjacent in the input. +void glrRecover(llvm::ArrayRef OldHeads, + unsigned &TokenIndex, const ParseParams &Params, + const Language &Lang, std::vector &NewHeads); + +} // namespace pseudo +} // namespace clang + +#endif // CLANG_PSEUDO_GLR_H diff --git a/clang-tools-extra/pseudo/include/clang-pseudo/Language.h b/clang-tools-extra/pseudo/include/clang-pseudo/Language.h new file mode 100644 index 0000000000000..1a2b71f081da0 --- /dev/null +++ b/clang-tools-extra/pseudo/include/clang-pseudo/Language.h @@ -0,0 +1,64 @@ +//===--- Language.h -------------------------------------------- -*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef CLANG_PSEUDO_LANGUAGE_H +#define CLANG_PSEUDO_LANGUAGE_H + +#include "clang-pseudo/Token.h" +#include "clang-pseudo/grammar/Grammar.h" +#include "clang-pseudo/grammar/LRTable.h" + +namespace clang { +namespace pseudo { +class ForestNode; +class TokenStream; +class LRTable; + +struct GuardParams { + llvm::ArrayRef RHS; + const TokenStream &Tokens; + // FIXME: use the index of Tokens. + SymbolID Lookahead; +}; +// A guard restricts when a grammar rule can be used. +// +// The GLR parser will use the guard to determine whether a rule reduction will +// be conducted. For example, e.g. a guard may allow the rule +// `virt-specifier := IDENTIFIER` only if the identifier's text is 'override`. +// +// Return true if the guard is satisfied. +using RuleGuard = llvm::function_ref; + +// A recovery strategy determines a region of code to skip when parsing fails. +// +// For example, given `class-def := CLASS IDENT { body [recover=Brackets] }`, +// if parsing fails while attempting to parse `body`, we may skip up to the +// matching `}` and assume everything between was a `body`. +// +// The provided index is the token where the skipped region begins. +// Returns the (excluded) end of the range, or Token::Invalid for no recovery. +using RecoveryStrategy = + llvm::function_ref; + +// Specify a language that can be parsed by the pseduoparser. +struct Language { + Grammar G; + LRTable Table; + + // Binding extension ids to corresponding implementations. + llvm::DenseMap Guards; + llvm::DenseMap RecoveryStrategies; + + // FIXME: add clang::LangOptions. + // FIXME: add default start symbols. +}; + +} // namespace pseudo +} // namespace clang + +#endif // CLANG_PSEUDO_LANGUAGE_H diff --git a/clang-tools-extra/clangd/support/Token.h b/clang-tools-extra/pseudo/include/clang-pseudo/Token.h similarity index 98% rename from clang-tools-extra/clangd/support/Token.h rename to clang-tools-extra/pseudo/include/clang-pseudo/Token.h index 555b6b0e4ce57..859fd7d2b3dfe 100644 --- a/clang-tools-extra/clangd/support/Token.h +++ b/clang-tools-extra/pseudo/include/clang-pseudo/Token.h @@ -25,8 +25,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_TOKEN_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_TOKEN_H +#ifndef CLANG_PSEUDO_TOKEN_H +#define CLANG_PSEUDO_TOKEN_H #include "clang/Basic/LLVM.h" #include "clang/Basic/LangStandard.h" @@ -41,7 +41,7 @@ namespace clang { class LangOptions; -namespace clangd { +namespace pseudo { /// A single C++ or preprocessor token. /// @@ -249,7 +249,7 @@ TokenStream cook(const TokenStream &, const clang::LangOptions &); /// Drops comment tokens. TokenStream stripComments(const TokenStream &); -} // namespace clangd +} // namespace pseudo } // namespace clang -#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_TOKEN_H +#endif // CLANG_PSEUDO_TOKEN_H diff --git a/clang-tools-extra/pseudo/include/clang-pseudo/cli/CLI.h b/clang-tools-extra/pseudo/include/clang-pseudo/cli/CLI.h new file mode 100644 index 0000000000000..db09aba21502f --- /dev/null +++ b/clang-tools-extra/pseudo/include/clang-pseudo/cli/CLI.h @@ -0,0 +1,35 @@ +//===--- CLI.h - Get grammar from variant sources ----------------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Provides the Grammar, LRTable etc for a language specified by the `--grammar` +// flags. It is by design to be used by pseudoparser-based CLI tools. +// +// The CLI library defines a `--grammar` CLI flag, which supports 1) using a +// grammar from a file (--grammar=/path/to/lang.bnf) or using the prebuilt cxx +// language (--grammar=cxx). +// +//===----------------------------------------------------------------------===// + +#ifndef CLANG_PSEUDO_CLI_CLI_H +#define CLANG_PSEUDO_CLI_CLI_H + +#include "clang-pseudo/Language.h" + +namespace clang { +namespace pseudo { + +// Returns the corresponding Language from the '--grammar' command-line flag. +// +// !! If the grammar flag is invalid (e.g. unexisting file), this function will +// exit the program immediately. +const Language &getLanguageFromFlags(); + +} // namespace pseudo +} // namespace clang + +#endif // CLANG_PSEUDO_CLI_CLI_H diff --git a/clang-tools-extra/pseudo/include/clang-pseudo/cxx/CXX.h b/clang-tools-extra/pseudo/include/clang-pseudo/cxx/CXX.h new file mode 100644 index 0000000000000..7bbb4d2c00201 --- /dev/null +++ b/clang-tools-extra/pseudo/include/clang-pseudo/cxx/CXX.h @@ -0,0 +1,91 @@ +//===--- CXX.h - Public interfaces for the C++ grammar -----------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines public interfaces for the C++ grammar +// (pseudo/lib/cxx/cxx.bnf). It provides a fast way to access core building +// pieces of the LR parser, e.g. Grammar, LRTable, rather than parsing the +// grammar file at the runtime. +// +// We do a compilation of the C++ BNF grammar at build time, and generate +// critical data sources. The implementation of the interfaces are based on the +// generated data sources. +// +// FIXME: not everything is fully compiled yet. The implementation of the +// interfaces are still parsing the grammar file at the runtime. +// +//===----------------------------------------------------------------------===// + +#ifndef CLANG_PSEUDO_CXX_CXX_H +#define CLANG_PSEUDO_CXX_CXX_H + +#include "clang-pseudo/Language.h" +#include "clang-pseudo/grammar/Grammar.h" + +namespace clang { +namespace pseudo { +namespace cxx { + +// We want enums to be scoped but implicitly convertible to RuleID etc. +// So create regular (unscoped) enums inside subnamespaces of `detail`. +// Then add aliases for them outside `detail`. +namespace detail { +namespace symbols { +enum Symbol : SymbolID { +#define NONTERMINAL(X, Y) X = Y, +#include "CXXSymbols.inc" +#undef NONTERMINAL +}; +} // namespace symbols + +namespace extensions { +enum Extension : ExtensionID { +#define EXTENSION(X, Y) X = Y, +#include "CXXSymbols.inc" +#undef EXTENSION +}; +} // namespace extensions + +namespace rules { +// For each symbol we close the last symbol's enum+namespace and open new ones. +// We need a dummy namespace+enum so that this works for the first rule. +namespace dummy { +enum Dummy { +//clang-format off +#define NONTERMINAL(NAME, ID) \ +}; \ +} \ +namespace NAME { \ +enum Rule : RuleID { +//clang-format on +#define RULE(LHS, RHS, ID) RHS = ID, +#include "CXXSymbols.inc" +}; +} +} // namespace rules +} // namespace detail + +// Symbol represents nonterminal symbols in the C++ grammar. +// It provides a simple uniform way to access a particular nonterminal. +using Symbol = detail::symbols::Symbol; + +using Extension = detail::extensions::Extension; + +namespace rule { +#define NONTERMINAL(NAME, ID) using NAME = detail::rules::NAME::Rule; +#include "CXXSymbols.inc" +} // namespace rule + +// Returns the Language for the cxx.bnf grammar. +const Language &getLanguage(); + +} // namespace cxx + +} // namespace pseudo +} // namespace clang + +#endif // CLANG_PSEUDO_CXX_CXX_H diff --git a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h new file mode 100644 index 0000000000000..a1c779a02d864 --- /dev/null +++ b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h @@ -0,0 +1,230 @@ +//===--- Grammar.h - grammar used by clang pseudoparser ---------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines base structures for parsing & modeling a grammar for a +// programming language: +// +// # This is a fake C++ BNF grammar +// _ := translation-unit +// translation-unit := declaration-seq_opt +// declaration-seq := declaration +// declaration-seq := declaration-seq declaration +// +// A grammar formally describes a language, and it is constructed by a set of +// production rules. A rule is of BNF form (AAA := BBB CCC). A symbol is either +// nonterminal or terminal, identified by a SymbolID. +// +// Annotations are supported in a syntax form of [key=value]. They specify +// attributes which are associated with either a grammar symbol (on the +// right-hand side of the symbol) or a grammar rule (at the end of the rule +// body). +// Attributes provide a way to inject custom code into the GLR parser. Each +// unique attribute value creates an extension point (identified by ExtensionID +// ), and an extension point corresponds to a piece of native code. For +// example, C++ grammar has a rule: +// +// compound_statement := { statement-seq [recover=Brackets] } +// +// The `recover` attribute instructs the parser that we should perform error +// recovery if parsing the statement-seq fails. The `Brackets` recovery +// heuristic is implemented in CXX.cpp by binding the ExtensionID for the +// `Recovery` value to a specific C++ function that finds the recovery point. +// +// Notions about the BNF grammar: +// - "_" is the start symbol of the augmented grammar; +// - single-line comment is supported, starting with a # +// - A rule describes how a nonterminal (left side of :=) is constructed, and +// it is *per line* in the grammar file +// - Terminals (also called tokens) correspond to the clang::TokenKind; they +// are written in the grammar like "IDENTIFIER", "USING", "+" +// - Nonterminals are specified with "lower-case" names in the grammar; they +// shouldn't be nullable (has an empty sequence) +// - optional symbols are supported (specified with a _opt suffix), and they +// will be eliminated during the grammar parsing stage +// +//===----------------------------------------------------------------------===// + +#ifndef CLANG_PSEUDO_GRAMMAR_GRAMMAR_H +#define CLANG_PSEUDO_GRAMMAR_GRAMMAR_H + +#include "clang/Basic/TokenKinds.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/raw_ostream.h" +#include +#include +#include + +namespace clang { +namespace pseudo { +// A SymbolID uniquely identifies a terminal/nonterminal symbol in a grammar. +// nonterminal IDs are indexes into a table of nonterminal symbols. +// Terminal IDs correspond to the clang TokenKind enum. +using SymbolID = uint16_t; +// SymbolID is only 12 bits wide. +// There are maximum 2^11 terminals (aka tokens) and 2^11 nonterminals. +static constexpr uint16_t SymbolBits = 12; +static constexpr uint16_t NumTerminals = tok::NUM_TOKENS; +// SymbolIDs with the top bit set are tokens/terminals. +static constexpr SymbolID TokenFlag = 1 << (SymbolBits - 1); +inline bool isToken(SymbolID ID) { return ID & TokenFlag; } +inline bool isNonterminal(SymbolID ID) { return !isToken(ID); } +// The terminals are always the clang tok::TokenKind (not all are used). +inline tok::TokenKind symbolToToken(SymbolID SID) { + assert(isToken(SID)); + SID &= ~TokenFlag; + assert(SID < NumTerminals); + return static_cast(SID); +} +inline constexpr SymbolID tokenSymbol(tok::TokenKind TK) { + return TokenFlag | static_cast(TK); +} + +// An extension is a piece of native code specific to a grammar that modifies +// the behavior of annotated rules. One ExtensionID is assigned for each unique +// attribute value (all attributes share a namespace). +using ExtensionID = uint16_t; + +// A RuleID uniquely identifies a production rule in a grammar. +// It is an index into a table of rules. +using RuleID = uint16_t; +// There are maximum 2^12 rules. +static constexpr unsigned RuleBits = 12; + +// Represent a production rule in the grammar, e.g. +// expression := a b c +// ^Target ^Sequence +struct Rule { + Rule(SymbolID Target, llvm::ArrayRef Seq); + + // We occupy 4 bits for the sequence, in theory, it can be at most 2^4 tokens + // long, however, we're stricter in order to reduce the size, we limit the max + // length to 9 (this is the longest sequence in cxx grammar). + static constexpr unsigned SizeBits = 4; + static constexpr unsigned MaxElements = 9; + static_assert(MaxElements < (1 << SizeBits), "Exceeds the maximum limit"); + static_assert(SizeBits + SymbolBits <= 16, + "Must be able to store symbol ID + size efficiently"); + + // 16 bits for target symbol and size of sequence: + // SymbolID : 12 | Size : 4 + SymbolID Target : SymbolBits; + uint8_t Size : SizeBits; // Size of the Sequence + SymbolID Sequence[MaxElements]; + + // A guarded rule has extra logic to determine whether the RHS is eligible. + bool Guarded = false; + + // Specifies the index within Sequence eligible for error recovery. + // Given stmt := { stmt-seq_opt }, if we fail to parse the stmt-seq then we + // should recover by finding the matching brace, and forcing stmt-seq to match + // everything between braces. + // For now, only a single strategy at a single point is possible. + uint8_t RecoveryIndex = -1; + ExtensionID Recovery = 0; + + llvm::ArrayRef seq() const { + return llvm::ArrayRef(Sequence, Size); + } + friend bool operator==(const Rule &L, const Rule &R) { + return L.Target == R.Target && L.seq() == R.seq() && L.Guarded == R.Guarded; + } +}; + +struct GrammarTable; + +// Grammar that describes a programming language, e.g. C++. It represents the +// contents of the specified grammar. +// It is a building block for constructing a table-based parser. +class Grammar { +public: + Grammar() = default; // Creates an invalid dummy grammar. + explicit Grammar(std::unique_ptr); + + // Parses grammar from a BNF file. + // Diagnostics emitted during parsing are stored in Diags. + static Grammar parseBNF(llvm::StringRef BNF, std::vector &Diags); + + // Returns the SymbolID of the symbol '_'. + SymbolID underscore() const { return Underscore; }; + + // Returns all rules of the given nonterminal symbol. + llvm::ArrayRef rulesFor(SymbolID SID) const; + const Rule &lookupRule(RuleID RID) const; + + // Gets symbol (terminal or nonterminal) name. + // Terminals have names like "," (kw_comma) or "OPERATOR" (kw_operator). + llvm::StringRef symbolName(SymbolID) const; + + // Lookup the SymbolID of the nonterminal symbol by Name. + std::optional findNonterminal(llvm::StringRef Name) const; + + // Dumps the whole grammar. + std::string dump() const; + // Dumps a particular rule. + std::string dumpRule(RuleID) const; + // Dumps all rules of the given nonterminal symbol. + std::string dumpRules(SymbolID) const; + + const GrammarTable &table() const { return *T; } + +private: + std::unique_ptr T; + // The symbol ID of '_'. (In the LR literature, this is the start symbol of + // the augmented grammar.) + SymbolID Underscore; +}; +// For each nonterminal X, computes the set of terminals that begin strings +// derived from X. (Known as FIRST sets in grammar-based parsers). +std::vector> firstSets(const Grammar &); +// For each nonterminal X, computes the set of terminals that could immediately +// follow X. (Known as FOLLOW sets in grammar-based parsers). +std::vector> followSets(const Grammar &); + +// Storage for the underlying data of the Grammar. +// It can be constructed dynamically (from compiling BNF file) or statically +// (a compiled data-source). +struct GrammarTable { + GrammarTable(); + + struct Nonterminal { + std::string Name; + // Corresponding rules that construct the nonterminal, it is a [Start, End) + // index range of the Rules table. + struct { + RuleID Start; + RuleID End; + } RuleRange; + }; + + // RuleID is an index into this table of rule definitions. + // + // Rules with the same target symbol (LHS) are grouped into a single range. + // The relative order of different target symbols is *not* by SymbolID, but + // rather a topological sort: if S := T then the rules producing T have lower + // RuleIDs than rules producing S. + // (This strange order simplifies the GLR parser: for a given token range, if + // we reduce in increasing RuleID order then we need never backtrack -- + // prerequisite reductions are reached before dependent ones). + std::vector Rules; + // A table of terminals (aka tokens). It corresponds to the clang::Token. + // clang::tok::TokenKind is the index of the table. + llvm::ArrayRef Terminals; + // A table of nonterminals, sorted by name. + // SymbolID is the index of the table. + std::vector Nonterminals; + // A table of attribute values, sorted by name. + // ExtensionID is the index of the table. + std::vector AttributeValues; +}; + +} // namespace pseudo +} // namespace clang + +#endif // CLANG_PSEUDO_GRAMMAR_GRAMMAR_H diff --git a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRGraph.h b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRGraph.h new file mode 100644 index 0000000000000..dd9e87c2c172b --- /dev/null +++ b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRGraph.h @@ -0,0 +1,196 @@ +//===--- LRGraph.h - Build an LR automaton ------------------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// LR parsers are bottom-up parsers -- they scan the input from left to right, +// and collect the right-hand side of a production rule (called handle) on top +// of the stack, then replace (reduce) the handle with the nonterminal defined +// by the production rule. +// +// This file defines LRGraph, a deterministic handle-finding finite-state +// automaton, which is a key component in LR parsers to recognize any of +// handles in the grammar efficiently. We build the LR table (ACTION and GOTO +// Table) based on the LRGraph. +// +// LRGraph can be constructed for any context-free grammars. +// Even for a LR-ambiguous grammar, we can construct a deterministic FSA, but +// interpretation of the FSA is nondeterministic -- we might in a state where +// we can continue searching an handle and identify a handle (called +// shift/reduce conflicts), or identify more than one handle (callled +// reduce/reduce conflicts). +// +// LRGraph is a common model for all variants of LR automatons, from the most +// basic one LR(0), the powerful SLR(1), LR(1) which uses a one-token lookahead +// in making decisions. +//===----------------------------------------------------------------------===// + +#ifndef CLANG_PSEUDO_GRAMMAR_LRGRAPH_H +#define CLANG_PSEUDO_GRAMMAR_LRGRAPH_H + +#include "clang-pseudo/grammar/Grammar.h" +#include "llvm/ADT/Hashing.h" +#include + +namespace clang { +namespace pseudo { + +// An LR item -- a grammar rule with a dot at some position of the body. +// e.g. a production rule A := X Y yields 3 items: +// A := . X Y +// A := X . Y +// A := X Y . +// An item indicates how much of a production rule has been recognized at a +// position (described by dot), for example, A := X . Y indicates that we have +// recognized the X part from the input, and we hope next to see the input +// derivable from Y. +class Item { +public: + static Item start(RuleID ID, const Grammar &G) { + Item I; + I.RID = ID; + I.RuleLength = G.lookupRule(ID).Size; + return I; + } + static Item sentinel(RuleID ID) { + Item I; + I.RID = ID; + return I; + } + + RuleID rule() const { return RID; } + uint8_t dot() const { return DotPos; } + + bool hasNext() const { return DotPos < RuleLength; } + SymbolID next(const Grammar &G) const { + assert(hasNext()); + return G.lookupRule(RID).Sequence[DotPos]; + } + + Item advance() const { + assert(hasNext()); + Item I = *this; + ++I.DotPos; + return I; + } + + std::string dump(const Grammar &G) const; + + bool operator==(const Item &I) const { + return DotPos == I.DotPos && RID == I.RID; + } + bool operator<(const Item &I) const { + return std::tie(RID, DotPos) < std::tie(I.RID, I.DotPos); + } + friend llvm::hash_code hash_value(const Item &I) { + return llvm::hash_combine(I.RID, I.DotPos); + } + +private: + RuleID RID = 0; + uint8_t DotPos = 0; + uint8_t RuleLength = 0; // the length of rule body. +}; + +// A state represents a node in the LR automaton graph. It is an item set, which +// contains all possible rules that the LR parser may be parsing in that state. +// +// Conceptually, If we knew in advance what we're parsing, at any point we're +// partway through parsing a production, sitting on a stack of partially parsed +// productions. But because we don't know, there could be *several* productions +// we're partway through. The set of possibilities is the parser state, and we +// precompute all the transitions between these states. +struct State { + // A full set of items (including non-kernel items) representing the state, + // in a canonical order (see SortByNextSymbol in the cpp file). + std::vector Items; + + std::string dump(const Grammar &G, unsigned Indent = 0) const; +}; + +// LRGraph is a deterministic finite state automaton for LR parsing. +// +// Intuitively, an LR automaton is a transition graph. The graph has a +// collection of nodes, called States. Each state corresponds to a particular +// item set, which represents a condition that could occur during the process of +// parsing a production. Edges are directed from one state to another. Each edge +// is labeled by a grammar symbol (terminal or nonterminal). +// +// LRGraph is used to construct the LR parsing table which is a core +// data-structure driving the LR parser. +class LRGraph { +public: + // StateID is the index in States table. + using StateID = uint16_t; + + // Constructs an LR(0) automaton. + static LRGraph buildLR0(const Grammar &); + + // An edge in the LR graph, it represents a transition in the LR automaton. + // If the parser is at state Src, with a lookahead Label, then it + // transits to state Dst. + struct Edge { + StateID Src, Dst; + SymbolID Label; + }; + + // A possible error recovery: choose to match some tokens against a symbol. + // + // e.g. a state that contains + // stmt := { . stmt-seq [recover=braces] } + // has a Recovery { Src = S, Strategy=braces, Result=stmt-seq }. + struct Recovery { + StateID Src; // The state we are in when encountering the error. + ExtensionID Strategy; // Heuristic choosing the tokens to match. + SymbolID Result; // The symbol that is produced. + }; + + llvm::ArrayRef states() const { return States; } + llvm::ArrayRef edges() const { return Edges; } + llvm::ArrayRef recoveries() const { return Recoveries; } + llvm::ArrayRef> startStates() const { + return StartStates; + } + + std::string dumpForTests(const Grammar &) const; + +private: + LRGraph(std::vector States, std::vector Edges, + std::vector Recoveries, + std::vector> StartStates) + : States(std::move(States)), Edges(std::move(Edges)), + Recoveries(std::move(Recoveries)), StartStates(std::move(StartStates)) { + } + + std::vector States; + std::vector Edges; + std::vector Recoveries; + std::vector> StartStates; +}; + +} // namespace pseudo +} // namespace clang + +namespace llvm { +// Support clang::pseudo::Item as DenseMap keys. +template <> struct DenseMapInfo { + static inline clang::pseudo::Item getEmptyKey() { + return clang::pseudo::Item::sentinel(-1); + } + static inline clang::pseudo::Item getTombstoneKey() { + return clang::pseudo::Item::sentinel(-2); + } + static unsigned getHashValue(const clang::pseudo::Item &I) { + return hash_value(I); + } + static bool isEqual(const clang::pseudo::Item &LHS, + const clang::pseudo::Item &RHS) { + return LHS == RHS; + } +}; +} // namespace llvm + +#endif // CLANG_PSEUDO_GRAMMAR_LRGRAPH_H diff --git a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h new file mode 100644 index 0000000000000..1706b6936c9ea --- /dev/null +++ b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h @@ -0,0 +1,278 @@ +//===--- LRTable.h - Define LR Parsing Table ---------------------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// The LRTable (referred as LR parsing table in the LR literature) is the core +// component in LR parsers, it drives the LR parsers by specifying an action to +// take given the current state on the top of the stack and the current +// lookahead token. +// +// The LRTable can be described as a matrix where the rows represent +// the states of the LR graph, the columns represent the symbols of the +// grammar, and each entry of the matrix (called action) represents a +// state transition in the graph. +// +// Typically, based on the category of the grammar symbol, the LRTable is +// broken into two logically separate tables: +// - ACTION table with terminals as columns -- e.g. ACTION[S, a] specifies +// next action (shift/reduce) on state S under a lookahead terminal a +// - GOTO table with nonterminals as columns -- e.g. GOTO[S, X] specifies +// the state which we transist to from the state S with the nonterminal X +// +// LRTable is *performance-critial* as it is consulted frequently during a +// parse. In general, LRTable is very sparse (most of the entries are empty). +// For example, for the C++ language, the SLR table has ~1500 states and 650 +// symbols which results in a matrix having 975K entries, ~90% of entries are +// empty. +// +// This file implements a speed-and-space-efficient LRTable. +// +//===----------------------------------------------------------------------===// + +#ifndef CLANG_PSEUDO_GRAMMAR_LRTABLE_H +#define CLANG_PSEUDO_GRAMMAR_LRTABLE_H + +#include "clang-pseudo/grammar/Grammar.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/BitVector.h" +#include "llvm/ADT/SmallSet.h" +#include "llvm/Support/Capacity.h" +#include "llvm/Support/MathExtras.h" +#include +#include + +namespace clang { +namespace pseudo { + +// Represents the LR parsing table, which can efficiently the question "what is +// the next step given the lookahead token and current state on top of the +// stack?". +// +// This is a dense implementation, which only takes an amount of space that is +// proportional to the number of non-empty entries in the table. +// +// Unlike the typical LR parsing table which allows at most one available action +// per entry, conflicted actions are allowed in LRTable. The LRTable is designed +// to be used in nondeterministic LR parsers (e.g. GLR). +// +// There are no "accept" actions in the LRTable, instead the stack is inspected +// after parsing completes: is the state goto(StartState, StartSymbol)? +class LRTable { +public: + // StateID is only 13 bits wide. + using StateID = uint16_t; + static constexpr unsigned StateBits = 13; + + struct Recovery { + ExtensionID Strategy; + SymbolID Result; + }; + + // Returns the state after we reduce a nonterminal. + // Expected to be called by LR parsers. + // If the nonterminal is invalid here, returns std::nullopt. + std::optional getGoToState(StateID State, + SymbolID Nonterminal) const { + return Gotos.get(gotoIndex(State, Nonterminal, numStates())); + } + // Returns the state after we shift a terminal. + // Expected to be called by LR parsers. + // If the terminal is invalid here, returns std::nullopt. + std::optional getShiftState(StateID State, + SymbolID Terminal) const { + return Shifts.get(shiftIndex(State, Terminal, numStates())); + } + + // Returns the possible reductions from a state. + // + // These are not keyed by a lookahead token. Instead, call canFollow() to + // check whether a reduction should apply in the current context: + // for (RuleID R : LR.getReduceRules(S)) { + // if (!LR.canFollow(G.lookupRule(R).Target, NextToken)) + // continue; + // // ...apply reduce... + // } + llvm::ArrayRef getReduceRules(StateID State) const { + assert(State + 1u < ReduceOffset.size()); + return llvm::ArrayRef(Reduces.data() + ReduceOffset[State], + Reduces.data() + ReduceOffset[State + 1]); + } + // Returns whether Terminal can follow Nonterminal in a valid source file. + bool canFollow(SymbolID Nonterminal, SymbolID Terminal) const { + assert(isToken(Terminal)); + assert(isNonterminal(Nonterminal)); + // tok::unknown is a sentinel value used in recovery: can follow anything. + return Terminal == tokenSymbol(tok::unknown) || + FollowSets.test(tok::NUM_TOKENS * Nonterminal + + symbolToToken(Terminal)); + } + + // Looks up available recovery actions if we stopped parsing in this state. + llvm::ArrayRef getRecovery(StateID State) const { + return llvm::ArrayRef(Recoveries.data() + RecoveryOffset[State], + Recoveries.data() + RecoveryOffset[State + 1]); + } + + // Returns the state from which the LR parser should start to parse the input + // tokens as the given StartSymbol. + // + // In LR parsing, the start state of `translation-unit` corresponds to + // `_ := • translation-unit`. + // + // Each start state responds to **a** single grammar rule like `_ := start`. + // REQUIRE: The given StartSymbol must exist in the grammar (in a form of + // `_ := start`). + StateID getStartState(SymbolID StartSymbol) const; + + size_t bytes() const { + return sizeof(*this) + Gotos.bytes() + Shifts.bytes() + + llvm::capacity_in_bytes(Reduces) + + llvm::capacity_in_bytes(ReduceOffset) + + llvm::capacity_in_bytes(FollowSets); + } + + std::string dumpStatistics() const; + std::string dumpForTests(const Grammar &G) const; + + // Build a SLR(1) parsing table. + static LRTable buildSLR(const Grammar &G); + + // Helper for building a table with specified actions/states. + struct Builder { + Builder() = default; + Builder(const Grammar &G) { + NumNonterminals = G.table().Nonterminals.size(); + FollowSets = followSets(G); + } + + unsigned int NumNonterminals = 0; + // States representing `_ := . start` for various start symbols. + std::vector> StartStates; + // State transitions `X := ABC . D EFG` => `X := ABC D . EFG`. + // Key is (initial state, D), value is final state. + llvm::DenseMap, StateID> Transition; + // Reductions available in a given state. + llvm::DenseMap> Reduce; + // FollowSets[NT] is the set of terminals that can follow the nonterminal. + std::vector> FollowSets; + // Recovery options available at each state. + std::vector> Recoveries; + + LRTable build() &&; + }; + +private: + unsigned numStates() const { return ReduceOffset.size() - 1; } + + // A map from unsigned key => StateID, used to store actions. + // The keys should be sequential but the values are somewhat sparse. + // + // In practice, the keys encode (origin state, symbol) pairs, and the values + // are the state we should move to after seeing that symbol. + // + // We store one bit for presence/absence of the value for each key. + // At every 64th key, we store the offset into the table of values. + // e.g. key 0x500 is checkpoint 0x500/64 = 20 + // Checkpoints[20] = 34 + // get(0x500) = Values[34] (assuming it has a value) + // To look up values in between, we count the set bits: + // get(0x509) has a value if HasValue[20] & (1<<9) + // #values between 0x500 and 0x509: popcnt(HasValue[20] & (1<<9 - 1)) + // get(0x509) = Values[34 + popcnt(...)] + // + // Overall size is 1.25 bits/key + 16 bits/value. + // Lookup is constant time with a low factor (no hashing). + class TransitionTable { + using Word = uint64_t; + constexpr static unsigned WordBits = CHAR_BIT * sizeof(Word); + + std::vector Values; + std::vector HasValue; + std::vector Checkpoints; + + public: + TransitionTable() = default; + TransitionTable(const llvm::DenseMap &Entries, + unsigned NumKeys) { + assert( + Entries.size() < + std::numeric_limits::max() && + "16 bits too small for value offsets!"); + unsigned NumWords = (NumKeys + WordBits - 1) / WordBits; + HasValue.resize(NumWords, 0); + Checkpoints.reserve(NumWords); + Values.reserve(Entries.size()); + for (unsigned I = 0; I < NumKeys; ++I) { + if ((I % WordBits) == 0) + Checkpoints.push_back(Values.size()); + auto It = Entries.find(I); + if (It != Entries.end()) { + HasValue[I / WordBits] |= (Word(1) << (I % WordBits)); + Values.push_back(It->second); + } + } + } + + std::optional get(unsigned Key) const { + // Do we have a value for this key? + Word KeyMask = Word(1) << (Key % WordBits); + unsigned KeyWord = Key / WordBits; + if ((HasValue[KeyWord] & KeyMask) == 0) + return std::nullopt; + // Count the number of values since the checkpoint. + Word BelowKeyMask = KeyMask - 1; + unsigned CountSinceCheckpoint = + llvm::popcount(HasValue[KeyWord] & BelowKeyMask); + // Find the value relative to the last checkpoint. + return Values[Checkpoints[KeyWord] + CountSinceCheckpoint]; + } + + unsigned size() const { return Values.size(); } + + size_t bytes() const { + return llvm::capacity_in_bytes(HasValue) + + llvm::capacity_in_bytes(Values) + + llvm::capacity_in_bytes(Checkpoints); + } + }; + // Shift and Goto tables are keyed by encoded (State, Symbol). + static unsigned shiftIndex(StateID State, SymbolID Terminal, + unsigned NumStates) { + return NumStates * symbolToToken(Terminal) + State; + } + static unsigned gotoIndex(StateID State, SymbolID Nonterminal, + unsigned NumStates) { + assert(isNonterminal(Nonterminal)); + return NumStates * Nonterminal + State; + } + TransitionTable Shifts; + TransitionTable Gotos; + + // A sorted table, storing the start state for each target parsing symbol. + std::vector> StartStates; + + // Given a state ID S, the half-open range of Reduces is + // [ReduceOffset[S], ReduceOffset[S+1]) + std::vector ReduceOffset; + std::vector Reduces; + // Conceptually this is a bool[SymbolID][Token], each entry describing whether + // the grammar allows the (nonterminal) symbol to be followed by the token. + // + // This is flattened by encoding the (SymbolID Nonterminal, tok::Kind Token) + // as an index: Nonterminal * NUM_TOKENS + Token. + llvm::BitVector FollowSets; + + // Recovery stores all recovery actions from all states. + // A given state has [RecoveryOffset[S], RecoveryOffset[S+1]). + std::vector RecoveryOffset; + std::vector Recoveries; +}; + +} // namespace pseudo +} // namespace clang + +#endif // CLANG_PSEUDO_GRAMMAR_LRTABLE_H diff --git a/clang-tools-extra/clangd/support/Bracket.cpp b/clang-tools-extra/pseudo/lib/Bracket.cpp similarity index 97% rename from clang-tools-extra/clangd/support/Bracket.cpp rename to clang-tools-extra/pseudo/lib/Bracket.cpp index 93d0f38015efb..07836146ad8a5 100644 --- a/clang-tools-extra/clangd/support/Bracket.cpp +++ b/clang-tools-extra/pseudo/lib/Bracket.cpp @@ -62,10 +62,10 @@ // //===----------------------------------------------------------------------===// -#include "Bracket.h" +#include "clang-pseudo/Bracket.h" namespace clang { -namespace clangd { +namespace pseudo { namespace { struct Bracket { @@ -83,7 +83,7 @@ struct Bracket { // Find brackets in the stream and convert to Bracket struct. std::vector findBrackets(const TokenStream &Stream) { std::vector Brackets; - auto Add = [&](const Token &Tok, Bracket::BracketKind K, + auto Add = [&](const pseudo::Token &Tok, Bracket::BracketKind K, Bracket::Direction D) { Brackets.push_back( {K, D, Tok.Line, Tok.Indent, Stream.index(Tok), Bracket::None}); @@ -151,5 +151,5 @@ void pairBrackets(TokenStream &Stream) { applyPairings(Brackets, Stream); } -} // namespace clangd +} // namespace pseudo } // namespace clang diff --git a/clang-tools-extra/pseudo/lib/CMakeLists.txt b/clang-tools-extra/pseudo/lib/CMakeLists.txt new file mode 100644 index 0000000000000..a13b5d20cf7c3 --- /dev/null +++ b/clang-tools-extra/pseudo/lib/CMakeLists.txt @@ -0,0 +1,31 @@ +add_subdirectory(cli) +add_subdirectory(cxx) +add_subdirectory(grammar) + +set(LLVM_LINK_COMPONENTS Support) + +add_clang_library(clangPseudo + Bracket.cpp + DirectiveTree.cpp + Disambiguate.cpp + Forest.cpp + GLR.cpp + Lex.cpp + Token.cpp + + LINK_LIBS + clangPseudoGrammar + + DEPENDS + ClangDriverOptions + ) + + target_include_directories(clangPseudo INTERFACE + $ + ) + +clang_target_link_libraries(clangPseudo + PRIVATE + clangBasic + clangLex + ) diff --git a/clang-tools-extra/clangd/support/DirectiveTree.cpp b/clang-tools-extra/pseudo/lib/DirectiveTree.cpp similarity index 99% rename from clang-tools-extra/clangd/support/DirectiveTree.cpp rename to clang-tools-extra/pseudo/lib/DirectiveTree.cpp index d25da111681af..9e853e46edc23 100644 --- a/clang-tools-extra/clangd/support/DirectiveTree.cpp +++ b/clang-tools-extra/pseudo/lib/DirectiveTree.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "DirectiveTree.h" +#include "clang-pseudo/DirectiveTree.h" #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/TokenKinds.h" #include "llvm/Support/FormatVariadic.h" @@ -14,7 +14,7 @@ #include namespace clang { -namespace clangd { +namespace pseudo { namespace { class DirectiveParser { @@ -353,5 +353,5 @@ TokenStream DirectiveTree::stripDirectives(const TokenStream &In) const { return Out; } -} // namespace clangd +} // namespace pseudo } // namespace clang diff --git a/clang-tools-extra/pseudo/lib/Disambiguate.cpp b/clang-tools-extra/pseudo/lib/Disambiguate.cpp new file mode 100644 index 0000000000000..b0bc75cf96c93 --- /dev/null +++ b/clang-tools-extra/pseudo/lib/Disambiguate.cpp @@ -0,0 +1,48 @@ +//===--- Disambiguate.cpp - Find the best tree in the forest --------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/Disambiguate.h" + +namespace clang::pseudo { + +Disambiguation disambiguate(const ForestNode *Root, + const DisambiguateParams &Params) { + // FIXME: this is a dummy placeholder strategy, implement a real one! + Disambiguation Result; + for (const ForestNode &N : Root->descendants()) { + if (N.kind() == ForestNode::Ambiguous) + Result.try_emplace(&N, 1); + } + return Result; +} + +void removeAmbiguities(ForestNode *&Root, const Disambiguation &D) { + std::vector Queue = {&Root}; + while (!Queue.empty()) { + ForestNode **Next = Queue.back(); + Queue.pop_back(); + switch ((*Next)->kind()) { + case ForestNode::Sequence: + for (ForestNode *&Child : (*Next)->elements()) + Queue.push_back(&Child); + break; + case ForestNode::Ambiguous: { + assert(D.count(*Next) != 0 && "disambiguation is incomplete!"); + ForestNode *ChosenChild = (*Next)->alternatives()[D.lookup(*Next)]; + *Next = ChosenChild; + Queue.push_back(Next); + break; + } + case ForestNode::Terminal: + case ForestNode::Opaque: + break; + } + } +} + +} // namespace clang::pseudo diff --git a/clang-tools-extra/pseudo/lib/Forest.cpp b/clang-tools-extra/pseudo/lib/Forest.cpp new file mode 100644 index 0000000000000..e8e60e5ec475a --- /dev/null +++ b/clang-tools-extra/pseudo/lib/Forest.cpp @@ -0,0 +1,199 @@ +//===--- Forest.cpp - Parse forest ------------------------------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/Forest.h" +#include "clang-pseudo/Token.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/Support/FormatVariadic.h" +#include + +namespace clang { +namespace pseudo { + +void ForestNode::RecursiveIterator::operator++() { + auto C = Cur->children(); + // Try to find a child of the current node to descend into. + for (unsigned I = 0; I < C.size(); ++I) { + if (Seen.insert(C[I]).second) { + Stack.push_back({Cur, I}); + Cur = C[I]; + return; + } + } + // Try to find a sibling af an ancestor to advance to. + for (; !Stack.empty(); Stack.pop_back()) { + C = Stack.back().Parent->children(); + unsigned &Index = Stack.back().ChildIndex; + while (++Index < C.size()) { + if (Seen.insert(C[Index]).second) { + Cur = C[Index]; + return; + } + } + } + Cur = nullptr; +} + +llvm::iterator_range +ForestNode::descendants() const { + return {RecursiveIterator(this), RecursiveIterator()}; +} + +std::string ForestNode::dump(const Grammar &G) const { + switch (kind()) { + case Ambiguous: + return llvm::formatv("{0} := ", G.symbolName(symbol())); + case Terminal: + return llvm::formatv("{0} := tok[{1}]", G.symbolName(symbol()), + startTokenIndex()); + case Sequence: + return G.dumpRule(rule()); + case Opaque: + return llvm::formatv("{0} := ", G.symbolName(symbol())); + } + llvm_unreachable("Unhandled node kind!"); +} + +std::string ForestNode::dumpRecursive(const Grammar &G, + bool Abbreviated) const { + using llvm::formatv; + Token::Index MaxToken = 0; + // Count visits of nodes so we can mark those seen multiple times. + llvm::DenseMap VisitCounts; + std::function CountVisits = + [&](const ForestNode *P) { + MaxToken = std::max(MaxToken, P->startTokenIndex()); + if (VisitCounts[P]++ > 0) + return; // Don't count children as multiply visited. + if (P->kind() == Ambiguous) + llvm::for_each(P->alternatives(), CountVisits); + else if (P->kind() == Sequence) + llvm::for_each(P->elements(), CountVisits); + }; + CountVisits(this); + + unsigned IndexWidth = std::max(3, (int)std::to_string(MaxToken).size()); + // e.g. "[{0,4}, {1,4})" if MaxToken is 5742. + std::string RangeFormat = formatv("[{{0,{0}}, {{1,{0}}) ", IndexWidth); + + // The box-drawing characters that should be added as a child is rendered. + struct LineDecoration { + std::string Prefix; // Prepended to every line. + llvm::StringRef First; // added to the child's line. + llvm::StringRef Subsequent; // added to descendants' lines. + }; + + // We print a "#" for nonterminal forest nodes that are being dumped + // multiple times. + llvm::DenseMap ReferenceIds; + std::string Result; + constexpr Token::Index KEnd = std::numeric_limits::max(); + std::function, + LineDecoration &LineDec)> + Dump = [&](const ForestNode *P, Token::Index End, + std::optional ElidedParent, LineDecoration LineDec) { + bool SharedNode = VisitCounts.find(P)->getSecond() > 1; + llvm::ArrayRef Children; + auto EndOfElement = [&](size_t ChildIndex) { + return ChildIndex + 1 == Children.size() + ? End + : Children[ChildIndex + 1]->startTokenIndex(); + }; + if (P->kind() == Ambiguous) { + Children = P->alternatives(); + } else if (P->kind() == Sequence) { + Children = P->elements(); + if (Abbreviated) { + // Abbreviate chains of trivial sequence nodes. + // A := B, B := C, C := D, D := X Y Z + // becomes + // A~D := X Y Z + // + // We can't hide nodes that appear multiple times in the tree, + // because we need to call out their identity with IDs. + if (Children.size() == 1 && !SharedNode) { + assert(Children[0]->startTokenIndex() == P->startTokenIndex() && + EndOfElement(0) == End); + return Dump(Children[0], End, + /*ElidedParent=*/ElidedParent.value_or(P->symbol()), + LineDec); + } + } + } + + if (End == KEnd) + Result += formatv(RangeFormat.c_str(), P->startTokenIndex(), "end"); + else + Result += formatv(RangeFormat.c_str(), P->startTokenIndex(), End); + Result += LineDec.Prefix; + Result += LineDec.First; + if (ElidedParent) { + Result += G.symbolName(*ElidedParent); + Result += "~"; + } + + if (SharedNode && P->kind() != ForestNode::Terminal) { + auto It = ReferenceIds.try_emplace(P, ReferenceIds.size() + 1); + bool First = It.second; + unsigned ID = It.first->second; + + // The first time, print as #1. Later, =#1. + if (First) { + Result += formatv("{0} #{1}", P->dump(G), ID); + } else { + Result += formatv("{0} =#{1}", G.symbolName(P->symbol()), ID); + Children = {}; // Don't walk the children again. + } + } else { + Result.append(P->dump(G)); + } + Result.push_back('\n'); + + auto OldPrefixSize = LineDec.Prefix.size(); + LineDec.Prefix += LineDec.Subsequent; + for (size_t I = 0; I < Children.size(); ++I) { + if (I == Children.size() - 1) { + LineDec.First = "└─"; + LineDec.Subsequent = " "; + } else { + LineDec.First = "├─"; + LineDec.Subsequent = "│ "; + } + Dump(Children[I], P->kind() == Sequence ? EndOfElement(I) : End, + std::nullopt, LineDec); + } + LineDec.Prefix.resize(OldPrefixSize); + }; + LineDecoration LineDec; + Dump(this, KEnd, std::nullopt, LineDec); + return Result; +} + +llvm::ArrayRef +ForestArena::createTerminals(const TokenStream &Code) { + ForestNode *Terminals = Arena.Allocate(Code.tokens().size() + 1); + size_t Index = 0; + for (const auto &T : Code.tokens()) { + new (&Terminals[Index]) + ForestNode(ForestNode::Terminal, tokenSymbol(T.Kind), + /*Start=*/Index, /*TerminalData*/ 0); + ++Index; + } + // Include an `eof` terminal. + // This is important to drive the final shift/recover/reduce loop. + new (&Terminals[Index]) + ForestNode(ForestNode::Terminal, tokenSymbol(tok::eof), + /*Start=*/Index, /*TerminalData*/ 0); + ++Index; + NodeCount = Index; + return llvm::ArrayRef(Terminals, Index); +} + +} // namespace pseudo +} // namespace clang diff --git a/clang-tools-extra/pseudo/lib/GLR.cpp b/clang-tools-extra/pseudo/lib/GLR.cpp new file mode 100644 index 0000000000000..ac43c02db521e --- /dev/null +++ b/clang-tools-extra/pseudo/lib/GLR.cpp @@ -0,0 +1,772 @@ +//===--- GLR.cpp -----------------------------------------------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/GLR.h" +#include "clang-pseudo/Language.h" +#include "clang-pseudo/grammar/Grammar.h" +#include "clang-pseudo/grammar/LRTable.h" +#include "clang/Basic/TokenKinds.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/ScopeExit.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/FormatVariadic.h" +#include +#include +#include +#include + +#define DEBUG_TYPE "GLR.cpp" + +namespace clang { +namespace pseudo { +namespace { + +Token::Index findRecoveryEndpoint(ExtensionID Strategy, Token::Index Begin, + const TokenStream &Tokens, + const Language &Lang) { + assert(Strategy != 0); + if (auto S = Lang.RecoveryStrategies.lookup(Strategy)) + return S(Begin, Tokens); + return Token::Invalid; +} + +} // namespace + +void glrRecover(llvm::ArrayRef OldHeads, + unsigned &TokenIndex, const ParseParams &Params, + const Language &Lang, + std::vector &NewHeads) { + LLVM_DEBUG(llvm::dbgs() << "Recovery at token " << TokenIndex << "...\n"); + // Describes a possibility to recover by forcibly interpreting a range of + // tokens around the cursor as a nonterminal that we expected to see. + struct PlaceholderRecovery { + // The token prior to the nonterminal which is being recovered. + // This starts of the region we're skipping, so higher Position is better. + Token::Index Position; + // The nonterminal which will be created in order to recover. + SymbolID Symbol; + // The heuristic used to choose the bounds of the nonterminal to recover. + ExtensionID Strategy; + + // The GSS head where we are expecting the recovered nonterminal. + const GSS::Node *RecoveryNode; + // Payload of nodes on the way back from the OldHead to the recovery node. + // These represent the partial parse that is being discarded. + // They should become the children of the opaque recovery node. + // FIXME: internal structure of opaque nodes is not implemented. + // + // There may be multiple paths leading to the same recovery node, we choose + // one arbitrarily. + std::vector DiscardedParse; + }; + std::vector Options; + + // Find recovery options by walking up the stack. + // + // This is similar to exception handling: we walk up the "frames" of nested + // rules being parsed until we find one that has a "handler" which allows us + // to determine the node bounds without parsing it. + // + // Unfortunately there's a significant difference: the stack contains both + // "upward" nodes (ancestor parses) and "leftward" ones. + // e.g. when parsing `{ if (1) ? }` as compound-stmt, the stack contains: + // stmt := IF ( expr ) . stmt - current state, we should recover here! + // stmt := IF ( expr . ) stmt - (left, no recovery here) + // stmt := IF ( . expr ) stmt - left, we should NOT recover here! + // stmt := IF . ( expr ) stmt - (left, no recovery here) + // stmt-seq := . stmt - up, we might recover here + // compound-stmt := { . stmt-seq } - up, we should recover here! + // + // It's not obvious how to avoid collecting "leftward" recovery options. + // I think the distinction is ill-defined after merging items into states. + // For now, we have to take this into account when defining recovery rules. + // (e.g. in the expr recovery above, stay inside the parentheses). + // FIXME: find a more satisfying way to avoid such false recovery. + // FIXME: Add a test for spurious recovery once tests can define strategies. + std::vector Path; + llvm::DenseSet Seen; + auto WalkUp = [&](const GSS::Node *N, Token::Index NextTok, auto &WalkUp) { + if (!Seen.insert(N).second) + return; + if (!N->Recovered) { // Don't recover the same way twice! + for (auto Strategy : Lang.Table.getRecovery(N->State)) { + Options.push_back(PlaceholderRecovery{ + NextTok, + Strategy.Result, + Strategy.Strategy, + N, + Path, + }); + LLVM_DEBUG(llvm::dbgs() + << "Option: recover " << Lang.G.symbolName(Strategy.Result) + << " at token " << NextTok << "\n"); + } + } + Path.push_back(N->Payload); + for (const GSS::Node *Parent : N->parents()) + WalkUp(Parent, N->Payload->startTokenIndex(), WalkUp); + Path.pop_back(); + }; + for (auto *N : OldHeads) + WalkUp(N, TokenIndex, WalkUp); + + // Now we select the option(s) we will use to recover. + // + // We prefer options starting further right, as these discard less code + // (e.g. we prefer to recover inner scopes rather than outer ones). + // The options also need to agree on an endpoint, so the parser has a + // consistent position afterwards. + // + // So conceptually we're sorting by the tuple (start, end), though we avoid + // computing `end` for options that can't be winners. + + // Consider options starting further right first. + // Don't drop the others yet though, we may still use them if preferred fails. + llvm::stable_sort(Options, [&](const auto &L, const auto &R) { + return L.Position > R.Position; + }); + + // We may find multiple winners, but they will have the same range. + std::optional RecoveryRange; + std::vector BestOptions; + for (const PlaceholderRecovery &Option : Options) { + // If this starts further left than options we've already found, then + // we'll never find anything better. Skip computing End for the rest. + if (RecoveryRange && Option.Position < RecoveryRange->Begin) + break; + + auto End = findRecoveryEndpoint(Option.Strategy, Option.Position, + Params.Code, Lang); + // Recovery may not take the parse backwards. + if (End == Token::Invalid || End < TokenIndex) + continue; + if (RecoveryRange) { + // If this is worse than our previous options, ignore it. + if (RecoveryRange->End < End) + continue; + // If this is an improvement over our previous options, then drop them. + if (RecoveryRange->End > End) + BestOptions.clear(); + } + // Create recovery nodes and heads for them in the GSS. These may be + // discarded if a better recovery is later found, but this path isn't hot. + RecoveryRange = {Option.Position, End}; + BestOptions.push_back(&Option); + } + + if (BestOptions.empty()) { + LLVM_DEBUG(llvm::dbgs() << "Recovery failed after trying " << Options.size() + << " strategies\n"); + return; + } + + // We've settled on a set of recovery options, so create their nodes and + // advance the cursor. + LLVM_DEBUG({ + llvm::dbgs() << "Recovered range=" << *RecoveryRange << ":"; + for (const auto *Option : BestOptions) + llvm::dbgs() << " " << Lang.G.symbolName(Option->Symbol); + llvm::dbgs() << "\n"; + }); + // FIXME: in general, we might have the same Option->Symbol multiple times, + // and we risk creating redundant Forest and GSS nodes. + // We also may inadvertently set up the next glrReduce to create a sequence + // node duplicating an opaque node that we're creating here. + // There are various options, including simply breaking ties between options. + // For now it's obscure enough to ignore. + for (const PlaceholderRecovery *Option : BestOptions) { + Option->RecoveryNode->Recovered = true; + const ForestNode &Placeholder = + Params.Forest.createOpaque(Option->Symbol, RecoveryRange->Begin); + LRTable::StateID OldState = Option->RecoveryNode->State; + LRTable::StateID NewState = + isToken(Option->Symbol) + ? *Lang.Table.getShiftState(OldState, Option->Symbol) + : *Lang.Table.getGoToState(OldState, Option->Symbol); + const GSS::Node *NewHead = + Params.GSStack.addNode(NewState, &Placeholder, {Option->RecoveryNode}); + NewHeads.push_back(NewHead); + } + TokenIndex = RecoveryRange->End; +} + +using StateID = LRTable::StateID; + +llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const GSS::Node &N) { + std::vector ParentStates; + for (const auto *Parent : N.parents()) + ParentStates.push_back(llvm::formatv("{0}", Parent->State)); + OS << llvm::formatv("state {0}, parsed symbol {1}, parents {3}", N.State, + N.Payload ? N.Payload->symbol() : 0, + llvm::join(ParentStates, ", ")); + return OS; +} + +// Apply all pending shift actions. +// In theory, LR parsing doesn't have shift/shift conflicts on a single head. +// But we may have multiple active heads, and each head has a shift action. +// +// We merge the stack -- if multiple heads will reach the same state after +// shifting a token, we shift only once by combining these heads. +// +// E.g. we have two heads (2, 3) in the GSS, and will shift both to reach 4: +// 0---1---2 +// â””---3 +// After the shift action, the GSS is: +// 0---1---2---4 +// â””---3---┘ +void glrShift(llvm::ArrayRef OldHeads, + const ForestNode &NewTok, const ParseParams &Params, + const Language &Lang, std::vector &NewHeads) { + assert(NewTok.kind() == ForestNode::Terminal); + LLVM_DEBUG(llvm::dbgs() << llvm::formatv(" Shift {0} ({1} active heads):\n", + Lang.G.symbolName(NewTok.symbol()), + OldHeads.size())); + + // We group pending shifts by their target state so we can merge them. + llvm::SmallVector, 8> Shifts; + for (const auto *H : OldHeads) + if (auto S = Lang.Table.getShiftState(H->State, NewTok.symbol())) + Shifts.push_back({*S, H}); + llvm::stable_sort(Shifts, llvm::less_first{}); + + auto Rest = llvm::ArrayRef(Shifts); + llvm::SmallVector Parents; + while (!Rest.empty()) { + // Collect the batch of PendingShift that have compatible shift states. + // Their heads become TempParents, the parents of the new GSS node. + StateID NextState = Rest.front().first; + + Parents.clear(); + for (const auto &Base : Rest) { + if (Base.first != NextState) + break; + Parents.push_back(Base.second); + } + Rest = Rest.drop_front(Parents.size()); + + LLVM_DEBUG(llvm::dbgs() << llvm::formatv(" --> S{0} ({1} heads)\n", + NextState, Parents.size())); + NewHeads.push_back(Params.GSStack.addNode(NextState, &NewTok, Parents)); + } +} + +namespace { +// A KeyedQueue yields pairs of keys and values in order of the keys. +template +using KeyedQueue = + std::priority_queue, + std::vector>, llvm::less_first>; + +template void sortAndUnique(std::vector &Vec) { + llvm::sort(Vec); + Vec.erase(std::unique(Vec.begin(), Vec.end()), Vec.end()); +} + +// Perform reduces until no more are possible. +// +// Generally this means walking up from the heads gathering ForestNodes that +// will match the RHS of the rule we're reducing into a sequence ForestNode, +// and ending up at a base node. +// Then we push a new GSS node onto that base, taking care to: +// - pack alternative sequence ForestNodes into an ambiguous ForestNode. +// - use the same GSS node for multiple heads if the parse state matches. +// +// Examples of reduction: +// Before (simple): +// 0--1(expr)--2(semi) +// After reducing 2 by `stmt := expr semi`: +// 0--3(stmt) // 3 is goto(0, stmt) +// +// Before (splitting due to R/R conflict): +// 0--1(IDENTIFIER) +// After reducing 1 by `class-name := IDENTIFIER` & `enum-name := IDENTIFIER`: +// 0--2(class-name) // 2 is goto(0, class-name) +// â””--3(enum-name) // 3 is goto(0, enum-name) +// +// Before (splitting due to multiple bases): +// 0--2(class-name)--4(STAR) +// â””--3(enum-name)---┘ +// After reducing 4 by `ptr-operator := STAR`: +// 0--2(class-name)--5(ptr-operator) // 5 is goto(2, ptr-operator) +// â””--3(enum-name)---6(ptr-operator) // 6 is goto(3, ptr-operator) +// +// Before (joining due to same goto state, multiple bases): +// 0--1(cv-qualifier)--3(class-name) +// â””--2(cv-qualifier)--4(enum-name) +// After reducing 3 by `type-name := class-name` and +// 4 by `type-name := enum-name`: +// 0--1(cv-qualifier)--5(type-name) // 5 is goto(1, type-name) and +// â””--2(cv-qualifier)--┘ // goto(2, type-name) +// +// Before (joining due to same goto state, the same base): +// 0--1(class-name)--3(STAR) +// â””--2(enum-name)--4(STAR) +// After reducing 3 by `pointer := class-name STAR` and +// 2 by`enum-name := class-name STAR`: +// 0--5(pointer) // 5 is goto(0, pointer) +// +// (This is a functor rather than a function to allow it to reuse scratch +// storage across calls). +class GLRReduce { + const ParseParams &Params; + const Language& Lang; + // There are two interacting complications: + // 1. Performing one reduce can unlock new reduces on the newly-created head. + // 2a. The ambiguous ForestNodes must be complete (have all sequence nodes). + // This means we must have unlocked all the reduces that contribute to it. + // 2b. Similarly, the new GSS nodes must be complete (have all parents). + // + // We define a "family" of reduces as those that produce the same symbol and + // cover the same range of tokens. These are exactly the set of reductions + // whose sequence nodes would be covered by the same ambiguous node. + // We wish to process a whole family at a time (to satisfy complication 2), + // and can address complication 1 by carefully ordering the families: + // - Process families covering fewer tokens first. + // A reduce can't depend on a longer reduce! + // - For equal token ranges: if S := T, process T families before S families. + // Parsing T can't depend on an equal-length S, as the grammar is acyclic. + // + // This isn't quite enough: we don't know the token length of the reduction + // until we walk up the stack to perform the pop. + // So we perform the pop part upfront, and place the push specification on + // priority queues such that we can retrieve a family at a time. + + // A reduction family is characterized by its token range and symbol produced. + // It is used as a key in the priority queues to group pushes by family. + struct Family { + // The start of the token range of the reduce. + Token::Index Start; + SymbolID Symbol; + // Rule must produce Symbol and can otherwise be arbitrary. + // RuleIDs have the topological order based on the acyclic grammar. + // FIXME: should SymbolIDs be so ordered instead? + RuleID Rule; + + bool operator==(const Family &Other) const { + return Start == Other.Start && Symbol == Other.Symbol; + } + // The larger Family is the one that should be processed first. + bool operator<(const Family &Other) const { + if (Start != Other.Start) + return Start < Other.Start; + if (Symbol != Other.Symbol) + return Rule > Other.Rule; + assert(*this == Other); + return false; + } + }; + + // A sequence is the ForestNode payloads of the GSS nodes we are reducing. + using Sequence = llvm::SmallVector; + // Like ArrayRef, but with the missing operator<. + // (Sequences are big to move by value as the collections gets rearranged). + struct SequenceRef { + SequenceRef(const Sequence &S) : S(S) {} + llvm::ArrayRef S; + friend bool operator==(SequenceRef A, SequenceRef B) { return A.S == B.S; } + friend bool operator<(const SequenceRef &A, const SequenceRef &B) { + return std::lexicographical_compare(A.S.begin(), A.S.end(), B.S.begin(), + B.S.end()); + } + }; + // Underlying storage for sequences pointed to by stored SequenceRefs. + std::deque SequenceStorage; + // We don't actually destroy the sequences between calls, to reuse storage. + // Everything SequenceStorage[ >=SequenceStorageCount ] is reusable scratch. + unsigned SequenceStorageCount; + + // Halfway through a reduction (after the pop, before the push), we have + // collected nodes for the RHS of a rule, and reached a base node. + // They specify a sequence ForestNode we may build (but we dedup first). + // (The RuleID is not stored here, but rather in the Family). + struct PushSpec { + // The last node popped before pushing. Its parent is the reduction base(s). + // (Base is more fundamental, but this is cheaper to store). + const GSS::Node* LastPop = nullptr; + Sequence *Seq = nullptr; + }; + KeyedQueue Sequences; // FIXME: rename => PendingPushes? + + // We treat Heads as a queue of Pop operations still to be performed. + // PoppedHeads is our position within it. + std::vector *Heads; + unsigned NextPopHead; + SymbolID Lookahead; + + Sequence TempSequence; +public: + GLRReduce(const ParseParams &Params, const Language &Lang) + : Params(Params), Lang(Lang) {} + + // Reduce Heads, resulting in new nodes that are appended to Heads. + // The "consumed" nodes are not removed! + // Only reduce rules compatible with the Lookahead are applied, though + // tokenSymbol(tok::unknown) will match any rule. + void operator()(std::vector &Heads, SymbolID Lookahead) { + assert(isToken(Lookahead)); + + NextPopHead = 0; + this->Heads = &Heads; + this->Lookahead = Lookahead; + assert(Sequences.empty()); + SequenceStorageCount = 0; + + popPending(); + while (!Sequences.empty()) { + pushNext(); + popPending(); + } + } + +private: + bool canReduce(const Rule &R, RuleID RID, + llvm::ArrayRef RHS) const { + if (!R.Guarded) + return true; + if (auto Guard = Lang.Guards.lookup(RID)) + return Guard({RHS, Params.Code, Lookahead}); + LLVM_DEBUG(llvm::dbgs() + << llvm::formatv("missing guard implementation for rule {0}\n", + Lang.G.dumpRule(RID))); + return true; + } + // pop walks up the parent chain(s) for a reduction from Head by to Rule. + // Once we reach the end, record the bases and sequences. + void pop(const GSS::Node *Head, RuleID RID, const Rule &Rule) { + LLVM_DEBUG(llvm::dbgs() << " Pop " << Lang.G.dumpRule(RID) << "\n"); + Family F{/*Start=*/0, /*Symbol=*/Rule.Target, /*Rule=*/RID}; + TempSequence.resize_for_overwrite(Rule.Size); + auto DFS = [&](const GSS::Node *N, unsigned I, auto &DFS) { + TempSequence[Rule.Size - 1 - I] = N->Payload; + if (I + 1 == Rule.Size) { + F.Start = TempSequence.front()->startTokenIndex(); + LLVM_DEBUG({ + for (const auto *B : N->parents()) + llvm::dbgs() << " --> base at S" << B->State << "\n"; + }); + if (!canReduce(Rule, RID, TempSequence)) + return; + // Copy the chain to stable storage so it can be enqueued. + if (SequenceStorageCount == SequenceStorage.size()) + SequenceStorage.emplace_back(); + SequenceStorage[SequenceStorageCount] = TempSequence; + Sequence *Seq = &SequenceStorage[SequenceStorageCount++]; + + Sequences.emplace(F, PushSpec{N, Seq}); + return; + } + for (const GSS::Node *Parent : N->parents()) + DFS(Parent, I + 1, DFS); + }; + DFS(Head, 0, DFS); + } + + // popPending pops every available reduction. + void popPending() { + for (; NextPopHead < Heads->size(); ++NextPopHead) { + // In trivial cases, we perform the complete reduce here! + if (popAndPushTrivial()) + continue; + for (RuleID RID : + Lang.Table.getReduceRules((*Heads)[NextPopHead]->State)) { + const auto &Rule = Lang.G.lookupRule(RID); + if (Lang.Table.canFollow(Rule.Target, Lookahead)) + pop((*Heads)[NextPopHead], RID, Rule); + } + } + } + + // Storage reused by each call to pushNext. + std::vector> FamilyBases; + std::vector> FamilySequences; + std::vector Parents; + std::vector SequenceNodes; + + // Process one push family, forming a forest node. + // This produces new GSS heads which may enable more pops. + void pushNext() { + assert(!Sequences.empty()); + Family F = Sequences.top().first; + + LLVM_DEBUG(llvm::dbgs() << " Push " << Lang.G.symbolName(F.Symbol) + << " from token " << F.Start << "\n"); + + // Grab the sequences and bases for this family. + // We don't care which rule yielded each base. If Family.Symbol is S, the + // base includes an item X := ... • S ... and since the grammar is + // context-free, *all* parses of S are valid here. + FamilySequences.clear(); + FamilyBases.clear(); + do { + const PushSpec &Push = Sequences.top().second; + FamilySequences.emplace_back(Sequences.top().first.Rule, *Push.Seq); + for (const GSS::Node *Base : Push.LastPop->parents()) { + auto NextState = Lang.Table.getGoToState(Base->State, F.Symbol); + assert(NextState.has_value() && "goto must succeed after reduce!"); + FamilyBases.emplace_back(*NextState, Base); + } + + Sequences.pop(); + } while (!Sequences.empty() && Sequences.top().first == F); + // Build a forest node for each unique sequence. + sortAndUnique(FamilySequences); + SequenceNodes.clear(); + for (const auto &SequenceSpec : FamilySequences) + SequenceNodes.push_back(&Params.Forest.createSequence( + F.Symbol, SequenceSpec.first, SequenceSpec.second.S)); + // Wrap in an ambiguous node if needed. + const ForestNode *Parsed = + SequenceNodes.size() == 1 + ? SequenceNodes.front() + : &Params.Forest.createAmbiguous(F.Symbol, SequenceNodes); + LLVM_DEBUG(llvm::dbgs() << " --> " << Parsed->dump(Lang.G) << "\n"); + + // Bases for this family, deduplicate them, and group by the goTo State. + sortAndUnique(FamilyBases); + // Create a GSS node for each unique goto state. + llvm::ArrayRef BasesLeft = FamilyBases; + while (!BasesLeft.empty()) { + StateID NextState = BasesLeft.front().first; + Parents.clear(); + for (const auto &Base : BasesLeft) { + if (Base.first != NextState) + break; + Parents.push_back(Base.second); + } + BasesLeft = BasesLeft.drop_front(Parents.size()); + Heads->push_back(Params.GSStack.addNode(NextState, Parsed, Parents)); + } + } + + // In general we split a reduce into a pop/push, so concurrently-available + // reductions can run in the correct order. The data structures are expensive. + // + // When only one reduction is possible at a time, we can skip this: + // we pop and immediately push, as an LR parser (as opposed to GLR) would. + // This is valid whenever there's only one concurrent PushSpec. + // + // This function handles a trivial but common subset of these cases: + // - there must be no pending pushes, and only one poppable head + // - the head must have only one reduction rule + // - the reduction path must be a straight line (no multiple parents) + // (Roughly this means there's no local ambiguity, so the LR algorithm works). + // + // Returns true if we successfully consumed the next unpopped head. + bool popAndPushTrivial() { + if (!Sequences.empty() || Heads->size() != NextPopHead + 1) + return false; + const GSS::Node *Head = Heads->back(); + std::optional RID; + for (RuleID R : Lang.Table.getReduceRules(Head->State)) { + if (RID.has_value()) + return false; + RID = R; + } + if (!RID) + return true; // no reductions available, but we've processed the head! + const auto &Rule = Lang.G.lookupRule(*RID); + if (!Lang.Table.canFollow(Rule.Target, Lookahead)) + return true; // reduction is not available + const GSS::Node *Base = Head; + TempSequence.resize_for_overwrite(Rule.Size); + for (unsigned I = 0; I < Rule.Size; ++I) { + if (Base->parents().size() != 1) + return false; + TempSequence[Rule.Size - 1 - I] = Base->Payload; + Base = Base->parents().front(); + } + if (!canReduce(Rule, *RID, TempSequence)) + return true; // reduction is not available + const ForestNode *Parsed = + &Params.Forest.createSequence(Rule.Target, *RID, TempSequence); + auto NextState = Lang.Table.getGoToState(Base->State, Rule.Target); + assert(NextState.has_value() && "goto must succeed after reduce!"); + Heads->push_back(Params.GSStack.addNode(*NextState, Parsed, {Base})); + LLVM_DEBUG(llvm::dbgs() + << " Reduce (trivial) " << Lang.G.dumpRule(*RID) << "\n" + << " --> S" << Heads->back()->State << "\n"); + return true; + } +}; + +} // namespace + +ForestNode &glrParse(const ParseParams &Params, SymbolID StartSymbol, + const Language &Lang) { + GLRReduce Reduce(Params, Lang); + assert(isNonterminal(StartSymbol) && "Start symbol must be a nonterminal"); + llvm::ArrayRef Terminals = Params.Forest.createTerminals(Params.Code); + auto &GSS = Params.GSStack; + + StateID StartState = Lang.Table.getStartState(StartSymbol); + // Heads correspond to the parse of tokens [0, I), NextHeads to [0, I+1). + std::vector Heads = {GSS.addNode(/*State=*/StartState, + /*ForestNode=*/nullptr, + {})}; + // Invariant: Heads is partitioned by source: {shifted | reduced}. + // HeadsPartition is the index of the first head formed by reduction. + // We use this to discard and recreate the reduced heads during recovery. + unsigned HeadsPartition = Heads.size(); + std::vector NextHeads; + auto MaybeGC = [&, Roots(std::vector{}), I(0u)]() mutable { + assert(NextHeads.empty() && "Running GC at the wrong time!"); + if (++I != 20) // Run periodically to balance CPU and memory usage. + return; + I = 0; + + // We need to copy the list: Roots is consumed by the GC. + Roots = Heads; + GSS.gc(std::move(Roots)); + }; + // Each iteration fully processes a single token. + for (unsigned I = 0; I < Terminals.size();) { + LLVM_DEBUG(llvm::dbgs() << llvm::formatv( + "Next token {0} (id={1})\n", + Lang.G.symbolName(Terminals[I].symbol()), Terminals[I].symbol())); + // Consume the token. + glrShift(Heads, Terminals[I], Params, Lang, NextHeads); + + // If we weren't able to consume the token, try to skip over some tokens + // so we can keep parsing. + if (NextHeads.empty()) { + // The reduction in the previous round was constrained by lookahead. + // On valid code this only rejects dead ends, but on broken code we should + // consider all possibilities. + // + // We discard all heads formed by reduction, and recreate them without + // this constraint. This may duplicate some nodes, but it's rare. + LLVM_DEBUG(llvm::dbgs() << "Shift failed, will attempt recovery. " + "Re-reducing without lookahead.\n"); + Heads.resize(HeadsPartition); + Reduce(Heads, /*allow all reductions*/ tokenSymbol(tok::unknown)); + + glrRecover(Heads, I, Params, Lang, NextHeads); + if (NextHeads.empty()) + // FIXME: Ensure the `_ := start-symbol` rules have a fallback + // error-recovery strategy attached. Then this condition can't happen. + return Params.Forest.createOpaque(StartSymbol, /*Token::Index=*/0); + } else + ++I; + + // Form nonterminals containing the token we just consumed. + SymbolID Lookahead = + I == Terminals.size() ? tokenSymbol(tok::eof) : Terminals[I].symbol(); + HeadsPartition = NextHeads.size(); + Reduce(NextHeads, Lookahead); + // Prepare for the next token. + std::swap(Heads, NextHeads); + NextHeads.clear(); + MaybeGC(); + } + LLVM_DEBUG(llvm::dbgs() << llvm::formatv("Reached eof\n")); + + // The parse was successful if in state `_ := start-symbol EOF .` + // The GSS parent has `_ := start-symbol . EOF`; its payload is the parse. + auto AfterStart = Lang.Table.getGoToState(StartState, StartSymbol); + assert(AfterStart.has_value() && "goto must succeed after start symbol!"); + auto Accept = Lang.Table.getShiftState(*AfterStart, tokenSymbol(tok::eof)); + assert(Accept.has_value() && "shift EOF must succeed!"); + auto SearchForAccept = [&](llvm::ArrayRef Heads) { + const ForestNode *Result = nullptr; + for (const auto *Head : Heads) { + if (Head->State == *Accept) { + assert(Head->Payload->symbol() == tokenSymbol(tok::eof)); + assert(Result == nullptr && "multiple results!"); + Result = Head->parents().front()->Payload; + assert(Result->symbol() == StartSymbol); + } + } + return Result; + }; + if (auto *Result = SearchForAccept(Heads)) + return *const_cast(Result); // Safe: we created all nodes. + // We failed to parse the input, returning an opaque forest node for recovery. + // FIXME: as above, we can add fallback error handling so this is impossible. + return Params.Forest.createOpaque(StartSymbol, /*Token::Index=*/0); +} + +void glrReduce(std::vector &Heads, SymbolID Lookahead, + const ParseParams &Params, const Language &Lang) { + // Create a new GLRReduce each time for tests, performance doesn't matter. + GLRReduce{Params, Lang}(Heads, Lookahead); +} + +const GSS::Node *GSS::addNode(LRTable::StateID State, const ForestNode *Symbol, + llvm::ArrayRef Parents) { + Node *Result = new (allocate(Parents.size())) Node(); + Result->State = State; + Result->GCParity = GCParity; + Result->ParentCount = Parents.size(); + Alive.push_back(Result); + ++NodesCreated; + Result->Payload = Symbol; + if (!Parents.empty()) + llvm::copy(Parents, reinterpret_cast(Result + 1)); + return Result; +} + +GSS::Node *GSS::allocate(unsigned Parents) { + if (FreeList.size() <= Parents) + FreeList.resize(Parents + 1); + auto &SizedList = FreeList[Parents]; + if (!SizedList.empty()) { + auto *Result = SizedList.back(); + SizedList.pop_back(); + return Result; + } + return static_cast( + Arena.Allocate(sizeof(Node) + Parents * sizeof(Node *), alignof(Node))); +} + +void GSS::destroy(Node *N) { + unsigned ParentCount = N->ParentCount; + N->~Node(); + assert(FreeList.size() > ParentCount && "established on construction!"); + FreeList[ParentCount].push_back(N); +} + +unsigned GSS::gc(std::vector &&Queue) { +#ifndef NDEBUG + auto ParityMatches = [&](const Node *N) { return N->GCParity == GCParity; }; + assert("Before GC" && llvm::all_of(Alive, ParityMatches)); + auto Deferred = llvm::make_scope_exit( + [&] { assert("After GC" && llvm::all_of(Alive, ParityMatches)); }); + assert(llvm::all_of( + Queue, [&](const Node *R) { return llvm::is_contained(Alive, R); })); +#endif + unsigned InitialCount = Alive.size(); + + // Mark + GCParity = !GCParity; + while (!Queue.empty()) { + Node *N = const_cast(Queue.back()); // Safe: we created these nodes. + Queue.pop_back(); + if (N->GCParity != GCParity) { // Not seen yet + N->GCParity = GCParity; // Mark as seen + for (const Node *P : N->parents()) // And walk parents + Queue.push_back(P); + } + } + // Sweep + llvm::erase_if(Alive, [&](Node *N) { + if (N->GCParity == GCParity) // Walk reached this node. + return false; + destroy(N); + return true; + }); + + LLVM_DEBUG(llvm::dbgs() << "GC pruned " << (InitialCount - Alive.size()) + << "/" << InitialCount << " GSS nodes\n"); + return InitialCount - Alive.size(); +} + +} // namespace pseudo +} // namespace clang diff --git a/clang-tools-extra/clangd/support/Lex.cpp b/clang-tools-extra/pseudo/lib/Lex.cpp similarity index 98% rename from clang-tools-extra/clangd/support/Lex.cpp rename to clang-tools-extra/pseudo/lib/Lex.cpp index f043b551b6bc6..2111476f04dc5 100644 --- a/clang-tools-extra/clangd/support/Lex.cpp +++ b/clang-tools-extra/pseudo/lib/Lex.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "Token.h" +#include "clang-pseudo/Token.h" #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/TokenKinds.h" @@ -14,7 +14,7 @@ #include "clang/Lex/LiteralSupport.h" namespace clang { -namespace clangd { +namespace pseudo { TokenStream lex(const std::string &Code, const clang::LangOptions &LangOpts) { clang::SourceLocation Start; @@ -135,5 +135,5 @@ TokenStream cook(const TokenStream &Code, const LangOptions &LangOpts) { return Result; } -} // namespace clangd +} // namespace pseudo } // namespace clang diff --git a/clang-tools-extra/clangd/support/Token.cpp b/clang-tools-extra/pseudo/lib/Token.cpp similarity index 98% rename from clang-tools-extra/clangd/support/Token.cpp rename to clang-tools-extra/pseudo/lib/Token.cpp index 13eee66606061..5b07a62f37fb2 100644 --- a/clang-tools-extra/clangd/support/Token.cpp +++ b/clang-tools-extra/pseudo/lib/Token.cpp @@ -6,14 +6,14 @@ // //===----------------------------------------------------------------------===// -#include "Token.h" +#include "clang-pseudo/Token.h" #include "clang/Basic/LangOptions.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Format.h" #include "llvm/Support/FormatVariadic.h" namespace clang { -namespace clangd { +namespace pseudo { llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Token &T) { OS << llvm::formatv("{0} {1}:{2} ", clang::tok::getTokenName(T.Kind), T.Line, @@ -126,5 +126,5 @@ TokenStream stripComments(const TokenStream &Input) { return Out; } -} // namespace clangd +} // namespace pseudo } // namespace clang diff --git a/clang-tools-extra/pseudo/lib/cli/CLI.cpp b/clang-tools-extra/pseudo/lib/cli/CLI.cpp new file mode 100644 index 0000000000000..5c7c3b6c827ea --- /dev/null +++ b/clang-tools-extra/pseudo/lib/cli/CLI.cpp @@ -0,0 +1,54 @@ +//===--- CLI.cpp - ----------------------------------------------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/cli/CLI.h" +#include "clang-pseudo/cxx/CXX.h" +#include "clang-pseudo/grammar/Grammar.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/ErrorOr.h" +#include "llvm/Support/MemoryBuffer.h" + +static llvm::cl::opt Grammar( + "grammar", + llvm::cl::desc( + "Specify a BNF grammar file path, or a builtin language (cxx)."), + llvm::cl::init("cxx")); + +namespace clang { +namespace pseudo { + +const Language &getLanguageFromFlags() { + if (::Grammar == "cxx") + return cxx::getLanguage(); + + static Language *Lang = []() { + // Read from a bnf grammar file. + llvm::ErrorOr> GrammarText = + llvm::MemoryBuffer::getFile(::Grammar); + if (std::error_code EC = GrammarText.getError()) { + llvm::errs() << "Error: can't read grammar file '" << ::Grammar + << "': " << EC.message() << "\n"; + std::exit(1); + } + std::vector Diags; + auto G = Grammar::parseBNF(GrammarText->get()->getBuffer(), Diags); + for (const auto &Diag : Diags) + llvm::errs() << Diag << "\n"; + auto Table = LRTable::buildSLR(G); + return new Language{ + std::move(G), + std::move(Table), + llvm::DenseMap(), + llvm::DenseMap(), + }; + }(); + return *Lang; +} + +} // namespace pseudo +} // namespace clang diff --git a/clang-tools-extra/pseudo/lib/cli/CMakeLists.txt b/clang-tools-extra/pseudo/lib/cli/CMakeLists.txt new file mode 100644 index 0000000000000..68e644f62fded --- /dev/null +++ b/clang-tools-extra/pseudo/lib/cli/CMakeLists.txt @@ -0,0 +1,15 @@ +set(LLVM_LINK_COMPONENTS + Support + ) + +add_clang_library(clangPseudoCLI + CLI.cpp + + # FIXME export the headers from clangPseudoCXX instead + DEPENDS + cxx_gen + + LINK_LIBS + clangPseudoGrammar + clangPseudoCXX + ) diff --git a/clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt b/clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt new file mode 100644 index 0000000000000..2fecdce6a10f9 --- /dev/null +++ b/clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt @@ -0,0 +1,19 @@ +set(LLVM_LINK_COMPONENTS + Support + ) + +add_clang_library(clangPseudoCXX + CXX.cpp + + DEPENDS + cxx_gen + + LINK_LIBS + clangPseudo + clangPseudoGrammar + ) + +clang_target_link_libraries(clangPseudoCXX + PRIVATE + clangBasic + ) diff --git a/clang-tools-extra/pseudo/lib/cxx/CXX.cpp b/clang-tools-extra/pseudo/lib/cxx/CXX.cpp new file mode 100644 index 0000000000000..4188dab31d3a9 --- /dev/null +++ b/clang-tools-extra/pseudo/lib/cxx/CXX.cpp @@ -0,0 +1,452 @@ +//===--- CXX.cpp - Define public interfaces for C++ grammar ---------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/cxx/CXX.h" +#include "clang-pseudo/Forest.h" +#include "clang-pseudo/Language.h" +#include "clang-pseudo/grammar/Grammar.h" +#include "clang-pseudo/grammar/LRTable.h" +#include "clang/Basic/CharInfo.h" +#include "clang/Basic/TokenKinds.h" +#include "llvm/ADT/StringSwitch.h" +#include "llvm/Support/Debug.h" +#include +#define DEBUG_TYPE "CXX.cpp" + +namespace clang { +namespace pseudo { +namespace cxx { +namespace { +static const char *CXXBNF = +#include "CXXBNF.inc" + ; + +// User-defined string literals look like `""suffix`. +bool isStringUserDefined(const Token &Tok) { + return !Tok.text().ends_with("\""); +} +bool isCharUserDefined(const Token &Tok) { return !Tok.text().ends_with("'"); } + +// Combinable flags describing numbers. +// Clang has just one numeric_token kind, the grammar has 4. +enum NumericKind { + Integer = 0, + Floating = 1 << 0, + UserDefined = 1 << 1, +}; +// Determine the kind of numeric_constant we have. +// We can assume it's something valid, as it has been lexed. +// FIXME: is this expensive enough that we should set flags on the token +// and reuse them rather than computing it for each guard? +unsigned numKind(const Token &Tok) { + assert(Tok.Kind == tok::numeric_constant); + llvm::StringRef Text = Tok.text(); + if (Text.size() <= 1) + return Integer; + bool Hex = + Text.size() > 2 && Text[0] == '0' && (Text[1] == 'x' || Text[1] == 'X'); + uint8_t K = Integer; + + for (char C : Text) { + switch (C) { + case '.': + K |= Floating; + break; + case 'e': + case 'E': + if (!Hex) + K |= Floating; + break; + case 'p': + case 'P': + if (Hex) + K |= Floating; + break; + case '_': + K |= UserDefined; + break; + default: + break; + } + } + + // We would be done here, but there are stdlib UDLs that lack _. + // We must distinguish these from the builtin suffixes. + unsigned LastLetter = Text.size(); + while (LastLetter > 0 && isLetter(Text[LastLetter - 1])) + --LastLetter; + if (LastLetter == Text.size()) // Common case + return NumericKind(K); + // Trailing d/e/f are not part of the suffix in hex numbers. + while (Hex && LastLetter < Text.size() && isHexDigit(Text[LastLetter])) + ++LastLetter; + return llvm::StringSwitch(Text.substr(LastLetter)) + // std::chrono + .Cases("h", "min", "s", "ms", "us", "ns", "d", "y", K | UserDefined) + // complex + .Cases("il", "i", "if", K | UserDefined) + .Default(K); +} + +// RHS is expected to contain a single terminal. +// Returns the corresponding token. +const Token &onlyToken(tok::TokenKind Kind, + const ArrayRef RHS, + const TokenStream &Tokens) { + assert(RHS.size() == 1 && RHS.front()->symbol() == tokenSymbol(Kind)); + return Tokens.tokens()[RHS.front()->startTokenIndex()]; +} +// RHS is expected to contain a single symbol. +// Returns the corresponding ForestNode. +const ForestNode &onlySymbol(SymbolID Kind, + const ArrayRef RHS, + const TokenStream &Tokens) { + assert(RHS.size() == 1 && RHS.front()->symbol() == Kind); + return *RHS.front(); +} + +bool isFunctionDeclarator(const ForestNode *Declarator) { + assert(Declarator->symbol() == cxx::Symbol::declarator); + bool IsFunction = false; + while (true) { + // not well-formed code, return the best guess. + if (Declarator->kind() != ForestNode::Sequence) + return IsFunction; + + switch (Declarator->rule()) { + case rule::noptr_declarator::declarator_id: // reached the bottom + return IsFunction; + // *X is a nonfunction (unless X is a function). + case rule::ptr_declarator::ptr_operator__ptr_declarator: + Declarator = Declarator->elements()[1]; + IsFunction = false; + continue; + // X() is a function (unless X is a pointer or similar). + case rule::declarator:: + noptr_declarator__parameters_and_qualifiers__trailing_return_type: + case rule::noptr_declarator::noptr_declarator__parameters_and_qualifiers: + Declarator = Declarator->elements()[0]; + IsFunction = true; + continue; + // X[] is an array (unless X is a pointer or function). + case rule::noptr_declarator:: + noptr_declarator__L_SQUARE__constant_expression__R_SQUARE: + case rule::noptr_declarator::noptr_declarator__L_SQUARE__R_SQUARE: + Declarator = Declarator->elements()[0]; + IsFunction = false; + continue; + // (X) is whatever X is. + case rule::noptr_declarator::L_PAREN__ptr_declarator__R_PAREN: + Declarator = Declarator->elements()[1]; + continue; + case rule::ptr_declarator::noptr_declarator: + case rule::declarator::ptr_declarator: + Declarator = Declarator->elements()[0]; + continue; + + default: + assert(false && "unhandled declarator for IsFunction"); + return IsFunction; + } + } + llvm_unreachable("unreachable"); +} + +bool guardNextTokenNotElse(const GuardParams &P) { + return symbolToToken(P.Lookahead) != tok::kw_else; +} + +bool specifiesStructuredBinding(const GuardParams &P) { + const auto DSS = P.RHS[0]; + assert(DSS->symbol() == Symbol::decl_specifier_seq); + + auto Length = P.RHS[1]->startTokenIndex() - DSS->startTokenIndex(); + for (const auto &T : + P.Tokens.tokens().slice(DSS->startTokenIndex(), Length)) { + switch (T.Kind) { + case clang::tok::kw_static: + case clang::tok::kw_thread_local: + case clang::tok::kw_auto: + case clang::tok::kw_const: + case clang::tok::kw_volatile: + break; + default: + return false; + } + } + return true; +} + +// Whether this e.g. decl-specifier contains an "exclusive" type such as a class +// name, and thus can't combine with a second exclusive type. +// +// Returns false for +// - non-types +// - "unsigned" etc that may suffice as types but may modify others +// - cases of uncertainty (e.g. due to ambiguity) +bool hasExclusiveType(const ForestNode *N) { + // FIXME: every time we apply this check, we walk the whole subtree. + // Add per-node caching instead. + while (true) { + assert(N->symbol() == Symbol::decl_specifier_seq || + N->symbol() == Symbol::type_specifier_seq || + N->symbol() == Symbol::defining_type_specifier_seq || + N->symbol() == Symbol::decl_specifier || + N->symbol() == Symbol::type_specifier || + N->symbol() == Symbol::defining_type_specifier || + N->symbol() == Symbol::simple_type_specifier); + if (N->kind() == ForestNode::Opaque) + return false; // conservative + if (N->kind() == ForestNode::Ambiguous) + return llvm::all_of(N->alternatives(), hasExclusiveType); // conservative + // All supported symbols are nonterminals. + assert(N->kind() == ForestNode::Sequence); + switch (N->rule()) { + // seq := element seq: check element then continue into seq + case rule::decl_specifier_seq::decl_specifier__decl_specifier_seq: + case rule::defining_type_specifier_seq::defining_type_specifier__defining_type_specifier_seq: + case rule::type_specifier_seq::type_specifier__type_specifier_seq: + if (hasExclusiveType(N->children()[0])) + return true; + N = N->children()[1]; + continue; + // seq := element: continue into element + case rule::decl_specifier_seq::decl_specifier: + case rule::type_specifier_seq::type_specifier: + case rule::defining_type_specifier_seq::defining_type_specifier: + N = N->children()[0]; + continue; + + // defining-type-specifier + case rule::defining_type_specifier::type_specifier: + N = N->children()[0]; + continue; + case rule::defining_type_specifier::class_specifier: + case rule::defining_type_specifier::enum_specifier: + return true; + + // decl-specifier + case rule::decl_specifier::defining_type_specifier: + N = N->children()[0]; + continue; + case rule::decl_specifier::CONSTEVAL: + case rule::decl_specifier::CONSTEXPR: + case rule::decl_specifier::CONSTINIT: + case rule::decl_specifier::INLINE: + case rule::decl_specifier::FRIEND: + case rule::decl_specifier::storage_class_specifier: + case rule::decl_specifier::TYPEDEF: + case rule::decl_specifier::function_specifier: + return false; + + // type-specifier + case rule::type_specifier::elaborated_type_specifier: + case rule::type_specifier::typename_specifier: + return true; + case rule::type_specifier::simple_type_specifier: + N = N->children()[0]; + continue; + case rule::type_specifier::cv_qualifier: + return false; + + // simple-type-specifier + case rule::simple_type_specifier::type_name: + case rule::simple_type_specifier::template_name: + case rule::simple_type_specifier::builtin_type: + case rule::simple_type_specifier::nested_name_specifier__TEMPLATE__simple_template_id: + case rule::simple_type_specifier::nested_name_specifier__template_name: + case rule::simple_type_specifier::nested_name_specifier__type_name: + case rule::simple_type_specifier::decltype_specifier: + case rule::simple_type_specifier::placeholder_type_specifier: + return true; + case rule::simple_type_specifier::LONG: + case rule::simple_type_specifier::SHORT: + case rule::simple_type_specifier::SIGNED: + case rule::simple_type_specifier::UNSIGNED: + return false; + + default: + LLVM_DEBUG(llvm::errs() << "Unhandled rule " << N->rule() << "\n"); + llvm_unreachable("hasExclusiveType be exhaustive!"); + } + } +} + +llvm::DenseMap buildGuards() { +#define GUARD(cond) \ + { \ + [](const GuardParams &P) { return cond; } \ + } +#define TOKEN_GUARD(kind, cond) \ + [](const GuardParams& P) { \ + const Token &Tok = onlyToken(tok::kind, P.RHS, P.Tokens); \ + return cond; \ + } +#define SYMBOL_GUARD(kind, cond) \ + [](const GuardParams& P) { \ + const ForestNode &N = onlySymbol(Symbol::kind, P.RHS, P.Tokens); \ + return cond; \ + } + return { + {rule::function_declarator::declarator, + SYMBOL_GUARD(declarator, isFunctionDeclarator(&N))}, + {rule::non_function_declarator::declarator, + SYMBOL_GUARD(declarator, !isFunctionDeclarator(&N))}, + + // A {decl,type,defining-type}-specifier-sequence cannot have multiple + // "exclusive" types (like class names): a value has only one type. + {rule::defining_type_specifier_seq:: + defining_type_specifier__defining_type_specifier_seq, + GUARD(!hasExclusiveType(P.RHS[0]) || !hasExclusiveType(P.RHS[1]))}, + {rule::type_specifier_seq::type_specifier__type_specifier_seq, + GUARD(!hasExclusiveType(P.RHS[0]) || !hasExclusiveType(P.RHS[1]))}, + {rule::decl_specifier_seq::decl_specifier__decl_specifier_seq, + GUARD(!hasExclusiveType(P.RHS[0]) || !hasExclusiveType(P.RHS[1]))}, + + {rule::contextual_override::IDENTIFIER, + TOKEN_GUARD(identifier, Tok.text() == "override")}, + {rule::contextual_final::IDENTIFIER, + TOKEN_GUARD(identifier, Tok.text() == "final")}, + {rule::import_keyword::IDENTIFIER, + TOKEN_GUARD(identifier, Tok.text() == "import")}, + {rule::export_keyword::IDENTIFIER, + TOKEN_GUARD(identifier, Tok.text() == "export")}, + {rule::module_keyword::IDENTIFIER, + TOKEN_GUARD(identifier, Tok.text() == "module")}, + {rule::contextual_zero::NUMERIC_CONSTANT, + TOKEN_GUARD(numeric_constant, Tok.text() == "0")}, + + {rule::selection_statement::IF__L_PAREN__condition__R_PAREN__statement, + guardNextTokenNotElse}, + {rule::selection_statement:: + IF__L_PAREN__init_statement__condition__R_PAREN__statement, + guardNextTokenNotElse}, + {rule::selection_statement:: + IF__CONSTEXPR__L_PAREN__condition__R_PAREN__statement, + guardNextTokenNotElse}, + {rule::selection_statement:: + IF__CONSTEXPR__L_PAREN__init_statement__condition__R_PAREN__statement, + guardNextTokenNotElse}, + + // Implement C++ [basic.lookup.qual.general]: + // If a name, template-id, or decltype-specifier is followed by a + // ​::​, it shall designate a namespace, class, enumeration, or + // dependent type, and the ​::​ is never interpreted as a complete + // nested-name-specifier. + {rule::nested_name_specifier::COLONCOLON, + TOKEN_GUARD(coloncolon, Tok.prev().Kind != tok::identifier)}, + + // Implement C++ [dcl.pre#6]: + // A simple-declaration with an identifier-list is called a structured + // binding declaration ([dcl.struct.bind]). If the decl-specifier-seq + // contains any decl-specifier other than static, thread_­local, auto, + // or cv-qualifiers, the program is ill-formed. + {rule::simple_declaration:: + decl_specifier_seq__ref_qualifier__L_SQUARE__identifier_list__R_SQUARE__initializer__SEMI, + specifiesStructuredBinding}, + {rule::simple_declaration:: + decl_specifier_seq__L_SQUARE__identifier_list__R_SQUARE__initializer__SEMI, + specifiesStructuredBinding}, + + // The grammar distinguishes (only) user-defined vs plain string literals, + // where the clang lexer distinguishes (only) encoding types. + {rule::user_defined_string_literal_chunk::STRING_LITERAL, + TOKEN_GUARD(string_literal, isStringUserDefined(Tok))}, + {rule::user_defined_string_literal_chunk::UTF8_STRING_LITERAL, + TOKEN_GUARD(utf8_string_literal, isStringUserDefined(Tok))}, + {rule::user_defined_string_literal_chunk::UTF16_STRING_LITERAL, + TOKEN_GUARD(utf16_string_literal, isStringUserDefined(Tok))}, + {rule::user_defined_string_literal_chunk::UTF32_STRING_LITERAL, + TOKEN_GUARD(utf32_string_literal, isStringUserDefined(Tok))}, + {rule::user_defined_string_literal_chunk::WIDE_STRING_LITERAL, + TOKEN_GUARD(wide_string_literal, isStringUserDefined(Tok))}, + {rule::string_literal_chunk::STRING_LITERAL, + TOKEN_GUARD(string_literal, !isStringUserDefined(Tok))}, + {rule::string_literal_chunk::UTF8_STRING_LITERAL, + TOKEN_GUARD(utf8_string_literal, !isStringUserDefined(Tok))}, + {rule::string_literal_chunk::UTF16_STRING_LITERAL, + TOKEN_GUARD(utf16_string_literal, !isStringUserDefined(Tok))}, + {rule::string_literal_chunk::UTF32_STRING_LITERAL, + TOKEN_GUARD(utf32_string_literal, !isStringUserDefined(Tok))}, + {rule::string_literal_chunk::WIDE_STRING_LITERAL, + TOKEN_GUARD(wide_string_literal, !isStringUserDefined(Tok))}, + // And the same for chars. + {rule::user_defined_character_literal::CHAR_CONSTANT, + TOKEN_GUARD(char_constant, isCharUserDefined(Tok))}, + {rule::user_defined_character_literal::UTF8_CHAR_CONSTANT, + TOKEN_GUARD(utf8_char_constant, isCharUserDefined(Tok))}, + {rule::user_defined_character_literal::UTF16_CHAR_CONSTANT, + TOKEN_GUARD(utf16_char_constant, isCharUserDefined(Tok))}, + {rule::user_defined_character_literal::UTF32_CHAR_CONSTANT, + TOKEN_GUARD(utf32_char_constant, isCharUserDefined(Tok))}, + {rule::user_defined_character_literal::WIDE_CHAR_CONSTANT, + TOKEN_GUARD(wide_char_constant, isCharUserDefined(Tok))}, + {rule::character_literal::CHAR_CONSTANT, + TOKEN_GUARD(char_constant, !isCharUserDefined(Tok))}, + {rule::character_literal::UTF8_CHAR_CONSTANT, + TOKEN_GUARD(utf8_char_constant, !isCharUserDefined(Tok))}, + {rule::character_literal::UTF16_CHAR_CONSTANT, + TOKEN_GUARD(utf16_char_constant, !isCharUserDefined(Tok))}, + {rule::character_literal::UTF32_CHAR_CONSTANT, + TOKEN_GUARD(utf32_char_constant, !isCharUserDefined(Tok))}, + {rule::character_literal::WIDE_CHAR_CONSTANT, + TOKEN_GUARD(wide_char_constant, !isCharUserDefined(Tok))}, + // clang just has one NUMERIC_CONSTANT token for {ud,plain}x{float,int} + {rule::user_defined_integer_literal::NUMERIC_CONSTANT, + TOKEN_GUARD(numeric_constant, numKind(Tok) == (Integer | UserDefined))}, + {rule::user_defined_floating_point_literal::NUMERIC_CONSTANT, + TOKEN_GUARD(numeric_constant, numKind(Tok) == (Floating | UserDefined))}, + {rule::integer_literal::NUMERIC_CONSTANT, + TOKEN_GUARD(numeric_constant, numKind(Tok) == Integer)}, + {rule::floating_point_literal::NUMERIC_CONSTANT, + TOKEN_GUARD(numeric_constant, numKind(Tok) == Floating)}, + }; +#undef TOKEN_GUARD +#undef SYMBOL_GUARD +} + +Token::Index recoverBrackets(Token::Index Begin, const TokenStream &Tokens) { + assert(Begin > 0); + const Token &Left = Tokens.tokens()[Begin - 1]; + assert(Left.Kind == tok::l_brace || Left.Kind == tok::l_paren || + Left.Kind == tok::l_square); + if (const Token *Right = Left.pair()) { + assert(Tokens.index(*Right) > Begin - 1); + return Tokens.index(*Right); + } + return Token::Invalid; +} + +llvm::DenseMap buildRecoveryStrategies() { + return { + {Extension::Brackets, recoverBrackets}, + }; +} + +} // namespace + +const Language &getLanguage() { + static const auto &CXXLanguage = []() -> const Language & { + std::vector Diags; + auto G = Grammar::parseBNF(CXXBNF, Diags); + assert(Diags.empty()); + LRTable Table = LRTable::buildSLR(G); + const Language *PL = new Language{ + std::move(G), + std::move(Table), + buildGuards(), + buildRecoveryStrategies(), + }; + return *PL; + }(); + return CXXLanguage; +} + +} // namespace cxx +} // namespace pseudo +} // namespace clang diff --git a/clang-tools-extra/pseudo/lib/cxx/cxx.bnf b/clang-tools-extra/pseudo/lib/cxx/cxx.bnf new file mode 100644 index 0000000000000..36caf7b1e6337 --- /dev/null +++ b/clang-tools-extra/pseudo/lib/cxx/cxx.bnf @@ -0,0 +1,776 @@ +# This is a C++ grammar from the C++ standard [1]. +# +# The grammar is a superset of the true grammar requring semantic constraints to +# resolve ambiguities. The grammar is context-free and ambiguous (beyond the +# limit of LR(k)). We use general parsing algorithm (e.g GLR) to handle the +# grammar and generate a transition table which is used to drive the parsing. +# +# It aims to align with the ISO C++ grammar as much as possible. We adjust it +# to fit the need for the grammar-based parser: +# - attributes are omitted, which will be handled as comments; +# - we don't allow nullable nonterminal symbols. There are few nullable +# nonterminals in the spec grammar, they are adjusted to be non-nullable; +# - the file merely describes the core C++ grammar. Preprocessor directives and +# lexical conversions are omitted as we reuse clang's lexer and run a fake +# preprocessor; +# - grammar rules with the >> token are adjusted, the greatergreater token is +# split into two > tokens, to make the GLR parser aware of nested templates +# and right shift operator; +# +# Guidelines: +# - nonterminals are lower_case; terminals (aka tokens) correspond to +# clang::TokenKind, written as "IDENTIFIER", "USING", "::" etc; +# - optional symbols are supported, with a _opt suffix; +# +# [1] https://isocpp.org/files/papers/N4860.pdf + +# _ lists all the start-symbols which we support parsing. +# +# We list important nonterminals as start symbols, rather than doing it for all +# nonterminals by default, this reduces the number of states by 30% and LRTable +# actions by 16%. +_ := translation-unit EOF +_ := statement-seq EOF +_ := declaration-seq EOF + +# gram.key +#! we don't distinguish between namespaces and namespace aliases, as it's hard +#! and uninteresting. +namespace-name := IDENTIFIER +template-name := IDENTIFIER + +# gram.basic +#! Custom modifications to eliminate optional declaration-seq +translation-unit := declaration-seq +translation-unit := global-module-fragment_opt module-declaration declaration-seq_opt private-module-fragment_opt + +# gram.expr +# expr.prim +primary-expression := literal +primary-expression := THIS +primary-expression := ( expression ) +primary-expression := id-expression +primary-expression := lambda-expression +primary-expression := fold-expression +primary-expression := requires-expression +id-expression := unqualified-id +id-expression := qualified-id +unqualified-id := IDENTIFIER +unqualified-id := operator-function-id +unqualified-id := conversion-function-id +unqualified-id := literal-operator-id +unqualified-id := ~ type-name +unqualified-id := ~ decltype-specifier +unqualified-id := template-id +qualified-id := nested-name-specifier TEMPLATE_opt unqualified-id +nested-name-specifier := :: [guard] +nested-name-specifier := type-name :: +nested-name-specifier := namespace-name :: +nested-name-specifier := decltype-specifier :: +nested-name-specifier := nested-name-specifier IDENTIFIER :: +nested-name-specifier := nested-name-specifier TEMPLATE_opt simple-template-id :: +lambda-expression := lambda-introducer lambda-declarator_opt compound-statement +lambda-expression := lambda-introducer < template-parameter-list > requires-clause_opt lambda-declarator_opt compound-statement +#! We allow a capture-default to appear anywhere in a capture-list. +# This simplifies the grammar and error recovery. +lambda-introducer := [ capture-list_opt ] +lambda-declarator := ( parameter-declaration-clause_opt ) decl-specifier-seq_opt noexcept-specifier_opt trailing-return-type_opt requires-clause_opt +capture-list := capture +capture-list := capture-list , capture +capture := capture-default +capture := simple-capture +capture := init-capture +capture-default := & +capture-default := = +simple-capture := IDENTIFIER ..._opt +simple-capture := & IDENTIFIER ..._opt +simple-capture := THIS +simple-capture := * THIS +init-capture := ..._opt IDENTIFIER initializer +init-capture := & ..._opt IDENTIFIER initializer +fold-expression := ( cast-expression fold-operator ... ) +fold-expression := ( ... fold-operator cast-expression ) +fold-expression := ( cast-expression fold-operator ... fold-operator cast-expression ) +fold-operator := + +fold-operator := - +fold-operator := * +fold-operator := / +fold-operator := % +fold-operator := ^ +fold-operator := | +fold-operator := << +fold-operator := greatergreater +fold-operator := += +fold-operator := -= +fold-operator := *= +fold-operator := /= +fold-operator := %= +fold-operator := ^= +fold-operator := &= +fold-operator := |= +fold-operator := <<= +fold-operator := >>= +fold-operator := = +fold-operator := == +fold-operator := != +fold-operator := < +fold-operator := > +fold-operator := <= +fold-operator := >= +fold-operator := && +fold-operator := || +fold-operator := , +fold-operator := .* +fold-operator := ->* +requires-expression := REQUIRES requirement-parameter-list_opt requirement-body +requirement-parameter-list := ( parameter-declaration-clause_opt ) +requirement-body := { requirement-seq } +requirement-seq := requirement +requirement-seq := requirement-seq requirement +requirement := simple-requirement +requirement := type-requirement +requirement := compound-requirement +requirement := nested-requirement +simple-requirement := expression ; +type-requirement := TYPENAME nested-name-specifier_opt type-name ; +compound-requirement := { expression } NOEXCEPT_opt return-type-requirement_opt ; +return-type-requirement := -> type-constraint +nested-requirement := REQUIRES constraint-expression ; +# expr.post +postfix-expression := primary-expression +postfix-expression := postfix-expression [ expr-or-braced-init-list ] +postfix-expression := postfix-expression ( expression-list_opt ) +postfix-expression := simple-type-specifier ( expression-list_opt ) +postfix-expression := typename-specifier ( expression-list_opt ) +postfix-expression := simple-type-specifier braced-init-list +postfix-expression := postfix-expression . TEMPLATE_opt id-expression +postfix-expression := postfix-expression -> TEMPLATE_opt id-expression +postfix-expression := postfix-expression ++ +postfix-expression := postfix-expression -- +postfix-expression := DYNAMIC_CAST < type-id > ( expression ) +postfix-expression := STATIC_CAST < type-id > ( expression ) +postfix-expression := REINTERPRET_CAST < type-id > ( expression ) +postfix-expression := CONST_CAST < type-id > ( expression ) +postfix-expression := TYPEID ( expression ) +postfix-expression := TYPEID ( type-id ) +#! Standard defines expression-list in terms of initializer-list, but our +# initializer-list allows designators. +expression-list := initializer-clause ..._opt +expression-list := expression-list , initializer-clause ..._opt +# expr.unary +unary-expression := postfix-expression +unary-expression := unary-operator cast-expression +unary-expression := ++ cast-expression +unary-expression := -- cast-expression +unary-expression := await-expression +unary-expression := SIZEOF unary-expression +unary-expression := SIZEOF ( type-id ) +unary-expression := SIZEOF ... ( IDENTIFIER ) +unary-expression := ALIGNOF ( type-id ) +unary-expression := noexcept-expression +unary-expression := new-expression +unary-expression := delete-expression +unary-operator := * +unary-operator := & +unary-operator := + +unary-operator := - +unary-operator := ! +unary-operator := ~ +await-expression := CO_AWAIT cast-expression +noexcept-expression := NOEXCEPT ( expression ) +new-expression := ::_opt NEW new-placement_opt new-type-id new-initializer_opt +new-expression := ::_opt NEW new-placement_opt ( type-id ) new-initializer_opt +new-placement := ( expression-list ) +new-type-id := type-specifier-seq new-declarator_opt +new-declarator := ptr-operator new-declarator_opt +new-declarator := noptr-new-declarator +noptr-new-declarator := [ expression_opt ] +noptr-new-declarator := noptr-new-declarator [ constant-expression ] +new-initializer := ( expression-list_opt ) +new-initializer := braced-init-list +delete-expression := ::_opt DELETE cast-expression +delete-expression := ::_opt DELETE [ ] cast-expression +cast-expression := unary-expression +cast-expression := ( type-id ) cast-expression +# expr.mptr.oper +pm-expression := cast-expression +pm-expression := pm-expression .* cast-expression +pm-expression := pm-expression ->* cast-expression +# expr.mul +multiplicative-expression := pm-expression +multiplicative-expression := multiplicative-expression * pm-expression +multiplicative-expression := multiplicative-expression / pm-expression +multiplicative-expression := multiplicative-expression % pm-expression +# expr.add +additive-expression := multiplicative-expression +additive-expression := additive-expression + multiplicative-expression +additive-expression := additive-expression - multiplicative-expression +# expr.shift +shift-expression := additive-expression +shift-expression := shift-expression << additive-expression +shift-expression := shift-expression greatergreater additive-expression +# expr.spaceship +compare-expression := shift-expression +compare-expression := compare-expression <=> shift-expression +# expr.rel +relational-expression := compare-expression +relational-expression := relational-expression < compare-expression +relational-expression := relational-expression > compare-expression +relational-expression := relational-expression <= compare-expression +relational-expression := relational-expression >= compare-expression +# expr.eq +equality-expression := relational-expression +equality-expression := equality-expression == relational-expression +equality-expression := equality-expression != relational-expression +# expr.bit.and +and-expression := equality-expression +and-expression := and-expression & equality-expression +# expr.xor +exclusive-or-expression := and-expression +exclusive-or-expression := exclusive-or-expression ^ and-expression +# expr.or +inclusive-or-expression := exclusive-or-expression +inclusive-or-expression := inclusive-or-expression | exclusive-or-expression +# expr.log.and +logical-and-expression := inclusive-or-expression +logical-and-expression := logical-and-expression && inclusive-or-expression +# expr.log.or +logical-or-expression := logical-and-expression +logical-or-expression := logical-or-expression || logical-and-expression +# expr.cond +conditional-expression := logical-or-expression +conditional-expression := logical-or-expression ? expression : assignment-expression +# expr.ass +yield-expression := CO_YIELD assignment-expression +yield-expression := CO_YIELD braced-init-list +throw-expression := THROW assignment-expression_opt +assignment-expression := conditional-expression +assignment-expression := yield-expression +assignment-expression := throw-expression +assignment-expression := logical-or-expression assignment-operator initializer-clause +assignment-operator := = +assignment-operator := *= +assignment-operator := /= +assignment-operator := %= +assignment-operator := += +assignment-operator := -= +assignment-operator := >>= +assignment-operator := <<= +assignment-operator := &= +assignment-operator := ^= +assignment-operator := |= +# expr.comma +expression := assignment-expression +expression := expression , assignment-expression +# expr.const +constant-expression := conditional-expression + +# gram.stmt +statement := labeled-statement +statement := expression-statement +statement := compound-statement +statement := selection-statement +statement := iteration-statement +statement := jump-statement +statement := declaration-statement +statement := try-block +init-statement := expression-statement +init-statement := simple-declaration +condition := expression +condition := decl-specifier-seq declarator brace-or-equal-initializer +labeled-statement := IDENTIFIER : statement +labeled-statement := CASE constant-expression : statement +labeled-statement := DEFAULT : statement +expression-statement := expression_opt ; +compound-statement := { statement-seq_opt [recover=Brackets] } +statement-seq := statement +statement-seq := statement-seq statement +selection-statement := IF CONSTEXPR_opt ( init-statement_opt condition ) statement [guard] +selection-statement := IF CONSTEXPR_opt ( init-statement_opt condition ) statement ELSE statement +selection-statement := SWITCH ( init-statement_opt condition ) statement +iteration-statement := WHILE ( condition ) statement +iteration-statement := DO statement WHILE ( expression ) ; +iteration-statement := FOR ( init-statement condition_opt ; expression_opt ) statement +iteration-statement := FOR ( init-statement_opt for-range-declaration : for-range-initializer ) statement +for-range-declaration := decl-specifier-seq declarator +for-range-declaration := decl-specifier-seq ref-qualifier_opt [ identifier-list ] +for-range-initializer := expr-or-braced-init-list +jump-statement := BREAK ; +jump-statement := CONTINUE ; +jump-statement := RETURN expr-or-braced-init-list_opt ; +jump-statement := coroutine-return-statement +jump-statement := GOTO IDENTIFIER ; +coroutine-return-statement := CO_RETURN expr-or-braced-init-list_opt ; +declaration-statement := block-declaration + +# gram.dcl +declaration-seq := declaration +declaration-seq := declaration-seq declaration +declaration := block-declaration +declaration := nodeclspec-function-declaration +declaration := function-definition +declaration := template-declaration +declaration := deduction-guide +declaration := explicit-instantiation +declaration := explicit-specialization +declaration := export-declaration +declaration := linkage-specification +declaration := namespace-definition +declaration := empty-declaration +declaration := module-import-declaration +block-declaration := simple-declaration +block-declaration := asm-declaration +block-declaration := namespace-alias-definition +block-declaration := using-declaration +block-declaration := using-enum-declaration +block-declaration := using-directive +block-declaration := static_assert-declaration +block-declaration := alias-declaration +block-declaration := opaque-enum-declaration +nodeclspec-function-declaration := function-declarator ; +alias-declaration := USING IDENTIFIER = defining-type-id ; +simple-declaration := decl-specifier-seq init-declarator-list_opt ; +simple-declaration := decl-specifier-seq ref-qualifier_opt [ identifier-list ] initializer ; [guard] +static_assert-declaration := STATIC_ASSERT ( constant-expression ) ; +static_assert-declaration := STATIC_ASSERT ( constant-expression , string-literal ) ; +empty-declaration := ; +# dcl.spec +decl-specifier := storage-class-specifier +decl-specifier := defining-type-specifier +decl-specifier := function-specifier +decl-specifier := FRIEND +decl-specifier := TYPEDEF +decl-specifier := CONSTEXPR +decl-specifier := CONSTEVAL +decl-specifier := CONSTINIT +decl-specifier := INLINE +decl-specifier-seq := decl-specifier +decl-specifier-seq := decl-specifier decl-specifier-seq [guard] +storage-class-specifier := STATIC +storage-class-specifier := THREAD_LOCAL +storage-class-specifier := EXTERN +storage-class-specifier := MUTABLE +function-specifier := VIRTUAL +function-specifier := explicit-specifier +explicit-specifier := EXPLICIT ( constant-expression ) +explicit-specifier := EXPLICIT +type-specifier := simple-type-specifier +type-specifier := elaborated-type-specifier +type-specifier := typename-specifier +type-specifier := cv-qualifier +type-specifier-seq := type-specifier +type-specifier-seq := type-specifier type-specifier-seq [guard] +defining-type-specifier := type-specifier +defining-type-specifier := class-specifier +defining-type-specifier := enum-specifier +defining-type-specifier-seq := defining-type-specifier +defining-type-specifier-seq := defining-type-specifier defining-type-specifier-seq [guard] +simple-type-specifier := nested-name-specifier_opt type-name +simple-type-specifier := nested-name-specifier TEMPLATE simple-template-id +simple-type-specifier := decltype-specifier +simple-type-specifier := placeholder-type-specifier +simple-type-specifier := nested-name-specifier_opt template-name +simple-type-specifier := SHORT +simple-type-specifier := LONG +simple-type-specifier := SIGNED +simple-type-specifier := UNSIGNED +simple-type-specifier := builtin-type +#! builtin-type added to aid in classifying which specifiers may combined. +builtin-type := CHAR +builtin-type := CHAR8_T +builtin-type := CHAR16_T +builtin-type := CHAR32_T +builtin-type := WCHAR_T +builtin-type := BOOL +builtin-type := INT +builtin-type := FLOAT +builtin-type := DOUBLE +builtin-type := VOID +#! Unlike C++ standard grammar, we don't distinguish the underlying type (class, +#! enum, typedef) of the IDENTIFIER, as these ambiguities are "local" and don't +#! affect the final parse tree. Eliminating them gives a significant performance +#! boost to the parser. +type-name := IDENTIFIER +type-name := simple-template-id +elaborated-type-specifier := class-key nested-name-specifier_opt IDENTIFIER +elaborated-type-specifier := class-key simple-template-id +elaborated-type-specifier := class-key nested-name-specifier TEMPLATE_opt simple-template-id +elaborated-type-specifier := elaborated-enum-specifier +elaborated-enum-specifier := ENUM nested-name-specifier_opt IDENTIFIER +decltype-specifier := DECLTYPE ( expression ) +placeholder-type-specifier := type-constraint_opt AUTO +placeholder-type-specifier := type-constraint_opt DECLTYPE ( AUTO ) +init-declarator-list := init-declarator +init-declarator-list := init-declarator-list , init-declarator +#! The standard grammar allows: +#! 1) an initializer with any declarator, including a function declarator, this +#! creates an ambiguity where a function definition is misparsed as a simple +#! declaration; +#! 2) an function-body with any declarator, includeing a non-function +#! declarator, this creates an ambiguity whwere a simple-declaration is +#! misparsed as a function-definition; +#! We extend the standard declarator to function-declarator and non-function-declarator +#! to eliminate these false parses. +init-declarator := non-function-declarator initializer_opt +init-declarator := function-declarator requires-clause_opt +function-declarator := declarator [guard] +non-function-declarator := declarator [guard] +declarator := ptr-declarator +declarator := noptr-declarator parameters-and-qualifiers trailing-return-type +ptr-declarator := noptr-declarator +ptr-declarator := ptr-operator ptr-declarator +noptr-declarator := declarator-id +noptr-declarator := noptr-declarator parameters-and-qualifiers +noptr-declarator := noptr-declarator [ constant-expression_opt ] +noptr-declarator := ( ptr-declarator ) +parameters-and-qualifiers := ( parameter-declaration-clause_opt [recover=Brackets] ) cv-qualifier-seq_opt ref-qualifier_opt noexcept-specifier_opt +trailing-return-type := -> type-id +ptr-operator := * cv-qualifier-seq_opt +ptr-operator := & +ptr-operator := && +ptr-operator := nested-name-specifier * cv-qualifier-seq_opt +cv-qualifier-seq := cv-qualifier cv-qualifier-seq_opt +cv-qualifier := CONST +cv-qualifier := VOLATILE +ref-qualifier := & +ref-qualifier := && +declarator-id := ..._opt id-expression +type-id := type-specifier-seq abstract-declarator_opt +defining-type-id := defining-type-specifier-seq abstract-declarator_opt +abstract-declarator := ptr-abstract-declarator +abstract-declarator := noptr-abstract-declarator_opt parameters-and-qualifiers trailing-return-type +abstract-declarator := abstract-pack-declarator +ptr-abstract-declarator := noptr-abstract-declarator +ptr-abstract-declarator := ptr-operator ptr-abstract-declarator_opt +noptr-abstract-declarator := noptr-abstract-declarator_opt parameters-and-qualifiers +noptr-abstract-declarator := noptr-abstract-declarator_opt [ constant-expression_opt ] +noptr-abstract-declarator := ( ptr-abstract-declarator ) +abstract-pack-declarator := noptr-abstract-pack-declarator +abstract-pack-declarator := ptr-operator abstract-pack-declarator +noptr-abstract-pack-declarator := noptr-abstract-pack-declarator parameters-and-qualifiers +noptr-abstract-pack-declarator := noptr-abstract-pack-declarator [ constant-expression_opt ] +noptr-abstract-pack-declarator := ... +#! Custom modifications to avoid nullable clause. +parameter-declaration-clause := parameter-declaration-list +parameter-declaration-clause := parameter-declaration-list_opt ... +parameter-declaration-clause := parameter-declaration-list , ... +parameter-declaration-list := parameter-declaration +parameter-declaration-list := parameter-declaration-list , parameter-declaration +parameter-declaration := decl-specifier-seq declarator +parameter-declaration := decl-specifier-seq declarator = initializer-clause +parameter-declaration := decl-specifier-seq abstract-declarator_opt +parameter-declaration := decl-specifier-seq abstract-declarator_opt = initializer-clause +# dcl.init +initializer := brace-or-equal-initializer +initializer := ( expression-list ) +brace-or-equal-initializer := = initializer-clause +brace-or-equal-initializer := braced-init-list +initializer-clause := assignment-expression +initializer-clause := braced-init-list +#! Allow mixed designated/non-designated init-list. +# This is standard C, and accepted by clang and others as an extension. +# FIXME: Decouple recovery from is-there-a-trailing-comma! +braced-init-list := { initializer-list [recover=Brackets] } +braced-init-list := { initializer-list , } +braced-init-list := { } +initializer-list := initializer-list-item +initializer-list := initializer-list , initializer-list-item +initializer-list-item := initializer-clause ..._opt +initializer-list-item := designator brace-or-equal-initializer ..._opt +designator := . IDENTIFIER +#! Array designators are legal in C, and a common extension in C++. +designator := [ expression ] +expr-or-braced-init-list := expression +expr-or-braced-init-list := braced-init-list +# dcl.fct +function-definition := decl-specifier-seq_opt function-declarator virt-specifier-seq_opt function-body +function-definition := decl-specifier-seq_opt function-declarator requires-clause function-body +function-body := ctor-initializer_opt compound-statement +function-body := function-try-block +function-body := = DEFAULT ; +function-body := = DELETE ; +# dcl.enum +enum-specifier := enum-head { enumerator-list_opt } +enum-specifier := enum-head { enumerator-list , } +enum-head := enum-key enum-head-name_opt enum-base_opt +enum-head-name := nested-name-specifier_opt IDENTIFIER +opaque-enum-declaration := enum-key enum-head-name enum-base_opt ; +enum-key := ENUM +enum-key := ENUM CLASS +enum-key := ENUM STRUCT +enum-base := : type-specifier-seq +enumerator-list := enumerator-definition +enumerator-list := enumerator-list , enumerator-definition +enumerator-definition := enumerator +enumerator-definition := enumerator = constant-expression +enumerator := IDENTIFIER +using-enum-declaration := USING elaborated-enum-specifier ; +# basic.namespace +namespace-definition := named-namespace-definition +namespace-definition := unnamed-namespace-definition +namespace-definition := nested-namespace-definition +named-namespace-definition := INLINE_opt NAMESPACE IDENTIFIER { namespace-body_opt } +unnamed-namespace-definition := INLINE_opt NAMESPACE { namespace-body_opt } +nested-namespace-definition := NAMESPACE enclosing-namespace-specifier :: INLINE_opt IDENTIFIER { namespace-body } +enclosing-namespace-specifier := IDENTIFIER +enclosing-namespace-specifier := enclosing-namespace-specifier :: INLINE_opt IDENTIFIER +#! Custom modification to avoid nullable namespace-body. +namespace-body := declaration-seq +namespace-alias-definition := NAMESPACE IDENTIFIER = qualified-namespace-specifier ; +qualified-namespace-specifier := nested-name-specifier_opt namespace-name +using-directive := USING NAMESPACE nested-name-specifier_opt namespace-name ; +using-declaration := USING using-declarator-list ; +using-declarator-list := using-declarator ..._opt +using-declarator-list := using-declarator-list , using-declarator ..._opt +using-declarator := TYPENAME_opt nested-name-specifier unqualified-id +# dcl.asm +asm-declaration := ASM ( string-literal ) ; +# dcl.link +linkage-specification := EXTERN string-literal { declaration-seq_opt } +linkage-specification := EXTERN string-literal declaration + +# gram.module +module-declaration := export-keyword_opt module-keyword module-name module-partition_opt ; +module-name := module-name-qualifier_opt IDENTIFIER +module-partition := : module-name-qualifier_opt IDENTIFIER +module-name-qualifier := IDENTIFIER . +module-name-qualifier := module-name-qualifier IDENTIFIER . +export-declaration := EXPORT declaration +export-declaration := EXPORT { declaration-seq_opt } +export-declaration := export-keyword module-import-declaration +module-import-declaration := import-keyword module-name ; +module-import-declaration := import-keyword module-partition ; +# FIXME: we don't have header-name in the grammar. Handle these in PP? +# module-import-declaration := import-keyword header-name ; +global-module-fragment := module-keyword ; declaration-seq_opt +private-module-fragment := module-keyword : PRIVATE ; declaration-seq_opt + +# gram.class +class-specifier := class-head { member-specification_opt [recover=Brackets] } +class-head := class-key class-head-name class-virt-specifier_opt base-clause_opt +class-head := class-key base-clause_opt +class-head-name := nested-name-specifier_opt type-name +class-virt-specifier := contextual-final +class-key := CLASS +class-key := STRUCT +class-key := UNION +member-specification := member-declaration member-specification_opt +member-specification := access-specifier : member-specification_opt +member-declaration := decl-specifier-seq member-declarator-list_opt ; +member-declaration := member-declarator-list ; +member-declaration := function-definition +member-declaration := using-declaration +member-declaration := using-enum-declaration +member-declaration := static_assert-declaration +member-declaration := template-declaration +member-declaration := explicit-specialization +member-declaration := deduction-guide +member-declaration := alias-declaration +member-declaration := opaque-enum-declaration +member-declaration := empty-declaration +member-declarator-list := member-declarator +member-declarator-list := member-declarator-list , member-declarator +member-declarator := function-declarator virt-specifier-seq_opt pure-specifier_opt +member-declarator := function-declarator requires-clause +member-declarator := non-function-declarator brace-or-equal-initializer_opt +member-declarator := IDENTIFIER_opt : constant-expression brace-or-equal-initializer_opt +virt-specifier-seq := virt-specifier +virt-specifier-seq := virt-specifier-seq virt-specifier +virt-specifier := contextual-override +virt-specifier := contextual-final +pure-specifier := = contextual-zero +conversion-function-id := OPERATOR conversion-type-id +conversion-type-id := type-specifier-seq conversion-declarator_opt +conversion-declarator := ptr-operator conversion-declarator_opt +base-clause := : base-specifier-list +base-specifier-list := base-specifier ..._opt +base-specifier-list := base-specifier-list , base-specifier ..._opt +base-specifier := class-or-decltype +base-specifier := VIRTUAL access-specifier_opt class-or-decltype +base-specifier := access-specifier VIRTUAL_opt class-or-decltype +class-or-decltype := nested-name-specifier_opt type-name +class-or-decltype := nested-name-specifier TEMPLATE simple-template-id +class-or-decltype := decltype-specifier +access-specifier := PRIVATE +access-specifier := PROTECTED +access-specifier := PUBLIC +ctor-initializer := : mem-initializer-list +mem-initializer-list := mem-initializer ..._opt +mem-initializer-list := mem-initializer-list , mem-initializer ..._opt +mem-initializer := mem-initializer-id ( expression-list_opt ) +mem-initializer := mem-initializer-id braced-init-list +mem-initializer-id := class-or-decltype +mem-initializer-id := IDENTIFIER + +# gram.over +operator-function-id := OPERATOR operator-name +operator-name := NEW +operator-name := DELETE +operator-name := NEW [ ] +operator-name := DELETE [ ] +operator-name := CO_AWAIT +operator-name := ( ) +operator-name := [ ] +operator-name := -> +operator-name := ->* +operator-name := ~ +operator-name := ! +operator-name := + +operator-name := - +operator-name := * +operator-name := / +operator-name := % +operator-name := ^ +operator-name := & +operator-name := | +operator-name := = +operator-name := += +operator-name := -= +operator-name := *= +operator-name := /= +operator-name := %= +operator-name := ^= +operator-name := &= +operator-name := |= +operator-name := == +operator-name := != +operator-name := < +operator-name := > +operator-name := <= +operator-name := >= +operator-name := <=> +operator-name := ^^ +operator-name := || +operator-name := << +operator-name := greatergreater +operator-name := <<= +operator-name := >>= +operator-name := ++ +operator-name := -- +operator-name := , +literal-operator-id := OPERATOR string-literal IDENTIFIER +literal-operator-id := OPERATOR user-defined-string-literal + +# gram.temp +template-declaration := template-head declaration +template-declaration := template-head concept-definition +template-head := TEMPLATE < template-parameter-list > requires-clause_opt +template-parameter-list := template-parameter +template-parameter-list := template-parameter-list , template-parameter +requires-clause := REQUIRES constraint-logical-or-expression +constraint-logical-or-expression := constraint-logical-and-expression +constraint-logical-or-expression := constraint-logical-or-expression || constraint-logical-and-expression +constraint-logical-and-expression := primary-expression +constraint-logical-and-expression := constraint-logical-and-expression && primary-expression +template-parameter := type-parameter +template-parameter := parameter-declaration +type-parameter := type-parameter-key ..._opt IDENTIFIER_opt +type-parameter := type-parameter-key IDENTIFIER_opt = type-id +type-parameter := type-constraint ..._opt IDENTIFIER_opt +type-parameter := type-constraint IDENTIFIER_opt = type-id +type-parameter := template-head type-parameter-key ..._opt IDENTIFIER_opt +type-parameter := template-head type-parameter-key IDENTIFIER_opt = id-expression +type-parameter-key := CLASS +type-parameter-key := TYPENAME +type-constraint := nested-name-specifier_opt concept-name +type-constraint := nested-name-specifier_opt concept-name < template-argument-list_opt > +simple-template-id := template-name < template-argument-list_opt > +template-id := simple-template-id +template-id := operator-function-id < template-argument-list_opt > +template-id := literal-operator-id < template-argument-list_opt > +template-argument-list := template-argument ..._opt +template-argument-list := template-argument-list , template-argument ..._opt +template-argument := constant-expression +template-argument := type-id +template-argument := id-expression +constraint-expression := logical-or-expression +deduction-guide := explicit-specifier_opt template-name ( parameter-declaration-list_opt ) -> simple-template-id ; +concept-definition := CONCEPT concept-name = constraint-expression ; +concept-name := IDENTIFIER +typename-specifier := TYPENAME nested-name-specifier IDENTIFIER +typename-specifier := TYPENAME nested-name-specifier TEMPLATE_opt simple-template-id +explicit-instantiation := EXTERN_opt TEMPLATE declaration +explicit-specialization := TEMPLATE < > declaration + +# gram.except +try-block := TRY compound-statement handler-seq +function-try-block := TRY ctor-initializer_opt compound-statement handler-seq +handler-seq := handler handler-seq_opt +handler := CATCH ( exception-declaration ) compound-statement +exception-declaration := type-specifier-seq declarator +exception-declaration := type-specifier-seq abstract-declarator_opt +noexcept-specifier := NOEXCEPT ( constant-expression ) +noexcept-specifier := NOEXCEPT + +# gram.cpp +identifier-list := IDENTIFIER +identifier-list := identifier-list , IDENTIFIER + +# gram.lex +#! As we use clang lexer, most of lexical symbols are not needed, we only add +#! needed literals. +literal := integer-literal +literal := character-literal +literal := floating-point-literal +literal := string-literal +literal := boolean-literal +literal := pointer-literal +literal := user-defined-literal +integer-literal := NUMERIC_CONSTANT [guard] +character-literal := CHAR_CONSTANT [guard] +character-literal := WIDE_CHAR_CONSTANT [guard] +character-literal := UTF8_CHAR_CONSTANT [guard] +character-literal := UTF16_CHAR_CONSTANT [guard] +character-literal := UTF32_CHAR_CONSTANT [guard] +floating-point-literal := NUMERIC_CONSTANT [guard] +string-literal-chunk := STRING_LITERAL [guard] +string-literal-chunk := WIDE_STRING_LITERAL [guard] +string-literal-chunk := UTF8_STRING_LITERAL [guard] +string-literal-chunk := UTF16_STRING_LITERAL [guard] +string-literal-chunk := UTF32_STRING_LITERAL [guard] +#! Technically, string concatenation happens at phase 6 which is before parsing, +#! so it doesn't belong to the grammar. However, we extend the grammar to +#! support it, to make the pseudoparser fully functional on practical code. +string-literal := string-literal-chunk +string-literal := string-literal string-literal-chunk +user-defined-literal := user-defined-integer-literal +user-defined-literal := user-defined-floating-point-literal +user-defined-literal := user-defined-string-literal +user-defined-literal := user-defined-character-literal +user-defined-integer-literal := NUMERIC_CONSTANT [guard] +user-defined-string-literal-chunk := STRING_LITERAL [guard] +user-defined-string-literal-chunk := WIDE_STRING_LITERAL [guard] +user-defined-string-literal-chunk := UTF8_STRING_LITERAL [guard] +user-defined-string-literal-chunk := UTF16_STRING_LITERAL [guard] +user-defined-string-literal-chunk := UTF32_STRING_LITERAL [guard] +user-defined-string-literal := user-defined-string-literal-chunk +user-defined-string-literal := string-literal-chunk user-defined-string-literal +user-defined-string-literal := user-defined-string-literal string-literal-chunk +user-defined-floating-point-literal := NUMERIC_CONSTANT [guard] +user-defined-character-literal := CHAR_CONSTANT [guard] +user-defined-character-literal := WIDE_CHAR_CONSTANT [guard] +user-defined-character-literal := UTF8_CHAR_CONSTANT [guard] +user-defined-character-literal := UTF16_CHAR_CONSTANT [guard] +user-defined-character-literal := UTF32_CHAR_CONSTANT [guard] +boolean-literal := FALSE +boolean-literal := TRUE +pointer-literal := NULLPTR + +#! Contextual keywords -- clang lexer always lexes them as identifier tokens. +#! Placeholders for literal text in the grammar that lex as other things. +contextual-override := IDENTIFIER [guard] +contextual-final := IDENTIFIER [guard] +contextual-zero := NUMERIC_CONSTANT [guard] +module-keyword := IDENTIFIER [guard] +import-keyword := IDENTIFIER [guard] +export-keyword := IDENTIFIER [guard] + +#! greatergreater token -- clang lexer always lexes it as a single token, we +#! split it into two tokens to make the GLR parser aware of the nested-template +#! case. +greatergreater := > > + +#! C++ predefined identifier, __func__ [dcl.fct.def.general] p8 +#! FIXME: add other (MSVC, GNU extension) predefined identifiers. +primary-expression := predefined-expression +predefined-expression := __FUNC__ diff --git a/clang-tools-extra/pseudo/lib/grammar/CMakeLists.txt b/clang-tools-extra/pseudo/lib/grammar/CMakeLists.txt new file mode 100644 index 0000000000000..bb08ebab0fa62 --- /dev/null +++ b/clang-tools-extra/pseudo/lib/grammar/CMakeLists.txt @@ -0,0 +1,10 @@ +set(LLVM_LINK_COMPONENTS Support) + +add_clang_library(clangPseudoGrammar + Grammar.cpp + GrammarBNF.cpp + LRGraph.cpp + LRTable.cpp + LRTableBuild.cpp + ) + diff --git a/clang-tools-extra/pseudo/lib/grammar/Grammar.cpp b/clang-tools-extra/pseudo/lib/grammar/Grammar.cpp new file mode 100644 index 0000000000000..3e9c5c3c7a6c4 --- /dev/null +++ b/clang-tools-extra/pseudo/lib/grammar/Grammar.cpp @@ -0,0 +1,190 @@ +//===--- Grammar.cpp - Grammar for clang pseudoparser -----------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/grammar/Grammar.h" +#include "clang/Basic/TokenKinds.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/raw_ostream.h" +#include + +namespace clang { +namespace pseudo { + +Rule::Rule(SymbolID Target, llvm::ArrayRef Sequence) + : Target(Target), Size(static_cast(Sequence.size())) { + assert(Sequence.size() <= Rule::MaxElements); + llvm::copy(Sequence, this->Sequence); +} + +Grammar::Grammar(std::unique_ptr Table) : T(std::move(Table)) { + Underscore = *findNonterminal("_"); +} + +llvm::ArrayRef Grammar::rulesFor(SymbolID SID) const { + assert(isNonterminal(SID)); + const auto &R = T->Nonterminals[SID].RuleRange; + assert(R.End <= T->Rules.size()); + return llvm::ArrayRef(&T->Rules[R.Start], R.End - R.Start); +} + +const Rule &Grammar::lookupRule(RuleID RID) const { + assert(RID < T->Rules.size()); + return T->Rules[RID]; +} + +llvm::StringRef Grammar::symbolName(SymbolID SID) const { + if (isToken(SID)) + return T->Terminals[symbolToToken(SID)]; + return T->Nonterminals[SID].Name; +} + +std::optional Grammar::findNonterminal(llvm::StringRef Name) const { + auto It = llvm::partition_point( + T->Nonterminals, + [&](const GrammarTable::Nonterminal &X) { return X.Name < Name; }); + if (It != T->Nonterminals.end() && It->Name == Name) + return It - T->Nonterminals.begin(); + return std::nullopt; +} + +std::string Grammar::dumpRule(RuleID RID) const { + std::string Result; + llvm::raw_string_ostream OS(Result); + const Rule &R = T->Rules[RID]; + OS << symbolName(R.Target) << " :="; + for (unsigned I = 0; I < R.Size; ++I) { + OS << " " << symbolName(R.Sequence[I]); + if (R.RecoveryIndex == I) + OS << " [recover=" << T->AttributeValues[R.Recovery] << "]"; + } + if (R.Guarded) + OS << " [guard]"; + return Result; +} + +std::string Grammar::dumpRules(SymbolID SID) const { + assert(isNonterminal(SID)); + std::string Result; + const auto &Range = T->Nonterminals[SID].RuleRange; + for (RuleID RID = Range.Start; RID < Range.End; ++RID) + Result.append(dumpRule(RID)).push_back('\n'); + return Result; +} + +std::string Grammar::dump() const { + std::string Result; + llvm::raw_string_ostream OS(Result); + OS << "Nonterminals:\n"; + for (SymbolID SID = 0; SID < T->Nonterminals.size(); ++SID) + OS << llvm::formatv(" {0} {1}\n", SID, symbolName(SID)); + OS << "Rules:\n"; + for (RuleID RID = 0; RID < T->Rules.size(); ++RID) + OS << llvm::formatv(" {0} {1}\n", RID, dumpRule(RID)); + return OS.str(); +} + +std::vector> firstSets(const Grammar &G) { + std::vector> FirstSets( + G.table().Nonterminals.size()); + auto ExpandFirstSet = [&FirstSets](SymbolID Target, SymbolID First) { + assert(isNonterminal(Target)); + if (isToken(First)) + return FirstSets[Target].insert(First).second; + bool Changed = false; + for (SymbolID SID : FirstSets[First]) + Changed |= FirstSets[Target].insert(SID).second; + return Changed; + }; + + // A rule S := T ... implies elements in FIRST(S): + // - if T is a terminal, FIRST(S) contains T + // - if T is a nonterminal, FIRST(S) contains FIRST(T) + // Since FIRST(T) may not have been fully computed yet, FIRST(S) itself may + // end up being incomplete. + // We iterate until we hit a fixed point. + // (This isn't particularly efficient, but table building isn't on the + // critical path). + bool Changed = true; + while (Changed) { + Changed = false; + for (const auto &R : G.table().Rules) + // We only need to consider the first element because symbols are + // non-nullable. + Changed |= ExpandFirstSet(R.Target, R.seq().front()); + } + return FirstSets; +} + +std::vector> followSets(const Grammar &G) { + auto FirstSets = firstSets(G); + std::vector> FollowSets( + G.table().Nonterminals.size()); + // Expand the follow set of a nonterminal symbol Y by adding all from the + // given symbol set. + auto ExpandFollowSet = [&FollowSets](SymbolID Y, + const llvm::DenseSet &ToAdd) { + assert(isNonterminal(Y)); + bool Changed = false; + for (SymbolID F : ToAdd) + Changed |= FollowSets[Y].insert(F).second; + return Changed; + }; + // Follow sets is computed based on the following 3 rules, the computation + // is completed at a fixed point where there is no more new symbols can be + // added to any of the follow sets. + // + // Rule 1: add endmarker to the FOLLOW(S), where S is the start symbol of the + // augmented grammar, in our case it is '_'. + FollowSets[G.underscore()].insert(tokenSymbol(tok::eof)); + bool Changed = true; + while (Changed) { + Changed = false; + for (const auto &R : G.table().Rules) { + // Rule 2: for a rule X := ... Y Z, we add all symbols from FIRST(Z) to + // FOLLOW(Y). + for (size_t I = 0; I + 1 < R.seq().size(); ++I) { + if (isToken(R.seq()[I])) + continue; + // We only need to consider the next symbol because symbols are + // non-nullable. + SymbolID Next = R.seq()[I + 1]; + if (isToken(Next)) + // First set for a terminal is itself. + Changed |= ExpandFollowSet(R.seq()[I], {Next}); + else + Changed |= ExpandFollowSet(R.seq()[I], FirstSets[Next]); + } + // Rule 3: for a rule X := ... Z, we add all symbols from FOLLOW(X) to + // FOLLOW(Z). + SymbolID Z = R.seq().back(); + if (isNonterminal(Z)) + Changed |= ExpandFollowSet(Z, FollowSets[R.Target]); + } + } + return FollowSets; +} + +static llvm::ArrayRef getTerminalNames() { + static const auto &TerminalNames = []() { + auto TerminalNames = new std::string[NumTerminals]; +#define PUNCTUATOR(Tok, Spelling) TerminalNames[tok::Tok] = Spelling; +#define KEYWORD(Keyword, Condition) \ + TerminalNames[tok::kw_##Keyword] = llvm::StringRef(#Keyword).upper(); +#define TOK(Tok) TerminalNames[tok::Tok] = llvm::StringRef(#Tok).upper(); +#include "clang/Basic/TokenKinds.def" + return llvm::ArrayRef(TerminalNames, NumTerminals); + }(); + return TerminalNames; +} +GrammarTable::GrammarTable() : Terminals(getTerminalNames()) {} + +} // namespace pseudo +} // namespace clang diff --git a/clang-tools-extra/pseudo/lib/grammar/GrammarBNF.cpp b/clang-tools-extra/pseudo/lib/grammar/GrammarBNF.cpp new file mode 100644 index 0000000000000..f1b8e06e22432 --- /dev/null +++ b/clang-tools-extra/pseudo/lib/grammar/GrammarBNF.cpp @@ -0,0 +1,362 @@ +//===--- GrammarBNF.cpp - build grammar from BNF files ----------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/grammar/Grammar.h" +#include "clang/Basic/TokenKinds.h" +#include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/Support/FormatVariadic.h" +#include +#include + +namespace clang { +namespace pseudo { + +namespace { +static const llvm::StringRef OptSuffix = "_opt"; +static const llvm::StringRef StartSymbol = "_"; + +// Builds grammar from BNF files. +class GrammarBuilder { +public: + GrammarBuilder(std::vector &Diagnostics) + : Diagnostics(Diagnostics) {} + + Grammar build(llvm::StringRef BNF) { + auto Specs = eliminateOptional(parse(BNF)); + + assert(llvm::all_of(Specs, + [](const RuleSpec &R) { + if (R.Target.ends_with(OptSuffix)) + return false; + return llvm::all_of( + R.Sequence, [](const RuleSpec::Element &E) { + return !E.Symbol.ends_with(OptSuffix); + }); + }) && + "Optional symbols should be eliminated!"); + + auto T = std::make_unique(); + + // Assemble the name->ID and ID->nonterminal name maps. + llvm::DenseSet UniqueNonterminals; + llvm::DenseMap SymbolIds; + + llvm::DenseSet UniqueAttributeValues; + + for (uint16_t I = 0; I < NumTerminals; ++I) + SymbolIds.try_emplace(T->Terminals[I], tokenSymbol(tok::TokenKind(I))); + auto Consider = [&](llvm::StringRef Name) { + if (!SymbolIds.count(Name)) + UniqueNonterminals.insert(Name); + }; + for (const auto &Spec : Specs) { + Consider(Spec.Target); + for (const RuleSpec::Element &Elt : Spec.Sequence) { + Consider(Elt.Symbol); + for (const auto& KV : Elt.Attributes) + UniqueAttributeValues.insert(KV.second); + } + } + for (llvm::StringRef Name : UniqueNonterminals) { + T->Nonterminals.emplace_back(); + T->Nonterminals.back().Name = Name.str(); + } + assert(T->Nonterminals.size() < (1 << (SymbolBits - 1)) && + "Too many nonterminals to fit in SymbolID bits!"); + llvm::sort(T->Nonterminals, [](const GrammarTable::Nonterminal &L, + const GrammarTable::Nonterminal &R) { + return L.Name < R.Name; + }); + // Add an empty string for the corresponding sentinel unset attribute. + T->AttributeValues.push_back(""); + UniqueAttributeValues.erase(""); + for (llvm::StringRef Name : UniqueAttributeValues) { + T->AttributeValues.emplace_back(); + T->AttributeValues.back() = Name.str(); + } + llvm::sort(T->AttributeValues); + assert(T->AttributeValues.front() == ""); + + // Build name -> ID maps for nonterminals. + for (SymbolID SID = 0; SID < T->Nonterminals.size(); ++SID) + SymbolIds.try_emplace(T->Nonterminals[SID].Name, SID); + + // Convert the rules. + T->Rules.reserve(Specs.size()); + std::vector Symbols; + auto Lookup = [SymbolIds](llvm::StringRef Name) { + auto It = SymbolIds.find(Name); + assert(It != SymbolIds.end() && "Didn't find the symbol in SymbolIds!"); + return It->second; + }; + for (const auto &Spec : Specs) { + assert(Spec.Sequence.size() <= Rule::MaxElements); + Symbols.clear(); + for (const RuleSpec::Element &Elt : Spec.Sequence) + Symbols.push_back(Lookup(Elt.Symbol)); + T->Rules.push_back(Rule(Lookup(Spec.Target), Symbols)); + applyAttributes(Spec, *T, T->Rules.back()); + } + + assert(T->Rules.size() < (1 << RuleBits) && + "Too many rules to fit in RuleID bits!"); + const auto &SymbolOrder = getTopologicalOrder(T.get()); + llvm::stable_sort( + T->Rules, [&SymbolOrder](const Rule &Left, const Rule &Right) { + // Sorted by the topological order of the nonterminal Target. + return SymbolOrder[Left.Target] < SymbolOrder[Right.Target]; + }); + for (SymbolID SID = 0; SID < T->Nonterminals.size(); ++SID) { + auto StartIt = llvm::partition_point(T->Rules, [&](const Rule &R) { + return SymbolOrder[R.Target] < SymbolOrder[SID]; + }); + RuleID Start = StartIt - T->Rules.begin(); + RuleID End = Start; + while (End < T->Rules.size() && T->Rules[End].Target == SID) + ++End; + T->Nonterminals[SID].RuleRange = {Start, End}; + } + Grammar G(std::move(T)); + diagnoseGrammar(G); + return G; + } + + // Gets topological order for nonterminal symbols. + // + // The topological order is defined as: if a *single* nonterminal A produces + // (or transitively) a nonterminal B (that said, there is a production rule + // B := A), then A is less than B. + // + // It returns the sort key for each symbol, the array is indexed by SymbolID. + std::vector getTopologicalOrder(GrammarTable *T) { + std::vector> Dependencies; + for (const auto &Rule : T->Rules) { + // if A := B, A depends on B. + if (Rule.Size == 1 && pseudo::isNonterminal(Rule.Sequence[0])) + Dependencies.push_back({Rule.Target, Rule.Sequence[0]}); + } + llvm::sort(Dependencies); + std::vector Order; + // Each nonterminal state flows: NotVisited -> Visiting -> Visited. + enum State { + NotVisited, + Visiting, + Visited, + }; + std::vector VisitStates(T->Nonterminals.size(), NotVisited); + std::function DFS = [&](SymbolID SID) -> void { + if (VisitStates[SID] == Visited) + return; + if (VisitStates[SID] == Visiting) { + Diagnostics.push_back( + llvm::formatv("The grammar contains a cycle involving symbol {0}", + T->Nonterminals[SID].Name)); + return; + } + VisitStates[SID] = Visiting; + for (auto It = llvm::lower_bound(Dependencies, + std::pair{SID, 0}); + It != Dependencies.end() && It->first == SID; ++It) + DFS(It->second); + VisitStates[SID] = Visited; + Order.push_back(SID); + }; + for (SymbolID ID = 0; ID != T->Nonterminals.size(); ++ID) + DFS(ID); + std::vector Result(T->Nonterminals.size(), 0); + for (size_t I = 0; I < Order.size(); ++I) + Result[Order[I]] = I; + return Result; + } + +private: + // Text representation of a BNF grammar rule. + struct RuleSpec { + llvm::StringRef Target; + struct Element { + llvm::StringRef Symbol; // Name of the symbol + // Attributes that are associated to the sequence symbol or rule. + std::vector> + Attributes; + }; + std::vector Sequence; + + std::string toString() const { + std::vector Body; + for (const auto &E : Sequence) + Body.push_back(E.Symbol); + return llvm::formatv("{0} := {1}", Target, llvm::join(Body, " ")); + } + }; + + std::vector parse(llvm::StringRef Lines) { + std::vector Specs; + for (llvm::StringRef Line : llvm::split(Lines, '\n')) { + Line = Line.trim(); + // Strip anything coming after the '#' (comment). + Line = Line.take_while([](char C) { return C != '#'; }); + if (Line.empty()) + continue; + RuleSpec Rule; + if (parseLine(Line, Rule)) + Specs.push_back(std::move(Rule)); + } + return Specs; + } + + bool parseLine(llvm::StringRef Line, RuleSpec &Out) { + auto Parts = Line.split(":="); + if (Parts.first == Line) { // no separator in Line + Diagnostics.push_back( + llvm::formatv("Failed to parse '{0}': no separator :=", Line).str()); + return false; + } + + Out.Target = Parts.first.trim(); + Out.Sequence.clear(); + for (llvm::StringRef Chunk : llvm::split(Parts.second, ' ')) { + Chunk = Chunk.trim(); + if (Chunk.empty()) + continue; // skip empty + if (Chunk.starts_with("[") && Chunk.ends_with("]")) { + if (Out.Sequence.empty()) + continue; + + parseAttributes(Chunk, Out.Sequence.back().Attributes); + continue; + } + + Out.Sequence.push_back({Chunk, /*Attributes=*/{}}); + } + return true; + } + + bool parseAttributes( + llvm::StringRef Content, + std::vector> &Out) { + assert(Content.starts_with("[") && Content.ends_with("]")); + auto KV = Content.drop_front().drop_back().split('='); + Out.push_back({KV.first, KV.second.trim()}); + + return true; + } + // Apply the parsed extensions (stored in RuleSpec) to the grammar Rule. + void applyAttributes(const RuleSpec& Spec, const GrammarTable& T, Rule& R) { + auto LookupExtensionID = [&T](llvm::StringRef Name) { + const auto It = llvm::partition_point( + T.AttributeValues, [&](llvm::StringRef X) { return X < Name; }); + assert(It != T.AttributeValues.end() && *It == Name && + "Didn't find the attribute in AttrValues!"); + return It - T.AttributeValues.begin(); + }; + for (unsigned I = 0; I < Spec.Sequence.size(); ++I) { + for (const auto &KV : Spec.Sequence[I].Attributes) { + if (KV.first == "guard") { + R.Guarded = true; + } else if (KV.first == "recover") { + R.Recovery = LookupExtensionID(KV.second); + R.RecoveryIndex = I; + } else { + Diagnostics.push_back( + llvm::formatv("Unknown attribute '{0}'", KV.first).str()); + } + } + } + } + + // Inlines all _opt symbols. + // For example, a rule E := id +_opt id, after elimination, we have two + // equivalent rules: + // 1) E := id + id + // 2) E := id id + std::vector eliminateOptional(llvm::ArrayRef Input) { + std::vector Results; + std::vector Storage; + for (const auto &R : Input) { + eliminateOptionalTail( + R.Sequence, Storage, [&Results, &Storage, &R, this]() { + if (Storage.empty()) { + Diagnostics.push_back( + llvm::formatv("Rule '{0}' has a nullable RHS", R.toString())); + return; + } + Results.push_back({R.Target, Storage}); + }); + assert(Storage.empty()); + } + return Results; + } + void eliminateOptionalTail(llvm::ArrayRef Elements, + std::vector &Result, + llvm::function_ref CB) { + if (Elements.empty()) + return CB(); + auto Front = Elements.front(); + if (!Front.Symbol.ends_with(OptSuffix)) { + Result.push_back(std::move(Front)); + eliminateOptionalTail(Elements.drop_front(1), Result, CB); + Result.pop_back(); + return; + } + // Enumerate two options: skip the opt symbol, or inline the symbol. + eliminateOptionalTail(Elements.drop_front(1), Result, CB); // skip + Front.Symbol = Front.Symbol.drop_back(OptSuffix.size()); // drop "_opt" + Result.push_back(std::move(Front)); + eliminateOptionalTail(Elements.drop_front(1), Result, CB); + Result.pop_back(); + } + + // Diagnoses the grammar and emit warnings if any. + void diagnoseGrammar(const Grammar &G) { + const auto &T = G.table(); + for (SymbolID SID = 0; SID < T.Nonterminals.size(); ++SID) { + auto Range = T.Nonterminals[SID].RuleRange; + if (Range.Start == Range.End) + Diagnostics.push_back( + llvm::formatv("No rules for nonterminal: {0}", G.symbolName(SID))); + llvm::StringRef NameRef = T.Nonterminals[SID].Name; + if (llvm::all_of(NameRef, llvm::isAlpha) && NameRef.upper() == NameRef) { + Diagnostics.push_back(llvm::formatv( + "Token-like name {0} is used as a nonterminal", G.symbolName(SID))); + } + } + llvm::DenseSet VisitedRules; + for (RuleID RID = 0; RID < T.Rules.size(); ++RID) { + const auto &R = T.Rules[RID]; + auto Code = llvm::hash_combine( + R.Target, llvm::hash_combine_range(R.seq().begin(), R.seq().end())); + auto [_, New] = VisitedRules.insert(Code); + if (!New) + Diagnostics.push_back( + llvm::formatv("Duplicate rule: `{0}`", G.dumpRule(RID))); + } + // symbol-id -> used counts + std::vector UseCounts(T.Nonterminals.size(), 0); + for (const Rule &R : T.Rules) + for (SymbolID SID : R.seq()) + if (isNonterminal(SID)) + ++UseCounts[SID]; + for (SymbolID SID = 0; SID < UseCounts.size(); ++SID) + if (UseCounts[SID] == 0 && T.Nonterminals[SID].Name != StartSymbol) + Diagnostics.push_back( + llvm::formatv("Nonterminal never used: {0}", G.symbolName(SID))); + } + std::vector &Diagnostics; +}; +} // namespace + +Grammar Grammar::parseBNF(llvm::StringRef BNF, + std::vector &Diagnostics) { + Diagnostics.clear(); + return GrammarBuilder(Diagnostics).build(BNF); +} + +} // namespace pseudo +} // namespace clang diff --git a/clang-tools-extra/pseudo/lib/grammar/LRGraph.cpp b/clang-tools-extra/pseudo/lib/grammar/LRGraph.cpp new file mode 100644 index 0000000000000..82c7cc7d8b293 --- /dev/null +++ b/clang-tools-extra/pseudo/lib/grammar/LRGraph.cpp @@ -0,0 +1,265 @@ +//===--- LRGraph.cpp - -------------------------------------------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/grammar/LRGraph.h" +#include "clang-pseudo/grammar/Grammar.h" +#include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/Hashing.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/raw_ostream.h" + +using ItemSet = std::vector; + +namespace llvm { +// Support clang::pseudo::Item as DenseMap keys. +template <> struct DenseMapInfo { + static inline ItemSet getEmptyKey() { + return {DenseMapInfo::getEmptyKey()}; + } + static inline ItemSet getTombstoneKey() { + return {DenseMapInfo::getTombstoneKey()}; + } + static unsigned getHashValue(const ItemSet &I) { + return llvm::hash_combine_range(I.begin(), I.end()); + } + static bool isEqual(const ItemSet &LHS, const ItemSet &RHS) { + return LHS == RHS; + } +}; +} // namespace llvm + +namespace clang { +namespace pseudo { +namespace { + +struct SortByNextSymbol { + SortByNextSymbol(const Grammar &G) : G(G) {} + bool operator()(const Item &L, const Item &R) { + if (L.hasNext() && R.hasNext() && L.next(G) != R.next(G)) + return L.next(G) < R.next(G); + if (L.hasNext() != R.hasNext()) + return L.hasNext() < R.hasNext(); // a trailing dot is minimal. + return L < R; + } + const Grammar &G; +}; + +// Computes a closure of the given item set S: +// - extends the given S to contain all options for parsing next token; +// - nonterminals after a dot are recursively expanded into the begin-state +// of all production rules that produce that nonterminal; +// +// Given +// Grammar rules = [ _ := E, E := E - T, E := T, T := n, T := ( E ) ] +// Input = [ E := . T ] +// returns [ E := . T, T := . n, T := . ( E ) ] +State closure(ItemSet Queue, const Grammar &G) { + llvm::DenseSet InQueue = {Queue.begin(), Queue.end()}; + // We reuse the passed-by-value Queue as the final result, as it's already + // initialized to the right elements. + size_t ItIndex = 0; + while (ItIndex < Queue.size()) { + const Item &ExpandingItem = Queue[ItIndex]; + ++ItIndex; + if (!ExpandingItem.hasNext()) + continue; + + SymbolID NextSym = ExpandingItem.next(G); + if (pseudo::isToken(NextSym)) + continue; + auto RRange = G.table().Nonterminals[NextSym].RuleRange; + for (RuleID RID = RRange.Start; RID < RRange.End; ++RID) { + Item NewItem = Item::start(RID, G); + if (InQueue.insert(NewItem).second) // new + Queue.push_back(std::move(NewItem)); + } + } + Queue.shrink_to_fit(); + llvm::sort(Queue, SortByNextSymbol(G)); + return {std::move(Queue)}; +} + +// Returns all next (with a dot advanced) kernel item sets, partitioned by the +// advanced symbol. +// +// Given +// S = [ E := . a b, E := E . - T ] +// returns [ +// {id(a), [ E := a . b ]}, +// {id(-), [ E := E - . T ]} +// ] +std::vector> +nextAvailableKernelItems(const State &S, const Grammar &G) { + std::vector> Results; + llvm::ArrayRef AllItems = S.Items; + AllItems = AllItems.drop_while([](const Item &I) { return !I.hasNext(); }); + while (!AllItems.empty()) { + SymbolID AdvancedSymbol = AllItems.front().next(G); + auto Batch = AllItems.take_while([AdvancedSymbol, &G](const Item &I) { + assert(I.hasNext()); + return I.next(G) == AdvancedSymbol; + }); + assert(!Batch.empty()); + AllItems = AllItems.drop_front(Batch.size()); + + // Advance a dot over the Symbol. + ItemSet Next; + for (const Item &I : Batch) + Next.push_back(I.advance()); + // sort the set to keep order determinism for hash computation. + llvm::sort(Next); + Results.push_back({AdvancedSymbol, std::move(Next)}); + } + return Results; +} + +std::vector> +availableRecovery(const State &S, const Grammar &G) { + std::vector> Result; + for (const Item &I : S.Items) { + const auto &Rule = G.lookupRule(I.rule()); + if (I.dot() != Rule.RecoveryIndex) + continue; + Result.push_back({Rule.Recovery, Rule.seq()[Rule.RecoveryIndex]}); + } + llvm::sort(Result); + Result.erase(std::unique(Result.begin(), Result.end()), Result.end()); + return Result; +} + +} // namespace + +std::string Item::dump(const Grammar &G) const { + const auto &Rule = G.lookupRule(RID); + auto ToNames = [&](llvm::ArrayRef Syms) { + std::vector Results; + for (auto SID : Syms) + Results.push_back(G.symbolName(SID)); + return Results; + }; + return llvm::formatv("{0} := {1} • {2}{3}", G.symbolName(Rule.Target), + llvm::join(ToNames(Rule.seq().take_front(DotPos)), " "), + llvm::join(ToNames(Rule.seq().drop_front(DotPos)), " "), + Rule.RecoveryIndex == DotPos ? " [recovery]" : "") + .str(); +} + +std::string State::dump(const Grammar &G, unsigned Indent) const { + std::string Result; + llvm::raw_string_ostream OS(Result); + for (const auto &Item : Items) + OS.indent(Indent) << llvm::formatv("{0}\n", Item.dump(G)); + return OS.str(); +} + +std::string LRGraph::dumpForTests(const Grammar &G) const { + std::string Result; + llvm::raw_string_ostream OS(Result); + OS << "States:\n"; + for (StateID ID = 0; ID < States.size(); ++ID) { + OS << llvm::formatv("State {0}\n", ID); + OS << States[ID].dump(G, /*Indent*/ 4); + } + for (const auto &E : Edges) { + OS << llvm::formatv("{0} ->[{1}] {2}\n", E.Src, G.symbolName(E.Label), + E.Dst); + } + return OS.str(); +} + +LRGraph LRGraph::buildLR0(const Grammar &G) { + class Builder { + public: + Builder(const Grammar &G) : G(G) {} + + // Adds a given state if not existed. + std::pair insert(ItemSet KernelItems) { + assert(llvm::is_sorted(KernelItems) && + "Item must be sorted before inserting to a hash map!"); + auto It = StatesIndex.find(KernelItems); + if (It != StatesIndex.end()) + return {It->second, false}; + States.push_back(closure(KernelItems, G)); + StateID NextStateID = States.size() - 1; + StatesIndex.insert({std::move(KernelItems), NextStateID}); + return {NextStateID, true}; + } + + void insertEdge(StateID Src, StateID Dst, SymbolID Label) { + Edges.push_back({Src, Dst, Label}); + } + + void insertRecovery(StateID Src, ExtensionID Strategy, SymbolID Result) { + Recoveries.push_back({Src, Strategy, Result}); + } + + // Returns a state with the given id. + const State &find(StateID ID) const { + assert(ID < States.size()); + return States[ID]; + } + + void addStartState(SymbolID Sym, StateID State) { + StartStates.push_back({Sym, State}); + } + + LRGraph build() && { + States.shrink_to_fit(); + Edges.shrink_to_fit(); + Recoveries.shrink_to_fit(); + llvm::sort(StartStates); + StartStates.shrink_to_fit(); + return LRGraph(std::move(States), std::move(Edges), std::move(Recoveries), + std::move(StartStates)); + } + + private: + // Key is the **kernel** item sets. + llvm::DenseMap StatesIndex; + std::vector States; + std::vector Edges; + std::vector Recoveries; + const Grammar &G; + std::vector> StartStates; + } Builder(G); + + std::vector PendingStates; + // Initialize states with the start symbol. + auto RRange = G.table().Nonterminals[G.underscore()].RuleRange; + for (RuleID RID = RRange.Start; RID < RRange.End; ++RID) { + auto StartState = std::vector{Item::start(RID, G)}; + auto Result = Builder.insert(std::move(StartState)); + assert(Result.second && "State must be new"); + PendingStates.push_back(Result.first); + + const Rule &StartRule = G.lookupRule(RID); + assert(StartRule.Size == 2 && + StartRule.seq().back() == tokenSymbol(tok::eof) && + "Start rule must be of the form `_ := start-symbol EOF`!"); + Builder.addStartState(StartRule.seq().front(), Result.first); + } + + while (!PendingStates.empty()) { + auto StateID = PendingStates.back(); + PendingStates.pop_back(); + for (auto Next : nextAvailableKernelItems(Builder.find(StateID), G)) { + auto Insert = Builder.insert(Next.second); + if (Insert.second) // new state, insert to the pending queue. + PendingStates.push_back(Insert.first); + Builder.insertEdge(StateID, Insert.first, Next.first); + } + for (auto Recovery : availableRecovery(Builder.find(StateID), G)) + Builder.insertRecovery(StateID, Recovery.first, Recovery.second); + } + return std::move(Builder).build(); +} + +} // namespace pseudo +} // namespace clang diff --git a/clang-tools-extra/pseudo/lib/grammar/LRTable.cpp b/clang-tools-extra/pseudo/lib/grammar/LRTable.cpp new file mode 100644 index 0000000000000..6a68f1489d57a --- /dev/null +++ b/clang-tools-extra/pseudo/lib/grammar/LRTable.cpp @@ -0,0 +1,79 @@ +//===--- LRTable.cpp - Parsing table for LR parsers --------------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/grammar/LRTable.h" +#include "clang-pseudo/grammar/Grammar.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/raw_ostream.h" + +namespace clang { +namespace pseudo { + +std::string LRTable::dumpStatistics() const { + return llvm::formatv(R"( +Statistics of the LR parsing table: + number of states: {0} + number of actions: shift={1} goto={2} reduce={3} + size of the table (bytes): {4} +)", + numStates(), Shifts.size(), Gotos.size(), Reduces.size(), + bytes()) + .str(); +} + +std::string LRTable::dumpForTests(const Grammar &G) const { + std::string Result; + llvm::raw_string_ostream OS(Result); + OS << "LRTable:\n"; + for (StateID S = 0; S < numStates(); ++S) { + OS << llvm::formatv("State {0}\n", S); + for (uint16_t Terminal = 0; Terminal < NumTerminals; ++Terminal) { + SymbolID TokID = tokenSymbol(static_cast(Terminal)); + if (auto SS = getShiftState(S, TokID)) + OS.indent(4) << llvm::formatv("{0}: shift state {1}\n", + G.symbolName(TokID), SS); + } + for (RuleID R : getReduceRules(S)) { + SymbolID Target = G.lookupRule(R).Target; + std::vector Terminals; + for (unsigned Terminal = 0; Terminal < NumTerminals; ++Terminal) { + SymbolID TokID = tokenSymbol(static_cast(Terminal)); + if (canFollow(Target, TokID)) + Terminals.push_back(G.symbolName(TokID)); + } + OS.indent(4) << llvm::formatv("{0}: reduce by rule {1} '{2}'\n", + llvm::join(Terminals, " "), R, + G.dumpRule(R)); + } + for (SymbolID NontermID = 0; NontermID < G.table().Nonterminals.size(); + ++NontermID) { + if (auto GS = getGoToState(S, NontermID)) { + OS.indent(4) << llvm::formatv("{0}: go to state {1}\n", + G.symbolName(NontermID), *GS); + } + } + } + return OS.str(); +} + +LRTable::StateID LRTable::getStartState(SymbolID Target) const { + assert(llvm::is_sorted(StartStates) && "StartStates must be sorted!"); + auto It = llvm::partition_point( + StartStates, [Target](const std::pair &X) { + return X.first < Target; + }); + assert(It != StartStates.end() && It->first == Target && + "target symbol doesn't have a start state!"); + return It->second; +} + +} // namespace pseudo +} // namespace clang diff --git a/clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp b/clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp new file mode 100644 index 0000000000000..387e1c54ee99b --- /dev/null +++ b/clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp @@ -0,0 +1,121 @@ +//===--- LRTableBuild.cpp - Build a LRTable from LRGraph ---------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/grammar/Grammar.h" +#include "clang-pseudo/grammar/LRGraph.h" +#include "clang-pseudo/grammar/LRTable.h" +#include "clang/Basic/TokenKinds.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallSet.h" +#include + +namespace clang { +namespace pseudo { + +LRTable LRTable::Builder::build() && { + assert(NumNonterminals != 0 && "Set NumNonterminals or init with grammar"); + LRTable Table; + + // Count number of states: every state has to be reachable somehow. + StateID MaxState = 0; + for (const auto &Entry : StartStates) + MaxState = std::max(MaxState, Entry.second); + for (const auto &Entry : Transition) + MaxState = std::max(MaxState, Entry.second); + unsigned NumStates = MaxState + 1; + + Table.StartStates = std::move(StartStates); + + // Compile the goto and shift actions into transition tables. + llvm::DenseMap Gotos; + llvm::DenseMap Shifts; + for (const auto &E : Transition) { + if (isToken(E.first.second)) + Shifts.try_emplace(shiftIndex(E.first.first, E.first.second, NumStates), + E.second); + else + Gotos.try_emplace(gotoIndex(E.first.first, E.first.second, NumStates), + E.second); + } + Table.Shifts = TransitionTable(Shifts, NumStates * NumTerminals); + Table.Gotos = TransitionTable(Gotos, NumStates * NumNonterminals); + + // Compile the follow sets into a bitmap. + Table.FollowSets.resize(tok::NUM_TOKENS * FollowSets.size()); + for (SymbolID NT = 0; NT < FollowSets.size(); ++NT) + for (SymbolID Follow : FollowSets[NT]) + Table.FollowSets.set(NT * tok::NUM_TOKENS + symbolToToken(Follow)); + + // Store the reduce actions in a vector partitioned by state. + Table.ReduceOffset.reserve(NumStates + 1); + std::vector StateRules; + for (StateID S = 0; S < NumStates; ++S) { + Table.ReduceOffset.push_back(Table.Reduces.size()); + auto It = Reduce.find(S); + if (It == Reduce.end()) + continue; + Table.Reduces.insert(Table.Reduces.end(), It->second.begin(), + It->second.end()); + llvm::sort(Table.Reduces.begin() + Table.ReduceOffset.back(), + Table.Reduces.end()); + } + Table.ReduceOffset.push_back(Table.Reduces.size()); + + // Error recovery entries: sort (no dups already), and build offset lookup. + llvm::sort(Recoveries, [&](const auto &L, const auto &R) { + return std::tie(L.first, L.second.Result, L.second.Strategy) < + std::tie(R.first, R.second.Result, R.second.Strategy); + }); + Table.Recoveries.reserve(Recoveries.size()); + for (const auto &R : Recoveries) + Table.Recoveries.push_back({R.second.Strategy, R.second.Result}); + Table.RecoveryOffset = std::vector(NumStates + 1, 0); + unsigned SortedIndex = 0; + for (StateID State = 0; State < NumStates; ++State) { + Table.RecoveryOffset[State] = SortedIndex; + while (SortedIndex < Recoveries.size() && + Recoveries[SortedIndex].first == State) + SortedIndex++; + } + Table.RecoveryOffset[NumStates] = SortedIndex; + assert(SortedIndex == Recoveries.size()); + + return Table; +} + +LRTable LRTable::buildSLR(const Grammar &G) { + auto Graph = LRGraph::buildLR0(G); + Builder Build(G); + Build.StartStates = Graph.startStates(); + for (const auto &T : Graph.edges()) + Build.Transition.try_emplace({T.Src, T.Label}, T.Dst); + for (const auto &Entry : Graph.recoveries()) + Build.Recoveries.push_back( + {Entry.Src, Recovery{Entry.Strategy, Entry.Result}}); + Build.FollowSets = followSets(G); + assert(Graph.states().size() <= (1 << StateBits) && + "Graph states execceds the maximum limit!"); + // Add reduce actions. + for (StateID SID = 0; SID < Graph.states().size(); ++SID) { + for (const Item &I : Graph.states()[SID].Items) { + // If we've just parsed the start symbol, this means we successfully parse + // the input. We don't add the reduce action of `_ := start_symbol` in the + // LRTable (the GLR parser handles it specifically). + if (G.lookupRule(I.rule()).Target == G.underscore() && !I.hasNext()) + continue; + if (!I.hasNext()) + // If we've reached the end of a rule A := ..., then we can reduce if + // the next token is in the follow set of A. + Build.Reduce[SID].insert(I.rule()); + } + } + return std::move(Build).build(); +} + +} // namespace pseudo +} // namespace clang diff --git a/clang-tools-extra/pseudo/test/.clang-format b/clang-tools-extra/pseudo/test/.clang-format new file mode 100644 index 0000000000000..e3845288a2aec --- /dev/null +++ b/clang-tools-extra/pseudo/test/.clang-format @@ -0,0 +1 @@ +DisableFormat: true diff --git a/clang-tools-extra/pseudo/test/CMakeLists.txt b/clang-tools-extra/pseudo/test/CMakeLists.txt new file mode 100644 index 0000000000000..712527f78140e --- /dev/null +++ b/clang-tools-extra/pseudo/test/CMakeLists.txt @@ -0,0 +1,29 @@ +set(CLANG_PSEUDO_TEST_DEPS + clang-pseudo + clang-pseudo-fuzzer + ClangPseudoTests + ) + +foreach(dep FileCheck not count) + if(TARGET ${dep}) + list(APPEND CLANG_PSEUDO_TEST_DEPS ${dep}) + endif() +endforeach() + +configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py + MAIN_CONFIG + ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py + ) + +configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py + MAIN_CONFIG + ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py + ) + +add_lit_testsuite(check-clang-pseudo "Running the clang-pseudo regression tests" + ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${CLANG_PSEUDO_TEST_DEPS}) diff --git a/clang-tools-extra/pseudo/test/Unit/lit.cfg.py b/clang-tools-extra/pseudo/test/Unit/lit.cfg.py new file mode 100644 index 0000000000000..000a8a772c31b --- /dev/null +++ b/clang-tools-extra/pseudo/test/Unit/lit.cfg.py @@ -0,0 +1,25 @@ +import lit.formats + +config.name = "clangPseudo Unit Tests" +config.test_format = lit.formats.GoogleTest(".", "Tests") +config.test_source_root = config.clang_pseudo_binary_dir + "/unittests" +config.test_exec_root = config.clang_pseudo_binary_dir + "/unittests" + +# Point the dynamic loader at dynamic libraries in 'lib'. +# FIXME: it seems every project has a copy of this logic. Move it somewhere. +import platform + +if platform.system() == "Darwin": + shlibpath_var = "DYLD_LIBRARY_PATH" +elif platform.system() == "Windows": + shlibpath_var = "PATH" +else: + shlibpath_var = "LD_LIBRARY_PATH" +config.environment[shlibpath_var] = os.path.pathsep.join( + ("@SHLIBDIR@", "@LLVM_LIBS_DIR@", config.environment.get(shlibpath_var, "")) +) + +# It is not realistically possible to account for all options that could +# possibly be present in system and user configuration files, so disable +# default configs for the test runs. +config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1" diff --git a/clang-tools-extra/pseudo/test/Unit/lit.site.cfg.py.in b/clang-tools-extra/pseudo/test/Unit/lit.site.cfg.py.in new file mode 100644 index 0000000000000..4107b0d2eb83f --- /dev/null +++ b/clang-tools-extra/pseudo/test/Unit/lit.site.cfg.py.in @@ -0,0 +1,11 @@ +@LIT_SITE_CFG_IN_HEADER@ +# This is a shim to run the gtest unittests in ../unittests using lit. + +config.llvm_libs_dir = "@LLVM_LIBS_DIR@" +config.shlibdir = "@SHLIBDIR@" + +config.clang_pseudo_source_dir = "@CMAKE_CURRENT_SOURCE_DIR@/.." +config.clang_pseudo_binary_dir = "@CMAKE_CURRENT_BINARY_DIR@/.." + +# Delegate logic to lit.cfg.py. +lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/Unit/lit.cfg.py") diff --git a/clang-tools-extra/pseudo/test/check-cxx-bnf.test b/clang-tools-extra/pseudo/test/check-cxx-bnf.test new file mode 100644 index 0000000000000..b825ff32faa1c --- /dev/null +++ b/clang-tools-extra/pseudo/test/check-cxx-bnf.test @@ -0,0 +1,2 @@ +// verify clang/lib/Tooling/Syntax/Pseudo/cxx/cxx.bnf +// RUN: clang-pseudo -grammar=%cxx-bnf-file diff --git a/clang-tools-extra/pseudo/test/crash/backslashes.c b/clang-tools-extra/pseudo/test/crash/backslashes.c new file mode 100644 index 0000000000000..4ca70c609a0e6 --- /dev/null +++ b/clang-tools-extra/pseudo/test/crash/backslashes.c @@ -0,0 +1,4 @@ +// We used to try to interpret these backslashes as UCNs. +// RUN: clang-pseudo -source=%s -print-tokens +\ +\ x diff --git a/clang-tools-extra/pseudo/test/cxx/capture-list.cpp b/clang-tools-extra/pseudo/test/cxx/capture-list.cpp new file mode 100644 index 0000000000000..fde46e4f0e038 --- /dev/null +++ b/clang-tools-extra/pseudo/test/cxx/capture-list.cpp @@ -0,0 +1,23 @@ +// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s +// We loosely allow capture defaults in any position/multiple times. +auto lambda = [&, &foo, bar(x), =]{}; +// CHECK: lambda-introducer := [ capture-list ] +// CHECK-NEXT: ├─[ +// CHECK-NEXT: ├─capture-list +// CHECK-NEXT: │ ├─capture-list +// CHECK-NEXT: │ │ ├─capture-list +// CHECK-NEXT: │ │ │ ├─capture-list~& := tok[4] +// CHECK-NEXT: │ │ │ ├─, +// CHECK-NEXT: │ │ │ └─capture~simple-capture +// CHECK-NEXT: │ │ │ ├─& +// CHECK-NEXT: │ │ │ └─IDENTIFIER := tok[7] +// CHECK-NEXT: │ │ ├─, +// CHECK-NEXT: │ │ └─capture~init-capture +// CHECK-NEXT: │ │ ├─IDENTIFIER := tok[9] +// CHECK-NEXT: │ │ └─initializer := ( expression-list ) +// CHECK-NEXT: │ │ ├─( +// CHECK-NEXT: │ │ ├─expression-list~IDENTIFIER := tok[11] +// CHECK-NEXT: │ │ └─) +// CHECK-NEXT: │ ├─, +// CHECK-NEXT: │ └─capture~= +// CHECK-NEXT: └─] diff --git a/clang-tools-extra/pseudo/test/cxx/contextual-keywords.cpp b/clang-tools-extra/pseudo/test/cxx/contextual-keywords.cpp new file mode 100644 index 0000000000000..ae74353c0a156 --- /dev/null +++ b/clang-tools-extra/pseudo/test/cxx/contextual-keywords.cpp @@ -0,0 +1,9 @@ +// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s +// Verify that the contextual-{final,override} rules are guarded conditionally, +// No ambiguous parsing for the virt-specifier. +class Foo { + void foo1() override; +// CHECK: virt-specifier-seq~IDENTIFIER := tok[7] + void foo2() final; +// CHECK: virt-specifier-seq~IDENTIFIER := tok[13] +}; diff --git a/clang-tools-extra/pseudo/test/cxx/dangling-else.cpp b/clang-tools-extra/pseudo/test/cxx/dangling-else.cpp new file mode 100644 index 0000000000000..151f3931b53f9 --- /dev/null +++ b/clang-tools-extra/pseudo/test/cxx/dangling-else.cpp @@ -0,0 +1,22 @@ +// RUN: clang-pseudo -grammar=cxx -source=%s --start-symbol=statement-seq --print-forest | FileCheck %s + +// Verify the else should belong to the nested if statement +if (true) if (true) {} else {} + +// CHECK: statement-seq~selection-statement := IF ( condition ) statement +// CHECK-NEXT: ├─IF +// CHECK-NEXT: ├─( +// CHECK-NEXT: ├─condition~TRUE +// CHECK-NEXT: ├─) +// CHECK-NEXT: └─statement~selection-statement +// CHECK-NEXT: ├─IF +// CHECK-NEXT: ├─( +// CHECK-NEXT: ├─condition~TRUE +// CHECK-NEXT: ├─) +// CHECK-NEXT: ├─statement~compound-statement := { } +// CHECK-NEXT: │ ├─{ +// CHECK-NEXT: │ └─} +// CHECK-NEXT: ├─ELSE +// CHECK-NEXT: └─statement~compound-statement := { } +// CHECK-NEXT: ├─{ +// CHECK-NEXT: └─} diff --git a/clang-tools-extra/pseudo/test/cxx/decl-specfier-seq.cpp b/clang-tools-extra/pseudo/test/cxx/decl-specfier-seq.cpp new file mode 100644 index 0000000000000..255e8bedac497 --- /dev/null +++ b/clang-tools-extra/pseudo/test/cxx/decl-specfier-seq.cpp @@ -0,0 +1,27 @@ +// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s + +// not parsed as Type{foo} Type{bar} +foo bar; +// CHECK-NOT: simple-declaration := decl-specifier-seq ; +// CHECK: simple-declaration := decl-specifier-seq init-declarator-list ; +// CHECK: ├─decl-specifier-seq~simple-type-specifier +// CHECK: ├─init-declarator-list~IDENTIFIER +// CHECK: └─; +// CHECK-NOT: simple-declaration := decl-specifier-seq ; + +// not parsed as Type{std} Type{::string} Declarator{s}; +std::string s; +// CHECK-NOT: nested-name-specifier := :: +// CHECK: simple-declaration := decl-specifier-seq init-declarator-list ; +// CHECK: ├─decl-specifier-seq~simple-type-specifier := +// CHECK: │ ├─simple-type-specifier := nested-name-specifier type-name +// CHECK: │ │ ├─nested-name-specifier := #1 +// CHECK: │ │ │ ├─nested-name-specifier := type-name :: +// CHECK: │ │ │ └─nested-name-specifier := namespace-name :: +// CHECK: │ │ └─type-name +// CHECK: │ └─simple-type-specifier := nested-name-specifier template-name +// CHECK: │ ├─nested-name-specifier =#1 +// CHECK: │ └─template-name~IDENTIFIER +// CHECK: ├─init-declarator-list~IDENTIFIER +// CHECK: └─; +// CHECK-NOT: nested-name-specifier := :: diff --git a/clang-tools-extra/pseudo/test/cxx/declarator-function.cpp b/clang-tools-extra/pseudo/test/cxx/declarator-function.cpp new file mode 100644 index 0000000000000..4d7972807c6db --- /dev/null +++ b/clang-tools-extra/pseudo/test/cxx/declarator-function.cpp @@ -0,0 +1,9 @@ +// The standard grammar allows an init-list with any declarator, including +// a function declarator. This creates an ambiguity where a function-definition +// is misparsed as a simple-declaration. + +// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s +void s(){}; +// CHECK-NOT: simple-declaration +// CHECK: function-definition := decl-specifier-seq function-declarator function-body +// CHECK-NOT: simple-declaration diff --git a/clang-tools-extra/pseudo/test/cxx/declarator-var.cpp b/clang-tools-extra/pseudo/test/cxx/declarator-var.cpp new file mode 100644 index 0000000000000..5aedd8037513f --- /dev/null +++ b/clang-tools-extra/pseudo/test/cxx/declarator-var.cpp @@ -0,0 +1,9 @@ +// The standard grammar allows an function-body to use any declarator, including +// a non-function declarator. This creates an ambiguity where a +// simple-declaration is misparsed as a function-definition. + +// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s +void (*s)(){}; +// CHECK-NOT: function-definition +// CHECK: init-declarator := non-function-declarator initializer +// CHECK-NOT: function-definition diff --git a/clang-tools-extra/pseudo/test/cxx/declator-member-function.cpp b/clang-tools-extra/pseudo/test/cxx/declator-member-function.cpp new file mode 100644 index 0000000000000..58d0ff4ccae9a --- /dev/null +++ b/clang-tools-extra/pseudo/test/cxx/declator-member-function.cpp @@ -0,0 +1,9 @@ +// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s + +// Similiar to declarator-function.cpp, but for member functions. +class Foo { + void foo() {}; +// CHECK-NOT: member-declarator := declarator brace-or-equal-initializer +// CHECK: member-declaration~function-definition := decl-specifier-seq function-declarator function-body +// CHECK-NOT: member-declarator := declarator brace-or-equal-initializer +}; diff --git a/clang-tools-extra/pseudo/test/cxx/empty-member-declaration.cpp b/clang-tools-extra/pseudo/test/cxx/empty-member-declaration.cpp new file mode 100644 index 0000000000000..2540dd010fcef --- /dev/null +++ b/clang-tools-extra/pseudo/test/cxx/empty-member-declaration.cpp @@ -0,0 +1,7 @@ +// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest --forest-abbrev=false | FileCheck %s +class A { + ; +// CHECK-NOT: member-declaration := ; +// CHECK: member-declaration := empty-declaration +// CHECK-NOT: member-declaration := ; +}; diff --git a/clang-tools-extra/pseudo/test/cxx/empty-member-spec.cpp b/clang-tools-extra/pseudo/test/cxx/empty-member-spec.cpp new file mode 100644 index 0000000000000..4d15835565b7e --- /dev/null +++ b/clang-tools-extra/pseudo/test/cxx/empty-member-spec.cpp @@ -0,0 +1,13 @@ +// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s +class Foo { +public: +}; +// CHECK: decl-specifier-seq~class-specifier := class-head { member-specification [recover=Brackets] } +// CHECK-NEXT: ├─class-head := class-key class-head-name +// CHECK-NEXT: │ ├─class-key~CLASS := tok[0] +// CHECK-NEXT: │ └─class-head-name~IDENTIFIER := tok[1] +// CHECK-NEXT: ├─{ := tok[2] +// CHECK-NEXT: ├─member-specification := access-specifier : +// CHECK-NEXT: │ ├─access-specifier~PUBLIC := tok[3] +// CHECK-NEXT: │ └─: := tok[4] +// CHECK-NEXT: └─} := tok[5] diff --git a/clang-tools-extra/pseudo/test/cxx/keyword.cpp b/clang-tools-extra/pseudo/test/cxx/keyword.cpp new file mode 100644 index 0000000000000..318db4ccc49b9 --- /dev/null +++ b/clang-tools-extra/pseudo/test/cxx/keyword.cpp @@ -0,0 +1,12 @@ +// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s +bool operator<(); +// CHECK: translation-unit~simple-declaration := decl-specifier-seq init-declarator-list ; +// CHECK-NEXT: ├─decl-specifier-seq~BOOL +// CHECK-NEXT: ├─init-declarator-list~noptr-declarator := noptr-declarator parameters-and-qualifiers +// CHECK-NEXT: │ ├─noptr-declarator~operator-function-id := OPERATOR operator-name +// CHECK-NEXT: │ │ ├─OPERATOR +// CHECK-NEXT: │ │ └─operator-name~< +// CHECK-NEXT: │ └─parameters-and-qualifiers := ( ) +// CHECK-NEXT: │ ├─( +// CHECK-NEXT: │ └─) +// CHECK-NEXT: └─; diff --git a/clang-tools-extra/pseudo/test/cxx/literals.cpp b/clang-tools-extra/pseudo/test/cxx/literals.cpp new file mode 100644 index 0000000000000..e1cec8985b25f --- /dev/null +++ b/clang-tools-extra/pseudo/test/cxx/literals.cpp @@ -0,0 +1,43 @@ +// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest -forest-abbrev=0 | FileCheck %s --implicit-check-not=ambiguous +auto list = { + 0, // CHECK: := integer-literal + 0b1011, // CHECK: := integer-literal + 0777, // CHECK: := integer-literal + 42_u, // CHECK: := user-defined-integer-literal + 0LL, // CHECK: := integer-literal + 0h, // CHECK: := user-defined-integer-literal + 0., // CHECK: := floating-point-literal + .2, // CHECK: := floating-point-literal + 2e1, // CHECK: := floating-point-literal + 0x42d, // CHECK: := integer-literal + 0x42_d, // CHECK: := user-defined-integer-literal + 0x42ds, // CHECK: := user-defined-integer-literal + 0x1.2p2,// CHECK: := floating-point-literal + + "", // CHECK: literal := string-literal + L"", // CHECK: literal := string-literal + u8"", // CHECK: literal := string-literal + u"", // CHECK: literal := string-literal + U"", // CHECK: literal := string-literal + R"()", // CHECK: literal := string-literal + uR"()", // CHECK: literal := string-literal + "a" "b", // CHECK: literal := string-literal + u8"a" "b", // CHECK: literal := string-literal + u"a" u"b", // CHECK: literal := string-literal + "a"_u "b", // CHECK: user-defined-literal := user-defined-string-literal + "a"_u u"b", // CHECK: user-defined-literal := user-defined-string-literal + R"(a)" "\n", // CHECK: literal := string-literal + R"c(a)c"_u u"\n", // CHECK: user-defined-literal := user-defined-string-literal + + 'a', // CHECK: := character-literal + 'abc', // CHECK: := character-literal + 'abcdef', // CHECK: := character-literal + u'a', // CHECK: := character-literal + U'a', // CHECK: := character-literal + L'a', // CHECK: := character-literal + L'abc', // CHECK: := character-literal + U'\u1234',// CHECK: := character-literal + '\u1234', // CHECK: := character-literal + u'a'_u, // CHECK: := user-defined-character-literal +}; + diff --git a/clang-tools-extra/pseudo/test/cxx/mixed-designator.cpp b/clang-tools-extra/pseudo/test/cxx/mixed-designator.cpp new file mode 100644 index 0000000000000..d605a3d66a5de --- /dev/null +++ b/clang-tools-extra/pseudo/test/cxx/mixed-designator.cpp @@ -0,0 +1,27 @@ +// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s +// FIXME: tighten CHECK to CHECK-NEXT once numeric literals are unambiguous. +auto x = { 1, .f = 2, [c]{3} }; +// CHECK: initializer-clause~braced-init-list +// CHECK-NEXT: ├─{ := tok[3] +// CHECK-NEXT: ├─initializer-list +// CHECK-NEXT: │ ├─initializer-list +// CHECK-NEXT: │ │ ├─initializer-list~NUMERIC_CONSTANT +// CHECK-NEXT: │ │ ├─, := tok[5] +// CHECK-NEXT: │ │ └─initializer-list-item +// CHECK-NEXT: │ │ ├─designator +// CHECK-NEXT: │ │ │ ├─. := tok[6] +// CHECK-NEXT: │ │ │ └─IDENTIFIER := tok[7] +// CHECK-NEXT: │ │ └─brace-or-equal-initializer +// CHECK-NEXT: │ │ ├─= := tok[8] +// CHECK-NEXT: │ │ └─initializer-clause~NUMERIC_CONSTANT +// CHECK-NEXT: │ ├─, := tok[10] +// CHECK-NEXT: │ └─initializer-list-item +// CHECK-NEXT: │ ├─designator +// CHECK-NEXT: │ │ ├─[ := tok[11] +// CHECK-NEXT: │ │ ├─expression~IDENTIFIER := tok[12] +// CHECK-NEXT: │ │ └─] := tok[13] +// CHECK-NEXT: │ └─brace-or-equal-initializer~braced-init-list +// CHECK-NEXT: │ ├─{ := tok[14] +// CHECK-NEXT: │ ├─initializer-list~NUMERIC_CONSTANT +// CHECK: │ └─} := tok[16] +// CHECK-NEXT: └─} := tok[17] diff --git a/clang-tools-extra/pseudo/test/cxx/nested-name-specifier.cpp b/clang-tools-extra/pseudo/test/cxx/nested-name-specifier.cpp new file mode 100644 index 0000000000000..41d0fa13ff6dd --- /dev/null +++ b/clang-tools-extra/pseudo/test/cxx/nested-name-specifier.cpp @@ -0,0 +1,28 @@ +// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s + +// Verify that we don't form a complete `::` nested-name-specifier if there is +// an identifier preceding it. +Foo::Foo() {} // No "Foo ::Foo()" false parse +// CHECK: ├─declaration-seq~function-definition := function-declarator function-body +// CHECK-NEXT: │ ├─function-declarator~noptr-declarator := noptr-declarator parameters-and-qualifiers + +int ::x; +// CHECK: declaration~simple-declaration := decl-specifier-seq init-declarator-list ; +// CHECK-NEXT: ├─decl-specifier-seq~INT + +void test() { + X::Y::Z; // No false qualified-declarator parses "X ::Y::Z" and "X::Y ::Z". +// CHECK: statement-seq~statement := +// CHECK: statement~expression-statement := expression ; +// CHECK: statement~simple-declaration := decl-specifier-seq ; +// CHECK-NOT: simple-declaration := decl-specifier-seq init-declarator-list ; + + // FIXME: eliminate the false `a ::c` declaration parse. + a::c; +// CHECK: statement := +// CHECK-NEXT: ├─statement~expression-statement := expression ; +// CHECK-NEXT: │ ├─expression~relational-expression := +// CHECK: └─statement~simple-declaration := +// CHECK-NEXT: ├─simple-declaration := decl-specifier-seq ; +// CHECK: └─simple-declaration := decl-specifier-seq init-declarator-list ; +} diff --git a/clang-tools-extra/pseudo/test/cxx/parameter-decl-clause.cpp b/clang-tools-extra/pseudo/test/cxx/parameter-decl-clause.cpp new file mode 100644 index 0000000000000..1426f4e0a9bc0 --- /dev/null +++ b/clang-tools-extra/pseudo/test/cxx/parameter-decl-clause.cpp @@ -0,0 +1,14 @@ +// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s +void foo2(int, ...); +// CHECK: translation-unit~simple-declaration := decl-specifier-seq init-declarator-list ; +// CHECK-NEXT: ├─decl-specifier-seq~VOID := +// CHECK-NEXT: ├─init-declarator-list~noptr-declarator := noptr-declarator parameters-and-qualifiers +// CHECK-NEXT: │ ├─noptr-declarator~IDENTIFIER := +// CHECK-NEXT: │ └─parameters-and-qualifiers := ( parameter-declaration-clause [recover=Brackets] ) +// CHECK-NEXT: │ ├─( := +// CHECK-NEXT: │ ├─parameter-declaration-clause := parameter-declaration-list , ... +// CHECK-NEXT: │ │ ├─parameter-declaration-list~INT := +// CHECK-NEXT: │ │ ├─, := +// CHECK-NEXT: │ │ └─... := +// CHECK-NEXT: │ └─) := +// CHECK-NEXT: └─; := diff --git a/clang-tools-extra/pseudo/test/cxx/predefined-identifier.cpp b/clang-tools-extra/pseudo/test/cxx/predefined-identifier.cpp new file mode 100644 index 0000000000000..5d48a3a43d027 --- /dev/null +++ b/clang-tools-extra/pseudo/test/cxx/predefined-identifier.cpp @@ -0,0 +1,5 @@ +// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s +void s() { + __func__; + // CHECK: expression~__FUNC__ := tok[5] +} diff --git a/clang-tools-extra/pseudo/test/cxx/recovery-func-parameters.cpp b/clang-tools-extra/pseudo/test/cxx/recovery-func-parameters.cpp new file mode 100644 index 0000000000000..0b41f881fa3bf --- /dev/null +++ b/clang-tools-extra/pseudo/test/cxx/recovery-func-parameters.cpp @@ -0,0 +1,13 @@ +// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s +void foo(complete garbage???) {} +// CHECK: translation-unit~function-definition := decl-specifier-seq function-declarator function-body +// CHECK-NEXT: ├─decl-specifier-seq~VOID := tok[0] +// CHECK-NEXT: ├─function-declarator~noptr-declarator := noptr-declarator parameters-and-qualifiers +// CHECK-NEXT: │ ├─noptr-declarator~IDENTIFIER := tok[1] +// CHECK-NEXT: │ └─parameters-and-qualifiers := ( parameter-declaration-clause [recover=Brackets] ) +// CHECK-NEXT: │ ├─( := tok[2] +// CHECK-NEXT: │ ├─parameter-declaration-clause := +// CHECK-NEXT: │ └─) := tok[8] +// CHECK-NEXT: └─function-body~compound-statement := { } +// CHECK-NEXT: ├─{ := tok[9] +// CHECK-NEXT: └─} := tok[10] diff --git a/clang-tools-extra/pseudo/test/cxx/recovery-init-list.cpp b/clang-tools-extra/pseudo/test/cxx/recovery-init-list.cpp new file mode 100644 index 0000000000000..38216ad964772 --- /dev/null +++ b/clang-tools-extra/pseudo/test/cxx/recovery-init-list.cpp @@ -0,0 +1,13 @@ +// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s +auto x = { complete garbage }; +// CHECK: translation-unit~simple-declaration +// CHECK-NEXT: ├─decl-specifier-seq~AUTO := tok[0] +// CHECK-NEXT: ├─init-declarator-list~init-declarator +// CHECK-NEXT: │ ├─non-function-declarator~IDENTIFIER := tok[1] +// CHECK-NEXT: │ └─initializer~brace-or-equal-initializer +// CHECK-NEXT: │ ├─= := tok[2] +// CHECK-NEXT: │ └─initializer-clause~braced-init-list +// CHECK-NEXT: │ ├─{ := tok[3] +// CHECK-NEXT: │ ├─initializer-list := +// CHECK-NEXT: │ └─} := tok[6] +// CHECK-NEXT: └─; := tok[7] diff --git a/clang-tools-extra/pseudo/test/cxx/structured-binding.cpp b/clang-tools-extra/pseudo/test/cxx/structured-binding.cpp new file mode 100644 index 0000000000000..1c68e928ddd62 --- /dev/null +++ b/clang-tools-extra/pseudo/test/cxx/structured-binding.cpp @@ -0,0 +1,6 @@ +// RUN: clang-pseudo -grammar=cxx -source=%s --start-symbol=statement-seq --print-forest | FileCheck %s + +// Verify there is no false parse of the structured binding declaration. +ABC[post] = abc; +// CHECK: statement-seq~expression-statement := expression ; +// CHECK: postfix-expression [ expr-or-braced-init-list ] diff --git a/clang-tools-extra/pseudo/test/cxx/template-empty-type-parameter.cpp b/clang-tools-extra/pseudo/test/cxx/template-empty-type-parameter.cpp new file mode 100644 index 0000000000000..02aff285f838c --- /dev/null +++ b/clang-tools-extra/pseudo/test/cxx/template-empty-type-parameter.cpp @@ -0,0 +1,3 @@ +// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s +template struct MatchParents; +// CHECK: template-parameter-list~TYPENAME := tok[2] diff --git a/clang-tools-extra/pseudo/test/cxx/unsized-array.cpp b/clang-tools-extra/pseudo/test/cxx/unsized-array.cpp new file mode 100644 index 0000000000000..1f7b106e0e93b --- /dev/null +++ b/clang-tools-extra/pseudo/test/cxx/unsized-array.cpp @@ -0,0 +1,7 @@ +// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s +void s(int[]); +// CHECK: parameter-declaration-clause~parameter-declaration := decl-specifier-seq abstract-declarator +// CHECK-NEXT: ├─decl-specifier-seq~INT := tok[3] +// CHECK-NEXT: └─abstract-declarator~noptr-abstract-declarator := [ ] +// CHECK-NEXT: ├─[ := tok[4] +// CHECK-NEXT: └─] := tok[5] diff --git a/clang-tools-extra/pseudo/test/fuzzer.cpp b/clang-tools-extra/pseudo/test/fuzzer.cpp new file mode 100644 index 0000000000000..400746a9d12d5 --- /dev/null +++ b/clang-tools-extra/pseudo/test/fuzzer.cpp @@ -0,0 +1,4 @@ +// RUN: clang-pseudo-fuzzer -grammar=%cxx-bnf-file -print %s | FileCheck %s +int x; +// CHECK: translation-unit := declaration-seq +// CHECK: builtin-type := INT diff --git a/clang-tools-extra/pseudo/test/glr-variant-start.cpp b/clang-tools-extra/pseudo/test/glr-variant-start.cpp new file mode 100644 index 0000000000000..1bd073707353b --- /dev/null +++ b/clang-tools-extra/pseudo/test/glr-variant-start.cpp @@ -0,0 +1,9 @@ +// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --start-symbol=statement-seq --print-forest | FileCheck %s + +a + a; +// CHECK: statement-seq~expression-statement := expression ; +// CHECK-NEXT: ├─expression~additive-expression := additive-expression + multiplicative-expression +// CHECK-NEXT: │ ├─additive-expression~IDENTIFIER := +// CHECK-NEXT: │ ├─+ := +// CHECK-NEXT: │ └─multiplicative-expression~IDENTIFIER := +// CHECK-NEXT: └─; := diff --git a/clang-tools-extra/pseudo/test/glr.cpp b/clang-tools-extra/pseudo/test/glr.cpp new file mode 100644 index 0000000000000..f805e42ffa6dd --- /dev/null +++ b/clang-tools-extra/pseudo/test/glr.cpp @@ -0,0 +1,30 @@ +// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest -print-statistics | FileCheck %s + +void foo() { + T* a; // a multiply expression or a pointer declaration? +// CHECK: statement-seq~statement := +// CHECK-NEXT: ├─statement~expression-statement := expression ; +// CHECK-NEXT: │ ├─expression~multiplicative-expression := multiplicative-expression * pm-expression +// CHECK-NEXT: │ │ ├─multiplicative-expression~IDENTIFIER := tok[5] +// CHECK-NEXT: │ │ ├─* := tok[6] +// CHECK-NEXT: │ │ └─pm-expression~id-expression := unqualified-id #1 +// CHECK-NEXT: │ │ └─unqualified-id~IDENTIFIER := tok[7] +// CHECK-NEXT: │ └─; := tok[8] +// CHECK-NEXT: └─statement~simple-declaration := decl-specifier-seq init-declarator-list ; +// CHECK-NEXT: ├─decl-specifier-seq~simple-type-specifier := +// CHECK-NEXT: │ ├─simple-type-specifier~IDENTIFIER := tok[5] +// CHECK-NEXT: │ └─simple-type-specifier~IDENTIFIER := tok[5] +// CHECK-NEXT: ├─init-declarator-list~ptr-declarator := ptr-operator ptr-declarator +// CHECK-NEXT: │ ├─ptr-operator~* := tok[6] +// CHECK-NEXT: │ └─ptr-declarator~id-expression =#1 +// CHECK-NEXT: └─; := tok[8] +} + +// CHECK: 2 Ambiguous nodes: +// CHECK-NEXT: 1 simple-type-specifier +// CHECK-NEXT: 1 statement +// CHECK-EMPTY: +// CHECK-NEXT: 0 Opaque nodes: +// CHECK-EMPTY: +// CHECK-NEXT: Ambiguity: 0.20 misparses/token +// CHECK-NEXT: Unparsed: 0.00% diff --git a/clang-tools-extra/pseudo/test/html-forest.c b/clang-tools-extra/pseudo/test/html-forest.c new file mode 100644 index 0000000000000..0be08da49f4a7 --- /dev/null +++ b/clang-tools-extra/pseudo/test/html-forest.c @@ -0,0 +1,8 @@ +// RUN: clang-pseudo -source %s -html-forest=%t.html +// RUN: FileCheck %s < %t.html +int main() { +} +// Sanity check for some obvious strings. +// CHECK-DAG: +// CHECK-DAG: "compound-statement" +// CHECK-DAG: main diff --git a/clang-tools-extra/pseudo/test/lex.c b/clang-tools-extra/pseudo/test/lex.c new file mode 100644 index 0000000000000..ebebd2e0fb72f --- /dev/null +++ b/clang-tools-extra/pseudo/test/lex.c @@ -0,0 +1,42 @@ +int is_debug() { +#ifndef NDEBUG + return 1; // in debug mode +#else + return 0; +#endif +} + +/* This comment gets lexed along with the input above! We just don't CHECK it. + +RUN: clang-pseudo -source %s -print-source | FileCheck %s -check-prefix=SOURCE --strict-whitespace + SOURCE: int is_debug() { +SOURCE-NEXT: #ifndef NDEBUG +SOURCE-NEXT: return 1; // in debug mode +SOURCE-NEXT: #else +SOURCE-NEXT: return 0; +SOURCE-NEXT: #end +SOURCE-NEXT: } + +RUN: clang-pseudo -source %s -print-tokens | FileCheck %s -check-prefix=TOKEN + TOKEN: 0: raw_identifier 0:0 "int" flags=1 +TOKEN-NEXT: raw_identifier 0:0 "is_debug" +TOKEN-NEXT: l_paren 0:0 "(" +TOKEN-NEXT: r_paren 0:0 ")" +TOKEN-NEXT: l_brace 0:0 "{" +TOKEN-NEXT: hash 1:0 "#" flags=1 +TOKEN-NEXT: raw_identifier 1:0 "ifndef" +TOKEN-NEXT: raw_identifier 1:0 "NDEBUG" +TOKEN-NEXT: raw_identifier 2:2 "return" flags=1 +TOKEN-NEXT: numeric_constant 2:2 "1" +TOKEN-NEXT: semi 2:2 ";" +TOKEN-NEXT: comment 2:2 "// in debug mode" +TOKEN-NEXT: hash 3:0 "#" flags=1 +TOKEN-NEXT: raw_identifier 3:0 "else" +TOKEN-NEXT: raw_identifier 4:2 "return" flags=1 +TOKEN-NEXT: numeric_constant 4:2 "0" +TOKEN-NEXT: semi 4:2 ";" +TOKEN-NEXT: hash 5:0 "#" flags=1 +TOKEN-NEXT: raw_identifier 5:0 "endif" +TOKEN-NEXT: r_brace 6:0 "}" flags=1 + +*******************************************************************************/ diff --git a/clang-tools-extra/pseudo/test/lit.cfg.py b/clang-tools-extra/pseudo/test/lit.cfg.py new file mode 100644 index 0000000000000..2ba1558b2ed7d --- /dev/null +++ b/clang-tools-extra/pseudo/test/lit.cfg.py @@ -0,0 +1,20 @@ +import lit.llvm + +lit.llvm.initialize(lit_config, config) +lit.llvm.llvm_config.use_default_substitutions() + +config.name = "ClangPseudo" +config.suffixes = [".test", ".c", ".cpp"] +config.excludes = ["Inputs"] +config.test_format = lit.formats.ShTest(not lit.llvm.llvm_config.use_lit_shell) +config.test_source_root = config.clang_pseudo_source_dir + "/test" +config.test_exec_root = config.clang_pseudo_binary_dir + "/test" + +config.environment["PATH"] = os.path.pathsep.join( + (config.clang_tools_dir, config.llvm_tools_dir, config.environment["PATH"]) +) + +# It is not realistically possible to account for all options that could +# possibly be present in system and user configuration files, so disable +# default configs for the test runs. +config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1" diff --git a/clang-tools-extra/pseudo/test/lit.local.cfg b/clang-tools-extra/pseudo/test/lit.local.cfg new file mode 100644 index 0000000000000..53079a0b538ae --- /dev/null +++ b/clang-tools-extra/pseudo/test/lit.local.cfg @@ -0,0 +1,2 @@ +cxx_bnf_file = os.path.join(config.clang_pseudo_source_dir, "lib", "cxx", "cxx.bnf") +config.substitutions.append(("%cxx-bnf-file", cxx_bnf_file)) diff --git a/clang-tools-extra/pseudo/test/lit.site.cfg.py.in b/clang-tools-extra/pseudo/test/lit.site.cfg.py.in new file mode 100644 index 0000000000000..3a969381ca613 --- /dev/null +++ b/clang-tools-extra/pseudo/test/lit.site.cfg.py.in @@ -0,0 +1,14 @@ +@LIT_SITE_CFG_IN_HEADER@ + +# Variables needed for common llvm config. +config.clang_tools_dir = "@CURRENT_TOOLS_DIR@" +config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" +config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@") +config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@") +config.target_triple = "@TARGET_TRIPLE@" +config.python_executable = "@Python3_EXECUTABLE@" + +config.clang_pseudo_source_dir = "@CMAKE_CURRENT_SOURCE_DIR@/.." +config.clang_pseudo_binary_dir = "@CMAKE_CURRENT_BINARY_DIR@/.." +# Delegate logic to lit.cfg.py. +lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py") diff --git a/clang-tools-extra/pseudo/test/lr-build-basic.test b/clang-tools-extra/pseudo/test/lr-build-basic.test new file mode 100644 index 0000000000000..13036349eb8c1 --- /dev/null +++ b/clang-tools-extra/pseudo/test/lr-build-basic.test @@ -0,0 +1,32 @@ +_ := expr EOF +expr := id +id := IDENTIFIER + +# RUN: clang-pseudo -grammar %s -print-graph | FileCheck %s --check-prefix=GRAPH +# GRAPH: States: +# GRAPH-NEXT: State 0 +# GRAPH-NEXT: _ := • expr EOF +# GRAPH-NEXT: expr := • id +# GRAPH-NEXT: id := • IDENTIFIER +# GRAPH-NEXT: State 1 +# GRAPH-NEXT: _ := expr • EOF +# GRAPH-NEXT: State 2 +# GRAPH-NEXT: expr := id • +# GRAPH-NEXT: State 3 +# GRAPH-NEXT: id := IDENTIFIER • +# GRAPH-NEXT: State 4 +# GRAPH-NEXT: _ := expr EOF • + +# RUN: clang-pseudo -grammar %s -print-table | FileCheck %s --check-prefix=TABLE +# TABLE: LRTable: +# TABLE-NEXT: State 0 +# TABLE-NEXT: IDENTIFIER: shift state 3 +# TABLE-NEXT: expr: go to state 1 +# TABLE-NEXT: id: go to state 2 +# TABLE-NEXT: State 1 +# TABLE-NEXT: EOF: shift state 4 +# TABLE-NEXT: State 2 +# TABLE-NEXT: EOF: reduce by rule 2 'expr := id' +# TABLE-NEXT: State 3 +# TABLE-NEXT: EOF: reduce by rule 1 'id := IDENTIFIER' +# TABLE-NEXT: State 4 diff --git a/clang-tools-extra/pseudo/test/lr-build-conflicts.test b/clang-tools-extra/pseudo/test/lr-build-conflicts.test new file mode 100644 index 0000000000000..a66ce4d622ca1 --- /dev/null +++ b/clang-tools-extra/pseudo/test/lr-build-conflicts.test @@ -0,0 +1,49 @@ +_ := expr EOF +expr := expr - expr # S/R conflict at state 4 on '-' token +expr := IDENTIFIER + +# RUN: clang-pseudo -grammar %s -print-graph | FileCheck %s --check-prefix=GRAPH +# GRAPH: States +# GRAPH-NEXT: State 0 +# GRAPH-NEXT: _ := • expr EOF +# GRAPH-NEXT: expr := • expr - expr +# GRAPH-NEXT: expr := • IDENTIFIER +# GRAPH-NEXT: State 1 +# GRAPH-NEXT: _ := expr • EOF +# GRAPH-NEXT: expr := expr • - expr +# GRAPH-NEXT: State 2 +# GRAPH-NEXT: expr := IDENTIFIER • +# GRAPH-NEXT: State 3 +# GRAPH-NEXT: _ := expr EOF • +# GRAPH-NEXT: State 4 +# GRAPH-NEXT: expr := • expr - expr +# GRAPH-NEXT: expr := expr - • expr +# GRAPH-NEXT: expr := • IDENTIFIER +# GRAPH-NEXT: State 5 +# GRAPH-NEXT: expr := expr - expr • +# GRAPH-NEXT: expr := expr • - expr +# GRAPH-NEXT: 0 ->[expr] 1 +# GRAPH-NEXT: 0 ->[IDENTIFIER] 2 +# GRAPH-NEXT: 1 ->[EOF] 3 +# GRAPH-NEXT: 1 ->[-] 4 +# GRAPH-NEXT: 4 ->[expr] 5 +# GRAPH-NEXT: 4 ->[IDENTIFIER] 2 +# GRAPH-NEXT: 5 ->[-] 4 + +# RUN: clang-pseudo -grammar %s -print-table | FileCheck %s --check-prefix=TABLE +# TABLE: LRTable: +# TABLE-NEXT: State 0 +# TABLE-NEXT: IDENTIFIER: shift state 2 +# TABLE-NEXT: expr: go to state 1 +# TABLE-NEXT: State 1 +# TABLE-NEXT: EOF: shift state 3 +# TABLE-NEXT: -: shift state 4 +# TABLE-NEXT: State 2 +# TABLE-NEXT: EOF -: reduce by rule 2 'expr := IDENTIFIER' +# TABLE-NEXT: State 3 +# TABLE-NEXT: State 4 +# TABLE-NEXT: IDENTIFIER: shift state 2 +# TABLE-NEXT: expr: go to state 5 +# TABLE-NEXT: State 5 +# TABLE-NEXT: -: shift state 4 +# TABLE-NEXT: EOF -: reduce by rule 1 'expr := expr - expr' diff --git a/clang-tools-extra/pseudo/test/strip-directives.c b/clang-tools-extra/pseudo/test/strip-directives.c new file mode 100644 index 0000000000000..c7878d9295a08 --- /dev/null +++ b/clang-tools-extra/pseudo/test/strip-directives.c @@ -0,0 +1,49 @@ +#include +int main() { +#error This was inevitable... +#if HELLO + printf("hello, world\n"); + return 0; +#else + abort(); +#endif +} + +/* This comment gets lexed along with the input above! We just don't CHECK it. + +RUN: clang-pseudo -source %s -print-directive-tree | FileCheck %s -check-prefix=PPT --strict-whitespace + PPT: #include (7 tokens) +PPT-NEXT: code (5 tokens) +PPT-NEXT: #error (6 tokens) +PPT-NEXT: #if (3 tokens) TAKEN +PPT-NEXT: code (8 tokens) +PPT-NEXT: #else (2 tokens) +PPT-NEXT: code (4 tokens) +PPT-NEXT: #endif (2 tokens) +PPT-NEXT: code (2 tokens) + ^ including this block comment + +RUN: clang-pseudo -source %s -strip-directives -print-source | FileCheck %s --strict-whitespace + CHECK: int main() { +CHECK-NEXT: printf("hello, world\n"); +CHECK-NEXT: return 0; +CHECK-NEXT: } + +RUN: clang-pseudo -source %s -strip-directives -print-tokens | FileCheck %s --check-prefix=TOKEN + TOKEN: 0: raw_identifier 1:0 "int" flags=1 +TOKEN-NEXT: raw_identifier 1:0 "main" +TOKEN-NEXT: l_paren 1:0 "(" +TOKEN-NEXT: r_paren 1:0 ")" +TOKEN-NEXT: l_brace 1:0 "{" +TOKEN-NEXT: raw_identifier 4:2 "printf" flags=1 +TOKEN-NEXT: l_paren 4:2 "(" +TOKEN-NEXT: string_literal 4:2 "\22hello, world\\n\22" +TOKEN-NEXT: r_paren 4:2 ")" +TOKEN-NEXT: semi 4:2 ";" +TOKEN-NEXT: raw_identifier 5:2 "return" flags=1 +TOKEN-NEXT: numeric_constant 5:2 "0" +TOKEN-NEXT: semi 5:2 ";" +TOKEN-NEXT: r_brace 9:0 "}" flags=1 + +*******************************************************************************/ + diff --git a/clang-tools-extra/pseudo/tool/CMakeLists.txt b/clang-tools-extra/pseudo/tool/CMakeLists.txt new file mode 100644 index 0000000000000..bead383228396 --- /dev/null +++ b/clang-tools-extra/pseudo/tool/CMakeLists.txt @@ -0,0 +1,30 @@ +set(LLVM_LINK_COMPONENTS support) + +add_clang_tool(clang-pseudo + ClangPseudo.cpp + HTMLForest.cpp + ) + +clang_target_link_libraries(clang-pseudo + PRIVATE + clangBasic + ) + +target_link_libraries(clang-pseudo + PRIVATE + clangPseudo + clangPseudoGrammar + clangPseudoCLI + ) + +add_custom_command(OUTPUT HTMLForestResources.inc + COMMAND "${Python3_EXECUTABLE}" ${CLANG_SOURCE_DIR}/utils/bundle_resources.py + ${CMAKE_CURRENT_BINARY_DIR}/HTMLForestResources.inc + HTMLForest.css HTMLForest.js HTMLForest.html + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "Bundling HTMLForest resources" + DEPENDS ${CLANG_SOURCE_DIR}/utils/bundle_resources.py HTMLForest.css HTMLForest.js HTMLForest.html + VERBATIM) +add_custom_target(clang-pseudo-resources DEPENDS HTMLForestResources.inc) +set_target_properties(clang-pseudo-resources PROPERTIES FOLDER "Clang Tools Extra/Resources") +add_dependencies(clang-pseudo clang-pseudo-resources) diff --git a/clang-tools-extra/pseudo/tool/ClangPseudo.cpp b/clang-tools-extra/pseudo/tool/ClangPseudo.cpp new file mode 100644 index 0000000000000..6a64760749cef --- /dev/null +++ b/clang-tools-extra/pseudo/tool/ClangPseudo.cpp @@ -0,0 +1,243 @@ +//===-- ClangPseudo.cpp - Clang pseudoparser tool -------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/Bracket.h" +#include "clang-pseudo/DirectiveTree.h" +#include "clang-pseudo/Disambiguate.h" +#include "clang-pseudo/Forest.h" +#include "clang-pseudo/GLR.h" +#include "clang-pseudo/Language.h" +#include "clang-pseudo/Token.h" +#include "clang-pseudo/cli/CLI.h" +#include "clang-pseudo/grammar/Grammar.h" +#include "clang-pseudo/grammar/LRGraph.h" +#include "clang-pseudo/grammar/LRTable.h" +#include "clang/Basic/LangOptions.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/STLFunctionalExtras.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/Signals.h" +#include + +using clang::pseudo::ForestNode; +using clang::pseudo::Token; +using clang::pseudo::TokenStream; +using llvm::cl::desc; +using llvm::cl::init; +using llvm::cl::opt; + +static opt PrintGrammar("print-grammar", desc("Print the grammar")); +static opt PrintGraph("print-graph", + desc("Print the LR graph for the grammar")); +static opt PrintTable("print-table", + desc("Print the LR table for the grammar")); +static opt Source("source", desc("Source file")); +static opt PrintSource("print-source", desc("Print token stream")); +static opt PrintTokens("print-tokens", desc("Print detailed token info")); +static opt + PrintDirectiveTree("print-directive-tree", + desc("Print directive structure of source code")); +static opt + StripDirectives("strip-directives", + desc("Strip directives and select conditional sections")); +static opt Disambiguate("disambiguate", + desc("Choose best tree from parse forest")); +static opt PrintStatistics("print-statistics", desc("Print GLR parser statistics")); +static opt PrintForest("print-forest", desc("Print parse forest")); +static opt ForestAbbrev("forest-abbrev", desc("Abbreviate parse forest"), + init(true)); +static opt HTMLForest("html-forest", + desc("output file for HTML forest")); +static opt StartSymbol("start-symbol", + desc("Specify the start symbol to parse"), + init("translation-unit")); + +static std::string readOrDie(llvm::StringRef Path) { + llvm::ErrorOr> Text = + llvm::MemoryBuffer::getFile(Path); + if (std::error_code EC = Text.getError()) { + llvm::errs() << "Error: can't read file '" << Path + << "': " << EC.message() << "\n"; + ::exit(1); + } + return Text.get()->getBuffer().str(); +} + +namespace clang { +namespace pseudo { +// Defined in HTMLForest.cpp +void writeHTMLForest(llvm::raw_ostream &OS, const Grammar &, + const ForestNode &Root, const Disambiguation &, + const TokenStream &); +namespace { + +struct NodeStats { + unsigned Total = 0; + std::vector> BySymbol; + + NodeStats(const ForestNode &Root, + llvm::function_ref Filter) { + llvm::DenseMap Map; + for (const ForestNode &N : Root.descendants()) + if (Filter(N)) { + ++Total; + ++Map[N.symbol()]; + } + BySymbol = {Map.begin(), Map.end()}; + // Sort by count descending, then symbol ascending. + llvm::sort(BySymbol, [](const auto &L, const auto &R) { + return std::tie(R.second, L.first) < std::tie(L.second, R.first); + }); + } +}; + +} // namespace +} // namespace pseudo +} // namespace clang + +int main(int argc, char *argv[]) { + llvm::cl::ParseCommandLineOptions(argc, argv, ""); + llvm::sys::PrintStackTraceOnErrorSignal(argv[0]); + + clang::LangOptions LangOpts = clang::pseudo::genericLangOpts(); + std::string SourceText; + std::optional RawStream; + std::optional PreprocessedStream; + std::optional ParseableStream; + if (Source.getNumOccurrences()) { + SourceText = readOrDie(Source); + RawStream = clang::pseudo::lex(SourceText, LangOpts); + TokenStream *Stream = &*RawStream; + + auto DirectiveStructure = clang::pseudo::DirectiveTree::parse(*RawStream); + clang::pseudo::chooseConditionalBranches(DirectiveStructure, *RawStream); + + std::optional Preprocessed; + if (StripDirectives) { + Preprocessed = DirectiveStructure.stripDirectives(*Stream); + Stream = &*Preprocessed; + } + + if (PrintSource) + Stream->print(llvm::outs()); + if (PrintTokens) + llvm::outs() << *Stream; + if (PrintDirectiveTree) + llvm::outs() << DirectiveStructure; + + ParseableStream = clang::pseudo::stripComments(cook(*Stream, LangOpts)); + pairBrackets(*ParseableStream); + } + + const auto &Lang = clang::pseudo::getLanguageFromFlags(); + if (PrintGrammar) + llvm::outs() << Lang.G.dump(); + if (PrintGraph) + llvm::outs() << clang::pseudo::LRGraph::buildLR0(Lang.G).dumpForTests( + Lang.G); + + if (PrintTable) + llvm::outs() << Lang.Table.dumpForTests(Lang.G); + if (PrintStatistics) + llvm::outs() << Lang.Table.dumpStatistics(); + + if (ParseableStream) { + clang::pseudo::ForestArena Arena; + clang::pseudo::GSS GSS; + std::optional StartSymID = + Lang.G.findNonterminal(StartSymbol); + if (!StartSymID) { + llvm::errs() << llvm::formatv( + "The start symbol {0} doesn't exit in the grammar!\n", StartSymbol); + return 2; + } + auto &Root = + glrParse(clang::pseudo::ParseParams{*ParseableStream, Arena, GSS}, + *StartSymID, Lang); + // If we're disambiguating, we'll print at the end instead. + if (PrintForest && !Disambiguate) + llvm::outs() << Root.dumpRecursive(Lang.G, /*Abbreviated=*/ForestAbbrev); + clang::pseudo::Disambiguation Disambig; + if (Disambiguate) + Disambig = clang::pseudo::disambiguate(&Root, {}); + + if (HTMLForest.getNumOccurrences()) { + std::error_code EC; + llvm::raw_fd_ostream HTMLOut(HTMLForest, EC); + if (EC) { + llvm::errs() << "Couldn't write " << HTMLForest << ": " << EC.message() + << "\n"; + return 2; + } + clang::pseudo::writeHTMLForest(HTMLOut, Lang.G, Root, Disambig, + *ParseableStream); + } + + if (PrintStatistics) { + llvm::outs() << "Forest bytes: " << Arena.bytes() + << " nodes: " << Arena.nodeCount() << "\n"; + llvm::outs() << "GSS bytes: " << GSS.bytes() + << " nodes: " << GSS.nodesCreated() << "\n"; + + for (auto &P : {std::make_pair("Ambiguous", ForestNode::Ambiguous), + std::make_pair("Opaque", ForestNode::Opaque)}) { + clang::pseudo::NodeStats Stats( + Root, [&](const auto &N) { return N.kind() == P.second; }); + llvm::outs() << "\n" << Stats.Total << " " << P.first << " nodes:\n"; + for (const auto &S : Stats.BySymbol) + llvm::outs() << llvm::formatv(" {0,3} {1}\n", S.second, + Lang.G.symbolName(S.first)); + } + + // Metrics for how imprecise parsing was. + // These are rough but aim to be: + // - linear: if we eliminate half the errors the metric should halve + // - length-independent + unsigned UnparsedTokens = 0; // Tokens covered by Opaque. (not unique) + unsigned Misparses = 0; // Sum of alternatives-1 + llvm::DenseSet Visited; + auto DFS = [&](const ForestNode &N, Token::Index End, auto &DFS) -> void { + if (N.kind() == ForestNode::Opaque) { + UnparsedTokens += End - N.startTokenIndex(); + } else if (N.kind() == ForestNode::Ambiguous) { + Misparses += N.alternatives().size() - 1; + for (const auto *C : N.alternatives()) + if (Visited.insert(C).second) + DFS(*C, End, DFS); + } else if (N.kind() == ForestNode::Sequence) { + for (unsigned I = 0, E = N.children().size(); I < E; ++I) + if (Visited.insert(N.children()[I]).second) + DFS(*N.children()[I], + I + 1 == N.children().size() + ? End + : N.children()[I + 1]->startTokenIndex(), + DFS); + } + }; + unsigned Len = ParseableStream->tokens().size(); + DFS(Root, Len, DFS); + llvm::outs() << "\n"; + llvm::outs() << llvm::formatv("Ambiguity: {0} misparses/token\n", + double(Misparses) / Len); + llvm::outs() << llvm::formatv("Unparsed: {0}%\n", + 100.0 * UnparsedTokens / Len); + } + + if (Disambiguate && PrintForest) { + ForestNode *DisambigRoot = &Root; + removeAmbiguities(DisambigRoot, Disambig); + llvm::outs() << "Disambiguated tree:\n"; + llvm::outs() << DisambigRoot->dumpRecursive(Lang.G, + /*Abbreviated=*/ForestAbbrev); + } + } + + return 0; +} diff --git a/clang-tools-extra/pseudo/tool/HTMLForest.cpp b/clang-tools-extra/pseudo/tool/HTMLForest.cpp new file mode 100644 index 0000000000000..184430bddd8d6 --- /dev/null +++ b/clang-tools-extra/pseudo/tool/HTMLForest.cpp @@ -0,0 +1,192 @@ +//===-- HTMLForest.cpp - browser-based parse forest explorer +//---------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// The plain text forest node dump (clang-pseudo -print-forest) is useful but +// hard to reconcile with the code being examined, especially when it is large. +// +// HTMLForest produces a self-contained HTML file containing both the code and +// the forest representation, linking them interactively with javascript. +// At any given time, a single parse tree is shown (ambiguities resolved). +// The user can switch between ambiguous alternatives. +// +// +-------+---------------+ +// | | +-----+| +// | #tree | #code |#info|| +// | | +-----+| +// | | | +// +-------+---------------+ +// +// #tree is a hierarchical view of the nodes (nested
    s), like -print-forest. +// (It is a simple tree, not a DAG, because ambiguities have been resolved). +// Like -print-forest, trivial sequences are collapsed (expression~IDENTIFIER). +// +// #code is the source code, annotated with s marking the node ranges. +// These spans are usually invisible (exception: ambiguities are marked), but +// they are used to show and change the selection. +// +// #info is a floating box that shows details of the currently selected node: +// - rule (for sequence nodes). Abbreviated rules are also shown. +// - alternatives (for ambiguous nodes). The user can choose an alternative. +// - ancestors. The parent nodes show how this node fits in translation-unit. +// +// There are two types of 'active' node: +// - *highlight* is what the cursor is over, and is colored blue. +// Near ancestors are shaded faintly (onion-skin) to show local structure. +// - *selection* is set by clicking. +// The #info box shows the selection, and selected nodes have a dashed ring. +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/Disambiguate.h" +#include "clang-pseudo/Forest.h" +#include "clang-pseudo/grammar/Grammar.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/Support/JSON.h" +#include "llvm/Support/raw_ostream.h" +namespace clang { +namespace pseudo { +namespace { + +// Defines const char HTMLForest_css[] = "...contents of HTMLForest.css..."; etc +#include "HTMLForestResources.inc" + +struct Writer { + llvm::raw_ostream &Out; + const Grammar &G; + const ForestNode &Root; + const TokenStream &Stream; + const Disambiguation &Disambig; + + void write() { + Out << "\n"; + tag("html", [&] { + tag("head", [&] { + tag("title", [&] { Out << "HTMLForest"; }); + tag("script", [&] { Out << HTMLForest_js; }); + tag("style", [&] { Out << HTMLForest_css; }); + tag("script", [&] { + Out << "var forest="; + writeForestJSON(); + Out << ";"; + }); + tag("pre id='hidden-code' hidden", [&] { writeCode(); }); + }); + tag("body", [&] { Out << HTMLForest_html; }); + }); + } + + void writeCode(); + void writeForestJSON(); + void tag(llvm::StringRef Opener, llvm::function_ref Body) { + Out << "<" << Opener << ">"; + Body(); + Out << "\n"; + } +}; + +void Writer::writeCode() { + // This loop (whitespace logic) is cribbed from TokenStream::Print. + bool FirstToken = true; + unsigned LastLine = -1; + StringRef LastText; + for (const auto &T : Stream.tokens()) { + StringRef Text = T.text(); + if (FirstToken) { + FirstToken = false; + } else if (T.Line == LastLine) { + if (LastText.data() + LastText.size() != Text.data()) + Out << ' '; + } else { + Out << " \n"; // Extra space aids selection. + Out.indent(T.Indent); + } + Out << ""; + llvm::printHTMLEscaped(Text, Out); + Out << ""; + LastLine = T.Line; + LastText = Text; + } + if (!FirstToken) + Out << '\n'; +} + +// Writes a JSON array of forest nodes. Items are e.g.: +// {kind:'sequence', symbol:'compound-stmt', children:[5,8,33], +// rule:'compound-stmt := ...'} {kind:'terminal', symbol:'VOID', token:'t52'} +// {kind:'ambiguous', symbol:'type-specifier', children:[3,100] selected:3} +// {kind:'opaque', symbol:'statement-seq', firstToken:'t5', lastToken:'t6'} +void Writer::writeForestJSON() { + // This is the flat array of nodes: the index into this array is the node ID. + std::vector> Sequence; + llvm::DenseMap Index; + auto AssignID = [&](const ForestNode *N, Token::Index End) -> unsigned { + auto R = Index.try_emplace(N, Sequence.size()); + if (R.second) + Sequence.push_back({N, End}); + return R.first->second; + }; + AssignID(&Root, Stream.tokens().size()); + auto TokenID = [](Token::Index I) { return ("t" + llvm::Twine(I)).str(); }; + + llvm::json::OStream Out(this->Out, 2); + Out.array([&] { + for (unsigned I = 0; I < Sequence.size(); ++I) { + const ForestNode *N = Sequence[I].first; + Token::Index End = Sequence[I].second; + Out.object([&] { + Out.attribute("symbol", G.symbolName(N->symbol())); + switch (N->kind()) { + case ForestNode::Terminal: + Out.attribute("kind", "terminal"); + Out.attribute("token", TokenID(N->startTokenIndex())); + break; + case ForestNode::Sequence: + Out.attribute("kind", "sequence"); + Out.attribute("rule", G.dumpRule(N->rule())); + break; + case ForestNode::Ambiguous: + Out.attribute("kind", "ambiguous"); + Out.attribute("selected", + AssignID(N->children()[Disambig.lookup(N)], End)); + break; + case ForestNode::Opaque: + Out.attribute("kind", "opaque"); + Out.attribute("firstToken", TokenID(N->startTokenIndex())); + // [firstToken, lastToken] is a closed range. + // If empty, lastToken is omitted. + if (N->startTokenIndex() != End) + Out.attribute("lastToken", TokenID(End - 1)); + break; + } + auto Children = N->children(); + if (!Children.empty()) + Out.attributeArray("children", [&] { + for (unsigned I = 0; I < Children.size(); ++I) + Out.value(AssignID(Children[I], + I + 1 == Children.size() + ? End + : Children[I + 1]->startTokenIndex())); + }); + }); + } + }); +} + +} // namespace + +// We only accept the derived stream here. +// FIXME: allow the original stream instead? +void writeHTMLForest(llvm::raw_ostream &OS, const Grammar &G, + const ForestNode &Root, const Disambiguation &Disambig, + const TokenStream &Stream) { + Writer{OS, G, Root, Stream, Disambig}.write(); +} + +} // namespace pseudo +} // namespace clang diff --git a/clang-tools-extra/pseudo/tool/HTMLForest.css b/clang-tools-extra/pseudo/tool/HTMLForest.css new file mode 100644 index 0000000000000..674cd59f0e76b --- /dev/null +++ b/clang-tools-extra/pseudo/tool/HTMLForest.css @@ -0,0 +1,93 @@ +body { + position: absolute; + top: 0; + bottom: 0; + right: 0; + left: 0; + + display: flex; + align-items: stretch; + margin: 0; + font-family: sans-serif; + white-space: nowrap; + height: 100%; +} +body > * { + overflow-y: auto; /* Scroll sections independently*/ + margin: 0; +} + +#code { + font-size: 18px; + line-height: 36px; + flex-grow: 1; + padding-right: 10em; /* Leave space for #info */ +} +#code span { + padding: 9px 0; /* No "gaps" between lines due to line-height */ +} +.node.ambiguous::before, .ancestors.ambiguous::after, .tree-node.ambiguous > header::after { + content: /*the thinking man's emoji*/'\01F914'; +} + +#info { + position: fixed; + right: 2em; + top: 1em; + width: 25em; + border: 1px solid black; + min-height: 20em; + background-color: whiteSmoke; + overflow-x: clip; + box-shadow: 3px 3px 5px rgba(0,0,0,0.2); +} +#info header { + background-color: black; + color: white; + font-size: larger; + padding: 0.5em; +} +#info.ambiguous header { background-color: #803; } +#info.sequence header { background-color: darkBlue; } +#info.terminal header { background-color: darkGreen; } +#info.opaque header { background-color: orangeRed; } +#i_kind { + float: right; + font-size: small; +} +#info section { + padding: 0.5em; + border-top: 1px solid lightGray; + overflow-x: auto; +} +#i_ancestors { font-size: small; } + +#tree { + flex-grow: 0; + min-width: 20em; + margin-right: 1em; + border-right: 1px solid darkGray; + background-color: azure; + font-size: small; + overflow-x: auto; + resize: horizontal; +} +#tree ul { + margin: 0; + display: inline-block; + padding-left: 6px; + border-left: 1px solid rgba(0,0,0,0.2); + list-style: none; +} +#tree > ul { border-left: none; } +.tree-node.selected > header .name { font-weight: bold; } +.tree-node.terminal .name { font-family: monospace; } +.tree-node.ambiguous > header .name { color: #803; font-weight: bold; } +.tree-node.sequence > header .name { color: darkBlue; } +.tree-node.terminal > header .name { color: darkGreen; } +.tree-node.opaque > header .name { color: orangeRed; } + +.selected { outline: 1px dashed black; } +.abbrev { opacity: 50%; } +.abbrev::after { content: '~'; } +.opaque { background-color: bisque; } diff --git a/clang-tools-extra/pseudo/tool/HTMLForest.html b/clang-tools-extra/pseudo/tool/HTMLForest.html new file mode 100644 index 0000000000000..4cf98cbbb2cc9 --- /dev/null +++ b/clang-tools-extra/pseudo/tool/HTMLForest.html @@ -0,0 +1,15 @@ +
      +
      
      +
      diff --git a/clang-tools-extra/pseudo/tool/HTMLForest.js b/clang-tools-extra/pseudo/tool/HTMLForest.js
      new file mode 100644
      index 0000000000000..24b88a5c10b47
      --- /dev/null
      +++ b/clang-tools-extra/pseudo/tool/HTMLForest.js
      @@ -0,0 +1,290 @@
      +// The global map of forest node index => NodeView.
      +views = [];
      +// NodeView is a visible forest node.
      +// It has an entry in the navigation tree, and a span in the code itself.
      +// Each NodeView is associated with a forest node, but not all nodes have views:
      +// - nodes not reachable though current ambiguity selection
      +// - trivial "wrapping" sequence nodes are abbreviated away
      +class NodeView {
      +  // Builds a node representing forest[index], or its target if it is a wrapper.
      +  // Registers the node in the global map.
      +  static make(index, parent, abbrev) {
      +    var node = forest[index];
      +    if (node.kind == 'sequence' && node.children.length == 1 &&
      +        forest[node.children[0]].kind != 'ambiguous') {
      +      abbrev ||= [];
      +      abbrev.push(index);
      +      return NodeView.make(node.children[0], parent, abbrev);
      +    }
      +    return views[index] = new NodeView(index, parent, node, abbrev);
      +  }
      +
      +  constructor(index, parent, node, abbrev) {
      +    this.abbrev = abbrev || [];
      +    this.parent = parent;
      +    this.children =
      +        (node.kind == 'ambiguous' ? [ node.selected ] : node.children || [])
      +            .map((c) => NodeView.make(c, this));
      +    this.index = index;
      +    this.node = node;
      +    views[index] = this;
      +
      +    this.span = this.buildSpan();
      +    this.tree = this.buildTree();
      +  }
      +
      +  // Replaces the token sequence in #code with a .
      +  buildSpan() {
      +    var elt = document.createElement('span');
      +    elt.dataset['index'] = this.index;
      +    elt.classList.add("node");
      +    elt.classList.add("selectable-node");
      +    elt.classList.add(this.node.kind);
      +
      +    var begin = null, end = null;
      +    if (this.children.length != 0) {
      +      begin = this.children[0].span;
      +      end = this.children[this.children.length - 1].span.nextSibling;
      +    } else if (this.node.kind == 'terminal') {
      +      begin = document.getElementById(this.node.token);
      +      end = begin.nextSibling;
      +    } else if (this.node.kind == 'opaque') {
      +      begin = document.getElementById(this.node.firstToken);
      +      end = (this.node.lastToken == null)
      +                ? begin
      +                : document.getElementById(this.node.lastToken).nextSibling;
      +    }
      +    var parent = begin.parentNode;
      +    splice(begin, end, elt);
      +    parent.insertBefore(elt, end);
      +    return elt;
      +  }
      +
      +  // Returns a (detached) 
    • suitable for use in #tree. + buildTree() { + var elt = document.createElement('li'); + elt.dataset['index'] = this.index; + elt.classList.add('tree-node'); + elt.classList.add('selectable-node'); + elt.classList.add(this.node.kind); + var header = document.createElement('header'); + elt.appendChild(header); + + if (this.abbrev.length > 0) { + var abbrev = document.createElement('span'); + abbrev.classList.add('abbrev'); + abbrev.innerText = forest[this.abbrev[0]].symbol; + header.appendChild(abbrev); + } + var name = document.createElement('span'); + name.classList.add('name'); + name.innerText = this.node.symbol; + header.appendChild(name); + + if (this.children.length != 0) { + var sublist = document.createElement('ul'); + this.children.forEach((c) => sublist.appendChild(c.tree)); + elt.appendChild(sublist); + } + return elt; + } + + // Make this view visible on the screen by scrolling if needed. + scrollVisible() { + scrollIntoViewV(document.getElementById('tree'), this.tree.firstChild); + scrollIntoViewV(document.getElementById('code'), this.span); + } + + // Fill #info with details of this node. + renderInfo() { + document.getElementById('info').classList = this.node.kind; + document.getElementById('i_symbol').innerText = this.node.symbol; + document.getElementById('i_kind').innerText = this.node.kind; + + // For sequence nodes, add LHS := RHS rule. + // If this node abbreviates trivial sequences, we want those rules too. + var rules = document.getElementById('i_rules'); + rules.textContent = ''; + function addRule(i) { + var ruleText = forest[i].rule; + if (ruleText == null) + return; + var rule = document.createElement('div'); + rule.classList.add('rule'); + rule.innerText = ruleText; + rules.insertBefore(rule, rules.firstChild); + } + this.abbrev.forEach(addRule); + addRule(this.index); + + // For ambiguous nodes, show a selectable list of alternatives. + var alternatives = document.getElementById('i_alternatives'); + alternatives.textContent = ''; + var that = this; + function addAlternative(i) { + var altNode = forest[i]; + var text = altNode.rule || altNode.kind; + var alt = document.createElement('div'); + alt.classList.add('alternative'); + alt.innerText = text; + alt.dataset['index'] = i; + alt.dataset['parent'] = that.index; + if (i == that.node.selected) + alt.classList.add('selected'); + alternatives.appendChild(alt); + } + if (this.node.kind == 'ambiguous') + this.node.children.forEach(addAlternative); + + // Show the stack of ancestor nodes. + // The part of each rule that leads to the current node is bolded. + var ancestors = document.getElementById('i_ancestors'); + ancestors.textContent = ''; + var child = this; + for (var view = this.parent; view != null; + child = view, view = view.parent) { + var indexInParent = view.children.indexOf(child); + + var ctx = document.createElement('div'); + ctx.classList.add('ancestors'); + ctx.classList.add('selectable-node'); + ctx.classList.add(view.node.kind); + if (view.node.rule) { + // Rule syntax is LHS := RHS1 [annotation] RHS2. + // We walk through the chunks and bold the one at parentInIndex. + var chunkCount = 0; + ctx.innerHTML = view.node.rule.replaceAll(/[^ ]+/g, function(match) { + if (!(match.startsWith('[') && match.endsWith(']')) /*annotations*/ + && chunkCount++ == indexInParent + 2 /*skip LHS :=*/) + return '' + match + ''; + return match; + }); + } else /*ambiguous*/ { + ctx.innerHTML = '' + view.node.symbol + ''; + } + ctx.dataset['index'] = view.index; + if (view.abbrev.length > 0) { + var abbrev = document.createElement('span'); + abbrev.classList.add('abbrev'); + abbrev.innerText = forest[view.abbrev[0]].symbol; + ctx.insertBefore(abbrev, ctx.firstChild); + } + + ctx.dataset['index'] = view.index; + ancestors.appendChild(ctx, ancestors.firstChild); + } + } + + remove() { + this.children.forEach((c) => c.remove()); + splice(this.span.firstChild, null, this.span.parentNode, + this.span.nextSibling); + detach(this.span); + delete views[this.index]; + } +}; + +var selection = null; +function selectView(view) { + var old = selection; + selection = view; + if (view == old) + return; + + if (old) { + old.tree.classList.remove('selected'); + old.span.classList.remove('selected'); + } + document.getElementById('info').hidden = (view == null); + if (!view) + return; + view.tree.classList.add('selected'); + view.span.classList.add('selected'); + view.renderInfo(); + view.scrollVisible(); +} + +// To highlight nodes on hover, we create dynamic CSS rules of the form +// .selectable-node[data-index="42"] { background-color: blue; } +// This avoids needing to find all the related nodes and update their classes. +var highlightSheet = new CSSStyleSheet(); +document.adoptedStyleSheets.push(highlightSheet); +function highlightView(view) { + var text = ''; + for (const color of ['#6af', '#bbb', '#ddd', '#eee']) { + if (view == null) + break; + text += '.selectable-node[data-index="' + view.index + '"] ' + text += '{ background-color: ' + color + '; }\n'; + view = view.parent; + } + highlightSheet.replace(text); +} + +// Select which branch of an ambiguous node is taken. +function chooseAlternative(parent, index) { + var parentView = views[parent]; + parentView.node.selected = index; + var oldChild = parentView.children[0]; + oldChild.remove(); + var newChild = NodeView.make(index, parentView); + parentView.children[0] = newChild; + parentView.tree.lastChild.replaceChild(newChild.tree, oldChild.tree); + + highlightView(null); + // Force redraw of the info box. + selectView(null); + selectView(parentView); +} + +// Attach event listeners and build content once the document is ready. +document.addEventListener("DOMContentLoaded", function() { + var code = document.getElementById('code'); + var tree = document.getElementById('tree'); + var ancestors = document.getElementById('i_ancestors'); + var alternatives = document.getElementById('i_alternatives'); + + [code, tree, ancestors].forEach(function(container) { + container.addEventListener('click', function(e) { + var nodeElt = e.target.closest('.selectable-node'); + selectView(nodeElt && views[Number(nodeElt.dataset['index'])]); + }); + container.addEventListener('mousemove', function(e) { + var nodeElt = e.target.closest('.selectable-node'); + highlightView(nodeElt && views[Number(nodeElt.dataset['index'])]); + }); + }); + + alternatives.addEventListener('click', function(e) { + var altElt = e.target.closest('.alternative'); + if (altElt) + chooseAlternative(Number(altElt.dataset['parent']), + Number(altElt.dataset['index'])); + }); + + // The HTML provides #code content in a hidden DOM element, move it. + var hiddenCode = document.getElementById('hidden-code'); + splice(hiddenCode.firstChild, hiddenCode.lastChild, code); + detach(hiddenCode); + + // Build the tree of NodeViews and attach to #tree. + tree.firstChild.appendChild(NodeView.make(0).tree); +}); + +// Helper DOM functions // + +// Moves the sibling range [first, until) into newParent. +function splice(first, until, newParent, before) { + for (var next = first; next != until;) { + var elt = next; + next = next.nextSibling; + newParent.insertBefore(elt, before); + } +} +function detach(node) { node.parentNode.removeChild(node); } +// Like scrollIntoView, but vertical only! +function scrollIntoViewV(container, elt) { + if (container.scrollTop > elt.offsetTop + elt.offsetHeight || + container.scrollTop + container.clientHeight < elt.offsetTop) + container.scrollTo({top : elt.offsetTop, behavior : 'smooth'}); +} diff --git a/clang-tools-extra/pseudo/unittests/BracketTest.cpp b/clang-tools-extra/pseudo/unittests/BracketTest.cpp new file mode 100644 index 0000000000000..2fbfc64151364 --- /dev/null +++ b/clang-tools-extra/pseudo/unittests/BracketTest.cpp @@ -0,0 +1,117 @@ +//===--- BracketTest.cpp -------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/Bracket.h" +#include "clang-pseudo/Token.h" +#include "clang/Basic/LangOptions.h" +#include "llvm/Testing/Annotations/Annotations.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +namespace clang { +namespace pseudo { + +// Return a version of Code with each paired bracket marked with ^. +std::string decorate(llvm::StringRef Code, const TokenStream &Stream) { + std::string Result; + const char *Pos = Code.data(); + for (const Token &Tok : Stream.tokens()) { + if (Tok.Pair == 0) + continue; + const char *NewPos = Tok.text().begin(); + assert(NewPos >= Code.begin() && NewPos < Code.end()); + Result.append(Pos, NewPos - Pos); + Result.push_back('^'); + Pos = NewPos; + } + Result.append(Pos, Code.end() - Pos); + return Result; +} + +// Checks that the brackets matched in Stream are those annotated in MarkedCode. +void verifyMatchedSet(llvm::StringRef Code, llvm::StringRef MarkedCode, + const TokenStream &Stream) { + EXPECT_EQ(MarkedCode, decorate(Code, Stream)); +} + +// Checks that paired brackets within the stream nest properly. +void verifyNesting(const TokenStream &Stream) { + std::vector Stack; + for (const auto &Tok : Stream.tokens()) { + if (Tok.Pair > 0) + Stack.push_back(&Tok); + else if (Tok.Pair < 0) { + ASSERT_FALSE(Stack.empty()) << Tok; + ASSERT_EQ(Stack.back(), Tok.pair()) + << *Stack.back() << " != " << *Tok.pair() << " = pair of " << Tok; + Stack.pop_back(); + } + } + ASSERT_THAT(Stack, testing::IsEmpty()); +} + +// Checks that ( pairs with a ) on its right, etc. +void verifyMatchKind(const TokenStream &Stream) { + for (const auto &Tok : Stream.tokens()) { + if (Tok.Pair == 0) + continue; + auto Want = [&]() -> std::pair { + switch (Tok.Kind) { + case tok::l_paren: + return {true, tok::r_paren}; + case tok::r_paren: + return {false, tok::l_paren}; + case tok::l_brace: + return {true, tok::r_brace}; + case tok::r_brace: + return {false, tok::l_brace}; + case tok::l_square: + return {true, tok::r_square}; + case tok::r_square: + return {false, tok::l_square}; + default: + ADD_FAILURE() << "Paired non-bracket " << Tok; + return {false, tok::eof}; + } + }(); + EXPECT_EQ(Tok.Pair > 0, Want.first) << Tok; + EXPECT_EQ(Tok.pair()->Kind, Want.second) << Tok; + } +} + +// Verifies an expected bracket pairing like: +// ^( [ ^) +// The input is annotated code, with the brackets expected to be matched marked. +// +// The input doesn't specify which bracket matches with which, but we verify: +// - exactly the marked subset are paired +// - ( is paired to a later ), etc +// - brackets properly nest +// This uniquely determines the bracket structure, so we indirectly verify it. +// If particular tests should emphasize which brackets are paired, use comments. +void verifyBrackets(llvm::StringRef MarkedCode) { + SCOPED_TRACE(MarkedCode); + llvm::Annotations A(MarkedCode); + std::string Code = A.code().str(); + LangOptions LangOpts; + auto Stream = lex(Code, LangOpts); + pairBrackets(Stream); + + verifyMatchedSet(Code, MarkedCode, Stream); + verifyNesting(Stream); + verifyMatchKind(Stream); +} + +TEST(Bracket, SimplePair) { + verifyBrackets("^{ ^[ ^( ^) ^( ^) ^] ^}"); + verifyBrackets(") ^{ ^[ ^] ^} ("); + verifyBrackets("{ [ ( ] }"); // FIXME +} + +} // namespace pseudo +} // namespace clang diff --git a/clang-tools-extra/pseudo/unittests/CMakeLists.txt b/clang-tools-extra/pseudo/unittests/CMakeLists.txt new file mode 100644 index 0000000000000..53583ceb61864 --- /dev/null +++ b/clang-tools-extra/pseudo/unittests/CMakeLists.txt @@ -0,0 +1,32 @@ +set(LLVM_LINK_COMPONENTS + Support + ) + +add_custom_target(ClangPseudoUnitTests) +set_target_properties(ClangPseudoUnitTests PROPERTIES FOLDER "Clang Tools Extra/Tests") +add_unittest(ClangPseudoUnitTests ClangPseudoTests + BracketTest.cpp + CXXTest.cpp + DirectiveTreeTest.cpp + DisambiguateTest.cpp + ForestTest.cpp + GLRTest.cpp + GrammarTest.cpp + LRTableTest.cpp + TokenTest.cpp +) + +clang_target_link_libraries(ClangPseudoTests + PRIVATE + clangBasic + clangLex + ) + +target_link_libraries(ClangPseudoTests + PRIVATE + clangPseudo + clangPseudoCXX + clangPseudoGrammar + LLVMTestingAnnotations + LLVMTestingSupport + ) diff --git a/clang-tools-extra/pseudo/unittests/CXXTest.cpp b/clang-tools-extra/pseudo/unittests/CXXTest.cpp new file mode 100644 index 0000000000000..505f958ae7556 --- /dev/null +++ b/clang-tools-extra/pseudo/unittests/CXXTest.cpp @@ -0,0 +1,30 @@ +//===--- CXXTest.cpp ------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/cxx/CXX.h" +#include "gtest/gtest.h" + +namespace clang { +namespace pseudo { +namespace cxx { +namespace { + +TEST(CXX, GeneratedEnums) { + const auto &Lang = clang::pseudo::cxx::getLanguage(); + EXPECT_EQ("iteration-statement", + Lang.G.symbolName(Symbol::iteration_statement)); + EXPECT_EQ("iteration-statement := DO statement WHILE ( expression ) ;", + Lang.G.dumpRule( + rule::iteration_statement:: + DO__statement__WHILE__L_PAREN__expression__R_PAREN__SEMI)); +} + +} // namespace +} // namespace cxx +} // namespace pseudo +} // namespace clang diff --git a/clang-tools-extra/pseudo/unittests/DirectiveTreeTest.cpp b/clang-tools-extra/pseudo/unittests/DirectiveTreeTest.cpp new file mode 100644 index 0000000000000..19e5e0526142a --- /dev/null +++ b/clang-tools-extra/pseudo/unittests/DirectiveTreeTest.cpp @@ -0,0 +1,357 @@ +//===--- DirectiveTreeTest.cpp --------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/DirectiveTree.h" + +#include "clang-pseudo/Token.h" +#include "clang/Basic/LangOptions.h" +#include "clang/Basic/TokenKinds.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringRef.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +namespace clang { +namespace pseudo { +namespace { + +using testing::_; +using testing::ElementsAre; +using testing::Matcher; +using testing::Pair; +using testing::StrEq; +using Chunk = DirectiveTree::Chunk; + +// Matches text of a list of tokens against a string (joined with spaces). +// e.g. EXPECT_THAT(Stream.tokens(), tokens("int main ( ) { }")); +MATCHER_P(tokens, Tokens, "") { + std::vector Texts; + for (const Token &Tok : arg) + Texts.push_back(Tok.text()); + return Matcher(StrEq(Tokens)) + .MatchAndExplain(llvm::join(Texts, " "), result_listener); +} + +// Matches tokens covered a directive chunk (with a Tokens property) against a +// string, similar to tokens() above. +// e.g. EXPECT_THAT(SomeDirective, tokensAre(Stream, "# include < vector >")); +MATCHER_P2(tokensAre, TS, Tokens, "tokens are " + std::string(Tokens)) { + return testing::Matches(tokens(Tokens))(TS.tokens(arg.Tokens)); +} + +MATCHER(directiveChunk, "") { + return std::holds_alternative(arg); +} +MATCHER(codeChunk, "") { + return std::holds_alternative(arg); +} +MATCHER(conditionalChunk, "") { + return std::holds_alternative(arg); +} + +TEST(DirectiveTree, Parse) { + LangOptions Opts; + std::string Code = R"cpp( + #include + + int main() { + #ifdef HAS_FOO + #if HAS_BAR + foo(bar); + #else + foo(0) + #endif + #elif NEEDS_FOO + #error missing_foo + #endif + } + )cpp"; + + TokenStream S = cook(lex(Code, Opts), Opts); + DirectiveTree PP = DirectiveTree::parse(S); + ASSERT_THAT(PP.Chunks, ElementsAre(directiveChunk(), codeChunk(), + conditionalChunk(), codeChunk())); + + EXPECT_THAT(std::get(PP.Chunks[0]), + tokensAre(S, "# include < foo . h >")); + EXPECT_THAT(std::get(PP.Chunks[1]), + tokensAre(S, "int main ( ) {")); + EXPECT_THAT(std::get(PP.Chunks[3]), tokensAre(S, "}")); + + const auto &Ifdef = std::get(PP.Chunks[2]); + EXPECT_THAT(Ifdef.Branches, + ElementsAre(Pair(tokensAre(S, "# ifdef HAS_FOO"), _), + Pair(tokensAre(S, "# elif NEEDS_FOO"), _))); + EXPECT_THAT(Ifdef.End, tokensAre(S, "# endif")); + + const DirectiveTree &HasFoo(Ifdef.Branches[0].second); + const DirectiveTree &NeedsFoo(Ifdef.Branches[1].second); + + EXPECT_THAT(HasFoo.Chunks, ElementsAre(conditionalChunk())); + const auto &If = std::get(HasFoo.Chunks[0]); + EXPECT_THAT(If.Branches, ElementsAre(Pair(tokensAre(S, "# if HAS_BAR"), _), + Pair(tokensAre(S, "# else"), _))); + EXPECT_THAT(If.Branches[0].second.Chunks, ElementsAre(codeChunk())); + EXPECT_THAT(If.Branches[1].second.Chunks, ElementsAre(codeChunk())); + + EXPECT_THAT(NeedsFoo.Chunks, ElementsAre(directiveChunk())); + const auto &Error = std::get(NeedsFoo.Chunks[0]); + EXPECT_THAT(Error, tokensAre(S, "# error missing_foo")); + EXPECT_EQ(Error.Kind, tok::pp_error); +} + +TEST(DirectiveTree, ParseUgly) { + LangOptions Opts; + std::string Code = R"cpp( + /*A*/ # /*B*/ \ + /*C*/ \ +define \ +BAR /*D*/ +/*E*/ +)cpp"; + TokenStream S = cook(lex(Code, Opts), Opts); + DirectiveTree PP = DirectiveTree::parse(S); + + ASSERT_THAT(PP.Chunks, + ElementsAre(codeChunk(), directiveChunk(), codeChunk())); + EXPECT_THAT(std::get(PP.Chunks[0]), + tokensAre(S, "/*A*/")); + const auto &Define = std::get(PP.Chunks[1]); + EXPECT_EQ(Define.Kind, tok::pp_define); + EXPECT_THAT(Define, tokensAre(S, "# /*B*/ /*C*/ define BAR /*D*/")); + EXPECT_THAT(std::get(PP.Chunks[2]), + tokensAre(S, "/*E*/")); +} + +TEST(DirectiveTree, ParseBroken) { + LangOptions Opts; + std::string Code = R"cpp( + a + #endif // mismatched + #if X + b +)cpp"; + TokenStream S = cook(lex(Code, Opts), Opts); + DirectiveTree PP = DirectiveTree::parse(S); + + ASSERT_THAT(PP.Chunks, + ElementsAre(codeChunk(), directiveChunk(), conditionalChunk())); + EXPECT_THAT(std::get(PP.Chunks[0]), tokensAre(S, "a")); + const auto &Endif = std::get(PP.Chunks[1]); + EXPECT_EQ(Endif.Kind, tok::pp_endif); + EXPECT_THAT(Endif, tokensAre(S, "# endif // mismatched")); + + const auto &X = std::get(PP.Chunks[2]); + EXPECT_EQ(1u, X.Branches.size()); + // The (only) branch of the broken conditional section runs until eof. + EXPECT_EQ(tok::pp_if, X.Branches.front().first.Kind); + EXPECT_THAT(X.Branches.front().second.Chunks, ElementsAre(codeChunk())); + // The missing terminating directive is marked as pp_not_keyword. + EXPECT_EQ(tok::pp_not_keyword, X.End.Kind); + EXPECT_EQ(0u, X.End.Tokens.size()); +} + +TEST(DirectiveTree, ChooseBranches) { + LangOptions Opts; + const std::string Cases[] = { + R"cpp( + // Branches with no alternatives are taken + #if COND // TAKEN + int x; + #endif + )cpp", + + R"cpp( + // Empty branches are better than nothing + #if COND // TAKEN + #endif + )cpp", + + R"cpp( + // Trivially false branches are not taken, even with no alternatives. + #if 0 + int x; + #endif + )cpp", + + R"cpp( + // Longer branches are preferred over shorter branches + #if COND // TAKEN + int x = 1; + #else + int x; + #endif + + #if COND + int x; + #else // TAKEN + int x = 1; + #endif + )cpp", + + R"cpp( + // Trivially true branches are taken if previous branches are trivial. + #if 1 // TAKEN + #else + int x = 1; + #endif + + #if 0 + int x = 1; + #elif 0 + int x = 2; + #elif 1 // TAKEN + int x; + #endif + + #if 0 + int x = 1; + #elif FOO // TAKEN + int x = 2; + #elif 1 + int x; + #endif + )cpp", + + R"cpp( + // #else is a trivially true branch + #if 0 + int x = 1; + #elif 0 + int x = 2; + #else // TAKEN + int x; + #endif + )cpp", + + R"cpp( + // Directives break ties, but nondirective text is more important. + #if FOO + #define A 1 2 3 + #else // TAKEN + #define B 4 5 6 + #define C 7 8 9 + #endif + + #if FOO // TAKEN + ; + #define A 1 2 3 + #else + #define B 4 5 6 + #define C 7 8 9 + #endif + )cpp", + + R"cpp( + // Avoid #error directives. + #if FOO + int x = 42; + #error This branch is no good + #else // TAKEN + #endif + + #if FOO + // All paths here lead to errors. + int x = 42; + #if 1 // TAKEN + #if COND // TAKEN + #error This branch is no good + #else + #error This one is no good either + #endif + #endif + #else // TAKEN + #endif + )cpp", + + R"cpp( + // Populate taken branches recursively. + #if FOO // TAKEN + int x = 42; + #if BAR + ; + #else // TAKEN + int y = 43; + #endif + #else + int x; + #if BAR // TAKEN + int y; + #else + ; + #endif + #endif + )cpp", + }; + for (const auto &Code : Cases) { + TokenStream S = cook(lex(Code, Opts), Opts); + + std::function Verify = + [&](const DirectiveTree &M) { + for (const auto &C : M.Chunks) { + if (!std::holds_alternative(C)) + continue; + const DirectiveTree::Conditional &Cond = + std::get(C); + for (unsigned I = 0; I < Cond.Branches.size(); ++I) { + auto Directive = S.tokens(Cond.Branches[I].first.Tokens); + EXPECT_EQ(I == Cond.Taken, Directive.back().text() == "// TAKEN") + << "At line " << Directive.front().Line << " of: " << Code; + Verify(Cond.Branches[I].second); + } + } + }; + + DirectiveTree Tree = DirectiveTree::parse(S); + chooseConditionalBranches(Tree, S); + Verify(Tree); + } +} + +TEST(DirectiveTree, StripDirectives) { + LangOptions Opts; + std::string Code = R"cpp( + #include + a a a + #warning AAA + b b b + #if 1 + c c c + #warning BBB + #if 0 + d d d + #warning CC + #else + e e e + #endif + f f f + #if 0 + g g g + #endif + h h h + #else + i i i + #endif + j j j + )cpp"; + TokenStream S = lex(Code, Opts); + + DirectiveTree Tree = DirectiveTree::parse(S); + chooseConditionalBranches(Tree, S); + EXPECT_THAT(Tree.stripDirectives(S).tokens(), + tokens("a a a b b b c c c e e e f f f h h h j j j")); + + const DirectiveTree &Part = + std::get(Tree.Chunks[4]).Branches[0].second; + EXPECT_THAT(Part.stripDirectives(S).tokens(), + tokens("c c c e e e f f f h h h")); +} + +} // namespace +} // namespace pseudo +} // namespace clang diff --git a/clang-tools-extra/pseudo/unittests/DisambiguateTest.cpp b/clang-tools-extra/pseudo/unittests/DisambiguateTest.cpp new file mode 100644 index 0000000000000..2f483bb090660 --- /dev/null +++ b/clang-tools-extra/pseudo/unittests/DisambiguateTest.cpp @@ -0,0 +1,111 @@ +//===--- DisambiguateTest.cpp ---------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/Disambiguate.h" +#include "clang-pseudo/Forest.h" +#include "clang-pseudo/Token.h" +#include "clang/Basic/TokenKinds.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include + +namespace clang { +namespace pseudo { +namespace { +using testing::ElementsAre; +using testing::Pair; +using testing::UnorderedElementsAre; + +// Common disambiguation test fixture. +// This is the ambiguous forest representing parses of 'a * b;'. +class DisambiguateTest : public ::testing::Test { +protected: + // Greatly simplified C++ grammar. + enum Symbol : SymbolID { + Statement, + Declarator, + Expression, + DeclSpecifier, + Type, + Template, + }; + enum Rule : RuleID { + /* LHS__RHS1_RHS2 means LHS := RHS1 RHS2 */ + Statement__DeclSpecifier_Declarator_Semi, + Declarator__Star_Declarator, + Declarator__Identifier, + Statement__Expression_Semi, + Expression__Expression_Star_Expression, + Expression__Identifier, + DeclSpecifier__Type, + DeclSpecifier__Template, + Type__Identifier, + Template__Identifier, + }; + + ForestArena Arena; + ForestNode &A = Arena.createTerminal(tok::identifier, 0); + ForestNode &Star = Arena.createTerminal(tok::star, 1); + ForestNode &B = Arena.createTerminal(tok::identifier, 2); + ForestNode &Semi = Arena.createTerminal(tok::semi, 3); + + // Parse as multiplication expression. + ForestNode &AExpr = + Arena.createSequence(Expression, Expression__Identifier, &A); + ForestNode &BExpr = + Arena.createSequence(Expression, Expression__Identifier, &B); + ForestNode &Expr = + Arena.createSequence(Expression, Expression__Expression_Star_Expression, + {&AExpr, &Star, &BExpr}); + ForestNode &ExprStmt = Arena.createSequence( + Statement, Statement__Expression_Semi, {&Expr, &Semi}); + // Parse as declaration (`a` may be CTAD or not). + ForestNode &AType = + Arena.createSequence(DeclSpecifier, DeclSpecifier__Type, + &Arena.createSequence(Type, Type__Identifier, &A)); + ForestNode &ATemplate = Arena.createSequence( + DeclSpecifier, DeclSpecifier__Template, + &Arena.createSequence(Template, Template__Identifier, &A)); + ForestNode &DeclSpec = + Arena.createAmbiguous(DeclSpecifier, {&AType, &ATemplate}); + ForestNode &BDeclarator = + Arena.createSequence(Declarator, Declarator__Identifier, &B); + ForestNode &BPtr = Arena.createSequence( + Declarator, Declarator__Star_Declarator, {&Star, &BDeclarator}); + ForestNode &DeclStmt = + Arena.createSequence(Statement, Statement__DeclSpecifier_Declarator_Semi, + {&DeclSpec, &Star, &BDeclarator}); + // Top-level ambiguity + ForestNode &Stmt = Arena.createAmbiguous(Statement, {&ExprStmt, &DeclStmt}); +}; + +TEST_F(DisambiguateTest, Remove) { + Disambiguation D; + D.try_emplace(&Stmt, 1); // statement is a declaration, not an expression + D.try_emplace(&DeclSpec, 0); // a is a type, not a (CTAD) template + ForestNode *Root = &Stmt; + removeAmbiguities(Root, D); + + EXPECT_EQ(Root, &DeclStmt); + EXPECT_THAT(DeclStmt.elements(), ElementsAre(&AType, &Star, &BDeclarator)); +} + +TEST_F(DisambiguateTest, DummyStrategy) { + Disambiguation D = disambiguate(&Stmt, {}); + EXPECT_THAT(D, UnorderedElementsAre(Pair(&Stmt, 1), Pair(&DeclSpec, 1))); + + ForestNode *Root = &Stmt; + removeAmbiguities(Root, D); + EXPECT_EQ(Root, &DeclStmt); + EXPECT_THAT(DeclStmt.elements(), + ElementsAre(&ATemplate, &Star, &BDeclarator)); +} + +} // namespace +} // namespace pseudo +} // namespace clang diff --git a/clang-tools-extra/pseudo/unittests/ForestTest.cpp b/clang-tools-extra/pseudo/unittests/ForestTest.cpp new file mode 100644 index 0000000000000..36af896148209 --- /dev/null +++ b/clang-tools-extra/pseudo/unittests/ForestTest.cpp @@ -0,0 +1,180 @@ +//===--- ForestTest.cpp - Test Forest dump ----------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/Forest.h" +#include "clang-pseudo/Token.h" +#include "clang/Basic/LangOptions.h" +#include "llvm/ADT/StringRef.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include + +namespace clang { +namespace pseudo { +namespace { + +// FIXME: extract to a TestGrammar class to allow code sharing among tests. +class ForestTest : public ::testing::Test { +public: + void build(llvm::StringRef BNF) { + Diags.clear(); + G = Grammar::parseBNF(BNF, Diags); + } + + SymbolID symbol(llvm::StringRef Name) const { + for (unsigned I = 0; I < NumTerminals; ++I) + if (G.table().Terminals[I] == Name) + return tokenSymbol(static_cast(I)); + for (SymbolID ID = 0; ID < G.table().Nonterminals.size(); ++ID) + if (G.table().Nonterminals[ID].Name == Name) + return ID; + ADD_FAILURE() << "No such symbol found: " << Name; + return 0; + } + + RuleID ruleFor(llvm::StringRef NonterminalName) const { + auto RuleRange = G.table().Nonterminals[symbol(NonterminalName)].RuleRange; + if (RuleRange.End - RuleRange.Start == 1) + return G.table().Nonterminals[symbol(NonterminalName)].RuleRange.Start; + ADD_FAILURE() << "Expected a single rule for " << NonterminalName + << ", but it has " << RuleRange.End - RuleRange.Start + << " rule!\n"; + return 0; + } + +protected: + Grammar G; + std::vector Diags; +}; + +TEST_F(ForestTest, DumpBasic) { + build(R"cpp( + _ := add-expression EOF + add-expression := id-expression + id-expression + id-expression := IDENTIFIER + )cpp"); + ASSERT_TRUE(Diags.empty()); + ForestArena Arena; + const auto &TS = + cook(lex("a + b", clang::LangOptions()), clang::LangOptions()); + + auto T = Arena.createTerminals(TS); + ASSERT_EQ(T.size(), 4u); + const auto *Left = &Arena.createSequence( + symbol("id-expression"), ruleFor("id-expression"), {&T.front()}); + const auto *Right = &Arena.createSequence(symbol("id-expression"), + ruleFor("id-expression"), {&T[2]}); + + const auto *Add = + &Arena.createSequence(symbol("add-expression"), ruleFor("add-expression"), + {Left, &T[1], Right}); + EXPECT_EQ(Add->dumpRecursive(G, true), + "[ 0, end) add-expression := id-expression + id-expression\n" + "[ 0, 1) ├─id-expression~IDENTIFIER := tok[0]\n" + "[ 1, 2) ├─+ := tok[1]\n" + "[ 2, end) └─id-expression~IDENTIFIER := tok[2]\n"); + EXPECT_EQ(Add->dumpRecursive(G, false), + "[ 0, end) add-expression := id-expression + id-expression\n" + "[ 0, 1) ├─id-expression := IDENTIFIER\n" + "[ 0, 1) │ └─IDENTIFIER := tok[0]\n" + "[ 1, 2) ├─+ := tok[1]\n" + "[ 2, end) └─id-expression := IDENTIFIER\n" + "[ 2, end) └─IDENTIFIER := tok[2]\n"); +} + +TEST_F(ForestTest, DumpAmbiguousAndRefs) { + build(R"cpp( + _ := type EOF + type := class-type # rule 4 + type := enum-type # rule 5 + class-type := shared-type + enum-type := shared-type + shared-type := IDENTIFIER)cpp"); + ASSERT_TRUE(Diags.empty()); + ForestArena Arena; + const auto &TS = cook(lex("abc", clang::LangOptions()), clang::LangOptions()); + + auto Terminals = Arena.createTerminals(TS); + ASSERT_EQ(Terminals.size(), 2u); + + const auto *SharedType = &Arena.createSequence( + symbol("shared-type"), ruleFor("shared-type"), {Terminals.begin()}); + const auto *ClassType = &Arena.createSequence( + symbol("class-type"), ruleFor("class-type"), {SharedType}); + const auto *EnumType = &Arena.createSequence( + symbol("enum-type"), ruleFor("enum-type"), {SharedType}); + const auto *Alternative1 = + &Arena.createSequence(symbol("type"), /*RuleID=*/4, {ClassType}); + const auto *Alternative2 = + &Arena.createSequence(symbol("type"), /*RuleID=*/5, {EnumType}); + const auto *Type = + &Arena.createAmbiguous(symbol("type"), {Alternative1, Alternative2}); + EXPECT_EQ(Type->dumpRecursive(G), + "[ 0, end) type := \n" + "[ 0, end) ├─type := class-type\n" + "[ 0, end) │ └─class-type := shared-type\n" + "[ 0, end) │ └─shared-type := IDENTIFIER #1\n" + "[ 0, end) │ └─IDENTIFIER := tok[0]\n" + "[ 0, end) └─type := enum-type\n" + "[ 0, end) └─enum-type := shared-type\n" + "[ 0, end) └─shared-type =#1\n"); +} + +TEST_F(ForestTest, DumpAbbreviatedShared) { + build(R"cpp( + _ := A + A := B + B := * + )cpp"); + + ForestArena Arena; + const auto *Star = &Arena.createTerminal(tok::star, 0); + + const auto *B = &Arena.createSequence(symbol("B"), ruleFor("B"), {Star}); + // We have two identical (but distinct) A nodes. + // The GLR parser would never produce this, but it makes the example simpler. + const auto *A1 = &Arena.createSequence(symbol("A"), ruleFor("A"), {B}); + const auto *A2 = &Arena.createSequence(symbol("A"), ruleFor("A"), {B}); + const auto *A = &Arena.createAmbiguous(symbol("A"), {A1, A2}); + + // We must not abbreviate away shared nodes: if we show A~* there's no way to + // show that the intermediate B node is shared between A1 and A2. + EXPECT_EQ(A->dumpRecursive(G, /*Abbreviate=*/true), + "[ 0, end) A := \n" + "[ 0, end) ├─A~B := * #1\n" + "[ 0, end) │ └─* := tok[0]\n" + "[ 0, end) └─A~B =#1\n"); +} + +TEST_F(ForestTest, Iteration) { + // Z + // / \ + // X Y + // |\| + // A B + ForestArena Arena; + const auto *A = &Arena.createTerminal(tok::identifier, 0); + const auto *B = &Arena.createOpaque(1, 0); + const auto *X = &Arena.createSequence(2, 1, {A, B}); + const auto *Y = &Arena.createSequence(2, 2, {B}); + const auto *Z = &Arena.createAmbiguous(2, {X, Y}); + + std::vector Nodes; + for (const ForestNode &N : Z->descendants()) + Nodes.push_back(&N); + EXPECT_THAT(Nodes, testing::UnorderedElementsAre(A, B, X, Y, Z)); + + Nodes.clear(); + for (const ForestNode &N : X->descendants()) + Nodes.push_back(&N); + EXPECT_THAT(Nodes, testing::UnorderedElementsAre(X, A, B)); +} + +} // namespace +} // namespace pseudo +} // namespace clang diff --git a/clang-tools-extra/pseudo/unittests/GLRTest.cpp b/clang-tools-extra/pseudo/unittests/GLRTest.cpp new file mode 100644 index 0000000000000..f361fb78247ac --- /dev/null +++ b/clang-tools-extra/pseudo/unittests/GLRTest.cpp @@ -0,0 +1,789 @@ +//===--- GLRTest.cpp - Test the GLR parser ----------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/GLR.h" +#include "clang-pseudo/Bracket.h" +#include "clang-pseudo/Language.h" +#include "clang-pseudo/Token.h" +#include "clang-pseudo/grammar/Grammar.h" +#include "clang/Basic/LangOptions.h" +#include "clang/Basic/TokenKinds.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/Support/FormatVariadic.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include + +namespace clang { +namespace pseudo { + +llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, + const std::vector &Heads) { + for (const auto *Head : Heads) + OS << *Head << "\n"; + return OS; +} + +namespace { + +using StateID = LRTable::StateID; +using testing::AllOf; +using testing::ElementsAre; +using testing::IsEmpty; +using testing::UnorderedElementsAre; + +MATCHER_P(state, StateID, "") { return arg->State == StateID; } +MATCHER_P(parsedSymbol, FNode, "") { return arg->Payload == FNode; } +MATCHER_P(parsedSymbolID, SID, "") { return arg->Payload->symbol() == SID; } +MATCHER_P(start, Start, "") { return arg->Payload->startTokenIndex() == Start; } + +testing::Matcher +parents(llvm::ArrayRef Parents) { + return testing::Property(&GSS::Node::parents, + testing::UnorderedElementsAreArray(Parents)); +} + +Token::Index recoverBraces(Token::Index Begin, const TokenStream &Code) { + EXPECT_GT(Begin, 0u); + const Token &Left = Code.tokens()[Begin - 1]; + EXPECT_EQ(Left.Kind, tok::l_brace); + if (const auto* Right = Left.pair()) { + EXPECT_EQ(Right->Kind, tok::r_brace); + return Code.index(*Right); + } + return Token::Invalid; +} + +class GLRTest : public ::testing::Test { +public: + void build(llvm::StringRef GrammarBNF) { + std::vector Diags; + TestLang.G = Grammar::parseBNF(GrammarBNF, Diags); + } + + TokenStream emptyTokenStream() { + TokenStream Empty; + Empty.finalize(); + return Empty; + } + + void buildGrammar(std::vector Nonterminals, + std::vector Rules) { + Nonterminals.push_back("_"); + llvm::sort(Nonterminals); + Nonterminals.erase(std::unique(Nonterminals.begin(), Nonterminals.end()), + Nonterminals.end()); + std::string FakeTestBNF; + for (const auto &NT : Nonterminals) + FakeTestBNF += llvm::formatv("{0} := {1}\n", "_", NT); + FakeTestBNF += llvm::join(Rules, "\n"); + build(FakeTestBNF); + } + + SymbolID id(llvm::StringRef Name) const { + for (unsigned I = 0; I < NumTerminals; ++I) + if (TestLang.G.table().Terminals[I] == Name) + return tokenSymbol(static_cast(I)); + for (SymbolID ID = 0; ID < TestLang.G.table().Nonterminals.size(); ++ID) + if (TestLang.G.table().Nonterminals[ID].Name == Name) + return ID; + ADD_FAILURE() << "No such symbol found: " << Name; + return 0; + } + ExtensionID extensionID(llvm::StringRef AttrValueName) const { + for (ExtensionID EID = 0; EID < TestLang.G.table().AttributeValues.size(); + ++EID) + if (TestLang.G.table().AttributeValues[EID] == AttrValueName) + return EID; + ADD_FAILURE() << "No such attribute value found: " << AttrValueName; + return 0; + } + + RuleID ruleFor(llvm::StringRef NonterminalName) const { + auto RuleRange = + TestLang.G.table().Nonterminals[id(NonterminalName)].RuleRange; + if (RuleRange.End - RuleRange.Start == 1) + return TestLang.G.table() + .Nonterminals[id(NonterminalName)] + .RuleRange.Start; + ADD_FAILURE() << "Expected a single rule for " << NonterminalName + << ", but it has " << RuleRange.End - RuleRange.Start + << " rule!\n"; + return 0; + } + +protected: + Language TestLang; + ForestArena Arena; + GSS GSStack; +}; + +TEST_F(GLRTest, ShiftMergingHeads) { + // Given a test case where we have two heads 1, 2, 3 in the GSS, the heads 1, + // 2 have shift actions to reach state 4, and the head 3 has a shift action to + // reach state 5: + // 0--1 + // â””--2 + // â””--3 + // After the shift action, the GSS (with new heads 4, 5) is: + // 0---1---4 + // â””---2---┘ + // â””---3---5 + auto *GSSNode0 = + GSStack.addNode(/*State=*/0, /*ForestNode=*/nullptr, /*Parents=*/{}); + auto *GSSNode1 = GSStack.addNode(/*State=*/1, /*ForestNode=*/nullptr, + /*Parents=*/{GSSNode0}); + auto *GSSNode2 = GSStack.addNode(/*State=*/2, /*ForestNode=*/nullptr, + /*Parents=*/{GSSNode0}); + auto *GSSNode3 = GSStack.addNode(/*State=*/3, /*ForestNode=*/nullptr, + /*Parents=*/{GSSNode0}); + + buildGrammar({}, {}); // Create a fake empty grammar. + LRTable::Builder B(TestLang.G); + B.Transition[{StateID{1}, tokenSymbol(tok::semi)}] = StateID{4}; + B.Transition[{StateID{2}, tokenSymbol(tok::semi)}] = StateID{4}; + B.Transition[{StateID{3}, tokenSymbol(tok::semi)}] = StateID{5}; + TestLang.Table = std::move(B).build(); + + ForestNode &SemiTerminal = Arena.createTerminal(tok::semi, 0); + std::vector NewHeads; + glrShift({GSSNode1, GSSNode2, GSSNode3}, SemiTerminal, + {emptyTokenStream(), Arena, GSStack}, TestLang, NewHeads); + + EXPECT_THAT(NewHeads, + UnorderedElementsAre(AllOf(state(4), parsedSymbol(&SemiTerminal), + parents({GSSNode1, GSSNode2})), + AllOf(state(5), parsedSymbol(&SemiTerminal), + parents({GSSNode3})))) + << NewHeads; +} + +TEST_F(GLRTest, ReduceConflictsSplitting) { + // Before (splitting due to R/R conflict): + // 0--1(IDENTIFIER) + // After reducing 1 by `class-name := IDENTIFIER` and + // `enum-name := IDENTIFIER`: + // 0--2(class-name) // 2 is goto(0, class-name) + // â””--3(enum-name) // 3 is goto(0, enum-name) + buildGrammar({"class-name", "enum-name"}, + {"class-name := IDENTIFIER", "enum-name := IDENTIFIER"}); + LRTable::Builder B(TestLang.G); + B.Transition[{StateID{0}, id("class-name")}] = StateID{2}; + B.Transition[{StateID{0}, id("enum-name")}] = StateID{3}; + B.Reduce[StateID{1}].insert(ruleFor("class-name")); + B.Reduce[StateID{1}].insert(ruleFor("enum-name")); + TestLang.Table = std::move(B).build(); + + const auto *GSSNode0 = + GSStack.addNode(/*State=*/0, /*ForestNode=*/nullptr, /*Parents=*/{}); + const auto *GSSNode1 = + GSStack.addNode(1, &Arena.createTerminal(tok::identifier, 0), {GSSNode0}); + + std::vector Heads = {GSSNode1}; + glrReduce(Heads, tokenSymbol(tok::eof), + {emptyTokenStream(), Arena, GSStack}, TestLang); + EXPECT_THAT(Heads, UnorderedElementsAre( + GSSNode1, + AllOf(state(2), parsedSymbolID(id("class-name")), + parents({GSSNode0})), + AllOf(state(3), parsedSymbolID(id("enum-name")), + parents({GSSNode0})))) + << Heads; +} + +TEST_F(GLRTest, ReduceSplittingDueToMultipleBases) { + // Before (splitting due to multiple bases): + // 2(class-name)--4(*) + // 3(enum-name)---┘ + // After reducing 4 by `ptr-operator := *`: + // 2(class-name)--5(ptr-operator) // 5 is goto(2, ptr-operator) + // 3(enum-name)---6(ptr-operator) // 6 is goto(3, ptr-operator) + buildGrammar({"ptr-operator", "class-name", "enum-name"}, + {"ptr-operator := *"}); + + auto *ClassNameNode = &Arena.createOpaque(id("class-name"), /*TokenIndex=*/0); + auto *EnumNameNode = &Arena.createOpaque(id("enum-name"), /*TokenIndex=*/0); + + const auto *GSSNode2 = + GSStack.addNode(/*State=*/2, /*ForestNode=*/ClassNameNode, /*Parents=*/{}); + const auto *GSSNode3 = + GSStack.addNode(/*State=*/3, /*ForestNode=*/EnumNameNode, /*Parents=*/{}); + const auto *GSSNode4 = GSStack.addNode( + /*State=*/4, &Arena.createTerminal(tok::star, /*TokenIndex=*/1), + /*Parents=*/{GSSNode2, GSSNode3}); + + LRTable::Builder B(TestLang.G); + B.Transition[{StateID{2}, id("ptr-operator")}] = StateID{5}; + B.Transition[{StateID{3}, id("ptr-operator")}] = StateID{6}; + B.Reduce[StateID{4}].insert(ruleFor("ptr-operator")); + TestLang.Table = std::move(B).build(); + + std::vector Heads = {GSSNode4}; + glrReduce(Heads, tokenSymbol(tok::eof), {emptyTokenStream(), Arena, GSStack}, + TestLang); + + EXPECT_THAT(Heads, UnorderedElementsAre( + GSSNode4, + AllOf(state(5), parsedSymbolID(id("ptr-operator")), + parents({GSSNode2})), + AllOf(state(6), parsedSymbolID(id("ptr-operator")), + parents({GSSNode3})))) + << Heads; + // Verify that the payload of the two new heads is shared, only a single + // ptr-operator node is created in the forest. + EXPECT_EQ(Heads[1]->Payload, Heads[2]->Payload); +} + +TEST_F(GLRTest, ReduceJoiningWithMultipleBases) { + // Before (joining due to same goto state, multiple bases): + // 0--1(cv-qualifier)--3(class-name) + // â””--2(cv-qualifier)--4(enum-name) + // After reducing 3 by `type-name := class-name` and + // 4 by `type-name := enum-name`: + // 0--1(cv-qualifier)--5(type-name) // 5 is goto(1, type-name) and + // â””--2(cv-qualifier)--┘ // goto(2, type-name) + buildGrammar({"type-name", "class-name", "enum-name", "cv-qualifier"}, + {"type-name := class-name", "type-name := enum-name"}); + + auto *CVQualifierNode = + &Arena.createOpaque(id("cv-qualifier"), /*TokenIndex=*/0); + auto *ClassNameNode = &Arena.createOpaque(id("class-name"), /*TokenIndex=*/1); + auto *EnumNameNode = &Arena.createOpaque(id("enum-name"), /*TokenIndex=*/1); + + const auto *GSSNode0 = + GSStack.addNode(/*State=*/0, /*ForestNode=*/nullptr, /*Parents=*/{}); + const auto *GSSNode1 = GSStack.addNode( + /*State=*/1, /*ForestNode=*/CVQualifierNode, /*Parents=*/{GSSNode0}); + const auto *GSSNode2 = GSStack.addNode( + /*State=*/2, /*ForestNode=*/CVQualifierNode, /*Parents=*/{GSSNode0}); + const auto *GSSNode3 = GSStack.addNode( + /*State=*/3, /*ForestNode=*/ClassNameNode, + /*Parents=*/{GSSNode1}); + const auto *GSSNode4 = + GSStack.addNode(/*State=*/4, /*ForestNode=*/EnumNameNode, + /*Parents=*/{GSSNode2}); + + // FIXME: figure out a way to get rid of the hard-coded reduce RuleID! + LRTable::Builder B(TestLang.G); + B.Transition[{StateID{1}, id("type-name")}] = StateID{5}; + B.Transition[{StateID{2}, id("type-name")}] = StateID{5}; + B.Reduce[StateID{3}].insert(/* type-name := class-name */ RuleID{0}); + B.Reduce[StateID{4}].insert(/* type-name := enum-name */ RuleID{1}); + TestLang.Table = std::move(B).build(); + + std::vector Heads = {GSSNode3, GSSNode4}; + glrReduce(Heads, tokenSymbol(tok::eof), {emptyTokenStream(), Arena, GSStack}, + TestLang); + + // Verify that the stack heads are joint at state 5 after reduces. + EXPECT_THAT(Heads, UnorderedElementsAre(GSSNode3, GSSNode4, + AllOf(state(5), + parsedSymbolID(id("type-name")), + parents({GSSNode1, GSSNode2})))) + << Heads; + // Verify that we create an ambiguous ForestNode of two parses of `type-name`. + EXPECT_EQ(Heads.back()->Payload->dumpRecursive(TestLang.G), + "[ 1, end) type-name := \n" + "[ 1, end) ├─type-name := class-name\n" + "[ 1, end) │ └─class-name := \n" + "[ 1, end) └─type-name := enum-name\n" + "[ 1, end) └─enum-name := \n"); +} + +TEST_F(GLRTest, ReduceJoiningWithSameBase) { + // Before (joining due to same goto state, the same base): + // 0--1(class-name)--3(*) + // â””--2(enum-name)--4(*) + // After reducing 3 by `pointer := class-name *` and + // 2 by `pointer := enum-name *`: + // 0--5(pointer) // 5 is goto(0, pointer) + buildGrammar({"pointer", "class-name", "enum-name"}, + {"pointer := class-name *", "pointer := enum-name *"}); + + auto *ClassNameNode = &Arena.createOpaque(id("class-name"), /*TokenIndex=*/0); + auto *EnumNameNode = &Arena.createOpaque(id("enum-name"), /*TokenIndex=*/0); + auto *StartTerminal = &Arena.createTerminal(tok::star, /*TokenIndex=*/1); + + const auto *GSSNode0 = + GSStack.addNode(/*State=*/0, /*ForestNode=*/nullptr, /*Parents=*/{}); + const auto *GSSNode1 = + GSStack.addNode(/*State=*/1, /*ForestNode=*/ClassNameNode, + /*Parents=*/{GSSNode0}); + const auto *GSSNode2 = + GSStack.addNode(/*State=*/2, /*ForestNode=*/EnumNameNode, + /*Parents=*/{GSSNode0}); + const auto *GSSNode3 = + GSStack.addNode(/*State=*/3, /*ForestNode=*/StartTerminal, + /*Parents=*/{GSSNode1}); + const auto *GSSNode4 = + GSStack.addNode(/*State=*/4, /*ForestNode=*/StartTerminal, + /*Parents=*/{GSSNode2}); + + // FIXME: figure out a way to get rid of the hard-coded reduce RuleID! + LRTable::Builder B(TestLang.G); + B.Transition[{StateID{0}, id("pointer")}] = StateID{5}; + B.Reduce[StateID{3}].insert(/* pointer := class-name */ RuleID{0}); + B.Reduce[StateID{4}].insert(/* pointer := enum-name */ RuleID{1}); + TestLang.Table = std::move(B).build(); + + std::vector Heads = {GSSNode3, GSSNode4}; + glrReduce(Heads, tokenSymbol(tok::eof), + {emptyTokenStream(), Arena, GSStack}, TestLang); + + EXPECT_THAT( + Heads, UnorderedElementsAre(GSSNode3, GSSNode4, + AllOf(state(5), parsedSymbolID(id("pointer")), + parents({GSSNode0})))) + << Heads; + EXPECT_EQ(Heads.back()->Payload->dumpRecursive(TestLang.G), + "[ 0, end) pointer := \n" + "[ 0, end) ├─pointer := class-name *\n" + "[ 0, 1) │ ├─class-name := \n" + "[ 1, end) │ └─* := tok[1]\n" + "[ 0, end) └─pointer := enum-name *\n" + "[ 0, 1) ├─enum-name := \n" + "[ 1, end) └─* := tok[1]\n"); +} + +TEST_F(GLRTest, ReduceLookahead) { + // A term can be followed by +, but not by -. + buildGrammar({"sum", "term"}, {"expr := term + term", "term := IDENTIFIER"}); + LRTable::Builder B(TestLang.G); + B.Transition[{StateID{0}, id("term")}] = StateID{2}; + B.Reduce[StateID{1}].insert(RuleID{0}); + TestLang.Table = std::move(B).build(); + + auto *Identifier = &Arena.createTerminal(tok::identifier, /*Start=*/0); + + const auto *Root = + GSStack.addNode(/*State=*/0, /*ForestNode=*/nullptr, /*Parents=*/{}); + const auto *GSSNode1 = + GSStack.addNode(/*State=*/1, /*ForestNode=*/Identifier, {Root}); + + // When the lookahead is +, reduce is performed. + std::vector Heads = {GSSNode1}; + glrReduce(Heads, tokenSymbol(tok::plus), {emptyTokenStream(), Arena, GSStack}, + TestLang); + EXPECT_THAT(Heads, + ElementsAre(GSSNode1, AllOf(state(2), parsedSymbolID(id("term")), + parents(Root)))); + + // When the lookahead is -, reduce is not performed. + Heads = {GSSNode1}; + glrReduce(Heads, tokenSymbol(tok::minus), + {emptyTokenStream(), Arena, GSStack}, TestLang); + EXPECT_THAT(Heads, ElementsAre(GSSNode1)); +} + +TEST_F(GLRTest, Recover) { + // Recovery while parsing "word" inside braces. + // Before: + // 0--1({)--2(?) + // After recovering a `word` at state 1: + // 0--3(word) // 3 is goto(1, word) + buildGrammar({"word", "top"}, {"top := { word [recover=Braces] }"}); + LRTable::Builder B(TestLang.G); + B.Transition[{StateID{1}, id("word")}] = StateID{3}; + B.Recoveries.push_back({StateID{1}, {extensionID("Braces"), id("word")}}); + TestLang.Table = std::move(B).build(); + TestLang.RecoveryStrategies.try_emplace(extensionID("Braces"), recoverBraces); + + auto *LBrace = &Arena.createTerminal(tok::l_brace, 0); + auto *Question1 = &Arena.createTerminal(tok::question, 1); + const auto *Root = GSStack.addNode(0, nullptr, {}); + const auto *OpenedBraces = GSStack.addNode(1, LBrace, {Root}); + const auto *AfterQuestion1 = GSStack.addNode(2, Question1, {OpenedBraces}); + + // Need a token stream with paired braces so the strategy works. + clang::LangOptions LOptions; + TokenStream Tokens = cook(lex("{ ? ? ? }", LOptions), LOptions); + pairBrackets(Tokens); + std::vector NewHeads; + + unsigned TokenIndex = 2; + glrRecover({AfterQuestion1}, TokenIndex, {Tokens, Arena, GSStack}, TestLang, + NewHeads); + EXPECT_EQ(TokenIndex, 4u) << "should skip ahead to matching brace"; + EXPECT_THAT(NewHeads, ElementsAre(AllOf(state(3), parsedSymbolID(id("word")), + parents({OpenedBraces}), start(1u)))); + EXPECT_EQ(NewHeads.front()->Payload->kind(), ForestNode::Opaque); + + // Test recovery failure: omit closing brace so strategy fails + TokenStream NoRBrace = cook(lex("{ ? ? ? ?", LOptions), LOptions); + pairBrackets(NoRBrace); + NewHeads.clear(); + TokenIndex = 2; + glrRecover({AfterQuestion1}, TokenIndex, {NoRBrace, Arena, GSStack}, TestLang, + NewHeads); + EXPECT_EQ(TokenIndex, 2u) << "should not advance on failure"; + EXPECT_THAT(NewHeads, IsEmpty()); +} + +TEST_F(GLRTest, RecoverRightmost) { + // In a nested block structure, we recover at the innermost possible block. + // Before: + // 0--1({)--1({)--1({) + // After recovering a `block` at inside the second braces: + // 0--1({)--2(body) // 2 is goto(1, body) + buildGrammar({"body", "top"}, {"top := { body [recover=Braces] }"}); + LRTable::Builder B(TestLang.G); + B.Transition[{StateID{1}, id("body")}] = StateID{2}; + B.Recoveries.push_back({StateID{1}, {extensionID("Braces"), id("body")}}); + TestLang.Table = std::move(B).build(); + TestLang.RecoveryStrategies.try_emplace(extensionID("Braces"), recoverBraces); + + clang::LangOptions LOptions; + // Innermost brace is unmatched, to test fallback to next brace. + TokenStream Tokens = cook(lex("{ { { ? } }", LOptions), LOptions); + Tokens.tokens()[0].Pair = 5; + Tokens.tokens()[1].Pair = 4; + Tokens.tokens()[4].Pair = 1; + Tokens.tokens()[5].Pair = 0; + + auto *Brace1 = &Arena.createTerminal(tok::l_brace, 0); + auto *Brace2 = &Arena.createTerminal(tok::l_brace, 1); + auto *Brace3 = &Arena.createTerminal(tok::l_brace, 2); + const auto *Root = GSStack.addNode(0, nullptr, {}); + const auto *In1 = GSStack.addNode(1, Brace1, {Root}); + const auto *In2 = GSStack.addNode(1, Brace2, {In1}); + const auto *In3 = GSStack.addNode(1, Brace3, {In2}); + + unsigned TokenIndex = 3; + std::vector NewHeads; + glrRecover({In3}, TokenIndex, {Tokens, Arena, GSStack}, TestLang, NewHeads); + EXPECT_EQ(TokenIndex, 5u); + EXPECT_THAT(NewHeads, ElementsAre(AllOf(state(2), parsedSymbolID(id("body")), + parents({In2}), start(2u)))); +} + +TEST_F(GLRTest, RecoverAlternatives) { + // Recovery inside braces with multiple equally good options + // Before: + // 0--1({) + // After recovering either `word` or `number` inside the braces: + // 0--1({)--2(word) // 2 is goto(1, word) + // â””--3(number) // 3 is goto(1, number) + buildGrammar({"number", "word", "top"}, + { + "top := { number [recover=Braces] }", + "top := { word [recover=Braces] }", + }); + LRTable::Builder B(TestLang.G); + B.Transition[{StateID{1}, id("number")}] = StateID{2}; + B.Transition[{StateID{1}, id("word")}] = StateID{3}; + B.Recoveries.push_back({StateID{1}, {extensionID("Braces"), id("number")}}); + B.Recoveries.push_back({StateID{1}, {extensionID("Braces"), id("word")}}); + TestLang.RecoveryStrategies.try_emplace(extensionID("Braces"), recoverBraces); + TestLang.Table = std::move(B).build(); + auto *LBrace = &Arena.createTerminal(tok::l_brace, 0); + const auto *Root = GSStack.addNode(0, nullptr, {}); + const auto *OpenedBraces = GSStack.addNode(1, LBrace, {Root}); + + clang::LangOptions LOptions; + TokenStream Tokens = cook(lex("{ ? }", LOptions), LOptions); + pairBrackets(Tokens); + std::vector NewHeads; + unsigned TokenIndex = 1; + + glrRecover({OpenedBraces}, TokenIndex, {Tokens, Arena, GSStack}, TestLang, + NewHeads); + EXPECT_EQ(TokenIndex, 2u); + EXPECT_THAT(NewHeads, + UnorderedElementsAre(AllOf(state(2), parsedSymbolID(id("number")), + parents({OpenedBraces}), start(1u)), + AllOf(state(3), parsedSymbolID(id("word")), + parents({OpenedBraces}), start(1u)))); +} + +TEST_F(GLRTest, PerfectForestNodeSharing) { + // Run the GLR on a simple grammar and test that we build exactly one forest + // node per (SymbolID, token range). + + // This is a grmammar where the original parsing-stack-based forest node + // sharing approach will fail. In its LR0 graph, it has two states containing + // item `expr := • IDENTIFIER`, and both have different goto states on the + // nonterminal `expr`. + build(R"bnf( + _ := test EOF + + test := { expr + test := { IDENTIFIER + test := left-paren expr + left-paren := { + expr := IDENTIFIER + )bnf"); + TestLang.Table = LRTable::buildSLR(TestLang.G); + clang::LangOptions LOptions; + const TokenStream &Tokens = cook(lex("{ abc", LOptions), LOptions); + + const ForestNode &Parsed = + glrParse({Tokens, Arena, GSStack}, id("test"), TestLang); + // Verify that there is no duplicated sequence node of `expr := IDENTIFIER` + // in the forest, see the `#1` and `=#1` in the dump string. + EXPECT_EQ(Parsed.dumpRecursive(TestLang.G), + "[ 0, end) test := \n" + "[ 0, end) ├─test := { expr\n" + "[ 0, 1) │ ├─{ := tok[0]\n" + "[ 1, end) │ └─expr := IDENTIFIER #1\n" + "[ 1, end) │ └─IDENTIFIER := tok[1]\n" + "[ 0, end) ├─test := { IDENTIFIER\n" + "[ 0, 1) │ ├─{ := tok[0]\n" + "[ 1, end) │ └─IDENTIFIER := tok[1]\n" + "[ 0, end) └─test := left-paren expr\n" + "[ 0, 1) ├─left-paren := {\n" + "[ 0, 1) │ └─{ := tok[0]\n" + "[ 1, end) └─expr =#1\n"); +} + +TEST_F(GLRTest, GLRReduceOrder) { + // Given the following grammar, and the input `IDENTIFIER`, reductions should + // be performed in the following order: + // 1. foo := IDENTIFIER + // 2. { test := IDENTIFIER, test := foo } + // foo should be reduced first, so that in step 2 we have completed reduces + // for test, and form an ambiguous forest node. + build(R"bnf( + _ := test EOF + + test := IDENTIFIER + test := foo + foo := IDENTIFIER + )bnf"); + clang::LangOptions LOptions; + const TokenStream &Tokens = cook(lex("IDENTIFIER", LOptions), LOptions); + TestLang.Table = LRTable::buildSLR(TestLang.G); + + const ForestNode &Parsed = + glrParse({Tokens, Arena, GSStack}, id("test"), TestLang); + EXPECT_EQ(Parsed.dumpRecursive(TestLang.G), + "[ 0, end) test := \n" + "[ 0, end) ├─test := IDENTIFIER\n" + "[ 0, end) │ └─IDENTIFIER := tok[0]\n" + "[ 0, end) └─test := foo\n" + "[ 0, end) └─foo := IDENTIFIER\n" + "[ 0, end) └─IDENTIFIER := tok[0]\n"); +} + +TEST_F(GLRTest, RecoveryEndToEnd) { + // Simple example of brace-based recovery showing: + // - recovered region includes tokens both ahead of and behind the cursor + // - multiple possible recovery rules + // - recovery from outer scopes is rejected + build(R"bnf( + _ := block EOF + + block := { block [recover=Braces] } + block := { numbers [recover=Braces] } + numbers := NUMERIC_CONSTANT NUMERIC_CONSTANT + )bnf"); + TestLang.Table = LRTable::buildSLR(TestLang.G); + TestLang.RecoveryStrategies.try_emplace(extensionID("Braces"), recoverBraces); + clang::LangOptions LOptions; + TokenStream Tokens = cook(lex("{ { 42 ? } }", LOptions), LOptions); + pairBrackets(Tokens); + + const ForestNode &Parsed = + glrParse({Tokens, Arena, GSStack}, id("block"), TestLang); + EXPECT_EQ(Parsed.dumpRecursive(TestLang.G), + "[ 0, end) block := { block [recover=Braces] }\n" + "[ 0, 1) ├─{ := tok[0]\n" + "[ 1, 5) ├─block := \n" + "[ 1, 5) │ ├─block := { block [recover=Braces] }\n" + "[ 1, 2) │ │ ├─{ := tok[1]\n" + "[ 2, 4) │ │ ├─block := \n" + "[ 4, 5) │ │ └─} := tok[4]\n" + "[ 1, 5) │ └─block := { numbers [recover=Braces] }\n" + "[ 1, 2) │ ├─{ := tok[1]\n" + "[ 2, 4) │ ├─numbers := \n" + "[ 4, 5) │ └─} := tok[4]\n" + "[ 5, end) └─} := tok[5]\n"); +} + +TEST_F(GLRTest, RecoverTerminal) { + build(R"bnf( + _ := stmt EOF + + stmt := IDENTIFIER ; [recover=Skip] + )bnf"); + TestLang.Table = LRTable::buildSLR(TestLang.G); + TestLang.RecoveryStrategies.try_emplace( + extensionID("Skip"), + [](Token::Index Start, const TokenStream &) { return Start; }); + clang::LangOptions LOptions; + TokenStream Tokens = cook(lex("foo", LOptions), LOptions); + + const ForestNode &Parsed = + glrParse({Tokens, Arena, GSStack}, id("stmt"), TestLang); + EXPECT_EQ(Parsed.dumpRecursive(TestLang.G), + "[ 0, end) stmt := IDENTIFIER ; [recover=Skip]\n" + "[ 0, 1) ├─IDENTIFIER := tok[0]\n" + "[ 1, end) └─; := \n"); +} + +TEST_F(GLRTest, RecoverUnrestrictedReduce) { + // Here, ! is not in any rule and therefore not in the follow set of `word`. + // We would not normally reduce `word := IDENTIFIER`, but do so for recovery. + + build(R"bnf( + _ := sentence EOF + + word := IDENTIFIER + sentence := word word [recover=AcceptAnyTokenInstead] + )bnf"); + + clang::LangOptions LOptions; + const TokenStream &Tokens = cook(lex("id !", LOptions), LOptions); + TestLang.Table = LRTable::buildSLR(TestLang.G); + TestLang.RecoveryStrategies.try_emplace( + extensionID("AcceptAnyTokenInstead"), + [](Token::Index Start, const TokenStream &Stream) { return Start + 1; }); + + const ForestNode &Parsed = + glrParse({Tokens, Arena, GSStack}, id("sentence"), TestLang); + EXPECT_EQ(Parsed.dumpRecursive(TestLang.G), + "[ 0, end) sentence := word word [recover=AcceptAnyTokenInstead]\n" + "[ 0, 1) ├─word := IDENTIFIER\n" + "[ 0, 1) │ └─IDENTIFIER := tok[0]\n" + "[ 1, end) └─word := \n"); +} + +TEST_F(GLRTest, RecoveryFromStartOfInput) { + build(R"bnf( + _ := start [recover=Fallback] EOF + + start := IDENTIFIER + )bnf"); + TestLang.Table = LRTable::buildSLR(TestLang.G); + bool fallback_recovered = false; + auto fallback = [&](Token::Index Start, const TokenStream & Code) { + fallback_recovered = true; + return Code.tokens().size(); + }; + TestLang.RecoveryStrategies.try_emplace( + extensionID("Fallback"), + fallback); + clang::LangOptions LOptions; + TokenStream Tokens = cook(lex("?", LOptions), LOptions); + + const ForestNode &Parsed = + glrParse({Tokens, Arena, GSStack}, id("start"), TestLang); + EXPECT_TRUE(fallback_recovered); + EXPECT_EQ(Parsed.dumpRecursive(TestLang.G), + "[ 0, end) start := \n"); +} + +TEST_F(GLRTest, RepeatedRecovery) { + // We require multiple steps of recovery at eof and then a reduction in order + // to successfully parse. + build(R"bnf( + _ := function EOF + # FIXME: this forces EOF to be in follow(signature). + # Remove it once we use unconstrained reduction for recovery. + _ := signature EOF + + function := signature body [recover=Skip] + signature := IDENTIFIER params [recover=Skip] + params := ( ) + body := { } + )bnf"); + TestLang.Table = LRTable::buildSLR(TestLang.G); + TestLang.RecoveryStrategies.try_emplace( + extensionID("Skip"), + [](Token::Index Start, const TokenStream &) { return Start; }); + clang::LangOptions LOptions; + TokenStream Tokens = cook(lex("main", LOptions), LOptions); + + const ForestNode &Parsed = + glrParse({Tokens, Arena, GSStack}, id("function"), TestLang); + EXPECT_EQ(Parsed.dumpRecursive(TestLang.G), + "[ 0, end) function := signature body [recover=Skip]\n" + "[ 0, 1) ├─signature := IDENTIFIER params [recover=Skip]\n" + "[ 0, 1) │ ├─IDENTIFIER := tok[0]\n" + "[ 1, 1) │ └─params := \n" + "[ 1, end) └─body := \n"); +} + +TEST_F(GLRTest, NoExplicitAccept) { + build(R"bnf( + _ := test EOF + + test := IDENTIFIER test + test := IDENTIFIER + )bnf"); + clang::LangOptions LOptions; + // Given the following input, and the grammar above, we perform two reductions + // of the nonterminal `test` when the next token is `eof`, verify that the + // parser stops at the right state. + const TokenStream &Tokens = cook(lex("id id", LOptions), LOptions); + TestLang.Table = LRTable::buildSLR(TestLang.G); + + const ForestNode &Parsed = + glrParse({Tokens, Arena, GSStack}, id("test"), TestLang); + EXPECT_EQ(Parsed.dumpRecursive(TestLang.G), + "[ 0, end) test := IDENTIFIER test\n" + "[ 0, 1) ├─IDENTIFIER := tok[0]\n" + "[ 1, end) └─test := IDENTIFIER\n" + "[ 1, end) └─IDENTIFIER := tok[1]\n"); +} + +TEST_F(GLRTest, GuardExtension) { + build(R"bnf( + _ := start EOF + + start := IDENTIFIER [guard] + )bnf"); + TestLang.Guards.try_emplace( + ruleFor("start"), [&](const GuardParams &P) { + assert(P.RHS.size() == 1 && + P.RHS.front()->symbol() == + tokenSymbol(clang::tok::identifier)); + return P.Tokens.tokens()[P.RHS.front()->startTokenIndex()] + .text() == "test"; + }); + clang::LangOptions LOptions; + TestLang.Table = LRTable::buildSLR(TestLang.G); + + std::string Input = "test"; + const TokenStream &Succeeded = cook(lex(Input, LOptions), LOptions); + EXPECT_EQ(glrParse({Succeeded, Arena, GSStack}, id("start"), TestLang) + .dumpRecursive(TestLang.G), + "[ 0, end) start := IDENTIFIER [guard]\n" + "[ 0, end) └─IDENTIFIER := tok[0]\n"); + + Input = "notest"; + const TokenStream &Failed = cook(lex(Input, LOptions), LOptions); + EXPECT_EQ(glrParse({Failed, Arena, GSStack}, id("start"), TestLang) + .dumpRecursive(TestLang.G), + "[ 0, end) start := \n"); +} + +TEST(GSSTest, GC) { + // ┌-A-┬-AB + // ├-B-┘ + // Root-+-C + // ├-D + // â””-E + GSS GSStack; + auto *Root = GSStack.addNode(0, nullptr, {}); + auto *A = GSStack.addNode(0, nullptr, {Root}); + auto *B = GSStack.addNode(0, nullptr, {Root}); + auto *C = GSStack.addNode(0, nullptr, {Root}); + auto *D = GSStack.addNode(0, nullptr, {Root}); + auto *AB = GSStack.addNode(0, nullptr, {A, B}); + + EXPECT_EQ(1u, GSStack.gc({AB, C})) << "D is destroyed"; + EXPECT_EQ(0u, GSStack.gc({AB, C})) << "D is already gone"; + auto *E = GSStack.addNode(0, nullptr, {Root}); + EXPECT_EQ(D, E) << "Storage of GCed node D is reused for E"; + EXPECT_EQ(3u, GSStack.gc({A, E})) << "Destroys B, AB, C"; + EXPECT_EQ(1u, GSStack.gc({E})) << "Destroys A"; +} + +} // namespace +} // namespace pseudo +} // namespace clang diff --git a/clang-tools-extra/pseudo/unittests/GrammarTest.cpp b/clang-tools-extra/pseudo/unittests/GrammarTest.cpp new file mode 100644 index 0000000000000..6b6b47b8a2dbe --- /dev/null +++ b/clang-tools-extra/pseudo/unittests/GrammarTest.cpp @@ -0,0 +1,213 @@ +//===--- GrammarTest.cpp - grammar tests -----------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/grammar/Grammar.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include + +namespace clang { +namespace pseudo { +namespace { + +using testing::AllOf; +using testing::ElementsAre; +using testing::IsEmpty; +using testing::Pair; +using testing::UnorderedElementsAre; + +MATCHER_P(TargetID, SID, "") { return arg.Target == SID; } +template testing::Matcher Sequence(T... IDs) { + return testing::Property(&Rule::seq, ElementsAre(IDs...)); +} + +class GrammarTest : public ::testing::Test { +public: + void build(llvm::StringRef BNF) { + Diags.clear(); + G = Grammar::parseBNF(BNF, Diags); + } + + SymbolID id(llvm::StringRef Name) const { + for (unsigned I = 0; I < NumTerminals; ++I) + if (G.table().Terminals[I] == Name) + return tokenSymbol(static_cast(I)); + for (SymbolID ID = 0; ID < G.table().Nonterminals.size(); ++ID) + if (G.table().Nonterminals[ID].Name == Name) + return ID; + ADD_FAILURE() << "No such symbol found: " << Name; + return 0; + } + + RuleID ruleFor(llvm::StringRef NonterminalName) const { + auto RuleRange = G.table().Nonterminals[id(NonterminalName)].RuleRange; + if (RuleRange.End - RuleRange.Start == 1) + return G.table().Nonterminals[id(NonterminalName)].RuleRange.Start; + ADD_FAILURE() << "Expected a single rule for " << NonterminalName + << ", but it has " << RuleRange.End - RuleRange.Start + << " rule!\n"; + return 0; + } + +protected: + Grammar G; + std::vector Diags; +}; + +TEST_F(GrammarTest, Basic) { + build("_ := IDENTIFIER + _ # comment"); + EXPECT_THAT(Diags, IsEmpty()); + + auto ExpectedRule = + AllOf(TargetID(id("_")), Sequence(id("IDENTIFIER"), id("+"), id("_"))); + EXPECT_EQ(G.symbolName(id("_")), "_"); + EXPECT_THAT(G.rulesFor(id("_")), UnorderedElementsAre(ExpectedRule)); + const auto &Rule = G.lookupRule(/*RID=*/0); + EXPECT_THAT(Rule, ExpectedRule); + EXPECT_THAT(G.symbolName(Rule.seq()[0]), "IDENTIFIER"); + EXPECT_THAT(G.symbolName(Rule.seq()[1]), "+"); + EXPECT_THAT(G.symbolName(Rule.seq()[2]), "_"); +} + +TEST_F(GrammarTest, EliminatedOptional) { + build("_ := CONST_opt INT ;_opt"); + EXPECT_THAT(Diags, IsEmpty()); + EXPECT_THAT(G.table().Rules, + UnorderedElementsAre(Sequence(id("INT")), + Sequence(id("CONST"), id("INT")), + Sequence(id("CONST"), id("INT"), id(";")), + Sequence(id("INT"), id(";")))); +} + +TEST_F(GrammarTest, RuleIDSorted) { + build(R"bnf( + _ := x + + x := y + y := z + z := IDENTIFIER + )bnf"); + ASSERT_TRUE(Diags.empty()); + + EXPECT_LT(ruleFor("z"), ruleFor("y")); + EXPECT_LT(ruleFor("y"), ruleFor("x")); + EXPECT_LT(ruleFor("x"), ruleFor("_")); +} + +TEST_F(GrammarTest, Annotation) { + build(R"bnf( + _ := x + x := IDENTIFIER [guard] + )bnf"); + ASSERT_THAT(Diags, IsEmpty()); + EXPECT_FALSE(G.lookupRule(ruleFor("_")).Guarded); + EXPECT_TRUE(G.lookupRule(ruleFor("x")).Guarded); +} + +TEST_F(GrammarTest, Diagnostics) { + build(R"cpp( + _ := ,_opt + _ := undefined-sym + null := + _ := IDENFIFIE # a typo of the terminal IDENFITIER + + invalid + # cycle + a := b + b := a + + _ := IDENTIFIER [unknown=value] + )cpp"); + + EXPECT_EQ(G.underscore(), id("_")); + EXPECT_THAT(Diags, UnorderedElementsAre( + "Rule '_ := ,_opt' has a nullable RHS", + "Rule 'null := ' has a nullable RHS", + "No rules for nonterminal: undefined-sym", + "Failed to parse 'invalid': no separator :=", + "Token-like name IDENFIFIE is used as a nonterminal", + "No rules for nonterminal: IDENFIFIE", + "The grammar contains a cycle involving symbol a", + "Unknown attribute 'unknown'")); +} + +TEST_F(GrammarTest, DuplicatedDiagnostics) { + build(R"cpp( + _ := test + + test := INT + test := DOUBLE + test := INT + )cpp"); + + EXPECT_THAT(Diags, UnorderedElementsAre("Duplicate rule: `test := INT`")); +} + +TEST_F(GrammarTest, FirstAndFollowSets) { + build( + R"bnf( +_ := expr +expr := expr - term +expr := term +term := IDENTIFIER +term := ( expr ) +)bnf"); + ASSERT_TRUE(Diags.empty()); + auto ToPairs = [](std::vector> Input) { + std::vector>> Sets; + for (SymbolID ID = 0; ID < Input.size(); ++ID) + Sets.emplace_back(ID, std::move(Input[ID])); + return Sets; + }; + + EXPECT_THAT( + ToPairs(firstSets(G)), + UnorderedElementsAre( + Pair(id("_"), UnorderedElementsAre(id("IDENTIFIER"), id("("))), + Pair(id("expr"), UnorderedElementsAre(id("IDENTIFIER"), id("("))), + Pair(id("term"), UnorderedElementsAre(id("IDENTIFIER"), id("("))))); + EXPECT_THAT( + ToPairs(followSets(G)), + UnorderedElementsAre( + Pair(id("_"), UnorderedElementsAre(id("EOF"))), + Pair(id("expr"), UnorderedElementsAre(id("-"), id("EOF"), id(")"))), + Pair(id("term"), UnorderedElementsAre(id("-"), id("EOF"), id(")"))))); + + build(R"bnf( +# A simplfied C++ decl-specifier-seq. +_ := decl-specifier-seq +decl-specifier-seq := decl-specifier decl-specifier-seq +decl-specifier-seq := decl-specifier +decl-specifier := simple-type-specifier +decl-specifier := INLINE +simple-type-specifier := INT + )bnf"); + ASSERT_TRUE(Diags.empty()); + EXPECT_THAT( + ToPairs(firstSets(G)), + UnorderedElementsAre( + Pair(id("_"), UnorderedElementsAre(id("INLINE"), id("INT"))), + Pair(id("decl-specifier-seq"), + UnorderedElementsAre(id("INLINE"), id("INT"))), + Pair(id("simple-type-specifier"), UnorderedElementsAre(id("INT"))), + Pair(id("decl-specifier"), + UnorderedElementsAre(id("INLINE"), id("INT"))))); + EXPECT_THAT( + ToPairs(followSets(G)), + UnorderedElementsAre( + Pair(id("_"), UnorderedElementsAre(id("EOF"))), + Pair(id("decl-specifier-seq"), UnorderedElementsAre(id("EOF"))), + Pair(id("decl-specifier"), + UnorderedElementsAre(id("INLINE"), id("INT"), id("EOF"))), + Pair(id("simple-type-specifier"), + UnorderedElementsAre(id("INLINE"), id("INT"), id("EOF"))))); +} + +} // namespace +} // namespace pseudo +} // namespace clang diff --git a/clang-tools-extra/pseudo/unittests/LRTableTest.cpp b/clang-tools-extra/pseudo/unittests/LRTableTest.cpp new file mode 100644 index 0000000000000..9c9f18e03a3d4 --- /dev/null +++ b/clang-tools-extra/pseudo/unittests/LRTableTest.cpp @@ -0,0 +1,76 @@ +//===--- LRTableTest.cpp - ---------------------------------------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/grammar/LRTable.h" +#include "clang-pseudo/grammar/Grammar.h" +#include "clang/Basic/TokenKinds.h" +#include "llvm/Testing/Support/SupportHelpers.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include + +namespace clang { +namespace pseudo { +namespace { + +using llvm::ValueIs; +using testing::ElementsAre; +using StateID = LRTable::StateID; + +TEST(LRTable, Builder) { + std::vector GrammarDiags; + Grammar G = Grammar::parseBNF(R"bnf( + _ := expr # rule 0 + expr := term # rule 1 + expr := expr + term # rule 2 + term := IDENTIFIER # rule 3 + )bnf", + GrammarDiags); + EXPECT_THAT(GrammarDiags, testing::IsEmpty()); + + SymbolID Term = *G.findNonterminal("term"); + SymbolID Eof = tokenSymbol(tok::eof); + SymbolID Identifier = tokenSymbol(tok::identifier); + SymbolID Plus = tokenSymbol(tok::plus); + + LRTable::Builder B(G); + // eof IDENT term + // +-------+----+-------+------+ + // |state0 | | s0 | | + // |state1 | | | g3 | + // |state2 | | | | + // +-------+----+-------+------+------- + B.Transition[{StateID{0}, Identifier}] = StateID{0}; + B.Transition[{StateID{1}, Term}] = StateID{3}; + B.Reduce[StateID{0}].insert(RuleID{0}); + B.Reduce[StateID{1}].insert(RuleID{2}); + B.Reduce[StateID{2}].insert(RuleID{1}); + LRTable T = std::move(B).build(); + + EXPECT_EQ(T.getShiftState(0, Eof), std::nullopt); + EXPECT_THAT(T.getShiftState(0, Identifier), ValueIs(0)); + EXPECT_THAT(T.getReduceRules(0), ElementsAre(0)); + + EXPECT_EQ(T.getShiftState(1, Eof), std::nullopt); + EXPECT_EQ(T.getShiftState(1, Identifier), std::nullopt); + EXPECT_THAT(T.getGoToState(1, Term), ValueIs(3)); + EXPECT_THAT(T.getReduceRules(1), ElementsAre(2)); + + // Verify the behaivor for other non-available-actions terminals. + SymbolID Int = tokenSymbol(tok::kw_int); + EXPECT_EQ(T.getShiftState(2, Int), std::nullopt); + + // Check follow sets. + EXPECT_TRUE(T.canFollow(Term, Plus)); + EXPECT_TRUE(T.canFollow(Term, Eof)); + EXPECT_FALSE(T.canFollow(Term, Int)); +} + +} // namespace +} // namespace pseudo +} // namespace clang diff --git a/clang-tools-extra/pseudo/unittests/TokenTest.cpp b/clang-tools-extra/pseudo/unittests/TokenTest.cpp new file mode 100644 index 0000000000000..5b71accfad50f --- /dev/null +++ b/clang-tools-extra/pseudo/unittests/TokenTest.cpp @@ -0,0 +1,224 @@ +//===--- TokenTest.cpp ----------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-pseudo/Token.h" +#include "clang/Basic/LangOptions.h" +#include "clang/Basic/TokenKinds.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +namespace clang { +namespace pseudo { +namespace { + +using testing::AllOf; +using testing::ElementsAre; +using testing::ElementsAreArray; +using testing::Not; + +MATCHER_P2(token, Text, Kind, "") { + return arg.Kind == Kind && arg.text() == Text; +} + +MATCHER_P(hasFlag, Flag, "") { return arg.flag(Flag); } + +MATCHER_P2(lineIndent, Line, Indent, "") { + return arg.Line == (unsigned)Line && arg.Indent == (unsigned)Indent; +} + +MATCHER_P(originalIndex, index, "") { + return arg.OriginalIndex == (Token::Index)index; +} + +TEST(TokenTest, Lex) { + LangOptions Opts; + std::string Code = R"cpp( + #include + int main() { + return 42; // the answer + } + )cpp"; + TokenStream Raw = lex(Code, Opts); + ASSERT_TRUE(Raw.isFinalized()); + EXPECT_THAT(Raw.tokens(), + ElementsAreArray({ + // Lexing of directives is weird, especially strings. + token("#", tok::hash), + token("include", tok::raw_identifier), + token("<", tok::less), + token("stdio", tok::raw_identifier), + token(".", tok::period), + token("h", tok::raw_identifier), + token(">", tok::greater), + + token("int", tok::raw_identifier), + token("main", tok::raw_identifier), + token("(", tok::l_paren), + token(")", tok::r_paren), + token("{", tok::l_brace), + token("return", tok::raw_identifier), + token("42", tok::numeric_constant), + token(";", tok::semi), + token("// the answer", tok::comment), + token("}", tok::r_brace), + })); + + TokenStream Cooked = cook(Raw, Opts); + ASSERT_TRUE(Cooked.isFinalized()); + EXPECT_THAT(Cooked.tokens(), + ElementsAreArray({ + // Cooked identifier types in directives are not meaningful. + token("#", tok::hash), + token("include", tok::identifier), + token("<", tok::less), + token("stdio", tok::identifier), + token(".", tok::period), + token("h", tok::identifier), + token(">", tok::greater), + + token("int", tok::kw_int), + token("main", tok::identifier), + token("(", tok::l_paren), + token(")", tok::r_paren), + token("{", tok::l_brace), + token("return", tok::kw_return), + token("42", tok::numeric_constant), + token(";", tok::semi), + token("// the answer", tok::comment), + token("}", tok::r_brace), + })); + // Check raw tokens point back into original source code. + EXPECT_EQ(Raw.tokens().front().text().begin(), &Code[Code.find('#')]); +} + +TEST(TokenTest, LineContinuation) { + LangOptions Opts; + std::string Code = R"cpp( +one_\ +token +two \ +tokens + )cpp"; + TokenStream Raw = lex(Code, Opts); + EXPECT_THAT( + Raw.tokens(), + ElementsAre(AllOf(token("one_\\\ntoken", tok::raw_identifier), + hasFlag(LexFlags::StartsPPLine), + hasFlag(LexFlags::NeedsCleaning), lineIndent(1, 0), + originalIndex(0)), + AllOf(token("two", tok::raw_identifier), + hasFlag(LexFlags::StartsPPLine), + Not(hasFlag(LexFlags::NeedsCleaning)), + originalIndex(1)), + AllOf(token("\\\ntokens", tok::raw_identifier), + Not(hasFlag(LexFlags::StartsPPLine)), + hasFlag(LexFlags::NeedsCleaning), originalIndex(2)))); + + TokenStream Cooked = cook(Raw, Opts); + EXPECT_THAT( + Cooked.tokens(), + ElementsAre(AllOf(token("one_token", tok::identifier), lineIndent(1, 0), + originalIndex(0)), + AllOf(token("two", tok::identifier), originalIndex(1)), + AllOf(token("tokens", tok::identifier), originalIndex(2)))); +} + +TEST(TokenTest, EncodedCharacters) { + LangOptions Opts; + Opts.Trigraphs = true; + Opts.Digraphs = true; + Opts.C99 = true; // UCNs + Opts.CXXOperatorNames = true; + std::string Code = R"(and <: ??! '??=' \u00E9)"; + TokenStream Raw = lex(Code, Opts); + EXPECT_THAT( + Raw.tokens(), + ElementsAre( // and is not recognized as && until cook(). + AllOf(token("and", tok::raw_identifier), + Not(hasFlag(LexFlags::NeedsCleaning))), + // Digraphs are just different spellings of tokens. + AllOf(token("<:", tok::l_square), + Not(hasFlag(LexFlags::NeedsCleaning))), + // Trigraps are interpreted, still need text cleaning. + AllOf(token(R"(??!)", tok::pipe), hasFlag(LexFlags::NeedsCleaning)), + // Trigraphs must be substituted inside constants too. + AllOf(token(R"('??=')", tok::char_constant), + hasFlag(LexFlags::NeedsCleaning)), + // UCNs need substitution. + AllOf(token(R"(\u00E9)", tok::raw_identifier), + hasFlag(LexFlags::NeedsCleaning)))); + + TokenStream Cooked = cook(Raw, Opts); + EXPECT_THAT( + Cooked.tokens(), + ElementsAre(token("and", tok::ampamp), // alternate spelling recognized + token("<:", tok::l_square), + token("|", tok::pipe), // trigraph substituted + token("'#'", tok::char_constant), // trigraph substituted + token("é", tok::identifier))); // UCN substituted +} + +TEST(TokenTest, Indentation) { + LangOptions Opts; + std::string Code = R"cpp( hello world +no_indent \ + line_was_continued +)cpp"; + TokenStream Raw = lex(Code, Opts); + EXPECT_THAT(Raw.tokens(), ElementsAreArray({ + lineIndent(0, 3), // hello + lineIndent(0, 3), // world + lineIndent(1, 0), // no_indent + lineIndent(2, 2), // line_was_continued + })); +} + +TEST(TokenTest, SplitGreaterGreater) { + LangOptions Opts; + std::string Code = R"cpp( +>> // split +// >> with an escaped newline in the middle, split +>\ +> +>>= // not split +)cpp"; + TokenStream Cook = cook(lex(Code, Opts), Opts); + TokenStream Split = stripComments(Cook); + EXPECT_THAT(Split.tokens(), + ElementsAre(AllOf(token(">", tok::greater), originalIndex(0)), + AllOf(token(">", tok::greater), originalIndex(0)), + // Token 1 and 2 are comments. + AllOf(token(">", tok::greater), originalIndex(3)), + AllOf(token(">", tok::greater), originalIndex(3)), + AllOf(token(">>=", tok::greatergreaterequal), + originalIndex(4)))); +} + +TEST(TokenTest, DropComments) { + LangOptions Opts; + std::string Code = R"cpp( + // comment + int /*abc*/; +)cpp"; + TokenStream Raw = cook(lex(Code, Opts), Opts); + TokenStream Stripped = stripComments(Raw); + EXPECT_THAT( + Raw.tokens(), + ElementsAre(AllOf(token("// comment", tok::comment), originalIndex(0)), + AllOf(token("int", tok::kw_int), originalIndex(1)), + AllOf(token("/*abc*/", tok::comment), originalIndex(2)), + AllOf(token(";", tok::semi), originalIndex(3)))); + + EXPECT_THAT(Stripped.tokens(), + ElementsAre(AllOf(token("int", tok::kw_int), originalIndex(1)), + AllOf(token(";", tok::semi), originalIndex(3)))); +} + +} // namespace +} // namespace pseudo +} // namespace clang diff --git a/clang-tools-extra/test/CMakeLists.txt b/clang-tools-extra/test/CMakeLists.txt index d72a117166a08..0953ff2531e1a 100644 --- a/clang-tools-extra/test/CMakeLists.txt +++ b/clang-tools-extra/test/CMakeLists.txt @@ -28,6 +28,9 @@ configure_lit_site_cfg( ) set(CLANG_TOOLS_TEST_DEPS + # For the clang-apply-replacements test that uses clang-rename. + clang-rename + # For the clang-doc tests that emit bitcode files. llvm-bcanalyzer diff --git a/clang-tools-extra/test/clang-apply-replacements/ClangRenameClassReplacements.cpp b/clang-tools-extra/test/clang-apply-replacements/ClangRenameClassReplacements.cpp new file mode 100644 index 0000000000000..2b478bbf900df --- /dev/null +++ b/clang-tools-extra/test/clang-apply-replacements/ClangRenameClassReplacements.cpp @@ -0,0 +1,11 @@ +// RUN: rm -rf %t +// RUN: mkdir -p %t/fixes +// RUN: cat %s > %t.cpp +// RUN: clang-rename -offset=254 -new-name=Bar -export-fixes=%t/fixes/clang-rename.yaml %t.cpp -- +// RUN: clang-apply-replacements %t +// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s + +class Foo {}; // CHECK: class Bar {}; + +// Use grep -FUbo 'Foo' to get the correct offset of Cla when changing +// this file. diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/casting-through-void.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/casting-through-void.cpp index 68172212904f8..a784e49885873 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/casting-through-void.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/casting-through-void.cpp @@ -10,42 +10,42 @@ const double cd = 100; void normal_test() { static_cast(static_cast(&d)); - // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: do not cast 'double *' to 'int *' through 'void *'; use reinterpret_cast instead [bugprone-casting-through-void] + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: do not cast 'double *' to 'int *' through 'void *' [bugprone-casting-through-void] static_cast(static_cast(&d)); - // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: do not cast 'double *' to 'int *' through 'V' (aka 'void *'); use reinterpret_cast instead [bugprone-casting-through-void] + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: do not cast 'double *' to 'int *' through 'V' (aka 'void *') [bugprone-casting-through-void] static_cast(static_cast(&i)); - // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: do not cast 'int *' to 'int *' through 'void *'; use reinterpret_cast instead [bugprone-casting-through-void] + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: do not cast 'int *' to 'int *' through 'void *' [bugprone-casting-through-void] static_cast(static_cast(&i)); } void const_pointer_test() { static_cast(static_cast(&d)); - // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: do not cast 'double *' to 'int *const' through 'void *'; use reinterpret_cast instead [bugprone-casting-through-void] + // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: do not cast 'double *' to 'int *const' through 'void *' [bugprone-casting-through-void] static_cast(static_cast(&d)); - // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: do not cast 'double *' to 'int *const' through 'V' (aka 'void *'); use reinterpret_cast instead [bugprone-casting-through-void] + // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: do not cast 'double *' to 'int *const' through 'V' (aka 'void *') [bugprone-casting-through-void] static_cast(static_cast(&i)); - // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: do not cast 'int *' to 'int *const' through 'void *'; use reinterpret_cast instead [bugprone-casting-through-void] + // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: do not cast 'int *' to 'int *const' through 'void *' [bugprone-casting-through-void] static_cast(static_cast(&i)); } void const_test() { static_cast(static_cast(&d)); - // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: do not cast 'double *' to 'const int *' through 'const void *'; use reinterpret_cast instead [bugprone-casting-through-void] + // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: do not cast 'double *' to 'const int *' through 'const void *' [bugprone-casting-through-void] static_cast(static_cast(&d)); - // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: do not cast 'double *' to 'const int *' through 'const V' (aka 'void *const'); use reinterpret_cast instead [bugprone-casting-through-void] + // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: do not cast 'double *' to 'const int *' through 'const V' (aka 'void *const') [bugprone-casting-through-void] static_cast(static_cast(&i)); - // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: do not cast 'int *' to 'const int *' through 'const void *'; use reinterpret_cast instead [bugprone-casting-through-void] + // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: do not cast 'int *' to 'const int *' through 'const void *' [bugprone-casting-through-void] static_cast(static_cast(&i)); static_cast(static_cast(&cd)); - // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: do not cast 'const double *' to 'const int *' through 'const void *'; use reinterpret_cast instead [bugprone-casting-through-void] + // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: do not cast 'const double *' to 'const int *' through 'const void *' [bugprone-casting-through-void] static_cast(static_cast(&cd)); - // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: do not cast 'const double *' to 'const int *' through 'const CV' (aka 'const void *const'); use reinterpret_cast instead [bugprone-casting-through-void] + // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: do not cast 'const double *' to 'const int *' through 'const CV' (aka 'const void *const') [bugprone-casting-through-void] static_cast(static_cast(&ci)); - // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: do not cast 'const int *' to 'const int *' through 'const void *'; use reinterpret_cast instead [bugprone-casting-through-void] + // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: do not cast 'const int *' to 'const int *' through 'const void *' [bugprone-casting-through-void] static_cast(static_cast(&ci)); } @@ -53,11 +53,11 @@ void const_test() { void reinterpret_cast_test() { static_cast(reinterpret_cast(&d)); - // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: do not cast 'double *' to 'int *' through 'void *'; use reinterpret_cast instead [bugprone-casting-through-void] + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: do not cast 'double *' to 'int *' through 'void *' [bugprone-casting-through-void] reinterpret_cast(static_cast(&d)); - // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: do not cast 'double *' to 'int *' through 'void *'; use reinterpret_cast instead [bugprone-casting-through-void] + // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: do not cast 'double *' to 'int *' through 'void *' [bugprone-casting-through-void] reinterpret_cast(reinterpret_cast(&d)); - // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: do not cast 'double *' to 'int *' through 'void *'; use reinterpret_cast instead [bugprone-casting-through-void] + // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: do not cast 'double *' to 'int *' through 'void *' [bugprone-casting-through-void] static_cast(reinterpret_cast(&i)); reinterpret_cast(reinterpret_cast(&i)); @@ -66,11 +66,11 @@ void reinterpret_cast_test() { void c_style_cast_test() { static_cast((void *)&d); - // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: do not cast 'double *' to 'int *' through 'void *'; use reinterpret_cast instead [bugprone-casting-through-void] + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: do not cast 'double *' to 'int *' through 'void *' [bugprone-casting-through-void] (int *)(void *)&d; - // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: do not cast 'double *' to 'int *' through 'void *'; use reinterpret_cast instead [bugprone-casting-through-void] + // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: do not cast 'double *' to 'int *' through 'void *' [bugprone-casting-through-void] static_cast((void *)&d); - // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: do not cast 'double *' to 'int *' through 'void *'; use reinterpret_cast instead [bugprone-casting-through-void] + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: do not cast 'double *' to 'int *' through 'void *' [bugprone-casting-through-void] static_cast((void *)&i); } @@ -82,12 +82,12 @@ using I = int *; void cxx_functional_cast() { A(static_cast(&d)); I(static_cast(&d)); - // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not cast 'double *' to 'I' (aka 'int *') through 'void *'; use reinterpret_cast instead [bugprone-casting-through-void] + // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not cast 'double *' to 'I' (aka 'int *') through 'void *' [bugprone-casting-through-void] } void bit_cast() { __builtin_bit_cast(int *, static_cast(&d)); - // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: do not cast 'double *' to 'int *' through 'void *'; use reinterpret_cast instead [bugprone-casting-through-void] + // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: do not cast 'double *' to 'int *' through 'void *' [bugprone-casting-through-void] } namespace PR87069 { diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/forwarding-reference-overload.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/forwarding-reference-overload.cpp index 27315199c7eba..92dfb718bb51b 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/forwarding-reference-overload.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/forwarding-reference-overload.cpp @@ -261,9 +261,3 @@ class Test11 { Test11(const Test11 &) = default; Test11(Test11 &&) = default; }; - -template