[PATCH] D138597: DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions

2022-12-12 Thread David Blaikie via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc73876db4f2d: Reapply DebugInfo: Add/support new 
DW_LANG codes for recent C and C++… (authored by dblaikie).

Changed prior to commit:
  https://reviews.llvm.org/D138597?vs=480590=482273#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138597/new/

https://reviews.llvm.org/D138597

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-preprocessed-file.i
  clang/test/CodeGen/debug-info-programming-language.c
  clang/test/CodeGenCXX/debug-info-programming-language.cpp
  clang/test/PCH/debug-info-pch-container-path.c

Index: clang/test/PCH/debug-info-pch-container-path.c
===
--- clang/test/PCH/debug-info-pch-container-path.c
+++ clang/test/PCH/debug-info-pch-container-path.c
@@ -14,7 +14,7 @@
 // RUN: cat %t-container.ll | FileCheck %s
 
 // CHECK: distinct !DICompileUnit(
-// CHECK-SAME:language: DW_LANG_C99,
+// CHECK-SAME:language: DW_LANG_C{{[^,]*}},
 // CHECK-SAME:file: ![[FILE:[0-9]+]],
 // CHECK: ![[FILE]] = !DIFile(
 // CHECK-SAME:filename: "SOURCE/debug-info-limited-struct.h",
Index: clang/test/CodeGenCXX/debug-info-programming-language.cpp
===
--- clang/test/CodeGenCXX/debug-info-programming-language.cpp
+++ clang/test/CodeGenCXX/debug-info-programming-language.cpp
@@ -4,6 +4,12 @@
 // RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
 // RUN:   -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited \
 // RUN:   | FileCheck --check-prefix=CHECK-CPP14 %s
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
+// RUN:   -x c++ -std=c++17 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   | FileCheck --check-prefix=CHECK-CPP17 %s
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
+// RUN:   -x c++ -std=c++20 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   | FileCheck --check-prefix=CHECK-CPP20 %s
 // RUN: %clang_cc1 -dwarf-version=3 -gstrict-dwarf -emit-llvm -triple %itanium_abi_triple %s -o - \
 // RUN:   -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited | FileCheck %s
 // RUN: %clang_cc1 -dwarf-version=5 -gstrict-dwarf -emit-llvm -triple %itanium_abi_triple %s -o - \
@@ -14,5 +20,15 @@
   return 0;
 }
 
+// Update these tests once support for DW_LANG_C_plus_plus_17/20 is added - it's
+// a complicated tradeoff. The language codes are already published/blessed by
+// the DWARF committee, but haven't been released in a published standard yet,
+// so consumers might not be ready for these codes & could regress functionality
+// (because they wouldn't be able to identify that the language was C++). The
+// DWARFv6 language encoding, separating language from language version, would
+// remove this problem/not require new codes for new language versions and make
+// it possible to identify the base language irrespective of the version.
 // CHECK-CPP14: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14,
+// CHECK-CPP17: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14,
+// CHECK-CPP20: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14,
 // CHECK: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,
Index: clang/test/CodeGen/debug-info-programming-language.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-programming-language.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
+// RUN:   -x c -std=c11 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   | FileCheck --check-prefix=CHECK-C11 %s
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
+// RUN:   -x c -std=c17 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   | FileCheck --check-prefix=CHECK-C17 %s
+
+// CHECK-C11: !DICompileUnit(language: DW_LANG_C11
+// Update this check once support for DW_LANG_C17 is broadly supported/known in
+// consumers. Maybe we'll skip this and go to the DWARFv6 language+version
+// encoding that avoids the risk of regression when describing a language
+// version newer than what the consumer is aware of.
+// CHECK-C17: !DICompileUnit(language: DW_LANG_C11
+
+void f1(void) { }
Index: clang/test/CodeGen/debug-info-preprocessed-file.i
===
--- clang/test/CodeGen/debug-info-preprocessed-file.i
+++ clang/test/CodeGen/debug-info-preprocessed-file.i
@@ -7,5 +7,5 @@
 # 1 "preprocessed-input.c" 2
 
 // RUN: %clang -g -c -S -emit-llvm -o - %s | FileCheck %s
-// CHECK: !DICompileUnit(language: DW_LANG_C99, file: ![[FILE:[0-9]+]] 
+// CHECK: 

[PATCH] D138597: DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions

2022-12-08 Thread David Blaikie via Phabricator via cfe-commits
dblaikie reopened this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

(just a side note I discovered while looking into this: seems someone else had 
this idea before & came to similar conclusions: 
https://reviews.llvm.org/D104118#2840490 )


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138597/new/

https://reviews.llvm.org/D138597

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138597: DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions

2022-12-06 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

Oh, right, PS4 defaults to C99.  It's okay with me if you make those two 
unsupported for PS4.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138597/new/

https://reviews.llvm.org/D138597

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138597: DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions

2022-12-06 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

LGTM.  I agree with the commentary in the test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138597/new/

https://reviews.llvm.org/D138597

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138597: DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions

2022-12-06 Thread David Blaikie via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3c312e48f325: DebugInfo: Add/support new DW_LANG codes for 
recent C and C++ versions (authored by dblaikie).

Changed prior to commit:
  https://reviews.llvm.org/D138597?vs=480296=480590#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138597/new/

https://reviews.llvm.org/D138597

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-preprocessed-file.i
  clang/test/CodeGen/debug-info-programming-language.c
  clang/test/CodeGenCXX/debug-info-programming-language.cpp
  clang/test/PCH/debug-info-pch-container-path.c

Index: clang/test/PCH/debug-info-pch-container-path.c
===
--- clang/test/PCH/debug-info-pch-container-path.c
+++ clang/test/PCH/debug-info-pch-container-path.c
@@ -14,7 +14,7 @@
 // RUN: cat %t-container.ll | FileCheck %s
 
 // CHECK: distinct !DICompileUnit(
-// CHECK-SAME:language: DW_LANG_C99,
+// CHECK-SAME:language: DW_LANG_C11,
 // CHECK-SAME:file: ![[FILE:[0-9]+]],
 // CHECK: ![[FILE]] = !DIFile(
 // CHECK-SAME:filename: "SOURCE/debug-info-limited-struct.h",
Index: clang/test/CodeGenCXX/debug-info-programming-language.cpp
===
--- clang/test/CodeGenCXX/debug-info-programming-language.cpp
+++ clang/test/CodeGenCXX/debug-info-programming-language.cpp
@@ -4,6 +4,12 @@
 // RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
 // RUN:   -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited \
 // RUN:   | FileCheck --check-prefix=CHECK-CPP14 %s
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
+// RUN:   -x c++ -std=c++17 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   | FileCheck --check-prefix=CHECK-CPP17 %s
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
+// RUN:   -x c++ -std=c++20 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   | FileCheck --check-prefix=CHECK-CPP20 %s
 // RUN: %clang_cc1 -dwarf-version=3 -gstrict-dwarf -emit-llvm -triple %itanium_abi_triple %s -o - \
 // RUN:   -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited | FileCheck %s
 // RUN: %clang_cc1 -dwarf-version=5 -gstrict-dwarf -emit-llvm -triple %itanium_abi_triple %s -o - \
@@ -14,5 +20,15 @@
   return 0;
 }
 
+// Update these tests once support for DW_LANG_C_plus_plus_17/20 is added - it's
+// a complicated tradeoff. The language codes are already published/blessed by
+// the DWARF committee, but haven't been released in a published standard yet,
+// so consumers might not be ready for these codes & could regress functionality
+// (because they wouldn't be able to identify that the language was C++). The
+// DWARFv6 language encoding, separating language from language version, would
+// remove this problem/not require new codes for new language versions and make
+// it possible to identify the base language irrespective of the version.
 // CHECK-CPP14: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14,
+// CHECK-CPP17: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14,
+// CHECK-CPP20: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14,
 // CHECK: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,
Index: clang/test/CodeGen/debug-info-programming-language.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-programming-language.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
+// RUN:   -x c -std=c11 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   | FileCheck --check-prefix=CHECK-C11 %s
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
+// RUN:   -x c -std=c17 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   | FileCheck --check-prefix=CHECK-C17 %s
+
+// CHECK-C11: !DICompileUnit(language: DW_LANG_C11
+// Update this check once support for DW_LANG_C17 is broadly supported/known in
+// consumers. Maybe we'll skip this and go to the DWARFv6 language+version
+// encoding that avoids the risk of regression when describing a language
+// version newer than what the consumer is aware of.
+// CHECK-C17: !DICompileUnit(language: DW_LANG_C11
+
+void f1(void) { }
Index: clang/test/CodeGen/debug-info-preprocessed-file.i
===
--- clang/test/CodeGen/debug-info-preprocessed-file.i
+++ clang/test/CodeGen/debug-info-preprocessed-file.i
@@ -7,5 +7,5 @@
 # 1 "preprocessed-input.c" 2
 
 // RUN: %clang -g -c -S -emit-llvm -o - %s | FileCheck %s
-// CHECK: !DICompileUnit(language: DW_LANG_C99, 

[PATCH] D138597: DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions

2022-12-06 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

This minimal patch LGTM.




Comment at: llvm/lib/IR/DIBuilder.cpp:159
 
-  assert(((Lang <= dwarf::DW_LANG_Fortran08 && Lang >= dwarf::DW_LANG_C89) ||
+  assert(((Lang <= dwarf::DW_LANG_Ada2012 && Lang >= dwarf::DW_LANG_C89) ||
   (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) 
&&

dblaikie wrote:
> aprantl wrote:
> > Should we define a DW_LANG_HI_DWARF in the .def file?
> Maybe? I'm not sure - if it has to explicitly write the constant or another 
> enum value in there, I think it's as liable to get missed when updating as 
> this code, perhaps? Open to ideas.
I guess this isn't important enough to spend too much time designing a solution 
for it. Let's leave it as is.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138597/new/

https://reviews.llvm.org/D138597

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138597: DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions

2022-12-05 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D138597#3966638 , @probinson wrote:

> One not-yet-asked question, does gcc produce the C++17/20 codes? If so, does 
> fstrict-dwarf affect that?

Looks like GCC uses C++17 for both 17 and 20: 
https://gcc.gnu.org/git/?p=gcc.git;a=commit;f=gcc/testsuite/g%2B%2B.dg/debug/dwarf2/lang-cpp17.C;h=a90606ab979762ce4630777c2fce5c921d0a2b96
 (apparently it used to use just C_plus_plus for 20: 
https://gcc.gnu.org/git/?p=gcc.git;a=commit;f=gcc/testsuite/g%2B%2B.dg/debug/dwarf2/lang-cpp17.C;h=a90606ab979762ce4630777c2fce5c921d0a2b96
 )

> The major consumers of this would be lldb (which we control) and gdb, so 
> following gcc's lead here would seem appropriate.  I can accept that listing 
> the codes on the website "counts" as in-spec for fstrict-dwarf purposes.

Yeah, I'm leaning towards just not implementing the v5 bonus codes - they're 
good for new languages, but for existing languages the risk of regression seems 
not worth the benefit.

I left the test cases in - easy to tweak them when we decide how to render this 
- and left some minor refactoring in that I could pull out/commit separately.

I still haven't heard from the internal user that seemed pretty adamant that 
expressing these newer versions was important... I can't really picture 
(relative to all the other debug info incompletenessess) why it would be 
especially important.




Comment at: llvm/lib/IR/DIBuilder.cpp:159
 
-  assert(((Lang <= dwarf::DW_LANG_Fortran08 && Lang >= dwarf::DW_LANG_C89) ||
+  assert(((Lang <= dwarf::DW_LANG_Ada2012 && Lang >= dwarf::DW_LANG_C89) ||
   (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) 
&&

aprantl wrote:
> Should we define a DW_LANG_HI_DWARF in the .def file?
Maybe? I'm not sure - if it has to explicitly write the constant or another 
enum value in there, I think it's as liable to get missed when updating as this 
code, perhaps? Open to ideas.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138597/new/

https://reviews.llvm.org/D138597

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138597: DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions

2022-12-05 Thread David Blaikie via Phabricator via cfe-commits
dblaikie updated this revision to Diff 480296.
dblaikie added a comment.

Don't use the since-v5-published codes


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138597/new/

https://reviews.llvm.org/D138597

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-programming-language.c
  clang/test/CodeGenCXX/debug-info-programming-language.cpp


Index: clang/test/CodeGenCXX/debug-info-programming-language.cpp
===
--- clang/test/CodeGenCXX/debug-info-programming-language.cpp
+++ clang/test/CodeGenCXX/debug-info-programming-language.cpp
@@ -4,6 +4,12 @@
 // RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s 
-o - \
 // RUN:   -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited \
 // RUN:   | FileCheck --check-prefix=CHECK-CPP14 %s
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s 
-o - \
+// RUN:   -x c++ -std=c++17 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   | FileCheck --check-prefix=CHECK-CPP17 %s
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s 
-o - \
+// RUN:   -x c++ -std=c++20 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   | FileCheck --check-prefix=CHECK-CPP20 %s
 // RUN: %clang_cc1 -dwarf-version=3 -gstrict-dwarf -emit-llvm -triple 
%itanium_abi_triple %s -o - \
 // RUN:   -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited 
| FileCheck %s
 // RUN: %clang_cc1 -dwarf-version=5 -gstrict-dwarf -emit-llvm -triple 
%itanium_abi_triple %s -o - \
@@ -14,5 +20,15 @@
   return 0;
 }
 
+// Update these tests once support for DW_LANG_C_plus_plus_17/20 is added - 
it's
+// a complicated tradeoff. The language codes are already published/blessed by
+// the DWARF committee, but haven't been released in a published standard yet,
+// so consumers might not be ready for these codes & could regress 
functionality
+// (because they wouldn't be able to identify that the language was C++). The
+// DWARFv6 language encoding, separating language from language version, would
+// remove this problem/not require new codes for new language versions and make
+// it possible to identify the base language irrespective of the version.
 // CHECK-CPP14: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14,
+// CHECK-CPP17: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14,
+// CHECK-CPP20: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14,
 // CHECK: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,
Index: clang/test/CodeGen/debug-info-programming-language.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-programming-language.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s 
-o - \
+// RUN:   -x c -std=c11 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   | FileCheck --check-prefix=CHECK-C11 %s
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s 
-o - \
+// RUN:   -x c -std=c17 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   | FileCheck --check-prefix=CHECK-C17 %s
+
+// CHECK-C11: !DICompileUnit(language: DW_LANG_C11
+// Update this check once support for DW_LANG_C17 is broadly supported/known in
+// consumers. Maybe we'll skip this and go to the DWARFv6 language+version
+// encoding that avoids the risk of regression when describing a language
+// version newer than what the consumer is aware of.
+// CHECK-C17: !DICompileUnit(language: DW_LANG_C11
+
+void f1(void) { }
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -526,7 +526,8 @@
 
   // Get absolute path name.
   SourceManager  = CGM.getContext().getSourceManager();
-  std::string MainFileName = CGM.getCodeGenOpts().MainFileName;
+  auto  = CGM.getCodeGenOpts();
+  std::string MainFileName = CGO.MainFileName;
   if (MainFileName.empty())
 MainFileName = "";
 
@@ -562,11 +563,11 @@
   if (LO.CPlusPlus) {
 if (LO.ObjC)
   LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus;
-else if (LO.CPlusPlus14 && (!CGM.getCodeGenOpts().DebugStrictDwarf ||
-CGM.getCodeGenOpts().DwarfVersion >= 5))
+else if (CGO.DebugStrictDwarf && CGO.DwarfVersion < 5)
+  LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
+else if (LO.CPlusPlus14)
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus_14;
-else if (LO.CPlusPlus11 && (!CGM.getCodeGenOpts().DebugStrictDwarf ||
-CGM.getCodeGenOpts().DwarfVersion >= 5))
+else if (LO.CPlusPlus11)
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus_11;
 else
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
@@ -577,6 +578,8 @@
 LangTag = llvm::dwarf::DW_LANG_OpenCL;
   } 

[PATCH] D138597: DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions

2022-12-05 Thread David Blaikie via Phabricator via cfe-commits
dblaikie updated this revision to Diff 480292.
dblaikie added a comment.

Rebase on top of committed LLVM changes


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138597/new/

https://reviews.llvm.org/D138597

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-programming-language.c
  clang/test/CodeGenCXX/debug-info-programming-language.cpp


Index: clang/test/CodeGenCXX/debug-info-programming-language.cpp
===
--- clang/test/CodeGenCXX/debug-info-programming-language.cpp
+++ clang/test/CodeGenCXX/debug-info-programming-language.cpp
@@ -4,6 +4,12 @@
 // RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s 
-o - \
 // RUN:   -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited \
 // RUN:   | FileCheck --check-prefix=CHECK-CPP14 %s
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s 
-o - \
+// RUN:   -x c++ -std=c++17 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   | FileCheck --check-prefix=CHECK-CPP17 %s
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s 
-o - \
+// RUN:   -x c++ -std=c++20 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   | FileCheck --check-prefix=CHECK-CPP20 %s
 // RUN: %clang_cc1 -dwarf-version=3 -gstrict-dwarf -emit-llvm -triple 
%itanium_abi_triple %s -o - \
 // RUN:   -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited 
| FileCheck %s
 // RUN: %clang_cc1 -dwarf-version=5 -gstrict-dwarf -emit-llvm -triple 
%itanium_abi_triple %s -o - \
@@ -15,4 +21,6 @@
 }
 
 // CHECK-CPP14: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14,
+// CHECK-CPP17: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_17,
+// CHECK-CPP20: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_20,
 // CHECK: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,
Index: clang/test/CodeGen/debug-info-programming-language.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-programming-language.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s 
-o - \
+// RUN:   -x c -std=c11 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   | FileCheck --check-prefix=CHECK-C11 %s
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s 
-o - \
+// RUN:   -x c -std=c17 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   | FileCheck --check-prefix=CHECK-C17 %s
+
+// CHECK-C11: !DICompileUnit(language: DW_LANG_C11
+// CHECK-C17: !DICompileUnit(language: DW_LANG_C17
+
+void f1(void) { }
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -526,7 +526,8 @@
 
   // Get absolute path name.
   SourceManager  = CGM.getContext().getSourceManager();
-  std::string MainFileName = CGM.getCodeGenOpts().MainFileName;
+  auto  = CGM.getCodeGenOpts();
+  std::string MainFileName = CGO.MainFileName;
   if (MainFileName.empty())
 MainFileName = "";
 
@@ -562,11 +563,15 @@
   if (LO.CPlusPlus) {
 if (LO.ObjC)
   LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus;
-else if (LO.CPlusPlus14 && (!CGM.getCodeGenOpts().DebugStrictDwarf ||
-CGM.getCodeGenOpts().DwarfVersion >= 5))
+else if (CGO.DebugStrictDwarf && CGO.DwarfVersion < 5)
+  LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
+else if (LO.CPlusPlus20)
+  LangTag = llvm::dwarf::DW_LANG_C_plus_plus_20;
+else if (LO.CPlusPlus17)
+  LangTag = llvm::dwarf::DW_LANG_C_plus_plus_17;
+else if (LO.CPlusPlus14)
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus_14;
-else if (LO.CPlusPlus11 && (!CGM.getCodeGenOpts().DebugStrictDwarf ||
-CGM.getCodeGenOpts().DwarfVersion >= 5))
+else if (LO.CPlusPlus11)
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus_11;
 else
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
@@ -577,6 +582,10 @@
 LangTag = llvm::dwarf::DW_LANG_OpenCL;
   } else if (LO.RenderScript) {
 LangTag = llvm::dwarf::DW_LANG_GOOGLE_RenderScript;
+  } else if (LO.C17) {
+LangTag = llvm::dwarf::DW_LANG_C17;
+  } else if (LO.C11) {
+LangTag = llvm::dwarf::DW_LANG_C11;
   } else if (LO.C99) {
 LangTag = llvm::dwarf::DW_LANG_C99;
   } else {


Index: clang/test/CodeGenCXX/debug-info-programming-language.cpp
===
--- clang/test/CodeGenCXX/debug-info-programming-language.cpp
+++ clang/test/CodeGenCXX/debug-info-programming-language.cpp
@@ -4,6 +4,12 @@
 // RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
 // RUN:   -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited \
 // RUN:   | FileCheck 

[PATCH] D138597: DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions

2022-12-02 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Agreeing with @probinson


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138597/new/

https://reviews.llvm.org/D138597

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138597: DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions

2022-12-02 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

One not-yet-asked question, does gcc produce the C++17/20 codes? If so, does 
fstrict-dwarf affect that?  The major consumers of this would be lldb (which we 
control) and gdb, so following gcc's lead here would seem appropriate.  I can 
accept that listing the codes on the website "counts" as in-spec for 
fstrict-dwarf purposes.

Deferring the v6 language attributes seems totally fair.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138597/new/

https://reviews.llvm.org/D138597

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138597: DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions

2022-12-01 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Don't know that I've got it in me right now to do the more invasive change of 
updating the LLVM DebugInfo IR metadata to carry the DWARFv6 style 
language+version stuff (perhaps especially if that's going to go alongside the 
DWARFv5 and earlier pure language encoding)

I could do the minimum and fix the C version case to use the DWARFv5-shipped 
C11 encoding. And perhaps add the post-v5 backported language encodings to LLVM 
so at least llvm-dwarfdump can detect/render/handle them correctly for name 
printing, etc.

Or I could maybe do something in between - where the post-v5 backported 
language codes could be used in the IR and then LLVM could detect those and 
remap them to v5-shipped DW_AT_language + v6-not-ready-yet (using an extension 
form? Using the form that's not shipped in v6 yet?) attributes?

Seems like it's probably not worth emitting the v6 stuff until it's baked. And 
not worth emitting the post-v5 backported attributes due to risk of breakage? 
So maybe just do the minimum?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138597/new/

https://reviews.llvm.org/D138597

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138597: DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions

2022-12-01 Thread David Blaikie via Phabricator via cfe-commits
dblaikie updated this revision to Diff 479499.
dblaikie added a comment.

Add llvm testing (but I'm going to rework this a lot, so this is just a 
snapshot for history)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138597/new/

https://reviews.llvm.org/D138597

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-programming-language.c
  clang/test/CodeGenCXX/debug-info-programming-language.cpp
  llvm/include/llvm-c/DebugInfo.h
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/BinaryFormat/Dwarf.h
  llvm/lib/IR/DIBuilder.cpp
  llvm/test/DebugInfo/X86/assumed_size_array.ll
  llvm/test/DebugInfo/X86/dwarf-public-names.ll

Index: llvm/test/DebugInfo/X86/dwarf-public-names.ll
===
--- llvm/test/DebugInfo/X86/dwarf-public-names.ll
+++ llvm/test/DebugInfo/X86/dwarf-public-names.ll
@@ -4,6 +4,24 @@
 ; RUN: llvm-dwarfdump -debug-pubnames %t.o | FileCheck --check-prefix=NOPUB %s
 ; RUN: llc -mtriple=x86_64-scei-ps4 -filetype=obj -o %t.o < %s
 ; RUN: llvm-dwarfdump -debug-pubnames %t.o | FileCheck --check-prefix=NOPUB %s
+
+; RUN: rm -rf %t
+; RUN: mkdir %t
+; RUN: sed -e "s/C_plus_plus/C_plus_plus_03/" %s > %t/test.ll
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -filetype=obj -o %t/test.o < %t/test.ll
+; RUN: llvm-dwarfdump -debug-pubnames %t/test.o | FileCheck --check-prefix=LINUX %s
+; RUN: sed -e "s/C_plus_plus/C_plus_plus_11/" %s > %t/test.ll
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -filetype=obj -o %t/test.o < %t/test.ll
+; RUN: llvm-dwarfdump -debug-pubnames %t/test.o | FileCheck --check-prefix=LINUX %s
+; RUN: sed -e "s/C_plus_plus/C_plus_plus_14/" %s > %t/test.ll
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -filetype=obj -o %t/test.o < %t/test.ll
+; RUN: llvm-dwarfdump -debug-pubnames %t/test.o | FileCheck --check-prefix=LINUX %s
+; RUN: sed -e "s/C_plus_plus/C_plus_plus_17/" %s > %t/test.ll
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -filetype=obj -o %t/test.o < %t/test.ll
+; RUN: llvm-dwarfdump -debug-pubnames %t/test.o | FileCheck --check-prefix=LINUX %s
+; RUN: sed -e "s/C_plus_plus/C_plus_plus_20/" %s > %t/test.ll
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -filetype=obj -o %t/test.o < %t/test.ll
+; RUN: llvm-dwarfdump -debug-pubnames %t/test.o | FileCheck --check-prefix=LINUX %s
 ; ModuleID = 'dwarf-public-names.cpp'
 ;
 ; Generated from:
Index: llvm/test/DebugInfo/X86/assumed_size_array.ll
===
--- llvm/test/DebugInfo/X86/assumed_size_array.ll
+++ llvm/test/DebugInfo/X86/assumed_size_array.ll
@@ -3,6 +3,11 @@
 
 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu %s -filetype=obj -o %t.o
 ; RUN: llvm-dwarfdump  %t.o | FileCheck %s
+; RUN: rm -rf %t
+; RUN: mkdir %t
+; RUN: sed -e "s/Fortran90/Fortran18/" %s > %t/test.ll
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu %t/test.ll -filetype=obj -o %t/test.o
+; RUN: llvm-dwarfdump  %t/test.o | FileCheck %s
 
 ; CHECK-LABEL: DW_TAG_formal_parameter
 ; CHECK: DW_AT_name("array1")
Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -156,7 +156,7 @@
 DICompileUnit::DebugNameTableKind NameTableKind, bool RangesBaseAddress,
 StringRef SysRoot, StringRef SDK) {
 
-  assert(((Lang <= dwarf::DW_LANG_Fortran08 && Lang >= dwarf::DW_LANG_C89) ||
+  assert(((Lang <= dwarf::DW_LANG_Ada2012 && Lang >= dwarf::DW_LANG_C89) ||
   (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
  "Invalid Language tag");
 
Index: llvm/include/llvm/BinaryFormat/Dwarf.h
===
--- llvm/include/llvm/BinaryFormat/Dwarf.h
+++ llvm/include/llvm/BinaryFormat/Dwarf.h
@@ -216,6 +216,8 @@
   case DW_LANG_C_plus_plus_03:
   case DW_LANG_C_plus_plus_11:
   case DW_LANG_C_plus_plus_14:
+  case DW_LANG_C_plus_plus_17:
+  case DW_LANG_C_plus_plus_20:
 result = true;
 break;
   case DW_LANG_C89:
@@ -256,6 +258,13 @@
   case DW_LANG_BORLAND_Delphi:
   case DW_LANG_lo_user:
   case DW_LANG_hi_user:
+  case DW_LANG_Kotlin:
+  case DW_LANG_Zig:
+  case DW_LANG_Crystal:
+  case DW_LANG_C17:
+  case DW_LANG_Fortran18:
+  case DW_LANG_Ada2005:
+  case DW_LANG_Ada2012:
 result = false;
 break;
   }
@@ -274,6 +283,7 @@
   case DW_LANG_Fortran95:
   case DW_LANG_Fortran03:
   case DW_LANG_Fortran08:
+  case DW_LANG_Fortran18:
 result = true;
 break;
   case DW_LANG_C89:
@@ -313,6 +323,14 @@
   case DW_LANG_BORLAND_Delphi:
   case DW_LANG_lo_user:
   case DW_LANG_hi_user:
+  case DW_LANG_Kotlin:
+  case DW_LANG_Zig:
+  case DW_LANG_Crystal:
+  case DW_LANG_C_plus_plus_17:
+  case DW_LANG_C_plus_plus_20:
+  case DW_LANG_C17:
+  case DW_LANG_Ada2005:
+  case DW_LANG_Ada2012:
 result = false;
 break;
   }
Index: llvm/include/llvm/BinaryFormat/Dwarf.def

[PATCH] D138597: DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions

2022-11-29 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

> @aprantl do you have an opinion on this? I tend to lean to the pedantic side 
> on this kind of thing, but I'm persuadable.

As long as LLDB can deal with it I'm fine either way.
Emitting the separated DWARF 6 attribute as an extension sounds fine to me.




Comment at: llvm/lib/IR/DIBuilder.cpp:159
 
-  assert(((Lang <= dwarf::DW_LANG_Fortran08 && Lang >= dwarf::DW_LANG_C89) ||
+  assert(((Lang <= dwarf::DW_LANG_Ada2012 && Lang >= dwarf::DW_LANG_C89) ||
   (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) 
&&

Should we define a DW_LANG_HI_DWARF in the .def file?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138597/new/

https://reviews.llvm.org/D138597

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138597: DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions

2022-11-29 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

> They're published on the website too: https://dwarfstd.org/LanguagesV6.php

(sigh) sorry, distracted by other things today.

Yeah, using the v6 codes with the v6 attributes for the new ones WFM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138597/new/

https://reviews.llvm.org/D138597

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138597: DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions

2022-11-29 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

>>> @aprantl do you have an opinion on this?  I tend to lean to the pedantic 
>>> side on this kind of thing, but I'm persuadable.
>>
>> Yeah, I've certainly got mixed feelings - maybe we don't pick up these 
>> after-release language codes, and instead produce the new language encoding 
>> (which separates language from version) as an extension, alongside the 
>> old/in-the-dwarfv5-spec-document codes? So that a DWARFv5 consumer that 
>> contains only the DWARFv5-spec-document functionality and not the new codes, 
>> and a newer consumer can read the new parts.
>
> Except the new LNAME codes aren't 1-1 with the old codes

I'm not sure that'd be a problem? They're in different attributes, etc, such 
that they wouldn't be read by an old consumer without explicit support for them.

> and aren't published anywhere.

They're published on the website too: https://dwarfstd.org/LanguagesV6.php


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138597/new/

https://reviews.llvm.org/D138597

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138597: DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions

2022-11-29 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

In D138597#3957356 , @dblaikie wrote:

> In D138597#3954269 , @probinson 
> wrote:
>
>> The codes have been allocated but AFAICT the website doesn't have the new 
>> codes listed (I looked at 
>> http://wiki.dwarfstd.org/index.php/DWARF_Language_Support which doesn't even 
>> have all the v5 codes yet).
>
> I think they're up here: https://dwarfstd.org/Languages.php (linked from the 
> dwarfstd.org front page "DWARF V5 Language Codes and Requests")

Oh, thanks.  I had it in my head they were on the wiki, but being on the main 
site is better.

>> @aprantl do you have an opinion on this?  I tend to lean to the pedantic 
>> side on this kind of thing, but I'm persuadable.
>
> Yeah, I've certainly got mixed feelings - maybe we don't pick up these 
> after-release language codes, and instead produce the new language encoding 
> (which separates language from version) as an extension, alongside the 
> old/in-the-dwarfv5-spec-document codes? So that a DWARFv5 consumer that 
> contains only the DWARFv5-spec-document functionality and not the new codes, 
> and a newer consumer can read the new parts.

Except the new LNAME codes aren't 1-1 with the old codes and aren't published 
anywhere. Well, except in the issue resolution, I guess, but that's not 
definitive (subject to change until DWARF 6 is published).  I'm not sure which 
way to go here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138597/new/

https://reviews.llvm.org/D138597

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138597: DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions

2022-11-29 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D138597#3954269 , @probinson wrote:

> Hmmm I might be inclined to emit 17 and 20 only under not-strict-DWARF for 
> v5, although it makes the logic more complicated.  The codes have been 
> allocated but AFAICT the website doesn't have the new codes listed (I looked 
> at http://wiki.dwarfstd.org/index.php/DWARF_Language_Support which doesn't 
> even have all the v5 codes yet).

I think they're up here: https://dwarfstd.org/Languages.php (linked from the 
dwarfstd.org front page "DWARF V5 Language Codes and Requests")

> @aprantl do you have an opinion on this?  I tend to lean to the pedantic side 
> on this kind of thing, but I'm persuadable.

Yeah, I've certainly got mixed feelings - maybe we don't pick up these 
after-release language codes, and instead produce the new language encoding 
(which separates language from version) as an extension, alongside the 
old/in-the-dwarfv5-spec-document codes? So that a DWARFv5 consumer that 
contains only the DWARFv5-spec-document functionality and not the new codes, 
and a newer consumer can read the new parts.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138597/new/

https://reviews.llvm.org/D138597

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138597: DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions

2022-11-28 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

Hmmm I might be inclined to emit 17 and 20 only under not-strict-DWARF for v5, 
although it makes the logic more complicated.  The codes have been allocated 
but AFAICT the website doesn't have the new codes listed (I looked at 
http://wiki.dwarfstd.org/index.php/DWARF_Language_Support which doesn't even 
have all the v5 codes yet).  @aprantl do you have an opinion on this?  I tend 
to lean to the pedantic side on this kind of thing, but I'm persuadable.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138597/new/

https://reviews.llvm.org/D138597

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138597: DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions

2022-11-23 Thread David Blaikie via Phabricator via cfe-commits
dblaikie created this revision.
dblaikie added reviewers: aprantl, probinson.
Herald added a reviewer: deadalnix.
Herald added a subscriber: hiraditya.
Herald added a project: All.
dblaikie requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This may be a breaking change for consumers if they're trying to detect
if code is C or C++, since it'll start using new codes that they may not
be ready to recognize, in which case they may fall back to non-C
handling.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138597

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-programming-language.c
  clang/test/CodeGenCXX/debug-info-programming-language.cpp
  llvm/include/llvm-c/DebugInfo.h
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/BinaryFormat/Dwarf.h
  llvm/lib/IR/DIBuilder.cpp

Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -156,7 +156,7 @@
 DICompileUnit::DebugNameTableKind NameTableKind, bool RangesBaseAddress,
 StringRef SysRoot, StringRef SDK) {
 
-  assert(((Lang <= dwarf::DW_LANG_Fortran08 && Lang >= dwarf::DW_LANG_C89) ||
+  assert(((Lang <= dwarf::DW_LANG_Ada2012 && Lang >= dwarf::DW_LANG_C89) ||
   (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
  "Invalid Language tag");
 
Index: llvm/include/llvm/BinaryFormat/Dwarf.h
===
--- llvm/include/llvm/BinaryFormat/Dwarf.h
+++ llvm/include/llvm/BinaryFormat/Dwarf.h
@@ -216,6 +216,8 @@
   case DW_LANG_C_plus_plus_03:
   case DW_LANG_C_plus_plus_11:
   case DW_LANG_C_plus_plus_14:
+  case DW_LANG_C_plus_plus_17:
+  case DW_LANG_C_plus_plus_20:
 result = true;
 break;
   case DW_LANG_C89:
@@ -256,6 +258,13 @@
   case DW_LANG_BORLAND_Delphi:
   case DW_LANG_lo_user:
   case DW_LANG_hi_user:
+  case DW_LANG_Kotlin:
+  case DW_LANG_Zig:
+  case DW_LANG_Crystal:
+  case DW_LANG_C17:
+  case DW_LANG_Fortran18:
+  case DW_LANG_Ada2005:
+  case DW_LANG_Ada2012:
 result = false;
 break;
   }
@@ -274,6 +283,7 @@
   case DW_LANG_Fortran95:
   case DW_LANG_Fortran03:
   case DW_LANG_Fortran08:
+  case DW_LANG_Fortran18:
 result = true;
 break;
   case DW_LANG_C89:
@@ -313,6 +323,14 @@
   case DW_LANG_BORLAND_Delphi:
   case DW_LANG_lo_user:
   case DW_LANG_hi_user:
+  case DW_LANG_Kotlin:
+  case DW_LANG_Zig:
+  case DW_LANG_Crystal:
+  case DW_LANG_C_plus_plus_17:
+  case DW_LANG_C_plus_plus_20:
+  case DW_LANG_C17:
+  case DW_LANG_Ada2005:
+  case DW_LANG_Ada2012:
 result = false;
 break;
   }
Index: llvm/include/llvm/BinaryFormat/Dwarf.def
===
--- llvm/include/llvm/BinaryFormat/Dwarf.def
+++ llvm/include/llvm/BinaryFormat/Dwarf.def
@@ -915,11 +915,22 @@
 HANDLE_DW_LANG(0x0023, Fortran08, 1, 5, DWARF)
 HANDLE_DW_LANG(0x0024, RenderScript, 0, 5, DWARF)
 HANDLE_DW_LANG(0x0025, BLISS, 0, 5, DWARF)
+// New since DWARF v5:
+HANDLE_DW_LANG(0x0026, Kotlin, 0, 0, DWARF)
+HANDLE_DW_LANG(0x0027, Zig, 0, 0, DWARF)
+HANDLE_DW_LANG(0x0028, Crystal, 0, 0, DWARF)
+HANDLE_DW_LANG(0x002a, C_plus_plus_17, 0, 0, DWARF)
+HANDLE_DW_LANG(0x002b, C_plus_plus_20, 0, 0, DWARF)
+HANDLE_DW_LANG(0x002c, C17, 0, 0, DWARF)
+HANDLE_DW_LANG(0x002d, Fortran18, 0, 0, DWARF)
+HANDLE_DW_LANG(0x002e, Ada2005, 0, 0, DWARF)
+HANDLE_DW_LANG(0x002f, Ada2012, 0, 0, DWARF)
 // Vendor extensions:
 HANDLE_DW_LANG(0x8001, Mips_Assembler, None, 0, MIPS)
 HANDLE_DW_LANG(0x8e57, GOOGLE_RenderScript, 0, 0, GOOGLE)
 HANDLE_DW_LANG(0xb000, BORLAND_Delphi, 0, 0, BORLAND)
 
+
 // DWARF attribute type encodings.
 HANDLE_DW_ATE(0x01, address, 2, DWARF)
 HANDLE_DW_ATE(0x02, boolean, 2, DWARF)
Index: llvm/include/llvm-c/DebugInfo.h
===
--- llvm/include/llvm-c/DebugInfo.h
+++ llvm/include/llvm-c/DebugInfo.h
@@ -116,6 +116,15 @@
   LLVMDWARFSourceLanguageFortran08,
   LLVMDWARFSourceLanguageRenderScript,
   LLVMDWARFSourceLanguageBLISS,
+  LLVMDWARFSourceLanguageKotlin,
+  LLVMDWARFSourceLanguageZig,
+  LLVMDWARFSourceLanguageCrystal,
+  LLVMDWARFSourceLanguageC_plus_plus_17,
+  LLVMDWARFSourceLanguageC_plus_plus_20,
+  LLVMDWARFSourceLanguageC17,
+  LLVMDWARFSourceLanguageFortran18,
+  LLVMDWARFSourceLanguageAda2005,
+  LLVMDWARFSourceLanguageAda2012,
   // Vendor extensions:
   LLVMDWARFSourceLanguageMips_Assembler,
   LLVMDWARFSourceLanguageGOOGLE_RenderScript,
Index: clang/test/CodeGenCXX/debug-info-programming-language.cpp
===
--- clang/test/CodeGenCXX/debug-info-programming-language.cpp
+++ clang/test/CodeGenCXX/debug-info-programming-language.cpp
@@ -4,6 +4,12 @@
 // RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
 //