Revert "[AST] Add RParen loc for decltype AutoTypeloc."
authorHaojian Wu <hokein.wu@gmail.com>
Mon, 10 Jan 2022 14:09:17 +0000 (15:09 +0100)
committerHaojian Wu <hokein.wu@gmail.com>
Mon, 10 Jan 2022 14:18:41 +0000 (15:18 +0100)
This breaks a clang-tidy check, needs to investigate and fix. Revert
them to bring the buildbot back.

This reverts commit 55d96ac3dc56bdebea854952a724c2a50d96ce19 and
37ec65e1d705f56fe5551de1dfcbac1e071588a2

clang-tools-extra/clangd/unittests/SelectionTests.cpp
clang/include/clang/AST/TypeLoc.h
clang/lib/AST/TypeLoc.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/AST/ast-dump-template-decls-json.cpp
clang/test/AST/ast-dump-template-decls.cpp
clang/unittests/AST/SourceLocationTest.cpp

index 0f44641..7e19f07 100644 (file)
@@ -391,8 +391,6 @@ TEST(SelectionTest, CommonAncestor) {
         )cpp",
           "DeclRefExpr"},
       {"[[decltype^(1)]] b;", "DecltypeTypeLoc"}, // Not the VarDecl.
-      // decltype(auto) is an AutoTypeLoc!
-      {"[[de^cltype(a^uto)]] a = 1;", "AutoTypeLoc"},
 
       // Objective-C nullability attributes.
       {
index 9c7ab4e..9a43d34 100644 (file)
@@ -2081,9 +2081,6 @@ struct AutoTypeLocInfo : TypeSpecLocInfo {
   NamedDecl *FoundDecl;
   SourceLocation LAngleLoc;
   SourceLocation RAngleLoc;
-
-  // For decltype(auto).
-  SourceLocation RParenLoc;
 };
 
 class AutoTypeLoc
@@ -2096,10 +2093,6 @@ public:
     return getTypePtr()->getKeyword();
   }
 
-  bool isDecltypeAuto() const { return getTypePtr()->isDecltypeAuto(); }
-  SourceLocation getRParenLoc() const { return getLocalData()->RParenLoc; }
-  void setRParenLoc(SourceLocation Loc) { getLocalData()->RParenLoc = Loc; }
-
   bool isConstrained() const {
     return getTypePtr()->isConstrained();
   }
@@ -2180,13 +2173,16 @@ public:
   }
 
   SourceRange getLocalSourceRange() const {
-    return {isConstrained()
-                ? (getNestedNameSpecifierLoc()
-                       ? getNestedNameSpecifierLoc().getBeginLoc()
-                       : (getTemplateKWLoc().isValid() ? getTemplateKWLoc()
-                                                       : getConceptNameLoc()))
-                : getNameLoc(),
-            isDecltypeAuto() ? getRParenLoc() : getNameLoc()};
+    return{
+        isConstrained()
+          ? (getNestedNameSpecifierLoc()
+               ? getNestedNameSpecifierLoc().getBeginLoc()
+               : (getTemplateKWLoc().isValid()
+                  ? getTemplateKWLoc()
+                  : getConceptNameLoc()))
+          : getNameLoc(),
+        getNameLoc()
+    };
   }
 
   void copy(AutoTypeLoc Loc) {
index 13aa54c..c3ed08d 100644 (file)
@@ -622,7 +622,6 @@ void AutoTypeLoc::initializeLocal(ASTContext &Context, SourceLocation Loc) {
   setFoundDecl(nullptr);
   setRAngleLoc(Loc);
   setLAngleLoc(Loc);
-  setRParenLoc(Loc);
   TemplateSpecializationTypeLoc::initializeArgLocs(Context, getNumArgs(),
                                                    getTypePtr()->getArgs(),
                                                    getArgInfos(), Loc);
index 959f490..f0bbbcf 100644 (file)
@@ -22,7 +22,6 @@
 #include "clang/AST/TypeLoc.h"
 #include "clang/AST/TypeLocVisitor.h"
 #include "clang/Basic/PartialDiagnostic.h"
-#include "clang/Basic/Specifiers.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/DeclSpec.h"
@@ -6042,8 +6041,6 @@ namespace {
              DS.getTypeSpecType() == TST_auto_type ||
              DS.getTypeSpecType() == TST_unspecified);
       TL.setNameLoc(DS.getTypeSpecTypeLoc());
-      if (DS.getTypeSpecType() == TST_decltype_auto)
-        TL.setRParenLoc(DS.getTypeofParensRange().getEnd());
       if (!DS.isConstrainedAuto())
         return;
       TemplateIdAnnotation *TemplateId = DS.getRepAsTemplateId();
index 9056f00..b8ec5b2 100644 (file)
@@ -6652,8 +6652,6 @@ void TypeLocReader::VisitAutoTypeLoc(AutoTypeLoc TL) {
       TL.setArgLocInfo(i, Reader.readTemplateArgumentLocInfo(
                               TL.getTypePtr()->getArg(i).getKind()));
   }
-  if (Reader.readBool())
-    TL.setRParenLoc(readSourceLocation());
 }
 
 void TypeLocReader::VisitDeducedTemplateSpecializationTypeLoc(
index c2bee93..40772bb 100644 (file)
@@ -452,9 +452,6 @@ void TypeLocWriter::VisitAutoTypeLoc(AutoTypeLoc TL) {
       Record.AddTemplateArgumentLocInfo(TL.getTypePtr()->getArg(I).getKind(),
                                         TL.getArgLocInfo(I));
   }
-  Record.push_back(TL.isDecltypeAuto());
-  if (TL.isDecltypeAuto())
-    Record.AddSourceLocation(TL.getRParenLoc());
 }
 
 void TypeLocWriter::VisitDeducedTemplateSpecializationTypeLoc(
index 5fc466b..fc1b883 100644 (file)
@@ -2130,9 +2130,9 @@ void i();
 // CHECK-NEXT:        "tokLen": 8
 // CHECK-NEXT:       },
 // CHECK-NEXT:       "end": {
-// CHECK-NEXT:        "offset": 718,
-// CHECK-NEXT:        "col": 24,
-// CHECK-NEXT:        "tokLen": 1
+// CHECK-NEXT:        "offset": 705,
+// CHECK-NEXT:        "col": 11,
+// CHECK-NEXT:        "tokLen": 8
 // CHECK-NEXT:       }
 // CHECK-NEXT:      },
 // CHECK-NEXT:      "type": {
index 51ec673..e58731a 100644 (file)
@@ -90,7 +90,7 @@ struct T {};
 
 template <decltype(auto)>
 // CHECK: ClassTemplateDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+2]]:11> col:8 U
-// CHECK-NEXT: NonTypeTemplateParmDecl 0x{{[^ ]*}} <line:[[@LINE-2]]:11, col:24> col:25 'decltype(auto)' depth 0 index 0
+// CHECK-NEXT: NonTypeTemplateParmDecl 0x{{[^ ]*}} <line:[[@LINE-2]]:11> col:25 'decltype(auto)' depth 0 index 0
 struct U {};
 
 template <typename Ty>
index 85f43ad..832d375 100644 (file)
@@ -242,13 +242,6 @@ TEST(TypeLoc, DecltypeTypeLocRange) {
   verify(Target2->getSourceRange(), Code.range("full2"));
 }
 
-TEST(TypeLoc, AutoTypeLocRange) {
-  RangeVerifier<TypeLoc> Verifier;
-  Verifier.expectRange(1, 1, 1, 14);
-  EXPECT_TRUE(Verifier.match("decltype(auto) a = 1;", typeLoc(loc(autoType())),
-                             Lang_CXX11));
-}
-
 TEST(TypeLoc, LongDoubleRange) {
   RangeVerifier<TypeLoc> Verifier;
   Verifier.expectRange(1, 1, 1, 6);