llvm-project/lldb/source/Symbol
Greg Clayton 529a3d87a7 [NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute.
Resubmission of https://reviews.llvm.org/D130309 with the 2 patches that fixed the linux buildbot, and new windows fixes.

The FileSpec APIs allow users to modify instance variables directly by getting a non const reference to the directory and filename instance variables. This makes it impossible to control all of the times the FileSpec object is modified so we can clear cached member variables like m_resolved and with an upcoming patch caching if the file is relative or absolute. This patch modifies the APIs of FileSpec so no one can modify the directory or filename instance variables directly by adding set accessors and by removing the get accessors that are non const.

Many clients were using FileSpec::GetCString(...) which returned a unique C string from a ConstString'ified version of the result of GetPath() which returned a std::string. This caused many locations to use this convenient function incorrectly and could cause many strings to be added to the constant string pool that didn't need to. Most clients were converted to using FileSpec::GetPath().c_str() when possible. Other clients were modified to use the newly renamed version of this function which returns an actualy ConstString:

ConstString FileSpec::GetPathAsConstString(bool denormalize = true) const;

This avoids the issue where people were getting an already uniqued "const char *" that came from a ConstString only to put the "const char *" back into a "ConstString" object. By returning the ConstString instead of a "const char *" clients can be more efficient with the result.

The patch:
- Removes the non const GetDirectory() and GetFilename() get accessors
- Adds set accessors to replace the above functions: SetDirectory() and SetFilename().
- Adds ClearDirectory() and ClearFilename() to replace usage of the FileSpec::GetDirectory().Clear()/FileSpec::GetFilename().Clear() call sites
- Fixed all incorrect usage of FileSpec::GetCString() to use FileSpec::GetPath().c_str() where appropriate, and updated other call sites that wanted a ConstString to use the newly returned ConstString appropriately and efficiently.

Differential Revision: https://reviews.llvm.org/D130549
2022-07-28 13:28:26 -07:00
..
ArmUnwindInfo.cpp Use the range-based overload of llvm::sort where possible 2022-07-23 15:13:25 +02:00
Block.cpp [lldb] Rename Logging.h to LLDBLog.h and clean up includes 2022-02-03 14:47:01 +01:00
CMakeLists.txt Introduce new symbol on-demand for debug info 2022-04-26 10:42:06 -07:00
CompactUnwindInfo.cpp [lldb] Replace Host::SystemLog with Debugger::Report{Error,Warning} 2022-06-24 09:46:26 -07:00
CompileUnit.cpp Use the range-based overload of llvm::sort where possible 2022-07-23 15:13:25 +02:00
CompilerDecl.cpp
CompilerDeclContext.cpp
CompilerType.cpp [lldb][NFC] Give CompilerType's IsArrayType/IsVectorType/IsBlockPointerType out-parameters default values 2021-02-23 11:15:31 +01:00
DWARFCallFrameInfo.cpp [lldb] Replace Host::SystemLog with Debugger::Report{Error,Warning} 2022-06-24 09:46:26 -07:00
DebugMacros.cpp
DeclVendor.cpp [lldb][NFC] Remove outdated FIXME 2021-09-20 11:44:20 -07:00
FuncUnwinders.cpp [lldb] Replace default bodies of special member functions with = default; 2021-07-02 11:31:16 -07:00
Function.cpp [trace] Add a flag to the decoder to output the instruction type 2022-07-12 16:23:03 -07:00
LineEntry.cpp Change PathMappingList::FindFile to return an optional result (NFC) 2021-06-29 15:10:46 -07:00
LineTable.cpp [lldb] Replace default bodies of special member functions with = default; 2021-07-02 11:31:16 -07:00
LocateSymbolFile.cpp [lldb] Add gnu-debuglink support for Windows PE/COFF 2022-06-09 14:39:33 +03:00
LocateSymbolFileMacOSX.cpp [NFC] Don't bother with unstripped binary w/ dSYM, don't DebugSymbols twice 2022-05-16 15:30:39 -07:00
ObjectFile.cpp [lldb] Change CreateMemoryInstance to take a WritableDataBuffer 2022-04-05 13:46:41 -07:00
PostfixExpression.cpp [LLDB] Remove cases of using namespace llvm:: from header file 2022-03-03 10:39:06 -08:00
Symbol.cpp [NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute. 2022-07-28 13:28:26 -07:00
SymbolContext.cpp [NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute. 2022-07-28 13:28:26 -07:00
SymbolFile.cpp Introduce new symbol on-demand for debug info 2022-04-26 10:42:06 -07:00
SymbolFileOnDemand.cpp [lldb] Fix modernize-use-equals-default warnings (NFC) 2022-06-17 15:08:02 -07:00
SymbolVendor.cpp [lldb] Return StringRef from PluginInterface::GetPluginName 2021-10-18 10:14:42 +02:00
Symtab.cpp Use the range-based overload of llvm::sort where possible 2022-07-23 15:13:25 +02:00
Type.cpp [LLDB][NFC][Reliability] Fix uninitialized variables from Coverity scan. Part 2 2022-07-25 20:52:45 -07:00
TypeList.cpp Use StringRef to avoid unnecessary copies into std::strings 2022-07-07 19:50:12 +00:00
TypeMap.cpp Remove dead code: TypeMap::RemoveMismatchedTypes(TypeClass type_class) 2022-07-07 20:46:14 +00:00
TypeSystem.cpp Use true/false instead of 1/0 (NFC) 2022-01-09 12:21:06 -08:00
UnwindPlan.cpp Cleanup LLVMDWARFDebugInfo 2022-02-15 09:16:03 +01:00
UnwindTable.cpp [lldb] Replace default bodies of special member functions with = default; 2021-07-02 11:31:16 -07:00
Variable.cpp Reland "[LLDB][NFC] Decouple dwarf location table from DWARFExpression." 2022-07-12 10:54:24 -07:00
VariableList.cpp [lldb] Replace default bodies of special member functions with = default; 2021-07-02 11:31:16 -07:00