Path: blob/main/contrib/llvm-project/compiler-rt/lib/scudo/standalone/flags_parser.h
35292 views
//===-- flags_parser.h ------------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef SCUDO_FLAGS_PARSER_H_9#define SCUDO_FLAGS_PARSER_H_1011#include "report.h"12#include "string_utils.h"1314#include <stddef.h>1516namespace scudo {1718enum class FlagType : u8 {19FT_bool,20FT_int,21};2223class FlagParser {24public:25void registerFlag(const char *Name, const char *Desc, FlagType Type,26void *Var);27void parseString(const char *S);28void printFlagDescriptions();29void parseStringPair(const char *Name, const char *Value);3031private:32static const u32 MaxFlags = 20;33struct Flag {34const char *Name;35const char *Desc;36FlagType Type;37void *Var;38} Flags[MaxFlags];3940u32 NumberOfFlags = 0;41const char *Buffer = nullptr;42uptr Pos = 0;4344void reportFatalError(const char *Error);45void skipWhitespace();46void parseFlags();47void parseFlag();48bool runHandler(const char *Name, const char *Value, char Sep);49};5051void reportUnrecognizedFlags();5253} // namespace scudo5455#endif // SCUDO_FLAGS_PARSER_H_565758