* This file is part of the MindStudio project.
* Copyright (c) 2025 Huawei Technologies Co.,Ltd.
*
* MindStudio is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* ------------------------------------------------------------------------- */
#ifndef PLUGIN_CLANG_INTERFACE_H
#define PLUGIN_CLANG_INTERFACE_H
#include <map>
#include <cstdint>
#include <string>
#include "core/framework/utility/macros.h"
extern "C" {
#define NO_INSTRUMENTATION 0
#define INSTRUMENTATION_BEFORE 1
#define INSTRUMENTATION_AFTER 2
#define FUNC_SUBSTITUTION 3
uint32_t NeedReport(const char *decoratedName);
}
namespace Sanitizer {
class SanitizerAPIRegister {
public:
void Register(std::string decoratedName, uint32_t place);
uint32_t Get(std::string decoratedName);
static SanitizerAPIRegister *GetInstance();
private:
SanitizerAPIRegister() = default;
std::map<std::string, uint32_t> decoratedNames_;
};
class SanitizerAPIBuiler {
public:
SanitizerAPIBuiler(std::string decoratedName, uint32_t place);
};
}
#define REPORT_API_REGISTER_WITH_PLACE(place, name) \
static SanitizerAPIBuiler MACRO_CONCAT(sanitizerApiOf##name, __COUNTER__) = \
Sanitizer::SanitizerAPIBuiler(#name, place)
#define REPORT_API_REGISTER(name) REPORT_API_REGISTER_WITH_PLACE(INSTRUMENTATION_BEFORE, name)
#endif