[llvm-commits] [llvm] r76780 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Chris Lattner clattner at apple.com
Wed Jul 22 17:57:35 PDT 2009


On Jul 22, 2009, at 1:33 PM, David Greene wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=76780&view=rev
> Log:
>
> Put comment printing under asm-verbose.

Thanks David.

> +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Jul 22  
> 15:33:26 2009
> @@ -1712,23 +1711,47 @@
> /// EmitComments - Pretty-print comments for instructions
> void AsmPrinter::EmitComments(const MachineInstr &MI) const
> {
> +  if (VerboseAsm) {
> +    if (!MI.getDebugLoc().isUnknown()) {

Please use early exits to simplify this code:
http://llvm.org/docs/CodingStandards.html#hl_earlyexit

> +      DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc());
>
> +      // Print source line info
> +      O.PadToColumn(TAI->getCommentColumn(), 1);
> +      O << TAI->getCommentString() << " SrcLine ";

> +      if (DLT.CompileUnit->hasInitializer()) {
> +        Constant *Name = DLT.CompileUnit->getInitializer();
> +        if (ConstantArray *NameString =  
> dyn_cast<ConstantArray>(Name))
> +          if (NameString->isString()) {
> +            O << NameString->getAsString() << " ";
> +          }
> +      }

This is nice, but unrelated to your commit message.  Please describe  
your commits more accurately.  There is no need for the {}'s in the  
inner 'if'.

>
> /// EmitComments - Pretty-print comments for instructions
> void AsmPrinter::EmitComments(const MCInst &MI) const
> {

You just duplicated a bunch of code from the other EmitComments  
function, please factor it.

-Chris




More information about the llvm-commits mailing list