llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.3k stars 11.69k forks source link

Debug info for variadic templates #36093

Closed kiranchandramohan closed 2 months ago

kiranchandramohan commented 6 years ago
Bugzilla Link 36745
Version trunk
OS All
CC @adrian-prantl,@dwblaikie,@DougGregor,@pogo59

Extended Description

template<typename T>
T accumulator(T v) {
  return v;
}

template<typename T, typename... Args>
T accumulator(T first, Args... args) {
  return first + accumulator(args...);
}

int main()
{
long sum = accumulator(1, 3, 5, 7);
return sum;
}

The testcase is given above. This testcase is an example for variadic templates. The debug info generated for this testcase by clang seems to be incorrect. The accumulator is passed the values (1,3,5,7). All the non-first elements are shown with value 7 at the breakpoint. Ideally they should be first=1, args=3, args=5, args=7

Breakpoint 2, accumulator<int, int, int, int> (first=1, args=7, args=7, args=7) at simple_var.cpp:8 8 return first + accumulator(args...);

llvmbot commented 3 months ago

@llvm/issue-subscribers-c-11

Author: Kiran Chandramohan (kiranchandramohan)

| | | | --- | --- | | Bugzilla Link | [36745](https://llvm.org/bz36745) | | Version | trunk | | OS | All | | CC | @adrian-prantl,@dwblaikie,@DougGregor,@pogo59 | ## Extended Description template<typename T> T accumulator(T v) { return v; } template<typename T, typename... Args> T accumulator(T first, Args... args) { return first + accumulator(args...); } int main() { long sum = accumulator(1, 3, 5, 7); return sum; } The testcase is given above. This testcase is an example for variadic templates. The debug info generated for this testcase by clang seems to be incorrect. The accumulator is passed the values (1,3,5,7). All the non-first elements are shown with value 7 at the breakpoint. Ideally they should be first=1, args=3, args=5, args=7 Breakpoint 2, accumulator<int, int, int, int> (first=1, args=7, args=7, args=7) at simple_var.cpp:8 8 return first + accumulator(args...);
llvmbot commented 3 months ago

@llvm/issue-subscribers-debuginfo

Author: Kiran Chandramohan (kiranchandramohan)

| | | | --- | --- | | Bugzilla Link | [36745](https://llvm.org/bz36745) | | Version | trunk | | OS | All | | CC | @adrian-prantl,@dwblaikie,@DougGregor,@pogo59 | ## Extended Description template<typename T> T accumulator(T v) { return v; } template<typename T, typename... Args> T accumulator(T first, Args... args) { return first + accumulator(args...); } int main() { long sum = accumulator(1, 3, 5, 7); return sum; } The testcase is given above. This testcase is an example for variadic templates. The debug info generated for this testcase by clang seems to be incorrect. The accumulator is passed the values (1,3,5,7). All the non-first elements are shown with value 7 at the breakpoint. Ideally they should be first=1, args=3, args=5, args=7 Breakpoint 2, accumulator<int, int, int, int> (first=1, args=7, args=7, args=7) at simple_var.cpp:8 8 return first + accumulator(args...);
dwblaikie commented 2 months ago

Duplicate of #24643