[PATCH] D18350: Fixing DILexicalBlockFile issue in r263424

Amjad Aboud via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 22 14:19:19 PDT 2016

aaboud added a comment.

Please see the answer below.

Comment at: lib/CodeGen/AsmPrinter/DwarfCompileUnit.h:129
@@ -128,2 +128,3 @@
   void addLocalDeclNode(const DINode *DI, DILocalScope *Scope) {
+    if (auto *File = dyn_cast<DILexicalBlockFile>(Scope))
aprantl wrote:
> Please add a comment here explaining why this is necessary.
I am not sure that I need to add a comment inside the code.
It is just that everywhere else this skip is being done...without any comment.

/// getOrCreateRegularScope - Find or create a regular lexical scope.
LexicalScope *
LexicalScopes::getOrCreateRegularScope(const DILocalScope *Scope) {
  if (auto *File = dyn_cast<DILexicalBlockFile>(Scope))
    Scope = File->getScope();

The below list maps all the local decls to there scope (function or lexical scope), later it will be used when we go over the lexical scopes that where captured by LexicalScopes component (see above), and it does not capture DILexicalBlockFile, but skip it to get the DILexicalBlock.
So, if we do not do the same here we will end up mapping the local decls DIEs to the wrong scope, and they will not be handled later.

If you still think we better comment on this code, please help me capture what I just said above in few words/lines.


More information about the llvm-commits mailing list