[cfe-dev] Given 2 undefined identifiers like `FUNC1(ARG1); ` ARG1 is reported undeclared, not FUNC1

xftroxgpx via cfe-dev cfe-dev at lists.llvm.org
Tue Sep 19 01:02:02 PDT 2017


Hello.

$ echo 'int main () { FUNC1(ARG1); }' >/tmp/really.cc |clang /tmp/really.cc
/tmp/really.cc:1:21: error: use of undeclared identifier 'ARG1'
int main () { FUNC1(ARG1); }
                    ^
1 error generated.

Is there a way to tell clang to error because of FUNC1 not being defined, instead of because of ARG1 ?

I'm on ArchLinux, using:
$ clang --version
clang version 5.0.0 (tags/RELEASE_500/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

The problem:
Currently, the way clang reports the above error, it requires me to look into the source code to see which one is FUNC1, as per the following real world example:

The error is:

../../../home/xftroxgpx/build/1packages/chro/4_chromium-dev-git/fetch_gclient_base/checkout_root/src/ui/events/gesture_detection/motion_event_buffer.cc:189:28: error: use of undeclared identifier 'TRACE_EVENT_SCOPE_THREAD'
                           TRACE_EVENT_SCOPE_THREAD,
                           ^
1 error generated.

The code is:

    if (resample_time > max_predict) {
      TRACE_EVENT_INSTANT2("input",
                           "MotionEventBuffer::TryResample prediction adjust",
                           TRACE_EVENT_SCOPE_THREAD,     //this is line 189
                           "original(ms)",
                           (resample_time - time1).InMilliseconds(),
                           "adjusted(ms)",
                           (max_predict - time1).InMilliseconds());
      resample_time = max_predict;
    }

thus FUNC1 is TRACE_EVENT_INSTANT2
and ARG1 is the one reported as TRACE_EVENT_SCOPE_THREAD

Obviously both are undefined, but I would really expect clang to let me know that FUNC1 is undefined(first).

Cheers!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170919/df151782/attachment.html>


More information about the cfe-dev mailing list