From a532af8cd01122ba598a85c1d728e3f74f782709 Mon Sep 17 00:00:00 2001 From: Bertrand Bellenot <bertrand.bellenot@cern.ch> Date: Wed, 4 Oct 2017 13:31:00 +0200 Subject: [PATCH] Use better variable name, use constexpr instead of const, fix a typo and formatting (clang-format) --- core/dictgen/src/TModuleGenerator.cxx | 25 +++++++++++-------------- core/dictgen/src/rootcling_impl.cxx | 21 ++++++++------------- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/core/dictgen/src/TModuleGenerator.cxx b/core/dictgen/src/TModuleGenerator.cxx index 2d12da3a84a..f32786eefe1 100644 --- a/core/dictgen/src/TModuleGenerator.cxx +++ b/core/dictgen/src/TModuleGenerator.cxx @@ -346,35 +346,32 @@ void TModuleGenerator::WriteRegistrationSource(std::ostream &out, const std::string &fwdDeclString) const { - std::string fwdDeclStringOS = fwdDeclString; + std::string fwdDeclStringSanitized = fwdDeclString; #ifdef R__WIN32 // Visual sudio has a limitation of 2048 characters max in raw strings, so split // the potentially huge DICTFWDDCLS raw string into multiple smaller ones - const std::string &from = "\n"; - const std::string &to = "\n)DICTFWDDCLS\"\nR\"DICTFWDDCLS("; + constexpr std::string &from = "\n"; + constexpr std::string &to = "\n)DICTFWDDCLS\"\nR\"DICTFWDDCLS("; size_t start_pos = 0; - while((start_pos = fwdDeclStringOS.find(from, start_pos)) != std::string::npos) { - if (fwdDeclStringOS.find(from, start_pos+1) == std::string::npos) // skip the last + while ((start_pos = fwdDeclStringSanitized.find(from, start_pos)) != std::string::npos) { + if (fwdDeclStringSanitized.find(from, start_pos + 1) == std::string::npos) // skip the last break; - if ((fwdDeclStringOS.at(start_pos+1) == '}') || - (fwdDeclStringOS.at(start_pos+1) == '\n') ) + if ((fwdDeclStringSanitized.at(start_pos + 1) == '}') || (fwdDeclStringSanitized.at(start_pos + 1) == '\n')) start_pos += 2; else { - fwdDeclStringOS.replace(start_pos, from.length(), to); + fwdDeclStringSanitized.replace(start_pos, from.length(), to); start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx' } } #endif std::string fwdDeclStringRAW; - if ("nullptr" == fwdDeclStringOS || - "\"\"" == fwdDeclStringOS) { - fwdDeclStringRAW = fwdDeclStringOS; - } - else { + if ("nullptr" == fwdDeclStringSanitized || "\"\"" == fwdDeclStringSanitized) { + fwdDeclStringRAW = fwdDeclStringSanitized; + } else { fwdDeclStringRAW = "R\"DICTFWDDCLS(\n"; fwdDeclStringRAW += "#line 1 \""; fwdDeclStringRAW += fDictionaryName +" dictionary forward declarations' payload\"\n"; - fwdDeclStringRAW += fwdDeclStringOS; + fwdDeclStringRAW += fwdDeclStringSanitized; fwdDeclStringRAW += ")DICTFWDDCLS\""; } diff --git a/core/dictgen/src/rootcling_impl.cxx b/core/dictgen/src/rootcling_impl.cxx index ac51d4faf70..05bcbf9c8fe 100644 --- a/core/dictgen/src/rootcling_impl.cxx +++ b/core/dictgen/src/rootcling_impl.cxx @@ -706,8 +706,7 @@ void SetRootSys() // $ROOTSYS/bin/rootcling_stage1.exe removesubdirs = 2; gBuildingROOT = true; - } - else if (!strncmp(s + 1, "rootcling_stage1", 16)) { + } else if (!strncmp(s + 1, "rootcling_stage1", 16)) { // $ROOTSYS/core/rootcling_stage1/src/rootcling_stage1 removesubdirs = 4; gBuildingROOT = true; @@ -2921,7 +2920,7 @@ int ExtractClassesListAndDeclLines(RScanner &scan, #ifdef WIN32 if (mangledName[0] == '\01') mangledName.erase(0, 1); - char* demangledTIName = TClassEdit::DemangleName(mangledName.c_str(), errDemangle); + char *demangledTIName = TClassEdit::DemangleName(mangledName.c_str(), errDemangle); if (!errDemangle && demangledTIName) { static const char typeinfoNameFor[] = " `RTTI Type Descriptor'"; if (strstr(demangledTIName, typeinfoNameFor)) { @@ -2948,7 +2947,7 @@ int ExtractClassesListAndDeclLines(RScanner &scan, } else { #ifdef WIN32 ROOT::TMetaUtils::Error("ExtractClassesListAndDeclLines", - "Demangled typeinfo name '%s' does not contains `RTTI Type Descriptor'\n", + "Demangled typeinfo name '%s' does not contain `RTTI Type Descriptor'\n", demangledTIName); #else ROOT::TMetaUtils::Error("ExtractClassesListAndDeclLines", @@ -3867,15 +3866,11 @@ public: ~TRootClingCallbacks(){}; - virtual void InclusionDirective(clang::SourceLocation /*HashLoc*/, - const clang::Token &/*IncludeTok*/, - llvm::StringRef FileName, - bool IsAngled, - clang::CharSourceRange /*FilenameRange*/, - const clang::FileEntry * /*File*/, - llvm::StringRef /*SearchPath*/, - llvm::StringRef /*RelativePath*/, - const clang::Module * /*Imported*/) { + virtual void InclusionDirective(clang::SourceLocation /*HashLoc*/, const clang::Token &/*IncludeTok*/, + llvm::StringRef FileName, bool IsAngled, clang::CharSourceRange /*FilenameRange*/, + const clang::FileEntry * /*File*/, llvm::StringRef /*SearchPath*/, + llvm::StringRef /*RelativePath*/, const clang::Module * /*Imported*/) + { if (isLocked) return; if (IsAngled) return; auto& PP = m_Interpreter->getCI()->getPreprocessor(); -- GitLab