Skip to content

Conversation

zasdfgbnm
Copy link
Collaborator

@zasdfgbnm zasdfgbnm commented Mar 7, 2023

Example usage:

void my_func(Expr* expr, int i) {
  // This is the only line you need to add
  // Arguments are not required. If you don't want to print arguments, simply don't put them here
  DebugPrintScope g("my_func", expr, i);
  // Below are the original code
  if (i == 0) {
    return;
  }
  auto result = do_something(expr, i);
  if (result) {
    return;
  }
  do_something_else(expr, i);
}

@zasdfgbnm zasdfgbnm requested a review from naoyam March 7, 2023 22:46
@naoyam
Copy link
Collaborator

naoyam commented Mar 8, 2023

Looks useful. How about using a macro to provide a function name automatically?

E.g.,

#define DEBUG_PRINT_SCOPE(...) DebugPrintScope _debug_print_scope(__func__, _VA_ARGS_)

@zasdfgbnm
Copy link
Collaborator Author

#define DEBUG_PRINT_SCOPE(...) DebugPrintScope _debug_print_scope(func, VA_ARGS)

Good suggestion! Added

@zasdfgbnm zasdfgbnm merged commit a86f9b0 into devel Mar 8, 2023
@zasdfgbnm zasdfgbnm deleted the DebugPrintScope branch March 8, 2023 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants