[Lldb-commits] [lldb] 8dbe2f0 - [lldb][NFC] Simplify CompilerType constructors/destructors and fix unused variable warning

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Wed Jan 1 13:57:24 PST 2020


Author: Raphael Isemann
Date: 2020-01-01T22:56:16+01:00
New Revision: 8dbe2f02c6d300e7222b5064b28c4d82a031647d

URL: https://github.com/llvm/llvm-project/commit/8dbe2f02c6d300e7222b5064b28c4d82a031647d
DIFF: https://github.com/llvm/llvm-project/commit/8dbe2f02c6d300e7222b5064b28c4d82a031647d.diff

LOG: [lldb][NFC] Simplify CompilerType constructors/destructors and fix unused variable warning

CompilerType has no virtual functions and no statements in its constructors,
so we can simplify this code. This also allows Clang to emit unused variable warnings
for CompilerType, so I also removed one unused variable that otherwise causes -Werror
builds to fail.

Added: 
    

Modified: 
    lldb/include/lldb/Symbol/CompilerType.h
    lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
    lldb/source/Symbol/CompilerType.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h
index ee87b53942b7..660466be6b30 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -30,14 +30,13 @@ class DataExtractor;
 class CompilerType {
 public:
   // Constructors and Destructors
-  CompilerType(TypeSystem *type_system, lldb::opaque_compiler_type_t type);
+  CompilerType(TypeSystem *type_system, lldb::opaque_compiler_type_t type)
+      : m_type(type), m_type_system(type_system) {}
 
   CompilerType(const CompilerType &rhs)
       : m_type(rhs.m_type), m_type_system(rhs.m_type_system) {}
 
-  CompilerType() : m_type(nullptr), m_type_system(nullptr) {}
-
-  ~CompilerType();
+  CompilerType() = default;
 
   // Operators
 
@@ -368,8 +367,8 @@ class CompilerType {
   }
 
 private:
-  lldb::opaque_compiler_type_t m_type;
-  TypeSystem *m_type_system;
+  lldb::opaque_compiler_type_t m_type = nullptr;
+  TypeSystem *m_type_system = nullptr;
 };
 
 bool operator==(const CompilerType &lhs, const CompilerType &rhs);

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
index 7423f623efb2..41d62a462ab4 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
@@ -67,8 +67,6 @@ void ClangPersistentVariables::RemovePersistentVariable(
 llvm::Optional<CompilerType>
 ClangPersistentVariables::GetCompilerTypeFromPersistentDecl(
     ConstString type_name) {
-  CompilerType compiler_type;
-
   PersistentDecl p = m_persistent_decls.lookup(type_name.GetCString());
 
   if (p.m_decl == nullptr)

diff  --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp
index ba924bf84c01..09930f7a800e 100644
--- a/lldb/source/Symbol/CompilerType.cpp
+++ b/lldb/source/Symbol/CompilerType.cpp
@@ -26,12 +26,6 @@
 using namespace lldb;
 using namespace lldb_private;
 
-CompilerType::CompilerType(TypeSystem *type_system,
-                           lldb::opaque_compiler_type_t type)
-    : m_type(type), m_type_system(type_system) {}
-
-CompilerType::~CompilerType() {}
-
 // Tests
 
 bool CompilerType::IsAggregateType() const {


        


More information about the lldb-commits mailing list