[cfe-dev] Fwd: [LibTooling] Unable to parse cpp code when using libtooling feature

Aditya Atluri via cfe-dev cfe-dev at lists.llvm.org
Fri Jan 11 11:02:22 PST 2019


Hi,
I am a novice developer hacking around ways to use clang for parsing C/CPP
code.

I am able to parse C code with clangs libtooling feature properly. But,
when I use the code to parse CPP test code, I am getting the following
error:

$ ./Main

test.cpp:1:1: error: unknown type name 'template'

template<typename T>

^

test.cpp:1:9: error: expected identifier or '('

template<typename T>

        ^

test.cpp:6:19: error: expected expression

    float c = add<float>(a, b);

                  ^

test.cpp:6:15: error: use of undeclared identifier 'add'

    float c = add<float>(a, b);

              ^


Attached: Main.mk (to build test), Main.cpp (Clang 8.0 based libtooling
source), test.cpp (test case)

Please let me know if I am doing anything bad or missing something.
The Makefile assumes that clang is installed in ~/llvm80
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190111/20ec6f40/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Main.cpp
Type: text/x-c-code
Size: 3186 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190111/20ec6f40/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.cpp
Type: text/x-c-code
Size: 159 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190111/20ec6f40/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Main.mk
Type: application/octet-stream
Size: 933 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190111/20ec6f40/attachment.obj>


More information about the cfe-dev mailing list