LLVM  15.0.0git
WindowsManifestMerger.h
Go to the documentation of this file.
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.
19 //
20 // Ref:
21 // https://msdn.microsoft.com/en-us/library/windows/desktop/aa374191(v=vs.85).aspx
22 //
23 //===---------------------------------------------------------------------===//
24 
25 #ifndef LLVM_WINDOWSMANIFEST_WINDOWSMANIFESTMERGER_H
26 #define LLVM_WINDOWSMANIFEST_WINDOWSMANIFESTMERGER_H
27 
28 #include "llvm/Support/Error.h"
29 
30 namespace llvm {
31 
32 class MemoryBuffer;
33 class MemoryBufferRef;
34 
35 namespace windows_manifest {
36 
37 bool isAvailable();
38 
39 class WindowsManifestError : public ErrorInfo<WindowsManifestError, ECError> {
40 public:
41  static char ID;
42  WindowsManifestError(const Twine &Msg);
43  void log(raw_ostream &OS) const override;
44 
45 private:
46  std::string Msg;
47 };
48 
50 public:
53  Error merge(MemoryBufferRef Manifest);
54 
55  // Returns vector containing merged xml manifest, or uninitialized vector for
56  // empty manifest.
57  std::unique_ptr<MemoryBuffer> getMergedManifest();
58 
59 private:
61  std::unique_ptr<WindowsManifestMergerImpl> Impl;
62 };
63 
64 } // namespace windows_manifest
65 } // namespace llvm
66 #endif
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::windows_manifest::WindowsManifestMerger::WindowsManifestMergerImpl
Definition: WindowsManifestMerger.cpp:33
Error.h
llvm::MemoryBufferRef
Definition: MemoryBufferRef.h:22
llvm::windows_manifest::WindowsManifestError::log
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition: WindowsManifestMerger.cpp:31
llvm::windows_manifest::WindowsManifestMerger::~WindowsManifestMerger
~WindowsManifestMerger()
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:54
llvm::windows_manifest::WindowsManifestError::ID
static char ID
Definition: WindowsManifestMerger.h:41
llvm::windows_manifest::WindowsManifestMerger::getMergedManifest
std::unique_ptr< MemoryBuffer > getMergedManifest()
Definition: WindowsManifestMerger.cpp:713
llvm::windows_manifest::isAvailable
bool isAvailable()
Definition: WindowsManifestMerger.cpp:700
llvm::ErrorInfo
Base class for user error types.
Definition: Error.h:347
llvm::windows_manifest::WindowsManifestMerger::WindowsManifestMerger
WindowsManifestMerger()
Definition: WindowsManifestMerger.cpp:704
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
llvm::windows_manifest::WindowsManifestMerger
Definition: WindowsManifestMerger.h:49
llvm::windows_manifest::WindowsManifestError::WindowsManifestError
WindowsManifestError(const Twine &Msg)
Definition: WindowsManifestMerger.cpp:29
llvm::windows_manifest::WindowsManifestError
Definition: WindowsManifestMerger.h:39
llvm::windows_manifest::WindowsManifestMerger::merge
Error merge(MemoryBufferRef Manifest)
Definition: WindowsManifestMerger.cpp:709