Skip to content

Commit 8bdd67c

Browse files
authored
Fix C++20 build (#705)
* Fix C++20 build + minor * Update readme
1 parent e02d90c commit 8bdd67c

16 files changed

Lines changed: 47 additions & 49 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,7 @@ endif()
3131

3232
option(PHASAR_EXPERIMENTAL_CXX20 "Build phasar in C++20 mode. This is an experimental feature" OFF)
3333

34-
set(CMAKE_EXPORT_COMPILE_COMMANDS YES)
35-
if(PHASAR_EXPERIMENTAL_CXX20)
36-
message(STATUS "Selected experimental C++20 build")
37-
set(CMAKE_CXX_STANDARD 20)
38-
else()
39-
set(CMAKE_CXX_STANDARD 17)
40-
endif()
34+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
4135
set(CMAKE_CXX_STANDARD_REQUIRED ON)
4236
set(CMAKE_CXX_EXTENSIONS OFF)
4337

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ Lead developers of PhASAR are: Fabian Schiebel (@fabianbs96)(<fabian.schiebel@i
1717

1818
PhASAR requires C++-17.
1919

20-
However, building in C++20 mode is supported as an experimental feature. You may enable this by turning the cmake option `PHASAR_EXPERIMENTAL_CXX20` on.
21-
Although phasar currently does not make use of C++20 features (except for some `concept`s behind an #ifdef border), your client application that just *uses* phasar as a library may want to use C++20 ealier.
20+
However, building in C++20 mode is supported as an experimental feature. You may enable this setting the cmake variable `CMAKE_CXX_STANDARD` to `20`.
21+
Although phasar currently does not make use of C++-20 features (except for some `concept`s behind an #ifdef border), your client application that just *uses* phasar as a library may want to use C++20 ealier.
2222

2323
## Currently Supported Version of LLVM
2424

@@ -124,7 +124,7 @@ When using CMake to compile PhASAR the following optional parameters can be used
124124
| **PHASAR_ENABLE_PAMM** : STRING | Enable the performance measurement mechanism ('Off', 'Core' or 'Full', default is Off) |
125125
| **PHASAR_ENABLE_PIC** : BOOL | Build Position-Independed Code (default is ON) |
126126
| **PHASAR_ENABLE_WARNINGS** : BOOL | Enable compiler warnings (default is ON) |
127-
| **PHASAR_EXPERIMENTAL_CXX20** : BOOL|Build phasar in C++20 mode. This is an experimental feature (default is OFF)|
127+
| **CMAKE_CXX_STANDARD** : INT|Build phasar in C++17 or C++20 mode (default is 17)|
128128

129129
You can use these parameters either directly or modify the installer-script `bootstrap.sh`
130130

cmake/phasar_macros.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ function(add_phasar_library name)
188188
EXPORT_NAME ${component_name}
189189
)
190190

191+
target_compile_features(${name} PUBLIC cxx_std_17)
192+
191193
if(LLVM_COMMON_DEPENDS)
192194
add_dependencies(${name} ${LLVM_COMMON_DEPENDS})
193195
endif(LLVM_COMMON_DEPENDS)

include/phasar/ControlFlow/CFGBase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ template <typename Derived> class CFGBase {
144144

145145
template <typename ICF, typename Domain>
146146
// NOLINTNEXTLINE(readability-identifier-naming)
147-
constexpr bool is_cfg_v = is_crtp_base_of_v<CFGBase, ICF>
147+
PSR_CONCEPT is_cfg_v = is_crtp_base_of_v<CFGBase, ICF>
148148
&&std::is_same_v<typename ICF::n_t, typename Domain::n_t>
149149
&&std::is_same_v<typename ICF::f_t, typename Domain::f_t>;
150150

include/phasar/ControlFlow/ICFGBase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ template <typename Derived> class ICFGBase {
121121
/// from the given analysis-Domain
122122
template <typename ICF, typename Domain>
123123
// NOLINTNEXTLINE(readability-identifier-naming)
124-
constexpr bool is_icfg_v = is_crtp_base_of_v<ICFGBase, ICF>
124+
PSR_CONCEPT is_icfg_v = is_crtp_base_of_v<ICFGBase, ICF>
125125
&&std::is_same_v<typename ICF::n_t, typename Domain::n_t>
126126
&&std::is_same_v<typename ICF::f_t, typename Domain::f_t>;
127127

include/phasar/DataFlow/IfdsIde/EdgeFunction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct IsEdgeFunction<
5353

5454
} // namespace detail
5555
template <typename T>
56-
static inline constexpr bool IsEdgeFunction = detail::IsEdgeFunction<T>::value;
56+
static constexpr bool IsEdgeFunction = detail::IsEdgeFunction<T>::value;
5757

5858
#else
5959
// clang-format off

include/phasar/DataFlow/IfdsIde/FlowFunctions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ template <typename FF> struct IsFlowFunction {
8383
/// Helper template to check at compile-time whether a type implements the
8484
/// FlowFunction interface, no matter which data-flow fact type it uses.
8585
template <typename FF>
86-
static constexpr bool is_flowfunction_v = IsFlowFunction<FF>::value; // NOLINT
86+
PSR_CONCEPT is_flowfunction_v = IsFlowFunction<FF>::value; // NOLINT
8787

8888
/// Given a flow-function type FF, returns a (smart) pointer type pointing to FF
8989
template <typename FF, typename = std::enable_if_t<is_flowfunction_v<FF>>>

include/phasar/Pointer/AliasInfoBase.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define PHASAR_POINTER_ALIASINFOBASE_H
1212

1313
#include "phasar/Pointer/AliasInfoTraits.h"
14+
#include "phasar/Utils/TypeTraits.h"
1415

1516
#include "llvm/ADT/DenseSet.h"
1617
#include "llvm/Support/raw_ostream.h"
@@ -74,8 +75,7 @@ struct IsAliasInfo<
7475
};
7576
} // namespace detail
7677

77-
template <typename T>
78-
static constexpr bool IsAliasInfo = detail::IsAliasInfo<T>::value;
78+
template <typename T> PSR_CONCEPT IsAliasInfo = detail::IsAliasInfo<T>::value;
7979

8080
} // namespace psr
8181

include/phasar/Pointer/PointsToInfoBase.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ struct is_PointsToTraits<
3636
: std::true_type {};
3737

3838
template <typename T>
39-
static constexpr bool is_PointsToTraits_v = // NOLINT
39+
PSR_CONCEPT is_PointsToTraits_v = // NOLINT
4040
is_PointsToTraits<T>::value;
4141

4242
// clang-format off
4343
template <typename T1, typename T2>
44-
static constexpr bool is_equivalent_PointsToTraits_v = // NOLINT
44+
PSR_CONCEPT is_equivalent_PointsToTraits_v = // NOLINT
4545
is_PointsToTraits_v<T1> && is_PointsToTraits_v<T2> &&
4646
std::is_same_v<typename T1::n_t, typename T2::n_t> &&
4747
std::is_same_v<typename T1::v_t, typename T2::v_t> &&

include/phasar/Utils/AdjacencyList.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ struct GraphTraits<AdjacencyList<T, EdgeTy>> {
163163
if constexpr (!std::is_same_v<value_type, llvm::NoneType>) {
164164
assert(G.Adj.size() == G.Nodes.size());
165165
}
166-
return psr::iota(size_t(0), G.Adj.size());
166+
return psr::iota(vertex_t(0), G.Adj.size());
167167
}
168168

169169
/// Gets the node-tag for node Vtx in graph G. Vtx must be part of G
@@ -292,8 +292,8 @@ struct GraphTraits<AdjacencyList<T, EdgeTy>> {
292292

293293
#if __cplusplus >= 202002L
294294
static_assert(is_graph<AdjacencyList<T>>);
295-
static_assert(is_reservable_graph_trait<GraphTraits<AdjacencyList<T>>>);
296295
#endif
296+
static_assert(is_reservable_graph_trait_v<GraphTraits<AdjacencyList<T>>>);
297297
};
298298

299299
} // namespace psr

0 commit comments

Comments
 (0)