On Thu, Sep 6, 2012 at 10:47 AM, Sergiy Migdalskiy <span dir="ltr"><<a href="mailto:migdalskiy@hotmail.com" target="_blank">migdalskiy@hotmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Ok, does everyone agree on this variant?<br>
Also, is the check "isValueDependent()" essentially for the cases when bitwidth is templatized? Or is there some other reason?<br></blockquote><div><br></div><div>Yes, exactly, it's for the case where the bitwidth involves a template argument in a way which means we can't evaluate it.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
// Return bitfield bit width. Cursor must be a value-independent bit field declaration<div class="im"><br>
int clang_Cursor_getBitfieldWidth(<u></u>CXCursor C) {<br>
 if (clang_isDeclaration(C.kind)) {<br>
   Decl *D = cxcursor::getCursorDecl(C);<br>
   if( const FieldDecl *FD = dyn_cast_or_null< FieldDecl >(D) ){<br>
     Expr *pBitWidth = FD->getBitWidth();<br></div>
     if( pBitWidth && !pBitWidth->isValueDependent() )<br>
       return FD->getBitWidthValue( getCursorASTUnit(C)-><u></u>getASTContext() );<div class="im"><br>
   }<br>
 }<br>
 return -1;<br>
}<br></div></blockquote><div><br></div><div>Yes, this looks fine to me, functionally. There are some coding style violations here (variable names, whitespace). See:</div><div><br></div><div><a href="http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly">http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly</a></div>
<div><a href="http://llvm.org/docs/CodingStandards.html#spaces-before-parentheses">http://llvm.org/docs/CodingStandards.html#spaces-before-parentheses</a></div><div><br></div><div>The next thing to do is to get a complete patch together and mail it to cfe-commits@ for a proper review. This patch should include test cases (maybe extend c-index-test.c's PrintCursor to print out the bit width for bitfields, and extend one of the test/Index/* tests to make sure the correct value is produced).</div>
<div><br></div><div>Thanks!</div><div>Richard</div></div>