In my code (either C or C++; let's say it's C++) I have a one-liner inline function foo()
which gets called from many places in the code. I'm using a profiling tool which gathers statistics by line in the object code, which it translates into statistics by using the source-code-line information (which we get with -g
in clang or GCC). Thus the profiler can't distinguish between calls to foo()
from different places.
I would like the stats to be counted separately for the different places foo()
get called. For this to happen, I need the compiler to "fully" inline foo()
- including forgetting about it when it comes to the source location information.
Now, I know I can achieve this by using a macro - that way, there is no function, and the code is just pasted where I use it. But that wont work for operators, for example; and it may be a problem with templates. So, can I tell the compiler to do what I described?
Notes:
- Compiler-specific answers are relevant; I'm mainly interested in GCC and clang.
- I'm not compiling a debug build, i.e. optimizations are turned on.