Răsfoiți Sursa

[ASTMatchers] Don't create a copy of a std::set when iterating over it.

This is a bit awkward because lookup returns a copy instead of a
reference. No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315276 91177308-0d34-0410-b5e6-96231b3b80d8
Benjamin Kramer 7 ani în urmă
părinte
comite
d89b5f87c9
1 a modificat fișierele cu 4 adăugiri și 1 ștergeri
  1. 4 1
      lib/ASTMatchers/ASTMatchFinder.cpp

+ 4 - 1
lib/ASTMatchers/ASTMatchFinder.cpp

@@ -734,7 +734,10 @@ private:
                             BoundNodesTreeBuilder *Builder) {
     const Type *const CanonicalType =
       ActiveASTContext->getCanonicalType(TypeNode);
-    for (const TypedefNameDecl *Alias : TypeAliases.lookup(CanonicalType)) {
+    auto Aliases = TypeAliases.find(CanonicalType);
+    if (Aliases == TypeAliases.end())
+      return false;
+    for (const TypedefNameDecl *Alias : Aliases->second) {
       BoundNodesTreeBuilder Result(*Builder);
       if (Matcher.matches(*Alias, this, &Result)) {
         *Builder = std::move(Result);