mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
Fix and ban namespace clobbering
Fix an instance where the `std` namespace got clobbered into the global namespace by accident.
This commit is contained in:
@@ -174,8 +174,8 @@ private:
|
||||
return Result;
|
||||
}
|
||||
|
||||
template<ranges::sized_range InputContainer,
|
||||
ranges::sized_range OutputContainer>
|
||||
template<std::ranges::sized_range InputContainer,
|
||||
std::ranges::sized_range OutputContainer>
|
||||
void assertSortingWasSuccessful(llvm::StringRef RegisterType,
|
||||
const InputContainer &Input,
|
||||
const OutputContainer &Output) const {
|
||||
@@ -206,7 +206,7 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
template<ranges::sized_range Container>
|
||||
template<std::ranges::sized_range Container>
|
||||
llvm::SmallVector<model::Register::Values, 8>
|
||||
sortArguments(const Container &Registers) const {
|
||||
SortedVector<model::Register::Values> Lookup;
|
||||
@@ -225,7 +225,7 @@ public:
|
||||
return Result;
|
||||
}
|
||||
|
||||
template<ranges::sized_range Container>
|
||||
template<std::ranges::sized_range Container>
|
||||
llvm::SmallVector<model::Register::Values, 8>
|
||||
sortReturnValues(const Container &Registers) const {
|
||||
SortedVector<model::Register::Values> Lookup;
|
||||
|
||||
@@ -70,7 +70,7 @@ inline constexpr uint64_t paddedSizeOnStack(uint64_t RealSize,
|
||||
/// \tparam DerivedType The desired type to filter based on
|
||||
/// \param Types The list of types to filter
|
||||
/// \return filtered list
|
||||
template<derived_from<model::TypeDefinition> DerivedType,
|
||||
template<std::derived_from<model::TypeDefinition> DerivedType,
|
||||
RangeOf<model::UpcastableTypeDefinition> OwningRange,
|
||||
RangeOf<model::TypeDefinition *> ViewRange =
|
||||
std::vector<model::TypeDefinition *>>
|
||||
|
||||
@@ -43,12 +43,10 @@ concept VectorOfPairs = std::is_same_v<std::vector<std::pair<
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace std;
|
||||
|
||||
static_assert(VectorOfPairs<const vector<pair<const int, long>>>, "");
|
||||
static_assert(VectorOfPairs<vector<pair<const int, long>>>, "");
|
||||
static_assert(not VectorOfPairs<const vector<pair<int, long>>>, "");
|
||||
static_assert(not VectorOfPairs<vector<pair<int, long>>>, "");
|
||||
static_assert(VectorOfPairs<const std::vector<std::pair<const int, long>>>, "");
|
||||
static_assert(VectorOfPairs<std::vector<std::pair<const int, long>>>, "");
|
||||
static_assert(not VectorOfPairs<const std::vector<std::pair<int, long>>>, "");
|
||||
static_assert(not VectorOfPairs<std::vector<std::pair<int, long>>>, "");
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ using SuccessorContainer = SortedVector<UpcastablePointer<FunctionEdgeBase>>;
|
||||
|
||||
template<typename T>
|
||||
concept SpecializationOfBasicBlock = requires(T Instance) {
|
||||
{ Instance.ID() } -> convertible_to<BasicBlockID>;
|
||||
{ Instance.End() } -> convertible_to<MetaAddress>;
|
||||
{ Instance.ID() } -> std::convertible_to<BasicBlockID>;
|
||||
{ Instance.End() } -> std::convertible_to<MetaAddress>;
|
||||
};
|
||||
|
||||
struct ParsedSuccessor {
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
/// - the reference to the newly made definition which can be used
|
||||
/// to modify it right away,
|
||||
/// - the corresponding defined type ready to be attached to others.
|
||||
template<derived_from<model::TypeDefinition> NewType,
|
||||
template<std::derived_from<model::TypeDefinition> NewType,
|
||||
typename... ArgumentTypes>
|
||||
[[nodiscard]] std::pair<NewType &, model::UpcastableType>
|
||||
makeTypeDefinition(ArgumentTypes &&...Arguments) {
|
||||
|
||||
@@ -39,19 +39,11 @@ enum Values {
|
||||
|
||||
}; // namespace PCAffectingCSV
|
||||
|
||||
namespace revng::detail {
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
using CSVFactory = std::function<
|
||||
GlobalVariable *(PCAffectingCSV::Values CSVID)>;
|
||||
|
||||
}; // namespace revng::detail
|
||||
|
||||
using CSVFactory = revng::detail::CSVFactory;
|
||||
|
||||
class ProgramCounterHandler {
|
||||
protected:
|
||||
using CSVFactory = llvm::function_ref<
|
||||
llvm::GlobalVariable *(PCAffectingCSV::Values CSVID)>;
|
||||
|
||||
static constexpr const char *AddressSpaceName = "pc_address_space";
|
||||
static constexpr const char *EpochName = "pc_epoch";
|
||||
static constexpr const char *TypeName = "pc_type";
|
||||
@@ -79,7 +71,7 @@ public:
|
||||
static std::unique_ptr<ProgramCounterHandler>
|
||||
create(model::Architecture::Values Architecture,
|
||||
llvm::Module *M,
|
||||
const CSVFactory &Factory);
|
||||
CSVFactory Factory);
|
||||
|
||||
static std::unique_ptr<ProgramCounterHandler>
|
||||
fromModule(model::Architecture::Values Architecture, llvm::Module *M);
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace pipeline {
|
||||
|
||||
template<typename T>
|
||||
concept HasID = requires {
|
||||
{ T::ID } -> convertible_to<const char &>;
|
||||
{ T::ID } -> std::convertible_to<const char &>;
|
||||
};
|
||||
|
||||
class ContainerTypeInfoBase {
|
||||
|
||||
@@ -84,7 +84,8 @@ public:
|
||||
template<typename T, typename... G>
|
||||
static ContainerFactory fromGlobal(G &&...Vals) {
|
||||
using Factory = ContainerFactoryWithArgs<T, G...>;
|
||||
return ContainerFactory(make_unique<Factory>(std::forward<G>(Vals)...));
|
||||
return ContainerFactory(std::make_unique<
|
||||
Factory>(std::forward<G>(Vals)...));
|
||||
}
|
||||
|
||||
ContainerFactory(const ContainerFactory &Other) :
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
|
||||
template<typename T>
|
||||
concept LLVMPass = requires(T P) {
|
||||
{ T::Name } -> convertible_to<const char *>;
|
||||
{ T::Name } -> std::convertible_to<const char *>;
|
||||
{ P.registerPasses(std::declval<llvm::legacy::PassManager &>()) };
|
||||
};
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
namespace pipeline {
|
||||
template<typename T>
|
||||
concept HasName = requires() {
|
||||
{ T::Name } -> convertible_to<const char *>;
|
||||
{ T::Name } -> std::convertible_to<const char *>;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@@ -80,7 +80,8 @@ concept ReturnsError = invokableTypeReturnsError<Invokable>();
|
||||
/// never fails.
|
||||
///
|
||||
template<typename InvokableType, typename First, typename... Rest>
|
||||
concept Invokable = convertible_to<ExecutionContext &, std::remove_cv_t<First>>
|
||||
concept Invokable = std::convertible_to<ExecutionContext &,
|
||||
std::remove_cv_t<First>>
|
||||
and HasName<InvokableType>;
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -193,7 +193,7 @@ public:
|
||||
void emplace_back(Args &&...A) {
|
||||
Contained.emplace_back(std::forward<Args>(A)...);
|
||||
llvm::sort(Contained);
|
||||
Contained.erase(unique(Contained.begin(), Contained.end()),
|
||||
Contained.erase(std::unique(Contained.begin(), Contained.end()),
|
||||
Contained.end());
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ public:
|
||||
void push_back(const Target &Target) {
|
||||
Contained.push_back(Target);
|
||||
llvm::sort(Contained);
|
||||
Contained.erase(unique(Contained.begin(), Contained.end()),
|
||||
Contained.erase(std::unique(Contained.begin(), Contained.end()),
|
||||
Contained.end());
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ public:
|
||||
using iterator = Map::iterator;
|
||||
using const_iterator = Map::const_iterator;
|
||||
using value_type = Map::value_type;
|
||||
using key_iterator = decltype(declval<Map>().keys());
|
||||
using key_iterator = decltype(std::declval<Map>().keys());
|
||||
|
||||
private:
|
||||
Map Status;
|
||||
|
||||
@@ -78,7 +78,7 @@ static_assert(Yamlizable<pipeline::TargetsList>);
|
||||
|
||||
template<typename T>
|
||||
concept HasEmpty = requires(T &&V) {
|
||||
{ V.empty() } -> same_as<bool>;
|
||||
{ V.empty() } -> std::same_as<bool>;
|
||||
};
|
||||
|
||||
template<Yamlizable T>
|
||||
|
||||
@@ -67,10 +67,11 @@ static_assert(MFP::MonotoneFrameworkInstance<AdvancedValueInfoMFI>);
|
||||
|
||||
/// \p DFG the data flow graph containing the instructions we're interested in.
|
||||
/// \p Context the position in the function for the current query.
|
||||
std::tuple<std::map<llvm::Instruction *, ConstantRangeSet>,
|
||||
ControlFlowEdgesGraph,
|
||||
map<const ForwardNode<ControlFlowEdgesNode> *,
|
||||
MFP::MFPResult<map<llvm::Instruction *, ConstantRangeSet>>>>
|
||||
std::tuple<
|
||||
std::map<llvm::Instruction *, ConstantRangeSet>,
|
||||
ControlFlowEdgesGraph,
|
||||
std::map<const ForwardNode<ControlFlowEdgesNode> *,
|
||||
MFP::MFPResult<std::map<llvm::Instruction *, ConstantRangeSet>>>>
|
||||
runAVI(const DataFlowGraph &DFG,
|
||||
llvm::Instruction *Context,
|
||||
const llvm::DominatorTree &DT,
|
||||
|
||||
@@ -57,8 +57,8 @@ private:
|
||||
//
|
||||
DataFlowGraph DataFlowGraph;
|
||||
ConstraintsMap OracleConstraints;
|
||||
map<const ForwardNode<ControlFlowEdgesNode> *,
|
||||
MFP::MFPResult<map<llvm::Instruction *, ConstantRangeSet>>>
|
||||
std::map<const ForwardNode<ControlFlowEdgesNode> *,
|
||||
MFP::MFPResult<std::map<llvm::Instruction *, ConstantRangeSet>>>
|
||||
MFIResults;
|
||||
std::optional<MaterializedValues> Values;
|
||||
ControlFlowEdgesGraph CFEG;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "revng/Support/ResourceFinder.h"
|
||||
#include "revng/Support/YAMLTraits.h"
|
||||
|
||||
template<ranges::range RegisterContainer>
|
||||
template<std::ranges::range RegisterContainer>
|
||||
bool verifyRegisters(const RegisterContainer &Registers,
|
||||
model::Architecture::Values Architecture) {
|
||||
for (const model::Register::Values &Register : Registers) {
|
||||
|
||||
@@ -457,7 +457,8 @@ void DetectABI::analyzeABI() {
|
||||
Task.advance("Create temporary functions");
|
||||
for (model::Function &Function : Binary->Functions()) {
|
||||
const MetaAddress &Entry = Function.Entry();
|
||||
auto NewFunction = make_unique<OutlinedFunction>(Analyzer.outline(Entry));
|
||||
auto NewFunction = std::make_unique<OutlinedFunction>(Analyzer
|
||||
.outline(Entry));
|
||||
Functions[Function.Entry()] = std::move(NewFunction);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "revng/Pipes/TaggedFunctionKind.h"
|
||||
|
||||
using namespace llvm;
|
||||
using std::tuple;
|
||||
|
||||
class InvokeIsolatedFunctionsImpl {
|
||||
private:
|
||||
|
||||
@@ -39,7 +39,7 @@ bool ptml::HeaderBuilder::printModelHeader() {
|
||||
B.append(std::move(Includes));
|
||||
|
||||
if (not Configuration.PostIncludeSnippet.empty())
|
||||
B.append(Configuration.PostIncludeSnippet + "\n"s);
|
||||
B.append(Configuration.PostIncludeSnippet + '\n');
|
||||
|
||||
std::string Defines = B.getDirective(CBuilder::Directive::IfNotDef) + " "
|
||||
+ B.getNullTag() + "\n"
|
||||
|
||||
@@ -928,8 +928,9 @@ ELFImporter<T, HasAddend>::ehFrameFromEhFrameHdr() {
|
||||
|
||||
template<typename T, bool HasAddend>
|
||||
void ELFImporter<T, HasAddend>::parseEHFrame(MetaAddress EHFrameAddress,
|
||||
optional<uint64_t> FDEsCount,
|
||||
optional<uint64_t> EHFrameSize) {
|
||||
std::optional<uint64_t> FDEsCount,
|
||||
std::optional<uint64_t>
|
||||
EHFrameSize) {
|
||||
if (not FDEsCount and not EHFrameSize) {
|
||||
revng_log(ELFImporterLog, "Neither FDE count and .eh_frame size available");
|
||||
return;
|
||||
|
||||
@@ -436,7 +436,8 @@ llvm::Error model::CNameBuilder::isNameReserved(llvm::StringRef Name) const {
|
||||
}
|
||||
|
||||
if (std::isdigit(Name[0]))
|
||||
return revng::createError("it starts with a digit: `"s + Name[0] + '`');
|
||||
return revng::createError(std::string{ "it starts with a digit: `" }
|
||||
+ Name[0] + '`');
|
||||
|
||||
// Filter out primitive names we use - we don't want collisions with those
|
||||
if (model::PrimitiveType::isCName(Name))
|
||||
@@ -584,7 +585,8 @@ model::AssemblyNameBuilder::isNameReserved(llvm::StringRef Name) const {
|
||||
}
|
||||
|
||||
if (std::isdigit(Name[0]))
|
||||
return revng::createError("it starts with a digit: `"s + Name[0] + '`');
|
||||
return revng::createError(std::string{ "it starts with a digit: `" }
|
||||
+ Name[0] + '`');
|
||||
|
||||
if (Configuration.ReserveNamesStartingWithUnderscore())
|
||||
if (Name[0] == '_')
|
||||
|
||||
@@ -901,7 +901,7 @@ getMinimumPCAlignment(model::Architecture::Values Architecture) {
|
||||
std::unique_ptr<ProgramCounterHandler>
|
||||
PCH::create(model::Architecture::Values Architecture,
|
||||
Module *M,
|
||||
const CSVFactory &Factory) {
|
||||
CSVFactory Factory) {
|
||||
auto Alignment = getMinimumPCAlignment(Architecture);
|
||||
|
||||
switch (Architecture) {
|
||||
|
||||
@@ -333,7 +333,7 @@ static void runnerImplementation(std::function<ReturnT(Args...)> Function,
|
||||
"function's prototype");
|
||||
|
||||
auto Sequence = std::make_index_sequence<sizeof...(Args)>();
|
||||
if constexpr (is_same_v<ReturnT, void>) {
|
||||
if constexpr (std::is_same_v<ReturnT, void>) {
|
||||
runCommand<Name>(Function, Arguments, Context, Sequence);
|
||||
return;
|
||||
} else {
|
||||
|
||||
@@ -357,10 +357,10 @@ PipelineManager::PipelineManager(llvm::ArrayRef<std::string> EnablingFlags,
|
||||
ExecutionDirectory(StorageClient.get(), "") {
|
||||
LLVMContext = std::make_unique<llvm::LLVMContext>();
|
||||
auto Context = setUpContext(*LLVMContext);
|
||||
PipelineContext = make_unique<pipeline::Context>(std::move(Context));
|
||||
PipelineContext = std::make_unique<pipeline::Context>(std::move(Context));
|
||||
|
||||
auto Loader = setupLoader(*PipelineContext, EnablingFlags);
|
||||
this->Loader = make_unique<pipeline::Loader>(std::move(Loader));
|
||||
this->Loader = std::make_unique<pipeline::Loader>(std::move(Loader));
|
||||
}
|
||||
|
||||
llvm::Expected<PipelineManager>
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "Helpers.h"
|
||||
|
||||
using namespace llvm;
|
||||
using std::tie;
|
||||
|
||||
static Logger Log("segregate-stack-accesses");
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "revng/ValueMaterializer/Helpers.h"
|
||||
|
||||
using namespace llvm;
|
||||
using std::map;
|
||||
|
||||
static Logger AVILogger("avi");
|
||||
|
||||
|
||||
@@ -403,14 +403,14 @@ handleSpecialCases(SortedVector<yield::TaggedString> &&Input,
|
||||
Instruction);
|
||||
|
||||
uint64_t CurrentIndex = ++Iterator->Index() - 1;
|
||||
Result.emplace(CurrentIndex, yield::TagType::Helper, "offset_to("s);
|
||||
Result.emplace(CurrentIndex, yield::TagType::Helper, "offset_to(");
|
||||
Result.emplace(emitAddress(std::move(*Iterator),
|
||||
Address,
|
||||
BasicBlock,
|
||||
Function,
|
||||
Binary,
|
||||
NameBuilder));
|
||||
Result.emplace(CurrentIndex + 2, yield::TagType::Helper, ")"s);
|
||||
Result.emplace(CurrentIndex + 2, yield::TagType::Helper, ")");
|
||||
IndexOffset += 2;
|
||||
} else {
|
||||
// TODO: handle other interesting tag types.
|
||||
|
||||
+1
-1
@@ -273,7 +273,7 @@ constexpr bool isVertical(yield::layout::sugiyama::Orientation Orientation) {
|
||||
|
||||
template<typename CallableType, typename NodeType>
|
||||
concept NodeExporter = requires(CallableType &&Callable, const NodeType &Node) {
|
||||
{ Callable(Node) } -> convertible_to<std::string>;
|
||||
{ Callable(Node) } -> std::convertible_to<std::string>;
|
||||
};
|
||||
|
||||
template<bool ShouldEmitEmptyNodes,
|
||||
|
||||
@@ -335,7 +335,7 @@ struct std::hash<const /*= struct | fullname =*/::Key> {
|
||||
}
|
||||
};
|
||||
template<>
|
||||
struct hash</*= struct | fullname =*/::Key> : hash<const /*= struct | fullname =*/::Key> {};
|
||||
struct std::hash</*= struct | fullname =*/::Key> : std::hash<const /*= struct | fullname =*/::Key> {};
|
||||
/** endif **/
|
||||
|
||||
/*# --- UpcastablePointer stuff --- #*/
|
||||
|
||||
@@ -169,6 +169,12 @@ read_passes:
|
||||
matcher:
|
||||
type: regexes_matcher
|
||||
regexes: ['^static\s']
|
||||
- name: Headers should not clobber namespaces
|
||||
matcher:
|
||||
type: regexes_matcher
|
||||
regexes:
|
||||
- '^using namespace \w+;'
|
||||
- '^namespace \w+ = [\w:]+;'
|
||||
- type: WhitespaceCheckPass
|
||||
- type: SingleCommandPass
|
||||
name: codespell
|
||||
|
||||
@@ -25,7 +25,7 @@ struct Expected {
|
||||
};
|
||||
|
||||
template<typename... Types>
|
||||
requires(same_as<Types, Expected> && ...)
|
||||
requires(std::same_as<Types, Expected> && ...)
|
||||
void testAlignment(model::UpcastableType &&Type, const Types &...TestCases) {
|
||||
for (auto &&[ABI, Expected] : std::array{ TestCases... }) {
|
||||
std::optional<uint64_t> TestResult = ABI.alignment(*Type);
|
||||
|
||||
@@ -91,7 +91,8 @@ template<typename LeftType, typename RightType>
|
||||
static void
|
||||
compare(LeftType &Left,
|
||||
RightType &Right,
|
||||
std::vector<std::pair<optional<int>, optional<int>>> &&Expected) {
|
||||
std::vector<std::pair<std::optional<int>, std::optional<int>>>
|
||||
&&Expected) {
|
||||
using LeftKE = KeyContainer<LeftType>;
|
||||
using RightKE = KeyContainer<RightType>;
|
||||
using left_pointer = element_pointer_t<LeftType>;
|
||||
|
||||
@@ -54,9 +54,10 @@ static cl::opt<bool> ListArtifacts("list",
|
||||
cl::cat(MainCategory),
|
||||
cl::init(false));
|
||||
|
||||
static cl::opt<string> Analyses("analyses",
|
||||
cl::desc("Analyses to run, comma separated"),
|
||||
cl::cat(MainCategory));
|
||||
static cl::opt<std::string> Analyses("analyses",
|
||||
cl::desc("Analyses to run, comma "
|
||||
"separated"),
|
||||
cl::cat(MainCategory));
|
||||
|
||||
static cl::opt<bool> Analyze("analyze",
|
||||
cl::desc("Run revng-initial-auto-analysis"),
|
||||
|
||||
@@ -85,7 +85,8 @@ int main(int argc, char *argv[]) {
|
||||
llvm::StringRef PipeArgument = Arguments[0];
|
||||
llvm::StringRef ModelArgument = Arguments[1];
|
||||
|
||||
auto ContainerArguments = llvm::ArrayRef<string>(Arguments).drop_front(2);
|
||||
auto ContainerArguments = llvm::ArrayRef<std::string>(Arguments)
|
||||
.drop_front(2);
|
||||
|
||||
const auto &Name = ModelGlobalName;
|
||||
auto *Model(cantFail(Manager.context().getGlobal<ModelGlobal>(Name)));
|
||||
|
||||
Reference in New Issue
Block a user