Commit Graph
1460 Commits
Author SHA1 Message Date
Stephan Bergmann 8fb5be18f8 Use OStringBuffer as a pad for the mutable string passed to mkstemp
...by introducing OStringBuffer::getMutableStr and (for consistency)
OUStringBuffer::getMutableStr

Change-Id: I4dfc3b8d8ffb49b8b3742600081d075536b312e5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197605
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
Tested-by: Jenkins
2026-01-20 07:33:22 +01:00
seyoufi22 b3fe1621d3 tdf#143148 Replace include guards with pragma once
Change-Id: I12f863c2248d57cac6c0a750b3eda157af7bb325
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194481
Tested-by: Jenkins
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
Code-Style: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
2025-11-25 17:30:21 +01:00
Michael Weghorn 1ccb2ecd4e linux_aarch64: Fix Android build with NDK 29
An Android build including autogen options

    --with-android-ndk=$HOME/Android/Sdk/ndk/29.0.14206865
    --with-distro=LibreOfficeAndroidAarch64

failed like this:

    .../bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx:604:29: error: cannot initialize a parameter of type 'char *' with an rvalue of type 'unsigned char *'
      604 |     __builtin___clear_cache(const_cast<unsigned char *>(begin), const_cast<unsigned char *>(end));
          |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.

Tweak the version check introduced in

    commit 28e542dc61
    Date:   Wed Apr 23 13:17:21 2025 +0200

        Avoid loplugin:redundantcast on macOS with recent LLVM 21 trunk

        ...including
        <https://github.com/llvm/llvm-project/commit/b6b025797245a5e5416b522df041252e3c4ff868>
        "Fix the signature for __builtin___clear_cache (#134376)", which now caused

        > bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx:601:9: error: redundant reinterpret_cast, result is implicitly cast to void pointer [loplugin:redundantcast]
        >   601 |         reinterpret_cast<char *>(const_cast<unsigned char *>(begin)),
        >       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        > bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx:602:9: error: redundant reinterpret_cast, result is implicitly cast to void pointer [loplugin:redundantcast]
        >   602 |         reinterpret_cast<char *>(const_cast<unsigned char *>(end)));
        >       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

to not expect the new signature for Android NDK <= 29,
for which __clang_major__ is 21, but which doesn't have the
relevant commit mentioned in the commit message quoted above.

The NDK 29 release notes mention [1]:

> Updated LLVM to clang-r563880c. See clang_source_info.md in the toolchain
> directory for version information.

~/Android/Sdk/ndk/29.0.14206865/toolchains/llvm/prebuilt/linux-x86_64/clang_source_info.md
contains this:

> Base revision: [386af4a5c64ab75eaee2448dc38f2e34a40bfed0](https://github.com/llvm/llvm-project/commits/386af4a5c64ab75eaee2448dc38f2e34a40bfed0)

That referenced llvm-projects commit
386af4a5c64ab75eaee2448dc38f2e34a40bfed0 is indeed before
the b6b025797245a5e5416b522df041252e3c4ff868 one mentioned
above.

[1] https://github.com/android/ndk/wiki/Changelog-r29

Change-Id: I88419d0d8d47563d6d0d236dc17806979e56c831
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192378
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2025-10-14 17:42:20 +02:00
Jason Whitmore 2ec289a70b tdf#158237 replace find() and end() with contains()
This change updates code to use C++20 features.

Change-Id: Ib9edbd83faf464a0d866fb57276050e72ff0d023
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190310
Tested-by: Jenkins
Reviewed-by: Hossein   <hossein@libreoffice.org>
2025-09-09 15:55:25 +02:00
Caolán McNamara d3fcc9a5b6 drop apparently no longer needed coverity markup
Change-Id: Ia8b3b271bb5cc67131b50d563bed58400da5b317
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189662
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
2025-08-15 11:25:12 +02:00
Caolán McNamara 4cd24c130c cid#1660150 silence Use after free
and

cid#1659619 Use after free

Change-Id: If8e25a72475085c5e0d1e7d9b86b5eeff9a2eee6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188782
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2025-08-01 22:16:05 +02:00
Christian Lohmaier ef4948bde2 linux_aarch64: loplugin:cstylecast in bridges
/home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_clang_dbgutil_64/bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx:588:10: error: C-style cast from incomplete 'void *' to 'void (*)(const unsigned char *, const unsigned char *)' (BitCast) [loplugin:cstylecast]
       = (void (*)(unsigned char const *, unsigned char const *)) dlsym(
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

fix that by using reinterpret_cast instead (and also fix the indent of
the lines)

Change-Id: I06ee2b2ca350790e2f97435cd70e58acd7c2cf84
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186334
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Tested-by: Jenkins
2025-06-11 12:15:58 +02:00
Stephan Bergmann 28e542dc61 Avoid loplugin:redundantcast on macOS with recent LLVM 21 trunk
...including
<https://github.com/llvm/llvm-project/commit/b6b025797245a5e5416b522df041252e3c4ff868>
"Fix the signature for __builtin___clear_cache (#134376)", which now caused

> bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx:601:9: error: redundant reinterpret_cast, result is implicitly cast to void pointer [loplugin:redundantcast]
>   601 |         reinterpret_cast<char *>(const_cast<unsigned char *>(begin)),
>       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx:602:9: error: redundant reinterpret_cast, result is implicitly cast to void pointer [loplugin:redundantcast]
>   602 |         reinterpret_cast<char *>(const_cast<unsigned char *>(end)));
>       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Change-Id: I38e230af517a71016a7afaea4b72ffc91b00ef3d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184499
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2025-04-23 15:22:09 +02:00
Emmanuel Dreyfus 9fb26786b7 tdf#165837 Avoid UNO failure if filesystem does not implement fallocate.
posix_fallocate() may be available but unimplemented for a
given filesystem. Detect that situation once and use ftruncate()
instead.

Change-Id: Ic1422bfbcbcda21ef4923a6fc30ceb5ce662db3e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183977
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Tested-by: Jenkins
2025-04-16 16:39:44 +02:00
Akshay Kumar Dubey 3e706aa31d tdf#145614 Convert #define to constexpr
Change-Id: I0bdbb662b807c6ffc9030c4c695e5022949e172f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180254
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2025-01-21 08:56:00 +01:00
Mike Kaganski 1180b3473a com::sun::star -> css
Change-Id: I890ec73e30d3cc6b210903ecee29431f3cb5f635
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175979
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-11-10 10:50:15 +01:00
Mike Kaganski ad686b26ce No need to use SAL_THROW_EXTERN_C macro in CXX
Change-Id: I6eb9f0431a9402479a2d90d5b6f68b611d52a9f9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175957
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-11-02 22:16:06 +01:00
Caolán McNamara d3959ecab9 cid#1606987 silence Overflowed integer argument
Change-Id: I77380d12a5d51c3debb1365a5fc9b57c33299eb8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173523
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-09-17 15:16:22 +02:00
Stephan Bergmann f610a602c9 tdf#160945: queryInterface must pass back indirect return value address in x0
Change-Id: I28dacffbbcdf26ee453fd32aeb82166484612846
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172791
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-09-03 14:21:55 +02:00
Rene Engelhard d9e818f3d7 fix build on armhf with gcc 14
/uno2cpp.cxx: In function ‘void {anonymous}::callVirtualMethod(void*, sal_Int32, void*, typelib_TypeDescriptionReference*, sal_uInt32*, sal_uInt32, sal_uInt32*, sal_uInt32, double*)’:
/<<PKGBUILDDIR>>/bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx:278:5: error: ‘asm’ operand has impossible constraints or there are not enough registers
  278 |     __asm__ __volatile__ (
      |     ^~~~~~~
make[2]: *** [/<<PKGBUILDDIR>>/solenv/gbuild/LinkTarget.mk:338: /<<PKGBUILDDIR>>/workdir/CxxObject/bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.o] Error 1

Just removing them makes it work, they are mentioned before anyway, too
(thanks Caolan)

Change-Id: Ibb9118b268a587ebdcfce343e2ee2605ac979915
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171650
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-08-08 20:35:30 +02:00
Stephan Bergmann 74829f2a64 Fully implement the Wasm UNO bridge cpp2uno direction
...after 875997c896 "Properly implement
cppu::throwException for Emscripten" had implemented only those parts that were
absolutely necessary for that exception throwing.  As detailed in the commit
message there, wasmcallgen has been extended to additionally generate all the
required vtable slot call trampoline code (which cannot be generated on the fly
for Wasm, as would be done for other platforms).  Consequently, some of the
"callvirtualfunction"-centric file names have been changed to "generated" as the
output of wasmcallgen is now more general.  (And wasmcallgen itself should also
be renamed, in a follow-up commit.  And when adding to the wasmcallgen code
here, some existing parts of its implementation have been cleaned up, too.)

There is no direct way to test this half of the Wasm UNO bridge directly from
unotest/source/embindtest/embindtest.js, so a new
org.libreoffice.embindtest.BridgeTest singleton has been added, which triggers
new test code in unotest/source/embindtest/embindtest.cxx that tests the bridge
in a way similar to testtools' bridgetest machinery.

Change-Id: I521a1d6c2160aedc814f7603b0b99861e5fbd1eb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170374
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-07-11 17:16:17 +02:00
Stephan Bergmann 0c2e0ea495 Consolidate common code
Change-Id: Ic24163970fd5b97c2426f0786d9b7d97a1796f87
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170309
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Tested-by: Jenkins
2024-07-10 17:39:24 +02:00
Stephan Bergmann 875997c896 Properly implement cppu::throwException for Emscripten
...by implementing (for now) just enough of the cpp2uno half of the Wasm UNO
bridge to make it work.  In general, that half suffers from the same issue as
the already-implemented uno2cpp half, namely that Wasm doesn't allow to generate
code on the fly (which, in this case, would be needed to implement the vtable
slot trampoline functions).  So, for now just hard-code the few
vtableSlotFunction_* that are needed by the UNO interfaces for
cppuhelper/source/exc_thrower.cxx.  (A proper fix would probably use the same
approach as for the uno2cpp half, and use something like wasmcallgen to generate
at least all the vtableSlotFunction_* needed for udkapi/offapi upfront.)

The RTTI for the exceptions needs to be unique across the executable for
exception catching to actually work (as it compares exception types by RTTI
address rather than by name).  We thus need to export all the relevant RTTI
symbols (which I hacked into the existing wasmcallgen for now, even if that
makes that executable's name a slight misnomer now), and access them with a new
jsGetExportedSymbol.  (This exporting would also be needed by the "classical"
approach of using dlsym on the main module, cf.
<https://gerrit.libreoffice.org/c/core/+/167187> "WIP: Emscripten: Set up
support for dlsym from main module".  And while that dlsym approach would work,
it is much simpler to just use that jsGetExportedSymbol than to use a dlsym
detour, and thereby avoid all the hassle of -sMAIN_MODULE detailed in the commit
message of that Gerrit change.)

It also turned out that including Emscripten's <cxxabi.h> needs
__USING_WASM_EXCEPTIONS__ to be defined, because it uses that in its declaration
of __cxa_throw.  (The source for setting that define internally in Emscripten is
get_cflags in the emsdk's upstream/emscripten/tools/system_libs.py, which
defines __USING_EMSCRIPTEN_EXCEPTIONS__ for the non-Wasm, Emscripten JS
exception mode, and defines __USING_WASM_EXCEPTIONS__ for
--enable-wasm-exceptions, which we use.  The commit message of
f4ec967599 "Fix redefinion of Emscripten
__cxxabiv1::__cxa_exception" documents my prior confusion of when one or the
other would be defined.)

Change-Id: Id08765ab5b4ce1553dc3a61648324526185cb64c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170246
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-07-10 12:32:15 +02:00
Stephan Bergmann eedbe966bb Embind: Fix C++ UNO exception catching
...with a new Module.catchUnoException JS function that can be used in a JS
catch block to provide the thrown UNO exception as an Any.  (For a non-C++
exception, it rethrows the exception, and for a non-UNO C++ exception it maps it
to css.uno.RuntimeException.)

The implementation reuses parts of bridges/source/cpp_uno/gcc3_wasm/, which have
been moved to a new StaticLibrary_emscriptencxxabi.

Change-Id: I708fe6121c43a1b9736de5dff449f6c4f32a45f3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169325
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-06-21 11:29:59 +02:00
Stephan Bergmann d9d63ba765 Don't expect _LIBCXXABI_DTOR_FUNC to be available
...as apparently happens to be the case with some older emsdk versions, see
<https://ci.libreoffice.org//job/lo_daily_tb_linux_wasm/743/> choking on that

Change-Id: Ie2f4b9684c794fdd51142eb81d96dd3332911272
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169319
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-06-21 09:51:16 +02:00
Stephan Bergmann f4ec967599 Fix redefinion of Emscripten __cxxabiv1::__cxa_exception
<https://github.com/emscripten-core/emscripten/>
system/lib/libcxxabi/src/cxa_exception.h has two different definitions of that
struct, a short one for when __USING_EMSCRIPTEN_EXCEPTIONS__ is defined, and a
long one for the other case.  In 7175431a4b
"Implement exception catching", I had naively copied the short version, assuming
that __USING_EMSCRIPTEN_EXCEPTIONS__ was something that sounded like it would be
defined with --enable-wasm-exceptions.  But some debugging of actual exception
handling now showed that the assumption had apparently been wrong (though I
still have no idea about the semantics of that __USING_EMSCRIPTEN_EXCEPTIONS__
define, and when it would or would not be defined), and that I had copied the
wrong version.

The relevant test code

>         try {
>             const ret = invoke.invoke('throwRuntimeException', params, outparamindex, outparam);
>             console.assert(false);
>             ret.delete();
>         } catch (e) {
>             const [type, message] = getExceptionMessage(e);
>             console.assert(type === 'com::sun::star::reflection::InvocationTargetException');
>             console.assert(message === undefined); //TODO
>             //TODO: inspect wrapped css.uno.RuntimeException
>             decrementExceptionRefcount(e);
>         }

in unotest/source/embindtest/embindtest.js had apparently happened to not cause a
crash with the wrong version of __cxxabiv1::__cxa_exception, but had also
happened to not detect the mistake due to the relevant parts being commented out
with TODO (because, in turn, proper UNO exception catching is still lacking in
our Embind-based JS binding).

Change-Id: I718087c7ed2c17808696267ece17237d5cdf2f54
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169305
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-06-20 21:49:23 +02:00
Andrea Gelmini a9b462758b Fix typo
Change-Id: I4750989bffaa95c652fe5f90962342638296b026
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169156
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2024-06-19 08:43:24 +02:00
Andrea Gelmini 637072a9b6 Fix typo
Change-Id: Ia7e36299a15fd4096f2e8e50efad2e8e1b61bec9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169166
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2024-06-19 08:37:10 +02:00
Andrea Gelmini e07e5e76f4 Fix typo
Change-Id: I392dc943c4a423ca6bd7c3a3efd2a68adb75bf1c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169176
Tested-by: Julien Nabet <serval2412@yahoo.fr>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2024-06-19 08:29:26 +02:00
Stephan Bergmann faa421fbbe Clean up using directives
Change-Id: Iaf343b3dabec951e1fd2d998a11fca8f593afdb7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168260
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-05-31 08:00:24 +02:00
Stephan Bergmann e303b3bba8 Implement attribute handling
Change-Id: Ic30d2de582f952555ec672984da78a07a9319443
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168224
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Tested-by: Jenkins
2024-05-30 09:35:06 +02:00
Stephan Bergmann 981542c1d2 Clean up gcc3_wasm bridge_noopt_objects
There appears to be no good reason that cpp2uno.cxx and uno2cpp.cxx are noopt
(presumably that was just cargo-culted from another platform?), and except.cxx
appears to be completely unused anyway.

Change-Id: Ic5f4142308a56b798dad61e9ec589046cad2ae13
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168182
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Tested-by: Jenkins
2024-05-29 12:59:29 +02:00
Stephan Bergmann 7175431a4b Implement exception catching
(Without 22ce8ed05b "Emscripten: Unconditional
--enable-wasm-exceptions", this would have failed to link due to missing
__cxa_current_exception_type and __cxa_get_globals.)

Change-Id: If89a3c62e4d2ac24d68f867b2fd7a4cd813d5a39
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168176
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-05-29 10:35:01 +02:00
Caolán McNamara 124252aa0b WaE: C6011 Dereferencing NULL pointer warnings
Change-Id: Iab647d1f98bb532bc0a2c42971e747708e52a875
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167495
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-05-11 11:09:49 +02:00
Stephan Bergmann 3956472eb2 Fix missing UNO<->C++ argument/return value conversions
Change-Id: I5ac6013d6c0bd72fe840a592628fd0d5b265b8ab
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167391
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Tested-by: Jenkins
2024-05-09 21:04:51 +02:00
Stephan Bergmann e49fd672b1 Fix typelib_TypeDescriptionReference -> typelib_TypeDescription conversion
Change-Id: Idfe74f1523ec866ed9926d3385a1605ad8a5547e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167352
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-05-09 14:00:33 +02:00
Stephan Bergmann 4fc4e24fb0 Move call code out into a function of its own
...so that it can be reused in the future for attribute getters/setters

Change-Id: I3dde796eb0c2f3812b7aee1a2c000bad31b33158
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167345
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-05-08 14:37:24 +02:00
Stephan Bergmann a469aea9c0 Emscripten: Towards a working C++ UNO bridge
...by making the general UNO -> C++ function call case work (modulo handling
exceptions, which I'll look into later).

Wasm call_indirect unfortunately needs to statically know the call target's
signature, so we statically need to know all possible signatures.  So introduce
wasmcallgen helper to scan the existing UNOIDL API upfront and generate the
relevant callvirtualfunction-wrapper.cxx and callvirtualfunction-inst.s code.
(The good thing is that the number of different signatures is somewhat limited,
each parameter can only be one of i32, i64, f32, or f64.  So even if 3rd-party
extensions bring along new UNOIDL interface methods, chances are relatively high
that the signatures needed for them would already be covered by the existing
ones.)

Testing this can nicely be done in unotest/source/embindtest/embindtest.js via
css.script.Invocation (which internally exercises the relevant code).  (Instead
of adding individual org.libreoffice.embindtest.StructLong/String etc., it would
be nicer to introduce some polymorphic StructOne<T>, but the Emind UNO binding
does not support polymorphic structs, so the embindtest.js code would not work.)

Change-Id: If829c9e3772bfd27561f3ad743d38a71d11545b6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167308
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Tested-by: Jenkins
2024-05-08 13:01:04 +02:00
Noel Grandin 171f984c90 loplugin:ostr in bridges
Change-Id: I6e0b9006924f058aceb2b0a4639f6987cec314a4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167204
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2024-05-06 19:23:41 +02:00
Caolán McNamara a2623abe07 WaE: C6011 Dereferencing NULL pointer warnings
Change-Id: I498c10e8bc134b41e3606d8a05cf3103a9274735
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166937
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-04-30 22:04:11 +02:00
Stephan Bergmann 1b9482e1d2 Drop unused RETURN_KIND_HFA_FLOAT/DOUBLE from msvc_win32_arm64 UNO bridge
Change-Id: I8c6fbed8c587affda69285c203a3a93fa2e2e603
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166699
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-04-26 14:01:54 +02:00
Stephan Bergmann 7414fc8418 Adapt queryInterface in fixed msvc_win32_arm64 UNO bridge
...where the function's argument is in x2, not x1 (see commit message of
ae6ee262d7 "Some fixing of msvc_win32_arm64 UNO
bridge" for details)

Change-Id: I00ef5df1ebad4609918c0c6845ebdcfe810f6152
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166622
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-04-25 18:27:24 +02:00
Stephan Bergmann 6fd06e0215 Add back the callVirtualFunction_fake boilerplate
...that ae6ee262d7 "Some fixing of
msvc_win32_arm64 UNO bridge" had removed, assuming it wasn't actually necessary.
But looks like Windows exception handling stack unwinding somehow needs it after
all.  Getting past the CustomTarget_testtools/uno_test getRaiseAttr1() call now
(but still failing at some later place).

Change-Id: I1e84345f2f355ab1e480c779da6b221b744132b3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166616
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Tested-by: Jenkins
2024-04-25 14:44:27 +02:00
Stephan Bergmann ae6ee262d7 Some fixing of msvc_win32_arm64 UNO bridge
For one, the Windows ABI deviates from the generic aarch64 ABI regarding
returning class instances by value from non-static member functions, see
<https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#return-values>:
"The caller shall reserve a block of memory of sufficient size and alignment to
hold the result.  The address of the memory block shall be passed as an
additional argument to the function in x0, or x1 if $this is passed in x0.  The
callee may modify the result memory block at any point during the execution of
the subroutine.  The callee returns the address of the memory block in x0."
That means RETURN_KIND_HFA_FLOAT and RETURN_KIND_HFA_DOUBLE are not needed, and
can be cleaned up in a follow-up commit.

And for another, setting up a call stack frame in call() in uno2cpp.cxx for
callVirtualFunction() didn't actually work, so go with a slightly less ambitious
aproach (as also used by the gcc_linux_aarch64 bridge) and explicitly copy the
arguments that end up on the stack around in callVirtualFunction().

This allows CustomTarget_testtools/uno_test to proceed at least as far as the
call of getRaiseAttr1(), which still leads to an uncaught
css::uno::RuntimeException.

Change-Id: I4a8ec09c270864ac4de246d7e8d1f923198236b1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166585
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-04-24 19:03:19 +02:00
Sakura286 de0a269a6e riscv64 bridge: replace some preprocessor directives to macros for debugging
Change-Id: Ic53d4a462e12e8448b14e750c4ef2824385b8f28
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165502
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-04-02 14:16:01 +02:00
Sakura286 4becdfe1ef riscv64 bridge: replace tab to space in call.s
Change-Id: I357f400050444336e26e73e1099b4b8ab9e8bdd1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165454
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Tested-by: Jenkins
2024-03-28 21:06:21 +01:00
Sakura286 18d989fe1e riscv64 bridge: switch CRLF to LF in abi.cxx/hxx
Change-Id: I810f2681f61336eb823ab1eed89389d18b95dc75
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165452
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-03-28 20:50:51 +01:00
Stephan Bergmann be2f27b011 Make msvc_raiseException explicitly [[noreturn]]
The comments at
<https://gerrit.libreoffice.org/c/core/+/165113/1#message-a76a16ede60a817426763c1c2c2090f23ae141e0>
"framework: MenuBarManager: fix WNT crash if queryDispatch() throws" suggest
that it was observed returning normally, and running into the

>         // is here for dummy
>         return typelib_TypeClass_VOID;

in cpp2uno_call.

Change-Id: I792a9eb82ef9e737aa69dc651b9a072871c0756b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165152
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-03-22 09:57:19 +01:00
Caolán McNamara 4b0c46dc61 ofz#66731 Crash in com::sun::star::uno::BaseReference::iquery
since

commit f93ae0455c
Date:   Sat Feb 3 18:03:45 2024 +0100

    Check bridges with IWYU

presumably not using the _LIBCPPABI_VERSION branch

move the _GLIBCXX_CDTOR_CALLABI fallback define to where
its used while I'm at it, that too seems to be from cxxabi.h

Change-Id: I2ead7207e3bcf24d3b120d22ae7f80e8f0a3216a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163672
Tested-by: Jenkins
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-02-21 12:26:18 +01:00
Stephan Bergmann b3fa6e6e65 Fix missing includes
...after f93ae0455c "Check bridges with IWYU"

Change-Id: I01ca7b015cb9f4fc1dbff099c52e8240e1517270
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163126
Tested-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
2024-02-09 01:36:54 +01:00
Gabor Kelemen f93ae0455c Check bridges with IWYU
Only the parts tha build on x64 arch

See tdf#42949 for motivation

Change-Id: Ifa3c5107887f5ab7837beee83d9603e8c883a7a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162961
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
2024-02-08 15:19:14 +01:00
Caolán McNamara f921a66d31 ofz: MemorySanitizer: extend use-of-uninitialized-value bridge workaround
Change-Id: I84f458b540e2e43cb3b4a06f4353e37ee2b7da2f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162646
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-01-28 15:49:45 +01:00
Sakura286 e49653f440 (riscv64) Fix Java bridgetest failure
* Refactor the code related to struct processing. Fix Java bridge-
  test failure. Fixed test list:
  * bridgetest-javaserver
  * [CUT] smoketest
  * [JUT] forms_unoapi_1
  * [JUT] forms_unoapi_2
  * [JUT] forms_unoapi_3
  * [JUT] forms_unoapi_4
* Clean higher bit to prevent compiler generate wrong code when
  pyuno calls functions through UNO environment. This fixes some
  weired uitest failure.
* Reorder the datatype list. Optimize the inserting args section in
  uno2cpp.cxx.
* Remove some unused code.

Change-Id: I74330126d31d847485b1d81fc34376b1d020f886
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160970
Tested-by: Jenkins
Tested-by: René Engelhard <rene@debian.org>
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-01-26 08:10:52 +01:00
Caolán McNamara 96bf7a9ace ofz: MemorySanitizer: use-of-uninitialized-value
WARNING: MemorySanitizer: use-of-uninitialized-value
	    #0 0x2e4597d in TreatDoubleError /src/libreoffice/sc/source/core/inc/interpre.hxx:1146:10
	    #1 0x2e4597d in ScInterpreter::PushDouble(double) /src/libreoffice/sc/source/core/tool/interpr4.cxx:1806:5
	    #2 0x2e83755 in ScInterpreter::ScExternal() /src/libreoffice/sc/source/core/tool/interpr4.cxx:3126:17
	    #3 0x2e94a38 in ScInterpreter::Interpret() /src/libreoffice/sc/source/core/tool/interpr4.cxx:4487:43
	    #4 0x27296ad in ScFormulaCell::InterpretTail(ScInterpreterContext&, ScFormulaCell::ScInterpretTailParameter) /src/libreoffice/sc/source/core/data/formulacell.cxx:1946:23
	    #5 0x2722f87 in ScFormulaCell::Interpret(int, int) /src/libreoffice/sc/source/core/data/formulacell.cxx:1619:13
	    #6 0x1e1c80f in operator() /src/libreoffice/sc/source/core/data/column.cxx:2808:16
	    #7 0x1e1c80f in EachElem<mdds::mtv::noncopyable_managed_element_block<54, ScFormulaCell, mdds::mtv::delayed_delete_vector>, std::__1::__wrap_iter<ScFormulaCell **>, mdds::detail::mtv::iterator_value_node<mdds::mtv::soa::multi_type_vector<sc::CellStoreTraits>, unsigned long>, (anonymous namespace)::CalcAllHandler> /src/libreoffice/sc/inc/mtvfunctions.hxx:130:9
	    #8 0x1e1c80f in ProcessElements1<mdds::mtv::soa::multi_type_vector<sc::CellStoreTraits>, mdds::mtv::noncopyable_managed_element_block<54, ScFormulaCell, mdds::mtv::delayed_delete_vector>, (anonymous namespace)::CalcAllHandler, sc::FuncElseNoOp<unsigned long, bool> > /src/libreoffice/sc/inc/mtvfunctions.hxx:330:9

Uninitialized value was stored to memory at
	    #0 0x2fdee53 in operator>>=<double> /src/libreoffice/sc/source/core/tool/rangeseq.cxx:0:14
	    #1 0x2fdee53 in ScApiTypeConversion::ConvertAnyToDouble(double&, com::sun::star::uno::TypeClass&, com::sun::star::uno::Any const&) /src/libreoffice/sc/source/core/tool/rangeseq.cxx:347:18
	    #2 0x2b1e9d4 in ScUnoAddInCall::SetResult(com::sun::star::uno::Any const&) /src/libreoffice/sc/source/core/tool/addincol.cxx:1583:17
	    #3 0x2b1d84f in ScUnoAddInCall::ExecuteCallWithArgs(com::sun::star::uno::Sequence<com::sun::star::uno::Any>&) /src/libreoffice/sc/source/core/tool/addincol.cxx:1541:9
	    #4 0x2b1c2ee in ScUnoAddInCall::ExecuteCall() /src/libreoffice/sc/source/core/tool/addincol.cxx:1495:9
	    #5 0x2e81a4b in ScInterpreter::ScExternal() /src/libreoffice/sc/source/core/tool/interpr4.cxx:3065:19
	    #6 0x2e94a38 in ScInterpreter::Interpret() /src/libreoffice/sc/source/core/tool/interpr4.cxx:4487:43

Uninitialized value was stored to memory at
	    #0 0x2b1daec in swap<void *> /usr/local/include/c++/v1/__utility/swap.h:37:7
	    #1 0x2b1daec in operator= /src/libreoffice/include/com/sun/star/uno/Any.hxx:153:5
	    #2 0x2b1daec in ScUnoAddInCall::ExecuteCallWithArgs(com::sun::star::uno::Sequence<com::sun::star::uno::Any>&) /src/libreoffice/sc/source/core/tool/addincol.cxx:1518:14
	    #3 0x2b1c2ee in ScUnoAddInCall::ExecuteCall() /src/libreoffice/sc/source/core/tool/addincol.cxx:1495:9
	    #4 0x2e81a4b in ScInterpreter::ScExternal() /src/libreoffice/sc/source/core/tool/interpr4.cxx:3065:19
	    #5 0x2e94a38 in ScInterpreter::Interpret() /src/libreoffice/sc/source/core/tool/interpr4.cxx:4487:43

Uninitialized value was stored to memory at
	    #0 0xc49bb64 in cppu::_copyConstructAnyFromData(_uno_Any*, void*, _typelib_TypeDescriptionReference*, _typelib_TypeDescription*, void (*)(void*), _uno_Mapping*) /src/libreoffice/cppu/source/uno/copy.hxx:178:49
	    #1 0xc497abd in cppu::_copyConstructAny(_uno_Any*, void*, _typelib_TypeDescriptionReference*, _typelib_TypeDescription*, void (*)(void*), _uno_Mapping*) /src/libreoffice/cppu/source/uno/copy.hxx:288:13
	    #2 0xc499443 in uno_any_constructAndConvert /src/libreoffice/cppu/source/uno/any.cxx:120:9
	    #3 0x174d263f in stoc_corefl::(anonymous namespace)::IdlInterfaceMethodImpl::invoke(com::sun::star::uno::Any const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any>&) /src/libreoffice/stoc/source/corereflection/criface.cxx:633:13
	    #4 0x174d5935 in non-virtual thunk to stoc_corefl::(anonymous namespace)::IdlInterfaceMethodImpl::invoke(com::sun::star::uno::Any const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any>&) /src/libreoffice/stoc/source/corereflection/criface.cxx:0
	    #5 0x2b1d5ce in ScUnoAddInCall::ExecuteCallWithArgs(com::sun::star::uno::Sequence<com::sun::star::uno::Any>&) /src/libreoffice/sc/source/core/tool/addincol.cxx:1518:27
	    #6 0x2b1c2ee in ScUnoAddInCall::ExecuteCall() /src/libreoffice/sc/source/core/tool/addincol.cxx:1495:9
	    #7 0x2e81a4b in ScInterpreter::ScExternal() /src/libreoffice/sc/source/core/tool/interpr4.cxx:3065:19
	    #8 0x2e94a38 in ScInterpreter::Interpret() /src/libreoffice/sc/source/core/tool/interpr4.cxx:4487:43

Uninitialized value was stored to memory at
	    #0 0xcd10714 in gcc3::callVirtualMethod(void*, unsigned int, void*, _typelib_TypeDescriptionReference*, bool, unsigned long*, unsigned int, unsigned long*, double*) /src/libreoffice/bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx:157:51
	    #1 0xcd0cd78 in cpp_call(bridges::cpp_uno::shared::UnoInterfaceProxy*, bridges::cpp_uno::shared::VtableSlot, _typelib_TypeDescriptionReference*, int, _typelib_MethodParameter*, void*, void**, _uno_Any**) /src/libreoffice/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:233:13
	    #2 0xcd0a9fa in unoInterfaceProxyDispatch /src/libreoffice/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:0
	    #3 0x174d1f01 in stoc_corefl::(anonymous namespace)::IdlInterfaceMethodImpl::invoke(com::sun::star::uno::Any const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any>&) /src/libreoffice/stoc/source/corereflection/criface.cxx:590:9
	    #4 0x174d5935 in non-virtual thunk to stoc_corefl::(anonymous namespace)::IdlInterfaceMethodImpl::invoke(com::sun::star::uno::Any const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any>&) /src/libreoffice/stoc/source/corereflection/criface.cxx:0
	    #5 0x2b1d5ce in ScUnoAddInCall::ExecuteCallWithArgs(com::sun::star::uno::Sequence<com::sun::star::uno::Any>&) /src/libreoffice/sc/source/core/tool/addincol.cxx:1518:27
	    #6 0x2b1c2ee in ScUnoAddInCall::ExecuteCall() /src/libreoffice/sc/source/core/tool/addincol.cxx:1495:9
	    #7 0x2e81a4b in ScInterpreter::ScExternal() /src/libreoffice/sc/source/core/tool/interpr4.cxx:3065:19
	    #8 0x2e94a38 in ScInterpreter::Interpret() /src/libreoffice/sc/source/core/tool/interpr4.cxx:4487:43

Uninitialized value was created by an allocation of 'data' in the stack frame of function '_ZN4gcc317callVirtualMethodEPvjS0_P33_typelib_TypeDescriptionReferencebPmjS3_Pd'
	    #0 0xcd0f1d0 in gcc3::callVirtualMethod(void*, unsigned int, void*, _typelib_TypeDescriptionReference*, bool, unsigned long*, unsigned int, unsigned long*, double*) /src/libreoffice/bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx:50

The double really comes from AnalysisAddIn::getConvert and when adding
code to switch off it there and msan is happy before it returns that it
is initialized, the problem arises when extracting that return value in
the bridge code. Its curious that this only appears now when we've been
running msan for years and only for double (so far) and not the other
types.

Change-Id: I8f381a9faf4fe9d4a02b77b241ab33de8eb3bce2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162348
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-01-21 21:27:11 +01:00
Caolán McNamara 5bc1d4bea2 merge float fix from gcc3_linux_x86-64 to gcc3_macosx_x86-64
presumably we need the same fix there as done with:

commit 3bcc14b4e2
Author: Stephan Bergmann <sbergman@redhat.com>
Date:   Thu Aug 3 13:21:44 2023 +0200

    Fix handling of float vs. double values

Change-Id: I7d6420dc954cdc320c9478172878e2a272ab2745
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162193
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-01-17 16:45:01 +01:00