Skip to content

Fix build with Clang 12

Christian Schärf requested to merge christianschaerf/clazy:fix_llvm12 into master

The clang::SourceManager::getBuffer was replaced in Clang revision d758f79e5d381bd4f5122193a9538d89c907c812 with optional semantics. Further, in revision b3eff6b7bb31e7ef059a3d238de138849839fbbd, the clang::Lexer constructor was updated to take a llvm::MemoryBufferRef instead of a llvm::MemoryBuffer*.

I must admit that I am not entirely happy with this patch. The reason it turned out somewhat clunky is that llvm::Optional<llvm::MemoryBufferRef> is dereferenced when being passed to the clang::Lexer constructor, whereas llvm::MemoryBuffer* is not. On the other hand, I do not think it is possible to dereference the optional inside clazy::getBuffer, even if the result is never actually used. So, if anyone has a better idea, I would be glad to adopt it.

Note that the patch is untested except for compilation.

Merge request reports