This is an archive of the discontinued LLVM Phabricator instance.

[TableGen] Allow references to class template arguments in defvar
ClosedPublic

Authored by pcwang-thead on Apr 13 2023, 12:10 AM.

Details

Summary

We can't refer to template arguments for defvar statements in class
definitions, or it will report some errors like:

error: Variable not defined: 'xxx'.

The key point here is we used to pass nullptr to ParseValue in
ParseDefvar. As a result, we can't refer to template arguments
since CurRec is nullptr in ParseIDValue.

So we add an argument CurRec to ParseDefvar and provide it
when parsing defvar statements in class definitions.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2023, 12:10 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
pcwang-thead requested review of this revision.Apr 13 2023, 12:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2023, 12:10 AM
simon_tatham accepted this revision.Apr 13 2023, 1:27 AM

And in all the other cases of ParseDefvar, the default nullptr parameter is used, so everything still behaves the same in contexts that aren't a class definition? Seems reasonable to me!

This revision is now accepted and ready to land.Apr 13 2023, 1:27 AM

And in all the other cases of ParseDefvar, the default nullptr parameter is used, so everything still behaves the same in contexts that aren't a class definition? Seems reasonable to me!

Yes! I think it will be more intuitive in this way.

tra accepted this revision.Apr 13 2023, 12:32 PM
This revision was landed with ongoing or failed builds.Apr 13 2023, 8:17 PM
This revision was automatically updated to reflect the committed changes.