[PATCH] D61015: [LibTooing] Change Transformer's TextGenerator to a partial function.
Yitzhak Mandelbaum via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 25 09:14:57 PDT 2019
ymandel added a comment.
In D61015#1478586 <https://reviews.llvm.org/D61015#1478586>, @ilya-biryukov wrote:
> I'd argue it's the server's job to validate the inputs in that case.
> The code that landed so far clearly looks like a C++ DSL to describe transformations of the source. While it **can** be used a dependency in the server-side, I don't see why doing user-input checking should be done by the library, rather than the server itself.
> User input would have to be transformed into the calls of the C++ API somehow, that looks like a proper layer to do the validation.
The problem is that validation can't* be done in the abstract. It has to be done with respect to a specific match result. Unfortunately, the server won't be layered directly on top of the call to the TextGenerator -- the rewrite rule is interposed between them. That is, the client of the TG is the rewriterule and that's where the validation has to happen, but the TG is opaque to the rewrite rule, so it can't hardcode that validation logic. So, we'd need to change `TextGenerator` to bundle a validation function and string generator. Is it still worth it in that case?
*"can't" is a bit strong. I could imagine a design which allows full analysis and validation of rewrite rules before they are executed, but it would be far more sophisticated than the current design.
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
More information about the cfe-commits