-
Book Overview & Buying
-
Table Of Contents
Clang Compiler Frontend
By :
We are going to start with RTTI replacement in the LLVM code and discuss how it’s implemented. We will then continue with basic containers and smart pointers. We will conclude with some important classes used to represent token locations and how diagnostics are realized in Clang. Later, in Section 4.6, Clang plugin project, we will use some of these classes in our test project.
As mentioned earlier, LLVM avoids using RTTI due to performance concerns. LLVM has introduced several helper functions that replace RTTI counterparts, allowing for the casting of an object from one type to another. The fundamental ones are as follows:
llvm::isa<> is akin to Java’s javainstanceof operator. It returns true or false depending on whether the reference to the tested object belongs to the tested class or not.
llvm::cast<>: Use this cast operator when you’re certain that the object is of the specified...