forked from facebook/infer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FCP] copy facebook-clang-plugins files [2/N]
Summary: Copy files from (clean commit) FCP [024a101](facebookarchive/facebook-clang-plugins@024a101) repo to folder in infer repo (i.e. no longer a subrepo). Excluding all dotfiles except .gitingnore and .clang-format ``` $ git checkout https://github.com/facebook/facebook-clang-plugins.git $ mkdir ~/infer/facebook-clang-plugins $ cp -r facebook-clang-plugins/* ~/infer/facebook-clang-plugins/ Reviewed By: ngorogiannis Differential Revision: D23315608 fbshipit-source-id: 2fc38b25e
- Loading branch information
1 parent
a7dee1e
commit 0ded780
Showing
205 changed files
with
212,241 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
AccessModifierOffset: -1 | ||
AlignEscapedNewlinesLeft: true | ||
AlignTrailingComments: false | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakBeforeMultilineStrings: true | ||
AlwaysBreakTemplateDeclarations: true | ||
BinPackArguments: false | ||
BinPackParameters: false | ||
BreakBeforeBinaryOperators: false | ||
BreakBeforeBraces: Attach | ||
BreakConstructorInitializersBeforeComma: false | ||
ColumnLimit: 80 | ||
CommentPragmas: '^@atd' | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: true | ||
ConstructorInitializerIndentWidth: 4 | ||
ContinuationIndentWidth: 4 | ||
Cpp11BracedListStyle: true | ||
DerivePointerAlignment: false | ||
ExperimentalAutoDetectBinPacking: true | ||
IndentCaseLabels: false | ||
IndentFunctionDeclarationAfterType: false | ||
IndentWidth: 2 | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: None | ||
ObjCSpaceBeforeProtocolList: false | ||
PenaltyBreakBeforeFirstCallParameter: 10 | ||
PenaltyBreakComment: 60 | ||
PenaltyBreakFirstLessLess: 20 | ||
PenaltyBreakString: 1000 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyReturnTypeOnItsOwnLine: 200 | ||
PointerAlignment: Right | ||
SpaceAfterControlStatementKeyword: true | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 1 | ||
SpacesInAngles: false | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInParentheses: false | ||
Standard: Cpp11 | ||
TabWidth: 8 | ||
UseTab: Never | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
build | ||
clang-ocaml/.depend | ||
xcode/* | ||
*~ | ||
clang/install | ||
clang/installed.version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Code of Conduct | ||
|
||
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.facebook.com/codeofconduct) so that you can understand what actions will and will not be tolerated. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Contributing to facebook-clang-plugins | ||
We want to make contributing to this project as easy and transparent as | ||
possible. | ||
|
||
## Code of Conduct | ||
The code of conduct is described in [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md). | ||
|
||
## Our Development Process | ||
The github repository https://github.com/facebook/facebook-clang-plugins is the source of truth. | ||
|
||
## Pull Requests | ||
We actively welcome your pull requests. | ||
|
||
1. Fork the repo and create your branch from `master`. | ||
2. If you've added code that should be tested, add tests | ||
3. If you've changed APIs, update the documentation. | ||
4. Ensure the test suite passes. | ||
Run tests with `make -C libtooling test`. For re-recording the tests, run `make -C libtooling record-test-outputs`. | ||
5. If you haven't already, complete the Contributor License Agreement ("CLA"). | ||
|
||
## Contributor License Agreement ("CLA") | ||
In order to accept your pull request, we need you to submit a CLA. You only need | ||
to do this once to work on any of Facebook's open source projects. | ||
|
||
Complete your CLA here: <https://developers.facebook.com/opensource/cla> | ||
|
||
## Issues | ||
We use GitHub issues to track public bugs. Please ensure your description is | ||
clear and has sufficient instructions to be able to reproduce the issue. | ||
|
||
Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe | ||
disclosure of security bugs. In those cases, please go through the process | ||
outlined on that page and do not file a public issue. | ||
|
||
## Coding Style | ||
Please use the LLVM style for new code: http://llvm.org/docs/CodingStandards.html | ||
while we are (slowly) updating the rest of the files. | ||
|
||
## License | ||
By contributing to facebook-clang-plugins, you agree that your contributions will be licensed | ||
under its MIT license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2014-present, Facebook, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
============================================================================== | ||
LLVM Release License | ||
============================================================================== | ||
University of Illinois/NCSA | ||
Open Source License | ||
|
||
Copyright (c) 2003-2014 University of Illinois at Urbana-Champaign. | ||
All rights reserved. | ||
|
||
Developed by: | ||
|
||
LLVM Team | ||
|
||
University of Illinois at Urbana-Champaign | ||
|
||
http://llvm.org | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal with | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
of the Software, and to permit persons to whom the Software is furnished to do | ||
so, subject to the following conditions: | ||
|
||
* Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimers. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimers in the | ||
documentation and/or other materials provided with the distribution. | ||
|
||
* Neither the names of the LLVM Team, University of Illinois at | ||
Urbana-Champaign, nor the names of its contributors may be used to | ||
endorse or promote products derived from this Software without specific | ||
prior written permission. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright (c) 2014-present, Facebook, Inc. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
LEVEL=. | ||
include Makefile.common | ||
|
||
.PHONY: all | ||
all: | ||
$(MAKE) -C libtooling/atdlib all | ||
$(MAKE) -C libtooling all | ||
|
||
.PHONY: test | ||
test: all | ||
$(MAKE) -C libtooling/atdlib test | ||
$(MAKE) -C libtooling test | ||
|
||
.PHONY: clean | ||
clean: | ||
$(MAKE) -C libtooling/atdlib clean | ||
$(MAKE) -C libtooling clean | ||
|
||
.PHONY: fmt_all | ||
fmt_all: | ||
find libtooling \ | ||
\( -name '*'.cpp -or -name '*'.h -or -name '*'.c -or -name '*'.m -or -name '*'.mm \) \ | ||
-exec ./clang/install/bin/clang-format -verbose -i \{\} \+ | ||
|
||
CHECKCOPYRIGHT=../infer/bin/checkCopyright | ||
|
||
.PHONY: copyright | ||
copyright: | ||
@[ -x $(CHECKCOPYRIGHT) ] || { \ | ||
echo "only works when this repo is checked out as a git submodule inside the infer repo" >&2; \ | ||
echo "make sure this is the case and that `make checkCopyright` has been run from within infer" >&2; \ | ||
exit 1; \ | ||
} | ||
git ls-files \ | ||
| grep -e '\(\.\(atd\|c\|cpp\|h\|m\|ml\|mli\|mm\|py\|sh\)\(\|\.p\)$$\|^\(.*/\|\)Makefile\)' \ | ||
| grep -v 'libtooling/ASTExporter\.\(cpp\|h\)' \ | ||
| xargs $(CHECKCOPYRIGHT) -i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Copyright (c) 2014-present, Facebook, Inc. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
include $(LEVEL)/Makefile.config | ||
|
||
# Typical compilation flags for Objective C examples | ||
ifeq ($(HAS_OBJC),yes) | ||
IOSFLAGS=-isysroot $(SDKPATH) -mios-simulator-version-min=8.2 -target x86_64-apple-darwin14 -fobjc-arc \ | ||
-Wno-unused-command-line-argument \ | ||
-Wno-objc-property-implementation | ||
endif | ||
|
||
# we assume that the targeted clang was configured with --enable-libcpp --enable-cxx14 | ||
CFLAGS_Darwin+=-stdlib=libc++ -std=c++14 | ||
LDFLAGS_Darwin+=-stdlib=libc++ | ||
|
||
CFLAGS_Linux+=-std=c++14 -fPIC | ||
LDFLAGS_Linux+= | ||
|
||
override CFLAGS+=$(CFLAGS_$(shell uname)) -g | ||
override LDFLAGS+=$(LDFLAGS_$(shell uname)) | ||
|
||
override CFLAGS+=$(CLANG_INCLUDES:%=-I%) -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -fno-common -Woverloaded-virtual -Wcast-qual -fno-strict-aliasing -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -Wno-uninitialized -Wno-missing-field-initializers -Wno-vla-extension -Wno-c99-extensions | ||
|
||
ifdef DEBUG | ||
override CFLAGS+=-DDEBUG | ||
export VERBOSE:=1 | ||
SHELL=bash -O nullglob | ||
else | ||
override CFLAGS+=-O3 -DNDEBUG | ||
override LDFLAGS+=-O3 | ||
# early exit when tests fail | ||
SHELL=bash -e -O nullglob | ||
endif | ||
|
||
# project headers (if any) | ||
HEADERS?= | ||
|
||
# test runner | ||
RUNTEST=$(LEVEL)/scripts/run_test.sh | ||
|
||
LDFLAGS_DYLIB=$(LDFLAGS) | ||
LDFLAGS_DYLIB+=-Wl,-rpath -Wl,@executable_path/../lib -Wl,-undefined,dynamic_lookup -Wl,-flat_namespace -Wl,-undefined,suppress -dynamiclib -shared | ||
|
||
CLANG_TOOL_LIBS := \ | ||
-lclangFrontend \ | ||
-lclangIndex \ | ||
-lclangSerialization \ | ||
-lclangDriver \ | ||
-lclangTooling \ | ||
-lclangCodeGen \ | ||
-lclangParse \ | ||
-lclangSema \ | ||
-lclangAnalysis \ | ||
-lclangRewriteFrontend \ | ||
-lclangRewrite \ | ||
-lclangEdit \ | ||
-lclangAST \ | ||
-lclangLex \ | ||
-lclangBasic | ||
|
||
# Local Variables: | ||
# mode: makefile | ||
# End: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Copyright (c) 2014-present, Facebook, Inc. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
# Template configuration file for make. | ||
# You may use $(LEVEL) to refer to the directory containing this file. | ||
|
||
# --- targeted clang compiler ---- | ||
|
||
# Where to find clang installation directories | ||
CLANG_PREFIX?=$(LEVEL)/clang/install | ||
# Where to find clang headers (possibly a list, see below) | ||
CLANG_INCLUDES?=$(CLANG_PREFIX)/include | ||
|
||
# example of alternative paths to compile and load the plugin into a locally compiled, not yet installed llvm/clang | ||
#CLANG_PREFIX=llvm-build/Debug+Asserts | ||
#CLANG_INCLUDES=llvm/tools/clang/include llvm-build/tools/clang/include llvm-build/include llvm/include | ||
|
||
# target compiler, must match the exact same version of clang as the include files | ||
CLANG?=$(CLANG_PREFIX)/bin/clang | ||
|
||
LLVM_CXXFLAGS?=`$(CLANG_PREFIX)/bin/llvm-config --cxxflags 2>/dev/null || true` | ||
LLVM_LDFLAGS?=`$(CLANG_PREFIX)/bin/llvm-config --ldflags --libs --system-libs 2>/dev/null || true` | ||
|
||
# --- local clang compiler --- | ||
|
||
# Which compiler to use to compile the plugin themselves. | ||
LOCAL_CLANG?=clang | ||
CC=$(LOCAL_CLANG) | ||
CXX=$(LOCAL_CLANG)++ | ||
|
||
# Which preprocessor to use to extract ATD comments from cpp files. | ||
# @requires clang >= 3.4 (The nonstandard part here is that we want to expand doc-comments contained in macros.) | ||
ATD_CPP?=$(LOCAL_CLANG) -cc1 -E -traditional-cpp -w -P -main-file-name - -o - | ||
|
||
# Which preprocessor to use on ocaml "pre-source" files. | ||
OCAML_CPP?=$(LOCAL_CLANG) -cc1 -E -P -x c -main-file-name - -o - | ||
|
||
# --- Objective C --- | ||
|
||
# Which SDK to use (if any) | ||
SDKPATH?=$(shell ls -d "`xcode-select --print-path 2> /dev/null`"/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator*.sdk 2> /dev/null | sort -r | head -n 1 || true) | ||
|
||
ifeq ($(SDKPATH),) | ||
HAS_OBJC=no | ||
else | ||
HAS_OBJC=yes | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright (c) 2014-present, Facebook, Inc. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
build/%.o: %.cpp $(HEADERS) $(CLANG) | ||
@mkdir -p $$(dirname $@) | ||
$(CXX) $(CFLAGS) -c $< -o $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Facebook Clang Plugins | ||
====================== | ||
|
||
This [repository](https://github.com/facebook/facebook-clang-plugins) aims to share some useful clang plugins developed at Facebook. They are mostly used by [infer](https://github.com/facebook/infer). | ||
|
||
It contains frontend plugins to the [clang compiler](http://clang.llvm.org/) to process the syntax of source files directly to accomplish more general tasks; specifically, we have developed a clang-to-ocaml bridge to make code analyses easier. | ||
|
||
Structure of the repository | ||
--------------------------- | ||
|
||
- [`libtooling`](https://github.com/facebook/facebook-clang-plugins/tree/master/libtooling) : frontend plugins (currently a clang-to-json AST exporter), | ||
|
||
- [`clang-ocaml`](https://github.com/facebook/facebook-clang-plugins/tree/master/clang-ocaml) : OCaml libraries to process the JSON output of frontend plugins, | ||
|
||
|
||
Quick start | ||
----------- | ||
|
||
The current version of the plugins requires recent version of the clang compiler, re-compiled from source. Clang source which is used by this project can be found in `clang/src/` | ||
|
||
General instructions to compile clang can be found here: http://clang.llvm.org/get_started.html | ||
|
||
To compile and use the required version of clang, please run ./clang/setup.sh. | ||
Using this script should make the variable CLANG_PREFIX unnecessary to compile the plugin. | ||
|
||
Caveat: | ||
- Because of the nature of C++, clang and the plugins need to be compiled with the exact same C++ libraries. | ||
- Also, the default stripping command of clang in release mode breaks plugins. | ||
|
||
Once the target compiler is installed, `make test` should run the unit tests. | ||
|
||
OCaml users may also run: | ||
``` | ||
make -C clang-ocaml test #requires proper ocaml libraries, see included clang-ocaml/README | ||
``` | ||
|
||
Additional configuration options are available in `Makefile.config`. | ||
|
||
Licence | ||
------- | ||
|
||
The plugins are MIT-licensed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
margin 100 | ||
version 0.5 |
Oops, something went wrong.