[llvm-branch-commits] [cfe-branch] r118577 - in /cfe/branches/Apple/whitney: include/clang/AST/Expr.h lib/AST/Expr.cpp
Daniel Dunbar
daniel at zuster.org
Tue Nov 9 09:32:47 PST 2010
Author: ddunbar
Date: Tue Nov 9 11:32:47 2010
New Revision: 118577
URL: http://llvm.org/viewvc/llvm-project?rev=118577&view=rev
Log:
Merge r118472:
--
Author: Ted Kremenek <kremenek at apple.com>
Date: Tue Nov 9 02:11:40 2010 +0000
Fix InitListExpr::getSourceRange() to work in the case of no locations for '(' and ')'. This can happen
in the case of transparent unions.
Modified:
cfe/branches/Apple/whitney/include/clang/AST/Expr.h
cfe/branches/Apple/whitney/lib/AST/Expr.cpp
Modified: cfe/branches/Apple/whitney/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/include/clang/AST/Expr.h?rev=118577&r1=118576&r2=118577&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/include/clang/AST/Expr.h (original)
+++ cfe/branches/Apple/whitney/include/clang/AST/Expr.h Tue Nov 9 11:32:47 2010
@@ -2931,9 +2931,8 @@
HadArrayRangeDesignator = ARD;
}
- virtual SourceRange getSourceRange() const {
- return SourceRange(LBraceLoc, RBraceLoc);
- }
+ virtual SourceRange getSourceRange() const;
+
static bool classof(const Stmt *T) {
return T->getStmtClass() == InitListExprClass;
}
Modified: cfe/branches/Apple/whitney/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/AST/Expr.cpp?rev=118577&r1=118576&r2=118577&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/AST/Expr.cpp (original)
+++ cfe/branches/Apple/whitney/lib/AST/Expr.cpp Tue Nov 9 11:32:47 2010
@@ -1028,6 +1028,35 @@
return Result;
}
+SourceRange InitListExpr::getSourceRange() const {
+ if (SyntacticForm)
+ return SyntacticForm->getSourceRange();
+ SourceLocation Beg = LBraceLoc, End = RBraceLoc;
+ if (Beg.isInvalid()) {
+ // Find the first non-null initializer.
+ for (InitExprsTy::const_iterator I = InitExprs.begin(),
+ E = InitExprs.end();
+ I != E; ++I) {
+ if (Stmt *S = *I) {
+ Beg = S->getLocStart();
+ break;
+ }
+ }
+ }
+ if (End.isInvalid()) {
+ // Find the first non-null initializer from the end.
+ for (InitExprsTy::const_reverse_iterator I = InitExprs.rbegin(),
+ E = InitExprs.rend();
+ I != E; ++I) {
+ if (Stmt *S = *I) {
+ End = S->getSourceRange().getEnd();
+ break;
+ }
+ }
+ }
+ return SourceRange(Beg, End);
+}
+
/// getFunctionType - Return the underlying function type for this block.
///
const FunctionType *BlockExpr::getFunctionType() const {
More information about the llvm-branch-commits
mailing list