aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorMarkus Böck <markus.boeck02@gmail.com>2023-09-04 18:19:18 +0200
committerGitHub <noreply@github.com>2023-09-04 18:19:18 +0200
commitb121c266744d030120c59e6256559cbccacd3c6f (patch)
treef2c280fd1e95dc2785de958d9d3bd6f4afbff34b /clang/lib/Frontend/CompilerInvocation.cpp
parent8031a088eb404ccd7490a589ecaa0fb76e73d2ef (diff)
downloadllvm-b121c266744d030120c59e6256559cbccacd3c6f.zip
llvm-b121c266744d030120c59e6256559cbccacd3c6f.tar.gz
llvm-b121c266744d030120c59e6256559cbccacd3c6f.tar.bz2
[mlir] Add helper method to print and parse cyclic attributes and types (#65210)
Printing cyclic attributes and types currently has no first-class support within the AsmPrinter and AsmParser. The workaround for this issue used in all mutable attributes and types upstream has been to create a `thread_local static SetVector` keeping track of currently parsed and printed attributes. This solution is not ideal readability wise due to the use of globals and keeping track of state. Worst of all, this pattern had to be reimplemented for every mutable attribute and type. This patch therefore adds support for this pattern in `AsmPrinter` and `AsmParser` replacing the use of this pattern. By calling `tryStartCyclingPrint/Parse`, the mutable attribute or type are registered in an internal stack. All subsequent calls to the function with the same attribute or type will lead to returning failure. This way the nesting can be detected and a short form printed or parsed instead. Through the resetter returned by the call, the cyclic printing or parsing region automatically ends on return.
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions