]> granicus.if.org Git - clang/commitdiff
Don't load ill-formed AmbiguityKind in Sema::Lookup.
authorAlexey Samsonov <vonosmas@gmail.com>
Thu, 28 Aug 2014 23:17:55 +0000 (23:17 +0000)
committerAlexey Samsonov <vonosmas@gmail.com>
Thu, 28 Aug 2014 23:17:55 +0000 (23:17 +0000)
This bug was reported by UBSan.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216695 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Sema/Lookup.h

index 00cc164d964c99d7d7982c489a14807bd28b522e..e050c7ddbf115616e340330310abe9d37fac6ee7 100644 (file)
@@ -424,13 +424,19 @@ public:
         Paths = nullptr;
       }
     } else {
-      AmbiguityKind SavedAK = Ambiguity;
+      AmbiguityKind SavedAK;
+      bool WasAmbiguous = false;
+      if (ResultKind == Ambiguous) {
+        SavedAK = Ambiguity;
+        WasAmbiguous = true;
+      }
       ResultKind = Found;
       resolveKind();
 
       // If we didn't make the lookup unambiguous, restore the old
       // ambiguity kind.
       if (ResultKind == Ambiguous) {
+        assert(WasAmbiguous);
         Ambiguity = SavedAK;
       } else if (Paths) {
         deletePaths(Paths);