Bug 363428 - false positive for writing to temporary QTextTableCell::setFormat
Summary: false positive for writing to temporary QTextTableCell::setFormat
Status: RESOLVED FIXED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Other Other
: NOR normal
Target Milestone: ---
Assignee: Unassigned bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-23 09:53 UTC by eric.lemanissier
Modified: 2016-05-30 20:21 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description eric.lemanissier 2016-05-23 09:53:44 UTC
Calling setFormat on a temporary QTextTableCell raises "Call to temporary is a no-op", but it is not, because QTextTableCell is just an indirection to the underlying QTextTable.

all other QTextTableCell members are const, so they are no-ops if the return value is ignored

Reproducible: Always

Steps to Reproduce:

    QTextCursor cursor;
    QTextTableCellFormat cellFormat;
// ...
    QTextTable *currentTable = cursor.currentTable();
    currentTable->cellAt(cursor).setFormat(cellFormat);

Actual Results:  
warning: Call to temporary is a no-op: QTextTableCell::setFormat [-Wclazy-writing-to-temporary]
    currentTable->cellAt(cursor).setFormat(cellFormat);
    ^
Comment 1 Sergio Martins 2016-05-26 14:52:30 UTC
Git commit 16084d3512cbe6cb163418766447d476b70f6213 by Sergio Martins.
Committed on 26/05/2016 at 14:52.
Pushed by smartins into branch 'master'.

writing-to-temporary: Whitelist QTextTableCell

It's an indirection to QTextTable so it's fine

M  +1    -1    checks/writingtotemporary.cpp

http://commits.kde.org/clazy/16084d3512cbe6cb163418766447d476b70f6213
Comment 2 eric.lemanissier 2016-05-30 18:43:37 UTC
The commit did not change the problem on my side.
Lookup at the source of WritingToTemporary, "QTextTableCell" was added to "isKnownType" function. I may be mistaken, but it looks like it should have been added to "isDisallowedClass"
Comment 3 Sergio Martins 2016-05-30 20:21:58 UTC
Git commit e3fd94c73311f737f692e434a683e2c2c6bcfb62 by Sergio Martins.
Committed on 30/05/2016 at 20:20.
Pushed by smartins into branch 'master'.

writing-to-temporary: Correctly fix QTextTableCell false-positive

This time with unit-test.

M  +3    -2    checks/level0/writingtotemporary.cpp
M  +9    -1    tests/writing-to-temporary/main.cpp

http://commits.kde.org/clazy/e3fd94c73311f737f692e434a683e2c2c6bcfb62