1/****************************************************************************
2 * Copyright (C) 2012-2016 Woboq GmbH
3 * Olivier Goffart <contact at woboq.com>
4 * https://woboq.com/codebrowser.html
5 *
6 * This file is part of the Woboq Code Browser.
7 *
8 * Commercial License Usage:
9 * Licensees holding valid commercial licenses provided by Woboq may use
10 * this file in accordance with the terms contained in a written agreement
11 * between the licensee and Woboq.
12 * For further information see https://woboq.com/codebrowser.html
13 *
14 * Alternatively, this work may be used under a Creative Commons
15 * Attribution-NonCommercial-ShareAlike 3.0 (CC-BY-NC-SA 3.0) License.
16 * http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US
17 * This license does not allow you to use the code browser to assist the
18 * development of your commercial software. If you intent to do so, consider
19 * purchasing a commercial licence.
20 ****************************************************************************/
21
22#pragma once
23
24#include <memory>
25
26// clang 3.6 uses unique_ptr in many places that was not using it before
27template<typename T>
28struct MaybeUnique
29{
30 T *val;
31 operator T *()
32 {
33 return val;
34 }
35 template<typename X>
36 operator std::unique_ptr<X>() &&
37 {
38 return std::unique_ptr<X>(val);
39 }
40};
41template<typename T>
42MaybeUnique<T> maybe_unique(T *val)
43{
44 return { val };
45}
46
47#ifndef LLVM_FALLTHROUGH
48#define LLVM_FALLTHROUGH
49#endif
50

source code of codebrowser/generator/compat.h