mirror of https://github.com/microsoft/clang.git
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
This commit is contained in:
parent
46da5bf4f2
commit
5f97f24294
|
@ -7,21 +7,17 @@ def NamedGroup : DiagGroup<"name">;
|
|||
|
||||
|
||||
def InNamedGroup : Warning<"">, InGroup<DiagGroup<"name">>;
|
||||
// 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<DiagGroup<"name">>;}}
|
||||
// CHECK-NEXT: {{^ ~~~~~~~~\^~~~~~~~~~~~~~~~~~}}
|
||||
// CHECK-NEXT: {{^ InGroup<NamedGroup>}}
|
||||
// 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<NamedGroup>}}
|
||||
// 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<DiagGroup<"anonymous">>;
|
|||
def AnonymousGroupAgain : Warning<"">,
|
||||
InGroup<DiagGroup<"anonymous">>;
|
||||
|
||||
// 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<DiagGroup<"anonymous">>;}}
|
||||
// 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<DiagGroup<"anonymous">>;}}
|
||||
// CHECK-NEXT: {{^ ~~~~~~~~\^~~~~~~~~~~~~~~~~~~~~~~}}
|
||||
// CHECK-NEXT: anonymous-groups.td:[[@LINE-8]]:11: note: also referenced here
|
||||
// CHECK-NEXT: {{^ InGroup<DiagGroup<"anonymous">>;}}
|
||||
// CHECK-NEXT: {{^ ~~~~~~~~\^~~~~~~~~~~~~~~~~~~~~~~}}
|
||||
// CHECK: anonymous-groups.td:[[@LINE-7]]:1: note: also referenced here
|
||||
|
|
|
@ -4,38 +4,22 @@ include "DiagnosticBase.inc"
|
|||
def NamedGroup : DiagGroup<"name">;
|
||||
|
||||
def InNamedGroup : Warning<"">, InGroup<DiagGroup<"name">>;
|
||||
// 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<DiagGroup<"name">>;}}
|
||||
// CHECK-NEXT: {{^ ~~~~~~~~\^~~~~~~~~~~~~~~~~~}}
|
||||
// CHECK-NEXT: {{^ InGroup<NamedGroup>}}
|
||||
|
||||
def Wrapped : Warning<"">, InGroup<DiagGroup<
|
||||
"name">>;
|
||||
// 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<DiagGroup<}}
|
||||
// CHECK-NEXT: {{^ ~~~~~~~~\^~~~~~~~~~}}
|
||||
// CHECK-NEXT: {{^ InGroup<NamedGroup>}}
|
||||
|
||||
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<NamedGroup>}}
|
||||
|
||||
// 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<NamedGrop>}}
|
||||
// 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<DiagGroup<"name">>;
|
||||
// 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<DiagGroup<"name">>;
|
||||
// CHECK-NEXT: note:
|
||||
|
|
|
@ -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<std::pair<Record *, SMRange>> Supers = R->getSuperClasses();
|
||||
auto I = std::find_if(Supers.begin(), Supers.end(),
|
||||
[&](const std::pair<Record *, SMRange> &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<Record*> &Diags,
|
||||
|
@ -236,22 +227,10 @@ static void groupDiagnostics(const std::vector<Record*> &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<SMFixIt>());
|
||||
"' 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<Record*> &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<DefInit>((*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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue