[Lldb-commits] [PATCH] D29288: Switch std::call_once to llvm::call_once

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Jan 30 09:56:01 PST 2017


clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

Be very careful when using this, you can't change member variables that used to be std::once to be statics. We also don't need the llvm namespace to be included with "using namespace llvm;" in many of the files.



================
Comment at: include/lldb/Core/Debugger.h:376
   Broadcaster m_sync_broadcaster;
   lldb::ListenerSP m_forward_listener_sp;
 
----------------
There must be an in ivar for m_clear_once. This can't be a static. Debugger::Clear() can only be called once per debugger instance, not just once ever.


================
Comment at: source/Core/Debugger.cpp:68
 using namespace lldb_private;
+using namespace llvm;
 
----------------
Why was this added? Remove if not needed.


================
Comment at: source/Core/Debugger.cpp:768-769
   //----------------------------------------------------------------------
-  std::call_once(m_clear_once, [this]() {
+  LLVM_DEFINE_ONCE_FLAG(m_clear_once);
+  llvm::call_once(m_clear_once, [this]() {
     ClearIOHandlers();
----------------
This is wrong, it must be in ivar. We are trying to make sure Debugger::Clear() gets calls only once for each instance of a Debugger. Read the comment.


================
Comment at: source/Core/ModuleList.cpp:33
 using namespace lldb_private;
+using namespace llvm;
 
----------------
Why was this using added? Remove please.


================
Comment at: source/Host/common/Editline.cpp:27
 using namespace lldb_private::line_editor;
+using namespace llvm;
 
----------------
Why was this added? Remove if not needed? I hope the LLVM_DEFINE_ONCE_FLAG doesn't require the using directive. If it does, it should be fixed.


================
Comment at: source/Host/common/HostInfoBase.cpp:33
 using namespace lldb_private;
+using namespace llvm;
 
----------------
Remove


================
Comment at: source/Host/linux/HostInfoLinux.cpp:22
 using namespace lldb_private;
+using namespace llvm;
 
----------------
Remove


================
Comment at: source/Host/windows/HostInfoWindows.cpp:24
 using namespace lldb_private;
+using namespace llvm;
 
----------------
Remove


================
Comment at: source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp:38
 using namespace lldb_private;
+using namespace llvm;
 
----------------
Remove


================
Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp:47
 using namespace lldb_private::formatters;
+using namespace llvm;
 
----------------
Remove


================
Comment at: source/Plugins/Language/Go/GoLanguage.cpp:30
 using namespace lldb_private::formatters;
+using namespace llvm;
 
----------------
Remove


================
Comment at: source/Plugins/Language/Java/JavaLanguage.cpp:32
 using namespace lldb_private::formatters;
+using namespace llvm;
 
----------------
Remove


================
Comment at: source/Plugins/Language/ObjC/ObjCLanguage.cpp:39
 using namespace lldb_private::formatters;
+using namespace llvm;
 
----------------
Remove


================
Comment at: source/Plugins/Platform/MacOSX/PlatformDarwin.cpp:51
 using namespace lldb_private;
+using namespace llvm;
 
----------------
Remove


================
Comment at: source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp:51
 using namespace lldb_private;
+using namespace llvm;
 
----------------
Remove


================
Comment at: source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp:53
 using namespace lldb_private;
+using namespace llvm;
 
----------------
Remove


================
Comment at: source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp:24
 using namespace lldb_private;
+using namespace llvm;
 
----------------
Remove


================
Comment at: source/Plugins/Process/Windows/Common/ProcessWindows.cpp:44
 using namespace lldb_private;
+using namespace llvm;
 
----------------
Remove


================
Comment at: source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp:20
 using namespace lldb_private;
+using namespace llvm;
 
----------------
Remove


================
Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:40
 using namespace lldb_private;
+using namespace llvm;
 
----------------
rm


================
Comment at: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp:48
 using namespace lldb_private::process_gdb_remote;
+using namespace llvm;
 
----------------
rm


================
Comment at: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:90
 using namespace lldb_private::process_gdb_remote;
+using namespace llvm;
 
----------------
rm


================
Comment at: source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp:24
 using namespace lldb_private::process_gdb_remote;
+using namespace llvm;
 
----------------
rm


================
Comment at: source/Plugins/Process/mach-core/ProcessMachCore.cpp:50
 using namespace lldb_private;
+using namespace llvm;
 
----------------
rm


================
Comment at: source/Plugins/Process/minidump/ProcessMinidump.cpp:35
 using namespace minidump;
+using namespace llvm;
 
----------------
rm


================
Comment at: source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp:24
 using namespace lldb_private;
+using namespace llvm;
 
----------------
rm


================
Comment at: source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp:58
 using namespace lldb_private;
+using namespace llvm;
 
----------------
rm


================
Comment at: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:91
 using namespace lldb_private;
+using namespace llvm;
 
----------------
rm


================
Comment at: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:558-559
                                       DWARFDataSegment &data_segment) {
-  std::call_once(data_segment.m_flag, &SymbolFileDWARF::LoadSectionData, this,
-                 sect_type, std::ref(data_segment.m_data));
+  LLVM_DEFINE_ONCE_FLAG(m_flag);
+  llvm::call_once(m_flag,  [this, sect_type, &data_segment]{ this->LoadSectionData(sect_type, std::ref(data_segment.m_data));});
   return data_segment.m_data;
----------------
You can't change a member variable std::once_flag to a static. Change back


================
Comment at: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:1635
                 const DWARFExpression &location = var_sp->LocationExpression();
-                Value location_result;
+                lldb_private::Value location_result;
                 Error error;
----------------
Revert since we shouldn't include llvm namespace.


================
Comment at: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:1641
                   if (location_result.GetValueType() ==
-                      Value::eValueTypeFileAddress) {
+                      lldb_private::Value::eValueTypeFileAddress) {
                     lldb::addr_t file_addr =
----------------
Revert since we shouldn't include llvm namespace.


================
Comment at: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h:307
 
   struct DWARFDataSegment {
     lldb_private::DWARFDataExtractor m_data;
----------------
You can't remove a member variable once flag. Restore with LLVM version.


================
Comment at: source/Symbol/GoASTContext.cpp:34
 using namespace lldb;
+using namespace llvm;
 
----------------
rm


================
Comment at: source/Target/Language.cpp:28
 using namespace lldb_private::formatters;
+using namespace llvm;
 
----------------
rm


Repository:
  rL LLVM

https://reviews.llvm.org/D29288





More information about the lldb-commits mailing list