brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · a90ad83 Raw
71 lines · cpp
1// RUN: %clang_cc1 -debug-info-kind=limited -gno-column-info -std=c++11 -emit-llvm %s -o -| FileCheck %s2//3// Two variables with the same name in subsequent if staments need to be in separate scopes.4 5int src();6 7void f();8 9void func() {10  // CHECK: = !DILocalVariable(name: "i"11  // CHECK-SAME:               scope: [[IF1:![0-9]*]]12  // CHECK-SAME:               line: [[@LINE+2]]13  // CHECK: [[IF1]] = distinct !DILexicalBlock({{.*}}line: [[@LINE+1]])14  if (int i = src())15    f();16 17  // CHECK: = !DILocalVariable(name: "i"18  // CHECK-SAME:               scope: [[IF2:![0-9]*]]19  // CHECK-SAME:               line: [[@LINE+2]]20  // CHECK: [[IF2]] = distinct !DILexicalBlock({{.*}}line: [[@LINE+1]])21  if (int i = src()) {22    f();23  } else24    f();25 26  // CHECK: = !DILocalVariable(name: "i"27  // CHECK-SAME:               scope: [[FOR:![0-9]*]]28  // CHECK-SAME:               line: [[@LINE+2]]29  // CHECK: [[FOR]] = distinct !DILexicalBlock({{.*}}line: [[@LINE+1]])30  for (int i = 0;31  // CHECK: = !DILocalVariable(name: "b"32  // CHECK-SAME:               scope: [[FOR_BODY:![0-9]*]]33  // CHECK-SAME:               line: [[@LINE+6]]34  // CHECK: [[FOR_BODY]] = distinct !DILexicalBlock({{.*}}line: [[@LINE-4]])35  // The scope could be located at 'bool b', but LLVM drops line information for36  // scopes anyway, so it's not terribly important.37  // FIXME: change the debug info schema to not include locations of scopes,38  // since they're not used.39       bool b = i != 10; ++i)40    f();41 42  // CHECK: = !DILocalVariable(name: "i"43  // CHECK-SAME:               scope: [[FOR:![0-9]*]]44  // CHECK-SAME:               line: [[@LINE+2]]45  // CHECK: [[FOR]] = distinct !DILexicalBlock({{.*}}line: [[@LINE+1]])46  for (int i = 0; i != 10; ++i) {47    // FIXME: Do not include scopes that have only other scopes (and no variables48    // or using declarations) as direct children, they just waste49    // space/relocations/etc.50    // CHECK: [[FOR_LOOP_INCLUDING_COND:!.*]] = distinct !DILexicalBlock(scope: [[FOR]],{{.*}} line: [[@LINE-4]])51    // CHECK: = !DILocalVariable(name: "b"52    // CHECK-SAME:               scope: [[FOR_COMPOUND:![0-9]*]]53    // CHECK-SAME:               line: [[@LINE+2]]54    // CHECK: [[FOR_COMPOUND]] = distinct !DILexicalBlock(scope: [[FOR_LOOP_INCLUDING_COND]],{{.*}} line: [[@LINE-8]])55    bool b = i % 2;56  }57 58  int x[] = {1, 2};59  // CHECK: = !DILocalVariable(name: "__range1"60  // CHECK-SAME:               scope: [[RANGE_FOR:![0-9]*]]61  // CHECK-NOT:                line:62  // CHECK-SAME:               ){{$}}63  // CHECK: [[RANGE_FOR]] = distinct !DILexicalBlock({{.*}}, line: [[@LINE+1]])64  for (int i : x) {65    // CHECK: = !DILocalVariable(name: "i"66    // CHECK-SAME:               scope: [[RANGE_FOR_BODY:![0-9]*]]67    // CHECK-SAME:               line: [[@LINE-3]]68    // CHECK: [[RANGE_FOR_BODY]] = distinct !DILexicalBlock(scope: [[RANGE_FOR]],{{.*}} line: [[@LINE-4]])69  }70}71