[llvm-dev] TableGen assertion mechanism

Jan Svoboda via llvm-dev llvm-dev at lists.llvm.org
Tue Dec 15 07:35:49 PST 2020


I'm currently working on the TableGen definitions of Clang command-line options.

One place where an assertion would be handy is the multiclass that generates the positive and negative flag from a base string, e.g.: "access-control" => "-faccess-control", "-fno-access-control". Users of the multiclass may get confused about the semantics and accidentally pass base string that already contains the "no-" prefix, resulting in incorrect flag names: "no-access-control" => "-fno-access-control", "-fno-no-access-control". This actually happens: <https://reviews.llvm.org/D93104 <https://reviews.llvm.org/D93104>>. If we could do something like "assert !not(!strstartswith(name, "no-"));", we could prevent these types of bugs.

Another place this would be useful is in the BoolOptionBase multiclass (clang/include/clang/Driver/Options.td). The use-cases are decribed in TODOs.

I'm not sure how to implement something like this. So far, I've looked into the implementation of conditions, which might be a good starting point <https://reviews.llvm.org/D71474 <https://reviews.llvm.org/D71474>>.

> On Dec 15, 2020, at 3:15 PM, Paul C. Anagnostopoulos via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> I have been thinking about an assertion feature, but it is difficult to figure out when assertions can be performed. Can you give me one or two specific examples of what you want to check?
> 
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201215/ad17e587/attachment.html>


More information about the llvm-dev mailing list