summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprCXX.cpp
diff options
context:
space:
mode:
authorKaelyn Takata <rikka@google.com>2015-06-25 23:47:39 +0000
committerKaelyn Takata <rikka@google.com>2015-06-25 23:47:39 +0000
commit26ffc5f7fb63dc00e68a3c7199441a396bcfbad9 (patch)
treeb8a1ca4640f933d3800852387b18e6704323d602 /clang/lib/Sema/SemaExprCXX.cpp
parent4fb1f9cda636c581753bb186d099cecc2954e401 (diff)
downloadbcm5719-llvm-26ffc5f7fb63dc00e68a3c7199441a396bcfbad9.tar.gz
bcm5719-llvm-26ffc5f7fb63dc00e68a3c7199441a396bcfbad9.zip
Fix a typo correction crash when resolving ambiguous corrections.
In certain cases, the tree transform would introduce new TypoExprs while trying one of the corrections, invalidating the unique_ptr in the state reference, and also causing a TypoExpr to exist that will never be corrected since it doesn't exist in the final corrected expression. The simple solution to both problems is to temporarily disable typo correction while handling potentially ambiguous typo corrections. llvm-svn: 240734
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 6c839f356fd..6608d7c1f06 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -6506,6 +6506,11 @@ public:
// with the same edit length that pass all the checks and filters.
// TODO: Properly handle various permutations of possible corrections when
// there is more than one potentially ambiguous typo correction.
+ // Also, disable typo correction while attempting the transform when
+ // handling potentially ambiguous typo corrections as any new TypoExprs will
+ // have been introduced by the application of one of the correction
+ // candidates and add little to no value if corrected.
+ SemaRef.DisableTypoCorrection = true;
while (!AmbiguousTypoExprs.empty()) {
auto TE = AmbiguousTypoExprs.back();
auto Cached = TransformCache[TE];
@@ -6522,6 +6527,7 @@ public:
State.Consumer->restoreSavedPosition();
TransformCache[TE] = Cached;
}
+ SemaRef.DisableTypoCorrection = false;
// Ensure that all of the TypoExprs within the current Expr have been found.
if (!Res.isUsable())
OpenPOWER on IntegriCloud