building a parser with clang - clang

I need to build an AST using clang and the only tutorials that I found are vague and two years out of date. Could anybody point me to an example?

There are several tutorial available that demonstrate the use of the Preprocessor class and how to build an AST:
A CLang tutorial (a bit outdated but with a lot of explanation)
Code samples

Related

Why clang documentation doesn't contain information on a lot of options?

At work, I work on a C++ program which uses Cmake. In the top-level CMakeLists.txt, the CMAKE_CXX_FLAGS_DEBUG flag is set for Clang to input the different flags we want for the compilation.
My problem is that I see previous developers on the project put a lot of compilation options I don't understand for clang and I don't find them in the documentation... I don't understand why they aren't documented ! Moreover, I really wonder how the previous developers had the idea to put them in the code if they couldn't find them in the official documentation !
Here is a few examples of flags I couldn't find in the documentation :
-Wno-covered-switch-default
-Wno-exit-time-destructors
-Wno-padded
-Wweak-vtables

I need help to build ERC-721 contract with solidity version 5.0 or higher

I am trying to write a contract with ERC-721 token system. I have experience with ERC-20, so I thought I can find a tutorial and follow the tutorial. However, tutorials I found are based on solidity version between 4.0~4.2. Nowadays we use 5.0~6.0. Therefore tutorial codes are not working. Is there any tutorial, or code can I look and learn? HELP!
I tried to fix the code, and make suitable for 5.0 or higher, but I failed.
Therefore I tried to downgrade solidity and use docker but still get
Error: CompileError: ParsedContract.sol:3:1: ParserError: Source
"zeppelin-solidity/contracts/token/ERC721/ERC721Token.sol" not found:
Unknown exception in read callback. import
'zeppelin-solidity/contracts/token/ERC721/ERC721Token.sol'; this
error. :(
+
I found https://github.com/OpenZeppelin/openzeppelin-solidity , this but I do not know how to write test. Thank you for your time to read this !.
due to renaming, ERC721Token.sol is no longer available in the latest version of OpenZeppelin v2.3.0. change ERC721Token.sol to ERC721.sol, and it should work.
I suggest you have a look at the OpenZeppelin documentation:
https://docs.openzeppelin.org/v2.3.0/tokens#erc721
If you have more questions about OpenZeppelin you can always ask in the community forum
I can put together a sample contract in the community forum if you need.

Latex (String formula to Image) for IOS

I've done my math application for Android.
I use JLatex Library to convert math expressions to Bitmap.
I have a lot of predefined strings with math expressions (in my crossplatform C++ core).
Now I'm working on IOS version. I want to use that core here.
But I face with Latex problem.
Are there JLatex alternatives for IOS?
I've found some Libraries, but syntax isn't the same...
Syntax of JLatex is the same as here.
Finally I've found great Latex Library for IOS.
It's iosMath.
Currently it has only one defect: doesn't support line break.
But I believe it'll be done soon.

ShaderBytecode.CompileFromFile and dependent functions

Moving from the old Effects Framework to the new world of SharpDX 3 (which has no effects framework) means I need to re-work my effect compilation. My old effect files have VS and PS entry points and the Shaderbytecode.CompileFromFile deals with this - but I'm trying to track down a bug where I have shaders which have dependent functions (which might be related to the bug - I'm just trying to eliminate possibilities).
Question : when compiling an entry point with Shaderbytecode.CompileFromFile does the resulting bytecode contain all the instructions for the dependent functions as well ? ShaderReflection on the bytecode doesn't help to find this out, so hoping someone will know the definitive answer.
To answer my own question for reference;
Yes - if you remove a dependent function from the HLSL source, the compiler will throw an error. Although this doesn't prove the bytecode contains the instructions for the function, its clearly being compiled.

LLVM compilation process and LLD

I've been trying to make the switch to LLVM, since I'd like to get more into the whole 'software-dev' scene, and it seems like right now, LLVM is the future. I built LLVM/Clang/LLD/compiler-rt/libcxx from source several times now, both with GNU/GCC and LLVM/Clang.
The problem appears when I try to use the newly compiled compilers. From what I can see, clang is using GNU ld rather than LLVM's lld. Is this true?
LLD seems to be a very limited program from the lld -help output, but from what I have read, it is as full featured as ld. I cannot find documentation on how to use it anywhere -- does anyone know where I can find some kind of comprehensive manual on it?
Thank you.
Pass -fuse-ld=lld to clang to make it use lld for linking. By now, it's in very good shape.
You can pass -v or -### to clang to make it print which linker command it runs or would run.
There's no manual for the moment and depending on platform may work well enough for you. That said, if lld were "production ready" we'd have switched clang to using it by default for the various platforms. It's not there yet so I wouldn't suggest you use it for your day to day development.
The LLVM team say that is production ready because FreeBSD can compile and link a lot of things with LLD.
The documentation on the LLD project can be found on http://lld.llvm.org/.
It's written :
LLD is a drop-in replacement for the GNU linkers.
That accepts the same command line arguments and linker scripts as GNU.
So you can use same arguments than GNU LD.
I know this question is old, but there is a newer solution to it:
To use the ld.lld linker when building any llvm target, just pass -DLLVM_ENABLE_LLD=ON in the commandline to cmake.
//Use lld as C and C++ linker.
LLVM_ENABLE_LLD:BOOL=TRUE
For other cmake projects, pass: -DCMAKE_LINKER=/etc/bin/ld.lld

Resources