# Open Clang Projects

Here are a few tasks that are available for newcomers to work on, depending on what your interests are. This list is provided to generate ideas, it is not intended to be comprehensive. Please ask on cfe-dev for more specifics or to verify that one of these isn't already completed. :)

- Compile your favorite C/ObjC project with Clang: Clang's type-checking and code generation is very close to complete (but not bug free!) for C and Objective-C. We appreciate all reports of code that is rejected or miscompiled by the front-end. If you notice invalid code that is not rejected, or poor diagnostics when code is rejected, that is also very important to us. For make-based projects, the `ccc` driver works as a drop-in replacement for GCC.
- Overflow detection: an interesting project would be to add a -ftrapv compilation mode that causes -emit-llvm to generate overflow tests for all signed integer arithmetic operators, and call abort if they overflow. Overflow is undefined in C and hard for people to reason about. LLVM IR also has intrinsics for generating arithmetic with overflow checks directly.
- Undefined behavior checking: similar to adding -ftrapv, codegen could insert runtime checks for all sorts of different undefined behaviors, from reading uninitialized variables, buffer overflows, and many other things. This checking would be expensive, but the optimizers could eliminate many of the checks in some cases, and it would be very interesting to test code in this mode for certain crowds of people. Because the inserted code is coming from clang, the "abort" message could be very detailed about exactly what went wrong.
- Improve target support: The current target interfaces are heavily stubbed out and need to be implemented fully. See the FIXME's in TargetInfo. Additionally, the actual target implementations (instances of TargetInfoImpl) also need to be completed.
- Implement an tool to generate code documentation: Clang's library-based design allows it to be used by a variety of tools that reason about source code. One great application of Clang would be to build an auto-documentation system like doxygen that generates code documentation from source code. The advantage of using Clang for such a tool is that the tool would use the same preprocessor/parser/ASTs as the compiler itself, giving it a very rich understanding of the code.
- Use clang libraries to implement better versions of existing tools: Clang is built as a set of libraries, which means that it is possible to implement capabilities similar to other source language tools, improving them in various ways. Two examples are distcc and the delta testcase reduction tool. The former can be improved to scale better and be more efficient. The later could also be faster and more efficient at reducing C-family programs if built on the clang preprocessor.
- Use clang libraries to extend Ragel with a JIT: Ragel is a state machine compiler that lets you embed C code into state machines and generate C code. It would be relatively easy to turn this into a JIT compiler using LLVM.
- Self-testing using clang: There are several neat ways to improve the quality of clang by self-testing. Some examples:
  - Improve the reliability of AST printing and serialization by ensuring that the AST produced by clang on an input doesn't change when it is reparsed or unserialized.
  - Improve parser reliability and error generation by automatically or randomly changing the input checking that clang doesn't crash and that it doesn't generate excessive errors for small input changes. Manipulating the input at both the text and token levels is likely to produce interesting test cases.
- Continue work on C++ support: Implementing all of C++ is a very big job, but there are lots of little pieces that can be picked off and implemented. Here are some small- to mid-sized C++ implementation projects:
  - Using declarations: These are completely unsupported at the moment.
  - Type-checking for the conditional operator (? :): this currently follows C semantics, not C++ semantics.
  - Type-checking for explicit conversions: currently follows C semantics, not C++ semantics.
  - Type-checking for copy assignment: Clang parses overloaded copy-assignment operators, but they aren't used as part of assignment syntax ("a = b").
  - Qualified member references: C++ supports qualified member references such as `x->Base::foo`, but Clang has no parsing or semantic analysis for them.
  - Virtual functions: Clang parses `virtual` and attaches it to the AST. However, it does not determine whether a given function overrides a virtual function in a base class.
  - Implicit definitions of special member functions: Clang implicitly declares the various special member functions (default constructor, copy constructor, copy assignment operator, destructor) when necessary, but is not yet able to provide definitions for these functions.
  - Parsing and AST representations of friend classes and functions
  - AST representation for implicit C++ conversions: implicit conversions that involve non-trivial operations (e.g., invoking a user-defined conversion function, performing a base-to-derived or derived-to-base conversion) need explicit representation in Clang's AST.
  - Improved diagnostics for overload resolution failures: after an overload resolution failure, we currently print out the overload resolution candidates. We should also print out the reason that each candidate failed, e.g., "too few arguments", "too many arguments", "cannot initialize parameter with an lvalue of type 'foo'", etc.
  Also, see the C++ status report page to find out what is missing and what is already at least partially supported.

If you hit a bug with clang, it is very useful for us if you reduce the code that demonstrates the problem down to something small. There are many ways to do this; ask on cfe-dev for advice.