[yaml2obj/obj2yaml] - Add support for .stack_sizes sections.
[llvm-complete.git] / include / llvm / WindowsManifest / WindowsManifestMerger.h
blob935c930ad91da7953f7301eb6ebd8a7c79c411ae
1 //===-- WindowsManifestMerger.h ---------------------------------*- C++-*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===---------------------------------------------------------------------===//
8 //
9 // This file provides a utility for merging Microsoft .manifest files. These
10 // files are xml documents which contain meta-information about applications,
11 // such as whether or not admin access is required, system compatibility,
12 // versions, etc. Part of the linking process of an executable may require
13 // merging several of these .manifest files using a tree-merge following
14 // specific rules. Unfortunately, these rules are not documented well
15 // anywhere. However, a careful investigation of the behavior of the original
16 // Microsoft Manifest Tool (mt.exe) revealed the rules of this merge. As the
17 // saying goes, code is the best documentation, so please look below if you are
18 // interested in the exact merging requirements.
20 // Ref:
21 // https://msdn.microsoft.com/en-us/library/windows/desktop/aa374191(v=vs.85).aspx
23 //===---------------------------------------------------------------------===//
25 #ifndef LLVM_INCLUDE_LLVM_SUPPORT_WINDOWS_MANIFEST_MERGER_H
26 #define LLVM_INCLUDE_LLVM_SUPPORT_WINDOWS_MANIFEST_MERGER_H
28 #include "llvm/Support/Error.h"
30 namespace llvm {
32 class MemoryBuffer;
34 namespace windows_manifest {
36 bool isAvailable();
38 class WindowsManifestError : public ErrorInfo<WindowsManifestError, ECError> {
39 public:
40 static char ID;
41 WindowsManifestError(const Twine &Msg);
42 void log(raw_ostream &OS) const override;
44 private:
45 std::string Msg;
48 class WindowsManifestMerger {
49 public:
50 WindowsManifestMerger();
51 ~WindowsManifestMerger();
52 Error merge(const MemoryBuffer &Manifest);
54 // Returns vector containing merged xml manifest, or uninitialized vector for
55 // empty manifest.
56 std::unique_ptr<MemoryBuffer> getMergedManifest();
58 private:
59 class WindowsManifestMergerImpl;
60 std::unique_ptr<WindowsManifestMergerImpl> Impl;
63 } // namespace windows_manifest
64 } // namespace llvm
65 #endif