Adding a New Pragma Approx Computation: Error on Parser


I’m from the UTFPR university in Brazil. We are currently working on adding a new pragma for approximated computation. At the moment, we have implemented a custom skeleton based on this repository: clang-custom-pragma.

However, I’m encountering a problem specifically when I reach the ‘funct’ pragma in the code. Here’s an example snippet:

#include <stdio.h>

void foo(int arg) {
    printf("Testing: %d\n", arg);

int main() {
    #pragma clang utfpr main 20
    printf("%d\n", 10);

    #pragma clang utfpr funct foo 15

    return 0;

When I attempt to generate the IR using the command “clang -S -emit-llvm,” I receive the following error message:

testing2.c:10:16: error: 'utfpr' attribute requires exactly 3 arguments
    #pragma clang utfpr funct foo 15
1 error generated.

I’m unsure why this error is occurring, as I have successfully added the “#pragma clang main” directive. Could you please guide me on where I can modify the number of arguments required for the pragma?

Thank you, Victor Briganti

Here is the link to the code on the UTFPR branch of the llvm-project repository.

I discover the error is in the file.
It’s define as:

def UTFPR : Attr {
  let Spellings = [Pragma<"clang", "utfpr">];
  let Args = [EnumArgument<"Option", "OptionType",
                          ["main", "funct"],
                          ["Main", "Funct"]>,
              ExprArgument<"ValueF">, ExprArgument<"Value">];
  let AdditionalMembers = [{
    static const char *getOptionName(int Option) {
      switch(Option) {
        case Main: return "main";
        case Funct: return "funct";
      llvm_unreachable("Unhandled UTFPR option.");
    void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
  let Documentation = [UTFPRDocs];

There is an error regarding the number of arguments in the let Args statement. It should receive three arguments: utfpr, main, and the number. I’m still unclear about something. Why does it receive utfpr first? Shouldn’t it start with main and the number? Additionally, I’m wondering how I can utilize this attribute to work with the funct as well.