summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-03-12 22:46:12 +0000
committerDouglas Gregor <dgregor@apple.com>2009-03-12 22:46:12 +0000
commit6873f9c5210316d37bc4067e4fdaf26b0bd70b34 (patch)
treef60c8a19ec200f8f6c4bc5b28c06be5e1f947722 /clang/lib/Sema
parent36ce7e17d7c1cce6b21259b52f6a68d2e6cf4301 (diff)
downloadbcm5719-llvm-6873f9c5210316d37bc4067e4fdaf26b0bd70b34.tar.gz
bcm5719-llvm-6873f9c5210316d37bc4067e4fdaf26b0bd70b34.zip
Implement template instantiation for builtin binary operators
llvm-svn: 66835
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/Sema.h24
-rw-r--r--clang/lib/Sema/SemaDecl.cpp3
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiate.cpp29
3 files changed, 42 insertions, 14 deletions
diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h
index 0ea1be3d7ea..913efaf7473 100644
--- a/clang/lib/Sema/Sema.h
+++ b/clang/lib/Sema/Sema.h
@@ -2121,33 +2121,33 @@ public:
/// or a null QualType (indicating an error diagnostic was issued).
/// type checking binary operators (subroutines of CreateBuiltinBinOp).
- inline QualType InvalidOperands(SourceLocation l, Expr *&lex, Expr *&rex);
+ QualType InvalidOperands(SourceLocation l, Expr *&lex, Expr *&rex);
QualType CheckPointerToMemberOperands( // C++ 5.5
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isIndirect);
- inline QualType CheckMultiplyDivideOperands( // C99 6.5.5
+ QualType CheckMultiplyDivideOperands( // C99 6.5.5
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
- inline QualType CheckRemainderOperands( // C99 6.5.5
+ QualType CheckRemainderOperands( // C99 6.5.5
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
- inline QualType CheckAdditionOperands( // C99 6.5.6
+ QualType CheckAdditionOperands( // C99 6.5.6
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
- inline QualType CheckSubtractionOperands( // C99 6.5.6
+ QualType CheckSubtractionOperands( // C99 6.5.6
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
- inline QualType CheckShiftOperands( // C99 6.5.7
+ QualType CheckShiftOperands( // C99 6.5.7
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
- inline QualType CheckCompareOperands( // C99 6.5.8/9
+ QualType CheckCompareOperands( // C99 6.5.8/9
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isRelational);
- inline QualType CheckBitwiseOperands( // C99 6.5.[10...12]
+ QualType CheckBitwiseOperands( // C99 6.5.[10...12]
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
- inline QualType CheckLogicalOperands( // C99 6.5.[13,14]
+ QualType CheckLogicalOperands( // C99 6.5.[13,14]
Expr *&lex, Expr *&rex, SourceLocation OpLoc);
// CheckAssignmentOperands is used for both simple and compound assignment.
// For simple assignment, pass both expressions and a null converted type.
// For compound assignment, pass both expressions and the converted type.
- inline QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
+ QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
Expr *lex, Expr *&rex, SourceLocation OpLoc, QualType convertedType);
- inline QualType CheckCommaOperands( // C99 6.5.17
+ QualType CheckCommaOperands( // C99 6.5.17
Expr *lex, Expr *&rex, SourceLocation OpLoc);
- inline QualType CheckConditionalOperands( // C99 6.5.15
+ QualType CheckConditionalOperands( // C99 6.5.15
Expr *&cond, Expr *&lhs, Expr *&rhs, SourceLocation questionLoc);
/// type checking for vector binary operators.
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index bedf05ed35e..f3983aee453 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -3379,7 +3379,8 @@ bool Sema::VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName,
return Diag(FieldLoc, diag::err_bitfield_has_zero_width) << FieldName;
if (Value.isNegative())
- return Diag(FieldLoc, diag::err_bitfield_has_negative_width) << FieldName;
+ return Diag(FieldLoc, diag::err_bitfield_has_negative_width)
+ << FieldName << Value.toString(10);
if (!FieldTy->isDependentType()) {
uint64_t TypeSize = Context.getTypeSize(FieldTy);
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 6252e29e568..4b98d30b47b 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -576,9 +576,13 @@ namespace {
Sema::OwningExprResult VisitIntegerLiteral(IntegerLiteral *E);
Sema::OwningExprResult VisitDeclRefExpr(DeclRefExpr *E);
Sema::OwningExprResult VisitParenExpr(ParenExpr *E);
+ Sema::OwningExprResult VisitBinaryOperator(BinaryOperator *E);
// Base case. I'm supposed to ignore this.
- Sema::OwningExprResult VisitStmt(Stmt *) { return SemaRef.ExprError(); }
+ Sema::OwningExprResult VisitStmt(Stmt *) {
+ assert(false && "Cannot instantiate this kind of expression");
+ return SemaRef.ExprError();
+ }
};
}
@@ -619,6 +623,29 @@ TemplateExprInstantiator::VisitParenExpr(ParenExpr *E) {
}
Sema::OwningExprResult
+TemplateExprInstantiator::VisitBinaryOperator(BinaryOperator *E) {
+ Sema::OwningExprResult LHS = Visit(E->getLHS());
+ if (LHS.isInvalid())
+ return SemaRef.ExprError();
+
+ Sema::OwningExprResult RHS = Visit(E->getRHS());
+ if (RHS.isInvalid())
+ return SemaRef.ExprError();
+
+ Sema::OwningExprResult Result
+ = SemaRef.CreateBuiltinBinOp(E->getOperatorLoc(),
+ E->getOpcode(),
+ (Expr *)LHS.get(),
+ (Expr *)RHS.get());
+ if (Result.isInvalid())
+ return SemaRef.ExprError();
+
+ LHS.release();
+ RHS.release();
+ return move(Result);
+}
+
+Sema::OwningExprResult
Sema::InstantiateExpr(Expr *E, const TemplateArgument *TemplateArgs,
unsigned NumTemplateArgs) {
TemplateExprInstantiator Instantiator(*this, TemplateArgs, NumTemplateArgs);
OpenPOWER on IntegriCloud