[LLVMbugs] [Bug 18938] New: Experiment with a -Windent warning

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Feb 23 11:47:21 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=18938

            Bug ID: 18938
           Summary: Experiment with a -Windent warning
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 12113
  --> http://llvm.org/bugs/attachment.cgi?id=12113&action=edit
prototype patch v0

Wouldn't it be great if clang warned on something like

  if (5 != 0)
    goto fail;
    goto fail;

?

This bug tracks various ideas for warnings about this based on indent level.
(There's already -Wunreachable-code for the CFG approach).

Version 1: Remember only child of unbraced ifs, fors, whiles, and warn if next
statement has same indent as that child. Prototype patch attached (it doesn't
reset IndentStmt often enough).

It has false positives on this code in udis86.c in mach_override:

  if (ud_input_end(u))
  return 0;

  u->asm_buf[0] = 0;

  if (ud_decode(u) == 0)
  return 0;


Also on this from mach_override.c, but looking at the style in the rest of the
file that might actually be a (harmless) true positive:

    if( !err )    
        err = allocateBranchIsland( &escapeIsland, kAllocateHigh,
originalFunctionAddress );
        if (err) fprintf(stderr, "err = %x %s:%d\n", err, __FILE__, __LINE__);

-- 
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/20140223/e7c7f1a6/attachment.html>


More information about the llvm-bugs mailing list