4.3 LLVM basic libraries
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.
4.3.1 RTTI replacement and cast operators
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’sjava
instanceof operator. It returnstrue
orfalse
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...