aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorKaelyn Uhrain <rikka@google.com>2012-06-29 21:30:39 +0000
committerKaelyn Uhrain <rikka@google.com>2012-06-29 21:30:39 +0000
commit4ac5751efb9de1065c71b0db587185d552803e2f (patch)
tree8945a101af2348cdeca35a676d4366407bc40030 /lib/Sema/SemaDecl.cpp
parent529cdf4c2ef0985dd6f4b7b68ab76e6a1a5082d5 (diff)
In Sema::ClassifyName, try to avoid nonsensical corrections to
keywords when doing type correction. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159464 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 40ec1baddb..d63922ba32 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -634,6 +634,19 @@ Corrected:
if (!SecondTry) {
SecondTry = true;
CorrectionCandidateCallback DefaultValidator;
+ // Try to limit which sets of keywords should be included in typo
+ // correction based on what the next token is.
+ DefaultValidator.WantTypeSpecifiers =
+ NextToken.is(tok::l_paren) || NextToken.is(tok::less) ||
+ NextToken.is(tok::identifier) || NextToken.is(tok::star) ||
+ NextToken.is(tok::amp) || NextToken.is(tok::l_square);
+ DefaultValidator.WantExpressionKeywords =
+ NextToken.is(tok::l_paren) || NextToken.is(tok::identifier) ||
+ NextToken.is(tok::arrow) || NextToken.is(tok::period);
+ DefaultValidator.WantRemainingKeywords =
+ NextToken.is(tok::l_paren) || NextToken.is(tok::semi) ||
+ NextToken.is(tok::identifier) || NextToken.is(tok::l_brace);
+ DefaultValidator.WantCXXNamedCasts = false;
if (TypoCorrection Corrected = CorrectTypo(Result.getLookupNameInfo(),
Result.getLookupKind(), S,
&SS, DefaultValidator)) {