[cfe-commits] r119966 - in /cfe/trunk: lib/Parse/ParseDecl.cpp lib/Parse/ParseExpr.cpp lib/Parse/ParseExprCXX.cpp lib/Sema/SemaType.cpp test/SemaCXX/sourceranges.cpp
Nico Weber
nicolasweber at gmx.de
Mon Nov 22 02:30:56 PST 2010
Author: nico
Date: Mon Nov 22 04:30:56 2010
New Revision: 119966
URL: http://llvm.org/viewvc/llvm-project?rev=119966&view=rev
Log:
Fix the source range of CXXNewExprs. Fixes http://llvm.org/pr8661.
Added:
cfe/trunk/test/SemaCXX/sourceranges.cpp
Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Sema/SemaType.cpp
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=119966&r1=119965&r2=119966&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Nov 22 04:30:56 2010
@@ -1020,7 +1020,8 @@
ConsumeToken(); // The C++ scope.
if (Tok.getAnnotationValue()) {
ParsedType T = getTypeAnnotation(Tok);
- isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename, Loc,
+ isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename,
+ Tok.getAnnotationEndLoc(),
PrevSpec, DiagID, T);
}
else
@@ -1082,7 +1083,8 @@
case tok::annot_typename: {
if (Tok.getAnnotationValue()) {
ParsedType T = getTypeAnnotation(Tok);
- isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec,
+ isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename,
+ Tok.getAnnotationEndLoc(), PrevSpec,
DiagID, T);
} else
DS.SetTypeSpecError();
@@ -1545,7 +1547,8 @@
// simple-type-specifier:
case tok::annot_typename: {
if (ParsedType T = getTypeAnnotation(Tok)) {
- isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec,
+ isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename,
+ Tok.getAnnotationEndLoc(), PrevSpec,
DiagID, T);
} else
DS.SetTypeSpecError();
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=119966&r1=119965&r2=119966&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Mon Nov 22 04:30:56 2010
@@ -822,8 +822,8 @@
const char *PrevSpec = 0;
unsigned DiagID;
- DS.SetTypeSpecType(TST_typename, Tok.getLocation(), PrevSpec, DiagID,
- Type);
+ DS.SetTypeSpecType(TST_typename, Tok.getAnnotationEndLoc(),
+ PrevSpec, DiagID, Type);
Declarator DeclaratorInfo(DS, Declarator::TypeNameContext);
TypeResult Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo);
Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=119966&r1=119965&r2=119966&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Mon Nov 22 04:30:56 2010
@@ -912,8 +912,8 @@
// type-name
case tok::annot_typename: {
- DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, DiagID,
- getTypeAnnotation(Tok));
+ DS.SetTypeSpecType(DeclSpec::TST_typename, Tok.getAnnotationEndLoc(),
+ PrevSpec, DiagID, getTypeAnnotation(Tok));
DS.SetRangeEnd(Tok.getAnnotationEndLoc());
ConsumeToken();
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=119966&r1=119965&r2=119966&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Mon Nov 22 04:30:56 2010
@@ -1558,7 +1558,7 @@
void VisitElaboratedTypeLoc(ElaboratedTypeLoc TL) {
ElaboratedTypeKeyword Keyword
= TypeWithKeyword::getKeywordForTypeSpec(DS.getTypeSpecType());
- if (Keyword == ETK_Typename) {
+ if (DS.getTypeSpecType() == TST_typename) {
TypeSourceInfo *TInfo = 0;
Sema::GetTypeFromParser(DS.getRepAsType(), &TInfo);
if (TInfo) {
@@ -1576,7 +1576,7 @@
void VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
ElaboratedTypeKeyword Keyword
= TypeWithKeyword::getKeywordForTypeSpec(DS.getTypeSpecType());
- if (Keyword == ETK_Typename) {
+ if (DS.getTypeSpecType() == TST_typename) {
TypeSourceInfo *TInfo = 0;
Sema::GetTypeFromParser(DS.getRepAsType(), &TInfo);
if (TInfo) {
Added: cfe/trunk/test/SemaCXX/sourceranges.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/sourceranges.cpp?rev=119966&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/sourceranges.cpp (added)
+++ cfe/trunk/test/SemaCXX/sourceranges.cpp Mon Nov 22 04:30:56 2010
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -ast-dump %s | FileCheck %s
+
+template<class T>
+class P {
+ public:
+ P(T* t) {}
+};
+
+namespace foo {
+class A {};
+enum B {};
+typedef int C;
+}
+
+int main() {
+ // CHECK: CXXNewExpr {{0x[0-9a-fA-F]+}} <col:19, col:28> 'foo::class A *'
+ P<foo::A> p14 = new foo::A;
+ // CHECK: CXXNewExpr {{0x[0-9a-fA-F]+}} <col:19, col:28> 'foo::enum B *'
+ P<foo::B> p24 = new foo::B;
+ // CHECK: CXXNewExpr {{0x[0-9a-fA-F]+}} <col:19, col:28> 'foo::C *'
+ P<foo::C> pr4 = new foo::C;
+}
More information about the cfe-commits
mailing list