Skip to content

Commit fd711a5

Browse files
authored
Merge branch 'development' into f-LLVM13Support
2 parents 7fa872f + 70fb317 commit fd711a5

47 files changed

Lines changed: 845 additions & 522 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 55 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
PhASAR a LLVM-based Static Analysis Framework
44
=============================================
55

6-
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/c944f18c7960488798a0728db9380eb5)](https://app.codacy.com/app/pdschubert/phasar?utm_source=github.com&utm_medium=referral&utm_content=secure-software-engineering/phasar&utm_campaign=Badge_Grade_Dashboard)
76
[![C++ Standard](https://img.shields.io/badge/C++_Standard-C%2B%2B17-blue.svg?style=flat&logo=c%2B%2B)](https://isocpp.org/)
87
[![GitHub license](https://img.shields.io/badge/license-MIT-blueviolet.svg)](https://raw.githubusercontent.com/secure-software-engineering/phasar/master/LICENSE.txt)
98

@@ -12,63 +11,59 @@ Version 0521
1211
Secure Software Engineering Group
1312
---------------------------------
1413

15-
+ Philipp Schubert (philipp.schubert@upb.de) and others
14+
+ Philipp Dominik Schubert (philipp.schubert@upb.de) and others
1615
+ Please also refer to https://phasar.org/
1716

18-
|branch | status |
19-
| :---: | :---: |
20-
| master | <img src="https://travis-ci.org/secure-software-engineering/phasar.svg?branch=master"> |
21-
| development | <img src="https://travis-ci.org/secure-software-engineering/phasar.svg?branch=development"> |
22-
2317
Required version of the C++ standard
2418
------------------------------------
25-
Phasar requires C++-17.
19+
PhASAR requires C++-17.
2620

2721
Currently supported version of LLVM
2822
-----------------------------------
29-
Phasar is currently set up to support LLVM-13.0.
23+
PhASAR is currently set up to support LLVM-13.0.
3024

31-
What is Phasar?
25+
What is PhASAR?
3226
---------------
33-
Phasar is a LLVM-based static analysis framework written in C++. It allows users
27+
PhASAR is a LLVM-based static analysis framework written in C++. It allows users
3428
to specify arbitrary data-flow problems which are then solved in a
3529
fully-automated manner on the specified LLVM IR target code. Computing points-to
3630
information, call-graph(s), etc. is done by the framework, thus you can focus on
3731
what matters.
3832

39-
How do I get started with Phasar?
33+
How do I get started with PhASAR?
4034
---------------------------------
41-
We have some documentation on Phasar in our [_**wiki**_](https://github.com/secure-software-engineering/phasar/wiki). You probably would like to read
35+
We have some documentation on PhASAR in our [_**wiki**_](https://github.com/secure-software-engineering/phasar/wiki). You probably would like to read
4236
this README first and then have a look on the material provided on https://phasar.org/
43-
as well. Please also have a look on Phasar's project directory and notice the project directory
37+
as well. Please also have a look on PhASAR's project directory and notice the project directory
4438
examples/ as well as the custom tool tools/myphasartool.cpp.
4539

46-
Building Phasar
40+
Building PhASAR
4741
---------------
48-
If you cannot work with one of the pre-built versions of Phasar and would like to
49-
compile Phasar yourself, then please check the wiki for installing the
50-
prerequisites and compilation. It is recommended to compile Phasar yourself in
42+
If you cannot work with one of the pre-built versions of PhASAR and would like to
43+
compile PhASAR yourself, then please check the wiki for installing the
44+
prerequisites and compilation. It is recommended to compile PhASAR yourself in
5145
order to get the full C++ experience and to have full control over the build
5246
mode.
5347

54-
Please help us to improve Phasar
48+
Please help us to improve PhASAR
5549
--------------------------------
56-
You are using Phasar and would like to help us in the future? Then please
50+
You are using PhASAR and would like to help us in the future? Then please
5751
support us by filling out this [web form](https://goo.gl/forms/YG6m3M7sxeUJmKyi1).
5852

59-
By giving us feedback you help to decide in what direction Phasar should stride in
53+
By giving us feedback you help to decide in what direction PhASAR should stride in
6054
the future and give us clues about our user base. Thank you very much!
6155

6256

6357
Installation
6458
------------
65-
Phasar can be installed using the installer scripts as explained in the following.
59+
PhASAR can be installed using the installer scripts as explained in the following.
60+
6661

67-
### Installing Phasar on an Ubuntu system
62+
### Installing PhASAR on an Ubuntu system
6863
In the following, we would like to give an complete example of how to install
69-
Phasar using an Ubuntu or Unix-like system.
64+
PhASAR using an Ubuntu or Unix-like system.
7065

71-
Therefore, we provide an installation script. To install Phasar, just navigate to the top-level
66+
Therefore, we provide an installation script. To install PhASAR, just navigate to the top-level
7267
directory of PhASAR and use the following command:
7368
```
7469
$ sudo ./bootstrap.sh
@@ -77,7 +72,7 @@ $ sudo ./bootstrap.sh
7772
Done!
7873

7974

80-
### Installing Phasar a MacOS system
75+
### Installing PhASAR a MacOS system
8176
Mac OS 10.13.1 or higher only!
8277
To install the framework on a Mac we will rely on Homebrew. (https://brew.sh/)
8378

@@ -93,7 +88,7 @@ $ brew install llvm
9388
$ export CC=/usr/local/opt/llvm/bin/clang
9489
$ export CXX=/usr/local/opt/llvm/bin/clang++
9590
# Set PATH env variable to /usr/local/opt/llvm/bin
96-
# Go to Phasar directory run the following commands
91+
# Go to PhASAR directory run the following commands
9792
$ git submodule init
9893
$ git submodule update
9994
$ mkdir build
@@ -103,11 +98,8 @@ $ make -j $(nproc) # or use a different number of cores to compile it
10398
$ sudo make install # if you wish a system-wise installation
10499
```
105100

106-
### Installing Phasar on a Windows system
107-
108-
**A solution is under implementation.**
109101

110-
### Compiling Phasar (if not already done using the installation scripts)
102+
### Compiling PhASAR (if not already done using the installation scripts)
111103
Set the system's variables for the C and C++ compiler to clang:
112104
```
113105
$ export CC=/usr/local/bin/clang
@@ -126,23 +118,23 @@ If you downloaded PhASAR as a compressed release (e.g. .zip or .tar.gz) you can
126118
$ utils/init-submodules-release.sh
127119
```
128120

129-
Navigate into the Phasar directory. The following commands will do the job and compile the Phasar framework:
121+
Navigate into the PhASAR directory. The following commands will do the job and compile the PhASAR framework:
130122

131123
```
132124
$ mkdir build
133125
$ cd build/
134126
$ cmake -DCMAKE_BUILD_TYPE=Release ..
135127
$ make -j $(nproc) # or use a different number of cores to compile it
136-
$ sudo make install # if you wish to install Phasar system wide
128+
$ sudo make install # if you wish to install PhASAR system wide
137129
```
138130

139-
When you have used the `bootstrap.sh` script to install Phasar, the above steps are already done.
140-
Use them as a reference if you wish to modify Phasar and recompile it.
131+
When you have used the `bootstrap.sh` script to install PhASAR, the above steps are already done.
132+
Use them as a reference if you wish to modify PhASAR and recompile it.
141133

142134
After compilation using cmake the following two binaries can be found in the build/ directory:
143135

144-
+ phasar-llvm - the actual Phasar command-line tool
145-
+ myphasartool - an example tool that shows how tools can be build on top of Phasar
136+
+ phasar-llvm - the actual PhASAR command-line tool
137+
+ myphasartool - an example tool that shows how tools can be build on top of PhASAR
146138

147139
Use the command:
148140

@@ -154,15 +146,17 @@ in order to display the manual and help message.
154146

155147
Please be careful and check if errors occur during the compilation.
156148

157-
When using CMake to compile Phasar the following optional parameters can be used:
149+
When using CMake to compile PhASAR the following optional parameters can be used:
158150

159151
| Parameter : Type| Effect |
160152
|-----------|--------|
161-
| <b>BUILD_SHARED_LIBS</b> : BOOL | Build shared libraries (default is OFF) |
162-
| <b>CMAKE_BUILD_TYPE</b> : STRING | Build Phasar in 'Debug' or 'Release' mode <br> (default is 'Debug') |
163-
| <b>CMAKE_INSTALL_PREFIX</b> : PATH | Path where Phasar will be installed if <br> “make install” is invoked or the “install” <br> target is built (default is /usr/local) |
164-
| <b>PHASAR_BUILD_DOC</b> : BOOL | Build Phasar documentation (default is OFF) |
165-
| <b>PHASAR_BUILD_UNITTESTS</b> : BOOL | Build Phasar unittests (default is OFF) |
153+
| <b>BUILD_SHARED_LIBS</b> : BOOL | Build shared libraries (default is ON) |
154+
| <b>CMAKE_BUILD_TYPE</b> : STRING | Build PhASAR in 'Debug' or 'Release' mode <br> (default is 'Debug') |
155+
| <b>CMAKE_INSTALL_PREFIX</b> : PATH | Path where PhASAR will be installed if <br> “make install” is invoked or the “install” <br> target is built (default is /usr/local/phasar) |
156+
| <b>PHASAR_BUILD_DOC</b> : BOOL | Build PhASAR documentation (default is OFF) |
157+
| <b>PHASAR_BUILD_UNITTESTS</b> : BOOL | Build PhASAR unit tests (default is ON) |
158+
| <b>PHASAR_BUILD_IR</b> : BOOL | Build PhASAR IR (required for running the unit tests) (default is ON) |
159+
| <b>PHASAR_BUILD_OPENSSL_TS_UNITTESTS</b> : BOOL | Build PhASAR unit tests that require OpenSSL (default is OFF) |
166160
| <b>PHASAR_ENABLE_PAMM</b> : STRING | Enable the performance measurement mechanism <br> ('Off', 'Core' or 'Full', default is Off) |
167161
| <b>PHASAR_ENABLE_PIC</b> : BOOL | Build Position-Independed Code (default is ON) |
168162
| <b>PHASAR_ENABLE_WARNINGS</b> : BOOL | Enable compiler warnings (default is ON) |
@@ -180,6 +174,22 @@ To test if everything works as expected please run the following command:
180174

181175
If you obtain output other than a segmentation fault or an exception terminating the program abnormally everything works as expected.
182176

183-
How to use Phasar?
177+
How to use PhASAR?
184178
------------------
185-
Please consult our [Phasar wiki pages](https://github.com/secure-software-engineering/phasar/wiki).
179+
Please consult our [PhASAR wiki pages](https://github.com/secure-software-engineering/phasar/wiki).
180+
181+
182+
### Installing PhASAR's Git pre-commit hook
183+
You are very much welcome to contribute to the PhASAR project.
184+
Please make sure that you install our pre-commit hook that ensures your commit adheres to the most important coding rules of the PhASAR project.
185+
For more details please consult [Coding Conventions](https://github.com/secure-software-engineering/phasar/wiki/Coding-Conventions) and [Contributing to PhASAR](https://github.com/secure-software-engineering/phasar/wiki/Contributing-to-PhASAR).
186+
187+
To install the pre-commit hook, please run the following commands in PhASAR's root directory:
188+
189+
```
190+
$ pip install pre-commit
191+
$ pre-commit install
192+
193+
```
194+
195+
Thanks. And have fun with the project.

cmake/phasar_macros.cmake

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function(add_phasar_unittest test_name)
5050
endfunction()
5151

5252
function(generate_ll_file)
53-
set(options MEM2REG DEBUG)
53+
set(options MEM2REG DEBUG O1 O2 O3)
5454
set(testfile FILE)
5555
cmake_parse_arguments(GEN_LL "${options}" "${testfile}" "" ${ARGN} )
5656
# get file extension
@@ -92,6 +92,21 @@ function(generate_ll_file)
9292
list(APPEND GEN_C_FLAGS -g)
9393
set(GEN_CMD_COMMENT "${GEN_CMD_COMMENT}[DBG]")
9494
endif()
95+
if(GEN_LL_O1)
96+
list(APPEND GEN_CXX_FLAGS -O1)
97+
list(APPEND GEN_C_FLAGS -O1)
98+
set(GEN_CMD_COMMENT "${GEN_CMD_COMMENT}[O1]")
99+
endif()
100+
if(GEN_LL_O2)
101+
list(APPEND GEN_CXX_FLAGS -O2)
102+
list(APPEND GEN_C_FLAGS -O2)
103+
set(GEN_CMD_COMMENT "${GEN_CMD_COMMENT}[O2]")
104+
endif()
105+
if(GEN_LL_03)
106+
list(APPEND GEN_CXX_FLAGS -O3)
107+
list(APPEND GEN_C_FLAGS -O3)
108+
set(GEN_CMD_COMMENT "${GEN_CMD_COMMENT}[O3]")
109+
endif()
95110
set(GEN_CMD_COMMENT "${GEN_CMD_COMMENT} ${GEN_LL_FILE}")
96111

97112
# define .ll file generation command

external/googletest

Submodule googletest updated 115 files

external/json-schema-validator

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/ExtendedTaintAnalysis/AbstractMemoryLocation.h

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class AbstractMemoryLocationImpl final
7878

7979
AbstractMemoryLocationImpl(const AbstractMemoryLocationImpl &) = delete;
8080
AbstractMemoryLocationImpl(AbstractMemoryLocationImpl &&) = delete;
81+
~AbstractMemoryLocationImpl() = default;
8182

8283
AbstractMemoryLocationImpl &
8384
operator=(const AbstractMemoryLocationImpl &) = delete;
@@ -153,31 +154,45 @@ class AbstractMemoryLocationImpl final
153154
class AbstractMemoryLocation {
154155
public:
155156
explicit AbstractMemoryLocation() noexcept = default;
157+
158+
AbstractMemoryLocation(const AbstractMemoryLocation &) noexcept = default;
159+
AbstractMemoryLocation(AbstractMemoryLocation &&) noexcept = default;
160+
~AbstractMemoryLocation() = default;
161+
162+
AbstractMemoryLocation &
163+
operator=(const AbstractMemoryLocation &) noexcept = default;
164+
AbstractMemoryLocation &
165+
operator=(AbstractMemoryLocation &&) noexcept = default;
166+
156167
AbstractMemoryLocation(
157168
const detail::AbstractMemoryLocationImpl *Impl) noexcept;
169+
158170
inline const detail::AbstractMemoryLocationImpl *operator->() const {
159171
return PImpl;
160172
}
161173

162174
/// Provide an arbitrary partial order for being able to store TaintedValues
163175
/// in std::set or as key in std::map
164-
inline bool operator<(const AbstractMemoryLocation &TV) const {
165-
return PImpl->base() < TV->base();
176+
inline bool operator<(AbstractMemoryLocation TV) const {
177+
return PImpl < TV.PImpl;
166178
}
167179

168-
inline bool operator==(const AbstractMemoryLocation &AML) const {
180+
inline bool operator==(AbstractMemoryLocation AML) const {
169181
return PImpl == AML.PImpl;
170182
}
171183

172-
friend std::ostream &operator<<(std::ostream &OS,
173-
const AbstractMemoryLocation &TV);
184+
inline bool operator!=(AbstractMemoryLocation AML) const {
185+
return !(*this == AML);
186+
}
187+
188+
friend std::ostream &operator<<(std::ostream &OS, AbstractMemoryLocation TV);
174189
friend llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
175-
const AbstractMemoryLocation &TV);
190+
AbstractMemoryLocation TV);
176191

177192
/// Computes the absolute offset-difference between this and TV assuming,
178193
/// either this->isProperPrefixOf(TV) or vice versa.
179194
[[nodiscard]] inline llvm::ArrayRef<ptrdiff_t>
180-
operator-(const AbstractMemoryLocation &TV) const {
195+
operator-(AbstractMemoryLocation TV) const {
181196
return *PImpl - *TV.PImpl;
182197
}
183198

@@ -187,14 +202,16 @@ class AbstractMemoryLocation {
187202
const detail::AbstractMemoryLocationImpl *PImpl = nullptr;
188203
};
189204

205+
// NOLINTNEXTLINE(readability-identifier-naming)
190206
std::string DToString(const AbstractMemoryLocation &AML);
207+
208+
// NOLINTNEXTLINE(readability-identifier-naming)
209+
llvm::hash_code hash_value(psr::AbstractMemoryLocation Val);
191210
} // namespace psr
192211

193212
// Hashing support
194213
namespace llvm {
195214

196-
hash_code hash_value(const psr::AbstractMemoryLocation &Val);
197-
198215
template <> struct DenseMapInfo<psr::AbstractMemoryLocation> {
199216
static inline psr::AbstractMemoryLocation getEmptyKey() {
200217
return psr::AbstractMemoryLocation(
@@ -205,11 +222,11 @@ template <> struct DenseMapInfo<psr::AbstractMemoryLocation> {
205222
DenseMapInfo<
206223
psr::detail::AbstractMemoryLocationImpl *>::getTombstoneKey());
207224
}
208-
static unsigned getHashValue(const psr::AbstractMemoryLocation &Val) {
225+
static unsigned getHashValue(psr::AbstractMemoryLocation Val) {
209226
return hash_value(Val);
210227
}
211-
static bool isEqual(const psr::AbstractMemoryLocation &LHS,
212-
const psr::AbstractMemoryLocation &RHS) {
228+
static bool isEqual(psr::AbstractMemoryLocation LHS,
229+
psr::AbstractMemoryLocation RHS) {
213230
return LHS.operator->() == RHS.operator->();
214231
}
215232
};
@@ -219,10 +236,10 @@ template <> struct DenseMapInfo<psr::AbstractMemoryLocation> {
219236
namespace std {
220237
template <> struct hash<psr::AbstractMemoryLocation> {
221238
size_t operator()(const psr::AbstractMemoryLocation &Val) const {
222-
return llvm::hash_value(Val);
239+
return hash_value(Val);
223240
}
224241
};
225242

226243
} // namespace std
227244

228-
#endif // PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_EXTENDEDTAINTANALYSIS_ABSTRACTMEMORYLOCATION_H_
245+
#endif // PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_EXTENDEDTAINTANALYSIS_ABSTRACTMEMORYLOCATION_H_

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/ExtendedTaintAnalysis/AbstractMemoryLocationFactory.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class AbstractMemoryLocationFactoryBase {
8989
const llvm::DataLayout *DL = nullptr;
9090

9191
const detail::AbstractMemoryLocationImpl *
92-
getOrCreateImpl(const llvm::Value *V, llvm::SmallVectorImpl<ptrdiff_t> &&offs,
92+
getOrCreateImpl(const llvm::Value *V, llvm::SmallVectorImpl<ptrdiff_t> &&Offs,
9393
unsigned BOUND);
9494

9595
const detail::AbstractMemoryLocationImpl *
@@ -152,6 +152,9 @@ class AbstractMemoryLocationFactory<AbstractMemoryLocation>
152152
size_t InitialCapacity)
153153
: detail::AbstractMemoryLocationFactoryBase(DL, InitialCapacity) {}
154154
AbstractMemoryLocationFactory(const AbstractMemoryLocationFactory &) = delete;
155+
~AbstractMemoryLocationFactory() = default;
156+
AbstractMemoryLocationFactory &
157+
operator=(const AbstractMemoryLocationFactory &) = delete;
155158

156159
[[nodiscard]] AbstractMemoryLocation Create(const llvm::Value *V,
157160
unsigned BOUND) {
@@ -205,4 +208,4 @@ class AbstractMemoryLocationFactory<AbstractMemoryLocation>
205208

206209
} // namespace psr
207210

208-
#endif // PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_EXTENDEDTAINTANALYSIS_ABSTRACTMEMORYLOCATIONFACTORY_H_
211+
#endif // PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_EXTENDEDTAINTANALYSIS_ABSTRACTMEMORYLOCATIONFACTORY_H_

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/ExtendedTaintAnalysis/ComposeEdgeFunction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ class ComposeEdgeFunction : public EdgeFunctionBase {
3434
};
3535
} // namespace psr::XTaint
3636

37-
#endif // PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_EXTENDEDTAINTANALYSIS_COMPOSEEDGEFUNCTION_H_
37+
#endif // PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_EXTENDEDTAINTANALYSIS_COMPOSEEDGEFUNCTION_H_

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/ExtendedTaintAnalysis/DebugEdgeIdentity.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
namespace llvm {
1717
class Instruction;
18-
}
18+
} // namespace llvm
1919

2020
namespace psr::XTaint {
2121
class DebugEdgeIdentity
@@ -39,4 +39,4 @@ class DebugEdgeIdentity
3939
};
4040
} // namespace psr::XTaint
4141

42-
#endif // PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_EXTENDEDTAINTANALYSIS_DEBUGEDGEIDENTITY_H_
42+
#endif // PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_EXTENDEDTAINTANALYSIS_DEBUGEDGEIDENTITY_H_

0 commit comments

Comments
 (0)