From 02d5d86b4e76041ddb90fe4b1625d8b244836c08 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Thu, 6 Aug 2015 01:01:12 +0000 Subject: [PATCH] Rename the non-coding style conformant functions in namespace Builtins to match the rest of their brethren and reformat the bits that need it. llvm-svn: 244186 --- clang/include/clang/Basic/Builtins.h | 74 ++++++++++++------------ clang/lib/AST/ASTContext.cpp | 2 +- clang/lib/Basic/Builtins.cpp | 18 +++--- clang/lib/CodeGen/CGBuiltin.cpp | 4 +- clang/lib/CodeGen/CodeGenModule.cpp | 2 +- clang/lib/Frontend/ChainedIncludesSource.cpp | 2 +- clang/lib/Frontend/FrontendAction.cpp | 2 +- clang/lib/Lex/Preprocessor.cpp | 2 +- clang/lib/Sema/SemaChecking.cpp | 6 +- clang/lib/Sema/SemaDecl.cpp | 10 ++-- clang/lib/StaticAnalyzer/Core/CheckerContext.cpp | 2 +- 11 files changed, 61 insertions(+), 63 deletions(-) diff --git a/clang/include/clang/Basic/Builtins.h b/clang/include/clang/Basic/Builtins.h index e8e97376..c5cf10c 100644 --- a/clang/include/clang/Basic/Builtins.h +++ b/clang/include/clang/Basic/Builtins.h @@ -23,22 +23,22 @@ #undef alloca namespace clang { - class TargetInfo; - class IdentifierTable; - class ASTContext; - class QualType; - class LangOptions; - - enum LanguageID { - GNU_LANG = 0x1, // builtin requires GNU mode. - C_LANG = 0x2, // builtin for c only. - CXX_LANG = 0x4, // builtin for cplusplus only. - OBJC_LANG = 0x8, // builtin for objective-c and objective-c++ - MS_LANG = 0x10, // builtin requires MS mode. - ALL_LANGUAGES = C_LANG | CXX_LANG | OBJC_LANG, // builtin for all languages. - ALL_GNU_LANGUAGES = ALL_LANGUAGES | GNU_LANG, // builtin requires GNU mode. - ALL_MS_LANGUAGES = ALL_LANGUAGES | MS_LANG // builtin requires MS mode. - }; +class TargetInfo; +class IdentifierTable; +class ASTContext; +class QualType; +class LangOptions; + +enum LanguageID { + GNU_LANG = 0x1, // builtin requires GNU mode. + C_LANG = 0x2, // builtin for c only. + CXX_LANG = 0x4, // builtin for cplusplus only. + OBJC_LANG = 0x8, // builtin for objective-c and objective-c++ + MS_LANG = 0x10, // builtin requires MS mode. + ALL_LANGUAGES = C_LANG | CXX_LANG | OBJC_LANG, // builtin for all languages. + ALL_GNU_LANGUAGES = ALL_LANGUAGES | GNU_LANG, // builtin requires GNU mode. + ALL_MS_LANGUAGES = ALL_LANGUAGES | MS_LANG // builtin requires MS mode. +}; namespace Builtin { enum ID { @@ -62,90 +62,90 @@ public: Context(); /// \brief Perform target-specific initialization - void InitializeTarget(const TargetInfo &Target); + void initializeTarget(const TargetInfo &Target); /// \brief Mark the identifiers for all the builtins with their /// appropriate builtin ID # and mark any non-portable builtin identifiers as /// such. - void InitializeBuiltins(IdentifierTable &Table, const LangOptions& LangOpts); + void initializeBuiltins(IdentifierTable &Table, const LangOptions& LangOpts); /// \brief Return the identifier name for the specified builtin, /// e.g. "__builtin_abs". - const char *GetName(unsigned ID) const { - return GetRecord(ID).Name; + const char *getName(unsigned ID) const { + return getRecord(ID).Name; } /// \brief Get the type descriptor string for the specified builtin. - const char *GetTypeString(unsigned ID) const { - return GetRecord(ID).Type; + const char *getTypeString(unsigned ID) const { + return getRecord(ID).Type; } /// \brief Return true if this function has no side effects and doesn't /// read memory. bool isConst(unsigned ID) const { - return strchr(GetRecord(ID).Attributes, 'c') != nullptr; + return strchr(getRecord(ID).Attributes, 'c') != nullptr; } /// \brief Return true if we know this builtin never throws an exception. bool isNoThrow(unsigned ID) const { - return strchr(GetRecord(ID).Attributes, 'n') != nullptr; + return strchr(getRecord(ID).Attributes, 'n') != nullptr; } /// \brief Return true if we know this builtin never returns. bool isNoReturn(unsigned ID) const { - return strchr(GetRecord(ID).Attributes, 'r') != nullptr; + return strchr(getRecord(ID).Attributes, 'r') != nullptr; } /// \brief Return true if we know this builtin can return twice. bool isReturnsTwice(unsigned ID) const { - return strchr(GetRecord(ID).Attributes, 'j') != nullptr; + return strchr(getRecord(ID).Attributes, 'j') != nullptr; } /// \brief Returns true if this builtin does not perform the side-effects /// of its arguments. bool isUnevaluated(unsigned ID) const { - return strchr(GetRecord(ID).Attributes, 'u') != nullptr; + return strchr(getRecord(ID).Attributes, 'u') != nullptr; } /// \brief Return true if this is a builtin for a libc/libm function, /// with a "__builtin_" prefix (e.g. __builtin_abs). bool isLibFunction(unsigned ID) const { - return strchr(GetRecord(ID).Attributes, 'F') != nullptr; + return strchr(getRecord(ID).Attributes, 'F') != nullptr; } /// \brief Determines whether this builtin is a predefined libc/libm /// function, such as "malloc", where we know the signature a /// priori. bool isPredefinedLibFunction(unsigned ID) const { - return strchr(GetRecord(ID).Attributes, 'f') != nullptr; + return strchr(getRecord(ID).Attributes, 'f') != nullptr; } /// \brief Determines whether this builtin is a predefined compiler-rt/libgcc /// function, such as "__clear_cache", where we know the signature a /// priori. bool isPredefinedRuntimeFunction(unsigned ID) const { - return strchr(GetRecord(ID).Attributes, 'i') != nullptr; + return strchr(getRecord(ID).Attributes, 'i') != nullptr; } /// \brief Determines whether this builtin has custom typechecking. bool hasCustomTypechecking(unsigned ID) const { - return strchr(GetRecord(ID).Attributes, 't') != nullptr; + return strchr(getRecord(ID).Attributes, 't') != nullptr; } /// \brief Determines whether this builtin has a result or any arguments which /// are pointer types. bool hasPtrArgsOrResult(unsigned ID) const { - return strchr(GetRecord(ID).Type, '*') != nullptr; + return strchr(getRecord(ID).Type, '*') != nullptr; } /// \brief Completely forget that the given ID was ever considered a builtin, /// e.g., because the user provided a conflicting signature. - void ForgetBuiltin(unsigned ID, IdentifierTable &Table); + void forgetBuiltin(unsigned ID, IdentifierTable &Table); /// \brief If this is a library function that comes from a specific /// header, retrieve that header name. const char *getHeaderName(unsigned ID) const { - return GetRecord(ID).HeaderName; + return getRecord(ID).HeaderName; } /// \brief Determine whether this builtin is like printf in its @@ -163,14 +163,14 @@ public: /// /// Such functions can be const when the MathErrno lang option is disabled. bool isConstWithoutErrno(unsigned ID) const { - return strchr(GetRecord(ID).Attributes, 'e') != nullptr; + return strchr(getRecord(ID).Attributes, 'e') != nullptr; } private: - const Info &GetRecord(unsigned ID) const; + const Info &getRecord(unsigned ID) const; /// \brief Is this builtin supported according to the given language options? - bool BuiltinIsSupported(const Builtin::Info &BuiltinInfo, + bool builtinIsSupported(const Builtin::Info &BuiltinInfo, const LangOptions &LangOpts); /// \brief Helper function for isPrintfLike and isScanfLike. diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index e17a981..bc94bd0 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -8118,7 +8118,7 @@ static QualType DecodeTypeFromStr(const char *&Str, const ASTContext &Context, QualType ASTContext::GetBuiltinType(unsigned Id, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs) const { - const char *TypeStr = BuiltinInfo.GetTypeString(Id); + const char *TypeStr = BuiltinInfo.getTypeString(Id); SmallVector ArgTypes; diff --git a/clang/lib/Basic/Builtins.cpp b/clang/lib/Basic/Builtins.cpp index 1d80e00..4ca82f3 100644 --- a/clang/lib/Basic/Builtins.cpp +++ b/clang/lib/Basic/Builtins.cpp @@ -30,7 +30,7 @@ static const Builtin::Info BuiltinInfo[] = { #include "clang/Basic/Builtins.def" }; -const Builtin::Info &Builtin::Context::GetRecord(unsigned ID) const { +const Builtin::Info &Builtin::Context::getRecord(unsigned ID) const { if (ID < Builtin::FirstTSBuiltin) return BuiltinInfo[ID]; assert(ID - Builtin::FirstTSBuiltin < NumTSRecords && "Invalid builtin ID!"); @@ -43,12 +43,12 @@ Builtin::Context::Context() { NumTSRecords = 0; } -void Builtin::Context::InitializeTarget(const TargetInfo &Target) { +void Builtin::Context::initializeTarget(const TargetInfo &Target) { assert(NumTSRecords == 0 && "Already initialized target?"); Target.getTargetBuiltins(TSRecords, NumTSRecords); } -bool Builtin::Context::BuiltinIsSupported(const Builtin::Info &BuiltinInfo, +bool Builtin::Context::builtinIsSupported(const Builtin::Info &BuiltinInfo, const LangOptions &LangOpts) { bool BuiltinsUnsupported = LangOpts.NoBuiltin && strchr(BuiltinInfo.Attributes, 'f'); @@ -66,22 +66,22 @@ bool Builtin::Context::BuiltinIsSupported(const Builtin::Info &BuiltinInfo, /// InitializeBuiltins - Mark the identifiers for all the builtins with their /// appropriate builtin ID # and mark any non-portable builtin identifiers as /// such. -void Builtin::Context::InitializeBuiltins(IdentifierTable &Table, +void Builtin::Context::initializeBuiltins(IdentifierTable &Table, const LangOptions& LangOpts) { // Step #1: mark all target-independent builtins with their ID's. for (unsigned i = Builtin::NotBuiltin+1; i != Builtin::FirstTSBuiltin; ++i) - if (BuiltinIsSupported(BuiltinInfo[i], LangOpts)) { + if (builtinIsSupported(BuiltinInfo[i], LangOpts)) { Table.get(BuiltinInfo[i].Name).setBuiltinID(i); } // Step #2: Register target-specific builtins. for (unsigned i = 0, e = NumTSRecords; i != e; ++i) - if (BuiltinIsSupported(TSRecords[i], LangOpts)) + if (builtinIsSupported(TSRecords[i], LangOpts)) Table.get(TSRecords[i].Name).setBuiltinID(i+Builtin::FirstTSBuiltin); } -void Builtin::Context::ForgetBuiltin(unsigned ID, IdentifierTable &Table) { - Table.get(GetRecord(ID).Name).setBuiltinID(0); +void Builtin::Context::forgetBuiltin(unsigned ID, IdentifierTable &Table) { + Table.get(getRecord(ID).Name).setBuiltinID(0); } bool Builtin::Context::isLike(unsigned ID, unsigned &FormatIdx, @@ -92,7 +92,7 @@ bool Builtin::Context::isLike(unsigned ID, unsigned &FormatIdx, assert(::toupper(Fmt[0]) == Fmt[1] && "Format string is not in the form \"xX\""); - const char *Like = ::strpbrk(GetRecord(ID).Attributes, Fmt); + const char *Like = ::strpbrk(getRecord(ID).Attributes, Fmt); if (!Like) return false; diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 1555d29..394d0d1 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -48,7 +48,7 @@ llvm::Value *CodeGenModule::getBuiltinLibFunction(const FunctionDecl *FD, if (FD->hasAttr()) Name = getMangledName(D); else - Name = Context.BuiltinInfo.GetName(BuiltinID) + 10; + Name = Context.BuiltinInfo.getName(BuiltinID) + 10; llvm::FunctionType *Ty = cast(getTypes().ConvertType(FD->getType())); @@ -1778,7 +1778,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, return emitLibraryCall(*this, FD, E, EmitScalarExpr(E->getCallee())); // See if we have a target specific intrinsic. - const char *Name = getContext().BuiltinInfo.GetName(BuiltinID); + const char *Name = getContext().BuiltinInfo.getName(BuiltinID); Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic; if (const char *Prefix = llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch())) { diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 8e5bc5d..fe1f9ba 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1439,7 +1439,7 @@ namespace { unsigned BuiltinID = FD->getBuiltinID(); if (!BuiltinID || !BI.isLibFunction(BuiltinID)) return true; - StringRef BuiltinName = BI.GetName(BuiltinID); + StringRef BuiltinName = BI.getName(BuiltinID); if (BuiltinName.startswith("__builtin_") && Name == BuiltinName.slice(strlen("__builtin_"), StringRef::npos)) { Result = true; diff --git a/clang/lib/Frontend/ChainedIncludesSource.cpp b/clang/lib/Frontend/ChainedIncludesSource.cpp index 5a5d2d5..d36162b 100644 --- a/clang/lib/Frontend/ChainedIncludesSource.cpp +++ b/clang/lib/Frontend/ChainedIncludesSource.cpp @@ -169,7 +169,7 @@ IntrusiveRefCntPtr clang::createChainedIncludesSource( if (firstInclude) { Preprocessor &PP = Clang->getPreprocessor(); - PP.getBuiltinInfo().InitializeBuiltins(PP.getIdentifierTable(), + PP.getBuiltinInfo().initializeBuiltins(PP.getIdentifierTable(), PP.getLangOpts()); } else { assert(!SerialBufs.empty()); diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 3e0f7a1..36135e8 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -375,7 +375,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, if (CI.getLangOpts().Modules) CI.createModuleManager(); - PP.getBuiltinInfo().InitializeBuiltins(PP.getIdentifierTable(), + PP.getBuiltinInfo().initializeBuiltins(PP.getIdentifierTable(), PP.getLangOpts()); } else { // FIXME: If this is a problem, recover from it by creating a multiplex diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index e2db638..29a00d3 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -176,7 +176,7 @@ void Preprocessor::Initialize(const TargetInfo &Target) { this->Target = &Target; // Initialize information about built-ins. - BuiltinInfo.InitializeTarget(Target); + BuiltinInfo.initializeTarget(Target); HeaderInfo.setTarget(Target); } diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index d9d26e2..e1656f2e 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -2142,7 +2142,7 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { // Get the decl for the concrete builtin from this, we can tell what the // concrete integer type we should convert to is. unsigned NewBuiltinID = BuiltinIndices[BuiltinIndex][SizeIndex]; - const char *NewBuiltinName = Context.BuiltinInfo.GetName(NewBuiltinID); + const char *NewBuiltinName = Context.BuiltinInfo.getName(NewBuiltinID); FunctionDecl *NewBuiltinDecl; if (NewBuiltinID == BuiltinID) NewBuiltinDecl = FDecl; @@ -4833,7 +4833,7 @@ static void emitReplacement(Sema &S, SourceLocation Loc, SourceRange Range, } } } else { - FunctionName = S.Context.BuiltinInfo.GetName(AbsKind); + FunctionName = S.Context.BuiltinInfo.getName(AbsKind); HeaderName = S.Context.BuiltinInfo.getHeaderName(AbsKind); if (HeaderName) { @@ -4909,7 +4909,7 @@ void Sema::CheckAbsoluteValueFunction(const CallExpr *Call, // function call. if (ArgType->isUnsignedIntegerType()) { const char *FunctionName = - IsStdAbs ? "std::abs" : Context.BuiltinInfo.GetName(AbsKind); + IsStdAbs ? "std::abs" : Context.BuiltinInfo.getName(AbsKind); Diag(Call->getExprLoc(), diag::warn_unsigned_abs) << ArgType << ParamType; Diag(Call->getExprLoc(), diag::note_remove_abs) << FunctionName diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index d0d9516..e25b160 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -1733,20 +1733,18 @@ NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, if (Error) { if (ForRedeclaration) Diag(Loc, diag::warn_implicit_decl_requires_sysheader) - << getHeaderName(Error) - << Context.BuiltinInfo.GetName(ID); + << getHeaderName(Error) << Context.BuiltinInfo.getName(ID); return nullptr; } if (!ForRedeclaration && Context.BuiltinInfo.isPredefinedLibFunction(ID)) { Diag(Loc, diag::ext_implicit_lib_function_decl) - << Context.BuiltinInfo.GetName(ID) - << R; + << Context.BuiltinInfo.getName(ID) << R; if (Context.BuiltinInfo.getHeaderName(ID) && !Diags.isIgnored(diag::ext_implicit_lib_function_decl, Loc)) Diag(Loc, diag::note_include_header_or_declare) << Context.BuiltinInfo.getHeaderName(ID) - << Context.BuiltinInfo.GetName(ID); + << Context.BuiltinInfo.getName(ID); } DeclContext *Parent = Context.getTranslationUnitDecl(); @@ -8290,7 +8288,7 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, if (!T.isNull() && !Context.hasSameType(T, NewFD->getType())) { // The type of this function differs from the type of the builtin, // so forget about the builtin entirely. - Context.BuiltinInfo.ForgetBuiltin(BuiltinID, Context.Idents); + Context.BuiltinInfo.forgetBuiltin(BuiltinID, Context.Idents); } } diff --git a/clang/lib/StaticAnalyzer/Core/CheckerContext.cpp b/clang/lib/StaticAnalyzer/Core/CheckerContext.cpp index 6b22bf4..37b2564 100644 --- a/clang/lib/StaticAnalyzer/Core/CheckerContext.cpp +++ b/clang/lib/StaticAnalyzer/Core/CheckerContext.cpp @@ -45,7 +45,7 @@ bool CheckerContext::isCLibraryFunction(const FunctionDecl *FD, if (BId != 0) { if (Name.empty()) return true; - StringRef BName = FD->getASTContext().BuiltinInfo.GetName(BId); + StringRef BName = FD->getASTContext().BuiltinInfo.getName(BId); if (BName.find(Name) != StringRef::npos) return true; } -- 2.7.4