Skip to content

Commit bc3bb20

Browse files
committed
[Verifier] Set CurrentSourceLang in visitDISubprogram too.
When visiting metadata attached to DISubprogram, it was possible to read `CurrentSourceLang` before `visitDICompileUnit` has a chance to set it to proper value. This happened because `Type` is processed before `Unit` because of the order of the metadata in DISubprogram. My initial fix was to change the order. But @jmorse suggested setting `CurrentSourceLang` in `visitDISubprogram` which eliminates the need for changing the order of metadata fields.
1 parent 694679c commit bc3bb20

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

llvm/lib/IR/Verifier.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,6 +1494,8 @@ void Verifier::visitDISubprogram(const DISubprogram &N) {
14941494
CheckDI(N.isDistinct(), "subprogram definitions must be distinct", &N);
14951495
CheckDI(Unit, "subprogram definitions must have a compile unit", &N);
14961496
CheckDI(isa<DICompileUnit>(Unit), "invalid unit type", &N, Unit);
1497+
if (auto *CU = dyn_cast_or_null<DICompileUnit>(Unit))
1498+
CurrentSourceLang = (dwarf::SourceLanguage)CU->getSourceLanguage();
14971499
// There's no good way to cross the CU boundary to insert a nested
14981500
// DISubprogram definition in one CU into a type defined in another CU.
14991501
auto *CT = dyn_cast_or_null<DICompositeType>(N.getRawScope());

0 commit comments

Comments
 (0)