From: Nicolai Haehnle Date: Tue, 6 Mar 2018 17:55:00 +0000 (+0000) Subject: TableGen: Give up on exact fixits for diagnostic groups X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5f97f24294a46877795d69580bb5ac560c9b1f9e;p=clang TableGen: Give up on exact fixits for diagnostic groups With recent changes in the TableGen frontend, we no longer have usable location information for anonymous defs. Fixes test breakage caused by r326788. The normal, non-error TableGen output is not affected by this change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326822 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/TableGen/anonymous-groups.td b/test/TableGen/anonymous-groups.td index acc0a211b6..9e8dc398bb 100644 --- a/test/TableGen/anonymous-groups.td +++ b/test/TableGen/anonymous-groups.td @@ -7,21 +7,17 @@ def NamedGroup : DiagGroup<"name">; def InNamedGroup : Warning<"">, InGroup>; -// CHECK: anonymous-groups.td:[[@LINE-1]]:41: error: group 'name' is referred to anonymously +// CHECK: anonymous-groups.td:[[@LINE-1]]:1: error: group 'name' is referred to anonymously // CHECK-NEXT: {{^def InNamedGroup : Warning<"">, InGroup>;}} -// CHECK-NEXT: {{^ ~~~~~~~~\^~~~~~~~~~~~~~~~~~}} -// CHECK-NEXT: {{^ InGroup}} -// CHECK-NEXT: anonymous-groups.td:6:1: note: group defined here +// CHECK: anonymous-groups.td:6:1: note: group defined here // CHECK-NEXT: def NamedGroup : DiagGroup<"name">; // CHECK-NEXT: ^ def AlsoInNamedGroup : Warning<"">, InGroup < DiagGroup<"name"> >; -// CHECK: anonymous-groups.td:[[@LINE-1]]:48: error: group 'name' is referred to anonymously +// CHECK: anonymous-groups.td:[[@LINE-1]]:1: error: group 'name' is referred to anonymously // CHECK-NEXT: {{^def AlsoInNamedGroup : Warning<"">, InGroup < DiagGroup<"name"> >;}} -// CHECK-NEXT: {{^ ~~~~~~~~~~~\^~~~~~~~~~~~~~~~~~~}} -// CHECK-NEXT: {{^ InGroup}} -// CHECK-NEXT: anonymous-groups.td:6:1: note: group defined here +// CHECK: anonymous-groups.td:6:1: note: group defined here // CHECK-NEXT: def NamedGroup : DiagGroup<"name">; // CHECK-NEXT: ^ @@ -31,12 +27,8 @@ def AlsoAnonymousGroup : Warning<"">, InGroup>; def AnonymousGroupAgain : Warning<"">, InGroup>; -// CHECK: anonymous-groups.td:[[@LINE-5]]:43: error: group 'anonymous' is referred to anonymously +// CHECK: anonymous-groups.td:[[@LINE-5]]:1: error: group 'anonymous' is referred to anonymously // CHECK-NEXT: {{^def AnonymousGroup : Warning<"">, InGroup>;}} -// CHECK-NEXT: {{^ ~~~~~~~~\^~~~~~~~~~~~~~~~~~~~~~~}} -// CHECK-NEXT: anonymous-groups.td:[[@LINE-7]]:47: note: also referenced here +// CHECK: anonymous-groups.td:[[@LINE-6]]:1: note: also referenced here // CHECK-NEXT: {{^def AlsoAnonymousGroup : Warning<"">, InGroup>;}} -// CHECK-NEXT: {{^ ~~~~~~~~\^~~~~~~~~~~~~~~~~~~~~~~}} -// CHECK-NEXT: anonymous-groups.td:[[@LINE-8]]:11: note: also referenced here -// CHECK-NEXT: {{^ InGroup>;}} -// CHECK-NEXT: {{^ ~~~~~~~~\^~~~~~~~~~~~~~~~~~~~~~~}} +// CHECK: anonymous-groups.td:[[@LINE-7]]:1: note: also referenced here diff --git a/test/TableGen/tg-fixits.td b/test/TableGen/tg-fixits.td index d04a6a67e4..f0f62ef9a4 100644 --- a/test/TableGen/tg-fixits.td +++ b/test/TableGen/tg-fixits.td @@ -4,38 +4,22 @@ include "DiagnosticBase.inc" def NamedGroup : DiagGroup<"name">; def InNamedGroup : Warning<"">, InGroup>; -// CHECK: tg-fixits.td:[[@LINE-1]]:41: error: group 'name' is referred to anonymously +// CHECK: tg-fixits.td:[[@LINE-1]]:1: error: group 'name' is referred to anonymously // CHECK-NEXT: {{^def InNamedGroup : Warning<"">, InGroup>;}} -// CHECK-NEXT: {{^ ~~~~~~~~\^~~~~~~~~~~~~~~~~~}} -// CHECK-NEXT: {{^ InGroup}} def Wrapped : Warning<"">, InGroup>; -// CHECK: tg-fixits.td:[[@LINE-2]]:36: error: group 'name' is referred to anonymously +// CHECK: tg-fixits.td:[[@LINE-2]]:1: error: group 'name' is referred to anonymously // CHECK-NEXT: {{^def Wrapped : Warning<"">, InGroup}} def AlsoWrapped : Warning<"">, InGroup< DiagGroup<"name">>; -// CHECK: tg-fixits.td:[[@LINE-1]]:3: error: group 'name' is referred to anonymously -// CHECK-NEXT: {{^ DiagGroup<"name">>;}} -// CHECK-NEXT: {{^~~\^~~~~~~~~~~~~~~~~~}} -// CHECK-NEXT: {{^InGroup}} - -// The following lines contain hard tabs (\t); do not change this! -def HardTabs : Warning<"">, - InGroup< DiagGroup<"name"> >; -// CHECK: tg-fixits.td:[[@LINE-1]]:11: error: group 'name' is referred to anonymously -// CHECK-NEXT: {{^ InGroup< DiagGroup<"name"> >;}} -// CHECK-NEXT: {{^ ~~~~~~~~~~~~~~~~\^~~~~~~~~~~~~~~~~~~~~~~~~}} -// CHECK-NEXT: {{^ InGroup}} +// CHECK: tg-fixits.td:[[@LINE-2]]:1: error: group 'name' is referred to anonymously // The following line has Unicode characters in it; do not change them! // FIXME: For now, we just give up on printing carets/ranges/fixits for // lines with Unicode in them, because SMDiagnostic don't keep a byte<->column // map around to line things up like Clang does. def Unicode : Warning<"ユニコード">, InGroup>; -// CHECK: tg-fixits.td:[[@LINE-1]]:51: error: group 'name' is referred to anonymously +// CHECK: tg-fixits.td:[[@LINE-1]]:1: error: group 'name' is referred to anonymously // CHECK-NEXT: def Unicode : Warning<"{{[^"]+}}">, InGroup>; -// CHECK-NEXT: note: diff --git a/utils/TableGen/ClangDiagnosticsEmitter.cpp b/utils/TableGen/ClangDiagnosticsEmitter.cpp index d9d99e0bb0..4a2516ff94 100644 --- a/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -154,15 +154,6 @@ static bool beforeThanCompareGroups(const GroupInfo *LHS, const GroupInfo *RHS){ RHS->DiagsInGroup.front()); } -static SMRange findSuperClassRange(const Record *R, StringRef SuperName) { - ArrayRef> Supers = R->getSuperClasses(); - auto I = std::find_if(Supers.begin(), Supers.end(), - [&](const std::pair &SuperPair) { - return SuperPair.first->getName() == SuperName; - }); - return (I != Supers.end()) ? I->second : SMRange(); -} - /// \brief Invert the 1-[0/1] mapping of diags to group into a one to many /// mapping of groups to diags in the group. static void groupDiagnostics(const std::vector &Diags, @@ -236,22 +227,10 @@ static void groupDiagnostics(const std::vector &Diags, if (NextDiagGroup == (*I)->ExplicitDef) continue; - SMRange InGroupRange = findSuperClassRange(*DI, "InGroup"); - SmallString<64> Replacement; - if (InGroupRange.isValid()) { - Replacement += "InGroup<"; - Replacement += (*I)->ExplicitDef->getName(); - Replacement += ">"; - } - SMFixIt FixIt(InGroupRange, Replacement); - - SrcMgr.PrintMessage(NextDiagGroup->getLoc().front(), + SrcMgr.PrintMessage((*DI)->getLoc().front(), SourceMgr::DK_Error, Twine("group '") + Name + - "' is referred to anonymously", - None, - InGroupRange.isValid() ? FixIt - : ArrayRef()); + "' is referred to anonymously"); SrcMgr.PrintMessage((*I)->ExplicitDef->getLoc().front(), SourceMgr::DK_Note, "group defined here"); } @@ -266,19 +245,14 @@ static void groupDiagnostics(const std::vector &Diags, const Record *NextDiagGroup = GroupInit->getDef(); std::string Name = NextDiagGroup->getValueAsString("GroupName"); - SMRange InGroupRange = findSuperClassRange(*DI, "InGroup"); - SrcMgr.PrintMessage(NextDiagGroup->getLoc().front(), + SrcMgr.PrintMessage((*DI)->getLoc().front(), SourceMgr::DK_Error, Twine("group '") + Name + - "' is referred to anonymously", - InGroupRange); + "' is referred to anonymously"); for (++DI; DI != DE; ++DI) { - GroupInit = cast((*DI)->getValueInit("Group")); - InGroupRange = findSuperClassRange(*DI, "InGroup"); - SrcMgr.PrintMessage(GroupInit->getDef()->getLoc().front(), - SourceMgr::DK_Note, "also referenced here", - InGroupRange); + SrcMgr.PrintMessage((*DI)->getLoc().front(), + SourceMgr::DK_Note, "also referenced here"); } } }