Files
archived-llvm/include/llvm/DebugInfo/PDB/GenericError.h
Zachary Turner 03936513dd [PDB] Fix bug when using multiple PCH header objects with the same name.
A common pattern in Windows is to have all your precompiled headers
use an object named stdafx.obj.  If you've got a project with many
different static libs, you might use a separate PCH for each one of
these.

During the final link step, a file from A might reference the PCH
object from A, but it will have the same name (stdafx.obj) as any
other PCH from another project.  The only difference will be the
path.  For example, A might be A/stdafx.obj while B is B/stdafx.obj.

The existing algorithm checks only the filename that was passed on
the command line (or stored in archive), but this is insufficient in
the case where relative paths are used, because depending on the
command line object file / library order, it might find the wrong
PCH object first resulting in a signature mismatch.

The fix here is to simply check whether the absolute path of the
PCH object (which is stored in the input obj file for the file that
references the PCH) *ends with* the full relative path of whatever
is specified on the command line (or is in the archive).

Differential Revision: https://reviews.llvm.org/D66431

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374442 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-10 20:25:51 +00:00

52 lines
1.4 KiB
C++

//===- GenericError.h - system_error extensions for PDB ---------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_DEBUGINFO_PDB_ERROR_H
#define LLVM_DEBUGINFO_PDB_ERROR_H
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
namespace llvm {
namespace pdb {
enum class pdb_error_code {
invalid_utf8_path = 1,
dia_sdk_not_present,
dia_failed_loading,
signature_out_of_date,
no_matching_pch,
unspecified,
};
} // namespace pdb
} // namespace llvm
namespace std {
template <>
struct is_error_code_enum<llvm::pdb::pdb_error_code> : std::true_type {};
} // namespace std
namespace llvm {
namespace pdb {
const std::error_category &PDBErrCategory();
inline std::error_code make_error_code(pdb_error_code E) {
return std::error_code(static_cast<int>(E), PDBErrCategory());
}
/// Base class for errors originating when parsing raw PDB files
class PDBError : public ErrorInfo<PDBError, StringError> {
public:
using ErrorInfo<PDBError, StringError>::ErrorInfo; // inherit constructors
PDBError(const Twine &S) : ErrorInfo(S, pdb_error_code::unspecified) {}
static char ID;
};
} // namespace pdb
} // namespace llvm
#endif