[PATCH] D55955: Properly diagnose [[nodiscard]] on the body of a range-based for loop
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 24 09:42:35 PST 2018
aaron.ballman updated this revision to Diff 179475.
aaron.ballman marked 3 inline comments as done.
aaron.ballman added a comment.
Updated based on review feedback.
The lookahead wasn't too annoying to thread through, but I did run into surprises in TreeTransform where I can't use the lookahead to determine whether the expression statement should be warned on or not. The solution I have is serviceable, but perhaps there's a better approach to be taken.
The changes introduce warnings where they were previously missed, such as in init-statements. The only unfortunate behavioral side effect comes from range-based for loops that have an expression as the first statement -- in addition to the error, we now trigger an unused expression result warning, but restructuring the code to avoid it would be challenging for such an edge case (and the warning behavior seems reasonable).
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D55955/new/
https://reviews.llvm.org/D55955
Files:
include/clang/Parse/Parser.h
include/clang/Sema/Sema.h
lib/Parse/ParseObjc.cpp
lib/Parse/ParseOpenMP.cpp
lib/Parse/ParseStmt.cpp
lib/Sema/SemaExprCXX.cpp
lib/Sema/SemaOpenMP.cpp
lib/Sema/SemaStmt.cpp
lib/Sema/TreeTransform.h
test/CXX/stmt.stmt/stmt.select/p3.cpp
test/CodeCompletion/pragma-macro-token-caching.c
test/Parser/cxx1z-init-statement.cpp
test/Parser/switch-recovery.cpp
test/SemaCXX/cxx1z-init-statement.cpp
test/SemaCXX/for-range-examples.cpp
test/SemaCXX/warn-unused-result.cpp
test/SemaObjCXX/foreach.mm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55955.179475.patch
Type: text/x-patch
Size: 21387 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181224/09332dc0/attachment-0001.bin>
More information about the cfe-commits
mailing list