This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] bugprone-argument-comment: SourceLocation valid judgment avoid emitting coredump in isInSystemHeader
ClosedPublic

Authored by Sockke on Oct 12 2021, 2:41 AM.

Details

Summary

If the Node has an invalid location, it will trigger assert in isInSystemHeader(...).

void test() {
  __builtin_va_list __args;
  // __builtin_va_list has no defination in any source file and its CXXConstructorDecl has invalid sourcelocation
}

coredump with "Assertion `Loc.isValid() && "Can't get file characteristic of invalid loc!"' failed." in getFileCharacteristic(SourceLocation)

Diff Detail

Event Timeline

Sockke created this revision.Oct 12 2021, 2:41 AM
Sockke requested review of this revision.Oct 12 2021, 2:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 12 2021, 2:41 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Can you add a test case that shows we've fixed the issue? (Note, you cannot include iostream directly in a test because that will use the platform STL and we want our tests to have consistent behavior regardless of platform.)

MTC added a subscriber: MTC.Oct 13 2021, 1:15 AM
Sockke updated this revision to Diff 379296.Oct 13 2021, 1:18 AM
Sockke edited the summary of this revision. (Show Details)
Sockke added a reviewer: MTC.

Update!

aaron.ballman accepted this revision.Oct 13 2021, 4:40 AM

LGTM, thank you! Do you need me to commit on your behalf? I'm happy to do so, but given the number of quality submissions you've had, I'm wondering if you'd like to obtain commit access of your own? (https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access has the details of what that entails.)

This revision is now accepted and ready to land.Oct 13 2021, 4:40 AM

LGTM, thank you! Do you need me to commit on your behalf? I'm happy to do so, but given the number of quality submissions you've had, I'm wondering if you'd like to obtain commit access of your own? (https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access has the details of what that entails.)

Thanks a lot! It's my pleasure to obtain commit access of my own. I will send the application as required later. Before that, I would appreciate it if you could commit it on my behalf. Thanks again!
Name: liuke
Email: liuke.gehry@bytedance.com

aaron.ballman closed this revision.Oct 13 2021, 9:31 AM

LGTM, thank you! Do you need me to commit on your behalf? I'm happy to do so, but given the number of quality submissions you've had, I'm wondering if you'd like to obtain commit access of your own? (https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access has the details of what that entails.)

Thanks a lot! It's my pleasure to obtain commit access of my own. I will send the application as required later. Before that, I would appreciate it if you could commit it on my behalf. Thanks again!
Name: liuke
Email: liuke.gehry@bytedance.com

Sounds great! I've commit on your behalf in ea72b55b5c7c281cb21bb7bd50e6e039ca63dfe8, thank you for the fix!