Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Using macro for file and line for lttng tracepoint gives error: expected expression #35989

Open Quuxplusone opened 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR37016
Status NEW
Importance P enhancement
Reported by Daniel Persson (daniel6651@gmail.com)
Reported on 2018-04-05 07:09:15 -0700
Last modified on 2019-01-09 06:18:59 -0800
Version unspecified
Hardware PC Linux
CC alexfh@google.com, djasper@google.com, klimek@google.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Using a macro for file and line as below generates an error:

myfile1.cc:461:9: error: expected expression [clang-diagnostic-error]
        MY_DEBUG(com_XXX, "YYY");
        ^
lttng_helper.h:31:65: note: expanded from macro 'MY_DEBUG'
      do_tracepoint(provider, S_debug, msg_lttng_helper_unique, TP_FILE_AND_LINE);            \
                                                                ^
lttng_helper.h:21:27: note: expanded from macro 'TP_FILE_AND_LINE'
#define TP_FILE_AND_LINE (__FILENAME__ ":" TP_TOSTRING(__LINE__))

Changing the line TP_FILE_AND_LINE to some dummy value like

#define TP_FILE_AND_LINE "Hi"

removes the error.

Adding // NOLINT after the line doesn't help as I would have expected.
Neither does surrounding it with #ifndef __clang-analyzer__ ... #else ... #endif

>clang-tidy -version
LLVM (http://llvm.org/):
  LLVM version 4.0.0
  Optimized build.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: sandybridge
Quuxplusone commented 5 years ago

Does the same code compile with clang? Does clang-tidy use the same command line arguments as clang does? Please provide an isolated test case and instructions to reproduce the issue.