Bug Summary

File:home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx
Warning:line 68, column 23
Access to field 'm_nIndex' results in a dereference of a null pointer (loaded from field 'm_pLast')

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name index.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -isystem /usr/include/libxml2 -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D SW_DLLIMPLEMENTATION -D SWUI_DLL_NAME="libswuilo.so" -D SYSTEM_LIBXML -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/i18n -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/common -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/sw/source/core/inc -I /home/maarten/src/libreoffice/core/sw/source/filter/inc -I /home/maarten/src/libreoffice/core/sw/source/uibase/inc -I /home/maarten/src/libreoffice/core/sw/inc -I /home/maarten/src/libreoffice/core/workdir/SdiTarget/sw/sdi -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/officecfg/registry -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/sw/generated -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/oovbaapi/normal -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <index.hxx>
21
22#include <assert.h>
23#include <sal/log.hxx>
24
25#include <crossrefbookmark.hxx>
26
27SwIndex::SwIndex(SwIndexReg *const pReg, sal_Int32 const nIdx)
28 : m_nIndex( nIdx )
29 , m_pIndexReg( pReg )
30 , m_pNext( nullptr )
31 , m_pPrev( nullptr )
32 , m_pMark( nullptr )
33{
34 Init(m_nIndex);
35}
36
37SwIndex::SwIndex( const SwIndex& rIdx, short nDiff )
38 : m_pIndexReg( rIdx.m_pIndexReg )
39 , m_pNext( nullptr )
40 , m_pPrev( nullptr )
41 , m_pMark( nullptr )
42{
43 ChgValue( rIdx, rIdx.m_nIndex + nDiff );
44}
45
46SwIndex::SwIndex( const SwIndex& rIdx )
47 : m_nIndex( rIdx.m_nIndex )
48 , m_pIndexReg( rIdx.m_pIndexReg )
49 , m_pNext( nullptr )
50 , m_pPrev( nullptr )
51 , m_pMark( nullptr )
52{
53 ChgValue( rIdx, rIdx.m_nIndex );
54}
55
56void SwIndex::Init(sal_Int32 const nIdx)
57{
58 if (!m_pIndexReg
27.1
Field 'm_pIndexReg' is non-null
65.1
Field 'm_pIndexReg' is non-null
)
28
Taking false branch
66
Taking false branch
59 {
60 m_nIndex = 0; // always 0 if no IndexReg
61 }
62 else if (!m_pIndexReg->m_pFirst
66.1
Field 'm_pFirst' is non-null
) // first Index?
29
Assuming field 'm_pFirst' is non-null
30
Taking false branch
67
Taking false branch
63 {
64 assert(!m_pIndexReg->m_pLast)(static_cast <bool> (!m_pIndexReg->m_pLast) ? void (
0) : __assert_fail ("!m_pIndexReg->m_pLast", "/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
, 64, __extension__ __PRETTY_FUNCTION__))
;
65 m_pIndexReg->m_pFirst = m_pIndexReg->m_pLast = this;
66 m_nIndex = nIdx;
67 }
68 else if (nIdx > ((m_pIndexReg->m_pLast->m_nIndex
31
Assuming the condition is false
32
Taking false branch
68
Access to field 'm_nIndex' results in a dereference of a null pointer (loaded from field 'm_pLast')
69 - m_pIndexReg->m_pFirst->m_nIndex) / 2))
70 {
71 ChgValue( *m_pIndexReg->m_pLast, nIdx );
72 }
73 else
74 {
75 ChgValue( *m_pIndexReg->m_pFirst, nIdx );
33
Calling 'SwIndex::ChgValue'
57
Returning from 'SwIndex::ChgValue'
76 }
77}
78
79SwIndex& SwIndex::ChgValue( const SwIndex& rIdx, sal_Int32 nNewValue )
80{
81 assert(m_pIndexReg == rIdx.m_pIndexReg)(static_cast <bool> (m_pIndexReg == rIdx.m_pIndexReg) ?
void (0) : __assert_fail ("m_pIndexReg == rIdx.m_pIndexReg",
"/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
, 81, __extension__ __PRETTY_FUNCTION__))
;
34
Assuming 'm_pIndexReg' is equal to 'rIdx.m_pIndexReg'
35
'?' condition is true
82 if (!m_pIndexReg
35.1
Field 'm_pIndexReg' is non-null
)
36
Taking false branch
83 {
84 m_nIndex = 0;
85 return *this; // no IndexReg => no list to sort into; m_nIndex is 0
86 }
87 SwIndex* pFnd = const_cast<SwIndex*>(&rIdx);
88 if (rIdx.m_nIndex > nNewValue) // move forwards
37
Assuming 'nNewValue' is >= field 'm_nIndex'
38
Taking false branch
89 {
90 for (;;)
91 {
92 SwIndex* pPrv = pFnd->m_pPrev;
93 if (!pPrv || pPrv->m_nIndex <= nNewValue)
94 break;
95 pFnd = pPrv;
96 }
97
98 if( pFnd != this )
99 {
100 // remove from list at old position
101 Remove();
102
103 m_pNext = pFnd;
104 m_pPrev = pFnd->m_pPrev;
105 if (m_pPrev)
106 m_pPrev->m_pNext = this;
107 else
108 m_pIndexReg->m_pFirst = this;
109 pFnd->m_pPrev = this;
110 }
111 }
112 else if (rIdx.m_nIndex < nNewValue)
39
Assuming 'nNewValue' is <= field 'm_nIndex'
40
Taking false branch
113 {
114 for (;;)
115 {
116 SwIndex* pNxt = pFnd->m_pNext;
117 if (!pNxt || pNxt->m_nIndex >= nNewValue)
118 break;
119 pFnd = pNxt;
120 }
121
122 if( pFnd != this )
123 {
124 // remove from list at old position
125 Remove();
126
127 m_pPrev = pFnd;
128 m_pNext = pFnd->m_pNext;
129 if (m_pNext)
130 m_pNext->m_pPrev = this;
131 else
132 m_pIndexReg->m_pLast = this;
133 pFnd->m_pNext = this;
134 }
135 }
136 else if( pFnd != this )
41
Assuming the condition is true
42
Taking true branch
137 {
138 // remove from list at old position
139 Remove();
43
Calling 'SwIndex::Remove'
51
Returning from 'SwIndex::Remove'
140
141 m_pPrev = pFnd; // == &rIdx here
142 m_pNext = rIdx.m_pNext;
143 m_pPrev->m_pNext = this;
144
145 if (!m_pNext) // last in the list
52
Assuming field 'm_pNext' is non-null
53
Taking false branch
146 m_pIndexReg->m_pLast = this;
147 else
148 m_pNext->m_pPrev = this;
149 }
150
151 if (m_pIndexReg->m_pFirst == m_pNext)
54
Assuming field 'm_pFirst' is not equal to field 'm_pNext'
55
Taking false branch
152 m_pIndexReg->m_pFirst = this;
153 if (m_pIndexReg->m_pLast
55.1
Field 'm_pLast' is not equal to field 'm_pPrev'
== m_pPrev)
56
Taking false branch
154 m_pIndexReg->m_pLast = this;
155
156 m_nIndex = nNewValue;
157
158 return *this;
159}
160
161void SwIndex::Remove()
162{
163 if (!m_pIndexReg
43.1
Field 'm_pIndexReg' is non-null
)
17
Assuming field 'm_pIndexReg' is non-null
18
Taking false branch
44
Taking false branch
164 {
165 assert(!m_pPrev && !m_pNext)(static_cast <bool> (!m_pPrev && !m_pNext) ? void
(0) : __assert_fail ("!m_pPrev && !m_pNext", "/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
, 165, __extension__ __PRETTY_FUNCTION__))
;
166 return;
167 }
168
169 if (m_pPrev
44.1
Field 'm_pPrev' is null
)
19
Assuming field 'm_pPrev' is null
20
Taking false branch
45
Taking false branch
170 {
171 m_pPrev->m_pNext = m_pNext;
172 }
173 else if (m_pIndexReg->m_pFirst == this)
21
Assuming the condition is false
22
Taking false branch
46
Taking false branch
174 {
175 m_pIndexReg->m_pFirst = m_pNext;
176 }
177
178 if (m_pNext
46.1
Field 'm_pNext' is null
)
23
Assuming field 'm_pNext' is non-null
24
Taking true branch
47
Taking false branch
179 {
180 m_pNext->m_pPrev = m_pPrev;
181 }
182 else if (m_pIndexReg->m_pLast == this)
48
Assuming the condition is true
49
Taking true branch
183 {
184 m_pIndexReg->m_pLast = m_pPrev;
50
Null pointer value stored to field 'm_pLast'
185 }
186}
187
188SwIndex& SwIndex::operator=( const SwIndex& rIdx )
189{
190 bool bEqual;
191 if (rIdx.m_pIndexReg != m_pIndexReg) // unregister!
192 {
193 Remove();
194 m_pIndexReg = rIdx.m_pIndexReg;
195 m_pNext = m_pPrev = nullptr;
196 bEqual = false;
197 }
198 else
199 bEqual = rIdx.m_nIndex == m_nIndex;
200
201 if( !bEqual )
202 ChgValue( rIdx, rIdx.m_nIndex );
203 return *this;
204}
205
206SwIndex& SwIndex::Assign( SwIndexReg* pArr, sal_Int32 nIdx )
207{
208 if (pArr != m_pIndexReg) // unregister!
6
Assuming 'pArr' is equal to field 'm_pIndexReg'
7
Taking false branch
14
Assuming 'pArr' is not equal to field 'm_pIndexReg'
15
Taking true branch
63
Assuming 'pArr' is not equal to field 'm_pIndexReg'
64
Taking true branch
209 {
210 Remove();
16
Calling 'SwIndex::Remove'
25
Returning from 'SwIndex::Remove'
211 m_pIndexReg = pArr;
212 m_pNext = m_pPrev = nullptr;
26
Null pointer value stored to field 'm_pPrev'
213 Init(nIdx);
27
Calling 'SwIndex::Init'
58
Returning from 'SwIndex::Init'
65
Calling 'SwIndex::Init'
214 }
215 else if (m_nIndex != nIdx
7.1
'nIdx' is equal to field 'm_nIndex'
)
8
Taking false branch
216 {
217 ChgValue( *this, nIdx );
218 }
219 return *this;
9
Returning without writing to 'pArr->m_pFirst', which participates in a condition later
10
Returning without writing to 'pArr->m_pLast'
59
Returning without writing to 'pArr->m_pFirst', which participates in a condition later
220}
221
222void SwIndex::SetMark(const sw::mark::IMark* pMark)
223{
224 m_pMark = pMark;
225}
226
227SwIndexReg::SwIndexReg()
228 : m_pFirst( nullptr ), m_pLast( nullptr )
229{
230}
231
232SwIndexReg::~SwIndexReg()
233{
234 assert(!m_pFirst && !m_pLast && "There are still indices registered")(static_cast <bool> (!m_pFirst && !m_pLast &&
"There are still indices registered") ? void (0) : __assert_fail
("!m_pFirst && !m_pLast && \"There are still indices registered\""
, "/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
, 234, __extension__ __PRETTY_FUNCTION__))
;
235}
236
237void SwIndexReg::Update(
238 SwIndex const & rIdx,
239 const sal_Int32 nDiff,
240 const bool bNeg,
241 const bool /* argument is only used in derived class*/ )
242{
243 SwIndex* pStt = const_cast<SwIndex*>(&rIdx);
244 const sal_Int32 nNewVal = rIdx.m_nIndex;
245 if( bNeg )
246 {
247 const sal_Int32 nLast = rIdx.GetIndex() + nDiff;
248 while (pStt && pStt->m_nIndex == nNewVal)
249 {
250 pStt->m_nIndex = nNewVal;
251 pStt = pStt->m_pPrev;
252 }
253 pStt = rIdx.m_pNext;
254 while (pStt && pStt->m_nIndex >= nNewVal
255 && pStt->m_nIndex <= nLast)
256 {
257 pStt->m_nIndex = nNewVal;
258 pStt = pStt->m_pNext;
259 }
260 while( pStt )
261 {
262 pStt->m_nIndex = pStt->m_nIndex - nDiff;
263 pStt = pStt->m_pNext;
264 }
265 }
266 else
267 {
268 while (pStt && pStt->m_nIndex == nNewVal)
269 {
270 pStt->m_nIndex = pStt->m_nIndex + nDiff;
271 pStt = pStt->m_pPrev;
272 }
273 pStt = rIdx.m_pNext;
274 while( pStt )
275 {
276 // HACK: avoid updating position of cross-ref bookmarks
277 if (!pStt->m_pMark || nullptr == dynamic_cast<
278 ::sw::mark::CrossRefBookmark const*>(pStt->m_pMark))
279 {
280 pStt->m_nIndex = pStt->m_nIndex + nDiff;
281 }
282 pStt = pStt->m_pNext;
283 }
284 }
285}
286
287void SwIndexReg::MoveTo( SwIndexReg& rArr )
288{
289 if (!(this != &rArr && m_pFirst))
1
Assuming the condition is true
2
Assuming the condition is false
3
Taking false branch
290 return;
291
292 SwIndex * pIdx = const_cast<SwIndex*>(m_pFirst);
293 SwIndex * pNext;
294 while( pIdx )
4
Loop condition is true. Entering loop body
12
Loop condition is true. Entering loop body
61
Loop condition is true. Entering loop body
295 {
296 pNext = pIdx->m_pNext;
297 pIdx->Assign( &rArr, pIdx->GetIndex() );
5
Calling 'SwIndex::Assign'
11
Returning from 'SwIndex::Assign'
13
Calling 'SwIndex::Assign'
60
Returning from 'SwIndex::Assign'
62
Calling 'SwIndex::Assign'
298 pIdx = pNext;
299 }
300 m_pFirst = nullptr;
301 m_pLast = nullptr;
302}
303
304#ifdef DBG_UTIL
305
306// SwIndex
307
308sal_Int32 SwIndex::operator++()
309{
310 SAL_WARN_IF( !(m_nIndex < SAL_MAX_INT32), "sw.core",do { if (true && (!(m_nIndex < ((sal_Int32) 0x7FFFFFFF
)))) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sw.core")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "SwIndex::operator++() wraps around"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"
), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "311" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "SwIndex::operator++() wraps around"),
0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "SwIndex::operator++() wraps around"; ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "311" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "SwIndex::operator++() wraps around") == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "311" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "SwIndex::operator++() wraps around"),
0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "SwIndex::operator++() wraps around"; ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "311" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
311 "SwIndex::operator++() wraps around" )do { if (true && (!(m_nIndex < ((sal_Int32) 0x7FFFFFFF
)))) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sw.core")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "SwIndex::operator++() wraps around"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"
), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "311" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "SwIndex::operator++() wraps around"),
0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "SwIndex::operator++() wraps around"; ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "311" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "SwIndex::operator++() wraps around") == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "311" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "SwIndex::operator++() wraps around"),
0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "SwIndex::operator++() wraps around"; ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "311" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
312
313 ChgValue( *this, m_nIndex+1 );
314 return m_nIndex;
315}
316
317sal_Int32 SwIndex::operator--(int)
318{
319 SAL_WARN_IF( !(m_nIndex > 0), "sw.core",do { if (true && (!(m_nIndex > 0))) { switch (sal_detail_log_report
(::SAL_DETAIL_LOG_LEVEL_WARN, "sw.core")) { case SAL_DETAIL_LOG_ACTION_IGNORE
: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail
::getResult( ::sal::detail::StreamStart() << "SwIndex::operator--(int) wraps around"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"
), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "320" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "SwIndex::operator--(int) wraps around"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "SwIndex::operator--(int) wraps around"; ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "320" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "SwIndex::operator--(int) wraps around") == 1) { ::
sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"), (
"/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "320" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "SwIndex::operator--(int) wraps around"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "SwIndex::operator--(int) wraps around"; ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "320" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
320 "SwIndex::operator--(int) wraps around" )do { if (true && (!(m_nIndex > 0))) { switch (sal_detail_log_report
(::SAL_DETAIL_LOG_LEVEL_WARN, "sw.core")) { case SAL_DETAIL_LOG_ACTION_IGNORE
: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail
::getResult( ::sal::detail::StreamStart() << "SwIndex::operator--(int) wraps around"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"
), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "320" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "SwIndex::operator--(int) wraps around"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "SwIndex::operator--(int) wraps around"; ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "320" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "SwIndex::operator--(int) wraps around") == 1) { ::
sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"), (
"/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "320" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "SwIndex::operator--(int) wraps around"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "SwIndex::operator--(int) wraps around"; ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "320" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
321
322 const sal_Int32 nOldIndex = m_nIndex;
323 ChgValue( *this, m_nIndex-1 );
324 return nOldIndex;
325}
326
327sal_Int32 SwIndex::operator--()
328{
329 SAL_WARN_IF( !( m_nIndex > 0), "sw.core",do { if (true && (!( m_nIndex > 0))) { switch (sal_detail_log_report
(::SAL_DETAIL_LOG_LEVEL_WARN, "sw.core")) { case SAL_DETAIL_LOG_ACTION_IGNORE
: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail
::getResult( ::sal::detail::StreamStart() << "SwIndex::operator--() wraps around"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"
), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "330" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "SwIndex::operator--() wraps around"),
0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "SwIndex::operator--() wraps around"; ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "330" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "SwIndex::operator--() wraps around") == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "330" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "SwIndex::operator--() wraps around"),
0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "SwIndex::operator--() wraps around"; ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "330" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
330 "SwIndex::operator--() wraps around" )do { if (true && (!( m_nIndex > 0))) { switch (sal_detail_log_report
(::SAL_DETAIL_LOG_LEVEL_WARN, "sw.core")) { case SAL_DETAIL_LOG_ACTION_IGNORE
: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail
::getResult( ::sal::detail::StreamStart() << "SwIndex::operator--() wraps around"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"
), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "330" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "SwIndex::operator--() wraps around"),
0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "SwIndex::operator--() wraps around"; ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "330" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "SwIndex::operator--() wraps around") == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "330" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "SwIndex::operator--() wraps around"),
0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "SwIndex::operator--() wraps around"; ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "330" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
331 return ChgValue( *this, m_nIndex-1 ).m_nIndex;
332}
333
334sal_Int32 SwIndex::operator+=( sal_Int32 const nVal )
335{
336 SAL_WARN_IF( !(m_nIndex <= SAL_MAX_INT32 - nVal), "sw.core",do { if (true && (!(m_nIndex <= ((sal_Int32) 0x7FFFFFFF
) - nVal))) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sw.core")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "SwIndex SwIndex::operator+=(sal_Int32) wraps around"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"
), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "337" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "SwIndex SwIndex::operator+=(sal_Int32) wraps around"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "SwIndex SwIndex::operator+=(sal_Int32) wraps around"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"
), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "337" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "SwIndex SwIndex::operator+=(sal_Int32) wraps around"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"
), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "337" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "SwIndex SwIndex::operator+=(sal_Int32) wraps around"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "SwIndex SwIndex::operator+=(sal_Int32) wraps around"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"
), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "337" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
337 "SwIndex SwIndex::operator+=(sal_Int32) wraps around" )do { if (true && (!(m_nIndex <= ((sal_Int32) 0x7FFFFFFF
) - nVal))) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sw.core")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "SwIndex SwIndex::operator+=(sal_Int32) wraps around"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"
), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "337" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "SwIndex SwIndex::operator+=(sal_Int32) wraps around"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "SwIndex SwIndex::operator+=(sal_Int32) wraps around"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"
), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "337" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "SwIndex SwIndex::operator+=(sal_Int32) wraps around"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"
), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "337" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "SwIndex SwIndex::operator+=(sal_Int32) wraps around"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "SwIndex SwIndex::operator+=(sal_Int32) wraps around"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"
), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "337" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
338 return ChgValue( *this, m_nIndex + nVal ).m_nIndex;
339}
340
341sal_Int32 SwIndex::operator-=( sal_Int32 const nVal )
342{
343 SAL_WARN_IF( !(m_nIndex >= nVal), "sw.core",do { if (true && (!(m_nIndex >= nVal))) { switch (
sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN, "sw.core")
) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "SwIndex::operator-=(sal_Int32) wraps around") ==
1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"
), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "344" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "SwIndex::operator-=(sal_Int32) wraps around"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "SwIndex::operator-=(sal_Int32) wraps around"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "344" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "SwIndex::operator-=(sal_Int32) wraps around") ==
1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"
), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "344" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "SwIndex::operator-=(sal_Int32) wraps around"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "SwIndex::operator-=(sal_Int32) wraps around"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "344" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
344 "SwIndex::operator-=(sal_Int32) wraps around" )do { if (true && (!(m_nIndex >= nVal))) { switch (
sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN, "sw.core")
) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "SwIndex::operator-=(sal_Int32) wraps around") ==
1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"
), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "344" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "SwIndex::operator-=(sal_Int32) wraps around"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "SwIndex::operator-=(sal_Int32) wraps around"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "344" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "SwIndex::operator-=(sal_Int32) wraps around") ==
1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"
), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "344" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "SwIndex::operator-=(sal_Int32) wraps around"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "SwIndex::operator-=(sal_Int32) wraps around"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"), ("/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
":" "344" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
345 return ChgValue( *this, m_nIndex - nVal ).m_nIndex;
346}
347
348bool SwIndex::operator< ( const SwIndex & rIndex ) const
349{
350 // Attempt to compare indices into different arrays
351 assert(m_pIndexReg == rIndex.m_pIndexReg)(static_cast <bool> (m_pIndexReg == rIndex.m_pIndexReg)
? void (0) : __assert_fail ("m_pIndexReg == rIndex.m_pIndexReg"
, "/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
, 351, __extension__ __PRETTY_FUNCTION__))
;
352 return m_nIndex < rIndex.m_nIndex;
353}
354
355bool SwIndex::operator<=( const SwIndex & rIndex ) const
356{
357 // Attempt to compare indices into different arrays
358 assert(m_pIndexReg == rIndex.m_pIndexReg)(static_cast <bool> (m_pIndexReg == rIndex.m_pIndexReg)
? void (0) : __assert_fail ("m_pIndexReg == rIndex.m_pIndexReg"
, "/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
, 358, __extension__ __PRETTY_FUNCTION__))
;
359 return m_nIndex <= rIndex.m_nIndex;
360}
361
362bool SwIndex::operator> ( const SwIndex & rIndex ) const
363{
364 // Attempt to compare indices into different arrays
365 assert(m_pIndexReg == rIndex.m_pIndexReg)(static_cast <bool> (m_pIndexReg == rIndex.m_pIndexReg)
? void (0) : __assert_fail ("m_pIndexReg == rIndex.m_pIndexReg"
, "/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
, 365, __extension__ __PRETTY_FUNCTION__))
;
366 return m_nIndex > rIndex.m_nIndex;
367}
368
369bool SwIndex::operator>=( const SwIndex & rIndex ) const
370{
371 // Attempt to compare indices into different arrays
372 assert(m_pIndexReg == rIndex.m_pIndexReg)(static_cast <bool> (m_pIndexReg == rIndex.m_pIndexReg)
? void (0) : __assert_fail ("m_pIndexReg == rIndex.m_pIndexReg"
, "/home/maarten/src/libreoffice/core/sw/source/core/bastyp/index.cxx"
, 372, __extension__ __PRETTY_FUNCTION__))
;
373 return m_nIndex >= rIndex.m_nIndex;
374}
375
376SwIndex& SwIndex::operator= ( sal_Int32 const nVal )
377{
378 if (m_nIndex != nVal)
379 ChgValue( *this, nVal );
380
381 return *this;
382}
383
384#endif
385
386std::ostream& operator <<(std::ostream& s, const SwIndex& index)
387{
388 return s << "SwIndex offset (" << index.GetIndex() << ")";
389}
390
391/* vim:set shiftwidth=4 softtabstop=4 expandtab: */