[PATCH] Fix source range of defaulted/deleted member declarations

Reid Kleckner rnk at google.com
Mon Mar 23 10:51:13 PDT 2015


================
Comment at: lib/Parse/ParseCXXInlineMethods.cpp:73
@@ -72,3 +72,3 @@
     bool Delete = false;
     SourceLocation KWLoc;
     if (TryConsumeToken(tok::kw_delete, KWLoc)) {
----------------
Any reason we can't save Tok.getEndLoc() here? Then we don't have to hardcode the lengths of delete and default.

================
Comment at: lib/Parse/ParseCXXInlineMethods.cpp:80
@@ -79,1 +79,3 @@
       Delete = true;
+      if (auto *DeclAsFunction = dyn_cast<FunctionDecl>(FnD)) {
+        // The end of this decl has to point to the end of the 'delete' keyword
----------------
This doesn't do the right thing for function templates, which the only case where this dyn_cast can fail. I think you can write a templated constructor and default it. =P A robust way to do this might be:
  auto *FD = dyn_cast<FunctionDecl>(FnD);
  FD = FD ? FD : cast<FunctionTemplateDecl>(FnD)->getTemplatedDecl();
  FD->setRangeEnd(KWEndLoc);

http://reviews.llvm.org/D8465

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list