GithubHelp home page GithubHelp logo

asutton / old-clang-reflect Goto Github PK

View Code? Open in Web Editor NEW

This project forked from llvm-mirror/clang

18.0 5.0 0.0 290.46 MB

Mirror of official clang git repository located at http://llvm.org/git/clang. Updated every five minutes.

Home Page: http://clang.llvm.org/

License: Other

CMake 0.12% Objective-C 7.07% C++ 69.46% C 20.14% Python 0.58% Objective-C++ 2.17% MATLAB 0.07% Mercury 0.01% LLVM 0.01% Assembly 0.05% Rust 0.01% Cuda 0.29% Mathematica 0.01% Shell 0.01% M 0.01% Fortran 0.01% Limbo 0.01% RenderScript 0.01% Forth 0.01% Perl 0.03%

old-clang-reflect's Introduction

//===----------------------------------------------------------------------===// // C Language Family Front-end //===----------------------------------------------------------------------===//

Welcome to Clang. This is a compiler front-end for the C family of languages (C, C++, Objective-C, and Objective-C++) which is built as part of the LLVM compiler infrastructure project.

Unlike many other compiler frontends, Clang is useful for a number of things beyond just compiling code: we intend for Clang to be host to a number of different source-level tools. One example of this is the Clang Static Analyzer.

If you're interested in more (including how to build Clang) it is best to read the relevant web sites. Here are some pointers:

Information on Clang: http://clang.llvm.org/ Building and using Clang: http://clang.llvm.org/get_started.html Clang Static Analyzer: http://clang-analyzer.llvm.org/ Information on the LLVM project: http://llvm.org/

If you have questions or comments about Clang, a great place to discuss them is on the Clang development mailing list: http://lists.llvm.org/mailman/listinfo/cfe-dev

If you find a bug in Clang, please file it in the LLVM bug tracker: http://llvm.org/bugs/

Reflection

This fork of the Clang compiler provides an experimental implementation of static reflection for C++. This is a work in progress; the design and implementation are known to be incomplete.

Note that this fork tracks the GitHub mirrors of LLVM and Clang. I try to sync with those repositories about once per week. This means that this repository will have the same features (and bugs) as trunk.

Getting started

The getting started instructions for this fork of the compiler are similar to those of the main trunk. The only difference is that, when you clone this repository, you need to make sure it is named clang and not clang-reflect.

Here are the set of commands I use to set up the build environment.

git clone https://github.com/llvm-mirror/llvm
cd llvm/tools
git clone https://github.com/asutton/clang-reflect clang
cd ../projects
git clone https://github.com/llvm-mirror/libcxx

If you forget to provide the name clang in the second step, you can simply rename the directory later:

cd llvm/tools
mv clang-reflect clang

Building LLVM + Clang

Follow the usual instructions for building LLVM + Clang.

However, I would make the following recommendations. First, unless you plan to hack on the implementation, make sure you're building a release compiler. Otherwise, compilation will be very slow.

Second, make sure you're installation path is configured before you start compiling the program. If you decide to change the installation path after building LLVM + Clang, you're going to have to rebuild the entire compiler. That can take a while.

You can configure these from the command line when you run cmake. Here's how I do that:

cd llvm
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/opt

This will configure a native release-mode compiler installed in $HOME/opt.

Building and installing is straightforward.

make
make install

Note that make may take a while. It goes faster using make -j4 (or some other number relative to your system).

Library support

Reflection requires library support. This is provided by a separate, header only library libcpp3k, which can be found in the clang/tools directory. The header(s) are installed when you install LLVM + Clang in the configured location. For example, with the configuration above, these files are installed at $HOME/opt/include.

We've opted to make library support separate from the C++ standard library for the time being. This allows the library to be used by other compiler implementations experimenting with the same approach to reflection.

Using the compiler

The compiler will be installed in the given location. If this is not on path (which I strongly recommend against), then you will need to invoke the compiler using its full path. A better solution is to define the CXX environment variable to refer to that compiler.

export CXX=$HOME/opt/bin/clang++
$CXX -version  # print version info

This has the added benefit of working with CMake for your own projects. That is, CMake will detect the C++ compiler as the one specified by the $CXX.

To enable reflection, you will need to compile with the following flags:

$CXX -std=c++1z -Xclang -freflection

The first enables the latest C++ language features. The next two flags -Xclang -freflection enable C++ reflection.

Depending on your installation path, you may also need to add include directories to the search path for libcpp3k.

$CXX -std=c++1z -Xclang -freflection -I$HOME/opt/include

Remember that libcpp3k is installed with (and alongside) this version of the compiler, so that wherever Clang is installed, that's where libcpp3k is also installed.

Reflection examples

A number of reflection examples can be found in the clang/tools/libcpp3k directory under examples. These can be built separately from the compiler using CMake.

If everything has been compiled and installed correctly, then you can build the examples like this:

cd llvm/tools/clang/tools/libcpp3k
mkdir build
cd build
export CXX=$HOME/opt/bin/clang++
cmake ..
make

These examples are largely taken from the WG21 proposal p0385r1 (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0385r1.pdf).

Errata and bugs

If you find compiler bugs, or things don't work the way you expect, please file an issue for the issue tracker in this repository.

old-clang-reflect's People

Contributors

aaronballman avatar akyrtzi avatar alexey-bataev avatar annazaks avatar atoker avatar chandlerc avatar chapuni avatar d0k avatar ddunbar avatar djasper avatar douggregor avatar dwblaikie avatar echristo avatar eefriedman avatar espindola avatar gribozavr avatar jrose-apple avatar lattner avatar majnemer avatar nico avatar pcc avatar r4nt avatar rjmccall avatar rnk avatar tkremenek avatar topperc avatar weverything avatar xuzhongxing avatar zmodem avatar zygoloid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.