[cfe-commits] r83352 - in /cfe/trunk/lib/CodeGen: CGDebugInfo.cpp CGDebugInfo.h

Daniel Dunbar daniel at zuster.org
Sat Oct 17 02:22:36 PDT 2009


Hi Devang,

On Mon, Oct 5, 2009 at 5:35 PM, Devang Patel <dpatel at apple.com> wrote:
> Author: dpatel
> Date: Mon Oct  5 19:35:31 2009
> New Revision: 83352
>
> URL: http://llvm.org/viewvc/llvm-project?rev=83352&view=rev
> Log:
> Set appropriate context for a global variable while emitting debug info.
>
> Modified:
>    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>    cfe/trunk/lib/CodeGen/CGDebugInfo.h
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=83352&r1=83351&r2=83352&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Oct  5 19:35:31 2009
> @@ -49,6 +49,22 @@
>     CurLoc = M->getContext().getSourceManager().getInstantiationLoc(Loc);
>  }
>
> +/// getContext - Get context info for the decl.
> +llvm::DIDescriptor CGDebugInfo::getContext(const VarDecl *Decl,
> +                                           llvm::DIDescriptor &CompileUnit) {
> +  if (Decl->isFileVarDecl())
> +    return CompileUnit;
> +  if (Decl->getDeclContext()->isFunctionOrMethod()) {

This can use an early exit.

> +    // Find the last subprogram in region stack.
> +    for (unsigned RI = RegionStack.size(), RE = 0; RI != RE; --RI) {

Doesn't RegionStack have r{begin,end}?

> +      llvm::DIDescriptor R = RegionStack[RI - 1];
> +      if (R.isSubprogram())
> +        return R;
> +    }
> +  }
> +  return CompileUnit;
> +}

 - Daniel




More information about the cfe-commits mailing list