This is an archive of the discontinued LLVM Phabricator instance.

[libc] add internal string class
ClosedPublic

Authored by michaelrj on Jan 6 2023, 3:04 PM.

Details

Summary

The scanf implementation needs a dynamically resizing string class. This
patch adds a minimal version of that class along with tests to check the
current functionality.

Diff Detail

Event Timeline

michaelrj created this revision.Jan 6 2023, 3:04 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJan 6 2023, 3:04 PM
michaelrj requested review of this revision.Jan 6 2023, 3:04 PM
sivachandra added inline comments.Jan 6 2023, 3:26 PM
libc/src/__support/CPP/vector_string.h
24 ↗(On Diff #486995)

Shouldn't this be named string?

michaelrj added inline comments.Jan 6 2023, 4:14 PM
libc/src/__support/CPP/vector_string.h
24 ↗(On Diff #486995)

I talked about it in my comment on the patch this was split out of but basically it has some differences from std::string that might warrant a different name.

sivachandra added inline comments.Jan 6 2023, 4:28 PM
libc/src/__support/CPP/vector_string.h
24 ↗(On Diff #486995)

Ah, sorry! I did not look at that patch yet.

Going by your explanation, what you have done previously is correct - Keep is scanf specific as we cannot add non-standard API in the CPP directory. Instead of VectorString, may be call it CharVector.

michaelrj added inline comments.Jan 18 2023, 2:28 PM
libc/src/__support/CPP/vector_string.h
24 ↗(On Diff #486995)

If we do want it to be CharVector it might be better as a general utility in the __support directory since I could see other functions using it. Additionally that makes the unit testing easier.

sivachandra added inline comments.Jan 18 2023, 2:32 PM
libc/src/__support/CPP/vector_string.h
24 ↗(On Diff #486995)

SGTM

michaelrj updated this revision to Diff 490300.Jan 18 2023, 2:41 PM

rename to CharVector and move it out of the CPP directory.

michaelrj updated this revision to Diff 490310.Jan 18 2023, 3:04 PM

move CharVector out of cpp namespace

sivachandra accepted this revision.Jan 19 2023, 12:14 AM
This revision is now accepted and ready to land.Jan 19 2023, 12:14 AM
This revision was automatically updated to reflect the committed changes.