#include "MacroToEnumCheck.h"
#include "IntegralLiteralExpressionMatcher.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/STLExtras.h"
#include <algorithm>
#include <cassert>
#include <cctype>
#include <string>
namespace clang::tidy::modernize {
static bool hasOnlyComments(SourceLocation Loc, const LangOptions &Options,
StringRef Text) { … }
static StringRef getTokenName(const Token &Tok) { … }
namespace {
struct EnumMacro { … };
MacroList;
enum class IncludeGuard { … };
struct FileState { … };
}
class MacroToEnumCallbacks : public PPCallbacks { … };
bool MacroToEnumCallbacks::isConsecutiveMacro(const MacroDirective *MD) const { … }
void MacroToEnumCallbacks::clearCurrentEnum(SourceLocation Loc) { … }
void MacroToEnumCallbacks::conditionStart(const SourceLocation &Loc) { … }
void MacroToEnumCallbacks::checkCondition(SourceRange Range) { … }
void MacroToEnumCallbacks::checkName(const Token &MacroNameTok) { … }
void MacroToEnumCallbacks::rememberExpressionName(const Token &Tok) { … }
void MacroToEnumCallbacks::rememberExpressionTokens(
ArrayRef<Token> MacroTokens) { … }
void MacroToEnumCallbacks::FileChanged(SourceLocation Loc,
FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType,
FileID PrevFID) { … }
bool MacroToEnumCallbacks::isInitializer(ArrayRef<Token> MacroTokens)
{ … }
void MacroToEnumCallbacks::MacroDefined(const Token &MacroNameTok,
const MacroDirective *MD) { … }
void MacroToEnumCallbacks::MacroUndefined(const Token &MacroNameTok,
const MacroDefinition &MD,
const MacroDirective *Undef) { … }
void MacroToEnumCallbacks::Endif(SourceLocation Loc, SourceLocation IfLoc) { … }
namespace {
template <size_t N>
bool textEquals(const char (&Needle)[N], const char *HayStack) { … }
template <size_t N> size_t len(const char (&)[N]) { … }
}
void MacroToEnumCallbacks::PragmaDirective(SourceLocation Loc,
PragmaIntroducerKind Introducer) { … }
void MacroToEnumCallbacks::invalidateExpressionNames() { … }
void MacroToEnumCallbacks::EndOfMainFile() { … }
void MacroToEnumCallbacks::invalidateRange(SourceRange Range) { … }
void MacroToEnumCallbacks::issueDiagnostics() { … }
void MacroToEnumCallbacks::warnMacroEnum(const EnumMacro &Macro) const { … }
void MacroToEnumCallbacks::fixEnumMacro(const MacroList &MacroList) const { … }
void MacroToEnumCheck::registerPPCallbacks(const SourceManager &SM,
Preprocessor *PP,
Preprocessor *ModuleExpanderPP) { … }
void MacroToEnumCheck::registerMatchers(ast_matchers::MatchFinder *Finder) { … }
static bool isValid(SourceRange Range) { … }
static bool empty(SourceRange Range) { … }
void MacroToEnumCheck::check(
const ast_matchers::MatchFinder::MatchResult &Result) { … }
}