[LLVMdev] fix warning with newer g++ compilers

Mike Stump
Sat, 15 Dec 2007 07:10:44 -0000

Newer g++ compilers can emit:

/Volumes/mrs5/net/llvm/llvm/llvm/lib/AsmParser/LLLexer.cpp: In member
function 'int llvm::LLLexer::LexAt()':
/Volumes/mrs5/net/llvm/llvm/llvm/lib/AsmParser/LLLexer.cpp:287:
warning: suggest a space before ';' or explicit braces around empty
body in 'for' statement
/Volumes/mrs5/net/llvm/llvm/llvm/lib/AsmParser/LLLexer.cpp: In member
function 'int llvm::LLLexer::LexPercent()':
/Volumes/mrs5/net/llvm/llvm/llvm/lib/AsmParser/LLLexer.cpp:338:
warning: suggest a space before ';' or explicit braces around empty
body in 'for' statement
/Volumes/mrs5/net/llvm/llvm/llvm/lib/AsmParser/LLLexer.cpp: In member
function 'int llvm::LLLexer::LexDigitOrNegative()':
/Volumes/mrs5/net/llvm/llvm/llvm/lib/AsmParser/LLLexer.cpp:720:
warning: suggest a space before ';' or explicit braces around empty
body in 'for' statement
/Volumes/mrs5/net/llvm/llvm/llvm/lib/AsmParser/LLLexer.cpp: In member
function 'int llvm::LLLexer::LexPositive()':
/Volumes/mrs5/net/llvm/llvm/llvm/lib/AsmParser/LLLexer.cpp:789:
warning: suggest a space before ';' or explicit braces around empty
body in 'for' statement

The usual style is to put a space before the ;, or put the ; on a new
line to visually separate the ; from the for statement, so that the
follow like doesn't look like it goes with the for.

Thoughts?


Index: lib/AsmParser/LLLexer.cpp
==================================================================---
lib/AsmParser/LLLexer.cpp	(revision 45058)
+++ lib/AsmParser/LLLexer.cpp	(working copy)
@@ -284,7 +284,7 @@

    // Handle GlobalVarID: @[0-9]+
    if (isdigit(CurPtr[0])) {
-    for (++CurPtr; isdigit(CurPtr[0]); ++CurPtr);
+    for (++CurPtr; isdigit(CurPtr[0]); ++CurPtr) ;

      uint64_t Val = atoull(TokStart+1, CurPtr);
      if ((unsigned)Val != Val)
@@ -335,7 +335,7 @@

    // Handle LocalVarID: %[0-9]+
    if (isdigit(CurPtr[0])) {
-    for (++CurPtr; isdigit(CurPtr[0]); ++CurPtr);
+    for (++CurPtr; isdigit(CurPtr[0]); ++CurPtr) ;

      uint64_t Val = atoull(TokStart+1, CurPtr);
      if ((unsigned)Val != Val)
@@ -717,7 +717,7 @@
    // At this point, it is either a label, int or fp constant.

    // Skip digits, we have at least one.
-  for (; isdigit(CurPtr[0]); ++CurPtr);
+  for (; isdigit(CurPtr[0]); ++CurPtr) ;

    // Check to see if this really is a label afterall, e.g. "-1:".
    if (isLabelChar(CurPtr[0]) || CurPtr[0] == ':') {
@@ -786,7 +786,7 @@
      return CurPtr[-1];

    // Skip digits.
-  for (++CurPtr; isdigit(CurPtr[0]); ++CurPtr);
+  for (++CurPtr; isdigit(CurPtr[0]); ++CurPtr) ;

    // At this point, we need a '.'.
    if (CurPtr[0] != '.') {