[PATCH] D37240: Fix crbug 759265 by suppressing llvm mt warnings.

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 1 15:12:30 PDT 2017


zturner added a comment.

We have similar issues in the PDB code, where we might want to use the native pdb reader or the DIA reader.  To handle this, we have an enumeration:

  /// Specifies which PDB reader implementation is to be used.  Only a value
  /// of PDB_ReaderType::DIA is currently supported, but Native is in the works.
  enum class PDB_ReaderType {
    DIA = 0,
    Native = 1,
  };

Then, when you actually call the function to load the PDB, it looks like this:

    // Create the correct concrete instance type based on the value of Type.
    if (Type == PDB_ReaderType::Native)
      return NativeSession::createFromPdb(Path, Session);
  
  #if LLVM_ENABLE_DIA_SDK
    return DIASession::createFromPdb(Path, Session);
  #else
    return make_error<GenericError>("DIA is not installed on the system");
  #endif

Then the user could write something like:

  if (auto EC = loadDataForPDB(PDB_ReaderType::DIA, Session)) {
    if (auto EC2 = loadDataForPDB(PDB_ReaderType::Native, Session)) {
      return make_error<Foo>("PDB Unsupported");
    }
  }
  
  // Now I have either a native session or a DIA session, but I don't know (or care) which.
  return Session;


https://reviews.llvm.org/D37240





More information about the llvm-commits mailing list