diff options
author | Sam Panzer <espanz@gmail.com> | 2012-08-21 00:52:01 +0000 |
---|---|---|
committer | Sam Panzer <espanz@gmail.com> | 2012-08-21 00:52:01 +0000 |
commit | e1715b66a878bcab315513351e5df68bfc010d2e (patch) | |
tree | bd09db1864a394c68f16dfa348c04f7399d0b562 /include/clang/Sema/Sema.h | |
parent | a34d4f47321324187ed57948628f5938357ae034 (diff) |
Better diagnostics for range-based for loops with bad range types.
The old error message stating that 'begin' was an undeclared identifier
is replaced with a new message explaining that the error is in the range
expression, along with which of the begin() and end() functions was
problematic if relevant.
Additionally, if the range was a pointer type or defines operator*,
attempt to dereference the range, and offer a FixIt if the modified range
works.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162248 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Sema/Sema.h')
-rw-r--r-- | include/clang/Sema/Sema.h | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 4be532c56f..4e2a9714a2 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -1924,6 +1924,30 @@ public: OverloadCandidateSet &CandidateSet, bool PartialOverloading = false); + // An enum used to represent the different possible results of building a + // range-based for loop. + enum ForRangeStatus { + FRS_Success, + FRS_NoViableFunction, + FRS_DiagnosticIssued + }; + + // An enum to represent whether something is dealing with a call to begin() + // or a call to end() in a range-based for loop. + enum BeginEndFunction { + BEF_begin, + BEF_end + }; + + ForRangeStatus BuildForRangeBeginEndCall(Scope *S, SourceLocation Loc, + SourceLocation RangeLoc, + VarDecl *Decl, + BeginEndFunction BEF, + const DeclarationNameInfo &NameInfo, + LookupResult &MemberLookup, + OverloadCandidateSet *CandidateSet, + Expr *Range, ExprResult *CallExpr); + ExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, @@ -1932,6 +1956,12 @@ public: Expr *ExecConfig, bool AllowTypoCorrection=true); + bool buildOverloadedCallSet(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, + Expr **Args, unsigned NumArgs, + SourceLocation RParenLoc, + OverloadCandidateSet *CandidateSet, + ExprResult *Result); + ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned Opc, const UnresolvedSetImpl &Fns, @@ -2512,13 +2542,15 @@ public: StmtResult ActOnCXXForRangeStmt(SourceLocation ForLoc, Stmt *LoopVar, SourceLocation ColonLoc, Expr *Collection, - SourceLocation RParenLoc); + SourceLocation RParenLoc, + bool ShouldTryDeref); StmtResult BuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation ColonLoc, Stmt *RangeDecl, Stmt *BeginEndDecl, Expr *Cond, Expr *Inc, Stmt *LoopVarDecl, - SourceLocation RParenLoc); + SourceLocation RParenLoc, + bool ShouldTryDeref); StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body); StmtResult ActOnGotoStmt(SourceLocation GotoLoc, |