[llvm-bugs] [Bug 29152] New: CFGBuilder needs to handle ExprWithCleanups better

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Aug 26 09:58:25 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=29152

            Bug ID: 29152
           Summary: CFGBuilder needs to handle ExprWithCleanups better
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: pirama at google.com
                CC: llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk,
                    srhines at google.com
    Classification: Unclassified

Created attachment 17054
  --> https://llvm.org/bugs/attachment.cgi?id=17054&action=edit
Preprocessed input file

CFGBuilder::VisitIfStmt in CFG.cpp does not handle a BinaryOperator packaged in
an ExprWithCleanup correctly.  r272296 increases the frequency and cases where
ExprWithCleanups are created.

This causes -Wunreachable-code in Android's ART code
(https://android.googlesource.com/platform/art/+/c9c055f96005b319d6c582b23432ba3ef0bd7488/runtime/class_table.cc).

ToT generates a warning in line 61: (pre-processed source attached.  Invocation
at the bottom)

art/runtime/class_table.cc:61:38: error: code will never be executed
[-Werror,-Wunreachable-code]
    for (const ClassSet& class_set : classes_) {
                                     ^~~~~~~~
1 error generated. 

This is because kIsDebugBuild, checked in line 60, is a constant set to false. 
However, there is another instance of similar dead code in line 173 that
doesn't trigger -Wunreachable-code.  Reverting r272296 does not trigger the
warning either.

CFGBuilder should be taught to step over the ExprWithCleanup when building CFG
for an If statement.

Clang invocation:
clang++ -cc1 -triple x86_64--linux-gnu -emit-llvm-bc -emit-llvm-uselists
-disable-free -main-file-name class_table.cc -mrelocation-model pic -pic-level
2 -mthread-model posix -mllvm -warn-stack-size=2700 -mdisable-fp-elim
-fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu
x86-64 -momit-leaf-frame-pointer -v -dwarf-column-info -debug-info-kind=limited
-dwarf-version=4 -debugger-tuning=gdb -nostdinc++ -O3 -Wno-multichar -W -Wall
-Wno-unused -Winit-self -Wpointer-arith -Werror=int-conversion
-Wno-reserved-id-macro -Wno-format-pedantic -Wno-unused-command-line-argument
-Wno-expansion-to-defined -Wsign-promo -Wno-inconsistent-missing-override
-Wno-null-dereference -Wthread-safety -Wthread-safety-negative
-Wimplicit-fallthrough -Wfloat-equal -Wint-to-void-pointer-cast
-Wused-but-marked-unused -Wdeprecated -Wunreachable-code-break
-Wunreachable-code-return -Wno-constant-conversion -Wno-undefined-var-template
-Wmissing-noreturn -Wall -Werror -Wextra -Wstrict-aliasing -Wunreachable-code
-Wredundant-decls -Wshadow -Wunused -Werror=int-to-pointer-cast
-Werror=pointer-to-int-cast -Werror=address-of-temporary -Werror=return-type
-std=gnu++14 -fdeprecated-macro  -fdebug-prefix-map=/proc/self/cwd=
-ferror-limit 19 -fmessage-length 0 -fvisibility protected -stack-protector 2
-fno-rtti -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics
-vectorize-loops -vectorize-slp -disable-llvm-passes -o class_table.bc -x
c++-cpp-output class_table.ii

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160826/52e1fbf9/attachment.html>


More information about the llvm-bugs mailing list