This is an archive of the discontinued LLVM Phabricator instance.

Lexer: Update the Lexer to use MemoryBufferRef, NFC
ClosedPublic

Authored by dexonsmith on Oct 14 2020, 8:41 AM.

Details

Summary

Update Lexer / Lexer::Lexer to use MemoryBufferRef instead of
MemoryBuffer*. Callers that were acquiring a MemoryBuffer* via
SourceManager::getBuffer were updated, such that if they checked
Invalid they use getBufferOrNone and otherwise getBufferOrFake.

Diff Detail

Event Timeline

dexonsmith created this revision.Oct 14 2020, 8:41 AM
JDevlieghere added inline comments.Oct 19 2020, 12:19 PM
clang/include/clang/Lex/Lexer.h
145

Should MemoryBufferRefs be passed by value like StringRefs?

dexonsmith added inline comments.Oct 19 2020, 2:39 PM
clang/include/clang/Lex/Lexer.h
145

I don't think it absolutely needs to be, but it could, it's just two StringRefs. Passing by reference here prevents adding an include unnecessarily.

dexonsmith added inline comments.Oct 19 2020, 3:02 PM
clang/include/clang/Lex/Lexer.h
145

That said, I don't feel strongly, happy to change to by-value if you think that's better.

JDevlieghere accepted this revision.Oct 19 2020, 3:16 PM

LGTM

clang/include/clang/Lex/Lexer.h
145

Thanks! I was mostly asking from a "policy" perspective, but avoiding an include seems as good of a motivation as any.

This revision is now accepted and ready to land.Oct 19 2020, 3:16 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptOct 19 2020, 4:10 PM