diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-05-02 18:31:19 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-05-02 18:31:19 +0000 |
| commit | 773dd0e6e632d48d7123a321ba86f50847b9afc0 (patch) | |
| tree | c6bd992bb1963df11f8de346d12a5a70c2e4deb2 /source/Symbol | |
| parent | 5060b64b7d79491d507a75201be161fd0c38fcbb (diff) | |
Notes
Diffstat (limited to 'source/Symbol')
| -rw-r--r-- | source/Symbol/ClangASTContext.cpp | 122 | ||||
| -rw-r--r-- | source/Symbol/GoASTContext.cpp | 35 | ||||
| -rw-r--r-- | source/Symbol/SymbolFile.cpp | 4 | ||||
| -rw-r--r-- | source/Symbol/Symtab.cpp | 68 |
4 files changed, 105 insertions, 124 deletions
diff --git a/source/Symbol/ClangASTContext.cpp b/source/Symbol/ClangASTContext.cpp index 6ad353099bc5..8e2576aaec95 100644 --- a/source/Symbol/ClangASTContext.cpp +++ b/source/Symbol/ClangASTContext.cpp @@ -378,10 +378,9 @@ static void ParseLangArgs(LangOptions &Opts, InputKind IK, const char *triple) { // Set some properties which depend solely on the input kind; it would be nice // to move these to the language standard, and have the driver resolve the // input kind + language standard. - if (IK == IK_Asm) { + if (IK.getLanguage() == InputKind::Asm) { Opts.AsmPreprocessor = 1; - } else if (IK == IK_ObjC || IK == IK_ObjCXX || IK == IK_PreprocessedObjC || - IK == IK_PreprocessedObjCXX) { + } else if (IK.isObjectiveC()) { Opts.ObjC1 = Opts.ObjC2 = 1; } @@ -389,30 +388,24 @@ static void ParseLangArgs(LangOptions &Opts, InputKind IK, const char *triple) { if (LangStd == LangStandard::lang_unspecified) { // Based on the base language, pick one. - switch (IK) { - case IK_None: - case IK_AST: - case IK_LLVM_IR: - case IK_RenderScript: + switch (IK.getLanguage()) { + case InputKind::Unknown: + case InputKind::LLVM_IR: + case InputKind::RenderScript: llvm_unreachable("Invalid input kind!"); - case IK_OpenCL: - LangStd = LangStandard::lang_opencl; + case InputKind::OpenCL: + LangStd = LangStandard::lang_opencl10; break; - case IK_CUDA: - case IK_PreprocessedCuda: + case InputKind::CUDA: LangStd = LangStandard::lang_cuda; break; - case IK_Asm: - case IK_C: - case IK_PreprocessedC: - case IK_ObjC: - case IK_PreprocessedObjC: + case InputKind::Asm: + case InputKind::C: + case InputKind::ObjC: LangStd = LangStandard::lang_gnu99; break; - case IK_CXX: - case IK_PreprocessedCXX: - case IK_ObjCXX: - case IK_PreprocessedObjCXX: + case InputKind::CXX: + case InputKind::ObjCXX: LangStd = LangStandard::lang_gnucxx98; break; } @@ -432,7 +425,7 @@ static void ParseLangArgs(LangOptions &Opts, InputKind IK, const char *triple) { Opts.WChar = true; // OpenCL has some additional defaults. - if (LangStd == LangStandard::lang_opencl) { + if (LangStd == LangStandard::lang_opencl10) { Opts.OpenCL = 1; Opts.AltiVec = 1; Opts.CXXOperatorNames = 1; @@ -784,8 +777,8 @@ IdentifierTable *ClangASTContext::getIdentifierTable() { LangOptions *ClangASTContext::getLanguageOptions() { if (m_language_options_ap.get() == nullptr) { m_language_options_ap.reset(new LangOptions()); - ParseLangArgs(*m_language_options_ap, IK_ObjCXX, GetTargetTriple()); - // InitializeLangOptions(*m_language_options_ap, IK_ObjCXX); + ParseLangArgs(*m_language_options_ap, InputKind::ObjCXX, GetTargetTriple()); + // InitializeLangOptions(*m_language_options_ap, InputKind::ObjCXX); } return m_language_options_ap.get(); } @@ -961,75 +954,60 @@ ClangASTContext::GetBasicTypeEnumeration(const ConstString &name) { static llvm::once_flag g_once_flag; llvm::call_once(g_once_flag, []() { // "void" - g_type_map.Append(ConstString("void").GetStringRef(), eBasicTypeVoid); + g_type_map.Append(ConstString("void"), eBasicTypeVoid); // "char" - g_type_map.Append(ConstString("char").GetStringRef(), eBasicTypeChar); - g_type_map.Append(ConstString("signed char").GetStringRef(), - eBasicTypeSignedChar); - g_type_map.Append(ConstString("unsigned char").GetStringRef(), - eBasicTypeUnsignedChar); - g_type_map.Append(ConstString("wchar_t").GetStringRef(), eBasicTypeWChar); - g_type_map.Append(ConstString("signed wchar_t").GetStringRef(), - eBasicTypeSignedWChar); - g_type_map.Append(ConstString("unsigned wchar_t").GetStringRef(), + g_type_map.Append(ConstString("char"), eBasicTypeChar); + g_type_map.Append(ConstString("signed char"), eBasicTypeSignedChar); + g_type_map.Append(ConstString("unsigned char"), eBasicTypeUnsignedChar); + g_type_map.Append(ConstString("wchar_t"), eBasicTypeWChar); + g_type_map.Append(ConstString("signed wchar_t"), eBasicTypeSignedWChar); + g_type_map.Append(ConstString("unsigned wchar_t"), eBasicTypeUnsignedWChar); // "short" - g_type_map.Append(ConstString("short").GetStringRef(), eBasicTypeShort); - g_type_map.Append(ConstString("short int").GetStringRef(), - eBasicTypeShort); - g_type_map.Append(ConstString("unsigned short").GetStringRef(), - eBasicTypeUnsignedShort); - g_type_map.Append(ConstString("unsigned short int").GetStringRef(), + g_type_map.Append(ConstString("short"), eBasicTypeShort); + g_type_map.Append(ConstString("short int"), eBasicTypeShort); + g_type_map.Append(ConstString("unsigned short"), eBasicTypeUnsignedShort); + g_type_map.Append(ConstString("unsigned short int"), eBasicTypeUnsignedShort); // "int" - g_type_map.Append(ConstString("int").GetStringRef(), eBasicTypeInt); - g_type_map.Append(ConstString("signed int").GetStringRef(), - eBasicTypeInt); - g_type_map.Append(ConstString("unsigned int").GetStringRef(), - eBasicTypeUnsignedInt); - g_type_map.Append(ConstString("unsigned").GetStringRef(), - eBasicTypeUnsignedInt); + g_type_map.Append(ConstString("int"), eBasicTypeInt); + g_type_map.Append(ConstString("signed int"), eBasicTypeInt); + g_type_map.Append(ConstString("unsigned int"), eBasicTypeUnsignedInt); + g_type_map.Append(ConstString("unsigned"), eBasicTypeUnsignedInt); // "long" - g_type_map.Append(ConstString("long").GetStringRef(), eBasicTypeLong); - g_type_map.Append(ConstString("long int").GetStringRef(), eBasicTypeLong); - g_type_map.Append(ConstString("unsigned long").GetStringRef(), - eBasicTypeUnsignedLong); - g_type_map.Append(ConstString("unsigned long int").GetStringRef(), + g_type_map.Append(ConstString("long"), eBasicTypeLong); + g_type_map.Append(ConstString("long int"), eBasicTypeLong); + g_type_map.Append(ConstString("unsigned long"), eBasicTypeUnsignedLong); + g_type_map.Append(ConstString("unsigned long int"), eBasicTypeUnsignedLong); // "long long" - g_type_map.Append(ConstString("long long").GetStringRef(), - eBasicTypeLongLong); - g_type_map.Append(ConstString("long long int").GetStringRef(), - eBasicTypeLongLong); - g_type_map.Append(ConstString("unsigned long long").GetStringRef(), + g_type_map.Append(ConstString("long long"), eBasicTypeLongLong); + g_type_map.Append(ConstString("long long int"), eBasicTypeLongLong); + g_type_map.Append(ConstString("unsigned long long"), eBasicTypeUnsignedLongLong); - g_type_map.Append(ConstString("unsigned long long int").GetStringRef(), + g_type_map.Append(ConstString("unsigned long long int"), eBasicTypeUnsignedLongLong); // "int128" - g_type_map.Append(ConstString("__int128_t").GetStringRef(), - eBasicTypeInt128); - g_type_map.Append(ConstString("__uint128_t").GetStringRef(), - eBasicTypeUnsignedInt128); + g_type_map.Append(ConstString("__int128_t"), eBasicTypeInt128); + g_type_map.Append(ConstString("__uint128_t"), eBasicTypeUnsignedInt128); // Miscellaneous - g_type_map.Append(ConstString("bool").GetStringRef(), eBasicTypeBool); - g_type_map.Append(ConstString("float").GetStringRef(), eBasicTypeFloat); - g_type_map.Append(ConstString("double").GetStringRef(), eBasicTypeDouble); - g_type_map.Append(ConstString("long double").GetStringRef(), - eBasicTypeLongDouble); - g_type_map.Append(ConstString("id").GetStringRef(), eBasicTypeObjCID); - g_type_map.Append(ConstString("SEL").GetStringRef(), eBasicTypeObjCSel); - g_type_map.Append(ConstString("nullptr").GetStringRef(), - eBasicTypeNullPtr); + g_type_map.Append(ConstString("bool"), eBasicTypeBool); + g_type_map.Append(ConstString("float"), eBasicTypeFloat); + g_type_map.Append(ConstString("double"), eBasicTypeDouble); + g_type_map.Append(ConstString("long double"), eBasicTypeLongDouble); + g_type_map.Append(ConstString("id"), eBasicTypeObjCID); + g_type_map.Append(ConstString("SEL"), eBasicTypeObjCSel); + g_type_map.Append(ConstString("nullptr"), eBasicTypeNullPtr); g_type_map.Sort(); }); - return g_type_map.Find(name.GetStringRef(), eBasicTypeInvalid); + return g_type_map.Find(name, eBasicTypeInvalid); } return eBasicTypeInvalid; } diff --git a/source/Symbol/GoASTContext.cpp b/source/Symbol/GoASTContext.cpp index 5ca173ae113c..6761a605e46b 100644 --- a/source/Symbol/GoASTContext.cpp +++ b/source/Symbol/GoASTContext.cpp @@ -598,33 +598,32 @@ GoASTContext::GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) { static llvm::once_flag g_once_flag; llvm::call_once(g_once_flag, []() { // "void" - g_type_map.Append(ConstString("void").GetStringRef(), eBasicTypeVoid); + g_type_map.Append(ConstString("void"), eBasicTypeVoid); // "int" - g_type_map.Append(ConstString("int").GetStringRef(), eBasicTypeInt); - g_type_map.Append(ConstString("uint").GetStringRef(), - eBasicTypeUnsignedInt); + g_type_map.Append(ConstString("int"), eBasicTypeInt); + g_type_map.Append(ConstString("uint"), eBasicTypeUnsignedInt); // Miscellaneous - g_type_map.Append(ConstString("bool").GetStringRef(), eBasicTypeBool); + g_type_map.Append(ConstString("bool"), eBasicTypeBool); // Others. Should these map to C types? - g_type_map.Append(ConstString("byte").GetStringRef(), eBasicTypeOther); - g_type_map.Append(ConstString("uint8").GetStringRef(), eBasicTypeOther); - g_type_map.Append(ConstString("uint16").GetStringRef(), eBasicTypeOther); - g_type_map.Append(ConstString("uint32").GetStringRef(), eBasicTypeOther); - g_type_map.Append(ConstString("uint64").GetStringRef(), eBasicTypeOther); - g_type_map.Append(ConstString("int8").GetStringRef(), eBasicTypeOther); - g_type_map.Append(ConstString("int16").GetStringRef(), eBasicTypeOther); - g_type_map.Append(ConstString("int32").GetStringRef(), eBasicTypeOther); - g_type_map.Append(ConstString("int64").GetStringRef(), eBasicTypeOther); - g_type_map.Append(ConstString("float32").GetStringRef(), eBasicTypeOther); - g_type_map.Append(ConstString("float64").GetStringRef(), eBasicTypeOther); - g_type_map.Append(ConstString("uintptr").GetStringRef(), eBasicTypeOther); + g_type_map.Append(ConstString("byte"), eBasicTypeOther); + g_type_map.Append(ConstString("uint8"), eBasicTypeOther); + g_type_map.Append(ConstString("uint16"), eBasicTypeOther); + g_type_map.Append(ConstString("uint32"), eBasicTypeOther); + g_type_map.Append(ConstString("uint64"), eBasicTypeOther); + g_type_map.Append(ConstString("int8"), eBasicTypeOther); + g_type_map.Append(ConstString("int16"), eBasicTypeOther); + g_type_map.Append(ConstString("int32"), eBasicTypeOther); + g_type_map.Append(ConstString("int64"), eBasicTypeOther); + g_type_map.Append(ConstString("float32"), eBasicTypeOther); + g_type_map.Append(ConstString("float64"), eBasicTypeOther); + g_type_map.Append(ConstString("uintptr"), eBasicTypeOther); g_type_map.Sort(); }); - return g_type_map.Find(name.GetStringRef(), eBasicTypeInvalid); + return g_type_map.Find(name, eBasicTypeInvalid); } return eBasicTypeInvalid; } diff --git a/source/Symbol/SymbolFile.cpp b/source/Symbol/SymbolFile.cpp index d7898919f45e..eb20b80f4916 100644 --- a/source/Symbol/SymbolFile.cpp +++ b/source/Symbol/SymbolFile.cpp @@ -21,6 +21,10 @@ using namespace lldb_private; +void SymbolFile::PreloadSymbols() { + // No-op for most implementations. +} + SymbolFile *SymbolFile::FindPlugin(ObjectFile *obj_file) { std::unique_ptr<SymbolFile> best_symfile_ap; if (obj_file != nullptr) { diff --git a/source/Symbol/Symtab.cpp b/source/Symbol/Symtab.cpp index 427029802634..1e241df0d90a 100644 --- a/source/Symbol/Symtab.cpp +++ b/source/Symbol/Symtab.cpp @@ -263,36 +263,35 @@ void Symtab::InitNameIndexes() { continue; const Mangled &mangled = symbol->GetMangled(); - entry.cstring = mangled.GetMangledName().GetStringRef(); - if (!entry.cstring.empty()) { + entry.cstring = mangled.GetMangledName(); + if (entry.cstring) { m_name_to_index.Append(entry); if (symbol->ContainsLinkerAnnotations()) { // If the symbol has linker annotations, also add the version without // the annotations. entry.cstring = ConstString(m_objfile->StripLinkerSymbolAnnotations( - entry.cstring)) - .GetStringRef(); + entry.cstring.GetStringRef())); m_name_to_index.Append(entry); } const SymbolType symbol_type = symbol->GetType(); if (symbol_type == eSymbolTypeCode || symbol_type == eSymbolTypeResolver) { - if (entry.cstring[0] == '_' && entry.cstring[1] == 'Z' && - (entry.cstring[2] != 'T' && // avoid virtual table, VTT structure, - // typeinfo structure, and typeinfo - // name - entry.cstring[2] != 'G' && // avoid guard variables - entry.cstring[2] != 'Z')) // named local entities (if we + llvm::StringRef entry_ref(entry.cstring.GetStringRef()); + if (entry_ref[0] == '_' && entry_ref[1] == 'Z' && + (entry_ref[2] != 'T' && // avoid virtual table, VTT structure, + // typeinfo structure, and typeinfo + // name + entry_ref[2] != 'G' && // avoid guard variables + entry_ref[2] != 'Z')) // named local entities (if we // eventually handle eSymbolTypeData, // we will want this back) { CPlusPlusLanguage::MethodName cxx_method( mangled.GetDemangledName(lldb::eLanguageTypeC_plus_plus)); - entry.cstring = - ConstString(cxx_method.GetBasename()).GetStringRef(); - if (!entry.cstring.empty()) { + entry.cstring = ConstString(cxx_method.GetBasename()); + if (entry.cstring) { // ConstString objects permanently store the string in the pool so // calling // GetCString() on the value gets us a const char * that will @@ -300,7 +299,8 @@ void Symtab::InitNameIndexes() { const char *const_context = ConstString(cxx_method.GetContext()).GetCString(); - if (entry.cstring[0] == '~' || + entry_ref = entry.cstring.GetStringRef(); + if (entry_ref[0] == '~' || !cxx_method.GetQualifiers().empty()) { // The first character of the demangled basename is '~' which // means we have a class destructor. We can use this information @@ -341,17 +341,15 @@ void Symtab::InitNameIndexes() { } } - entry.cstring = - mangled.GetDemangledName(symbol->GetLanguage()).GetStringRef(); - if (!entry.cstring.empty()) { + entry.cstring = mangled.GetDemangledName(symbol->GetLanguage()); + if (entry.cstring) { m_name_to_index.Append(entry); if (symbol->ContainsLinkerAnnotations()) { // If the symbol has linker annotations, also add the version without // the annotations. entry.cstring = ConstString(m_objfile->StripLinkerSymbolAnnotations( - entry.cstring)) - .GetStringRef(); + entry.cstring.GetStringRef())); m_name_to_index.Append(entry); } } @@ -359,15 +357,15 @@ void Symtab::InitNameIndexes() { // If the demangled name turns out to be an ObjC name, and // is a category name, add the version without categories to the index // too. - ObjCLanguage::MethodName objc_method(entry.cstring, true); + ObjCLanguage::MethodName objc_method(entry.cstring.GetStringRef(), true); if (objc_method.IsValid(true)) { - entry.cstring = objc_method.GetSelector().GetStringRef(); + entry.cstring = objc_method.GetSelector(); m_selector_to_index.Append(entry); ConstString objc_method_no_category( objc_method.GetFullNameWithoutCategory(true)); if (objc_method_no_category) { - entry.cstring = objc_method_no_category.GetStringRef(); + entry.cstring = objc_method_no_category; m_name_to_index.Append(entry); } } @@ -427,6 +425,11 @@ void Symtab::InitNameIndexes() { } } +void Symtab::PreloadSymbols() { + std::lock_guard<std::recursive_mutex> guard(m_mutex); + InitNameIndexes(); +} + void Symtab::AppendSymbolNamesToMap(const IndexCollection &indexes, bool add_demangled, bool add_mangled, NameToIndexMap &name_to_index_map) const { @@ -444,15 +447,14 @@ void Symtab::AppendSymbolNamesToMap(const IndexCollection &indexes, const Mangled &mangled = symbol->GetMangled(); if (add_demangled) { - entry.cstring = - mangled.GetDemangledName(symbol->GetLanguage()).GetStringRef(); - if (!entry.cstring.empty()) + entry.cstring = mangled.GetDemangledName(symbol->GetLanguage()); + if (entry.cstring) name_to_index_map.Append(entry); } if (add_mangled) { - entry.cstring = mangled.GetMangledName().GetStringRef(); - if (!entry.cstring.empty()) + entry.cstring = mangled.GetMangledName(); + if (entry.cstring) name_to_index_map.Append(entry); } } @@ -625,7 +627,7 @@ uint32_t Symtab::AppendSymbolIndexesWithName(const ConstString &symbol_name, if (!m_name_indexes_computed) InitNameIndexes(); - return m_name_to_index.GetValues(symbol_name.GetStringRef(), indexes); + return m_name_to_index.GetValues(symbol_name, indexes); } return 0; } @@ -644,7 +646,7 @@ uint32_t Symtab::AppendSymbolIndexesWithName(const ConstString &symbol_name, std::vector<uint32_t> all_name_indexes; const size_t name_match_count = - m_name_to_index.GetValues(symbol_name.GetStringRef(), all_name_indexes); + m_name_to_index.GetValues(symbol_name, all_name_indexes); for (size_t i = 0; i < name_match_count; ++i) { if (CheckSymbolAtIndex(all_name_indexes[i], symbol_debug_type, symbol_visibility)) @@ -1068,8 +1070,6 @@ size_t Symtab::FindFunctionSymbols(const ConstString &name, size_t count = 0; std::vector<uint32_t> symbol_indexes; - llvm::StringRef name_cstr = name.GetStringRef(); - // eFunctionNameTypeAuto should be pre-resolved by a call to // Module::LookupInfo::LookupInfo() assert((name_type_mask & eFunctionNameTypeAuto) == 0); @@ -1107,7 +1107,7 @@ size_t Symtab::FindFunctionSymbols(const ConstString &name, if (!m_basename_to_index.IsEmpty()) { const UniqueCStringMap<uint32_t>::Entry *match; - for (match = m_basename_to_index.FindFirstValueForName(name_cstr); + for (match = m_basename_to_index.FindFirstValueForName(name); match != nullptr; match = m_basename_to_index.FindNextValueForName(match)) { symbol_indexes.push_back(match->value); @@ -1121,7 +1121,7 @@ size_t Symtab::FindFunctionSymbols(const ConstString &name, if (!m_method_to_index.IsEmpty()) { const UniqueCStringMap<uint32_t>::Entry *match; - for (match = m_method_to_index.FindFirstValueForName(name_cstr); + for (match = m_method_to_index.FindFirstValueForName(name); match != nullptr; match = m_method_to_index.FindNextValueForName(match)) { symbol_indexes.push_back(match->value); @@ -1135,7 +1135,7 @@ size_t Symtab::FindFunctionSymbols(const ConstString &name, if (!m_selector_to_index.IsEmpty()) { const UniqueCStringMap<uint32_t>::Entry *match; - for (match = m_selector_to_index.FindFirstValueForName(name_cstr); + for (match = m_selector_to_index.FindFirstValueForName(name); match != nullptr; match = m_selector_to_index.FindNextValueForName(match)) { symbol_indexes.push_back(match->value); |
