This is an archive of the discontinued LLVM Phabricator instance.

[clang] Fix crash during template sema checking
ClosedPublic

Authored by gchatelet on Mar 20 2020, 8:34 AM.

Details

Summary

If the size parameter of __builtin_memcpy_inline comes from an un-instantiated template parameter current code would crash.

Diff Detail

Event Timeline

gchatelet created this revision.Mar 20 2020, 8:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 20 2020, 8:34 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
courbet added inline comments.Mar 20 2020, 8:43 AM
clang/lib/Sema/SemaChecking.cpp
1655

Are the first two necessary ? IIRC only EvaluateKnownConstInt() does not like template-dependent stuff.

gchatelet updated this revision to Diff 251671.Mar 20 2020, 9:17 AM
gchatelet marked an inline comment as done.

Address comments

clang/lib/Sema/SemaChecking.cpp
1655

That's right I don't think it's realistic to pass the pointers as template parameters so whatever CheckNonNullArgument is doing it will probably never end up crashing in the same way.

I'll limit the fix to SizeOp then.

Please post patches against master, not previous versions of the patch.

I think you want to check isValueDependent(); isInstantiationDependent() includes some other stuff that isn't relevant here.

gchatelet updated this revision to Diff 251780.Mar 20 2020, 3:01 PM

Address comments

efriedma accepted this revision.Mar 20 2020, 3:28 PM

LGTM

clang/lib/Sema/SemaChecking.cpp
1655

"<<"?

This revision is now accepted and ready to land.Mar 20 2020, 3:28 PM
This revision was automatically updated to reflect the committed changes.