Using LSP & clangd in Vim

After having used YouCompleteMe, I finally decided to give one of the Language Server Protocol (LSP) implementations a spin. As an LLVM developer I’ve been following clangd’s development and wanted to try it out. At the time of writing, several LSP implementations exist for Vim: LanguageClient-neovim vim-lsc vim-lsp Setting up vim-lsp I decided to go with vim-lsp because it’s asyncronous, written in vimscript and easy to setup. The plugin has a single dependency: async....

<span title='2018-04-22 09:00:00 +0000 UTC'>April 22, 2018</span>

Reference Counting PIMPL Idiom

The pointer to implementation or PIMPL idiom is a popular C++ idiom for decoupling the representation and implementation of a class. It reduces compilation times and enables a stable API while allowing the internals to change. Reference counting is another ubiquitous programming technique, used to manage an object’s lifetime by keeping track of the number of references held to it. C++’s std::shared_ptr uses this technique to provide shared ownership of an object through a pointer....

<span title='2017-08-08 18:00:00 +0000 UTC'>August 8, 2017</span>

Exposing Containers of Unique Pointers

The std::unique_ptr is probably one of my favorite and most used features in modern C++. The unique pointer is as powerful as it is simple, and assuming you’ve used it before, you surely know how awesome it is. There are many great articles written about unique pointers, so I won’t go into detail. What I will mention though is that unique pointers provide ownership semantics. What this means is that the unique pointer follows a well defined set of rules regarding the lifetime of its allocated resource....

<span title='2017-04-17 10:00:00 +0000 UTC'>April 17, 2017</span>

Order Your Members

The C++ standard guarantees that the members of a class or struct appear in memory in the same order as they are declared. Nonstatic data members of a (non-union) class with the same access control are allocated so that later members have higher addresses within a class object. The order of allocation of non-static data members with different access control is unspecified. Implementation alignment requirements might cause two adjacent members not to be allocated immediately after each other; so might requirements for space for managing virtual functions and virtual base classes....

<span title='2017-01-04 21:00:00 +0000 UTC'>January 4, 2017</span>

Guaranteed Copy Elision

The new C++17 standard brings many exciting new features. A smaller, more subtle improvement it brings is guaranteed copy elision. The keyword is guaranteed, as copy elision itself has always been part of the standard. Although it might not be a change as radical as, say, structured bindings, I’m very happy to see it made it into the standard. Table of Content Copy Elision Return Value Optimization Passing a Temporary by Value Throwing and Catching Exceptions by Value Guaranteed Copy Elision Value Categories Addendum: Translation Units Addendum: Copy-List-Initialization Copy Elision Before discussing what changed in the latest version of the standard, it might be useful to revisit the basics of copy elision as they are currently defined by the C++14 standard....

<span title='2016-11-21 21:00:00 +0000 UTC'>November 21, 2016</span>

LibEBC & ebcutil

In a previous blog post I wrote about bitcode. Embedding it was already possible for quite some time with Apple’s fork of LLVM that ships with Xcode. Recently, Apple upstreamed (parts of) their implementation making it possible to do the same with the open source clang compiler. However, there are some differences between the two implementations. Bitcode embedded with Apple’s version of clang is bundled into a xar-archive. Metadata such as compiler commands used to create the binary and dylibs which the code linked against, are kept in the archive’s table of content....

<span title='2016-10-13 21:34:44 +0000 UTC'>October 13, 2016</span>

Understanding the Clang AST

Clang is everywhere; It is the core of my favorite Vim plugin YouCompleteMe, it recently got supported by Microsoft Visual Studio, it is mentioned in numerous episodes of CppCast and it powers the excellent clang formatter. Naturally, I wanted to get a better understanding of how the clang front end works under the hood. Table of Content Clang Front End & AST ASTContext Classes Navigating Sources AST Traversal Recursive AST Visitor AST Matchers Cursors Building the Examples Conclusion Related Clang Front End & AST Clang is a C language family front end for LLVM....

<span title='2015-12-31 11:08:16 +0000 UTC'>December 31, 2015</span>

A better YouCompleteMe Config

If you’re like me and have (1) been using Vim for a while and (2) have been programming in C++, you’ve likely heard about YouCompleteMe. YCM is an awesome auto-completion engine for Vim. For C++ and other C-based languages it uses the libclang under the hood, but it integrates with other engines as well to support C#, Python and Go to name a few. If you’re not yet convinced, check out the author’s website and this blog post....

<span title='2015-07-26 15:45:00 +0000 UTC'>July 26, 2015</span>