<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Sorry for that, I broke a LIT test that I added few days ago.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">The LIT test need to be fixed and I already fixed it in r268063.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Let’s wait till r268063 run bots and see that everything will pass.<o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></a></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Amjad<o:p></o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><a name="_____replyseparator"></a><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> peter_cooper@apple.com [mailto:peter_cooper@apple.com]
<br>
<b>Sent:</b> Friday, April 29, 2016 19:53<br>
<b>To:</b> Aboud, Amjad <amjad.aboud@intel.com><br>
<b>Cc:</b> cfe-commits@lists.llvm.org<br>
<b>Subject:</b> Re: r268055 - Recommitted r264281 "Supporting all entities declared in lexical scope in LLVM debug info."<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hi Amjad<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Either this change, or r268054, appears to have broken the bots.  Can you please take a look?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">The error at: <a href="http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/22409/consoleFull#8333002949ba4694-19c4-4d7e-bec5-911270d8a58c">http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/22409/consoleFull#8333002949ba4694-19c4-4d7e-bec5-911270d8a58c</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Pete<o:p></o:p></p>
</div>
<div>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">On Apr 29, 2016, at 9:08 AM, Amjad Aboud via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">Author: aaboud<br>
Date: Fri Apr 29 11:08:08 2016<br>
New Revision: 268055<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=268055&view=rev">http://llvm.org/viewvc/llvm-project?rev=268055&view=rev</a><br>
Log:<br>
Recommitted r264281 "Supporting all entities declared in lexical scope in LLVM debug info."<br>
After fixing PR26942 in r267004.<br>
<br>
Added:<br>
   cfe/trunk/test/CodeGenCXX/debug-info-lb.cpp<br>
Modified:<br>
   cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
   cfe/trunk/lib/CodeGen/CGDebugInfo.h<br>
   cfe/trunk/lib/CodeGen/CGDecl.cpp<br>
   cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=268055&r1=268054&r2=268055&view=diff">
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=268055&r1=268054&r2=268055&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Apr 29 11:08:08 2016<br>
@@ -814,15 +814,18 @@ llvm::DIType *CGDebugInfo::CreateType(co<br>
<br>
llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty,<br>
                                      llvm::DIFile *Unit) {<br>
+  TypedefNameDecl *TD = Ty->getDecl();<br>
  // We don't set size information, but do specify where the typedef was<br>
  // declared.<br>
-  SourceLocation Loc = Ty->getDecl()->getLocation();<br>
+  SourceLocation Loc = TD->getLocation();<br>
+<br>
+  llvm::DIScope *TDContext = getDeclarationLexicalScope(*TD, QualType(Ty, 0));<br>
<br>
  // Typedefs are derived from some other type.<br>
  return DBuilder.createTypedef(<br>
      getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit),<br>
      Ty->getDecl()->getName(), getOrCreateFile(Loc), getLineNumber(Loc),<br>
-      getDeclContextDescriptor(Ty->getDecl()));<br>
+      TDContext);<br>
}<br>
<br>
llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty,<br>
@@ -1457,6 +1460,23 @@ llvm::DIType *CGDebugInfo::getOrCreateSt<br>
  return T;<br>
}<br>
<br>
+void CGDebugInfo::recordDeclarationLexicalScope(const Decl &D) {<br>
+  assert(LexicalBlockMap.find(&D) == LexicalBlockMap.end() &&<br>
+         "D is already mapped to lexical block scope");<br>
+  if (!LexicalBlockStack.empty())<br>
+    LexicalBlockMap[&D] = LexicalBlockStack.back();<br>
+}<br>
+<br>
+llvm::DIScope *CGDebugInfo::getDeclarationLexicalScope(const Decl &D,<br>
+                                                       QualType Ty) {<br>
+  auto I = LexicalBlockMap.find(&D);<br>
+  if (I != LexicalBlockMap.end()) {<br>
+    RetainedTypes.push_back(Ty.getAsOpaquePtr());<br>
+    return I->second;<br>
+  }<br>
+  return getDeclContextDescriptor(cast<Decl>(&D));<br>
+}<br>
+<br>
void CGDebugInfo::completeType(const EnumDecl *ED) {<br>
  if (DebugKind <= codegenoptions::DebugLineTablesOnly)<br>
    return;<br>
@@ -2060,7 +2080,7 @@ llvm::DIType *CGDebugInfo::CreateEnumTyp<br>
    // entered into the ReplaceMap: finalize() will replace the first<br>
    // FwdDecl with the second and then replace the second with<br>
    // complete type.<br>
-    llvm::DIScope *EDContext = getDeclContextDescriptor(ED);<br>
+    llvm::DIScope *EDContext = getDeclarationLexicalScope(*ED, QualType(Ty, 0));<br>
    llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());<br>
    llvm::TempDIScope TmpContext(DBuilder.createReplaceableCompositeType(<br>
        llvm::dwarf::DW_TAG_enumeration_type, "", TheCU, DefUnit, 0));<br>
@@ -2104,7 +2124,7 @@ llvm::DIType *CGDebugInfo::CreateTypeDef<br>
<br>
  llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());<br>
  unsigned Line = getLineNumber(ED->getLocation());<br>
-  llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);<br>
+  llvm::DIScope *EnumContext = getDeclarationLexicalScope(*ED, QualType(Ty, 0));<br>
  llvm::DIType *ClassTy =<br>
      ED->isFixed() ? getOrCreateType(ED->getIntegerType(), DefUnit) : nullptr;<br>
  return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit,<br>
@@ -2365,7 +2385,7 @@ llvm::DICompositeType *CGDebugInfo::Crea<br>
  unsigned Line = getLineNumber(RD->getLocation());<br>
  StringRef RDName = getClassName(RD);<br>
<br>
-  llvm::DIScope *RDContext = getDeclContextDescriptor(RD);<br>
+  llvm::DIScope *RDContext = getDeclarationLexicalScope(*RD, QualType(Ty, 0));<br>
<br>
  // If we ended up creating the type during the context chain construction,<br>
  // just return that.<br>
@@ -2536,8 +2556,15 @@ void CGDebugInfo::collectVarDeclProps(co<br>
  if (DC->isRecord())<br>
    DC = CGM.getContext().getTranslationUnitDecl();<br>
<br>
- llvm::DIScope *Mod = getParentModuleOrNull(VD);<br>
- VDContext = getContextDescriptor(cast<Decl>(DC), Mod ? Mod : TheCU);<br>
+  if (VD->isStaticLocal()) {<br>
+    // Get context for static locals (that are technically globals) the same way<br>
+    // we do for "local" locals -- by using current lexical block.<br>
+    assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");<br>
+    VDContext = LexicalBlockStack.back();<br>
+  } else {<br>
+    llvm::DIScope *Mod = getParentModuleOrNull(VD);<br>
+    VDContext = getContextDescriptor(cast<Decl>(DC), Mod ? Mod : TheCU);<br>
+  }<br>
}<br>
<br>
llvm::DISubprogram *<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=268055&r1=268054&r2=268055&view=diff">
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=268055&r1=268054&r2=268055&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)<br>
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Fri Apr 29 11:08:08 2016<br>
@@ -107,6 +107,11 @@ class CGDebugInfo {<br>
<br>
  /// Keep track of our current nested lexical block.<br>
  std::vector<llvm::TypedTrackingMDRef<llvm::DIScope>> LexicalBlockStack;<br>
+<br>
+  /// Map of AST declaration to its lexical block scope.<br>
+  llvm::DenseMap<const Decl *, llvm::TypedTrackingMDRef<llvm::DIScope>><br>
+      LexicalBlockMap;<br>
+<br>
  llvm::DenseMap<const Decl *, llvm::TrackingMDRef> RegionMap;<br>
  /// Keep track of LexicalBlockStack counter at the beginning of a<br>
  /// function. This is used to pop unbalanced regions at the end of a<br>
@@ -369,6 +374,12 @@ public:<br>
  /// Emit an Objective-C interface type standalone debug info.<br>
  llvm::DIType *getOrCreateInterfaceType(QualType Ty, SourceLocation Loc);<br>
<br>
+  /// Map AST declaration to its lexical block scope if available.<br>
+  void recordDeclarationLexicalScope(const Decl &D);<br>
+<br>
+  /// Get lexical scope of AST declaration.<br>
+  llvm::DIScope *getDeclarationLexicalScope(const Decl &D, QualType Ty);<br>
+<br>
  /// Emit standalone debug info for a type.<br>
  llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation Loc);<br>
<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=268055&r1=268054&r2=268055&view=diff">
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=268055&r1=268054&r2=268055&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Fri Apr 29 11:08:08 2016<br>
@@ -87,11 +87,7 @@ void CodeGenFunction::EmitDecl(const Dec<br>
  case Decl::UsingShadow:<br>
  case Decl::ObjCTypeParam:<br>
    llvm_unreachable("Declaration should not be in declstmts!");<br>
-  case Decl::Function:  // void X();<br>
-  case Decl::Record:    // struct/union/class X;<br>
-  case Decl::Enum:      // enum X;<br>
-  case Decl::EnumConstant: // enum ? { X = ? }<br>
-  case Decl::CXXRecord: // struct/union/class X; [C++]<br>
+  case Decl::Function:     // void X();<br>
  case Decl::StaticAssert: // static_assert(X, ""); [C++0x]<br>
  case Decl::Label:        // __label__ x;<br>
  case Decl::Import:<br>
@@ -101,13 +97,21 @@ void CodeGenFunction::EmitDecl(const Dec<br>
    // None of these decls require codegen support.<br>
    return;<br>
<br>
+  case Decl::Record:       // struct/union/class X;<br>
+  case Decl::Enum:         // enum X;<br>
+  case Decl::EnumConstant: // enum ? { X = ? }<br>
+  case Decl::CXXRecord:    // struct/union/class X; [C++]<br>
+    if (CGDebugInfo *DI = getDebugInfo())<br>
+      DI->recordDeclarationLexicalScope(D);<br>
+    return;<br>
+<br>
  case Decl::NamespaceAlias:<br>
    if (CGDebugInfo *DI = getDebugInfo())<br>
-        DI->EmitNamespaceAlias(cast<NamespaceAliasDecl>(D));<br>
+      DI->EmitNamespaceAlias(cast<NamespaceAliasDecl>(D));<br>
    return;<br>
  case Decl::Using:          // using X; [C++]<br>
    if (CGDebugInfo *DI = getDebugInfo())<br>
-        DI->EmitUsingDecl(cast<UsingDecl>(D));<br>
+      DI->EmitUsingDecl(cast<UsingDecl>(D));<br>
    return;<br>
  case Decl::UsingDirective: // using namespace X; [C++]<br>
    if (CGDebugInfo *DI = getDebugInfo())<br>
@@ -128,6 +132,9 @@ void CodeGenFunction::EmitDecl(const Dec<br>
    const TypedefNameDecl &TD = cast<TypedefNameDecl>(D);<br>
    QualType Ty = TD.getUnderlyingType();<br>
<br>
+    if (CGDebugInfo *DI = getDebugInfo())<br>
+      DI->recordDeclarationLexicalScope(D);<br>
+<br>
    if (Ty->isVariablyModifiedType())<br>
      EmitVariablyModifiedType(Ty);<br>
  }<br>
<br>
Modified: cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp?rev=268055&r1=268054&r2=268055&view=diff">
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp?rev=268055&r1=268054&r2=268055&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp (original)<br>
+++ cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp Fri Apr 29 11:08:08 2016<br>
@@ -44,8 +44,13 @@ void instantiate(int x) {<br>
  buildBytes(x);<br>
}<br>
<br>
-// CHECK: !DIGlobalVariable(name: "c",{{.*}} file: [[FILE:.*]], line: 6,{{.*}} isLocal: true, isDefinition: true<br>
-// CHECK: [[FILE]] = !DIFile(filename: "{{.*}}debug-info-anon-union-vars.cpp",<br>
+// CHECK: ![[UNION:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_union_type,<br>
+// CHECK-NOT: name:<br>
+// CHECK: elements<br>
+// CHECK: [[FILE:.*]] = !DIFile(filename: "{{.*}}debug-info-anon-union-vars.cpp",<br>
+// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "i", scope: ![[UNION]],<br>
+// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "c", scope: ![[UNION]],<br>
+// CHECK: !DIGlobalVariable(name: "c",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true<br>
// CHECK: !DIGlobalVariable(name: "d",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true<br>
// CHECK: !DIGlobalVariable(name: "a",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true<br>
// CHECK: !DIGlobalVariable(name: "b",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true<br>
@@ -55,9 +60,4 @@ void instantiate(int x) {<br>
// CHECK: !DILocalVariable(name: "c", {{.*}}, flags: DIFlagArtificial<br>
// CHECK: !DILocalVariable(<br>
// CHECK-NOT: name:<br>
-// CHECK: type: ![[UNION:[0-9]+]]<br>
-// CHECK: ![[UNION]] = distinct !DICompositeType(tag: DW_TAG_union_type,<br>
-// CHECK-NOT: name:<br>
-// CHECK: elements<br>
-// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "i", scope: ![[UNION]],<br>
-// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "c", scope: ![[UNION]],<br>
+// CHECK: type: ![[UNION]]<br>
<br>
Added: cfe/trunk/test/CodeGenCXX/debug-info-lb.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-lb.cpp?rev=268055&view=auto">
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-lb.cpp?rev=268055&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/debug-info-lb.cpp (added)<br>
+++ cfe/trunk/test/CodeGenCXX/debug-info-lb.cpp Fri Apr 29 11:08:08 2016<br>
@@ -0,0 +1,27 @@<br>
+// RUN: %clang_cc1 -triple x86_64-none-linux-gnu -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s<br>
+<br>
+void foo() {<br>
+  static int bar = 1;<br>
+  {<br>
+    struct X {};<br>
+    typedef char Y;<br>
+    static int bar = 0;<br>
+    // The following basic block is intended, in order to check the case where<br>
+    // types "X", "Y" are defined in a different scope than where they are used.<br>
+    // They should have the scope they are defined at as their parent scope.<br>
+    {<br>
+      X a;<br>
+      Y b;<br>
+    }<br>
+  }<br>
+}<br>
+<br>
+// CHECK: !{{[0-9]+}} = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "X", scope: [[LBScope:![0-9]+]],<br>
+// CHECK: [[LBScope]] = distinct !DILexicalBlock(scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: 5)<br>
+<br>
+// CHECK: [[FuncScope:![0-9]+]] = distinct !DISubprogram(name: "foo",<br>
+<br>
+// CHECK: !{{[0-9]+}} = !DIDerivedType(tag: DW_TAG_typedef, name: "Y", scope: [[LBScope]],<br>
+// CHECK: !{{[0-9]+}} = distinct !DIGlobalVariable(name: "bar", scope: [[FuncScope]], file: !{{[0-9]+}}, line: 4<br>
+// CHECK: !{{[0-9]+}} = distinct !DIGlobalVariable(name: "bar", scope: [[LBScope]], file: !{{[0-9]+}}, line: 8<br>
+<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
<p>---------------------------------------------------------------------<br>
Intel Israel (74) Limited</p>

<p>This e-mail and any attachments may contain confidential material for<br>
the sole use of the intended recipient(s). Any review or distribution<br>
by others is strictly prohibited. If you are not the intended<br>
recipient, please contact the sender and delete all copies.</p></body>
</html>