Index: lldb/source/Target/Target.cpp =================================================================== --- lldb/source/Target/Target.cpp +++ lldb/source/Target/Target.cpp @@ -60,6 +60,7 @@ #include "lldb/Utility/Timer.h" #include "llvm/ADT/ScopeExit.h" +#include "llvm/ADT/SetVector.h" #include #include @@ -2231,7 +2232,10 @@ if (!m_valid) return {}; - std::vector 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 scratch_type_systems; LanguageSet languages_for_expressions = Language::GetLanguagesSupportingTypeSystemsForExpressions(); @@ -2247,10 +2251,10 @@ "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 * 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)