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....

April 22, 2018

Finding Reviewers for Your Patch

Finding the right people to review your patch can be tough. I see the question “who should I add as reviewer for this patch?” popping up on IRC quite regularly and not something I’m unfamiliar with myself. Not every project has a list of code owners and as soon as your change spans multiple components things might get tricky. Preferable you want reviewers that know the code you’ve changed. If the project is using git you can use git blame to find out for each individual line of a file, who changed it last....

December 16, 2017

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....

August 8, 2017

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....

April 17, 2017

One Year At GuardSquare

Today marks my one year anniversary at GuardSquare. On the one hand it feels like yesterday (as cliché as that might sound) but on the other hand it feels like ages ago, considering how much we have been able to do in just one year’s time. For those that don’t know GuardSquare yet, allow me to quickly introduce our company. If you have ever used Java, you probably know ProGuard, our open source optimizer for Java bytecode....

March 7, 2017

Building a Workstation

January 2017 marks the sixth birthday of my desktop computer. When I purchased my trusty Intel Core i5-2500K, I would’ve never guessed that I’d use it for that long. However, rather than jumping to the recently released Kaby Lake CPUs, I’m building my new workstation around two Intel Xeon E5-2670s. Why Xeon? There’s several reasons I went with a dual Xeon setup rather than a flagship i5 or i7. The first reason is that I’m not building a gaming rig but a workstation....

January 13, 2017

Escape Analysis & Capture Tracking in LLVM

Pointer analysis is an important topic in compiler optimization. One interesting aspect is the dynamic scope of pointers. LLVM differentiates between two situations: Pointer Capture: A pointer value is captured if the function makes a copy of any part of the pointer that outlives the call. Pointer Escape: A pointer value escapes if it is is accessible from outside the current function or thread. The latter case is sometimes considered separate and called thread-escape....

January 8, 2017

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....

January 4, 2017

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. 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....

November 21, 2016

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....

October 13, 2016