[clang] [clang] AST Visitor: skip empty qualifiers in QualifiedTemplateName (PR #93926)

via cfe-commits cfe-commits at lists.llvm.org
Fri May 31 15:26:18 PDT 2024


Sterling-Augustine wrote:

Even with this fix, I'm seeing a segfault in clang/lib/AST/QualTypeNames.cpp at line 216. 

```
  switch(Scope->getKind()) {
```
Scope is nullptr. The call is from line 70:

```
  QualifiedTemplateName *QTName = TName.getAsQualifiedTemplateName();

  if (QTName && !QTName->hasTemplateKeyword()) {
    NNS = QTName->getQualifier();
    NestedNameSpecifier *QNNS = getFullyQualifiedNestedNameSpecifier(
        Ctx, NNS, WithGlobalNsPrefix);
```

which means that the `QTName->getQualifier()` is returning nullptr where it didn't before. Checking QTName->getQualifier() for nullptr in the conditional (so it can take the else side), everything works. But it seems to me that there is probably a better fix that someone familiar with the code would be able to figure out. I'm not even sure the original is doing the right thing.

I have a fix in testing that adds this check, but if you would double check it after it goes in, that would be helpful.

Unfortunately the failure is in an internal tool, against internal sources, which makes getting a reproducer a long process. I'm also working on that.

https://github.com/llvm/llvm-project/pull/93926


More information about the cfe-commits mailing list