Index: lldb/source/Target/Target.cpp =================================================================== --- lldb/source/Target/Target.cpp +++ lldb/source/Target/Target.cpp @@ -2250,6 +2250,13 @@ scratch_type_systems.emplace_back(&type_system_or_err.get()); } + // Some TypeSystem instances are associated with several LanguageTypes so + // they will show up multiple times in the loop above. Filter out the + // duplicates as they serve no useful purpose for the caller. + llvm::sort(scratch_type_systems); + auto remove_from = + std::unique(scratch_type_systems.begin(), scratch_type_systems.end()); + scratch_type_systems.erase(remove_from, scratch_type_systems.end()); return scratch_type_systems; } Index: lldb/test/API/lang/c/builtin-types/TestCBuiltinTypes.py =================================================================== --- /dev/null +++ lldb/test/API/lang/c/builtin-types/TestCBuiltinTypes.py @@ -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)