Jelajahi Sumber

clang-tidy: fix `modernize-use-nullptr` lints

Ben Boeckel 2 tahun lalu
induk
melakukan
1b929ba8e4

+ 2 - 2
Source/cmGlobalVisualStudio10Generator.h

@@ -243,8 +243,8 @@ private:
   {
     LongestSourcePath() = default;
     size_t Length = 0;
-    cmGeneratorTarget* Target = 0;
-    cmSourceFile const* SourceFile = 0;
+    cmGeneratorTarget* Target = nullptr;
+    cmSourceFile const* SourceFile = nullptr;
     std::string SourceRel;
   };
   LongestSourcePath LongestSource;

+ 1 - 1
Source/cmGlobalVisualStudio11Generator.cxx

@@ -22,7 +22,7 @@ static const char* cmVS11GenName(const std::string& name, std::string& genName)
 {
   if (strncmp(name.c_str(), vs11generatorName,
               sizeof(vs11generatorName) - 6) != 0) {
-    return 0;
+    return nullptr;
   }
   const char* p = name.c_str() + sizeof(vs11generatorName) - 6;
   if (cmHasLiteralPrefix(p, " 2012")) {

+ 1 - 1
Source/cmGlobalVisualStudio12Generator.cxx

@@ -21,7 +21,7 @@ static const char* cmVS12GenName(const std::string& name, std::string& genName)
 {
   if (strncmp(name.c_str(), vs12generatorName,
               sizeof(vs12generatorName) - 6) != 0) {
-    return 0;
+    return nullptr;
   }
   const char* p = name.c_str() + sizeof(vs12generatorName) - 6;
   if (cmHasLiteralPrefix(p, " 2013")) {

+ 1 - 1
Source/cmGlobalVisualStudio14Generator.cxx

@@ -23,7 +23,7 @@ static const char* cmVS14GenName(const std::string& name, std::string& genName)
 {
   if (strncmp(name.c_str(), vs14generatorName,
               sizeof(vs14generatorName) - 6) != 0) {
-    return 0;
+    return nullptr;
   }
   const char* p = name.c_str() + sizeof(vs14generatorName) - 6;
   if (cmHasLiteralPrefix(p, " 2015")) {

+ 3 - 3
Source/cmGlobalVisualStudioVersionedGenerator.cxx

@@ -211,7 +211,7 @@ static const char* cmVS15GenName(const std::string& name, std::string& genName)
 {
   if (strncmp(name.c_str(), vs15generatorName,
               sizeof(vs15generatorName) - 6) != 0) {
-    return 0;
+    return nullptr;
   }
   const char* p = name.c_str() + sizeof(vs15generatorName) - 6;
   if (cmHasLiteralPrefix(p, " 2017")) {
@@ -306,7 +306,7 @@ static const char* cmVS16GenName(const std::string& name, std::string& genName)
 {
   if (strncmp(name.c_str(), vs16generatorName,
               sizeof(vs16generatorName) - 6) != 0) {
-    return 0;
+    return nullptr;
   }
   const char* p = name.c_str() + sizeof(vs16generatorName) - 6;
   if (cmHasLiteralPrefix(p, " 2019")) {
@@ -320,7 +320,7 @@ static const char* cmVS17GenName(const std::string& name, std::string& genName)
 {
   if (strncmp(name.c_str(), vs17generatorName,
               sizeof(vs17generatorName) - 6) != 0) {
-    return 0;
+    return nullptr;
   }
   const char* p = name.c_str() + sizeof(vs17generatorName) - 6;
   if (cmHasLiteralPrefix(p, " 2022")) {

+ 3 - 3
Source/cmIDEOptions.cxx

@@ -20,9 +20,9 @@ cmIDEOptions::cmIDEOptions()
   this->AllowDefine = true;
   this->DoingInclude = false;
   this->AllowSlash = false;
-  this->DoingFollowing = 0;
+  this->DoingFollowing = nullptr;
   for (int i = 0; i < FlagTableCount; ++i) {
-    this->FlagTable[i] = 0;
+    this->FlagTable[i] = nullptr;
   }
 }
 
@@ -47,7 +47,7 @@ void cmIDEOptions::HandleFlag(std::string const& flag)
   // If the last option expected a following value, this is it.
   if (this->DoingFollowing) {
     this->FlagMapUpdate(this->DoingFollowing, flag);
-    this->DoingFollowing = 0;
+    this->DoingFollowing = nullptr;
     return;
   }
 

+ 7 - 7
Source/cmLocalVisualStudio7Generator.cxx

@@ -57,7 +57,7 @@ public:
   using ItemVector = cmComputeLinkInformation::ItemVector;
   void OutputLibraries(std::ostream& fout, ItemVector const& libs);
   void OutputObjects(std::ostream& fout, cmGeneratorTarget* t,
-                     std::string const& config, const char* isep = 0);
+                     std::string const& config, const char* isep = nullptr);
 
 private:
   cmLocalVisualStudio7Generator* LocalGenerator;
@@ -633,7 +633,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
   // 1 == executable
   // 10 == utility
   const char* configType = "10";
-  const char* projectType = 0;
+  const char* projectType = nullptr;
   bool targetBuilds = true;
 
   switch (target->GetType()) {
@@ -842,7 +842,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
   }
   fout << "/>\n"; // end of <Tool Name=VCCLCompilerTool
   if (gg->IsMarmasmEnabled() && !this->FortranProject) {
-    Options marmasmOptions(this, Options::MarmasmCompiler, 0, 0);
+    Options marmasmOptions(this, Options::MarmasmCompiler, nullptr, nullptr);
     /* clang-format off */
     fout <<
       "\t\t\t<Tool\n"
@@ -860,7 +860,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
     /* clang-format on */
   }
   if (gg->IsMasmEnabled() && !this->FortranProject) {
-    Options masmOptions(this, Options::MasmCompiler, 0, 0);
+    Options masmOptions(this, Options::MasmCompiler, nullptr, nullptr);
     /* clang-format off */
     fout <<
       "\t\t\t<Tool\n"
@@ -1993,7 +1993,7 @@ void cmLocalVisualStudio7Generator::WriteProjectStartFortran(
   /* clang-format on */
   cmValue p = target->GetProperty("VS_KEYWORD");
   const char* keyword = p ? p->c_str() : "Console Application";
-  const char* projectType = 0;
+  const char* projectType = nullptr;
   switch (target->GetType()) {
     case cmStateEnums::OBJECT_LIBRARY:
     case cmStateEnums::STATIC_LIBRARY:
@@ -2013,7 +2013,7 @@ void cmLocalVisualStudio7Generator::WriteProjectStartFortran(
       if (!keyword) {
         keyword = "Console Application";
       }
-      projectType = 0;
+      projectType = nullptr;
       break;
     case cmStateEnums::UTILITY:
     case cmStateEnums::GLOBAL_TARGET:
@@ -2234,7 +2234,7 @@ static bool cmLVS7G_IsFAT(const char* dir)
     volRoot[0] = dir[0];
     char fsName[16];
     if (GetVolumeInformationA(volRoot, 0, 0, 0, 0, 0, fsName, 16) &&
-        strstr(fsName, "FAT") != 0) {
+        strstr(fsName, "FAT") != nullptr) {
       return true;
     }
   }

+ 1 - 1
Source/cmLocalVisualStudioGenerator.h

@@ -47,7 +47,7 @@ public:
 
   void ComputeObjectFilenames(
     std::map<cmSourceFile const*, std::string>& mapping,
-    cmGeneratorTarget const* = 0) override;
+    cmGeneratorTarget const* = nullptr) override;
 
 protected:
   virtual const char* ReportErrorLabel() const;

+ 22 - 22
Source/cmVSSetupHelper.cxx

@@ -87,11 +87,11 @@ std::string VSInstanceInfo::GetInstallLocation() const
 
 cmVSSetupAPIHelper::cmVSSetupAPIHelper(unsigned int version)
   : Version(version)
-  , setupConfig(NULL)
-  , setupConfig2(NULL)
-  , setupHelper(NULL)
+  , setupConfig(nullptr)
+  , setupConfig2(nullptr)
+  , setupHelper(nullptr)
 {
-  comInitialized = CoInitializeEx(NULL, 0);
+  comInitialized = CoInitializeEx(nullptr, 0);
   if (SUCCEEDED(comInitialized)) {
     Initialize();
   } else {
@@ -101,9 +101,9 @@ cmVSSetupAPIHelper::cmVSSetupAPIHelper(unsigned int version)
 
 cmVSSetupAPIHelper::~cmVSSetupAPIHelper()
 {
-  setupHelper = NULL;
-  setupConfig2 = NULL;
-  setupConfig = NULL;
+  setupHelper = nullptr;
+  setupConfig2 = nullptr;
+  setupConfig = nullptr;
   if (SUCCEEDED(comInitialized))
     CoUninitialize();
 }
@@ -176,7 +176,7 @@ bool cmVSSetupAPIHelper::CheckInstalledComponent(
 bool cmVSSetupAPIHelper::GetVSInstanceInfo(
   SmartCOMPtr<ISetupInstance2> pInstance, VSInstanceInfo& vsInstanceInfo)
 {
-  if (pInstance == NULL)
+  if (pInstance == nullptr)
     return false;
 
   InstanceState state;
@@ -219,7 +219,7 @@ bool cmVSSetupAPIHelper::GetVSInstanceInfo(
 
     LPSAFEARRAY lpsaPackages;
     if (FAILED(pInstance->GetPackages(&lpsaPackages)) ||
-        lpsaPackages == NULL) {
+        lpsaPackages == nullptr) {
       return false;
     }
 
@@ -228,10 +228,10 @@ bool cmVSSetupAPIHelper::GetVSInstanceInfo(
 
     IUnknown** ppData = (IUnknown**)lpsaPackages->pvData;
     for (int i = lower; i < upper; i++) {
-      SmartCOMPtr<ISetupPackageReference> package = NULL;
+      SmartCOMPtr<ISetupPackageReference> package = nullptr;
       if (FAILED(ppData[i]->QueryInterface(IID_ISetupPackageReference,
                                            (void**)&package)) ||
-          package == NULL)
+          package == nullptr)
         continue;
 
       bool win10SDKInstalled = false;
@@ -369,11 +369,11 @@ bool cmVSSetupAPIHelper::EnumerateVSInstancesWithVswhere(
 bool cmVSSetupAPIHelper::EnumerateVSInstancesWithCOM(
   std::vector<VSInstanceInfo>& VSInstances)
 {
-  if (initializationFailure || setupConfig == NULL || setupConfig2 == NULL ||
-      setupHelper == NULL)
+  if (initializationFailure || setupConfig == nullptr ||
+      setupConfig2 == nullptr || setupHelper == nullptr)
     return false;
 
-  SmartCOMPtr<IEnumSetupInstances> enumInstances = NULL;
+  SmartCOMPtr<IEnumSetupInstances> enumInstances = nullptr;
   if (FAILED(
         setupConfig2->EnumInstances((IEnumSetupInstances**)&enumInstances)) ||
       !enumInstances) {
@@ -381,18 +381,18 @@ bool cmVSSetupAPIHelper::EnumerateVSInstancesWithCOM(
   }
 
   SmartCOMPtr<ISetupInstance> instance;
-  while (SUCCEEDED(enumInstances->Next(1, &instance, NULL)) && instance) {
-    SmartCOMPtr<ISetupInstance2> instance2 = NULL;
+  while (SUCCEEDED(enumInstances->Next(1, &instance, nullptr)) && instance) {
+    SmartCOMPtr<ISetupInstance2> instance2 = nullptr;
     if (FAILED(
           instance->QueryInterface(IID_ISetupInstance2, (void**)&instance2)) ||
         !instance2) {
-      instance = NULL;
+      instance = nullptr;
       continue;
     }
 
     VSInstanceInfo instanceInfo;
     bool isInstalled = GetVSInstanceInfo(instance2, instanceInfo);
-    instance = instance2 = NULL;
+    instance = instance2 = nullptr;
     if (isInstalled)
       VSInstances.push_back(instanceInfo);
   }
@@ -596,24 +596,24 @@ bool cmVSSetupAPIHelper::Initialize()
     return false;
   }
 
-  if (FAILED(setupConfig.CoCreateInstance(CLSID_SetupConfiguration, NULL,
+  if (FAILED(setupConfig.CoCreateInstance(CLSID_SetupConfiguration, nullptr,
                                           IID_ISetupConfiguration,
                                           CLSCTX_INPROC_SERVER)) ||
-      setupConfig == NULL) {
+      setupConfig == nullptr) {
     initializationFailure = true;
     return false;
   }
 
   if (FAILED(setupConfig.QueryInterface(IID_ISetupConfiguration2,
                                         (void**)&setupConfig2)) ||
-      setupConfig2 == NULL) {
+      setupConfig2 == nullptr) {
     initializationFailure = true;
     return false;
   }
 
   if (FAILED(
         setupConfig.QueryInterface(IID_ISetupHelper, (void**)&setupHelper)) ||
-      setupHelper == NULL) {
+      setupHelper == nullptr) {
     initializationFailure = true;
     return false;
   }

+ 7 - 7
Source/cmVSSetupHelper.h

@@ -21,13 +21,13 @@ public:
   SmartCOMPtr(T* p)
   {
     ptr = p;
-    if (ptr != NULL)
+    if (ptr != nullptr)
       ptr->AddRef();
   }
   SmartCOMPtr(const SmartCOMPtr<T>& sptr)
   {
     ptr = sptr.ptr;
-    if (ptr != NULL)
+    if (ptr != nullptr)
       ptr->AddRef();
   }
   T** operator&() { return &ptr; }
@@ -36,7 +36,7 @@ public:
   {
     if (*this != p) {
       ptr = p;
-      if (ptr != NULL)
+      if (ptr != nullptr)
         ptr->AddRef();
     }
     return *this;
@@ -45,7 +45,7 @@ public:
   template <class I>
   HRESULT QueryInterface(REFCLSID rclsid, I** pp)
   {
-    if (pp != NULL) {
+    if (pp != nullptr) {
       return ptr->QueryInterface(rclsid, (void**)pp);
     } else {
       return E_FAIL;
@@ -60,12 +60,12 @@ public:
   }
   ~SmartCOMPtr()
   {
-    if (ptr != NULL)
+    if (ptr != nullptr)
       ptr->Release();
   }
 
 private:
-  T* ptr = NULL;
+  T* ptr = nullptr;
 };
 
 class SmartBSTR
@@ -79,7 +79,7 @@ public:
   ~SmartBSTR() throw() { ::SysFreeString(str); }
 
 private:
-  BSTR str = NULL;
+  BSTR str = nullptr;
 };
 
 struct VSInstanceInfo

+ 1 - 1
Source/cmVisualStudio10TargetGenerator.cxx

@@ -2675,7 +2675,7 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
     ? "C"
     : this->GlobalGenerator->GetLanguageFromExtension(ext.c_str());
   std::string lang = this->LocalGenerator->GetSourceFileLanguage(sf);
-  const char* compileAs = 0;
+  const char* compileAs = nullptr;
   if (lang != extLang) {
     if (lang == "CXX") {
       // force a C++ file type

+ 1 - 1
Source/cmVisualStudioSlnData.cxx

@@ -56,7 +56,7 @@ cmSlnProjectEntry* cmSlnData::AddProject(
 {
   ProjectStorage::iterator it(ProjectsByGUID.find(projectGUID));
   if (it != ProjectsByGUID.end())
-    return NULL;
+    return nullptr;
   it = ProjectsByGUID
          .insert(ProjectStorage::value_type(
            projectGUID,

+ 1 - 1
Source/cmVisualStudioWCEPlatformParser.cxx

@@ -50,7 +50,7 @@ const char* cmVisualStudioWCEPlatformParser::GetArchitectureFamily() const
     return it->second.c_str();
   }
 
-  return 0;
+  return nullptr;
 }
 
 void cmVisualStudioWCEPlatformParser::StartElement(const std::string& name,

+ 1 - 1
Source/cmVisualStudioWCEPlatformParser.h

@@ -16,7 +16,7 @@
 class cmVisualStudioWCEPlatformParser : public cmXMLParser
 {
 public:
-  cmVisualStudioWCEPlatformParser(const char* name = NULL)
+  cmVisualStudioWCEPlatformParser(const char* name = nullptr)
     : RequiredName(name)
   {
   }