]> granicus.if.org Git - clang/commitdiff
Make C++ temporary-related expressions provide proper source-range information.
authorDouglas Gregor <dgregor@apple.com>
Wed, 23 Sep 2009 22:51:26 +0000 (22:51 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 23 Sep 2009 22:51:26 +0000 (22:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82665 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/ExprCXX.h
test/SemaCXX/references.cpp

index 0435d21483b0acf6337266ab03cac49d16f00437..3f66b1f40bfcb4f72266f898871ffa33b89fa7fd 100644 (file)
@@ -466,7 +466,9 @@ public:
   Expr *getSubExpr() { return cast<Expr>(SubExpr); }
   void setSubExpr(Expr *E) { SubExpr = E; }
 
-  virtual SourceRange getSourceRange() const { return SourceRange(); }
+  virtual SourceRange getSourceRange() const { 
+    return SubExpr->getSourceRange();
+  }
 
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Stmt *T) {
@@ -539,7 +541,13 @@ public:
     Args[Arg] = ArgExpr;
   }
 
-  virtual SourceRange getSourceRange() const { return SourceRange(); }
+  virtual SourceRange getSourceRange() const { 
+    // FIXME: Should we know where the parentheses are, if there are any?
+    if (NumArgs == 0)
+      return SourceRange(); 
+    
+    return SourceRange(Args[0]->getLocStart(), Args[NumArgs - 1]->getLocEnd());
+  }
 
   static bool classof(const Stmt *T) {
     return T->getStmtClass() == CXXConstructExprClass ||
@@ -1289,7 +1297,9 @@ public:
   const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
   void setSubExpr(Expr *E) { SubExpr = E; }
 
-  virtual SourceRange getSourceRange() const { return SourceRange(); }
+  virtual SourceRange getSourceRange() const { 
+    return SubExpr->getSourceRange();
+  }
 
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Stmt *T) {
index 9067a8661d7cc2d6f47630e5254ac1aeaaf3c41e..e03abf4300a3a301a70be909e02aaef1cbd17fa2 100644 (file)
@@ -87,3 +87,18 @@ void test8(int& const,// expected-error{{'const' qualifier may not be applied to
 
   typedef intref const intref_c; // okay. FIXME: how do we verify that this is the same type as intref?
 }
+
+
+class string {
+  char *Data;
+  unsigned Length;
+public:
+  string(); 
+  ~string();
+};
+
+string getInput();
+
+void test9() {
+  string &s = getInput(); // expected-error{{lvalue reference}}
+}