[Lldb-commits] [PATCH] D41550: Update failing PDB unit tests that are searching for symbols by regex to use FindTypesByRegex instead of FindTypes

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Wed Dec 27 18:46:03 PST 2017


Sorry I missed this, lgtm
On Fri, Dec 22, 2017 at 7:55 PM Aaron Smith via Phabricator <
reviews at reviews.llvm.org> wrote:

> asmith created this revision.
> asmith added reviewers: zturner, lldb-commits, labath, clayborg.
>
> https://reviews.llvm.org/D41086 fixed an exception in
> FindTypes()/FindTypesByRegex() and caused two lldb unit test to fail. This
> change updates the unit tests to pass again.
>
> Related review:
> https://reviews.llvm.org/D41086
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D41550
>
> Files:
>   source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
>   unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
>
>
> Index: unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
> ===================================================================
> --- unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
> +++ unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
> @@ -512,13 +512,14 @@
>    SymbolVendor *plugin = module->GetSymbolVendor();
>    SymbolFilePDB *symfile =
>        static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
> -  SymbolContext sc;
> -  llvm::DenseSet<SymbolFile *> searched_files;
>    TypeMap results;
> -  uint32_t num_results = symfile->FindTypes(sc, ConstString(".*"),
> nullptr,
> -                                            false, 0, searched_files,
> results);
> -  EXPECT_GT(num_results, 1u);
> -  EXPECT_EQ(num_results, results.GetSize());
> +  symfile->FindTypesByRegex(RegularExpression(".*"), 0, results);
> +  EXPECT_GT(results.GetSize(), 1u);
> +
> +  // We expect no exception thrown if the given regex can't be compiled
> +  results.Clear();
> +  symfile->FindTypesByRegex(RegularExpression("**"), 0, results);
> +  EXPECT_EQ(0u, results.GetSize());
>  }
>
>  TEST_F(SymbolFilePDBTests, TestMaxMatches) {
> @@ -532,7 +533,8 @@
>    SymbolContext sc;
>    llvm::DenseSet<SymbolFile *> searched_files;
>    TypeMap results;
> -  uint32_t num_results = symfile->FindTypes(sc, ConstString(".*"),
> nullptr,
> +  const ConstString name("ClassTypedef");
> +  uint32_t num_results = symfile->FindTypes(sc, name, nullptr,
>                                              false, 0, searched_files,
> results);
>    // Try to limit ourselves from 1 to 10 results, otherwise we could be
> doing
>    // this thousands of times.
> @@ -542,7 +544,7 @@
>    uint32_t iterations = std::min(num_results, 10u);
>    for (uint32_t i = 1; i <= iterations; ++i) {
>      uint32_t num_limited_results = symfile->FindTypes(
> -        sc, ConstString(".*"), nullptr, false, i, searched_files,
> results);
> +        sc, name, nullptr, false, i, searched_files, results);
>      EXPECT_EQ(i, num_limited_results);
>      EXPECT_EQ(num_limited_results, results.GetSize());
>    }
> Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
> ===================================================================
> --- source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
> +++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
> @@ -140,6 +140,10 @@
>    size_t FindTypes(const std::vector<lldb_private::CompilerContext>
> &context,
>                     bool append, lldb_private::TypeMap &types) override;
>
> +  void FindTypesByRegex(const lldb_private::RegularExpression &regex,
> +                        uint32_t max_matches,
> +                        lldb_private::TypeMap &types);
> +
>    lldb_private::TypeList *GetTypeList() override;
>
>    size_t GetTypes(lldb_private::SymbolContextScope *sc_scope,
> @@ -172,9 +176,6 @@
>        const llvm::pdb::PDBSymbolCompiland &cu,
>        llvm::DenseMap<uint32_t, uint32_t> &index_map) const;
>
> -  void FindTypesByRegex(const std::string &regex, uint32_t max_matches,
> -                        lldb_private::TypeMap &types);
> -
>    void FindTypesByName(const std::string &name, uint32_t max_matches,
>                         lldb_private::TypeMap &types);
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20171228/e4839e37/attachment.html>


More information about the lldb-commits mailing list