Use ExprResult& instead of Expr *& in Sema
This patch authored by Eric Niebler. Many methods on the Sema class (e.g. ConvertPropertyForRValue) take Expr pointers as in/out parameters (Expr *&). This is especially true for the routines that apply implicit conversions to nodes in-place. This design is workable only as long as those conversions cannot fail. If they are allowed to fail, they need a way to report their failures. The typical way of doing this in clang is to use an ExprResult, which has an extra bit to signal a valid/invalid state. Returning ExprResult is de riguour elsewhere in the Sema interface. We suggest changing the Expr *& parameters in the Sema interface to ExprResult &. This increases interface consistency and maintainability. This interface change is important for work supporting MS-style C++ properties. For reasons explained here <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-February/013180.html>, seemingly trivial operations like rvalue/lvalue conversions that formerly could not fail now can. (The reason is that given the semantics of the feature, getter/setter method lookup cannot happen until the point of use, at which point it may be found that the method does not exist, or it may have the wrong type, or overload resolution may fail, or it may be inaccessible.) llvm-svn: 129143
Showing
- clang/include/clang/Sema/Initialization.h 2 additions, 0 deletionsclang/include/clang/Sema/Initialization.h
- clang/include/clang/Sema/Sema.h 86 additions, 78 deletionsclang/include/clang/Sema/Sema.h
- clang/lib/Sema/Sema.cpp 10 additions, 10 deletionsclang/lib/Sema/Sema.cpp
- clang/lib/Sema/SemaCXXCast.cpp 137 additions, 89 deletionsclang/lib/Sema/SemaCXXCast.cpp
- clang/lib/Sema/SemaChecking.cpp 21 additions, 17 deletionsclang/lib/Sema/SemaChecking.cpp
- clang/lib/Sema/SemaCodeComplete.cpp 6 additions, 2 deletionsclang/lib/Sema/SemaCodeComplete.cpp
- clang/lib/Sema/SemaDecl.cpp 3 additions, 3 deletionsclang/lib/Sema/SemaDecl.cpp
- clang/lib/Sema/SemaDeclCXX.cpp 11 additions, 13 deletionsclang/lib/Sema/SemaDeclCXX.cpp
- clang/lib/Sema/SemaExpr.cpp 818 additions, 636 deletionsclang/lib/Sema/SemaExpr.cpp
- clang/lib/Sema/SemaExprCXX.cpp 282 additions, 233 deletionsclang/lib/Sema/SemaExprCXX.cpp
- clang/lib/Sema/SemaExprObjC.cpp 39 additions, 26 deletionsclang/lib/Sema/SemaExprObjC.cpp
- clang/lib/Sema/SemaInit.cpp 90 additions, 67 deletionsclang/lib/Sema/SemaInit.cpp
- clang/lib/Sema/SemaOverload.cpp 208 additions, 130 deletionsclang/lib/Sema/SemaOverload.cpp
- clang/lib/Sema/SemaStmt.cpp 42 additions, 14 deletionsclang/lib/Sema/SemaStmt.cpp
- clang/lib/Sema/SemaTemplate.cpp 65 additions, 59 deletionsclang/lib/Sema/SemaTemplate.cpp
- clang/lib/Sema/SemaType.cpp 7 additions, 2 deletionsclang/lib/Sema/SemaType.cpp
- clang/lib/Sema/TreeTransform.h 29 additions, 27 deletionsclang/lib/Sema/TreeTransform.h
Loading
Please register or sign in to comment