diff --git .ci/metrics/metrics.py .ci/metrics/metrics.py index 48d2aa2f330e..70b787665a8b 100644 --- .ci/metrics/metrics.py +++ .ci/metrics/metrics.py @@ -130,34 +130,6 @@ def get_per_workflow_metrics( workflow_jobs = workflow_run.jobs() if workflow_jobs.totalCount == 0: continue - if workflow_jobs.totalCount > 1: - raise ValueError( - f"Encountered an unexpected number of jobs: {workflow_jobs.totalCount}" - ) - - created_at = workflow_jobs[0].created_at - started_at = workflow_jobs[0].started_at - completed_at = workflow_jobs[0].completed_at - - job_result = int(workflow_jobs[0].conclusion == "success") - if job_result: - # We still might want to mark the job as a failure if one of the steps - # failed. This is required due to use setting continue-on-error in - # the premerge pipeline to prevent sending emails while we are - # testing the infrastructure. - # TODO(boomanaiden154): Remove this once the premerge pipeline is no - # longer in a testing state and we can directly assert the workflow - # result. - for step in workflow_jobs[0].steps: - if step.conclusion != "success": - job_result = 0 - break - - queue_time = started_at - created_at - run_time = completed_at - started_at - - if run_time.seconds == 0: - continue if ( workflows_to_track[workflow_run.name] is None @@ -170,20 +142,45 @@ def get_per_workflow_metrics( ): break - # The timestamp associated with the event is expected by Grafana to be - # in nanoseconds. - created_at_ns = int(created_at.timestamp()) * 10**9 - - workflow_metrics.append( - JobMetrics( - workflow_run.name, - queue_time.seconds, - run_time.seconds, - job_result, - created_at_ns, - workflow_run.id, + for workflow_job in workflow_jobs: + created_at = workflow_job.created_at + started_at = workflow_job.started_at + completed_at = workflow_job.completed_at + + job_result = int(workflow_job.conclusion == "success") + if job_result: + # We still might want to mark the job as a failure if one of the steps + # failed. This is required due to use setting continue-on-error in + # the premerge pipeline to prevent sending emails while we are + # testing the infrastructure. + # TODO(boomanaiden154): Remove this once the premerge pipeline is no + # longer in a testing state and we can directly assert the workflow + # result. + for step in workflow_job.steps: + if step.conclusion != "success": + job_result = 0 + break + + queue_time = started_at - created_at + run_time = completed_at - started_at + + if run_time.seconds == 0: + continue + + # The timestamp associated with the event is expected by Grafana to be + # in nanoseconds. + created_at_ns = int(created_at.timestamp()) * 10**9 + + workflow_metrics.append( + JobMetrics( + workflow_run.name + "-" + workflow_job.name, + queue_time.seconds, + run_time.seconds, + job_result, + created_at_ns, + workflow_run.id, + ) ) - ) return workflow_metrics diff --git .github/workflows/libcxx-build-and-test.yaml .github/workflows/libcxx-build-and-test.yaml index a28bf4d5daf6..ee77e83363d3 100644 --- .github/workflows/libcxx-build-and-test.yaml +++ .github/workflows/libcxx-build-and-test.yaml @@ -48,8 +48,8 @@ jobs: 'generic-cxx26', 'generic-modules' ] - cc: [ 'clang-19' ] - cxx: [ 'clang++-19' ] + cc: [ 'clang-20' ] + cxx: [ 'clang++-20' ] include: - config: 'generic-gcc' cc: 'gcc-14' @@ -88,18 +88,18 @@ jobs: 'generic-cxx20', 'generic-cxx23' ] - cc: [ 'clang-19' ] - cxx: [ 'clang++-19' ] + cc: [ 'clang-20' ] + cxx: [ 'clang++-20' ] include: - config: 'generic-gcc-cxx11' cc: 'gcc-14' cxx: 'g++-14' - config: 'generic-cxx23' - cc: 'clang-17' - cxx: 'clang++-17' - - config: 'generic-cxx26' cc: 'clang-18' cxx: 'clang++-18' + - config: 'generic-cxx26' + cc: 'clang-19' + cxx: 'clang++-19' steps: - uses: actions/checkout@v4 - name: ${{ matrix.config }} @@ -169,8 +169,8 @@ jobs: - name: ${{ matrix.config }} run: libcxx/utils/ci/run-buildbot ${{ matrix.config }} env: - CC: clang-19 - CXX: clang++-19 + CC: clang-20 + CXX: clang++-20 - uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0 if: always() with: diff --git .github/workflows/release-binaries.yml .github/workflows/release-binaries.yml index 2ca4aea8a3b0..c49939ea48c5 100644 --- .github/workflows/release-binaries.yml +++ .github/workflows/release-binaries.yml @@ -226,14 +226,6 @@ jobs: id: setup-stage uses: ./workflows-main/.github/workflows/release-binaries-setup-stage - - name: Setup sccache - uses: hendrikmuhs/ccache-action@ca3acd2731eef11f1572ccb126356c2f9298d35e # v1.2.9 - with: - # Default to 2G to workaround: https://github.com/hendrikmuhs/ccache-action/issues/174 - max-size: 2G - key: ${{ needs.prepare.outputs.ccache }}-${{ runner.os }}-${{ runner.arch }}-release - variant: ${{ needs.prepare.outputs.ccache }} - - name: Configure id: build shell: bash @@ -246,9 +238,8 @@ jobs: ${{ needs.prepare.outputs.target-cmake-flags }} \ -C clang/cmake/caches/Release.cmake \ -DBOOTSTRAP_LLVM_PARALLEL_LINK_JOBS=1 \ - -DBOOTSTRAP_CPACK_PACKAGE_FILE_NAME="${{ needs.prepare.outputs.release-binary-basename }}" \ - -DCMAKE_C_COMPILER_LAUNCHER=$CCACHE_BIN \ - -DCMAKE_CXX_COMPILER_LAUNCHER=$CCACHE_BIN + -DBOOTSTRAP_CPACK_PACKAGE_FILE_NAME="${{ needs.prepare.outputs.release-binary-basename }}" + - name: Build shell: bash run: | diff --git bolt/lib/Core/BinaryFunction.cpp bolt/lib/Core/BinaryFunction.cpp index 1c5cd62a095b..88562a60dd50 100644 --- bolt/lib/Core/BinaryFunction.cpp +++ bolt/lib/Core/BinaryFunction.cpp @@ -795,7 +795,6 @@ BinaryFunction::processIndirectBranch(MCInst &Instruction, unsigned Size, auto Begin = Instructions.begin(); if (BC.isAArch64()) { - PreserveNops = BC.HasRelocations; // Start at the last label as an approximation of the current basic block. // This is a heuristic, since the full set of labels have yet to be // determined @@ -2300,6 +2299,10 @@ Error BinaryFunction::buildCFG(MCPlusBuilder::AllocatorIdTy AllocatorId) { BC.errs() << "BOLT-WARNING: failed to post-process indirect branches for " << *this << '\n'; } + + if (BC.isAArch64()) + PreserveNops = BC.HasRelocations; + // In relocation mode we want to keep processing the function but avoid // optimizing it. setSimple(false); diff --git bolt/test/AArch64/pad-before-funcs.s bolt/test/AArch64/pad-before-funcs.s index f3e8a23ddfdd..c1b92063d6fa 100644 --- bolt/test/AArch64/pad-before-funcs.s +++ bolt/test/AArch64/pad-before-funcs.s @@ -15,7 +15,7 @@ # RUN: llvm-bolt %t.exe -o %t.bolt.4.4 --pad-funcs-before=_start:4 --pad-funcs=_start:4 # RUN: llvm-bolt %t.exe -o %t.bolt.4.8 --pad-funcs-before=_start:4 --pad-funcs=_start:8 -# RUN: not llvm-bolt %t.exe -o %t.bolt.8 --pad-funcs-before=_start:1 2>&1 | FileCheck --check-prefix=CHECK-BAD-ALIGN %s +# RUN: not llvm-bolt %t.exe -o %t.bolt.1 --pad-funcs-before=_start:1 2>&1 | FileCheck --check-prefix=CHECK-BAD-ALIGN %s # CHECK-BAD-ALIGN: user-requested 1 padding bytes before function _start(*2) is not a multiple of the minimum function alignment (4). diff --git bolt/test/AArch64/remove-nops.s bolt/test/AArch64/remove-nops.s new file mode 100644 index 000000000000..0f02a4b273dd --- /dev/null +++ bolt/test/AArch64/remove-nops.s @@ -0,0 +1,28 @@ +## Verify that llvm-bolt removes nop instructions from functions with indirect +## branches that have defined control flow. + +# REQUIRES: system-linux + +# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o +# RUN: %clang %cflags --target=aarch64-unknown-linux %t.o -o %t.exe -Wl,-q +# RUN: llvm-bolt %t.exe -o %t.bolt --print-normalized 2>&1 | FileCheck %s +# RUN: llvm-objdump -d --disassemble-symbols=_start %t.bolt \ +# RUN: | FileCheck %s --check-prefix=CHECK-OBJDUMP + +# CHECK-OBJDUMP-LABEL: _start +# CHECK-OBJDUMP-NOT: nop + + .section .text + .align 4 + .globl _start + .type _start, %function +_start: +# CHECK-LABEL: Binary Function "_start" + nop +# CHECK-NOT: nop + br x0 +# CHECK: br x0 # TAILCALL +.size _start, .-_start + +## Force relocation mode. + .reloc 0, R_AARCH64_NONE diff --git clang-tools-extra/clangd/Diagnostics.cpp clang-tools-extra/clangd/Diagnostics.cpp index a59d1e7ac840..28bb994a9e99 100644 --- clang-tools-extra/clangd/Diagnostics.cpp +++ clang-tools-extra/clangd/Diagnostics.cpp @@ -577,7 +577,17 @@ std::vector<Diag> 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. - StringRef Warning = DiagnosticIDs::getWarningOptionForDiag(Diag.ID); + StringRef Warning = [&] { + if (OrigSrcMgr) { + return OrigSrcMgr->getDiagnostics() + .getDiagnosticIDs() + ->getWarningOptionForDiag(Diag.ID); + } + if (!DiagnosticIDs::IsCustomDiag(Diag.ID)) + return DiagnosticIDs{}.getWarningOptionForDiag(Diag.ID); + return StringRef{}; + }(); + if (!Warning.empty()) { Diag.Name = ("-W" + Warning).str(); } else { @@ -894,20 +904,23 @@ void StoreDiags::flushLastDiag() { Output.push_back(std::move(*LastDiag)); } -bool isBuiltinDiagnosticSuppressed(unsigned ID, - const llvm::StringSet<> &Suppress, - const LangOptions &LangOpts) { +bool isDiagnosticSuppressed(const clang::Diagnostic &Diag, + 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 (ID == diag::pp_pragma_sysheader_in_main_file && LangOpts.IsHeaderFile) + if (Diag.getID() == diag::pp_pragma_sysheader_in_main_file && + LangOpts.IsHeaderFile) return true; - if (const char *CodePtr = getDiagnosticCode(ID)) { + if (const char *CodePtr = getDiagnosticCode(Diag.getID())) { if (Suppress.contains(normalizeSuppressedCode(CodePtr))) return true; } - StringRef Warning = DiagnosticIDs::getWarningOptionForDiag(ID); + StringRef Warning = + Diag.getDiags()->getDiagnosticIDs()->getWarningOptionForDiag( + Diag.getID()); if (!Warning.empty() && Suppress.contains(Warning)) return true; return false; diff --git clang-tools-extra/clangd/Diagnostics.h clang-tools-extra/clangd/Diagnostics.h index d4c0478c63a5..c45d8dc3aa6c 100644 --- clang-tools-extra/clangd/Diagnostics.h +++ clang-tools-extra/clangd/Diagnostics.h @@ -181,11 +181,11 @@ private: }; /// Determine whether a (non-clang-tidy) diagnostic is suppressed by config. -bool isBuiltinDiagnosticSuppressed(unsigned ID, - const llvm::StringSet<> &Suppressed, - const LangOptions &); +bool isDiagnosticSuppressed(const clang::Diagnostic &Diag, + 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 isBuiltinDiagnosticsSuppressed. +/// stored in the config and consumed by isDiagnosticsSuppressed. /// /// (This strips err_ and -W prefix so we can match with or without them.) llvm::StringRef normalizeSuppressedCode(llvm::StringRef); diff --git clang-tools-extra/clangd/ParsedAST.cpp clang-tools-extra/clangd/ParsedAST.cpp index 89d6f26d0f15..3f63daaf400d 100644 --- clang-tools-extra/clangd/ParsedAST.cpp +++ clang-tools-extra/clangd/ParsedAST.cpp @@ -342,7 +342,7 @@ void applyWarningOptions(llvm::ArrayRef<std::string> ExtraArgs, if (Enable) { if (Diags.getDiagnosticLevel(ID, SourceLocation()) < DiagnosticsEngine::Warning) { - auto Group = DiagnosticIDs::getGroupForDiag(ID); + auto Group = Diags.getDiagnosticIDs()->getGroupForDiag(ID); if (!Group || !EnabledGroups(*Group)) continue; Diags.setSeverity(ID, diag::Severity::Warning, SourceLocation()); @@ -585,8 +585,8 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs, ASTDiags.setLevelAdjuster([&](DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &Info) { if (Cfg.Diagnostics.SuppressAll || - isBuiltinDiagnosticSuppressed(Info.getID(), Cfg.Diagnostics.Suppress, - Clang->getLangOpts())) + isDiagnosticSuppressed(Info, Cfg.Diagnostics.Suppress, + Clang->getLangOpts())) return DiagnosticsEngine::Ignored; auto It = OverriddenSeverity.find(Info.getID()); diff --git clang-tools-extra/clangd/Preamble.cpp clang-tools-extra/clangd/Preamble.cpp index ce88ec0eb88c..b247e608eece 100644 --- clang-tools-extra/clangd/Preamble.cpp +++ clang-tools-extra/clangd/Preamble.cpp @@ -622,8 +622,8 @@ buildPreamble(PathRef FileName, CompilerInvocation CI, PreambleDiagnostics.setLevelAdjuster([&](DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &Info) { if (Cfg.Diagnostics.SuppressAll || - isBuiltinDiagnosticSuppressed(Info.getID(), Cfg.Diagnostics.Suppress, - CI.getLangOpts())) + isDiagnosticSuppressed(Info, Cfg.Diagnostics.Suppress, + CI.getLangOpts())) return DiagnosticsEngine::Ignored; switch (Info.getID()) { case diag::warn_no_newline_eof: diff --git clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp index 179960a02cad..c3e484a1a79c 100644 --- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp +++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp @@ -298,20 +298,41 @@ TEST_F(ConfigCompileTests, DiagnosticSuppression) { "unreachable-code", "unused-variable", "typecheck_bool_condition", "unexpected_friend", "warn_alloca")); - EXPECT_TRUE(isBuiltinDiagnosticSuppressed( - diag::warn_unreachable, Conf.Diagnostics.Suppress, LangOptions())); + 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())); + } // Subcategory not respected/suppressed. - 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())); + { + 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())); + } Frag.Diagnostics.Suppress.emplace_back("*"); EXPECT_TRUE(compileAndApply()); diff --git clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/ReleaseNotes.rst index cc5f64a3f9fa..727c7622426c 100644 --- clang-tools-extra/docs/ReleaseNotes.rst +++ clang-tools-extra/docs/ReleaseNotes.rst @@ -43,21 +43,12 @@ 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 <https://discourse.llvm.org/t/removing-pseudo-parser/71131/>`_ for - more details. - -... - Improvements to clangd ---------------------- Inlay hints ^^^^^^^^^^^ -- Added `DefaultArguments` Inlay Hints option. - Diagnostics ^^^^^^^^^^^ @@ -73,16 +64,9 @@ Hover Code completion ^^^^^^^^^^^^^^^ -- Added completion for C++20 keywords. - Code actions ^^^^^^^^^^^^ -- Added `Swap operands` tweak for certain binary operators. - -- Improved the extract-to-function code action to allow extracting statements - with overloaded operators like ``<<`` of ``std::ostream``. - Signature help ^^^^^^^^^^^^^^ @@ -95,326 +79,30 @@ Objective-C Miscellaneous ^^^^^^^^^^^^^ -- The DefineOutline tweak now handles member functions of class templates. - Improvements to clang-doc ------------------------- Improvements to clang-query --------------------------- -- Added `set enable-profile true/false` command for basic matcher profiling. - Improvements to clang-tidy -------------------------- -- Improved :program:`clang-tidy-diff.py` script. Add the `-only-check-in-db` - option to exclude files not present in the compilation database, avoiding - false-negative results. - -- Improved :program:`run-clang-tidy.py` script. Fixed minor shutdown noise - happening on certain platforms when interrupting the script. - -- Improved :program:`clang-tidy`: - - - add support for `--verify-config` flag to check the configuration options of - the `Clang Static Analyzer Checks <https://clang.llvm.org/docs/analyzer/checkers.html>`_. - - accept parameters file in command line. - - fix incorrect configuration file path resolving when file paths contain ``..``. - - remove global options for most of checks. All options are changed to local - options except `IncludeStyle`, `StrictMode` and `IgnoreMacros`. Global scoped - `StrictMode` and `IgnoreMacros` are deprecated and will be removed in further - releases. - -.. csv-table:: - :header: "Check", "Options removed from global option" - - :doc:`bugprone-reserved-identifier <clang-tidy/checks/bugprone/reserved-identifier>`, AggressiveDependentMemberLookup - :doc:`bugprone-unchecked-optional-access <clang-tidy/checks/bugprone/unchecked-optional-access>`, IgnoreSmartPointerDereference - :doc:`cppcoreguidelines-pro-type-member-init <clang-tidy/checks/cppcoreguidelines/pro-type-member-init>`, UseAssignment - :doc:`cppcoreguidelines-rvalue-reference-param-not-moved <clang-tidy/checks/cppcoreguidelines/rvalue-reference-param-not-moved>`, AllowPartialMove; IgnoreUnnamedParams; IgnoreNonDeducedTemplateTypes - :doc:`misc-include-cleaner <clang-tidy/checks/misc/include-cleaner>`, IgnoreHeaders; DeduplicateFindings - :doc:`performance-inefficient-vector-operation <clang-tidy/checks/performance/inefficient-vector-operation>`, EnableProto - :doc:`readability-identifier-naming <clang-tidy/checks/readability/identifier-naming>`, AggressiveDependentMemberLookup - :doc:`readability-inconsistent-declaration-parameter-name <clang-tidy/checks/readability/inconsistent-declaration-parameter-name>`, Strict - :doc:`readability-redundant-access-specifiers <clang-tidy/checks/readability/redundant-access-specifiers>`, CheckFirstDeclaration - :doc:`readability-redundant-casting <clang-tidy/checks/readability/redundant-casting>`, IgnoreTypeAliases - New checks ^^^^^^^^^^ -- New :doc:`bugprone-bitwise-pointer-cast - <clang-tidy/checks/bugprone/bitwise-pointer-cast>` check. - - Warns about code that tries to cast between pointers by means of - ``std::bit_cast`` or ``memcpy``. - -- New :doc:`bugprone-incorrect-enable-shared-from-this - <clang-tidy/checks/bugprone/incorrect-enable-shared-from-this>` check. - - Detect classes or structs that do not publicly inherit from - ``std::enable_shared_from_this``, because unintended behavior will - otherwise occur when calling ``shared_from_this``. - -- New :doc:`bugprone-nondeterministic-pointer-iteration-order - <clang-tidy/checks/bugprone/nondeterministic-pointer-iteration-order>` - check. - - Finds nondeterministic usages of pointers in unordered containers. - -- New :doc:`bugprone-tagged-union-member-count - <clang-tidy/checks/bugprone/tagged-union-member-count>` check. - - Gives warnings for tagged unions, where the number of tags is - different from the number of data members inside the union. - -- New :doc:`modernize-use-integer-sign-comparison - <clang-tidy/checks/modernize/use-integer-sign-comparison>` check. - - Replace comparisons between signed and unsigned integers with their safe - C++20 ``std::cmp_*`` alternative, if available. - -- New :doc:`portability-template-virtual-member-function - <clang-tidy/checks/portability/template-virtual-member-function>` check. - - Finds cases when an uninstantiated virtual member function in a template class - causes cross-compiler incompatibility. - New check aliases ^^^^^^^^^^^^^^^^^ -- New alias :doc:`cert-arr39-c <clang-tidy/checks/cert/arr39-c>` to - :doc:`bugprone-sizeof-expression - <clang-tidy/checks/bugprone/sizeof-expression>` was added. - Changes in existing checks ^^^^^^^^^^^^^^^^^^^^^^^^^^ -- Improved :doc:`altera-id-dependent-backward-branch - <clang-tidy/checks/altera/id-dependent-backward-branch>` check by fixing - crashes from invalid code. - -- Improved :doc:`bugprone-branch-clone - <clang-tidy/checks/bugprone/branch-clone>` check to improve detection of - branch clones by now detecting duplicate inner and outer if statements. - -- Improved :doc:`bugprone-casting-through-void - <clang-tidy/checks/bugprone/casting-through-void>` check to suggest replacing - the offending code with ``reinterpret_cast``, to more clearly express intent. - -- Improved :doc:`bugprone-dangling-handle - <clang-tidy/checks/bugprone/dangling-handle>` check to treat ``std::span`` as a - handle class. - -- Improved :doc:`bugprone-exception-escape - <clang-tidy/checks/bugprone/exception-escape>` by fixing false positives - when a consteval function with throw statements. - -- Improved :doc:`bugprone-forwarding-reference-overload - <clang-tidy/checks/bugprone/forwarding-reference-overload>` check by fixing - a crash when determining if an ``enable_if[_t]`` was found. - -- Improve :doc:`bugprone-narrowing-conversions - <clang-tidy/checks/bugprone/narrowing-conversions>` to avoid incorrect check - results when floating point type is not ``float``, ``double`` and - ``long double``. - -- Improved :doc:`bugprone-optional-value-conversion - <clang-tidy/checks/bugprone/optional-value-conversion>` to support detecting - conversion directly by ``std::make_unique`` and ``std::make_shared``. - -- Improved :doc:`bugprone-posix-return - <clang-tidy/checks/bugprone/posix-return>` check to support integer literals - as LHS and posix call as RHS of comparison. - -- Improved :doc:`bugprone-return-const-ref-from-parameter - <clang-tidy/checks/bugprone/return-const-ref-from-parameter>` check to - diagnose potential dangling references when returning a ``const &`` parameter - by using the conditional operator ``cond ? var1 : var2`` and fixing false - positives for functions which contain lambda and ignore parameters - with ``[[clang::lifetimebound]]`` attribute. - -- Improved :doc:`bugprone-sizeof-expression - <clang-tidy/checks/bugprone/sizeof-expression>` check to find suspicious - usages of ``sizeof()``, ``alignof()``, and ``offsetof()`` when adding or - subtracting from a pointer directly or when used to scale a numeric value and - fix false positive when sizeof expression with template types. - -- Improved :doc:`bugprone-throw-keyword-missing - <clang-tidy/checks/bugprone/throw-keyword-missing>` by fixing a false positive - when using non-static member initializers and a constructor. - -- Improved :doc:`bugprone-unchecked-optional-access - <clang-tidy/checks/bugprone/unchecked-optional-access>` to support - ``bsl::optional`` and ``bdlb::NullableValue`` from - <https://github.com/bloomberg/bde>_. - -- Improved :doc:`bugprone-unhandled-self-assignment - <clang-tidy/checks/bugprone/unhandled-self-assignment>` check by fixing smart - pointer check against std::unique_ptr type. - -- Improved :doc:`bugprone-unsafe-functions - <clang-tidy/checks/bugprone/unsafe-functions>` check to allow specifying - additional functions to match. - -- Improved :doc:`bugprone-unused-local-non-trivial-variable - <clang-tidy/checks/bugprone/unused-local-non-trivial-variable>` check to avoid - false positives when using name-independent variables after C++26. - -- Improved :doc:`bugprone-use-after-move - <clang-tidy/checks/bugprone/use-after-move>` to avoid triggering on - ``reset()`` calls on moved-from ``std::optional`` and ``std::any`` objects, - similarly to smart pointers. - -- Improved :doc:`cert-flp30-c <clang-tidy/checks/cert/flp30-c>` check to - fix false positive that floating point variable is only used in increment - expression. - -- Improved :doc:`cppcoreguidelines-avoid-const-or-ref-data-members - <clang-tidy/checks/cppcoreguidelines/avoid-const-or-ref-data-members>` check to - avoid false positives when detecting a templated class with inheritance. - -- Improved :doc:`cppcoreguidelines-init-variables - <clang-tidy/checks/cppcoreguidelines/init-variables>` check by fixing the - insertion location for function pointers. - -- Improved :doc:`cppcoreguidelines-prefer-member-initializer - <clang-tidy/checks/cppcoreguidelines/prefer-member-initializer>` check to - avoid false positive when member initialization depends on a structured - binding variable. - -- Fixed :doc:`cppcoreguidelines-pro-type-union-access - <clang-tidy/checks/cppcoreguidelines/pro-type-union-access>` check to - report a location even when the member location is not valid. - -- Improved :doc:`misc-definitions-in-headers - <clang-tidy/checks/misc/definitions-in-headers>` check by rewording the - diagnostic note that suggests adding ``inline``. - -- Improved :doc:`misc-redundant-expression - <clang-tidy/checks/misc/redundant-expression>` check by extending the - checker to detect floating point and integer literals in redundant - expressions. - -- Improved :doc:`misc-unconventional-assign-operator - <clang-tidy/checks/misc/unconventional-assign-operator>` check to avoid - false positive for C++23 deducing this. - -- Improved :doc:`misc-use-internal-linkage - <clang-tidy/checks/misc/use-internal-linkage>` check to insert ``static`` - keyword before type qualifiers such as ``const`` and ``volatile``. Also, fix - false positives for function declaration without body, C++20 consteval - functions, C++20 export declarations, and global scoped - overloaded ``operator new`` and ``operator delete``. - -- Improved :doc:`modernize-avoid-c-arrays - <clang-tidy/checks/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-loop-convert - <clang-tidy/checks/modernize/loop-convert>` check to fix false positive when - using loop variable in initializer of lambda capture. - -- Improved :doc:`modernize-min-max-use-initializer-list - <clang-tidy/checks/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-raw-string-literal - <clang-tidy/checks/modernize/raw-string-literal>` check to fix incorrect - fix-it when the string contains a user-defined suffix. - -- Improved :doc:`modernize-use-designated-initializers - <clang-tidy/checks/modernize/use-designated-initializers>` check to fix a - crash when a class is declared but not defined. - -- Improved :doc:`modernize-use-integer-sign-comparison - <clang-tidy/checks/modernize/use-integer-sign-comparison>` check to - add an option ``EnableQtSupport``, that makes C++17 ``q20::cmp_*`` alternative - available for Qt-based applications. - -- Improved :doc:`modernize-use-nullptr - <clang-tidy/checks/modernize/use-nullptr>` check to also recognize - ``NULL``/``__null`` (but not ``0``) when used with a templated type. - -- Improved :doc:`modernize-use-starts-ends-with - <clang-tidy/checks/modernize/use-starts-ends-with>` check to handle two new - cases from ``rfind`` and ``compare`` to ``ends_with``, and one new case from - ``substr`` to ``starts_with``, and a small adjustment to the diagnostic message. - -- Improved :doc:`modernize-use-std-format - <clang-tidy/checks/modernize/use-std-format>` check to support replacing - member function calls too and to only expand macros starting with ``PRI`` - and ``__PRI`` from ``<inttypes.h>`` in the format string. - -- Improved :doc:`modernize-use-std-print - <clang-tidy/checks/modernize/use-std-print>` check to support replacing - member function calls too and to only expand macros starting with ``PRI`` - and ``__PRI`` from ``<inttypes.h>`` in the format string. - -- Improved :doc:`modernize-use-using - <clang-tidy/checks/modernize/use-using>` check by not expanding macros. - -- Improved :doc:`performance-avoid-endl - <clang-tidy/checks/performance/avoid-endl>` check to use ``std::endl`` as - placeholder when lexer cannot get source text. - -- Improved :doc:`performance-move-const-arg - <clang-tidy/checks/performance/move-const-arg>` check to fix a crash when - an argument type is declared but not defined. - -- Improved :doc:`performance-unnecessary-copy-initialization - <clang-tidy/checks/performance/unnecessary-copy-initialization>` check - to consider static member functions the same way as free functions. - -- Improved :doc:`readability-container-contains - <clang-tidy/checks/readability/container-contains>` check to let it work on - any class that has a ``contains`` method. Fix some false negatives in the - ``find()`` case. - -- Improved :doc:`readability-enum-initial-value - <clang-tidy/checks/readability/enum-initial-value>` check by only issuing - diagnostics for the definition of an ``enum``, by not emitting a redundant - file path for anonymous enums in the diagnostic, and by fixing a typo in the - diagnostic. - -- Improved :doc:`readability-identifier-naming - <clang-tidy/checks/readability/identifier-naming>` check to - validate ``namespace`` aliases. - -- Improved :doc:`readability-implicit-bool-conversion - <clang-tidy/checks/readability/implicit-bool-conversion>` check - by adding the option `UseUpperCaseLiteralSuffix` to select the - case of the literal suffix in fixes and fixing false positive for implicit - conversion of comparison result in C23. - -- Improved :doc:`readability-redundant-casting - <clang-tidy/checks/readability/redundant-casting>` check - by addressing a false positive in aggregate initialization through - parenthesized list. - -- Improved :doc:`readability-redundant-smartptr-get - <clang-tidy/checks/readability/redundant-smartptr-get>` check to - remove ``->``, when redundant ``get()`` is removed. - -- Improved :doc:`readability-use-std-min-max - <clang-tidy/checks/readability/use-std-min-max>` check to use correct template - type in ``std::min`` and ``std::max`` when operand is integer literal. - Removed checks ^^^^^^^^^^^^^^ Miscellaneous ^^^^^^^^^^^^^ -- The :doc:`bugprone-narrowing-conversions <clang-tidy/checks/bugprone/narrowing-conversions>` - check is no longer an alias of :doc:`cppcoreguidelines-narrowing-conversions - <clang-tidy/checks/cppcoreguidelines/narrowing-conversions>`. Instead, - :doc:`cppcoreguidelines-narrowing-conversions - <clang-tidy/checks/cppcoreguidelines/narrowing-conversions>` is now an alias - of :doc:`bugprone-narrowing-conversions <clang-tidy/checks/bugprone/narrowing-conversions>`. - Improvements to include-fixer ----------------------------- diff --git clang-tools-extra/docs/clang-tidy/checks/bugprone/assert-side-effect.rst clang-tools-extra/docs/clang-tidy/checks/bugprone/assert-side-effect.rst index 8ba84ff61c6a..1355afae92e4 100644 --- clang-tools-extra/docs/clang-tidy/checks/bugprone/assert-side-effect.rst +++ clang-tools-extra/docs/clang-tidy/checks/bugprone/assert-side-effect.rst @@ -26,8 +26,8 @@ Options A semicolon-separated list of the names of functions or methods to be considered as not having side-effects. Regular expressions are accepted, - e.g. `[Rr]ef(erence)?$` matches every type with suffix `Ref`, `ref`, - `Reference` and `reference`. The default is empty. If a name in the list - contains the sequence `::` it is matched against the qualified typename - (i.e. `namespace::Type`, otherwise it is matched against only - the type name (i.e. `Type`). + e.g. ``[Rr]ef(erence)?$`` matches every type with suffix ``Ref``, ``ref``, + ``Reference`` and ``reference``. The default is empty. If a name in the list + contains the sequence `::` it is matched against the qualified type name + (i.e. ``namespace::Type``), otherwise it is matched against only + the type name (i.e. ``Type``). diff --git clang-tools-extra/docs/clang-tidy/checks/performance/for-range-copy.rst clang-tools-extra/docs/clang-tidy/checks/performance/for-range-copy.rst index 01fde9580e2a..d74098402948 100644 --- clang-tools-extra/docs/clang-tidy/checks/performance/for-range-copy.rst +++ clang-tools-extra/docs/clang-tidy/checks/performance/for-range-copy.rst @@ -23,14 +23,15 @@ Options .. option:: WarnOnAllAutoCopies - When `true`, warns on any use of `auto` as the type of the range-based for + When `true`, warns on any use of ``auto`` as the type of the range-based for loop variable. Default is `false`. .. option:: AllowedTypes A semicolon-separated list of names of types allowed to be copied in each - iteration. Regular expressions are accepted, e.g. `[Rr]ef(erence)?$` matches - every type with suffix `Ref`, `ref`, `Reference` and `reference`. The default - is empty. If a name in the list contains the sequence `::` it is matched - against the qualified typename (i.e. `namespace::Type`, otherwise it is - matched against only the type name (i.e. `Type`). + iteration. Regular expressions are accepted, e.g. ``[Rr]ef(erence)?$`` + matches every type with suffix ``Ref``, ``ref``, ``Reference`` and + ``reference``. The default is empty. If a name in the list contains the + sequence `::`, it is matched against the qualified type name + (i.e. ``namespace::Type``), otherwise it is matched against only the + type name (i.e. ``Type``). diff --git clang-tools-extra/docs/clang-tidy/checks/performance/unnecessary-copy-initialization.rst clang-tools-extra/docs/clang-tidy/checks/performance/unnecessary-copy-initialization.rst index 837283811ddc..bb4f42c88d62 100644 --- clang-tools-extra/docs/clang-tidy/checks/performance/unnecessary-copy-initialization.rst +++ clang-tools-extra/docs/clang-tidy/checks/performance/unnecessary-copy-initialization.rst @@ -42,11 +42,11 @@ Options .. option:: AllowedTypes A semicolon-separated list of names of types allowed to be initialized by - copying. Regular expressions are accepted, e.g. `[Rr]ef(erence)?$` matches - every type with suffix `Ref`, `ref`, `Reference` and `reference`. The default - is empty. If a name in the list contains the sequence `::` it is matched - against the qualified typename (i.e. `namespace::Type`, otherwise it is - matched against only the type name (i.e. `Type`). + copying. Regular expressions are accepted, e.g. ``[Rr]ef(erence)?$`` matches + every type with suffix ``Ref``, ``ref``, ``Reference`` and ``reference``. + The default is empty. If a name in the list contains the sequence `::`, it + is matched against the qualified type name (i.e. ``namespace::Type``), + otherwise it is matched against only the type name (i.e. ``Type``). .. option:: ExcludedContainerTypes diff --git clang-tools-extra/docs/clang-tidy/checks/performance/unnecessary-value-param.rst clang-tools-extra/docs/clang-tidy/checks/performance/unnecessary-value-param.rst index cc5e1ae73508..d13c53eea994 100644 --- clang-tools-extra/docs/clang-tidy/checks/performance/unnecessary-value-param.rst +++ clang-tools-extra/docs/clang-tidy/checks/performance/unnecessary-value-param.rst @@ -65,8 +65,8 @@ Options .. option:: AllowedTypes A semicolon-separated list of names of types allowed to be passed by value. - Regular expressions are accepted, e.g. `[Rr]ef(erence)?$` matches every type - with suffix `Ref`, `ref`, `Reference` and `reference`. The default is - empty. If a name in the list contains the sequence `::` it is matched against - the qualified typename (i.e. `namespace::Type`, otherwise it is matched - against only the type name (i.e. `Type`). + Regular expressions are accepted, e.g. ``[Rr]ef(erence)?$`` matches every + type with suffix ``Ref``, ``ref``, ``Reference`` and ``reference``. The + default is empty. If a name in the list contains the sequence `::`, it is + matched against the qualified type name (i.e. ``namespace::Type``), + otherwise it is matched against only the type name (i.e. ``Type``). diff --git clang/CMakeLists.txt clang/CMakeLists.txt index cacbf2ebf868..c3f30e2a8e9c 100644 --- clang/CMakeLists.txt +++ clang/CMakeLists.txt @@ -331,6 +331,7 @@ if(NOT DEFINED CLANG_VERSION_SUFFIX) set(CLANG_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX}) endif() set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}${CLANG_VERSION_SUFFIX}") +set(MAX_CLANG_ABI_COMPAT_VERSION "${LLVM_VERSION_MAJOR}") message(STATUS "Clang version: ${CLANG_VERSION}") # Configure the Version.inc file. @@ -431,18 +432,16 @@ if(NOT LLVM_STATIC_LINK_CXX_STDLIB) set(HAVE_CLANG_REPL_SUPPORT ON) endif() -option(CLANG_ENABLE_ARCMT "Build ARCMT." ON) +option(CLANG_ENABLE_OBJC_REWRITER "Build the Objective-C rewriter tool" OFF) + option(CLANG_ENABLE_STATIC_ANALYZER "Include static analyzer in clang binary." ON) option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF) -if(NOT CLANG_ENABLE_STATIC_ANALYZER AND CLANG_ENABLE_ARCMT) - message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or Z3") -endif() - -if(CLANG_ENABLE_ARCMT) - set(CLANG_ENABLE_OBJC_REWRITER ON) +if (DEFINED CLANG_ENABLE_ARCMT) + set(CLANG_ENABLE_OBJC_REWRITER ${CLANG_ENABLE_ARCMT}) + message(DEPRECATION "'CLANG_ENABLE_ARCMT' is deprecated as ARCMigrate has been removed from Clang. Please use 'CLANG_ENABLE_OBJC_REWRITER' instead to enable or disable the Objective-C rewriter.") endif() # This option is a stop-gap, we should commit to removing this as diff --git clang/cmake/caches/Android.cmake clang/cmake/caches/Android.cmake index d5ca6b50d4ad..c89e31f67cc9 100644 --- clang/cmake/caches/Android.cmake +++ clang/cmake/caches/Android.cmake @@ -2,7 +2,6 @@ set(LLVM_TARGETS_TO_BUILD X86 CACHE STRING "") -set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "") set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "") set(CLANG_TIDY_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "") set(CLANG_VENDOR Android CACHE STRING "") diff --git clang/cmake/caches/Fuchsia-stage2.cmake clang/cmake/caches/Fuchsia-stage2.cmake index 1cbf691f29d5..ba1bb3573311 100644 --- clang/cmake/caches/Fuchsia-stage2.cmake +++ clang/cmake/caches/Fuchsia-stage2.cmake @@ -44,7 +44,6 @@ set(CLANG_DEFAULT_LINKER lld CACHE STRING "") set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "") set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "") set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "") -set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "") set(CLANG_ENABLE_STATIC_ANALYZER ON CACHE BOOL "") set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "") @@ -190,6 +189,10 @@ foreach(target aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn set(RUNTIMES_${target}_LLVM_TOOLS_DIR "${CMAKE_BINARY_DIR}/bin" CACHE BOOL "") set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "") + # Enable FatLTO for Linux and baremetal runtimes + set(RUNTIMES_${target}_LLVM_ENABLE_LTO ON CACHE BOOL "") + set(RUNTIMES_${target}_LLVM_ENABLE_FATLTO ON CACHE BOOL "") + # Use .build-id link. list(APPEND RUNTIME_BUILD_ID_LINK "${target}") endif() @@ -272,6 +275,10 @@ if(FUCHSIA_SDK) set(RUNTIMES_${target}+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "") set(RUNTIMES_${target}+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "") + # Enable FatLTO for Fuchsia runtimes + set(RUNTIMES_${target}_LLVM_ENABLE_LTO ON CACHE BOOL "") + set(RUNTIMES_${target}_LLVM_ENABLE_FATLTO ON CACHE BOOL "") + # Use .build-id link. list(APPEND RUNTIME_BUILD_ID_LINK "${target}") endforeach() @@ -369,6 +376,10 @@ foreach(target armv6m-none-eabi;armv7m-none-eabi;armv7em-none-eabi;armv8m.main-n set(RUNTIMES_${target}_LLVM_INCLUDE_TESTS OFF CACHE BOOL "") set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "") set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc;libcxx" CACHE STRING "") + + # Enable FatLTO for baremetal runtimes + set(RUNTIMES_${target}_LLVM_ENABLE_LTO ON CACHE BOOL "") + set(RUNTIMES_${target}_LLVM_ENABLE_FATLTO ON CACHE BOOL "") endforeach() foreach(target riscv32-unknown-elf) @@ -420,6 +431,10 @@ foreach(target riscv32-unknown-elf) set(RUNTIMES_${target}_LLVM_INCLUDE_TESTS OFF CACHE BOOL "") set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "") set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc;libcxx" CACHE STRING "") + + # Enable FatLTO for baremetal runtimes + set(RUNTIMES_${target}_LLVM_ENABLE_LTO ON CACHE BOOL "") + set(RUNTIMES_${target}_LLVM_ENABLE_FATLTO ON CACHE BOOL "") endforeach() set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "") diff --git clang/cmake/caches/Fuchsia.cmake clang/cmake/caches/Fuchsia.cmake index 07637cd0ed08..83336589da30 100644 --- clang/cmake/caches/Fuchsia.cmake +++ clang/cmake/caches/Fuchsia.cmake @@ -84,7 +84,6 @@ set(CLANG_DEFAULT_LINKER lld CACHE STRING "") set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "") set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "") set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "") -set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "") set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "") set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "") diff --git clang/docs/ClangFormatStyleOptions.rst clang/docs/ClangFormatStyleOptions.rst index 30a2325949f4..bbb912eb10e9 100644 --- clang/docs/ClangFormatStyleOptions.rst +++ clang/docs/ClangFormatStyleOptions.rst @@ -5198,6 +5198,11 @@ the configuration (without a prefix: ``Auto``). **PenaltyBreakBeforeFirstCallParameter** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <PenaltyBreakBeforeFirstCallParameter>` The penalty for breaking a function call after ``call(``. +.. _PenaltyBreakBeforeMemberAccess: + +**PenaltyBreakBeforeMemberAccess** (``Unsigned``) :versionbadge:`clang-format 20` :ref:`¶ <PenaltyBreakBeforeMemberAccess>` + The penalty for breaking before a member access operator (``.``, ``->``). + .. _PenaltyBreakComment: **PenaltyBreakComment** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ <PenaltyBreakComment>` diff --git clang/docs/HIPSupport.rst clang/docs/HIPSupport.rst index e830acd8dd85..481ed3923081 100644 --- clang/docs/HIPSupport.rst +++ clang/docs/HIPSupport.rst @@ -27,7 +27,8 @@ AMD GPU Support Clang provides HIP support on AMD GPUs via the ROCm platform `<https://rocm.docs.amd.com/en/latest/#>`_. The ROCm runtime forms the base for HIP host APIs, while HIP device APIs are realized through HIP header files and the ROCm device library. The Clang driver uses the HIPAMD toolchain to compile HIP device code -to AMDGPU ISA via the AMDGPU backend. The compiled code is then bundled and embedded in the host executables. +to AMDGPU ISA via the AMDGPU backend, or SPIR-V via the workflow outlined below. +The compiled code is then bundled and embedded in the host executables. Intel GPU Support ================= @@ -285,6 +286,401 @@ Example Usage basePtr->virtualFunction(); // Allowed since obj is constructed in device code } +C++ Standard Parallelism Offload Support: Compiler And Runtime +============================================================== + +Introduction +============ + +This section describes the implementation of support for offloading the +execution of standard C++ algorithms to accelerators that can be targeted via +HIP. Furthermore, it enumerates restrictions on user defined code, as well as +the interactions with runtimes. + +Algorithm Offload: What, Why, Where +=================================== + +C++17 introduced overloads +`for most algorithms in the standard library <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0024r2.html>`_ +which allow the user to specify a desired +`execution policy <https://en.cppreference.com/w/cpp/algorithm#Execution_policies>`_. +The `parallel_unsequenced_policy <https://en.cppreference.com/w/cpp/algorithm/execution_policy_tag_t>`_ +maps relatively well to the execution model of AMD GPUs. This, coupled with the +the availability and maturity of GPU accelerated algorithm libraries that +implement most / all corresponding algorithms in the standard library +(e.g. `rocThrust <https://github.com/ROCmSoftwarePlatform/rocThrust>`__), makes +it feasible to provide seamless accelerator offload for supported algorithms, +when an accelerated version exists. Thus, it becomes possible to easily access +the computational resources of an AMD accelerator, via a well specified, +familiar, algorithmic interface, without having to delve into low-level hardware +specific details. Putting it all together: + +- **What**: standard library algorithms, when invoked with the + ``parallel_unsequenced_policy`` +- **Why**: democratise AMDGPU accelerator programming, without loss of user + familiarity +- **Where**: only AMDGPU accelerators targeted by Clang/LLVM via HIP + +Small Example +============= + +Given the following C++ code: + +.. code-block:: C++ + + bool has_the_answer(const std::vector<int>& v) { + return std::find(std::execution::par_unseq, std::cbegin(v), std::cend(v), 42) != std::cend(v); + } + +if Clang is invoked with the ``--hipstdpar --offload-arch=foo`` flags, the call +to ``find`` will be offloaded to an accelerator that is part of the ``foo`` +target family. If either ``foo`` or its runtime environment do not support +transparent on-demand paging (such as e.g. that provided in Linux via +`HMM <https://docs.kernel.org/mm/hmm.html>`_), it is necessary to also include +the ``--hipstdpar-interpose-alloc`` flag. If the accelerator specific algorithm +library ``foo`` uses doesn't have an implementation of a particular algorithm, +execution seamlessly falls back to the host CPU. It is legal to specify multiple +``--offload-arch``\s. All the flags we introduce, as well as a thorough view of +various restrictions an their implementations, will be provided below. + +Implementation - General View +============================= + +We built support for Algorithm Offload support atop the pre-existing HIP +infrastructure. More specifically, when one requests offload via ``--hipstdpar``, +compilation is switched to HIP compilation, as if ``-x hip`` was specified. +Similarly, linking is also switched to HIP linking, as if ``--hip-link`` was +specified. Note that these are implicit, and one should not assume that any +interop with HIP specific language constructs is available e.g. ``__device__`` +annotations are neither necessary nor guaranteed to work. + +Since there are no language restriction mechanisms in place, it is necessary to +relax HIP language specific semantic checks performed by the FE; they would +identify otherwise valid, offloadable code, as invalid HIP code. Given that we +know that the user intended only for certain algorithms to be offloaded, and +encoded this by specifying the ``parallel_unsequenced_policy``, we rely on a +pass over IR to clean up any and all code that was not "meant" for offload. If +requested, allocation interposition is also handled via a separate pass over IR. + +To interface with the client HIP runtime, and to forward offloaded algorithm +invocations to the corresponding accelerator specific library implementation, an +implementation detail forwarding header is implicitly included by the driver, +when compiling with ``--hipstdpar``. In what follows, we will delve into each +component that contributes to implementing Algorithm Offload support. + +Implementation - Driver +======================= + +We augment the ``clang`` driver with the following flags: + +- ``--hipstdpar`` enables algorithm offload, which depending on phase, has the + following effects: + + - when compiling: + + - ``-x hip`` gets prepended to enable HIP support; + - the ``ROCmToolchain`` component checks for the ``hipstdpar_lib.hpp`` + forwarding header, + `rocThrust <https://rocm.docs.amd.com/projects/rocThrust/en/latest/>`_ and + `rocPrim <https://rocm.docs.amd.com/projects/rocPRIM/en/latest/>`_ in + their canonical locations, which can be overriden via flags found below; + if all are found, the forwarding header gets implicitly included, + otherwise an error listing the missing component is generated; + - the ``LangOpts.HIPStdPar`` member is set. + + - when linking: + + - ``--hip-link`` and ``-frtlib-add-rpath`` gets appended to enable HIP + support. + +- ``--hipstdpar-interpose-alloc`` enables the interposition of standard + allocation / deallocation functions with accelerator aware equivalents; the + ``LangOpts.HIPStdParInterposeAlloc`` member is set; +- ``--hipstdpar-path=`` specifies a non-canonical path for the forwarding + header; it must point to the folder where the header is located and not to the + header itself; +- ``--hipstdpar-thrust-path=`` specifies a non-canonical path for + `rocThrust <https://rocm.docs.amd.com/projects/rocThrust/en/latest/>`_; it + must point to the folder where the library is installed / built under a + ``/thrust`` subfolder; +- ``--hipstdpar-prim-path=`` specifies a non-canonical path for + `rocPrim <https://rocm.docs.amd.com/projects/rocPRIM/en/latest/>`_; it must + point to the folder where the library is installed / built under a + ``/rocprim`` subfolder; + +The `--offload-arch <https://llvm.org/docs/AMDGPUUsage.html#amdgpu-processors>`_ +flag can be used to specify the accelerator for which offload code is to be +generated. + +Implementation - Front-End +========================== + +When ``LangOpts.HIPStdPar`` is set, we relax some of the HIP language specific +``Sema`` checks to account for the fact that we want to consume pure unannotated +C++ code: + +1. ``__device__`` / ``__host__ __device__`` functions (which would originate in + the accelerator specific algorithm library) are allowed to call implicitly + ``__host__`` functions; +2. ``__global__`` functions (which would originate in the accelerator specific + algorithm library) are allowed to call implicitly ``__host__`` functions; +3. resolving ``__builtin`` availability is deferred, because it is possible that + a ``__builtin`` that is unavailable on the target accelerator is not + reachable from any offloaded algorithm, and thus will be safely removed in + the middle-end; +4. ASM parsing / checking is deferred, because it is possible that an ASM block + that e.g. uses some constraints that are incompatible with the target + accelerator is not reachable from any offloaded algorithm, and thus will be + safely removed in the middle-end. + +``CodeGen`` is similarly relaxed, with implicitly ``__host__`` functions being +emitted as well. + +Implementation - Middle-End +=========================== + +We add two ``opt`` passes: + +1. ``HipStdParAcceleratorCodeSelectionPass`` + + - For all kernels in a ``Module``, compute reachability, where a function + ``F`` is reachable from a kernel ``K`` if and only if there exists a direct + call-chain rooted in ``F`` that includes ``K``; + - Remove all functions that are not reachable from kernels; + - This pass is only run when compiling for the accelerator. + +The first pass assumes that the only code that the user intended to offload was +that which was directly or transitively invocable as part of an algorithm +execution. It also assumes that an accelerator aware algorithm implementation +would rely on accelerator specific special functions (kernels), and that these +effectively constitute the only roots for accelerator execution graphs. Both of +these assumptions are based on observing how widespread accelerators, +such as GPUs, work. + +1. ``HipStdParAllocationInterpositionPass`` + + - Iterate through all functions in a ``Module``, and replace standard + allocation / deallocation functions with accelerator-aware equivalents, + based on a pre-established table; the list of functions that can be + interposed is available + `here <https://github.com/ROCmSoftwarePlatform/roc-stdpar#allocation--deallocation-interposition-status>`__; + - This is only run when compiling for the host. + +The second pass is optional. + +Implementation - Forwarding Header +================================== + +The forwarding header implements two pieces of functionality: + +1. It forwards algorithms to a target accelerator, which is done by relying on + C++ language rules around overloading: + + - overloads taking an explicit argument of type + ``parallel_unsequenced_policy`` are introduced into the ``std`` namespace; + - these will get preferentially selected versus the master template; + - the body forwards to the equivalent algorithm from the accelerator specific + library + +2. It provides allocation / deallocation functions that are equivalent to the + standard ones, but obtain memory by invoking + `hipMallocManaged <https://rocm.docs.amd.com/projects/HIP/en/latest/.doxygen/docBin/html/group___memory_m.html#gab8cfa0e292193fa37e0cc2e4911fa90a>`_ + and release it via `hipFree <https://rocm.docs.amd.com/projects/HIP/en/latest/.doxygen/docBin/html/group___memory.html#ga740d08da65cae1441ba32f8fedb863d1>`_. + +Predefined Macros +================= + +.. list-table:: + :header-rows: 1 + + * - Macro + - Description + * - ``__HIPSTDPAR__`` + - Defined when Clang is compiling code in algorithm offload mode, enabled + with the ``--hipstdpar`` compiler option. + * - ``__HIPSTDPAR_INTERPOSE_ALLOC__`` + - Defined only when compiling in algorithm offload mode, when the user + enables interposition mode with the ``--hipstdpar-interpose-alloc`` + compiler option, indicating that all dynamic memory allocation / + deallocation functions should be replaced with accelerator aware + variants. + +Restrictions +============ + +We define two modes in which runtime execution can occur: + +1. **HMM Mode** - this assumes that the + `HMM <https://docs.kernel.org/mm/hmm.html>`_ subsystem of the Linux kernel + is used to provide transparent on-demand paging i.e. memory obtained from a + system / OS allocator such as via a call to ``malloc`` or ``operator new`` is + directly accessible to the accelerator and it follows the C++ memory model; +2. **Interposition Mode** - this is a fallback mode for cases where transparent + on-demand paging is unavailable (e.g. in the Windows OS), which means that + memory must be allocated via an accelerator aware mechanism, and system + allocated memory is inaccessible for the accelerator. + +The following restrictions imposed on user code apply to both modes: + +1. Pointers to function, and all associated features, such as e.g. dynamic + polymorphism, cannot be used (directly or transitively) by the user provided + callable passed to an algorithm invocation; +2. Global / namespace scope / ``static`` / ``thread`` storage duration variables + cannot be used (directly or transitively) in name by the user provided + callable; + + - When executing in **HMM Mode** they can be used in address e.g.: + + .. code-block:: C++ + + namespace { int foo = 42; } + + bool never(const std::vector<int>& v) { + return std::any_of(std::execution::par_unseq, std::cbegin(v), std::cend(v), [](auto&& x) { + return x == foo; + }); + } + + bool only_in_hmm_mode(const std::vector<int>& v) { + return std::any_of(std::execution::par_unseq, std::cbegin(v), std::cend(v), + [p = &foo](auto&& x) { return x == *p; }); + } + +3. Only algorithms that are invoked with the ``parallel_unsequenced_policy`` are + candidates for offload; +4. Only algorithms that are invoked with iterator arguments that model + `random_access_iterator <https://en.cppreference.com/w/cpp/iterator/random_access_iterator>`_ + are candidates for offload; +5. `Exceptions <https://en.cppreference.com/w/cpp/language/exceptions>`_ cannot + be used by the user provided callable; +6. Dynamic memory allocation (e.g. ``operator new``) cannot be used by the user + provided callable; +7. Selective offload is not possible i.e. it is not possible to indicate that + only some algorithms invoked with the ``parallel_unsequenced_policy`` are to + be executed on the accelerator. + +In addition to the above, using **Interposition Mode** imposes the following +additional restrictions: + +1. All code that is expected to interoperate has to be recompiled with the + ``--hipstdpar-interpose-alloc`` flag i.e. it is not safe to compose libraries + that have been independently compiled; +2. automatic storage duration (i.e. stack allocated) variables cannot be used + (directly or transitively) by the user provided callable e.g. + + .. code-block:: c++ + + bool never(const std::vector<int>& v, int n) { + return std::any_of(std::execution::par_unseq, std::cbegin(v), std::cend(v), + [p = &n](auto&& x) { return x == *p; }); + } + +Current Support +=============== + +At the moment, C++ Standard Parallelism Offload is only available for AMD GPUs, +when the `ROCm <https://rocm.docs.amd.com/en/latest/>`_ stack is used, on the +Linux operating system. Support is synthesised in the following table: + +.. list-table:: + :header-rows: 1 + + * - `Processor <https://llvm.org/docs/AMDGPUUsage.html#amdgpu-processors>`_ + - HMM Mode + - Interposition Mode + * - GCN GFX9 (Vega) + - YES + - YES + * - GCN GFX10.1 (RDNA 1) + - *NO* + - YES + * - GCN GFX10.3 (RDNA 2) + - *NO* + - YES + * - GCN GFX11 (RDNA 3) + - *NO* + - YES + * - GCN GFX12 (RDNA 4) + - *NO* + - YES + +The minimum Linux kernel version for running in HMM mode is 6.4. + +The forwarding header can be obtained from +`its GitHub repository <https://github.com/ROCmSoftwarePlatform/roc-stdpar>`_. +It will be packaged with a future `ROCm <https://rocm.docs.amd.com/en/latest/>`_ +release. Because accelerated algorithms are provided via +`rocThrust <https://rocm.docs.amd.com/projects/rocThrust/en/latest/>`_, a +transitive dependency on +`rocPrim <https://rocm.docs.amd.com/projects/rocPRIM/en/latest/>`_ exists. Both +can be obtained either by installing their associated components of the +`ROCm <https://rocm.docs.amd.com/en/latest/>`_ stack, or from their respective +repositories. The list algorithms that can be offloaded is available +`here <https://github.com/ROCmSoftwarePlatform/roc-stdpar#algorithm-support-status>`_. + +HIP Specific Elements +--------------------- + +1. There is no defined interop with the + `HIP kernel language <https://rocm.docs.amd.com/projects/HIP/en/latest/reference/kernel_language.html>`_; + whilst things like using `__device__` annotations might accidentally "work", + they are not guaranteed to, and thus cannot be relied upon by user code; + + - A consequence of the above is that both bitcode linking and linking + relocatable object files will "work", but it is not guaranteed to remain + working or actively tested at the moment; this restriction might be relaxed + in the future. + +2. Combining explicit HIP, CUDA or OpenMP Offload compilation with + ``--hipstdpar`` based offloading is not allowed or supported in any way. +3. There is no way to target different accelerators via a standard algorithm + invocation (`this might be addressed in future C++ standards <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2500r1.html>`_); + an unsafe (per the point above) way of achieving this is to spawn new threads + and invoke the `hipSetDevice <https://rocm.docs.amd.com/projects/HIP/en/latest/.doxygen/docBin/html/group___device.html#ga43c1e7f15925eeb762195ccb5e063eae>`_ + interface e.g.: + + .. code-block:: c++ + + int accelerator_0 = ...; + int accelerator_1 = ...; + + bool multiple_accelerators(const std::vector<int>& u, const std::vector<int>& v) { + std::atomic<unsigned int> r{0u}; + + thread t0{[&]() { + hipSetDevice(accelerator_0); + + r += std::count(std::execution::par_unseq, std::cbegin(u), std::cend(u), 42); + }}; + thread t1{[&]() { + hitSetDevice(accelerator_1); + + r += std::count(std::execution::par_unseq, std::cbegin(v), std::cend(v), 314152) + }}; + + t0.join(); + t1.join(); + + return r; + } + + Note that this is a temporary, unsafe workaround for a deficiency in the C++ + Standard. + +Open Questions / Future Developments +==================================== + +1. The restriction on the use of global / namespace scope / ``static`` / + ``thread`` storage duration variables in offloaded algorithms will be lifted + in the future, when running in **HMM Mode**; +2. The restriction on the use of dynamic memory allocation in offloaded + algorithms will be lifted in the future. +3. The restriction on the use of pointers to function, and associated features + such as dynamic polymorphism might be lifted in the future, when running in + **HMM Mode**; +4. Offload support might be extended to cases where the ``parallel_policy`` is + used for some or all targets. + SPIR-V Support on HIPAMD ToolChain ================================== @@ -316,13 +712,6 @@ Using ``--offload-arch=amdgcnspirv`` - **Clang Offload Bundler**: The resulting SPIR-V is embedded in the Clang offload bundler with the bundle ID ``hip-spirv64-amd-amdhsa--amdgcnspirv``. -Mixed with Normal ``--offload-arch`` -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -**Mixing ``amdgcnspirv`` and concrete ``gfx###`` targets via ``--offload-arch`` -is not currently supported; this limitation is temporary and will be removed in -a future release** - Architecture Specific Macros ---------------------------- diff --git clang/docs/LanguageExtensions.rst clang/docs/LanguageExtensions.rst index c42b88015e26..dd7513ceaa4e 100644 --- clang/docs/LanguageExtensions.rst +++ clang/docs/LanguageExtensions.rst @@ -514,9 +514,7 @@ available in all language modes. __nullptr --------- -``__nullptr`` is an alternate spelling for ``nullptr``, but is also available in -C++ modes prior to C++11. Note that it's currently not availbale in C despite -C23 having support for ``nullptr``. +``__nullptr`` is an alternate spelling for ``nullptr``. It is available in all C and C++ language modes. __signed, __signed__ -------------------- @@ -759,6 +757,9 @@ The integer elementwise intrinsics, including ``__builtin_elementwise_popcount`` ``__builtin_elementwise_bitreverse``, ``__builtin_elementwise_add_sat``, ``__builtin_elementwise_sub_sat`` can be called in a ``constexpr`` context. +No implicit promotion of integer types takes place. The mixing of integer types +of different sizes and signs is forbidden in binary and ternary builtins. + ============================================== ====================================================================== ========================================= Name Operation Supported element types ============================================== ====================================================================== ========================================= diff --git clang/docs/ReleaseNotes.rst clang/docs/ReleaseNotes.rst index b63bd366cfe8..b8b47103d951 100644 --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -33,219 +33,18 @@ latest release, please see the `Clang Web Site <https://clang.llvm.org>`_ or the Potentially Breaking Changes ============================ -These changes are ones which we think may surprise users when upgrading to -Clang |release| because of the opportunity they pose for disruption to existing -code bases. - -- The ``le32`` and ``le64`` targets have been removed. - -- ``clang -m32`` defaults to ``-mcpu=v9`` on SPARC Linux now. Distros - still supporting SPARC V8 CPUs need to specify ``-mcpu=v8`` with a - `config file - <https://clang.llvm.org/docs/UsersManual.html#configuration-files>`_. - -- The ``clang-rename`` tool has been removed. - -- Removed support for RenderScript targets. This technology is - `officially deprecated <https://developer.android.com/guide/topics/renderscript/compute>`_ - and users are encouraged to - `migrate to Vulkan <https://developer.android.com/guide/topics/renderscript/migrate>`_ - or other options. - -- Clang now emits distinct type-based alias analysis tags for incompatible - pointers by default, enabling more powerful alias analysis when accessing - pointer types. This change may silently change code behavior for code - containing strict-aliasing violations. The new default behavior can be - disabled using ``-fno-pointer-tbaa``. - -- Clang will now more aggressively use undefined behavior on pointer addition - overflow for optimization purposes. For example, a check like - ``ptr + unsigned_offset < ptr`` will now optimize to ``false``, because - ``ptr + unsigned_offset`` will cause undefined behavior if it overflows (or - advances past the end of the object). - - Previously, ``ptr + unsigned_offset < ptr`` was optimized (by both Clang and - GCC) to ``(ssize_t)unsigned_offset < 0``. This also results in an incorrect - overflow check, but in a way that is less apparent when only testing with - pointers in the low half of the address space. - - To avoid pointer addition overflow, it is necessary to perform the addition - on integers, for example using - ``(uintptr_t)ptr + unsigned_offset < (uintptr_t)ptr``. Sometimes, it is also - possible to rewrite checks by only comparing the offset. For example, - ``ptr + offset < end_ptr && ptr + offset >= ptr`` can be written as - ``offset < (uintptr_t)(end_ptr - ptr)``. - - Undefined behavior due to pointer addition overflow can be reliably detected - using ``-fsanitize=pointer-overflow``. It is also possible to use - ``-fno-strict-overflow`` to opt-in to a language dialect where signed integer - and pointer overflow are well-defined. + +- The Objective-C ARC migrator (ARCMigrate) has been removed. C/C++ Language Potentially Breaking Changes ------------------------------------------- -- Clang now rejects ``_Complex _BitInt`` types. - C++ Specific Potentially Breaking Changes ----------------------------------------- -- The type trait builtin ``__is_nullptr`` has been removed, since it has very - few users and can be written as ``__is_same(__remove_cv(T), decltype(nullptr))``, - which GCC supports as well. - -- The type trait builtin ``__is_referenceable`` has been deprecated, since it has - very few users and all the type traits that could benefit from it in the - standard library already have their own bespoke builtins. It will be removed in - Clang 21. - -- Clang will now correctly diagnose as ill-formed a constant expression where an - enum without a fixed underlying type is set to a value outside the range of - the enumeration's values. - - .. code-block:: c++ - - enum E { Zero, One, Two, Three, Four }; - constexpr E Val1 = (E)3; // Ok - constexpr E Val2 = (E)7; // Ok - constexpr E Val3 = (E)8; // Now ill-formed, out of the range [0, 7] - constexpr E Val4 = (E)-1; // Now ill-formed, out of the range [0, 7] - - Since Clang 16, it has been possible to suppress the diagnostic via - `-Wno-enum-constexpr-conversion`, to allow for a transition period for users. - Now, in Clang 20, **it is no longer possible to suppress the diagnostic**. - -- Extraneous template headers are now ill-formed by default. - This error can be disable with ``-Wno-error=extraneous-template-head``. - - .. code-block:: c++ - - template <> // error: extraneous template head - template <typename T> - void f(); - -- During constant evaluation, comparisons between different evaluations of the - same string literal are now correctly treated as non-constant, and comparisons - between string literals that cannot possibly overlap in memory are now treated - as constant. This updates Clang to match the anticipated direction of open core - issue `CWG2765 <http://wg21.link/CWG2765>`, but is subject to change once that - issue is resolved. - - .. code-block:: c++ - - constexpr const char *f() { return "hello"; } - constexpr const char *g() { return "world"; } - // Used to evaluate to false, now error: non-constant comparison. - constexpr bool a = f() == f(); - // Might evaluate to true or false, as before. - bool at_runtime() { return f() == f(); } - // Was error, now evaluates to false. - constexpr bool b = f() == g(); - -- Clang will now correctly not consider pointers to non classes for covariance - and disallow changing return type to a type that doesn't have the same or less cv-qualifications. - - .. code-block:: c++ - - struct A { - virtual const int *f() const; - virtual const std::string *g() const; - }; - struct B : A { - // Return type has less cv-qualification but doesn't point to a class. - // Error will be generated. - int *f() const override; - - // Return type doesn't have more cv-qualification also not the same or - // less cv-qualification. - // Error will be generated. - volatile std::string *g() const override; - }; - -- The warning ``-Wdeprecated-literal-operator`` is now on by default, as this is - something that WG21 has shown interest in removing from the language. The - result is that anyone who is compiling with ``-Werror`` should see this - diagnostic. To fix this diagnostic, simply removing the space character from - between the ``operator""`` and the user defined literal name will make the - source no longer deprecated. This is consistent with `CWG2521 <https://cplusplus.github.io/CWG/issues/2521.html>_`. - - .. code-block:: c++ - - // Now diagnoses by default. - unsigned operator"" _udl_name(unsigned long long); - // Fixed version: - unsigned operator""_udl_name(unsigned long long); - -- Clang will now produce an error diagnostic when ``[[clang::lifetimebound]]`` is - applied on a parameter or an implicit object parameter of a function that - returns void. This was previously ignored and had no effect. (#GH107556) - - .. code-block:: c++ - - // Now diagnoses with an error. - void f(int& i [[clang::lifetimebound]]); - -- Clang will now produce an error diagnostic when ``[[clang::lifetimebound]]`` - is applied on a type (instead of a function parameter or an implicit object - parameter); this includes the case when the attribute is specified for an - unnamed function parameter. These were previously ignored and had no effect. - (#GH118281) - - .. code-block:: c++ - - // Now diagnoses with an error. - int* [[clang::lifetimebound]] x; - // Now diagnoses with an error. - void f(int* [[clang::lifetimebound]] i); - // Now diagnoses with an error. - void g(int* [[clang::lifetimebound]]); - -- Clang now rejects all field accesses on null pointers in constant expressions. The following code - used to work but will now be rejected: - - .. code-block:: c++ - - struct S { int a; int b; }; - constexpr const int *p = &((S*)nullptr)->b; - - Previously, this code was erroneously accepted. - -- Clang will now consider the implicitly deleted destructor of a union or - a non-union class without virtual base class to be ``constexpr`` in C++20 - mode (Clang 19 only did so in C++23 mode but the standard specification for - this changed in C++20). (#GH85550) - - .. code-block:: c++ - - struct NonLiteral { - NonLiteral() {} - ~NonLiteral() {} - }; - - template <class T> - struct Opt { - union { - char c; - T data; - }; - bool engaged = false; - - constexpr Opt() {} - constexpr ~Opt() { - if (engaged) - data.~T(); - } - }; - - // Previously only accepted in C++23 and later, now also accepted in C++20. - consteval void foo() { Opt<NonLiteral>{}; } - ABI Changes in This Version --------------------------- -- Fixed Microsoft name mangling of placeholder, auto and decltype(auto), return types for MSVC 1920+. This change resolves incompatibilities with code compiled by MSVC 1920+ but will introduce incompatibilities with code compiled by earlier versions of Clang unless such code is built with the compiler option -fms-compatibility-version=19.14 to imitate the MSVC 1914 mangling behavior. -- Fixed the Itanium mangling of the construction vtable name. This change will introduce incompatibilities with code compiled by Clang 19 and earlier versions, unless the -fclang-abi-compat=19 option is used. (#GH108015) -- Mangle member-like friend function templates as members of the enclosing class. (#GH110247, #GH110503) - AST Dumping Potentially Breaking Changes ---------------------------------------- @@ -254,581 +53,63 @@ Clang Frontend Potentially Breaking Changes Clang Python Bindings Potentially Breaking Changes -------------------------------------------------- -- Parts of the interface returning string results will now return - the empty string ``""`` when no result is available, instead of ``None``. -- Calling a property on the ``CompletionChunk`` or ``CompletionString`` class - statically now leads to an error, instead of returning a ``CachedProperty`` object - that is used internally. Properties are only available on instances. -- For a single-line ``SourceRange`` and a ``SourceLocation`` in the same line, - but after the end of the ``SourceRange``, ``SourceRange.__contains__`` - used to incorrectly return ``True``. (#GH22617), (#GH52827) What's New in Clang |release|? ============================== -Some of the major new features and improvements to Clang are listed -here. Generic improvements to Clang as a whole or to its underlying -infrastructure are described first, followed by language-specific -sections with improvements to Clang's support for those languages. C++ Language Changes -------------------- -- Allow single element access of GCC vector/ext_vector_type object to be - constant expression. Supports the `V.xyzw` syntax and other tidbits - as seen in OpenCL. Selecting multiple elements is left as a future work. -- Implement `CWG1815 <https://wg21.link/CWG1815>`_. Support lifetime extension - of temporary created by aggregate initialization using a default member - initializer. - -- Accept C++26 user-defined ``static_assert`` messages in C++11 as an extension. - -- Add ``__builtin_elementwise_popcount`` builtin for integer types only. - -- Add ``__builtin_elementwise_fmod`` builtin for floating point types only. - -- Add ``__builtin_elementwise_minimum`` and ``__builtin_elementwise_maximum`` - builtin for floating point types only. - -- The builtin type alias ``__builtin_common_type`` has been added to improve the - performance of ``std::common_type``. C++2c Feature Support ^^^^^^^^^^^^^^^^^^^^^ -- Add ``__builtin_is_virtual_base_of`` intrinsic, which supports - `P2985R0 A type trait for detecting virtual base classes <https://wg21.link/p2985r0>`_ - -- Implemented `P2893R3 Variadic Friends <https://wg21.link/P2893>`_ - -- Implemented `P2747R2 constexpr placement new <https://wg21.link/P2747R2>`_. - -- Added the ``__builtin_is_within_lifetime`` builtin, which supports - `P2641R4 Checking if a union alternative is active <https://wg21.link/p2641r4>`_ - -- Implemented `P3176R1 The Oxford variadic comma <https://wg21.link/P3176R1>`_ - C++23 Feature Support ^^^^^^^^^^^^^^^^^^^^^ -- Removed the restriction to literal types in constexpr functions in C++23 mode. - -- Extend lifetime of temporaries in mem-default-init for P2718R0. Clang now fully - supports `P2718R0 Lifetime extension in range-based for loops <https://wg21.link/P2718R0>`_. - -- ``__cpp_explicit_this_parameter`` is now defined. (#GH82780) - -- Add ``__builtin_is_implicit_lifetime`` intrinsic, which supports - `P2674R1 A trait for implicit lifetime types <https://wg21.link/p2674r1>`_ - -- Add support for `P2280R4 Using unknown pointers and references in constant expressions <https://wg21.link/P2280R4>`_. (#GH63139) C++20 Feature Support ^^^^^^^^^^^^^^^^^^^^^ -- Implemented module level lookup for C++20 modules. (#GH90154) - C++17 Feature Support ^^^^^^^^^^^^^^^^^^^^^ -- The implementation of the relaxed template template argument matching rules is - more complete and reliable, and should provide more accurate diagnostics. Resolutions to C++ Defect Reports ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- Allow calling initializer list constructors from initializer lists with - a single element of the same type instead of always copying. - (`CWG2137: List-initialization from object of same type <https://cplusplus.github.io/CWG/issues/2137.html>`) - -- Speculative resolution for CWG2311 implemented so that the implementation of CWG2137 doesn't remove - previous cases where guaranteed copy elision was done. Given a prvalue ``e`` of class type - ``T``, ``T{e}`` will try to resolve an initializer list constructor and will use it if successful. - Otherwise, if there is no initializer list constructor, the copy will be elided as if it was ``T(e)``. - (`CWG2311: Missed case for guaranteed copy elision <https://cplusplus.github.io/CWG/issues/2311.html>`) - -- Casts from a bit-field to an integral type is now not considered narrowing if the - width of the bit-field means that all potential values are in the range - of the target type, even if the type of the bit-field is larger. - (`CWG2627: Bit-fields and narrowing conversions <https://cplusplus.github.io/CWG/issues/2627.html>`_) - -- ``nullptr`` is now promoted to ``void*`` when passed to a C-style variadic function. - (`CWG722: Can nullptr be passed to an ellipsis? <https://cplusplus.github.io/CWG/issues/722.html>`_) - -- Allow ``void{}`` as a prvalue of type ``void``. - (`CWG2351: void{} <https://cplusplus.github.io/CWG/issues/2351.html>`_). - -- Clang now has improved resolution to CWG2398, allowing class templates to have - default arguments deduced when partial ordering, and better backwards compatibility - in overload resolution. - -- Clang now allows comparing unequal object pointers that have been cast to ``void *`` - in constant expressions. These comparisons always worked in non-constant expressions. - (`CWG2749: Treatment of "pointer to void" for relational comparisons <https://cplusplus.github.io/CWG/issues/2749.html>`_). - -- Reject explicit object parameters with type ``void`` (``this void``). - (`CWG2915: Explicit object parameters of type void <https://cplusplus.github.io/CWG/issues/2915.html>`_). - -- Clang now allows trailing requires clause on explicit deduction guides. - (`CWG2707: Deduction guides cannot have a trailing requires-clause <https://cplusplus.github.io/CWG/issues/2707.html>`_). - -- Respect constructor constraints during CTAD. - (`CWG2628: Implicit deduction guides should propagate constraints <https://cplusplus.github.io/CWG/issues/2628.html>`_). - -- Clang now diagnoses a space in the first production of a ``literal-operator-id`` - by default. - (`CWG2521: User-defined literals and reserved identifiers <https://cplusplus.github.io/CWG/issues/2521.html>`_). - -- Fix name lookup for a dependent base class that is the current instantiation. - (`CWG591: When a dependent base class is the current instantiation <https://cplusplus.github.io/CWG/issues/591.html>`_). - -- Clang now allows calling explicit object member functions directly with prvalues - instead of always materializing a temporary, meaning by-value explicit object parameters - do not need to move from a temporary. - (`CWG2813: Class member access with prvalues <https://cplusplus.github.io/CWG/issues/2813.html>`_). +- The flag `-frelaxed-template-template-args` + and its negation have been removed, having been deprecated since the previous + two releases. The improvements to template template parameter matching implemented + in the previous release, as described in P3310 and P3579, made this flag unnecessary. C Language Changes ------------------ -- Extend clang's ``<limits.h>`` to define ``LONG_LONG_*`` macros for Android's bionic. - C2y Feature Support ^^^^^^^^^^^^^^^^^^^ -- Updated conformance for `N3298 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3298.htm>`_ - which adds the ``i`` and ``j`` suffixes for the creation of a ``_Complex`` - constant value. Clang has always supported these suffixes as a GNU extension, - so ``-Wgnu-imaginary-constant`` no longer has effect in C modes, as this is - now a C2y extension in C. ``-Wgnu-imaginary-constant`` still applies in C++ - modes. - -- Clang updated conformance for `N3370 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3370.htm>`_ - case range expressions. This feature was previously supported by Clang as a - GNU extension, so ``-Wgnu-case-range`` no longer has effect in C modes, as - this is now a C2y extension in C. ``-Wgnu-case-range`` still applies in C++ - modes. - -- Clang implemented support for `N3344 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3344.pdf>`_ - which disallows a ``void`` parameter from having a qualifier or storage class - specifier. Note that ``register void`` was previously accepted in all C - language modes but is now rejected (all of the other qualifiers and storage - class specifiers were previously rejected). - -- Updated conformance for `N3364 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3364.pdf>`_ - on floating-point translation-time initialization with signaling NaN. This - paper adopts Clang's existing practice, so there were no changes to compiler - behavior. - -- Implemented support for `N3341 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3341.pdf>`_ - which makes empty structure and union objects implementation-defined in C. - ``-Wgnu-empty-struct`` will be emitted in C23 and earlier modes because the - behavior is a conforming GNU extension in those modes, but will no longer - have an effect in C2y mode. - -- Updated conformance for `N3342 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3342.pdf>`_ - which made qualified function types implementation-defined rather than - undefined. Clang has always accepted ``const`` and ``volatile`` qualified - function types by ignoring the qualifiers. - -- Updated conformance for `N3346 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3346.pdf>`_ - which changes some undefined behavior around initialization to instead be - constraint violations. This paper adopts Clang's existing practice, so there - were no changes to compiler behavior. - C23 Feature Support ^^^^^^^^^^^^^^^^^^^ -- Clang now supports `N3029 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3029.htm>`_ Improved Normal Enumerations. -- Clang now officially supports `N3030 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3030.htm>`_ Enhancements to Enumerations. Clang already supported it as an extension, so there were no changes to compiler behavior. -- Fixed the value of ``BOOL_WIDTH`` in ``<limits.h>`` to return ``1`` - explicitly, as mandated by the standard. Fixes #GH117348 - Non-comprehensive list of changes in this release ------------------------------------------------- -- The floating point comparison builtins (``__builtin_isgreater``, - ``__builtin_isgreaterequal``, ``__builtin_isless``, etc.) and - ``__builtin_signbit`` can now be used in constant expressions. -- Plugins can now define custom attributes that apply to statements - as well as declarations. -- ``__builtin_abs`` function can now be used in constant expressions. - -- The new builtin ``__builtin_counted_by_ref`` was added. In contexts where the - programmer needs access to the ``counted_by`` attribute's field, but it's not - available --- e.g. in macros. For instance, it can be used to automatically - set the counter during allocation in the Linux kernel: - - .. code-block:: c - - /* A simplified version of Linux allocation macros */ - #define alloc(PTR, FAM, COUNT) ({ \ - sizeof_t __ignored_assignment; \ - typeof(P) __p; \ - size_t __size = sizeof(*P) + sizeof(*P->FAM) * COUNT; \ - __p = malloc(__size); \ - *_Generic( \ - __builtin_counted_by_ref(__p->FAM), \ - void *: &__ignored_assignment, \ - default: __builtin_counted_by_ref(__p->FAM)) = COUNT; \ - __p; \ - }) - - The flexible array member (FAM) can now be accessed immediately without causing - issues with the sanitizer because the counter is automatically set. - -- The following builtins can now be used in constant expressions: ``__builtin_reduce_add``, - ``__builtin_reduce_mul``, ``__builtin_reduce_and``, ``__builtin_reduce_or``, - ``__builtin_reduce_xor``, ``__builtin_elementwise_popcount``, - ``__builtin_elementwise_bitreverse``, ``__builtin_elementwise_add_sat``, - ``__builtin_elementwise_sub_sat``, ``__builtin_reduce_min`` (For integral element type), - ``__builtin_reduce_max`` (For integral element type). - -- The builtin macros ``__INT8_C``, ``__INT16_C``, ``__INT32_C``, ``__INT64_C``, - ``__INTMAX_C``, ``__UINT8_C``, ``__UINT16_C``, ``__UINT32_C``, ``__UINT64_C`` - and ``__UINTMAX_C`` have been introduced to ease the implementaton of section - 7.18.4 of ISO/IEC 9899:1999. These macros are also defined by GCC and should - be used instead of others that expand and paste the suffixes provided by - ``__INT8_C_SUFFIX__``, ``__INT16_C_SUFFIX__``, ``__INT32_C_SUFFIX__``, - ``__INT64_C_SUFFIX__``, ``__INTMAX_C_SUFFIX__``, ``__UINT8_C_SUFFIX__``, - ``__UINT16_C_SUFFIX__``, ``__UINT32_C_SUFFIX__``, ``__UINT64_C_SUFFIX__`` and - ``__UINTMAX_C_SUFFIX__``. Pasting suffixes after the expansion of their - respective macros is unsafe, as users can define the suffixes as macros. - -- Clang now rejects ``_BitInt`` matrix element types if the bit width is less than ``CHAR_WIDTH`` or - not a power of two, matching preexisting behaviour for vector types. - -- Matrix types (a Clang extension) can now be used in pseudo-destructor expressions, - which allows them to be stored in STL containers. - -- In the ``-ftime-report`` output, the new "Clang time report" group replaces - the old "Clang front-end time report" and includes "Front end", "LLVM IR - generation", "Optimizer", and "Machine code generation". - New Compiler Flags ------------------ -- The ``-fc++-static-destructors={all,thread-local,none}`` flag was - added to control which C++ variables have static destructors - registered: all (the default) does so for all variables, thread-local - only for thread-local variables, and none (which corresponds to the - existing ``-fno-c++-static-destructors`` flag) skips all static - destructors registration. - -- The ``-Warray-compare`` warning has been added to warn about array comparison - on versions older than C++20. - -- The ``-Warray-compare-cxx26`` warning has been added to warn about array comparison - starting from C++26, this warning is enabled as an error by default. - -- clang-cl and clang-dxc now support ``-fdiagnostics-color=[auto|never|always]`` - in addition to ``-f[no-]color-diagnostics``. - Deprecated Compiler Flags ------------------------- -- ``-fheinous-gnu-extensions`` is deprecated; it is now equivalent to - specifying ``-Wno-error=invalid-gnu-asm-cast`` and may be removed in the - future. - Modified Compiler Flags ----------------------- -- The ``-ffp-model`` option has been updated to enable a more limited set of - optimizations when the ``fast`` argument is used and to accept a new argument, - ``aggressive``. The behavior of ``-ffp-model=aggressive`` is equivalent - to the previous behavior of ``-ffp-model=fast``. The updated - ``-ffp-model=fast`` behavior no longer assumes finite math only and uses - the ``promoted`` algorithm for complex division when possible rather than the - less basic (limited range) algorithm. - -- The ``-fveclib`` option has been updated to enable ``-fno-math-errno`` for - ``-fveclib=ArmPL`` and ``-fveclib=SLEEF``. This gives Clang more opportunities - to utilize these vector libraries. The behavior for all other vector function - libraries remains unchanged. - -- The ``-Wnontrivial-memcall`` warning has been added to warn about - passing non-trivially-copyable destination parameter to ``memcpy``, - ``memset`` and similar functions for which it is a documented undefined - behavior. It is implied by ``-Wnontrivial-memaccess`` - -- Added ``-fmodules-reduced-bmi`` flag corresponding to - ``-fexperimental-modules-reduced-bmi`` flag. The ``-fmodules-reduced-bmi`` flag - is intended to be enabled by default in the future. - Removed Compiler Flags ------------------------- -- The compiler flag `-Wenum-constexpr-conversion` (and the `Wno-`, `Wno-error-` - derivatives) is now removed, since it's no longer possible to suppress the - diagnostic (see above). Users can expect an `unknown warning` diagnostic if - it's still in use. - Attribute Changes in Clang -------------------------- -- The ``swift_attr`` can now be applied to types. To make it possible to use imported APIs - in Swift safely there has to be a way to annotate individual parameters and result types - with relevant attributes that indicate that e.g. a block is called on a particular actor - or it accepts a Sendable or global-actor (i.e. ``@MainActor``) isolated parameter. - - For example: - - .. code-block:: objc - - @interface MyService - -(void) handle: (void (^ __attribute__((swift_attr("@Sendable"))))(id)) handler; - @end - -- Clang now disallows more than one ``__attribute__((ownership_returns(class, idx)))`` with - different class names attached to one function. - -- Introduced a new format attribute ``__attribute__((format(syslog, 1, 2)))`` from OpenBSD. - -- The ``hybrid_patchable`` attribute is now supported on ARM64EC targets. It can be used to specify - that a function requires an additional x86-64 thunk, which may be patched at runtime. - -- The attribute ``[[clang::no_specializations]]`` has been added to warn - users that a specific template shouldn't be specialized. This is useful for - e.g. standard library type traits, where adding a specialization results in - undefined behaviour. - -- ``[[clang::lifetimebound]]`` is now explicitly disallowed on explicit object member functions - where they were previously silently ignored. - -- Clang now automatically adds ``[[clang::lifetimebound]]`` to the parameters of - ``std::span, std::string_view`` constructors, this enables Clang to capture - more cases where the returned reference outlives the object. - (#GH100567) - -- Clang now correctly diagnoses the use of ``btf_type_tag`` in C++ and ignores - it; this attribute is a C-only attribute, and caused crashes with template - instantiation by accidentally allowing it in C++ in some circumstances. - (#GH106864) - -- Introduced a new attribute ``[[clang::coro_await_elidable]]`` on coroutine return types - to express elideability at call sites where the coroutine is invoked under a safe elide context. - -- Introduced a new attribute ``[[clang::coro_await_elidable_argument]]`` on function parameters - to propagate safe elide context to arguments if such function is also under a safe elide context. - -- The documentation of the ``[[clang::musttail]]`` attribute was updated to - note that the lifetimes of all local variables end before the call. This does - not change the behaviour of the compiler, as this was true for previous - versions. - -- Fix a bug where clang doesn't automatically apply the ``[[gsl::Owner]]`` or - ``[[gsl::Pointer]]`` to STL explicit template specialization decls. (#GH109442) - -- Clang now supports ``[[clang::lifetime_capture_by(X)]]``. Similar to lifetimebound, this can be - used to specify when a reference to a function parameter is captured by another capturing entity ``X``. - -- The ``target_version`` attribute is now only supported for AArch64 and RISC-V architectures. - -- Clang now permits the usage of the placement new operator in ``[[msvc::constexpr]]`` - context outside of the std namespace. (#GH74924) - -- Clang now disallows the use of attributes after the namespace name. (#GH121407) - Improvements to Clang's diagnostics ----------------------------------- -- Some template related diagnostics have been improved. - - .. code-block:: c++ - - void foo() { template <typename> int i; } // error: templates can only be declared in namespace or class scope - - struct S { - template <typename> int i; // error: non-static data member 'i' cannot be declared as a template - }; - -- Clang now has improved diagnostics for functions with explicit 'this' parameters. Fixes #GH97878 - -- Clang now diagnoses dangling references to fields of temporary objects. Fixes #GH81589. - -- Clang now diagnoses undefined behavior in constant expressions more consistently. This includes invalid shifts, and signed overflow in arithmetic. - -- -Wdangling-assignment-gsl is enabled by default. -- Clang now always preserves the template arguments as written used - to specialize template type aliases. - -- Clang now diagnoses the use of ``main`` in an ``extern`` context as invalid according to [basic.start.main] p3. Fixes #GH101512. - -- Clang now diagnoses when the result of a [[nodiscard]] function is discarded after being cast in C. Fixes #GH104391. - -- Clang now properly explains the reason a template template argument failed to - match a template template parameter, in terms of the C++17 relaxed matching rules - instead of the old ones. - -- Don't emit duplicated dangling diagnostics. (#GH93386). - -- Improved diagnostic when trying to befriend a concept. (#GH45182). - -- Added the ``-Winvalid-gnu-asm-cast`` diagnostic group to control warnings - about use of "noop" casts for lvalues (a GNU extension). This diagnostic is - a warning which defaults to being an error, is enabled by default, and is - also controlled by the now-deprecated ``-fheinous-gnu-extensions`` flag. - -- Added the ``-Wdecls-in-multiple-modules`` option to assist users to identify - multiple declarations in different modules, which is the major reason of the slow - compilation speed with modules. This warning is disabled by default and it needs - to be explicitly enabled or by ``-Weverything``. - -- Improved diagnostic when trying to overload a function in an ``extern "C"`` context. (#GH80235) - -- Clang now respects lifetimebound attribute for the assignment operator parameter. (#GH106372). - -- The lifetimebound and GSL analysis in clang are coherent, allowing clang to - detect more use-after-free bugs. (#GH100549). - -- Clang now diagnoses dangling cases where a gsl-pointer is constructed from a gsl-owner object inside a container (#GH100384). - -- Clang now warns for u8 character literals used in C23 with ``-Wpre-c23-compat`` instead of ``-Wpre-c++17-compat``. - -- Clang now diagnose when importing module implementation partition units in module interface units. - -- Don't emit bogus dangling diagnostics when ``[[gsl::Owner]]`` and `[[clang::lifetimebound]]` are used together (#GH108272). - -- Don't emit bogus dignostic about an undefined behavior on ``reinterpret_cast<T>`` for non-instantiated template functions without sufficient knowledge whether it can actually lead to undefined behavior for ``T`` (#GH109430). - -- The ``-Wreturn-stack-address`` warning now also warns about addresses of - local variables passed to function calls using the ``[[clang::musttail]]`` - attribute. - -- Clang now diagnoses cases where a dangling ``GSLOwner<GSLPointer>`` object is constructed, e.g. ``std::vector<string_view> v = {std::string()};`` (#GH100526). - -- Clang now diagnoses when a ``requires`` expression has a local parameter of void type, aligning with the function parameter (#GH109831). - -- Clang now emits a diagnostic note at the class declaration when the method definition does not match any declaration (#GH110638). - -- Clang now omits warnings for extra parentheses in fold expressions with single expansion (#GH101863). - -- The warning for an unsupported type for a named register variable is now phrased ``unsupported type for named register variable``, - instead of ``bad type for named register variable``. This makes it clear that the type is not supported at all, rather than being - suboptimal in some way the error fails to mention (#GH111550). - -- Clang now emits a ``-Wdepredcated-literal-operator`` diagnostic, even if the - name was a reserved name, which we improperly allowed to suppress the - diagnostic. - -- Clang now diagnoses ``[[deprecated]]`` attribute usage on local variables (#GH90073). - -- Fix false positives when `[[gsl::Owner/Pointer]]` and `[[clang::lifetimebound]]` are used together. - -- Improved diagnostic message for ``__builtin_bit_cast`` size mismatch (#GH115870). - -- Clang now omits shadow warnings for enum constants in separate class scopes (#GH62588). - -- When diagnosing an unused return value of a type declared ``[[nodiscard]]``, the type - itself is now included in the diagnostic. - -- Clang will now prefer the ``[[nodiscard]]`` declaration on function declarations over ``[[nodiscard]]`` - declaration on the return type of a function. Previously, when both have a ``[[nodiscard]]`` declaration attached, - the one on the return type would be preferred. This may affect the generated warning message: - - .. code-block:: c++ - - struct [[nodiscard("Reason 1")]] S {}; - [[nodiscard("Reason 2")]] S getS(); - void use() - { - getS(); // Now diagnoses "Reason 2", previously diagnoses "Reason 1" - } - -- Clang now diagnoses ``= delete("reason")`` extension warnings only in pedantic mode rather than on by default. (#GH109311). - -- Clang now diagnoses missing return value in functions containing ``if consteval`` (#GH116485). - -- Clang now correctly recognises code after a call to a ``[[noreturn]]`` constructor - as unreachable (#GH63009). - -- Clang now omits shadowing warnings for parameter names in explicit object member functions (#GH95707). - -- Improved error recovery for function call arguments with trailing commas (#GH100921). - -- For an rvalue reference bound to a temporary struct with an integer member, Clang will detect constant integer overflow - in the initializer for the integer member (#GH46755). - -- Fixed a false negative ``-Wunused-private-field`` diagnostic when a defaulted comparison operator is defined out of class (#GH116961). - -- Clang now diagnoses dangling references for C++20's parenthesized aggregate initialization (#101957). - -- Fixed a bug where Clang would not emit ``-Wunused-private-field`` warnings when an unrelated class - defined a defaulted comparison operator (#GH116270). - - .. code-block:: c++ - - class A { - private: - int a; // warning: private field 'a' is not used, no diagnostic previously - }; - - class C { - bool operator==(const C&) = default; - }; - -- Clang now emits `-Wdangling-capture` diangostic when a STL container captures a dangling reference. - - .. code-block:: c++ - - void test() { - std::vector<std::string_view> views; - views.push_back(std::string("123")); // warning - } - -- Clang now emits a ``-Wtautological-compare`` diagnostic when a check for - pointer addition overflow is always true or false, because overflow would - be undefined behavior. - - .. code-block:: c++ - - bool incorrect_overflow_check(const char *ptr, size_t index) { - return ptr + index < ptr; // warning - } - -- Clang now emits a ``-Wvarargs`` diagnostic when the second argument - to ``va_arg`` is of array type, which is an undefined behavior (#GH119360). - - .. code-block:: c++ - - void test() { - va_list va; - va_arg(va, int[10]); // warning - } - -- Fix -Wdangling false positives on conditional operators (#120206). - -- Fixed a bug where Clang hung on an unsupported optional scope specifier ``::`` when parsing - Objective-C. Clang now emits a diagnostic message instead of hanging. - -- The :doc:`ThreadSafetyAnalysis` now supports passing scoped capabilities into functions: - an attribute on the scoped capability parameter indicates both the expected associated capabilities and, - like in the case of attributes on the function declaration itself, their state before and after the call. - - .. code-block:: c++ - - #include "mutex.h" - - Mutex mu1, mu2; - int a GUARDED_BY(mu1); - - void require(MutexLocker& scope REQUIRES(mu1)) { - scope.Unlock(); - a = 0; // Warning! Requires mu1. - scope.Lock(); - } - - void testParameter() { - MutexLocker scope(&mu1), scope2(&mu2); - require(scope2); // Warning! Mutex managed by 'scope2' is 'mu2' instead of 'mu1' - require(scope); // OK. - scope.Unlock(); - require(scope); // Warning! Requires mu1. - } -- Diagnose invalid declarators in the declaration of constructors and destructors (#GH121706). - -- Fix false positives warning for non-std functions with name `infinity` (#123231). - -- Clang now emits a ``-Wignored-qualifiers`` diagnostic when a base class includes cv-qualifiers (#GH55474). - -- Clang now diagnoses the use of attribute names reserved by the C++ standard (#GH92196). - Improvements to Clang's time-trace ---------------------------------- @@ -838,367 +119,61 @@ Improvements to Coverage Mapping Bug Fixes in This Version ------------------------- -- Fixed the definition of ``ATOMIC_FLAG_INIT`` in ``<stdatomic.h>`` so it can - be used in C++. -- Fixed a failed assertion when checking required literal types in C context. (#GH101304). -- Fixed a crash when trying to transform a dependent address space type. Fixes #GH101685. -- Fixed a crash when diagnosing format strings and encountering an empty - delimited escape sequence (e.g., ``"\o{}"``). #GH102218 -- Fixed a crash using ``__array_rank`` on 64-bit targets. (#GH113044). -- The warning emitted for an unsupported register variable type now points to - the unsupported type instead of the ``register`` keyword (#GH109776). -- Fixed a crash when emit ctor for global variant with flexible array init (#GH113187). -- Fixed a crash when GNU statement expression contains invalid statement (#GH113468). -- Fixed a crash when passing the variable length array type to ``va_arg`` (#GH119360). -- Fixed a failed assertion when using ``__attribute__((noderef))`` on an - ``_Atomic``-qualified type (#GH116124). -- No longer incorrectly diagnosing use of a deleted destructor when the - selected overload of ``operator delete`` for that type is a destroying delete - (#GH46818). -- No longer return ``false`` for ``noexcept`` expressions involving a - ``delete`` which resolves to a destroying delete but the type of the object - being deleted has a potentially throwing destructor (#GH118660). - Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- Fix crash when atomic builtins are called with pointer to zero-size struct (#GH90330) - -- Clang now allows pointee types of atomic builtin arguments to be complete template types - that was not instantiated elsewhere. - -- ``__noop`` can now be used in a constant expression. (#GH102064) - -- Fix ``__has_builtin`` incorrectly returning ``false`` for some C++ type traits. (#GH111477) - -- Fix ``__builtin_source_location`` incorrectly returning wrong column for method chains. (#GH119129) - Bug Fixes to Attribute Support ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Bug Fixes to C++ Support ^^^^^^^^^^^^^^^^^^^^^^^^ -- Fixed a crash when an expression with a dependent ``__typeof__`` type is used as the operand of a unary operator. (#GH97646) -- Fixed incorrect pack expansion of init-capture references in requires expresssions. -- Fixed a failed assertion when checking invalid delete operator declaration. (#GH96191) -- Fix a crash when checking destructor reference with an invalid initializer. (#GH97230) -- Clang now correctly parses potentially declarative nested-name-specifiers in pointer-to-member declarators. -- Fix a crash when checking the initializer of an object that was initialized - with a string literal. (#GH82167) -- Fix a crash when matching template template parameters with templates which have - parameters of different class type. (#GH101394) -- Clang now correctly recognizes the correct context for parameter - substitutions in concepts, so it doesn't incorrectly complain of missing - module imports in those situations. (#GH60336) -- Fix init-capture packs having a size of one before being instantiated. (#GH63677) -- Clang now preserves the unexpanded flag in a lambda transform used for pack expansion. (#GH56852), (#GH85667), - (#GH99877), (#GH122417). -- Fixed a bug when diagnosing ambiguous explicit specializations of constrained member functions. -- Fixed an assertion failure when selecting a function from an overload set that includes a - specialization of a conversion function template. -- Correctly diagnose attempts to use a concept name in its own definition; - A concept name is introduced to its scope sooner to match the C++ standard. (#GH55875) -- Properly reject defaulted relational operators with invalid types for explicit object parameters, - e.g., ``bool operator==(this int, const Foo&)`` (#GH100329), and rvalue reference parameters. -- Properly reject defaulted copy/move assignment operators that have a non-reference explicit object parameter. -- Clang now properly handles the order of attributes in `extern` blocks. (#GH101990). -- Fixed an assertion failure by preventing null explicit object arguments from being deduced. (#GH102025). -- Correctly check constraints of explicit instantiations of member functions. (#GH46029) -- When performing partial ordering of function templates, clang now checks that - the deduction was consistent. Fixes (#GH18291). -- Fixes to several issues in partial ordering of template template parameters, which - were documented in the test suite. -- Fixed an assertion failure about a constraint of a friend function template references to a value with greater - template depth than the friend function template. (#GH98258) -- Clang now rebuilds the template parameters of out-of-line declarations and specializations in the context - of the current instantiation in all cases. -- Fix evaluation of the index of dependent pack indexing expressions/types specifiers (#GH105900) -- Correctly handle subexpressions of an immediate invocation in the presence of implicit casts. (#GH105558) -- Clang now correctly handles direct-list-initialization of a structured bindings from an array. (#GH31813) -- Mangle placeholders for deduced types as a template-prefix, such that mangling - of template template parameters uses the correct production. (#GH106182) -- Fixed an assertion failure when converting vectors to int/float with invalid expressions. (#GH105486) -- Template parameter names are considered in the name lookup of out-of-line class template - specialization right before its declaration context. (#GH64082) -- Fixed a constraint comparison bug for friend declarations. (#GH78101) -- Fix handling of ``_`` as the name of a lambda's init capture variable. (#GH107024) -- Fix an issue with dependent source location expressions (#GH106428), (#GH81155), (#GH80210), (#GH85373) -- Fixed a bug in the substitution of empty pack indexing types. (#GH105903) -- Clang no longer tries to capture non-odr used default arguments of template parameters of generic lambdas (#GH107048) -- Fixed a bug where defaulted comparison operators would remove ``const`` from base classes. (#GH102588) -- Fix a crash when using ``source_location`` in the trailing return type of a lambda expression. (#GH67134) -- A follow-up fix was added for (#GH61460), as the previous fix was not entirely correct. (#GH86361), (#GH112352) -- Fixed a crash in the typo correction of an invalid CTAD guide. (#GH107887) -- Fixed a crash when clang tries to substitute parameter pack while retaining the parameter - pack. (#GH63819), (#GH107560) -- Fix a crash when a static assert declaration has an invalid close location. (#GH108687) -- Avoided a redundant friend declaration instantiation under a certain ``consteval`` context. (#GH107175) -- Fixed an assertion failure in debug mode, and potential crashes in release mode, when - diagnosing a failed cast caused indirectly by a failed implicit conversion to the type of the constructor parameter. -- Fixed an assertion failure by adjusting integral to boolean vector conversions (#GH108326) -- Fixed a crash when mixture of designated and non-designated initializers in union. (#GH113855) -- Fixed an issue deducing non-type template arguments of reference type. (#GH73460) -- Fixed an issue in constraint evaluation, where type constraints on the lambda expression - containing outer unexpanded parameters were not correctly expanded. (#GH101754) -- Fixes crashes with function template member specializations, and increases - conformance of explicit instantiation behaviour with MSVC. (#GH111266) -- Fixed a bug in constraint expression comparison where the ``sizeof...`` expression was not handled properly - in certain friend declarations. (#GH93099) -- Clang now instantiates the correct lambda call operator when a lambda's class type is - merged across modules. (#GH110401) -- Fix a crash when parsing a pseudo destructor involving an invalid type. (#GH111460) -- Fixed an assertion failure when invoking recovery call expressions with explicit attributes - and undeclared templates. (#GH107047), (#GH49093) -- Clang no longer crashes when a lambda contains an invalid block declaration that contains an unexpanded - parameter pack. (#GH109148) -- Fixed overload handling for object parameters with top-level cv-qualifiers in explicit member functions (#GH100394) -- Fixed a bug in lambda captures where ``constexpr`` class-type objects were not properly considered ODR-used in - certain situations. (#GH47400), (#GH90896) -- Fix erroneous templated array size calculation leading to crashes in generated code. (#GH41441) -- During the lookup for a base class name, non-type names are ignored. (#GH16855) -- Fix a crash when recovering an invalid expression involving an explicit object member conversion operator. (#GH112559) -- Clang incorrectly considered a class with an anonymous union member to not be - const-default-constructible even if a union member has a default member initializer. - (#GH95854). -- Fixed an assertion failure when evaluating an invalid expression in an array initializer. (#GH112140) -- Fixed an assertion failure in range calculations for conditional throw expressions. (#GH111854) -- Clang now correctly ignores previous partial specializations of member templates explicitly specialized for - an implicitly instantiated class template specialization. (#GH51051) -- Fixed an assertion failure caused by invalid enum forward declarations. (#GH112208) -- Name independent data members were not correctly initialized from default member initializers. (#GH114069) -- Fixed expression transformation for ``[[assume(...)]]``, allowing using pack indexing expressions within the - assumption if they also occur inside of a dependent lambda. (#GH114787) -- Lambdas now capture function types without considering top-level const qualifiers. (#GH84961) -- Clang now uses valid deduced type locations when diagnosing functions with trailing return type - missing placeholder return type. (#GH78694) -- Fixed a bug where bounds of partially expanded pack indexing expressions were checked too early. (#GH116105) -- Fixed an assertion failure caused by using ``consteval`` in condition in consumed analyses. (#GH117385) -- Fixed an assertion failure caused by invalid default argument substitutions in non-defining - friend declarations. (#GH113324) -- Fix a crash caused by incorrect argument position in merging deduced template arguments. (#GH113659) -- Fixed a parser crash when using pack indexing as a nested name specifier. (#GH119072) -- Fixed a null pointer dereference issue when heuristically computing ``sizeof...(pack)`` expressions. (#GH81436) -- Fixed an assertion failure caused by mangled names with invalid identifiers. (#GH112205) -- Fixed an incorrect lambda scope of generic lambdas that caused Clang to crash when computing potential lambda - captures at the end of a full expression. (#GH115931) -- Clang no longer rejects deleting a pointer of incomplete enumeration type. (#GH99278) -- Fixed recognition of ``std::initializer_list`` when it's surrounded with ``extern "C++"`` and exported - out of a module (which is the case e.g. in MSVC's implementation of ``std`` module). (#GH118218) -- Fixed a pack expansion issue in checking unexpanded parameter sizes. (#GH17042) -- Fixed a bug where captured structured bindings were modifiable inside non-mutable lambda (#GH95081) -- Passing incomplete types to ``__is_base_of`` and other builtin type traits for which the corresponding - standard type trait mandates a complete type is now a hard (non-sfinae-friendly) error - (`LWG3929 <https://wg21.link/LWG3929>`__.) (#GH121278) -- Clang now identifies unexpanded parameter packs within the type constraint on a non-type template parameter. (#GH88866) -- Fixed an issue while resolving type of expression indexing into a pack of values of non-dependent type (#GH121242) -- Fixed a crash when __PRETTY_FUNCTION__ or __FUNCSIG__ (clang-cl) appears in the trailing return type of the lambda (#GH121274) -- Fixed a crash caused by the incorrect construction of template arguments for CTAD alias guides when type - constraints are applied. (#GH122134) -- Fixed canonicalization of pack indexing types - Clang did not always recognized identical pack indexing. (#GH123033) -- Fixed a nested lambda substitution issue for constraint evaluation. (#GH123441) -- Fixed various false diagnostics related to the use of immediate functions. (#GH123472) -- Fix immediate escalation not propagating through inherited constructors. (#GH112677) -- Fixed assertions or false compiler diagnostics in the case of C++ modules for - lambda functions or inline friend functions defined inside templates (#GH122493). -- Clang now rejects declaring an alias template with the same name as its template parameter. (#GH123423) -- Correctly determine the implicit constexprness of lambdas in dependent contexts. (#GH97958) (#GH114234) +- Clang is now better at keeping track of friend function template instance contexts. (#GH55509) Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ -- Fixed a crash that occurred when dividing by zero in complex integer division. (#GH55390). -- Fixed a bug in ``ASTContext::getRawCommentForAnyRedecl()`` where the function could - sometimes incorrectly return null even if a comment was present. (#GH108145) -- Clang now correctly parses the argument of the ``relates``, ``related``, ``relatesalso``, - and ``relatedalso`` comment commands. -- Clang now uses the location of the begin of the member expression for ``CallExpr`` - involving deduced ``this``. (#GH116928) -- Fixed printout of AST that uses pack indexing expression. (#GH116486) - Miscellaneous Bug Fixes ^^^^^^^^^^^^^^^^^^^^^^^ Miscellaneous Clang Crashes Fixed ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- Fixed a crash in C due to incorrect lookup that members in nested anonymous struct/union - can be found as ordinary identifiers in struct/union definition. (#GH31295) - -- Fixed a crash caused by long chains of ``sizeof`` and other similar operators - that can be followed by a non-parenthesized expression. (#GH45061) - -- Fixed an crash when compiling ``#pragma STDC FP_CONTRACT DEFAULT`` with - ``-ffp-contract=fast-honor-pragmas``. (#GH104830) - -- Fixed a crash when function has more than 65536 parameters. - Now a diagnostic is emitted. (#GH35741) - -- Fixed ``-ast-dump`` crashes on codes involving ``concept`` with ``-ast-dump-decl-types``. (#GH94928) - -- Fixed internal assertion firing when a declaration in the implicit global - module is found through ADL. (GH#109879) - -- Fixed a crash when an unscoped enumeration declared by an opaque-enum-declaration within a class template - with a dependent underlying type is subject to integral promotion. (#GH117960) - OpenACC Specific Changes ------------------------ Target Specific Changes ----------------------- -- Clang now implements the Solaris-specific mangling of ``std::tm`` as - ``tm``, same for ``std::div_t``, ``std::ldiv_t``, and - ``std::lconv``, for Solaris ABI compatibility. (#GH33114) - AMDGPU Support ^^^^^^^^^^^^^^ -- Initial support for gfx950 - -- Added headers ``gpuintrin.h`` and ``amdgpuintrin.h`` that contains common - definitions for GPU builtin functions. This header can be included for OpenMP, - CUDA, HIP, OpenCL, and C/C++. - NVPTX Support ^^^^^^^^^^^^^^ -- Added headers ``gpuintrin.h`` and ``nvptxintrin.h`` that contains common - definitions for GPU builtin functions. This header can be included for OpenMP, - CUDA, HIP, OpenCL, and C/C++. - X86 Support ^^^^^^^^^^^ -- The MMX vector intrinsic functions from ``*mmintrin.h`` which - operate on `__m64` vectors, such as ``_mm_add_pi8``, have been - reimplemented to use the SSE2 instruction-set and XMM registers - unconditionally. These intrinsics are therefore *no longer - supported* if MMX is enabled without SSE2 -- either from targeting - CPUs from the Pentium-MMX through the Pentium 3, or explicitly via - passing arguments such as ``-mmmx -mno-sse2``. MMX assembly code - remains supported without requiring SSE2, including inside - inline-assembly. - -- The compiler builtins such as ``__builtin_ia32_paddb`` which - formerly implemented the above MMX intrinsic functions have been - removed. Any uses of these removed functions should migrate to the - functions defined by the ``*mmintrin.h`` headers. A mapping can be - found in the file ``clang/www/builtins.py``. - -- Support ISA of ``AVX10.2``. - * Supported MINMAX intrinsics of ``*_(mask(z)))_minmax(ne)_p[s|d|h|bh]`` and - ``*_(mask(z)))_minmax_s[s|d|h]``. - -- Supported intrinsics for ``SM4 and AVX10.2``. - * Supported SM4 intrinsics of ``_mm512_sm4key4_epi32`` and - ``_mm512_sm4rnds4_epi32``. - -- All intrinsics in adcintrin.h can now be used in constant expressions. - -- All intrinsics in adxintrin.h can now be used in constant expressions. - -- All intrinsics in lzcntintrin.h can now be used in constant expressions. - -- All intrinsics in bmiintrin.h can now be used in constant expressions. - -- All intrinsics in bmi2intrin.h can now be used in constant expressions. - -- All intrinsics in tbmintrin.h can now be used in constant expressions. - -- Supported intrinsics for ``MOVRS AND AVX10.2``. - * Supported intrinsics of ``_mm(256|512)_(mask(z))_loadrs_epi(8|16|32|64)``. -- Support ISA of ``AMX-FP8``. -- Support ISA of ``AMX-TRANSPOSE``. -- Support ISA of ``AMX-MOVRS``. -- Support ISA of ``AMX-AVX512``. -- Support ISA of ``AMX-TF32``. -- Support ISA of ``MOVRS``. - -- Supported ``-march/tune=diamondrapids`` - Arm and AArch64 Support ^^^^^^^^^^^^^^^^^^^^^^^ -- Implementation of SVE2.1 and SME2.1 in accordance with the Arm C Language - Extensions (ACLE) is now available. - -- In the ARM Target, the frame pointer (FP) of a leaf function can be retained - by using the ``-fno-omit-frame-pointer`` option. If you want to eliminate the FP - in leaf functions after enabling ``-fno-omit-frame-pointer``, you can do so by adding - the ``-momit-leaf-frame-pointer`` option. - -- SME keyword attributes which apply to function types are now represented in the - mangling of the type. This means that ``void foo(void (*f)() __arm_streaming);`` - now has a different mangling from ``void foo(void (*f)());``. - -- The ``__arm_agnostic`` keyword attribute was added to let users describe - a function that preserves SME state enabled by PSTATE.ZA without having to share - this state with its callers and without making the assumption that this state - exists. - -- Support has been added for the following processors (-mcpu identifiers in parenthesis): - - For AArch64: - - * FUJITSU-MONAKA (fujitsu-monaka) - Android Support ^^^^^^^^^^^^^^^ Windows Support ^^^^^^^^^^^^^^^ -- clang-cl now supports ``/std:c++23preview`` which enables C++23 features. - -- Clang no longer allows references inside a union when emulating MSVC 1900+ even if `fms-extensions` is enabled. - Starting with VS2015, MSVC 1900, this Microsoft extension is no longer allowed and always results in an error. - Clang now follows the MSVC behavior in this scenario. - When `-fms-compatibility-version=18.00` or prior is set on the command line this Microsoft extension is still - allowed as VS2013 and prior allow it. - -- Clang now supports the ``#pragma clang section`` directive for COFF targets. - LoongArch Support ^^^^^^^^^^^^^^^^^ -- Types of parameters and return value of ``__builtin_lsx_vorn_v`` and ``__builtin_lasx_xvorn_v`` - are changed from ``signed char`` to ``unsigned char``. (#GH114514) - -- ``-mrelax`` and ``-mno-relax`` are supported now on LoongArch that can be used - to enable / disable the linker relaxation optimization. (#GH123587) - -- Fine-grained la64v1.1 options are added including ``-m{no-,}frecipe``, ``-m{no-,}lam-bh``, - ``-m{no-,}ld-seq-sa``, ``-m{no-,}div32``, ``-m{no-,}lamcas`` and ``-m{no-,}scq``. - -- Two options ``-m{no-,}annotate-tablejump`` are added to enable / disable - annotating table jump instruction to correlate it with the jump table. (#GH102411) - -- FreeBSD support is added for LoongArch64 and has been tested by building kernel-toolchain. (#GH119191) - RISC-V Support ^^^^^^^^^^^^^^ -- The option ``-mcmodel=large`` for the large code model is supported. -- Bump RVV intrinsic to version 1.0, the spec: https://github.com/riscv-non-isa/rvv-intrinsic-doc/releases/tag/v1.0.0-rc4 - CUDA/HIP Language Changes ^^^^^^^^^^^^^^^^^^^^^^^^^ -- Fixed a bug about overriding a constexpr pure-virtual member function with a non-constexpr virtual member function which causes compilation failure when including standard C++ header `format`. -- Added initial support for version 3 of the compressed offload bundle format, which uses 64-bit fields for Total File Size and Uncompressed Binary Size. This enables support for files larger than 4GB. The support is currently experimental and can be enabled by setting the environment variable `COMPRESSED_BUNDLE_FORMAT_VERSION=3`. CUDA Support ^^^^^^^^^^^^ -- Clang now supports CUDA SDK up to 12.6 -- Added support for sm_100 -- Added support for `__grid_constant__` attribute. -- CUDA now uses the new offloading driver by default. The new driver supports - device-side LTO, interoperability with OpenMP and other languages, and native ``-fgpu-rdc`` - support with static libraries. The old behavior can be returned using the - ``--no-offload-new-driver`` flag. The binary format is no longer compatible - with the NVIDIA compiler's RDC-mode support. More information can be found at: - https://clang.llvm.org/docs/OffloadingDesign.html AIX Support ^^^^^^^^^^^ @@ -1209,276 +184,58 @@ NetBSD Support WebAssembly Support ^^^^^^^^^^^^^^^^^^^ -The default target CPU, "generic", now enables the `-mnontrapping-fptoint` -and `-mbulk-memory` flags, which correspond to the [Bulk Memory Operations] -and [Non-trapping float-to-int Conversions] language features, which are -[widely implemented in engines]. - -A new Lime1 target CPU is added, -mcpu=lime1. This CPU follows the definition of -the Lime1 CPU [here], and enables -mmultivalue, -mmutable-globals, --mcall-indirect-overlong, -msign-ext, -mbulk-memory-opt, -mnontrapping-fptoint, -and -mextended-const. - -[Bulk Memory Operations]: https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md -[Non-trapping float-to-int Conversions]: https://github.com/WebAssembly/spec/blob/master/proposals/nontrapping-float-to-int-conversion/Overview.md -[widely implemented in engines]: https://webassembly.org/features/ -[here]: https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#lime1 - AVR Support ^^^^^^^^^^^ -- Reject C/C++ compilation for avr1 devices which have no SRAM. - DWARF Support in Clang ---------------------- Floating Point Support in Clang ------------------------------- -- Add ``__builtin_elementwise_atan2`` builtin for floating point types only. - Fixed Point Support in Clang ---------------------------- AST Matchers ------------ -- Fixed an issue with the `hasName` and `hasAnyName` matcher when matching - inline namespaces with an enclosing namespace of the same name. - -- Fixed an ordering issue with the `hasOperands` matcher occurring when setting a - binding in the first matcher and using it in the second matcher. - -- Fixed a crash when traverse lambda expr with invalid captures. (#GH106444) - -- Fixed ``isInstantiated`` and ``isInTemplateInstantiation`` to also match for variable templates. (#GH110666) - -- Ensure ``hasName`` matches template specializations across inline namespaces, - making `matchesNodeFullSlow` and `matchesNodeFullFast` consistent. - -- Improved the performance of the ``getExpansionLocOfMacro`` by tracking already processed macros during recursion. - -- Add ``exportDecl`` matcher to match export declaration. - -- Ensure ``hasType`` and ``hasDeclaration`` match Objective-C interface declarations. - -- Ensure ``pointee`` matches Objective-C pointer types. - -- Add ``dependentScopeDeclRefExpr`` matcher to match expressions that refer to dependent scope declarations. - -- Add ``dependentNameType`` matcher to match a dependent name type. - -- Add ``dependentTemplateSpecializationType`` matcher to match a dependent template specialization type. - -- Add ``hasDependentName`` matcher to match the dependent name of a DependentScopeDeclRefExpr or DependentNameType. - clang-format ------------ -- Adds ``BreakBinaryOperations`` option. -- Adds ``TemplateNames`` option. -- Adds ``AlignFunctionDeclarations`` option to ``AlignConsecutiveDeclarations``. -- Adds ``IndentOnly`` suboption to ``ReflowComments`` to fix the indentation of - multi-line comments without touching their contents, renames ``false`` to - ``Never``, and ``true`` to ``Always``. -- Adds ``RemoveEmptyLinesInUnwrappedLines`` option. -- Adds ``KeepFormFeed`` option and set it to ``true`` for ``GNU`` style. -- Adds ``AllowShortNamespacesOnASingleLine`` option. -- Adds ``VariableTemplates`` option. -- Adds support for bash globstar in ``.clang-format-ignore``. -- Adds ``WrapNamespaceBodyWithEmptyLines`` option. -- Adds the ``IndentExportBlock`` option. - libclang -------- -- Add ``clang_isBeforeInTranslationUnit``. Given two source locations, it determines - whether the first one comes strictly before the second in the source code. -- Add ``clang_getTypePrettyPrinted``. It allows controlling the PrintingPolicy used - to pretty-print a type. -- Added ``clang_visitCXXBaseClasses``, which allows visiting the base classes - of a class. -- Added ``clang_getOffsetOfBase``, which allows computing the offset of a base - class in a class's layout. - Code Completion --------------- -- Use ``HeuristicResolver`` (upstreamed from clangd) to improve code completion results - in dependent code - Static Analyzer --------------- New features ^^^^^^^^^^^^ -- Now CSA models `__builtin_*_overflow` functions. (#GH102602) - -- MallocChecker now checks for ``ownership_returns(class, idx)`` and ``ownership_takes(class, idx)`` - attributes with class names different from "malloc". Clang static analyzer now reports an error - if class of allocation and deallocation function mismatches. - `Documentation <https://clang.llvm.org/docs/analyzer/checkers.html#unix-mismatcheddeallocator-c-c>`__. - -- Function effects, e.g. the ``nonblocking`` and ``nonallocating`` "performance constraint" - attributes, are now verified. For example, for functions declared with the ``nonblocking`` - attribute, the compiler can generate warnings about the use of any language features, or calls to - other functions, which may block. - -- Introduced ``-warning-suppression-mappings`` flag to control diagnostic - suppressions per file. See `documentation <https://clang.llvm.org/docs/WarningSuppressionMappings.html>_` for details. - Crash and bug fixes ^^^^^^^^^^^^^^^^^^^ -- In loops where the loop condition is opaque (i.e. the analyzer cannot - determine whether it's true or false), the analyzer will no longer assume - execution paths that perform more that two iterations. These unjustified - assumptions caused false positive reports (e.g. 100+ out-of-bounds reports in - the FFMPEG codebase) in loops where the programmer intended only two or three - steps but the analyzer wasn't able to understand that the loop is limited. - Improvements ^^^^^^^^^^^^ -- Improved the handling of the ``ownership_returns`` attribute. Now, Clang reports an - error if the attribute is attached to a function that returns a non-pointer value. - Fixes (#GH99501) - Moved checkers ^^^^^^^^^^^^^^ -- The checker ``alpha.core.IdenticalExpr`` was deleted because it was - duplicated in the clang-tidy checkers ``misc-redundant-expression`` and - ``bugprone-branch-clone``. - -- The checker ``alpha.security.MallocOverflow`` was deleted because it was - badly implemented and its aggressive logic produced too many false positives. - To detect too large arguments passed to malloc, consider using the checker - ``alpha.taint.TaintedAlloc``. - -- The checkers ``alpha.nondeterministic.PointerSorting`` and - ``alpha.nondeterministic.PointerIteration`` were moved to a new bugprone - checker named ``bugprone-nondeterministic-pointer-iteration-order``. The - original checkers were implemented only using AST matching and make more - sense as a single clang-tidy check. - -- The checker ``alpha.unix.Chroot`` was modernized, improved and moved to - ``unix.Chroot``. Testing was done on open source projects that use chroot(), - and false issues addressed in the improvements based on real use cases. Open - source projects used for testing include nsjail, lxroot, dive and ruri. - This checker conforms to SEI Cert C recommendation `POS05-C. Limit access to - files by creating a jail - <https://wiki.sei.cmu.edu/confluence/display/c/POS05-C.+Limit+access+to+files+by+creating+a+jail>`_. - Fixes (#GH34697). - (#GH117791) [Documentation](https://clang.llvm.org/docs/analyzer/checkers.html#unix-chroot-c). - .. _release-notes-sanitizers: Sanitizers ---------- -- Introduced Realtime Sanitizer, activated by using the -fsanitize=realtime - flag. This sanitizer detects unsafe system library calls, such as memory - allocations and mutex locks. If any such function is called during invocation - of a function marked with the ``[[clang::nonblocking]]`` attribute, an error - is printed to the console and the process exits non-zero. - -- Added the ``-fsanitize-undefined-ignore-overflow-pattern`` flag which can be - used to disable specific overflow-dependent code patterns. The supported - patterns are: ``add-signed-overflow-test``, ``add-unsigned-overflow-test``, - ``negated-unsigned-const``, and ``unsigned-post-decr-while``. The sanitizer - instrumentation can be toggled off for all available patterns by specifying - ``all``. Conversely, you may disable all exclusions with ``none`` which is - the default. - - .. code-block:: c++ - - /// specified with ``-fsanitize-undefined-ignore-overflow-pattern=add-unsigned-overflow-test`` - int common_overflow_check_pattern(unsigned base, unsigned offset) { - if (base + offset < base) { /* ... */ } // The pattern of `a + b < a`, and other re-orderings, won't be instrumented - } - - /// specified with ``-fsanitize-undefined-ignore-overflow-pattern=add-signed-overflow-test`` - int common_overflow_check_pattern_signed(signed int base, signed int offset) { - if (base + offset < base) { /* ... */ } // The pattern of `a + b < a`, and other re-orderings, won't be instrumented - } - - /// specified with ``-fsanitize-undefined-ignore-overflow-pattern=negated-unsigned-const`` - void negation_overflow() { - unsigned long foo = -1UL; // No longer causes a negation overflow warning - unsigned long bar = -2UL; // and so on... - } - - /// specified with ``-fsanitize-undefined-ignore-overflow-pattern=unsigned-post-decr-while`` - void while_post_decrement() { - unsigned char count = 16; - while (count--) { /* ... */ } // No longer causes unsigned-integer-overflow sanitizer to trip - } - - Many existing projects have a large amount of these code patterns present. - This new flag should allow those projects to enable integer sanitizers with - less noise. - -- ``-fsanitize=signed-integer-overflow``, ``-fsanitize=unsigned-integer-overflow``, - ``-fsanitize=implicit-signed-integer-truncation``, ``-fsanitize=implicit-unsigned-integer-truncation``, - ``-fsanitize=enum`` now properly support the - "type" prefix within `Sanitizer Special Case Lists (SSCL) - <https://clang.llvm.org/docs/SanitizerSpecialCaseList.html>`_. See that link - for examples. - -- Introduced an experimental Type Sanitizer, activated by using the - ``-fsanitize=type`` flag. This sanitizer detects violations of C/C++ type-based - aliasing rules. - -- Implemented ``-f[no-]sanitize-trap=local-bounds``, and ``-f[no-]sanitize-recover=local-bounds``. - -- ``-fsanitize-merge`` (default) and ``-fno-sanitize-merge`` have been added for - fine-grained, unified control of which UBSan checks can potentially be merged - by the compiler (for example, - ``-fno-sanitize-merge=bool,enum,array-bounds,local-bounds``). - -- Changed ``-fsanitize=pointer-overflow`` to no longer report ``NULL + 0`` as - undefined behavior in C, in line with - `N3322 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3322.pdf>`_, - and matching the previous behavior for C++. - ``NULL + non_zero`` continues to be reported as undefined behavior. Python Binding Changes ---------------------- -- Fixed an issue that led to crashes when calling ``Type.get_exception_specification_kind``. -- Added ``Cursor.pretty_printed``, a binding for ``clang_getCursorPrettyPrinted``, - and related functions, which allow changing the formatting of pretty-printed code. -- Added ``Cursor.is_anonymous_record_decl``, a binding for - ``clang_Cursor_isAnonymousRecordDecl``, which allows checking if a - declaration is an anonymous union or anonymous struct. -- Added ``Type.pretty_printed`, a binding for ``clang_getTypePrettyPrinted``, - which allows changing the formatting of pretty-printed types. -- Added ``Cursor.is_virtual_base``, a binding for ``clang_isVirtualBase``, - which checks whether a base class is virtual. -- Added ``Type.get_bases``, a binding for ``clang_visitCXXBaseClasses``, which - allows visiting the base classes of a class. -- Added ``Cursor.get_base_offsetof``, a binding for ``clang_getOffsetOfBase``, - which allows computing the offset of a base class in a class's layout. OpenMP Support -------------- -- Added support for 'omp assume' directive. -- Added support for 'omp scope' directive. -- Added support for allocator-modifier in 'allocate' clause. -- Changed the OpenMP DeviceRTL to use 'generic' IR. The - ``LIBOMPTARGET_DEVICE_ARCHITECTURES`` CMake argument is now unused and will - always build support for AMDGPU and NVPTX targets. -- Added support for combined masked constructs 'omp parallel masked taskloop', - 'omp parallel masked taskloop simd','omp masked taskloop' and 'omp masked taskloop simd' directive. -- Added support for align-modifier in 'allocate' clause. Improvements ^^^^^^^^^^^^ -- Improve the handling of mapping array-section for struct containing nested structs with user defined mappers - -- `num_teams` and `thead_limit` now accept multiple expressions when it is used - along in ``target teams ompx_bare`` construct. This allows the target region - to be launched with multi-dim grid on GPUs. Additional Information ====================== diff --git clang/docs/TypeSanitizer.rst clang/docs/TypeSanitizer.rst new file mode 100644 index 000000000000..8b815d8804fa --- /dev/null +++ clang/docs/TypeSanitizer.rst @@ -0,0 +1,205 @@ +============= +TypeSanitizer +============= + +.. contents:: + :local: + +Introduction +============ + +The TypeSanitizer is a detector for strict type aliasing violations. It consists of a compiler +instrumentation module and a run-time library. C/C++ has type-based aliasing rules, and LLVM +can exploit these for optimizations given the TBAA metadata Clang emits. In general, a pointer +of a given type cannot access an object of a different type, with only a few exceptions. + +These rules aren't always apparent to users, which leads to code that violates these rules +(e.g. for type punning). This can lead to optimization passes introducing bugs unless the +code is build with ``-fno-strict-aliasing``, sacrificing performance. + +TypeSanitizer is built to catch when these strict aliasing rules have been violated, helping +users find where such bugs originate in their code despite the code looking valid at first glance. + +As TypeSanitizer is still experimental, it can currently have a large impact on runtime speed, +memory use, and code size. It also has a large compile-time overhead. Work is being done to +reduce these impacts. + +The TypeSanitizer Algorithm +=========================== +For each TBAA type-access descriptor, encoded in LLVM IR using TBAA Metadata, the instrumentation +pass generates descriptor tales. Thus there is a unique pointer to each type (and access descriptor). +These tables are comdat (except for anonymous-namespace types), so the pointer values are unique +across the program. + +The descriptors refer to other descriptors to form a type aliasing tree, like how LLVM's TBAA data +does. + +The runtime uses 8 bytes of shadow memory, the size of the pointer to the type descriptor, for +every byte of accessed data in the program. The first byte of a type will have its shadow memory +be set to the pointer to its type descriptor. Aside from that, there are some other values it may be. + +* 0 is used to represent an unknown type +* Negative numbers represent an interior byte: A byte inside a type that is not the first one. As an + example, a value of -2 means you are in the third byte of a type. + +The Instrumentation first checks for an exact match between the type of the current access and the +type for that address in the shadow memory. This can quickly be done by checking pointer values. If +it matches, it checks the remaining shadow memory of the type to ensure they are the correct negative +numbers. If this fails, it calls the "slow path" check. If the exact match fails, we check to see if +the value, and the remainder of the shadow bytes, is 0. If they are, we can set the shadow memory to +the correct type descriptor pointer for the first byte, and the correct negative numbers for the rest +of the type's shadow. + +If the type in shadow memory is neither an exact match nor 0, we call the slower runtime check. It +uses the full TBAA algorithm, just as the compiler does, to determine when two types are permitted to +alias. + +The instrumentation pass inserts calls to the memset intrinsic to set the memory updated by memset, +memcpy, and memmove, as well as allocas/byval (and for lifetime.start/end) to reset the shadow memory +to reflect that the type is now unknown. The runtime intercepts memset, memcpy, etc. to perform the +same function for the library calls. + +How to build +============ + +Build LLVM/Clang with `CMake <https://llvm.org/docs/CMake.html>`_ and enable +the ``compiler-rt`` runtime. An example CMake configuration that will allow +for the use/testing of TypeSanitizer: + +.. code-block:: console + + $ cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_RUNTIMES="compiler-rt" <path to source>/llvm + +Usage +===== + +Compile and link your program with ``-fsanitize=type`` flag. The +TypeSanitizer run-time library should be linked to the final executable, so +make sure to use ``clang`` (not ``ld``) for the final link step. To +get a reasonable performance add ``-O1`` or higher. +TypeSanitizer by default doesn't print the full stack trace in error messages. Use ``TYSAN_OPTIONS=print_stacktrace=1`` +to print the full trace. To get nicer stack traces in error messages add ``-fno-omit-frame-pointer`` and +``-g``. To get perfect stack traces you may need to disable inlining (just use ``-O1``) and tail call elimination +(``-fno-optimize-sibling-calls``). + +.. code-block:: console + + % cat example_AliasViolation.c + int main(int argc, char **argv) { + int x = 100; + float *y = (float*)&x; + *y += 2.0f; // Strict aliasing violation + return 0; + } + + # Compile and link + % clang++ -g -fsanitize=type example_AliasViolation.cc + +The program will print an error message to ``stderr`` each time a strict aliasing violation is detected. +The program won't terminate, which will allow you to detect many strict aliasing violations in one +run. + +.. code-block:: console + + % ./a.out + ==1375532==ERROR: TypeSanitizer: type-aliasing-violation on address 0x7ffeebf1a72c (pc 0x5b3b1145ff41 bp 0x7ffeebf1a660 sp 0x7ffeebf19e08 tid 1375532) + READ of size 4 at 0x7ffeebf1a72c with type float accesses an existing object of type int + #0 0x5b3b1145ff40 in main example_AliasViolation.c:4:10 + + ==1375532==ERROR: TypeSanitizer: type-aliasing-violation on address 0x7ffeebf1a72c (pc 0x5b3b1146008a bp 0x7ffeebf1a660 sp 0x7ffeebf19e08 tid 1375532) + WRITE of size 4 at 0x7ffeebf1a72c with type float accesses an existing object of type int + #0 0x5b3b11460089 in main example_AliasViolation.c:4:10 + +Error terminology +------------------ + +There are some terms that may appear in TypeSanitizer errors that are derived from +`TBAA Metadata <https://llvm.org/docs/LangRef.html#tbaa-metadata>`. This section hopes to provide a +brief dictionary of these terms. + +* ``omnipotent char``: This is a special type which can alias with anything. Its name comes from the C/C++ + type ``char``. +* ``type p[x]``: This signifies pointers to the type. ``x`` is the number of indirections to reach the final value. + As an example, a pointer to a pointer to an integer would be ``type p2 int``. + +TypeSanitizer is still experimental. User-facing error messages should be improved in the future to remove +references to LLVM IR specific terms. + +Sanitizer features +================== + +``__has_feature(type_sanitizer)`` +------------------------------------ + +In some cases one may need to execute different code depending on whether +TypeSanitizer is enabled. +:ref:`\_\_has\_feature <langext-__has_feature-__has_extension>` can be used for +this purpose. + +.. code-block:: c + + #if defined(__has_feature) + # if __has_feature(type_sanitizer) + // code that builds only under TypeSanitizer + # endif + #endif + +``__attribute__((no_sanitize("type")))`` +----------------------------------------------- + +Some code you may not want to be instrumented by TypeSanitizer. One may use the +function attribute ``no_sanitize("type")`` to disable instrumenting type aliasing. +It is possible, depending on what happens in non-instrumented code, that instrumented code +emits false-positives/ false-negatives. This attribute may not be supported by other +compilers, so we suggest to use it together with ``__has_feature(type_sanitizer)``. + +``__attribute__((disable_sanitizer_instrumentation))`` +-------------------------------------------------------- + +The ``disable_sanitizer_instrumentation`` attribute can be applied to functions +to prevent all kinds of instrumentation. As a result, it may introduce false +positives and incorrect stack traces. Therefore, it should be used with care, +and only if absolutely required; for example for certain code that cannot +tolerate any instrumentation and resulting side-effects. This attribute +overrides ``no_sanitize("type")``. + +Ignorelist +---------- + +TypeSanitizer supports ``src`` and ``fun`` entity types in +:doc:`SanitizerSpecialCaseList`, that can be used to suppress aliasing +violation reports in the specified source files or functions. Like +with other methods of ignoring instrumentation, this can result in false +positives/ false-negatives. + +Limitations +----------- + +* TypeSanitizer uses more real memory than a native run. It uses 8 bytes of + shadow memory for each byte of user memory. +* There are transformation passes which run before TypeSanitizer. If these + passes optimize out an aliasing violation, TypeSanitizer cannot catch it. +* Currently, all instrumentation is inlined. This can result in a **15x** + (on average) increase in generated file size, and **3x** to **7x** increase + in compile time. In some documented cases this can cause the compiler to hang. + There are plans to improve this in the future. +* Codebases that use unions and struct-initialized variables can see incorrect + results, as TypeSanitizer doesn't yet instrument these reliably. +* Since Clang & LLVM's TBAA system is used to generate the checks used by the + instrumentation, TypeSanitizer follows Clang & LLVM's rules for type aliasing. + There may be situations where that disagrees with the standard. However this + does at least mean that TypeSanitizer will catch any aliasing violations that + would cause bugs when compiling with Clang & LLVM. +* TypeSanitizer cannot currently be run alongside other sanitizers such as + AddressSanitizer, ThreadSanitizer or UndefinedBehaviourSanitizer. + +Current Status +-------------- + +TypeSanitizer is brand new, and still in development. There are some known +issues, especially in areas where Clang's emitted TBAA data isn't extensive +enough for TypeSanitizer's runtime. + +We are actively working on enhancing the tool --- stay tuned. Any help, +issues, pull requests, ideas, is more than welcome. You can find the +`issue tracker here.<https://github.com/llvm/llvm-project/issues?q=is%3Aissue%20state%3Aopen%20TySan%20label%3Acompiler-rt%3Atysan>` diff --git clang/docs/UsersManual.rst clang/docs/UsersManual.rst index 260e84910c6f..a56c9425ebb7 100644 --- clang/docs/UsersManual.rst +++ clang/docs/UsersManual.rst @@ -2103,7 +2103,10 @@ are listed below. ``-fsanitize=undefined``: :doc:`UndefinedBehaviorSanitizer`, a fast and compatible undefined behavior checker. + - .. _opt_fsanitize_type: + ``-fsanitize=type``: :doc:`TypeSanitizer`, a detector for strict + aliasing violations. - ``-fsanitize=dataflow``: :doc:`DataFlowSanitizer`, a general data flow analysis. - ``-fsanitize=cfi``: :doc:`control flow integrity <ControlFlowIntegrity>` diff --git clang/docs/index.rst clang/docs/index.rst index 349378b1efa2..6c792af66a62 100644 --- clang/docs/index.rst +++ clang/docs/index.rst @@ -35,6 +35,7 @@ Using Clang as a Compiler UndefinedBehaviorSanitizer DataFlowSanitizer LeakSanitizer + TypeSanitizer RealtimeSanitizer SanitizerCoverage SanitizerStats diff --git clang/include/clang-c/Index.h clang/include/clang-c/Index.h index aac5d1fa8aa2..cc7c65b15088 100644 --- clang/include/clang-c/Index.h +++ clang/include/clang-c/Index.h @@ -5905,66 +5905,6 @@ CINDEX_LINKAGE const char *clang_EvalResult_getAsStr(CXEvalResult E); * Disposes the created Eval memory. */ CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E); -/** - * @} - */ - -/** \defgroup CINDEX_REMAPPING Remapping functions - * - * @{ - */ - -/** - * A remapping of original source files and their translated files. - */ -typedef void *CXRemapping; - -/** - * Retrieve a remapping. - * - * \param path the path that contains metadata about remappings. - * - * \returns the requested remapping. This remapping must be freed - * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred. - */ -CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path); - -/** - * Retrieve a remapping. - * - * \param filePaths pointer to an array of file paths containing remapping info. - * - * \param numFiles number of file paths. - * - * \returns the requested remapping. This remapping must be freed - * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred. - */ -CINDEX_LINKAGE -CXRemapping clang_getRemappingsFromFileList(const char **filePaths, - unsigned numFiles); - -/** - * Determine the number of remappings. - */ -CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping); - -/** - * Get the original and the associated filename from the remapping. - * - * \param original If non-NULL, will be set to the original filename. - * - * \param transformed If non-NULL, will be set to the filename that the original - * is associated with. - */ -CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index, - CXString *original, - CXString *transformed); - -/** - * Dispose the remapping. - */ -CINDEX_LINKAGE void clang_remap_dispose(CXRemapping); - /** * @} */ diff --git clang/include/clang/ARCMigrate/ARCMT.h clang/include/clang/ARCMigrate/ARCMT.h deleted file mode 100644 index 2b950e3d2cc2..000000000000 --- clang/include/clang/ARCMigrate/ARCMT.h +++ /dev/null @@ -1,130 +0,0 @@ -//===-- ARCMT.h - ARC Migration Rewriter ------------------------*- 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 LLVM_CLANG_ARCMIGRATE_ARCMT_H -#define LLVM_CLANG_ARCMIGRATE_ARCMT_H - -#include "clang/ARCMigrate/FileRemapper.h" -#include "clang/Basic/SourceLocation.h" -#include "clang/Frontend/CompilerInvocation.h" - -namespace clang { - class ASTContext; - class DiagnosticConsumer; - class PCHContainerOperations; - -namespace arcmt { - class MigrationPass; - -/// Creates an AST with the provided CompilerInvocation but with these -/// changes: -/// -if a PCH/PTH is set, the original header is used instead -/// -Automatic Reference Counting mode is enabled -/// -/// It then checks the AST and produces errors/warning for ARC migration issues -/// that the user needs to handle manually. -/// -/// \param emitPremigrationARCErrors if true all ARC errors will get emitted -/// even if the migrator can fix them, but the function will still return false -/// if all ARC errors can be fixed. -/// -/// \param plistOut if non-empty, it is the file path to store the plist with -/// the pre-migration ARC diagnostics. -/// -/// \returns false if no error is produced, true otherwise. -bool -checkForManualIssues(CompilerInvocation &CI, const FrontendInputFile &Input, - std::shared_ptr<PCHContainerOperations> PCHContainerOps, - DiagnosticConsumer *DiagClient, - bool emitPremigrationARCErrors = false, - StringRef plistOut = StringRef()); - -/// Works similar to checkForManualIssues but instead of checking, it -/// applies automatic modifications to source files to conform to ARC. -/// -/// \returns false if no error is produced, true otherwise. -bool -applyTransformations(CompilerInvocation &origCI, - const FrontendInputFile &Input, - std::shared_ptr<PCHContainerOperations> PCHContainerOps, - DiagnosticConsumer *DiagClient); - -/// Applies automatic modifications and produces temporary files -/// and metadata into the \p outputDir path. -/// -/// \param emitPremigrationARCErrors if true all ARC errors will get emitted -/// even if the migrator can fix them, but the function will still return false -/// if all ARC errors can be fixed. -/// -/// \param plistOut if non-empty, it is the file path to store the plist with -/// the pre-migration ARC diagnostics. -/// -/// \returns false if no error is produced, true otherwise. -bool migrateWithTemporaryFiles( - CompilerInvocation &origCI, const FrontendInputFile &Input, - std::shared_ptr<PCHContainerOperations> PCHContainerOps, - DiagnosticConsumer *DiagClient, StringRef outputDir, - bool emitPremigrationARCErrors, StringRef plistOut); - -/// Get the set of file remappings from the \p outputDir path that -/// migrateWithTemporaryFiles produced. -/// -/// \returns false if no error is produced, true otherwise. -bool getFileRemappings(std::vector<std::pair<std::string,std::string> > &remap, - StringRef outputDir, - DiagnosticConsumer *DiagClient); - -/// Get the set of file remappings from a list of files with remapping -/// info. -/// -/// \returns false if no error is produced, true otherwise. -bool getFileRemappingsFromFileList( - std::vector<std::pair<std::string,std::string> > &remap, - ArrayRef<StringRef> remapFiles, - DiagnosticConsumer *DiagClient); - -typedef void (*TransformFn)(MigrationPass &pass); - -std::vector<TransformFn> getAllTransformations(LangOptions::GCMode OrigGCMode, - bool NoFinalizeRemoval); - -class MigrationProcess { - CompilerInvocation OrigCI; - std::shared_ptr<PCHContainerOperations> PCHContainerOps; - DiagnosticConsumer *DiagClient; - FileRemapper Remapper; - -public: - bool HadARCErrors; - - MigrationProcess(CompilerInvocation &CI, - std::shared_ptr<PCHContainerOperations> PCHContainerOps, - DiagnosticConsumer *diagClient, - StringRef outputDir = StringRef()); - - class RewriteListener { - public: - virtual ~RewriteListener(); - - virtual void start(ASTContext &Ctx) { } - virtual void finish() { } - - virtual void insert(SourceLocation loc, StringRef text) { } - virtual void remove(CharSourceRange range) { } - }; - - bool applyTransform(TransformFn trans, RewriteListener *listener = nullptr); - - FileRemapper &getRemapper() { return Remapper; } -}; - -} // end namespace arcmt - -} // end namespace clang - -#endif diff --git clang/include/clang/ARCMigrate/ARCMTActions.h clang/include/clang/ARCMigrate/ARCMTActions.h deleted file mode 100644 index 714f4b33db44..000000000000 --- clang/include/clang/ARCMigrate/ARCMTActions.h +++ /dev/null @@ -1,76 +0,0 @@ -//===--- ARCMTActions.h - ARC Migrate Tool Frontend Actions -----*- 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 LLVM_CLANG_ARCMIGRATE_ARCMTACTIONS_H -#define LLVM_CLANG_ARCMIGRATE_ARCMTACTIONS_H - -#include "clang/ARCMigrate/FileRemapper.h" -#include "clang/Frontend/FrontendAction.h" -#include <memory> - -namespace clang { -namespace arcmt { - -class CheckAction : public WrapperFrontendAction { -protected: - bool BeginInvocation(CompilerInstance &CI) override; - -public: - CheckAction(std::unique_ptr<FrontendAction> WrappedAction); -}; - -class ModifyAction : public WrapperFrontendAction { -protected: - bool BeginInvocation(CompilerInstance &CI) override; - -public: - ModifyAction(std::unique_ptr<FrontendAction> WrappedAction); -}; - -class MigrateSourceAction : public ASTFrontendAction { - FileRemapper Remapper; -protected: - bool BeginInvocation(CompilerInstance &CI) override; - std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, - StringRef InFile) override; -}; - -class MigrateAction : public WrapperFrontendAction { - std::string MigrateDir; - std::string PlistOut; - bool EmitPremigrationARCErrors; -protected: - bool BeginInvocation(CompilerInstance &CI) override; - -public: - MigrateAction(std::unique_ptr<FrontendAction> WrappedAction, - StringRef migrateDir, - StringRef plistOut, - bool emitPremigrationARCErrors); -}; - -/// Migrates to modern ObjC syntax. -class ObjCMigrateAction : public WrapperFrontendAction { - std::string MigrateDir; - unsigned ObjCMigAction; - FileRemapper Remapper; - CompilerInstance *CompInst; -public: - ObjCMigrateAction(std::unique_ptr<FrontendAction> WrappedAction, - StringRef migrateDir, unsigned migrateAction); - -protected: - std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, - StringRef InFile) override; - bool BeginInvocation(CompilerInstance &CI) override; -}; - -} -} - -#endif diff --git clang/include/clang/ARCMigrate/FileRemapper.h clang/include/clang/ARCMigrate/FileRemapper.h deleted file mode 100644 index afcee363516a..000000000000 --- clang/include/clang/ARCMigrate/FileRemapper.h +++ /dev/null @@ -1,84 +0,0 @@ -//===-- FileRemapper.h - File Remapping Helper ------------------*- 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 LLVM_CLANG_ARCMIGRATE_FILEREMAPPER_H -#define LLVM_CLANG_ARCMIGRATE_FILEREMAPPER_H - -#include "clang/Basic/FileEntry.h" -#include "clang/Basic/LLVM.h" -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/StringRef.h" -#include <memory> -#include <variant> - -namespace llvm { - class MemoryBuffer; - class MemoryBufferRef; -} - -namespace clang { - class FileManager; - class DiagnosticsEngine; - class PreprocessorOptions; - -namespace arcmt { - -class FileRemapper { - // FIXME: Reuse the same FileManager for multiple ASTContexts. - std::unique_ptr<FileManager> FileMgr; - - using Target = std::variant<FileEntryRef, llvm::MemoryBuffer *>; - using MappingsTy = llvm::DenseMap<FileEntryRef, Target>; - MappingsTy FromToMappings; - - llvm::DenseMap<const FileEntry *, FileEntryRef> ToFromMappings; - -public: - FileRemapper(); - ~FileRemapper(); - - bool initFromDisk(StringRef outputDir, DiagnosticsEngine &Diag, - bool ignoreIfFilesChanged); - bool initFromFile(StringRef filePath, DiagnosticsEngine &Diag, - bool ignoreIfFilesChanged); - bool flushToDisk(StringRef outputDir, DiagnosticsEngine &Diag); - bool flushToFile(StringRef outputPath, DiagnosticsEngine &Diag); - - bool overwriteOriginal(DiagnosticsEngine &Diag, - StringRef outputDir = StringRef()); - - void remap(StringRef filePath, std::unique_ptr<llvm::MemoryBuffer> memBuf); - - void applyMappings(PreprocessorOptions &PPOpts) const; - - /// Iterate through all the mappings. - void forEachMapping( - llvm::function_ref<void(StringRef, StringRef)> CaptureFile, - llvm::function_ref<void(StringRef, const llvm::MemoryBufferRef &)> - CaptureBuffer) const; - - void clear(StringRef outputDir = StringRef()); - -private: - void remap(FileEntryRef file, std::unique_ptr<llvm::MemoryBuffer> memBuf); - void remap(FileEntryRef file, FileEntryRef newfile); - - OptionalFileEntryRef getOriginalFile(StringRef filePath); - void resetTarget(Target &targ); - - bool report(const Twine &err, DiagnosticsEngine &Diag); - - std::string getRemapInfoFile(StringRef outputDir); -}; - -} // end namespace arcmt - -} // end namespace clang - -#endif diff --git clang/include/clang/AST/ASTLambda.h clang/include/clang/AST/ASTLambda.h index 646cb574847f..a1854b6a1a94 100644 --- clang/include/clang/AST/ASTLambda.h +++ clang/include/clang/AST/ASTLambda.h @@ -17,6 +17,7 @@ #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclTemplate.h" +#include "llvm/Support/Casting.h" namespace clang { inline StringRef getLambdaStaticInvokerName() { @@ -35,6 +36,12 @@ inline bool isLambdaCallOperator(const DeclContext *DC) { return isLambdaCallOperator(cast<CXXMethodDecl>(DC)); } +inline bool isLambdaMethod(const DeclContext *DC) { + if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(DC)) + return MD->getParent()->isLambda(); + return false; +} + inline bool isLambdaCallWithExplicitObjectParameter(const DeclContext *DC) { return isLambdaCallOperator(DC) && cast<CXXMethodDecl>(DC)->isExplicitObjectMemberFunction(); diff --git clang/include/clang/AST/Decl.h clang/include/clang/AST/Decl.h index 16403774e72b..f305cbbce4c6 100644 --- clang/include/clang/AST/Decl.h +++ clang/include/clang/AST/Decl.h @@ -698,6 +698,10 @@ public: return const_cast<ValueDecl *>(this)->getPotentiallyDecomposedVarDecl(); } + /// Determine whether this value is actually a function parameter pack, + /// init-capture pack, or structured binding pack + bool isParameterPack() const; + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K >= firstValue && K <= lastValue; } @@ -1527,10 +1531,6 @@ public: NonParmVarDeclBits.IsInitCapture = IC; } - /// Determine whether this variable is actually a function parameter pack or - /// init-capture pack. - bool isParameterPack() const; - /// Whether this local extern variable declaration's previous declaration /// was declared in the same block scope. Only correct in C++. bool isPreviousDeclInSameBlockScope() const { @@ -2298,6 +2298,13 @@ public: FunctionDeclBits.IsLateTemplateParsed = ILT; } + bool isInstantiatedFromMemberTemplate() const { + return FunctionDeclBits.IsInstantiatedFromMemberTemplate; + } + void setInstantiatedFromMemberTemplate(bool Val = true) { + FunctionDeclBits.IsInstantiatedFromMemberTemplate = Val; + } + /// Whether this function is "trivial" in some specialized C++ senses. /// Can only be true for default constructors, copy constructors, /// copy assignment operators, and destructors. Not meaningful until @@ -5139,6 +5146,12 @@ static constexpr StringRef getOpenMPVariantManglingSeparatorStr() { bool IsArmStreamingFunction(const FunctionDecl *FD, bool IncludeLocallyStreaming); +/// Returns whether the given FunctionDecl has Arm ZA state. +bool hasArmZAState(const FunctionDecl *FD); + +/// Returns whether the given FunctionDecl has Arm ZT0 state. +bool hasArmZT0State(const FunctionDecl *FD); + } // namespace clang #endif // LLVM_CLANG_AST_DECL_H diff --git clang/include/clang/AST/DeclBase.h clang/include/clang/AST/DeclBase.h index 2c0c3a8dc2f9..3a13309a6100 100644 --- clang/include/clang/AST/DeclBase.h +++ clang/include/clang/AST/DeclBase.h @@ -1777,6 +1777,8 @@ protected: uint64_t HasImplicitReturnZero : 1; LLVM_PREFERRED_TYPE(bool) uint64_t IsLateTemplateParsed : 1; + LLVM_PREFERRED_TYPE(bool) + uint64_t IsInstantiatedFromMemberTemplate : 1; /// Kind of contexpr specifier as defined by ConstexprSpecKind. LLVM_PREFERRED_TYPE(ConstexprSpecKind) @@ -1827,7 +1829,7 @@ protected: }; /// Number of inherited and non-inherited bits in FunctionDeclBitfields. - enum { NumFunctionDeclBits = NumDeclContextBits + 31 }; + enum { NumFunctionDeclBits = NumDeclContextBits + 32 }; /// Stores the bits used by CXXConstructorDecl. If modified /// NumCXXConstructorDeclBits and the accessor @@ -1838,12 +1840,12 @@ protected: LLVM_PREFERRED_TYPE(FunctionDeclBitfields) uint64_t : NumFunctionDeclBits; - /// 20 bits to fit in the remaining available space. + /// 19 bits to fit in the remaining available space. /// Note that this makes CXXConstructorDeclBitfields take /// exactly 64 bits and thus the width of NumCtorInitializers /// will need to be shrunk if some bit is added to NumDeclContextBitfields, /// NumFunctionDeclBitfields or CXXConstructorDeclBitfields. - uint64_t NumCtorInitializers : 17; + uint64_t NumCtorInitializers : 16; LLVM_PREFERRED_TYPE(bool) uint64_t IsInheritingConstructor : 1; @@ -1857,7 +1859,7 @@ protected: }; /// Number of inherited and non-inherited bits in CXXConstructorDeclBitfields. - enum { NumCXXConstructorDeclBits = NumFunctionDeclBits + 20 }; + enum { NumCXXConstructorDeclBits = NumFunctionDeclBits + 19 }; /// Stores the bits used by ObjCMethodDecl. /// If modified NumObjCMethodDeclBits and the accessor diff --git clang/include/clang/AST/DeclCXX.h clang/include/clang/AST/DeclCXX.h index fa3f4ec98eb3..766821b4fb25 100644 --- clang/include/clang/AST/DeclCXX.h +++ clang/include/clang/AST/DeclCXX.h @@ -1967,17 +1967,29 @@ public: class CXXDeductionGuideDecl : public FunctionDecl { void anchor() override; +public: + // Represents the relationship between this deduction guide and the + // deduction guide that it was generated from (or lack thereof). + // See the SourceDeductionGuide member for more details. + enum class SourceDeductionGuideKind : uint8_t { + None, + Alias, + }; + private: CXXDeductionGuideDecl(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, SourceLocation EndLocation, CXXConstructorDecl *Ctor, DeductionCandidate Kind, - Expr *TrailingRequiresClause) + Expr *TrailingRequiresClause, + const CXXDeductionGuideDecl *GeneratedFrom, + SourceDeductionGuideKind SourceKind) : FunctionDecl(CXXDeductionGuide, C, DC, StartLoc, NameInfo, T, TInfo, SC_None, false, false, ConstexprSpecKind::Unspecified, TrailingRequiresClause), - Ctor(Ctor), ExplicitSpec(ES) { + Ctor(Ctor), ExplicitSpec(ES), + SourceDeductionGuide(GeneratedFrom, SourceKind) { if (EndLocation.isValid()) setRangeEnd(EndLocation); setDeductionCandidateKind(Kind); @@ -1985,6 +1997,12 @@ private: CXXConstructorDecl *Ctor; ExplicitSpecifier ExplicitSpec; + // The deduction guide, if any, that this deduction guide was generated from, + // in the case of alias template deduction. The SourceDeductionGuideKind + // member indicates which of these sources applies, or is None otherwise. + llvm::PointerIntPair<const CXXDeductionGuideDecl *, 2, + SourceDeductionGuideKind> + SourceDeductionGuide; void setExplicitSpecifier(ExplicitSpecifier ES) { ExplicitSpec = ES; } public: @@ -1997,7 +2015,9 @@ public: TypeSourceInfo *TInfo, SourceLocation EndLocation, CXXConstructorDecl *Ctor = nullptr, DeductionCandidate Kind = DeductionCandidate::Normal, - Expr *TrailingRequiresClause = nullptr); + Expr *TrailingRequiresClause = nullptr, + const CXXDeductionGuideDecl *SourceDG = nullptr, + SourceDeductionGuideKind SK = SourceDeductionGuideKind::None); static CXXDeductionGuideDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID); @@ -2017,6 +2037,25 @@ public: /// this is an implicit deduction guide. CXXConstructorDecl *getCorrespondingConstructor() const { return Ctor; } + /// Get the deduction guide from which this deduction guide was generated, + /// if it was generated as part of alias template deduction or from an + /// inherited constructor. + const CXXDeductionGuideDecl *getSourceDeductionGuide() const { + return SourceDeductionGuide.getPointer(); + } + + void setSourceDeductionGuide(CXXDeductionGuideDecl *DG) { + SourceDeductionGuide.setPointer(DG); + } + + SourceDeductionGuideKind getSourceDeductionGuideKind() const { + return SourceDeductionGuide.getInt(); + } + + void setSourceDeductionGuideKind(SourceDeductionGuideKind SK) { + SourceDeductionGuide.setInt(SK); + } + void setDeductionCandidateKind(DeductionCandidate K) { FunctionDeclBits.DeductionCandidateKind = static_cast<unsigned char>(K); } @@ -4136,8 +4175,9 @@ class BindingDecl : public ValueDecl { /// binding). Expr *Binding = nullptr; - BindingDecl(DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id) - : ValueDecl(Decl::Binding, DC, IdLoc, Id, QualType()) {} + BindingDecl(DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, + QualType T) + : ValueDecl(Decl::Binding, DC, IdLoc, Id, T) {} void anchor() override; @@ -4145,7 +4185,8 @@ public: friend class ASTDeclReader; static BindingDecl *Create(ASTContext &C, DeclContext *DC, - SourceLocation IdLoc, IdentifierInfo *Id); + SourceLocation IdLoc, IdentifierInfo *Id, + QualType T); static BindingDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID); /// Get the expression to which this declaration is bound. This may be null @@ -4153,14 +4194,13 @@ public: /// decomposition declaration, and when the initializer is type-dependent. Expr *getBinding() const { return Binding; } + // Get the array of Exprs when the binding represents a pack. + llvm::ArrayRef<Expr *> getBindingPackExprs() const; + /// Get the decomposition declaration that this binding represents a /// decomposition of. ValueDecl *getDecomposedDecl() const { return Decomp; } - /// Get the variable (if any) that holds the value of evaluating the binding. - /// Only present for user-defined bindings for tuple-like types. - VarDecl *getHoldingVar() const; - /// Set the binding for this BindingDecl, along with its declared type (which /// should be a possibly-cv-qualified form of the type of the binding, or a /// reference to such a type). @@ -4172,6 +4212,10 @@ public: /// Set the decomposed variable for this BindingDecl. void setDecomposedDecl(ValueDecl *Decomposed) { Decomp = Decomposed; } + /// Get the variable (if any) that holds the value of evaluating the binding. + /// Only present for user-defined bindings for tuple-like types. + VarDecl *getHoldingVar() const; + static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == Decl::Binding; } }; @@ -4199,8 +4243,16 @@ class DecompositionDecl final NumBindings(Bindings.size()) { std::uninitialized_copy(Bindings.begin(), Bindings.end(), getTrailingObjects<BindingDecl *>()); - for (auto *B : Bindings) + for (auto *B : Bindings) { B->setDecomposedDecl(this); + if (B->isParameterPack() && B->getBinding()) { + for (Expr *E : B->getBindingPackExprs()) { + auto *DRE = cast<DeclRefExpr>(E); + auto *NestedB = cast<BindingDecl>(DRE->getDecl()); + NestedB->setDecomposedDecl(this); + } + } + } } void anchor() override; @@ -4218,8 +4270,33 @@ public: static DecompositionDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NumBindings); - ArrayRef<BindingDecl *> bindings() const { - return llvm::ArrayRef(getTrailingObjects<BindingDecl *>(), NumBindings); + // Provide the range of bindings which may have a nested pack. + llvm::ArrayRef<BindingDecl *> bindings() const { + return {getTrailingObjects<BindingDecl *>(), NumBindings}; + } + + // Provide a flattened range to visit each binding. + auto flat_bindings() const { + llvm::ArrayRef<BindingDecl *> Bindings = bindings(); + llvm::ArrayRef<Expr *> PackExprs; + + // Split the bindings into subranges split by the pack. + auto S1 = Bindings.take_until( + [](BindingDecl *BD) { return BD->isParameterPack(); }); + + Bindings = Bindings.drop_front(S1.size()); + if (!Bindings.empty()) { + PackExprs = Bindings.front()->getBindingPackExprs(); + Bindings = Bindings.drop_front(); + } + + auto S2 = llvm::map_range(PackExprs, [](Expr *E) { + auto *DRE = cast<DeclRefExpr>(E); + return cast<BindingDecl>(DRE->getDecl()); + }); + + return llvm::concat<BindingDecl *>(std::move(S1), std::move(S2), + std::move(Bindings)); } void printName(raw_ostream &OS, const PrintingPolicy &Policy) const override; diff --git clang/include/clang/AST/DeclTemplate.h clang/include/clang/AST/DeclTemplate.h index caaa47d0a297..0c706036ff70 100644 --- clang/include/clang/AST/DeclTemplate.h +++ clang/include/clang/AST/DeclTemplate.h @@ -1011,6 +1011,15 @@ public: return getTemplatedDecl()->isThisDeclarationADefinition(); } + bool isCompatibleWithDefinition() const { + return getTemplatedDecl()->isInstantiatedFromMemberTemplate() || + isThisDeclarationADefinition(); + } + void setInstantiatedFromMemberTemplate(FunctionTemplateDecl *D) { + getTemplatedDecl()->setInstantiatedFromMemberTemplate(); + RedeclarableTemplateDecl::setInstantiatedFromMemberTemplate(D); + } + /// Return the specialization with the provided arguments if it exists, /// otherwise return the insertion point. FunctionDecl *findSpecialization(ArrayRef<TemplateArgument> Args, @@ -2018,7 +2027,8 @@ public: /// Set the template argument list as written in the sources. void setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten) { - if (auto *Info = ExplicitInfo.dyn_cast<ExplicitInstantiationInfo *>()) + if (auto *Info = + dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo)) Info->TemplateArgsAsWritten = ArgsWritten; else ExplicitInfo = ArgsWritten; @@ -2032,7 +2042,8 @@ public: /// Gets the location of the extern keyword, if present. SourceLocation getExternKeywordLoc() const { - if (auto *Info = ExplicitInfo.dyn_cast<ExplicitInstantiationInfo *>()) + if (auto *Info = + dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo)) return Info->ExternKeywordLoc; return SourceLocation(); } @@ -2780,7 +2791,8 @@ public: /// Retrieve the template argument list as written in the sources, /// if any. const ASTTemplateArgumentListInfo *getTemplateArgsAsWritten() const { - if (auto *Info = ExplicitInfo.dyn_cast<ExplicitInstantiationInfo *>()) + if (auto *Info = + dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo)) return Info->TemplateArgsAsWritten; return cast<const ASTTemplateArgumentListInfo *>(ExplicitInfo); } @@ -2803,7 +2815,8 @@ public: /// Gets the location of the extern keyword, if present. SourceLocation getExternKeywordLoc() const { - if (auto *Info = ExplicitInfo.dyn_cast<ExplicitInstantiationInfo *>()) + if (auto *Info = + dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo)) return Info->ExternKeywordLoc; return SourceLocation(); } @@ -2813,7 +2826,8 @@ public: /// Gets the location of the template keyword, if present. SourceLocation getTemplateKeywordLoc() const { - if (auto *Info = ExplicitInfo.dyn_cast<ExplicitInstantiationInfo *>()) + if (auto *Info = + dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo)) return Info->TemplateKeywordLoc; return SourceLocation(); } diff --git clang/include/clang/AST/DynamicRecursiveASTVisitor.h clang/include/clang/AST/DynamicRecursiveASTVisitor.h index 4382d2099082..4e0ba568263b 100644 --- clang/include/clang/AST/DynamicRecursiveASTVisitor.h +++ clang/include/clang/AST/DynamicRecursiveASTVisitor.h @@ -52,7 +52,11 @@ class ASTContext; /// WalkUpFromX or post-order traversal). /// /// \see RecursiveASTVisitor. -class DynamicRecursiveASTVisitor { +template <bool IsConst> class DynamicRecursiveASTVisitorBase { +protected: + template <typename ASTNode> + using MaybeConst = std::conditional_t<IsConst, const ASTNode, ASTNode>; + public: /// Whether this visitor should recurse into template instantiations. bool ShouldVisitTemplateInstantiations = false; @@ -68,28 +72,29 @@ public: bool ShouldVisitLambdaBody = true; protected: - DynamicRecursiveASTVisitor() = default; - DynamicRecursiveASTVisitor(DynamicRecursiveASTVisitor &&) = default; - DynamicRecursiveASTVisitor(const DynamicRecursiveASTVisitor &) = default; - DynamicRecursiveASTVisitor & - operator=(DynamicRecursiveASTVisitor &&) = default; - DynamicRecursiveASTVisitor & - operator=(const DynamicRecursiveASTVisitor &) = default; + DynamicRecursiveASTVisitorBase() = default; + DynamicRecursiveASTVisitorBase(DynamicRecursiveASTVisitorBase &&) = default; + DynamicRecursiveASTVisitorBase(const DynamicRecursiveASTVisitorBase &) = + default; + DynamicRecursiveASTVisitorBase & + operator=(DynamicRecursiveASTVisitorBase &&) = default; + DynamicRecursiveASTVisitorBase & + operator=(const DynamicRecursiveASTVisitorBase &) = default; public: virtual void anchor(); - virtual ~DynamicRecursiveASTVisitor() = default; + virtual ~DynamicRecursiveASTVisitorBase() = default; /// Recursively visits an entire AST, starting from the TranslationUnitDecl. /// \returns false if visitation was terminated early. - virtual bool TraverseAST(ASTContext &AST); + virtual bool TraverseAST(MaybeConst<ASTContext> &AST); /// Recursively visit an attribute, by dispatching to /// Traverse*Attr() based on the argument's dynamic type. /// /// \returns false if the visitation was terminated early, true /// otherwise (including when the argument is a Null type location). - virtual bool TraverseAttr(Attr *At); + virtual bool TraverseAttr(MaybeConst<Attr> *At); /// Recursively visit a constructor initializer. This /// automatically dispatches to another visitor for the initializer @@ -97,7 +102,8 @@ public: /// be overridden for clients that need access to the name. /// /// \returns false if the visitation was terminated early, true otherwise. - virtual bool TraverseConstructorInitializer(CXXCtorInitializer *Init); + virtual bool + TraverseConstructorInitializer(MaybeConst<CXXCtorInitializer> *Init); /// Recursively visit a base specifier. This can be overridden by a /// subclass. @@ -110,7 +116,7 @@ public: /// /// \returns false if the visitation was terminated early, true /// otherwise (including when the argument is NULL). - virtual bool TraverseDecl(Decl *D); + virtual bool TraverseDecl(MaybeConst<Decl> *D); /// Recursively visit a name with its location information. /// @@ -121,13 +127,15 @@ public: /// will be used to initialize the capture. /// /// \returns false if the visitation was terminated early, true otherwise. - virtual bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C, - Expr *Init); + virtual bool TraverseLambdaCapture(MaybeConst<LambdaExpr> *LE, + const LambdaCapture *C, + MaybeConst<Expr> *Init); /// Recursively visit a C++ nested-name-specifier. /// /// \returns false if the visitation was terminated early, true otherwise. - virtual bool TraverseNestedNameSpecifier(NestedNameSpecifier *NNS); + virtual bool + TraverseNestedNameSpecifier(MaybeConst<NestedNameSpecifier> *NNS); /// Recursively visit a C++ nested-name-specifier with location /// information. @@ -140,7 +148,7 @@ public: /// /// \returns false if the visitation was terminated early, true /// otherwise (including when the argument is nullptr). - virtual bool TraverseStmt(Stmt *S); + virtual bool TraverseStmt(MaybeConst<Stmt> *S); /// Recursively visit a template argument and dispatch to the /// appropriate method for the argument type. @@ -190,41 +198,51 @@ public: /// Traverse a concept (requirement). virtual bool TraverseTypeConstraint(const TypeConstraint *C); - virtual bool TraverseConceptRequirement(concepts::Requirement *R); - virtual bool TraverseConceptTypeRequirement(concepts::TypeRequirement *R); - virtual bool TraverseConceptExprRequirement(concepts::ExprRequirement *R); - virtual bool TraverseConceptNestedRequirement(concepts::NestedRequirement *R); - virtual bool TraverseConceptReference(ConceptReference *CR); - virtual bool VisitConceptReference(ConceptReference *CR) { return true; } + virtual bool TraverseConceptRequirement(MaybeConst<concepts::Requirement> *R); + + virtual bool + TraverseConceptTypeRequirement(MaybeConst<concepts::TypeRequirement> *R); + + virtual bool + TraverseConceptExprRequirement(MaybeConst<concepts::ExprRequirement> *R); + + virtual bool + TraverseConceptNestedRequirement(MaybeConst<concepts::NestedRequirement> *R); + + virtual bool TraverseConceptReference(MaybeConst<ConceptReference> *CR); + virtual bool VisitConceptReference(MaybeConst<ConceptReference> *CR) { + return true; + } /// Visit a node. - virtual bool VisitAttr(Attr *A) { return true; } - virtual bool VisitDecl(Decl *D) { return true; } - virtual bool VisitStmt(Stmt *S) { return true; } - virtual bool VisitType(Type *T) { return true; } + virtual bool VisitAttr(MaybeConst<Attr> *A) { return true; } + virtual bool VisitDecl(MaybeConst<Decl> *D) { return true; } + virtual bool VisitStmt(MaybeConst<Stmt> *S) { return true; } + virtual bool VisitType(MaybeConst<Type> *T) { return true; } virtual bool VisitTypeLoc(TypeLoc TL) { return true; } /// Walk up from a node. - bool WalkUpFromDecl(Decl *D) { return VisitDecl(D); } - bool WalkUpFromStmt(Stmt *S) { return VisitStmt(S); } - bool WalkUpFromType(Type *T) { return VisitType(T); } + bool WalkUpFromDecl(MaybeConst<Decl> *D) { return VisitDecl(D); } + bool WalkUpFromStmt(MaybeConst<Stmt> *S) { return VisitStmt(S); } + bool WalkUpFromType(MaybeConst<Type> *T) { return VisitType(T); } bool WalkUpFromTypeLoc(TypeLoc TL) { return VisitTypeLoc(TL); } /// Invoked before visiting a statement or expression via data recursion. /// /// \returns false to skip visiting the node, true otherwise. - virtual bool dataTraverseStmtPre(Stmt *S) { return true; } + virtual bool dataTraverseStmtPre(MaybeConst<Stmt> *S) { return true; } /// Invoked after visiting a statement or expression via data recursion. /// This is not invoked if the previously invoked \c dataTraverseStmtPre /// returned false. /// /// \returns false if the visitation was terminated early, true otherwise. - virtual bool dataTraverseStmtPost(Stmt *S) { return true; } - virtual bool dataTraverseNode(Stmt *S); + virtual bool dataTraverseStmtPost(MaybeConst<Stmt> *S) { return true; } + virtual bool dataTraverseNode(MaybeConst<Stmt> *S); #define DEF_TRAVERSE_TMPL_INST(kind) \ - virtual bool TraverseTemplateInstantiations(kind##TemplateDecl *D); + virtual bool TraverseTemplateInstantiations( \ + MaybeConst<kind##TemplateDecl> *D); DEF_TRAVERSE_TMPL_INST(Class) DEF_TRAVERSE_TMPL_INST(Var) DEF_TRAVERSE_TMPL_INST(Function) @@ -232,32 +250,34 @@ public: // Decls. #define ABSTRACT_DECL(DECL) -#define DECL(CLASS, BASE) virtual bool Traverse##CLASS##Decl(CLASS##Decl *D); +#define DECL(CLASS, BASE) \ + virtual bool Traverse##CLASS##Decl(MaybeConst<CLASS##Decl> *D); #include "clang/AST/DeclNodes.inc" #define DECL(CLASS, BASE) \ - bool WalkUpFrom##CLASS##Decl(CLASS##Decl *D); \ - virtual bool Visit##CLASS##Decl(CLASS##Decl *D) { return true; } + bool WalkUpFrom##CLASS##Decl(MaybeConst<CLASS##Decl> *D); \ + virtual bool Visit##CLASS##Decl(MaybeConst<CLASS##Decl> *D) { return true; } #include "clang/AST/DeclNodes.inc" // Stmts. #define ABSTRACT_STMT(STMT) -#define STMT(CLASS, PARENT) virtual bool Traverse##CLASS(CLASS *S); +#define STMT(CLASS, PARENT) virtual bool Traverse##CLASS(MaybeConst<CLASS> *S); #include "clang/AST/StmtNodes.inc" #define STMT(CLASS, PARENT) \ - bool WalkUpFrom##CLASS(CLASS *S); \ - virtual bool Visit##CLASS(CLASS *S) { return true; } + bool WalkUpFrom##CLASS(MaybeConst<CLASS> *S); \ + virtual bool Visit##CLASS(MaybeConst<CLASS> *S) { return true; } #include "clang/AST/StmtNodes.inc" // Types. #define ABSTRACT_TYPE(CLASS, BASE) -#define TYPE(CLASS, BASE) virtual bool Traverse##CLASS##Type(CLASS##Type *T); +#define TYPE(CLASS, BASE) \ + virtual bool Traverse##CLASS##Type(MaybeConst<CLASS##Type> *T); #include "clang/AST/TypeNodes.inc" #define TYPE(CLASS, BASE) \ - bool WalkUpFrom##CLASS##Type(CLASS##Type *T); \ - virtual bool Visit##CLASS##Type(CLASS##Type *T) { return true; } + bool WalkUpFrom##CLASS##Type(MaybeConst<CLASS##Type> *T); \ + virtual bool Visit##CLASS##Type(MaybeConst<CLASS##Type> *T) { return true; } #include "clang/AST/TypeNodes.inc" // TypeLocs. @@ -271,6 +291,14 @@ public: virtual bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TL) { return true; } #include "clang/AST/TypeLocNodes.def" }; + +extern template class DynamicRecursiveASTVisitorBase<false>; +extern template class DynamicRecursiveASTVisitorBase<true>; + +using DynamicRecursiveASTVisitor = + DynamicRecursiveASTVisitorBase</*Const=*/false>; +using ConstDynamicRecursiveASTVisitor = + DynamicRecursiveASTVisitorBase</*Const=*/true>; } // namespace clang #endif // LLVM_CLANG_AST_DYNAMIC_RECURSIVE_AST_VISITOR_H diff --git clang/include/clang/AST/ExprCXX.h clang/include/clang/AST/ExprCXX.h index aa10945addf7..0b6c8cfb163c 100644 --- clang/include/clang/AST/ExprCXX.h +++ clang/include/clang/AST/ExprCXX.h @@ -2847,8 +2847,8 @@ public: /// /// Example: /// \code -/// __array_rank(int[10][20]) == 2 -/// __array_extent(int, 1) == 20 +/// __array_rank(int[10][20]) == 2 +/// __array_extent(int[10][20], 1) == 20 /// \endcode class ArrayTypeTraitExpr : public Expr { /// The trait. An ArrayTypeTrait enum in MSVC compat unsigned. @@ -4326,8 +4326,6 @@ public: /// Retrieve the parameter pack. NamedDecl *getPack() const { return Pack; } - void setPack(NamedDecl *NewPack) { Pack = NewPack; } - /// Retrieve the length of the parameter pack. /// /// This routine may only be invoked when the expression is not @@ -5321,6 +5319,59 @@ public: } }; +// Represents an unexpanded pack where the list of expressions are +// known. These are used when structured bindings introduce a pack. +class ResolvedUnexpandedPackExpr final + : public Expr, + private llvm::TrailingObjects<ResolvedUnexpandedPackExpr, Expr *> { + friend class ASTStmtReader; + friend class ASTStmtWriter; + friend TrailingObjects; + + SourceLocation BeginLoc; + unsigned NumExprs; + + ResolvedUnexpandedPackExpr(SourceLocation BL, QualType QT, unsigned NumExprs); + +public: + static ResolvedUnexpandedPackExpr *CreateDeserialized(ASTContext &C, + unsigned NumExprs); + static ResolvedUnexpandedPackExpr * + Create(ASTContext &C, SourceLocation BeginLoc, QualType T, unsigned NumExprs); + static ResolvedUnexpandedPackExpr *Create(ASTContext &C, + SourceLocation BeginLoc, QualType T, + llvm::ArrayRef<Expr *> Exprs); + + unsigned getNumExprs() const { return NumExprs; } + + llvm::MutableArrayRef<Expr *> getExprs() { + return {getTrailingObjects<Expr *>(), NumExprs}; + } + + llvm::ArrayRef<Expr *> getExprs() const { + return {getTrailingObjects<Expr *>(), NumExprs}; + } + + Expr *getExpansion(unsigned Idx) { return getExprs()[Idx]; } + Expr *getExpansion(unsigned Idx) const { return getExprs()[Idx]; } + + // Iterators + child_range children() { + return child_range((Stmt **)getTrailingObjects<Expr *>(), + (Stmt **)getTrailingObjects<Expr *>() + getNumExprs()); + } + + SourceLocation getBeginLoc() const LLVM_READONLY { return BeginLoc; } + SourceLocation getEndLoc() const LLVM_READONLY { return BeginLoc; } + + // Returns the resolved pack of a decl or nullptr + static ResolvedUnexpandedPackExpr *getFromDecl(Decl *); + + static bool classof(const Stmt *T) { + return T->getStmtClass() == ResolvedUnexpandedPackExprClass; + } +}; + } // namespace clang #endif // LLVM_CLANG_AST_EXPRCXX_H diff --git clang/include/clang/AST/RecursiveASTVisitor.h clang/include/clang/AST/RecursiveASTVisitor.h index c4a1d03f1b3d..5f4c39b9cbdb 100644 --- clang/include/clang/AST/RecursiveASTVisitor.h +++ clang/include/clang/AST/RecursiveASTVisitor.h @@ -2950,6 +2950,7 @@ DEF_TRAVERSE_STMT(FunctionParmPackExpr, {}) DEF_TRAVERSE_STMT(CXXFoldExpr, {}) DEF_TRAVERSE_STMT(AtomicExpr, {}) DEF_TRAVERSE_STMT(CXXParenListInitExpr, {}) +DEF_TRAVERSE_STMT(ResolvedUnexpandedPackExpr, {}) DEF_TRAVERSE_STMT(MaterializeTemporaryExpr, { if (S->getLifetimeExtendedTemporaryDecl()) { diff --git clang/include/clang/AST/Type.h clang/include/clang/AST/Type.h index 3457d524c63a..1d9743520654 100644 --- clang/include/clang/AST/Type.h +++ clang/include/clang/AST/Type.h @@ -2518,6 +2518,7 @@ public: bool isFloat32Type() const; bool isDoubleType() const; bool isBFloat16Type() const; + bool isMFloat8Type() const; bool isFloat128Type() const; bool isIbm128Type() const; bool isRealType() const; // C99 6.2.5p17 (real floating + integer) @@ -8537,6 +8538,10 @@ inline bool Type::isBFloat16Type() const { return isSpecificBuiltinType(BuiltinType::BFloat16); } +inline bool Type::isMFloat8Type() const { + return isSpecificBuiltinType(BuiltinType::MFloat8); +} + inline bool Type::isFloat128Type() const { return isSpecificBuiltinType(BuiltinType::Float128); } diff --git clang/include/clang/Basic/AArch64SVEACLETypes.def clang/include/clang/Basic/AArch64SVEACLETypes.def index 063cac1f4a58..a408bb0c5405 100644 --- clang/include/clang/Basic/AArch64SVEACLETypes.def +++ clang/include/clang/Basic/AArch64SVEACLETypes.def @@ -57,6 +57,11 @@ // - IsBF true for vector of brain float elements. //===----------------------------------------------------------------------===// +#ifndef SVE_SCALAR_TYPE +#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \ + SVE_TYPE(Name, Id, SingletonId) +#endif + #ifndef SVE_VECTOR_TYPE #define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \ SVE_TYPE(Name, Id, SingletonId) @@ -72,6 +77,11 @@ SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, false, true) #endif +#ifndef SVE_VECTOR_TYPE_MFLOAT +#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \ + SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, false, false) +#endif + #ifndef SVE_VECTOR_TYPE_FLOAT #define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \ SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, true, false) @@ -97,16 +107,6 @@ SVE_TYPE(Name, Id, SingletonId) #endif -#ifndef AARCH64_VECTOR_TYPE -#define AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \ - SVE_TYPE(Name, Id, SingletonId) -#endif - -#ifndef AARCH64_VECTOR_TYPE_MFLOAT -#define AARCH64_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \ - AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) -#endif - //===- Vector point types -----------------------------------------------===// SVE_VECTOR_TYPE_INT("__SVInt8_t", "__SVInt8_t", SveInt8, SveInt8Ty, 16, 8, 1, true) @@ -125,8 +125,7 @@ SVE_VECTOR_TYPE_FLOAT("__SVFloat64_t", "__SVFloat64_t", SveFloat64, SveFloat64Ty SVE_VECTOR_TYPE_BFLOAT("__SVBfloat16_t", "__SVBfloat16_t", SveBFloat16, SveBFloat16Ty, 8, 16, 1) -// This is a 8 bits opaque type. -SVE_VECTOR_TYPE_INT("__SVMfloat8_t", "__SVMfloat8_t", SveMFloat8, SveMFloat8Ty, 16, 8, 1, false) +SVE_VECTOR_TYPE_MFLOAT("__SVMfloat8_t", "__SVMfloat8_t", SveMFloat8, SveMFloat8Ty, 16, 8, 1) // // x2 @@ -148,7 +147,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x2_t", "svfloat64x2_t", SveFloat64x2, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x2_t", "svbfloat16x2_t", SveBFloat16x2, SveBFloat16x2Ty, 8, 16, 2) -SVE_VECTOR_TYPE_INT("__clang_svmfloat8x2_t", "svmfloat8x2_t", SveMFloat8x2, SveMFloat8x2Ty, 16, 8, 2, false) +SVE_VECTOR_TYPE_MFLOAT("__clang_svmfloat8x2_t", "svmfloat8x2_t", SveMFloat8x2, SveMFloat8x2Ty, 16, 8, 2) // // x3 @@ -170,7 +169,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x3_t", "svfloat64x3_t", SveFloat64x3, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x3_t", "svbfloat16x3_t", SveBFloat16x3, SveBFloat16x3Ty, 8, 16, 3) -SVE_VECTOR_TYPE_INT("__clang_svmfloat8x3_t", "svmfloat8x3_t", SveMFloat8x3, SveMFloat8x3Ty, 16, 8, 3, false) +SVE_VECTOR_TYPE_MFLOAT("__clang_svmfloat8x3_t", "svmfloat8x3_t", SveMFloat8x3, SveMFloat8x3Ty, 16, 8, 3) // // x4 @@ -192,7 +191,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x4_t", "svfloat64x4_t", SveFloat64x4, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x4_t", "svbfloat16x4_t", SveBFloat16x4, SveBFloat16x4Ty, 8, 16, 4) -SVE_VECTOR_TYPE_INT("__clang_svmfloat8x4_t", "svmfloat8x4_t", SveMFloat8x4, SveMFloat8x4Ty, 16, 8, 4, false) +SVE_VECTOR_TYPE_MFLOAT("__clang_svmfloat8x4_t", "svmfloat8x4_t", SveMFloat8x4, SveMFloat8x4Ty, 16, 8, 4) SVE_PREDICATE_TYPE_ALL("__SVBool_t", "__SVBool_t", SveBool, SveBoolTy, 16, 1) SVE_PREDICATE_TYPE_ALL("__clang_svboolx2_t", "svboolx2_t", SveBoolx2, SveBoolx2Ty, 16, 2) @@ -200,17 +199,15 @@ SVE_PREDICATE_TYPE_ALL("__clang_svboolx4_t", "svboolx4_t", SveBoolx4, SveBoolx4T SVE_OPAQUE_TYPE("__SVCount_t", "__SVCount_t", SveCount, SveCountTy) -AARCH64_VECTOR_TYPE_MFLOAT("__mfp8", "__mfp8", MFloat8, MFloat8Ty, 1, 8, 1) -AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8x8_t", "__MFloat8x8_t", MFloat8x8, MFloat8x8Ty, 8, 8, 1) -AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8x16_t", "__MFloat8x16_t", MFloat8x16, MFloat8x16Ty, 16, 8, 1) +SVE_SCALAR_TYPE("__mfp8", "__mfp8", MFloat8, MFloat8Ty, 8) #undef SVE_VECTOR_TYPE +#undef SVE_VECTOR_TYPE_MFLOAT #undef SVE_VECTOR_TYPE_BFLOAT #undef SVE_VECTOR_TYPE_FLOAT #undef SVE_VECTOR_TYPE_INT #undef SVE_PREDICATE_TYPE #undef SVE_PREDICATE_TYPE_ALL #undef SVE_OPAQUE_TYPE -#undef AARCH64_VECTOR_TYPE_MFLOAT -#undef AARCH64_VECTOR_TYPE +#undef SVE_SCALAR_TYPE #undef SVE_TYPE diff --git clang/include/clang/Basic/Attr.td clang/include/clang/Basic/Attr.td index 408d3adf370c..f4ba2bc3c6de 100644 --- clang/include/clang/Basic/Attr.td +++ clang/include/clang/Basic/Attr.td @@ -3458,18 +3458,16 @@ def DiagnoseIf : InheritableAttr { let Spellings = [GNU<"diagnose_if">]; let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty]>; let Args = [ExprArgument<"Cond">, StringArgument<"Message">, - EnumArgument<"DiagnosticType", "DiagnosticType", + EnumArgument<"DefaultSeverity", + "DefaultSeverity", /*is_string=*/true, - ["error", "warning"], - ["DT_Error", "DT_Warning"]>, + ["error", "warning"], + ["DS_error", "DS_warning"]>, + StringArgument<"WarningGroup", /*optional*/ 1>, BoolArgument<"ArgDependent", 0, /*fake*/ 1>, DeclArgument<Named, "Parent", 0, /*fake*/ 1>]; let InheritEvenIfAlreadyPresent = 1; let LateParsed = LateAttrParseStandard; - let AdditionalMembers = [{ - bool isError() const { return diagnosticType == DT_Error; } - bool isWarning() const { return diagnosticType == DT_Warning; } - }]; let TemplateDependent = 1; let Documentation = [DiagnoseIfDocs]; } diff --git clang/include/clang/Basic/Builtins.td clang/include/clang/Basic/Builtins.td index 60c360d4a9e0..29939242596b 100644 --- clang/include/clang/Basic/Builtins.td +++ clang/include/clang/Basic/Builtins.td @@ -4795,6 +4795,12 @@ def HLSLWaveActiveCountBits : LangBuiltin<"HLSL_LANG"> { let Prototype = "unsigned int(bool)"; } +def HLSLWaveActiveMax : LangBuiltin<"HLSL_LANG"> { + let Spellings = ["__builtin_hlsl_wave_active_max"]; + let Attributes = [NoThrow, Const]; + let Prototype = "void (...)"; +} + def HLSLWaveActiveSum : LangBuiltin<"HLSL_LANG"> { let Spellings = ["__builtin_hlsl_wave_active_sum"]; let Attributes = [NoThrow, Const]; diff --git clang/include/clang/Basic/BuiltinsAMDGPU.def clang/include/clang/Basic/BuiltinsAMDGPU.def index 1b29a8e359c2..39e295aced96 100644 --- clang/include/clang/Basic/BuiltinsAMDGPU.def +++ clang/include/clang/Basic/BuiltinsAMDGPU.def @@ -504,6 +504,8 @@ TARGET_BUILTIN(__builtin_amdgcn_global_load_tr_b128_v4i16, "V4sV4s*1", "nc", "gf TARGET_BUILTIN(__builtin_amdgcn_global_load_tr_b128_v4f16, "V4hV4h*1", "nc", "gfx12-insts,wavefrontsize64") TARGET_BUILTIN(__builtin_amdgcn_global_load_tr_b128_v4bf16, "V4yV4y*1", "nc", "gfx12-insts,wavefrontsize64") +TARGET_BUILTIN(__builtin_amdgcn_ds_bpermute_fi_b32, "iii", "nc", "gfx12-insts") + //===----------------------------------------------------------------------===// // WMMA builtins. // Postfix w32 indicates the builtin requires wavefront size of 32. diff --git clang/include/clang/Basic/BuiltinsHexagon.def clang/include/clang/Basic/BuiltinsHexagon.def deleted file mode 100644 index adff9f884c04..000000000000 --- clang/include/clang/Basic/BuiltinsHexagon.def +++ /dev/null @@ -1,173 +0,0 @@ -//===-- BuiltinsHexagon.def - Hexagon Builtin function database --*- 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 the Hexagon-specific builtin function database. Users of -// this file must define the BUILTIN macro to make use of this information. -// -//===----------------------------------------------------------------------===// - -// The format of this database matches clang/Basic/Builtins.def. - -#if defined(BUILTIN) && !defined(TARGET_BUILTIN) -# define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS) -#endif - -#pragma push_macro("V79") -#define V79 "v79" -#pragma push_macro("V75") -#define V75 "v75|" V79 -#pragma push_macro("V73") -#define V73 "v73|" V75 -#pragma push_macro("V71") -#define V71 "v71|" V73 -#pragma push_macro("V69") -#define V69 "v69|" V71 -#pragma push_macro("V68") -#define V68 "v68|" V69 -#pragma push_macro("V67") -#define V67 "v67|" V68 -#pragma push_macro("V66") -#define V66 "v66|" V67 -#pragma push_macro("V65") -#define V65 "v65|" V66 -#pragma push_macro("V62") -#define V62 "v62|" V65 -#pragma push_macro("V60") -#define V60 "v60|" V62 -#pragma push_macro("V55") -#define V55 "v55|" V60 -#pragma push_macro("V5") -#define V5 "v5|" V55 - -#pragma push_macro("HVXV79") -#define HVXV79 "hvxv79" -#pragma push_macro("HVXV75") -#define HVXV75 "hvxv75|" HVXV79 -#pragma push_macro("HVXV73") -#define HVXV73 "hvxv73|" HVXV75 -#pragma push_macro("HVXV71") -#define HVXV71 "hvxv71|" HVXV73 -#pragma push_macro("HVXV69") -#define HVXV69 "hvxv69|" HVXV71 -#pragma push_macro("HVXV68") -#define HVXV68 "hvxv68|" HVXV69 -#pragma push_macro("HVXV67") -#define HVXV67 "hvxv67|" HVXV68 -#pragma push_macro("HVXV66") -#define HVXV66 "hvxv66|" HVXV67 -#pragma push_macro("HVXV65") -#define HVXV65 "hvxv65|" HVXV66 -#pragma push_macro("HVXV62") -#define HVXV62 "hvxv62|" HVXV65 -#pragma push_macro("HVXV60") -#define HVXV60 "hvxv60|" HVXV62 - - -// The builtins below are not autogenerated from iset.py. -// Make sure you do not overwrite these. -TARGET_BUILTIN(__builtin_SI_to_SXTHI_asrh, "ii", "", V5) -TARGET_BUILTIN(__builtin_brev_ldd, "v*LLi*CLLi*iC", "", V5) -TARGET_BUILTIN(__builtin_brev_ldw, "v*i*Ci*iC", "", V5) -TARGET_BUILTIN(__builtin_brev_ldh, "v*s*Cs*iC", "", V5) -TARGET_BUILTIN(__builtin_brev_lduh, "v*Us*CUs*iC", "", V5) -TARGET_BUILTIN(__builtin_brev_ldb, "v*Sc*CSc*iC", "", V5) -TARGET_BUILTIN(__builtin_brev_ldub, "v*Uc*CUc*iC", "", V5) -TARGET_BUILTIN(__builtin_circ_ldd, "LLi*LLi*LLi*iIi", "", V5) -TARGET_BUILTIN(__builtin_circ_ldw, "i*i*i*iIi", "", V5) -TARGET_BUILTIN(__builtin_circ_ldh, "s*s*s*iIi", "", V5) -TARGET_BUILTIN(__builtin_circ_lduh, "Us*Us*Us*iIi", "", V5) -TARGET_BUILTIN(__builtin_circ_ldb, "c*c*c*iIi", "", V5) -TARGET_BUILTIN(__builtin_circ_ldub, "Uc*Uc*Uc*iIi", "", V5) -TARGET_BUILTIN(__builtin_brev_std, "LLi*CLLi*LLiiC", "", V5) -TARGET_BUILTIN(__builtin_brev_stw, "i*Ci*iiC", "", V5) -TARGET_BUILTIN(__builtin_brev_sth, "s*Cs*iiC", "", V5) -TARGET_BUILTIN(__builtin_brev_sthhi, "s*Cs*iiC", "", V5) -TARGET_BUILTIN(__builtin_brev_stb, "c*Cc*iiC", "", V5) -TARGET_BUILTIN(__builtin_circ_std, "LLi*LLi*LLiiIi", "", V5) -TARGET_BUILTIN(__builtin_circ_stw, "i*i*iiIi", "", V5) -TARGET_BUILTIN(__builtin_circ_sth, "s*s*iiIi", "", V5) -TARGET_BUILTIN(__builtin_circ_sthhi, "s*s*iiIi", "", V5) -TARGET_BUILTIN(__builtin_circ_stb, "c*c*iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_L2_loadrub_pci, "iv*IiivC*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_L2_loadrb_pci, "iv*IiivC*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_L2_loadruh_pci, "iv*IiivC*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_L2_loadrh_pci, "iv*IiivC*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_L2_loadri_pci, "iv*IiivC*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_L2_loadrd_pci, "LLiv*IiivC*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_L2_loadrub_pcr, "iv*ivC*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_L2_loadrb_pcr, "iv*ivC*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_L2_loadruh_pcr, "iv*ivC*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_L2_loadrh_pcr, "iv*ivC*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_L2_loadri_pcr, "iv*ivC*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_L2_loadrd_pcr, "LLiv*ivC*", "", V5) - -TARGET_BUILTIN(__builtin_HEXAGON_S2_storerb_pci, "vv*IiiivC*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_storerh_pci, "vv*IiiivC*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_storerf_pci, "vv*IiiivC*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_storeri_pci, "vv*IiiivC*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_storerd_pci, "vv*IiiLLivC*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_storerb_pcr, "vv*iivC*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_storerh_pcr, "vv*iivC*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_storerf_pcr, "vv*iivC*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_storeri_pcr, "vv*iivC*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_storerd_pcr, "vv*iLLivC*", "", V5) - -TARGET_BUILTIN(__builtin_HEXAGON_prefetch,"vv*","", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A6_vminub_RdP,"LLiLLiLLi","", V62) - -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaskedstoreq,"vV64bv*V16i","", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaskedstorenq,"vV64bv*V16i","", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaskedstorentq,"vV64bv*V16i","", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaskedstorentnq,"vV64bv*V16i","", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaskedstoreq_128B,"vV128bv*V32i","", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaskedstorenq_128B,"vV128bv*V32i","", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaskedstorentq_128B,"vV128bv*V32i","", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaskedstorentnq_128B,"vV128bv*V32i","", HVXV60) - - -// These are only valid on v65 -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybub_rtt,"V32iV16iLLi","", "hvxv65") -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybub_rtt_128B,"V64iV32iLLi","", "hvxv65") -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybub_rtt_acc,"V32iV32iV16iLLi","", "hvxv65") -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybub_rtt_acc_128B,"V64iV64iV32iLLi","", "hvxv65") -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_rtt,"V32iV16iLLi","", "hvxv65") -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_rtt_128B,"V64iV32iLLi","", "hvxv65") -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_rtt_acc,"V32iV32iV16iLLi","", "hvxv65") -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_rtt_acc_128B,"V64iV64iV32iLLi","", "hvxv65") - -#include "clang/Basic/BuiltinsHexagonDep.def" - -#pragma pop_macro("HVXV60") -#pragma pop_macro("HVXV62") -#pragma pop_macro("HVXV65") -#pragma pop_macro("HVXV66") -#pragma pop_macro("HVXV67") -#pragma pop_macro("HVXV68") -#pragma pop_macro("HVXV69") -#pragma pop_macro("HVXV71") -#pragma pop_macro("HVXV73") -#pragma pop_macro("HVXV75") -#pragma pop_macro("HVXV79") - -#pragma pop_macro("V5") -#pragma pop_macro("V55") -#pragma pop_macro("V60") -#pragma pop_macro("V62") -#pragma pop_macro("V65") -#pragma pop_macro("V66") -#pragma pop_macro("V67") -#pragma pop_macro("V68") -#pragma pop_macro("V69") -#pragma pop_macro("V71") -#pragma pop_macro("V73") -#pragma pop_macro("V75") -#pragma pop_macro("V79") - -#undef BUILTIN -#undef TARGET_BUILTIN - diff --git clang/include/clang/Basic/BuiltinsHexagon.td clang/include/clang/Basic/BuiltinsHexagon.td new file mode 100644 index 000000000000..95b9012bf74f --- /dev/null +++ clang/include/clang/Basic/BuiltinsHexagon.td @@ -0,0 +1,2143 @@ +//===--- BuiltinsHexagon.td - Hexagon Builtin function defs -----*- 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 the Hexagon-specific builtin function database. +// +//===----------------------------------------------------------------------===// + +include "clang/Basic/BuiltinsBase.td" + +class VFeatures { + string Features; +} + +class V<string version, VFeatures newer> : VFeatures { + let Features = !strconcat("v", version, "|", newer.Features); +} + +let Features = "v79" in def V79 : VFeatures; + +def V75 : V<"75", V79>; +def V73 : V<"73", V75>; +def V71 : V<"71", V73>; +def V69 : V<"69", V71>; +def V68 : V<"68", V69>; +def V67 : V<"67", V68>; +def V66 : V<"66", V67>; +def V65 : V<"65", V66>; +def V62 : V<"62", V65>; +def V60 : V<"60", V62>; +def V55 : V<"55", V60>; +def V5 : V<"5", V55>; + +class HVXVFeatures { + string Features; +} + +class HVXV<string version, HVXVFeatures newer> : HVXVFeatures { + let Features = !strconcat("hvxv", version, "|", newer.Features); +} + +let Features = "hvxv79" in def HVXV79 : HVXVFeatures; + +def HVXV75 : HVXV<"75", HVXV79>; +def HVXV73 : HVXV<"73", HVXV75>; +def HVXV71 : HVXV<"71", HVXV73>; +def HVXV69 : HVXV<"69", HVXV71>; +def HVXV68 : HVXV<"68", HVXV69>; +def HVXV67 : HVXV<"67", HVXV68>; +def HVXV66 : HVXV<"66", HVXV67>; +def HVXV65 : HVXV<"65", HVXV66>; +def HVXV62 : HVXV<"62", HVXV65>; +def HVXV60 : HVXV<"60", HVXV62>; + +class HexagonBuiltin<string prototype> : TargetBuiltin { + let Spellings = ["__builtin_HEXAGON_" # NAME]; + let Prototype = prototype; + let Features = V5.Features; +} + +class HexagonBuiltinNoPrefix<string prototype> : TargetBuiltin { + let Spellings = [NAME]; + let Prototype = prototype; + let Features = V5.Features; +} + +// The builtins below are not autogenerated from iset.py. +// Make sure you do not overwrite these. +def __builtin_SI_to_SXTHI_asrh : HexagonBuiltinNoPrefix<"int(int)">; +def __builtin_brev_ldd : HexagonBuiltinNoPrefix<"void *(long long int * const, long long int *, int const)">; +def __builtin_brev_ldw : HexagonBuiltinNoPrefix<"void *(int * const, int *, int const)">; +def __builtin_brev_ldh : HexagonBuiltinNoPrefix<"void *(short * const, short *, int const)">; +def __builtin_brev_lduh : HexagonBuiltinNoPrefix<"void *(unsigned short * const, unsigned short *, int const)">; +def __builtin_brev_ldb : HexagonBuiltinNoPrefix<"void *(signed char * const, signed char *, int const)">; +def __builtin_brev_ldub : HexagonBuiltinNoPrefix<"void *(unsigned char * const, unsigned char *, int const)">; +def __builtin_circ_ldd : HexagonBuiltinNoPrefix<"long long int *(long long int *, long long int *, int, _Constant int)">; +def __builtin_circ_ldw : HexagonBuiltinNoPrefix<"int *(int *, int *, int, _Constant int)">; +def __builtin_circ_ldh : HexagonBuiltinNoPrefix<"short *(short *, short *, int, _Constant int)">; +def __builtin_circ_lduh : HexagonBuiltinNoPrefix<"unsigned short *(unsigned short *, unsigned short *, int, _Constant int)">; +def __builtin_circ_ldb : HexagonBuiltinNoPrefix<"char *(char *, char *, int, _Constant int)">; +def __builtin_circ_ldub : HexagonBuiltinNoPrefix<"unsigned char *(unsigned char *, unsigned char *, int, _Constant int)">; +def __builtin_brev_std : HexagonBuiltinNoPrefix<"long long int * const(long long int *, long long int, int const)">; +def __builtin_brev_stw : HexagonBuiltinNoPrefix<"int * const(int *, int, int const)">; +def __builtin_brev_sth : HexagonBuiltinNoPrefix<"short * const(short *, int, int const)">; +def __builtin_brev_sthhi : HexagonBuiltinNoPrefix<"short * const(short *, int, int const)">; +def __builtin_brev_stb : HexagonBuiltinNoPrefix<"char * const(char *, int, int const)">; +def __builtin_circ_std : HexagonBuiltinNoPrefix<"long long int *(long long int *, long long int, int, _Constant int)">; +def __builtin_circ_stw : HexagonBuiltinNoPrefix<"int *(int *, int, int, _Constant int)">; +def __builtin_circ_sth : HexagonBuiltinNoPrefix<"short *(short *, int, int, _Constant int)">; +def __builtin_circ_sthhi : HexagonBuiltinNoPrefix<"short *(short *, int, int, _Constant int)">; +def __builtin_circ_stb : HexagonBuiltinNoPrefix<"char *(char *, int, int, _Constant int)">; +def L2_loadrub_pci : HexagonBuiltin<"int(void *, _Constant int, int, void const *)">; +def L2_loadrb_pci : HexagonBuiltin<"int(void *, _Constant int, int, void const *)">; +def L2_loadruh_pci : HexagonBuiltin<"int(void *, _Constant int, int, void const *)">; +def L2_loadrh_pci : HexagonBuiltin<"int(void *, _Constant int, int, void const *)">; +def L2_loadri_pci : HexagonBuiltin<"int(void *, _Constant int, int, void const *)">; +def L2_loadrd_pci : HexagonBuiltin<"long long int(void *, _Constant int, int, void const *)">; +def L2_loadrub_pcr : HexagonBuiltin<"int(void *, int, void const *)">; +def L2_loadrb_pcr : HexagonBuiltin<"int(void *, int, void const *)">; +def L2_loadruh_pcr : HexagonBuiltin<"int(void *, int, void const *)">; +def L2_loadrh_pcr : HexagonBuiltin<"int(void *, int, void const *)">; +def L2_loadri_pcr : HexagonBuiltin<"int(void *, int, void const *)">; +def L2_loadrd_pcr : HexagonBuiltin<"long long int(void *, int, void const *)">; + +def S2_storerb_pci : HexagonBuiltin<"void(void *, _Constant int, int, int, void const *)">; +def S2_storerh_pci : HexagonBuiltin<"void(void *, _Constant int, int, int, void const *)">; +def S2_storerf_pci : HexagonBuiltin<"void(void *, _Constant int, int, int, void const *)">; +def S2_storeri_pci : HexagonBuiltin<"void(void *, _Constant int, int, int, void const *)">; +def S2_storerd_pci : HexagonBuiltin<"void(void *, _Constant int, int, long long int, void const *)">; +def S2_storerb_pcr : HexagonBuiltin<"void(void *, int, int, void const *)">; +def S2_storerh_pcr : HexagonBuiltin<"void(void *, int, int, void const *)">; +def S2_storerf_pcr : HexagonBuiltin<"void(void *, int, int, void const *)">; +def S2_storeri_pcr : HexagonBuiltin<"void(void *, int, int, void const *)">; +def S2_storerd_pcr : HexagonBuiltin<"void(void *, int, long long int, void const *)">; + +def prefetch : HexagonBuiltin<"void(void *)">; +let Features = V62.Features in { + def A6_vminub_RdP : HexagonBuiltin<"long long int(long long int, long long int)">; +} + +let Features = HVXV60.Features in { + def V6_vmaskedstoreq : HexagonBuiltin<"void(_Vector<64, bool>, void *, _Vector<16, int>)">; + def V6_vmaskedstorenq : HexagonBuiltin<"void(_Vector<64, bool>, void *, _Vector<16, int>)">; + def V6_vmaskedstorentq : HexagonBuiltin<"void(_Vector<64, bool>, void *, _Vector<16, int>)">; + def V6_vmaskedstorentnq : HexagonBuiltin<"void(_Vector<64, bool>, void *, _Vector<16, int>)">; + def V6_vmaskedstoreq_128B : HexagonBuiltin<"void(_Vector<128, bool>, void *, _Vector<32, int>)">; + def V6_vmaskedstorenq_128B : HexagonBuiltin<"void(_Vector<128, bool>, void *, _Vector<32, int>)">; + def V6_vmaskedstorentq_128B : HexagonBuiltin<"void(_Vector<128, bool>, void *, _Vector<32, int>)">; + def V6_vmaskedstorentnq_128B : HexagonBuiltin<"void(_Vector<128, bool>, void *, _Vector<32, int>)">; +} + + +// These are only valid on v65 +let Features = "hvxv65" in { + def V6_vrmpybub_rtt : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, long long int)">; + def V6_vrmpybub_rtt_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, long long int)">; + def V6_vrmpybub_rtt_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, long long int)">; + def V6_vrmpybub_rtt_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, long long int)">; + def V6_vrmpyub_rtt : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, long long int)">; + def V6_vrmpyub_rtt_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, long long int)">; + def V6_vrmpyub_rtt_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, long long int)">; + def V6_vrmpyub_rtt_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, long long int)">; +} + +// V5 Scalar Instructions. + +def A2_abs : HexagonBuiltin<"int(int)">; +def A2_absp : HexagonBuiltin<"long long int(long long int)">; +def A2_abssat : HexagonBuiltin<"int(int)">; +def A2_add : HexagonBuiltin<"int(int, int)">; +def A2_addh_h16_hh : HexagonBuiltin<"int(int, int)">; +def A2_addh_h16_hl : HexagonBuiltin<"int(int, int)">; +def A2_addh_h16_lh : HexagonBuiltin<"int(int, int)">; +def A2_addh_h16_ll : HexagonBuiltin<"int(int, int)">; +def A2_addh_h16_sat_hh : HexagonBuiltin<"int(int, int)">; +def A2_addh_h16_sat_hl : HexagonBuiltin<"int(int, int)">; +def A2_addh_h16_sat_lh : HexagonBuiltin<"int(int, int)">; +def A2_addh_h16_sat_ll : HexagonBuiltin<"int(int, int)">; +def A2_addh_l16_hl : HexagonBuiltin<"int(int, int)">; +def A2_addh_l16_ll : HexagonBuiltin<"int(int, int)">; +def A2_addh_l16_sat_hl : HexagonBuiltin<"int(int, int)">; +def A2_addh_l16_sat_ll : HexagonBuiltin<"int(int, int)">; +def A2_addi : HexagonBuiltin<"int(int, _Constant int)">; +def A2_addp : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_addpsat : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_addsat : HexagonBuiltin<"int(int, int)">; +def A2_addsp : HexagonBuiltin<"long long int(int, long long int)">; +def A2_and : HexagonBuiltin<"int(int, int)">; +def A2_andir : HexagonBuiltin<"int(int, _Constant int)">; +def A2_andp : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_aslh : HexagonBuiltin<"int(int)">; +def A2_asrh : HexagonBuiltin<"int(int)">; +def A2_combine_hh : HexagonBuiltin<"int(int, int)">; +def A2_combine_hl : HexagonBuiltin<"int(int, int)">; +def A2_combine_lh : HexagonBuiltin<"int(int, int)">; +def A2_combine_ll : HexagonBuiltin<"int(int, int)">; +def A2_combineii : HexagonBuiltin<"long long int(_Constant int, _Constant int)">; +def A2_combinew : HexagonBuiltin<"long long int(int, int)">; +def A2_max : HexagonBuiltin<"int(int, int)">; +def A2_maxp : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_maxu : HexagonBuiltin<"unsigned int(int, int)">; +def A2_maxup : HexagonBuiltin<"unsigned long long int(long long int, long long int)">; +def A2_min : HexagonBuiltin<"int(int, int)">; +def A2_minp : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_minu : HexagonBuiltin<"unsigned int(int, int)">; +def A2_minup : HexagonBuiltin<"unsigned long long int(long long int, long long int)">; +def A2_neg : HexagonBuiltin<"int(int)">; +def A2_negp : HexagonBuiltin<"long long int(long long int)">; +def A2_negsat : HexagonBuiltin<"int(int)">; +def A2_not : HexagonBuiltin<"int(int)">; +def A2_notp : HexagonBuiltin<"long long int(long long int)">; +def A2_or : HexagonBuiltin<"int(int, int)">; +def A2_orir : HexagonBuiltin<"int(int, _Constant int)">; +def A2_orp : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_roundsat : HexagonBuiltin<"int(long long int)">; +def A2_sat : HexagonBuiltin<"int(long long int)">; +def A2_satb : HexagonBuiltin<"int(int)">; +def A2_sath : HexagonBuiltin<"int(int)">; +def A2_satub : HexagonBuiltin<"int(int)">; +def A2_satuh : HexagonBuiltin<"int(int)">; +def A2_sub : HexagonBuiltin<"int(int, int)">; +def A2_subh_h16_hh : HexagonBuiltin<"int(int, int)">; +def A2_subh_h16_hl : HexagonBuiltin<"int(int, int)">; +def A2_subh_h16_lh : HexagonBuiltin<"int(int, int)">; +def A2_subh_h16_ll : HexagonBuiltin<"int(int, int)">; +def A2_subh_h16_sat_hh : HexagonBuiltin<"int(int, int)">; +def A2_subh_h16_sat_hl : HexagonBuiltin<"int(int, int)">; +def A2_subh_h16_sat_lh : HexagonBuiltin<"int(int, int)">; +def A2_subh_h16_sat_ll : HexagonBuiltin<"int(int, int)">; +def A2_subh_l16_hl : HexagonBuiltin<"int(int, int)">; +def A2_subh_l16_ll : HexagonBuiltin<"int(int, int)">; +def A2_subh_l16_sat_hl : HexagonBuiltin<"int(int, int)">; +def A2_subh_l16_sat_ll : HexagonBuiltin<"int(int, int)">; +def A2_subp : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_subri : HexagonBuiltin<"int(_Constant int, int)">; +def A2_subsat : HexagonBuiltin<"int(int, int)">; +def A2_svaddh : HexagonBuiltin<"int(int, int)">; +def A2_svaddhs : HexagonBuiltin<"int(int, int)">; +def A2_svadduhs : HexagonBuiltin<"int(int, int)">; +def A2_svavgh : HexagonBuiltin<"int(int, int)">; +def A2_svavghs : HexagonBuiltin<"int(int, int)">; +def A2_svnavgh : HexagonBuiltin<"int(int, int)">; +def A2_svsubh : HexagonBuiltin<"int(int, int)">; +def A2_svsubhs : HexagonBuiltin<"int(int, int)">; +def A2_svsubuhs : HexagonBuiltin<"int(int, int)">; +def A2_swiz : HexagonBuiltin<"int(int)">; +def A2_sxtb : HexagonBuiltin<"int(int)">; +def A2_sxth : HexagonBuiltin<"int(int)">; +def A2_sxtw : HexagonBuiltin<"long long int(int)">; +def A2_tfr : HexagonBuiltin<"int(int)">; +def A2_tfrih : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def A2_tfril : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def A2_tfrp : HexagonBuiltin<"long long int(long long int)">; +def A2_tfrpi : HexagonBuiltin<"long long int(_Constant int)">; +def A2_tfrsi : HexagonBuiltin<"int(_Constant int)">; +def A2_vabsh : HexagonBuiltin<"long long int(long long int)">; +def A2_vabshsat : HexagonBuiltin<"long long int(long long int)">; +def A2_vabsw : HexagonBuiltin<"long long int(long long int)">; +def A2_vabswsat : HexagonBuiltin<"long long int(long long int)">; +def A2_vaddb_map : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vaddh : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vaddhs : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vaddub : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vaddubs : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vadduhs : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vaddw : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vaddws : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vavgh : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vavghcr : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vavghr : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vavgub : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vavgubr : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vavguh : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vavguhr : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vavguw : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vavguwr : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vavgw : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vavgwcr : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vavgwr : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vcmpbeq : HexagonBuiltin<"int(long long int, long long int)">; +def A2_vcmpbgtu : HexagonBuiltin<"int(long long int, long long int)">; +def A2_vcmpheq : HexagonBuiltin<"int(long long int, long long int)">; +def A2_vcmphgt : HexagonBuiltin<"int(long long int, long long int)">; +def A2_vcmphgtu : HexagonBuiltin<"int(long long int, long long int)">; +def A2_vcmpweq : HexagonBuiltin<"int(long long int, long long int)">; +def A2_vcmpwgt : HexagonBuiltin<"int(long long int, long long int)">; +def A2_vcmpwgtu : HexagonBuiltin<"int(long long int, long long int)">; +def A2_vconj : HexagonBuiltin<"long long int(long long int)">; +def A2_vmaxb : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vmaxh : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vmaxub : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vmaxuh : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vmaxuw : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vmaxw : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vminb : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vminh : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vminub : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vminuh : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vminuw : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vminw : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vnavgh : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vnavghcr : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vnavghr : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vnavgw : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vnavgwcr : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vnavgwr : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vraddub : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vraddub_acc : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def A2_vrsadub : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vrsadub_acc : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def A2_vsubb_map : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vsubh : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vsubhs : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vsubub : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vsububs : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vsubuhs : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vsubw : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_vsubws : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_xor : HexagonBuiltin<"int(int, int)">; +def A2_xorp : HexagonBuiltin<"long long int(long long int, long long int)">; +def A2_zxtb : HexagonBuiltin<"int(int)">; +def A2_zxth : HexagonBuiltin<"int(int)">; +def A4_andn : HexagonBuiltin<"int(int, int)">; +def A4_andnp : HexagonBuiltin<"long long int(long long int, long long int)">; +def A4_bitsplit : HexagonBuiltin<"long long int(int, int)">; +def A4_bitspliti : HexagonBuiltin<"long long int(int, unsigned _Constant int)">; +def A4_boundscheck : HexagonBuiltin<"int(int, long long int)">; +def A4_cmpbeq : HexagonBuiltin<"int(int, int)">; +def A4_cmpbeqi : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def A4_cmpbgt : HexagonBuiltin<"int(int, int)">; +def A4_cmpbgti : HexagonBuiltin<"int(int, _Constant int)">; +def A4_cmpbgtu : HexagonBuiltin<"int(int, int)">; +def A4_cmpbgtui : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def A4_cmpheq : HexagonBuiltin<"int(int, int)">; +def A4_cmpheqi : HexagonBuiltin<"int(int, _Constant int)">; +def A4_cmphgt : HexagonBuiltin<"int(int, int)">; +def A4_cmphgti : HexagonBuiltin<"int(int, _Constant int)">; +def A4_cmphgtu : HexagonBuiltin<"int(int, int)">; +def A4_cmphgtui : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def A4_combineir : HexagonBuiltin<"long long int(_Constant int, int)">; +def A4_combineri : HexagonBuiltin<"long long int(int, _Constant int)">; +def A4_cround_ri : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def A4_cround_rr : HexagonBuiltin<"int(int, int)">; +def A4_modwrapu : HexagonBuiltin<"int(int, int)">; +def A4_orn : HexagonBuiltin<"int(int, int)">; +def A4_ornp : HexagonBuiltin<"long long int(long long int, long long int)">; +def A4_rcmpeq : HexagonBuiltin<"int(int, int)">; +def A4_rcmpeqi : HexagonBuiltin<"int(int, _Constant int)">; +def A4_rcmpneq : HexagonBuiltin<"int(int, int)">; +def A4_rcmpneqi : HexagonBuiltin<"int(int, _Constant int)">; +def A4_round_ri : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def A4_round_ri_sat : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def A4_round_rr : HexagonBuiltin<"int(int, int)">; +def A4_round_rr_sat : HexagonBuiltin<"int(int, int)">; +def A4_tlbmatch : HexagonBuiltin<"int(long long int, int)">; +def A4_vcmpbeq_any : HexagonBuiltin<"int(long long int, long long int)">; +def A4_vcmpbeqi : HexagonBuiltin<"int(long long int, unsigned _Constant int)">; +def A4_vcmpbgt : HexagonBuiltin<"int(long long int, long long int)">; +def A4_vcmpbgti : HexagonBuiltin<"int(long long int, _Constant int)">; +def A4_vcmpbgtui : HexagonBuiltin<"int(long long int, unsigned _Constant int)">; +def A4_vcmpheqi : HexagonBuiltin<"int(long long int, _Constant int)">; +def A4_vcmphgti : HexagonBuiltin<"int(long long int, _Constant int)">; +def A4_vcmphgtui : HexagonBuiltin<"int(long long int, unsigned _Constant int)">; +def A4_vcmpweqi : HexagonBuiltin<"int(long long int, _Constant int)">; +def A4_vcmpwgti : HexagonBuiltin<"int(long long int, _Constant int)">; +def A4_vcmpwgtui : HexagonBuiltin<"int(long long int, unsigned _Constant int)">; +def A4_vrmaxh : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def A4_vrmaxuh : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def A4_vrmaxuw : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def A4_vrmaxw : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def A4_vrminh : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def A4_vrminuh : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def A4_vrminuw : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def A4_vrminw : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def A5_vaddhubs : HexagonBuiltin<"int(long long int, long long int)">; +def C2_all8 : HexagonBuiltin<"int(int)">; +def C2_and : HexagonBuiltin<"int(int, int)">; +def C2_andn : HexagonBuiltin<"int(int, int)">; +def C2_any8 : HexagonBuiltin<"int(int)">; +def C2_bitsclr : HexagonBuiltin<"int(int, int)">; +def C2_bitsclri : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def C2_bitsset : HexagonBuiltin<"int(int, int)">; +def C2_cmpeq : HexagonBuiltin<"int(int, int)">; +def C2_cmpeqi : HexagonBuiltin<"int(int, _Constant int)">; +def C2_cmpeqp : HexagonBuiltin<"int(long long int, long long int)">; +def C2_cmpgei : HexagonBuiltin<"int(int, _Constant int)">; +def C2_cmpgeui : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def C2_cmpgt : HexagonBuiltin<"int(int, int)">; +def C2_cmpgti : HexagonBuiltin<"int(int, _Constant int)">; +def C2_cmpgtp : HexagonBuiltin<"int(long long int, long long int)">; +def C2_cmpgtu : HexagonBuiltin<"int(int, int)">; +def C2_cmpgtui : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def C2_cmpgtup : HexagonBuiltin<"int(long long int, long long int)">; +def C2_cmplt : HexagonBuiltin<"int(int, int)">; +def C2_cmpltu : HexagonBuiltin<"int(int, int)">; +def C2_mask : HexagonBuiltin<"long long int(int)">; +def C2_mux : HexagonBuiltin<"int(int, int, int)">; +def C2_muxii : HexagonBuiltin<"int(int, _Constant int, _Constant int)">; +def C2_muxir : HexagonBuiltin<"int(int, int, _Constant int)">; +def C2_muxri : HexagonBuiltin<"int(int, _Constant int, int)">; +def C2_not : HexagonBuiltin<"int(int)">; +def C2_or : HexagonBuiltin<"int(int, int)">; +def C2_orn : HexagonBuiltin<"int(int, int)">; +def C2_pxfer_map : HexagonBuiltin<"int(int)">; +def C2_tfrpr : HexagonBuiltin<"int(int)">; +def C2_tfrrp : HexagonBuiltin<"int(int)">; +def C2_vitpack : HexagonBuiltin<"int(int, int)">; +def C2_vmux : HexagonBuiltin<"long long int(int, long long int, long long int)">; +def C2_xor : HexagonBuiltin<"int(int, int)">; +def C4_and_and : HexagonBuiltin<"int(int, int, int)">; +def C4_and_andn : HexagonBuiltin<"int(int, int, int)">; +def C4_and_or : HexagonBuiltin<"int(int, int, int)">; +def C4_and_orn : HexagonBuiltin<"int(int, int, int)">; +def C4_cmplte : HexagonBuiltin<"int(int, int)">; +def C4_cmpltei : HexagonBuiltin<"int(int, _Constant int)">; +def C4_cmplteu : HexagonBuiltin<"int(int, int)">; +def C4_cmplteui : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def C4_cmpneq : HexagonBuiltin<"int(int, int)">; +def C4_cmpneqi : HexagonBuiltin<"int(int, _Constant int)">; +def C4_fastcorner9 : HexagonBuiltin<"int(int, int)">; +def C4_fastcorner9_not : HexagonBuiltin<"int(int, int)">; +def C4_nbitsclr : HexagonBuiltin<"int(int, int)">; +def C4_nbitsclri : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def C4_nbitsset : HexagonBuiltin<"int(int, int)">; +def C4_or_and : HexagonBuiltin<"int(int, int, int)">; +def C4_or_andn : HexagonBuiltin<"int(int, int, int)">; +def C4_or_or : HexagonBuiltin<"int(int, int, int)">; +def C4_or_orn : HexagonBuiltin<"int(int, int, int)">; +def F2_conv_d2df : HexagonBuiltin<"double(long long int)">; +def F2_conv_d2sf : HexagonBuiltin<"float(long long int)">; +def F2_conv_df2d : HexagonBuiltin<"long long int(double)">; +def F2_conv_df2d_chop : HexagonBuiltin<"long long int(double)">; +def F2_conv_df2sf : HexagonBuiltin<"float(double)">; +def F2_conv_df2ud : HexagonBuiltin<"long long int(double)">; +def F2_conv_df2ud_chop : HexagonBuiltin<"long long int(double)">; +def F2_conv_df2uw : HexagonBuiltin<"int(double)">; +def F2_conv_df2uw_chop : HexagonBuiltin<"int(double)">; +def F2_conv_df2w : HexagonBuiltin<"int(double)">; +def F2_conv_df2w_chop : HexagonBuiltin<"int(double)">; +def F2_conv_sf2d : HexagonBuiltin<"long long int(float)">; +def F2_conv_sf2d_chop : HexagonBuiltin<"long long int(float)">; +def F2_conv_sf2df : HexagonBuiltin<"double(float)">; +def F2_conv_sf2ud : HexagonBuiltin<"long long int(float)">; +def F2_conv_sf2ud_chop : HexagonBuiltin<"long long int(float)">; +def F2_conv_sf2uw : HexagonBuiltin<"int(float)">; +def F2_conv_sf2uw_chop : HexagonBuiltin<"int(float)">; +def F2_conv_sf2w : HexagonBuiltin<"int(float)">; +def F2_conv_sf2w_chop : HexagonBuiltin<"int(float)">; +def F2_conv_ud2df : HexagonBuiltin<"double(long long int)">; +def F2_conv_ud2sf : HexagonBuiltin<"float(long long int)">; +def F2_conv_uw2df : HexagonBuiltin<"double(int)">; +def F2_conv_uw2sf : HexagonBuiltin<"float(int)">; +def F2_conv_w2df : HexagonBuiltin<"double(int)">; +def F2_conv_w2sf : HexagonBuiltin<"float(int)">; +def F2_dfclass : HexagonBuiltin<"int(double, unsigned _Constant int)">; +def F2_dfcmpeq : HexagonBuiltin<"int(double, double)">; +def F2_dfcmpge : HexagonBuiltin<"int(double, double)">; +def F2_dfcmpgt : HexagonBuiltin<"int(double, double)">; +def F2_dfcmpuo : HexagonBuiltin<"int(double, double)">; +def F2_dfimm_n : HexagonBuiltin<"double(unsigned _Constant int)">; +def F2_dfimm_p : HexagonBuiltin<"double(unsigned _Constant int)">; +def F2_sfadd : HexagonBuiltin<"float(float, float)">; +def F2_sfclass : HexagonBuiltin<"int(float, unsigned _Constant int)">; +def F2_sfcmpeq : HexagonBuiltin<"int(float, float)">; +def F2_sfcmpge : HexagonBuiltin<"int(float, float)">; +def F2_sfcmpgt : HexagonBuiltin<"int(float, float)">; +def F2_sfcmpuo : HexagonBuiltin<"int(float, float)">; +def F2_sffixupd : HexagonBuiltin<"float(float, float)">; +def F2_sffixupn : HexagonBuiltin<"float(float, float)">; +def F2_sffixupr : HexagonBuiltin<"float(float)">; +def F2_sffma : HexagonBuiltin<"float(float, float, float)">; +def F2_sffma_lib : HexagonBuiltin<"float(float, float, float)">; +def F2_sffma_sc : HexagonBuiltin<"float(float, float, float, int)">; +def F2_sffms : HexagonBuiltin<"float(float, float, float)">; +def F2_sffms_lib : HexagonBuiltin<"float(float, float, float)">; +def F2_sfimm_n : HexagonBuiltin<"float(unsigned _Constant int)">; +def F2_sfimm_p : HexagonBuiltin<"float(unsigned _Constant int)">; +def F2_sfmax : HexagonBuiltin<"float(float, float)">; +def F2_sfmin : HexagonBuiltin<"float(float, float)">; +def F2_sfmpy : HexagonBuiltin<"float(float, float)">; +def F2_sfsub : HexagonBuiltin<"float(float, float)">; +def M2_acci : HexagonBuiltin<"int(int, int, int)">; +def M2_accii : HexagonBuiltin<"int(int, int, _Constant int)">; +def M2_cmaci_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_cmacr_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_cmacs_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_cmacs_s1 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_cmacsc_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_cmacsc_s1 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_cmpyi_s0 : HexagonBuiltin<"long long int(int, int)">; +def M2_cmpyr_s0 : HexagonBuiltin<"long long int(int, int)">; +def M2_cmpyrs_s0 : HexagonBuiltin<"int(int, int)">; +def M2_cmpyrs_s1 : HexagonBuiltin<"int(int, int)">; +def M2_cmpyrsc_s0 : HexagonBuiltin<"int(int, int)">; +def M2_cmpyrsc_s1 : HexagonBuiltin<"int(int, int)">; +def M2_cmpys_s0 : HexagonBuiltin<"long long int(int, int)">; +def M2_cmpys_s1 : HexagonBuiltin<"long long int(int, int)">; +def M2_cmpysc_s0 : HexagonBuiltin<"long long int(int, int)">; +def M2_cmpysc_s1 : HexagonBuiltin<"long long int(int, int)">; +def M2_cnacs_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_cnacs_s1 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_cnacsc_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_cnacsc_s1 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_dpmpyss_acc_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_dpmpyss_nac_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_dpmpyss_rnd_s0 : HexagonBuiltin<"int(int, int)">; +def M2_dpmpyss_s0 : HexagonBuiltin<"long long int(int, int)">; +def M2_dpmpyuu_acc_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_dpmpyuu_nac_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_dpmpyuu_s0 : HexagonBuiltin<"unsigned long long int(int, int)">; +def M2_hmmpyh_rs1 : HexagonBuiltin<"int(int, int)">; +def M2_hmmpyh_s1 : HexagonBuiltin<"int(int, int)">; +def M2_hmmpyl_rs1 : HexagonBuiltin<"int(int, int)">; +def M2_hmmpyl_s1 : HexagonBuiltin<"int(int, int)">; +def M2_maci : HexagonBuiltin<"int(int, int, int)">; +def M2_macsin : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; +def M2_macsip : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; +def M2_mmachs_rs0 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_mmachs_rs1 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_mmachs_s0 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_mmachs_s1 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_mmacls_rs0 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_mmacls_rs1 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_mmacls_s0 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_mmacls_s1 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_mmacuhs_rs0 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_mmacuhs_rs1 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_mmacuhs_s0 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_mmacuhs_s1 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_mmaculs_rs0 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_mmaculs_rs1 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_mmaculs_s0 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_mmaculs_s1 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_mmpyh_rs0 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_mmpyh_rs1 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_mmpyh_s0 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_mmpyh_s1 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_mmpyl_rs0 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_mmpyl_rs1 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_mmpyl_s0 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_mmpyl_s1 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_mmpyuh_rs0 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_mmpyuh_rs1 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_mmpyuh_s0 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_mmpyuh_s1 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_mmpyul_rs0 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_mmpyul_rs1 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_mmpyul_s0 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_mmpyul_s1 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_mpy_acc_hh_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_acc_hh_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_acc_hl_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_acc_hl_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_acc_lh_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_acc_lh_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_acc_ll_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_acc_ll_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_acc_sat_hh_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_acc_sat_hh_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_acc_sat_hl_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_acc_sat_hl_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_acc_sat_lh_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_acc_sat_lh_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_acc_sat_ll_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_acc_sat_ll_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_hh_s0 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_hh_s1 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_hl_s0 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_hl_s1 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_lh_s0 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_lh_s1 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_ll_s0 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_ll_s1 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_nac_hh_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_nac_hh_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_nac_hl_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_nac_hl_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_nac_lh_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_nac_lh_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_nac_ll_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_nac_ll_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_nac_sat_hh_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_nac_sat_hh_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_nac_sat_hl_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_nac_sat_hl_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_nac_sat_lh_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_nac_sat_lh_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_nac_sat_ll_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_nac_sat_ll_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpy_rnd_hh_s0 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_rnd_hh_s1 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_rnd_hl_s0 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_rnd_hl_s1 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_rnd_lh_s0 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_rnd_lh_s1 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_rnd_ll_s0 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_rnd_ll_s1 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_sat_hh_s0 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_sat_hh_s1 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_sat_hl_s0 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_sat_hl_s1 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_sat_lh_s0 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_sat_lh_s1 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_sat_ll_s0 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_sat_ll_s1 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_sat_rnd_hh_s0 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_sat_rnd_hh_s1 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_sat_rnd_hl_s0 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_sat_rnd_hl_s1 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_sat_rnd_lh_s0 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_sat_rnd_lh_s1 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_sat_rnd_ll_s0 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_sat_rnd_ll_s1 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_up : HexagonBuiltin<"int(int, int)">; +def M2_mpy_up_s1 : HexagonBuiltin<"int(int, int)">; +def M2_mpy_up_s1_sat : HexagonBuiltin<"int(int, int)">; +def M2_mpyd_acc_hh_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyd_acc_hh_s1 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyd_acc_hl_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyd_acc_hl_s1 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyd_acc_lh_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyd_acc_lh_s1 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyd_acc_ll_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyd_acc_ll_s1 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyd_hh_s0 : HexagonBuiltin<"long long int(int, int)">; +def M2_mpyd_hh_s1 : HexagonBuiltin<"long long int(int, int)">; +def M2_mpyd_hl_s0 : HexagonBuiltin<"long long int(int, int)">; +def M2_mpyd_hl_s1 : HexagonBuiltin<"long long int(int, int)">; +def M2_mpyd_lh_s0 : HexagonBuiltin<"long long int(int, int)">; +def M2_mpyd_lh_s1 : HexagonBuiltin<"long long int(int, int)">; +def M2_mpyd_ll_s0 : HexagonBuiltin<"long long int(int, int)">; +def M2_mpyd_ll_s1 : HexagonBuiltin<"long long int(int, int)">; +def M2_mpyd_nac_hh_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyd_nac_hh_s1 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyd_nac_hl_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyd_nac_hl_s1 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyd_nac_lh_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyd_nac_lh_s1 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyd_nac_ll_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyd_nac_ll_s1 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyd_rnd_hh_s0 : HexagonBuiltin<"long long int(int, int)">; +def M2_mpyd_rnd_hh_s1 : HexagonBuiltin<"long long int(int, int)">; +def M2_mpyd_rnd_hl_s0 : HexagonBuiltin<"long long int(int, int)">; +def M2_mpyd_rnd_hl_s1 : HexagonBuiltin<"long long int(int, int)">; +def M2_mpyd_rnd_lh_s0 : HexagonBuiltin<"long long int(int, int)">; +def M2_mpyd_rnd_lh_s1 : HexagonBuiltin<"long long int(int, int)">; +def M2_mpyd_rnd_ll_s0 : HexagonBuiltin<"long long int(int, int)">; +def M2_mpyd_rnd_ll_s1 : HexagonBuiltin<"long long int(int, int)">; +def M2_mpyi : HexagonBuiltin<"int(int, int)">; +def M2_mpysmi : HexagonBuiltin<"int(int, _Constant int)">; +def M2_mpysu_up : HexagonBuiltin<"int(int, int)">; +def M2_mpyu_acc_hh_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpyu_acc_hh_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpyu_acc_hl_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpyu_acc_hl_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpyu_acc_lh_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpyu_acc_lh_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpyu_acc_ll_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpyu_acc_ll_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpyu_hh_s0 : HexagonBuiltin<"unsigned int(int, int)">; +def M2_mpyu_hh_s1 : HexagonBuiltin<"unsigned int(int, int)">; +def M2_mpyu_hl_s0 : HexagonBuiltin<"unsigned int(int, int)">; +def M2_mpyu_hl_s1 : HexagonBuiltin<"unsigned int(int, int)">; +def M2_mpyu_lh_s0 : HexagonBuiltin<"unsigned int(int, int)">; +def M2_mpyu_lh_s1 : HexagonBuiltin<"unsigned int(int, int)">; +def M2_mpyu_ll_s0 : HexagonBuiltin<"unsigned int(int, int)">; +def M2_mpyu_ll_s1 : HexagonBuiltin<"unsigned int(int, int)">; +def M2_mpyu_nac_hh_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpyu_nac_hh_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpyu_nac_hl_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpyu_nac_hl_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpyu_nac_lh_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpyu_nac_lh_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpyu_nac_ll_s0 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpyu_nac_ll_s1 : HexagonBuiltin<"int(int, int, int)">; +def M2_mpyu_up : HexagonBuiltin<"unsigned int(int, int)">; +def M2_mpyud_acc_hh_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyud_acc_hh_s1 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyud_acc_hl_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyud_acc_hl_s1 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyud_acc_lh_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyud_acc_lh_s1 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyud_acc_ll_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyud_acc_ll_s1 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyud_hh_s0 : HexagonBuiltin<"unsigned long long int(int, int)">; +def M2_mpyud_hh_s1 : HexagonBuiltin<"unsigned long long int(int, int)">; +def M2_mpyud_hl_s0 : HexagonBuiltin<"unsigned long long int(int, int)">; +def M2_mpyud_hl_s1 : HexagonBuiltin<"unsigned long long int(int, int)">; +def M2_mpyud_lh_s0 : HexagonBuiltin<"unsigned long long int(int, int)">; +def M2_mpyud_lh_s1 : HexagonBuiltin<"unsigned long long int(int, int)">; +def M2_mpyud_ll_s0 : HexagonBuiltin<"unsigned long long int(int, int)">; +def M2_mpyud_ll_s1 : HexagonBuiltin<"unsigned long long int(int, int)">; +def M2_mpyud_nac_hh_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyud_nac_hh_s1 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyud_nac_hl_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyud_nac_hl_s1 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyud_nac_lh_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyud_nac_lh_s1 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyud_nac_ll_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyud_nac_ll_s1 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_mpyui : HexagonBuiltin<"int(int, int)">; +def M2_nacci : HexagonBuiltin<"int(int, int, int)">; +def M2_naccii : HexagonBuiltin<"int(int, int, _Constant int)">; +def M2_subacc : HexagonBuiltin<"int(int, int, int)">; +def M2_vabsdiffh : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_vabsdiffw : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_vcmac_s0_sat_i : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_vcmac_s0_sat_r : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_vcmpy_s0_sat_i : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_vcmpy_s0_sat_r : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_vcmpy_s1_sat_i : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_vcmpy_s1_sat_r : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_vdmacs_s0 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_vdmacs_s1 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_vdmpyrs_s0 : HexagonBuiltin<"int(long long int, long long int)">; +def M2_vdmpyrs_s1 : HexagonBuiltin<"int(long long int, long long int)">; +def M2_vdmpys_s0 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_vdmpys_s1 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_vmac2 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_vmac2es : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_vmac2es_s0 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_vmac2es_s1 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_vmac2s_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_vmac2s_s1 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_vmac2su_s0 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_vmac2su_s1 : HexagonBuiltin<"long long int(long long int, int, int)">; +def M2_vmpy2es_s0 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_vmpy2es_s1 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_vmpy2s_s0 : HexagonBuiltin<"long long int(int, int)">; +def M2_vmpy2s_s0pack : HexagonBuiltin<"int(int, int)">; +def M2_vmpy2s_s1 : HexagonBuiltin<"long long int(int, int)">; +def M2_vmpy2s_s1pack : HexagonBuiltin<"int(int, int)">; +def M2_vmpy2su_s0 : HexagonBuiltin<"long long int(int, int)">; +def M2_vmpy2su_s1 : HexagonBuiltin<"long long int(int, int)">; +def M2_vraddh : HexagonBuiltin<"int(long long int, long long int)">; +def M2_vradduh : HexagonBuiltin<"int(long long int, long long int)">; +def M2_vrcmaci_s0 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_vrcmaci_s0c : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_vrcmacr_s0 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_vrcmacr_s0c : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_vrcmpyi_s0 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_vrcmpyi_s0c : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_vrcmpyr_s0 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_vrcmpyr_s0c : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_vrcmpys_acc_s1 : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def M2_vrcmpys_s1 : HexagonBuiltin<"long long int(long long int, int)">; +def M2_vrcmpys_s1rp : HexagonBuiltin<"int(long long int, int)">; +def M2_vrmac_s0 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M2_vrmpy_s0 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M2_xor_xacc : HexagonBuiltin<"int(int, int, int)">; +def M4_and_and : HexagonBuiltin<"int(int, int, int)">; +def M4_and_andn : HexagonBuiltin<"int(int, int, int)">; +def M4_and_or : HexagonBuiltin<"int(int, int, int)">; +def M4_and_xor : HexagonBuiltin<"int(int, int, int)">; +def M4_cmpyi_wh : HexagonBuiltin<"int(long long int, int)">; +def M4_cmpyi_whc : HexagonBuiltin<"int(long long int, int)">; +def M4_cmpyr_wh : HexagonBuiltin<"int(long long int, int)">; +def M4_cmpyr_whc : HexagonBuiltin<"int(long long int, int)">; +def M4_mac_up_s1_sat : HexagonBuiltin<"int(int, int, int)">; +def M4_mpyri_addi : HexagonBuiltin<"int(unsigned _Constant int, int, unsigned _Constant int)">; +def M4_mpyri_addr : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; +def M4_mpyri_addr_u2 : HexagonBuiltin<"int(int, unsigned _Constant int, int)">; +def M4_mpyrr_addi : HexagonBuiltin<"int(unsigned _Constant int, int, int)">; +def M4_mpyrr_addr : HexagonBuiltin<"int(int, int, int)">; +def M4_nac_up_s1_sat : HexagonBuiltin<"int(int, int, int)">; +def M4_or_and : HexagonBuiltin<"int(int, int, int)">; +def M4_or_andn : HexagonBuiltin<"int(int, int, int)">; +def M4_or_or : HexagonBuiltin<"int(int, int, int)">; +def M4_or_xor : HexagonBuiltin<"int(int, int, int)">; +def M4_pmpyw : HexagonBuiltin<"long long int(int, int)">; +def M4_pmpyw_acc : HexagonBuiltin<"long long int(long long int, int, int)">; +def M4_vpmpyh : HexagonBuiltin<"long long int(int, int)">; +def M4_vpmpyh_acc : HexagonBuiltin<"long long int(long long int, int, int)">; +def M4_vrmpyeh_acc_s0 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M4_vrmpyeh_acc_s1 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M4_vrmpyeh_s0 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M4_vrmpyeh_s1 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M4_vrmpyoh_acc_s0 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M4_vrmpyoh_acc_s1 : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M4_vrmpyoh_s0 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M4_vrmpyoh_s1 : HexagonBuiltin<"long long int(long long int, long long int)">; +def M4_xor_and : HexagonBuiltin<"int(int, int, int)">; +def M4_xor_andn : HexagonBuiltin<"int(int, int, int)">; +def M4_xor_or : HexagonBuiltin<"int(int, int, int)">; +def M4_xor_xacc : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M5_vdmacbsu : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M5_vdmpybsu : HexagonBuiltin<"long long int(long long int, long long int)">; +def M5_vmacbsu : HexagonBuiltin<"long long int(long long int, int, int)">; +def M5_vmacbuu : HexagonBuiltin<"long long int(long long int, int, int)">; +def M5_vmpybsu : HexagonBuiltin<"long long int(int, int)">; +def M5_vmpybuu : HexagonBuiltin<"long long int(int, int)">; +def M5_vrmacbsu : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M5_vrmacbuu : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def M5_vrmpybsu : HexagonBuiltin<"long long int(long long int, long long int)">; +def M5_vrmpybuu : HexagonBuiltin<"long long int(long long int, long long int)">; +def S2_addasl_rrri : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; +def S2_asl_i_p : HexagonBuiltin<"long long int(long long int, unsigned _Constant int)">; +def S2_asl_i_p_acc : HexagonBuiltin<"long long int(long long int, long long int, unsigned _Constant int)">; +def S2_asl_i_p_and : HexagonBuiltin<"long long int(long long int, long long int, unsigned _Constant int)">; +def S2_asl_i_p_nac : HexagonBuiltin<"long long int(long long int, long long int, unsigned _Constant int)">; +def S2_asl_i_p_or : HexagonBuiltin<"long long int(long long int, long long int, unsigned _Constant int)">; +def S2_asl_i_p_xacc : HexagonBuiltin<"long long int(long long int, long long int, unsigned _Constant int)">; +def S2_asl_i_r : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def S2_asl_i_r_acc : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; +def S2_asl_i_r_and : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; +def S2_asl_i_r_nac : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; +def S2_asl_i_r_or : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; +def S2_asl_i_r_sat : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def S2_asl_i_r_xacc : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; +def S2_asl_i_vh : HexagonBuiltin<"long long int(long long int, unsigned _Constant int)">; +def S2_asl_i_vw : HexagonBuiltin<"long long int(long long int, unsigned _Constant int)">; +def S2_asl_r_p : HexagonBuiltin<"long long int(long long int, int)">; +def S2_asl_r_p_acc : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_asl_r_p_and : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_asl_r_p_nac : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_asl_r_p_or : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_asl_r_p_xor : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_asl_r_r : HexagonBuiltin<"int(int, int)">; +def S2_asl_r_r_acc : HexagonBuiltin<"int(int, int, int)">; +def S2_asl_r_r_and : HexagonBuiltin<"int(int, int, int)">; +def S2_asl_r_r_nac : HexagonBuiltin<"int(int, int, int)">; +def S2_asl_r_r_or : HexagonBuiltin<"int(int, int, int)">; +def S2_asl_r_r_sat : HexagonBuiltin<"int(int, int)">; +def S2_asl_r_vh : HexagonBuiltin<"long long int(long long int, int)">; +def S2_asl_r_vw : HexagonBuiltin<"long long int(long long int, int)">; +def S2_asr_i_p : HexagonBuiltin<"long long int(long long int, unsigned _Constant int)">; +def S2_asr_i_p_acc : HexagonBuiltin<"long long int(long long int, long long int, unsigned _Constant int)">; +def S2_asr_i_p_and : HexagonBuiltin<"long long int(long long int, long long int, unsigned _Constant int)">; +def S2_asr_i_p_nac : HexagonBuiltin<"long long int(long long int, long long int, unsigned _Constant int)">; +def S2_asr_i_p_or : HexagonBuiltin<"long long int(long long int, long long int, unsigned _Constant int)">; +def S2_asr_i_p_rnd : HexagonBuiltin<"long long int(long long int, unsigned _Constant int)">; +def S2_asr_i_p_rnd_goodsyntax : HexagonBuiltin<"long long int(long long int, unsigned _Constant int)">; +def S2_asr_i_r : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def S2_asr_i_r_acc : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; +def S2_asr_i_r_and : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; +def S2_asr_i_r_nac : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; +def S2_asr_i_r_or : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; +def S2_asr_i_r_rnd : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def S2_asr_i_r_rnd_goodsyntax : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def S2_asr_i_svw_trun : HexagonBuiltin<"int(long long int, unsigned _Constant int)">; +def S2_asr_i_vh : HexagonBuiltin<"long long int(long long int, unsigned _Constant int)">; +def S2_asr_i_vw : HexagonBuiltin<"long long int(long long int, unsigned _Constant int)">; +def S2_asr_r_p : HexagonBuiltin<"long long int(long long int, int)">; +def S2_asr_r_p_acc : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_asr_r_p_and : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_asr_r_p_nac : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_asr_r_p_or : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_asr_r_p_xor : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_asr_r_r : HexagonBuiltin<"int(int, int)">; +def S2_asr_r_r_acc : HexagonBuiltin<"int(int, int, int)">; +def S2_asr_r_r_and : HexagonBuiltin<"int(int, int, int)">; +def S2_asr_r_r_nac : HexagonBuiltin<"int(int, int, int)">; +def S2_asr_r_r_or : HexagonBuiltin<"int(int, int, int)">; +def S2_asr_r_r_sat : HexagonBuiltin<"int(int, int)">; +def S2_asr_r_svw_trun : HexagonBuiltin<"int(long long int, int)">; +def S2_asr_r_vh : HexagonBuiltin<"long long int(long long int, int)">; +def S2_asr_r_vw : HexagonBuiltin<"long long int(long long int, int)">; +def S2_brev : HexagonBuiltin<"int(int)">; +def S2_brevp : HexagonBuiltin<"long long int(long long int)">; +def S2_cl0 : HexagonBuiltin<"int(int)">; +def S2_cl0p : HexagonBuiltin<"int(long long int)">; +def S2_cl1 : HexagonBuiltin<"int(int)">; +def S2_cl1p : HexagonBuiltin<"int(long long int)">; +def S2_clb : HexagonBuiltin<"int(int)">; +def S2_clbnorm : HexagonBuiltin<"int(int)">; +def S2_clbp : HexagonBuiltin<"int(long long int)">; +def S2_clrbit_i : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def S2_clrbit_r : HexagonBuiltin<"int(int, int)">; +def S2_ct0 : HexagonBuiltin<"int(int)">; +def S2_ct0p : HexagonBuiltin<"int(long long int)">; +def S2_ct1 : HexagonBuiltin<"int(int)">; +def S2_ct1p : HexagonBuiltin<"int(long long int)">; +def S2_deinterleave : HexagonBuiltin<"long long int(long long int)">; +def S2_extractu : HexagonBuiltin<"int(int, unsigned _Constant int, unsigned _Constant int)">; +def S2_extractu_rp : HexagonBuiltin<"int(int, long long int)">; +def S2_extractup : HexagonBuiltin<"long long int(long long int, unsigned _Constant int, unsigned _Constant int)">; +def S2_extractup_rp : HexagonBuiltin<"long long int(long long int, long long int)">; +def S2_insert : HexagonBuiltin<"int(int, int, unsigned _Constant int, unsigned _Constant int)">; +def S2_insert_rp : HexagonBuiltin<"int(int, int, long long int)">; +def S2_insertp : HexagonBuiltin<"long long int(long long int, long long int, unsigned _Constant int, unsigned _Constant int)">; +def S2_insertp_rp : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +def S2_interleave : HexagonBuiltin<"long long int(long long int)">; +def S2_lfsp : HexagonBuiltin<"long long int(long long int, long long int)">; +def S2_lsl_r_p : HexagonBuiltin<"long long int(long long int, int)">; +def S2_lsl_r_p_acc : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_lsl_r_p_and : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_lsl_r_p_nac : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_lsl_r_p_or : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_lsl_r_p_xor : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_lsl_r_r : HexagonBuiltin<"int(int, int)">; +def S2_lsl_r_r_acc : HexagonBuiltin<"int(int, int, int)">; +def S2_lsl_r_r_and : HexagonBuiltin<"int(int, int, int)">; +def S2_lsl_r_r_nac : HexagonBuiltin<"int(int, int, int)">; +def S2_lsl_r_r_or : HexagonBuiltin<"int(int, int, int)">; +def S2_lsl_r_vh : HexagonBuiltin<"long long int(long long int, int)">; +def S2_lsl_r_vw : HexagonBuiltin<"long long int(long long int, int)">; +def S2_lsr_i_p : HexagonBuiltin<"long long int(long long int, unsigned _Constant int)">; +def S2_lsr_i_p_acc : HexagonBuiltin<"long long int(long long int, long long int, unsigned _Constant int)">; +def S2_lsr_i_p_and : HexagonBuiltin<"long long int(long long int, long long int, unsigned _Constant int)">; +def S2_lsr_i_p_nac : HexagonBuiltin<"long long int(long long int, long long int, unsigned _Constant int)">; +def S2_lsr_i_p_or : HexagonBuiltin<"long long int(long long int, long long int, unsigned _Constant int)">; +def S2_lsr_i_p_xacc : HexagonBuiltin<"long long int(long long int, long long int, unsigned _Constant int)">; +def S2_lsr_i_r : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def S2_lsr_i_r_acc : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; +def S2_lsr_i_r_and : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; +def S2_lsr_i_r_nac : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; +def S2_lsr_i_r_or : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; +def S2_lsr_i_r_xacc : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; +def S2_lsr_i_vh : HexagonBuiltin<"long long int(long long int, unsigned _Constant int)">; +def S2_lsr_i_vw : HexagonBuiltin<"long long int(long long int, unsigned _Constant int)">; +def S2_lsr_r_p : HexagonBuiltin<"long long int(long long int, int)">; +def S2_lsr_r_p_acc : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_lsr_r_p_and : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_lsr_r_p_nac : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_lsr_r_p_or : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_lsr_r_p_xor : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_lsr_r_r : HexagonBuiltin<"int(int, int)">; +def S2_lsr_r_r_acc : HexagonBuiltin<"int(int, int, int)">; +def S2_lsr_r_r_and : HexagonBuiltin<"int(int, int, int)">; +def S2_lsr_r_r_nac : HexagonBuiltin<"int(int, int, int)">; +def S2_lsr_r_r_or : HexagonBuiltin<"int(int, int, int)">; +def S2_lsr_r_vh : HexagonBuiltin<"long long int(long long int, int)">; +def S2_lsr_r_vw : HexagonBuiltin<"long long int(long long int, int)">; +def S2_packhl : HexagonBuiltin<"long long int(int, int)">; +def S2_parityp : HexagonBuiltin<"int(long long int, long long int)">; +def S2_setbit_i : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def S2_setbit_r : HexagonBuiltin<"int(int, int)">; +def S2_shuffeb : HexagonBuiltin<"long long int(long long int, long long int)">; +def S2_shuffeh : HexagonBuiltin<"long long int(long long int, long long int)">; +def S2_shuffob : HexagonBuiltin<"long long int(long long int, long long int)">; +def S2_shuffoh : HexagonBuiltin<"long long int(long long int, long long int)">; +def S2_svsathb : HexagonBuiltin<"int(int)">; +def S2_svsathub : HexagonBuiltin<"int(int)">; +def S2_tableidxb_goodsyntax : HexagonBuiltin<"int(int, int, unsigned _Constant int, unsigned _Constant int)">; +def S2_tableidxd_goodsyntax : HexagonBuiltin<"int(int, int, unsigned _Constant int, unsigned _Constant int)">; +def S2_tableidxh_goodsyntax : HexagonBuiltin<"int(int, int, unsigned _Constant int, unsigned _Constant int)">; +def S2_tableidxw_goodsyntax : HexagonBuiltin<"int(int, int, unsigned _Constant int, unsigned _Constant int)">; +def S2_togglebit_i : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def S2_togglebit_r : HexagonBuiltin<"int(int, int)">; +def S2_tstbit_i : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def S2_tstbit_r : HexagonBuiltin<"int(int, int)">; +def S2_valignib : HexagonBuiltin<"long long int(long long int, long long int, unsigned _Constant int)">; +def S2_valignrb : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_vcnegh : HexagonBuiltin<"long long int(long long int, int)">; +def S2_vcrotate : HexagonBuiltin<"long long int(long long int, int)">; +def S2_vrcnegh : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_vrndpackwh : HexagonBuiltin<"int(long long int)">; +def S2_vrndpackwhs : HexagonBuiltin<"int(long long int)">; +def S2_vsathb : HexagonBuiltin<"int(long long int)">; +def S2_vsathb_nopack : HexagonBuiltin<"long long int(long long int)">; +def S2_vsathub : HexagonBuiltin<"int(long long int)">; +def S2_vsathub_nopack : HexagonBuiltin<"long long int(long long int)">; +def S2_vsatwh : HexagonBuiltin<"int(long long int)">; +def S2_vsatwh_nopack : HexagonBuiltin<"long long int(long long int)">; +def S2_vsatwuh : HexagonBuiltin<"int(long long int)">; +def S2_vsatwuh_nopack : HexagonBuiltin<"long long int(long long int)">; +def S2_vsplatrb : HexagonBuiltin<"int(int)">; +def S2_vsplatrh : HexagonBuiltin<"long long int(int)">; +def S2_vspliceib : HexagonBuiltin<"long long int(long long int, long long int, unsigned _Constant int)">; +def S2_vsplicerb : HexagonBuiltin<"long long int(long long int, long long int, int)">; +def S2_vsxtbh : HexagonBuiltin<"long long int(int)">; +def S2_vsxthw : HexagonBuiltin<"long long int(int)">; +def S2_vtrunehb : HexagonBuiltin<"int(long long int)">; +def S2_vtrunewh : HexagonBuiltin<"long long int(long long int, long long int)">; +def S2_vtrunohb : HexagonBuiltin<"int(long long int)">; +def S2_vtrunowh : HexagonBuiltin<"long long int(long long int, long long int)">; +def S2_vzxtbh : HexagonBuiltin<"long long int(int)">; +def S2_vzxthw : HexagonBuiltin<"long long int(int)">; +def S4_addaddi : HexagonBuiltin<"int(int, int, _Constant int)">; +def S4_addi_asl_ri : HexagonBuiltin<"int(unsigned _Constant int, int, unsigned _Constant int)">; +def S4_addi_lsr_ri : HexagonBuiltin<"int(unsigned _Constant int, int, unsigned _Constant int)">; +def S4_andi_asl_ri : HexagonBuiltin<"int(unsigned _Constant int, int, unsigned _Constant int)">; +def S4_andi_lsr_ri : HexagonBuiltin<"int(unsigned _Constant int, int, unsigned _Constant int)">; +def S4_clbaddi : HexagonBuiltin<"int(int, _Constant int)">; +def S4_clbpaddi : HexagonBuiltin<"int(long long int, _Constant int)">; +def S4_clbpnorm : HexagonBuiltin<"int(long long int)">; +def S4_extract : HexagonBuiltin<"int(int, unsigned _Constant int, unsigned _Constant int)">; +def S4_extract_rp : HexagonBuiltin<"int(int, long long int)">; +def S4_extractp : HexagonBuiltin<"long long int(long long int, unsigned _Constant int, unsigned _Constant int)">; +def S4_extractp_rp : HexagonBuiltin<"long long int(long long int, long long int)">; +def S4_lsli : HexagonBuiltin<"int(_Constant int, int)">; +def S4_ntstbit_i : HexagonBuiltin<"int(int, unsigned _Constant int)">; +def S4_ntstbit_r : HexagonBuiltin<"int(int, int)">; +def S4_or_andi : HexagonBuiltin<"int(int, int, _Constant int)">; +def S4_or_andix : HexagonBuiltin<"int(int, int, _Constant int)">; +def S4_or_ori : HexagonBuiltin<"int(int, int, _Constant int)">; +def S4_ori_asl_ri : HexagonBuiltin<"int(unsigned _Constant int, int, unsigned _Constant int)">; +def S4_ori_lsr_ri : HexagonBuiltin<"int(unsigned _Constant int, int, unsigned _Constant int)">; +def S4_parity : HexagonBuiltin<"int(int, int)">; +def S4_subaddi : HexagonBuiltin<"int(int, _Constant int, int)">; +def S4_subi_asl_ri : HexagonBuiltin<"int(unsigned _Constant int, int, unsigned _Constant int)">; +def S4_subi_lsr_ri : HexagonBuiltin<"int(unsigned _Constant int, int, unsigned _Constant int)">; +def S4_vrcrotate : HexagonBuiltin<"long long int(long long int, int, unsigned _Constant int)">; +def S4_vrcrotate_acc : HexagonBuiltin<"long long int(long long int, long long int, int, unsigned _Constant int)">; +def S4_vxaddsubh : HexagonBuiltin<"long long int(long long int, long long int)">; +def S4_vxaddsubhr : HexagonBuiltin<"long long int(long long int, long long int)">; +def S4_vxaddsubw : HexagonBuiltin<"long long int(long long int, long long int)">; +def S4_vxsubaddh : HexagonBuiltin<"long long int(long long int, long long int)">; +def S4_vxsubaddhr : HexagonBuiltin<"long long int(long long int, long long int)">; +def S4_vxsubaddw : HexagonBuiltin<"long long int(long long int, long long int)">; +def S5_asrhub_rnd_sat_goodsyntax : HexagonBuiltin<"int(long long int, unsigned _Constant int)">; +def S5_asrhub_sat : HexagonBuiltin<"int(long long int, unsigned _Constant int)">; +def S5_popcountp : HexagonBuiltin<"int(long long int)">; +def S5_vasrhrnd_goodsyntax : HexagonBuiltin<"long long int(long long int, unsigned _Constant int)">; +def Y2_dccleana : HexagonBuiltin<"void(void *)">; +def Y2_dccleaninva : HexagonBuiltin<"void(void *)">; +def Y2_dcfetch : HexagonBuiltin<"void(void *)">; +def Y2_dcinva : HexagonBuiltin<"void(void *)">; +def Y2_dczeroa : HexagonBuiltin<"void(void *)">; +def Y4_l2fetch : HexagonBuiltin<"void(void *, int)">; +def Y5_l2fetch : HexagonBuiltin<"void(void *, long long int)">; + +// V60 Scalar Instructions. + +let Features = V60.Features in { + def S6_rol_i_p : HexagonBuiltin<"long long int(long long int, unsigned _Constant int)">; + def S6_rol_i_p_acc : HexagonBuiltin<"long long int(long long int, long long int, unsigned _Constant int)">; + def S6_rol_i_p_and : HexagonBuiltin<"long long int(long long int, long long int, unsigned _Constant int)">; + def S6_rol_i_p_nac : HexagonBuiltin<"long long int(long long int, long long int, unsigned _Constant int)">; + def S6_rol_i_p_or : HexagonBuiltin<"long long int(long long int, long long int, unsigned _Constant int)">; + def S6_rol_i_p_xacc : HexagonBuiltin<"long long int(long long int, long long int, unsigned _Constant int)">; + def S6_rol_i_r : HexagonBuiltin<"int(int, unsigned _Constant int)">; + def S6_rol_i_r_acc : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; + def S6_rol_i_r_and : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; + def S6_rol_i_r_nac : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; + def S6_rol_i_r_or : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; + def S6_rol_i_r_xacc : HexagonBuiltin<"int(int, int, unsigned _Constant int)">; +} + +// V62 Scalar Instructions. + +let Features = V62.Features in { + def M6_vabsdiffb : HexagonBuiltin<"long long int(long long int, long long int)">; + def M6_vabsdiffub : HexagonBuiltin<"long long int(long long int, long long int)">; + def S6_vsplatrbp : HexagonBuiltin<"long long int(int)">; + def S6_vtrunehb_ppp : HexagonBuiltin<"long long int(long long int, long long int)">; + def S6_vtrunohb_ppp : HexagonBuiltin<"long long int(long long int, long long int)">; +} + +// V65 Scalar Instructions. + +let Features = V65.Features in { + def A6_vcmpbeq_notany : HexagonBuiltin<"int(long long int, long long int)">; +} + +// V66 Scalar Instructions. + +let Features = V66.Features in { + def F2_dfadd : HexagonBuiltin<"double(double, double)">; + def F2_dfsub : HexagonBuiltin<"double(double, double)">; + def M2_mnaci : HexagonBuiltin<"int(int, int, int)">; + def S2_mask : HexagonBuiltin<"int(unsigned _Constant int, unsigned _Constant int)">; +} + +// V67 Scalar Instructions. + +let Features = "audio" in { + def A7_clip : HexagonBuiltin<"int(int, unsigned _Constant int)">; + def A7_croundd_ri : HexagonBuiltin<"long long int(long long int, unsigned _Constant int)">; + def A7_croundd_rr : HexagonBuiltin<"long long int(long long int, int)">; + def A7_vclip : HexagonBuiltin<"long long int(long long int, unsigned _Constant int)">; +} +let Features = V67.Features in { + def F2_dfmax : HexagonBuiltin<"double(double, double)">; + def F2_dfmin : HexagonBuiltin<"double(double, double)">; + def F2_dfmpyfix : HexagonBuiltin<"double(double, double)">; + def F2_dfmpyhh : HexagonBuiltin<"double(double, double, double)">; + def F2_dfmpylh : HexagonBuiltin<"double(double, double, double)">; + def F2_dfmpyll : HexagonBuiltin<"double(double, double)">; +} +let Features = "audio" in { + def M7_dcmpyiw : HexagonBuiltin<"long long int(long long int, long long int)">; + def M7_dcmpyiw_acc : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; + def M7_dcmpyiwc : HexagonBuiltin<"long long int(long long int, long long int)">; + def M7_dcmpyiwc_acc : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; + def M7_dcmpyrw : HexagonBuiltin<"long long int(long long int, long long int)">; + def M7_dcmpyrw_acc : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; + def M7_dcmpyrwc : HexagonBuiltin<"long long int(long long int, long long int)">; + def M7_dcmpyrwc_acc : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +} +let Features = V67.Features in { + def M7_vdmpy : HexagonBuiltin<"long long int(long long int, long long int)">; + def M7_vdmpy_acc : HexagonBuiltin<"long long int(long long int, long long int, long long int)">; +} +let Features = "audio" in { + def M7_wcmpyiw : HexagonBuiltin<"int(long long int, long long int)">; + def M7_wcmpyiw_rnd : HexagonBuiltin<"int(long long int, long long int)">; + def M7_wcmpyiwc : HexagonBuiltin<"int(long long int, long long int)">; + def M7_wcmpyiwc_rnd : HexagonBuiltin<"int(long long int, long long int)">; + def M7_wcmpyrw : HexagonBuiltin<"int(long long int, long long int)">; + def M7_wcmpyrw_rnd : HexagonBuiltin<"int(long long int, long long int)">; + def M7_wcmpyrwc : HexagonBuiltin<"int(long long int, long long int)">; + def M7_wcmpyrwc_rnd : HexagonBuiltin<"int(long long int, long long int)">; +} + +// V68 Scalar Instructions. + +let Features = V68.Features in { + def Y6_dmlink : HexagonBuiltin<"void(void *, void *)">; + def Y6_dmpause : HexagonBuiltin<"int()">; + def Y6_dmpoll : HexagonBuiltin<"int()">; + def Y6_dmresume : HexagonBuiltin<"void(void *)">; + def Y6_dmstart : HexagonBuiltin<"void(void *)">; + def Y6_dmwait : HexagonBuiltin<"int()">; +} + +// V60 HVX Instructions. + +let Features = HVXV60.Features in { + def V6_extractw : HexagonBuiltin<"int(_Vector<16, int>, int)">; + def V6_extractw_128B : HexagonBuiltin<"int(_Vector<32, int>, int)">; + def V6_hi : HexagonBuiltin<"_Vector<16, int>(_Vector<32, int>)">; + def V6_hi_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<64, int>)">; + def V6_lo : HexagonBuiltin<"_Vector<16, int>(_Vector<32, int>)">; + def V6_lo_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<64, int>)">; + def V6_lvsplatw : HexagonBuiltin<"_Vector<16, int>(int)">; + def V6_lvsplatw_128B : HexagonBuiltin<"_Vector<32, int>(int)">; + def V6_pred_and : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<64, bool>)">; + def V6_pred_and_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<128, bool>)">; + def V6_pred_and_n : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<64, bool>)">; + def V6_pred_and_n_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<128, bool>)">; + def V6_pred_not : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>)">; + def V6_pred_not_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>)">; + def V6_pred_or : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<64, bool>)">; + def V6_pred_or_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<128, bool>)">; + def V6_pred_or_n : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<64, bool>)">; + def V6_pred_or_n_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<128, bool>)">; + def V6_pred_scalar2 : HexagonBuiltin<"_Vector<64, bool>(int)">; + def V6_pred_scalar2_128B : HexagonBuiltin<"_Vector<128, bool>(int)">; + def V6_pred_xor : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<64, bool>)">; + def V6_pred_xor_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<128, bool>)">; + def V6_vS32b_nqpred_ai : HexagonBuiltin<"void(_Vector<64, bool>, void *, _Vector<16, int>)">; + def V6_vS32b_nqpred_ai_128B : HexagonBuiltin<"void(_Vector<128, bool>, void *, _Vector<32, int>)">; + def V6_vS32b_nt_nqpred_ai : HexagonBuiltin<"void(_Vector<64, bool>, void *, _Vector<16, int>)">; + def V6_vS32b_nt_nqpred_ai_128B : HexagonBuiltin<"void(_Vector<128, bool>, void *, _Vector<32, int>)">; + def V6_vS32b_nt_qpred_ai : HexagonBuiltin<"void(_Vector<64, bool>, void *, _Vector<16, int>)">; + def V6_vS32b_nt_qpred_ai_128B : HexagonBuiltin<"void(_Vector<128, bool>, void *, _Vector<32, int>)">; + def V6_vS32b_qpred_ai : HexagonBuiltin<"void(_Vector<64, bool>, void *, _Vector<16, int>)">; + def V6_vS32b_qpred_ai_128B : HexagonBuiltin<"void(_Vector<128, bool>, void *, _Vector<32, int>)">; + def V6_vabsdiffh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vabsdiffh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vabsdiffub : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vabsdiffub_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vabsdiffuh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vabsdiffuh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vabsdiffw : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vabsdiffw_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vabsh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vabsh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vabsh_sat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vabsh_sat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vabsw : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vabsw_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vabsw_sat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vabsw_sat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vaddb : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vaddb_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vaddb_dv : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vaddb_dv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>)">; + def V6_vaddbnq : HexagonBuiltin<"_Vector<16, int>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vaddbnq_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vaddbq : HexagonBuiltin<"_Vector<16, int>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vaddbq_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vaddh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vaddh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vaddh_dv : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vaddh_dv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>)">; + def V6_vaddhnq : HexagonBuiltin<"_Vector<16, int>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vaddhnq_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vaddhq : HexagonBuiltin<"_Vector<16, int>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vaddhq_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vaddhsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vaddhsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vaddhsat_dv : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vaddhsat_dv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>)">; + def V6_vaddhw : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vaddhw_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vaddubh : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vaddubh_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vaddubsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vaddubsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vaddubsat_dv : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vaddubsat_dv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>)">; + def V6_vadduhsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vadduhsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vadduhsat_dv : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vadduhsat_dv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>)">; + def V6_vadduhw : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vadduhw_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vaddw : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vaddw_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vaddw_dv : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vaddw_dv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>)">; + def V6_vaddwnq : HexagonBuiltin<"_Vector<16, int>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vaddwnq_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vaddwq : HexagonBuiltin<"_Vector<16, int>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vaddwq_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vaddwsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vaddwsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vaddwsat_dv : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vaddwsat_dv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>)">; + def V6_valignb : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_valignb_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_valignbi : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, unsigned _Constant int)">; + def V6_valignbi_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, unsigned _Constant int)">; + def V6_vand : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vand_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vandqrt : HexagonBuiltin<"_Vector<16, int>(_Vector<64, bool>, int)">; + def V6_vandqrt_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<128, bool>, int)">; + def V6_vandqrt_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<64, bool>, int)">; + def V6_vandqrt_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<128, bool>, int)">; + def V6_vandvrt : HexagonBuiltin<"_Vector<64, bool>(_Vector<16, int>, int)">; + def V6_vandvrt_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<32, int>, int)">; + def V6_vandvrt_acc : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, int)">; + def V6_vandvrt_acc_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, int)">; + def V6_vaslh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vaslh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vaslhv : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vaslhv_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vaslw : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vaslw_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vaslw_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vaslw_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vaslwv : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vaslwv_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vasrh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vasrh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vasrhbrndsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vasrhbrndsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vasrhubrndsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vasrhubrndsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vasrhubsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vasrhubsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vasrhv : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vasrhv_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vasrw : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vasrw_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vasrw_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vasrw_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vasrwh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vasrwh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vasrwhrndsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vasrwhrndsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vasrwhsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vasrwhsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vasrwuhsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vasrwuhsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vasrwv : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vasrwv_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vassign : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vassign_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vassignp : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vassignp_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>)">; + def V6_vavgh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vavgh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vavghrnd : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vavghrnd_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vavgub : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vavgub_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vavgubrnd : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vavgubrnd_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vavguh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vavguh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vavguhrnd : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vavguhrnd_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vavgw : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vavgw_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vavgwrnd : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vavgwrnd_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vcl0h : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vcl0h_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vcl0w : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vcl0w_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vcombine : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vcombine_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vd0 : HexagonBuiltin<"_Vector<16, int>()">; + def V6_vd0_128B : HexagonBuiltin<"_Vector<32, int>()">; + def V6_vdealb : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vdealb_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vdealb4w : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vdealb4w_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vdealh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vdealh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vdealvdd : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vdealvdd_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vdelta : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vdelta_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vdmpybus : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vdmpybus_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vdmpybus_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vdmpybus_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vdmpybus_dv : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vdmpybus_dv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, int)">; + def V6_vdmpybus_dv_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vdmpybus_dv_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>, int)">; + def V6_vdmpyhb : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vdmpyhb_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vdmpyhb_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vdmpyhb_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vdmpyhb_dv : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vdmpyhb_dv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, int)">; + def V6_vdmpyhb_dv_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vdmpyhb_dv_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>, int)">; + def V6_vdmpyhisat : HexagonBuiltin<"_Vector<16, int>(_Vector<32, int>, int)">; + def V6_vdmpyhisat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<64, int>, int)">; + def V6_vdmpyhisat_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<32, int>, int)">; + def V6_vdmpyhisat_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<64, int>, int)">; + def V6_vdmpyhsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vdmpyhsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vdmpyhsat_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vdmpyhsat_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vdmpyhsuisat : HexagonBuiltin<"_Vector<16, int>(_Vector<32, int>, int)">; + def V6_vdmpyhsuisat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<64, int>, int)">; + def V6_vdmpyhsuisat_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<32, int>, int)">; + def V6_vdmpyhsuisat_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<64, int>, int)">; + def V6_vdmpyhsusat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vdmpyhsusat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vdmpyhsusat_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vdmpyhsusat_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vdmpyhvsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vdmpyhvsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vdmpyhvsat_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vdmpyhvsat_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vdsaduh : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vdsaduh_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, int)">; + def V6_vdsaduh_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vdsaduh_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>, int)">; + def V6_veqb : HexagonBuiltin<"_Vector<64, bool>(_Vector<16, int>, _Vector<16, int>)">; + def V6_veqb_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<32, int>, _Vector<32, int>)">; + def V6_veqb_and : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_veqb_and_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_veqb_or : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_veqb_or_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_veqb_xor : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_veqb_xor_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_veqh : HexagonBuiltin<"_Vector<64, bool>(_Vector<16, int>, _Vector<16, int>)">; + def V6_veqh_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<32, int>, _Vector<32, int>)">; + def V6_veqh_and : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_veqh_and_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_veqh_or : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_veqh_or_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_veqh_xor : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_veqh_xor_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_veqw : HexagonBuiltin<"_Vector<64, bool>(_Vector<16, int>, _Vector<16, int>)">; + def V6_veqw_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<32, int>, _Vector<32, int>)">; + def V6_veqw_and : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_veqw_and_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_veqw_or : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_veqw_or_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_veqw_xor : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_veqw_xor_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgtb : HexagonBuiltin<"_Vector<64, bool>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vgtb_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vgtb_and : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgtb_and_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgtb_or : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgtb_or_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgtb_xor : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgtb_xor_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgth : HexagonBuiltin<"_Vector<64, bool>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vgth_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vgth_and : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgth_and_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgth_or : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgth_or_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgth_xor : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgth_xor_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgtub : HexagonBuiltin<"_Vector<64, bool>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vgtub_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vgtub_and : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgtub_and_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgtub_or : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgtub_or_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgtub_xor : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgtub_xor_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgtuh : HexagonBuiltin<"_Vector<64, bool>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vgtuh_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vgtuh_and : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgtuh_and_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgtuh_or : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgtuh_or_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgtuh_xor : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgtuh_xor_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgtuw : HexagonBuiltin<"_Vector<64, bool>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vgtuw_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vgtuw_and : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgtuw_and_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgtuw_or : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgtuw_or_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgtuw_xor : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgtuw_xor_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgtw : HexagonBuiltin<"_Vector<64, bool>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vgtw_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vgtw_and : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgtw_and_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgtw_or : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgtw_or_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgtw_xor : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgtw_xor_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vinsertwr : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vinsertwr_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vlalignb : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vlalignb_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vlalignbi : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, unsigned _Constant int)">; + def V6_vlalignbi_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, unsigned _Constant int)">; + def V6_vlsrh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vlsrh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vlsrhv : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vlsrhv_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vlsrw : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vlsrw_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vlsrwv : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vlsrwv_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vlutvvb : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vlutvvb_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vlutvvb_oracc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, _Vector<16, int>, int)">; + def V6_vlutvvb_oracc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, _Vector<32, int>, int)">; + def V6_vlutvwh : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vlutvwh_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vlutvwh_oracc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, _Vector<16, int>, int)">; + def V6_vlutvwh_oracc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, _Vector<32, int>, int)">; + def V6_vmaxh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmaxh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmaxub : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmaxub_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmaxuh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmaxuh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmaxw : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmaxw_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vminh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vminh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vminub : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vminub_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vminuh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vminuh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vminw : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vminw_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpabus : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vmpabus_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, int)">; + def V6_vmpabus_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vmpabus_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>, int)">; + def V6_vmpabusv : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpabusv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>)">; + def V6_vmpabuuv : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpabuuv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>)">; + def V6_vmpahb : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vmpahb_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, int)">; + def V6_vmpahb_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vmpahb_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>, int)">; + def V6_vmpybus : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, int)">; + def V6_vmpybus_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, int)">; + def V6_vmpybus_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, int)">; + def V6_vmpybus_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, int)">; + def V6_vmpybusv : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpybusv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpybusv_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vmpybusv_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vmpybv : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpybv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpybv_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vmpybv_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vmpyewuh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyewuh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpyh : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, int)">; + def V6_vmpyh_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, int)">; + def V6_vmpyhsat_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, int)">; + def V6_vmpyhsat_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, int)">; + def V6_vmpyhsrs : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vmpyhsrs_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vmpyhss : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vmpyhss_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vmpyhus : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyhus_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpyhus_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyhus_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vmpyhv : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyhv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpyhv_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyhv_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vmpyhvsrs : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyhvsrs_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpyieoh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyieoh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpyiewh_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyiewh_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vmpyiewuh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyiewuh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpyiewuh_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyiewuh_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vmpyih : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyih_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpyih_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyih_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vmpyihb : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vmpyihb_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vmpyihb_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vmpyihb_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vmpyiowh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyiowh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpyiwb : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vmpyiwb_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vmpyiwb_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vmpyiwb_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vmpyiwh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vmpyiwh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vmpyiwh_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vmpyiwh_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vmpyowh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyowh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpyowh_rnd : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyowh_rnd_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpyowh_rnd_sacc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyowh_rnd_sacc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vmpyowh_sacc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyowh_sacc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vmpyub : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, int)">; + def V6_vmpyub_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, int)">; + def V6_vmpyub_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, int)">; + def V6_vmpyub_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, int)">; + def V6_vmpyubv : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyubv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpyubv_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyubv_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vmpyuh : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, int)">; + def V6_vmpyuh_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, int)">; + def V6_vmpyuh_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, int)">; + def V6_vmpyuh_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, int)">; + def V6_vmpyuhv : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyuhv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpyuhv_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyuhv_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vmux : HexagonBuiltin<"_Vector<16, int>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vmux_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vnavgh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vnavgh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vnavgub : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vnavgub_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vnavgw : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vnavgw_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vnormamth : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vnormamth_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vnormamtw : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vnormamtw_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vnot : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vnot_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vor : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vor_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vpackeb : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vpackeb_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vpackeh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vpackeh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vpackhb_sat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vpackhb_sat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vpackhub_sat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vpackhub_sat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vpackob : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vpackob_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vpackoh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vpackoh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vpackwh_sat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vpackwh_sat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vpackwuh_sat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vpackwuh_sat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vpopcounth : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vpopcounth_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vrdelta : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vrdelta_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vrmpybus : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vrmpybus_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vrmpybus_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vrmpybus_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vrmpybusi : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int, unsigned _Constant int)">; + def V6_vrmpybusi_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, int, unsigned _Constant int)">; + def V6_vrmpybusi_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int, unsigned _Constant int)">; + def V6_vrmpybusi_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>, int, unsigned _Constant int)">; + def V6_vrmpybusv : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vrmpybusv_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vrmpybusv_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vrmpybusv_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vrmpybv : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vrmpybv_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vrmpybv_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vrmpybv_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vrmpyub : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vrmpyub_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vrmpyub_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vrmpyub_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vrmpyubi : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int, unsigned _Constant int)">; + def V6_vrmpyubi_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, int, unsigned _Constant int)">; + def V6_vrmpyubi_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int, unsigned _Constant int)">; + def V6_vrmpyubi_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>, int, unsigned _Constant int)">; + def V6_vrmpyubv : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vrmpyubv_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vrmpyubv_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vrmpyubv_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vror : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vror_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vroundhb : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vroundhb_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vroundhub : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vroundhub_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vroundwh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vroundwh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vroundwuh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vroundwuh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vrsadubi : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int, unsigned _Constant int)">; + def V6_vrsadubi_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, int, unsigned _Constant int)">; + def V6_vrsadubi_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int, unsigned _Constant int)">; + def V6_vrsadubi_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>, int, unsigned _Constant int)">; + def V6_vsathub : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsathub_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsatwh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsatwh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsb : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>)">; + def V6_vsb_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>)">; + def V6_vsh : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>)">; + def V6_vsh_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>)">; + def V6_vshufeh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vshufeh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vshuffb : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vshuffb_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vshuffeb : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vshuffeb_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vshuffh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vshuffh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vshuffob : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vshuffob_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vshuffvdd : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vshuffvdd_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vshufoeb : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vshufoeb_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vshufoeh : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vshufoeh_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vshufoh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vshufoh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsubb : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsubb_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsubb_dv : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsubb_dv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>)">; + def V6_vsubbnq : HexagonBuiltin<"_Vector<16, int>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vsubbnq_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vsubbq : HexagonBuiltin<"_Vector<16, int>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vsubbq_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vsubh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsubh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsubh_dv : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsubh_dv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>)">; + def V6_vsubhnq : HexagonBuiltin<"_Vector<16, int>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vsubhnq_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vsubhq : HexagonBuiltin<"_Vector<16, int>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vsubhq_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vsubhsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsubhsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsubhsat_dv : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsubhsat_dv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>)">; + def V6_vsubhw : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsubhw_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsububh : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsububh_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsububsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsububsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsububsat_dv : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsububsat_dv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>)">; + def V6_vsubuhsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsubuhsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsubuhsat_dv : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsubuhsat_dv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>)">; + def V6_vsubuhw : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsubuhw_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsubw : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsubw_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsubw_dv : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsubw_dv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>)">; + def V6_vsubwnq : HexagonBuiltin<"_Vector<16, int>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vsubwnq_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vsubwq : HexagonBuiltin<"_Vector<16, int>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vsubwq_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vsubwsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsubwsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsubwsat_dv : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsubwsat_dv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>)">; + def V6_vswap : HexagonBuiltin<"_Vector<32, int>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vswap_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vtmpyb : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vtmpyb_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, int)">; + def V6_vtmpyb_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vtmpyb_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>, int)">; + def V6_vtmpybus : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vtmpybus_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, int)">; + def V6_vtmpybus_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vtmpybus_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>, int)">; + def V6_vtmpyhb : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vtmpyhb_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, int)">; + def V6_vtmpyhb_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vtmpyhb_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>, int)">; + def V6_vunpackb : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>)">; + def V6_vunpackb_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>)">; + def V6_vunpackh : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>)">; + def V6_vunpackh_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>)">; + def V6_vunpackob : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>)">; + def V6_vunpackob_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>)">; + def V6_vunpackoh : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>)">; + def V6_vunpackoh_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>)">; + def V6_vunpackub : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>)">; + def V6_vunpackub_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>)">; + def V6_vunpackuh : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>)">; + def V6_vunpackuh_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>)">; + def V6_vxor : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vxor_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vzb : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>)">; + def V6_vzb_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>)">; + def V6_vzh : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>)">; + def V6_vzh_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>)">; +} + +// V62 HVX Instructions. + +let Features = HVXV62.Features in { + def V6_lvsplatb : HexagonBuiltin<"_Vector<16, int>(int)">; + def V6_lvsplatb_128B : HexagonBuiltin<"_Vector<32, int>(int)">; + def V6_lvsplath : HexagonBuiltin<"_Vector<16, int>(int)">; + def V6_lvsplath_128B : HexagonBuiltin<"_Vector<32, int>(int)">; + def V6_pred_scalar2v2 : HexagonBuiltin<"_Vector<64, bool>(int)">; + def V6_pred_scalar2v2_128B : HexagonBuiltin<"_Vector<128, bool>(int)">; + def V6_shuffeqh : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<64, bool>)">; + def V6_shuffeqh_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<128, bool>)">; + def V6_shuffeqw : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<64, bool>)">; + def V6_shuffeqw_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<128, bool>)">; + def V6_vaddbsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vaddbsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vaddbsat_dv : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vaddbsat_dv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>)">; + def V6_vaddcarry : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, void *)">; + def V6_vaddcarry_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, void *)">; + def V6_vaddclbh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vaddclbh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vaddclbw : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vaddclbw_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vaddhw_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vaddhw_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vaddubh_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vaddubh_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vaddububb_sat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vaddububb_sat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vadduhw_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vadduhw_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vadduwsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vadduwsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vadduwsat_dv : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vadduwsat_dv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>)">; + def V6_vandnqrt : HexagonBuiltin<"_Vector<16, int>(_Vector<64, bool>, int)">; + def V6_vandnqrt_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<128, bool>, int)">; + def V6_vandnqrt_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<64, bool>, int)">; + def V6_vandnqrt_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<128, bool>, int)">; + def V6_vandvnqv : HexagonBuiltin<"_Vector<16, int>(_Vector<64, bool>, _Vector<16, int>)">; + def V6_vandvnqv_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<128, bool>, _Vector<32, int>)">; + def V6_vandvqv : HexagonBuiltin<"_Vector<16, int>(_Vector<64, bool>, _Vector<16, int>)">; + def V6_vandvqv_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<128, bool>, _Vector<32, int>)">; + def V6_vasrhbsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vasrhbsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vasruwuhrndsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vasruwuhrndsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vasrwuhrndsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vasrwuhrndsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vlsrb : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vlsrb_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vlutvvb_nm : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vlutvvb_nm_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vlutvvb_oracci : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, _Vector<16, int>, unsigned _Constant int)">; + def V6_vlutvvb_oracci_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, _Vector<32, int>, unsigned _Constant int)">; + def V6_vlutvvbi : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, unsigned _Constant int)">; + def V6_vlutvvbi_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, unsigned _Constant int)">; + def V6_vlutvwh_nm : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vlutvwh_nm_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vlutvwh_oracci : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, _Vector<16, int>, unsigned _Constant int)">; + def V6_vlutvwh_oracci_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, _Vector<32, int>, unsigned _Constant int)">; + def V6_vlutvwhi : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>, unsigned _Constant int)">; + def V6_vlutvwhi_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>, unsigned _Constant int)">; + def V6_vmaxb : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmaxb_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vminb : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vminb_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpauhb : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vmpauhb_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, int)">; + def V6_vmpauhb_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vmpauhb_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>, int)">; + def V6_vmpyewuh_64 : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyewuh_64_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpyiwub : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vmpyiwub_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vmpyiwub_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vmpyiwub_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vmpyowh_64_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyowh_64_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vrounduhub : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vrounduhub_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vrounduwuh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vrounduwuh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsatuwuh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsatuwuh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsubbsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsubbsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsubbsat_dv : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsubbsat_dv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>)">; + def V6_vsubcarry : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, void *)">; + def V6_vsubcarry_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, void *)">; + def V6_vsubububb_sat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsubububb_sat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsubuwsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsubuwsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsubuwsat_dv : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsubuwsat_dv_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>)">; +} + +// V65 HVX Instructions. + +let Features = HVXV65.Features in { + def V6_vabsb : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vabsb_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vabsb_sat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vabsb_sat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vaslh_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vaslh_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vasrh_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vasrh_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vasruhubrndsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vasruhubrndsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vasruhubsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vasruhubsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vasruwuhsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vasruwuhsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vavgb : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vavgb_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vavgbrnd : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vavgbrnd_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vavguw : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vavguw_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vavguwrnd : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vavguwrnd_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vdd0 : HexagonBuiltin<"_Vector<32, int>()">; + def V6_vdd0_128B : HexagonBuiltin<"_Vector<64, int>()">; + def V6_vgathermh : HexagonBuiltin<"void(void *, int, int, _Vector<16, int>)">; + def V6_vgathermh_128B : HexagonBuiltin<"void(void *, int, int, _Vector<32, int>)">; + def V6_vgathermhq : HexagonBuiltin<"void(void *, _Vector<64, bool>, int, int, _Vector<16, int>)">; + def V6_vgathermhq_128B : HexagonBuiltin<"void(void *, _Vector<128, bool>, int, int, _Vector<32, int>)">; + def V6_vgathermhw : HexagonBuiltin<"void(void *, int, int, _Vector<32, int>)">; + def V6_vgathermhw_128B : HexagonBuiltin<"void(void *, int, int, _Vector<64, int>)">; + def V6_vgathermhwq : HexagonBuiltin<"void(void *, _Vector<64, bool>, int, int, _Vector<32, int>)">; + def V6_vgathermhwq_128B : HexagonBuiltin<"void(void *, _Vector<128, bool>, int, int, _Vector<64, int>)">; + def V6_vgathermw : HexagonBuiltin<"void(void *, int, int, _Vector<16, int>)">; + def V6_vgathermw_128B : HexagonBuiltin<"void(void *, int, int, _Vector<32, int>)">; + def V6_vgathermwq : HexagonBuiltin<"void(void *, _Vector<64, bool>, int, int, _Vector<16, int>)">; + def V6_vgathermwq_128B : HexagonBuiltin<"void(void *, _Vector<128, bool>, int, int, _Vector<32, int>)">; + def V6_vlut4 : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, long long int)">; + def V6_vlut4_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, long long int)">; + def V6_vmpabuu : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vmpabuu_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, int)">; + def V6_vmpabuu_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vmpabuu_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>, int)">; + def V6_vmpahhsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, long long int)">; + def V6_vmpahhsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, long long int)">; + def V6_vmpauhuhsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, long long int)">; + def V6_vmpauhuhsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, long long int)">; + def V6_vmpsuhuhsat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, long long int)">; + def V6_vmpsuhuhsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, long long int)">; + def V6_vmpyh_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, int)">; + def V6_vmpyh_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, int)">; + def V6_vmpyuhe : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vmpyuhe_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vmpyuhe_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_vmpyuhe_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_vnavgb : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vnavgb_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vprefixqb : HexagonBuiltin<"_Vector<16, int>(_Vector<64, bool>)">; + def V6_vprefixqb_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<128, bool>)">; + def V6_vprefixqh : HexagonBuiltin<"_Vector<16, int>(_Vector<64, bool>)">; + def V6_vprefixqh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<128, bool>)">; + def V6_vprefixqw : HexagonBuiltin<"_Vector<16, int>(_Vector<64, bool>)">; + def V6_vprefixqw_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<128, bool>)">; + def V6_vscattermh : HexagonBuiltin<"void(int, int, _Vector<16, int>, _Vector<16, int>)">; + def V6_vscattermh_128B : HexagonBuiltin<"void(int, int, _Vector<32, int>, _Vector<32, int>)">; + def V6_vscattermh_add : HexagonBuiltin<"void(int, int, _Vector<16, int>, _Vector<16, int>)">; + def V6_vscattermh_add_128B : HexagonBuiltin<"void(int, int, _Vector<32, int>, _Vector<32, int>)">; + def V6_vscattermhq : HexagonBuiltin<"void(_Vector<64, bool>, int, int, _Vector<16, int>, _Vector<16, int>)">; + def V6_vscattermhq_128B : HexagonBuiltin<"void(_Vector<128, bool>, int, int, _Vector<32, int>, _Vector<32, int>)">; + def V6_vscattermhw : HexagonBuiltin<"void(int, int, _Vector<32, int>, _Vector<16, int>)">; + def V6_vscattermhw_128B : HexagonBuiltin<"void(int, int, _Vector<64, int>, _Vector<32, int>)">; + def V6_vscattermhw_add : HexagonBuiltin<"void(int, int, _Vector<32, int>, _Vector<16, int>)">; + def V6_vscattermhw_add_128B : HexagonBuiltin<"void(int, int, _Vector<64, int>, _Vector<32, int>)">; + def V6_vscattermhwq : HexagonBuiltin<"void(_Vector<64, bool>, int, int, _Vector<32, int>, _Vector<16, int>)">; + def V6_vscattermhwq_128B : HexagonBuiltin<"void(_Vector<128, bool>, int, int, _Vector<64, int>, _Vector<32, int>)">; + def V6_vscattermw : HexagonBuiltin<"void(int, int, _Vector<16, int>, _Vector<16, int>)">; + def V6_vscattermw_128B : HexagonBuiltin<"void(int, int, _Vector<32, int>, _Vector<32, int>)">; + def V6_vscattermw_add : HexagonBuiltin<"void(int, int, _Vector<16, int>, _Vector<16, int>)">; + def V6_vscattermw_add_128B : HexagonBuiltin<"void(int, int, _Vector<32, int>, _Vector<32, int>)">; + def V6_vscattermwq : HexagonBuiltin<"void(_Vector<64, bool>, int, int, _Vector<16, int>, _Vector<16, int>)">; + def V6_vscattermwq_128B : HexagonBuiltin<"void(_Vector<128, bool>, int, int, _Vector<32, int>, _Vector<32, int>)">; +} + +// V66 HVX Instructions. + +let Features = HVXV66.Features in { + def V6_vaddcarryo : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, void *)">; + def V6_vaddcarryo_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, void *)">; + def V6_vaddcarrysat : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, _Vector<64, bool>)">; + def V6_vaddcarrysat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, _Vector<128, bool>)">; + def V6_vasr_into : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vasr_into_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vrotr : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vrotr_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsatdw : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsatdw_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsubcarryo : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, void *)">; + def V6_vsubcarryo_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, void *)">; +} + +// V68 HVX Instructions. + +let Features = HVXV68.Features in { + def V6_v6mpyhubs10 : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, unsigned _Constant int)">; + def V6_v6mpyhubs10_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>, unsigned _Constant int)">; + def V6_v6mpyhubs10_vxx : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, _Vector<32, int>, unsigned _Constant int)">; + def V6_v6mpyhubs10_vxx_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>, _Vector<64, int>, unsigned _Constant int)">; + def V6_v6mpyvubs10 : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, unsigned _Constant int)">; + def V6_v6mpyvubs10_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>, unsigned _Constant int)">; + def V6_v6mpyvubs10_vxx : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, _Vector<32, int>, unsigned _Constant int)">; + def V6_v6mpyvubs10_vxx_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<64, int>, _Vector<64, int>, unsigned _Constant int)">; + def V6_vabs_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vabs_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vabs_sf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vabs_sf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vadd_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vadd_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vadd_hf_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vadd_hf_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vadd_qf16 : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vadd_qf16_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vadd_qf16_mix : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vadd_qf16_mix_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vadd_qf32 : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vadd_qf32_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vadd_qf32_mix : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vadd_qf32_mix_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vadd_sf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vadd_sf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vadd_sf_hf : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vadd_sf_hf_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vadd_sf_sf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vadd_sf_sf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vassign_fp : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vassign_fp_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vconv_hf_qf16 : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vconv_hf_qf16_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vconv_hf_qf32 : HexagonBuiltin<"_Vector<16, int>(_Vector<32, int>)">; + def V6_vconv_hf_qf32_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<64, int>)">; + def V6_vconv_sf_qf32 : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vconv_sf_qf32_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vcvt_b_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vcvt_b_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vcvt_h_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vcvt_h_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vcvt_hf_b : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>)">; + def V6_vcvt_hf_b_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>)">; + def V6_vcvt_hf_h : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vcvt_hf_h_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vcvt_hf_sf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vcvt_hf_sf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vcvt_hf_ub : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>)">; + def V6_vcvt_hf_ub_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>)">; + def V6_vcvt_hf_uh : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vcvt_hf_uh_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vcvt_sf_hf : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>)">; + def V6_vcvt_sf_hf_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>)">; + def V6_vcvt_ub_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vcvt_ub_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vcvt_uh_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vcvt_uh_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vdmpy_sf_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vdmpy_sf_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vdmpy_sf_hf_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vdmpy_sf_hf_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vfmax_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vfmax_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vfmax_sf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vfmax_sf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vfmin_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vfmin_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vfmin_sf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vfmin_sf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vfneg_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vfneg_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vfneg_sf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vfneg_sf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vgthf : HexagonBuiltin<"_Vector<64, bool>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vgthf_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vgthf_and : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgthf_and_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgthf_or : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgthf_or_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgthf_xor : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgthf_xor_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgtsf : HexagonBuiltin<"_Vector<64, bool>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vgtsf_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vgtsf_and : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgtsf_and_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgtsf_or : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgtsf_or_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgtsf_xor : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgtsf_xor_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vmax_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmax_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmax_sf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmax_sf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmin_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmin_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmin_sf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmin_sf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpy_hf_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpy_hf_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpy_hf_hf_acc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vmpy_hf_hf_acc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vmpy_qf16 : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpy_qf16_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpy_qf16_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpy_qf16_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpy_qf16_mix_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpy_qf16_mix_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpy_qf32 : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpy_qf32_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpy_qf32_hf : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpy_qf32_hf_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpy_qf32_mix_hf : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpy_qf32_mix_hf_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpy_qf32_qf16 : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpy_qf32_qf16_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpy_qf32_sf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpy_qf32_sf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpy_sf_hf : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpy_sf_hf_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpy_sf_hf_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vmpy_sf_hf_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vmpy_sf_sf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpy_sf_sf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsub_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsub_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsub_hf_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsub_hf_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsub_qf16 : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsub_qf16_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsub_qf16_mix : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsub_qf16_mix_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsub_qf32 : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsub_qf32_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsub_qf32_mix : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsub_qf32_mix_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsub_sf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsub_sf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsub_sf_hf : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsub_sf_hf_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vsub_sf_sf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsub_sf_sf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; +} + +// V69 HVX Instructions. + +let Features = HVXV69.Features in { + def V6_vasrvuhubrndsat : HexagonBuiltin<"_Vector<16, int>(_Vector<32, int>, _Vector<16, int>)">; + def V6_vasrvuhubrndsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<64, int>, _Vector<32, int>)">; + def V6_vasrvuhubsat : HexagonBuiltin<"_Vector<16, int>(_Vector<32, int>, _Vector<16, int>)">; + def V6_vasrvuhubsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<64, int>, _Vector<32, int>)">; + def V6_vasrvwuhrndsat : HexagonBuiltin<"_Vector<16, int>(_Vector<32, int>, _Vector<16, int>)">; + def V6_vasrvwuhrndsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<64, int>, _Vector<32, int>)">; + def V6_vasrvwuhsat : HexagonBuiltin<"_Vector<16, int>(_Vector<32, int>, _Vector<16, int>)">; + def V6_vasrvwuhsat_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<64, int>, _Vector<32, int>)">; + def V6_vmpyuhvs : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpyuhvs_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; +} + +// V73 HVX Instructions. + +let Features = HVXV73.Features in { + def V6_vadd_sf_bf : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vadd_sf_bf_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vconv_h_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vconv_h_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vconv_hf_h : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vconv_hf_h_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vconv_sf_w : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vconv_sf_w_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vconv_w_sf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vconv_w_sf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vcvt_bf_sf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vcvt_bf_sf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vgtbf : HexagonBuiltin<"_Vector<64, bool>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vgtbf_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vgtbf_and : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgtbf_and_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgtbf_or : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgtbf_or_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vgtbf_xor : HexagonBuiltin<"_Vector<64, bool>(_Vector<64, bool>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vgtbf_xor_128B : HexagonBuiltin<"_Vector<128, bool>(_Vector<128, bool>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vmax_bf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmax_bf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmin_bf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmin_bf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpy_sf_bf : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpy_sf_bf_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpy_sf_bf_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vmpy_sf_bf_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vsub_sf_bf : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsub_sf_bf_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; +} + +// V79 HVX Instructions. + +let Features = HVXV79.Features in { + def V6_get_qfext : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_get_qfext_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_get_qfext_oracc : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>, int)">; + def V6_get_qfext_oracc_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>, int)">; + def V6_set_qfext : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_set_qfext_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vabs_f8 : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vabs_f8_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vadd_hf_f8 : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vadd_hf_f8_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vcvt2_b_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vcvt2_b_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vcvt2_hf_b : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>)">; + def V6_vcvt2_hf_b_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>)">; + def V6_vcvt2_hf_ub : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>)">; + def V6_vcvt2_hf_ub_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>)">; + def V6_vcvt2_ub_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vcvt2_ub_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vcvt_f8_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vcvt_f8_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vcvt_hf_f8 : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>)">; + def V6_vcvt_hf_f8_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>)">; + def V6_vfmax_f8 : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vfmax_f8_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vfmin_f8 : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vfmin_f8_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vfneg_f8 : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>)">; + def V6_vfneg_f8_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>)">; + def V6_vmerge_qf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmerge_qf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpy_hf_f8 : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vmpy_hf_f8_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; + def V6_vmpy_hf_f8_acc : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, _Vector<16, int>, _Vector<16, int>)">; + def V6_vmpy_hf_f8_acc_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<64, int>, _Vector<32, int>, _Vector<32, int>)">; + def V6_vmpy_rt_hf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vmpy_rt_hf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vmpy_rt_qf16 : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vmpy_rt_qf16_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vmpy_rt_sf : HexagonBuiltin<"_Vector<16, int>(_Vector<16, int>, int)">; + def V6_vmpy_rt_sf_128B : HexagonBuiltin<"_Vector<32, int>(_Vector<32, int>, int)">; + def V6_vsub_hf_f8 : HexagonBuiltin<"_Vector<32, int>(_Vector<16, int>, _Vector<16, int>)">; + def V6_vsub_hf_f8_128B : HexagonBuiltin<"_Vector<64, int>(_Vector<32, int>, _Vector<32, int>)">; +} diff --git clang/include/clang/Basic/BuiltinsHexagonDep.def clang/include/clang/Basic/BuiltinsHexagonDep.def deleted file mode 100644 index 616ff3ccf5b6..000000000000 --- clang/include/clang/Basic/BuiltinsHexagonDep.def +++ /dev/null @@ -1,1970 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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 -// -//===----------------------------------------------------------------------===// -// Automatically generated file, do not edit! -//===----------------------------------------------------------------------===// - - -// V5 Scalar Instructions. - -TARGET_BUILTIN(__builtin_HEXAGON_A2_abs, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_absp, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_abssat, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_add, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_hh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_hl, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_lh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_ll, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_sat_hh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_sat_hl, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_sat_lh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_h16_sat_ll, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_l16_hl, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_l16_ll, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_l16_sat_hl, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addh_l16_sat_ll, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addi, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addpsat, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addsat, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_addsp, "LLiiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_and, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_andir, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_andp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_aslh, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_asrh, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_combine_hh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_combine_hl, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_combine_lh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_combine_ll, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_combineii, "LLiIiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_combinew, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_max, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_maxp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_maxu, "Uiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_maxup, "ULLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_min, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_minp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_minu, "Uiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_minup, "ULLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_neg, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_negp, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_negsat, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_not, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_notp, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_or, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_orir, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_orp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_roundsat, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_sat, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_satb, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_sath, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_satub, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_satuh, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_sub, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_hh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_hl, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_lh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_ll, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_sat_hh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_sat_hl, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_sat_lh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_h16_sat_ll, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_l16_hl, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_l16_ll, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_l16_sat_hl, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subh_l16_sat_ll, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subri, "iIii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_subsat, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_svaddh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_svaddhs, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_svadduhs, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_svavgh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_svavghs, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_svnavgh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_svsubh, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_svsubhs, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_svsubuhs, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_swiz, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_sxtb, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_sxth, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_sxtw, "LLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_tfr, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_tfrih, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_tfril, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_tfrp, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_tfrpi, "LLiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_tfrsi, "iIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vabsh, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vabshsat, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vabsw, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vabswsat, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vaddb_map, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vaddh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vaddhs, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vaddub, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vaddubs, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vadduhs, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vaddw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vaddws, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavgh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavghcr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavghr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavgub, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavgubr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavguh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavguhr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavguw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavguwr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavgw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavgwcr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vavgwr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vcmpbeq, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vcmpbgtu, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vcmpheq, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vcmphgt, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vcmphgtu, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vcmpweq, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vcmpwgt, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vcmpwgtu, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vconj, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vmaxb, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vmaxh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vmaxub, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vmaxuh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vmaxuw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vmaxw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vminb, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vminh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vminub, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vminuh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vminuw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vminw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vnavgh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vnavghcr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vnavghr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vnavgw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vnavgwcr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vnavgwr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vraddub, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vraddub_acc, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vrsadub, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vrsadub_acc, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vsubb_map, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vsubh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vsubhs, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vsubub, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vsububs, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vsubuhs, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vsubw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_vsubws, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_xor, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_xorp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_zxtb, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A2_zxth, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_andn, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_andnp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_bitsplit, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_bitspliti, "LLiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_boundscheck, "iiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_cmpbeq, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_cmpbeqi, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_cmpbgt, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_cmpbgti, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_cmpbgtu, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_cmpbgtui, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_cmpheq, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_cmpheqi, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_cmphgt, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_cmphgti, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_cmphgtu, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_cmphgtui, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_combineir, "LLiIii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_combineri, "LLiiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_cround_ri, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_cround_rr, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_modwrapu, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_orn, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_ornp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_rcmpeq, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_rcmpeqi, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_rcmpneq, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_rcmpneqi, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_round_ri, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_round_ri_sat, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_round_rr, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_round_rr_sat, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_tlbmatch, "iLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpbeq_any, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpbeqi, "iLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpbgt, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpbgti, "iLLiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpbgtui, "iLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpheqi, "iLLiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmphgti, "iLLiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmphgtui, "iLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpweqi, "iLLiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpwgti, "iLLiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vcmpwgtui, "iLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vrmaxh, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vrmaxuh, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vrmaxuw, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vrmaxw, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vrminh, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vrminuh, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vrminuw, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A4_vrminw, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_A5_vaddhubs, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_all8, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_and, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_andn, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_any8, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_bitsclr, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_bitsclri, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_bitsset, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpeq, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpeqi, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpeqp, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgei, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgeui, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgt, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgti, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgtp, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgtu, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgtui, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpgtup, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmplt, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_cmpltu, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_mask, "LLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_mux, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_muxii, "iiIiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_muxir, "iiiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_muxri, "iiIii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_not, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_or, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_orn, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_pxfer_map, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_tfrpr, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_tfrrp, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_vitpack, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_vmux, "LLiiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C2_xor, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_and_and, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_and_andn, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_and_or, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_and_orn, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_cmplte, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_cmpltei, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_cmplteu, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_cmplteui, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_cmpneq, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_cmpneqi, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_fastcorner9, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_fastcorner9_not, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_nbitsclr, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_nbitsclri, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_nbitsset, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_or_and, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_or_andn, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_or_or, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_C4_or_orn, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_d2df, "dLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_d2sf, "fLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2d, "LLid", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2d_chop, "LLid", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2sf, "fd", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2ud, "LLid", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2ud_chop, "LLid", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2uw, "id", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2uw_chop, "id", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2w, "id", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_df2w_chop, "id", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2d, "LLif", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2d_chop, "LLif", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2df, "df", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2ud, "LLif", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2ud_chop, "LLif", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2uw, "if", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2uw_chop, "if", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2w, "if", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_sf2w_chop, "if", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_ud2df, "dLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_ud2sf, "fLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_uw2df, "di", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_uw2sf, "fi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_w2df, "di", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_conv_w2sf, "fi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfclass, "idUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfcmpeq, "idd", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfcmpge, "idd", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfcmpgt, "idd", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfcmpuo, "idd", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfimm_n, "dUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfimm_p, "dUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfadd, "fff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfclass, "ifUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfcmpeq, "iff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfcmpge, "iff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfcmpgt, "iff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfcmpuo, "iff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sffixupd, "fff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sffixupn, "fff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sffixupr, "ff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sffma, "ffff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sffma_lib, "ffff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sffma_sc, "ffffi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sffms, "ffff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sffms_lib, "ffff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfimm_n, "fUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfimm_p, "fUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfmax, "fff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfmin, "fff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfmpy, "fff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_F2_sfsub, "fff", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_acci, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_accii, "iiiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmaci_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmacr_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmacs_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmacs_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmacsc_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmacsc_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpyi_s0, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpyr_s0, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpyrs_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpyrs_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpyrsc_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpyrsc_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpys_s0, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpys_s1, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpysc_s0, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cmpysc_s1, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cnacs_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cnacs_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cnacsc_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_cnacsc_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_dpmpyss_acc_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_dpmpyss_nac_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_dpmpyss_rnd_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_dpmpyss_s0, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_dpmpyuu_acc_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_dpmpyuu_nac_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_dpmpyuu_s0, "ULLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_hmmpyh_rs1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_hmmpyh_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_hmmpyl_rs1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_hmmpyl_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_maci, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_macsin, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_macsip, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmachs_rs0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmachs_rs1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmachs_s0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmachs_s1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacls_rs0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacls_rs1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacls_s0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacls_s1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacuhs_rs0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacuhs_rs1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacuhs_s0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmacuhs_s1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmaculs_rs0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmaculs_rs1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmaculs_s0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmaculs_s1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyh_rs0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyh_rs1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyh_s0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyh_s1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyl_rs0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyl_rs1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyl_s0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyl_s1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyuh_rs0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyuh_rs1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyuh_s0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyuh_s1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyul_rs0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyul_rs1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyul_s0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mmpyul_s1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_hh_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_hh_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_hl_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_hl_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_lh_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_lh_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_ll_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_ll_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_sat_hh_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_sat_hh_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_sat_hl_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_sat_hl_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_sat_lh_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_sat_lh_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_sat_ll_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_acc_sat_ll_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_hh_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_hh_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_hl_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_hl_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_lh_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_lh_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_ll_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_ll_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_hh_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_hh_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_hl_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_hl_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_lh_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_lh_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_ll_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_ll_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_hh_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_hh_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_hl_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_hl_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_lh_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_lh_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_ll_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_nac_sat_ll_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_rnd_hh_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_rnd_hh_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_rnd_hl_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_rnd_hl_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_rnd_lh_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_rnd_lh_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_rnd_ll_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_rnd_ll_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_hh_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_hh_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_hl_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_hl_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_lh_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_lh_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_ll_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_ll_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_rnd_hh_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_rnd_hh_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_rnd_hl_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_rnd_hl_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_rnd_lh_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_rnd_lh_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_rnd_ll_s0, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_sat_rnd_ll_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_up, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_up_s1, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpy_up_s1_sat, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_acc_hh_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_acc_hh_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_acc_hl_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_acc_hl_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_acc_lh_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_acc_lh_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_acc_ll_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_acc_ll_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_hh_s0, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_hh_s1, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_hl_s0, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_hl_s1, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_lh_s0, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_lh_s1, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_ll_s0, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_ll_s1, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_hh_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_hh_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_hl_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_hl_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_lh_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_lh_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_ll_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_nac_ll_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_rnd_hh_s0, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_rnd_hh_s1, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_rnd_hl_s0, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_rnd_hl_s1, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_rnd_lh_s0, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_rnd_lh_s1, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_rnd_ll_s0, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyd_rnd_ll_s1, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyi, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpysmi, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpysu_up, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_acc_hh_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_acc_hh_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_acc_hl_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_acc_hl_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_acc_lh_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_acc_lh_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_acc_ll_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_acc_ll_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_hh_s0, "Uiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_hh_s1, "Uiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_hl_s0, "Uiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_hl_s1, "Uiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_lh_s0, "Uiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_lh_s1, "Uiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_ll_s0, "Uiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_ll_s1, "Uiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_hh_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_hh_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_hl_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_hl_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_lh_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_lh_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_ll_s0, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_nac_ll_s1, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyu_up, "Uiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_acc_hh_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_acc_hh_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_acc_hl_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_acc_hl_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_acc_lh_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_acc_lh_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_acc_ll_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_acc_ll_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_hh_s0, "ULLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_hh_s1, "ULLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_hl_s0, "ULLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_hl_s1, "ULLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_lh_s0, "ULLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_lh_s1, "ULLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_ll_s0, "ULLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_ll_s1, "ULLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_hh_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_hh_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_hl_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_hl_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_lh_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_lh_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_ll_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyud_nac_ll_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mpyui, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_nacci, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_naccii, "iiiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_subacc, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vabsdiffh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vabsdiffw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vcmac_s0_sat_i, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vcmac_s0_sat_r, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vcmpy_s0_sat_i, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vcmpy_s0_sat_r, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vcmpy_s1_sat_i, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vcmpy_s1_sat_r, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vdmacs_s0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vdmacs_s1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vdmpyrs_s0, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vdmpyrs_s1, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vdmpys_s0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vdmpys_s1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmac2, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmac2es, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmac2es_s0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmac2es_s1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmac2s_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmac2s_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmac2su_s0, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmac2su_s1, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmpy2es_s0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmpy2es_s1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmpy2s_s0, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmpy2s_s0pack, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmpy2s_s1, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmpy2s_s1pack, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmpy2su_s0, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vmpy2su_s1, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vraddh, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vradduh, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmaci_s0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmaci_s0c, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmacr_s0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmacr_s0c, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmpyi_s0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmpyi_s0c, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmpyr_s0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmpyr_s0c, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmpys_acc_s1, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmpys_s1, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vrcmpys_s1rp, "iLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vrmac_s0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_vrmpy_s0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M2_xor_xacc, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_and_and, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_and_andn, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_and_or, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_and_xor, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_cmpyi_wh, "iLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_cmpyi_whc, "iLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_cmpyr_wh, "iLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_cmpyr_whc, "iLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_mac_up_s1_sat, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_mpyri_addi, "iUIiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_mpyri_addr, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_mpyri_addr_u2, "iiUIii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_mpyrr_addi, "iUIiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_mpyrr_addr, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_nac_up_s1_sat, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_or_and, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_or_andn, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_or_or, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_or_xor, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_pmpyw, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_pmpyw_acc, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_vpmpyh, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_vpmpyh_acc, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyeh_acc_s0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyeh_acc_s1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyeh_s0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyeh_s1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyoh_acc_s0, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyoh_acc_s1, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyoh_s0, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_vrmpyoh_s1, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_xor_and, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_xor_andn, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_xor_or, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M4_xor_xacc, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M5_vdmacbsu, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M5_vdmpybsu, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M5_vmacbsu, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M5_vmacbuu, "LLiLLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M5_vmpybsu, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M5_vmpybuu, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M5_vrmacbsu, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M5_vrmacbuu, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M5_vrmpybsu, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_M5_vrmpybuu, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_addasl_rrri, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_p, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_p_acc, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_p_and, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_p_nac, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_p_or, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_p_xacc, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_r, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_r_acc, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_r_and, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_r_nac, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_r_or, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_r_sat, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_r_xacc, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_vh, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_i_vw, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_p, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_p_acc, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_p_and, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_p_nac, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_p_or, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_p_xor, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_r, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_r_acc, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_r_and, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_r_nac, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_r_or, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_r_sat, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_vh, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asl_r_vw, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_p, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_p_acc, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_p_and, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_p_nac, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_p_or, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_p_rnd, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_p_rnd_goodsyntax, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_r, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_r_acc, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_r_and, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_r_nac, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_r_or, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_r_rnd, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_r_rnd_goodsyntax, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_svw_trun, "iLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_vh, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_i_vw, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_p, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_p_acc, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_p_and, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_p_nac, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_p_or, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_p_xor, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_r, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_r_acc, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_r_and, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_r_nac, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_r_or, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_r_sat, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_svw_trun, "iLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_vh, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_asr_r_vw, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_brev, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_brevp, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_cl0, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_cl0p, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_cl1, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_cl1p, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_clb, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_clbnorm, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_clbp, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_clrbit_i, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_clrbit_r, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_ct0, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_ct0p, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_ct1, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_ct1p, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_deinterleave, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_extractu, "iiUIiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_extractu_rp, "iiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_extractup, "LLiLLiUIiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_extractup_rp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_insert, "iiiUIiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_insert_rp, "iiiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_insertp, "LLiLLiLLiUIiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_insertp_rp, "LLiLLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_interleave, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lfsp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_p, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_p_acc, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_p_and, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_p_nac, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_p_or, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_p_xor, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_r, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_r_acc, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_r_and, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_r_nac, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_r_or, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_vh, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsl_r_vw, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_p, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_p_acc, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_p_and, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_p_nac, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_p_or, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_p_xacc, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_r, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_r_acc, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_r_and, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_r_nac, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_r_or, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_r_xacc, "iiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_vh, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_i_vw, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_p, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_p_acc, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_p_and, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_p_nac, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_p_or, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_p_xor, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_r, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_r_acc, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_r_and, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_r_nac, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_r_or, "iiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_vh, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_lsr_r_vw, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_packhl, "LLiii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_parityp, "iLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_setbit_i, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_setbit_r, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_shuffeb, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_shuffeh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_shuffob, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_shuffoh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_svsathb, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_svsathub, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_tableidxb_goodsyntax, "iiiUIiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_tableidxd_goodsyntax, "iiiUIiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_tableidxh_goodsyntax, "iiiUIiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_tableidxw_goodsyntax, "iiiUIiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_togglebit_i, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_togglebit_r, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_tstbit_i, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_tstbit_r, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_valignib, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_valignrb, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vcnegh, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vcrotate, "LLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vrcnegh, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vrndpackwh, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vrndpackwhs, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vsathb, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vsathb_nopack, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vsathub, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vsathub_nopack, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vsatwh, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vsatwh_nopack, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vsatwuh, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vsatwuh_nopack, "LLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vsplatrb, "ii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vsplatrh, "LLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vspliceib, "LLiLLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vsplicerb, "LLiLLiLLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vsxtbh, "LLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vsxthw, "LLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vtrunehb, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vtrunewh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vtrunohb, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vtrunowh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vzxtbh, "LLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S2_vzxthw, "LLii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_addaddi, "iiiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_addi_asl_ri, "iUIiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_addi_lsr_ri, "iUIiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_andi_asl_ri, "iUIiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_andi_lsr_ri, "iUIiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_clbaddi, "iiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_clbpaddi, "iLLiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_clbpnorm, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_extract, "iiUIiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_extract_rp, "iiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_extractp, "LLiLLiUIiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_extractp_rp, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_lsli, "iIii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_ntstbit_i, "iiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_ntstbit_r, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_or_andi, "iiiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_or_andix, "iiiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_or_ori, "iiiIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_ori_asl_ri, "iUIiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_ori_lsr_ri, "iUIiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_parity, "iii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_subaddi, "iiIii", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_subi_asl_ri, "iUIiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_subi_lsr_ri, "iUIiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_vrcrotate, "LLiLLiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_vrcrotate_acc, "LLiLLiLLiiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_vxaddsubh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_vxaddsubhr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_vxaddsubw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_vxsubaddh, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_vxsubaddhr, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S4_vxsubaddw, "LLiLLiLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S5_asrhub_rnd_sat_goodsyntax, "iLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S5_asrhub_sat, "iLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S5_popcountp, "iLLi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_S5_vasrhrnd_goodsyntax, "LLiLLiUIi", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_Y2_dccleana, "vv*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_Y2_dccleaninva, "vv*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_Y2_dcfetch, "vv*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_Y2_dcinva, "vv*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_Y2_dczeroa, "vv*", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_Y4_l2fetch, "vv*i", "", V5) -TARGET_BUILTIN(__builtin_HEXAGON_Y5_l2fetch, "vv*LLi", "", V5) - -// V60 Scalar Instructions. - -TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_p, "LLiLLiUIi", "", V60) -TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_p_acc, "LLiLLiLLiUIi", "", V60) -TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_p_and, "LLiLLiLLiUIi", "", V60) -TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_p_nac, "LLiLLiLLiUIi", "", V60) -TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_p_or, "LLiLLiLLiUIi", "", V60) -TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_p_xacc, "LLiLLiLLiUIi", "", V60) -TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_r, "iiUIi", "", V60) -TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_r_acc, "iiiUIi", "", V60) -TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_r_and, "iiiUIi", "", V60) -TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_r_nac, "iiiUIi", "", V60) -TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_r_or, "iiiUIi", "", V60) -TARGET_BUILTIN(__builtin_HEXAGON_S6_rol_i_r_xacc, "iiiUIi", "", V60) - -// V62 Scalar Instructions. - -TARGET_BUILTIN(__builtin_HEXAGON_M6_vabsdiffb, "LLiLLiLLi", "", V62) -TARGET_BUILTIN(__builtin_HEXAGON_M6_vabsdiffub, "LLiLLiLLi", "", V62) -TARGET_BUILTIN(__builtin_HEXAGON_S6_vsplatrbp, "LLii", "", V62) -TARGET_BUILTIN(__builtin_HEXAGON_S6_vtrunehb_ppp, "LLiLLiLLi", "", V62) -TARGET_BUILTIN(__builtin_HEXAGON_S6_vtrunohb_ppp, "LLiLLiLLi", "", V62) - -// V65 Scalar Instructions. - -TARGET_BUILTIN(__builtin_HEXAGON_A6_vcmpbeq_notany, "iLLiLLi", "", V65) - -// V66 Scalar Instructions. - -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfadd, "ddd", "", V66) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfsub, "ddd", "", V66) -TARGET_BUILTIN(__builtin_HEXAGON_M2_mnaci, "iiii", "", V66) -TARGET_BUILTIN(__builtin_HEXAGON_S2_mask, "iUIiUIi", "", V66) - -// V67 Scalar Instructions. - -TARGET_BUILTIN(__builtin_HEXAGON_A7_clip, "iiUIi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_A7_croundd_ri, "LLiLLiUIi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_A7_croundd_rr, "LLiLLii", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_A7_vclip, "LLiLLiUIi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfmax, "ddd", "", V67) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfmin, "ddd", "", V67) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfmpyfix, "ddd", "", V67) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfmpyhh, "dddd", "", V67) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfmpylh, "dddd", "", V67) -TARGET_BUILTIN(__builtin_HEXAGON_F2_dfmpyll, "ddd", "", V67) -TARGET_BUILTIN(__builtin_HEXAGON_M7_dcmpyiw, "LLiLLiLLi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_M7_dcmpyiw_acc, "LLiLLiLLiLLi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_M7_dcmpyiwc, "LLiLLiLLi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_M7_dcmpyiwc_acc, "LLiLLiLLiLLi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_M7_dcmpyrw, "LLiLLiLLi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_M7_dcmpyrw_acc, "LLiLLiLLiLLi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_M7_dcmpyrwc, "LLiLLiLLi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_M7_dcmpyrwc_acc, "LLiLLiLLiLLi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_M7_vdmpy, "LLiLLiLLi", "", V67) -TARGET_BUILTIN(__builtin_HEXAGON_M7_vdmpy_acc, "LLiLLiLLiLLi", "", V67) -TARGET_BUILTIN(__builtin_HEXAGON_M7_wcmpyiw, "iLLiLLi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_M7_wcmpyiw_rnd, "iLLiLLi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_M7_wcmpyiwc, "iLLiLLi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_M7_wcmpyiwc_rnd, "iLLiLLi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_M7_wcmpyrw, "iLLiLLi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_M7_wcmpyrw_rnd, "iLLiLLi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_M7_wcmpyrwc, "iLLiLLi", "", "audio") -TARGET_BUILTIN(__builtin_HEXAGON_M7_wcmpyrwc_rnd, "iLLiLLi", "", "audio") - -// V68 Scalar Instructions. - -TARGET_BUILTIN(__builtin_HEXAGON_Y6_dmlink, "vv*v*", "", V68) -TARGET_BUILTIN(__builtin_HEXAGON_Y6_dmpause, "i", "", V68) -TARGET_BUILTIN(__builtin_HEXAGON_Y6_dmpoll, "i", "", V68) -TARGET_BUILTIN(__builtin_HEXAGON_Y6_dmresume, "vv*", "", V68) -TARGET_BUILTIN(__builtin_HEXAGON_Y6_dmstart, "vv*", "", V68) -TARGET_BUILTIN(__builtin_HEXAGON_Y6_dmwait, "i", "", V68) - -// V60 HVX Instructions. - -TARGET_BUILTIN(__builtin_HEXAGON_V6_extractw, "iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_extractw_128B, "iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_hi, "V16iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_hi_128B, "V32iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_lo, "V16iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_lo_128B, "V32iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_lvsplatw, "V16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_lvsplatw_128B, "V32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_and, "V64bV64bV64b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_and_128B, "V128bV128bV128b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_and_n, "V64bV64bV64b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_and_n_128B, "V128bV128bV128b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_not, "V64bV64b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_not_128B, "V128bV128b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_or, "V64bV64bV64b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_or_128B, "V128bV128bV128b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_or_n, "V64bV64bV64b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_or_n_128B, "V128bV128bV128b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_scalar2, "V64bi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_scalar2_128B, "V128bi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_xor, "V64bV64bV64b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_xor_128B, "V128bV128bV128b", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vS32b_nqpred_ai, "vV64bv*V16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vS32b_nqpred_ai_128B, "vV128bv*V32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vS32b_nt_nqpred_ai, "vV64bv*V16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vS32b_nt_nqpred_ai_128B, "vV128bv*V32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vS32b_nt_qpred_ai, "vV64bv*V16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vS32b_nt_qpred_ai_128B, "vV128bv*V32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vS32b_qpred_ai, "vV64bv*V16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vS32b_qpred_ai_128B, "vV128bv*V32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffub, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffub_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffuh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffuh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffw, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsdiffw_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsh, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsh_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsh_sat, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsh_sat_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsw, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsw_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsw_sat, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsw_sat_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddb, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddb_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddb_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddb_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddbnq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddbnq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddbq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddbq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddh_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddh_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhnq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhnq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhsat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhsat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhsat_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhsat_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhw, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhw_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddubh, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddubh_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddubsat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddubsat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddubsat_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddubsat_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduhsat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduhsat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduhsat_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduhsat_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduhw, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduhw_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddw, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddw_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddw_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddw_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddwnq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddwnq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddwq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddwq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddwsat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddwsat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddwsat_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddwsat_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_valignb, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_valignb_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_valignbi, "V16iV16iV16iUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_valignbi_128B, "V32iV32iV32iUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vand, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vand_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandqrt, "V16iV64bi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandqrt_128B, "V32iV128bi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandqrt_acc, "V16iV16iV64bi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandqrt_acc_128B, "V32iV32iV128bi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandvrt, "V64bV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandvrt_128B, "V128bV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandvrt_acc, "V64bV64bV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandvrt_acc_128B, "V128bV128bV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslh, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslh_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslhv, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslhv_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslw, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslw_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslw_acc, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslw_acc_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslwv, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslwv_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrh, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrh_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhbrndsat, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhbrndsat_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhubrndsat, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhubrndsat_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhubsat, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhubsat_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhv, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhv_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrw, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrw_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrw_acc, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrw_acc_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwh, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwh_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwhrndsat, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwhrndsat_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwhsat, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwhsat_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwuhsat, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwuhsat_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwv, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwv_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vassign, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vassign_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vassignp, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vassignp_128B, "V64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavghrnd, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavghrnd_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgub, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgub_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgubrnd, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgubrnd_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavguh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavguh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavguhrnd, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavguhrnd_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgw, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgw_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgwrnd, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgwrnd_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcl0h, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcl0h_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcl0w, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcl0w_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcombine, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcombine_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vd0, "V16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vd0_128B, "V32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealb, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealb_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealb4w, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealb4w_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealh, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealh_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealvdd, "V32iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdealvdd_128B, "V64iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdelta, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdelta_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus_acc, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus_acc_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus_dv, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus_dv_128B, "V64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus_dv_acc, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpybus_dv_acc_128B, "V64iV64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb_acc, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb_acc_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb_dv, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb_dv_128B, "V64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb_dv_acc, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhb_dv_acc_128B, "V64iV64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhisat, "V16iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhisat_128B, "V32iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhisat_acc, "V16iV16iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhisat_acc_128B, "V32iV32iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsat, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsat_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsat_acc, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsat_acc_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsuisat, "V16iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsuisat_128B, "V32iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsuisat_acc, "V16iV16iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsuisat_acc_128B, "V32iV32iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsusat, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsusat_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsusat_acc, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhsusat_acc_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhvsat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhvsat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhvsat_acc, "V16iV16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpyhvsat_acc_128B, "V32iV32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdsaduh, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdsaduh_128B, "V64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdsaduh_acc, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdsaduh_acc_128B, "V64iV64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb, "V64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb_128B, "V128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb_and, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb_and_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb_or, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb_or_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb_xor, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqb_xor_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqh, "V64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqh_128B, "V128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqh_and, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqh_and_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqh_or, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqh_or_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqh_xor, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqh_xor_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw, "V64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw_128B, "V128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw_and, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw_and_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw_or, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw_or_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw_xor, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_veqw_xor_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtb, "V64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtb_128B, "V128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtb_and, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtb_and_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtb_or, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtb_or_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtb_xor, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtb_xor_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth, "V64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth_128B, "V128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth_and, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth_and_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth_or, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth_or_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth_xor, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgth_xor_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtub, "V64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtub_128B, "V128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtub_and, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtub_and_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtub_or, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtub_or_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtub_xor, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtub_xor_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh, "V64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh_128B, "V128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh_and, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh_and_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh_or, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh_or_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh_xor, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuh_xor_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw, "V64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw_128B, "V128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw_and, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw_and_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw_or, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw_or_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw_xor, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtuw_xor_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw, "V64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw_128B, "V128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw_and, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw_and_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw_or, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw_or_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw_xor, "V64bV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtw_xor_128B, "V128bV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vinsertwr, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vinsertwr_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlalignb, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlalignb_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlalignbi, "V16iV16iV16iUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlalignbi_128B, "V32iV32iV32iUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrh, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrh_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrhv, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrhv_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrw, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrw_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrwv, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrwv_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb_oracc, "V16iV16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb_oracc_128B, "V32iV32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh, "V32iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh_128B, "V64iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh_oracc, "V32iV32iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh_oracc_128B, "V64iV64iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaxh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaxh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaxub, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaxub_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaxuh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaxuh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaxw, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaxw_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vminh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vminh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vminub, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vminub_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vminuh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vminuh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vminw, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vminw_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabus, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabus_128B, "V64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabus_acc, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabus_acc_128B, "V64iV64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabusv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabusv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabuuv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabuuv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpahb, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpahb_128B, "V64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpahb_acc, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpahb_acc_128B, "V64iV64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybus, "V32iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybus_128B, "V64iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybus_acc, "V32iV32iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybus_acc_128B, "V64iV64iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybusv, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybusv_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybusv_acc, "V32iV32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybusv_acc_128B, "V64iV64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybv, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybv_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybv_acc, "V32iV32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpybv_acc_128B, "V64iV64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyewuh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyewuh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyh, "V32iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyh_128B, "V64iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhsat_acc, "V32iV32iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhsat_acc_128B, "V64iV64iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhsrs, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhsrs_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhss, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhss_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhus, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhus_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhus_acc, "V32iV32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhus_acc_128B, "V64iV64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhv, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhv_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhv_acc, "V32iV32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhv_acc_128B, "V64iV64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhvsrs, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyhvsrs_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyieoh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyieoh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiewh_acc, "V16iV16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiewh_acc_128B, "V32iV32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiewuh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiewuh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiewuh_acc, "V16iV16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiewuh_acc_128B, "V32iV32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyih, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyih_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyih_acc, "V16iV16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyih_acc_128B, "V32iV32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyihb, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyihb_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyihb_acc, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyihb_acc_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiowh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiowh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwb, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwb_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwb_acc, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwb_acc_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwh, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwh_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwh_acc, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwh_acc_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_rnd, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_rnd_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_rnd_sacc, "V16iV16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_rnd_sacc_128B, "V32iV32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_sacc, "V16iV16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_sacc_128B, "V32iV32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyub, "V32iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyub_128B, "V64iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyub_acc, "V32iV32iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyub_acc_128B, "V64iV64iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyubv, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyubv_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyubv_acc, "V32iV32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyubv_acc_128B, "V64iV64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuh, "V32iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuh_128B, "V64iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuh_acc, "V32iV32iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuh_acc_128B, "V64iV64iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhv, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhv_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhv_acc, "V32iV32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhv_acc_128B, "V64iV64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmux, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmux_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgub, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgub_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgw, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgw_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnormamth, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnormamth_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnormamtw, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnormamtw_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnot, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnot_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vor, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vor_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackeb, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackeb_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackeh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackeh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackhb_sat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackhb_sat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackhub_sat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackhub_sat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackob, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackob_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackoh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackoh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackwh_sat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackwh_sat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackwuh_sat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpackwuh_sat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpopcounth, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vpopcounth_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrdelta, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrdelta_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybus, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybus_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybus_acc, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybus_acc_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusi, "V32iV32iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusi_128B, "V64iV64iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusi_acc, "V32iV32iV32iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusi_acc_128B, "V64iV64iV64iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusv, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusv_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusv_acc, "V16iV16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybusv_acc_128B, "V32iV32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybv, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybv_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybv_acc, "V16iV16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpybv_acc_128B, "V32iV32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_acc, "V16iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_acc_128B, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubi, "V32iV32iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubi_128B, "V64iV64iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubi_acc, "V32iV32iV32iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubi_acc_128B, "V64iV64iV64iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubv, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubv_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubv_acc, "V16iV16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyubv_acc_128B, "V32iV32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vror, "V16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vror_128B, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundhb, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundhb_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundhub, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundhub_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundwh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundwh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundwuh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vroundwuh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrsadubi, "V32iV32iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrsadubi_128B, "V64iV64iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrsadubi_acc, "V32iV32iV32iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrsadubi_acc_128B, "V64iV64iV64iiUIi", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsathub, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsathub_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsatwh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsatwh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsb, "V32iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsb_128B, "V64iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsh, "V32iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsh_128B, "V64iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshufeh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshufeh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffb, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffb_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffeb, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffeb_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffh, "V16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffh_128B, "V32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffob, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffob_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffvdd, "V32iV16iV16ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshuffvdd_128B, "V64iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshufoeb, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshufoeb_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshufoeh, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshufoeh_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshufoh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vshufoh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubb, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubb_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubb_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubb_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbnq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbnq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubh, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubh_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubh_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubh_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhnq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhnq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhsat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhsat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhsat_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhsat_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhw, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubhw_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsububh, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsububh_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsububsat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsububsat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsububsat_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsububsat_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuhsat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuhsat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuhsat_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuhsat_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuhw, "V32iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuhw_128B, "V64iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubw, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubw_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubw_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubw_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwnq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwnq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwq, "V16iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwq_128B, "V32iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwsat, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwsat_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwsat_dv, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubwsat_dv_128B, "V64iV64iV64i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vswap, "V32iV64bV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vswap_128B, "V64iV128bV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyb, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyb_128B, "V64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyb_acc, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyb_acc_128B, "V64iV64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpybus, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpybus_128B, "V64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpybus_acc, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpybus_acc_128B, "V64iV64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyhb, "V32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyhb_128B, "V64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyhb_acc, "V32iV32iV32ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vtmpyhb_acc_128B, "V64iV64iV64ii", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackb, "V32iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackb_128B, "V64iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackh, "V32iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackh_128B, "V64iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackob, "V32iV32iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackob_128B, "V64iV64iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackoh, "V32iV32iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackoh_128B, "V64iV64iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackub, "V32iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackub_128B, "V64iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackuh, "V32iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vunpackuh_128B, "V64iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vxor, "V16iV16iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vxor_128B, "V32iV32iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vzb, "V32iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vzb_128B, "V64iV32i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vzh, "V32iV16i", "", HVXV60) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vzh_128B, "V64iV32i", "", HVXV60) - -// V62 HVX Instructions. - -TARGET_BUILTIN(__builtin_HEXAGON_V6_lvsplatb, "V16ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_lvsplatb_128B, "V32ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_lvsplath, "V16ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_lvsplath_128B, "V32ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_scalar2v2, "V64bi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_pred_scalar2v2_128B, "V128bi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_shuffeqh, "V64bV64bV64b", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_shuffeqh_128B, "V128bV128bV128b", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_shuffeqw, "V64bV64bV64b", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_shuffeqw_128B, "V128bV128bV128b", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddbsat, "V16iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddbsat_128B, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddbsat_dv, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddbsat_dv_128B, "V64iV64iV64i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddcarry, "V16iV16iV16iv*", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddcarry_128B, "V32iV32iV32iv*", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddclbh, "V16iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddclbh_128B, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddclbw, "V16iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddclbw_128B, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhw_acc, "V32iV32iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddhw_acc_128B, "V64iV64iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddubh_acc, "V32iV32iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddubh_acc_128B, "V64iV64iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddububb_sat, "V16iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddububb_sat_128B, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduhw_acc, "V32iV32iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduhw_acc_128B, "V64iV64iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduwsat, "V16iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduwsat_128B, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduwsat_dv, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadduwsat_dv_128B, "V64iV64iV64i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandnqrt, "V16iV64bi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandnqrt_128B, "V32iV128bi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandnqrt_acc, "V16iV16iV64bi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandnqrt_acc_128B, "V32iV32iV128bi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandvnqv, "V16iV64bV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandvnqv_128B, "V32iV128bV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandvqv, "V16iV64bV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vandvqv_128B, "V32iV128bV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhbsat, "V16iV16iV16ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrhbsat_128B, "V32iV32iV32ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruwuhrndsat, "V16iV16iV16ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruwuhrndsat_128B, "V32iV32iV32ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwuhrndsat, "V16iV16iV16ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrwuhrndsat_128B, "V32iV32iV32ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrb, "V16iV16ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlsrb_128B, "V32iV32ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb_nm, "V16iV16iV16ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb_nm_128B, "V32iV32iV32ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb_oracci, "V16iV16iV16iV16iUIi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvb_oracci_128B, "V32iV32iV32iV32iUIi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvbi, "V16iV16iV16iUIi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvvbi_128B, "V32iV32iV32iUIi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh_nm, "V32iV16iV16ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh_nm_128B, "V64iV32iV32ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh_oracci, "V32iV32iV16iV16iUIi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwh_oracci_128B, "V64iV64iV32iV32iUIi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwhi, "V32iV16iV16iUIi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlutvwhi_128B, "V64iV32iV32iUIi", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaxb, "V16iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmaxb_128B, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vminb, "V16iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vminb_128B, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpauhb, "V32iV32ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpauhb_128B, "V64iV64ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpauhb_acc, "V32iV32iV32ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpauhb_acc_128B, "V64iV64iV64ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyewuh_64, "V32iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyewuh_64_128B, "V64iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwub, "V16iV16ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwub_128B, "V32iV32ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwub_acc, "V16iV16iV16ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyiwub_acc_128B, "V32iV32iV32ii", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_64_acc, "V32iV32iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyowh_64_acc_128B, "V64iV64iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrounduhub, "V16iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrounduhub_128B, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrounduwuh, "V16iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrounduwuh_128B, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsatuwuh, "V16iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsatuwuh_128B, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbsat, "V16iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbsat_128B, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbsat_dv, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubbsat_dv_128B, "V64iV64iV64i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubcarry, "V16iV16iV16iv*", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubcarry_128B, "V32iV32iV32iv*", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubububb_sat, "V16iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubububb_sat_128B, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuwsat, "V16iV16iV16i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuwsat_128B, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuwsat_dv, "V32iV32iV32i", "", HVXV62) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubuwsat_dv_128B, "V64iV64iV64i", "", HVXV62) - -// V65 HVX Instructions. - -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsb, "V16iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsb_128B, "V32iV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsb_sat, "V16iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabsb_sat_128B, "V32iV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslh_acc, "V16iV16iV16ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaslh_acc_128B, "V32iV32iV32ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrh_acc, "V16iV16iV16ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrh_acc_128B, "V32iV32iV32ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruhubrndsat, "V16iV16iV16ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruhubrndsat_128B, "V32iV32iV32ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruhubsat, "V16iV16iV16ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruhubsat_128B, "V32iV32iV32ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruwuhsat, "V16iV16iV16ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasruwuhsat_128B, "V32iV32iV32ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgb, "V16iV16iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgb_128B, "V32iV32iV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgbrnd, "V16iV16iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavgbrnd_128B, "V32iV32iV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavguw, "V16iV16iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavguw_128B, "V32iV32iV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavguwrnd, "V16iV16iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vavguwrnd_128B, "V32iV32iV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdd0, "V32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdd0_128B, "V64i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermh, "vv*iiV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermh_128B, "vv*iiV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermhq, "vv*V64biiV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermhq_128B, "vv*V128biiV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermhw, "vv*iiV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermhw_128B, "vv*iiV64i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermhwq, "vv*V64biiV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermhwq_128B, "vv*V128biiV64i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermw, "vv*iiV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermw_128B, "vv*iiV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermwq, "vv*V64biiV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgathermwq_128B, "vv*V128biiV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlut4, "V16iV16iLLi", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vlut4_128B, "V32iV32iLLi", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabuu, "V32iV32ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabuu_128B, "V64iV64ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabuu_acc, "V32iV32iV32ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpabuu_acc_128B, "V64iV64iV64ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpahhsat, "V16iV16iV16iLLi", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpahhsat_128B, "V32iV32iV32iLLi", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpauhuhsat, "V16iV16iV16iLLi", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpauhuhsat_128B, "V32iV32iV32iLLi", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpsuhuhsat, "V16iV16iV16iLLi", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpsuhuhsat_128B, "V32iV32iV32iLLi", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyh_acc, "V32iV32iV16ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyh_acc_128B, "V64iV64iV32ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhe, "V16iV16ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhe_128B, "V32iV32ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhe_acc, "V16iV16iV16ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhe_acc_128B, "V32iV32iV32ii", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgb, "V16iV16iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vnavgb_128B, "V32iV32iV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vprefixqb, "V16iV64b", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vprefixqb_128B, "V32iV128b", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vprefixqh, "V16iV64b", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vprefixqh_128B, "V32iV128b", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vprefixqw, "V16iV64b", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vprefixqw_128B, "V32iV128b", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermh, "viiV16iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermh_128B, "viiV32iV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermh_add, "viiV16iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermh_add_128B, "viiV32iV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermhq, "vV64biiV16iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermhq_128B, "vV128biiV32iV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermhw, "viiV32iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermhw_128B, "viiV64iV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermhw_add, "viiV32iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermhw_add_128B, "viiV64iV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermhwq, "vV64biiV32iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermhwq_128B, "vV128biiV64iV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermw, "viiV16iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermw_128B, "viiV32iV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermw_add, "viiV16iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermw_add_128B, "viiV32iV32i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermwq, "vV64biiV16iV16i", "", HVXV65) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vscattermwq_128B, "vV128biiV32iV32i", "", HVXV65) - -// V66 HVX Instructions. - -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddcarryo, "V16iV16iV16iv*", "", HVXV66) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddcarryo_128B, "V32iV32iV32iv*", "", HVXV66) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddcarrysat, "V16iV16iV16iV64b", "", HVXV66) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vaddcarrysat_128B, "V32iV32iV32iV128b", "", HVXV66) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasr_into, "V32iV32iV16iV16i", "", HVXV66) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasr_into_128B, "V64iV64iV32iV32i", "", HVXV66) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrotr, "V16iV16iV16i", "", HVXV66) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vrotr_128B, "V32iV32iV32i", "", HVXV66) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsatdw, "V16iV16iV16i", "", HVXV66) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsatdw_128B, "V32iV32iV32i", "", HVXV66) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubcarryo, "V16iV16iV16iv*", "", HVXV66) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsubcarryo_128B, "V32iV32iV32iv*", "", HVXV66) - -// V68 HVX Instructions. - -TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyhubs10, "V32iV32iV32iUIi", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyhubs10_128B, "V64iV64iV64iUIi", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyhubs10_vxx, "V32iV32iV32iV32iUIi", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyhubs10_vxx_128B, "V64iV64iV64iV64iUIi", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyvubs10, "V32iV32iV32iUIi", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyvubs10_128B, "V64iV64iV64iUIi", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyvubs10_vxx, "V32iV32iV32iV32iUIi", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyvubs10_vxx_128B, "V64iV64iV64iV64iUIi", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabs_hf, "V16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabs_hf_128B, "V32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabs_sf, "V16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabs_sf_128B, "V32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_hf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_hf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_hf_hf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_hf_hf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf16, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf16_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf16_mix, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf16_mix_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf32, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf32_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf32_mix, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf32_mix_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf_hf, "V32iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf_hf_128B, "V64iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf_sf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf_sf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vassign_fp, "V16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vassign_fp_128B, "V32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_hf_qf16, "V16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_hf_qf16_128B, "V32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_hf_qf32, "V16iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_hf_qf32_128B, "V32iV64i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_sf_qf32, "V16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_sf_qf32_128B, "V32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_b_hf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_b_hf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_h_hf, "V16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_h_hf_128B, "V32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_hf_b, "V32iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_hf_b_128B, "V64iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_hf_h, "V16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_hf_h_128B, "V32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_hf_sf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_hf_sf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_hf_ub, "V32iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_hf_ub_128B, "V64iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_hf_uh, "V16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_hf_uh_128B, "V32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_sf_hf, "V32iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_sf_hf_128B, "V64iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_ub_hf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_ub_hf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_uh_hf, "V16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_uh_hf_128B, "V32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpy_sf_hf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpy_sf_hf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpy_sf_hf_acc, "V16iV16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpy_sf_hf_acc_128B, "V32iV32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vfmax_hf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vfmax_hf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vfmax_sf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vfmax_sf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vfmin_hf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vfmin_hf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vfmin_sf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vfmin_sf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vfneg_hf, "V16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vfneg_hf_128B, "V32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vfneg_sf, "V16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vfneg_sf_128B, "V32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgthf, "V64bV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgthf_128B, "V128bV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgthf_and, "V64bV64bV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgthf_and_128B, "V128bV128bV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgthf_or, "V64bV64bV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgthf_or_128B, "V128bV128bV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgthf_xor, "V64bV64bV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgthf_xor_128B, "V128bV128bV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtsf, "V64bV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtsf_128B, "V128bV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtsf_and, "V64bV64bV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtsf_and_128B, "V128bV128bV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtsf_or, "V64bV64bV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtsf_or_128B, "V128bV128bV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtsf_xor, "V64bV64bV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtsf_xor_128B, "V128bV128bV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmax_hf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmax_hf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmax_sf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmax_sf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmin_hf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmin_hf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmin_sf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmin_sf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_hf_hf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_hf_hf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_hf_hf_acc, "V16iV16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_hf_hf_acc_128B, "V32iV32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf16, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf16_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf16_hf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf16_hf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf16_mix_hf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf16_mix_hf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf32, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf32_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf32_hf, "V32iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf32_hf_128B, "V64iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf32_mix_hf, "V32iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf32_mix_hf_128B, "V64iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf32_qf16, "V32iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf32_qf16_128B, "V64iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf32_sf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf32_sf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_sf_hf, "V32iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_sf_hf_128B, "V64iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_sf_hf_acc, "V32iV32iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_sf_hf_acc_128B, "V64iV64iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_sf_sf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_sf_sf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_hf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_hf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_hf_hf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_hf_hf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_qf16, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_qf16_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_qf16_mix, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_qf16_mix_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_qf32, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_qf32_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_qf32_mix, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_qf32_mix_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_sf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_sf_128B, "V32iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_sf_hf, "V32iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_sf_hf_128B, "V64iV32iV32i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_sf_sf, "V16iV16iV16i", "", HVXV68) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_sf_sf_128B, "V32iV32iV32i", "", HVXV68) - -// V69 HVX Instructions. - -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrvuhubrndsat, "V16iV32iV16i", "", HVXV69) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrvuhubrndsat_128B, "V32iV64iV32i", "", HVXV69) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrvuhubsat, "V16iV32iV16i", "", HVXV69) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrvuhubsat_128B, "V32iV64iV32i", "", HVXV69) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrvwuhrndsat, "V16iV32iV16i", "", HVXV69) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrvwuhrndsat_128B, "V32iV64iV32i", "", HVXV69) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrvwuhsat, "V16iV32iV16i", "", HVXV69) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrvwuhsat_128B, "V32iV64iV32i", "", HVXV69) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhvs, "V16iV16iV16i", "", HVXV69) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhvs_128B, "V32iV32iV32i", "", HVXV69) - -// V73 HVX Instructions. - -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf_bf, "V32iV16iV16i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf_bf_128B, "V64iV32iV32i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_h_hf, "V16iV16i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_h_hf_128B, "V32iV32i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_hf_h, "V16iV16i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_hf_h_128B, "V32iV32i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_sf_w, "V16iV16i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_sf_w_128B, "V32iV32i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_w_sf, "V16iV16i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_w_sf_128B, "V32iV32i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_bf_sf, "V16iV16iV16i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_bf_sf_128B, "V32iV32iV32i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtbf, "V64bV16iV16i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtbf_128B, "V128bV32iV32i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtbf_and, "V64bV64bV16iV16i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtbf_and_128B, "V128bV128bV32iV32i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtbf_or, "V64bV64bV16iV16i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtbf_or_128B, "V128bV128bV32iV32i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtbf_xor, "V64bV64bV16iV16i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtbf_xor_128B, "V128bV128bV32iV32i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmax_bf, "V16iV16iV16i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmax_bf_128B, "V32iV32iV32i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmin_bf, "V16iV16iV16i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmin_bf_128B, "V32iV32iV32i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_sf_bf, "V32iV16iV16i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_sf_bf_128B, "V64iV32iV32i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_sf_bf_acc, "V32iV32iV16iV16i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_sf_bf_acc_128B, "V64iV64iV32iV32i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_sf_bf, "V32iV16iV16i", "", HVXV73) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_sf_bf_128B, "V64iV32iV32i", "", HVXV73) - -// V79 HVX Instructions. - -TARGET_BUILTIN(__builtin_HEXAGON_V6_get_qfext, "V16iV16ii", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_get_qfext_128B, "V32iV32ii", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_get_qfext_oracc, "V16iV16iV16ii", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_get_qfext_oracc_128B, "V32iV32iV32ii", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_set_qfext, "V16iV16ii", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_set_qfext_128B, "V32iV32ii", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabs_f8, "V16iV16i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vabs_f8_128B, "V32iV32i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_hf_f8, "V32iV16iV16i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_hf_f8_128B, "V64iV32iV32i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt2_b_hf, "V16iV16iV16i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt2_b_hf_128B, "V32iV32iV32i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt2_hf_b, "V32iV16i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt2_hf_b_128B, "V64iV32i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt2_hf_ub, "V32iV16i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt2_hf_ub_128B, "V64iV32i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt2_ub_hf, "V16iV16iV16i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt2_ub_hf_128B, "V32iV32iV32i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_f8_hf, "V16iV16iV16i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_f8_hf_128B, "V32iV32iV32i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_hf_f8, "V32iV16i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_hf_f8_128B, "V64iV32i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vfmax_f8, "V16iV16iV16i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vfmax_f8_128B, "V32iV32iV32i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vfmin_f8, "V16iV16iV16i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vfmin_f8_128B, "V32iV32iV32i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vfneg_f8, "V16iV16i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vfneg_f8_128B, "V32iV32i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmerge_qf, "V16iV16iV16i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmerge_qf_128B, "V32iV32iV32i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_hf_f8, "V32iV16iV16i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_hf_f8_128B, "V64iV32iV32i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_hf_f8_acc, "V32iV32iV16iV16i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_hf_f8_acc_128B, "V64iV64iV32iV32i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_rt_hf, "V16iV16ii", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_rt_hf_128B, "V32iV32ii", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_rt_qf16, "V16iV16ii", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_rt_qf16_128B, "V32iV32ii", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_rt_sf, "V16iV16ii", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_rt_sf_128B, "V32iV32ii", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_hf_f8, "V32iV16iV16i", "", HVXV79) -TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_hf_f8_128B, "V64iV32iV32i", "", HVXV79) diff --git clang/include/clang/Basic/BuiltinsNVPTX.def clang/include/clang/Basic/BuiltinsNVPTX.def deleted file mode 100644 index 37b4e6ff77fd..000000000000 --- clang/include/clang/Basic/BuiltinsNVPTX.def +++ /dev/null @@ -1,1119 +0,0 @@ -//===--- BuiltinsPTX.def - PTX Builtin function database ----*- 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 the PTX-specific builtin function database. Users of -// this file must define the BUILTIN macro to make use of this information. -// -//===----------------------------------------------------------------------===// - -// The format of this database matches clang/Basic/Builtins.def. - -#if defined(BUILTIN) && !defined(TARGET_BUILTIN) -# define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS) -#endif - -#pragma push_macro("SM_53") -#pragma push_macro("SM_70") -#pragma push_macro("SM_72") -#pragma push_macro("SM_75") -#pragma push_macro("SM_80") -#pragma push_macro("SM_86") -#pragma push_macro("SM_87") -#pragma push_macro("SM_89") -#pragma push_macro("SM_90") -#pragma push_macro("SM_90a") -#pragma push_macro("SM_100") -#pragma push_macro("SM_100a") -#define SM_100a "sm_100a" -#define SM_100 "sm_100|" SM_100a -#define SM_90a "sm_90a" -#define SM_90 "sm_90|" SM_90a "|" SM_100 -#define SM_89 "sm_89|" SM_90 -#define SM_87 "sm_87|" SM_89 -#define SM_86 "sm_86|" SM_87 -#define SM_80 "sm_80|" SM_86 -#define SM_75 "sm_75|" SM_80 -#define SM_72 "sm_72|" SM_75 -#define SM_70 "sm_70|" SM_72 - -#pragma push_macro("SM_60") -#define SM_60 "sm_60|sm_61|sm_62|" SM_70 -#define SM_53 "sm_53|" SM_60 - -#pragma push_macro("PTX42") -#pragma push_macro("PTX60") -#pragma push_macro("PTX61") -#pragma push_macro("PTX62") -#pragma push_macro("PTX63") -#pragma push_macro("PTX64") -#pragma push_macro("PTX65") -#pragma push_macro("PTX70") -#pragma push_macro("PTX71") -#pragma push_macro("PTX72") -#pragma push_macro("PTX73") -#pragma push_macro("PTX74") -#pragma push_macro("PTX75") -#pragma push_macro("PTX76") -#pragma push_macro("PTX77") -#pragma push_macro("PTX78") -#pragma push_macro("PTX80") -#pragma push_macro("PTX81") -#pragma push_macro("PTX82") -#pragma push_macro("PTX83") -#pragma push_macro("PTX84") -#pragma push_macro("PTX85") -#pragma push_macro("PTX86") -#define PTX86 "ptx86" -#define PTX85 "ptx85|" PTX86 -#define PTX84 "ptx84|" PTX85 -#define PTX83 "ptx83|" PTX84 -#define PTX82 "ptx82|" PTX83 -#define PTX81 "ptx81|" PTX82 -#define PTX80 "ptx80|" PTX81 -#define PTX78 "ptx78|" PTX80 -#define PTX77 "ptx77|" PTX78 -#define PTX76 "ptx76|" PTX77 -#define PTX75 "ptx75|" PTX76 -#define PTX74 "ptx74|" PTX75 -#define PTX73 "ptx73|" PTX74 -#define PTX72 "ptx72|" PTX73 -#define PTX71 "ptx71|" PTX72 -#define PTX70 "ptx70|" PTX71 -#define PTX65 "ptx65|" PTX70 -#define PTX64 "ptx64|" PTX65 -#define PTX63 "ptx63|" PTX64 -#define PTX62 "ptx62|" PTX63 -#define PTX61 "ptx61|" PTX62 -#define PTX60 "ptx60|" PTX61 -#define PTX42 "ptx42|" PTX60 - -#pragma push_macro("AND") -#define AND(a, b) "(" a "),(" b ")" - -// Special Registers - -BUILTIN(__nvvm_read_ptx_sreg_tid_x, "i", "nc") -BUILTIN(__nvvm_read_ptx_sreg_tid_y, "i", "nc") -BUILTIN(__nvvm_read_ptx_sreg_tid_z, "i", "nc") -BUILTIN(__nvvm_read_ptx_sreg_tid_w, "i", "nc") - -BUILTIN(__nvvm_read_ptx_sreg_ntid_x, "i", "nc") -BUILTIN(__nvvm_read_ptx_sreg_ntid_y, "i", "nc") -BUILTIN(__nvvm_read_ptx_sreg_ntid_z, "i", "nc") -BUILTIN(__nvvm_read_ptx_sreg_ntid_w, "i", "nc") - -BUILTIN(__nvvm_read_ptx_sreg_ctaid_x, "i", "nc") -BUILTIN(__nvvm_read_ptx_sreg_ctaid_y, "i", "nc") -BUILTIN(__nvvm_read_ptx_sreg_ctaid_z, "i", "nc") -BUILTIN(__nvvm_read_ptx_sreg_ctaid_w, "i", "nc") - -BUILTIN(__nvvm_read_ptx_sreg_nctaid_x, "i", "nc") -BUILTIN(__nvvm_read_ptx_sreg_nctaid_y, "i", "nc") -BUILTIN(__nvvm_read_ptx_sreg_nctaid_z, "i", "nc") -BUILTIN(__nvvm_read_ptx_sreg_nctaid_w, "i", "nc") - -TARGET_BUILTIN(__nvvm_read_ptx_sreg_clusterid_x, "i", "nc", AND(SM_90, PTX78)) -TARGET_BUILTIN(__nvvm_read_ptx_sreg_clusterid_y, "i", "nc", AND(SM_90, PTX78)) -TARGET_BUILTIN(__nvvm_read_ptx_sreg_clusterid_z, "i", "nc", AND(SM_90, PTX78)) -TARGET_BUILTIN(__nvvm_read_ptx_sreg_clusterid_w, "i", "nc", AND(SM_90, PTX78)) - -TARGET_BUILTIN(__nvvm_read_ptx_sreg_nclusterid_x, "i", "nc", AND(SM_90, PTX78)) -TARGET_BUILTIN(__nvvm_read_ptx_sreg_nclusterid_y, "i", "nc", AND(SM_90, PTX78)) -TARGET_BUILTIN(__nvvm_read_ptx_sreg_nclusterid_z, "i", "nc", AND(SM_90, PTX78)) -TARGET_BUILTIN(__nvvm_read_ptx_sreg_nclusterid_w, "i", "nc", AND(SM_90, PTX78)) - -TARGET_BUILTIN(__nvvm_read_ptx_sreg_cluster_ctaid_x, "i", "nc", AND(SM_90, PTX78)) -TARGET_BUILTIN(__nvvm_read_ptx_sreg_cluster_ctaid_y, "i", "nc", AND(SM_90, PTX78)) -TARGET_BUILTIN(__nvvm_read_ptx_sreg_cluster_ctaid_z, "i", "nc", AND(SM_90, PTX78)) -TARGET_BUILTIN(__nvvm_read_ptx_sreg_cluster_ctaid_w, "i", "nc", AND(SM_90, PTX78)) - -TARGET_BUILTIN(__nvvm_read_ptx_sreg_cluster_nctaid_x, "i", "nc", AND(SM_90, PTX78)) -TARGET_BUILTIN(__nvvm_read_ptx_sreg_cluster_nctaid_y, "i", "nc", AND(SM_90, PTX78)) -TARGET_BUILTIN(__nvvm_read_ptx_sreg_cluster_nctaid_z, "i", "nc", AND(SM_90, PTX78)) -TARGET_BUILTIN(__nvvm_read_ptx_sreg_cluster_nctaid_w, "i", "nc", AND(SM_90, PTX78)) - -TARGET_BUILTIN(__nvvm_read_ptx_sreg_cluster_ctarank, "i", "nc", AND(SM_90, PTX78)) -TARGET_BUILTIN(__nvvm_read_ptx_sreg_cluster_nctarank, "i", "nc", AND(SM_90, PTX78)) - -TARGET_BUILTIN(__nvvm_is_explicit_cluster, "b", "nc", AND(SM_90, PTX78)) - -BUILTIN(__nvvm_read_ptx_sreg_laneid, "i", "nc") -BUILTIN(__nvvm_read_ptx_sreg_warpid, "i", "nc") -BUILTIN(__nvvm_read_ptx_sreg_nwarpid, "i", "nc") -BUILTIN(__nvvm_read_ptx_sreg_warpsize, "i", "nc") - -BUILTIN(__nvvm_read_ptx_sreg_smid, "i", "nc") -BUILTIN(__nvvm_read_ptx_sreg_nsmid, "i", "nc") -BUILTIN(__nvvm_read_ptx_sreg_gridid, "i", "nc") - -BUILTIN(__nvvm_read_ptx_sreg_lanemask_eq, "i", "nc") -BUILTIN(__nvvm_read_ptx_sreg_lanemask_le, "i", "nc") -BUILTIN(__nvvm_read_ptx_sreg_lanemask_lt, "i", "nc") -BUILTIN(__nvvm_read_ptx_sreg_lanemask_ge, "i", "nc") -BUILTIN(__nvvm_read_ptx_sreg_lanemask_gt, "i", "nc") - -BUILTIN(__nvvm_read_ptx_sreg_clock, "i", "n") -BUILTIN(__nvvm_read_ptx_sreg_clock64, "LLi", "n") -BUILTIN(__nvvm_read_ptx_sreg_globaltimer, "LLi", "n") - -BUILTIN(__nvvm_read_ptx_sreg_pm0, "i", "n") -BUILTIN(__nvvm_read_ptx_sreg_pm1, "i", "n") -BUILTIN(__nvvm_read_ptx_sreg_pm2, "i", "n") -BUILTIN(__nvvm_read_ptx_sreg_pm3, "i", "n") - -// MISC - -BUILTIN(__nvvm_prmt, "UiUiUiUi", "") -BUILTIN(__nvvm_exit, "v", "r") -BUILTIN(__nvvm_reflect, "UicC*", "r") -TARGET_BUILTIN(__nvvm_nanosleep, "vUi", "n", AND(SM_70, PTX63)) - -// Min Max - -TARGET_BUILTIN(__nvvm_fmin_f16, "hhh", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmin_ftz_f16, "hhh", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmin_nan_f16, "hhh", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmin_ftz_nan_f16, "hhh", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmin_xorsign_abs_f16, "hhh", "", AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmin_ftz_xorsign_abs_f16, "hhh", "", AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmin_nan_xorsign_abs_f16, "hhh", "", AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmin_ftz_nan_xorsign_abs_f16, "hhh", "", - AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmin_f16x2, "V2hV2hV2h", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmin_ftz_f16x2, "V2hV2hV2h", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmin_nan_f16x2, "V2hV2hV2h", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmin_ftz_nan_f16x2, "V2hV2hV2h", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmin_xorsign_abs_f16x2, "V2hV2hV2h", "", - AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmin_ftz_xorsign_abs_f16x2, "V2hV2hV2h", "", - AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmin_nan_xorsign_abs_f16x2, "V2hV2hV2h", "", - AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmin_ftz_nan_xorsign_abs_f16x2, "V2hV2hV2h", "", - AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmin_bf16, "yyy", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmin_ftz_bf16, "yyy", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmin_nan_bf16, "yyy", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmin_ftz_nan_bf16, "yyy", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmin_xorsign_abs_bf16, "yyy", "", AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmin_nan_xorsign_abs_bf16, "yyy", "", - AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmin_bf16x2, "V2yV2yV2y", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmin_ftz_bf16x2, "V2yV2yV2y", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmin_nan_bf16x2, "V2yV2yV2y", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmin_ftz_nan_bf16x2, "V2yV2yV2y", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmin_xorsign_abs_bf16x2, "V2yV2yV2y", "", - AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmin_nan_xorsign_abs_bf16x2, "V2yV2yV2y", "", - AND(SM_86, PTX72)) -BUILTIN(__nvvm_fmin_f, "fff", "") -BUILTIN(__nvvm_fmin_ftz_f, "fff", "") -TARGET_BUILTIN(__nvvm_fmin_nan_f, "fff", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmin_ftz_nan_f, "fff", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmin_xorsign_abs_f, "fff", "", AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmin_ftz_xorsign_abs_f, "fff", "", AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmin_nan_xorsign_abs_f, "fff", "", AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmin_ftz_nan_xorsign_abs_f, "fff", "", AND(SM_86, PTX72)) -BUILTIN(__nvvm_fmin_d, "ddd", "") - -TARGET_BUILTIN(__nvvm_fmax_f16, "hhh", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmax_ftz_f16, "hhh", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmax_nan_f16, "hhh", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmax_ftz_nan_f16, "hhh", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmax_xorsign_abs_f16, "hhh", "", AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmax_ftz_xorsign_abs_f16, "hhh", "", AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmax_nan_xorsign_abs_f16, "hhh", "", AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmax_ftz_nan_xorsign_abs_f16, "hhh", "", - AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmax_f16x2, "V2hV2hV2h", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmax_ftz_f16x2, "V2hV2hV2h", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmax_nan_f16x2, "V2hV2hV2h", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmax_ftz_nan_f16x2, "V2hV2hV2h", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmax_xorsign_abs_f16x2, "V2hV2hV2h", "", - AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmax_ftz_xorsign_abs_f16x2, "V2hV2hV2h", "", - AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmax_nan_xorsign_abs_f16x2, "V2hV2hV2h", "", - AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmax_ftz_nan_xorsign_abs_f16x2, "V2hV2hV2h", "", - AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmax_bf16, "yyy", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmax_ftz_bf16, "yyy", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmax_nan_bf16, "yyy", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmax_ftz_nan_bf16, "yyy", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmax_xorsign_abs_bf16, "yyy", "", AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmax_nan_xorsign_abs_bf16, "yyy", "", - AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmax_bf16x2, "V2yV2yV2y", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmax_ftz_bf16x2, "V2yV2yV2y", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmax_nan_bf16x2, "V2yV2yV2y", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmax_ftz_nan_bf16x2, "V2yV2yV2y", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmax_xorsign_abs_bf16x2, "V2yV2yV2y", "", - AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmax_nan_xorsign_abs_bf16x2, "V2yV2yV2y", "", - AND(SM_86, PTX72)) -BUILTIN(__nvvm_fmax_f, "fff", "") -BUILTIN(__nvvm_fmax_ftz_f, "fff", "") -TARGET_BUILTIN(__nvvm_fmax_nan_f, "fff", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmax_ftz_nan_f, "fff", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fmax_xorsign_abs_f, "fff", "", AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmax_ftz_xorsign_abs_f, "fff", "", AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmax_nan_xorsign_abs_f, "fff", "", AND(SM_86, PTX72)) -TARGET_BUILTIN(__nvvm_fmax_ftz_nan_xorsign_abs_f, "fff", "", AND(SM_86, PTX72)) -BUILTIN(__nvvm_fmax_d, "ddd", "") - -// Multiplication - -BUILTIN(__nvvm_mulhi_i, "iii", "") -BUILTIN(__nvvm_mulhi_ui, "UiUiUi", "") -BUILTIN(__nvvm_mulhi_ll, "LLiLLiLLi", "") -BUILTIN(__nvvm_mulhi_ull, "ULLiULLiULLi", "") - -BUILTIN(__nvvm_mul_rn_ftz_f, "fff", "") -BUILTIN(__nvvm_mul_rn_f, "fff", "") -BUILTIN(__nvvm_mul_rz_ftz_f, "fff", "") -BUILTIN(__nvvm_mul_rz_f, "fff", "") -BUILTIN(__nvvm_mul_rm_ftz_f, "fff", "") -BUILTIN(__nvvm_mul_rm_f, "fff", "") -BUILTIN(__nvvm_mul_rp_ftz_f, "fff", "") -BUILTIN(__nvvm_mul_rp_f, "fff", "") - -BUILTIN(__nvvm_mul_rn_d, "ddd", "") -BUILTIN(__nvvm_mul_rz_d, "ddd", "") -BUILTIN(__nvvm_mul_rm_d, "ddd", "") -BUILTIN(__nvvm_mul_rp_d, "ddd", "") - -BUILTIN(__nvvm_mul24_i, "iii", "") -BUILTIN(__nvvm_mul24_ui, "UiUiUi", "") - -// Div - -BUILTIN(__nvvm_div_approx_ftz_f, "fff", "") -BUILTIN(__nvvm_div_approx_f, "fff", "") - -BUILTIN(__nvvm_div_rn_ftz_f, "fff", "") -BUILTIN(__nvvm_div_rn_f, "fff", "") -BUILTIN(__nvvm_div_rz_ftz_f, "fff", "") -BUILTIN(__nvvm_div_rz_f, "fff", "") -BUILTIN(__nvvm_div_rm_ftz_f, "fff", "") -BUILTIN(__nvvm_div_rm_f, "fff", "") -BUILTIN(__nvvm_div_rp_ftz_f, "fff", "") -BUILTIN(__nvvm_div_rp_f, "fff", "") - -BUILTIN(__nvvm_div_rn_d, "ddd", "") -BUILTIN(__nvvm_div_rz_d, "ddd", "") -BUILTIN(__nvvm_div_rm_d, "ddd", "") -BUILTIN(__nvvm_div_rp_d, "ddd", "") - -// Sad - -BUILTIN(__nvvm_sad_i, "iiii", "") -BUILTIN(__nvvm_sad_ui, "UiUiUiUi", "") - -// Floor, Ceil - -BUILTIN(__nvvm_floor_ftz_f, "ff", "") -BUILTIN(__nvvm_floor_f, "ff", "") -BUILTIN(__nvvm_floor_d, "dd", "") - -BUILTIN(__nvvm_ceil_ftz_f, "ff", "") -BUILTIN(__nvvm_ceil_f, "ff", "") -BUILTIN(__nvvm_ceil_d, "dd", "") - -// Abs - -BUILTIN(__nvvm_fabs_ftz_f, "ff", "") -BUILTIN(__nvvm_fabs_f, "ff", "") -BUILTIN(__nvvm_fabs_d, "dd", "") - -// Round - -BUILTIN(__nvvm_round_ftz_f, "ff", "") -BUILTIN(__nvvm_round_f, "ff", "") -BUILTIN(__nvvm_round_d, "dd", "") - -// Trunc - -BUILTIN(__nvvm_trunc_ftz_f, "ff", "") -BUILTIN(__nvvm_trunc_f, "ff", "") -BUILTIN(__nvvm_trunc_d, "dd", "") - -// Saturate - -BUILTIN(__nvvm_saturate_ftz_f, "ff", "") -BUILTIN(__nvvm_saturate_f, "ff", "") -BUILTIN(__nvvm_saturate_d, "dd", "") - -// Exp2, Log2 - -BUILTIN(__nvvm_ex2_approx_ftz_f, "ff", "") -BUILTIN(__nvvm_ex2_approx_f, "ff", "") -BUILTIN(__nvvm_ex2_approx_d, "dd", "") -TARGET_BUILTIN(__nvvm_ex2_approx_f16, "hh", "", AND(SM_75, PTX70)) -TARGET_BUILTIN(__nvvm_ex2_approx_f16x2, "V2hV2h", "", AND(SM_75, PTX70)) - -BUILTIN(__nvvm_lg2_approx_ftz_f, "ff", "") -BUILTIN(__nvvm_lg2_approx_f, "ff", "") -BUILTIN(__nvvm_lg2_approx_d, "dd", "") - -// Sin, Cos - -BUILTIN(__nvvm_sin_approx_ftz_f, "ff", "") -BUILTIN(__nvvm_sin_approx_f, "ff", "") - -BUILTIN(__nvvm_cos_approx_ftz_f, "ff", "") -BUILTIN(__nvvm_cos_approx_f, "ff", "") - -// Fma - -TARGET_BUILTIN(__nvvm_fma_rn_f16, "hhhh", "", AND(SM_53, PTX42)) -TARGET_BUILTIN(__nvvm_fma_rn_ftz_f16, "hhhh", "", AND(SM_53, PTX42)) -TARGET_BUILTIN(__nvvm_fma_rn_sat_f16, "hhhh", "", AND(SM_53, PTX42)) -TARGET_BUILTIN(__nvvm_fma_rn_ftz_sat_f16, "hhhh", "", AND(SM_53, PTX42)) -TARGET_BUILTIN(__nvvm_fma_rn_relu_f16, "hhhh", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fma_rn_ftz_relu_f16, "hhhh", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fma_rn_f16x2, "V2hV2hV2hV2h", "", AND(SM_53, PTX42)) -TARGET_BUILTIN(__nvvm_fma_rn_ftz_f16x2, "V2hV2hV2hV2h", "", AND(SM_53, PTX42)) -TARGET_BUILTIN(__nvvm_fma_rn_sat_f16x2, "V2hV2hV2hV2h", "", AND(SM_53, PTX42)) -TARGET_BUILTIN(__nvvm_fma_rn_ftz_sat_f16x2, "V2hV2hV2hV2h", "", AND(SM_53, PTX42)) -TARGET_BUILTIN(__nvvm_fma_rn_relu_f16x2, "V2hV2hV2hV2h", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fma_rn_ftz_relu_f16x2, "V2hV2hV2hV2h", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fma_rn_bf16, "yyyy", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fma_rn_relu_bf16, "yyyy", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fma_rn_bf16x2, "V2yV2yV2yV2y", "", AND(SM_80, PTX70)) -TARGET_BUILTIN(__nvvm_fma_rn_relu_bf16x2, "V2yV2yV2yV2y", "", AND(SM_80, PTX70)) -BUILTIN(__nvvm_fma_rn_ftz_f, "ffff", "") -BUILTIN(__nvvm_fma_rn_f, "ffff", "") -BUILTIN(__nvvm_fma_rz_ftz_f, "ffff", "") -BUILTIN(__nvvm_fma_rz_f, "ffff", "") -BUILTIN(__nvvm_fma_rm_ftz_f, "ffff", "") -BUILTIN(__nvvm_fma_rm_f, "ffff", "") -BUILTIN(__nvvm_fma_rp_ftz_f, "ffff", "") -BUILTIN(__nvvm_fma_rp_f, "ffff", "") -BUILTIN(__nvvm_fma_rn_d, "dddd", "") -BUILTIN(__nvvm_fma_rz_d, "dddd", "") -BUILTIN(__nvvm_fma_rm_d, "dddd", "") -BUILTIN(__nvvm_fma_rp_d, "dddd", "") - -// Rcp - -BUILTIN(__nvvm_rcp_rn_ftz_f, "ff", "") -BUILTIN(__nvvm_rcp_rn_f, "ff", "") -BUILTIN(__nvvm_rcp_rz_ftz_f, "ff", "") -BUILTIN(__nvvm_rcp_rz_f, "ff", "") -BUILTIN(__nvvm_rcp_rm_ftz_f, "ff", "") -BUILTIN(__nvvm_rcp_rm_f, "ff", "") -BUILTIN(__nvvm_rcp_rp_ftz_f, "ff", "") -BUILTIN(__nvvm_rcp_rp_f, "ff", "") - -BUILTIN(__nvvm_rcp_rn_d, "dd", "") -BUILTIN(__nvvm_rcp_rz_d, "dd", "") -BUILTIN(__nvvm_rcp_rm_d, "dd", "") -BUILTIN(__nvvm_rcp_rp_d, "dd", "") - -BUILTIN(__nvvm_rcp_approx_ftz_f, "ff", "") -BUILTIN(__nvvm_rcp_approx_ftz_d, "dd", "") - -// Sqrt - -BUILTIN(__nvvm_sqrt_rn_ftz_f, "ff", "") -BUILTIN(__nvvm_sqrt_rn_f, "ff", "") -BUILTIN(__nvvm_sqrt_rz_ftz_f, "ff", "") -BUILTIN(__nvvm_sqrt_rz_f, "ff", "") -BUILTIN(__nvvm_sqrt_rm_ftz_f, "ff", "") -BUILTIN(__nvvm_sqrt_rm_f, "ff", "") -BUILTIN(__nvvm_sqrt_rp_ftz_f, "ff", "") -BUILTIN(__nvvm_sqrt_rp_f, "ff", "") -BUILTIN(__nvvm_sqrt_approx_ftz_f, "ff", "") -BUILTIN(__nvvm_sqrt_approx_f, "ff", "") - -BUILTIN(__nvvm_sqrt_rn_d, "dd", "") -BUILTIN(__nvvm_sqrt_rz_d, "dd", "") -BUILTIN(__nvvm_sqrt_rm_d, "dd", "") -BUILTIN(__nvvm_sqrt_rp_d, "dd", "") - -// Rsqrt - -BUILTIN(__nvvm_rsqrt_approx_ftz_f, "ff", "") -BUILTIN(__nvvm_rsqrt_approx_f, "ff", "") -BUILTIN(__nvvm_rsqrt_approx_d, "dd", "") - -// Add - -BUILTIN(__nvvm_add_rn_ftz_f, "fff", "") -BUILTIN(__nvvm_add_rn_f, "fff", "") -BUILTIN(__nvvm_add_rz_ftz_f, "fff", "") -BUILTIN(__nvvm_add_rz_f, "fff", "") -BUILTIN(__nvvm_add_rm_ftz_f, "fff", "") -BUILTIN(__nvvm_add_rm_f, "fff", "") -BUILTIN(__nvvm_add_rp_ftz_f, "fff", "") -BUILTIN(__nvvm_add_rp_f, "fff", "") - -BUILTIN(__nvvm_add_rn_d, "ddd", "") -BUILTIN(__nvvm_add_rz_d, "ddd", "") -BUILTIN(__nvvm_add_rm_d, "ddd", "") -BUILTIN(__nvvm_add_rp_d, "ddd", "") - -// Convert - -BUILTIN(__nvvm_d2f_rn_ftz, "fd", "") -BUILTIN(__nvvm_d2f_rn, "fd", "") -BUILTIN(__nvvm_d2f_rz_ftz, "fd", "") -BUILTIN(__nvvm_d2f_rz, "fd", "") -BUILTIN(__nvvm_d2f_rm_ftz, "fd", "") -BUILTIN(__nvvm_d2f_rm, "fd", "") -BUILTIN(__nvvm_d2f_rp_ftz, "fd", "") -BUILTIN(__nvvm_d2f_rp, "fd", "") - -BUILTIN(__nvvm_d2i_rn, "id", "") -BUILTIN(__nvvm_d2i_rz, "id", "") -BUILTIN(__nvvm_d2i_rm, "id", "") -BUILTIN(__nvvm_d2i_rp, "id", "") - -BUILTIN(__nvvm_d2ui_rn, "Uid", "") -BUILTIN(__nvvm_d2ui_rz, "Uid", "") -BUILTIN(__nvvm_d2ui_rm, "Uid", "") -BUILTIN(__nvvm_d2ui_rp, "Uid", "") - -BUILTIN(__nvvm_i2d_rn, "di", "") -BUILTIN(__nvvm_i2d_rz, "di", "") -BUILTIN(__nvvm_i2d_rm, "di", "") -BUILTIN(__nvvm_i2d_rp, "di", "") - -BUILTIN(__nvvm_ui2d_rn, "dUi", "") -BUILTIN(__nvvm_ui2d_rz, "dUi", "") -BUILTIN(__nvvm_ui2d_rm, "dUi", "") -BUILTIN(__nvvm_ui2d_rp, "dUi", "") - -BUILTIN(__nvvm_f2i_rn_ftz, "if", "") -BUILTIN(__nvvm_f2i_rn, "if", "") -BUILTIN(__nvvm_f2i_rz_ftz, "if", "") -BUILTIN(__nvvm_f2i_rz, "if", "") -BUILTIN(__nvvm_f2i_rm_ftz, "if", "") -BUILTIN(__nvvm_f2i_rm, "if", "") -BUILTIN(__nvvm_f2i_rp_ftz, "if", "") -BUILTIN(__nvvm_f2i_rp, "if", "") - -BUILTIN(__nvvm_f2ui_rn_ftz, "Uif", "") -BUILTIN(__nvvm_f2ui_rn, "Uif", "") -BUILTIN(__nvvm_f2ui_rz_ftz, "Uif", "") -BUILTIN(__nvvm_f2ui_rz, "Uif", "") -BUILTIN(__nvvm_f2ui_rm_ftz, "Uif", "") -BUILTIN(__nvvm_f2ui_rm, "Uif", "") -BUILTIN(__nvvm_f2ui_rp_ftz, "Uif", "") -BUILTIN(__nvvm_f2ui_rp, "Uif", "") - -BUILTIN(__nvvm_i2f_rn, "fi", "") -BUILTIN(__nvvm_i2f_rz, "fi", "") -BUILTIN(__nvvm_i2f_rm, "fi", "") -BUILTIN(__nvvm_i2f_rp, "fi", "") - -BUILTIN(__nvvm_ui2f_rn, "fUi", "") -BUILTIN(__nvvm_ui2f_rz, "fUi", "") -BUILTIN(__nvvm_ui2f_rm, "fUi", "") -BUILTIN(__nvvm_ui2f_rp, "fUi", "") - -BUILTIN(__nvvm_lohi_i2d, "dii", "") - -BUILTIN(__nvvm_d2i_lo, "id", "") -BUILTIN(__nvvm_d2i_hi, "id", "") - -BUILTIN(__nvvm_f2ll_rn_ftz, "LLif", "") -BUILTIN(__nvvm_f2ll_rn, "LLif", "") -BUILTIN(__nvvm_f2ll_rz_ftz, "LLif", "") -BUILTIN(__nvvm_f2ll_rz, "LLif", "") -BUILTIN(__nvvm_f2ll_rm_ftz, "LLif", "") -BUILTIN(__nvvm_f2ll_rm, "LLif", "") -BUILTIN(__nvvm_f2ll_rp_ftz, "LLif", "") -BUILTIN(__nvvm_f2ll_rp, "LLif", "") - -BUILTIN(__nvvm_f2ull_rn_ftz, "ULLif", "") -BUILTIN(__nvvm_f2ull_rn, "ULLif", "") -BUILTIN(__nvvm_f2ull_rz_ftz, "ULLif", "") -BUILTIN(__nvvm_f2ull_rz, "ULLif", "") -BUILTIN(__nvvm_f2ull_rm_ftz, "ULLif", "") -BUILTIN(__nvvm_f2ull_rm, "ULLif", "") -BUILTIN(__nvvm_f2ull_rp_ftz, "ULLif", "") -BUILTIN(__nvvm_f2ull_rp, "ULLif", "") - -BUILTIN(__nvvm_d2ll_rn, "LLid", "") -BUILTIN(__nvvm_d2ll_rz, "LLid", "") -BUILTIN(__nvvm_d2ll_rm, "LLid", "") -BUILTIN(__nvvm_d2ll_rp, "LLid", "") - -BUILTIN(__nvvm_d2ull_rn, "ULLid", "") -BUILTIN(__nvvm_d2ull_rz, "ULLid", "") -BUILTIN(__nvvm_d2ull_rm, "ULLid", "") -BUILTIN(__nvvm_d2ull_rp, "ULLid", "") - -BUILTIN(__nvvm_ll2f_rn, "fLLi", "") -BUILTIN(__nvvm_ll2f_rz, "fLLi", "") -BUILTIN(__nvvm_ll2f_rm, "fLLi", "") -BUILTIN(__nvvm_ll2f_rp, "fLLi", "") - -BUILTIN(__nvvm_ull2f_rn, "fULLi", "") -BUILTIN(__nvvm_ull2f_rz, "fULLi", "") -BUILTIN(__nvvm_ull2f_rm, "fULLi", "") -BUILTIN(__nvvm_ull2f_rp, "fULLi", "") - -BUILTIN(__nvvm_ll2d_rn, "dLLi", "") -BUILTIN(__nvvm_ll2d_rz, "dLLi", "") -BUILTIN(__nvvm_ll2d_rm, "dLLi", "") -BUILTIN(__nvvm_ll2d_rp, "dLLi", "") - -BUILTIN(__nvvm_ull2d_rn, "dULLi", "") -BUILTIN(__nvvm_ull2d_rz, "dULLi", "") -BUILTIN(__nvvm_ull2d_rm, "dULLi", "") -BUILTIN(__nvvm_ull2d_rp, "dULLi", "") - -BUILTIN(__nvvm_f2h_rn_ftz, "Usf", "") -BUILTIN(__nvvm_f2h_rn, "Usf", "") - -TARGET_BUILTIN(__nvvm_ff2bf16x2_rn, "V2yff", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_ff2bf16x2_rn_relu, "V2yff", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_ff2bf16x2_rz, "V2yff", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_ff2bf16x2_rz_relu, "V2yff", "", AND(SM_80,PTX70)) - -TARGET_BUILTIN(__nvvm_ff2f16x2_rn, "V2hff", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_ff2f16x2_rn_relu, "V2hff", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_ff2f16x2_rz, "V2hff", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_ff2f16x2_rz_relu, "V2hff", "", AND(SM_80,PTX70)) - -TARGET_BUILTIN(__nvvm_f2bf16_rn, "yf", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_f2bf16_rn_relu, "yf", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_f2bf16_rz, "yf", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_f2bf16_rz_relu, "yf", "", AND(SM_80,PTX70)) - -TARGET_BUILTIN(__nvvm_f2tf32_rna, "ZUif", "", AND(SM_80,PTX70)) - -TARGET_BUILTIN(__nvvm_ff_to_e4m3x2_rn, "sff", "", AND(SM_89,PTX81)) -TARGET_BUILTIN(__nvvm_ff_to_e4m3x2_rn_relu, "sff", "", AND(SM_89,PTX81)) -TARGET_BUILTIN(__nvvm_ff_to_e5m2x2_rn, "sff", "", AND(SM_89,PTX81)) -TARGET_BUILTIN(__nvvm_ff_to_e5m2x2_rn_relu, "sff", "", AND(SM_89,PTX81)) - -TARGET_BUILTIN(__nvvm_f16x2_to_e4m3x2_rn, "sV2h", "", AND(SM_89,PTX81)) -TARGET_BUILTIN(__nvvm_f16x2_to_e4m3x2_rn_relu, "sV2h", "", AND(SM_89,PTX81)) -TARGET_BUILTIN(__nvvm_f16x2_to_e5m2x2_rn, "sV2h", "", AND(SM_89,PTX81)) -TARGET_BUILTIN(__nvvm_f16x2_to_e5m2x2_rn_relu, "sV2h", "", AND(SM_89,PTX81)) - -TARGET_BUILTIN(__nvvm_e4m3x2_to_f16x2_rn, "V2hs", "", AND(SM_89,PTX81)) -TARGET_BUILTIN(__nvvm_e4m3x2_to_f16x2_rn_relu, "V2hs", "", AND(SM_89,PTX81)) -TARGET_BUILTIN(__nvvm_e5m2x2_to_f16x2_rn, "V2hs", "", AND(SM_89,PTX81)) -TARGET_BUILTIN(__nvvm_e5m2x2_to_f16x2_rn_relu, "V2hs", "", AND(SM_89,PTX81)) - -// FNS -TARGET_BUILTIN(__nvvm_fns, "UiUiUii", "n", PTX60) - -// Sync - -BUILTIN(__syncthreads, "v", "") -BUILTIN(__nvvm_bar0_popc, "ii", "") -BUILTIN(__nvvm_bar0_and, "ii", "") -BUILTIN(__nvvm_bar0_or, "ii", "") -BUILTIN(__nvvm_bar_sync, "vi", "n") -TARGET_BUILTIN(__nvvm_bar_warp_sync, "vUi", "n", PTX60) -TARGET_BUILTIN(__nvvm_barrier_sync, "vUi", "n", PTX60) -TARGET_BUILTIN(__nvvm_barrier_sync_cnt, "vUiUi", "n", PTX60) - -TARGET_BUILTIN(__nvvm_barrier_cluster_arrive, "v", "n", AND(SM_90,PTX78)) -TARGET_BUILTIN(__nvvm_barrier_cluster_arrive_relaxed, "v", "n", AND(SM_90,PTX80)) -TARGET_BUILTIN(__nvvm_barrier_cluster_wait, "v", "n", AND(SM_90,PTX78)) -TARGET_BUILTIN(__nvvm_fence_sc_cluster, "v", "n", AND(SM_90,PTX78)) - -// Shuffle - -BUILTIN(__nvvm_shfl_down_i32, "iiii", "") -BUILTIN(__nvvm_shfl_down_f32, "ffii", "") -BUILTIN(__nvvm_shfl_up_i32, "iiii", "") -BUILTIN(__nvvm_shfl_up_f32, "ffii", "") -BUILTIN(__nvvm_shfl_bfly_i32, "iiii", "") -BUILTIN(__nvvm_shfl_bfly_f32, "ffii", "") -BUILTIN(__nvvm_shfl_idx_i32, "iiii", "") -BUILTIN(__nvvm_shfl_idx_f32, "ffii", "") - -TARGET_BUILTIN(__nvvm_shfl_sync_down_i32, "iUiiii", "", PTX60) -TARGET_BUILTIN(__nvvm_shfl_sync_down_f32, "fUifii", "", PTX60) -TARGET_BUILTIN(__nvvm_shfl_sync_up_i32, "iUiiii", "", PTX60) -TARGET_BUILTIN(__nvvm_shfl_sync_up_f32, "fUifii", "", PTX60) -TARGET_BUILTIN(__nvvm_shfl_sync_bfly_i32, "iUiiii", "", PTX60) -TARGET_BUILTIN(__nvvm_shfl_sync_bfly_f32, "fUifii", "", PTX60) -TARGET_BUILTIN(__nvvm_shfl_sync_idx_i32, "iUiiii", "", PTX60) -TARGET_BUILTIN(__nvvm_shfl_sync_idx_f32, "fUifii", "", PTX60) - -// Vote -BUILTIN(__nvvm_vote_all, "bb", "") -BUILTIN(__nvvm_vote_any, "bb", "") -BUILTIN(__nvvm_vote_uni, "bb", "") -BUILTIN(__nvvm_vote_ballot, "Uib", "") - -TARGET_BUILTIN(__nvvm_vote_all_sync, "bUib", "", PTX60) -TARGET_BUILTIN(__nvvm_vote_any_sync, "bUib", "", PTX60) -TARGET_BUILTIN(__nvvm_vote_uni_sync, "bUib", "", PTX60) -TARGET_BUILTIN(__nvvm_vote_ballot_sync, "UiUib", "", PTX60) - -// Mask -TARGET_BUILTIN(__nvvm_activemask, "Ui", "n", PTX62) - -// Match -TARGET_BUILTIN(__nvvm_match_any_sync_i32, "UiUiUi", "", AND(SM_70,PTX60)) -TARGET_BUILTIN(__nvvm_match_any_sync_i64, "UiUiWi", "", AND(SM_70,PTX60)) -// These return a pair {value, predicate}, which requires custom lowering. -TARGET_BUILTIN(__nvvm_match_all_sync_i32p, "UiUiUii*", "", AND(SM_70,PTX60)) -TARGET_BUILTIN(__nvvm_match_all_sync_i64p, "UiUiWii*", "", AND(SM_70,PTX60)) - -// Redux -TARGET_BUILTIN(__nvvm_redux_sync_add, "iii", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_redux_sync_min, "iii", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_redux_sync_max, "iii", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_redux_sync_umin, "UiUii", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_redux_sync_umax, "UiUii", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_redux_sync_and, "iii", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_redux_sync_xor, "iii", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_redux_sync_or, "iii", "", AND(SM_80,PTX70)) - -// Membar - -BUILTIN(__nvvm_membar_cta, "v", "") -BUILTIN(__nvvm_membar_gl, "v", "") -BUILTIN(__nvvm_membar_sys, "v", "") - -// mbarrier - -TARGET_BUILTIN(__nvvm_mbarrier_init, "vWi*i", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_mbarrier_init_shared, "vWi*3i", "", AND(SM_80,PTX70)) - -TARGET_BUILTIN(__nvvm_mbarrier_inval, "vWi*", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_mbarrier_inval_shared, "vWi*3", "", AND(SM_80,PTX70)) - -TARGET_BUILTIN(__nvvm_mbarrier_arrive, "WiWi*", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_mbarrier_arrive_shared, "WiWi*3", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_mbarrier_arrive_noComplete, "WiWi*i", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_mbarrier_arrive_noComplete_shared, "WiWi*3i", "", AND(SM_80,PTX70)) - -TARGET_BUILTIN(__nvvm_mbarrier_arrive_drop, "WiWi*", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_mbarrier_arrive_drop_shared, "WiWi*3", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_mbarrier_arrive_drop_noComplete, "WiWi*i", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_mbarrier_arrive_drop_noComplete_shared, "WiWi*3i", "", AND(SM_80,PTX70)) - -TARGET_BUILTIN(__nvvm_mbarrier_test_wait, "bWi*Wi", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_mbarrier_test_wait_shared, "bWi*3Wi", "", AND(SM_80,PTX70)) - -TARGET_BUILTIN(__nvvm_mbarrier_pending_count, "iWi", "", AND(SM_80,PTX70)) - -// Memcpy, Memset - -BUILTIN(__nvvm_memcpy, "vUc*Uc*zi","") -BUILTIN(__nvvm_memset, "vUc*Uczi","") - -// Image - -BUILTIN(__builtin_ptx_read_image2Dfi_, "V4fiiii", "") -BUILTIN(__builtin_ptx_read_image2Dff_, "V4fiiff", "") -BUILTIN(__builtin_ptx_read_image2Dii_, "V4iiiii", "") -BUILTIN(__builtin_ptx_read_image2Dif_, "V4iiiff", "") - -BUILTIN(__builtin_ptx_read_image3Dfi_, "V4fiiiiii", "") -BUILTIN(__builtin_ptx_read_image3Dff_, "V4fiiffff", "") -BUILTIN(__builtin_ptx_read_image3Dii_, "V4iiiiiii", "") -BUILTIN(__builtin_ptx_read_image3Dif_, "V4iiiffff", "") - -BUILTIN(__builtin_ptx_write_image2Df_, "viiiffff", "") -BUILTIN(__builtin_ptx_write_image2Di_, "viiiiiii", "") -BUILTIN(__builtin_ptx_write_image2Dui_, "viiiUiUiUiUi", "") -BUILTIN(__builtin_ptx_get_image_depthi_, "ii", "") -BUILTIN(__builtin_ptx_get_image_heighti_, "ii", "") -BUILTIN(__builtin_ptx_get_image_widthi_, "ii", "") -BUILTIN(__builtin_ptx_get_image_channel_data_typei_, "ii", "") -BUILTIN(__builtin_ptx_get_image_channel_orderi_, "ii", "") - -// Atomic -// -// We need the atom intrinsics because -// - they are used in converging analysis -// - they are used in address space analysis and optimization -// So it does not hurt to expose them as builtins. -// -BUILTIN(__nvvm_atom_add_gen_i, "iiD*i", "n") -TARGET_BUILTIN(__nvvm_atom_cta_add_gen_i, "iiD*i", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_add_gen_i, "iiD*i", "n", SM_60) -BUILTIN(__nvvm_atom_add_gen_l, "LiLiD*Li", "n") -TARGET_BUILTIN(__nvvm_atom_cta_add_gen_l, "LiLiD*Li", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_add_gen_l, "LiLiD*Li", "n", SM_60) -BUILTIN(__nvvm_atom_add_gen_ll, "LLiLLiD*LLi", "n") -TARGET_BUILTIN(__nvvm_atom_cta_add_gen_ll, "LLiLLiD*LLi", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_add_gen_ll, "LLiLLiD*LLi", "n", SM_60) -BUILTIN(__nvvm_atom_add_gen_f, "ffD*f", "n") -TARGET_BUILTIN(__nvvm_atom_cta_add_gen_f, "ffD*f", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_add_gen_f, "ffD*f", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_add_gen_d, "ddD*d", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_cta_add_gen_d, "ddD*d", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_add_gen_d, "ddD*d", "n", SM_60) - -BUILTIN(__nvvm_atom_sub_gen_i, "iiD*i", "n") -BUILTIN(__nvvm_atom_sub_gen_l, "LiLiD*Li", "n") -BUILTIN(__nvvm_atom_sub_gen_ll, "LLiLLiD*LLi", "n") - -BUILTIN(__nvvm_atom_xchg_gen_i, "iiD*i", "n") -TARGET_BUILTIN(__nvvm_atom_cta_xchg_gen_i, "iiD*i", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_xchg_gen_i, "iiD*i", "n", SM_60) -BUILTIN(__nvvm_atom_xchg_gen_l, "LiLiD*Li", "n") -TARGET_BUILTIN(__nvvm_atom_cta_xchg_gen_l, "LiLiD*Li", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_xchg_gen_l, "LiLiD*Li", "n", SM_60) -BUILTIN(__nvvm_atom_xchg_gen_ll, "LLiLLiD*LLi", "n") -TARGET_BUILTIN(__nvvm_atom_cta_xchg_gen_ll, "LLiLLiD*LLi", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_xchg_gen_ll, "LLiLLiD*LLi", "n", SM_60) - -BUILTIN(__nvvm_atom_max_gen_i, "iiD*i", "n") -TARGET_BUILTIN(__nvvm_atom_cta_max_gen_i, "iiD*i", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_max_gen_i, "iiD*i", "n", SM_60) -BUILTIN(__nvvm_atom_max_gen_ui, "UiUiD*Ui", "n") -TARGET_BUILTIN(__nvvm_atom_cta_max_gen_ui, "UiUiD*Ui", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_max_gen_ui, "UiUiD*Ui", "n", SM_60) -BUILTIN(__nvvm_atom_max_gen_l, "LiLiD*Li", "n") -TARGET_BUILTIN(__nvvm_atom_cta_max_gen_l, "LiLiD*Li", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_max_gen_l, "LiLiD*Li", "n", SM_60) -BUILTIN(__nvvm_atom_max_gen_ul, "ULiULiD*ULi", "n") -TARGET_BUILTIN(__nvvm_atom_cta_max_gen_ul, "ULiULiD*ULi", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_max_gen_ul, "ULiULiD*ULi", "n", SM_60) -BUILTIN(__nvvm_atom_max_gen_ll, "LLiLLiD*LLi", "n") -TARGET_BUILTIN(__nvvm_atom_cta_max_gen_ll, "LLiLLiD*LLi", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_max_gen_ll, "LLiLLiD*LLi", "n", SM_60) -BUILTIN(__nvvm_atom_max_gen_ull, "ULLiULLiD*ULLi", "n") -TARGET_BUILTIN(__nvvm_atom_cta_max_gen_ull, "ULLiULLiD*ULLi", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_max_gen_ull, "ULLiULLiD*ULLi", "n", SM_60) - -BUILTIN(__nvvm_atom_min_gen_i, "iiD*i", "n") -TARGET_BUILTIN(__nvvm_atom_cta_min_gen_i, "iiD*i", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_min_gen_i, "iiD*i", "n", SM_60) -BUILTIN(__nvvm_atom_min_gen_ui, "UiUiD*Ui", "n") -TARGET_BUILTIN(__nvvm_atom_cta_min_gen_ui, "UiUiD*Ui", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_min_gen_ui, "UiUiD*Ui", "n", SM_60) -BUILTIN(__nvvm_atom_min_gen_l, "LiLiD*Li", "n") -TARGET_BUILTIN(__nvvm_atom_cta_min_gen_l, "LiLiD*Li", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_min_gen_l, "LiLiD*Li", "n", SM_60) -BUILTIN(__nvvm_atom_min_gen_ul, "ULiULiD*ULi", "n") -TARGET_BUILTIN(__nvvm_atom_cta_min_gen_ul, "ULiULiD*ULi", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_min_gen_ul, "ULiULiD*ULi", "n", SM_60) -BUILTIN(__nvvm_atom_min_gen_ll, "LLiLLiD*LLi", "n") -TARGET_BUILTIN(__nvvm_atom_cta_min_gen_ll, "LLiLLiD*LLi", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_min_gen_ll, "LLiLLiD*LLi", "n", SM_60) -BUILTIN(__nvvm_atom_min_gen_ull, "ULLiULLiD*ULLi", "n") -TARGET_BUILTIN(__nvvm_atom_cta_min_gen_ull, "ULLiULLiD*ULLi", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_min_gen_ull, "ULLiULLiD*ULLi", "n", SM_60) - -BUILTIN(__nvvm_atom_inc_gen_ui, "UiUiD*Ui", "n") -TARGET_BUILTIN(__nvvm_atom_cta_inc_gen_ui, "UiUiD*Ui", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_inc_gen_ui, "UiUiD*Ui", "n", SM_60) -BUILTIN(__nvvm_atom_dec_gen_ui, "UiUiD*Ui", "n") -TARGET_BUILTIN(__nvvm_atom_cta_dec_gen_ui, "UiUiD*Ui", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_dec_gen_ui, "UiUiD*Ui", "n", SM_60) - -BUILTIN(__nvvm_atom_and_gen_i, "iiD*i", "n") -TARGET_BUILTIN(__nvvm_atom_cta_and_gen_i, "iiD*i", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_and_gen_i, "iiD*i", "n", SM_60) -BUILTIN(__nvvm_atom_and_gen_l, "LiLiD*Li", "n") -TARGET_BUILTIN(__nvvm_atom_cta_and_gen_l, "LiLiD*Li", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_and_gen_l, "LiLiD*Li", "n", SM_60) -BUILTIN(__nvvm_atom_and_gen_ll, "LLiLLiD*LLi", "n") -TARGET_BUILTIN(__nvvm_atom_cta_and_gen_ll, "LLiLLiD*LLi", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_and_gen_ll, "LLiLLiD*LLi", "n", SM_60) - -BUILTIN(__nvvm_atom_or_gen_i, "iiD*i", "n") -TARGET_BUILTIN(__nvvm_atom_cta_or_gen_i, "iiD*i", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_or_gen_i, "iiD*i", "n", SM_60) -BUILTIN(__nvvm_atom_or_gen_l, "LiLiD*Li", "n") -TARGET_BUILTIN(__nvvm_atom_cta_or_gen_l, "LiLiD*Li", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_or_gen_l, "LiLiD*Li", "n", SM_60) -BUILTIN(__nvvm_atom_or_gen_ll, "LLiLLiD*LLi", "n") -TARGET_BUILTIN(__nvvm_atom_cta_or_gen_ll, "LLiLLiD*LLi", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_or_gen_ll, "LLiLLiD*LLi", "n", SM_60) - -BUILTIN(__nvvm_atom_xor_gen_i, "iiD*i", "n") -TARGET_BUILTIN(__nvvm_atom_cta_xor_gen_i, "iiD*i", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_xor_gen_i, "iiD*i", "n", SM_60) -BUILTIN(__nvvm_atom_xor_gen_l, "LiLiD*Li", "n") -TARGET_BUILTIN(__nvvm_atom_cta_xor_gen_l, "LiLiD*Li", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_xor_gen_l, "LiLiD*Li", "n", SM_60) -BUILTIN(__nvvm_atom_xor_gen_ll, "LLiLLiD*LLi", "n") -TARGET_BUILTIN(__nvvm_atom_cta_xor_gen_ll, "LLiLLiD*LLi", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_xor_gen_ll, "LLiLLiD*LLi", "n", SM_60) - -TARGET_BUILTIN(__nvvm_atom_cas_gen_us, "UsUsD*UsUs", "n", SM_70) -TARGET_BUILTIN(__nvvm_atom_cta_cas_gen_us, "UsUsD*UsUs", "n", SM_70) -TARGET_BUILTIN(__nvvm_atom_sys_cas_gen_us, "UsUsD*UsUs", "n", SM_70) -BUILTIN(__nvvm_atom_cas_gen_i, "iiD*ii", "n") -TARGET_BUILTIN(__nvvm_atom_cta_cas_gen_i, "iiD*ii", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_cas_gen_i, "iiD*ii", "n", SM_60) -BUILTIN(__nvvm_atom_cas_gen_l, "LiLiD*LiLi", "n") -TARGET_BUILTIN(__nvvm_atom_cta_cas_gen_l, "LiLiD*LiLi", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_cas_gen_l, "LiLiD*LiLi", "n", SM_60) -BUILTIN(__nvvm_atom_cas_gen_ll, "LLiLLiD*LLiLLi", "n") -TARGET_BUILTIN(__nvvm_atom_cta_cas_gen_ll, "LLiLLiD*LLiLLi", "n", SM_60) -TARGET_BUILTIN(__nvvm_atom_sys_cas_gen_ll, "LLiLLiD*LLiLLi", "n", SM_60) - -// Compiler Error Warn -BUILTIN(__nvvm_compiler_error, "vcC*4", "n") -BUILTIN(__nvvm_compiler_warn, "vcC*4", "n") - -BUILTIN(__nvvm_ldu_c, "ccC*", "") -BUILTIN(__nvvm_ldu_sc, "ScScC*", "") -BUILTIN(__nvvm_ldu_s, "ssC*", "") -BUILTIN(__nvvm_ldu_i, "iiC*", "") -BUILTIN(__nvvm_ldu_l, "LiLiC*", "") -BUILTIN(__nvvm_ldu_ll, "LLiLLiC*", "") - -BUILTIN(__nvvm_ldu_uc, "UcUcC*", "") -BUILTIN(__nvvm_ldu_us, "UsUsC*", "") -BUILTIN(__nvvm_ldu_ui, "UiUiC*", "") -BUILTIN(__nvvm_ldu_ul, "ULiULiC*", "") -BUILTIN(__nvvm_ldu_ull, "ULLiULLiC*", "") - -BUILTIN(__nvvm_ldu_h, "hhC*", "") -BUILTIN(__nvvm_ldu_f, "ffC*", "") -BUILTIN(__nvvm_ldu_d, "ddC*", "") - -BUILTIN(__nvvm_ldu_c2, "E2cE2cC*", "") -BUILTIN(__nvvm_ldu_sc2, "E2ScE2ScC*", "") -BUILTIN(__nvvm_ldu_c4, "E4cE4cC*", "") -BUILTIN(__nvvm_ldu_sc4, "E4ScE4ScC*", "") -BUILTIN(__nvvm_ldu_s2, "E2sE2sC*", "") -BUILTIN(__nvvm_ldu_s4, "E4sE4sC*", "") -BUILTIN(__nvvm_ldu_i2, "E2iE2iC*", "") -BUILTIN(__nvvm_ldu_i4, "E4iE4iC*", "") -BUILTIN(__nvvm_ldu_l2, "E2LiE2LiC*", "") -BUILTIN(__nvvm_ldu_ll2, "E2LLiE2LLiC*", "") - -BUILTIN(__nvvm_ldu_uc2, "E2UcE2UcC*", "") -BUILTIN(__nvvm_ldu_uc4, "E4UcE4UcC*", "") -BUILTIN(__nvvm_ldu_us2, "E2UsE2UsC*", "") -BUILTIN(__nvvm_ldu_us4, "E4UsE4UsC*", "") -BUILTIN(__nvvm_ldu_ui2, "E2UiE2UiC*", "") -BUILTIN(__nvvm_ldu_ui4, "E4UiE4UiC*", "") -BUILTIN(__nvvm_ldu_ul2, "E2ULiE2ULiC*", "") -BUILTIN(__nvvm_ldu_ull2, "E2ULLiE2ULLiC*", "") - -BUILTIN(__nvvm_ldu_h2, "E2hE2hC*", "") -BUILTIN(__nvvm_ldu_f2, "E2fE2fC*", "") -BUILTIN(__nvvm_ldu_f4, "E4fE4fC*", "") -BUILTIN(__nvvm_ldu_d2, "E2dE2dC*", "") - -BUILTIN(__nvvm_ldg_c, "ccC*", "") -BUILTIN(__nvvm_ldg_sc, "ScScC*", "") -BUILTIN(__nvvm_ldg_s, "ssC*", "") -BUILTIN(__nvvm_ldg_i, "iiC*", "") -BUILTIN(__nvvm_ldg_l, "LiLiC*", "") -BUILTIN(__nvvm_ldg_ll, "LLiLLiC*", "") - -BUILTIN(__nvvm_ldg_uc, "UcUcC*", "") -BUILTIN(__nvvm_ldg_us, "UsUsC*", "") -BUILTIN(__nvvm_ldg_ui, "UiUiC*", "") -BUILTIN(__nvvm_ldg_ul, "ULiULiC*", "") -BUILTIN(__nvvm_ldg_ull, "ULLiULLiC*", "") - -BUILTIN(__nvvm_ldg_h, "hhC*", "") -BUILTIN(__nvvm_ldg_f, "ffC*", "") -BUILTIN(__nvvm_ldg_d, "ddC*", "") - -BUILTIN(__nvvm_ldg_c2, "E2cE2cC*", "") -BUILTIN(__nvvm_ldg_sc2, "E2ScE2ScC*", "") -BUILTIN(__nvvm_ldg_c4, "E4cE4cC*", "") -BUILTIN(__nvvm_ldg_sc4, "E4ScE4ScC*", "") -BUILTIN(__nvvm_ldg_s2, "E2sE2sC*", "") -BUILTIN(__nvvm_ldg_s4, "E4sE4sC*", "") -BUILTIN(__nvvm_ldg_i2, "E2iE2iC*", "") -BUILTIN(__nvvm_ldg_i4, "E4iE4iC*", "") -BUILTIN(__nvvm_ldg_l2, "E2LiE2LiC*", "") -BUILTIN(__nvvm_ldg_ll2, "E2LLiE2LLiC*", "") - -BUILTIN(__nvvm_ldg_uc2, "E2UcE2UcC*", "") -BUILTIN(__nvvm_ldg_uc4, "E4UcE4UcC*", "") -BUILTIN(__nvvm_ldg_us2, "E2UsE2UsC*", "") -BUILTIN(__nvvm_ldg_us4, "E4UsE4UsC*", "") -BUILTIN(__nvvm_ldg_ui2, "E2UiE2UiC*", "") -BUILTIN(__nvvm_ldg_ui4, "E4UiE4UiC*", "") -BUILTIN(__nvvm_ldg_ul2, "E2ULiE2ULiC*", "") -BUILTIN(__nvvm_ldg_ull2, "E2ULLiE2ULLiC*", "") - -BUILTIN(__nvvm_ldg_h2, "E2hE2hC*", "") -BUILTIN(__nvvm_ldg_f2, "E2fE2fC*", "") -BUILTIN(__nvvm_ldg_f4, "E4fE4fC*", "") -BUILTIN(__nvvm_ldg_d2, "E2dE2dC*", "") - -// Address space predicates. -BUILTIN(__nvvm_isspacep_const, "bvC*", "nc") -BUILTIN(__nvvm_isspacep_global, "bvC*", "nc") -BUILTIN(__nvvm_isspacep_local, "bvC*", "nc") -BUILTIN(__nvvm_isspacep_shared, "bvC*", "nc") -TARGET_BUILTIN(__nvvm_isspacep_shared_cluster,"bvC*", "nc", AND(SM_90,PTX78)) - -// Builtins to support WMMA instructions on sm_70 -TARGET_BUILTIN(__hmma_m16n16k16_ld_a, "vi*iC*UiIi", "", AND(SM_70,PTX60)) -TARGET_BUILTIN(__hmma_m16n16k16_ld_b, "vi*iC*UiIi", "", AND(SM_70,PTX60)) -TARGET_BUILTIN(__hmma_m16n16k16_ld_c_f16, "vi*iC*UiIi", "", AND(SM_70,PTX60)) -TARGET_BUILTIN(__hmma_m16n16k16_ld_c_f32, "vf*fC*UiIi", "", AND(SM_70,PTX60)) -TARGET_BUILTIN(__hmma_m16n16k16_st_c_f16, "vi*iC*UiIi", "", AND(SM_70,PTX60)) -TARGET_BUILTIN(__hmma_m16n16k16_st_c_f32, "vf*fC*UiIi", "", AND(SM_70,PTX60)) - -TARGET_BUILTIN(__hmma_m32n8k16_ld_a, "vi*iC*UiIi", "", AND(SM_70,PTX61)) -TARGET_BUILTIN(__hmma_m32n8k16_ld_b, "vi*iC*UiIi", "", AND(SM_70,PTX61)) -TARGET_BUILTIN(__hmma_m32n8k16_ld_c_f16, "vi*iC*UiIi", "", AND(SM_70,PTX61)) -TARGET_BUILTIN(__hmma_m32n8k16_ld_c_f32, "vf*fC*UiIi", "", AND(SM_70,PTX61)) -TARGET_BUILTIN(__hmma_m32n8k16_st_c_f16, "vi*iC*UiIi", "", AND(SM_70,PTX61)) -TARGET_BUILTIN(__hmma_m32n8k16_st_c_f32, "vf*fC*UiIi", "", AND(SM_70,PTX61)) - -TARGET_BUILTIN(__hmma_m8n32k16_ld_a, "vi*iC*UiIi", "", AND(SM_70,PTX61)) -TARGET_BUILTIN(__hmma_m8n32k16_ld_b, "vi*iC*UiIi", "", AND(SM_70,PTX61)) -TARGET_BUILTIN(__hmma_m8n32k16_ld_c_f16, "vi*iC*UiIi", "", AND(SM_70,PTX61)) -TARGET_BUILTIN(__hmma_m8n32k16_ld_c_f32, "vf*fC*UiIi", "", AND(SM_70,PTX61)) -TARGET_BUILTIN(__hmma_m8n32k16_st_c_f16, "vi*iC*UiIi", "", AND(SM_70,PTX61)) -TARGET_BUILTIN(__hmma_m8n32k16_st_c_f32, "vf*fC*UiIi", "", AND(SM_70,PTX61)) - -TARGET_BUILTIN(__hmma_m16n16k16_mma_f16f16, "vi*iC*iC*iC*IiIi", "", AND(SM_70,PTX60)) -TARGET_BUILTIN(__hmma_m16n16k16_mma_f32f16, "vf*iC*iC*iC*IiIi", "", AND(SM_70,PTX60)) -TARGET_BUILTIN(__hmma_m16n16k16_mma_f32f32, "vf*iC*iC*fC*IiIi", "", AND(SM_70,PTX60)) -TARGET_BUILTIN(__hmma_m16n16k16_mma_f16f32, "vi*iC*iC*fC*IiIi", "", AND(SM_70,PTX60)) - -TARGET_BUILTIN(__hmma_m32n8k16_mma_f16f16, "vi*iC*iC*iC*IiIi", "", AND(SM_70,PTX61)) -TARGET_BUILTIN(__hmma_m32n8k16_mma_f32f16, "vf*iC*iC*iC*IiIi", "", AND(SM_70,PTX61)) -TARGET_BUILTIN(__hmma_m32n8k16_mma_f32f32, "vf*iC*iC*fC*IiIi", "", AND(SM_70,PTX61)) -TARGET_BUILTIN(__hmma_m32n8k16_mma_f16f32, "vi*iC*iC*fC*IiIi", "", AND(SM_70,PTX61)) - -TARGET_BUILTIN(__hmma_m8n32k16_mma_f16f16, "vi*iC*iC*iC*IiIi", "", AND(SM_70,PTX61)) -TARGET_BUILTIN(__hmma_m8n32k16_mma_f32f16, "vf*iC*iC*iC*IiIi", "", AND(SM_70,PTX61)) -TARGET_BUILTIN(__hmma_m8n32k16_mma_f32f32, "vf*iC*iC*fC*IiIi", "", AND(SM_70,PTX61)) -TARGET_BUILTIN(__hmma_m8n32k16_mma_f16f32, "vi*iC*iC*fC*IiIi", "", AND(SM_70,PTX61)) - -// Builtins to support integer and sub-integer WMMA instructions on sm_72/sm_75 -TARGET_BUILTIN(__bmma_m8n8k128_ld_a_b1, "vi*iC*UiIi", "", AND(SM_75,PTX63)) -TARGET_BUILTIN(__bmma_m8n8k128_ld_b_b1, "vi*iC*UiIi", "", AND(SM_75,PTX63)) -TARGET_BUILTIN(__bmma_m8n8k128_ld_c, "vi*iC*UiIi", "", AND(SM_75,PTX63)) -TARGET_BUILTIN(__bmma_m8n8k128_mma_and_popc_b1, "vi*iC*iC*iC*Ii", "", AND(SM_80,PTX71)) -TARGET_BUILTIN(__bmma_m8n8k128_mma_xor_popc_b1, "vi*iC*iC*iC*Ii", "", AND(SM_75,PTX63)) -TARGET_BUILTIN(__bmma_m8n8k128_st_c_i32, "vi*iC*UiIi", "", AND(SM_75,PTX63)) -TARGET_BUILTIN(__imma_m16n16k16_ld_a_s8, "vi*iC*UiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m16n16k16_ld_a_u8, "vi*iC*UiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m16n16k16_ld_b_s8, "vi*iC*UiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m16n16k16_ld_b_u8, "vi*iC*UiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m16n16k16_ld_c, "vi*iC*UiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m16n16k16_mma_s8, "vi*iC*iC*iC*IiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m16n16k16_mma_u8, "vi*iC*iC*iC*IiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m16n16k16_st_c_i32, "vi*iC*UiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m32n8k16_ld_a_s8, "vi*iC*UiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m32n8k16_ld_a_u8, "vi*iC*UiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m32n8k16_ld_b_s8, "vi*iC*UiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m32n8k16_ld_b_u8, "vi*iC*UiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m32n8k16_ld_c, "vi*iC*UiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m32n8k16_mma_s8, "vi*iC*iC*iC*IiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m32n8k16_mma_u8, "vi*iC*iC*iC*IiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m32n8k16_st_c_i32, "vi*iC*UiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m8n32k16_ld_a_s8, "vi*iC*UiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m8n32k16_ld_a_u8, "vi*iC*UiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m8n32k16_ld_b_s8, "vi*iC*UiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m8n32k16_ld_b_u8, "vi*iC*UiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m8n32k16_ld_c, "vi*iC*UiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m8n32k16_mma_s8, "vi*iC*iC*iC*IiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m8n32k16_mma_u8, "vi*iC*iC*iC*IiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m8n32k16_st_c_i32, "vi*iC*UiIi", "", AND(SM_72,PTX63)) -TARGET_BUILTIN(__imma_m8n8k32_ld_a_s4, "vi*iC*UiIi", "", AND(SM_75,PTX63)) -TARGET_BUILTIN(__imma_m8n8k32_ld_a_u4, "vi*iC*UiIi", "", AND(SM_75,PTX63)) -TARGET_BUILTIN(__imma_m8n8k32_ld_b_s4, "vi*iC*UiIi", "", AND(SM_75,PTX63)) -TARGET_BUILTIN(__imma_m8n8k32_ld_b_u4, "vi*iC*UiIi", "", AND(SM_75,PTX63)) -TARGET_BUILTIN(__imma_m8n8k32_ld_c, "vi*iC*UiIi", "", AND(SM_75,PTX63)) -TARGET_BUILTIN(__imma_m8n8k32_mma_s4, "vi*iC*iC*iC*IiIi", "", AND(SM_75,PTX63)) -TARGET_BUILTIN(__imma_m8n8k32_mma_u4, "vi*iC*iC*iC*IiIi", "", AND(SM_75,PTX63)) -TARGET_BUILTIN(__imma_m8n8k32_st_c_i32, "vi*iC*UiIi", "", AND(SM_75,PTX63)) - -// Builtins to support double and alternate float WMMA instructions on sm_80 -TARGET_BUILTIN(__dmma_m8n8k4_ld_a, "vd*dC*UiIi", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__dmma_m8n8k4_ld_b, "vd*dC*UiIi", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__dmma_m8n8k4_ld_c, "vd*dC*UiIi", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__dmma_m8n8k4_st_c_f64, "vd*dC*UiIi", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__dmma_m8n8k4_mma_f64, "vd*dC*dC*dC*IiIi", "", AND(SM_80,PTX70)) - -TARGET_BUILTIN(__mma_bf16_m16n16k16_ld_a, "vi*iC*UiIi", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__mma_bf16_m16n16k16_ld_b, "vi*iC*UiIi", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__mma_bf16_m16n16k16_mma_f32, "vf*iC*iC*fC*IiIi", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__mma_bf16_m8n32k16_ld_a, "vi*iC*UiIi", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__mma_bf16_m8n32k16_ld_b, "vi*iC*UiIi", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__mma_bf16_m8n32k16_mma_f32, "vf*iC*iC*fC*IiIi", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__mma_bf16_m32n8k16_ld_a, "vi*iC*UiIi", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__mma_bf16_m32n8k16_ld_b, "vi*iC*UiIi", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__mma_bf16_m32n8k16_mma_f32, "vf*iC*iC*fC*IiIi", "", AND(SM_80,PTX70)) - -TARGET_BUILTIN(__mma_tf32_m16n16k8_ld_a, "vi*iC*UiIi", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__mma_tf32_m16n16k8_ld_b, "vi*iC*UiIi", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__mma_tf32_m16n16k8_ld_c, "vf*fC*UiIi", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__mma_m16n16k8_st_c_f32, "vf*fC*UiIi", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__mma_tf32_m16n16k8_mma_f32, "vf*iC*iC*fC*IiIi", "", AND(SM_80,PTX70)) - -// Async Copy -TARGET_BUILTIN(__nvvm_cp_async_mbarrier_arrive, "vWi*", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_cp_async_mbarrier_arrive_shared, "vWi*3", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_cp_async_mbarrier_arrive_noinc, "vWi*", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_cp_async_mbarrier_arrive_noinc_shared, "vWi*3", "", AND(SM_80,PTX70)) - -TARGET_BUILTIN(__nvvm_cp_async_ca_shared_global_4, "vv*3vC*1.", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_cp_async_ca_shared_global_8, "vv*3vC*1.", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_cp_async_ca_shared_global_16, "vv*3vC*1.", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_cp_async_cg_shared_global_16, "vv*3vC*1.", "", AND(SM_80,PTX70)) - -TARGET_BUILTIN(__nvvm_cp_async_commit_group, "v", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_cp_async_wait_group, "vIi", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_cp_async_wait_all, "v", "", AND(SM_80,PTX70)) - - -// bf16, bf16x2 abs, neg -TARGET_BUILTIN(__nvvm_abs_bf16, "yy", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_abs_bf16x2, "V2yV2y", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_neg_bf16, "yy", "", AND(SM_80,PTX70)) -TARGET_BUILTIN(__nvvm_neg_bf16x2, "V2yV2y", "", AND(SM_80,PTX70)) - -TARGET_BUILTIN(__nvvm_mapa, "v*v*i", "", AND(SM_90, PTX78)) -TARGET_BUILTIN(__nvvm_mapa_shared_cluster, "v*3v*3i", "", AND(SM_90, PTX78)) -TARGET_BUILTIN(__nvvm_getctarank, "iv*", "", AND(SM_90, PTX78)) -TARGET_BUILTIN(__nvvm_getctarank_shared_cluster, "iv*3", "", AND(SM_90,PTX78)) - -#undef BUILTIN -#undef TARGET_BUILTIN -#pragma pop_macro("AND") -#pragma pop_macro("SM_53") -#pragma pop_macro("SM_60") -#pragma pop_macro("SM_70") -#pragma pop_macro("SM_72") -#pragma pop_macro("SM_75") -#pragma pop_macro("SM_80") -#pragma pop_macro("SM_86") -#pragma pop_macro("SM_87") -#pragma pop_macro("SM_89") -#pragma pop_macro("SM_90") -#pragma pop_macro("SM_90a") -#pragma pop_macro("SM_100") -#pragma pop_macro("SM_100a") -#pragma pop_macro("PTX42") -#pragma pop_macro("PTX60") -#pragma pop_macro("PTX61") -#pragma pop_macro("PTX62") -#pragma pop_macro("PTX63") -#pragma pop_macro("PTX64") -#pragma pop_macro("PTX65") -#pragma pop_macro("PTX70") -#pragma pop_macro("PTX71") -#pragma pop_macro("PTX72") -#pragma pop_macro("PTX73") -#pragma pop_macro("PTX74") -#pragma pop_macro("PTX75") -#pragma pop_macro("PTX76") -#pragma pop_macro("PTX77") -#pragma pop_macro("PTX78") -#pragma pop_macro("PTX80") -#pragma pop_macro("PTX81") -#pragma pop_macro("PTX82") -#pragma pop_macro("PTX83") -#pragma pop_macro("PTX84") -#pragma pop_macro("PTX85") -#pragma pop_macro("PTX86") diff --git clang/include/clang/Basic/BuiltinsNVPTX.td clang/include/clang/Basic/BuiltinsNVPTX.td new file mode 100644 index 000000000000..9d24a992563a --- /dev/null +++ clang/include/clang/Basic/BuiltinsNVPTX.td @@ -0,0 +1,1079 @@ +//===--- BuiltinsNVPTX.td - NVPTX Builtin function defs ---------*- 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 the PTX-specific builtin function database. +// +//===----------------------------------------------------------------------===// + +include "clang/Basic/BuiltinsBase.td" + +class SMFeatures { + string Features; +} + +class SM<string version, list<SMFeatures> newer_list> : SMFeatures { + let Features = !foldl(!strconcat("sm_", version), newer_list, f, newer, + !strconcat(f, "|", newer.Features)); +} + +let Features = "sm_100a" in def SM_100a : SMFeatures; + +def SM_100 : SM<"100", [SM_100a]>; + +let Features = "sm_90a" in def SM_90a : SMFeatures; + +def SM_90 : SM<"90", [SM_90a, SM_100]>; +def SM_89 : SM<"89", [SM_90]>; +def SM_87 : SM<"87", [SM_89]>; +def SM_86 : SM<"86", [SM_87]>; +def SM_80 : SM<"80", [SM_86]>; +def SM_75 : SM<"75", [SM_80]>; +def SM_72 : SM<"72", [SM_75]>; +def SM_70 : SM<"70", [SM_72]>; +def SM_62 : SM<"62", [SM_70]>; +def SM_61 : SM<"61", [SM_62]>; +def SM_60 : SM<"60", [SM_61]>; +def SM_53 : SM<"53", [SM_60]>; + +class PTXFeatures { + string Features; +} + +class PTX<string version, PTXFeatures newer> : PTXFeatures { + let Features = !strconcat("ptx", version, "|", newer.Features); +} + +let Features = "ptx87" in def PTX87 : PTXFeatures; + +def PTX86 : PTX<"86", PTX87>; +def PTX85 : PTX<"85", PTX86>; +def PTX84 : PTX<"84", PTX85>; +def PTX83 : PTX<"83", PTX84>; +def PTX82 : PTX<"82", PTX83>; +def PTX81 : PTX<"81", PTX82>; +def PTX80 : PTX<"80", PTX81>; +def PTX78 : PTX<"78", PTX80>; +def PTX77 : PTX<"77", PTX78>; +def PTX76 : PTX<"76", PTX77>; +def PTX75 : PTX<"75", PTX76>; +def PTX74 : PTX<"74", PTX75>; +def PTX73 : PTX<"73", PTX74>; +def PTX72 : PTX<"72", PTX73>; +def PTX71 : PTX<"71", PTX72>; +def PTX70 : PTX<"70", PTX71>; +def PTX65 : PTX<"65", PTX70>; +def PTX64 : PTX<"64", PTX65>; +def PTX63 : PTX<"63", PTX64>; +def PTX62 : PTX<"62", PTX63>; +def PTX61 : PTX<"61", PTX62>; +def PTX60 : PTX<"60", PTX61>; +def PTX42 : PTX<"42", PTX60>; + +class NVPTXBuiltin<string prototype> : TargetBuiltin { + let Spellings = [NAME]; + let Prototype = prototype; +} + +class NVPTXBuiltinSM<string prototype, SMFeatures sm> : NVPTXBuiltin<prototype> { + let Features = sm.Features; +} + +class NVPTXBuiltinPTX<string prototype, PTXFeatures ptx> : NVPTXBuiltin<prototype> { + let Features = ptx.Features; +} + +class NVPTXBuiltinSMAndPTX<string prototype, SMFeatures sm, PTXFeatures ptx> : NVPTXBuiltin<prototype> { + let Features = !strconcat("(", sm.Features, "),(", ptx.Features, ")"); +} + +// Special Registers + +let Attributes = [NoThrow, Const] in { + def __nvvm_read_ptx_sreg_tid_x : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_tid_y : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_tid_z : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_tid_w : NVPTXBuiltin<"int()">; + + def __nvvm_read_ptx_sreg_ntid_x : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_ntid_y : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_ntid_z : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_ntid_w : NVPTXBuiltin<"int()">; + + def __nvvm_read_ptx_sreg_ctaid_x : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_ctaid_y : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_ctaid_z : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_ctaid_w : NVPTXBuiltin<"int()">; + + def __nvvm_read_ptx_sreg_nctaid_x : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_nctaid_y : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_nctaid_z : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_nctaid_w : NVPTXBuiltin<"int()">; + + def __nvvm_read_ptx_sreg_clusterid_x : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_clusterid_y : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_clusterid_z : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_clusterid_w : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + + def __nvvm_read_ptx_sreg_nclusterid_x : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_nclusterid_y : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_nclusterid_z : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_nclusterid_w : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + + def __nvvm_read_ptx_sreg_cluster_ctaid_x : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_cluster_ctaid_y : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_cluster_ctaid_z : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_cluster_ctaid_w : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + + def __nvvm_read_ptx_sreg_cluster_nctaid_x : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_cluster_nctaid_y : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_cluster_nctaid_z : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_cluster_nctaid_w : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + + def __nvvm_read_ptx_sreg_cluster_ctarank : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_cluster_nctarank : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + + def __nvvm_is_explicit_cluster : NVPTXBuiltinSMAndPTX<"bool()", SM_90, PTX78>; + + def __nvvm_read_ptx_sreg_laneid : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_warpid : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_nwarpid : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_warpsize : NVPTXBuiltin<"int()">; + + def __nvvm_read_ptx_sreg_smid : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_nsmid : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_gridid : NVPTXBuiltin<"int()">; + + def __nvvm_read_ptx_sreg_lanemask_eq : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_lanemask_le : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_lanemask_lt : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_lanemask_ge : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_lanemask_gt : NVPTXBuiltin<"int()">; +} + +let Attributes = [NoThrow] in { + def __nvvm_read_ptx_sreg_clock : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_clock64 : NVPTXBuiltin<"long long int()">; + def __nvvm_read_ptx_sreg_globaltimer : NVPTXBuiltin<"long long int()">; + + def __nvvm_read_ptx_sreg_pm0 : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_pm1 : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_pm2 : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_pm3 : NVPTXBuiltin<"int()">; +} + +// MISC + +def __nvvm_prmt : NVPTXBuiltin<"unsigned int(unsigned int, unsigned int, unsigned int)">; +let Attributes = [NoReturn] in { + def __nvvm_exit : NVPTXBuiltin<"void()">; + def __nvvm_reflect : NVPTXBuiltin<"unsigned int(char const *)">; +} +let Attributes = [NoThrow] in { + def __nvvm_nanosleep : NVPTXBuiltinSMAndPTX<"void(unsigned int)", SM_70, PTX63>; +} + +// Min Max + +def __nvvm_fmin_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16, __fp16)", SM_80, PTX70>; +def __nvvm_fmin_ftz_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16, __fp16)", SM_80, PTX70>; +def __nvvm_fmin_nan_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16, __fp16)", SM_80, PTX70>; +def __nvvm_fmin_ftz_nan_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16, __fp16)", SM_80, PTX70>; +def __nvvm_fmin_xorsign_abs_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16, __fp16)", SM_86, PTX72>; +def __nvvm_fmin_ftz_xorsign_abs_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16, __fp16)", SM_86, PTX72>; +def __nvvm_fmin_nan_xorsign_abs_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16, __fp16)", SM_86, PTX72>; +def __nvvm_fmin_ftz_nan_xorsign_abs_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16, __fp16)", SM_86, PTX72>; +def __nvvm_fmin_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>, _Vector<2, __fp16>)", SM_80, PTX70>; +def __nvvm_fmin_ftz_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>, _Vector<2, __fp16>)", SM_80, PTX70>; +def __nvvm_fmin_nan_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>, _Vector<2, __fp16>)", SM_80, PTX70>; +def __nvvm_fmin_ftz_nan_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>, _Vector<2, __fp16>)", SM_80, PTX70>; +def __nvvm_fmin_xorsign_abs_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>, _Vector<2, __fp16>)", SM_86, PTX72>; +def __nvvm_fmin_ftz_xorsign_abs_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>, _Vector<2, __fp16>)", SM_86, PTX72>; +def __nvvm_fmin_nan_xorsign_abs_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>, _Vector<2, __fp16>)", SM_86, PTX72>; +def __nvvm_fmin_ftz_nan_xorsign_abs_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>, _Vector<2, __fp16>)", SM_86, PTX72>; +def __nvvm_fmin_bf16 : NVPTXBuiltinSMAndPTX<"__bf16(__bf16, __bf16)", SM_80, PTX70>; +def __nvvm_fmin_ftz_bf16 : NVPTXBuiltinSMAndPTX<"__bf16(__bf16, __bf16)", SM_80, PTX70>; +def __nvvm_fmin_nan_bf16 : NVPTXBuiltinSMAndPTX<"__bf16(__bf16, __bf16)", SM_80, PTX70>; +def __nvvm_fmin_ftz_nan_bf16 : NVPTXBuiltinSMAndPTX<"__bf16(__bf16, __bf16)", SM_80, PTX70>; +def __nvvm_fmin_xorsign_abs_bf16 : NVPTXBuiltinSMAndPTX<"__bf16(__bf16, __bf16)", SM_86, PTX72>; +def __nvvm_fmin_nan_xorsign_abs_bf16 : NVPTXBuiltinSMAndPTX<"__bf16(__bf16, __bf16)", SM_86, PTX72>; +def __nvvm_fmin_bf16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __bf16>(_Vector<2, __bf16>, _Vector<2, __bf16>)", SM_80, PTX70>; +def __nvvm_fmin_ftz_bf16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __bf16>(_Vector<2, __bf16>, _Vector<2, __bf16>)", SM_80, PTX70>; +def __nvvm_fmin_nan_bf16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __bf16>(_Vector<2, __bf16>, _Vector<2, __bf16>)", SM_80, PTX70>; +def __nvvm_fmin_ftz_nan_bf16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __bf16>(_Vector<2, __bf16>, _Vector<2, __bf16>)", SM_80, PTX70>; +def __nvvm_fmin_xorsign_abs_bf16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __bf16>(_Vector<2, __bf16>, _Vector<2, __bf16>)", SM_86, PTX72>; +def __nvvm_fmin_nan_xorsign_abs_bf16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __bf16>(_Vector<2, __bf16>, _Vector<2, __bf16>)", SM_86, PTX72>; +def __nvvm_fmin_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_fmin_ftz_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_fmin_nan_f : NVPTXBuiltinSMAndPTX<"float(float, float)", SM_80, PTX70>; +def __nvvm_fmin_ftz_nan_f : NVPTXBuiltinSMAndPTX<"float(float, float)", SM_80, PTX70>; +def __nvvm_fmin_xorsign_abs_f : NVPTXBuiltinSMAndPTX<"float(float, float)", SM_86, PTX72>; +def __nvvm_fmin_ftz_xorsign_abs_f : NVPTXBuiltinSMAndPTX<"float(float, float)", SM_86, PTX72>; +def __nvvm_fmin_nan_xorsign_abs_f : NVPTXBuiltinSMAndPTX<"float(float, float)", SM_86, PTX72>; +def __nvvm_fmin_ftz_nan_xorsign_abs_f : NVPTXBuiltinSMAndPTX<"float(float, float)", SM_86, PTX72>; +def __nvvm_fmin_d : NVPTXBuiltin<"double(double, double)">; + +def __nvvm_fmax_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16, __fp16)", SM_80, PTX70>; +def __nvvm_fmax_ftz_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16, __fp16)", SM_80, PTX70>; +def __nvvm_fmax_nan_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16, __fp16)", SM_80, PTX70>; +def __nvvm_fmax_ftz_nan_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16, __fp16)", SM_80, PTX70>; +def __nvvm_fmax_xorsign_abs_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16, __fp16)", SM_86, PTX72>; +def __nvvm_fmax_ftz_xorsign_abs_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16, __fp16)", SM_86, PTX72>; +def __nvvm_fmax_nan_xorsign_abs_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16, __fp16)", SM_86, PTX72>; +def __nvvm_fmax_ftz_nan_xorsign_abs_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16, __fp16)", SM_86, PTX72>; +def __nvvm_fmax_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>, _Vector<2, __fp16>)", SM_80, PTX70>; +def __nvvm_fmax_ftz_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>, _Vector<2, __fp16>)", SM_80, PTX70>; +def __nvvm_fmax_nan_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>, _Vector<2, __fp16>)", SM_80, PTX70>; +def __nvvm_fmax_ftz_nan_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>, _Vector<2, __fp16>)", SM_80, PTX70>; +def __nvvm_fmax_xorsign_abs_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>, _Vector<2, __fp16>)", SM_86, PTX72>; +def __nvvm_fmax_ftz_xorsign_abs_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>, _Vector<2, __fp16>)", SM_86, PTX72>; +def __nvvm_fmax_nan_xorsign_abs_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>, _Vector<2, __fp16>)", SM_86, PTX72>; +def __nvvm_fmax_ftz_nan_xorsign_abs_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>, _Vector<2, __fp16>)", SM_86, PTX72>; +def __nvvm_fmax_bf16 : NVPTXBuiltinSMAndPTX<"__bf16(__bf16, __bf16)", SM_80, PTX70>; +def __nvvm_fmax_ftz_bf16 : NVPTXBuiltinSMAndPTX<"__bf16(__bf16, __bf16)", SM_80, PTX70>; +def __nvvm_fmax_nan_bf16 : NVPTXBuiltinSMAndPTX<"__bf16(__bf16, __bf16)", SM_80, PTX70>; +def __nvvm_fmax_ftz_nan_bf16 : NVPTXBuiltinSMAndPTX<"__bf16(__bf16, __bf16)", SM_80, PTX70>; +def __nvvm_fmax_xorsign_abs_bf16 : NVPTXBuiltinSMAndPTX<"__bf16(__bf16, __bf16)", SM_86, PTX72>; +def __nvvm_fmax_nan_xorsign_abs_bf16 : NVPTXBuiltinSMAndPTX<"__bf16(__bf16, __bf16)", SM_86, PTX72>; +def __nvvm_fmax_bf16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __bf16>(_Vector<2, __bf16>, _Vector<2, __bf16>)", SM_80, PTX70>; +def __nvvm_fmax_ftz_bf16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __bf16>(_Vector<2, __bf16>, _Vector<2, __bf16>)", SM_80, PTX70>; +def __nvvm_fmax_nan_bf16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __bf16>(_Vector<2, __bf16>, _Vector<2, __bf16>)", SM_80, PTX70>; +def __nvvm_fmax_ftz_nan_bf16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __bf16>(_Vector<2, __bf16>, _Vector<2, __bf16>)", SM_80, PTX70>; +def __nvvm_fmax_xorsign_abs_bf16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __bf16>(_Vector<2, __bf16>, _Vector<2, __bf16>)", SM_86, PTX72>; +def __nvvm_fmax_nan_xorsign_abs_bf16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __bf16>(_Vector<2, __bf16>, _Vector<2, __bf16>)", SM_86, PTX72>; +def __nvvm_fmax_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_fmax_ftz_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_fmax_nan_f : NVPTXBuiltinSMAndPTX<"float(float, float)", SM_80, PTX70>; +def __nvvm_fmax_ftz_nan_f : NVPTXBuiltinSMAndPTX<"float(float, float)", SM_80, PTX70>; +def __nvvm_fmax_xorsign_abs_f : NVPTXBuiltinSMAndPTX<"float(float, float)", SM_86, PTX72>; +def __nvvm_fmax_ftz_xorsign_abs_f : NVPTXBuiltinSMAndPTX<"float(float, float)", SM_86, PTX72>; +def __nvvm_fmax_nan_xorsign_abs_f : NVPTXBuiltinSMAndPTX<"float(float, float)", SM_86, PTX72>; +def __nvvm_fmax_ftz_nan_xorsign_abs_f : NVPTXBuiltinSMAndPTX<"float(float, float)", SM_86, PTX72>; +def __nvvm_fmax_d : NVPTXBuiltin<"double(double, double)">; + +// Multiplication + +def __nvvm_mulhi_i : NVPTXBuiltin<"int(int, int)">; +def __nvvm_mulhi_ui : NVPTXBuiltin<"unsigned int(unsigned int, unsigned int)">; +def __nvvm_mulhi_ll : NVPTXBuiltin<"long long int(long long int, long long int)">; +def __nvvm_mulhi_ull : NVPTXBuiltin<"unsigned long long int(unsigned long long int, unsigned long long int)">; + +def __nvvm_mul_rn_ftz_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_mul_rn_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_mul_rz_ftz_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_mul_rz_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_mul_rm_ftz_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_mul_rm_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_mul_rp_ftz_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_mul_rp_f : NVPTXBuiltin<"float(float, float)">; + +def __nvvm_mul_rn_d : NVPTXBuiltin<"double(double, double)">; +def __nvvm_mul_rz_d : NVPTXBuiltin<"double(double, double)">; +def __nvvm_mul_rm_d : NVPTXBuiltin<"double(double, double)">; +def __nvvm_mul_rp_d : NVPTXBuiltin<"double(double, double)">; + +def __nvvm_mul24_i : NVPTXBuiltin<"int(int, int)">; +def __nvvm_mul24_ui : NVPTXBuiltin<"unsigned int(unsigned int, unsigned int)">; + +// Div + +def __nvvm_div_approx_ftz_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_div_approx_f : NVPTXBuiltin<"float(float, float)">; + +def __nvvm_div_rn_ftz_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_div_rn_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_div_rz_ftz_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_div_rz_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_div_rm_ftz_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_div_rm_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_div_rp_ftz_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_div_rp_f : NVPTXBuiltin<"float(float, float)">; + +def __nvvm_div_rn_d : NVPTXBuiltin<"double(double, double)">; +def __nvvm_div_rz_d : NVPTXBuiltin<"double(double, double)">; +def __nvvm_div_rm_d : NVPTXBuiltin<"double(double, double)">; +def __nvvm_div_rp_d : NVPTXBuiltin<"double(double, double)">; + +// Sad + +def __nvvm_sad_i : NVPTXBuiltin<"int(int, int, int)">; +def __nvvm_sad_ui : NVPTXBuiltin<"unsigned int(unsigned int, unsigned int, unsigned int)">; + +// Floor, Ceil + +def __nvvm_floor_ftz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_floor_f : NVPTXBuiltin<"float(float)">; +def __nvvm_floor_d : NVPTXBuiltin<"double(double)">; + +def __nvvm_ceil_ftz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_ceil_f : NVPTXBuiltin<"float(float)">; +def __nvvm_ceil_d : NVPTXBuiltin<"double(double)">; + +// Abs + +def __nvvm_fabs_ftz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_fabs_f : NVPTXBuiltin<"float(float)">; +def __nvvm_fabs_d : NVPTXBuiltin<"double(double)">; + +// Round + +def __nvvm_round_ftz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_round_f : NVPTXBuiltin<"float(float)">; +def __nvvm_round_d : NVPTXBuiltin<"double(double)">; + +// Trunc + +def __nvvm_trunc_ftz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_trunc_f : NVPTXBuiltin<"float(float)">; +def __nvvm_trunc_d : NVPTXBuiltin<"double(double)">; + +// Saturate + +def __nvvm_saturate_ftz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_saturate_f : NVPTXBuiltin<"float(float)">; +def __nvvm_saturate_d : NVPTXBuiltin<"double(double)">; + +// Exp2, Log2 + +def __nvvm_ex2_approx_ftz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_ex2_approx_f : NVPTXBuiltin<"float(float)">; +def __nvvm_ex2_approx_d : NVPTXBuiltin<"double(double)">; +def __nvvm_ex2_approx_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16)", SM_75, PTX70>; +def __nvvm_ex2_approx_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>)", SM_75, PTX70>; + +def __nvvm_lg2_approx_ftz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_lg2_approx_f : NVPTXBuiltin<"float(float)">; +def __nvvm_lg2_approx_d : NVPTXBuiltin<"double(double)">; + +// Sin, Cos + +def __nvvm_sin_approx_ftz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_sin_approx_f : NVPTXBuiltin<"float(float)">; + +def __nvvm_cos_approx_ftz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_cos_approx_f : NVPTXBuiltin<"float(float)">; + +// Fma + +def __nvvm_fma_rn_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16, __fp16, __fp16)", SM_53, PTX42>; +def __nvvm_fma_rn_ftz_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16, __fp16, __fp16)", SM_53, PTX42>; +def __nvvm_fma_rn_sat_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16, __fp16, __fp16)", SM_53, PTX42>; +def __nvvm_fma_rn_ftz_sat_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16, __fp16, __fp16)", SM_53, PTX42>; +def __nvvm_fma_rn_relu_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16, __fp16, __fp16)", SM_80, PTX70>; +def __nvvm_fma_rn_ftz_relu_f16 : NVPTXBuiltinSMAndPTX<"__fp16(__fp16, __fp16, __fp16)", SM_80, PTX70>; +def __nvvm_fma_rn_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>, _Vector<2, __fp16>, _Vector<2, __fp16>)", SM_53, PTX42>; +def __nvvm_fma_rn_ftz_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>, _Vector<2, __fp16>, _Vector<2, __fp16>)", SM_53, PTX42>; +def __nvvm_fma_rn_sat_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>, _Vector<2, __fp16>, _Vector<2, __fp16>)", SM_53, PTX42>; +def __nvvm_fma_rn_ftz_sat_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>, _Vector<2, __fp16>, _Vector<2, __fp16>)", SM_53, PTX42>; +def __nvvm_fma_rn_relu_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>, _Vector<2, __fp16>, _Vector<2, __fp16>)", SM_80, PTX70>; +def __nvvm_fma_rn_ftz_relu_f16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(_Vector<2, __fp16>, _Vector<2, __fp16>, _Vector<2, __fp16>)", SM_80, PTX70>; +def __nvvm_fma_rn_bf16 : NVPTXBuiltinSMAndPTX<"__bf16(__bf16, __bf16, __bf16)", SM_80, PTX70>; +def __nvvm_fma_rn_relu_bf16 : NVPTXBuiltinSMAndPTX<"__bf16(__bf16, __bf16, __bf16)", SM_80, PTX70>; +def __nvvm_fma_rn_bf16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __bf16>(_Vector<2, __bf16>, _Vector<2, __bf16>, _Vector<2, __bf16>)", SM_80, PTX70>; +def __nvvm_fma_rn_relu_bf16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __bf16>(_Vector<2, __bf16>, _Vector<2, __bf16>, _Vector<2, __bf16>)", SM_80, PTX70>; +def __nvvm_fma_rn_ftz_f : NVPTXBuiltin<"float(float, float, float)">; +def __nvvm_fma_rn_f : NVPTXBuiltin<"float(float, float, float)">; +def __nvvm_fma_rz_ftz_f : NVPTXBuiltin<"float(float, float, float)">; +def __nvvm_fma_rz_f : NVPTXBuiltin<"float(float, float, float)">; +def __nvvm_fma_rm_ftz_f : NVPTXBuiltin<"float(float, float, float)">; +def __nvvm_fma_rm_f : NVPTXBuiltin<"float(float, float, float)">; +def __nvvm_fma_rp_ftz_f : NVPTXBuiltin<"float(float, float, float)">; +def __nvvm_fma_rp_f : NVPTXBuiltin<"float(float, float, float)">; +def __nvvm_fma_rn_d : NVPTXBuiltin<"double(double, double, double)">; +def __nvvm_fma_rz_d : NVPTXBuiltin<"double(double, double, double)">; +def __nvvm_fma_rm_d : NVPTXBuiltin<"double(double, double, double)">; +def __nvvm_fma_rp_d : NVPTXBuiltin<"double(double, double, double)">; + +// Rcp + +def __nvvm_rcp_rn_ftz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_rcp_rn_f : NVPTXBuiltin<"float(float)">; +def __nvvm_rcp_rz_ftz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_rcp_rz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_rcp_rm_ftz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_rcp_rm_f : NVPTXBuiltin<"float(float)">; +def __nvvm_rcp_rp_ftz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_rcp_rp_f : NVPTXBuiltin<"float(float)">; + +def __nvvm_rcp_rn_d : NVPTXBuiltin<"double(double)">; +def __nvvm_rcp_rz_d : NVPTXBuiltin<"double(double)">; +def __nvvm_rcp_rm_d : NVPTXBuiltin<"double(double)">; +def __nvvm_rcp_rp_d : NVPTXBuiltin<"double(double)">; + +def __nvvm_rcp_approx_ftz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_rcp_approx_ftz_d : NVPTXBuiltin<"double(double)">; + +// Sqrt + +def __nvvm_sqrt_rn_ftz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_sqrt_rn_f : NVPTXBuiltin<"float(float)">; +def __nvvm_sqrt_rz_ftz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_sqrt_rz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_sqrt_rm_ftz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_sqrt_rm_f : NVPTXBuiltin<"float(float)">; +def __nvvm_sqrt_rp_ftz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_sqrt_rp_f : NVPTXBuiltin<"float(float)">; +def __nvvm_sqrt_approx_ftz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_sqrt_approx_f : NVPTXBuiltin<"float(float)">; + +def __nvvm_sqrt_rn_d : NVPTXBuiltin<"double(double)">; +def __nvvm_sqrt_rz_d : NVPTXBuiltin<"double(double)">; +def __nvvm_sqrt_rm_d : NVPTXBuiltin<"double(double)">; +def __nvvm_sqrt_rp_d : NVPTXBuiltin<"double(double)">; + +// Rsqrt + +def __nvvm_rsqrt_approx_ftz_f : NVPTXBuiltin<"float(float)">; +def __nvvm_rsqrt_approx_f : NVPTXBuiltin<"float(float)">; +def __nvvm_rsqrt_approx_d : NVPTXBuiltin<"double(double)">; + +// Add + +def __nvvm_add_rn_ftz_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_add_rn_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_add_rz_ftz_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_add_rz_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_add_rm_ftz_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_add_rm_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_add_rp_ftz_f : NVPTXBuiltin<"float(float, float)">; +def __nvvm_add_rp_f : NVPTXBuiltin<"float(float, float)">; + +def __nvvm_add_rn_d : NVPTXBuiltin<"double(double, double)">; +def __nvvm_add_rz_d : NVPTXBuiltin<"double(double, double)">; +def __nvvm_add_rm_d : NVPTXBuiltin<"double(double, double)">; +def __nvvm_add_rp_d : NVPTXBuiltin<"double(double, double)">; + +// Convert + +def __nvvm_d2f_rn_ftz : NVPTXBuiltin<"float(double)">; +def __nvvm_d2f_rn : NVPTXBuiltin<"float(double)">; +def __nvvm_d2f_rz_ftz : NVPTXBuiltin<"float(double)">; +def __nvvm_d2f_rz : NVPTXBuiltin<"float(double)">; +def __nvvm_d2f_rm_ftz : NVPTXBuiltin<"float(double)">; +def __nvvm_d2f_rm : NVPTXBuiltin<"float(double)">; +def __nvvm_d2f_rp_ftz : NVPTXBuiltin<"float(double)">; +def __nvvm_d2f_rp : NVPTXBuiltin<"float(double)">; + +def __nvvm_d2i_rn : NVPTXBuiltin<"int(double)">; +def __nvvm_d2i_rz : NVPTXBuiltin<"int(double)">; +def __nvvm_d2i_rm : NVPTXBuiltin<"int(double)">; +def __nvvm_d2i_rp : NVPTXBuiltin<"int(double)">; + +def __nvvm_d2ui_rn : NVPTXBuiltin<"unsigned int(double)">; +def __nvvm_d2ui_rz : NVPTXBuiltin<"unsigned int(double)">; +def __nvvm_d2ui_rm : NVPTXBuiltin<"unsigned int(double)">; +def __nvvm_d2ui_rp : NVPTXBuiltin<"unsigned int(double)">; + +def __nvvm_i2d_rn : NVPTXBuiltin<"double(int)">; +def __nvvm_i2d_rz : NVPTXBuiltin<"double(int)">; +def __nvvm_i2d_rm : NVPTXBuiltin<"double(int)">; +def __nvvm_i2d_rp : NVPTXBuiltin<"double(int)">; + +def __nvvm_ui2d_rn : NVPTXBuiltin<"double(unsigned int)">; +def __nvvm_ui2d_rz : NVPTXBuiltin<"double(unsigned int)">; +def __nvvm_ui2d_rm : NVPTXBuiltin<"double(unsigned int)">; +def __nvvm_ui2d_rp : NVPTXBuiltin<"double(unsigned int)">; + +def __nvvm_f2i_rn_ftz : NVPTXBuiltin<"int(float)">; +def __nvvm_f2i_rn : NVPTXBuiltin<"int(float)">; +def __nvvm_f2i_rz_ftz : NVPTXBuiltin<"int(float)">; +def __nvvm_f2i_rz : NVPTXBuiltin<"int(float)">; +def __nvvm_f2i_rm_ftz : NVPTXBuiltin<"int(float)">; +def __nvvm_f2i_rm : NVPTXBuiltin<"int(float)">; +def __nvvm_f2i_rp_ftz : NVPTXBuiltin<"int(float)">; +def __nvvm_f2i_rp : NVPTXBuiltin<"int(float)">; + +def __nvvm_f2ui_rn_ftz : NVPTXBuiltin<"unsigned int(float)">; +def __nvvm_f2ui_rn : NVPTXBuiltin<"unsigned int(float)">; +def __nvvm_f2ui_rz_ftz : NVPTXBuiltin<"unsigned int(float)">; +def __nvvm_f2ui_rz : NVPTXBuiltin<"unsigned int(float)">; +def __nvvm_f2ui_rm_ftz : NVPTXBuiltin<"unsigned int(float)">; +def __nvvm_f2ui_rm : NVPTXBuiltin<"unsigned int(float)">; +def __nvvm_f2ui_rp_ftz : NVPTXBuiltin<"unsigned int(float)">; +def __nvvm_f2ui_rp : NVPTXBuiltin<"unsigned int(float)">; + +def __nvvm_i2f_rn : NVPTXBuiltin<"float(int)">; +def __nvvm_i2f_rz : NVPTXBuiltin<"float(int)">; +def __nvvm_i2f_rm : NVPTXBuiltin<"float(int)">; +def __nvvm_i2f_rp : NVPTXBuiltin<"float(int)">; + +def __nvvm_ui2f_rn : NVPTXBuiltin<"float(unsigned int)">; +def __nvvm_ui2f_rz : NVPTXBuiltin<"float(unsigned int)">; +def __nvvm_ui2f_rm : NVPTXBuiltin<"float(unsigned int)">; +def __nvvm_ui2f_rp : NVPTXBuiltin<"float(unsigned int)">; + +def __nvvm_lohi_i2d : NVPTXBuiltin<"double(int, int)">; + +def __nvvm_d2i_lo : NVPTXBuiltin<"int(double)">; +def __nvvm_d2i_hi : NVPTXBuiltin<"int(double)">; + +def __nvvm_f2ll_rn_ftz : NVPTXBuiltin<"long long int(float)">; +def __nvvm_f2ll_rn : NVPTXBuiltin<"long long int(float)">; +def __nvvm_f2ll_rz_ftz : NVPTXBuiltin<"long long int(float)">; +def __nvvm_f2ll_rz : NVPTXBuiltin<"long long int(float)">; +def __nvvm_f2ll_rm_ftz : NVPTXBuiltin<"long long int(float)">; +def __nvvm_f2ll_rm : NVPTXBuiltin<"long long int(float)">; +def __nvvm_f2ll_rp_ftz : NVPTXBuiltin<"long long int(float)">; +def __nvvm_f2ll_rp : NVPTXBuiltin<"long long int(float)">; + +def __nvvm_f2ull_rn_ftz : NVPTXBuiltin<"unsigned long long int(float)">; +def __nvvm_f2ull_rn : NVPTXBuiltin<"unsigned long long int(float)">; +def __nvvm_f2ull_rz_ftz : NVPTXBuiltin<"unsigned long long int(float)">; +def __nvvm_f2ull_rz : NVPTXBuiltin<"unsigned long long int(float)">; +def __nvvm_f2ull_rm_ftz : NVPTXBuiltin<"unsigned long long int(float)">; +def __nvvm_f2ull_rm : NVPTXBuiltin<"unsigned long long int(float)">; +def __nvvm_f2ull_rp_ftz : NVPTXBuiltin<"unsigned long long int(float)">; +def __nvvm_f2ull_rp : NVPTXBuiltin<"unsigned long long int(float)">; + +def __nvvm_d2ll_rn : NVPTXBuiltin<"long long int(double)">; +def __nvvm_d2ll_rz : NVPTXBuiltin<"long long int(double)">; +def __nvvm_d2ll_rm : NVPTXBuiltin<"long long int(double)">; +def __nvvm_d2ll_rp : NVPTXBuiltin<"long long int(double)">; + +def __nvvm_d2ull_rn : NVPTXBuiltin<"unsigned long long int(double)">; +def __nvvm_d2ull_rz : NVPTXBuiltin<"unsigned long long int(double)">; +def __nvvm_d2ull_rm : NVPTXBuiltin<"unsigned long long int(double)">; +def __nvvm_d2ull_rp : NVPTXBuiltin<"unsigned long long int(double)">; + +def __nvvm_ll2f_rn : NVPTXBuiltin<"float(long long int)">; +def __nvvm_ll2f_rz : NVPTXBuiltin<"float(long long int)">; +def __nvvm_ll2f_rm : NVPTXBuiltin<"float(long long int)">; +def __nvvm_ll2f_rp : NVPTXBuiltin<"float(long long int)">; + +def __nvvm_ull2f_rn : NVPTXBuiltin<"float(unsigned long long int)">; +def __nvvm_ull2f_rz : NVPTXBuiltin<"float(unsigned long long int)">; +def __nvvm_ull2f_rm : NVPTXBuiltin<"float(unsigned long long int)">; +def __nvvm_ull2f_rp : NVPTXBuiltin<"float(unsigned long long int)">; + +def __nvvm_ll2d_rn : NVPTXBuiltin<"double(long long int)">; +def __nvvm_ll2d_rz : NVPTXBuiltin<"double(long long int)">; +def __nvvm_ll2d_rm : NVPTXBuiltin<"double(long long int)">; +def __nvvm_ll2d_rp : NVPTXBuiltin<"double(long long int)">; + +def __nvvm_ull2d_rn : NVPTXBuiltin<"double(unsigned long long int)">; +def __nvvm_ull2d_rz : NVPTXBuiltin<"double(unsigned long long int)">; +def __nvvm_ull2d_rm : NVPTXBuiltin<"double(unsigned long long int)">; +def __nvvm_ull2d_rp : NVPTXBuiltin<"double(unsigned long long int)">; + +def __nvvm_f2h_rn_ftz : NVPTXBuiltin<"unsigned short(float)">; +def __nvvm_f2h_rn : NVPTXBuiltin<"unsigned short(float)">; + +def __nvvm_ff2bf16x2_rn : NVPTXBuiltinSMAndPTX<"_Vector<2, __bf16>(float, float)", SM_80, PTX70>; +def __nvvm_ff2bf16x2_rn_relu : NVPTXBuiltinSMAndPTX<"_Vector<2, __bf16>(float, float)", SM_80, PTX70>; +def __nvvm_ff2bf16x2_rz : NVPTXBuiltinSMAndPTX<"_Vector<2, __bf16>(float, float)", SM_80, PTX70>; +def __nvvm_ff2bf16x2_rz_relu : NVPTXBuiltinSMAndPTX<"_Vector<2, __bf16>(float, float)", SM_80, PTX70>; + +def __nvvm_ff2f16x2_rn : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(float, float)", SM_80, PTX70>; +def __nvvm_ff2f16x2_rn_relu : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(float, float)", SM_80, PTX70>; +def __nvvm_ff2f16x2_rz : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(float, float)", SM_80, PTX70>; +def __nvvm_ff2f16x2_rz_relu : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(float, float)", SM_80, PTX70>; + +def __nvvm_f2bf16_rn : NVPTXBuiltinSMAndPTX<"__bf16(float)", SM_80, PTX70>; +def __nvvm_f2bf16_rn_relu : NVPTXBuiltinSMAndPTX<"__bf16(float)", SM_80, PTX70>; +def __nvvm_f2bf16_rz : NVPTXBuiltinSMAndPTX<"__bf16(float)", SM_80, PTX70>; +def __nvvm_f2bf16_rz_relu : NVPTXBuiltinSMAndPTX<"__bf16(float)", SM_80, PTX70>; + +def __nvvm_f2tf32_rna : NVPTXBuiltinSMAndPTX<"int32_t(float)", SM_80, PTX70>; + +def __nvvm_ff_to_e4m3x2_rn : NVPTXBuiltinSMAndPTX<"short(float, float)", SM_89, PTX81>; +def __nvvm_ff_to_e4m3x2_rn_relu : NVPTXBuiltinSMAndPTX<"short(float, float)", SM_89, PTX81>; +def __nvvm_ff_to_e5m2x2_rn : NVPTXBuiltinSMAndPTX<"short(float, float)", SM_89, PTX81>; +def __nvvm_ff_to_e5m2x2_rn_relu : NVPTXBuiltinSMAndPTX<"short(float, float)", SM_89, PTX81>; + +def __nvvm_f16x2_to_e4m3x2_rn : NVPTXBuiltinSMAndPTX<"short(_Vector<2, __fp16>)", SM_89, PTX81>; +def __nvvm_f16x2_to_e4m3x2_rn_relu : NVPTXBuiltinSMAndPTX<"short(_Vector<2, __fp16>)", SM_89, PTX81>; +def __nvvm_f16x2_to_e5m2x2_rn : NVPTXBuiltinSMAndPTX<"short(_Vector<2, __fp16>)", SM_89, PTX81>; +def __nvvm_f16x2_to_e5m2x2_rn_relu : NVPTXBuiltinSMAndPTX<"short(_Vector<2, __fp16>)", SM_89, PTX81>; + +def __nvvm_e4m3x2_to_f16x2_rn : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(short)", SM_89, PTX81>; +def __nvvm_e4m3x2_to_f16x2_rn_relu : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(short)", SM_89, PTX81>; +def __nvvm_e5m2x2_to_f16x2_rn : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(short)", SM_89, PTX81>; +def __nvvm_e5m2x2_to_f16x2_rn_relu : NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(short)", SM_89, PTX81>; + +// FNS +let Attributes = [NoThrow] in { + def __nvvm_fns : NVPTXBuiltinPTX<"unsigned int(unsigned int, unsigned int, int)", PTX60>; +} + +// Sync + +def __syncthreads : NVPTXBuiltin<"void()">; +def __nvvm_bar0_popc : NVPTXBuiltin<"int(int)">; +def __nvvm_bar0_and : NVPTXBuiltin<"int(int)">; +def __nvvm_bar0_or : NVPTXBuiltin<"int(int)">; +let Attributes = [NoThrow] in { + def __nvvm_bar_sync : NVPTXBuiltin<"void(int)">; + def __nvvm_bar_warp_sync : NVPTXBuiltinPTX<"void(unsigned int)", PTX60>; + def __nvvm_barrier_sync : NVPTXBuiltinPTX<"void(unsigned int)", PTX60>; + def __nvvm_barrier_sync_cnt : NVPTXBuiltinPTX<"void(unsigned int, unsigned int)", PTX60>; + + def __nvvm_barrier_cluster_arrive : NVPTXBuiltinSMAndPTX<"void()", SM_90, PTX78>; + def __nvvm_barrier_cluster_arrive_relaxed : NVPTXBuiltinSMAndPTX<"void()", SM_90, PTX80>; + def __nvvm_barrier_cluster_wait : NVPTXBuiltinSMAndPTX<"void()", SM_90, PTX78>; + def __nvvm_fence_sc_cluster : NVPTXBuiltinSMAndPTX<"void()", SM_90, PTX78>; +} + +// Shuffle + +def __nvvm_shfl_down_i32 : NVPTXBuiltin<"int(int, int, int)">; +def __nvvm_shfl_down_f32 : NVPTXBuiltin<"float(float, int, int)">; +def __nvvm_shfl_up_i32 : NVPTXBuiltin<"int(int, int, int)">; +def __nvvm_shfl_up_f32 : NVPTXBuiltin<"float(float, int, int)">; +def __nvvm_shfl_bfly_i32 : NVPTXBuiltin<"int(int, int, int)">; +def __nvvm_shfl_bfly_f32 : NVPTXBuiltin<"float(float, int, int)">; +def __nvvm_shfl_idx_i32 : NVPTXBuiltin<"int(int, int, int)">; +def __nvvm_shfl_idx_f32 : NVPTXBuiltin<"float(float, int, int)">; + +def __nvvm_shfl_sync_down_i32 : NVPTXBuiltinPTX<"int(unsigned int, int, int, int)", PTX60>; +def __nvvm_shfl_sync_down_f32 : NVPTXBuiltinPTX<"float(unsigned int, float, int, int)", PTX60>; +def __nvvm_shfl_sync_up_i32 : NVPTXBuiltinPTX<"int(unsigned int, int, int, int)", PTX60>; +def __nvvm_shfl_sync_up_f32 : NVPTXBuiltinPTX<"float(unsigned int, float, int, int)", PTX60>; +def __nvvm_shfl_sync_bfly_i32 : NVPTXBuiltinPTX<"int(unsigned int, int, int, int)", PTX60>; +def __nvvm_shfl_sync_bfly_f32 : NVPTXBuiltinPTX<"float(unsigned int, float, int, int)", PTX60>; +def __nvvm_shfl_sync_idx_i32 : NVPTXBuiltinPTX<"int(unsigned int, int, int, int)", PTX60>; +def __nvvm_shfl_sync_idx_f32 : NVPTXBuiltinPTX<"float(unsigned int, float, int, int)", PTX60>; + +// Vote +def __nvvm_vote_all : NVPTXBuiltin<"bool(bool)">; +def __nvvm_vote_any : NVPTXBuiltin<"bool(bool)">; +def __nvvm_vote_uni : NVPTXBuiltin<"bool(bool)">; +def __nvvm_vote_ballot : NVPTXBuiltin<"unsigned int(bool)">; + +def __nvvm_vote_all_sync : NVPTXBuiltinPTX<"bool(unsigned int, bool)", PTX60>; +def __nvvm_vote_any_sync : NVPTXBuiltinPTX<"bool(unsigned int, bool)", PTX60>; +def __nvvm_vote_uni_sync : NVPTXBuiltinPTX<"bool(unsigned int, bool)", PTX60>; +def __nvvm_vote_ballot_sync : NVPTXBuiltinPTX<"unsigned int(unsigned int, bool)", PTX60>; + +// Mask +let Attributes = [NoThrow] in { + def __nvvm_activemask : NVPTXBuiltinPTX<"unsigned int()", PTX62>; +} + +// Match +def __nvvm_match_any_sync_i32 : NVPTXBuiltinSMAndPTX<"unsigned int(unsigned int, unsigned int)", SM_70, PTX60>; +def __nvvm_match_any_sync_i64 : NVPTXBuiltinSMAndPTX<"unsigned int(unsigned int, int64_t)", SM_70, PTX60>; +// These return a pair {value, predicate}, which requires custom lowering. +def __nvvm_match_all_sync_i32p : NVPTXBuiltinSMAndPTX<"unsigned int(unsigned int, unsigned int, int *)", SM_70, PTX60>; +def __nvvm_match_all_sync_i64p : NVPTXBuiltinSMAndPTX<"unsigned int(unsigned int, int64_t, int *)", SM_70, PTX60>; + +// Redux +def __nvvm_redux_sync_add : NVPTXBuiltinSMAndPTX<"int(int, int)", SM_80, PTX70>; +def __nvvm_redux_sync_min : NVPTXBuiltinSMAndPTX<"int(int, int)", SM_80, PTX70>; +def __nvvm_redux_sync_max : NVPTXBuiltinSMAndPTX<"int(int, int)", SM_80, PTX70>; +def __nvvm_redux_sync_umin : NVPTXBuiltinSMAndPTX<"unsigned int(unsigned int, int)", SM_80, PTX70>; +def __nvvm_redux_sync_umax : NVPTXBuiltinSMAndPTX<"unsigned int(unsigned int, int)", SM_80, PTX70>; +def __nvvm_redux_sync_and : NVPTXBuiltinSMAndPTX<"int(int, int)", SM_80, PTX70>; +def __nvvm_redux_sync_xor : NVPTXBuiltinSMAndPTX<"int(int, int)", SM_80, PTX70>; +def __nvvm_redux_sync_or : NVPTXBuiltinSMAndPTX<"int(int, int)", SM_80, PTX70>; + +// Membar + +def __nvvm_membar_cta : NVPTXBuiltin<"void()">; +def __nvvm_membar_gl : NVPTXBuiltin<"void()">; +def __nvvm_membar_sys : NVPTXBuiltin<"void()">; + +// mbarrier + +def __nvvm_mbarrier_init : NVPTXBuiltinSMAndPTX<"void(int64_t *, int)", SM_80, PTX70>; +def __nvvm_mbarrier_init_shared : NVPTXBuiltinSMAndPTX<"void(int64_t address_space<3> *, int)", SM_80, PTX70>; + +def __nvvm_mbarrier_inval : NVPTXBuiltinSMAndPTX<"void(int64_t *)", SM_80, PTX70>; +def __nvvm_mbarrier_inval_shared : NVPTXBuiltinSMAndPTX<"void(int64_t address_space<3> *)", SM_80, PTX70>; + +def __nvvm_mbarrier_arrive : NVPTXBuiltinSMAndPTX<"int64_t(int64_t *)", SM_80, PTX70>; +def __nvvm_mbarrier_arrive_shared : NVPTXBuiltinSMAndPTX<"int64_t(int64_t address_space<3> *)", SM_80, PTX70>; +def __nvvm_mbarrier_arrive_noComplete : NVPTXBuiltinSMAndPTX<"int64_t(int64_t *, int)", SM_80, PTX70>; +def __nvvm_mbarrier_arrive_noComplete_shared : NVPTXBuiltinSMAndPTX<"int64_t(int64_t address_space<3> *, int)", SM_80, PTX70>; + +def __nvvm_mbarrier_arrive_drop : NVPTXBuiltinSMAndPTX<"int64_t(int64_t *)", SM_80, PTX70>; +def __nvvm_mbarrier_arrive_drop_shared : NVPTXBuiltinSMAndPTX<"int64_t(int64_t address_space<3> *)", SM_80, PTX70>; +def __nvvm_mbarrier_arrive_drop_noComplete : NVPTXBuiltinSMAndPTX<"int64_t(int64_t *, int)", SM_80, PTX70>; +def __nvvm_mbarrier_arrive_drop_noComplete_shared : NVPTXBuiltinSMAndPTX<"int64_t(int64_t address_space<3> *, int)", SM_80, PTX70>; + +def __nvvm_mbarrier_test_wait : NVPTXBuiltinSMAndPTX<"bool(int64_t *, int64_t)", SM_80, PTX70>; +def __nvvm_mbarrier_test_wait_shared : NVPTXBuiltinSMAndPTX<"bool(int64_t address_space<3> *, int64_t)", SM_80, PTX70>; + +def __nvvm_mbarrier_pending_count : NVPTXBuiltinSMAndPTX<"int(int64_t)", SM_80, PTX70>; + +// Memcpy, Memset + +def __nvvm_memcpy : NVPTXBuiltin<"void(unsigned char *, unsigned char *, size_t, int)">; +def __nvvm_memset : NVPTXBuiltin<"void(unsigned char *, unsigned char, size_t, int)">; + +// Image + +def __builtin_ptx_read_image2Dfi_ : NVPTXBuiltin<"_Vector<4, float>(int, int, int, int)">; +def __builtin_ptx_read_image2Dff_ : NVPTXBuiltin<"_Vector<4, float>(int, int, float, float)">; +def __builtin_ptx_read_image2Dii_ : NVPTXBuiltin<"_Vector<4, int>(int, int, int, int)">; +def __builtin_ptx_read_image2Dif_ : NVPTXBuiltin<"_Vector<4, int>(int, int, float, float)">; + +def __builtin_ptx_read_image3Dfi_ : NVPTXBuiltin<"_Vector<4, float>(int, int, int, int, int, int)">; +def __builtin_ptx_read_image3Dff_ : NVPTXBuiltin<"_Vector<4, float>(int, int, float, float, float, float)">; +def __builtin_ptx_read_image3Dii_ : NVPTXBuiltin<"_Vector<4, int>(int, int, int, int, int, int)">; +def __builtin_ptx_read_image3Dif_ : NVPTXBuiltin<"_Vector<4, int>(int, int, float, float, float, float)">; + +def __builtin_ptx_write_image2Df_ : NVPTXBuiltin<"void(int, int, int, float, float, float, float)">; +def __builtin_ptx_write_image2Di_ : NVPTXBuiltin<"void(int, int, int, int, int, int, int)">; +def __builtin_ptx_write_image2Dui_ : NVPTXBuiltin<"void(int, int, int, unsigned int, unsigned int, unsigned int, unsigned int)">; +def __builtin_ptx_get_image_depthi_ : NVPTXBuiltin<"int(int)">; +def __builtin_ptx_get_image_heighti_ : NVPTXBuiltin<"int(int)">; +def __builtin_ptx_get_image_widthi_ : NVPTXBuiltin<"int(int)">; +def __builtin_ptx_get_image_channel_data_typei_ : NVPTXBuiltin<"int(int)">; +def __builtin_ptx_get_image_channel_orderi_ : NVPTXBuiltin<"int(int)">; + +// Atomic +// +// We need the atom intrinsics because +// - they are used in converging analysis +// - they are used in address space analysis and optimization +// So it does not hurt to expose them as builtins. +// +let Attributes = [NoThrow] in { + def __nvvm_atom_add_gen_i : NVPTXBuiltin<"int(int volatile *, int)">; + def __nvvm_atom_cta_add_gen_i : NVPTXBuiltinSM<"int(int volatile *, int)", SM_60>; + def __nvvm_atom_sys_add_gen_i : NVPTXBuiltinSM<"int(int volatile *, int)", SM_60>; + def __nvvm_atom_add_gen_l : NVPTXBuiltin<"long int(long int volatile *, long int)">; + def __nvvm_atom_cta_add_gen_l : NVPTXBuiltinSM<"long int(long int volatile *, long int)", SM_60>; + def __nvvm_atom_sys_add_gen_l : NVPTXBuiltinSM<"long int(long int volatile *, long int)", SM_60>; + def __nvvm_atom_add_gen_ll : NVPTXBuiltin<"long long int(long long int volatile *, long long int)">; + def __nvvm_atom_cta_add_gen_ll : NVPTXBuiltinSM<"long long int(long long int volatile *, long long int)", SM_60>; + def __nvvm_atom_sys_add_gen_ll : NVPTXBuiltinSM<"long long int(long long int volatile *, long long int)", SM_60>; + def __nvvm_atom_add_gen_f : NVPTXBuiltin<"float(float volatile *, float)">; + def __nvvm_atom_cta_add_gen_f : NVPTXBuiltinSM<"float(float volatile *, float)", SM_60>; + def __nvvm_atom_sys_add_gen_f : NVPTXBuiltinSM<"float(float volatile *, float)", SM_60>; + def __nvvm_atom_add_gen_d : NVPTXBuiltinSM<"double(double volatile *, double)", SM_60>; + def __nvvm_atom_cta_add_gen_d : NVPTXBuiltinSM<"double(double volatile *, double)", SM_60>; + def __nvvm_atom_sys_add_gen_d : NVPTXBuiltinSM<"double(double volatile *, double)", SM_60>; + + def __nvvm_atom_sub_gen_i : NVPTXBuiltin<"int(int volatile *, int)">; + def __nvvm_atom_sub_gen_l : NVPTXBuiltin<"long int(long int volatile *, long int)">; + def __nvvm_atom_sub_gen_ll : NVPTXBuiltin<"long long int(long long int volatile *, long long int)">; + + def __nvvm_atom_xchg_gen_i : NVPTXBuiltin<"int(int volatile *, int)">; + def __nvvm_atom_cta_xchg_gen_i : NVPTXBuiltinSM<"int(int volatile *, int)", SM_60>; + def __nvvm_atom_sys_xchg_gen_i : NVPTXBuiltinSM<"int(int volatile *, int)", SM_60>; + def __nvvm_atom_xchg_gen_l : NVPTXBuiltin<"long int(long int volatile *, long int)">; + def __nvvm_atom_cta_xchg_gen_l : NVPTXBuiltinSM<"long int(long int volatile *, long int)", SM_60>; + def __nvvm_atom_sys_xchg_gen_l : NVPTXBuiltinSM<"long int(long int volatile *, long int)", SM_60>; + def __nvvm_atom_xchg_gen_ll : NVPTXBuiltin<"long long int(long long int volatile *, long long int)">; + def __nvvm_atom_cta_xchg_gen_ll : NVPTXBuiltinSM<"long long int(long long int volatile *, long long int)", SM_60>; + def __nvvm_atom_sys_xchg_gen_ll : NVPTXBuiltinSM<"long long int(long long int volatile *, long long int)", SM_60>; + + def __nvvm_atom_max_gen_i : NVPTXBuiltin<"int(int volatile *, int)">; + def __nvvm_atom_cta_max_gen_i : NVPTXBuiltinSM<"int(int volatile *, int)", SM_60>; + def __nvvm_atom_sys_max_gen_i : NVPTXBuiltinSM<"int(int volatile *, int)", SM_60>; + def __nvvm_atom_max_gen_ui : NVPTXBuiltin<"unsigned int(unsigned int volatile *, unsigned int)">; + def __nvvm_atom_cta_max_gen_ui : NVPTXBuiltinSM<"unsigned int(unsigned int volatile *, unsigned int)", SM_60>; + def __nvvm_atom_sys_max_gen_ui : NVPTXBuiltinSM<"unsigned int(unsigned int volatile *, unsigned int)", SM_60>; + def __nvvm_atom_max_gen_l : NVPTXBuiltin<"long int(long int volatile *, long int)">; + def __nvvm_atom_cta_max_gen_l : NVPTXBuiltinSM<"long int(long int volatile *, long int)", SM_60>; + def __nvvm_atom_sys_max_gen_l : NVPTXBuiltinSM<"long int(long int volatile *, long int)", SM_60>; + def __nvvm_atom_max_gen_ul : NVPTXBuiltin<"unsigned long int(unsigned long int volatile *, unsigned long int)">; + def __nvvm_atom_cta_max_gen_ul : NVPTXBuiltinSM<"unsigned long int(unsigned long int volatile *, unsigned long int)", SM_60>; + def __nvvm_atom_sys_max_gen_ul : NVPTXBuiltinSM<"unsigned long int(unsigned long int volatile *, unsigned long int)", SM_60>; + def __nvvm_atom_max_gen_ll : NVPTXBuiltin<"long long int(long long int volatile *, long long int)">; + def __nvvm_atom_cta_max_gen_ll : NVPTXBuiltinSM<"long long int(long long int volatile *, long long int)", SM_60>; + def __nvvm_atom_sys_max_gen_ll : NVPTXBuiltinSM<"long long int(long long int volatile *, long long int)", SM_60>; + def __nvvm_atom_max_gen_ull : NVPTXBuiltin<"unsigned long long int(unsigned long long int volatile *, unsigned long long int)">; + def __nvvm_atom_cta_max_gen_ull : NVPTXBuiltinSM<"unsigned long long int(unsigned long long int volatile *, unsigned long long int)", SM_60>; + def __nvvm_atom_sys_max_gen_ull : NVPTXBuiltinSM<"unsigned long long int(unsigned long long int volatile *, unsigned long long int)", SM_60>; + + def __nvvm_atom_min_gen_i : NVPTXBuiltin<"int(int volatile *, int)">; + def __nvvm_atom_cta_min_gen_i : NVPTXBuiltinSM<"int(int volatile *, int)", SM_60>; + def __nvvm_atom_sys_min_gen_i : NVPTXBuiltinSM<"int(int volatile *, int)", SM_60>; + def __nvvm_atom_min_gen_ui : NVPTXBuiltin<"unsigned int(unsigned int volatile *, unsigned int)">; + def __nvvm_atom_cta_min_gen_ui : NVPTXBuiltinSM<"unsigned int(unsigned int volatile *, unsigned int)", SM_60>; + def __nvvm_atom_sys_min_gen_ui : NVPTXBuiltinSM<"unsigned int(unsigned int volatile *, unsigned int)", SM_60>; + def __nvvm_atom_min_gen_l : NVPTXBuiltin<"long int(long int volatile *, long int)">; + def __nvvm_atom_cta_min_gen_l : NVPTXBuiltinSM<"long int(long int volatile *, long int)", SM_60>; + def __nvvm_atom_sys_min_gen_l : NVPTXBuiltinSM<"long int(long int volatile *, long int)", SM_60>; + def __nvvm_atom_min_gen_ul : NVPTXBuiltin<"unsigned long int(unsigned long int volatile *, unsigned long int)">; + def __nvvm_atom_cta_min_gen_ul : NVPTXBuiltinSM<"unsigned long int(unsigned long int volatile *, unsigned long int)", SM_60>; + def __nvvm_atom_sys_min_gen_ul : NVPTXBuiltinSM<"unsigned long int(unsigned long int volatile *, unsigned long int)", SM_60>; + def __nvvm_atom_min_gen_ll : NVPTXBuiltin<"long long int(long long int volatile *, long long int)">; + def __nvvm_atom_cta_min_gen_ll : NVPTXBuiltinSM<"long long int(long long int volatile *, long long int)", SM_60>; + def __nvvm_atom_sys_min_gen_ll : NVPTXBuiltinSM<"long long int(long long int volatile *, long long int)", SM_60>; + def __nvvm_atom_min_gen_ull : NVPTXBuiltin<"unsigned long long int(unsigned long long int volatile *, unsigned long long int)">; + def __nvvm_atom_cta_min_gen_ull : NVPTXBuiltinSM<"unsigned long long int(unsigned long long int volatile *, unsigned long long int)", SM_60>; + def __nvvm_atom_sys_min_gen_ull : NVPTXBuiltinSM<"unsigned long long int(unsigned long long int volatile *, unsigned long long int)", SM_60>; + + def __nvvm_atom_inc_gen_ui : NVPTXBuiltin<"unsigned int(unsigned int volatile *, unsigned int)">; + def __nvvm_atom_cta_inc_gen_ui : NVPTXBuiltinSM<"unsigned int(unsigned int volatile *, unsigned int)", SM_60>; + def __nvvm_atom_sys_inc_gen_ui : NVPTXBuiltinSM<"unsigned int(unsigned int volatile *, unsigned int)", SM_60>; + def __nvvm_atom_dec_gen_ui : NVPTXBuiltin<"unsigned int(unsigned int volatile *, unsigned int)">; + def __nvvm_atom_cta_dec_gen_ui : NVPTXBuiltinSM<"unsigned int(unsigned int volatile *, unsigned int)", SM_60>; + def __nvvm_atom_sys_dec_gen_ui : NVPTXBuiltinSM<"unsigned int(unsigned int volatile *, unsigned int)", SM_60>; + + def __nvvm_atom_and_gen_i : NVPTXBuiltin<"int(int volatile *, int)">; + def __nvvm_atom_cta_and_gen_i : NVPTXBuiltinSM<"int(int volatile *, int)", SM_60>; + def __nvvm_atom_sys_and_gen_i : NVPTXBuiltinSM<"int(int volatile *, int)", SM_60>; + def __nvvm_atom_and_gen_l : NVPTXBuiltin<"long int(long int volatile *, long int)">; + def __nvvm_atom_cta_and_gen_l : NVPTXBuiltinSM<"long int(long int volatile *, long int)", SM_60>; + def __nvvm_atom_sys_and_gen_l : NVPTXBuiltinSM<"long int(long int volatile *, long int)", SM_60>; + def __nvvm_atom_and_gen_ll : NVPTXBuiltin<"long long int(long long int volatile *, long long int)">; + def __nvvm_atom_cta_and_gen_ll : NVPTXBuiltinSM<"long long int(long long int volatile *, long long int)", SM_60>; + def __nvvm_atom_sys_and_gen_ll : NVPTXBuiltinSM<"long long int(long long int volatile *, long long int)", SM_60>; + + def __nvvm_atom_or_gen_i : NVPTXBuiltin<"int(int volatile *, int)">; + def __nvvm_atom_cta_or_gen_i : NVPTXBuiltinSM<"int(int volatile *, int)", SM_60>; + def __nvvm_atom_sys_or_gen_i : NVPTXBuiltinSM<"int(int volatile *, int)", SM_60>; + def __nvvm_atom_or_gen_l : NVPTXBuiltin<"long int(long int volatile *, long int)">; + def __nvvm_atom_cta_or_gen_l : NVPTXBuiltinSM<"long int(long int volatile *, long int)", SM_60>; + def __nvvm_atom_sys_or_gen_l : NVPTXBuiltinSM<"long int(long int volatile *, long int)", SM_60>; + def __nvvm_atom_or_gen_ll : NVPTXBuiltin<"long long int(long long int volatile *, long long int)">; + def __nvvm_atom_cta_or_gen_ll : NVPTXBuiltinSM<"long long int(long long int volatile *, long long int)", SM_60>; + def __nvvm_atom_sys_or_gen_ll : NVPTXBuiltinSM<"long long int(long long int volatile *, long long int)", SM_60>; + + def __nvvm_atom_xor_gen_i : NVPTXBuiltin<"int(int volatile *, int)">; + def __nvvm_atom_cta_xor_gen_i : NVPTXBuiltinSM<"int(int volatile *, int)", SM_60>; + def __nvvm_atom_sys_xor_gen_i : NVPTXBuiltinSM<"int(int volatile *, int)", SM_60>; + def __nvvm_atom_xor_gen_l : NVPTXBuiltin<"long int(long int volatile *, long int)">; + def __nvvm_atom_cta_xor_gen_l : NVPTXBuiltinSM<"long int(long int volatile *, long int)", SM_60>; + def __nvvm_atom_sys_xor_gen_l : NVPTXBuiltinSM<"long int(long int volatile *, long int)", SM_60>; + def __nvvm_atom_xor_gen_ll : NVPTXBuiltin<"long long int(long long int volatile *, long long int)">; + def __nvvm_atom_cta_xor_gen_ll : NVPTXBuiltinSM<"long long int(long long int volatile *, long long int)", SM_60>; + def __nvvm_atom_sys_xor_gen_ll : NVPTXBuiltinSM<"long long int(long long int volatile *, long long int)", SM_60>; + + def __nvvm_atom_cas_gen_us : NVPTXBuiltinSM<"unsigned short(unsigned short volatile *, unsigned short, unsigned short)", SM_70>; + def __nvvm_atom_cta_cas_gen_us : NVPTXBuiltinSM<"unsigned short(unsigned short volatile *, unsigned short, unsigned short)", SM_70>; + def __nvvm_atom_sys_cas_gen_us : NVPTXBuiltinSM<"unsigned short(unsigned short volatile *, unsigned short, unsigned short)", SM_70>; + def __nvvm_atom_cas_gen_i : NVPTXBuiltin<"int(int volatile *, int, int)">; + def __nvvm_atom_cta_cas_gen_i : NVPTXBuiltinSM<"int(int volatile *, int, int)", SM_60>; + def __nvvm_atom_sys_cas_gen_i : NVPTXBuiltinSM<"int(int volatile *, int, int)", SM_60>; + def __nvvm_atom_cas_gen_l : NVPTXBuiltin<"long int(long int volatile *, long int, long int)">; + def __nvvm_atom_cta_cas_gen_l : NVPTXBuiltinSM<"long int(long int volatile *, long int, long int)", SM_60>; + def __nvvm_atom_sys_cas_gen_l : NVPTXBuiltinSM<"long int(long int volatile *, long int, long int)", SM_60>; + def __nvvm_atom_cas_gen_ll : NVPTXBuiltin<"long long int(long long int volatile *, long long int, long long int)">; + def __nvvm_atom_cta_cas_gen_ll : NVPTXBuiltinSM<"long long int(long long int volatile *, long long int, long long int)", SM_60>; + def __nvvm_atom_sys_cas_gen_ll : NVPTXBuiltinSM<"long long int(long long int volatile *, long long int, long long int)", SM_60>; +} + +// Compiler Error Warn +let Attributes = [NoThrow] in { + def __nvvm_compiler_error : NVPTXBuiltin<"void(char const address_space<4> *)">; + def __nvvm_compiler_warn : NVPTXBuiltin<"void(char const address_space<4> *)">; +} + +def __nvvm_ldu_c : NVPTXBuiltin<"char(char const *)">; +def __nvvm_ldu_sc : NVPTXBuiltin<"signed char(signed char const *)">; +def __nvvm_ldu_s : NVPTXBuiltin<"short(short const *)">; +def __nvvm_ldu_i : NVPTXBuiltin<"int(int const *)">; +def __nvvm_ldu_l : NVPTXBuiltin<"long int(long int const *)">; +def __nvvm_ldu_ll : NVPTXBuiltin<"long long int(long long int const *)">; + +def __nvvm_ldu_uc : NVPTXBuiltin<"unsigned char(unsigned char const *)">; +def __nvvm_ldu_us : NVPTXBuiltin<"unsigned short(unsigned short const *)">; +def __nvvm_ldu_ui : NVPTXBuiltin<"unsigned int(unsigned int const *)">; +def __nvvm_ldu_ul : NVPTXBuiltin<"unsigned long int(unsigned long int const *)">; +def __nvvm_ldu_ull : NVPTXBuiltin<"unsigned long long int(unsigned long long int const *)">; + +def __nvvm_ldu_h : NVPTXBuiltin<"__fp16(__fp16 const *)">; +def __nvvm_ldu_f : NVPTXBuiltin<"float(float const *)">; +def __nvvm_ldu_d : NVPTXBuiltin<"double(double const *)">; + +def __nvvm_ldu_c2 : NVPTXBuiltin<"_ExtVector<2, char>(_ExtVector<2, char const *>)">; +def __nvvm_ldu_sc2 : NVPTXBuiltin<"_ExtVector<2, signed char>(_ExtVector<2, signed char const *>)">; +def __nvvm_ldu_c4 : NVPTXBuiltin<"_ExtVector<4, char>(_ExtVector<4, char const *>)">; +def __nvvm_ldu_sc4 : NVPTXBuiltin<"_ExtVector<4, signed char>(_ExtVector<4, signed char const *>)">; +def __nvvm_ldu_s2 : NVPTXBuiltin<"_ExtVector<2, short>(_ExtVector<2, short const *>)">; +def __nvvm_ldu_s4 : NVPTXBuiltin<"_ExtVector<4, short>(_ExtVector<4, short const *>)">; +def __nvvm_ldu_i2 : NVPTXBuiltin<"_ExtVector<2, int>(_ExtVector<2, int const *>)">; +def __nvvm_ldu_i4 : NVPTXBuiltin<"_ExtVector<4, int>(_ExtVector<4, int const *>)">; +def __nvvm_ldu_l2 : NVPTXBuiltin<"_ExtVector<2, long int>(_ExtVector<2, long int const *>)">; +def __nvvm_ldu_ll2 : NVPTXBuiltin<"_ExtVector<2, long long int>(_ExtVector<2, long long int const *>)">; + +def __nvvm_ldu_uc2 : NVPTXBuiltin<"_ExtVector<2, unsigned char>(_ExtVector<2, unsigned char const *>)">; +def __nvvm_ldu_uc4 : NVPTXBuiltin<"_ExtVector<4, unsigned char>(_ExtVector<4, unsigned char const *>)">; +def __nvvm_ldu_us2 : NVPTXBuiltin<"_ExtVector<2, unsigned short>(_ExtVector<2, unsigned short const *>)">; +def __nvvm_ldu_us4 : NVPTXBuiltin<"_ExtVector<4, unsigned short>(_ExtVector<4, unsigned short const *>)">; +def __nvvm_ldu_ui2 : NVPTXBuiltin<"_ExtVector<2, unsigned int>(_ExtVector<2, unsigned int const *>)">; +def __nvvm_ldu_ui4 : NVPTXBuiltin<"_ExtVector<4, unsigned int>(_ExtVector<4, unsigned int const *>)">; +def __nvvm_ldu_ul2 : NVPTXBuiltin<"_ExtVector<2, unsigned long int>(_ExtVector<2, unsigned long int const *>)">; +def __nvvm_ldu_ull2 : NVPTXBuiltin<"_ExtVector<2, unsigned long long int>(_ExtVector<2, unsigned long long int const *>)">; + +def __nvvm_ldu_h2 : NVPTXBuiltin<"_ExtVector<2, __fp16>(_ExtVector<2, __fp16 const *>)">; +def __nvvm_ldu_f2 : NVPTXBuiltin<"_ExtVector<2, float>(_ExtVector<2, float const *>)">; +def __nvvm_ldu_f4 : NVPTXBuiltin<"_ExtVector<4, float>(_ExtVector<4, float const *>)">; +def __nvvm_ldu_d2 : NVPTXBuiltin<"_ExtVector<2, double>(_ExtVector<2, double const *>)">; + +def __nvvm_ldg_c : NVPTXBuiltin<"char(char const *)">; +def __nvvm_ldg_sc : NVPTXBuiltin<"signed char(signed char const *)">; +def __nvvm_ldg_s : NVPTXBuiltin<"short(short const *)">; +def __nvvm_ldg_i : NVPTXBuiltin<"int(int const *)">; +def __nvvm_ldg_l : NVPTXBuiltin<"long int(long int const *)">; +def __nvvm_ldg_ll : NVPTXBuiltin<"long long int(long long int const *)">; + +def __nvvm_ldg_uc : NVPTXBuiltin<"unsigned char(unsigned char const *)">; +def __nvvm_ldg_us : NVPTXBuiltin<"unsigned short(unsigned short const *)">; +def __nvvm_ldg_ui : NVPTXBuiltin<"unsigned int(unsigned int const *)">; +def __nvvm_ldg_ul : NVPTXBuiltin<"unsigned long int(unsigned long int const *)">; +def __nvvm_ldg_ull : NVPTXBuiltin<"unsigned long long int(unsigned long long int const *)">; + +def __nvvm_ldg_h : NVPTXBuiltin<"__fp16(__fp16 const *)">; +def __nvvm_ldg_f : NVPTXBuiltin<"float(float const *)">; +def __nvvm_ldg_d : NVPTXBuiltin<"double(double const *)">; + +def __nvvm_ldg_c2 : NVPTXBuiltin<"_ExtVector<2, char>(_ExtVector<2, char const *>)">; +def __nvvm_ldg_sc2 : NVPTXBuiltin<"_ExtVector<2, signed char>(_ExtVector<2, signed char const *>)">; +def __nvvm_ldg_c4 : NVPTXBuiltin<"_ExtVector<4, char>(_ExtVector<4, char const *>)">; +def __nvvm_ldg_sc4 : NVPTXBuiltin<"_ExtVector<4, signed char>(_ExtVector<4, signed char const *>)">; +def __nvvm_ldg_s2 : NVPTXBuiltin<"_ExtVector<2, short>(_ExtVector<2, short const *>)">; +def __nvvm_ldg_s4 : NVPTXBuiltin<"_ExtVector<4, short>(_ExtVector<4, short const *>)">; +def __nvvm_ldg_i2 : NVPTXBuiltin<"_ExtVector<2, int>(_ExtVector<2, int const *>)">; +def __nvvm_ldg_i4 : NVPTXBuiltin<"_ExtVector<4, int>(_ExtVector<4, int const *>)">; +def __nvvm_ldg_l2 : NVPTXBuiltin<"_ExtVector<2, long int>(_ExtVector<2, long int const *>)">; +def __nvvm_ldg_ll2 : NVPTXBuiltin<"_ExtVector<2, long long int>(_ExtVector<2, long long int const *>)">; + +def __nvvm_ldg_uc2 : NVPTXBuiltin<"_ExtVector<2, unsigned char>(_ExtVector<2, unsigned char const *>)">; +def __nvvm_ldg_uc4 : NVPTXBuiltin<"_ExtVector<4, unsigned char>(_ExtVector<4, unsigned char const *>)">; +def __nvvm_ldg_us2 : NVPTXBuiltin<"_ExtVector<2, unsigned short>(_ExtVector<2, unsigned short const *>)">; +def __nvvm_ldg_us4 : NVPTXBuiltin<"_ExtVector<4, unsigned short>(_ExtVector<4, unsigned short const *>)">; +def __nvvm_ldg_ui2 : NVPTXBuiltin<"_ExtVector<2, unsigned int>(_ExtVector<2, unsigned int const *>)">; +def __nvvm_ldg_ui4 : NVPTXBuiltin<"_ExtVector<4, unsigned int>(_ExtVector<4, unsigned int const *>)">; +def __nvvm_ldg_ul2 : NVPTXBuiltin<"_ExtVector<2, unsigned long int>(_ExtVector<2, unsigned long int const *>)">; +def __nvvm_ldg_ull2 : NVPTXBuiltin<"_ExtVector<2, unsigned long long int>(_ExtVector<2, unsigned long long int const *>)">; + +def __nvvm_ldg_h2 : NVPTXBuiltin<"_ExtVector<2, __fp16>(_ExtVector<2, __fp16 const *>)">; +def __nvvm_ldg_f2 : NVPTXBuiltin<"_ExtVector<2, float>(_ExtVector<2, float const *>)">; +def __nvvm_ldg_f4 : NVPTXBuiltin<"_ExtVector<4, float>(_ExtVector<4, float const *>)">; +def __nvvm_ldg_d2 : NVPTXBuiltin<"_ExtVector<2, double>(_ExtVector<2, double const *>)">; + +// Address space predicates. +let Attributes = [NoThrow, Const] in { + def __nvvm_isspacep_const : NVPTXBuiltin<"bool(void const *)">; + def __nvvm_isspacep_global : NVPTXBuiltin<"bool(void const *)">; + def __nvvm_isspacep_local : NVPTXBuiltin<"bool(void const *)">; + def __nvvm_isspacep_shared : NVPTXBuiltin<"bool(void const *)">; + def __nvvm_isspacep_shared_cluster : NVPTXBuiltinSMAndPTX<"bool(void const *)", SM_90, PTX78>; +} + +// Builtins to support WMMA instructions on sm_70 +def __hmma_m16n16k16_ld_a : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_70, PTX60>; +def __hmma_m16n16k16_ld_b : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_70, PTX60>; +def __hmma_m16n16k16_ld_c_f16 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_70, PTX60>; +def __hmma_m16n16k16_ld_c_f32 : NVPTXBuiltinSMAndPTX<"void(float *, float const *, unsigned int, _Constant int)", SM_70, PTX60>; +def __hmma_m16n16k16_st_c_f16 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_70, PTX60>; +def __hmma_m16n16k16_st_c_f32 : NVPTXBuiltinSMAndPTX<"void(float *, float const *, unsigned int, _Constant int)", SM_70, PTX60>; + +def __hmma_m32n8k16_ld_a : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_70, PTX61>; +def __hmma_m32n8k16_ld_b : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_70, PTX61>; +def __hmma_m32n8k16_ld_c_f16 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_70, PTX61>; +def __hmma_m32n8k16_ld_c_f32 : NVPTXBuiltinSMAndPTX<"void(float *, float const *, unsigned int, _Constant int)", SM_70, PTX61>; +def __hmma_m32n8k16_st_c_f16 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_70, PTX61>; +def __hmma_m32n8k16_st_c_f32 : NVPTXBuiltinSMAndPTX<"void(float *, float const *, unsigned int, _Constant int)", SM_70, PTX61>; + +def __hmma_m8n32k16_ld_a : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_70, PTX61>; +def __hmma_m8n32k16_ld_b : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_70, PTX61>; +def __hmma_m8n32k16_ld_c_f16 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_70, PTX61>; +def __hmma_m8n32k16_ld_c_f32 : NVPTXBuiltinSMAndPTX<"void(float *, float const *, unsigned int, _Constant int)", SM_70, PTX61>; +def __hmma_m8n32k16_st_c_f16 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_70, PTX61>; +def __hmma_m8n32k16_st_c_f32 : NVPTXBuiltinSMAndPTX<"void(float *, float const *, unsigned int, _Constant int)", SM_70, PTX61>; + +def __hmma_m16n16k16_mma_f16f16 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, int const *, int const *, _Constant int, _Constant int)", SM_70, PTX60>; +def __hmma_m16n16k16_mma_f32f16 : NVPTXBuiltinSMAndPTX<"void(float *, int const *, int const *, int const *, _Constant int, _Constant int)", SM_70, PTX60>; +def __hmma_m16n16k16_mma_f32f32 : NVPTXBuiltinSMAndPTX<"void(float *, int const *, int const *, float const *, _Constant int, _Constant int)", SM_70, PTX60>; +def __hmma_m16n16k16_mma_f16f32 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, int const *, float const *, _Constant int, _Constant int)", SM_70, PTX60>; + +def __hmma_m32n8k16_mma_f16f16 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, int const *, int const *, _Constant int, _Constant int)", SM_70, PTX61>; +def __hmma_m32n8k16_mma_f32f16 : NVPTXBuiltinSMAndPTX<"void(float *, int const *, int const *, int const *, _Constant int, _Constant int)", SM_70, PTX61>; +def __hmma_m32n8k16_mma_f32f32 : NVPTXBuiltinSMAndPTX<"void(float *, int const *, int const *, float const *, _Constant int, _Constant int)", SM_70, PTX61>; +def __hmma_m32n8k16_mma_f16f32 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, int const *, float const *, _Constant int, _Constant int)", SM_70, PTX61>; + +def __hmma_m8n32k16_mma_f16f16 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, int const *, int const *, _Constant int, _Constant int)", SM_70, PTX61>; +def __hmma_m8n32k16_mma_f32f16 : NVPTXBuiltinSMAndPTX<"void(float *, int const *, int const *, int const *, _Constant int, _Constant int)", SM_70, PTX61>; +def __hmma_m8n32k16_mma_f32f32 : NVPTXBuiltinSMAndPTX<"void(float *, int const *, int const *, float const *, _Constant int, _Constant int)", SM_70, PTX61>; +def __hmma_m8n32k16_mma_f16f32 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, int const *, float const *, _Constant int, _Constant int)", SM_70, PTX61>; + +// Builtins to support integer and sub-integer WMMA instructions on sm_72/sm_75 +def __bmma_m8n8k128_ld_a_b1 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_75, PTX63>; +def __bmma_m8n8k128_ld_b_b1 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_75, PTX63>; +def __bmma_m8n8k128_ld_c : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_75, PTX63>; +def __bmma_m8n8k128_mma_and_popc_b1 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, int const *, int const *, _Constant int)", SM_80, PTX71>; +def __bmma_m8n8k128_mma_xor_popc_b1 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, int const *, int const *, _Constant int)", SM_75, PTX63>; +def __bmma_m8n8k128_st_c_i32 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_75, PTX63>; +def __imma_m16n16k16_ld_a_s8 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_72, PTX63>; +def __imma_m16n16k16_ld_a_u8 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_72, PTX63>; +def __imma_m16n16k16_ld_b_s8 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_72, PTX63>; +def __imma_m16n16k16_ld_b_u8 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_72, PTX63>; +def __imma_m16n16k16_ld_c : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_72, PTX63>; +def __imma_m16n16k16_mma_s8 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, int const *, int const *, _Constant int, _Constant int)", SM_72, PTX63>; +def __imma_m16n16k16_mma_u8 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, int const *, int const *, _Constant int, _Constant int)", SM_72, PTX63>; +def __imma_m16n16k16_st_c_i32 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_72, PTX63>; +def __imma_m32n8k16_ld_a_s8 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_72, PTX63>; +def __imma_m32n8k16_ld_a_u8 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_72, PTX63>; +def __imma_m32n8k16_ld_b_s8 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_72, PTX63>; +def __imma_m32n8k16_ld_b_u8 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_72, PTX63>; +def __imma_m32n8k16_ld_c : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_72, PTX63>; +def __imma_m32n8k16_mma_s8 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, int const *, int const *, _Constant int, _Constant int)", SM_72, PTX63>; +def __imma_m32n8k16_mma_u8 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, int const *, int const *, _Constant int, _Constant int)", SM_72, PTX63>; +def __imma_m32n8k16_st_c_i32 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_72, PTX63>; +def __imma_m8n32k16_ld_a_s8 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_72, PTX63>; +def __imma_m8n32k16_ld_a_u8 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_72, PTX63>; +def __imma_m8n32k16_ld_b_s8 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_72, PTX63>; +def __imma_m8n32k16_ld_b_u8 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_72, PTX63>; +def __imma_m8n32k16_ld_c : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_72, PTX63>; +def __imma_m8n32k16_mma_s8 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, int const *, int const *, _Constant int, _Constant int)", SM_72, PTX63>; +def __imma_m8n32k16_mma_u8 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, int const *, int const *, _Constant int, _Constant int)", SM_72, PTX63>; +def __imma_m8n32k16_st_c_i32 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_72, PTX63>; +def __imma_m8n8k32_ld_a_s4 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_75, PTX63>; +def __imma_m8n8k32_ld_a_u4 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_75, PTX63>; +def __imma_m8n8k32_ld_b_s4 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_75, PTX63>; +def __imma_m8n8k32_ld_b_u4 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_75, PTX63>; +def __imma_m8n8k32_ld_c : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_75, PTX63>; +def __imma_m8n8k32_mma_s4 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, int const *, int const *, _Constant int, _Constant int)", SM_75, PTX63>; +def __imma_m8n8k32_mma_u4 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, int const *, int const *, _Constant int, _Constant int)", SM_75, PTX63>; +def __imma_m8n8k32_st_c_i32 : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_75, PTX63>; + +// Builtins to support double and alternate float WMMA instructions on sm_80 +def __dmma_m8n8k4_ld_a : NVPTXBuiltinSMAndPTX<"void(double *, double const *, unsigned int, _Constant int)", SM_80, PTX70>; +def __dmma_m8n8k4_ld_b : NVPTXBuiltinSMAndPTX<"void(double *, double const *, unsigned int, _Constant int)", SM_80, PTX70>; +def __dmma_m8n8k4_ld_c : NVPTXBuiltinSMAndPTX<"void(double *, double const *, unsigned int, _Constant int)", SM_80, PTX70>; +def __dmma_m8n8k4_st_c_f64 : NVPTXBuiltinSMAndPTX<"void(double *, double const *, unsigned int, _Constant int)", SM_80, PTX70>; +def __dmma_m8n8k4_mma_f64 : NVPTXBuiltinSMAndPTX<"void(double *, double const *, double const *, double const *, _Constant int, _Constant int)", SM_80, PTX70>; + +def __mma_bf16_m16n16k16_ld_a : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_80, PTX70>; +def __mma_bf16_m16n16k16_ld_b : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_80, PTX70>; +def __mma_bf16_m16n16k16_mma_f32 : NVPTXBuiltinSMAndPTX<"void(float *, int const *, int const *, float const *, _Constant int, _Constant int)", SM_80, PTX70>; +def __mma_bf16_m8n32k16_ld_a : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_80, PTX70>; +def __mma_bf16_m8n32k16_ld_b : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_80, PTX70>; +def __mma_bf16_m8n32k16_mma_f32 : NVPTXBuiltinSMAndPTX<"void(float *, int const *, int const *, float const *, _Constant int, _Constant int)", SM_80, PTX70>; +def __mma_bf16_m32n8k16_ld_a : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_80, PTX70>; +def __mma_bf16_m32n8k16_ld_b : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_80, PTX70>; +def __mma_bf16_m32n8k16_mma_f32 : NVPTXBuiltinSMAndPTX<"void(float *, int const *, int const *, float const *, _Constant int, _Constant int)", SM_80, PTX70>; + +def __mma_tf32_m16n16k8_ld_a : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_80, PTX70>; +def __mma_tf32_m16n16k8_ld_b : NVPTXBuiltinSMAndPTX<"void(int *, int const *, unsigned int, _Constant int)", SM_80, PTX70>; +def __mma_tf32_m16n16k8_ld_c : NVPTXBuiltinSMAndPTX<"void(float *, float const *, unsigned int, _Constant int)", SM_80, PTX70>; +def __mma_m16n16k8_st_c_f32 : NVPTXBuiltinSMAndPTX<"void(float *, float const *, unsigned int, _Constant int)", SM_80, PTX70>; +def __mma_tf32_m16n16k8_mma_f32 : NVPTXBuiltinSMAndPTX<"void(float *, int const *, int const *, float const *, _Constant int, _Constant int)", SM_80, PTX70>; + +// Async Copy +def __nvvm_cp_async_mbarrier_arrive : NVPTXBuiltinSMAndPTX<"void(int64_t *)", SM_80, PTX70>; +def __nvvm_cp_async_mbarrier_arrive_shared : NVPTXBuiltinSMAndPTX<"void(int64_t address_space<3> *)", SM_80, PTX70>; +def __nvvm_cp_async_mbarrier_arrive_noinc : NVPTXBuiltinSMAndPTX<"void(int64_t *)", SM_80, PTX70>; +def __nvvm_cp_async_mbarrier_arrive_noinc_shared : NVPTXBuiltinSMAndPTX<"void(int64_t address_space<3> *)", SM_80, PTX70>; + +def __nvvm_cp_async_ca_shared_global_4 : NVPTXBuiltinSMAndPTX<"void(void address_space<3> *, void const address_space<1> *, ...)", SM_80, PTX70>; +def __nvvm_cp_async_ca_shared_global_8 : NVPTXBuiltinSMAndPTX<"void(void address_space<3> *, void const address_space<1> *, ...)", SM_80, PTX70>; +def __nvvm_cp_async_ca_shared_global_16 : NVPTXBuiltinSMAndPTX<"void(void address_space<3> *, void const address_space<1> *, ...)", SM_80, PTX70>; +def __nvvm_cp_async_cg_shared_global_16 : NVPTXBuiltinSMAndPTX<"void(void address_space<3> *, void const address_space<1> *, ...)", SM_80, PTX70>; + +def __nvvm_cp_async_commit_group : NVPTXBuiltinSMAndPTX<"void()", SM_80, PTX70>; +def __nvvm_cp_async_wait_group : NVPTXBuiltinSMAndPTX<"void(_Constant int)", SM_80, PTX70>; +def __nvvm_cp_async_wait_all : NVPTXBuiltinSMAndPTX<"void()", SM_80, PTX70>; + + +// bf16, bf16x2 abs, neg +def __nvvm_abs_bf16 : NVPTXBuiltinSMAndPTX<"__bf16(__bf16)", SM_80, PTX70>; +def __nvvm_abs_bf16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __bf16>(_Vector<2, __bf16>)", SM_80, PTX70>; +def __nvvm_neg_bf16 : NVPTXBuiltinSMAndPTX<"__bf16(__bf16)", SM_80, PTX70>; +def __nvvm_neg_bf16x2 : NVPTXBuiltinSMAndPTX<"_Vector<2, __bf16>(_Vector<2, __bf16>)", SM_80, PTX70>; + +def __nvvm_mapa : NVPTXBuiltinSMAndPTX<"void *(void *, int)", SM_90, PTX78>; +def __nvvm_mapa_shared_cluster : NVPTXBuiltinSMAndPTX<"void address_space<3> *(void address_space<3> *, int)", SM_90, PTX78>; +def __nvvm_getctarank : NVPTXBuiltinSMAndPTX<"int(void *)", SM_90, PTX78>; +def __nvvm_getctarank_shared_cluster : NVPTXBuiltinSMAndPTX<"int(void address_space<3> *)", SM_90, PTX78>; diff --git clang/include/clang/Basic/CMakeLists.txt clang/include/clang/Basic/CMakeLists.txt index 4103d2753abc..93dbc9c8ca62 100644 --- clang/include/clang/Basic/CMakeLists.txt +++ clang/include/clang/Basic/CMakeLists.txt @@ -72,6 +72,14 @@ clang_tablegen(BuiltinsBPF.inc -gen-clang-builtins SOURCE BuiltinsBPF.td TARGET ClangBuiltinsBPF) +clang_tablegen(BuiltinsHexagon.inc -gen-clang-builtins + SOURCE BuiltinsHexagon.td + TARGET ClangBuiltinsHexagon) + +clang_tablegen(BuiltinsNVPTX.inc -gen-clang-builtins + SOURCE BuiltinsNVPTX.td + TARGET ClangBuiltinsNVPTX) + clang_tablegen(BuiltinsRISCV.inc -gen-clang-builtins SOURCE BuiltinsRISCV.td TARGET ClangBuiltinsRISCV) diff --git clang/include/clang/Basic/CodeGenOptions.def clang/include/clang/Basic/CodeGenOptions.def index 1ab8c7fb4d3c..259972bdf8f0 100644 --- clang/include/clang/Basic/CodeGenOptions.def +++ clang/include/clang/Basic/CodeGenOptions.def @@ -393,6 +393,9 @@ CODEGENOPT(EnableTLSDESC, 1, 0) /// Bit size of immediate TLS offsets (0 == use the default). VALUE_CODEGENOPT(TLSSize, 8, 0) +/// The types of variables that we will extend the live ranges of. +ENUM_CODEGENOPT(ExtendVariableLiveness, ExtendVariableLivenessKind, 2, ExtendVariableLivenessKind::None) + /// The default stack protector guard offset to use. VALUE_CODEGENOPT(StackProtectorGuardOffset, 32, INT_MAX) diff --git clang/include/clang/Basic/CodeGenOptions.h clang/include/clang/Basic/CodeGenOptions.h index b64ad74d711c..c531c656f42b 100644 --- clang/include/clang/Basic/CodeGenOptions.h +++ clang/include/clang/Basic/CodeGenOptions.h @@ -95,6 +95,12 @@ public: Embed_Marker // Embed a marker as a placeholder for bitcode. }; + enum class ExtendVariableLivenessKind { + None, + This, + All, + }; + enum InlineAsmDialectKind { IAD_ATT, IAD_Intel, diff --git clang/include/clang/Basic/Diagnostic.h clang/include/clang/Basic/Diagnostic.h index 510b782e35d0..848acce3c4f1 100644 --- clang/include/clang/Basic/Diagnostic.h +++ clang/include/clang/Basic/Diagnostic.h @@ -375,10 +375,12 @@ private: // Map extensions to warnings or errors? diag::Severity ExtBehavior = diag::Severity::Ignored; - DiagState() + DiagnosticIDs &DiagIDs; + + DiagState(DiagnosticIDs &DiagIDs) : IgnoreAllWarnings(false), EnableAllWarnings(false), WarningsAsErrors(false), ErrorsAsFatal(false), - SuppressSystemWarnings(false) {} + SuppressSystemWarnings(false), DiagIDs(DiagIDs) {} using iterator = llvm::DenseMap<unsigned, DiagnosticMapping>::iterator; using const_iterator = @@ -893,6 +895,8 @@ public: /// \param FormatString A fixed diagnostic format string that will be hashed /// and mapped to a unique DiagID. template <unsigned N> + // TODO: Deprecate this once all uses are removed from Clang. + // [[deprecated("Use a CustomDiagDesc instead of a Level")]] unsigned getCustomDiagID(Level L, const char (&FormatString)[N]) { return Diags->getCustomDiagID((DiagnosticIDs::Level)L, StringRef(FormatString, N - 1)); diff --git clang/include/clang/Basic/DiagnosticCategories.h clang/include/clang/Basic/DiagnosticCategories.h index 14be326f7515..839f8dee3ca8 100644 --- clang/include/clang/Basic/DiagnosticCategories.h +++ clang/include/clang/Basic/DiagnosticCategories.h @@ -21,11 +21,12 @@ namespace clang { }; enum class Group { -#define DIAG_ENTRY(GroupName, FlagNameOffset, Members, SubGroups, Docs) \ - GroupName, +#define DIAG_ENTRY(GroupName, FlagNameOffset, Members, SubGroups, Docs) \ + GroupName, #include "clang/Basic/DiagnosticGroups.inc" #undef CATEGORY #undef DIAG_ENTRY + NUM_GROUPS }; } // end namespace diag } // end namespace clang diff --git clang/include/clang/Basic/DiagnosticCommonKinds.td clang/include/clang/Basic/DiagnosticCommonKinds.td index f4a155bb00bb..f26c906b4644 100644 --- clang/include/clang/Basic/DiagnosticCommonKinds.td +++ clang/include/clang/Basic/DiagnosticCommonKinds.td @@ -402,16 +402,6 @@ def note_file_misc_sloc_usage : Note< def err_module_format_unhandled : Error< "no handler registered for module format '%0'">, DefaultFatal; -// TransformActions -// TODO: Use a custom category name to distinguish rewriter errors. -def err_mt_message : Error<"[rewriter] %0">, SuppressInSystemHeader; -def warn_mt_message : Warning<"[rewriter] %0">; -def note_mt_message : Note<"[rewriter] %0">; - -// ARCMigrate -def warn_arcmt_nsalloc_realloc : Warning<"[rewriter] call returns pointer to GC managed memory; it will become unmanaged in ARC">; -def err_arcmt_nsinvocation_ownership : Error<"NSInvocation's %0 is not safe to be used with an object with ownership other than __unsafe_unretained">; - // API notes def err_apinotes_message : Error<"%0">; def warn_apinotes_message : Warning<"%0">, InGroup<DiagGroup<"apinotes">>; diff --git clang/include/clang/Basic/DiagnosticDriverKinds.td clang/include/clang/Basic/DiagnosticDriverKinds.td index 288786b8ce93..8d599c96eb4f 100644 --- clang/include/clang/Basic/DiagnosticDriverKinds.td +++ clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -445,9 +445,6 @@ def warn_drv_clang_unsupported : Warning< "the clang compiler does not support '%0'">; def warn_drv_deprecated_arg : Warning< "argument '%0' is deprecated%select{|, use '%2' instead}1">, InGroup<Deprecated>; -def warn_drv_deprecated_arg_no_relaxed_template_template_args : Warning< - "argument '-fno-relaxed-template-template-args' is deprecated">, - InGroup<DeprecatedNoRelaxedTemplateTemplateArgs>; def warn_drv_deprecated_arg_ofast : Warning< "argument '-Ofast' is deprecated; use '-O3 -ffast-math' for the same behavior," " or '-O3' to enable only conforming optimizations">, diff --git clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Basic/DiagnosticGroups.td index 209792f851b6..527e588d46a0 100644 --- clang/include/clang/Basic/DiagnosticGroups.td +++ clang/include/clang/Basic/DiagnosticGroups.td @@ -102,7 +102,6 @@ def EnumConversion : DiagGroup<"enum-conversion", [EnumEnumConversion, EnumFloatConversion, EnumCompareConditional]>; -def DeprecatedNoRelaxedTemplateTemplateArgs : DiagGroup<"deprecated-no-relaxed-template-template-args">; def DeprecatedOFast : DiagGroup<"deprecated-ofast">; def ObjCSignedCharBoolImplicitIntConversion : DiagGroup<"objc-signed-char-bool-implicit-int-conversion">; @@ -230,7 +229,6 @@ def Deprecated : DiagGroup<"deprecated", [DeprecatedAnonEnumEnumConversion, DeprecatedLiteralOperator, DeprecatedPragma, DeprecatedRegister, - DeprecatedNoRelaxedTemplateTemplateArgs, DeprecatedOFast, DeprecatedThisCapture, DeprecatedType, diff --git clang/include/clang/Basic/DiagnosticIDs.h clang/include/clang/Basic/DiagnosticIDs.h index a051af327de2..b49185c3335d 100644 --- clang/include/clang/Basic/DiagnosticIDs.h +++ clang/include/clang/Basic/DiagnosticIDs.h @@ -14,6 +14,7 @@ #ifndef LLVM_CLANG_BASIC_DIAGNOSTICIDS_H #define LLVM_CLANG_BASIC_DIAGNOSTICIDS_H +#include "clang/Basic/DiagnosticCategories.h" #include "clang/Basic/LLVM.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/StringRef.h" @@ -84,7 +85,7 @@ namespace clang { /// to either Ignore (nothing), Remark (emit a remark), Warning /// (emit a warning) or Error (emit as an error). It allows clients to /// map ERRORs to Error or Fatal (stop emitting diagnostics after this one). - enum class Severity { + enum class Severity : uint8_t { // NOTE: 0 means "uncomputed". Ignored = 1, ///< Do not present this diagnostic, ignore it. Remark = 2, ///< Present this diagnostic as a remark. @@ -181,13 +182,96 @@ public: class DiagnosticIDs : public RefCountedBase<DiagnosticIDs> { public: /// The level of the diagnostic, after it has been through mapping. - enum Level { - Ignored, Note, Remark, Warning, Error, Fatal + enum Level : uint8_t { Ignored, Note, Remark, Warning, Error, Fatal }; + + // Diagnostic classes. + enum Class { + CLASS_INVALID = 0x00, + CLASS_NOTE = 0x01, + CLASS_REMARK = 0x02, + CLASS_WARNING = 0x03, + CLASS_EXTENSION = 0x04, + CLASS_ERROR = 0x05 + }; + + static bool IsCustomDiag(diag::kind Diag) { + return Diag >= diag::DIAG_UPPER_LIMIT; + } + + class CustomDiagDesc { + LLVM_PREFERRED_TYPE(diag::Severity) + unsigned DefaultSeverity : 3; + LLVM_PREFERRED_TYPE(Class) + unsigned DiagClass : 3; + LLVM_PREFERRED_TYPE(bool) + unsigned ShowInSystemHeader : 1; + LLVM_PREFERRED_TYPE(bool) + unsigned ShowInSystemMacro : 1; + LLVM_PREFERRED_TYPE(bool) + unsigned HasGroup : 1; + diag::Group Group; + std::string Description; + + auto get_as_tuple() const { + return std::tuple(DefaultSeverity, DiagClass, ShowInSystemHeader, + ShowInSystemMacro, HasGroup, Group, + std::string_view{Description}); + } + + public: + CustomDiagDesc(diag::Severity DefaultSeverity, std::string Description, + unsigned Class = CLASS_WARNING, + bool ShowInSystemHeader = false, + bool ShowInSystemMacro = false, + std::optional<diag::Group> Group = std::nullopt) + : DefaultSeverity(static_cast<unsigned>(DefaultSeverity)), + DiagClass(Class), ShowInSystemHeader(ShowInSystemHeader), + ShowInSystemMacro(ShowInSystemMacro), HasGroup(Group != std::nullopt), + Group(Group.value_or(diag::Group{})), + Description(std::move(Description)) {} + + std::optional<diag::Group> GetGroup() const { + if (HasGroup) + return Group; + return std::nullopt; + } + + diag::Severity GetDefaultSeverity() const { + return static_cast<diag::Severity>(DefaultSeverity); + } + + Class GetClass() const { return static_cast<Class>(DiagClass); } + std::string_view GetDescription() const { return Description; } + bool ShouldShowInSystemHeader() const { return ShowInSystemHeader; } + + friend bool operator==(const CustomDiagDesc &lhs, + const CustomDiagDesc &rhs) { + return lhs.get_as_tuple() == rhs.get_as_tuple(); + } + + friend bool operator<(const CustomDiagDesc &lhs, + const CustomDiagDesc &rhs) { + return lhs.get_as_tuple() < rhs.get_as_tuple(); + } + }; + + struct GroupInfo { + LLVM_PREFERRED_TYPE(diag::Severity) + unsigned Severity : 3; + LLVM_PREFERRED_TYPE(bool) + unsigned HasNoWarningAsError : 1; }; private: /// Information for uniquing and looking up custom diags. std::unique_ptr<diag::CustomDiagInfo> CustomDiagInfo; + std::unique_ptr<GroupInfo[]> GroupInfos = []() { + auto GIs = std::make_unique<GroupInfo[]>( + static_cast<size_t>(diag::Group::NUM_GROUPS)); + for (size_t i = 0; i != static_cast<size_t>(diag::Group::NUM_GROUPS); ++i) + GIs[i] = {{}, false}; + return GIs; + }(); public: DiagnosticIDs(); @@ -202,7 +286,35 @@ public: // FIXME: Replace this function with a create-only facilty like // createCustomDiagIDFromFormatString() to enforce safe usage. At the time of // writing, nearly all callers of this function were invalid. - unsigned getCustomDiagID(Level L, StringRef FormatString); + unsigned getCustomDiagID(CustomDiagDesc Diag); + + // TODO: Deprecate this once all uses are removed from LLVM + // [[deprecated("Use a CustomDiagDesc instead of a Level")]] + unsigned getCustomDiagID(Level Level, StringRef Message) { + return getCustomDiagID([&]() -> CustomDiagDesc { + switch (Level) { + case DiagnosticIDs::Level::Ignored: + return {diag::Severity::Ignored, std::string(Message), CLASS_WARNING, + /*ShowInSystemHeader*/ true, /*ShowInSystemMacro=*/true}; + case DiagnosticIDs::Level::Note: + return {diag::Severity::Fatal, std::string(Message), CLASS_NOTE, + /*ShowInSystemHeader*/ true, /*ShowInSystemMacro=*/true}; + case DiagnosticIDs::Level::Remark: + return {diag::Severity::Remark, std::string(Message), CLASS_REMARK, + /*ShowInSystemHeader*/ true, /*ShowInSystemMacro=*/true}; + case DiagnosticIDs::Level::Warning: + return {diag::Severity::Warning, std::string(Message), CLASS_WARNING, + /*ShowInSystemHeader*/ true, /*ShowInSystemMacro=*/true}; + case DiagnosticIDs::Level::Error: + return {diag::Severity::Error, std::string(Message), CLASS_ERROR, + /*ShowInSystemHeader*/ true, /*ShowInSystemMacro=*/true}; + case DiagnosticIDs::Level::Fatal: + return {diag::Severity::Fatal, std::string(Message), CLASS_ERROR, + /*ShowInSystemHeader*/ true, /*ShowInSystemMacro=*/true}; + } + llvm_unreachable("Fully covered switch above!"); + }()); + } //===--------------------------------------------------------------------===// // Diagnostic classification and reporting interfaces. @@ -214,35 +326,36 @@ public: /// Return true if the unmapped diagnostic levelof the specified /// diagnostic ID is a Warning or Extension. /// - /// This only works on builtin diagnostics, not custom ones, and is not - /// legal to call on NOTEs. - static bool isBuiltinWarningOrExtension(unsigned DiagID); + /// This is not legal to call on NOTEs. + bool isWarningOrExtension(unsigned DiagID) const; /// Return true if the specified diagnostic is mapped to errors by /// default. - static bool isDefaultMappingAsError(unsigned DiagID); + bool isDefaultMappingAsError(unsigned DiagID) const; /// Get the default mapping for this diagnostic. - static DiagnosticMapping getDefaultMapping(unsigned DiagID); + DiagnosticMapping getDefaultMapping(unsigned DiagID) const; + + void initCustomDiagMapping(DiagnosticMapping &, unsigned DiagID); - /// Determine whether the given built-in diagnostic ID is a Note. - static bool isBuiltinNote(unsigned DiagID); + /// Determine whether the given diagnostic ID is a Note. + bool isNote(unsigned DiagID) const; - /// Determine whether the given built-in diagnostic ID is for an + /// Determine whether the given diagnostic ID is for an /// extension of some sort. - static bool isBuiltinExtensionDiag(unsigned DiagID) { + bool isExtensionDiag(unsigned DiagID) const { bool ignored; - return isBuiltinExtensionDiag(DiagID, ignored); + return isExtensionDiag(DiagID, ignored); } - /// Determine whether the given built-in diagnostic ID is for an + /// Determine whether the given diagnostic ID is for an /// extension of some sort, and whether it is enabled by default. /// /// This also returns EnabledByDefault, which is set to indicate whether the /// diagnostic is ignored by default (in which case -pedantic enables it) or /// treated as a warning/error by default. /// - static bool isBuiltinExtensionDiag(unsigned DiagID, bool &EnabledByDefault); + bool isExtensionDiag(unsigned DiagID, bool &EnabledByDefault) const; /// Given a group ID, returns the flag that toggles the group. /// For example, for Group::DeprecatedDeclarations, returns @@ -252,19 +365,22 @@ public: /// Given a diagnostic group ID, return its documentation. static StringRef getWarningOptionDocumentation(diag::Group GroupID); + void setGroupSeverity(StringRef Group, diag::Severity); + void setGroupNoWarningsAsError(StringRef Group, bool); + /// Given a group ID, returns the flag that toggles the group. /// For example, for "deprecated-declarations", returns /// Group::DeprecatedDeclarations. static std::optional<diag::Group> getGroupForWarningOption(StringRef); /// Return the lowest-level group that contains the specified diagnostic. - static std::optional<diag::Group> getGroupForDiag(unsigned DiagID); + std::optional<diag::Group> getGroupForDiag(unsigned DiagID) const; /// Return the lowest-level warning option that enables the specified /// diagnostic. /// /// If there is no -Wfoo flag that controls the diagnostic, this returns null. - static StringRef getWarningOptionForDiag(unsigned DiagID); + StringRef getWarningOptionForDiag(unsigned DiagID); /// Return the category number that a specified \p DiagID belongs to, /// or 0 if no category. @@ -365,6 +481,8 @@ private: getDiagnosticSeverity(unsigned DiagID, SourceLocation Loc, const DiagnosticsEngine &Diag) const LLVM_READONLY; + Class getDiagClass(unsigned DiagID) const; + /// Used to report a diagnostic that is finally fully formed. /// /// \returns \c true if the diagnostic was emitted, \c false if it was diff --git clang/include/clang/Basic/DiagnosticParseKinds.td clang/include/clang/Basic/DiagnosticParseKinds.td index 3309f59a981f..c513dab810d1 100644 --- clang/include/clang/Basic/DiagnosticParseKinds.td +++ clang/include/clang/Basic/DiagnosticParseKinds.td @@ -1099,6 +1099,16 @@ def err_lambda_capture_misplaced_ellipsis : Error< "the name of the capture">; def err_lambda_capture_multiple_ellipses : Error< "multiple ellipses in pack capture">; +def err_binding_multiple_ellipses : Error< + "multiple packs in structured binding declaration">; +def note_previous_ellipsis : Note< + "previous binding pack specified here">; +def ext_cxx_binding_pack : ExtWarn< + "structured binding packs are a C++2c extension ">, + InGroup<CXX26>; +def warn_cxx23_compat_binding_pack : Warning< + "structured binding packs are incompatible with C++ standards before C++2c">, + InGroup<CXXPre26Compat>, DefaultIgnore; def err_capture_default_first : Error< "capture default must be first">; def ext_decl_attrs_on_lambda : ExtWarn< diff --git clang/include/clang/Basic/DiagnosticSemaKinds.td clang/include/clang/Basic/DiagnosticSemaKinds.td index 774e5484cfa0..2ac3879a4caa 100644 --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -82,11 +82,11 @@ def err_typecheck_converted_constant_expression_indirect : Error< "conversion from %0 to %1 in converted constant expression would " "bind reference to a temporary">; def err_expr_not_cce : Error< - "%select{case value|enumerator value|non-type template argument|" + "%select{case value|enumerator value|non-type template argument|non-type parameter of template template parameter|" "array size|explicit specifier argument|noexcept specifier argument|" "call to 'size()'|call to 'data()'}0 is not a constant expression">; def ext_cce_narrowing : ExtWarn< - "%select{case value|enumerator value|non-type template argument|" + "%select{case value|enumerator value|non-type template argument|non-type parameter of template template parameter|" "array size|explicit specifier argument|noexcept specifier argument|" "call to 'size()'|call to 'data()'}0 %select{cannot be narrowed from " "type %2 to %3|evaluates to %2, which cannot be narrowed to type %3}1">, @@ -2953,9 +2953,15 @@ def ext_constexpr_function_never_constant_expr : ExtWarn< "constant expression">, InGroup<DiagGroup<"invalid-constexpr">>, DefaultError; def err_attr_cond_never_constant_expr : Error< "%0 attribute expression never produces a constant expression">; +def err_diagnose_if_unknown_warning : Error<"unknown warning group '%0'">; def err_diagnose_if_invalid_diagnostic_type : Error< "invalid diagnostic type for 'diagnose_if'; use \"error\" or \"warning\" " "instead">; +def err_diagnose_if_unknown_option : Error<"unknown diagnostic option">; +def err_diagnose_if_expected_equals : Error< + "expected '=' after diagnostic option">; +def err_diagnose_if_unexpected_value : Error< + "unexpected value; use 'true' or 'false'">; def err_constexpr_body_no_return : Error< "no return statement in %select{constexpr|consteval}0 function">; def err_constexpr_return_missing_expr : Error< @@ -3864,6 +3870,9 @@ def err_sme_definition_using_za_in_non_sme_target : Error< "function using ZA state requires 'sme'">; def err_sme_definition_using_zt0_in_non_sme2_target : Error< "function using ZT0 state requires 'sme2'">; +def err_sme_openmp_captured_region : Error< + "OpenMP captured regions are not yet supported in " + "%select{streaming functions|functions with ZA state|functions with ZT0 state}0">; def warn_sme_streaming_pass_return_vl_to_non_streaming : Warning< "%select{returning|passing}0 a VL-dependent argument %select{from|to}0 a function with a different" " streaming-mode is undefined behaviour when the streaming and non-streaming vector lengths are different at runtime">, @@ -5936,6 +5945,9 @@ def warn_cxx23_pack_indexing : Warning< "pack indexing is incompatible with C++ standards before C++2c">, DefaultIgnore, InGroup<CXXPre26Compat>; +def err_pack_outside_template : Error< + "pack declaration outside of template">; + def err_fold_expression_packs_both_sides : Error< "binary fold expression has unexpanded parameter packs in both operands">; def err_fold_expression_empty : Error< diff --git clang/include/clang/Basic/LangOptions.def clang/include/clang/Basic/LangOptions.def index a980be853d53..cb55f09acc07 100644 --- clang/include/clang/Basic/LangOptions.def +++ clang/include/clang/Basic/LangOptions.def @@ -160,7 +160,6 @@ LANGOPT(GNUAsm , 1, 1, "GNU-style inline assembly") LANGOPT(Coroutines , 1, 0, "C++20 coroutines") LANGOPT(CoroAlignedAllocation, 1, 0, "prefer Aligned Allocation according to P2014 Option 2") LANGOPT(DllExportInlines , 1, 1, "dllexported classes dllexport inline methods") -LANGOPT(RelaxedTemplateTemplateArgs, 1, 1, "C++17 relaxed matching of template template arguments") LANGOPT(ExperimentalLibrary, 1, 0, "enable unstable and experimental library features") LANGOPT(RetainSubstTemplateTypeParmTypeAstNodes, 1, 0, "retain SubstTemplateTypeParmType nodes in the AST's representation of alias template specializations") @@ -407,6 +406,7 @@ VALUE_LANGOPT(TrivialAutoVarInitMaxSize, 32, 0, "stop trivial automatic variable initialization if var size exceeds the specified size (in bytes). Must be greater than 0.") ENUM_LANGOPT(SignedOverflowBehavior, SignedOverflowBehaviorTy, 2, SOB_Undefined, "signed integer overflow handling") +LANGOPT(PointerOverflowDefined, 1, 0, "make pointer overflow defined") ENUM_LANGOPT(ThreadModel , ThreadModelKind, 2, ThreadModelKind::POSIX, "Thread Model") BENIGN_LANGOPT(ArrowDepth, 32, 256, diff --git clang/include/clang/Basic/LangOptions.h clang/include/clang/Basic/LangOptions.h index 949c8f5d448b..114a5d34a008 100644 --- clang/include/clang/Basic/LangOptions.h +++ clang/include/clang/Basic/LangOptions.h @@ -144,6 +144,7 @@ public: MSVC2019_5 = 1925, MSVC2019_8 = 1928, MSVC2022_3 = 1933, + MSVC2022_9 = 1939, }; enum SYCLMajorVersion { diff --git clang/include/clang/Basic/StmtNodes.td clang/include/clang/Basic/StmtNodes.td index 53fc77bbbcec..2fea05e322c7 100644 --- clang/include/clang/Basic/StmtNodes.td +++ clang/include/clang/Basic/StmtNodes.td @@ -163,6 +163,7 @@ def MaterializeTemporaryExpr : StmtNode<Expr>; def LambdaExpr : StmtNode<Expr>; def CXXFoldExpr : StmtNode<Expr>; def CXXParenListInitExpr: StmtNode<Expr>; +def ResolvedUnexpandedPackExpr : StmtNode<Expr>; // C++ Coroutines expressions def CoroutineSuspendExpr : StmtNode<Expr, 1>; diff --git clang/include/clang/Basic/TargetBuiltins.h clang/include/clang/Basic/TargetBuiltins.h index 4dc8b24ed8ae..95eb110bb9c2 100644 --- clang/include/clang/Basic/TargetBuiltins.h +++ clang/include/clang/Basic/TargetBuiltins.h @@ -101,12 +101,12 @@ namespace clang { /// NVPTX builtins namespace NVPTX { - enum { - LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1, + enum { + LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, #define BUILTIN(ID, TYPE, ATTRS) BI##ID, -#include "clang/Basic/BuiltinsNVPTX.def" - LastTSBuiltin - }; +#include "clang/Basic/BuiltinsNVPTX.inc" + LastTSBuiltin + }; } /// AMDGPU builtins @@ -208,7 +208,8 @@ namespace clang { Float16, Float32, Float64, - BFloat16 + BFloat16, + MFloat8 }; NeonTypeFlags(unsigned F) : Flags(F) {} @@ -230,6 +231,7 @@ namespace clang { switch (getEltType()) { case Int8: case Poly8: + case MFloat8: return 8; case Int16: case Float16: @@ -352,12 +354,12 @@ namespace clang { /// Hexagon builtins namespace Hexagon { - enum { - LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1, + enum { + LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, #define BUILTIN(ID, TYPE, ATTRS) BI##ID, -#include "clang/Basic/BuiltinsHexagon.def" - LastTSBuiltin - }; +#include "clang/Basic/BuiltinsHexagon.inc" + LastTSBuiltin + }; } /// MIPS builtins diff --git clang/include/clang/Basic/TokenKinds.def clang/include/clang/Basic/TokenKinds.def index 2c692c999bdf..8902a20b07ff 100644 --- clang/include/clang/Basic/TokenKinds.def +++ clang/include/clang/Basic/TokenKinds.def @@ -707,7 +707,7 @@ ALIAS("__decltype" , decltype , KEYCXX) ALIAS("__imag__" , __imag , KEYALL) ALIAS("__inline" , inline , KEYALL) ALIAS("__inline__" , inline , KEYALL) -ALIAS("__nullptr" , nullptr , KEYCXX) +ALIAS("__nullptr" , nullptr , KEYALL) ALIAS("__real__" , __real , KEYALL) ALIAS("__restrict" , restrict , KEYALL) ALIAS("__restrict__" , restrict , KEYALL) diff --git clang/include/clang/Basic/Version.inc.in clang/include/clang/Basic/Version.inc.in index 370da8506d14..69c79d03861c 100644 --- clang/include/clang/Basic/Version.inc.in +++ clang/include/clang/Basic/Version.inc.in @@ -4,3 +4,4 @@ #define CLANG_VERSION_MAJOR_STRING "@CLANG_VERSION_MAJOR@" #define CLANG_VERSION_MINOR @CLANG_VERSION_MINOR@ #define CLANG_VERSION_PATCHLEVEL @CLANG_VERSION_PATCHLEVEL@ +#define MAX_CLANG_ABI_COMPAT_VERSION @MAX_CLANG_ABI_COMPAT_VERSION@ diff --git clang/include/clang/Basic/arm_neon.td clang/include/clang/Basic/arm_neon.td index ddc5391eb3fa..3e73dd054933 100644 --- clang/include/clang/Basic/arm_neon.td +++ clang/include/clang/Basic/arm_neon.td @@ -1299,7 +1299,7 @@ def VQTBX4_A64 : WInst<"vqtbx4", "..(4Q)U", "UccPcQUcQcQPc">; // NeonEmitter implicitly takes the cartesian product of the type string with // itself during generation so, unlike all other intrinsics, this one should // include *all* types, not just additional ones. -def VVREINTERPRET : REINTERPRET_CROSS_SELF<"csilUcUsUiUlhfdPcPsPlQcQsQiQlQUcQUsQUiQUlQhQfQdQPcQPsQPlQPk"> { +def VVREINTERPRET : REINTERPRET_CROSS_SELF<"csilUcUsUiUlmhfdPcPsPlQcQsQiQlQUcQUsQUiQUlQmQhQfQdQPcQPsQPlQPk"> { let ArchGuard = "defined(__aarch64__) || defined(__arm64ec__)"; let BigEndianSafe = 1; } @@ -2119,6 +2119,72 @@ let ArchGuard = "defined(__aarch64__)", TargetGuard = "lut" in { } } +let ArchGuard = "defined(__aarch64__)", TargetGuard = "fp8,neon" in { + def VBF1CVT_BF16_MF8 : VInst<"vcvt1_bf16_mf8_fpm", "(QB).V", "m">; + def VBF1CVT_LOW_BF16_MF8 : VInst<"vcvt1_low_bf16_mf8_fpm", "B.V", "Hm">; + def VBF2CVTL_BF16_MF8 : VInst<"vcvt2_bf16_mf8_fpm", "(QB).V", "m">; + def VBF2CVTL_LOW_BF16_MF8 : VInst<"vcvt2_low_bf16_mf8_fpm", "B.V", "Hm">; + def VBF1CVTL2_HIGH_BF16_MF8 : VInst<"vcvt1_high_bf16_mf8_fpm", "B.V", "Hm">; + def VBF2CVTL2_HIGH_BF16_MF8 : VInst<"vcvt2_high_bf16_mf8_fpm", "B.V", "Hm">; +} + +let ArchGuard = "defined(__aarch64__)", TargetGuard = "fp8,neon" in { + def VF1CVT_F16_MF8 : VInst<"vcvt1_f16_mf8_fpm", "(>QF).V", "m">; + def VF1CVT_LOW_F16_MF8 : VInst<"vcvt1_low_f16_mf8_fpm", "(>F).V", "Hm">; + def VF2CVTL_F16_MF8 : VInst<"vcvt2_f16_mf8_fpm", "(>QF).V", "m">; + def VF2CVTL_LOW_F16_MF8 : VInst<"vcvt2_low_f16_mf8_fpm", "(>F).V", "Hm">; + def VF1CVTL2_HIGH_F16_MF8 : VInst<"vcvt1_high_f16_mf8_fpm", "(>F).V", "Hm">; + def VF2CVTL2_HIGH_F16_MF8 : VInst<"vcvt2_high_f16_mf8_fpm", "(>F).V", "Hm">; + + def VCVTN_LOW_F8_F32 : VInst<"vcvt_mf8_f32_fpm", ".(>>QF)(>>QF)V", "m">; + def VCVTN_HIGH_F8_F32 : VInst<"vcvt_high_mf8_f32_fpm", ".(q)(>>F)(>>F)V", "Hm">; + def VCVTN_F8_F16 : VInst<"vcvt_mf8_f16_fpm", ".(>F)(>F)V", "mQm">; +} + +let ArchGuard = "defined(__aarch64__)", TargetGuard = "fp8dot2,neon" in { + def VDOT_F16_MF8 : VInst<"vdot_f16_mf8_fpm", "(>F)(>F)..V", "mQm">; + + def VDOT_LANE_F16_MF8 : VInst<"vdot_lane_f16_mf8_fpm", "(>F)(>F)..IV", "m", [ImmCheck<3, ImmCheck0_3, 0>]>; + def VDOT_LANEQ_F16_MF8 : VInst<"vdot_laneq_f16_mf8_fpm", "(>F)(>F).QIV", "m", [ImmCheck<3, ImmCheck0_7, 0>]>; + + def VDOTQ_LANE_F16_MF8 : VInst<"vdot_lane_f16_mf8_fpm", "(>F)(>F).qIV", "Qm", [ImmCheck<3, ImmCheck0_3, 0>]>; + def VDOTQ_LANEQ_F16_MF8 : VInst<"vdot_laneq_f16_mf8_fpm", "(>F)(>F)..IV", "Qm", [ImmCheck<3, ImmCheck0_7, 0>]>; +} + +let ArchGuard = "defined(__aarch64__)", TargetGuard = "fp8dot4,neon" in { + def VDOT_F32_MF8 : VInst<"vdot_f32_mf8_fpm", "(>>F)(>>F)..V", "mQm">; + + def VDOT_LANE_F32_MF8 : VInst<"vdot_lane_f32_mf8_fpm", "(>>F)(>>F)..IV", "m", [ImmCheck<3, ImmCheck0_1, 0>]>; + def VDOT_LANEQ_F32_MF8 : VInst<"vdot_laneq_f32_mf8_fpm", "(>>F)(>>F).QIV", "m", [ImmCheck<3, ImmCheck0_3, 0>]>; + + def VDOTQ_LANE_F32_MF8 : VInst<"vdot_lane_f32_mf8_fpm", "(>>F)(>>F).qIV", "Qm", [ImmCheck<3, ImmCheck0_1, 0>]>; + def VDOTQ_LANEQ_F32_MF8 : VInst<"vdot_laneq_f32_mf8_fpm", "(>>F)(>>F)..IV", "Qm", [ImmCheck<3, ImmCheck0_3, 0>]>; +} + +let ArchGuard = "defined(__aarch64__)", TargetGuard = "fp8fma,neon" in { + def VMLALB_F16_F8 : VInst<"vmlalb_f16_mf8_fpm", "(>F)(>F)..V", "Qm">; + def VMLALT_F16_F8 : VInst<"vmlalt_f16_mf8_fpm", "(>F)(>F)..V", "Qm">; + + def VMLALLBB_F32_F8 : VInst<"vmlallbb_f32_mf8_fpm", "(>>F)(>>F)..V", "Qm">; + def VMLALLBT_F32_F8 : VInst<"vmlallbt_f32_mf8_fpm", "(>>F)(>>F)..V", "Qm">; + def VMLALLTB_F32_F8 : VInst<"vmlalltb_f32_mf8_fpm", "(>>F)(>>F)..V", "Qm">; + def VMLALLTT_F32_F8 : VInst<"vmlalltt_f32_mf8_fpm", "(>>F)(>>F)..V", "Qm">; + + def VMLALB_F16_F8_LANE : VInst<"vmlalb_lane_f16_mf8_fpm", "(>F)(>F).qIV", "Qm", [ImmCheck<3, ImmCheck0_7, 0>]>; + def VMLALB_F16_F8_LANEQ : VInst<"vmlalb_laneq_f16_mf8_fpm", "(>F)(>F)..IV", "Qm", [ImmCheck<3, ImmCheck0_15, 0>]>; + def VMLALT_F16_F8_LANE : VInst<"vmlalt_lane_f16_mf8_fpm", "(>F)(>F).qIV", "Qm", [ImmCheck<3, ImmCheck0_7, 0>]>; + def VMLALT_F16_F8_LANEQ : VInst<"vmlalt_laneq_f16_mf8_fpm", "(>F)(>F)..IV", "Qm", [ImmCheck<3, ImmCheck0_15, 0>]>; + + def VMLALLBB_F32_F8_LANE : VInst<"vmlallbb_lane_f32_mf8_fpm", "(>>F)(>>F).qIV", "Qm", [ImmCheck<3, ImmCheck0_7, 0>]>; + def VMLALLBB_F32_F8_LANEQ : VInst<"vmlallbb_laneq_f32_mf8_fpm", "(>>F)(>>F)..IV", "Qm", [ImmCheck<3, ImmCheck0_15, 0>]>; + def VMLALLBT_F32_F8_LANE : VInst<"vmlallbt_lane_f32_mf8_fpm", "(>>F)(>>F).qIV", "Qm", [ImmCheck<3, ImmCheck0_7, 0>]>; + def VMLALLBT_F32_F8_LANEQ : VInst<"vmlallbt_laneq_f32_mf8_fpm", "(>>F)(>>F)..IV", "Qm", [ImmCheck<3, ImmCheck0_15, 0>]>; + def VMLALLTB_F32_F8_LANE : VInst<"vmlalltb_lane_f32_mf8_fpm", "(>>F)(>>F).qIV", "Qm", [ImmCheck<3, ImmCheck0_7, 0>]>; + def VMLALLTB_F32_F8_LANEQ : VInst<"vmlalltb_laneq_f32_mf8_fpm", "(>>F)(>>F)..IV", "Qm", [ImmCheck<3, ImmCheck0_15, 0>]>; + def VMLALLTT_F32_F8_LANE : VInst<"vmlalltt_lane_f32_mf8_fpm", "(>>F)(>>F).qIV", "Qm", [ImmCheck<3, ImmCheck0_7, 0>]>; + def VMLALLTT_F32_F8_LANEQ : VInst<"vmlalltt_laneq_f32_mf8_fpm", "(>>F)(>>F)..IV", "Qm", [ImmCheck<3, ImmCheck0_15, 0>]>; +} + let ArchGuard = "defined(__aarch64__)", TargetGuard = "neon,faminmax" in { def FAMIN : WInst<"vamin", "...", "fhQdQfQh">; def FAMAX : WInst<"vamax", "...", "fhQdQfQh">; diff --git clang/include/clang/Basic/arm_neon_incl.td clang/include/clang/Basic/arm_neon_incl.td index fd800e5a6278..b9b9d509c225 100644 --- clang/include/clang/Basic/arm_neon_incl.td +++ clang/include/clang/Basic/arm_neon_incl.td @@ -243,6 +243,7 @@ def OP_UNAVAILABLE : Operation { // B: change to BFloat16 // P: change to polynomial category. // p: change polynomial to equivalent integer category. Otherwise nop. +// V: change to fpm_t // // >: double element width (vector size unchanged). // <: half element width (vector size unchanged). @@ -301,6 +302,7 @@ class Inst <string n, string p, string t, Operation o, list<ImmCheck> ch = []>{ class SInst<string n, string p, string t, list<ImmCheck> ch = []> : Inst<n, p, t, OP_NONE, ch> {} class IInst<string n, string p, string t, list<ImmCheck> ch = []> : Inst<n, p, t, OP_NONE, ch> {} class WInst<string n, string p, string t, list<ImmCheck> ch = []> : Inst<n, p, t, OP_NONE, ch> {} +class VInst<string n, string p, string t, list<ImmCheck> ch = []> : Inst<n, p, t, OP_NONE, ch> {} // The following instruction classes are implemented via operators // instead of builtins. As such these declarations are only used for diff --git clang/include/clang/Config/config.h.cmake clang/include/clang/Config/config.h.cmake index 27ed69e21562..00c352b458c3 100644 --- clang/include/clang/Config/config.h.cmake +++ clang/include/clang/Config/config.h.cmake @@ -76,7 +76,6 @@ #cmakedefine01 PPC_LINUX_DEFAULT_IEEELONGDOUBLE /* Enable each functionality of modules */ -#cmakedefine01 CLANG_ENABLE_ARCMT #cmakedefine01 CLANG_ENABLE_OBJC_REWRITER #cmakedefine01 CLANG_ENABLE_STATIC_ANALYZER diff --git clang/include/clang/Driver/Action.h clang/include/clang/Driver/Action.h index feeabae89d6b..e5307b0fcedd 100644 --- clang/include/clang/Driver/Action.h +++ clang/include/clang/Driver/Action.h @@ -60,7 +60,6 @@ public: PrecompileJobClass, ExtractAPIJobClass, AnalyzeJobClass, - MigrateJobClass, CompileJobClass, BackendJobClass, AssembleJobClass, @@ -460,17 +459,6 @@ public: } }; -class MigrateJobAction : public JobAction { - void anchor() override; - -public: - MigrateJobAction(Action *Input, types::ID OutputType); - - static bool classof(const Action *A) { - return A->getKind() == MigrateJobClass; - } -}; - class CompileJobAction : public JobAction { void anchor() override; diff --git clang/include/clang/Driver/Options.td clang/include/clang/Driver/Options.td index 6c171a62bbee..6eabd9f76a79 100644 --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -694,20 +694,6 @@ def ccc_print_phases : Flag<["-"], "ccc-print-phases">, def ccc_print_bindings : Flag<["-"], "ccc-print-bindings">, InternalDebugOpt, HelpText<"Show bindings of tools to actions">; -def ccc_arcmt_check : Flag<["-"], "ccc-arcmt-check">, InternalDriverOpt, - HelpText<"Check for ARC migration issues that need manual handling">; -def ccc_arcmt_modify : Flag<["-"], "ccc-arcmt-modify">, InternalDriverOpt, - HelpText<"Apply modifications to files to conform to ARC">; -def ccc_arcmt_migrate : Separate<["-"], "ccc-arcmt-migrate">, InternalDriverOpt, - HelpText<"Apply modifications and produces temporary files that conform to ARC">; -def arcmt_migrate_report_output : Separate<["-"], "arcmt-migrate-report-output">, - HelpText<"Output path for the plist report">, - Visibility<[ClangOption, CC1Option]>, - MarshallingInfoString<FrontendOpts<"ARCMTMigrateReportOut">>; -def arcmt_migrate_emit_arc_errors : Flag<["-"], "arcmt-migrate-emit-errors">, - HelpText<"Emit ARC errors even if the migrator can fix them">, - Visibility<[ClangOption, CC1Option]>, - MarshallingInfoFlag<FrontendOpts<"ARCMTMigrateEmitARCErrors">>; def gen_reproducer_eq: Joined<["-"], "gen-reproducer=">, Flags<[NoArgumentUnused]>, Visibility<[ClangOption, CLOption, DXCOption]>, HelpText<"Emit reproducer on (option: off, crash (default), error, always)">; @@ -723,87 +709,6 @@ def no_round_trip_args : Flag<["-"], "no-round-trip-args">, Visibility<[CC1Option]>, HelpText<"Disable command line arguments round-trip.">; -def _migrate : Flag<["--"], "migrate">, Flags<[NoXarchOption]>, - HelpText<"Run the migrator">; -def ccc_objcmt_migrate : Separate<["-"], "ccc-objcmt-migrate">, - InternalDriverOpt, - HelpText<"Apply modifications and produces temporary files to migrate to " - "modern ObjC syntax">; - -def objcmt_migrate_literals : Flag<["-"], "objcmt-migrate-literals">, - Visibility<[ClangOption, CC1Option]>, - HelpText<"Enable migration to modern ObjC literals">, - MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_Literals">; -def objcmt_migrate_subscripting : Flag<["-"], "objcmt-migrate-subscripting">, - Visibility<[ClangOption, CC1Option]>, - HelpText<"Enable migration to modern ObjC subscripting">, - MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_Subscripting">; -def objcmt_migrate_property : Flag<["-"], "objcmt-migrate-property">, - Visibility<[ClangOption, CC1Option]>, - HelpText<"Enable migration to modern ObjC property">, - MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_Property">; -def objcmt_migrate_all : Flag<["-"], "objcmt-migrate-all">, - Visibility<[ClangOption, CC1Option]>, - HelpText<"Enable migration to modern ObjC">, - MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_MigrateDecls">; -def objcmt_migrate_readonly_property : Flag<["-"], "objcmt-migrate-readonly-property">, - Visibility<[ClangOption, CC1Option]>, - HelpText<"Enable migration to modern ObjC readonly property">, - MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_ReadonlyProperty">; -def objcmt_migrate_readwrite_property : Flag<["-"], "objcmt-migrate-readwrite-property">, - Visibility<[ClangOption, CC1Option]>, - HelpText<"Enable migration to modern ObjC readwrite property">, - MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_ReadwriteProperty">; -def objcmt_migrate_property_dot_syntax : Flag<["-"], "objcmt-migrate-property-dot-syntax">, - Visibility<[ClangOption, CC1Option]>, - HelpText<"Enable migration of setter/getter messages to property-dot syntax">, - MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_PropertyDotSyntax">; -def objcmt_migrate_annotation : Flag<["-"], "objcmt-migrate-annotation">, - Visibility<[ClangOption, CC1Option]>, - HelpText<"Enable migration to property and method annotations">, - MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_Annotation">; -def objcmt_migrate_instancetype : Flag<["-"], "objcmt-migrate-instancetype">, - Visibility<[ClangOption, CC1Option]>, - HelpText<"Enable migration to infer instancetype for method result type">, - MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_Instancetype">; -def objcmt_migrate_nsmacros : Flag<["-"], "objcmt-migrate-ns-macros">, - Visibility<[ClangOption, CC1Option]>, - HelpText<"Enable migration to NS_ENUM/NS_OPTIONS macros">, - MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_NsMacros">; -def objcmt_migrate_protocol_conformance : Flag<["-"], "objcmt-migrate-protocol-conformance">, - Visibility<[ClangOption, CC1Option]>, - HelpText<"Enable migration to add protocol conformance on classes">, - MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_ProtocolConformance">; -def objcmt_atomic_property : Flag<["-"], "objcmt-atomic-property">, - Visibility<[ClangOption, CC1Option]>, - HelpText<"Make migration to 'atomic' properties">, - MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_AtomicProperty">; -def objcmt_returns_innerpointer_property : Flag<["-"], "objcmt-returns-innerpointer-property">, - Visibility<[ClangOption, CC1Option]>, - HelpText<"Enable migration to annotate property with NS_RETURNS_INNER_POINTER">, - MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_ReturnsInnerPointerProperty">; -def objcmt_ns_nonatomic_iosonly: Flag<["-"], "objcmt-ns-nonatomic-iosonly">, - Visibility<[ClangOption, CC1Option]>, - HelpText<"Enable migration to use NS_NONATOMIC_IOSONLY macro for setting property's 'atomic' attribute">, - MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_NsAtomicIOSOnlyProperty">; -def objcmt_migrate_designated_init : Flag<["-"], "objcmt-migrate-designated-init">, - Visibility<[ClangOption, CC1Option]>, - HelpText<"Enable migration to infer NS_DESIGNATED_INITIALIZER for initializer methods">, - MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_DesignatedInitializer">; - -def objcmt_allowlist_dir_path: Joined<["-"], "objcmt-allowlist-dir-path=">, - Visibility<[ClangOption, CC1Option]>, - HelpText<"Only modify files with a filename contained in the provided directory path">, - MarshallingInfoString<FrontendOpts<"ObjCMTAllowListPath">>; -def : Joined<["-"], "objcmt-whitelist-dir-path=">, - Visibility<[ClangOption, CC1Option]>, - HelpText<"Alias for -objcmt-allowlist-dir-path">, - Alias<objcmt_allowlist_dir_path>; -// The misspelt "white-list" [sic] alias is due for removal. -def : Joined<["-"], "objcmt-white-list-dir-path=">, - Visibility<[ClangOption, CC1Option]>, - Alias<objcmt_allowlist_dir_path>; - // Make sure all other -ccc- options are rejected. def ccc_ : Joined<["-"], "ccc-">, Group<internal_Group>, Flags<[Unsupported]>; @@ -3557,11 +3462,6 @@ defm application_extension : BoolFOption<"application-extension", PosFlag<SetTrue, [], [ClangOption, CC1Option], "Restrict code to those available for App Extensions">, NegFlag<SetFalse>>; -defm relaxed_template_template_args : BoolFOption<"relaxed-template-template-args", - LangOpts<"RelaxedTemplateTemplateArgs">, DefaultTrue, - PosFlag<SetTrue, [], [], "Enable">, - NegFlag<SetFalse, [], [CC1Option], "Disable">, - BothFlags<[], [ClangOption], " C++17 relaxed template template argument matching">>; defm retain_subst_template_type_parm_type_ast_nodes : BoolFOption<"retain-subst-template-type-parm-type-ast-nodes", LangOpts<"RetainSubstTemplateTypeParmTypeAstNodes">, DefaultFalse, PosFlag<SetTrue, [], [CC1Option], "Enable">, @@ -4301,6 +4201,11 @@ def fwrapv : Flag<["-"], "fwrapv">, Group<f_Group>, HelpText<"Treat signed integer overflow as two's complement">; def fno_wrapv : Flag<["-"], "fno-wrapv">, Group<f_Group>, Visibility<[ClangOption, CLOption, FlangOption]>; +def fwrapv_pointer : Flag<["-"], "fwrapv-pointer">, Group<f_Group>, + Visibility<[ClangOption, CLOption, CC1Option, FlangOption, FC1Option]>, + HelpText<"Treat pointer overflow as two's complement">; +def fno_wrapv_pointer : Flag<["-"], "fno-wrapv-pointer">, Group<f_Group>, + Visibility<[ClangOption, CLOption, FlangOption]>; def fwritable_strings : Flag<["-"], "fwritable-strings">, Group<f_Group>, Visibility<[ClangOption, CC1Option]>, HelpText<"Store string literals as writable data">, @@ -4344,6 +4249,18 @@ def stack_usage_file : Separate<["-"], "stack-usage-file">, Visibility<[CC1Option]>, HelpText<"Filename (or -) to write stack usage output to">, MarshallingInfoString<CodeGenOpts<"StackUsageOutput">>; +def fextend_variable_liveness_EQ : Joined<["-"], "fextend-variable-liveness=">, + Group<f_Group>, Visibility<[ClangOption, CC1Option]>, + HelpText<"Extend the liveness of user variables through optimizations to " + "prevent stale or optimized-out variable values when debugging.">, + Values<"all,this,none">, + NormalizedValues<["All", "This", "None"]>, + NormalizedValuesScope<"CodeGenOptions::ExtendVariableLivenessKind">, + MarshallingInfoEnum<CodeGenOpts<"ExtendVariableLiveness">, "None">; +def fextend_variable_liveness : Flag<["-"], "fextend-variable-liveness">, + Visibility<[ClangOption, CC1Option]>, + Alias<fextend_variable_liveness_EQ>, AliasArgs<["all"]>, + HelpText<"Alias for -fextend-variable-liveness=all.">; defm unique_basic_block_section_names : BoolFOption<"unique-basic-block-section-names", CodeGenOpts<"UniqueBasicBlockSectionNames">, DefaultFalse, @@ -7963,8 +7880,6 @@ def rewrite_test : Flag<["-"], "rewrite-test">, HelpText<"Rewriter playground">; def rewrite_macros : Flag<["-"], "rewrite-macros">, HelpText<"Expand macros without full preprocessing">; -def migrate : Flag<["-"], "migrate">, - HelpText<"Migrate source code">; def compiler_options_dump : Flag<["-"], "compiler-options-dump">, HelpText<"Dump the compiler configuration options">; def print_dependency_directives_minimized_source : Flag<["-"], @@ -7978,17 +7893,6 @@ defm emit_llvm_uselists : BoolOption<"", "emit-llvm-uselists", NegFlag<SetFalse, [], [ClangOption], "Don't preserve">, BothFlags<[], [ClangOption], " order of LLVM use-lists when serializing">>; -def mt_migrate_directory : Separate<["-"], "mt-migrate-directory">, - HelpText<"Directory for temporary files produced during ARC or ObjC migration">, - MarshallingInfoString<FrontendOpts<"MTMigrateDir">>; - -def arcmt_action_EQ : Joined<["-"], "arcmt-action=">, Visibility<[CC1Option]>, - HelpText<"The ARC migration action to take">, - Values<"check,modify,migrate">, - NormalizedValuesScope<"FrontendOptions">, - NormalizedValues<["ARCMT_Check", "ARCMT_Modify", "ARCMT_Migrate"]>, - MarshallingInfoEnum<FrontendOpts<"ARCMTAction">, "ARCMT_None">; - def print_stats : Flag<["-"], "print-stats">, HelpText<"Print performance metrics and statistics">, MarshallingInfoFlag<FrontendOpts<"ShowStats">>; diff --git clang/include/clang/ExtractAPI/ExtractAPIVisitor.h clang/include/clang/ExtractAPI/ExtractAPIVisitor.h index b09b8b44d9ab..aa86e4180671 100644 --- clang/include/clang/ExtractAPI/ExtractAPIVisitor.h +++ clang/include/clang/ExtractAPI/ExtractAPIVisitor.h @@ -252,6 +252,11 @@ protected: if (!NewRecordContext) return; auto *Tag = D.getType()->getAsTagDecl(); + if (!Tag) { + if (const auto *AT = D.getASTContext().getAsArrayType(D.getType())) { + Tag = AT->getElementType()->getAsTagDecl(); + } + } SmallString<128> TagUSR; clang::index::generateUSRForDecl(Tag, TagUSR); if (auto *Record = llvm::dyn_cast_if_present<TagRecord>( diff --git clang/include/clang/Format/Format.h clang/include/clang/Format/Format.h index fd526f189ec8..6f432d1d5031 100644 --- clang/include/clang/Format/Format.h +++ clang/include/clang/Format/Format.h @@ -3639,6 +3639,10 @@ struct FormatStyle { /// \version 3.7 unsigned PenaltyBreakBeforeFirstCallParameter; + /// The penalty for breaking before a member access operator (``.``, ``->``). + /// \version 20 + unsigned PenaltyBreakBeforeMemberAccess; + /// The penalty for each line break introduced inside a comment. /// \version 3.7 unsigned PenaltyBreakComment; @@ -5311,6 +5315,7 @@ struct FormatStyle { PenaltyBreakAssignment == R.PenaltyBreakAssignment && PenaltyBreakBeforeFirstCallParameter == R.PenaltyBreakBeforeFirstCallParameter && + PenaltyBreakBeforeMemberAccess == R.PenaltyBreakBeforeMemberAccess && PenaltyBreakComment == R.PenaltyBreakComment && PenaltyBreakFirstLessLess == R.PenaltyBreakFirstLessLess && PenaltyBreakOpenParenthesis == R.PenaltyBreakOpenParenthesis && diff --git clang/include/clang/Frontend/FrontendOptions.h clang/include/clang/Frontend/FrontendOptions.h index 8241925c9847..99b2d9a98ed1 100644 --- clang/include/clang/Frontend/FrontendOptions.h +++ clang/include/clang/Frontend/FrontendOptions.h @@ -141,9 +141,6 @@ enum ActionKind { /// Dump template instantiations TemplightDump, - /// Run migrator. - MigrateSource, - /// Just lex, no output. RunPreprocessorOnly, @@ -330,10 +327,6 @@ public: LLVM_PREFERRED_TYPE(bool) unsigned FixToTemporaries : 1; - /// Emit ARC errors even if the migrator can fix them. - LLVM_PREFERRED_TYPE(bool) - unsigned ARCMTMigrateEmitARCErrors : 1; - /// Skip over function bodies to speed up parsing in cases you do not need /// them (e.g. with code completion). LLVM_PREFERRED_TYPE(bool) @@ -424,72 +417,6 @@ public: /// Specifies the output format of the AST. ASTDumpOutputFormat ASTDumpFormat = ADOF_Default; - enum { - ARCMT_None, - ARCMT_Check, - ARCMT_Modify, - ARCMT_Migrate - } ARCMTAction = ARCMT_None; - - enum { - ObjCMT_None = 0, - - /// Enable migration to modern ObjC literals. - ObjCMT_Literals = 0x1, - - /// Enable migration to modern ObjC subscripting. - ObjCMT_Subscripting = 0x2, - - /// Enable migration to modern ObjC readonly property. - ObjCMT_ReadonlyProperty = 0x4, - - /// Enable migration to modern ObjC readwrite property. - ObjCMT_ReadwriteProperty = 0x8, - - /// Enable migration to modern ObjC property. - ObjCMT_Property = (ObjCMT_ReadonlyProperty | ObjCMT_ReadwriteProperty), - - /// Enable annotation of ObjCMethods of all kinds. - ObjCMT_Annotation = 0x10, - - /// Enable migration of ObjC methods to 'instancetype'. - ObjCMT_Instancetype = 0x20, - - /// Enable migration to NS_ENUM/NS_OPTIONS macros. - ObjCMT_NsMacros = 0x40, - - /// Enable migration to add conforming protocols. - ObjCMT_ProtocolConformance = 0x80, - - /// prefer 'atomic' property over 'nonatomic'. - ObjCMT_AtomicProperty = 0x100, - - /// annotate property with NS_RETURNS_INNER_POINTER - ObjCMT_ReturnsInnerPointerProperty = 0x200, - - /// use NS_NONATOMIC_IOSONLY for property 'atomic' attribute - ObjCMT_NsAtomicIOSOnlyProperty = 0x400, - - /// Enable inferring NS_DESIGNATED_INITIALIZER for ObjC methods. - ObjCMT_DesignatedInitializer = 0x800, - - /// Enable converting setter/getter expressions to property-dot syntx. - ObjCMT_PropertyDotSyntax = 0x1000, - - ObjCMT_MigrateDecls = (ObjCMT_ReadonlyProperty | ObjCMT_ReadwriteProperty | - ObjCMT_Annotation | ObjCMT_Instancetype | - ObjCMT_NsMacros | ObjCMT_ProtocolConformance | - ObjCMT_NsAtomicIOSOnlyProperty | - ObjCMT_DesignatedInitializer), - ObjCMT_MigrateAll = (ObjCMT_Literals | ObjCMT_Subscripting | - ObjCMT_MigrateDecls | ObjCMT_PropertyDotSyntax) - }; - unsigned ObjCMTAction = ObjCMT_None; - std::string ObjCMTAllowListPath; - - std::string MTMigrateDir; - std::string ARCMTMigrateReportOut; - /// The input kind, either specified via -x argument or deduced from the input /// file name. InputKind DashX; @@ -596,14 +523,14 @@ public: : DisableFree(false), RelocatablePCH(false), ShowHelp(false), ShowStats(false), AppendStats(false), ShowVersion(false), FixWhatYouCan(false), FixOnlyWarnings(false), FixAndRecompile(false), - FixToTemporaries(false), ARCMTMigrateEmitARCErrors(false), - SkipFunctionBodies(false), UseGlobalModuleIndex(true), - GenerateGlobalModuleIndex(true), ASTDumpDecls(false), - ASTDumpLookups(false), BuildingImplicitModule(false), - BuildingImplicitModuleUsesLock(true), ModulesEmbedAllFiles(false), - IncludeTimestamps(true), UseTemporary(true), - AllowPCMWithCompilerErrors(false), ModulesShareFileManager(true), - EmitSymbolGraph(false), EmitExtensionSymbolGraphs(false), + FixToTemporaries(false), SkipFunctionBodies(false), + UseGlobalModuleIndex(true), GenerateGlobalModuleIndex(true), + ASTDumpDecls(false), ASTDumpLookups(false), + BuildingImplicitModule(false), BuildingImplicitModuleUsesLock(true), + ModulesEmbedAllFiles(false), IncludeTimestamps(true), + UseTemporary(true), AllowPCMWithCompilerErrors(false), + ModulesShareFileManager(true), EmitSymbolGraph(false), + EmitExtensionSymbolGraphs(false), EmitSymbolGraphSymbolLabelsForTesting(false), EmitPrettySymbolGraphs(false), GenReducedBMI(false), UseClangIRPipeline(false), TimeTraceGranularity(500), diff --git clang/include/clang/Sema/DeclSpec.h clang/include/clang/Sema/DeclSpec.h index 06243f262487..5f5df3a45d41 100644 --- clang/include/clang/Sema/DeclSpec.h +++ clang/include/clang/Sema/DeclSpec.h @@ -1795,6 +1795,7 @@ public: IdentifierInfo *Name; SourceLocation NameLoc; std::optional<ParsedAttributes> Attrs; + SourceLocation EllipsisLoc; }; private: diff --git clang/include/clang/Sema/Sema.h clang/include/clang/Sema/Sema.h index 4d6e02fe2956..472a0e25adc9 100644 --- clang/include/clang/Sema/Sema.h +++ clang/include/clang/Sema/Sema.h @@ -16,6 +16,7 @@ #include "clang/APINotes/APINotesManager.h" #include "clang/AST/ASTFwd.h" +#include "clang/AST/ASTLambda.h" #include "clang/AST/Attr.h" #include "clang/AST/AttrIterator.h" #include "clang/AST/CharUnits.h" @@ -231,7 +232,8 @@ void threadSafetyCleanup(BeforeSet *Cache); // FIXME: No way to easily map from TemplateTypeParmTypes to // TemplateTypeParmDecls, so we have this horrible PointerUnion. -typedef std::pair<llvm::PointerUnion<const TemplateTypeParmType *, NamedDecl *>, +typedef std::pair<llvm::PointerUnion<const TemplateTypeParmType *, NamedDecl *, + ResolvedUnexpandedPackExpr *>, SourceLocation> UnexpandedParameterPack; @@ -2330,7 +2332,8 @@ public: const FunctionProtoType *Proto); /// \param FPOnly restricts the arguments to floating-point types. - bool BuiltinVectorMath(CallExpr *TheCall, QualType &Res, bool FPOnly = false); + std::optional<QualType> BuiltinVectorMath(CallExpr *TheCall, + bool FPOnly = false); bool BuiltinVectorToScalarMath(CallExpr *TheCall); void checkLifetimeCaptureBy(FunctionDecl *FDecl, bool IsMemberFunction, @@ -6019,6 +6022,7 @@ public: RecordDecl *ClassDecl, const IdentifierInfo *Name); + unsigned GetDecompositionElementCount(QualType DecompType); void CheckCompleteDecompositionDeclaration(DecompositionDecl *DD); /// Stack containing information needed when in C++2a an 'auto' is encountered @@ -7498,10 +7502,15 @@ public: return K == ConditionKind::Switch ? Context.IntTy : Context.BoolTy; } - // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts - // functions and arrays to their respective pointers (C99 6.3.2.1). + // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2), converts + // functions and arrays to their respective pointers (C99 6.3.2.1), and + // promotes floating-piont types according to the language semantics. ExprResult UsualUnaryConversions(Expr *E); + // UsualUnaryFPConversions - promotes floating-point types according to the + // current language semantics. + ExprResult UsualUnaryFPConversions(Expr *E); + /// CallExprUnaryConversions - a special case of an unary conversion /// performed on a function designator of a call expression. ExprResult CallExprUnaryConversions(Expr *E); @@ -7564,6 +7573,11 @@ public: ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, FunctionDecl *FDecl); + // Check that the usual arithmetic conversions can be performed on this pair + // of expressions that might be of enumeration type. + void checkEnumArithmeticConversions(Expr *LHS, Expr *RHS, SourceLocation Loc, + Sema::ArithConvKind ACK); + // UsualArithmeticConversions - performs the UsualUnaryConversions on it's // operands and then handles various conversions that are common to binary // operators (C99 6.3.1.8). If both operands aren't arithmetic, this @@ -9999,6 +10013,7 @@ public: CCEK_CaseValue, ///< Expression in a case label. CCEK_Enumerator, ///< Enumerator value with fixed underlying type. CCEK_TemplateArg, ///< Value of a non-type template parameter. + CCEK_InjectedTTP, ///< Injected parameter of a template template parameter. CCEK_ArrayBound, ///< Array bound in array declarator or new-expression. CCEK_ExplicitBool, ///< Condition in an explicit(bool) specifier. CCEK_Noexcept, ///< Condition in a noexcept(bool) specifier. @@ -11649,6 +11664,33 @@ public: CTAK_DeducedFromArrayBound }; + struct CheckTemplateArgumentInfo { + explicit CheckTemplateArgumentInfo(bool PartialOrdering = false, + bool MatchingTTP = false) + : PartialOrdering(PartialOrdering), MatchingTTP(MatchingTTP) {} + CheckTemplateArgumentInfo(const CheckTemplateArgumentInfo &) = delete; + CheckTemplateArgumentInfo & + operator=(const CheckTemplateArgumentInfo &) = delete; + + /// The checked, converted argument will be added to the + /// end of these vectors. + SmallVector<TemplateArgument, 4> SugaredConverted, CanonicalConverted; + + /// The check is being performed in the context of partial ordering. + bool PartialOrdering; + + /// If true, assume these template arguments are + /// the injected template arguments for a template template parameter. + /// This will relax the requirement that all its possible uses are valid: + /// TTP checking is loose, and assumes that invalid uses will be diagnosed + /// during instantiation. + bool MatchingTTP; + + /// Is set to true when, in the context of TTP matching, a pack parameter + /// matches non-pack arguments. + bool MatchedPackOnParmToNonPackOnArg = false; + }; + /// Check that the given template argument corresponds to the given /// template parameter. /// @@ -11668,21 +11710,16 @@ public: /// \param ArgumentPackIndex The index into the argument pack where this /// argument will be placed. Only valid if the parameter is a parameter pack. /// - /// \param Converted The checked, converted argument will be added to the - /// end of this small vector. - /// /// \param CTAK Describes how we arrived at this particular template argument: /// explicitly written, deduced, etc. /// /// \returns true on error, false otherwise. - bool - CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, - NamedDecl *Template, SourceLocation TemplateLoc, - SourceLocation RAngleLoc, unsigned ArgumentPackIndex, - SmallVectorImpl<TemplateArgument> &SugaredConverted, - SmallVectorImpl<TemplateArgument> &CanonicalConverted, - CheckTemplateArgumentKind CTAK, bool PartialOrdering, - bool *MatchedPackOnParmToNonPackOnArg); + bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, + NamedDecl *Template, SourceLocation TemplateLoc, + SourceLocation RAngleLoc, + unsigned ArgumentPackIndex, + CheckTemplateArgumentInfo &CTAI, + CheckTemplateArgumentKind CTAK); /// Check that the given template arguments can be provided to /// the given template, converting the arguments along the way. @@ -11715,22 +11752,15 @@ public: /// \param DefaultArgs any default arguments from template specialization /// deduction. /// - /// \param PartialOrderingTTP If true, assume these template arguments are - /// the injected template arguments for a template template parameter. - /// This will relax the requirement that all its possible uses are valid: - /// TTP checking is loose, and assumes that invalid uses will be diagnosed - /// during instantiation. - /// /// \returns true if an error occurred, false otherwise. - bool CheckTemplateArgumentList( - TemplateDecl *Template, SourceLocation TemplateLoc, - TemplateArgumentListInfo &TemplateArgs, - const DefaultArguments &DefaultArgs, bool PartialTemplateArgs, - SmallVectorImpl<TemplateArgument> &SugaredConverted, - SmallVectorImpl<TemplateArgument> &CanonicalConverted, - bool UpdateArgsWithConversions = true, - bool *ConstraintsNotSatisfied = nullptr, bool PartialOrderingTTP = false, - bool *MatchedPackOnParmToNonPackOnArg = nullptr); + bool CheckTemplateArgumentList(TemplateDecl *Template, + SourceLocation TemplateLoc, + TemplateArgumentListInfo &TemplateArgs, + const DefaultArguments &DefaultArgs, + bool PartialTemplateArgs, + CheckTemplateArgumentInfo &CTAI, + bool UpdateArgsWithConversions = true, + bool *ConstraintsNotSatisfied = nullptr); bool CheckTemplateTypeArgument( TemplateTypeParmDecl *Param, TemplateArgumentLoc &Arg, @@ -11755,6 +11785,7 @@ public: QualType InstantiatedParamType, Expr *Arg, TemplateArgument &SugaredConverted, TemplateArgument &CanonicalConverted, + bool MatchingTTP, CheckTemplateArgumentKind CTAK); /// Check a template argument against its corresponding @@ -11776,6 +11807,9 @@ public: /// declaration and the type of its corresponding non-type template /// parameter, produce an expression that properly refers to that /// declaration. + /// FIXME: This is used in some contexts where the resulting expression + /// doesn't need to live too long. It would be useful if this function + /// could return a temporary expression. ExprResult BuildExpressionFromDeclTemplateArgument( const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc, NamedDecl *TemplateParam = nullptr); @@ -11805,17 +11839,6 @@ public: /// \endcode TPL_TemplateTemplateParmMatch, - /// We are matching the template parameter lists of a template - /// template argument against the template parameter lists of a template - /// template parameter. - /// - /// \code - /// template<template<int Value> class Metafun> struct X; - /// template<int Value> struct integer_c; - /// X<integer_c> xic; - /// \endcode - TPL_TemplateTemplateArgumentMatch, - /// We are determining whether the template-parameters are equivalent /// according to C++ [temp.over.link]/6. This comparison does not consider /// constraints. @@ -13108,14 +13131,16 @@ public: ? ExpressionEvaluationContext::ImmediateFunctionContext : ExpressionEvaluationContext::PotentiallyEvaluated); if (FD) { + auto &Current = S.currentEvaluationContext(); + const auto &Parent = S.parentEvaluationContext(); + FD->setWillHaveBody(true); - S.ExprEvalContexts.back().InImmediateFunctionContext = + Current.InImmediateFunctionContext = FD->isImmediateFunction() || - S.ExprEvalContexts[S.ExprEvalContexts.size() - 2] - .isConstantEvaluated() || - S.ExprEvalContexts[S.ExprEvalContexts.size() - 2] - .isImmediateFunctionContext(); - S.ExprEvalContexts.back().InImmediateEscalatingFunctionContext = + (isLambdaMethod(FD) && (Parent.isConstantEvaluated() || + Parent.isImmediateFunctionContext())); + + Current.InImmediateEscalatingFunctionContext = S.getLangOpts().CPlusPlus20 && FD->isImmediateEscalating(); } else assert(isa<ObjCMethodDecl>(DC)); diff --git clang/include/clang/Serialization/ASTBitCodes.h clang/include/clang/Serialization/ASTBitCodes.h index 1b56ed2c9776..7656add0b688 100644 --- clang/include/clang/Serialization/ASTBitCodes.h +++ clang/include/clang/Serialization/ASTBitCodes.h @@ -1908,6 +1908,7 @@ enum StmtCode { EXPR_PACK_EXPANSION, // PackExpansionExpr EXPR_PACK_INDEXING, // PackIndexingExpr EXPR_SIZEOF_PACK, // SizeOfPackExpr + EXPR_RESOLVED_UNEXPANDED_PACK, // ResolvedUnexpandedPackExpr EXPR_SUBST_NON_TYPE_TEMPLATE_PARM, // SubstNonTypeTemplateParmExpr EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK, // SubstNonTypeTemplateParmPackExpr EXPR_FUNCTION_PARM_PACK, // FunctionParmPackExpr diff --git clang/include/module.modulemap clang/include/module.modulemap index f00dede7fd52..b318bd95ee67 100644 --- clang/include/module.modulemap +++ clang/include/module.modulemap @@ -44,8 +44,6 @@ module Clang_Basic { textual header "clang/Basic/BuiltinsAArch64NeonSVEBridge_cg.def" textual header "clang/Basic/BuiltinsAMDGPU.def" textual header "clang/Basic/BuiltinsARM.def" - textual header "clang/Basic/BuiltinsHexagon.def" - textual header "clang/Basic/BuiltinsHexagonDep.def" textual header "clang/Basic/BuiltinsHexagonMapCustomDep.def" textual header "clang/Basic/BuiltinsLoongArch.def" textual header "clang/Basic/BuiltinsLoongArchBase.def" @@ -53,7 +51,6 @@ module Clang_Basic { textual header "clang/Basic/BuiltinsLoongArchLSX.def" textual header "clang/Basic/BuiltinsMips.def" textual header "clang/Basic/BuiltinsNEON.def" - textual header "clang/Basic/BuiltinsNVPTX.def" textual header "clang/Basic/BuiltinsPPC.def" textual header "clang/Basic/BuiltinsRISCVVector.def" textual header "clang/Basic/BuiltinsSME.def" diff --git clang/lib/ARCMigrate/ARCMT.cpp clang/lib/ARCMigrate/ARCMT.cpp deleted file mode 100644 index 1a8a200f2fc1..000000000000 --- clang/lib/ARCMigrate/ARCMT.cpp +++ /dev/null @@ -1,616 +0,0 @@ -//===--- ARCMT.cpp - Migration to ARC mode --------------------------------===// -// -// 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/ARCMigrate/ARCMT.h" -#include "Internals.h" -#include "clang/AST/ASTConsumer.h" -#include "clang/Basic/DiagnosticCategories.h" -#include "clang/Frontend/ASTUnit.h" -#include "clang/Frontend/CompilerInstance.h" -#include "clang/Frontend/FrontendAction.h" -#include "clang/Frontend/TextDiagnosticPrinter.h" -#include "clang/Frontend/Utils.h" -#include "clang/Lex/Preprocessor.h" -#include "clang/Lex/PreprocessorOptions.h" -#include "clang/Rewrite/Core/Rewriter.h" -#include "clang/Sema/SemaDiagnostic.h" -#include "clang/Serialization/ASTReader.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/TargetParser/Triple.h" -#include <utility> -using namespace clang; -using namespace arcmt; - -bool CapturedDiagList::clearDiagnostic(ArrayRef<unsigned> IDs, - SourceRange range) { - if (range.isInvalid()) - return false; - - bool cleared = false; - ListTy::iterator I = List.begin(); - while (I != List.end()) { - FullSourceLoc diagLoc = I->getLocation(); - if ((IDs.empty() || // empty means clear all diagnostics in the range. - llvm::is_contained(IDs, I->getID())) && - !diagLoc.isBeforeInTranslationUnitThan(range.getBegin()) && - (diagLoc == range.getEnd() || - diagLoc.isBeforeInTranslationUnitThan(range.getEnd()))) { - cleared = true; - ListTy::iterator eraseS = I++; - if (eraseS->getLevel() != DiagnosticsEngine::Note) - while (I != List.end() && I->getLevel() == DiagnosticsEngine::Note) - ++I; - // Clear the diagnostic and any notes following it. - I = List.erase(eraseS, I); - continue; - } - - ++I; - } - - return cleared; -} - -bool CapturedDiagList::hasDiagnostic(ArrayRef<unsigned> IDs, - SourceRange range) const { - if (range.isInvalid()) - return false; - - ListTy::const_iterator I = List.begin(); - while (I != List.end()) { - FullSourceLoc diagLoc = I->getLocation(); - if ((IDs.empty() || // empty means any diagnostic in the range. - llvm::is_contained(IDs, I->getID())) && - !diagLoc.isBeforeInTranslationUnitThan(range.getBegin()) && - (diagLoc == range.getEnd() || - diagLoc.isBeforeInTranslationUnitThan(range.getEnd()))) { - return true; - } - - ++I; - } - - return false; -} - -void CapturedDiagList::reportDiagnostics(DiagnosticsEngine &Diags) const { - for (ListTy::const_iterator I = List.begin(), E = List.end(); I != E; ++I) - Diags.Report(*I); -} - -bool CapturedDiagList::hasErrors() const { - for (ListTy::const_iterator I = List.begin(), E = List.end(); I != E; ++I) - if (I->getLevel() >= DiagnosticsEngine::Error) - return true; - - return false; -} - -namespace { - -class CaptureDiagnosticConsumer : public DiagnosticConsumer { - DiagnosticsEngine &Diags; - DiagnosticConsumer &DiagClient; - CapturedDiagList &CapturedDiags; - bool HasBegunSourceFile; -public: - CaptureDiagnosticConsumer(DiagnosticsEngine &diags, - DiagnosticConsumer &client, - CapturedDiagList &capturedDiags) - : Diags(diags), DiagClient(client), CapturedDiags(capturedDiags), - HasBegunSourceFile(false) { } - - void BeginSourceFile(const LangOptions &Opts, - const Preprocessor *PP) override { - // Pass BeginSourceFile message onto DiagClient on first call. - // The corresponding EndSourceFile call will be made from an - // explicit call to FinishCapture. - if (!HasBegunSourceFile) { - DiagClient.BeginSourceFile(Opts, PP); - HasBegunSourceFile = true; - } - } - - void FinishCapture() { - // Call EndSourceFile on DiagClient on completion of capture to - // enable VerifyDiagnosticConsumer to check diagnostics *after* - // it has received the diagnostic list. - if (HasBegunSourceFile) { - DiagClient.EndSourceFile(); - HasBegunSourceFile = false; - } - } - - ~CaptureDiagnosticConsumer() override { - assert(!HasBegunSourceFile && "FinishCapture not called!"); - } - - void HandleDiagnostic(DiagnosticsEngine::Level level, - const Diagnostic &Info) override { - if (DiagnosticIDs::isARCDiagnostic(Info.getID()) || - level >= DiagnosticsEngine::Error || level == DiagnosticsEngine::Note) { - if (Info.getLocation().isValid()) - CapturedDiags.push_back(StoredDiagnostic(level, Info)); - return; - } - - // Non-ARC warnings are ignored. - Diags.setLastDiagnosticIgnored(true); - } -}; - -} // end anonymous namespace - -static bool HasARCRuntime(CompilerInvocation &origCI) { - // This duplicates some functionality from Darwin::AddDeploymentTarget - // but this function is well defined, so keep it decoupled from the driver - // and avoid unrelated complications. - llvm::Triple triple(origCI.getTargetOpts().Triple); - - if (triple.isiOS()) - return triple.getOSMajorVersion() >= 5; - - if (triple.isWatchOS()) - return true; - - if (triple.getOS() == llvm::Triple::Darwin) - return triple.getOSMajorVersion() >= 11; - - if (triple.getOS() == llvm::Triple::MacOSX) { - return triple.getOSVersion() >= VersionTuple(10, 7); - } - - return false; -} - -static CompilerInvocation * -createInvocationForMigration(CompilerInvocation &origCI, - const PCHContainerReader &PCHContainerRdr) { - std::unique_ptr<CompilerInvocation> CInvok; - CInvok.reset(new CompilerInvocation(origCI)); - PreprocessorOptions &PPOpts = CInvok->getPreprocessorOpts(); - if (!PPOpts.ImplicitPCHInclude.empty()) { - // We can't use a PCH because it was likely built in non-ARC mode and we - // want to parse in ARC. Include the original header. - FileManager FileMgr(origCI.getFileSystemOpts()); - IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs()); - IntrusiveRefCntPtr<DiagnosticsEngine> Diags( - new DiagnosticsEngine(DiagID, &origCI.getDiagnosticOpts(), - new IgnoringDiagConsumer())); - std::string OriginalFile = ASTReader::getOriginalSourceFile( - PPOpts.ImplicitPCHInclude, FileMgr, PCHContainerRdr, *Diags); - if (!OriginalFile.empty()) - PPOpts.Includes.insert(PPOpts.Includes.begin(), OriginalFile); - PPOpts.ImplicitPCHInclude.clear(); - } - std::string define = std::string(getARCMTMacroName()); - define += '='; - CInvok->getPreprocessorOpts().addMacroDef(define); - CInvok->getLangOpts().ObjCAutoRefCount = true; - CInvok->getLangOpts().setGC(LangOptions::NonGC); - CInvok->getDiagnosticOpts().ErrorLimit = 0; - CInvok->getDiagnosticOpts().PedanticErrors = 0; - - // Ignore -Werror flags when migrating. - std::vector<std::string> WarnOpts; - for (std::vector<std::string>::iterator - I = CInvok->getDiagnosticOpts().Warnings.begin(), - E = CInvok->getDiagnosticOpts().Warnings.end(); I != E; ++I) { - if (!StringRef(*I).starts_with("error")) - WarnOpts.push_back(*I); - } - WarnOpts.push_back("error=arc-unsafe-retained-assign"); - CInvok->getDiagnosticOpts().Warnings = std::move(WarnOpts); - - CInvok->getLangOpts().ObjCWeakRuntime = HasARCRuntime(origCI); - CInvok->getLangOpts().ObjCWeak = CInvok->getLangOpts().ObjCWeakRuntime; - - return CInvok.release(); -} - -static void emitPremigrationErrors(const CapturedDiagList &arcDiags, - DiagnosticOptions *diagOpts, - Preprocessor &PP) { - TextDiagnosticPrinter printer(llvm::errs(), diagOpts); - IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs()); - IntrusiveRefCntPtr<DiagnosticsEngine> Diags( - new DiagnosticsEngine(DiagID, diagOpts, &printer, - /*ShouldOwnClient=*/false)); - Diags->setSourceManager(&PP.getSourceManager()); - - printer.BeginSourceFile(PP.getLangOpts(), &PP); - arcDiags.reportDiagnostics(*Diags); - printer.EndSourceFile(); -} - -//===----------------------------------------------------------------------===// -// checkForManualIssues. -//===----------------------------------------------------------------------===// - -bool arcmt::checkForManualIssues( - CompilerInvocation &origCI, const FrontendInputFile &Input, - std::shared_ptr<PCHContainerOperations> PCHContainerOps, - DiagnosticConsumer *DiagClient, bool emitPremigrationARCErrors, - StringRef plistOut) { - if (!origCI.getLangOpts().ObjC) - return false; - - LangOptions::GCMode OrigGCMode = origCI.getLangOpts().getGC(); - bool NoNSAllocReallocError = origCI.getMigratorOpts().NoNSAllocReallocError; - bool NoFinalizeRemoval = origCI.getMigratorOpts().NoFinalizeRemoval; - - std::vector<TransformFn> transforms = arcmt::getAllTransformations(OrigGCMode, - NoFinalizeRemoval); - assert(!transforms.empty()); - - std::unique_ptr<CompilerInvocation> CInvok; - CInvok.reset( - createInvocationForMigration(origCI, PCHContainerOps->getRawReader())); - CInvok->getFrontendOpts().Inputs.clear(); - CInvok->getFrontendOpts().Inputs.push_back(Input); - - CapturedDiagList capturedDiags; - - assert(DiagClient); - IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs()); - IntrusiveRefCntPtr<DiagnosticsEngine> Diags( - new DiagnosticsEngine(DiagID, &origCI.getDiagnosticOpts(), - DiagClient, /*ShouldOwnClient=*/false)); - - // Filter of all diagnostics. - CaptureDiagnosticConsumer errRec(*Diags, *DiagClient, capturedDiags); - Diags->setClient(&errRec, /*ShouldOwnClient=*/false); - - std::unique_ptr<ASTUnit> Unit(ASTUnit::LoadFromCompilerInvocationAction( - std::move(CInvok), PCHContainerOps, Diags)); - if (!Unit) { - errRec.FinishCapture(); - return true; - } - - // Don't filter diagnostics anymore. - Diags->setClient(DiagClient, /*ShouldOwnClient=*/false); - - ASTContext &Ctx = Unit->getASTContext(); - - if (Diags->hasFatalErrorOccurred()) { - Diags->Reset(); - DiagClient->BeginSourceFile(Ctx.getLangOpts(), &Unit->getPreprocessor()); - capturedDiags.reportDiagnostics(*Diags); - DiagClient->EndSourceFile(); - errRec.FinishCapture(); - return true; - } - - if (emitPremigrationARCErrors) - emitPremigrationErrors(capturedDiags, &origCI.getDiagnosticOpts(), - Unit->getPreprocessor()); - if (!plistOut.empty()) { - SmallVector<StoredDiagnostic, 8> arcDiags; - for (CapturedDiagList::iterator - I = capturedDiags.begin(), E = capturedDiags.end(); I != E; ++I) - arcDiags.push_back(*I); - writeARCDiagsToPlist(std::string(plistOut), arcDiags, - Ctx.getSourceManager(), Ctx.getLangOpts()); - } - - // After parsing of source files ended, we want to reuse the - // diagnostics objects to emit further diagnostics. - // We call BeginSourceFile because DiagnosticConsumer requires that - // diagnostics with source range information are emitted only in between - // BeginSourceFile() and EndSourceFile(). - DiagClient->BeginSourceFile(Ctx.getLangOpts(), &Unit->getPreprocessor()); - - // No macros will be added since we are just checking and we won't modify - // source code. - std::vector<SourceLocation> ARCMTMacroLocs; - - TransformActions testAct(*Diags, capturedDiags, Ctx, Unit->getPreprocessor()); - MigrationPass pass(Ctx, OrigGCMode, Unit->getSema(), testAct, capturedDiags, - ARCMTMacroLocs); - pass.setNoFinalizeRemoval(NoFinalizeRemoval); - if (!NoNSAllocReallocError) - Diags->setSeverity(diag::warn_arcmt_nsalloc_realloc, diag::Severity::Error, - SourceLocation()); - - for (unsigned i=0, e = transforms.size(); i != e; ++i) - transforms[i](pass); - - capturedDiags.reportDiagnostics(*Diags); - - DiagClient->EndSourceFile(); - errRec.FinishCapture(); - - return capturedDiags.hasErrors() || testAct.hasReportedErrors(); -} - -//===----------------------------------------------------------------------===// -// applyTransformations. -//===----------------------------------------------------------------------===// - -static bool -applyTransforms(CompilerInvocation &origCI, const FrontendInputFile &Input, - std::shared_ptr<PCHContainerOperations> PCHContainerOps, - DiagnosticConsumer *DiagClient, StringRef outputDir, - bool emitPremigrationARCErrors, StringRef plistOut) { - if (!origCI.getLangOpts().ObjC) - return false; - - LangOptions::GCMode OrigGCMode = origCI.getLangOpts().getGC(); - - // Make sure checking is successful first. - CompilerInvocation CInvokForCheck(origCI); - if (arcmt::checkForManualIssues(CInvokForCheck, Input, PCHContainerOps, - DiagClient, emitPremigrationARCErrors, - plistOut)) - return true; - - CompilerInvocation CInvok(origCI); - CInvok.getFrontendOpts().Inputs.clear(); - CInvok.getFrontendOpts().Inputs.push_back(Input); - - MigrationProcess migration(CInvok, PCHContainerOps, DiagClient, outputDir); - bool NoFinalizeRemoval = origCI.getMigratorOpts().NoFinalizeRemoval; - - std::vector<TransformFn> transforms = arcmt::getAllTransformations(OrigGCMode, - NoFinalizeRemoval); - assert(!transforms.empty()); - - for (unsigned i=0, e = transforms.size(); i != e; ++i) { - bool err = migration.applyTransform(transforms[i]); - if (err) return true; - } - - IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs()); - IntrusiveRefCntPtr<DiagnosticsEngine> Diags( - new DiagnosticsEngine(DiagID, &origCI.getDiagnosticOpts(), - DiagClient, /*ShouldOwnClient=*/false)); - - if (outputDir.empty()) { - origCI.getLangOpts().ObjCAutoRefCount = true; - return migration.getRemapper().overwriteOriginal(*Diags); - } else { - return migration.getRemapper().flushToDisk(outputDir, *Diags); - } -} - -bool arcmt::applyTransformations( - CompilerInvocation &origCI, const FrontendInputFile &Input, - std::shared_ptr<PCHContainerOperations> PCHContainerOps, - DiagnosticConsumer *DiagClient) { - return applyTransforms(origCI, Input, PCHContainerOps, DiagClient, - StringRef(), false, StringRef()); -} - -bool arcmt::migrateWithTemporaryFiles( - CompilerInvocation &origCI, const FrontendInputFile &Input, - std::shared_ptr<PCHContainerOperations> PCHContainerOps, - DiagnosticConsumer *DiagClient, StringRef outputDir, - bool emitPremigrationARCErrors, StringRef plistOut) { - assert(!outputDir.empty() && "Expected output directory path"); - return applyTransforms(origCI, Input, PCHContainerOps, DiagClient, outputDir, - emitPremigrationARCErrors, plistOut); -} - -bool arcmt::getFileRemappings(std::vector<std::pair<std::string,std::string> > & - remap, - StringRef outputDir, - DiagnosticConsumer *DiagClient) { - assert(!outputDir.empty()); - - IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs()); - IntrusiveRefCntPtr<DiagnosticsEngine> Diags( - new DiagnosticsEngine(DiagID, new DiagnosticOptions, - DiagClient, /*ShouldOwnClient=*/false)); - - FileRemapper remapper; - bool err = remapper.initFromDisk(outputDir, *Diags, - /*ignoreIfFilesChanged=*/true); - if (err) - return true; - - remapper.forEachMapping( - [&](StringRef From, StringRef To) { - remap.push_back(std::make_pair(From.str(), To.str())); - }, - [](StringRef, const llvm::MemoryBufferRef &) {}); - - return false; -} - - -//===----------------------------------------------------------------------===// -// CollectTransformActions. -//===----------------------------------------------------------------------===// - -namespace { - -class ARCMTMacroTrackerPPCallbacks : public PPCallbacks { - std::vector<SourceLocation> &ARCMTMacroLocs; - -public: - ARCMTMacroTrackerPPCallbacks(std::vector<SourceLocation> &ARCMTMacroLocs) - : ARCMTMacroLocs(ARCMTMacroLocs) { } - - void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD, - SourceRange Range, const MacroArgs *Args) override { - if (MacroNameTok.getIdentifierInfo()->getName() == getARCMTMacroName()) - ARCMTMacroLocs.push_back(MacroNameTok.getLocation()); - } -}; - -class ARCMTMacroTrackerAction : public ASTFrontendAction { - std::vector<SourceLocation> &ARCMTMacroLocs; - -public: - ARCMTMacroTrackerAction(std::vector<SourceLocation> &ARCMTMacroLocs) - : ARCMTMacroLocs(ARCMTMacroLocs) { } - - std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, - StringRef InFile) override { - CI.getPreprocessor().addPPCallbacks( - std::make_unique<ARCMTMacroTrackerPPCallbacks>(ARCMTMacroLocs)); - return std::make_unique<ASTConsumer>(); - } -}; - -class RewritesApplicator : public TransformActions::RewriteReceiver { - Rewriter &rewriter; - MigrationProcess::RewriteListener *Listener; - -public: - RewritesApplicator(Rewriter &rewriter, ASTContext &ctx, - MigrationProcess::RewriteListener *listener) - : rewriter(rewriter), Listener(listener) { - if (Listener) - Listener->start(ctx); - } - ~RewritesApplicator() override { - if (Listener) - Listener->finish(); - } - - void insert(SourceLocation loc, StringRef text) override { - bool err = rewriter.InsertText(loc, text, /*InsertAfter=*/true, - /*indentNewLines=*/true); - if (!err && Listener) - Listener->insert(loc, text); - } - - void remove(CharSourceRange range) override { - Rewriter::RewriteOptions removeOpts; - removeOpts.IncludeInsertsAtBeginOfRange = false; - removeOpts.IncludeInsertsAtEndOfRange = false; - removeOpts.RemoveLineIfEmpty = true; - - bool err = rewriter.RemoveText(range, removeOpts); - if (!err && Listener) - Listener->remove(range); - } - - void increaseIndentation(CharSourceRange range, - SourceLocation parentIndent) override { - rewriter.IncreaseIndentation(range, parentIndent); - } -}; - -} // end anonymous namespace. - -/// Anchor for VTable. -MigrationProcess::RewriteListener::~RewriteListener() { } - -MigrationProcess::MigrationProcess( - CompilerInvocation &CI, - std::shared_ptr<PCHContainerOperations> PCHContainerOps, - DiagnosticConsumer *diagClient, StringRef outputDir) - : OrigCI(CI), PCHContainerOps(std::move(PCHContainerOps)), - DiagClient(diagClient), HadARCErrors(false) { - if (!outputDir.empty()) { - IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs()); - IntrusiveRefCntPtr<DiagnosticsEngine> Diags( - new DiagnosticsEngine(DiagID, &CI.getDiagnosticOpts(), - DiagClient, /*ShouldOwnClient=*/false)); - Remapper.initFromDisk(outputDir, *Diags, /*ignoreIfFilesChanged=*/true); - } -} - -bool MigrationProcess::applyTransform(TransformFn trans, - RewriteListener *listener) { - std::unique_ptr<CompilerInvocation> CInvok; - CInvok.reset( - createInvocationForMigration(OrigCI, PCHContainerOps->getRawReader())); - CInvok->getDiagnosticOpts().IgnoreWarnings = true; - - Remapper.applyMappings(CInvok->getPreprocessorOpts()); - - CapturedDiagList capturedDiags; - std::vector<SourceLocation> ARCMTMacroLocs; - - assert(DiagClient); - IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs()); - IntrusiveRefCntPtr<DiagnosticsEngine> Diags( - new DiagnosticsEngine(DiagID, new DiagnosticOptions, - DiagClient, /*ShouldOwnClient=*/false)); - - // Filter of all diagnostics. - CaptureDiagnosticConsumer errRec(*Diags, *DiagClient, capturedDiags); - Diags->setClient(&errRec, /*ShouldOwnClient=*/false); - - std::unique_ptr<ARCMTMacroTrackerAction> ASTAction; - ASTAction.reset(new ARCMTMacroTrackerAction(ARCMTMacroLocs)); - - std::unique_ptr<ASTUnit> Unit(ASTUnit::LoadFromCompilerInvocationAction( - std::move(CInvok), PCHContainerOps, Diags, ASTAction.get())); - if (!Unit) { - errRec.FinishCapture(); - return true; - } - Unit->setOwnsRemappedFileBuffers(false); // FileRemapper manages that. - - HadARCErrors = HadARCErrors || capturedDiags.hasErrors(); - - // Don't filter diagnostics anymore. - Diags->setClient(DiagClient, /*ShouldOwnClient=*/false); - - ASTContext &Ctx = Unit->getASTContext(); - - if (Diags->hasFatalErrorOccurred()) { - Diags->Reset(); - DiagClient->BeginSourceFile(Ctx.getLangOpts(), &Unit->getPreprocessor()); - capturedDiags.reportDiagnostics(*Diags); - DiagClient->EndSourceFile(); - errRec.FinishCapture(); - return true; - } - - // After parsing of source files ended, we want to reuse the - // diagnostics objects to emit further diagnostics. - // We call BeginSourceFile because DiagnosticConsumer requires that - // diagnostics with source range information are emitted only in between - // BeginSourceFile() and EndSourceFile(). - DiagClient->BeginSourceFile(Ctx.getLangOpts(), &Unit->getPreprocessor()); - - Rewriter rewriter(Ctx.getSourceManager(), Ctx.getLangOpts()); - TransformActions TA(*Diags, capturedDiags, Ctx, Unit->getPreprocessor()); - MigrationPass pass(Ctx, OrigCI.getLangOpts().getGC(), - Unit->getSema(), TA, capturedDiags, ARCMTMacroLocs); - - trans(pass); - - { - RewritesApplicator applicator(rewriter, Ctx, listener); - TA.applyRewrites(applicator); - } - - DiagClient->EndSourceFile(); - errRec.FinishCapture(); - - if (DiagClient->getNumErrors()) - return true; - - for (Rewriter::buffer_iterator - I = rewriter.buffer_begin(), E = rewriter.buffer_end(); I != E; ++I) { - FileID FID = I->first; - llvm::RewriteBuffer &buf = I->second; - OptionalFileEntryRef file = - Ctx.getSourceManager().getFileEntryRefForID(FID); - assert(file); - std::string newFname = std::string(file->getName()); - newFname += "-trans"; - SmallString<512> newText; - llvm::raw_svector_ostream vecOS(newText); - buf.write(vecOS); - std::unique_ptr<llvm::MemoryBuffer> memBuf( - llvm::MemoryBuffer::getMemBufferCopy(newText.str(), newFname)); - SmallString<64> filePath(file->getName()); - Unit->getFileManager().FixupRelativePath(filePath); - Remapper.remap(filePath.str(), std::move(memBuf)); - } - - return false; -} diff --git clang/lib/ARCMigrate/ARCMTActions.cpp clang/lib/ARCMigrate/ARCMTActions.cpp deleted file mode 100644 index 0805d90d25aa..000000000000 --- clang/lib/ARCMigrate/ARCMTActions.cpp +++ /dev/null @@ -1,59 +0,0 @@ -//===--- ARCMTActions.cpp - ARC Migrate Tool Frontend Actions ---*- 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/ARCMigrate/ARCMTActions.h" -#include "clang/ARCMigrate/ARCMT.h" -#include "clang/Frontend/CompilerInstance.h" - -using namespace clang; -using namespace arcmt; - -bool CheckAction::BeginInvocation(CompilerInstance &CI) { - if (arcmt::checkForManualIssues(CI.getInvocation(), getCurrentInput(), - CI.getPCHContainerOperations(), - CI.getDiagnostics().getClient())) - return false; // errors, stop the action. - - // We only want to see warnings reported from arcmt::checkForManualIssues. - CI.getDiagnostics().setIgnoreAllWarnings(true); - return true; -} - -CheckAction::CheckAction(std::unique_ptr<FrontendAction> WrappedAction) - : WrapperFrontendAction(std::move(WrappedAction)) {} - -bool ModifyAction::BeginInvocation(CompilerInstance &CI) { - return !arcmt::applyTransformations(CI.getInvocation(), getCurrentInput(), - CI.getPCHContainerOperations(), - CI.getDiagnostics().getClient()); -} - -ModifyAction::ModifyAction(std::unique_ptr<FrontendAction> WrappedAction) - : WrapperFrontendAction(std::move(WrappedAction)) {} - -bool MigrateAction::BeginInvocation(CompilerInstance &CI) { - if (arcmt::migrateWithTemporaryFiles( - CI.getInvocation(), getCurrentInput(), CI.getPCHContainerOperations(), - CI.getDiagnostics().getClient(), MigrateDir, EmitPremigrationARCErrors, - PlistOut)) - return false; // errors, stop the action. - - // We only want to see diagnostics emitted by migrateWithTemporaryFiles. - CI.getDiagnostics().setIgnoreAllWarnings(true); - return true; -} - -MigrateAction::MigrateAction(std::unique_ptr<FrontendAction> WrappedAction, - StringRef migrateDir, - StringRef plistOut, - bool emitPremigrationARCErrors) - : WrapperFrontendAction(std::move(WrappedAction)), MigrateDir(migrateDir), - PlistOut(plistOut), EmitPremigrationARCErrors(emitPremigrationARCErrors) { - if (MigrateDir.empty()) - MigrateDir = "."; // user current directory if none is given. -} diff --git clang/lib/ARCMigrate/CMakeLists.txt clang/lib/ARCMigrate/CMakeLists.txt deleted file mode 100644 index 515d0960920a..000000000000 --- clang/lib/ARCMigrate/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -set(LLVM_LINK_COMPONENTS - Support - TargetParser - ) - -# By default MSVC has a 2^16 limit on the number of sections in an object -# file, and Transforms.cpp needs more than that. -if (MSVC) - set_source_files_properties(Transforms.cpp PROPERTIES COMPILE_FLAGS /bigobj) -endif() - -add_clang_library(clangARCMigrate - ARCMT.cpp - ARCMTActions.cpp - FileRemapper.cpp - ObjCMT.cpp - PlistReporter.cpp - TransAPIUses.cpp - TransARCAssign.cpp - TransAutoreleasePool.cpp - TransBlockObjCVariable.cpp - TransEmptyStatementsAndDealloc.cpp - TransGCAttrs.cpp - TransGCCalls.cpp - TransProperties.cpp - TransProtectedScope.cpp - TransRetainReleaseDealloc.cpp - TransUnbridgedCasts.cpp - TransUnusedInitDelegate.cpp - TransZeroOutPropsInDealloc.cpp - TransformActions.cpp - Transforms.cpp - - LINK_LIBS - clangAST - clangAnalysis - clangBasic - clangEdit - clangFrontend - clangLex - clangRewrite - clangSema - clangSerialization - - DEPENDS - omp_gen - ClangDriverOptions - ) diff --git clang/lib/ARCMigrate/FileRemapper.cpp clang/lib/ARCMigrate/FileRemapper.cpp deleted file mode 100644 index 84024c3bafdc..000000000000 --- clang/lib/ARCMigrate/FileRemapper.cpp +++ /dev/null @@ -1,274 +0,0 @@ -//===--- FileRemapper.cpp - File Remapping Helper -------------------------===// -// -// 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/ARCMigrate/FileRemapper.h" -#include "clang/Basic/Diagnostic.h" -#include "clang/Basic/FileManager.h" -#include "clang/Lex/PreprocessorOptions.h" -#include "llvm/Support/FileSystem.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/Path.h" -#include "llvm/Support/raw_ostream.h" -#include <fstream> - -using namespace clang; -using namespace arcmt; - -FileRemapper::FileRemapper() { - FileMgr.reset(new FileManager(FileSystemOptions())); -} - -FileRemapper::~FileRemapper() { - clear(); -} - -void FileRemapper::clear(StringRef outputDir) { - for (MappingsTy::iterator - I = FromToMappings.begin(), E = FromToMappings.end(); I != E; ++I) - resetTarget(I->second); - FromToMappings.clear(); - assert(ToFromMappings.empty()); - if (!outputDir.empty()) { - std::string infoFile = getRemapInfoFile(outputDir); - llvm::sys::fs::remove(infoFile); - } -} - -std::string FileRemapper::getRemapInfoFile(StringRef outputDir) { - assert(!outputDir.empty()); - SmallString<128> InfoFile = outputDir; - llvm::sys::path::append(InfoFile, "remap"); - return std::string(InfoFile); -} - -bool FileRemapper::initFromDisk(StringRef outputDir, DiagnosticsEngine &Diag, - bool ignoreIfFilesChanged) { - std::string infoFile = getRemapInfoFile(outputDir); - return initFromFile(infoFile, Diag, ignoreIfFilesChanged); -} - -bool FileRemapper::initFromFile(StringRef filePath, DiagnosticsEngine &Diag, - bool ignoreIfFilesChanged) { - assert(FromToMappings.empty() && - "initFromDisk should be called before any remap calls"); - std::string infoFile = std::string(filePath); - if (!llvm::sys::fs::exists(infoFile)) - return false; - - std::vector<std::pair<FileEntryRef, FileEntryRef>> pairs; - - llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> fileBuf = - llvm::MemoryBuffer::getFile(infoFile, /*IsText=*/true); - if (!fileBuf) - return report("Error opening file: " + infoFile, Diag); - - SmallVector<StringRef, 64> lines; - fileBuf.get()->getBuffer().split(lines, "\n"); - - for (unsigned idx = 0; idx+3 <= lines.size(); idx += 3) { - StringRef fromFilename = lines[idx]; - unsigned long long timeModified; - if (lines[idx+1].getAsInteger(10, timeModified)) - return report("Invalid file data: '" + lines[idx+1] + "' not a number", - Diag); - StringRef toFilename = lines[idx+2]; - - auto origFE = FileMgr->getOptionalFileRef(fromFilename); - if (!origFE) { - if (ignoreIfFilesChanged) - continue; - return report("File does not exist: " + fromFilename, Diag); - } - auto newFE = FileMgr->getOptionalFileRef(toFilename); - if (!newFE) { - if (ignoreIfFilesChanged) - continue; - return report("File does not exist: " + toFilename, Diag); - } - - if ((uint64_t)origFE->getModificationTime() != timeModified) { - if (ignoreIfFilesChanged) - continue; - return report("File was modified: " + fromFilename, Diag); - } - - pairs.push_back(std::make_pair(*origFE, *newFE)); - } - - for (unsigned i = 0, e = pairs.size(); i != e; ++i) - remap(pairs[i].first, pairs[i].second); - - return false; -} - -bool FileRemapper::flushToDisk(StringRef outputDir, DiagnosticsEngine &Diag) { - using namespace llvm::sys; - - if (fs::create_directory(outputDir)) - return report("Could not create directory: " + outputDir, Diag); - - std::string infoFile = getRemapInfoFile(outputDir); - return flushToFile(infoFile, Diag); -} - -bool FileRemapper::flushToFile(StringRef outputPath, DiagnosticsEngine &Diag) { - using namespace llvm::sys; - - std::error_code EC; - std::string infoFile = std::string(outputPath); - llvm::raw_fd_ostream infoOut(infoFile, EC, llvm::sys::fs::OF_Text); - if (EC) - return report(EC.message(), Diag); - - for (MappingsTy::iterator - I = FromToMappings.begin(), E = FromToMappings.end(); I != E; ++I) { - - FileEntryRef origFE = I->first; - SmallString<200> origPath = StringRef(origFE.getName()); - fs::make_absolute(origPath); - infoOut << origPath << '\n'; - infoOut << (uint64_t)origFE.getModificationTime() << '\n'; - - if (const auto *FE = std::get_if<FileEntryRef>(&I->second)) { - SmallString<200> newPath = StringRef(FE->getName()); - fs::make_absolute(newPath); - infoOut << newPath << '\n'; - } else { - - SmallString<64> tempPath; - int fd; - if (fs::createTemporaryFile( - path::filename(origFE.getName()), - path::extension(origFE.getName()).drop_front(), fd, tempPath, - llvm::sys::fs::OF_Text)) - return report("Could not create file: " + tempPath.str(), Diag); - - llvm::raw_fd_ostream newOut(fd, /*shouldClose=*/true); - llvm::MemoryBuffer *mem = std::get<llvm::MemoryBuffer *>(I->second); - newOut.write(mem->getBufferStart(), mem->getBufferSize()); - newOut.close(); - - auto newE = FileMgr->getOptionalFileRef(tempPath); - if (newE) { - remap(origFE, *newE); - infoOut << newE->getName() << '\n'; - } - } - } - - infoOut.close(); - return false; -} - -bool FileRemapper::overwriteOriginal(DiagnosticsEngine &Diag, - StringRef outputDir) { - using namespace llvm::sys; - - for (MappingsTy::iterator - I = FromToMappings.begin(), E = FromToMappings.end(); I != E; ++I) { - FileEntryRef origFE = I->first; - assert(std::holds_alternative<llvm::MemoryBuffer *>(I->second)); - if (!fs::exists(origFE.getName())) - return report(StringRef("File does not exist: ") + origFE.getName(), - Diag); - - std::error_code EC; - llvm::raw_fd_ostream Out(origFE.getName(), EC, llvm::sys::fs::OF_None); - if (EC) - return report(EC.message(), Diag); - - llvm::MemoryBuffer *mem = std::get<llvm::MemoryBuffer *>(I->second); - Out.write(mem->getBufferStart(), mem->getBufferSize()); - Out.close(); - } - - clear(outputDir); - return false; -} - -void FileRemapper::forEachMapping( - llvm::function_ref<void(StringRef, StringRef)> CaptureFile, - llvm::function_ref<void(StringRef, const llvm::MemoryBufferRef &)> - CaptureBuffer) const { - for (auto &Mapping : FromToMappings) { - if (const auto *FE = std::get_if<FileEntryRef>(&Mapping.second)) { - CaptureFile(Mapping.first.getName(), FE->getName()); - continue; - } - CaptureBuffer( - Mapping.first.getName(), - std::get<llvm::MemoryBuffer *>(Mapping.second)->getMemBufferRef()); - } -} - -void FileRemapper::applyMappings(PreprocessorOptions &PPOpts) const { - for (MappingsTy::const_iterator - I = FromToMappings.begin(), E = FromToMappings.end(); I != E; ++I) { - if (const auto *FE = std::get_if<FileEntryRef>(&I->second)) { - PPOpts.addRemappedFile(I->first.getName(), FE->getName()); - } else { - llvm::MemoryBuffer *mem = std::get<llvm::MemoryBuffer *>(I->second); - PPOpts.addRemappedFile(I->first.getName(), mem); - } - } - - PPOpts.RetainRemappedFileBuffers = true; -} - -void FileRemapper::remap(StringRef filePath, - std::unique_ptr<llvm::MemoryBuffer> memBuf) { - OptionalFileEntryRef File = getOriginalFile(filePath); - assert(File); - remap(*File, std::move(memBuf)); -} - -void FileRemapper::remap(FileEntryRef File, - std::unique_ptr<llvm::MemoryBuffer> MemBuf) { - auto [It, New] = FromToMappings.insert({File, nullptr}); - if (!New) - resetTarget(It->second); - It->second = MemBuf.release(); -} - -void FileRemapper::remap(FileEntryRef File, FileEntryRef NewFile) { - auto [It, New] = FromToMappings.insert({File, nullptr}); - if (!New) - resetTarget(It->second); - It->second = NewFile; - ToFromMappings.insert({NewFile, File}); -} - -OptionalFileEntryRef FileRemapper::getOriginalFile(StringRef filePath) { - OptionalFileEntryRef File = FileMgr->getOptionalFileRef(filePath); - if (!File) - return std::nullopt; - // If we are updating a file that overridden an original file, - // actually update the original file. - auto I = ToFromMappings.find(*File); - if (I != ToFromMappings.end()) { - *File = I->second; - assert(FromToMappings.contains(*File) && "Original file not in mappings!"); - } - return File; -} - -void FileRemapper::resetTarget(Target &targ) { - if (std::holds_alternative<llvm::MemoryBuffer *>(targ)) { - llvm::MemoryBuffer *oldmem = std::get<llvm::MemoryBuffer *>(targ); - delete oldmem; - } else { - FileEntryRef toFE = std::get<FileEntryRef>(targ); - ToFromMappings.erase(toFE); - } -} - -bool FileRemapper::report(const Twine &err, DiagnosticsEngine &Diag) { - Diag.Report(Diag.getCustomDiagID(DiagnosticsEngine::Error, "%0")) - << err.str(); - return true; -} diff --git clang/lib/ARCMigrate/Internals.h clang/lib/ARCMigrate/Internals.h deleted file mode 100644 index de6ebdce1bea..000000000000 --- clang/lib/ARCMigrate/Internals.h +++ /dev/null @@ -1,180 +0,0 @@ -//===-- Internals.h - Implementation Details---------------------*- 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 LLVM_CLANG_LIB_ARCMIGRATE_INTERNALS_H -#define LLVM_CLANG_LIB_ARCMIGRATE_INTERNALS_H - -#include "clang/Basic/LangOptions.h" -#include "clang/Basic/Diagnostic.h" -#include "clang/Frontend/MigratorOptions.h" -#include "llvm/ADT/ArrayRef.h" -#include <list> -#include <optional> - -namespace clang { - class ASTContext; - class Sema; - class Stmt; - -namespace arcmt { - -class CapturedDiagList { - typedef std::list<StoredDiagnostic> ListTy; - ListTy List; - -public: - void push_back(const StoredDiagnostic &diag) { List.push_back(diag); } - - bool clearDiagnostic(ArrayRef<unsigned> IDs, SourceRange range); - bool hasDiagnostic(ArrayRef<unsigned> IDs, SourceRange range) const; - - void reportDiagnostics(DiagnosticsEngine &diags) const; - - bool hasErrors() const; - - typedef ListTy::const_iterator iterator; - iterator begin() const { return List.begin(); } - iterator end() const { return List.end(); } -}; - -void writeARCDiagsToPlist(const std::string &outPath, - ArrayRef<StoredDiagnostic> diags, - SourceManager &SM, const LangOptions &LangOpts); - -class TransformActions { - DiagnosticsEngine &Diags; - CapturedDiagList &CapturedDiags; - void *Impl; // TransformActionsImpl. - -public: - TransformActions(DiagnosticsEngine &diag, CapturedDiagList &capturedDiags, - ASTContext &ctx, Preprocessor &PP); - ~TransformActions(); - - void startTransaction(); - bool commitTransaction(); - void abortTransaction(); - - void insert(SourceLocation loc, StringRef text); - void insertAfterToken(SourceLocation loc, StringRef text); - void remove(SourceRange range); - void removeStmt(Stmt *S); - void replace(SourceRange range, StringRef text); - void replace(SourceRange range, SourceRange replacementRange); - void replaceStmt(Stmt *S, StringRef text); - void replaceText(SourceLocation loc, StringRef text, - StringRef replacementText); - void increaseIndentation(SourceRange range, - SourceLocation parentIndent); - - bool clearDiagnostic(ArrayRef<unsigned> IDs, SourceRange range); - bool clearAllDiagnostics(SourceRange range) { - return clearDiagnostic({}, range); - } - bool clearDiagnostic(unsigned ID1, unsigned ID2, SourceRange range) { - unsigned IDs[] = { ID1, ID2 }; - return clearDiagnostic(IDs, range); - } - bool clearDiagnostic(unsigned ID1, unsigned ID2, unsigned ID3, - SourceRange range) { - unsigned IDs[] = { ID1, ID2, ID3 }; - return clearDiagnostic(IDs, range); - } - - bool hasDiagnostic(unsigned ID, SourceRange range) { - return CapturedDiags.hasDiagnostic(ID, range); - } - - bool hasDiagnostic(unsigned ID1, unsigned ID2, SourceRange range) { - unsigned IDs[] = { ID1, ID2 }; - return CapturedDiags.hasDiagnostic(IDs, range); - } - - DiagnosticBuilder report(SourceLocation loc, unsigned diagId, - SourceRange range = SourceRange()); - void reportError(StringRef error, SourceLocation loc, - SourceRange range = SourceRange()); - void reportWarning(StringRef warning, SourceLocation loc, - SourceRange range = SourceRange()); - void reportNote(StringRef note, SourceLocation loc, - SourceRange range = SourceRange()); - - bool hasReportedErrors() const { - return Diags.hasUnrecoverableErrorOccurred(); - } - - class RewriteReceiver { - public: - virtual ~RewriteReceiver(); - - virtual void insert(SourceLocation loc, StringRef text) = 0; - virtual void remove(CharSourceRange range) = 0; - virtual void increaseIndentation(CharSourceRange range, - SourceLocation parentIndent) = 0; - }; - - void applyRewrites(RewriteReceiver &receiver); -}; - -class Transaction { - TransformActions &TA; - bool Aborted; - -public: - Transaction(TransformActions &TA) : TA(TA), Aborted(false) { - TA.startTransaction(); - } - - ~Transaction() { - if (!isAborted()) - TA.commitTransaction(); - } - - void abort() { - TA.abortTransaction(); - Aborted = true; - } - - bool isAborted() const { return Aborted; } -}; - -class MigrationPass { -public: - ASTContext &Ctx; - LangOptions::GCMode OrigGCMode; - MigratorOptions MigOptions; - Sema &SemaRef; - TransformActions &TA; - const CapturedDiagList &CapturedDiags; - std::vector<SourceLocation> &ARCMTMacroLocs; - std::optional<bool> EnableCFBridgeFns; - - MigrationPass(ASTContext &Ctx, LangOptions::GCMode OrigGCMode, Sema &sema, - TransformActions &TA, const CapturedDiagList &capturedDiags, - std::vector<SourceLocation> &ARCMTMacroLocs) - : Ctx(Ctx), OrigGCMode(OrigGCMode), SemaRef(sema), TA(TA), - CapturedDiags(capturedDiags), ARCMTMacroLocs(ARCMTMacroLocs) {} - - const CapturedDiagList &getDiags() const { return CapturedDiags; } - - bool isGCMigration() const { return OrigGCMode != LangOptions::NonGC; } - bool noFinalizeRemoval() const { return MigOptions.NoFinalizeRemoval; } - void setNoFinalizeRemoval(bool val) {MigOptions.NoFinalizeRemoval = val; } - - bool CFBridgingFunctionsDefined(); -}; - -static inline StringRef getARCMTMacroName() { - return "__IMPL_ARCMT_REMOVED_EXPR__"; -} - -} // end namespace arcmt - -} // end namespace clang - -#endif diff --git clang/lib/ARCMigrate/ObjCMT.cpp clang/lib/ARCMigrate/ObjCMT.cpp deleted file mode 100644 index c1bc7c762088..000000000000 --- clang/lib/ARCMigrate/ObjCMT.cpp +++ /dev/null @@ -1,2262 +0,0 @@ -//===--- ObjCMT.cpp - ObjC Migrate 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 "Transforms.h" -#include "clang/Analysis/RetainSummaryManager.h" -#include "clang/ARCMigrate/ARCMT.h" -#include "clang/ARCMigrate/ARCMTActions.h" -#include "clang/AST/ASTConsumer.h" -#include "clang/AST/ASTContext.h" -#include "clang/AST/Attr.h" -#include "clang/AST/NSAPI.h" -#include "clang/AST/ParentMap.h" -#include "clang/AST/RecursiveASTVisitor.h" -#include "clang/Analysis/DomainSpecific/CocoaConventions.h" -#include "clang/Basic/FileManager.h" -#include "clang/Edit/Commit.h" -#include "clang/Edit/EditedSource.h" -#include "clang/Edit/EditsReceiver.h" -#include "clang/Edit/Rewriters.h" -#include "clang/Frontend/CompilerInstance.h" -#include "clang/Frontend/MultiplexConsumer.h" -#include "clang/Lex/PPConditionalDirectiveRecord.h" -#include "clang/Lex/Preprocessor.h" -#include "clang/Rewrite/Core/Rewriter.h" -#include "llvm/ADT/SmallString.h" -#include "llvm/ADT/StringSet.h" -#include "llvm/Support/Path.h" -#include "llvm/Support/SourceMgr.h" -#include "llvm/Support/YAMLParser.h" - -using namespace clang; -using namespace arcmt; -using namespace ento; -using llvm::RewriteBuffer; - -namespace { - -class ObjCMigrateASTConsumer : public ASTConsumer { - enum CF_BRIDGING_KIND { - CF_BRIDGING_NONE, - CF_BRIDGING_ENABLE, - CF_BRIDGING_MAY_INCLUDE - }; - - void migrateDecl(Decl *D); - void migrateObjCContainerDecl(ASTContext &Ctx, ObjCContainerDecl *D); - void migrateProtocolConformance(ASTContext &Ctx, - const ObjCImplementationDecl *ImpDecl); - void CacheObjCNSIntegerTypedefed(const TypedefDecl *TypedefDcl); - bool migrateNSEnumDecl(ASTContext &Ctx, const EnumDecl *EnumDcl, - const TypedefDecl *TypedefDcl); - void migrateAllMethodInstaceType(ASTContext &Ctx, ObjCContainerDecl *CDecl); - void migrateMethodInstanceType(ASTContext &Ctx, ObjCContainerDecl *CDecl, - ObjCMethodDecl *OM); - bool migrateProperty(ASTContext &Ctx, ObjCContainerDecl *D, ObjCMethodDecl *OM); - void migrateNsReturnsInnerPointer(ASTContext &Ctx, ObjCMethodDecl *OM); - void migratePropertyNsReturnsInnerPointer(ASTContext &Ctx, ObjCPropertyDecl *P); - void migrateFactoryMethod(ASTContext &Ctx, ObjCContainerDecl *CDecl, - ObjCMethodDecl *OM, - ObjCInstanceTypeFamily OIT_Family = OIT_None); - - void migrateCFAnnotation(ASTContext &Ctx, const Decl *Decl); - void AddCFAnnotations(ASTContext &Ctx, - const RetainSummary *RS, - const FunctionDecl *FuncDecl, bool ResultAnnotated); - void AddCFAnnotations(ASTContext &Ctx, - const RetainSummary *RS, - const ObjCMethodDecl *MethodDecl, bool ResultAnnotated); - - void AnnotateImplicitBridging(ASTContext &Ctx); - - CF_BRIDGING_KIND migrateAddFunctionAnnotation(ASTContext &Ctx, - const FunctionDecl *FuncDecl); - - void migrateARCSafeAnnotation(ASTContext &Ctx, ObjCContainerDecl *CDecl); - - void migrateAddMethodAnnotation(ASTContext &Ctx, - const ObjCMethodDecl *MethodDecl); - - void inferDesignatedInitializers(ASTContext &Ctx, - const ObjCImplementationDecl *ImplD); - - bool InsertFoundation(ASTContext &Ctx, SourceLocation Loc); - - std::unique_ptr<RetainSummaryManager> Summaries; - -public: - std::string MigrateDir; - unsigned ASTMigrateActions; - FileID FileId; - const TypedefDecl *NSIntegerTypedefed; - const TypedefDecl *NSUIntegerTypedefed; - std::unique_ptr<NSAPI> NSAPIObj; - std::unique_ptr<edit::EditedSource> Editor; - FileRemapper &Remapper; - FileManager &FileMgr; - const PPConditionalDirectiveRecord *PPRec; - Preprocessor &PP; - bool IsOutputFile; - bool FoundationIncluded; - llvm::SmallPtrSet<ObjCProtocolDecl *, 32> ObjCProtocolDecls; - llvm::SmallVector<const Decl *, 8> CFFunctionIBCandidates; - llvm::StringSet<> AllowListFilenames; - - RetainSummaryManager &getSummaryManager(ASTContext &Ctx) { - if (!Summaries) - Summaries.reset(new RetainSummaryManager(Ctx, - /*TrackNSCFObjects=*/true, - /*trackOSObjects=*/false)); - return *Summaries; - } - - ObjCMigrateASTConsumer(StringRef migrateDir, unsigned astMigrateActions, - FileRemapper &remapper, FileManager &fileMgr, - const PPConditionalDirectiveRecord *PPRec, - Preprocessor &PP, bool isOutputFile, - ArrayRef<std::string> AllowList) - : MigrateDir(migrateDir), ASTMigrateActions(astMigrateActions), - NSIntegerTypedefed(nullptr), NSUIntegerTypedefed(nullptr), - Remapper(remapper), FileMgr(fileMgr), PPRec(PPRec), PP(PP), - IsOutputFile(isOutputFile), FoundationIncluded(false) { - AllowListFilenames.insert(AllowList.begin(), AllowList.end()); - } - -protected: - void Initialize(ASTContext &Context) override { - NSAPIObj.reset(new NSAPI(Context)); - Editor.reset(new edit::EditedSource(Context.getSourceManager(), - Context.getLangOpts(), - PPRec)); - } - - bool HandleTopLevelDecl(DeclGroupRef DG) override { - for (DeclGroupRef::iterator I = DG.begin(), E = DG.end(); I != E; ++I) - migrateDecl(*I); - return true; - } - void HandleInterestingDecl(DeclGroupRef DG) override { - // Ignore decls from the PCH. - } - void HandleTopLevelDeclInObjCContainer(DeclGroupRef DG) override { - ObjCMigrateASTConsumer::HandleTopLevelDecl(DG); - } - - void HandleTranslationUnit(ASTContext &Ctx) override; - - bool canModifyFile(StringRef Path) { - if (AllowListFilenames.empty()) - return true; - return AllowListFilenames.contains(llvm::sys::path::filename(Path)); - } - bool canModifyFile(OptionalFileEntryRef FE) { - if (!FE) - return false; - return canModifyFile(FE->getName()); - } - bool canModifyFile(FileID FID) { - if (FID.isInvalid()) - return false; - return canModifyFile(PP.getSourceManager().getFileEntryRefForID(FID)); - } - - bool canModify(const Decl *D) { - if (!D) - return false; - if (const ObjCCategoryImplDecl *CatImpl = dyn_cast<ObjCCategoryImplDecl>(D)) - return canModify(CatImpl->getCategoryDecl()); - if (const ObjCImplementationDecl *Impl = dyn_cast<ObjCImplementationDecl>(D)) - return canModify(Impl->getClassInterface()); - if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) - return canModify(cast<Decl>(MD->getDeclContext())); - - FileID FID = PP.getSourceManager().getFileID(D->getLocation()); - return canModifyFile(FID); - } -}; - -} // end anonymous namespace - -ObjCMigrateAction::ObjCMigrateAction( - std::unique_ptr<FrontendAction> WrappedAction, StringRef migrateDir, - unsigned migrateAction) - : WrapperFrontendAction(std::move(WrappedAction)), MigrateDir(migrateDir), - ObjCMigAction(migrateAction), CompInst(nullptr) { - if (MigrateDir.empty()) - MigrateDir = "."; // user current directory if none is given. -} - -std::unique_ptr<ASTConsumer> -ObjCMigrateAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { - PPConditionalDirectiveRecord * - PPRec = new PPConditionalDirectiveRecord(CompInst->getSourceManager()); - CI.getPreprocessor().addPPCallbacks(std::unique_ptr<PPCallbacks>(PPRec)); - std::vector<std::unique_ptr<ASTConsumer>> Consumers; - Consumers.push_back(WrapperFrontendAction::CreateASTConsumer(CI, InFile)); - Consumers.push_back(std::make_unique<ObjCMigrateASTConsumer>( - MigrateDir, ObjCMigAction, Remapper, CompInst->getFileManager(), PPRec, - CompInst->getPreprocessor(), false, std::nullopt)); - return std::make_unique<MultiplexConsumer>(std::move(Consumers)); -} - -bool ObjCMigrateAction::BeginInvocation(CompilerInstance &CI) { - Remapper.initFromDisk(MigrateDir, CI.getDiagnostics(), - /*ignoreIfFilesChanged=*/true); - CompInst = &CI; - CI.getDiagnostics().setIgnoreAllWarnings(true); - return true; -} - -namespace { - // FIXME. This duplicates one in RewriteObjCFoundationAPI.cpp - bool subscriptOperatorNeedsParens(const Expr *FullExpr) { - const Expr* Expr = FullExpr->IgnoreImpCasts(); - return !(isa<ArraySubscriptExpr>(Expr) || isa<CallExpr>(Expr) || - isa<DeclRefExpr>(Expr) || isa<CXXNamedCastExpr>(Expr) || - isa<CXXConstructExpr>(Expr) || isa<CXXThisExpr>(Expr) || - isa<CXXTypeidExpr>(Expr) || - isa<CXXUnresolvedConstructExpr>(Expr) || - isa<ObjCMessageExpr>(Expr) || isa<ObjCPropertyRefExpr>(Expr) || - isa<ObjCProtocolExpr>(Expr) || isa<MemberExpr>(Expr) || - isa<ObjCIvarRefExpr>(Expr) || isa<ParenExpr>(FullExpr) || - isa<ParenListExpr>(Expr) || isa<SizeOfPackExpr>(Expr)); - } - - /// - Rewrite message expression for Objective-C setter and getters into - /// property-dot syntax. - bool rewriteToPropertyDotSyntax(const ObjCMessageExpr *Msg, - Preprocessor &PP, - const NSAPI &NS, edit::Commit &commit, - const ParentMap *PMap) { - if (!Msg || Msg->isImplicit() || - (Msg->getReceiverKind() != ObjCMessageExpr::Instance && - Msg->getReceiverKind() != ObjCMessageExpr::SuperInstance)) - return false; - if (const Expr *Receiver = Msg->getInstanceReceiver()) - if (Receiver->getType()->isObjCBuiltinType()) - return false; - - const ObjCMethodDecl *Method = Msg->getMethodDecl(); - if (!Method) - return false; - if (!Method->isPropertyAccessor()) - return false; - - const ObjCPropertyDecl *Prop = Method->findPropertyDecl(); - if (!Prop) - return false; - - SourceRange MsgRange = Msg->getSourceRange(); - bool ReceiverIsSuper = - (Msg->getReceiverKind() == ObjCMessageExpr::SuperInstance); - // for 'super' receiver is nullptr. - const Expr *receiver = Msg->getInstanceReceiver(); - bool NeedsParen = - ReceiverIsSuper ? false : subscriptOperatorNeedsParens(receiver); - bool IsGetter = (Msg->getNumArgs() == 0); - if (IsGetter) { - // Find space location range between receiver expression and getter method. - SourceLocation BegLoc = - ReceiverIsSuper ? Msg->getSuperLoc() : receiver->getEndLoc(); - BegLoc = PP.getLocForEndOfToken(BegLoc); - SourceLocation EndLoc = Msg->getSelectorLoc(0); - SourceRange SpaceRange(BegLoc, EndLoc); - std::string PropertyDotString; - // rewrite getter method expression into: receiver.property or - // (receiver).property - if (NeedsParen) { - commit.insertBefore(receiver->getBeginLoc(), "("); - PropertyDotString = ")."; - } - else - PropertyDotString = "."; - PropertyDotString += Prop->getName(); - commit.replace(SpaceRange, PropertyDotString); - - // remove '[' ']' - commit.replace(SourceRange(MsgRange.getBegin(), MsgRange.getBegin()), ""); - commit.replace(SourceRange(MsgRange.getEnd(), MsgRange.getEnd()), ""); - } else { - if (NeedsParen) - commit.insertWrap("(", receiver->getSourceRange(), ")"); - std::string PropertyDotString = "."; - PropertyDotString += Prop->getName(); - PropertyDotString += " ="; - const Expr*const* Args = Msg->getArgs(); - const Expr *RHS = Args[0]; - if (!RHS) - return false; - SourceLocation BegLoc = - ReceiverIsSuper ? Msg->getSuperLoc() : receiver->getEndLoc(); - BegLoc = PP.getLocForEndOfToken(BegLoc); - SourceLocation EndLoc = RHS->getBeginLoc(); - EndLoc = EndLoc.getLocWithOffset(-1); - const char *colon = PP.getSourceManager().getCharacterData(EndLoc); - // Add a space after '=' if there is no space between RHS and '=' - if (colon && colon[0] == ':') - PropertyDotString += " "; - SourceRange Range(BegLoc, EndLoc); - commit.replace(Range, PropertyDotString); - // remove '[' ']' - commit.replace(SourceRange(MsgRange.getBegin(), MsgRange.getBegin()), ""); - commit.replace(SourceRange(MsgRange.getEnd(), MsgRange.getEnd()), ""); - } - return true; - } - -class ObjCMigrator : public RecursiveASTVisitor<ObjCMigrator> { - ObjCMigrateASTConsumer &Consumer; - ParentMap &PMap; - -public: - ObjCMigrator(ObjCMigrateASTConsumer &consumer, ParentMap &PMap) - : Consumer(consumer), PMap(PMap) { } - - bool shouldVisitTemplateInstantiations() const { return false; } - bool shouldWalkTypesOfTypeLocs() const { return false; } - - bool VisitObjCMessageExpr(ObjCMessageExpr *E) { - if (Consumer.ASTMigrateActions & FrontendOptions::ObjCMT_Literals) { - edit::Commit commit(*Consumer.Editor); - edit::rewriteToObjCLiteralSyntax(E, *Consumer.NSAPIObj, commit, &PMap); - Consumer.Editor->commit(commit); - } - - if (Consumer.ASTMigrateActions & FrontendOptions::ObjCMT_Subscripting) { - edit::Commit commit(*Consumer.Editor); - edit::rewriteToObjCSubscriptSyntax(E, *Consumer.NSAPIObj, commit); - Consumer.Editor->commit(commit); - } - - if (Consumer.ASTMigrateActions & FrontendOptions::ObjCMT_PropertyDotSyntax) { - edit::Commit commit(*Consumer.Editor); - rewriteToPropertyDotSyntax(E, Consumer.PP, *Consumer.NSAPIObj, - commit, &PMap); - Consumer.Editor->commit(commit); - } - - return true; - } - - bool TraverseObjCMessageExpr(ObjCMessageExpr *E) { - // Do depth first; we want to rewrite the subexpressions first so that if - // we have to move expressions we will move them already rewritten. - for (Stmt *SubStmt : E->children()) - if (!TraverseStmt(SubStmt)) - return false; - - return WalkUpFromObjCMessageExpr(E); - } -}; - -class BodyMigrator : public RecursiveASTVisitor<BodyMigrator> { - ObjCMigrateASTConsumer &Consumer; - std::unique_ptr<ParentMap> PMap; - -public: - BodyMigrator(ObjCMigrateASTConsumer &consumer) : Consumer(consumer) { } - - bool shouldVisitTemplateInstantiations() const { return false; } - bool shouldWalkTypesOfTypeLocs() const { return false; } - - bool TraverseStmt(Stmt *S) { - PMap.reset(new ParentMap(S)); - ObjCMigrator(Consumer, *PMap).TraverseStmt(S); - return true; - } -}; -} // end anonymous namespace - -void ObjCMigrateASTConsumer::migrateDecl(Decl *D) { - if (!D) - return; - if (isa<ObjCMethodDecl>(D)) - return; // Wait for the ObjC container declaration. - - BodyMigrator(*this).TraverseDecl(D); -} - -static void append_attr(std::string &PropertyString, const char *attr, - bool &LParenAdded) { - if (!LParenAdded) { - PropertyString += "("; - LParenAdded = true; - } - else - PropertyString += ", "; - PropertyString += attr; -} - -static -void MigrateBlockOrFunctionPointerTypeVariable(std::string & PropertyString, - const std::string& TypeString, - const char *name) { - const char *argPtr = TypeString.c_str(); - int paren = 0; - while (*argPtr) { - switch (*argPtr) { - case '(': - PropertyString += *argPtr; - paren++; - break; - case ')': - PropertyString += *argPtr; - paren--; - break; - case '^': - case '*': - PropertyString += (*argPtr); - if (paren == 1) { - PropertyString += name; - name = ""; - } - break; - default: - PropertyString += *argPtr; - break; - } - argPtr++; - } -} - -static const char *PropertyMemoryAttribute(ASTContext &Context, QualType ArgType) { - Qualifiers::ObjCLifetime propertyLifetime = ArgType.getObjCLifetime(); - bool RetainableObject = ArgType->isObjCRetainableType(); - if (RetainableObject && - (propertyLifetime == Qualifiers::OCL_Strong - || propertyLifetime == Qualifiers::OCL_None)) { - if (const ObjCObjectPointerType *ObjPtrTy = - ArgType->getAs<ObjCObjectPointerType>()) { - ObjCInterfaceDecl *IDecl = ObjPtrTy->getObjectType()->getInterface(); - if (IDecl && - IDecl->lookupNestedProtocol(&Context.Idents.get("NSCopying"))) - return "copy"; - else - return "strong"; - } - else if (ArgType->isBlockPointerType()) - return "copy"; - } else if (propertyLifetime == Qualifiers::OCL_Weak) - // TODO. More precise determination of 'weak' attribute requires - // looking into setter's implementation for backing weak ivar. - return "weak"; - else if (RetainableObject) - return ArgType->isBlockPointerType() ? "copy" : "strong"; - return nullptr; -} - -static void rewriteToObjCProperty(const ObjCMethodDecl *Getter, - const ObjCMethodDecl *Setter, - const NSAPI &NS, edit::Commit &commit, - unsigned LengthOfPrefix, - bool Atomic, bool UseNsIosOnlyMacro, - bool AvailabilityArgsMatch) { - ASTContext &Context = NS.getASTContext(); - bool LParenAdded = false; - std::string PropertyString = "@property "; - if (UseNsIosOnlyMacro && NS.isMacroDefined("NS_NONATOMIC_IOSONLY")) { - PropertyString += "(NS_NONATOMIC_IOSONLY"; - LParenAdded = true; - } else if (!Atomic) { - PropertyString += "(nonatomic"; - LParenAdded = true; - } - - std::string PropertyNameString = Getter->getNameAsString(); - StringRef PropertyName(PropertyNameString); - if (LengthOfPrefix > 0) { - if (!LParenAdded) { - PropertyString += "(getter="; - LParenAdded = true; - } - else - PropertyString += ", getter="; - PropertyString += PropertyNameString; - } - // Property with no setter may be suggested as a 'readonly' property. - if (!Setter) - append_attr(PropertyString, "readonly", LParenAdded); - - - // Short circuit 'delegate' properties that contain the name "delegate" or - // "dataSource", or have exact name "target" to have 'assign' attribute. - if (PropertyName == "target" || PropertyName.contains("delegate") || - PropertyName.contains("dataSource")) { - QualType QT = Getter->getReturnType(); - if (!QT->isRealType()) - append_attr(PropertyString, "assign", LParenAdded); - } else if (!Setter) { - QualType ResType = Context.getCanonicalType(Getter->getReturnType()); - if (const char *MemoryManagementAttr = PropertyMemoryAttribute(Context, ResType)) - append_attr(PropertyString, MemoryManagementAttr, LParenAdded); - } else { - const ParmVarDecl *argDecl = *Setter->param_begin(); - QualType ArgType = Context.getCanonicalType(argDecl->getType()); - if (const char *MemoryManagementAttr = PropertyMemoryAttribute(Context, ArgType)) - append_attr(PropertyString, MemoryManagementAttr, LParenAdded); - } - if (LParenAdded) - PropertyString += ')'; - QualType RT = Getter->getReturnType(); - if (!RT->getAs<TypedefType>()) { - // strip off any ARC lifetime qualifier. - QualType CanResultTy = Context.getCanonicalType(RT); - if (CanResultTy.getQualifiers().hasObjCLifetime()) { - Qualifiers Qs = CanResultTy.getQualifiers(); - Qs.removeObjCLifetime(); - RT = Context.getQualifiedType(CanResultTy.getUnqualifiedType(), Qs); - } - } - PropertyString += " "; - PrintingPolicy SubPolicy(Context.getPrintingPolicy()); - SubPolicy.SuppressStrongLifetime = true; - SubPolicy.SuppressLifetimeQualifiers = true; - std::string TypeString = RT.getAsString(SubPolicy); - if (LengthOfPrefix > 0) { - // property name must strip off "is" and lower case the first character - // after that; e.g. isContinuous will become continuous. - StringRef PropertyNameStringRef(PropertyNameString); - PropertyNameStringRef = PropertyNameStringRef.drop_front(LengthOfPrefix); - PropertyNameString = std::string(PropertyNameStringRef); - bool NoLowering = (isUppercase(PropertyNameString[0]) && - PropertyNameString.size() > 1 && - isUppercase(PropertyNameString[1])); - if (!NoLowering) - PropertyNameString[0] = toLowercase(PropertyNameString[0]); - } - if (RT->isBlockPointerType() || RT->isFunctionPointerType()) - MigrateBlockOrFunctionPointerTypeVariable(PropertyString, - TypeString, - PropertyNameString.c_str()); - else { - char LastChar = TypeString[TypeString.size()-1]; - PropertyString += TypeString; - if (LastChar != '*') - PropertyString += ' '; - PropertyString += PropertyNameString; - } - SourceLocation StartGetterSelectorLoc = Getter->getSelectorStartLoc(); - Selector GetterSelector = Getter->getSelector(); - - SourceLocation EndGetterSelectorLoc = - StartGetterSelectorLoc.getLocWithOffset(GetterSelector.getNameForSlot(0).size()); - commit.replace(CharSourceRange::getCharRange(Getter->getBeginLoc(), - EndGetterSelectorLoc), - PropertyString); - if (Setter && AvailabilityArgsMatch) { - SourceLocation EndLoc = Setter->getDeclaratorEndLoc(); - // Get location past ';' - EndLoc = EndLoc.getLocWithOffset(1); - SourceLocation BeginOfSetterDclLoc = Setter->getBeginLoc(); - // FIXME. This assumes that setter decl; is immediately preceded by eoln. - // It is trying to remove the setter method decl. line entirely. - BeginOfSetterDclLoc = BeginOfSetterDclLoc.getLocWithOffset(-1); - commit.remove(SourceRange(BeginOfSetterDclLoc, EndLoc)); - } -} - -static bool IsCategoryNameWithDeprecatedSuffix(ObjCContainerDecl *D) { - if (ObjCCategoryDecl *CatDecl = dyn_cast<ObjCCategoryDecl>(D)) { - StringRef Name = CatDecl->getName(); - return Name.ends_with("Deprecated"); - } - return false; -} - -void ObjCMigrateASTConsumer::migrateObjCContainerDecl(ASTContext &Ctx, - ObjCContainerDecl *D) { - if (D->isDeprecated() || IsCategoryNameWithDeprecatedSuffix(D)) - return; - - for (auto *Method : D->methods()) { - if (Method->isDeprecated()) - continue; - bool PropertyInferred = migrateProperty(Ctx, D, Method); - // If a property is inferred, do not attempt to attach NS_RETURNS_INNER_POINTER to - // the getter method as it ends up on the property itself which we don't want - // to do unless -objcmt-returns-innerpointer-property option is on. - if (!PropertyInferred || - (ASTMigrateActions & FrontendOptions::ObjCMT_ReturnsInnerPointerProperty)) - if (ASTMigrateActions & FrontendOptions::ObjCMT_Annotation) - migrateNsReturnsInnerPointer(Ctx, Method); - } - if (!(ASTMigrateActions & FrontendOptions::ObjCMT_ReturnsInnerPointerProperty)) - return; - - for (auto *Prop : D->instance_properties()) { - if ((ASTMigrateActions & FrontendOptions::ObjCMT_Annotation) && - !Prop->isDeprecated()) - migratePropertyNsReturnsInnerPointer(Ctx, Prop); - } -} - -static bool -ClassImplementsAllMethodsAndProperties(ASTContext &Ctx, - const ObjCImplementationDecl *ImpDecl, - const ObjCInterfaceDecl *IDecl, - ObjCProtocolDecl *Protocol) { - // In auto-synthesis, protocol properties are not synthesized. So, - // a conforming protocol must have its required properties declared - // in class interface. - bool HasAtleastOneRequiredProperty = false; - if (const ObjCProtocolDecl *PDecl = Protocol->getDefinition()) - for (const auto *Property : PDecl->instance_properties()) { - if (Property->getPropertyImplementation() == ObjCPropertyDecl::Optional) - continue; - HasAtleastOneRequiredProperty = true; - DeclContext::lookup_result R = IDecl->lookup(Property->getDeclName()); - if (R.empty()) { - // Relax the rule and look into class's implementation for a synthesize - // or dynamic declaration. Class is implementing a property coming from - // another protocol. This still makes the target protocol as conforming. - if (!ImpDecl->FindPropertyImplDecl( - Property->getDeclName().getAsIdentifierInfo(), - Property->getQueryKind())) - return false; - } else if (auto *ClassProperty = R.find_first<ObjCPropertyDecl>()) { - if ((ClassProperty->getPropertyAttributes() != - Property->getPropertyAttributes()) || - !Ctx.hasSameType(ClassProperty->getType(), Property->getType())) - return false; - } else - return false; - } - - // At this point, all required properties in this protocol conform to those - // declared in the class. - // Check that class implements the required methods of the protocol too. - bool HasAtleastOneRequiredMethod = false; - if (const ObjCProtocolDecl *PDecl = Protocol->getDefinition()) { - if (PDecl->meth_begin() == PDecl->meth_end()) - return HasAtleastOneRequiredProperty; - for (const auto *MD : PDecl->methods()) { - if (MD->isImplicit()) - continue; - if (MD->getImplementationControl() == ObjCImplementationControl::Optional) - continue; - DeclContext::lookup_result R = ImpDecl->lookup(MD->getDeclName()); - if (R.empty()) - return false; - bool match = false; - HasAtleastOneRequiredMethod = true; - for (NamedDecl *ND : R) - if (ObjCMethodDecl *ImpMD = dyn_cast<ObjCMethodDecl>(ND)) - if (Ctx.ObjCMethodsAreEqual(MD, ImpMD)) { - match = true; - break; - } - if (!match) - return false; - } - } - return HasAtleastOneRequiredProperty || HasAtleastOneRequiredMethod; -} - -static bool rewriteToObjCInterfaceDecl(const ObjCInterfaceDecl *IDecl, - llvm::SmallVectorImpl<ObjCProtocolDecl*> &ConformingProtocols, - const NSAPI &NS, edit::Commit &commit) { - const ObjCList<ObjCProtocolDecl> &Protocols = IDecl->getReferencedProtocols(); - std::string ClassString; - SourceLocation EndLoc = - IDecl->getSuperClass() ? IDecl->getSuperClassLoc() : IDecl->getLocation(); - - if (Protocols.empty()) { - ClassString = '<'; - for (unsigned i = 0, e = ConformingProtocols.size(); i != e; i++) { - ClassString += ConformingProtocols[i]->getNameAsString(); - if (i != (e-1)) - ClassString += ", "; - } - ClassString += "> "; - } - else { - ClassString = ", "; - for (unsigned i = 0, e = ConformingProtocols.size(); i != e; i++) { - ClassString += ConformingProtocols[i]->getNameAsString(); - if (i != (e-1)) - ClassString += ", "; - } - ObjCInterfaceDecl::protocol_loc_iterator PL = IDecl->protocol_loc_end() - 1; - EndLoc = *PL; - } - - commit.insertAfterToken(EndLoc, ClassString); - return true; -} - -static StringRef GetUnsignedName(StringRef NSIntegerName) { - StringRef UnsignedName = llvm::StringSwitch<StringRef>(NSIntegerName) - .Case("int8_t", "uint8_t") - .Case("int16_t", "uint16_t") - .Case("int32_t", "uint32_t") - .Case("NSInteger", "NSUInteger") - .Case("int64_t", "uint64_t") - .Default(NSIntegerName); - return UnsignedName; -} - -static bool rewriteToNSEnumDecl(const EnumDecl *EnumDcl, - const TypedefDecl *TypedefDcl, - const NSAPI &NS, edit::Commit &commit, - StringRef NSIntegerName, - bool NSOptions) { - std::string ClassString; - if (NSOptions) { - ClassString = "typedef NS_OPTIONS("; - ClassString += GetUnsignedName(NSIntegerName); - } - else { - ClassString = "typedef NS_ENUM("; - ClassString += NSIntegerName; - } - ClassString += ", "; - - ClassString += TypedefDcl->getIdentifier()->getName(); - ClassString += ')'; - SourceRange R(EnumDcl->getBeginLoc(), EnumDcl->getBeginLoc()); - commit.replace(R, ClassString); - SourceLocation EndOfEnumDclLoc = EnumDcl->getEndLoc(); - EndOfEnumDclLoc = trans::findSemiAfterLocation(EndOfEnumDclLoc, - NS.getASTContext(), /*IsDecl*/true); - if (EndOfEnumDclLoc.isValid()) { - SourceRange EnumDclRange(EnumDcl->getBeginLoc(), EndOfEnumDclLoc); - commit.insertFromRange(TypedefDcl->getBeginLoc(), EnumDclRange); - } - else - return false; - - SourceLocation EndTypedefDclLoc = TypedefDcl->getEndLoc(); - EndTypedefDclLoc = trans::findSemiAfterLocation(EndTypedefDclLoc, - NS.getASTContext(), /*IsDecl*/true); - if (EndTypedefDclLoc.isValid()) { - SourceRange TDRange(TypedefDcl->getBeginLoc(), EndTypedefDclLoc); - commit.remove(TDRange); - } - else - return false; - - EndOfEnumDclLoc = - trans::findLocationAfterSemi(EnumDcl->getEndLoc(), NS.getASTContext(), - /*IsDecl*/ true); - if (EndOfEnumDclLoc.isValid()) { - SourceLocation BeginOfEnumDclLoc = EnumDcl->getBeginLoc(); - // FIXME. This assumes that enum decl; is immediately preceded by eoln. - // It is trying to remove the enum decl. lines entirely. - BeginOfEnumDclLoc = BeginOfEnumDclLoc.getLocWithOffset(-1); - commit.remove(SourceRange(BeginOfEnumDclLoc, EndOfEnumDclLoc)); - return true; - } - return false; -} - -static void rewriteToNSMacroDecl(ASTContext &Ctx, - const EnumDecl *EnumDcl, - const TypedefDecl *TypedefDcl, - const NSAPI &NS, edit::Commit &commit, - bool IsNSIntegerType) { - QualType DesignatedEnumType = EnumDcl->getIntegerType(); - assert(!DesignatedEnumType.isNull() - && "rewriteToNSMacroDecl - underlying enum type is null"); - - PrintingPolicy Policy(Ctx.getPrintingPolicy()); - std::string TypeString = DesignatedEnumType.getAsString(Policy); - std::string ClassString = IsNSIntegerType ? "NS_ENUM(" : "NS_OPTIONS("; - ClassString += TypeString; - ClassString += ", "; - - ClassString += TypedefDcl->getIdentifier()->getName(); - ClassString += ") "; - SourceLocation EndLoc = EnumDcl->getBraceRange().getBegin(); - if (EndLoc.isInvalid()) - return; - CharSourceRange R = - CharSourceRange::getCharRange(EnumDcl->getBeginLoc(), EndLoc); - commit.replace(R, ClassString); - // This is to remove spaces between '}' and typedef name. - SourceLocation StartTypedefLoc = EnumDcl->getEndLoc(); - StartTypedefLoc = StartTypedefLoc.getLocWithOffset(+1); - SourceLocation EndTypedefLoc = TypedefDcl->getEndLoc(); - - commit.remove(SourceRange(StartTypedefLoc, EndTypedefLoc)); -} - -static bool UseNSOptionsMacro(Preprocessor &PP, ASTContext &Ctx, - const EnumDecl *EnumDcl) { - bool PowerOfTwo = true; - bool AllHexdecimalEnumerator = true; - uint64_t MaxPowerOfTwoVal = 0; - for (auto *Enumerator : EnumDcl->enumerators()) { - const Expr *InitExpr = Enumerator->getInitExpr(); - if (!InitExpr) { - PowerOfTwo = false; - AllHexdecimalEnumerator = false; - continue; - } - InitExpr = InitExpr->IgnoreParenCasts(); - if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(InitExpr)) - if (BO->isShiftOp() || BO->isBitwiseOp()) - return true; - - uint64_t EnumVal = Enumerator->getInitVal().getZExtValue(); - if (PowerOfTwo && EnumVal) { - if (!llvm::isPowerOf2_64(EnumVal)) - PowerOfTwo = false; - else if (EnumVal > MaxPowerOfTwoVal) - MaxPowerOfTwoVal = EnumVal; - } - if (AllHexdecimalEnumerator && EnumVal) { - bool FoundHexdecimalEnumerator = false; - SourceLocation EndLoc = Enumerator->getEndLoc(); - Token Tok; - if (!PP.getRawToken(EndLoc, Tok, /*IgnoreWhiteSpace=*/true)) - if (Tok.isLiteral() && Tok.getLength() > 2) { - if (const char *StringLit = Tok.getLiteralData()) - FoundHexdecimalEnumerator = - (StringLit[0] == '0' && (toLowercase(StringLit[1]) == 'x')); - } - if (!FoundHexdecimalEnumerator) - AllHexdecimalEnumerator = false; - } - } - return AllHexdecimalEnumerator || (PowerOfTwo && (MaxPowerOfTwoVal > 2)); -} - -void ObjCMigrateASTConsumer::migrateProtocolConformance(ASTContext &Ctx, - const ObjCImplementationDecl *ImpDecl) { - const ObjCInterfaceDecl *IDecl = ImpDecl->getClassInterface(); - if (!IDecl || ObjCProtocolDecls.empty() || IDecl->isDeprecated()) - return; - // Find all implicit conforming protocols for this class - // and make them explicit. - llvm::SmallPtrSet<ObjCProtocolDecl *, 8> ExplicitProtocols; - Ctx.CollectInheritedProtocols(IDecl, ExplicitProtocols); - llvm::SmallVector<ObjCProtocolDecl *, 8> PotentialImplicitProtocols; - - for (ObjCProtocolDecl *ProtDecl : ObjCProtocolDecls) - if (!ExplicitProtocols.count(ProtDecl)) - PotentialImplicitProtocols.push_back(ProtDecl); - - if (PotentialImplicitProtocols.empty()) - return; - - // go through list of non-optional methods and properties in each protocol - // in the PotentialImplicitProtocols list. If class implements every one of the - // methods and properties, then this class conforms to this protocol. - llvm::SmallVector<ObjCProtocolDecl*, 8> ConformingProtocols; - for (unsigned i = 0, e = PotentialImplicitProtocols.size(); i != e; i++) - if (ClassImplementsAllMethodsAndProperties(Ctx, ImpDecl, IDecl, - PotentialImplicitProtocols[i])) - ConformingProtocols.push_back(PotentialImplicitProtocols[i]); - - if (ConformingProtocols.empty()) - return; - - // Further reduce number of conforming protocols. If protocol P1 is in the list - // protocol P2 (P2<P1>), No need to include P1. - llvm::SmallVector<ObjCProtocolDecl*, 8> MinimalConformingProtocols; - for (unsigned i = 0, e = ConformingProtocols.size(); i != e; i++) { - bool DropIt = false; - ObjCProtocolDecl *TargetPDecl = ConformingProtocols[i]; - for (unsigned i1 = 0, e1 = ConformingProtocols.size(); i1 != e1; i1++) { - ObjCProtocolDecl *PDecl = ConformingProtocols[i1]; - if (PDecl == TargetPDecl) - continue; - if (PDecl->lookupProtocolNamed( - TargetPDecl->getDeclName().getAsIdentifierInfo())) { - DropIt = true; - break; - } - } - if (!DropIt) - MinimalConformingProtocols.push_back(TargetPDecl); - } - if (MinimalConformingProtocols.empty()) - return; - edit::Commit commit(*Editor); - rewriteToObjCInterfaceDecl(IDecl, MinimalConformingProtocols, - *NSAPIObj, commit); - Editor->commit(commit); -} - -void ObjCMigrateASTConsumer::CacheObjCNSIntegerTypedefed( - const TypedefDecl *TypedefDcl) { - - QualType qt = TypedefDcl->getTypeSourceInfo()->getType(); - if (NSAPIObj->isObjCNSIntegerType(qt)) - NSIntegerTypedefed = TypedefDcl; - else if (NSAPIObj->isObjCNSUIntegerType(qt)) - NSUIntegerTypedefed = TypedefDcl; -} - -bool ObjCMigrateASTConsumer::migrateNSEnumDecl(ASTContext &Ctx, - const EnumDecl *EnumDcl, - const TypedefDecl *TypedefDcl) { - if (!EnumDcl->isCompleteDefinition() || EnumDcl->getIdentifier() || - EnumDcl->isDeprecated()) - return false; - if (!TypedefDcl) { - if (NSIntegerTypedefed) { - TypedefDcl = NSIntegerTypedefed; - NSIntegerTypedefed = nullptr; - } - else if (NSUIntegerTypedefed) { - TypedefDcl = NSUIntegerTypedefed; - NSUIntegerTypedefed = nullptr; - } - else - return false; - FileID FileIdOfTypedefDcl = - PP.getSourceManager().getFileID(TypedefDcl->getLocation()); - FileID FileIdOfEnumDcl = - PP.getSourceManager().getFileID(EnumDcl->getLocation()); - if (FileIdOfTypedefDcl != FileIdOfEnumDcl) - return false; - } - if (TypedefDcl->isDeprecated()) - return false; - - QualType qt = TypedefDcl->getTypeSourceInfo()->getType(); - StringRef NSIntegerName = NSAPIObj->GetNSIntegralKind(qt); - - if (NSIntegerName.empty()) { - // Also check for typedef enum {...} TD; - if (const EnumType *EnumTy = qt->getAs<EnumType>()) { - if (EnumTy->getDecl() == EnumDcl) { - bool NSOptions = UseNSOptionsMacro(PP, Ctx, EnumDcl); - if (!InsertFoundation(Ctx, TypedefDcl->getBeginLoc())) - return false; - edit::Commit commit(*Editor); - rewriteToNSMacroDecl(Ctx, EnumDcl, TypedefDcl, *NSAPIObj, commit, !NSOptions); - Editor->commit(commit); - return true; - } - } - return false; - } - - // We may still use NS_OPTIONS based on what we find in the enumertor list. - bool NSOptions = UseNSOptionsMacro(PP, Ctx, EnumDcl); - if (!InsertFoundation(Ctx, TypedefDcl->getBeginLoc())) - return false; - edit::Commit commit(*Editor); - bool Res = rewriteToNSEnumDecl(EnumDcl, TypedefDcl, *NSAPIObj, - commit, NSIntegerName, NSOptions); - Editor->commit(commit); - return Res; -} - -static void ReplaceWithInstancetype(ASTContext &Ctx, - const ObjCMigrateASTConsumer &ASTC, - ObjCMethodDecl *OM) { - if (OM->getReturnType() == Ctx.getObjCInstanceType()) - return; // already has instancetype. - - SourceRange R; - std::string ClassString; - if (TypeSourceInfo *TSInfo = OM->getReturnTypeSourceInfo()) { - TypeLoc TL = TSInfo->getTypeLoc(); - R = SourceRange(TL.getBeginLoc(), TL.getEndLoc()); - ClassString = "instancetype"; - } - else { - R = SourceRange(OM->getBeginLoc(), OM->getBeginLoc()); - ClassString = OM->isInstanceMethod() ? '-' : '+'; - ClassString += " (instancetype)"; - } - edit::Commit commit(*ASTC.Editor); - commit.replace(R, ClassString); - ASTC.Editor->commit(commit); -} - -static void ReplaceWithClasstype(const ObjCMigrateASTConsumer &ASTC, - ObjCMethodDecl *OM) { - ObjCInterfaceDecl *IDecl = OM->getClassInterface(); - SourceRange R; - std::string ClassString; - if (TypeSourceInfo *TSInfo = OM->getReturnTypeSourceInfo()) { - TypeLoc TL = TSInfo->getTypeLoc(); - R = SourceRange(TL.getBeginLoc(), TL.getEndLoc()); { - ClassString = std::string(IDecl->getName()); - ClassString += "*"; - } - } - else { - R = SourceRange(OM->getBeginLoc(), OM->getBeginLoc()); - ClassString = "+ ("; - ClassString += IDecl->getName(); ClassString += "*)"; - } - edit::Commit commit(*ASTC.Editor); - commit.replace(R, ClassString); - ASTC.Editor->commit(commit); -} - -void ObjCMigrateASTConsumer::migrateMethodInstanceType(ASTContext &Ctx, - ObjCContainerDecl *CDecl, - ObjCMethodDecl *OM) { - ObjCInstanceTypeFamily OIT_Family = - Selector::getInstTypeMethodFamily(OM->getSelector()); - - std::string ClassName; - switch (OIT_Family) { - case OIT_None: - migrateFactoryMethod(Ctx, CDecl, OM); - return; - case OIT_Array: - ClassName = "NSArray"; - break; - case OIT_Dictionary: - ClassName = "NSDictionary"; - break; - case OIT_Singleton: - migrateFactoryMethod(Ctx, CDecl, OM, OIT_Singleton); - return; - case OIT_Init: - if (OM->getReturnType()->isObjCIdType()) - ReplaceWithInstancetype(Ctx, *this, OM); - return; - case OIT_ReturnsSelf: - migrateFactoryMethod(Ctx, CDecl, OM, OIT_ReturnsSelf); - return; - } - if (!OM->getReturnType()->isObjCIdType()) - return; - - ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(CDecl); - if (!IDecl) { - if (ObjCCategoryDecl *CatDecl = dyn_cast<ObjCCategoryDecl>(CDecl)) - IDecl = CatDecl->getClassInterface(); - else if (ObjCImplDecl *ImpDecl = dyn_cast<ObjCImplDecl>(CDecl)) - IDecl = ImpDecl->getClassInterface(); - } - if (!IDecl || - !IDecl->lookupInheritedClass(&Ctx.Idents.get(ClassName))) { - migrateFactoryMethod(Ctx, CDecl, OM); - return; - } - ReplaceWithInstancetype(Ctx, *this, OM); -} - -static bool TypeIsInnerPointer(QualType T) { - if (!T->isAnyPointerType()) - return false; - if (T->isObjCObjectPointerType() || T->isObjCBuiltinType() || - T->isBlockPointerType() || T->isFunctionPointerType() || - ento::coreFoundation::isCFObjectRef(T)) - return false; - // Also, typedef-of-pointer-to-incomplete-struct is something that we assume - // is not an innter pointer type. - QualType OrigT = T; - while (const auto *TD = T->getAs<TypedefType>()) - T = TD->getDecl()->getUnderlyingType(); - if (OrigT == T || !T->isPointerType()) - return true; - const PointerType* PT = T->getAs<PointerType>(); - QualType UPointeeT = PT->getPointeeType().getUnqualifiedType(); - if (UPointeeT->isRecordType()) { - const RecordType *RecordTy = UPointeeT->getAs<RecordType>(); - if (!RecordTy->getDecl()->isCompleteDefinition()) - return false; - } - return true; -} - -/// Check whether the two versions match. -static bool versionsMatch(const VersionTuple &X, const VersionTuple &Y) { - return (X == Y); -} - -/// AvailabilityAttrsMatch - This routine checks that if comparing two -/// availability attributes, all their components match. It returns -/// true, if not dealing with availability or when all components of -/// availability attributes match. This routine is only called when -/// the attributes are of the same kind. -static bool AvailabilityAttrsMatch(Attr *At1, Attr *At2) { - const AvailabilityAttr *AA1 = dyn_cast<AvailabilityAttr>(At1); - if (!AA1) - return true; - const AvailabilityAttr *AA2 = cast<AvailabilityAttr>(At2); - - VersionTuple Introduced1 = AA1->getIntroduced(); - VersionTuple Deprecated1 = AA1->getDeprecated(); - VersionTuple Obsoleted1 = AA1->getObsoleted(); - bool IsUnavailable1 = AA1->getUnavailable(); - VersionTuple Introduced2 = AA2->getIntroduced(); - VersionTuple Deprecated2 = AA2->getDeprecated(); - VersionTuple Obsoleted2 = AA2->getObsoleted(); - bool IsUnavailable2 = AA2->getUnavailable(); - return (versionsMatch(Introduced1, Introduced2) && - versionsMatch(Deprecated1, Deprecated2) && - versionsMatch(Obsoleted1, Obsoleted2) && - IsUnavailable1 == IsUnavailable2); -} - -static bool MatchTwoAttributeLists(const AttrVec &Attrs1, const AttrVec &Attrs2, - bool &AvailabilityArgsMatch) { - // This list is very small, so this need not be optimized. - for (unsigned i = 0, e = Attrs1.size(); i != e; i++) { - bool match = false; - for (unsigned j = 0, f = Attrs2.size(); j != f; j++) { - // Matching attribute kind only. Except for Availability attributes, - // we are not getting into details of the attributes. For all practical purposes - // this is sufficient. - if (Attrs1[i]->getKind() == Attrs2[j]->getKind()) { - if (AvailabilityArgsMatch) - AvailabilityArgsMatch = AvailabilityAttrsMatch(Attrs1[i], Attrs2[j]); - match = true; - break; - } - } - if (!match) - return false; - } - return true; -} - -/// AttributesMatch - This routine checks list of attributes for two -/// decls. It returns false, if there is a mismatch in kind of -/// attributes seen in the decls. It returns true if the two decls -/// have list of same kind of attributes. Furthermore, when there -/// are availability attributes in the two decls, it sets the -/// AvailabilityArgsMatch to false if availability attributes have -/// different versions, etc. -static bool AttributesMatch(const Decl *Decl1, const Decl *Decl2, - bool &AvailabilityArgsMatch) { - if (!Decl1->hasAttrs() || !Decl2->hasAttrs()) { - AvailabilityArgsMatch = (Decl1->hasAttrs() == Decl2->hasAttrs()); - return true; - } - AvailabilityArgsMatch = true; - const AttrVec &Attrs1 = Decl1->getAttrs(); - const AttrVec &Attrs2 = Decl2->getAttrs(); - bool match = MatchTwoAttributeLists(Attrs1, Attrs2, AvailabilityArgsMatch); - if (match && (Attrs2.size() > Attrs1.size())) - return MatchTwoAttributeLists(Attrs2, Attrs1, AvailabilityArgsMatch); - return match; -} - -static bool IsValidIdentifier(ASTContext &Ctx, - const char *Name) { - if (!isAsciiIdentifierStart(Name[0])) - return false; - std::string NameString = Name; - NameString[0] = toLowercase(NameString[0]); - const IdentifierInfo *II = &Ctx.Idents.get(NameString); - return II->getTokenID() == tok::identifier; -} - -bool ObjCMigrateASTConsumer::migrateProperty(ASTContext &Ctx, - ObjCContainerDecl *D, - ObjCMethodDecl *Method) { - if (Method->isPropertyAccessor() || !Method->isInstanceMethod() || - Method->param_size() != 0) - return false; - // Is this method candidate to be a getter? - QualType GRT = Method->getReturnType(); - if (GRT->isVoidType()) - return false; - - Selector GetterSelector = Method->getSelector(); - ObjCInstanceTypeFamily OIT_Family = - Selector::getInstTypeMethodFamily(GetterSelector); - - if (OIT_Family != OIT_None) - return false; - - const IdentifierInfo *getterName = GetterSelector.getIdentifierInfoForSlot(0); - Selector SetterSelector = - SelectorTable::constructSetterSelector(PP.getIdentifierTable(), - PP.getSelectorTable(), - getterName); - ObjCMethodDecl *SetterMethod = D->getInstanceMethod(SetterSelector); - unsigned LengthOfPrefix = 0; - if (!SetterMethod) { - // try a different naming convention for getter: isXxxxx - StringRef getterNameString = getterName->getName(); - bool IsPrefix = getterNameString.starts_with("is"); - // Note that we don't want to change an isXXX method of retainable object - // type to property (readonly or otherwise). - if (IsPrefix && GRT->isObjCRetainableType()) - return false; - if (IsPrefix || getterNameString.starts_with("get")) { - LengthOfPrefix = (IsPrefix ? 2 : 3); - const char *CGetterName = getterNameString.data() + LengthOfPrefix; - // Make sure that first character after "is" or "get" prefix can - // start an identifier. - if (!IsValidIdentifier(Ctx, CGetterName)) - return false; - if (CGetterName[0] && isUppercase(CGetterName[0])) { - getterName = &Ctx.Idents.get(CGetterName); - SetterSelector = - SelectorTable::constructSetterSelector(PP.getIdentifierTable(), - PP.getSelectorTable(), - getterName); - SetterMethod = D->getInstanceMethod(SetterSelector); - } - } - } - - if (SetterMethod) { - if ((ASTMigrateActions & FrontendOptions::ObjCMT_ReadwriteProperty) == 0) - return false; - bool AvailabilityArgsMatch; - if (SetterMethod->isDeprecated() || - !AttributesMatch(Method, SetterMethod, AvailabilityArgsMatch)) - return false; - - // Is this a valid setter, matching the target getter? - QualType SRT = SetterMethod->getReturnType(); - if (!SRT->isVoidType()) - return false; - const ParmVarDecl *argDecl = *SetterMethod->param_begin(); - QualType ArgType = argDecl->getType(); - if (!Ctx.hasSameUnqualifiedType(ArgType, GRT)) - return false; - edit::Commit commit(*Editor); - rewriteToObjCProperty(Method, SetterMethod, *NSAPIObj, commit, - LengthOfPrefix, - (ASTMigrateActions & - FrontendOptions::ObjCMT_AtomicProperty) != 0, - (ASTMigrateActions & - FrontendOptions::ObjCMT_NsAtomicIOSOnlyProperty) != 0, - AvailabilityArgsMatch); - Editor->commit(commit); - return true; - } - else if (ASTMigrateActions & FrontendOptions::ObjCMT_ReadonlyProperty) { - // Try a non-void method with no argument (and no setter or property of same name - // as a 'readonly' property. - edit::Commit commit(*Editor); - rewriteToObjCProperty(Method, nullptr /*SetterMethod*/, *NSAPIObj, commit, - LengthOfPrefix, - (ASTMigrateActions & - FrontendOptions::ObjCMT_AtomicProperty) != 0, - (ASTMigrateActions & - FrontendOptions::ObjCMT_NsAtomicIOSOnlyProperty) != 0, - /*AvailabilityArgsMatch*/false); - Editor->commit(commit); - return true; - } - return false; -} - -void ObjCMigrateASTConsumer::migrateNsReturnsInnerPointer(ASTContext &Ctx, - ObjCMethodDecl *OM) { - if (OM->isImplicit() || - !OM->isInstanceMethod() || - OM->hasAttr<ObjCReturnsInnerPointerAttr>()) - return; - - QualType RT = OM->getReturnType(); - if (!TypeIsInnerPointer(RT) || - !NSAPIObj->isMacroDefined("NS_RETURNS_INNER_POINTER")) - return; - - edit::Commit commit(*Editor); - commit.insertBefore(OM->getEndLoc(), " NS_RETURNS_INNER_POINTER"); - Editor->commit(commit); -} - -void ObjCMigrateASTConsumer::migratePropertyNsReturnsInnerPointer(ASTContext &Ctx, - ObjCPropertyDecl *P) { - QualType T = P->getType(); - - if (!TypeIsInnerPointer(T) || - !NSAPIObj->isMacroDefined("NS_RETURNS_INNER_POINTER")) - return; - edit::Commit commit(*Editor); - commit.insertBefore(P->getEndLoc(), " NS_RETURNS_INNER_POINTER "); - Editor->commit(commit); -} - -void ObjCMigrateASTConsumer::migrateAllMethodInstaceType(ASTContext &Ctx, - ObjCContainerDecl *CDecl) { - if (CDecl->isDeprecated() || IsCategoryNameWithDeprecatedSuffix(CDecl)) - return; - - // migrate methods which can have instancetype as their result type. - for (auto *Method : CDecl->methods()) { - if (Method->isDeprecated()) - continue; - migrateMethodInstanceType(Ctx, CDecl, Method); - } -} - -void ObjCMigrateASTConsumer::migrateFactoryMethod(ASTContext &Ctx, - ObjCContainerDecl *CDecl, - ObjCMethodDecl *OM, - ObjCInstanceTypeFamily OIT_Family) { - if (OM->isInstanceMethod() || - OM->getReturnType() == Ctx.getObjCInstanceType() || - !OM->getReturnType()->isObjCIdType()) - return; - - // Candidate factory methods are + (id) NaMeXXX : ... which belong to a class - // NSYYYNamE with matching names be at least 3 characters long. - ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(CDecl); - if (!IDecl) { - if (ObjCCategoryDecl *CatDecl = dyn_cast<ObjCCategoryDecl>(CDecl)) - IDecl = CatDecl->getClassInterface(); - else if (ObjCImplDecl *ImpDecl = dyn_cast<ObjCImplDecl>(CDecl)) - IDecl = ImpDecl->getClassInterface(); - } - if (!IDecl) - return; - - std::string StringClassName = std::string(IDecl->getName()); - StringRef LoweredClassName(StringClassName); - std::string StringLoweredClassName = LoweredClassName.lower(); - LoweredClassName = StringLoweredClassName; - - const IdentifierInfo *MethodIdName = - OM->getSelector().getIdentifierInfoForSlot(0); - // Handle method with no name at its first selector slot; e.g. + (id):(int)x. - if (!MethodIdName) - return; - - std::string MethodName = std::string(MethodIdName->getName()); - if (OIT_Family == OIT_Singleton || OIT_Family == OIT_ReturnsSelf) { - StringRef STRefMethodName(MethodName); - size_t len = 0; - if (STRefMethodName.starts_with("standard")) - len = strlen("standard"); - else if (STRefMethodName.starts_with("shared")) - len = strlen("shared"); - else if (STRefMethodName.starts_with("default")) - len = strlen("default"); - else - return; - MethodName = std::string(STRefMethodName.substr(len)); - } - std::string MethodNameSubStr = MethodName.substr(0, 3); - StringRef MethodNamePrefix(MethodNameSubStr); - std::string StringLoweredMethodNamePrefix = MethodNamePrefix.lower(); - MethodNamePrefix = StringLoweredMethodNamePrefix; - size_t Ix = LoweredClassName.rfind(MethodNamePrefix); - if (Ix == StringRef::npos) - return; - std::string ClassNamePostfix = std::string(LoweredClassName.substr(Ix)); - StringRef LoweredMethodName(MethodName); - std::string StringLoweredMethodName = LoweredMethodName.lower(); - LoweredMethodName = StringLoweredMethodName; - if (!LoweredMethodName.starts_with(ClassNamePostfix)) - return; - if (OIT_Family == OIT_ReturnsSelf) - ReplaceWithClasstype(*this, OM); - else - ReplaceWithInstancetype(Ctx, *this, OM); -} - -static bool IsVoidStarType(QualType Ty) { - if (!Ty->isPointerType()) - return false; - - // Is the type void*? - const PointerType* PT = Ty->castAs<PointerType>(); - if (PT->getPointeeType().getUnqualifiedType()->isVoidType()) - return true; - return IsVoidStarType(PT->getPointeeType()); -} - -/// AuditedType - This routine audits the type AT and returns false if it is one of known -/// CF object types or of the "void *" variety. It returns true if we don't care about the type -/// such as a non-pointer or pointers which have no ownership issues (such as "int *"). -static bool AuditedType (QualType AT) { - if (!AT->isAnyPointerType() && !AT->isBlockPointerType()) - return true; - // FIXME. There isn't much we can say about CF pointer type; or is there? - if (ento::coreFoundation::isCFObjectRef(AT) || - IsVoidStarType(AT) || - // If an ObjC object is type, assuming that it is not a CF function and - // that it is an un-audited function. - AT->isObjCObjectPointerType() || AT->isObjCBuiltinType()) - return false; - // All other pointers are assumed audited as harmless. - return true; -} - -void ObjCMigrateASTConsumer::AnnotateImplicitBridging(ASTContext &Ctx) { - if (CFFunctionIBCandidates.empty()) - return; - if (!NSAPIObj->isMacroDefined("CF_IMPLICIT_BRIDGING_ENABLED")) { - CFFunctionIBCandidates.clear(); - FileId = FileID(); - return; - } - // Insert CF_IMPLICIT_BRIDGING_ENABLE/CF_IMPLICIT_BRIDGING_DISABLED - const Decl *FirstFD = CFFunctionIBCandidates[0]; - const Decl *LastFD = - CFFunctionIBCandidates[CFFunctionIBCandidates.size()-1]; - const char *PragmaString = "\nCF_IMPLICIT_BRIDGING_ENABLED\n\n"; - edit::Commit commit(*Editor); - commit.insertBefore(FirstFD->getBeginLoc(), PragmaString); - PragmaString = "\n\nCF_IMPLICIT_BRIDGING_DISABLED\n"; - SourceLocation EndLoc = LastFD->getEndLoc(); - // get location just past end of function location. - EndLoc = PP.getLocForEndOfToken(EndLoc); - if (isa<FunctionDecl>(LastFD)) { - // For Methods, EndLoc points to the ending semcolon. So, - // not of these extra work is needed. - Token Tok; - // get locaiton of token that comes after end of function. - bool Failed = PP.getRawToken(EndLoc, Tok, /*IgnoreWhiteSpace=*/true); - if (!Failed) - EndLoc = Tok.getLocation(); - } - commit.insertAfterToken(EndLoc, PragmaString); - Editor->commit(commit); - FileId = FileID(); - CFFunctionIBCandidates.clear(); -} - -void ObjCMigrateASTConsumer::migrateCFAnnotation(ASTContext &Ctx, const Decl *Decl) { - if (Decl->isDeprecated()) - return; - - if (Decl->hasAttr<CFAuditedTransferAttr>()) { - assert(CFFunctionIBCandidates.empty() && - "Cannot have audited functions/methods inside user " - "provided CF_IMPLICIT_BRIDGING_ENABLE"); - return; - } - - // Finction must be annotated first. - if (const FunctionDecl *FuncDecl = dyn_cast<FunctionDecl>(Decl)) { - CF_BRIDGING_KIND AuditKind = migrateAddFunctionAnnotation(Ctx, FuncDecl); - if (AuditKind == CF_BRIDGING_ENABLE) { - CFFunctionIBCandidates.push_back(Decl); - if (FileId.isInvalid()) - FileId = PP.getSourceManager().getFileID(Decl->getLocation()); - } - else if (AuditKind == CF_BRIDGING_MAY_INCLUDE) { - if (!CFFunctionIBCandidates.empty()) { - CFFunctionIBCandidates.push_back(Decl); - if (FileId.isInvalid()) - FileId = PP.getSourceManager().getFileID(Decl->getLocation()); - } - } - else - AnnotateImplicitBridging(Ctx); - } - else { - migrateAddMethodAnnotation(Ctx, cast<ObjCMethodDecl>(Decl)); - AnnotateImplicitBridging(Ctx); - } -} - -void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx, - const RetainSummary *RS, - const FunctionDecl *FuncDecl, - bool ResultAnnotated) { - // Annotate function. - if (!ResultAnnotated) { - RetEffect Ret = RS->getRetEffect(); - const char *AnnotationString = nullptr; - if (Ret.getObjKind() == ObjKind::CF) { - if (Ret.isOwned() && NSAPIObj->isMacroDefined("CF_RETURNS_RETAINED")) - AnnotationString = " CF_RETURNS_RETAINED"; - else if (Ret.notOwned() && - NSAPIObj->isMacroDefined("CF_RETURNS_NOT_RETAINED")) - AnnotationString = " CF_RETURNS_NOT_RETAINED"; - } - else if (Ret.getObjKind() == ObjKind::ObjC) { - if (Ret.isOwned() && NSAPIObj->isMacroDefined("NS_RETURNS_RETAINED")) - AnnotationString = " NS_RETURNS_RETAINED"; - } - - if (AnnotationString) { - edit::Commit commit(*Editor); - commit.insertAfterToken(FuncDecl->getEndLoc(), AnnotationString); - Editor->commit(commit); - } - } - unsigned i = 0; - for (FunctionDecl::param_const_iterator pi = FuncDecl->param_begin(), - pe = FuncDecl->param_end(); pi != pe; ++pi, ++i) { - const ParmVarDecl *pd = *pi; - ArgEffect AE = RS->getArg(i); - if (AE.getKind() == DecRef && AE.getObjKind() == ObjKind::CF && - !pd->hasAttr<CFConsumedAttr>() && - NSAPIObj->isMacroDefined("CF_CONSUMED")) { - edit::Commit commit(*Editor); - commit.insertBefore(pd->getLocation(), "CF_CONSUMED "); - Editor->commit(commit); - } else if (AE.getKind() == DecRef && AE.getObjKind() == ObjKind::ObjC && - !pd->hasAttr<NSConsumedAttr>() && - NSAPIObj->isMacroDefined("NS_CONSUMED")) { - edit::Commit commit(*Editor); - commit.insertBefore(pd->getLocation(), "NS_CONSUMED "); - Editor->commit(commit); - } - } -} - -ObjCMigrateASTConsumer::CF_BRIDGING_KIND - ObjCMigrateASTConsumer::migrateAddFunctionAnnotation( - ASTContext &Ctx, - const FunctionDecl *FuncDecl) { - if (FuncDecl->hasBody()) - return CF_BRIDGING_NONE; - - const RetainSummary *RS = - getSummaryManager(Ctx).getSummary(AnyCall(FuncDecl)); - bool FuncIsReturnAnnotated = (FuncDecl->hasAttr<CFReturnsRetainedAttr>() || - FuncDecl->hasAttr<CFReturnsNotRetainedAttr>() || - FuncDecl->hasAttr<NSReturnsRetainedAttr>() || - FuncDecl->hasAttr<NSReturnsNotRetainedAttr>() || - FuncDecl->hasAttr<NSReturnsAutoreleasedAttr>()); - - // Trivial case of when function is annotated and has no argument. - if (FuncIsReturnAnnotated && FuncDecl->getNumParams() == 0) - return CF_BRIDGING_NONE; - - bool ReturnCFAudited = false; - if (!FuncIsReturnAnnotated) { - RetEffect Ret = RS->getRetEffect(); - if (Ret.getObjKind() == ObjKind::CF && - (Ret.isOwned() || Ret.notOwned())) - ReturnCFAudited = true; - else if (!AuditedType(FuncDecl->getReturnType())) - return CF_BRIDGING_NONE; - } - - // At this point result type is audited for potential inclusion. - unsigned i = 0; - bool ArgCFAudited = false; - for (FunctionDecl::param_const_iterator pi = FuncDecl->param_begin(), - pe = FuncDecl->param_end(); pi != pe; ++pi, ++i) { - const ParmVarDecl *pd = *pi; - ArgEffect AE = RS->getArg(i); - if ((AE.getKind() == DecRef /*CFConsumed annotated*/ || - AE.getKind() == IncRef) && AE.getObjKind() == ObjKind::CF) { - if (AE.getKind() == DecRef && !pd->hasAttr<CFConsumedAttr>()) - ArgCFAudited = true; - else if (AE.getKind() == IncRef) - ArgCFAudited = true; - } else { - QualType AT = pd->getType(); - if (!AuditedType(AT)) { - AddCFAnnotations(Ctx, RS, FuncDecl, FuncIsReturnAnnotated); - return CF_BRIDGING_NONE; - } - } - } - if (ReturnCFAudited || ArgCFAudited) - return CF_BRIDGING_ENABLE; - - return CF_BRIDGING_MAY_INCLUDE; -} - -void ObjCMigrateASTConsumer::migrateARCSafeAnnotation(ASTContext &Ctx, - ObjCContainerDecl *CDecl) { - if (!isa<ObjCInterfaceDecl>(CDecl) || CDecl->isDeprecated()) - return; - - // migrate methods which can have instancetype as their result type. - for (const auto *Method : CDecl->methods()) - migrateCFAnnotation(Ctx, Method); -} - -void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx, - const RetainSummary *RS, - const ObjCMethodDecl *MethodDecl, - bool ResultAnnotated) { - // Annotate function. - if (!ResultAnnotated) { - RetEffect Ret = RS->getRetEffect(); - const char *AnnotationString = nullptr; - if (Ret.getObjKind() == ObjKind::CF) { - if (Ret.isOwned() && NSAPIObj->isMacroDefined("CF_RETURNS_RETAINED")) - AnnotationString = " CF_RETURNS_RETAINED"; - else if (Ret.notOwned() && - NSAPIObj->isMacroDefined("CF_RETURNS_NOT_RETAINED")) - AnnotationString = " CF_RETURNS_NOT_RETAINED"; - } - else if (Ret.getObjKind() == ObjKind::ObjC) { - ObjCMethodFamily OMF = MethodDecl->getMethodFamily(); - switch (OMF) { - case clang::OMF_alloc: - case clang::OMF_new: - case clang::OMF_copy: - case clang::OMF_init: - case clang::OMF_mutableCopy: - break; - - default: - if (Ret.isOwned() && NSAPIObj->isMacroDefined("NS_RETURNS_RETAINED")) - AnnotationString = " NS_RETURNS_RETAINED"; - break; - } - } - - if (AnnotationString) { - edit::Commit commit(*Editor); - commit.insertBefore(MethodDecl->getEndLoc(), AnnotationString); - Editor->commit(commit); - } - } - unsigned i = 0; - for (ObjCMethodDecl::param_const_iterator pi = MethodDecl->param_begin(), - pe = MethodDecl->param_end(); pi != pe; ++pi, ++i) { - const ParmVarDecl *pd = *pi; - ArgEffect AE = RS->getArg(i); - if (AE.getKind() == DecRef - && AE.getObjKind() == ObjKind::CF - && !pd->hasAttr<CFConsumedAttr>() && - NSAPIObj->isMacroDefined("CF_CONSUMED")) { - edit::Commit commit(*Editor); - commit.insertBefore(pd->getLocation(), "CF_CONSUMED "); - Editor->commit(commit); - } - } -} - -void ObjCMigrateASTConsumer::migrateAddMethodAnnotation( - ASTContext &Ctx, - const ObjCMethodDecl *MethodDecl) { - if (MethodDecl->hasBody() || MethodDecl->isImplicit()) - return; - - const RetainSummary *RS = - getSummaryManager(Ctx).getSummary(AnyCall(MethodDecl)); - - bool MethodIsReturnAnnotated = - (MethodDecl->hasAttr<CFReturnsRetainedAttr>() || - MethodDecl->hasAttr<CFReturnsNotRetainedAttr>() || - MethodDecl->hasAttr<NSReturnsRetainedAttr>() || - MethodDecl->hasAttr<NSReturnsNotRetainedAttr>() || - MethodDecl->hasAttr<NSReturnsAutoreleasedAttr>()); - - if (RS->getReceiverEffect().getKind() == DecRef && - !MethodDecl->hasAttr<NSConsumesSelfAttr>() && - MethodDecl->getMethodFamily() != OMF_init && - MethodDecl->getMethodFamily() != OMF_release && - NSAPIObj->isMacroDefined("NS_CONSUMES_SELF")) { - edit::Commit commit(*Editor); - commit.insertBefore(MethodDecl->getEndLoc(), " NS_CONSUMES_SELF"); - Editor->commit(commit); - } - - // Trivial case of when function is annotated and has no argument. - if (MethodIsReturnAnnotated && - (MethodDecl->param_begin() == MethodDecl->param_end())) - return; - - if (!MethodIsReturnAnnotated) { - RetEffect Ret = RS->getRetEffect(); - if ((Ret.getObjKind() == ObjKind::CF || - Ret.getObjKind() == ObjKind::ObjC) && - (Ret.isOwned() || Ret.notOwned())) { - AddCFAnnotations(Ctx, RS, MethodDecl, false); - return; - } else if (!AuditedType(MethodDecl->getReturnType())) - return; - } - - // At this point result type is either annotated or audited. - unsigned i = 0; - for (ObjCMethodDecl::param_const_iterator pi = MethodDecl->param_begin(), - pe = MethodDecl->param_end(); pi != pe; ++pi, ++i) { - const ParmVarDecl *pd = *pi; - ArgEffect AE = RS->getArg(i); - if ((AE.getKind() == DecRef && !pd->hasAttr<CFConsumedAttr>()) || - AE.getKind() == IncRef || !AuditedType(pd->getType())) { - AddCFAnnotations(Ctx, RS, MethodDecl, MethodIsReturnAnnotated); - return; - } - } -} - -namespace { -class SuperInitChecker : public RecursiveASTVisitor<SuperInitChecker> { -public: - bool shouldVisitTemplateInstantiations() const { return false; } - bool shouldWalkTypesOfTypeLocs() const { return false; } - - bool VisitObjCMessageExpr(ObjCMessageExpr *E) { - if (E->getReceiverKind() == ObjCMessageExpr::SuperInstance) { - if (E->getMethodFamily() == OMF_init) - return false; - } - return true; - } -}; -} // end anonymous namespace - -static bool hasSuperInitCall(const ObjCMethodDecl *MD) { - return !SuperInitChecker().TraverseStmt(MD->getBody()); -} - -void ObjCMigrateASTConsumer::inferDesignatedInitializers( - ASTContext &Ctx, - const ObjCImplementationDecl *ImplD) { - - const ObjCInterfaceDecl *IFace = ImplD->getClassInterface(); - if (!IFace || IFace->hasDesignatedInitializers()) - return; - if (!NSAPIObj->isMacroDefined("NS_DESIGNATED_INITIALIZER")) - return; - - for (const auto *MD : ImplD->instance_methods()) { - if (MD->isDeprecated() || - MD->getMethodFamily() != OMF_init || - MD->isDesignatedInitializerForTheInterface()) - continue; - const ObjCMethodDecl *IFaceM = IFace->getMethod(MD->getSelector(), - /*isInstance=*/true); - if (!IFaceM) - continue; - if (hasSuperInitCall(MD)) { - edit::Commit commit(*Editor); - commit.insert(IFaceM->getEndLoc(), " NS_DESIGNATED_INITIALIZER"); - Editor->commit(commit); - } - } -} - -bool ObjCMigrateASTConsumer::InsertFoundation(ASTContext &Ctx, - SourceLocation Loc) { - if (FoundationIncluded) - return true; - if (Loc.isInvalid()) - return false; - auto *nsEnumId = &Ctx.Idents.get("NS_ENUM"); - if (PP.getMacroDefinitionAtLoc(nsEnumId, Loc)) { - FoundationIncluded = true; - return true; - } - edit::Commit commit(*Editor); - if (Ctx.getLangOpts().Modules) - commit.insert(Loc, "#ifndef NS_ENUM\n@import Foundation;\n#endif\n"); - else - commit.insert(Loc, "#ifndef NS_ENUM\n#import <Foundation/Foundation.h>\n#endif\n"); - Editor->commit(commit); - FoundationIncluded = true; - return true; -} - -namespace { - -class RewritesReceiver : public edit::EditsReceiver { - Rewriter &Rewrite; - -public: - RewritesReceiver(Rewriter &Rewrite) : Rewrite(Rewrite) { } - - void insert(SourceLocation loc, StringRef text) override { - Rewrite.InsertText(loc, text); - } - void replace(CharSourceRange range, StringRef text) override { - Rewrite.ReplaceText(range.getBegin(), Rewrite.getRangeSize(range), text); - } -}; - -class JSONEditWriter : public edit::EditsReceiver { - SourceManager &SourceMgr; - llvm::raw_ostream &OS; - -public: - JSONEditWriter(SourceManager &SM, llvm::raw_ostream &OS) - : SourceMgr(SM), OS(OS) { - OS << "[\n"; - } - ~JSONEditWriter() override { OS << "]\n"; } - -private: - struct EntryWriter { - SourceManager &SourceMgr; - llvm::raw_ostream &OS; - - EntryWriter(SourceManager &SM, llvm::raw_ostream &OS) - : SourceMgr(SM), OS(OS) { - OS << " {\n"; - } - ~EntryWriter() { - OS << " },\n"; - } - - void writeLoc(SourceLocation Loc) { - FileID FID; - unsigned Offset; - std::tie(FID, Offset) = SourceMgr.getDecomposedLoc(Loc); - assert(FID.isValid()); - SmallString<200> Path = - StringRef(SourceMgr.getFileEntryRefForID(FID)->getName()); - llvm::sys::fs::make_absolute(Path); - OS << " \"file\": \""; - OS.write_escaped(Path.str()) << "\",\n"; - OS << " \"offset\": " << Offset << ",\n"; - } - - void writeRemove(CharSourceRange Range) { - assert(Range.isCharRange()); - std::pair<FileID, unsigned> Begin = - SourceMgr.getDecomposedLoc(Range.getBegin()); - std::pair<FileID, unsigned> End = - SourceMgr.getDecomposedLoc(Range.getEnd()); - assert(Begin.first == End.first); - assert(Begin.second <= End.second); - unsigned Length = End.second - Begin.second; - - OS << " \"remove\": " << Length << ",\n"; - } - - void writeText(StringRef Text) { - OS << " \"text\": \""; - OS.write_escaped(Text) << "\",\n"; - } - }; - - void insert(SourceLocation Loc, StringRef Text) override { - EntryWriter Writer(SourceMgr, OS); - Writer.writeLoc(Loc); - Writer.writeText(Text); - } - - void replace(CharSourceRange Range, StringRef Text) override { - EntryWriter Writer(SourceMgr, OS); - Writer.writeLoc(Range.getBegin()); - Writer.writeRemove(Range); - Writer.writeText(Text); - } - - void remove(CharSourceRange Range) override { - EntryWriter Writer(SourceMgr, OS); - Writer.writeLoc(Range.getBegin()); - Writer.writeRemove(Range); - } -}; - -} // end anonymous namespace - -void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) { - - TranslationUnitDecl *TU = Ctx.getTranslationUnitDecl(); - if (ASTMigrateActions & FrontendOptions::ObjCMT_MigrateDecls) { - for (DeclContext::decl_iterator D = TU->decls_begin(), DEnd = TU->decls_end(); - D != DEnd; ++D) { - FileID FID = PP.getSourceManager().getFileID((*D)->getLocation()); - if (FID.isValid()) - if (FileId.isValid() && FileId != FID) { - if (ASTMigrateActions & FrontendOptions::ObjCMT_Annotation) - AnnotateImplicitBridging(Ctx); - } - - if (ObjCInterfaceDecl *CDecl = dyn_cast<ObjCInterfaceDecl>(*D)) - if (canModify(CDecl)) - migrateObjCContainerDecl(Ctx, CDecl); - if (ObjCCategoryDecl *CatDecl = dyn_cast<ObjCCategoryDecl>(*D)) { - if (canModify(CatDecl)) - migrateObjCContainerDecl(Ctx, CatDecl); - } - else if (ObjCProtocolDecl *PDecl = dyn_cast<ObjCProtocolDecl>(*D)) { - ObjCProtocolDecls.insert(PDecl->getCanonicalDecl()); - if (canModify(PDecl)) - migrateObjCContainerDecl(Ctx, PDecl); - } - else if (const ObjCImplementationDecl *ImpDecl = - dyn_cast<ObjCImplementationDecl>(*D)) { - if ((ASTMigrateActions & FrontendOptions::ObjCMT_ProtocolConformance) && - canModify(ImpDecl)) - migrateProtocolConformance(Ctx, ImpDecl); - } - else if (const EnumDecl *ED = dyn_cast<EnumDecl>(*D)) { - if (!(ASTMigrateActions & FrontendOptions::ObjCMT_NsMacros)) - continue; - if (!canModify(ED)) - continue; - DeclContext::decl_iterator N = D; - if (++N != DEnd) { - const TypedefDecl *TD = dyn_cast<TypedefDecl>(*N); - if (migrateNSEnumDecl(Ctx, ED, TD) && TD) - D++; - } - else - migrateNSEnumDecl(Ctx, ED, /*TypedefDecl */nullptr); - } - else if (const TypedefDecl *TD = dyn_cast<TypedefDecl>(*D)) { - if (!(ASTMigrateActions & FrontendOptions::ObjCMT_NsMacros)) - continue; - if (!canModify(TD)) - continue; - DeclContext::decl_iterator N = D; - if (++N == DEnd) - continue; - if (const EnumDecl *ED = dyn_cast<EnumDecl>(*N)) { - if (canModify(ED)) { - if (++N != DEnd) - if (const TypedefDecl *TDF = dyn_cast<TypedefDecl>(*N)) { - // prefer typedef-follows-enum to enum-follows-typedef pattern. - if (migrateNSEnumDecl(Ctx, ED, TDF)) { - ++D; ++D; - CacheObjCNSIntegerTypedefed(TD); - continue; - } - } - if (migrateNSEnumDecl(Ctx, ED, TD)) { - ++D; - continue; - } - } - } - CacheObjCNSIntegerTypedefed(TD); - } - else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(*D)) { - if ((ASTMigrateActions & FrontendOptions::ObjCMT_Annotation) && - canModify(FD)) - migrateCFAnnotation(Ctx, FD); - } - - if (ObjCContainerDecl *CDecl = dyn_cast<ObjCContainerDecl>(*D)) { - bool CanModify = canModify(CDecl); - // migrate methods which can have instancetype as their result type. - if ((ASTMigrateActions & FrontendOptions::ObjCMT_Instancetype) && - CanModify) - migrateAllMethodInstaceType(Ctx, CDecl); - // annotate methods with CF annotations. - if ((ASTMigrateActions & FrontendOptions::ObjCMT_Annotation) && - CanModify) - migrateARCSafeAnnotation(Ctx, CDecl); - } - - if (const ObjCImplementationDecl * - ImplD = dyn_cast<ObjCImplementationDecl>(*D)) { - if ((ASTMigrateActions & FrontendOptions::ObjCMT_DesignatedInitializer) && - canModify(ImplD)) - inferDesignatedInitializers(Ctx, ImplD); - } - } - if (ASTMigrateActions & FrontendOptions::ObjCMT_Annotation) - AnnotateImplicitBridging(Ctx); - } - - if (IsOutputFile) { - std::error_code EC; - llvm::raw_fd_ostream OS(MigrateDir, EC, llvm::sys::fs::OF_None); - if (EC) { - DiagnosticsEngine &Diags = Ctx.getDiagnostics(); - Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Error, "%0")) - << EC.message(); - return; - } - - JSONEditWriter Writer(Ctx.getSourceManager(), OS); - Editor->applyRewrites(Writer); - return; - } - - Rewriter rewriter(Ctx.getSourceManager(), Ctx.getLangOpts()); - RewritesReceiver Rec(rewriter); - Editor->applyRewrites(Rec); - - for (Rewriter::buffer_iterator - I = rewriter.buffer_begin(), E = rewriter.buffer_end(); I != E; ++I) { - FileID FID = I->first; - RewriteBuffer &buf = I->second; - OptionalFileEntryRef file = - Ctx.getSourceManager().getFileEntryRefForID(FID); - assert(file); - SmallString<512> newText; - llvm::raw_svector_ostream vecOS(newText); - buf.write(vecOS); - std::unique_ptr<llvm::MemoryBuffer> memBuf( - llvm::MemoryBuffer::getMemBufferCopy(newText.str(), file->getName())); - SmallString<64> filePath(file->getName()); - FileMgr.FixupRelativePath(filePath); - Remapper.remap(filePath.str(), std::move(memBuf)); - } - - if (IsOutputFile) { - Remapper.flushToFile(MigrateDir, Ctx.getDiagnostics()); - } else { - Remapper.flushToDisk(MigrateDir, Ctx.getDiagnostics()); - } -} - -bool MigrateSourceAction::BeginInvocation(CompilerInstance &CI) { - CI.getDiagnostics().setIgnoreAllWarnings(true); - return true; -} - -static std::vector<std::string> getAllowListFilenames(StringRef DirPath) { - using namespace llvm::sys::fs; - using namespace llvm::sys::path; - - std::vector<std::string> Filenames; - if (DirPath.empty() || !is_directory(DirPath)) - return Filenames; - - std::error_code EC; - directory_iterator DI = directory_iterator(DirPath, EC); - directory_iterator DE; - for (; !EC && DI != DE; DI = DI.increment(EC)) { - if (is_regular_file(DI->path())) - Filenames.push_back(std::string(filename(DI->path()))); - } - - return Filenames; -} - -std::unique_ptr<ASTConsumer> -MigrateSourceAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { - PPConditionalDirectiveRecord * - PPRec = new PPConditionalDirectiveRecord(CI.getSourceManager()); - unsigned ObjCMTAction = CI.getFrontendOpts().ObjCMTAction; - unsigned ObjCMTOpts = ObjCMTAction; - // These are companion flags, they do not enable transformations. - ObjCMTOpts &= ~(FrontendOptions::ObjCMT_AtomicProperty | - FrontendOptions::ObjCMT_NsAtomicIOSOnlyProperty); - if (ObjCMTOpts == FrontendOptions::ObjCMT_None) { - // If no specific option was given, enable literals+subscripting transforms - // by default. - ObjCMTAction |= - FrontendOptions::ObjCMT_Literals | FrontendOptions::ObjCMT_Subscripting; - } - CI.getPreprocessor().addPPCallbacks(std::unique_ptr<PPCallbacks>(PPRec)); - std::vector<std::string> AllowList = - getAllowListFilenames(CI.getFrontendOpts().ObjCMTAllowListPath); - return std::make_unique<ObjCMigrateASTConsumer>( - CI.getFrontendOpts().OutputFile, ObjCMTAction, Remapper, - CI.getFileManager(), PPRec, CI.getPreprocessor(), - /*isOutputFile=*/true, AllowList); -} - -namespace { -struct EditEntry { - OptionalFileEntryRef File; - unsigned Offset = 0; - unsigned RemoveLen = 0; - std::string Text; -}; -} // end anonymous namespace - -namespace llvm { -template<> struct DenseMapInfo<EditEntry> { - static inline EditEntry getEmptyKey() { - EditEntry Entry; - Entry.Offset = unsigned(-1); - return Entry; - } - static inline EditEntry getTombstoneKey() { - EditEntry Entry; - Entry.Offset = unsigned(-2); - return Entry; - } - static unsigned getHashValue(const EditEntry& Val) { - return (unsigned)llvm::hash_combine(Val.File, Val.Offset, Val.RemoveLen, - Val.Text); - } - static bool isEqual(const EditEntry &LHS, const EditEntry &RHS) { - return LHS.File == RHS.File && - LHS.Offset == RHS.Offset && - LHS.RemoveLen == RHS.RemoveLen && - LHS.Text == RHS.Text; - } -}; -} // end namespace llvm - -namespace { -class RemapFileParser { - FileManager &FileMgr; - -public: - RemapFileParser(FileManager &FileMgr) : FileMgr(FileMgr) { } - - bool parse(StringRef File, SmallVectorImpl<EditEntry> &Entries) { - using namespace llvm::yaml; - - llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileBufOrErr = - llvm::MemoryBuffer::getFile(File); - if (!FileBufOrErr) - return true; - - llvm::SourceMgr SM; - Stream YAMLStream(FileBufOrErr.get()->getMemBufferRef(), SM); - document_iterator I = YAMLStream.begin(); - if (I == YAMLStream.end()) - return true; - Node *Root = I->getRoot(); - if (!Root) - return true; - - SequenceNode *SeqNode = dyn_cast<SequenceNode>(Root); - if (!SeqNode) - return true; - - for (SequenceNode::iterator - AI = SeqNode->begin(), AE = SeqNode->end(); AI != AE; ++AI) { - MappingNode *MapNode = dyn_cast<MappingNode>(&*AI); - if (!MapNode) - continue; - parseEdit(MapNode, Entries); - } - - return false; - } - -private: - void parseEdit(llvm::yaml::MappingNode *Node, - SmallVectorImpl<EditEntry> &Entries) { - using namespace llvm::yaml; - EditEntry Entry; - bool Ignore = false; - - for (MappingNode::iterator - KVI = Node->begin(), KVE = Node->end(); KVI != KVE; ++KVI) { - ScalarNode *KeyString = dyn_cast<ScalarNode>((*KVI).getKey()); - if (!KeyString) - continue; - SmallString<10> KeyStorage; - StringRef Key = KeyString->getValue(KeyStorage); - - ScalarNode *ValueString = dyn_cast<ScalarNode>((*KVI).getValue()); - if (!ValueString) - continue; - SmallString<64> ValueStorage; - StringRef Val = ValueString->getValue(ValueStorage); - - if (Key == "file") { - if (auto File = FileMgr.getOptionalFileRef(Val)) - Entry.File = File; - else - Ignore = true; - } else if (Key == "offset") { - if (Val.getAsInteger(10, Entry.Offset)) - Ignore = true; - } else if (Key == "remove") { - if (Val.getAsInteger(10, Entry.RemoveLen)) - Ignore = true; - } else if (Key == "text") { - Entry.Text = std::string(Val); - } - } - - if (!Ignore) - Entries.push_back(Entry); - } -}; -} // end anonymous namespace - -static bool reportDiag(const Twine &Err, DiagnosticsEngine &Diag) { - Diag.Report(Diag.getCustomDiagID(DiagnosticsEngine::Error, "%0")) - << Err.str(); - return true; -} - -static std::string applyEditsToTemp(FileEntryRef FE, - ArrayRef<EditEntry> Edits, - FileManager &FileMgr, - DiagnosticsEngine &Diag) { - using namespace llvm::sys; - - SourceManager SM(Diag, FileMgr); - FileID FID = SM.createFileID(FE, SourceLocation(), SrcMgr::C_User); - LangOptions LangOpts; - edit::EditedSource Editor(SM, LangOpts); - for (ArrayRef<EditEntry>::iterator - I = Edits.begin(), E = Edits.end(); I != E; ++I) { - const EditEntry &Entry = *I; - assert(Entry.File == FE); - SourceLocation Loc = - SM.getLocForStartOfFile(FID).getLocWithOffset(Entry.Offset); - CharSourceRange Range; - if (Entry.RemoveLen != 0) { - Range = CharSourceRange::getCharRange(Loc, - Loc.getLocWithOffset(Entry.RemoveLen)); - } - - edit::Commit commit(Editor); - if (Range.isInvalid()) { - commit.insert(Loc, Entry.Text); - } else if (Entry.Text.empty()) { - commit.remove(Range); - } else { - commit.replace(Range, Entry.Text); - } - Editor.commit(commit); - } - - Rewriter rewriter(SM, LangOpts); - RewritesReceiver Rec(rewriter); - Editor.applyRewrites(Rec, /*adjustRemovals=*/false); - - const RewriteBuffer *Buf = rewriter.getRewriteBufferFor(FID); - SmallString<512> NewText; - llvm::raw_svector_ostream OS(NewText); - Buf->write(OS); - - SmallString<64> TempPath; - int FD; - if (fs::createTemporaryFile(path::filename(FE.getName()), - path::extension(FE.getName()).drop_front(), FD, - TempPath)) { - reportDiag("Could not create file: " + TempPath.str(), Diag); - return std::string(); - } - - llvm::raw_fd_ostream TmpOut(FD, /*shouldClose=*/true); - TmpOut.write(NewText.data(), NewText.size()); - TmpOut.close(); - - return std::string(TempPath); -} - -bool arcmt::getFileRemappingsFromFileList( - std::vector<std::pair<std::string,std::string> > &remap, - ArrayRef<StringRef> remapFiles, - DiagnosticConsumer *DiagClient) { - bool hasErrorOccurred = false; - - FileSystemOptions FSOpts; - FileManager FileMgr(FSOpts); - RemapFileParser Parser(FileMgr); - - IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs()); - IntrusiveRefCntPtr<DiagnosticsEngine> Diags( - new DiagnosticsEngine(DiagID, new DiagnosticOptions, - DiagClient, /*ShouldOwnClient=*/false)); - - typedef llvm::DenseMap<FileEntryRef, std::vector<EditEntry> > - FileEditEntriesTy; - FileEditEntriesTy FileEditEntries; - - llvm::DenseSet<EditEntry> EntriesSet; - - for (ArrayRef<StringRef>::iterator - I = remapFiles.begin(), E = remapFiles.end(); I != E; ++I) { - SmallVector<EditEntry, 16> Entries; - if (Parser.parse(*I, Entries)) - continue; - - for (SmallVectorImpl<EditEntry>::iterator - EI = Entries.begin(), EE = Entries.end(); EI != EE; ++EI) { - EditEntry &Entry = *EI; - if (!Entry.File) - continue; - std::pair<llvm::DenseSet<EditEntry>::iterator, bool> - Insert = EntriesSet.insert(Entry); - if (!Insert.second) - continue; - - FileEditEntries[*Entry.File].push_back(Entry); - } - } - - for (FileEditEntriesTy::iterator - I = FileEditEntries.begin(), E = FileEditEntries.end(); I != E; ++I) { - std::string TempFile = applyEditsToTemp(I->first, I->second, - FileMgr, *Diags); - if (TempFile.empty()) { - hasErrorOccurred = true; - continue; - } - - remap.emplace_back(std::string(I->first.getName()), TempFile); - } - - return hasErrorOccurred; -} diff --git clang/lib/ARCMigrate/PlistReporter.cpp clang/lib/ARCMigrate/PlistReporter.cpp deleted file mode 100644 index f78ca5e1c9bd..000000000000 --- clang/lib/ARCMigrate/PlistReporter.cpp +++ /dev/null @@ -1,124 +0,0 @@ -//===--- PlistReporter.cpp - ARC Migrate Tool Plist Reporter ----*- 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 "Internals.h" -#include "clang/Basic/FileManager.h" -#include "clang/Basic/PlistSupport.h" -#include "clang/Basic/SourceManager.h" -#include "clang/Lex/Lexer.h" -using namespace clang; -using namespace arcmt; -using namespace markup; - -static StringRef getLevelName(DiagnosticsEngine::Level Level) { - switch (Level) { - case DiagnosticsEngine::Ignored: - llvm_unreachable("ignored"); - case DiagnosticsEngine::Note: - return "note"; - case DiagnosticsEngine::Remark: - case DiagnosticsEngine::Warning: - return "warning"; - case DiagnosticsEngine::Fatal: - case DiagnosticsEngine::Error: - return "error"; - } - llvm_unreachable("Invalid DiagnosticsEngine level!"); -} - -void arcmt::writeARCDiagsToPlist(const std::string &outPath, - ArrayRef<StoredDiagnostic> diags, - SourceManager &SM, - const LangOptions &LangOpts) { - DiagnosticIDs DiagIDs; - - // Build up a set of FIDs that we use by scanning the locations and - // ranges of the diagnostics. - FIDMap FM; - SmallVector<FileID, 10> Fids; - - for (ArrayRef<StoredDiagnostic>::iterator - I = diags.begin(), E = diags.end(); I != E; ++I) { - const StoredDiagnostic &D = *I; - - AddFID(FM, Fids, SM, D.getLocation()); - - for (StoredDiagnostic::range_iterator - RI = D.range_begin(), RE = D.range_end(); RI != RE; ++RI) { - AddFID(FM, Fids, SM, RI->getBegin()); - AddFID(FM, Fids, SM, RI->getEnd()); - } - } - - std::error_code EC; - llvm::raw_fd_ostream o(outPath, EC, llvm::sys::fs::OF_TextWithCRLF); - if (EC) { - llvm::errs() << "error: could not create file: " << outPath << '\n'; - return; - } - - EmitPlistHeader(o); - - // Write the root object: a <dict> containing... - // - "files", an <array> mapping from FIDs to file names - // - "diagnostics", an <array> containing the diagnostics - o << "<dict>\n" - " <key>files</key>\n" - " <array>\n"; - - for (FileID FID : Fids) - EmitString(o << " ", SM.getFileEntryRefForID(FID)->getName()) << '\n'; - - o << " </array>\n" - " <key>diagnostics</key>\n" - " <array>\n"; - - for (ArrayRef<StoredDiagnostic>::iterator - DI = diags.begin(), DE = diags.end(); DI != DE; ++DI) { - - const StoredDiagnostic &D = *DI; - - if (D.getLevel() == DiagnosticsEngine::Ignored) - continue; - - o << " <dict>\n"; - - // Output the diagnostic. - o << " <key>description</key>"; - EmitString(o, D.getMessage()) << '\n'; - o << " <key>category</key>"; - EmitString(o, DiagIDs.getCategoryNameFromID( - DiagIDs.getCategoryNumberForDiag(D.getID()))) << '\n'; - o << " <key>type</key>"; - EmitString(o, getLevelName(D.getLevel())) << '\n'; - - // Output the location of the bug. - o << " <key>location</key>\n"; - EmitLocation(o, SM, D.getLocation(), FM, 2); - - // Output the ranges (if any). - if (!D.getRanges().empty()) { - o << " <key>ranges</key>\n"; - o << " <array>\n"; - for (auto &R : D.getRanges()) { - CharSourceRange ExpansionRange = SM.getExpansionRange(R); - EmitRange(o, SM, Lexer::getAsCharRange(ExpansionRange, SM, LangOpts), - FM, 4); - } - o << " </array>\n"; - } - - // Close up the entry. - o << " </dict>\n"; - } - - o << " </array>\n"; - - // Finish. - o << "</dict>\n</plist>\n"; -} diff --git clang/lib/ARCMigrate/TransAPIUses.cpp clang/lib/ARCMigrate/TransAPIUses.cpp deleted file mode 100644 index 8f5d4f4bde06..000000000000 --- clang/lib/ARCMigrate/TransAPIUses.cpp +++ /dev/null @@ -1,107 +0,0 @@ -//===--- TransAPIUses.cpp - Transformations to ARC mode -------------------===// -// -// 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 -// -//===----------------------------------------------------------------------===// -// -// checkAPIUses: -// -// Emits error/fix with some API uses that are obsolete or not safe in ARC mode: -// -// - NSInvocation's [get/set]ReturnValue and [get/set]Argument are only safe -// with __unsafe_unretained objects. -// - Calling -zone gets replaced with 'nil'. -// -//===----------------------------------------------------------------------===// - -#include "Transforms.h" -#include "Internals.h" -#include "clang/AST/ASTContext.h" -#include "clang/Sema/SemaDiagnostic.h" - -using namespace clang; -using namespace arcmt; -using namespace trans; - -namespace { - -class APIChecker : public RecursiveASTVisitor<APIChecker> { - MigrationPass &Pass; - - Selector getReturnValueSel, setReturnValueSel; - Selector getArgumentSel, setArgumentSel; - - Selector zoneSel; -public: - APIChecker(MigrationPass &pass) : Pass(pass) { - SelectorTable &sels = Pass.Ctx.Selectors; - IdentifierTable &ids = Pass.Ctx.Idents; - getReturnValueSel = sels.getUnarySelector(&ids.get("getReturnValue")); - setReturnValueSel = sels.getUnarySelector(&ids.get("setReturnValue")); - - const IdentifierInfo *selIds[2]; - selIds[0] = &ids.get("getArgument"); - selIds[1] = &ids.get("atIndex"); - getArgumentSel = sels.getSelector(2, selIds); - selIds[0] = &ids.get("setArgument"); - setArgumentSel = sels.getSelector(2, selIds); - - zoneSel = sels.getNullarySelector(&ids.get("zone")); - } - - bool VisitObjCMessageExpr(ObjCMessageExpr *E) { - // NSInvocation. - if (E->isInstanceMessage() && - E->getReceiverInterface() && - E->getReceiverInterface()->getName() == "NSInvocation") { - StringRef selName; - if (E->getSelector() == getReturnValueSel) - selName = "getReturnValue"; - else if (E->getSelector() == setReturnValueSel) - selName = "setReturnValue"; - else if (E->getSelector() == getArgumentSel) - selName = "getArgument"; - else if (E->getSelector() == setArgumentSel) - selName = "setArgument"; - else - return true; - - Expr *parm = E->getArg(0)->IgnoreParenCasts(); - QualType pointee = parm->getType()->getPointeeType(); - if (pointee.isNull()) - return true; - - if (pointee.getObjCLifetime() > Qualifiers::OCL_ExplicitNone) - Pass.TA.report(parm->getBeginLoc(), - diag::err_arcmt_nsinvocation_ownership, - parm->getSourceRange()) - << selName; - - return true; - } - - // -zone. - if (E->isInstanceMessage() && - E->getInstanceReceiver() && - E->getSelector() == zoneSel && - Pass.TA.hasDiagnostic(diag::err_unavailable, - diag::err_unavailable_message, - E->getSelectorLoc(0))) { - // Calling -zone is meaningless in ARC, change it to nil. - Transaction Trans(Pass.TA); - Pass.TA.clearDiagnostic(diag::err_unavailable, - diag::err_unavailable_message, - E->getSelectorLoc(0)); - Pass.TA.replace(E->getSourceRange(), getNilString(Pass)); - } - return true; - } -}; - -} // anonymous namespace - -void trans::checkAPIUses(MigrationPass &pass) { - APIChecker(pass).TraverseDecl(pass.Ctx.getTranslationUnitDecl()); -} diff --git clang/lib/ARCMigrate/TransARCAssign.cpp clang/lib/ARCMigrate/TransARCAssign.cpp deleted file mode 100644 index d1d5b9e014b1..000000000000 --- clang/lib/ARCMigrate/TransARCAssign.cpp +++ /dev/null @@ -1,77 +0,0 @@ -//===--- TransARCAssign.cpp - Transformations to ARC mode -----------------===// -// -// 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 -// -//===----------------------------------------------------------------------===// -// -// makeAssignARCSafe: -// -// Add '__strong' where appropriate. -// -// for (id x in collection) { -// x = 0; -// } -// ----> -// for (__strong id x in collection) { -// x = 0; -// } -// -//===----------------------------------------------------------------------===// - -#include "Transforms.h" -#include "Internals.h" -#include "clang/AST/ASTContext.h" -#include "clang/Sema/SemaDiagnostic.h" - -using namespace clang; -using namespace arcmt; -using namespace trans; - -namespace { - -class ARCAssignChecker : public RecursiveASTVisitor<ARCAssignChecker> { - MigrationPass &Pass; - llvm::DenseSet<VarDecl *> ModifiedVars; - -public: - ARCAssignChecker(MigrationPass &pass) : Pass(pass) { } - - bool VisitBinaryOperator(BinaryOperator *Exp) { - if (Exp->getType()->isDependentType()) - return true; - - Expr *E = Exp->getLHS(); - SourceLocation OrigLoc = E->getExprLoc(); - SourceLocation Loc = OrigLoc; - DeclRefExpr *declRef = dyn_cast<DeclRefExpr>(E->IgnoreParenCasts()); - if (declRef && isa<VarDecl>(declRef->getDecl())) { - ASTContext &Ctx = Pass.Ctx; - Expr::isModifiableLvalueResult IsLV = E->isModifiableLvalue(Ctx, &Loc); - if (IsLV != Expr::MLV_ConstQualified) - return true; - VarDecl *var = cast<VarDecl>(declRef->getDecl()); - if (var->isARCPseudoStrong()) { - Transaction Trans(Pass.TA); - if (Pass.TA.clearDiagnostic(diag::err_typecheck_arr_assign_enumeration, - Exp->getOperatorLoc())) { - if (!ModifiedVars.count(var)) { - TypeLoc TLoc = var->getTypeSourceInfo()->getTypeLoc(); - Pass.TA.insert(TLoc.getBeginLoc(), "__strong "); - ModifiedVars.insert(var); - } - } - } - } - - return true; - } -}; - -} // anonymous namespace - -void trans::makeAssignARCSafe(MigrationPass &pass) { - ARCAssignChecker assignCheck(pass); - assignCheck.TraverseDecl(pass.Ctx.getTranslationUnitDecl()); -} diff --git clang/lib/ARCMigrate/TransAutoreleasePool.cpp clang/lib/ARCMigrate/TransAutoreleasePool.cpp deleted file mode 100644 index 6d501228e712..000000000000 --- clang/lib/ARCMigrate/TransAutoreleasePool.cpp +++ /dev/null @@ -1,435 +0,0 @@ -//===--- TransAutoreleasePool.cpp - Transformations to ARC mode -----------===// -// -// 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 -// -//===----------------------------------------------------------------------===// -// -// rewriteAutoreleasePool: -// -// Calls to NSAutoreleasePools will be rewritten as an @autorelease scope. -// -// NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; -// ... -// [pool release]; -// ----> -// @autorelease { -// ... -// } -// -// An NSAutoreleasePool will not be touched if: -// - There is not a corresponding -release/-drain in the same scope -// - Not all references of the NSAutoreleasePool variable can be removed -// - There is a variable that is declared inside the intended @autorelease scope -// which is also used outside it. -// -//===----------------------------------------------------------------------===// - -#include "Transforms.h" -#include "Internals.h" -#include "clang/AST/ASTContext.h" -#include "clang/Basic/SourceManager.h" -#include "clang/Sema/SemaDiagnostic.h" -#include <map> - -using namespace clang; -using namespace arcmt; -using namespace trans; - -namespace { - -class ReleaseCollector : public RecursiveASTVisitor<ReleaseCollector> { - Decl *Dcl; - SmallVectorImpl<ObjCMessageExpr *> &Releases; - -public: - ReleaseCollector(Decl *D, SmallVectorImpl<ObjCMessageExpr *> &releases) - : Dcl(D), Releases(releases) { } - - bool VisitObjCMessageExpr(ObjCMessageExpr *E) { - if (!E->isInstanceMessage()) - return true; - if (E->getMethodFamily() != OMF_release) - return true; - Expr *instance = E->getInstanceReceiver()->IgnoreParenCasts(); - if (DeclRefExpr *DE = dyn_cast<DeclRefExpr>(instance)) { - if (DE->getDecl() == Dcl) - Releases.push_back(E); - } - return true; - } -}; - -} - -namespace { - -class AutoreleasePoolRewriter - : public RecursiveASTVisitor<AutoreleasePoolRewriter> { -public: - AutoreleasePoolRewriter(MigrationPass &pass) - : Body(nullptr), Pass(pass) { - PoolII = &pass.Ctx.Idents.get("NSAutoreleasePool"); - DrainSel = pass.Ctx.Selectors.getNullarySelector( - &pass.Ctx.Idents.get("drain")); - } - - void transformBody(Stmt *body, Decl *ParentD) { - Body = body; - TraverseStmt(body); - } - - ~AutoreleasePoolRewriter() { - SmallVector<VarDecl *, 8> VarsToHandle; - - for (std::map<VarDecl *, PoolVarInfo>::iterator - I = PoolVars.begin(), E = PoolVars.end(); I != E; ++I) { - VarDecl *var = I->first; - PoolVarInfo &info = I->second; - - // Check that we can handle/rewrite all references of the pool. - - clearRefsIn(info.Dcl, info.Refs); - for (SmallVectorImpl<PoolScope>::iterator - scpI = info.Scopes.begin(), - scpE = info.Scopes.end(); scpI != scpE; ++scpI) { - PoolScope &scope = *scpI; - clearRefsIn(*scope.Begin, info.Refs); - clearRefsIn(*scope.End, info.Refs); - clearRefsIn(scope.Releases.begin(), scope.Releases.end(), info.Refs); - } - - // Even if one reference is not handled we will not do anything about that - // pool variable. - if (info.Refs.empty()) - VarsToHandle.push_back(var); - } - - for (unsigned i = 0, e = VarsToHandle.size(); i != e; ++i) { - PoolVarInfo &info = PoolVars[VarsToHandle[i]]; - - Transaction Trans(Pass.TA); - - clearUnavailableDiags(info.Dcl); - Pass.TA.removeStmt(info.Dcl); - - // Add "@autoreleasepool { }" - for (SmallVectorImpl<PoolScope>::iterator - scpI = info.Scopes.begin(), - scpE = info.Scopes.end(); scpI != scpE; ++scpI) { - PoolScope &scope = *scpI; - clearUnavailableDiags(*scope.Begin); - clearUnavailableDiags(*scope.End); - if (scope.IsFollowedBySimpleReturnStmt) { - // Include the return in the scope. - Pass.TA.replaceStmt(*scope.Begin, "@autoreleasepool {"); - Pass.TA.removeStmt(*scope.End); - Stmt::child_iterator retI = scope.End; - ++retI; - SourceLocation afterSemi = - findLocationAfterSemi((*retI)->getEndLoc(), Pass.Ctx); - assert(afterSemi.isValid() && - "Didn't we check before setting IsFollowedBySimpleReturnStmt " - "to true?"); - Pass.TA.insertAfterToken(afterSemi, "\n}"); - Pass.TA.increaseIndentation( - SourceRange(scope.getIndentedRange().getBegin(), - (*retI)->getEndLoc()), - scope.CompoundParent->getBeginLoc()); - } else { - Pass.TA.replaceStmt(*scope.Begin, "@autoreleasepool {"); - Pass.TA.replaceStmt(*scope.End, "}"); - Pass.TA.increaseIndentation(scope.getIndentedRange(), - scope.CompoundParent->getBeginLoc()); - } - } - - // Remove rest of pool var references. - for (SmallVectorImpl<PoolScope>::iterator - scpI = info.Scopes.begin(), - scpE = info.Scopes.end(); scpI != scpE; ++scpI) { - PoolScope &scope = *scpI; - for (SmallVectorImpl<ObjCMessageExpr *>::iterator - relI = scope.Releases.begin(), - relE = scope.Releases.end(); relI != relE; ++relI) { - clearUnavailableDiags(*relI); - Pass.TA.removeStmt(*relI); - } - } - } - } - - bool VisitCompoundStmt(CompoundStmt *S) { - SmallVector<PoolScope, 4> Scopes; - - for (Stmt::child_iterator - I = S->body_begin(), E = S->body_end(); I != E; ++I) { - Stmt *child = getEssential(*I); - if (DeclStmt *DclS = dyn_cast<DeclStmt>(child)) { - if (DclS->isSingleDecl()) { - if (VarDecl *VD = dyn_cast<VarDecl>(DclS->getSingleDecl())) { - if (isNSAutoreleasePool(VD->getType())) { - PoolVarInfo &info = PoolVars[VD]; - info.Dcl = DclS; - collectRefs(VD, S, info.Refs); - // Does this statement follow the pattern: - // NSAutoreleasePool * pool = [NSAutoreleasePool new]; - if (isPoolCreation(VD->getInit())) { - Scopes.push_back(PoolScope()); - Scopes.back().PoolVar = VD; - Scopes.back().CompoundParent = S; - Scopes.back().Begin = I; - } - } - } - } - } else if (BinaryOperator *bop = dyn_cast<BinaryOperator>(child)) { - if (DeclRefExpr *dref = dyn_cast<DeclRefExpr>(bop->getLHS())) { - if (VarDecl *VD = dyn_cast<VarDecl>(dref->getDecl())) { - // Does this statement follow the pattern: - // pool = [NSAutoreleasePool new]; - if (isNSAutoreleasePool(VD->getType()) && - isPoolCreation(bop->getRHS())) { - Scopes.push_back(PoolScope()); - Scopes.back().PoolVar = VD; - Scopes.back().CompoundParent = S; - Scopes.back().Begin = I; - } - } - } - } - - if (Scopes.empty()) - continue; - - if (isPoolDrain(Scopes.back().PoolVar, child)) { - PoolScope &scope = Scopes.back(); - scope.End = I; - handlePoolScope(scope, S); - Scopes.pop_back(); - } - } - return true; - } - -private: - void clearUnavailableDiags(Stmt *S) { - if (S) - Pass.TA.clearDiagnostic(diag::err_unavailable, - diag::err_unavailable_message, - S->getSourceRange()); - } - - struct PoolScope { - VarDecl *PoolVar; - CompoundStmt *CompoundParent; - Stmt::child_iterator Begin; - Stmt::child_iterator End; - bool IsFollowedBySimpleReturnStmt; - SmallVector<ObjCMessageExpr *, 4> Releases; - - PoolScope() - : PoolVar(nullptr), CompoundParent(nullptr), - IsFollowedBySimpleReturnStmt(false) {} - - SourceRange getIndentedRange() const { - Stmt::child_iterator rangeS = Begin; - ++rangeS; - if (rangeS == End) - return SourceRange(); - Stmt::child_iterator rangeE = Begin; - for (Stmt::child_iterator I = rangeS; I != End; ++I) - ++rangeE; - return SourceRange((*rangeS)->getBeginLoc(), (*rangeE)->getEndLoc()); - } - }; - - class NameReferenceChecker : public RecursiveASTVisitor<NameReferenceChecker>{ - ASTContext &Ctx; - SourceRange ScopeRange; - SourceLocation &referenceLoc, &declarationLoc; - - public: - NameReferenceChecker(ASTContext &ctx, PoolScope &scope, - SourceLocation &referenceLoc, - SourceLocation &declarationLoc) - : Ctx(ctx), referenceLoc(referenceLoc), - declarationLoc(declarationLoc) { - ScopeRange = SourceRange((*scope.Begin)->getBeginLoc(), - (*scope.End)->getBeginLoc()); - } - - bool VisitDeclRefExpr(DeclRefExpr *E) { - return checkRef(E->getLocation(), E->getDecl()->getLocation()); - } - - bool VisitTypedefTypeLoc(TypedefTypeLoc TL) { - return checkRef(TL.getBeginLoc(), TL.getTypedefNameDecl()->getLocation()); - } - - bool VisitTagTypeLoc(TagTypeLoc TL) { - return checkRef(TL.getBeginLoc(), TL.getDecl()->getLocation()); - } - - private: - bool checkRef(SourceLocation refLoc, SourceLocation declLoc) { - if (isInScope(declLoc)) { - referenceLoc = refLoc; - declarationLoc = declLoc; - return false; - } - return true; - } - - bool isInScope(SourceLocation loc) { - if (loc.isInvalid()) - return false; - - SourceManager &SM = Ctx.getSourceManager(); - if (SM.isBeforeInTranslationUnit(loc, ScopeRange.getBegin())) - return false; - return SM.isBeforeInTranslationUnit(loc, ScopeRange.getEnd()); - } - }; - - void handlePoolScope(PoolScope &scope, CompoundStmt *compoundS) { - // Check that all names declared inside the scope are not used - // outside the scope. - { - bool nameUsedOutsideScope = false; - SourceLocation referenceLoc, declarationLoc; - Stmt::child_iterator SI = scope.End, SE = compoundS->body_end(); - ++SI; - // Check if the autoreleasepool scope is followed by a simple return - // statement, in which case we will include the return in the scope. - if (SI != SE) - if (ReturnStmt *retS = dyn_cast<ReturnStmt>(*SI)) - if ((retS->getRetValue() == nullptr || - isa<DeclRefExpr>(retS->getRetValue()->IgnoreParenCasts())) && - findLocationAfterSemi(retS->getEndLoc(), Pass.Ctx).isValid()) { - scope.IsFollowedBySimpleReturnStmt = true; - ++SI; // the return will be included in scope, don't check it. - } - - for (; SI != SE; ++SI) { - nameUsedOutsideScope = !NameReferenceChecker(Pass.Ctx, scope, - referenceLoc, - declarationLoc).TraverseStmt(*SI); - if (nameUsedOutsideScope) - break; - } - - // If not all references were cleared it means some variables/typenames/etc - // declared inside the pool scope are used outside of it. - // We won't try to rewrite the pool. - if (nameUsedOutsideScope) { - Pass.TA.reportError("a name is referenced outside the " - "NSAutoreleasePool scope that it was declared in", referenceLoc); - Pass.TA.reportNote("name declared here", declarationLoc); - Pass.TA.reportNote("intended @autoreleasepool scope begins here", - (*scope.Begin)->getBeginLoc()); - Pass.TA.reportNote("intended @autoreleasepool scope ends here", - (*scope.End)->getBeginLoc()); - return; - } - } - - // Collect all releases of the pool; they will be removed. - { - ReleaseCollector releaseColl(scope.PoolVar, scope.Releases); - Stmt::child_iterator I = scope.Begin; - ++I; - for (; I != scope.End; ++I) - releaseColl.TraverseStmt(*I); - } - - PoolVars[scope.PoolVar].Scopes.push_back(scope); - } - - bool isPoolCreation(Expr *E) { - if (!E) return false; - E = getEssential(E); - ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(E); - if (!ME) return false; - if (ME->getMethodFamily() == OMF_new && - ME->getReceiverKind() == ObjCMessageExpr::Class && - isNSAutoreleasePool(ME->getReceiverInterface())) - return true; - if (ME->getReceiverKind() == ObjCMessageExpr::Instance && - ME->getMethodFamily() == OMF_init) { - Expr *rec = getEssential(ME->getInstanceReceiver()); - if (ObjCMessageExpr *recME = dyn_cast_or_null<ObjCMessageExpr>(rec)) { - if (recME->getMethodFamily() == OMF_alloc && - recME->getReceiverKind() == ObjCMessageExpr::Class && - isNSAutoreleasePool(recME->getReceiverInterface())) - return true; - } - } - - return false; - } - - bool isPoolDrain(VarDecl *poolVar, Stmt *S) { - if (!S) return false; - S = getEssential(S); - ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(S); - if (!ME) return false; - if (ME->getReceiverKind() == ObjCMessageExpr::Instance) { - Expr *rec = getEssential(ME->getInstanceReceiver()); - if (DeclRefExpr *dref = dyn_cast<DeclRefExpr>(rec)) - if (dref->getDecl() == poolVar) - return ME->getMethodFamily() == OMF_release || - ME->getSelector() == DrainSel; - } - - return false; - } - - bool isNSAutoreleasePool(ObjCInterfaceDecl *IDecl) { - return IDecl && IDecl->getIdentifier() == PoolII; - } - - bool isNSAutoreleasePool(QualType Ty) { - QualType pointee = Ty->getPointeeType(); - if (pointee.isNull()) - return false; - if (const ObjCInterfaceType *interT = pointee->getAs<ObjCInterfaceType>()) - return isNSAutoreleasePool(interT->getDecl()); - return false; - } - - static Expr *getEssential(Expr *E) { - return cast<Expr>(getEssential((Stmt*)E)); - } - static Stmt *getEssential(Stmt *S) { - if (FullExpr *FE = dyn_cast<FullExpr>(S)) - S = FE->getSubExpr(); - if (Expr *E = dyn_cast<Expr>(S)) - S = E->IgnoreParenCasts(); - return S; - } - - Stmt *Body; - MigrationPass &Pass; - - IdentifierInfo *PoolII; - Selector DrainSel; - - struct PoolVarInfo { - DeclStmt *Dcl = nullptr; - ExprSet Refs; - SmallVector<PoolScope, 2> Scopes; - - PoolVarInfo() = default; - }; - - std::map<VarDecl *, PoolVarInfo> PoolVars; -}; - -} // anonymous namespace - -void trans::rewriteAutoreleasePool(MigrationPass &pass) { - BodyTransform<AutoreleasePoolRewriter> trans(pass); - trans.TraverseDecl(pass.Ctx.getTranslationUnitDecl()); -} diff --git clang/lib/ARCMigrate/TransBlockObjCVariable.cpp clang/lib/ARCMigrate/TransBlockObjCVariable.cpp deleted file mode 100644 index 1e4db33135b6..000000000000 --- clang/lib/ARCMigrate/TransBlockObjCVariable.cpp +++ /dev/null @@ -1,146 +0,0 @@ -//===--- TransBlockObjCVariable.cpp - Transformations to ARC mode ---------===// -// -// 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 -// -//===----------------------------------------------------------------------===// -// -// rewriteBlockObjCVariable: -// -// Adding __block to an obj-c variable could be either because the variable -// is used for output storage or the user wanted to break a retain cycle. -// This transformation checks whether a reference of the variable for the block -// is actually needed (it is assigned to or its address is taken) or not. -// If the reference is not needed it will assume __block was added to break a -// cycle so it will remove '__block' and add __weak/__unsafe_unretained. -// e.g -// -// __block Foo *x; -// bar(^ { [x cake]; }); -// ----> -// __weak Foo *x; -// bar(^ { [x cake]; }); -// -//===----------------------------------------------------------------------===// - -#include "Transforms.h" -#include "Internals.h" -#include "clang/AST/ASTContext.h" -#include "clang/AST/Attr.h" -#include "clang/Basic/SourceManager.h" - -using namespace clang; -using namespace arcmt; -using namespace trans; - -namespace { - -class RootBlockObjCVarRewriter : - public RecursiveASTVisitor<RootBlockObjCVarRewriter> { - llvm::DenseSet<VarDecl *> &VarsToChange; - - class BlockVarChecker : public RecursiveASTVisitor<BlockVarChecker> { - VarDecl *Var; - - typedef RecursiveASTVisitor<BlockVarChecker> base; - public: - BlockVarChecker(VarDecl *var) : Var(var) { } - - bool TraverseImplicitCastExpr(ImplicitCastExpr *castE) { - if (DeclRefExpr * - ref = dyn_cast<DeclRefExpr>(castE->getSubExpr())) { - if (ref->getDecl() == Var) { - if (castE->getCastKind() == CK_LValueToRValue) - return true; // Using the value of the variable. - if (castE->getCastKind() == CK_NoOp && castE->isLValue() && - Var->getASTContext().getLangOpts().CPlusPlus) - return true; // Binding to const C++ reference. - } - } - - return base::TraverseImplicitCastExpr(castE); - } - - bool VisitDeclRefExpr(DeclRefExpr *E) { - if (E->getDecl() == Var) - return false; // The reference of the variable, and not just its value, - // is needed. - return true; - } - }; - -public: - RootBlockObjCVarRewriter(llvm::DenseSet<VarDecl *> &VarsToChange) - : VarsToChange(VarsToChange) { } - - bool VisitBlockDecl(BlockDecl *block) { - SmallVector<VarDecl *, 4> BlockVars; - - for (const auto &I : block->captures()) { - VarDecl *var = I.getVariable(); - if (I.isByRef() && - var->getType()->isObjCObjectPointerType() && - isImplicitStrong(var->getType())) { - BlockVars.push_back(var); - } - } - - for (unsigned i = 0, e = BlockVars.size(); i != e; ++i) { - VarDecl *var = BlockVars[i]; - - BlockVarChecker checker(var); - bool onlyValueOfVarIsNeeded = checker.TraverseStmt(block->getBody()); - if (onlyValueOfVarIsNeeded) - VarsToChange.insert(var); - else - VarsToChange.erase(var); - } - - return true; - } - -private: - bool isImplicitStrong(QualType ty) { - if (isa<AttributedType>(ty.getTypePtr())) - return false; - return ty.getLocalQualifiers().getObjCLifetime() == Qualifiers::OCL_Strong; - } -}; - -class BlockObjCVarRewriter : public RecursiveASTVisitor<BlockObjCVarRewriter> { - llvm::DenseSet<VarDecl *> &VarsToChange; - -public: - BlockObjCVarRewriter(llvm::DenseSet<VarDecl *> &VarsToChange) - : VarsToChange(VarsToChange) { } - - bool TraverseBlockDecl(BlockDecl *block) { - RootBlockObjCVarRewriter(VarsToChange).TraverseDecl(block); - return true; - } -}; - -} // anonymous namespace - -void BlockObjCVariableTraverser::traverseBody(BodyContext &BodyCtx) { - MigrationPass &Pass = BodyCtx.getMigrationContext().Pass; - llvm::DenseSet<VarDecl *> VarsToChange; - - BlockObjCVarRewriter trans(VarsToChange); - trans.TraverseStmt(BodyCtx.getTopStmt()); - - for (llvm::DenseSet<VarDecl *>::iterator - I = VarsToChange.begin(), E = VarsToChange.end(); I != E; ++I) { - VarDecl *var = *I; - BlocksAttr *attr = var->getAttr<BlocksAttr>(); - if(!attr) - continue; - bool useWeak = canApplyWeak(Pass.Ctx, var->getType()); - SourceManager &SM = Pass.Ctx.getSourceManager(); - Transaction Trans(Pass.TA); - Pass.TA.replaceText(SM.getExpansionLoc(attr->getLocation()), - "__block", - useWeak ? "__weak" : "__unsafe_unretained"); - } -} diff --git clang/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp clang/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp deleted file mode 100644 index e9c21b8106d7..000000000000 --- clang/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp +++ /dev/null @@ -1,249 +0,0 @@ -//===-- TransEmptyStatementsAndDealloc.cpp - Transformations to ARC mode --===// -// -// 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 -// -//===----------------------------------------------------------------------===// -// -// removeEmptyStatementsAndDealloc: -// -// Removes empty statements that are leftovers from previous transformations. -// e.g for -// -// [x retain]; -// -// removeRetainReleaseDealloc will leave an empty ";" that removeEmptyStatements -// will remove. -// -//===----------------------------------------------------------------------===// - -#include "Transforms.h" -#include "Internals.h" -#include "clang/AST/ASTContext.h" -#include "clang/AST/StmtVisitor.h" -#include "clang/Basic/SourceManager.h" - -using namespace clang; -using namespace arcmt; -using namespace trans; - -static bool isEmptyARCMTMacroStatement(NullStmt *S, - std::vector<SourceLocation> &MacroLocs, - ASTContext &Ctx) { - if (!S->hasLeadingEmptyMacro()) - return false; - - SourceLocation SemiLoc = S->getSemiLoc(); - if (SemiLoc.isInvalid() || SemiLoc.isMacroID()) - return false; - - if (MacroLocs.empty()) - return false; - - SourceManager &SM = Ctx.getSourceManager(); - std::vector<SourceLocation>::iterator I = llvm::upper_bound( - MacroLocs, SemiLoc, BeforeThanCompare<SourceLocation>(SM)); - --I; - SourceLocation - AfterMacroLoc = I->getLocWithOffset(getARCMTMacroName().size()); - assert(AfterMacroLoc.isFileID()); - - if (AfterMacroLoc == SemiLoc) - return true; - - SourceLocation::IntTy RelOffs = 0; - if (!SM.isInSameSLocAddrSpace(AfterMacroLoc, SemiLoc, &RelOffs)) - return false; - if (RelOffs < 0) - return false; - - // We make the reasonable assumption that a semicolon after 100 characters - // means that it is not the next token after our macro. If this assumption - // fails it is not critical, we will just fail to clear out, e.g., an empty - // 'if'. - if (RelOffs - getARCMTMacroName().size() > 100) - return false; - - SourceLocation AfterMacroSemiLoc = findSemiAfterLocation(AfterMacroLoc, Ctx); - return AfterMacroSemiLoc == SemiLoc; -} - -namespace { - -/// Returns true if the statement became empty due to previous -/// transformations. -class EmptyChecker : public StmtVisitor<EmptyChecker, bool> { - ASTContext &Ctx; - std::vector<SourceLocation> &MacroLocs; - -public: - EmptyChecker(ASTContext &ctx, std::vector<SourceLocation> ¯oLocs) - : Ctx(ctx), MacroLocs(macroLocs) { } - - bool VisitNullStmt(NullStmt *S) { - return isEmptyARCMTMacroStatement(S, MacroLocs, Ctx); - } - bool VisitCompoundStmt(CompoundStmt *S) { - if (S->body_empty()) - return false; // was already empty, not because of transformations. - for (auto *I : S->body()) - if (!Visit(I)) - return false; - return true; - } - bool VisitIfStmt(IfStmt *S) { - if (S->getConditionVariable()) - return false; - Expr *condE = S->getCond(); - if (!condE) - return false; - if (hasSideEffects(condE, Ctx)) - return false; - if (!S->getThen() || !Visit(S->getThen())) - return false; - return !S->getElse() || Visit(S->getElse()); - } - bool VisitWhileStmt(WhileStmt *S) { - if (S->getConditionVariable()) - return false; - Expr *condE = S->getCond(); - if (!condE) - return false; - if (hasSideEffects(condE, Ctx)) - return false; - if (!S->getBody()) - return false; - return Visit(S->getBody()); - } - bool VisitDoStmt(DoStmt *S) { - Expr *condE = S->getCond(); - if (!condE) - return false; - if (hasSideEffects(condE, Ctx)) - return false; - if (!S->getBody()) - return false; - return Visit(S->getBody()); - } - bool VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) { - Expr *Exp = S->getCollection(); - if (!Exp) - return false; - if (hasSideEffects(Exp, Ctx)) - return false; - if (!S->getBody()) - return false; - return Visit(S->getBody()); - } - bool VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) { - if (!S->getSubStmt()) - return false; - return Visit(S->getSubStmt()); - } -}; - -class EmptyStatementsRemover : - public RecursiveASTVisitor<EmptyStatementsRemover> { - MigrationPass &Pass; - -public: - EmptyStatementsRemover(MigrationPass &pass) : Pass(pass) { } - - bool TraverseStmtExpr(StmtExpr *E) { - CompoundStmt *S = E->getSubStmt(); - for (CompoundStmt::body_iterator - I = S->body_begin(), E = S->body_end(); I != E; ++I) { - if (I != E - 1) - check(*I); - TraverseStmt(*I); - } - return true; - } - - bool VisitCompoundStmt(CompoundStmt *S) { - for (auto *I : S->body()) - check(I); - return true; - } - - ASTContext &getContext() { return Pass.Ctx; } - -private: - void check(Stmt *S) { - if (!S) return; - if (EmptyChecker(Pass.Ctx, Pass.ARCMTMacroLocs).Visit(S)) { - Transaction Trans(Pass.TA); - Pass.TA.removeStmt(S); - } - } -}; - -} // anonymous namespace - -static bool isBodyEmpty(CompoundStmt *body, ASTContext &Ctx, - std::vector<SourceLocation> &MacroLocs) { - for (auto *I : body->body()) - if (!EmptyChecker(Ctx, MacroLocs).Visit(I)) - return false; - - return true; -} - -static void cleanupDeallocOrFinalize(MigrationPass &pass) { - ASTContext &Ctx = pass.Ctx; - TransformActions &TA = pass.TA; - DeclContext *DC = Ctx.getTranslationUnitDecl(); - Selector FinalizeSel = - Ctx.Selectors.getNullarySelector(&pass.Ctx.Idents.get("finalize")); - - typedef DeclContext::specific_decl_iterator<ObjCImplementationDecl> - impl_iterator; - for (impl_iterator I = impl_iterator(DC->decls_begin()), - E = impl_iterator(DC->decls_end()); I != E; ++I) { - ObjCMethodDecl *DeallocM = nullptr; - ObjCMethodDecl *FinalizeM = nullptr; - for (auto *MD : I->instance_methods()) { - if (!MD->hasBody()) - continue; - - if (MD->getMethodFamily() == OMF_dealloc) { - DeallocM = MD; - } else if (MD->isInstanceMethod() && MD->getSelector() == FinalizeSel) { - FinalizeM = MD; - } - } - - if (DeallocM) { - if (isBodyEmpty(DeallocM->getCompoundBody(), Ctx, pass.ARCMTMacroLocs)) { - Transaction Trans(TA); - TA.remove(DeallocM->getSourceRange()); - } - - if (FinalizeM) { - Transaction Trans(TA); - TA.remove(FinalizeM->getSourceRange()); - } - - } else if (FinalizeM) { - if (isBodyEmpty(FinalizeM->getCompoundBody(), Ctx, pass.ARCMTMacroLocs)) { - Transaction Trans(TA); - TA.remove(FinalizeM->getSourceRange()); - } else { - Transaction Trans(TA); - TA.replaceText(FinalizeM->getSelectorStartLoc(), "finalize", "dealloc"); - } - } - } -} - -void trans::removeEmptyStatementsAndDeallocFinalize(MigrationPass &pass) { - EmptyStatementsRemover(pass).TraverseDecl(pass.Ctx.getTranslationUnitDecl()); - - cleanupDeallocOrFinalize(pass); - - for (unsigned i = 0, e = pass.ARCMTMacroLocs.size(); i != e; ++i) { - Transaction Trans(pass.TA); - pass.TA.remove(pass.ARCMTMacroLocs[i]); - } -} diff --git clang/lib/ARCMigrate/TransGCAttrs.cpp clang/lib/ARCMigrate/TransGCAttrs.cpp deleted file mode 100644 index 85e3fe77660b..000000000000 --- clang/lib/ARCMigrate/TransGCAttrs.cpp +++ /dev/null @@ -1,350 +0,0 @@ -//===--- TransGCAttrs.cpp - Transformations to ARC mode -------------------===// -// -// 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 "Transforms.h" -#include "Internals.h" -#include "clang/AST/ASTContext.h" -#include "clang/Basic/SourceManager.h" -#include "clang/Lex/Lexer.h" -#include "clang/Sema/SemaDiagnostic.h" -#include "llvm/ADT/SmallString.h" -#include "llvm/ADT/TinyPtrVector.h" -#include "llvm/Support/SaveAndRestore.h" - -using namespace clang; -using namespace arcmt; -using namespace trans; - -namespace { - -/// Collects all the places where GC attributes __strong/__weak occur. -class GCAttrsCollector : public RecursiveASTVisitor<GCAttrsCollector> { - MigrationContext &MigrateCtx; - bool FullyMigratable; - std::vector<ObjCPropertyDecl *> &AllProps; - - typedef RecursiveASTVisitor<GCAttrsCollector> base; -public: - GCAttrsCollector(MigrationContext &ctx, - std::vector<ObjCPropertyDecl *> &AllProps) - : MigrateCtx(ctx), FullyMigratable(false), - AllProps(AllProps) { } - - bool shouldWalkTypesOfTypeLocs() const { return false; } - - bool VisitAttributedTypeLoc(AttributedTypeLoc TL) { - handleAttr(TL); - return true; - } - - bool TraverseDecl(Decl *D) { - if (!D || D->isImplicit()) - return true; - - SaveAndRestore Save(FullyMigratable, isMigratable(D)); - - if (ObjCPropertyDecl *PropD = dyn_cast<ObjCPropertyDecl>(D)) { - lookForAttribute(PropD, PropD->getTypeSourceInfo()); - AllProps.push_back(PropD); - } else if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(D)) { - lookForAttribute(DD, DD->getTypeSourceInfo()); - } - return base::TraverseDecl(D); - } - - void lookForAttribute(Decl *D, TypeSourceInfo *TInfo) { - if (!TInfo) - return; - TypeLoc TL = TInfo->getTypeLoc(); - while (TL) { - if (QualifiedTypeLoc QL = TL.getAs<QualifiedTypeLoc>()) { - TL = QL.getUnqualifiedLoc(); - } else if (AttributedTypeLoc Attr = TL.getAs<AttributedTypeLoc>()) { - if (handleAttr(Attr, D)) - break; - TL = Attr.getModifiedLoc(); - } else if (MacroQualifiedTypeLoc MDTL = - TL.getAs<MacroQualifiedTypeLoc>()) { - TL = MDTL.getInnerLoc(); - } else if (ArrayTypeLoc Arr = TL.getAs<ArrayTypeLoc>()) { - TL = Arr.getElementLoc(); - } else if (PointerTypeLoc PT = TL.getAs<PointerTypeLoc>()) { - TL = PT.getPointeeLoc(); - } else if (ReferenceTypeLoc RT = TL.getAs<ReferenceTypeLoc>()) - TL = RT.getPointeeLoc(); - else - break; - } - } - - bool handleAttr(AttributedTypeLoc TL, Decl *D = nullptr) { - auto *OwnershipAttr = TL.getAttrAs<ObjCOwnershipAttr>(); - if (!OwnershipAttr) - return false; - - SourceLocation Loc = OwnershipAttr->getLocation(); - SourceLocation OrigLoc = Loc; - if (MigrateCtx.AttrSet.count(OrigLoc)) - return true; - - ASTContext &Ctx = MigrateCtx.Pass.Ctx; - SourceManager &SM = Ctx.getSourceManager(); - if (Loc.isMacroID()) - Loc = SM.getImmediateExpansionRange(Loc).getBegin(); - StringRef Spell = OwnershipAttr->getKind()->getName(); - MigrationContext::GCAttrOccurrence::AttrKind Kind; - if (Spell == "strong") - Kind = MigrationContext::GCAttrOccurrence::Strong; - else if (Spell == "weak") - Kind = MigrationContext::GCAttrOccurrence::Weak; - else - return false; - - MigrateCtx.AttrSet.insert(OrigLoc); - MigrateCtx.GCAttrs.push_back(MigrationContext::GCAttrOccurrence()); - MigrationContext::GCAttrOccurrence &Attr = MigrateCtx.GCAttrs.back(); - - Attr.Kind = Kind; - Attr.Loc = Loc; - Attr.ModifiedType = TL.getModifiedLoc().getType(); - Attr.Dcl = D; - Attr.FullyMigratable = FullyMigratable; - return true; - } - - bool isMigratable(Decl *D) { - if (isa<TranslationUnitDecl>(D)) - return false; - - if (isInMainFile(D)) - return true; - - if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) - return FD->hasBody(); - - if (ObjCContainerDecl *ContD = dyn_cast<ObjCContainerDecl>(D)) - return hasObjCImpl(ContD); - - if (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D)) { - for (const auto *MI : RD->methods()) { - if (MI->isOutOfLine()) - return true; - } - return false; - } - - return isMigratable(cast<Decl>(D->getDeclContext())); - } - - static bool hasObjCImpl(Decl *D) { - if (!D) - return false; - if (ObjCContainerDecl *ContD = dyn_cast<ObjCContainerDecl>(D)) { - if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(ContD)) - return ID->getImplementation() != nullptr; - if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(ContD)) - return CD->getImplementation() != nullptr; - return isa<ObjCImplDecl>(ContD); - } - return false; - } - - bool isInMainFile(Decl *D) { - if (!D) - return false; - - for (auto *I : D->redecls()) - if (!isInMainFile(I->getLocation())) - return false; - - return true; - } - - bool isInMainFile(SourceLocation Loc) { - if (Loc.isInvalid()) - return false; - - SourceManager &SM = MigrateCtx.Pass.Ctx.getSourceManager(); - return SM.isInFileID(SM.getExpansionLoc(Loc), SM.getMainFileID()); - } -}; - -} // anonymous namespace - -static void errorForGCAttrsOnNonObjC(MigrationContext &MigrateCtx) { - TransformActions &TA = MigrateCtx.Pass.TA; - - for (unsigned i = 0, e = MigrateCtx.GCAttrs.size(); i != e; ++i) { - MigrationContext::GCAttrOccurrence &Attr = MigrateCtx.GCAttrs[i]; - if (Attr.FullyMigratable && Attr.Dcl) { - if (Attr.ModifiedType.isNull()) - continue; - if (!Attr.ModifiedType->isObjCRetainableType()) { - TA.reportError("GC managed memory will become unmanaged in ARC", - Attr.Loc); - } - } - } -} - -static void checkWeakGCAttrs(MigrationContext &MigrateCtx) { - TransformActions &TA = MigrateCtx.Pass.TA; - - for (unsigned i = 0, e = MigrateCtx.GCAttrs.size(); i != e; ++i) { - MigrationContext::GCAttrOccurrence &Attr = MigrateCtx.GCAttrs[i]; - if (Attr.Kind == MigrationContext::GCAttrOccurrence::Weak) { - if (Attr.ModifiedType.isNull() || - !Attr.ModifiedType->isObjCRetainableType()) - continue; - if (!canApplyWeak(MigrateCtx.Pass.Ctx, Attr.ModifiedType, - /*AllowOnUnknownClass=*/true)) { - Transaction Trans(TA); - if (!MigrateCtx.RemovedAttrSet.count(Attr.Loc)) - TA.replaceText(Attr.Loc, "__weak", "__unsafe_unretained"); - TA.clearDiagnostic(diag::err_arc_weak_no_runtime, - diag::err_arc_unsupported_weak_class, - Attr.Loc); - } - } - } -} - -typedef llvm::TinyPtrVector<ObjCPropertyDecl *> IndivPropsTy; - -static void checkAllAtProps(MigrationContext &MigrateCtx, - SourceLocation AtLoc, - IndivPropsTy &IndProps) { - if (IndProps.empty()) - return; - - for (IndivPropsTy::iterator - PI = IndProps.begin(), PE = IndProps.end(); PI != PE; ++PI) { - QualType T = (*PI)->getType(); - if (T.isNull() || !T->isObjCRetainableType()) - return; - } - - SmallVector<std::pair<AttributedTypeLoc, ObjCPropertyDecl *>, 4> ATLs; - bool hasWeak = false, hasStrong = false; - ObjCPropertyAttribute::Kind Attrs = ObjCPropertyAttribute::kind_noattr; - for (IndivPropsTy::iterator - PI = IndProps.begin(), PE = IndProps.end(); PI != PE; ++PI) { - ObjCPropertyDecl *PD = *PI; - Attrs = PD->getPropertyAttributesAsWritten(); - TypeSourceInfo *TInfo = PD->getTypeSourceInfo(); - if (!TInfo) - return; - TypeLoc TL = TInfo->getTypeLoc(); - if (AttributedTypeLoc ATL = - TL.getAs<AttributedTypeLoc>()) { - ATLs.push_back(std::make_pair(ATL, PD)); - if (TInfo->getType().getObjCLifetime() == Qualifiers::OCL_Weak) { - hasWeak = true; - } else if (TInfo->getType().getObjCLifetime() == Qualifiers::OCL_Strong) - hasStrong = true; - else - return; - } - } - if (ATLs.empty()) - return; - if (hasWeak && hasStrong) - return; - - TransformActions &TA = MigrateCtx.Pass.TA; - Transaction Trans(TA); - - if (GCAttrsCollector::hasObjCImpl( - cast<Decl>(IndProps.front()->getDeclContext()))) { - if (hasWeak) - MigrateCtx.AtPropsWeak.insert(AtLoc); - - } else { - StringRef toAttr = "strong"; - if (hasWeak) { - if (canApplyWeak(MigrateCtx.Pass.Ctx, IndProps.front()->getType(), - /*AllowOnUnknownClass=*/true)) - toAttr = "weak"; - else - toAttr = "unsafe_unretained"; - } - if (Attrs & ObjCPropertyAttribute::kind_assign) - MigrateCtx.rewritePropertyAttribute("assign", toAttr, AtLoc); - else - MigrateCtx.addPropertyAttribute(toAttr, AtLoc); - } - - for (unsigned i = 0, e = ATLs.size(); i != e; ++i) { - SourceLocation Loc = ATLs[i].first.getAttr()->getLocation(); - if (Loc.isMacroID()) - Loc = MigrateCtx.Pass.Ctx.getSourceManager() - .getImmediateExpansionRange(Loc) - .getBegin(); - TA.remove(Loc); - TA.clearDiagnostic(diag::err_objc_property_attr_mutually_exclusive, AtLoc); - TA.clearDiagnostic(diag::err_arc_inconsistent_property_ownership, - ATLs[i].second->getLocation()); - MigrateCtx.RemovedAttrSet.insert(Loc); - } -} - -static void checkAllProps(MigrationContext &MigrateCtx, - std::vector<ObjCPropertyDecl *> &AllProps) { - typedef llvm::TinyPtrVector<ObjCPropertyDecl *> IndivPropsTy; - llvm::DenseMap<SourceLocation, IndivPropsTy> AtProps; - - for (unsigned i = 0, e = AllProps.size(); i != e; ++i) { - ObjCPropertyDecl *PD = AllProps[i]; - if (PD->getPropertyAttributesAsWritten() & - (ObjCPropertyAttribute::kind_assign | - ObjCPropertyAttribute::kind_readonly)) { - SourceLocation AtLoc = PD->getAtLoc(); - if (AtLoc.isInvalid()) - continue; - AtProps[AtLoc].push_back(PD); - } - } - - for (auto I = AtProps.begin(), E = AtProps.end(); I != E; ++I) { - SourceLocation AtLoc = I->first; - IndivPropsTy &IndProps = I->second; - checkAllAtProps(MigrateCtx, AtLoc, IndProps); - } -} - -void GCAttrsTraverser::traverseTU(MigrationContext &MigrateCtx) { - std::vector<ObjCPropertyDecl *> AllProps; - GCAttrsCollector(MigrateCtx, AllProps).TraverseDecl( - MigrateCtx.Pass.Ctx.getTranslationUnitDecl()); - - errorForGCAttrsOnNonObjC(MigrateCtx); - checkAllProps(MigrateCtx, AllProps); - checkWeakGCAttrs(MigrateCtx); -} - -void MigrationContext::dumpGCAttrs() { - llvm::errs() << "\n################\n"; - for (unsigned i = 0, e = GCAttrs.size(); i != e; ++i) { - GCAttrOccurrence &Attr = GCAttrs[i]; - llvm::errs() << "KIND: " - << (Attr.Kind == GCAttrOccurrence::Strong ? "strong" : "weak"); - llvm::errs() << "\nLOC: "; - Attr.Loc.print(llvm::errs(), Pass.Ctx.getSourceManager()); - llvm::errs() << "\nTYPE: "; - Attr.ModifiedType.dump(); - if (Attr.Dcl) { - llvm::errs() << "DECL:\n"; - Attr.Dcl->dump(); - } else { - llvm::errs() << "DECL: NONE"; - } - llvm::errs() << "\nMIGRATABLE: " << Attr.FullyMigratable; - llvm::errs() << "\n----------------\n"; - } - llvm::errs() << "\n################\n"; -} diff --git clang/lib/ARCMigrate/TransGCCalls.cpp clang/lib/ARCMigrate/TransGCCalls.cpp deleted file mode 100644 index 43233e2d0b45..000000000000 --- clang/lib/ARCMigrate/TransGCCalls.cpp +++ /dev/null @@ -1,76 +0,0 @@ -//===--- TransGCCalls.cpp - Transformations to ARC mode -------------------===// -// -// 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 "Transforms.h" -#include "Internals.h" -#include "clang/AST/ASTContext.h" -#include "clang/Sema/SemaDiagnostic.h" - -using namespace clang; -using namespace arcmt; -using namespace trans; - -namespace { - -class GCCollectableCallsChecker : - public RecursiveASTVisitor<GCCollectableCallsChecker> { - MigrationContext &MigrateCtx; - IdentifierInfo *NSMakeCollectableII; - IdentifierInfo *CFMakeCollectableII; - -public: - GCCollectableCallsChecker(MigrationContext &ctx) - : MigrateCtx(ctx) { - IdentifierTable &Ids = MigrateCtx.Pass.Ctx.Idents; - NSMakeCollectableII = &Ids.get("NSMakeCollectable"); - CFMakeCollectableII = &Ids.get("CFMakeCollectable"); - } - - bool shouldWalkTypesOfTypeLocs() const { return false; } - - bool VisitCallExpr(CallExpr *E) { - TransformActions &TA = MigrateCtx.Pass.TA; - - if (MigrateCtx.isGCOwnedNonObjC(E->getType())) { - TA.report(E->getBeginLoc(), diag::warn_arcmt_nsalloc_realloc, - E->getSourceRange()); - return true; - } - - Expr *CEE = E->getCallee()->IgnoreParenImpCasts(); - if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE)) { - if (FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(DRE->getDecl())) { - if (!FD->getDeclContext()->getRedeclContext()->isFileContext()) - return true; - - if (FD->getIdentifier() == NSMakeCollectableII) { - Transaction Trans(TA); - TA.clearDiagnostic(diag::err_unavailable, - diag::err_unavailable_message, - diag::err_ovl_deleted_call, // ObjC++ - DRE->getSourceRange()); - TA.replace(DRE->getSourceRange(), "CFBridgingRelease"); - - } else if (FD->getIdentifier() == CFMakeCollectableII) { - TA.reportError("CFMakeCollectable will leak the object that it " - "receives in ARC", DRE->getLocation(), - DRE->getSourceRange()); - } - } - } - - return true; - } -}; - -} // anonymous namespace - -void GCCollectableCallsTraverser::traverseBody(BodyContext &BodyCtx) { - GCCollectableCallsChecker(BodyCtx.getMigrationContext()) - .TraverseStmt(BodyCtx.getTopStmt()); -} diff --git clang/lib/ARCMigrate/TransProperties.cpp clang/lib/ARCMigrate/TransProperties.cpp deleted file mode 100644 index 6d1d950821a0..000000000000 --- clang/lib/ARCMigrate/TransProperties.cpp +++ /dev/null @@ -1,379 +0,0 @@ -//===--- TransProperties.cpp - Transformations to ARC mode ----------------===// -// -// 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 -// -//===----------------------------------------------------------------------===// -// -// rewriteProperties: -// -// - Adds strong/weak/unsafe_unretained ownership specifier to properties that -// are missing one. -// - Migrates properties from (retain) to (strong) and (assign) to -// (unsafe_unretained/weak). -// - If a property is synthesized, adds the ownership specifier in the ivar -// backing the property. -// -// @interface Foo : NSObject { -// NSObject *x; -// } -// @property (assign) id x; -// @end -// ----> -// @interface Foo : NSObject { -// NSObject *__weak x; -// } -// @property (weak) id x; -// @end -// -//===----------------------------------------------------------------------===// - -#include "Transforms.h" -#include "Internals.h" -#include "clang/Basic/SourceManager.h" -#include "clang/Lex/Lexer.h" -#include "clang/Sema/SemaDiagnostic.h" -#include <map> - -using namespace clang; -using namespace arcmt; -using namespace trans; - -namespace { - -class PropertiesRewriter { - MigrationContext &MigrateCtx; - MigrationPass &Pass; - ObjCImplementationDecl *CurImplD = nullptr; - - enum PropActionKind { - PropAction_None, - PropAction_RetainReplacedWithStrong, - PropAction_AssignRemoved, - PropAction_AssignRewritten, - PropAction_MaybeAddWeakOrUnsafe - }; - - struct PropData { - ObjCPropertyDecl *PropD; - ObjCIvarDecl *IvarD; - ObjCPropertyImplDecl *ImplD; - - PropData(ObjCPropertyDecl *propD) - : PropD(propD), IvarD(nullptr), ImplD(nullptr) {} - }; - - typedef SmallVector<PropData, 2> PropsTy; - typedef std::map<SourceLocation, PropsTy> AtPropDeclsTy; - AtPropDeclsTy AtProps; - llvm::DenseMap<IdentifierInfo *, PropActionKind> ActionOnProp; - -public: - explicit PropertiesRewriter(MigrationContext &MigrateCtx) - : MigrateCtx(MigrateCtx), Pass(MigrateCtx.Pass) { } - - static void collectProperties(ObjCContainerDecl *D, AtPropDeclsTy &AtProps, - AtPropDeclsTy *PrevAtProps = nullptr) { - for (auto *Prop : D->instance_properties()) { - SourceLocation Loc = Prop->getAtLoc(); - if (Loc.isInvalid()) - continue; - if (PrevAtProps) - if (PrevAtProps->find(Loc) != PrevAtProps->end()) - continue; - PropsTy &props = AtProps[Loc]; - props.push_back(Prop); - } - } - - void doTransform(ObjCImplementationDecl *D) { - CurImplD = D; - ObjCInterfaceDecl *iface = D->getClassInterface(); - if (!iface) - return; - - collectProperties(iface, AtProps); - - // Look through extensions. - for (auto *Ext : iface->visible_extensions()) - collectProperties(Ext, AtProps); - - typedef DeclContext::specific_decl_iterator<ObjCPropertyImplDecl> - prop_impl_iterator; - for (prop_impl_iterator - I = prop_impl_iterator(D->decls_begin()), - E = prop_impl_iterator(D->decls_end()); I != E; ++I) { - ObjCPropertyImplDecl *implD = *I; - if (implD->getPropertyImplementation() != ObjCPropertyImplDecl::Synthesize) - continue; - ObjCPropertyDecl *propD = implD->getPropertyDecl(); - if (!propD || propD->isInvalidDecl()) - continue; - ObjCIvarDecl *ivarD = implD->getPropertyIvarDecl(); - if (!ivarD || ivarD->isInvalidDecl()) - continue; - AtPropDeclsTy::iterator findAtLoc = AtProps.find(propD->getAtLoc()); - if (findAtLoc == AtProps.end()) - continue; - - PropsTy &props = findAtLoc->second; - for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) { - if (I->PropD == propD) { - I->IvarD = ivarD; - I->ImplD = implD; - break; - } - } - } - - for (AtPropDeclsTy::iterator - I = AtProps.begin(), E = AtProps.end(); I != E; ++I) { - SourceLocation atLoc = I->first; - PropsTy &props = I->second; - if (!getPropertyType(props)->isObjCRetainableType()) - continue; - if (hasIvarWithExplicitARCOwnership(props)) - continue; - - Transaction Trans(Pass.TA); - rewriteProperty(props, atLoc); - } - } - -private: - void doPropAction(PropActionKind kind, - PropsTy &props, SourceLocation atLoc, - bool markAction = true) { - if (markAction) - for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) - ActionOnProp[I->PropD->getIdentifier()] = kind; - - switch (kind) { - case PropAction_None: - return; - case PropAction_RetainReplacedWithStrong: { - StringRef toAttr = "strong"; - MigrateCtx.rewritePropertyAttribute("retain", toAttr, atLoc); - return; - } - case PropAction_AssignRemoved: - return removeAssignForDefaultStrong(props, atLoc); - case PropAction_AssignRewritten: - return rewriteAssign(props, atLoc); - case PropAction_MaybeAddWeakOrUnsafe: - return maybeAddWeakOrUnsafeUnretainedAttr(props, atLoc); - } - } - - void rewriteProperty(PropsTy &props, SourceLocation atLoc) { - ObjCPropertyAttribute::Kind propAttrs = getPropertyAttrs(props); - - if (propAttrs & - (ObjCPropertyAttribute::kind_copy | - ObjCPropertyAttribute::kind_unsafe_unretained | - ObjCPropertyAttribute::kind_strong | ObjCPropertyAttribute::kind_weak)) - return; - - if (propAttrs & ObjCPropertyAttribute::kind_retain) { - // strong is the default. - return doPropAction(PropAction_RetainReplacedWithStrong, props, atLoc); - } - - bool HasIvarAssignedAPlusOneObject = hasIvarAssignedAPlusOneObject(props); - - if (propAttrs & ObjCPropertyAttribute::kind_assign) { - if (HasIvarAssignedAPlusOneObject) - return doPropAction(PropAction_AssignRemoved, props, atLoc); - return doPropAction(PropAction_AssignRewritten, props, atLoc); - } - - if (HasIvarAssignedAPlusOneObject || - (Pass.isGCMigration() && !hasGCWeak(props, atLoc))) - return; // 'strong' by default. - - return doPropAction(PropAction_MaybeAddWeakOrUnsafe, props, atLoc); - } - - void removeAssignForDefaultStrong(PropsTy &props, - SourceLocation atLoc) const { - removeAttribute("retain", atLoc); - if (!removeAttribute("assign", atLoc)) - return; - - for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) { - if (I->ImplD) - Pass.TA.clearDiagnostic(diag::err_arc_strong_property_ownership, - diag::err_arc_assign_property_ownership, - diag::err_arc_inconsistent_property_ownership, - I->IvarD->getLocation()); - } - } - - void rewriteAssign(PropsTy &props, SourceLocation atLoc) const { - bool canUseWeak = canApplyWeak(Pass.Ctx, getPropertyType(props), - /*AllowOnUnknownClass=*/Pass.isGCMigration()); - const char *toWhich = - (Pass.isGCMigration() && !hasGCWeak(props, atLoc)) ? "strong" : - (canUseWeak ? "weak" : "unsafe_unretained"); - - bool rewroteAttr = rewriteAttribute("assign", toWhich, atLoc); - if (!rewroteAttr) - canUseWeak = false; - - for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) { - if (isUserDeclared(I->IvarD)) { - if (I->IvarD && - I->IvarD->getType().getObjCLifetime() != Qualifiers::OCL_Weak) { - const char *toWhich = - (Pass.isGCMigration() && !hasGCWeak(props, atLoc)) ? "__strong " : - (canUseWeak ? "__weak " : "__unsafe_unretained "); - Pass.TA.insert(I->IvarD->getLocation(), toWhich); - } - } - if (I->ImplD) - Pass.TA.clearDiagnostic(diag::err_arc_strong_property_ownership, - diag::err_arc_assign_property_ownership, - diag::err_arc_inconsistent_property_ownership, - I->IvarD->getLocation()); - } - } - - void maybeAddWeakOrUnsafeUnretainedAttr(PropsTy &props, - SourceLocation atLoc) const { - bool canUseWeak = canApplyWeak(Pass.Ctx, getPropertyType(props), - /*AllowOnUnknownClass=*/Pass.isGCMigration()); - - bool addedAttr = addAttribute(canUseWeak ? "weak" : "unsafe_unretained", - atLoc); - if (!addedAttr) - canUseWeak = false; - - for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) { - if (isUserDeclared(I->IvarD)) { - if (I->IvarD && - I->IvarD->getType().getObjCLifetime() != Qualifiers::OCL_Weak) - Pass.TA.insert(I->IvarD->getLocation(), - canUseWeak ? "__weak " : "__unsafe_unretained "); - } - if (I->ImplD) { - Pass.TA.clearDiagnostic(diag::err_arc_strong_property_ownership, - diag::err_arc_assign_property_ownership, - diag::err_arc_inconsistent_property_ownership, - I->IvarD->getLocation()); - Pass.TA.clearDiagnostic( - diag::err_arc_objc_property_default_assign_on_object, - I->ImplD->getLocation()); - } - } - } - - bool removeAttribute(StringRef fromAttr, SourceLocation atLoc) const { - return MigrateCtx.removePropertyAttribute(fromAttr, atLoc); - } - - bool rewriteAttribute(StringRef fromAttr, StringRef toAttr, - SourceLocation atLoc) const { - return MigrateCtx.rewritePropertyAttribute(fromAttr, toAttr, atLoc); - } - - bool addAttribute(StringRef attr, SourceLocation atLoc) const { - return MigrateCtx.addPropertyAttribute(attr, atLoc); - } - - class PlusOneAssign : public RecursiveASTVisitor<PlusOneAssign> { - ObjCIvarDecl *Ivar; - public: - PlusOneAssign(ObjCIvarDecl *D) : Ivar(D) {} - - bool VisitBinaryOperator(BinaryOperator *E) { - if (E->getOpcode() != BO_Assign) - return true; - - Expr *lhs = E->getLHS()->IgnoreParenImpCasts(); - if (ObjCIvarRefExpr *RE = dyn_cast<ObjCIvarRefExpr>(lhs)) { - if (RE->getDecl() != Ivar) - return true; - - if (isPlusOneAssign(E)) - return false; - } - - return true; - } - }; - - bool hasIvarAssignedAPlusOneObject(PropsTy &props) const { - for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) { - PlusOneAssign oneAssign(I->IvarD); - bool notFound = oneAssign.TraverseDecl(CurImplD); - if (!notFound) - return true; - } - - return false; - } - - bool hasIvarWithExplicitARCOwnership(PropsTy &props) const { - if (Pass.isGCMigration()) - return false; - - for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) { - if (isUserDeclared(I->IvarD)) { - if (isa<AttributedType>(I->IvarD->getType())) - return true; - if (I->IvarD->getType().getLocalQualifiers().getObjCLifetime() - != Qualifiers::OCL_Strong) - return true; - } - } - - return false; - } - - // Returns true if all declarations in the @property have GC __weak. - bool hasGCWeak(PropsTy &props, SourceLocation atLoc) const { - if (!Pass.isGCMigration()) - return false; - if (props.empty()) - return false; - return MigrateCtx.AtPropsWeak.count(atLoc); - } - - bool isUserDeclared(ObjCIvarDecl *ivarD) const { - return ivarD && !ivarD->getSynthesize(); - } - - QualType getPropertyType(PropsTy &props) const { - assert(!props.empty()); - QualType ty = props[0].PropD->getType().getUnqualifiedType(); - -#ifndef NDEBUG - for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) - assert(ty == I->PropD->getType().getUnqualifiedType()); -#endif - - return ty; - } - - ObjCPropertyAttribute::Kind getPropertyAttrs(PropsTy &props) const { - assert(!props.empty()); - ObjCPropertyAttribute::Kind attrs = - props[0].PropD->getPropertyAttributesAsWritten(); - -#ifndef NDEBUG - for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) - assert(attrs == I->PropD->getPropertyAttributesAsWritten()); -#endif - - return attrs; - } -}; - -} // anonymous namespace - -void PropertyRewriteTraverser::traverseObjCImplementation( - ObjCImplementationContext &ImplCtx) { - PropertiesRewriter(ImplCtx.getMigrationContext()) - .doTransform(ImplCtx.getImplementationDecl()); -} diff --git clang/lib/ARCMigrate/TransProtectedScope.cpp clang/lib/ARCMigrate/TransProtectedScope.cpp deleted file mode 100644 index 154e0b54800f..000000000000 --- clang/lib/ARCMigrate/TransProtectedScope.cpp +++ /dev/null @@ -1,203 +0,0 @@ -//===--- TransProtectedScope.cpp - Transformations to ARC mode ------------===// -// -// 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 -// -//===----------------------------------------------------------------------===// -// -// Adds brackets in case statements that "contain" initialization of retaining -// variable, thus emitting the "switch case is in protected scope" error. -// -//===----------------------------------------------------------------------===// - -#include "Internals.h" -#include "Transforms.h" -#include "clang/AST/ASTContext.h" -#include "clang/Basic/SourceManager.h" -#include "clang/Sema/SemaDiagnostic.h" - -using namespace clang; -using namespace arcmt; -using namespace trans; - -namespace { - -class LocalRefsCollector : public RecursiveASTVisitor<LocalRefsCollector> { - SmallVectorImpl<DeclRefExpr *> &Refs; - -public: - LocalRefsCollector(SmallVectorImpl<DeclRefExpr *> &refs) - : Refs(refs) { } - - bool VisitDeclRefExpr(DeclRefExpr *E) { - if (ValueDecl *D = E->getDecl()) - if (D->getDeclContext()->getRedeclContext()->isFunctionOrMethod()) - Refs.push_back(E); - return true; - } -}; - -struct CaseInfo { - SwitchCase *SC; - SourceRange Range; - enum { - St_Unchecked, - St_CannotFix, - St_Fixed - } State; - - CaseInfo() : SC(nullptr), State(St_Unchecked) {} - CaseInfo(SwitchCase *S, SourceRange Range) - : SC(S), Range(Range), State(St_Unchecked) {} -}; - -class CaseCollector : public RecursiveASTVisitor<CaseCollector> { - ParentMap &PMap; - SmallVectorImpl<CaseInfo> &Cases; - -public: - CaseCollector(ParentMap &PMap, SmallVectorImpl<CaseInfo> &Cases) - : PMap(PMap), Cases(Cases) { } - - bool VisitSwitchStmt(SwitchStmt *S) { - SwitchCase *Curr = S->getSwitchCaseList(); - if (!Curr) - return true; - Stmt *Parent = getCaseParent(Curr); - Curr = Curr->getNextSwitchCase(); - // Make sure all case statements are in the same scope. - while (Curr) { - if (getCaseParent(Curr) != Parent) - return true; - Curr = Curr->getNextSwitchCase(); - } - - SourceLocation NextLoc = S->getEndLoc(); - Curr = S->getSwitchCaseList(); - // We iterate over case statements in reverse source-order. - while (Curr) { - Cases.push_back( - CaseInfo(Curr, SourceRange(Curr->getBeginLoc(), NextLoc))); - NextLoc = Curr->getBeginLoc(); - Curr = Curr->getNextSwitchCase(); - } - return true; - } - - Stmt *getCaseParent(SwitchCase *S) { - Stmt *Parent = PMap.getParent(S); - while (Parent && (isa<SwitchCase>(Parent) || isa<LabelStmt>(Parent))) - Parent = PMap.getParent(Parent); - return Parent; - } -}; - -class ProtectedScopeFixer { - MigrationPass &Pass; - SourceManager &SM; - SmallVector<CaseInfo, 16> Cases; - SmallVector<DeclRefExpr *, 16> LocalRefs; - -public: - ProtectedScopeFixer(BodyContext &BodyCtx) - : Pass(BodyCtx.getMigrationContext().Pass), - SM(Pass.Ctx.getSourceManager()) { - - CaseCollector(BodyCtx.getParentMap(), Cases) - .TraverseStmt(BodyCtx.getTopStmt()); - LocalRefsCollector(LocalRefs).TraverseStmt(BodyCtx.getTopStmt()); - - SourceRange BodyRange = BodyCtx.getTopStmt()->getSourceRange(); - const CapturedDiagList &DiagList = Pass.getDiags(); - // Copy the diagnostics so we don't have to worry about invaliding iterators - // from the diagnostic list. - SmallVector<StoredDiagnostic, 16> StoredDiags; - StoredDiags.append(DiagList.begin(), DiagList.end()); - SmallVectorImpl<StoredDiagnostic>::iterator - I = StoredDiags.begin(), E = StoredDiags.end(); - while (I != E) { - if (I->getID() == diag::err_switch_into_protected_scope && - isInRange(I->getLocation(), BodyRange)) { - handleProtectedScopeError(I, E); - continue; - } - ++I; - } - } - - void handleProtectedScopeError( - SmallVectorImpl<StoredDiagnostic>::iterator &DiagI, - SmallVectorImpl<StoredDiagnostic>::iterator DiagE){ - Transaction Trans(Pass.TA); - assert(DiagI->getID() == diag::err_switch_into_protected_scope); - SourceLocation ErrLoc = DiagI->getLocation(); - bool handledAllNotes = true; - ++DiagI; - for (; DiagI != DiagE && DiagI->getLevel() == DiagnosticsEngine::Note; - ++DiagI) { - if (!handleProtectedNote(*DiagI)) - handledAllNotes = false; - } - - if (handledAllNotes) - Pass.TA.clearDiagnostic(diag::err_switch_into_protected_scope, ErrLoc); - } - - bool handleProtectedNote(const StoredDiagnostic &Diag) { - assert(Diag.getLevel() == DiagnosticsEngine::Note); - - for (unsigned i = 0; i != Cases.size(); i++) { - CaseInfo &info = Cases[i]; - if (isInRange(Diag.getLocation(), info.Range)) { - - if (info.State == CaseInfo::St_Unchecked) - tryFixing(info); - assert(info.State != CaseInfo::St_Unchecked); - - if (info.State == CaseInfo::St_Fixed) { - Pass.TA.clearDiagnostic(Diag.getID(), Diag.getLocation()); - return true; - } - return false; - } - } - - return false; - } - - void tryFixing(CaseInfo &info) { - assert(info.State == CaseInfo::St_Unchecked); - if (hasVarReferencedOutside(info)) { - info.State = CaseInfo::St_CannotFix; - return; - } - - Pass.TA.insertAfterToken(info.SC->getColonLoc(), " {"); - Pass.TA.insert(info.Range.getEnd(), "}\n"); - info.State = CaseInfo::St_Fixed; - } - - bool hasVarReferencedOutside(CaseInfo &info) { - for (unsigned i = 0, e = LocalRefs.size(); i != e; ++i) { - DeclRefExpr *DRE = LocalRefs[i]; - if (isInRange(DRE->getDecl()->getLocation(), info.Range) && - !isInRange(DRE->getLocation(), info.Range)) - return true; - } - return false; - } - - bool isInRange(SourceLocation Loc, SourceRange R) { - if (Loc.isInvalid()) - return false; - return !SM.isBeforeInTranslationUnit(Loc, R.getBegin()) && - SM.isBeforeInTranslationUnit(Loc, R.getEnd()); - } -}; - -} // anonymous namespace - -void ProtectedScopeTraverser::traverseBody(BodyContext &BodyCtx) { - ProtectedScopeFixer Fix(BodyCtx); -} diff --git clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp deleted file mode 100644 index baa503d8a39d..000000000000 --- clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp +++ /dev/null @@ -1,459 +0,0 @@ -//===--- TransRetainReleaseDealloc.cpp - Transformations to ARC mode ------===// -// -// 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 -// -//===----------------------------------------------------------------------===// -// -// removeRetainReleaseDealloc: -// -// Removes retain/release/autorelease/dealloc messages. -// -// return [[foo retain] autorelease]; -// ----> -// return foo; -// -//===----------------------------------------------------------------------===// - -#include "Transforms.h" -#include "Internals.h" -#include "clang/AST/ASTContext.h" -#include "clang/AST/ParentMap.h" -#include "clang/Basic/SourceManager.h" -#include "clang/Lex/Lexer.h" -#include "clang/Sema/SemaDiagnostic.h" -#include "llvm/ADT/StringSwitch.h" - -using namespace clang; -using namespace arcmt; -using namespace trans; - -namespace { - -class RetainReleaseDeallocRemover : - public RecursiveASTVisitor<RetainReleaseDeallocRemover> { - Stmt *Body; - MigrationPass &Pass; - - ExprSet Removables; - std::unique_ptr<ParentMap> StmtMap; - - Selector DelegateSel, FinalizeSel; - -public: - RetainReleaseDeallocRemover(MigrationPass &pass) - : Body(nullptr), Pass(pass) { - DelegateSel = - Pass.Ctx.Selectors.getNullarySelector(&Pass.Ctx.Idents.get("delegate")); - FinalizeSel = - Pass.Ctx.Selectors.getNullarySelector(&Pass.Ctx.Idents.get("finalize")); - } - - void transformBody(Stmt *body, Decl *ParentD) { - Body = body; - collectRemovables(body, Removables); - StmtMap.reset(new ParentMap(body)); - TraverseStmt(body); - } - - bool VisitObjCMessageExpr(ObjCMessageExpr *E) { - switch (E->getMethodFamily()) { - default: - if (E->isInstanceMessage() && E->getSelector() == FinalizeSel) - break; - return true; - case OMF_autorelease: - if (isRemovable(E)) { - if (!isCommonUnusedAutorelease(E)) { - // An unused autorelease is badness. If we remove it the receiver - // will likely die immediately while previously it was kept alive - // by the autorelease pool. This is bad practice in general, leave it - // and emit an error to force the user to restructure their code. - Pass.TA.reportError( - "it is not safe to remove an unused 'autorelease' " - "message; its receiver may be destroyed immediately", - E->getBeginLoc(), E->getSourceRange()); - return true; - } - } - // Pass through. - [[fallthrough]]; - case OMF_retain: - case OMF_release: - if (E->getReceiverKind() == ObjCMessageExpr::Instance) - if (Expr *rec = E->getInstanceReceiver()) { - rec = rec->IgnoreParenImpCasts(); - if (rec->getType().getObjCLifetime() == Qualifiers::OCL_ExplicitNone && - (E->getMethodFamily() != OMF_retain || isRemovable(E))) { - std::string err = "it is not safe to remove '"; - err += E->getSelector().getAsString() + "' message on " - "an __unsafe_unretained type"; - Pass.TA.reportError(err, rec->getBeginLoc()); - return true; - } - - if (isGlobalVar(rec) && - (E->getMethodFamily() != OMF_retain || isRemovable(E))) { - std::string err = "it is not safe to remove '"; - err += E->getSelector().getAsString() + "' message on " - "a global variable"; - Pass.TA.reportError(err, rec->getBeginLoc()); - return true; - } - - if (E->getMethodFamily() == OMF_release && isDelegateMessage(rec)) { - Pass.TA.reportError( - "it is not safe to remove 'retain' " - "message on the result of a 'delegate' message; " - "the object that was passed to 'setDelegate:' may not be " - "properly retained", - rec->getBeginLoc()); - return true; - } - } - break; - case OMF_dealloc: - break; - } - - switch (E->getReceiverKind()) { - default: - return true; - case ObjCMessageExpr::SuperInstance: { - Transaction Trans(Pass.TA); - clearDiagnostics(E->getSelectorLoc(0)); - if (tryRemoving(E)) - return true; - Pass.TA.replace(E->getSourceRange(), "self"); - return true; - } - case ObjCMessageExpr::Instance: - break; - } - - Expr *rec = E->getInstanceReceiver(); - if (!rec) return true; - - Transaction Trans(Pass.TA); - clearDiagnostics(E->getSelectorLoc(0)); - - ObjCMessageExpr *Msg = E; - Expr *RecContainer = Msg; - SourceRange RecRange = rec->getSourceRange(); - checkForGCDOrXPC(Msg, RecContainer, rec, RecRange); - - if (Msg->getMethodFamily() == OMF_release && - isRemovable(RecContainer) && isInAtFinally(RecContainer)) { - // Change the -release to "receiver = nil" in a finally to avoid a leak - // when an exception is thrown. - Pass.TA.replace(RecContainer->getSourceRange(), RecRange); - std::string str = " = "; - str += getNilString(Pass); - Pass.TA.insertAfterToken(RecRange.getEnd(), str); - return true; - } - - if (hasSideEffects(rec, Pass.Ctx) || !tryRemoving(RecContainer)) - Pass.TA.replace(RecContainer->getSourceRange(), RecRange); - - return true; - } - -private: - /// Checks for idioms where an unused -autorelease is common. - /// - /// Returns true for this idiom which is common in property - /// setters: - /// - /// [backingValue autorelease]; - /// backingValue = [newValue retain]; // in general a +1 assign - /// - /// For these as well: - /// - /// [[var retain] autorelease]; - /// return var; - /// - bool isCommonUnusedAutorelease(ObjCMessageExpr *E) { - return isPlusOneAssignBeforeOrAfterAutorelease(E) || - isReturnedAfterAutorelease(E); - } - - bool isReturnedAfterAutorelease(ObjCMessageExpr *E) { - Expr *Rec = E->getInstanceReceiver(); - if (!Rec) - return false; - - Decl *RefD = getReferencedDecl(Rec); - if (!RefD) - return false; - - Stmt *nextStmt = getNextStmt(E); - if (!nextStmt) - return false; - - // Check for "return <variable>;". - - if (ReturnStmt *RetS = dyn_cast<ReturnStmt>(nextStmt)) - return RefD == getReferencedDecl(RetS->getRetValue()); - - return false; - } - - bool isPlusOneAssignBeforeOrAfterAutorelease(ObjCMessageExpr *E) { - Expr *Rec = E->getInstanceReceiver(); - if (!Rec) - return false; - - Decl *RefD = getReferencedDecl(Rec); - if (!RefD) - return false; - - Stmt *prevStmt, *nextStmt; - std::tie(prevStmt, nextStmt) = getPreviousAndNextStmt(E); - - return isPlusOneAssignToVar(prevStmt, RefD) || - isPlusOneAssignToVar(nextStmt, RefD); - } - - bool isPlusOneAssignToVar(Stmt *S, Decl *RefD) { - if (!S) - return false; - - // Check for "RefD = [+1 retained object];". - - if (BinaryOperator *Bop = dyn_cast<BinaryOperator>(S)) { - return (RefD == getReferencedDecl(Bop->getLHS())) && isPlusOneAssign(Bop); - } - - if (DeclStmt *DS = dyn_cast<DeclStmt>(S)) { - if (DS->isSingleDecl() && DS->getSingleDecl() == RefD) { - if (VarDecl *VD = dyn_cast<VarDecl>(RefD)) - return isPlusOne(VD->getInit()); - } - return false; - } - - return false; - } - - Stmt *getNextStmt(Expr *E) { - return getPreviousAndNextStmt(E).second; - } - - std::pair<Stmt *, Stmt *> getPreviousAndNextStmt(Expr *E) { - Stmt *prevStmt = nullptr, *nextStmt = nullptr; - if (!E) - return std::make_pair(prevStmt, nextStmt); - - Stmt *OuterS = E, *InnerS; - do { - InnerS = OuterS; - OuterS = StmtMap->getParent(InnerS); - } - while (OuterS && (isa<ParenExpr>(OuterS) || - isa<CastExpr>(OuterS) || - isa<FullExpr>(OuterS))); - - if (!OuterS) - return std::make_pair(prevStmt, nextStmt); - - Stmt::child_iterator currChildS = OuterS->child_begin(); - Stmt::child_iterator childE = OuterS->child_end(); - Stmt::child_iterator prevChildS = childE; - for (; currChildS != childE; ++currChildS) { - if (*currChildS == InnerS) - break; - prevChildS = currChildS; - } - - if (prevChildS != childE) { - prevStmt = *prevChildS; - if (auto *E = dyn_cast_or_null<Expr>(prevStmt)) - prevStmt = E->IgnoreImplicit(); - } - - if (currChildS == childE) - return std::make_pair(prevStmt, nextStmt); - ++currChildS; - if (currChildS == childE) - return std::make_pair(prevStmt, nextStmt); - - nextStmt = *currChildS; - if (auto *E = dyn_cast_or_null<Expr>(nextStmt)) - nextStmt = E->IgnoreImplicit(); - - return std::make_pair(prevStmt, nextStmt); - } - - Decl *getReferencedDecl(Expr *E) { - if (!E) - return nullptr; - - E = E->IgnoreParenCasts(); - if (ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(E)) { - switch (ME->getMethodFamily()) { - case OMF_copy: - case OMF_autorelease: - case OMF_release: - case OMF_retain: - return getReferencedDecl(ME->getInstanceReceiver()); - default: - return nullptr; - } - } - if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) - return DRE->getDecl(); - if (MemberExpr *ME = dyn_cast<MemberExpr>(E)) - return ME->getMemberDecl(); - if (ObjCIvarRefExpr *IRE = dyn_cast<ObjCIvarRefExpr>(E)) - return IRE->getDecl(); - - return nullptr; - } - - /// Check if the retain/release is due to a GCD/XPC macro that are - /// defined as: - /// - /// #define dispatch_retain(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); (void)[_o retain]; }) - /// #define dispatch_release(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); [_o release]; }) - /// #define xpc_retain(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o retain]; }) - /// #define xpc_release(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o release]; }) - /// - /// and return the top container which is the StmtExpr and the macro argument - /// expression. - void checkForGCDOrXPC(ObjCMessageExpr *Msg, Expr *&RecContainer, - Expr *&Rec, SourceRange &RecRange) { - SourceLocation Loc = Msg->getExprLoc(); - if (!Loc.isMacroID()) - return; - SourceManager &SM = Pass.Ctx.getSourceManager(); - StringRef MacroName = Lexer::getImmediateMacroName(Loc, SM, - Pass.Ctx.getLangOpts()); - bool isGCDOrXPC = llvm::StringSwitch<bool>(MacroName) - .Case("dispatch_retain", true) - .Case("dispatch_release", true) - .Case("xpc_retain", true) - .Case("xpc_release", true) - .Default(false); - if (!isGCDOrXPC) - return; - - StmtExpr *StmtE = nullptr; - Stmt *S = Msg; - while (S) { - if (StmtExpr *SE = dyn_cast<StmtExpr>(S)) { - StmtE = SE; - break; - } - S = StmtMap->getParent(S); - } - - if (!StmtE) - return; - - Stmt::child_range StmtExprChild = StmtE->children(); - if (StmtExprChild.begin() == StmtExprChild.end()) - return; - auto *CompS = dyn_cast_or_null<CompoundStmt>(*StmtExprChild.begin()); - if (!CompS) - return; - - Stmt::child_range CompStmtChild = CompS->children(); - if (CompStmtChild.begin() == CompStmtChild.end()) - return; - auto *DeclS = dyn_cast_or_null<DeclStmt>(*CompStmtChild.begin()); - if (!DeclS) - return; - if (!DeclS->isSingleDecl()) - return; - VarDecl *VD = dyn_cast_or_null<VarDecl>(DeclS->getSingleDecl()); - if (!VD) - return; - Expr *Init = VD->getInit(); - if (!Init) - return; - - RecContainer = StmtE; - Rec = Init->IgnoreParenImpCasts(); - if (FullExpr *FE = dyn_cast<FullExpr>(Rec)) - Rec = FE->getSubExpr()->IgnoreParenImpCasts(); - RecRange = Rec->getSourceRange(); - if (SM.isMacroArgExpansion(RecRange.getBegin())) - RecRange.setBegin(SM.getImmediateSpellingLoc(RecRange.getBegin())); - if (SM.isMacroArgExpansion(RecRange.getEnd())) - RecRange.setEnd(SM.getImmediateSpellingLoc(RecRange.getEnd())); - } - - void clearDiagnostics(SourceLocation loc) const { - Pass.TA.clearDiagnostic(diag::err_arc_illegal_explicit_message, - diag::err_unavailable, - diag::err_unavailable_message, - loc); - } - - bool isDelegateMessage(Expr *E) const { - if (!E) return false; - - E = E->IgnoreParenCasts(); - - // Also look through property-getter sugar. - if (PseudoObjectExpr *pseudoOp = dyn_cast<PseudoObjectExpr>(E)) - E = pseudoOp->getResultExpr()->IgnoreImplicit(); - - if (ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(E)) - return (ME->isInstanceMessage() && ME->getSelector() == DelegateSel); - - return false; - } - - bool isInAtFinally(Expr *E) const { - assert(E); - Stmt *S = E; - while (S) { - if (isa<ObjCAtFinallyStmt>(S)) - return true; - S = StmtMap->getParent(S); - } - - return false; - } - - bool isRemovable(Expr *E) const { - return Removables.count(E); - } - - bool tryRemoving(Expr *E) const { - if (isRemovable(E)) { - Pass.TA.removeStmt(E); - return true; - } - - Stmt *parent = StmtMap->getParent(E); - - if (ImplicitCastExpr *castE = dyn_cast_or_null<ImplicitCastExpr>(parent)) - return tryRemoving(castE); - - if (ParenExpr *parenE = dyn_cast_or_null<ParenExpr>(parent)) - return tryRemoving(parenE); - - if (BinaryOperator * - bopE = dyn_cast_or_null<BinaryOperator>(parent)) { - if (bopE->getOpcode() == BO_Comma && bopE->getLHS() == E && - isRemovable(bopE)) { - Pass.TA.replace(bopE->getSourceRange(), bopE->getRHS()->getSourceRange()); - return true; - } - } - - return false; - } - -}; - -} // anonymous namespace - -void trans::removeRetainReleaseDeallocFinalize(MigrationPass &pass) { - BodyTransform<RetainReleaseDeallocRemover> trans(pass); - trans.TraverseDecl(pass.Ctx.getTranslationUnitDecl()); -} diff --git clang/lib/ARCMigrate/TransUnbridgedCasts.cpp clang/lib/ARCMigrate/TransUnbridgedCasts.cpp deleted file mode 100644 index 7390ea17c8a4..000000000000 --- clang/lib/ARCMigrate/TransUnbridgedCasts.cpp +++ /dev/null @@ -1,466 +0,0 @@ -//===--- TransUnbridgedCasts.cpp - Transformations to ARC mode ------------===// -// -// 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 -// -//===----------------------------------------------------------------------===// -// -// rewriteUnbridgedCasts: -// -// A cast of non-objc pointer to an objc one is checked. If the non-objc pointer -// is from a file-level variable, __bridge cast is used to convert it. -// For the result of a function call that we know is +1/+0, -// __bridge/CFBridgingRelease is used. -// -// NSString *str = (NSString *)kUTTypePlainText; -// str = b ? kUTTypeRTF : kUTTypePlainText; -// NSString *_uuidString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, -// _uuid); -// ----> -// NSString *str = (__bridge NSString *)kUTTypePlainText; -// str = (__bridge NSString *)(b ? kUTTypeRTF : kUTTypePlainText); -// NSString *_uuidString = (NSString *) -// CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, _uuid)); -// -// For a C pointer to ObjC, for casting 'self', __bridge is used. -// -// CFStringRef str = (CFStringRef)self; -// ----> -// CFStringRef str = (__bridge CFStringRef)self; -// -// Uses of Block_copy/Block_release macros are rewritten: -// -// c = Block_copy(b); -// Block_release(c); -// ----> -// c = [b copy]; -// <removed> -// -//===----------------------------------------------------------------------===// - -#include "Transforms.h" -#include "Internals.h" -#include "clang/AST/ASTContext.h" -#include "clang/AST/Attr.h" -#include "clang/AST/ParentMap.h" -#include "clang/Analysis/DomainSpecific/CocoaConventions.h" -#include "clang/Basic/SourceManager.h" -#include "clang/Lex/Lexer.h" -#include "clang/Sema/SemaDiagnostic.h" -#include "llvm/ADT/SmallString.h" - -using namespace clang; -using namespace arcmt; -using namespace trans; - -namespace { - -class UnbridgedCastRewriter : public RecursiveASTVisitor<UnbridgedCastRewriter>{ - MigrationPass &Pass; - IdentifierInfo *SelfII; - std::unique_ptr<ParentMap> StmtMap; - Decl *ParentD; - Stmt *Body; - mutable std::unique_ptr<ExprSet> Removables; - -public: - UnbridgedCastRewriter(MigrationPass &pass) - : Pass(pass), ParentD(nullptr), Body(nullptr) { - SelfII = &Pass.Ctx.Idents.get("self"); - } - - void transformBody(Stmt *body, Decl *ParentD) { - this->ParentD = ParentD; - Body = body; - StmtMap.reset(new ParentMap(body)); - TraverseStmt(body); - } - - bool TraverseBlockDecl(BlockDecl *D) { - // ParentMap does not enter into a BlockDecl to record its stmts, so use a - // new UnbridgedCastRewriter to handle the block. - UnbridgedCastRewriter(Pass).transformBody(D->getBody(), D); - return true; - } - - bool VisitCastExpr(CastExpr *E) { - if (E->getCastKind() != CK_CPointerToObjCPointerCast && - E->getCastKind() != CK_BitCast && - E->getCastKind() != CK_AnyPointerToBlockPointerCast) - return true; - - QualType castType = E->getType(); - Expr *castExpr = E->getSubExpr(); - QualType castExprType = castExpr->getType(); - - if (castType->isObjCRetainableType() == castExprType->isObjCRetainableType()) - return true; - - bool exprRetainable = castExprType->isObjCIndirectLifetimeType(); - bool castRetainable = castType->isObjCIndirectLifetimeType(); - if (exprRetainable == castRetainable) return true; - - if (castExpr->isNullPointerConstant(Pass.Ctx, - Expr::NPC_ValueDependentIsNull)) - return true; - - SourceLocation loc = castExpr->getExprLoc(); - if (loc.isValid() && Pass.Ctx.getSourceManager().isInSystemHeader(loc)) - return true; - - if (castType->isObjCRetainableType()) - transformNonObjCToObjCCast(E); - else - transformObjCToNonObjCCast(E); - - return true; - } - -private: - void transformNonObjCToObjCCast(CastExpr *E) { - if (!E) return; - - // Global vars are assumed that are cast as unretained. - if (isGlobalVar(E)) - if (E->getSubExpr()->getType()->isPointerType()) { - castToObjCObject(E, /*retained=*/false); - return; - } - - // If the cast is directly over the result of a Core Foundation function - // try to figure out whether it should be cast as retained or unretained. - Expr *inner = E->IgnoreParenCasts(); - if (CallExpr *callE = dyn_cast<CallExpr>(inner)) { - if (FunctionDecl *FD = callE->getDirectCallee()) { - if (FD->hasAttr<CFReturnsRetainedAttr>()) { - castToObjCObject(E, /*retained=*/true); - return; - } - if (FD->hasAttr<CFReturnsNotRetainedAttr>()) { - castToObjCObject(E, /*retained=*/false); - return; - } - if (FD->isGlobal() && - FD->getIdentifier() && - ento::cocoa::isRefType(E->getSubExpr()->getType(), "CF", - FD->getIdentifier()->getName())) { - StringRef fname = FD->getIdentifier()->getName(); - if (fname.ends_with("Retain") || fname.contains("Create") || - fname.contains("Copy")) { - // Do not migrate to couple of bridge transfer casts which - // cancel each other out. Leave it unchanged so error gets user - // attention instead. - if (FD->getName() == "CFRetain" && - FD->getNumParams() == 1 && - FD->getParent()->isTranslationUnit() && - FD->isExternallyVisible()) { - Expr *Arg = callE->getArg(0); - if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Arg)) { - const Expr *sub = ICE->getSubExpr(); - QualType T = sub->getType(); - if (T->isObjCObjectPointerType()) - return; - } - } - castToObjCObject(E, /*retained=*/true); - return; - } - - if (fname.contains("Get")) { - castToObjCObject(E, /*retained=*/false); - return; - } - } - } - } - - // If returning an ivar or a member of an ivar from a +0 method, use - // a __bridge cast. - Expr *base = inner->IgnoreParenImpCasts(); - while (isa<MemberExpr>(base)) - base = cast<MemberExpr>(base)->getBase()->IgnoreParenImpCasts(); - if (isa<ObjCIvarRefExpr>(base) && - isa<ReturnStmt>(StmtMap->getParentIgnoreParenCasts(E))) { - if (ObjCMethodDecl *method = dyn_cast_or_null<ObjCMethodDecl>(ParentD)) { - if (!method->hasAttr<NSReturnsRetainedAttr>()) { - castToObjCObject(E, /*retained=*/false); - return; - } - } - } - } - - void castToObjCObject(CastExpr *E, bool retained) { - rewriteToBridgedCast(E, retained ? OBC_BridgeTransfer : OBC_Bridge); - } - - void rewriteToBridgedCast(CastExpr *E, ObjCBridgeCastKind Kind) { - Transaction Trans(Pass.TA); - rewriteToBridgedCast(E, Kind, Trans); - } - - void rewriteToBridgedCast(CastExpr *E, ObjCBridgeCastKind Kind, - Transaction &Trans) { - TransformActions &TA = Pass.TA; - - // We will remove the compiler diagnostic. - if (!TA.hasDiagnostic(diag::err_arc_mismatched_cast, - diag::err_arc_cast_requires_bridge, - E->getBeginLoc())) { - Trans.abort(); - return; - } - - StringRef bridge; - switch(Kind) { - case OBC_Bridge: - bridge = "__bridge "; break; - case OBC_BridgeTransfer: - bridge = "__bridge_transfer "; break; - case OBC_BridgeRetained: - bridge = "__bridge_retained "; break; - } - - TA.clearDiagnostic(diag::err_arc_mismatched_cast, - diag::err_arc_cast_requires_bridge, E->getBeginLoc()); - if (Kind == OBC_Bridge || !Pass.CFBridgingFunctionsDefined()) { - if (CStyleCastExpr *CCE = dyn_cast<CStyleCastExpr>(E)) { - TA.insertAfterToken(CCE->getLParenLoc(), bridge); - } else { - SourceLocation insertLoc = E->getSubExpr()->getBeginLoc(); - SmallString<128> newCast; - newCast += '('; - newCast += bridge; - newCast += E->getType().getAsString(Pass.Ctx.getPrintingPolicy()); - newCast += ')'; - - if (isa<ParenExpr>(E->getSubExpr())) { - TA.insert(insertLoc, newCast.str()); - } else { - newCast += '('; - TA.insert(insertLoc, newCast.str()); - TA.insertAfterToken(E->getEndLoc(), ")"); - } - } - } else { - assert(Kind == OBC_BridgeTransfer || Kind == OBC_BridgeRetained); - SmallString<32> BridgeCall; - - Expr *WrapE = E->getSubExpr(); - SourceLocation InsertLoc = WrapE->getBeginLoc(); - - SourceManager &SM = Pass.Ctx.getSourceManager(); - char PrevChar = *SM.getCharacterData(InsertLoc.getLocWithOffset(-1)); - if (Lexer::isAsciiIdentifierContinueChar(PrevChar, - Pass.Ctx.getLangOpts())) - BridgeCall += ' '; - - if (Kind == OBC_BridgeTransfer) - BridgeCall += "CFBridgingRelease"; - else - BridgeCall += "CFBridgingRetain"; - - if (isa<ParenExpr>(WrapE)) { - TA.insert(InsertLoc, BridgeCall); - } else { - BridgeCall += '('; - TA.insert(InsertLoc, BridgeCall); - TA.insertAfterToken(WrapE->getEndLoc(), ")"); - } - } - } - - void rewriteCastForCFRetain(CastExpr *castE, CallExpr *callE) { - Transaction Trans(Pass.TA); - Pass.TA.replace(callE->getSourceRange(), callE->getArg(0)->getSourceRange()); - rewriteToBridgedCast(castE, OBC_BridgeRetained, Trans); - } - - void getBlockMacroRanges(CastExpr *E, SourceRange &Outer, SourceRange &Inner) { - SourceManager &SM = Pass.Ctx.getSourceManager(); - SourceLocation Loc = E->getExprLoc(); - assert(Loc.isMacroID()); - CharSourceRange MacroRange = SM.getImmediateExpansionRange(Loc); - SourceRange SubRange = E->getSubExpr()->IgnoreParenImpCasts()->getSourceRange(); - SourceLocation InnerBegin = SM.getImmediateMacroCallerLoc(SubRange.getBegin()); - SourceLocation InnerEnd = SM.getImmediateMacroCallerLoc(SubRange.getEnd()); - - Outer = MacroRange.getAsRange(); - Inner = SourceRange(InnerBegin, InnerEnd); - } - - void rewriteBlockCopyMacro(CastExpr *E) { - SourceRange OuterRange, InnerRange; - getBlockMacroRanges(E, OuterRange, InnerRange); - - Transaction Trans(Pass.TA); - Pass.TA.replace(OuterRange, InnerRange); - Pass.TA.insert(InnerRange.getBegin(), "["); - Pass.TA.insertAfterToken(InnerRange.getEnd(), " copy]"); - Pass.TA.clearDiagnostic(diag::err_arc_mismatched_cast, - diag::err_arc_cast_requires_bridge, - OuterRange); - } - - void removeBlockReleaseMacro(CastExpr *E) { - SourceRange OuterRange, InnerRange; - getBlockMacroRanges(E, OuterRange, InnerRange); - - Transaction Trans(Pass.TA); - Pass.TA.clearDiagnostic(diag::err_arc_mismatched_cast, - diag::err_arc_cast_requires_bridge, - OuterRange); - if (!hasSideEffects(E, Pass.Ctx)) { - if (tryRemoving(cast<Expr>(StmtMap->getParentIgnoreParenCasts(E)))) - return; - } - Pass.TA.replace(OuterRange, InnerRange); - } - - bool tryRemoving(Expr *E) const { - if (!Removables) { - Removables.reset(new ExprSet); - collectRemovables(Body, *Removables); - } - - if (Removables->count(E)) { - Pass.TA.removeStmt(E); - return true; - } - - return false; - } - - void transformObjCToNonObjCCast(CastExpr *E) { - SourceLocation CastLoc = E->getExprLoc(); - if (CastLoc.isMacroID()) { - StringRef MacroName = Lexer::getImmediateMacroName(CastLoc, - Pass.Ctx.getSourceManager(), - Pass.Ctx.getLangOpts()); - if (MacroName == "Block_copy") { - rewriteBlockCopyMacro(E); - return; - } - if (MacroName == "Block_release") { - removeBlockReleaseMacro(E); - return; - } - } - - if (isSelf(E->getSubExpr())) - return rewriteToBridgedCast(E, OBC_Bridge); - - CallExpr *callE; - if (isPassedToCFRetain(E, callE)) - return rewriteCastForCFRetain(E, callE); - - ObjCMethodFamily family = getFamilyOfMessage(E->getSubExpr()); - if (family == OMF_retain) - return rewriteToBridgedCast(E, OBC_BridgeRetained); - - if (family == OMF_autorelease || family == OMF_release) { - std::string err = "it is not safe to cast to '"; - err += E->getType().getAsString(Pass.Ctx.getPrintingPolicy()); - err += "' the result of '"; - err += family == OMF_autorelease ? "autorelease" : "release"; - err += "' message; a __bridge cast may result in a pointer to a " - "destroyed object and a __bridge_retained may leak the object"; - Pass.TA.reportError(err, E->getBeginLoc(), - E->getSubExpr()->getSourceRange()); - Stmt *parent = E; - do { - parent = StmtMap->getParentIgnoreParenImpCasts(parent); - } while (isa_and_nonnull<FullExpr>(parent)); - - if (ReturnStmt *retS = dyn_cast_or_null<ReturnStmt>(parent)) { - std::string note = "remove the cast and change return type of function " - "to '"; - note += E->getSubExpr()->getType().getAsString(Pass.Ctx.getPrintingPolicy()); - note += "' to have the object automatically autoreleased"; - Pass.TA.reportNote(note, retS->getBeginLoc()); - } - } - - Expr *subExpr = E->getSubExpr(); - - // Look through pseudo-object expressions. - if (PseudoObjectExpr *pseudo = dyn_cast<PseudoObjectExpr>(subExpr)) { - subExpr = pseudo->getResultExpr(); - assert(subExpr && "no result for pseudo-object of non-void type?"); - } - - if (ImplicitCastExpr *implCE = dyn_cast<ImplicitCastExpr>(subExpr)) { - if (implCE->getCastKind() == CK_ARCConsumeObject) - return rewriteToBridgedCast(E, OBC_BridgeRetained); - if (implCE->getCastKind() == CK_ARCReclaimReturnedObject) - return rewriteToBridgedCast(E, OBC_Bridge); - } - - bool isConsumed = false; - if (isPassedToCParamWithKnownOwnership(E, isConsumed)) - return rewriteToBridgedCast(E, isConsumed ? OBC_BridgeRetained - : OBC_Bridge); - } - - static ObjCMethodFamily getFamilyOfMessage(Expr *E) { - E = E->IgnoreParenCasts(); - if (ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(E)) - return ME->getMethodFamily(); - - return OMF_None; - } - - bool isPassedToCFRetain(Expr *E, CallExpr *&callE) const { - if ((callE = dyn_cast_or_null<CallExpr>( - StmtMap->getParentIgnoreParenImpCasts(E)))) - if (FunctionDecl * - FD = dyn_cast_or_null<FunctionDecl>(callE->getCalleeDecl())) - if (FD->getName() == "CFRetain" && FD->getNumParams() == 1 && - FD->getParent()->isTranslationUnit() && - FD->isExternallyVisible()) - return true; - - return false; - } - - bool isPassedToCParamWithKnownOwnership(Expr *E, bool &isConsumed) const { - if (CallExpr *callE = dyn_cast_or_null<CallExpr>( - StmtMap->getParentIgnoreParenImpCasts(E))) - if (FunctionDecl * - FD = dyn_cast_or_null<FunctionDecl>(callE->getCalleeDecl())) { - unsigned i = 0; - for (unsigned e = callE->getNumArgs(); i != e; ++i) { - Expr *arg = callE->getArg(i); - if (arg == E || arg->IgnoreParenImpCasts() == E) - break; - } - if (i < callE->getNumArgs() && i < FD->getNumParams()) { - ParmVarDecl *PD = FD->getParamDecl(i); - if (PD->hasAttr<CFConsumedAttr>()) { - isConsumed = true; - return true; - } - } - } - - return false; - } - - bool isSelf(Expr *E) const { - E = E->IgnoreParenLValueCasts(); - if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) - if (ImplicitParamDecl *IPD = dyn_cast<ImplicitParamDecl>(DRE->getDecl())) - if (IPD->getIdentifier() == SelfII) - return true; - - return false; - } -}; - -} // end anonymous namespace - -void trans::rewriteUnbridgedCasts(MigrationPass &pass) { - BodyTransform<UnbridgedCastRewriter> trans(pass); - trans.TraverseDecl(pass.Ctx.getTranslationUnitDecl()); -} diff --git clang/lib/ARCMigrate/TransUnusedInitDelegate.cpp clang/lib/ARCMigrate/TransUnusedInitDelegate.cpp deleted file mode 100644 index bac8dfac9b41..000000000000 --- clang/lib/ARCMigrate/TransUnusedInitDelegate.cpp +++ /dev/null @@ -1,77 +0,0 @@ -//===--- TransUnusedInitDelegate.cpp - Transformations to ARC mode --------===// -// -// 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 -// -//===----------------------------------------------------------------------===// -// Transformations: -//===----------------------------------------------------------------------===// -// -// rewriteUnusedInitDelegate: -// -// Rewrites an unused result of calling a delegate initialization, to assigning -// the result to self. -// e.g -// [self init]; -// ----> -// self = [self init]; -// -//===----------------------------------------------------------------------===// - -#include "Transforms.h" -#include "Internals.h" -#include "clang/AST/ASTContext.h" -#include "clang/Sema/SemaDiagnostic.h" - -using namespace clang; -using namespace arcmt; -using namespace trans; - -namespace { - -class UnusedInitRewriter : public RecursiveASTVisitor<UnusedInitRewriter> { - Stmt *Body; - MigrationPass &Pass; - - ExprSet Removables; - -public: - UnusedInitRewriter(MigrationPass &pass) - : Body(nullptr), Pass(pass) { } - - void transformBody(Stmt *body, Decl *ParentD) { - Body = body; - collectRemovables(body, Removables); - TraverseStmt(body); - } - - bool VisitObjCMessageExpr(ObjCMessageExpr *ME) { - if (ME->isDelegateInitCall() && - isRemovable(ME) && - Pass.TA.hasDiagnostic(diag::err_arc_unused_init_message, - ME->getExprLoc())) { - Transaction Trans(Pass.TA); - Pass.TA.clearDiagnostic(diag::err_arc_unused_init_message, - ME->getExprLoc()); - SourceRange ExprRange = ME->getSourceRange(); - Pass.TA.insert(ExprRange.getBegin(), "if (!(self = "); - std::string retStr = ")) return "; - retStr += getNilString(Pass); - Pass.TA.insertAfterToken(ExprRange.getEnd(), retStr); - } - return true; - } - -private: - bool isRemovable(Expr *E) const { - return Removables.count(E); - } -}; - -} // anonymous namespace - -void trans::rewriteUnusedInitDelegate(MigrationPass &pass) { - BodyTransform<UnusedInitRewriter> trans(pass); - trans.TraverseDecl(pass.Ctx.getTranslationUnitDecl()); -} diff --git clang/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp clang/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp deleted file mode 100644 index 81e67628fb1f..000000000000 --- clang/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp +++ /dev/null @@ -1,224 +0,0 @@ -//===--- TransZeroOutPropsInDealloc.cpp - Transformations to ARC mode -----===// -// -// 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 -// -//===----------------------------------------------------------------------===// -// -// removeZeroOutPropsInDealloc: -// -// Removes zero'ing out "strong" @synthesized properties in a -dealloc method. -// -//===----------------------------------------------------------------------===// - -#include "Transforms.h" -#include "Internals.h" -#include "clang/AST/ASTContext.h" - -using namespace clang; -using namespace arcmt; -using namespace trans; - -namespace { - -class ZeroOutInDeallocRemover : - public RecursiveASTVisitor<ZeroOutInDeallocRemover> { - typedef RecursiveASTVisitor<ZeroOutInDeallocRemover> base; - - MigrationPass &Pass; - - llvm::DenseMap<ObjCPropertyDecl*, ObjCPropertyImplDecl*> SynthesizedProperties; - ImplicitParamDecl *SelfD; - ExprSet Removables; - Selector FinalizeSel; - -public: - ZeroOutInDeallocRemover(MigrationPass &pass) : Pass(pass), SelfD(nullptr) { - FinalizeSel = - Pass.Ctx.Selectors.getNullarySelector(&Pass.Ctx.Idents.get("finalize")); - } - - bool VisitObjCMessageExpr(ObjCMessageExpr *ME) { - ASTContext &Ctx = Pass.Ctx; - TransformActions &TA = Pass.TA; - - if (ME->getReceiverKind() != ObjCMessageExpr::Instance) - return true; - Expr *receiver = ME->getInstanceReceiver(); - if (!receiver) - return true; - - DeclRefExpr *refE = dyn_cast<DeclRefExpr>(receiver->IgnoreParenCasts()); - if (!refE || refE->getDecl() != SelfD) - return true; - - bool BackedBySynthesizeSetter = false; - for (llvm::DenseMap<ObjCPropertyDecl*, ObjCPropertyImplDecl*>::iterator - P = SynthesizedProperties.begin(), - E = SynthesizedProperties.end(); P != E; ++P) { - ObjCPropertyDecl *PropDecl = P->first; - if (PropDecl->getSetterName() == ME->getSelector()) { - BackedBySynthesizeSetter = true; - break; - } - } - if (!BackedBySynthesizeSetter) - return true; - - // Remove the setter message if RHS is null - Transaction Trans(TA); - Expr *RHS = ME->getArg(0); - bool RHSIsNull = - RHS->isNullPointerConstant(Ctx, - Expr::NPC_ValueDependentIsNull); - if (RHSIsNull && isRemovable(ME)) - TA.removeStmt(ME); - - return true; - } - - bool VisitPseudoObjectExpr(PseudoObjectExpr *POE) { - if (isZeroingPropIvar(POE) && isRemovable(POE)) { - Transaction Trans(Pass.TA); - Pass.TA.removeStmt(POE); - } - - return true; - } - - bool VisitBinaryOperator(BinaryOperator *BOE) { - if (isZeroingPropIvar(BOE) && isRemovable(BOE)) { - Transaction Trans(Pass.TA); - Pass.TA.removeStmt(BOE); - } - - return true; - } - - bool TraverseObjCMethodDecl(ObjCMethodDecl *D) { - if (D->getMethodFamily() != OMF_dealloc && - !(D->isInstanceMethod() && D->getSelector() == FinalizeSel)) - return true; - if (!D->hasBody()) - return true; - - ObjCImplDecl *IMD = dyn_cast<ObjCImplDecl>(D->getDeclContext()); - if (!IMD) - return true; - - SelfD = D->getSelfDecl(); - collectRemovables(D->getBody(), Removables); - - // For a 'dealloc' method use, find all property implementations in - // this class implementation. - for (auto *PID : IMD->property_impls()) { - if (PID->getPropertyImplementation() == - ObjCPropertyImplDecl::Synthesize) { - ObjCPropertyDecl *PD = PID->getPropertyDecl(); - ObjCMethodDecl *setterM = PD->getSetterMethodDecl(); - if (!(setterM && setterM->isDefined())) { - ObjCPropertyAttribute::Kind AttrKind = PD->getPropertyAttributes(); - if (AttrKind & (ObjCPropertyAttribute::kind_retain | - ObjCPropertyAttribute::kind_copy | - ObjCPropertyAttribute::kind_strong)) - SynthesizedProperties[PD] = PID; - } - } - } - - // Now, remove all zeroing of ivars etc. - base::TraverseObjCMethodDecl(D); - - // clear out for next method. - SynthesizedProperties.clear(); - SelfD = nullptr; - Removables.clear(); - return true; - } - - bool TraverseFunctionDecl(FunctionDecl *D) { return true; } - bool TraverseBlockDecl(BlockDecl *block) { return true; } - bool TraverseBlockExpr(BlockExpr *block) { return true; } - -private: - bool isRemovable(Expr *E) const { - return Removables.count(E); - } - - bool isZeroingPropIvar(Expr *E) { - E = E->IgnoreParens(); - if (BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) - return isZeroingPropIvar(BO); - if (PseudoObjectExpr *PO = dyn_cast<PseudoObjectExpr>(E)) - return isZeroingPropIvar(PO); - return false; - } - - bool isZeroingPropIvar(BinaryOperator *BOE) { - if (BOE->getOpcode() == BO_Comma) - return isZeroingPropIvar(BOE->getLHS()) && - isZeroingPropIvar(BOE->getRHS()); - - if (BOE->getOpcode() != BO_Assign) - return false; - - Expr *LHS = BOE->getLHS(); - if (ObjCIvarRefExpr *IV = dyn_cast<ObjCIvarRefExpr>(LHS)) { - ObjCIvarDecl *IVDecl = IV->getDecl(); - if (!IVDecl->getType()->isObjCObjectPointerType()) - return false; - bool IvarBacksPropertySynthesis = false; - for (llvm::DenseMap<ObjCPropertyDecl*, ObjCPropertyImplDecl*>::iterator - P = SynthesizedProperties.begin(), - E = SynthesizedProperties.end(); P != E; ++P) { - ObjCPropertyImplDecl *PropImpDecl = P->second; - if (PropImpDecl && PropImpDecl->getPropertyIvarDecl() == IVDecl) { - IvarBacksPropertySynthesis = true; - break; - } - } - if (!IvarBacksPropertySynthesis) - return false; - } - else - return false; - - return isZero(BOE->getRHS()); - } - - bool isZeroingPropIvar(PseudoObjectExpr *PO) { - BinaryOperator *BO = dyn_cast<BinaryOperator>(PO->getSyntacticForm()); - if (!BO) return false; - if (BO->getOpcode() != BO_Assign) return false; - - ObjCPropertyRefExpr *PropRefExp = - dyn_cast<ObjCPropertyRefExpr>(BO->getLHS()->IgnoreParens()); - if (!PropRefExp) return false; - - // TODO: Using implicit property decl. - if (PropRefExp->isImplicitProperty()) - return false; - - if (ObjCPropertyDecl *PDecl = PropRefExp->getExplicitProperty()) { - if (!SynthesizedProperties.count(PDecl)) - return false; - } - - return isZero(cast<OpaqueValueExpr>(BO->getRHS())->getSourceExpr()); - } - - bool isZero(Expr *E) { - if (E->isNullPointerConstant(Pass.Ctx, Expr::NPC_ValueDependentIsNull)) - return true; - - return isZeroingPropIvar(E); - } -}; - -} // anonymous namespace - -void trans::removeZeroOutPropsInDeallocFinalize(MigrationPass &pass) { - ZeroOutInDeallocRemover trans(pass); - trans.TraverseDecl(pass.Ctx.getTranslationUnitDecl()); -} diff --git clang/lib/ARCMigrate/TransformActions.cpp clang/lib/ARCMigrate/TransformActions.cpp deleted file mode 100644 index 6bc6fed1a903..000000000000 --- clang/lib/ARCMigrate/TransformActions.cpp +++ /dev/null @@ -1,700 +0,0 @@ -//===-- TransformActions.cpp - Migration to ARC mode ----------------------===// -// -// 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 "Internals.h" -#include "clang/AST/ASTContext.h" -#include "clang/AST/Expr.h" -#include "clang/Basic/SourceManager.h" -#include "clang/Lex/Preprocessor.h" -#include "llvm/ADT/DenseSet.h" -#include <map> -using namespace clang; -using namespace arcmt; - -namespace { - -/// Collects transformations and merges them before applying them with -/// with applyRewrites(). E.g. if the same source range -/// is requested to be removed twice, only one rewriter remove will be invoked. -/// Rewrites happen in "transactions"; if one rewrite in the transaction cannot -/// be done (e.g. it resides in a macro) all rewrites in the transaction are -/// aborted. -/// FIXME: "Transactional" rewrites support should be baked in the Rewriter. -class TransformActionsImpl { - CapturedDiagList &CapturedDiags; - ASTContext &Ctx; - Preprocessor &PP; - - bool IsInTransaction; - - enum ActionKind { - Act_Insert, Act_InsertAfterToken, - Act_Remove, Act_RemoveStmt, - Act_Replace, Act_ReplaceText, - Act_IncreaseIndentation, - Act_ClearDiagnostic - }; - - struct ActionData { - ActionKind Kind; - SourceLocation Loc; - SourceRange R1, R2; - StringRef Text1, Text2; - Stmt *S; - SmallVector<unsigned, 2> DiagIDs; - }; - - std::vector<ActionData> CachedActions; - - enum RangeComparison { - Range_Before, - Range_After, - Range_Contains, - Range_Contained, - Range_ExtendsBegin, - Range_ExtendsEnd - }; - - /// A range to remove. It is a character range. - struct CharRange { - FullSourceLoc Begin, End; - - CharRange(CharSourceRange range, SourceManager &srcMgr, Preprocessor &PP) { - SourceLocation beginLoc = range.getBegin(), endLoc = range.getEnd(); - assert(beginLoc.isValid() && endLoc.isValid()); - if (range.isTokenRange()) { - Begin = FullSourceLoc(srcMgr.getExpansionLoc(beginLoc), srcMgr); - End = FullSourceLoc(getLocForEndOfToken(endLoc, srcMgr, PP), srcMgr); - } else { - Begin = FullSourceLoc(srcMgr.getExpansionLoc(beginLoc), srcMgr); - End = FullSourceLoc(srcMgr.getExpansionLoc(endLoc), srcMgr); - } - assert(Begin.isValid() && End.isValid()); - } - - RangeComparison compareWith(const CharRange &RHS) const { - if (End.isBeforeInTranslationUnitThan(RHS.Begin)) - return Range_Before; - if (RHS.End.isBeforeInTranslationUnitThan(Begin)) - return Range_After; - if (!Begin.isBeforeInTranslationUnitThan(RHS.Begin) && - !RHS.End.isBeforeInTranslationUnitThan(End)) - return Range_Contained; - if (Begin.isBeforeInTranslationUnitThan(RHS.Begin) && - RHS.End.isBeforeInTranslationUnitThan(End)) - return Range_Contains; - if (Begin.isBeforeInTranslationUnitThan(RHS.Begin)) - return Range_ExtendsBegin; - else - return Range_ExtendsEnd; - } - - static RangeComparison compare(SourceRange LHS, SourceRange RHS, - SourceManager &SrcMgr, Preprocessor &PP) { - return CharRange(CharSourceRange::getTokenRange(LHS), SrcMgr, PP) - .compareWith(CharRange(CharSourceRange::getTokenRange(RHS), - SrcMgr, PP)); - } - }; - - typedef SmallVector<StringRef, 2> TextsVec; - typedef std::map<FullSourceLoc, TextsVec, FullSourceLoc::BeforeThanCompare> - InsertsMap; - InsertsMap Inserts; - /// A list of ranges to remove. They are always sorted and they never - /// intersect with each other. - std::list<CharRange> Removals; - - llvm::DenseSet<Stmt *> StmtRemovals; - - std::vector<std::pair<CharRange, SourceLocation> > IndentationRanges; - - /// Keeps text passed to transformation methods. - llvm::StringMap<bool> UniqueText; - -public: - TransformActionsImpl(CapturedDiagList &capturedDiags, - ASTContext &ctx, Preprocessor &PP) - : CapturedDiags(capturedDiags), Ctx(ctx), PP(PP), IsInTransaction(false) { } - - ASTContext &getASTContext() { return Ctx; } - - void startTransaction(); - bool commitTransaction(); - void abortTransaction(); - - bool isInTransaction() const { return IsInTransaction; } - - void insert(SourceLocation loc, StringRef text); - void insertAfterToken(SourceLocation loc, StringRef text); - void remove(SourceRange range); - void removeStmt(Stmt *S); - void replace(SourceRange range, StringRef text); - void replace(SourceRange range, SourceRange replacementRange); - void replaceStmt(Stmt *S, StringRef text); - void replaceText(SourceLocation loc, StringRef text, - StringRef replacementText); - void increaseIndentation(SourceRange range, - SourceLocation parentIndent); - - bool clearDiagnostic(ArrayRef<unsigned> IDs, SourceRange range); - - void applyRewrites(TransformActions::RewriteReceiver &receiver); - -private: - bool canInsert(SourceLocation loc); - bool canInsertAfterToken(SourceLocation loc); - bool canRemoveRange(SourceRange range); - bool canReplaceRange(SourceRange range, SourceRange replacementRange); - bool canReplaceText(SourceLocation loc, StringRef text); - - void commitInsert(SourceLocation loc, StringRef text); - void commitInsertAfterToken(SourceLocation loc, StringRef text); - void commitRemove(SourceRange range); - void commitRemoveStmt(Stmt *S); - void commitReplace(SourceRange range, SourceRange replacementRange); - void commitReplaceText(SourceLocation loc, StringRef text, - StringRef replacementText); - void commitIncreaseIndentation(SourceRange range,SourceLocation parentIndent); - void commitClearDiagnostic(ArrayRef<unsigned> IDs, SourceRange range); - - void addRemoval(CharSourceRange range); - void addInsertion(SourceLocation loc, StringRef text); - - /// Stores text passed to the transformation methods to keep the string - /// "alive". Since the vast majority of text will be the same, we also unique - /// the strings using a StringMap. - StringRef getUniqueText(StringRef text); - - /// Computes the source location just past the end of the token at - /// the given source location. If the location points at a macro, the whole - /// macro expansion is skipped. - static SourceLocation getLocForEndOfToken(SourceLocation loc, - SourceManager &SM,Preprocessor &PP); -}; - -} // anonymous namespace - -void TransformActionsImpl::startTransaction() { - assert(!IsInTransaction && - "Cannot start a transaction in the middle of another one"); - IsInTransaction = true; -} - -bool TransformActionsImpl::commitTransaction() { - assert(IsInTransaction && "No transaction started"); - - if (CachedActions.empty()) { - IsInTransaction = false; - return false; - } - - // Verify that all actions are possible otherwise abort the whole transaction. - bool AllActionsPossible = true; - for (unsigned i = 0, e = CachedActions.size(); i != e; ++i) { - ActionData &act = CachedActions[i]; - switch (act.Kind) { - case Act_Insert: - if (!canInsert(act.Loc)) - AllActionsPossible = false; - break; - case Act_InsertAfterToken: - if (!canInsertAfterToken(act.Loc)) - AllActionsPossible = false; - break; - case Act_Remove: - if (!canRemoveRange(act.R1)) - AllActionsPossible = false; - break; - case Act_RemoveStmt: - assert(act.S); - if (!canRemoveRange(act.S->getSourceRange())) - AllActionsPossible = false; - break; - case Act_Replace: - if (!canReplaceRange(act.R1, act.R2)) - AllActionsPossible = false; - break; - case Act_ReplaceText: - if (!canReplaceText(act.Loc, act.Text1)) - AllActionsPossible = false; - break; - case Act_IncreaseIndentation: - // This is not important, we don't care if it will fail. - break; - case Act_ClearDiagnostic: - // We are just checking source rewrites. - break; - } - if (!AllActionsPossible) - break; - } - - if (!AllActionsPossible) { - abortTransaction(); - return true; - } - - for (unsigned i = 0, e = CachedActions.size(); i != e; ++i) { - ActionData &act = CachedActions[i]; - switch (act.Kind) { - case Act_Insert: - commitInsert(act.Loc, act.Text1); - break; - case Act_InsertAfterToken: - commitInsertAfterToken(act.Loc, act.Text1); - break; - case Act_Remove: - commitRemove(act.R1); - break; - case Act_RemoveStmt: - commitRemoveStmt(act.S); - break; - case Act_Replace: - commitReplace(act.R1, act.R2); - break; - case Act_ReplaceText: - commitReplaceText(act.Loc, act.Text1, act.Text2); - break; - case Act_IncreaseIndentation: - commitIncreaseIndentation(act.R1, act.Loc); - break; - case Act_ClearDiagnostic: - commitClearDiagnostic(act.DiagIDs, act.R1); - break; - } - } - - CachedActions.clear(); - IsInTransaction = false; - return false; -} - -void TransformActionsImpl::abortTransaction() { - assert(IsInTransaction && "No transaction started"); - CachedActions.clear(); - IsInTransaction = false; -} - -void TransformActionsImpl::insert(SourceLocation loc, StringRef text) { - assert(IsInTransaction && "Actions only allowed during a transaction"); - text = getUniqueText(text); - ActionData data; - data.Kind = Act_Insert; - data.Loc = loc; - data.Text1 = text; - CachedActions.push_back(data); -} - -void TransformActionsImpl::insertAfterToken(SourceLocation loc, StringRef text) { - assert(IsInTransaction && "Actions only allowed during a transaction"); - text = getUniqueText(text); - ActionData data; - data.Kind = Act_InsertAfterToken; - data.Loc = loc; - data.Text1 = text; - CachedActions.push_back(data); -} - -void TransformActionsImpl::remove(SourceRange range) { - assert(IsInTransaction && "Actions only allowed during a transaction"); - ActionData data; - data.Kind = Act_Remove; - data.R1 = range; - CachedActions.push_back(data); -} - -void TransformActionsImpl::removeStmt(Stmt *S) { - assert(IsInTransaction && "Actions only allowed during a transaction"); - ActionData data; - data.Kind = Act_RemoveStmt; - if (auto *E = dyn_cast<Expr>(S)) - S = E->IgnoreImplicit(); // important for uniquing - data.S = S; - CachedActions.push_back(data); -} - -void TransformActionsImpl::replace(SourceRange range, StringRef text) { - assert(IsInTransaction && "Actions only allowed during a transaction"); - text = getUniqueText(text); - remove(range); - insert(range.getBegin(), text); -} - -void TransformActionsImpl::replace(SourceRange range, - SourceRange replacementRange) { - assert(IsInTransaction && "Actions only allowed during a transaction"); - ActionData data; - data.Kind = Act_Replace; - data.R1 = range; - data.R2 = replacementRange; - CachedActions.push_back(data); -} - -void TransformActionsImpl::replaceText(SourceLocation loc, StringRef text, - StringRef replacementText) { - text = getUniqueText(text); - replacementText = getUniqueText(replacementText); - ActionData data; - data.Kind = Act_ReplaceText; - data.Loc = loc; - data.Text1 = text; - data.Text2 = replacementText; - CachedActions.push_back(data); -} - -void TransformActionsImpl::replaceStmt(Stmt *S, StringRef text) { - assert(IsInTransaction && "Actions only allowed during a transaction"); - text = getUniqueText(text); - insert(S->getBeginLoc(), text); - removeStmt(S); -} - -void TransformActionsImpl::increaseIndentation(SourceRange range, - SourceLocation parentIndent) { - if (range.isInvalid()) return; - assert(IsInTransaction && "Actions only allowed during a transaction"); - ActionData data; - data.Kind = Act_IncreaseIndentation; - data.R1 = range; - data.Loc = parentIndent; - CachedActions.push_back(data); -} - -bool TransformActionsImpl::clearDiagnostic(ArrayRef<unsigned> IDs, - SourceRange range) { - assert(IsInTransaction && "Actions only allowed during a transaction"); - if (!CapturedDiags.hasDiagnostic(IDs, range)) - return false; - - ActionData data; - data.Kind = Act_ClearDiagnostic; - data.R1 = range; - data.DiagIDs.append(IDs.begin(), IDs.end()); - CachedActions.push_back(data); - return true; -} - -bool TransformActionsImpl::canInsert(SourceLocation loc) { - if (loc.isInvalid()) - return false; - - SourceManager &SM = Ctx.getSourceManager(); - if (SM.isInSystemHeader(SM.getExpansionLoc(loc))) - return false; - - if (loc.isFileID()) - return true; - return PP.isAtStartOfMacroExpansion(loc); -} - -bool TransformActionsImpl::canInsertAfterToken(SourceLocation loc) { - if (loc.isInvalid()) - return false; - - SourceManager &SM = Ctx.getSourceManager(); - if (SM.isInSystemHeader(SM.getExpansionLoc(loc))) - return false; - - if (loc.isFileID()) - return true; - return PP.isAtEndOfMacroExpansion(loc); -} - -bool TransformActionsImpl::canRemoveRange(SourceRange range) { - return canInsert(range.getBegin()) && canInsertAfterToken(range.getEnd()); -} - -bool TransformActionsImpl::canReplaceRange(SourceRange range, - SourceRange replacementRange) { - return canRemoveRange(range) && canRemoveRange(replacementRange); -} - -bool TransformActionsImpl::canReplaceText(SourceLocation loc, StringRef text) { - if (!canInsert(loc)) - return false; - - SourceManager &SM = Ctx.getSourceManager(); - loc = SM.getExpansionLoc(loc); - - // Break down the source location. - std::pair<FileID, unsigned> locInfo = SM.getDecomposedLoc(loc); - - // Try to load the file buffer. - bool invalidTemp = false; - StringRef file = SM.getBufferData(locInfo.first, &invalidTemp); - if (invalidTemp) - return false; - - return file.substr(locInfo.second).starts_with(text); -} - -void TransformActionsImpl::commitInsert(SourceLocation loc, StringRef text) { - addInsertion(loc, text); -} - -void TransformActionsImpl::commitInsertAfterToken(SourceLocation loc, - StringRef text) { - addInsertion(getLocForEndOfToken(loc, Ctx.getSourceManager(), PP), text); -} - -void TransformActionsImpl::commitRemove(SourceRange range) { - addRemoval(CharSourceRange::getTokenRange(range)); -} - -void TransformActionsImpl::commitRemoveStmt(Stmt *S) { - assert(S); - if (StmtRemovals.count(S)) - return; // already removed. - - if (Expr *E = dyn_cast<Expr>(S)) { - commitRemove(E->getSourceRange()); - commitInsert(E->getSourceRange().getBegin(), getARCMTMacroName()); - } else - commitRemove(S->getSourceRange()); - - StmtRemovals.insert(S); -} - -void TransformActionsImpl::commitReplace(SourceRange range, - SourceRange replacementRange) { - RangeComparison comp = CharRange::compare(replacementRange, range, - Ctx.getSourceManager(), PP); - assert(comp == Range_Contained); - if (comp != Range_Contained) - return; // Although we asserted, be extra safe for release build. - if (range.getBegin() != replacementRange.getBegin()) - addRemoval(CharSourceRange::getCharRange(range.getBegin(), - replacementRange.getBegin())); - if (replacementRange.getEnd() != range.getEnd()) - addRemoval(CharSourceRange::getTokenRange( - getLocForEndOfToken(replacementRange.getEnd(), - Ctx.getSourceManager(), PP), - range.getEnd())); -} -void TransformActionsImpl::commitReplaceText(SourceLocation loc, - StringRef text, - StringRef replacementText) { - SourceManager &SM = Ctx.getSourceManager(); - loc = SM.getExpansionLoc(loc); - // canReplaceText already checked if loc points at text. - SourceLocation afterText = loc.getLocWithOffset(text.size()); - - addRemoval(CharSourceRange::getCharRange(loc, afterText)); - commitInsert(loc, replacementText); -} - -void TransformActionsImpl::commitIncreaseIndentation(SourceRange range, - SourceLocation parentIndent) { - SourceManager &SM = Ctx.getSourceManager(); - IndentationRanges.push_back( - std::make_pair(CharRange(CharSourceRange::getTokenRange(range), - SM, PP), - SM.getExpansionLoc(parentIndent))); -} - -void TransformActionsImpl::commitClearDiagnostic(ArrayRef<unsigned> IDs, - SourceRange range) { - CapturedDiags.clearDiagnostic(IDs, range); -} - -void TransformActionsImpl::addInsertion(SourceLocation loc, StringRef text) { - SourceManager &SM = Ctx.getSourceManager(); - loc = SM.getExpansionLoc(loc); - for (const CharRange &I : llvm::reverse(Removals)) { - if (!SM.isBeforeInTranslationUnit(loc, I.End)) - break; - if (I.Begin.isBeforeInTranslationUnitThan(loc)) - return; - } - - Inserts[FullSourceLoc(loc, SM)].push_back(text); -} - -void TransformActionsImpl::addRemoval(CharSourceRange range) { - CharRange newRange(range, Ctx.getSourceManager(), PP); - if (newRange.Begin == newRange.End) - return; - - Inserts.erase(Inserts.upper_bound(newRange.Begin), - Inserts.lower_bound(newRange.End)); - - std::list<CharRange>::iterator I = Removals.end(); - while (I != Removals.begin()) { - std::list<CharRange>::iterator RI = I; - --RI; - RangeComparison comp = newRange.compareWith(*RI); - switch (comp) { - case Range_Before: - --I; - break; - case Range_After: - Removals.insert(I, newRange); - return; - case Range_Contained: - return; - case Range_Contains: - RI->End = newRange.End; - [[fallthrough]]; - case Range_ExtendsBegin: - newRange.End = RI->End; - Removals.erase(RI); - break; - case Range_ExtendsEnd: - RI->End = newRange.End; - return; - } - } - - Removals.insert(Removals.begin(), newRange); -} - -void TransformActionsImpl::applyRewrites( - TransformActions::RewriteReceiver &receiver) { - for (InsertsMap::iterator I = Inserts.begin(), E = Inserts.end(); I!=E; ++I) { - SourceLocation loc = I->first; - for (TextsVec::iterator - TI = I->second.begin(), TE = I->second.end(); TI != TE; ++TI) { - receiver.insert(loc, *TI); - } - } - - for (std::vector<std::pair<CharRange, SourceLocation> >::iterator - I = IndentationRanges.begin(), E = IndentationRanges.end(); I!=E; ++I) { - CharSourceRange range = CharSourceRange::getCharRange(I->first.Begin, - I->first.End); - receiver.increaseIndentation(range, I->second); - } - - for (std::list<CharRange>::iterator - I = Removals.begin(), E = Removals.end(); I != E; ++I) { - CharSourceRange range = CharSourceRange::getCharRange(I->Begin, I->End); - receiver.remove(range); - } -} - -/// Stores text passed to the transformation methods to keep the string -/// "alive". Since the vast majority of text will be the same, we also unique -/// the strings using a StringMap. -StringRef TransformActionsImpl::getUniqueText(StringRef text) { - return UniqueText.insert(std::make_pair(text, false)).first->first(); -} - -/// Computes the source location just past the end of the token at -/// the given source location. If the location points at a macro, the whole -/// macro expansion is skipped. -SourceLocation TransformActionsImpl::getLocForEndOfToken(SourceLocation loc, - SourceManager &SM, - Preprocessor &PP) { - if (loc.isMacroID()) { - CharSourceRange Exp = SM.getExpansionRange(loc); - if (Exp.isCharRange()) - return Exp.getEnd(); - loc = Exp.getEnd(); - } - return PP.getLocForEndOfToken(loc); -} - -TransformActions::RewriteReceiver::~RewriteReceiver() { } - -TransformActions::TransformActions(DiagnosticsEngine &diag, - CapturedDiagList &capturedDiags, - ASTContext &ctx, Preprocessor &PP) - : Diags(diag), CapturedDiags(capturedDiags) { - Impl = new TransformActionsImpl(capturedDiags, ctx, PP); -} - -TransformActions::~TransformActions() { - delete static_cast<TransformActionsImpl*>(Impl); -} - -void TransformActions::startTransaction() { - static_cast<TransformActionsImpl*>(Impl)->startTransaction(); -} - -bool TransformActions::commitTransaction() { - return static_cast<TransformActionsImpl*>(Impl)->commitTransaction(); -} - -void TransformActions::abortTransaction() { - static_cast<TransformActionsImpl*>(Impl)->abortTransaction(); -} - - -void TransformActions::insert(SourceLocation loc, StringRef text) { - static_cast<TransformActionsImpl*>(Impl)->insert(loc, text); -} - -void TransformActions::insertAfterToken(SourceLocation loc, - StringRef text) { - static_cast<TransformActionsImpl*>(Impl)->insertAfterToken(loc, text); -} - -void TransformActions::remove(SourceRange range) { - static_cast<TransformActionsImpl*>(Impl)->remove(range); -} - -void TransformActions::removeStmt(Stmt *S) { - static_cast<TransformActionsImpl*>(Impl)->removeStmt(S); -} - -void TransformActions::replace(SourceRange range, StringRef text) { - static_cast<TransformActionsImpl*>(Impl)->replace(range, text); -} - -void TransformActions::replace(SourceRange range, - SourceRange replacementRange) { - static_cast<TransformActionsImpl*>(Impl)->replace(range, replacementRange); -} - -void TransformActions::replaceStmt(Stmt *S, StringRef text) { - static_cast<TransformActionsImpl*>(Impl)->replaceStmt(S, text); -} - -void TransformActions::replaceText(SourceLocation loc, StringRef text, - StringRef replacementText) { - static_cast<TransformActionsImpl*>(Impl)->replaceText(loc, text, - replacementText); -} - -void TransformActions::increaseIndentation(SourceRange range, - SourceLocation parentIndent) { - static_cast<TransformActionsImpl*>(Impl)->increaseIndentation(range, - parentIndent); -} - -bool TransformActions::clearDiagnostic(ArrayRef<unsigned> IDs, - SourceRange range) { - return static_cast<TransformActionsImpl*>(Impl)->clearDiagnostic(IDs, range); -} - -void TransformActions::applyRewrites(RewriteReceiver &receiver) { - static_cast<TransformActionsImpl*>(Impl)->applyRewrites(receiver); -} - -DiagnosticBuilder TransformActions::report(SourceLocation loc, unsigned diagId, - SourceRange range) { - assert(!static_cast<TransformActionsImpl *>(Impl)->isInTransaction() && - "Errors should be emitted out of a transaction"); - return Diags.Report(loc, diagId) << range; -} - -void TransformActions::reportError(StringRef message, SourceLocation loc, - SourceRange range) { - report(loc, diag::err_mt_message, range) << message; -} - -void TransformActions::reportWarning(StringRef message, SourceLocation loc, - SourceRange range) { - report(loc, diag::warn_mt_message, range) << message; -} - -void TransformActions::reportNote(StringRef message, SourceLocation loc, - SourceRange range) { - report(loc, diag::note_mt_message, range) << message; -} diff --git clang/lib/ARCMigrate/Transforms.cpp clang/lib/ARCMigrate/Transforms.cpp deleted file mode 100644 index fda0e1c932fc..000000000000 --- clang/lib/ARCMigrate/Transforms.cpp +++ /dev/null @@ -1,594 +0,0 @@ -//===--- Transforms.cpp - Transformations to ARC mode ---------------------===// -// -// 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 "Transforms.h" -#include "Internals.h" -#include "clang/ARCMigrate/ARCMT.h" -#include "clang/AST/ASTContext.h" -#include "clang/AST/RecursiveASTVisitor.h" -#include "clang/Analysis/DomainSpecific/CocoaConventions.h" -#include "clang/Basic/SourceManager.h" -#include "clang/Basic/TargetInfo.h" -#include "clang/Lex/Lexer.h" -#include "clang/Lex/Preprocessor.h" -#include "clang/Sema/Sema.h" -#include "clang/Sema/SemaObjC.h" - -using namespace clang; -using namespace arcmt; -using namespace trans; - -ASTTraverser::~ASTTraverser() { } - -bool MigrationPass::CFBridgingFunctionsDefined() { - if (!EnableCFBridgeFns) - EnableCFBridgeFns = SemaRef.ObjC().isKnownName("CFBridgingRetain") && - SemaRef.ObjC().isKnownName("CFBridgingRelease"); - return *EnableCFBridgeFns; -} - -//===----------------------------------------------------------------------===// -// Helpers. -//===----------------------------------------------------------------------===// - -bool trans::canApplyWeak(ASTContext &Ctx, QualType type, - bool AllowOnUnknownClass) { - if (!Ctx.getLangOpts().ObjCWeakRuntime) - return false; - - QualType T = type; - if (T.isNull()) - return false; - - // iOS is always safe to use 'weak'. - if (Ctx.getTargetInfo().getTriple().isiOS() || - Ctx.getTargetInfo().getTriple().isWatchOS()) - AllowOnUnknownClass = true; - - while (const PointerType *ptr = T->getAs<PointerType>()) - T = ptr->getPointeeType(); - if (const ObjCObjectPointerType *ObjT = T->getAs<ObjCObjectPointerType>()) { - ObjCInterfaceDecl *Class = ObjT->getInterfaceDecl(); - if (!AllowOnUnknownClass && (!Class || Class->getName() == "NSObject")) - return false; // id/NSObject is not safe for weak. - if (!AllowOnUnknownClass && !Class->hasDefinition()) - return false; // forward classes are not verifiable, therefore not safe. - if (Class && Class->isArcWeakrefUnavailable()) - return false; - } - - return true; -} - -bool trans::isPlusOneAssign(const BinaryOperator *E) { - if (E->getOpcode() != BO_Assign) - return false; - - return isPlusOne(E->getRHS()); -} - -bool trans::isPlusOne(const Expr *E) { - if (!E) - return false; - if (const FullExpr *FE = dyn_cast<FullExpr>(E)) - E = FE->getSubExpr(); - - if (const ObjCMessageExpr * - ME = dyn_cast<ObjCMessageExpr>(E->IgnoreParenCasts())) - if (ME->getMethodFamily() == OMF_retain) - return true; - - if (const CallExpr * - callE = dyn_cast<CallExpr>(E->IgnoreParenCasts())) { - if (const FunctionDecl *FD = callE->getDirectCallee()) { - if (FD->hasAttr<CFReturnsRetainedAttr>()) - return true; - - if (FD->isGlobal() && - FD->getIdentifier() && - FD->getParent()->isTranslationUnit() && - FD->isExternallyVisible() && - ento::cocoa::isRefType(callE->getType(), "CF", - FD->getIdentifier()->getName())) { - StringRef fname = FD->getIdentifier()->getName(); - if (fname.ends_with("Retain") || fname.contains("Create") || - fname.contains("Copy")) - return true; - } - } - } - - const ImplicitCastExpr *implCE = dyn_cast<ImplicitCastExpr>(E); - while (implCE && implCE->getCastKind() == CK_BitCast) - implCE = dyn_cast<ImplicitCastExpr>(implCE->getSubExpr()); - - return implCE && implCE->getCastKind() == CK_ARCConsumeObject; -} - -/// 'Loc' is the end of a statement range. This returns the location -/// immediately after the semicolon following the statement. -/// If no semicolon is found or the location is inside a macro, the returned -/// source location will be invalid. -SourceLocation trans::findLocationAfterSemi(SourceLocation loc, - ASTContext &Ctx, bool IsDecl) { - SourceLocation SemiLoc = findSemiAfterLocation(loc, Ctx, IsDecl); - if (SemiLoc.isInvalid()) - return SourceLocation(); - return SemiLoc.getLocWithOffset(1); -} - -/// \arg Loc is the end of a statement range. This returns the location -/// of the semicolon following the statement. -/// If no semicolon is found or the location is inside a macro, the returned -/// source location will be invalid. -SourceLocation trans::findSemiAfterLocation(SourceLocation loc, - ASTContext &Ctx, - bool IsDecl) { - SourceManager &SM = Ctx.getSourceManager(); - if (loc.isMacroID()) { - if (!Lexer::isAtEndOfMacroExpansion(loc, SM, Ctx.getLangOpts(), &loc)) - return SourceLocation(); - } - loc = Lexer::getLocForEndOfToken(loc, /*Offset=*/0, SM, Ctx.getLangOpts()); - - // Break down the source location. - std::pair<FileID, unsigned> locInfo = SM.getDecomposedLoc(loc); - - // Try to load the file buffer. - bool invalidTemp = false; - StringRef file = SM.getBufferData(locInfo.first, &invalidTemp); - if (invalidTemp) - return SourceLocation(); - - const char *tokenBegin = file.data() + locInfo.second; - - // Lex from the start of the given location. - Lexer lexer(SM.getLocForStartOfFile(locInfo.first), - Ctx.getLangOpts(), - file.begin(), tokenBegin, file.end()); - Token tok; - lexer.LexFromRawLexer(tok); - if (tok.isNot(tok::semi)) { - if (!IsDecl) - return SourceLocation(); - // Declaration may be followed with other tokens; such as an __attribute, - // before ending with a semicolon. - return findSemiAfterLocation(tok.getLocation(), Ctx, /*IsDecl*/true); - } - - return tok.getLocation(); -} - -bool trans::hasSideEffects(Expr *E, ASTContext &Ctx) { - if (!E || !E->HasSideEffects(Ctx)) - return false; - - E = E->IgnoreParenCasts(); - ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(E); - if (!ME) - return true; - switch (ME->getMethodFamily()) { - case OMF_autorelease: - case OMF_dealloc: - case OMF_release: - case OMF_retain: - switch (ME->getReceiverKind()) { - case ObjCMessageExpr::SuperInstance: - return false; - case ObjCMessageExpr::Instance: - return hasSideEffects(ME->getInstanceReceiver(), Ctx); - default: - break; - } - break; - default: - break; - } - - return true; -} - -bool trans::isGlobalVar(Expr *E) { - E = E->IgnoreParenCasts(); - if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) - return DRE->getDecl()->getDeclContext()->isFileContext() && - DRE->getDecl()->isExternallyVisible(); - if (ConditionalOperator *condOp = dyn_cast<ConditionalOperator>(E)) - return isGlobalVar(condOp->getTrueExpr()) && - isGlobalVar(condOp->getFalseExpr()); - - return false; -} - -StringRef trans::getNilString(MigrationPass &Pass) { - return Pass.SemaRef.PP.isMacroDefined("nil") ? "nil" : "0"; -} - -namespace { - -class ReferenceClear : public RecursiveASTVisitor<ReferenceClear> { - ExprSet &Refs; -public: - ReferenceClear(ExprSet &refs) : Refs(refs) { } - bool VisitDeclRefExpr(DeclRefExpr *E) { Refs.erase(E); return true; } -}; - -class ReferenceCollector : public RecursiveASTVisitor<ReferenceCollector> { - ValueDecl *Dcl; - ExprSet &Refs; - -public: - ReferenceCollector(ValueDecl *D, ExprSet &refs) - : Dcl(D), Refs(refs) { } - - bool VisitDeclRefExpr(DeclRefExpr *E) { - if (E->getDecl() == Dcl) - Refs.insert(E); - return true; - } -}; - -class RemovablesCollector : public RecursiveASTVisitor<RemovablesCollector> { - ExprSet &Removables; - -public: - RemovablesCollector(ExprSet &removables) - : Removables(removables) { } - - bool shouldWalkTypesOfTypeLocs() const { return false; } - - bool TraverseStmtExpr(StmtExpr *E) { - CompoundStmt *S = E->getSubStmt(); - for (CompoundStmt::body_iterator - I = S->body_begin(), E = S->body_end(); I != E; ++I) { - if (I != E - 1) - mark(*I); - TraverseStmt(*I); - } - return true; - } - - bool VisitCompoundStmt(CompoundStmt *S) { - for (auto *I : S->body()) - mark(I); - return true; - } - - bool VisitIfStmt(IfStmt *S) { - mark(S->getThen()); - mark(S->getElse()); - return true; - } - - bool VisitWhileStmt(WhileStmt *S) { - mark(S->getBody()); - return true; - } - - bool VisitDoStmt(DoStmt *S) { - mark(S->getBody()); - return true; - } - - bool VisitForStmt(ForStmt *S) { - mark(S->getInit()); - mark(S->getInc()); - mark(S->getBody()); - return true; - } - -private: - void mark(Stmt *S) { - if (!S) return; - - while (auto *Label = dyn_cast<LabelStmt>(S)) - S = Label->getSubStmt(); - if (auto *E = dyn_cast<Expr>(S)) - S = E->IgnoreImplicit(); - if (auto *E = dyn_cast<Expr>(S)) - Removables.insert(E); - } -}; - -} // end anonymous namespace - -void trans::clearRefsIn(Stmt *S, ExprSet &refs) { - ReferenceClear(refs).TraverseStmt(S); -} - -void trans::collectRefs(ValueDecl *D, Stmt *S, ExprSet &refs) { - ReferenceCollector(D, refs).TraverseStmt(S); -} - -void trans::collectRemovables(Stmt *S, ExprSet &exprs) { - RemovablesCollector(exprs).TraverseStmt(S); -} - -//===----------------------------------------------------------------------===// -// MigrationContext -//===----------------------------------------------------------------------===// - -namespace { - -class ASTTransform : public RecursiveASTVisitor<ASTTransform> { - MigrationContext &MigrateCtx; - typedef RecursiveASTVisitor<ASTTransform> base; - -public: - ASTTransform(MigrationContext &MigrateCtx) : MigrateCtx(MigrateCtx) { } - - bool shouldWalkTypesOfTypeLocs() const { return false; } - - bool TraverseObjCImplementationDecl(ObjCImplementationDecl *D) { - ObjCImplementationContext ImplCtx(MigrateCtx, D); - for (MigrationContext::traverser_iterator - I = MigrateCtx.traversers_begin(), - E = MigrateCtx.traversers_end(); I != E; ++I) - (*I)->traverseObjCImplementation(ImplCtx); - - return base::TraverseObjCImplementationDecl(D); - } - - bool TraverseStmt(Stmt *rootS) { - if (!rootS) - return true; - - BodyContext BodyCtx(MigrateCtx, rootS); - for (MigrationContext::traverser_iterator - I = MigrateCtx.traversers_begin(), - E = MigrateCtx.traversers_end(); I != E; ++I) - (*I)->traverseBody(BodyCtx); - - return true; - } -}; - -} - -MigrationContext::~MigrationContext() { - for (traverser_iterator - I = traversers_begin(), E = traversers_end(); I != E; ++I) - delete *I; -} - -bool MigrationContext::isGCOwnedNonObjC(QualType T) { - while (!T.isNull()) { - if (const AttributedType *AttrT = T->getAs<AttributedType>()) { - if (AttrT->getAttrKind() == attr::ObjCOwnership) - return !AttrT->getModifiedType()->isObjCRetainableType(); - } - - if (T->isArrayType()) - T = Pass.Ctx.getBaseElementType(T); - else if (const PointerType *PT = T->getAs<PointerType>()) - T = PT->getPointeeType(); - else if (const ReferenceType *RT = T->getAs<ReferenceType>()) - T = RT->getPointeeType(); - else - break; - } - - return false; -} - -bool MigrationContext::rewritePropertyAttribute(StringRef fromAttr, - StringRef toAttr, - SourceLocation atLoc) { - if (atLoc.isMacroID()) - return false; - - SourceManager &SM = Pass.Ctx.getSourceManager(); - - // Break down the source location. - std::pair<FileID, unsigned> locInfo = SM.getDecomposedLoc(atLoc); - - // Try to load the file buffer. - bool invalidTemp = false; - StringRef file = SM.getBufferData(locInfo.first, &invalidTemp); - if (invalidTemp) - return false; - - const char *tokenBegin = file.data() + locInfo.second; - - // Lex from the start of the given location. - Lexer lexer(SM.getLocForStartOfFile(locInfo.first), - Pass.Ctx.getLangOpts(), - file.begin(), tokenBegin, file.end()); - Token tok; - lexer.LexFromRawLexer(tok); - if (tok.isNot(tok::at)) return false; - lexer.LexFromRawLexer(tok); - if (tok.isNot(tok::raw_identifier)) return false; - if (tok.getRawIdentifier() != "property") - return false; - lexer.LexFromRawLexer(tok); - if (tok.isNot(tok::l_paren)) return false; - - Token BeforeTok = tok; - Token AfterTok; - AfterTok.startToken(); - SourceLocation AttrLoc; - - lexer.LexFromRawLexer(tok); - if (tok.is(tok::r_paren)) - return false; - - while (true) { - if (tok.isNot(tok::raw_identifier)) return false; - if (tok.getRawIdentifier() == fromAttr) { - if (!toAttr.empty()) { - Pass.TA.replaceText(tok.getLocation(), fromAttr, toAttr); - return true; - } - // We want to remove the attribute. - AttrLoc = tok.getLocation(); - } - - do { - lexer.LexFromRawLexer(tok); - if (AttrLoc.isValid() && AfterTok.is(tok::unknown)) - AfterTok = tok; - } while (tok.isNot(tok::comma) && tok.isNot(tok::r_paren)); - if (tok.is(tok::r_paren)) - break; - if (AttrLoc.isInvalid()) - BeforeTok = tok; - lexer.LexFromRawLexer(tok); - } - - if (toAttr.empty() && AttrLoc.isValid() && AfterTok.isNot(tok::unknown)) { - // We want to remove the attribute. - if (BeforeTok.is(tok::l_paren) && AfterTok.is(tok::r_paren)) { - Pass.TA.remove(SourceRange(BeforeTok.getLocation(), - AfterTok.getLocation())); - } else if (BeforeTok.is(tok::l_paren) && AfterTok.is(tok::comma)) { - Pass.TA.remove(SourceRange(AttrLoc, AfterTok.getLocation())); - } else { - Pass.TA.remove(SourceRange(BeforeTok.getLocation(), AttrLoc)); - } - - return true; - } - - return false; -} - -bool MigrationContext::addPropertyAttribute(StringRef attr, - SourceLocation atLoc) { - if (atLoc.isMacroID()) - return false; - - SourceManager &SM = Pass.Ctx.getSourceManager(); - - // Break down the source location. - std::pair<FileID, unsigned> locInfo = SM.getDecomposedLoc(atLoc); - - // Try to load the file buffer. - bool invalidTemp = false; - StringRef file = SM.getBufferData(locInfo.first, &invalidTemp); - if (invalidTemp) - return false; - - const char *tokenBegin = file.data() + locInfo.second; - - // Lex from the start of the given location. - Lexer lexer(SM.getLocForStartOfFile(locInfo.first), - Pass.Ctx.getLangOpts(), - file.begin(), tokenBegin, file.end()); - Token tok; - lexer.LexFromRawLexer(tok); - if (tok.isNot(tok::at)) return false; - lexer.LexFromRawLexer(tok); - if (tok.isNot(tok::raw_identifier)) return false; - if (tok.getRawIdentifier() != "property") - return false; - lexer.LexFromRawLexer(tok); - - if (tok.isNot(tok::l_paren)) { - Pass.TA.insert(tok.getLocation(), std::string("(") + attr.str() + ") "); - return true; - } - - lexer.LexFromRawLexer(tok); - if (tok.is(tok::r_paren)) { - Pass.TA.insert(tok.getLocation(), attr); - return true; - } - - if (tok.isNot(tok::raw_identifier)) return false; - - Pass.TA.insert(tok.getLocation(), std::string(attr) + ", "); - return true; -} - -void MigrationContext::traverse(TranslationUnitDecl *TU) { - for (traverser_iterator - I = traversers_begin(), E = traversers_end(); I != E; ++I) - (*I)->traverseTU(*this); - - ASTTransform(*this).TraverseDecl(TU); -} - -static void GCRewriteFinalize(MigrationPass &pass) { - ASTContext &Ctx = pass.Ctx; - TransformActions &TA = pass.TA; - DeclContext *DC = Ctx.getTranslationUnitDecl(); - Selector FinalizeSel = - Ctx.Selectors.getNullarySelector(&pass.Ctx.Idents.get("finalize")); - - typedef DeclContext::specific_decl_iterator<ObjCImplementationDecl> - impl_iterator; - for (impl_iterator I = impl_iterator(DC->decls_begin()), - E = impl_iterator(DC->decls_end()); I != E; ++I) { - for (const auto *MD : I->instance_methods()) { - if (!MD->hasBody()) - continue; - - if (MD->isInstanceMethod() && MD->getSelector() == FinalizeSel) { - const ObjCMethodDecl *FinalizeM = MD; - Transaction Trans(TA); - TA.insert(FinalizeM->getSourceRange().getBegin(), - "#if !__has_feature(objc_arc)\n"); - CharSourceRange::getTokenRange(FinalizeM->getSourceRange()); - const SourceManager &SM = pass.Ctx.getSourceManager(); - const LangOptions &LangOpts = pass.Ctx.getLangOpts(); - bool Invalid; - std::string str = "\n#endif\n"; - str += Lexer::getSourceText( - CharSourceRange::getTokenRange(FinalizeM->getSourceRange()), - SM, LangOpts, &Invalid); - TA.insertAfterToken(FinalizeM->getSourceRange().getEnd(), str); - - break; - } - } - } -} - -//===----------------------------------------------------------------------===// -// getAllTransformations. -//===----------------------------------------------------------------------===// - -static void traverseAST(MigrationPass &pass) { - MigrationContext MigrateCtx(pass); - - if (pass.isGCMigration()) { - MigrateCtx.addTraverser(new GCCollectableCallsTraverser); - MigrateCtx.addTraverser(new GCAttrsTraverser()); - } - MigrateCtx.addTraverser(new PropertyRewriteTraverser()); - MigrateCtx.addTraverser(new BlockObjCVariableTraverser()); - MigrateCtx.addTraverser(new ProtectedScopeTraverser()); - - MigrateCtx.traverse(pass.Ctx.getTranslationUnitDecl()); -} - -static void independentTransforms(MigrationPass &pass) { - rewriteAutoreleasePool(pass); - removeRetainReleaseDeallocFinalize(pass); - rewriteUnusedInitDelegate(pass); - removeZeroOutPropsInDeallocFinalize(pass); - makeAssignARCSafe(pass); - rewriteUnbridgedCasts(pass); - checkAPIUses(pass); - traverseAST(pass); -} - -std::vector<TransformFn> arcmt::getAllTransformations( - LangOptions::GCMode OrigGCMode, - bool NoFinalizeRemoval) { - std::vector<TransformFn> transforms; - - if (OrigGCMode == LangOptions::GCOnly && NoFinalizeRemoval) - transforms.push_back(GCRewriteFinalize); - transforms.push_back(independentTransforms); - // This depends on previous transformations removing various expressions. - transforms.push_back(removeEmptyStatementsAndDeallocFinalize); - - return transforms; -} diff --git clang/lib/ARCMigrate/Transforms.h clang/lib/ARCMigrate/Transforms.h deleted file mode 100644 index 37e2d6b2a7e1..000000000000 --- clang/lib/ARCMigrate/Transforms.h +++ /dev/null @@ -1,224 +0,0 @@ -//===-- Transforms.h - Transformations to ARC mode --------------*- 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 LLVM_CLANG_LIB_ARCMIGRATE_TRANSFORMS_H -#define LLVM_CLANG_LIB_ARCMIGRATE_TRANSFORMS_H - -#include "clang/AST/ParentMap.h" -#include "clang/AST/RecursiveASTVisitor.h" -#include "llvm/ADT/DenseSet.h" -#include "llvm/Support/SaveAndRestore.h" - -namespace clang { - class Decl; - class Stmt; - class BlockDecl; - class ObjCMethodDecl; - class FunctionDecl; - -namespace arcmt { - class MigrationPass; - -namespace trans { - - class MigrationContext; - -//===----------------------------------------------------------------------===// -// Transformations. -//===----------------------------------------------------------------------===// - -void rewriteAutoreleasePool(MigrationPass &pass); -void rewriteUnbridgedCasts(MigrationPass &pass); -void makeAssignARCSafe(MigrationPass &pass); -void removeRetainReleaseDeallocFinalize(MigrationPass &pass); -void removeZeroOutPropsInDeallocFinalize(MigrationPass &pass); -void rewriteUnusedInitDelegate(MigrationPass &pass); -void checkAPIUses(MigrationPass &pass); - -void removeEmptyStatementsAndDeallocFinalize(MigrationPass &pass); - -class BodyContext { - MigrationContext &MigrateCtx; - ParentMap PMap; - Stmt *TopStmt; - -public: - BodyContext(MigrationContext &MigrateCtx, Stmt *S) - : MigrateCtx(MigrateCtx), PMap(S), TopStmt(S) {} - - MigrationContext &getMigrationContext() { return MigrateCtx; } - ParentMap &getParentMap() { return PMap; } - Stmt *getTopStmt() { return TopStmt; } -}; - -class ObjCImplementationContext { - MigrationContext &MigrateCtx; - ObjCImplementationDecl *ImpD; - -public: - ObjCImplementationContext(MigrationContext &MigrateCtx, - ObjCImplementationDecl *D) - : MigrateCtx(MigrateCtx), ImpD(D) {} - - MigrationContext &getMigrationContext() { return MigrateCtx; } - ObjCImplementationDecl *getImplementationDecl() { return ImpD; } -}; - -class ASTTraverser { -public: - virtual ~ASTTraverser(); - virtual void traverseTU(MigrationContext &MigrateCtx) { } - virtual void traverseBody(BodyContext &BodyCtx) { } - virtual void traverseObjCImplementation(ObjCImplementationContext &ImplCtx) {} -}; - -class MigrationContext { - std::vector<ASTTraverser *> Traversers; - -public: - MigrationPass &Pass; - - struct GCAttrOccurrence { - enum AttrKind { Weak, Strong } Kind; - SourceLocation Loc; - QualType ModifiedType; - Decl *Dcl; - /// true if the attribute is owned, e.g. it is in a body and not just - /// in an interface. - bool FullyMigratable; - }; - std::vector<GCAttrOccurrence> GCAttrs; - llvm::DenseSet<SourceLocation> AttrSet; - llvm::DenseSet<SourceLocation> RemovedAttrSet; - - /// Set of raw '@' locations for 'assign' properties group that contain - /// GC __weak. - llvm::DenseSet<SourceLocation> AtPropsWeak; - - explicit MigrationContext(MigrationPass &pass) : Pass(pass) {} - ~MigrationContext(); - - typedef std::vector<ASTTraverser *>::iterator traverser_iterator; - traverser_iterator traversers_begin() { return Traversers.begin(); } - traverser_iterator traversers_end() { return Traversers.end(); } - - void addTraverser(ASTTraverser *traverser) { - Traversers.push_back(traverser); - } - - bool isGCOwnedNonObjC(QualType T); - bool removePropertyAttribute(StringRef fromAttr, SourceLocation atLoc) { - return rewritePropertyAttribute(fromAttr, StringRef(), atLoc); - } - bool rewritePropertyAttribute(StringRef fromAttr, StringRef toAttr, - SourceLocation atLoc); - bool addPropertyAttribute(StringRef attr, SourceLocation atLoc); - - void traverse(TranslationUnitDecl *TU); - - void dumpGCAttrs(); -}; - -class PropertyRewriteTraverser : public ASTTraverser { -public: - void traverseObjCImplementation(ObjCImplementationContext &ImplCtx) override; -}; - -class BlockObjCVariableTraverser : public ASTTraverser { -public: - void traverseBody(BodyContext &BodyCtx) override; -}; - -class ProtectedScopeTraverser : public ASTTraverser { -public: - void traverseBody(BodyContext &BodyCtx) override; -}; - -// GC transformations - -class GCAttrsTraverser : public ASTTraverser { -public: - void traverseTU(MigrationContext &MigrateCtx) override; -}; - -class GCCollectableCallsTraverser : public ASTTraverser { -public: - void traverseBody(BodyContext &BodyCtx) override; -}; - -//===----------------------------------------------------------------------===// -// Helpers. -//===----------------------------------------------------------------------===// - -/// Determine whether we can add weak to the given type. -bool canApplyWeak(ASTContext &Ctx, QualType type, - bool AllowOnUnknownClass = false); - -bool isPlusOneAssign(const BinaryOperator *E); -bool isPlusOne(const Expr *E); - -/// 'Loc' is the end of a statement range. This returns the location -/// immediately after the semicolon following the statement. -/// If no semicolon is found or the location is inside a macro, the returned -/// source location will be invalid. -SourceLocation findLocationAfterSemi(SourceLocation loc, ASTContext &Ctx, - bool IsDecl = false); - -/// 'Loc' is the end of a statement range. This returns the location -/// of the semicolon following the statement. -/// If no semicolon is found or the location is inside a macro, the returned -/// source location will be invalid. -SourceLocation findSemiAfterLocation(SourceLocation loc, ASTContext &Ctx, - bool IsDecl = false); - -bool hasSideEffects(Expr *E, ASTContext &Ctx); -bool isGlobalVar(Expr *E); -/// Returns "nil" or "0" if 'nil' macro is not actually defined. -StringRef getNilString(MigrationPass &Pass); - -template <typename BODY_TRANS> -class BodyTransform : public RecursiveASTVisitor<BodyTransform<BODY_TRANS> > { - MigrationPass &Pass; - Decl *ParentD; - - typedef RecursiveASTVisitor<BodyTransform<BODY_TRANS> > base; -public: - BodyTransform(MigrationPass &pass) : Pass(pass), ParentD(nullptr) { } - - bool TraverseStmt(Stmt *rootS) { - if (rootS) - BODY_TRANS(Pass).transformBody(rootS, ParentD); - return true; - } - - bool TraverseObjCMethodDecl(ObjCMethodDecl *D) { - SaveAndRestore<Decl *> SetParent(ParentD, D); - return base::TraverseObjCMethodDecl(D); - } -}; - -typedef llvm::DenseSet<Expr *> ExprSet; - -void clearRefsIn(Stmt *S, ExprSet &refs); -template <typename iterator> -void clearRefsIn(iterator begin, iterator end, ExprSet &refs) { - for (; begin != end; ++begin) - clearRefsIn(*begin, refs); -} - -void collectRefs(ValueDecl *D, Stmt *S, ExprSet &refs); - -void collectRemovables(Stmt *S, ExprSet &exprs); - -} // end namespace trans - -} // end namespace arcmt - -} // end namespace clang - -#endif diff --git clang/lib/AST/ASTContext.cpp clang/lib/AST/ASTContext.cpp index a4ba9fd05534..4e387da6dccd 100644 --- clang/lib/AST/ASTContext.cpp +++ clang/lib/AST/ASTContext.cpp @@ -2269,11 +2269,10 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { Width = 0; \ Align = 16; \ break; -#define AARCH64_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \ - ElBits, NF) \ +#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \ case BuiltinType::Id: \ - Width = NumEls * ElBits * NF; \ - Align = NumEls * ElBits; \ + Width = Bits; \ + Align = Bits; \ break; #include "clang/Basic/AArch64SVEACLETypes.def" #define PPC_VECTOR_TYPE(Name, Id, Size) \ @@ -4423,15 +4422,14 @@ ASTContext::getBuiltinVectorTypeInfo(const BuiltinType *Ty) const { ElBits, NF) \ case BuiltinType::Id: \ return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF}; +#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \ + ElBits, NF) \ + case BuiltinType::Id: \ + return {MFloat8Ty, llvm::ElementCount::getScalable(NumEls), NF}; #define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \ case BuiltinType::Id: \ return {BoolTy, llvm::ElementCount::getScalable(NumEls), NF}; -#define AARCH64_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \ - ElBits, NF) \ - case BuiltinType::Id: \ - return {getIntTypeForBitwidth(ElBits, false), \ - llvm::ElementCount::getFixed(NumEls), NF}; -#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) +#define SVE_TYPE(Name, Id, SingletonId) #include "clang/Basic/AArch64SVEACLETypes.def" #define RVV_VECTOR_TYPE_INT(Name, Id, SingletonId, NumEls, ElBits, NF, \ @@ -4493,11 +4491,16 @@ QualType ASTContext::getScalableVectorType(QualType EltTy, unsigned NumElts, EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \ return SingletonId; \ } +#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \ + ElBits, NF) \ + if (EltTy->isMFloat8Type() && EltTySize == ElBits && \ + NumElts == (NumEls * NF) && NumFields == 1) { \ + return SingletonId; \ + } #define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \ if (EltTy->isBooleanType() && NumElts == (NumEls * NF) && NumFields == 1) \ return SingletonId; -#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) -#define AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) +#define SVE_TYPE(Name, Id, SingletonId) #include "clang/Basic/AArch64SVEACLETypes.def" } else if (Target->hasRISCVVTypes()) { uint64_t EltTySize = getTypeSize(EltTy); @@ -12382,6 +12385,9 @@ static QualType DecodeTypeFromStr(const char *&Str, const ASTContext &Context, case 'p': Type = Context.getProcessIDType(); break; + case 'm': + Type = Context.MFloat8Ty; + break; } // If there are modifiers and if we're allowed to parse them, go for it. @@ -12835,11 +12841,12 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) { // Likewise, variables with tuple-like bindings are required if their // bindings have side-effects. - if (const auto *DD = dyn_cast<DecompositionDecl>(VD)) - for (const auto *BD : DD->bindings()) + if (const auto *DD = dyn_cast<DecompositionDecl>(VD)) { + for (const auto *BD : DD->flat_bindings()) if (const auto *BindingVD = BD->getHoldingVar()) if (DeclMustBeEmitted(BindingVD)) return true; + } return false; } diff --git clang/lib/AST/ASTImporter.cpp clang/lib/AST/ASTImporter.cpp index 0669aa1b809c..c9f2f905d213 100644 --- clang/lib/AST/ASTImporter.cpp +++ clang/lib/AST/ASTImporter.cpp @@ -15,6 +15,7 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/ASTDiagnostic.h" #include "clang/AST/ASTImporterSharedState.h" +#include "clang/AST/ASTLambda.h" #include "clang/AST/ASTStructuralEquivalence.h" #include "clang/AST/Attr.h" #include "clang/AST/Decl.h" @@ -2552,7 +2553,7 @@ ExpectedDecl ASTNodeImporter::VisitBindingDecl(BindingDecl *D) { BindingDecl *ToD; if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), DC, Loc, - Name.getAsIdentifierInfo())) + Name.getAsIdentifierInfo(), D->getType())) return ToD; Error Err = Error::success(); @@ -3729,10 +3730,7 @@ bool ASTNodeImporter::hasReturnTypeDeclaredInside(FunctionDecl *D) { if (Importer.FromContext.getLangOpts().CPlusPlus14) // C++14 or later return false; - if (const auto *MD = dyn_cast<CXXMethodDecl>(D)) - return cast<CXXRecordDecl>(MD->getDeclContext())->isLambda(); - - return false; + return isLambdaMethod(D); }; QualType RetT = FromFPT->getReturnType(); @@ -3999,14 +3997,16 @@ ExpectedDecl ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) { importExplicitSpecifier(Err, Guide->getExplicitSpecifier()); CXXConstructorDecl *Ctor = importChecked(Err, Guide->getCorrespondingConstructor()); + const CXXDeductionGuideDecl *SourceDG = + importChecked(Err, Guide->getSourceDeductionGuide()); if (Err) return std::move(Err); if (GetImportedOrCreateDecl<CXXDeductionGuideDecl>( ToFunction, D, Importer.getToContext(), DC, ToInnerLocStart, ESpec, - NameInfo, T, TInfo, ToEndLoc, Ctor)) + NameInfo, T, TInfo, ToEndLoc, Ctor, + Guide->getDeductionCandidateKind(), TrailingRequiresClause, + SourceDG, Guide->getSourceDeductionGuideKind())) return ToFunction; - cast<CXXDeductionGuideDecl>(ToFunction) - ->setDeductionCandidateKind(Guide->getDeductionCandidateKind()); } else { if (GetImportedOrCreateDecl( ToFunction, D, Importer.getToContext(), DC, ToInnerLocStart, @@ -4701,9 +4701,13 @@ ExpectedDecl ASTNodeImporter::VisitImplicitParamDecl(ImplicitParamDecl *D) { Error ASTNodeImporter::ImportDefaultArgOfParmVarDecl( const ParmVarDecl *FromParam, ParmVarDecl *ToParam) { + + if (auto LocOrErr = import(FromParam->getExplicitObjectParamThisLoc())) + ToParam->setExplicitObjectParameterLoc(*LocOrErr); + else + return LocOrErr.takeError(); + ToParam->setHasInheritedDefaultArg(FromParam->hasInheritedDefaultArg()); - ToParam->setExplicitObjectParameterLoc( - FromParam->getExplicitObjectParamThisLoc()); ToParam->setKNRPromoted(FromParam->isKNRPromoted()); if (FromParam->hasUninstantiatedDefaultArg()) { @@ -6755,6 +6759,14 @@ ASTNodeImporter::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { Params, TemplatedFD)) return ToFunc; + // Fail if TemplatedFD is already part of a template. + // The template should have been found by structural equivalence check before, + // or ToFunc should be already imported. + // If not, there is AST incompatibility that can be caused by previous import + // errors. (NameConflict is not exact here.) + if (TemplatedFD->getDescribedTemplate()) + return make_error<ASTImportError>(ASTImportError::NameConflict); + TemplatedFD->setDescribedFunctionTemplate(ToFunc); ToFunc->setAccess(D->getAccess()); diff --git clang/lib/AST/ByteCode/Compiler.cpp clang/lib/AST/ByteCode/Compiler.cpp index 66ab27bdd13d..4659d0e00784 100644 --- clang/lib/AST/ByteCode/Compiler.cpp +++ clang/lib/AST/ByteCode/Compiler.cpp @@ -6175,7 +6175,7 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) { } if (D->getType()->isReferenceType()) - return false; // FIXME: Do we need to emit InvalidDeclRef? + return this->emitDummyPtr(D, E); } // In case we need to re-visit a declaration. diff --git clang/lib/AST/ByteCode/Context.cpp clang/lib/AST/ByteCode/Context.cpp index b52892cf69bf..a322700fc0d2 100644 --- clang/lib/AST/ByteCode/Context.cpp +++ clang/lib/AST/ByteCode/Context.cpp @@ -27,10 +27,7 @@ Context::~Context() {} bool Context::isPotentialConstantExpr(State &Parent, const FunctionDecl *FD) { assert(Stk.empty()); - Function *Func = P->getFunction(FD); - if (!Func || !Func->hasBody()) - Func = Compiler<ByteCodeEmitter>(*this, *P).compileFunc(FD); - + const Function *Func = getOrCreateFunction(FD); if (!Func) return false; @@ -271,6 +268,7 @@ Context::getOverridingFunction(const CXXRecordDecl *DynamicDecl, const Function *Context::getOrCreateFunction(const FunctionDecl *FD) { assert(FD); + FD = FD->getMostRecentDecl(); const Function *Func = P->getFunction(FD); bool IsBeingCompiled = Func && Func->isDefined() && !Func->isFullyCompiled(); bool WasNotDefined = Func && !Func->isConstexpr() && !Func->isDefined(); diff --git clang/lib/AST/ByteCode/Descriptor.cpp clang/lib/AST/ByteCode/Descriptor.cpp index 1c16c2022dd0..319d1690c1cd 100644 --- clang/lib/AST/ByteCode/Descriptor.cpp +++ clang/lib/AST/ByteCode/Descriptor.cpp @@ -409,7 +409,8 @@ QualType Descriptor::getElemQualType() const { assert(isArray()); QualType T = getType(); if (T->isPointerOrReferenceType()) - return T->getPointeeType(); + T = T->getPointeeType(); + if (const auto *AT = T->getAsArrayTypeUnsafe()) { // For primitive arrays, we don't save a QualType at all, // just a PrimType. Try to figure out the QualType here. @@ -424,7 +425,8 @@ QualType Descriptor::getElemQualType() const { return CT->getElementType(); if (const auto *CT = T->getAs<VectorType>()) return CT->getElementType(); - llvm_unreachable("Array that's not an array/complex/vector type?"); + + return T; } SourceLocation Descriptor::getLocation() const { diff --git clang/lib/AST/ByteCode/Interp.cpp clang/lib/AST/ByteCode/Interp.cpp index 40fe7147a18a..f91820e16fac 100644 --- clang/lib/AST/ByteCode/Interp.cpp +++ clang/lib/AST/ByteCode/Interp.cpp @@ -68,6 +68,9 @@ static bool diagnoseUnknownDecl(InterpState &S, CodePtr OpPC, const SourceInfo &E = S.Current->getSource(OpPC); if (isa<ParmVarDecl>(D)) { + if (D->getType()->isReferenceType()) + return false; + if (S.getLangOpts().CPlusPlus11) { S.FFDiag(E, diag::note_constexpr_function_param_value_unknown) << D; S.Note(D->getLocation(), diag::note_declared_at) << D->getSourceRange(); @@ -1287,6 +1290,12 @@ bool Call(InterpState &S, CodePtr OpPC, const Function *Func, const Pointer &ThisPtr = S.Stk.peek<Pointer>(ThisOffset); + // C++23 [expr.const]p5.6 + // an invocation of a virtual function ([class.virtual]) for an object whose + // dynamic type is constexpr-unknown; + if (ThisPtr.isDummy() && Func->isVirtual()) + return false; + // If the current function is a lambda static invoker and // the function we're about to call is a lambda call operator, // skip the CheckInvoke, since the ThisPtr is a null pointer @@ -1661,17 +1670,6 @@ bool GetTypeidPtr(InterpState &S, CodePtr OpPC, const Type *TypeInfoType) { if (!P.isBlockPointer()) return false; - if (P.isDummy()) { - QualType StarThisType = - S.getASTContext().getLValueReferenceType(P.getType()); - S.FFDiag(S.Current->getSource(OpPC), - diag::note_constexpr_polymorphic_unknown_dynamic_type) - << AK_TypeId - << P.toAPValue(S.getASTContext()) - .getAsString(S.getASTContext(), StarThisType); - return false; - } - S.Stk.push<Pointer>(P.getType().getTypePtr(), TypeInfoType); return true; } diff --git clang/lib/AST/ByteCode/InterpBuiltin.cpp clang/lib/AST/ByteCode/InterpBuiltin.cpp index e657dbd2f9c7..0e586725b586 100644 --- clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -1538,9 +1538,12 @@ static bool interp__builtin_constant_p(InterpState &S, CodePtr OpPC, if (ArgType->isIntegralOrEnumerationType() || ArgType->isFloatingType() || ArgType->isAnyComplexType() || ArgType->isPointerType() || ArgType->isNullPtrType()) { + auto PrevDiags = S.getEvalStatus().Diag; + S.getEvalStatus().Diag = nullptr; InterpStack Stk; Compiler<EvalEmitter> C(S.Ctx, S.P, S, Stk); auto Res = C.interpretExpr(Arg, /*ConvertResultToRValue=*/Arg->isGLValue()); + S.getEvalStatus().Diag = PrevDiags; if (Res.isInvalid()) { C.cleanup(); Stk.clear(); diff --git clang/lib/AST/ByteCode/Pointer.cpp clang/lib/AST/ByteCode/Pointer.cpp index ec4756fe4f87..3033bd47adf7 100644 --- clang/lib/AST/ByteCode/Pointer.cpp +++ clang/lib/AST/ByteCode/Pointer.cpp @@ -209,6 +209,10 @@ APValue Pointer::toAPValue(const ASTContext &ASTCtx) const { return ASTCtx.toCharUnitsFromBits(Layout.getFieldOffset(FieldIndex)); }; + bool UsePath = true; + if (getType()->isLValueReferenceType()) + UsePath = false; + // Build the path into the object. Pointer Ptr = *this; while (Ptr.isField() || Ptr.isArrayElement()) { @@ -217,38 +221,42 @@ APValue Pointer::toAPValue(const ASTContext &ASTCtx) const { // An array root may still be an array element itself. if (Ptr.isArrayElement()) { Ptr = Ptr.expand(); + const Descriptor *Desc = Ptr.getFieldDesc(); unsigned Index = Ptr.getIndex(); - Path.push_back(APValue::LValuePathEntry::ArrayIndex(Index)); - QualType ElemType = Ptr.getFieldDesc()->getElemQualType(); + QualType ElemType = Desc->getElemQualType(); Offset += (Index * ASTCtx.getTypeSizeInChars(ElemType)); + if (Ptr.getArray().getType()->isArrayType()) + Path.push_back(APValue::LValuePathEntry::ArrayIndex(Index)); Ptr = Ptr.getArray(); } else { - Path.push_back(APValue::LValuePathEntry( - {Ptr.getFieldDesc()->asDecl(), /*IsVirtual=*/false})); + const Descriptor *Desc = Ptr.getFieldDesc(); + const auto *Dcl = Desc->asDecl(); + Path.push_back(APValue::LValuePathEntry({Dcl, /*IsVirtual=*/false})); - if (const auto *FD = - dyn_cast_if_present<FieldDecl>(Ptr.getFieldDesc()->asDecl())) + if (const auto *FD = dyn_cast_if_present<FieldDecl>(Dcl)) Offset += getFieldOffset(FD); Ptr = Ptr.getBase(); } } else if (Ptr.isArrayElement()) { Ptr = Ptr.expand(); + const Descriptor *Desc = Ptr.getFieldDesc(); unsigned Index; if (Ptr.isOnePastEnd()) Index = Ptr.getArray().getNumElems(); else Index = Ptr.getIndex(); - QualType ElemType = Ptr.getFieldDesc()->getElemQualType(); + QualType ElemType = Desc->getElemQualType(); Offset += (Index * ASTCtx.getTypeSizeInChars(ElemType)); - Path.push_back(APValue::LValuePathEntry::ArrayIndex(Index)); + if (Ptr.getArray().getType()->isArrayType()) + Path.push_back(APValue::LValuePathEntry::ArrayIndex(Index)); Ptr = Ptr.getArray(); } else { + const Descriptor *Desc = Ptr.getFieldDesc(); bool IsVirtual = false; // Create a path entry for the field. - const Descriptor *Desc = Ptr.getFieldDesc(); if (const auto *BaseOrMember = Desc->asDecl()) { if (const auto *FD = dyn_cast<FieldDecl>(BaseOrMember)) { Ptr = Ptr.getBase(); @@ -281,8 +289,11 @@ APValue Pointer::toAPValue(const ASTContext &ASTCtx) const { // Just invert the order of the elements. std::reverse(Path.begin(), Path.end()); - return APValue(Base, Offset, Path, /*IsOnePastEnd=*/isOnePastEnd(), - /*IsNullPtr=*/false); + if (UsePath) + return APValue(Base, Offset, Path, + /*IsOnePastEnd=*/!isElementPastEnd() && isOnePastEnd()); + + return APValue(Base, Offset, APValue::NoLValuePath()); } void Pointer::print(llvm::raw_ostream &OS) const { diff --git clang/lib/AST/ByteCode/Pointer.h clang/lib/AST/ByteCode/Pointer.h index ef03c12e86c1..971b0d5e14cf 100644 --- clang/lib/AST/ByteCode/Pointer.h +++ clang/lib/AST/ByteCode/Pointer.h @@ -630,8 +630,7 @@ public: if (isUnknownSizeArray()) return false; - return isElementPastEnd() || isPastEnd() || - (getSize() == getOffset() && !isZeroSizeArray()); + return isPastEnd() || (getSize() == getOffset() && !isZeroSizeArray()); } /// Checks if the pointer points past the end of the object. diff --git clang/lib/AST/ByteCode/Program.cpp clang/lib/AST/ByteCode/Program.cpp index 7d8862d606ba..1ffe7cd721f1 100644 --- clang/lib/AST/ByteCode/Program.cpp +++ clang/lib/AST/ByteCode/Program.cpp @@ -453,15 +453,21 @@ Descriptor *Program::createDescriptor(const DeclTy &D, const Type *Ty, // Complex types - represented as arrays of elements. if (const auto *CT = Ty->getAs<ComplexType>()) { - PrimType ElemTy = *Ctx.classify(CT->getElementType()); - return allocateDescriptor(D, ElemTy, MDSize, 2, IsConst, IsTemporary, + std::optional<PrimType> ElemTy = Ctx.classify(CT->getElementType()); + if (!ElemTy) + return nullptr; + + return allocateDescriptor(D, *ElemTy, MDSize, 2, IsConst, IsTemporary, IsMutable); } // Same with vector types. if (const auto *VT = Ty->getAs<VectorType>()) { - PrimType ElemTy = *Ctx.classify(VT->getElementType()); - return allocateDescriptor(D, ElemTy, MDSize, VT->getNumElements(), IsConst, + std::optional<PrimType> ElemTy = Ctx.classify(VT->getElementType()); + if (!ElemTy) + return nullptr; + + return allocateDescriptor(D, *ElemTy, MDSize, VT->getNumElements(), IsConst, IsTemporary, IsMutable); } diff --git clang/lib/AST/Decl.cpp clang/lib/AST/Decl.cpp index 74bcb618f295..610207cf8b9a 100644 --- clang/lib/AST/Decl.cpp +++ clang/lib/AST/Decl.cpp @@ -2659,10 +2659,6 @@ bool VarDecl::checkForConstantInitialization( return Eval->HasConstantInitialization; } -bool VarDecl::isParameterPack() const { - return isa<PackExpansionType>(getType()); -} - template<typename DeclT> static DeclT *getDefinitionOrSelf(DeclT *D) { assert(D); @@ -3069,6 +3065,7 @@ FunctionDecl::FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, FunctionDeclBits.IsIneligibleOrNotSelected = false; FunctionDeclBits.HasImplicitReturnZero = false; FunctionDeclBits.IsLateTemplateParsed = false; + FunctionDeclBits.IsInstantiatedFromMemberTemplate = false; FunctionDeclBits.ConstexprKind = static_cast<uint64_t>(ConstexprKind); FunctionDeclBits.BodyContainsImmediateEscalatingExpression = false; FunctionDeclBits.InstantiationIsPending = false; @@ -3314,6 +3311,10 @@ bool FunctionDecl::isImmediateFunction() const { .getConstructor() ->isImmediateFunction(); + if (FunctionDecl *P = getTemplateInstantiationPattern(); + P && P->isImmediateFunction()) + return true; + if (const auto *MD = dyn_cast<CXXMethodDecl>(this); MD && MD->isLambdaStaticInvoker()) return MD->getParent()->getLambdaCallOperator()->isImmediateFunction(); @@ -4356,9 +4357,9 @@ FunctionDecl::getTemplateSpecializationKindForInstantiation() const { void FunctionDecl::setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation) { - if (FunctionTemplateSpecializationInfo *FTSInfo - = TemplateOrSpecialization.dyn_cast< - FunctionTemplateSpecializationInfo*>()) { + if (FunctionTemplateSpecializationInfo *FTSInfo = + dyn_cast<FunctionTemplateSpecializationInfo *>( + TemplateOrSpecialization)) { FTSInfo->setTemplateSpecializationKind(TSK); if (TSK != TSK_ExplicitSpecialization && PointOfInstantiation.isValid() && @@ -4367,8 +4368,9 @@ FunctionDecl::setTemplateSpecializationKind(TemplateSpecializationKind TSK, if (ASTMutationListener *L = getASTContext().getASTMutationListener()) L->InstantiationRequested(this); } - } else if (MemberSpecializationInfo *MSInfo - = TemplateOrSpecialization.dyn_cast<MemberSpecializationInfo*>()) { + } else if (MemberSpecializationInfo *MSInfo = + dyn_cast<MemberSpecializationInfo *>( + TemplateOrSpecialization)) { MSInfo->setTemplateSpecializationKind(TSK); if (TSK != TSK_ExplicitSpecialization && PointOfInstantiation.isValid() && @@ -5415,6 +5417,13 @@ bool ValueDecl::isInitCapture() const { return false; } +bool ValueDecl::isParameterPack() const { + if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(this)) + return NTTP->isParameterPack(); + + return isa_and_nonnull<PackExpansionType>(getType().getTypePtrOrNull()); +} + void ImplicitParamDecl::anchor() {} ImplicitParamDecl *ImplicitParamDecl::Create(ASTContext &C, DeclContext *DC, @@ -5840,3 +5849,17 @@ bool clang::IsArmStreamingFunction(const FunctionDecl *FD, return false; } + +bool clang::hasArmZAState(const FunctionDecl *FD) { + const auto *T = FD->getType()->getAs<FunctionProtoType>(); + return (T && FunctionType::getArmZAState(T->getAArch64SMEAttributes()) != + FunctionType::ARM_None) || + (FD->hasAttr<ArmNewAttr>() && FD->getAttr<ArmNewAttr>()->isNewZA()); +} + +bool clang::hasArmZT0State(const FunctionDecl *FD) { + const auto *T = FD->getType()->getAs<FunctionProtoType>(); + return (T && FunctionType::getArmZT0State(T->getAArch64SMEAttributes()) != + FunctionType::ARM_None) || + (FD->hasAttr<ArmNewAttr>() && FD->getAttr<ArmNewAttr>()->isNewZT0()); +} diff --git clang/lib/AST/DeclBase.cpp clang/lib/AST/DeclBase.cpp index 8506b95f761f..c0a331d18cab 100644 --- clang/lib/AST/DeclBase.cpp +++ clang/lib/AST/DeclBase.cpp @@ -245,7 +245,7 @@ bool Decl::isTemplateParameterPack() const { } bool Decl::isParameterPack() const { - if (const auto *Var = dyn_cast<VarDecl>(this)) + if (const auto *Var = dyn_cast<ValueDecl>(this)) return Var->isParameterPack(); return isTemplateParameterPack(); diff --git clang/lib/AST/DeclCXX.cpp clang/lib/AST/DeclCXX.cpp index c0a4356dcb00..e394e0515e59 100644 --- clang/lib/AST/DeclCXX.cpp +++ clang/lib/AST/DeclCXX.cpp @@ -2292,18 +2292,22 @@ CXXDeductionGuideDecl *CXXDeductionGuideDecl::Create( ASTContext &C, DeclContext *DC, SourceLocation StartLoc, ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, SourceLocation EndLocation, CXXConstructorDecl *Ctor, - DeductionCandidate Kind, Expr *TrailingRequiresClause) { - return new (C, DC) - CXXDeductionGuideDecl(C, DC, StartLoc, ES, NameInfo, T, TInfo, - EndLocation, Ctor, Kind, TrailingRequiresClause); + DeductionCandidate Kind, Expr *TrailingRequiresClause, + const CXXDeductionGuideDecl *GeneratedFrom, + SourceDeductionGuideKind SourceKind) { + return new (C, DC) CXXDeductionGuideDecl( + C, DC, StartLoc, ES, NameInfo, T, TInfo, EndLocation, Ctor, Kind, + TrailingRequiresClause, GeneratedFrom, SourceKind); } CXXDeductionGuideDecl * CXXDeductionGuideDecl::CreateDeserialized(ASTContext &C, GlobalDeclID ID) { return new (C, ID) CXXDeductionGuideDecl( - C, nullptr, SourceLocation(), ExplicitSpecifier(), DeclarationNameInfo(), - QualType(), nullptr, SourceLocation(), nullptr, - DeductionCandidate::Normal, nullptr); + C, /*DC=*/nullptr, SourceLocation(), ExplicitSpecifier(), + DeclarationNameInfo(), QualType(), /*TInfo=*/nullptr, SourceLocation(), + /*Ctor=*/nullptr, DeductionCandidate::Normal, + /*TrailingRequiresClause=*/nullptr, + /*GeneratedFrom=*/nullptr, SourceDeductionGuideKind::None); } RequiresExprBodyDecl *RequiresExprBodyDecl::Create( @@ -3458,19 +3462,21 @@ VarDecl *ValueDecl::getPotentiallyDecomposedVarDecl() { if (auto *Var = llvm::dyn_cast<VarDecl>(this)) return Var; if (auto *BD = llvm::dyn_cast<BindingDecl>(this)) - return llvm::dyn_cast<VarDecl>(BD->getDecomposedDecl()); + return llvm::dyn_cast_if_present<VarDecl>(BD->getDecomposedDecl()); return nullptr; } void BindingDecl::anchor() {} BindingDecl *BindingDecl::Create(ASTContext &C, DeclContext *DC, - SourceLocation IdLoc, IdentifierInfo *Id) { - return new (C, DC) BindingDecl(DC, IdLoc, Id); + SourceLocation IdLoc, IdentifierInfo *Id, + QualType T) { + return new (C, DC) BindingDecl(DC, IdLoc, Id, T); } BindingDecl *BindingDecl::CreateDeserialized(ASTContext &C, GlobalDeclID ID) { - return new (C, ID) BindingDecl(nullptr, SourceLocation(), nullptr); + return new (C, ID) + BindingDecl(nullptr, SourceLocation(), nullptr, QualType()); } VarDecl *BindingDecl::getHoldingVar() const { @@ -3486,6 +3492,12 @@ VarDecl *BindingDecl::getHoldingVar() const { return VD; } +llvm::ArrayRef<Expr *> BindingDecl::getBindingPackExprs() const { + assert(Binding && "expecting a pack expr"); + auto *RP = cast<ResolvedUnexpandedPackExpr>(Binding); + return RP->getExprs(); +} + void DecompositionDecl::anchor() {} DecompositionDecl *DecompositionDecl::Create(ASTContext &C, DeclContext *DC, diff --git clang/lib/AST/DeclTemplate.cpp clang/lib/AST/DeclTemplate.cpp index de81bc64106f..2e1ed9e10713 100644 --- clang/lib/AST/DeclTemplate.cpp +++ clang/lib/AST/DeclTemplate.cpp @@ -1496,7 +1496,7 @@ SourceRange VarTemplateSpecializationDecl::getSourceRange() const { } void VarTemplateSpecializationDecl::setExternKeywordLoc(SourceLocation Loc) { - auto *Info = ExplicitInfo.dyn_cast<ExplicitInstantiationInfo *>(); + auto *Info = dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo); if (!Info) { // Don't allocate if the location is invalid. if (Loc.isInvalid()) @@ -1509,7 +1509,7 @@ void VarTemplateSpecializationDecl::setExternKeywordLoc(SourceLocation Loc) { } void VarTemplateSpecializationDecl::setTemplateKeywordLoc(SourceLocation Loc) { - auto *Info = ExplicitInfo.dyn_cast<ExplicitInstantiationInfo *>(); + auto *Info = dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo); if (!Info) { // Don't allocate if the location is invalid. if (Loc.isInvalid()) diff --git clang/lib/AST/DynamicRecursiveASTVisitor.cpp clang/lib/AST/DynamicRecursiveASTVisitor.cpp index 8cfabd9f3e93..b478e7a39ea1 100644 --- clang/lib/AST/DynamicRecursiveASTVisitor.cpp +++ clang/lib/AST/DynamicRecursiveASTVisitor.cpp @@ -89,9 +89,9 @@ using namespace clang; // // End result: RAV::TraverseCallExpr() is executed, namespace { -struct Impl : RecursiveASTVisitor<Impl> { - DynamicRecursiveASTVisitor &Visitor; - Impl(DynamicRecursiveASTVisitor &Visitor) : Visitor(Visitor) {} +template <bool Const> struct Impl : RecursiveASTVisitor<Impl<Const>> { + DynamicRecursiveASTVisitorBase<Const> &Visitor; + Impl(DynamicRecursiveASTVisitorBase<Const> &Visitor) : Visitor(Visitor) {} bool shouldVisitTemplateInstantiations() const { return Visitor.ShouldVisitTemplateInstantiations; @@ -189,8 +189,10 @@ struct Impl : RecursiveASTVisitor<Impl> { // TraverseStmt() always passes in a queue, so we have no choice but to // accept it as a parameter here. - bool dataTraverseNode(Stmt *S, DataRecursionQueue * = nullptr) { - // But since don't support postorder traversal, we don't need it, so + bool dataTraverseNode( + Stmt *S, + typename RecursiveASTVisitor<Impl>::DataRecursionQueue * = nullptr) { + // But since we don't support postorder traversal, we don't need it, so // simply discard it here. This way, derived classes don't need to worry // about including it as a parameter that they never use. return Visitor.dataTraverseNode(S); @@ -266,187 +268,106 @@ struct Impl : RecursiveASTVisitor<Impl> { }; } // namespace -void DynamicRecursiveASTVisitor::anchor() {} - -bool DynamicRecursiveASTVisitor::TraverseAST(ASTContext &AST) { - return Impl(*this).RecursiveASTVisitor<Impl>::TraverseAST(AST); -} - -bool DynamicRecursiveASTVisitor::TraverseAttr(Attr *At) { - return Impl(*this).RecursiveASTVisitor<Impl>::TraverseAttr(At); -} - -bool DynamicRecursiveASTVisitor::TraverseConstructorInitializer( - CXXCtorInitializer *Init) { - return Impl(*this).RecursiveASTVisitor<Impl>::TraverseConstructorInitializer( - Init); -} - -bool DynamicRecursiveASTVisitor::TraverseDecl(Decl *D) { - return Impl(*this).RecursiveASTVisitor<Impl>::TraverseDecl(D); -} - -bool DynamicRecursiveASTVisitor::TraverseLambdaCapture(LambdaExpr *LE, - const LambdaCapture *C, - Expr *Init) { - return Impl(*this).RecursiveASTVisitor<Impl>::TraverseLambdaCapture(LE, C, - Init); -} - -bool DynamicRecursiveASTVisitor::TraverseStmt(Stmt *S) { - return Impl(*this).RecursiveASTVisitor<Impl>::TraverseStmt(S); -} - -bool DynamicRecursiveASTVisitor::TraverseTemplateArgument( - const TemplateArgument &Arg) { - return Impl(*this).RecursiveASTVisitor<Impl>::TraverseTemplateArgument(Arg); -} - -bool DynamicRecursiveASTVisitor::TraverseTemplateArguments( - ArrayRef<TemplateArgument> Args) { - return Impl(*this).RecursiveASTVisitor<Impl>::TraverseTemplateArguments(Args); -} - -bool DynamicRecursiveASTVisitor::TraverseTemplateArgumentLoc( - const TemplateArgumentLoc &ArgLoc) { - return Impl(*this).RecursiveASTVisitor<Impl>::TraverseTemplateArgumentLoc( - ArgLoc); -} - -bool DynamicRecursiveASTVisitor::TraverseTemplateName(TemplateName Template) { - return Impl(*this).RecursiveASTVisitor<Impl>::TraverseTemplateName(Template); -} - -bool DynamicRecursiveASTVisitor::TraverseType(QualType T) { - return Impl(*this).RecursiveASTVisitor<Impl>::TraverseType(T); -} - -bool DynamicRecursiveASTVisitor::TraverseTypeLoc(TypeLoc TL) { - return Impl(*this).RecursiveASTVisitor<Impl>::TraverseTypeLoc(TL); -} - -bool DynamicRecursiveASTVisitor::TraverseTypeConstraint( - const TypeConstraint *C) { - return Impl(*this).RecursiveASTVisitor<Impl>::TraverseTypeConstraint(C); -} -bool DynamicRecursiveASTVisitor::TraverseObjCProtocolLoc( - ObjCProtocolLoc ProtocolLoc) { - return Impl(*this).RecursiveASTVisitor<Impl>::TraverseObjCProtocolLoc( - ProtocolLoc); -} - -bool DynamicRecursiveASTVisitor::TraverseConceptRequirement( - concepts::Requirement *R) { - return Impl(*this).RecursiveASTVisitor<Impl>::TraverseConceptRequirement(R); -} -bool DynamicRecursiveASTVisitor::TraverseConceptTypeRequirement( - concepts::TypeRequirement *R) { - return Impl(*this).RecursiveASTVisitor<Impl>::TraverseConceptTypeRequirement( - R); -} -bool DynamicRecursiveASTVisitor::TraverseConceptExprRequirement( - concepts::ExprRequirement *R) { - return Impl(*this).RecursiveASTVisitor<Impl>::TraverseConceptExprRequirement( - R); -} -bool DynamicRecursiveASTVisitor::TraverseConceptNestedRequirement( - concepts::NestedRequirement *R) { - return Impl(*this) - .RecursiveASTVisitor<Impl>::TraverseConceptNestedRequirement(R); -} - -bool DynamicRecursiveASTVisitor::TraverseConceptReference( - ConceptReference *CR) { - return Impl(*this).RecursiveASTVisitor<Impl>::TraverseConceptReference(CR); -} - -bool DynamicRecursiveASTVisitor::TraverseCXXBaseSpecifier( - const CXXBaseSpecifier &Base) { - return Impl(*this).RecursiveASTVisitor<Impl>::TraverseCXXBaseSpecifier(Base); -} - -bool DynamicRecursiveASTVisitor::TraverseDeclarationNameInfo( - DeclarationNameInfo NameInfo) { - return Impl(*this).RecursiveASTVisitor<Impl>::TraverseDeclarationNameInfo( - NameInfo); -} - -bool DynamicRecursiveASTVisitor::TraverseNestedNameSpecifier( - NestedNameSpecifier *NNS) { - return Impl(*this).RecursiveASTVisitor<Impl>::TraverseNestedNameSpecifier( - NNS); -} - -bool DynamicRecursiveASTVisitor::TraverseNestedNameSpecifierLoc( - NestedNameSpecifierLoc NNS) { - return Impl(*this).RecursiveASTVisitor<Impl>::TraverseNestedNameSpecifierLoc( - NNS); +template <bool Const> void DynamicRecursiveASTVisitorBase<Const>::anchor() {} + +// Helper macros to forward a call to the base implementation since that +// ends up getting very verbose otherwise. + +// This calls the RecursiveASTVisitor implementation of the same function, +// stripping any 'const' that the DRAV implementation may have added since +// the RAV implementation largely doesn't use 'const'. +#define FORWARD_TO_BASE(Function, Type, RefOrPointer) \ + template <bool Const> \ + bool DynamicRecursiveASTVisitorBase<Const>::Function( \ + MaybeConst<Type> RefOrPointer Param) { \ + return Impl<Const>(*this).RecursiveASTVisitor<Impl<Const>>::Function( \ + const_cast<Type RefOrPointer>(Param)); \ + } + +// Same as 'FORWARD_TO_BASE', but doesn't change the parameter type in any way. +#define FORWARD_TO_BASE_EXACT(Function, Type) \ + template <bool Const> \ + bool DynamicRecursiveASTVisitorBase<Const>::Function(Type Param) { \ + return Impl<Const>(*this).RecursiveASTVisitor<Impl<Const>>::Function( \ + Param); \ + } + +FORWARD_TO_BASE(TraverseAST, ASTContext, &) +FORWARD_TO_BASE(TraverseAttr, Attr, *) +FORWARD_TO_BASE(TraverseConstructorInitializer, CXXCtorInitializer, *) +FORWARD_TO_BASE(TraverseDecl, Decl, *) +FORWARD_TO_BASE(TraverseStmt, Stmt, *) +FORWARD_TO_BASE(TraverseNestedNameSpecifier, NestedNameSpecifier, *) +FORWARD_TO_BASE(TraverseTemplateInstantiations, ClassTemplateDecl, *) +FORWARD_TO_BASE(TraverseTemplateInstantiations, VarTemplateDecl, *) +FORWARD_TO_BASE(TraverseTemplateInstantiations, FunctionTemplateDecl, *) +FORWARD_TO_BASE(TraverseConceptRequirement, concepts::Requirement, *) +FORWARD_TO_BASE(TraverseConceptTypeRequirement, concepts::TypeRequirement, *) +FORWARD_TO_BASE(TraverseConceptExprRequirement, concepts::ExprRequirement, *) +FORWARD_TO_BASE(TraverseConceptReference, ConceptReference, *) +FORWARD_TO_BASE(TraverseConceptNestedRequirement, + concepts::NestedRequirement, *) + +FORWARD_TO_BASE_EXACT(TraverseCXXBaseSpecifier, const CXXBaseSpecifier &) +FORWARD_TO_BASE_EXACT(TraverseDeclarationNameInfo, DeclarationNameInfo) +FORWARD_TO_BASE_EXACT(TraverseTemplateArgument, const TemplateArgument &) +FORWARD_TO_BASE_EXACT(TraverseTemplateArguments, ArrayRef<TemplateArgument>) +FORWARD_TO_BASE_EXACT(TraverseTemplateArgumentLoc, const TemplateArgumentLoc &) +FORWARD_TO_BASE_EXACT(TraverseTemplateName, TemplateName) +FORWARD_TO_BASE_EXACT(TraverseType, QualType) +FORWARD_TO_BASE_EXACT(TraverseTypeLoc, TypeLoc) +FORWARD_TO_BASE_EXACT(TraverseTypeConstraint, const TypeConstraint *) +FORWARD_TO_BASE_EXACT(TraverseObjCProtocolLoc, ObjCProtocolLoc) +FORWARD_TO_BASE_EXACT(TraverseNestedNameSpecifierLoc, NestedNameSpecifierLoc) + +template <bool Const> +bool DynamicRecursiveASTVisitorBase<Const>::TraverseLambdaCapture( + MaybeConst<LambdaExpr> *LE, const LambdaCapture *C, + MaybeConst<Expr> *Init) { + return Impl<Const>(*this) + .RecursiveASTVisitor<Impl<Const>>::TraverseLambdaCapture( + const_cast<LambdaExpr *>(LE), C, const_cast<Expr *>(Init)); } -bool DynamicRecursiveASTVisitor::dataTraverseNode(Stmt *S) { - return Impl(*this).RecursiveASTVisitor<Impl>::dataTraverseNode(S, nullptr); +template <bool Const> +bool DynamicRecursiveASTVisitorBase<Const>::dataTraverseNode( + MaybeConst<Stmt> *S) { + return Impl<Const>(*this).RecursiveASTVisitor<Impl<Const>>::dataTraverseNode( + const_cast<Stmt *>(S), nullptr); } -#define DEF_TRAVERSE_TMPL_INST(kind) \ - bool DynamicRecursiveASTVisitor::TraverseTemplateInstantiations( \ - kind##TemplateDecl *D) { \ - return Impl(*this) \ - .RecursiveASTVisitor<Impl>::TraverseTemplateInstantiations(D); \ - } -DEF_TRAVERSE_TMPL_INST(Class) -DEF_TRAVERSE_TMPL_INST(Var) -DEF_TRAVERSE_TMPL_INST(Function) -#undef DEF_TRAVERSE_TMPL_INST - // Declare Traverse*() for and friends all concrete Decl classes. #define ABSTRACT_DECL(DECL) #define DECL(CLASS, BASE) \ - bool DynamicRecursiveASTVisitor::Traverse##CLASS##Decl(CLASS##Decl *D) { \ - return Impl(*this).RecursiveASTVisitor<Impl>::Traverse##CLASS##Decl(D); \ - } \ - bool DynamicRecursiveASTVisitor::WalkUpFrom##CLASS##Decl(CLASS##Decl *D) { \ - return Impl(*this).RecursiveASTVisitor<Impl>::WalkUpFrom##CLASS##Decl(D); \ - } + FORWARD_TO_BASE(Traverse##CLASS##Decl, CLASS##Decl, *) \ + FORWARD_TO_BASE(WalkUpFrom##CLASS##Decl, CLASS##Decl, *) #include "clang/AST/DeclNodes.inc" // Declare Traverse*() and friends for all concrete Stmt classes. #define ABSTRACT_STMT(STMT) -#define STMT(CLASS, PARENT) \ - bool DynamicRecursiveASTVisitor::Traverse##CLASS(CLASS *S) { \ - return Impl(*this).RecursiveASTVisitor<Impl>::Traverse##CLASS(S); \ - } +#define STMT(CLASS, PARENT) FORWARD_TO_BASE(Traverse##CLASS, CLASS, *) #include "clang/AST/StmtNodes.inc" -#define STMT(CLASS, PARENT) \ - bool DynamicRecursiveASTVisitor::WalkUpFrom##CLASS(CLASS *S) { \ - return Impl(*this).RecursiveASTVisitor<Impl>::WalkUpFrom##CLASS(S); \ - } +#define STMT(CLASS, PARENT) FORWARD_TO_BASE(WalkUpFrom##CLASS, CLASS, *) #include "clang/AST/StmtNodes.inc" -// Declare Traverse*() and friends for all concrete Typeclasses. +// Declare Traverse*() and friends for all concrete Type classes. #define ABSTRACT_TYPE(CLASS, BASE) #define TYPE(CLASS, BASE) \ - bool DynamicRecursiveASTVisitor::Traverse##CLASS##Type(CLASS##Type *T) { \ - return Impl(*this).RecursiveASTVisitor<Impl>::Traverse##CLASS##Type(T); \ - } \ - bool DynamicRecursiveASTVisitor::WalkUpFrom##CLASS##Type(CLASS##Type *T) { \ - return Impl(*this).RecursiveASTVisitor<Impl>::WalkUpFrom##CLASS##Type(T); \ - } + FORWARD_TO_BASE(Traverse##CLASS##Type, CLASS##Type, *) \ + FORWARD_TO_BASE(WalkUpFrom##CLASS##Type, CLASS##Type, *) #include "clang/AST/TypeNodes.inc" #define ABSTRACT_TYPELOC(CLASS, BASE) #define TYPELOC(CLASS, BASE) \ - bool DynamicRecursiveASTVisitor::Traverse##CLASS##TypeLoc( \ - CLASS##TypeLoc TL) { \ - return Impl(*this).RecursiveASTVisitor<Impl>::Traverse##CLASS##TypeLoc( \ - TL); \ - } + FORWARD_TO_BASE_EXACT(Traverse##CLASS##TypeLoc, CLASS##TypeLoc) #include "clang/AST/TypeLocNodes.def" #define TYPELOC(CLASS, BASE) \ - bool DynamicRecursiveASTVisitor::WalkUpFrom##CLASS##TypeLoc( \ - CLASS##TypeLoc TL) { \ - return Impl(*this).RecursiveASTVisitor<Impl>::WalkUpFrom##CLASS##TypeLoc( \ - TL); \ - } + FORWARD_TO_BASE_EXACT(WalkUpFrom##CLASS##TypeLoc, CLASS##TypeLoc) #include "clang/AST/TypeLocNodes.def" + +namespace clang { +template class DynamicRecursiveASTVisitorBase<false>; +template class DynamicRecursiveASTVisitorBase<true>; +} // namespace clang diff --git clang/lib/AST/Expr.cpp clang/lib/AST/Expr.cpp index 31b95bca613c..4fc62919fde9 100644 --- clang/lib/AST/Expr.cpp +++ clang/lib/AST/Expr.cpp @@ -895,8 +895,7 @@ std::string PredefinedExpr::ComputeName(PredefinedIdentKind IK, // type deduction and lambdas. For trailing return types resolve the // decltype expression. Otherwise print the real type when this is // not a constructor or destructor. - if (isa<CXXMethodDecl>(FD) && - cast<CXXMethodDecl>(FD)->getParent()->isLambda()) + if (isLambdaMethod(FD)) Proto = "auto " + Proto; else if (FT && FT->getReturnType()->getAs<DecltypeType>()) FT->getReturnType() @@ -3660,6 +3659,7 @@ bool Expr::HasSideEffects(const ASTContext &Ctx, case PackIndexingExprClass: case HLSLOutArgExprClass: case OpenACCAsteriskSizeExprClass: + case ResolvedUnexpandedPackExprClass: // These never have a side-effect. return false; diff --git clang/lib/AST/ExprCXX.cpp clang/lib/AST/ExprCXX.cpp index 5bf5d6adf525..d900af895b42 100644 --- clang/lib/AST/ExprCXX.cpp +++ clang/lib/AST/ExprCXX.cpp @@ -1965,3 +1965,52 @@ CXXFoldExpr::CXXFoldExpr(QualType T, UnresolvedLookupExpr *Callee, SubExprs[SubExpr::RHS] = RHS; setDependence(computeDependence(this)); } + +ResolvedUnexpandedPackExpr::ResolvedUnexpandedPackExpr(SourceLocation BL, + QualType QT, + unsigned NumExprs) + : Expr(ResolvedUnexpandedPackExprClass, QT, VK_PRValue, OK_Ordinary), + BeginLoc(BL), NumExprs(NumExprs) { + // C++ [temp.dep.expr]p3 + // An id-expression is type-dependent if it is + // - associated by name lookup with a pack + setDependence(ExprDependence::TypeValueInstantiation | + ExprDependence::UnexpandedPack); +} + +ResolvedUnexpandedPackExpr * +ResolvedUnexpandedPackExpr::CreateDeserialized(ASTContext &Ctx, + unsigned NumExprs) { + void *Mem = Ctx.Allocate(totalSizeToAlloc<Expr *>(NumExprs), + alignof(ResolvedUnexpandedPackExpr)); + return new (Mem) + ResolvedUnexpandedPackExpr(SourceLocation(), QualType(), NumExprs); +} + +ResolvedUnexpandedPackExpr * +ResolvedUnexpandedPackExpr::Create(ASTContext &Ctx, SourceLocation BL, + QualType T, unsigned NumExprs) { + void *Mem = Ctx.Allocate(totalSizeToAlloc<Expr *>(NumExprs), + alignof(ResolvedUnexpandedPackExpr)); + ResolvedUnexpandedPackExpr *New = + new (Mem) ResolvedUnexpandedPackExpr(BL, T, NumExprs); + + auto Exprs = New->getExprs(); + std::uninitialized_fill(Exprs.begin(), Exprs.end(), nullptr); + + return New; +} + +ResolvedUnexpandedPackExpr * +ResolvedUnexpandedPackExpr::Create(ASTContext &Ctx, SourceLocation BL, + QualType T, ArrayRef<Expr *> Exprs) { + auto *New = Create(Ctx, BL, T, Exprs.size()); + std::uninitialized_copy(Exprs.begin(), Exprs.end(), New->getExprs().begin()); + return New; +} + +ResolvedUnexpandedPackExpr *ResolvedUnexpandedPackExpr::getFromDecl(Decl *D) { + if (auto *BD = dyn_cast<BindingDecl>(D)) + return dyn_cast_if_present<ResolvedUnexpandedPackExpr>(BD->getBinding()); + return nullptr; +} diff --git clang/lib/AST/ExprClassification.cpp clang/lib/AST/ExprClassification.cpp index 3f37d06cc8f3..5225c3ca773a 100644 --- clang/lib/AST/ExprClassification.cpp +++ clang/lib/AST/ExprClassification.cpp @@ -451,6 +451,13 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) { case Expr::PackExpansionExprClass: return ClassifyInternal(Ctx, cast<PackExpansionExpr>(E)->getPattern()); + case Expr::ResolvedUnexpandedPackExprClass: { + if (cast<ResolvedUnexpandedPackExpr>(E)->getNumExprs() > 0) + return ClassifyInternal( + Ctx, cast<ResolvedUnexpandedPackExpr>(E)->getExpansion(0)); + return Cl::CL_LValue; + } + case Expr::MaterializeTemporaryExprClass: return cast<MaterializeTemporaryExpr>(E)->isBoundToLvalueReference() ? Cl::CL_LValue diff --git clang/lib/AST/ExprConstant.cpp clang/lib/AST/ExprConstant.cpp index be8f1fe02e72..37019b5235f5 100644 --- clang/lib/AST/ExprConstant.cpp +++ clang/lib/AST/ExprConstant.cpp @@ -3600,8 +3600,12 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E, VD->mightBeUsableInConstantExpressions(Info.Ctx)) || ((Info.getLangOpts().CPlusPlus || Info.getLangOpts().OpenCL) && !Info.getLangOpts().CPlusPlus11 && !VD->hasICEInitializer(Info.Ctx))) { - Info.CCEDiag(E, diag::note_constexpr_var_init_non_constant, 1) << VD; - NoteLValueLocation(Info, Base); + if (Init) { + Info.CCEDiag(E, diag::note_constexpr_var_init_non_constant, 1) << VD; + NoteLValueLocation(Info, Base); + } else { + Info.CCEDiag(E); + } } // Never use the initializer of a weak variable, not even for constant @@ -5221,7 +5225,7 @@ static bool EvaluateDecl(EvalInfo &Info, const Decl *D) { OK &= EvaluateVarDecl(Info, VD); if (const DecompositionDecl *DD = dyn_cast<DecompositionDecl>(D)) - for (auto *BD : DD->bindings()) + for (auto *BD : DD->flat_bindings()) if (auto *VD = BD->getHoldingVar()) OK &= EvaluateDecl(Info, VD); @@ -17249,6 +17253,7 @@ static ICEDiag CheckICE(const Expr* E, const ASTContext &Ctx) { case Expr::SYCLUniqueStableNameExprClass: case Expr::CXXParenListInitExprClass: case Expr::HLSLOutArgExprClass: + case Expr::ResolvedUnexpandedPackExprClass: return ICEDiag(IK_NotICE, E->getBeginLoc()); case Expr::InitListExprClass: { diff --git clang/lib/AST/ItaniumMangle.cpp clang/lib/AST/ItaniumMangle.cpp index 1dd936cf4fb5..e889b74a5cda 100644 --- clang/lib/AST/ItaniumMangle.cpp +++ clang/lib/AST/ItaniumMangle.cpp @@ -3433,7 +3433,7 @@ void CXXNameMangler::mangleType(const BuiltinType *T) { type_name = MangledName; \ Out << (type_name == Name ? "u" : "") << type_name.size() << type_name; \ break; -#define AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \ +#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \ case BuiltinType::Id: \ type_name = MangledName; \ Out << (type_name == Name ? "u" : "") << type_name.size() << type_name; \ @@ -3919,6 +3919,9 @@ void CXXNameMangler::mangleNeonVectorType(const VectorType *T) { case BuiltinType::Float: EltName = "float32_t"; break; case BuiltinType::Half: EltName = "float16_t"; break; case BuiltinType::BFloat16: EltName = "bfloat16_t"; break; + case BuiltinType::MFloat8: + EltName = "mfloat8_t"; + break; default: llvm_unreachable("unexpected Neon vector element type"); } @@ -3972,6 +3975,8 @@ static StringRef mangleAArch64VectorBase(const BuiltinType *EltType) { return "Float64"; case BuiltinType::BFloat16: return "Bfloat16"; + case BuiltinType::MFloat8: + return "Mfloat8"; default: llvm_unreachable("Unexpected vector element base type"); } @@ -4928,7 +4933,7 @@ recurse: case Expr::SourceLocExprClass: case Expr::EmbedExprClass: case Expr::BuiltinBitCastExprClass: - { + case Expr::ResolvedUnexpandedPackExprClass: { NotPrimaryExpr(); if (!NullOut) { // As bad as this diagnostic is, it's better than crashing. diff --git clang/lib/AST/ParentMapContext.cpp clang/lib/AST/ParentMapContext.cpp index 7ff492443031..2e77e1d7c4c6 100644 --- clang/lib/AST/ParentMapContext.cpp +++ clang/lib/AST/ParentMapContext.cpp @@ -117,7 +117,7 @@ class ParentMapContext::ParentMap { if (I == Map.end()) { return llvm::ArrayRef<DynTypedNode>(); } - if (const auto *V = I->second.template dyn_cast<ParentVector *>()) { + if (const auto *V = dyn_cast<ParentVector *>(I->second)) { return V->view(); } return getSingleDynTypedNodeFromParentMap(I->second); @@ -268,9 +268,9 @@ public: auto It = PointerParents.find(E); if (It == PointerParents.end()) break; - const auto *S = It->second.dyn_cast<const Stmt *>(); + const auto *S = dyn_cast<const Stmt *>(It->second); if (!S) { - if (auto *Vec = It->second.dyn_cast<ParentVector *>()) + if (auto *Vec = dyn_cast<ParentVector *>(It->second)) return Vec->view(); return getSingleDynTypedNodeFromParentMap(It->second); } diff --git clang/lib/AST/StmtPrinter.cpp clang/lib/AST/StmtPrinter.cpp index b5def6fbe525..d523abfe3128 100644 --- clang/lib/AST/StmtPrinter.cpp +++ clang/lib/AST/StmtPrinter.cpp @@ -45,9 +45,11 @@ #include "clang/Basic/TypeTraits.h" #include "clang/Lex/Lexer.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" @@ -1257,11 +1259,12 @@ void StmtPrinter::VisitConstantExpr(ConstantExpr *Node) { } void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) { - if (const auto *OCED = dyn_cast<OMPCapturedExprDecl>(Node->getDecl())) { + ValueDecl *VD = Node->getDecl(); + if (const auto *OCED = dyn_cast<OMPCapturedExprDecl>(VD)) { OCED->getInit()->IgnoreImpCasts()->printPretty(OS, nullptr, Policy); return; } - if (const auto *TPOD = dyn_cast<TemplateParamObjectDecl>(Node->getDecl())) { + if (const auto *TPOD = dyn_cast<TemplateParamObjectDecl>(VD)) { TPOD->printAsExpr(OS, Policy); return; } @@ -1269,16 +1272,41 @@ void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) { Qualifier->print(OS, Policy); if (Node->hasTemplateKeyword()) OS << "template "; - if (Policy.CleanUglifiedParameters && - isa<ParmVarDecl, NonTypeTemplateParmDecl>(Node->getDecl()) && - Node->getDecl()->getIdentifier()) - OS << Node->getDecl()->getIdentifier()->deuglifiedName(); - else - Node->getNameInfo().printName(OS, Policy); + DeclarationNameInfo NameInfo = Node->getNameInfo(); + if (IdentifierInfo *ID = NameInfo.getName().getAsIdentifierInfo(); + ID || NameInfo.getName().getNameKind() != DeclarationName::Identifier) { + if (Policy.CleanUglifiedParameters && + isa<ParmVarDecl, NonTypeTemplateParmDecl>(VD) && ID) + OS << ID->deuglifiedName(); + else + NameInfo.printName(OS, Policy); + } else { + switch (VD->getKind()) { + case Decl::NonTypeTemplateParm: { + auto *TD = cast<NonTypeTemplateParmDecl>(VD); + OS << "value-parameter-" << TD->getDepth() << '-' << TD->getIndex() << ""; + break; + } + case Decl::ParmVar: { + auto *PD = cast<ParmVarDecl>(VD); + OS << "function-parameter-" << PD->getFunctionScopeDepth() << '-' + << PD->getFunctionScopeIndex(); + break; + } + case Decl::Decomposition: + OS << "decomposition"; + for (const auto &I : cast<DecompositionDecl>(VD)->bindings()) + OS << '-' << I->getName(); + break; + default: + OS << "unhandled-anonymous-" << VD->getDeclKindName(); + break; + } + } if (Node->hasExplicitTemplateArgs()) { const TemplateParameterList *TPL = nullptr; if (!Node->hadMultipleCandidates()) - if (auto *TD = dyn_cast<TemplateDecl>(Node->getDecl())) + if (auto *TD = dyn_cast<TemplateDecl>(VD)) TPL = TD->getTemplateParameters(); printTemplateArgumentList(OS, Node->template_arguments(), Policy, TPL); } @@ -2567,6 +2595,15 @@ void StmtPrinter::VisitPackIndexingExpr(PackIndexingExpr *E) { OS << "]"; } +void StmtPrinter::VisitResolvedUnexpandedPackExpr( + ResolvedUnexpandedPackExpr *E) { + OS << "<<resolved pack("; + llvm::interleave( + E->getExprs().begin(), E->getExprs().end(), + [this](auto *X) { PrintExpr(X); }, [this] { OS << ", "; }); + OS << ")>>"; +} + void StmtPrinter::VisitSubstNonTypeTemplateParmPackExpr( SubstNonTypeTemplateParmPackExpr *Node) { OS << *Node->getParameterPack(); diff --git clang/lib/AST/StmtProfile.cpp clang/lib/AST/StmtProfile.cpp index 85b59f714ba8..84985fcb20ff 100644 --- clang/lib/AST/StmtProfile.cpp +++ clang/lib/AST/StmtProfile.cpp @@ -2270,16 +2270,20 @@ void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) { void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) { VisitExpr(S); - VisitDecl(S->getPack()); if (S->isPartiallySubstituted()) { auto Args = S->getPartialArguments(); ID.AddInteger(Args.size()); for (const auto &TA : Args) VisitTemplateArgument(TA); } else { + VisitDecl(S->getPack()); ID.AddInteger(0); } } +void StmtProfiler::VisitResolvedUnexpandedPackExpr( + const ResolvedUnexpandedPackExpr *S) { + VisitExpr(S); +} void StmtProfiler::VisitPackIndexingExpr(const PackIndexingExpr *E) { VisitExpr(E); diff --git clang/lib/AST/TextNodeDumper.cpp clang/lib/AST/TextNodeDumper.cpp index 670641242cae..a57cba959748 100644 --- clang/lib/AST/TextNodeDumper.cpp +++ clang/lib/AST/TextNodeDumper.cpp @@ -710,10 +710,36 @@ void TextNodeDumper::Visit(const APValue &Value, QualType Ty) { << GetApproxValue(Value.getComplexFloatImag()) << 'i'; } return; - case APValue::LValue: + case APValue::LValue: { (void)Context; - OS << "LValue <todo>"; + OS << "LValue Base="; + APValue::LValueBase B = Value.getLValueBase(); + if (B.isNull()) + OS << "null"; + else if (const auto *BE = B.dyn_cast<const Expr *>()) { + OS << BE->getStmtClassName() << ' '; + dumpPointer(BE); + } else { + const auto *VDB = B.get<const ValueDecl *>(); + OS << VDB->getDeclKindName() << "Decl"; + dumpPointer(VDB); + } + OS << ", Null=" << Value.isNullPointer() + << ", Offset=" << Value.getLValueOffset().getQuantity() + << ", HasPath=" << Value.hasLValuePath(); + if (Value.hasLValuePath()) { + OS << ", PathLength=" << Value.getLValuePath().size(); + OS << ", Path=("; + llvm::ListSeparator Sep; + for (const auto &PathEntry : Value.getLValuePath()) { + // We're printing all entries as array indices because don't have the + // type information here to do anything else. + OS << Sep << PathEntry.getAsArrayIndex(); + } + OS << ")"; + } return; + } case APValue::Array: { unsigned ArraySize = Value.getArraySize(); unsigned NumInitializedElements = Value.getArrayInitializedElts(); @@ -875,7 +901,41 @@ void TextNodeDumper::dumpBareDeclRef(const Decl *D) { if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) { ColorScope Color(OS, ShowColors, DeclNameColor); - OS << " '" << ND->getDeclName() << '\''; + if (DeclarationName Name = ND->getDeclName()) + OS << " '" << Name << '\''; + else + switch (ND->getKind()) { + case Decl::Decomposition: { + auto *DD = cast<DecompositionDecl>(ND); + OS << " first_binding '" << DD->bindings()[0]->getDeclName() << '\''; + break; + } + case Decl::Field: { + auto *FD = cast<FieldDecl>(ND); + OS << " field_index " << FD->getFieldIndex(); + break; + } + case Decl::ParmVar: { + auto *PD = cast<ParmVarDecl>(ND); + OS << " depth " << PD->getFunctionScopeDepth() << " index " + << PD->getFunctionScopeIndex(); + break; + } + case Decl::TemplateTypeParm: { + auto *TD = cast<TemplateTypeParmDecl>(ND); + OS << " depth " << TD->getDepth() << " index " << TD->getIndex(); + break; + } + case Decl::NonTypeTemplateParm: { + auto *TD = cast<NonTypeTemplateParmDecl>(ND); + OS << " depth " << TD->getDepth() << " index " << TD->getIndex(); + break; + } + default: + // Var, Namespace, (CXX)Record: Nothing else besides source location. + dumpSourceRange(ND->getSourceRange()); + break; + } } if (const ValueDecl *VD = dyn_cast<ValueDecl>(D)) diff --git clang/lib/AST/Type.cpp clang/lib/AST/Type.cpp index caa0ac858a1b..fde0746a1757 100644 --- clang/lib/AST/Type.cpp +++ clang/lib/AST/Type.cpp @@ -2527,9 +2527,7 @@ bool Type::isSVESizelessBuiltinType() const { #define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \ case BuiltinType::Id: \ return true; -#define AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \ - case BuiltinType::Id: \ - return false; +#define SVE_TYPE(Name, Id, SingletonId) #include "clang/Basic/AArch64SVEACLETypes.def" default: return false; diff --git clang/lib/Basic/Diagnostic.cpp clang/lib/Basic/Diagnostic.cpp index ae71758bc81e..9e2f13413564 100644 --- clang/lib/Basic/Diagnostic.cpp +++ clang/lib/Basic/Diagnostic.cpp @@ -145,7 +145,7 @@ void DiagnosticsEngine::Reset(bool soft /*=false*/) { // Create a DiagState and DiagStatePoint representing diagnostic changes // through command-line. - DiagStates.emplace_back(); + DiagStates.emplace_back(*Diags); DiagStatesByLoc.appendFirst(&DiagStates.back()); } } @@ -156,8 +156,11 @@ DiagnosticsEngine::DiagState::getOrAddMapping(diag::kind Diag) { DiagMap.insert(std::make_pair(Diag, DiagnosticMapping())); // Initialize the entry if we added it. - if (Result.second) - Result.first->second = DiagnosticIDs::getDefaultMapping(Diag); + if (Result.second) { + Result.first->second = DiagIDs.getDefaultMapping(Diag); + if (DiagnosticIDs::IsCustomDiag(Diag)) + DiagIDs.initCustomDiagMapping(Result.first->second, Diag); + } return Result.first->second; } @@ -299,7 +302,8 @@ void DiagnosticsEngine::DiagStateMap::dump(SourceManager &SrcMgr, for (auto &Mapping : *Transition.State) { StringRef Option = - DiagnosticIDs::getWarningOptionForDiag(Mapping.first); + SrcMgr.getDiagnostics().Diags->getWarningOptionForDiag( + Mapping.first); if (!DiagName.empty() && DiagName != Option) continue; @@ -343,9 +347,7 @@ void DiagnosticsEngine::PushDiagStatePoint(DiagState *State, void DiagnosticsEngine::setSeverity(diag::kind Diag, diag::Severity Map, SourceLocation L) { - assert(Diag < diag::DIAG_UPPER_LIMIT && - "Can only map builtin diagnostics"); - assert((Diags->isBuiltinWarningOrExtension(Diag) || + assert((Diags->isWarningOrExtension(Diag) || (Map == diag::Severity::Fatal || Map == diag::Severity::Error)) && "Cannot map errors into warnings!"); assert((L.isInvalid() || SourceMgr) && "No SourceMgr for valid location"); @@ -397,6 +399,8 @@ bool DiagnosticsEngine::setSeverityForGroup(diag::Flavor Flavor, if (Diags->getDiagnosticsInGroup(Flavor, Group, GroupDiags)) return true; + Diags->setGroupSeverity(Group, Map); + // Set the mapping. for (diag::kind Diag : GroupDiags) setSeverity(Diag, Map, Loc); @@ -419,6 +423,7 @@ bool DiagnosticsEngine::setDiagnosticGroupWarningAsError(StringRef Group, if (Enabled) return setSeverityForGroup(diag::Flavor::WarningOrError, Group, diag::Severity::Error); + Diags->setGroupSeverity(Group, diag::Severity::Warning); // Otherwise, we want to set the diagnostic mapping's "no Werror" bit, and // potentially downgrade anything already mapped to be a warning. @@ -450,6 +455,7 @@ bool DiagnosticsEngine::setDiagnosticGroupErrorAsFatal(StringRef Group, if (Enabled) return setSeverityForGroup(diag::Flavor::WarningOrError, Group, diag::Severity::Fatal); + Diags->setGroupSeverity(Group, diag::Severity::Error); // Otherwise, we want to set the diagnostic mapping's "no Wfatal-errors" bit, // and potentially downgrade anything already mapped to be a fatal error. @@ -482,7 +488,7 @@ void DiagnosticsEngine::setSeverityForAll(diag::Flavor Flavor, // Set the mapping. for (diag::kind Diag : AllDiags) - if (Diags->isBuiltinWarningOrExtension(Diag)) + if (Diags->isWarningOrExtension(Diag)) setSeverity(Diag, Map, Loc); } diff --git clang/lib/Basic/DiagnosticIDs.cpp clang/lib/Basic/DiagnosticIDs.cpp index de1de6f61f3a..ca5b8d2da769 100644 --- clang/lib/Basic/DiagnosticIDs.cpp +++ clang/lib/Basic/DiagnosticIDs.cpp @@ -62,13 +62,12 @@ const uint32_t StaticDiagInfoDescriptionOffsets[] = { #undef DIAG }; -// Diagnostic classes. enum DiagnosticClass { - CLASS_NOTE = 0x01, - CLASS_REMARK = 0x02, - CLASS_WARNING = 0x03, - CLASS_EXTENSION = 0x04, - CLASS_ERROR = 0x05 + CLASS_NOTE = DiagnosticIDs::CLASS_NOTE, + CLASS_REMARK = DiagnosticIDs::CLASS_REMARK, + CLASS_WARNING = DiagnosticIDs::CLASS_WARNING, + CLASS_EXTENSION = DiagnosticIDs::CLASS_EXTENSION, + CLASS_ERROR = DiagnosticIDs::CLASS_ERROR, }; struct StaticDiagInfoRec { @@ -229,11 +228,60 @@ CATEGORY(INSTALLAPI, REFACTORING) return Found; } -DiagnosticMapping DiagnosticIDs::getDefaultMapping(unsigned DiagID) { +//===----------------------------------------------------------------------===// +// Custom Diagnostic information +//===----------------------------------------------------------------------===// + +namespace clang { +namespace diag { +using CustomDiagDesc = DiagnosticIDs::CustomDiagDesc; +class CustomDiagInfo { + std::vector<CustomDiagDesc> DiagInfo; + std::map<CustomDiagDesc, unsigned> DiagIDs; + std::map<diag::Group, std::vector<unsigned>> GroupToDiags; + +public: + /// getDescription - Return the description of the specified custom + /// diagnostic. + const CustomDiagDesc &getDescription(unsigned DiagID) const { + assert(DiagID - DIAG_UPPER_LIMIT < DiagInfo.size() && + "Invalid diagnostic ID"); + return DiagInfo[DiagID - DIAG_UPPER_LIMIT]; + } + + unsigned getOrCreateDiagID(DiagnosticIDs::CustomDiagDesc D) { + // Check to see if it already exists. + std::map<CustomDiagDesc, unsigned>::iterator I = DiagIDs.lower_bound(D); + if (I != DiagIDs.end() && I->first == D) + return I->second; + + // If not, assign a new ID. + unsigned ID = DiagInfo.size() + DIAG_UPPER_LIMIT; + DiagIDs.insert(std::make_pair(D, ID)); + DiagInfo.push_back(D); + if (auto Group = D.GetGroup()) + GroupToDiags[*Group].emplace_back(ID); + return ID; + } + + ArrayRef<unsigned> getDiagsInGroup(diag::Group G) const { + if (auto Diags = GroupToDiags.find(G); Diags != GroupToDiags.end()) + return Diags->second; + return {}; + } +}; + +} // namespace diag +} // namespace clang + +DiagnosticMapping DiagnosticIDs::getDefaultMapping(unsigned DiagID) const { DiagnosticMapping Info = DiagnosticMapping::Make( diag::Severity::Fatal, /*IsUser=*/false, /*IsPragma=*/false); - if (const StaticDiagInfoRec *StaticInfo = GetDiagInfo(DiagID)) { + if (IsCustomDiag(DiagID)) { + Info.setSeverity( + CustomDiagInfo->getDescription(DiagID).GetDefaultSeverity()); + } else if (const StaticDiagInfoRec *StaticInfo = GetDiagInfo(DiagID)) { Info.setSeverity((diag::Severity)StaticInfo->DefaultSeverity); if (StaticInfo->WarnNoWerror) { @@ -246,6 +294,22 @@ DiagnosticMapping DiagnosticIDs::getDefaultMapping(unsigned DiagID) { return Info; } +void DiagnosticIDs::initCustomDiagMapping(DiagnosticMapping &Mapping, + unsigned DiagID) { + assert(IsCustomDiag(DiagID)); + const auto &Diag = CustomDiagInfo->getDescription(DiagID); + if (auto Group = Diag.GetGroup()) { + GroupInfo GroupInfo = GroupInfos[static_cast<size_t>(*Group)]; + if (static_cast<diag::Severity>(GroupInfo.Severity) != diag::Severity()) + Mapping.setSeverity(static_cast<diag::Severity>(GroupInfo.Severity)); + Mapping.setNoWarningAsError(GroupInfo.HasNoWarningAsError); + } else { + Mapping.setSeverity(Diag.GetDefaultSeverity()); + Mapping.setNoWarningAsError(true); + Mapping.setNoErrorAsFatal(true); + } +} + /// getCategoryNumberForDiag - Return the category number that a specified /// DiagID belongs to, or 0 if no category. unsigned DiagnosticIDs::getCategoryNumberForDiag(unsigned DiagID) { @@ -303,61 +367,6 @@ bool DiagnosticIDs::isDeferrable(unsigned DiagID) { return false; } -/// getBuiltinDiagClass - Return the class field of the diagnostic. -/// -static unsigned getBuiltinDiagClass(unsigned DiagID) { - if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID)) - return Info->Class; - return ~0U; -} - -//===----------------------------------------------------------------------===// -// Custom Diagnostic information -//===----------------------------------------------------------------------===// - -namespace clang { - namespace diag { - class CustomDiagInfo { - typedef std::pair<DiagnosticIDs::Level, std::string> DiagDesc; - std::vector<DiagDesc> DiagInfo; - std::map<DiagDesc, unsigned> DiagIDs; - public: - - /// getDescription - Return the description of the specified custom - /// diagnostic. - StringRef getDescription(unsigned DiagID) const { - assert(DiagID - DIAG_UPPER_LIMIT < DiagInfo.size() && - "Invalid diagnostic ID"); - return DiagInfo[DiagID-DIAG_UPPER_LIMIT].second; - } - - /// getLevel - Return the level of the specified custom diagnostic. - DiagnosticIDs::Level getLevel(unsigned DiagID) const { - assert(DiagID - DIAG_UPPER_LIMIT < DiagInfo.size() && - "Invalid diagnostic ID"); - return DiagInfo[DiagID-DIAG_UPPER_LIMIT].first; - } - - unsigned getOrCreateDiagID(DiagnosticIDs::Level L, StringRef Message, - DiagnosticIDs &Diags) { - DiagDesc D(L, std::string(Message)); - // Check to see if it already exists. - std::map<DiagDesc, unsigned>::iterator I = DiagIDs.lower_bound(D); - if (I != DiagIDs.end() && I->first == D) - return I->second; - - // If not, assign a new ID. - unsigned ID = DiagInfo.size()+DIAG_UPPER_LIMIT; - DiagIDs.insert(std::make_pair(D, ID)); - DiagInfo.push_back(D); - return ID; - } - }; - - } // end diag namespace -} // end clang namespace - - //===----------------------------------------------------------------------===// // Common Diagnostic implementation //===----------------------------------------------------------------------===// @@ -372,38 +381,32 @@ DiagnosticIDs::~DiagnosticIDs() {} /// /// \param FormatString A fixed diagnostic format string that will be hashed and /// mapped to a unique DiagID. -unsigned DiagnosticIDs::getCustomDiagID(Level L, StringRef FormatString) { +unsigned DiagnosticIDs::getCustomDiagID(CustomDiagDesc Diag) { if (!CustomDiagInfo) CustomDiagInfo.reset(new diag::CustomDiagInfo()); - return CustomDiagInfo->getOrCreateDiagID(L, FormatString, *this); + return CustomDiagInfo->getOrCreateDiagID(Diag); } - -/// isBuiltinWarningOrExtension - Return true if the unmapped diagnostic -/// level of the specified diagnostic ID is a Warning or Extension. -/// This only works on builtin diagnostics, not custom ones, and is not legal to -/// call on NOTEs. -bool DiagnosticIDs::isBuiltinWarningOrExtension(unsigned DiagID) { - return DiagID < diag::DIAG_UPPER_LIMIT && - getBuiltinDiagClass(DiagID) != CLASS_ERROR; +bool DiagnosticIDs::isWarningOrExtension(unsigned DiagID) const { + return DiagID < diag::DIAG_UPPER_LIMIT + ? getDiagClass(DiagID) != CLASS_ERROR + : CustomDiagInfo->getDescription(DiagID).GetClass() != CLASS_ERROR; } /// Determine whether the given built-in diagnostic ID is a /// Note. -bool DiagnosticIDs::isBuiltinNote(unsigned DiagID) { - return DiagID < diag::DIAG_UPPER_LIMIT && - getBuiltinDiagClass(DiagID) == CLASS_NOTE; +bool DiagnosticIDs::isNote(unsigned DiagID) const { + return DiagID < diag::DIAG_UPPER_LIMIT && getDiagClass(DiagID) == CLASS_NOTE; } -/// isBuiltinExtensionDiag - Determine whether the given built-in diagnostic +/// isExtensionDiag - Determine whether the given built-in diagnostic /// ID is for an extension of some sort. This also returns EnabledByDefault, /// which is set to indicate whether the diagnostic is ignored by default (in /// which case -pedantic enables it) or treated as a warning/error by default. /// -bool DiagnosticIDs::isBuiltinExtensionDiag(unsigned DiagID, - bool &EnabledByDefault) { - if (DiagID >= diag::DIAG_UPPER_LIMIT || - getBuiltinDiagClass(DiagID) != CLASS_EXTENSION) +bool DiagnosticIDs::isExtensionDiag(unsigned DiagID, + bool &EnabledByDefault) const { + if (IsCustomDiag(DiagID) || getDiagClass(DiagID) != CLASS_EXTENSION) return false; EnabledByDefault = @@ -411,10 +414,7 @@ bool DiagnosticIDs::isBuiltinExtensionDiag(unsigned DiagID, return true; } -bool DiagnosticIDs::isDefaultMappingAsError(unsigned DiagID) { - if (DiagID >= diag::DIAG_UPPER_LIMIT) - return false; - +bool DiagnosticIDs::isDefaultMappingAsError(unsigned DiagID) const { return getDefaultMapping(DiagID).getSeverity() >= diag::Severity::Error; } @@ -424,7 +424,7 @@ StringRef DiagnosticIDs::getDescription(unsigned DiagID) const { if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID)) return Info->getDescription(); assert(CustomDiagInfo && "Invalid CustomDiagInfo"); - return CustomDiagInfo->getDescription(DiagID); + return CustomDiagInfo->getDescription(DiagID).GetDescription(); } static DiagnosticIDs::Level toLevel(diag::Severity SV) { @@ -449,13 +449,7 @@ static DiagnosticIDs::Level toLevel(diag::Severity SV) { DiagnosticIDs::Level DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, SourceLocation Loc, const DiagnosticsEngine &Diag) const { - // Handle custom diagnostics, which cannot be mapped. - if (DiagID >= diag::DIAG_UPPER_LIMIT) { - assert(CustomDiagInfo && "Invalid CustomDiagInfo"); - return CustomDiagInfo->getLevel(DiagID); - } - - unsigned DiagClass = getBuiltinDiagClass(DiagID); + unsigned DiagClass = getDiagClass(DiagID); if (DiagClass == CLASS_NOTE) return DiagnosticIDs::Note; return toLevel(getDiagnosticSeverity(DiagID, Loc, Diag)); } @@ -469,7 +463,8 @@ DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, SourceLocation Loc, diag::Severity DiagnosticIDs::getDiagnosticSeverity(unsigned DiagID, SourceLocation Loc, const DiagnosticsEngine &Diag) const { - assert(getBuiltinDiagClass(DiagID) != CLASS_NOTE); + bool IsCustomDiag = DiagnosticIDs::IsCustomDiag(DiagID); + assert(getDiagClass(DiagID) != CLASS_NOTE); // Specific non-error diagnostics may be mapped to various levels from ignored // to error. Errors can only be mapped to fatal. @@ -477,7 +472,7 @@ DiagnosticIDs::getDiagnosticSeverity(unsigned DiagID, SourceLocation Loc, // Get the mapping information, or compute it lazily. DiagnosticsEngine::DiagState *State = Diag.GetDiagStateForLoc(Loc); - DiagnosticMapping &Mapping = State->getOrAddMapping((diag::kind)DiagID); + DiagnosticMapping Mapping = State->getOrAddMapping((diag::kind)DiagID); // TODO: Can a null severity really get here? if (Mapping.getSeverity() != diag::Severity()) @@ -485,14 +480,15 @@ DiagnosticIDs::getDiagnosticSeverity(unsigned DiagID, SourceLocation Loc, // Upgrade ignored diagnostics if -Weverything is enabled. if (State->EnableAllWarnings && Result == diag::Severity::Ignored && - !Mapping.isUser() && getBuiltinDiagClass(DiagID) != CLASS_REMARK) + !Mapping.isUser() && + (IsCustomDiag || getDiagClass(DiagID) != CLASS_REMARK)) Result = diag::Severity::Warning; // Ignore -pedantic diagnostics inside __extension__ blocks. // (The diagnostics controlled by -pedantic are the extension diagnostics // that are not enabled by default.) bool EnabledByDefault = false; - bool IsExtensionDiag = isBuiltinExtensionDiag(DiagID, EnabledByDefault); + bool IsExtensionDiag = isExtensionDiag(DiagID, EnabledByDefault); if (Diag.AllExtensionsSilenced && IsExtensionDiag && !EnabledByDefault) return diag::Severity::Ignored; @@ -510,10 +506,12 @@ DiagnosticIDs::getDiagnosticSeverity(unsigned DiagID, SourceLocation Loc, // as well as disabling all messages which are currently mapped to Warning // (whether by default or downgraded from Error via e.g. -Wno-error or #pragma // diagnostic.) + // FIXME: Should -w be ignored for custom warnings without a group? if (State->IgnoreAllWarnings) { - if (Result == diag::Severity::Warning || - (Result >= diag::Severity::Error && - !isDefaultMappingAsError((diag::kind)DiagID))) + if ((!IsCustomDiag || CustomDiagInfo->getDescription(DiagID).GetGroup()) && + (Result == diag::Severity::Warning || + (Result >= diag::Severity::Error && + !isDefaultMappingAsError((diag::kind)DiagID)))) return diag::Severity::Ignored; } @@ -541,9 +539,11 @@ DiagnosticIDs::getDiagnosticSeverity(unsigned DiagID, SourceLocation Loc, return Result; const auto &SM = Diag.getSourceManager(); - // Custom diagnostics always are emitted in system headers. + bool ShowInSystemHeader = - !GetDiagInfo(DiagID) || GetDiagInfo(DiagID)->WarnShowInSystemHeader; + IsCustomDiag + ? CustomDiagInfo->getDescription(DiagID).ShouldShowInSystemHeader() + : !GetDiagInfo(DiagID) || GetDiagInfo(DiagID)->WarnShowInSystemHeader; // If we are in a system header, we ignore it. We look at the diagnostic class // because we also want to ignore extensions and warnings in -Werror and @@ -566,6 +566,15 @@ DiagnosticIDs::getDiagnosticSeverity(unsigned DiagID, SourceLocation Loc, return Result; } +DiagnosticIDs::Class DiagnosticIDs::getDiagClass(unsigned DiagID) const { + if (IsCustomDiag(DiagID)) + return Class(CustomDiagInfo->getDescription(DiagID).GetClass()); + + if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID)) + return Class(Info->Class); + return CLASS_INVALID; +} + #define GET_DIAG_ARRAYS #include "clang/Basic/DiagnosticGroups.inc" #undef GET_DIAG_ARRAYS @@ -607,7 +616,12 @@ DiagnosticIDs::getGroupForWarningOption(StringRef Name) { return static_cast<diag::Group>(Found - OptionTable); } -std::optional<diag::Group> DiagnosticIDs::getGroupForDiag(unsigned DiagID) { +std::optional<diag::Group> +DiagnosticIDs::getGroupForDiag(unsigned DiagID) const { + if (IsCustomDiag(DiagID)) { + assert(CustomDiagInfo); + return CustomDiagInfo->getDescription(DiagID).GetGroup(); + } if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID)) return static_cast<diag::Group>(Info->getOptionGroupIndex()); return std::nullopt; @@ -639,7 +653,8 @@ std::vector<std::string> DiagnosticIDs::getDiagnosticFlags() { /// were filtered out due to having the wrong flavor. static bool getDiagnosticsInGroup(diag::Flavor Flavor, const WarningOption *Group, - SmallVectorImpl<diag::kind> &Diags) { + SmallVectorImpl<diag::kind> &Diags, + diag::CustomDiagInfo *CustomDiagInfo) { // An empty group is considered to be a warning group: we have empty groups // for GCC compatibility, and GCC does not have remarks. if (!Group->Members && !Group->SubGroups) @@ -658,9 +673,14 @@ static bool getDiagnosticsInGroup(diag::Flavor Flavor, // Add the members of the subgroups. const int16_t *SubGroups = DiagSubGroups + Group->SubGroups; - for (; *SubGroups != (int16_t)-1; ++SubGroups) + for (; *SubGroups != (int16_t)-1; ++SubGroups) { + if (CustomDiagInfo) + llvm::copy( + CustomDiagInfo->getDiagsInGroup(static_cast<diag::Group>(*SubGroups)), + std::back_inserter(Diags)); NotFound &= getDiagnosticsInGroup(Flavor, &OptionTable[(short)*SubGroups], - Diags); + Diags, CustomDiagInfo); + } return NotFound; } @@ -668,12 +688,49 @@ static bool getDiagnosticsInGroup(diag::Flavor Flavor, bool DiagnosticIDs::getDiagnosticsInGroup(diag::Flavor Flavor, StringRef Group, SmallVectorImpl<diag::kind> &Diags) const { - if (std::optional<diag::Group> G = getGroupForWarningOption(Group)) - return ::getDiagnosticsInGroup( - Flavor, &OptionTable[static_cast<unsigned>(*G)], Diags); + if (std::optional<diag::Group> G = getGroupForWarningOption(Group)) { + if (CustomDiagInfo) + llvm::copy(CustomDiagInfo->getDiagsInGroup(*G), + std::back_inserter(Diags)); + return ::getDiagnosticsInGroup(Flavor, + &OptionTable[static_cast<unsigned>(*G)], + Diags, CustomDiagInfo.get()); + } return true; } +template <class Func> +static void forEachSubGroupImpl(const WarningOption *Group, Func func) { + for (const int16_t *SubGroups = DiagSubGroups + Group->SubGroups; + *SubGroups != -1; ++SubGroups) { + func(static_cast<size_t>(*SubGroups)); + forEachSubGroupImpl(&OptionTable[*SubGroups], std::move(func)); + } +} + +template <class Func> +static void forEachSubGroup(diag::Group Group, Func func) { + const WarningOption *WarningOpt = &OptionTable[static_cast<size_t>(Group)]; + func(static_cast<size_t>(Group)); + ::forEachSubGroupImpl(WarningOpt, std::move(func)); +} + +void DiagnosticIDs::setGroupSeverity(StringRef Group, diag::Severity Sev) { + if (std::optional<diag::Group> G = getGroupForWarningOption(Group)) { + ::forEachSubGroup(*G, [&](size_t SubGroup) { + GroupInfos[SubGroup].Severity = static_cast<unsigned>(Sev); + }); + } +} + +void DiagnosticIDs::setGroupNoWarningsAsError(StringRef Group, bool Val) { + if (std::optional<diag::Group> G = getGroupForWarningOption(Group)) { + ::forEachSubGroup(*G, [&](size_t SubGroup) { + GroupInfos[static_cast<size_t>(*G)].HasNoWarningAsError = Val; + }); + } +} + void DiagnosticIDs::getAllDiagnostics(diag::Flavor Flavor, std::vector<diag::kind> &Diags) { for (unsigned i = 0; i != StaticDiagInfoSize; ++i) @@ -696,7 +753,7 @@ StringRef DiagnosticIDs::getNearestOption(diag::Flavor Flavor, // Don't suggest groups that are not of this kind. llvm::SmallVector<diag::kind, 8> Diags; - if (::getDiagnosticsInGroup(Flavor, &O, Diags) || Diags.empty()) + if (::getDiagnosticsInGroup(Flavor, &O, Diags, nullptr) || Diags.empty()) continue; if (Distance == BestDistance) { @@ -810,14 +867,8 @@ void DiagnosticIDs::EmitDiag(DiagnosticsEngine &Diag, } bool DiagnosticIDs::isUnrecoverable(unsigned DiagID) const { - if (DiagID >= diag::DIAG_UPPER_LIMIT) { - assert(CustomDiagInfo && "Invalid CustomDiagInfo"); - // Custom diagnostics. - return CustomDiagInfo->getLevel(DiagID) >= DiagnosticIDs::Error; - } - // Only errors may be unrecoverable. - if (getBuiltinDiagClass(DiagID) < CLASS_ERROR) + if (getDiagClass(DiagID) < CLASS_ERROR) return false; if (DiagID == diag::err_unavailable || diff --git clang/lib/Basic/Targets/ARM.cpp clang/lib/Basic/Targets/ARM.cpp index 0fd5433a7640..5aa2baeb81b7 100644 --- clang/lib/Basic/Targets/ARM.cpp +++ clang/lib/Basic/Targets/ARM.cpp @@ -608,6 +608,8 @@ bool ARMTargetInfo::handleTargetFeatures(std::vector<std::string> &Features, HasBTI = 1; } else if (Feature == "+fullbf16") { HasFullBFloat16 = true; + } else if (Feature == "+execute-only") { + TLSSupported = false; } } diff --git clang/lib/Basic/Targets/Hexagon.cpp clang/lib/Basic/Targets/Hexagon.cpp index b5e06b679ece..2e173e01ed8e 100644 --- clang/lib/Basic/Targets/Hexagon.cpp +++ clang/lib/Basic/Targets/Hexagon.cpp @@ -211,7 +211,7 @@ static constexpr Builtin::Info BuiltinInfo[] = { {#ID, TYPE, ATTRS, nullptr, HEADER, ALL_LANGUAGES}, #define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, -#include "clang/Basic/BuiltinsHexagon.def" +#include "clang/Basic/BuiltinsHexagon.inc" }; bool HexagonTargetInfo::hasFeature(StringRef Feature) const { diff --git clang/lib/Basic/Targets/NVPTX.cpp clang/lib/Basic/Targets/NVPTX.cpp index 56efad90cb7c..a03f4983b9d0 100644 --- clang/lib/Basic/Targets/NVPTX.cpp +++ clang/lib/Basic/Targets/NVPTX.cpp @@ -21,13 +21,9 @@ using namespace clang; using namespace clang::targets; static constexpr Builtin::Info BuiltinInfo[] = { -#define BUILTIN(ID, TYPE, ATTRS) \ - {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, -#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \ - {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES}, #define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, -#include "clang/Basic/BuiltinsNVPTX.def" +#include "clang/Basic/BuiltinsNVPTX.inc" }; const char *const NVPTXTargetInfo::GCCRegNames[] = {"r0"}; diff --git clang/lib/Basic/Targets/OSTargets.cpp clang/lib/Basic/Targets/OSTargets.cpp index bf10f9a72556..8af6623e5cb1 100644 --- clang/lib/Basic/Targets/OSTargets.cpp +++ clang/lib/Basic/Targets/OSTargets.cpp @@ -259,8 +259,10 @@ static void addVisualCDefines(const LangOptions &Opts, MacroBuilder &Builder) { Builder.defineMacro("_KERNEL_MODE"); Builder.defineMacro("_INTEGRAL_MAX_BITS", "64"); - Builder.defineMacro("__STDC_NO_THREADS__"); - + // Define __STDC_NO_THREADS__ based on MSVC version, threads.h availability, + // and language standard. + if (!(Opts.isCompatibleWithMSVC(LangOptions::MSVC2022_9) && Opts.C11)) + Builder.defineMacro("__STDC_NO_THREADS__"); // Starting with VS 2022 17.1, MSVC predefines the below macro to inform // users of the execution character set defined at compile time. // The value given is the Windows Code Page Identifier: diff --git clang/lib/CMakeLists.txt clang/lib/CMakeLists.txt index 14ba55360fe0..4f2218b583e4 100644 --- clang/lib/CMakeLists.txt +++ clang/lib/CMakeLists.txt @@ -12,9 +12,6 @@ add_subdirectory(Analysis) add_subdirectory(Edit) add_subdirectory(ExtractAPI) add_subdirectory(Rewrite) -if(CLANG_ENABLE_ARCMT) - add_subdirectory(ARCMigrate) -endif() add_subdirectory(Driver) add_subdirectory(Serialization) add_subdirectory(Frontend) diff --git clang/lib/CodeGen/CGBuiltin.cpp clang/lib/CodeGen/CGBuiltin.cpp index 26bccccdc5e3..7ec9d59bfed5 100644 --- clang/lib/CodeGen/CGBuiltin.cpp +++ clang/lib/CodeGen/CGBuiltin.cpp @@ -6679,6 +6679,7 @@ static llvm::FixedVectorType *GetNeonType(CodeGenFunction *CGF, switch (TypeFlags.getEltType()) { case NeonTypeFlags::Int8: case NeonTypeFlags::Poly8: + case NeonTypeFlags::MFloat8: return llvm::FixedVectorType::get(CGF->Int8Ty, V1Ty ? 1 : (8 << IsQuad)); case NeonTypeFlags::Int16: case NeonTypeFlags::Poly16: @@ -6758,12 +6759,68 @@ Value *CodeGenFunction::EmitNeonCall(Function *F, SmallVectorImpl<Value*> &Ops, return Builder.CreateCall(F, Ops, name); } +Value *CodeGenFunction::EmitFP8NeonCall(unsigned IID, + ArrayRef<llvm::Type *> Tys, + SmallVectorImpl<Value *> &Ops, + const CallExpr *E, const char *name) { + llvm::Value *FPM = + EmitScalarOrConstFoldImmArg(/* ICEArguments */ 0, E->getNumArgs() - 1, E); + Builder.CreateCall(CGM.getIntrinsic(Intrinsic::aarch64_set_fpmr), FPM); + return EmitNeonCall(CGM.getIntrinsic(IID, Tys), Ops, name); +} + +llvm::Value *CodeGenFunction::EmitFP8NeonFDOTCall( + unsigned IID, bool ExtendLaneArg, llvm::Type *RetTy, + SmallVectorImpl<llvm::Value *> &Ops, const CallExpr *E, const char *name) { + + const unsigned ElemCount = Ops[0]->getType()->getPrimitiveSizeInBits() / + RetTy->getPrimitiveSizeInBits(); + llvm::Type *Tys[] = {llvm::FixedVectorType::get(RetTy, ElemCount), + Ops[1]->getType()}; + if (ExtendLaneArg) { + auto *VT = llvm::FixedVectorType::get(Int8Ty, 16); + Ops[2] = Builder.CreateInsertVector(VT, PoisonValue::get(VT), Ops[2], + Builder.getInt64(0)); + } + return EmitFP8NeonCall(IID, Tys, Ops, E, name); +} + +llvm::Value *CodeGenFunction::EmitFP8NeonFMLACall( + unsigned IID, bool ExtendLaneArg, llvm::Type *RetTy, + SmallVectorImpl<llvm::Value *> &Ops, const CallExpr *E, const char *name) { + + if (ExtendLaneArg) { + auto *VT = llvm::FixedVectorType::get(Int8Ty, 16); + Ops[2] = Builder.CreateInsertVector(VT, PoisonValue::get(VT), Ops[2], + Builder.getInt64(0)); + } + const unsigned ElemCount = Ops[0]->getType()->getPrimitiveSizeInBits() / + RetTy->getPrimitiveSizeInBits(); + return EmitFP8NeonCall(IID, {llvm::FixedVectorType::get(RetTy, ElemCount)}, + Ops, E, name); +} + Value *CodeGenFunction::EmitNeonShiftVector(Value *V, llvm::Type *Ty, bool neg) { int SV = cast<ConstantInt>(V)->getSExtValue(); return ConstantInt::get(Ty, neg ? -SV : SV); } +Value *CodeGenFunction::EmitFP8NeonCvtCall(unsigned IID, llvm::Type *Ty0, + llvm::Type *Ty1, bool Extract, + SmallVectorImpl<llvm::Value *> &Ops, + const CallExpr *E, + const char *name) { + llvm::Type *Tys[] = {Ty0, Ty1}; + if (Extract) { + // Op[0] is mfloat8x16_t, but the intrinsic converts only the lower part of + // the vector. + Tys[1] = llvm::FixedVectorType::get(Int8Ty, 8); + Ops[0] = Builder.CreateExtractVector(Tys[1], Ops[0], Builder.getInt64(0)); + } + return EmitFP8NeonCall(IID, Tys, Ops, E, name); +} + // Right-shift a vector by a constant. Value *CodeGenFunction::EmitNeonRShiftImm(Value *Vec, Value *Shift, llvm::Type *Ty, bool usgn, @@ -12735,6 +12792,8 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID, return V; unsigned Int; + bool ExtractLow = false; + bool ExtendLaneArg = false; switch (BuiltinID) { default: return nullptr; case NEON::BI__builtin_neon_vbsl_v: @@ -13949,7 +14008,145 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID, Int = Intrinsic::aarch64_neon_vluti4q_laneq_x2; return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vluti4q_laneq_x2"); } - + case NEON::BI__builtin_neon_vcvt1_low_bf16_mf8_fpm: + ExtractLow = true; + LLVM_FALLTHROUGH; + case NEON::BI__builtin_neon_vcvt1_bf16_mf8_fpm: + case NEON::BI__builtin_neon_vcvt1_high_bf16_mf8_fpm: + return EmitFP8NeonCvtCall(Intrinsic::aarch64_neon_fp8_cvtl1, + llvm::FixedVectorType::get(BFloatTy, 8), + Ops[0]->getType(), ExtractLow, Ops, E, "vbfcvt1"); + case NEON::BI__builtin_neon_vcvt2_low_bf16_mf8_fpm: + ExtractLow = true; + LLVM_FALLTHROUGH; + case NEON::BI__builtin_neon_vcvt2_bf16_mf8_fpm: + case NEON::BI__builtin_neon_vcvt2_high_bf16_mf8_fpm: + return EmitFP8NeonCvtCall(Intrinsic::aarch64_neon_fp8_cvtl2, + llvm::FixedVectorType::get(BFloatTy, 8), + Ops[0]->getType(), ExtractLow, Ops, E, "vbfcvt2"); + case NEON::BI__builtin_neon_vcvt1_low_f16_mf8_fpm: + ExtractLow = true; + LLVM_FALLTHROUGH; + case NEON::BI__builtin_neon_vcvt1_f16_mf8_fpm: + case NEON::BI__builtin_neon_vcvt1_high_f16_mf8_fpm: + return EmitFP8NeonCvtCall(Intrinsic::aarch64_neon_fp8_cvtl1, + llvm::FixedVectorType::get(HalfTy, 8), + Ops[0]->getType(), ExtractLow, Ops, E, "vbfcvt1"); + case NEON::BI__builtin_neon_vcvt2_low_f16_mf8_fpm: + ExtractLow = true; + LLVM_FALLTHROUGH; + case NEON::BI__builtin_neon_vcvt2_f16_mf8_fpm: + case NEON::BI__builtin_neon_vcvt2_high_f16_mf8_fpm: + return EmitFP8NeonCvtCall(Intrinsic::aarch64_neon_fp8_cvtl2, + llvm::FixedVectorType::get(HalfTy, 8), + Ops[0]->getType(), ExtractLow, Ops, E, "vbfcvt2"); + case NEON::BI__builtin_neon_vcvt_mf8_f32_fpm: + return EmitFP8NeonCvtCall(Intrinsic::aarch64_neon_fp8_fcvtn, + llvm::FixedVectorType::get(Int8Ty, 8), + Ops[0]->getType(), false, Ops, E, "vfcvtn"); + case NEON::BI__builtin_neon_vcvt_mf8_f16_fpm: + return EmitFP8NeonCvtCall(Intrinsic::aarch64_neon_fp8_fcvtn, + llvm::FixedVectorType::get(Int8Ty, 8), + llvm::FixedVectorType::get(HalfTy, 4), false, Ops, + E, "vfcvtn"); + case NEON::BI__builtin_neon_vcvtq_mf8_f16_fpm: + return EmitFP8NeonCvtCall(Intrinsic::aarch64_neon_fp8_fcvtn, + llvm::FixedVectorType::get(Int8Ty, 16), + llvm::FixedVectorType::get(HalfTy, 8), false, Ops, + E, "vfcvtn"); + case NEON::BI__builtin_neon_vcvt_high_mf8_f32_fpm: { + llvm::Type *Ty = llvm::FixedVectorType::get(Int8Ty, 16); + Ops[0] = Builder.CreateInsertVector(Ty, PoisonValue::get(Ty), Ops[0], + Builder.getInt64(0)); + return EmitFP8NeonCvtCall(Intrinsic::aarch64_neon_fp8_fcvtn2, Ty, + Ops[1]->getType(), false, Ops, E, "vfcvtn2"); + } + + case NEON::BI__builtin_neon_vdot_f16_mf8_fpm: + case NEON::BI__builtin_neon_vdotq_f16_mf8_fpm: + return EmitFP8NeonFDOTCall(Intrinsic::aarch64_neon_fp8_fdot2, false, HalfTy, + Ops, E, "fdot2"); + case NEON::BI__builtin_neon_vdot_lane_f16_mf8_fpm: + case NEON::BI__builtin_neon_vdotq_lane_f16_mf8_fpm: + ExtendLaneArg = true; + LLVM_FALLTHROUGH; + case NEON::BI__builtin_neon_vdot_laneq_f16_mf8_fpm: + case NEON::BI__builtin_neon_vdotq_laneq_f16_mf8_fpm: + return EmitFP8NeonFDOTCall(Intrinsic::aarch64_neon_fp8_fdot2_lane, + ExtendLaneArg, HalfTy, Ops, E, "fdot2_lane"); + case NEON::BI__builtin_neon_vdot_f32_mf8_fpm: + case NEON::BI__builtin_neon_vdotq_f32_mf8_fpm: + return EmitFP8NeonFDOTCall(Intrinsic::aarch64_neon_fp8_fdot4, false, + FloatTy, Ops, E, "fdot4"); + case NEON::BI__builtin_neon_vdot_lane_f32_mf8_fpm: + case NEON::BI__builtin_neon_vdotq_lane_f32_mf8_fpm: + ExtendLaneArg = true; + LLVM_FALLTHROUGH; + case NEON::BI__builtin_neon_vdot_laneq_f32_mf8_fpm: + case NEON::BI__builtin_neon_vdotq_laneq_f32_mf8_fpm: + return EmitFP8NeonFDOTCall(Intrinsic::aarch64_neon_fp8_fdot4_lane, + ExtendLaneArg, FloatTy, Ops, E, "fdot4_lane"); + + case NEON::BI__builtin_neon_vmlalbq_f16_mf8_fpm: + return EmitFP8NeonCall(Intrinsic::aarch64_neon_fp8_fmlalb, + {llvm::FixedVectorType::get(HalfTy, 8)}, Ops, E, + "vmlal"); + case NEON::BI__builtin_neon_vmlaltq_f16_mf8_fpm: + return EmitFP8NeonCall(Intrinsic::aarch64_neon_fp8_fmlalt, + {llvm::FixedVectorType::get(HalfTy, 8)}, Ops, E, + "vmlal"); + case NEON::BI__builtin_neon_vmlallbbq_f32_mf8_fpm: + return EmitFP8NeonCall(Intrinsic::aarch64_neon_fp8_fmlallbb, + {llvm::FixedVectorType::get(FloatTy, 4)}, Ops, E, + "vmlall"); + case NEON::BI__builtin_neon_vmlallbtq_f32_mf8_fpm: + return EmitFP8NeonCall(Intrinsic::aarch64_neon_fp8_fmlallbt, + {llvm::FixedVectorType::get(FloatTy, 4)}, Ops, E, + "vmlall"); + case NEON::BI__builtin_neon_vmlalltbq_f32_mf8_fpm: + return EmitFP8NeonCall(Intrinsic::aarch64_neon_fp8_fmlalltb, + {llvm::FixedVectorType::get(FloatTy, 4)}, Ops, E, + "vmlall"); + case NEON::BI__builtin_neon_vmlallttq_f32_mf8_fpm: + return EmitFP8NeonCall(Intrinsic::aarch64_neon_fp8_fmlalltt, + {llvm::FixedVectorType::get(FloatTy, 4)}, Ops, E, + "vmlall"); + case NEON::BI__builtin_neon_vmlalbq_lane_f16_mf8_fpm: + ExtendLaneArg = true; + LLVM_FALLTHROUGH; + case NEON::BI__builtin_neon_vmlalbq_laneq_f16_mf8_fpm: + return EmitFP8NeonFMLACall(Intrinsic::aarch64_neon_fp8_fmlalb_lane, + ExtendLaneArg, HalfTy, Ops, E, "vmlal_lane"); + case NEON::BI__builtin_neon_vmlaltq_lane_f16_mf8_fpm: + ExtendLaneArg = true; + LLVM_FALLTHROUGH; + case NEON::BI__builtin_neon_vmlaltq_laneq_f16_mf8_fpm: + return EmitFP8NeonFMLACall(Intrinsic::aarch64_neon_fp8_fmlalt_lane, + ExtendLaneArg, HalfTy, Ops, E, "vmlal_lane"); + case NEON::BI__builtin_neon_vmlallbbq_lane_f32_mf8_fpm: + ExtendLaneArg = true; + LLVM_FALLTHROUGH; + case NEON::BI__builtin_neon_vmlallbbq_laneq_f32_mf8_fpm: + return EmitFP8NeonFMLACall(Intrinsic::aarch64_neon_fp8_fmlallbb_lane, + ExtendLaneArg, FloatTy, Ops, E, "vmlall_lane"); + case NEON::BI__builtin_neon_vmlallbtq_lane_f32_mf8_fpm: + ExtendLaneArg = true; + LLVM_FALLTHROUGH; + case NEON::BI__builtin_neon_vmlallbtq_laneq_f32_mf8_fpm: + return EmitFP8NeonFMLACall(Intrinsic::aarch64_neon_fp8_fmlallbt_lane, + ExtendLaneArg, FloatTy, Ops, E, "vmlall_lane"); + case NEON::BI__builtin_neon_vmlalltbq_lane_f32_mf8_fpm: + ExtendLaneArg = true; + LLVM_FALLTHROUGH; + case NEON::BI__builtin_neon_vmlalltbq_laneq_f32_mf8_fpm: + return EmitFP8NeonFMLACall(Intrinsic::aarch64_neon_fp8_fmlalltb_lane, + ExtendLaneArg, FloatTy, Ops, E, "vmlall_lane"); + case NEON::BI__builtin_neon_vmlallttq_lane_f32_mf8_fpm: + ExtendLaneArg = true; + LLVM_FALLTHROUGH; + case NEON::BI__builtin_neon_vmlallttq_laneq_f32_mf8_fpm: + return EmitFP8NeonFMLACall(Intrinsic::aarch64_neon_fp8_fmlalltt_lane, + ExtendLaneArg, FloatTy, Ops, E, "vmlall_lane"); case NEON::BI__builtin_neon_vamin_f16: case NEON::BI__builtin_neon_vaminq_f16: case NEON::BI__builtin_neon_vamin_f32: @@ -19098,6 +19295,25 @@ static Intrinsic::ID getWaveActiveSumIntrinsic(llvm::Triple::ArchType Arch, } } +// Return wave active sum that corresponds to the QT scalar type +static Intrinsic::ID getWaveActiveMaxIntrinsic(llvm::Triple::ArchType Arch, + CGHLSLRuntime &RT, QualType QT) { + switch (Arch) { + case llvm::Triple::spirv: + if (QT->isUnsignedIntegerType()) + return llvm::Intrinsic::spv_wave_reduce_umax; + return llvm::Intrinsic::spv_wave_reduce_max; + case llvm::Triple::dxil: { + if (QT->isUnsignedIntegerType()) + return llvm::Intrinsic::dx_wave_reduce_umax; + return llvm::Intrinsic::dx_wave_reduce_max; + } + default: + llvm_unreachable("Intrinsic WaveActiveMax" + " not supported by target architecture"); + } +} + Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID, const CallExpr *E, ReturnValueSlot ReturnValue) { @@ -19427,6 +19643,23 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { /*AssumeConvergent=*/true), ArrayRef{OpExpr}, "hlsl.wave.active.sum"); } + case Builtin::BI__builtin_hlsl_wave_active_max: { + // Due to the use of variadic arguments, explicitly retreive argument + Value *OpExpr = EmitScalarExpr(E->getArg(0)); + llvm::FunctionType *FT = llvm::FunctionType::get( + OpExpr->getType(), ArrayRef{OpExpr->getType()}, false); + Intrinsic::ID IID = getWaveActiveMaxIntrinsic( + getTarget().getTriple().getArch(), CGM.getHLSLRuntime(), + E->getArg(0)->getType()); + + // Get overloaded name + std::string Name = + Intrinsic::getName(IID, ArrayRef{OpExpr->getType()}, &CGM.getModule()); + return EmitRuntimeCall(CGM.CreateRuntimeFunction(FT, Name, {}, + /*Local=*/false, + /*AssumeConvergent=*/true), + ArrayRef{OpExpr}, "hlsl.wave.active.max"); + } case Builtin::BI__builtin_hlsl_wave_get_lane_index: { // We don't define a SPIR-V intrinsic, instead it is a SPIR-V built-in // defined in SPIRVBuiltins.td. So instead we manually get the matching name @@ -22051,7 +22284,7 @@ RValue CodeGenFunction::EmitBuiltinAlignTo(const CallExpr *E, bool AlignUp) { // By adding the mask, we ensure that align_up on an already aligned // value will not change the value. if (Args.Src->getType()->isPointerTy()) { - if (getLangOpts().isSignedOverflowDefined()) + if (getLangOpts().PointerOverflowDefined) SrcForMask = Builder.CreateGEP(Int8Ty, SrcForMask, Args.Mask, "over_boundary"); else diff --git clang/lib/CodeGen/CGCUDANV.cpp clang/lib/CodeGen/CGCUDANV.cpp index 23a40b8f7c32..e8d2dca855dd 100644 --- clang/lib/CodeGen/CGCUDANV.cpp +++ clang/lib/CodeGen/CGCUDANV.cpp @@ -1199,11 +1199,14 @@ void CGNVCUDARuntime::transformManagedVars() { void CGNVCUDARuntime::createOffloadingEntries() { SmallVector<char, 32> Out; StringRef Section = (SectionPrefix + "_offloading_entries").toStringRef(Out); + llvm::object::OffloadKind Kind = CGM.getLangOpts().HIP + ? llvm::object::OffloadKind::OFK_HIP + : llvm::object::OffloadKind::OFK_Cuda; llvm::Module &M = CGM.getModule(); for (KernelInfo &I : EmittedKernels) llvm::offloading::emitOffloadingEntry( - M, KernelHandles[I.Kernel->getName()], + M, Kind, KernelHandles[I.Kernel->getName()], getDeviceSideName(cast<NamedDecl>(I.D)), /*Flags=*/0, /*Data=*/0, llvm::offloading::OffloadGlobalEntry, Section); @@ -1221,42 +1224,30 @@ void CGNVCUDARuntime::createOffloadingEntries() { ? static_cast<int32_t>(llvm::offloading::OffloadGlobalNormalized) : 0); if (I.Flags.getKind() == DeviceVarFlags::Variable) { - // TODO: Update the offloading entries struct to avoid this indirection. if (I.Flags.isManaged()) { assert(I.Var->getName().ends_with(".managed") && "HIP managed variables not transformed"); - // Create a struct to contain the two variables. auto *ManagedVar = M.getNamedGlobal( I.Var->getName().drop_back(StringRef(".managed").size())); - llvm::Constant *StructData[] = {ManagedVar, I.Var}; - llvm::Constant *Initializer = llvm::ConstantStruct::get( - llvm::offloading::getManagedTy(M), StructData); - auto *Struct = new llvm::GlobalVariable( - M, llvm::offloading::getManagedTy(M), - /*IsConstant=*/true, llvm::GlobalValue::PrivateLinkage, Initializer, - I.Var->getName(), /*InsertBefore=*/nullptr, - llvm::GlobalVariable::NotThreadLocal, - M.getDataLayout().getDefaultGlobalsAddressSpace()); - llvm::offloading::emitOffloadingEntry( - M, Struct, getDeviceSideName(I.D), VarSize, + M, Kind, I.Var, getDeviceSideName(I.D), VarSize, llvm::offloading::OffloadGlobalManagedEntry | Flags, - /*Data=*/static_cast<uint32_t>(I.Var->getAlignment()), Section); + /*Data=*/I.Var->getAlignment(), Section, ManagedVar); } else { llvm::offloading::emitOffloadingEntry( - M, I.Var, getDeviceSideName(I.D), VarSize, + M, Kind, I.Var, getDeviceSideName(I.D), VarSize, llvm::offloading::OffloadGlobalEntry | Flags, /*Data=*/0, Section); } } else if (I.Flags.getKind() == DeviceVarFlags::Surface) { llvm::offloading::emitOffloadingEntry( - M, I.Var, getDeviceSideName(I.D), VarSize, + M, Kind, I.Var, getDeviceSideName(I.D), VarSize, llvm::offloading::OffloadGlobalSurfaceEntry | Flags, I.Flags.getSurfTexType(), Section); } else if (I.Flags.getKind() == DeviceVarFlags::Texture) { llvm::offloading::emitOffloadingEntry( - M, I.Var, getDeviceSideName(I.D), VarSize, + M, Kind, I.Var, getDeviceSideName(I.D), VarSize, llvm::offloading::OffloadGlobalTextureEntry | Flags, I.Flags.getSurfTexType(), Section); } diff --git clang/lib/CodeGen/CGCall.cpp clang/lib/CodeGen/CGCall.cpp index e0cf6ca69f0d..2dce86410db8 100644 --- clang/lib/CodeGen/CGCall.cpp +++ clang/lib/CodeGen/CGCall.cpp @@ -2881,7 +2881,7 @@ void CodeGenModule::ConstructAttributeList(StringRef Name, } if (FI.getExtParameterInfo(ArgNo).isNoEscape()) - Attrs.addAttribute(llvm::Attribute::NoCapture); + Attrs.addCapturesAttr(llvm::CaptureInfo::none()); if (Attrs.hasAttributes()) { unsigned FirstIRArg, NumIRArgs; @@ -3581,15 +3581,26 @@ static llvm::StoreInst *findDominatingStoreToReturnValue(CodeGenFunction &CGF) { llvm::BasicBlock *IP = CGF.Builder.GetInsertBlock(); if (IP->empty()) return nullptr; - // Look at directly preceding instruction, skipping bitcasts and lifetime - // markers. + // Look at directly preceding instruction, skipping bitcasts, lifetime + // markers, and fake uses and their operands. + const llvm::Instruction *LoadIntoFakeUse = nullptr; for (llvm::Instruction &I : make_range(IP->rbegin(), IP->rend())) { + // Ignore instructions that are just loads for fake uses; the load should + // immediately precede the fake use, so we only need to remember the + // operand for the last fake use seen. + if (LoadIntoFakeUse == &I) + continue; if (isa<llvm::BitCastInst>(&I)) continue; - if (auto *II = dyn_cast<llvm::IntrinsicInst>(&I)) + if (auto *II = dyn_cast<llvm::IntrinsicInst>(&I)) { if (II->getIntrinsicID() == llvm::Intrinsic::lifetime_end) continue; + if (II->getIntrinsicID() == llvm::Intrinsic::fake_use) { + LoadIntoFakeUse = dyn_cast<llvm::Instruction>(II->getArgOperand(0)); + continue; + } + } return GetStoreIfValid(&I); } return nullptr; diff --git clang/lib/CodeGen/CGCleanup.cpp clang/lib/CodeGen/CGCleanup.cpp index d9c0dbe45d6c..7e1c5b7da955 100644 --- clang/lib/CodeGen/CGCleanup.cpp +++ clang/lib/CodeGen/CGCleanup.cpp @@ -112,11 +112,15 @@ void EHScopeStack::deallocate(size_t Size) { StartOfData += llvm::alignTo(Size, ScopeStackAlignment); } -bool EHScopeStack::containsOnlyLifetimeMarkers( +bool EHScopeStack::containsOnlyNoopCleanups( EHScopeStack::stable_iterator Old) const { for (EHScopeStack::iterator it = begin(); stabilize(it) != Old; it++) { EHCleanupScope *cleanup = dyn_cast<EHCleanupScope>(&*it); - if (!cleanup || !cleanup->isLifetimeMarker()) + // If this is anything other than a lifetime marker or fake use cleanup, + // then the scope stack does not contain only noop cleanups. + if (!cleanup) + return false; + if (!cleanup->isLifetimeMarker() && !cleanup->isFakeUse()) return false; } @@ -154,6 +158,7 @@ void *EHScopeStack::pushCleanup(CleanupKind Kind, size_t Size) { bool IsNormalCleanup = Kind & NormalCleanup; bool IsEHCleanup = Kind & EHCleanup; bool IsLifetimeMarker = Kind & LifetimeMarker; + bool IsFakeUse = Kind & FakeUse; // Per C++ [except.terminate], it is implementation-defined whether none, // some, or all cleanups are called before std::terminate. Thus, when @@ -176,6 +181,8 @@ void *EHScopeStack::pushCleanup(CleanupKind Kind, size_t Size) { InnermostEHScope = stable_begin(); if (IsLifetimeMarker) Scope->setLifetimeMarker(); + if (IsFakeUse) + Scope->setFakeUse(); // With Windows -EHa, Invoke llvm.seh.scope.begin() for EHCleanup // If exceptions are disabled/ignored and SEH is not in use, then there is no diff --git clang/lib/CodeGen/CGCleanup.h clang/lib/CodeGen/CGCleanup.h index c73c97146abc..ba78e5478ac3 100644 --- clang/lib/CodeGen/CGCleanup.h +++ clang/lib/CodeGen/CGCleanup.h @@ -87,6 +87,10 @@ protected: LLVM_PREFERRED_TYPE(bool) unsigned IsLifetimeMarker : 1; + /// Whether this cleanup is a fake use + LLVM_PREFERRED_TYPE(bool) + unsigned IsFakeUse : 1; + /// Whether the normal cleanup should test the activation flag. LLVM_PREFERRED_TYPE(bool) unsigned TestFlagInNormalCleanup : 1; @@ -352,6 +356,7 @@ public: CleanupBits.IsEHCleanup = isEH; CleanupBits.IsActive = true; CleanupBits.IsLifetimeMarker = false; + CleanupBits.IsFakeUse = false; CleanupBits.TestFlagInNormalCleanup = false; CleanupBits.TestFlagInEHCleanup = false; CleanupBits.CleanupSize = cleanupSize; @@ -384,6 +389,9 @@ public: bool isLifetimeMarker() const { return CleanupBits.IsLifetimeMarker; } void setLifetimeMarker() { CleanupBits.IsLifetimeMarker = true; } + bool isFakeUse() const { return CleanupBits.IsFakeUse; } + void setFakeUse() { CleanupBits.IsFakeUse = true; } + bool hasActiveFlag() const { return ActiveFlag.isValid(); } Address getActiveFlag() const { return ActiveFlag; diff --git clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGDebugInfo.cpp index 6cbcaf038441..db595796c067 100644 --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -2815,7 +2815,7 @@ static bool shouldOmitDefinition(llvm::codegenoptions::DebugInfoKind DebugKind, // without any dllimport methods can be used in one DLL and constructed in // another, but it is the current behavior of LimitedDebugInfo. if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass() && - !isClassOrMethodDLLImport(CXXDecl)) + !isClassOrMethodDLLImport(CXXDecl) && !CXXDecl->hasAttr<MSNoVTableAttr>()) return true; TemplateSpecializationKind Spec = TSK_Undeclared; @@ -5083,10 +5083,9 @@ CGDebugInfo::EmitDeclareOfAutoVariable(const VarDecl *VD, llvm::Value *Storage, assert(CGM.getCodeGenOpts().hasReducedDebugInfo()); if (auto *DD = dyn_cast<DecompositionDecl>(VD)) { - for (auto *B : DD->bindings()) { + for (BindingDecl *B : DD->flat_bindings()) EmitDeclare(B, Storage, std::nullopt, Builder, VD->getType()->isReferenceType()); - } // Don't emit an llvm.dbg.declare for the composite storage as it doesn't // correspond to a user variable. return nullptr; diff --git clang/lib/CodeGen/CGDecl.cpp clang/lib/CodeGen/CGDecl.cpp index 60f67d464037..cc6815db4d20 100644 --- clang/lib/CodeGen/CGDecl.cpp +++ clang/lib/CodeGen/CGDecl.cpp @@ -164,9 +164,10 @@ void CodeGenFunction::EmitDecl(const Decl &D) { "Should not see file-scope variables inside a function!"); EmitVarDecl(VD); if (auto *DD = dyn_cast<DecompositionDecl>(&VD)) - for (auto *B : DD->bindings()) + for (auto *B : DD->flat_bindings()) if (auto *HD = B->getHoldingVar()) EmitVarDecl(*HD); + return; } @@ -1355,6 +1356,14 @@ void CodeGenFunction::EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr) { C->setDoesNotThrow(); } +void CodeGenFunction::EmitFakeUse(Address Addr) { + auto NL = ApplyDebugLocation::CreateEmpty(*this); + llvm::Value *V = Builder.CreateLoad(Addr, "fake.use"); + llvm::CallInst *C = Builder.CreateCall(CGM.getLLVMFakeUseFn(), {V}); + C->setDoesNotThrow(); + C->setTailCallKind(llvm::CallInst::TCK_NoTail); +} + void CodeGenFunction::EmitAndRegisterVariableArrayDimensions( CGDebugInfo *DI, const VarDecl &D, bool EmitDebugInfo) { // For each dimension stores its QualType and corresponding @@ -1414,6 +1423,39 @@ void CodeGenFunction::EmitAndRegisterVariableArrayDimensions( } } +/// Return the maximum size of an aggregate for which we generate a fake use +/// intrinsic when -fextend-variable-liveness is in effect. +static uint64_t maxFakeUseAggregateSize(const ASTContext &C) { + return 4 * C.getTypeSize(C.UnsignedIntTy); +} + +// Helper function to determine whether a variable's or parameter's lifetime +// should be extended. +static bool shouldExtendLifetime(const ASTContext &Context, + const Decl *FuncDecl, const VarDecl &D, + ImplicitParamDecl *CXXABIThisDecl) { + // When we're not inside a valid function it is unlikely that any + // lifetime extension is useful. + if (!FuncDecl) + return false; + if (FuncDecl->isImplicit()) + return false; + // Do not extend compiler-created variables except for the this pointer. + if (D.isImplicit() && &D != CXXABIThisDecl) + return false; + QualType Ty = D.getType(); + // No need to extend volatiles, they have a memory location. + if (Ty.isVolatileQualified()) + return false; + // Don't extend variables that exceed a certain size. + if (Context.getTypeSize(Ty) > maxFakeUseAggregateSize(Context)) + return false; + // Do not extend variables in nodebug or optnone functions. + if (FuncDecl->hasAttr<NoDebugAttr>() || FuncDecl->hasAttr<OptimizeNoneAttr>()) + return false; + return true; +} + /// EmitAutoVarAlloca - Emit the alloca and debug information for a /// local variable. Does not emit initialization or destruction. CodeGenFunction::AutoVarEmission @@ -1666,6 +1708,18 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) { emission.getOriginalAllocatedAddress(), emission.getSizeForLifetimeMarkers()); + // Analogous to lifetime markers, we use a 'cleanup' to emit fake.use + // calls for local variables. We are exempting volatile variables and + // non-scalars larger than 4 times the size of an unsigned int. Larger + // non-scalars are often allocated in memory and may create unnecessary + // overhead. + if (CGM.getCodeGenOpts().getExtendVariableLiveness() == + CodeGenOptions::ExtendVariableLivenessKind::All) { + if (shouldExtendLifetime(getContext(), CurCodeDecl, D, CXXABIThisDecl)) + EHStack.pushCleanup<FakeUse>(NormalFakeUse, + emission.getAllocatedAddress()); + } + return emission; } @@ -2532,6 +2586,15 @@ llvm::Function *CodeGenModule::getLLVMLifetimeEndFn() { return LifetimeEndFn; } +/// Lazily declare the @llvm.fake.use intrinsic. +llvm::Function *CodeGenModule::getLLVMFakeUseFn() { + if (FakeUseFn) + return FakeUseFn; + FakeUseFn = llvm::Intrinsic::getOrInsertDeclaration( + &getModule(), llvm::Intrinsic::fake_use); + return FakeUseFn; +} + namespace { /// A cleanup to perform a release of an object at the end of a /// function. This is used to balance out the incoming +1 of a @@ -2725,6 +2788,18 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, ParamValue Arg, setAddrOfLocalVar(&D, DeclPtr); + // Push a FakeUse 'cleanup' object onto the EHStack for the parameter, + // which may be the 'this' pointer. This causes the emission of a fake.use + // call with the parameter as argument at the end of the function. + if (CGM.getCodeGenOpts().getExtendVariableLiveness() == + CodeGenOptions::ExtendVariableLivenessKind::All || + (CGM.getCodeGenOpts().getExtendVariableLiveness() == + CodeGenOptions::ExtendVariableLivenessKind::This && + &D == CXXABIThisDecl)) { + if (shouldExtendLifetime(getContext(), CurCodeDecl, D, CXXABIThisDecl)) + EHStack.pushCleanup<FakeUse>(NormalFakeUse, DeclPtr); + } + // Emit debug info for param declarations in non-thunk functions. if (CGDebugInfo *DI = getDebugInfo()) { if (CGM.getCodeGenOpts().hasReducedDebugInfo() && !CurFuncIsThunk && diff --git clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CGExpr.cpp index 054f8d1eadb8..9676e61cf322 100644 --- clang/lib/CodeGen/CGExpr.cpp +++ clang/lib/CodeGen/CGExpr.cpp @@ -24,6 +24,7 @@ #include "ConstantEmitter.h" #include "TargetInfo.h" #include "clang/AST/ASTContext.h" +#include "clang/AST/ASTLambda.h" #include "clang/AST/Attr.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/NSAPI.h" @@ -1809,8 +1810,7 @@ CodeGenFunction::tryEmitAsConstant(DeclRefExpr *refExpr) { if (CGM.getLangOpts().CUDAIsDevice && result.Val.isLValue() && refExpr->refersToEnclosingVariableOrCapture()) { auto *MD = dyn_cast_or_null<CXXMethodDecl>(CurCodeDecl); - if (MD && MD->getParent()->isLambda() && - MD->getOverloadedOperator() == OO_Call) { + if (isLambdaMethod(MD) && MD->getOverloadedOperator() == OO_Call) { const APValue::LValueBase &base = result.Val.getLValueBase(); if (const ValueDecl *D = base.dyn_cast<const ValueDecl *>()) { if (const VarDecl *VD = dyn_cast<const VarDecl>(D)) { @@ -2414,8 +2414,15 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst, Vec = Builder.CreateBitCast(Vec, IRVecTy); // iN --> <N x i1>. } - Vec = Builder.CreateInsertElement(Vec, Src.getScalarVal(), - Dst.getVectorIdx(), "vecins"); + llvm::Value *SrcVal = Src.getScalarVal(); + // Allow inserting `<1 x T>` into an `<N x T>`. It can happen with scalar + // types which are mapped to vector LLVM IR types (e.g. for implementing + // an ABI). + if (auto *EltTy = dyn_cast<llvm::FixedVectorType>(SrcVal->getType()); + EltTy && EltTy->getNumElements() == 1) + SrcVal = Builder.CreateBitCast(SrcVal, EltTy->getElementType()); + Vec = Builder.CreateInsertElement(Vec, SrcVal, Dst.getVectorIdx(), + "vecins"); if (IRStoreTy) { // <N x i1> --> <iN>. Vec = Builder.CreateBitCast(Vec, IRStoreTy); @@ -4311,14 +4318,14 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, // GEP indexes are signed, and scaling an index isn't permitted to // signed-overflow, so we use the same semantics for our explicit // multiply. We suppress this if overflow is not undefined behavior. - if (getLangOpts().isSignedOverflowDefined()) { + if (getLangOpts().PointerOverflowDefined) { Idx = Builder.CreateMul(Idx, numElements); } else { Idx = Builder.CreateNSWMul(Idx, numElements); } Addr = emitArraySubscriptGEP(*this, Addr, Idx, vla->getElementType(), - !getLangOpts().isSignedOverflowDefined(), + !getLangOpts().PointerOverflowDefined, SignedIndices, E->getExprLoc()); } else if (const ObjCObjectType *OIT = E->getType()->getAs<ObjCObjectType>()){ @@ -4408,7 +4415,7 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, QualType arrayType = Array->getType(); Addr = emitArraySubscriptGEP( *this, ArrayLV.getAddress(), {CGM.getSize(CharUnits::Zero()), Idx}, - E->getType(), !getLangOpts().isSignedOverflowDefined(), SignedIndices, + E->getType(), !getLangOpts().PointerOverflowDefined, SignedIndices, E->getExprLoc(), &arrayType, E->getBase()); EltBaseInfo = ArrayLV.getBaseInfo(); EltTBAAInfo = CGM.getTBAAInfoForSubobject(ArrayLV, E->getType()); @@ -4417,10 +4424,9 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, Addr = EmitPointerWithAlignment(E->getBase(), &EltBaseInfo, &EltTBAAInfo); auto *Idx = EmitIdxAfterBase(/*Promote*/true); QualType ptrType = E->getBase()->getType(); - Addr = emitArraySubscriptGEP(*this, Addr, Idx, E->getType(), - !getLangOpts().isSignedOverflowDefined(), - SignedIndices, E->getExprLoc(), &ptrType, - E->getBase()); + Addr = emitArraySubscriptGEP( + *this, Addr, Idx, E->getType(), !getLangOpts().PointerOverflowDefined, + SignedIndices, E->getExprLoc(), &ptrType, E->getBase()); } LValue LV = MakeAddrLValue(Addr, E->getType(), EltBaseInfo, EltTBAAInfo); @@ -4565,11 +4571,11 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E, : llvm::ConstantInt::get(IntPtrTy, ConstLength); Idx = Builder.CreateAdd(LowerBoundVal, LengthVal, "lb_add_len", /*HasNUW=*/false, - !getLangOpts().isSignedOverflowDefined()); + !getLangOpts().PointerOverflowDefined); if (Length && LowerBound) { Idx = Builder.CreateSub( Idx, llvm::ConstantInt::get(IntPtrTy, /*V=*/1), "idx_sub_1", - /*HasNUW=*/false, !getLangOpts().isSignedOverflowDefined()); + /*HasNUW=*/false, !getLangOpts().PointerOverflowDefined); } } else Idx = llvm::ConstantInt::get(IntPtrTy, ConstLength + ConstLowerBound); @@ -4595,7 +4601,7 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E, Length->getType()->hasSignedIntegerRepresentation()); Idx = Builder.CreateSub( LengthVal, llvm::ConstantInt::get(IntPtrTy, /*V=*/1), "len_sub_1", - /*HasNUW=*/false, !getLangOpts().isSignedOverflowDefined()); + /*HasNUW=*/false, !getLangOpts().PointerOverflowDefined); } else { ConstLength = ConstLength.zextOrTrunc(PointerWidthInBits); --ConstLength; @@ -4622,12 +4628,12 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E, // GEP indexes are signed, and scaling an index isn't permitted to // signed-overflow, so we use the same semantics for our explicit // multiply. We suppress this if overflow is not undefined behavior. - if (getLangOpts().isSignedOverflowDefined()) + if (getLangOpts().PointerOverflowDefined) Idx = Builder.CreateMul(Idx, NumElements); else Idx = Builder.CreateNSWMul(Idx, NumElements); EltPtr = emitArraySubscriptGEP(*this, Base, Idx, VLA->getElementType(), - !getLangOpts().isSignedOverflowDefined(), + !getLangOpts().PointerOverflowDefined, /*signedIndices=*/false, E->getExprLoc()); } else if (const Expr *Array = isSimpleArrayDecayOperand(E->getBase())) { // If this is A[i] where A is an array, the frontend will have decayed the @@ -4647,7 +4653,7 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E, // Propagate the alignment from the array itself to the result. EltPtr = emitArraySubscriptGEP( *this, ArrayLV.getAddress(), {CGM.getSize(CharUnits::Zero()), Idx}, - ResultExprTy, !getLangOpts().isSignedOverflowDefined(), + ResultExprTy, !getLangOpts().PointerOverflowDefined, /*signedIndices=*/false, E->getExprLoc()); BaseInfo = ArrayLV.getBaseInfo(); TBAAInfo = CGM.getTBAAInfoForSubobject(ArrayLV, ResultExprTy); @@ -4656,7 +4662,7 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E, emitOMPArraySectionBase(*this, E->getBase(), BaseInfo, TBAAInfo, BaseTy, ResultExprTy, IsLowerBound); EltPtr = emitArraySubscriptGEP(*this, Base, Idx, ResultExprTy, - !getLangOpts().isSignedOverflowDefined(), + !getLangOpts().PointerOverflowDefined, /*signedIndices=*/false, E->getExprLoc()); } diff --git clang/lib/CodeGen/CGExprScalar.cpp clang/lib/CodeGen/CGExprScalar.cpp index ac499e490ee8..df850421c72c 100644 --- clang/lib/CodeGen/CGExprScalar.cpp +++ clang/lib/CodeGen/CGExprScalar.cpp @@ -3043,7 +3043,7 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV, llvm::Value *numElts = CGF.getVLASize(vla).NumElts; if (!isInc) numElts = Builder.CreateNSWNeg(numElts, "vla.negsize"); llvm::Type *elemTy = CGF.ConvertTypeForMem(vla->getElementType()); - if (CGF.getLangOpts().isSignedOverflowDefined()) + if (CGF.getLangOpts().PointerOverflowDefined) value = Builder.CreateGEP(elemTy, value, numElts, "vla.inc"); else value = CGF.EmitCheckedInBoundsGEP( @@ -3054,7 +3054,7 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV, } else if (type->isFunctionType()) { llvm::Value *amt = Builder.getInt32(amount); - if (CGF.getLangOpts().isSignedOverflowDefined()) + if (CGF.getLangOpts().PointerOverflowDefined) value = Builder.CreateGEP(CGF.Int8Ty, value, amt, "incdec.funcptr"); else value = @@ -3066,7 +3066,7 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV, } else { llvm::Value *amt = Builder.getInt32(amount); llvm::Type *elemTy = CGF.ConvertTypeForMem(type); - if (CGF.getLangOpts().isSignedOverflowDefined()) + if (CGF.getLangOpts().PointerOverflowDefined) value = Builder.CreateGEP(elemTy, value, amt, "incdec.ptr"); else value = CGF.EmitCheckedInBoundsGEP( @@ -3179,7 +3179,7 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV, llvm::Value *sizeValue = llvm::ConstantInt::get(CGF.SizeTy, size.getQuantity()); - if (CGF.getLangOpts().isSignedOverflowDefined()) + if (CGF.getLangOpts().PointerOverflowDefined) value = Builder.CreateGEP(CGF.Int8Ty, value, sizeValue, "incdec.objptr"); else value = CGF.EmitCheckedInBoundsGEP( @@ -4075,7 +4075,7 @@ static Value *emitPointerArithmetic(CodeGenFunction &CGF, // signed-overflow, so we use the same semantics for our explicit // multiply. We suppress this if overflow is not undefined behavior. llvm::Type *elemTy = CGF.ConvertTypeForMem(vla->getElementType()); - if (CGF.getLangOpts().isSignedOverflowDefined()) { + if (CGF.getLangOpts().PointerOverflowDefined) { index = CGF.Builder.CreateMul(index, numElements, "vla.index"); pointer = CGF.Builder.CreateGEP(elemTy, pointer, index, "add.ptr"); } else { @@ -4096,7 +4096,7 @@ static Value *emitPointerArithmetic(CodeGenFunction &CGF, else elemTy = CGF.ConvertTypeForMem(elementType); - if (CGF.getLangOpts().isSignedOverflowDefined()) + if (CGF.getLangOpts().PointerOverflowDefined) return CGF.Builder.CreateGEP(elemTy, pointer, index, "add.ptr"); return CGF.EmitCheckedInBoundsGEP( diff --git clang/lib/CodeGen/CGObjCGNU.cpp clang/lib/CodeGen/CGObjCGNU.cpp index cfc92be39394..ebd88bb38849 100644 --- clang/lib/CodeGen/CGObjCGNU.cpp +++ clang/lib/CodeGen/CGObjCGNU.cpp @@ -773,7 +773,9 @@ class CGObjCGNUstep : public CGObjCGNU { // The lookup function is guaranteed not to capture the receiver pointer. if (auto *LookupFn2 = dyn_cast<llvm::Function>(LookupFn.getCallee())) - LookupFn2->addParamAttr(0, llvm::Attribute::NoCapture); + LookupFn2->addParamAttr( + 0, llvm::Attribute::getWithCaptureInfo(CGF.getLLVMContext(), + llvm::CaptureInfo::none())); llvm::Value *args[] = { EnforceType(Builder, ReceiverPtr.getPointer(), PtrToIdTy), diff --git clang/lib/CodeGen/CGObjCRuntime.cpp clang/lib/CodeGen/CGObjCRuntime.cpp index b438a92a4fd6..a7f5c913f42f 100644 --- clang/lib/CodeGen/CGObjCRuntime.cpp +++ clang/lib/CodeGen/CGObjCRuntime.cpp @@ -230,11 +230,14 @@ void CGObjCRuntime::EmitTryCatchStmt(CodeGenFunction &CGF, CodeGenFunction::LexicalScope Cleanups(CGF, Handler.Body->getSourceRange()); SaveAndRestore RevertAfterScope(CGF.CurrentFuncletPad); if (useFunclets) { - llvm::Instruction *CPICandidate = Handler.Block->getFirstNonPHI(); - if (auto *CPI = dyn_cast_or_null<llvm::CatchPadInst>(CPICandidate)) { - CGF.CurrentFuncletPad = CPI; - CPI->setOperand(2, CGF.getExceptionSlot().emitRawPointer(CGF)); - CGF.EHStack.pushCleanup<CatchRetScope>(NormalCleanup, CPI); + llvm::BasicBlock::iterator CPICandidate = + Handler.Block->getFirstNonPHIIt(); + if (CPICandidate != Handler.Block->end()) { + if (auto *CPI = dyn_cast_or_null<llvm::CatchPadInst>(CPICandidate)) { + CGF.CurrentFuncletPad = CPI; + CPI->setOperand(2, CGF.getExceptionSlot().emitRawPointer(CGF)); + CGF.EHStack.pushCleanup<CatchRetScope>(NormalCleanup, CPI); + } } } diff --git clang/lib/CodeGen/CodeGenFunction.cpp clang/lib/CodeGen/CodeGenFunction.cpp index 11fdddba1144..bbef277a5244 100644 --- clang/lib/CodeGen/CodeGenFunction.cpp +++ clang/lib/CodeGen/CodeGenFunction.cpp @@ -404,9 +404,9 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) { // important to do this before we enter the return block or return // edges will be *really* confused. bool HasCleanups = EHStack.stable_begin() != PrologueCleanupDepth; - bool HasOnlyLifetimeMarkers = - HasCleanups && EHStack.containsOnlyLifetimeMarkers(PrologueCleanupDepth); - bool EmitRetDbgLoc = !HasCleanups || HasOnlyLifetimeMarkers; + bool HasOnlyNoopCleanups = + HasCleanups && EHStack.containsOnlyNoopCleanups(PrologueCleanupDepth); + bool EmitRetDbgLoc = !HasCleanups || HasOnlyNoopCleanups; std::optional<ApplyDebugLocation> OAL; if (HasCleanups) { diff --git clang/lib/CodeGen/CodeGenFunction.h clang/lib/CodeGen/CodeGenFunction.h index fab27d4c22ed..e978cad43362 100644 --- clang/lib/CodeGen/CodeGenFunction.h +++ clang/lib/CodeGen/CodeGenFunction.h @@ -451,7 +451,7 @@ public: "EBB should be entry block of the current code gen function"); PostAllocaInsertPt = AllocaInsertPt->clone(); PostAllocaInsertPt->setName("postallocapt"); - PostAllocaInsertPt->insertAfter(AllocaInsertPt); + PostAllocaInsertPt->insertAfter(AllocaInsertPt->getIterator()); } return PostAllocaInsertPt; @@ -723,6 +723,20 @@ public: } }; + // We are using objects of this 'cleanup' class to emit fake.use calls + // for -fextend-variable-liveness. They are placed at the end of a variable's + // scope analogous to lifetime markers. + class FakeUse final : public EHScopeStack::Cleanup { + Address Addr; + + public: + FakeUse(Address addr) : Addr(addr) {} + + void Emit(CodeGenFunction &CGF, Flags flags) override { + CGF.EmitFakeUse(Addr); + } + }; + /// Header for data within LifetimeExtendedCleanupStack. struct LifetimeExtendedCleanupHeader { /// The size of the following cleanup object. @@ -4692,6 +4706,21 @@ public: SmallVectorImpl<llvm::Value*> &O, const char *name, unsigned shift = 0, bool rightshift = false); + llvm::Value *EmitFP8NeonCall(unsigned IID, ArrayRef<llvm::Type *> Tys, + SmallVectorImpl<llvm::Value *> &O, + const CallExpr *E, const char *name); + llvm::Value *EmitFP8NeonCvtCall(unsigned IID, llvm::Type *Ty0, + llvm::Type *Ty1, bool Extract, + SmallVectorImpl<llvm::Value *> &Ops, + const CallExpr *E, const char *name); + llvm::Value *EmitFP8NeonFDOTCall(unsigned IID, bool ExtendLaneArg, + llvm::Type *RetTy, + SmallVectorImpl<llvm::Value *> &Ops, + const CallExpr *E, const char *name); + llvm::Value *EmitFP8NeonFMLACall(unsigned IID, bool ExtendLaneArg, + llvm::Type *RetTy, + SmallVectorImpl<llvm::Value *> &Ops, + const CallExpr *E, const char *name); llvm::Value *EmitNeonSplat(llvm::Value *V, llvm::Constant *Idx, const llvm::ElementCount &Count); llvm::Value *EmitNeonSplat(llvm::Value *V, llvm::Constant *Idx); @@ -5060,6 +5089,8 @@ public: RValue EmitAtomicExpr(AtomicExpr *E); + void EmitFakeUse(Address Addr); + //===--------------------------------------------------------------------===// // Annotations Emission //===--------------------------------------------------------------------===// diff --git clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenModule.cpp index eb8d3ceeeba4..a015d64f4065 100644 --- clang/lib/CodeGen/CodeGenModule.cpp +++ clang/lib/CodeGen/CodeGenModule.cpp @@ -7014,9 +7014,10 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) { case Decl::VarTemplateSpecialization: EmitGlobal(cast<VarDecl>(D)); if (auto *DD = dyn_cast<DecompositionDecl>(D)) - for (auto *B : DD->bindings()) + for (auto *B : DD->flat_bindings()) if (auto *HD = B->getHoldingVar()) EmitGlobal(HD); + break; // Indirect fields from global anonymous structs and unions can be diff --git clang/lib/CodeGen/CodeGenModule.h clang/lib/CodeGen/CodeGenModule.h index 1aa5d483d49c..0956296e2d5d 100644 --- clang/lib/CodeGen/CodeGenModule.h +++ clang/lib/CodeGen/CodeGenModule.h @@ -647,6 +647,9 @@ private: /// void @llvm.lifetime.end(i64 %size, i8* nocapture <ptr>) llvm::Function *LifetimeEndFn = nullptr; + /// void @llvm.fake.use(...) + llvm::Function *FakeUseFn = nullptr; + std::unique_ptr<SanitizerMetadata> SanitizerMD; llvm::MapVector<const Decl *, bool> DeferredEmptyCoverageMappingDecls; @@ -1326,6 +1329,7 @@ public: llvm::Function *getLLVMLifetimeStartFn(); llvm::Function *getLLVMLifetimeEndFn(); + llvm::Function *getLLVMFakeUseFn(); // Make sure that this type is translated. void UpdateCompletedType(const TagDecl *TD); diff --git clang/lib/CodeGen/CodeGenTypes.cpp clang/lib/CodeGen/CodeGenTypes.cpp index 09191a4901f4..405242e97e75 100644 --- clang/lib/CodeGen/CodeGenTypes.cpp +++ clang/lib/CodeGen/CodeGenTypes.cpp @@ -505,15 +505,18 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) { case BuiltinType::Id: #define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \ case BuiltinType::Id: -#define AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \ - case BuiltinType::Id: -#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) +#define SVE_TYPE(Name, Id, SingletonId) #include "clang/Basic/AArch64SVEACLETypes.def" { ASTContext::BuiltinVectorTypeInfo Info = Context.getBuiltinVectorTypeInfo(cast<BuiltinType>(Ty)); - auto VTy = - llvm::VectorType::get(ConvertType(Info.ElementType), Info.EC); + // The `__mfp8` type maps to `<1 x i8>` which can't be used to build + // a <N x i8> vector type, hence bypass the call to `ConvertType` for + // the element type and create the vector type directly. + auto *EltTy = Info.ElementType->isMFloat8Type() + ? llvm::Type::getInt8Ty(getLLVMContext()) + : ConvertType(Info.ElementType); + auto *VTy = llvm::VectorType::get(EltTy, Info.EC); switch (Info.NumVectors) { default: llvm_unreachable("Expected 1, 2, 3 or 4 vectors!"); @@ -529,6 +532,9 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) { } case BuiltinType::SveCount: return llvm::TargetExtType::get(getLLVMContext(), "aarch64.svcount"); + case BuiltinType::MFloat8: + return llvm::VectorType::get(llvm::Type::getInt8Ty(getLLVMContext()), 1, + false); #define PPC_VECTOR_TYPE(Name, Id, Size) \ case BuiltinType::Id: \ ResultType = \ @@ -650,6 +656,8 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) { // An ext_vector_type of Bool is really a vector of bits. llvm::Type *IRElemTy = VT->isExtVectorBoolType() ? llvm::Type::getInt1Ty(getLLVMContext()) + : VT->getElementType()->isMFloat8Type() + ? llvm::Type::getInt8Ty(getLLVMContext()) : ConvertType(VT->getElementType()); ResultType = llvm::FixedVectorType::get(IRElemTy, VT->getNumElements()); break; diff --git clang/lib/CodeGen/EHScopeStack.h clang/lib/CodeGen/EHScopeStack.h index 0c667e80bb6d..ed11dc2bb05d 100644 --- clang/lib/CodeGen/EHScopeStack.h +++ clang/lib/CodeGen/EHScopeStack.h @@ -87,6 +87,11 @@ enum CleanupKind : unsigned { LifetimeMarker = 0x8, NormalEHLifetimeMarker = LifetimeMarker | NormalAndEHCleanup, + + // FakeUse needs to be recognized as a special cleanup similar to lifetime + // markers chiefly to be ignored in most contexts. + FakeUse = 0x10, + NormalFakeUse = FakeUse | NormalCleanup, }; /// A stack of scopes which respond to exceptions, including cleanups @@ -352,8 +357,8 @@ public: void popTerminate(); // Returns true iff the current scope is either empty or contains only - // lifetime markers, i.e. no real cleanup code - bool containsOnlyLifetimeMarkers(stable_iterator Old) const; + // noop cleanups, i.e. lifetime markers and fake uses. + bool containsOnlyNoopCleanups(stable_iterator Old) const; /// Determines whether the exception-scopes stack is empty. bool empty() const { return StartOfData == EndOfBuffer; } diff --git clang/lib/CodeGen/Targets/AArch64.cpp clang/lib/CodeGen/Targets/AArch64.cpp index 7db67ecba07c..e2e434815d43 100644 --- clang/lib/CodeGen/Targets/AArch64.cpp +++ clang/lib/CodeGen/Targets/AArch64.cpp @@ -244,6 +244,7 @@ AArch64ABIInfo::convertFixedToScalableVectorType(const VectorType *VT) const { case BuiltinType::SChar: case BuiltinType::UChar: + case BuiltinType::MFloat8: return llvm::ScalableVectorType::get( llvm::Type::getInt8Ty(getVMContext()), 16); @@ -383,10 +384,6 @@ ABIArgInfo AArch64ABIInfo::classifyArgumentType(QualType Ty, bool IsVariadicFn, NSRN = std::min(NSRN + 1, 8u); else { switch (BT->getKind()) { - case BuiltinType::MFloat8x8: - case BuiltinType::MFloat8x16: - NSRN = std::min(NSRN + 1, 8u); - break; case BuiltinType::SveBool: case BuiltinType::SveCount: NPRN = std::min(NPRN + 1, 4u); @@ -418,18 +415,21 @@ ABIArgInfo AArch64ABIInfo::classifyArgumentType(QualType Ty, bool IsVariadicFn, CGCXXABI::RAA_DirectInMemory); } - // Empty records are always ignored on Darwin, but actually passed in C++ mode - // elsewhere for GNU compatibility. + // Empty records: uint64_t Size = getContext().getTypeSize(Ty); bool IsEmpty = isEmptyRecord(getContext(), Ty, true); if (!Ty->isSVESizelessBuiltinType() && (IsEmpty || Size == 0)) { + // Empty records are ignored in C mode, and in C++ on Darwin. if (!getContext().getLangOpts().CPlusPlus || isDarwinPCS()) return ABIArgInfo::getIgnore(); - // GNU C mode. The only argument that gets ignored is an empty one with size - // 0. - if (IsEmpty && Size == 0) + // In C++ mode, arguments which have sizeof() == 0 (which are non-standard + // C++) are ignored. This isn't defined by any standard, so we copy GCC's + // behaviour here. + if (Size == 0) return ABIArgInfo::getIgnore(); + + // Otherwise, they are passed as if they have a size of 1 byte. return ABIArgInfo::getDirect(llvm::Type::getInt8Ty(getVMContext())); } @@ -629,8 +629,7 @@ bool AArch64ABIInfo::isHomogeneousAggregateBaseType(QualType Ty) const { // but with the difference that any floating-point type is allowed, // including __fp16. if (const BuiltinType *BT = Ty->getAs<BuiltinType>()) { - if (BT->isFloatingPoint() || BT->getKind() == BuiltinType::MFloat8x16 || - BT->getKind() == BuiltinType::MFloat8x8) + if (BT->isFloatingPoint()) return true; } else if (const VectorType *VT = Ty->getAs<VectorType>()) { if (auto Kind = VT->getVectorKind(); @@ -781,8 +780,10 @@ bool AArch64ABIInfo::passAsPureScalableType( NPred += Info.NumVectors; else NVec += Info.NumVectors; - auto VTy = llvm::ScalableVectorType::get(CGT.ConvertType(Info.ElementType), - Info.EC.getKnownMinValue()); + llvm::Type *EltTy = Info.ElementType->isMFloat8Type() + ? llvm::Type::getInt8Ty(getVMContext()) + : CGT.ConvertType(Info.ElementType); + auto *VTy = llvm::ScalableVectorType::get(EltTy, Info.EC.getKnownMinValue()); if (CoerceToSeq.size() + Info.NumVectors > 12) return false; diff --git clang/lib/Driver/Action.cpp clang/lib/Driver/Action.cpp index 23dbcebc9a1c..0899b8ef0015 100644 --- clang/lib/Driver/Action.cpp +++ clang/lib/Driver/Action.cpp @@ -27,8 +27,8 @@ const char *Action::getClassName(ActionClass AC) { case PrecompileJobClass: return "precompiler"; case ExtractAPIJobClass: return "api-extractor"; - case AnalyzeJobClass: return "analyzer"; - case MigrateJobClass: return "migrator"; + case AnalyzeJobClass: + return "analyzer"; case CompileJobClass: return "compiler"; case BackendJobClass: return "backend"; case AssembleJobClass: return "assembler"; @@ -373,11 +373,6 @@ void AnalyzeJobAction::anchor() {} AnalyzeJobAction::AnalyzeJobAction(Action *Input, types::ID OutputType) : JobAction(AnalyzeJobClass, Input, OutputType) {} -void MigrateJobAction::anchor() {} - -MigrateJobAction::MigrateJobAction(Action *Input, types::ID OutputType) - : JobAction(MigrateJobClass, Input, OutputType) {} - void CompileJobAction::anchor() {} CompileJobAction::CompileJobAction(Action *Input, types::ID OutputType) diff --git clang/lib/Driver/Driver.cpp clang/lib/Driver/Driver.cpp index 87855fdb7997..612e44b8c4da 100644 --- clang/lib/Driver/Driver.cpp +++ clang/lib/Driver/Driver.cpp @@ -413,12 +413,12 @@ phases::ID Driver::getFinalPhase(const DerivedArgList &DAL, // -{fsyntax-only,-analyze,emit-ast} only run up to the compiler. } else if ((PhaseArg = DAL.getLastArg(options::OPT_fsyntax_only)) || (PhaseArg = DAL.getLastArg(options::OPT_print_supported_cpus)) || - (PhaseArg = DAL.getLastArg(options::OPT_print_enabled_extensions)) || + (PhaseArg = + DAL.getLastArg(options::OPT_print_enabled_extensions)) || (PhaseArg = DAL.getLastArg(options::OPT_module_file_info)) || (PhaseArg = DAL.getLastArg(options::OPT_verify_pch)) || (PhaseArg = DAL.getLastArg(options::OPT_rewrite_objc)) || (PhaseArg = DAL.getLastArg(options::OPT_rewrite_legacy_objc)) || - (PhaseArg = DAL.getLastArg(options::OPT__migrate)) || (PhaseArg = DAL.getLastArg(options::OPT__analyze)) || (PhaseArg = DAL.getLastArg(options::OPT_emit_cir)) || (PhaseArg = DAL.getLastArg(options::OPT_emit_ast))) { @@ -637,6 +637,10 @@ static llvm::Triple computeTargetTriple(const Driver &D, } } + // Currently the only architecture supported by *-uefi triples are x86_64. + if (Target.isUEFI() && Target.getArch() != llvm::Triple::x86_64) + D.Diag(diag::err_target_unknown_triple) << Target.str(); + // The `-maix[32|64]` flags are only valid for AIX targets. if (Arg *A = Args.getLastArgNoClaim(options::OPT_maix32, options::OPT_maix64); A && !Target.isOSAIX()) @@ -5078,8 +5082,6 @@ Action *Driver::ConstructPhaseAction( types::TY_RewrittenLegacyObjC); if (Args.hasArg(options::OPT__analyze)) return C.MakeAction<AnalyzeJobAction>(Input, types::TY_Plist); - if (Args.hasArg(options::OPT__migrate)) - return C.MakeAction<MigrateJobAction>(Input, types::TY_Remap); if (Args.hasArg(options::OPT_emit_ast)) return C.MakeAction<CompileJobAction>(Input, types::TY_AST); if (Args.hasArg(options::OPT_emit_cir)) diff --git clang/lib/Driver/SanitizerArgs.cpp clang/lib/Driver/SanitizerArgs.cpp index a0d6919c6dc8..3420472c0f75 100644 --- clang/lib/Driver/SanitizerArgs.cpp +++ clang/lib/Driver/SanitizerArgs.cpp @@ -575,6 +575,9 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC, options::OPT_fstrict_overflow, false); if (Args.hasFlagNoClaim(options::OPT_fwrapv, options::OPT_fno_wrapv, S)) Add &= ~SanitizerKind::SignedIntegerOverflow; + if (Args.hasFlagNoClaim(options::OPT_fwrapv_pointer, + options::OPT_fno_wrapv_pointer, S)) + Add &= ~SanitizerKind::PointerOverflow; } Add &= Supported; diff --git clang/lib/Driver/ToolChain.cpp clang/lib/Driver/ToolChain.cpp index acf9d264d631..ebc982096595 100644 --- clang/lib/Driver/ToolChain.cpp +++ clang/lib/Driver/ToolChain.cpp @@ -646,7 +646,6 @@ Tool *ToolChain::getTool(Action::ActionClass AC) const { case Action::PreprocessJobClass: case Action::ExtractAPIJobClass: case Action::AnalyzeJobClass: - case Action::MigrateJobClass: case Action::VerifyPCHJobClass: case Action::BackendJobClass: return getClang(); diff --git clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/Clang.cpp index 518113e20cb0..9b5132c5625f 100644 --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -3958,78 +3958,6 @@ static void RenderOpenACCOptions(const Driver &D, const ArgList &Args, } } -static void RenderARCMigrateToolOptions(const Driver &D, const ArgList &Args, - ArgStringList &CmdArgs) { - bool ARCMTEnabled = false; - if (!Args.hasArg(options::OPT_fno_objc_arc, options::OPT_fobjc_arc)) { - if (const Arg *A = Args.getLastArg(options::OPT_ccc_arcmt_check, - options::OPT_ccc_arcmt_modify, - options::OPT_ccc_arcmt_migrate)) { - ARCMTEnabled = true; - switch (A->getOption().getID()) { - default: llvm_unreachable("missed a case"); - case options::OPT_ccc_arcmt_check: - CmdArgs.push_back("-arcmt-action=check"); - break; - case options::OPT_ccc_arcmt_modify: - CmdArgs.push_back("-arcmt-action=modify"); - break; - case options::OPT_ccc_arcmt_migrate: - CmdArgs.push_back("-arcmt-action=migrate"); - CmdArgs.push_back("-mt-migrate-directory"); - CmdArgs.push_back(A->getValue()); - - Args.AddLastArg(CmdArgs, options::OPT_arcmt_migrate_report_output); - Args.AddLastArg(CmdArgs, options::OPT_arcmt_migrate_emit_arc_errors); - break; - } - } - } else { - Args.ClaimAllArgs(options::OPT_ccc_arcmt_check); - Args.ClaimAllArgs(options::OPT_ccc_arcmt_modify); - Args.ClaimAllArgs(options::OPT_ccc_arcmt_migrate); - } - - if (const Arg *A = Args.getLastArg(options::OPT_ccc_objcmt_migrate)) { - if (ARCMTEnabled) - D.Diag(diag::err_drv_argument_not_allowed_with) - << A->getAsString(Args) << "-ccc-arcmt-migrate"; - - CmdArgs.push_back("-mt-migrate-directory"); - CmdArgs.push_back(A->getValue()); - - if (!Args.hasArg(options::OPT_objcmt_migrate_literals, - options::OPT_objcmt_migrate_subscripting, - options::OPT_objcmt_migrate_property)) { - // None specified, means enable them all. - CmdArgs.push_back("-objcmt-migrate-literals"); - CmdArgs.push_back("-objcmt-migrate-subscripting"); - CmdArgs.push_back("-objcmt-migrate-property"); - } else { - Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_literals); - Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_subscripting); - Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_property); - } - } else { - Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_literals); - Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_subscripting); - Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_property); - Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_all); - Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_readonly_property); - Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_readwrite_property); - Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_property_dot_syntax); - Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_annotation); - Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_instancetype); - Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_nsmacros); - Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_protocol_conformance); - Args.AddLastArg(CmdArgs, options::OPT_objcmt_atomic_property); - Args.AddLastArg(CmdArgs, options::OPT_objcmt_returns_innerpointer_property); - Args.AddLastArg(CmdArgs, options::OPT_objcmt_ns_nonatomic_iosonly); - Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_designated_init); - Args.AddLastArg(CmdArgs, options::OPT_objcmt_allowlist_dir_path); - } -} - static void RenderBuiltinOptions(const ToolChain &TC, const llvm::Triple &T, const ArgList &Args, ArgStringList &CmdArgs) { // -fbuiltin is default unless -mkernel is used. @@ -5319,8 +5247,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, if (isa<AnalyzeJobAction>(JA)) { assert(JA.getType() == types::TY_Plist && "Invalid output type."); CmdArgs.push_back("-analyze"); - } else if (isa<MigrateJobAction>(JA)) { - CmdArgs.push_back("-migrate"); } else if (isa<PreprocessJobAction>(JA)) { if (Output.getType() == types::TY_Dependencies) CmdArgs.push_back("-Eonly"); @@ -6445,8 +6371,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, Args.AddLastArg(CmdArgs, options::OPT_working_directory); - RenderARCMigrateToolOptions(D, Args, CmdArgs); - // Add preprocessing options like -I, -D, etc. if we are using the // preprocessor. // @@ -7502,20 +7426,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, Args.addOptOutFlag(CmdArgs, options::OPT_fassume_unique_vtables, options::OPT_fno_assume_unique_vtables); - // -frelaxed-template-template-args is deprecated. - if (Arg *A = - Args.getLastArg(options::OPT_frelaxed_template_template_args, - options::OPT_fno_relaxed_template_template_args)) { - if (A->getOption().matches( - options::OPT_fno_relaxed_template_template_args)) { - D.Diag(diag::warn_drv_deprecated_arg_no_relaxed_template_template_args); - CmdArgs.push_back("-fno-relaxed-template-template-args"); - } else { - D.Diag(diag::warn_drv_deprecated_arg) - << A->getAsString(Args) << /*hasReplacement=*/false; - } - } - // -fsized-deallocation is on by default in C++14 onwards and otherwise off // by default. Args.addLastArg(CmdArgs, options::OPT_fsized_deallocation, @@ -7706,6 +7616,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, if (Args.hasArg(options::OPT_fretain_comments_from_system_headers)) CmdArgs.push_back("-fretain-comments-from-system-headers"); + Args.AddLastArg(CmdArgs, options::OPT_fextend_variable_liveness_EQ); + // Forward -fcomment-block-commands to -cc1. Args.AddAllArgs(CmdArgs, options::OPT_fcomment_block_commands); // Forward -fparse-all-comments to -cc1. diff --git clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp index 86ebb880bae0..361cf41544b0 100644 --- clang/lib/Driver/ToolChains/CommonArgs.cpp +++ clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -3094,12 +3094,19 @@ void tools::renderCommonIntegerOverflowOptions(const ArgList &Args, ArgStringList &CmdArgs) { // -fno-strict-overflow implies -fwrapv if it isn't disabled, but // -fstrict-overflow won't turn off an explicitly enabled -fwrapv. + bool StrictOverflow = Args.hasFlag(options::OPT_fstrict_overflow, + options::OPT_fno_strict_overflow, true); if (Arg *A = Args.getLastArg(options::OPT_fwrapv, options::OPT_fno_wrapv)) { if (A->getOption().matches(options::OPT_fwrapv)) CmdArgs.push_back("-fwrapv"); - } else if (Arg *A = Args.getLastArg(options::OPT_fstrict_overflow, - options::OPT_fno_strict_overflow)) { - if (A->getOption().matches(options::OPT_fno_strict_overflow)) - CmdArgs.push_back("-fwrapv"); + } else if (!StrictOverflow) { + CmdArgs.push_back("-fwrapv"); + } + if (Arg *A = Args.getLastArg(options::OPT_fwrapv_pointer, + options::OPT_fno_wrapv_pointer)) { + if (A->getOption().matches(options::OPT_fwrapv_pointer)) + CmdArgs.push_back("-fwrapv-pointer"); + } else if (!StrictOverflow) { + CmdArgs.push_back("-fwrapv-pointer"); } } diff --git clang/lib/Driver/ToolChains/Darwin.cpp clang/lib/Driver/ToolChains/Darwin.cpp index 55c55bad7393..9a276c55bf7b 100644 --- clang/lib/Driver/ToolChains/Darwin.cpp +++ clang/lib/Driver/ToolChains/Darwin.cpp @@ -588,20 +588,6 @@ void darwin::Linker::ConstructJob(Compilation &C, const JobAction &JA, // more information. ArgStringList CmdArgs; - /// Hack(tm) to ignore linking errors when we are doing ARC migration. - if (Args.hasArg(options::OPT_ccc_arcmt_check, - options::OPT_ccc_arcmt_migrate)) { - for (const auto &Arg : Args) - Arg->claim(); - const char *Exec = - Args.MakeArgString(getToolChain().GetProgramPath("touch")); - CmdArgs.push_back(Output.getFilename()); - C.addCommand(std::make_unique<Command>(JA, *this, - ResponseFileSupport::None(), Exec, - CmdArgs, std::nullopt, Output)); - return; - } - VersionTuple Version = getMachOToolChain().getLinkerVersion(Args); bool LinkerIsLLD; diff --git clang/lib/Format/Format.cpp clang/lib/Format/Format.cpp index c25d9bf7c225..f02bf95cfeed 100644 --- clang/lib/Format/Format.cpp +++ clang/lib/Format/Format.cpp @@ -1091,6 +1091,8 @@ template <> struct MappingTraits<FormatStyle> { IO.mapOptional("PenaltyBreakAssignment", Style.PenaltyBreakAssignment); IO.mapOptional("PenaltyBreakBeforeFirstCallParameter", Style.PenaltyBreakBeforeFirstCallParameter); + IO.mapOptional("PenaltyBreakBeforeMemberAccess", + Style.PenaltyBreakBeforeMemberAccess); IO.mapOptional("PenaltyBreakComment", Style.PenaltyBreakComment); IO.mapOptional("PenaltyBreakFirstLessLess", Style.PenaltyBreakFirstLessLess); @@ -1659,6 +1661,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) { LLVMStyle.PenaltyBreakAssignment = prec::Assignment; LLVMStyle.PenaltyBreakBeforeFirstCallParameter = 19; + LLVMStyle.PenaltyBreakBeforeMemberAccess = 150; LLVMStyle.PenaltyBreakComment = 300; LLVMStyle.PenaltyBreakFirstLessLess = 120; LLVMStyle.PenaltyBreakOpenParenthesis = 0; diff --git clang/lib/Format/TokenAnnotator.cpp clang/lib/Format/TokenAnnotator.cpp index 655766178fbb..a172df5291ae 100644 --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -252,10 +252,10 @@ private: // parameters. // FIXME: This is getting out of hand, write a decent parser. if (MaybeAngles && InExpr && !Line.startsWith(tok::kw_template) && - Prev.is(TT_BinaryOperator)) { - const auto Precedence = Prev.getPrecedence(); - if (Precedence > prec::Conditional && Precedence < prec::Relational) - MaybeAngles = false; + Prev.is(TT_BinaryOperator) && + (Prev.isOneOf(tok::pipepipe, tok::ampamp) || + Prev.getPrecedence() == prec::Equality)) { + MaybeAngles = false; } if (Prev.isOneOf(tok::question, tok::colon) && !Style.isProto()) SeenTernaryOperator = true; @@ -4313,9 +4313,11 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line, // // aaaaaaa // .aaaaaaaaa.bbbbbbbb(cccccccc); - return !Right.NextOperator || !Right.NextOperator->Previous->closesScope() - ? 150 - : 35; + const auto *NextOperator = Right.NextOperator; + const auto Penalty = Style.PenaltyBreakBeforeMemberAccess; + return NextOperator && NextOperator->Previous->closesScope() + ? std::min(Penalty, 35u) + : Penalty; } if (Right.is(TT_TrailingAnnotation) && diff --git clang/lib/Frontend/CompilerInvocation.cpp clang/lib/Frontend/CompilerInvocation.cpp index 3bf124e4827b..11fd6ab7f52a 100644 --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -2756,7 +2756,6 @@ static const auto &getFrontendActionTable() { {frontend::RewriteObjC, OPT_rewrite_objc}, {frontend::RewriteTest, OPT_rewrite_test}, {frontend::RunAnalysis, OPT_analyze}, - {frontend::MigrateSource, OPT_migrate}, {frontend::RunPreprocessorOnly, OPT_Eonly}, {frontend::PrintDependencyDirectivesSourceMinimizerOutput, OPT_print_dependency_directives_minimized_source}, @@ -3099,12 +3098,6 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args, if (Args.hasArg(OPT_aux_target_feature)) Opts.AuxTargetFeatures = Args.getAllArgValues(OPT_aux_target_feature); - if (Opts.ARCMTAction != FrontendOptions::ARCMT_None && - Opts.ObjCMTAction != FrontendOptions::ObjCMT_None) { - Diags.Report(diag::err_drv_argument_not_allowed_with) - << "ARC migration" << "ObjC migration"; - } - InputKind DashX(Language::Unknown); if (const Arg *A = Args.getLastArg(OPT_x)) { StringRef XValue = A->getValue(); @@ -3721,6 +3714,8 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts, } else if (Opts.SignedOverflowBehavior == LangOptions::SOB_Defined) { GenerateArg(Consumer, OPT_fwrapv); } + if (Opts.PointerOverflowDefined) + GenerateArg(Consumer, OPT_fwrapv_pointer); if (Opts.MSCompatibilityVersion != 0) { unsigned Major = Opts.MSCompatibilityVersion / 10000000; @@ -4138,6 +4133,8 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args, } else if (Args.hasArg(OPT_fwrapv)) Opts.setSignedOverflowBehavior(LangOptions::SOB_Defined); + if (Args.hasArg(OPT_fwrapv_pointer)) + Opts.PointerOverflowDefined = true; Opts.MSCompatibilityVersion = 0; if (const Arg *A = Args.getLastArg(OPT_fms_compatibility_version)) { @@ -4211,7 +4208,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args, } } - // Check if -fopenmp is specified and set default version to 5.0. + // Check if -fopenmp is specified and set default version to 5.1. Opts.OpenMP = Args.hasArg(OPT_fopenmp) ? 51 : 0; // Check if -fopenmp-simd is specified. bool IsSimdSpecified = @@ -4409,7 +4406,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args, // y or y.0 (4 <= y <= current version). if (!VerParts.first.starts_with("0") && !VerParts.first.getAsInteger(10, Major) && 3 <= Major && - Major <= CLANG_VERSION_MAJOR && + Major <= MAX_CLANG_ABI_COMPAT_VERSION && (Major == 3 ? VerParts.second.size() == 1 && !VerParts.second.getAsInteger(10, Minor) @@ -4635,7 +4632,6 @@ static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) { case frontend::RewriteTest: case frontend::RunAnalysis: case frontend::TemplightDump: - case frontend::MigrateSource: return false; case frontend::DumpCompilerOptions: diff --git clang/lib/Frontend/InitPreprocessor.cpp clang/lib/Frontend/InitPreprocessor.cpp index 17f624e96453..77833f5d1def 100644 --- clang/lib/Frontend/InitPreprocessor.cpp +++ clang/lib/Frontend/InitPreprocessor.cpp @@ -729,8 +729,8 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts, } if (LangOpts.AlignedAllocation && !LangOpts.AlignedAllocationUnavailable) Builder.defineMacro("__cpp_aligned_new", "201606L"); - if (LangOpts.RelaxedTemplateTemplateArgs) - Builder.defineMacro("__cpp_template_template_args", "201611L"); + + Builder.defineMacro("__cpp_template_template_args", "201611L"); // C++20 features. if (LangOpts.CPlusPlus20) { @@ -1466,9 +1466,15 @@ static void InitializePredefinedMacros(const TargetInfo &TI, case 50: Builder.defineMacro("_OPENMP", "201811"); break; + case 51: + Builder.defineMacro("_OPENMP", "202011"); + break; case 52: Builder.defineMacro("_OPENMP", "202111"); break; + case 60: + Builder.defineMacro("_OPENMP", "202411"); + break; default: // case 51: // Default version is OpenMP 5.1 Builder.defineMacro("_OPENMP", "202011"); diff --git clang/lib/Frontend/LogDiagnosticPrinter.cpp clang/lib/Frontend/LogDiagnosticPrinter.cpp index 469d1c22633a..4e963af837f0 100644 --- clang/lib/Frontend/LogDiagnosticPrinter.cpp +++ clang/lib/Frontend/LogDiagnosticPrinter.cpp @@ -129,7 +129,8 @@ void LogDiagnosticPrinter::HandleDiagnostic(DiagnosticsEngine::Level Level, DE.DiagnosticLevel = Level; DE.WarningOption = - std::string(DiagnosticIDs::getWarningOptionForDiag(DE.DiagnosticID)); + std::string(Info.getDiags()->getDiagnosticIDs()->getWarningOptionForDiag( + DE.DiagnosticID)); // Format the message. SmallString<100> MessageStr; @@ -160,4 +161,3 @@ void LogDiagnosticPrinter::HandleDiagnostic(DiagnosticsEngine::Level Level, // Record the diagnostic entry. Entries.push_back(DE); } - diff --git clang/lib/Frontend/SerializedDiagnosticPrinter.cpp clang/lib/Frontend/SerializedDiagnosticPrinter.cpp index 131334269aa7..02aa3e8e4d98 100644 --- clang/lib/Frontend/SerializedDiagnosticPrinter.cpp +++ clang/lib/Frontend/SerializedDiagnosticPrinter.cpp @@ -202,7 +202,7 @@ private: /// Emit the string information for diagnostic flags. unsigned getEmitDiagnosticFlag(DiagnosticsEngine::Level DiagLevel, - unsigned DiagID = 0); + const Diagnostic *Diag = nullptr); unsigned getEmitDiagnosticFlag(StringRef DiagName); @@ -536,11 +536,13 @@ unsigned SDiagsWriter::getEmitCategory(unsigned int category) { } unsigned SDiagsWriter::getEmitDiagnosticFlag(DiagnosticsEngine::Level DiagLevel, - unsigned DiagID) { - if (DiagLevel == DiagnosticsEngine::Note) + const Diagnostic *Diag) { + if (!Diag || DiagLevel == DiagnosticsEngine::Note) return 0; // No flag for notes. - StringRef FlagName = DiagnosticIDs::getWarningOptionForDiag(DiagID); + StringRef FlagName = + Diag->getDiags()->getDiagnosticIDs()->getWarningOptionForDiag( + Diag->getID()); return getEmitDiagnosticFlag(FlagName); } @@ -655,7 +657,7 @@ void SDiagsWriter::EmitDiagnosticMessage(FullSourceLoc Loc, PresumedLoc PLoc, unsigned DiagID = DiagnosticIDs::getCategoryNumberForDiag(Info->getID()); Record.push_back(getEmitCategory(DiagID)); // Emit the diagnostic flag string lazily and get the mapped ID. - Record.push_back(getEmitDiagnosticFlag(Level, Info->getID())); + Record.push_back(getEmitDiagnosticFlag(Level, Info)); } else { Record.push_back(getEmitCategory()); Record.push_back(getEmitDiagnosticFlag(Level)); diff --git clang/lib/Frontend/TextDiagnosticPrinter.cpp clang/lib/Frontend/TextDiagnosticPrinter.cpp index dac5c44fe925..28f7218dc23f 100644 --- clang/lib/Frontend/TextDiagnosticPrinter.cpp +++ clang/lib/Frontend/TextDiagnosticPrinter.cpp @@ -70,13 +70,17 @@ static void printDiagnosticOptions(raw_ostream &OS, // flag it as such. Note that diagnostics could also have been mapped by a // pragma, but we don't currently have a way to distinguish this. if (Level == DiagnosticsEngine::Error && - DiagnosticIDs::isBuiltinWarningOrExtension(Info.getID()) && - !DiagnosticIDs::isDefaultMappingAsError(Info.getID())) { + Info.getDiags()->getDiagnosticIDs()->isWarningOrExtension( + Info.getID()) && + !Info.getDiags()->getDiagnosticIDs()->isDefaultMappingAsError( + Info.getID())) { OS << " [-Werror"; Started = true; } - StringRef Opt = DiagnosticIDs::getWarningOptionForDiag(Info.getID()); + StringRef Opt = + Info.getDiags()->getDiagnosticIDs()->getWarningOptionForDiag( + Info.getID()); if (!Opt.empty()) { OS << (Started ? "," : " [") << (Level == DiagnosticsEngine::Remark ? "-R" : "-W") << Opt; diff --git clang/lib/FrontendTool/CMakeLists.txt clang/lib/FrontendTool/CMakeLists.txt index bfc7652b4c11..d7a3699361f0 100644 --- clang/lib/FrontendTool/CMakeLists.txt +++ clang/lib/FrontendTool/CMakeLists.txt @@ -21,12 +21,6 @@ if(CLANG_ENABLE_CIR) ) endif() -if(CLANG_ENABLE_ARCMT) - list(APPEND link_libs - clangARCMigrate - ) -endif() - if(CLANG_ENABLE_STATIC_ANALYZER) list(APPEND link_libs clangStaticAnalyzerFrontend diff --git clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp index 3f95a1efb2ee..079bcd93d616 100644 --- clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -11,7 +11,6 @@ // //===----------------------------------------------------------------------===// -#include "clang/ARCMigrate/ARCMTActions.h" #include "clang/CodeGen/CodeGenAction.h" #include "clang/Config/config.h" #include "clang/Driver/Options.h" @@ -131,12 +130,6 @@ CreateFrontendBaseAction(CompilerInstance &CI) { #else case RewriteObjC: Action = "RewriteObjC"; break; #endif -#if CLANG_ENABLE_ARCMT - case MigrateSource: - return std::make_unique<arcmt::MigrateSourceAction>(); -#else - case MigrateSource: Action = "MigrateSource"; break; -#endif #if CLANG_ENABLE_STATIC_ANALYZER case RunAnalysis: return std::make_unique<ento::AnalysisAction>(); #else @@ -147,8 +140,7 @@ CreateFrontendBaseAction(CompilerInstance &CI) { return std::make_unique<PrintDependencyDirectivesSourceMinimizerAction>(); } -#if !CLANG_ENABLE_ARCMT || !CLANG_ENABLE_STATIC_ANALYZER \ - || !CLANG_ENABLE_OBJC_REWRITER +#if !CLANG_ENABLE_STATIC_ANALYZER || !CLANG_ENABLE_OBJC_REWRITER CI.getDiagnostics().Report(diag::err_fe_action_not_available) << Action; return 0; #else @@ -169,35 +161,6 @@ CreateFrontendAction(CompilerInstance &CI) { Act = std::make_unique<FixItRecompile>(std::move(Act)); } -#if CLANG_ENABLE_ARCMT - if (CI.getFrontendOpts().ProgramAction != frontend::MigrateSource && - CI.getFrontendOpts().ProgramAction != frontend::GeneratePCH) { - // Potentially wrap the base FE action in an ARC Migrate Tool action. - switch (FEOpts.ARCMTAction) { - case FrontendOptions::ARCMT_None: - break; - case FrontendOptions::ARCMT_Check: - Act = std::make_unique<arcmt::CheckAction>(std::move(Act)); - break; - case FrontendOptions::ARCMT_Modify: - Act = std::make_unique<arcmt::ModifyAction>(std::move(Act)); - break; - case FrontendOptions::ARCMT_Migrate: - Act = std::make_unique<arcmt::MigrateAction>(std::move(Act), - FEOpts.MTMigrateDir, - FEOpts.ARCMTMigrateReportOut, - FEOpts.ARCMTMigrateEmitARCErrors); - break; - } - - if (FEOpts.ObjCMTAction != FrontendOptions::ObjCMT_None) { - Act = std::make_unique<arcmt::ObjCMigrateAction>(std::move(Act), - FEOpts.MTMigrateDir, - FEOpts.ObjCMTAction); - } - } -#endif - // Wrap the base FE action in an extract api action to generate // symbol graph as a biproduct of compilation (enabled with // --emit-symbol-graph option) diff --git clang/lib/Headers/amdgpuintrin.h clang/lib/Headers/amdgpuintrin.h index 720674a85f52..038605605462 100644 --- clang/lib/Headers/amdgpuintrin.h +++ clang/lib/Headers/amdgpuintrin.h @@ -158,16 +158,16 @@ __gpu_shuffle_idx_u64(uint64_t __lane_mask, uint32_t __idx, uint64_t __x) { ((uint64_t)__builtin_amdgcn_ds_bpermute(__idx << 2, __lo)); } -// Returns true if the flat pointer points to CUDA 'shared' memory. +// Returns true if the flat pointer points to AMDGPU 'shared' memory. _DEFAULT_FN_ATTRS static __inline__ bool __gpu_is_ptr_local(void *ptr) { - return __builtin_amdgcn_is_shared((void __attribute__((address_space(0))) *)(( + return __builtin_amdgcn_is_shared((void [[clang::address_space(0)]] *)(( void [[clang::opencl_generic]] *)ptr)); } -// Returns true if the flat pointer points to CUDA 'local' memory. +// Returns true if the flat pointer points to AMDGPU 'private' memory. _DEFAULT_FN_ATTRS static __inline__ bool __gpu_is_ptr_private(void *ptr) { - return __builtin_amdgcn_is_private((void __attribute__(( - address_space(0))) *)((void [[clang::opencl_generic]] *)ptr)); + return __builtin_amdgcn_is_private((void [[clang::address_space(0)]] *)(( + void [[clang::opencl_generic]] *)ptr)); } // Terminates execution of the associated wavefront. diff --git clang/lib/Headers/amxtf32transposeintrin.h clang/lib/Headers/amxtf32transposeintrin.h index 60336f953ecb..e1b90c1adfb2 100644 --- clang/lib/Headers/amxtf32transposeintrin.h +++ clang/lib/Headers/amxtf32transposeintrin.h @@ -8,7 +8,7 @@ */ #ifndef __IMMINTRIN_H #error \ - "Never use <amxtf32tranposeintrin.h> directly; include <immintrin.h> instead." + "Never use <amxtf32transposeintrin.h> directly; include <immintrin.h> instead." #endif // __IMMINTRIN_H #ifndef __AMX_TF32TRANSPOSEINTRIN_H diff --git clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/lib/Headers/hlsl/hlsl_intrinsics.h index d1e4eb08aa76..d1f5fdff8b60 100644 --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -2468,6 +2468,105 @@ __attribute__((convergent)) double3 WaveReadLaneAt(double3, int32_t); _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) __attribute__((convergent)) double4 WaveReadLaneAt(double4, int32_t); +//===----------------------------------------------------------------------===// +// WaveActiveMax builtins +//===----------------------------------------------------------------------===// + +_HLSL_16BIT_AVAILABILITY(shadermodel, 6.0) +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) half WaveActiveMax(half); +_HLSL_16BIT_AVAILABILITY(shadermodel, 6.0) +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) half2 WaveActiveMax(half2); +_HLSL_16BIT_AVAILABILITY(shadermodel, 6.0) +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) half3 WaveActiveMax(half3); +_HLSL_16BIT_AVAILABILITY(shadermodel, 6.0) +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) half4 WaveActiveMax(half4); + +#ifdef __HLSL_ENABLE_16_BIT +_HLSL_AVAILABILITY(shadermodel, 6.0) +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) int16_t WaveActiveMax(int16_t); +_HLSL_AVAILABILITY(shadermodel, 6.0) +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) int16_t2 WaveActiveMax(int16_t2); +_HLSL_AVAILABILITY(shadermodel, 6.0) +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) int16_t3 WaveActiveMax(int16_t3); +_HLSL_AVAILABILITY(shadermodel, 6.0) +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) int16_t4 WaveActiveMax(int16_t4); + +_HLSL_AVAILABILITY(shadermodel, 6.0) +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) uint16_t WaveActiveMax(uint16_t); +_HLSL_AVAILABILITY(shadermodel, 6.0) +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) uint16_t2 WaveActiveMax(uint16_t2); +_HLSL_AVAILABILITY(shadermodel, 6.0) +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) uint16_t3 WaveActiveMax(uint16_t3); +_HLSL_AVAILABILITY(shadermodel, 6.0) +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) uint16_t4 WaveActiveMax(uint16_t4); +#endif + +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) int WaveActiveMax(int); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) int2 WaveActiveMax(int2); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) int3 WaveActiveMax(int3); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) int4 WaveActiveMax(int4); + +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) uint WaveActiveMax(uint); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) uint2 WaveActiveMax(uint2); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) uint3 WaveActiveMax(uint3); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) uint4 WaveActiveMax(uint4); + +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) int64_t WaveActiveMax(int64_t); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) int64_t2 WaveActiveMax(int64_t2); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) int64_t3 WaveActiveMax(int64_t3); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) int64_t4 WaveActiveMax(int64_t4); + +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) uint64_t WaveActiveMax(uint64_t); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) uint64_t2 WaveActiveMax(uint64_t2); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) uint64_t3 WaveActiveMax(uint64_t3); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) uint64_t4 WaveActiveMax(uint64_t4); + +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) float WaveActiveMax(float); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) float2 WaveActiveMax(float2); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) float3 WaveActiveMax(float3); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) float4 WaveActiveMax(float4); + +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) double WaveActiveMax(double); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) double2 WaveActiveMax(double2); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) double3 WaveActiveMax(double3); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_max) +__attribute__((convergent)) double4 WaveActiveMax(double4); + //===----------------------------------------------------------------------===// // WaveActiveSum builtins //===----------------------------------------------------------------------===// diff --git clang/lib/Headers/nvptxintrin.h clang/lib/Headers/nvptxintrin.h index 962dca9cf031..fb2864eab6a0 100644 --- clang/lib/Headers/nvptxintrin.h +++ clang/lib/Headers/nvptxintrin.h @@ -151,9 +151,7 @@ _DEFAULT_FN_ATTRS static __inline__ void __gpu_sync_lane(uint64_t __lane_mask) { _DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_shuffle_idx_u32(uint64_t __lane_mask, uint32_t __idx, uint32_t __x) { uint32_t __mask = (uint32_t)__lane_mask; - uint32_t __bitmask = (__mask >> __idx) & 1u; - return -__bitmask & - __nvvm_shfl_sync_idx_i32(__mask, __x, __idx, __gpu_num_lanes() - 1u); + return __nvvm_shfl_sync_idx_i32(__mask, __x, __idx, __gpu_num_lanes() - 1u); } // Shuffles the the lanes inside the warp according to the given index. @@ -162,10 +160,9 @@ __gpu_shuffle_idx_u64(uint64_t __lane_mask, uint32_t __idx, uint64_t __x) { uint32_t __hi = (uint32_t)(__x >> 32ull); uint32_t __lo = (uint32_t)(__x & 0xFFFFFFFF); uint32_t __mask = (uint32_t)__lane_mask; - uint64_t __bitmask = (__mask >> __idx) & 1u; - return -__bitmask & ((uint64_t)__nvvm_shfl_sync_idx_i32( - __mask, __hi, __idx, __gpu_num_lanes() - 1u) - << 32ull) | + return ((uint64_t)__nvvm_shfl_sync_idx_i32(__mask, __hi, __idx, + __gpu_num_lanes() - 1u) + << 32ull) | ((uint64_t)__nvvm_shfl_sync_idx_i32(__mask, __lo, __idx, __gpu_num_lanes() - 1u)); } diff --git clang/lib/Lex/PPMacroExpansion.cpp clang/lib/Lex/PPMacroExpansion.cpp index 9cf29668f251..347c13da0ad2 100644 --- clang/lib/Lex/PPMacroExpansion.cpp +++ clang/lib/Lex/PPMacroExpansion.cpp @@ -1804,9 +1804,8 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { diag::err_feature_check_malformed); if (!II) return false; - auto BuiltinID = II->getBuiltinID(); - if (BuiltinID != 0) { - switch (BuiltinID) { + else if (II->getBuiltinID() != 0) { + switch (II->getBuiltinID()) { case Builtin::BI__builtin_cpu_is: return getTargetInfo().supportsCpuIs(); case Builtin::BI__builtin_cpu_init: @@ -1819,11 +1818,8 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { // usual allocation and deallocation functions. Required by libc++ return 201802; default: - // __has_builtin should return false for aux builtins. - if (getBuiltinInfo().isAuxBuiltinID(BuiltinID)) - return false; return Builtin::evaluateRequiredTargetFeatures( - getBuiltinInfo().getRequiredFeatures(BuiltinID), + getBuiltinInfo().getRequiredFeatures(II->getBuiltinID()), getTargetInfo().getTargetOpts().FeatureMap); } return true; diff --git clang/lib/Parse/ParseDecl.cpp clang/lib/Parse/ParseDecl.cpp index f136d5007e8a..75b5e11f8327 100644 --- clang/lib/Parse/ParseDecl.cpp +++ clang/lib/Parse/ParseDecl.cpp @@ -7315,15 +7315,16 @@ void Parser::ParseDecompositionDeclarator(Declarator &D) { // If this doesn't look like a structured binding, maybe it's a misplaced // array declarator. - if (!(Tok.is(tok::identifier) && + if (!(Tok.isOneOf(tok::identifier, tok::ellipsis) && NextToken().isOneOf(tok::comma, tok::r_square, tok::kw_alignas, - tok::l_square)) && + tok::identifier, tok::l_square, tok::ellipsis)) && !(Tok.is(tok::r_square) && NextToken().isOneOf(tok::equal, tok::l_brace))) { PA.Revert(); return ParseMisplacedBracketDeclarator(D); } + SourceLocation PrevEllipsisLoc; SmallVector<DecompositionDeclarator::Binding, 32> Bindings; while (Tok.isNot(tok::r_square)) { if (!Bindings.empty()) { @@ -7338,11 +7339,11 @@ void Parser::ParseDecompositionDeclarator(Declarator &D) { Diag(Tok, diag::err_expected_comma_or_rsquare); } - SkipUntil(tok::r_square, tok::comma, tok::identifier, + SkipUntil({tok::r_square, tok::comma, tok::identifier, tok::ellipsis}, StopAtSemi | StopBeforeMatch); if (Tok.is(tok::comma)) ConsumeToken(); - else if (Tok.isNot(tok::identifier)) + else if (Tok.is(tok::r_square)) break; } } @@ -7350,6 +7351,21 @@ void Parser::ParseDecompositionDeclarator(Declarator &D) { if (isCXX11AttributeSpecifier()) DiagnoseAndSkipCXX11Attributes(); + SourceLocation EllipsisLoc; + + if (Tok.is(tok::ellipsis)) { + Diag(Tok, getLangOpts().CPlusPlus26 ? diag::warn_cxx23_compat_binding_pack + : diag::ext_cxx_binding_pack); + if (PrevEllipsisLoc.isValid()) { + Diag(Tok, diag::err_binding_multiple_ellipses); + Diag(PrevEllipsisLoc, diag::note_previous_ellipsis); + break; + } + EllipsisLoc = Tok.getLocation(); + PrevEllipsisLoc = EllipsisLoc; + ConsumeToken(); + } + if (Tok.isNot(tok::identifier)) { Diag(Tok, diag::err_expected) << tok::identifier; break; @@ -7359,6 +7375,13 @@ void Parser::ParseDecompositionDeclarator(Declarator &D) { SourceLocation Loc = Tok.getLocation(); ConsumeToken(); + if (Tok.is(tok::ellipsis) && !PrevEllipsisLoc.isValid()) { + DiagnoseMisplacedEllipsis(Tok.getLocation(), Loc, EllipsisLoc.isValid(), + true); + EllipsisLoc = Tok.getLocation(); + ConsumeToken(); + } + ParsedAttributes Attrs(AttrFactory); if (isCXX11AttributeSpecifier()) { Diag(Tok, getLangOpts().CPlusPlus26 @@ -7367,7 +7390,7 @@ void Parser::ParseDecompositionDeclarator(Declarator &D) { MaybeParseCXX11Attributes(Attrs); } - Bindings.push_back({II, Loc, std::move(Attrs)}); + Bindings.push_back({II, Loc, std::move(Attrs), EllipsisLoc}); } if (Tok.isNot(tok::r_square)) diff --git clang/lib/Sema/HeuristicResolver.cpp clang/lib/Sema/HeuristicResolver.cpp index 87c7274e7aef..0c57250e63df 100644 --- clang/lib/Sema/HeuristicResolver.cpp +++ clang/lib/Sema/HeuristicResolver.cpp @@ -71,8 +71,17 @@ private: // Helper function for HeuristicResolver::resolveDependentMember() // which takes a possibly-dependent type `T` and heuristically - // resolves it to a CXXRecordDecl in which we can try name lookup. - CXXRecordDecl *resolveTypeToRecordDecl(const Type *T); + // resolves it to a TagDecl in which we can try name lookup. + TagDecl *resolveTypeToTagDecl(const Type *T); + + // Helper function for simplifying a type. + // `Type` is the type to simplify. + // `E` is the expression whose type `Type` is, if known. This sometimes + // contains information relevant to the type that's not stored in `Type` + // itself. + // If `UnwrapPointer` is true, exactly only pointer type will be unwrapped + // during simplification, and the operation fails if no pointer type is found. + QualType simplifyType(QualType Type, const Expr *E, bool UnwrapPointer); // This is a reimplementation of CXXRecordDecl::lookupDependentName() // so that the implementation can call into other HeuristicResolver helpers. @@ -130,7 +139,7 @@ TemplateName getReferencedTemplateName(const Type *T) { // Helper function for HeuristicResolver::resolveDependentMember() // which takes a possibly-dependent type `T` and heuristically // resolves it to a CXXRecordDecl in which we can try name lookup. -CXXRecordDecl *HeuristicResolverImpl::resolveTypeToRecordDecl(const Type *T) { +TagDecl *HeuristicResolverImpl::resolveTypeToTagDecl(const Type *T) { assert(T); // Unwrap type sugar such as type aliases. @@ -144,8 +153,9 @@ CXXRecordDecl *HeuristicResolverImpl::resolveTypeToRecordDecl(const Type *T) { T = T->getCanonicalTypeInternal().getTypePtr(); } - if (const auto *RT = T->getAs<RecordType>()) - return dyn_cast<CXXRecordDecl>(RT->getDecl()); + if (auto *TT = T->getAs<TagType>()) { + return TT->getDecl(); + } if (const auto *ICNT = T->getAs<InjectedClassNameType>()) T = ICNT->getInjectedSpecializationType().getTypePtrOrNull(); @@ -197,6 +207,57 @@ QualType HeuristicResolverImpl::getPointeeType(QualType T) { return FirstArg.getAsType(); } +QualType HeuristicResolverImpl::simplifyType(QualType Type, const Expr *E, + bool UnwrapPointer) { + bool DidUnwrapPointer = false; + auto SimplifyOneStep = [&](QualType T) { + if (UnwrapPointer) { + if (QualType Pointee = getPointeeType(T); !Pointee.isNull()) { + DidUnwrapPointer = true; + return Pointee; + } + } + if (const auto *RT = T->getAs<ReferenceType>()) { + // Does not count as "unwrap pointer". + return RT->getPointeeType(); + } + if (const auto *BT = T->getAs<BuiltinType>()) { + // If BaseType is the type of a dependent expression, it's just + // represented as BuiltinType::Dependent which gives us no information. We + // can get further by analyzing the dependent expression. + if (E && BT->getKind() == BuiltinType::Dependent) { + return resolveExprToType(E); + } + } + if (const auto *AT = T->getContainedAutoType()) { + // If T contains a dependent `auto` type, deduction will not have + // been performed on it yet. In simple cases (e.g. `auto` variable with + // initializer), get the approximate type that would result from + // deduction. + // FIXME: A more accurate implementation would propagate things like the + // `const` in `const auto`. + if (E && AT->isUndeducedAutoType()) { + if (const auto *DRE = dyn_cast<DeclRefExpr>(E)) { + if (const auto *VD = dyn_cast<VarDecl>(DRE->getDecl())) { + if (VD->hasInit()) + return resolveExprToType(VD->getInit()); + } + } + } + } + return T; + }; + while (!Type.isNull()) { + QualType New = SimplifyOneStep(Type); + if (New == Type) + break; + Type = New; + } + if (UnwrapPointer && !DidUnwrapPointer) + return QualType(); + return Type; +} + std::vector<const NamedDecl *> HeuristicResolverImpl::resolveMemberExpr( const CXXDependentScopeMemberExpr *ME) { // If the expression has a qualifier, try resolving the member inside the @@ -229,34 +290,7 @@ std::vector<const NamedDecl *> HeuristicResolverImpl::resolveMemberExpr( // Try resolving the member inside the expression's base type. Expr *Base = ME->isImplicitAccess() ? nullptr : ME->getBase(); QualType BaseType = ME->getBaseType(); - if (ME->isArrow()) { - BaseType = getPointeeType(BaseType); - } - if (BaseType.isNull()) - return {}; - if (const auto *BT = BaseType->getAs<BuiltinType>()) { - // If BaseType is the type of a dependent expression, it's just - // represented as BuiltinType::Dependent which gives us no information. We - // can get further by analyzing the dependent expression. - if (Base && BT->getKind() == BuiltinType::Dependent) { - BaseType = resolveExprToType(Base); - } - } - if (const auto *AT = BaseType->getContainedAutoType()) { - // If BaseType contains a dependent `auto` type, deduction will not have - // been performed on it yet. In simple cases (e.g. `auto` variable with - // initializer), get the approximate type that would result from deduction. - // FIXME: A more accurate implementation would propagate things like the - // `const` in `const auto`. - if (AT->isUndeducedAutoType()) { - if (const auto *DRE = dyn_cast<DeclRefExpr>(Base)) { - if (const auto *VD = dyn_cast<VarDecl>(DRE->getDecl())) { - if (VD->hasInit()) - BaseType = resolveExprToType(VD->getInit()); - } - } - } - } + BaseType = simplifyType(BaseType, Base, ME->isArrow()); return resolveDependentMember(BaseType, ME->getMember(), NoFilter); } @@ -276,7 +310,7 @@ HeuristicResolverImpl::resolveTypeOfCallExpr(const CallExpr *CE) { CalleeType = FnTypePtr->getPointeeType(); if (const FunctionType *FnType = CalleeType->getAs<FunctionType>()) { if (const auto *D = - resolveTypeToRecordDecl(FnType->getReturnType().getTypePtr())) { + resolveTypeToTagDecl(FnType->getReturnType().getTypePtr())) { return {D}; } } @@ -387,11 +421,11 @@ bool findOrdinaryMember(const CXXRecordDecl *RD, CXXBasePath &Path, bool HeuristicResolverImpl::findOrdinaryMemberInDependentClasses( const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name) { - CXXRecordDecl *RD = - resolveTypeToRecordDecl(Specifier->getType().getTypePtr()); - if (!RD) - return false; - return findOrdinaryMember(RD, Path, Name); + TagDecl *TD = resolveTypeToTagDecl(Specifier->getType().getTypePtr()); + if (const auto *RD = dyn_cast_if_present<CXXRecordDecl>(TD)) { + return findOrdinaryMember(RD, Path, Name); + } + return false; } std::vector<const NamedDecl *> HeuristicResolverImpl::lookupDependentName( @@ -433,11 +467,14 @@ std::vector<const NamedDecl *> HeuristicResolverImpl::resolveDependentMember( const Type *T = QT.getTypePtrOrNull(); if (!T) return {}; - if (auto *ET = T->getAs<EnumType>()) { - auto Result = ET->getDecl()->lookup(Name); + TagDecl *TD = resolveTypeToTagDecl(T); + if (!TD) + return {}; + if (auto *ED = dyn_cast<EnumDecl>(TD)) { + auto Result = ED->lookup(Name); return {Result.begin(), Result.end()}; } - if (auto *RD = resolveTypeToRecordDecl(T)) { + if (auto *RD = dyn_cast<CXXRecordDecl>(TD)) { if (!RD->hasDefinition()) return {}; RD = RD->getDefinition(); diff --git clang/lib/Sema/Sema.cpp clang/lib/Sema/Sema.cpp index abb46d3a84e7..9507d7602aa4 100644 --- clang/lib/Sema/Sema.cpp +++ clang/lib/Sema/Sema.cpp @@ -1679,7 +1679,7 @@ void Sema::EmitDiagnostic(unsigned DiagID, const DiagnosticBuilder &DB) { // that is different from the last template instantiation where // we emitted an error, print a template instantiation // backtrace. - if (!DiagnosticIDs::isBuiltinNote(DiagID)) + if (!Diags.getDiagnosticIDs()->isNote(DiagID)) PrintContextStack(); } @@ -1693,7 +1693,8 @@ bool Sema::hasUncompilableErrorOccurred() const { if (Loc == DeviceDeferredDiags.end()) return false; for (auto PDAt : Loc->second) { - if (DiagnosticIDs::isDefaultMappingAsError(PDAt.second.getDiagID())) + if (Diags.getDiagnosticIDs()->isDefaultMappingAsError( + PDAt.second.getDiagID())) return true; } return false; diff --git clang/lib/Sema/SemaARM.cpp clang/lib/Sema/SemaARM.cpp index db418d80e0e0..71dfe68f104e 100644 --- clang/lib/Sema/SemaARM.cpp +++ clang/lib/Sema/SemaARM.cpp @@ -352,6 +352,8 @@ static QualType getNeonEltType(NeonTypeFlags Flags, ASTContext &Context, return Context.DoubleTy; case NeonTypeFlags::BFloat16: return Context.BFloat16Ty; + case NeonTypeFlags::MFloat8: + return Context.MFloat8Ty; } llvm_unreachable("Invalid NeonTypeFlag!"); } @@ -622,20 +624,6 @@ static bool checkArmStreamingBuiltin(Sema &S, CallExpr *TheCall, return true; } -static bool hasArmZAState(const FunctionDecl *FD) { - const auto *T = FD->getType()->getAs<FunctionProtoType>(); - return (T && FunctionType::getArmZAState(T->getAArch64SMEAttributes()) != - FunctionType::ARM_None) || - (FD->hasAttr<ArmNewAttr>() && FD->getAttr<ArmNewAttr>()->isNewZA()); -} - -static bool hasArmZT0State(const FunctionDecl *FD) { - const auto *T = FD->getType()->getAs<FunctionProtoType>(); - return (T && FunctionType::getArmZT0State(T->getAArch64SMEAttributes()) != - FunctionType::ARM_None) || - (FD->hasAttr<ArmNewAttr>() && FD->getAttr<ArmNewAttr>()->isNewZT0()); -} - static ArmSMEState getSMEState(unsigned BuiltinID) { switch (BuiltinID) { default: @@ -648,7 +636,8 @@ static ArmSMEState getSMEState(unsigned BuiltinID) { bool SemaARM::CheckSMEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { - if (const FunctionDecl *FD = SemaRef.getCurFunctionDecl()) { + if (const FunctionDecl *FD = + SemaRef.getCurFunctionDecl(/*AllowLambda=*/true)) { std::optional<ArmStreamingType> BuiltinType; switch (BuiltinID) { @@ -688,7 +677,8 @@ bool SemaARM::CheckSMEBuiltinFunctionCall(unsigned BuiltinID, bool SemaARM::CheckSVEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { - if (const FunctionDecl *FD = SemaRef.getCurFunctionDecl()) { + if (const FunctionDecl *FD = + SemaRef.getCurFunctionDecl(/*AllowLambda=*/true)) { std::optional<ArmStreamingType> BuiltinType; switch (BuiltinID) { @@ -717,7 +707,8 @@ bool SemaARM::CheckSVEBuiltinFunctionCall(unsigned BuiltinID, bool SemaARM::CheckNeonBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, CallExpr *TheCall) { - if (const FunctionDecl *FD = SemaRef.getCurFunctionDecl()) { + if (const FunctionDecl *FD = + SemaRef.getCurFunctionDecl(/*AllowLambda=*/true)) { switch (BuiltinID) { default: diff --git clang/lib/Sema/SemaCUDA.cpp clang/lib/Sema/SemaCUDA.cpp index 35f28bf1bd61..0e1bf727d72d 100644 --- clang/lib/Sema/SemaCUDA.cpp +++ clang/lib/Sema/SemaCUDA.cpp @@ -833,7 +833,7 @@ SemaBase::SemaDiagnosticBuilder SemaCUDA::DiagIfDeviceCode(SourceLocation Loc, if (!getLangOpts().CUDAIsDevice) return SemaDiagnosticBuilder::K_Nop; if (SemaRef.IsLastErrorImmediate && - getDiagnostics().getDiagnosticIDs()->isBuiltinNote(DiagID)) + getDiagnostics().getDiagnosticIDs()->isNote(DiagID)) return SemaDiagnosticBuilder::K_Immediate; return (SemaRef.getEmissionStatus(CurFunContext) == Sema::FunctionEmissionStatus::Emitted) @@ -864,7 +864,7 @@ Sema::SemaDiagnosticBuilder SemaCUDA::DiagIfHostCode(SourceLocation Loc, if (getLangOpts().CUDAIsDevice) return SemaDiagnosticBuilder::K_Nop; if (SemaRef.IsLastErrorImmediate && - getDiagnostics().getDiagnosticIDs()->isBuiltinNote(DiagID)) + getDiagnostics().getDiagnosticIDs()->isNote(DiagID)) return SemaDiagnosticBuilder::K_Immediate; return (SemaRef.getEmissionStatus(CurFunContext) == Sema::FunctionEmissionStatus::Emitted) diff --git clang/lib/Sema/SemaChecking.cpp clang/lib/Sema/SemaChecking.cpp index e440f60526bb..61b2c8cf1cad 100644 --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -14649,11 +14649,23 @@ void Sema::CheckAddressOfPackedMember(Expr *rhs) { _2, _3, _4)); } +// Performs a similar job to Sema::UsualUnaryConversions, but without any +// implicit promotion of integral/enumeration types. +static ExprResult BuiltinVectorMathConversions(Sema &S, Expr *E) { + // First, convert to an r-value. + ExprResult Res = S.DefaultFunctionArrayLvalueConversion(E); + if (Res.isInvalid()) + return ExprError(); + + // Promote floating-point types. + return S.UsualUnaryFPConversions(Res.get()); +} + bool Sema::PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall) { if (checkArgCount(TheCall, 1)) return true; - ExprResult A = UsualUnaryConversions(TheCall->getArg(0)); + ExprResult A = BuiltinVectorMathConversions(*this, TheCall->getArg(0)); if (A.isInvalid()) return true; @@ -14668,57 +14680,77 @@ bool Sema::PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall) { } bool Sema::BuiltinElementwiseMath(CallExpr *TheCall, bool FPOnly) { - QualType Res; - if (BuiltinVectorMath(TheCall, Res, FPOnly)) - return true; - TheCall->setType(Res); - return false; + if (auto Res = BuiltinVectorMath(TheCall, FPOnly); Res.has_value()) { + TheCall->setType(*Res); + return false; + } + return true; } bool Sema::BuiltinVectorToScalarMath(CallExpr *TheCall) { - QualType Res; - if (BuiltinVectorMath(TheCall, Res)) + std::optional<QualType> Res = BuiltinVectorMath(TheCall); + if (!Res) return true; - if (auto *VecTy0 = Res->getAs<VectorType>()) + if (auto *VecTy0 = (*Res)->getAs<VectorType>()) TheCall->setType(VecTy0->getElementType()); else - TheCall->setType(Res); + TheCall->setType(*Res); return false; } -bool Sema::BuiltinVectorMath(CallExpr *TheCall, QualType &Res, bool FPOnly) { +static bool checkBuiltinVectorMathMixedEnums(Sema &S, Expr *LHS, Expr *RHS, + SourceLocation Loc) { + QualType L = LHS->getEnumCoercedType(S.Context), + R = RHS->getEnumCoercedType(S.Context); + if (L->isUnscopedEnumerationType() && R->isUnscopedEnumerationType() && + !S.Context.hasSameUnqualifiedType(L, R)) { + return S.Diag(Loc, diag::err_conv_mixed_enum_types_cxx26) + << LHS->getSourceRange() << RHS->getSourceRange() + << /*Arithmetic Between*/ 0 << L << R; + } + return false; +} + +std::optional<QualType> Sema::BuiltinVectorMath(CallExpr *TheCall, + bool FPOnly) { if (checkArgCount(TheCall, 2)) - return true; + return std::nullopt; - ExprResult A = TheCall->getArg(0); - ExprResult B = TheCall->getArg(1); - // Do standard promotions between the two arguments, returning their common - // type. - Res = UsualArithmeticConversions(A, B, TheCall->getExprLoc(), ACK_Comparison); - if (A.isInvalid() || B.isInvalid()) - return true; + if (checkBuiltinVectorMathMixedEnums( + *this, TheCall->getArg(0), TheCall->getArg(1), TheCall->getExprLoc())) + return std::nullopt; - QualType TyA = A.get()->getType(); - QualType TyB = B.get()->getType(); + Expr *Args[2]; + for (int I = 0; I < 2; ++I) { + ExprResult Converted = + BuiltinVectorMathConversions(*this, TheCall->getArg(I)); + if (Converted.isInvalid()) + return std::nullopt; + Args[I] = Converted.get(); + } - if (Res.isNull() || TyA.getCanonicalType() != TyB.getCanonicalType()) - return Diag(A.get()->getBeginLoc(), - diag::err_typecheck_call_different_arg_types) - << TyA << TyB; + SourceLocation LocA = Args[0]->getBeginLoc(); + QualType TyA = Args[0]->getType(); + QualType TyB = Args[1]->getType(); + + if (TyA.getCanonicalType() != TyB.getCanonicalType()) { + Diag(LocA, diag::err_typecheck_call_different_arg_types) << TyA << TyB; + return std::nullopt; + } if (FPOnly) { - if (checkFPMathBuiltinElementType(*this, A.get()->getBeginLoc(), TyA, 1)) - return true; + if (checkFPMathBuiltinElementType(*this, LocA, TyA, 1)) + return std::nullopt; } else { - if (checkMathBuiltinElementType(*this, A.get()->getBeginLoc(), TyA, 1)) - return true; + if (checkMathBuiltinElementType(*this, LocA, TyA, 1)) + return std::nullopt; } - TheCall->setArg(0, A.get()); - TheCall->setArg(1, B.get()); - return false; + TheCall->setArg(0, Args[0]); + TheCall->setArg(1, Args[1]); + return TyA; } bool Sema::BuiltinElementwiseTernaryMath(CallExpr *TheCall, @@ -14726,9 +14758,17 @@ bool Sema::BuiltinElementwiseTernaryMath(CallExpr *TheCall, if (checkArgCount(TheCall, 3)) return true; + SourceLocation Loc = TheCall->getExprLoc(); + if (checkBuiltinVectorMathMixedEnums(*this, TheCall->getArg(0), + TheCall->getArg(1), Loc) || + checkBuiltinVectorMathMixedEnums(*this, TheCall->getArg(1), + TheCall->getArg(2), Loc)) + return true; + Expr *Args[3]; for (int I = 0; I < 3; ++I) { - ExprResult Converted = UsualUnaryConversions(TheCall->getArg(I)); + ExprResult Converted = + BuiltinVectorMathConversions(*this, TheCall->getArg(I)); if (Converted.isInvalid()) return true; Args[I] = Converted.get(); diff --git clang/lib/Sema/SemaCodeComplete.cpp clang/lib/Sema/SemaCodeComplete.cpp index bc0f6a9435f9..f10f7f4768f8 100644 --- clang/lib/Sema/SemaCodeComplete.cpp +++ clang/lib/Sema/SemaCodeComplete.cpp @@ -137,7 +137,7 @@ private: ~ShadowMapEntry() { if (DeclIndexPairVector *Vec = - DeclOrVector.dyn_cast<DeclIndexPairVector *>()) { + dyn_cast_if_present<DeclIndexPairVector *>(DeclOrVector)) { delete Vec; DeclOrVector = ((NamedDecl *)nullptr); } diff --git clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDecl.cpp index c3ff247a6316..3cad9827fdab 100644 --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -11380,8 +11380,11 @@ static bool CheckMultiVersionAdditionalRules(Sema &S, const FunctionDecl *OldFD, return true; // Only allow transition to MultiVersion if it hasn't been used. - if (OldFD && CausesMV && OldFD->isUsed(false)) - return S.Diag(NewFD->getLocation(), diag::err_multiversion_after_used); + if (OldFD && CausesMV && OldFD->isUsed(false)) { + S.Diag(NewFD->getLocation(), diag::err_multiversion_after_used); + S.Diag(OldFD->getLocation(), diag::note_previous_declaration); + return true; + } return S.areMultiversionVariantFunctionsCompatible( OldFD, NewFD, S.PDiag(diag::err_multiversion_noproto), @@ -16016,7 +16019,6 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, if (!FD->isDeletedAsWritten()) FD->setBody(Body); FD->setWillHaveBody(false); - CheckImmediateEscalatingFunctionDefinition(FD, FSI); if (getLangOpts().CPlusPlus14) { if (!FD->isInvalidDecl() && Body && !FD->isDependentContext() && @@ -16394,6 +16396,9 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, // the declaration context below. Otherwise, we're unable to transform // 'this' expressions when transforming immediate context functions. + if (FD) + CheckImmediateEscalatingFunctionDefinition(FD, getCurFunction()); + if (!IsInstantiation) PopDeclContext(); diff --git clang/lib/Sema/SemaDeclAttr.cpp clang/lib/Sema/SemaDeclAttr.cpp index c2d82b9aa9b3..9d7d22590bce 100644 --- clang/lib/Sema/SemaDeclAttr.cpp +++ clang/lib/Sema/SemaDeclAttr.cpp @@ -879,22 +879,38 @@ static void handleDiagnoseIfAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!checkFunctionConditionAttr(S, D, AL, Cond, Msg)) return; - StringRef DiagTypeStr; - if (!S.checkStringLiteralArgumentAttr(AL, 2, DiagTypeStr)) + StringRef DefaultSevStr; + if (!S.checkStringLiteralArgumentAttr(AL, 2, DefaultSevStr)) return; - DiagnoseIfAttr::DiagnosticType DiagType; - if (!DiagnoseIfAttr::ConvertStrToDiagnosticType(DiagTypeStr, DiagType)) { + DiagnoseIfAttr::DefaultSeverity DefaultSev; + if (!DiagnoseIfAttr::ConvertStrToDefaultSeverity(DefaultSevStr, DefaultSev)) { S.Diag(AL.getArgAsExpr(2)->getBeginLoc(), diag::err_diagnose_if_invalid_diagnostic_type); return; } + StringRef WarningGroup; + SmallVector<StringRef, 2> Options; + if (AL.getNumArgs() > 3) { + if (!S.checkStringLiteralArgumentAttr(AL, 3, WarningGroup)) + return; + if (WarningGroup.empty() || + !S.getDiagnostics().getDiagnosticIDs()->getGroupForWarningOption( + WarningGroup)) { + S.Diag(AL.getArgAsExpr(3)->getBeginLoc(), + diag::err_diagnose_if_unknown_warning) + << WarningGroup; + return; + } + } + bool ArgDependent = false; if (const auto *FD = dyn_cast<FunctionDecl>(D)) ArgDependent = ArgumentDependenceChecker(FD).referencesArgs(Cond); D->addAttr(::new (S.Context) DiagnoseIfAttr( - S.Context, AL, Cond, Msg, DiagType, ArgDependent, cast<NamedDecl>(D))); + S.Context, AL, Cond, Msg, DefaultSev, WarningGroup, ArgDependent, + cast<NamedDecl>(D))); } static void handleNoBuiltinAttr(Sema &S, Decl *D, const ParsedAttr &AL) { diff --git clang/lib/Sema/SemaDeclCXX.cpp clang/lib/Sema/SemaDeclCXX.cpp index 08065e3cad2b..0cf02fe6407c 100644 --- clang/lib/Sema/SemaDeclCXX.cpp +++ clang/lib/Sema/SemaDeclCXX.cpp @@ -888,7 +888,15 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D, Previous.clear(); } - auto *BD = BindingDecl::Create(Context, DC, B.NameLoc, VarName); + QualType QT; + if (B.EllipsisLoc.isValid()) { + if (!cast<Decl>(DC)->isTemplated()) + Diag(B.EllipsisLoc, diag::err_pack_outside_template); + QT = Context.getPackExpansionType(Context.DependentTy, std::nullopt, + /*ExpectsPackInType=*/false); + } + + auto *BD = BindingDecl::Create(Context, DC, B.NameLoc, B.Name, QT); ProcessDeclAttributeList(S, BD, *B.Attrs); @@ -951,20 +959,68 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D, return New; } +// Check the arity of the structured bindings. +// Create the resolved pack expr if needed. +static bool CheckBindingsCount(Sema &S, DecompositionDecl *DD, + QualType DecompType, + ArrayRef<BindingDecl *> Bindings, + unsigned MemberCount) { + auto BindingWithPackItr = + std::find_if(Bindings.begin(), Bindings.end(), + [](BindingDecl *D) -> bool { return D->isParameterPack(); }); + bool HasPack = BindingWithPackItr != Bindings.end(); + bool IsValid; + if (!HasPack) { + IsValid = Bindings.size() == MemberCount; + } else { + // There may not be more members than non-pack bindings. + IsValid = MemberCount >= Bindings.size() - 1; + } + + if (IsValid && HasPack) { + // Create the pack expr and assign it to the binding. + unsigned PackSize = MemberCount - Bindings.size() + 1; + QualType PackType = S.Context.getPackExpansionType( + S.Context.DependentTy, std::nullopt, /*ExpectsPackInType=*/false); + BindingDecl *BD = (*BindingWithPackItr); + auto *RP = ResolvedUnexpandedPackExpr::Create(S.Context, DD->getBeginLoc(), + DecompType, PackSize); + BD->setDecomposedDecl(DD); + BD->setBinding(PackType, RP); + + BindingDecl *BPack = *BindingWithPackItr; + // Create the nested BindingDecls. + for (Expr *&E : RP->getExprs()) { + auto *NestedBD = BindingDecl::Create(S.Context, BPack->getDeclContext(), + BPack->getLocation(), + BPack->getIdentifier(), QualType()); + NestedBD->setDecomposedDecl(DD); + E = S.BuildDeclRefExpr(NestedBD, S.Context.DependentTy, VK_LValue, + BPack->getLocation()); + } + } + + if (IsValid) + return false; + + S.Diag(DD->getLocation(), diag::err_decomp_decl_wrong_number_bindings) + << DecompType << (unsigned)Bindings.size() << MemberCount << MemberCount + << (MemberCount < Bindings.size()); + return true; +} + static bool checkSimpleDecomposition( Sema &S, ArrayRef<BindingDecl *> Bindings, ValueDecl *Src, - QualType DecompType, const llvm::APSInt &NumElems, QualType ElemType, + QualType DecompType, const llvm::APSInt &NumElemsAPS, QualType ElemType, llvm::function_ref<ExprResult(SourceLocation, Expr *, unsigned)> GetInit) { - if ((int64_t)Bindings.size() != NumElems) { - S.Diag(Src->getLocation(), diag::err_decomp_decl_wrong_number_bindings) - << DecompType << (unsigned)Bindings.size() - << (unsigned)NumElems.getLimitedValue(UINT_MAX) - << toString(NumElems, 10) << (NumElems < Bindings.size()); + unsigned NumElems = (unsigned)NumElemsAPS.getLimitedValue(UINT_MAX); + auto *DD = cast<DecompositionDecl>(Src); + + if (CheckBindingsCount(S, DD, DecompType, Bindings, NumElems)) return true; - } unsigned I = 0; - for (auto *B : Bindings) { + for (auto *B : DD->flat_bindings()) { SourceLocation Loc = B->getLocation(); ExprResult E = S.BuildDeclRefExpr(Src, DecompType, VK_LValue, Loc); if (E.isInvalid()) @@ -1210,13 +1266,10 @@ static bool checkTupleLikeDecomposition(Sema &S, ArrayRef<BindingDecl *> Bindings, VarDecl *Src, QualType DecompType, const llvm::APSInt &TupleSize) { - if ((int64_t)Bindings.size() != TupleSize) { - S.Diag(Src->getLocation(), diag::err_decomp_decl_wrong_number_bindings) - << DecompType << (unsigned)Bindings.size() - << (unsigned)TupleSize.getLimitedValue(UINT_MAX) - << toString(TupleSize, 10) << (TupleSize < Bindings.size()); + auto *DD = cast<DecompositionDecl>(Src); + unsigned NumElems = (unsigned)TupleSize.getLimitedValue(UINT_MAX); + if (CheckBindingsCount(S, DD, DecompType, Bindings, NumElems)) return true; - } if (Bindings.empty()) return false; @@ -1250,7 +1303,7 @@ static bool checkTupleLikeDecomposition(Sema &S, } unsigned I = 0; - for (auto *B : Bindings) { + for (auto *B : DD->flat_bindings()) { InitializingBinding InitContext(S, B); SourceLocation Loc = B->getLocation(); @@ -1433,20 +1486,18 @@ static bool checkMemberDecomposition(Sema &S, ArrayRef<BindingDecl*> Bindings, QualType BaseType = S.Context.getQualifiedType(S.Context.getRecordType(RD), DecompType.getQualifiers()); - auto DiagnoseBadNumberOfBindings = [&]() -> bool { - unsigned NumFields = llvm::count_if( - RD->fields(), [](FieldDecl *FD) { return !FD->isUnnamedBitField(); }); - assert(Bindings.size() != NumFields); - S.Diag(Src->getLocation(), diag::err_decomp_decl_wrong_number_bindings) - << DecompType << (unsigned)Bindings.size() << NumFields << NumFields - << (NumFields < Bindings.size()); + auto *DD = cast<DecompositionDecl>(Src); + unsigned NumFields = llvm::count_if( + RD->fields(), [](FieldDecl *FD) { return !FD->isUnnamedBitField(); }); + if (CheckBindingsCount(S, DD, DecompType, Bindings, NumFields)) return true; - }; // all of E's non-static data members shall be [...] well-formed // when named as e.name in the context of the structured binding, // E shall not have an anonymous union member, ... - unsigned I = 0; + auto FlatBindings = DD->flat_bindings(); + assert(llvm::range_size(FlatBindings) == NumFields); + auto FlatBindingsItr = FlatBindings.begin(); for (auto *FD : RD->fields()) { if (FD->isUnnamedBitField()) continue; @@ -1471,9 +1522,8 @@ static bool checkMemberDecomposition(Sema &S, ArrayRef<BindingDecl*> Bindings, } // We have a real field to bind. - if (I >= Bindings.size()) - return DiagnoseBadNumberOfBindings(); - auto *B = Bindings[I++]; + assert(FlatBindingsItr != FlatBindings.end()); + BindingDecl *B = *(FlatBindingsItr++); SourceLocation Loc = B->getLocation(); // The field must be accessible in the context of the structured binding. @@ -1511,9 +1561,6 @@ static bool checkMemberDecomposition(Sema &S, ArrayRef<BindingDecl*> Bindings, B->setBinding(S.BuildQualifiedType(FD->getType(), Loc, Q), E.get()); } - if (I != Bindings.size()) - return DiagnoseBadNumberOfBindings(); - return false; } @@ -1523,8 +1570,12 @@ void Sema::CheckCompleteDecompositionDeclaration(DecompositionDecl *DD) { // If the type of the decomposition is dependent, then so is the type of // each binding. if (DecompType->isDependentType()) { - for (auto *B : DD->bindings()) - B->setType(Context.DependentTy); + // Note that all of the types are still Null or PackExpansionType. + for (auto *B : DD->bindings()) { + // Do not overwrite any pack type. + if (B->getType().isNull()) + B->setType(Context.DependentTy); + } return; } @@ -3316,6 +3367,29 @@ void Sema::CheckShadowInheritedFields(const SourceLocation &Loc, } } +template <typename AttrType> +inline static bool HasAttribute(const QualType &T) { + if (const TagDecl *TD = T->getAsTagDecl()) + return TD->hasAttr<AttrType>(); + if (const TypedefType *TDT = T->getAs<TypedefType>()) + return TDT->getDecl()->hasAttr<AttrType>(); + return false; +} + +static bool IsUnusedPrivateField(const FieldDecl *FD) { + if (FD->getAccess() == AS_private && FD->getDeclName()) { + QualType FieldType = FD->getType(); + if (HasAttribute<WarnUnusedAttr>(FieldType)) + return true; + + return !FD->isImplicit() && !FD->hasAttr<UnusedAttr>() && + !FD->getParent()->isDependentContext() && + !HasAttribute<UnusedAttr>(FieldType) && + !InitializationHasSideEffects(*FD); + } + return false; +} + NamedDecl * Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, @@ -3598,25 +3672,11 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, FieldDecl *FD = cast<FieldDecl>(Member); FieldCollector->Add(FD); - if (!Diags.isIgnored(diag::warn_unused_private_field, FD->getLocation())) { + if (!Diags.isIgnored(diag::warn_unused_private_field, FD->getLocation()) && + IsUnusedPrivateField(FD)) { // Remember all explicit private FieldDecls that have a name, no side // effects and are not part of a dependent type declaration. - - auto DeclHasUnusedAttr = [](const QualType &T) { - if (const TagDecl *TD = T->getAsTagDecl()) - return TD->hasAttr<UnusedAttr>(); - if (const TypedefType *TDT = T->getAs<TypedefType>()) - return TDT->getDecl()->hasAttr<UnusedAttr>(); - return false; - }; - - if (!FD->isImplicit() && FD->getDeclName() && - FD->getAccess() == AS_private && - !FD->hasAttr<UnusedAttr>() && - !FD->getParent()->isDependentContext() && - !DeclHasUnusedAttr(FD->getType()) && - !InitializationHasSideEffects(*FD)) - UnusedPrivateFields.insert(FD); + UnusedPrivateFields.insert(FD); } } @@ -9235,7 +9295,7 @@ struct SpecialMemberVisitor { static SourceLocation getSubobjectLoc(Subobject Subobj) { // FIXME: For an indirect virtual base, the direct base leading to // the indirect virtual base would be a more useful choice. - if (auto *B = Subobj.dyn_cast<CXXBaseSpecifier*>()) + if (auto *B = dyn_cast<CXXBaseSpecifier *>(Subobj)) return B->getBaseTypeLoc(); else return cast<FieldDecl *>(Subobj)->getLocation(); @@ -13855,8 +13915,7 @@ void Sema::setupImplicitSpecialMemberType(CXXMethodDecl *SpecialMem, // During template instantiation of implicit special member functions we need // a reliable TypeSourceInfo for the function prototype in order to allow // functions to be substituted. - if (inTemplateInstantiation() && - cast<CXXRecordDecl>(SpecialMem->getParent())->isLambda()) { + if (inTemplateInstantiation() && isLambdaMethod(SpecialMem)) { TypeSourceInfo *TSI = Context.getTrivialTypeSourceInfo(SpecialMem->getType()); SpecialMem->setTypeSourceInfo(TSI); @@ -17525,7 +17584,7 @@ DeclResult Sema::ActOnTemplatedFriendTag( unsigned FriendDeclDepth = TempParamLists.front()->getDepth(); for (UnexpandedParameterPack &U : Unexpanded) { if (getDepthAndIndex(U).first >= FriendDeclDepth) { - auto *ND = U.first.dyn_cast<NamedDecl *>(); + auto *ND = dyn_cast<NamedDecl *>(U.first); if (!ND) ND = cast<const TemplateTypeParmType *>(U.first)->getDecl(); Diag(U.second, diag::friend_template_decl_malformed_pack_expansion) diff --git clang/lib/Sema/SemaExceptionSpec.cpp clang/lib/Sema/SemaExceptionSpec.cpp index 470d0d753b55..7b08a066d3cc 100644 --- clang/lib/Sema/SemaExceptionSpec.cpp +++ clang/lib/Sema/SemaExceptionSpec.cpp @@ -1068,7 +1068,7 @@ static CanThrowResult canVarDeclThrow(Sema &Self, const VarDecl *VD) { // If this is a decomposition declaration, bindings might throw. if (auto *DD = dyn_cast<DecompositionDecl>(VD)) - for (auto *B : DD->bindings()) + for (auto *B : DD->flat_bindings()) if (auto *HD = B->getHoldingVar()) CT = mergeCanThrow(CT, canVarDeclThrow(Self, HD)); @@ -1286,6 +1286,7 @@ CanThrowResult Sema::canThrow(const Stmt *S) { case Expr::ConvertVectorExprClass: case Expr::VAArgExprClass: case Expr::CXXParenListInitExprClass: + case Expr::ResolvedUnexpandedPackExprClass: return canSubStmtsThrow(*this, S); case Expr::CompoundLiteralExprClass: diff --git clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaExpr.cpp index d5273d463d7c..ba4aaa94b90f 100644 --- clang/lib/Sema/SemaExpr.cpp +++ clang/lib/Sema/SemaExpr.cpp @@ -776,20 +776,11 @@ ExprResult Sema::CallExprUnaryConversions(Expr *E) { return Res.get(); } -/// UsualUnaryConversions - Performs various conversions that are common to most -/// operators (C99 6.3). The conversions of array and function types are -/// sometimes suppressed. For example, the array->pointer conversion doesn't -/// apply if the array is an argument to the sizeof or address (&) operators. -/// In these instances, this routine should *not* be called. -ExprResult Sema::UsualUnaryConversions(Expr *E) { - // First, convert to an r-value. - ExprResult Res = DefaultFunctionArrayLvalueConversion(E); - if (Res.isInvalid()) - return ExprError(); - E = Res.get(); - +/// UsualUnaryFPConversions - Promotes floating-point types according to the +/// current language semantics. +ExprResult Sema::UsualUnaryFPConversions(Expr *E) { QualType Ty = E->getType(); - assert(!Ty.isNull() && "UsualUnaryConversions - missing type"); + assert(!Ty.isNull() && "UsualUnaryFPConversions - missing type"); LangOptions::FPEvalMethodKind EvalMethod = CurFPFeatures.getFPEvalMethod(); if (EvalMethod != LangOptions::FEM_Source && Ty->isFloatingType() && @@ -827,7 +818,30 @@ ExprResult Sema::UsualUnaryConversions(Expr *E) { // Half FP have to be promoted to float unless it is natively supported if (Ty->isHalfType() && !getLangOpts().NativeHalfType) - return ImpCastExprToType(Res.get(), Context.FloatTy, CK_FloatingCast); + return ImpCastExprToType(E, Context.FloatTy, CK_FloatingCast); + + return E; +} + +/// UsualUnaryConversions - Performs various conversions that are common to most +/// operators (C99 6.3). The conversions of array and function types are +/// sometimes suppressed. For example, the array->pointer conversion doesn't +/// apply if the array is an argument to the sizeof or address (&) operators. +/// In these instances, this routine should *not* be called. +ExprResult Sema::UsualUnaryConversions(Expr *E) { + // First, convert to an r-value. + ExprResult Res = DefaultFunctionArrayLvalueConversion(E); + if (Res.isInvalid()) + return ExprError(); + + // Promote floating-point types. + Res = UsualUnaryFPConversions(Res.get()); + if (Res.isInvalid()) + return ExprError(); + E = Res.get(); + + QualType Ty = E->getType(); + assert(!Ty.isNull() && "UsualUnaryConversions - missing type"); // Try to perform integral promotions if the object has a theoretically // promotable type. @@ -1489,9 +1503,9 @@ static QualType handleFixedPointConversion(Sema &S, QualType LHSTy, /// Check that the usual arithmetic conversions can be performed on this pair of /// expressions that might be of enumeration type. -static void checkEnumArithmeticConversions(Sema &S, Expr *LHS, Expr *RHS, - SourceLocation Loc, - Sema::ArithConvKind ACK) { +void Sema::checkEnumArithmeticConversions(Expr *LHS, Expr *RHS, + SourceLocation Loc, + Sema::ArithConvKind ACK) { // C++2a [expr.arith.conv]p1: // If one operand is of enumeration type and the other operand is of a // different enumeration type or a floating-point type, this behavior is @@ -1499,54 +1513,53 @@ static void checkEnumArithmeticConversions(Sema &S, Expr *LHS, Expr *RHS, // // Warn on this in all language modes. Produce a deprecation warning in C++20. // Eventually we will presumably reject these cases (in C++23 onwards?). - QualType L = LHS->getEnumCoercedType(S.Context), - R = RHS->getEnumCoercedType(S.Context); + QualType L = LHS->getEnumCoercedType(Context), + R = RHS->getEnumCoercedType(Context); bool LEnum = L->isUnscopedEnumerationType(), REnum = R->isUnscopedEnumerationType(); bool IsCompAssign = ACK == Sema::ACK_CompAssign; if ((!IsCompAssign && LEnum && R->isFloatingType()) || (REnum && L->isFloatingType())) { - S.Diag(Loc, S.getLangOpts().CPlusPlus26 - ? diag::err_arith_conv_enum_float_cxx26 - : S.getLangOpts().CPlusPlus20 - ? diag::warn_arith_conv_enum_float_cxx20 - : diag::warn_arith_conv_enum_float) + Diag(Loc, getLangOpts().CPlusPlus26 ? diag::err_arith_conv_enum_float_cxx26 + : getLangOpts().CPlusPlus20 + ? diag::warn_arith_conv_enum_float_cxx20 + : diag::warn_arith_conv_enum_float) << LHS->getSourceRange() << RHS->getSourceRange() << (int)ACK << LEnum << L << R; } else if (!IsCompAssign && LEnum && REnum && - !S.Context.hasSameUnqualifiedType(L, R)) { + !Context.hasSameUnqualifiedType(L, R)) { unsigned DiagID; // In C++ 26, usual arithmetic conversions between 2 different enum types // are ill-formed. - if (S.getLangOpts().CPlusPlus26) + if (getLangOpts().CPlusPlus26) DiagID = diag::err_conv_mixed_enum_types_cxx26; else if (!L->castAs<EnumType>()->getDecl()->hasNameForLinkage() || !R->castAs<EnumType>()->getDecl()->hasNameForLinkage()) { // If either enumeration type is unnamed, it's less likely that the // user cares about this, but this situation is still deprecated in // C++2a. Use a different warning group. - DiagID = S.getLangOpts().CPlusPlus20 - ? diag::warn_arith_conv_mixed_anon_enum_types_cxx20 - : diag::warn_arith_conv_mixed_anon_enum_types; + DiagID = getLangOpts().CPlusPlus20 + ? diag::warn_arith_conv_mixed_anon_enum_types_cxx20 + : diag::warn_arith_conv_mixed_anon_enum_types; } else if (ACK == Sema::ACK_Conditional) { // Conditional expressions are separated out because they have // historically had a different warning flag. - DiagID = S.getLangOpts().CPlusPlus20 + DiagID = getLangOpts().CPlusPlus20 ? diag::warn_conditional_mixed_enum_types_cxx20 : diag::warn_conditional_mixed_enum_types; } else if (ACK == Sema::ACK_Comparison) { // Comparison expressions are separated out because they have // historically had a different warning flag. - DiagID = S.getLangOpts().CPlusPlus20 + DiagID = getLangOpts().CPlusPlus20 ? diag::warn_comparison_mixed_enum_types_cxx20 : diag::warn_comparison_mixed_enum_types; } else { - DiagID = S.getLangOpts().CPlusPlus20 + DiagID = getLangOpts().CPlusPlus20 ? diag::warn_arith_conv_mixed_enum_types_cxx20 : diag::warn_arith_conv_mixed_enum_types; } - S.Diag(Loc, DiagID) << LHS->getSourceRange() << RHS->getSourceRange() - << (int)ACK << L << R; + Diag(Loc, DiagID) << LHS->getSourceRange() << RHS->getSourceRange() + << (int)ACK << L << R; } } @@ -1557,7 +1570,7 @@ static void checkEnumArithmeticConversions(Sema &S, Expr *LHS, Expr *RHS, QualType Sema::UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, ArithConvKind ACK) { - checkEnumArithmeticConversions(*this, LHS.get(), RHS.get(), Loc, ACK); + checkEnumArithmeticConversions(LHS.get(), RHS.get(), Loc, ACK); if (ACK != ACK_CompAssign) { LHS = UsualUnaryConversions(LHS.get()); @@ -7503,7 +7516,7 @@ static bool breakDownVectorType(QualType type, uint64_t &len, if (const VectorType *vecType = type->getAs<VectorType>()) { len = vecType->getNumElements(); eltType = vecType->getElementType(); - assert(eltType->isScalarType()); + assert(eltType->isScalarType() || eltType->isMFloat8Type()); return true; } @@ -10174,6 +10187,11 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, return HLSL().handleVectorBinOpConversion(LHS, RHS, LHSType, RHSType, IsCompAssign); + // Any operation with MFloat8 type is only possible with C intrinsics + if ((LHSVecType && LHSVecType->getElementType()->isMFloat8Type()) || + (RHSVecType && RHSVecType->getElementType()->isMFloat8Type())) + return InvalidOperands(Loc, LHS, RHS); + // AltiVec-style "vector bool op vector bool" combinations are allowed // for some operators but not others. if (!AllowBothBool && LHSVecType && @@ -11793,7 +11811,7 @@ static std::optional<bool> isTautologicalBoundsCheck(Sema &S, const Expr *LHS, const Expr *RHS, BinaryOperatorKind Opc) { if (!LHS->getType()->isPointerType() || - S.getLangOpts().isSignedOverflowDefined()) + S.getLangOpts().PointerOverflowDefined) return std::nullopt; // Canonicalize to >= or < predicate. diff --git clang/lib/Sema/SemaHLSL.cpp clang/lib/Sema/SemaHLSL.cpp index aa99b44958ea..d748c1045528 100644 --- clang/lib/Sema/SemaHLSL.cpp +++ clang/lib/Sema/SemaHLSL.cpp @@ -2430,6 +2430,7 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { TheCall->setType(ArgTyA); break; } + case Builtin::BI__builtin_hlsl_wave_active_max: case Builtin::BI__builtin_hlsl_wave_active_sum: { if (SemaRef.checkArgCount(TheCall, 1)) return true; diff --git clang/lib/Sema/SemaLookup.cpp clang/lib/Sema/SemaLookup.cpp index 5f8ffa71607b..0f5b7426e743 100644 --- clang/lib/Sema/SemaLookup.cpp +++ clang/lib/Sema/SemaLookup.cpp @@ -3721,13 +3721,11 @@ Sema::LookupLiteralOperator(Scope *S, LookupResult &R, // is a well-formed template argument for the template parameter. if (StringLit) { SFINAETrap Trap(*this); - SmallVector<TemplateArgument, 1> SugaredChecked, CanonicalChecked; + CheckTemplateArgumentInfo CTAI; TemplateArgumentLoc Arg(TemplateArgument(StringLit), StringLit); if (CheckTemplateArgument( Params->getParam(0), Arg, FD, R.getNameLoc(), R.getNameLoc(), - 0, SugaredChecked, CanonicalChecked, CTAK_Specified, - /*PartialOrdering=*/false, - /*MatchedPackOnParmToNonPackOnArg=*/nullptr) || + /*ArgumentPackIndex=*/0, CTAI, CTAK_Specified) || Trap.hasErrorOccurred()) IsTemplate = false; } diff --git clang/lib/Sema/SemaOverload.cpp clang/lib/Sema/SemaOverload.cpp index 6ae9c51c06b3..16ecea67aea9 100644 --- clang/lib/Sema/SemaOverload.cpp +++ clang/lib/Sema/SemaOverload.cpp @@ -6151,8 +6151,8 @@ static ExprResult BuildConvertedConstantExpression(Sema &S, Expr *From, Sema::CCEKind CCE, NamedDecl *Dest, APValue &PreNarrowingValue) { - assert(S.getLangOpts().CPlusPlus11 && - "converted constant expression outside C++11"); + assert((S.getLangOpts().CPlusPlus11 || CCE == Sema::CCEK_InjectedTTP) && + "converted constant expression outside C++11 or TTP matching"); if (checkPlaceholderForOverload(S, From)) return ExprError(); @@ -6221,8 +6221,10 @@ static ExprResult BuildConvertedConstantExpression(Sema &S, Expr *From, // earlier, but that's not guaranteed to work when initializing an object of // class type. ExprResult Result; + bool IsTemplateArgument = + CCE == Sema::CCEK_TemplateArg || CCE == Sema::CCEK_InjectedTTP; if (T->isRecordType()) { - assert(CCE == Sema::CCEK_TemplateArg && + assert(IsTemplateArgument && "unexpected class type converted constant expr"); Result = S.PerformCopyInitialization( InitializedEntity::InitializeTemplateParameter( @@ -6239,7 +6241,7 @@ static ExprResult BuildConvertedConstantExpression(Sema &S, Expr *From, // A full-expression is [...] a constant-expression [...] Result = S.ActOnFinishFullExpr(Result.get(), From->getExprLoc(), /*DiscardedValue=*/false, /*IsConstexpr=*/true, - CCE == Sema::CCEKind::CCEK_TemplateArg); + IsTemplateArgument); if (Result.isInvalid()) return Result; @@ -6248,9 +6250,6 @@ static ExprResult BuildConvertedConstantExpression(Sema &S, Expr *From, QualType PreNarrowingType; switch (SCS->getNarrowingKind(S.Context, Result.get(), PreNarrowingValue, PreNarrowingType)) { - case NK_Dependent_Narrowing: - // Implicit conversion to a narrower type, but the expression is - // value-dependent so we can't tell whether it's actually narrowing. case NK_Variable_Narrowing: // Implicit conversion to a narrower type, and the value is not a constant // expression. We'll diagnose this in a moment. @@ -6271,6 +6270,14 @@ static ExprResult BuildConvertedConstantExpression(Sema &S, Expr *From, << PreNarrowingValue.getAsString(S.Context, PreNarrowingType) << T; break; + case NK_Dependent_Narrowing: + // Implicit conversion to a narrower type, but the expression is + // value-dependent so we can't tell whether it's actually narrowing. + // For matching the parameters of a TTP, the conversion is ill-formed + // if it may narrow. + if (CCE != Sema::CCEK_InjectedTTP) + break; + [[fallthrough]]; case NK_Type_Narrowing: // FIXME: It would be better to diagnose that the expression is not a // constant expression. @@ -6343,6 +6350,8 @@ Sema::EvaluateConvertedConstantExpression(Expr *E, QualType T, APValue &Value, Expr::EvalResult Eval; Eval.Diag = &Notes; + assert(CCE != Sema::CCEK_InjectedTTP && "unnexpected CCE Kind"); + ConstantExprKind Kind; if (CCE == Sema::CCEK_TemplateArg && T->isRecordType()) Kind = ConstantExprKind::ClassTemplateArgument; @@ -7377,8 +7386,10 @@ static bool diagnoseDiagnoseIfAttrsWith(Sema &S, const NamedDecl *ND, return false; auto WarningBegin = std::stable_partition( - Attrs.begin(), Attrs.end(), - [](const DiagnoseIfAttr *DIA) { return DIA->isError(); }); + Attrs.begin(), Attrs.end(), [](const DiagnoseIfAttr *DIA) { + return DIA->getDefaultSeverity() == DiagnoseIfAttr::DS_error && + DIA->getWarningGroup().empty(); + }); // Note that diagnose_if attributes are late-parsed, so they appear in the // correct order (unlike enable_if attributes). @@ -7392,11 +7403,32 @@ static bool diagnoseDiagnoseIfAttrsWith(Sema &S, const NamedDecl *ND, return true; } + auto ToSeverity = [](DiagnoseIfAttr::DefaultSeverity Sev) { + switch (Sev) { + case DiagnoseIfAttr::DS_warning: + return diag::Severity::Warning; + case DiagnoseIfAttr::DS_error: + return diag::Severity::Error; + } + llvm_unreachable("Fully covered switch above!"); + }; + for (const auto *DIA : llvm::make_range(WarningBegin, Attrs.end())) if (IsSuccessful(DIA)) { - S.Diag(Loc, diag::warn_diagnose_if_succeeded) << DIA->getMessage(); - S.Diag(DIA->getLocation(), diag::note_from_diagnose_if) - << DIA->getParent() << DIA->getCond()->getSourceRange(); + if (DIA->getWarningGroup().empty() && + DIA->getDefaultSeverity() == DiagnoseIfAttr::DS_warning) { + S.Diag(Loc, diag::warn_diagnose_if_succeeded) << DIA->getMessage(); + S.Diag(DIA->getLocation(), diag::note_from_diagnose_if) + << DIA->getParent() << DIA->getCond()->getSourceRange(); + } else { + auto DiagGroup = S.Diags.getDiagnosticIDs()->getGroupForWarningOption( + DIA->getWarningGroup()); + assert(DiagGroup); + auto DiagID = S.Diags.getDiagnosticIDs()->getCustomDiagID( + {ToSeverity(DIA->getDefaultSeverity()), "%0", + DiagnosticIDs::CLASS_WARNING, false, false, *DiagGroup}); + S.Diag(Loc, DiagID) << DIA->getMessage(); + } } return false; diff --git clang/lib/Sema/SemaStmt.cpp clang/lib/Sema/SemaStmt.cpp index 25a07d0315ea..ec38674a2c3e 100644 --- clang/lib/Sema/SemaStmt.cpp +++ clang/lib/Sema/SemaStmt.cpp @@ -2716,8 +2716,10 @@ StmtResult Sema::BuildCXXForRangeStmt( // them in properly when we instantiate the loop. if (!LoopVar->isInvalidDecl() && Kind != BFRK_Check) { if (auto *DD = dyn_cast<DecompositionDecl>(LoopVar)) - for (auto *Binding : DD->bindings()) - Binding->setType(Context.DependentTy); + for (auto *Binding : DD->bindings()) { + if (!Binding->isParameterPack()) + Binding->setType(Context.DependentTy); + } LoopVar->setType(SubstAutoTypeDependent(LoopVar->getType())); } } else if (!BeginDeclStmt.get()) { @@ -4568,9 +4570,27 @@ buildCapturedStmtCaptureList(Sema &S, CapturedRegionScopeInfo *RSI, return false; } +static std::optional<int> +isOpenMPCapturedRegionInArmSMEFunction(Sema const &S, CapturedRegionKind Kind) { + if (!S.getLangOpts().OpenMP || Kind != CR_OpenMP) + return {}; + if (const FunctionDecl *FD = S.getCurFunctionDecl(/*AllowLambda=*/true)) { + if (IsArmStreamingFunction(FD, /*IncludeLocallyStreaming=*/true)) + return /* in streaming functions */ 0; + if (hasArmZAState(FD)) + return /* in functions with ZA state */ 1; + if (hasArmZT0State(FD)) + return /* in fuctions with ZT0 state */ 2; + } + return {}; +} + void Sema::ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope, CapturedRegionKind Kind, unsigned NumParams) { + if (auto ErrorIndex = isOpenMPCapturedRegionInArmSMEFunction(*this, Kind)) + Diag(Loc, diag::err_sme_openmp_captured_region) << *ErrorIndex; + CapturedDecl *CD = nullptr; RecordDecl *RD = CreateCapturedStmtRecordDecl(CD, Loc, NumParams); @@ -4602,6 +4622,9 @@ void Sema::ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope, CapturedRegionKind Kind, ArrayRef<CapturedParamNameType> Params, unsigned OpenMPCaptureLevel) { + if (auto ErrorIndex = isOpenMPCapturedRegionInArmSMEFunction(*this, Kind)) + Diag(Loc, diag::err_sme_openmp_captured_region) << *ErrorIndex; + CapturedDecl *CD = nullptr; RecordDecl *RD = CreateCapturedStmtRecordDecl(CD, Loc, Params.size()); diff --git clang/lib/Sema/SemaTemplate.cpp clang/lib/Sema/SemaTemplate.cpp index 38196c5c2bc1..35ece88c603d 100644 --- clang/lib/Sema/SemaTemplate.cpp +++ clang/lib/Sema/SemaTemplate.cpp @@ -38,6 +38,7 @@ #include "clang/Sema/TemplateDeduction.h" #include "llvm/ADT/SmallBitVector.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/Support/SaveAndRestore.h" #include <optional> using namespace clang; @@ -3497,10 +3498,10 @@ QualType Sema::CheckTemplateIdType(TemplateName Name, // Check that the template argument list is well-formed for this // template. - SmallVector<TemplateArgument, 4> SugaredConverted, CanonicalConverted; + CheckTemplateArgumentInfo CTAI; if (CheckTemplateArgumentList(Template, TemplateLoc, TemplateArgs, - DefaultArgs, false, SugaredConverted, - CanonicalConverted, + DefaultArgs, /*PartialTemplateArgs=*/false, + CTAI, /*UpdateArgsWithConversions=*/true)) return QualType(); @@ -3522,7 +3523,7 @@ QualType Sema::CheckTemplateIdType(TemplateName Name, // template type alias specializations apart. MultiLevelTemplateArgumentList TemplateArgLists; TemplateArgLists.addOuterTemplateArguments( - Template, SugaredConverted, + Template, CTAI.SugaredConverted, /*Final=*/!getLangOpts().RetainSubstTemplateTypeParmTypeAstNodes); TemplateArgLists.addOuterRetainedLevels( AliasTemplate->getTemplateParameters()->getDepth()); @@ -3582,11 +3583,11 @@ QualType Sema::CheckTemplateIdType(TemplateName Name, return QualType(); } } else if (auto *BTD = dyn_cast<BuiltinTemplateDecl>(Template)) { - CanonType = checkBuiltinTemplateIdType(*this, BTD, SugaredConverted, + CanonType = checkBuiltinTemplateIdType(*this, BTD, CTAI.SugaredConverted, TemplateLoc, TemplateArgs); } else if (Name.isDependent() || TemplateSpecializationType::anyDependentTemplateArguments( - TemplateArgs, CanonicalConverted)) { + TemplateArgs, CTAI.CanonicalConverted)) { // This class template specialization is a dependent // type. Therefore, its canonical type is another class template // specialization type that contains all of the converted @@ -3595,7 +3596,7 @@ QualType Sema::CheckTemplateIdType(TemplateName Name, // // template<typename T, typename U = T> struct A; CanonType = Context.getCanonicalTemplateSpecializationType( - Name, CanonicalConverted); + Name, CTAI.CanonicalConverted); // This might work out to be a current instantiation, in which // case the canonical type needs to be the InjectedClassNameType. @@ -3640,7 +3641,7 @@ QualType Sema::CheckTemplateIdType(TemplateName Name, // corresponds to these arguments. void *InsertPos = nullptr; ClassTemplateSpecializationDecl *Decl = - ClassTemplate->findSpecialization(CanonicalConverted, InsertPos); + ClassTemplate->findSpecialization(CTAI.CanonicalConverted, InsertPos); if (!Decl) { // This is the first time we have referenced this class template // specialization. Create the canonical declaration and add it to @@ -3649,7 +3650,7 @@ QualType Sema::CheckTemplateIdType(TemplateName Name, Context, ClassTemplate->getTemplatedDecl()->getTagKind(), ClassTemplate->getDeclContext(), ClassTemplate->getTemplatedDecl()->getBeginLoc(), - ClassTemplate->getLocation(), ClassTemplate, CanonicalConverted, + ClassTemplate->getLocation(), ClassTemplate, CTAI.CanonicalConverted, nullptr); ClassTemplate->AddSpecialization(Decl, InsertPos); if (ClassTemplate->isOutOfLine()) @@ -3661,7 +3662,7 @@ QualType Sema::CheckTemplateIdType(TemplateName Name, InstantiatingTemplate Inst(*this, TemplateLoc, Decl); if (!Inst.isInvalid()) { MultiLevelTemplateArgumentList TemplateArgLists(Template, - CanonicalConverted, + CTAI.CanonicalConverted, /*Final=*/false); InstantiateAttrsForDecl(TemplateArgLists, ClassTemplate->getTemplatedDecl(), Decl); @@ -4183,10 +4184,10 @@ DeclResult Sema::ActOnVarTemplateSpecialization( // Check that the template argument list is well-formed for this // template. - SmallVector<TemplateArgument, 4> SugaredConverted, CanonicalConverted; + CheckTemplateArgumentInfo CTAI; if (CheckTemplateArgumentList(VarTemplate, TemplateNameLoc, TemplateArgs, - /*DefaultArgs=*/{}, false, SugaredConverted, - CanonicalConverted, + /*DefaultArgs=*/{}, + /*PartialTemplateArgs=*/false, CTAI, /*UpdateArgsWithConversions=*/true)) return true; @@ -4195,21 +4196,21 @@ DeclResult Sema::ActOnVarTemplateSpecialization( if (IsPartialSpecialization) { if (CheckTemplatePartialSpecializationArgs(TemplateNameLoc, VarTemplate, TemplateArgs.size(), - CanonicalConverted)) + CTAI.CanonicalConverted)) return true; - // FIXME: Move these checks to CheckTemplatePartialSpecializationArgs so we - // also do them during instantiation. + // FIXME: Move these checks to CheckTemplatePartialSpecializationArgs so + // we also do them during instantiation. if (!Name.isDependent() && !TemplateSpecializationType::anyDependentTemplateArguments( - TemplateArgs, CanonicalConverted)) { + TemplateArgs, CTAI.CanonicalConverted)) { Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized) << VarTemplate->getDeclName(); IsPartialSpecialization = false; } if (isSameAsPrimaryTemplate(VarTemplate->getTemplateParameters(), - CanonicalConverted) && + CTAI.CanonicalConverted) && (!Context.getLangOpts().CPlusPlus20 || !TemplateParams->hasAssociatedConstraints())) { // C++ [temp.class.spec]p9b3: @@ -4217,11 +4218,11 @@ DeclResult Sema::ActOnVarTemplateSpecialization( // -- The argument list of the specialization shall not be identical // to the implicit argument list of the primary template. Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template) - << /*variable template*/ 1 - << /*is definition*/(SC != SC_Extern && !CurContext->isRecord()) - << FixItHint::CreateRemoval(SourceRange(LAngleLoc, RAngleLoc)); - // FIXME: Recover from this by treating the declaration as a redeclaration - // of the primary template. + << /*variable template*/ 1 + << /*is definition*/ (SC != SC_Extern && !CurContext->isRecord()) + << FixItHint::CreateRemoval(SourceRange(LAngleLoc, RAngleLoc)); + // FIXME: Recover from this by treating the declaration as a + // redeclaration of the primary template. return true; } } @@ -4231,9 +4232,10 @@ DeclResult Sema::ActOnVarTemplateSpecialization( if (IsPartialSpecialization) PrevDecl = VarTemplate->findPartialSpecialization( - CanonicalConverted, TemplateParams, InsertPos); + CTAI.CanonicalConverted, TemplateParams, InsertPos); else - PrevDecl = VarTemplate->findSpecialization(CanonicalConverted, InsertPos); + PrevDecl = + VarTemplate->findSpecialization(CTAI.CanonicalConverted, InsertPos); VarTemplateSpecializationDecl *Specialization = nullptr; @@ -4260,7 +4262,7 @@ DeclResult Sema::ActOnVarTemplateSpecialization( VarTemplatePartialSpecializationDecl::Create( Context, VarTemplate->getDeclContext(), TemplateKWLoc, TemplateNameLoc, TemplateParams, VarTemplate, DI->getType(), DI, SC, - CanonicalConverted); + CTAI.CanonicalConverted); Partial->setTemplateArgsAsWritten(TemplateArgs); if (!PrevPartial) @@ -4278,7 +4280,7 @@ DeclResult Sema::ActOnVarTemplateSpecialization( // this explicit specialization or friend declaration. Specialization = VarTemplateSpecializationDecl::Create( Context, VarTemplate->getDeclContext(), TemplateKWLoc, TemplateNameLoc, - VarTemplate, DI->getType(), DI, SC, CanonicalConverted); + VarTemplate, DI->getType(), DI, SC, CTAI.CanonicalConverted); Specialization->setTemplateArgsAsWritten(TemplateArgs); if (!PrevDecl) @@ -4350,25 +4352,25 @@ Sema::CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, assert(Template && "A variable template id without template?"); // Check that the template argument list is well-formed for this template. - SmallVector<TemplateArgument, 4> SugaredConverted, CanonicalConverted; + CheckTemplateArgumentInfo CTAI; if (CheckTemplateArgumentList( Template, TemplateNameLoc, const_cast<TemplateArgumentListInfo &>(TemplateArgs), - /*DefaultArgs=*/{}, false, SugaredConverted, CanonicalConverted, + /*DefaultArgs=*/{}, /*PartialTemplateArgs=*/false, CTAI, /*UpdateArgsWithConversions=*/true)) return true; // Produce a placeholder value if the specialization is dependent. if (Template->getDeclContext()->isDependentContext() || TemplateSpecializationType::anyDependentTemplateArguments( - TemplateArgs, CanonicalConverted)) + TemplateArgs, CTAI.CanonicalConverted)) return DeclResult(); // Find the variable template specialization declaration that // corresponds to these arguments. void *InsertPos = nullptr; if (VarTemplateSpecializationDecl *Spec = - Template->findSpecialization(CanonicalConverted, InsertPos)) { + Template->findSpecialization(CTAI.CanonicalConverted, InsertPos)) { checkSpecializationReachability(TemplateNameLoc, Spec); // If we already have a variable template specialization, return it. return Spec; @@ -4412,7 +4414,7 @@ Sema::CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, TemplateDeductionInfo Info(FailedCandidates.getLocation()); if (TemplateDeductionResult Result = - DeduceTemplateArguments(Partial, SugaredConverted, Info); + DeduceTemplateArguments(Partial, CTAI.SugaredConverted, Info); Result != TemplateDeductionResult::Success) { // Store the failed-deduction information for use in diagnostics, later. // TODO: Actually use the failed-deduction info? @@ -4479,7 +4481,7 @@ Sema::CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, // FIXME: LateAttrs et al.? VarTemplateSpecializationDecl *Decl = BuildVarTemplateInstantiation( Template, InstantiationPattern, PartialSpecArgs, TemplateArgs, - CanonicalConverted, TemplateNameLoc /*, LateAttrs, StartingScope*/); + CTAI.CanonicalConverted, TemplateNameLoc /*, LateAttrs, StartingScope*/); if (!Decl) return true; @@ -4559,12 +4561,12 @@ Sema::CheckConceptTemplateId(const CXXScopeSpec &SS, if (NamedConcept->isInvalidDecl()) return ExprError(); - llvm::SmallVector<TemplateArgument, 4> SugaredConverted, CanonicalConverted; + CheckTemplateArgumentInfo CTAI; if (CheckTemplateArgumentList( NamedConcept, ConceptNameInfo.getLoc(), const_cast<TemplateArgumentListInfo &>(*TemplateArgs), /*DefaultArgs=*/{}, - /*PartialTemplateArgs=*/false, SugaredConverted, CanonicalConverted, + /*PartialTemplateArgs=*/false, CTAI, /*UpdateArgsWithConversions=*/false)) return ExprError(); @@ -4572,12 +4574,12 @@ Sema::CheckConceptTemplateId(const CXXScopeSpec &SS, auto *CSD = ImplicitConceptSpecializationDecl::Create( Context, NamedConcept->getDeclContext(), NamedConcept->getLocation(), - CanonicalConverted); + CTAI.CanonicalConverted); ConstraintSatisfaction Satisfaction; bool AreArgsDependent = TemplateSpecializationType::anyDependentTemplateArguments( - *TemplateArgs, CanonicalConverted); - MultiLevelTemplateArgumentList MLTAL(NamedConcept, CanonicalConverted, + *TemplateArgs, CTAI.CanonicalConverted); + MultiLevelTemplateArgumentList MLTAL(NamedConcept, CTAI.CanonicalConverted, /*Final=*/false); LocalInstantiationScope Scope(*this); @@ -5198,19 +5200,19 @@ convertTypeTemplateArgumentToTemplate(ASTContext &Context, TypeLoc TLoc) { return TemplateArgumentLoc(); } -bool Sema::CheckTemplateArgument( - NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, - SourceLocation TemplateLoc, SourceLocation RAngleLoc, - unsigned ArgumentPackIndex, - SmallVectorImpl<TemplateArgument> &SugaredConverted, - SmallVectorImpl<TemplateArgument> &CanonicalConverted, - CheckTemplateArgumentKind CTAK, bool PartialOrdering, - bool *MatchedPackOnParmToNonPackOnArg) { +bool Sema::CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &ArgLoc, + NamedDecl *Template, + SourceLocation TemplateLoc, + SourceLocation RAngleLoc, + unsigned ArgumentPackIndex, + CheckTemplateArgumentInfo &CTAI, + CheckTemplateArgumentKind CTAK) { // Check template type parameters. if (TemplateTypeParmDecl *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) - return CheckTemplateTypeArgument(TTP, Arg, SugaredConverted, - CanonicalConverted); + return CheckTemplateTypeArgument(TTP, ArgLoc, CTAI.SugaredConverted, + CTAI.CanonicalConverted); + const TemplateArgument &Arg = ArgLoc.getArgument(); // Check non-type template parameters. if (NonTypeTemplateParmDecl *NTTP =dyn_cast<NonTypeTemplateParmDecl>(Param)) { // Do substitution on the type of the non-type template parameter @@ -5225,12 +5227,12 @@ bool Sema::CheckTemplateArgument( !Template->getDeclContext()->isDependentContext()) { // Do substitution on the type of the non-type template parameter. InstantiatingTemplate Inst(*this, TemplateLoc, Template, NTTP, - SugaredConverted, + CTAI.SugaredConverted, SourceRange(TemplateLoc, RAngleLoc)); if (Inst.isInvalid()) return true; - MultiLevelTemplateArgumentList MLTAL(Template, SugaredConverted, + MultiLevelTemplateArgumentList MLTAL(Template, CTAI.SugaredConverted, /*Final=*/true); // If the parameter is a pack expansion, expand this slice of the pack. if (auto *PET = NTTPType->getAs<PackExpansionType>()) { @@ -5252,62 +5254,73 @@ bool Sema::CheckTemplateArgument( return true; } - switch (Arg.getArgument().getKind()) { + auto checkExpr = [&](Expr *E) -> Expr * { + TemplateArgument SugaredResult, CanonicalResult; + unsigned CurSFINAEErrors = NumSFINAEErrors; + ExprResult Res = + CheckTemplateArgument(NTTP, NTTPType, E, SugaredResult, + CanonicalResult, CTAI.MatchingTTP, CTAK); + // If the current template argument causes an error, give up now. + if (Res.isInvalid() || CurSFINAEErrors < NumSFINAEErrors) + return nullptr; + CTAI.SugaredConverted.push_back(SugaredResult); + CTAI.CanonicalConverted.push_back(CanonicalResult); + return Res.get(); + }; + + switch (Arg.getKind()) { case TemplateArgument::Null: llvm_unreachable("Should never see a NULL template argument here"); case TemplateArgument::Expression: { - Expr *E = Arg.getArgument().getAsExpr(); - TemplateArgument SugaredResult, CanonicalResult; - unsigned CurSFINAEErrors = NumSFINAEErrors; - ExprResult Res = CheckTemplateArgument(NTTP, NTTPType, E, SugaredResult, - CanonicalResult, CTAK); - if (Res.isInvalid()) + Expr *E = Arg.getAsExpr(); + Expr *R = checkExpr(E); + if (!R) return true; - // If the current template argument causes an error, give up now. - if (CurSFINAEErrors < NumSFINAEErrors) - return true; - // If the resulting expression is new, then use it in place of the // old expression in the template argument. - if (Res.get() != E) { - TemplateArgument TA(Res.get()); - Arg = TemplateArgumentLoc(TA, Res.get()); + if (R != E) { + TemplateArgument TA(R); + ArgLoc = TemplateArgumentLoc(TA, R); } - - SugaredConverted.push_back(SugaredResult); - CanonicalConverted.push_back(CanonicalResult); break; } - case TemplateArgument::Declaration: + // As for the converted NTTP kinds, they still might need another + // conversion, as the new corresponding parameter might be different. + // Ideally, we would always perform substitution starting with sugared types + // and never need these, as we would still have expressions. Since these are + // needed so rarely, it's probably a better tradeoff to just convert them + // back to expressions. case TemplateArgument::Integral: - case TemplateArgument::StructuralValue: + case TemplateArgument::Declaration: case TemplateArgument::NullPtr: - // We've already checked this template argument, so just copy - // it to the list of converted arguments. - SugaredConverted.push_back(Arg.getArgument()); - CanonicalConverted.push_back( - Context.getCanonicalTemplateArgument(Arg.getArgument())); + case TemplateArgument::StructuralValue: { + // FIXME: StructuralValue is untested here. + ExprResult R = + BuildExpressionFromNonTypeTemplateArgument(Arg, SourceLocation()); + assert(R.isUsable()); + if (!checkExpr(R.get())) + return true; break; + } case TemplateArgument::Template: case TemplateArgument::TemplateExpansion: // We were given a template template argument. It may not be ill-formed; // see below. - if (DependentTemplateName *DTN - = Arg.getArgument().getAsTemplateOrTemplatePattern() - .getAsDependentTemplateName()) { + if (DependentTemplateName *DTN = Arg.getAsTemplateOrTemplatePattern() + .getAsDependentTemplateName()) { // We have a template argument such as \c T::template X, which we // parsed as a template template argument. However, since we now // know that we need a non-type template argument, convert this // template name into an expression. DeclarationNameInfo NameInfo(DTN->getIdentifier(), - Arg.getTemplateNameLoc()); + ArgLoc.getTemplateNameLoc()); CXXScopeSpec SS; - SS.Adopt(Arg.getTemplateQualifierLoc()); + SS.Adopt(ArgLoc.getTemplateQualifierLoc()); // FIXME: the template-template arg was a DependentTemplateName, // so it was provided with a template keyword. However, its source // location is not stored in the template argument structure. @@ -5318,28 +5331,29 @@ bool Sema::CheckTemplateArgument( // If we parsed the template argument as a pack expansion, create a // pack expansion expression. - if (Arg.getArgument().getKind() == TemplateArgument::TemplateExpansion){ - E = ActOnPackExpansion(E.get(), Arg.getTemplateEllipsisLoc()); + if (Arg.getKind() == TemplateArgument::TemplateExpansion) { + E = ActOnPackExpansion(E.get(), ArgLoc.getTemplateEllipsisLoc()); if (E.isInvalid()) return true; } TemplateArgument SugaredResult, CanonicalResult; E = CheckTemplateArgument(NTTP, NTTPType, E.get(), SugaredResult, - CanonicalResult, CTAK_Specified); + CanonicalResult, /*PartialOrderingTTP=*/false, + CTAK_Specified); if (E.isInvalid()) return true; - SugaredConverted.push_back(SugaredResult); - CanonicalConverted.push_back(CanonicalResult); + CTAI.SugaredConverted.push_back(SugaredResult); + CTAI.CanonicalConverted.push_back(CanonicalResult); break; } // We have a template argument that actually does refer to a class // template, alias template, or template template parameter, and // therefore cannot be a non-type template argument. - Diag(Arg.getLocation(), diag::err_template_arg_must_be_expr) - << Arg.getSourceRange(); + Diag(ArgLoc.getLocation(), diag::err_template_arg_must_be_expr) + << ArgLoc.getSourceRange(); NoteTemplateParameterLocation(*Param); return true; @@ -5355,8 +5369,8 @@ bool Sema::CheckTemplateArgument( // // We warn specifically about this case, since it can be rather // confusing for users. - QualType T = Arg.getArgument().getAsType(); - SourceRange SR = Arg.getSourceRange(); + QualType T = Arg.getAsType(); + SourceRange SR = ArgLoc.getSourceRange(); if (T->isFunctionType()) Diag(SR.getBegin(), diag::err_template_arg_nontype_ambig) << SR << T; else @@ -5389,16 +5403,16 @@ bool Sema::CheckTemplateArgument( // Set up a template instantiation context. LocalInstantiationScope Scope(*this); InstantiatingTemplate Inst(*this, TemplateLoc, Template, TempParm, - SugaredConverted, + CTAI.SugaredConverted, SourceRange(TemplateLoc, RAngleLoc)); if (Inst.isInvalid()) return true; - Params = - SubstTemplateParams(Params, CurContext, - MultiLevelTemplateArgumentList( - Template, SugaredConverted, /*Final=*/true), - /*EvaluateConstraints=*/false); + Params = SubstTemplateParams( + Params, CurContext, + MultiLevelTemplateArgumentList(Template, CTAI.SugaredConverted, + /*Final=*/true), + /*EvaluateConstraints=*/false); if (!Params) return true; } @@ -5407,34 +5421,35 @@ bool Sema::CheckTemplateArgument( // When [the injected-class-name] is used [...] as a template-argument for // a template template-parameter [...] it refers to the class template // itself. - if (Arg.getArgument().getKind() == TemplateArgument::Type) { + if (Arg.getKind() == TemplateArgument::Type) { TemplateArgumentLoc ConvertedArg = convertTypeTemplateArgumentToTemplate( - Context, Arg.getTypeSourceInfo()->getTypeLoc()); + Context, ArgLoc.getTypeSourceInfo()->getTypeLoc()); if (!ConvertedArg.getArgument().isNull()) - Arg = ConvertedArg; + ArgLoc = ConvertedArg; } - switch (Arg.getArgument().getKind()) { + switch (Arg.getKind()) { case TemplateArgument::Null: llvm_unreachable("Should never see a NULL template argument here"); case TemplateArgument::Template: case TemplateArgument::TemplateExpansion: - if (CheckTemplateTemplateArgument(TempParm, Params, Arg, PartialOrdering, - MatchedPackOnParmToNonPackOnArg)) + if (CheckTemplateTemplateArgument(TempParm, Params, ArgLoc, + CTAI.PartialOrdering, + &CTAI.MatchedPackOnParmToNonPackOnArg)) return true; - SugaredConverted.push_back(Arg.getArgument()); - CanonicalConverted.push_back( - Context.getCanonicalTemplateArgument(Arg.getArgument())); + CTAI.SugaredConverted.push_back(Arg); + CTAI.CanonicalConverted.push_back( + Context.getCanonicalTemplateArgument(Arg)); break; case TemplateArgument::Expression: case TemplateArgument::Type: // We have a template template parameter but the template // argument does not refer to a template. - Diag(Arg.getLocation(), diag::err_template_arg_must_be_template) - << getLangOpts().CPlusPlus11; + Diag(ArgLoc.getLocation(), diag::err_template_arg_must_be_template) + << getLangOpts().CPlusPlus11; return true; case TemplateArgument::Declaration: @@ -5491,11 +5506,8 @@ static bool diagnoseMissingArgument(Sema &S, SourceLocation Loc, bool Sema::CheckTemplateArgumentList( TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, const DefaultArguments &DefaultArgs, - bool PartialTemplateArgs, - SmallVectorImpl<TemplateArgument> &SugaredConverted, - SmallVectorImpl<TemplateArgument> &CanonicalConverted, - bool UpdateArgsWithConversions, bool *ConstraintsNotSatisfied, - bool PartialOrderingTTP, bool *MatchedPackOnParmToNonPackOnArg) { + bool PartialTemplateArgs, CheckTemplateArgumentInfo &CTAI, + bool UpdateArgsWithConversions, bool *ConstraintsNotSatisfied) { if (ConstraintsNotSatisfied) *ConstraintsNotSatisfied = false; @@ -5532,8 +5544,8 @@ bool Sema::CheckTemplateArgumentList( assert(Param + DefaultArgs.Args.size() <= ParamEnd); // Default arguments from a DeducedTemplateName are already converted. for (const TemplateArgument &DefArg : DefaultArgs.Args) { - SugaredConverted.push_back(DefArg); - CanonicalConverted.push_back( + CTAI.SugaredConverted.push_back(DefArg); + CTAI.CanonicalConverted.push_back( Context.getCanonicalTemplateArgument(DefArg)); ++Param; } @@ -5547,11 +5559,11 @@ bool Sema::CheckTemplateArgumentList( if (*Expansions == SugaredArgumentPack.size()) { // We're done with this parameter pack. Pack up its arguments and add // them to the list. - SugaredConverted.push_back( + CTAI.SugaredConverted.push_back( TemplateArgument::CreatePackCopy(Context, SugaredArgumentPack)); SugaredArgumentPack.clear(); - CanonicalConverted.push_back( + CTAI.CanonicalConverted.push_back( TemplateArgument::CreatePackCopy(Context, CanonicalArgumentPack)); CanonicalArgumentPack.clear(); @@ -5575,7 +5587,7 @@ bool Sema::CheckTemplateArgumentList( !(*Param)->isTemplateParameterPack() || getExpandedPackSize(*Param); bool ArgIsExpansion = ArgLoc.getArgument().isPackExpansion(); - if (ArgIsExpansion && PartialOrderingTTP) { + if (ArgIsExpansion && CTAI.MatchingTTP) { SmallVector<TemplateArgument, 4> Args(ParamEnd - Param); for (TemplateParameterList::iterator First = Param; Param != ParamEnd; ++Param) { @@ -5585,31 +5597,30 @@ bool Sema::CheckTemplateArgumentList( getExpandedPackSize(*Param)) Arg = Arg.getPackExpansionPattern(); TemplateArgumentLoc NewArgLoc(Arg, ArgLoc.getLocInfo()); + SaveAndRestore _1(CTAI.PartialOrdering, false); + SaveAndRestore _2(CTAI.MatchingTTP, true); if (CheckTemplateArgument(*Param, NewArgLoc, Template, TemplateLoc, - RAngleLoc, SugaredArgumentPack.size(), - SugaredConverted, CanonicalConverted, - CTAK_Specified, /*PartialOrdering=*/false, - MatchedPackOnParmToNonPackOnArg)) + RAngleLoc, SugaredArgumentPack.size(), CTAI, + CTAK_Specified)) return true; Arg = NewArgLoc.getArgument(); - CanonicalConverted.back().setIsDefaulted( + CTAI.CanonicalConverted.back().setIsDefaulted( clang::isSubstitutedDefaultArgument(Context, Arg, *Param, - CanonicalConverted, + CTAI.CanonicalConverted, Params->getDepth())); } ArgLoc = TemplateArgumentLoc(TemplateArgument::CreatePackCopy(Context, Args), ArgLoc.getLocInfo()); } else { + SaveAndRestore _1(CTAI.PartialOrdering, false); if (CheckTemplateArgument(*Param, ArgLoc, Template, TemplateLoc, - RAngleLoc, SugaredArgumentPack.size(), - SugaredConverted, CanonicalConverted, - CTAK_Specified, /*PartialOrdering=*/false, - MatchedPackOnParmToNonPackOnArg)) + RAngleLoc, SugaredArgumentPack.size(), CTAI, + CTAK_Specified)) return true; - CanonicalConverted.back().setIsDefaulted( + CTAI.CanonicalConverted.back().setIsDefaulted( clang::isSubstitutedDefaultArgument(Context, ArgLoc.getArgument(), - *Param, CanonicalConverted, + *Param, CTAI.CanonicalConverted, Params->getDepth())); if (ArgIsExpansion && NonPackParameter) { // CWG1430/CWG2686: we have a pack expansion as an argument to an @@ -5629,28 +5640,28 @@ bool Sema::CheckTemplateArgumentList( // We're now done with this argument. ++ArgIdx; - if (ArgIsExpansion && (PartialOrderingTTP || NonPackParameter)) { + if (ArgIsExpansion && (CTAI.MatchingTTP || NonPackParameter)) { // Directly convert the remaining arguments, because we don't know what // parameters they'll match up with. if (!SugaredArgumentPack.empty()) { // If we were part way through filling in an expanded parameter pack, // fall back to just producing individual arguments. - SugaredConverted.insert(SugaredConverted.end(), - SugaredArgumentPack.begin(), - SugaredArgumentPack.end()); + CTAI.SugaredConverted.insert(CTAI.SugaredConverted.end(), + SugaredArgumentPack.begin(), + SugaredArgumentPack.end()); SugaredArgumentPack.clear(); - CanonicalConverted.insert(CanonicalConverted.end(), - CanonicalArgumentPack.begin(), - CanonicalArgumentPack.end()); + CTAI.CanonicalConverted.insert(CTAI.CanonicalConverted.end(), + CanonicalArgumentPack.begin(), + CanonicalArgumentPack.end()); CanonicalArgumentPack.clear(); } while (ArgIdx < NumArgs) { const TemplateArgument &Arg = NewArgs[ArgIdx].getArgument(); - SugaredConverted.push_back(Arg); - CanonicalConverted.push_back( + CTAI.SugaredConverted.push_back(Arg); + CTAI.CanonicalConverted.push_back( Context.getCanonicalTemplateArgument(Arg)); ++ArgIdx; } @@ -5663,8 +5674,8 @@ bool Sema::CheckTemplateArgumentList( // deduced argument and place it on the argument pack. Note that we // stay on the same template parameter so that we can deduce more // arguments. - SugaredArgumentPack.push_back(SugaredConverted.pop_back_val()); - CanonicalArgumentPack.push_back(CanonicalConverted.pop_back_val()); + SugaredArgumentPack.push_back(CTAI.SugaredConverted.pop_back_val()); + CanonicalArgumentPack.push_back(CTAI.CanonicalConverted.pop_back_val()); } else { // Move to the next template parameter. ++Param; @@ -5675,9 +5686,9 @@ bool Sema::CheckTemplateArgumentList( // If we're checking a partial template argument list, we're done. if (PartialTemplateArgs) { if ((*Param)->isTemplateParameterPack() && !SugaredArgumentPack.empty()) { - SugaredConverted.push_back( + CTAI.SugaredConverted.push_back( TemplateArgument::CreatePackCopy(Context, SugaredArgumentPack)); - CanonicalConverted.push_back( + CTAI.CanonicalConverted.push_back( TemplateArgument::CreatePackCopy(Context, CanonicalArgumentPack)); } return false; @@ -5699,11 +5710,11 @@ bool Sema::CheckTemplateArgumentList( return true; } - SugaredConverted.push_back( + CTAI.SugaredConverted.push_back( TemplateArgument::CreatePackCopy(Context, SugaredArgumentPack)); SugaredArgumentPack.clear(); - CanonicalConverted.push_back( + CTAI.CanonicalConverted.push_back( TemplateArgument::CreatePackCopy(Context, CanonicalArgumentPack)); CanonicalArgumentPack.clear(); @@ -5720,8 +5731,8 @@ bool Sema::CheckTemplateArgumentList( // (when the template parameter was part of a nested template) into // the default argument. TemplateArgumentLoc Arg = SubstDefaultTemplateArgumentIfAvailable( - Template, TemplateLoc, RAngleLoc, *Param, SugaredConverted, - CanonicalConverted, HasDefaultArg); + Template, TemplateLoc, RAngleLoc, *Param, CTAI.SugaredConverted, + CTAI.CanonicalConverted, HasDefaultArg); if (Arg.getArgument().isNull()) { if (!HasDefaultArg) { @@ -5744,20 +5755,21 @@ bool Sema::CheckTemplateArgumentList( // template here, we just create this object to put a note into the // context stack. InstantiatingTemplate Inst(*this, RAngleLoc, Template, *Param, - SugaredConverted, + CTAI.SugaredConverted, SourceRange(TemplateLoc, RAngleLoc)); if (Inst.isInvalid()) return true; + SaveAndRestore _1(CTAI.PartialOrdering, false); + SaveAndRestore _2(CTAI.MatchingTTP, false); + SaveAndRestore _3(CTAI.MatchedPackOnParmToNonPackOnArg, {}); // Check the default template argument. if (CheckTemplateArgument(*Param, Arg, Template, TemplateLoc, RAngleLoc, 0, - SugaredConverted, CanonicalConverted, - CTAK_Specified, /*PartialOrdering=*/false, - /*MatchedPackOnParmToNonPackOnArg=*/nullptr)) + CTAI, CTAK_Specified)) return true; - SugaredConverted.back().setIsDefaulted(true); - CanonicalConverted.back().setIsDefaulted(true); + CTAI.SugaredConverted.back().setIsDefaulted(true); + CTAI.CanonicalConverted.back().setIsDefaulted(true); // Core issue 150 (assumed resolution): if this is a template template // parameter, keep track of the default template arguments from the @@ -5774,14 +5786,15 @@ bool Sema::CheckTemplateArgumentList( // pack expansions; they might be empty. This can happen even if // PartialTemplateArgs is false (the list of arguments is complete but // still dependent). - if (PartialOrderingTTP || + if (CTAI.MatchingTTP || (CurrentInstantiationScope && CurrentInstantiationScope->getPartiallySubstitutedPack())) { while (ArgIdx < NumArgs && NewArgs[ArgIdx].getArgument().isPackExpansion()) { const TemplateArgument &Arg = NewArgs[ArgIdx++].getArgument(); - SugaredConverted.push_back(Arg); - CanonicalConverted.push_back(Context.getCanonicalTemplateArgument(Arg)); + CTAI.SugaredConverted.push_back(Arg); + CTAI.CanonicalConverted.push_back( + Context.getCanonicalTemplateArgument(Arg)); } } @@ -5822,7 +5835,7 @@ bool Sema::CheckTemplateArgumentList( CXXThisScopeRAII(*this, RD, ThisQuals, RD != nullptr); MultiLevelTemplateArgumentList MLTAL = getTemplateInstantiationArgs( - Template, NewContext, /*Final=*/false, CanonicalConverted, + Template, NewContext, /*Final=*/false, CTAI.CanonicalConverted, /*RelativeToPrimary=*/true, /*Pattern=*/nullptr, /*ForConceptInstantiation=*/true); @@ -6740,6 +6753,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *Arg, TemplateArgument &SugaredConverted, TemplateArgument &CanonicalConverted, + bool PartialOrderingTTP, CheckTemplateArgumentKind CTAK) { SourceLocation StartLoc = Arg->getBeginLoc(); @@ -6930,17 +6944,21 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, IsConvertedConstantExpression = false; } - if (getLangOpts().CPlusPlus17) { + if (getLangOpts().CPlusPlus17 || PartialOrderingTTP) { // C++17 [temp.arg.nontype]p1: // A template-argument for a non-type template parameter shall be // a converted constant expression of the type of the template-parameter. APValue Value; ExprResult ArgResult; if (IsConvertedConstantExpression) { - ArgResult = BuildConvertedConstantExpression(Arg, ParamType, - CCEK_TemplateArg, Param); - if (ArgResult.isInvalid()) + ArgResult = BuildConvertedConstantExpression( + Arg, ParamType, + PartialOrderingTTP ? CCEK_InjectedTTP : CCEK_TemplateArg, Param); + assert(!ArgResult.isUnset()); + if (ArgResult.isInvalid()) { + NoteTemplateParameterLocation(*Param); return ExprError(); + } } else { ArgResult = Arg; } @@ -7381,11 +7399,6 @@ bool Sema::CheckTemplateTemplateArgument( << Template; } - if (!getLangOpts().RelaxedTemplateTemplateArgs) - return !TemplateParameterListsAreEqual( - Template->getTemplateParameters(), Params, /*Complain=*/true, - TPL_TemplateTemplateArgumentMatch, Arg.getLocation()); - // C++1z [temp.arg.template]p3: (DR 150) // A template-argument matches a template template-parameter P when P // is at least as specialized as the template-argument A. @@ -7757,9 +7770,7 @@ static bool MatchTemplateParameterKind( // However, if we are matching a template template argument to a // template template parameter, the template template parameter can have // a parameter pack where the template template argument does not. - if (Old->isTemplateParameterPack() != New->isTemplateParameterPack() && - !(Kind == Sema::TPL_TemplateTemplateArgumentMatch && - Old->isTemplateParameterPack())) { + if (Old->isTemplateParameterPack() != New->isTemplateParameterPack()) { if (Complain) { unsigned NextDiag = diag::err_template_parameter_pack_non_pack; if (TemplateArgLoc.isValid()) { @@ -7785,37 +7796,28 @@ static bool MatchTemplateParameterKind( = dyn_cast<NonTypeTemplateParmDecl>(Old)) { NonTypeTemplateParmDecl *NewNTTP = cast<NonTypeTemplateParmDecl>(New); - // If we are matching a template template argument to a template - // template parameter and one of the non-type template parameter types - // is dependent, then we must wait until template instantiation time - // to actually compare the arguments. - if (Kind != Sema::TPL_TemplateTemplateArgumentMatch || - (!OldNTTP->getType()->isDependentType() && - !NewNTTP->getType()->isDependentType())) { - // C++20 [temp.over.link]p6: - // Two [non-type] template-parameters are equivalent [if] they have - // equivalent types ignoring the use of type-constraints for - // placeholder types - QualType OldType = S.Context.getUnconstrainedType(OldNTTP->getType()); - QualType NewType = S.Context.getUnconstrainedType(NewNTTP->getType()); - if (!S.Context.hasSameType(OldType, NewType)) { - if (Complain) { - unsigned NextDiag = diag::err_template_nontype_parm_different_type; - if (TemplateArgLoc.isValid()) { - S.Diag(TemplateArgLoc, - diag::err_template_arg_template_params_mismatch); - NextDiag = diag::note_template_nontype_parm_different_type; - } - S.Diag(NewNTTP->getLocation(), NextDiag) - << NewNTTP->getType() - << (Kind != Sema::TPL_TemplateMatch); - S.Diag(OldNTTP->getLocation(), - diag::note_template_nontype_parm_prev_declaration) - << OldNTTP->getType(); + // C++20 [temp.over.link]p6: + // Two [non-type] template-parameters are equivalent [if] they have + // equivalent types ignoring the use of type-constraints for + // placeholder types + QualType OldType = S.Context.getUnconstrainedType(OldNTTP->getType()); + QualType NewType = S.Context.getUnconstrainedType(NewNTTP->getType()); + if (!S.Context.hasSameType(OldType, NewType)) { + if (Complain) { + unsigned NextDiag = diag::err_template_nontype_parm_different_type; + if (TemplateArgLoc.isValid()) { + S.Diag(TemplateArgLoc, + diag::err_template_arg_template_params_mismatch); + NextDiag = diag::note_template_nontype_parm_different_type; } - - return false; + S.Diag(NewNTTP->getLocation(), NextDiag) + << NewNTTP->getType() << (Kind != Sema::TPL_TemplateMatch); + S.Diag(OldNTTP->getLocation(), + diag::note_template_nontype_parm_prev_declaration) + << OldNTTP->getType(); } + + return false; } } // For template template parameters, check the template parameter types. @@ -7835,7 +7837,6 @@ static bool MatchTemplateParameterKind( } if (Kind != Sema::TPL_TemplateParamsEquivalent && - Kind != Sema::TPL_TemplateTemplateArgumentMatch && !isa<TemplateTemplateParmDecl>(Old)) { const Expr *NewC = nullptr, *OldC = nullptr; @@ -7906,7 +7907,7 @@ bool Sema::TemplateParameterListsAreEqual( const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New, const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc) { - if (Old->size() != New->size() && Kind != TPL_TemplateTemplateArgumentMatch) { + if (Old->size() != New->size()) { if (Complain) DiagnoseTemplateParameterListArityMismatch(*this, New, Old, Kind, TemplateArgLoc); @@ -7923,40 +7924,18 @@ bool Sema::TemplateParameterListsAreEqual( TemplateParameterList::iterator NewParm = New->begin(); TemplateParameterList::iterator NewParmEnd = New->end(); for (TemplateParameterList::iterator OldParm = Old->begin(), - OldParmEnd = Old->end(); - OldParm != OldParmEnd; ++OldParm) { - if (Kind != TPL_TemplateTemplateArgumentMatch || - !(*OldParm)->isTemplateParameterPack()) { - if (NewParm == NewParmEnd) { - if (Complain) - DiagnoseTemplateParameterListArityMismatch(*this, New, Old, Kind, - TemplateArgLoc); - - return false; - } - - if (!MatchTemplateParameterKind(*this, *NewParm, NewInstFrom, *OldParm, - OldInstFrom, Complain, Kind, - TemplateArgLoc)) - return false; - - ++NewParm; - continue; - } - - // C++0x [temp.arg.template]p3: - // [...] When P's template- parameter-list contains a template parameter - // pack (14.5.3), the template parameter pack will match zero or more - // template parameters or template parameter packs in the - // template-parameter-list of A with the same type and form as the - // template parameter pack in P (ignoring whether those template - // parameters are template parameter packs). - for (; NewParm != NewParmEnd; ++NewParm) { - if (!MatchTemplateParameterKind(*this, *NewParm, NewInstFrom, *OldParm, - OldInstFrom, Complain, Kind, - TemplateArgLoc)) - return false; + OldParmEnd = Old->end(); + OldParm != OldParmEnd; ++OldParm, ++NewParm) { + if (NewParm == NewParmEnd) { + if (Complain) + DiagnoseTemplateParameterListArityMismatch(*this, New, Old, Kind, + TemplateArgLoc); + return false; } + if (!MatchTemplateParameterKind(*this, *NewParm, NewInstFrom, *OldParm, + OldInstFrom, Complain, Kind, + TemplateArgLoc)) + return false; } // Make sure we exhausted all of the arguments. @@ -7968,8 +7947,7 @@ bool Sema::TemplateParameterListsAreEqual( return false; } - if (Kind != TPL_TemplateTemplateArgumentMatch && - Kind != TPL_TemplateParamsEquivalent) { + if (Kind != TPL_TemplateParamsEquivalent) { const Expr *NewRC = New->getRequiresClause(); const Expr *OldRC = Old->getRequiresClause(); @@ -8441,11 +8419,10 @@ DeclResult Sema::ActOnClassTemplateSpecialization( // Check that the template argument list is well-formed for this // template. - SmallVector<TemplateArgument, 4> SugaredConverted, CanonicalConverted; + CheckTemplateArgumentInfo CTAI; if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc, TemplateArgs, /*DefaultArgs=*/{}, - /*PartialTemplateArgs=*/false, SugaredConverted, - CanonicalConverted, + /*PartialTemplateArgs=*/false, CTAI, /*UpdateArgsWithConversions=*/true)) return true; @@ -8454,14 +8431,14 @@ DeclResult Sema::ActOnClassTemplateSpecialization( if (isPartialSpecialization) { if (CheckTemplatePartialSpecializationArgs(TemplateNameLoc, ClassTemplate, TemplateArgs.size(), - CanonicalConverted)) + CTAI.CanonicalConverted)) return true; // FIXME: Move this to CheckTemplatePartialSpecializationArgs so we // also do it during instantiation. if (!Name.isDependent() && !TemplateSpecializationType::anyDependentTemplateArguments( - TemplateArgs, CanonicalConverted)) { + TemplateArgs, CTAI.CanonicalConverted)) { Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized) << ClassTemplate->getDeclName(); isPartialSpecialization = false; @@ -8474,9 +8451,10 @@ DeclResult Sema::ActOnClassTemplateSpecialization( if (isPartialSpecialization) PrevDecl = ClassTemplate->findPartialSpecialization( - CanonicalConverted, TemplateParams, InsertPos); + CTAI.CanonicalConverted, TemplateParams, InsertPos); else - PrevDecl = ClassTemplate->findSpecialization(CanonicalConverted, InsertPos); + PrevDecl = + ClassTemplate->findSpecialization(CTAI.CanonicalConverted, InsertPos); ClassTemplateSpecializationDecl *Specialization = nullptr; @@ -8495,7 +8473,7 @@ DeclResult Sema::ActOnClassTemplateSpecialization( // arguments of the class template partial specialization. TemplateName CanonTemplate = Context.getCanonicalTemplateName(Name); CanonType = Context.getTemplateSpecializationType(CanonTemplate, - CanonicalConverted); + CTAI.CanonicalConverted); if (Context.hasSameType(CanonType, ClassTemplate->getInjectedClassNameSpecialization()) && @@ -8525,7 +8503,7 @@ DeclResult Sema::ActOnClassTemplateSpecialization( ClassTemplatePartialSpecializationDecl *Partial = ClassTemplatePartialSpecializationDecl::Create( Context, Kind, DC, KWLoc, TemplateNameLoc, TemplateParams, - ClassTemplate, CanonicalConverted, CanonType, PrevPartial); + ClassTemplate, CTAI.CanonicalConverted, CanonType, PrevPartial); Partial->setTemplateArgsAsWritten(TemplateArgs); SetNestedNameSpecifier(*this, Partial, SS); if (TemplateParameterLists.size() > 1 && SS.isSet()) { @@ -8548,7 +8526,7 @@ DeclResult Sema::ActOnClassTemplateSpecialization( // this explicit specialization or friend declaration. Specialization = ClassTemplateSpecializationDecl::Create( Context, Kind, DC, KWLoc, TemplateNameLoc, ClassTemplate, - CanonicalConverted, PrevDecl); + CTAI.CanonicalConverted, PrevDecl); Specialization->setTemplateArgsAsWritten(TemplateArgs); SetNestedNameSpecifier(*this, Specialization, SS); if (TemplateParameterLists.size() > 0) { @@ -8561,8 +8539,8 @@ DeclResult Sema::ActOnClassTemplateSpecialization( if (CurContext->isDependentContext()) { TemplateName CanonTemplate = Context.getCanonicalTemplateName(Name); - CanonType = Context.getTemplateSpecializationType(CanonTemplate, - CanonicalConverted); + CanonType = Context.getTemplateSpecializationType( + CanonTemplate, CTAI.CanonicalConverted); } else { CanonType = Context.getTypeDeclType(Specialization); } @@ -9821,21 +9799,18 @@ DeclResult Sema::ActOnExplicitInstantiation( // Check that the template argument list is well-formed for this // template. - bool PrimaryHasMatchedPackOnParmToNonPackOnArg = false; - SmallVector<TemplateArgument, 4> SugaredConverted, CanonicalConverted; - if (CheckTemplateArgumentList( - ClassTemplate, TemplateNameLoc, TemplateArgs, - /*DefaultArgs=*/{}, false, SugaredConverted, CanonicalConverted, - /*UpdateArgsWithConversions=*/true, - /*ConstraintsNotSatisfied=*/nullptr, /*PartialOrderingTTP=*/false, - &PrimaryHasMatchedPackOnParmToNonPackOnArg)) + CheckTemplateArgumentInfo CTAI; + if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc, TemplateArgs, + /*DefaultArgs=*/{}, false, CTAI, + /*UpdateArgsWithConversions=*/true, + /*ConstraintsNotSatisfied=*/nullptr)) return true; // Find the class template specialization declaration that // corresponds to these arguments. void *InsertPos = nullptr; ClassTemplateSpecializationDecl *PrevDecl = - ClassTemplate->findSpecialization(CanonicalConverted, InsertPos); + ClassTemplate->findSpecialization(CTAI.CanonicalConverted, InsertPos); TemplateSpecializationKind PrevDecl_TSK = PrevDecl ? PrevDecl->getTemplateSpecializationKind() : TSK_Undeclared; @@ -9894,7 +9869,7 @@ DeclResult Sema::ActOnExplicitInstantiation( // this explicit specialization. Specialization = ClassTemplateSpecializationDecl::Create( Context, Kind, ClassTemplate->getDeclContext(), KWLoc, TemplateNameLoc, - ClassTemplate, CanonicalConverted, PrevDecl); + ClassTemplate, CTAI.CanonicalConverted, PrevDecl); SetNestedNameSpecifier(*this, Specialization, SS); // A MSInheritanceAttr attached to the previous declaration must be @@ -9951,7 +9926,7 @@ DeclResult Sema::ActOnExplicitInstantiation( if (!Def) InstantiateClassTemplateSpecialization( TemplateNameLoc, Specialization, TSK, - /*Complain=*/true, PrimaryHasMatchedPackOnParmToNonPackOnArg); + /*Complain=*/true, CTAI.MatchedPackOnParmToNonPackOnArg); else if (TSK == TSK_ExplicitInstantiationDefinition) { MarkVTableUsed(TemplateNameLoc, Specialization, true); Specialization->setPointOfInstantiation(Def->getPointOfInstantiation()); diff --git clang/lib/Sema/SemaTemplateDeduction.cpp clang/lib/Sema/SemaTemplateDeduction.cpp index 7882d7a755d3..6aaf86a6a6ff 100644 --- clang/lib/Sema/SemaTemplateDeduction.cpp +++ clang/lib/Sema/SemaTemplateDeduction.cpp @@ -53,6 +53,7 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/SaveAndRestore.h" #include <algorithm> #include <cassert> #include <optional> @@ -2541,10 +2542,9 @@ DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams, return TemplateDeductionResult::NonDeducedMismatch; case TemplateArgument::NullPtr: - if (A.getKind() == TemplateArgument::NullPtr && - S.Context.hasSameType(P.getNullPtrType(), A.getNullPtrType())) + // 'nullptr' has only one possible value, so it always matches. + if (A.getKind() == TemplateArgument::NullPtr) return TemplateDeductionResult::Success; - Info.FirstArg = P; Info.SecondArg = A; return TemplateDeductionResult::NonDeducedMismatch; @@ -2559,6 +2559,8 @@ DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams, return TemplateDeductionResult::NonDeducedMismatch; case TemplateArgument::StructuralValue: + // FIXME: structural equality will also compare types, + // but they should match iff they have the same value. if (A.getKind() == TemplateArgument::StructuralValue && A.structurallyEquals(P)) return TemplateDeductionResult::Success; @@ -2956,11 +2958,11 @@ Sema::getIdentityTemplateArgumentLoc(NamedDecl *TemplateParm, /// Convert the given deduced template argument and add it to the set of /// fully-converted template arguments. -static bool ConvertDeducedTemplateArgument( - Sema &S, NamedDecl *Param, DeducedTemplateArgument Arg, NamedDecl *Template, - TemplateDeductionInfo &Info, bool IsDeduced, bool PartialOrdering, - SmallVectorImpl<TemplateArgument> &SugaredOutput, - SmallVectorImpl<TemplateArgument> &CanonicalOutput) { +static bool +ConvertDeducedTemplateArgument(Sema &S, NamedDecl *Param, + DeducedTemplateArgument Arg, NamedDecl *Template, + TemplateDeductionInfo &Info, bool IsDeduced, + Sema::CheckTemplateArgumentInfo &CTAI) { auto ConvertArg = [&](DeducedTemplateArgument Arg, unsigned ArgumentPackIndex) { // Convert the deduced template argument into a template @@ -2969,18 +2971,17 @@ static bool ConvertDeducedTemplateArgument( TemplateArgumentLoc ArgLoc = S.getTrivialTemplateArgumentLoc( Arg, QualType(), Info.getLocation(), Param); - bool MatchedPackOnParmToNonPackOnArg = false; + SaveAndRestore _1(CTAI.MatchingTTP, false); + SaveAndRestore _2(CTAI.MatchedPackOnParmToNonPackOnArg, false); // Check the template argument, converting it as necessary. auto Res = S.CheckTemplateArgument( Param, ArgLoc, Template, Template->getLocation(), - Template->getSourceRange().getEnd(), ArgumentPackIndex, SugaredOutput, - CanonicalOutput, + Template->getSourceRange().getEnd(), ArgumentPackIndex, CTAI, IsDeduced ? (Arg.wasDeducedFromArrayBound() ? Sema::CTAK_DeducedFromArrayBound : Sema::CTAK_Deduced) - : Sema::CTAK_Specified, - PartialOrdering, &MatchedPackOnParmToNonPackOnArg); - if (MatchedPackOnParmToNonPackOnArg) + : Sema::CTAK_Specified); + if (CTAI.MatchedPackOnParmToNonPackOnArg) Info.setMatchedPackOnParmToNonPackOnArg(); return Res; }; @@ -3012,20 +3013,21 @@ static bool ConvertDeducedTemplateArgument( return true; // Move the converted template argument into our argument pack. - SugaredPackedArgsBuilder.push_back(SugaredOutput.pop_back_val()); - CanonicalPackedArgsBuilder.push_back(CanonicalOutput.pop_back_val()); + SugaredPackedArgsBuilder.push_back(CTAI.SugaredConverted.pop_back_val()); + CanonicalPackedArgsBuilder.push_back( + CTAI.CanonicalConverted.pop_back_val()); } // If the pack is empty, we still need to substitute into the parameter // itself, in case that substitution fails. if (SugaredPackedArgsBuilder.empty()) { LocalInstantiationScope Scope(S); - MultiLevelTemplateArgumentList Args(Template, SugaredOutput, + MultiLevelTemplateArgumentList Args(Template, CTAI.SugaredConverted, /*Final=*/true); if (auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) { Sema::InstantiatingTemplate Inst(S, Template->getLocation(), Template, - NTTP, SugaredOutput, + NTTP, CTAI.SugaredConverted, Template->getSourceRange()); if (Inst.isInvalid() || S.SubstType(NTTP->getType(), Args, NTTP->getLocation(), @@ -3033,7 +3035,7 @@ static bool ConvertDeducedTemplateArgument( return true; } else if (auto *TTP = dyn_cast<TemplateTemplateParmDecl>(Param)) { Sema::InstantiatingTemplate Inst(S, Template->getLocation(), Template, - TTP, SugaredOutput, + TTP, CTAI.SugaredConverted, Template->getSourceRange()); if (Inst.isInvalid() || !S.SubstDecl(TTP, S.CurContext, Args)) return true; @@ -3042,9 +3044,9 @@ static bool ConvertDeducedTemplateArgument( } // Create the resulting argument pack. - SugaredOutput.push_back( + CTAI.SugaredConverted.push_back( TemplateArgument::CreatePackCopy(S.Context, SugaredPackedArgsBuilder)); - CanonicalOutput.push_back(TemplateArgument::CreatePackCopy( + CTAI.CanonicalConverted.push_back(TemplateArgument::CreatePackCopy( S.Context, CanonicalPackedArgsBuilder)); return false; } @@ -3063,9 +3065,7 @@ template <typename TemplateDeclT> static TemplateDeductionResult ConvertDeducedTemplateArguments( Sema &S, TemplateDeclT *Template, bool IsDeduced, SmallVectorImpl<DeducedTemplateArgument> &Deduced, - TemplateDeductionInfo &Info, - SmallVectorImpl<TemplateArgument> &SugaredBuilder, - SmallVectorImpl<TemplateArgument> &CanonicalBuilder, bool PartialOrdering, + TemplateDeductionInfo &Info, Sema::CheckTemplateArgumentInfo &CTAI, LocalInstantiationScope *CurrentInstantiationScope, unsigned NumAlreadyConverted, bool *IsIncomplete) { TemplateParameterList *TemplateParams = Template->getTemplateParameters(); @@ -3100,8 +3100,8 @@ static TemplateDeductionResult ConvertDeducedTemplateArguments( // We have already fully type-checked and converted this // argument, because it was explicitly-specified. Just record the // presence of this argument. - SugaredBuilder.push_back(Deduced[I]); - CanonicalBuilder.push_back( + CTAI.SugaredConverted.push_back(Deduced[I]); + CTAI.CanonicalConverted.push_back( S.Context.getCanonicalTemplateArgument(Deduced[I])); continue; } @@ -3110,13 +3110,13 @@ static TemplateDeductionResult ConvertDeducedTemplateArguments( // We may have deduced this argument, so it still needs to be // checked and converted. if (ConvertDeducedTemplateArgument(S, Param, Deduced[I], Template, Info, - IsDeduced, PartialOrdering, - SugaredBuilder, CanonicalBuilder)) { + IsDeduced, CTAI)) { Info.Param = makeTemplateParameter(Param); // FIXME: These template arguments are temporary. Free them! Info.reset( - TemplateArgumentList::CreateCopy(S.Context, SugaredBuilder), - TemplateArgumentList::CreateCopy(S.Context, CanonicalBuilder)); + TemplateArgumentList::CreateCopy(S.Context, CTAI.SugaredConverted), + TemplateArgumentList::CreateCopy(S.Context, + CTAI.CanonicalConverted)); return TemplateDeductionResult::SubstitutionFailure; } @@ -3130,8 +3130,8 @@ static TemplateDeductionResult ConvertDeducedTemplateArguments( // arguments. if (IsIncomplete) { *IsIncomplete = true; - SugaredBuilder.push_back({}); - CanonicalBuilder.push_back({}); + CTAI.SugaredConverted.push_back({}); + CTAI.CanonicalConverted.push_back({}); continue; } @@ -3160,31 +3160,34 @@ static TemplateDeductionResult ConvertDeducedTemplateArguments( DefArg = S.SubstDefaultTemplateArgumentIfAvailable( TD, TD->getLocation(), TD->getSourceRange().getEnd(), Param, - SugaredBuilder, CanonicalBuilder, HasDefaultArg); + CTAI.SugaredConverted, CTAI.CanonicalConverted, HasDefaultArg); } // If there was no default argument, deduction is incomplete. if (DefArg.getArgument().isNull()) { Info.Param = makeTemplateParameter( const_cast<NamedDecl *>(TemplateParams->getParam(I))); - Info.reset(TemplateArgumentList::CreateCopy(S.Context, SugaredBuilder), - TemplateArgumentList::CreateCopy(S.Context, CanonicalBuilder)); + Info.reset( + TemplateArgumentList::CreateCopy(S.Context, CTAI.SugaredConverted), + TemplateArgumentList::CreateCopy(S.Context, CTAI.CanonicalConverted)); return HasDefaultArg ? TemplateDeductionResult::SubstitutionFailure : TemplateDeductionResult::Incomplete; } + SaveAndRestore _1(CTAI.PartialOrdering, false); + SaveAndRestore _2(CTAI.MatchingTTP, false); + SaveAndRestore _3(CTAI.MatchedPackOnParmToNonPackOnArg, false); // Check whether we can actually use the default argument. if (S.CheckTemplateArgument( Param, DefArg, TD, TD->getLocation(), TD->getSourceRange().getEnd(), - /*ArgumentPackIndex=*/0, SugaredBuilder, CanonicalBuilder, - Sema::CTAK_Specified, /*PartialOrdering=*/false, - /*MatchedPackOnParmToNonPackOnArg=*/nullptr)) { + /*ArgumentPackIndex=*/0, CTAI, Sema::CTAK_Specified)) { Info.Param = makeTemplateParameter( const_cast<NamedDecl *>(TemplateParams->getParam(I))); // FIXME: These template arguments are temporary. Free them! - Info.reset(TemplateArgumentList::CreateCopy(S.Context, SugaredBuilder), - TemplateArgumentList::CreateCopy(S.Context, CanonicalBuilder)); + Info.reset( + TemplateArgumentList::CreateCopy(S.Context, CTAI.SugaredConverted), + TemplateArgumentList::CreateCopy(S.Context, CTAI.CanonicalConverted)); return TemplateDeductionResult::SubstitutionFailure; } @@ -3284,10 +3287,9 @@ FinishTemplateArgumentDeduction( // C++ [temp.deduct.type]p2: // [...] or if any template argument remains neither deduced nor // explicitly specified, template argument deduction fails. - SmallVector<TemplateArgument, 4> SugaredBuilder, CanonicalBuilder; + Sema::CheckTemplateArgumentInfo CTAI(IsPartialOrdering); if (auto Result = ConvertDeducedTemplateArguments( - S, Partial, IsPartialOrdering, Deduced, Info, SugaredBuilder, - CanonicalBuilder, IsPartialOrdering, + S, Partial, IsPartialOrdering, Deduced, Info, CTAI, /*CurrentInstantiationScope=*/nullptr, /*NumAlreadyConverted=*/0, /*IsIncomplete=*/nullptr); Result != TemplateDeductionResult::Success) @@ -3295,9 +3297,9 @@ FinishTemplateArgumentDeduction( // Form the template argument list from the deduced template arguments. TemplateArgumentList *SugaredDeducedArgumentList = - TemplateArgumentList::CreateCopy(S.Context, SugaredBuilder); + TemplateArgumentList::CreateCopy(S.Context, CTAI.SugaredConverted); TemplateArgumentList *CanonicalDeducedArgumentList = - TemplateArgumentList::CreateCopy(S.Context, CanonicalBuilder); + TemplateArgumentList::CreateCopy(S.Context, CTAI.CanonicalConverted); Info.reset(SugaredDeducedArgumentList, CanonicalDeducedArgumentList); @@ -3314,11 +3316,11 @@ FinishTemplateArgumentDeduction( TemplateArgumentListInfo InstArgs(PartialTemplArgInfo->LAngleLoc, PartialTemplArgInfo->RAngleLoc); - if (S.SubstTemplateArguments(PartialTemplArgInfo->arguments(), - MultiLevelTemplateArgumentList(Partial, - SugaredBuilder, - /*Final=*/true), - InstArgs)) { + if (S.SubstTemplateArguments( + PartialTemplArgInfo->arguments(), + MultiLevelTemplateArgumentList(Partial, CTAI.SugaredConverted, + /*Final=*/true), + InstArgs)) { unsigned ArgIdx = InstArgs.size(), ParamIdx = ArgIdx; if (ParamIdx >= Partial->getTemplateParameters()->size()) ParamIdx = Partial->getTemplateParameters()->size() - 1; @@ -3330,24 +3332,21 @@ FinishTemplateArgumentDeduction( return TemplateDeductionResult::SubstitutionFailure; } - bool MatchedPackOnParmToNonPackOnArg = false; bool ConstraintsNotSatisfied; - SmallVector<TemplateArgument, 4> SugaredConvertedInstArgs, - CanonicalConvertedInstArgs; - if (S.CheckTemplateArgumentList( - Template, Partial->getLocation(), InstArgs, /*DefaultArgs=*/{}, false, - SugaredConvertedInstArgs, CanonicalConvertedInstArgs, - /*UpdateArgsWithConversions=*/true, &ConstraintsNotSatisfied, - /*PartialOrderingTTP=*/false, &MatchedPackOnParmToNonPackOnArg)) + Sema::CheckTemplateArgumentInfo InstCTAI; + if (S.CheckTemplateArgumentList(Template, Partial->getLocation(), InstArgs, + /*DefaultArgs=*/{}, false, InstCTAI, + /*UpdateArgsWithConversions=*/true, + &ConstraintsNotSatisfied)) return ConstraintsNotSatisfied ? TemplateDeductionResult::ConstraintsNotSatisfied : TemplateDeductionResult::SubstitutionFailure; - if (MatchedPackOnParmToNonPackOnArg) + if (InstCTAI.MatchedPackOnParmToNonPackOnArg) Info.setMatchedPackOnParmToNonPackOnArg(); TemplateParameterList *TemplateParams = Template->getTemplateParameters(); for (unsigned I = 0, E = TemplateParams->size(); I != E; ++I) { - TemplateArgument InstArg = SugaredConvertedInstArgs.data()[I]; + TemplateArgument InstArg = InstCTAI.SugaredConverted.data()[I]; if (!isSameTemplateArg(S.Context, TemplateArgs[I], InstArg, IsPartialOrdering)) { Info.Param = makeTemplateParameter(TemplateParams->getParam(I)); @@ -3362,7 +3361,7 @@ FinishTemplateArgumentDeduction( if (!IsPartialOrdering) { if (auto Result = CheckDeducedArgumentConstraints( - S, Partial, SugaredBuilder, CanonicalBuilder, Info); + S, Partial, CTAI.SugaredConverted, CTAI.CanonicalConverted, Info); Result != TemplateDeductionResult::Success) return Result; } @@ -3387,10 +3386,9 @@ static TemplateDeductionResult FinishTemplateArgumentDeduction( // C++ [temp.deduct.type]p2: // [...] or if any template argument remains neither deduced nor // explicitly specified, template argument deduction fails. - SmallVector<TemplateArgument, 4> SugaredBuilder, CanonicalBuilder; + Sema::CheckTemplateArgumentInfo CTAI(PartialOrdering); if (auto Result = ConvertDeducedTemplateArguments( - S, Template, /*IsDeduced=*/PartialOrdering, Deduced, Info, - SugaredBuilder, CanonicalBuilder, PartialOrdering, + S, Template, /*IsDeduced=*/PartialOrdering, Deduced, Info, CTAI, /*CurrentInstantiationScope=*/nullptr, /*NumAlreadyConverted=*/0U, /*IsIncomplete=*/nullptr); Result != TemplateDeductionResult::Success) @@ -3398,7 +3396,7 @@ static TemplateDeductionResult FinishTemplateArgumentDeduction( // Check that we produced the correct argument list. SmallVector<ArrayRef<TemplateArgument>, 4> PsStack{TemplateArgs}, - AsStack{CanonicalBuilder}; + AsStack{CTAI.CanonicalConverted}; for (;;) { auto take = [](SmallVectorImpl<ArrayRef<TemplateArgument>> &Stack) -> std::tuple<ArrayRef<TemplateArgument> &, TemplateArgument> { @@ -3455,7 +3453,7 @@ static TemplateDeductionResult FinishTemplateArgumentDeduction( if (!PartialOrdering) { if (auto Result = CheckDeducedArgumentConstraints( - S, Template, SugaredBuilder, CanonicalBuilder, Info); + S, Template, CTAI.SugaredConverted, CTAI.CanonicalConverted, Info); Result != TemplateDeductionResult::Success) return Result; } @@ -3479,17 +3477,16 @@ static TemplateDeductionResult FinishTemplateArgumentDeduction( // C++ [temp.deduct.type]p2: // [...] or if any template argument remains neither deduced nor // explicitly specified, template argument deduction fails. - SmallVector<TemplateArgument, 4> SugaredBuilder, CanonicalBuilder; + Sema::CheckTemplateArgumentInfo CTAI; if (auto Result = ConvertDeducedTemplateArguments( - S, TD, /*IsDeduced=*/false, Deduced, Info, SugaredBuilder, - CanonicalBuilder, /*PartialOrdering=*/false, + S, TD, /*IsDeduced=*/false, Deduced, Info, CTAI, /*CurrentInstantiationScope=*/nullptr, /*NumAlreadyConverted=*/0, /*IsIncomplete=*/nullptr); Result != TemplateDeductionResult::Success) return Result; - return ::CheckDeducedArgumentConstraints(S, TD, SugaredBuilder, - CanonicalBuilder, Info); + return ::CheckDeducedArgumentConstraints(S, TD, CTAI.SugaredConverted, + CTAI.CanonicalConverted, Info); } /// Perform template argument deduction to determine whether the given template @@ -3670,7 +3667,6 @@ TemplateDeductionResult Sema::SubstituteExplicitTemplateArguments( // declaration order of their corresponding template-parameters. The // template argument list shall not specify more template-arguments than // there are corresponding template-parameters. - SmallVector<TemplateArgument, 4> SugaredBuilder, CanonicalBuilder; // Enter a new template instantiation context where we check the // explicitly-specified template arguments against this function template, @@ -3682,12 +3678,13 @@ TemplateDeductionResult Sema::SubstituteExplicitTemplateArguments( if (Inst.isInvalid()) return TemplateDeductionResult::InstantiationDepth; + CheckTemplateArgumentInfo CTAI; if (CheckTemplateArgumentList(FunctionTemplate, SourceLocation(), - ExplicitTemplateArgs, /*DefaultArgs=*/{}, true, - SugaredBuilder, CanonicalBuilder, + ExplicitTemplateArgs, /*DefaultArgs=*/{}, + /*PartialTemplateArgs=*/true, CTAI, /*UpdateArgsWithConversions=*/false) || Trap.hasErrorOccurred()) { - unsigned Index = SugaredBuilder.size(); + unsigned Index = CTAI.SugaredConverted.size(); if (Index >= TemplateParams->size()) return TemplateDeductionResult::SubstitutionFailure; Info.Param = makeTemplateParameter(TemplateParams->getParam(Index)); @@ -3697,9 +3694,9 @@ TemplateDeductionResult Sema::SubstituteExplicitTemplateArguments( // Form the template argument list from the explicitly-specified // template arguments. TemplateArgumentList *SugaredExplicitArgumentList = - TemplateArgumentList::CreateCopy(Context, SugaredBuilder); + TemplateArgumentList::CreateCopy(Context, CTAI.SugaredConverted); TemplateArgumentList *CanonicalExplicitArgumentList = - TemplateArgumentList::CreateCopy(Context, CanonicalBuilder); + TemplateArgumentList::CreateCopy(Context, CTAI.CanonicalConverted); Info.setExplicitArgs(SugaredExplicitArgumentList, CanonicalExplicitArgumentList); @@ -3714,15 +3711,15 @@ TemplateDeductionResult Sema::SubstituteExplicitTemplateArguments( // the explicit template arguments. They'll be used as part of deduction // for this template parameter pack. unsigned PartiallySubstitutedPackIndex = -1u; - if (!SugaredBuilder.empty()) { - const TemplateArgument &Arg = SugaredBuilder.back(); + if (!CTAI.SugaredConverted.empty()) { + const TemplateArgument &Arg = CTAI.SugaredConverted.back(); if (Arg.getKind() == TemplateArgument::Pack) { - auto *Param = TemplateParams->getParam(SugaredBuilder.size() - 1); + auto *Param = TemplateParams->getParam(CTAI.SugaredConverted.size() - 1); // If this is a fully-saturated fixed-size pack, it should be // fully-substituted, not partially-substituted. std::optional<unsigned> Expansions = getExpandedPackSize(Param); if (!Expansions || Arg.pack_size() < *Expansions) { - PartiallySubstitutedPackIndex = SugaredBuilder.size() - 1; + PartiallySubstitutedPackIndex = CTAI.SugaredConverted.size() - 1; CurrentInstantiationScope->SetPartiallySubstitutedPack( Param, Arg.pack_begin(), Arg.pack_size()); } @@ -4044,10 +4041,9 @@ TemplateDeductionResult Sema::FinishTemplateArgumentDeduction( // [...] or if any template argument remains neither deduced nor // explicitly specified, template argument deduction fails. bool IsIncomplete = false; - SmallVector<TemplateArgument, 4> SugaredBuilder, CanonicalBuilder; + CheckTemplateArgumentInfo CTAI(PartialOrdering); if (auto Result = ConvertDeducedTemplateArguments( - *this, FunctionTemplate, /*IsDeduced=*/true, Deduced, Info, - SugaredBuilder, CanonicalBuilder, PartialOrdering, + *this, FunctionTemplate, /*IsDeduced=*/true, Deduced, Info, CTAI, CurrentInstantiationScope, NumExplicitlySpecified, PartialOverloading ? &IsIncomplete : nullptr); Result != TemplateDeductionResult::Success) @@ -4067,9 +4063,9 @@ TemplateDeductionResult Sema::FinishTemplateArgumentDeduction( // Form the template argument list from the deduced template arguments. TemplateArgumentList *SugaredDeducedArgumentList = - TemplateArgumentList::CreateCopy(Context, SugaredBuilder); + TemplateArgumentList::CreateCopy(Context, CTAI.SugaredConverted); TemplateArgumentList *CanonicalDeducedArgumentList = - TemplateArgumentList::CreateCopy(Context, CanonicalBuilder); + TemplateArgumentList::CreateCopy(Context, CTAI.CanonicalConverted); Info.reset(SugaredDeducedArgumentList, CanonicalDeducedArgumentList); // Substitute the deduced template arguments into the function template @@ -4078,22 +4074,7 @@ TemplateDeductionResult Sema::FinishTemplateArgumentDeduction( if (FunctionTemplate->getFriendObjectKind()) Owner = FunctionTemplate->getLexicalDeclContext(); FunctionDecl *FD = FunctionTemplate->getTemplatedDecl(); - // additional check for inline friend, - // ``` - // template <class F1> int foo(F1 X); - // template <int A1> struct A { - // template <class F1> friend int foo(F1 X) { return A1; } - // }; - // template struct A<1>; - // int a = foo(1.0); - // ``` - const FunctionDecl *FDFriend; - if (FD->getFriendObjectKind() == Decl::FriendObjectKind::FOK_None && - FD->isDefined(FDFriend, /*CheckForPendingFriendDefinition*/ true) && - FDFriend->getFriendObjectKind() != Decl::FriendObjectKind::FOK_None) { - FD = const_cast<FunctionDecl *>(FDFriend); - Owner = FD->getLexicalDeclContext(); - } + MultiLevelTemplateArgumentList SubstArgs( FunctionTemplate, CanonicalDeducedArgumentList->asArray(), /*Final=*/false); @@ -4130,13 +4111,13 @@ TemplateDeductionResult Sema::FinishTemplateArgumentDeduction( // deduction fails. if (!IsIncomplete) { if (CheckInstantiatedFunctionTemplateConstraints( - Info.getLocation(), Specialization, CanonicalBuilder, + Info.getLocation(), Specialization, CTAI.CanonicalConverted, Info.AssociatedConstraintsSatisfaction)) return TemplateDeductionResult::MiscellaneousDeductionFailure; if (!Info.AssociatedConstraintsSatisfaction.IsSatisfied) { - Info.reset(Info.takeSugared(), - TemplateArgumentList::CreateCopy(Context, CanonicalBuilder)); + Info.reset(Info.takeSugared(), TemplateArgumentList::CreateCopy( + Context, CTAI.CanonicalConverted)); return TemplateDeductionResult::ConstraintsNotSatisfied; } } @@ -5219,12 +5200,12 @@ static bool CheckDeducedPlaceholderConstraints(Sema &S, const AutoType &Type, for (unsigned I = 0, C = TypeLoc.getNumArgs(); I != C; ++I) TemplateArgs.addArgument(TypeLoc.getArgLoc(I)); - llvm::SmallVector<TemplateArgument, 4> SugaredConverted, CanonicalConverted; - if (S.CheckTemplateArgumentList( - Concept, SourceLocation(), TemplateArgs, /*DefaultArgs=*/{}, - /*PartialTemplateArgs=*/false, SugaredConverted, CanonicalConverted)) + Sema::CheckTemplateArgumentInfo CTAI; + if (S.CheckTemplateArgumentList(Concept, SourceLocation(), TemplateArgs, + /*DefaultArgs=*/{}, + /*PartialTemplateArgs=*/false, CTAI)) return true; - MultiLevelTemplateArgumentList MLTAL(Concept, CanonicalConverted, + MultiLevelTemplateArgumentList MLTAL(Concept, CTAI.CanonicalConverted, /*Final=*/false); // Build up an EvaluationContext with an ImplicitConceptSpecializationDecl so // that the template arguments of the constraint can be preserved. For @@ -5239,7 +5220,7 @@ static bool CheckDeducedPlaceholderConstraints(Sema &S, const AutoType &Type, S, Sema::ExpressionEvaluationContext::Unevaluated, ImplicitConceptSpecializationDecl::Create( S.getASTContext(), Concept->getDeclContext(), Concept->getLocation(), - CanonicalConverted)); + CTAI.CanonicalConverted)); if (S.CheckConstraintSatisfaction(Concept, {Concept->getConstraintExpr()}, MLTAL, TypeLoc.getLocalSourceRange(), Satisfaction)) @@ -5669,10 +5650,9 @@ static TemplateDeductionResult FinishTemplateArgumentDeduction( // [...] or if any template argument remains neither deduced nor // explicitly specified, template argument deduction fails. bool IsIncomplete = false; - SmallVector<TemplateArgument, 4> SugaredBuilder, CanonicalBuilder; + Sema::CheckTemplateArgumentInfo CTAI(/*PartialOrdering=*/true); if (auto Result = ConvertDeducedTemplateArguments( - S, FTD, /*IsDeduced=*/true, Deduced, Info, SugaredBuilder, - CanonicalBuilder, /*PartialOrdering=*/true, + S, FTD, /*IsDeduced=*/true, Deduced, Info, CTAI, /*CurrentInstantiationScope=*/nullptr, /*NumAlreadyConverted=*/0, &IsIncomplete); Result != TemplateDeductionResult::Success) @@ -5680,9 +5660,9 @@ static TemplateDeductionResult FinishTemplateArgumentDeduction( // Form the template argument list from the deduced template arguments. TemplateArgumentList *SugaredDeducedArgumentList = - TemplateArgumentList::CreateCopy(S.Context, SugaredBuilder); + TemplateArgumentList::CreateCopy(S.Context, CTAI.SugaredConverted); TemplateArgumentList *CanonicalDeducedArgumentList = - TemplateArgumentList::CreateCopy(S.Context, CanonicalBuilder); + TemplateArgumentList::CreateCopy(S.Context, CTAI.CanonicalConverted); Info.reset(SugaredDeducedArgumentList, CanonicalDeducedArgumentList); @@ -5691,7 +5671,7 @@ static TemplateDeductionResult FinishTemplateArgumentDeduction( // and equivalent to the parameter. LocalInstantiationScope InstScope(S); - if (auto TDR = CheckDeductionConsistency(S, FTD, SugaredBuilder); + if (auto TDR = CheckDeductionConsistency(S, FTD, CTAI.SugaredConverted); TDR != TemplateDeductionResult::Success) return TDR; @@ -6568,13 +6548,17 @@ bool Sema::isTemplateTemplateParameterAtLeastAsSpecializedAs( // C++1z [temp.arg.template]p3: // If the rewrite produces an invalid type, then P is not at least as // specialized as A. - SmallVector<TemplateArgument, 4> CanonicalPArgs; - if (CheckTemplateArgumentList( - AArg, ArgLoc, PArgList, DefaultArgs, false, PArgs, CanonicalPArgs, - /*UpdateArgsWithConversions=*/true, - /*ConstraintsNotSatisfied=*/nullptr, - /*PartialOrderingTTP=*/true, MatchedPackOnParmToNonPackOnArg)) + CheckTemplateArgumentInfo CTAI( + /*PartialOrdering=*/false, /*MatchingTTP=*/true); + CTAI.SugaredConverted = std::move(PArgs); + if (CheckTemplateArgumentList(AArg, ArgLoc, PArgList, DefaultArgs, + /*PartialTemplateArgs=*/false, CTAI, + /*UpdateArgsWithConversions=*/true, + /*ConstraintsNotSatisfied=*/nullptr)) return false; + PArgs = std::move(CTAI.SugaredConverted); + if (MatchedPackOnParmToNonPackOnArg) + *MatchedPackOnParmToNonPackOnArg |= CTAI.MatchedPackOnParmToNonPackOnArg; } // Determine whether P1 is at least as specialized as P2. diff --git clang/lib/Sema/SemaTemplateDeductionGuide.cpp clang/lib/Sema/SemaTemplateDeductionGuide.cpp index 950783303efb..00c5dfd3d7a4 100644 --- clang/lib/Sema/SemaTemplateDeductionGuide.cpp +++ clang/lib/Sema/SemaTemplateDeductionGuide.cpp @@ -1175,8 +1175,12 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef, GG->getTypeSourceInfo(), AliasTemplate->getBeginLoc(), AliasTemplate->getLocation(), AliasTemplate->getEndLoc(), F->isImplicit())); - cast<CXXDeductionGuideDecl>(Result->getTemplatedDecl()) - ->setDeductionCandidateKind(GG->getDeductionCandidateKind()); + auto *DGuide = cast<CXXDeductionGuideDecl>(Result->getTemplatedDecl()); + DGuide->setDeductionCandidateKind(GG->getDeductionCandidateKind()); + DGuide->setSourceDeductionGuide( + cast<CXXDeductionGuideDecl>(F->getTemplatedDecl())); + DGuide->setSourceDeductionGuideKind( + CXXDeductionGuideDecl::SourceDeductionGuideKind::Alias); return Result; } return nullptr; diff --git clang/lib/Sema/SemaTemplateInstantiate.cpp clang/lib/Sema/SemaTemplateInstantiate.cpp index 3dc5696bd382..12e98a33d078 100644 --- clang/lib/Sema/SemaTemplateInstantiate.cpp +++ clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -479,9 +479,6 @@ MultiLevelTemplateArgumentList Sema::getTemplateInstantiationArgs( using namespace TemplateInstArgsHelpers; const Decl *CurDecl = ND; - if (!CurDecl) - CurDecl = Decl::castFromDeclContext(DC); - if (Innermost) { Result.addOuterTemplateArguments(const_cast<NamedDecl *>(ND), *Innermost, Final); @@ -495,8 +492,10 @@ MultiLevelTemplateArgumentList Sema::getTemplateInstantiationArgs( // has a depth of 0. if (const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(CurDecl)) HandleDefaultTempArgIntoTempTempParam(TTP, Result); - CurDecl = Response::UseNextDecl(CurDecl).NextDecl; - } + CurDecl = DC ? Decl::castFromDeclContext(DC) + : Response::UseNextDecl(CurDecl).NextDecl; + } else if (!CurDecl) + CurDecl = Decl::castFromDeclContext(DC); while (!CurDecl->isFileContextDecl()) { Response R; @@ -1584,6 +1583,10 @@ namespace { /// pack. ExprResult TransformFunctionParmPackExpr(FunctionParmPackExpr *E); + // Transform a ResolvedUnexpandedPackExpr + ExprResult + TransformResolvedUnexpandedPackExpr(ResolvedUnexpandedPackExpr *E); + QualType TransformFunctionProtoType(TypeLocBuilder &TLB, FunctionProtoTypeLoc TL) { // Call the base version; it will forward to our overridden version below. @@ -1762,23 +1765,6 @@ namespace { return inherited::TransformLambdaBody(E, Body); } - ExprResult TransformSizeOfPackExpr(SizeOfPackExpr *E) { - ExprResult Transformed = inherited::TransformSizeOfPackExpr(E); - if (!Transformed.isUsable()) - return Transformed; - auto *TransformedExpr = cast<SizeOfPackExpr>(Transformed.get()); - if (SemaRef.CodeSynthesisContexts.back().Kind == - Sema::CodeSynthesisContext::ConstraintNormalization && - TransformedExpr->getPack() == E->getPack()) { - Decl *NewPack = - TransformDecl(E->getPackLoc(), TransformedExpr->getPack()); - if (!NewPack) - return ExprError(); - TransformedExpr->setPack(cast<NamedDecl>(NewPack)); - } - return TransformedExpr; - } - ExprResult TransformRequiresExpr(RequiresExpr *E) { LocalInstantiationScope Scope(SemaRef, /*CombineWithOuterScope=*/true); ExprResult TransReq = inherited::TransformRequiresExpr(E); @@ -1866,7 +1852,8 @@ bool TemplateInstantiator::AlreadyTransformed(QualType T) { if (T.isNull()) return true; - if (T->isInstantiationDependentType() || T->isVariablyModifiedType()) + if (T->isInstantiationDependentType() || T->isVariablyModifiedType() || + T->containsUnexpandedParameterPack()) return false; getSema().MarkDeclarationsReferencedInType(Loc, T); @@ -1902,15 +1889,6 @@ Decl *TemplateInstantiator::TransformDecl(SourceLocation Loc, Decl *D) { TemplateArgument Arg = TemplateArgs(TTP->getDepth(), TTP->getPosition()); if (TTP->isParameterPack()) { - // We might not have an index for pack expansion when normalizing - // constraint expressions. In that case, resort to instantiation scopes - // for the transformed declarations. - if (SemaRef.ArgumentPackSubstitutionIndex == -1 && - SemaRef.CodeSynthesisContexts.back().Kind == - Sema::CodeSynthesisContext::ConstraintNormalization) { - return SemaRef.FindInstantiatedDecl(Loc, cast<NamedDecl>(D), - TemplateArgs); - } assert(Arg.getKind() == TemplateArgument::Pack && "Missing argument pack"); Arg = getPackSubstitutedTemplateArgument(getSema(), Arg); @@ -2399,9 +2377,10 @@ TemplateInstantiator::TransformSubstNonTypeTemplateParmExpr( // The call to CheckTemplateArgument here produces the ImpCast. TemplateArgument SugaredConverted, CanonicalConverted; if (SemaRef - .CheckTemplateArgument(E->getParameter(), SubstType, - SubstReplacement.get(), SugaredConverted, - CanonicalConverted, Sema::CTAK_Specified) + .CheckTemplateArgument( + E->getParameter(), SubstType, SubstReplacement.get(), + SugaredConverted, CanonicalConverted, + /*PartialOrderingTTP=*/false, Sema::CTAK_Specified) .isInvalid()) return true; return transformNonTypeTemplateParmRef(E->getAssociatedDecl(), @@ -2499,6 +2478,15 @@ TemplateInstantiator::TransformDeclRefExpr(DeclRefExpr *E) { if (PD->isParameterPack()) return TransformFunctionParmPackRefExpr(E, PD); + if (BindingDecl *BD = dyn_cast<BindingDecl>(D); BD && BD->isParameterPack()) { + BD = cast_or_null<BindingDecl>(TransformDecl(BD->getLocation(), BD)); + if (!BD) + return ExprError(); + if (auto *RP = + dyn_cast_if_present<ResolvedUnexpandedPackExpr>(BD->getBinding())) + return TransformResolvedUnexpandedPackExpr(RP); + } + return inherited::TransformDeclRefExpr(E); } @@ -2663,6 +2651,19 @@ TemplateInstantiator::TransformTemplateTypeParmType(TypeLocBuilder &TLB, return Result; } +ExprResult TemplateInstantiator::TransformResolvedUnexpandedPackExpr( + ResolvedUnexpandedPackExpr *E) { + if (getSema().ArgumentPackSubstitutionIndex != -1) { + assert(static_cast<unsigned>(getSema().ArgumentPackSubstitutionIndex) < + E->getNumExprs() && + "ArgumentPackSubstitutionIndex is out of range"); + return TransformExpr( + E->getExpansion(getSema().ArgumentPackSubstitutionIndex)); + } + + return inherited::TransformResolvedUnexpandedPackExpr(E); +} + QualType TemplateInstantiator::TransformSubstTemplateTypeParmPackType( TypeLocBuilder &TLB, SubstTemplateTypeParmPackTypeLoc TL, bool SuppressObjCLifetime) { diff --git clang/lib/Sema/SemaTemplateInstantiateDecl.cpp clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 6a2331e59477..d530ed0847ae 100644 --- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -12,6 +12,7 @@ #include "TreeTransform.h" #include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTContext.h" +#include "clang/AST/ASTLambda.h" #include "clang/AST/ASTMutationListener.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/DependentDiagnostic.h" @@ -284,7 +285,8 @@ static void instantiateDependentDiagnoseIfAttr( if (Cond) New->addAttr(new (S.getASTContext()) DiagnoseIfAttr( S.getASTContext(), *DIA, Cond, DIA->getMessage(), - DIA->getDiagnosticType(), DIA->getArgDependent(), New)); + DIA->getDefaultSeverity(), DIA->getWarningGroup(), + DIA->getArgDependent(), New)); } // Constructs and adds to New a new instance of CUDALaunchBoundsAttr using @@ -1166,26 +1168,57 @@ TemplateDeclInstantiator::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) { Decl *TemplateDeclInstantiator::VisitBindingDecl(BindingDecl *D) { auto *NewBD = BindingDecl::Create(SemaRef.Context, Owner, D->getLocation(), - D->getIdentifier()); + D->getIdentifier(), D->getType()); NewBD->setReferenced(D->isReferenced()); SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, NewBD); + return NewBD; } Decl *TemplateDeclInstantiator::VisitDecompositionDecl(DecompositionDecl *D) { // Transform the bindings first. + // The transformed DD will have all of the concrete BindingDecls. SmallVector<BindingDecl*, 16> NewBindings; - for (auto *OldBD : D->bindings()) + ResolvedUnexpandedPackExpr *OldResolvedPack = nullptr; + for (auto *OldBD : D->bindings()) { + Expr *BindingExpr = OldBD->getBinding(); + if (auto *RP = + dyn_cast_if_present<ResolvedUnexpandedPackExpr>(BindingExpr)) { + assert(!OldResolvedPack && "no more than one pack is allowed"); + OldResolvedPack = RP; + } NewBindings.push_back(cast<BindingDecl>(VisitBindingDecl(OldBD))); + } ArrayRef<BindingDecl*> NewBindingArray = NewBindings; - auto *NewDD = cast_or_null<DecompositionDecl>( + auto *NewDD = cast_if_present<DecompositionDecl>( VisitVarDecl(D, /*InstantiatingVarTemplate=*/false, &NewBindingArray)); if (!NewDD || NewDD->isInvalidDecl()) for (auto *NewBD : NewBindings) NewBD->setInvalidDecl(); + if (OldResolvedPack) { + // Mark the holding vars (if any) in the pack as instantiated since + // they are created implicitly. + auto Bindings = NewDD->bindings(); + auto BPack = llvm::find_if( + Bindings, [](BindingDecl *D) -> bool { return D->isParameterPack(); }); + auto *NewResolvedPack = + cast<ResolvedUnexpandedPackExpr>((*BPack)->getBinding()); + auto OldExprs = OldResolvedPack->getExprs(); + auto NewExprs = NewResolvedPack->getExprs(); + assert(OldExprs.size() == NewExprs.size()); + for (unsigned I = 0; I < OldResolvedPack->getNumExprs(); I++) { + DeclRefExpr *OldDRE = cast<DeclRefExpr>(OldExprs[I]); + BindingDecl *OldNestedBD = cast<BindingDecl>(OldDRE->getDecl()); + DeclRefExpr *NewDRE = cast<DeclRefExpr>(NewExprs[I]); + BindingDecl *NewNestedBD = cast<BindingDecl>(NewDRE->getDecl()); + SemaRef.CurrentInstantiationScope->InstantiatedLocal(OldNestedBD, + NewNestedBD); + } + } + return NewDD; } @@ -1627,12 +1660,17 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) { // specialization causes the implicit instantiation of the declarations, but // not the definitions of scoped member enumerations. // - // DR1484 clarifies that enumeration definitions inside of a template + // DR1484 clarifies that enumeration definitions inside a template // declaration aren't considered entities that can be separately instantiated - // from the rest of the entity they are declared inside of. + // from the rest of the entity they are declared inside. if (isDeclWithinFunction(D) ? D == Def : Def && !Enum->isScoped()) { - SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Enum); - InstantiateEnumDefinition(Enum, Def); + // Prevent redundant instantiation of the enumerator-definition if the + // definition has already been instantiated due to a prior + // opaque-enum-declaration. + if (PrevDecl == nullptr) { + SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Enum); + InstantiateEnumDefinition(Enum, Def); + } } return Enum; @@ -2264,7 +2302,9 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl( SemaRef.Context, DC, D->getInnerLocStart(), InstantiatedExplicitSpecifier, NameInfo, T, TInfo, D->getSourceRange().getEnd(), DGuide->getCorrespondingConstructor(), - DGuide->getDeductionCandidateKind(), TrailingRequiresClause); + DGuide->getDeductionCandidateKind(), TrailingRequiresClause, + DGuide->getSourceDeductionGuide(), + DGuide->getSourceDeductionGuideKind()); Function->setAccess(D->getAccess()); } else { Function = FunctionDecl::Create( @@ -2606,8 +2646,7 @@ Decl *TemplateDeclInstantiator::VisitCXXMethodDecl( // conditionally populate the TSI without breaking non-template related use // cases. Populate TSIs prior to calling SubstFunctionType to make sure we get // a proper transformation. - if (cast<CXXRecordDecl>(D->getParent())->isLambda() && - !D->getTypeSourceInfo() && + if (isLambdaMethod(D) && !D->getTypeSourceInfo() && isa<CXXConstructorDecl, CXXDestructorDecl>(D)) { TypeSourceInfo *TSI = SemaRef.Context.getTrivialTypeSourceInfo(D->getType()); @@ -3950,10 +3989,10 @@ TemplateDeclInstantiator::VisitClassTemplateSpecializationDecl( // Check that the template argument list is well-formed for this // class template. - SmallVector<TemplateArgument, 4> SugaredConverted, CanonicalConverted; + Sema::CheckTemplateArgumentInfo CTAI; if (SemaRef.CheckTemplateArgumentList( InstClassTemplate, D->getLocation(), InstTemplateArgs, - /*DefaultArgs=*/{}, false, SugaredConverted, CanonicalConverted, + /*DefaultArgs=*/{}, /*PartialTemplateArgs=*/false, CTAI, /*UpdateArgsWithConversions=*/true)) return nullptr; @@ -3961,7 +4000,7 @@ TemplateDeclInstantiator::VisitClassTemplateSpecializationDecl( // in the member template's set of class template explicit specializations. void *InsertPos = nullptr; ClassTemplateSpecializationDecl *PrevDecl = - InstClassTemplate->findSpecialization(CanonicalConverted, InsertPos); + InstClassTemplate->findSpecialization(CTAI.CanonicalConverted, InsertPos); // Check whether we've already seen a conflicting instantiation of this // declaration (for instance, if there was a prior implicit instantiation). @@ -3999,7 +4038,8 @@ TemplateDeclInstantiator::VisitClassTemplateSpecializationDecl( ClassTemplateSpecializationDecl *InstD = ClassTemplateSpecializationDecl::Create( SemaRef.Context, D->getTagKind(), Owner, D->getBeginLoc(), - D->getLocation(), InstClassTemplate, CanonicalConverted, PrevDecl); + D->getLocation(), InstClassTemplate, CTAI.CanonicalConverted, + PrevDecl); InstD->setTemplateArgsAsWritten(InstTemplateArgs); // Add this partial specialization to the set of class template partial @@ -4058,17 +4098,17 @@ Decl *TemplateDeclInstantiator::VisitVarTemplateSpecializationDecl( } // Check that the template argument list is well-formed for this template. - SmallVector<TemplateArgument, 4> SugaredConverted, CanonicalConverted; + Sema::CheckTemplateArgumentInfo CTAI; if (SemaRef.CheckTemplateArgumentList( InstVarTemplate, D->getLocation(), VarTemplateArgsInfo, - /*DefaultArgs=*/{}, false, SugaredConverted, CanonicalConverted, + /*DefaultArgs=*/{}, /*PartialTemplateArgs=*/false, CTAI, /*UpdateArgsWithConversions=*/true)) return nullptr; // Check whether we've already seen a declaration of this specialization. void *InsertPos = nullptr; VarTemplateSpecializationDecl *PrevDecl = - InstVarTemplate->findSpecialization(CanonicalConverted, InsertPos); + InstVarTemplate->findSpecialization(CTAI.CanonicalConverted, InsertPos); // Check whether we've already seen a conflicting instantiation of this // declaration (for instance, if there was a prior implicit instantiation). @@ -4079,8 +4119,9 @@ Decl *TemplateDeclInstantiator::VisitVarTemplateSpecializationDecl( PrevDecl->getPointOfInstantiation(), Ignored)) return nullptr; - return VisitVarTemplateSpecializationDecl( - InstVarTemplate, D, VarTemplateArgsInfo, CanonicalConverted, PrevDecl); + return VisitVarTemplateSpecializationDecl(InstVarTemplate, D, + VarTemplateArgsInfo, + CTAI.CanonicalConverted, PrevDecl); } Decl *TemplateDeclInstantiator::VisitVarTemplateSpecializationDecl( @@ -4324,37 +4365,37 @@ TemplateDeclInstantiator::InstantiateClassTemplatePartialSpecialization( // Check that the template argument list is well-formed for this // class template. - SmallVector<TemplateArgument, 4> SugaredConverted, CanonicalConverted; + Sema::CheckTemplateArgumentInfo CTAI; if (SemaRef.CheckTemplateArgumentList( ClassTemplate, PartialSpec->getLocation(), InstTemplateArgs, /*DefaultArgs=*/{}, - /*PartialTemplateArgs=*/false, SugaredConverted, CanonicalConverted)) + /*PartialTemplateArgs=*/false, CTAI)) return nullptr; // Check these arguments are valid for a template partial specialization. if (SemaRef.CheckTemplatePartialSpecializationArgs( PartialSpec->getLocation(), ClassTemplate, InstTemplateArgs.size(), - CanonicalConverted)) + CTAI.CanonicalConverted)) return nullptr; // Figure out where to insert this class template partial specialization // in the member template's set of class template partial specializations. void *InsertPos = nullptr; ClassTemplateSpecializationDecl *PrevDecl = - ClassTemplate->findPartialSpecialization(CanonicalConverted, InstParams, - InsertPos); + ClassTemplate->findPartialSpecialization(CTAI.CanonicalConverted, + InstParams, InsertPos); // Build the canonical type that describes the converted template // arguments of the class template partial specialization. QualType CanonType = SemaRef.Context.getTemplateSpecializationType( - TemplateName(ClassTemplate), CanonicalConverted); + TemplateName(ClassTemplate), CTAI.CanonicalConverted); // Create the class template partial specialization declaration. ClassTemplatePartialSpecializationDecl *InstPartialSpec = ClassTemplatePartialSpecializationDecl::Create( SemaRef.Context, PartialSpec->getTagKind(), Owner, PartialSpec->getBeginLoc(), PartialSpec->getLocation(), InstParams, - ClassTemplate, CanonicalConverted, CanonType, + ClassTemplate, CTAI.CanonicalConverted, CanonType, /*PrevDecl=*/nullptr); InstPartialSpec->setTemplateArgsAsWritten(InstTemplateArgs); @@ -4438,25 +4479,24 @@ TemplateDeclInstantiator::InstantiateVarTemplatePartialSpecialization( // Check that the template argument list is well-formed for this // class template. - SmallVector<TemplateArgument, 4> SugaredConverted, CanonicalConverted; + Sema::CheckTemplateArgumentInfo CTAI; if (SemaRef.CheckTemplateArgumentList(VarTemplate, PartialSpec->getLocation(), InstTemplateArgs, /*DefaultArgs=*/{}, - /*PartialTemplateArgs=*/false, - SugaredConverted, CanonicalConverted)) + /*PartialTemplateArgs=*/false, CTAI)) return nullptr; // Check these arguments are valid for a template partial specialization. if (SemaRef.CheckTemplatePartialSpecializationArgs( PartialSpec->getLocation(), VarTemplate, InstTemplateArgs.size(), - CanonicalConverted)) + CTAI.CanonicalConverted)) return nullptr; // Figure out where to insert this variable template partial specialization // in the member template's set of variable template partial specializations. void *InsertPos = nullptr; VarTemplateSpecializationDecl *PrevDecl = - VarTemplate->findPartialSpecialization(CanonicalConverted, InstParams, - InsertPos); + VarTemplate->findPartialSpecialization(CTAI.CanonicalConverted, + InstParams, InsertPos); // Do substitution on the type of the declaration TypeSourceInfo *DI = SemaRef.SubstType( @@ -4477,7 +4517,7 @@ TemplateDeclInstantiator::InstantiateVarTemplatePartialSpecialization( VarTemplatePartialSpecializationDecl::Create( SemaRef.Context, Owner, PartialSpec->getInnerLocStart(), PartialSpec->getLocation(), InstParams, VarTemplate, DI->getType(), - DI, PartialSpec->getStorageClass(), CanonicalConverted); + DI, PartialSpec->getStorageClass(), CTAI.CanonicalConverted); InstPartialSpec->setTemplateArgsAsWritten(InstTemplateArgs); @@ -5237,9 +5277,26 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, RebuildTypeSourceInfoForDefaultSpecialMembers(); SetDeclDefaulted(Function, PatternDecl->getLocation()); } else { + NamedDecl *ND = Function; + DeclContext *DC = ND->getLexicalDeclContext(); + std::optional<ArrayRef<TemplateArgument>> Innermost; + if (auto *Primary = Function->getPrimaryTemplate(); + Primary && + !isGenericLambdaCallOperatorOrStaticInvokerSpecialization(Function) && + Function->getTemplateSpecializationKind() != + TSK_ExplicitSpecialization) { + auto It = llvm::find_if(Primary->redecls(), + [](const RedeclarableTemplateDecl *RTD) { + return cast<FunctionTemplateDecl>(RTD) + ->isCompatibleWithDefinition(); + }); + assert(It != Primary->redecls().end() && + "Should't get here without a definition"); + DC = (*It)->getLexicalDeclContext(); + Innermost.emplace(Function->getTemplateSpecializationArgs()->asArray()); + } MultiLevelTemplateArgumentList TemplateArgs = getTemplateInstantiationArgs( - Function, Function->getLexicalDeclContext(), /*Final=*/false, - /*Innermost=*/std::nullopt, false, PatternDecl); + Function, DC, /*Final=*/false, Innermost, false, PatternDecl); // Substitute into the qualifier; we can get a substitution failure here // through evil use of alias templates. @@ -6214,8 +6271,16 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, // declarations to their instantiations. if (CurrentInstantiationScope) { if (auto Found = CurrentInstantiationScope->findInstantiationOf(D)) { - if (Decl *FD = Found->dyn_cast<Decl *>()) + if (Decl *FD = Found->dyn_cast<Decl *>()) { + if (auto *BD = dyn_cast<BindingDecl>(FD); + BD && BD->isParameterPack() && + ArgumentPackSubstitutionIndex != -1) { + auto *DRE = cast<DeclRefExpr>( + BD->getBindingPackExprs()[ArgumentPackSubstitutionIndex]); + return cast<NamedDecl>(DRE->getDecl()); + } return cast<NamedDecl>(FD); + } int PackIdx = ArgumentPackSubstitutionIndex; assert(PackIdx != -1 && diff --git clang/lib/Sema/SemaTemplateVariadic.cpp clang/lib/Sema/SemaTemplateVariadic.cpp index c8452db6bc90..3c56794722dc 100644 --- clang/lib/Sema/SemaTemplateVariadic.cpp +++ clang/lib/Sema/SemaTemplateVariadic.cpp @@ -50,17 +50,29 @@ class CollectUnexpandedParameterPacksVisitor auto *FTD = FD ? FD->getDescribedFunctionTemplate() : nullptr; if (FTD && FTD->getTemplateParameters()->getDepth() >= DepthLimit) return; - } else if (getDepthAndIndex(ND).first >= DepthLimit) + } else if (auto *BD = dyn_cast<BindingDecl>(ND)) { + Expr *E = BD->getBinding(); + if (auto *RP = cast_if_present<ResolvedUnexpandedPackExpr>(E)) { + addUnexpanded(RP); + return; + } + } else if (getDepthAndIndex(ND).first >= DepthLimit) { return; + } Unexpanded.push_back({ND, Loc}); } + void addUnexpanded(const TemplateTypeParmType *T, SourceLocation Loc = SourceLocation()) { if (T->getDepth() < DepthLimit) Unexpanded.push_back({T, Loc}); } + void addUnexpanded(ResolvedUnexpandedPackExpr *E) { + Unexpanded.push_back({E, E->getBeginLoc()}); + } + public: explicit CollectUnexpandedParameterPacksVisitor( SmallVectorImpl<UnexpandedParameterPack> &Unexpanded) @@ -103,6 +115,12 @@ class CollectUnexpandedParameterPacksVisitor return true; } + bool + VisitResolvedUnexpandedPackExpr(ResolvedUnexpandedPackExpr *E) override { + addUnexpanded(E); + return true; + } + /// Record occurrences of template template parameter packs. bool TraverseTemplateName(TemplateName Template) override { if (auto *TTP = dyn_cast_or_null<TemplateTemplateParmDecl>( @@ -422,8 +440,8 @@ Sema::DiagnoseUnexpandedParameterPacks(SourceLocation Loc, if (const TemplateTypeParmType *TTP = Unexpanded[I].first.dyn_cast<const TemplateTypeParmType *>()) Name = TTP->getIdentifier(); - else - Name = cast<NamedDecl *>(Unexpanded[I].first)->getIdentifier(); + else if (NamedDecl *ND = Unexpanded[I].first.dyn_cast<NamedDecl *>()) + Name = ND->getIdentifier(); if (Name && NamesKnown.insert(Name).second) Names.push_back(Name); @@ -757,23 +775,39 @@ bool Sema::CheckParameterPacksForExpansion( bool HaveFirstPack = false; std::optional<unsigned> NumPartialExpansions; SourceLocation PartiallySubstitutedPackLoc; + typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack; for (UnexpandedParameterPack ParmPack : Unexpanded) { // Compute the depth and index for this parameter pack. unsigned Depth = 0, Index = 0; IdentifierInfo *Name; bool IsVarDeclPack = false; + ResolvedUnexpandedPackExpr *ResolvedPack = nullptr; if (const TemplateTypeParmType *TTP = ParmPack.first.dyn_cast<const TemplateTypeParmType *>()) { Depth = TTP->getDepth(); Index = TTP->getIndex(); Name = TTP->getIdentifier(); + } else if (auto *RP = + ParmPack.first.dyn_cast<ResolvedUnexpandedPackExpr *>()) { + ResolvedPack = RP; } else { NamedDecl *ND = cast<NamedDecl *>(ParmPack.first); if (isa<VarDecl>(ND)) IsVarDeclPack = true; - else + else if (isa<BindingDecl>(ND)) { + // Find the instantiated BindingDecl and check it for a resolved pack. + llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation = + CurrentInstantiationScope->findInstantiationOf(ND); + Decl *B = cast<Decl *>(*Instantiation); + Expr *BindingExpr = cast<BindingDecl>(B)->getBinding(); + ResolvedPack = cast_if_present<ResolvedUnexpandedPackExpr>(BindingExpr); + if (!ResolvedPack) { + ShouldExpand = false; + continue; + } + } else std::tie(Depth, Index) = getDepthAndIndex(ND); Name = ND->getIdentifier(); @@ -783,8 +817,6 @@ bool Sema::CheckParameterPacksForExpansion( unsigned NewPackSize, PendingPackExpansionSize = 0; if (IsVarDeclPack) { // Figure out whether we're instantiating to an argument pack or not. - typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack; - llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation = CurrentInstantiationScope->findInstantiationOf( cast<NamedDecl *>(ParmPack.first)); @@ -797,6 +829,8 @@ bool Sema::CheckParameterPacksForExpansion( ShouldExpand = false; continue; } + } else if (ResolvedPack) { + NewPackSize = ResolvedPack->getNumExprs(); } else { // If we don't have a template argument at this depth/index, then we // cannot expand the pack expansion. Make a note of this, but we still @@ -833,7 +867,7 @@ bool Sema::CheckParameterPacksForExpansion( // Template argument deduction can extend the sequence of template // arguments corresponding to a template parameter pack, even when the // sequence contains explicitly specified template arguments. - if (!IsVarDeclPack && CurrentInstantiationScope) { + if (!IsVarDeclPack && !ResolvedPack && CurrentInstantiationScope) { if (NamedDecl *PartialPack = CurrentInstantiationScope->getPartiallySubstitutedPack()) { unsigned PartialDepth, PartialIndex; @@ -939,6 +973,12 @@ std::optional<unsigned> Sema::getNumArgumentsInExpansionFromUnexpanded( Unexpanded[I].first.dyn_cast<const TemplateTypeParmType *>()) { Depth = TTP->getDepth(); Index = TTP->getIndex(); + } else if (auto *PE = Unexpanded[I] + .first.dyn_cast<ResolvedUnexpandedPackExpr *>()) { + unsigned Size = PE->getNumExprs(); + assert((!Result || *Result == Size) && "inconsistent pack sizes"); + Result = Size; + continue; } else { NamedDecl *ND = cast<NamedDecl *>(Unexpanded[I].first); if (isa<VarDecl>(ND)) { @@ -1167,8 +1207,12 @@ ExprResult Sema::ActOnSizeofParameterPackExpr(Scope *S, MarkAnyDeclReferenced(OpLoc, ParameterPack, true); + std::optional<unsigned> Length; + if (auto *RP = ResolvedUnexpandedPackExpr::getFromDecl(ParameterPack)) + Length = RP->getNumExprs(); + return SizeOfPackExpr::Create(Context, OpLoc, ParameterPack, NameLoc, - RParenLoc); + RParenLoc, Length); } static bool isParameterPack(Expr *PackExpression) { diff --git clang/lib/Sema/SemaType.cpp clang/lib/Sema/SemaType.cpp index 2ccf5a8e1d6f..33d5378944dd 100644 --- clang/lib/Sema/SemaType.cpp +++ clang/lib/Sema/SemaType.cpp @@ -8306,7 +8306,8 @@ static bool isPermittedNeonBaseType(QualType &Ty, VectorKind VecKind, Sema &S) { BTy->getKind() == BuiltinType::ULongLong || BTy->getKind() == BuiltinType::Float || BTy->getKind() == BuiltinType::Half || - BTy->getKind() == BuiltinType::BFloat16; + BTy->getKind() == BuiltinType::BFloat16 || + BTy->getKind() == BuiltinType::MFloat8; } static bool verifyValidIntegerConstantExpr(Sema &S, const ParsedAttr &Attr, diff --git clang/lib/Sema/TreeTransform.h clang/lib/Sema/TreeTransform.h index 12680843a434..808b56448e1e 100644 --- clang/lib/Sema/TreeTransform.h +++ clang/lib/Sema/TreeTransform.h @@ -3680,6 +3680,13 @@ public: FullySubstituted); } + ExprResult RebuildResolvedUnexpandedPackExpr(SourceLocation BeginLoc, + QualType T, + ArrayRef<Expr *> Exprs) { + return ResolvedUnexpandedPackExpr::Create(SemaRef.Context, BeginLoc, T, + Exprs); + } + /// Build a new expression representing a call to a source location /// builtin. /// @@ -7335,8 +7342,10 @@ QualType TreeTransform<Derived>::TransformTemplateSpecializationType( NewTemplateArgs)) return QualType(); - // FIXME: maybe don't rebuild if all the template arguments are the same. - + // This needs to be rebuilt if either the arguments changed, or if the + // original template changed. If the template changed, and even if the + // arguments didn't change, these arguments might not correspond to their + // respective parameters, therefore needing conversions. QualType Result = getDerived().RebuildTemplateSpecializationType(Template, TL.getTemplateNameLoc(), @@ -14903,7 +14912,7 @@ TreeTransform<Derived>::TransformExprRequirement(concepts::ExprRequirement *Req) TransRetReq.emplace(TPL); } assert(TransRetReq && "All code paths leading here must set TransRetReq"); - if (Expr *E = TransExpr.dyn_cast<Expr *>()) + if (Expr *E = dyn_cast<Expr *>(TransExpr)) return getDerived().RebuildExprRequirement(E, Req->isSimple(), Req->getNoexceptLoc(), std::move(*TransRetReq)); @@ -14947,9 +14956,6 @@ TreeTransform<Derived>::TransformArrayTypeTraitExpr(ArrayTypeTraitExpr *E) { SubExpr = getDerived().TransformExpr(E->getDimensionExpression()); if (SubExpr.isInvalid()) return ExprError(); - - if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getDimensionExpression()) - return E; } return getDerived().RebuildArrayTypeTrait(E->getTrait(), E->getBeginLoc(), T, @@ -15428,12 +15434,11 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) { // The transform has determined that we should perform an expansion; // transform and capture each of the arguments. // expansion of the pattern. Do so. - auto *Pack = cast<VarDecl>(C->getCapturedVar()); + auto *Pack = cast<ValueDecl>(C->getCapturedVar()); for (unsigned I = 0; I != *NumExpansions; ++I) { Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I); - VarDecl *CapturedVar - = cast_or_null<VarDecl>(getDerived().TransformDecl(C->getLocation(), - Pack)); + ValueDecl *CapturedVar = cast_if_present<ValueDecl>( + getDerived().TransformDecl(C->getLocation(), Pack)); if (!CapturedVar) { Invalid = true; continue; @@ -16128,6 +16133,24 @@ TreeTransform<Derived>::TransformFunctionParmPackExpr(FunctionParmPackExpr *E) { return E; } +template <typename Derived> +ExprResult TreeTransform<Derived>::TransformResolvedUnexpandedPackExpr( + ResolvedUnexpandedPackExpr *E) { + bool ArgumentChanged = false; + SmallVector<Expr *, 12> NewExprs; + if (TransformExprs(E->getExprs().begin(), E->getNumExprs(), + /*IsCall=*/false, NewExprs, &ArgumentChanged)) + return ExprError(); + + if (!AlwaysRebuild() && !ArgumentChanged) + return E; + + // NOTE: The type is just a superficial PackExpansionType + // that needs no substitution. + return RebuildResolvedUnexpandedPackExpr(E->getBeginLoc(), E->getType(), + NewExprs); +} + template<typename Derived> ExprResult TreeTransform<Derived>::TransformMaterializeTemporaryExpr( diff --git clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTReader.cpp index 08801d22fdca..f524251c48dd 100644 --- clang/lib/Serialization/ASTReader.cpp +++ clang/lib/Serialization/ASTReader.cpp @@ -6864,7 +6864,7 @@ void ASTReader::ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag) { // command line (-w, -Weverything, -Werror, ...) along with any explicit // -Wblah flags. unsigned Flags = Record[Idx++]; - DiagState Initial; + DiagState Initial(*Diag.getDiagnosticIDs()); Initial.SuppressSystemWarnings = Flags & 1; Flags >>= 1; Initial.ErrorsAsFatal = Flags & 1; Flags >>= 1; Initial.WarningsAsErrors = Flags & 1; Flags >>= 1; diff --git clang/lib/Serialization/ASTReaderDecl.cpp clang/lib/Serialization/ASTReaderDecl.cpp index 0b75468a9410..7a15e60d87d8 100644 --- clang/lib/Serialization/ASTReaderDecl.cpp +++ clang/lib/Serialization/ASTReaderDecl.cpp @@ -1064,6 +1064,7 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) { FD->setHasImplicitReturnZero(FunctionDeclBits.getNextBit()); FD->setIsMultiVersion(FunctionDeclBits.getNextBit()); FD->setLateTemplateParsed(FunctionDeclBits.getNextBit()); + FD->setInstantiatedFromMemberTemplate(FunctionDeclBits.getNextBit()); FD->setFriendConstraintRefersToEnclosingTemplate( FunctionDeclBits.getNextBit()); FD->setUsesSEHTry(FunctionDeclBits.getNextBit()); @@ -2295,6 +2296,10 @@ void ASTDeclReader::VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D) { VisitFunctionDecl(D); D->setDeductionCandidateKind( static_cast<DeductionCandidate>(Record.readInt())); + D->setSourceDeductionGuide(readDeclAs<CXXDeductionGuideDecl>()); + D->setSourceDeductionGuideKind( + static_cast<CXXDeductionGuideDecl::SourceDeductionGuideKind>( + Record.readInt())); } void ASTDeclReader::VisitCXXMethodDecl(CXXMethodDecl *D) { @@ -4678,8 +4683,8 @@ void ASTDeclReader::UpdateDecl(Decl *D) { MSInfo->setPointOfInstantiation(POI); } else { auto *FD = cast<FunctionDecl>(D); - if (auto *FTSInfo = FD->TemplateOrSpecialization - .dyn_cast<FunctionTemplateSpecializationInfo *>()) + if (auto *FTSInfo = dyn_cast<FunctionTemplateSpecializationInfo *>( + FD->TemplateOrSpecialization)) FTSInfo->setPointOfInstantiation(POI); else cast<MemberSpecializationInfo *>(FD->TemplateOrSpecialization) diff --git clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTReaderStmt.cpp index 990235a310d9..b15eca87993a 100644 --- clang/lib/Serialization/ASTReaderStmt.cpp +++ clang/lib/Serialization/ASTReaderStmt.cpp @@ -2208,6 +2208,16 @@ void ASTStmtReader::VisitPackIndexingExpr(PackIndexingExpr *E) { Exprs[I] = Record.readExpr(); } +void ASTStmtReader::VisitResolvedUnexpandedPackExpr( + ResolvedUnexpandedPackExpr *E) { + VisitExpr(E); + E->NumExprs = Record.readInt(); + E->BeginLoc = readSourceLocation(); + auto **Exprs = E->getTrailingObjects<Expr *>(); + for (unsigned I = 0; I < E->NumExprs; ++I) + Exprs[I] = Record.readExpr(); +} + void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr( SubstNonTypeTemplateParmExpr *E) { VisitExpr(E); @@ -4291,6 +4301,12 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) { /*TransformedExprs=*/Record[ASTStmtReader::NumExprFields]); break; + case EXPR_RESOLVED_UNEXPANDED_PACK: + S = ResolvedUnexpandedPackExpr::CreateDeserialized( + Context, + /*NumExprs=*/Record[ASTStmtReader::NumExprFields]); + break; + case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM: S = new (Context) SubstNonTypeTemplateParmExpr(Empty); break; diff --git clang/lib/Serialization/ASTWriter.cpp clang/lib/Serialization/ASTWriter.cpp index a580f375aee3..e81a441d753b 100644 --- clang/lib/Serialization/ASTWriter.cpp +++ clang/lib/Serialization/ASTWriter.cpp @@ -874,6 +874,7 @@ static void AddStmtsExprs(llvm::BitstreamWriter &Stream, RECORD(EXPR_PACK_EXPANSION); RECORD(EXPR_SIZEOF_PACK); RECORD(EXPR_PACK_INDEXING); + RECORD(EXPR_RESOLVED_UNEXPANDED_PACK); RECORD(EXPR_SUBST_NON_TYPE_TEMPLATE_PARM); RECORD(EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK); RECORD(EXPR_FUNCTION_PARM_PACK); @@ -3264,7 +3265,7 @@ void ASTWriter::WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag, // Skip default mappings. We have a mapping for every diagnostic ever // emitted, regardless of whether it was customized. if (!I.second.isPragma() && - I.second == DiagnosticIDs::getDefaultMapping(I.first)) + I.second == Diag.getDiagnosticIDs()->getDefaultMapping(I.first)) continue; Mappings.push_back(I); } diff --git clang/lib/Serialization/ASTWriterDecl.cpp clang/lib/Serialization/ASTWriterDecl.cpp index 8b9ba04dce91..6a79444bdb98 100644 --- clang/lib/Serialization/ASTWriterDecl.cpp +++ clang/lib/Serialization/ASTWriterDecl.cpp @@ -679,7 +679,7 @@ void ASTDeclWriter::VisitDeclaratorDecl(DeclaratorDecl *D) { } void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) { - static_assert(DeclContext::NumFunctionDeclBits == 44, + static_assert(DeclContext::NumFunctionDeclBits == 45, "You need to update the serializer after you change the " "FunctionDeclBits"); @@ -785,6 +785,7 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) { FunctionDeclBits.addBit(D->hasImplicitReturnZero()); FunctionDeclBits.addBit(D->isMultiVersion()); FunctionDeclBits.addBit(D->isLateTemplateParsed()); + FunctionDeclBits.addBit(D->isInstantiatedFromMemberTemplate()); FunctionDeclBits.addBit(D->FriendConstraintRefersToEnclosingTemplate()); FunctionDeclBits.addBit(D->usesSEHTry()); Record.push_back(FunctionDeclBits); @@ -846,6 +847,9 @@ void ASTDeclWriter::VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D) { Record.AddDeclRef(D->Ctor); VisitFunctionDecl(D); Record.push_back(static_cast<unsigned char>(D->getDeductionCandidateKind())); + Record.AddDeclRef(D->getSourceDeductionGuide()); + Record.push_back( + static_cast<unsigned char>(D->getSourceDeductionGuideKind())); Code = serialization::DECL_CXX_DEDUCTION_GUIDE; } diff --git clang/lib/Serialization/ASTWriterStmt.cpp clang/lib/Serialization/ASTWriterStmt.cpp index 651553244812..e6701c586e02 100644 --- clang/lib/Serialization/ASTWriterStmt.cpp +++ clang/lib/Serialization/ASTWriterStmt.cpp @@ -475,7 +475,7 @@ addConstraintSatisfaction(ASTRecordWriter &Record, if (!Satisfaction.IsSatisfied) { Record.push_back(Satisfaction.NumRecords); for (const auto &DetailRecord : Satisfaction) { - auto *E = DetailRecord.dyn_cast<Expr *>(); + auto *E = dyn_cast<Expr *>(DetailRecord); Record.push_back(/* IsDiagnostic */ E == nullptr); if (E) Record.AddStmt(E); @@ -2210,6 +2210,16 @@ void ASTStmtWriter::VisitPackIndexingExpr(PackIndexingExpr *E) { Code = serialization::EXPR_PACK_INDEXING; } +void ASTStmtWriter::VisitResolvedUnexpandedPackExpr( + ResolvedUnexpandedPackExpr *E) { + VisitExpr(E); + Record.push_back(E->getNumExprs()); + Record.AddSourceLocation(E->getBeginLoc()); + for (Expr *Sub : E->getExprs()) + Record.AddStmt(Sub); + Code = serialization::EXPR_RESOLVED_UNEXPANDED_PACK; +} + void ASTStmtWriter::VisitSubstNonTypeTemplateParmExpr( SubstNonTypeTemplateParmExpr *E) { VisitExpr(E); diff --git clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp index d7e5ebee9a9b..79f88553feb9 100644 --- clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp @@ -48,7 +48,7 @@ public: // The calls to checkAST* from AnalysisConsumer don't // visit template instantiations or lambda classes. We // want to visit those, so we make our own RecursiveASTVisitor. - struct LocalVisitor : DynamicRecursiveASTVisitor { + struct LocalVisitor : ConstDynamicRecursiveASTVisitor { const RawPtrRefMemberChecker *Checker; explicit LocalVisitor(const RawPtrRefMemberChecker *Checker) : Checker(Checker) { @@ -57,14 +57,14 @@ public: ShouldVisitImplicitCode = false; } - bool VisitRecordDecl(RecordDecl *RD) override { + bool VisitRecordDecl(const RecordDecl *RD) override { Checker->visitRecordDecl(RD); return true; } }; LocalVisitor visitor(this); - visitor.TraverseDecl(const_cast<TranslationUnitDecl *>(TUD)); + visitor.TraverseDecl(TUD); } void visitRecordDecl(const RecordDecl *RD) const { diff --git clang/lib/StaticAnalyzer/Core/ExprEngine.cpp clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index 140c77790496..2b1872f8386a 100644 --- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -1743,6 +1743,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred, case Stmt::DependentCoawaitExprClass: case Stmt::CoreturnStmtClass: case Stmt::CoyieldExprClass: + case Stmt::ResolvedUnexpandedPackExprClass: case Stmt::SEHTryStmtClass: case Stmt::SEHExceptStmtClass: case Stmt::SEHLeaveStmtClass: diff --git clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp index e8cf367b8334..79ee430988b7 100644 --- clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp +++ clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp @@ -91,7 +91,6 @@ public: ? " [" + PD->getCheckerName() + "]" : "") .str(); - reportPiece(WarnID, PD->getLocation().asLocation(), (PD->getShortDescription() + WarningMsg).str(), PD->path.back()->getRanges(), PD->path.back()->getFixits()); diff --git clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp index 2e97cac0796c..732de7b82475 100644 --- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp +++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp @@ -214,9 +214,6 @@ makeCommonInvocationForModuleBuild(CompilerInvocation CI) { CI.getDependencyOutputOpts().Targets.clear(); CI.getFrontendOpts().ProgramAction = frontend::GenerateModule; - CI.getFrontendOpts().ARCMTAction = FrontendOptions::ARCMT_None; - CI.getFrontendOpts().ObjCMTAction = FrontendOptions::ObjCMT_None; - CI.getFrontendOpts().MTMigrateDir.clear(); CI.getLangOpts().ModuleName.clear(); // Remove any macro definitions that are explicitly ignored. diff --git clang/test/ARCMT/Common.h clang/test/ARCMT/Common.h deleted file mode 100644 index b388ecab7410..000000000000 --- clang/test/ARCMT/Common.h +++ /dev/null @@ -1,110 +0,0 @@ -#if __has_feature(objc_arr) -#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode"))) -#else -#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE -#endif - -#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) -#define CF_CONSUMED __attribute__((cf_consumed)) -#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) - -#define NS_INLINE static __inline__ __attribute__((always_inline)) -#define nil ((void*) 0) -#define NULL ((void*)0) - -typedef int BOOL; -typedef unsigned NSUInteger; -typedef int int32_t; -typedef unsigned char uint8_t; -typedef int32_t UChar32; -typedef unsigned char UChar; - -typedef struct _NSZone NSZone; - -typedef const void * CFTypeRef; -CFTypeRef CFRetain(CFTypeRef cf); -CFTypeRef CFMakeCollectable(CFTypeRef cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE; - -NS_INLINE NS_RETURNS_RETAINED id NSMakeCollectable(CFTypeRef CF_CONSUMED cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE; - -@protocol NSObject -- (BOOL)isEqual:(id)object; -- (NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -@end - -@interface NSObject <NSObject> {} -- (id)init; - -+ (id)new; -+ (id)alloc; -- (void)dealloc; - -- (void)finalize; - -- (id)copy; -- (id)mutableCopy; -@end - -NS_AUTOMATED_REFCOUNT_UNAVAILABLE -@interface NSAutoreleasePool : NSObject { -@private - void *_token; - void *_reserved3; - void *_reserved2; - void *_reserved; -} - -+ (void)addObject:(id)anObject; - -- (void)addObject:(id)anObject; - -- (void)drain; - -@end - -typedef const void* objc_objectptr_t; -extern __attribute__((ns_returns_retained)) id objc_retainedObject(objc_objectptr_t __attribute__((cf_consumed)) pointer); -extern __attribute__((ns_returns_not_retained)) id objc_unretainedObject(objc_objectptr_t pointer); -extern objc_objectptr_t objc_unretainedPointer(id object); - -#define dispatch_retain(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); (void)[_o retain]; }) -#define dispatch_release(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); [_o release]; }) -#define xpc_retain(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o retain]; }) -#define xpc_release(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o release]; }) - -typedef id dispatch_object_t; -typedef id xpc_object_t; - -void _dispatch_object_validate(dispatch_object_t object); -void _xpc_object_validate(xpc_object_t object); - -#if __has_feature(objc_arc) - -NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) { - return (__bridge_retained CFTypeRef)X; -} - -NS_INLINE id CFBridgingRelease(CFTypeRef CF_CONSUMED X) { - return (__bridge_transfer id)X; -} - -#else - -NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) { - return X ? CFRetain((CFTypeRef)X) : NULL; -} - -NS_INLINE id CFBridgingRelease(CFTypeRef CF_CONSUMED X) { - return [(id)CFMakeCollectable(X) autorelease]; -} - -#endif - -void *_Block_copy(const void *aBlock); -void _Block_release(const void *aBlock); -#define Block_copy(...) ((__typeof(__VA_ARGS__))_Block_copy((const void *)(__VA_ARGS__))) -#define Block_release(...) _Block_release((const void *)(__VA_ARGS__)) diff --git clang/test/ARCMT/GC-check-warn-nsalloc.m clang/test/ARCMT/GC-check-warn-nsalloc.m deleted file mode 100644 index 1c33de5b65b2..000000000000 --- clang/test/ARCMT/GC-check-warn-nsalloc.m +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -arcmt-action=check -no-ns-alloc-error -triple x86_64-apple-darwin10 -fobjc-gc-only %s 2>&1 | grep 'warning: \[rewriter\] call returns pointer to GC managed memory' -// RUN: %clang_cc1 -arcmt-action=check -no-ns-alloc-error -triple x86_64-apple-darwin10 -fobjc-gc-only -x objective-c++ %s 2>&1 | grep 'warning: \[rewriter\] call returns pointer to GC managed memory' -// TODO: Investigate VerifyDiagnosticConsumer failures on these tests when using -verify. - -typedef unsigned NSUInteger; -void *__strong NSAllocateCollectable(NSUInteger size, NSUInteger options); - -void test1(void) { - NSAllocateCollectable(100, 0); -} diff --git clang/test/ARCMT/GC-check.m clang/test/ARCMT/GC-check.m deleted file mode 100644 index e95e285432e0..000000000000 --- clang/test/ARCMT/GC-check.m +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -arcmt-action=check -verify -triple x86_64-apple-darwin10 -fobjc-gc-only %s -// RUN: %clang_cc1 -arcmt-action=check -verify -triple x86_64-apple-darwin10 -fobjc-gc-only -x objective-c++ %s - -#define CF_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode"))) -typedef unsigned NSUInteger; -typedef const void * CFTypeRef; -CFTypeRef CFMakeCollectable(CFTypeRef cf) CF_AUTOMATED_REFCOUNT_UNAVAILABLE; // expected-note {{unavailable}} -void *__strong NSAllocateCollectable(NSUInteger size, NSUInteger options); - -void test1(CFTypeRef *cft) { - CFTypeRef c = CFMakeCollectable(cft); // expected-error {{CFMakeCollectable will leak the object that it receives in ARC}} \ - // expected-error {{unavailable}} - NSAllocateCollectable(100, 0); // expected-error {{call returns pointer to GC managed memory; it will become unmanaged in ARC}} -} - -@interface I1 { - __strong void *gcVar; // expected-error {{GC managed memory will become unmanaged in ARC}} -} -@end; diff --git clang/test/ARCMT/GC-no-arc-runtime.m clang/test/ARCMT/GC-no-arc-runtime.m deleted file mode 100644 index 99ba2eb5f7ae..000000000000 --- clang/test/ARCMT/GC-no-arc-runtime.m +++ /dev/null @@ -1,80 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-gc-only -x objective-c %s > %t -// RUN: diff %t %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-gc-only -x objective-c++ %s > %t -// RUN: diff %t %s.result - -// MRC __weak broke this test somehow. -// XFAIL: * - -#include "Common.h" -#include "GC.h" - -void test1(CFTypeRef *cft) { - id x = NSMakeCollectable(cft); -} - -@interface I1 -@end - -@implementation I1 --(void)dealloc { - // dealloc - test1(0); -} - --(void)finalize { - // finalize - test1(0); -} -@end - -@interface I2 -@property (retain) id prop; -@end - -@implementation I2 -@synthesize prop; - --(void)finalize { - self.prop = 0; - // finalize - test1(0); -} -@end - -__attribute__((objc_arc_weak_reference_unavailable)) -@interface QQ { - __weak id s; - __weak QQ *q; -} -@end - -@interface I3 -@property (assign) I3 *__weak pw1, *__weak pw2; -@property (assign) I3 *__strong ps; -@property (assign) I3 * pds; -@end - -@interface I4Impl { - I4Impl *pds2; -} -@property (assign) I4Impl *__weak pw1, *__weak pw2; -@property (assign) I4Impl *__strong ps; -@property (assign) I4Impl * pds; -@property (assign) I4Impl * pds2; -@end - -@implementation I4Impl -@synthesize pw1, pw2, ps, pds, pds2; - --(void)test1:(CFTypeRef *)cft { - id x = NSMakeCollectable(cft); -} -@end - -@interface I5 { - __weak id prop; -} -@property (readonly) __weak id prop; -@end diff --git clang/test/ARCMT/GC-no-arc-runtime.m.result clang/test/ARCMT/GC-no-arc-runtime.m.result deleted file mode 100644 index c338bdb2ed47..000000000000 --- clang/test/ARCMT/GC-no-arc-runtime.m.result +++ /dev/null @@ -1,72 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-gc-only -x objective-c %s > %t -// RUN: diff %t %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-gc-only -x objective-c++ %s > %t -// RUN: diff %t %s.result - -#include "Common.h" -#include "GC.h" - -void test1(CFTypeRef *cft) { - id x = CFBridgingRelease(cft); -} - -@interface I1 -@end - -@implementation I1 --(void)dealloc { - // dealloc - test1(0); -} - -@end - -@interface I2 -@property (strong) id prop; -@end - -@implementation I2 -@synthesize prop; - --(void)dealloc { - // finalize - test1(0); -} -@end - -__attribute__((objc_arc_weak_reference_unavailable)) -@interface QQ { - __unsafe_unretained id s; - __unsafe_unretained QQ *q; -} -@end - -@interface I3 -@property (unsafe_unretained) I3 * pw1, * pw2; -@property (strong) I3 * ps; -@property (assign) I3 * pds; -@end - -@interface I4Impl { - I4Impl *__strong pds2; -} -@property (unsafe_unretained) I4Impl * pw1, * pw2; -@property (strong) I4Impl * ps; -@property (strong) I4Impl * pds; -@property (strong) I4Impl * pds2; -@end - -@implementation I4Impl -@synthesize pw1, pw2, ps, pds, pds2; - --(void)test1:(CFTypeRef *)cft { - id x = CFBridgingRelease(cft); -} -@end - -@interface I5 { - __unsafe_unretained id prop; -} -@property (unsafe_unretained, readonly) id prop; -@end diff --git clang/test/ARCMT/GC-no-finalize-removal.m clang/test/ARCMT/GC-no-finalize-removal.m deleted file mode 100644 index 07a737c1b775..000000000000 --- clang/test/ARCMT/GC-no-finalize-removal.m +++ /dev/null @@ -1,88 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -no-finalize-removal -x objective-c %s > %t -// RUN: diff %t %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -no-finalize-removal -x objective-c++ %s > %t -// RUN: diff %t %s.result - -#include "Common.h" -#include "GC.h" - -void test1(CFTypeRef *cft) { - id x = NSMakeCollectable(cft); -} - -@interface I1 -@end - -@implementation I1 --(void)dealloc { - // dealloc - test1(0); -} - --(void)finalize { - // finalize - test1(0); -} -@end - -@interface I2 -@property (retain) id prop; -@end - -@implementation I2 -@synthesize prop; - --(void)finalize { - self.prop = 0; - // finalize - test1(0); -} -@end - -__attribute__((objc_arc_weak_reference_unavailable)) -@interface QQ { - __weak id s; - __weak QQ *q; -} -@end - -@interface I3 -@property (assign) I3 *__weak pw1, *__weak pw2; -@property (assign) I3 *__strong ps; -@property (assign) I3 * pds; -@end - -@interface I4Impl { - I4Impl *pds2; - I4Impl *pds3; - __weak I4Impl *pw3; - __weak I4Impl *pw4; -} -@property (assign) I4Impl *__weak pw1, *__weak pw2; -@property (assign) I4Impl *__strong ps; -@property (assign) I4Impl * pds; -@property (assign) I4Impl * pds2; -@property (readwrite) I4Impl * pds3; -@property (readonly) I4Impl * pds4; -@property (readonly) __weak I4Impl *pw3; -@property (assign) __weak I4Impl *pw4; -@end - -@implementation I4Impl -@synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4; - --(void)test1:(CFTypeRef *)cft { - id x = NSMakeCollectable(cft); -} -@end - -@interface rdar10532449 -@property (assign) id assign_prop; -@property (assign, readonly) id __strong strong_readonly_prop; -@property (assign) id __weak weak_prop; -@end - -@implementation rdar10532449 -@synthesize assign_prop, strong_readonly_prop, weak_prop; -@end diff --git clang/test/ARCMT/GC-no-finalize-removal.m.result clang/test/ARCMT/GC-no-finalize-removal.m.result deleted file mode 100644 index a2105b32fc75..000000000000 --- clang/test/ARCMT/GC-no-finalize-removal.m.result +++ /dev/null @@ -1,96 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -no-finalize-removal -x objective-c %s > %t -// RUN: diff %t %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -no-finalize-removal -x objective-c++ %s > %t -// RUN: diff %t %s.result - -#include "Common.h" -#include "GC.h" - -void test1(CFTypeRef *cft) { - id x = CFBridgingRelease(cft); -} - -@interface I1 -@end - -@implementation I1 --(void)dealloc { - // dealloc - test1(0); -} - -#if !__has_feature(objc_arc) --(void)finalize { - // finalize - test1(0); -} -#endif -@end - -@interface I2 -@property (strong) id prop; -@end - -@implementation I2 -@synthesize prop; - -#if !__has_feature(objc_arc) --(void)finalize { - self.prop = 0; - // finalize - test1(0); -} -#endif --(void)dealloc { - // finalize - test1(0); -} -@end - -__attribute__((objc_arc_weak_reference_unavailable)) -@interface QQ { - __weak id s; - __unsafe_unretained QQ *q; -} -@end - -@interface I3 -@property (weak) I3 * pw1, * pw2; -@property (strong) I3 * ps; -@property (assign) I3 * pds; -@end - -@interface I4Impl { - I4Impl *__strong pds2; - I4Impl *pds3; - __weak I4Impl *pw3; - __weak I4Impl *pw4; -} -@property (weak) I4Impl * pw1, * pw2; -@property (strong) I4Impl * ps; -@property (strong) I4Impl * pds; -@property (strong) I4Impl * pds2; -@property (readwrite) I4Impl * pds3; -@property (readonly) I4Impl * pds4; -@property (weak, readonly) I4Impl *pw3; -@property (weak) I4Impl *pw4; -@end - -@implementation I4Impl -@synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4; - --(void)test1:(CFTypeRef *)cft { - id x = CFBridgingRelease(cft); -} -@end - -@interface rdar10532449 -@property (strong) id assign_prop; -@property (strong, readonly) id strong_readonly_prop; -@property (weak) id weak_prop; -@end - -@implementation rdar10532449 -@synthesize assign_prop, strong_readonly_prop, weak_prop; -@end diff --git clang/test/ARCMT/GC.h clang/test/ARCMT/GC.h deleted file mode 100644 index 4301baf27246..000000000000 --- clang/test/ARCMT/GC.h +++ /dev/null @@ -1,6 +0,0 @@ - -@interface ExtInterface { - __strong ExtInterface *myivar; - __strong void *gcVar; -} -@end diff --git clang/test/ARCMT/GC.m clang/test/ARCMT/GC.m deleted file mode 100644 index 97723e89ed36..000000000000 --- clang/test/ARCMT/GC.m +++ /dev/null @@ -1,93 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -x objective-c %s > %t -// RUN: diff %t %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -x objective-c++ %s > %t -// RUN: diff %t %s.result - -#include "Common.h" -#include "GC.h" - -void test1(CFTypeRef *cft) { - id x = NSMakeCollectable(cft); -} - -@interface I1 -@end - -@implementation I1 --(void)dealloc { - // dealloc - test1(0); -} - --(void)finalize { - // finalize - test1(0); -} -@end - -@interface I2 -@property (retain) id prop; -@end - -@implementation I2 -@synthesize prop; - --(void)finalize { - self.prop = 0; - // finalize - test1(0); -} -@end - -__attribute__((objc_arc_weak_reference_unavailable)) -@interface QQ { - __weak id s; - __weak QQ *q; -} -@end - -@interface I3 -@property (assign) I3 *__weak pw1, *__weak pw2; -@property (assign) I3 *__strong ps; -@property (assign) I3 * pds; -@end - -@interface I4Impl { - I4Impl *pds2; - I4Impl *pds3; - __weak I4Impl *pw3; - __weak I4Impl *pw4; -} -@property (assign) I4Impl *__weak pw1, *__weak pw2; -@property (assign) I4Impl *__strong ps; -@property (assign) I4Impl * pds; -@property (assign) I4Impl * pds2; -@property (readwrite) I4Impl * pds3; -@property (readonly) I4Impl * pds4; -@property (readonly) __weak I4Impl *pw3; -@property (assign) __weak I4Impl *pw4; -@end - -@implementation I4Impl -@synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4; - --(void)test1:(CFTypeRef *)cft { - id x = NSMakeCollectable(cft); -} -@end - -@interface rdar10532449 -@property (assign) id assign_prop; -@property (assign, readonly) id __strong strong_readonly_prop; -@property (assign) id __weak weak_prop; -@end - -@implementation rdar10532449 -@synthesize assign_prop, strong_readonly_prop, weak_prop; -@end - -void test2(id p, __strong I1 *ap[]) { - for (__strong I1 *specRule in p) { - } -} diff --git clang/test/ARCMT/GC.m.result clang/test/ARCMT/GC.m.result deleted file mode 100644 index b60b07ac9c11..000000000000 --- clang/test/ARCMT/GC.m.result +++ /dev/null @@ -1,88 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -x objective-c %s > %t -// RUN: diff %t %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -x objective-c++ %s > %t -// RUN: diff %t %s.result - -#include "Common.h" -#include "GC.h" - -void test1(CFTypeRef *cft) { - id x = CFBridgingRelease(cft); -} - -@interface I1 -@end - -@implementation I1 --(void)dealloc { - // dealloc - test1(0); -} - -@end - -@interface I2 -@property (strong) id prop; -@end - -@implementation I2 -@synthesize prop; - --(void)dealloc { - // finalize - test1(0); -} -@end - -__attribute__((objc_arc_weak_reference_unavailable)) -@interface QQ { - __weak id s; - __unsafe_unretained QQ *q; -} -@end - -@interface I3 -@property (weak) I3 * pw1, * pw2; -@property (strong) I3 * ps; -@property (assign) I3 * pds; -@end - -@interface I4Impl { - I4Impl *__strong pds2; - I4Impl *pds3; - __weak I4Impl *pw3; - __weak I4Impl *pw4; -} -@property (weak) I4Impl * pw1, * pw2; -@property (strong) I4Impl * ps; -@property (strong) I4Impl * pds; -@property (strong) I4Impl * pds2; -@property (readwrite) I4Impl * pds3; -@property (readonly) I4Impl * pds4; -@property (weak, readonly) I4Impl *pw3; -@property (weak) I4Impl *pw4; -@end - -@implementation I4Impl -@synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4; - --(void)test1:(CFTypeRef *)cft { - id x = CFBridgingRelease(cft); -} -@end - -@interface rdar10532449 -@property (strong) id assign_prop; -@property (strong, readonly) id strong_readonly_prop; -@property (weak) id weak_prop; -@end - -@implementation rdar10532449 -@synthesize assign_prop, strong_readonly_prop, weak_prop; -@end - -void test2(id p, __strong I1 *ap[]) { - for (__strong I1 *specRule in p) { - } -} diff --git clang/test/ARCMT/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h clang/test/ARCMT/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h deleted file mode 100644 index f7f9fb66c9e9..000000000000 --- clang/test/ARCMT/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef MODULE_SUBFRAMEWORK_H -#define MODULE_SUBFRAMEWORK_H -#__private_macro MODULE_SUBFRAMEWORK_H -char *module_subframework; -#endif diff --git clang/test/ARCMT/Inputs/Module.framework/Headers/Buried/Treasure.h clang/test/ARCMT/Inputs/Module.framework/Headers/Buried/Treasure.h deleted file mode 100644 index 6e81adcb2b60..000000000000 --- clang/test/ARCMT/Inputs/Module.framework/Headers/Buried/Treasure.h +++ /dev/null @@ -1 +0,0 @@ -unsigned *Buried_Treasure; diff --git clang/test/ARCMT/Inputs/Module.framework/Headers/Module.h clang/test/ARCMT/Inputs/Module.framework/Headers/Module.h deleted file mode 100644 index 3d2476b20431..000000000000 --- clang/test/ARCMT/Inputs/Module.framework/Headers/Module.h +++ /dev/null @@ -1,28 +0,0 @@ -// expected-warning 0-1 {{umbrella header}} - -// FIXME: The "umbrella header" warning should be moved to a separate test. -// This "0-1" is only here because the warning is only emitted when the -// module is (otherwise) successfully included. - -#ifndef MODULE_H -#define MODULE_H -const char *getModuleVersion(void); - -#ifdef FOO -# error Module should have been built without -DFOO -#endif - -@interface Module -+(const char *)version; // retrieve module version -+alloc; -@end - -#define MODULE_H_MACRO 1 -#__private_macro MODULE_H_MACRO - -#include <Module/Sub.h> -#include <Module/Buried/Treasure.h> - -__asm("foo"); - -#endif // MODULE_H diff --git clang/test/ARCMT/Inputs/Module.framework/Headers/NotInModule.h clang/test/ARCMT/Inputs/Module.framework/Headers/NotInModule.h deleted file mode 100644 index 6b15791eb2c7..000000000000 --- clang/test/ARCMT/Inputs/Module.framework/Headers/NotInModule.h +++ /dev/null @@ -1 +0,0 @@ -int not_in_module; diff --git clang/test/ARCMT/Inputs/Module.framework/Headers/Sub.h clang/test/ARCMT/Inputs/Module.framework/Headers/Sub.h deleted file mode 100644 index dea76e764617..000000000000 --- clang/test/ARCMT/Inputs/Module.framework/Headers/Sub.h +++ /dev/null @@ -1,3 +0,0 @@ -#include <Module/Sub2.h> -int *Module_Sub; - diff --git clang/test/ARCMT/Inputs/Module.framework/Headers/Sub2.h clang/test/ARCMT/Inputs/Module.framework/Headers/Sub2.h deleted file mode 100644 index beed4a862dca..000000000000 --- clang/test/ARCMT/Inputs/Module.framework/Headers/Sub2.h +++ /dev/null @@ -1 +0,0 @@ -int *Module_Sub2; diff --git clang/test/ARCMT/Inputs/Module.framework/Module clang/test/ARCMT/Inputs/Module.framework/Module deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git clang/test/ARCMT/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h clang/test/ARCMT/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h deleted file mode 100644 index 0782336df9de..000000000000 --- clang/test/ARCMT/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h +++ /dev/null @@ -1 +0,0 @@ -int module_private; diff --git clang/test/ARCMT/Inputs/module.modulemap clang/test/ARCMT/Inputs/module.modulemap deleted file mode 100644 index 061abbd24d57..000000000000 --- clang/test/ARCMT/Inputs/module.modulemap +++ /dev/null @@ -1,309 +0,0 @@ -module c_library [extern_c] { module inner { header "c-header.h" } } -module cxx_library { header "cxx-header.h" requires cplusplus } -module c_library_bad [extern_c] { header "c-header-bad.h" } -module diamond_top { header "diamond_top.h" } -module diamond_left { - header "diamond_left.h" - export diamond_top -} -module diamond_right { - header "diamond_right.h" - export diamond_top -} -module diamond_bottom { - header "diamond_bottom.h" - export * -} -module irgen { header "irgen.h" } -module cxx_irgen_top { header "cxx-irgen-top.h" } -module cxx_irgen_left { header "cxx-irgen-left.h" } -module cxx_irgen_right { header "cxx-irgen-right.h" } -module lookup_left_objc { header "lookup_left.h" } -module lookup_right_objc { header "lookup_right.h" } -module lookup_left_cxx { header "lookup_left.hpp" } -module lookup_right_cxx { header "lookup_right.hpp" } -module module_private_left { header "module_private_left.h" } -module module_private_right { header "module_private_right.h" } -module macros_top { - header "macros_top.h" - explicit module b { header "macros_top_b.h" } - explicit module c { header "macros_top_c.h" } -} -module macros_left { - header "macros_left.h" - export * -} -module macros_right { - header "macros_right.h" - export * - explicit module undef { - header "macros_right_undef.h" - } -} -module macros { header "macros.h" } -module macros_other { header "macros_other.h" } -module category_top { header "category_top.h" } -module category_left { - header "category_left.h" - export category_top - - explicit module sub { - header "category_left_sub.h" - } -} -module category_right { - header "category_right.h" - export category_top - - explicit module sub { - header "category_right_sub.h" - } -} -module category_bottom { - header "category_bottom.h" - export category_left - export category_right -} -module category_other { header "category_other.h" } -module redeclarations_left { header "redeclarations_left.h" } -module redeclarations_right { header "redeclarations_right.h" } -module redecl_namespaces_left { header "redecl_namespaces_left.h" } -module redecl_namespaces_right { header "redecl_namespaces_right.h" } -module redecl_add_after_load_top { header "redecl-add-after-load-top.h" } -module redecl_add_after_load { header "redecl-add-after-load.h" } -module load_failure { header "load_failure.h" } - -module decldef { - explicit module Decl { header "decl.h" } - explicit module Decl2 { header "decl2.h" } - explicit module Def { header "def.h" } -} - -module redecl_merge_top { - header "redecl-merge-top.h" - explicit module Explicit { header "redecl-merge-top-explicit.h" } - exclude header "nonexistent.h" -} -module redecl_merge_left { - header "redecl-merge-left.h" - export * -} -module redecl_merge_left_left { - header "redecl-merge-left-left.h" - export * -} -module redecl_merge_right { - header "redecl-merge-right.h" - export * -} -module redecl_merge_bottom { - explicit module prefix { - header "redecl-merge-bottom-prefix.h" - } - - header "redecl-merge-bottom.h" - export * -} -module namespaces_top { - header "namespaces-top.h" - export * -} -module namespaces_left { - header "namespaces-left.h" - export * -} -module namespaces_right { - header "namespaces-right.h" - export * -} -module templates_top { - header "templates-top.h" - export * -} -module templates_left { - header "templates-left.h" - export * -} -module templates_right { - header "templates-right.h" - export * -} -module MethodPoolA { - header "MethodPoolA.h" - - explicit module Sub2 { - header "MethodPoolASub2.h" - } - - explicit module Sub { - header "MethodPoolASub.h" - } -} -module MethodPoolB { - header "MethodPoolB.h" - - explicit module Sub2 { - header "MethodPoolBSub2.h" - } - - explicit module Sub { - header "MethodPoolBSub.h" - } -} -module import_decl { - header "import-decl.h" -} - -framework module * { - exclude NotAModule -} - -module linkage_merge_left { - explicit module sub { - header "linkage-merge-sub.h" - } -} - -module autolink { - header "autolink.h" - link "autolink" - - explicit module sub { - header "autolink-sub.h" - link "autolink_sub" - } - - explicit module sub2 { - header "autolink-sub2.h" - link framework "autolink_framework" - } - - explicit module sub3 { - header "autolink-sub3.h" - link "autolink_from_pch" - } -} - -module weird_objc { - header "weird_objc.h" -} - -module ignored_macros { - header "ignored_macros.h" -} - -module cxx_many_overloads { - header "cxx-many-overloads.h" -} - -module cxx_inline_namespace { - header "cxx-inline-namespace.h" -} - -module cxx_inline_namespace_b { - header "cxx-inline-namespace-b.h" -} - -module cxx_linkage_cache { - header "cxx-linkage-cache.h" -} - -module cxx_templates_common { - header "cxx-templates-common.h" -} - -module cxx_templates_a { - header "cxx-templates-a.h" -} - -module cxx_templates_b_impl { - header "cxx-templates-b-impl.h" -} - -module cxx_templates_b { - header "cxx-templates-b.h" -} - -module cxx_templates_c { - header "cxx-templates-c.h" -} - -module cxx_decls { - module unimported { - header "cxx-decls-unimported.h" - } - module imported { - header "cxx-decls-imported.h" - } -} - -module config { - header "config.h" - config_macros [exhaustive] WANT_FOO, WANT_BAR -} - -module diag_pragma { - header "diag_pragma.h" -} - -module dummy { - header "dummy.h" -} - -module builtin { - header "builtin.h" - explicit module sub { - header "builtin_sub.h" - } -} - -module linkage_merge { - explicit module foo { - header "linkage-merge-foo.h" - } - explicit module bar { - header "linkage-merge-bar.h" - } - -} - -module incomplete_mod { - header "incomplete_mod.h" -} - -module warning { - header "warning.h" -} - -module initializer_list { - header "initializer_list" -} - -module using_decl { - module a { header "using-decl-a.h" export * } - module b { header "using-decl-b.h" export * } -} - -module recursive_visibility_a1 { - module inner { header "recursive_visibility_a1_inner.h" } -} -module recursive_visibility_a2 { - module inner { - module more_inner { - header "recursive_visibility_a2_more_inner.h" - } - } -} -module recursive_visibility_b { - header "recursive_visibility_b.h" - export * -} -module recursive_visibility_c { - header "recursive_visibility_c.h" -} -module recursive1 { - header "recursive1.h" -} -module recursive2 { - header "recursive2.h" -} diff --git clang/test/ARCMT/Inputs/test.h clang/test/ARCMT/Inputs/test.h deleted file mode 100644 index 756295f27e69..000000000000 --- clang/test/ARCMT/Inputs/test.h +++ /dev/null @@ -1,15 +0,0 @@ -@protocol NSObject -- (oneway void)release; -@end - -#ifdef PART1 -static inline void part1(id p) { - [p release]; -} -#endif - -#ifdef PART2 -static inline void part2(id p) { - [p release]; -} -#endif diff --git clang/test/ARCMT/Inputs/test.h.result clang/test/ARCMT/Inputs/test.h.result deleted file mode 100644 index 0638a3378c1c..000000000000 --- clang/test/ARCMT/Inputs/test.h.result +++ /dev/null @@ -1,13 +0,0 @@ -@protocol NSObject -- (oneway void)release; -@end - -#ifdef PART1 -static inline void part1(id p) { -} -#endif - -#ifdef PART2 -static inline void part2(id p) { -} -#endif diff --git clang/test/ARCMT/Inputs/test1.m.in clang/test/ARCMT/Inputs/test1.m.in deleted file mode 100644 index 44a3c4cf3d93..000000000000 --- clang/test/ARCMT/Inputs/test1.m.in +++ /dev/null @@ -1,16 +0,0 @@ -#define PART1 -#include "test.h" - -void test1(id p) { - [p release]; -} - -@interface Test2 -@property (strong) id prop; -@end - -@implementation Test2 --(id)init { - _prop = 0; -} -@end diff --git clang/test/ARCMT/Inputs/test1.m.in.result clang/test/ARCMT/Inputs/test1.m.in.result deleted file mode 100644 index 1db9bf7ad65c..000000000000 --- clang/test/ARCMT/Inputs/test1.m.in.result +++ /dev/null @@ -1,15 +0,0 @@ -#define PART1 -#include "test.h" - -void test1(id p) { -} - -@interface Test2 -@property (strong) id prop; -@end - -@implementation Test2 --(id)init { - _prop = 0; -} -@end diff --git clang/test/ARCMT/Inputs/test2.m.in clang/test/ARCMT/Inputs/test2.m.in deleted file mode 100644 index 99f87b072171..000000000000 --- clang/test/ARCMT/Inputs/test2.m.in +++ /dev/null @@ -1,6 +0,0 @@ -#define PART2 -#include "test.h" - -void test2(id p) { - [p release]; -} diff --git clang/test/ARCMT/Inputs/test2.m.in.result clang/test/ARCMT/Inputs/test2.m.in.result deleted file mode 100644 index f8e918ce2598..000000000000 --- clang/test/ARCMT/Inputs/test2.m.in.result +++ /dev/null @@ -1,5 +0,0 @@ -#define PART2 -#include "test.h" - -void test2(id p) { -} diff --git clang/test/ARCMT/Inputs/with space/test.h clang/test/ARCMT/Inputs/with space/test.h deleted file mode 100644 index 756295f27e69..000000000000 --- clang/test/ARCMT/Inputs/with space/test.h +++ /dev/null @@ -1,15 +0,0 @@ -@protocol NSObject -- (oneway void)release; -@end - -#ifdef PART1 -static inline void part1(id p) { - [p release]; -} -#endif - -#ifdef PART2 -static inline void part2(id p) { - [p release]; -} -#endif diff --git clang/test/ARCMT/Inputs/with space/test.h.result clang/test/ARCMT/Inputs/with space/test.h.result deleted file mode 100644 index 0638a3378c1c..000000000000 --- clang/test/ARCMT/Inputs/with space/test.h.result +++ /dev/null @@ -1,13 +0,0 @@ -@protocol NSObject -- (oneway void)release; -@end - -#ifdef PART1 -static inline void part1(id p) { -} -#endif - -#ifdef PART2 -static inline void part2(id p) { -} -#endif diff --git clang/test/ARCMT/Inputs/with space/test1.m.in clang/test/ARCMT/Inputs/with space/test1.m.in deleted file mode 100644 index 8416a8896569..000000000000 --- clang/test/ARCMT/Inputs/with space/test1.m.in +++ /dev/null @@ -1,6 +0,0 @@ -#define PART1 -#include "test.h" - -void test1(id p) { - [p release]; -} diff --git clang/test/ARCMT/Inputs/with space/test1.m.in.result clang/test/ARCMT/Inputs/with space/test1.m.in.result deleted file mode 100644 index f351fe6c8355..000000000000 --- clang/test/ARCMT/Inputs/with space/test1.m.in.result +++ /dev/null @@ -1,5 +0,0 @@ -#define PART1 -#include "test.h" - -void test1(id p) { -} diff --git clang/test/ARCMT/Inputs/with space/test2.m.in clang/test/ARCMT/Inputs/with space/test2.m.in deleted file mode 100644 index 99f87b072171..000000000000 --- clang/test/ARCMT/Inputs/with space/test2.m.in +++ /dev/null @@ -1,6 +0,0 @@ -#define PART2 -#include "test.h" - -void test2(id p) { - [p release]; -} diff --git clang/test/ARCMT/Inputs/with space/test2.m.in.result clang/test/ARCMT/Inputs/with space/test2.m.in.result deleted file mode 100644 index f8e918ce2598..000000000000 --- clang/test/ARCMT/Inputs/with space/test2.m.in.result +++ /dev/null @@ -1,5 +0,0 @@ -#define PART2 -#include "test.h" - -void test2(id p) { -} diff --git clang/test/ARCMT/allowlisted/Inputs/header1.h clang/test/ARCMT/allowlisted/Inputs/header1.h deleted file mode 100644 index 44430f3b77e3..000000000000 --- clang/test/ARCMT/allowlisted/Inputs/header1.h +++ /dev/null @@ -1 +0,0 @@ -// the contents are not important diff --git clang/test/ARCMT/allowlisted/header1.h clang/test/ARCMT/allowlisted/header1.h deleted file mode 100644 index 33f77aa5dd15..000000000000 --- clang/test/ARCMT/allowlisted/header1.h +++ /dev/null @@ -1,8 +0,0 @@ - -@interface I1 : NSObject --(int)prop; --(void)setProp:(int)p; -+(id)i1; -@end - -typedef long NSInteger; diff --git clang/test/ARCMT/allowlisted/header1.h.result clang/test/ARCMT/allowlisted/header1.h.result deleted file mode 100644 index c7cf109a27e9..000000000000 --- clang/test/ARCMT/allowlisted/header1.h.result +++ /dev/null @@ -1,7 +0,0 @@ - -@interface I1 : NSObject -@property (nonatomic) int prop; -+(instancetype)i1; -@end - -typedef long NSInteger; diff --git clang/test/ARCMT/allowlisted/header2.h clang/test/ARCMT/allowlisted/header2.h deleted file mode 100644 index ac3888ccdf8c..000000000000 --- clang/test/ARCMT/allowlisted/header2.h +++ /dev/null @@ -1,8 +0,0 @@ - -#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type -typedef enum : NSInteger {five} ApplicableEnum; - -@interface I2 : NSObject --(int)prop; --(void)setProp:(int)p; -@end diff --git clang/test/ARCMT/allowlisted/header2.h.result clang/test/ARCMT/allowlisted/header2.h.result deleted file mode 100644 index 3226e711b98a..000000000000 --- clang/test/ARCMT/allowlisted/header2.h.result +++ /dev/null @@ -1,7 +0,0 @@ - -#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type -typedef NS_ENUM(NSInteger, ApplicableEnum) {five}; - -@interface I2 : NSObject -@property (nonatomic) int prop; -@end diff --git clang/test/ARCMT/allowlisted/objcmt-with-allowlist-impl.m clang/test/ARCMT/allowlisted/objcmt-with-allowlist-impl.m deleted file mode 100644 index 36797eb1c843..000000000000 --- clang/test/ARCMT/allowlisted/objcmt-with-allowlist-impl.m +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -objcmt-allowlist-dir-path=%S/Inputs %s -triple x86_64-apple-darwin11 -migrate -o %t.remap -// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %S/header1.h.result %s.result - -@interface NSObject -+ (id)alloc; -@end - -#include "header1.h" -#include "header2.h" - -@interface I2(cat) --(id)initInCat; -@end - -@implementation I1 -+(id)i1 {} -@end diff --git clang/test/ARCMT/allowlisted/objcmt-with-allowlist-impl.m.result clang/test/ARCMT/allowlisted/objcmt-with-allowlist-impl.m.result deleted file mode 100644 index 69e7b767ef2b..000000000000 --- clang/test/ARCMT/allowlisted/objcmt-with-allowlist-impl.m.result +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -objcmt-allowlist-dir-path=%S/Inputs %s -triple x86_64-apple-darwin11 -migrate -o %t.remap -// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %S/header1.h.result %s.result - -@interface NSObject -+ (id)alloc; -@end - -#include "header1.h" -#include "header2.h" - -@interface I2(cat) --(id)initInCat; -@end - -@implementation I1 -+(instancetype)i1 {} -@end diff --git clang/test/ARCMT/allowlisted/objcmt-with-allowlist.m clang/test/ARCMT/allowlisted/objcmt-with-allowlist.m deleted file mode 100644 index c22c02d3bf2e..000000000000 --- clang/test/ARCMT/allowlisted/objcmt-with-allowlist.m +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -objcmt-migrate-ns-macros %s -triple x86_64-apple-darwin11 -migrate -o %t.remap -// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %S/header1.h.result %S/header2.h.result -// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -objcmt-migrate-ns-macros -objcmt-allowlist-dir-path=%S/Inputs %s -triple x86_64-apple-darwin11 -migrate -o %t.remap -// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %S/header1.h.result - -@interface NSObject -+ (id)alloc; -@end - -#include "header1.h" -#include "header2.h" diff --git clang/test/ARCMT/api.m clang/test/ARCMT/api.m deleted file mode 100644 index b186ec724745..000000000000 --- clang/test/ARCMT/api.m +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -void test(NSObject *o) { - NSZone *z = [o zone]; -} diff --git clang/test/ARCMT/api.m.result clang/test/ARCMT/api.m.result deleted file mode 100644 index e3093751b626..000000000000 --- clang/test/ARCMT/api.m.result +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -void test(NSObject *o) { - NSZone *z = nil; -} diff --git clang/test/ARCMT/assign-prop-no-arc-runtime.m clang/test/ARCMT/assign-prop-no-arc-runtime.m deleted file mode 100644 index de1c456b3d19..000000000000 --- clang/test/ARCMT/assign-prop-no-arc-runtime.m +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -@interface Foo : NSObject { - NSObject *x; -} -@property (readonly,assign) id x; -@end - -@implementation Foo -@synthesize x; -@end diff --git clang/test/ARCMT/assign-prop-no-arc-runtime.m.result clang/test/ARCMT/assign-prop-no-arc-runtime.m.result deleted file mode 100644 index 23848d357268..000000000000 --- clang/test/ARCMT/assign-prop-no-arc-runtime.m.result +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -@interface Foo : NSObject { - NSObject *__unsafe_unretained x; -} -@property (readonly,unsafe_unretained) id x; -@end - -@implementation Foo -@synthesize x; -@end diff --git clang/test/ARCMT/assign-prop-with-arc-runtime.m clang/test/ARCMT/assign-prop-with-arc-runtime.m deleted file mode 100644 index a00538cd6197..000000000000 --- clang/test/ARCMT/assign-prop-with-arc-runtime.m +++ /dev/null @@ -1,72 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -__attribute__((objc_arc_weak_reference_unavailable)) -@interface WeakOptOut -@end - -@class _NSCachedAttributedString; -typedef _NSCachedAttributedString *BadClassForWeak; - -@class Forw; - -@interface Foo : NSObject { - Foo *x, *w, *q1, *q2; - WeakOptOut *oo; - BadClassForWeak bcw; - id not_safe1; - NSObject *not_safe2; - Forw *not_safe3; - Foo *assign_plus1; -} -@property (readonly) Foo *x; -@property (assign) Foo *w; -@property Foo *q1, *q2; -@property (assign) WeakOptOut *oo; -@property (assign) BadClassForWeak bcw; -@property (assign) id not_safe1; -@property () NSObject *not_safe2; -@property Forw *not_safe3; -@property (readonly) Foo *assign_plus1; -@property (readonly) Foo *assign_plus2; -@property (readonly) Foo *assign_plus3; - -@property (assign) Foo *no_user_ivar1; -@property (readonly) Foo *no_user_ivar2; - -@property (retain) id def1; -@property (atomic,retain) id def2; -@property (retain,atomic) id def3; - -@end - -@implementation Foo -@synthesize x,w,q1,q2,oo,bcw,not_safe1,not_safe2,not_safe3; -@synthesize no_user_ivar1, no_user_ivar2; -@synthesize assign_plus1, assign_plus2, assign_plus3; -@synthesize def1, def2, def3; - --(void)test:(Foo *)parm { - assign_plus1 = [[Foo alloc] init]; - assign_plus2 = [Foo new]; - assign_plus3 = [parm retain]; -} -@end - -@interface TestExt -@property (retain,readonly) TestExt *x1; -@property (readonly) TestExt *x2; -@end - -@interface TestExt() -@property (retain,readwrite) TestExt *x1; -@property (readwrite) TestExt *x2; -@property (retain) TestExt *x3; -@end - -@implementation TestExt -@synthesize x1, x2, x3; -@end diff --git clang/test/ARCMT/assign-prop-with-arc-runtime.m.result clang/test/ARCMT/assign-prop-with-arc-runtime.m.result deleted file mode 100644 index 8bb684f79a33..000000000000 --- clang/test/ARCMT/assign-prop-with-arc-runtime.m.result +++ /dev/null @@ -1,72 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -__attribute__((objc_arc_weak_reference_unavailable)) -@interface WeakOptOut -@end - -@class _NSCachedAttributedString; -typedef _NSCachedAttributedString *BadClassForWeak; - -@class Forw; - -@interface Foo : NSObject { - Foo *__weak x, *__weak w, *__weak q1, *__weak q2; - WeakOptOut *__unsafe_unretained oo; - BadClassForWeak __unsafe_unretained bcw; - id __unsafe_unretained not_safe1; - NSObject *__unsafe_unretained not_safe2; - Forw *__unsafe_unretained not_safe3; - Foo *assign_plus1; -} -@property (weak, readonly) Foo *x; -@property (weak) Foo *w; -@property (weak) Foo *q1, *q2; -@property (unsafe_unretained) WeakOptOut *oo; -@property (unsafe_unretained) BadClassForWeak bcw; -@property (unsafe_unretained) id not_safe1; -@property (unsafe_unretained) NSObject *not_safe2; -@property (unsafe_unretained) Forw *not_safe3; -@property (readonly) Foo *assign_plus1; -@property (readonly) Foo *assign_plus2; -@property (readonly) Foo *assign_plus3; - -@property (weak) Foo *no_user_ivar1; -@property (weak, readonly) Foo *no_user_ivar2; - -@property (strong) id def1; -@property (atomic,strong) id def2; -@property (strong,atomic) id def3; - -@end - -@implementation Foo -@synthesize x,w,q1,q2,oo,bcw,not_safe1,not_safe2,not_safe3; -@synthesize no_user_ivar1, no_user_ivar2; -@synthesize assign_plus1, assign_plus2, assign_plus3; -@synthesize def1, def2, def3; - --(void)test:(Foo *)parm { - assign_plus1 = [[Foo alloc] init]; - assign_plus2 = [Foo new]; - assign_plus3 = parm; -} -@end - -@interface TestExt -@property (strong,readonly) TestExt *x1; -@property (weak, readonly) TestExt *x2; -@end - -@interface TestExt() -@property (strong,readwrite) TestExt *x1; -@property (weak, readwrite) TestExt *x2; -@property (strong) TestExt *x3; -@end - -@implementation TestExt -@synthesize x1, x2, x3; -@end diff --git clang/test/ARCMT/atautorelease-2.m clang/test/ARCMT/atautorelease-2.m deleted file mode 100644 index b9bc10655325..000000000000 --- clang/test/ARCMT/atautorelease-2.m +++ /dev/null @@ -1,29 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -@interface NSAutoreleasePool -- drain; -+new; -+alloc; --init; --autorelease; --release; -@end - -void NSLog(id, ...); - -int main (int argc, const char * argv[]) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - NSAutoreleasePool *chunkPool = [[NSAutoreleasePool alloc] init]; - - while (argc) { - [chunkPool release]; - return 0; - } - - [chunkPool drain]; - [pool drain]; - - return 0; -} diff --git clang/test/ARCMT/atautorelease-2.m.result clang/test/ARCMT/atautorelease-2.m.result deleted file mode 100644 index 205473380b73..000000000000 --- clang/test/ARCMT/atautorelease-2.m.result +++ /dev/null @@ -1,28 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -@interface NSAutoreleasePool -- drain; -+new; -+alloc; --init; --autorelease; --release; -@end - -void NSLog(id, ...); - -int main (int argc, const char * argv[]) { - @autoreleasepool { - @autoreleasepool { - - while (argc) { - return 0; - } - - } - } - - return 0; -} diff --git clang/test/ARCMT/atautorelease-3.m clang/test/ARCMT/atautorelease-3.m deleted file mode 100644 index 87b80af9350e..000000000000 --- clang/test/ARCMT/atautorelease-3.m +++ /dev/null @@ -1,40 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -@interface NSAutoreleasePool -- drain; -+new; -+alloc; --init; --autorelease; -- release; -@end - -void NSLog(id, ...); - -void test1(int x) { - // All this stuff get removed since nothing is happening inside. - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - NSAutoreleasePool *chunkPool = [[NSAutoreleasePool alloc] init]; - while (x) { - chunkPool = [[NSAutoreleasePool alloc] init]; - [chunkPool release]; - } - - [chunkPool drain]; - [pool drain]; -} - -void test2(int x) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - NSAutoreleasePool *chunkPool = [[NSAutoreleasePool alloc] init]; - while (x) { - chunkPool = [[NSAutoreleasePool alloc] init]; - ++x; - [chunkPool release]; - } - - [chunkPool drain]; - [pool drain]; -} diff --git clang/test/ARCMT/atautorelease-3.m.result clang/test/ARCMT/atautorelease-3.m.result deleted file mode 100644 index 801376a7e82b..000000000000 --- clang/test/ARCMT/atautorelease-3.m.result +++ /dev/null @@ -1,31 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -@interface NSAutoreleasePool -- drain; -+new; -+alloc; --init; --autorelease; -- release; -@end - -void NSLog(id, ...); - -void test1(int x) { - // All this stuff get removed since nothing is happening inside. -} - -void test2(int x) { - @autoreleasepool { - @autoreleasepool { - while (x) { - @autoreleasepool { - ++x; - } - } - - } - } -} diff --git clang/test/ARCMT/atautorelease-check.m clang/test/ARCMT/atautorelease-check.m deleted file mode 100644 index 5f8ffa8bc40e..000000000000 --- clang/test/ARCMT/atautorelease-check.m +++ /dev/null @@ -1,144 +0,0 @@ -// RUN: %clang_cc1 -arcmt-action=check -verify -triple x86_64-apple-darwin10 %s - -#if __has_feature(objc_arr) -#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode"))) -#else -#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE -#endif - -typedef struct _NSZone NSZone; -typedef int BOOL; -typedef unsigned NSUInteger; - -@protocol NSObject -- (BOOL)isEqual:(id)object; -- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE; - -- (NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -@end - -@protocol NSCopying -- (id)copyWithZone:(NSZone *)zone; -@end - -@protocol NSMutableCopying -- (id)mutableCopyWithZone:(NSZone *)zone; -@end - -@interface NSObject <NSObject> {} -- (id)init; - -+ (id)new; -+ (id)allocWithZone:(NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -+ (id)alloc; -- (void)dealloc; - -- (void)finalize; - -- (id)copy; -- (id)mutableCopy; - -+ (id)copyWithZone:(NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -+ (id)mutableCopyWithZone:(NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -@end - -extern void NSRecycleZone(NSZone *zone); - -NS_AUTOMATED_REFCOUNT_UNAVAILABLE -@interface NSAutoreleasePool : NSObject { // expected-note 13 {{marked unavailable here}} -@private - void *_token; - void *_reserved3; - void *_reserved2; - void *_reserved; -} - -+ (void)addObject:(id)anObject; - -- (void)addObject:(id)anObject; - -- (void)drain; - -@end - - -void NSLog(id, ...); - -int main (int argc, const char * argv[]) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - NSAutoreleasePool *chunkPool = [[NSAutoreleasePool alloc] init]; // expected-error 2 {{'NSAutoreleasePool' is unavailable}} - - while (argc) { - [chunkPool release]; - // the following pool was not released in this scope, don't touch it. - chunkPool = [[NSAutoreleasePool alloc] init]; // expected-error {{'NSAutoreleasePool' is unavailable}} - } - - [chunkPool drain]; - [pool drain]; - - return 0; -} - -void f(void) { - NSAutoreleasePool * pool; // expected-error {{'NSAutoreleasePool' is unavailable}} - - for (int i=0; i != 10; ++i) { - id x = pool; // We won't touch a NSAutoreleasePool if we can't safely - // remove all the references to it. - } - - pool = [[NSAutoreleasePool alloc] init]; // expected-error {{'NSAutoreleasePool' is unavailable}} - NSLog(@"%s", "YES"); - [pool release]; -} - -void f2(void) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // expected-error 2 {{'NSAutoreleasePool' is unavailable}} \ - // expected-note {{scope begins here}} - - // 'x' is declared inside the "pool scope" but used outside it, if we create - // a @autorelease scope it will be undefined outside it so don't touch the pool. - int x = 0; // expected-note {{declared here}} - - [pool release]; // expected-note {{scope ends here}} - - ++x; // expected-error {{a name is referenced outside the NSAutoreleasePool scope that it was declared in}} -} - -void f3(void) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // expected-error 2 {{'NSAutoreleasePool' is unavailable}} \ - // expected-note {{scope begins here}} - - struct S { int x; }; // expected-note {{declared here}} - - [pool release]; // expected-note {{scope ends here}} - - struct S *var; // expected-error {{a name is referenced outside the NSAutoreleasePool scope that it was declared in}} - var->x = 0; -} - -void f4(void) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // expected-error 2 {{'NSAutoreleasePool' is unavailable}} \ - // expected-note {{scope begins here}} - - enum { Bar }; // expected-note {{declared here}} - - [pool release]; // expected-note {{scope ends here}} - - int x = Bar; // expected-error {{a name is referenced outside the NSAutoreleasePool scope that it was declared in}} -} - -void f5(void) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // expected-error 2 {{'NSAutoreleasePool' is unavailable}} \ - // expected-note {{scope begins here}} - - typedef int Bar; // expected-note {{declared here}} - - [pool release]; // expected-note {{scope ends here}} - - Bar x; // expected-error {{a name is referenced outside the NSAutoreleasePool scope that it was declared in}} -} diff --git clang/test/ARCMT/atautorelease.m clang/test/ARCMT/atautorelease.m deleted file mode 100644 index a6aed146497b..000000000000 --- clang/test/ARCMT/atautorelease.m +++ /dev/null @@ -1,61 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -void NSLog(id, ...); - -int main (int argc, const char * argv[]) { - - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - - if (argc) { - NSAutoreleasePool * pool = [NSAutoreleasePool new]; - NSLog(@"%s", "YES"); - [pool drain]; - } - [pool drain]; - - NSAutoreleasePool * pool1 = [[NSAutoreleasePool alloc] init]; - NSLog(@"%s", "YES"); - [pool1 release]; - - return 0; -} - -void f(void) { - NSAutoreleasePool *pool1; - - pool1 = [NSAutoreleasePool new]; - int x = 4; - - NSAutoreleasePool *pool2 = [[NSAutoreleasePool alloc] init]; - ++x; - [pool2 drain]; - - [pool1 release]; -} - -int UIApplicationMain(int argc, char *argv[]); - -int main2(int argc, char *argv[]) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - int result = UIApplicationMain(argc, argv); - [pool release]; - return result; -} - -@interface Foo : NSObject -@property (assign) id myProp; -@end - -@implementation Foo -@synthesize myProp; - --(void)test:(id)p { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [pool drain]; - self.myProp = p; -} -@end diff --git clang/test/ARCMT/atautorelease.m.result clang/test/ARCMT/atautorelease.m.result deleted file mode 100644 index e24339a3b9e3..000000000000 --- clang/test/ARCMT/atautorelease.m.result +++ /dev/null @@ -1,60 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -void NSLog(id, ...); - -int main (int argc, const char * argv[]) { - - @autoreleasepool { - - if (argc) { - @autoreleasepool { - NSLog(@"%s", "YES"); - } - } - } - - @autoreleasepool { - NSLog(@"%s", "YES"); - } - - return 0; -} - -void f(void) { - - @autoreleasepool { - int x = 4; - - @autoreleasepool { - ++x; - } - - } -} - -int UIApplicationMain(int argc, char *argv[]); - -int main2(int argc, char *argv[]) { - @autoreleasepool { - int result = UIApplicationMain(argc, argv); - return result; - } -} - -@interface Foo : NSObject -@property (unsafe_unretained) id myProp; -@end - -@implementation Foo -@synthesize myProp; - --(void)test:(id)p { - @autoreleasepool { - } - self.myProp = p; -} -@end diff --git clang/test/ARCMT/autoreleases.m clang/test/ARCMT/autoreleases.m deleted file mode 100644 index 7c046dc227a0..000000000000 --- clang/test/ARCMT/autoreleases.m +++ /dev/null @@ -1,75 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -@interface A : NSObject { -@package - id object; -} -@end - -@interface B : NSObject { - id _prop; - xpc_object_t _xpc_prop; -} -- (BOOL)containsSelf:(A*)a; -@property (retain) id prop; -@property (retain) xpc_object_t xpc_prop; -@end - -@implementation A -@end - -@implementation B -- (BOOL)containsSelf:(A*)a { - return a->object == self; -} - --(id) prop { - return _prop; -} --(void) setProp:(id) newVal { - [_prop autorelease]; - _prop = [newVal retain]; -} --(void) setProp2:(CFTypeRef) newVal { - [_prop autorelease]; - _prop = (id)CFRetain(newVal); -} - --(id) xpc_prop { - return _xpc_prop; -} --(void) setXpc_prop:(xpc_object_t) newVal { - [_xpc_prop autorelease]; - _xpc_prop = xpc_retain(newVal); -} -@end - -void NSLog(id, ...); - -int main (int argc, const char * argv[]) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - A *a = [[A new] autorelease]; - B *b = [[B new] autorelease]; - NSLog(@"%s", [b containsSelf:a] ? "YES" : "NO"); - [pool drain]; - return 0; -} - -void test(A *prevVal, A *newVal) { - [prevVal autorelease]; - prevVal = [newVal retain]; -} - -id test2(A* val) { - [[val retain] autorelease]; - return val; -} - -void test3(void) { - id a = [[A alloc] init]; - [a autorelease]; -} diff --git clang/test/ARCMT/autoreleases.m.result clang/test/ARCMT/autoreleases.m.result deleted file mode 100644 index 29d00ea60dee..000000000000 --- clang/test/ARCMT/autoreleases.m.result +++ /dev/null @@ -1,69 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -@interface A : NSObject { -@package - id object; -} -@end - -@interface B : NSObject { - id _prop; - xpc_object_t _xpc_prop; -} -- (BOOL)containsSelf:(A*)a; -@property (strong) id prop; -@property (strong) xpc_object_t xpc_prop; -@end - -@implementation A -@end - -@implementation B -- (BOOL)containsSelf:(A*)a { - return a->object == self; -} - --(id) prop { - return _prop; -} --(void) setProp:(id) newVal { - _prop = newVal; -} --(void) setProp2:(CFTypeRef) newVal { - _prop = (id)CFBridgingRelease(CFRetain(newVal)); -} - --(id) xpc_prop { - return _xpc_prop; -} --(void) setXpc_prop:(xpc_object_t) newVal { - _xpc_prop = newVal; -} -@end - -void NSLog(id, ...); - -int main (int argc, const char * argv[]) { - @autoreleasepool { - A *a = [A new]; - B *b = [B new]; - NSLog(@"%s", [b containsSelf:a] ? "YES" : "NO"); - } - return 0; -} - -void test(A *prevVal, A *newVal) { - prevVal = newVal; -} - -id test2(A* val) { - return val; -} - -void test3(void) { - id a = [[A alloc] init]; -} diff --git clang/test/ARCMT/block_copy_release.m clang/test/ARCMT/block_copy_release.m deleted file mode 100644 index ae3b82660a8e..000000000000 --- clang/test/ARCMT/block_copy_release.m +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -typedef void (^blk)(int); - -void func(blk b) { - blk c = Block_copy(b); - Block_release(c); -} - -void func2(id b) { - id c = Block_copy(b); - Block_release(c); -} diff --git clang/test/ARCMT/block_copy_release.m.result clang/test/ARCMT/block_copy_release.m.result deleted file mode 100644 index b292b64f17d6..000000000000 --- clang/test/ARCMT/block_copy_release.m.result +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -typedef void (^blk)(int); - -void func(blk b) { - blk c = [b copy]; -} - -void func2(id b) { - id c = [b copy]; -} diff --git clang/test/ARCMT/check-api.m clang/test/ARCMT/check-api.m deleted file mode 100644 index b395f0b4a4b9..000000000000 --- clang/test/ARCMT/check-api.m +++ /dev/null @@ -1,43 +0,0 @@ -// RUN: %clang_cc1 -arcmt-action=check -verify -triple x86_64-apple-macosx10.7 %s - -#include "Common.h" - -@interface NSInvocation : NSObject -- (void)getReturnValue:(void *)retLoc; -- (void)setReturnValue:(void *)retLoc; - -- (void)getArgument:(void *)argumentLocation atIndex:(int)idx; -- (void)setArgument:(void *)argumentLocation atIndex:(int)idx; -@end - -@interface Test -@end - -@implementation Test { - id strong_id; - __weak id weak_id; - __unsafe_unretained id unsafe_id; - int arg; -} -- (void) test:(NSInvocation *)invok { - [invok getReturnValue:&strong_id]; // expected-error {{NSInvocation's getReturnValue is not safe to be used with an object with ownership other than __unsafe_unretained}} - [invok getReturnValue:&weak_id]; // expected-error {{NSInvocation's getReturnValue is not safe to be used with an object with ownership other than __unsafe_unretained}} - [invok getReturnValue:&unsafe_id]; - [invok getReturnValue:&arg]; - - [invok setReturnValue:&strong_id]; // expected-error {{NSInvocation's setReturnValue is not safe to be used with an object with ownership other than __unsafe_unretained}} - [invok setReturnValue:&weak_id]; // expected-error {{NSInvocation's setReturnValue is not safe to be used with an object with ownership other than __unsafe_unretained}} - [invok setReturnValue:&unsafe_id]; - [invok setReturnValue:&arg]; - - [invok getArgument:&strong_id atIndex:0]; // expected-error {{NSInvocation's getArgument is not safe to be used with an object with ownership other than __unsafe_unretained}} - [invok getArgument:&weak_id atIndex:0]; // expected-error {{NSInvocation's getArgument is not safe to be used with an object with ownership other than __unsafe_unretained}} - [invok getArgument:&unsafe_id atIndex:0]; - [invok getArgument:&arg atIndex:0]; - - [invok setArgument:&strong_id atIndex:0]; // expected-error {{NSInvocation's setArgument is not safe to be used with an object with ownership other than __unsafe_unretained}} - [invok setArgument:&weak_id atIndex:0]; // expected-error {{NSInvocation's setArgument is not safe to be used with an object with ownership other than __unsafe_unretained}} - [invok setArgument:&unsafe_id atIndex:0]; - [invok setArgument:&arg atIndex:0]; -} -@end diff --git clang/test/ARCMT/check-with-pch.m clang/test/ARCMT/check-with-pch.m deleted file mode 100644 index c2fda3b52cbc..000000000000 --- clang/test/ARCMT/check-with-pch.m +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -x objective-c -triple x86_64-apple-darwin10 %S/Common.h -emit-pch -o %t.pch -// RUN: %clang_cc1 -include-pch %t.pch -arcmt-action=check -verify -triple x86_64-apple-darwin10 -fblocks -Werror %s -// REQUIRES: x86-registered-target - -@interface I9601437 { - __unsafe_unretained id x; -} --(void)Meth; -@end - -@implementation I9601437 --(void)Meth { - self->x = [NSObject new]; // expected-error {{assigning retained object}} -} -@end diff --git clang/test/ARCMT/check-with-serialized-diag.m clang/test/ARCMT/check-with-serialized-diag.m deleted file mode 100644 index 6102be037fcc..000000000000 --- clang/test/ARCMT/check-with-serialized-diag.m +++ /dev/null @@ -1,55 +0,0 @@ - -@protocol NSObject -- (id)retain; -- (unsigned)retainCount; -- (oneway void)release; -- (id)autorelease; -@end - -@interface NSObject <NSObject> {} -- (id)init; - -+ (id)new; -+ (id)alloc; -- (void)dealloc; - -- (void)finalize; - -- (id)copy; -- (id)mutableCopy; -@end - -@interface A : NSObject -@end - -struct UnsafeS { - A *__unsafe_unretained unsafeObj; -}; - -id global_foo; - -void test1(A *a, struct UnsafeS *unsafeS) { - [unsafeS->unsafeObj retain]; - id foo = [unsafeS->unsafeObj retain]; // no warning. - [global_foo retain]; - [a retainCount]; -} - -// RUN: not %clang_cc1 -arcmt-action=check -triple x86_64-apple-darwin10 %s -serialize-diagnostic-file %t.diag -// RUN: c-index-test -read-diagnostics %t.diag > %t 2>&1 -// RUN: FileCheck --input-file=%t %s - -// CHECK: {{.*}}check-with-serialized-diag.m:32:4: error: [rewriter] it is not safe to remove 'retain' message on an __unsafe_unretained type -// CHECK-NEXT: Number FIXITs = 0 -// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:34:4: error: [rewriter] it is not safe to remove 'retain' message on a global variable -// CHECK-NEXT: Number FIXITs = 0 -// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:32:23: error: ARC forbids explicit message send of 'retain' -// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:32:4 {{.*}}check-with-serialized-diag.m:32:22 -// CHECK-NEXT: Number FIXITs = 0 -// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:34:15: error: ARC forbids explicit message send of 'retain' -// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:34:4 {{.*}}check-with-serialized-diag.m:34:14 -// CHECK-NEXT: Number FIXITs = 0 -// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:35:6: error: ARC forbids explicit message send of 'retainCount' -// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:35:4 {{.*}}check-with-serialized-diag.m:35:5 -// CHECK-NEXT: Number FIXITs = 0 - diff --git clang/test/ARCMT/checking-in-arc.m clang/test/ARCMT/checking-in-arc.m deleted file mode 100644 index 1bf6aca18a34..000000000000 --- clang/test/ARCMT/checking-in-arc.m +++ /dev/null @@ -1,50 +0,0 @@ -// RUN: %clang_cc1 -arcmt-action=check -fobjc-arc -fobjc-runtime=macosx-10.8.0 -triple x86_64-apple-darwin12 -fblocks -Werror %s - -#if __has_feature(objc_arc) -#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode"))) -#else -#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE -#endif - -typedef const void * CFTypeRef; -CFTypeRef CFBridgingRetain(id X); -id CFBridgingRelease(CFTypeRef); - -typedef int BOOL; -typedef unsigned NSUInteger; - -@protocol NSObject -- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -@end - -@interface NSObject <NSObject> {} -- (id)init; - -+ (id)new; -+ (id)alloc; -- (void)dealloc; - -- (void)finalize; - -- (id)copy; -- (id)mutableCopy; -@end - -typedef const struct __CFString * CFStringRef; -extern const CFStringRef kUTTypePlainText; -extern const CFStringRef kUTTypeRTF; -@class NSString; - -@interface Test : NSObject -@property (weak) NSString *weakProperty; -@end - -@implementation Test -@end - -#if ! __has_feature(objc_arc) -#error This file must be compiled with ARC (set -fobjc_arc flag on file) -#endif diff --git clang/test/ARCMT/checking.m clang/test/ARCMT/checking.m deleted file mode 100644 index 5bc456c6301c..000000000000 --- clang/test/ARCMT/checking.m +++ /dev/null @@ -1,351 +0,0 @@ -// RUN: %clang_cc1 -arcmt-action=check -verify -triple x86_64-apple-darwin10 -fblocks -Werror %s - -#if __has_feature(objc_arc) -#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode"))) -#else -#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE -#endif - -typedef const void * CFTypeRef; -CFTypeRef CFBridgingRetain(id X); -id CFBridgingRelease(CFTypeRef); - -typedef int BOOL; -typedef unsigned NSUInteger; - -@protocol NSObject -- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -@end - -@interface NSObject <NSObject> {} -- (id)init; - -+ (id)new; -+ (id)alloc; -- (void)dealloc; - -- (void)finalize; - -- (id)copy; -- (id)mutableCopy; -@end - -typedef const struct __CFString * CFStringRef; -extern const CFStringRef kUTTypePlainText; -extern const CFStringRef kUTTypeRTF; -@class NSString; -@class A; - -struct UnsafeS { - A *__unsafe_unretained unsafeObj; -}; - -@interface A : NSObject -- (id)retain __attribute__((unavailable)); // expected-note {{'retain' has been explicitly marked unavailable here}} -- (id)retainCount __attribute__((unavailable)); // expected-note {{'retainCount' has been explicitly marked unavailable here}} -- (id)autorelease __attribute__((unavailable)); // expected-note 2 {{'autorelease' has been explicitly marked unavailable here}} -- (id)init; -- (oneway void)release; -- (void)dealloc; --(void)test; --(id)delegate; -@end - -@implementation A --(void)test { - [super dealloc]; -} --(void)dealloc { - [super dealloc]; -} - -- (id)retain { return self; } // expected-error {{ARC forbids implementation}} -- (id)retainCount { return self; } // expected-error {{ARC forbids implementation}} -- (id)autorelease { return self; } // expected-error {{ARC forbids implementation}} -- (oneway void)release { } // expected-error {{ARC forbids implementation}} - --(id)delegate { return self; } -@end - -id global_foo; - -void test1(A *a, BOOL b, struct UnsafeS *unsafeS) { - [[a delegate] release]; // expected-error {{it is not safe to remove 'retain' message on the result of a 'delegate' message; the object that was passed to 'setDelegate:' may not be properly retained}} \ - // expected-error {{ARC forbids explicit message send}} - [a.delegate release]; // expected-error {{it is not safe to remove 'retain' message on the result of a 'delegate' message; the object that was passed to 'setDelegate:' may not be properly retained}} \ - // expected-error {{ARC forbids explicit message send}} - [unsafeS->unsafeObj retain]; // expected-error {{it is not safe to remove 'retain' message on an __unsafe_unretained type}} \ - // expected-error {{ARC forbids explicit message send}} \ - // expected-error {{'retain' is unavailable}} - id foo = [unsafeS->unsafeObj retain]; // no warning. - [global_foo retain]; // expected-error {{it is not safe to remove 'retain' message on a global variable}} \ - // expected-error {{ARC forbids explicit message send}} - [global_foo release]; // expected-error {{it is not safe to remove 'release' message on a global variable}} \ - // expected-error {{ARC forbids explicit message send}} - [a dealloc]; - [a retain]; - [a retainCount]; // expected-error {{ARC forbids explicit message send of 'retainCount'}} \ - // expected-error {{'retainCount' is unavailable}} - [a release]; - [a autorelease]; // expected-error {{it is not safe to remove an unused 'autorelease' message; its receiver may be destroyed immediately}} \ - // expected-error {{ARC forbids explicit message send}} \ - // expected-error {{'autorelease' is unavailable}} - [a autorelease]; // expected-error {{it is not safe to remove an unused 'autorelease' message; its receiver may be destroyed immediately}} \ - // expected-error {{ARC forbids explicit message send}} \ - // expected-error {{'autorelease' is unavailable}} - a = 0; - - CFStringRef cfstr; - NSString *str = (NSString *)cfstr; // expected-error {{cast of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \ - // expected-note {{use __bridge to convert directly (no change in ownership)}} \ - // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}} \ - str = (NSString *)kUTTypePlainText; - str = b ? kUTTypeRTF : kUTTypePlainText; - str = (NSString *)(b ? kUTTypeRTF : kUTTypePlainText); - str = (NSString *)a; // no change. - - SEL s = @selector(retain); // expected-error {{ARC forbids use of 'retain' in a @selector}} - s = @selector(release); // expected-error {{ARC forbids use of 'release' in a @selector}} - s = @selector(autorelease); // expected-error {{ARC forbids use of 'autorelease' in a @selector}} - s = @selector(dealloc); // expected-error {{ARC forbids use of 'dealloc' in a @selector}} - - static id __autoreleasing X1; // expected-error {{global variables cannot have __autoreleasing ownership}} -} - -struct S { - A* a; -}; - -@interface B --(id)alloc; -- (id)initWithInt: (int) i; -@end - -void rdar8861761(void) { - B *o1 = [[B alloc] initWithInt:0]; - B *o2 = [B alloc]; - [o2 initWithInt:0]; -} - -@interface Test13 -- (id) init0; -- (void) noninit; -@end -@implementation Test13 -- (id) init0 { - self = 0; -} -- (void) noninit { - self = 0; // expected-error {{cannot assign to 'self' outside of a method in the init family}} - - for (__strong id x in collection) { // expected-error {{use of undeclared identifier 'collection'}} - x = 0; - } -} -@end - -void * cvt(id arg) -{ - void* voidp_val; - (void)(int*)arg; // expected-error {{disallowed}} - (void)(id)arg; - (void)(__autoreleasing id*)arg; // expected-error {{disallowed}} - (void)(id*)arg; // expected-error {{disallowed}} - - (void)(__autoreleasing id**)voidp_val; - (void)(void*)voidp_val; - (void)(void**)arg; // expected-error {{disallowed}} - cvt((void*)arg); // expected-error 2 {{requires a bridged cast}} \ - // expected-note 2 {{use __bridge to}} expected-note {{use CFBridgingRelease call}} expected-note {{use CFBridgingRetain call}} - cvt(0); - (void)(__strong id**)(0); - return arg; // expected-error {{requires a bridged cast}} expected-note {{use __bridge}} expected-note {{use CFBridgingRetain call}} -} - - -void test12(id collection) { - for (id x in collection) { - x = 0; - } - - for (__strong id x in collection) { - x = 0; - } -} - -void test6(unsigned cond) { - switch (cond) { - case 0: - ; - id x; // expected-note {{jump bypasses initialization of __strong variable}} - - case 1: // expected-error {{cannot jump}} - x = 0; - break; - } -} - -@class Test8_incomplete; -@interface Test8_complete @end; -@interface Test8_super @end; -@interface Test8 : Test8_super -- (id) init00; -- (id) init01; // expected-note {{declaration in interface}} -- (id) init02; -- (id) init03; // covariance -- (id) init04; // covariance -- (id) init05; - -- (void) init10; // expected-note {{declaration in interface is not in the 'init' family because its result type is not an object pointer}} -- (void) init11; -- (void) init12; -- (void) init13; // expected-note {{declaration in interface is not in the 'init' family because its result type is not an object pointer}} -- (void) init14; // expected-note {{declaration in interface is not in the 'init' family because its result type is not an object pointer}} -- (void) init15; - -// These should be invalid to actually call. -- (Test8_incomplete*) init20; -- (Test8_incomplete*) init21; // expected-note {{declaration in interface}} -- (Test8_incomplete*) init22; -- (Test8_incomplete*) init23; -- (Test8_incomplete*) init24; -- (Test8_incomplete*) init25; - -- (Test8_super*) init30; // id exception to covariance -- (Test8_super*) init31; // expected-note {{declaration in interface}} -- (Test8_super*) init32; -- (Test8_super*) init33; -- (Test8_super*) init34; // covariance -- (Test8_super*) init35; - -- (Test8*) init40; // id exception to covariance -- (Test8*) init41; // expected-note {{declaration in interface}} -- (Test8*) init42; -- (Test8*) init43; // this should be a warning, but that's a general language thing, not an ARC thing -- (Test8*) init44; -- (Test8*) init45; - -- (Test8_complete*) init50; // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_complete*) init51; // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_complete*) init52; // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_complete*) init53; // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_complete*) init54; // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_complete*) init55; // expected-error {{init methods must return a type related to the receiver type}} -@end -@implementation Test8 -- (id) init00 { return 0; } -- (id) init10 { return 0; } // expected-error {{method implementation does not match its declaration}} -- (id) init20 { return 0; } -- (id) init30 { return 0; } -- (id) init40 { return 0; } -- (id) init50 { return 0; } - -- (void) init01 {} // expected-error {{method was declared as an 'init' method, but its implementation doesn't match because its result type is not an object pointer}} -- (void) init11 {} -- (void) init21 {} // expected-error {{method was declared as an 'init' method, but its implementation doesn't match because its result type is not an object pointer}} -- (void) init31 {} // expected-error {{method was declared as an 'init' method, but its implementation doesn't match because its result type is not an object pointer}} -- (void) init41 {} // expected-error {{method was declared as an 'init' method, but its implementation doesn't match because its result type is not an object pointer}} -- (void) init51 {} - -- (Test8_incomplete*) init02 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_incomplete*) init12 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_incomplete*) init22 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_incomplete*) init32 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_incomplete*) init42 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_incomplete*) init52 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} - -- (Test8_super*) init03 { return 0; } -- (Test8_super*) init13 { return 0; } // expected-error {{method implementation does not match its declaration}} -- (Test8_super*) init23 { return 0; } -- (Test8_super*) init33 { return 0; } -- (Test8_super*) init43 { return 0; } -- (Test8_super*) init53 { return 0; } - -- (Test8*) init04 { return 0; } -- (Test8*) init14 { return 0; } // expected-error {{method implementation does not match its declaration}} -- (Test8*) init24 { return 0; } -- (Test8*) init34 { return 0; } -- (Test8*) init44 { return 0; } -- (Test8*) init54 { return 0; } - -- (Test8_complete*) init05 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_complete*) init15 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_complete*) init25 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_complete*) init35 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_complete*) init45 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_complete*) init55 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} -@end - -@class Test9_incomplete; -@interface Test9 -- (Test9_incomplete*) init1; // expected-error {{init methods must return a type related to the receiver type}} -- (Test9_incomplete*) init2; -@end -id test9(Test9 *v) { - return [v init1]; -} - -void rdar9491791(int p) { - switch (p) { - case 3:; - NSObject *o = [[NSObject alloc] init]; - [o release]; - break; - default: - break; - } -} - -#define RELEASE_MACRO(x) do { [x release]; } while(1) - -void rdar9504750(id p) { - RELEASE_MACRO(p); // expected-error {{ARC forbids explicit message send of 'release'}} -} - -@interface TestReadonlyProperty : NSObject -@property(assign,readonly) NSObject *value; -@end - -@implementation TestReadonlyProperty -@synthesize value; -- (void)viewDidLoad { - value = [NSObject new]; // expected-error {{assigning retained object}} -} -@end - -@interface I9601437 { - __unsafe_unretained id x; -} --(void)Meth; -@end - -@implementation I9601437 --(void)Meth { - self->x = [NSObject new]; // expected-error {{assigning retained object}} -} -@end - -@interface Test10 : NSObject { - CFStringRef cfstr; -} -@property (retain) id prop; --(void)foo; -@end - -void test(Test10 *x) { - x.prop = ^{ [x foo]; }; // expected-warning {{likely to lead to a retain cycle}} \ - // expected-note {{retained by the captured object}} -} - -@implementation Test10 --(void)foo { - ^{ - NSString *str = (NSString *)cfstr; // expected-error {{cast of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \ - // expected-note {{use __bridge to convert directly (no change in ownership)}} \ - // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}} - }; -} -@end diff --git clang/test/ARCMT/cxx-checking.mm clang/test/ARCMT/cxx-checking.mm deleted file mode 100644 index f8836d9d7cd8..000000000000 --- clang/test/ARCMT/cxx-checking.mm +++ /dev/null @@ -1,100 +0,0 @@ -// RUN: %clang_cc1 -arcmt-action=check -verify -triple x86_64-apple-darwin10 -fsyntax-only -fblocks %s - -// Classes that have an Objective-C object pointer. -struct HasObjectMember0 { - id x; -}; - -struct HasObjectMember1 { - id x[3]; -}; - -struct HasObjectMember2 { - id x[3][2]; -}; - -// Don't complain if the type has non-external linkage -namespace { - struct HasObjectMember3 { - id x[3][2]; - }; -} - -// Don't complain if the Objective-C pointer type was explicitly given -// no lifetime. -struct HasObjectMember3 { - __unsafe_unretained id x[3][2]; -}; - -struct HasBlockPointerMember0 { - int (^bp)(int); -}; - -struct HasBlockPointerMember1 { - int (^bp[2][3])(int); -}; - -struct NonPOD { - NonPOD(const NonPOD&); -}; - -struct HasObjectMemberAndNonPOD0 { - id x; - NonPOD np; -}; - -struct HasObjectMemberAndNonPOD1 { - NonPOD np; - id x[3]; -}; - -struct HasObjectMemberAndNonPOD2 { - NonPOD np; - id x[3][2]; -}; - -struct HasObjectMemberAndNonPOD3 { - HasObjectMemberAndNonPOD3 &operator=(const HasObjectMemberAndNonPOD3&); - ~HasObjectMemberAndNonPOD3(); - NonPOD np; - id x[3][2]; -}; - -struct HasBlockPointerMemberAndNonPOD0 { - NonPOD np; - int (^bp)(int); -}; - -struct HasBlockPointerMemberAndNonPOD1 { - NonPOD np; - int (^bp[2][3])(int); -}; - -int check_non_pod_objc_pointer0[__is_pod(id)? 1 : -1]; -int check_non_pod_objc_pointer1[__is_pod(__strong id)? -1 : 1]; -int check_non_pod_objc_pointer2[__is_pod(__unsafe_unretained id)? 1 : -1]; -int check_non_pod_objc_pointer3[__is_pod(id[2][3])? 1 : -1]; -int check_non_pod_objc_pointer4[__is_pod(__unsafe_unretained id[2][3])? 1 : -1]; -int check_non_pod_block0[__is_pod(int (^)(int))? 1 : -1]; -int check_non_pod_block1[__is_pod(int (^ __unsafe_unretained)(int))? 1 : -1]; - -struct FlexibleArrayMember0 { - int length; - id array[]; // expected-error{{flexible array member 'array' of type '__strong id[]' with non-trivial destruction}} -}; - -struct FlexibleArrayMember1 { - int length; - __unsafe_unretained id array[]; -}; - -// It's okay to pass a retainable type through an ellipsis. -void variadic(...); -void test_variadic() { - variadic(1, 17, @"Foo"); -} - -// It's okay to create a VLA of retainable types. -void vla(int n) { - id vla[n]; -} diff --git clang/test/ARCMT/cxx-rewrite.mm clang/test/ARCMT/cxx-rewrite.mm deleted file mode 100644 index 4a9c50c92426..000000000000 --- clang/test/ARCMT/cxx-rewrite.mm +++ /dev/null @@ -1,33 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c++ %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -@interface NSString : NSObject -+(id)string; -@end - -struct foo { - NSString *s; - foo(NSString *s): s([s retain]){ - NSAutoreleasePool *pool = [NSAutoreleasePool new]; - [[[NSString string] retain] release]; - [pool drain]; - if (s) - [s release]; - } - ~foo(){ [s release]; } -private: - foo(foo const &); - foo &operator=(foo const &); -}; - -int main(){ - NSAutoreleasePool *pool = [NSAutoreleasePool new]; - - foo f([[NSString string] autorelease]); - - [pool drain]; - return 0; -} diff --git clang/test/ARCMT/cxx-rewrite.mm.result clang/test/ARCMT/cxx-rewrite.mm.result deleted file mode 100644 index a96d254bf463..000000000000 --- clang/test/ARCMT/cxx-rewrite.mm.result +++ /dev/null @@ -1,31 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c++ %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -@interface NSString : NSObject -+(id)string; -@end - -struct foo { - NSString *s; - foo(NSString *s): s(s){ - @autoreleasepool { - [NSString string]; - } - } - ~foo(){ } -private: - foo(foo const &); - foo &operator=(foo const &); -}; - -int main(){ - @autoreleasepool { - - foo f([NSString string]); - - } - return 0; -} diff --git clang/test/ARCMT/dealloc.m clang/test/ARCMT/dealloc.m deleted file mode 100644 index d7a72af4f726..000000000000 --- clang/test/ARCMT/dealloc.m +++ /dev/null @@ -1,24 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -@interface A -- (id)retain; -- (id)autorelease; -- (oneway void)release; -- (void)dealloc; -@end - -void test1(A *a) { - [a dealloc]; -} - -@interface Test2 : A -- (void) dealloc; -@end - -@implementation Test2 -- (void) dealloc { - [super dealloc]; -} -@end diff --git clang/test/ARCMT/dealloc.m.result clang/test/ARCMT/dealloc.m.result deleted file mode 100644 index fbd9e445d275..000000000000 --- clang/test/ARCMT/dealloc.m.result +++ /dev/null @@ -1,20 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -@interface A -- (id)retain; -- (id)autorelease; -- (oneway void)release; -- (void)dealloc; -@end - -void test1(A *a) { -} - -@interface Test2 : A -- (void) dealloc; -@end - -@implementation Test2 -@end diff --git clang/test/ARCMT/designated-init-in-header/designated-init-in-header.m clang/test/ARCMT/designated-init-in-header/designated-init-in-header.m deleted file mode 100644 index 8286583b3c89..000000000000 --- clang/test/ARCMT/designated-init-in-header/designated-init-in-header.m +++ /dev/null @@ -1,3 +0,0 @@ -// RUN: %clang_cc1 -objcmt-migrate-designated-init -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -x objective-c %S/file1.m.in -triple x86_64-apple-darwin11 -fobjc-arc -migrate -o %t1.remap -// RUN: %clang_cc1 -objcmt-migrate-designated-init -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -x objective-c %S/file2.m.in -triple x86_64-apple-darwin11 -fobjc-arc -migrate -o %t2.remap -// RUN: c-arcmt-test %t1.remap %t2.remap | arcmt-test -verify-transformed-files %S/header1.h.result %S/file2.m.in.result diff --git clang/test/ARCMT/designated-init-in-header/file1.m.in clang/test/ARCMT/designated-init-in-header/file1.m.in deleted file mode 100644 index 0201b32abd32..000000000000 --- clang/test/ARCMT/designated-init-in-header/file1.m.in +++ /dev/null @@ -1,2 +0,0 @@ -#include "header1.h" - diff --git clang/test/ARCMT/designated-init-in-header/file2.m.in clang/test/ARCMT/designated-init-in-header/file2.m.in deleted file mode 100644 index 258159735a77..000000000000 --- clang/test/ARCMT/designated-init-in-header/file2.m.in +++ /dev/null @@ -1,14 +0,0 @@ -#include "header1.h" - -@implementation S1 --(int)prop { return 0; } --(void)setProp:(int)p {} -+(id)s1 { return 0; } --(id)initWithFoo:(NSString*)foo -{ - self = [super init]; - if (self) { - } - return self; -} -@end diff --git clang/test/ARCMT/designated-init-in-header/file2.m.in.result clang/test/ARCMT/designated-init-in-header/file2.m.in.result deleted file mode 100644 index 7465ed576f5f..000000000000 --- clang/test/ARCMT/designated-init-in-header/file2.m.in.result +++ /dev/null @@ -1,14 +0,0 @@ -#include "header1.h" - -@implementation S1 --(int)prop { return 0; } --(void)setProp:(int)p {} -+(instancetype)s1 { return 0; } --(instancetype)initWithFoo:(NSString*)foo -{ - self = [super init]; - if (self) { - } - return self; -} -@end diff --git clang/test/ARCMT/designated-init-in-header/header1.h clang/test/ARCMT/designated-init-in-header/header1.h deleted file mode 100644 index c5668cc46086..000000000000 --- clang/test/ARCMT/designated-init-in-header/header1.h +++ /dev/null @@ -1,14 +0,0 @@ -#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) - -@class NSString; - -@interface B1 --(id)init; -@end - -@interface S1 : B1 --(int)prop; --(void)setProp:(int)p; -+(id)s1; --(id)initWithFoo:(NSString*)foo; -@end diff --git clang/test/ARCMT/designated-init-in-header/header1.h.result clang/test/ARCMT/designated-init-in-header/header1.h.result deleted file mode 100644 index 974175b1c3e6..000000000000 --- clang/test/ARCMT/designated-init-in-header/header1.h.result +++ /dev/null @@ -1,13 +0,0 @@ -#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) - -@class NSString; - -@interface B1 --(instancetype)init; -@end - -@interface S1 : B1 -@property (nonatomic) int prop; -+(instancetype)s1; --(instancetype)initWithFoo:(NSString*)foo NS_DESIGNATED_INITIALIZER; -@end diff --git clang/test/ARCMT/dispatch.m clang/test/ARCMT/dispatch.m deleted file mode 100644 index 58c7769638cb..000000000000 --- clang/test/ARCMT/dispatch.m +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -dispatch_object_t getme(void); - -void func(dispatch_object_t o) { - dispatch_retain(o); - dispatch_release(o); - dispatch_retain(getme()); -} - -void func2(xpc_object_t o) { - xpc_retain(o); - xpc_release(o); -} diff --git clang/test/ARCMT/dispatch.m.result clang/test/ARCMT/dispatch.m.result deleted file mode 100644 index 55b65585e4f6..000000000000 --- clang/test/ARCMT/dispatch.m.result +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -dispatch_object_t getme(void); - -void func(dispatch_object_t o) { - getme(); -} - -void func2(xpc_object_t o) { -} diff --git clang/test/ARCMT/driver-migrate.m clang/test/ARCMT/driver-migrate.m deleted file mode 100644 index ec3f4cc8c4a3..000000000000 --- clang/test/ARCMT/driver-migrate.m +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang -### -ccc-arcmt-migrate /foo/bar -fsyntax-only %s 2>&1 | FileCheck %s - -// CHECK: "-arcmt-action=migrate" "-mt-migrate-directory" "{{[^"]*}}/foo/bar" - -// RUN: touch %t.o -// RUN: %clang -ccc-arcmt-check -target i386-apple-darwin9 -### %t.o 2> %t.log -// RUN: FileCheck -check-prefix=LINK %s < %t.log -// RUN: %clang -ccc-arcmt-migrate /foo/bar -target i386-apple-darwin9 -### %t.o 2> %t.log -// RUN: FileCheck -check-prefix=LINK %s < %t.log - -// LINK-NOT: {{ld(.exe)?"}} -// LINK: {{touch(.exe)?"}} - -// RUN: %clang -### -ccc-arcmt-migrate /foo/bar -fsyntax-only -fno-objc-arc %s 2>&1 | FileCheck -check-prefix=CHECK-NOARC %s -// CHECK-NOARC-NOT: argument unused during compilation diff --git clang/test/ARCMT/init.m clang/test/ARCMT/init.m deleted file mode 100644 index b1f127e54fd1..000000000000 --- clang/test/ARCMT/init.m +++ /dev/null @@ -1,39 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#define nil (void *)0 - -@interface NSObject --init; -@end - -@interface A : NSObject --init; --init2; --foo; -+alloc; -@end - -@implementation A --(id) init { - [self init]; - id a; - [a init]; - a = [[A alloc] init]; - - return self; -} - --(id) init2 { - [super init]; - return self; -} - --(id) foo { - [self init]; - [super init]; - - return self; -} -@end diff --git clang/test/ARCMT/init.m.result clang/test/ARCMT/init.m.result deleted file mode 100644 index d550dedb1dc1..000000000000 --- clang/test/ARCMT/init.m.result +++ /dev/null @@ -1,39 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#define nil (void *)0 - -@interface NSObject --init; -@end - -@interface A : NSObject --init; --init2; --foo; -+alloc; -@end - -@implementation A --(id) init { - if (!(self = [self init])) return nil; - id a; - [a init]; - a = [[A alloc] init]; - - return self; -} - --(id) init2 { - if (!(self = [super init])) return nil; - return self; -} - --(id) foo { - [self init]; - [super init]; - - return self; -} -@end diff --git clang/test/ARCMT/lit.local.cfg clang/test/ARCMT/lit.local.cfg deleted file mode 100644 index e9b04164d69d..000000000000 --- clang/test/ARCMT/lit.local.cfg +++ /dev/null @@ -1,2 +0,0 @@ -if not config.root.clang_arcmt: - config.unsupported = True diff --git clang/test/ARCMT/migrate-emit-errors.m clang/test/ARCMT/migrate-emit-errors.m deleted file mode 100644 index 3e33acf75a59..000000000000 --- clang/test/ARCMT/migrate-emit-errors.m +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -arcmt-action=migrate -mt-migrate-directory %t -arcmt-migrate-emit-errors %s 2>&1 | FileCheck %s -// RUN: rm -rf %t - -@protocol NSObject -- (oneway void)release; -@end - -void test(id p) { - [p release]; -} - -// CHECK: error: ARC forbids explicit message send of 'release' diff --git clang/test/ARCMT/migrate-on-pch-and-module.m clang/test/ARCMT/migrate-on-pch-and-module.m deleted file mode 100644 index 42e01ea91a9c..000000000000 --- clang/test/ARCMT/migrate-on-pch-and-module.m +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: rm -rf %t-mcp -// RUN: %clang_cc1 -objcmt-migrate-subscripting -emit-pch -o %t.pch %s -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -F %S/Inputs -fmodules -fimplicit-module-maps -fmodules-cache-path=%t-mcp -w -// RUN: %clang_cc1 -objcmt-migrate-subscripting -include-pch %t.pch %s -migrate -o %t.remap -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -F %S/Inputs -fmodules -fimplicit-module-maps -fmodules-cache-path=%t-mcp -// REQUIRES: x86-registered-target -#ifndef HEADER -#define HEADER - -@import Module; - -#else - -#endif diff --git clang/test/ARCMT/migrate-plist-output.m clang/test/ARCMT/migrate-plist-output.m deleted file mode 100644 index e5710d818ecc..000000000000 --- clang/test/ARCMT/migrate-plist-output.m +++ /dev/null @@ -1,51 +0,0 @@ -// RUN: %clang_cc1 -arcmt-action=migrate -mt-migrate-directory %t.dir -arcmt-migrate-report-output %t.plist %s -// RUN: FileCheck %s -input-file=%t.plist -// RUN: rm -rf %t.dir - -@protocol NSObject -- (oneway void)release; -@end - -void test(id p) { - [p release]; -} - -// CHECK: <?xml version="1.0" encoding="UTF-8"?> -// CHECK: <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> -// CHECK: <plist version="1.0"> -// CHECK: <dict> -// CHECK: <key>files</key> -// CHECK: <array> -// CHECK: </array> -// CHECK: <key>diagnostics</key> -// CHECK: <array> -// CHECK: <dict> -// CHECK: <key>description</key><string>ARC forbids explicit message send of 'release'</string> -// CHECK: <key>category</key><string>ARC Restrictions</string> -// CHECK: <key>type</key><string>error</string> -// CHECK: <key>location</key> -// CHECK: <dict> -// CHECK: <key>line</key><integer>10</integer> -// CHECK: <key>col</key><integer>6</integer> -// CHECK: <key>file</key><integer>0</integer> -// CHECK: </dict> -// CHECK: <key>ranges</key> -// CHECK: <array> -// CHECK: <array> -// CHECK: <dict> -// CHECK: <key>line</key><integer>10</integer> -// CHECK: <key>col</key><integer>4</integer> -// CHECK: <key>file</key><integer>0</integer> -// CHECK: </dict> -// CHECK: <dict> -// CHECK: <key>line</key><integer>10</integer> -// CHECK: <key>col</key><integer>4</integer> -// CHECK: <key>file</key><integer>0</integer> -// CHECK: </dict> -// CHECK: </array> -// CHECK: </array> -// CHECK: </dict> -// CHECK: </array> -// CHECK: </dict> -// CHECK: </plist> - diff --git clang/test/ARCMT/migrate-space-in-path.m clang/test/ARCMT/migrate-space-in-path.m deleted file mode 100644 index 14a464d438f4..000000000000 --- clang/test/ARCMT/migrate-space-in-path.m +++ /dev/null @@ -1,5 +0,0 @@ -// RUN: rm -rf %t.migrate -// RUN: %clang_cc1 -arcmt-action=migrate -mt-migrate-directory %t.migrate %S/Inputs/"with space"/test1.m.in -x objective-c -// RUN: %clang_cc1 -arcmt-action=migrate -mt-migrate-directory %t.migrate %S/Inputs/"with space"/test2.m.in -x objective-c -// RUN: c-arcmt-test -mt-migrate-directory %t.migrate | arcmt-test -verify-transformed-files %S/Inputs/"with space"/test1.m.in.result %S/Inputs/"with space"/test2.m.in.result %S/Inputs/"with space"/test.h.result -// RUN: rm -rf %t.migrate diff --git clang/test/ARCMT/migrate-with-pch.m clang/test/ARCMT/migrate-with-pch.m deleted file mode 100644 index d8e261be13d8..000000000000 --- clang/test/ARCMT/migrate-with-pch.m +++ /dev/null @@ -1,6 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -x objective-c %S/Common.h -emit-pch -o %t.pch -// RUN: %clang_cc1 -arcmt-action=migrate -mt-migrate-directory %t %S/Inputs/test1.m.in -x objective-c -include-pch %t.pch -// RUN: %clang_cc1 -arcmt-action=migrate -mt-migrate-directory %t %S/Inputs/test2.m.in -x objective-c -include-pch %t.pch -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %S/Inputs/test1.m.in.result %S/Inputs/test2.m.in.result %S/Inputs/test.h.result -// RUN: rm -rf %t diff --git clang/test/ARCMT/migrate.m clang/test/ARCMT/migrate.m deleted file mode 100644 index bc819df1c8a1..000000000000 --- clang/test/ARCMT/migrate.m +++ /dev/null @@ -1,5 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -arcmt-action=migrate -mt-migrate-directory %t %S/Inputs/test1.m.in -x objective-c -// RUN: %clang_cc1 -arcmt-action=migrate -mt-migrate-directory %t %S/Inputs/test2.m.in -x objective-c -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %S/Inputs/test1.m.in.result %S/Inputs/test2.m.in.result %S/Inputs/test.h.result -// RUN: rm -rf %t diff --git clang/test/ARCMT/no-canceling-bridge-to-bridge-cast.m clang/test/ARCMT/no-canceling-bridge-to-bridge-cast.m deleted file mode 100644 index be4939495152..000000000000 --- clang/test/ARCMT/no-canceling-bridge-to-bridge-cast.m +++ /dev/null @@ -1,41 +0,0 @@ -// RUN: %clang_cc1 -arcmt-action=check -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -verify %s -typedef const void * CFTypeRef; -CFTypeRef CFBridgingRetain(id X); -id CFBridgingRelease(CFTypeRef); - -extern -CFTypeRef CFRetain(CFTypeRef cf); - -@interface INTF -{ - void *cf_format; - id objc_format; -} -@end - -@interface NSString -+ (id)stringWithFormat:(NSString *)format; -@end - -@implementation INTF -- (void) Meth { - NSString *result; - - result = (id) CFRetain([NSString stringWithFormat:@"PBXLoopMode"]); // expected-error {{cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast}} \ - // expected-note {{use __bridge to convert directly (no change in ownership)}} \ - // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}} - - result = (id) CFRetain((id)((objc_format))); // expected-error {{cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast}} \ - // expected-note {{use __bridge to convert directly (no change in ownership)}} \ - // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}} - - result = (id) CFRetain((id)((cf_format))); // expected-error {{cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast}} \ - // expected-note {{use __bridge to convert directly (no change in ownership)}} \ - // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}} - - result = (id) CFRetain((CFTypeRef)((objc_format))); - - result = (id) CFRetain(cf_format); // OK -} -@end - diff --git clang/test/ARCMT/nonobjc-to-objc-cast-2.m clang/test/ARCMT/nonobjc-to-objc-cast-2.m deleted file mode 100644 index 391c636906d5..000000000000 --- clang/test/ARCMT/nonobjc-to-objc-cast-2.m +++ /dev/null @@ -1,63 +0,0 @@ -// RUN: %clang_cc1 -arcmt-action=check -verify -triple x86_64-apple-darwin10 %s - -#include "Common.h" - -typedef const struct __CFString * CFStringRef; -typedef const void * CFTypeRef; -CFTypeRef CFBridgingRetain(id X); -id CFBridgingRelease(CFTypeRef); - -struct StrS { - CFStringRef sref_member; -}; - -@interface NSString : NSObject { - CFStringRef sref; - struct StrS *strS; -} --(id)string; --(id)newString; -@end - -@implementation NSString --(id)string { - if (0) - return sref; - else - return strS->sref_member; -} --(id)newString { - return sref; // expected-error {{implicit conversion of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'id' requires a bridged cast}} \ - // expected-note{{use __bridge to convert directly (no change in ownership)}} \ - // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}} -} -@end - -void f(BOOL b) { - CFStringRef cfstr; - NSString *str = (NSString *)cfstr; // expected-error {{cast of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \ - // expected-note{{use __bridge to convert directly (no change in ownership)}} \ - // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}} - void *vp = str; // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRetain call}} expected-note {{use __bridge}} -} - -void f2(NSString *s) { - CFStringRef ref; - ref = [(CFStringRef)[s string] retain]; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef' (aka 'const struct __CFString *') requires a bridged cast}} \ - // expected-error {{bad receiver type 'CFStringRef' (aka 'const struct __CFString *')}} \ - // expected-note{{use __bridge to convert directly (no change in ownership)}} \ - // expected-note{{use CFBridgingRetain call to make an ARC object available as a +1 'CFStringRef' (aka 'const struct __CFString *')}} -} - -CFStringRef f3(void) { - return (CFStringRef)[[[NSString alloc] init] autorelease]; // expected-error {{it is not safe to cast to 'CFStringRef' the result of 'autorelease' message; a __bridge cast may result in a pointer to a destroyed object and a __bridge_retained may leak the object}} \ - // expected-note {{remove the cast and change return type of function to 'NSString *' to have the object automatically autoreleased}} -} - -extern void NSLog(NSString *format, ...); - -void f4(NSString *s) { - NSLog(@"%@", (CFStringRef)s); // expected-error {{cast of Objective-C pointer type 'NSString *' to C pointer type 'CFStringRef' (aka 'const struct __CFString *') requires a bridged cast}} \ - // expected-note{{use __bridge to convert directly (no change in ownership)}} \ - // expected-note{{use CFBridgingRetain call to make an ARC object available as a +1 'CFStringRef' (aka 'const struct __CFString *')}} -} diff --git clang/test/ARCMT/nonobjc-to-objc-cast.m clang/test/ARCMT/nonobjc-to-objc-cast.m deleted file mode 100644 index 7913661787e5..000000000000 --- clang/test/ARCMT/nonobjc-to-objc-cast.m +++ /dev/null @@ -1,83 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -typedef const struct __CFString * CFStringRef; -extern const CFStringRef kUTTypePlainText; -extern const CFStringRef kUTTypeRTF; -extern CFStringRef kNonConst; - -typedef const struct __CFAllocator * CFAllocatorRef; -typedef const struct __CFUUID * CFUUIDRef; - -extern const CFAllocatorRef kCFAllocatorDefault; - -extern CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid); - -struct StrS { - CFStringRef sref_member; -}; - -@interface NSString : NSObject { - CFStringRef sref; - struct StrS *strS; -} --(id)string; --(id)newString; -@end - -void f(BOOL b, id p) { - NSString *str = (NSString *)kUTTypePlainText; // no change - str = b ? kUTTypeRTF : kUTTypePlainText; // no change - str = (NSString *)(b ? kUTTypeRTF : kUTTypePlainText); // no change - str = (NSString *)p; // no change. - - str = (NSString *)kNonConst; - str = b ? kUTTypeRTF : kNonConst; - str = (NSString *)(b ? kUTTypeRTF : kNonConst); - - CFUUIDRef _uuid; - NSString *_uuidString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid); - _uuidString = [(NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid) autorelease]; - _uuidString = CFRetain(_uuid); -} - -@implementation NSString (StrExt) -- (NSString *)stringEscapedAsURI { - CFStringRef str = (CFStringRef)self; - CFStringRef str2 = self; - return self; -} -@end - -@implementation NSString --(id)string { - if (0) - return sref; - else - return strS->sref_member; -} --(id)newString { return 0; } -@end - -extern void consumeParam(CFStringRef CF_CONSUMED p); - -void f2(NSString *s) { - CFStringRef ref = [s string]; - ref = (CFStringRef)[s string]; - ref = s.string; - ref = [NSString new]; - ref = [s newString]; - ref = (CFStringRef)[NSString new]; - ref = [[NSString alloc] init]; - ref = [[s string] retain]; - ref = CFRetain((CFStringRef)[s string]); - ref = CFRetain([s string]); - ref = CFRetain(s); - ref = [s retain]; - - consumeParam((CFStringRef)s); - consumeParam(s); -} diff --git clang/test/ARCMT/nonobjc-to-objc-cast.m.result clang/test/ARCMT/nonobjc-to-objc-cast.m.result deleted file mode 100644 index 8f3092f8786d..000000000000 --- clang/test/ARCMT/nonobjc-to-objc-cast.m.result +++ /dev/null @@ -1,83 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -typedef const struct __CFString * CFStringRef; -extern const CFStringRef kUTTypePlainText; -extern const CFStringRef kUTTypeRTF; -extern CFStringRef kNonConst; - -typedef const struct __CFAllocator * CFAllocatorRef; -typedef const struct __CFUUID * CFUUIDRef; - -extern const CFAllocatorRef kCFAllocatorDefault; - -extern CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid); - -struct StrS { - CFStringRef sref_member; -}; - -@interface NSString : NSObject { - CFStringRef sref; - struct StrS *strS; -} --(id)string; --(id)newString; -@end - -void f(BOOL b, id p) { - NSString *str = (NSString *)kUTTypePlainText; // no change - str = b ? kUTTypeRTF : kUTTypePlainText; // no change - str = (NSString *)(b ? kUTTypeRTF : kUTTypePlainText); // no change - str = (NSString *)p; // no change. - - str = (__bridge NSString *)kNonConst; - str = (__bridge NSString *)(b ? kUTTypeRTF : kNonConst); - str = (__bridge NSString *)(b ? kUTTypeRTF : kNonConst); - - CFUUIDRef _uuid; - NSString *_uuidString = (NSString *)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, _uuid)); - _uuidString = (NSString *)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, _uuid)); - _uuidString = CFBridgingRelease(CFRetain(_uuid)); -} - -@implementation NSString (StrExt) -- (NSString *)stringEscapedAsURI { - CFStringRef str = (__bridge CFStringRef)self; - CFStringRef str2 = (__bridge CFStringRef)(self); - return self; -} -@end - -@implementation NSString --(id)string { - if (0) - return (__bridge id)(sref); - else - return (__bridge id)(strS->sref_member); -} --(id)newString { return 0; } -@end - -extern void consumeParam(CFStringRef CF_CONSUMED p); - -void f2(NSString *s) { - CFStringRef ref = (__bridge CFStringRef)([s string]); - ref = (__bridge CFStringRef)[s string]; - ref = (__bridge CFStringRef)(s.string); - ref = CFBridgingRetain([NSString new]); - ref = CFBridgingRetain([s newString]); - ref = (CFStringRef)CFBridgingRetain([NSString new]); - ref = CFBridgingRetain([[NSString alloc] init]); - ref = CFBridgingRetain([s string]); - ref = (CFStringRef)CFBridgingRetain([s string]); - ref = CFBridgingRetain([s string]); - ref = CFBridgingRetain(s); - ref = CFBridgingRetain(s); - - consumeParam((CFStringRef)CFBridgingRetain(s)); - consumeParam(CFBridgingRetain(s)); -} diff --git clang/test/ARCMT/objcmt-arc-cf-annotations.m clang/test/ARCMT/objcmt-arc-cf-annotations.m deleted file mode 100644 index 47c83ac9e3dd..000000000000 --- clang/test/ARCMT/objcmt-arc-cf-annotations.m +++ /dev/null @@ -1,2017 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fblocks -objcmt-migrate-annotation -objcmt-migrate-instancetype -objcmt-migrate-readwrite-property -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result - -#ifndef CF_IMPLICIT_BRIDGING_ENABLED -#if __has_feature(arc_cf_code_audited) -#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin") -#else -#define CF_IMPLICIT_BRIDGING_ENABLED -#endif -#endif - -#ifndef CF_IMPLICIT_BRIDGING_DISABLED -#if __has_feature(arc_cf_code_audited) -#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end") -#else -#define CF_IMPLICIT_BRIDGING_DISABLED -#endif -#endif - -#if __has_feature(attribute_ns_returns_retained) -#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) -#endif -#if __has_feature(attribute_cf_returns_retained) -#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) -#endif -#if __has_feature(attribute_ns_returns_not_retained) -#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained)) -#endif -#if __has_feature(attribute_cf_returns_not_retained) -#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained)) -#endif -#if __has_feature(attribute_ns_consumes_self) -#define NS_CONSUMES_SELF __attribute__((ns_consumes_self)) -#endif -#if __has_feature(attribute_ns_consumed) -#define NS_CONSUMED __attribute__((ns_consumed)) -#endif -#if __has_feature(attribute_cf_consumed) -#define CF_CONSUMED __attribute__((cf_consumed)) -#endif -#if __has_attribute(ns_returns_autoreleased) -#define NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased)) -#endif - -//===----------------------------------------------------------------------===// -// The following code is reduced using delta-debugging from Mac OS X headers: -// -// #include <Cocoa/Cocoa.h> -// #include <CoreFoundation/CoreFoundation.h> -// #include <DiskArbitration/DiskArbitration.h> -// #include <QuartzCore/QuartzCore.h> -// #include <Quartz/Quartz.h> -// #include <IOKit/IOKitLib.h> -// -// It includes the basic definitions for the test cases below. -//===----------------------------------------------------------------------===// - -typedef unsigned int __darwin_natural_t; -typedef unsigned long uintptr_t; -typedef unsigned int uint32_t; -typedef unsigned long long uint64_t; -typedef unsigned int UInt32; -typedef signed long CFIndex; -typedef CFIndex CFByteOrder; -typedef struct { - CFIndex location; - CFIndex length; -} CFRange; -static __inline__ __attribute__((always_inline)) CFRange CFRangeMake(CFIndex loc, CFIndex len) { - CFRange range; - range.location = loc; - range.length = len; - return range; -} -typedef const void * CFTypeRef; -typedef const struct __CFString * CFStringRef; -typedef const struct __CFAllocator * CFAllocatorRef; -extern const CFAllocatorRef kCFAllocatorDefault; -extern CFTypeRef CFRetain(CFTypeRef cf); -extern void CFRelease(CFTypeRef cf); -extern CFTypeRef CFAutorelease(CFTypeRef cf); -extern CFTypeRef CFMakeCollectable(CFTypeRef cf); -typedef struct { -} -CFArrayCallBacks; -extern const CFArrayCallBacks kCFTypeArrayCallBacks; -typedef const struct __CFArray * CFArrayRef; -typedef struct __CFArray * CFMutableArrayRef; -extern CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFArrayCallBacks *callBacks); -extern const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx); -extern void CFArrayAppendValue(CFMutableArrayRef theArray, const void *value); -typedef struct { -} -CFDictionaryKeyCallBacks; -extern const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks; -typedef struct { -} -CFDictionaryValueCallBacks; -extern const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks; -typedef const struct __CFDictionary * CFDictionaryRef; -typedef struct __CFDictionary * CFMutableDictionaryRef; -extern CFMutableDictionaryRef CFDictionaryCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks); -typedef UInt32 CFStringEncoding; -enum { -kCFStringEncodingMacRoman = 0, kCFStringEncodingWindowsLatin1 = 0x0500, kCFStringEncodingISOLatin1 = 0x0201, kCFStringEncodingNextStepLatin = 0x0B01, kCFStringEncodingASCII = 0x0600, kCFStringEncodingUnicode = 0x0100, kCFStringEncodingUTF8 = 0x08000100, kCFStringEncodingNonLossyASCII = 0x0BFF , kCFStringEncodingUTF16 = 0x0100, kCFStringEncodingUTF16BE = 0x10000100, kCFStringEncodingUTF16LE = 0x14000100, kCFStringEncodingUTF32 = 0x0c000100, kCFStringEncodingUTF32BE = 0x18000100, kCFStringEncodingUTF32LE = 0x1c000100 }; -extern CFStringRef CFStringCreateWithCString(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding); -typedef double CFTimeInterval; -typedef CFTimeInterval CFAbsoluteTime; -extern CFAbsoluteTime CFAbsoluteTimeGetCurrent(void); -typedef const struct __CFDate * CFDateRef; -extern CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at); -extern CFAbsoluteTime CFDateGetAbsoluteTime(CFDateRef theDate); -typedef __darwin_natural_t natural_t; -typedef natural_t mach_port_name_t; -typedef mach_port_name_t mach_port_t; -typedef int kern_return_t; -typedef kern_return_t mach_error_t; -enum { -kCFNumberSInt8Type = 1, kCFNumberSInt16Type = 2, kCFNumberSInt32Type = 3, kCFNumberSInt64Type = 4, kCFNumberFloat32Type = 5, kCFNumberFloat64Type = 6, kCFNumberCharType = 7, kCFNumberShortType = 8, kCFNumberIntType = 9, kCFNumberLongType = 10, kCFNumberLongLongType = 11, kCFNumberFloatType = 12, kCFNumberDoubleType = 13, kCFNumberCFIndexType = 14, kCFNumberNSIntegerType = 15, kCFNumberCGFloatType = 16, kCFNumberMaxType = 16 }; -typedef CFIndex CFNumberType; -typedef const struct __CFNumber * CFNumberRef; -extern CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr); -typedef const struct __CFAttributedString *CFAttributedStringRef; -typedef struct __CFAttributedString *CFMutableAttributedStringRef; -extern CFAttributedStringRef CFAttributedStringCreate(CFAllocatorRef alloc, CFStringRef str, CFDictionaryRef attributes) ; -extern CFMutableAttributedStringRef CFAttributedStringCreateMutableCopy(CFAllocatorRef alloc, CFIndex maxLength, CFAttributedStringRef aStr) ; -extern void CFAttributedStringSetAttribute(CFMutableAttributedStringRef aStr, CFRange range, CFStringRef attrName, CFTypeRef value) ; -typedef signed char BOOL; -typedef unsigned long NSUInteger; -@class NSString, Protocol; -extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2))); -typedef struct _NSZone NSZone; -@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; -@protocol NSObject -- (BOOL)isEqual:(id)object; -- (id)retain; -- (oneway void)release; -- (id)autorelease; -- (NSString *)description; -- (id)init; -@end -@protocol NSCopying -- (id)copyWithZone:(NSZone *)zone; -@end -@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; -@end -@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; -@end -@interface NSObject <NSObject> {} -+ (id)allocWithZone:(NSZone *)zone; -+ (id)alloc; -+ (id)new; -- (void)dealloc; -@end -@interface NSObject (NSCoderMethods) -- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder; -@end -extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); -typedef struct { -} -NSFastEnumerationState; -@protocol NSFastEnumeration -- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len; -@end -@class NSString, NSDictionary; -@interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value; -@end -@interface NSNumber : NSValue -- (char)charValue; -- (id)initWithInt:(int)value; -+ (NSNumber *)numberWithInt:(int)value; -@end -@class NSString; -@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> -- (NSUInteger)count; -- (id)initWithObjects:(const id [])objects count:(NSUInteger)cnt; -+ (id)arrayWithObject:(id)anObject; -+ (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt; -+ (id)arrayWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1))); -- (id)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1))); -- (id)initWithArray:(NSArray *)array; -@end @interface NSArray (NSArrayCreation) + (id)array; -@end @interface NSAutoreleasePool : NSObject { -} -- (void)drain; -@end extern NSString * const NSBundleDidLoadNotification; -typedef double NSTimeInterval; -@interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate; -@end typedef unsigned short unichar; -@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding> -- (NSUInteger)length; -- (NSString *)stringByAppendingString:(NSString *)aString; -- ( const char *)UTF8String; -- (id)initWithUTF8String:(const char *)nullTerminatedCString; -+ (id)stringWithUTF8String:(const char *)nullTerminatedCString; -@end @class NSString, NSURL, NSError; -@interface NSData : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length; -+ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length; -+ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b; -@end @class NSLocale, NSDate, NSCalendar, NSTimeZone, NSError, NSArray, NSMutableDictionary; -@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> -- (NSUInteger)count; -+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; -+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt; -@end -@interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey; -- (void)setObject:(id)anObject forKey:(id)aKey; -@end @interface NSMutableDictionary (NSMutableDictionaryCreation) + (id)dictionaryWithCapacity:(NSUInteger)numItems; -@end typedef double CGFloat; -struct CGSize { -}; -typedef struct CGSize CGSize; -struct CGRect { -}; -typedef struct CGRect CGRect; -typedef mach_port_t io_object_t; -typedef char io_name_t[128]; -typedef io_object_t io_iterator_t; -typedef io_object_t io_service_t; -typedef struct IONotificationPort * IONotificationPortRef; -typedef void (*IOServiceMatchingCallback)( void * refcon, io_iterator_t iterator ); -io_service_t IOServiceGetMatchingService( mach_port_t mainPort, CFDictionaryRef matching ); -kern_return_t IOServiceGetMatchingServices( mach_port_t mainPort, CFDictionaryRef matching, io_iterator_t * existing ); -kern_return_t IOServiceAddNotification( mach_port_t mainPort, const io_name_t notificationType, CFDictionaryRef matching, mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) __attribute__((deprecated)); // expected-note {{'IOServiceAddNotification' declared here}} -kern_return_t IOServiceAddMatchingNotification( IONotificationPortRef notifyPort, const io_name_t notificationType, CFDictionaryRef matching, IOServiceMatchingCallback callback, void * refCon, io_iterator_t * notification ); -CFMutableDictionaryRef IOServiceMatching( const char * name ); -CFMutableDictionaryRef IOServiceNameMatching( const char * name ); -CFMutableDictionaryRef IOBSDNameMatching( mach_port_t mainPort, uint32_t options, const char * bsdName ); -CFMutableDictionaryRef IOOpenFirmwarePathMatching( mach_port_t mainPort, uint32_t options, const char * path ); -CFMutableDictionaryRef IORegistryEntryIDMatching( uint64_t entryID ); -typedef struct __DASession * DASessionRef; -extern DASessionRef DASessionCreate( CFAllocatorRef allocator ); -typedef struct __DADisk * DADiskRef; -extern DADiskRef DADiskCreateFromBSDName( CFAllocatorRef allocator, DASessionRef session, const char * name ); -extern DADiskRef DADiskCreateFromIOMedia( CFAllocatorRef allocator, DASessionRef session, io_service_t media ); -extern CFDictionaryRef DADiskCopyDescription( DADiskRef disk ); -extern DADiskRef DADiskCopyWholeDisk( DADiskRef disk ); -@interface NSTask : NSObject - (id)init; -@end typedef struct CGColorSpace *CGColorSpaceRef; -typedef struct CGImage *CGImageRef; -typedef struct CGLayer *CGLayerRef; -@interface NSResponder : NSObject <NSCoding> { -} -@end @protocol NSAnimatablePropertyContainer - (id)animator; -@end extern NSString *NSAnimationTriggerOrderIn ; -@interface NSView : NSResponder <NSAnimatablePropertyContainer> { -} -@end @protocol NSValidatedUserInterfaceItem - (SEL)action; -@end @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem; -@end @class NSDate, NSDictionary, NSError, NSException, NSNotification; -@class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError; -@interface NSApplication : NSResponder <NSUserInterfaceValidations> { -} -- (void)beginSheet:(NSWindow *)sheet modalForWindow:(NSWindow *)docWindow modalDelegate:(id)modalDelegate didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo; -@end enum { -NSTerminateCancel = 0, NSTerminateNow = 1, NSTerminateLater = 2 }; -typedef NSUInteger NSApplicationTerminateReply; -@protocol NSApplicationDelegate <NSObject> @optional - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; -@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView, NSTextView; -@interface NSCell : NSObject <NSCopying, NSCoding> { -} -@end -typedef struct { -} -CVTimeStamp; -@interface CIImage : NSObject <NSCoding, NSCopying> { -} -typedef int CIFormat; -@end enum { -kDAReturnSuccess = 0, kDAReturnError = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x01, kDAReturnBusy = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x02, kDAReturnBadArgument = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x03, kDAReturnExclusiveAccess = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x04, kDAReturnNoResources = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x05, kDAReturnNotFound = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x06, kDAReturnNotMounted = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x07, kDAReturnNotPermitted = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x08, kDAReturnNotPrivileged = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x09, kDAReturnNotReady = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0A, kDAReturnNotWritable = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0B, kDAReturnUnsupported = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0C }; -typedef mach_error_t DAReturn; -typedef const struct __DADissenter * DADissenterRef; -extern DADissenterRef DADissenterCreate( CFAllocatorRef allocator, DAReturn status, CFStringRef string ); -@interface CIContext: NSObject { -} -- (CGImageRef)createCGImage:(CIImage *)im fromRect:(CGRect)r; -- (CGImageRef)createCGImage:(CIImage *)im fromRect:(CGRect)r format:(CIFormat)f colorSpace:(CGColorSpaceRef)cs; -- (CGLayerRef)createCGLayerWithSize:(CGSize)size info:(CFDictionaryRef)d; -@end extern NSString* const QCRendererEventKey; -@protocol QCCompositionRenderer - (NSDictionary*) attributes; -@end @interface QCRenderer : NSObject <QCCompositionRenderer> { -} -- (id) createSnapshotImageOfType:(NSString*)type; -@end extern NSString* const QCViewDidStartRenderingNotification; -@interface QCView : NSView <QCCompositionRenderer> { -} -- (id) createSnapshotImageOfType:(NSString*)type; -@end enum { -ICEXIFOrientation1 = 1, ICEXIFOrientation2 = 2, ICEXIFOrientation3 = 3, ICEXIFOrientation4 = 4, ICEXIFOrientation5 = 5, ICEXIFOrientation6 = 6, ICEXIFOrientation7 = 7, ICEXIFOrientation8 = 8, }; -@class ICDevice; -@protocol ICDeviceDelegate <NSObject> @required - (void)didRemoveDevice:(ICDevice*)device; -@end extern NSString *const ICScannerStatusWarmingUp; -@class ICScannerDevice; -@protocol ICScannerDeviceDelegate <ICDeviceDelegate> @optional - (void)scannerDeviceDidBecomeAvailable:(ICScannerDevice*)scanner; -@end - -typedef long unsigned int __darwin_size_t; -typedef __darwin_size_t size_t; -typedef unsigned long CFTypeID; -struct CGPoint { - CGFloat x; - CGFloat y; -}; -typedef struct CGPoint CGPoint; -typedef struct CGGradient *CGGradientRef; -typedef uint32_t CGGradientDrawingOptions; -extern CFTypeID CGGradientGetTypeID(void); -extern CGGradientRef CGGradientCreateWithColorComponents(CGColorSpaceRef - space, const CGFloat components[], const CGFloat locations[], size_t count); -extern CGGradientRef CGGradientCreateWithColors(CGColorSpaceRef space, - CFArrayRef colors, const CGFloat locations[]); -extern CGGradientRef CGGradientRetain(CGGradientRef gradient); -extern void CGGradientRelease(CGGradientRef gradient); -typedef struct CGContext *CGContextRef; -extern void CGContextDrawLinearGradient(CGContextRef context, - CGGradientRef gradient, CGPoint startPoint, CGPoint endPoint, - CGGradientDrawingOptions options); -extern CGColorSpaceRef CGColorSpaceCreateDeviceRGB(void); - -@interface NSMutableArray : NSObject -- (void)addObject:(id)object; -+ (id)array; -@end - -// This is how NSMakeCollectable is declared in the OS X 10.8 headers. -id NSMakeCollectable(CFTypeRef __attribute__((cf_consumed))) __attribute__((ns_returns_retained)); - -typedef const struct __CFUUID * CFUUIDRef; - -extern -void *CFPlugInInstanceCreate(CFAllocatorRef allocator, CFUUIDRef factoryUUID, CFUUIDRef typeUUID); - -//===----------------------------------------------------------------------===// -// Test cases. -//===----------------------------------------------------------------------===// - -CFAbsoluteTime f1(void) { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(0, t); - CFRetain(date); - CFRelease(date); - CFDateGetAbsoluteTime(date); // no-warning - CFRelease(date); - t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released}} - return t; -} - -CFAbsoluteTime f2(void) { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(0, t); - [((NSDate*) date) retain]; - CFRelease(date); - CFDateGetAbsoluteTime(date); // no-warning - [((NSDate*) date) release]; - t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released}} - return t; -} - - -NSDate* global_x; - -// Test to see if we suppress an error when we store the pointer -// to a global. - -CFAbsoluteTime f3(void) { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(0, t); - [((NSDate*) date) retain]; - CFRelease(date); - CFDateGetAbsoluteTime(date); // no-warning - global_x = (NSDate*) date; - [((NSDate*) date) release]; - t = CFDateGetAbsoluteTime(date); // no-warning - return t; -} - -//--------------------------------------------------------------------------- -// Test case 'f4' differs for region store and basic store. See -// retain-release-region-store.m and retain-release-basic-store.m. -//--------------------------------------------------------------------------- - -// Test a leak. - -CFAbsoluteTime f5(int x) { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(0, t); // expected-warning{{leak}} - - if (x) - CFRelease(date); - - return t; -} - -// Test a leak involving the return. - -CFDateRef f6(int x) { - CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // expected-warning{{leak}} - CFRetain(date); - return date; -} - -// Test a leak involving an overwrite. - -CFDateRef f7(void) { - CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); //expected-warning{{leak}} - CFRetain(date); - date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // expected-warning {{leak}} - return date; -} - -// Generalization of Create rule. MyDateCreate returns a CFXXXTypeRef, and -// has the word create. -CFDateRef MyDateCreate(void); - -CFDateRef f8(void) { - CFDateRef date = MyDateCreate(); // expected-warning{{leak}} - CFRetain(date); - return date; -} - -__attribute__((cf_returns_retained)) CFDateRef f9(void) { - CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // no-warning - int *p = 0; - // When allocations fail, CFDateCreate can return null. - if (!date) *p = 1; // expected-warning{{null}} - return date; -} - -// Handle DiskArbitration API: -// -// http://developer.apple.com/DOCUMENTATION/DARWIN/Reference/DiscArbitrationFramework/ -// -void f10(io_service_t media, DADiskRef d, CFStringRef s) { - DADiskRef disk = DADiskCreateFromBSDName(kCFAllocatorDefault, 0, "hello"); // expected-warning{{leak}} - if (disk) NSLog(@"ok"); - - disk = DADiskCreateFromIOMedia(kCFAllocatorDefault, 0, media); // expected-warning{{leak}} - if (disk) NSLog(@"ok"); - - CFDictionaryRef dict = DADiskCopyDescription(d); // expected-warning{{leak}} - if (dict) NSLog(@"ok"); - - disk = DADiskCopyWholeDisk(d); // expected-warning{{leak}} - if (disk) NSLog(@"ok"); - - DADissenterRef dissenter = DADissenterCreate(kCFAllocatorDefault, // expected-warning{{leak}} - kDAReturnSuccess, s); - if (dissenter) NSLog(@"ok"); - - DASessionRef session = DASessionCreate(kCFAllocatorDefault); // expected-warning{{leak}} - if (session) NSLog(@"ok"); -} - -// Test retain/release checker with CFString and CFMutableArray. -void f11(void) { - // Create the array. - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); - - // Create a string. - CFStringRef s1 = CFStringCreateWithCString(0, "hello world", - kCFStringEncodingUTF8); - - // Add the string to the array. - CFArrayAppendValue(A, s1); - - // Decrement the reference count. - CFRelease(s1); // no-warning - - // Get the string. We don't own it. - s1 = (CFStringRef) CFArrayGetValueAtIndex(A, 0); - - // Release the array. - CFRelease(A); // no-warning - - // Release the string. This is a bug. - CFRelease(s1); // expected-warning{{Incorrect decrement of the reference count}} -} - -// PR 3337: Handle functions declared using typedefs. -typedef CFTypeRef CREATEFUN(void); -CFTypeRef MyCreateFun(void); - -void f12(void) { - CFTypeRef o = MyCreateFun(); // expected-warning {{leak}} -} - -void f13_autorelease(void) { - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning - [(id) A autorelease]; // no-warning -} - -void f13_autorelease_b(void) { - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); - [(id) A autorelease]; - [(id) A autorelease]; -} // expected-warning{{Object autoreleased too many times}} - -CFMutableArrayRef f13_autorelease_c(void) { - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); - [(id) A autorelease]; - [(id) A autorelease]; - return A; // expected-warning{{Object autoreleased too many times}} -} - -CFMutableArrayRef f13_autorelease_d(void) { - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); - [(id) A autorelease]; - [(id) A autorelease]; - CFMutableArrayRef B = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{Object autoreleased too many times}} - CFRelease(B); // no-warning - while (1) {} -} - - -// This case exercises the logic where the leak site is the same as the allocation site. -void f14_leakimmediately(void) { - CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{leak}} -} - -// Test that we track an allocated object beyond the point where the *name* -// of the variable storing the reference is no longer live. -void f15(void) { - // Create the array. - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); - CFMutableArrayRef *B = &A; - // At this point, the name 'A' is no longer live. - CFRelease(*B); // no-warning -} - -// Test when we pass NULL to CFRetain/CFRelease/CFMakeCollectable/CFAutorelease. -void f16(int x, CFTypeRef p) { - if (p) - return; - - switch (x) { - case 0: - CFRelease(p); - break; - case 1: - CFRetain(p); - break; - case 2: - CFMakeCollectable(p); - break; - case 3: - CFAutorelease(p); - break; - default: - break; - } -} - -// Test that an object is non-null after CFRetain/CFRelease/CFMakeCollectable/CFAutorelease. -void f17(int x, CFTypeRef p) { - switch (x) { - case 0: - CFRelease(p); - if (!p) - CFRelease(0); // no-warning - break; - case 1: - CFRetain(p); - if (!p) - CFRetain(0); // no-warning - break; - case 2: - CFMakeCollectable(p); - if (!p) - CFMakeCollectable(0); // no-warning - break; - case 3: - CFAutorelease(p); - if (!p) - CFAutorelease(0); // no-warning - break; - default: - break; - } -} - -// Test basic tracking of ivars associated with 'self'. For the retain/release -// checker we currently do not want to flag leaks associated with stores -// of tracked objects to ivars. -@interface SelfIvarTest : NSObject { - id myObj; -} -- (void)test_self_tracking; -@end - -@implementation SelfIvarTest -- (void)test_self_tracking { - myObj = (id) CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} -@end - -// Test return of non-owned objects in contexts where an owned object -// is expected. -@interface TestReturnNotOwnedWhenExpectedOwned -- (NSString*)newString; -@end - -@implementation TestReturnNotOwnedWhenExpectedOwned -- (NSString*)newString { - NSString *s = [NSString stringWithUTF8String:"hello"]; - return s; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} -} -@end - -int isFoo(char c); - -static void rdar_6659160(char *inkind, char *inname) -{ - // We currently expect that [NSObject alloc] cannot fail. This - // will be a toggled flag in the future. It can indeed return null, but - // Cocoa programmers generally aren't expected to reason about out-of-memory - // conditions. - NSString *kind = [[NSString alloc] initWithUTF8String:inkind]; // expected-warning{{leak}} - - // We do allow stringWithUTF8String to fail. This isn't really correct, as - // far as returning 0. In most error conditions it will throw an exception. - // If allocation fails it could return 0, but again this - // isn't expected. - NSString *name = [NSString stringWithUTF8String:inname]; - if(!name) - return; - - const char *kindC = 0; - const char *nameC = 0; - - // In both cases, we cannot reach a point down below where we - // dereference kindC or nameC with either being null. This is because - // we assume that [NSObject alloc] doesn't fail and that we have the guard - // up above. - - if(kind) - kindC = [kind UTF8String]; - if(name) - nameC = [name UTF8String]; - if(!isFoo(kindC[0])) // expected-warning{{null}} - return; - if(!isFoo(nameC[0])) // no-warning - return; - - [kind release]; - [name release]; // expected-warning{{Incorrect decrement of the reference count}} -} - -// PR 3677 - 'allocWithZone' should be treated as following the Cocoa naming -// conventions with respect to 'return'ing ownership. -@interface PR3677: NSObject @end -@implementation PR3677 -+ (id)allocWithZone:(NSZone *)inZone { - return [super allocWithZone:inZone]; // no-warning -} -@end - -// PR 3820 - Reason about calls to -dealloc -void pr3820_DeallocInsteadOfRelease(void) -{ - id foo = [[NSString alloc] init]; // no-warning - [foo dealloc]; - // foo is not leaked, since it has been deallocated. -} - -void pr3820_ReleaseAfterDealloc(void) -{ - id foo = [[NSString alloc] init]; - [foo dealloc]; - [foo release]; // expected-warning{{used after it is release}} - // NSInternalInconsistencyException: message sent to deallocated object -} - -void pr3820_DeallocAfterRelease(void) -{ - NSLog(@"\n\n[%s]", __FUNCTION__); - id foo = [[NSString alloc] init]; - [foo release]; - [foo dealloc]; // expected-warning{{used after it is released}} - // message sent to released object -} - -// The problem here is that 'length' binds to '($0 - 1)' after '--length', but -// SimpleConstraintManager doesn't know how to reason about -// '($0 - 1) > constant'. As a temporary hack, we drop the value of '($0 - 1)' -// and conjure a new symbol. -void rdar6704930(unsigned char *s, unsigned int length) { - NSString* name = 0; - if (s != 0) { - if (length > 0) { - while (length > 0) { - if (*s == ':') { - ++s; - --length; - name = [[NSString alloc] init]; // no-warning - break; - } - ++s; - --length; - } - if ((length == 0) && (name != 0)) { - [name release]; - name = 0; - } - if (length == 0) { // no ':' found -> use it all as name - name = [[NSString alloc] init]; // no-warning - } - } - } - - if (name != 0) { - [name release]; - } -} - -//===----------------------------------------------------------------------===// -// One build of the analyzer accidentally stopped tracking the allocated -// object after the 'retain'. -//===----------------------------------------------------------------------===// - -@interface rdar_6833332 : NSObject <NSApplicationDelegate> { - NSWindow *window; -} -@property (nonatomic, retain) NSWindow *window; -@end - -@implementation rdar_6833332 -@synthesize window; -- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - NSMutableDictionary *dict = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; // expected-warning{{leak}} - - [dict setObject:@"foo" forKey:@"bar"]; - - NSLog(@"%@", dict); -} -- (void)dealloc { - [window release]; - [super dealloc]; -} - -- (void)radar10102244 { - NSMutableDictionary *dict = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; // expected-warning{{leak}} - if (window) - NSLog(@"%@", window); -} -@end - -//===----------------------------------------------------------------------===// -// clang checker fails to catch use-after-release -//===----------------------------------------------------------------------===// -int rdar_6257780_Case1(void) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - NSArray *array = [NSArray array]; - [array release]; // expected-warning{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} - [pool drain]; - return 0; -} - -//===----------------------------------------------------------------------===// -// Analyzer is confused about NSAutoreleasePool -allocWithZone:. -//===----------------------------------------------------------------------===// -void rdar_10640253_autorelease_allocWithZone(void) { - NSAutoreleasePool *pool = [[NSAutoreleasePool allocWithZone:(NSZone*)0] init]; - (void) pool; -} - -//===----------------------------------------------------------------------===// -// Checker should understand new/setObject:/release constructs -//===----------------------------------------------------------------------===// -void rdar_6866843(void) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] init]; - NSArray* array = [[NSArray alloc] init]; - [dictionary setObject:array forKey:@"key"]; - [array release]; - // Using 'array' here should be fine - NSLog(@"array = %@\n", array); // no-warning - // Now the array is released - [dictionary release]; - [pool drain]; -} - - -//===----------------------------------------------------------------------===// -// Classes typedef-ed to CF objects should get the same treatment as CF objects -//===----------------------------------------------------------------------===// -typedef CFTypeRef OtherRef; - -@interface RDar6877235 : NSObject {} -- (CFTypeRef)_copyCFTypeRef; -- (OtherRef)_copyOtherRef; -@end - -@implementation RDar6877235 -- (CFTypeRef)_copyCFTypeRef { - return [[NSString alloc] init]; // no-warning -} -- (OtherRef)_copyOtherRef { - return [[NSString alloc] init]; // no-warning -} -@end - -//===----------------------------------------------------------------------===// -// false positive - init method returns an object owned by caller -//===----------------------------------------------------------------------===// -@interface RDar6320065 : NSObject { - NSString *_foo; -} -- (id)initReturningNewClass; -- (id)_initReturningNewClassBad; -- (id)initReturningNewClassBad2; -@end - -@interface RDar6320065Subclass : RDar6320065 -@end - -@implementation RDar6320065 -- (id)initReturningNewClass { - [self release]; - self = [[RDar6320065Subclass alloc] init]; // no-warning - return self; -} -- (id)_initReturningNewClassBad { - [self release]; - [[RDar6320065Subclass alloc] init]; // expected-warning {{leak}} - return self; -} -- (id)initReturningNewClassBad2 { - [self release]; - self = [[RDar6320065Subclass alloc] init]; - return [self autorelease]; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} -} - -@end - -@implementation RDar6320065Subclass -@end - -int RDar6320065_test(void) { - RDar6320065 *test = [[RDar6320065 alloc] init]; // no-warning - [test release]; - return 0; -} - -//===----------------------------------------------------------------------===// -// -awakeAfterUsingCoder: returns an owned object and claims the receiver -//===----------------------------------------------------------------------===// -@interface RDar7129086 : NSObject {} @end -@implementation RDar7129086 -- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder { - [self release]; // no-warning - return [NSString alloc]; // no-warning -} -@end - -//===----------------------------------------------------------------------===// -// [NSData dataWithBytesNoCopy] does not return a retained object -//===----------------------------------------------------------------------===// -@interface RDar6859457 : NSObject {} -- (NSString*) NoCopyString; -- (NSString*) noCopyString; -@end - -@implementation RDar6859457 -- (NSString*) NoCopyString { return [[NSString alloc] init]; } // expected-warning{{leak}} -- (NSString*) noCopyString { return [[NSString alloc] init]; } // expected-warning{{leak}} -@end - -void test_RDar6859457(RDar6859457 *x, void *bytes, NSUInteger dataLength) { - [x NoCopyString]; // expected-warning{{leak}} - [x noCopyString]; // expected-warning{{leak}} - [NSData dataWithBytesNoCopy:bytes length:dataLength]; // no-warning - [NSData dataWithBytesNoCopy:bytes length:dataLength freeWhenDone:1]; // no-warning -} - -//===----------------------------------------------------------------------===// -// PR 4230 - an autorelease pool is not necessarily leaked during a premature -// return -//===----------------------------------------------------------------------===// - -static void PR4230(void) -{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // no-warning - NSString *object = [[[NSString alloc] init] autorelease]; // no-warning - return; -} - -static void PR4230_new(void) -{ - NSAutoreleasePool *pool = [NSAutoreleasePool new]; // no-warning - NSString *object = [[[NSString alloc] init] autorelease]; // no-warning - return; -} - -//===----------------------------------------------------------------------===// -// Method name that has a null IdentifierInfo* for its first selector slot. -// This test just makes sure that we handle it. -//===----------------------------------------------------------------------===// -@interface TestNullIdentifier -@end - -@implementation TestNullIdentifier -+ (id):(int)x, ... { - return [[NSString alloc] init]; // expected-warning{{leak}} -} -@end - -//===----------------------------------------------------------------------===// -// don't flag leaks for return types that cannot be determined to be CF types -//===----------------------------------------------------------------------===// - -// We don't know if 'struct s6893565' represents a Core Foundation type, so -// we shouldn't emit an error here. -typedef struct s6893565* TD6893565; - -@interface RDar6893565 {} --(TD6893565)newThing; -@end - -@implementation RDar6893565 --(TD6893565)newThing { - return (TD6893565) [[NSString alloc] init]; // no-warning -} -@end - -//===----------------------------------------------------------------------===// -// clang: false positives w/QC and CoreImage methods -//===----------------------------------------------------------------------===// -void rdar6902710(QCView *view, QCRenderer *renderer, CIContext *context, - NSString *str, CIImage *img, CGRect rect, - CIFormat form, CGColorSpaceRef cs) { - [view createSnapshotImageOfType:str]; // expected-warning{{leak}} - [renderer createSnapshotImageOfType:str]; // expected-warning{{leak}} - [context createCGImage:img fromRect:rect]; // expected-warning{{leak}} - [context createCGImage:img fromRect:rect format:form colorSpace:cs]; // expected-warning{{leak}} -} - -//===----------------------------------------------------------------------===// -// -[CIContext createCGLayerWithSize:info:] misinterpreted by clang scan-build -//===----------------------------------------------------------------------===// -void rdar6945561(CIContext *context, CGSize size, CFDictionaryRef d) { - [context createCGLayerWithSize:size info:d]; // expected-warning{{leak}} -} - -//===----------------------------------------------------------------------===// -// Add knowledge of IOKit functions to retain/release checker. -//===----------------------------------------------------------------------===// -void IOBSDNameMatching_wrapper(mach_port_t mainPort, uint32_t options, const char * bsdName) { - IOBSDNameMatching(mainPort, options, bsdName); // expected-warning{{leak}} -} - -void IOServiceMatching_wrapper(const char * name) { - IOServiceMatching(name); // expected-warning{{leak}} -} - -void IOServiceNameMatching_wrapper(const char * name) { - IOServiceNameMatching(name); // expected-warning{{leak}} -} - -CF_RETURNS_RETAINED CFDictionaryRef CreateDict(void); - -void IOServiceAddNotification_wrapper(mach_port_t mainPort, const io_name_t notificationType, - mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) { - - CFDictionaryRef matching = CreateDict(); - CFRelease(matching); - IOServiceAddNotification(mainPort, notificationType, matching, // expected-warning{{used after it is released}} expected-warning{{deprecated}} - wakePort, reference, notification); -} - -void IORegistryEntryIDMatching_wrapper(uint64_t entryID ) { - IORegistryEntryIDMatching(entryID); // expected-warning{{leak}} -} - -void IOOpenFirmwarePathMatching_wrapper(mach_port_t mainPort, uint32_t options, - const char * path) { - IOOpenFirmwarePathMatching(mainPort, options, path); // expected-warning{{leak}} -} - -void IOServiceGetMatchingService_wrapper(mach_port_t mainPort) { - CFDictionaryRef matching = CreateDict(); - IOServiceGetMatchingService(mainPort, matching); - CFRelease(matching); // expected-warning{{used after it is released}} -} - -void IOServiceGetMatchingServices_wrapper(mach_port_t mainPort, io_iterator_t *existing) { - CFDictionaryRef matching = CreateDict(); - IOServiceGetMatchingServices(mainPort, matching, existing); - CFRelease(matching); // expected-warning{{used after it is released}} -} - -void IOServiceAddMatchingNotification_wrapper(IONotificationPortRef notifyPort, const io_name_t notificationType, - IOServiceMatchingCallback callback, void * refCon, io_iterator_t * notification) { - - CFDictionaryRef matching = CreateDict(); - IOServiceAddMatchingNotification(notifyPort, notificationType, matching, callback, refCon, notification); - CFRelease(matching); // expected-warning{{used after it is released}} -} - -//===----------------------------------------------------------------------===// -// Test of handling objects whose references "escape" to containers. -//===----------------------------------------------------------------------===// -void CFDictionaryAddValue(CFMutableDictionaryRef, void *, void *); - -void rdar_6539791(CFMutableDictionaryRef y, void* key, void* val_key) { - CFMutableDictionaryRef x = CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - CFDictionaryAddValue(y, key, x); - CFRelease(x); // the dictionary keeps a reference, so the object isn't deallocated yet - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); - if (value) { - CFDictionaryAddValue(x, val_key, (void*)value); // no-warning - CFRelease(value); - CFDictionaryAddValue(y, val_key, (void*)value); // no-warning - } -} - -// Same issue, except with "AppendValue" functions. -void rdar_6560661(CFMutableArrayRef x) { - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); - // CFArrayAppendValue keeps a reference to value. - CFArrayAppendValue(x, value); - CFRelease(value); - CFRetain(value); - CFRelease(value); // no-warning -} - -// Same issue, excwept with "CFAttributeStringSetAttribute". -void rdar_7152619(CFStringRef str) { - CFAttributedStringRef string = CFAttributedStringCreate(kCFAllocatorDefault, str, 0); - CFMutableAttributedStringRef attrString = CFAttributedStringCreateMutableCopy(kCFAllocatorDefault, 100, string); - CFRelease(string); - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}} - CFAttributedStringSetAttribute(attrString, CFRangeMake(0, 1), str, number); - [number release]; - [number retain]; - CFRelease(attrString); -} - -//===----------------------------------------------------------------------===// -// Test of handling CGGradientXXX functions. -//===----------------------------------------------------------------------===// - -void rdar_7184450(CGContextRef myContext, CGFloat x, CGPoint myStartPoint, - CGPoint myEndPoint) { - size_t num_locations = 6; - CGFloat locations[6] = { 0.0, 0.265, 0.28, 0.31, 0.36, 1.0 }; - CGFloat components[28] = { 239.0/256.0, 167.0/256.0, 170.0/256.0, - x, // Start color - 207.0/255.0, 39.0/255.0, 39.0/255.0, x, - 147.0/255.0, 21.0/255.0, 22.0/255.0, x, - 175.0/255.0, 175.0/255.0, 175.0/255.0, x, - 255.0/255.0,255.0/255.0, 255.0/255.0, x, - 255.0/255.0,255.0/255.0, 255.0/255.0, x - }; // End color - - CGGradientRef myGradient = - CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), // expected-warning{{leak}} - components, locations, num_locations); - - CGContextDrawLinearGradient(myContext, myGradient, myStartPoint, myEndPoint, - 0); - CGGradientRelease(myGradient); -} - -void rdar_7184450_pos(CGContextRef myContext, CGFloat x, CGPoint myStartPoint, - CGPoint myEndPoint) { - size_t num_locations = 6; - CGFloat locations[6] = { 0.0, 0.265, 0.28, 0.31, 0.36, 1.0 }; - CGFloat components[28] = { 239.0/256.0, 167.0/256.0, 170.0/256.0, - x, // Start color - 207.0/255.0, 39.0/255.0, 39.0/255.0, x, - 147.0/255.0, 21.0/255.0, 22.0/255.0, x, - 175.0/255.0, 175.0/255.0, 175.0/255.0, x, - 255.0/255.0,255.0/255.0, 255.0/255.0, x, - 255.0/255.0,255.0/255.0, 255.0/255.0, x - }; // End color - - CGGradientRef myGradient = - CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), components, locations, num_locations); // expected-warning 2 {{leak}} - - CGContextDrawLinearGradient(myContext, myGradient, myStartPoint, myEndPoint, - 0); -} - -//===----------------------------------------------------------------------===// -// clang false positive: retained instance passed to thread in pthread_create -// marked as leak -// -// Until we have full IPA, the analyzer should stop tracking the reference -// count of objects passed to pthread_create. -// -//===----------------------------------------------------------------------===// -struct _opaque_pthread_t {}; -struct _opaque_pthread_attr_t {}; -typedef struct _opaque_pthread_t *__darwin_pthread_t; -typedef struct _opaque_pthread_attr_t __darwin_pthread_attr_t; -typedef __darwin_pthread_t pthread_t; -typedef __darwin_pthread_attr_t pthread_attr_t; -typedef unsigned long __darwin_pthread_key_t; -typedef __darwin_pthread_key_t pthread_key_t; - -int pthread_create(pthread_t *, const pthread_attr_t *, - void *(*)(void *), void *); - -int pthread_setspecific(pthread_key_t key, const void *value); - -void *rdar_7299394_start_routine(void *p) { - [((id) p) release]; - return 0; -} -void rdar_7299394(pthread_attr_t *attr, pthread_t *thread, void *args) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - pthread_create(thread, attr, rdar_7299394_start_routine, number); -} -void rdar_7299394_positive(pthread_attr_t *attr, pthread_t *thread) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}} -} - -//===----------------------------------------------------------------------===// -// false positive with not understanding thread local storage -//===----------------------------------------------------------------------===// -void rdar11282706(pthread_key_t key) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - pthread_setspecific(key, (void*) number); -} - -//===----------------------------------------------------------------------===// -// False leak associated with call to CVPixelBufferCreateWithBytes () -// -// According to the Core Video Reference (ADC), CVPixelBufferCreateWithBytes and -// CVPixelBufferCreateWithPlanarBytes can release (via a callback) the -// pixel buffer object. These test cases show how the analyzer stops tracking -// the reference count for the objects passed for this argument. This -// could be made smarter. -//===----------------------------------------------------------------------===// -typedef int int32_t; -typedef UInt32 FourCharCode; -typedef FourCharCode OSType; -typedef uint64_t CVOptionFlags; -typedef int32_t CVReturn; -typedef struct __CVBuffer *CVBufferRef; -typedef CVBufferRef CVImageBufferRef; -typedef CVImageBufferRef CVPixelBufferRef; -typedef void (*CVPixelBufferReleaseBytesCallback)( void *releaseRefCon, const void *baseAddress ); - -extern CVReturn CVPixelBufferCreateWithBytes(CFAllocatorRef allocator, - size_t width, - size_t height, - OSType pixelFormatType, - void *baseAddress, - size_t bytesPerRow, - CVPixelBufferReleaseBytesCallback releaseCallback, - void *releaseRefCon, - CFDictionaryRef pixelBufferAttributes, - CVPixelBufferRef *pixelBufferOut) ; - -typedef void (*CVPixelBufferReleasePlanarBytesCallback)( void *releaseRefCon, const void *dataPtr, size_t dataSize, size_t numberOfPlanes, const void *planeAddresses[] ); - -extern CVReturn CVPixelBufferCreateWithPlanarBytes(CFAllocatorRef allocator, - size_t width, - size_t height, - OSType pixelFormatType, - void *dataPtr, - size_t dataSize, - size_t numberOfPlanes, - void *planeBaseAddress[], - size_t planeWidth[], - size_t planeHeight[], - size_t planeBytesPerRow[], - CVPixelBufferReleasePlanarBytesCallback releaseCallback, - void *releaseRefCon, - CFDictionaryRef pixelBufferAttributes, - CVPixelBufferRef *pixelBufferOut) ; - -extern CVReturn CVPixelBufferCreateWithBytes(CFAllocatorRef allocator, - size_t width, - size_t height, - OSType pixelFormatType, - void *baseAddress, - size_t bytesPerRow, - CVPixelBufferReleaseBytesCallback releaseCallback, - void *releaseRefCon, - CFDictionaryRef pixelBufferAttributes, - CVPixelBufferRef *pixelBufferOut) ; - -CVReturn rdar_7283567(CFAllocatorRef allocator, size_t width, size_t height, - OSType pixelFormatType, void *baseAddress, - size_t bytesPerRow, - CVPixelBufferReleaseBytesCallback releaseCallback, - CFDictionaryRef pixelBufferAttributes, - CVPixelBufferRef *pixelBufferOut) { - - // For the allocated object, it doesn't really matter what type it is - // for the purpose of this test. All we want to show is that - // this is freed later by the callback. - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - - return CVPixelBufferCreateWithBytes(allocator, width, height, pixelFormatType, - baseAddress, bytesPerRow, releaseCallback, - number, // potentially released by callback - pixelBufferAttributes, pixelBufferOut) ; -} - -CVReturn rdar_7283567_2(CFAllocatorRef allocator, size_t width, size_t height, - OSType pixelFormatType, void *dataPtr, size_t dataSize, - size_t numberOfPlanes, void *planeBaseAddress[], - size_t planeWidth[], size_t planeHeight[], size_t planeBytesPerRow[], - CVPixelBufferReleasePlanarBytesCallback releaseCallback, - CFDictionaryRef pixelBufferAttributes, - CVPixelBufferRef *pixelBufferOut) { - - // For the allocated object, it doesn't really matter what type it is - // for the purpose of this test. All we want to show is that - // this is freed later by the callback. - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - - return CVPixelBufferCreateWithPlanarBytes(allocator, - width, height, pixelFormatType, dataPtr, dataSize, - numberOfPlanes, planeBaseAddress, planeWidth, - planeHeight, planeBytesPerRow, releaseCallback, - number, // potentially released by callback - pixelBufferAttributes, pixelBufferOut) ; -} - -//===----------------------------------------------------------------------===// -// False leak associated with CGBitmapContextCreateWithData -//===----------------------------------------------------------------------===// -typedef uint32_t CGBitmapInfo; -typedef void (*CGBitmapContextReleaseDataCallback)(void *releaseInfo, void *data); - -CGContextRef CGBitmapContextCreateWithData(void *data, - size_t width, size_t height, size_t bitsPerComponent, - size_t bytesPerRow, CGColorSpaceRef space, CGBitmapInfo bitmapInfo, - CGBitmapContextReleaseDataCallback releaseCallback, void *releaseInfo); - -void rdar_7358899(void *data, - size_t width, size_t height, size_t bitsPerComponent, - size_t bytesPerRow, CGColorSpaceRef space, CGBitmapInfo bitmapInfo, - CGBitmapContextReleaseDataCallback releaseCallback) { - - // For the allocated object, it doesn't really matter what type it is - // for the purpose of this test. All we want to show is that - // this is freed later by the callback. - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - - CGBitmapContextCreateWithData(data, width, height, bitsPerComponent, // expected-warning{{leak}} - bytesPerRow, space, bitmapInfo, releaseCallback, number); -} - -//===----------------------------------------------------------------------===// -// Allow 'new', 'copy', 'alloc', 'init' prefix to start before '_' when -// determining Cocoa fundamental rule. -// -// Previously the retain/release checker just skipped prefixes before the -// first '_' entirely. Now the checker honors the prefix if it results in a -// recognizable naming convention (e.g., 'new', 'init'). -//===----------------------------------------------------------------------===// -@interface RDar7265711 {} -- (id) new_stuff; -@end - -void rdar7265711_a(RDar7265711 *x) { - id y = [x new_stuff]; // expected-warning{{leak}} -} - -void rdar7265711_b(RDar7265711 *x) { - id y = [x new_stuff]; // no-warning - [y release]; -} - -//===----------------------------------------------------------------------===// -// clang thinks [NSCursor dragCopyCursor] returns a retained reference -//===----------------------------------------------------------------------===// -@interface NSCursor : NSObject -+ (NSCursor *)dragCopyCursor; -@end - -void rdar7306898(void) { - // 'dragCopyCursor' does not follow Cocoa's fundamental rule. It is a noun, not an sentence - // implying a 'copy' of something. - NSCursor *c = [NSCursor dragCopyCursor]; // no-warning - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}} -} - -//===----------------------------------------------------------------------===// -// Sending 'release', 'retain', etc. to a Class directly is not likely what the -// user intended. -//===----------------------------------------------------------------------===// -@interface RDar7252064 : NSObject @end -void rdar7252064(void) { - [RDar7252064 release]; // expected-warning{{The 'release' message should be sent to instances of class 'RDar7252064' and not the class directly}} - [RDar7252064 retain]; // expected-warning{{The 'retain' message should be sent to instances of class 'RDar7252064' and not the class directly}} - [RDar7252064 autorelease]; // expected-warning{{The 'autorelease' message should be sent to instances of class 'RDar7252064' and not the class directly}} - [NSAutoreleasePool drain]; // expected-warning{{method '+drain' not found}} expected-warning{{The 'drain' message should be sent to instances of class 'NSAutoreleasePool' and not the class directly}} -} - -//===----------------------------------------------------------------------===// -// Tests of ownership attributes. -//===----------------------------------------------------------------------===// - -typedef NSString* MyStringTy; - -@protocol FooP; - -@interface TestOwnershipAttr : NSObject -- (NSString*) returnsAnOwnedString NS_RETURNS_RETAINED; // no-warning -- (NSString*) returnsAnOwnedCFString CF_RETURNS_RETAINED; // no-warning -- (MyStringTy) returnsAnOwnedTypedString NS_RETURNS_RETAINED; // no-warning -- (NSString*) newString NS_RETURNS_NOT_RETAINED; // no-warning -- (NSString*) newString_auto NS_RETURNS_AUTORELEASED; // no-warning -- (NSString*) newStringNoAttr; -- (int) returnsAnOwnedInt NS_RETURNS_RETAINED; // expected-warning{{'ns_returns_retained' attribute only applies to methods that return an Objective-C object}} -- (id) pseudoInit NS_CONSUMES_SELF NS_RETURNS_RETAINED; -+ (void) consume:(id) NS_CONSUMED x; -+ (void) consume2:(id) CF_CONSUMED x; -@end - -static int ownership_attribute_doesnt_go_here NS_RETURNS_RETAINED; // expected-warning{{'ns_returns_retained' attribute only applies to functions and methods}} - -void test_attr_1(TestOwnershipAttr *X) { - NSString *str = [X returnsAnOwnedString]; // expected-warning{{leak}} -} - -void test_attr_1b(TestOwnershipAttr *X) { - NSString *str = [X returnsAnOwnedCFString]; // expected-warning{{leak}} -} - -void test_attr1c(TestOwnershipAttr *X) { - NSString *str = [X newString]; // no-warning - NSString *str2 = [X newStringNoAttr]; // expected-warning{{leak}} - NSString *str3 = [X newString_auto]; // no-warning - NSString *str4 = [[X newString_auto] retain]; // expected-warning {{leak}} -} - -void testattr2_a(void) { - TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // expected-warning{{leak}} -} - -void testattr2_b(void) { - TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; // expected-warning{{leak}} -} - -void testattr2_b_11358224_self_assign_looses_the_leak(void) { - TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit];// expected-warning{{leak}} - x = x; -} - -void testattr2_c(void) { - TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; // no-warning - [x release]; -} - -void testattr3(void) { - TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // no-warning - [TestOwnershipAttr consume:x]; - TestOwnershipAttr *y = [TestOwnershipAttr alloc]; // no-warning - [TestOwnershipAttr consume2:y]; -} - -void consume_ns(id NS_CONSUMED x); -void consume_cf(id CF_CONSUMED x); - -void testattr4(void) { - TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // no-warning - consume_ns(x); - TestOwnershipAttr *y = [TestOwnershipAttr alloc]; // no-warning - consume_cf(y); -} - -@interface TestOwnershipAttr2 : NSObject -- (NSString*) newString NS_RETURNS_NOT_RETAINED; // no-warning -@end - -@implementation TestOwnershipAttr2 -- (NSString*) newString { - return [NSString alloc]; // expected-warning {{Potential leak of an object}} -} -@end - -@interface MyClassTestCFAttr : NSObject {} -- (NSDate*) returnsCFRetained CF_RETURNS_RETAINED; -- (CFDateRef) returnsCFRetainedAsCF CF_RETURNS_RETAINED; -- (CFDateRef) newCFRetainedAsCF CF_RETURNS_NOT_RETAINED; -- (CFDateRef) newCFRetainedAsCFNoAttr; -- (NSDate*) alsoReturnsRetained; -- (CFDateRef) alsoReturnsRetainedAsCF; -- (NSDate*) returnsNSRetained NS_RETURNS_RETAINED; -@end - -CF_RETURNS_RETAINED -CFDateRef returnsRetainedCFDate(void) { - return CFDateCreate(0, CFAbsoluteTimeGetCurrent()); -} - -@implementation MyClassTestCFAttr -- (NSDate*) returnsCFRetained { - return (NSDate*) returnsRetainedCFDate(); // No leak. -} - -- (CFDateRef) returnsCFRetainedAsCF { - return returnsRetainedCFDate(); // No leak. -} - -- (CFDateRef) newCFRetainedAsCF { - return (CFDateRef)[(id)[self returnsCFRetainedAsCF] autorelease]; -} - -- (CFDateRef) newCFRetainedAsCFNoAttr { - return (CFDateRef)[(id)[self returnsCFRetainedAsCF] autorelease]; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} -} - -- (NSDate*) alsoReturnsRetained { - return (NSDate*) returnsRetainedCFDate(); // expected-warning{{leak}} -} - -- (CFDateRef) alsoReturnsRetainedAsCF { - return returnsRetainedCFDate(); // expected-warning{{leak}} -} - - -- (NSDate*) returnsNSRetained { - return (NSDate*) returnsRetainedCFDate(); // no-warning -} -@end - -//===----------------------------------------------------------------------===// -// Test that leaks post-dominated by "panic" functions are not reported. -// -// Do not report a leak when post-dominated by a call to a noreturn or panic -// function. -//===----------------------------------------------------------------------===// -void panic(void) __attribute__((noreturn)); -void panic_not_in_hardcoded_list(void) __attribute__((noreturn)); - -void test_panic_negative(void) { - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // expected-warning{{leak}} -} - -void test_panic_positive(void) { - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // no-warning - panic(); -} - -void test_panic_neg_2(int x) { - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // expected-warning{{leak}} - if (x) - panic(); -} - -void test_panic_pos_2(int x) { - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // no-warning - if (x) - panic(); - if (!x) { - // This showed up previously where we silently missed checking the function - // type for noreturn. "panic()" is a hard-coded known panic function that - // isn't always noreturn. - panic_not_in_hardcoded_list(); - } -} - -//===----------------------------------------------------------------------===// -// Test uses of blocks (closures) -//===----------------------------------------------------------------------===// - -void test_blocks_1_pos(void) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}} - ^{}(); -} - -void test_blocks_1_indirect_release(void) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - ^{ [number release]; }(); -} - -void test_blocks_1_indirect_retain(void) { - // Eventually this should be reported as a leak. - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - ^{ [number retain]; }(); -} - -void test_blocks_1_indirect_release_via_call(void) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - ^(NSObject *o){ [o release]; }(number); -} - -void test_blocks_1_indirect_retain_via_call(void) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning {{leak}} - ^(NSObject *o){ [o retain]; }(number); -} - -//===--------------------------------------------------------------------===// -// Test sending message to super that returns an object alias. Previously -// this caused a crash in the analyzer. -//===--------------------------------------------------------------------===// - -@interface Rdar8015556 : NSObject {} @end -@implementation Rdar8015556 -- (id)retain { - return [super retain]; -} -@end - -// Correcly handle Class<...> in Cocoa Conventions detector. -@protocol Prot_R8272168 @end -Class <Prot_R8272168> GetAClassThatImplementsProt_R8272168(void); -void r8272168(void) { - GetAClassThatImplementsProt_R8272168(); -} - -// Test case which in the past triggered a false positive. -@interface RDar8356342 -- (NSDate*) rdar8356342:(NSDate *)inValue; -@end - -@implementation RDar8356342 -- (NSDate*) rdar8356342:(NSDate*)inValue { - NSDate *outValue = inValue; - if (outValue == 0) - outValue = [[NSDate alloc] init]; // no-warning - - if (outValue != inValue) - [outValue autorelease]; - - return outValue; -} -@end - -// This test case previously crashed because of a bug in BugReporter. -extern const void *CFDictionaryGetValue(CFDictionaryRef theDict, const void *key); -typedef struct __CFError * CFErrorRef; -extern const CFStringRef kCFErrorUnderlyingErrorKey; -extern CFDictionaryRef CFErrorCopyUserInfo(CFErrorRef err); -static void rdar_8724287(CFErrorRef error) -{ - CFErrorRef error_to_dump; - - error_to_dump = error; - while (error_to_dump != ((void*)0)) { - CFDictionaryRef info; - - info = CFErrorCopyUserInfo(error_to_dump); // expected-warning{{Potential leak of an object}} - - if (info != ((void*)0)) { - } - - error_to_dump = (CFErrorRef) CFDictionaryGetValue(info, kCFErrorUnderlyingErrorKey); - } -} - -// Make sure the model applies cf_consumed correctly in argument positions -// besides the first. -extern void *CFStringCreate(void); -extern void rdar_9234108_helper(void *key, void * CF_CONSUMED value); -void rdar_9234108(void) { - rdar_9234108_helper(0, CFStringCreate()); -} - -// Make sure that objc_method_family works to override naming conventions. -struct TwoDoubles { - double one; - double two; -}; -typedef struct TwoDoubles TwoDoubles; - -@interface NSValue (Mine) -- (id)_prefix_initWithTwoDoubles:(TwoDoubles)twoDoubles __attribute__((objc_method_family(init))); -@end - -@implementation NSValue (Mine) -- (id)_prefix_initWithTwoDoubles:(TwoDoubles)twoDoubles -{ - return [self init]; -} -@end - -void rdar9726279(void) { - TwoDoubles twoDoubles = { 0.0, 0.0 }; - NSValue *value = [[NSValue alloc] _prefix_initWithTwoDoubles:twoDoubles]; - [value release]; -} - -// Test camelcase support for CF conventions. While Core Foundation APIs -// don't use camel casing, other code is allowed to use it. -CFArrayRef camelcase_create_1(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef camelcase_createno(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}} -} - -CFArrayRef camelcase_copy(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef camelcase_copying(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}} -} - -CFArrayRef copyCamelCase(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef __copyCamelCase(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef __createCamelCase(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef camel_create(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - - -CFArrayRef camel_creat(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}} -} - -CFArrayRef camel_copy(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef camel_copyMachine(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef camel_copymachine(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}} -} - -@protocol F18P -- (id) clone; -@end -@interface F18 : NSObject<F18P> @end -@interface F18(Cat) -- (id) clone NS_RETURNS_RETAINED; -@end - -@implementation F18 -- (id) clone { - return [F18 alloc]; -} -@end - -void rdar6582778(void) { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFTypeRef vals[] = { CFDateCreate(0, t) }; // expected-warning {{leak}} -} - -CFTypeRef global; - -void rdar6582778_2(void) { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - global = CFDateCreate(0, t); // no-warning -} - -// Test that objects passed to containers are marked "escaped". -void rdar10232019(void) { - NSMutableArray *array = [NSMutableArray array]; - - NSString *string = [[NSString alloc] initWithUTF8String:"foo"]; - [array addObject:string]; - [string release]; - - NSString *otherString = [string stringByAppendingString:@"bar"]; // no-warning - NSLog(@"%@", otherString); -} - -void rdar10232019_positive(void) { - NSMutableArray *array = [NSMutableArray array]; - - NSString *string = [[NSString alloc] initWithUTF8String:"foo"]; - [string release]; - - NSString *otherString = [string stringByAppendingString:@"bar"]; // expected-warning {{Reference-counted object is used after it is release}} - NSLog(@"%@", otherString); -} - -// RetainCountChecker support for XPC. -typedef void * xpc_object_t; -xpc_object_t _CFXPCCreateXPCObjectFromCFObject(CFTypeRef cf); -void xpc_release(xpc_object_t object); - -void rdar9658496(void) { - CFStringRef cf; - xpc_object_t xpc; - cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning - xpc = _CFXPCCreateXPCObjectFromCFObject( cf ); - CFRelease(cf); - xpc_release(xpc); -} - -// Support annotations with method families. -@interface RDar10824732 : NSObject -- (id)initWithObj:(id CF_CONSUMED)obj; -@end - -@implementation RDar10824732 -- (id)initWithObj:(id)obj { - [obj release]; - return [super init]; -} -@end - -void rdar_10824732(void) { - @autoreleasepool { - NSString *obj = @"test"; - RDar10824732 *foo = [[RDar10824732 alloc] initWithObj:obj]; // no-warning - [foo release]; - } -} - -// Stop tracking objects passed to functions, which take callbacks as parameters. -typedef int (*CloseCallback) (void *); -void ReaderForIO(CloseCallback ioclose, void *ioctx); -int IOClose(void *context); - -@protocol SInS <NSObject> -@end - -@interface radar10973977 : NSObject -- (id<SInS>)inputS; -- (void)reader; -@end - -@implementation radar10973977 -- (void)reader -{ - id<SInS> inputS = [[self inputS] retain]; - ReaderForIO(IOClose, inputS); -} -- (id<SInS>)inputS -{ - return 0; -} -@end - -// Object escapes through a selector callback -extern id NSApp; -@interface MySheetController -- (id<SInS>)inputS; -- (void)showDoSomethingSheetAction:(id)action; -- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo; -@end - -@implementation MySheetController -- (id<SInS>)inputS { - return 0; -} -- (void)showDoSomethingSheetAction:(id)action { - id<SInS> inputS = [[self inputS] retain]; - [NSApp beginSheet:0 - modalForWindow:0 - modalDelegate:0 - didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) - contextInfo:(void *)inputS]; // no - warning -} -- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { - - id contextObject = (id)contextInfo; - [contextObject release]; -} - -- (id)copyAutoreleaseRadar13081402 { - id x = [[[NSString alloc] initWithUTF8String:"foo"] autorelease]; - [x retain]; - return x; // no warning -} - -@end -//===----------------------------------------------------------------------===// -// Test returning allocated memory in a struct. -// -// We currently don't have a general way to track pointers that "escape". -// Here we test that RetainCountChecker doesn't get excited about returning -// allocated CF objects in struct fields. -//===----------------------------------------------------------------------===// -void *malloc(size_t); -struct rdar11104566 { CFStringRef myStr; }; -struct rdar11104566 test_rdar11104566(void) { - CFStringRef cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning - struct rdar11104566 V; - V.myStr = cf; - return V; // no-warning -} - -struct rdar11104566 *test_2_rdar11104566(void) { - CFStringRef cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning - struct rdar11104566 *V = (struct rdar11104566 *) malloc(sizeof(*V)); - V->myStr = cf; - return V; // no-warning -} - -//===----------------------------------------------------------------------===// -// ObjC literals support. -//===----------------------------------------------------------------------===// - -void test_objc_arrays(void) { - { // CASE ONE -- OBJECT IN ARRAY CREATED DIRECTLY - NSObject *o = [[NSObject alloc] init]; - NSArray *a = [[NSArray alloc] initWithObjects:o, (void*)0]; // expected-warning {{leak}} - [o release]; - [a description]; - [o description]; - } - - { // CASE TWO -- OBJECT IN ARRAY CREATED BY DUPING AUTORELEASED ARRAY - NSObject *o = [[NSObject alloc] init]; - NSArray *a1 = [NSArray arrayWithObjects:o, (void*)0]; - NSArray *a2 = [[NSArray alloc] initWithArray:a1]; // expected-warning {{leak}} - [o release]; - [a2 description]; - [o description]; - } - - { // CASE THREE -- OBJECT IN RETAINED @[] - NSObject *o = [[NSObject alloc] init]; - NSArray *a3 = [@[o] retain]; // expected-warning {{leak}} - [o release]; - [a3 description]; - [o description]; - } - - { // CASE FOUR -- OBJECT IN ARRAY CREATED BY DUPING @[] - NSObject *o = [[NSObject alloc] init]; - NSArray *a = [[NSArray alloc] initWithArray:@[o]]; // expected-warning {{leak}} - [o release]; - - [a description]; - [o description]; - } - - { // CASE FIVE -- OBJECT IN RETAINED @{} - NSValue *o = [[NSValue alloc] init]; - NSDictionary *a = [@{o : o} retain]; // expected-warning {{leak}} - [o release]; - - [a description]; - [o description]; - } -} - -void test_objc_integer_literals(void) { - id value = [@1 retain]; // expected-warning {{leak}} - [value description]; -} - -void test_objc_boxed_expressions(int x, const char *y) { - id value = [@(x) retain]; // expected-warning {{leak}} - [value description]; - - value = [@(y) retain]; // expected-warning {{leak}} - [value description]; -} - -// Test NSLog doesn't escape tracked objects. -void rdar11400885(int y) -{ - @autoreleasepool { - NSString *printString; - if(y > 2) - printString = [[NSString alloc] init]; - else - printString = [[NSString alloc] init]; - NSLog(@"Once %@", printString); - [printString release]; - NSLog(@"Again: %@", printString); // expected-warning {{Reference-counted object is used after it is released}} - } -} - -id makeCollectableNonLeak(void) { - extern CFTypeRef CFCreateSomething(void); - - CFTypeRef object = CFCreateSomething(); // +1 - CFRetain(object); // +2 - id objCObject = NSMakeCollectable(object); // +2 - [objCObject release]; // +1 - return [objCObject autorelease]; // +0 -} - - -void consumeAndStopTracking(id NS_CONSUMED obj, void (^callback)(void)); -void CFConsumeAndStopTracking(CFTypeRef CF_CONSUMED obj, void (^callback)(void)); - -void testConsumeAndStopTracking(void) { - id retained = [@[] retain]; // +1 - consumeAndStopTracking(retained, ^{}); // no-warning - - id doubleRetained = [[@[] retain] retain]; // +2 - consumeAndStopTracking(doubleRetained, ^{ - [doubleRetained release]; - }); // no-warning - - id unretained = @[]; // +0 - consumeAndStopTracking(unretained, ^{}); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} -} - -void testCFConsumeAndStopTracking(void) { - id retained = [@[] retain]; // +1 - CFConsumeAndStopTracking((CFTypeRef)retained, ^{}); // no-warning - - id doubleRetained = [[@[] retain] retain]; // +2 - CFConsumeAndStopTracking((CFTypeRef)doubleRetained, ^{ - [doubleRetained release]; - }); // no-warning - - id unretained = @[]; // +0 - CFConsumeAndStopTracking((CFTypeRef)unretained, ^{}); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} -} -//===----------------------------------------------------------------------===// -// Test 'pragma clang arc_cf_code_audited' support. -//===----------------------------------------------------------------------===// - -typedef void *MyCFType; -#pragma clang arc_cf_code_audited begin -MyCFType CreateMyCFType(void); -#pragma clang arc_cf_code_audited end - -void test_custom_cf(void) { - MyCFType x = CreateMyCFType(); // expected-warning {{leak of an object stored into 'x'}} -} - -//===----------------------------------------------------------------------===// -// Test calling CFPlugInInstanceCreate, which appears in CF but doesn't -// return a CF object. -//===----------------------------------------------------------------------===// - -void test_CFPlugInInstanceCreate(CFUUIDRef factoryUUID, CFUUIDRef typeUUID) { - CFPlugInInstanceCreate(kCFAllocatorDefault, factoryUUID, typeUUID); // no-warning -} - -//===----------------------------------------------------------------------===// -// PR14927: -drain only has retain-count semantics on NSAutoreleasePool. -//===----------------------------------------------------------------------===// - -@interface PR14927 : NSObject -- (void)drain; -@end - -void test_drain(void) { - PR14927 *obj = [[PR14927 alloc] init]; - [obj drain]; - [obj release]; // no-warning -} - -//===----------------------------------------------------------------------===// -// Allow cf_returns_retained and cf_returns_not_retained to mark a return -// value as tracked, even if the object isn't a known CF type. -//===----------------------------------------------------------------------===// - -MyCFType getCustom(void) __attribute__((cf_returns_not_retained)); -MyCFType makeCustom(void) __attribute__((cf_returns_retained)); - -void testCustomReturnsRetained(void) { - MyCFType obj = makeCustom(); // expected-warning {{leak of an object stored into 'obj'}} -} - -void testCustomReturnsNotRetained(void) { - CFRelease(getCustom()); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} -} - -//===----------------------------------------------------------------------===// -// Don't print variables which are out of the current scope. -//===----------------------------------------------------------------------===// -@interface MyObj12706177 : NSObject --(id)initX; -+(void)test12706177; -@end -static int Cond; -@implementation MyObj12706177 --(id)initX { - if (Cond) - return 0; - self = [super init]; - return self; -} -+(void)test12706177 { - id x = [[MyObj12706177 alloc] initX]; //expected-warning {{Potential leak of an object}} - [x release]; -} -@end - -//===----------------------------------------------------------------------===// -// xpc_connection_set_finalizer_f -//===----------------------------------------------------------------------===// -typedef xpc_object_t xpc_connection_t; -typedef void (*xpc_finalizer_t)(void *value); -void xpc_connection_set_context(xpc_connection_t connection, void *ctx); -void xpc_connection_set_finalizer_f(xpc_connection_t connection, - xpc_finalizer_t finalizer); -void releaseAfterXPC(void *context) { - [(NSArray *)context release]; -} - -void rdar13783514(xpc_connection_t connection) { - xpc_connection_set_context(connection, [[NSMutableArray alloc] init]); - xpc_connection_set_finalizer_f(connection, releaseAfterXPC); -} // no-warning - -CFAttributedStringRef CFAttributedCreate(void *CFObj CF_CONSUMED) CF_RETURNS_RETAINED; - -@interface Action -- (SEL)action; -- (void)setAction:(SEL)aSelector; -- (id) target; -- (void)setTarget:(id)aTarget; -@end diff --git clang/test/ARCMT/objcmt-arc-cf-annotations.m.result clang/test/ARCMT/objcmt-arc-cf-annotations.m.result deleted file mode 100644 index 1e9412978488..000000000000 --- clang/test/ARCMT/objcmt-arc-cf-annotations.m.result +++ /dev/null @@ -1,2063 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fblocks -objcmt-migrate-annotation -objcmt-migrate-instancetype -objcmt-migrate-readwrite-property -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result - -#ifndef CF_IMPLICIT_BRIDGING_ENABLED -#if __has_feature(arc_cf_code_audited) -#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin") -#else -#define CF_IMPLICIT_BRIDGING_ENABLED -#endif -#endif - -#ifndef CF_IMPLICIT_BRIDGING_DISABLED -#if __has_feature(arc_cf_code_audited) -#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end") -#else -#define CF_IMPLICIT_BRIDGING_DISABLED -#endif -#endif - -#if __has_feature(attribute_ns_returns_retained) -#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) -#endif -#if __has_feature(attribute_cf_returns_retained) -#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) -#endif -#if __has_feature(attribute_ns_returns_not_retained) -#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained)) -#endif -#if __has_feature(attribute_cf_returns_not_retained) -#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained)) -#endif -#if __has_feature(attribute_ns_consumes_self) -#define NS_CONSUMES_SELF __attribute__((ns_consumes_self)) -#endif -#if __has_feature(attribute_ns_consumed) -#define NS_CONSUMED __attribute__((ns_consumed)) -#endif -#if __has_feature(attribute_cf_consumed) -#define CF_CONSUMED __attribute__((cf_consumed)) -#endif -#if __has_attribute(ns_returns_autoreleased) -#define NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased)) -#endif - -//===----------------------------------------------------------------------===// -// The following code is reduced using delta-debugging from Mac OS X headers: -// -// #include <Cocoa/Cocoa.h> -// #include <CoreFoundation/CoreFoundation.h> -// #include <DiskArbitration/DiskArbitration.h> -// #include <QuartzCore/QuartzCore.h> -// #include <Quartz/Quartz.h> -// #include <IOKit/IOKitLib.h> -// -// It includes the basic definitions for the test cases below. -//===----------------------------------------------------------------------===// - -typedef unsigned int __darwin_natural_t; -typedef unsigned long uintptr_t; -typedef unsigned int uint32_t; -typedef unsigned long long uint64_t; -typedef unsigned int UInt32; -typedef signed long CFIndex; -typedef CFIndex CFByteOrder; -typedef struct { - CFIndex location; - CFIndex length; -} CFRange; -static __inline__ __attribute__((always_inline)) CFRange CFRangeMake(CFIndex loc, CFIndex len) { - CFRange range; - range.location = loc; - range.length = len; - return range; -} -typedef const void * CFTypeRef; -typedef const struct __CFString * CFStringRef; -typedef const struct __CFAllocator * CFAllocatorRef; -extern const CFAllocatorRef kCFAllocatorDefault; -extern CFTypeRef CFRetain(CFTypeRef cf); - -CF_IMPLICIT_BRIDGING_ENABLED - -extern void CFRelease(CFTypeRef cf); - -CF_IMPLICIT_BRIDGING_DISABLED - -extern CFTypeRef CFAutorelease(CFTypeRef cf); -extern CFTypeRef CFMakeCollectable(CFTypeRef cf); -typedef struct { -} -CFArrayCallBacks; -extern const CFArrayCallBacks kCFTypeArrayCallBacks; -typedef const struct __CFArray * CFArrayRef; -typedef struct __CFArray * CFMutableArrayRef; -extern CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFArrayCallBacks *callBacks) CF_RETURNS_RETAINED; -extern const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx) CF_RETURNS_NOT_RETAINED; -extern void CFArrayAppendValue(CFMutableArrayRef theArray, const void *value); -typedef struct { -} -CFDictionaryKeyCallBacks; -extern const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks; -typedef struct { -} -CFDictionaryValueCallBacks; -extern const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks; -typedef const struct __CFDictionary * CFDictionaryRef; -typedef struct __CFDictionary * CFMutableDictionaryRef; -extern CFMutableDictionaryRef CFDictionaryCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks) CF_RETURNS_RETAINED; -typedef UInt32 CFStringEncoding; -enum { -kCFStringEncodingMacRoman = 0, kCFStringEncodingWindowsLatin1 = 0x0500, kCFStringEncodingISOLatin1 = 0x0201, kCFStringEncodingNextStepLatin = 0x0B01, kCFStringEncodingASCII = 0x0600, kCFStringEncodingUnicode = 0x0100, kCFStringEncodingUTF8 = 0x08000100, kCFStringEncodingNonLossyASCII = 0x0BFF , kCFStringEncodingUTF16 = 0x0100, kCFStringEncodingUTF16BE = 0x10000100, kCFStringEncodingUTF16LE = 0x14000100, kCFStringEncodingUTF32 = 0x0c000100, kCFStringEncodingUTF32BE = 0x18000100, kCFStringEncodingUTF32LE = 0x1c000100 }; -extern CFStringRef CFStringCreateWithCString(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding) CF_RETURNS_RETAINED; -typedef double CFTimeInterval; -typedef CFTimeInterval CFAbsoluteTime; -extern CFAbsoluteTime CFAbsoluteTimeGetCurrent(void); -typedef const struct __CFDate * CFDateRef; -extern CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at) CF_RETURNS_RETAINED; -extern CFAbsoluteTime CFDateGetAbsoluteTime(CFDateRef theDate); -typedef __darwin_natural_t natural_t; -typedef natural_t mach_port_name_t; -typedef mach_port_name_t mach_port_t; -typedef int kern_return_t; -typedef kern_return_t mach_error_t; -enum { -kCFNumberSInt8Type = 1, kCFNumberSInt16Type = 2, kCFNumberSInt32Type = 3, kCFNumberSInt64Type = 4, kCFNumberFloat32Type = 5, kCFNumberFloat64Type = 6, kCFNumberCharType = 7, kCFNumberShortType = 8, kCFNumberIntType = 9, kCFNumberLongType = 10, kCFNumberLongLongType = 11, kCFNumberFloatType = 12, kCFNumberDoubleType = 13, kCFNumberCFIndexType = 14, kCFNumberNSIntegerType = 15, kCFNumberCGFloatType = 16, kCFNumberMaxType = 16 }; -typedef CFIndex CFNumberType; -typedef const struct __CFNumber * CFNumberRef; -extern CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr) CF_RETURNS_RETAINED; -typedef const struct __CFAttributedString *CFAttributedStringRef; -typedef struct __CFAttributedString *CFMutableAttributedStringRef; -extern CFAttributedStringRef CFAttributedStringCreate(CFAllocatorRef alloc, CFStringRef str, CFDictionaryRef attributes) CF_RETURNS_RETAINED ; -extern CFMutableAttributedStringRef CFAttributedStringCreateMutableCopy(CFAllocatorRef alloc, CFIndex maxLength, CFAttributedStringRef aStr) CF_RETURNS_RETAINED ; -extern void CFAttributedStringSetAttribute(CFMutableAttributedStringRef aStr, CFRange range, CFStringRef attrName, CFTypeRef value) ; -typedef signed char BOOL; -typedef unsigned long NSUInteger; -@class NSString, Protocol; -extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2))); -typedef struct _NSZone NSZone; -@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; -@protocol NSObject -- (BOOL)isEqual:(id)object; -- (id)retain; -- (oneway void)release; -- (id)autorelease; -- (NSString *)description; -- (instancetype)init; -@end -@protocol NSCopying -- (id)copyWithZone:(NSZone *)zone; -@end -@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; -@end -@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; -@end -@interface NSObject <NSObject> {} -+ (id)allocWithZone:(NSZone *)zone; -+ (id)alloc; -+ (id)new; -- (void)dealloc; -@end -@interface NSObject (NSCoderMethods) -- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder; -@end -extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); -typedef struct { -} -NSFastEnumerationState; -@protocol NSFastEnumeration -- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len; -@end -@class NSString, NSDictionary; -@interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value; -@end -@interface NSNumber : NSValue -- (char)charValue; -- (instancetype)initWithInt:(int)value; -+ (NSNumber *)numberWithInt:(int)value; -@end -@class NSString; -@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> -- (NSUInteger)count; -- (instancetype)initWithObjects:(const id [])objects count:(NSUInteger)cnt; -+ (instancetype)arrayWithObject:(id)anObject; -+ (instancetype)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt; -+ (instancetype)arrayWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1))); -- (instancetype)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1))); -- (instancetype)initWithArray:(NSArray *)array; -@end @interface NSArray (NSArrayCreation) + (instancetype)array; -@end @interface NSAutoreleasePool : NSObject { -} -- (void)drain; -@end extern NSString * const NSBundleDidLoadNotification; -typedef double NSTimeInterval; -@interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate; -@end typedef unsigned short unichar; -@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding> -- (NSUInteger)length; -- (NSString *)stringByAppendingString:(NSString *)aString; -- ( const char *)UTF8String; -- (instancetype)initWithUTF8String:(const char *)nullTerminatedCString; -+ (instancetype)stringWithUTF8String:(const char *)nullTerminatedCString; -@end @class NSString, NSURL, NSError; -@interface NSData : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length; -+ (instancetype)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length; -+ (instancetype)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b; -@end @class NSLocale, NSDate, NSCalendar, NSTimeZone, NSError, NSArray, NSMutableDictionary; -@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> -- (NSUInteger)count; -+ (instancetype)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; -+ (instancetype)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt; -@end -@interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey; -- (void)setObject:(id)anObject forKey:(id)aKey; -@end @interface NSMutableDictionary (NSMutableDictionaryCreation) + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; -@end typedef double CGFloat; -struct CGSize { -}; -typedef struct CGSize CGSize; -struct CGRect { -}; -typedef struct CGRect CGRect; -typedef mach_port_t io_object_t; -typedef char io_name_t[128]; -typedef io_object_t io_iterator_t; -typedef io_object_t io_service_t; -typedef struct IONotificationPort * IONotificationPortRef; -typedef void (*IOServiceMatchingCallback)( void * refcon, io_iterator_t iterator ); - -CF_IMPLICIT_BRIDGING_ENABLED - -io_service_t IOServiceGetMatchingService( mach_port_t mainPort, CFDictionaryRef matching ); -kern_return_t IOServiceGetMatchingServices( mach_port_t mainPort, CFDictionaryRef matching, io_iterator_t * existing ); - -CF_IMPLICIT_BRIDGING_DISABLED - -kern_return_t IOServiceAddNotification( mach_port_t mainPort, const io_name_t notificationType, CFDictionaryRef matching, mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) __attribute__((deprecated)); // expected-note {{'IOServiceAddNotification' declared here}} -kern_return_t IOServiceAddMatchingNotification( IONotificationPortRef notifyPort, const io_name_t notificationType, CFDictionaryRef CF_CONSUMED matching, IOServiceMatchingCallback callback, void * refCon, io_iterator_t * notification ); - -CF_IMPLICIT_BRIDGING_ENABLED - -CFMutableDictionaryRef IOServiceMatching( const char * name ); -CFMutableDictionaryRef IOServiceNameMatching( const char * name ); -CFMutableDictionaryRef IOBSDNameMatching( mach_port_t mainPort, uint32_t options, const char * bsdName ); -CFMutableDictionaryRef IOOpenFirmwarePathMatching( mach_port_t mainPort, uint32_t options, const char * path ); -CFMutableDictionaryRef IORegistryEntryIDMatching( uint64_t entryID ); - -CF_IMPLICIT_BRIDGING_DISABLED - -typedef struct __DASession * DASessionRef; -extern DASessionRef DASessionCreate( CFAllocatorRef allocator ) CF_RETURNS_RETAINED; -typedef struct __DADisk * DADiskRef; -extern DADiskRef DADiskCreateFromBSDName( CFAllocatorRef allocator, DASessionRef session, const char * name ) CF_RETURNS_RETAINED; -extern DADiskRef DADiskCreateFromIOMedia( CFAllocatorRef allocator, DASessionRef session, io_service_t media ) CF_RETURNS_RETAINED; -extern CFDictionaryRef DADiskCopyDescription( DADiskRef disk ) CF_RETURNS_RETAINED; -extern DADiskRef DADiskCopyWholeDisk( DADiskRef disk ) CF_RETURNS_RETAINED; -@interface NSTask : NSObject - (instancetype)init; -@end typedef struct CGColorSpace *CGColorSpaceRef; -typedef struct CGImage *CGImageRef; -typedef struct CGLayer *CGLayerRef; -@interface NSResponder : NSObject <NSCoding> { -} -@end @protocol NSAnimatablePropertyContainer - (id)animator; -@end extern NSString *NSAnimationTriggerOrderIn ; -@interface NSView : NSResponder <NSAnimatablePropertyContainer> { -} -@end @protocol NSValidatedUserInterfaceItem - (SEL)action; -@end @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem; -@end @class NSDate, NSDictionary, NSError, NSException, NSNotification; -@class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError; -@interface NSApplication : NSResponder <NSUserInterfaceValidations> { -} -- (void)beginSheet:(NSWindow *)sheet modalForWindow:(NSWindow *)docWindow modalDelegate:(id)modalDelegate didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo; -@end enum { -NSTerminateCancel = 0, NSTerminateNow = 1, NSTerminateLater = 2 }; -typedef NSUInteger NSApplicationTerminateReply; -@protocol NSApplicationDelegate <NSObject> @optional - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; -@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView, NSTextView; -@interface NSCell : NSObject <NSCopying, NSCoding> { -} -@end -typedef struct { -} -CVTimeStamp; -@interface CIImage : NSObject <NSCoding, NSCopying> { -} -typedef int CIFormat; -@end enum { -kDAReturnSuccess = 0, kDAReturnError = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x01, kDAReturnBusy = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x02, kDAReturnBadArgument = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x03, kDAReturnExclusiveAccess = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x04, kDAReturnNoResources = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x05, kDAReturnNotFound = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x06, kDAReturnNotMounted = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x07, kDAReturnNotPermitted = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x08, kDAReturnNotPrivileged = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x09, kDAReturnNotReady = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0A, kDAReturnNotWritable = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0B, kDAReturnUnsupported = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0C }; -typedef mach_error_t DAReturn; -typedef const struct __DADissenter * DADissenterRef; -extern DADissenterRef DADissenterCreate( CFAllocatorRef allocator, DAReturn status, CFStringRef string ) CF_RETURNS_RETAINED; -@interface CIContext: NSObject { -} -- (CGImageRef)createCGImage:(CIImage *)im fromRect:(CGRect)r CF_RETURNS_RETAINED; -- (CGImageRef)createCGImage:(CIImage *)im fromRect:(CGRect)r format:(CIFormat)f colorSpace:(CGColorSpaceRef)cs CF_RETURNS_RETAINED; -- (CGLayerRef)createCGLayerWithSize:(CGSize)size info:(CFDictionaryRef)d CF_RETURNS_RETAINED; -@end extern NSString* const QCRendererEventKey; -@protocol QCCompositionRenderer - (NSDictionary*) attributes; -@end @interface QCRenderer : NSObject <QCCompositionRenderer> { -} -- (id) createSnapshotImageOfType:(NSString*)type NS_RETURNS_RETAINED; -@end extern NSString* const QCViewDidStartRenderingNotification; -@interface QCView : NSView <QCCompositionRenderer> { -} -- (id) createSnapshotImageOfType:(NSString*)type NS_RETURNS_RETAINED; -@end enum { -ICEXIFOrientation1 = 1, ICEXIFOrientation2 = 2, ICEXIFOrientation3 = 3, ICEXIFOrientation4 = 4, ICEXIFOrientation5 = 5, ICEXIFOrientation6 = 6, ICEXIFOrientation7 = 7, ICEXIFOrientation8 = 8, }; -@class ICDevice; -@protocol ICDeviceDelegate <NSObject> @required - (void)didRemoveDevice:(ICDevice*)device; -@end extern NSString *const ICScannerStatusWarmingUp; -@class ICScannerDevice; -@protocol ICScannerDeviceDelegate <ICDeviceDelegate> @optional - (void)scannerDeviceDidBecomeAvailable:(ICScannerDevice*)scanner; -@end - -typedef long unsigned int __darwin_size_t; -typedef __darwin_size_t size_t; -typedef unsigned long CFTypeID; -struct CGPoint { - CGFloat x; - CGFloat y; -}; -typedef struct CGPoint CGPoint; -typedef struct CGGradient *CGGradientRef; -typedef uint32_t CGGradientDrawingOptions; -extern CFTypeID CGGradientGetTypeID(void); -extern CGGradientRef CGGradientCreateWithColorComponents(CGColorSpaceRef - space, const CGFloat components[], const CGFloat locations[], size_t count) CF_RETURNS_RETAINED; -extern CGGradientRef CGGradientCreateWithColors(CGColorSpaceRef space, - CFArrayRef colors, const CGFloat locations[]) CF_RETURNS_RETAINED; -extern CGGradientRef CGGradientRetain(CGGradientRef gradient); - -CF_IMPLICIT_BRIDGING_ENABLED - -extern void CGGradientRelease(CGGradientRef gradient); - -CF_IMPLICIT_BRIDGING_DISABLED - -typedef struct CGContext *CGContextRef; -extern void CGContextDrawLinearGradient(CGContextRef context, - CGGradientRef gradient, CGPoint startPoint, CGPoint endPoint, - CGGradientDrawingOptions options); - -CF_IMPLICIT_BRIDGING_ENABLED - -extern CGColorSpaceRef CGColorSpaceCreateDeviceRGB(void); - -CF_IMPLICIT_BRIDGING_DISABLED - - -@interface NSMutableArray : NSObject -- (void)addObject:(id)object; -+ (instancetype)array; -@end - -// This is how NSMakeCollectable is declared in the OS X 10.8 headers. -id NSMakeCollectable(CFTypeRef __attribute__((cf_consumed))) __attribute__((ns_returns_retained)); - -typedef const struct __CFUUID * CFUUIDRef; - -extern -void *CFPlugInInstanceCreate(CFAllocatorRef allocator, CFUUIDRef factoryUUID, CFUUIDRef typeUUID); - -//===----------------------------------------------------------------------===// -// Test cases. -//===----------------------------------------------------------------------===// - -CFAbsoluteTime f1(void) { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(0, t); - CFRetain(date); - CFRelease(date); - CFDateGetAbsoluteTime(date); // no-warning - CFRelease(date); - t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released}} - return t; -} - -CFAbsoluteTime f2(void) { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(0, t); - [((NSDate*) date) retain]; - CFRelease(date); - CFDateGetAbsoluteTime(date); // no-warning - [((NSDate*) date) release]; - t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released}} - return t; -} - - -NSDate* global_x; - -// Test to see if we suppress an error when we store the pointer -// to a global. - -CFAbsoluteTime f3(void) { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(0, t); - [((NSDate*) date) retain]; - CFRelease(date); - CFDateGetAbsoluteTime(date); // no-warning - global_x = (NSDate*) date; - [((NSDate*) date) release]; - t = CFDateGetAbsoluteTime(date); // no-warning - return t; -} - -//--------------------------------------------------------------------------- -// Test case 'f4' differs for region store and basic store. See -// retain-release-region-store.m and retain-release-basic-store.m. -//--------------------------------------------------------------------------- - -// Test a leak. - -CFAbsoluteTime f5(int x) { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(0, t); // expected-warning{{leak}} - - if (x) - CFRelease(date); - - return t; -} - -// Test a leak involving the return. - -CFDateRef f6(int x) { - CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // expected-warning{{leak}} - CFRetain(date); - return date; -} - -// Test a leak involving an overwrite. - -CFDateRef f7(void) { - CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); //expected-warning{{leak}} - CFRetain(date); - date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // expected-warning {{leak}} - return date; -} - -// Generalization of Create rule. MyDateCreate returns a CFXXXTypeRef, and -// has the word create. - -CF_IMPLICIT_BRIDGING_ENABLED - -CFDateRef MyDateCreate(void); - -CF_IMPLICIT_BRIDGING_DISABLED - - -CFDateRef f8(void) { - CFDateRef date = MyDateCreate(); // expected-warning{{leak}} - CFRetain(date); - return date; -} - -__attribute__((cf_returns_retained)) CFDateRef f9(void) { - CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // no-warning - int *p = 0; - // When allocations fail, CFDateCreate can return null. - if (!date) *p = 1; // expected-warning{{null}} - return date; -} - -// Handle DiskArbitration API: -// -// http://developer.apple.com/DOCUMENTATION/DARWIN/Reference/DiscArbitrationFramework/ -// -void f10(io_service_t media, DADiskRef d, CFStringRef s) { - DADiskRef disk = DADiskCreateFromBSDName(kCFAllocatorDefault, 0, "hello"); // expected-warning{{leak}} - if (disk) NSLog(@"ok"); - - disk = DADiskCreateFromIOMedia(kCFAllocatorDefault, 0, media); // expected-warning{{leak}} - if (disk) NSLog(@"ok"); - - CFDictionaryRef dict = DADiskCopyDescription(d); // expected-warning{{leak}} - if (dict) NSLog(@"ok"); - - disk = DADiskCopyWholeDisk(d); // expected-warning{{leak}} - if (disk) NSLog(@"ok"); - - DADissenterRef dissenter = DADissenterCreate(kCFAllocatorDefault, // expected-warning{{leak}} - kDAReturnSuccess, s); - if (dissenter) NSLog(@"ok"); - - DASessionRef session = DASessionCreate(kCFAllocatorDefault); // expected-warning{{leak}} - if (session) NSLog(@"ok"); -} - -// Test retain/release checker with CFString and CFMutableArray. -void f11(void) { - // Create the array. - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); - - // Create a string. - CFStringRef s1 = CFStringCreateWithCString(0, "hello world", - kCFStringEncodingUTF8); - - // Add the string to the array. - CFArrayAppendValue(A, s1); - - // Decrement the reference count. - CFRelease(s1); // no-warning - - // Get the string. We don't own it. - s1 = (CFStringRef) CFArrayGetValueAtIndex(A, 0); - - // Release the array. - CFRelease(A); // no-warning - - // Release the string. This is a bug. - CFRelease(s1); // expected-warning{{Incorrect decrement of the reference count}} -} - -// PR 3337: Handle functions declared using typedefs. -typedef CFTypeRef CREATEFUN(void); - -CF_IMPLICIT_BRIDGING_ENABLED - -CFTypeRef MyCreateFun(void); - -CF_IMPLICIT_BRIDGING_DISABLED - - -void f12(void) { - CFTypeRef o = MyCreateFun(); // expected-warning {{leak}} -} - -void f13_autorelease(void) { - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning - [(id) A autorelease]; // no-warning -} - -void f13_autorelease_b(void) { - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); - [(id) A autorelease]; - [(id) A autorelease]; -} // expected-warning{{Object autoreleased too many times}} - -CFMutableArrayRef f13_autorelease_c(void) { - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); - [(id) A autorelease]; - [(id) A autorelease]; - return A; // expected-warning{{Object autoreleased too many times}} -} - -CFMutableArrayRef f13_autorelease_d(void) { - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); - [(id) A autorelease]; - [(id) A autorelease]; - CFMutableArrayRef B = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{Object autoreleased too many times}} - CFRelease(B); // no-warning - while (1) {} -} - - -// This case exercises the logic where the leak site is the same as the allocation site. -void f14_leakimmediately(void) { - CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{leak}} -} - -// Test that we track an allocated object beyond the point where the *name* -// of the variable storing the reference is no longer live. -void f15(void) { - // Create the array. - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); - CFMutableArrayRef *B = &A; - // At this point, the name 'A' is no longer live. - CFRelease(*B); // no-warning -} - -// Test when we pass NULL to CFRetain/CFRelease/CFMakeCollectable/CFAutorelease. -void f16(int x, CFTypeRef p) { - if (p) - return; - - switch (x) { - case 0: - CFRelease(p); - break; - case 1: - CFRetain(p); - break; - case 2: - CFMakeCollectable(p); - break; - case 3: - CFAutorelease(p); - break; - default: - break; - } -} - -// Test that an object is non-null after CFRetain/CFRelease/CFMakeCollectable/CFAutorelease. -void f17(int x, CFTypeRef p) { - switch (x) { - case 0: - CFRelease(p); - if (!p) - CFRelease(0); // no-warning - break; - case 1: - CFRetain(p); - if (!p) - CFRetain(0); // no-warning - break; - case 2: - CFMakeCollectable(p); - if (!p) - CFMakeCollectable(0); // no-warning - break; - case 3: - CFAutorelease(p); - if (!p) - CFAutorelease(0); // no-warning - break; - default: - break; - } -} - -// Test basic tracking of ivars associated with 'self'. For the retain/release -// checker we currently do not want to flag leaks associated with stores -// of tracked objects to ivars. -@interface SelfIvarTest : NSObject { - id myObj; -} -- (void)test_self_tracking; -@end - -@implementation SelfIvarTest -- (void)test_self_tracking { - myObj = (id) CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} -@end - -// Test return of non-owned objects in contexts where an owned object -// is expected. -@interface TestReturnNotOwnedWhenExpectedOwned -- (NSString*)newString; -@end - -@implementation TestReturnNotOwnedWhenExpectedOwned -- (NSString*)newString { - NSString *s = [NSString stringWithUTF8String:"hello"]; - return s; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} -} -@end - -int isFoo(char c); - -static void rdar_6659160(char *inkind, char *inname) -{ - // We currently expect that [NSObject alloc] cannot fail. This - // will be a toggled flag in the future. It can indeed return null, but - // Cocoa programmers generally aren't expected to reason about out-of-memory - // conditions. - NSString *kind = [[NSString alloc] initWithUTF8String:inkind]; // expected-warning{{leak}} - - // We do allow stringWithUTF8String to fail. This isn't really correct, as - // far as returning 0. In most error conditions it will throw an exception. - // If allocation fails it could return 0, but again this - // isn't expected. - NSString *name = [NSString stringWithUTF8String:inname]; - if(!name) - return; - - const char *kindC = 0; - const char *nameC = 0; - - // In both cases, we cannot reach a point down below where we - // dereference kindC or nameC with either being null. This is because - // we assume that [NSObject alloc] doesn't fail and that we have the guard - // up above. - - if(kind) - kindC = [kind UTF8String]; - if(name) - nameC = [name UTF8String]; - if(!isFoo(kindC[0])) // expected-warning{{null}} - return; - if(!isFoo(nameC[0])) // no-warning - return; - - [kind release]; - [name release]; // expected-warning{{Incorrect decrement of the reference count}} -} - -// PR 3677 - 'allocWithZone' should be treated as following the Cocoa naming -// conventions with respect to 'return'ing ownership. -@interface PR3677: NSObject @end -@implementation PR3677 -+ (id)allocWithZone:(NSZone *)inZone { - return [super allocWithZone:inZone]; // no-warning -} -@end - -// PR 3820 - Reason about calls to -dealloc -void pr3820_DeallocInsteadOfRelease(void) -{ - id foo = [[NSString alloc] init]; // no-warning - [foo dealloc]; - // foo is not leaked, since it has been deallocated. -} - -void pr3820_ReleaseAfterDealloc(void) -{ - id foo = [[NSString alloc] init]; - [foo dealloc]; - [foo release]; // expected-warning{{used after it is release}} - // NSInternalInconsistencyException: message sent to deallocated object -} - -void pr3820_DeallocAfterRelease(void) -{ - NSLog(@"\n\n[%s]", __FUNCTION__); - id foo = [[NSString alloc] init]; - [foo release]; - [foo dealloc]; // expected-warning{{used after it is released}} - // message sent to released object -} - -// The problem here is that 'length' binds to '($0 - 1)' after '--length', but -// SimpleConstraintManager doesn't know how to reason about -// '($0 - 1) > constant'. As a temporary hack, we drop the value of '($0 - 1)' -// and conjure a new symbol. -void rdar6704930(unsigned char *s, unsigned int length) { - NSString* name = 0; - if (s != 0) { - if (length > 0) { - while (length > 0) { - if (*s == ':') { - ++s; - --length; - name = [[NSString alloc] init]; // no-warning - break; - } - ++s; - --length; - } - if ((length == 0) && (name != 0)) { - [name release]; - name = 0; - } - if (length == 0) { // no ':' found -> use it all as name - name = [[NSString alloc] init]; // no-warning - } - } - } - - if (name != 0) { - [name release]; - } -} - -//===----------------------------------------------------------------------===// -// One build of the analyzer accidentally stopped tracking the allocated -// object after the 'retain'. -//===----------------------------------------------------------------------===// - -@interface rdar_6833332 : NSObject <NSApplicationDelegate> { - NSWindow *window; -} -@property (nonatomic, retain) NSWindow *window; -@end - -@implementation rdar_6833332 -@synthesize window; -- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - NSMutableDictionary *dict = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; // expected-warning{{leak}} - - [dict setObject:@"foo" forKey:@"bar"]; - - NSLog(@"%@", dict); -} -- (void)dealloc { - [window release]; - [super dealloc]; -} - -- (void)radar10102244 { - NSMutableDictionary *dict = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; // expected-warning{{leak}} - if (window) - NSLog(@"%@", window); -} -@end - -//===----------------------------------------------------------------------===// -// clang checker fails to catch use-after-release -//===----------------------------------------------------------------------===// -int rdar_6257780_Case1(void) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - NSArray *array = [NSArray array]; - [array release]; // expected-warning{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} - [pool drain]; - return 0; -} - -//===----------------------------------------------------------------------===// -// Analyzer is confused about NSAutoreleasePool -allocWithZone:. -//===----------------------------------------------------------------------===// -void rdar_10640253_autorelease_allocWithZone(void) { - NSAutoreleasePool *pool = [[NSAutoreleasePool allocWithZone:(NSZone*)0] init]; - (void) pool; -} - -//===----------------------------------------------------------------------===// -// Checker should understand new/setObject:/release constructs -//===----------------------------------------------------------------------===// -void rdar_6866843(void) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] init]; - NSArray* array = [[NSArray alloc] init]; - [dictionary setObject:array forKey:@"key"]; - [array release]; - // Using 'array' here should be fine - NSLog(@"array = %@\n", array); // no-warning - // Now the array is released - [dictionary release]; - [pool drain]; -} - - -//===----------------------------------------------------------------------===// -// Classes typedef-ed to CF objects should get the same treatment as CF objects -//===----------------------------------------------------------------------===// -typedef CFTypeRef OtherRef; - -@interface RDar6877235 : NSObject {} -- (CFTypeRef)_copyCFTypeRef CF_RETURNS_RETAINED; -- (OtherRef)_copyOtherRef CF_RETURNS_RETAINED; -@end - -@implementation RDar6877235 -- (CFTypeRef)_copyCFTypeRef { - return [[NSString alloc] init]; // no-warning -} -- (OtherRef)_copyOtherRef { - return [[NSString alloc] init]; // no-warning -} -@end - -//===----------------------------------------------------------------------===// -// false positive - init method returns an object owned by caller -//===----------------------------------------------------------------------===// -@interface RDar6320065 : NSObject { - NSString *_foo; -} -- (instancetype)initReturningNewClass; -- (id)_initReturningNewClassBad; -- (instancetype)initReturningNewClassBad2; -@end - -@interface RDar6320065Subclass : RDar6320065 -@end - -@implementation RDar6320065 -- (instancetype)initReturningNewClass { - [self release]; - self = [[RDar6320065Subclass alloc] init]; // no-warning - return self; -} -- (id)_initReturningNewClassBad { - [self release]; - [[RDar6320065Subclass alloc] init]; // expected-warning {{leak}} - return self; -} -- (instancetype)initReturningNewClassBad2 { - [self release]; - self = [[RDar6320065Subclass alloc] init]; - return [self autorelease]; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} -} - -@end - -@implementation RDar6320065Subclass -@end - -int RDar6320065_test(void) { - RDar6320065 *test = [[RDar6320065 alloc] init]; // no-warning - [test release]; - return 0; -} - -//===----------------------------------------------------------------------===// -// -awakeAfterUsingCoder: returns an owned object and claims the receiver -//===----------------------------------------------------------------------===// -@interface RDar7129086 : NSObject {} @end -@implementation RDar7129086 -- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder { - [self release]; // no-warning - return [NSString alloc]; // no-warning -} -@end - -//===----------------------------------------------------------------------===// -// [NSData dataWithBytesNoCopy] does not return a retained object -//===----------------------------------------------------------------------===// -@interface RDar6859457 : NSObject {} -- (NSString*) NoCopyString; -- (NSString*) noCopyString; -@end - -@implementation RDar6859457 -- (NSString*) NoCopyString { return [[NSString alloc] init]; } // expected-warning{{leak}} -- (NSString*) noCopyString { return [[NSString alloc] init]; } // expected-warning{{leak}} -@end - -void test_RDar6859457(RDar6859457 *x, void *bytes, NSUInteger dataLength) { - [x NoCopyString]; // expected-warning{{leak}} - [x noCopyString]; // expected-warning{{leak}} - [NSData dataWithBytesNoCopy:bytes length:dataLength]; // no-warning - [NSData dataWithBytesNoCopy:bytes length:dataLength freeWhenDone:1]; // no-warning -} - -//===----------------------------------------------------------------------===// -// PR 4230 - an autorelease pool is not necessarily leaked during a premature -// return -//===----------------------------------------------------------------------===// - -static void PR4230(void) -{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // no-warning - NSString *object = [[[NSString alloc] init] autorelease]; // no-warning - return; -} - -static void PR4230_new(void) -{ - NSAutoreleasePool *pool = [NSAutoreleasePool new]; // no-warning - NSString *object = [[[NSString alloc] init] autorelease]; // no-warning - return; -} - -//===----------------------------------------------------------------------===// -// Method name that has a null IdentifierInfo* for its first selector slot. -// This test just makes sure that we handle it. -//===----------------------------------------------------------------------===// -@interface TestNullIdentifier -@end - -@implementation TestNullIdentifier -+ (id):(int)x, ... { - return [[NSString alloc] init]; // expected-warning{{leak}} -} -@end - -//===----------------------------------------------------------------------===// -// don't flag leaks for return types that cannot be determined to be CF types -//===----------------------------------------------------------------------===// - -// We don't know if 'struct s6893565' represents a Core Foundation type, so -// we shouldn't emit an error here. -typedef struct s6893565* TD6893565; - -@interface RDar6893565 {} --(TD6893565)newThing; -@end - -@implementation RDar6893565 --(TD6893565)newThing { - return (TD6893565) [[NSString alloc] init]; // no-warning -} -@end - -//===----------------------------------------------------------------------===// -// clang: false positives w/QC and CoreImage methods -//===----------------------------------------------------------------------===// -void rdar6902710(QCView *view, QCRenderer *renderer, CIContext *context, - NSString *str, CIImage *img, CGRect rect, - CIFormat form, CGColorSpaceRef cs) { - [view createSnapshotImageOfType:str]; // expected-warning{{leak}} - [renderer createSnapshotImageOfType:str]; // expected-warning{{leak}} - [context createCGImage:img fromRect:rect]; // expected-warning{{leak}} - [context createCGImage:img fromRect:rect format:form colorSpace:cs]; // expected-warning{{leak}} -} - -//===----------------------------------------------------------------------===// -// -[CIContext createCGLayerWithSize:info:] misinterpreted by clang scan-build -//===----------------------------------------------------------------------===// -void rdar6945561(CIContext *context, CGSize size, CFDictionaryRef d) { - [context createCGLayerWithSize:size info:d]; // expected-warning{{leak}} -} - -//===----------------------------------------------------------------------===// -// Add knowledge of IOKit functions to retain/release checker. -//===----------------------------------------------------------------------===// -void IOBSDNameMatching_wrapper(mach_port_t mainPort, uint32_t options, const char * bsdName) { - IOBSDNameMatching(mainPort, options, bsdName); // expected-warning{{leak}} -} - -void IOServiceMatching_wrapper(const char * name) { - IOServiceMatching(name); // expected-warning{{leak}} -} - -void IOServiceNameMatching_wrapper(const char * name) { - IOServiceNameMatching(name); // expected-warning{{leak}} -} - -CF_RETURNS_RETAINED CFDictionaryRef CreateDict(void); - -void IOServiceAddNotification_wrapper(mach_port_t mainPort, const io_name_t notificationType, - mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) { - - CFDictionaryRef matching = CreateDict(); - CFRelease(matching); - IOServiceAddNotification(mainPort, notificationType, matching, // expected-warning{{used after it is released}} expected-warning{{deprecated}} - wakePort, reference, notification); -} - -void IORegistryEntryIDMatching_wrapper(uint64_t entryID ) { - IORegistryEntryIDMatching(entryID); // expected-warning{{leak}} -} - -void IOOpenFirmwarePathMatching_wrapper(mach_port_t mainPort, uint32_t options, - const char * path) { - IOOpenFirmwarePathMatching(mainPort, options, path); // expected-warning{{leak}} -} - -void IOServiceGetMatchingService_wrapper(mach_port_t mainPort) { - CFDictionaryRef matching = CreateDict(); - IOServiceGetMatchingService(mainPort, matching); - CFRelease(matching); // expected-warning{{used after it is released}} -} - -void IOServiceGetMatchingServices_wrapper(mach_port_t mainPort, io_iterator_t *existing) { - CFDictionaryRef matching = CreateDict(); - IOServiceGetMatchingServices(mainPort, matching, existing); - CFRelease(matching); // expected-warning{{used after it is released}} -} - -void IOServiceAddMatchingNotification_wrapper(IONotificationPortRef notifyPort, const io_name_t notificationType, - IOServiceMatchingCallback callback, void * refCon, io_iterator_t * notification) { - - CFDictionaryRef matching = CreateDict(); - IOServiceAddMatchingNotification(notifyPort, notificationType, matching, callback, refCon, notification); - CFRelease(matching); // expected-warning{{used after it is released}} -} - -//===----------------------------------------------------------------------===// -// Test of handling objects whose references "escape" to containers. -//===----------------------------------------------------------------------===// -void CFDictionaryAddValue(CFMutableDictionaryRef, void *, void *); - -void rdar_6539791(CFMutableDictionaryRef y, void* key, void* val_key) { - CFMutableDictionaryRef x = CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - CFDictionaryAddValue(y, key, x); - CFRelease(x); // the dictionary keeps a reference, so the object isn't deallocated yet - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); - if (value) { - CFDictionaryAddValue(x, val_key, (void*)value); // no-warning - CFRelease(value); - CFDictionaryAddValue(y, val_key, (void*)value); // no-warning - } -} - -// Same issue, except with "AppendValue" functions. -void rdar_6560661(CFMutableArrayRef x) { - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); - // CFArrayAppendValue keeps a reference to value. - CFArrayAppendValue(x, value); - CFRelease(value); - CFRetain(value); - CFRelease(value); // no-warning -} - -// Same issue, excwept with "CFAttributeStringSetAttribute". -void rdar_7152619(CFStringRef str) { - CFAttributedStringRef string = CFAttributedStringCreate(kCFAllocatorDefault, str, 0); - CFMutableAttributedStringRef attrString = CFAttributedStringCreateMutableCopy(kCFAllocatorDefault, 100, string); - CFRelease(string); - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}} - CFAttributedStringSetAttribute(attrString, CFRangeMake(0, 1), str, number); - [number release]; - [number retain]; - CFRelease(attrString); -} - -//===----------------------------------------------------------------------===// -// Test of handling CGGradientXXX functions. -//===----------------------------------------------------------------------===// - -void rdar_7184450(CGContextRef myContext, CGFloat x, CGPoint myStartPoint, - CGPoint myEndPoint) { - size_t num_locations = 6; - CGFloat locations[6] = { 0.0, 0.265, 0.28, 0.31, 0.36, 1.0 }; - CGFloat components[28] = { 239.0/256.0, 167.0/256.0, 170.0/256.0, - x, // Start color - 207.0/255.0, 39.0/255.0, 39.0/255.0, x, - 147.0/255.0, 21.0/255.0, 22.0/255.0, x, - 175.0/255.0, 175.0/255.0, 175.0/255.0, x, - 255.0/255.0,255.0/255.0, 255.0/255.0, x, - 255.0/255.0,255.0/255.0, 255.0/255.0, x - }; // End color - - CGGradientRef myGradient = - CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), // expected-warning{{leak}} - components, locations, num_locations); - - CGContextDrawLinearGradient(myContext, myGradient, myStartPoint, myEndPoint, - 0); - CGGradientRelease(myGradient); -} - -void rdar_7184450_pos(CGContextRef myContext, CGFloat x, CGPoint myStartPoint, - CGPoint myEndPoint) { - size_t num_locations = 6; - CGFloat locations[6] = { 0.0, 0.265, 0.28, 0.31, 0.36, 1.0 }; - CGFloat components[28] = { 239.0/256.0, 167.0/256.0, 170.0/256.0, - x, // Start color - 207.0/255.0, 39.0/255.0, 39.0/255.0, x, - 147.0/255.0, 21.0/255.0, 22.0/255.0, x, - 175.0/255.0, 175.0/255.0, 175.0/255.0, x, - 255.0/255.0,255.0/255.0, 255.0/255.0, x, - 255.0/255.0,255.0/255.0, 255.0/255.0, x - }; // End color - - CGGradientRef myGradient = - CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), components, locations, num_locations); // expected-warning 2 {{leak}} - - CGContextDrawLinearGradient(myContext, myGradient, myStartPoint, myEndPoint, - 0); -} - -//===----------------------------------------------------------------------===// -// clang false positive: retained instance passed to thread in pthread_create -// marked as leak -// -// Until we have full IPA, the analyzer should stop tracking the reference -// count of objects passed to pthread_create. -// -//===----------------------------------------------------------------------===// -struct _opaque_pthread_t {}; -struct _opaque_pthread_attr_t {}; -typedef struct _opaque_pthread_t *__darwin_pthread_t; -typedef struct _opaque_pthread_attr_t __darwin_pthread_attr_t; -typedef __darwin_pthread_t pthread_t; -typedef __darwin_pthread_attr_t pthread_attr_t; -typedef unsigned long __darwin_pthread_key_t; -typedef __darwin_pthread_key_t pthread_key_t; - -int pthread_create(pthread_t *, const pthread_attr_t *, - void *(*)(void *), void *); - -int pthread_setspecific(pthread_key_t key, const void *value); - -void *rdar_7299394_start_routine(void *p) { - [((id) p) release]; - return 0; -} -void rdar_7299394(pthread_attr_t *attr, pthread_t *thread, void *args) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - pthread_create(thread, attr, rdar_7299394_start_routine, number); -} -void rdar_7299394_positive(pthread_attr_t *attr, pthread_t *thread) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}} -} - -//===----------------------------------------------------------------------===// -// false positive with not understanding thread local storage -//===----------------------------------------------------------------------===// -void rdar11282706(pthread_key_t key) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - pthread_setspecific(key, (void*) number); -} - -//===----------------------------------------------------------------------===// -// False leak associated with call to CVPixelBufferCreateWithBytes () -// -// According to the Core Video Reference (ADC), CVPixelBufferCreateWithBytes and -// CVPixelBufferCreateWithPlanarBytes can release (via a callback) the -// pixel buffer object. These test cases show how the analyzer stops tracking -// the reference count for the objects passed for this argument. This -// could be made smarter. -//===----------------------------------------------------------------------===// -typedef int int32_t; -typedef UInt32 FourCharCode; -typedef FourCharCode OSType; -typedef uint64_t CVOptionFlags; -typedef int32_t CVReturn; -typedef struct __CVBuffer *CVBufferRef; -typedef CVBufferRef CVImageBufferRef; -typedef CVImageBufferRef CVPixelBufferRef; -typedef void (*CVPixelBufferReleaseBytesCallback)( void *releaseRefCon, const void *baseAddress ); - -extern CVReturn CVPixelBufferCreateWithBytes(CFAllocatorRef allocator, - size_t width, - size_t height, - OSType pixelFormatType, - void *baseAddress, - size_t bytesPerRow, - CVPixelBufferReleaseBytesCallback releaseCallback, - void *releaseRefCon, - CFDictionaryRef pixelBufferAttributes, - CVPixelBufferRef *pixelBufferOut) ; - -typedef void (*CVPixelBufferReleasePlanarBytesCallback)( void *releaseRefCon, const void *dataPtr, size_t dataSize, size_t numberOfPlanes, const void *planeAddresses[] ); - -extern CVReturn CVPixelBufferCreateWithPlanarBytes(CFAllocatorRef allocator, - size_t width, - size_t height, - OSType pixelFormatType, - void *dataPtr, - size_t dataSize, - size_t numberOfPlanes, - void *planeBaseAddress[], - size_t planeWidth[], - size_t planeHeight[], - size_t planeBytesPerRow[], - CVPixelBufferReleasePlanarBytesCallback releaseCallback, - void *releaseRefCon, - CFDictionaryRef pixelBufferAttributes, - CVPixelBufferRef *pixelBufferOut) ; - -extern CVReturn CVPixelBufferCreateWithBytes(CFAllocatorRef allocator, - size_t width, - size_t height, - OSType pixelFormatType, - void *baseAddress, - size_t bytesPerRow, - CVPixelBufferReleaseBytesCallback releaseCallback, - void *releaseRefCon, - CFDictionaryRef pixelBufferAttributes, - CVPixelBufferRef *pixelBufferOut) ; - -CVReturn rdar_7283567(CFAllocatorRef allocator, size_t width, size_t height, - OSType pixelFormatType, void *baseAddress, - size_t bytesPerRow, - CVPixelBufferReleaseBytesCallback releaseCallback, - CFDictionaryRef pixelBufferAttributes, - CVPixelBufferRef *pixelBufferOut) { - - // For the allocated object, it doesn't really matter what type it is - // for the purpose of this test. All we want to show is that - // this is freed later by the callback. - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - - return CVPixelBufferCreateWithBytes(allocator, width, height, pixelFormatType, - baseAddress, bytesPerRow, releaseCallback, - number, // potentially released by callback - pixelBufferAttributes, pixelBufferOut) ; -} - -CVReturn rdar_7283567_2(CFAllocatorRef allocator, size_t width, size_t height, - OSType pixelFormatType, void *dataPtr, size_t dataSize, - size_t numberOfPlanes, void *planeBaseAddress[], - size_t planeWidth[], size_t planeHeight[], size_t planeBytesPerRow[], - CVPixelBufferReleasePlanarBytesCallback releaseCallback, - CFDictionaryRef pixelBufferAttributes, - CVPixelBufferRef *pixelBufferOut) { - - // For the allocated object, it doesn't really matter what type it is - // for the purpose of this test. All we want to show is that - // this is freed later by the callback. - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - - return CVPixelBufferCreateWithPlanarBytes(allocator, - width, height, pixelFormatType, dataPtr, dataSize, - numberOfPlanes, planeBaseAddress, planeWidth, - planeHeight, planeBytesPerRow, releaseCallback, - number, // potentially released by callback - pixelBufferAttributes, pixelBufferOut) ; -} - -//===----------------------------------------------------------------------===// -// False leak associated with CGBitmapContextCreateWithData -//===----------------------------------------------------------------------===// -typedef uint32_t CGBitmapInfo; -typedef void (*CGBitmapContextReleaseDataCallback)(void *releaseInfo, void *data); - -CGContextRef CGBitmapContextCreateWithData(void *data, - size_t width, size_t height, size_t bitsPerComponent, - size_t bytesPerRow, CGColorSpaceRef space, CGBitmapInfo bitmapInfo, - CGBitmapContextReleaseDataCallback releaseCallback, void *releaseInfo) CF_RETURNS_RETAINED; - -void rdar_7358899(void *data, - size_t width, size_t height, size_t bitsPerComponent, - size_t bytesPerRow, CGColorSpaceRef space, CGBitmapInfo bitmapInfo, - CGBitmapContextReleaseDataCallback releaseCallback) { - - // For the allocated object, it doesn't really matter what type it is - // for the purpose of this test. All we want to show is that - // this is freed later by the callback. - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - - CGBitmapContextCreateWithData(data, width, height, bitsPerComponent, // expected-warning{{leak}} - bytesPerRow, space, bitmapInfo, releaseCallback, number); -} - -//===----------------------------------------------------------------------===// -// Allow 'new', 'copy', 'alloc', 'init' prefix to start before '_' when -// determining Cocoa fundamental rule. -// -// Previously the retain/release checker just skipped prefixes before the -// first '_' entirely. Now the checker honors the prefix if it results in a -// recognizable naming convention (e.g., 'new', 'init'). -//===----------------------------------------------------------------------===// -@interface RDar7265711 {} -- (id) new_stuff; -@end - -void rdar7265711_a(RDar7265711 *x) { - id y = [x new_stuff]; // expected-warning{{leak}} -} - -void rdar7265711_b(RDar7265711 *x) { - id y = [x new_stuff]; // no-warning - [y release]; -} - -//===----------------------------------------------------------------------===// -// clang thinks [NSCursor dragCopyCursor] returns a retained reference -//===----------------------------------------------------------------------===// -@interface NSCursor : NSObject -+ (NSCursor *)dragCopyCursor; -@end - -void rdar7306898(void) { - // 'dragCopyCursor' does not follow Cocoa's fundamental rule. It is a noun, not an sentence - // implying a 'copy' of something. - NSCursor *c = [NSCursor dragCopyCursor]; // no-warning - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}} -} - -//===----------------------------------------------------------------------===// -// Sending 'release', 'retain', etc. to a Class directly is not likely what the -// user intended. -//===----------------------------------------------------------------------===// -@interface RDar7252064 : NSObject @end -void rdar7252064(void) { - [RDar7252064 release]; // expected-warning{{The 'release' message should be sent to instances of class 'RDar7252064' and not the class directly}} - [RDar7252064 retain]; // expected-warning{{The 'retain' message should be sent to instances of class 'RDar7252064' and not the class directly}} - [RDar7252064 autorelease]; // expected-warning{{The 'autorelease' message should be sent to instances of class 'RDar7252064' and not the class directly}} - [NSAutoreleasePool drain]; // expected-warning{{method '+drain' not found}} expected-warning{{The 'drain' message should be sent to instances of class 'NSAutoreleasePool' and not the class directly}} -} - -//===----------------------------------------------------------------------===// -// Tests of ownership attributes. -//===----------------------------------------------------------------------===// - -typedef NSString* MyStringTy; - -@protocol FooP; - -@interface TestOwnershipAttr : NSObject -- (NSString*) returnsAnOwnedString NS_RETURNS_RETAINED; // no-warning -- (NSString*) returnsAnOwnedCFString CF_RETURNS_RETAINED; // no-warning -- (MyStringTy) returnsAnOwnedTypedString NS_RETURNS_RETAINED; // no-warning -- (NSString*) newString NS_RETURNS_NOT_RETAINED; // no-warning -- (NSString*) newString_auto NS_RETURNS_AUTORELEASED; // no-warning -- (NSString*) newStringNoAttr; -- (int) returnsAnOwnedInt NS_RETURNS_RETAINED; // expected-warning{{'ns_returns_retained' attribute only applies to methods that return an Objective-C object}} -- (id) pseudoInit NS_CONSUMES_SELF NS_RETURNS_RETAINED; -+ (void) consume:(id) NS_CONSUMED x; -+ (void) consume2:(id) CF_CONSUMED x; -@end - -static int ownership_attribute_doesnt_go_here NS_RETURNS_RETAINED; // expected-warning{{'ns_returns_retained' attribute only applies to functions and methods}} - -void test_attr_1(TestOwnershipAttr *X) { - NSString *str = [X returnsAnOwnedString]; // expected-warning{{leak}} -} - -void test_attr_1b(TestOwnershipAttr *X) { - NSString *str = [X returnsAnOwnedCFString]; // expected-warning{{leak}} -} - -void test_attr1c(TestOwnershipAttr *X) { - NSString *str = [X newString]; // no-warning - NSString *str2 = [X newStringNoAttr]; // expected-warning{{leak}} - NSString *str3 = [X newString_auto]; // no-warning - NSString *str4 = [[X newString_auto] retain]; // expected-warning {{leak}} -} - -void testattr2_a(void) { - TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // expected-warning{{leak}} -} - -void testattr2_b(void) { - TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; // expected-warning{{leak}} -} - -void testattr2_b_11358224_self_assign_looses_the_leak(void) { - TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit];// expected-warning{{leak}} - x = x; -} - -void testattr2_c(void) { - TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; // no-warning - [x release]; -} - -void testattr3(void) { - TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // no-warning - [TestOwnershipAttr consume:x]; - TestOwnershipAttr *y = [TestOwnershipAttr alloc]; // no-warning - [TestOwnershipAttr consume2:y]; -} - -void consume_ns(id NS_CONSUMED x); -void consume_cf(id CF_CONSUMED x); - -void testattr4(void) { - TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // no-warning - consume_ns(x); - TestOwnershipAttr *y = [TestOwnershipAttr alloc]; // no-warning - consume_cf(y); -} - -@interface TestOwnershipAttr2 : NSObject -- (NSString*) newString NS_RETURNS_NOT_RETAINED; // no-warning -@end - -@implementation TestOwnershipAttr2 -- (NSString*) newString { - return [NSString alloc]; // expected-warning {{Potential leak of an object}} -} -@end - -@interface MyClassTestCFAttr : NSObject {} -- (NSDate*) returnsCFRetained CF_RETURNS_RETAINED; -- (CFDateRef) returnsCFRetainedAsCF CF_RETURNS_RETAINED; -- (CFDateRef) newCFRetainedAsCF CF_RETURNS_NOT_RETAINED; -- (CFDateRef) newCFRetainedAsCFNoAttr CF_RETURNS_RETAINED; -- (NSDate*) alsoReturnsRetained; -- (CFDateRef) alsoReturnsRetainedAsCF CF_RETURNS_NOT_RETAINED; -- (NSDate*) returnsNSRetained NS_RETURNS_RETAINED; -@end - -CF_RETURNS_RETAINED -CFDateRef returnsRetainedCFDate(void) { - return CFDateCreate(0, CFAbsoluteTimeGetCurrent()); -} - -@implementation MyClassTestCFAttr -- (NSDate*) returnsCFRetained { - return (NSDate*) returnsRetainedCFDate(); // No leak. -} - -- (CFDateRef) returnsCFRetainedAsCF { - return returnsRetainedCFDate(); // No leak. -} - -- (CFDateRef) newCFRetainedAsCF { - return (CFDateRef)[(id)[self returnsCFRetainedAsCF] autorelease]; -} - -- (CFDateRef) newCFRetainedAsCFNoAttr { - return (CFDateRef)[(id)[self returnsCFRetainedAsCF] autorelease]; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} -} - -- (NSDate*) alsoReturnsRetained { - return (NSDate*) returnsRetainedCFDate(); // expected-warning{{leak}} -} - -- (CFDateRef) alsoReturnsRetainedAsCF { - return returnsRetainedCFDate(); // expected-warning{{leak}} -} - - -- (NSDate*) returnsNSRetained { - return (NSDate*) returnsRetainedCFDate(); // no-warning -} -@end - -//===----------------------------------------------------------------------===// -// Test that leaks post-dominated by "panic" functions are not reported. -// -// Do not report a leak when post-dominated by a call to a noreturn or panic -// function. -//===----------------------------------------------------------------------===// -void panic(void) __attribute__((noreturn)); -void panic_not_in_hardcoded_list(void) __attribute__((noreturn)); - -void test_panic_negative(void) { - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // expected-warning{{leak}} -} - -void test_panic_positive(void) { - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // no-warning - panic(); -} - -void test_panic_neg_2(int x) { - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // expected-warning{{leak}} - if (x) - panic(); -} - -void test_panic_pos_2(int x) { - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // no-warning - if (x) - panic(); - if (!x) { - // This showed up previously where we silently missed checking the function - // type for noreturn. "panic()" is a hard-coded known panic function that - // isn't always noreturn. - panic_not_in_hardcoded_list(); - } -} - -//===----------------------------------------------------------------------===// -// Test uses of blocks (closures) -//===----------------------------------------------------------------------===// - -void test_blocks_1_pos(void) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}} - ^{}(); -} - -void test_blocks_1_indirect_release(void) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - ^{ [number release]; }(); -} - -void test_blocks_1_indirect_retain(void) { - // Eventually this should be reported as a leak. - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - ^{ [number retain]; }(); -} - -void test_blocks_1_indirect_release_via_call(void) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - ^(NSObject *o){ [o release]; }(number); -} - -void test_blocks_1_indirect_retain_via_call(void) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning {{leak}} - ^(NSObject *o){ [o retain]; }(number); -} - -//===--------------------------------------------------------------------===// -// Test sending message to super that returns an object alias. Previously -// this caused a crash in the analyzer. -//===--------------------------------------------------------------------===// - -@interface Rdar8015556 : NSObject {} @end -@implementation Rdar8015556 -- (id)retain { - return [super retain]; -} -@end - -// Correcly handle Class<...> in Cocoa Conventions detector. -@protocol Prot_R8272168 @end -Class <Prot_R8272168> GetAClassThatImplementsProt_R8272168(void); -void r8272168(void) { - GetAClassThatImplementsProt_R8272168(); -} - -// Test case which in the past triggered a false positive. -@interface RDar8356342 -- (NSDate*) rdar8356342:(NSDate *)inValue; -@end - -@implementation RDar8356342 -- (NSDate*) rdar8356342:(NSDate*)inValue { - NSDate *outValue = inValue; - if (outValue == 0) - outValue = [[NSDate alloc] init]; // no-warning - - if (outValue != inValue) - [outValue autorelease]; - - return outValue; -} -@end - -// This test case previously crashed because of a bug in BugReporter. -extern const void *CFDictionaryGetValue(CFDictionaryRef theDict, const void *key) CF_RETURNS_NOT_RETAINED; -typedef struct __CFError * CFErrorRef; -extern const CFStringRef kCFErrorUnderlyingErrorKey; -extern CFDictionaryRef CFErrorCopyUserInfo(CFErrorRef err) CF_RETURNS_RETAINED; -static void rdar_8724287(CFErrorRef error) -{ - CFErrorRef error_to_dump; - - error_to_dump = error; - while (error_to_dump != ((void*)0)) { - CFDictionaryRef info; - - info = CFErrorCopyUserInfo(error_to_dump); // expected-warning{{Potential leak of an object}} - - if (info != ((void*)0)) { - } - - error_to_dump = (CFErrorRef) CFDictionaryGetValue(info, kCFErrorUnderlyingErrorKey); - } -} - -// Make sure the model applies cf_consumed correctly in argument positions -// besides the first. - -CF_IMPLICIT_BRIDGING_ENABLED - -extern void *CFStringCreate(void); - -CF_IMPLICIT_BRIDGING_DISABLED - -extern void rdar_9234108_helper(void *key, void * CF_CONSUMED value); -void rdar_9234108(void) { - rdar_9234108_helper(0, CFStringCreate()); -} - -// Make sure that objc_method_family works to override naming conventions. -struct TwoDoubles { - double one; - double two; -}; -typedef struct TwoDoubles TwoDoubles; - -@interface NSValue (Mine) -- (id)_prefix_initWithTwoDoubles:(TwoDoubles)twoDoubles __attribute__((objc_method_family(init))); -@end - -@implementation NSValue (Mine) -- (id)_prefix_initWithTwoDoubles:(TwoDoubles)twoDoubles -{ - return [self init]; -} -@end - -void rdar9726279(void) { - TwoDoubles twoDoubles = { 0.0, 0.0 }; - NSValue *value = [[NSValue alloc] _prefix_initWithTwoDoubles:twoDoubles]; - [value release]; -} - -// Test camelcase support for CF conventions. While Core Foundation APIs -// don't use camel casing, other code is allowed to use it. -CFArrayRef camelcase_create_1(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef camelcase_createno(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}} -} - -CFArrayRef camelcase_copy(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef camelcase_copying(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}} -} - -CFArrayRef copyCamelCase(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef __copyCamelCase(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef __createCamelCase(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef camel_create(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - - -CFArrayRef camel_creat(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}} -} - -CFArrayRef camel_copy(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef camel_copyMachine(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef camel_copymachine(void) { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}} -} - -@protocol F18P -- (id) clone; -@end -@interface F18 : NSObject<F18P> @end -@interface F18(Cat) -- (id) clone NS_RETURNS_RETAINED; -@end - -@implementation F18 -- (id) clone { - return [F18 alloc]; -} -@end - -void rdar6582778(void) { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFTypeRef vals[] = { CFDateCreate(0, t) }; // expected-warning {{leak}} -} - -CFTypeRef global; - -void rdar6582778_2(void) { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - global = CFDateCreate(0, t); // no-warning -} - -// Test that objects passed to containers are marked "escaped". -void rdar10232019(void) { - NSMutableArray *array = [NSMutableArray array]; - - NSString *string = [[NSString alloc] initWithUTF8String:"foo"]; - [array addObject:string]; - [string release]; - - NSString *otherString = [string stringByAppendingString:@"bar"]; // no-warning - NSLog(@"%@", otherString); -} - -void rdar10232019_positive(void) { - NSMutableArray *array = [NSMutableArray array]; - - NSString *string = [[NSString alloc] initWithUTF8String:"foo"]; - [string release]; - - NSString *otherString = [string stringByAppendingString:@"bar"]; // expected-warning {{Reference-counted object is used after it is release}} - NSLog(@"%@", otherString); -} - -// RetainCountChecker support for XPC. -typedef void * xpc_object_t; -xpc_object_t _CFXPCCreateXPCObjectFromCFObject(CFTypeRef cf); -void xpc_release(xpc_object_t object); - -void rdar9658496(void) { - CFStringRef cf; - xpc_object_t xpc; - cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning - xpc = _CFXPCCreateXPCObjectFromCFObject( cf ); - CFRelease(cf); - xpc_release(xpc); -} - -// Support annotations with method families. -@interface RDar10824732 : NSObject -- (instancetype)initWithObj:(id CF_CONSUMED)obj; -@end - -@implementation RDar10824732 -- (instancetype)initWithObj:(id)obj { - [obj release]; - return [super init]; -} -@end - -void rdar_10824732(void) { - @autoreleasepool { - NSString *obj = @"test"; - RDar10824732 *foo = [[RDar10824732 alloc] initWithObj:obj]; // no-warning - [foo release]; - } -} - -// Stop tracking objects passed to functions, which take callbacks as parameters. -typedef int (*CloseCallback) (void *); -void ReaderForIO(CloseCallback ioclose, void *ioctx); -int IOClose(void *context); - -@protocol SInS <NSObject> -@end - -@interface radar10973977 : NSObject -- (id<SInS>)inputS; -- (void)reader; -@end - -@implementation radar10973977 -- (void)reader -{ - id<SInS> inputS = [[self inputS] retain]; - ReaderForIO(IOClose, inputS); -} -- (id<SInS>)inputS -{ - return 0; -} -@end - -// Object escapes through a selector callback -extern id NSApp; -@interface MySheetController -- (id<SInS>)inputS; -- (void)showDoSomethingSheetAction:(id)action; -- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo; -@end - -@implementation MySheetController -- (id<SInS>)inputS { - return 0; -} -- (void)showDoSomethingSheetAction:(id)action { - id<SInS> inputS = [[self inputS] retain]; - [NSApp beginSheet:0 - modalForWindow:0 - modalDelegate:0 - didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) - contextInfo:(void *)inputS]; // no - warning -} -- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { - - id contextObject = (id)contextInfo; - [contextObject release]; -} - -- (id)copyAutoreleaseRadar13081402 { - id x = [[[NSString alloc] initWithUTF8String:"foo"] autorelease]; - [x retain]; - return x; // no warning -} - -@end -//===----------------------------------------------------------------------===// -// Test returning allocated memory in a struct. -// -// We currently don't have a general way to track pointers that "escape". -// Here we test that RetainCountChecker doesn't get excited about returning -// allocated CF objects in struct fields. -//===----------------------------------------------------------------------===// -void *malloc(size_t); -struct rdar11104566 { CFStringRef myStr; }; -struct rdar11104566 test_rdar11104566(void) { - CFStringRef cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning - struct rdar11104566 V; - V.myStr = cf; - return V; // no-warning -} - -struct rdar11104566 *test_2_rdar11104566(void) { - CFStringRef cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning - struct rdar11104566 *V = (struct rdar11104566 *) malloc(sizeof(*V)); - V->myStr = cf; - return V; // no-warning -} - -//===----------------------------------------------------------------------===// -// ObjC literals support. -//===----------------------------------------------------------------------===// - -void test_objc_arrays(void) { - { // CASE ONE -- OBJECT IN ARRAY CREATED DIRECTLY - NSObject *o = [[NSObject alloc] init]; - NSArray *a = [[NSArray alloc] initWithObjects:o, (void*)0]; // expected-warning {{leak}} - [o release]; - [a description]; - [o description]; - } - - { // CASE TWO -- OBJECT IN ARRAY CREATED BY DUPING AUTORELEASED ARRAY - NSObject *o = [[NSObject alloc] init]; - NSArray *a1 = [NSArray arrayWithObjects:o, (void*)0]; - NSArray *a2 = [[NSArray alloc] initWithArray:a1]; // expected-warning {{leak}} - [o release]; - [a2 description]; - [o description]; - } - - { // CASE THREE -- OBJECT IN RETAINED @[] - NSObject *o = [[NSObject alloc] init]; - NSArray *a3 = [@[o] retain]; // expected-warning {{leak}} - [o release]; - [a3 description]; - [o description]; - } - - { // CASE FOUR -- OBJECT IN ARRAY CREATED BY DUPING @[] - NSObject *o = [[NSObject alloc] init]; - NSArray *a = [[NSArray alloc] initWithArray:@[o]]; // expected-warning {{leak}} - [o release]; - - [a description]; - [o description]; - } - - { // CASE FIVE -- OBJECT IN RETAINED @{} - NSValue *o = [[NSValue alloc] init]; - NSDictionary *a = [@{o : o} retain]; // expected-warning {{leak}} - [o release]; - - [a description]; - [o description]; - } -} - -void test_objc_integer_literals(void) { - id value = [@1 retain]; // expected-warning {{leak}} - [value description]; -} - -void test_objc_boxed_expressions(int x, const char *y) { - id value = [@(x) retain]; // expected-warning {{leak}} - [value description]; - - value = [@(y) retain]; // expected-warning {{leak}} - [value description]; -} - -// Test NSLog doesn't escape tracked objects. -void rdar11400885(int y) -{ - @autoreleasepool { - NSString *printString; - if(y > 2) - printString = [[NSString alloc] init]; - else - printString = [[NSString alloc] init]; - NSLog(@"Once %@", printString); - [printString release]; - NSLog(@"Again: %@", printString); // expected-warning {{Reference-counted object is used after it is released}} - } -} - -id makeCollectableNonLeak(void) { - extern CFTypeRef CFCreateSomething(void); - - CFTypeRef object = CFCreateSomething(); // +1 - CFRetain(object); // +2 - id objCObject = NSMakeCollectable(object); // +2 - [objCObject release]; // +1 - return [objCObject autorelease]; // +0 -} - - -void consumeAndStopTracking(id NS_CONSUMED obj, void (^callback)(void)); -void CFConsumeAndStopTracking(CFTypeRef CF_CONSUMED obj, void (^callback)(void)); - -void testConsumeAndStopTracking(void) { - id retained = [@[] retain]; // +1 - consumeAndStopTracking(retained, ^{}); // no-warning - - id doubleRetained = [[@[] retain] retain]; // +2 - consumeAndStopTracking(doubleRetained, ^{ - [doubleRetained release]; - }); // no-warning - - id unretained = @[]; // +0 - consumeAndStopTracking(unretained, ^{}); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} -} - -void testCFConsumeAndStopTracking(void) { - id retained = [@[] retain]; // +1 - CFConsumeAndStopTracking((CFTypeRef)retained, ^{}); // no-warning - - id doubleRetained = [[@[] retain] retain]; // +2 - CFConsumeAndStopTracking((CFTypeRef)doubleRetained, ^{ - [doubleRetained release]; - }); // no-warning - - id unretained = @[]; // +0 - CFConsumeAndStopTracking((CFTypeRef)unretained, ^{}); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} -} -//===----------------------------------------------------------------------===// -// Test 'pragma clang arc_cf_code_audited' support. -//===----------------------------------------------------------------------===// - -typedef void *MyCFType; -#pragma clang arc_cf_code_audited begin -MyCFType CreateMyCFType(void); -#pragma clang arc_cf_code_audited end - -void test_custom_cf(void) { - MyCFType x = CreateMyCFType(); // expected-warning {{leak of an object stored into 'x'}} -} - -//===----------------------------------------------------------------------===// -// Test calling CFPlugInInstanceCreate, which appears in CF but doesn't -// return a CF object. -//===----------------------------------------------------------------------===// - -void test_CFPlugInInstanceCreate(CFUUIDRef factoryUUID, CFUUIDRef typeUUID) { - CFPlugInInstanceCreate(kCFAllocatorDefault, factoryUUID, typeUUID); // no-warning -} - -//===----------------------------------------------------------------------===// -// PR14927: -drain only has retain-count semantics on NSAutoreleasePool. -//===----------------------------------------------------------------------===// - -@interface PR14927 : NSObject -- (void)drain; -@end - -void test_drain(void) { - PR14927 *obj = [[PR14927 alloc] init]; - [obj drain]; - [obj release]; // no-warning -} - -//===----------------------------------------------------------------------===// -// Allow cf_returns_retained and cf_returns_not_retained to mark a return -// value as tracked, even if the object isn't a known CF type. -//===----------------------------------------------------------------------===// - -MyCFType getCustom(void) __attribute__((cf_returns_not_retained)); -MyCFType makeCustom(void) __attribute__((cf_returns_retained)); - -void testCustomReturnsRetained(void) { - MyCFType obj = makeCustom(); // expected-warning {{leak of an object stored into 'obj'}} -} - -void testCustomReturnsNotRetained(void) { - CFRelease(getCustom()); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} -} - -//===----------------------------------------------------------------------===// -// Don't print variables which are out of the current scope. -//===----------------------------------------------------------------------===// -@interface MyObj12706177 : NSObject --(instancetype)initX; -+(void)test12706177; -@end -static int Cond; -@implementation MyObj12706177 --(instancetype)initX { - if (Cond) - return 0; - self = [super init]; - return self; -} -+(void)test12706177 { - id x = [[MyObj12706177 alloc] initX]; //expected-warning {{Potential leak of an object}} - [x release]; -} -@end - -//===----------------------------------------------------------------------===// -// xpc_connection_set_finalizer_f -//===----------------------------------------------------------------------===// -typedef xpc_object_t xpc_connection_t; -typedef void (*xpc_finalizer_t)(void *value); -void xpc_connection_set_context(xpc_connection_t connection, void *ctx); -void xpc_connection_set_finalizer_f(xpc_connection_t connection, - xpc_finalizer_t finalizer); -void releaseAfterXPC(void *context) { - [(NSArray *)context release]; -} - -void rdar13783514(xpc_connection_t connection) { - xpc_connection_set_context(connection, [[NSMutableArray alloc] init]); - xpc_connection_set_finalizer_f(connection, releaseAfterXPC); -} // no-warning - -CFAttributedStringRef CFAttributedCreate(void *CFObj CF_CONSUMED) CF_RETURNS_RETAINED; - -@interface Action -@property (nonatomic) SEL action; -@property (nonatomic, assign) id target; -@end diff --git clang/test/ARCMT/objcmt-atomic-property.m clang/test/ARCMT/objcmt-atomic-property.m deleted file mode 100644 index 00b5e09c8e08..000000000000 --- clang/test/ARCMT/objcmt-atomic-property.m +++ /dev/null @@ -1,227 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -objcmt-migrate-readonly-property -objcmt-atomic-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -#define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION -#define WEAK_IMPORT_ATTRIBUTE __attribute__((objc_arc_weak_reference_unavailable)) -#define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER -#define DEPRECATED __attribute__((deprecated)) - -typedef char BOOL; -@class NSString; -@protocol NSCopying @end - -@interface NSObject <NSCopying> -@end - -@interface NSDictionary : NSObject -@end - -@interface I : NSObject { - int ivarVal; -} -- (void) setWeakProp : (NSString *__weak)Val; -- (NSString *__weak) WeakProp; - -- (NSString *) StrongProp; -- (void) setStrongProp : (NSString *)Val; - -- (NSString *) UnavailProp __attribute__((unavailable)); -- (void) setUnavailProp : (NSString *)Val; - -- (NSString *) UnavailProp1 __attribute__((unavailable)); -- (void) setUnavailProp1 : (NSString *)Val __attribute__((unavailable)); - -- (NSString *) UnavailProp2; -- (void) setUnavailProp2 : (NSString *)Val __attribute__((unavailable)); - -- (NSDictionary*) undoAction; -- (void) setUndoAction: (NSDictionary*)Arg; -@end - -@implementation I -@end - -@class NSArray; - -@interface MyClass2 { -@private - NSArray *_names1; - NSArray *_names2; - NSArray *_names3; - NSArray *_names4; -} -- (void)setNames1:(NSArray *)names; -- (void)setNames4:(__strong NSArray *)names; -- (void)setNames3:(__strong NSArray *)names; -- (void)setNames2:(NSArray *)names; -- (NSArray *) names2; -- (NSArray *)names3; -- (__strong NSArray *)names4; -- (NSArray *) names1; -@end - -// Properties that contain the name "delegate" or "dataSource", -// or have exact name "target" have unsafe_unretained attribute. -@interface NSInvocation -- (id)target; -- (void)setTarget:(id)target; - -- (id) dataSource; - -- (id)xxxdelegateYYY; -- (void)setXxxdelegateYYY:(id)delegate; - -- (void)setDataSource:(id)source; - -- (id)MYtarget; -- (void)setMYtarget: (id)target; - -- (id)targetX; -- (void)setTargetX: (id)t; - -- (int)value; -- (void)setValue: (int)val; - --(BOOL) isContinuous; --(void) setContinuous:(BOOL)value; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -- (int) Length; -- (id) object; -+ (double) D; -- (void *)JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER); -- (BOOL)isIgnoringInteractionEvents; - -- (NSString *)getStringValue; -- (BOOL)getCounterValue; -- (void)setStringValue:(NSString *)stringValue AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; -- (NSDictionary *)getns_dixtionary; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -- (BOOL) getM; -- (BOOL) getMA; -- (BOOL) getALL; -- (BOOL) getMANY; -- (BOOL) getSome; -@end - - -@interface NSInvocation(CAT) -- (id)target; -- (void)setTarget:(id)target; - -- (id) dataSource; - -- (id)xxxdelegateYYY; -- (void)setXxxdelegateYYY:(id)delegate; - -- (void)setDataSource:(id)source; - -- (id)MYtarget; -- (void)setMYtarget: (id)target; - -- (id)targetX; -- (void)setTargetX: (id)t; - -- (int)value; -- (void)setValue: (int)val; - --(BOOL) isContinuous; --(void) setContinuous:(BOOL)value; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -- (int) Length; -- (id) object; -+ (double) D; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -- (BOOL) getM; -- (BOOL) getMA; -- (BOOL) getALL; -- (BOOL) getMANY; -- (BOOL) getSome; -@end - -DEPRECATED -@interface I_DEP -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; -@end - -@interface AnotherOne -- (BOOL) isinValid DEPRECATED; -- (void) setInValid : (BOOL) arg; -- (id)MYtarget; -- (void)setMYtarget: (id)target DEPRECATED; -- (BOOL) getM DEPRECATED; - -- (id)xxxdelegateYYY DEPRECATED; -- (void)setXxxdelegateYYY:(id)delegate DEPRECATED; -@end - -#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0))) -#define NORETURN __attribute__((noreturn)) -#define ALIGNED __attribute__((aligned(16))) - -@interface NSURL -// Do not infer a property. -- (NSURL *)appStoreReceiptURL NS_AVAILABLE; -- (void) setAppStoreReceiptURL : (NSURL *)object; - -- (NSURL *)appStoreReceiptURLX NS_AVAILABLE; -- (void) setAppStoreReceiptURLX : (NSURL *)object NS_AVAILABLE; - -// Do not infer a property. -- (NSURL *)appStoreReceiptURLY ; -- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE; - -- (id)OkToInfer NS_AVAILABLE; - -// Do not infer a property. -- (NSURL *)appStoreReceiptURLZ ; -- (void) setAppStoreReceiptURLZ : (NSURL *)object NS_AVAILABLE; - -// Do not infer a property. -- (id) t1 NORETURN NS_AVAILABLE; -- (void) setT1 : (id) arg NS_AVAILABLE; - -- (id)method1 ALIGNED NS_AVAILABLE; -- (void) setMethod1 : (id) object NS_AVAILABLE ALIGNED; - -- (NSURL *)init; // No Change -+ (id)alloc; // No Change - -- (BOOL)is1stClass; // Not a valid property -- (BOOL)isClass; // This is a valid property 'class' is not a keyword in ObjC -- (BOOL)isDouble; // Not a valid property - -@end - -@class NSMutableDictionary; - -@interface NSArray -- (id (^)(id, NSArray *, NSMutableDictionary *)) expressionBlock; -- (id (^)(id, NSArray *, NSMutableDictionary *)) MyBlock; -- (void) setMyBlock : (id (^)(id, NSArray *, NSMutableDictionary *)) bl; -- (id (*)(id, NSArray *, NSMutableDictionary *)) expressionFuncptr; -- (id (*)(id, NSArray *, NSMutableDictionary *)) MyFuncptr; -- (void) setMyFuncptr : (id (*)(id, NSArray *, NSMutableDictionary *)) bl; -@end diff --git clang/test/ARCMT/objcmt-atomic-property.m.result clang/test/ARCMT/objcmt-atomic-property.m.result deleted file mode 100644 index c829a7aacb50..000000000000 --- clang/test/ARCMT/objcmt-atomic-property.m.result +++ /dev/null @@ -1,200 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -objcmt-migrate-readonly-property -objcmt-atomic-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -#define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION -#define WEAK_IMPORT_ATTRIBUTE __attribute__((objc_arc_weak_reference_unavailable)) -#define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER -#define DEPRECATED __attribute__((deprecated)) - -typedef char BOOL; -@class NSString; -@protocol NSCopying @end - -@interface NSObject <NSCopying> -@end - -@interface NSDictionary : NSObject -@end - -@interface I : NSObject { - int ivarVal; -} -@property (weak) NSString *WeakProp; - -@property (strong) NSString *StrongProp; - -@property (strong) NSString *UnavailProp __attribute__((unavailable)); -- (void) setUnavailProp : (NSString *)Val; - -@property (strong) NSString *UnavailProp1 __attribute__((unavailable)); - -@property (strong) NSString *UnavailProp2; -- (void) setUnavailProp2 : (NSString *)Val __attribute__((unavailable)); - -@property (copy) NSDictionary *undoAction; -@end - -@implementation I -@end - -@class NSArray; - -@interface MyClass2 { -@private - NSArray *_names1; - NSArray *_names2; - NSArray *_names3; - NSArray *_names4; -} -@property (strong) NSArray *names2; -@property (strong) NSArray *names3; -@property (strong) NSArray *names4; -@property (strong) NSArray *names1; -@end - -// Properties that contain the name "delegate" or "dataSource", -// or have exact name "target" have unsafe_unretained attribute. -@interface NSInvocation -@property (assign) id target; - -@property (assign) id dataSource; - -@property (assign) id xxxdelegateYYY; - - -@property (strong) id MYtarget; - -@property (strong) id targetX; - -@property int value; - -@property (getter=isContinuous) BOOL continuous; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -@property (getter=isinValid, readonly) BOOL inValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -@property (readonly) int Length; -@property (readonly, strong) id object; -+ (double) D; -@property (readonly) void *JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER); -@property (getter=isIgnoringInteractionEvents, readonly) BOOL ignoringInteractionEvents; - -@property (getter=getStringValue, strong) NSString *stringValue; -@property (getter=getCounterValue, readonly) BOOL counterValue; -@property (getter=getns_dixtionary, readonly, copy) NSDictionary *ns_dixtionary; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -@property (getter=getM, readonly) BOOL m; -@property (getter=getMA, readonly) BOOL MA; -@property (getter=getALL, readonly) BOOL ALL; -@property (getter=getMANY, readonly) BOOL MANY; -@property (getter=getSome, readonly) BOOL some; -@end - - -@interface NSInvocation(CAT) -@property (assign) id target; - -@property (assign) id dataSource; - -@property (assign) id xxxdelegateYYY; - - -@property (strong) id MYtarget; - -@property (strong) id targetX; - -@property int value; - -@property (getter=isContinuous) BOOL continuous; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -@property (getter=isinValid, readonly) BOOL inValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -@property (readonly) int Length; -@property (readonly, strong) id object; -+ (double) D; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -@property (getter=getM, readonly) BOOL m; -@property (getter=getMA, readonly) BOOL MA; -@property (getter=getALL, readonly) BOOL ALL; -@property (getter=getMANY, readonly) BOOL MANY; -@property (getter=getSome, readonly) BOOL some; -@end - -DEPRECATED -@interface I_DEP -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; -@end - -@interface AnotherOne -- (BOOL) isinValid DEPRECATED; -- (void) setInValid : (BOOL) arg; -- (id)MYtarget; -- (void)setMYtarget: (id)target DEPRECATED; -- (BOOL) getM DEPRECATED; - -- (id)xxxdelegateYYY DEPRECATED; -- (void)setXxxdelegateYYY:(id)delegate DEPRECATED; -@end - -#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0))) -#define NORETURN __attribute__((noreturn)) -#define ALIGNED __attribute__((aligned(16))) - -@interface NSURL -// Do not infer a property. -@property (strong) NSURL *appStoreReceiptURL NS_AVAILABLE; -- (void) setAppStoreReceiptURL : (NSURL *)object; - -@property (strong) NSURL *appStoreReceiptURLX NS_AVAILABLE; - -// Do not infer a property. -@property (strong) NSURL *appStoreReceiptURLY ; -- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE; - -@property (readonly, strong) id OkToInfer NS_AVAILABLE; - -// Do not infer a property. -@property (strong) NSURL *appStoreReceiptURLZ ; -- (void) setAppStoreReceiptURLZ : (NSURL *)object NS_AVAILABLE; - -// Do not infer a property. -- (id) t1 NORETURN NS_AVAILABLE; -- (void) setT1 : (id) arg NS_AVAILABLE; - -@property (strong) id method1 ALIGNED NS_AVAILABLE; - -- (NSURL *)init; // No Change -+ (id)alloc; // No Change - -- (BOOL)is1stClass; // Not a valid property -@property (getter=isClass, readonly) BOOL class; // This is a valid property 'class' is not a keyword in ObjC -- (BOOL)isDouble; // Not a valid property - -@end - -@class NSMutableDictionary; - -@interface NSArray -@property (readonly, copy) id (^expressionBlock)(id, NSArray *, NSMutableDictionary *); -@property (copy) id (^MyBlock)(id, NSArray *, NSMutableDictionary *); -@property (readonly) id (*expressionFuncptr)(id, NSArray *, NSMutableDictionary *); -@property id (*MyFuncptr)(id, NSArray *, NSMutableDictionary *); -@end diff --git clang/test/ARCMT/objcmt-boxing.m clang/test/ARCMT/objcmt-boxing.m deleted file mode 100644 index 07ee68dda33b..000000000000 --- clang/test/ARCMT/objcmt-boxing.m +++ /dev/null @@ -1,106 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fobjc-arc -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ -verify -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result - -#define YES __objc_yes -#define NO __objc_no - -typedef long NSInteger; -typedef unsigned long NSUInteger; -typedef signed char BOOL; -#define nil ((void*) 0) - -#define INT_MIN (-__INT_MAX__ -1) - -@interface NSObject -+ (id)alloc; -@end - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -- (id)initWithChar:(char)value; -- (id)initWithUnsignedChar:(unsigned char)value; -- (id)initWithShort:(short)value; -- (id)initWithUnsignedShort:(unsigned short)value; -- (id)initWithInt:(int)value; -- (id)initWithUnsignedInt:(unsigned int)value; -- (id)initWithLong:(long)value; -- (id)initWithUnsignedLong:(unsigned long)value; -- (id)initWithLongLong:(long long)value; -- (id)initWithUnsignedLongLong:(unsigned long long)value; -- (id)initWithFloat:(float)value; -- (id)initWithDouble:(double)value; -- (id)initWithBool:(BOOL)value; -- (id)initWithInteger:(NSInteger)value; -- (id)initWithUnsignedInteger:(NSUInteger)value; - -+ (NSNumber *)numberWithChar:(char)value; -+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value; -+ (NSNumber *)numberWithShort:(short)value; -+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value; -+ (NSNumber *)numberWithInt:(int)value; -+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value; -+ (NSNumber *)numberWithLong:(long)value; -+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value; -+ (NSNumber *)numberWithLongLong:(long long)value; -+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; -+ (NSNumber *)numberWithFloat:(float)value; -+ (NSNumber *)numberWithDouble:(double)value; -+ (NSNumber *)numberWithBool:(BOOL)value; -+ (NSNumber *)numberWithInteger:(NSInteger)value; -+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value; -@end - -enum { - NSASCIIStringEncoding = 1, - NSUTF8StringEncoding = 4, - NSUnicodeStringEncoding = 10 -}; -typedef NSUInteger NSStringEncoding; - -@interface NSString : NSObject -@end - -@interface NSString (NSStringExtensionMethods) -+ (id)stringWithUTF8String:(const char *)nullTerminatedCString; -+ (id)stringWithCString:(const char *)cString encoding:(NSStringEncoding)enc; -+ (id)stringWithCString:(const char *)bytes; -- (instancetype)initWithUTF8String:(const char *)nullTerminatedCString; -@end - -enum MyEnm { - ME_foo -}; - -void foo() { - [NSNumber numberWithInt:INT_MIN]; - bool cppb; - [NSNumber numberWithBool:cppb]; - MyEnm myenum; - [NSNumber numberWithInteger:myenum]; - [NSNumber numberWithInteger:ME_foo]; - [NSNumber numberWithDouble:cppb]; // expected-warning {{converting to boxing syntax requires casting 'bool' to 'double'}} -} - -void boxString() { - NSString *s = [NSString stringWithUTF8String:"box"]; - const char *cstr1; - char *cstr2; - s = [NSString stringWithUTF8String:cstr1]; - s = [NSString stringWithUTF8String:cstr2]; - s = [NSString stringWithCString:cstr1 encoding:NSASCIIStringEncoding]; - s = [NSString stringWithCString:cstr1 encoding:NSUTF8StringEncoding]; - s = [NSString stringWithCString:cstr1 encoding: NSUnicodeStringEncoding]; - NSStringEncoding encode; - s = [NSString stringWithCString:cstr1 encoding:encode]; - s = [NSString stringWithCString:cstr1]; - - static const char strarr[] = "coolbox"; - s = [NSString stringWithUTF8String:strarr]; - const char *utf8Bytes = "blah"; - NSString *string1 = [NSString stringWithUTF8String:utf8Bytes]; - NSString *string2 = [[NSString alloc] initWithUTF8String:utf8Bytes]; -} diff --git clang/test/ARCMT/objcmt-boxing.m.result clang/test/ARCMT/objcmt-boxing.m.result deleted file mode 100644 index a60b35900bf3..000000000000 --- clang/test/ARCMT/objcmt-boxing.m.result +++ /dev/null @@ -1,106 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fobjc-arc -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ -verify -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result - -#define YES __objc_yes -#define NO __objc_no - -typedef long NSInteger; -typedef unsigned long NSUInteger; -typedef signed char BOOL; -#define nil ((void*) 0) - -#define INT_MIN (-__INT_MAX__ -1) - -@interface NSObject -+ (id)alloc; -@end - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -- (id)initWithChar:(char)value; -- (id)initWithUnsignedChar:(unsigned char)value; -- (id)initWithShort:(short)value; -- (id)initWithUnsignedShort:(unsigned short)value; -- (id)initWithInt:(int)value; -- (id)initWithUnsignedInt:(unsigned int)value; -- (id)initWithLong:(long)value; -- (id)initWithUnsignedLong:(unsigned long)value; -- (id)initWithLongLong:(long long)value; -- (id)initWithUnsignedLongLong:(unsigned long long)value; -- (id)initWithFloat:(float)value; -- (id)initWithDouble:(double)value; -- (id)initWithBool:(BOOL)value; -- (id)initWithInteger:(NSInteger)value; -- (id)initWithUnsignedInteger:(NSUInteger)value; - -+ (NSNumber *)numberWithChar:(char)value; -+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value; -+ (NSNumber *)numberWithShort:(short)value; -+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value; -+ (NSNumber *)numberWithInt:(int)value; -+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value; -+ (NSNumber *)numberWithLong:(long)value; -+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value; -+ (NSNumber *)numberWithLongLong:(long long)value; -+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; -+ (NSNumber *)numberWithFloat:(float)value; -+ (NSNumber *)numberWithDouble:(double)value; -+ (NSNumber *)numberWithBool:(BOOL)value; -+ (NSNumber *)numberWithInteger:(NSInteger)value; -+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value; -@end - -enum { - NSASCIIStringEncoding = 1, - NSUTF8StringEncoding = 4, - NSUnicodeStringEncoding = 10 -}; -typedef NSUInteger NSStringEncoding; - -@interface NSString : NSObject -@end - -@interface NSString (NSStringExtensionMethods) -+ (id)stringWithUTF8String:(const char *)nullTerminatedCString; -+ (id)stringWithCString:(const char *)cString encoding:(NSStringEncoding)enc; -+ (id)stringWithCString:(const char *)bytes; -- (instancetype)initWithUTF8String:(const char *)nullTerminatedCString; -@end - -enum MyEnm { - ME_foo -}; - -void foo() { - @INT_MIN; - bool cppb; - @(cppb); - MyEnm myenum; - @(myenum); - @(ME_foo); - [NSNumber numberWithDouble:cppb]; // expected-warning {{converting to boxing syntax requires casting 'bool' to 'double'}} -} - -void boxString() { - NSString *s = @"box"; - const char *cstr1; - char *cstr2; - s = @(cstr1); - s = @(cstr2); - s = @(cstr1); - s = @(cstr1); - s = [NSString stringWithCString:cstr1 encoding: NSUnicodeStringEncoding]; - NSStringEncoding encode; - s = [NSString stringWithCString:cstr1 encoding:encode]; - s = @(cstr1); - - static const char strarr[] = "coolbox"; - s = @(strarr); - const char *utf8Bytes = "blah"; - NSString *string1 = @(utf8Bytes); - NSString *string2 = @(utf8Bytes); -} diff --git clang/test/ARCMT/objcmt-designated-initializer.m clang/test/ARCMT/objcmt-designated-initializer.m deleted file mode 100644 index 279d4f35d8eb..000000000000 --- clang/test/ARCMT/objcmt-designated-initializer.m +++ /dev/null @@ -1,44 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-designated-init %s -triple x86_64-apple-darwin11 -fobjc-arc -migrate -o %t.remap -// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-arc %s.result - -#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) - -@class NSString; - -@interface B1 --(id)init; -@end - -@interface S1 : B1 --(id)initWithFoo:(NSString*)foo; -@end - -@implementation S1 --(id)initWithFoo:(NSString*)foo -{ - self = [super init]; - if (self) { - } - return self; -} -@end - -@interface B2 --(id)init NS_DESIGNATED_INITIALIZER; -@end - -@interface S2 : B2 --(id)init; -@end - -@implementation S2 --(id)init -{ - self = [super init]; - if (self) { - } - return self; -} -@end diff --git clang/test/ARCMT/objcmt-designated-initializer.m.result clang/test/ARCMT/objcmt-designated-initializer.m.result deleted file mode 100644 index 4c59b0cc5826..000000000000 --- clang/test/ARCMT/objcmt-designated-initializer.m.result +++ /dev/null @@ -1,44 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-designated-init %s -triple x86_64-apple-darwin11 -fobjc-arc -migrate -o %t.remap -// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-arc %s.result - -#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) - -@class NSString; - -@interface B1 --(id)init; -@end - -@interface S1 : B1 --(id)initWithFoo:(NSString*)foo NS_DESIGNATED_INITIALIZER; -@end - -@implementation S1 --(id)initWithFoo:(NSString*)foo -{ - self = [super init]; - if (self) { - } - return self; -} -@end - -@interface B2 --(id)init NS_DESIGNATED_INITIALIZER; -@end - -@interface S2 : B2 --(id)init; -@end - -@implementation S2 --(id)init -{ - self = [super init]; - if (self) { - } - return self; -} -@end diff --git clang/test/ARCMT/objcmt-instancetype-2.m clang/test/ARCMT/objcmt-instancetype-2.m deleted file mode 100644 index fb59265c4be3..000000000000 --- clang/test/ARCMT/objcmt-instancetype-2.m +++ /dev/null @@ -1,103 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-instancetype -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -typedef unsigned int NSUInteger; -typedef int NSInteger; -typedef char BOOL; -@class NSData, NSError, NSProtocolChecker, NSObject; -@class NSPortNameServer, NSTimeZone; - -@interface NSMutableString -@end - -@interface NSString @end - -@class NSString, NSURL; -@interface NSString (NSStringDeprecated) -+ (id)stringWithContentsOfFile:(NSString *)path __attribute__((availability(macosx,introduced=10.0 ,message="" ))); -+ (id)stringWithContentsOfURL:(NSURL *)url __attribute__((availability(macosx,introduced=10.0 ,message="" ))); -+ (id)stringWithCString:(const char *)bytes length:(NSUInteger)length __attribute__((availability(macosx,introduced=10.0 ,message="" ))); -+ (id)stringWithCString:(const char *)bytes __attribute__((availability(macosx,introduced=10.0 ,message="" ))); -@end - - -typedef enum NSURLBookmarkResolutionOptions { - Bookmark -} NSURLBookmarkResolutionOptions; - -@interface NSURL -+ (id)URLWithString:(NSString *)URLString; -+ (id)URLWithString:(NSString *)URLString relativeToURL:(NSURL *)baseURL; -+ (id)URLByResolvingBookmarkData:(NSData *)bookmarkData options:(NSURLBookmarkResolutionOptions)options relativeToURL:(NSURL *)relativeURL bookmarkDataIsStale:(BOOL *)isStale error:(NSError **)error __attribute__((availability(macosx,introduced=10.6))); -@end - -@class NSDictionary; -@interface NSError -+ (id)errorWithDomain:(NSString *)domain code:(NSInteger)code userInfo:(NSDictionary *)dict; -@end - - -@interface NSMutableString (NSMutableStringExtensionMethods) -+ (id)stringWithCapacity:(NSUInteger)capacity; -@end - -@interface NSMutableData -+ (id)dataWithCapacity:(NSUInteger)aNumItems; -+ (id)dataWithLength:(NSUInteger)length; -@end - -@interface NSMutableDictionary @end - -@interface NSMutableDictionary (NSSharedKeySetDictionary) -+ (id )dictionaryWithSharedKeySet:(id)keyset __attribute__((availability(macosx,introduced=10.8))); -@end - -@interface NSProtocolChecker -+ (id)protocolCheckerWithTarget:(NSObject *)anObject protocol:(Protocol *)aProtocol; -@end - -@interface NSConnection -+ (id)connectionWithRegisteredName:(NSString *)name host:(NSString *)hostName; -+ (id)connectionWithRegisteredName:(NSString *)name host:(NSString *)hostName usingNameServer:(NSPortNameServer *)server; -@end - -@interface NSDate -+ (id)dateWithString:(NSString *)aString __attribute__((availability(macosx,introduced=10.4))); -@end - -@interface NSCalendarDate : NSDate -+ (id)calendarDate __attribute__((availability(macosx,introduced=10.4))); -+ (id)dateWithString:(NSString *)description calendarFormat:(NSString *)format locale:(id)locale __attribute__((availability(macosx,introduced=10.4))); -+ (id)dateWithString:(NSString *)description calendarFormat:(NSString *)format __attribute__((availability(macosx,introduced=10.4))); -+ (id)dateWithYear:(NSInteger)year month:(NSUInteger)month day:(NSUInteger)day hour:(NSUInteger)hour minute:(NSUInteger)minute second:(NSUInteger)second timeZone:(NSTimeZone *)aTimeZone __attribute__((availability(macosx,introduced=10.4))); -@end - -@interface NSUserDefaults -+ (id) standardUserDefaults; -@end - -@interface NSNotificationCenter -+ (id) defaultCenter; -+ sharedCenter; -@end - -@interface UIApplication -+ (id)sharedApplication; -+ defaultApplication; -@end - -//===----------------------------------------------------------------------===// -// Method name that has a null IdentifierInfo* for its first selector slot. -// This test just makes sure that we handle it. -//===----------------------------------------------------------------------===// -@interface TestNullIdentifier -@end - -@implementation TestNullIdentifier -+ (id):(int)x, ... { - return 0; -} -@end - diff --git clang/test/ARCMT/objcmt-instancetype-2.m.result clang/test/ARCMT/objcmt-instancetype-2.m.result deleted file mode 100644 index 7a32894f5706..000000000000 --- clang/test/ARCMT/objcmt-instancetype-2.m.result +++ /dev/null @@ -1,103 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-instancetype -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -typedef unsigned int NSUInteger; -typedef int NSInteger; -typedef char BOOL; -@class NSData, NSError, NSProtocolChecker, NSObject; -@class NSPortNameServer, NSTimeZone; - -@interface NSMutableString -@end - -@interface NSString @end - -@class NSString, NSURL; -@interface NSString (NSStringDeprecated) -+ (id)stringWithContentsOfFile:(NSString *)path __attribute__((availability(macosx,introduced=10.0 ,message="" ))); -+ (id)stringWithContentsOfURL:(NSURL *)url __attribute__((availability(macosx,introduced=10.0 ,message="" ))); -+ (id)stringWithCString:(const char *)bytes length:(NSUInteger)length __attribute__((availability(macosx,introduced=10.0 ,message="" ))); -+ (id)stringWithCString:(const char *)bytes __attribute__((availability(macosx,introduced=10.0 ,message="" ))); -@end - - -typedef enum NSURLBookmarkResolutionOptions { - Bookmark -} NSURLBookmarkResolutionOptions; - -@interface NSURL -+ (instancetype)URLWithString:(NSString *)URLString; -+ (instancetype)URLWithString:(NSString *)URLString relativeToURL:(NSURL *)baseURL; -+ (instancetype)URLByResolvingBookmarkData:(NSData *)bookmarkData options:(NSURLBookmarkResolutionOptions)options relativeToURL:(NSURL *)relativeURL bookmarkDataIsStale:(BOOL *)isStale error:(NSError **)error __attribute__((availability(macosx,introduced=10.6))); -@end - -@class NSDictionary; -@interface NSError -+ (instancetype)errorWithDomain:(NSString *)domain code:(NSInteger)code userInfo:(NSDictionary *)dict; -@end - - -@interface NSMutableString (NSMutableStringExtensionMethods) -+ (instancetype)stringWithCapacity:(NSUInteger)capacity; -@end - -@interface NSMutableData -+ (instancetype)dataWithCapacity:(NSUInteger)aNumItems; -+ (instancetype)dataWithLength:(NSUInteger)length; -@end - -@interface NSMutableDictionary @end - -@interface NSMutableDictionary (NSSharedKeySetDictionary) -+ (instancetype )dictionaryWithSharedKeySet:(id)keyset __attribute__((availability(macosx,introduced=10.8))); -@end - -@interface NSProtocolChecker -+ (instancetype)protocolCheckerWithTarget:(NSObject *)anObject protocol:(Protocol *)aProtocol; -@end - -@interface NSConnection -+ (instancetype)connectionWithRegisteredName:(NSString *)name host:(NSString *)hostName; -+ (instancetype)connectionWithRegisteredName:(NSString *)name host:(NSString *)hostName usingNameServer:(NSPortNameServer *)server; -@end - -@interface NSDate -+ (instancetype)dateWithString:(NSString *)aString __attribute__((availability(macosx,introduced=10.4))); -@end - -@interface NSCalendarDate : NSDate -+ (instancetype)calendarDate __attribute__((availability(macosx,introduced=10.4))); -+ (instancetype)dateWithString:(NSString *)description calendarFormat:(NSString *)format locale:(id)locale __attribute__((availability(macosx,introduced=10.4))); -+ (instancetype)dateWithString:(NSString *)description calendarFormat:(NSString *)format __attribute__((availability(macosx,introduced=10.4))); -+ (instancetype)dateWithYear:(NSInteger)year month:(NSUInteger)month day:(NSUInteger)day hour:(NSUInteger)hour minute:(NSUInteger)minute second:(NSUInteger)second timeZone:(NSTimeZone *)aTimeZone __attribute__((availability(macosx,introduced=10.4))); -@end - -@interface NSUserDefaults -+ (instancetype) standardUserDefaults; -@end - -@interface NSNotificationCenter -+ (NSNotificationCenter*) defaultCenter; -+ (NSNotificationCenter*) sharedCenter; -@end - -@interface UIApplication -+ (UIApplication*)sharedApplication; -+ (UIApplication*) defaultApplication; -@end - -//===----------------------------------------------------------------------===// -// Method name that has a null IdentifierInfo* for its first selector slot. -// This test just makes sure that we handle it. -//===----------------------------------------------------------------------===// -@interface TestNullIdentifier -@end - -@implementation TestNullIdentifier -+ (id):(int)x, ... { - return 0; -} -@end - diff --git clang/test/ARCMT/objcmt-instancetype-unnecessary-diff.m clang/test/ARCMT/objcmt-instancetype-unnecessary-diff.m deleted file mode 100644 index e250bb0956c0..000000000000 --- clang/test/ARCMT/objcmt-instancetype-unnecessary-diff.m +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -objcmt-migrate-instancetype %s -triple x86_64-apple-darwin11 -fobjc-arc -migrate -o %t.remap -// RUN: FileCheck %s -input-file=%t.remap - -// Make sure we don't create an edit unnecessarily. -// CHECK-NOT: instancetype - -@class NSString; -@interface NSDictionary -+(instancetype) dictionaryWithURLEncodedString:(NSString *)urlEncodedString; -@end diff --git clang/test/ARCMT/objcmt-instancetype.m clang/test/ARCMT/objcmt-instancetype.m deleted file mode 100644 index 17dd5a46b1e7..000000000000 --- clang/test/ARCMT/objcmt-instancetype.m +++ /dev/null @@ -1,111 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-instancetype -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -typedef signed char BOOL; -#define nil ((void*) 0) - -@interface NSObject -+ (id)alloc; -@end - -@interface NSString : NSObject -+ (id)stringWithString:(NSString *)string; -- (id)initWithString:(NSString *)aString; -@end - -@implementation NSString : NSObject -+ (id)stringWithString:(NSString *)string { return 0; }; -- (instancetype)initWithString:(NSString *)aString { return 0; }; -@end - -@interface NSArray : NSObject -- (id)objectAtIndex:(unsigned long)index; -- (id)objectAtIndexedSubscript:(int)index; -@end - -@interface NSArray (NSArrayCreation) -+ (id)array; -+ (id)arrayWithObject:(id)anObject; -+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; -+ (id)arrayWithObjects:(id)firstObj, ...; -+ arrayWithArray:(NSArray *)array; - -- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; -- (id)initWithObjects:(id)firstObj, ...; -- (id)initWithArray:(NSArray *)array; - -- (id)objectAtIndex:(unsigned long)index; -@end - -@implementation NSArray (NSArrayCreation) -+ (id)array { return 0; } -+ (id)arrayWithObject:(id)anObject { - return anObject; -} -+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt { return 0; } -+ (id)arrayWithObjects:(id)firstObj, ... { - return 0; } -+ arrayWithArray:(NSArray *)array { - return 0; -} - -- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt { return 0; } -- (id)initWithObjects:(id)firstObj, ... { return 0; } -- (id)initWithArray:(NSArray *)array { return 0; } - -- (id)objectAtIndex:(unsigned long)index { return 0; } -@end - -@interface NSMutableArray : NSArray -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -- (void)setObject:(id)object atIndexedSubscript:(int)index; -@end - -@interface NSDictionary : NSObject -- (id)objectForKeyedSubscript:(id)key; -@end - -@interface NSDictionary (NSDictionaryCreation) -+ (id)dictionary; -+ (id)dictionaryWithObject:(id)object forKey:(id)key; -+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -+ dictionaryWithObjectsAndKeys:(id)firstObject, ...; -+ (id)dictionaryWithDictionary:(NSDictionary *)dict; -+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -- (id)initWithObjectsAndKeys:(id)firstObject, ...; -- (id)initWithDictionary:(NSDictionary *)otherDictionary; -- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)objectForKey:(id)aKey; -@end - -@interface NSMutableDictionary : NSDictionary -- (void)setObject:(id)anObject forKey:(id)aKey; -- (void)setObject:(id)object forKeyedSubscript:(id)key; -@end - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value; -@end - -@implementation NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value { return 0; } -@end - -#define M(x) (x) -#define PAIR(x) @#x, [NSNumber numberWithInt:(x)] -#define TWO(x) ((x), (x)) - -void foo(void) { - NSString *str = M([NSString stringWithString:@"foo"]); // expected-warning {{redundant}} - str = [[NSString alloc] initWithString:@"foo"]; // expected-warning {{redundant}} - NSArray *arr = [NSArray arrayWithArray:@[str]]; // expected-warning {{redundant}} - NSDictionary *dict = [NSDictionary dictionaryWithDictionary:@{str: arr}]; // expected-warning {{redundant}} -} diff --git clang/test/ARCMT/objcmt-instancetype.m.result clang/test/ARCMT/objcmt-instancetype.m.result deleted file mode 100644 index 5203368aad64..000000000000 --- clang/test/ARCMT/objcmt-instancetype.m.result +++ /dev/null @@ -1,111 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-instancetype -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -typedef signed char BOOL; -#define nil ((void*) 0) - -@interface NSObject -+ (id)alloc; -@end - -@interface NSString : NSObject -+ (instancetype)stringWithString:(NSString *)string; -- (instancetype)initWithString:(NSString *)aString; -@end - -@implementation NSString : NSObject -+ (instancetype)stringWithString:(NSString *)string { return 0; }; -- (instancetype)initWithString:(NSString *)aString { return 0; }; -@end - -@interface NSArray : NSObject -- (id)objectAtIndex:(unsigned long)index; -- (id)objectAtIndexedSubscript:(int)index; -@end - -@interface NSArray (NSArrayCreation) -+ (instancetype)array; -+ (instancetype)arrayWithObject:(id)anObject; -+ (instancetype)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; -+ (instancetype)arrayWithObjects:(id)firstObj, ...; -+ (instancetype) arrayWithArray:(NSArray *)array; - -- (instancetype)initWithObjects:(const id [])objects count:(unsigned long)cnt; -- (instancetype)initWithObjects:(id)firstObj, ...; -- (instancetype)initWithArray:(NSArray *)array; - -- (id)objectAtIndex:(unsigned long)index; -@end - -@implementation NSArray (NSArrayCreation) -+ (instancetype)array { return 0; } -+ (instancetype)arrayWithObject:(id)anObject { - return anObject; -} -+ (instancetype)arrayWithObjects:(const id [])objects count:(unsigned long)cnt { return 0; } -+ (instancetype)arrayWithObjects:(id)firstObj, ... { - return 0; } -+ (instancetype) arrayWithArray:(NSArray *)array { - return 0; -} - -- (instancetype)initWithObjects:(const id [])objects count:(unsigned long)cnt { return 0; } -- (instancetype)initWithObjects:(id)firstObj, ... { return 0; } -- (instancetype)initWithArray:(NSArray *)array { return 0; } - -- (id)objectAtIndex:(unsigned long)index { return 0; } -@end - -@interface NSMutableArray : NSArray -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -- (void)setObject:(id)object atIndexedSubscript:(int)index; -@end - -@interface NSDictionary : NSObject -- (id)objectForKeyedSubscript:(id)key; -@end - -@interface NSDictionary (NSDictionaryCreation) -+ (instancetype)dictionary; -+ (instancetype)dictionaryWithObject:(id)object forKey:(id)key; -+ (instancetype)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -+ (instancetype) dictionaryWithObjectsAndKeys:(id)firstObject, ...; -+ (instancetype)dictionaryWithDictionary:(NSDictionary *)dict; -+ (instancetype)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (instancetype)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -- (instancetype)initWithObjectsAndKeys:(id)firstObject, ...; -- (instancetype)initWithDictionary:(NSDictionary *)otherDictionary; -- (instancetype)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)objectForKey:(id)aKey; -@end - -@interface NSMutableDictionary : NSDictionary -- (void)setObject:(id)anObject forKey:(id)aKey; -- (void)setObject:(id)object forKeyedSubscript:(id)key; -@end - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value; -@end - -@implementation NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value { return 0; } -@end - -#define M(x) (x) -#define PAIR(x) @#x, [NSNumber numberWithInt:(x)] -#define TWO(x) ((x), (x)) - -void foo(void) { - NSString *str = M([NSString stringWithString:@"foo"]); // expected-warning {{redundant}} - str = [[NSString alloc] initWithString:@"foo"]; // expected-warning {{redundant}} - NSArray *arr = [NSArray arrayWithArray:@[str]]; // expected-warning {{redundant}} - NSDictionary *dict = [NSDictionary dictionaryWithDictionary:@{str: arr}]; // expected-warning {{redundant}} -} diff --git clang/test/ARCMT/objcmt-invalid-code.mm clang/test/ARCMT/objcmt-invalid-code.mm deleted file mode 100644 index f780d3de57ed..000000000000 --- clang/test/ARCMT/objcmt-invalid-code.mm +++ /dev/null @@ -1,19 +0,0 @@ -// REQUIRES: x86-registered-target -// RUN: rm -rf %t -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only %s -verify -// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result - -// Make sure there is no crash. - -@interface NSObject @end -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value; -@end - -void foo(int x = undeclared) { // expected-error {{undeclared}} - NSNumber *n = [NSNumber numberWithInt:1]; -} diff --git clang/test/ARCMT/objcmt-invalid-code.mm.result clang/test/ARCMT/objcmt-invalid-code.mm.result deleted file mode 100644 index 52b2db00f610..000000000000 --- clang/test/ARCMT/objcmt-invalid-code.mm.result +++ /dev/null @@ -1,19 +0,0 @@ -// REQUIRES: x86-registered-target -// RUN: rm -rf %t -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only %s -verify -// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result - -// Make sure there is no crash. - -@interface NSObject @end -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value; -@end - -void foo(int x = undeclared) { // expected-error {{undeclared}} - NSNumber *n = @1; -} diff --git clang/test/ARCMT/objcmt-migrate-all.m clang/test/ARCMT/objcmt-migrate-all.m deleted file mode 100644 index 0aa66756b761..000000000000 --- clang/test/ARCMT/objcmt-migrate-all.m +++ /dev/null @@ -1,133 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-all -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -#ifndef NS_RETURNS_INNER_POINTER // defined in iOS 6 for sure -#define NS_RETURNS_INNER_POINTER __attribute__((objc_returns_inner_pointer)) -#endif - -#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin") - -#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end") - -#if __has_feature(attribute_ns_returns_retained) -#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) -#endif -#if __has_feature(attribute_cf_returns_retained) -#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) -#endif -#if __has_feature(attribute_ns_returns_not_retained) -#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained)) -#endif -#if __has_feature(attribute_cf_returns_not_retained) -#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained)) -#endif -#if __has_feature(attribute_ns_consumes_self) -#define NS_CONSUMES_SELF __attribute__((ns_consumes_self)) -#endif -#if __has_feature(attribute_ns_consumed) -#define NS_CONSUMED __attribute__((ns_consumed)) -#endif -#if __has_feature(attribute_cf_consumed) -#define CF_CONSUMED __attribute__((cf_consumed)) -#endif -#if __has_attribute(ns_returns_autoreleased) -#define NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased)) -#endif - -#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0))) - -CF_IMPLICIT_BRIDGING_ENABLED - -typedef unsigned long CFTypeID; -typedef unsigned long CFOptionFlags; -typedef unsigned long CFHashCode; - -typedef signed long CFIndex; /*AnyObj*/ -typedef const struct __CFArray * CFArrayRef; -typedef struct { - CFIndex location; - CFIndex length; -} CFRange; - -typedef void (*CFArrayApplierFunction)(const void *value, void *context); - -typedef enum CFComparisonResult : CFIndex CFComparisonResult; enum CFComparisonResult : CFIndex { - kCFCompareLessThan = -1L, - kCFCompareEqualTo = 0, - kCFCompareGreaterThan = 1 -}; - - -typedef CFComparisonResult (*CFComparatorFunction)(const void *val1, const void *val2, void *context); - -typedef struct __CFArray * CFMutableArrayRef; - -typedef const struct __CFAttributedString *CFAttributedStringRef; -typedef struct __CFAttributedString *CFMutableAttributedStringRef; - -typedef const struct __CFAllocator * CFAllocatorRef; - -typedef const struct __CFString * CFStringRef; -typedef struct __CFString * CFMutableStringRef; - -typedef const struct __CFDictionary * CFDictionaryRef; -typedef struct __CFDictionary * CFMutableDictionaryRef; - -typedef struct CGImage *CGImageRef; - -typedef struct OpaqueJSValue* JSObjectRef; - -typedef JSObjectRef TTJSObjectRef; -typedef unsigned int NSUInteger; - -CF_IMPLICIT_BRIDGING_DISABLED - -@interface I -- (void*) ReturnsInnerPointer; -- (int*) AlreadyReturnsInnerPointer NS_RETURNS_INNER_POINTER; -@end - -@interface UIImage -- (CGImageRef)CGImage; -@end - -@interface NSData -- (void *)bytes; -- (void **) ptr_bytes __attribute__((availability(macosx,unavailable))); -@end - -@interface NSMutableData -- (void *)mutableBytes __attribute__((deprecated)) __attribute__((unavailable)); -@end - -@interface JS -- (JSObjectRef)JSObject; -- (TTJSObjectRef)JSObject1; -- (JSObjectRef*)JSObject2; -@end - -typedef void *SecTrustRef; - -@interface NSURLProtectionSpace -@property (readonly) SecTrustRef serverTrust NS_AVAILABLE; -- (void *) FOO NS_AVAILABLE; -@property (readonly) void * mitTrust NS_AVAILABLE; - -@property (readonly) void * mittiTrust; - -@property (readonly) SecTrustRef XserverTrust; - -- (SecTrustRef) FOO1 NS_AVAILABLE; - -+ (const NSURLProtectionSpace *)ProtectionSpace; - -// pointer personality functions -@property NSUInteger (*hashFunction)(const void *item, NSUInteger (*size)(const void *item)); -@end - -@interface MustNotMigrateToInnerPointer -- (void*) nono; -- (void) setNono : (void*) val; -@end diff --git clang/test/ARCMT/objcmt-migrate-all.m.result clang/test/ARCMT/objcmt-migrate-all.m.result deleted file mode 100644 index e0972875e11b..000000000000 --- clang/test/ARCMT/objcmt-migrate-all.m.result +++ /dev/null @@ -1,132 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-all -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -#ifndef NS_RETURNS_INNER_POINTER // defined in iOS 6 for sure -#define NS_RETURNS_INNER_POINTER __attribute__((objc_returns_inner_pointer)) -#endif - -#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin") - -#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end") - -#if __has_feature(attribute_ns_returns_retained) -#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) -#endif -#if __has_feature(attribute_cf_returns_retained) -#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) -#endif -#if __has_feature(attribute_ns_returns_not_retained) -#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained)) -#endif -#if __has_feature(attribute_cf_returns_not_retained) -#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained)) -#endif -#if __has_feature(attribute_ns_consumes_self) -#define NS_CONSUMES_SELF __attribute__((ns_consumes_self)) -#endif -#if __has_feature(attribute_ns_consumed) -#define NS_CONSUMED __attribute__((ns_consumed)) -#endif -#if __has_feature(attribute_cf_consumed) -#define CF_CONSUMED __attribute__((cf_consumed)) -#endif -#if __has_attribute(ns_returns_autoreleased) -#define NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased)) -#endif - -#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0))) - -CF_IMPLICIT_BRIDGING_ENABLED - -typedef unsigned long CFTypeID; -typedef unsigned long CFOptionFlags; -typedef unsigned long CFHashCode; - -typedef signed long CFIndex; /*AnyObj*/ -typedef const struct __CFArray * CFArrayRef; -typedef struct { - CFIndex location; - CFIndex length; -} CFRange; - -typedef void (*CFArrayApplierFunction)(const void *value, void *context); - -typedef enum CFComparisonResult : CFIndex CFComparisonResult; enum CFComparisonResult : CFIndex { - kCFCompareLessThan = -1L, - kCFCompareEqualTo = 0, - kCFCompareGreaterThan = 1 -}; - - -typedef CFComparisonResult (*CFComparatorFunction)(const void *val1, const void *val2, void *context); - -typedef struct __CFArray * CFMutableArrayRef; - -typedef const struct __CFAttributedString *CFAttributedStringRef; -typedef struct __CFAttributedString *CFMutableAttributedStringRef; - -typedef const struct __CFAllocator * CFAllocatorRef; - -typedef const struct __CFString * CFStringRef; -typedef struct __CFString * CFMutableStringRef; - -typedef const struct __CFDictionary * CFDictionaryRef; -typedef struct __CFDictionary * CFMutableDictionaryRef; - -typedef struct CGImage *CGImageRef; - -typedef struct OpaqueJSValue* JSObjectRef; - -typedef JSObjectRef TTJSObjectRef; -typedef unsigned int NSUInteger; - -CF_IMPLICIT_BRIDGING_DISABLED - -@interface I -@property (nonatomic, readonly) void *ReturnsInnerPointer; -@property (nonatomic, readonly) int *AlreadyReturnsInnerPointer NS_RETURNS_INNER_POINTER; -@end - -@interface UIImage -@property (nonatomic, readonly) CGImageRef CGImage CF_RETURNS_NOT_RETAINED; -@end - -@interface NSData -@property (nonatomic, readonly) void *bytes; -@property (nonatomic, readonly) void **ptr_bytes __attribute__((availability(macosx,unavailable))); -@end - -@interface NSMutableData -@property (nonatomic, readonly) void *mutableBytes __attribute__((deprecated)) __attribute__((unavailable)); -@end - -@interface JS -@property (nonatomic, readonly) JSObjectRef JSObject; -@property (nonatomic, readonly) TTJSObjectRef JSObject1; -@property (nonatomic, readonly) JSObjectRef *JSObject2; -@end - -typedef void *SecTrustRef; - -@interface NSURLProtectionSpace -@property (readonly) SecTrustRef serverTrust NS_AVAILABLE; -@property (nonatomic, readonly) void *FOO NS_AVAILABLE; -@property (readonly) void * mitTrust NS_AVAILABLE; - -@property (readonly) void * mittiTrust; - -@property (readonly) SecTrustRef XserverTrust; - -@property (nonatomic, readonly) SecTrustRef FOO1 NS_AVAILABLE; - -+ (const NSURLProtectionSpace *)ProtectionSpace; - -// pointer personality functions -@property NSUInteger (*hashFunction)(const void *item, NSUInteger (*size)(const void *item)); -@end - -@interface MustNotMigrateToInnerPointer -@property (nonatomic) void *nono; -@end diff --git clang/test/ARCMT/objcmt-ns-enum-crash.m clang/test/ARCMT/objcmt-ns-enum-crash.m deleted file mode 100644 index 7c9c708efaef..000000000000 --- clang/test/ARCMT/objcmt-ns-enum-crash.m +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result - -#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type -#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type -typedef long NSInteger; - -typedef enum : NSInteger {five} ApplicableEnum; - -typedef unsigned long mytd; - -#define MY_ENUM(name, type, ...) typedef enum : type { __VA_ARGS__ } name##_t -MY_ENUM(MyEnum, unsigned int, One); diff --git clang/test/ARCMT/objcmt-ns-enum-crash.m.result clang/test/ARCMT/objcmt-ns-enum-crash.m.result deleted file mode 100644 index 0a76e66ea211..000000000000 --- clang/test/ARCMT/objcmt-ns-enum-crash.m.result +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result - -#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type -#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type -typedef long NSInteger; - -typedef NS_ENUM(NSInteger, ApplicableEnum) {five}; - -typedef unsigned long mytd; - -#define MY_ENUM(name, type, ...) typedef enum : type { __VA_ARGS__ } name##_t -MY_ENUM(MyEnum, unsigned int, One); diff --git clang/test/ARCMT/objcmt-ns-macros.m clang/test/ARCMT/objcmt-ns-macros.m deleted file mode 100644 index 902e765bead3..000000000000 --- clang/test/ARCMT/objcmt-ns-macros.m +++ /dev/null @@ -1,379 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -typedef signed char int8_t; -typedef short int16_t; -typedef int int32_t; -typedef long NSInteger; -typedef long long int64_t; - -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; -typedef unsigned long NSUInteger; -typedef unsigned long long uint64_t; - -#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type -#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type -#define DEPRECATED __attribute__((deprecated)) - -enum { - blah, - blarg -}; -typedef NSInteger wibble; - -enum { - UIViewAutoresizingNone = 0, - UIViewAutoresizingFlexibleLeftMargin, - UIViewAutoresizingFlexibleWidth, - UIViewAutoresizingFlexibleRightMargin, - UIViewAutoresizingFlexibleTopMargin, - UIViewAutoresizingFlexibleHeight, - UIViewAutoresizingFlexibleBottomMargin -}; -typedef NSUInteger UITableViewCellStyle; - -typedef enum { - UIViewAnimationTransitionNone, - UIViewAnimationTransitionFlipFromLeft, - UIViewAnimationTransitionFlipFromRight, - UIViewAnimationTransitionCurlUp, - UIViewAnimationTransitionCurlDown, -} UIViewAnimationTransition; - -typedef enum { - UIViewOne = 0, - UIViewTwo = 1 << 0, - UIViewThree = 1 << 1, - UIViewFour = 1 << 2, - UIViewFive = 1 << 3, - UIViewSix = 1 << 4, - UIViewSeven = 1 << 5 -} UITableView; - -enum { - UIOne = 0, - UITwo = 0x1, - UIthree = 0x8, - UIFour = 0x100 -}; -typedef NSInteger UI; - -typedef enum { - UIP2One = 0, - UIP2Two = 0x1, - UIP2three = 0x8, - UIP2Four = 0x100 -} UIPOWER2; - -enum { - UNOne, - UNTwo -}; - -// Should use NS_ENUM even though it is all power of 2. -enum { - UIKOne = 1, - UIKTwo = 2, -}; -typedef NSInteger UIK; - -typedef enum { - NSTickMarkBelow = 0, - NSTickMarkAbove = 1, - NSTickMarkLeft = NSTickMarkAbove, - NSTickMarkRight = NSTickMarkBelow -} NSTickMarkPosition; - -enum { - UIViewNone = 0x0, - UIViewMargin = 0x1, - UIViewWidth = 0x2, - UIViewRightMargin = 0x3, - UIViewBottomMargin = 0xbadbeef -}; -typedef NSInteger UITableStyle; - -enum { - UIView0 = 0, - UIView1 = 0XBADBEEF -}; -typedef NSInteger UIStyle; - -enum { - NSTIFFFileType, - NSBMPFileType, - NSGIFFileType, - NSJPEGFileType, - NSPNGFileType, - NSJPEG2000FileType -}; -typedef NSUInteger NSBitmapImageFileType; - -enum { - NSWarningAlertStyle = 0, - NSInformationalAlertStyle = 1, - NSCriticalAlertStyle = 2 -}; -typedef NSUInteger NSAlertStyle; - -enum { - D_NSTIFFFileType, - D_NSBMPFileType, - D_NSGIFFileType, - D_NSJPEGFileType, - D_NSPNGFileType, - D_NSJPEG2000FileType -}; -typedef NSUInteger D_NSBitmapImageFileType DEPRECATED; - -typedef enum { - D_NSTickMarkBelow = 0, - D_NSTickMarkAbove = 1 -} D_NSTickMarkPosition DEPRECATED; - - -#define NS_ENUM_AVAILABLE(X,Y) - -enum { - NSFStrongMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (0UL << 0), - NSFOpaqueMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (2UL << 0), - NSFMallocMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (3UL << 0), - NSFMachVirtualMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (4UL << 0), - NSFWeakMemory NS_ENUM_AVAILABLE(10_8, 6_0) = (5UL << 0), - - NSFObjectPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (0UL << 8), - NSFOpaquePersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (1UL << 8), - NSFObjectPointerPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (2UL << 8), - NSFCStringPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (3UL << 8), - NSFStructPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (4UL << 8), - NSFIntegerPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (5UL << 8), - NSFCopyIn NS_ENUM_AVAILABLE(10_5, 6_0) = (1UL << 16), -}; - -typedef NSUInteger NSFOptions; - -typedef enum { - UIP0One = 0, - UIP0Two = 1, - UIP0Three = 2, - UIP0Four = 10, - UIP0Last = 0x100 -} UIP; - -typedef enum { - UIPZero = 0x0, - UIPOne = 0x1, - UIPTwo = 0x2, - UIP10 = 0x10, - UIPHundred = 0x100 -} UIP_3; - -typedef enum { - UIP4Zero = 0x0, - UIP4One = 0x1, - UIP4Two = 0x2, - UIP410 = 0x10, - UIP4Hundred = 100 -} UIP4_3; - -typedef enum { - UIP5Zero = 0x0, - UIP5Two = 0x2, - UIP510 = 0x3, - UIP5Hundred = 0x4 -} UIP5_3; - -typedef enum { - UIP6Zero = 0x0, - UIP6One = 0x1, - UIP6Two = 0x2, - UIP610 = 10, - UIP6Hundred = 0x100 -} UIP6_3; - -typedef enum { - UIP7Zero = 0x0, - UIP7One = 1, - UIP7Two = 0x2, - UIP710 = 10, - UIP7Hundred = 100 -} UIP7_3; - - -typedef enum { - Random = 0, - Random1 = 2, - Random2 = 4, - Random3 = 0x12345, - Random4 = 0x3444444, - Random5 = 0xbadbeef, - Random6 -} UIP8_3; - -#define NS_AVAILABLE_MAC(X) __attribute__((availability(macosx,introduced=X))) -#define NS_ENUM_AVAILABLE_MAC(X) __attribute__((availability(macosx,introduced=X))) - -enum { - NSModalResponseStop = (-1000), // Also used as the default response for sheets - NSModalResponseAbort = (-1001), - NSModalResponseContinue = (-1002), -} NS_ENUM_AVAILABLE_MAC(10.9); -typedef NSInteger NSModalResponse NS_AVAILABLE_MAC(10.9); - -typedef NSUInteger FarFarAwayOptions; - -typedef NSUInteger FarAwayOptions; -enum { - NSWorkspaceLaunchAndPrint = 0x00000002, - NSWorkspaceLaunchWithErrorPresentation = 0x00000040, - NSWorkspaceLaunchInhibitingBackgroundOnly = 0x00000080, - NSWorkspaceLaunchWithoutAddingToRecents = 0x00000100, - NSWorkspaceLaunchWithoutActivation = 0x00000200, - NSWorkspaceLaunchAsync = 0x00010000, - NSWorkspaceLaunchAllowingClassicStartup = 0x00020000, - NSWorkspaceLaunchPreferringClassic = 0x00040000, - NSWorkspaceLaunchNewInstance = 0x00080000, - NSWorkspaceLaunchAndHide = 0x00100000, - NSWorkspaceLaunchAndHideOthers = 0x00200000, - NSWorkspaceLaunchDefault = NSWorkspaceLaunchAsync | - NSWorkspaceLaunchAllowingClassicStartup -}; -typedef NSUInteger NSWorkspaceLaunchOptions; - -enum { - NSExcludeQuickDrawElementsIconCreationOption = 1 << 1, - NSExclude10_4ElementsIconCreationOption = 1 << 2 -}; -typedef NSUInteger NSExcludeOptions; - -enum { - NSExcludeQuickDrawElementsCreationOption = 1 << 1, - NSExclude10_4ElementsCreationOption = 1 << 2 -}; -typedef NSUInteger NSExcludeCreationOption; - -enum { - FarAway1 = 1 << 1, - FarAway2 = 1 << 2 -}; - -enum { - NSExcludeQuickDrawElementsIconOption = 1 << 1, - NSExclude10_4ElementsIconOption = 1 << 2 -}; -typedef NSUInteger NSExcludeIconOptions; - -@interface INTF { - NSExcludeIconOptions I1; - NSExcludeIconOptions I2; -} -@end - -enum { - FarFarAway1 = 1 << 1, - FarFarAway2 = 1 << 2 -}; - -typedef NS_OPTIONS(NSUInteger, NSWindowOcclusionState) { - NSWindowOcclusionStateVisible = 1UL << 1, -}; - -typedef NSUInteger NSWindowNumberListOptions; - -enum { - NSDirectSelection = 0, - NSSelectingNext, - NSSelectingPrevious -}; -typedef NSUInteger NSSelectionDirection; - -// standard window buttons -enum { - NSWindowCloseButton, - NSWindowMiniaturizeButton, - NSWindowZoomButton, - NSWindowToolbarButton, - NSWindowDocumentIconButton -}; - -typedef enum : NSUInteger { - ThingOne, - ThingTwo, - ThingThree, -} Thing; - -typedef enum { - one = 1 -} NumericEnum; - -typedef enum { - Two = 2 -}NumericEnum2; - -typedef enum { - Three = 3 -} -NumericEnum3; - -typedef enum { - Four = 4 -} - - NumericEnum4; - -enum -{ - UI8one = 1 -}; -typedef int8_t MyEnumeratedType; - - -enum { - UI16One = 0, - UI16Two = 0x1, - UI16three = 0x8, - UI16Four = 0x100 -}; -typedef int16_t UI16; - -enum { - UI32ViewAutoresizingNone = 0, - UI32ViewAutoresizingFlexibleLeftMargin, - UI32ViewAutoresizingFlexibleWidth, - UI32ViewAutoresizingFlexibleRightMargin, - UI32ViewAutoresizingFlexibleTopMargin, - UI32ViewAutoresizingFlexibleHeight, - UI32ViewAutoresizingFlexibleBottomMargin -}; -typedef uint32_t UI32TableViewCellStyle; - -enum -{ - UIU8one = 1 -}; -typedef uint8_t UI8Type; - -typedef enum : NSInteger {zero} MyEnum; - -typedef enum : NSUInteger {two} MyEnumNSUInteger; - -typedef enum : int {three, four} MyEnumint; - -typedef enum : unsigned long {five} MyEnumlonglong; - -typedef enum : unsigned long long { - ll1, - ll2= 0xff, - ll3, - ll4 -} MyEnumunsignedlonglong; - -typedef enum : int8_t {int8_one} MyOneEnum; - -typedef enum : int16_t { - int16_t_one, - int16_t_two } Myint16_tEnum; diff --git clang/test/ARCMT/objcmt-ns-macros.m.result clang/test/ARCMT/objcmt-ns-macros.m.result deleted file mode 100644 index d4c0870e8cdc..000000000000 --- clang/test/ARCMT/objcmt-ns-macros.m.result +++ /dev/null @@ -1,355 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -typedef signed char int8_t; -typedef short int16_t; -typedef int int32_t; -typedef long NSInteger; -typedef long long int64_t; - -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; -typedef unsigned long NSUInteger; -typedef unsigned long long uint64_t; - -#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type -#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type -#define DEPRECATED __attribute__((deprecated)) - -typedef NS_ENUM(NSInteger, wibble) { - blah, - blarg -}; - -typedef NS_ENUM(NSUInteger, UITableViewCellStyle) { - UIViewAutoresizingNone = 0, - UIViewAutoresizingFlexibleLeftMargin, - UIViewAutoresizingFlexibleWidth, - UIViewAutoresizingFlexibleRightMargin, - UIViewAutoresizingFlexibleTopMargin, - UIViewAutoresizingFlexibleHeight, - UIViewAutoresizingFlexibleBottomMargin -}; - -typedef NS_ENUM(unsigned int, UIViewAnimationTransition) { - UIViewAnimationTransitionNone, - UIViewAnimationTransitionFlipFromLeft, - UIViewAnimationTransitionFlipFromRight, - UIViewAnimationTransitionCurlUp, - UIViewAnimationTransitionCurlDown, -}; - -typedef NS_OPTIONS(unsigned int, UITableView) { - UIViewOne = 0, - UIViewTwo = 1 << 0, - UIViewThree = 1 << 1, - UIViewFour = 1 << 2, - UIViewFive = 1 << 3, - UIViewSix = 1 << 4, - UIViewSeven = 1 << 5 -}; - -typedef NS_OPTIONS(NSUInteger, UI) { - UIOne = 0, - UITwo = 0x1, - UIthree = 0x8, - UIFour = 0x100 -}; - -typedef NS_OPTIONS(unsigned int, UIPOWER2) { - UIP2One = 0, - UIP2Two = 0x1, - UIP2three = 0x8, - UIP2Four = 0x100 -}; - -enum { - UNOne, - UNTwo -}; - -// Should use NS_ENUM even though it is all power of 2. -typedef NS_ENUM(NSInteger, UIK) { - UIKOne = 1, - UIKTwo = 2, -}; - -typedef NS_ENUM(unsigned int, NSTickMarkPosition) { - NSTickMarkBelow = 0, - NSTickMarkAbove = 1, - NSTickMarkLeft = NSTickMarkAbove, - NSTickMarkRight = NSTickMarkBelow -}; - -typedef NS_OPTIONS(NSUInteger, UITableStyle) { - UIViewNone = 0x0, - UIViewMargin = 0x1, - UIViewWidth = 0x2, - UIViewRightMargin = 0x3, - UIViewBottomMargin = 0xbadbeef -}; - -typedef NS_OPTIONS(NSUInteger, UIStyle) { - UIView0 = 0, - UIView1 = 0XBADBEEF -}; - -typedef NS_ENUM(NSUInteger, NSBitmapImageFileType) { - NSTIFFFileType, - NSBMPFileType, - NSGIFFileType, - NSJPEGFileType, - NSPNGFileType, - NSJPEG2000FileType -}; - -typedef NS_ENUM(NSUInteger, NSAlertStyle) { - NSWarningAlertStyle = 0, - NSInformationalAlertStyle = 1, - NSCriticalAlertStyle = 2 -}; - -enum { - D_NSTIFFFileType, - D_NSBMPFileType, - D_NSGIFFileType, - D_NSJPEGFileType, - D_NSPNGFileType, - D_NSJPEG2000FileType -}; -typedef NSUInteger D_NSBitmapImageFileType DEPRECATED; - -typedef enum { - D_NSTickMarkBelow = 0, - D_NSTickMarkAbove = 1 -} D_NSTickMarkPosition DEPRECATED; - - -#define NS_ENUM_AVAILABLE(X,Y) - - -typedef NS_OPTIONS(NSUInteger, NSFOptions) { - NSFStrongMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (0UL << 0), - NSFOpaqueMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (2UL << 0), - NSFMallocMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (3UL << 0), - NSFMachVirtualMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (4UL << 0), - NSFWeakMemory NS_ENUM_AVAILABLE(10_8, 6_0) = (5UL << 0), - - NSFObjectPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (0UL << 8), - NSFOpaquePersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (1UL << 8), - NSFObjectPointerPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (2UL << 8), - NSFCStringPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (3UL << 8), - NSFStructPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (4UL << 8), - NSFIntegerPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (5UL << 8), - NSFCopyIn NS_ENUM_AVAILABLE(10_5, 6_0) = (1UL << 16), -}; - -typedef NS_ENUM(unsigned int, UIP) { - UIP0One = 0, - UIP0Two = 1, - UIP0Three = 2, - UIP0Four = 10, - UIP0Last = 0x100 -}; - -typedef NS_OPTIONS(unsigned int, UIP_3) { - UIPZero = 0x0, - UIPOne = 0x1, - UIPTwo = 0x2, - UIP10 = 0x10, - UIPHundred = 0x100 -}; - -typedef NS_ENUM(unsigned int, UIP4_3) { - UIP4Zero = 0x0, - UIP4One = 0x1, - UIP4Two = 0x2, - UIP410 = 0x10, - UIP4Hundred = 100 -}; - -typedef NS_OPTIONS(unsigned int, UIP5_3) { - UIP5Zero = 0x0, - UIP5Two = 0x2, - UIP510 = 0x3, - UIP5Hundred = 0x4 -}; - -typedef NS_ENUM(unsigned int, UIP6_3) { - UIP6Zero = 0x0, - UIP6One = 0x1, - UIP6Two = 0x2, - UIP610 = 10, - UIP6Hundred = 0x100 -}; - -typedef NS_ENUM(unsigned int, UIP7_3) { - UIP7Zero = 0x0, - UIP7One = 1, - UIP7Two = 0x2, - UIP710 = 10, - UIP7Hundred = 100 -}; - - -typedef NS_ENUM(unsigned int, UIP8_3) { - Random = 0, - Random1 = 2, - Random2 = 4, - Random3 = 0x12345, - Random4 = 0x3444444, - Random5 = 0xbadbeef, - Random6 -}; - -#define NS_AVAILABLE_MAC(X) __attribute__((availability(macosx,introduced=X))) -#define NS_ENUM_AVAILABLE_MAC(X) __attribute__((availability(macosx,introduced=X))) - -typedef NS_ENUM(NSInteger, NSModalResponse) { - NSModalResponseStop = (-1000), // Also used as the default response for sheets - NSModalResponseAbort = (-1001), - NSModalResponseContinue = (-1002), -} NS_ENUM_AVAILABLE_MAC(10.9); - -typedef NSUInteger FarFarAwayOptions; - -typedef NS_OPTIONS(NSUInteger, FarAwayOptions) { - FarAway1 = 1 << 1, - FarAway2 = 1 << 2 -}; -typedef NS_OPTIONS(NSUInteger, NSWorkspaceLaunchOptions) { - NSWorkspaceLaunchAndPrint = 0x00000002, - NSWorkspaceLaunchWithErrorPresentation = 0x00000040, - NSWorkspaceLaunchInhibitingBackgroundOnly = 0x00000080, - NSWorkspaceLaunchWithoutAddingToRecents = 0x00000100, - NSWorkspaceLaunchWithoutActivation = 0x00000200, - NSWorkspaceLaunchAsync = 0x00010000, - NSWorkspaceLaunchAllowingClassicStartup = 0x00020000, - NSWorkspaceLaunchPreferringClassic = 0x00040000, - NSWorkspaceLaunchNewInstance = 0x00080000, - NSWorkspaceLaunchAndHide = 0x00100000, - NSWorkspaceLaunchAndHideOthers = 0x00200000, - NSWorkspaceLaunchDefault = NSWorkspaceLaunchAsync | - NSWorkspaceLaunchAllowingClassicStartup -}; - -typedef NS_OPTIONS(NSUInteger, NSExcludeOptions) { - NSExcludeQuickDrawElementsIconCreationOption = 1 << 1, - NSExclude10_4ElementsIconCreationOption = 1 << 2 -}; - -typedef NS_OPTIONS(NSUInteger, NSExcludeCreationOption) { - NSExcludeQuickDrawElementsCreationOption = 1 << 1, - NSExclude10_4ElementsCreationOption = 1 << 2 -}; - - -typedef NS_OPTIONS(NSUInteger, NSExcludeIconOptions) { - NSExcludeQuickDrawElementsIconOption = 1 << 1, - NSExclude10_4ElementsIconOption = 1 << 2 -}; - -@interface INTF { - NSExcludeIconOptions I1; - NSExcludeIconOptions I2; -} -@end - -enum { - FarFarAway1 = 1 << 1, - FarFarAway2 = 1 << 2 -}; - -typedef NS_OPTIONS(NSUInteger, NSWindowOcclusionState) { - NSWindowOcclusionStateVisible = 1UL << 1, -}; - -typedef NS_ENUM(NSUInteger, NSWindowNumberListOptions) { - NSWindowCloseButton, - NSWindowMiniaturizeButton, - NSWindowZoomButton, - NSWindowToolbarButton, - NSWindowDocumentIconButton -}; - -typedef NS_ENUM(NSUInteger, NSSelectionDirection) { - NSDirectSelection = 0, - NSSelectingNext, - NSSelectingPrevious -}; - -// standard window buttons - -typedef NS_ENUM(NSUInteger, Thing) { - ThingOne, - ThingTwo, - ThingThree, -}; - -typedef NS_ENUM(unsigned int, NumericEnum) { - one = 1 -}; - -typedef NS_ENUM(unsigned int, NumericEnum2) { - Two = 2 -}; - -typedef NS_ENUM(unsigned int, NumericEnum3) { - Three = 3 -}; - -typedef NS_OPTIONS(unsigned int, NumericEnum4) { - Four = 4 -}; - -typedef NS_ENUM(int8_t, MyEnumeratedType) -{ - UI8one = 1 -}; - - -typedef NS_OPTIONS(uint16_t, UI16) { - UI16One = 0, - UI16Two = 0x1, - UI16three = 0x8, - UI16Four = 0x100 -}; - -typedef NS_ENUM(uint32_t, UI32TableViewCellStyle) { - UI32ViewAutoresizingNone = 0, - UI32ViewAutoresizingFlexibleLeftMargin, - UI32ViewAutoresizingFlexibleWidth, - UI32ViewAutoresizingFlexibleRightMargin, - UI32ViewAutoresizingFlexibleTopMargin, - UI32ViewAutoresizingFlexibleHeight, - UI32ViewAutoresizingFlexibleBottomMargin -}; - -typedef NS_ENUM(uint8_t, UI8Type) -{ - UIU8one = 1 -}; - -typedef NS_ENUM(NSInteger, MyEnum) {zero}; - -typedef NS_ENUM(NSUInteger, MyEnumNSUInteger) {two}; - -typedef NS_ENUM(int, MyEnumint) {three, four}; - -typedef NS_ENUM(unsigned long, MyEnumlonglong) {five}; - -typedef NS_ENUM(unsigned long long, MyEnumunsignedlonglong) { - ll1, - ll2= 0xff, - ll3, - ll4 -}; - -typedef NS_ENUM(int8_t, MyOneEnum) {int8_one}; - -typedef NS_ENUM(int16_t, Myint16_tEnum) { - int16_t_one, - int16_t_two }; diff --git clang/test/ARCMT/objcmt-ns-nonatomic-iosonly.m clang/test/ARCMT/objcmt-ns-nonatomic-iosonly.m deleted file mode 100644 index 55a116c8ca5d..000000000000 --- clang/test/ARCMT/objcmt-ns-nonatomic-iosonly.m +++ /dev/null @@ -1,233 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -objcmt-ns-nonatomic-iosonly -objcmt-migrate-readonly-property -objcmt-atomic-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -#define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION -#define WEAK_IMPORT_ATTRIBUTE __attribute__((objc_arc_weak_reference_unavailable)) -#define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER -#define DEPRECATED __attribute__((deprecated)) - -#if TARGET_OS_IPHONE - #define NS_NONATOMIC_IOSONLY nonatomic -#else - #define NS_NONATOMIC_IOSONLY atomic -#endif - -typedef char BOOL; -@class NSString; -@protocol NSCopying @end - -@interface NSObject <NSCopying> -@end - -@interface NSDictionary : NSObject -@end - -@interface I : NSObject { - int ivarVal; -} -- (void) setWeakProp : (NSString *__weak)Val; -- (NSString *__weak) WeakProp; - -- (NSString *) StrongProp; -- (void) setStrongProp : (NSString *)Val; - -- (NSString *) UnavailProp __attribute__((unavailable)); -- (void) setUnavailProp : (NSString *)Val; - -- (NSString *) UnavailProp1 __attribute__((unavailable)); -- (void) setUnavailProp1 : (NSString *)Val __attribute__((unavailable)); - -- (NSString *) UnavailProp2; -- (void) setUnavailProp2 : (NSString *)Val __attribute__((unavailable)); - -- (NSDictionary*) undoAction; -- (void) setUndoAction: (NSDictionary*)Arg; -@end - -@implementation I -@end - -@class NSArray; - -@interface MyClass2 { -@private - NSArray *_names1; - NSArray *_names2; - NSArray *_names3; - NSArray *_names4; -} -- (void)setNames1:(NSArray *)names; -- (void)setNames4:(__strong NSArray *)names; -- (void)setNames3:(__strong NSArray *)names; -- (void)setNames2:(NSArray *)names; -- (NSArray *) names2; -- (NSArray *)names3; -- (__strong NSArray *)names4; -- (NSArray *) names1; -@end - -// Properties that contain the name "delegate" or "dataSource", -// or have exact name "target" have unsafe_unretained attribute. -@interface NSInvocation -- (id)target; -- (void)setTarget:(id)target; - -- (id) dataSource; - -- (id)xxxdelegateYYY; -- (void)setXxxdelegateYYY:(id)delegate; - -- (void)setDataSource:(id)source; - -- (id)MYtarget; -- (void)setMYtarget: (id)target; - -- (id)targetX; -- (void)setTargetX: (id)t; - -- (int)value; -- (void)setValue: (int)val; - --(BOOL) isContinuous; --(void) setContinuous:(BOOL)value; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -- (int) Length; -- (id) object; -+ (double) D; -- (void *)JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER); -- (BOOL)isIgnoringInteractionEvents; - -- (NSString *)getStringValue; -- (BOOL)getCounterValue; -- (void)setStringValue:(NSString *)stringValue AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; -- (NSDictionary *)getns_dixtionary; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -- (BOOL) getM; -- (BOOL) getMA; -- (BOOL) getALL; -- (BOOL) getMANY; -- (BOOL) getSome; -@end - - -@interface NSInvocation(CAT) -- (id)target; -- (void)setTarget:(id)target; - -- (id) dataSource; - -- (id)xxxdelegateYYY; -- (void)setXxxdelegateYYY:(id)delegate; - -- (void)setDataSource:(id)source; - -- (id)MYtarget; -- (void)setMYtarget: (id)target; - -- (id)targetX; -- (void)setTargetX: (id)t; - -- (int)value; -- (void)setValue: (int)val; - --(BOOL) isContinuous; --(void) setContinuous:(BOOL)value; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -- (int) Length; -- (id) object; -+ (double) D; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -- (BOOL) getM; -- (BOOL) getMA; -- (BOOL) getALL; -- (BOOL) getMANY; -- (BOOL) getSome; -@end - -DEPRECATED -@interface I_DEP -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; -@end - -@interface AnotherOne -- (BOOL) isinValid DEPRECATED; -- (void) setInValid : (BOOL) arg; -- (id)MYtarget; -- (void)setMYtarget: (id)target DEPRECATED; -- (BOOL) getM DEPRECATED; - -- (id)xxxdelegateYYY DEPRECATED; -- (void)setXxxdelegateYYY:(id)delegate DEPRECATED; -@end - -#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0))) -#define NORETURN __attribute__((noreturn)) -#define ALIGNED __attribute__((aligned(16))) - -@interface NSURL -// Do not infer a property. -- (NSURL *)appStoreReceiptURL NS_AVAILABLE; -- (void) setAppStoreReceiptURL : (NSURL *)object; - -- (NSURL *)appStoreReceiptURLX NS_AVAILABLE; -- (void) setAppStoreReceiptURLX : (NSURL *)object NS_AVAILABLE; - -// Do not infer a property. -- (NSURL *)appStoreReceiptURLY ; -- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE; - -- (id)OkToInfer NS_AVAILABLE; - -// Do not infer a property. -- (NSURL *)appStoreReceiptURLZ ; -- (void) setAppStoreReceiptURLZ : (NSURL *)object NS_AVAILABLE; - -// Do not infer a property. -- (id) t1 NORETURN NS_AVAILABLE; -- (void) setT1 : (id) arg NS_AVAILABLE; - -- (id)method1 ALIGNED NS_AVAILABLE; -- (void) setMethod1 : (id) object NS_AVAILABLE ALIGNED; - -- (NSURL *)init; // No Change -+ (id)alloc; // No Change - -- (BOOL)is1stClass; // Not a valid property -- (BOOL)isClass; // This is a valid property 'class' is not a keyword in ObjC -- (BOOL)isDouble; // Not a valid property - -@end - -@class NSMutableDictionary; - -@interface NSArray -- (id (^)(id, NSArray *, NSMutableDictionary *)) expressionBlock; -- (id (^)(id, NSArray *, NSMutableDictionary *)) MyBlock; -- (void) setMyBlock : (id (^)(id, NSArray *, NSMutableDictionary *)) bl; -- (id (*)(id, NSArray *, NSMutableDictionary *)) expressionFuncptr; -- (id (*)(id, NSArray *, NSMutableDictionary *)) MyFuncptr; -- (void) setMyFuncptr : (id (*)(id, NSArray *, NSMutableDictionary *)) bl; -@end diff --git clang/test/ARCMT/objcmt-ns-nonatomic-iosonly.m.result clang/test/ARCMT/objcmt-ns-nonatomic-iosonly.m.result deleted file mode 100644 index 512deb12583a..000000000000 --- clang/test/ARCMT/objcmt-ns-nonatomic-iosonly.m.result +++ /dev/null @@ -1,206 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -objcmt-ns-nonatomic-iosonly -objcmt-migrate-readonly-property -objcmt-atomic-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -#define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION -#define WEAK_IMPORT_ATTRIBUTE __attribute__((objc_arc_weak_reference_unavailable)) -#define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER -#define DEPRECATED __attribute__((deprecated)) - -#if TARGET_OS_IPHONE - #define NS_NONATOMIC_IOSONLY nonatomic -#else - #define NS_NONATOMIC_IOSONLY atomic -#endif - -typedef char BOOL; -@class NSString; -@protocol NSCopying @end - -@interface NSObject <NSCopying> -@end - -@interface NSDictionary : NSObject -@end - -@interface I : NSObject { - int ivarVal; -} -@property (NS_NONATOMIC_IOSONLY, weak) NSString *WeakProp; - -@property (NS_NONATOMIC_IOSONLY, strong) NSString *StrongProp; - -@property (NS_NONATOMIC_IOSONLY, strong) NSString *UnavailProp __attribute__((unavailable)); -- (void) setUnavailProp : (NSString *)Val; - -@property (NS_NONATOMIC_IOSONLY, strong) NSString *UnavailProp1 __attribute__((unavailable)); - -@property (NS_NONATOMIC_IOSONLY, strong) NSString *UnavailProp2; -- (void) setUnavailProp2 : (NSString *)Val __attribute__((unavailable)); - -@property (NS_NONATOMIC_IOSONLY, copy) NSDictionary *undoAction; -@end - -@implementation I -@end - -@class NSArray; - -@interface MyClass2 { -@private - NSArray *_names1; - NSArray *_names2; - NSArray *_names3; - NSArray *_names4; -} -@property (NS_NONATOMIC_IOSONLY, strong) NSArray *names2; -@property (NS_NONATOMIC_IOSONLY, strong) NSArray *names3; -@property (NS_NONATOMIC_IOSONLY, strong) NSArray *names4; -@property (NS_NONATOMIC_IOSONLY, strong) NSArray *names1; -@end - -// Properties that contain the name "delegate" or "dataSource", -// or have exact name "target" have unsafe_unretained attribute. -@interface NSInvocation -@property (NS_NONATOMIC_IOSONLY, assign) id target; - -@property (NS_NONATOMIC_IOSONLY, assign) id dataSource; - -@property (NS_NONATOMIC_IOSONLY, assign) id xxxdelegateYYY; - - -@property (NS_NONATOMIC_IOSONLY, strong) id MYtarget; - -@property (NS_NONATOMIC_IOSONLY, strong) id targetX; - -@property (NS_NONATOMIC_IOSONLY) int value; - -@property (NS_NONATOMIC_IOSONLY, getter=isContinuous) BOOL continuous; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -@property (NS_NONATOMIC_IOSONLY, getter=isinValid, readonly) BOOL inValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -@property (NS_NONATOMIC_IOSONLY, readonly) int Length; -@property (NS_NONATOMIC_IOSONLY, readonly, strong) id object; -+ (double) D; -@property (NS_NONATOMIC_IOSONLY, readonly) void *JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER); -@property (NS_NONATOMIC_IOSONLY, getter=isIgnoringInteractionEvents, readonly) BOOL ignoringInteractionEvents; - -@property (NS_NONATOMIC_IOSONLY, getter=getStringValue, strong) NSString *stringValue; -@property (NS_NONATOMIC_IOSONLY, getter=getCounterValue, readonly) BOOL counterValue; -@property (NS_NONATOMIC_IOSONLY, getter=getns_dixtionary, readonly, copy) NSDictionary *ns_dixtionary; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -@property (NS_NONATOMIC_IOSONLY, getter=getM, readonly) BOOL m; -@property (NS_NONATOMIC_IOSONLY, getter=getMA, readonly) BOOL MA; -@property (NS_NONATOMIC_IOSONLY, getter=getALL, readonly) BOOL ALL; -@property (NS_NONATOMIC_IOSONLY, getter=getMANY, readonly) BOOL MANY; -@property (NS_NONATOMIC_IOSONLY, getter=getSome, readonly) BOOL some; -@end - - -@interface NSInvocation(CAT) -@property (NS_NONATOMIC_IOSONLY, assign) id target; - -@property (NS_NONATOMIC_IOSONLY, assign) id dataSource; - -@property (NS_NONATOMIC_IOSONLY, assign) id xxxdelegateYYY; - - -@property (NS_NONATOMIC_IOSONLY, strong) id MYtarget; - -@property (NS_NONATOMIC_IOSONLY, strong) id targetX; - -@property (NS_NONATOMIC_IOSONLY) int value; - -@property (NS_NONATOMIC_IOSONLY, getter=isContinuous) BOOL continuous; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -@property (NS_NONATOMIC_IOSONLY, getter=isinValid, readonly) BOOL inValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -@property (NS_NONATOMIC_IOSONLY, readonly) int Length; -@property (NS_NONATOMIC_IOSONLY, readonly, strong) id object; -+ (double) D; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -@property (NS_NONATOMIC_IOSONLY, getter=getM, readonly) BOOL m; -@property (NS_NONATOMIC_IOSONLY, getter=getMA, readonly) BOOL MA; -@property (NS_NONATOMIC_IOSONLY, getter=getALL, readonly) BOOL ALL; -@property (NS_NONATOMIC_IOSONLY, getter=getMANY, readonly) BOOL MANY; -@property (NS_NONATOMIC_IOSONLY, getter=getSome, readonly) BOOL some; -@end - -DEPRECATED -@interface I_DEP -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; -@end - -@interface AnotherOne -- (BOOL) isinValid DEPRECATED; -- (void) setInValid : (BOOL) arg; -- (id)MYtarget; -- (void)setMYtarget: (id)target DEPRECATED; -- (BOOL) getM DEPRECATED; - -- (id)xxxdelegateYYY DEPRECATED; -- (void)setXxxdelegateYYY:(id)delegate DEPRECATED; -@end - -#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0))) -#define NORETURN __attribute__((noreturn)) -#define ALIGNED __attribute__((aligned(16))) - -@interface NSURL -// Do not infer a property. -@property (NS_NONATOMIC_IOSONLY, strong) NSURL *appStoreReceiptURL NS_AVAILABLE; -- (void) setAppStoreReceiptURL : (NSURL *)object; - -@property (NS_NONATOMIC_IOSONLY, strong) NSURL *appStoreReceiptURLX NS_AVAILABLE; - -// Do not infer a property. -@property (NS_NONATOMIC_IOSONLY, strong) NSURL *appStoreReceiptURLY ; -- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE; - -@property (NS_NONATOMIC_IOSONLY, readonly, strong) id OkToInfer NS_AVAILABLE; - -// Do not infer a property. -@property (NS_NONATOMIC_IOSONLY, strong) NSURL *appStoreReceiptURLZ ; -- (void) setAppStoreReceiptURLZ : (NSURL *)object NS_AVAILABLE; - -// Do not infer a property. -- (id) t1 NORETURN NS_AVAILABLE; -- (void) setT1 : (id) arg NS_AVAILABLE; - -@property (NS_NONATOMIC_IOSONLY, strong) id method1 ALIGNED NS_AVAILABLE; - -- (NSURL *)init; // No Change -+ (id)alloc; // No Change - -- (BOOL)is1stClass; // Not a valid property -@property (NS_NONATOMIC_IOSONLY, getter=isClass, readonly) BOOL class; // This is a valid property 'class' is not a keyword in ObjC -- (BOOL)isDouble; // Not a valid property - -@end - -@class NSMutableDictionary; - -@interface NSArray -@property (NS_NONATOMIC_IOSONLY, readonly, copy) id (^expressionBlock)(id, NSArray *, NSMutableDictionary *); -@property (NS_NONATOMIC_IOSONLY, copy) id (^MyBlock)(id, NSArray *, NSMutableDictionary *); -@property (NS_NONATOMIC_IOSONLY, readonly) id (*expressionFuncptr)(id, NSArray *, NSMutableDictionary *); -@property (NS_NONATOMIC_IOSONLY) id (*MyFuncptr)(id, NSArray *, NSMutableDictionary *); -@end diff --git clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m deleted file mode 100644 index 853d16dc7894..000000000000 --- clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m +++ /dev/null @@ -1,128 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-returns-innerpointer-property -objcmt-migrate-annotation -objcmt-migrate-readwrite-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -#ifndef NS_RETURNS_INNER_POINTER // defined in iOS 6 for sure -#define NS_RETURNS_INNER_POINTER __attribute__((objc_returns_inner_pointer)) -#endif - -#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin") - -#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end") - -#if __has_feature(attribute_ns_returns_retained) -#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) -#endif -#if __has_feature(attribute_cf_returns_retained) -#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) -#endif -#if __has_feature(attribute_ns_returns_not_retained) -#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained)) -#endif -#if __has_feature(attribute_cf_returns_not_retained) -#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained)) -#endif -#if __has_feature(attribute_ns_consumes_self) -#define NS_CONSUMES_SELF __attribute__((ns_consumes_self)) -#endif -#if __has_feature(attribute_ns_consumed) -#define NS_CONSUMED __attribute__((ns_consumed)) -#endif -#if __has_feature(attribute_cf_consumed) -#define CF_CONSUMED __attribute__((cf_consumed)) -#endif -#if __has_attribute(ns_returns_autoreleased) -#define NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased)) -#endif - -#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0))) - -CF_IMPLICIT_BRIDGING_ENABLED - -typedef unsigned long CFTypeID; -typedef unsigned long CFOptionFlags; -typedef unsigned long CFHashCode; - -typedef signed long CFIndex; /*AnyObj*/ -typedef const struct __CFArray * CFArrayRef; -typedef struct { - CFIndex location; - CFIndex length; -} CFRange; - -typedef void (*CFArrayApplierFunction)(const void *value, void *context); - -typedef enum CFComparisonResult : CFIndex CFComparisonResult; enum CFComparisonResult : CFIndex { - kCFCompareLessThan = -1L, - kCFCompareEqualTo = 0, - kCFCompareGreaterThan = 1 -}; - - -typedef CFComparisonResult (*CFComparatorFunction)(const void *val1, const void *val2, void *context); - -typedef struct __CFArray * CFMutableArrayRef; - -typedef const struct __CFAttributedString *CFAttributedStringRef; -typedef struct __CFAttributedString *CFMutableAttributedStringRef; - -typedef const struct __CFAllocator * CFAllocatorRef; - -typedef const struct __CFString * CFStringRef; -typedef struct __CFString * CFMutableStringRef; - -typedef const struct __CFDictionary * CFDictionaryRef; -typedef struct __CFDictionary * CFMutableDictionaryRef; - -typedef struct CGImage *CGImageRef; - -typedef struct OpaqueJSValue* JSObjectRef; - -typedef JSObjectRef TTJSObjectRef; -typedef unsigned int NSUInteger; - -CF_IMPLICIT_BRIDGING_DISABLED - -@interface I -- (void*) ReturnsInnerPointer; -- (int*) AlreadyReturnsInnerPointer NS_RETURNS_INNER_POINTER; -@end - -@interface UIImage -- (CGImageRef)CGImage; -@end - -@interface NSData -- (void *)bytes; -- (void **) ptr_bytes __attribute__((availability(macosx,unavailable))); -@end - -@interface NSMutableData -- (void *)mutableBytes __attribute__((deprecated)) __attribute__((unavailable)); -@end - -@interface JS -- (JSObjectRef)JSObject; -- (TTJSObjectRef)JSObject1; -- (JSObjectRef*)JSObject2; -@end - -typedef void *SecTrustRef; - -@interface NSURLProtectionSpace -@property (readonly) SecTrustRef serverTrust NS_AVAILABLE; -- (void *) FOO NS_AVAILABLE; -@property (readonly) void * mitTrust NS_AVAILABLE; - -@property (readonly) void * mittiTrust; - -@property (readonly) SecTrustRef XserverTrust; - -- (SecTrustRef) FOO1 NS_AVAILABLE; - -+ (const NSURLProtectionSpace *)ProtectionSpace; - -// pointer personality functions -@property NSUInteger (*hashFunction)(const void *item, NSUInteger (*size)(const void *item)); -@end diff --git clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result deleted file mode 100644 index c89c91eedce3..000000000000 --- clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result +++ /dev/null @@ -1,128 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-returns-innerpointer-property -objcmt-migrate-annotation -objcmt-migrate-readwrite-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -#ifndef NS_RETURNS_INNER_POINTER // defined in iOS 6 for sure -#define NS_RETURNS_INNER_POINTER __attribute__((objc_returns_inner_pointer)) -#endif - -#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin") - -#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end") - -#if __has_feature(attribute_ns_returns_retained) -#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) -#endif -#if __has_feature(attribute_cf_returns_retained) -#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) -#endif -#if __has_feature(attribute_ns_returns_not_retained) -#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained)) -#endif -#if __has_feature(attribute_cf_returns_not_retained) -#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained)) -#endif -#if __has_feature(attribute_ns_consumes_self) -#define NS_CONSUMES_SELF __attribute__((ns_consumes_self)) -#endif -#if __has_feature(attribute_ns_consumed) -#define NS_CONSUMED __attribute__((ns_consumed)) -#endif -#if __has_feature(attribute_cf_consumed) -#define CF_CONSUMED __attribute__((cf_consumed)) -#endif -#if __has_attribute(ns_returns_autoreleased) -#define NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased)) -#endif - -#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0))) - -CF_IMPLICIT_BRIDGING_ENABLED - -typedef unsigned long CFTypeID; -typedef unsigned long CFOptionFlags; -typedef unsigned long CFHashCode; - -typedef signed long CFIndex; /*AnyObj*/ -typedef const struct __CFArray * CFArrayRef; -typedef struct { - CFIndex location; - CFIndex length; -} CFRange; - -typedef void (*CFArrayApplierFunction)(const void *value, void *context); - -typedef enum CFComparisonResult : CFIndex CFComparisonResult; enum CFComparisonResult : CFIndex { - kCFCompareLessThan = -1L, - kCFCompareEqualTo = 0, - kCFCompareGreaterThan = 1 -}; - - -typedef CFComparisonResult (*CFComparatorFunction)(const void *val1, const void *val2, void *context); - -typedef struct __CFArray * CFMutableArrayRef; - -typedef const struct __CFAttributedString *CFAttributedStringRef; -typedef struct __CFAttributedString *CFMutableAttributedStringRef; - -typedef const struct __CFAllocator * CFAllocatorRef; - -typedef const struct __CFString * CFStringRef; -typedef struct __CFString * CFMutableStringRef; - -typedef const struct __CFDictionary * CFDictionaryRef; -typedef struct __CFDictionary * CFMutableDictionaryRef; - -typedef struct CGImage *CGImageRef; - -typedef struct OpaqueJSValue* JSObjectRef; - -typedef JSObjectRef TTJSObjectRef; -typedef unsigned int NSUInteger; - -CF_IMPLICIT_BRIDGING_DISABLED - -@interface I -- (void*) ReturnsInnerPointer NS_RETURNS_INNER_POINTER; -- (int*) AlreadyReturnsInnerPointer NS_RETURNS_INNER_POINTER; -@end - -@interface UIImage -- (CGImageRef)CGImage CF_RETURNS_NOT_RETAINED; -@end - -@interface NSData -- (void *)bytes NS_RETURNS_INNER_POINTER; -- (void **) ptr_bytes __attribute__((availability(macosx,unavailable))) NS_RETURNS_INNER_POINTER; -@end - -@interface NSMutableData -- (void *)mutableBytes __attribute__((deprecated)) __attribute__((unavailable)) NS_RETURNS_INNER_POINTER; -@end - -@interface JS -- (JSObjectRef)JSObject; -- (TTJSObjectRef)JSObject1; -- (JSObjectRef*)JSObject2 NS_RETURNS_INNER_POINTER; -@end - -typedef void *SecTrustRef; - -@interface NSURLProtectionSpace -@property (readonly) SecTrustRef NS_RETURNS_INNER_POINTER serverTrust NS_AVAILABLE; -- (void *) FOO NS_AVAILABLE NS_RETURNS_INNER_POINTER; -@property (readonly) void * NS_RETURNS_INNER_POINTER mitTrust NS_AVAILABLE; - -@property (readonly) void * NS_RETURNS_INNER_POINTER mittiTrust; - -@property (readonly) SecTrustRef NS_RETURNS_INNER_POINTER XserverTrust; - -- (SecTrustRef) FOO1 NS_AVAILABLE NS_RETURNS_INNER_POINTER; - -+ (const NSURLProtectionSpace *)ProtectionSpace; - -// pointer personality functions -@property NSUInteger (*hashFunction)(const void *item, NSUInteger (*size)(const void *item)); -@end diff --git clang/test/ARCMT/objcmt-numeric-literals.m clang/test/ARCMT/objcmt-numeric-literals.m deleted file mode 100644 index 7f33dc27997e..000000000000 --- clang/test/ARCMT/objcmt-numeric-literals.m +++ /dev/null @@ -1,502 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result - -#define YES __objc_yes -#define NO __objc_no - -typedef long NSInteger; -typedef unsigned long NSUInteger; -typedef signed char BOOL; -#define nil ((void*) 0) - -@interface NSObject -+ (id)alloc; -@end - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -- (id)initWithChar:(char)value; -- (id)initWithUnsignedChar:(unsigned char)value; -- (id)initWithShort:(short)value; -- (id)initWithUnsignedShort:(unsigned short)value; -- (id)initWithInt:(int)value; -- (id)initWithUnsignedInt:(unsigned int)value; -- (id)initWithLong:(long)value; -- (id)initWithUnsignedLong:(unsigned long)value; -- (id)initWithLongLong:(long long)value; -- (id)initWithUnsignedLongLong:(unsigned long long)value; -- (id)initWithFloat:(float)value; -- (id)initWithDouble:(double)value; -- (id)initWithBool:(BOOL)value; -- (id)initWithInteger:(NSInteger)value; -- (id)initWithUnsignedInteger:(NSUInteger)value; - -+ (NSNumber *)numberWithChar:(char)value; -+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value; -+ (NSNumber *)numberWithShort:(short)value; -+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value; -+ (NSNumber *)numberWithInt:(int)value; -+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value; -+ (NSNumber *)numberWithLong:(long)value; -+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value; -+ (NSNumber *)numberWithLongLong:(long long)value; -+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; -+ (NSNumber *)numberWithFloat:(float)value; -+ (NSNumber *)numberWithDouble:(double)value; -+ (NSNumber *)numberWithBool:(BOOL)value; -+ (NSNumber *)numberWithInteger:(NSInteger)value; -+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value; -@end - -#define VAL_INT 2 -#define VAL_UINT 2U -#define VAL_CHAR 'a' - -void foo() { - [NSNumber numberWithChar:'a']; - [NSNumber numberWithChar:L'a']; - [NSNumber numberWithChar:2]; - [NSNumber numberWithChar:2U]; - [NSNumber numberWithChar:2u]; - [NSNumber numberWithChar:2L]; - [NSNumber numberWithChar:2l]; - [NSNumber numberWithChar:2LL]; - [NSNumber numberWithChar:2ll]; - [NSNumber numberWithChar:2ul]; - [NSNumber numberWithChar:2lu]; - [NSNumber numberWithChar:2ull]; - [NSNumber numberWithChar:2llu]; - [NSNumber numberWithChar:2.0]; - [NSNumber numberWithChar:2.0f]; - [NSNumber numberWithChar:2.0F]; - [NSNumber numberWithChar:2.0l]; - [NSNumber numberWithChar:2.0L]; - [NSNumber numberWithChar:0x2f]; - [NSNumber numberWithChar:04]; - [NSNumber numberWithChar:0]; - [NSNumber numberWithChar:0.0]; - [NSNumber numberWithChar:YES]; - [NSNumber numberWithChar:NO]; - [NSNumber numberWithChar:true]; - [NSNumber numberWithChar:false]; - [NSNumber numberWithChar:VAL_INT]; - [NSNumber numberWithChar:VAL_UINT]; - [NSNumber numberWithChar:VAL_CHAR]; - - [NSNumber numberWithUnsignedChar:'a']; - [NSNumber numberWithUnsignedChar:L'a']; - [NSNumber numberWithUnsignedChar:2]; - [NSNumber numberWithUnsignedChar:2U]; - [NSNumber numberWithUnsignedChar:2u]; - [NSNumber numberWithUnsignedChar:2L]; - [NSNumber numberWithUnsignedChar:2l]; - [NSNumber numberWithUnsignedChar:2LL]; - [NSNumber numberWithUnsignedChar:2ll]; - [NSNumber numberWithUnsignedChar:2ul]; - [NSNumber numberWithUnsignedChar:2lu]; - [NSNumber numberWithUnsignedChar:2ull]; - [NSNumber numberWithUnsignedChar:2llu]; - [NSNumber numberWithUnsignedChar:2.0]; - [NSNumber numberWithUnsignedChar:2.0f]; - [NSNumber numberWithUnsignedChar:2.0F]; - [NSNumber numberWithUnsignedChar:2.0l]; - [NSNumber numberWithUnsignedChar:2.0L]; - [NSNumber numberWithUnsignedChar:0x2f]; - [NSNumber numberWithUnsignedChar:04]; - [NSNumber numberWithUnsignedChar:0]; - [NSNumber numberWithUnsignedChar:0.0]; - [NSNumber numberWithUnsignedChar:YES]; - [NSNumber numberWithUnsignedChar:NO]; - [NSNumber numberWithUnsignedChar:true]; - [NSNumber numberWithUnsignedChar:false]; - [NSNumber numberWithUnsignedChar:VAL_INT]; - [NSNumber numberWithUnsignedChar:VAL_UINT]; - [NSNumber numberWithUnsignedChar:VAL_CHAR]; - - [NSNumber numberWithShort:'a']; - [NSNumber numberWithShort:L'a']; - [NSNumber numberWithShort:2]; - [NSNumber numberWithShort:2U]; - [NSNumber numberWithShort:2u]; - [NSNumber numberWithShort:2L]; - [NSNumber numberWithShort:2l]; - [NSNumber numberWithShort:2LL]; - [NSNumber numberWithShort:2ll]; - [NSNumber numberWithShort:2ul]; - [NSNumber numberWithShort:2lu]; - [NSNumber numberWithShort:2ull]; - [NSNumber numberWithShort:2llu]; - [NSNumber numberWithShort:2.0]; - [NSNumber numberWithShort:2.0f]; - [NSNumber numberWithShort:2.0F]; - [NSNumber numberWithShort:2.0l]; - [NSNumber numberWithShort:2.0L]; - [NSNumber numberWithShort:0x2f]; - [NSNumber numberWithShort:04]; - [NSNumber numberWithShort:0]; - [NSNumber numberWithShort:0.0]; - [NSNumber numberWithShort:YES]; - [NSNumber numberWithShort:NO]; - [NSNumber numberWithShort:true]; - [NSNumber numberWithShort:false]; - [NSNumber numberWithShort:VAL_INT]; - [NSNumber numberWithShort:VAL_UINT]; - - [NSNumber numberWithUnsignedShort:'a']; - [NSNumber numberWithUnsignedShort:L'a']; - [NSNumber numberWithUnsignedShort:2]; - [NSNumber numberWithUnsignedShort:2U]; - [NSNumber numberWithUnsignedShort:2u]; - [NSNumber numberWithUnsignedShort:2L]; - [NSNumber numberWithUnsignedShort:2l]; - [NSNumber numberWithUnsignedShort:2LL]; - [NSNumber numberWithUnsignedShort:2ll]; - [NSNumber numberWithUnsignedShort:2ul]; - [NSNumber numberWithUnsignedShort:2lu]; - [NSNumber numberWithUnsignedShort:2ull]; - [NSNumber numberWithUnsignedShort:2llu]; - [NSNumber numberWithUnsignedShort:2.0]; - [NSNumber numberWithUnsignedShort:2.0f]; - [NSNumber numberWithUnsignedShort:2.0F]; - [NSNumber numberWithUnsignedShort:2.0l]; - [NSNumber numberWithUnsignedShort:2.0L]; - [NSNumber numberWithUnsignedShort:0x2f]; - [NSNumber numberWithUnsignedShort:04]; - [NSNumber numberWithUnsignedShort:0]; - [NSNumber numberWithUnsignedShort:0.0]; - [NSNumber numberWithUnsignedShort:YES]; - [NSNumber numberWithUnsignedShort:NO]; - [NSNumber numberWithUnsignedShort:true]; - [NSNumber numberWithUnsignedShort:false]; - [NSNumber numberWithUnsignedShort:VAL_INT]; - [NSNumber numberWithUnsignedShort:VAL_UINT]; - - [NSNumber numberWithInt:'a']; - [NSNumber numberWithInt:L'a']; - [NSNumber numberWithInt:2]; - [NSNumber numberWithInt:2U]; - [NSNumber numberWithInt:2u]; - [NSNumber numberWithInt:2L]; - [NSNumber numberWithInt:2l]; - [NSNumber numberWithInt:2LL]; - [NSNumber numberWithInt:2ll]; - [NSNumber numberWithInt:2ul]; - [NSNumber numberWithInt:2lu]; - [NSNumber numberWithInt:2ull]; - [NSNumber numberWithInt:2llu]; - [NSNumber numberWithInt:2.0]; - [NSNumber numberWithInt:2.0f]; - [NSNumber numberWithInt:2.0F]; - [NSNumber numberWithInt:2.0l]; - [NSNumber numberWithInt:2.0L]; - [NSNumber numberWithInt:0x2f]; - [NSNumber numberWithInt:04]; - [NSNumber numberWithInt:0]; - [NSNumber numberWithInt:0.0]; - [NSNumber numberWithInt:YES]; - [NSNumber numberWithInt:NO]; - [NSNumber numberWithInt:true]; - [NSNumber numberWithInt:false]; - [NSNumber numberWithInt:VAL_INT]; - [NSNumber numberWithInt:VAL_UINT]; - - (void)[[NSNumber alloc] initWithInt:2]; - (void)[[NSNumber alloc] initWithInt:2U]; - - [NSNumber numberWithInt:+2]; - [NSNumber numberWithInt:-2]; - - [NSNumber numberWithUnsignedInt:'a']; - [NSNumber numberWithUnsignedInt:L'a']; - [NSNumber numberWithUnsignedInt:2]; - [NSNumber numberWithUnsignedInt:2U]; - [NSNumber numberWithUnsignedInt:2u]; - [NSNumber numberWithUnsignedInt:2L]; - [NSNumber numberWithUnsignedInt:2l]; - [NSNumber numberWithUnsignedInt:2LL]; - [NSNumber numberWithUnsignedInt:2ll]; - [NSNumber numberWithUnsignedInt:2ul]; - [NSNumber numberWithUnsignedInt:2lu]; - [NSNumber numberWithUnsignedInt:2ull]; - [NSNumber numberWithUnsignedInt:2llu]; - [NSNumber numberWithUnsignedInt:2.0]; - [NSNumber numberWithUnsignedInt:2.0f]; - [NSNumber numberWithUnsignedInt:2.0F]; - [NSNumber numberWithUnsignedInt:2.0l]; - [NSNumber numberWithUnsignedInt:2.0L]; - [NSNumber numberWithUnsignedInt:0x2f]; - [NSNumber numberWithUnsignedInt:04]; - [NSNumber numberWithUnsignedInt:0]; - [NSNumber numberWithUnsignedInt:0.0]; - [NSNumber numberWithUnsignedInt:YES]; - [NSNumber numberWithUnsignedInt:NO]; - [NSNumber numberWithUnsignedInt:true]; - [NSNumber numberWithUnsignedInt:false]; - [NSNumber numberWithUnsignedInt:VAL_INT]; - [NSNumber numberWithUnsignedInt:VAL_UINT]; - - [NSNumber numberWithLong:'a']; - [NSNumber numberWithLong:L'a']; - [NSNumber numberWithLong:2]; - [NSNumber numberWithLong:2U]; - [NSNumber numberWithLong:2u]; - [NSNumber numberWithLong:2L]; - [NSNumber numberWithLong:2l]; - [NSNumber numberWithLong:2LL]; - [NSNumber numberWithLong:2ll]; - [NSNumber numberWithLong:2ul]; - [NSNumber numberWithLong:2lu]; - [NSNumber numberWithLong:2ull]; - [NSNumber numberWithLong:2llu]; - [NSNumber numberWithLong:2.0]; - [NSNumber numberWithLong:2.0f]; - [NSNumber numberWithLong:2.0F]; - [NSNumber numberWithLong:2.0l]; - [NSNumber numberWithLong:2.0L]; - [NSNumber numberWithLong:0x2f]; - [NSNumber numberWithLong:04]; - [NSNumber numberWithLong:0]; - [NSNumber numberWithLong:0.0]; - [NSNumber numberWithLong:YES]; - [NSNumber numberWithLong:NO]; - [NSNumber numberWithLong:true]; - [NSNumber numberWithLong:false]; - [NSNumber numberWithLong:VAL_INT]; - [NSNumber numberWithLong:VAL_UINT]; - - [NSNumber numberWithUnsignedLong:'a']; - [NSNumber numberWithUnsignedLong:L'a']; - [NSNumber numberWithUnsignedLong:2]; - [NSNumber numberWithUnsignedLong:2U]; - [NSNumber numberWithUnsignedLong:2u]; - [NSNumber numberWithUnsignedLong:2L]; - [NSNumber numberWithUnsignedLong:2l]; - [NSNumber numberWithUnsignedLong:2LL]; - [NSNumber numberWithUnsignedLong:2ll]; - [NSNumber numberWithUnsignedLong:2ul]; - [NSNumber numberWithUnsignedLong:2lu]; - [NSNumber numberWithUnsignedLong:2ull]; - [NSNumber numberWithUnsignedLong:2llu]; - [NSNumber numberWithUnsignedLong:2.0]; - [NSNumber numberWithUnsignedLong:2.0f]; - [NSNumber numberWithUnsignedLong:2.0F]; - [NSNumber numberWithUnsignedLong:2.0l]; - [NSNumber numberWithUnsignedLong:2.0L]; - [NSNumber numberWithUnsignedLong:0x2f]; - [NSNumber numberWithUnsignedLong:04]; - [NSNumber numberWithUnsignedLong:0]; - [NSNumber numberWithUnsignedLong:0.0]; - [NSNumber numberWithUnsignedLong:YES]; - [NSNumber numberWithUnsignedLong:NO]; - [NSNumber numberWithUnsignedLong:true]; - [NSNumber numberWithUnsignedLong:false]; - [NSNumber numberWithUnsignedLong:VAL_INT]; - [NSNumber numberWithUnsignedLong:VAL_UINT]; - - [NSNumber numberWithLongLong:'a']; - [NSNumber numberWithLongLong:L'a']; - [NSNumber numberWithLongLong:2]; - [NSNumber numberWithLongLong:2U]; - [NSNumber numberWithLongLong:2u]; - [NSNumber numberWithLongLong:2L]; - [NSNumber numberWithLongLong:2l]; - [NSNumber numberWithLongLong:2LL]; - [NSNumber numberWithLongLong:2ll]; - [NSNumber numberWithLongLong:2ul]; - [NSNumber numberWithLongLong:2lu]; - [NSNumber numberWithLongLong:2ull]; - [NSNumber numberWithLongLong:2llu]; - [NSNumber numberWithLongLong:2.0]; - [NSNumber numberWithLongLong:2.0f]; - [NSNumber numberWithLongLong:2.0F]; - [NSNumber numberWithLongLong:2.0l]; - [NSNumber numberWithLongLong:2.0L]; - [NSNumber numberWithLongLong:0x2f]; - [NSNumber numberWithLongLong:04]; - [NSNumber numberWithLongLong:0]; - [NSNumber numberWithLongLong:0.0]; - [NSNumber numberWithLongLong:YES]; - [NSNumber numberWithLongLong:NO]; - [NSNumber numberWithLongLong:true]; - [NSNumber numberWithLongLong:false]; - [NSNumber numberWithLongLong:VAL_INT]; - [NSNumber numberWithLongLong:VAL_UINT]; - - [NSNumber numberWithUnsignedLongLong:'a']; - [NSNumber numberWithUnsignedLongLong:L'a']; - [NSNumber numberWithUnsignedLongLong:2]; - [NSNumber numberWithUnsignedLongLong:2U]; - [NSNumber numberWithUnsignedLongLong:2u]; - [NSNumber numberWithUnsignedLongLong:2L]; - [NSNumber numberWithUnsignedLongLong:2l]; - [NSNumber numberWithUnsignedLongLong:2LL]; - [NSNumber numberWithUnsignedLongLong:2ll]; - [NSNumber numberWithUnsignedLongLong:2ul]; - [NSNumber numberWithUnsignedLongLong:2lu]; - [NSNumber numberWithUnsignedLongLong:2ull]; - [NSNumber numberWithUnsignedLongLong:2llu]; - [NSNumber numberWithUnsignedLongLong:2.0]; - [NSNumber numberWithUnsignedLongLong:2.0f]; - [NSNumber numberWithUnsignedLongLong:2.0F]; - [NSNumber numberWithUnsignedLongLong:2.0l]; - [NSNumber numberWithUnsignedLongLong:2.0L]; - [NSNumber numberWithUnsignedLongLong:0x2f]; - [NSNumber numberWithUnsignedLongLong:04]; - [NSNumber numberWithUnsignedLongLong:0]; - [NSNumber numberWithUnsignedLongLong:0.0]; - [NSNumber numberWithUnsignedLongLong:YES]; - [NSNumber numberWithUnsignedLongLong:NO]; - [NSNumber numberWithUnsignedLongLong:true]; - [NSNumber numberWithUnsignedLongLong:false]; - [NSNumber numberWithUnsignedLongLong:VAL_INT]; - [NSNumber numberWithUnsignedLongLong:VAL_UINT]; - - [NSNumber numberWithFloat:'a']; - [NSNumber numberWithFloat:L'a']; - [NSNumber numberWithFloat:2]; - [NSNumber numberWithFloat:2U]; - [NSNumber numberWithFloat:2u]; - [NSNumber numberWithFloat:2L]; - [NSNumber numberWithFloat:2l]; - [NSNumber numberWithFloat:2LL]; - [NSNumber numberWithFloat:2ll]; - [NSNumber numberWithFloat:2ul]; - [NSNumber numberWithFloat:2lu]; - [NSNumber numberWithFloat:2ull]; - [NSNumber numberWithFloat:2llu]; - [NSNumber numberWithFloat:2.0]; - [NSNumber numberWithFloat:2.0f]; - [NSNumber numberWithFloat:2.0F]; - [NSNumber numberWithFloat:2.0l]; - [NSNumber numberWithFloat:2.0L]; - [NSNumber numberWithFloat:0x2f]; - [NSNumber numberWithFloat:04]; - [NSNumber numberWithFloat:0]; - [NSNumber numberWithFloat:0.0]; - [NSNumber numberWithFloat:YES]; - [NSNumber numberWithFloat:NO]; - [NSNumber numberWithFloat:true]; - [NSNumber numberWithFloat:false]; - [NSNumber numberWithFloat:VAL_INT]; - [NSNumber numberWithFloat:VAL_UINT]; - - [NSNumber numberWithDouble:'a']; - [NSNumber numberWithDouble:L'a']; - [NSNumber numberWithDouble:2]; - [NSNumber numberWithDouble:2U]; - [NSNumber numberWithDouble:2u]; - [NSNumber numberWithDouble:2L]; - [NSNumber numberWithDouble:2l]; - [NSNumber numberWithDouble:2LL]; - [NSNumber numberWithDouble:2ll]; - [NSNumber numberWithDouble:2ul]; - [NSNumber numberWithDouble:2lu]; - [NSNumber numberWithDouble:2ull]; - [NSNumber numberWithDouble:2llu]; - [NSNumber numberWithDouble:2.0]; - [NSNumber numberWithDouble:2.0f]; - [NSNumber numberWithDouble:2.0F]; - [NSNumber numberWithDouble:2.0l]; - [NSNumber numberWithDouble:2.0L]; - [NSNumber numberWithDouble:0x2f]; - [NSNumber numberWithDouble:04]; - [NSNumber numberWithDouble:0]; - [NSNumber numberWithDouble:0.0]; - [NSNumber numberWithDouble:YES]; - [NSNumber numberWithDouble:NO]; - [NSNumber numberWithDouble:true]; - [NSNumber numberWithDouble:false]; - [NSNumber numberWithDouble:VAL_INT]; - [NSNumber numberWithDouble:VAL_UINT]; - - [NSNumber numberWithBool:'a']; - [NSNumber numberWithBool:L'a']; - [NSNumber numberWithBool:2]; - [NSNumber numberWithBool:2U]; - [NSNumber numberWithBool:2u]; - [NSNumber numberWithBool:2L]; - [NSNumber numberWithBool:2l]; - [NSNumber numberWithBool:2LL]; - [NSNumber numberWithBool:2ll]; - [NSNumber numberWithBool:2ul]; - [NSNumber numberWithBool:2lu]; - [NSNumber numberWithBool:2ull]; - [NSNumber numberWithBool:2llu]; - [NSNumber numberWithBool:2.0]; - [NSNumber numberWithBool:2.0f]; - [NSNumber numberWithBool:2.0F]; - [NSNumber numberWithBool:2.0l]; - [NSNumber numberWithBool:2.0L]; - [NSNumber numberWithBool:0x2f]; - [NSNumber numberWithBool:04]; - [NSNumber numberWithBool:0]; - [NSNumber numberWithBool:0.0]; - [NSNumber numberWithBool:YES]; - [NSNumber numberWithBool:NO]; - [NSNumber numberWithBool:true]; - [NSNumber numberWithBool:false]; - [NSNumber numberWithBool:VAL_INT]; - [NSNumber numberWithBool:VAL_UINT]; - - [NSNumber numberWithInteger:'a']; - [NSNumber numberWithInteger:L'a']; - [NSNumber numberWithInteger:2]; - [NSNumber numberWithInteger:2U]; - [NSNumber numberWithInteger:2u]; - [NSNumber numberWithInteger:2L]; - [NSNumber numberWithInteger:2l]; - [NSNumber numberWithInteger:2LL]; - [NSNumber numberWithInteger:2ll]; - [NSNumber numberWithInteger:2ul]; - [NSNumber numberWithInteger:2lu]; - [NSNumber numberWithInteger:2ull]; - [NSNumber numberWithInteger:2llu]; - [NSNumber numberWithInteger:2.0]; - [NSNumber numberWithInteger:2.0f]; - [NSNumber numberWithInteger:2.0F]; - [NSNumber numberWithInteger:2.0l]; - [NSNumber numberWithInteger:2.0L]; - [NSNumber numberWithInteger:0x2f]; - [NSNumber numberWithInteger:04]; - [NSNumber numberWithInteger:0]; - [NSNumber numberWithInteger:0.0]; - [NSNumber numberWithInteger:YES]; - [NSNumber numberWithInteger:NO]; - [NSNumber numberWithInteger:true]; - [NSNumber numberWithInteger:false]; - [NSNumber numberWithInteger:VAL_INT]; - [NSNumber numberWithInteger:VAL_UINT]; - - [NSNumber numberWithUnsignedInteger:'a']; - [NSNumber numberWithUnsignedInteger:L'a']; - [NSNumber numberWithUnsignedInteger:2]; - [NSNumber numberWithUnsignedInteger:2U]; - [NSNumber numberWithUnsignedInteger:2u]; - [NSNumber numberWithUnsignedInteger:2L]; - [NSNumber numberWithUnsignedInteger:2l]; - [NSNumber numberWithUnsignedInteger:2LL]; - [NSNumber numberWithUnsignedInteger:2ll]; - [NSNumber numberWithUnsignedInteger:2ul]; - [NSNumber numberWithUnsignedInteger:2lu]; - [NSNumber numberWithUnsignedInteger:2ull]; - [NSNumber numberWithUnsignedInteger:2llu]; - [NSNumber numberWithUnsignedInteger:2.0]; - [NSNumber numberWithUnsignedInteger:2.0f]; - [NSNumber numberWithUnsignedInteger:2.0F]; - [NSNumber numberWithUnsignedInteger:2.0l]; - [NSNumber numberWithUnsignedInteger:2.0L]; - [NSNumber numberWithUnsignedInteger:0x2f]; - [NSNumber numberWithUnsignedInteger:04]; - [NSNumber numberWithUnsignedInteger:0]; - [NSNumber numberWithUnsignedInteger:0.0]; - [NSNumber numberWithUnsignedInteger:YES]; - [NSNumber numberWithUnsignedInteger:NO]; - [NSNumber numberWithUnsignedInteger:true]; - [NSNumber numberWithUnsignedInteger:false]; - [NSNumber numberWithUnsignedInteger:VAL_INT]; - [NSNumber numberWithUnsignedInteger:VAL_UINT]; -} diff --git clang/test/ARCMT/objcmt-numeric-literals.m.result clang/test/ARCMT/objcmt-numeric-literals.m.result deleted file mode 100644 index bb7b515566d0..000000000000 --- clang/test/ARCMT/objcmt-numeric-literals.m.result +++ /dev/null @@ -1,502 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result - -#define YES __objc_yes -#define NO __objc_no - -typedef long NSInteger; -typedef unsigned long NSUInteger; -typedef signed char BOOL; -#define nil ((void*) 0) - -@interface NSObject -+ (id)alloc; -@end - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -- (id)initWithChar:(char)value; -- (id)initWithUnsignedChar:(unsigned char)value; -- (id)initWithShort:(short)value; -- (id)initWithUnsignedShort:(unsigned short)value; -- (id)initWithInt:(int)value; -- (id)initWithUnsignedInt:(unsigned int)value; -- (id)initWithLong:(long)value; -- (id)initWithUnsignedLong:(unsigned long)value; -- (id)initWithLongLong:(long long)value; -- (id)initWithUnsignedLongLong:(unsigned long long)value; -- (id)initWithFloat:(float)value; -- (id)initWithDouble:(double)value; -- (id)initWithBool:(BOOL)value; -- (id)initWithInteger:(NSInteger)value; -- (id)initWithUnsignedInteger:(NSUInteger)value; - -+ (NSNumber *)numberWithChar:(char)value; -+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value; -+ (NSNumber *)numberWithShort:(short)value; -+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value; -+ (NSNumber *)numberWithInt:(int)value; -+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value; -+ (NSNumber *)numberWithLong:(long)value; -+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value; -+ (NSNumber *)numberWithLongLong:(long long)value; -+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; -+ (NSNumber *)numberWithFloat:(float)value; -+ (NSNumber *)numberWithDouble:(double)value; -+ (NSNumber *)numberWithBool:(BOOL)value; -+ (NSNumber *)numberWithInteger:(NSInteger)value; -+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value; -@end - -#define VAL_INT 2 -#define VAL_UINT 2U -#define VAL_CHAR 'a' - -void foo() { - @'a'; - [NSNumber numberWithChar:L'a']; - [NSNumber numberWithChar:2]; - [NSNumber numberWithChar:2U]; - [NSNumber numberWithChar:2u]; - [NSNumber numberWithChar:2L]; - [NSNumber numberWithChar:2l]; - [NSNumber numberWithChar:2LL]; - [NSNumber numberWithChar:2ll]; - [NSNumber numberWithChar:2ul]; - [NSNumber numberWithChar:2lu]; - [NSNumber numberWithChar:2ull]; - [NSNumber numberWithChar:2llu]; - [NSNumber numberWithChar:2.0]; - [NSNumber numberWithChar:2.0f]; - [NSNumber numberWithChar:2.0F]; - [NSNumber numberWithChar:2.0l]; - [NSNumber numberWithChar:2.0L]; - [NSNumber numberWithChar:0x2f]; - [NSNumber numberWithChar:04]; - [NSNumber numberWithChar:0]; - [NSNumber numberWithChar:0.0]; - [NSNumber numberWithChar:YES]; - [NSNumber numberWithChar:NO]; - [NSNumber numberWithChar:true]; - [NSNumber numberWithChar:false]; - [NSNumber numberWithChar:VAL_INT]; - [NSNumber numberWithChar:VAL_UINT]; - @VAL_CHAR; - - [NSNumber numberWithUnsignedChar:'a']; - [NSNumber numberWithUnsignedChar:L'a']; - [NSNumber numberWithUnsignedChar:2]; - [NSNumber numberWithUnsignedChar:2U]; - [NSNumber numberWithUnsignedChar:2u]; - [NSNumber numberWithUnsignedChar:2L]; - [NSNumber numberWithUnsignedChar:2l]; - [NSNumber numberWithUnsignedChar:2LL]; - [NSNumber numberWithUnsignedChar:2ll]; - [NSNumber numberWithUnsignedChar:2ul]; - [NSNumber numberWithUnsignedChar:2lu]; - [NSNumber numberWithUnsignedChar:2ull]; - [NSNumber numberWithUnsignedChar:2llu]; - [NSNumber numberWithUnsignedChar:2.0]; - [NSNumber numberWithUnsignedChar:2.0f]; - [NSNumber numberWithUnsignedChar:2.0F]; - [NSNumber numberWithUnsignedChar:2.0l]; - [NSNumber numberWithUnsignedChar:2.0L]; - [NSNumber numberWithUnsignedChar:0x2f]; - [NSNumber numberWithUnsignedChar:04]; - [NSNumber numberWithUnsignedChar:0]; - [NSNumber numberWithUnsignedChar:0.0]; - [NSNumber numberWithUnsignedChar:YES]; - [NSNumber numberWithUnsignedChar:NO]; - [NSNumber numberWithUnsignedChar:true]; - [NSNumber numberWithUnsignedChar:false]; - [NSNumber numberWithUnsignedChar:VAL_INT]; - [NSNumber numberWithUnsignedChar:VAL_UINT]; - [NSNumber numberWithUnsignedChar:VAL_CHAR]; - - [NSNumber numberWithShort:'a']; - [NSNumber numberWithShort:L'a']; - [NSNumber numberWithShort:2]; - [NSNumber numberWithShort:2U]; - [NSNumber numberWithShort:2u]; - [NSNumber numberWithShort:2L]; - [NSNumber numberWithShort:2l]; - [NSNumber numberWithShort:2LL]; - [NSNumber numberWithShort:2ll]; - [NSNumber numberWithShort:2ul]; - [NSNumber numberWithShort:2lu]; - [NSNumber numberWithShort:2ull]; - [NSNumber numberWithShort:2llu]; - [NSNumber numberWithShort:2.0]; - [NSNumber numberWithShort:2.0f]; - [NSNumber numberWithShort:2.0F]; - [NSNumber numberWithShort:2.0l]; - [NSNumber numberWithShort:2.0L]; - [NSNumber numberWithShort:0x2f]; - [NSNumber numberWithShort:04]; - [NSNumber numberWithShort:0]; - [NSNumber numberWithShort:0.0]; - [NSNumber numberWithShort:YES]; - [NSNumber numberWithShort:NO]; - [NSNumber numberWithShort:true]; - [NSNumber numberWithShort:false]; - [NSNumber numberWithShort:VAL_INT]; - [NSNumber numberWithShort:VAL_UINT]; - - [NSNumber numberWithUnsignedShort:'a']; - [NSNumber numberWithUnsignedShort:L'a']; - [NSNumber numberWithUnsignedShort:2]; - [NSNumber numberWithUnsignedShort:2U]; - [NSNumber numberWithUnsignedShort:2u]; - [NSNumber numberWithUnsignedShort:2L]; - [NSNumber numberWithUnsignedShort:2l]; - [NSNumber numberWithUnsignedShort:2LL]; - [NSNumber numberWithUnsignedShort:2ll]; - [NSNumber numberWithUnsignedShort:2ul]; - [NSNumber numberWithUnsignedShort:2lu]; - [NSNumber numberWithUnsignedShort:2ull]; - [NSNumber numberWithUnsignedShort:2llu]; - [NSNumber numberWithUnsignedShort:2.0]; - [NSNumber numberWithUnsignedShort:2.0f]; - [NSNumber numberWithUnsignedShort:2.0F]; - [NSNumber numberWithUnsignedShort:2.0l]; - [NSNumber numberWithUnsignedShort:2.0L]; - [NSNumber numberWithUnsignedShort:0x2f]; - [NSNumber numberWithUnsignedShort:04]; - [NSNumber numberWithUnsignedShort:0]; - [NSNumber numberWithUnsignedShort:0.0]; - [NSNumber numberWithUnsignedShort:YES]; - [NSNumber numberWithUnsignedShort:NO]; - [NSNumber numberWithUnsignedShort:true]; - [NSNumber numberWithUnsignedShort:false]; - [NSNumber numberWithUnsignedShort:VAL_INT]; - [NSNumber numberWithUnsignedShort:VAL_UINT]; - - [NSNumber numberWithInt:'a']; - [NSNumber numberWithInt:L'a']; - @2; - @2; - @2; - @2; - @2; - @2; - @2; - @2; - @2; - @2; - @2; - [NSNumber numberWithInt:2.0]; - [NSNumber numberWithInt:2.0f]; - [NSNumber numberWithInt:2.0F]; - [NSNumber numberWithInt:2.0l]; - [NSNumber numberWithInt:2.0L]; - @0x2f; - @04; - @0; - [NSNumber numberWithInt:0.0]; - [NSNumber numberWithInt:YES]; - [NSNumber numberWithInt:NO]; - [NSNumber numberWithInt:true]; - [NSNumber numberWithInt:false]; - @VAL_INT; - [NSNumber numberWithInt:VAL_UINT]; - - (void)[[NSNumber alloc] initWithInt:2]; - (void)[[NSNumber alloc] initWithInt:2U]; - - @+2; - @-2; - - [NSNumber numberWithUnsignedInt:'a']; - [NSNumber numberWithUnsignedInt:L'a']; - @2U; - @2U; - @2u; - @2U; - @2u; - @2U; - @2u; - @2u; - @2u; - @2u; - @2u; - [NSNumber numberWithUnsignedInt:2.0]; - [NSNumber numberWithUnsignedInt:2.0f]; - [NSNumber numberWithUnsignedInt:2.0F]; - [NSNumber numberWithUnsignedInt:2.0l]; - [NSNumber numberWithUnsignedInt:2.0L]; - @0x2fU; - @04U; - @0U; - [NSNumber numberWithUnsignedInt:0.0]; - [NSNumber numberWithUnsignedInt:YES]; - [NSNumber numberWithUnsignedInt:NO]; - [NSNumber numberWithUnsignedInt:true]; - [NSNumber numberWithUnsignedInt:false]; - [NSNumber numberWithUnsignedInt:VAL_INT]; - @VAL_UINT; - - [NSNumber numberWithLong:'a']; - [NSNumber numberWithLong:L'a']; - @2L; - @2L; - @2l; - @2L; - @2l; - @2L; - @2l; - @2l; - @2l; - @2l; - @2l; - [NSNumber numberWithLong:2.0]; - [NSNumber numberWithLong:2.0f]; - [NSNumber numberWithLong:2.0F]; - [NSNumber numberWithLong:2.0l]; - [NSNumber numberWithLong:2.0L]; - @0x2fL; - @04L; - @0L; - [NSNumber numberWithLong:0.0]; - [NSNumber numberWithLong:YES]; - [NSNumber numberWithLong:NO]; - [NSNumber numberWithLong:true]; - [NSNumber numberWithLong:false]; - [NSNumber numberWithLong:VAL_INT]; - [NSNumber numberWithLong:VAL_UINT]; - - [NSNumber numberWithUnsignedLong:'a']; - [NSNumber numberWithUnsignedLong:L'a']; - @2UL; - @2UL; - @2ul; - @2UL; - @2ul; - @2UL; - @2ul; - @2ul; - @2lu; - @2ul; - @2ul; - [NSNumber numberWithUnsignedLong:2.0]; - [NSNumber numberWithUnsignedLong:2.0f]; - [NSNumber numberWithUnsignedLong:2.0F]; - [NSNumber numberWithUnsignedLong:2.0l]; - [NSNumber numberWithUnsignedLong:2.0L]; - @0x2fUL; - @04UL; - @0UL; - [NSNumber numberWithUnsignedLong:0.0]; - [NSNumber numberWithUnsignedLong:YES]; - [NSNumber numberWithUnsignedLong:NO]; - [NSNumber numberWithUnsignedLong:true]; - [NSNumber numberWithUnsignedLong:false]; - [NSNumber numberWithUnsignedLong:VAL_INT]; - [NSNumber numberWithUnsignedLong:VAL_UINT]; - - [NSNumber numberWithLongLong:'a']; - [NSNumber numberWithLongLong:L'a']; - @2LL; - @2LL; - @2ll; - @2LL; - @2ll; - @2LL; - @2ll; - @2ll; - @2ll; - @2ll; - @2ll; - [NSNumber numberWithLongLong:2.0]; - [NSNumber numberWithLongLong:2.0f]; - [NSNumber numberWithLongLong:2.0F]; - [NSNumber numberWithLongLong:2.0l]; - [NSNumber numberWithLongLong:2.0L]; - @0x2fLL; - @04LL; - @0LL; - [NSNumber numberWithLongLong:0.0]; - [NSNumber numberWithLongLong:YES]; - [NSNumber numberWithLongLong:NO]; - [NSNumber numberWithLongLong:true]; - [NSNumber numberWithLongLong:false]; - [NSNumber numberWithLongLong:VAL_INT]; - [NSNumber numberWithLongLong:VAL_UINT]; - - [NSNumber numberWithUnsignedLongLong:'a']; - [NSNumber numberWithUnsignedLongLong:L'a']; - @2ULL; - @2ULL; - @2ull; - @2ULL; - @2ull; - @2ULL; - @2ull; - @2ull; - @2ull; - @2ull; - @2llu; - [NSNumber numberWithUnsignedLongLong:2.0]; - [NSNumber numberWithUnsignedLongLong:2.0f]; - [NSNumber numberWithUnsignedLongLong:2.0F]; - [NSNumber numberWithUnsignedLongLong:2.0l]; - [NSNumber numberWithUnsignedLongLong:2.0L]; - @0x2fULL; - @04ULL; - @0ULL; - [NSNumber numberWithUnsignedLongLong:0.0]; - [NSNumber numberWithUnsignedLongLong:YES]; - [NSNumber numberWithUnsignedLongLong:NO]; - [NSNumber numberWithUnsignedLongLong:true]; - [NSNumber numberWithUnsignedLongLong:false]; - [NSNumber numberWithUnsignedLongLong:VAL_INT]; - [NSNumber numberWithUnsignedLongLong:VAL_UINT]; - - [NSNumber numberWithFloat:'a']; - [NSNumber numberWithFloat:L'a']; - @2.0f; - @2.0f; - @2.0f; - @2.0f; - @2.0f; - @2.0f; - @2.0f; - @2.0f; - @2.0f; - @2.0f; - @2.0f; - @2.0f; - @2.0f; - @2.0F; - @2.0f; - @2.0f; - [NSNumber numberWithFloat:0x2f]; - [NSNumber numberWithFloat:04]; - @0.0f; - @0.0f; - [NSNumber numberWithFloat:YES]; - [NSNumber numberWithFloat:NO]; - [NSNumber numberWithFloat:true]; - [NSNumber numberWithFloat:false]; - [NSNumber numberWithFloat:VAL_INT]; - [NSNumber numberWithFloat:VAL_UINT]; - - [NSNumber numberWithDouble:'a']; - [NSNumber numberWithDouble:L'a']; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - [NSNumber numberWithDouble:0x2f]; - [NSNumber numberWithDouble:04]; - @0.0; - @0.0; - [NSNumber numberWithDouble:YES]; - [NSNumber numberWithDouble:NO]; - [NSNumber numberWithDouble:true]; - [NSNumber numberWithDouble:false]; - [NSNumber numberWithDouble:VAL_INT]; - [NSNumber numberWithDouble:VAL_UINT]; - - [NSNumber numberWithBool:'a']; - [NSNumber numberWithBool:L'a']; - [NSNumber numberWithBool:2]; - [NSNumber numberWithBool:2U]; - [NSNumber numberWithBool:2u]; - [NSNumber numberWithBool:2L]; - [NSNumber numberWithBool:2l]; - [NSNumber numberWithBool:2LL]; - [NSNumber numberWithBool:2ll]; - [NSNumber numberWithBool:2ul]; - [NSNumber numberWithBool:2lu]; - [NSNumber numberWithBool:2ull]; - [NSNumber numberWithBool:2llu]; - [NSNumber numberWithBool:2.0]; - [NSNumber numberWithBool:2.0f]; - [NSNumber numberWithBool:2.0F]; - [NSNumber numberWithBool:2.0l]; - [NSNumber numberWithBool:2.0L]; - [NSNumber numberWithBool:0x2f]; - [NSNumber numberWithBool:04]; - [NSNumber numberWithBool:0]; - [NSNumber numberWithBool:0.0]; - @YES; - @NO; - @true; - @false; - [NSNumber numberWithBool:VAL_INT]; - [NSNumber numberWithBool:VAL_UINT]; - - [NSNumber numberWithInteger:'a']; - [NSNumber numberWithInteger:L'a']; - @2; - @2; - @2; - @2L; - @2l; - @2; - @2; - @2; - @2; - @2; - @2; - [NSNumber numberWithInteger:2.0]; - [NSNumber numberWithInteger:2.0f]; - [NSNumber numberWithInteger:2.0F]; - [NSNumber numberWithInteger:2.0l]; - [NSNumber numberWithInteger:2.0L]; - @0x2f; - @04; - @0; - [NSNumber numberWithInteger:0.0]; - [NSNumber numberWithInteger:YES]; - [NSNumber numberWithInteger:NO]; - [NSNumber numberWithInteger:true]; - [NSNumber numberWithInteger:false]; - @VAL_INT; - [NSNumber numberWithInteger:VAL_UINT]; - - [NSNumber numberWithUnsignedInteger:'a']; - [NSNumber numberWithUnsignedInteger:L'a']; - @2U; - @2U; - @2u; - @2U; - @2u; - @2U; - @2u; - @2ul; - @2lu; - @2u; - @2u; - [NSNumber numberWithUnsignedInteger:2.0]; - [NSNumber numberWithUnsignedInteger:2.0f]; - [NSNumber numberWithUnsignedInteger:2.0F]; - [NSNumber numberWithUnsignedInteger:2.0l]; - [NSNumber numberWithUnsignedInteger:2.0L]; - @0x2fU; - @04U; - @0U; - [NSNumber numberWithUnsignedInteger:0.0]; - [NSNumber numberWithUnsignedInteger:YES]; - [NSNumber numberWithUnsignedInteger:NO]; - [NSNumber numberWithUnsignedInteger:true]; - [NSNumber numberWithUnsignedInteger:false]; - [NSNumber numberWithUnsignedInteger:VAL_INT]; - @VAL_UINT; -} diff --git clang/test/ARCMT/objcmt-property-availability.m clang/test/ARCMT/objcmt-property-availability.m deleted file mode 100644 index 37ba74f3346f..000000000000 --- clang/test/ARCMT/objcmt-property-availability.m +++ /dev/null @@ -1,45 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-readonly-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - - -#define __NSi_7_0 introduced=7.0 -#define __NSi_6_0 introduced=6.0 - -#define CF_AVAILABLE(_mac, _ios) __attribute__((availability(ios,__NSi_##_ios))) -#define CF_AVAILABLE_MAC(_mac) __attribute__((availability(macosx,__NSi_##_mac))) -#define CF_AVAILABLE_IOS(_ios) __attribute__((availability(macosx,unavailable))) - -#define NS_AVAILABLE(_mac, _ios) CF_AVAILABLE(_mac, _ios) -#define NS_AVAILABLE_MAC(_mac) CF_AVAILABLE_MAC(_mac) -#define NS_AVAILABLE_IOS(_ios) CF_AVAILABLE_IOS(_ios) - -#define UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode"))) - -@interface MKMapItem -- (MKMapItem *)source NS_AVAILABLE(10_9, 6_0); -- (void)setSource:(MKMapItem *)source NS_AVAILABLE(10_9, 7_0); - -- (void)setDest:(MKMapItem *)source NS_AVAILABLE(10_9, 6_0); -- (MKMapItem *)dest NS_AVAILABLE(10_9, 6_0); - -- (MKMapItem *)final; -- (void)setFinal:(MKMapItem *)source; - -- (MKMapItem *)total NS_AVAILABLE(10_9, 6_0); -- (void)setTotal:(MKMapItem *)source; - -- (MKMapItem *)comp NS_AVAILABLE(10_9, 6_0); -- (void)setComp:(MKMapItem *)source UNAVAILABLE; - -- (MKMapItem *)tally UNAVAILABLE NS_AVAILABLE(10_9, 6_0); -- (void)setTally:(MKMapItem *)source UNAVAILABLE NS_AVAILABLE(10_9, 6_0); - -- (MKMapItem *)itally NS_AVAILABLE(10_9, 6_0); -- (void)setItally:(MKMapItem *)source UNAVAILABLE NS_AVAILABLE(10_9, 6_0); - -- (MKMapItem *)normal UNAVAILABLE; -- (void)setNormal:(MKMapItem *)source UNAVAILABLE NS_AVAILABLE(10_9, 6_0); -@end - diff --git clang/test/ARCMT/objcmt-property-availability.m.result clang/test/ARCMT/objcmt-property-availability.m.result deleted file mode 100644 index 3a212ac894c4..000000000000 --- clang/test/ARCMT/objcmt-property-availability.m.result +++ /dev/null @@ -1,42 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-readonly-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - - -#define __NSi_7_0 introduced=7.0 -#define __NSi_6_0 introduced=6.0 - -#define CF_AVAILABLE(_mac, _ios) __attribute__((availability(ios,__NSi_##_ios))) -#define CF_AVAILABLE_MAC(_mac) __attribute__((availability(macosx,__NSi_##_mac))) -#define CF_AVAILABLE_IOS(_ios) __attribute__((availability(macosx,unavailable))) - -#define NS_AVAILABLE(_mac, _ios) CF_AVAILABLE(_mac, _ios) -#define NS_AVAILABLE_MAC(_mac) CF_AVAILABLE_MAC(_mac) -#define NS_AVAILABLE_IOS(_ios) CF_AVAILABLE_IOS(_ios) - -#define UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode"))) - -@interface MKMapItem -@property (nonatomic, strong) MKMapItem *source NS_AVAILABLE(10_9, 6_0); -- (void)setSource:(MKMapItem *)source NS_AVAILABLE(10_9, 7_0); - -@property (nonatomic, strong) MKMapItem *dest NS_AVAILABLE(10_9, 6_0); - -@property (nonatomic, strong) MKMapItem *final; - -@property (nonatomic, strong) MKMapItem *total NS_AVAILABLE(10_9, 6_0); -- (void)setTotal:(MKMapItem *)source; - -- (MKMapItem *)comp NS_AVAILABLE(10_9, 6_0); -- (void)setComp:(MKMapItem *)source UNAVAILABLE; - -@property (nonatomic, strong) MKMapItem *tally UNAVAILABLE NS_AVAILABLE(10_9, 6_0); - -- (MKMapItem *)itally NS_AVAILABLE(10_9, 6_0); -- (void)setItally:(MKMapItem *)source UNAVAILABLE NS_AVAILABLE(10_9, 6_0); - -- (MKMapItem *)normal UNAVAILABLE; -- (void)setNormal:(MKMapItem *)source UNAVAILABLE NS_AVAILABLE(10_9, 6_0); -@end - diff --git clang/test/ARCMT/objcmt-property-dot-syntax.m clang/test/ARCMT/objcmt-property-dot-syntax.m deleted file mode 100644 index ec75b5140e18..000000000000 --- clang/test/ARCMT/objcmt-property-dot-syntax.m +++ /dev/null @@ -1,117 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-property-dot-syntax -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -@class NSString; - -@protocol NSObject -@property (readonly, copy) NSString *description; -@end - -@interface NSObject <NSObject> @end - -@interface P : NSObject -{ - P* obj; - int i1, i2, i3; -} -@property int count; -@property (copy) P* PropertyReturnsPObj; -- (P*) MethodReturnsPObj; -@end - -P* fun(void); - -@implementation P -- (int) Meth : (P*)array { - [obj setCount : 100]; - - [(P*)0 setCount : [array count]]; - - [[obj PropertyReturnsPObj] setCount : [array count]]; - - [obj setCount : (i1+i2*i3 - 100)]; - - return [obj count] - - [(P*)0 count] + [array count] + - [fun() count] - - [[obj PropertyReturnsPObj] count] + - [self->obj count]; -} - -- (P*) MethodReturnsPObj { return 0; } - -- (NSString *)description { return [super description]; } -@end - -@interface Sub : P -@end - -@implementation Sub -- (int) Meth : (P*)array { - [super setCount : 100]; - - [super setCount : [array count]]; - - [[super PropertyReturnsPObj] setCount : [array count]]; - - [super setCount : (i1+i2*i3 - 100)]; - - return [super count] - - [(P*)0 count] + [array count] + - [fun() count] - - [[super PropertyReturnsPObj] count] + - [self->obj count]; -} -@end - - -@interface Rdar19038838 -@property id newItem; // should be marked objc_method_family(none), but isn't. -@end - -id testRdar19038838(Rdar19038838 *obj) { - return [obj newItem]; -} - -@interface rdar19381786 : NSObject -{ - rdar19381786* obj; -} -@property int count; -@end - -@protocol PR -@property int count; -@end - -@implementation rdar19381786 --(void)test:(id)some : (id<PR>)qsome : (SEL)selsome -{ - [obj setCount : 100]; - [some setCount : [some count]]; - [qsome setCount : [qsome count]]; -} -@end - -int NSOnState; -int ArrNSOnState[4]; -@interface rdar19140114 : NSObject -{ - rdar19140114* menuItem; -} -@property int state; -@end - -@implementation rdar19140114 -- (void) Meth { - [menuItem setState:NSOnState]; - [menuItem setState :NSOnState]; - [menuItem setState :ArrNSOnState[NSOnState]]; - [menuItem setState : NSOnState]; - [menuItem setState: NSOnState]; - [menuItem setState: NSOnState]; - [menuItem setState : NSOnState]; -} -@end diff --git clang/test/ARCMT/objcmt-property-dot-syntax.m.result clang/test/ARCMT/objcmt-property-dot-syntax.m.result deleted file mode 100644 index 5153b0e658f6..000000000000 --- clang/test/ARCMT/objcmt-property-dot-syntax.m.result +++ /dev/null @@ -1,117 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-property-dot-syntax -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -@class NSString; - -@protocol NSObject -@property (readonly, copy) NSString *description; -@end - -@interface NSObject <NSObject> @end - -@interface P : NSObject -{ - P* obj; - int i1, i2, i3; -} -@property int count; -@property (copy) P* PropertyReturnsPObj; -- (P*) MethodReturnsPObj; -@end - -P* fun(void); - -@implementation P -- (int) Meth : (P*)array { - obj.count = 100; - - ((P*)0).count = array.count; - - obj.PropertyReturnsPObj.count = array.count; - - obj.count = (i1+i2*i3 - 100); - - return obj.count - - ((P*)0).count + array.count + - fun().count - - obj.PropertyReturnsPObj.count + - self->obj.count; -} - -- (P*) MethodReturnsPObj { return 0; } - -- (NSString *)description { return super.description; } -@end - -@interface Sub : P -@end - -@implementation Sub -- (int) Meth : (P*)array { - super.count = 100; - - super.count = array.count; - - super.PropertyReturnsPObj.count = array.count; - - super.count = (i1+i2*i3 - 100); - - return super.count - - ((P*)0).count + array.count + - fun().count - - super.PropertyReturnsPObj.count + - self->obj.count; -} -@end - - -@interface Rdar19038838 -@property id newItem; // should be marked objc_method_family(none), but isn't. -@end - -id testRdar19038838(Rdar19038838 *obj) { - return obj.newItem; -} - -@interface rdar19381786 : NSObject -{ - rdar19381786* obj; -} -@property int count; -@end - -@protocol PR -@property int count; -@end - -@implementation rdar19381786 --(void)test:(id)some : (id<PR>)qsome : (SEL)selsome -{ - obj.count = 100; - [some setCount : [some count]]; - qsome.count = qsome.count; -} -@end - -int NSOnState; -int ArrNSOnState[4]; -@interface rdar19140114 : NSObject -{ - rdar19140114* menuItem; -} -@property int state; -@end - -@implementation rdar19140114 -- (void) Meth { - menuItem.state = NSOnState; - menuItem.state = NSOnState; - menuItem.state = ArrNSOnState[NSOnState]; - menuItem.state = NSOnState; - menuItem.state = NSOnState; - menuItem.state = NSOnState; - menuItem.state = NSOnState; -} -@end diff --git clang/test/ARCMT/objcmt-property.m clang/test/ARCMT/objcmt-property.m deleted file mode 100644 index f2b722e66d96..000000000000 --- clang/test/ARCMT/objcmt-property.m +++ /dev/null @@ -1,243 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -objcmt-migrate-readonly-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -#define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION -#define WEAK_IMPORT_ATTRIBUTE __attribute__((objc_arc_weak_reference_unavailable)) -#define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER -#define DEPRECATED __attribute__((deprecated)) - -typedef char BOOL; -@class NSString; -@protocol NSCopying @end - -@interface NSObject <NSCopying> -@end - -@interface NSDictionary : NSObject -@end - -@interface I : NSObject { - int ivarVal; -} -- (void) setWeakProp : (NSString *__weak)Val; -- (NSString *__weak) WeakProp; - -- (NSString *) StrongProp; -- (void) setStrongProp : (NSString *)Val; - -- (NSString *) UnavailProp __attribute__((unavailable)); -- (void) setUnavailProp : (NSString *)Val; - -- (NSString *) UnavailProp1 __attribute__((unavailable)); -- (void) setUnavailProp1 : (NSString *)Val __attribute__((unavailable)); - -- (NSString *) UnavailProp2; -- (void) setUnavailProp2 : (NSString *)Val __attribute__((unavailable)); - -- (NSDictionary*) undoAction; -- (void) setUndoAction: (NSDictionary*)Arg; -@end - -@implementation I -@end - -@class NSArray; - -@interface MyClass2 { -@private - NSArray *_names1; - NSArray *_names2; - NSArray *_names3; - NSArray *_names4; -} -- (void)setNames1:(NSArray *)names; -- (void)setNames4:(__strong NSArray *)names; -- (void)setNames3:(__strong NSArray *)names; -- (void)setNames2:(NSArray *)names; -- (NSArray *) names2; -- (NSArray *)names3; -- (__strong NSArray *)names4; -- (NSArray *) names1; -@end - -// Properties that contain the name "delegate" or "dataSource", -// or have exact name "target" have unsafe_unretained attribute. -@interface NSInvocation -- (id)target; -- (void)setTarget:(id)target; - -- (id) dataSource; - -- (id)delegate; - -- (id)xxxdelegateYYY; -- (void)setXxxdelegateYYY:(id)delegate; - -- (void)setDataSource:(id)source; - -- (id)MYtarget; -- (void)setMYtarget: (id)target; - -- (id)targetX; -- (void)setTargetX: (id)t; - -- (int)value; -- (void)setValue: (int)val; - --(BOOL) isContinuous; --(void) setContinuous:(BOOL)value; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -- (int) Length; -- (id) object; -+ (double) D; -- (void *)JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER); -- (BOOL)isIgnoringInteractionEvents; - -- (NSString *)getStringValue; -- (BOOL)getCounterValue; -- (void)setStringValue:(NSString *)stringValue AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; -- (NSDictionary *)getns_dixtionary; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -- (BOOL) getM; -- (BOOL) getMA; -- (BOOL) getALL; -- (BOOL) getMANY; -- (BOOL) getSome; -@end - - -@interface NSInvocation(CAT) -- (id)target; -- (void)setTarget:(id)target; - -- (id) dataSource; - -- (id)xxxdelegateYYY; -- (void)setXxxdelegateYYY:(id)delegate; - -- (void)setDataSource:(id)source; - -- (id)MYtarget; -- (void)setMYtarget: (id)target; - -- (id)targetX; -- (void)setTargetX: (id)t; - -- (int)value; -- (void)setValue: (int)val; - --(BOOL) isContinuous; --(void) setContinuous:(BOOL)value; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -- (int) Length; -- (id) object; -+ (double) D; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -- (BOOL) getM; -- (BOOL) getMA; -- (BOOL) getALL; -- (BOOL) getMANY; -- (BOOL) getSome; -@end - -DEPRECATED -@interface I_DEP -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; -@end - -@interface AnotherOne -- (BOOL) isinValid DEPRECATED; -- (void) setInValid : (BOOL) arg; -- (id)MYtarget; -- (void)setMYtarget: (id)target DEPRECATED; -- (BOOL) getM DEPRECATED; - -- (id)xxxdelegateYYY DEPRECATED; -- (void)setXxxdelegateYYY:(id)delegate DEPRECATED; -@end - -#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0))) -#define NORETURN __attribute__((noreturn)) -#define ALIGNED __attribute__((aligned(16))) - -@interface NSURL -// Do not infer a property. -- (NSURL *)appStoreReceiptURL NS_AVAILABLE; -- (void) setAppStoreReceiptURL : (NSURL *)object; - -- (NSURL *)appStoreReceiptURLX NS_AVAILABLE; -- (void) setAppStoreReceiptURLX : (NSURL *)object NS_AVAILABLE; - -// Do not infer a property. -- (NSURL *)appStoreReceiptURLY ; -- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE; - -- (id)OkToInfer NS_AVAILABLE; - -// Do not infer a property. -- (NSURL *)appStoreReceiptURLZ ; -- (void) setAppStoreReceiptURLZ : (NSURL *)object NS_AVAILABLE; - -// Do not infer a property. -- (id) t1 NORETURN NS_AVAILABLE; -- (void) setT1 : (id) arg NS_AVAILABLE; - -- (id)method1 ALIGNED NS_AVAILABLE; -- (void) setMethod1 : (id) object NS_AVAILABLE ALIGNED; - -- (NSURL *)init; // No Change -+ (id)alloc; // No Change - -- (BOOL)is1stClass; // Not a valid property -- (BOOL)isClass; // This is a valid property 'class' is not a keyword in ObjC -- (BOOL)isDouble; // Not a valid property - -@end - -@class NSMutableDictionary; - -@interface NSArray -- (id (^)(id, NSArray *, NSMutableDictionary *)) expressionBlock; -- (id (^)(id, NSArray *, NSMutableDictionary *)) MyBlock; -- (void) setMyBlock : (id (^)(id, NSArray *, NSMutableDictionary *)) bl; -- (id (*)(id, NSArray *, NSMutableDictionary *)) expressionFuncptr; -- (id (*)(id, NSArray *, NSMutableDictionary *)) MyFuncptr; -- (void) setMyFuncptr : (id (*)(id, NSArray *, NSMutableDictionary *)) bl; -@end - -@interface rdar15231241 -@property (nonatomic, readonly) double Ddelegate; -@property (nonatomic, readonly) float Fdelegate; -@property (nonatomic, readonly) int Idelegate; -@property (nonatomic, readonly) BOOL Bdelegate; -@end - -@protocol NSObject @end -@protocol MyProtocol <NSObject> -- (id)readonlyProperty; -- (id)readWriteProperty; -- (void)setReadWriteProperty:(id)readWriteProperty; -@end diff --git clang/test/ARCMT/objcmt-property.m.result clang/test/ARCMT/objcmt-property.m.result deleted file mode 100644 index 610f027cee5c..000000000000 --- clang/test/ARCMT/objcmt-property.m.result +++ /dev/null @@ -1,215 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -objcmt-migrate-readonly-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -#define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION -#define WEAK_IMPORT_ATTRIBUTE __attribute__((objc_arc_weak_reference_unavailable)) -#define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER -#define DEPRECATED __attribute__((deprecated)) - -typedef char BOOL; -@class NSString; -@protocol NSCopying @end - -@interface NSObject <NSCopying> -@end - -@interface NSDictionary : NSObject -@end - -@interface I : NSObject { - int ivarVal; -} -@property (nonatomic, weak) NSString *WeakProp; - -@property (nonatomic, strong) NSString *StrongProp; - -@property (nonatomic, strong) NSString *UnavailProp __attribute__((unavailable)); -- (void) setUnavailProp : (NSString *)Val; - -@property (nonatomic, strong) NSString *UnavailProp1 __attribute__((unavailable)); - -@property (nonatomic, strong) NSString *UnavailProp2; -- (void) setUnavailProp2 : (NSString *)Val __attribute__((unavailable)); - -@property (nonatomic, copy) NSDictionary *undoAction; -@end - -@implementation I -@end - -@class NSArray; - -@interface MyClass2 { -@private - NSArray *_names1; - NSArray *_names2; - NSArray *_names3; - NSArray *_names4; -} -@property (nonatomic, strong) NSArray *names2; -@property (nonatomic, strong) NSArray *names3; -@property (nonatomic, strong) NSArray *names4; -@property (nonatomic, strong) NSArray *names1; -@end - -// Properties that contain the name "delegate" or "dataSource", -// or have exact name "target" have unsafe_unretained attribute. -@interface NSInvocation -@property (nonatomic, assign) id target; - -@property (nonatomic, assign) id dataSource; - -@property (nonatomic, readonly, assign) id delegate; - -@property (nonatomic, assign) id xxxdelegateYYY; - - -@property (nonatomic, strong) id MYtarget; - -@property (nonatomic, strong) id targetX; - -@property (nonatomic) int value; - -@property (nonatomic, getter=isContinuous) BOOL continuous; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -@property (nonatomic, getter=isinValid, readonly) BOOL inValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -@property (nonatomic, readonly) int Length; -@property (nonatomic, readonly, strong) id object; -+ (double) D; -@property (nonatomic, readonly) void *JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER); -@property (nonatomic, getter=isIgnoringInteractionEvents, readonly) BOOL ignoringInteractionEvents; - -@property (nonatomic, getter=getStringValue, strong) NSString *stringValue; -@property (nonatomic, getter=getCounterValue, readonly) BOOL counterValue; -@property (nonatomic, getter=getns_dixtionary, readonly, copy) NSDictionary *ns_dixtionary; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -@property (nonatomic, getter=getM, readonly) BOOL m; -@property (nonatomic, getter=getMA, readonly) BOOL MA; -@property (nonatomic, getter=getALL, readonly) BOOL ALL; -@property (nonatomic, getter=getMANY, readonly) BOOL MANY; -@property (nonatomic, getter=getSome, readonly) BOOL some; -@end - - -@interface NSInvocation(CAT) -@property (nonatomic, assign) id target; - -@property (nonatomic, assign) id dataSource; - -@property (nonatomic, assign) id xxxdelegateYYY; - - -@property (nonatomic, strong) id MYtarget; - -@property (nonatomic, strong) id targetX; - -@property (nonatomic) int value; - -@property (nonatomic, getter=isContinuous) BOOL continuous; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -@property (nonatomic, getter=isinValid, readonly) BOOL inValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -@property (nonatomic, readonly) int Length; -@property (nonatomic, readonly, strong) id object; -+ (double) D; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -@property (nonatomic, getter=getM, readonly) BOOL m; -@property (nonatomic, getter=getMA, readonly) BOOL MA; -@property (nonatomic, getter=getALL, readonly) BOOL ALL; -@property (nonatomic, getter=getMANY, readonly) BOOL MANY; -@property (nonatomic, getter=getSome, readonly) BOOL some; -@end - -DEPRECATED -@interface I_DEP -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; -@end - -@interface AnotherOne -- (BOOL) isinValid DEPRECATED; -- (void) setInValid : (BOOL) arg; -- (id)MYtarget; -- (void)setMYtarget: (id)target DEPRECATED; -- (BOOL) getM DEPRECATED; - -- (id)xxxdelegateYYY DEPRECATED; -- (void)setXxxdelegateYYY:(id)delegate DEPRECATED; -@end - -#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0))) -#define NORETURN __attribute__((noreturn)) -#define ALIGNED __attribute__((aligned(16))) - -@interface NSURL -// Do not infer a property. -@property (nonatomic, strong) NSURL *appStoreReceiptURL NS_AVAILABLE; -- (void) setAppStoreReceiptURL : (NSURL *)object; - -@property (nonatomic, strong) NSURL *appStoreReceiptURLX NS_AVAILABLE; - -// Do not infer a property. -@property (nonatomic, strong) NSURL *appStoreReceiptURLY ; -- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE; - -@property (nonatomic, readonly, strong) id OkToInfer NS_AVAILABLE; - -// Do not infer a property. -@property (nonatomic, strong) NSURL *appStoreReceiptURLZ ; -- (void) setAppStoreReceiptURLZ : (NSURL *)object NS_AVAILABLE; - -// Do not infer a property. -- (id) t1 NORETURN NS_AVAILABLE; -- (void) setT1 : (id) arg NS_AVAILABLE; - -@property (nonatomic, strong) id method1 ALIGNED NS_AVAILABLE; - -- (NSURL *)init; // No Change -+ (id)alloc; // No Change - -- (BOOL)is1stClass; // Not a valid property -@property (nonatomic, getter=isClass, readonly) BOOL class; // This is a valid property 'class' is not a keyword in ObjC -- (BOOL)isDouble; // Not a valid property - -@end - -@class NSMutableDictionary; - -@interface NSArray -@property (nonatomic, readonly, copy) id (^expressionBlock)(id, NSArray *, NSMutableDictionary *); -@property (nonatomic, copy) id (^MyBlock)(id, NSArray *, NSMutableDictionary *); -@property (nonatomic, readonly) id (*expressionFuncptr)(id, NSArray *, NSMutableDictionary *); -@property (nonatomic) id (*MyFuncptr)(id, NSArray *, NSMutableDictionary *); -@end - -@interface rdar15231241 -@property (nonatomic, readonly) double Ddelegate; -@property (nonatomic, readonly) float Fdelegate; -@property (nonatomic, readonly) int Idelegate; -@property (nonatomic, readonly) BOOL Bdelegate; -@end - -@protocol NSObject @end -@protocol MyProtocol <NSObject> -@property (nonatomic, readonly, strong) id readonlyProperty; -@property (nonatomic, strong) id readWriteProperty; -@end diff --git clang/test/ARCMT/objcmt-protocol-conformance.m clang/test/ARCMT/objcmt-protocol-conformance.m deleted file mode 100644 index e9bb4ac12e6d..000000000000 --- clang/test/ARCMT/objcmt-protocol-conformance.m +++ /dev/null @@ -1,129 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-protocol-conformance -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -@interface NSObject @end - -@protocol P -- (id) Meth1: (double) arg; -@end - -@interface Test1 // Test for no super class and no protocol list -@end - -@implementation Test1 -- (id) Meth1: (double) arg { return 0; } -@end - -@protocol P1 @end -@protocol P2 @end - -@interface Test2 <P1, P2> // Test for no super class and with protocol list -{ - id IVAR1; - id IVAR2; -} -@end - -@implementation Test2 -- (id) Meth1: (double) arg { return 0; } -@end - -@interface Test3 : NSObject { // Test for Super class and no protocol list - id IV1; -} -@end - -@implementation Test3 -- (id) Meth1: (double) arg { return 0; } -@end - -@interface Test4 : NSObject <P1, P2> // Test for Super class and protocol list -@end - -@implementation Test4 -- (id) Meth1: (double) arg { return 0; } -@end - -// Test5 - conforms to P3 because it implement's P3's property. -@protocol P3 -@property (copy) id Prop; -@end - -@protocol P4 -@property (copy) id Prop; -@end - -@interface Test5 : NSObject<P3> -@end - -@implementation Test5 -@synthesize Prop=_XXX; -@end - -@protocol P5 <P3, P4> -@property (copy) id Prop; -@end - -@protocol P6 <P3, P4, P5> -@property (copy) id Prop; -@end - -@interface Test6 : NSObject // Test for minimal listing of conforming protocols -@property (copy) id Prop; -@end - -@implementation Test6 -@end - -@class UIDynamicAnimator, UIWindow; -@interface UIResponder : NSObject -@end - -@protocol EmptyProtocol -@end - -@protocol OptionalMethodsOnly -@optional -- (void)dynamicAnimatorWillResume:(UIDynamicAnimator*)animator; -- (void)dynamicAnimatorDidPause:(UIDynamicAnimator*)animator; -@end - -@protocol OptionalPropertiesOnly -@optional -@property (strong, nonatomic) id OptionalProperty; -@end - -@protocol OptionalEvrything -@optional -- (void)dynamicAnimatorWillResume:(UIDynamicAnimator*)animator; -@property (strong, nonatomic) id OptionalProperty; -- (void)dynamicAnimatorDidPause:(UIDynamicAnimator*)animator; -@end - -@protocol UIApplicationDelegate -@end - -@interface Test7 : UIResponder <UIApplicationDelegate> -@property (strong, nonatomic) UIWindow *window; -@end - -@implementation Test7 -@end - -@interface BTLEBrowser -@end - -@protocol CBCentralManagerDelegate; - -@protocol CBCentralManagerDelegate -- (id) Meth1: (double) arg; -@end - -@interface BTLEBrowser() <CBCentralManagerDelegate> -@end - -@implementation BTLEBrowser -- (id) Meth15515206: (double) arg { return 0; } -@end diff --git clang/test/ARCMT/objcmt-protocol-conformance.m.result clang/test/ARCMT/objcmt-protocol-conformance.m.result deleted file mode 100644 index 987532544bc6..000000000000 --- clang/test/ARCMT/objcmt-protocol-conformance.m.result +++ /dev/null @@ -1,129 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-protocol-conformance -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -@interface NSObject @end - -@protocol P -- (id) Meth1: (double) arg; -@end - -@interface Test1<P> // Test for no super class and no protocol list -@end - -@implementation Test1 -- (id) Meth1: (double) arg { return 0; } -@end - -@protocol P1 @end -@protocol P2 @end - -@interface Test2 <P1, P2, P> // Test for no super class and with protocol list -{ - id IVAR1; - id IVAR2; -} -@end - -@implementation Test2 -- (id) Meth1: (double) arg { return 0; } -@end - -@interface Test3 : NSObject<P> { // Test for Super class and no protocol list - id IV1; -} -@end - -@implementation Test3 -- (id) Meth1: (double) arg { return 0; } -@end - -@interface Test4 : NSObject <P1, P2, P> // Test for Super class and protocol list -@end - -@implementation Test4 -- (id) Meth1: (double) arg { return 0; } -@end - -// Test5 - conforms to P3 because it implement's P3's property. -@protocol P3 -@property (copy) id Prop; -@end - -@protocol P4 -@property (copy) id Prop; -@end - -@interface Test5 : NSObject<P3, P4> -@end - -@implementation Test5 -@synthesize Prop=_XXX; -@end - -@protocol P5 <P3, P4> -@property (copy) id Prop; -@end - -@protocol P6 <P3, P4, P5> -@property (copy) id Prop; -@end - -@interface Test6 : NSObject<P6> // Test for minimal listing of conforming protocols -@property (copy) id Prop; -@end - -@implementation Test6 -@end - -@class UIDynamicAnimator, UIWindow; -@interface UIResponder : NSObject -@end - -@protocol EmptyProtocol -@end - -@protocol OptionalMethodsOnly -@optional -- (void)dynamicAnimatorWillResume:(UIDynamicAnimator*)animator; -- (void)dynamicAnimatorDidPause:(UIDynamicAnimator*)animator; -@end - -@protocol OptionalPropertiesOnly -@optional -@property (strong, nonatomic) id OptionalProperty; -@end - -@protocol OptionalEvrything -@optional -- (void)dynamicAnimatorWillResume:(UIDynamicAnimator*)animator; -@property (strong, nonatomic) id OptionalProperty; -- (void)dynamicAnimatorDidPause:(UIDynamicAnimator*)animator; -@end - -@protocol UIApplicationDelegate -@end - -@interface Test7 : UIResponder <UIApplicationDelegate> -@property (strong, nonatomic) UIWindow *window; -@end - -@implementation Test7 -@end - -@interface BTLEBrowser -@end - -@protocol CBCentralManagerDelegate; - -@protocol CBCentralManagerDelegate -- (id) Meth1: (double) arg; -@end - -@interface BTLEBrowser() <CBCentralManagerDelegate> -@end - -@implementation BTLEBrowser -- (id) Meth15515206: (double) arg { return 0; } -@end diff --git clang/test/ARCMT/objcmt-subscripting-literals-in-arc.m clang/test/ARCMT/objcmt-subscripting-literals-in-arc.m deleted file mode 100644 index 1f56f4a2cf51..000000000000 --- clang/test/ARCMT/objcmt-subscripting-literals-in-arc.m +++ /dev/null @@ -1,108 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fobjc-arc -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fobjc-arc -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result - -typedef signed char BOOL; -#define nil ((void*) 0) - -typedef const struct __CFString * CFStringRef; - -@interface NSObject -+ (id)alloc; -@end - -@protocol NSCopying -@end - -@interface NSString : NSObject -+ (id)stringWithString:(NSString *)string; -- (id)initWithString:(NSString *)aString; -@end - -@interface NSArray : NSObject -- (id)objectAtIndex:(unsigned long)index; -@end - -@interface NSArray (NSExtendedArray) -- (id)objectAtIndexedSubscript:(unsigned)idx; -@end - -@interface NSArray (NSArrayCreation) -+ (id)array; -+ (id)arrayWithObject:(id)anObject; -+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; -+ (id)arrayWithObjects:(id)firstObj, ...; -+ (id)arrayWithArray:(NSArray *)array; - -- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; -- (id)initWithObjects:(id)firstObj, ...; -- (id)initWithArray:(NSArray *)array; -@end - -@interface NSMutableArray : NSArray -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -@end - -@interface NSMutableArray (NSExtendedMutableArray) -- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; -@end - -@interface NSDictionary : NSObject -- (id)objectForKey:(id)aKey; -@end - -@interface NSDictionary (NSExtendedDictionary) -- (id)objectForKeyedSubscript:(id)key; -@end - -@interface NSDictionary (NSDictionaryCreation) -+ (id)dictionary; -+ (id)dictionaryWithObject:(id)object forKey:(id)key; -+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -+ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...; -+ (id)dictionaryWithDictionary:(NSDictionary *)dict; -+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -- (id)initWithObjectsAndKeys:(id)firstObject, ...; -- (id)initWithDictionary:(NSDictionary *)otherDictionary; -- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; -@end - -@interface NSMutableDictionary : NSDictionary -- (void)setObject:(id)anObject forKey:(id)aKey; -@end - -@interface NSMutableDictionary (NSExtendedMutableDictionary) -- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key; -@end - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value; -- (id)initWithInt:(int)value; -@end - -@interface I { - NSArray *ivarArr; -} -@end -@implementation I --(void) foo { - NSString *str; - NSArray *arr; - NSDictionary *dict; - - arr = [NSArray arrayWithObjects:str, str, nil]; - arr = [[NSArray alloc] initWithObjects:str, str, nil]; - dict = [NSDictionary dictionaryWithObjectsAndKeys: @"value1", @"key1", @"value2", @"key2", nil]; - dict = [[NSDictionary alloc] initWithObjectsAndKeys: @"value1", @"key1", @"value2", @"key2", nil]; - - dict = [[NSDictionary alloc] initWithObjects:[[NSArray alloc] initWithObjects:@"1", @"2", nil] forKeys:[NSArray arrayWithObjects:@"A", @"B", nil]]; - - NSNumber *n = [[NSNumber alloc] initWithInt:2]; -} -@end diff --git clang/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result clang/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result deleted file mode 100644 index d974a2564d43..000000000000 --- clang/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result +++ /dev/null @@ -1,108 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fobjc-arc -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fobjc-arc -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result - -typedef signed char BOOL; -#define nil ((void*) 0) - -typedef const struct __CFString * CFStringRef; - -@interface NSObject -+ (id)alloc; -@end - -@protocol NSCopying -@end - -@interface NSString : NSObject -+ (id)stringWithString:(NSString *)string; -- (id)initWithString:(NSString *)aString; -@end - -@interface NSArray : NSObject -- (id)objectAtIndex:(unsigned long)index; -@end - -@interface NSArray (NSExtendedArray) -- (id)objectAtIndexedSubscript:(unsigned)idx; -@end - -@interface NSArray (NSArrayCreation) -+ (id)array; -+ (id)arrayWithObject:(id)anObject; -+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; -+ (id)arrayWithObjects:(id)firstObj, ...; -+ (id)arrayWithArray:(NSArray *)array; - -- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; -- (id)initWithObjects:(id)firstObj, ...; -- (id)initWithArray:(NSArray *)array; -@end - -@interface NSMutableArray : NSArray -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -@end - -@interface NSMutableArray (NSExtendedMutableArray) -- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; -@end - -@interface NSDictionary : NSObject -- (id)objectForKey:(id)aKey; -@end - -@interface NSDictionary (NSExtendedDictionary) -- (id)objectForKeyedSubscript:(id)key; -@end - -@interface NSDictionary (NSDictionaryCreation) -+ (id)dictionary; -+ (id)dictionaryWithObject:(id)object forKey:(id)key; -+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -+ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...; -+ (id)dictionaryWithDictionary:(NSDictionary *)dict; -+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -- (id)initWithObjectsAndKeys:(id)firstObject, ...; -- (id)initWithDictionary:(NSDictionary *)otherDictionary; -- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; -@end - -@interface NSMutableDictionary : NSDictionary -- (void)setObject:(id)anObject forKey:(id)aKey; -@end - -@interface NSMutableDictionary (NSExtendedMutableDictionary) -- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key; -@end - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value; -- (id)initWithInt:(int)value; -@end - -@interface I { - NSArray *ivarArr; -} -@end -@implementation I --(void) foo { - NSString *str; - NSArray *arr; - NSDictionary *dict; - - arr = @[str, str]; - arr = @[str, str]; - dict = @{@"key1": @"value1", @"key2": @"value2"}; - dict = @{@"key1": @"value1", @"key2": @"value2"}; - - dict = @{@"A": @"1", @"B": @"2"}; - - NSNumber *n = @2; -} -@end diff --git clang/test/ARCMT/objcmt-subscripting-literals.m clang/test/ARCMT/objcmt-subscripting-literals.m deleted file mode 100644 index e2b03e2d7b58..000000000000 --- clang/test/ARCMT/objcmt-subscripting-literals.m +++ /dev/null @@ -1,230 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result - -typedef signed char BOOL; -#define nil ((void*) 0) - -typedef const struct __CFString * CFStringRef; - -@interface NSObject -+ (id)alloc; -@end - -@protocol NSCopying -@end - -@interface NSString : NSObject -+ (id)stringWithString:(NSString *)string; -- (id)initWithString:(NSString *)aString; -@end - -@interface NSArray : NSObject -- (id)objectAtIndex:(unsigned long)index; -@end - -@interface NSArray (NSExtendedArray) -- (id)objectAtIndexedSubscript:(unsigned)idx; -@end - -@interface NSArray (NSArrayCreation) -+ (id)array; -+ (id)arrayWithObject:(id)anObject; -+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; -+ (id)arrayWithObjects:(id)firstObj, ...; -+ (id)arrayWithArray:(NSArray *)array; - -- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; -- (id)initWithObjects:(id)firstObj, ...; -- (id)initWithArray:(NSArray *)array; -@end - -@interface NSMutableArray : NSArray -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -@end - -@interface NSMutableArray (NSExtendedMutableArray) -- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; -@end - -@interface NSDictionary : NSObject -- (id)objectForKey:(id)aKey; -@end - -@interface NSDictionary (NSExtendedDictionary) -- (id)objectForKeyedSubscript:(id)key; -@end - -@interface NSDictionary (NSDictionaryCreation) -+ (id)dictionary; -+ (id)dictionaryWithObject:(id)object forKey:(id)key; -+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -+ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...; -+ (id)dictionaryWithDictionary:(NSDictionary *)dict; -+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -- (id)initWithObjectsAndKeys:(id)firstObject, ...; -- (id)initWithDictionary:(NSDictionary *)otherDictionary; -- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; -@end - -@interface NSMutableDictionary : NSDictionary -- (void)setObject:(id)anObject forKey:(id)aKey; -@end - -@interface NSMutableDictionary (NSExtendedMutableDictionary) -- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key; -@end - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value; -@end - -#define M(x) (x) -#define PAIR(x) @#x, [NSNumber numberWithInt:(x)] -#define TWO(x) ((x), (x)) -#define TWO_SEP(x,y) ((x), (y)) - -@interface I { - NSArray *ivarArr; -} -@end -@implementation I --(void) foo { - NSString *str; - NSArray *arr; - NSDictionary *dict; - - arr = [NSArray array]; - arr = [NSArray arrayWithObject:str]; - arr = [NSArray arrayWithObjects:str, str, nil]; - dict = [NSDictionary dictionary]; - dict = [NSDictionary dictionaryWithObject:arr forKey:str]; - dict = [NSDictionary dictionaryWithObjectsAndKeys: @"value1", @"key1", @"value2", @"key2", nil]; - dict = [NSDictionary dictionaryWithObjectsAndKeys: PAIR(1), PAIR(2), nil]; - dict = [NSDictionary dictionaryWithObjectsAndKeys: - @"value1", @"key1", -#ifdef BLAH - @"value2", @"key2", -#else - @"value3", @"key3", -#endif - nil ]; - - id o = [arr objectAtIndex:2]; - o = [dict objectForKey:@"key"]; - o = TWO([dict objectForKey:@"key"]); - o = TWO_SEP([dict objectForKey:@"key"], [arr objectAtIndex:2]); - o = [NSDictionary dictionaryWithObject:[NSDictionary dictionary] forKey:@"key"]; - NSMutableArray *marr = 0; - NSMutableDictionary *mdict = 0; - [marr replaceObjectAtIndex:2 withObject:@"val"]; - [mdict setObject:@"value" forKey:@"key"]; - [marr replaceObjectAtIndex:2 withObject:[arr objectAtIndex:4]]; - [mdict setObject:[dict objectForKey:@"key2"] forKey:@"key"]; - [mdict setObject:[dict objectForKey:@"key2"] forKey: -#if 1 - @"key1" -#else - @"key2" -#endif - ]; - [mdict setObject:[dict objectForKey: -#if 2 - @"key3" -#else - @"key4" -#endif - ] forKey:@"key"]; - [mdict setObject:@"value" forKey:[dict objectForKey: -#if 3 - @"key5" -#else - @"key6" -#endif - ] ]; - [mdict setObject:@"val" forKey:[dict objectForKey:@"key2"]]; - [mdict setObject:[dict objectForKey:@"key1"] forKey:[dict objectForKey:[NSArray arrayWithObject:@"arrkey"]]]; - __strong NSArray **parr = 0; - o = [*parr objectAtIndex:2]; - void *hd; - o = [(NSArray*)hd objectAtIndex:2]; - o = [ivarArr objectAtIndex:2]; - - dict = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"1", [NSArray array], nil] forKeys:[NSArray arrayWithObjects:@"A", [arr objectAtIndex:2], nil]]; - dict = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"1", @"2", nil] forKeys:arr]; - dict = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"1", @"2", nil] forKeys:@[@"A", @"B"]]; - dict = [NSDictionary dictionaryWithObjectsAndKeys:[NSArray array], @"A", [NSArray array], @"B", nil]; -} -@end - -extern const CFStringRef globStr; - -void test1(NSString *str) { - NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: str, globStr, nil]; - dict = [NSDictionary dictionaryWithObjectsAndKeys: globStr, str, nil]; - dict = [NSDictionary dictionaryWithObject:str forKey:globStr]; - dict = [NSDictionary dictionaryWithObject:globStr forKey:str]; - - NSArray *arr = [NSArray arrayWithObjects: globStr, globStr, nil]; - arr = [NSArray arrayWithObjects: str, globStr, nil]; - arr = [NSArray arrayWithObjects: globStr, str, nil]; - arr = [NSArray arrayWithObject:globStr]; -} - -@interface Custom : NSObject -- (id)objectAtIndex:(unsigned long)index; -@end - -@interface Custom (Extended) -- (id)objectAtIndexedSubscript:(unsigned)idx; -@end - -@interface MutableCustom : Custom -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -@end - -@interface MutableCustom (Extended) -- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; -@end - -@interface CustomUnavail : NSObject -- (id)objectAtIndex:(unsigned long)index; -@end - -@interface CustomUnavail (Extended) -- (id)objectAtIndexedSubscript:(unsigned)idx __attribute__((unavailable)); -@end - -@interface MutableCustomUnavail : CustomUnavail -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -@end - -@interface MutableCustomUnavail (Extended) -- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx __attribute__((unavailable)); -@end - -void test2(void) { - MutableCustom *mutc; - id o = [mutc objectAtIndex:4]; - [mutc replaceObjectAtIndex:2 withObject:@"val"]; - - MutableCustomUnavail *mutcunaval; - o = [mutcunaval objectAtIndex:4]; - [mutcunaval replaceObjectAtIndex:2 withObject:@"val"]; -} - -@interface NSLocale : NSObject -+ (id)systemLocale; -+ (id)currentLocale; -- (id)objectForKey:(id)key; -@end - -void test3(id key) { - id o = [[NSLocale currentLocale] objectForKey:key]; -} diff --git clang/test/ARCMT/objcmt-subscripting-literals.m.result clang/test/ARCMT/objcmt-subscripting-literals.m.result deleted file mode 100644 index e0b385741f01..000000000000 --- clang/test/ARCMT/objcmt-subscripting-literals.m.result +++ /dev/null @@ -1,230 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result - -typedef signed char BOOL; -#define nil ((void*) 0) - -typedef const struct __CFString * CFStringRef; - -@interface NSObject -+ (id)alloc; -@end - -@protocol NSCopying -@end - -@interface NSString : NSObject -+ (id)stringWithString:(NSString *)string; -- (id)initWithString:(NSString *)aString; -@end - -@interface NSArray : NSObject -- (id)objectAtIndex:(unsigned long)index; -@end - -@interface NSArray (NSExtendedArray) -- (id)objectAtIndexedSubscript:(unsigned)idx; -@end - -@interface NSArray (NSArrayCreation) -+ (id)array; -+ (id)arrayWithObject:(id)anObject; -+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; -+ (id)arrayWithObjects:(id)firstObj, ...; -+ (id)arrayWithArray:(NSArray *)array; - -- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; -- (id)initWithObjects:(id)firstObj, ...; -- (id)initWithArray:(NSArray *)array; -@end - -@interface NSMutableArray : NSArray -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -@end - -@interface NSMutableArray (NSExtendedMutableArray) -- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; -@end - -@interface NSDictionary : NSObject -- (id)objectForKey:(id)aKey; -@end - -@interface NSDictionary (NSExtendedDictionary) -- (id)objectForKeyedSubscript:(id)key; -@end - -@interface NSDictionary (NSDictionaryCreation) -+ (id)dictionary; -+ (id)dictionaryWithObject:(id)object forKey:(id)key; -+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -+ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...; -+ (id)dictionaryWithDictionary:(NSDictionary *)dict; -+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -- (id)initWithObjectsAndKeys:(id)firstObject, ...; -- (id)initWithDictionary:(NSDictionary *)otherDictionary; -- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; -@end - -@interface NSMutableDictionary : NSDictionary -- (void)setObject:(id)anObject forKey:(id)aKey; -@end - -@interface NSMutableDictionary (NSExtendedMutableDictionary) -- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key; -@end - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value; -@end - -#define M(x) (x) -#define PAIR(x) @#x, [NSNumber numberWithInt:(x)] -#define TWO(x) ((x), (x)) -#define TWO_SEP(x,y) ((x), (y)) - -@interface I { - NSArray *ivarArr; -} -@end -@implementation I --(void) foo { - NSString *str; - NSArray *arr; - NSDictionary *dict; - - arr = @[]; - arr = @[str]; - arr = @[str, str]; - dict = @{}; - dict = @{str: arr}; - dict = @{@"key1": @"value1", @"key2": @"value2"}; - dict = [NSDictionary dictionaryWithObjectsAndKeys: PAIR(1), PAIR(2), nil]; - dict = [NSDictionary dictionaryWithObjectsAndKeys: - @"value1", @"key1", -#ifdef BLAH - @"value2", @"key2", -#else - @"value3", @"key3", -#endif - nil ]; - - id o = arr[2]; - o = dict[@"key"]; - o = TWO(dict[@"key"]); - o = TWO_SEP(dict[@"key"], arr[2]); - o = @{@"key": @{}}; - NSMutableArray *marr = 0; - NSMutableDictionary *mdict = 0; - marr[2] = @"val"; - mdict[@"key"] = @"value"; - marr[2] = arr[4]; - mdict[@"key"] = dict[@"key2"]; - [mdict setObject:dict[@"key2"] forKey: -#if 1 - @"key1" -#else - @"key2" -#endif - ]; - mdict[@"key"] = [dict objectForKey: -#if 2 - @"key3" -#else - @"key4" -#endif - ]; - mdict[[dict objectForKey: -#if 3 - @"key5" -#else - @"key6" -#endif - ]] = @"value"; - mdict[dict[@"key2"]] = @"val"; - mdict[dict[@[@"arrkey"]]] = dict[@"key1"]; - __strong NSArray **parr = 0; - o = (*parr)[2]; - void *hd; - o = ((NSArray*)hd)[2]; - o = ivarArr[2]; - - dict = @{@"A": @"1", arr[2]: @[]}; - dict = [NSDictionary dictionaryWithObjects:@[@"1", @"2"] forKeys:arr]; - dict = @{@"A": @"1", @"B": @"2"}; - dict = @{@"A": @[], @"B": @[]}; -} -@end - -extern const CFStringRef globStr; - -void test1(NSString *str) { - NSDictionary *dict = @{(id)globStr: str}; - dict = @{str: (id)globStr}; - dict = @{(id)globStr: str}; - dict = @{str: (id)globStr}; - - NSArray *arr = @[(id)globStr, (id)globStr]; - arr = @[str, (id)globStr]; - arr = @[(id)globStr, str]; - arr = @[(id)globStr]; -} - -@interface Custom : NSObject -- (id)objectAtIndex:(unsigned long)index; -@end - -@interface Custom (Extended) -- (id)objectAtIndexedSubscript:(unsigned)idx; -@end - -@interface MutableCustom : Custom -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -@end - -@interface MutableCustom (Extended) -- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; -@end - -@interface CustomUnavail : NSObject -- (id)objectAtIndex:(unsigned long)index; -@end - -@interface CustomUnavail (Extended) -- (id)objectAtIndexedSubscript:(unsigned)idx __attribute__((unavailable)); -@end - -@interface MutableCustomUnavail : CustomUnavail -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -@end - -@interface MutableCustomUnavail (Extended) -- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx __attribute__((unavailable)); -@end - -void test2(void) { - MutableCustom *mutc; - id o = mutc[4]; - mutc[2] = @"val"; - - MutableCustomUnavail *mutcunaval; - o = [mutcunaval objectAtIndex:4]; - [mutcunaval replaceObjectAtIndex:2 withObject:@"val"]; -} - -@interface NSLocale : NSObject -+ (id)systemLocale; -+ (id)currentLocale; -- (id)objectForKey:(id)key; -@end - -void test3(id key) { - id o = [[NSLocale currentLocale] objectForKey:key]; -} diff --git clang/test/ARCMT/objcmt-subscripting-unavailable.m clang/test/ARCMT/objcmt-subscripting-unavailable.m deleted file mode 100644 index d72c362e30f4..000000000000 --- clang/test/ARCMT/objcmt-subscripting-unavailable.m +++ /dev/null @@ -1,79 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result - -typedef signed char BOOL; -#define nil ((void*) 0) - -@interface NSObject -+ (id)alloc; -@end - -@interface NSArray : NSObject -- (id)objectAtIndex:(unsigned long)index; -@end - -@interface NSArray (NSArrayCreation) -+ (id)array; -+ (id)arrayWithObject:(id)anObject; -+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; -+ (id)arrayWithObjects:(id)firstObj, ...; -+ (id)arrayWithArray:(NSArray *)array; - -- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; -- (id)initWithObjects:(id)firstObj, ...; -- (id)initWithArray:(NSArray *)array; -@end - -@interface NSMutableArray : NSArray -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -@end - -@interface NSDictionary : NSObject -@end - -@interface NSDictionary (NSDictionaryCreation) -+ (id)dictionary; -+ (id)dictionaryWithObject:(id)object forKey:(id)key; -+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -+ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...; -+ (id)dictionaryWithDictionary:(NSDictionary *)dict; -+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -- (id)initWithObjectsAndKeys:(id)firstObject, ...; -- (id)initWithDictionary:(NSDictionary *)otherDictionary; -- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)objectForKey:(id)aKey; -@end - -@interface NSMutableDictionary : NSDictionary -- (void)setObject:(id)anObject forKey:(id)aKey; -@end - -@interface I -@end -@implementation I --(void) foo { - id str; - NSArray *arr; - NSDictionary *dict; - - arr = [NSArray array]; - arr = [NSArray arrayWithObject:str]; - arr = [NSArray arrayWithObjects:str, str, nil]; - dict = [NSDictionary dictionary]; - dict = [NSDictionary dictionaryWithObject:arr forKey:str]; - - id o = [arr objectAtIndex:2]; - o = [dict objectForKey:@"key"]; - NSMutableArray *marr = 0; - NSMutableDictionary *mdict = 0; - [marr replaceObjectAtIndex:2 withObject:@"val"]; - [mdict setObject:@"value" forKey:@"key"]; - [marr replaceObjectAtIndex:2 withObject:[arr objectAtIndex:4]]; - [mdict setObject:[dict objectForKey:@"key2"] forKey:@"key"]; -} -@end diff --git clang/test/ARCMT/objcmt-subscripting-unavailable.m.result clang/test/ARCMT/objcmt-subscripting-unavailable.m.result deleted file mode 100644 index bd74d5583860..000000000000 --- clang/test/ARCMT/objcmt-subscripting-unavailable.m.result +++ /dev/null @@ -1,79 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result - -typedef signed char BOOL; -#define nil ((void*) 0) - -@interface NSObject -+ (id)alloc; -@end - -@interface NSArray : NSObject -- (id)objectAtIndex:(unsigned long)index; -@end - -@interface NSArray (NSArrayCreation) -+ (id)array; -+ (id)arrayWithObject:(id)anObject; -+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; -+ (id)arrayWithObjects:(id)firstObj, ...; -+ (id)arrayWithArray:(NSArray *)array; - -- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; -- (id)initWithObjects:(id)firstObj, ...; -- (id)initWithArray:(NSArray *)array; -@end - -@interface NSMutableArray : NSArray -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -@end - -@interface NSDictionary : NSObject -@end - -@interface NSDictionary (NSDictionaryCreation) -+ (id)dictionary; -+ (id)dictionaryWithObject:(id)object forKey:(id)key; -+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -+ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...; -+ (id)dictionaryWithDictionary:(NSDictionary *)dict; -+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -- (id)initWithObjectsAndKeys:(id)firstObject, ...; -- (id)initWithDictionary:(NSDictionary *)otherDictionary; -- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)objectForKey:(id)aKey; -@end - -@interface NSMutableDictionary : NSDictionary -- (void)setObject:(id)anObject forKey:(id)aKey; -@end - -@interface I -@end -@implementation I --(void) foo { - id str; - NSArray *arr; - NSDictionary *dict; - - arr = @[]; - arr = @[str]; - arr = @[str, str]; - dict = @{}; - dict = @{str: arr}; - - id o = [arr objectAtIndex:2]; - o = [dict objectForKey:@"key"]; - NSMutableArray *marr = 0; - NSMutableDictionary *mdict = 0; - [marr replaceObjectAtIndex:2 withObject:@"val"]; - [mdict setObject:@"value" forKey:@"key"]; - [marr replaceObjectAtIndex:2 withObject:[arr objectAtIndex:4]]; - [mdict setObject:[dict objectForKey:@"key2"] forKey:@"key"]; -} -@end diff --git clang/test/ARCMT/objcmt-undefined-ns-macros.m clang/test/ARCMT/objcmt-undefined-ns-macros.m deleted file mode 100644 index 473b49589222..000000000000 --- clang/test/ARCMT/objcmt-undefined-ns-macros.m +++ /dev/null @@ -1,22 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fmodules -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result - -typedef long NSInteger; -enum { - UIViewNone = 0x0, - UIViewMargin = 0x1, - UIViewWidth = 0x2, - UIViewRightMargin = 0x3, - UIViewBottomMargin = 0xbadbeef -}; -typedef NSInteger UITableStyle; - - -typedef - enum { two = 1 } NumericEnum2; - -typedef enum { three = 1 } NumericEnum3; - -typedef enum { four = 1 } NumericEnum4; - diff --git clang/test/ARCMT/objcmt-undefined-ns-macros.m.result clang/test/ARCMT/objcmt-undefined-ns-macros.m.result deleted file mode 100644 index a6942e20795f..000000000000 --- clang/test/ARCMT/objcmt-undefined-ns-macros.m.result +++ /dev/null @@ -1,24 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fmodules -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result - -typedef long NSInteger; -#ifndef NS_ENUM -@import Foundation; -#endif -typedef NS_OPTIONS(NSUInteger, UITableStyle) { - UIViewNone = 0x0, - UIViewMargin = 0x1, - UIViewWidth = 0x2, - UIViewRightMargin = 0x3, - UIViewBottomMargin = 0xbadbeef -}; - - -typedef - NS_ENUM(unsigned int, NumericEnum2) { two = 1 }; - -typedef NS_ENUM(unsigned int, NumericEnum3) { three = 1 }; - -typedef NS_ENUM(unsigned int, NumericEnum4) { four = 1 }; - diff --git clang/test/ARCMT/objcmt-with-pch.m clang/test/ARCMT/objcmt-with-pch.m deleted file mode 100644 index 0925442d45eb..000000000000 --- clang/test/ARCMT/objcmt-with-pch.m +++ /dev/null @@ -1,17 +0,0 @@ -// REQUIRES: x86-registered-target -// RUN: rm -rf %t -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c %S/Common.h -emit-pch -o %t.pch -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -include-pch %t.pch -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result -include-pch %t.pch - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value; -@end - -void foo(void) { - NSNumber *n = [NSNumber numberWithInt:1]; -} diff --git clang/test/ARCMT/objcmt-with-pch.m.result clang/test/ARCMT/objcmt-with-pch.m.result deleted file mode 100644 index 6d37d11fe480..000000000000 --- clang/test/ARCMT/objcmt-with-pch.m.result +++ /dev/null @@ -1,17 +0,0 @@ -// REQUIRES: x86-registered-target -// RUN: rm -rf %t -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c %S/Common.h -emit-pch -o %t.pch -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -include-pch %t.pch -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result -include-pch %t.pch - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value; -@end - -void foo(void) { - NSNumber *n = @1; -} diff --git clang/test/ARCMT/protected-scope.m clang/test/ARCMT/protected-scope.m deleted file mode 100644 index b522f54cdf7c..000000000000 --- clang/test/ARCMT/protected-scope.m +++ /dev/null @@ -1,36 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -void test(id p, int x) { - int v; - switch(x) { - case 0: - v++; - id w1 = p; - id w2 = p; - break; - case 1: - v++; - id w3 = p; - break; - case 2: - case 3: - break; - default: - break; - } -} - -void test2(int p) { - switch (p) { - case 3:; - NSObject *o = [[NSObject alloc] init]; - [o release]; - break; - default: - break; - } -} diff --git clang/test/ARCMT/protected-scope.m.result clang/test/ARCMT/protected-scope.m.result deleted file mode 100644 index 55070f273227..000000000000 --- clang/test/ARCMT/protected-scope.m.result +++ /dev/null @@ -1,38 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -void test(id p, int x) { - int v; - switch(x) { - case 0: { - v++; - id w1 = p; - id w2 = p; - break; - } - case 1: { - v++; - id w3 = p; - break; - } - case 2: - case 3: - break; - default: - break; - } -} - -void test2(int p) { - switch (p) { - case 3: {; - NSObject *o = [[NSObject alloc] init]; - break; - } - default: - break; - } -} diff --git clang/test/ARCMT/releases-driver.m clang/test/ARCMT/releases-driver.m deleted file mode 100644 index 96f96c1d3b48..000000000000 --- clang/test/ARCMT/releases-driver.m +++ /dev/null @@ -1,67 +0,0 @@ -// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: cat %s > %t -// RUN: %clang_cc1 -arcmt-action=modify -triple x86_64-apple-macosx10.6 -x objective-c %t -// RUN: diff %t %s.result -// RUN: rm %t - -typedef int BOOL; - -id IhaveSideEffect(void); - -@protocol NSObject -- (BOOL)isEqual:(id)object; -- (id)retain; -- (oneway void)release; -@end - -@interface NSObject <NSObject> {} -@end - -@interface Foo : NSObject { - id bar; -} -@property (retain) id bar; --(void)test:(id)obj; -@end - -@implementation Foo - -@synthesize bar; - --(void)test:(id)obj { - id x = self.bar; - [x retain]; - self.bar = obj; - // do stuff with x; - [x release]; - - [IhaveSideEffect() release]; - - [x release], x = 0; -} - -@end - -void func(Foo *p) { - [p release]; - (([p release])); -} - -@interface Baz { - id <NSObject> _foo; -} -@end - -@implementation Baz -- (void) dealloc { - [_foo release]; -} -@end - -#define RELEASE_MACRO(x) [x release] -#define RELEASE_MACRO2(x) RELEASE_MACRO(x) - -void test2(id p) { - RELEASE_MACRO(p); - RELEASE_MACRO2(p); -} diff --git clang/test/ARCMT/releases-driver.m.result clang/test/ARCMT/releases-driver.m.result deleted file mode 100644 index e7da9a04fc62..000000000000 --- clang/test/ARCMT/releases-driver.m.result +++ /dev/null @@ -1,58 +0,0 @@ -// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: cat %s > %t -// RUN: %clang_cc1 -arcmt-action=modify -triple x86_64-apple-macosx10.6 -x objective-c %t -// RUN: diff %t %s.result -// RUN: rm %t - -typedef int BOOL; - -id IhaveSideEffect(void); - -@protocol NSObject -- (BOOL)isEqual:(id)object; -- (id)retain; -- (oneway void)release; -@end - -@interface NSObject <NSObject> {} -@end - -@interface Foo : NSObject { - id bar; -} -@property (strong) id bar; --(void)test:(id)obj; -@end - -@implementation Foo - -@synthesize bar; - --(void)test:(id)obj { - id x = self.bar; - self.bar = obj; - // do stuff with x; - - IhaveSideEffect(); - - x = 0; -} - -@end - -void func(Foo *p) { -} - -@interface Baz { - id <NSObject> _foo; -} -@end - -@implementation Baz -@end - -#define RELEASE_MACRO(x) [x release] -#define RELEASE_MACRO2(x) RELEASE_MACRO(x) - -void test2(id p) { -} diff --git clang/test/ARCMT/releases.m clang/test/ARCMT/releases.m deleted file mode 100644 index 8636a8a5acea..000000000000 --- clang/test/ARCMT/releases.m +++ /dev/null @@ -1,98 +0,0 @@ -// RUN: %clang_cc1 -fobjc-exceptions -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fobjc-exceptions -fblocks -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#define nil 0 - -typedef int BOOL; - -id IhaveSideEffect(void); - -@protocol NSObject -- (BOOL)isEqual:(id)object; -- (id)retain; -- (oneway void)release; -@end - -@interface NSObject <NSObject> {} -@end - -@interface Foo : NSObject { - id bar; -} -@property (retain) id bar; --(void)test:(id)obj; -@end - -@implementation Foo - -@synthesize bar; - --(void)test:(id)obj { - id x = self.bar; - [x retain]; - self.bar = obj; - // do stuff with x; - [x release]; - - [IhaveSideEffect() release]; - - [x release], x = 0; - - @try { - } @finally { - [x release]; - } -} - -@end - -void func(Foo *p) { - [p release]; - (([p release])); -} - -@interface Baz { - id <NSObject> _foo; -} -@end - -@implementation Baz -- (void) dealloc { - [_foo release]; -} -@end - -void block_test(Foo *p) { - id (^B)(void) = ^(void) { - if (p) { - id (^IB)(void) = ^(void) { - id bar = [p retain]; - [p release]; - return bar; - }; - IB(); - } - return [p retain]; - }; -} - -#define RELEASE_MACRO(x) [x release] -#define RELEASE_MACRO2(x) RELEASE_MACRO(x) - -void test2(id p) { - RELEASE_MACRO(p); - RELEASE_MACRO2(p); -} - -@implementation Foo2 - -static id internal_var = 0; - -+ (void)setIt:(id)newone { - if (internal_var != newone) { - [internal_var release]; - internal_var = [newone retain]; - } -} -@end diff --git clang/test/ARCMT/releases.m.result clang/test/ARCMT/releases.m.result deleted file mode 100644 index 261175362b9b..000000000000 --- clang/test/ARCMT/releases.m.result +++ /dev/null @@ -1,87 +0,0 @@ -// RUN: %clang_cc1 -fobjc-exceptions -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fobjc-exceptions -fblocks -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#define nil 0 - -typedef int BOOL; - -id IhaveSideEffect(void); - -@protocol NSObject -- (BOOL)isEqual:(id)object; -- (id)retain; -- (oneway void)release; -@end - -@interface NSObject <NSObject> {} -@end - -@interface Foo : NSObject { - id bar; -} -@property (strong) id bar; --(void)test:(id)obj; -@end - -@implementation Foo - -@synthesize bar; - --(void)test:(id)obj { - id x = self.bar; - self.bar = obj; - // do stuff with x; - - IhaveSideEffect(); - - x = 0; - - @try { - } @finally { - x = nil; - } -} - -@end - -void func(Foo *p) { -} - -@interface Baz { - id <NSObject> _foo; -} -@end - -@implementation Baz -@end - -void block_test(Foo *p) { - id (^B)(void) = ^(void) { - if (p) { - id (^IB)(void) = ^(void) { - id bar = p; - return bar; - }; - IB(); - } - return p; - }; -} - -#define RELEASE_MACRO(x) [x release] -#define RELEASE_MACRO2(x) RELEASE_MACRO(x) - -void test2(id p) { -} - -@implementation Foo2 - -static id internal_var = 0; - -+ (void)setIt:(id)newone { - if (internal_var != newone) { - internal_var = newone; - } -} -@end diff --git clang/test/ARCMT/remap-applying.c clang/test/ARCMT/remap-applying.c deleted file mode 100644 index dee2e391d5bd..000000000000 --- clang/test/ARCMT/remap-applying.c +++ /dev/null @@ -1,4 +0,0 @@ -a bc - -// RUN: echo "[{\"file\": \"%/s\", \"offset\": 1, \"remove\": 2, }]" > %t.remap -// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result diff --git clang/test/ARCMT/remap-applying.c.result clang/test/ARCMT/remap-applying.c.result deleted file mode 100644 index 514e9c264915..000000000000 --- clang/test/ARCMT/remap-applying.c.result +++ /dev/null @@ -1,4 +0,0 @@ -ac - -// RUN: echo "[{\"file\": \"%/s\", \"offset\": 1, \"remove\": 2, }]" > %t.remap -// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result diff --git clang/test/ARCMT/remove-dealloc-method.m clang/test/ARCMT/remove-dealloc-method.m deleted file mode 100644 index 8e39fc874c95..000000000000 --- clang/test/ARCMT/remove-dealloc-method.m +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#define nil ((void*) 0) - -@interface Foo -@property (retain) id x; -@property (retain) id y; -@property (retain) id w; -@property (retain) id z; -@end - -@implementation Foo -@synthesize x; -@synthesize y; -@synthesize w; -@synthesize z; - -- (void) dealloc { - self.x = 0; - [self setY:nil]; - w = nil; - self.z = nil; -} -@end diff --git clang/test/ARCMT/remove-dealloc-method.m.result clang/test/ARCMT/remove-dealloc-method.m.result deleted file mode 100644 index 47e31f9d249a..000000000000 --- clang/test/ARCMT/remove-dealloc-method.m.result +++ /dev/null @@ -1,20 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#define nil ((void*) 0) - -@interface Foo -@property (strong) id x; -@property (strong) id y; -@property (strong) id w; -@property (strong) id z; -@end - -@implementation Foo -@synthesize x; -@synthesize y; -@synthesize w; -@synthesize z; - -@end diff --git clang/test/ARCMT/remove-dealloc-zerouts.m clang/test/ARCMT/remove-dealloc-zerouts.m deleted file mode 100644 index 4176ec580c3e..000000000000 --- clang/test/ARCMT/remove-dealloc-zerouts.m +++ /dev/null @@ -1,44 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -@interface Foo -@property (retain) id x; -@property (retain) id y; -@property (retain) id w; -@property (retain) id z; -@property (strong) id q; -@end - -@implementation Foo -@synthesize x; -@synthesize y; -@synthesize w; -@synthesize q; -@dynamic z; - -- (void) dealloc { - self.x = self.y = self.w = 0; - self.x = 0, w = 0, y = 0; - [self setY:0]; - w = 0; - q = 0; - self.z = 0; -} -@end - -@interface Bar -@property (retain) Foo *a; -- (void) setA:(Foo*) val; -- (id) a; -@end - -@implementation Bar -- (void) dealloc { - [self setA:0]; // This is user-defined setter overriding synthesize, don't touch it. - self.a.x = 0; // every dealloc must zero out its own ivar. This patter is not recognized. -} -@synthesize a; -- (void) setA:(Foo*) val { } -- (id) a {return 0;} -@end diff --git clang/test/ARCMT/remove-dealloc-zerouts.m.result clang/test/ARCMT/remove-dealloc-zerouts.m.result deleted file mode 100644 index 9ae831abacf2..000000000000 --- clang/test/ARCMT/remove-dealloc-zerouts.m.result +++ /dev/null @@ -1,39 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -@interface Foo -@property (strong) id x; -@property (strong) id y; -@property (strong) id w; -@property (strong) id z; -@property (strong) id q; -@end - -@implementation Foo -@synthesize x; -@synthesize y; -@synthesize w; -@synthesize q; -@dynamic z; - -- (void) dealloc { - self.z = 0; -} -@end - -@interface Bar -@property (strong) Foo *a; -- (void) setA:(Foo*) val; -- (id) a; -@end - -@implementation Bar -- (void) dealloc { - [self setA:0]; // This is user-defined setter overriding synthesize, don't touch it. - self.a.x = 0; // every dealloc must zero out its own ivar. This patter is not recognized. -} -@synthesize a; -- (void) setA:(Foo*) val { } -- (id) a {return 0;} -@end diff --git clang/test/ARCMT/remove-statements.m clang/test/ARCMT/remove-statements.m deleted file mode 100644 index 286a8e715e0d..000000000000 --- clang/test/ARCMT/remove-statements.m +++ /dev/null @@ -1,45 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -@interface myController : NSObject --(id)test:(id)x; -@end - -#define MY_MACRO1(x) -#define MY_MACRO2(x) (void)x - -@implementation myController --(id) test:(id) x { - [[x retain] release]; - return [[x retain] autorelease]; -} - --(void)dealloc -{ - id array, array_already_empty; - for (id element in array_already_empty) { - } - - [array release]; - ; - - int b, b_array_already_empty; - if (b) - [array release]; - if (b_array_already_empty) ; - - if (b) { - [array release]; - } - if (b_array_already_empty) { - } - - if (b) - MY_MACRO1(array); - if (b) - MY_MACRO2(array); -} -@end diff --git clang/test/ARCMT/remove-statements.m.result clang/test/ARCMT/remove-statements.m.result deleted file mode 100644 index 6a4ea08b8c95..000000000000 --- clang/test/ARCMT/remove-statements.m.result +++ /dev/null @@ -1,38 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -@interface myController : NSObject --(id)test:(id)x; -@end - -#define MY_MACRO1(x) -#define MY_MACRO2(x) (void)x - -@implementation myController --(id) test:(id) x { - return x; -} - --(void)dealloc -{ - id array, array_already_empty; - for (id element in array_already_empty) { - } - - ; - - int b, b_array_already_empty; - if (b_array_already_empty) ; - - if (b_array_already_empty) { - } - - if (b) - MY_MACRO1(array); - if (b) - MY_MACRO2(array); -} -@end diff --git clang/test/ARCMT/retains.m clang/test/ARCMT/retains.m deleted file mode 100644 index a38efe159640..000000000000 --- clang/test/ARCMT/retains.m +++ /dev/null @@ -1,71 +0,0 @@ -// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -id IhaveSideEffect(void); - -@interface Foo : NSObject { - id bar; -} -@property (retain) id bar; --(id)test:(id)obj; --(id)something; -@end - -#define Something_Macro(key, comment) \ - [[Foo new] something] - -@implementation Foo - -@synthesize bar; - --(id)something { return (id)0; } - --(id)test:(id)obj { - id x = self.bar; - [x retain]; - self.bar = obj; - if (obj) - [obj retain]; - - [Something_Macro(@"foo", "@bar") retain]; - - [IhaveSideEffect() retain]; - - [[self something] retain]; - - [[self retain] something]; - - [[IhaveSideEffect() retain] release]; - [[x retain] release]; - // do stuff with x; - [x release]; - return [self retain]; -} - -- (id)test1 { - id x=0; - ([x retain]); - return ((([x retain]))); -} -@end - -id foo (Foo *p) { - p = [p retain]; - return ([p retain]); -} - -void block_tests(Foo *p) { - id (^B)(void) = ^(void) { - if (p) { - id (^IB)(void) = ^(void) { - id bar = [p retain]; - return bar; - }; - IB(); - } - return [p retain]; - }; -} diff --git clang/test/ARCMT/retains.m.result clang/test/ARCMT/retains.m.result deleted file mode 100644 index cd3bb3848fce..000000000000 --- clang/test/ARCMT/retains.m.result +++ /dev/null @@ -1,65 +0,0 @@ -// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -id IhaveSideEffect(void); - -@interface Foo : NSObject { - id bar; -} -@property (strong) id bar; --(id)test:(id)obj; --(id)something; -@end - -#define Something_Macro(key, comment) \ - [[Foo new] something] - -@implementation Foo - -@synthesize bar; - --(id)something { return (id)0; } - --(id)test:(id)obj { - id x = self.bar; - self.bar = obj; - - Something_Macro(@"foo", "@bar"); - - IhaveSideEffect(); - - [self something]; - - [self something]; - - IhaveSideEffect(); - // do stuff with x; - return self; -} - -- (id)test1 { - id x=0; - return (((x))); -} -@end - -id foo (Foo *p) { - p = p; - return (p); -} - -void block_tests(Foo *p) { - id (^B)(void) = ^(void) { - if (p) { - id (^IB)(void) = ^(void) { - id bar = p; - return bar; - }; - IB(); - } - return p; - }; -} diff --git clang/test/ARCMT/rewrite-block-var.m clang/test/ARCMT/rewrite-block-var.m deleted file mode 100644 index eb3c5b653597..000000000000 --- clang/test/ARCMT/rewrite-block-var.m +++ /dev/null @@ -1,45 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -fobjc-arc -x objective-c -fobjc-runtime-has-weak %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fblocks -fsyntax-only %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -@interface Foo : NSObject --(Foo *)something; -@end - -void bar(void (^block)(void)); - -void test1(Foo *p) { - __block Foo *x = p; // __block used just to break cycle. - bar(^{ - [x something]; - }); -} - -void test2(Foo *p) { - __block Foo *x; // __block used as output variable. - bar(^{ - x = [p something]; - }); -} - -void test3(Foo *p) { - __block Foo *x; // __block used as output variable. - bar(^{ - [x something]; - }); - bar(^{ - x = 0; - }); -} - -void test4(Foo *p) { - __block Foo *x = p; // __block used just to break cycle. - bar(^{ - [x something]; - }); - bar(^{ - [x something]; - }); -} diff --git clang/test/ARCMT/rewrite-block-var.m.result clang/test/ARCMT/rewrite-block-var.m.result deleted file mode 100644 index cf5718fbd7f5..000000000000 --- clang/test/ARCMT/rewrite-block-var.m.result +++ /dev/null @@ -1,45 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -fobjc-arc -x objective-c -fobjc-runtime-has-weak %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fblocks -fsyntax-only %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -@interface Foo : NSObject --(Foo *)something; -@end - -void bar(void (^block)(void)); - -void test1(Foo *p) { - __weak Foo *x = p; // __block used just to break cycle. - bar(^{ - [x something]; - }); -} - -void test2(Foo *p) { - __block Foo *x; // __block used as output variable. - bar(^{ - x = [p something]; - }); -} - -void test3(Foo *p) { - __block Foo *x; // __block used as output variable. - bar(^{ - [x something]; - }); - bar(^{ - x = 0; - }); -} - -void test4(Foo *p) { - __weak Foo *x = p; // __block used just to break cycle. - bar(^{ - [x something]; - }); - bar(^{ - [x something]; - }); -} diff --git clang/test/ARCMT/safe-arc-assign.m clang/test/ARCMT/safe-arc-assign.m deleted file mode 100644 index 4a0a575794e1..000000000000 --- clang/test/ARCMT/safe-arc-assign.m +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -void test12(id collection) { - for (id x in collection) { - x = 0; - x = 0; - } - - for (__strong id x in collection) { - x = 0; - } -} diff --git clang/test/ARCMT/safe-arc-assign.m.result clang/test/ARCMT/safe-arc-assign.m.result deleted file mode 100644 index c25955ea7d1c..000000000000 --- clang/test/ARCMT/safe-arc-assign.m.result +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -void test12(id collection) { - for (__strong id x in collection) { - x = 0; - x = 0; - } - - for (__strong id x in collection) { - x = 0; - } -} diff --git clang/test/ARCMT/verify.m clang/test/ARCMT/verify.m deleted file mode 100644 index 7d245fe80575..000000000000 --- clang/test/ARCMT/verify.m +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %clang_cc1 -arcmt-action=check -verify %s -// RUN: not %clang_cc1 -arcmt-action=check -verify %t.invalid 2>&1 | FileCheck %s - -#if 0 -// expected-error {{should be ignored}} -#endif - -#error should not be ignored -// expected-error@-1 {{should not be ignored}} - -#error -// expected-error@-1 {{}} - -// CHECK: error: no expected directives found: consider use of 'expected-no-diagnostics' -// CHECK-NEXT: error: 'expected-error' diagnostics seen but not expected: -// CHECK-NEXT: (frontend): error reading '{{.*}}verify.m.tmp.invalid' -// CHECK-NEXT: 2 errors generated. diff --git clang/test/ARCMT/with-arc-mode-modify.m clang/test/ARCMT/with-arc-mode-modify.m deleted file mode 100644 index beff6784bbbb..000000000000 --- clang/test/ARCMT/with-arc-mode-modify.m +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: cat %s > %t -// RUN: %clang_cc1 -arcmt-action=modify -fsyntax-only -fobjc-arc -x objective-c %t -// RUN: diff %t %s.result -// RUN: rm %t - -@protocol NSObject -- (oneway void)release; -@end - -void test1(id p) { - [p release]; -} diff --git clang/test/ARCMT/with-arc-mode-modify.m.result clang/test/ARCMT/with-arc-mode-modify.m.result deleted file mode 100644 index 685226db8654..000000000000 --- clang/test/ARCMT/with-arc-mode-modify.m.result +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: cat %s > %t -// RUN: %clang_cc1 -arcmt-action=modify -fsyntax-only -fobjc-arc -x objective-c %t -// RUN: diff %t %s.result -// RUN: rm %t - -@protocol NSObject -- (oneway void)release; -@end - -void test1(id p) { -} diff --git clang/test/AST/ByteCode/cxx2a.cpp clang/test/AST/ByteCode/cxx2a.cpp index e478a0ddc4c1..72ef58ca0b1d 100644 --- clang/test/AST/ByteCode/cxx2a.cpp +++ clang/test/AST/ByteCode/cxx2a.cpp @@ -139,9 +139,7 @@ namespace TypeId { static_assert(&B2().ti1 == &typeid(B)); static_assert(&B2().ti2 == &typeid(B2)); extern B2 extern_b2; - static_assert(&typeid(extern_b2) == &typeid(B2)); // expected-error {{constant expression}} \ - // expected-note{{typeid applied to object 'extern_b2' whose dynamic type is not constant}} - + static_assert(&typeid(extern_b2) == &typeid(B2)); constexpr B2 b2; constexpr const B &b1 = b2; @@ -170,3 +168,12 @@ namespace TypeId { } static_assert(side_effects()); } + +consteval int f(int i); +constexpr bool test(auto i) { + return f(0) == 0; +} +consteval int f(int i) { + return 2 * i; +} +static_assert(test(42)); diff --git clang/test/AST/ByteCode/neon.c clang/test/AST/ByteCode/neon.c new file mode 100644 index 000000000000..5905d7808603 --- /dev/null +++ clang/test/AST/ByteCode/neon.c @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon -disable-O0-optnone -emit-llvm -o - %s -fexperimental-new-constant-interpreter + +// REQUIRES: aarch64-registered-target + +/// This just tests that we're not crashing with a non-primitive vector element type. + +typedef __mfp8 mfloat8_t; +typedef __bf16 bfloat16_t; + +typedef __attribute__((neon_vector_type(8))) mfloat8_t mfloat8x8_t; +typedef __attribute__((neon_vector_type(8))) bfloat16_t bfloat16x8_t; + +typedef __UINT64_TYPE__ fpm_t; +#define __ai static __inline__ __attribute__((__always_inline__, __nodebug__)) +__ai __attribute__((target("fp8,neon"))) bfloat16x8_t vcvt1_bf16_mf8_fpm(mfloat8x8_t __p0, fpm_t __p1) { + bfloat16x8_t __ret; + __ret = (bfloat16x8_t) __builtin_neon_vcvt1_bf16_mf8_fpm(__p0, __p1); + return __ret; +} diff --git clang/test/AST/HLSL/StructuredBuffers-AST.hlsl clang/test/AST/HLSL/StructuredBuffers-AST.hlsl index db3f2d405e68..11be67d45a14 100644 --- clang/test/AST/HLSL/StructuredBuffers-AST.hlsl +++ clang/test/AST/HLSL/StructuredBuffers-AST.hlsl @@ -1,222 +1,222 @@ -// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \ -// RUN: -DRESOURCE=StructuredBuffer %s | FileCheck -DRESOURCE=StructuredBuffer \ -// RUN: -check-prefix=EMPTY %s -// -// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \ -// RUN: -DRESOURCE=StructuredBuffer %s | FileCheck -DRESOURCE=StructuredBuffer \ -// RUN: -check-prefixes=CHECK,CHECK-SRV,CHECK-SUBSCRIPT,CHECK-LOAD %s -// -// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \ -// RUN: -DRESOURCE=RWStructuredBuffer %s | FileCheck -DRESOURCE=RWStructuredBuffer \ -// RUN: -check-prefix=EMPTY %s -// -// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \ -// RUN: -DRESOURCE=RWStructuredBuffer %s | FileCheck -DRESOURCE=RWStructuredBuffer \ -// RUN: -check-prefixes=CHECK,CHECK-UAV,CHECK-SUBSCRIPT,CHECK-COUNTER,CHECK-LOAD %s -// -// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \ -// RUN: -DRESOURCE=AppendStructuredBuffer %s | FileCheck -DRESOURCE=AppendStructuredBuffer \ -// RUN: -check-prefix=EMPTY %s -// -// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \ -// RUN: -DRESOURCE=AppendStructuredBuffer %s | FileCheck -DRESOURCE=AppendStructuredBuffer \ -// RUN: -check-prefixes=CHECK,CHECK-UAV,CHECK-NOSUBSCRIPT,CHECK-APPEND %s -// -// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \ -// RUN: -DRESOURCE=ConsumeStructuredBuffer %s | FileCheck -DRESOURCE=ConsumeStructuredBuffer \ -// RUN: -check-prefix=EMPTY %s -// -// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \ -// RUN: -DRESOURCE=ConsumeStructuredBuffer %s | FileCheck -DRESOURCE=ConsumeStructuredBuffer \ -// RUN: -check-prefixes=CHECK,CHECK-UAV,CHECK-NOSUBSCRIPT,CHECK-CONSUME %s -// -// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \ -// RUN: -DRESOURCE=RasterizerOrderedStructuredBuffer %s | FileCheck -DRESOURCE=RasterizerOrderedStructuredBuffer \ -// RUN: -check-prefix=EMPTY %s -// -// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \ -// RUN: -DRESOURCE=RasterizerOrderedStructuredBuffer %s | FileCheck -DRESOURCE=RasterizerOrderedStructuredBuffer \ -// RUN: -check-prefixes=CHECK,CHECK-UAV,CHECK-ROV,CHECK-SUBSCRIPT,CHECK-LOAD %s - -// This test tests two different AST generations for each structured buffer. -// The "EMPTY" test mode verifies the AST generated by forward declaration -// of the HLSL types which happens on initializing the HLSL external AST with -// an AST Context. - -// The non-empty mode has a use that requires the resource type be complete, -// which results in the AST being populated by the external AST source. That -// case covers the full implementation of the template declaration and the -// instantiated specialization. - -// EMPTY: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit [[RESOURCE]] -// EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> typename depth 0 index 0 element_type -// EMPTY-NEXT: ConceptSpecializationExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'bool' Concept 0x{{[0-9A-Fa-f]+}} '__is_structured_resource_element_compatible' -// EMPTY-NEXT: ImplicitConceptSpecializationDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> -// EMPTY-NEXT: TemplateArgument type 'type-parameter-0-0' -// EMPTY-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-0' dependent depth 0 index 0 -// EMPTY-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} '' -// EMPTY-NEXT: TemplateArgument type 'element_type':'type-parameter-0-0' -// EMPTY-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'element_type' dependent depth 0 index 0 -// EMPTY-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'element_type' -// EMPTY-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit <undeserialized declarations> class [[RESOURCE]] -// EMPTY-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final - -// There should be no more occurrences of [[RESOURCE]] -// EMPTY-NOT: {{[^[:alnum:]]}}[[RESOURCE]] - -#ifndef EMPTY - -RESOURCE<float> Buffer; - -#endif - -// CHECK: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit [[RESOURCE]] -// CHECK-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> typename depth 0 index 0 element_type -// CHECK-NEXT: ConceptSpecializationExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'bool' Concept 0x{{[0-9A-Fa-f]+}} '__is_structured_resource_element_compatible' -// CHECK-NEXT: ImplicitConceptSpecializationDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> -// CHECK-NEXT: TemplateArgument type 'type-parameter-0-0' -// CHECK-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-0' dependent depth 0 index 0 -// CHECK-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} '' -// CHECK-NEXT: TemplateArgument type 'element_type':'type-parameter-0-0' -// CHECK-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'element_type' dependent depth 0 index 0 -// CHECK-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'element_type' -// CHECK-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit class [[RESOURCE]] definition - -// CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final -// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit __handle '__hlsl_resource_t -// CHECK-SRV-SAME{LITERAL}: [[hlsl::resource_class(SRV)]] -// CHECK-UAV-SAME{LITERAL}: [[hlsl::resource_class(UAV)]] -// CHECK-SAME{LITERAL}: [[hlsl::raw_buffer]] -// CHECK-SAME{LITERAL}: [[hlsl::contained_type(element_type)]] -// CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit RawBuffer - -// CHECK-SUBSCRIPT: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> operator[] 'const element_type &(unsigned int) const' -// CHECK-SUBSCRIPT-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> Index 'unsigned int' -// CHECK-SUBSCRIPT-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> -// CHECK-SUBSCRIPT-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> -// CHECK-SUBSCRIPT-NEXT: UnaryOperator 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' prefix '*' cannot overflow -// CHECK-SUBSCRIPT-NEXT: CallExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type *' -// CHECK-SUBSCRIPT-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '<builtin fn type>' Function 0x{{[0-9A-Fa-f]+}} '__builtin_hlsl_resource_getpointer' 'void (...) noexcept' -// CHECK-SUBSCRIPT-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '__hlsl_resource_t -// CHECK-SUBSCRIPT-SAME{LITERAL}: [[hlsl::resource_class( -// CHECK-SUBSCRIPT-SAME{LITERAL}: [[hlsl::raw_buffer]] -// CHECK-SUBSCRIPT-SAME{LITERAL}: [[hlsl::contained_type(element_type)]] -// CHECK-SUBSCRIPT-SAME: ' lvalue .__handle 0x{{[0-9A-Fa-f]+}} -// CHECK-SUBSCRIPT-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'const [[RESOURCE]]<element_type>' lvalue implicit this -// CHECK-SUBSCRIPT-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'unsigned int' ParmVar 0x{{[0-9A-Fa-f]+}} 'Index' 'unsigned int' -// CHECK-SUBSCRIPT-NEXT: AlwaysInlineAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit always_inline - -// CHECK-SUBSCRIPT-NEXT: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> operator[] 'element_type &(unsigned int)' -// CHECK-SUBSCRIPT-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> Index 'unsigned int' -// CHECK-SUBSCRIPT-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> -// CHECK-SUBSCRIPT-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> -// CHECK-SUBSCRIPT-NEXT: UnaryOperator 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' prefix '*' cannot overflow -// CHECK-SUBSCRIPT-NEXT: CallExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type *' -// CHECK-SUBSCRIPT-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '<builtin fn type>' Function 0x{{[0-9A-Fa-f]+}} '__builtin_hlsl_resource_getpointer' 'void (...) noexcept' -// CHECK-SUBSCRIPT-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '__hlsl_resource_t -// CHECK-SUBSCRIPT-SAME{LITERAL}: [[hlsl::resource_class( -// CHECK-SUBSCRIPT-SAME{LITERAL}: [[hlsl::raw_buffer]] -// CHECK-SUBSCRIPT-SAME{LITERAL}: [[hlsl::contained_type(element_type)]] -// CHECK-SUBSCRIPT-SAME: ' lvalue .__handle 0x{{[0-9A-Fa-f]+}} -// CHECK-SUBSCRIPT-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '[[RESOURCE]]<element_type>' lvalue implicit this -// CHECK-SUBSCRIPT-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'unsigned int' ParmVar 0x{{[0-9A-Fa-f]+}} 'Index' 'unsigned int' -// CHECK-SUBSCRIPT-NEXT: AlwaysInlineAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit always_inline - -// CHECK-NOSUBSCRIPT-NOT: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> operator[] 'const element_type &(unsigned int) const' -// CHECK-NOSUBSCRIPT-NOT: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> operator[] 'element_type &(unsigned int)' - -// CHECK-LOAD: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> Load 'element_type (unsigned int)' -// CHECK-LOAD-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> Index 'unsigned int' -// CHECK-LOAD-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> -// CHECK-LOAD-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> -// CHECK-LOAD-NEXT: UnaryOperator 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' prefix '*' cannot overflow -// CHECK-LOAD-NEXT: CallExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type *' -// CHECK-LOAD-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '<builtin fn type>' Function 0x{{[0-9A-Fa-f]+}} '__builtin_hlsl_resource_getpointer' 'void (...) noexcept' -// CHECK-LOAD-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '__hlsl_resource_t -// CHECK-LOAD-SAME{LITERAL}: [[hlsl::resource_class( -// CHECK-LOAD-SAME{LITERAL}: [[hlsl::contained_type(element_type)]] -// CHECK-LOAD-SAME: ' lvalue .__handle 0x{{[0-9A-Fa-f]+}} -// CHECK-LOAD-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '[[RESOURCE]]<element_type>' lvalue implicit this -// CHECK-LOAD-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'unsigned int' ParmVar 0x{{[0-9A-Fa-f]+}} 'Index' 'unsigned int' -// CHECK-LOAD-NEXT: AlwaysInlineAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit always_inline - -// CHECK-COUNTER: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> IncrementCounter 'unsigned int ()' -// CHECK-COUNTER-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> -// CHECK-COUNTER-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> -// CHECK-COUNTER-NEXT: CallExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'unsigned int' -// CHECK-COUNTER-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '<builtin fn type>' Function 0x{{[0-9A-Fa-f]+}} '__builtin_hlsl_buffer_update_counter' 'unsigned int (...) noexcept' -// CHECK-COUNTER-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '__hlsl_resource_t -// CHECK-COUNTER-SAME{LITERAL}: [[hlsl::resource_class(UAV)]] -// CHECK-COUNTER-SAME{LITERAL}: [[hlsl::raw_buffer]] -// CHECK-COUNTER-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]' lvalue .__handle -// CHECK-COUNTER-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'RWStructuredBuffer<element_type>' lvalue implicit this -// CHECK-COUNTER-NEXT: IntegerLiteral 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'int' 1 -// CHECK-COUNTER-NEXT: AlwaysInlineAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit always_inline - -// CHECK-COUNTER-NEXT: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> DecrementCounter 'unsigned int ()' -// CHECK-COUNTER-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> -// CHECK-COUNTER-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> -// CHECK-COUNTER-NEXT: CallExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'unsigned int' -// CHECK-COUNTER-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '<builtin fn type>' Function 0x{{[0-9A-Fa-f]+}} '__builtin_hlsl_buffer_update_counter' 'unsigned int (...) noexcept' -// CHECK-COUNTER-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '__hlsl_resource_t -// CHECK-COUNTER-SAME{LITERAL}: [[hlsl::resource_class(UAV)]] -// CHECK-COUNTER-SAME{LITERAL}: [[hlsl::raw_buffer]] -// CHECK-COUNTER-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]' lvalue .__handle -// CHECK-COUNTER-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'RWStructuredBuffer<element_type>' lvalue implicit this -// CHECK-COUNTER-NEXT: IntegerLiteral 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'int' -1 -// CHECK-COUNTER-NEXT: AlwaysInlineAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit always_inline - -// CHECK-APPEND: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> Append 'void (element_type)' -// CHECK-APPEND-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> value 'element_type' -// CHECK-APPEND-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> -// CHECK-APPEND-NEXT: BinaryOperator 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' '=' -// CHECK-APPEND-NEXT: UnaryOperator 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' prefix '*' cannot overflow -// CHECK-APPEND-NEXT: CallExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type *' -// CHECK-APPEND-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '<builtin fn type>' Function 0x{{[0-9A-Fa-f]+}} '__builtin_hlsl_resource_getpointer' 'void (...) noexcept' -// CHECK-APPEND-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '__hlsl_resource_t -// CHECK-APPEND-SAME{LITERAL}: [[hlsl::resource_class(UAV)]] -// CHECK-APPEND-SAME{LITERAL}: [[hlsl::raw_buffer]] -// CHECK-APPEND-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]' lvalue .__handle -// CHECK-APPEND-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '[[RESOURCE]]<element_type>' lvalue implicit this -// CHECK-APPEND-NEXT: CallExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'unsigned int' -// CHECK-APPEND-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '<builtin fn type>' Function 0x{{[0-9A-Fa-f]+}} '__builtin_hlsl_buffer_update_counter' 'unsigned int (...) noexcept' -// CHECK-APPEND-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '__hlsl_resource_t -// CHECK-APPEND-SAME{LITERAL}: [[hlsl::resource_class(UAV)]] -// CHECK-APPEND-SAME{LITERAL}: [[hlsl::raw_buffer]] -// CHECK-APPEND-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]' lvalue .__handle -// CHECK-APPEND-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '[[RESOURCE]]<element_type>' lvalue implicit this -// CHECK-APPEND-NEXT: IntegerLiteral 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'int' 1 -// CHECK-APPEND-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' ParmVar 0x{{[0-9A-Fa-f]+}} 'value' 'element_type' - -// CHECK-CONSUME: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> Consume 'element_type ()' -// CHECK-CONSUME-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> -// CHECK-CONSUME-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> -// CHECK-CONSUME-NEXT: UnaryOperator 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' prefix '*' cannot overflow -// CHECK-CONSUME-NEXT: CallExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type *' -// CHECK-CONSUME-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '<builtin fn type>' Function 0x{{[0-9A-Fa-f]+}} '__builtin_hlsl_resource_getpointer' 'void (...) noexcept' -// CHECK-CONSUME-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '__hlsl_resource_t -// CHECK-CONSUME-SAME{LITERAL}: [[hlsl::resource_class(UAV)]] -// CHECK-CONSUME-SAME{LITERAL}: [[hlsl::raw_buffer]] -// CHECK-CONSUME-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]' lvalue .__handle -// CHECK-CONSUME-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '[[RESOURCE]]<element_type>' lvalue implicit this -// CHECK-CONSUME-NEXT: CallExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'unsigned int' -// CHECK-CONSUME-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '<builtin fn type>' Function 0x{{[0-9A-Fa-f]+}} '__builtin_hlsl_buffer_update_counter' 'unsigned int (...) noexcept' -// CHECK-CONSUME-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '__hlsl_resource_t -// CHECK-CONSUME-SAME{LITERAL}: [[hlsl::resource_class(UAV)]] -// CHECK-CONSUME-SAME{LITERAL}: [[hlsl::raw_buffer]] -// CHECK-CONSUME-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]' lvalue .__handle -// CHECK-CONSUME-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '[[RESOURCE]]<element_type>' lvalue implicit this -// CHECK-CONSUME-NEXT: IntegerLiteral 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'int' -1 - -// CHECK: ClassTemplateSpecializationDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> class [[RESOURCE]] definition - -// CHECK: TemplateArgument type 'float' -// CHECK-NEXT: BuiltinType 0x{{[0-9A-Fa-f]+}} 'float' -// CHECK-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final -// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit __handle '__hlsl_resource_t -// CHECK-SRV-SAME{LITERAL}: [[hlsl::resource_class(SRV)]] -// CHECK-UAV-SAME{LITERAL}: [[hlsl::resource_class(UAV)]] -// CHECK-ROV-SAME{LITERAL}: [[hlsl::is_rov]] -// CHECK-SAME{LITERAL}: [[hlsl::raw_buffer]] -// CHECK-SAME{LITERAL}: [[hlsl::contained_type(float)]] -// CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit RawBuffer +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \ +// RUN: -DRESOURCE=StructuredBuffer %s | FileCheck -DRESOURCE=StructuredBuffer \ +// RUN: -check-prefix=EMPTY %s +// +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \ +// RUN: -DRESOURCE=StructuredBuffer %s | FileCheck -DRESOURCE=StructuredBuffer \ +// RUN: -check-prefixes=CHECK,CHECK-SRV,CHECK-SUBSCRIPT,CHECK-LOAD %s +// +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \ +// RUN: -DRESOURCE=RWStructuredBuffer %s | FileCheck -DRESOURCE=RWStructuredBuffer \ +// RUN: -check-prefix=EMPTY %s +// +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \ +// RUN: -DRESOURCE=RWStructuredBuffer %s | FileCheck -DRESOURCE=RWStructuredBuffer \ +// RUN: -check-prefixes=CHECK,CHECK-UAV,CHECK-SUBSCRIPT,CHECK-COUNTER,CHECK-LOAD %s +// +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \ +// RUN: -DRESOURCE=AppendStructuredBuffer %s | FileCheck -DRESOURCE=AppendStructuredBuffer \ +// RUN: -check-prefix=EMPTY %s +// +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \ +// RUN: -DRESOURCE=AppendStructuredBuffer %s | FileCheck -DRESOURCE=AppendStructuredBuffer \ +// RUN: -check-prefixes=CHECK,CHECK-UAV,CHECK-NOSUBSCRIPT,CHECK-APPEND %s +// +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \ +// RUN: -DRESOURCE=ConsumeStructuredBuffer %s | FileCheck -DRESOURCE=ConsumeStructuredBuffer \ +// RUN: -check-prefix=EMPTY %s +// +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \ +// RUN: -DRESOURCE=ConsumeStructuredBuffer %s | FileCheck -DRESOURCE=ConsumeStructuredBuffer \ +// RUN: -check-prefixes=CHECK,CHECK-UAV,CHECK-NOSUBSCRIPT,CHECK-CONSUME %s +// +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \ +// RUN: -DRESOURCE=RasterizerOrderedStructuredBuffer %s | FileCheck -DRESOURCE=RasterizerOrderedStructuredBuffer \ +// RUN: -check-prefix=EMPTY %s +// +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \ +// RUN: -DRESOURCE=RasterizerOrderedStructuredBuffer %s | FileCheck -DRESOURCE=RasterizerOrderedStructuredBuffer \ +// RUN: -check-prefixes=CHECK,CHECK-UAV,CHECK-ROV,CHECK-SUBSCRIPT,CHECK-LOAD %s + +// This test tests two different AST generations for each structured buffer. +// The "EMPTY" test mode verifies the AST generated by forward declaration +// of the HLSL types which happens on initializing the HLSL external AST with +// an AST Context. + +// The non-empty mode has a use that requires the resource type be complete, +// which results in the AST being populated by the external AST source. That +// case covers the full implementation of the template declaration and the +// instantiated specialization. + +// EMPTY: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit [[RESOURCE]] +// EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> typename depth 0 index 0 element_type +// EMPTY-NEXT: ConceptSpecializationExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'bool' Concept 0x{{[0-9A-Fa-f]+}} '__is_structured_resource_element_compatible' +// EMPTY-NEXT: ImplicitConceptSpecializationDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> +// EMPTY-NEXT: TemplateArgument type 'type-parameter-0-0' +// EMPTY-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-0' dependent depth 0 index 0 +// EMPTY-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} depth 0 index 0 +// EMPTY-NEXT: TemplateArgument type 'element_type':'type-parameter-0-0' +// EMPTY-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'element_type' dependent depth 0 index 0 +// EMPTY-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'element_type' +// EMPTY-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit <undeserialized declarations> class [[RESOURCE]] +// EMPTY-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final + +// There should be no more occurrences of [[RESOURCE]] +// EMPTY-NOT: {{[^[:alnum:]]}}[[RESOURCE]] + +#ifndef EMPTY + +RESOURCE<float> Buffer; + +#endif + +// CHECK: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit [[RESOURCE]] +// CHECK-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> typename depth 0 index 0 element_type +// CHECK-NEXT: ConceptSpecializationExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'bool' Concept 0x{{[0-9A-Fa-f]+}} '__is_structured_resource_element_compatible' +// CHECK-NEXT: ImplicitConceptSpecializationDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> +// CHECK-NEXT: TemplateArgument type 'type-parameter-0-0' +// CHECK-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-0' dependent depth 0 index 0 +// CHECK-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} depth 0 index 0 +// CHECK-NEXT: TemplateArgument type 'element_type':'type-parameter-0-0' +// CHECK-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'element_type' dependent depth 0 index 0 +// CHECK-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'element_type' +// CHECK-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit class [[RESOURCE]] definition + +// CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final +// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit __handle '__hlsl_resource_t +// CHECK-SRV-SAME{LITERAL}: [[hlsl::resource_class(SRV)]] +// CHECK-UAV-SAME{LITERAL}: [[hlsl::resource_class(UAV)]] +// CHECK-SAME{LITERAL}: [[hlsl::raw_buffer]] +// CHECK-SAME{LITERAL}: [[hlsl::contained_type(element_type)]] +// CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit RawBuffer + +// CHECK-SUBSCRIPT: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> operator[] 'const element_type &(unsigned int) const' +// CHECK-SUBSCRIPT-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> Index 'unsigned int' +// CHECK-SUBSCRIPT-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> +// CHECK-SUBSCRIPT-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> +// CHECK-SUBSCRIPT-NEXT: UnaryOperator 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' prefix '*' cannot overflow +// CHECK-SUBSCRIPT-NEXT: CallExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type *' +// CHECK-SUBSCRIPT-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '<builtin fn type>' Function 0x{{[0-9A-Fa-f]+}} '__builtin_hlsl_resource_getpointer' 'void (...) noexcept' +// CHECK-SUBSCRIPT-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '__hlsl_resource_t +// CHECK-SUBSCRIPT-SAME{LITERAL}: [[hlsl::resource_class( +// CHECK-SUBSCRIPT-SAME{LITERAL}: [[hlsl::raw_buffer]] +// CHECK-SUBSCRIPT-SAME{LITERAL}: [[hlsl::contained_type(element_type)]] +// CHECK-SUBSCRIPT-SAME: ' lvalue .__handle 0x{{[0-9A-Fa-f]+}} +// CHECK-SUBSCRIPT-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'const [[RESOURCE]]<element_type>' lvalue implicit this +// CHECK-SUBSCRIPT-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'unsigned int' ParmVar 0x{{[0-9A-Fa-f]+}} 'Index' 'unsigned int' +// CHECK-SUBSCRIPT-NEXT: AlwaysInlineAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit always_inline + +// CHECK-SUBSCRIPT-NEXT: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> operator[] 'element_type &(unsigned int)' +// CHECK-SUBSCRIPT-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> Index 'unsigned int' +// CHECK-SUBSCRIPT-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> +// CHECK-SUBSCRIPT-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> +// CHECK-SUBSCRIPT-NEXT: UnaryOperator 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' prefix '*' cannot overflow +// CHECK-SUBSCRIPT-NEXT: CallExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type *' +// CHECK-SUBSCRIPT-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '<builtin fn type>' Function 0x{{[0-9A-Fa-f]+}} '__builtin_hlsl_resource_getpointer' 'void (...) noexcept' +// CHECK-SUBSCRIPT-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '__hlsl_resource_t +// CHECK-SUBSCRIPT-SAME{LITERAL}: [[hlsl::resource_class( +// CHECK-SUBSCRIPT-SAME{LITERAL}: [[hlsl::raw_buffer]] +// CHECK-SUBSCRIPT-SAME{LITERAL}: [[hlsl::contained_type(element_type)]] +// CHECK-SUBSCRIPT-SAME: ' lvalue .__handle 0x{{[0-9A-Fa-f]+}} +// CHECK-SUBSCRIPT-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '[[RESOURCE]]<element_type>' lvalue implicit this +// CHECK-SUBSCRIPT-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'unsigned int' ParmVar 0x{{[0-9A-Fa-f]+}} 'Index' 'unsigned int' +// CHECK-SUBSCRIPT-NEXT: AlwaysInlineAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit always_inline + +// CHECK-NOSUBSCRIPT-NOT: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> operator[] 'const element_type &(unsigned int) const' +// CHECK-NOSUBSCRIPT-NOT: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> operator[] 'element_type &(unsigned int)' + +// CHECK-LOAD: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> Load 'element_type (unsigned int)' +// CHECK-LOAD-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> Index 'unsigned int' +// CHECK-LOAD-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> +// CHECK-LOAD-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> +// CHECK-LOAD-NEXT: UnaryOperator 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' prefix '*' cannot overflow +// CHECK-LOAD-NEXT: CallExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type *' +// CHECK-LOAD-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '<builtin fn type>' Function 0x{{[0-9A-Fa-f]+}} '__builtin_hlsl_resource_getpointer' 'void (...) noexcept' +// CHECK-LOAD-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '__hlsl_resource_t +// CHECK-LOAD-SAME{LITERAL}: [[hlsl::resource_class( +// CHECK-LOAD-SAME{LITERAL}: [[hlsl::contained_type(element_type)]] +// CHECK-LOAD-SAME: ' lvalue .__handle 0x{{[0-9A-Fa-f]+}} +// CHECK-LOAD-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '[[RESOURCE]]<element_type>' lvalue implicit this +// CHECK-LOAD-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'unsigned int' ParmVar 0x{{[0-9A-Fa-f]+}} 'Index' 'unsigned int' +// CHECK-LOAD-NEXT: AlwaysInlineAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit always_inline + +// CHECK-COUNTER: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> IncrementCounter 'unsigned int ()' +// CHECK-COUNTER-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> +// CHECK-COUNTER-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> +// CHECK-COUNTER-NEXT: CallExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'unsigned int' +// CHECK-COUNTER-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '<builtin fn type>' Function 0x{{[0-9A-Fa-f]+}} '__builtin_hlsl_buffer_update_counter' 'unsigned int (...) noexcept' +// CHECK-COUNTER-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '__hlsl_resource_t +// CHECK-COUNTER-SAME{LITERAL}: [[hlsl::resource_class(UAV)]] +// CHECK-COUNTER-SAME{LITERAL}: [[hlsl::raw_buffer]] +// CHECK-COUNTER-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]' lvalue .__handle +// CHECK-COUNTER-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'RWStructuredBuffer<element_type>' lvalue implicit this +// CHECK-COUNTER-NEXT: IntegerLiteral 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'int' 1 +// CHECK-COUNTER-NEXT: AlwaysInlineAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit always_inline + +// CHECK-COUNTER-NEXT: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> DecrementCounter 'unsigned int ()' +// CHECK-COUNTER-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> +// CHECK-COUNTER-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> +// CHECK-COUNTER-NEXT: CallExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'unsigned int' +// CHECK-COUNTER-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '<builtin fn type>' Function 0x{{[0-9A-Fa-f]+}} '__builtin_hlsl_buffer_update_counter' 'unsigned int (...) noexcept' +// CHECK-COUNTER-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '__hlsl_resource_t +// CHECK-COUNTER-SAME{LITERAL}: [[hlsl::resource_class(UAV)]] +// CHECK-COUNTER-SAME{LITERAL}: [[hlsl::raw_buffer]] +// CHECK-COUNTER-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]' lvalue .__handle +// CHECK-COUNTER-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'RWStructuredBuffer<element_type>' lvalue implicit this +// CHECK-COUNTER-NEXT: IntegerLiteral 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'int' -1 +// CHECK-COUNTER-NEXT: AlwaysInlineAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit always_inline + +// CHECK-APPEND: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> Append 'void (element_type)' +// CHECK-APPEND-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> value 'element_type' +// CHECK-APPEND-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> +// CHECK-APPEND-NEXT: BinaryOperator 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' '=' +// CHECK-APPEND-NEXT: UnaryOperator 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' prefix '*' cannot overflow +// CHECK-APPEND-NEXT: CallExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type *' +// CHECK-APPEND-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '<builtin fn type>' Function 0x{{[0-9A-Fa-f]+}} '__builtin_hlsl_resource_getpointer' 'void (...) noexcept' +// CHECK-APPEND-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '__hlsl_resource_t +// CHECK-APPEND-SAME{LITERAL}: [[hlsl::resource_class(UAV)]] +// CHECK-APPEND-SAME{LITERAL}: [[hlsl::raw_buffer]] +// CHECK-APPEND-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]' lvalue .__handle +// CHECK-APPEND-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '[[RESOURCE]]<element_type>' lvalue implicit this +// CHECK-APPEND-NEXT: CallExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'unsigned int' +// CHECK-APPEND-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '<builtin fn type>' Function 0x{{[0-9A-Fa-f]+}} '__builtin_hlsl_buffer_update_counter' 'unsigned int (...) noexcept' +// CHECK-APPEND-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '__hlsl_resource_t +// CHECK-APPEND-SAME{LITERAL}: [[hlsl::resource_class(UAV)]] +// CHECK-APPEND-SAME{LITERAL}: [[hlsl::raw_buffer]] +// CHECK-APPEND-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]' lvalue .__handle +// CHECK-APPEND-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '[[RESOURCE]]<element_type>' lvalue implicit this +// CHECK-APPEND-NEXT: IntegerLiteral 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'int' 1 +// CHECK-APPEND-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' ParmVar 0x{{[0-9A-Fa-f]+}} 'value' 'element_type' + +// CHECK-CONSUME: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> Consume 'element_type ()' +// CHECK-CONSUME-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> +// CHECK-CONSUME-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> +// CHECK-CONSUME-NEXT: UnaryOperator 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' prefix '*' cannot overflow +// CHECK-CONSUME-NEXT: CallExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type *' +// CHECK-CONSUME-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '<builtin fn type>' Function 0x{{[0-9A-Fa-f]+}} '__builtin_hlsl_resource_getpointer' 'void (...) noexcept' +// CHECK-CONSUME-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '__hlsl_resource_t +// CHECK-CONSUME-SAME{LITERAL}: [[hlsl::resource_class(UAV)]] +// CHECK-CONSUME-SAME{LITERAL}: [[hlsl::raw_buffer]] +// CHECK-CONSUME-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]' lvalue .__handle +// CHECK-CONSUME-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '[[RESOURCE]]<element_type>' lvalue implicit this +// CHECK-CONSUME-NEXT: CallExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'unsigned int' +// CHECK-CONSUME-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '<builtin fn type>' Function 0x{{[0-9A-Fa-f]+}} '__builtin_hlsl_buffer_update_counter' 'unsigned int (...) noexcept' +// CHECK-CONSUME-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '__hlsl_resource_t +// CHECK-CONSUME-SAME{LITERAL}: [[hlsl::resource_class(UAV)]] +// CHECK-CONSUME-SAME{LITERAL}: [[hlsl::raw_buffer]] +// CHECK-CONSUME-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]' lvalue .__handle +// CHECK-CONSUME-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> '[[RESOURCE]]<element_type>' lvalue implicit this +// CHECK-CONSUME-NEXT: IntegerLiteral 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'int' -1 + +// CHECK: ClassTemplateSpecializationDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> class [[RESOURCE]] definition + +// CHECK: TemplateArgument type 'float' +// CHECK-NEXT: BuiltinType 0x{{[0-9A-Fa-f]+}} 'float' +// CHECK-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final +// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit __handle '__hlsl_resource_t +// CHECK-SRV-SAME{LITERAL}: [[hlsl::resource_class(SRV)]] +// CHECK-UAV-SAME{LITERAL}: [[hlsl::resource_class(UAV)]] +// CHECK-ROV-SAME{LITERAL}: [[hlsl::is_rov]] +// CHECK-SAME{LITERAL}: [[hlsl::raw_buffer]] +// CHECK-SAME{LITERAL}: [[hlsl::contained_type(float)]] +// CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit RawBuffer diff --git clang/test/AST/HLSL/TypedBuffers-AST.hlsl clang/test/AST/HLSL/TypedBuffers-AST.hlsl index d6dfb0caba5d..406ff07d0cf6 100644 --- clang/test/AST/HLSL/TypedBuffers-AST.hlsl +++ clang/test/AST/HLSL/TypedBuffers-AST.hlsl @@ -23,7 +23,7 @@ // EMPTY-NEXT: ImplicitConceptSpecializationDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> // EMPTY-NEXT: TemplateArgument type 'type-parameter-0-0' // EMPTY-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-0' dependent depth 0 index 0 -// EMPTY-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} '' +// EMPTY-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} depth 0 index 0 // EMPTY-NEXT: TemplateArgument type 'element_type':'type-parameter-0-0' // EMPTY-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'element_type' dependent depth 0 index 0 // EMPTY-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'element_type' @@ -45,7 +45,7 @@ RESOURCE<float> Buffer; // CHECK-NEXT: ImplicitConceptSpecializationDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> // CHECK-NEXT: TemplateArgument type 'type-parameter-0-0' // CHECK-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-0' dependent depth 0 index 0 -// CHECK-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} '' +// CHECK-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} depth 0 index 0 // CHECK-NEXT: TemplateArgument type 'element_type':'type-parameter-0-0' // CHECK-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'element_type' dependent depth 0 index 0 // CHECK-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'element_type' diff --git clang/test/AST/ast-dump-APValue-lvalue.cpp clang/test/AST/ast-dump-APValue-lvalue.cpp new file mode 100644 index 000000000000..224caddb3eab --- /dev/null +++ clang/test/AST/ast-dump-APValue-lvalue.cpp @@ -0,0 +1,50 @@ +// Test without serialization: +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \ +// RUN: -ast-dump %s -ast-dump-filter Test \ +// RUN: | FileCheck --strict-whitespace --match-full-lines %s +// +// Test with serialization: +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 -emit-pch -o %t %s +// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \ +// RUN: -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \ +// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \ +// RUN: | FileCheck --strict-whitespace --match-full-lines %s + +int i; +struct S { + int i; + int ii; +}; +S s; + +struct F { + char padding[12]; + S s; +}; +F f; + +void Test(int (&arr)[10]) { + constexpr int *pi = &i; + // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pi 'int *const' constexpr cinit + // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=0, HasPath=1, PathLength=0, Path=() + + constexpr int *psi = &s.i; + // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} psi 'int *const' constexpr cinit + // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=0, HasPath=1, PathLength=1, Path=({{.*}}) + + constexpr int *psii = &s.ii; + // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} psii 'int *const' constexpr cinit + // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=4, HasPath=1, PathLength=1, Path=({{.*}}) + + constexpr int *pf = &f.s.ii; + // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pf 'int *const' constexpr cinit + // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=16, HasPath=1, PathLength=2, Path=({{.*}}, {{.*}}) + + constexpr char *pc = &f.padding[2]; + // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pc 'char *const' constexpr cinit + // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=2, HasPath=1, PathLength=2, Path=({{.*}}, 2) + + constexpr const int *n = nullptr; + // CHECK: `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} n 'const int *const' constexpr cinit + // CHECK-NEXT: |-value: LValue Base=null, Null=1, Offset=0, HasPath=1, PathLength=0, Path=() +} diff --git clang/test/AST/ast-dump-APValue-todo.cpp clang/test/AST/ast-dump-APValue-todo.cpp index 78cc9cf36c73..acaa82ba53b6 100644 --- clang/test/AST/ast-dump-APValue-todo.cpp +++ clang/test/AST/ast-dump-APValue-todo.cpp @@ -16,10 +16,6 @@ struct S { }; void Test() { - constexpr int *pi = &i; - // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pi 'int *const' constexpr cinit - // CHECK-NEXT: | |-value: LValue <todo> - constexpr int(S::*pmi) = &S::i; // CHECK: `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pmi 'int (S::*const)' constexpr cinit // CHECK-NEXT: |-value: MemberPointer <todo> diff --git clang/test/AST/ast-dump-binding-pack.cpp clang/test/AST/ast-dump-binding-pack.cpp new file mode 100644 index 000000000000..81c75a126873 --- /dev/null +++ clang/test/AST/ast-dump-binding-pack.cpp @@ -0,0 +1,74 @@ +// RUN: %clang_cc1 -ast-dump -std=c++26 %s | FileCheck %s + +// Test this with PCH. +// RUN: %clang_cc1 %s -std=c++26 -emit-pch -o %t %s +// RUN: %clang_cc1 %s -std=c++26 -include-pch %t -ast-dump-all | FileCheck %s + +#ifndef PCH_HELPER +#define PCH_HELPER + +template <unsigned N> +void foo() { + int arr[4] = {1, 2, 3, 4}; + auto [binding_1, ...binding_rest, binding_4] = arr; + int arr_2[] = {binding_rest...}; +}; + +// CHECK-LABEL: FunctionTemplateDecl {{.*}} foo +// CHECK-LABEL: BindingDecl {{.*}} binding_1 +// CHECK-NEXT: ArraySubscriptExpr {{.*}} +// CHECK-NEXT: ImplicitCastExpr +// CHECK-NEXT: DeclRefExpr {{.*}} +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 0 +// CHECK-NOT: BindingDecl +// CHECK-LABEL: BindingDecl {{.*}} binding_rest +// CHECK-NEXT: ResolvedUnexpandedPackExpr +// CHECK-NEXT: DeclRefExpr {{.*}} lvalue Binding {{.*}} 'binding_rest' +// CHECK-NEXT: DeclRefExpr {{.*}} lvalue Binding {{.*}} 'binding_rest' +// CHECK-NOT: BindingDecl +// CHECK-LABEL: BindingDecl {{.*}} binding_4 +// CHECK-NEXT: ArraySubscriptExpr +// CHECK-NEXT: ImplicitCastExpr {{.*}} +// CHECK-NEXT: DeclRefExpr {{.*}} lvalue Decomposition {{.*}} +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 3 +// CHECK-NOT: BindingDecl +// CHECK-LABEL: VarDecl {{.*}} arr_2 +// CHECK-NEXT: InitListExpr +// CHECK-NEXT: PackExpansionExpr {{.*}} '<dependent type>' lvalue +// CHECK-NEXT: DeclRefExpr {{.*}} lvalue Binding {{.*}} 'binding_rest' + +struct tag_t { }; +template <unsigned N> +void bar() { + auto [...empty_binding_pack] = tag_t{}; + static_assert(sizeof...(empty_binding_pack) == 0); +}; + +// CHECK-LABEL: FunctionTemplateDecl {{.*}} bar +// CHECK-NOT: BindingDecl +// CHECK-LABEL: BindingDecl {{.*}} empty_binding_pack +// CHECK-NEXT: ResolvedUnexpandedPackExpr +// CHECK-NOT: DeclRefExpr {{.*}} 'empty_binding_pack' +// CHECK-NOT: BindingDecl +// CHECK: DeclStmt + +struct int_pair { int x; int y; }; +template <typename T> +void baz() { + auto [binding_1, binding_2, ...empty_binding_pack] = T{}; + static_assert(sizeof...(empty_binding_pack) == 0); +}; + +void(*f)() = baz<int_pair>; + +// CHECK-LABEL: FunctionDecl {{.*}} baz {{.*}} implicit_instantiation +// CHECK-NEXT: TemplateArgument type 'int_pair' +// CHECK: BindingDecl {{.*}} binding_1 +// CHECK: BindingDecl {{.*}} binding_2 +// CHECK-NOT: BindingDecl +// CHECK-LABEL: BindingDecl {{.*}} empty_binding_pack +// CHECK-NEXT: ResolvedUnexpandedPackExpr +// CHECK-NOT: DeclRefExpr {{.*}} 'empty_binding_pack' +// CHECK-NOT: BindingDecl +// CHECK: DeclStmt +#endif diff --git clang/test/AST/ast-dump-decl.c clang/test/AST/ast-dump-decl.c index 28b58c8eb648..683df50f7e91 100644 --- clang/test/AST/ast-dump-decl.c +++ clang/test/AST/ast-dump-decl.c @@ -121,7 +121,7 @@ struct testIndirectFieldDecl { }; }; // CHECK: IndirectFieldDecl{{.*}} TestIndirectFieldDecl 'int' -// CHECK-NEXT: Field{{.*}} '' +// CHECK-NEXT: Field{{.*}} field_index 0 // CHECK-NEXT: Field{{.*}} 'TestIndirectFieldDecl' // FIXME: It would be nice to dump the enum and its enumerators. diff --git clang/test/AST/ast-dump-records.c clang/test/AST/ast-dump-records.c index c0fbac67bc49..f4a540f3fa87 100644 --- clang/test/AST/ast-dump-records.c +++ clang/test/AST/ast-dump-records.c @@ -58,10 +58,10 @@ struct C { }; // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <line:[[@LINE-7]]:3> col:3 implicit 'union C::(anonymous at {{.*}}:[[@LINE-7]]:3)' // CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-6]]:9> col:9 implicit c 'int' - // CHECK-NEXT: Field 0x{{[^ ]*}} '' 'union C::(anonymous at {{.*}}:[[@LINE-9]]:3)' + // CHECK-NEXT: Field 0x{{[^ ]*}} field_index 1 'union C::(anonymous at {{.*}}:[[@LINE-9]]:3)' // CHECK-NEXT: Field 0x{{[^ ]*}} 'c' 'int' // CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-7]]:11> col:11 implicit d 'float' - // CHECK-NEXT: Field 0x{{[^ ]*}} '' 'union C::(anonymous at {{.*}}:[[@LINE-12]]:3)' + // CHECK-NEXT: Field 0x{{[^ ]*}} field_index 1 'union C::(anonymous at {{.*}}:[[@LINE-12]]:3)' // CHECK-NEXT: Field 0x{{[^ ]*}} 'd' 'float' struct { @@ -72,10 +72,10 @@ struct C { }; // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <line:[[@LINE-6]]:3> col:3 implicit 'struct C::(anonymous at {{.*}}:[[@LINE-6]]:3)' // CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-5]]:9> col:9 implicit e 'int' - // CHECK-NEXT: Field 0x{{[^ ]*}} '' 'struct C::(anonymous at {{.*}}:[[@LINE-8]]:3)' + // CHECK-NEXT: Field 0x{{[^ ]*}} field_index 2 'struct C::(anonymous at {{.*}}:[[@LINE-8]]:3)' // CHECK-NEXT: Field 0x{{[^ ]*}} 'e' 'int' // CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <col:12> col:12 implicit f 'int' - // CHECK-NEXT: Field 0x{{[^ ]*}} '' 'struct C::(anonymous at {{.*}}:[[@LINE-11]]:3)' + // CHECK-NEXT: Field 0x{{[^ ]*}} field_index 2 'struct C::(anonymous at {{.*}}:[[@LINE-11]]:3)' // CHECK-NEXT: Field 0x{{[^ ]*}} 'f' 'int' }; @@ -141,10 +141,10 @@ union G { }; // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <line:[[@LINE-7]]:3> col:3 implicit 'union G::(anonymous at {{.*}}:[[@LINE-7]]:3)' // CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-6]]:9> col:9 implicit c 'int' - // CHECK-NEXT: Field 0x{{[^ ]*}} '' 'union G::(anonymous at {{.*}}:[[@LINE-9]]:3)' + // CHECK-NEXT: Field 0x{{[^ ]*}} field_index 1 'union G::(anonymous at {{.*}}:[[@LINE-9]]:3)' // CHECK-NEXT: Field 0x{{[^ ]*}} 'c' 'int' // CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-7]]:11> col:11 implicit d 'float' - // CHECK-NEXT: Field 0x{{[^ ]*}} '' 'union G::(anonymous at {{.*}}:[[@LINE-12]]:3)' + // CHECK-NEXT: Field 0x{{[^ ]*}} field_index 1 'union G::(anonymous at {{.*}}:[[@LINE-12]]:3)' // CHECK-NEXT: Field 0x{{[^ ]*}} 'd' 'float' struct { @@ -155,10 +155,10 @@ union G { }; // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <line:[[@LINE-6]]:3> col:3 implicit 'struct G::(anonymous at {{.*}}:[[@LINE-6]]:3)' // CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-5]]:9> col:9 implicit e 'int' - // CHECK-NEXT: Field 0x{{[^ ]*}} '' 'struct G::(anonymous at {{.*}}:[[@LINE-8]]:3)' + // CHECK-NEXT: Field 0x{{[^ ]*}} field_index 2 'struct G::(anonymous at {{.*}}:[[@LINE-8]]:3)' // CHECK-NEXT: Field 0x{{[^ ]*}} 'e' 'int' // CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <col:12> col:12 implicit f 'int' - // CHECK-NEXT: Field 0x{{[^ ]*}} '' 'struct G::(anonymous at {{.*}}:[[@LINE-11]]:3)' + // CHECK-NEXT: Field 0x{{[^ ]*}} field_index 2 'struct G::(anonymous at {{.*}}:[[@LINE-11]]:3)' // CHECK-NEXT: Field 0x{{[^ ]*}} 'f' 'int' }; diff --git clang/test/AST/ast-dump-records.cpp clang/test/AST/ast-dump-records.cpp index bfd8892698d4..e9b37b73002d 100644 --- clang/test/AST/ast-dump-records.cpp +++ clang/test/AST/ast-dump-records.cpp @@ -90,10 +90,10 @@ struct C { }; // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <line:[[@LINE-14]]:3> col:3 implicit 'C::(anonymous union at {{.*}}:[[@LINE-14]]:3)' // CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-6]]:9> col:9 implicit c 'int' - // CHECK-NEXT: Field 0x{{[^ ]*}} '' 'C::(anonymous union at {{.*}}:[[@LINE-16]]:3)' + // CHECK-NEXT: Field 0x{{[^ ]*}} field_index 1 'C::(anonymous union at {{.*}}:[[@LINE-16]]:3)' // CHECK-NEXT: Field 0x{{[^ ]*}} 'c' 'int' // CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-7]]:11> col:11 implicit d 'float' - // CHECK-NEXT: Field 0x{{[^ ]*}} '' 'C::(anonymous union at {{.*}}:[[@LINE-19]]:3)' + // CHECK-NEXT: Field 0x{{[^ ]*}} field_index 1 'C::(anonymous union at {{.*}}:[[@LINE-19]]:3)' // CHECK-NEXT: Field 0x{{[^ ]*}} 'd' 'float' struct { @@ -111,10 +111,10 @@ struct C { }; // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <line:[[@LINE-13]]:3> col:3 implicit 'C::(anonymous struct at {{.*}}:[[@LINE-13]]:3)' // CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-5]]:9> col:9 implicit e 'int' - // CHECK-NEXT: Field 0x{{[^ ]*}} '' 'C::(anonymous struct at {{.*}}:[[@LINE-15]]:3)' + // CHECK-NEXT: Field 0x{{[^ ]*}} field_index 2 'C::(anonymous struct at {{.*}}:[[@LINE-15]]:3)' // CHECK-NEXT: Field 0x{{[^ ]*}} 'e' 'int' // CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <col:12> col:12 implicit f 'int' - // CHECK-NEXT: Field 0x{{[^ ]*}} '' 'C::(anonymous struct at {{.*}}:[[@LINE-18]]:3)' + // CHECK-NEXT: Field 0x{{[^ ]*}} field_index 2 'C::(anonymous struct at {{.*}}:[[@LINE-18]]:3)' // CHECK-NEXT: Field 0x{{[^ ]*}} 'f' 'int' }; @@ -223,10 +223,10 @@ union G { }; // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <line:[[@LINE-15]]:3> col:3 implicit 'G::(anonymous union at {{.*}}:[[@LINE-15]]:3)' // CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-6]]:9> col:9 implicit c 'int' - // CHECK-NEXT: Field 0x{{[^ ]*}} '' 'G::(anonymous union at {{.*}}:[[@LINE-17]]:3)' + // CHECK-NEXT: Field 0x{{[^ ]*}} field_index 1 'G::(anonymous union at {{.*}}:[[@LINE-17]]:3)' // CHECK-NEXT: Field 0x{{[^ ]*}} 'c' 'int' // CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-7]]:11> col:11 implicit d 'float' - // CHECK-NEXT: Field 0x{{[^ ]*}} '' 'G::(anonymous union at {{.*}}:[[@LINE-20]]:3)' + // CHECK-NEXT: Field 0x{{[^ ]*}} field_index 1 'G::(anonymous union at {{.*}}:[[@LINE-20]]:3)' // CHECK-NEXT: Field 0x{{[^ ]*}} 'd' 'float' struct { @@ -245,10 +245,10 @@ union G { }; // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <line:[[@LINE-14]]:3> col:3 implicit 'G::(anonymous struct at {{.*}}:[[@LINE-14]]:3)' // CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-5]]:9> col:9 implicit e 'int' - // CHECK-NEXT: Field 0x{{[^ ]*}} '' 'G::(anonymous struct at {{.*}}:[[@LINE-16]]:3)' + // CHECK-NEXT: Field 0x{{[^ ]*}} field_index 2 'G::(anonymous struct at {{.*}}:[[@LINE-16]]:3)' // CHECK-NEXT: Field 0x{{[^ ]*}} 'e' 'int' // CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <col:12> col:12 implicit f 'int' - // CHECK-NEXT: Field 0x{{[^ ]*}} '' 'G::(anonymous struct at {{.*}}:[[@LINE-19]]:3)' + // CHECK-NEXT: Field 0x{{[^ ]*}} field_index 2 'G::(anonymous struct at {{.*}}:[[@LINE-19]]:3)' // CHECK-NEXT: Field 0x{{[^ ]*}} 'f' 'int' }; diff --git clang/test/AST/attr-counted-by-late-parsed-struct-ptrs.c clang/test/AST/attr-counted-by-late-parsed-struct-ptrs.c index a585a45eeff0..f9772db8b655 100644 --- clang/test/AST/attr-counted-by-late-parsed-struct-ptrs.c +++ clang/test/AST/attr-counted-by-late-parsed-struct-ptrs.c @@ -31,7 +31,7 @@ struct on_pointer_anon_count { // CHECK-NEXT: | `-FieldDecl {{.*}} count 'int' // CHECK-NEXT: |-FieldDecl {{.*}} implicit 'struct on_pointer_anon_count::(anonymous at {{.*}})' // CHECK-NEXT: `-IndirectFieldDecl {{.*}} implicit referenced count 'int' -// CHECK-NEXT: |-Field {{.*}} '' 'struct on_pointer_anon_count::(anonymous at {{.*}})' +// CHECK-NEXT: |-Field {{.*}} field_index 1 'struct on_pointer_anon_count::(anonymous at {{.*}})' // CHECK-NEXT: `-Field {{.*}} 'count' 'int' //============================================================================== diff --git clang/test/AST/attr-counted-by-or-null-late-parsed-struct-ptrs.c clang/test/AST/attr-counted-by-or-null-late-parsed-struct-ptrs.c index 975c0a023194..59b866dae720 100644 --- clang/test/AST/attr-counted-by-or-null-late-parsed-struct-ptrs.c +++ clang/test/AST/attr-counted-by-or-null-late-parsed-struct-ptrs.c @@ -31,7 +31,7 @@ struct on_pointer_anon_count { // CHECK-NEXT: | `-FieldDecl {{.*}} count 'int' // CHECK-NEXT: |-FieldDecl {{.*}} implicit 'struct on_pointer_anon_count::(anonymous at {{.*}})' // CHECK-NEXT: `-IndirectFieldDecl {{.*}} implicit referenced count 'int' -// CHECK-NEXT: |-Field {{.*}} '' 'struct on_pointer_anon_count::(anonymous at {{.*}})' +// CHECK-NEXT: |-Field {{.*}} field_index 1 'struct on_pointer_anon_count::(anonymous at {{.*}})' // CHECK-NEXT: `-Field {{.*}} 'count' 'int' //============================================================================== diff --git clang/test/AST/attr-counted-by-or-null-struct-ptrs.c clang/test/AST/attr-counted-by-or-null-struct-ptrs.c index 075f583784fe..d42547003f0b 100644 --- clang/test/AST/attr-counted-by-or-null-struct-ptrs.c +++ clang/test/AST/attr-counted-by-or-null-struct-ptrs.c @@ -26,7 +26,7 @@ struct on_member_pointer_complete_ty { // CHECK-NEXT: | `-FieldDecl {{.+}} buf 'struct size_known * __counted_by_or_null(count)':'struct size_known *' // CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH:.+]])' // CHECK-NEXT: `-IndirectFieldDecl {{.+}} implicit buf 'struct size_known * __counted_by_or_null(count)':'struct size_known *' -// CHECK-NEXT: |-Field {{.+}} '' 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH]])' +// CHECK-NEXT: |-Field {{.+}} field_index 1 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH]])' // CHECK-NEXT: `-Field {{.+}} 'buf' 'struct size_known * __counted_by_or_null(count)':'struct size_known *' struct on_pointer_anon_buf { int count; @@ -94,7 +94,7 @@ struct on_nested_pointer_outer { // CHECK-NEXT: | `-FieldDecl {{.+}} buf 'struct size_known * __counted_by_or_null(count)':'struct size_known *' // CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2:.+]])' // CHECK-NEXT: `-IndirectFieldDecl {{.+}} implicit buf 'struct size_known * __counted_by_or_null(count)':'struct size_known *' -// CHECK-NEXT: |-Field {{.+}} '' 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2]])' +// CHECK-NEXT: |-Field {{.+}} field_index 1 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2]])' // CHECK-NEXT: `-Field {{.+}} 'buf' 'struct size_known * __counted_by_or_null(count)':'struct size_known *' struct on_pointer_anon_buf_ty_pos { int count; @@ -108,7 +108,7 @@ struct on_pointer_anon_buf_ty_pos { // CHECK-NEXT: | `-FieldDecl {{.+}} count 'int' // CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3:.+]])' // CHECK-NEXT: |-IndirectFieldDecl {{.+}} implicit referenced count 'int' -// CHECK-NEXT: | |-Field {{.+}} '' 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3]])' +// CHECK-NEXT: | |-Field {{.+}} field_index 0 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3]])' // CHECK-NEXT: | `-Field {{.+}} 'count' 'int' struct on_pointer_anon_count_ty_pos { struct { diff --git clang/test/AST/attr-counted-by-struct-ptrs.c clang/test/AST/attr-counted-by-struct-ptrs.c index 0c0525823414..afef9c8c3b95 100644 --- clang/test/AST/attr-counted-by-struct-ptrs.c +++ clang/test/AST/attr-counted-by-struct-ptrs.c @@ -26,7 +26,7 @@ struct on_member_pointer_complete_ty { // CHECK-NEXT: | `-FieldDecl {{.+}} buf 'struct size_known * __counted_by(count)':'struct size_known *' // CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH:.+]])' // CHECK-NEXT: `-IndirectFieldDecl {{.+}} implicit buf 'struct size_known * __counted_by(count)':'struct size_known *' -// CHECK-NEXT: |-Field {{.+}} '' 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH]])' +// CHECK-NEXT: |-Field {{.+}} field_index 1 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH]])' // CHECK-NEXT: `-Field {{.+}} 'buf' 'struct size_known * __counted_by(count)':'struct size_known *' struct on_pointer_anon_buf { int count; @@ -94,7 +94,7 @@ struct on_nested_pointer_outer { // CHECK-NEXT: | `-FieldDecl {{.+}} buf 'struct size_known * __counted_by(count)':'struct size_known *' // CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2:.+]])' // CHECK-NEXT: `-IndirectFieldDecl {{.+}} implicit buf 'struct size_known * __counted_by(count)':'struct size_known *' -// CHECK-NEXT: |-Field {{.+}} '' 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2]])' +// CHECK-NEXT: |-Field {{.+}} field_index 1 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2]])' // CHECK-NEXT: `-Field {{.+}} 'buf' 'struct size_known * __counted_by(count)':'struct size_known *' struct on_pointer_anon_buf_ty_pos { int count; @@ -108,7 +108,7 @@ struct on_pointer_anon_buf_ty_pos { // CHECK-NEXT: | `-FieldDecl {{.+}} count 'int' // CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3:.+]])' // CHECK-NEXT: |-IndirectFieldDecl {{.+}} implicit referenced count 'int' -// CHECK-NEXT: | |-Field {{.+}} '' 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3]])' +// CHECK-NEXT: | |-Field {{.+}} field_index 0 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3]])' // CHECK-NEXT: | `-Field {{.+}} 'count' 'int' struct on_pointer_anon_count_ty_pos { struct { diff --git clang/test/AST/attr-sized-by-late-parsed-struct-ptrs.c clang/test/AST/attr-sized-by-late-parsed-struct-ptrs.c index b58caf608bf9..411b333f3798 100644 --- clang/test/AST/attr-sized-by-late-parsed-struct-ptrs.c +++ clang/test/AST/attr-sized-by-late-parsed-struct-ptrs.c @@ -31,7 +31,7 @@ struct on_pointer_anon_count { // CHECK-NEXT: | `-FieldDecl {{.*}} count 'int' // CHECK-NEXT: |-FieldDecl {{.*}} implicit 'struct on_pointer_anon_count::(anonymous at {{.*}})' // CHECK-NEXT: `-IndirectFieldDecl {{.*}} implicit referenced count 'int' -// CHECK-NEXT: |-Field {{.*}} '' 'struct on_pointer_anon_count::(anonymous at {{.*}})' +// CHECK-NEXT: |-Field {{.*}} field_index 1 'struct on_pointer_anon_count::(anonymous at {{.*}})' // CHECK-NEXT: `-Field {{.*}} 'count' 'int' //============================================================================== diff --git clang/test/AST/attr-sized-by-or-null-late-parsed-struct-ptrs.c clang/test/AST/attr-sized-by-or-null-late-parsed-struct-ptrs.c index d55a42ac0fb9..ae89360e1749 100644 --- clang/test/AST/attr-sized-by-or-null-late-parsed-struct-ptrs.c +++ clang/test/AST/attr-sized-by-or-null-late-parsed-struct-ptrs.c @@ -31,7 +31,7 @@ struct on_pointer_anon_count { // CHECK-NEXT: | `-FieldDecl {{.*}} count 'int' // CHECK-NEXT: |-FieldDecl {{.*}} implicit 'struct on_pointer_anon_count::(anonymous at {{.*}})' // CHECK-NEXT: `-IndirectFieldDecl {{.*}} implicit referenced count 'int' -// CHECK-NEXT: |-Field {{.*}} '' 'struct on_pointer_anon_count::(anonymous at {{.*}})' +// CHECK-NEXT: |-Field {{.*}} field_index 1 'struct on_pointer_anon_count::(anonymous at {{.*}})' // CHECK-NEXT: `-Field {{.*}} 'count' 'int' //============================================================================== diff --git clang/test/AST/attr-sized-by-or-null-struct-ptrs.c clang/test/AST/attr-sized-by-or-null-struct-ptrs.c index 73b8a71f2350..7273280e4b60 100644 --- clang/test/AST/attr-sized-by-or-null-struct-ptrs.c +++ clang/test/AST/attr-sized-by-or-null-struct-ptrs.c @@ -26,7 +26,7 @@ struct on_member_pointer_complete_ty { // CHECK-NEXT: | `-FieldDecl {{.+}} buf 'struct size_known * __sized_by_or_null(count)':'struct size_known *' // CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH:.+]])' // CHECK-NEXT: `-IndirectFieldDecl {{.+}} implicit buf 'struct size_known * __sized_by_or_null(count)':'struct size_known *' -// CHECK-NEXT: |-Field {{.+}} '' 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH]])' +// CHECK-NEXT: |-Field {{.+}} field_index 1 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH]])' // CHECK-NEXT: `-Field {{.+}} 'buf' 'struct size_known * __sized_by_or_null(count)':'struct size_known *' struct on_pointer_anon_buf { int count; @@ -94,7 +94,7 @@ struct on_nested_pointer_outer { // CHECK-NEXT: | `-FieldDecl {{.+}} buf 'struct size_known * __sized_by_or_null(count)':'struct size_known *' // CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2:.+]])' // CHECK-NEXT: `-IndirectFieldDecl {{.+}} implicit buf 'struct size_known * __sized_by_or_null(count)':'struct size_known *' -// CHECK-NEXT: |-Field {{.+}} '' 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2]])' +// CHECK-NEXT: |-Field {{.+}} field_index 1 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2]])' // CHECK-NEXT: `-Field {{.+}} 'buf' 'struct size_known * __sized_by_or_null(count)':'struct size_known *' struct on_pointer_anon_buf_ty_pos { int count; @@ -108,7 +108,7 @@ struct on_pointer_anon_buf_ty_pos { // CHECK-NEXT: | `-FieldDecl {{.+}} count 'int' // CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3:.+]])' // CHECK-NEXT: |-IndirectFieldDecl {{.+}} implicit referenced count 'int' -// CHECK-NEXT: | |-Field {{.+}} '' 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3]])' +// CHECK-NEXT: | |-Field {{.+}} field_index 0 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3]])' // CHECK-NEXT: | `-Field {{.+}} 'count' 'int' struct on_pointer_anon_count_ty_pos { struct { diff --git clang/test/AST/attr-sized-by-struct-ptrs.c clang/test/AST/attr-sized-by-struct-ptrs.c index 7f7e3dfea2ac..738eaf8cbf36 100644 --- clang/test/AST/attr-sized-by-struct-ptrs.c +++ clang/test/AST/attr-sized-by-struct-ptrs.c @@ -26,7 +26,7 @@ struct on_member_pointer_complete_ty { // CHECK-NEXT: | `-FieldDecl {{.+}} buf 'struct size_known * __sized_by(count)':'struct size_known *' // CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH:.+]])' // CHECK-NEXT: `-IndirectFieldDecl {{.+}} implicit buf 'struct size_known * __sized_by(count)':'struct size_known *' -// CHECK-NEXT: |-Field {{.+}} '' 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH]])' +// CHECK-NEXT: |-Field {{.+}} field_index 1 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH]])' // CHECK-NEXT: `-Field {{.+}} 'buf' 'struct size_known * __sized_by(count)':'struct size_known *' struct on_pointer_anon_buf { int count; @@ -94,7 +94,7 @@ struct on_nested_pointer_outer { // CHECK-NEXT: | `-FieldDecl {{.+}} buf 'struct size_known * __sized_by(count)':'struct size_known *' // CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2:.+]])' // CHECK-NEXT: `-IndirectFieldDecl {{.+}} implicit buf 'struct size_known * __sized_by(count)':'struct size_known *' -// CHECK-NEXT: |-Field {{.+}} '' 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2]])' +// CHECK-NEXT: |-Field {{.+}} field_index 1 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2]])' // CHECK-NEXT: `-Field {{.+}} 'buf' 'struct size_known * __sized_by(count)':'struct size_known *' struct on_pointer_anon_buf_ty_pos { int count; @@ -108,7 +108,7 @@ struct on_pointer_anon_buf_ty_pos { // CHECK-NEXT: | `-FieldDecl {{.+}} count 'int' // CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3:.+]])' // CHECK-NEXT: |-IndirectFieldDecl {{.+}} implicit referenced count 'int' -// CHECK-NEXT: | |-Field {{.+}} '' 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3]])' +// CHECK-NEXT: | |-Field {{.+}} field_index 0 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3]])' // CHECK-NEXT: | `-Field {{.+}} 'count' 'int' struct on_pointer_anon_count_ty_pos { struct { diff --git clang/test/Analysis/Inputs/ctu-test-import-failure-import.cpp clang/test/Analysis/Inputs/ctu-test-import-failure-import.cpp new file mode 100644 index 000000000000..ffe860870a21 --- /dev/null +++ clang/test/Analysis/Inputs/ctu-test-import-failure-import.cpp @@ -0,0 +1,52 @@ +namespace std { +inline namespace __cxx11 { +template <typename _CharT, typename = int, typename = _CharT> +class basic_string; +} +template <typename, typename> class basic_istream; +template <typename> struct __get_first_arg; +struct allocator_traits { + using type = __get_first_arg<int>; +}; +} // namespace std +namespace std { +inline namespace __cxx11 { +template <typename, typename, typename> class basic_string { + allocator_traits _M_allocated_capacity; + void _M_assign(); +}; +} // namespace __cxx11 +} // namespace std +namespace std { +template <typename _CharT, typename _Alloc> void operator!=(_Alloc, _CharT); +template <typename _CharT, typename _Traits, typename _Alloc> +basic_istream<_CharT, _Traits> &getline(basic_istream<_CharT, _Traits> &, + basic_string<_CharT, _Traits, _Alloc> &, + _CharT); +} // namespace std +namespace std { +template <typename _CharT, typename _Traits, typename _Alloc> +void basic_string<_CharT, _Traits, _Alloc>::_M_assign() { + this != 0; +} +template <typename _CharT, typename _Traits, typename _Alloc> +basic_istream<_CharT, _Traits> &getline(basic_istream<_CharT, _Traits> &, + basic_string<_CharT, _Traits, _Alloc> &, + _CharT) {} +} // namespace std +struct CommandLineOptionDefinition { + void *OutAddress; +}; +struct CommandLineCommand { + CommandLineOptionDefinition Options; +}; +namespace CommandLine { +extern const CommandLineCommand RootCommands[]; +extern const int RootExamples[]; +} // namespace CommandLine +using utf8 = char; +using u8string = std::basic_string<utf8>; +u8string _rct2DataPath; +CommandLineOptionDefinition StandardOptions{&_rct2DataPath}; +const CommandLineCommand CommandLine::RootCommands[]{StandardOptions}; +const int CommandLine::RootExamples[]{}; diff --git clang/test/Analysis/Inputs/ctu-test-import-failure-import.cpp.externalDefMap.ast-dump.txt clang/test/Analysis/Inputs/ctu-test-import-failure-import.cpp.externalDefMap.ast-dump.txt new file mode 100644 index 000000000000..6ffb3795d3e3 --- /dev/null +++ clang/test/Analysis/Inputs/ctu-test-import-failure-import.cpp.externalDefMap.ast-dump.txt @@ -0,0 +1,5 @@ +47:c:@N@std@S@allocator_traits@F@allocator_traits# ctu-test-import-failure-import.cpp.ast +29:c:@N@CommandLine@RootCommands ctu-test-import-failure-import.cpp.ast +55:c:@N@std@N@__cxx11@ST>3#T#T#T@basic_string@F@_M_assign# ctu-test-import-failure-import.cpp.ast +97:c:@S@CommandLineOptionDefinition@F@CommandLineOptionDefinition#&1$@S@CommandLineOptionDefinition# ctu-test-import-failure-import.cpp.ast +29:c:@N@CommandLine@RootExamples ctu-test-import-failure-import.cpp.ast \ No newline at end of file diff --git clang/test/Analysis/anonymous-decls.cpp clang/test/Analysis/anonymous-decls.cpp new file mode 100644 index 000000000000..211184523aa5 --- /dev/null +++ clang/test/Analysis/anonymous-decls.cpp @@ -0,0 +1,89 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -triple x86_64-apple-darwin12 -std=c++20 %s 2>&1 | FileCheck %s + +struct A { + static A a; + char b; + friend bool operator==(A, A) = default; +}; +bool _ = A() == A::a; + +// FIXME: steps 1 and 5 show anonymous function parameters are +// not handled correctly. + +// CHECK-LABEL: bool operator==(A, A) noexcept = default +// CHECK-NEXT: [B2 (ENTRY)] +// CHECK-NEXT: Succs (1): B1 +// CHECK: [B1] +// CHECK-NEXT: 1: function-parameter-0-0 +// CHECK-NEXT: 2: [B1.1].b +// CHECK-NEXT: 3: [B1.2] (ImplicitCastExpr, LValueToRValue, char) +// CHECK-NEXT: 4: [B1.3] (ImplicitCastExpr, IntegralCast, int) +// CHECK-NEXT: 5: function-parameter-0-1 +// CHECK-NEXT: 6: [B1.5].b +// CHECK-NEXT: 7: [B1.6] (ImplicitCastExpr, LValueToRValue, char) +// CHECK-NEXT: 8: [B1.7] (ImplicitCastExpr, IntegralCast, int) +// CHECK-NEXT: 9: [B1.4] == [B1.8] +// CHECK-NEXT: 10: return [B1.9]; +// CHECK-NEXT: Preds (1): B2 +// CHECK-NEXT: Succs (1): B0 +// CHECK: [B0 (EXIT)] +// CHECK-NEXT: Preds (1): B1 + +namespace std { +template <class> struct iterator_traits; +template <class, class> struct pair; +template <class _Tp> struct iterator_traits<_Tp *> { + typedef _Tp &reference; +}; +template <long, class> struct tuple_element; +template <class> struct tuple_size; +template <class _T1, class _T2> struct tuple_size<pair<_T1, _T2>> { + static const int value = 2; +}; +template <class _T1, class _T2> struct tuple_element<0, pair<_T1, _T2>> { + using type = _T1; +}; +template <class _T1, class _T2> struct tuple_element<1, pair<_T1, _T2>> { + using type = _T2; +}; +template <long _Ip, class _T1, class _T2> +tuple_element<_Ip, pair<_T1, _T2>>::type get(pair<_T1, _T2> &); +struct __wrap_iter { + iterator_traits<pair<int, int> *>::reference operator*(); + void operator++(); +}; +bool operator!=(__wrap_iter, __wrap_iter); +struct vector { + __wrap_iter begin(); + __wrap_iter end(); +}; +} // namespace std +int main() { + std::vector v; + for (auto &[a, b] : v) + ; +} + +// FIXME: On steps 8 and 14, a decomposition is referred by name, which they never have. + +// CHECK-LABEL: int main() +// CHECK: [B3] +// CHECK-NEXT: 1: operator* +// CHECK-NEXT: 2: [B3.1] (ImplicitCastExpr, FunctionToPointerDecay, iterator_traits<pair<int, int> *>::reference (*)(void)) +// CHECK-NEXT: 3: __begin1 +// CHECK-NEXT: 4: * [B3.3] (OperatorCall) +// CHECK-NEXT: 5: auto &; +// CHECK-NEXT: 6: get<0UL> +// CHECK-NEXT: 7: [B3.6] (ImplicitCastExpr, FunctionToPointerDecay, typename tuple_element<0L, pair<int, int> >::type (*)(pair<int, int> &)) +// CHECK-NEXT: 8: decomposition-a-b +// CHECK-NEXT: 9: [B3.7]([B3.8]) +// CHECK-NEXT: 10: [B3.9] +// CHECK-NEXT: 11: std::tuple_element<0, std::pair<int, int>>::type a = get<0UL>(decomposition-a-b); +// CHECK-NEXT: 12: get<1UL> +// CHECK-NEXT: 13: [B3.12] (ImplicitCastExpr, FunctionToPointerDecay, typename tuple_element<1L, pair<int, int> >::type (*)(pair<int, int> &)) +// CHECK-NEXT: 14: decomposition-a-b +// CHECK-NEXT: 15: [B3.13]([B3.14]) +// CHECK-NEXT: 16: [B3.15] +// CHECK-NEXT: 17: std::tuple_element<1, std::pair<int, int>>::type b = get<1UL>(decomposition-a-b); +// CHECK-NEXT: Preds (1): B1 +// CHECK-NEXT: Succs (1): B2 diff --git clang/test/Analysis/ctu-test-import-failure.cpp clang/test/Analysis/ctu-test-import-failure.cpp new file mode 100644 index 000000000000..2295a66538fc --- /dev/null +++ clang/test/Analysis/ctu-test-import-failure.cpp @@ -0,0 +1,34 @@ +// RUN: rm -rf %t && mkdir %t +// RUN: mkdir -p %t/ctudir +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++17 \ +// RUN: -emit-pch -o %t/ctudir/ctu-test-import-failure-import.cpp.ast %S/Inputs/ctu-test-import-failure-import.cpp +// RUN: cp %S/Inputs/ctu-test-import-failure-import.cpp.externalDefMap.ast-dump.txt %t/ctudir/externalDefMap.txt +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++17 -analyze \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-config experimental-enable-naive-ctu-analysis=true \ +// RUN: -analyzer-config ctu-dir=%t/ctudir \ +// RUN: -verify %s + +// Check that importing this code does not cause crash. +// Import intentionally fails because mismatch of '__get_first_arg'. + +namespace std { +inline namespace __cxx11 {} +template <typename _CharT, typename> class basic_istream; +struct __get_first_arg; +inline namespace __cxx11 { +template <typename, typename, typename> class basic_string; +} +template <typename _CharT, typename _Traits, typename _Alloc> +basic_istream<_CharT, _Traits> &getline(basic_istream<_CharT, _Traits> &, + basic_string<_CharT, _Traits, _Alloc> &, + _CharT) {} +} // namespace std +namespace CommandLine { +extern const int RootExamples[]; +} + +// expected-warning@Inputs/ctu-test-import-failure-import.cpp:14{{incompatible definitions}} +// expected-warning@Inputs/ctu-test-import-failure-import.cpp:14{{incompatible definitions}} +// expected-note@Inputs/ctu-test-import-failure-import.cpp:14{{no corresponding field here}} +// expected-note@Inputs/ctu-test-import-failure-import.cpp:14{{no corresponding field here}} diff --git clang/test/CMakeLists.txt clang/test/CMakeLists.txt index 5369dc92f69e..9ce8365910d5 100644 --- clang/test/CMakeLists.txt +++ clang/test/CMakeLists.txt @@ -5,7 +5,6 @@ llvm_canonicalize_cmake_booleans( CLANG_BUILD_EXAMPLES CLANG_BUILT_STANDALONE CLANG_DEFAULT_PIE_ON_LINUX - CLANG_ENABLE_ARCMT CLANG_ENABLE_STATIC_ANALYZER CLANG_PLUGIN_SUPPORT CLANG_SPAWN_CC1 @@ -92,13 +91,6 @@ if(CLANG_ENABLE_STATIC_ANALYZER) ) endif() -if (CLANG_ENABLE_ARCMT) - list(APPEND CLANG_TEST_DEPS - arcmt-test - c-arcmt-test - ) -endif () - if(CLANG_BUILD_EXAMPLES AND CLANG_PLUGIN_SUPPORT) list(APPEND CLANG_TEST_DEPS Attribute diff --git clang/test/CXX/drs/cwg0xx.cpp clang/test/CXX/drs/cwg0xx.cpp index 15f469440c66..44a0eb520af2 100644 --- clang/test/CXX/drs/cwg0xx.cpp +++ clang/test/CXX/drs/cwg0xx.cpp @@ -521,12 +521,12 @@ namespace example1 { namespace A { int i; } - + namespace A1 { using A::i; using A::i; } - + void f() { using A::i; @@ -1371,7 +1371,7 @@ namespace cwg92 { // cwg92: 4 c++17 // considered in this context. In C++17, we *do* perform an implicit // conversion (which performs initialization), and the exception specification // is part of the type of the parameter, so this is invalid. - template<void() throw()> struct X {}; + template<void() throw()> struct X {}; // since-cxx17-note {{template parameter is declared here}} X<&f> xp; // since-cxx17-error@-1 {{value of type 'void (*)() throw(int, float)' is not implicitly convertible to 'void (*)() throw()'}} diff --git clang/test/CXX/drs/cwg12xx.cpp clang/test/CXX/drs/cwg12xx.cpp index 344adb6d7202..e02a7e11b80b 100644 --- clang/test/CXX/drs/cwg12xx.cpp +++ clang/test/CXX/drs/cwg12xx.cpp @@ -155,6 +155,8 @@ namespace cwg1295 { // cwg1295: 4 // cxx98-14-error@-1 {{non-type template argument does not refer to any declaration}} // cxx98-14-note@#cwg1295-Y {{template parameter is declared here}} // since-cxx17-error@#cwg1295-y {{reference cannot bind to bit-field in converted constant expression}} + // since-cxx17-note@#cwg1295-Y {{template parameter is declared here}} + #if __cplusplus >= 201103L const unsigned other = 0; diff --git clang/test/CXX/drs/cwg3xx.cpp clang/test/CXX/drs/cwg3xx.cpp index b5e07a66bb4e..6c420ecd4c91 100644 --- clang/test/CXX/drs/cwg3xx.cpp +++ clang/test/CXX/drs/cwg3xx.cpp @@ -444,7 +444,7 @@ namespace cwg329 { // cwg329: 3.5 // expected-note@#cwg329-b {{in instantiation of template class 'cwg329::A<char>' requested here}} // expected-note@#cwg329-i {{previous definition is here}} }; - A<int> a; + A<int> a; A<char> b; // #cwg329-b void test() { @@ -688,9 +688,9 @@ namespace cwg341 { // cwg341: sup 1708 namespace B { extern "C" int &cwg341_a = cwg341_a; // expected-error@-1 {{redefinition of 'cwg341_a'}} - // expected-note@#cwg341_a {{previous definition is here}} + // expected-note@#cwg341_a {{previous definition is here}} } - extern "C" void cwg341_b(); // #cwg341_b + extern "C" void cwg341_b(); // #cwg341_b } int cwg341_a; // expected-error@-1 {{declaration of 'cwg341_a' in global scope conflicts with declaration with C language linkage}} @@ -708,7 +708,7 @@ namespace cwg341 { // expected-error@-1 {{declaration of 'cwg341_d' with C language linkage conflicts with declaration in global scope}} // expected-note@#cwg341_d {{declared in global scope here}} - namespace A { extern "C" int cwg341_e; } // #cwg341_e + namespace A { extern "C" int cwg341_e; } // #cwg341_e namespace B { extern "C" void cwg341_e(); } // expected-error@-1 {{redefinition of 'cwg341_e' as different kind of symbol}} // expected-note@#cwg341_e {{previous definition is here}} @@ -960,6 +960,7 @@ namespace cwg354 { // cwg354: 3.1 c++11 // cxx11-14-error@#cwg354-p0 {{null non-type template argument must be cast to template parameter type 'int *'}} // cxx11-14-note@#cwg354-ptr {{template parameter is declared here}} // since-cxx17-error@#cwg354-p0 {{conversion from 'int' to 'int *' is not allowed in a converted constant expression}} + // since-cxx17-note@#cwg354-ptr {{template parameter is declared here}} ptr<(int*)0> p1; // cxx98-error@-1 {{non-type template argument does not refer to any declaration}} // cxx98-note@#cwg354-ptr {{template parameter is declared here}} @@ -969,12 +970,14 @@ namespace cwg354 { // cwg354: 3.1 c++11 // cxx11-14-error@#cwg354-p2 {{null non-type template argument of type 'float *' does not match template parameter of type 'int *'}} // cxx11-14-note@#cwg354-ptr {{template parameter is declared here}} // since-cxx17-error@#cwg354-p2 {{value of type 'float *' is not implicitly convertible to 'int *'}} + // since-cxx17-note@#cwg354-ptr {{template parameter is declared here}} ptr<(int S::*)0> p3; // #cwg354-p3 // cxx98-error@#cwg354-p3 {{non-type template argument does not refer to any declaration}} // cxx98-note@#cwg354-ptr {{template parameter is declared here}} // cxx11-14-error@#cwg354-p3 {{null non-type template argument of type 'int S::*' does not match template parameter of type 'int *'}} // cxx11-14-note@#cwg354-ptr {{template parameter is declared here}} // since-cxx17-error@#cwg354-p3 {{value of type 'int S::*' is not implicitly convertible to 'int *'}} + // since-cxx17-note@#cwg354-ptr {{template parameter is declared here}} template<int*> int both(); // #cwg354-both-int-ptr template<int> int both(); // #cwg354-both-int @@ -991,6 +994,7 @@ namespace cwg354 { // cwg354: 3.1 c++11 // cxx11-14-error@#cwg354-m0 {{null non-type template argument must be cast to template parameter type 'int S::*'}} // cxx11-14-note@#cwg354-ptr_mem {{template parameter is declared here}} // since-cxx17-error@#cwg354-m0 {{conversion from 'int' to 'int S::*' is not allowed in a converted constant expression}} + // since-cxx17-note@#cwg354-ptr_mem {{template parameter is declared here}} ptr_mem<(int S::*)0> m1; // cxx98-error@-1 {{non-type template argument is not a pointer to member constant}} ptr_mem<(float S::*)0> m2; // #cwg354-m2 @@ -999,12 +1003,14 @@ namespace cwg354 { // cwg354: 3.1 c++11 // cxx11-14-error@#cwg354-m2 {{null non-type template argument of type 'float S::*' does not match template parameter of type 'int S::*'}} // cxx11-14-note@#cwg354-ptr_mem {{template parameter is declared here}} // since-cxx17-error@#cwg354-m2 {{value of type 'float S::*' is not implicitly convertible to 'int S::*'}} + // since-cxx17-note@#cwg354-ptr_mem {{template parameter is declared here}} ptr_mem<(int *)0> m3; // #cwg354-m3 // cxx98-error@#cwg354-m3 {{non-type template argument of type 'int *' cannot be converted to a value of type 'int S::*'}} // cxx98-note@#cwg354-ptr_mem {{template parameter is declared here}} // cxx11-14-error@#cwg354-m3 {{null non-type template argument of type 'int *' does not match template parameter of type 'int S::*'}} // cxx11-14-note@#cwg354-ptr_mem {{template parameter is declared here}} // since-cxx17-error@#cwg354-m3 {{value of type 'int *' is not implicitly convertible to 'int S::*'}} + // since-cxx17-note@#cwg354-ptr_mem {{template parameter is declared here}} } // namespace cwg354 struct cwg355_S; // cwg355: 2.7 @@ -1116,7 +1122,7 @@ namespace cwg364 { // cwg364: 2.7 } // namespace cwg364 namespace cwg366 { // cwg366: 2.7 -#if "foo" // expected-error {{invalid token at start of a preprocessor expression}} +#if "foo" // expected-error {{invalid token at start of a preprocessor expression}} #endif } // namespace cwg366 diff --git clang/test/CXX/expr/expr.const/p3-0x.cpp clang/test/CXX/expr/expr.const/p3-0x.cpp index 5bd70c5250b5..3eedef3cf771 100644 --- clang/test/CXX/expr/expr.const/p3-0x.cpp +++ clang/test/CXX/expr/expr.const/p3-0x.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -// RUN: %clang_cc1 -fsyntax-only -std=c++1z -verify %s +// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify=expected,cxx11 %s +// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify=expected,cxx17 %s // A converted constant expression of type T is a core constant expression, int nonconst = 8; // expected-note 3 {{here}} @@ -66,7 +66,8 @@ enum class EEE : unsigned short { e = 123456, // expected-error {{enumerator value evaluates to 123456, which cannot be narrowed to type 'unsigned short'}} f = -3 // expected-error {{enumerator value evaluates to -3, which cannot be narrowed to type 'unsigned short'}} }; -template<unsigned char> using A = int; +template<unsigned char> using A = int; // cxx17-note 2{{template parameter is declared here}} + using Int = A<E6>; using Int = A<EE::EE32>; // expected-error {{not implicitly convertible}} using Int = A<(int)EE::EE32>; @@ -78,6 +79,7 @@ using Int = A<-3>; // expected-error {{template argument evaluates to -3, which // integral conversions as well as boolean conversions. // FIXME: Per core issue 1407, this is not correct. template<typename T, T v> struct Val { static constexpr T value = v; }; +// cxx17-note@-1 2{{template parameter is declared here}} static_assert(Val<bool, E1>::value == 1, ""); // ok static_assert(Val<bool, '\0'>::value == 0, ""); // ok static_assert(Val<bool, U'\1'>::value == 1, ""); // ok diff --git clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp index 7fce61551692..629000d88acc 100644 --- clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp +++ clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp @@ -8,7 +8,7 @@ // be one of: // -- an integral constant expression; or // -- the name of a non-type template-parameter ; or -#ifndef CPP11ONLY +#ifndef CPP11ONLY namespace non_type_tmpl_param { template <int N> struct X0 { X0(); }; @@ -31,15 +31,18 @@ namespace non_type_tmpl_param { // omitted if the name refers to a function or array and shall be omitted // if the corresopnding template-parameter is a reference; or namespace addr_of_obj_or_func { - template <int* p> struct X0 { }; // precxx17-note 5{{here}} + template <int* p> struct X0 { }; // expected-note 5{{here}} #if __cplusplus >= 201103L // precxx17-note@-2 2{{template parameter is declared here}} #endif - template <int (*fp)(int)> struct X1 { }; - template <int &p> struct X2 { }; // precxx17-note 4{{here}} - template <const int &p> struct X2k { }; // precxx17-note {{here}} - template <int (&fp)(int)> struct X3 { }; // precxx17-note 4{{here}} + template <int (*fp)(int)> struct X1 { }; // cxx17-note {{here}} +#if __cplusplus <= 199711L + // precxx17-note@-2 {{here}} +#endif + template <int &p> struct X2 { }; // expected-note 4{{here}} + template <const int &p> struct X2k { }; // expected-note {{here}} + template <int (&fp)(int)> struct X3 { }; // expected-note 4{{here}} int i = 42; #if __cplusplus >= 201103L diff --git clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp index 54fcfccad6f5..3caed045c668 100644 --- clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp +++ clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp @@ -18,8 +18,9 @@ eval<D<int, 17>> eD; // expected-error{{implicit instantiation of undefined temp eval<E<int, float>> eE; // expected-error{{implicit instantiation of undefined template 'eval<E<int, float>>}} template< - template <int ...N> // expected-error{{deduced non-type template argument does not have the same type as the corresponding template parameter ('int' vs 'void *')}} - class TT // expected-note {{previous template template parameter is here}} + template <int ...N> // expected-error {{cannot be narrowed from type 'int' to 'short'}} + // expected-error@-1 {{conversion from 'int' to 'void *' is not allowed in a converted constant expression}} + class TT // expected-note 2{{previous template template parameter is here}} > struct X0 { }; template<int I, int J, int ...Rest> struct X0a; @@ -31,12 +32,13 @@ template<int I, void *J> struct X0e; // expected-note{{template parameter is dec X0<X0a> inst_x0a; X0<X0b> inst_x0b; X0<X0c> inst_x0c; -X0<X0d> inst_x0d; +X0<X0d> inst_x0d; // expected-note {{has different template parameters}} X0<X0e> inst_x0e; // expected-note{{template template argument has different template parameters than its corresponding template template parameter}} template<typename T, - template <T ...N> // expected-error{{deduced non-type template argument does not have the same type as the corresponding template parameter ('short' vs 'void *')}} - class TT // expected-note {{previous template template parameter is here}} + template <T ...N> // expected-error {{conversion from 'short' to 'void *' is not allowed in a converted constant expression}} + // expected-error@-1 {{cannot be narrowed from type 'int' to 'short'}} + class TT // expected-note 2{{previous template template parameter is here}} > struct X1 { }; template<int I, int J, int ...Rest> struct X1a; @@ -49,8 +51,8 @@ X1<int, X1a> inst_x1a; X1<long, X1b> inst_x1b; X1<short, X1c> inst_x1c; X1<short, X1d> inst_sx1d; -X1<int, X1d> inst_ix1d; -X1<short, X1e> inst_x1e; // expected-note{{template template argument has different template parameters than its corresponding template template parameter}} +X1<int, X1d> inst_ix1d; // expected-note {{has different template parameters}} +X1<short, X1e> inst_x1e; // expected-note {{has different template parameters}} template <int> class X2; // expected-note{{template is declared here}} \ // expected-note{{template is declared here}} diff --git clang/test/ClangScanDeps/strip-input-args.m clang/test/ClangScanDeps/strip-input-args.m index e1954ecc2891..31f634dd8013 100644 --- clang/test/ClangScanDeps/strip-input-args.m +++ clang/test/ClangScanDeps/strip-input-args.m @@ -11,11 +11,6 @@ // CHECK: "modules": [ // CHECK-NEXT: { -// CHECK: "command-line": [ -// CHECK-NOT: "-arcmt-action=check" -// CHECK-NOT: "-objcmt-migrate-literals" -// CHECK-NOT: "-mt-migrate-directory" -// CHECK: ] // CHECK: "name": "A" // CHECK: } // CHECK-NOT: "name": "A" @@ -25,12 +20,12 @@ [ { "directory": "DIR", - "command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -ccc-arcmt-check -fsyntax-only DIR/t1.m", + "command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -fsyntax-only DIR/t1.m", "file": "DIR/t1.m" }, { "directory": "DIR", - "command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -ccc-objcmt-migrate bob -fsyntax-only DIR/t2.m", + "command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -fsyntax-only DIR/t2.m", "file": "DIR/t2.m" } ] diff --git clang/test/CodeGen/AArch64/args.cpp clang/test/CodeGen/AArch64/args.cpp index fe1298cc683a..6f1f3d5e2a06 100644 --- clang/test/CodeGen/AArch64/args.cpp +++ clang/test/CodeGen/AArch64/args.cpp @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -triple arm64-apple-ios7.0 -target-abi darwinpcs -emit-llvm -o - %s | FileCheck %s -// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - -x c %s | FileCheck %s --check-prefix=CHECK-GNU-C -// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-GNU-CXX +// RUN: %clang_cc1 -triple arm64-apple-ios7.0 -target-abi darwinpcs -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,DARWIN +// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - -x c %s | FileCheck %s --check-prefixes=CHECK,C +// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,CXX // Empty structs are ignored for PCS purposes on Darwin and in C mode elsewhere. // In C++ mode on ELF they consume a register slot though. Functions are @@ -15,16 +15,16 @@ struct Empty {}; -// CHECK: define{{.*}} i32 @empty_arg(i32 noundef %a) -// CHECK-GNU-C: define{{.*}} i32 @empty_arg(i32 noundef %a) -// CHECK-GNU-CXX: define{{.*}} i32 @empty_arg(i8 %e.coerce, i32 noundef %a) +// DARWIN: define{{.*}} i32 @empty_arg(i32 noundef %a) +// C: define{{.*}} i32 @empty_arg(i32 noundef %a) +// CXX: define{{.*}} i32 @empty_arg(i8 %e.coerce, i32 noundef %a) EXTERNC int empty_arg(struct Empty e, int a) { return a; } -// CHECK: define{{.*}} void @empty_ret() -// CHECK-GNU-C: define{{.*}} void @empty_ret() -// CHECK-GNU-CXX: define{{.*}} void @empty_ret() +// DARWIN: define{{.*}} void @empty_ret() +// C: define{{.*}} void @empty_ret() +// CXX: define{{.*}} void @empty_ret() EXTERNC struct Empty empty_ret(void) { struct Empty e; return e; @@ -38,30 +38,75 @@ struct SuperEmpty { int arr[0]; }; -// CHECK: define{{.*}} i32 @super_empty_arg(i32 noundef %a) -// CHECK-GNU-C: define{{.*}} i32 @super_empty_arg(i32 noundef %a) -// CHECK-GNU-CXX: define{{.*}} i32 @super_empty_arg(i32 noundef %a) +// DARWIN: define{{.*}} i32 @super_empty_arg(i32 noundef %a) +// C: define{{.*}} i32 @super_empty_arg(i32 noundef %a) +// CXX: define{{.*}} i32 @super_empty_arg(i32 noundef %a) EXTERNC int super_empty_arg(struct SuperEmpty e, int a) { return a; } -// This is not empty. It has 0 size but consumes a register slot for GCC. +// This is also not empty, and non-standard. We previously considered it to +// consume a register slot, but GCC does not, so we match that. struct SortOfEmpty { struct SuperEmpty e; }; -// CHECK: define{{.*}} i32 @sort_of_empty_arg(i32 noundef %a) -// CHECK-GNU-C: define{{.*}} i32 @sort_of_empty_arg(i32 noundef %a) -// CHECK-GNU-CXX: define{{.*}} i32 @sort_of_empty_arg(i8 %e.coerce, i32 noundef %a) -EXTERNC int sort_of_empty_arg(struct Empty e, int a) { +// DARWIN: define{{.*}} i32 @sort_of_empty_arg(i32 noundef %a) +// C: define{{.*}} i32 @sort_of_empty_arg(i32 noundef %a) +// CXX: define{{.*}} i32 @sort_of_empty_arg(i32 noundef %a) +EXTERNC int sort_of_empty_arg(struct SortOfEmpty e, int a) { return a; } -// CHECK: define{{.*}} void @sort_of_empty_ret() -// CHECK-GNU-C: define{{.*}} void @sort_of_empty_ret() -// CHECK-GNU-CXX: define{{.*}} void @sort_of_empty_ret() +// DARWIN: define{{.*}} void @sort_of_empty_ret() +// C: define{{.*}} void @sort_of_empty_ret() +// CXX: define{{.*}} void @sort_of_empty_ret() EXTERNC struct SortOfEmpty sort_of_empty_ret(void) { struct SortOfEmpty e; return e; } + +#include <stdarg.h> + +// va_arg matches the above rules, consuming an incoming argument in cases +// where one would be passed, and not doing so when the argument should be +// ignored. + +EXTERNC struct Empty empty_arg_variadic(int a, ...) { +// CHECK-LABEL: @empty_arg_variadic( +// DARWIN-NOT: {{ getelementptr }} +// C-NOT: {{ getelementptr }} +// CXX: %new_reg_offs = add i32 %gr_offs, 8 +// CXX: %new_stack = getelementptr inbounds i8, ptr %stack, i64 8 + va_list vl; + va_start(vl, a); + struct Empty b = va_arg(vl, struct Empty); + va_end(vl); + return b; +} + +EXTERNC struct SuperEmpty super_empty_arg_variadic(int a, ...) { +// CHECK-LABEL: @super_empty_arg_variadic( +// DARWIN-NOT: {{ getelementptr }} +// C-NOT: {{ getelementptr }} +// CXX-NOT: {{ getelementptr }} + va_list vl; + va_start(vl, a); + struct SuperEmpty b = va_arg(vl, struct SuperEmpty); + va_end(vl); + return b; +} + +EXTERNC struct SortOfEmpty sort_of_empty_arg_variadic(int a, ...) { +// CHECK-LABEL: @sort_of_empty_arg_variadic( +// DARWIN: %argp.next = getelementptr inbounds i8, ptr %argp.cur, i64 0 +// C-NOT: {{ getelementptr }} +// CXX-NOT: {{ getelementptr }} + va_list vl; + va_start(vl, a); + struct SortOfEmpty b = va_arg(vl, struct SortOfEmpty); + va_end(vl); + return b; +} + diff --git clang/test/CodeGen/AArch64/builtin-shufflevector-fp8.c clang/test/CodeGen/AArch64/builtin-shufflevector-fp8.c new file mode 100644 index 000000000000..147ca1d1becc --- /dev/null +++ clang/test/CodeGen/AArch64/builtin-shufflevector-fp8.c @@ -0,0 +1,123 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -triple aarch64-linux -target-feature +neon -disable-O0-optnone -emit-llvm -o - %s | opt -S -passes=mem2reg | FileCheck %s + +// REQUIRES: aarch64-registered-target + +typedef __attribute__((neon_vector_type(8))) signed char int8x8_t; +typedef __attribute__((neon_vector_type(16))) signed char int8x16_t; + +typedef __attribute__((neon_vector_type(8))) __mfp8 mfloat8x8_t; +typedef __attribute__((neon_vector_type(16))) __mfp8 mfloat8x16_t; + +// CHECK-LABEL: define dso_local <8 x i8> @test_8x8( +// CHECK-SAME: <8 x i8> [[X:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[SHUFFLE:%.*]] = shufflevector <8 x i8> [[X]], <8 x i8> [[X]], <8 x i32> <i32 3, i32 2, i32 1, i32 0, i32 3, i32 2, i32 1, i32 0> +// CHECK-NEXT: ret <8 x i8> [[SHUFFLE]] +// +mfloat8x8_t test_8x8(mfloat8x8_t x) { + return __builtin_shufflevector(x, x, 3, 2, 1, 0, 3, 2, 1, 0); +} + +// CHECK-LABEL: define dso_local <8 x i8> @test_8x8_v( +// CHECK-SAME: <8 x i8> [[X:%.*]], <8 x i8> noundef [[P:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[MASK:%.*]] = and <8 x i8> [[P]], splat (i8 7) +// CHECK-NEXT: [[SHUF_IDX:%.*]] = extractelement <8 x i8> [[MASK]], i64 0 +// CHECK-NEXT: [[SHUF_ELT:%.*]] = extractelement <8 x i8> [[X]], i8 [[SHUF_IDX]] +// CHECK-NEXT: [[SHUF_INS:%.*]] = insertelement <8 x i8> poison, i8 [[SHUF_ELT]], i64 0 +// CHECK-NEXT: [[SHUF_IDX1:%.*]] = extractelement <8 x i8> [[MASK]], i64 1 +// CHECK-NEXT: [[SHUF_ELT2:%.*]] = extractelement <8 x i8> [[X]], i8 [[SHUF_IDX1]] +// CHECK-NEXT: [[SHUF_INS3:%.*]] = insertelement <8 x i8> [[SHUF_INS]], i8 [[SHUF_ELT2]], i64 1 +// CHECK-NEXT: [[SHUF_IDX4:%.*]] = extractelement <8 x i8> [[MASK]], i64 2 +// CHECK-NEXT: [[SHUF_ELT5:%.*]] = extractelement <8 x i8> [[X]], i8 [[SHUF_IDX4]] +// CHECK-NEXT: [[SHUF_INS6:%.*]] = insertelement <8 x i8> [[SHUF_INS3]], i8 [[SHUF_ELT5]], i64 2 +// CHECK-NEXT: [[SHUF_IDX7:%.*]] = extractelement <8 x i8> [[MASK]], i64 3 +// CHECK-NEXT: [[SHUF_ELT8:%.*]] = extractelement <8 x i8> [[X]], i8 [[SHUF_IDX7]] +// CHECK-NEXT: [[SHUF_INS9:%.*]] = insertelement <8 x i8> [[SHUF_INS6]], i8 [[SHUF_ELT8]], i64 3 +// CHECK-NEXT: [[SHUF_IDX10:%.*]] = extractelement <8 x i8> [[MASK]], i64 4 +// CHECK-NEXT: [[SHUF_ELT11:%.*]] = extractelement <8 x i8> [[X]], i8 [[SHUF_IDX10]] +// CHECK-NEXT: [[SHUF_INS12:%.*]] = insertelement <8 x i8> [[SHUF_INS9]], i8 [[SHUF_ELT11]], i64 4 +// CHECK-NEXT: [[SHUF_IDX13:%.*]] = extractelement <8 x i8> [[MASK]], i64 5 +// CHECK-NEXT: [[SHUF_ELT14:%.*]] = extractelement <8 x i8> [[X]], i8 [[SHUF_IDX13]] +// CHECK-NEXT: [[SHUF_INS15:%.*]] = insertelement <8 x i8> [[SHUF_INS12]], i8 [[SHUF_ELT14]], i64 5 +// CHECK-NEXT: [[SHUF_IDX16:%.*]] = extractelement <8 x i8> [[MASK]], i64 6 +// CHECK-NEXT: [[SHUF_ELT17:%.*]] = extractelement <8 x i8> [[X]], i8 [[SHUF_IDX16]] +// CHECK-NEXT: [[SHUF_INS18:%.*]] = insertelement <8 x i8> [[SHUF_INS15]], i8 [[SHUF_ELT17]], i64 6 +// CHECK-NEXT: [[SHUF_IDX19:%.*]] = extractelement <8 x i8> [[MASK]], i64 7 +// CHECK-NEXT: [[SHUF_ELT20:%.*]] = extractelement <8 x i8> [[X]], i8 [[SHUF_IDX19]] +// CHECK-NEXT: [[SHUF_INS21:%.*]] = insertelement <8 x i8> [[SHUF_INS18]], i8 [[SHUF_ELT20]], i64 7 +// CHECK-NEXT: ret <8 x i8> [[SHUF_INS21]] +// +mfloat8x8_t test_8x8_v(mfloat8x8_t x, int8x8_t p) { + return __builtin_shufflevector(x, p); +} + +// CHECK-LABEL: define dso_local <16 x i8> @test_8x16( +// CHECK-SAME: <16 x i8> [[X:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[SHUFFLE:%.*]] = shufflevector <16 x i8> [[X]], <16 x i8> [[X]], <16 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0> +// CHECK-NEXT: ret <16 x i8> [[SHUFFLE]] +// +mfloat8x16_t test_8x16(mfloat8x16_t x) { + return __builtin_shufflevector(x, x, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, + 1, 0); +} + +// CHECK-LABEL: define dso_local <16 x i8> @test_8x16_v( +// CHECK-SAME: <16 x i8> [[X:%.*]], <16 x i8> noundef [[P:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[MASK:%.*]] = and <16 x i8> [[P]], splat (i8 15) +// CHECK-NEXT: [[SHUF_IDX:%.*]] = extractelement <16 x i8> [[MASK]], i64 0 +// CHECK-NEXT: [[SHUF_ELT:%.*]] = extractelement <16 x i8> [[X]], i8 [[SHUF_IDX]] +// CHECK-NEXT: [[SHUF_INS:%.*]] = insertelement <16 x i8> poison, i8 [[SHUF_ELT]], i64 0 +// CHECK-NEXT: [[SHUF_IDX1:%.*]] = extractelement <16 x i8> [[MASK]], i64 1 +// CHECK-NEXT: [[SHUF_ELT2:%.*]] = extractelement <16 x i8> [[X]], i8 [[SHUF_IDX1]] +// CHECK-NEXT: [[SHUF_INS3:%.*]] = insertelement <16 x i8> [[SHUF_INS]], i8 [[SHUF_ELT2]], i64 1 +// CHECK-NEXT: [[SHUF_IDX4:%.*]] = extractelement <16 x i8> [[MASK]], i64 2 +// CHECK-NEXT: [[SHUF_ELT5:%.*]] = extractelement <16 x i8> [[X]], i8 [[SHUF_IDX4]] +// CHECK-NEXT: [[SHUF_INS6:%.*]] = insertelement <16 x i8> [[SHUF_INS3]], i8 [[SHUF_ELT5]], i64 2 +// CHECK-NEXT: [[SHUF_IDX7:%.*]] = extractelement <16 x i8> [[MASK]], i64 3 +// CHECK-NEXT: [[SHUF_ELT8:%.*]] = extractelement <16 x i8> [[X]], i8 [[SHUF_IDX7]] +// CHECK-NEXT: [[SHUF_INS9:%.*]] = insertelement <16 x i8> [[SHUF_INS6]], i8 [[SHUF_ELT8]], i64 3 +// CHECK-NEXT: [[SHUF_IDX10:%.*]] = extractelement <16 x i8> [[MASK]], i64 4 +// CHECK-NEXT: [[SHUF_ELT11:%.*]] = extractelement <16 x i8> [[X]], i8 [[SHUF_IDX10]] +// CHECK-NEXT: [[SHUF_INS12:%.*]] = insertelement <16 x i8> [[SHUF_INS9]], i8 [[SHUF_ELT11]], i64 4 +// CHECK-NEXT: [[SHUF_IDX13:%.*]] = extractelement <16 x i8> [[MASK]], i64 5 +// CHECK-NEXT: [[SHUF_ELT14:%.*]] = extractelement <16 x i8> [[X]], i8 [[SHUF_IDX13]] +// CHECK-NEXT: [[SHUF_INS15:%.*]] = insertelement <16 x i8> [[SHUF_INS12]], i8 [[SHUF_ELT14]], i64 5 +// CHECK-NEXT: [[SHUF_IDX16:%.*]] = extractelement <16 x i8> [[MASK]], i64 6 +// CHECK-NEXT: [[SHUF_ELT17:%.*]] = extractelement <16 x i8> [[X]], i8 [[SHUF_IDX16]] +// CHECK-NEXT: [[SHUF_INS18:%.*]] = insertelement <16 x i8> [[SHUF_INS15]], i8 [[SHUF_ELT17]], i64 6 +// CHECK-NEXT: [[SHUF_IDX19:%.*]] = extractelement <16 x i8> [[MASK]], i64 7 +// CHECK-NEXT: [[SHUF_ELT20:%.*]] = extractelement <16 x i8> [[X]], i8 [[SHUF_IDX19]] +// CHECK-NEXT: [[SHUF_INS21:%.*]] = insertelement <16 x i8> [[SHUF_INS18]], i8 [[SHUF_ELT20]], i64 7 +// CHECK-NEXT: [[SHUF_IDX22:%.*]] = extractelement <16 x i8> [[MASK]], i64 8 +// CHECK-NEXT: [[SHUF_ELT23:%.*]] = extractelement <16 x i8> [[X]], i8 [[SHUF_IDX22]] +// CHECK-NEXT: [[SHUF_INS24:%.*]] = insertelement <16 x i8> [[SHUF_INS21]], i8 [[SHUF_ELT23]], i64 8 +// CHECK-NEXT: [[SHUF_IDX25:%.*]] = extractelement <16 x i8> [[MASK]], i64 9 +// CHECK-NEXT: [[SHUF_ELT26:%.*]] = extractelement <16 x i8> [[X]], i8 [[SHUF_IDX25]] +// CHECK-NEXT: [[SHUF_INS27:%.*]] = insertelement <16 x i8> [[SHUF_INS24]], i8 [[SHUF_ELT26]], i64 9 +// CHECK-NEXT: [[SHUF_IDX28:%.*]] = extractelement <16 x i8> [[MASK]], i64 10 +// CHECK-NEXT: [[SHUF_ELT29:%.*]] = extractelement <16 x i8> [[X]], i8 [[SHUF_IDX28]] +// CHECK-NEXT: [[SHUF_INS30:%.*]] = insertelement <16 x i8> [[SHUF_INS27]], i8 [[SHUF_ELT29]], i64 10 +// CHECK-NEXT: [[SHUF_IDX31:%.*]] = extractelement <16 x i8> [[MASK]], i64 11 +// CHECK-NEXT: [[SHUF_ELT32:%.*]] = extractelement <16 x i8> [[X]], i8 [[SHUF_IDX31]] +// CHECK-NEXT: [[SHUF_INS33:%.*]] = insertelement <16 x i8> [[SHUF_INS30]], i8 [[SHUF_ELT32]], i64 11 +// CHECK-NEXT: [[SHUF_IDX34:%.*]] = extractelement <16 x i8> [[MASK]], i64 12 +// CHECK-NEXT: [[SHUF_ELT35:%.*]] = extractelement <16 x i8> [[X]], i8 [[SHUF_IDX34]] +// CHECK-NEXT: [[SHUF_INS36:%.*]] = insertelement <16 x i8> [[SHUF_INS33]], i8 [[SHUF_ELT35]], i64 12 +// CHECK-NEXT: [[SHUF_IDX37:%.*]] = extractelement <16 x i8> [[MASK]], i64 13 +// CHECK-NEXT: [[SHUF_ELT38:%.*]] = extractelement <16 x i8> [[X]], i8 [[SHUF_IDX37]] +// CHECK-NEXT: [[SHUF_INS39:%.*]] = insertelement <16 x i8> [[SHUF_INS36]], i8 [[SHUF_ELT38]], i64 13 +// CHECK-NEXT: [[SHUF_IDX40:%.*]] = extractelement <16 x i8> [[MASK]], i64 14 +// CHECK-NEXT: [[SHUF_ELT41:%.*]] = extractelement <16 x i8> [[X]], i8 [[SHUF_IDX40]] +// CHECK-NEXT: [[SHUF_INS42:%.*]] = insertelement <16 x i8> [[SHUF_INS39]], i8 [[SHUF_ELT41]], i64 14 +// CHECK-NEXT: [[SHUF_IDX43:%.*]] = extractelement <16 x i8> [[MASK]], i64 15 +// CHECK-NEXT: [[SHUF_ELT44:%.*]] = extractelement <16 x i8> [[X]], i8 [[SHUF_IDX43]] +// CHECK-NEXT: [[SHUF_INS45:%.*]] = insertelement <16 x i8> [[SHUF_INS42]], i8 [[SHUF_ELT44]], i64 15 +// CHECK-NEXT: ret <16 x i8> [[SHUF_INS45]] +// +mfloat8x16_t test_8x16_v(mfloat8x16_t x, int8x16_t p) { + return __builtin_shufflevector(x, p); +} diff --git clang/test/CodeGen/AArch64/fp8-cast.c clang/test/CodeGen/AArch64/fp8-cast.c new file mode 100644 index 000000000000..a9ce31b9e6be --- /dev/null +++ clang/test/CodeGen/AArch64/fp8-cast.c @@ -0,0 +1,193 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg | FileCheck %s +// RUN: %clang_cc1 -x c++ -triple aarch64-none-linux-gnu -target-feature +neon -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg | FileCheck %s -check-prefix CHECK-CXX + +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon -disable-O0-optnone -Werror -Wall -S -o /dev/null %s + +// REQUIRES: aarch64-registered-target + +#include <arm_neon.h> + +// Bitcast between FP8 Neon vectors +// CHECK-LABEL: define dso_local <8 x i8> @test_f8_f8( +// CHECK-SAME: <8 x i8> [[X:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: ret <8 x i8> [[X]] +// +// CHECK-CXX-LABEL: define dso_local <8 x i8> @_Z10test_f8_f813__Mfloat8x8_t( +// CHECK-CXX-SAME: <8 x i8> [[X:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: ret <8 x i8> [[X]] +// +mfloat8x8_t test_f8_f8(mfloat8x8_t x) { + return (mfloat8x8_t) x; +} + +// CHECK-LABEL: define dso_local <16 x i8> @testq_f8_f8( +// CHECK-SAME: <16 x i8> [[X:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: ret <16 x i8> [[X]] +// +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z11testq_f8_f814__Mfloat8x16_t( +// CHECK-CXX-SAME: <16 x i8> [[X:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: ret <16 x i8> [[X]] +// +mfloat8x16_t testq_f8_f8(mfloat8x16_t x) { + return (mfloat8x16_t) x; +} + +// Bitcast between FP8 and int8 Neon vectors +// CHECK-LABEL: define dso_local <8 x i8> @test_f8_s8( +// CHECK-SAME: <8 x i8> noundef [[X:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: ret <8 x i8> [[X]] +// +// CHECK-CXX-LABEL: define dso_local <8 x i8> @_Z10test_f8_s810__Int8x8_t( +// CHECK-CXX-SAME: <8 x i8> noundef [[X:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: ret <8 x i8> [[X]] +// +mfloat8x8_t test_f8_s8(int8x8_t x) { + return (mfloat8x8_t) x; +} + +// CHECK-LABEL: define dso_local <8 x i8> @test_s8_f8( +// CHECK-SAME: <8 x i8> [[X:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: ret <8 x i8> [[X]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x i8> @_Z10test_s8_f813__Mfloat8x8_t( +// CHECK-CXX-SAME: <8 x i8> [[X:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: ret <8 x i8> [[X]] +// +int8x8_t test_s8_f8(mfloat8x8_t x) { + return (int8x8_t) x; +} + +// CHECK-LABEL: define dso_local <16 x i8> @testq_f8_s8( +// CHECK-SAME: <16 x i8> noundef [[X:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: ret <16 x i8> [[X]] +// +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z11testq_f8_s811__Int8x16_t( +// CHECK-CXX-SAME: <16 x i8> noundef [[X:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: ret <16 x i8> [[X]] +// +mfloat8x16_t testq_f8_s8(int8x16_t x) { + return (mfloat8x16_t) x; +} + +// CHECK-LABEL: define dso_local <16 x i8> @testq_s8_f8( +// CHECK-SAME: <16 x i8> [[X:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: ret <16 x i8> [[X]] +// +// CHECK-CXX-LABEL: define dso_local noundef <16 x i8> @_Z11testq_s8_f814__Mfloat8x16_t( +// CHECK-CXX-SAME: <16 x i8> [[X:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: ret <16 x i8> [[X]] +// +int8x16_t testq_s8_f8(mfloat8x16_t x) { + return (int8x16_t) x; +} + +// Bitcast between FP8 and float32 Neon vectors +// CHECK-LABEL: define dso_local <8 x i8> @test_f8_f32( +// CHECK-SAME: <2 x float> noundef [[X:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <2 x float> [[X]] to <8 x i8> +// CHECK-NEXT: ret <8 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <8 x i8> @_Z11test_f8_f3213__Float32x2_t( +// CHECK-CXX-SAME: <2 x float> noundef [[X:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <2 x float> [[X]] to <8 x i8> +// CHECK-CXX-NEXT: ret <8 x i8> [[TMP0]] +// +mfloat8x8_t test_f8_f32(float32x2_t x) { + return (mfloat8x8_t) x; +} + +// CHECK-LABEL: define dso_local <2 x float> @test_f32_f8( +// CHECK-SAME: <8 x i8> [[X:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[X]] to <2 x float> +// CHECK-NEXT: ret <2 x float> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <2 x float> @_Z11test_f32_f813__Mfloat8x8_t( +// CHECK-CXX-SAME: <8 x i8> [[X:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[X]] to <2 x float> +// CHECK-CXX-NEXT: ret <2 x float> [[TMP0]] +// +float32x2_t test_f32_f8(mfloat8x8_t x) { + return (float32x2_t) x; +} + +// CHECK-LABEL: define dso_local <16 x i8> @testq_f8_f32( +// CHECK-SAME: <4 x float> noundef [[X:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <4 x float> [[X]] to <16 x i8> +// CHECK-NEXT: ret <16 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z12testq_f8_f3213__Float32x4_t( +// CHECK-CXX-SAME: <4 x float> noundef [[X:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <4 x float> [[X]] to <16 x i8> +// CHECK-CXX-NEXT: ret <16 x i8> [[TMP0]] +// +mfloat8x16_t testq_f8_f32(float32x4_t x) { + return (mfloat8x16_t) x; +} + +// CHECK-LABEL: define dso_local <4 x float> @testq_f32_f8( +// CHECK-SAME: <16 x i8> [[X:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[X]] to <4 x float> +// CHECK-NEXT: ret <4 x float> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x float> @_Z12testq_f32_f814__Mfloat8x16_t( +// CHECK-CXX-SAME: <16 x i8> [[X:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[X]] to <4 x float> +// CHECK-CXX-NEXT: ret <4 x float> [[TMP0]] +// +float32x4_t testq_f32_f8(mfloat8x16_t x) { + return (float32x4_t) x; +} + +// Bitcast between FP8 and poly128_t (which is integral) +// CHECK-LABEL: define dso_local <16 x i8> @testq_f8_p128( +// CHECK-SAME: i128 noundef [[X:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast i128 [[X]] to <16 x i8> +// CHECK-NEXT: ret <16 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z13testq_f8_p128o( +// CHECK-CXX-SAME: i128 noundef [[X:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast i128 [[X]] to <16 x i8> +// CHECK-CXX-NEXT: ret <16 x i8> [[TMP0]] +// +mfloat8x16_t testq_f8_p128(poly128_t x) { + return (mfloat8x16_t) x; +} + +// CHECK-LABEL: define dso_local i128 @testq_p128_f8( +// CHECK-SAME: <16 x i8> [[X:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[X]] to i128 +// CHECK-NEXT: ret i128 [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef i128 @_Z13testq_p128_f814__Mfloat8x16_t( +// CHECK-CXX-SAME: <16 x i8> [[X:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[X]] to i128 +// CHECK-CXX-NEXT: ret i128 [[TMP0]] +// +poly128_t testq_p128_f8(mfloat8x16_t x) { + return (poly128_t) x; +} diff --git clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_cvt.c clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_cvt.c new file mode 100644 index 000000000000..4305b840f2a0 --- /dev/null +++ clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_cvt.c @@ -0,0 +1,316 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +bf16 -target-feature +fp8 -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg | FileCheck %s +// RUN: %clang_cc1 -x c++ -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +bf16 -target-feature +fp8 -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg | FileCheck %s -check-prefix CHECK-CXX + +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +bf16 -target-feature +fp8 -S -O3 -o /dev/null %s + +// REQUIRES: aarch64-registered-target + +#include <arm_neon.h> + +// CHECK-LABEL: define dso_local <8 x bfloat> @test_vcvt1_bf16_mf8_fpm( +// CHECK-SAME: <8 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VBFCVT1_I:%.*]] = call <8 x bfloat> @llvm.aarch64.neon.fp8.cvtl1.v8bf16.v8i8(<8 x i8> [[OP]]) +// CHECK-NEXT: ret <8 x bfloat> [[VBFCVT1_I]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x bfloat> @_Z23test_vcvt1_bf16_mf8_fpm13__Mfloat8x8_tm( +// CHECK-CXX-SAME: <8 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VBFCVT1_I:%.*]] = call <8 x bfloat> @llvm.aarch64.neon.fp8.cvtl1.v8bf16.v8i8(<8 x i8> [[OP]]) +// CHECK-CXX-NEXT: ret <8 x bfloat> [[VBFCVT1_I]] +// +bfloat16x8_t test_vcvt1_bf16_mf8_fpm(mfloat8x8_t op, fpm_t fpm) { + return vcvt1_bf16_mf8_fpm(op, fpm); +} + +// CHECK-LABEL: define dso_local <8 x bfloat> @test_vcvt1_low_bf16_mf8_fpm( +// CHECK-SAME: <16 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = call <8 x i8> @llvm.vector.extract.v8i8.v16i8(<16 x i8> [[OP]], i64 0) +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VBFCVT1_I:%.*]] = call <8 x bfloat> @llvm.aarch64.neon.fp8.cvtl1.v8bf16.v8i8(<8 x i8> [[TMP0]]) +// CHECK-NEXT: ret <8 x bfloat> [[VBFCVT1_I]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x bfloat> @_Z27test_vcvt1_low_bf16_mf8_fpm14__Mfloat8x16_tm( +// CHECK-CXX-SAME: <16 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = call <8 x i8> @llvm.vector.extract.v8i8.v16i8(<16 x i8> [[OP]], i64 0) +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VBFCVT1_I:%.*]] = call <8 x bfloat> @llvm.aarch64.neon.fp8.cvtl1.v8bf16.v8i8(<8 x i8> [[TMP0]]) +// CHECK-CXX-NEXT: ret <8 x bfloat> [[VBFCVT1_I]] +// +bfloat16x8_t test_vcvt1_low_bf16_mf8_fpm(mfloat8x16_t op, fpm_t fpm) { + return vcvt1_low_bf16_mf8_fpm(op, fpm); +} + +// CHECK-LABEL: define dso_local <8 x bfloat> @test_vcvt2_bf16_mf8_fpm( +// CHECK-SAME: <8 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VBFCVT2_I:%.*]] = call <8 x bfloat> @llvm.aarch64.neon.fp8.cvtl2.v8bf16.v8i8(<8 x i8> [[OP]]) +// CHECK-NEXT: ret <8 x bfloat> [[VBFCVT2_I]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x bfloat> @_Z23test_vcvt2_bf16_mf8_fpm13__Mfloat8x8_tm( +// CHECK-CXX-SAME: <8 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VBFCVT2_I:%.*]] = call <8 x bfloat> @llvm.aarch64.neon.fp8.cvtl2.v8bf16.v8i8(<8 x i8> [[OP]]) +// CHECK-CXX-NEXT: ret <8 x bfloat> [[VBFCVT2_I]] +// +bfloat16x8_t test_vcvt2_bf16_mf8_fpm(mfloat8x8_t op, fpm_t fpm) { + return vcvt2_bf16_mf8_fpm(op, fpm); +} + +// CHECK-LABEL: define dso_local <8 x bfloat> @test_vcvt2_low_bf16_mf8_fpm( +// CHECK-SAME: <16 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = call <8 x i8> @llvm.vector.extract.v8i8.v16i8(<16 x i8> [[OP]], i64 0) +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VBFCVT2_I:%.*]] = call <8 x bfloat> @llvm.aarch64.neon.fp8.cvtl2.v8bf16.v8i8(<8 x i8> [[TMP0]]) +// CHECK-NEXT: ret <8 x bfloat> [[VBFCVT2_I]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x bfloat> @_Z27test_vcvt2_low_bf16_mf8_fpm14__Mfloat8x16_tm( +// CHECK-CXX-SAME: <16 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = call <8 x i8> @llvm.vector.extract.v8i8.v16i8(<16 x i8> [[OP]], i64 0) +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VBFCVT2_I:%.*]] = call <8 x bfloat> @llvm.aarch64.neon.fp8.cvtl2.v8bf16.v8i8(<8 x i8> [[TMP0]]) +// CHECK-CXX-NEXT: ret <8 x bfloat> [[VBFCVT2_I]] +// +bfloat16x8_t test_vcvt2_low_bf16_mf8_fpm(mfloat8x16_t op, fpm_t fpm) { + return vcvt2_low_bf16_mf8_fpm(op, fpm); +} + +// CHECK-LABEL: define dso_local <8 x bfloat> @test_vcvt1_high_bf16_mf8_fpm( +// CHECK-SAME: <16 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VBFCVT1_I:%.*]] = call <8 x bfloat> @llvm.aarch64.neon.fp8.cvtl1.v8bf16.v16i8(<16 x i8> [[OP]]) +// CHECK-NEXT: ret <8 x bfloat> [[VBFCVT1_I]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x bfloat> @_Z28test_vcvt1_high_bf16_mf8_fpm14__Mfloat8x16_tm( +// CHECK-CXX-SAME: <16 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VBFCVT1_I:%.*]] = call <8 x bfloat> @llvm.aarch64.neon.fp8.cvtl1.v8bf16.v16i8(<16 x i8> [[OP]]) +// CHECK-CXX-NEXT: ret <8 x bfloat> [[VBFCVT1_I]] +// +bfloat16x8_t test_vcvt1_high_bf16_mf8_fpm(mfloat8x16_t op, fpm_t fpm) { + return vcvt1_high_bf16_mf8_fpm(op, fpm); +} + +// CHECK-LABEL: define dso_local <8 x bfloat> @test_vcvt2_high_bf16_mf8_fpm( +// CHECK-SAME: <16 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VBFCVT2_I:%.*]] = call <8 x bfloat> @llvm.aarch64.neon.fp8.cvtl2.v8bf16.v16i8(<16 x i8> [[OP]]) +// CHECK-NEXT: ret <8 x bfloat> [[VBFCVT2_I]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x bfloat> @_Z28test_vcvt2_high_bf16_mf8_fpm14__Mfloat8x16_tm( +// CHECK-CXX-SAME: <16 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VBFCVT2_I:%.*]] = call <8 x bfloat> @llvm.aarch64.neon.fp8.cvtl2.v8bf16.v16i8(<16 x i8> [[OP]]) +// CHECK-CXX-NEXT: ret <8 x bfloat> [[VBFCVT2_I]] +// +bfloat16x8_t test_vcvt2_high_bf16_mf8_fpm(mfloat8x16_t op, fpm_t fpm) { + return vcvt2_high_bf16_mf8_fpm(op, fpm); +} + +// CHECK-LABEL: define dso_local <8 x half> @test_vcvt1_f16_mf8_fpm( +// CHECK-SAME: <8 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VBFCVT1_I:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.cvtl1.v8f16.v8i8(<8 x i8> [[OP]]) +// CHECK-NEXT: ret <8 x half> [[VBFCVT1_I]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x half> @_Z22test_vcvt1_f16_mf8_fpm13__Mfloat8x8_tm( +// CHECK-CXX-SAME: <8 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VBFCVT1_I:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.cvtl1.v8f16.v8i8(<8 x i8> [[OP]]) +// CHECK-CXX-NEXT: ret <8 x half> [[VBFCVT1_I]] +// +float16x8_t test_vcvt1_f16_mf8_fpm(mfloat8x8_t op, fpm_t fpm) { + return vcvt1_f16_mf8_fpm(op, fpm); +} + +// CHECK-LABEL: define dso_local <8 x half> @test_vcvt1_low_f16_mf8_fpm( +// CHECK-SAME: <16 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = call <8 x i8> @llvm.vector.extract.v8i8.v16i8(<16 x i8> [[OP]], i64 0) +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VBFCVT1_I:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.cvtl1.v8f16.v8i8(<8 x i8> [[TMP0]]) +// CHECK-NEXT: ret <8 x half> [[VBFCVT1_I]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x half> @_Z26test_vcvt1_low_f16_mf8_fpm14__Mfloat8x16_tm( +// CHECK-CXX-SAME: <16 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = call <8 x i8> @llvm.vector.extract.v8i8.v16i8(<16 x i8> [[OP]], i64 0) +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VBFCVT1_I:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.cvtl1.v8f16.v8i8(<8 x i8> [[TMP0]]) +// CHECK-CXX-NEXT: ret <8 x half> [[VBFCVT1_I]] +// +float16x8_t test_vcvt1_low_f16_mf8_fpm(mfloat8x16_t op, fpm_t fpm) { + return vcvt1_low_f16_mf8_fpm(op, fpm); +} + +// CHECK-LABEL: define dso_local <8 x half> @test_vcvt2_f16_mf8_fpm( +// CHECK-SAME: <8 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VBFCVT2_I:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.cvtl2.v8f16.v8i8(<8 x i8> [[OP]]) +// CHECK-NEXT: ret <8 x half> [[VBFCVT2_I]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x half> @_Z22test_vcvt2_f16_mf8_fpm13__Mfloat8x8_tm( +// CHECK-CXX-SAME: <8 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VBFCVT2_I:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.cvtl2.v8f16.v8i8(<8 x i8> [[OP]]) +// CHECK-CXX-NEXT: ret <8 x half> [[VBFCVT2_I]] +// +float16x8_t test_vcvt2_f16_mf8_fpm(mfloat8x8_t op, fpm_t fpm) { + return vcvt2_f16_mf8_fpm(op, fpm); +} + +// CHECK-LABEL: define dso_local <8 x half> @test_vcvt2_low_f16_mf8_fpm( +// CHECK-SAME: <16 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = call <8 x i8> @llvm.vector.extract.v8i8.v16i8(<16 x i8> [[OP]], i64 0) +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VBFCVT2_I:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.cvtl2.v8f16.v8i8(<8 x i8> [[TMP0]]) +// CHECK-NEXT: ret <8 x half> [[VBFCVT2_I]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x half> @_Z26test_vcvt2_low_f16_mf8_fpm14__Mfloat8x16_tm( +// CHECK-CXX-SAME: <16 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = call <8 x i8> @llvm.vector.extract.v8i8.v16i8(<16 x i8> [[OP]], i64 0) +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VBFCVT2_I:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.cvtl2.v8f16.v8i8(<8 x i8> [[TMP0]]) +// CHECK-CXX-NEXT: ret <8 x half> [[VBFCVT2_I]] +// +float16x8_t test_vcvt2_low_f16_mf8_fpm(mfloat8x16_t op, fpm_t fpm) { + return vcvt2_low_f16_mf8_fpm(op, fpm); +} + +// CHECK-LABEL: define dso_local <8 x half> @test_vcvt1_high_f16_mf8_fpm( +// CHECK-SAME: <16 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VBFCVT1_I:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.cvtl1.v8f16.v16i8(<16 x i8> [[OP]]) +// CHECK-NEXT: ret <8 x half> [[VBFCVT1_I]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x half> @_Z27test_vcvt1_high_f16_mf8_fpm14__Mfloat8x16_tm( +// CHECK-CXX-SAME: <16 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VBFCVT1_I:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.cvtl1.v8f16.v16i8(<16 x i8> [[OP]]) +// CHECK-CXX-NEXT: ret <8 x half> [[VBFCVT1_I]] +// +float16x8_t test_vcvt1_high_f16_mf8_fpm(mfloat8x16_t op, fpm_t fpm) { + return vcvt1_high_f16_mf8_fpm(op, fpm); +} + +// CHECK-LABEL: define dso_local <8 x half> @test_vcvt2_high_f16_mf8_fpm( +// CHECK-SAME: <16 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VBFCVT2_I:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.cvtl2.v8f16.v16i8(<16 x i8> [[OP]]) +// CHECK-NEXT: ret <8 x half> [[VBFCVT2_I]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x half> @_Z27test_vcvt2_high_f16_mf8_fpm14__Mfloat8x16_tm( +// CHECK-CXX-SAME: <16 x i8> [[OP:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VBFCVT2_I:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.cvtl2.v8f16.v16i8(<16 x i8> [[OP]]) +// CHECK-CXX-NEXT: ret <8 x half> [[VBFCVT2_I]] +// +float16x8_t test_vcvt2_high_f16_mf8_fpm(mfloat8x16_t op, fpm_t fpm) { + return vcvt2_high_f16_mf8_fpm(op, fpm); +} + +// CHECK-LABEL: define dso_local <8 x i8> @test_vcvt_mf8_f32_fpm( +// CHECK-SAME: <4 x float> noundef [[VN:%.*]], <4 x float> noundef [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VFCVTN_I:%.*]] = call <8 x i8> @llvm.aarch64.neon.fp8.fcvtn.v8i8.v4f32(<4 x float> [[VN]], <4 x float> [[VM]]) +// CHECK-NEXT: ret <8 x i8> [[VFCVTN_I]] +// +// CHECK-CXX-LABEL: define dso_local <8 x i8> @_Z21test_vcvt_mf8_f32_fpm13__Float32x4_tS_m( +// CHECK-CXX-SAME: <4 x float> noundef [[VN:%.*]], <4 x float> noundef [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VFCVTN_I:%.*]] = call <8 x i8> @llvm.aarch64.neon.fp8.fcvtn.v8i8.v4f32(<4 x float> [[VN]], <4 x float> [[VM]]) +// CHECK-CXX-NEXT: ret <8 x i8> [[VFCVTN_I]] +// +mfloat8x8_t test_vcvt_mf8_f32_fpm(float32x4_t vn, float32x4_t vm, fpm_t fpm) { + return vcvt_mf8_f32_fpm(vn, vm, fpm); +} + +// CHECK-LABEL: define dso_local <16 x i8> @test_vcvt_high_mf8_f32_fpm( +// CHECK-SAME: <8 x i8> [[VD:%.*]], <4 x float> noundef [[VN:%.*]], <4 x float> noundef [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = call <16 x i8> @llvm.vector.insert.v16i8.v8i8(<16 x i8> poison, <8 x i8> [[VD]], i64 0) +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VFCVTN2_I:%.*]] = call <16 x i8> @llvm.aarch64.neon.fp8.fcvtn2.v16i8.v4f32(<16 x i8> [[TMP0]], <4 x float> [[VN]], <4 x float> [[VM]]) +// CHECK-NEXT: ret <16 x i8> [[VFCVTN2_I]] +// +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z26test_vcvt_high_mf8_f32_fpm13__Mfloat8x8_t13__Float32x4_tS0_m( +// CHECK-CXX-SAME: <8 x i8> [[VD:%.*]], <4 x float> noundef [[VN:%.*]], <4 x float> noundef [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = call <16 x i8> @llvm.vector.insert.v16i8.v8i8(<16 x i8> poison, <8 x i8> [[VD]], i64 0) +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VFCVTN2_I:%.*]] = call <16 x i8> @llvm.aarch64.neon.fp8.fcvtn2.v16i8.v4f32(<16 x i8> [[TMP0]], <4 x float> [[VN]], <4 x float> [[VM]]) +// CHECK-CXX-NEXT: ret <16 x i8> [[VFCVTN2_I]] +// +mfloat8x16_t test_vcvt_high_mf8_f32_fpm(mfloat8x8_t vd, float32x4_t vn, + float32x4_t vm, fpm_t fpm) { + return vcvt_high_mf8_f32_fpm(vd, vn, vm, fpm); +} + +// CHECK-LABEL: define dso_local <8 x i8> @test_vcvt_mf8_f16_fpm( +// CHECK-SAME: <4 x half> noundef [[VN:%.*]], <4 x half> noundef [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <4 x half> [[VN]] to <8 x i8> +// CHECK-NEXT: [[TMP1:%.*]] = bitcast <4 x half> [[VM]] to <8 x i8> +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VFCVTN2_I:%.*]] = call <8 x i8> @llvm.aarch64.neon.fp8.fcvtn.v8i8.v4f16(<4 x half> [[VN]], <4 x half> [[VM]]) +// CHECK-NEXT: ret <8 x i8> [[VFCVTN2_I]] +// +// CHECK-CXX-LABEL: define dso_local <8 x i8> @_Z21test_vcvt_mf8_f16_fpm13__Float16x4_tS_m( +// CHECK-CXX-SAME: <4 x half> noundef [[VN:%.*]], <4 x half> noundef [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <4 x half> [[VN]] to <8 x i8> +// CHECK-CXX-NEXT: [[TMP1:%.*]] = bitcast <4 x half> [[VM]] to <8 x i8> +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VFCVTN2_I:%.*]] = call <8 x i8> @llvm.aarch64.neon.fp8.fcvtn.v8i8.v4f16(<4 x half> [[VN]], <4 x half> [[VM]]) +// CHECK-CXX-NEXT: ret <8 x i8> [[VFCVTN2_I]] +// +mfloat8x8_t test_vcvt_mf8_f16_fpm(float16x4_t vn, float16x4_t vm, fpm_t fpm) { + return vcvt_mf8_f16_fpm(vn, vm, fpm); +} + +// CHECK-LABEL: define dso_local <16 x i8> @test_vcvtq_mf8_f16_fpm( +// CHECK-SAME: <8 x half> noundef [[VN:%.*]], <8 x half> noundef [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x half> [[VN]] to <16 x i8> +// CHECK-NEXT: [[TMP1:%.*]] = bitcast <8 x half> [[VM]] to <16 x i8> +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VFCVTN2_I:%.*]] = call <16 x i8> @llvm.aarch64.neon.fp8.fcvtn.v16i8.v8f16(<8 x half> [[VN]], <8 x half> [[VM]]) +// CHECK-NEXT: ret <16 x i8> [[VFCVTN2_I]] +// +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z22test_vcvtq_mf8_f16_fpm13__Float16x8_tS_m( +// CHECK-CXX-SAME: <8 x half> noundef [[VN:%.*]], <8 x half> noundef [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x half> [[VN]] to <16 x i8> +// CHECK-CXX-NEXT: [[TMP1:%.*]] = bitcast <8 x half> [[VM]] to <16 x i8> +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VFCVTN2_I:%.*]] = call <16 x i8> @llvm.aarch64.neon.fp8.fcvtn.v16i8.v8f16(<8 x half> [[VN]], <8 x half> [[VM]]) +// CHECK-CXX-NEXT: ret <16 x i8> [[VFCVTN2_I]] +// +mfloat8x16_t test_vcvtq_mf8_f16_fpm(float16x8_t vn, float16x8_t vm, fpm_t fpm) { + return vcvtq_mf8_f16_fpm(vn, vm, fpm); +} diff --git clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_fdot.c clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_fdot.c new file mode 100644 index 000000000000..4d2f5d550c4d --- /dev/null +++ clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_fdot.c @@ -0,0 +1,254 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 + +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +bf16 -target-feature +fp8 -target-feature +fp8dot2 -target-feature +fp8dot4 -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg | FileCheck %s +// RUN: %clang_cc1 -x c++ -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +bf16 -target-feature +fp8 -target-feature +fp8dot2 -target-feature +fp8dot4 -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg | FileCheck %s -check-prefix CHECK-CXX + +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +bf16 -target-feature +fp8 -target-feature +fp8dot2 -target-feature +fp8dot4 -O3 -Werror -Wall -S -o /dev/null %s + +// REQUIRES: aarch64-registered-target + +#include <arm_neon.h> + +// CHECK-LABEL: define dso_local <4 x half> @test_vdot_f16( +// CHECK-SAME: <4 x half> noundef [[VD:%.*]], <8 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <4 x half> [[VD]] to <8 x i8> +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-NEXT: [[FDOT21_I:%.*]] = call <4 x half> @llvm.aarch64.neon.fp8.fdot2.v4f16.v8i8(<4 x half> [[VD]], <8 x i8> [[VN]], <8 x i8> [[VM]]) +// CHECK-NEXT: ret <4 x half> [[FDOT21_I]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x half> @_Z13test_vdot_f1613__Float16x4_t13__Mfloat8x8_tS0_m( +// CHECK-CXX-SAME: <4 x half> noundef [[VD:%.*]], <8 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <4 x half> [[VD]] to <8 x i8> +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-CXX-NEXT: [[FDOT21_I:%.*]] = call <4 x half> @llvm.aarch64.neon.fp8.fdot2.v4f16.v8i8(<4 x half> [[VD]], <8 x i8> [[VN]], <8 x i8> [[VM]]) +// CHECK-CXX-NEXT: ret <4 x half> [[FDOT21_I]] +// +float16x4_t test_vdot_f16(float16x4_t vd, mfloat8x8_t vn, mfloat8x8_t vm, fpm_t fpmr) { + return vdot_f16_mf8_fpm(vd, vn, vm, fpmr); +} + +// CHECK-LABEL: define dso_local <8 x half> @test_vdotq_f16( +// CHECK-SAME: <8 x half> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x half> [[VD]] to <16 x i8> +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-NEXT: [[FDOT21_I:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.fdot2.v8f16.v16i8(<8 x half> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]]) +// CHECK-NEXT: ret <8 x half> [[FDOT21_I]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x half> @_Z14test_vdotq_f1613__Float16x8_t14__Mfloat8x16_tS0_m( +// CHECK-CXX-SAME: <8 x half> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x half> [[VD]] to <16 x i8> +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-CXX-NEXT: [[FDOT21_I:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.fdot2.v8f16.v16i8(<8 x half> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]]) +// CHECK-CXX-NEXT: ret <8 x half> [[FDOT21_I]] +// +float16x8_t test_vdotq_f16(float16x8_t vd, mfloat8x16_t vn, mfloat8x16_t vm, fpm_t fpmr) { + return vdotq_f16_mf8_fpm(vd, vn, vm, fpmr); +} + +// CHECK-LABEL: define dso_local <4 x half> @test_vdot_lane_f16( +// CHECK-SAME: <4 x half> noundef [[VD:%.*]], <8 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <4 x half> [[VD]] to <8 x i8> +// CHECK-NEXT: [[TMP1:%.*]] = call <16 x i8> @llvm.vector.insert.v16i8.v8i8(<16 x i8> poison, <8 x i8> [[VM]], i64 0) +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-NEXT: [[FDOT2_LANE:%.*]] = bitcast <8 x i8> [[TMP0]] to <4 x half> +// CHECK-NEXT: [[FDOT2_LANE1:%.*]] = call <4 x half> @llvm.aarch64.neon.fp8.fdot2.lane.v4f16.v8i8(<4 x half> [[FDOT2_LANE]], <8 x i8> [[VN]], <16 x i8> [[TMP1]], i32 3) +// CHECK-NEXT: ret <4 x half> [[FDOT2_LANE1]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x half> @_Z18test_vdot_lane_f1613__Float16x4_t13__Mfloat8x8_tS0_m( +// CHECK-CXX-SAME: <4 x half> noundef [[VD:%.*]], <8 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <4 x half> [[VD]] to <8 x i8> +// CHECK-CXX-NEXT: [[TMP1:%.*]] = call <16 x i8> @llvm.vector.insert.v16i8.v8i8(<16 x i8> poison, <8 x i8> [[VM]], i64 0) +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-CXX-NEXT: [[FDOT2_LANE:%.*]] = bitcast <8 x i8> [[TMP0]] to <4 x half> +// CHECK-CXX-NEXT: [[FDOT2_LANE1:%.*]] = call <4 x half> @llvm.aarch64.neon.fp8.fdot2.lane.v4f16.v8i8(<4 x half> [[FDOT2_LANE]], <8 x i8> [[VN]], <16 x i8> [[TMP1]], i32 3) +// CHECK-CXX-NEXT: ret <4 x half> [[FDOT2_LANE1]] +// +float16x4_t test_vdot_lane_f16(float16x4_t vd, mfloat8x8_t vn, mfloat8x8_t vm, fpm_t fpmr) { + return vdot_lane_f16_mf8_fpm(vd, vn, vm, 3, fpmr); +} + +// CHECK-LABEL: define dso_local <4 x half> @test_vdot_laneq_f16( +// CHECK-SAME: <4 x half> noundef [[VD:%.*]], <8 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <4 x half> [[VD]] to <8 x i8> +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-NEXT: [[FDOT2_LANE:%.*]] = bitcast <8 x i8> [[TMP0]] to <4 x half> +// CHECK-NEXT: [[FDOT2_LANE1:%.*]] = call <4 x half> @llvm.aarch64.neon.fp8.fdot2.lane.v4f16.v8i8(<4 x half> [[FDOT2_LANE]], <8 x i8> [[VN]], <16 x i8> [[VM]], i32 7) +// CHECK-NEXT: ret <4 x half> [[FDOT2_LANE1]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x half> @_Z19test_vdot_laneq_f1613__Float16x4_t13__Mfloat8x8_t14__Mfloat8x16_tm( +// CHECK-CXX-SAME: <4 x half> noundef [[VD:%.*]], <8 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <4 x half> [[VD]] to <8 x i8> +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-CXX-NEXT: [[FDOT2_LANE:%.*]] = bitcast <8 x i8> [[TMP0]] to <4 x half> +// CHECK-CXX-NEXT: [[FDOT2_LANE1:%.*]] = call <4 x half> @llvm.aarch64.neon.fp8.fdot2.lane.v4f16.v8i8(<4 x half> [[FDOT2_LANE]], <8 x i8> [[VN]], <16 x i8> [[VM]], i32 7) +// CHECK-CXX-NEXT: ret <4 x half> [[FDOT2_LANE1]] +// +float16x4_t test_vdot_laneq_f16(float16x4_t vd, mfloat8x8_t vn, mfloat8x16_t vm, fpm_t fpmr) { + return vdot_laneq_f16_mf8_fpm(vd, vn, vm, 7, fpmr); +} + +// CHECK-LABEL: define dso_local <8 x half> @test_vdotq_lane_f16( +// CHECK-SAME: <8 x half> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x half> [[VD]] to <16 x i8> +// CHECK-NEXT: [[TMP1:%.*]] = call <16 x i8> @llvm.vector.insert.v16i8.v8i8(<16 x i8> poison, <8 x i8> [[VM]], i64 0) +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-NEXT: [[FDOT2_LANE:%.*]] = bitcast <16 x i8> [[TMP0]] to <8 x half> +// CHECK-NEXT: [[FDOT2_LANE1:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.fdot2.lane.v8f16.v16i8(<8 x half> [[FDOT2_LANE]], <16 x i8> [[VN]], <16 x i8> [[TMP1]], i32 3) +// CHECK-NEXT: ret <8 x half> [[FDOT2_LANE1]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x half> @_Z19test_vdotq_lane_f1613__Float16x8_t14__Mfloat8x16_t13__Mfloat8x8_tm( +// CHECK-CXX-SAME: <8 x half> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x half> [[VD]] to <16 x i8> +// CHECK-CXX-NEXT: [[TMP1:%.*]] = call <16 x i8> @llvm.vector.insert.v16i8.v8i8(<16 x i8> poison, <8 x i8> [[VM]], i64 0) +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-CXX-NEXT: [[FDOT2_LANE:%.*]] = bitcast <16 x i8> [[TMP0]] to <8 x half> +// CHECK-CXX-NEXT: [[FDOT2_LANE1:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.fdot2.lane.v8f16.v16i8(<8 x half> [[FDOT2_LANE]], <16 x i8> [[VN]], <16 x i8> [[TMP1]], i32 3) +// CHECK-CXX-NEXT: ret <8 x half> [[FDOT2_LANE1]] +// +float16x8_t test_vdotq_lane_f16(float16x8_t vd, mfloat8x16_t vn, mfloat8x8_t vm, fpm_t fpmr) { + return vdotq_lane_f16_mf8_fpm(vd, vn, vm, 3, fpmr); +} + +// CHECK-LABEL: define dso_local <8 x half> @test_vdotq_laneq_f16( +// CHECK-SAME: <8 x half> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x half> [[VD]] to <16 x i8> +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-NEXT: [[FDOT2_LANE:%.*]] = bitcast <16 x i8> [[TMP0]] to <8 x half> +// CHECK-NEXT: [[FDOT2_LANE1:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.fdot2.lane.v8f16.v16i8(<8 x half> [[FDOT2_LANE]], <16 x i8> [[VN]], <16 x i8> [[VM]], i32 7) +// CHECK-NEXT: ret <8 x half> [[FDOT2_LANE1]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x half> @_Z20test_vdotq_laneq_f1613__Float16x8_t14__Mfloat8x16_tS0_m( +// CHECK-CXX-SAME: <8 x half> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x half> [[VD]] to <16 x i8> +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-CXX-NEXT: [[FDOT2_LANE:%.*]] = bitcast <16 x i8> [[TMP0]] to <8 x half> +// CHECK-CXX-NEXT: [[FDOT2_LANE1:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.fdot2.lane.v8f16.v16i8(<8 x half> [[FDOT2_LANE]], <16 x i8> [[VN]], <16 x i8> [[VM]], i32 7) +// CHECK-CXX-NEXT: ret <8 x half> [[FDOT2_LANE1]] +// +float16x8_t test_vdotq_laneq_f16(float16x8_t vd, mfloat8x16_t vn, mfloat8x16_t vm, fpm_t fpmr) { + return vdotq_laneq_f16_mf8_fpm(vd, vn, vm, 7, fpmr); +} + +// CHECK-LABEL: define dso_local <2 x float> @test_vdot_f32( +// CHECK-SAME: <2 x float> noundef [[VD:%.*]], <8 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-NEXT: [[FDOT4_I:%.*]] = call <2 x float> @llvm.aarch64.neon.fp8.fdot4.v2f32.v8i8(<2 x float> [[VD]], <8 x i8> [[VN]], <8 x i8> [[VM]]) +// CHECK-NEXT: ret <2 x float> [[FDOT4_I]] +// +// CHECK-CXX-LABEL: define dso_local noundef <2 x float> @_Z13test_vdot_f3213__Float32x2_t13__Mfloat8x8_tS0_m( +// CHECK-CXX-SAME: <2 x float> noundef [[VD:%.*]], <8 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-CXX-NEXT: [[FDOT4_I:%.*]] = call <2 x float> @llvm.aarch64.neon.fp8.fdot4.v2f32.v8i8(<2 x float> [[VD]], <8 x i8> [[VN]], <8 x i8> [[VM]]) +// CHECK-CXX-NEXT: ret <2 x float> [[FDOT4_I]] +// +float32x2_t test_vdot_f32(float32x2_t vd, mfloat8x8_t vn, mfloat8x8_t vm, fpm_t fpmr) { + return vdot_f32_mf8_fpm(vd, vn, vm, fpmr); +} + +// CHECK-LABEL: define dso_local <4 x float> @test_vdotq_f32( +// CHECK-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-NEXT: [[FDOT4_I:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fdot4.v4f32.v16i8(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]]) +// CHECK-NEXT: ret <4 x float> [[FDOT4_I]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x float> @_Z14test_vdotq_f3213__Float32x4_t14__Mfloat8x16_tS0_m( +// CHECK-CXX-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-CXX-NEXT: [[FDOT4_I:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fdot4.v4f32.v16i8(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]]) +// CHECK-CXX-NEXT: ret <4 x float> [[FDOT4_I]] +// +float32x4_t test_vdotq_f32(float32x4_t vd, mfloat8x16_t vn, mfloat8x16_t vm, fpm_t fpmr) { + return vdotq_f32_mf8_fpm(vd, vn, vm, fpmr); +} + +// CHECK-LABEL: define dso_local <2 x float> @test_vdot_lane_f32( +// CHECK-SAME: <2 x float> noundef [[VD:%.*]], <8 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = call <16 x i8> @llvm.vector.insert.v16i8.v8i8(<16 x i8> poison, <8 x i8> [[VM]], i64 0) +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-NEXT: [[FDOT4_LANE:%.*]] = call <2 x float> @llvm.aarch64.neon.fp8.fdot4.lane.v2f32.v8i8(<2 x float> [[VD]], <8 x i8> [[VN]], <16 x i8> [[TMP0]], i32 1) +// CHECK-NEXT: ret <2 x float> [[FDOT4_LANE]] +// +// CHECK-CXX-LABEL: define dso_local noundef <2 x float> @_Z18test_vdot_lane_f3213__Float32x2_t13__Mfloat8x8_tS0_m( +// CHECK-CXX-SAME: <2 x float> noundef [[VD:%.*]], <8 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = call <16 x i8> @llvm.vector.insert.v16i8.v8i8(<16 x i8> poison, <8 x i8> [[VM]], i64 0) +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-CXX-NEXT: [[FDOT4_LANE:%.*]] = call <2 x float> @llvm.aarch64.neon.fp8.fdot4.lane.v2f32.v8i8(<2 x float> [[VD]], <8 x i8> [[VN]], <16 x i8> [[TMP0]], i32 1) +// CHECK-CXX-NEXT: ret <2 x float> [[FDOT4_LANE]] +// +float32x2_t test_vdot_lane_f32(float32x2_t vd, mfloat8x8_t vn, mfloat8x8_t vm, fpm_t fpmr) { + return vdot_lane_f32_mf8_fpm(vd, vn, vm, 1, fpmr); +} + +// CHECK-LABEL: define dso_local <2 x float> @test_vdot_laneq_f32( +// CHECK-SAME: <2 x float> noundef [[VD:%.*]], <8 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-NEXT: [[FDOT4_LANE:%.*]] = call <2 x float> @llvm.aarch64.neon.fp8.fdot4.lane.v2f32.v8i8(<2 x float> [[VD]], <8 x i8> [[VN]], <16 x i8> [[VM]], i32 3) +// CHECK-NEXT: ret <2 x float> [[FDOT4_LANE]] +// +// CHECK-CXX-LABEL: define dso_local noundef <2 x float> @_Z19test_vdot_laneq_f3213__Float32x2_t13__Mfloat8x8_t14__Mfloat8x16_tm( +// CHECK-CXX-SAME: <2 x float> noundef [[VD:%.*]], <8 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-CXX-NEXT: [[FDOT4_LANE:%.*]] = call <2 x float> @llvm.aarch64.neon.fp8.fdot4.lane.v2f32.v8i8(<2 x float> [[VD]], <8 x i8> [[VN]], <16 x i8> [[VM]], i32 3) +// CHECK-CXX-NEXT: ret <2 x float> [[FDOT4_LANE]] +// +float32x2_t test_vdot_laneq_f32(float32x2_t vd, mfloat8x8_t vn, mfloat8x16_t vm, fpm_t fpmr) { + return vdot_laneq_f32_mf8_fpm(vd, vn, vm, 3, fpmr); +} + +// CHECK-LABEL: define dso_local <4 x float> @test_vdotq_lane_f32( +// CHECK-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = call <16 x i8> @llvm.vector.insert.v16i8.v8i8(<16 x i8> poison, <8 x i8> [[VM]], i64 0) +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-NEXT: [[FDOT4_LANE:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fdot4.lane.v4f32.v16i8(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[TMP0]], i32 1) +// CHECK-NEXT: ret <4 x float> [[FDOT4_LANE]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x float> @_Z19test_vdotq_lane_f3213__Float32x4_t14__Mfloat8x16_t13__Mfloat8x8_tm( +// CHECK-CXX-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = call <16 x i8> @llvm.vector.insert.v16i8.v8i8(<16 x i8> poison, <8 x i8> [[VM]], i64 0) +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-CXX-NEXT: [[FDOT4_LANE:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fdot4.lane.v4f32.v16i8(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[TMP0]], i32 1) +// CHECK-CXX-NEXT: ret <4 x float> [[FDOT4_LANE]] +// +float32x4_t test_vdotq_lane_f32(float32x4_t vd, mfloat8x16_t vn, mfloat8x8_t vm, fpm_t fpmr) { + return vdotq_lane_f32_mf8_fpm(vd, vn, vm, 1, fpmr); +} + +// CHECK-LABEL: define dso_local <4 x float> @test_vdotq_laneq_f32( +// CHECK-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-NEXT: [[FDOT4_LANE:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fdot4.lane.v4f32.v16i8(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]], i32 3) +// CHECK-NEXT: ret <4 x float> [[FDOT4_LANE]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x float> @_Z20test_vdotq_laneq_f3213__Float32x4_t14__Mfloat8x16_tS0_m( +// CHECK-CXX-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPMR:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPMR]]) +// CHECK-CXX-NEXT: [[FDOT4_LANE:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fdot4.lane.v4f32.v16i8(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]], i32 3) +// CHECK-CXX-NEXT: ret <4 x float> [[FDOT4_LANE]] +// +float32x4_t test_vdotq_laneq_f32(float32x4_t vd, mfloat8x16_t vn, mfloat8x16_t vm, fpm_t fpmr) { + return vdotq_laneq_f32_mf8_fpm(vd, vn, vm, 3, fpmr); +} diff --git clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_fmla.c clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_fmla.c new file mode 100644 index 000000000000..736538073cb3 --- /dev/null +++ clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_fmla.c @@ -0,0 +1,365 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +bf16 -target-feature +fp8 -target-feature +fp8fma -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg | FileCheck %s +// RUN: %clang_cc1 -x c++ -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +bf16 -target-feature +fp8 -target-feature +fp8fma -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg | FileCheck %s -check-prefix CHECK-CXX + +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +bf16 -target-feature +fp8 -target-feature +fp8fma -disable-O0-optnone -Werror -Wall -S -o /dev/null %s + +// REQUIRES: aarch64-registered-target + +#include <arm_neon.h> + +// CHECK-LABEL: define dso_local <8 x half> @test_vmlalb( +// CHECK-SAME: <8 x half> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x half> [[VD]] to <16 x i8> +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VMLAL1_I:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.fmlalb.v8f16(<8 x half> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]]) +// CHECK-NEXT: ret <8 x half> [[VMLAL1_I]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x half> @_Z11test_vmlalb13__Float16x8_t14__Mfloat8x16_tS0_m( +// CHECK-CXX-SAME: <8 x half> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x half> [[VD]] to <16 x i8> +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VMLAL1_I:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.fmlalb.v8f16(<8 x half> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]]) +// CHECK-CXX-NEXT: ret <8 x half> [[VMLAL1_I]] +// +float16x8_t test_vmlalb(float16x8_t vd, mfloat8x16_t vn, mfloat8x16_t vm, fpm_t fpm) { + return vmlalbq_f16_mf8_fpm(vd, vn, vm, fpm); +} + +// CHECK-LABEL: define dso_local <8 x half> @test_vmlalt( +// CHECK-SAME: <8 x half> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x half> [[VD]] to <16 x i8> +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VMLAL1_I:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.fmlalt.v8f16(<8 x half> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]]) +// CHECK-NEXT: ret <8 x half> [[VMLAL1_I]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x half> @_Z11test_vmlalt13__Float16x8_t14__Mfloat8x16_tS0_m( +// CHECK-CXX-SAME: <8 x half> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x half> [[VD]] to <16 x i8> +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VMLAL1_I:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.fmlalt.v8f16(<8 x half> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]]) +// CHECK-CXX-NEXT: ret <8 x half> [[VMLAL1_I]] +// +float16x8_t test_vmlalt(float16x8_t vd, mfloat8x16_t vn, mfloat8x16_t vm, fpm_t fpm) { + return vmlaltq_f16_mf8_fpm(vd, vn, vm, fpm); +} + +// CHECK-LABEL: define dso_local <4 x float> @test_vmlallbb( +// CHECK-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VMLALL_I:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlallbb.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]]) +// CHECK-NEXT: ret <4 x float> [[VMLALL_I]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x float> @_Z13test_vmlallbb13__Float32x4_t14__Mfloat8x16_tS0_m( +// CHECK-CXX-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VMLALL_I:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlallbb.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]]) +// CHECK-CXX-NEXT: ret <4 x float> [[VMLALL_I]] +// +float32x4_t test_vmlallbb(float32x4_t vd, mfloat8x16_t vn, mfloat8x16_t vm, fpm_t fpm) { + return vmlallbbq_f32_mf8_fpm(vd, vn, vm, fpm); +} + +// CHECK-LABEL: define dso_local <4 x float> @test_vmlallbt( +// CHECK-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VMLALL_I:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlallbt.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]]) +// CHECK-NEXT: ret <4 x float> [[VMLALL_I]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x float> @_Z13test_vmlallbt13__Float32x4_t14__Mfloat8x16_tS0_m( +// CHECK-CXX-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VMLALL_I:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlallbt.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]]) +// CHECK-CXX-NEXT: ret <4 x float> [[VMLALL_I]] +// +float32x4_t test_vmlallbt(float32x4_t vd, mfloat8x16_t vn, mfloat8x16_t vm, fpm_t fpm) { + return vmlallbtq_f32_mf8_fpm(vd, vn, vm, fpm); +} + +// CHECK-LABEL: define dso_local <4 x float> @test_vmlalltb( +// CHECK-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VMLALL_I:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlalltb.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]]) +// CHECK-NEXT: ret <4 x float> [[VMLALL_I]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x float> @_Z13test_vmlalltb13__Float32x4_t14__Mfloat8x16_tS0_m( +// CHECK-CXX-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VMLALL_I:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlalltb.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]]) +// CHECK-CXX-NEXT: ret <4 x float> [[VMLALL_I]] +// +float32x4_t test_vmlalltb(float32x4_t vd, mfloat8x16_t vn, mfloat8x16_t vm, fpm_t fpm) { + return vmlalltbq_f32_mf8_fpm(vd, vn, vm, fpm); +} + +// CHECK-LABEL: define dso_local <4 x float> @test_vmlalltt( +// CHECK-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VMLALL_I:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlalltt.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]]) +// CHECK-NEXT: ret <4 x float> [[VMLALL_I]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x float> @_Z13test_vmlalltt13__Float32x4_t14__Mfloat8x16_tS0_m( +// CHECK-CXX-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VMLALL_I:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlalltt.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]]) +// CHECK-CXX-NEXT: ret <4 x float> [[VMLALL_I]] +// +float32x4_t test_vmlalltt(float32x4_t vd, mfloat8x16_t vn, mfloat8x16_t vm, fpm_t fpm) { + return vmlallttq_f32_mf8_fpm(vd, vn, vm, fpm); +} + +// CHECK-LABEL: define dso_local <8 x half> @test_vmlalb_lane( +// CHECK-SAME: <8 x half> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x half> [[VD]] to <16 x i8> +// CHECK-NEXT: [[TMP1:%.*]] = call <16 x i8> @llvm.vector.insert.v16i8.v8i8(<16 x i8> poison, <8 x i8> [[VM]], i64 0) +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VMLAL_LANE:%.*]] = bitcast <16 x i8> [[TMP0]] to <8 x half> +// CHECK-NEXT: [[VMLAL_LANE1:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.fmlalb.lane.v8f16(<8 x half> [[VMLAL_LANE]], <16 x i8> [[VN]], <16 x i8> [[TMP1]], i32 0) +// CHECK-NEXT: ret <8 x half> [[VMLAL_LANE1]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x half> @_Z16test_vmlalb_lane13__Float16x8_t14__Mfloat8x16_t13__Mfloat8x8_tm( +// CHECK-CXX-SAME: <8 x half> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x half> [[VD]] to <16 x i8> +// CHECK-CXX-NEXT: [[TMP1:%.*]] = call <16 x i8> @llvm.vector.insert.v16i8.v8i8(<16 x i8> poison, <8 x i8> [[VM]], i64 0) +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VMLAL_LANE:%.*]] = bitcast <16 x i8> [[TMP0]] to <8 x half> +// CHECK-CXX-NEXT: [[VMLAL_LANE1:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.fmlalb.lane.v8f16(<8 x half> [[VMLAL_LANE]], <16 x i8> [[VN]], <16 x i8> [[TMP1]], i32 0) +// CHECK-CXX-NEXT: ret <8 x half> [[VMLAL_LANE1]] +// +float16x8_t test_vmlalb_lane(float16x8_t vd, mfloat8x16_t vn, mfloat8x8_t vm, fpm_t fpm) { + return vmlalbq_lane_f16_mf8_fpm(vd, vn, vm, 0, fpm); +} + +// CHECK-LABEL: define dso_local <8 x half> @test_vmlalb_laneq( +// CHECK-SAME: <8 x half> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x half> [[VD]] to <16 x i8> +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VMLAL_LANE:%.*]] = bitcast <16 x i8> [[TMP0]] to <8 x half> +// CHECK-NEXT: [[VMLAL_LANE1:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.fmlalb.lane.v8f16(<8 x half> [[VMLAL_LANE]], <16 x i8> [[VN]], <16 x i8> [[VM]], i32 0) +// CHECK-NEXT: ret <8 x half> [[VMLAL_LANE1]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x half> @_Z17test_vmlalb_laneq13__Float16x8_t14__Mfloat8x16_tS0_m( +// CHECK-CXX-SAME: <8 x half> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x half> [[VD]] to <16 x i8> +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VMLAL_LANE:%.*]] = bitcast <16 x i8> [[TMP0]] to <8 x half> +// CHECK-CXX-NEXT: [[VMLAL_LANE1:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.fmlalb.lane.v8f16(<8 x half> [[VMLAL_LANE]], <16 x i8> [[VN]], <16 x i8> [[VM]], i32 0) +// CHECK-CXX-NEXT: ret <8 x half> [[VMLAL_LANE1]] +// +float16x8_t test_vmlalb_laneq(float16x8_t vd, mfloat8x16_t vn, mfloat8x16_t vm, fpm_t fpm) { + return vmlalbq_laneq_f16_mf8_fpm(vd, vn, vm, 0, fpm); +} + +// CHECK-LABEL: define dso_local <8 x half> @test_vmlalt_lane( +// CHECK-SAME: <8 x half> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x half> [[VD]] to <16 x i8> +// CHECK-NEXT: [[TMP1:%.*]] = call <16 x i8> @llvm.vector.insert.v16i8.v8i8(<16 x i8> poison, <8 x i8> [[VM]], i64 0) +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VMLAL_LANE:%.*]] = bitcast <16 x i8> [[TMP0]] to <8 x half> +// CHECK-NEXT: [[VMLAL_LANE1:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.fmlalt.lane.v8f16(<8 x half> [[VMLAL_LANE]], <16 x i8> [[VN]], <16 x i8> [[TMP1]], i32 7) +// CHECK-NEXT: ret <8 x half> [[VMLAL_LANE1]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x half> @_Z16test_vmlalt_lane13__Float16x8_t14__Mfloat8x16_t13__Mfloat8x8_tm( +// CHECK-CXX-SAME: <8 x half> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x half> [[VD]] to <16 x i8> +// CHECK-CXX-NEXT: [[TMP1:%.*]] = call <16 x i8> @llvm.vector.insert.v16i8.v8i8(<16 x i8> poison, <8 x i8> [[VM]], i64 0) +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VMLAL_LANE:%.*]] = bitcast <16 x i8> [[TMP0]] to <8 x half> +// CHECK-CXX-NEXT: [[VMLAL_LANE1:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.fmlalt.lane.v8f16(<8 x half> [[VMLAL_LANE]], <16 x i8> [[VN]], <16 x i8> [[TMP1]], i32 7) +// CHECK-CXX-NEXT: ret <8 x half> [[VMLAL_LANE1]] +// +float16x8_t test_vmlalt_lane(float16x8_t vd, mfloat8x16_t vn, mfloat8x8_t vm, fpm_t fpm) { + return vmlaltq_lane_f16_mf8_fpm(vd, vn, vm, 7, fpm); +} + +// CHECK-LABEL: define dso_local <8 x half> @test_vmlalt_laneq( +// CHECK-SAME: <8 x half> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x half> [[VD]] to <16 x i8> +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VMLAL_LANE:%.*]] = bitcast <16 x i8> [[TMP0]] to <8 x half> +// CHECK-NEXT: [[VMLAL_LANE1:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.fmlalt.lane.v8f16(<8 x half> [[VMLAL_LANE]], <16 x i8> [[VN]], <16 x i8> [[VM]], i32 15) +// CHECK-NEXT: ret <8 x half> [[VMLAL_LANE1]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x half> @_Z17test_vmlalt_laneq13__Float16x8_t14__Mfloat8x16_tS0_m( +// CHECK-CXX-SAME: <8 x half> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x half> [[VD]] to <16 x i8> +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VMLAL_LANE:%.*]] = bitcast <16 x i8> [[TMP0]] to <8 x half> +// CHECK-CXX-NEXT: [[VMLAL_LANE1:%.*]] = call <8 x half> @llvm.aarch64.neon.fp8.fmlalt.lane.v8f16(<8 x half> [[VMLAL_LANE]], <16 x i8> [[VN]], <16 x i8> [[VM]], i32 15) +// CHECK-CXX-NEXT: ret <8 x half> [[VMLAL_LANE1]] +// +float16x8_t test_vmlalt_laneq(float16x8_t vd, mfloat8x16_t vn, mfloat8x16_t vm, fpm_t fpm) { + return vmlaltq_laneq_f16_mf8_fpm(vd, vn, vm, 15, fpm); +} + +// CHECK-LABEL: define dso_local <4 x float> @test_vmlallbb_lane( +// CHECK-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = call <16 x i8> @llvm.vector.insert.v16i8.v8i8(<16 x i8> poison, <8 x i8> [[VM]], i64 0) +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VMLALL_LANE:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlallbb.lane.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[TMP0]], i32 0) +// CHECK-NEXT: ret <4 x float> [[VMLALL_LANE]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x float> @_Z18test_vmlallbb_lane13__Float32x4_t14__Mfloat8x16_t13__Mfloat8x8_tm( +// CHECK-CXX-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = call <16 x i8> @llvm.vector.insert.v16i8.v8i8(<16 x i8> poison, <8 x i8> [[VM]], i64 0) +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VMLALL_LANE:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlallbb.lane.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[TMP0]], i32 0) +// CHECK-CXX-NEXT: ret <4 x float> [[VMLALL_LANE]] +// +float32x4_t test_vmlallbb_lane(float32x4_t vd, mfloat8x16_t vn, mfloat8x8_t vm, fpm_t fpm) { + return vmlallbbq_lane_f32_mf8_fpm(vd, vn, vm, 0, fpm); +} + +// CHECK-LABEL: define dso_local <4 x float> @test_vmlallbb_laneq( +// CHECK-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VMLALL_LANE:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlallbb.lane.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]], i32 0) +// CHECK-NEXT: ret <4 x float> [[VMLALL_LANE]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x float> @_Z19test_vmlallbb_laneq13__Float32x4_t14__Mfloat8x16_tS0_m( +// CHECK-CXX-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VMLALL_LANE:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlallbb.lane.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]], i32 0) +// CHECK-CXX-NEXT: ret <4 x float> [[VMLALL_LANE]] +// +float32x4_t test_vmlallbb_laneq(float32x4_t vd, mfloat8x16_t vn, mfloat8x16_t vm, fpm_t fpm) { + return vmlallbbq_laneq_f32_mf8_fpm(vd, vn, vm, 0, fpm); +} + +// CHECK-LABEL: define dso_local <4 x float> @test_vmlallbt_lane( +// CHECK-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = call <16 x i8> @llvm.vector.insert.v16i8.v8i8(<16 x i8> poison, <8 x i8> [[VM]], i64 0) +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VMLALL_LANE:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlallbt.lane.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[TMP0]], i32 3) +// CHECK-NEXT: ret <4 x float> [[VMLALL_LANE]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x float> @_Z18test_vmlallbt_lane13__Float32x4_t14__Mfloat8x16_t13__Mfloat8x8_tm( +// CHECK-CXX-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = call <16 x i8> @llvm.vector.insert.v16i8.v8i8(<16 x i8> poison, <8 x i8> [[VM]], i64 0) +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VMLALL_LANE:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlallbt.lane.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[TMP0]], i32 3) +// CHECK-CXX-NEXT: ret <4 x float> [[VMLALL_LANE]] +// +float32x4_t test_vmlallbt_lane(float32x4_t vd, mfloat8x16_t vn, mfloat8x8_t vm, fpm_t fpm) { + return vmlallbtq_lane_f32_mf8_fpm(vd, vn, vm, 3, fpm); +} + +// CHECK-LABEL: define dso_local <4 x float> @test_vmlallbt_laneq( +// CHECK-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VMLALL_LANE:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlallbt.lane.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]], i32 3) +// CHECK-NEXT: ret <4 x float> [[VMLALL_LANE]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x float> @_Z19test_vmlallbt_laneq13__Float32x4_t14__Mfloat8x16_tS0_m( +// CHECK-CXX-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VMLALL_LANE:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlallbt.lane.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]], i32 3) +// CHECK-CXX-NEXT: ret <4 x float> [[VMLALL_LANE]] +// +float32x4_t test_vmlallbt_laneq(float32x4_t vd, mfloat8x16_t vn, mfloat8x16_t vm, fpm_t fpm) { + return vmlallbtq_laneq_f32_mf8_fpm(vd, vn, vm, 3, fpm); +} + +// CHECK-LABEL: define dso_local <4 x float> @test_vmlalltb_lane( +// CHECK-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = call <16 x i8> @llvm.vector.insert.v16i8.v8i8(<16 x i8> poison, <8 x i8> [[VM]], i64 0) +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VMLALL_LANE:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlalltb.lane.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[TMP0]], i32 7) +// CHECK-NEXT: ret <4 x float> [[VMLALL_LANE]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x float> @_Z18test_vmlalltb_lane13__Float32x4_t14__Mfloat8x16_t13__Mfloat8x8_tm( +// CHECK-CXX-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = call <16 x i8> @llvm.vector.insert.v16i8.v8i8(<16 x i8> poison, <8 x i8> [[VM]], i64 0) +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VMLALL_LANE:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlalltb.lane.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[TMP0]], i32 7) +// CHECK-CXX-NEXT: ret <4 x float> [[VMLALL_LANE]] +// +float32x4_t test_vmlalltb_lane(float32x4_t vd, mfloat8x16_t vn, mfloat8x8_t vm, fpm_t fpm) { + return vmlalltbq_lane_f32_mf8_fpm(vd, vn, vm, 7, fpm); +} + +// CHECK-LABEL: define dso_local <4 x float> @test_vmlalltb_laneq( +// CHECK-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VMLALL_LANE:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlalltb.lane.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]], i32 7) +// CHECK-NEXT: ret <4 x float> [[VMLALL_LANE]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x float> @_Z19test_vmlalltb_laneq13__Float32x4_t14__Mfloat8x16_tS0_m( +// CHECK-CXX-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VMLALL_LANE:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlalltb.lane.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]], i32 7) +// CHECK-CXX-NEXT: ret <4 x float> [[VMLALL_LANE]] +// +float32x4_t test_vmlalltb_laneq(float32x4_t vd, mfloat8x16_t vn, mfloat8x16_t vm, fpm_t fpm) { + return vmlalltbq_laneq_f32_mf8_fpm(vd, vn, vm, 7, fpm); +} + +// CHECK-LABEL: define dso_local <4 x float> @test_vmlalltt_lane( +// CHECK-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = call <16 x i8> @llvm.vector.insert.v16i8.v8i8(<16 x i8> poison, <8 x i8> [[VM]], i64 0) +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VMLALL_LANE:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlalltt.lane.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[TMP0]], i32 7) +// CHECK-NEXT: ret <4 x float> [[VMLALL_LANE]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x float> @_Z18test_vmlalltt_lane13__Float32x4_t14__Mfloat8x16_t13__Mfloat8x8_tm( +// CHECK-CXX-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <8 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = call <16 x i8> @llvm.vector.insert.v16i8.v8i8(<16 x i8> poison, <8 x i8> [[VM]], i64 0) +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VMLALL_LANE:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlalltt.lane.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[TMP0]], i32 7) +// CHECK-CXX-NEXT: ret <4 x float> [[VMLALL_LANE]] +// +float32x4_t test_vmlalltt_lane(float32x4_t vd, mfloat8x16_t vn, mfloat8x8_t vm, fpm_t fpm) { + return vmlallttq_lane_f32_mf8_fpm(vd, vn, vm, 7, fpm); +} + +// CHECK-LABEL: define dso_local <4 x float> @test_vmlalltt_laneq( +// CHECK-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-NEXT: [[VMLALL_LANE:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlalltt.lane.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]], i32 15) +// CHECK-NEXT: ret <4 x float> [[VMLALL_LANE]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x float> @_Z19test_vmlalltt_laneq13__Float32x4_t14__Mfloat8x16_tS0_m( +// CHECK-CXX-SAME: <4 x float> noundef [[VD:%.*]], <16 x i8> [[VN:%.*]], <16 x i8> [[VM:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: call void @llvm.aarch64.set.fpmr(i64 [[FPM]]) +// CHECK-CXX-NEXT: [[VMLALL_LANE:%.*]] = call <4 x float> @llvm.aarch64.neon.fp8.fmlalltt.lane.v4f32(<4 x float> [[VD]], <16 x i8> [[VN]], <16 x i8> [[VM]], i32 15) +// CHECK-CXX-NEXT: ret <4 x float> [[VMLALL_LANE]] +// +float32x4_t test_vmlalltt_laneq(float32x4_t vd, mfloat8x16_t vn, mfloat8x16_t vm, fpm_t fpm) { + return vmlallttq_laneq_f32_mf8_fpm(vd, vn, vm, 15, fpm); +} diff --git clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_reinterpret.c clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_reinterpret.c new file mode 100644 index 000000000000..201d4dbbe34a --- /dev/null +++ clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_reinterpret.c @@ -0,0 +1,855 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +#include <arm_neon.h> +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +bf16 -target-feature +fp8 -target-feature +fp8fma -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg | FileCheck %s +// RUN: %clang_cc1 -x c++ -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +bf16 -target-feature +fp8 -target-feature +fp8fma -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg | FileCheck %s -check-prefix CHECK-CXX + +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +bf16 -target-feature +fp8 -target-feature +fp8fma -disable-O0-optnone -Werror -Wall -S -o /dev/null %s + +// REQUIRES: aarch64-registered-target + +// CHECK-LABEL: define dso_local <8 x i8> @test_vreinterpret_p8_mf8( +// CHECK-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: ret <8 x i8> [[V]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x i8> @_Z24test_vreinterpret_p8_mf813__Mfloat8x8_t( +// CHECK-CXX-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: ret <8 x i8> [[V]] +// +poly8x8_t test_vreinterpret_p8_mf8(mfloat8x8_t v) { + return vreinterpret_p8_mf8(v); +} +// CHECK-LABEL: define dso_local <1 x i64> @test_vreinterpret_p64_mf8( +// CHECK-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[V]] to <1 x i64> +// CHECK-NEXT: ret <1 x i64> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <1 x i64> @_Z25test_vreinterpret_p64_mf813__Mfloat8x8_t( +// CHECK-CXX-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[V]] to <1 x i64> +// CHECK-CXX-NEXT: ret <1 x i64> [[TMP0]] +// +poly64x1_t test_vreinterpret_p64_mf8(mfloat8x8_t v) { + return vreinterpret_p64_mf8(v); +} +// CHECK-LABEL: define dso_local <4 x i16> @test_vreinterpret_p16_mf8( +// CHECK-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[V]] to <4 x i16> +// CHECK-NEXT: ret <4 x i16> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x i16> @_Z25test_vreinterpret_p16_mf813__Mfloat8x8_t( +// CHECK-CXX-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[V]] to <4 x i16> +// CHECK-CXX-NEXT: ret <4 x i16> [[TMP0]] +// +poly16x4_t test_vreinterpret_p16_mf8(mfloat8x8_t v) { + return vreinterpret_p16_mf8(v); +} +// CHECK-LABEL: define dso_local <16 x i8> @test_vreinterpretq_p8_mf8( +// CHECK-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: ret <16 x i8> [[V]] +// +// CHECK-CXX-LABEL: define dso_local noundef <16 x i8> @_Z25test_vreinterpretq_p8_mf814__Mfloat8x16_t( +// CHECK-CXX-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: ret <16 x i8> [[V]] +// +poly8x16_t test_vreinterpretq_p8_mf8(mfloat8x16_t v) { + return vreinterpretq_p8_mf8(v); +} +// CHECK-LABEL: define dso_local i128 @test_vreinterpretq_p128_mf8( +// CHECK-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to i128 +// CHECK-NEXT: ret i128 [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef i128 @_Z27test_vreinterpretq_p128_mf814__Mfloat8x16_t( +// CHECK-CXX-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to i128 +// CHECK-CXX-NEXT: ret i128 [[TMP0]] +// +poly128_t test_vreinterpretq_p128_mf8(mfloat8x16_t v) { + return vreinterpretq_p128_mf8(v); +} +// CHECK-LABEL: define dso_local <2 x i64> @test_vreinterpretq_p64_mf8( +// CHECK-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to <2 x i64> +// CHECK-NEXT: ret <2 x i64> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <2 x i64> @_Z26test_vreinterpretq_p64_mf814__Mfloat8x16_t( +// CHECK-CXX-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to <2 x i64> +// CHECK-CXX-NEXT: ret <2 x i64> [[TMP0]] +// +poly64x2_t test_vreinterpretq_p64_mf8(mfloat8x16_t v) { + return vreinterpretq_p64_mf8(v); +} +// CHECK-LABEL: define dso_local <8 x i16> @test_vreinterpretq_p16_mf8( +// CHECK-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to <8 x i16> +// CHECK-NEXT: ret <8 x i16> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x i16> @_Z26test_vreinterpretq_p16_mf814__Mfloat8x16_t( +// CHECK-CXX-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to <8 x i16> +// CHECK-CXX-NEXT: ret <8 x i16> [[TMP0]] +// +poly16x8_t test_vreinterpretq_p16_mf8(mfloat8x16_t v) { + return vreinterpretq_p16_mf8(v); +} +// CHECK-LABEL: define dso_local <16 x i8> @test_vreinterpretq_u8_mf8( +// CHECK-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: ret <16 x i8> [[V]] +// +// CHECK-CXX-LABEL: define dso_local noundef <16 x i8> @_Z25test_vreinterpretq_u8_mf814__Mfloat8x16_t( +// CHECK-CXX-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: ret <16 x i8> [[V]] +// +uint8x16_t test_vreinterpretq_u8_mf8(mfloat8x16_t v) { + return vreinterpretq_u8_mf8(v); +} +// CHECK-LABEL: define dso_local <4 x i32> @test_vreinterpretq_u32_mf8( +// CHECK-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to <4 x i32> +// CHECK-NEXT: ret <4 x i32> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x i32> @_Z26test_vreinterpretq_u32_mf814__Mfloat8x16_t( +// CHECK-CXX-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to <4 x i32> +// CHECK-CXX-NEXT: ret <4 x i32> [[TMP0]] +// +uint32x4_t test_vreinterpretq_u32_mf8(mfloat8x16_t v) { + return vreinterpretq_u32_mf8(v); +} +// CHECK-LABEL: define dso_local <2 x i64> @test_vreinterpretq_u64_mf8( +// CHECK-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to <2 x i64> +// CHECK-NEXT: ret <2 x i64> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <2 x i64> @_Z26test_vreinterpretq_u64_mf814__Mfloat8x16_t( +// CHECK-CXX-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to <2 x i64> +// CHECK-CXX-NEXT: ret <2 x i64> [[TMP0]] +// +uint64x2_t test_vreinterpretq_u64_mf8(mfloat8x16_t v) { + return vreinterpretq_u64_mf8(v); +} +// CHECK-LABEL: define dso_local <8 x i16> @test_vreinterpretq_u16_mf8( +// CHECK-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to <8 x i16> +// CHECK-NEXT: ret <8 x i16> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x i16> @_Z26test_vreinterpretq_u16_mf814__Mfloat8x16_t( +// CHECK-CXX-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to <8 x i16> +// CHECK-CXX-NEXT: ret <8 x i16> [[TMP0]] +// +uint16x8_t test_vreinterpretq_u16_mf8(mfloat8x16_t v) { + return vreinterpretq_u16_mf8(v); +} +// CHECK-LABEL: define dso_local <16 x i8> @test_vreinterpretq_s8_mf8( +// CHECK-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: ret <16 x i8> [[V]] +// +// CHECK-CXX-LABEL: define dso_local noundef <16 x i8> @_Z25test_vreinterpretq_s8_mf814__Mfloat8x16_t( +// CHECK-CXX-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: ret <16 x i8> [[V]] +// +int8x16_t test_vreinterpretq_s8_mf8(mfloat8x16_t v) { + return vreinterpretq_s8_mf8(v); +} +// CHECK-LABEL: define dso_local <2 x double> @test_vreinterpretq_f64_mf8( +// CHECK-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to <2 x double> +// CHECK-NEXT: ret <2 x double> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <2 x double> @_Z26test_vreinterpretq_f64_mf814__Mfloat8x16_t( +// CHECK-CXX-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to <2 x double> +// CHECK-CXX-NEXT: ret <2 x double> [[TMP0]] +// +float64x2_t test_vreinterpretq_f64_mf8(mfloat8x16_t v) { + return vreinterpretq_f64_mf8(v); +} +// CHECK-LABEL: define dso_local <4 x float> @test_vreinterpretq_f32_mf8( +// CHECK-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to <4 x float> +// CHECK-NEXT: ret <4 x float> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x float> @_Z26test_vreinterpretq_f32_mf814__Mfloat8x16_t( +// CHECK-CXX-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to <4 x float> +// CHECK-CXX-NEXT: ret <4 x float> [[TMP0]] +// +float32x4_t test_vreinterpretq_f32_mf8(mfloat8x16_t v) { + return vreinterpretq_f32_mf8(v); +} +// CHECK-LABEL: define dso_local <8 x half> @test_vreinterpretq_f16_mf8( +// CHECK-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to <8 x half> +// CHECK-NEXT: ret <8 x half> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x half> @_Z26test_vreinterpretq_f16_mf814__Mfloat8x16_t( +// CHECK-CXX-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to <8 x half> +// CHECK-CXX-NEXT: ret <8 x half> [[TMP0]] +// +float16x8_t test_vreinterpretq_f16_mf8(mfloat8x16_t v) { + return vreinterpretq_f16_mf8(v); +} +// CHECK-LABEL: define dso_local <4 x i32> @test_vreinterpretq_s32_mf8( +// CHECK-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to <4 x i32> +// CHECK-NEXT: ret <4 x i32> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x i32> @_Z26test_vreinterpretq_s32_mf814__Mfloat8x16_t( +// CHECK-CXX-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to <4 x i32> +// CHECK-CXX-NEXT: ret <4 x i32> [[TMP0]] +// +int32x4_t test_vreinterpretq_s32_mf8(mfloat8x16_t v) { + return vreinterpretq_s32_mf8(v); +} +// CHECK-LABEL: define dso_local <2 x i64> @test_vreinterpretq_s64_mf8( +// CHECK-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to <2 x i64> +// CHECK-NEXT: ret <2 x i64> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <2 x i64> @_Z26test_vreinterpretq_s64_mf814__Mfloat8x16_t( +// CHECK-CXX-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to <2 x i64> +// CHECK-CXX-NEXT: ret <2 x i64> [[TMP0]] +// +int64x2_t test_vreinterpretq_s64_mf8(mfloat8x16_t v) { + return vreinterpretq_s64_mf8(v); +} +// CHECK-LABEL: define dso_local <16 x i8> @test_vreinterpretq_mf8_p8( +// CHECK-SAME: <16 x i8> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: ret <16 x i8> [[V]] +// +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z25test_vreinterpretq_mf8_p812__Poly8x16_t( +// CHECK-CXX-SAME: <16 x i8> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: ret <16 x i8> [[V]] +// +mfloat8x16_t test_vreinterpretq_mf8_p8(poly8x16_t v) { + return vreinterpretq_mf8_p8(v); +} +// CHECK-LABEL: define dso_local <16 x i8> @test_vreinterpretq_mf8_p128( +// CHECK-SAME: i128 noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast i128 [[V]] to <16 x i8> +// CHECK-NEXT: ret <16 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z27test_vreinterpretq_mf8_p128o( +// CHECK-CXX-SAME: i128 noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast i128 [[V]] to <16 x i8> +// CHECK-CXX-NEXT: ret <16 x i8> [[TMP0]] +// +mfloat8x16_t test_vreinterpretq_mf8_p128(poly128_t v) { + return vreinterpretq_mf8_p128(v); +} +// CHECK-LABEL: define dso_local <16 x i8> @test_vreinterpretq_mf8_p64( +// CHECK-SAME: <2 x i64> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <2 x i64> [[V]] to <16 x i8> +// CHECK-NEXT: ret <16 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z26test_vreinterpretq_mf8_p6412__Poly64x2_t( +// CHECK-CXX-SAME: <2 x i64> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <2 x i64> [[V]] to <16 x i8> +// CHECK-CXX-NEXT: ret <16 x i8> [[TMP0]] +// +mfloat8x16_t test_vreinterpretq_mf8_p64(poly64x2_t v) { + return vreinterpretq_mf8_p64(v); +} +// CHECK-LABEL: define dso_local <16 x i8> @test_vreinterpretq_mf8_p16( +// CHECK-SAME: <8 x i16> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x i16> [[V]] to <16 x i8> +// CHECK-NEXT: ret <16 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z26test_vreinterpretq_mf8_p1612__Poly16x8_t( +// CHECK-CXX-SAME: <8 x i16> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x i16> [[V]] to <16 x i8> +// CHECK-CXX-NEXT: ret <16 x i8> [[TMP0]] +// +mfloat8x16_t test_vreinterpretq_mf8_p16(poly16x8_t v) { + return vreinterpretq_mf8_p16(v); +} +// CHECK-LABEL: define dso_local <16 x i8> @test_vreinterpretq_mf8_u8( +// CHECK-SAME: <16 x i8> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: ret <16 x i8> [[V]] +// +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z25test_vreinterpretq_mf8_u812__Uint8x16_t( +// CHECK-CXX-SAME: <16 x i8> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: ret <16 x i8> [[V]] +// +mfloat8x16_t test_vreinterpretq_mf8_u8(uint8x16_t v) { + return vreinterpretq_mf8_u8(v); +} +// CHECK-LABEL: define dso_local <16 x i8> @test_vreinterpretq_mf8_u32( +// CHECK-SAME: <4 x i32> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <4 x i32> [[V]] to <16 x i8> +// CHECK-NEXT: ret <16 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z26test_vreinterpretq_mf8_u3212__Uint32x4_t( +// CHECK-CXX-SAME: <4 x i32> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <4 x i32> [[V]] to <16 x i8> +// CHECK-CXX-NEXT: ret <16 x i8> [[TMP0]] +// +mfloat8x16_t test_vreinterpretq_mf8_u32(uint32x4_t v) { + return vreinterpretq_mf8_u32(v); +} +// CHECK-LABEL: define dso_local <16 x i8> @test_vreinterpretq_mf8_u64( +// CHECK-SAME: <2 x i64> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <2 x i64> [[V]] to <16 x i8> +// CHECK-NEXT: ret <16 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z26test_vreinterpretq_mf8_u6412__Uint64x2_t( +// CHECK-CXX-SAME: <2 x i64> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <2 x i64> [[V]] to <16 x i8> +// CHECK-CXX-NEXT: ret <16 x i8> [[TMP0]] +// +mfloat8x16_t test_vreinterpretq_mf8_u64(uint64x2_t v) { + return vreinterpretq_mf8_u64(v); +} +// CHECK-LABEL: define dso_local <16 x i8> @test_vreinterpretq_mf8_u16( +// CHECK-SAME: <8 x i16> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x i16> [[V]] to <16 x i8> +// CHECK-NEXT: ret <16 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z26test_vreinterpretq_mf8_u1612__Uint16x8_t( +// CHECK-CXX-SAME: <8 x i16> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x i16> [[V]] to <16 x i8> +// CHECK-CXX-NEXT: ret <16 x i8> [[TMP0]] +// +mfloat8x16_t test_vreinterpretq_mf8_u16(uint16x8_t v) { + return vreinterpretq_mf8_u16(v); +} +// CHECK-LABEL: define dso_local <16 x i8> @test_vreinterpretq_mf8_s8( +// CHECK-SAME: <16 x i8> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: ret <16 x i8> [[V]] +// +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z25test_vreinterpretq_mf8_s811__Int8x16_t( +// CHECK-CXX-SAME: <16 x i8> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: ret <16 x i8> [[V]] +// +mfloat8x16_t test_vreinterpretq_mf8_s8(int8x16_t v) { + return vreinterpretq_mf8_s8(v); +} +// CHECK-LABEL: define dso_local <16 x i8> @test_vreinterpretq_mf8_f64( +// CHECK-SAME: <2 x double> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <2 x double> [[V]] to <16 x i8> +// CHECK-NEXT: ret <16 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z26test_vreinterpretq_mf8_f6413__Float64x2_t( +// CHECK-CXX-SAME: <2 x double> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <2 x double> [[V]] to <16 x i8> +// CHECK-CXX-NEXT: ret <16 x i8> [[TMP0]] +// +mfloat8x16_t test_vreinterpretq_mf8_f64(float64x2_t v) { + return vreinterpretq_mf8_f64(v); +} +// CHECK-LABEL: define dso_local <16 x i8> @test_vreinterpretq_mf8_f32( +// CHECK-SAME: <4 x float> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <4 x float> [[V]] to <16 x i8> +// CHECK-NEXT: ret <16 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z26test_vreinterpretq_mf8_f3213__Float32x4_t( +// CHECK-CXX-SAME: <4 x float> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <4 x float> [[V]] to <16 x i8> +// CHECK-CXX-NEXT: ret <16 x i8> [[TMP0]] +// +mfloat8x16_t test_vreinterpretq_mf8_f32(float32x4_t v) { + return vreinterpretq_mf8_f32(v); +} +// CHECK-LABEL: define dso_local <16 x i8> @test_vreinterpretq_mf8_f16( +// CHECK-SAME: <8 x half> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x half> [[V]] to <16 x i8> +// CHECK-NEXT: ret <16 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z26test_vreinterpretq_mf8_f1613__Float16x8_t( +// CHECK-CXX-SAME: <8 x half> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x half> [[V]] to <16 x i8> +// CHECK-CXX-NEXT: ret <16 x i8> [[TMP0]] +// +mfloat8x16_t test_vreinterpretq_mf8_f16(float16x8_t v) { + return vreinterpretq_mf8_f16(v); +} +// CHECK-LABEL: define dso_local <16 x i8> @test_vreinterpretq_mf8_s32( +// CHECK-SAME: <4 x i32> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <4 x i32> [[V]] to <16 x i8> +// CHECK-NEXT: ret <16 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z26test_vreinterpretq_mf8_s3211__Int32x4_t( +// CHECK-CXX-SAME: <4 x i32> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <4 x i32> [[V]] to <16 x i8> +// CHECK-CXX-NEXT: ret <16 x i8> [[TMP0]] +// +mfloat8x16_t test_vreinterpretq_mf8_s32(int32x4_t v) { + return vreinterpretq_mf8_s32(v); +} +// CHECK-LABEL: define dso_local <16 x i8> @test_vreinterpretq_mf8_s64( +// CHECK-SAME: <2 x i64> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <2 x i64> [[V]] to <16 x i8> +// CHECK-NEXT: ret <16 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z26test_vreinterpretq_mf8_s6411__Int64x2_t( +// CHECK-CXX-SAME: <2 x i64> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <2 x i64> [[V]] to <16 x i8> +// CHECK-CXX-NEXT: ret <16 x i8> [[TMP0]] +// +mfloat8x16_t test_vreinterpretq_mf8_s64(int64x2_t v) { + return vreinterpretq_mf8_s64(v); +} +// CHECK-LABEL: define dso_local <16 x i8> @test_vreinterpretq_mf8_s16( +// CHECK-SAME: <8 x i16> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x i16> [[V]] to <16 x i8> +// CHECK-NEXT: ret <16 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z26test_vreinterpretq_mf8_s1611__Int16x8_t( +// CHECK-CXX-SAME: <8 x i16> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x i16> [[V]] to <16 x i8> +// CHECK-CXX-NEXT: ret <16 x i8> [[TMP0]] +// +mfloat8x16_t test_vreinterpretq_mf8_s16(int16x8_t v) { + return vreinterpretq_mf8_s16(v); +} +// CHECK-LABEL: define dso_local <8 x i16> @test_vreinterpretq_s16_mf8( +// CHECK-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to <8 x i16> +// CHECK-NEXT: ret <8 x i16> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x i16> @_Z26test_vreinterpretq_s16_mf814__Mfloat8x16_t( +// CHECK-CXX-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <16 x i8> [[V]] to <8 x i16> +// CHECK-CXX-NEXT: ret <8 x i16> [[TMP0]] +// +int16x8_t test_vreinterpretq_s16_mf8(mfloat8x16_t v) { + return vreinterpretq_s16_mf8(v); +} +// CHECK-LABEL: define dso_local <8 x i8> @test_vreinterpret_u8_mf8( +// CHECK-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: ret <8 x i8> [[V]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x i8> @_Z24test_vreinterpret_u8_mf813__Mfloat8x8_t( +// CHECK-CXX-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: ret <8 x i8> [[V]] +// +uint8x8_t test_vreinterpret_u8_mf8(mfloat8x8_t v) { + return vreinterpret_u8_mf8(v); +} +// CHECK-LABEL: define dso_local <2 x i32> @test_vreinterpret_u32_mf8( +// CHECK-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[V]] to <2 x i32> +// CHECK-NEXT: ret <2 x i32> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <2 x i32> @_Z25test_vreinterpret_u32_mf813__Mfloat8x8_t( +// CHECK-CXX-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[V]] to <2 x i32> +// CHECK-CXX-NEXT: ret <2 x i32> [[TMP0]] +// +uint32x2_t test_vreinterpret_u32_mf8(mfloat8x8_t v) { + return vreinterpret_u32_mf8(v); +} +// CHECK-LABEL: define dso_local <1 x i64> @test_vreinterpret_u64_mf8( +// CHECK-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[V]] to <1 x i64> +// CHECK-NEXT: ret <1 x i64> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <1 x i64> @_Z25test_vreinterpret_u64_mf813__Mfloat8x8_t( +// CHECK-CXX-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[V]] to <1 x i64> +// CHECK-CXX-NEXT: ret <1 x i64> [[TMP0]] +// +uint64x1_t test_vreinterpret_u64_mf8(mfloat8x8_t v) { + return vreinterpret_u64_mf8(v); +} +// CHECK-LABEL: define dso_local <4 x i16> @test_vreinterpret_u16_mf8( +// CHECK-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[V]] to <4 x i16> +// CHECK-NEXT: ret <4 x i16> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x i16> @_Z25test_vreinterpret_u16_mf813__Mfloat8x8_t( +// CHECK-CXX-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[V]] to <4 x i16> +// CHECK-CXX-NEXT: ret <4 x i16> [[TMP0]] +// +uint16x4_t test_vreinterpret_u16_mf8(mfloat8x8_t v) { + return vreinterpret_u16_mf8(v); +} +// CHECK-LABEL: define dso_local <8 x i8> @test_vreinterpret_s8_mf8( +// CHECK-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: ret <8 x i8> [[V]] +// +// CHECK-CXX-LABEL: define dso_local noundef <8 x i8> @_Z24test_vreinterpret_s8_mf813__Mfloat8x8_t( +// CHECK-CXX-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: ret <8 x i8> [[V]] +// +int8x8_t test_vreinterpret_s8_mf8(mfloat8x8_t v) { + return vreinterpret_s8_mf8(v); +} +// CHECK-LABEL: define dso_local <1 x double> @test_vreinterpret_f64_mf8( +// CHECK-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[V]] to <1 x double> +// CHECK-NEXT: ret <1 x double> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <1 x double> @_Z25test_vreinterpret_f64_mf813__Mfloat8x8_t( +// CHECK-CXX-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[V]] to <1 x double> +// CHECK-CXX-NEXT: ret <1 x double> [[TMP0]] +// +float64x1_t test_vreinterpret_f64_mf8(mfloat8x8_t v) { + return vreinterpret_f64_mf8(v); +} +// CHECK-LABEL: define dso_local <2 x float> @test_vreinterpret_f32_mf8( +// CHECK-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[V]] to <2 x float> +// CHECK-NEXT: ret <2 x float> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <2 x float> @_Z25test_vreinterpret_f32_mf813__Mfloat8x8_t( +// CHECK-CXX-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[V]] to <2 x float> +// CHECK-CXX-NEXT: ret <2 x float> [[TMP0]] +// +float32x2_t test_vreinterpret_f32_mf8(mfloat8x8_t v) { + return vreinterpret_f32_mf8(v); +} +// CHECK-LABEL: define dso_local <4 x half> @test_vreinterpret_f16_mf8( +// CHECK-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[V]] to <4 x half> +// CHECK-NEXT: ret <4 x half> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x half> @_Z25test_vreinterpret_f16_mf813__Mfloat8x8_t( +// CHECK-CXX-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[V]] to <4 x half> +// CHECK-CXX-NEXT: ret <4 x half> [[TMP0]] +// +float16x4_t test_vreinterpret_f16_mf8(mfloat8x8_t v) { + return vreinterpret_f16_mf8(v); +} +// CHECK-LABEL: define dso_local <2 x i32> @test_vreinterpret_s32_mf8( +// CHECK-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[V]] to <2 x i32> +// CHECK-NEXT: ret <2 x i32> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <2 x i32> @_Z25test_vreinterpret_s32_mf813__Mfloat8x8_t( +// CHECK-CXX-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[V]] to <2 x i32> +// CHECK-CXX-NEXT: ret <2 x i32> [[TMP0]] +// +int32x2_t test_vreinterpret_s32_mf8(mfloat8x8_t v) { + return vreinterpret_s32_mf8(v); +} +// CHECK-LABEL: define dso_local <1 x i64> @test_vreinterpret_s64_mf8( +// CHECK-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[V]] to <1 x i64> +// CHECK-NEXT: ret <1 x i64> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <1 x i64> @_Z25test_vreinterpret_s64_mf813__Mfloat8x8_t( +// CHECK-CXX-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[V]] to <1 x i64> +// CHECK-CXX-NEXT: ret <1 x i64> [[TMP0]] +// +int64x1_t test_vreinterpret_s64_mf8(mfloat8x8_t v) { + return vreinterpret_s64_mf8(v); +} +// CHECK-LABEL: define dso_local <8 x i8> @test_vreinterpret_mf8_p8( +// CHECK-SAME: <8 x i8> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: ret <8 x i8> [[V]] +// +// CHECK-CXX-LABEL: define dso_local <8 x i8> @_Z24test_vreinterpret_mf8_p811__Poly8x8_t( +// CHECK-CXX-SAME: <8 x i8> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: ret <8 x i8> [[V]] +// +mfloat8x8_t test_vreinterpret_mf8_p8(poly8x8_t v) { + return vreinterpret_mf8_p8(v); +} +// CHECK-LABEL: define dso_local <8 x i8> @test_vreinterpret_mf8_p64( +// CHECK-SAME: <1 x i64> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <1 x i64> [[V]] to <8 x i8> +// CHECK-NEXT: ret <8 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <8 x i8> @_Z25test_vreinterpret_mf8_p6412__Poly64x1_t( +// CHECK-CXX-SAME: <1 x i64> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <1 x i64> [[V]] to <8 x i8> +// CHECK-CXX-NEXT: ret <8 x i8> [[TMP0]] +// +mfloat8x8_t test_vreinterpret_mf8_p64(poly64x1_t v) { + return vreinterpret_mf8_p64(v); +} +// CHECK-LABEL: define dso_local <8 x i8> @test_vreinterpret_mf8_p16( +// CHECK-SAME: <4 x i16> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <4 x i16> [[V]] to <8 x i8> +// CHECK-NEXT: ret <8 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <8 x i8> @_Z25test_vreinterpret_mf8_p1612__Poly16x4_t( +// CHECK-CXX-SAME: <4 x i16> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <4 x i16> [[V]] to <8 x i8> +// CHECK-CXX-NEXT: ret <8 x i8> [[TMP0]] +// +mfloat8x8_t test_vreinterpret_mf8_p16(poly16x4_t v) { + return vreinterpret_mf8_p16(v); +} +// CHECK-LABEL: define dso_local <8 x i8> @test_vreinterpret_mf8_u8( +// CHECK-SAME: <8 x i8> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: ret <8 x i8> [[V]] +// +// CHECK-CXX-LABEL: define dso_local <8 x i8> @_Z24test_vreinterpret_mf8_u811__Uint8x8_t( +// CHECK-CXX-SAME: <8 x i8> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: ret <8 x i8> [[V]] +// +mfloat8x8_t test_vreinterpret_mf8_u8(uint8x8_t v) { + return vreinterpret_mf8_u8(v); +} +// CHECK-LABEL: define dso_local <8 x i8> @test_vreinterpret_mf8_u32( +// CHECK-SAME: <2 x i32> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <2 x i32> [[V]] to <8 x i8> +// CHECK-NEXT: ret <8 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <8 x i8> @_Z25test_vreinterpret_mf8_u3212__Uint32x2_t( +// CHECK-CXX-SAME: <2 x i32> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <2 x i32> [[V]] to <8 x i8> +// CHECK-CXX-NEXT: ret <8 x i8> [[TMP0]] +// +mfloat8x8_t test_vreinterpret_mf8_u32(uint32x2_t v) { + return vreinterpret_mf8_u32(v); +} +// CHECK-LABEL: define dso_local <8 x i8> @test_vreinterpret_mf8_u64( +// CHECK-SAME: <1 x i64> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <1 x i64> [[V]] to <8 x i8> +// CHECK-NEXT: ret <8 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <8 x i8> @_Z25test_vreinterpret_mf8_u6412__Uint64x1_t( +// CHECK-CXX-SAME: <1 x i64> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <1 x i64> [[V]] to <8 x i8> +// CHECK-CXX-NEXT: ret <8 x i8> [[TMP0]] +// +mfloat8x8_t test_vreinterpret_mf8_u64(uint64x1_t v) { + return vreinterpret_mf8_u64(v); +} +// CHECK-LABEL: define dso_local <8 x i8> @test_vreinterpret_mf8_u16( +// CHECK-SAME: <4 x i16> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <4 x i16> [[V]] to <8 x i8> +// CHECK-NEXT: ret <8 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <8 x i8> @_Z25test_vreinterpret_mf8_u1612__Uint16x4_t( +// CHECK-CXX-SAME: <4 x i16> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <4 x i16> [[V]] to <8 x i8> +// CHECK-CXX-NEXT: ret <8 x i8> [[TMP0]] +// +mfloat8x8_t test_vreinterpret_mf8_u16(uint16x4_t v) { + return vreinterpret_mf8_u16(v); +} +// CHECK-LABEL: define dso_local <8 x i8> @test_vreinterpret_mf8_s8( +// CHECK-SAME: <8 x i8> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: ret <8 x i8> [[V]] +// +// CHECK-CXX-LABEL: define dso_local <8 x i8> @_Z24test_vreinterpret_mf8_s810__Int8x8_t( +// CHECK-CXX-SAME: <8 x i8> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: ret <8 x i8> [[V]] +// +mfloat8x8_t test_vreinterpret_mf8_s8(int8x8_t v) { + return vreinterpret_mf8_s8(v); +} +// CHECK-LABEL: define dso_local <8 x i8> @test_vreinterpret_mf8_f64( +// CHECK-SAME: <1 x double> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <1 x double> [[V]] to <8 x i8> +// CHECK-NEXT: ret <8 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <8 x i8> @_Z25test_vreinterpret_mf8_f6413__Float64x1_t( +// CHECK-CXX-SAME: <1 x double> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <1 x double> [[V]] to <8 x i8> +// CHECK-CXX-NEXT: ret <8 x i8> [[TMP0]] +// +mfloat8x8_t test_vreinterpret_mf8_f64(float64x1_t v) { + return vreinterpret_mf8_f64(v); +} +// CHECK-LABEL: define dso_local <8 x i8> @test_vreinterpret_mf8_f32( +// CHECK-SAME: <2 x float> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <2 x float> [[V]] to <8 x i8> +// CHECK-NEXT: ret <8 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <8 x i8> @_Z25test_vreinterpret_mf8_f3213__Float32x2_t( +// CHECK-CXX-SAME: <2 x float> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <2 x float> [[V]] to <8 x i8> +// CHECK-CXX-NEXT: ret <8 x i8> [[TMP0]] +// +mfloat8x8_t test_vreinterpret_mf8_f32(float32x2_t v) { + return vreinterpret_mf8_f32(v); +} +// CHECK-LABEL: define dso_local <8 x i8> @test_vreinterpret_mf8_f16( +// CHECK-SAME: <4 x half> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <4 x half> [[V]] to <8 x i8> +// CHECK-NEXT: ret <8 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <8 x i8> @_Z25test_vreinterpret_mf8_f1613__Float16x4_t( +// CHECK-CXX-SAME: <4 x half> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <4 x half> [[V]] to <8 x i8> +// CHECK-CXX-NEXT: ret <8 x i8> [[TMP0]] +// +mfloat8x8_t test_vreinterpret_mf8_f16(float16x4_t v) { + return vreinterpret_mf8_f16(v); +} +// CHECK-LABEL: define dso_local <8 x i8> @test_vreinterpret_mf8_s32( +// CHECK-SAME: <2 x i32> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <2 x i32> [[V]] to <8 x i8> +// CHECK-NEXT: ret <8 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <8 x i8> @_Z25test_vreinterpret_mf8_s3211__Int32x2_t( +// CHECK-CXX-SAME: <2 x i32> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <2 x i32> [[V]] to <8 x i8> +// CHECK-CXX-NEXT: ret <8 x i8> [[TMP0]] +// +mfloat8x8_t test_vreinterpret_mf8_s32(int32x2_t v) { + return vreinterpret_mf8_s32(v); +} +// CHECK-LABEL: define dso_local <8 x i8> @test_vreinterpret_mf8_s64( +// CHECK-SAME: <1 x i64> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <1 x i64> [[V]] to <8 x i8> +// CHECK-NEXT: ret <8 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <8 x i8> @_Z25test_vreinterpret_mf8_s6411__Int64x1_t( +// CHECK-CXX-SAME: <1 x i64> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <1 x i64> [[V]] to <8 x i8> +// CHECK-CXX-NEXT: ret <8 x i8> [[TMP0]] +// +mfloat8x8_t test_vreinterpret_mf8_s64(int64x1_t v) { + return vreinterpret_mf8_s64(v); +} +// CHECK-LABEL: define dso_local <8 x i8> @test_vreinterpret_mf8_s16( +// CHECK-SAME: <4 x i16> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <4 x i16> [[V]] to <8 x i8> +// CHECK-NEXT: ret <8 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <8 x i8> @_Z25test_vreinterpret_mf8_s1611__Int16x4_t( +// CHECK-CXX-SAME: <4 x i16> noundef [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <4 x i16> [[V]] to <8 x i8> +// CHECK-CXX-NEXT: ret <8 x i8> [[TMP0]] +// +mfloat8x8_t test_vreinterpret_mf8_s16(int16x4_t v) { + return vreinterpret_mf8_s16(v); +} +// CHECK-LABEL: define dso_local <4 x i16> @test_vreinterpret_s16_mf8( +// CHECK-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[V]] to <4 x i16> +// CHECK-NEXT: ret <4 x i16> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local noundef <4 x i16> @_Z25test_vreinterpret_s16_mf813__Mfloat8x8_t( +// CHECK-CXX-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <8 x i8> [[V]] to <4 x i16> +// CHECK-CXX-NEXT: ret <4 x i16> [[TMP0]] +// +int16x4_t test_vreinterpret_s16_mf8(mfloat8x8_t v) { + return vreinterpret_s16_mf8(v); +} diff --git clang/test/CodeGen/AArch64/pure-scalable-args.c clang/test/CodeGen/AArch64/pure-scalable-args.c index b03011e70b6a..fecd370d09be 100644 --- clang/test/CodeGen/AArch64/pure-scalable-args.c +++ clang/test/CodeGen/AArch64/pure-scalable-args.c @@ -67,7 +67,7 @@ void test_argpass_simple(PST *p) { void argpass_simple_callee(PST); argpass_simple_callee(*p); } -// CHECK-AAPCS: define dso_local void @test_argpass_simple(ptr nocapture noundef readonly %p) +// CHECK-AAPCS: define dso_local void @test_argpass_simple(ptr noundef readonly captures(none) %p) // CHECK-AAPCS-NEXT: entry: // CHECK-AAPCS-NEXT: %0 = load <2 x i8>, ptr %p, align 16 // CHECK-AAPCS-NEXT: %cast.scalable = tail call <vscale x 2 x i8> @llvm.vector.insert.nxv2i8.v2i8(<vscale x 2 x i8> poison, <2 x i8> %0, i64 0) @@ -292,7 +292,7 @@ PST test_return(PST *p) { return *p; } // CHECK-AAPCS: define dso_local <{ <vscale x 16 x i1>, <vscale x 2 x double>, <vscale x 4 x float>, <vscale x 4 x float>, <vscale x 16 x i8>, <vscale x 16 x i1> }> @test_return(ptr -// CHECK-DARWIN: define void @test_return(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.PST) align 16 initializes((0, 96)) %agg.result, ptr nocapture noundef readonly %p) +// CHECK-DARWIN: define void @test_return(ptr dead_on_unwind noalias writable writeonly sret(%struct.PST) align 16 captures(none) initializes((0, 96)) %agg.result, ptr noundef readonly captures(none) %p) // Corner case of 1-element aggregate // p->x -> q0 @@ -300,7 +300,7 @@ SmallPST test_return_small_pst(SmallPST *p) { return *p; } // CHECK-AAPCS: define dso_local <vscale x 4 x float> @test_return_small_pst(ptr -// CHECK-DARWIN: define i128 @test_return_small_pst(ptr nocapture noundef readonly %p) +// CHECK-DARWIN: define i128 @test_return_small_pst(ptr noundef readonly captures(none) %p) // Big PST, returned indirectly @@ -308,8 +308,8 @@ SmallPST test_return_small_pst(SmallPST *p) { BigPST test_return_big_pst(BigPST *p) { return *p; } -// CHECK-AAPCS: define dso_local void @test_return_big_pst(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.BigPST) align 16 initializes((0, 176)) %agg.result, ptr nocapture noundef readonly %p) -// CHECK-DARWIN: define void @test_return_big_pst(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.BigPST) align 16 initializes((0, 176)) %agg.result, ptr nocapture noundef readonly %p) +// CHECK-AAPCS: define dso_local void @test_return_big_pst(ptr dead_on_unwind noalias writable writeonly sret(%struct.BigPST) align 16 captures(none) initializes((0, 176)) %agg.result, ptr noundef readonly captures(none) %p) +// CHECK-DARWIN: define void @test_return_big_pst(ptr dead_on_unwind noalias writable writeonly sret(%struct.BigPST) align 16 captures(none) initializes((0, 176)) %agg.result, ptr noundef readonly captures(none) %p) // Variadic arguments are unnamed, PST passed indirectly. // (Passing SVE types to a variadic function currently unsupported by diff --git clang/test/CodeGen/AArch64/sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.c clang/test/CodeGen/AArch64/sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.c index 28d69d52c9ae..bbed683ac1fd 100644 --- clang/test/CodeGen/AArch64/sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.c +++ clang/test/CodeGen/AArch64/sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.c @@ -59,7 +59,7 @@ typedef int8_t vec_int8 __attribute__((vector_size(N / 8))); // CHECK128-NEXT: ret <16 x i8> [[CASTFIXEDSVE]] // CHECK-LABEL: define{{.*}} void @f2( -// CHECK-SAME: ptr dead_on_unwind noalias nocapture writable writeonly sret(<[[#div(VBITS,8)]] x i8>) align 16 initializes((0, [[#div(VBITS,8)]])) %agg.result, ptr nocapture noundef readonly %0) +// CHECK-SAME: ptr dead_on_unwind noalias writable writeonly sret(<[[#div(VBITS,8)]] x i8>) align 16 captures(none) initializes((0, [[#div(VBITS,8)]])) %agg.result, ptr noundef readonly captures(none) %0) // CHECK-NEXT: entry: // CHECK-NEXT: [[X:%.*]] = load <[[#div(VBITS,8)]] x i8>, ptr [[TMP0:%.*]], align 16, [[TBAA6:!tbaa !.*]] // CHECK-NEXT: [[TMP1:%.*]] = tail call <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 31) diff --git clang/test/CodeGen/PowerPC/aix-vaargs.c clang/test/CodeGen/PowerPC/aix-vaargs.c index 724ba6560cdb..8716a9e4698c 100644 --- clang/test/CodeGen/PowerPC/aix-vaargs.c +++ clang/test/CodeGen/PowerPC/aix-vaargs.c @@ -68,8 +68,8 @@ void testva (int n, ...) { // CHECK: declare void @llvm.va_start.p0(ptr) -// AIX32: declare void @llvm.memcpy.p0.p0.i32(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i32, i1 immarg) -// AIX64: declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) +// AIX32: declare void @llvm.memcpy.p0.p0.i32(ptr noalias writeonly captures(none), ptr noalias readonly captures(none), i32, i1 immarg) +// AIX64: declare void @llvm.memcpy.p0.p0.i64(ptr noalias writeonly captures(none), ptr noalias readonly captures(none), i64, i1 immarg) // CHECK: declare void @llvm.va_copy.p0(ptr, ptr) // CHECK: declare void @llvm.va_end.p0(ptr) diff --git clang/test/CodeGen/SystemZ/systemz-inline-asm.c clang/test/CodeGen/SystemZ/systemz-inline-asm.c index 2a9d6a5f8745..9e62b8e10790 100644 --- clang/test/CodeGen/SystemZ/systemz-inline-asm.c +++ clang/test/CodeGen/SystemZ/systemz-inline-asm.c @@ -123,7 +123,7 @@ double test_f64(double f, double g) { long double test_f128(long double f, long double g) { asm("axbr %0, %2" : "=f" (f) : "0" (f), "f" (g)); return f; -// CHECK: define{{.*}} void @test_f128(ptr dead_on_unwind noalias nocapture writable writeonly sret(fp128) align 8 initializes((0, 16)) [[DEST:%.*]], ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) +// CHECK: define{{.*}} void @test_f128(ptr dead_on_unwind noalias writable writeonly sret(fp128) align 8 captures(none) initializes((0, 16)) [[DEST:%.*]], ptr noundef readonly captures(none) %0, ptr noundef readonly captures(none) %1) // CHECK: %f = load fp128, ptr %0 // CHECK: %g = load fp128, ptr %1 // CHECK: [[RESULT:%.*]] = tail call fp128 asm "axbr $0, $2", "=f,0,f"(fp128 %f, fp128 %g) diff --git clang/test/CodeGen/allow-ubsan-check.c clang/test/CodeGen/allow-ubsan-check.c index 38b4848c1edc..b88c1f9cb220 100644 --- clang/test/CodeGen/allow-ubsan-check.c +++ clang/test/CodeGen/allow-ubsan-check.c @@ -202,7 +202,7 @@ void use(double*); // TR-NEXT: [[TMP5:%.*]] = load double, ptr [[ARRAYIDX]], align 8, !tbaa [[TBAA7:![0-9]+]] // TR-NEXT: ret double [[TMP5]] // TR: [[TRAP]]: -// TR-NEXT: call void @llvm.ubsantrap(i8 3) #[[ATTR5]], !nosanitize [[META2]] +// TR-NEXT: call void @llvm.ubsantrap(i8 71) #[[ATTR5]], !nosanitize [[META2]] // TR-NEXT: unreachable, !nosanitize [[META2]] // // REC-LABEL: define dso_local double @lbounds( diff --git clang/test/CodeGen/arm-cmse-attr.c clang/test/CodeGen/arm-cmse-attr.c index 6322a82dfa46..b01124a03df7 100644 --- clang/test/CodeGen/arm-cmse-attr.c +++ clang/test/CodeGen/arm-cmse-attr.c @@ -29,9 +29,9 @@ void f4(void) __attribute__((cmse_nonsecure_entry)) { } -// CHECK: define{{.*}} void @f1(ptr nocapture noundef readonly %fptr) {{[^#]*}}#0 { +// CHECK: define{{.*}} void @f1(ptr noundef readonly captures(none) %fptr) {{[^#]*}}#0 { // CHECK: call void %fptr() #2 -// CHECK: define{{.*}} void @f2(ptr nocapture noundef readonly %fptr) {{[^#]*}}#0 { +// CHECK: define{{.*}} void @f2(ptr noundef readonly captures(none) %fptr) {{[^#]*}}#0 { // CHECK: call void %fptr() #2 // CHECK: define{{.*}} void @f3() {{[^#]*}}#1 { // CHECK: define{{.*}} void @f4() {{[^#]*}}#1 { diff --git clang/test/CodeGen/arm-mfp8.c clang/test/CodeGen/arm-mfp8.c index bf91066335a2..9385b537f18b 100644 --- clang/test/CodeGen/arm-mfp8.c +++ clang/test/CodeGen/arm-mfp8.c @@ -1,6 +1,6 @@ // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 -// RUN: %clang_cc1 -emit-llvm -triple aarch64-arm-none-eabi -target-feature -fp8 -target-feature +neon -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-C -// RUN: %clang_cc1 -emit-llvm -triple aarch64-arm-none-eabi -target-feature -fp8 -target-feature +neon -o - -x c++ %s | FileCheck %s --check-prefixes=CHECK,CHECK-CXX +// RUN: %clang_cc1 -emit-llvm -triple aarch64-arm-none-eabi -target-feature -fp8 -target-feature +neon -disable-O0-optnone -o - %s | opt -S --passes=mem2reg | FileCheck %s --check-prefixes=CHECK-C +// RUN: %clang_cc1 -emit-llvm -triple aarch64-arm-none-eabi -target-feature -fp8 -target-feature +neon -disable-O0-optnone -o - -x c++ %s | opt -S --passes=mem2reg | FileCheck %s --check-prefixes=CHECK-CXX // REQUIRES: aarch64-registered-target @@ -10,18 +10,12 @@ // CHECK-C-LABEL: define dso_local <16 x i8> @test_ret_mfloat8x16_t( // CHECK-C-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0:[0-9]+]] { // CHECK-C-NEXT: [[ENTRY:.*:]] -// CHECK-C-NEXT: [[V_ADDR:%.*]] = alloca <16 x i8>, align 16 -// CHECK-C-NEXT: store <16 x i8> [[V]], ptr [[V_ADDR]], align 16 -// CHECK-C-NEXT: [[TMP0:%.*]] = load <16 x i8>, ptr [[V_ADDR]], align 16 -// CHECK-C-NEXT: ret <16 x i8> [[TMP0]] +// CHECK-C-NEXT: ret <16 x i8> [[V]] // -// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z21test_ret_mfloat8x16_tu14__MFloat8x16_t( +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z21test_ret_mfloat8x16_t14__Mfloat8x16_t( // CHECK-CXX-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0:[0-9]+]] { // CHECK-CXX-NEXT: [[ENTRY:.*:]] -// CHECK-CXX-NEXT: [[V_ADDR:%.*]] = alloca <16 x i8>, align 16 -// CHECK-CXX-NEXT: store <16 x i8> [[V]], ptr [[V_ADDR]], align 16 -// CHECK-CXX-NEXT: [[TMP0:%.*]] = load <16 x i8>, ptr [[V_ADDR]], align 16 -// CHECK-CXX-NEXT: ret <16 x i8> [[TMP0]] +// CHECK-CXX-NEXT: ret <16 x i8> [[V]] // mfloat8x16_t test_ret_mfloat8x16_t(mfloat8x16_t v) { return v; @@ -30,18 +24,12 @@ mfloat8x16_t test_ret_mfloat8x16_t(mfloat8x16_t v) { // CHECK-C-LABEL: define dso_local <8 x i8> @test_ret_mfloat8x8_t( // CHECK-C-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { // CHECK-C-NEXT: [[ENTRY:.*:]] -// CHECK-C-NEXT: [[V_ADDR:%.*]] = alloca <8 x i8>, align 8 -// CHECK-C-NEXT: store <8 x i8> [[V]], ptr [[V_ADDR]], align 8 -// CHECK-C-NEXT: [[TMP0:%.*]] = load <8 x i8>, ptr [[V_ADDR]], align 8 -// CHECK-C-NEXT: ret <8 x i8> [[TMP0]] +// CHECK-C-NEXT: ret <8 x i8> [[V]] // -// CHECK-CXX-LABEL: define dso_local <8 x i8> @_Z20test_ret_mfloat8x8_tu13__MFloat8x8_t( +// CHECK-CXX-LABEL: define dso_local <8 x i8> @_Z20test_ret_mfloat8x8_t13__Mfloat8x8_t( // CHECK-CXX-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] { // CHECK-CXX-NEXT: [[ENTRY:.*:]] -// CHECK-CXX-NEXT: [[V_ADDR:%.*]] = alloca <8 x i8>, align 8 -// CHECK-CXX-NEXT: store <8 x i8> [[V]], ptr [[V_ADDR]], align 8 -// CHECK-CXX-NEXT: [[TMP0:%.*]] = load <8 x i8>, ptr [[V_ADDR]], align 8 -// CHECK-CXX-NEXT: ret <8 x i8> [[TMP0]] +// CHECK-CXX-NEXT: ret <8 x i8> [[V]] // mfloat8x8_t test_ret_mfloat8x8_t(mfloat8x8_t v) { return v; @@ -50,28 +38,22 @@ mfloat8x8_t test_ret_mfloat8x8_t(mfloat8x8_t v) { // CHECK-C-LABEL: define dso_local <1 x i8> @func1n( // CHECK-C-SAME: <1 x i8> [[MFP8:%.*]]) #[[ATTR0]] { // CHECK-C-NEXT: [[ENTRY:.*:]] -// CHECK-C-NEXT: [[MFP8_ADDR:%.*]] = alloca <1 x i8>, align 1 // CHECK-C-NEXT: [[F1N:%.*]] = alloca [10 x <1 x i8>], align 1 -// CHECK-C-NEXT: store <1 x i8> [[MFP8]], ptr [[MFP8_ADDR]], align 1 -// CHECK-C-NEXT: [[TMP0:%.*]] = load <1 x i8>, ptr [[MFP8_ADDR]], align 1 // CHECK-C-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [10 x <1 x i8>], ptr [[F1N]], i64 0, i64 2 -// CHECK-C-NEXT: store <1 x i8> [[TMP0]], ptr [[ARRAYIDX]], align 1 +// CHECK-C-NEXT: store <1 x i8> [[MFP8]], ptr [[ARRAYIDX]], align 1 // CHECK-C-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds [10 x <1 x i8>], ptr [[F1N]], i64 0, i64 2 -// CHECK-C-NEXT: [[TMP1:%.*]] = load <1 x i8>, ptr [[ARRAYIDX1]], align 1 -// CHECK-C-NEXT: ret <1 x i8> [[TMP1]] +// CHECK-C-NEXT: [[TMP0:%.*]] = load <1 x i8>, ptr [[ARRAYIDX1]], align 1 +// CHECK-C-NEXT: ret <1 x i8> [[TMP0]] // // CHECK-CXX-LABEL: define dso_local <1 x i8> @_Z6func1nu6__mfp8( // CHECK-CXX-SAME: <1 x i8> [[MFP8:%.*]]) #[[ATTR0]] { // CHECK-CXX-NEXT: [[ENTRY:.*:]] -// CHECK-CXX-NEXT: [[MFP8_ADDR:%.*]] = alloca <1 x i8>, align 1 // CHECK-CXX-NEXT: [[F1N:%.*]] = alloca [10 x <1 x i8>], align 1 -// CHECK-CXX-NEXT: store <1 x i8> [[MFP8]], ptr [[MFP8_ADDR]], align 1 -// CHECK-CXX-NEXT: [[TMP0:%.*]] = load <1 x i8>, ptr [[MFP8_ADDR]], align 1 // CHECK-CXX-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [10 x <1 x i8>], ptr [[F1N]], i64 0, i64 2 -// CHECK-CXX-NEXT: store <1 x i8> [[TMP0]], ptr [[ARRAYIDX]], align 1 +// CHECK-CXX-NEXT: store <1 x i8> [[MFP8]], ptr [[ARRAYIDX]], align 1 // CHECK-CXX-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds [10 x <1 x i8>], ptr [[F1N]], i64 0, i64 2 -// CHECK-CXX-NEXT: [[TMP1:%.*]] = load <1 x i8>, ptr [[ARRAYIDX1]], align 1 -// CHECK-CXX-NEXT: ret <1 x i8> [[TMP1]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = load <1 x i8>, ptr [[ARRAYIDX1]], align 1 +// CHECK-CXX-NEXT: ret <1 x i8> [[TMP0]] // __mfp8 func1n(__mfp8 mfp8) { __mfp8 f1n[10]; @@ -79,7 +61,43 @@ __mfp8 func1n(__mfp8 mfp8) { return f1n[2]; } +// CHECK-C-LABEL: define dso_local <1 x i8> @test_extract_element( +// CHECK-C-SAME: <16 x i8> [[X:%.*]], i32 noundef [[I:%.*]]) #[[ATTR0]] { +// CHECK-C-NEXT: [[ENTRY:.*:]] +// CHECK-C-NEXT: [[RETVAL:%.*]] = alloca <1 x i8>, align 1 +// CHECK-C-NEXT: [[VECEXT:%.*]] = extractelement <16 x i8> [[X]], i32 [[I]] +// CHECK-C-NEXT: store i8 [[VECEXT]], ptr [[RETVAL]], align 1 +// CHECK-C-NEXT: [[TMP0:%.*]] = load <1 x i8>, ptr [[RETVAL]], align 1 +// CHECK-C-NEXT: ret <1 x i8> [[TMP0]] +// +// CHECK-CXX-LABEL: define dso_local <1 x i8> @_Z20test_extract_element14__Mfloat8x16_ti( +// CHECK-CXX-SAME: <16 x i8> [[X:%.*]], i32 noundef [[I:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[RETVAL:%.*]] = alloca <1 x i8>, align 1 +// CHECK-CXX-NEXT: [[VECEXT:%.*]] = extractelement <16 x i8> [[X]], i32 [[I]] +// CHECK-CXX-NEXT: store i8 [[VECEXT]], ptr [[RETVAL]], align 1 +// CHECK-CXX-NEXT: [[TMP0:%.*]] = load <1 x i8>, ptr [[RETVAL]], align 1 +// CHECK-CXX-NEXT: ret <1 x i8> [[TMP0]] +// +mfloat8_t test_extract_element(mfloat8x16_t x, int i) { + return x[i]; +} - -//// NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: -// CHECK: {{.*}} +// CHECK-C-LABEL: define dso_local <16 x i8> @test_insert_element( +// CHECK-C-SAME: <16 x i8> [[X:%.*]], i32 noundef [[I:%.*]], <1 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-C-NEXT: [[ENTRY:.*:]] +// CHECK-C-NEXT: [[TMP0:%.*]] = bitcast <1 x i8> [[V]] to i8 +// CHECK-C-NEXT: [[VECINS:%.*]] = insertelement <16 x i8> [[X]], i8 [[TMP0]], i32 [[I]] +// CHECK-C-NEXT: ret <16 x i8> [[VECINS]] +// +// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z19test_insert_element14__Mfloat8x16_tiu6__mfp8( +// CHECK-CXX-SAME: <16 x i8> [[X:%.*]], i32 noundef [[I:%.*]], <1 x i8> [[V:%.*]]) #[[ATTR0]] { +// CHECK-CXX-NEXT: [[ENTRY:.*:]] +// CHECK-CXX-NEXT: [[TMP0:%.*]] = bitcast <1 x i8> [[V]] to i8 +// CHECK-CXX-NEXT: [[VECINS:%.*]] = insertelement <16 x i8> [[X]], i8 [[TMP0]], i32 [[I]] +// CHECK-CXX-NEXT: ret <16 x i8> [[VECINS]] +// +mfloat8x16_t test_insert_element(mfloat8x16_t x, int i, mfloat8_t v) { + x[i] = v; + return x; +} diff --git clang/test/CodeGen/arm-vfp16-arguments.c clang/test/CodeGen/arm-vfp16-arguments.c index 3c6691df4747..c0bbb3df72bf 100644 --- clang/test/CodeGen/arm-vfp16-arguments.c +++ clang/test/CodeGen/arm-vfp16-arguments.c @@ -71,6 +71,6 @@ void test_hfa(hfa_t a) {} hfa_t ghfa; hfa_t test_ret_hfa(void) { return ghfa; } -// CHECK-SOFT: define{{.*}} void @test_ret_hfa(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.hfa_t) align 8 initializes((0, 16)) %agg.result) +// CHECK-SOFT: define{{.*}} void @test_ret_hfa(ptr dead_on_unwind noalias writable writeonly sret(%struct.hfa_t) align 8 captures(none) initializes((0, 16)) %agg.result) // CHECK-HARD: define{{.*}} arm_aapcs_vfpcc [2 x <2 x i32>] @test_ret_hfa() // CHECK-FULL: define{{.*}} arm_aapcs_vfpcc %struct.hfa_t @test_ret_hfa() diff --git clang/test/CodeGen/arm-vfp16-arguments2.cpp clang/test/CodeGen/arm-vfp16-arguments2.cpp index b810cfd0a664..6e9a24e70c14 100644 --- clang/test/CodeGen/arm-vfp16-arguments2.cpp +++ clang/test/CodeGen/arm-vfp16-arguments2.cpp @@ -37,27 +37,27 @@ struct S5 : B1 { B1 M[1]; }; -// CHECK-SOFT: define{{.*}} void @_Z2f12S1(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.S1) align 8 initializes((0, 16)) %agg.result, [2 x i64] %s1.coerce) +// CHECK-SOFT: define{{.*}} void @_Z2f12S1(ptr dead_on_unwind noalias writable writeonly sret(%struct.S1) align 8 captures(none) initializes((0, 16)) %agg.result, [2 x i64] %s1.coerce) // CHECK-HARD: define{{.*}} arm_aapcs_vfpcc [2 x <2 x i32>] @_Z2f12S1([2 x <2 x i32>] returned %s1.coerce) // CHECK-FULL: define{{.*}} arm_aapcs_vfpcc %struct.S1 @_Z2f12S1(%struct.S1 returned %s1.coerce) struct S1 f1(struct S1 s1) { return s1; } -// CHECK-SOFT: define{{.*}} void @_Z2f22S2(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.S2) align 8 initializes((0, 16)) %agg.result, [4 x i32] %s2.coerce) +// CHECK-SOFT: define{{.*}} void @_Z2f22S2(ptr dead_on_unwind noalias writable writeonly sret(%struct.S2) align 8 captures(none) initializes((0, 16)) %agg.result, [4 x i32] %s2.coerce) // CHECK-HARD: define{{.*}} arm_aapcs_vfpcc [2 x <2 x i32>] @_Z2f22S2([2 x <2 x i32>] returned %s2.coerce) // CHECK-FULL: define{{.*}} arm_aapcs_vfpcc %struct.S2 @_Z2f22S2(%struct.S2 %s2.coerce) struct S2 f2(struct S2 s2) { return s2; } -// CHECK-SOFT: define{{.*}} void @_Z2f32S3(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.S3) align 8 initializes((0, 16)) %agg.result, [2 x i64] %s3.coerce) +// CHECK-SOFT: define{{.*}} void @_Z2f32S3(ptr dead_on_unwind noalias writable writeonly sret(%struct.S3) align 8 captures(none) initializes((0, 16)) %agg.result, [2 x i64] %s3.coerce) // CHECK-HARD: define{{.*}} arm_aapcs_vfpcc [2 x <2 x i32>] @_Z2f32S3([2 x <2 x i32>] returned %s3.coerce) // CHECK-FULL: define{{.*}} arm_aapcs_vfpcc %struct.S3 @_Z2f32S3(%struct.S3 %s3.coerce) struct S3 f3(struct S3 s3) { return s3; } -// CHECK-SOFT: define{{.*}} void @_Z2f42S4(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.S4) align 8 initializes((0, 16)) %agg.result, [2 x i64] %s4.coerce) +// CHECK-SOFT: define{{.*}} void @_Z2f42S4(ptr dead_on_unwind noalias writable writeonly sret(%struct.S4) align 8 captures(none) initializes((0, 16)) %agg.result, [2 x i64] %s4.coerce) // CHECK-HARD: define{{.*}} arm_aapcs_vfpcc [2 x <2 x i32>] @_Z2f42S4([2 x <2 x i32>] returned %s4.coerce) // CHECK-FULL: define{{.*}} arm_aapcs_vfpcc %struct.S4 @_Z2f42S4(%struct.S4 %s4.coerce) struct S4 f4(struct S4 s4) { return s4; } -// CHECK-SOFT: define{{.*}} void @_Z2f52S5(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.S5) align 8 initializes((0, 16)) %agg.result, [2 x i64] %s5.coerce) +// CHECK-SOFT: define{{.*}} void @_Z2f52S5(ptr dead_on_unwind noalias writable writeonly sret(%struct.S5) align 8 captures(none) initializes((0, 16)) %agg.result, [2 x i64] %s5.coerce) // CHECK-HARD: define{{.*}} arm_aapcs_vfpcc %struct.S5 @_Z2f52S5(%struct.S5 %s5.coerce) // CHECK-FULL: define{{.*}} arm_aapcs_vfpcc %struct.S5 @_Z2f52S5(%struct.S5 %s5.coerce) struct S5 f5(struct S5 s5) { return s5; } diff --git clang/test/CodeGen/attr-counted-by-pr110385.c clang/test/CodeGen/attr-counted-by-pr110385.c index f211610c3173..412c12cb687c 100644 --- clang/test/CodeGen/attr-counted-by-pr110385.c +++ clang/test/CodeGen/attr-counted-by-pr110385.c @@ -26,7 +26,7 @@ struct bucket2 { void init(void * __attribute__((pass_dynamic_object_size(0)))); // CHECK-LABEL: define dso_local void @test1( -// CHECK-SAME: ptr nocapture noundef readonly [[FOO:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { +// CHECK-SAME: ptr noundef readonly captures(none) [[FOO:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { // CHECK-NEXT: entry: // CHECK-NEXT: [[GROWABLE:%.*]] = getelementptr inbounds nuw i8, ptr [[FOO]], i64 8 // CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[GROWABLE]], align 8, !tbaa [[TBAA2:![0-9]+]] diff --git clang/test/CodeGen/attr-counted-by.c clang/test/CodeGen/attr-counted-by.c index 1066e2e74160..71fc6c5da2b8 100644 --- clang/test/CodeGen/attr-counted-by.c +++ clang/test/CodeGen/attr-counted-by.c @@ -75,7 +75,7 @@ struct anon_struct { // SANITIZE-WITH-ATTR-NEXT: ret void // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local void @test1( -// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef writeonly [[P:%.*]], i32 noundef [[INDEX:%.*]], i32 noundef [[VAL:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { +// NO-SANITIZE-WITH-ATTR-SAME: ptr noundef writeonly captures(none) [[P:%.*]], i32 noundef [[INDEX:%.*]], i32 noundef [[VAL:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: [[ARRAY:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 12 // NO-SANITIZE-WITH-ATTR-NEXT: [[IDXPROM:%.*]] = sext i32 [[INDEX]] to i64 @@ -93,7 +93,7 @@ struct anon_struct { // SANITIZE-WITHOUT-ATTR-NEXT: ret void // // NO-SANITIZE-WITHOUT-ATTR-LABEL: define dso_local void @test1( -// NO-SANITIZE-WITHOUT-ATTR-SAME: ptr nocapture noundef writeonly [[P:%.*]], i32 noundef [[INDEX:%.*]], i32 noundef [[VAL:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { +// NO-SANITIZE-WITHOUT-ATTR-SAME: ptr noundef writeonly captures(none) [[P:%.*]], i32 noundef [[INDEX:%.*]], i32 noundef [[VAL:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { // NO-SANITIZE-WITHOUT-ATTR-NEXT: entry: // NO-SANITIZE-WITHOUT-ATTR-NEXT: [[ARRAY:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 12 // NO-SANITIZE-WITHOUT-ATTR-NEXT: [[IDXPROM:%.*]] = sext i32 [[INDEX]] to i64 @@ -125,7 +125,7 @@ void test1(struct annotated *p, int index, int val) { // SANITIZE-WITH-ATTR-NEXT: ret void // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local void @test2( -// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef [[P:%.*]], i64 noundef [[INDEX:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] { +// NO-SANITIZE-WITH-ATTR-SAME: ptr noundef captures(none) [[P:%.*]], i64 noundef [[INDEX:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_GEP:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 8 // NO-SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_LOAD:%.*]] = load i32, ptr [[COUNTED_BY_GEP]], align 4 @@ -157,7 +157,7 @@ void test2(struct annotated *p, size_t index) { } // SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 -8589934592, 8589934589) i64 @test2_bdos( -// SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] { +// SANITIZE-WITH-ATTR-SAME: ptr noundef readonly captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] { // SANITIZE-WITH-ATTR-NEXT: entry: // SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_GEP:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 8 // SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_LOAD:%.*]] = load i32, ptr [[COUNTED_BY_GEP]], align 4 @@ -168,7 +168,7 @@ void test2(struct annotated *p, size_t index) { // SANITIZE-WITH-ATTR-NEXT: ret i64 [[TMP3]] // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 -8589934592, 8589934589) i64 @test2_bdos( -// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] { +// NO-SANITIZE-WITH-ATTR-SAME: ptr noundef readonly captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_GEP:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 8 // NO-SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_LOAD:%.*]] = load i32, ptr [[COUNTED_BY_GEP]], align 4 @@ -323,7 +323,7 @@ size_t test3_bdos(struct annotated *p) { // SANITIZE-WITH-ATTR-NEXT: ret void // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local void @test4( -// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef [[P:%.*]], i32 noundef [[INDEX:%.*]], i32 noundef [[FAM_IDX:%.*]]) local_unnamed_addr #[[ATTR1]] { +// NO-SANITIZE-WITH-ATTR-SAME: ptr noundef captures(none) [[P:%.*]], i32 noundef [[INDEX:%.*]], i32 noundef [[FAM_IDX:%.*]]) local_unnamed_addr #[[ATTR1]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_GEP:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 8 // NO-SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_LOAD:%.*]] = load i32, ptr [[COUNTED_BY_GEP]], align 4 @@ -405,7 +405,7 @@ void test4(struct annotated *p, int index, int fam_idx) { } // SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 -17179869180, 17179869181) i64 @test4_bdos( -// SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]], i32 noundef [[INDEX:%.*]]) local_unnamed_addr #[[ATTR2]] { +// SANITIZE-WITH-ATTR-SAME: ptr noundef readonly captures(none) [[P:%.*]], i32 noundef [[INDEX:%.*]]) local_unnamed_addr #[[ATTR2]] { // SANITIZE-WITH-ATTR-NEXT: entry: // SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_GEP:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 8 // SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_LOAD:%.*]] = load i32, ptr [[COUNTED_BY_GEP]], align 4 @@ -420,7 +420,7 @@ void test4(struct annotated *p, int index, int fam_idx) { // SANITIZE-WITH-ATTR-NEXT: ret i64 [[TMP7]] // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 -17179869180, 17179869181) i64 @test4_bdos( -// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]], i32 noundef [[INDEX:%.*]]) local_unnamed_addr #[[ATTR2]] { +// NO-SANITIZE-WITH-ATTR-SAME: ptr noundef readonly captures(none) [[P:%.*]], i32 noundef [[INDEX:%.*]]) local_unnamed_addr #[[ATTR2]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_GEP:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 8 // NO-SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_LOAD:%.*]] = load i32, ptr [[COUNTED_BY_GEP]], align 4 @@ -541,7 +541,7 @@ size_t test5_bdos(struct anon_struct *p) { // SANITIZE-WITH-ATTR-NEXT: ret void // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local void @test6( -// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef [[P:%.*]], i32 noundef [[INDEX:%.*]]) local_unnamed_addr #[[ATTR1]] { +// NO-SANITIZE-WITH-ATTR-SAME: ptr noundef captures(none) [[P:%.*]], i32 noundef [[INDEX:%.*]]) local_unnamed_addr #[[ATTR1]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_GEP:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 8 // NO-SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_LOAD:%.*]] = load i64, ptr [[COUNTED_BY_GEP]], align 4 @@ -577,7 +577,7 @@ void test6(struct anon_struct *p, int index) { } // SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 0, -3) i64 @test6_bdos( -// SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { +// SANITIZE-WITH-ATTR-SAME: ptr noundef readonly captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { // SANITIZE-WITH-ATTR-NEXT: entry: // SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_GEP:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 8 // SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_LOAD:%.*]] = load i64, ptr [[COUNTED_BY_GEP]], align 4 @@ -586,7 +586,7 @@ void test6(struct anon_struct *p, int index) { // SANITIZE-WITH-ATTR-NEXT: ret i64 [[TMP1]] // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 0, -3) i64 @test6_bdos( -// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { +// NO-SANITIZE-WITH-ATTR-SAME: ptr noundef readonly captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_GEP:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 8 // NO-SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_LOAD:%.*]] = load i64, ptr [[COUNTED_BY_GEP]], align 4 @@ -700,7 +700,7 @@ size_t test7_bdos(struct union_of_fams *p) { // SANITIZE-WITH-ATTR-NEXT: ret void // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local void @test8( -// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef [[P:%.*]], i32 noundef [[INDEX:%.*]]) local_unnamed_addr #[[ATTR1]] { +// NO-SANITIZE-WITH-ATTR-SAME: ptr noundef captures(none) [[P:%.*]], i32 noundef [[INDEX:%.*]]) local_unnamed_addr #[[ATTR1]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_GEP:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 8 // NO-SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_LOAD:%.*]] = load i8, ptr [[COUNTED_BY_GEP]], align 4 @@ -733,7 +733,7 @@ void test8(struct union_of_fams *p, int index) { } // SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 0, 256) i64 @test8_bdos( -// SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { +// SANITIZE-WITH-ATTR-SAME: ptr noundef readonly captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { // SANITIZE-WITH-ATTR-NEXT: entry: // SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_GEP:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 8 // SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_LOAD:%.*]] = load i8, ptr [[COUNTED_BY_GEP]], align 4 @@ -741,7 +741,7 @@ void test8(struct union_of_fams *p, int index) { // SANITIZE-WITH-ATTR-NEXT: ret i64 [[TMP0]] // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 0, 256) i64 @test8_bdos( -// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { +// NO-SANITIZE-WITH-ATTR-SAME: ptr noundef readonly captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_GEP:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 8 // NO-SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_LOAD:%.*]] = load i8, ptr [[COUNTED_BY_GEP]], align 4 @@ -856,7 +856,7 @@ size_t test9_bdos(struct union_of_fams *p) { // SANITIZE-WITH-ATTR-NEXT: ret void // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local void @test10( -// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef [[P:%.*]], i32 noundef [[INDEX:%.*]]) local_unnamed_addr #[[ATTR1]] { +// NO-SANITIZE-WITH-ATTR-SAME: ptr noundef captures(none) [[P:%.*]], i32 noundef [[INDEX:%.*]]) local_unnamed_addr #[[ATTR1]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_GEP:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 8 // NO-SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_LOAD:%.*]] = load i32, ptr [[COUNTED_BY_GEP]], align 4 @@ -891,7 +891,7 @@ void test10(struct union_of_fams *p, int index) { } // SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 0, 2147483648) i64 @test10_bdos( -// SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { +// SANITIZE-WITH-ATTR-SAME: ptr noundef readonly captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { // SANITIZE-WITH-ATTR-NEXT: entry: // SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_GEP:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 8 // SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_LOAD:%.*]] = load i32, ptr [[COUNTED_BY_GEP]], align 4 @@ -900,7 +900,7 @@ void test10(struct union_of_fams *p, int index) { // SANITIZE-WITH-ATTR-NEXT: ret i64 [[TMP0]] // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 0, 2147483648) i64 @test10_bdos( -// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { +// NO-SANITIZE-WITH-ATTR-SAME: ptr noundef readonly captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_GEP:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 8 // NO-SANITIZE-WITH-ATTR-NEXT: [[COUNTED_BY_LOAD:%.*]] = load i32, ptr [[COUNTED_BY_GEP]], align 4 @@ -941,7 +941,7 @@ size_t test10_bdos(struct union_of_fams *p) { // SANITIZE-WITH-ATTR-NEXT: ret void // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local void @test11( -// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef writeonly [[P:%.*]], i32 noundef [[INDEX:%.*]]) local_unnamed_addr #[[ATTR0]] { +// NO-SANITIZE-WITH-ATTR-SAME: ptr noundef writeonly captures(none) [[P:%.*]], i32 noundef [[INDEX:%.*]]) local_unnamed_addr #[[ATTR0]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: [[ARRAY:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 12 // NO-SANITIZE-WITH-ATTR-NEXT: [[IDXPROM:%.*]] = sext i32 [[INDEX]] to i64 @@ -959,7 +959,7 @@ size_t test10_bdos(struct union_of_fams *p) { // SANITIZE-WITHOUT-ATTR-NEXT: ret void // // NO-SANITIZE-WITHOUT-ATTR-LABEL: define dso_local void @test11( -// NO-SANITIZE-WITHOUT-ATTR-SAME: ptr nocapture noundef writeonly [[P:%.*]], i32 noundef [[INDEX:%.*]]) local_unnamed_addr #[[ATTR0]] { +// NO-SANITIZE-WITHOUT-ATTR-SAME: ptr noundef writeonly captures(none) [[P:%.*]], i32 noundef [[INDEX:%.*]]) local_unnamed_addr #[[ATTR0]] { // NO-SANITIZE-WITHOUT-ATTR-NEXT: entry: // NO-SANITIZE-WITHOUT-ATTR-NEXT: [[ARRAY:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 12 // NO-SANITIZE-WITHOUT-ATTR-NEXT: [[IDXPROM:%.*]] = sext i32 [[INDEX]] to i64 @@ -972,22 +972,22 @@ void test11(struct annotated *p, int index) { } // SANITIZE-WITH-ATTR-LABEL: define dso_local noundef i64 @test11_bdos( -// SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readnone [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { +// SANITIZE-WITH-ATTR-SAME: ptr noundef readnone captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { // SANITIZE-WITH-ATTR-NEXT: entry: // SANITIZE-WITH-ATTR-NEXT: ret i64 4 // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local noundef i64 @test11_bdos( -// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readnone [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { +// NO-SANITIZE-WITH-ATTR-SAME: ptr noundef readnone captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: ret i64 4 // // SANITIZE-WITHOUT-ATTR-LABEL: define dso_local noundef i64 @test11_bdos( -// SANITIZE-WITHOUT-ATTR-SAME: ptr nocapture noundef readnone [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { +// SANITIZE-WITHOUT-ATTR-SAME: ptr noundef readnone captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { // SANITIZE-WITHOUT-ATTR-NEXT: entry: // SANITIZE-WITHOUT-ATTR-NEXT: ret i64 4 // // NO-SANITIZE-WITHOUT-ATTR-LABEL: define dso_local noundef i64 @test11_bdos( -// NO-SANITIZE-WITHOUT-ATTR-SAME: ptr nocapture noundef readnone [[P:%.*]]) local_unnamed_addr #[[ATTR1]] { +// NO-SANITIZE-WITHOUT-ATTR-SAME: ptr noundef readnone captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR1]] { // NO-SANITIZE-WITHOUT-ATTR-NEXT: entry: // NO-SANITIZE-WITHOUT-ATTR-NEXT: ret i64 4 // @@ -1281,12 +1281,12 @@ int test15(int idx) { } // SANITIZE-WITH-ATTR-LABEL: define dso_local noundef i64 @test19( -// SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readnone [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { +// SANITIZE-WITH-ATTR-SAME: ptr noundef readnone captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { // SANITIZE-WITH-ATTR-NEXT: entry: // SANITIZE-WITH-ATTR-NEXT: ret i64 -1 // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local noundef i64 @test19( -// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readnone [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { +// NO-SANITIZE-WITH-ATTR-SAME: ptr noundef readnone captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: ret i64 -1 // @@ -1306,22 +1306,22 @@ size_t test19(struct annotated *p) { } // SANITIZE-WITH-ATTR-LABEL: define dso_local noundef i64 @test20( -// SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readnone [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { +// SANITIZE-WITH-ATTR-SAME: ptr noundef readnone captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { // SANITIZE-WITH-ATTR-NEXT: entry: // SANITIZE-WITH-ATTR-NEXT: ret i64 -1 // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local noundef i64 @test20( -// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readnone [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { +// NO-SANITIZE-WITH-ATTR-SAME: ptr noundef readnone captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: ret i64 -1 // // SANITIZE-WITHOUT-ATTR-LABEL: define dso_local noundef i64 @test20( -// SANITIZE-WITHOUT-ATTR-SAME: ptr nocapture noundef readnone [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { +// SANITIZE-WITHOUT-ATTR-SAME: ptr noundef readnone captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { // SANITIZE-WITHOUT-ATTR-NEXT: entry: // SANITIZE-WITHOUT-ATTR-NEXT: ret i64 -1 // // NO-SANITIZE-WITHOUT-ATTR-LABEL: define dso_local noundef i64 @test20( -// NO-SANITIZE-WITHOUT-ATTR-SAME: ptr nocapture noundef readnone [[P:%.*]]) local_unnamed_addr #[[ATTR1]] { +// NO-SANITIZE-WITHOUT-ATTR-SAME: ptr noundef readnone captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR1]] { // NO-SANITIZE-WITHOUT-ATTR-NEXT: entry: // NO-SANITIZE-WITHOUT-ATTR-NEXT: ret i64 -1 // @@ -1331,22 +1331,22 @@ size_t test20(struct annotated *p) { } // SANITIZE-WITH-ATTR-LABEL: define dso_local noundef i64 @test21( -// SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readnone [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { +// SANITIZE-WITH-ATTR-SAME: ptr noundef readnone captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { // SANITIZE-WITH-ATTR-NEXT: entry: // SANITIZE-WITH-ATTR-NEXT: ret i64 -1 // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local noundef i64 @test21( -// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readnone [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { +// NO-SANITIZE-WITH-ATTR-SAME: ptr noundef readnone captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: ret i64 -1 // // SANITIZE-WITHOUT-ATTR-LABEL: define dso_local noundef i64 @test21( -// SANITIZE-WITHOUT-ATTR-SAME: ptr nocapture noundef readnone [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { +// SANITIZE-WITHOUT-ATTR-SAME: ptr noundef readnone captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { // SANITIZE-WITHOUT-ATTR-NEXT: entry: // SANITIZE-WITHOUT-ATTR-NEXT: ret i64 -1 // // NO-SANITIZE-WITHOUT-ATTR-LABEL: define dso_local noundef i64 @test21( -// NO-SANITIZE-WITHOUT-ATTR-SAME: ptr nocapture noundef readnone [[P:%.*]]) local_unnamed_addr #[[ATTR1]] { +// NO-SANITIZE-WITHOUT-ATTR-SAME: ptr noundef readnone captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR1]] { // NO-SANITIZE-WITHOUT-ATTR-NEXT: entry: // NO-SANITIZE-WITHOUT-ATTR-NEXT: ret i64 -1 // @@ -1356,22 +1356,22 @@ size_t test21(struct annotated *p) { } // SANITIZE-WITH-ATTR-LABEL: define dso_local noundef i64 @test22( -// SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readnone [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { +// SANITIZE-WITH-ATTR-SAME: ptr noundef readnone captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { // SANITIZE-WITH-ATTR-NEXT: entry: // SANITIZE-WITH-ATTR-NEXT: ret i64 -1 // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local noundef i64 @test22( -// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readnone [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { +// NO-SANITIZE-WITH-ATTR-SAME: ptr noundef readnone captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: ret i64 -1 // // SANITIZE-WITHOUT-ATTR-LABEL: define dso_local noundef i64 @test22( -// SANITIZE-WITHOUT-ATTR-SAME: ptr nocapture noundef readnone [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { +// SANITIZE-WITHOUT-ATTR-SAME: ptr noundef readnone captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { // SANITIZE-WITHOUT-ATTR-NEXT: entry: // SANITIZE-WITHOUT-ATTR-NEXT: ret i64 -1 // // NO-SANITIZE-WITHOUT-ATTR-LABEL: define dso_local noundef i64 @test22( -// NO-SANITIZE-WITHOUT-ATTR-SAME: ptr nocapture noundef readnone [[P:%.*]]) local_unnamed_addr #[[ATTR1]] { +// NO-SANITIZE-WITHOUT-ATTR-SAME: ptr noundef readnone captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR1]] { // NO-SANITIZE-WITHOUT-ATTR-NEXT: entry: // NO-SANITIZE-WITHOUT-ATTR-NEXT: ret i64 -1 // @@ -1381,22 +1381,22 @@ size_t test22(struct annotated *p) { } // SANITIZE-WITH-ATTR-LABEL: define dso_local noundef i64 @test23( -// SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readnone [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { +// SANITIZE-WITH-ATTR-SAME: ptr noundef readnone captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { // SANITIZE-WITH-ATTR-NEXT: entry: // SANITIZE-WITH-ATTR-NEXT: ret i64 -1 // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local noundef i64 @test23( -// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readnone [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { +// NO-SANITIZE-WITH-ATTR-SAME: ptr noundef readnone captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR3]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: ret i64 -1 // // SANITIZE-WITHOUT-ATTR-LABEL: define dso_local noundef i64 @test23( -// SANITIZE-WITHOUT-ATTR-SAME: ptr nocapture noundef readnone [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { +// SANITIZE-WITHOUT-ATTR-SAME: ptr noundef readnone captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { // SANITIZE-WITHOUT-ATTR-NEXT: entry: // SANITIZE-WITHOUT-ATTR-NEXT: ret i64 -1 // // NO-SANITIZE-WITHOUT-ATTR-LABEL: define dso_local noundef i64 @test23( -// NO-SANITIZE-WITHOUT-ATTR-SAME: ptr nocapture noundef readnone [[P:%.*]]) local_unnamed_addr #[[ATTR1]] { +// NO-SANITIZE-WITHOUT-ATTR-SAME: ptr noundef readnone captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR1]] { // NO-SANITIZE-WITHOUT-ATTR-NEXT: entry: // NO-SANITIZE-WITHOUT-ATTR-NEXT: ret i64 -1 // @@ -1426,7 +1426,7 @@ struct tests_foo { // SANITIZE-WITH-ATTR-NEXT: ret i32 [[TMP1]] // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local i32 @test24( -// NO-SANITIZE-WITH-ATTR-SAME: i32 noundef [[C:%.*]], ptr nocapture noundef readonly [[VAR:%.*]]) local_unnamed_addr #[[ATTR2]] { +// NO-SANITIZE-WITH-ATTR-SAME: i32 noundef [[C:%.*]], ptr noundef readonly captures(none) [[VAR:%.*]]) local_unnamed_addr #[[ATTR2]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds nuw i8, ptr [[VAR]], i64 84 // NO-SANITIZE-WITH-ATTR-NEXT: [[TMP0:%.*]] = load i32, ptr [[ARRAYIDX1]], align 4, !tbaa [[TBAA2]] @@ -1440,7 +1440,7 @@ struct tests_foo { // SANITIZE-WITHOUT-ATTR-NEXT: ret i32 [[TMP0]] // // NO-SANITIZE-WITHOUT-ATTR-LABEL: define dso_local i32 @test24( -// NO-SANITIZE-WITHOUT-ATTR-SAME: i32 noundef [[C:%.*]], ptr nocapture noundef readonly [[VAR:%.*]]) local_unnamed_addr #[[ATTR6:[0-9]+]] { +// NO-SANITIZE-WITHOUT-ATTR-SAME: i32 noundef [[C:%.*]], ptr noundef readonly captures(none) [[VAR:%.*]]) local_unnamed_addr #[[ATTR6:[0-9]+]] { // NO-SANITIZE-WITHOUT-ATTR-NEXT: entry: // NO-SANITIZE-WITHOUT-ATTR-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds nuw i8, ptr [[VAR]], i64 84 // NO-SANITIZE-WITHOUT-ATTR-NEXT: [[TMP0:%.*]] = load i32, ptr [[ARRAYIDX1]], align 4, !tbaa [[TBAA2]] @@ -1467,7 +1467,7 @@ int test24(int c, struct tests_foo *var) { // SANITIZE-WITH-ATTR-NEXT: ret i32 [[TMP2]] // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local i32 @test25( -// NO-SANITIZE-WITH-ATTR-SAME: i32 noundef [[C:%.*]], ptr nocapture noundef readonly [[VAR:%.*]]) local_unnamed_addr #[[ATTR8:[0-9]+]] { +// NO-SANITIZE-WITH-ATTR-SAME: i32 noundef [[C:%.*]], ptr noundef readonly captures(none) [[VAR:%.*]]) local_unnamed_addr #[[ATTR8:[0-9]+]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: [[TMP0:%.*]] = load ptr, ptr [[VAR]], align 8, !tbaa [[TBAA14:![0-9]+]] // NO-SANITIZE-WITH-ATTR-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds nuw i8, ptr [[TMP0]], i64 44 @@ -1483,7 +1483,7 @@ int test24(int c, struct tests_foo *var) { // SANITIZE-WITHOUT-ATTR-NEXT: ret i32 [[TMP1]] // // NO-SANITIZE-WITHOUT-ATTR-LABEL: define dso_local i32 @test25( -// NO-SANITIZE-WITHOUT-ATTR-SAME: i32 noundef [[C:%.*]], ptr nocapture noundef readonly [[VAR:%.*]]) local_unnamed_addr #[[ATTR7:[0-9]+]] { +// NO-SANITIZE-WITHOUT-ATTR-SAME: i32 noundef [[C:%.*]], ptr noundef readonly captures(none) [[VAR:%.*]]) local_unnamed_addr #[[ATTR7:[0-9]+]] { // NO-SANITIZE-WITHOUT-ATTR-NEXT: entry: // NO-SANITIZE-WITHOUT-ATTR-NEXT: [[TMP0:%.*]] = load ptr, ptr [[VAR]], align 8, !tbaa [[TBAA14:![0-9]+]] // NO-SANITIZE-WITHOUT-ATTR-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds nuw i8, ptr [[TMP0]], i64 44 @@ -1520,7 +1520,7 @@ struct test26_foo { // SANITIZE-WITH-ATTR-NEXT: ret i32 [[TMP2]] // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local i32 @test26( -// NO-SANITIZE-WITH-ATTR-SAME: i32 noundef [[C:%.*]], ptr nocapture noundef readonly [[FOO:%.*]]) local_unnamed_addr #[[ATTR2]] { +// NO-SANITIZE-WITH-ATTR-SAME: i32 noundef [[C:%.*]], ptr noundef readonly captures(none) [[FOO:%.*]]) local_unnamed_addr #[[ATTR2]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: [[ARR:%.*]] = getelementptr inbounds nuw i8, ptr [[FOO]], i64 8 // NO-SANITIZE-WITH-ATTR-NEXT: [[IDXPROM:%.*]] = sext i32 [[C]] to i64 @@ -1538,7 +1538,7 @@ struct test26_foo { // SANITIZE-WITHOUT-ATTR-NEXT: ret i32 [[TMP0]] // // NO-SANITIZE-WITHOUT-ATTR-LABEL: define dso_local i32 @test26( -// NO-SANITIZE-WITHOUT-ATTR-SAME: i32 noundef [[C:%.*]], ptr nocapture noundef readonly [[FOO:%.*]]) local_unnamed_addr #[[ATTR6]] { +// NO-SANITIZE-WITHOUT-ATTR-SAME: i32 noundef [[C:%.*]], ptr noundef readonly captures(none) [[FOO:%.*]]) local_unnamed_addr #[[ATTR6]] { // NO-SANITIZE-WITHOUT-ATTR-NEXT: entry: // NO-SANITIZE-WITHOUT-ATTR-NEXT: [[ARR:%.*]] = getelementptr inbounds nuw i8, ptr [[FOO]], i64 8 // NO-SANITIZE-WITHOUT-ATTR-NEXT: [[IDXPROM:%.*]] = sext i32 [[C]] to i64 @@ -1593,7 +1593,7 @@ struct test27_foo { // SANITIZE-WITH-ATTR-NEXT: ret ptr [[ARRAYIDX5]] // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local ptr @test27( -// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]], i32 noundef [[I:%.*]], i32 noundef [[J:%.*]]) local_unnamed_addr #[[ATTR2]] { +// NO-SANITIZE-WITH-ATTR-SAME: ptr noundef readonly captures(none) [[P:%.*]], i32 noundef [[I:%.*]], i32 noundef [[J:%.*]]) local_unnamed_addr #[[ATTR2]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: [[ENTRIES:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 24 // NO-SANITIZE-WITH-ATTR-NEXT: [[IDXPROM:%.*]] = sext i32 [[I]] to i64 @@ -1615,7 +1615,7 @@ struct test27_foo { // SANITIZE-WITHOUT-ATTR-NEXT: ret ptr [[ARRAYIDX4]] // // NO-SANITIZE-WITHOUT-ATTR-LABEL: define dso_local ptr @test27( -// NO-SANITIZE-WITHOUT-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]], i32 noundef [[I:%.*]], i32 noundef [[J:%.*]]) local_unnamed_addr #[[ATTR6]] { +// NO-SANITIZE-WITHOUT-ATTR-SAME: ptr noundef readonly captures(none) [[P:%.*]], i32 noundef [[I:%.*]], i32 noundef [[J:%.*]]) local_unnamed_addr #[[ATTR6]] { // NO-SANITIZE-WITHOUT-ATTR-NEXT: entry: // NO-SANITIZE-WITHOUT-ATTR-NEXT: [[ENTRIES:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 24 // NO-SANITIZE-WITHOUT-ATTR-NEXT: [[IDXPROM:%.*]] = sext i32 [[I]] to i64 @@ -1657,7 +1657,7 @@ struct test28_foo { // SANITIZE-WITH-ATTR-NEXT: ret i32 [[TMP5]] // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local i32 @test28( -// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]], i32 noundef [[I:%.*]]) local_unnamed_addr #[[ATTR8]] { +// NO-SANITIZE-WITH-ATTR-SAME: ptr noundef readonly captures(none) [[P:%.*]], i32 noundef [[I:%.*]]) local_unnamed_addr #[[ATTR8]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: [[TMP0:%.*]] = load ptr, ptr [[P]], align 8, !tbaa [[TBAA18:![0-9]+]] // NO-SANITIZE-WITH-ATTR-NEXT: [[TMP1:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA18]] @@ -1681,7 +1681,7 @@ struct test28_foo { // SANITIZE-WITHOUT-ATTR-NEXT: ret i32 [[TMP3]] // // NO-SANITIZE-WITHOUT-ATTR-LABEL: define dso_local i32 @test28( -// NO-SANITIZE-WITHOUT-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]], i32 noundef [[I:%.*]]) local_unnamed_addr #[[ATTR7]] { +// NO-SANITIZE-WITHOUT-ATTR-SAME: ptr noundef readonly captures(none) [[P:%.*]], i32 noundef [[I:%.*]]) local_unnamed_addr #[[ATTR7]] { // NO-SANITIZE-WITHOUT-ATTR-NEXT: entry: // NO-SANITIZE-WITHOUT-ATTR-NEXT: [[TMP0:%.*]] = load ptr, ptr [[P]], align 8, !tbaa [[TBAA18:![0-9]+]] // NO-SANITIZE-WITHOUT-ATTR-NEXT: [[TMP1:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA18]] @@ -1733,7 +1733,7 @@ struct annotated_struct_array { // SANITIZE-WITH-ATTR-NEXT: ret void // // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local void @test29( -// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[ANN:%.*]], i32 noundef [[IDX1:%.*]], i32 noundef [[IDX2:%.*]]) local_unnamed_addr #[[ATTR9:[0-9]+]] { +// NO-SANITIZE-WITH-ATTR-SAME: ptr noundef readonly captures(none) [[ANN:%.*]], i32 noundef [[IDX1:%.*]], i32 noundef [[IDX2:%.*]]) local_unnamed_addr #[[ATTR9:[0-9]+]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT: [[IDXPROM:%.*]] = sext i32 [[IDX1]] to i64 // NO-SANITIZE-WITH-ATTR-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [10 x ptr], ptr [[ANN]], i64 0, i64 [[IDXPROM]] @@ -1767,7 +1767,7 @@ struct annotated_struct_array { // SANITIZE-WITHOUT-ATTR-NEXT: ret void // // NO-SANITIZE-WITHOUT-ATTR-LABEL: define dso_local void @test29( -// NO-SANITIZE-WITHOUT-ATTR-SAME: ptr nocapture noundef readonly [[ANN:%.*]], i32 noundef [[IDX1:%.*]], i32 noundef [[IDX2:%.*]]) local_unnamed_addr #[[ATTR8:[0-9]+]] { +// NO-SANITIZE-WITHOUT-ATTR-SAME: ptr noundef readonly captures(none) [[ANN:%.*]], i32 noundef [[IDX1:%.*]], i32 noundef [[IDX2:%.*]]) local_unnamed_addr #[[ATTR8:[0-9]+]] { // NO-SANITIZE-WITHOUT-ATTR-NEXT: entry: // NO-SANITIZE-WITHOUT-ATTR-NEXT: [[IDXPROM:%.*]] = sext i32 [[IDX1]] to i64 // NO-SANITIZE-WITHOUT-ATTR-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [10 x ptr], ptr [[ANN]], i64 0, i64 [[IDXPROM]] diff --git clang/test/CodeGen/builtins-elementwise-math.c clang/test/CodeGen/builtins-elementwise-math.c index 7f6b5f26eb93..5661bbc6008a 100644 --- clang/test/CodeGen/builtins-elementwise-math.c +++ clang/test/CodeGen/builtins-elementwise-math.c @@ -14,10 +14,18 @@ __attribute__((address_space(1))) int int_as_one; typedef int bar; bar b; +struct StructWithBitfield { + int i : 5; + short s : 3; + char c: 2; + long long int lli : 3; +}; + void test_builtin_elementwise_abs(float f1, float f2, double d1, double d2, float4 vf1, float4 vf2, si8 vi1, si8 vi2, long long int i1, long long int i2, short si, - _BitInt(31) bi1, _BitInt(31) bi2) { + _BitInt(31) bi1, _BitInt(31) bi2, int i, + char ci) { // CHECK-LABEL: define void @test_builtin_elementwise_abs( // CHECK: [[F1:%.+]] = load float, ptr %f1.addr, align 4 // CHECK-NEXT: call float @llvm.fabs.f32(float [[F1]]) @@ -35,6 +43,11 @@ void test_builtin_elementwise_abs(float f1, float f2, double d1, double d2, // CHECK-NEXT: call i64 @llvm.abs.i64(i64 [[I1]], i1 false) i2 = __builtin_elementwise_abs(i1); + // CHECK: [[I1:%.+]] = load i64, ptr %i1.addr, align 8 + // CHECK: [[S1:%.+]] = trunc i64 [[I1]] to i16 + // CHECK-NEXT: call i16 @llvm.abs.i16(i16 [[S1]], i1 false) + i1 = __builtin_elementwise_abs((short)i1); + // CHECK: [[VI1:%.+]] = load <8 x i16>, ptr %vi1.addr, align 16 // CHECK-NEXT: call <8 x i16> @llvm.abs.v8i16(<8 x i16> [[VI1]], i1 false) vi2 = __builtin_elementwise_abs(vi1); @@ -57,10 +70,37 @@ void test_builtin_elementwise_abs(float f1, float f2, double d1, double d2, b = __builtin_elementwise_abs(-10); // CHECK: [[SI:%.+]] = load i16, ptr %si.addr, align 2 - // CHECK-NEXT: [[SI_EXT:%.+]] = sext i16 [[SI]] to i32 - // CHECK-NEXT: [[RES:%.+]] = call i32 @llvm.abs.i32(i32 [[SI_EXT]], i1 false) - // CHECK-NEXT: = trunc i32 [[RES]] to i16 + // CHECK-NEXT: [[RES:%.+]] = call i16 @llvm.abs.i16(i16 [[SI]], i1 false) si = __builtin_elementwise_abs(si); + + struct StructWithBitfield t; + + // CHECK: [[BFLOAD:%.+]] = load i16, ptr %t, align 8 + // CHECK-NEXT: [[BFSHL:%.+]] = shl i16 [[BFLOAD]], 11 + // CHECK-NEXT: [[BFASHR:%.+]] = ashr i16 [[BFSHL]], 11 + // CHECK-NEXT: [[BFCAST:%.+]] = sext i16 [[BFASHR]] to i32 + // CHECK-NEXT: [[RES:%.+]] = call i32 @llvm.abs.i32(i32 [[BFCAST]], i1 false) + i = __builtin_elementwise_abs(t.i); + + // CHECK: [[BFLOAD:%.+]] = load i16, ptr %t, align 8 + // CHECK-NEXT: [[BFSHL:%.+]] = shl i16 [[BFLOAD]], 8 + // CHECK-NEXT: [[BFASHR:%.+]] = ashr i16 [[BFSHL]], 13 + // CHECK-NEXT: [[RES:%.+]] = call i16 @llvm.abs.i16(i16 [[BFASHR]], i1 false) + si = __builtin_elementwise_abs(t.s); + + // CHECK: [[BFLOAD:%.+]] = load i16, ptr %t, align 8 + // CHECK-NEXT: [[BFSHL:%.+]] = shl i16 [[BFLOAD]], 6 + // CHECK-NEXT: [[BFASHR:%.+]] = ashr i16 [[BFSHL]], 14 + // CHECK-NEXT: [[BFCAST:%.+]] = trunc i16 [[BFASHR]] to i8 + // CHECK-NEXT: [[RES:%.+]] = call i8 @llvm.abs.i8(i8 [[BFCAST]], i1 false) + ci = __builtin_elementwise_abs(t.c); + + // CHECK: [[BFLOAD:%.+]] = load i16, ptr %t, align 8 + // CHECK-NEXT: [[BFSHL:%.+]] = shl i16 [[BFLOAD]], 3 + // CHECK-NEXT: [[BFASHR:%.+]] = ashr i16 [[BFSHL]], 13 + // CHECK-NEXT: [[BFCAST:%.+]] = sext i16 [[BFASHR]] to i64 + // CHECK-NEXT: [[RES:%.+]] = call i64 @llvm.abs.i64(i64 [[BFCAST]], i1 false) + i1 = __builtin_elementwise_abs(t.lli); } void test_builtin_elementwise_add_sat(float f1, float f2, double d1, double d2, @@ -68,7 +108,10 @@ void test_builtin_elementwise_add_sat(float f1, float f2, double d1, double d2, long long int i2, si8 vi1, si8 vi2, unsigned u1, unsigned u2, u4 vu1, u4 vu2, _BitInt(31) bi1, _BitInt(31) bi2, - unsigned _BitInt(55) bu1, unsigned _BitInt(55) bu2) { + unsigned _BitInt(55) bu1, unsigned _BitInt(55) bu2, + char c1, char c2, unsigned char uc1, + unsigned char uc2, short s1, short s2, + unsigned short us1, unsigned short us2) { // CHECK: [[I1:%.+]] = load i64, ptr %i1.addr, align 8 // CHECK-NEXT: [[I2:%.+]] = load i64, ptr %i2.addr, align 8 // CHECK-NEXT: call i64 @llvm.sadd.sat.i64(i64 [[I1]], i64 [[I2]]) @@ -76,7 +119,7 @@ void test_builtin_elementwise_add_sat(float f1, float f2, double d1, double d2, // CHECK: [[I1:%.+]] = load i64, ptr %i1.addr, align 8 // CHECK-NEXT: call i64 @llvm.sadd.sat.i64(i64 [[I1]], i64 10) - i1 = __builtin_elementwise_add_sat(i1, 10); + i1 = __builtin_elementwise_add_sat(i1, 10ll); // CHECK: [[VI1:%.+]] = load <8 x i16>, ptr %vi1.addr, align 16 // CHECK-NEXT: [[VI2:%.+]] = load <8 x i16>, ptr %vi2.addr, align 16 @@ -114,6 +157,33 @@ void test_builtin_elementwise_add_sat(float f1, float f2, double d1, double d2, // CHECK: store i64 98, ptr %i1.addr, align 8 i1 = __builtin_elementwise_add_sat(1, 'a'); + + // CHECK: [[C1:%.+]] = load i8, ptr %c1.addr, align 1 + // CHECK-NEXT: [[C2:%.+]] = load i8, ptr %c2.addr, align 1 + // CHECK-NEXT: call i8 @llvm.sadd.sat.i8(i8 [[C1]], i8 [[C2]]) + c1 = __builtin_elementwise_add_sat(c1, c2); + + // CHECK: [[UC1:%.+]] = load i8, ptr %uc1.addr, align 1 + // CHECK-NEXT: [[UC2:%.+]] = load i8, ptr %uc2.addr, align 1 + // CHECK-NEXT: call i8 @llvm.uadd.sat.i8(i8 [[UC1]], i8 [[UC2]]) + uc1 = __builtin_elementwise_add_sat(uc1, uc2); + + // CHECK: [[S1:%.+]] = load i16, ptr %s1.addr, align 2 + // CHECK-NEXT: [[S2:%.+]] = load i16, ptr %s2.addr, align 2 + // CHECK-NEXT: call i16 @llvm.sadd.sat.i16(i16 [[S1]], i16 [[S2]]) + s1 = __builtin_elementwise_add_sat(s1, s2); + + // CHECK: [[S1:%.+]] = load i16, ptr %s1.addr, align 2 + // CHECK: [[I1:%.+]] = sext i16 [[S1]] to i32 + // CHECK-NEXT: [[S2:%.+]] = load i16, ptr %s2.addr, align 2 + // CHECK: [[I2:%.+]] = sext i16 [[S2]] to i32 + // CHECK-NEXT: call i32 @llvm.sadd.sat.i32(i32 [[I1]], i32 [[I2]]) + s1 = __builtin_elementwise_add_sat((int)s1, (int)s2); + + // CHECK: [[US1:%.+]] = load i16, ptr %us1.addr, align 2 + // CHECK-NEXT: [[US2:%.+]] = load i16, ptr %us2.addr, align 2 + // CHECK-NEXT: call i16 @llvm.uadd.sat.i16(i16 [[US1]], i16 [[US2]]) + us1 = __builtin_elementwise_add_sat(us1, us2); } void test_builtin_elementwise_sub_sat(float f1, float f2, double d1, double d2, @@ -121,7 +191,10 @@ void test_builtin_elementwise_sub_sat(float f1, float f2, double d1, double d2, long long int i2, si8 vi1, si8 vi2, unsigned u1, unsigned u2, u4 vu1, u4 vu2, _BitInt(31) bi1, _BitInt(31) bi2, - unsigned _BitInt(55) bu1, unsigned _BitInt(55) bu2) { + unsigned _BitInt(55) bu1, unsigned _BitInt(55) bu2, + char c1, char c2, unsigned char uc1, + unsigned char uc2, short s1, short s2, + unsigned short us1, unsigned short us2) { // CHECK: [[I1:%.+]] = load i64, ptr %i1.addr, align 8 // CHECK-NEXT: [[I2:%.+]] = load i64, ptr %i2.addr, align 8 // CHECK-NEXT: call i64 @llvm.ssub.sat.i64(i64 [[I1]], i64 [[I2]]) @@ -129,7 +202,7 @@ void test_builtin_elementwise_sub_sat(float f1, float f2, double d1, double d2, // CHECK: [[I1:%.+]] = load i64, ptr %i1.addr, align 8 // CHECK-NEXT: call i64 @llvm.ssub.sat.i64(i64 [[I1]], i64 10) - i1 = __builtin_elementwise_sub_sat(i1, 10); + i1 = __builtin_elementwise_sub_sat(i1, 10ll); // CHECK: [[VI1:%.+]] = load <8 x i16>, ptr %vi1.addr, align 16 // CHECK-NEXT: [[VI2:%.+]] = load <8 x i16>, ptr %vi2.addr, align 16 @@ -167,6 +240,26 @@ void test_builtin_elementwise_sub_sat(float f1, float f2, double d1, double d2, // CHECK: store i64 -96, ptr %i1.addr, align 8 i1 = __builtin_elementwise_sub_sat(1, 'a'); + + // CHECK: [[C1:%.+]] = load i8, ptr %c1.addr, align 1 + // CHECK-NEXT: [[C2:%.+]] = load i8, ptr %c2.addr, align 1 + // CHECK-NEXT: call i8 @llvm.ssub.sat.i8(i8 [[C1]], i8 [[C2]]) + c1 = __builtin_elementwise_sub_sat(c1, c2); + + // CHECK: [[UC1:%.+]] = load i8, ptr %uc1.addr, align 1 + // CHECK-NEXT: [[UC2:%.+]] = load i8, ptr %uc2.addr, align 1 + // CHECK-NEXT: call i8 @llvm.usub.sat.i8(i8 [[UC1]], i8 [[UC2]]) + uc1 = __builtin_elementwise_sub_sat(uc1, uc2); + + // CHECK: [[S1:%.+]] = load i16, ptr %s1.addr, align 2 + // CHECK-NEXT: [[S2:%.+]] = load i16, ptr %s2.addr, align 2 + // CHECK-NEXT: call i16 @llvm.ssub.sat.i16(i16 [[S1]], i16 [[S2]]) + s1 = __builtin_elementwise_sub_sat(s1, s2); + + // CHECK: [[US1:%.+]] = load i16, ptr %us1.addr, align 2 + // CHECK-NEXT: [[US2:%.+]] = load i16, ptr %us2.addr, align 2 + // CHECK-NEXT: call i16 @llvm.usub.sat.i16(i16 [[US1]], i16 [[US2]]) + us1 = __builtin_elementwise_sub_sat(us1, us2); } void test_builtin_elementwise_maximum(float f1, float f2, double d1, double d2, @@ -278,7 +371,7 @@ void test_builtin_elementwise_max(float f1, float f2, double d1, double d2, // CHECK: [[I1:%.+]] = load i64, ptr %i1.addr, align 8 // CHECK-NEXT: call i64 @llvm.smax.i64(i64 [[I1]], i64 10) - i1 = __builtin_elementwise_max(i1, 10); + i1 = __builtin_elementwise_max(i1, 10ll); // CHECK: [[VI1:%.+]] = load <8 x i16>, ptr %vi1.addr, align 16 // CHECK-NEXT: [[VI2:%.+]] = load <8 x i16>, ptr %vi2.addr, align 16 @@ -362,7 +455,14 @@ void test_builtin_elementwise_min(float f1, float f2, double d1, double d2, // CHECK: [[I2:%.+]] = load i64, ptr %i2.addr, align 8 // CHECK-NEXT: call i64 @llvm.smin.i64(i64 -11, i64 [[I2]]) - i1 = __builtin_elementwise_min(-11, i2); + i1 = __builtin_elementwise_min(-11ll, i2); + + // CHECK: [[I1:%.+]] = load i64, ptr %i1.addr, align 8 + // CHECK: [[S1:%.+]] = trunc i64 [[I1]] to i16 + // CHECK-NEXT: [[I2:%.+]] = load i64, ptr %i2.addr, align 8 + // CHECK: [[S2:%.+]] = trunc i64 [[I2]] to i16 + // CHECK-NEXT: call i16 @llvm.smin.i16(i16 [[S1]], i16 [[S2]]) + i1 = __builtin_elementwise_min((short)i1, (short)i2); // CHECK: [[VI1:%.+]] = load <8 x i16>, ptr %vi1.addr, align 16 // CHECK-NEXT: [[VI2:%.+]] = load <8 x i16>, ptr %vi2.addr, align 16 @@ -374,12 +474,6 @@ void test_builtin_elementwise_min(float f1, float f2, double d1, double d2, // CHECK-NEXT: call i32 @llvm.umin.i32(i32 [[U1]], i32 [[U2]]) u1 = __builtin_elementwise_min(u1, u2); - // CHECK: [[U1:%.+]] = load i32, ptr %u1.addr, align 4 - // CHECK-NEXT: [[ZEXT_U1:%.+]] = zext i32 [[U1]] to i64 - // CHECK-NEXT: [[I2:%.+]] = load i64, ptr %i2.addr, align 8 - // CHECK-NEXT: call i64 @llvm.smin.i64(i64 [[ZEXT_U1]], i64 [[I2]]) - u1 = __builtin_elementwise_min(u1, i2); - // CHECK: [[VU1:%.+]] = load <4 x i32>, ptr %vu1.addr, align 16 // CHECK-NEXT: [[VU2:%.+]] = load <4 x i32>, ptr %vu2.addr, align 16 // CHECK-NEXT: call <4 x i32> @llvm.umin.v4i32(<4 x i32> [[VU1]], <4 x i32> [[VU2]]) @@ -418,7 +512,8 @@ void test_builtin_elementwise_min(float f1, float f2, double d1, double d2, void test_builtin_elementwise_bitreverse(si8 vi1, si8 vi2, long long int i1, long long int i2, short si, - _BitInt(31) bi1, _BitInt(31) bi2) { + _BitInt(31) bi1, _BitInt(31) bi2, + char ci) { // CHECK: [[I1:%.+]] = load i64, ptr %i1.addr, align 8 @@ -447,10 +542,24 @@ void test_builtin_elementwise_bitreverse(si8 vi1, si8 vi2, b = __builtin_elementwise_bitreverse(-10); // CHECK: [[SI:%.+]] = load i16, ptr %si.addr, align 2 - // CHECK-NEXT: [[SI_EXT:%.+]] = sext i16 [[SI]] to i32 - // CHECK-NEXT: [[RES:%.+]] = call i32 @llvm.bitreverse.i32(i32 [[SI_EXT]]) - // CHECK-NEXT: = trunc i32 [[RES]] to i16 + // CHECK-NEXT: [[RES:%.+]] = call i16 @llvm.bitreverse.i16(i16 [[SI]]) si = __builtin_elementwise_bitreverse(si); + + // CHECK: store i16 28671, ptr %si.addr, align 2 + si = __builtin_elementwise_bitreverse((short)-10); + + // CHECK: store i16 28671, ptr %si.addr, align 2 + si = __builtin_elementwise_bitreverse((unsigned short)-10); + + // CHECK: [[CI:%.+]] = load i8, ptr %ci.addr, align 1 + // CHECK-NEXT: [[RES:%.+]] = call i8 @llvm.bitreverse.i8(i8 [[CI]]) + ci = __builtin_elementwise_bitreverse(ci); + + // CHECK: store i8 111, ptr %ci.addr, align 1 + ci = __builtin_elementwise_bitreverse((unsigned char)-10); + + // CHECK: store i8 111, ptr %ci.addr, align 1 + ci = __builtin_elementwise_bitreverse((char)-10); } void test_builtin_elementwise_ceil(float f1, float f2, double d1, double d2, @@ -668,7 +777,8 @@ void test_builtin_elementwise_log2(float f1, float f2, double d1, double d2, void test_builtin_elementwise_popcount(si8 vi1, si8 vi2, long long int i1, long long int i2, short si, - _BitInt(31) bi1, _BitInt(31) bi2) { + _BitInt(31) bi1, _BitInt(31) bi2, + char ci) { // CHECK: [[I1:%.+]] = load i64, ptr %i1.addr, align 8 // CHECK-NEXT: call i64 @llvm.ctpop.i64(i64 [[I1]]) i2 = __builtin_elementwise_popcount(i1); @@ -695,10 +805,24 @@ void test_builtin_elementwise_popcount(si8 vi1, si8 vi2, long long int i1, b = __builtin_elementwise_popcount(-10); // CHECK: [[SI:%.+]] = load i16, ptr %si.addr, align 2 - // CHECK-NEXT: [[SI_EXT:%.+]] = sext i16 [[SI]] to i32 - // CHECK-NEXT: [[RES:%.+]] = call i32 @llvm.ctpop.i32(i32 [[SI_EXT]]) - // CHECK-NEXT: = trunc i32 [[RES]] to i16 + // CHECK-NEXT: [[RES:%.+]] = call i16 @llvm.ctpop.i16(i16 [[SI]]) si = __builtin_elementwise_popcount(si); + + // CHECK: store i16 3, ptr %si.addr, align 2 + si = __builtin_elementwise_popcount((unsigned short)32771); + + // CHECK: store i16 3, ptr %si.addr, align 2 + si = __builtin_elementwise_popcount((short)32771); + + // CHECK: [[CI:%.+]] = load i8, ptr %ci.addr, align 1 + // CHECK-NEXT: [[RES:%.+]] = call i8 @llvm.ctpop.i8(i8 [[CI]]) + ci = __builtin_elementwise_popcount(ci); + + // CHECK: store i8 2, ptr %ci.addr, align 1 + ci = __builtin_elementwise_popcount((unsigned char)192); + + // CHECK: store i8 2, ptr %ci.addr, align 1 + ci = __builtin_elementwise_popcount((char)192); } void test_builtin_elementwise_fmod(float f1, float f2, double d1, double d2, diff --git clang/test/CodeGen/builtins-nvptx.c clang/test/CodeGen/builtins-nvptx.c index 163aee4799ff..ffa41c85c273 100644 --- clang/test/CodeGen/builtins-nvptx.c +++ clang/test/CodeGen/builtins-nvptx.c @@ -28,6 +28,11 @@ // RUN: %clang_cc1 -ffp-contract=off -triple nvptx64-unknown-unknown -target-cpu sm_89 -target-feature +ptx81 \ // RUN: -fcuda-is-device -emit-llvm -o - -x cuda %s \ // RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK_PTX81_SM89 %s +// ### The last run to check with the highest SM and PTX version available +// ### to make sure target builtins are still accepted. +// RUN: %clang_cc1 -ffp-contract=off -triple nvptx64-unknown-unknown -target-cpu sm_100a -target-feature +ptx87 \ +// RUN: -fcuda-is-device -emit-llvm -o - -x cuda %s \ +// RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK_PTX81_SM89 %s #define __device__ __attribute__((device)) #define __global__ __attribute__((global)) @@ -202,7 +207,7 @@ __device__ void exit() { // NVVM intrinsics // The idea is not to test all intrinsics, just that Clang is recognizing the -// builtins defined in BuiltinsNVPTX.def +// builtins defined in BuiltinsNVPTX.td __device__ void nvvm_math(float f1, float f2, double d1, double d2) { // CHECK: call float @llvm.nvvm.fmax.f float t1 = __nvvm_fmax_f(f1, f2); diff --git clang/test/CodeGen/extend-variable-liveness-except.cpp clang/test/CodeGen/extend-variable-liveness-except.cpp new file mode 100644 index 000000000000..c3a29f57bdae --- /dev/null +++ clang/test/CodeGen/extend-variable-liveness-except.cpp @@ -0,0 +1,34 @@ +// RUN: %clang_cc1 %s -triple %itanium_abi_triple -emit-llvm -fextend-variable-liveness -fcxx-exceptions -fexceptions -o - | FileCheck %s +// This test checks that the fake uses can be generated in exception handling +// blocks and that we can emit fake uses for the __int128 data type. + +extern int bar(); + +/// Try block: fake use ends at try-block scope. +// [[BAR_VAL::%[a-zA-Z0-9\.]+]] = invoke{{.*}} i32 @_Z3barv() +// store i32 %[[BAR_VAL]], ptr [[K_ALLOC_VAL:%[a-zA-Z0-9\.]+]], align 4 +// [[K_FAKE_USE:%[a-zA-Z0-9\.]+]] = load i32, ptr [[K_ALLOC_VAL]], align 4 +// call void (...) @llvm.fake.use(i32 [[K_FAKE_USE]]) #2 +// br label + +/// Catch block: fetching the caught value... +// CHECK: [[CATCH_PTR:%[a-zA-Z0-9\.]+]] = call ptr @__cxa_begin_catch( +// CHECK: [[L_VAL:%[a-zA-Z0-9\.]+]] = load i32, ptr [[CATCH_PTR]], align 4 + +/// Storing to allocas... +// CHECK-DAG: store i32 8, ptr [[M_ALLOC_VAL:%[a-zA-Z0-9\.]+]] +// CHECK-DAG: store i32 [[L_VAL]], ptr [[L_ALLOC_VAL:%[a-zA-Z0-9\.]+]], align 4 + +/// Load into fake uses - expect M to precede L. +// CHECK: [[M_FAKE_VAL:%[a-zA-Z0-9\.]+]] = load i32, ptr [[M_ALLOC_VAL]] +// CHECK: call void (...) @llvm.fake.use(i32 [[M_FAKE_VAL]]) +// CHECK: [[L_FAKE_VAL:%[a-zA-Z0-9\.]+]] = load i32, ptr [[L_ALLOC_VAL]] +// CHECK: call void (...) @llvm.fake.use(i32 [[L_FAKE_VAL]]) +void foo() { + try { + int k = bar(); + } catch (int l) { + /// The catch block contains a fake use for the local within its scope. + int m = 8; + } +} diff --git clang/test/CodeGen/extend-variable-liveness-wide-scalar.cpp clang/test/CodeGen/extend-variable-liveness-wide-scalar.cpp new file mode 100644 index 000000000000..42b893cc3cdf --- /dev/null +++ clang/test/CodeGen/extend-variable-liveness-wide-scalar.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 %s -emit-llvm -fextend-variable-liveness -triple x86_64-unknown-linux -o - | FileCheck %s +// REQUIRES: x86-registered-target +// This test checks that the fake uses can be generated in exception handling +// blocks and that we can emit fake uses for the __int128 data type. + +void bar(); + +// CHECK: call void (...) @llvm.fake.use(i128 % +void foo(__int128 wide_int) { + bar(); +} diff --git clang/test/CodeGen/extend-variable-liveness.c clang/test/CodeGen/extend-variable-liveness.c new file mode 100644 index 000000000000..c6bca48e6469 --- /dev/null +++ clang/test/CodeGen/extend-variable-liveness.c @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -fextend-variable-liveness -o - | FileCheck %s --implicit-check-not=llvm.fake.use +// Check that fake use calls are emitted at the correct locations, i.e. +// at the end of lexical blocks and at the end of the function. + +int glob_i; +char glob_c; +float glob_f; + +int foo(int i) { + // CHECK-LABEL: define{{.*}}foo + if (i < 4) { + char j = i * 3; + if (glob_i > 3) { + float f = glob_f; + j = f; + glob_c = j; + // CHECK: call void (...) @llvm.fake.use(float % + // CHECK-NEXT: br label % + } + glob_i = j; + // CHECK: call void (...) @llvm.fake.use(i8 % + // CHECK-NEXT: br label % + } + // CHECK: call void (...) @llvm.fake.use(i32 % + // CHECK-NEXT: ret + return 4; +} + +// CHECK: declare void @llvm.fake.use(...) diff --git clang/test/CodeGen/fake-use-determinism.c clang/test/CodeGen/fake-use-determinism.c new file mode 100644 index 000000000000..039d8de69243 --- /dev/null +++ clang/test/CodeGen/fake-use-determinism.c @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fextend-variable-liveness %s -o - | FileCheck %s +// +// We are checking that the fake.use calls for i, j and k appear +// in a particular order. It is not the order itself that is important +// but that it remains the same between different test runs. + +// CHECK: [[K_FAKE_USE:%[a-zA-Z0-9\.]+]] = load i32, ptr %k.addr +// CHECK-NEXT: call void (...) @llvm.fake.use(i32 [[K_FAKE_USE]]) #2 +// CHECK-NEXT: [[J_FAKE_USE:%[a-zA-Z0-9\.]+]] = load i32, ptr %j.addr +// CHECK-NEXT: call void (...) @llvm.fake.use(i32 [[J_FAKE_USE]]) #2 +// CHECK-NEXT: [[I_FAKE_USE:%[a-zA-Z0-9\.]+]] = load i32, ptr %i.addr +// CHECK-NEXT: call void (...) @llvm.fake.use(i32 [[I_FAKE_USE]]) #2 + +void bar(); +void foo(int i, int j, int k) +{ + for (int l = 0; l < i; l++) { + bar(); + } +} diff --git clang/test/CodeGen/fake-use-lambda.cpp clang/test/CodeGen/fake-use-lambda.cpp new file mode 100644 index 000000000000..aaf25caab6a3 --- /dev/null +++ clang/test/CodeGen/fake-use-lambda.cpp @@ -0,0 +1,43 @@ +// RUN: %clang_cc1 %s -triple=%itanium_abi_triple -O1 -emit-llvm -fextend-variable-liveness -o - | FileCheck %s +// Make sure we don't crash compiling a lambda that is not nested in a function. +// We also check that fake uses are properly issued in lambdas. + +int glob; + +extern int foo(); + +struct S { + static const int a; +}; + +const int S::a = [](int b) __attribute__((noinline)) { + return b * foo(); +} +(glob); + +int func(int param) { + return ([=](int lambdaparm) __attribute__((noinline))->int { + int lambdalocal = lambdaparm * 2; + return lambdalocal; + }(glob)); +} + +// We are looking for the first lambda's call operator, which should contain +// 2 fake uses, one for 'b' and one for its 'this' pointer (in that order). +// The mangled function name contains a $_0, followed by 'cl'. +// This lambda is an orphaned lambda, i.e. one without lexical parent. +// +// CHECK-LABEL: define internal {{.+\"_Z.+\$_0.*cl.*\"}} +// CHECK-NOT: ret +// CHECK: fake.use(i32 +// CHECK-NOT: ret +// CHECK: fake.use(ptr + +// The second lambda. We are looking for 3 fake uses. +// CHECK-LABEL: define internal {{.+\"_Z.+\$_0.*cl.*\"}} +// CHECK-NOT: ret +// CHECK: fake.use(i32 +// CHECK-NOT: ret +// CHECK: fake.use(i32 +// CHECK-NOT: ret +// CHECK: fake.use(ptr diff --git clang/test/CodeGen/fake-use-landingpad.c clang/test/CodeGen/fake-use-landingpad.c new file mode 100644 index 000000000000..ffaf3975ef33 --- /dev/null +++ clang/test/CodeGen/fake-use-landingpad.c @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 %s -emit-llvm -fextend-variable-liveness -fexceptions -o - | FileCheck %s --implicit-check-not="landingpad {" + +// Check that fake uses do not mistakenly cause a landing pad to be generated when +// exceptions are enabled. + +extern void bar(int); +void foo(int p) { + int a = 17; + bar(a); +} + +// CHECK: define {{.*}} @foo +// CHECK-NOT: personality +// CHECK: call void (...) @llvm.fake.use diff --git clang/test/CodeGen/fake-use-noreturn.cpp clang/test/CodeGen/fake-use-noreturn.cpp new file mode 100644 index 000000000000..db7f27735b1d --- /dev/null +++ clang/test/CodeGen/fake-use-noreturn.cpp @@ -0,0 +1,28 @@ +// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -fextend-variable-liveness -o - | FileCheck %s +// +// Check we can correctly produce fake uses for function-level variables even +// when we have a return in a nested conditional and there is no code at the end +// of the function. + +// CHECK-LABEL: define{{.*}}@_Z3fooi +// CHECK: [[I_FAKE_USE:%[a-zA-Z0-9\.]+]] = load i32, ptr %i.addr +// CHECK: call void (...) @llvm.fake.use(i32 [[I_FAKE_USE]]) +// CHECK-LABEL: define{{.*}}@_ZN1C3barEi +// CHECK: [[J_FAKE_USE:%[a-zA-Z0-9\.]+]] = load i32, ptr %j.addr +// CHECK: call void (...) @llvm.fake.use(i32 [[J_FAKE_USE]]) + +void foo(int i) { + while (0) + if (1) + return; +} + +class C { + void bar(int j); +}; + +void C::bar(int j) { + while (0) + if (1) + return; +} diff --git clang/test/CodeGen/fake-use-return-line.c clang/test/CodeGen/fake-use-return-line.c new file mode 100644 index 000000000000..50d5885c2834 --- /dev/null +++ clang/test/CodeGen/fake-use-return-line.c @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -fextend-variable-liveness -o - %s | FileCheck %s + +// Clang adjusts the line numbers of returns based on the line numbers of +// dominating stores to %retval; we test that fake use intrinsics do not affect +// this, and the return is given the correct line. + +// CHECK: define{{.*}}@main +// CHECK: call void (...) @llvm.fake.use(i32 +// CHECK-NEXT: ret i32{{.*}}!dbg ![[MDINDEX:[0-9]*]] +// CHECK: ![[MDINDEX]] = !DILocation(line: [[# @LINE + 5]] +int main() +{ + volatile int a = 1; + int b = a + 2; + return b; +} diff --git clang/test/CodeGen/fake-use-sanitizer.cpp clang/test/CodeGen/fake-use-sanitizer.cpp new file mode 100644 index 000000000000..e808c645b9c6 --- /dev/null +++ clang/test/CodeGen/fake-use-sanitizer.cpp @@ -0,0 +1,61 @@ +// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -fextend-variable-liveness -fsanitize=null -fsanitize-trap=null -o - | FileCheck --check-prefixes=CHECK,NULL --implicit-check-not=ubsantrap %s +// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -fextend-variable-liveness -o - | FileCheck %s + +// With -fextend-variable-liveness, the compiler previously generated a fake.use of any +// reference variable at the end of the scope in which its alloca exists. This +// caused two issues, where we would get fake uses for uninitialized variables +// if that variable was declared after an early-return, and UBSan's null checks +// would complain about this. +// This test verifies that UBSan does not produce null-checks for arguments to +// llvm.fake.use, and that fake uses are not emitted for a variable on paths +// it has not been declared. + +struct A { short s1, s2; }; +extern long& getA(); + +void foo() +{ + auto& va = getA(); + if (va < 5) + return; + + auto& vb = getA(); +} + +// CHECK-LABEL: define{{.*}}foo +// CHECK: [[VA_CALL:%.+]] = call{{.*}} ptr @_Z4getAv() + +/// We check here for the first UBSan check for "va". +// NULL: [[VA_ISNULL:%.+]] = icmp ne ptr [[VA_CALL]], null +// NULL: br i1 [[VA_ISNULL]], label %{{[^,]+}}, label %[[VA_TRAP:[^,]+]] +// NULL: [[VA_TRAP]]: +// NULL: call void @llvm.ubsantrap( + +// CHECK: [[VA_PTR:%.+]] = load ptr, ptr %va +// CHECK-NEXT: [[VA_CMP:%.+]] = load i64, ptr [[VA_PTR]] +// CHECK-NEXT: [[VA_CMP_RES:%.+]] = icmp slt i64 [[VA_CMP]], 5 +// CHECK-NEXT: br i1 [[VA_CMP_RES]], label %[[EARLY_EXIT:[^,]+]], label %[[NOT_EARLY_EXIT:[^,]+]] + +// CHECK: [[EARLY_EXIT]]: +// CHECK: br label %cleanup + +/// The fake use for "vb" only appears on the path where its declaration is +/// reached. +// CHECK: [[NOT_EARLY_EXIT]]: +// CHECK: [[VB_CALL:%.+]] = call{{.*}} ptr @_Z4getAv() + +/// We check here for the second UBSan check for "vb". +// NULL: [[VB_ISNULL:%.+]] = icmp ne ptr [[VB_CALL]], null +// NULL: br i1 [[VB_ISNULL]], label %{{[^,]+}}, label %[[VB_TRAP:[^,]+]] +// NULL: [[VB_TRAP]]: +// NULL: call void @llvm.ubsantrap( + +// CHECK: [[VB_FAKE_USE:%.+]] = load ptr, ptr %vb +// CHECK-NEXT: call void (...) @llvm.fake.use(ptr [[VB_FAKE_USE]]) +// CHECK: br label %cleanup + +// CHECK: cleanup: +// CHECK: [[VA_FAKE_USE:%.+]] = load ptr, ptr %va +// CHECK-NEXT: call void (...) @llvm.fake.use(ptr [[VA_FAKE_USE]]) + +// NULL: declare void @llvm.ubsantrap diff --git clang/test/CodeGen/fake-use-scalar.c clang/test/CodeGen/fake-use-scalar.c new file mode 100644 index 000000000000..8514d5795892 --- /dev/null +++ clang/test/CodeGen/fake-use-scalar.c @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 %s -emit-llvm -fextend-variable-liveness -o - | FileCheck %s --implicit-check-not=fake.use +// Make sure we don't generate fake.use for non-scalar variables, unless they +// are small enough that they may be represented as a scalar in LLVM IR. +// Make sure we don't generate fake.use for volatile variables +// and parameters even when they are scalar. + +struct BigAggr { + unsigned long t; + char c[1024]; + unsigned char r[32]; +}; + +struct SmallAggr { + int i; + int j; +}; + +int foo(volatile int vol_param, int param) +{ + struct BigAggr big; + struct SmallAggr small; + volatile int vol_local; + int local; + unsigned long_arr[5]; + unsigned short_arr[4]; + return 0; +} + +// CHECK: [[SMALL_ARR_FAKE_USE:%.+]] = load [4 x i[[#UINT_SIZE:]]], ptr %short_arr +// CHECK: call void (...) @llvm.fake.use([4 x i[[#UINT_SIZE]]] [[SMALL_ARR_FAKE_USE]]) + +// CHECK: [[LOCAL_FAKE_USE:%.+]] = load i32, ptr %local +// CHECK: call void (...) @llvm.fake.use(i32 [[LOCAL_FAKE_USE]]) + +// CHECK: [[SMALL_FAKE_USE:%.+]] = load %struct.SmallAggr, ptr %small +// CHECK: call void (...) @llvm.fake.use(%struct.SmallAggr [[SMALL_FAKE_USE]]) + +// CHECK: [[PARAM_FAKE_USE:%.+]] = load i32, ptr %param.addr +// CHECK: call void (...) @llvm.fake.use(i32 [[PARAM_FAKE_USE]]) + +// CHECK: declare void @llvm.fake.use diff --git clang/test/CodeGen/fake-use-this.cpp clang/test/CodeGen/fake-use-this.cpp new file mode 100644 index 000000000000..a0ed93d222d5 --- /dev/null +++ clang/test/CodeGen/fake-use-this.cpp @@ -0,0 +1,34 @@ +// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -fextend-variable-liveness=this -o - | FileCheck %s --implicit-check-not=fake.use +// Check that we generate a fake_use call with the 'this' pointer as argument, +// and no other fake uses. +// The call should appear after the call to bar(). + +void bar(); + +class C +{ +public: + bool test(int p); + C(int v): v(v) {} + +private: + int v; +}; + +bool C::test(int p) +{ +// CHECK-LABEL: define{{.*}}_ZN1C4testEi(ptr{{[^,]*}} %this, i32{{.*}} %p) +// CHECK: %this.addr = alloca ptr +// CHECK: store ptr %this, ptr %this.addr + int res = p - v; + + bar(); +// CHECK: call{{.*}}bar + + return res != 0; +// CHECK: [[FAKE_USE:%.+]] = load ptr, ptr %this.addr +// CHECK-NEXT: call void (...) @llvm.fake.use(ptr{{.*}} [[FAKE_USE]]) +// CHECK-NEXT: ret +} + +// CHECK: declare void @llvm.fake.use diff --git clang/test/CodeGen/fake-use-while.c clang/test/CodeGen/fake-use-while.c new file mode 100644 index 000000000000..a74887d97952 --- /dev/null +++ clang/test/CodeGen/fake-use-while.c @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 %s -emit-llvm -fextend-variable-liveness -o - | FileCheck %s +// +// Check we don't assert when there is no more code after a while statement +// and the body of the while statement ends in a return, i.e. no insertion point +// is available. + +// CHECK: define{{.*}}foo +// CHECK: call{{.*}}llvm.fake.use + +void foo() { + { + while (1) { + int ret; + if (1) + return; + } + } +} diff --git clang/test/CodeGen/integer-overflow.c clang/test/CodeGen/integer-overflow.c index 9e8cde8b33b1..a3a66e6137be 100644 --- clang/test/CodeGen/integer-overflow.c +++ clang/test/CodeGen/integer-overflow.c @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s --check-prefix=DEFAULT // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fwrapv | FileCheck %s --check-prefix=WRAPV // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -ftrapv | FileCheck %s --check-prefix=TRAPV -// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fsanitize=signed-integer-overflow | FileCheck %s --check-prefixes=CATCH_UB,CATCH_UB_POINTER +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fsanitize=signed-integer-overflow | FileCheck %s --check-prefixes=CATCH_UB,NOCATCH_UB_POINTER // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fsanitize=signed-integer-overflow -fwrapv | FileCheck %s --check-prefixes=CATCH_UB,NOCATCH_UB_POINTER // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -ftrapv -ftrapv-handler foo | FileCheck %s --check-prefix=TRAPV_HANDLER @@ -57,14 +57,14 @@ void test1(void) { // TRAPV_HANDLER: foo( --a; - // -fwrapv should turn off inbounds for GEP's, PR9256 + // -fwrapv does not affect inbounds for GEP's. + // This is controlled by -fwrapv-pointer instead. extern int* P; ++P; // DEFAULT: getelementptr inbounds nuw i32, ptr - // WRAPV: getelementptr i32, ptr + // WRAPV: getelementptr inbounds nuw i32, ptr // TRAPV: getelementptr inbounds nuw i32, ptr - // CATCH_UB_POINTER: getelementptr inbounds nuw i32, ptr - // NOCATCH_UB_POINTER: getelementptr i32, ptr + // NOCATCH_UB_POINTER: getelementptr inbounds nuw i32, ptr // PR9350: char pre-increment never overflows. extern volatile signed char PR9350_char_inc; diff --git clang/test/CodeGen/isfpclass.c clang/test/CodeGen/isfpclass.c index 1bf60b8fbca1..26dd846a2bf2 100644 --- clang/test/CodeGen/isfpclass.c +++ clang/test/CodeGen/isfpclass.c @@ -160,7 +160,7 @@ int4 check_isfpclass_nan_strict_v4f32(float4 x) { } // CHECK-LABEL: define dso_local void @check_isfpclass_nan_v4f64 -// CHECK-SAME: (ptr dead_on_unwind noalias nocapture writable writeonly sret(<4 x i64>) align 16 initializes((0, 32)) [[AGG_RESULT:%.*]], ptr nocapture noundef readonly [[TMP0:%.*]]) local_unnamed_addr #[[ATTR3:[0-9]+]] { +// CHECK-SAME: (ptr dead_on_unwind noalias writable writeonly sret(<4 x i64>) align 16 captures(none) initializes((0, 32)) [[AGG_RESULT:%.*]], ptr noundef readonly captures(none) [[TMP0:%.*]]) local_unnamed_addr #[[ATTR3:[0-9]+]] { // CHECK-NEXT: entry: // CHECK-NEXT: [[X:%.*]] = load <4 x double>, ptr [[TMP0]], align 16, !tbaa [[TBAA2:![0-9]+]] // CHECK-NEXT: [[TMP1:%.*]] = fcmp uno <4 x double> [[X]], zeroinitializer diff --git clang/test/CodeGen/math-libcalls-tbaa-indirect-args.c clang/test/CodeGen/math-libcalls-tbaa-indirect-args.c index 440db83fef5d..eb706154300a 100644 --- clang/test/CodeGen/math-libcalls-tbaa-indirect-args.c +++ clang/test/CodeGen/math-libcalls-tbaa-indirect-args.c @@ -53,7 +53,7 @@ long double powl(long double a, long double b); // CHECK-SPIR: [[CALL:%.*]] = tail call spir_func double @powl(double noundef [[A]], double noundef [[B]]) #[[ATTR3:[0-9]+]], !tbaa [[TBAA2:![0-9]+]] // // CHECK-MINGW32-LABEL: define dso_local void @test_powl( -// CHECK-MINGW32-SAME: ptr dead_on_unwind noalias nocapture writable writeonly sret(x86_fp80) align 16 initializes((0, 10)) [[AGG_RESULT:%.*]], ptr nocapture noundef readonly [[TMP0:%.*]], ptr nocapture noundef readonly [[TMP1:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { +// CHECK-MINGW32-SAME: ptr dead_on_unwind noalias writable writeonly sret(x86_fp80) align 16 captures(none) initializes((0, 10)) [[AGG_RESULT:%.*]], ptr noundef readonly captures(none) [[TMP0:%.*]], ptr noundef readonly captures(none) [[TMP1:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { // CHECK-MINGW32: [[A:%.*]] = load x86_fp80, ptr [[TMP0]], align 16, !tbaa [[TBAA3:![0-9]+]] // CHECK-MINGW32: [[B:%.*]] = load x86_fp80, ptr [[TMP1]], align 16, !tbaa [[TBAA3]] // CHECK-MINGW32: store x86_fp80 [[A]], ptr [[BYVAL_TEMP:%.*]], align 16, !tbaa [[TBAA3]] @@ -67,7 +67,7 @@ long double test_powl(long double a, long double b) { } // CHECK-LABEL: define dso_local { x86_fp80, x86_fp80 } @test_cargl( -// CHECK-SAME: ptr nocapture noundef readonly byval({ x86_fp80, x86_fp80 }) align 16 [[CLD:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] { +// CHECK-SAME: ptr noundef readonly byval({ x86_fp80, x86_fp80 }) align 16 captures(none) [[CLD:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] { // CHECK: [[CLD_REAL:%.*]] = load x86_fp80, ptr [[CLD]], align 16 // CHECK: [[CLD_IMAG:%.*]] = load x86_fp80, ptr [[CLD_IMAGP:%.*]], align 16 // CHECK: store x86_fp80 [[CLD_REAL]], ptr [[BYVAL_TEMP:%.*]], align 16 @@ -75,7 +75,7 @@ long double test_powl(long double a, long double b) { // CHECK: [[CALL:%.*]] = tail call x86_fp80 @cargl(ptr noundef nonnull byval({ x86_fp80, x86_fp80 }) align 16 [[BYVAL_TEMP]]) #[[ATTR5]] // // CHECK-WIN64-LABEL: define dso_local { x86_fp80, x86_fp80 } @test_cargl( -// CHECK-WIN64-SAME: ptr nocapture noundef readonly byval({ x86_fp80, x86_fp80 }) align 16 [[CLD:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] { +// CHECK-WIN64-SAME: ptr noundef readonly byval({ x86_fp80, x86_fp80 }) align 16 captures(none) [[CLD:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] { // CHECK-WIN64: [[CLD_REAL:%.*]] = load x86_fp80, ptr [[CLD]], align 16 // CHECK-WIN64: [[CLD_IMAG:%.*]] = load x86_fp80, ptr [[CLD_IMAGP:%.*]], align 16 // CHECK-WIN64: store x86_fp80 [[CLD_REAL]], ptr [[BYVAL_TEMP:%.*]], align 16 @@ -83,7 +83,7 @@ long double test_powl(long double a, long double b) { // CHECK-WIN64: [[CALL:%.*]] = tail call x86_fp80 @cargl(ptr noundef nonnull byval({ x86_fp80, x86_fp80 }) align 16 [[BYVAL_TEMP]]) #[[ATTR5]] // // CHECK-I686-LABEL: define dso_local void @test_cargl( -// CHECK-I686-SAME: ptr dead_on_unwind noalias nocapture writable writeonly sret({ x86_fp80, x86_fp80 }) align 4 initializes((0, 10), (12, 22)) [[AGG_RESULT:%.*]], ptr nocapture noundef readonly byval({ x86_fp80, x86_fp80 }) align 4 [[CLD:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] { +// CHECK-I686-SAME: ptr dead_on_unwind noalias writable writeonly sret({ x86_fp80, x86_fp80 }) align 4 captures(none) initializes((0, 10), (12, 22)) [[AGG_RESULT:%.*]], ptr noundef readonly byval({ x86_fp80, x86_fp80 }) align 4 captures(none) [[CLD:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] { // CHECK-I686: [[CLD_REAL:%.*]] = load x86_fp80, ptr [[CLD]], align 4 // CHECK-I686: [[CLD_IMAG:%.*]] = load x86_fp80, ptr [[CLD_IMAGP:%.*]], align 4 // CHECK-I686: store x86_fp80 [[CLD_REAL]], ptr [[BYVAL_TEMP:%.*]], align 4 @@ -93,7 +93,7 @@ long double test_powl(long double a, long double b) { // CHECK-I686: store x86_fp80 [[MUL_IR:%.*]], ptr [[AGG_RESULT_IMAGP:%.*]], align 4 // // CHECK-PPC-LABEL: define dso_local void @test_cargl( -// CHECK-PPC-SAME: ptr dead_on_unwind noalias nocapture writable writeonly sret({ ppc_fp128, ppc_fp128 }) align 16 initializes((0, 32)) [[AGG_RESULT:%.*]], ptr nocapture noundef readonly byval({ ppc_fp128, ppc_fp128 }) align 16 [[CLD:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] { +// CHECK-PPC-SAME: ptr dead_on_unwind noalias writable writeonly sret({ ppc_fp128, ppc_fp128 }) align 16 captures(none) initializes((0, 32)) [[AGG_RESULT:%.*]], ptr noundef readonly byval({ ppc_fp128, ppc_fp128 }) align 16 captures(none) [[CLD:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] { // CHECK-PPC: [[CLD_REAL:%.*]] = load ppc_fp128, ptr [[CLD]], align 16 // CHECK-PPC: [[CLD_IMAG:%.*]] = load ppc_fp128, ptr [[CLD_IMAGP:%.*]], align 16 // CHECK-PPC: store ppc_fp128 [[CLD_REAL]], ptr [[BYVAL_TEMP:%.*]], align 16 @@ -103,7 +103,7 @@ long double test_powl(long double a, long double b) { // CHECK-PPC: store ppc_fp128 [[MUL_IR:%.*]], ptr [[AGG_RESULT_IMAGP:%.*]], align 16 // // CHECK-ARM-LABEL: define dso_local void @test_cargl( -// CHECK-ARM-SAME: ptr dead_on_unwind noalias nocapture writable writeonly sret({ double, double }) align 8 initializes((0, 16)) [[AGG_RESULT:%.*]], [2 x i64] noundef [[CLD_COERCE:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] { +// CHECK-ARM-SAME: ptr dead_on_unwind noalias writable writeonly sret({ double, double }) align 8 captures(none) initializes((0, 16)) [[AGG_RESULT:%.*]], [2 x i64] noundef [[CLD_COERCE:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] { // CHECK-ARM: [[CALL:%.*]] = tail call double @cargl([2 x i64] noundef [[CLD_COERCE]]) #[[ATTR2]], !tbaa [[TBAA3]] // CHECK-ARM: store double [[MUL_RL:%.*]], ptr [[AGG_RESULT]], align 8 // CHECK-ARM: store double [[MUL_IR:%.*]], ptr [[AGG_RESULT_IMAGP:%.*]], align 8 @@ -121,7 +121,7 @@ long double test_powl(long double a, long double b) { // CHECK-AARCH: [[CALL:%.*]] = tail call fp128 @cargl([2 x fp128] noundef alignstack(16) [[CLD_COERCE]]) #[[ATTR2]], !tbaa [[TBAA2]] // // CHECK-SPIR-LABEL: define dso_local spir_func void @test_cargl( -// CHECK-SPIR-SAME: ptr dead_on_unwind noalias nocapture writable writeonly sret({ double, double }) align 8 initializes((0, 16)) [[AGG_RESULT:%.*]], ptr nocapture noundef readonly byval({ double, double }) align 8 [[CLD:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] { +// CHECK-SPIR-SAME: ptr dead_on_unwind noalias writable writeonly sret({ double, double }) align 8 captures(none) initializes((0, 16)) [[AGG_RESULT:%.*]], ptr noundef readonly byval({ double, double }) align 8 captures(none) [[CLD:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] { // CHECK-SPIR: [[CLD_REAL:%.*]] = load double, ptr [[CLD]], align 8 // CHECK-SPIR: [[CLD_IMAG:%.*]] = load double, ptr [[CLD_IMAGP:%.*]], align 8 // CHECK-SPIR: store double [[CLD_REAL]], ptr [[BYVAL_TEMP:%.*]], align 8 @@ -131,7 +131,7 @@ long double test_powl(long double a, long double b) { // CHECK-SPIR: store double [[MUL_IR:%.*]], ptr [[AGG_RESULT_IMAGP:%.*]], align 8 // // CHECK-MINGW32-LABEL: define dso_local void @test_cargl( -// CHECK-MINGW32-SAME: ptr dead_on_unwind noalias nocapture writable writeonly sret({ x86_fp80, x86_fp80 }) align 16 initializes((0, 10), (16, 26)) [[AGG_RESULT:%.*]], ptr nocapture noundef readonly [[CLD:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-MINGW32-SAME: ptr dead_on_unwind noalias writable writeonly sret({ x86_fp80, x86_fp80 }) align 16 captures(none) initializes((0, 10), (16, 26)) [[AGG_RESULT:%.*]], ptr noundef readonly captures(none) [[CLD:%.*]]) local_unnamed_addr #[[ATTR0]] { // CHECK-MINGW32: [[CLD_REAL:%.*]] = load x86_fp80, ptr [[CLD]], align 16 // CHECK-MINGW32: [[CLD_IMAG:%.*]] = load x86_fp80, ptr [[CLD_IMAGP:%.*]], align 16 // CHECK-MINGW32: store x86_fp80 [[CLD_REAL]], ptr [[BYVAL_TEMP:%.*]], align 16 @@ -189,7 +189,7 @@ int ilogbl(long double a); // CHECK-SPIR: [[CALL:%.*]] = tail call spir_func i32 @ilogbl(double noundef [[A]]) #[[ATTR3]], !tbaa [[TBAA2]] // // CHECK-MINGW32-LABEL: define dso_local i32 @test_ilogb( -// CHECK-MINGW32-SAME: ptr nocapture noundef readonly [[TMP0:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-MINGW32-SAME: ptr noundef readonly captures(none) [[TMP0:%.*]]) local_unnamed_addr #[[ATTR0]] { // CHECK-MINGW32: [[A:%.*]] = load x86_fp80, ptr [[TMP0]], align 16, !tbaa [[TBAA3]] // CHECK-MINGW32: store x86_fp80 [[A]], ptr [[BYVAL_TEMP:%.*]], align 16, !tbaa [[TBAA3]] // CHECK-MINGW32: [[CALL:%.*]] = call i32 @ilogbl(ptr noundef nonnull [[BYVAL_TEMP]]) #[[ATTR3]] diff --git clang/test/CodeGen/math-libcalls-tbaa.c clang/test/CodeGen/math-libcalls-tbaa.c index 17a93ed2aed2..f4e81ea6dff1 100644 --- clang/test/CodeGen/math-libcalls-tbaa.c +++ clang/test/CodeGen/math-libcalls-tbaa.c @@ -14,7 +14,7 @@ float crealf(float _Complex); // Emit int TBAA metadata on FP math libcalls, which is useful for alias analysis // CHECK-LABEL: define dso_local float @test_expf( -// CHECK-SAME: ptr nocapture noundef readonly [[NUM:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { +// CHECK-SAME: ptr noundef readonly captures(none) [[NUM:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { // CHECK-NEXT: [[ENTRY:.*:]] // CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds nuw i8, ptr [[NUM]], i64 40 // CHECK-NEXT: [[TMP0:%.*]] = load float, ptr [[ARRAYIDX]], align 4, !tbaa [[TBAA2:![0-9]+]] @@ -29,7 +29,7 @@ float test_expf (float num[]) { } // CHECK-LABEL: define dso_local float @test_builtin_expf( -// CHECK-SAME: ptr nocapture noundef readonly [[NUM:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-SAME: ptr noundef readonly captures(none) [[NUM:%.*]]) local_unnamed_addr #[[ATTR0]] { // CHECK-NEXT: [[ENTRY:.*:]] // CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds nuw i8, ptr [[NUM]], i64 40 // CHECK-NEXT: [[TMP0:%.*]] = load float, ptr [[ARRAYIDX]], align 4, !tbaa [[TBAA2]] @@ -46,7 +46,7 @@ float test_builtin_expf (float num[]) { // // Negative test: fabs cannot set errno // CHECK-LABEL: define dso_local double @test_fabs( -// CHECK-SAME: ptr nocapture noundef readonly [[NUM:%.*]]) local_unnamed_addr #[[ATTR3:[0-9]+]] { +// CHECK-SAME: ptr noundef readonly captures(none) [[NUM:%.*]]) local_unnamed_addr #[[ATTR3:[0-9]+]] { // CHECK-NEXT: [[ENTRY:.*:]] // CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds nuw i8, ptr [[NUM]], i64 80 // CHECK-NEXT: [[TMP0:%.*]] = load double, ptr [[ARRAYIDX]], align 8, !tbaa [[TBAA8:![0-9]+]] @@ -61,7 +61,7 @@ double test_fabs (double num[]) { } // CHECK-LABEL: define dso_local double @test_remainder( -// CHECK-SAME: ptr nocapture noundef readonly [[NUM:%.*]], double noundef [[A:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-SAME: ptr noundef readonly captures(none) [[NUM:%.*]], double noundef [[A:%.*]]) local_unnamed_addr #[[ATTR0]] { // CHECK-NEXT: [[ENTRY:.*:]] // CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds nuw i8, ptr [[NUM]], i64 80 // CHECK-NEXT: [[TMP0:%.*]] = load double, ptr [[ARRAYIDX]], align 8, !tbaa [[TBAA8]] @@ -79,7 +79,7 @@ double test_remainder (double num[], double a) { // TODO: frexp is not subject to any errors, but also writes to // its int pointer out argument, so it could emit int TBAA metadata. // CHECK-LABEL: define dso_local double @test_frexp( -// CHECK-SAME: ptr nocapture noundef readonly [[NUM:%.*]]) local_unnamed_addr #[[ATTR5:[0-9]+]] { +// CHECK-SAME: ptr noundef readonly captures(none) [[NUM:%.*]]) local_unnamed_addr #[[ATTR5:[0-9]+]] { // CHECK-NEXT: [[ENTRY:.*:]] // CHECK-NEXT: [[E:%.*]] = alloca i32, align 4 // CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 4, ptr nonnull [[E]]) #[[ATTR9]] @@ -101,7 +101,7 @@ double test_frexp (double num[]) { // Negative test: sincos is a library function, but is not a builtin function // checked in CodeGenFunction::EmitCallExpr. // CHECK-LABEL: define dso_local float @test_sincos( -// CHECK-SAME: ptr nocapture noundef readonly [[NUM:%.*]]) local_unnamed_addr #[[ATTR7:[0-9]+]] { +// CHECK-SAME: ptr noundef readonly captures(none) [[NUM:%.*]]) local_unnamed_addr #[[ATTR7:[0-9]+]] { // CHECK-NEXT: [[ENTRY:.*:]] // CHECK-NEXT: [[SIN:%.*]] = alloca float, align 4 // CHECK-NEXT: [[COS:%.*]] = alloca float, align 4 @@ -128,7 +128,7 @@ float test_sincos (float num[]) { // TODO: The builtin return a complex type // CHECK-LABEL: define dso_local float @test_cacoshf( -// CHECK-SAME: ptr nocapture noundef readonly [[NUM:%.*]]) local_unnamed_addr #[[ATTR7]] { +// CHECK-SAME: ptr noundef readonly captures(none) [[NUM:%.*]]) local_unnamed_addr #[[ATTR7]] { // CHECK-NEXT: [[ENTRY:.*:]] // CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds nuw i8, ptr [[NUM]], i64 8 // CHECK-NEXT: [[TMP0:%.*]] = load float, ptr [[ARRAYIDX]], align 4, !tbaa [[TBAA2]] diff --git clang/test/CodeGen/nofpclass.c clang/test/CodeGen/nofpclass.c index 75aa0318421d..8e61ae22ef87 100644 --- clang/test/CodeGen/nofpclass.c +++ clang/test/CodeGen/nofpclass.c @@ -920,7 +920,7 @@ _Complex _Float16 defined_complex_func_f16_ret(_Complex _Float16 c) { // // CLFINITEONLY: Function Attrs: convergent norecurse nounwind // CLFINITEONLY-LABEL: define dso_local nofpclass(nan inf) float @call_variadic -// CLFINITEONLY-SAME: (float noundef nofpclass(nan inf) [[F32:%.*]], double noundef nofpclass(nan inf) [[F64:%.*]], half noundef nofpclass(nan inf) [[F16:%.*]], double noundef nofpclass(nan inf) [[V2F32_COERCE:%.*]], <2 x double> noundef nofpclass(nan inf) [[V2F64:%.*]], i32 noundef [[V2F16_COERCE:%.*]], <2 x float> noundef nofpclass(nan inf) [[CF32_COERCE:%.*]], double noundef nofpclass(nan inf) [[CF64_COERCE0:%.*]], double noundef nofpclass(nan inf) [[CF64_COERCE1:%.*]], ptr nocapture noundef readonly byval({ half, half }) align 8 [[CF16:%.*]]) local_unnamed_addr #[[ATTR5]] { +// CLFINITEONLY-SAME: (float noundef nofpclass(nan inf) [[F32:%.*]], double noundef nofpclass(nan inf) [[F64:%.*]], half noundef nofpclass(nan inf) [[F16:%.*]], double noundef nofpclass(nan inf) [[V2F32_COERCE:%.*]], <2 x double> noundef nofpclass(nan inf) [[V2F64:%.*]], i32 noundef [[V2F16_COERCE:%.*]], <2 x float> noundef nofpclass(nan inf) [[CF32_COERCE:%.*]], double noundef nofpclass(nan inf) [[CF64_COERCE0:%.*]], double noundef nofpclass(nan inf) [[CF64_COERCE1:%.*]], ptr noundef readonly byval({ half, half }) align 8 captures(none) [[CF16:%.*]]) local_unnamed_addr #[[ATTR5]] { // CLFINITEONLY-NEXT: entry: // CLFINITEONLY-NEXT: [[BYVAL_TEMP:%.*]] = alloca { double, double }, align 8 // CLFINITEONLY-NEXT: [[CONV:%.*]] = fpext nnan ninf float [[F32]] to double @@ -1173,7 +1173,7 @@ float call_variadic(float f32, double f64, _Float16 f16, // // CLFINITEONLY: Function Attrs: convergent norecurse nounwind // CLFINITEONLY-LABEL: define dso_local nofpclass(nan inf) float @call_variadic_indirect -// CLFINITEONLY-SAME: (ptr nocapture noundef readonly [[FPTR:%.*]], float noundef nofpclass(nan inf) [[F32:%.*]], double noundef nofpclass(nan inf) [[F64:%.*]], half noundef nofpclass(nan inf) [[F16:%.*]], double noundef nofpclass(nan inf) [[V2F32_COERCE:%.*]], <2 x double> noundef nofpclass(nan inf) [[V2F64:%.*]], i32 noundef [[V2F16_COERCE:%.*]], <2 x float> noundef nofpclass(nan inf) [[CF32_COERCE:%.*]], double noundef nofpclass(nan inf) [[CF64_COERCE0:%.*]], double noundef nofpclass(nan inf) [[CF64_COERCE1:%.*]], ptr nocapture noundef readonly byval({ half, half }) align 8 [[CF16:%.*]]) local_unnamed_addr #[[ATTR5]] { +// CLFINITEONLY-SAME: (ptr noundef readonly captures(none) [[FPTR:%.*]], float noundef nofpclass(nan inf) [[F32:%.*]], double noundef nofpclass(nan inf) [[F64:%.*]], half noundef nofpclass(nan inf) [[F16:%.*]], double noundef nofpclass(nan inf) [[V2F32_COERCE:%.*]], <2 x double> noundef nofpclass(nan inf) [[V2F64:%.*]], i32 noundef [[V2F16_COERCE:%.*]], <2 x float> noundef nofpclass(nan inf) [[CF32_COERCE:%.*]], double noundef nofpclass(nan inf) [[CF64_COERCE0:%.*]], double noundef nofpclass(nan inf) [[CF64_COERCE1:%.*]], ptr noundef readonly byval({ half, half }) align 8 captures(none) [[CF16:%.*]]) local_unnamed_addr #[[ATTR5]] { // CLFINITEONLY-NEXT: entry: // CLFINITEONLY-NEXT: [[BYVAL_TEMP:%.*]] = alloca { double, double }, align 8 // CLFINITEONLY-NEXT: [[CONV:%.*]] = fpext nnan ninf float [[F32]] to double diff --git clang/test/CodeGen/pointer-overflow.c clang/test/CodeGen/pointer-overflow.c new file mode 100644 index 000000000000..9c7821b84198 --- /dev/null +++ clang/test/CodeGen/pointer-overflow.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s --check-prefix=DEFAULT +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fwrapv | FileCheck %s --check-prefix=DEFAULT +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -ftrapv | FileCheck %s --check-prefix=DEFAULT +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fwrapv-pointer | FileCheck %s --check-prefix=FWRAPV-POINTER + +void test(void) { + // -fwrapv-pointer should turn off inbounds for GEP's + extern int* P; + ++P; + // DEFAULT: getelementptr inbounds nuw i32, ptr + // FWRAPV-POINTER: getelementptr i32, ptr +} diff --git clang/test/CodeGen/sanitize-metadata-nosanitize.c clang/test/CodeGen/sanitize-metadata-nosanitize.c index fd2fdce31b52..eabcbd1409fe 100644 --- clang/test/CodeGen/sanitize-metadata-nosanitize.c +++ clang/test/CodeGen/sanitize-metadata-nosanitize.c @@ -23,7 +23,7 @@ __attribute__((noinline, not_tail_called)) void escape(const volatile void *p) { // CHECK: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: none) // CHECK-LABEL: define dso_local i32 @normal_function -// CHECK-SAME: (ptr noundef [[X:%.*]], ptr nocapture noundef readonly [[Y:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] !pcsections [[META4:![0-9]+]] { +// CHECK-SAME: (ptr noundef [[X:%.*]], ptr noundef readonly captures(none) [[Y:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] !pcsections [[META4:![0-9]+]] { // CHECK-NEXT: entry: // CHECK-NEXT: [[X_ADDR:%.*]] = alloca ptr, align 8 // CHECK-NEXT: store ptr [[X]], ptr [[X_ADDR]], align 8, !tbaa [[TBAA6:![0-9]+]] @@ -40,7 +40,7 @@ int normal_function(int *x, int *y) { // CHECK: Function Attrs: disable_sanitizer_instrumentation mustprogress nofree norecurse nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: none) // CHECK-LABEL: define dso_local i32 @test_disable_sanitize_instrumentation -// CHECK-SAME: (ptr noundef [[X:%.*]], ptr nocapture noundef readonly [[Y:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] { +// CHECK-SAME: (ptr noundef [[X:%.*]], ptr noundef readonly captures(none) [[Y:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] { // CHECK-NEXT: entry: // CHECK-NEXT: [[X_ADDR:%.*]] = alloca ptr, align 8 // CHECK-NEXT: store ptr [[X]], ptr [[X_ADDR]], align 8, !tbaa [[TBAA6]] @@ -57,7 +57,7 @@ __attribute__((disable_sanitizer_instrumentation)) int test_disable_sanitize_ins // CHECK: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: none) // CHECK-LABEL: define dso_local i32 @test_no_sanitize_thread -// CHECK-SAME: (ptr noundef [[X:%.*]], ptr nocapture noundef readonly [[Y:%.*]]) local_unnamed_addr #[[ATTR3:[0-9]+]] !pcsections [[META14:![0-9]+]] { +// CHECK-SAME: (ptr noundef [[X:%.*]], ptr noundef readonly captures(none) [[Y:%.*]]) local_unnamed_addr #[[ATTR3:[0-9]+]] !pcsections [[META14:![0-9]+]] { // CHECK-NEXT: entry: // CHECK-NEXT: [[X_ADDR:%.*]] = alloca ptr, align 8 // CHECK-NEXT: store ptr [[X]], ptr [[X_ADDR]], align 8, !tbaa [[TBAA6]] @@ -74,7 +74,7 @@ __attribute__((no_sanitize("thread"))) int test_no_sanitize_thread(int *x, int * // CHECK: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: none) // CHECK-LABEL: define dso_local i32 @test_no_sanitize_all -// CHECK-SAME: (ptr noundef [[X:%.*]], ptr nocapture noundef readonly [[Y:%.*]]) local_unnamed_addr #[[ATTR3]] !pcsections [[META14]] { +// CHECK-SAME: (ptr noundef [[X:%.*]], ptr noundef readonly captures(none) [[Y:%.*]]) local_unnamed_addr #[[ATTR3]] !pcsections [[META14]] { // CHECK-NEXT: entry: // CHECK-NEXT: [[X_ADDR:%.*]] = alloca ptr, align 8 // CHECK-NEXT: store ptr [[X]], ptr [[X_ADDR]], align 8, !tbaa [[TBAA6]] diff --git clang/test/CodeGen/struct-copy.c clang/test/CodeGen/struct-copy.c index bb4166c9464f..299f98833a30 100644 --- clang/test/CodeGen/struct-copy.c +++ clang/test/CodeGen/struct-copy.c @@ -8,7 +8,7 @@ void foo(struct x *P, struct x *Q) { *P = *Q; } -// CHECK: declare void @llvm.memcpy.p0.p0{{.*}}(ptr noalias nocapture writeonly, ptr noalias nocapture readonly +// CHECK: declare void @llvm.memcpy.p0.p0{{.*}}(ptr noalias writeonly captures(none), ptr noalias readonly void bar(struct x *P, struct x *Q) { // CHECK-LABEL: @bar( diff --git clang/test/CodeGen/tbaa-struct-bitfield-endianness.cpp clang/test/CodeGen/tbaa-struct-bitfield-endianness.cpp index 7173b6e8fbe2..1177691ca511 100644 --- clang/test/CodeGen/tbaa-struct-bitfield-endianness.cpp +++ clang/test/CodeGen/tbaa-struct-bitfield-endianness.cpp @@ -16,7 +16,7 @@ struct NamedBitfields { }; // CHECK-LABEL: _Z4copyP14NamedBitfieldsS0_ -// CHECK-SAME: ptr nocapture noundef writeonly initializes((0, 16)) [[A1:%.*]], ptr nocapture noundef readonly [[A2:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { +// CHECK-SAME: ptr noundef writeonly captures(none) initializes((0, 16)) [[A1:%.*]], ptr noundef readonly captures(none) [[A2:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { // CHECK-NEXT: entry: // CHECK-NEXT: tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) [[A1]], ptr noundef nonnull align 8 dereferenceable(16) [[A2]], i64 16, i1 false), !tbaa.struct [[TBAA_STRUCT2:![0-9]+]] // CHECK-NEXT: ret void diff --git clang/test/CodeGen/transparent-union-type.c clang/test/CodeGen/transparent-union-type.c index f7fac25dc098..5c81b8a02477 100644 --- clang/test/CodeGen/transparent-union-type.c +++ clang/test/CodeGen/transparent-union-type.c @@ -53,7 +53,7 @@ void ftest0(tu_c_t uc) { } void ftest1(tu_s_t uc) { } // CHECK-LABEL: define{{.*}} void @ftest1b( -// CHECK-SAME: ptr nocapture noundef readnone [[UC:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-SAME: ptr noundef readnone captures(none) [[UC:%.*]]) local_unnamed_addr #[[ATTR0]] { // CHECK-NEXT: [[ENTRY:.*:]] // CHECK-NEXT: ret void // @@ -94,14 +94,14 @@ typedef union tu_ptr { } tu_ptr_t __attribute__((transparent_union)); // CHECK-LABEL: define{{.*}} void @ftest5( -// CHECK-SAME: ptr nocapture readnone [[UC_COERCE:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { +// CHECK-SAME: ptr readnone captures(none) [[UC_COERCE:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { // CHECK-NEXT: [[ENTRY:.*:]] // CHECK-NEXT: ret void // void ftest5(tu_ptr_t uc) { } // CHECK-LABEL: define{{.*}} void @ftest6( -// CHECK-SAME: ptr nocapture noundef readnone [[UC:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-SAME: ptr noundef readnone captures(none) [[UC:%.*]]) local_unnamed_addr #[[ATTR0]] { // CHECK-NEXT: [[ENTRY:.*:]] // CHECK-NEXT: ret void // diff --git clang/test/CodeGen/union-tbaa1.c clang/test/CodeGen/union-tbaa1.c index 0f7a67cb7ecc..1e2f384c29a5 100644 --- clang/test/CodeGen/union-tbaa1.c +++ clang/test/CodeGen/union-tbaa1.c @@ -8,7 +8,7 @@ typedef union __attribute__((aligned(4))) { void bar(vect32 p[][2]); // CHECK-LABEL: define dso_local void @fred -// CHECK-SAME: (i32 noundef [[NUM:%.*]], ptr nocapture noundef writeonly initializes((0, 8)) [[VEC:%.*]], ptr nocapture noundef readonly [[INDEX:%.*]], ptr nocapture noundef readonly [[ARR:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { +// CHECK-SAME: (i32 noundef [[NUM:%.*]], ptr noundef writeonly captures(none) initializes((0, 8)) [[VEC:%.*]], ptr noundef readonly captures(none) [[INDEX:%.*]], ptr noundef readonly captures(none) [[ARR:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { // CHECK-NEXT: entry: // CHECK-NEXT: [[TMP:%.*]] = alloca [4 x [2 x %union.vect32]], align 8 // CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 32, ptr nonnull [[TMP]]) #[[ATTR3:[0-9]+]] diff --git clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu index 19730e392551..a48affaec3c8 100644 --- clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu +++ clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu @@ -50,7 +50,7 @@ // CHECK-SPIRV-NEXT: ret void // // OPT-LABEL: define dso_local amdgpu_kernel void @_Z7kernel1Pi( -// OPT-SAME: ptr addrspace(1) nocapture noundef [[X_COERCE:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { +// OPT-SAME: ptr addrspace(1) noundef captures(none) [[X_COERCE:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { // OPT-NEXT: [[ENTRY:.*:]] // OPT-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(1) [[X_COERCE]], align 4 // OPT-NEXT: [[INC:%.*]] = add nsw i32 [[TMP0]], 1 @@ -118,7 +118,7 @@ __global__ void kernel1(int *x) { // CHECK-SPIRV-NEXT: ret void // // OPT-LABEL: define dso_local amdgpu_kernel void @_Z7kernel2Ri( -// OPT-SAME: ptr addrspace(1) nocapture noundef nonnull align 4 dereferenceable(4) [[X_COERCE:%.*]]) local_unnamed_addr #[[ATTR0]] { +// OPT-SAME: ptr addrspace(1) noundef nonnull align 4 captures(none) dereferenceable(4) [[X_COERCE:%.*]]) local_unnamed_addr #[[ATTR0]] { // OPT-NEXT: [[ENTRY:.*:]] // OPT-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(1) [[X_COERCE]], align 4 // OPT-NEXT: [[INC:%.*]] = add nsw i32 [[TMP0]], 1 @@ -188,14 +188,14 @@ __global__ void kernel2(int &x) { // CHECK-SPIRV-NEXT: ret void // // OPT-LABEL: define dso_local amdgpu_kernel void @_Z7kernel3PU3AS2iPU3AS1i( -// OPT-SAME: ptr addrspace(2) nocapture noundef readonly [[X:%.*]], ptr addrspace(1) nocapture noundef writeonly initializes((0, 4)) [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { +// OPT-SAME: ptr addrspace(2) noundef readonly captures(none) [[X:%.*]], ptr addrspace(1) noundef writeonly captures(none) initializes((0, 4)) [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { // OPT-NEXT: [[ENTRY:.*:]] // OPT-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(2) [[X]], align 4 // OPT-NEXT: store i32 [[TMP0]], ptr addrspace(1) [[Y]], align 4 // OPT-NEXT: ret void // // OPT-SPIRV-LABEL: define spir_kernel void @_Z7kernel3PU3AS2iPU3AS1i( -// OPT-SPIRV-SAME: ptr addrspace(2) nocapture noundef readonly [[X:%.*]], ptr addrspace(1) nocapture noundef writeonly initializes((0, 4)) [[Y:%.*]]) local_unnamed_addr addrspace(4) #[[ATTR1:[0-9]+]] !max_work_group_size [[META5]] { +// OPT-SPIRV-SAME: ptr addrspace(2) noundef readonly captures(none) [[X:%.*]], ptr addrspace(1) noundef writeonly captures(none) initializes((0, 4)) [[Y:%.*]]) local_unnamed_addr addrspace(4) #[[ATTR1:[0-9]+]] !max_work_group_size [[META5]] { // OPT-SPIRV-NEXT: [[ENTRY:.*:]] // OPT-SPIRV-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(2) [[X]], align 4 // OPT-SPIRV-NEXT: store i32 [[TMP0]], ptr addrspace(1) [[Y]], align 4 @@ -253,7 +253,7 @@ __global__ void kernel3(__attribute__((address_space(2))) int *x, // CHECK-SPIRV-NEXT: ret void // // OPT-LABEL: define dso_local void @_Z4funcPi( -// OPT-SAME: ptr nocapture noundef [[X:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] { +// OPT-SAME: ptr noundef captures(none) [[X:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] { // OPT-NEXT: [[ENTRY:.*:]] // OPT-NEXT: [[TMP0:%.*]] = load i32, ptr [[X]], align 4 // OPT-NEXT: [[INC:%.*]] = add nsw i32 [[TMP0]], 1 @@ -261,7 +261,7 @@ __global__ void kernel3(__attribute__((address_space(2))) int *x, // OPT-NEXT: ret void // // OPT-SPIRV-LABEL: define spir_func void @_Z4funcPi( -// OPT-SPIRV-SAME: ptr addrspace(4) nocapture noundef [[X:%.*]]) local_unnamed_addr addrspace(4) #[[ATTR2:[0-9]+]] { +// OPT-SPIRV-SAME: ptr addrspace(4) noundef captures(none) [[X:%.*]]) local_unnamed_addr addrspace(4) #[[ATTR2:[0-9]+]] { // OPT-SPIRV-NEXT: [[ENTRY:.*:]] // OPT-SPIRV-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(4) [[X]], align 4 // OPT-SPIRV-NEXT: [[INC:%.*]] = add nsw i32 [[TMP0]], 1 @@ -327,7 +327,7 @@ struct S { // CHECK-SPIRV-NEXT: ret void // // OPT-LABEL: define dso_local amdgpu_kernel void @_Z7kernel41S( -// OPT-SAME: ptr addrspace(4) nocapture noundef readonly byref([[STRUCT_S:%.*]]) align 8 [[TMP0:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] { +// OPT-SAME: ptr addrspace(4) noundef readonly byref([[STRUCT_S:%.*]]) align 8 captures(none) [[TMP0:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] { // OPT-NEXT: [[ENTRY:.*:]] // OPT-NEXT: [[COERCE_SROA_0_0_COPYLOAD:%.*]] = load ptr, ptr addrspace(4) [[TMP0]], align 8, !amdgpu.noclobber [[META4:![0-9]+]] // OPT-NEXT: [[TMP1:%.*]] = addrspacecast ptr [[COERCE_SROA_0_0_COPYLOAD]] to ptr addrspace(1) @@ -432,7 +432,7 @@ __global__ void kernel4(struct S s) { // CHECK-SPIRV-NEXT: ret void // // OPT-LABEL: define dso_local amdgpu_kernel void @_Z7kernel5P1S( -// OPT-SAME: ptr addrspace(1) nocapture noundef readonly [[S_COERCE:%.*]]) local_unnamed_addr #[[ATTR2]] { +// OPT-SAME: ptr addrspace(1) noundef readonly captures(none) [[S_COERCE:%.*]]) local_unnamed_addr #[[ATTR2]] { // OPT-NEXT: [[ENTRY:.*:]] // OPT-NEXT: [[TMP0:%.*]] = load ptr, ptr addrspace(1) [[S_COERCE]], align 8 // OPT-NEXT: [[TMP1:%.*]] = load i32, ptr [[TMP0]], align 4 @@ -535,7 +535,7 @@ struct T { // CHECK-SPIRV-NEXT: ret void // // OPT-LABEL: define dso_local amdgpu_kernel void @_Z7kernel61T( -// OPT-SAME: ptr addrspace(4) nocapture noundef readonly byref([[STRUCT_T:%.*]]) align 8 [[TMP0:%.*]]) local_unnamed_addr #[[ATTR2]] { +// OPT-SAME: ptr addrspace(4) noundef readonly byref([[STRUCT_T:%.*]]) align 8 captures(none) [[TMP0:%.*]]) local_unnamed_addr #[[ATTR2]] { // OPT-NEXT: [[ENTRY:.*:]] // OPT-NEXT: [[COERCE_SROA_0_0_COPYLOAD:%.*]] = load ptr, ptr addrspace(4) [[TMP0]], align 8, !amdgpu.noclobber [[META4]] // OPT-NEXT: [[TMP1:%.*]] = addrspacecast ptr [[COERCE_SROA_0_0_COPYLOAD]] to ptr addrspace(1) @@ -623,7 +623,7 @@ __global__ void kernel6(struct T t) { // CHECK-SPIRV-NEXT: ret void // // OPT-LABEL: define dso_local amdgpu_kernel void @_Z7kernel7Pi( -// OPT-SAME: ptr addrspace(1) noalias nocapture noundef [[X_COERCE:%.*]]) local_unnamed_addr #[[ATTR0]] { +// OPT-SAME: ptr addrspace(1) noalias noundef captures(none) [[X_COERCE:%.*]]) local_unnamed_addr #[[ATTR0]] { // OPT-NEXT: [[ENTRY:.*:]] // OPT-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(1) [[X_COERCE]], align 4 // OPT-NEXT: [[INC:%.*]] = add nsw i32 [[TMP0]], 1 @@ -692,7 +692,7 @@ struct SS { // CHECK-SPIRV-NEXT: ret void // // OPT-LABEL: define dso_local amdgpu_kernel void @_Z7kernel82SS( -// OPT-SAME: ptr addrspace(1) nocapture [[A_COERCE:%.*]]) local_unnamed_addr #[[ATTR0]] { +// OPT-SAME: ptr addrspace(1) captures(none) [[A_COERCE:%.*]]) local_unnamed_addr #[[ATTR0]] { // OPT-NEXT: [[ENTRY:.*:]] // OPT-NEXT: [[TMP0:%.*]] = load float, ptr addrspace(1) [[A_COERCE]], align 4 // OPT-NEXT: [[ADD:%.*]] = fadd contract float [[TMP0]], 3.000000e+00 diff --git clang/test/CodeGenCUDA/offloading-entries.cu clang/test/CodeGenCUDA/offloading-entries.cu index d46a25969e3e..4f65e7335d85 100644 --- clang/test/CodeGenCUDA/offloading-entries.cu +++ clang/test/CodeGenCUDA/offloading-entries.cu @@ -19,63 +19,61 @@ //. // CUDA: @managed = global i32 undef, align 4 // CUDA: @.offloading.entry_name = internal unnamed_addr constant [8 x i8] c"_Z3foov\00", section ".llvm.rodata.offloading", align 1 -// CUDA: @.offloading.entry._Z3foov = weak constant %struct.__tgt_offload_entry { ptr @_Z18__device_stub__foov, ptr @.offloading.entry_name, i64 0, i32 0, i32 0 }, section "cuda_offloading_entries", align 1 +// CUDA: @.offloading.entry._Z3foov = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 2, i32 0, ptr @_Z18__device_stub__foov, ptr @.offloading.entry_name, i64 0, i64 0, ptr null }, section "cuda_offloading_entries", align 1 // CUDA: @.offloading.entry_name.1 = internal unnamed_addr constant [11 x i8] c"_Z6kernelv\00", section ".llvm.rodata.offloading", align 1 -// CUDA: @.offloading.entry._Z6kernelv = weak constant %struct.__tgt_offload_entry { ptr @_Z21__device_stub__kernelv, ptr @.offloading.entry_name.1, i64 0, i32 0, i32 0 }, section "cuda_offloading_entries", align 1 +// CUDA: @.offloading.entry._Z6kernelv = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 2, i32 0, ptr @_Z21__device_stub__kernelv, ptr @.offloading.entry_name.1, i64 0, i64 0, ptr null }, section "cuda_offloading_entries", align 1 // CUDA: @.offloading.entry_name.2 = internal unnamed_addr constant [4 x i8] c"var\00", section ".llvm.rodata.offloading", align 1 -// CUDA: @.offloading.entry.var = weak constant %struct.__tgt_offload_entry { ptr @var, ptr @.offloading.entry_name.2, i64 4, i32 0, i32 0 }, section "cuda_offloading_entries", align 1 +// CUDA: @.offloading.entry.var = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 2, i32 0, ptr @var, ptr @.offloading.entry_name.2, i64 4, i64 0, ptr null }, section "cuda_offloading_entries", align 1 // CUDA: @.offloading.entry_name.3 = internal unnamed_addr constant [8 x i8] c"managed\00", section ".llvm.rodata.offloading", align 1 -// CUDA: @.offloading.entry.managed = weak constant %struct.__tgt_offload_entry { ptr @managed, ptr @.offloading.entry_name.3, i64 4, i32 0, i32 0 }, section "cuda_offloading_entries", align 1 +// CUDA: @.offloading.entry.managed = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 2, i32 0, ptr @managed, ptr @.offloading.entry_name.3, i64 4, i64 0, ptr null }, section "cuda_offloading_entries", align 1 // CUDA: @.offloading.entry_name.4 = internal unnamed_addr constant [5 x i8] c"surf\00", section ".llvm.rodata.offloading", align 1 -// CUDA: @.offloading.entry.surf = weak constant %struct.__tgt_offload_entry { ptr @surf, ptr @.offloading.entry_name.4, i64 4, i32 2, i32 1 }, section "cuda_offloading_entries", align 1 +// CUDA: @.offloading.entry.surf = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 2, i32 2, ptr @surf, ptr @.offloading.entry_name.4, i64 4, i64 1, ptr null }, section "cuda_offloading_entries", align 1 // CUDA: @.offloading.entry_name.5 = internal unnamed_addr constant [4 x i8] c"tex\00", section ".llvm.rodata.offloading", align 1 -// CUDA: @.offloading.entry.tex = weak constant %struct.__tgt_offload_entry { ptr @tex, ptr @.offloading.entry_name.5, i64 4, i32 3, i32 1 }, section "cuda_offloading_entries", align 1 +// CUDA: @.offloading.entry.tex = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 2, i32 3, ptr @tex, ptr @.offloading.entry_name.5, i64 4, i64 1, ptr null }, section "cuda_offloading_entries", align 1 //. // HIP: @managed.managed = global i32 0, align 4 // HIP: @managed = externally_initialized global ptr null // HIP: @.offloading.entry_name = internal unnamed_addr constant [8 x i8] c"_Z3foov\00", section ".llvm.rodata.offloading", align 1 -// HIP: @.offloading.entry._Z3foov = weak constant %struct.__tgt_offload_entry { ptr @_Z3foov, ptr @.offloading.entry_name, i64 0, i32 0, i32 0 }, section "hip_offloading_entries", align 1 +// HIP: @.offloading.entry._Z3foov = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 3, i32 0, ptr @_Z3foov, ptr @.offloading.entry_name, i64 0, i64 0, ptr null }, section "hip_offloading_entries", align 1 // HIP: @.offloading.entry_name.1 = internal unnamed_addr constant [11 x i8] c"_Z6kernelv\00", section ".llvm.rodata.offloading", align 1 -// HIP: @.offloading.entry._Z6kernelv = weak constant %struct.__tgt_offload_entry { ptr @_Z6kernelv, ptr @.offloading.entry_name.1, i64 0, i32 0, i32 0 }, section "hip_offloading_entries", align 1 +// HIP: @.offloading.entry._Z6kernelv = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 3, i32 0, ptr @_Z6kernelv, ptr @.offloading.entry_name.1, i64 0, i64 0, ptr null }, section "hip_offloading_entries", align 1 // HIP: @.offloading.entry_name.2 = internal unnamed_addr constant [4 x i8] c"var\00", section ".llvm.rodata.offloading", align 1 -// HIP: @.offloading.entry.var = weak constant %struct.__tgt_offload_entry { ptr @var, ptr @.offloading.entry_name.2, i64 4, i32 0, i32 0 }, section "hip_offloading_entries", align 1 -// HIP: @managed.managed.3 = private constant %struct.__managed_var { ptr @managed, ptr @managed.managed } -// HIP: @.offloading.entry_name.4 = internal unnamed_addr constant [8 x i8] c"managed\00", section ".llvm.rodata.offloading", align 1 -// HIP: @.offloading.entry.managed = weak constant %struct.__tgt_offload_entry { ptr @managed.managed.3, ptr @.offloading.entry_name.4, i64 4, i32 1, i32 4 }, section "hip_offloading_entries", align 1 -// HIP: @.offloading.entry_name.5 = internal unnamed_addr constant [5 x i8] c"surf\00", section ".llvm.rodata.offloading", align 1 -// HIP: @.offloading.entry.surf = weak constant %struct.__tgt_offload_entry { ptr @surf, ptr @.offloading.entry_name.5, i64 4, i32 2, i32 1 }, section "hip_offloading_entries", align 1 -// HIP: @.offloading.entry_name.6 = internal unnamed_addr constant [4 x i8] c"tex\00", section ".llvm.rodata.offloading", align 1 -// HIP: @.offloading.entry.tex = weak constant %struct.__tgt_offload_entry { ptr @tex, ptr @.offloading.entry_name.6, i64 4, i32 3, i32 1 }, section "hip_offloading_entries", align 1 +// HIP: @.offloading.entry.var = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 3, i32 0, ptr @var, ptr @.offloading.entry_name.2, i64 4, i64 0, ptr null }, section "hip_offloading_entries", align 1 +// HIP: @.offloading.entry_name.3 = internal unnamed_addr constant [8 x i8] c"managed\00", section ".llvm.rodata.offloading", align 1 +// HIP: @.offloading.entry.managed = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 3, i32 1, ptr @managed.managed, ptr @.offloading.entry_name.3, i64 4, i64 4, ptr @managed }, section "hip_offloading_entries", align 1 +// HIP: @.offloading.entry_name.4 = internal unnamed_addr constant [5 x i8] c"surf\00", section ".llvm.rodata.offloading", align 1 +// HIP: @.offloading.entry.surf = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 3, i32 2, ptr @surf, ptr @.offloading.entry_name.4, i64 4, i64 1, ptr null }, section "hip_offloading_entries", align 1 +// HIP: @.offloading.entry_name.5 = internal unnamed_addr constant [4 x i8] c"tex\00", section ".llvm.rodata.offloading", align 1 +// HIP: @.offloading.entry.tex = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 3, i32 3, ptr @tex, ptr @.offloading.entry_name.5, i64 4, i64 1, ptr null }, section "hip_offloading_entries", align 1 //. // CUDA-COFF: @managed = dso_local global i32 undef, align 4 // CUDA-COFF: @.offloading.entry_name = internal unnamed_addr constant [8 x i8] c"_Z3foov\00", section ".llvm.rodata.offloading", align 1 -// CUDA-COFF: @.offloading.entry._Z3foov = weak constant %struct.__tgt_offload_entry { ptr @_Z18__device_stub__foov, ptr @.offloading.entry_name, i64 0, i32 0, i32 0 }, section "cuda_offloading_entries$OE", align 1 +// CUDA-COFF: @.offloading.entry._Z3foov = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 2, i32 0, ptr @_Z18__device_stub__foov, ptr @.offloading.entry_name, i64 0, i64 0, ptr null }, section "cuda_offloading_entries$OE", align 1 // CUDA-COFF: @.offloading.entry_name.1 = internal unnamed_addr constant [11 x i8] c"_Z6kernelv\00", section ".llvm.rodata.offloading", align 1 -// CUDA-COFF: @.offloading.entry._Z6kernelv = weak constant %struct.__tgt_offload_entry { ptr @_Z21__device_stub__kernelv, ptr @.offloading.entry_name.1, i64 0, i32 0, i32 0 }, section "cuda_offloading_entries$OE", align 1 +// CUDA-COFF: @.offloading.entry._Z6kernelv = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 2, i32 0, ptr @_Z21__device_stub__kernelv, ptr @.offloading.entry_name.1, i64 0, i64 0, ptr null }, section "cuda_offloading_entries$OE", align 1 // CUDA-COFF: @.offloading.entry_name.2 = internal unnamed_addr constant [4 x i8] c"var\00", section ".llvm.rodata.offloading", align 1 -// CUDA-COFF: @.offloading.entry.var = weak constant %struct.__tgt_offload_entry { ptr @var, ptr @.offloading.entry_name.2, i64 4, i32 0, i32 0 }, section "cuda_offloading_entries$OE", align 1 +// CUDA-COFF: @.offloading.entry.var = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 2, i32 0, ptr @var, ptr @.offloading.entry_name.2, i64 4, i64 0, ptr null }, section "cuda_offloading_entries$OE", align 1 // CUDA-COFF: @.offloading.entry_name.3 = internal unnamed_addr constant [8 x i8] c"managed\00", section ".llvm.rodata.offloading", align 1 -// CUDA-COFF: @.offloading.entry.managed = weak constant %struct.__tgt_offload_entry { ptr @managed, ptr @.offloading.entry_name.3, i64 4, i32 0, i32 0 }, section "cuda_offloading_entries$OE", align 1 +// CUDA-COFF: @.offloading.entry.managed = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 2, i32 0, ptr @managed, ptr @.offloading.entry_name.3, i64 4, i64 0, ptr null }, section "cuda_offloading_entries$OE", align 1 // CUDA-COFF: @.offloading.entry_name.4 = internal unnamed_addr constant [5 x i8] c"surf\00", section ".llvm.rodata.offloading", align 1 -// CUDA-COFF: @.offloading.entry.surf = weak constant %struct.__tgt_offload_entry { ptr @surf, ptr @.offloading.entry_name.4, i64 4, i32 2, i32 1 }, section "cuda_offloading_entries$OE", align 1 +// CUDA-COFF: @.offloading.entry.surf = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 2, i32 2, ptr @surf, ptr @.offloading.entry_name.4, i64 4, i64 1, ptr null }, section "cuda_offloading_entries$OE", align 1 // CUDA-COFF: @.offloading.entry_name.5 = internal unnamed_addr constant [4 x i8] c"tex\00", section ".llvm.rodata.offloading", align 1 -// CUDA-COFF: @.offloading.entry.tex = weak constant %struct.__tgt_offload_entry { ptr @tex, ptr @.offloading.entry_name.5, i64 4, i32 3, i32 1 }, section "cuda_offloading_entries$OE", align 1 +// CUDA-COFF: @.offloading.entry.tex = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 2, i32 3, ptr @tex, ptr @.offloading.entry_name.5, i64 4, i64 1, ptr null }, section "cuda_offloading_entries$OE", align 1 //. // HIP-COFF: @managed.managed = dso_local global i32 0, align 4 // HIP-COFF: @managed = dso_local externally_initialized global ptr null // HIP-COFF: @.offloading.entry_name = internal unnamed_addr constant [8 x i8] c"_Z3foov\00", section ".llvm.rodata.offloading", align 1 -// HIP-COFF: @.offloading.entry._Z3foov = weak constant %struct.__tgt_offload_entry { ptr @_Z3foov, ptr @.offloading.entry_name, i64 0, i32 0, i32 0 }, section "hip_offloading_entries$OE", align 1 +// HIP-COFF: @.offloading.entry._Z3foov = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 3, i32 0, ptr @_Z3foov, ptr @.offloading.entry_name, i64 0, i64 0, ptr null }, section "hip_offloading_entries$OE", align 1 // HIP-COFF: @.offloading.entry_name.1 = internal unnamed_addr constant [11 x i8] c"_Z6kernelv\00", section ".llvm.rodata.offloading", align 1 -// HIP-COFF: @.offloading.entry._Z6kernelv = weak constant %struct.__tgt_offload_entry { ptr @_Z6kernelv, ptr @.offloading.entry_name.1, i64 0, i32 0, i32 0 }, section "hip_offloading_entries$OE", align 1 +// HIP-COFF: @.offloading.entry._Z6kernelv = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 3, i32 0, ptr @_Z6kernelv, ptr @.offloading.entry_name.1, i64 0, i64 0, ptr null }, section "hip_offloading_entries$OE", align 1 // HIP-COFF: @.offloading.entry_name.2 = internal unnamed_addr constant [4 x i8] c"var\00", section ".llvm.rodata.offloading", align 1 -// HIP-COFF: @.offloading.entry.var = weak constant %struct.__tgt_offload_entry { ptr @var, ptr @.offloading.entry_name.2, i64 4, i32 0, i32 0 }, section "hip_offloading_entries$OE", align 1 -// HIP-COFF: @managed.managed.3 = private constant %struct.__managed_var { ptr @managed, ptr @managed.managed } -// HIP-COFF: @.offloading.entry_name.4 = internal unnamed_addr constant [8 x i8] c"managed\00", section ".llvm.rodata.offloading", align 1 -// HIP-COFF: @.offloading.entry.managed = weak constant %struct.__tgt_offload_entry { ptr @managed.managed.3, ptr @.offloading.entry_name.4, i64 4, i32 1, i32 4 }, section "hip_offloading_entries$OE", align 1 -// HIP-COFF: @.offloading.entry_name.5 = internal unnamed_addr constant [5 x i8] c"surf\00", section ".llvm.rodata.offloading", align 1 -// HIP-COFF: @.offloading.entry.surf = weak constant %struct.__tgt_offload_entry { ptr @surf, ptr @.offloading.entry_name.5, i64 4, i32 2, i32 1 }, section "hip_offloading_entries$OE", align 1 -// HIP-COFF: @.offloading.entry_name.6 = internal unnamed_addr constant [4 x i8] c"tex\00", section ".llvm.rodata.offloading", align 1 -// HIP-COFF: @.offloading.entry.tex = weak constant %struct.__tgt_offload_entry { ptr @tex, ptr @.offloading.entry_name.6, i64 4, i32 3, i32 1 }, section "hip_offloading_entries$OE", align 1 +// HIP-COFF: @.offloading.entry.var = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 3, i32 0, ptr @var, ptr @.offloading.entry_name.2, i64 4, i64 0, ptr null }, section "hip_offloading_entries$OE", align 1 +// HIP-COFF: @.offloading.entry_name.3 = internal unnamed_addr constant [8 x i8] c"managed\00", section ".llvm.rodata.offloading", align 1 +// HIP-COFF: @.offloading.entry.managed = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 3, i32 1, ptr @managed.managed, ptr @.offloading.entry_name.3, i64 4, i64 4, ptr @managed }, section "hip_offloading_entries$OE", align 1 +// HIP-COFF: @.offloading.entry_name.4 = internal unnamed_addr constant [5 x i8] c"surf\00", section ".llvm.rodata.offloading", align 1 +// HIP-COFF: @.offloading.entry.surf = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 3, i32 2, ptr @surf, ptr @.offloading.entry_name.4, i64 4, i64 1, ptr null }, section "hip_offloading_entries$OE", align 1 +// HIP-COFF: @.offloading.entry_name.5 = internal unnamed_addr constant [4 x i8] c"tex\00", section ".llvm.rodata.offloading", align 1 +// HIP-COFF: @.offloading.entry.tex = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 3, i32 3, ptr @tex, ptr @.offloading.entry_name.5, i64 4, i64 1, ptr null }, section "hip_offloading_entries$OE", align 1 //. // CUDA-LABEL: @_Z18__device_stub__foov( // CUDA-NEXT: entry: diff --git clang/test/CodeGenCXX/aarch64-mangle-neon-vectors.cpp clang/test/CodeGenCXX/aarch64-mangle-neon-vectors.cpp index 3b4a309327fe..9b855698f57f 100644 --- clang/test/CodeGenCXX/aarch64-mangle-neon-vectors.cpp +++ clang/test/CodeGenCXX/aarch64-mangle-neon-vectors.cpp @@ -11,6 +11,7 @@ typedef unsigned short poly16_t; typedef __fp16 float16_t; typedef float float32_t; typedef double float64_t; +typedef __mfp8 mfloat8_t; typedef __attribute__((neon_vector_type(8))) int8_t int8x8_t; typedef __attribute__((neon_vector_type(16))) int8_t int8x16_t; @@ -26,6 +27,8 @@ typedef __attribute__((neon_vector_type(8))) uint16_t uint16x8_t; typedef __attribute__((neon_vector_type(2))) unsigned int uint32x2_t; typedef __attribute__((neon_vector_type(4))) unsigned int uint32x4_t; typedef __attribute__((neon_vector_type(2))) uint64_t uint64x2_t; +typedef __attribute__((neon_vector_type(8))) mfloat8_t mfloat8x8_t; +typedef __attribute__((neon_vector_type(16))) mfloat8_t mfloat8x16_t; typedef __attribute__((neon_vector_type(4))) float16_t float16x4_t; typedef __attribute__((neon_vector_type(8))) float16_t float16x8_t; typedef __attribute__((neon_vector_type(2))) float32_t float32x2_t; @@ -82,3 +85,7 @@ void f21(int64x2_t) {} void f22(uint64x2_t) {} // CHECK: 13__Float64x2_t void f23(float64x2_t) {} +// CHECK: 13__Mfloat8x8_t +void f24(mfloat8x8_t) {} +// CHECK: 14__Mfloat8x16_t +void f25(mfloat8x16_t) {} diff --git clang/test/CodeGenCXX/bitfield-ir.cpp clang/test/CodeGenCXX/bitfield-ir.cpp index d91b089d0962..8fc4375a4f41 100644 --- clang/test/CodeGenCXX/bitfield-ir.cpp +++ clang/test/CodeGenCXX/bitfield-ir.cpp @@ -21,7 +21,7 @@ struct Int { // CHECK-LABEL: define dso_local void @_Z1AP4Tail -// CHECK-SAME: (ptr nocapture noundef [[P:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { +// CHECK-SAME: (ptr noundef captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { // CHECK-NEXT: entry: // CHECK-NEXT: [[BF_LOAD:%.*]] = load i16, ptr [[P]], align 4 // CHECK-NEXT: [[INC:%.*]] = add i16 [[BF_LOAD]], 1 @@ -33,7 +33,7 @@ void A (Tail *p) { } // CHECK-LABEL: define dso_local void @_Z1BP4Tail -// CHECK-SAME: (ptr nocapture noundef [[P:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-SAME: (ptr noundef captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR0]] { // CHECK-NEXT: entry: // CHECK-NEXT: [[B:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 2 // CHECK-NEXT: [[BF_LOAD:%.*]] = load i8, ptr [[B]], align 2 @@ -46,7 +46,7 @@ void B (Tail *p) { } // CHECK-LABEL: define dso_local void @_Z1AP4Char -// CHECK-SAME: (ptr nocapture noundef [[P:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-SAME: (ptr noundef captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR0]] { // CHECK-NEXT: entry: // CHECK-NEXT: [[BF_LOAD:%.*]] = load i16, ptr [[P]], align 4 // CHECK-NEXT: [[INC:%.*]] = add i16 [[BF_LOAD]], 1 @@ -58,7 +58,7 @@ void A (Char *p) { } // CHECK-LABEL: define dso_local void @_Z1BP4Char -// CHECK-SAME: (ptr nocapture noundef [[P:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-SAME: (ptr noundef captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR0]] { // CHECK-NEXT: entry: // CHECK-NEXT: [[B:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 2 // CHECK-NEXT: [[BF_LOAD:%.*]] = load i8, ptr [[B]], align 2 @@ -71,7 +71,7 @@ void B (Char *p) { } // CHECK-LABEL: define dso_local void @_Z1AP3Int -// CHECK-SAME: (ptr nocapture noundef [[P:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-SAME: (ptr noundef captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR0]] { // CHECK-NEXT: entry: // CHECK-NEXT: [[BF_LOAD:%.*]] = load i32, ptr [[P]], align 4 // CHECK-NEXT: [[INC:%.*]] = add i32 [[BF_LOAD]], 1 @@ -86,7 +86,7 @@ void A (Int *p) { } // CHECK-LABEL: define dso_local void @_Z1BP3Int -// CHECK-SAME: (ptr nocapture noundef [[P:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-SAME: (ptr noundef captures(none) [[P:%.*]]) local_unnamed_addr #[[ATTR0]] { // CHECK-NEXT: entry: // CHECK-NEXT: [[BF_LOAD:%.*]] = load i32, ptr [[P]], align 4 // CHECK-NEXT: [[BF_VALUE:%.*]] = add i32 [[BF_LOAD]], 65536 diff --git clang/test/CodeGenCXX/cxx2c-decomposition.cpp clang/test/CodeGenCXX/cxx2c-decomposition.cpp new file mode 100644 index 000000000000..27562524fd4b --- /dev/null +++ clang/test/CodeGenCXX/cxx2c-decomposition.cpp @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -std=c++26 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s + +namespace std { + using size_t = decltype(sizeof(0)); + template<typename> struct tuple_size; + template<size_t, typename> struct tuple_element; +} + +struct Y { int n; }; +struct X { X(); X(Y); X(const X&); ~X(); }; + +struct A { int a : 13; bool b; }; + +struct B {}; +template<> struct std::tuple_size<B> { enum { value = 2 }; }; +template<> struct std::tuple_element<0,B> { using type = X; }; +template<> struct std::tuple_element<1,B> { using type = const int&; }; +template<int N> auto get(B) { + if constexpr (N == 0) + return Y(); + else + return 0.0; +} + +using C = int[2]; + +template<typename T> T &make(); + +// CHECK-LABEL: define {{.*}} @_Z8big_testIiEiv() +template <typename T> +int big_test() { + A& a = make<A>(); +A: + auto &[...an] = a; + an...[0] = 5; + // CHECK: %[[a1:.*]].load = load i16, ptr %[[BITFIELD:.*]], + // CHECK: %[[a1]].clear = and i16 %[[a1]].load, -8192 + // CHECK: %[[a1]].set = or i16 %[[a1]].clear, 5 + // CHECK: store i16 %[[a1]].set, ptr %[[BITFIELD]], +B: + auto [b1, ...bn] = make<B>(); + // CHECK: @_Z4makeI1BERT_v() + // CHECK: call i32 @_Z3getILi0EEDa1B() + // CHECK: call void @_ZN1XC1E1Y(ptr {{[^,]*}} %[[b1:.*]], i32 + // + // CHECK: call noundef double @_Z3getILi1EEDa1B() + // CHECK: %[[cvt:.*]] = fptosi double %{{.*}} to i32 + // CHECK: store i32 %[[cvt]], ptr %[[b2:.*]], + // CHECK: store ptr %[[b2]], ptr %[[b2ref:.*]], + int bn2 = bn...[0]; + // CHECK load ptr, ptr %[[b2ref]] + + return 0; +} + +int g = big_test<int>(); diff --git clang/test/CodeGenCXX/debug-info-ms-novtable.cpp clang/test/CodeGenCXX/debug-info-ms-novtable.cpp new file mode 100644 index 000000000000..d8800608f8b8 --- /dev/null +++ clang/test/CodeGenCXX/debug-info-ms-novtable.cpp @@ -0,0 +1,16 @@ +// RUN: %clang -g -S -emit-llvm -fms-extensions -fms-compatibility -target x86_64-pc-windows-msvc -o - %s | FileCheck %s + +// CHECK-DAG: ![[FOO:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_class_type, name: "Foo", file: !{{[0-9]+}}, line: {{[0-9]+}}, size: 128, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: ![[FOO_ELEMENTS:[0-9]+]], vtableHolder: ![[FOO]], identifier: ".?AVFoo@@") +// CHECK-DAG: ![[FOO_ELEMENTS]] = !{![[FOO_VTBL_TY:[0-9]+]], ![[FOO_VTBL_MEMBER:[0-9]+]], ![[FOO_MEMBER:[0-9]+]], ![[FOO_DUMMY:[0-9]+]]} +// CHECK-DAG: ![[FOO_VTBL_TY]] = !DIDerivedType(tag: DW_TAG_pointer_type, name: "__vtbl_ptr_type", baseType: null, size: 64) +// CHECK-DAG: ![[FOO_VTBL_MEMBER]] = !DIDerivedType(tag: DW_TAG_member, name: "_vptr$Foo", scope: !10, file: !{{[0-9]+}}, baseType: ![[FOO_VTBL_PTR_TY:[0-9]+]], size: 64, flags: DIFlagArtificial) +// CHECK-DAG: ![[FOO_VTBL_PTR_TY]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[FOO_VTBL_TY]], size: 64) +// CHECK-DAG: ![[FOO_MEMBER]] = !DIDerivedType(tag: DW_TAG_member, name: "member", scope: ![[FOO]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 32, offset: 64) +// CHECK-DAG: ![[FOO_DUMMY]] = !DISubprogram(name: "dummy", linkageName: "?dummy@Foo@@EEAAXXZ", scope: ![[FOO]], file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, scopeLine: {{[0-9]+}}, containingType: ![[FOO]], virtualIndex: 0, flags: DIFlagPrototyped | DIFlagIntroducedVirtual, spFlags: DISPFlagVirtual) +class __declspec(novtable) Foo { + virtual void dummy() noexcept {}; + + int member = 1; +}; + +void foo(Foo) {} diff --git clang/test/CodeGenCXX/gh119046.cpp clang/test/CodeGenCXX/gh119046.cpp new file mode 100644 index 000000000000..cad76879f086 --- /dev/null +++ clang/test/CodeGenCXX/gh119046.cpp @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 -std=c++2a -triple x86_64-elf-gnu %s -emit-llvm -o - | FileCheck %s + +struct S { + consteval void operator()() {} +}; + +template <class Fn> +constexpr void dispatch(Fn fn) { + fn(); +} + +template <class Visitor> +struct value_visitor { + constexpr void operator()() { visitor(); } + Visitor&& visitor; +}; + +template <class Visitor> +constexpr auto make_dispatch() { + return dispatch<value_visitor<S>>; +} + +template <class Visitor> +constexpr void visit(Visitor&&) { + make_dispatch<Visitor>(); +} + +void f() { visit(S{}); } + +// CHECK: define {{.*}} @_Z1fv +// CHECK-NOT: define {{.*}} @_Z5visitI1SEvOT_ +// CHECK-NOT: define {{.*}} @_Z13make_dispatchI1SEDav diff --git clang/test/CodeGenCXX/inline-then-fold-variadics.cpp clang/test/CodeGenCXX/inline-then-fold-variadics.cpp index 855787731c8b..5f83545f7812 100644 --- clang/test/CodeGenCXX/inline-then-fold-variadics.cpp +++ clang/test/CodeGenCXX/inline-then-fold-variadics.cpp @@ -101,14 +101,14 @@ extern "C" { typedef uint64_t ulong2 __attribute__((__vector_size__(16), __aligned__(16))); // CHECK-LABEL: define {{[^@]+}}@first_i32_ulong2 -// CHECK-SAME: (i32 noundef returned [[X:%.*]], ptr nocapture noundef readonly [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-SAME: (i32 noundef returned [[X:%.*]], ptr noundef readonly captures(none) [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { // CHECK-NEXT: entry: // CHECK-NEXT: ret i32 [[X]] // int first_i32_ulong2(int x, ulong2 *y) { return first<int, ulong2>(x, *y); } // CHECK-LABEL: define {{[^@]+}}@second_i32_ulong2 -// CHECK-SAME: (i32 noundef [[X:%.*]], ptr nocapture noundef readonly [[Y:%.*]], ptr nocapture noundef writeonly initializes((0, 16)) [[R:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] { +// CHECK-SAME: (i32 noundef [[X:%.*]], ptr noundef readonly captures(none) [[Y:%.*]], ptr noundef writeonly captures(none) initializes((0, 16)) [[R:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] { // CHECK-NEXT: entry: // CHECK-NEXT: [[TMP0:%.*]] = load <2 x i64>, ptr [[Y]], align 16, !tbaa [[TBAA2:![0-9]+]] // CHECK-NEXT: store <2 x i64> [[TMP0]], ptr [[R]], align 16, !tbaa [[TBAA2]] @@ -119,7 +119,7 @@ void second_i32_ulong2(int x, ulong2 *y, ulong2 *r) { } // CHECK-LABEL: define {{[^@]+}}@first_ulong2_i32 -// CHECK-SAME: (ptr nocapture noundef readonly [[X:%.*]], i32 noundef [[Y:%.*]], ptr nocapture noundef writeonly initializes((0, 16)) [[R:%.*]]) local_unnamed_addr #[[ATTR1]] { +// CHECK-SAME: (ptr noundef readonly captures(none) [[X:%.*]], i32 noundef [[Y:%.*]], ptr noundef writeonly captures(none) initializes((0, 16)) [[R:%.*]]) local_unnamed_addr #[[ATTR1]] { // CHECK-NEXT: entry: // CHECK-NEXT: [[TMP0:%.*]] = load <2 x i64>, ptr [[X]], align 16, !tbaa [[TBAA2]] // CHECK-NEXT: store <2 x i64> [[TMP0]], ptr [[R]], align 16, !tbaa [[TBAA2]] @@ -130,7 +130,7 @@ void first_ulong2_i32(ulong2 *x, int y, ulong2 *r) { } // CHECK-LABEL: define {{[^@]+}}@second_ulong2_i32 -// CHECK-SAME: (ptr nocapture noundef readonly [[X:%.*]], i32 noundef returned [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-SAME: (ptr noundef readonly captures(none) [[X:%.*]], i32 noundef returned [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { // CHECK-NEXT: entry: // CHECK-NEXT: ret i32 [[Y]] // @@ -150,14 +150,14 @@ typedef struct { extern "C" { // CHECK-LABEL: define {{[^@]+}}@first_i32_asc -// CHECK-SAME: (i32 noundef returned [[X:%.*]], ptr nocapture noundef readonly [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-SAME: (i32 noundef returned [[X:%.*]], ptr noundef readonly captures(none) [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { // CHECK-NEXT: entry: // CHECK-NEXT: ret i32 [[X]] // int first_i32_asc(int x, asc *y) { return first<int, asc>(x, *y); } // CHECK-LABEL: define {{[^@]+}}@second_i32_asc -// CHECK-SAME: (i32 noundef [[X:%.*]], ptr nocapture noundef readonly [[Y:%.*]], ptr nocapture noundef writeonly initializes((0, 24)) [[R:%.*]]) local_unnamed_addr #[[ATTR1]] { +// CHECK-SAME: (i32 noundef [[X:%.*]], ptr noundef readonly captures(none) [[Y:%.*]], ptr noundef writeonly captures(none) initializes((0, 24)) [[R:%.*]]) local_unnamed_addr #[[ATTR1]] { // CHECK-NEXT: entry: // CHECK-NEXT: tail call void @llvm.memmove.p0.p0.i32(ptr noundef nonnull align 8 dereferenceable(24) [[R]], ptr noundef nonnull align 1 dereferenceable(24) [[Y]], i32 24, i1 false) // CHECK-NEXT: ret void @@ -165,7 +165,7 @@ int first_i32_asc(int x, asc *y) { return first<int, asc>(x, *y); } void second_i32_asc(int x, asc *y, asc *r) { *r = second<int, asc>(x, *y); } // CHECK-LABEL: define {{[^@]+}}@first_asc_i32 -// CHECK-SAME: (ptr nocapture noundef readonly [[X:%.*]], i32 noundef [[Y:%.*]], ptr nocapture noundef writeonly initializes((0, 24)) [[R:%.*]]) local_unnamed_addr #[[ATTR1]] { +// CHECK-SAME: (ptr noundef readonly captures(none) [[X:%.*]], i32 noundef [[Y:%.*]], ptr noundef writeonly captures(none) initializes((0, 24)) [[R:%.*]]) local_unnamed_addr #[[ATTR1]] { // CHECK-NEXT: entry: // CHECK-NEXT: tail call void @llvm.memmove.p0.p0.i32(ptr noundef nonnull align 8 dereferenceable(24) [[R]], ptr noundef nonnull align 1 dereferenceable(24) [[X]], i32 24, i1 false) // CHECK-NEXT: ret void @@ -173,7 +173,7 @@ void second_i32_asc(int x, asc *y, asc *r) { *r = second<int, asc>(x, *y); } void first_asc_i32(asc *x, int y, asc *r) { *r = first<asc, int>(*x, y); } // CHECK-LABEL: define {{[^@]+}}@second_asc_i32 -// CHECK-SAME: (ptr nocapture noundef readonly [[X:%.*]], i32 noundef returned [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { +// CHECK-SAME: (ptr noundef readonly captures(none) [[X:%.*]], i32 noundef returned [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { // CHECK-NEXT: entry: // CHECK-NEXT: ret i32 [[Y]] // diff --git clang/test/CodeGenCXX/mangle-neon-vectors.cpp clang/test/CodeGenCXX/mangle-neon-vectors.cpp index cb5e40be6a6d..2139a8ae98ca 100644 --- clang/test/CodeGenCXX/mangle-neon-vectors.cpp +++ clang/test/CodeGenCXX/mangle-neon-vectors.cpp @@ -9,6 +9,7 @@ typedef __fp16 float16_t; #if defined(__aarch64__) typedef unsigned char poly8_t; typedef unsigned short poly16_t; +typedef __mfp8 mfloat8_t; #else typedef signed char poly8_t; typedef short poly16_t; @@ -29,6 +30,8 @@ typedef __attribute__((neon_vector_type(4))) float16_t float16x4_t; typedef __attribute__((neon_vector_type(8))) float16_t float16x8_t; #ifdef __aarch64__ typedef __attribute__((neon_vector_type(2))) float64_t float64x2_t; +typedef __attribute__((neon_vector_type(8))) mfloat8_t mfloat8x8_t; +typedef __attribute__((neon_vector_type(16))) mfloat8_t mfloat8x16_t; #endif typedef __attribute__((neon_polyvector_type(16))) poly8_t poly8x16_t; typedef __attribute__((neon_polyvector_type(8))) poly16_t poly16x8_t; @@ -86,3 +89,11 @@ void f11(float64x2_t v) { } // CHECK-AARCH64-BF16: 14__Bfloat16x4_t void f12(bfloat16x4_t v) {} #endif + + +#ifdef __aarch64__ +// CHECK-AARCH64: 13__Mfloat8x8_t +void f13(mfloat8x8_t v) { } +// CHECK-AARCH64: 14__Mfloat8x16_t +void f14(mfloat8x16_t v) { } +#endif diff --git clang/test/CodeGenCXX/noescape.cpp clang/test/CodeGenCXX/noescape.cpp index e6d7a727ebb3..c3fc90e2ea54 100644 --- clang/test/CodeGenCXX/noescape.cpp +++ clang/test/CodeGenCXX/noescape.cpp @@ -8,26 +8,26 @@ struct S { virtual void vm1(int *, int * __attribute__((noescape))); }; -// CHECK: define{{.*}} void @_ZN1SC2EPiS0_(ptr {{.*}}, {{.*}}, {{.*}} nocapture noundef {{%.*}}) -// CHECK: define{{.*}} void @_ZN1SC1EPiS0_(ptr {{.*}}, {{.*}}, {{.*}} nocapture noundef {{%.*}}) {{.*}} { -// CHECK: call void @_ZN1SC2EPiS0_(ptr {{.*}}, {{.*}}, {{.*}} nocapture {{.*}}) +// CHECK: define{{.*}} void @_ZN1SC2EPiS0_(ptr {{.*}}, {{.*}}, {{.*}} noundef captures(none) {{%.*}}) +// CHECK: define{{.*}} void @_ZN1SC1EPiS0_(ptr {{.*}}, {{.*}}, {{.*}} noundef captures(none) {{%.*}}) {{.*}} { +// CHECK: call void @_ZN1SC2EPiS0_(ptr {{.*}}, {{.*}}, {{.*}} captures(none) {{.*}}) S::S(int *, int * __attribute__((noescape))) {} -// CHECK: define {{.*}} ptr @_ZN1SaSEPi(ptr {{.*}}, {{.*}} nocapture noundef {{%.*}}) +// CHECK: define {{.*}} ptr @_ZN1SaSEPi(ptr {{.*}}, {{.*}} noundef captures(none) {{%.*}}) S &S::operator=(int * __attribute__((noescape))) { return *this; } -// CHECK: define{{.*}} void @_ZN1S2m0EPiS0_(ptr {{.*}}, {{.*}} nocapture noundef {{%.*}}) +// CHECK: define{{.*}} void @_ZN1S2m0EPiS0_(ptr {{.*}}, {{.*}} noundef captures(none) {{%.*}}) void S::m0(int *, int * __attribute__((noescape))) {} -// CHECK: define{{.*}} void @_ZN1S3vm1EPiS0_(ptr {{.*}}, {{.*}} nocapture noundef {{%.*}}) +// CHECK: define{{.*}} void @_ZN1S3vm1EPiS0_(ptr {{.*}}, {{.*}} noundef captures(none) {{%.*}}) void S::vm1(int *, int * __attribute__((noescape))) {} // CHECK-LABEL: define{{.*}} void @_Z5test0P1SPiS1_( -// CHECK: call void @_ZN1SC1EPiS0_(ptr {{.*}}, {{.*}}, {{.*}} nocapture noundef {{.*}}) -// CHECK: call {{.*}} ptr @_ZN1SaSEPi(ptr {{.*}}, {{.*}} nocapture noundef {{.*}}) -// CHECK: call void @_ZN1S2m0EPiS0_(ptr {{.*}}, {{.*}}, {{.*}} nocapture noundef {{.*}}) -// CHECK: call void {{.*}}(ptr {{.*}}, {{.*}}, {{.*}} nocapture noundef {{.*}}) +// CHECK: call void @_ZN1SC1EPiS0_(ptr {{.*}}, {{.*}}, {{.*}} noundef captures(none) {{.*}}) +// CHECK: call {{.*}} ptr @_ZN1SaSEPi(ptr {{.*}}, {{.*}} noundef captures(none) {{.*}}) +// CHECK: call void @_ZN1S2m0EPiS0_(ptr {{.*}}, {{.*}}, {{.*}} noundef captures(none) {{.*}}) +// CHECK: call void {{.*}}(ptr {{.*}}, {{.*}}, {{.*}} noundef captures(none) {{.*}}) void test0(S *s, int *p0, int *p1) { S t(p0, p1); t = p1; @@ -39,27 +39,27 @@ namespace std { typedef decltype(sizeof(0)) size_t; } -// CHECK: define {{.*}} @_ZnwmPv({{.*}}, {{.*}} nocapture {{.*}}) +// CHECK: define {{.*}} @_ZnwmPv({{.*}}, {{.*}} captures(none) {{.*}}) void *operator new(std::size_t, void * __attribute__((noescape)) p) { return p; } // CHECK-LABEL: define{{.*}} ptr @_Z5test1Pv( -// CHECK: %call = call {{.*}} @_ZnwmPv({{.*}}, {{.*}} nocapture {{.*}}) +// CHECK: %call = call {{.*}} @_ZnwmPv({{.*}}, {{.*}} captures(none) {{.*}}) void *test1(void *p0) { return ::operator new(16, p0); } // CHECK-LABEL: define{{.*}} void @_Z5test2PiS_( -// CHECK: call void @"_ZZ5test2PiS_ENK3$_0clES_S_"({{.*}}, {{.*}}, {{.*}} nocapture {{.*}}) -// CHECK: define internal void @"_ZZ5test2PiS_ENK3$_0clES_S_"({{.*}}, {{.*}}, {{.*}} nocapture noundef {{%.*}}) +// CHECK: call void @"_ZZ5test2PiS_ENK3$_0clES_S_"({{.*}}, {{.*}}, {{.*}} captures(none) {{.*}}) +// CHECK: define internal void @"_ZZ5test2PiS_ENK3$_0clES_S_"({{.*}}, {{.*}}, {{.*}} noundef captures(none) {{%.*}}) void test2(int *p0, int *p1) { auto t = [](int *, int * __attribute__((noescape))){}; t(p0, p1); } // CHECK-LABEL: define{{.*}} void @_Z5test3PFvU8noescapePiES_( -// CHECK: call void {{.*}}(ptr nocapture noundef {{.*}}) +// CHECK: call void {{.*}}(ptr noundef captures(none) {{.*}}) typedef void (*NoEscapeFunc)(__attribute__((noescape)) int *); void test3(NoEscapeFunc f, int *p) { diff --git clang/test/CodeGenCXX/wasm-args-returns.cpp clang/test/CodeGenCXX/wasm-args-returns.cpp index b57896b0e0ff..fbb152ac1bb3 100644 --- clang/test/CodeGenCXX/wasm-args-returns.cpp +++ clang/test/CodeGenCXX/wasm-args-returns.cpp @@ -30,7 +30,7 @@ struct two_fields { double d, e; }; test(two_fields); -// CHECK: define void @_Z7forward10two_fields(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.two_fields) align 8 initializes((0, 16)) %{{.*}}, ptr nocapture readonly byval(%struct.two_fields) align 8 %{{.*}}) +// CHECK: define void @_Z7forward10two_fields(ptr dead_on_unwind noalias writable writeonly sret(%struct.two_fields) align 8 captures(none) initializes((0, 16)) %{{.*}}, ptr readonly byval(%struct.two_fields) align 8 captures(none) %{{.*}}) // // CHECK: define void @_Z15test_two_fieldsv() // CHECK: %[[tmp:.*]] = alloca %struct.two_fields, align 8 diff --git clang/test/CodeGenHLSL/builtins/WaveActiveMax.hlsl clang/test/CodeGenHLSL/builtins/WaveActiveMax.hlsl new file mode 100644 index 000000000000..7891cfc1989a --- /dev/null +++ clang/test/CodeGenHLSL/builtins/WaveActiveMax.hlsl @@ -0,0 +1,46 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -triple \ +// RUN: dxil-pc-shadermodel6.3-compute %s -emit-llvm -disable-llvm-passes -o - | \ +// RUN: FileCheck %s --check-prefixes=CHECK,CHECK-DXIL +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -triple \ +// RUN: spirv-pc-vulkan-compute %s -emit-llvm -disable-llvm-passes -o - | \ +// RUN: FileCheck %s --check-prefixes=CHECK,CHECK-SPIRV + +// Test basic lowering to runtime function call. + +// CHECK-LABEL: test_int +int test_int(int expr) { + // CHECK-SPIRV: %[[RET:.*]] = call spir_func [[TY:.*]] @llvm.spv.wave.reduce.max.i32([[TY]] %[[#]]) + // CHECK-DXIL: %[[RET:.*]] = call [[TY:.*]] @llvm.dx.wave.reduce.max.i32([[TY]] %[[#]]) + // CHECK: ret [[TY]] %[[RET]] + return WaveActiveMax(expr); +} + +// CHECK-DXIL: declare [[TY]] @llvm.dx.wave.reduce.max.i32([[TY]]) #[[#attr:]] +// CHECK-SPIRV: declare spir_func [[TY]] @llvm.spv.wave.reduce.max.i32([[TY]]) #[[#attr:]] + +// CHECK-LABEL: test_uint64_t +uint64_t test_uint64_t(uint64_t expr) { + // CHECK-SPIRV: %[[RET:.*]] = call spir_func [[TY:.*]] @llvm.spv.wave.reduce.umax.i64([[TY]] %[[#]]) + // CHECK-DXIL: %[[RET:.*]] = call [[TY:.*]] @llvm.dx.wave.reduce.umax.i64([[TY]] %[[#]]) + // CHECK: ret [[TY]] %[[RET]] + return WaveActiveMax(expr); +} + +// CHECK-DXIL: declare [[TY]] @llvm.dx.wave.reduce.umax.i64([[TY]]) #[[#attr:]] +// CHECK-SPIRV: declare spir_func [[TY]] @llvm.spv.wave.reduce.umax.i64([[TY]]) #[[#attr:]] + +// Test basic lowering to runtime function call with array and float value. + +// CHECK-LABEL: test_floatv4 +float4 test_floatv4(float4 expr) { + // CHECK-SPIRV: %[[RET1:.*]] = call reassoc nnan ninf nsz arcp afn spir_func [[TY1:.*]] @llvm.spv.wave.reduce.max.v4f32([[TY1]] %[[#]] + // CHECK-DXIL: %[[RET1:.*]] = call reassoc nnan ninf nsz arcp afn [[TY1:.*]] @llvm.dx.wave.reduce.max.v4f32([[TY1]] %[[#]]) + // CHECK: ret [[TY1]] %[[RET1]] + return WaveActiveMax(expr); +} + +// CHECK-DXIL: declare [[TY1]] @llvm.dx.wave.reduce.max.v4f32([[TY1]]) #[[#attr]] +// CHECK-SPIRV: declare spir_func [[TY1]] @llvm.spv.wave.reduce.max.v4f32([[TY1]]) #[[#attr]] + +// CHECK: attributes #[[#attr]] = {{{.*}} convergent {{.*}}} + diff --git clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl index 4045169d6516..36c73f875e94 100644 --- clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl +++ clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl @@ -6,7 +6,7 @@ // CHECK: %conv2 = fptrunc reassoc nnan ninf nsz arcp afn double %hlsl.dot to float // CHECK: ret float %conv2 float builtin_bool_to_float_type_promotion ( float p0, bool p1 ) { - return __builtin_hlsl_dot ( p0, p1 ); + return __builtin_hlsl_dot ( (double)p0, (double)p1 ); } // CHECK-LABEL: builtin_bool_to_float_arg1_type_promotion @@ -16,7 +16,7 @@ float builtin_bool_to_float_type_promotion ( float p0, bool p1 ) { // CHECK: %conv2 = fptrunc reassoc nnan ninf nsz arcp afn double %hlsl.dot to float // CHECK: ret float %conv2 float builtin_bool_to_float_arg1_type_promotion ( bool p0, float p1 ) { - return __builtin_hlsl_dot ( p0, p1 ); + return __builtin_hlsl_dot ( (double)p0, (double)p1 ); } // CHECK-LABEL: builtin_dot_int_to_float_promotion @@ -26,5 +26,5 @@ float builtin_bool_to_float_arg1_type_promotion ( bool p0, float p1 ) { // CHECK: %conv2 = fptrunc reassoc nnan ninf nsz arcp afn double %hlsl.dot to float // CHECK: ret float %conv2 float builtin_dot_int_to_float_promotion ( float p0, int p1 ) { - return __builtin_hlsl_dot ( p0, p1 ); + return __builtin_hlsl_dot ( (double)p0, (double)p1 ); } diff --git clang/test/CodeGenHLSL/implicit-norecurse-attrib.hlsl clang/test/CodeGenHLSL/implicit-norecurse-attrib.hlsl index ca0196067817..a8ab6ce98ae7 100644 --- clang/test/CodeGenHLSL/implicit-norecurse-attrib.hlsl +++ clang/test/CodeGenHLSL/implicit-norecurse-attrib.hlsl @@ -37,7 +37,7 @@ uint Find(Node SortedTree[MAX], uint key) { // Imagine the inout works export bool InitTree(/*inout*/ Node tree[MAX], RWBuffer<uint4> encodedTree, uint maxDepth) { - uint size = pow(2.f, maxDepth) - 1; + uint size = pow(2.f, (float)maxDepth) - 1; if (size > MAX) return false; for (uint i = 1; i < size; i++) { tree[i].value = encodedTree[i].x; diff --git clang/test/CodeGenHLSL/inline-functions.hlsl clang/test/CodeGenHLSL/inline-functions.hlsl index fa9c88db26df..e78d04ec9594 100644 --- clang/test/CodeGenHLSL/inline-functions.hlsl +++ clang/test/CodeGenHLSL/inline-functions.hlsl @@ -43,7 +43,7 @@ void BubbleSort(unsigned Buf[MAX], unsigned size) { // Note ExtAttr is the inlined export set of attribs // CHECK: Function Attrs: alwaysinline -// CHECK: define noundef i32 @_Z11RemoveDupesA100_jj(ptr {{[a-z_ ]*}}noundef byval([100 x i32]) align 4 %Buf, i32 noundef %size) {{[a-z_ ]*}}[[ExtAttr:\#[0-9]+]] +// CHECK: define noundef i32 @_Z11RemoveDupesA100_jj(ptr {{[a-z_ ]*}}noundef byval([100 x i32]) align 4 {{.*}}%Buf, i32 noundef %size) {{[a-z_ ]*}}[[ExtAttr:\#[0-9]+]] // CHECK: ret i32 // Sort Buf and remove any duplicate values // returns the number of values left diff --git clang/test/CodeGenObjC/noescape.m clang/test/CodeGenObjC/noescape.m index 395f110251f3..e1dbc0eb92e5 100644 --- clang/test/CodeGenObjC/noescape.m +++ clang/test/CodeGenObjC/noescape.m @@ -26,37 +26,37 @@ void noescapeFunc3(__attribute__((noescape)) union U); // CHECK: @[[BLOCK_DESCIPTOR_TMP_2:.*ls32l8"]] = linkonce_odr hidden unnamed_addr constant { i64, i64, ptr, i64 } { i64 0, i64 40, ptr @{{.*}}, i64 256 }, align 8 // CHECK-LABEL: define{{.*}} void @test0( -// CHECK: call void @noescapeFunc0({{.*}}, {{.*}} nocapture {{.*}}) -// CHECK: declare void @noescapeFunc0(ptr noundef, {{.*}} nocapture noundef) +// CHECK: call void @noescapeFunc0({{.*}}, {{.*}} captures(none) {{.*}}) +// CHECK: declare void @noescapeFunc0(ptr noundef, {{.*}} noundef captures(none)) void test0(BlockTy b) { noescapeFunc0(0, b); } // CHECK-LABEL: define{{.*}} void @test1( -// CHECK: call void @noescapeFunc1({{.*}} nocapture {{.*}}) -// CHECK: declare void @noescapeFunc1({{.*}} nocapture noundef) +// CHECK: call void @noescapeFunc1({{.*}} captures(none) {{.*}}) +// CHECK: declare void @noescapeFunc1({{.*}} noundef captures(none)) void test1(int *i) { noescapeFunc1(i); } // CHECK-LABEL: define{{.*}} void @test2( -// CHECK: call void @noescapeFunc2({{.*}} nocapture {{.*}}) -// CHECK: declare void @noescapeFunc2({{.*}} nocapture noundef) +// CHECK: call void @noescapeFunc2({{.*}} captures(none) {{.*}}) +// CHECK: declare void @noescapeFunc2({{.*}} noundef captures(none)) void test2(id i) { noescapeFunc2(i); } // CHECK-LABEL: define{{.*}} void @test3( -// CHECK: call void @noescapeFunc3({{.*}} nocapture {{.*}}) -// CHECK: declare void @noescapeFunc3({{.*}} nocapture) +// CHECK: call void @noescapeFunc3({{.*}} captures(none) {{.*}}) +// CHECK: declare void @noescapeFunc3({{.*}} captures(none)) void test3(union U u) { noescapeFunc3(u); } -// CHECK: define internal void @"\01-[C0 m0:]"({{.*}}, {{.*}}, {{.*}} nocapture {{.*}}) +// CHECK: define internal void @"\01-[C0 m0:]"({{.*}}, {{.*}}, {{.*}} captures(none) {{.*}}) // CHECK-LABEL: define{{.*}} void @test4( -// CHECK: call void @objc_msgSend(ptr {{.*}}, ptr {{.*}}, ptr nocapture {{.*}}) +// CHECK: call void @objc_msgSend(ptr {{.*}}, ptr {{.*}}, ptr noundef captures(none) {{.*}}) @interface C0 -(void) m0:(int*)__attribute__((noescape)) p0; @@ -72,9 +72,9 @@ void test4(C0 *c0, int *p) { } // CHECK-LABEL: define{{.*}} void @test5( -// CHECK: call void {{.*}}(ptr noundef @{{.*}}, ptr nocapture {{.*}}) -// CHECK: call void {{.*}}(ptr {{.*}}, ptr nocapture {{.*}}) -// CHECK: define internal void @{{.*}}(ptr {{.*}}, ptr nocapture {{.*}}) +// CHECK: call void {{.*}}(ptr noundef @{{.*}}, ptr noundef captures(none) {{.*}}) +// CHECK: call void {{.*}}(ptr {{.*}}, ptr noundef captures(none) {{.*}}) +// CHECK: define internal void @{{.*}}(ptr {{.*}}, ptr noundef captures(none) {{.*}}) typedef void (^BlockTy2)(__attribute__((noescape)) int *); diff --git clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl index 35a08a90d8cf..6776e2227847 100644 --- clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl +++ clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl @@ -307,7 +307,7 @@ void func_single_struct_element_struct_arg(single_struct_element_struct_arg_t ar // CHECK: void @func_different_size_type_pair_arg(i64 %arg1.coerce0, i32 %arg1.coerce1) void func_different_size_type_pair_arg(different_size_type_pair arg1) { } -// CHECK: void @func_flexible_array_arg(ptr addrspace(5) nocapture noundef readnone byval(%struct.flexible_array) align 4 %arg) +// CHECK: void @func_flexible_array_arg(ptr addrspace(5) noundef readnone byval(%struct.flexible_array) align 4 captures(none) %arg) void func_flexible_array_arg(flexible_array arg) { } // CHECK: define{{.*}} float @func_f32_ret() @@ -402,14 +402,14 @@ struct_arr16 func_ret_struct_arr16() return s; } -// CHECK: define{{.*}} void @func_ret_struct_arr32(ptr addrspace(5) dead_on_unwind noalias nocapture writable writeonly sret(%struct.struct_arr32) align 4 initializes((0, 128)) %agg.result) +// CHECK: define{{.*}} void @func_ret_struct_arr32(ptr addrspace(5) dead_on_unwind noalias writable writeonly sret(%struct.struct_arr32) align 4 captures(none) initializes((0, 128)) %agg.result) struct_arr32 func_ret_struct_arr32() { struct_arr32 s = { 0 }; return s; } -// CHECK: define{{.*}} void @func_ret_struct_arr33(ptr addrspace(5) dead_on_unwind noalias nocapture writable writeonly sret(%struct.struct_arr33) align 4 initializes((0, 132)) %agg.result) +// CHECK: define{{.*}} void @func_ret_struct_arr33(ptr addrspace(5) dead_on_unwind noalias writable writeonly sret(%struct.struct_arr33) align 4 captures(none) initializes((0, 132)) %agg.result) struct_arr33 func_ret_struct_arr33() { struct_arr33 s = { 0 }; @@ -438,7 +438,7 @@ different_size_type_pair func_different_size_type_pair_ret() return s; } -// CHECK: define{{.*}} void @func_flexible_array_ret(ptr addrspace(5) dead_on_unwind noalias nocapture writable writeonly sret(%struct.flexible_array) align 4 initializes((0, 4)) %agg.result) +// CHECK: define{{.*}} void @func_flexible_array_ret(ptr addrspace(5) dead_on_unwind noalias writable writeonly sret(%struct.flexible_array) align 4 captures(none) initializes((0, 4)) %agg.result) flexible_array func_flexible_array_ret() ########## TRUNCATED ###########