mirror of
https://github.com/siemens-mobile-hacks/llvm-c166.git
synced 2026-11-25 21:45:57 +00:00
[lldb] Filter duplicates in Target::GetScratchTypeSystems
`Target::GetScratchTypeSystems` returns the list of scratch TypeSystems. The current implementation is iterating over all LanguageType values and retrieves the respective TypeSystem for each LanguageType. All C/C++/Obj-C LanguageTypes are however mapped to the same ScratchTypeSystemClang instance, so the current implementation adds this single TypeSystem instance several times to the list of TypeSystems (once for every LanguageType that we support). The only observable effect of this is that `SBTarget.FindTypes` for builtin types currently queries the ScratchTypeSystemClang several times (and also adds the same result several times). Reviewed By: bulbazord, labath Differential Revision: https://reviews.llvm.org/D111931
This commit is contained in:
parent
e41ebbecf9
commit
cfaa5c344d
2 changed files with 27 additions and 3 deletions
|
|
@ -60,6 +60,7 @@
|
|||
#include "lldb/Utility/Timer.h"
|
||||
|
||||
#include "llvm/ADT/ScopeExit.h"
|
||||
#include "llvm/ADT/SetVector.h"
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
|
@ -2231,7 +2232,10 @@ std::vector<TypeSystem *> Target::GetScratchTypeSystems(bool create_on_demand) {
|
|||
if (!m_valid)
|
||||
return {};
|
||||
|
||||
std::vector<TypeSystem *> scratch_type_systems;
|
||||
// Some TypeSystem instances are associated with several LanguageTypes so
|
||||
// they will show up several times in the loop below. The SetVector filters
|
||||
// out all duplicates as they serve no use for the caller.
|
||||
llvm::SetVector<TypeSystem *> scratch_type_systems;
|
||||
|
||||
LanguageSet languages_for_expressions =
|
||||
Language::GetLanguagesSupportingTypeSystemsForExpressions();
|
||||
|
|
@ -2247,10 +2251,10 @@ std::vector<TypeSystem *> Target::GetScratchTypeSystems(bool create_on_demand) {
|
|||
"system available",
|
||||
Language::GetNameForLanguageType(language));
|
||||
else
|
||||
scratch_type_systems.emplace_back(&type_system_or_err.get());
|
||||
scratch_type_systems.insert(&type_system_or_err.get());
|
||||
}
|
||||
|
||||
return scratch_type_systems;
|
||||
return scratch_type_systems.takeVector();
|
||||
}
|
||||
|
||||
PersistentExpressionState *
|
||||
|
|
|
|||
20
lldb/test/API/lang/c/builtin-types/TestCBuiltinTypes.py
Normal file
20
lldb/test/API/lang/c/builtin-types/TestCBuiltinTypes.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
class TestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
@no_debug_info_test
|
||||
def test_FindTypes_on_scratch_AST(self):
|
||||
"""
|
||||
Tests FindTypes invoked with only LLDB's scratch AST present.
|
||||
"""
|
||||
target = self.dbg.GetDummyTarget()
|
||||
# There should be only one instance of 'unsigned long' in our single
|
||||
# scratch AST. Note: FindTypes/SBType hahave no filter by language, so
|
||||
# pick something that is unlikely to also be found in the scratch
|
||||
# TypeSystem of other language plugins.
|
||||
self.assertEqual(len(target.FindTypes("unsigned long")), 1)
|
||||
Loading…
Add table
Reference in a new issue