]> granicus.if.org Git - clang/commitdiff
Fix CXXConstructExpr::getSourceRange() to not include the source ranges of CXXDefault...
authorTed Kremenek <kremenek@apple.com>
Wed, 23 Dec 2009 04:00:48 +0000 (04:00 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 23 Dec 2009 04:00:48 +0000 (04:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91984 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/ExprCXX.h
lib/AST/ExprCXX.cpp

index 4b540d9c54fa0bd8ae41402060c34c7784fdba1c..88e667a2c26fadc167267f179af1626e6919f7ee 100644 (file)
@@ -561,13 +561,7 @@ public:
     Args[Arg] = ArgExpr;
   }
 
-  virtual SourceRange getSourceRange() const { 
-    // FIXME: Should we know where the parentheses are, if there are any?
-    if (NumArgs == 0)
-      return SourceRange(Loc); 
-    
-    return SourceRange(Loc, Args[NumArgs - 1]->getLocEnd());
-  }
+  virtual SourceRange getSourceRange() const;
 
   static bool classof(const Stmt *T) {
     return T->getStmtClass() == CXXConstructExprClass ||
index 9c14f741fdddd4839c998ad84bf405391529cb40..5444a7748cb826033d04216e6adb38bfab461f0a 100644 (file)
@@ -282,6 +282,18 @@ bool UnaryTypeTraitExpr::EvaluateTrait(ASTContext& C) const {
   }
 }
 
+SourceRange CXXConstructExpr::getSourceRange() const { 
+  // FIXME: Should we know where the parentheses are, if there are any?
+  for (std::reverse_iterator<Stmt**> I(&Args[NumArgs]), E(&Args[0]); I!=E;++I) {
+    // Ignore CXXDefaultExprs when computing the range, as they don't
+    // have a range.
+    if (!isa<CXXDefaultArgExpr>(*I))
+      return SourceRange(Loc, (*I)->getLocEnd());
+  }
+  
+  return SourceRange(Loc);
+}
+
 SourceRange CXXOperatorCallExpr::getSourceRange() const {
   OverloadedOperatorKind Kind = getOperator();
   if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {