Hi rsmith,
When adding the implicit compound statement (required for Codegen?), the end
location was previously overridden by the start location, probably based on the
assumptions:
- The location of the implicit compound statement should be the destructor's
location
- The compound statement if present is always the last element of a FunctionDecl
This patch changes the location of the compound statement to the destructor's
end location, but I am open to other suggestions.
http://reviews.llvm.org/D4175
Files:
lib/Sema/SemaDeclCXX.cpp
test/Misc/ast-dump-decl.cpp
Index: lib/Sema/SemaDeclCXX.cpp
===================================================================
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -8880,7 +8880,7 @@
return;
}
- SourceLocation Loc = Destructor->getLocation();
+ SourceLocation Loc = Destructor->getLocEnd();
Destructor->setBody(new (Context) CompoundStmt(Loc));
Destructor->markUsed(Context);
MarkVTableUsed(CurrentLocation, ClassDecl);
Index: test/Misc/ast-dump-decl.cpp
===================================================================
--- test/Misc/ast-dump-decl.cpp
+++ test/Misc/ast-dump-decl.cpp
@@ -133,6 +133,18 @@
// CHECK: CXXDestructorDecl{{.*}} ~TestCXXDestructorDecl 'void (void)
noexcept'
// CHECK-NEXT: CompoundStmt
+// Test that the range of a defaulted destructor is computed correctly.
+// FIXME: This should include the "= default".
+class Base {
+public:
+ virtual ~Base() {}
+};
+class TestDerived : public Base {
+ TestDerived() {}
+ ~TestDerived() = default;
+};
+// CHECK: CXXDestructorDecl{{.*}} <line:{{.*}}:3, col:16>
+
class TestCXXConversionDecl {
operator int() { return 0; }
};
Index: lib/Sema/SemaDeclCXX.cpp
===================================================================
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -8880,7 +8880,7 @@
return;
}
- SourceLocation Loc = Destructor->getLocation();
+ SourceLocation Loc = Destructor->getLocEnd();
Destructor->setBody(new (Context) CompoundStmt(Loc));
Destructor->markUsed(Context);
MarkVTableUsed(CurrentLocation, ClassDecl);
Index: test/Misc/ast-dump-decl.cpp
===================================================================
--- test/Misc/ast-dump-decl.cpp
+++ test/Misc/ast-dump-decl.cpp
@@ -133,6 +133,18 @@
// CHECK: CXXDestructorDecl{{.*}} ~TestCXXDestructorDecl 'void (void) noexcept'
// CHECK-NEXT: CompoundStmt
+// Test that the range of a defaulted destructor is computed correctly.
+// FIXME: This should include the "= default".
+class Base {
+public:
+ virtual ~Base() {}
+};
+class TestDerived : public Base {
+ TestDerived() {}
+ ~TestDerived() = default;
+};
+// CHECK: CXXDestructorDecl{{.*}} <line:{{.*}}:3, col:16>
+
class TestCXXConversionDecl {
operator int() { return 0; }
};
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits