kmh11
400b4eba99
Implement AtomicExpr translation ( #1434 )
...
Summary:
Implements the translation of most clang atomic builtins to SIL, including those used in `stdatomic.h`. It does not attempt to model the atomicity of the operations, since I don't know of any way Infer can represent that. I didn't bother implementing the rarely used min/max builtins, so they're left as `BuiltinDecl` calls.
This is my first major OCaml project, so any feedback is appreciated!
Also, CONTRIBUTING.md says to update the [facebook-clang-plugins](https://github.com/facebook/facebook-clang-plugins ) submodule, but it doesn't seem to be a submodule anymore, and the code has diverged from that repo. Should I still make a PR over there?
Pull Request resolved: https://github.com/facebook/infer/pull/1434
Reviewed By: skcho
Differential Revision: D28118300
Pulled By: jvillard
fbshipit-source-id: 121c4ad25
4 years ago
Graham Sutherland
c90ec06834
Fix clang plugin compile error in FileUtils.cpp ( #1437 )
...
Summary:
I ran into this error while compiling:
```
[*ERROR**][48253] FileUtils.cpp: In function ‘std::string FileUtils::makeAbsolutePath(const string&, std::string)’:
[*ERROR**][48253] FileUtils.cpp:44:57: error: invalid initialization of reference of type ‘const string&’ {aka ‘const std::__cxx11::basic_string<char>&’} from expression of type ‘llvm::StringRef’
[*ERROR**][48253] 44 | const std::string &element(llvm::sys::path::filename(path));
[*ERROR**][48253] | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
```
The path element in FileUtils.cpp was attempted to be initialised from an `llvm::StringRef` directly, which doesn't appear to be a thing that is implemented anywhere. This PR simply dereferences the `StringRef` to an `std::string` with `str()`, which makes the compile error go away.
The complete compile error output is as follows:
```
[02:04:57][48253] Building clang plugin...
[*ERROR**][48253] *** ERROR 'Building clang plugin'
[*ERROR**][48253] *** command: ' make INTERACTIVE=1 -C /home/graham/infer/facebook-clang-plugins/libtooling all CC=gcc CXX=g++ CFLAGS=-g -O2 CXXFLAGS=-g -O2 CPP=gcc -E LDFLAGS= LIBS= LOCAL_CLANG=/home/graham/infer/facebook-clang-plugins/clang/install/bin/clang CLANG_PREFIX=/home/graham/infer/facebook-clang-plugins/clang/install CLANG_INCLUDES=/home/graham/infer/facebook-clang-plugins/clang/install/include SDKPATH= '
[*ERROR**][48253] *** CWD: '/home/graham/infer'
[*ERROR**][48253] *** stdout:
[*ERROR**][48253] make[2]: Entering directory '/home/graham/infer/facebook-clang-plugins/libtooling'
[*ERROR**][48253] g++ -g -O2 -std=c++14 -fPIC -g -I/home/graham/infer/facebook-clang-plugins/clang/install/include -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 -O3 -DNDEBUG -c ASTExporter.cpp -o build/ASTExporter.o
[*ERROR**][48253] g++ -g -O2 -std=c++14 -fPIC -g -I/home/graham/infer/facebook-clang-plugins/clang/install/include -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 -O3 -DNDEBUG -c SimplePluginASTAction.cpp -o build/SimplePluginASTAction.o
[*ERROR**][48253] g++ -g -O2 -std=c++14 -fPIC -g -I/home/graham/infer/facebook-clang-plugins/clang/install/include -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 -O3 -DNDEBUG -c FileUtils.cpp -o build/FileUtils.o
[*ERROR**][48253] g++ -g -O2 -std=c++14 -fPIC -g -I/home/graham/infer/facebook-clang-plugins/clang/install/include -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 -O3 -DNDEBUG -c AttrParameterVectorStream.cpp -o build/AttrParameterVectorStream.o
[*ERROR**][48253] make[2]: Leaving directory '/home/graham/infer/facebook-clang-plugins/libtooling'
[*ERROR**][48253] *** stderr:
[*ERROR**][48253] In file included from /home/graham/infer/facebook-clang-plugins/clang/install/include/clang/AST/DeclVisitor.h:21,
[*ERROR**][48253] from ASTExporter.h:41,
[*ERROR**][48253] from ASTExporter.cpp:17:
[*ERROR**][48253] /home/graham/infer/facebook-clang-plugins/clang/install/include/clang/AST/DeclOpenMP.h:97:1: warning: multi-line comment [-Wcomment]
[*ERROR**][48253] 97 | /// #pragma omp declare reduction (foo : int,float : omp_out += omp_in) \
[*ERROR**][48253] | ^
[*ERROR**][48253] In file included from ASTExporter.cpp:17:
[*ERROR**][48253] ASTExporter.h:4552: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas]
[*ERROR**][48253] 4552 | #pragma clang diagnostic push
[*ERROR**][48253] |
[*ERROR**][48253] ASTExporter.h:4553: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas]
[*ERROR**][48253] 4553 | #pragma clang diagnostic ignored "-Wcast-qual"
[*ERROR**][48253] |
[*ERROR**][48253] ASTExporter.h:4555: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas]
[*ERROR**][48253] 4555 | #pragma clang diagnostic pop
[*ERROR**][48253] |
[*ERROR**][48253] FileUtils.cpp: In function ‘std::string FileUtils::makeAbsolutePath(const string&, std::string)’:
[*ERROR**][48253] FileUtils.cpp:44:57: error: invalid initialization of reference of type ‘const string&’ {aka ‘const std::__cxx11::basic_string<char>&’} from expression of type ‘llvm::StringRef’
[*ERROR**][48253] 44 | const std::string &element(llvm::sys::path::filename(path));
[*ERROR**][48253] | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
[*ERROR**][48253] At global scope:
[*ERROR**][48253] cc1plus: warning: unrecognized command line option ‘-Wno-c99-extensions’
[*ERROR**][48253] cc1plus: warning: unrecognized command line option ‘-Wno-vla-extension’
[*ERROR**][48253] make[2]: *** [../Makefile.rules:7: build/FileUtils.o] Error 1
[*ERROR**][48253] make[2]: *** Waiting for unfinished jobs....
[*ERROR**][48253] In file included from ASTExporter.cpp:17:
[*ERROR**][48253] ASTExporter.h:71:7: warning: C++ designated initializers only available with ‘-std=c++2a’ or ‘-std=gnu++2a’ [-Wpedantic]
[*ERROR**][48253] 71 | .useYojson = false,
[*ERROR**][48253] | ^
[*ERROR**][48253] ASTExporter.h:72:7: warning: C++ designated initializers only available with ‘-std=c++2a’ or ‘-std=gnu++2a’ [-Wpedantic]
[*ERROR**][48253] 72 | .prettifyJson = true,
[*ERROR**][48253] | ^
[*ERROR**][48253] In file included from ASTExporter.cpp:17:
[*ERROR**][48253] ASTExporter.h: In instantiation of ‘void ASTLib::ASTExporter<ATDWriter>::VisitObjCAvailabilityCheckExpr(const clang::ObjCAvailabilityCheckExpr*) [with ATDWriter = ATDWriter::JsonWriter<llvm::raw_ostream>]’:
[*ERROR**][48253] /home/graham/infer/facebook-clang-plugins/clang/install/include/clang/AST/StmtNodes.inc:1161:1: required from ‘RetTy clang::StmtVisitorBase<Ptr, ImplClass, RetTy, ParamTys>::Visit(typename Ptr<clang::Stmt>::type, ParamTys ...) [with Ptr = llvm::make_const_ptr; ImplClass = ASTLib::ASTExporter<ATDWriter::JsonWriter<llvm::raw_ostream> >; RetTy = void; ParamTys = {}; typename Ptr<clang::Stmt>::type = const clang::Stmt*]’
[*ERROR**][48253] ASTExporter.h:3089:52: required from ‘void ASTLib::ASTExporter<ATDWriter>::dumpStmt(const clang::Stmt*) [with ATDWriter = ATDWriter::JsonWriter<llvm::raw_ostream>]’
[*ERROR**][48253] ASTExporter.h:3048:9: required from ‘void ASTLib::ASTExporter<ATDWriter>::VisitBlockDecl(const clang::BlockDecl*) [with ATDWriter = ATDWriter::JsonWriter<llvm::raw_ostream>]’
[*ERROR**][48253] /home/graham/infer/facebook-clang-plugins/clang/install/include/clang/AST/DeclNodes.inc:29:1: required from ‘RetTy clang::declvisitor::Base<Ptr, ImplClass, RetTy>::Visit(typename Ptr<clang::Decl>::type) [with Ptr = llvm::make_const_ptr; ImplClass = ASTLib::ASTExporter<ATDWriter::JsonWriter<llvm::raw_ostream> >; RetTy = void; typename Ptr<clang::Decl>::type = const clang::Decl*]’
[*ERROR**][48253] ASTExporter.h:1072:52: required from ‘void ASTLib::ASTExporter<ATDWriter>::dumpDecl(const clang::Decl*) [with ATDWriter = ATDWriter::JsonWriter<llvm::raw_ostream>]’
[*ERROR**][48253] ASTExporter.h:5448:5: required from ‘void ASTLib::ExporterASTConsumer<ATDWriter, ForceYojson>::HandleTranslationUnit(clang::ASTContext&) [with ATDWriter = ATDWriter::JsonWriter<llvm::raw_ostream>; bool ForceYojson = false]’
[*ERROR**][48253] ASTExporter.h:5445:16: required from here
[*ERROR**][48253] ASTExporter.h:4554:36: warning: cast from type ‘const clang::ObjCAvailabilityCheckExpr*’ to type ‘clang::ObjCAvailabilityCheckExpr*’ casts away qualifiers [-Wcast-qual]
[*ERROR**][48253] 4554 | ObjCAvailabilityCheckExpr *E = (ObjCAvailabilityCheckExpr *)Expr;
[*ERROR**][48253] | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[*ERROR**][48253] ASTExporter.h: In instantiation of ‘void ASTLib::ASTExporter<ATDWriter>::VisitObjCAvailabilityCheckExpr(const clang::ObjCAvailabilityCheckExpr*) [with ATDWriter = ATDWriter::BiniouWriter<llvm::raw_ostream>]’:
[*ERROR**][48253] /home/graham/infer/facebook-clang-plugins/clang/install/include/clang/AST/StmtNodes.inc:1161:1: required from ‘RetTy clang::StmtVisitorBase<Ptr, ImplClass, RetTy, ParamTys>::Visit(typename Ptr<clang::Stmt>::type, ParamTys ...) [with Ptr = llvm::make_const_ptr; ImplClass = ASTLib::ASTExporter<ATDWriter::BiniouWriter<llvm::raw_ostream> >; RetTy = void; ParamTys = {}; typename Ptr<clang::Stmt>::type = const clang::Stmt*]’
[*ERROR**][48253] ASTExporter.h:3089:52: required from ‘void ASTLib::ASTExporter<ATDWriter>::dumpStmt(const clang::Stmt*) [with ATDWriter = ATDWriter::BiniouWriter<llvm::raw_ostream>]’
[*ERROR**][48253] ASTExporter.h:3048:9: required from ‘void ASTLib::ASTExporter<ATDWriter>::VisitBlockDecl(const clang::BlockDecl*) [with ATDWriter = ATDWriter::BiniouWriter<llvm::raw_ostream>]’
[*ERROR**][48253] /home/graham/infer/facebook-clang-plugins/clang/install/include/clang/AST/DeclNodes.inc:29:1: required from ‘RetTy clang::declvisitor::Base<Ptr, ImplClass, RetTy>::Visit(typename Ptr<clang::Decl>::type) [with Ptr = llvm::make_const_ptr; ImplClass = ASTLib::ASTExporter<ATDWriter::BiniouWriter<llvm::raw_ostream> >; RetTy = void; typename Ptr<clang::Decl>::type = const clang::Decl*]’
[*ERROR**][48253] ASTExporter.h:1072:52: required from ‘void ASTLib::ASTExporter<ATDWriter>::dumpDecl(const clang::Decl*) [with ATDWriter = ATDWriter::BiniouWriter<llvm::raw_ostream>]’
[*ERROR**][48253] ASTExporter.h:5448:5: required from ‘void ASTLib::ExporterASTConsumer<ATDWriter, ForceYojson>::HandleTranslationUnit(clang::ASTContext&) [with ATDWriter = ATDWriter::BiniouWriter<llvm::raw_ostream>; bool ForceYojson = true]’
[*ERROR**][48253] ASTExporter.h:5445:16: required from here
[*ERROR**][48253] ASTExporter.h:4554:36: warning: cast from type ‘const clang::ObjCAvailabilityCheckExpr*’ to type ‘clang::ObjCAvailabilityCheckExpr*’ casts away qualifiers [-Wcast-qual]
[*ERROR**][48253] cc1plus: warning: unrecognized command line option ‘-Wno-c99-extensions’
[*ERROR**][48253] cc1plus: warning: unrecognized command line option ‘-Wno-vla-extension’
make[1]: *** [Makefile:415: clang_plugin] Error 2
make[1]: Leaving directory '/home/graham/infer'
make: *** [Makefile:389: opt] Error 2
compilation failure; you can try running
make clean
'./build-infer.sh' clang
```
Pull Request resolved: https://github.com/facebook/infer/pull/1437
Reviewed By: skcho
Differential Revision: D28118303
Pulled By: jvillard
fbshipit-source-id: b821b601b
4 years ago
Jules Villard
4c48b79f6c
[siof] detect constexpr for all procedures
...
Summary:
Previously we were only taking constexpr into account on constructors.
Add this info to ProcAttributes.t instead by exporting it from the
plugin for all functions.
This allows SIOF to take constexpr into account in more cases as it's not
always good at capturing which functions *can* be constexpr-evaluated,
which caused false positives.
Delete now-useless is_constexpr in constructor types. This generated the
changes in frontend tests.
Some minor renamings of variants of is_const_expr -> is_constexpr.
Reviewed By: da319
Differential Revision: D27503433
fbshipit-source-id: 3d1972900
4 years ago
Martin Trojer
18f28395e8
[clang] migrate to llvm/clang11
...
Summary:
Update Infer to LLVM (clang) 11.1.0.
Infer/clang now uses the LLVM 'monorepo' release, simplifying the download script.
Some changes done to how/when ASTExporter mangles names, this to avoid the
plugin hitting asserts in the clang code when mangling names.
Reviewed By: jvillard
Differential Revision: D27006986
fbshipit-source-id: 4d4b6ba05
4 years ago
Martin Trojer
9fd1a87cd5
Upgrade Infer to clang10
...
Reviewed By: jvillard
Differential Revision: D25048497
fbshipit-source-id: 7e839a076
4 years ago
Martin Trojer
498da13cad
[objc] [fcp] only emit property_control tag when we have non-None property_control
...
Summary: Plugin can emit corrupt data when ObjCPropertyDecl == None
Reviewed By: ezgicicek, jvillard
Differential Revision: D25023778
fbshipit-source-id: 30b950f7a
4 years ago
Martin Trojer
96755539c2
Make infer build on centos8
...
Reviewed By: skcho
Differential Revision: D23985761
fbshipit-source-id: fd02ec9be
4 years ago
Martin Trojer
26dcd63a25
Revert "upgrade to clang10"
...
Reviewed By: jvillard
Differential Revision: D23961256
fbshipit-source-id: d57760b27
4 years ago
Martin Trojer
15786e8f09
upgrade to clang10
...
Summary:
Upgrade to latest clang release, needed for xcode12.
clang-8/9 won't be able to read the Xcode 12 SDK since there's annotations that will fail compilation.
Also removing unused (and hard to compile) binary `ast_exporter_bin` from facebook-clang-plugins/libtooling.
Reviewed By: ngorogiannis
Differential Revision: D23780089
fbshipit-source-id: 2314125a9
4 years ago
Sungkeun Cho
76ad9915a1
[cost] Increase autoreleasepool size when non-ARC call ARC
...
Summary:
This diff increases autoreleasepool size when
* caller is non-ARC-compiled
* callee is ARC-compiled
* return type is a pointer to objc object
To distinguish non-ARC-/ARC-compiled:
* extended `translation_unit_decl_info` to have a boolean field `is_objc_arc_on`
* then copied it to `ProcAttributes.t` for each procedures.
Reviewed By: ezgicicek
Differential Revision: D23565003
fbshipit-source-id: dee22ea82
4 years ago
Martin Trojer
83c368f8a7
[FCP] linting facebook-clang-plugin files [4/N]
...
Summary:
arc lint run on all facebook-clang-plugins files
```
$ arc lint
$ make clang_plugin_test_replace
```
Reviewed By: jvillard
Differential Revision: D23597477
fbshipit-source-id: 746b5ed76
4 years ago
Martin Trojer
0ded7805c2
[FCP] copy facebook-clang-plugins files [2/N]
...
Summary:
Copy files from (clean commit) FCP [024a101](024a101228
) 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
4 years ago