Fix undefined behavior in Variable.h
authorZachary Turner <zturner@google.com>
Tue, 11 Dec 2018 00:15:03 +0000 (00:15 +0000)
committerZachary Turner <zturner@google.com>
Tue, 11 Dec 2018 00:15:03 +0000 (00:15 +0000)
m_loc_is_constant_data was uninitialized, so unless someone
explicitly called SetLocIsConstantData(), this would be UB.

I think every existing call-site would always call the proper
function to initialize the value, so there were no existing
bugs, but I encountered this when I tried to use it without
calling this function and encountered this.

llvm-svn: 348813

lldb/source/Symbol/Variable.cpp

index 2573c87..ffed48a 100644 (file)
@@ -50,7 +50,8 @@ Variable::Variable(
       m_symfile_type_sp(symfile_type_sp), m_scope(scope),
       m_owner_scope(context), m_scope_range(scope_range),
       m_declaration(decl_ptr), m_location(location), m_external(external),
-      m_artificial(artificial), m_static_member(static_member) {}
+      m_artificial(artificial), m_loc_is_const_data(false),
+      m_static_member(static_member) {}
 
 //----------------------------------------------------------------------
 // Destructor