Skip to content

Commit

Permalink
Merged main:dc82890a77fe into amd-gfx:738ee4837572
Browse files Browse the repository at this point in the history
Local branch amd-gfx 738ee48 Merged main:ce0c0013d8b1 into amd-gfx:bdc55c25369a
Remote branch main dc82890 [lldb/API] Expose Target::CreateBreakpoint(..., move_to_nearest_code) overload
  • Loading branch information
Sw authored and Sw committed Dec 15, 2020
2 parents 738ee48 + dc82890 commit cf15849
Show file tree
Hide file tree
Showing 81 changed files with 11,819 additions and 442 deletions.
12 changes: 6 additions & 6 deletions clang-tools-extra/modularize/ModularizeUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,22 +258,22 @@ std::error_code ModularizeUtilities::loadProblemHeaderList(
std::error_code ModularizeUtilities::loadModuleMap(
llvm::StringRef InputPath) {
// Get file entry for module.modulemap file.
auto ExpectedModuleMapEntry =
SourceMgr->getFileManager().getFileRef(InputPath);
auto ModuleMapEntryOrErr =
SourceMgr->getFileManager().getFile(InputPath);

// return error if not found.
if (!ExpectedModuleMapEntry) {
if (!ModuleMapEntryOrErr) {
llvm::errs() << "error: File \"" << InputPath << "\" not found.\n";
return errorToErrorCode(ExpectedModuleMapEntry.takeError());
return ModuleMapEntryOrErr.getError();
}
FileEntryRef ModuleMapEntry = *ExpectedModuleMapEntry;
const FileEntry *ModuleMapEntry = *ModuleMapEntryOrErr;

// Because the module map parser uses a ForwardingDiagnosticConsumer,
// which doesn't forward the BeginSourceFile call, we do it explicitly here.
DC.BeginSourceFile(*LangOpts, nullptr);

// Figure out the home directory for the module map file.
const DirectoryEntry *Dir = ModuleMapEntry.getDir();
const DirectoryEntry *Dir = ModuleMapEntry->getDir();
StringRef DirName(Dir->getName());
if (llvm::sys::path::filename(DirName) == "Modules") {
DirName = llvm::sys::path::parent_path(DirName);
Expand Down
9 changes: 4 additions & 5 deletions clang/include/clang/AST/APValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/PointerUnion.h"
#include <type_traits>
#include "llvm/Support/AlignOf.h"

namespace clang {
class AddrLabelExpr;
Expand Down Expand Up @@ -286,10 +286,9 @@ class APValue {
struct MemberPointerData;

// We ensure elsewhere that Data is big enough for LV and MemberPointerData.
typedef std::aligned_union_t<1, void *, APSInt, APFloat, ComplexAPSInt,
ComplexAPFloat, Vec, Arr, StructData, UnionData,
AddrLabelDiffData>
DataType;
typedef llvm::AlignedCharArrayUnion<void *, APSInt, APFloat, ComplexAPSInt,
ComplexAPFloat, Vec, Arr, StructData,
UnionData, AddrLabelDiffData> DataType;
static const size_t DataSize = sizeof(DataType);

DataType Data;
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include "llvm/ADT/TinyPtrVector.h"
#include "llvm/ADT/Triple.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h"
Expand Down
19 changes: 4 additions & 15 deletions clang/include/clang/AST/ASTTypeTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "clang/AST/TypeLoc.h"
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/DenseMapInfo.h"
#include <type_traits>
#include "llvm/Support/AlignOf.h"

namespace llvm {

Expand Down Expand Up @@ -456,8 +456,9 @@ class DynTypedNode {
/// \c QualTypes, \c NestedNameSpecifierLocs, \c TypeLocs,
/// \c TemplateArguments and \c TemplateArgumentLocs on the other hand do not
/// have storage or unique pointers and thus need to be stored by value.
std::aligned_union_t<1, const void *, TemplateArgument, TemplateArgumentLoc,
NestedNameSpecifierLoc, QualType, TypeLoc>
llvm::AlignedCharArrayUnion<const void *, TemplateArgument,
TemplateArgumentLoc, NestedNameSpecifierLoc,
QualType, TypeLoc>
Storage;
};

Expand Down Expand Up @@ -528,18 +529,6 @@ template <typename T, typename EnablerT> struct DynTypedNode::BaseConverter {
}
};

// Previously these types were defined in the clang::ast_type_traits namespace.
// Provide typedefs so that legacy code can be fixed asynchronously.
namespace ast_type_traits {
using DynTypedNode = ::clang::DynTypedNode;
using ASTNodeKind = ::clang::ASTNodeKind;
using TraversalKind = ::clang::TraversalKind;

constexpr TraversalKind TK_AsIs = ::clang::TK_AsIs;
constexpr TraversalKind TK_IgnoreUnlessSpelledInSource =
::clang::TK_IgnoreUnlessSpelledInSource;
} // namespace ast_type_traits

} // end namespace clang

namespace llvm {
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/AST/ParentMapContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class TraversalKindScope {
/// Container for either a single DynTypedNode or for an ArrayRef to
/// DynTypedNode. For use with ParentMap.
class DynTypedNodeList {
std::aligned_union_t<1, DynTypedNode, ArrayRef<DynTypedNode>> Storage;
llvm::AlignedCharArrayUnion<DynTypedNode, ArrayRef<DynTypedNode>> Storage;
bool IsSingleNode;

public:
Expand Down
3 changes: 2 additions & 1 deletion clang/include/clang/Frontend/PrecompiledPreamble.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/MD5.h"
#include <cstddef>
#include <memory>
Expand Down Expand Up @@ -197,7 +198,7 @@ class PrecompiledPreamble {

private:
Kind StorageKind = Kind::Empty;
std::aligned_union_t<1, TempPCHFile, InMemoryPreamble> Storage = {};
llvm::AlignedCharArrayUnion<TempPCHFile, InMemoryPreamble> Storage = {};
};

/// Data used to determine if a file used in the preamble has been changed.
Expand Down
13 changes: 7 additions & 6 deletions clang/include/clang/Lex/HeaderSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class HeaderSearch {

/// Set of module map files we've already loaded, and a flag indicating
/// whether they were valid or not.
llvm::DenseMap<FileEntryRef, bool> LoadedModuleMaps;
llvm::DenseMap<const FileEntry *, bool> LoadedModuleMaps;

/// Uniqued set of framework names, which is used to track which
/// headers were included as framework headers.
Expand Down Expand Up @@ -560,8 +560,8 @@ class HeaderSearch {

/// Try to find a module map file in the given directory, returning
/// \c nullptr if none is found.
Optional<FileEntryRef> lookupModuleMapFile(const DirectoryEntry *Dir,
bool IsFramework);
const FileEntry *lookupModuleMapFile(const DirectoryEntry *Dir,
bool IsFramework);

/// Determine whether there is a module map that may map the header
/// with the given file name to a (sub)module.
Expand Down Expand Up @@ -603,8 +603,8 @@ class HeaderSearch {
/// used to resolve paths within the module (this is required when
/// building the module from preprocessed source).
/// \returns true if an error occurred, false otherwise.
bool loadModuleMapFile(FileEntryRef File, bool IsSystem, FileID ID = FileID(),
unsigned *Offset = nullptr,
bool loadModuleMapFile(const FileEntry *File, bool IsSystem,
FileID ID = FileID(), unsigned *Offset = nullptr,
StringRef OriginalModuleMapFile = StringRef());

/// Collect the set of all known, top-level modules.
Expand Down Expand Up @@ -794,7 +794,8 @@ class HeaderSearch {
LMM_InvalidModuleMap
};

LoadModuleMapResult loadModuleMapFileImpl(FileEntryRef File, bool IsSystem,
LoadModuleMapResult loadModuleMapFileImpl(const FileEntry *File,
bool IsSystem,
const DirectoryEntry *Dir,
FileID ID = FileID(),
unsigned *Offset = nullptr);
Expand Down
6 changes: 3 additions & 3 deletions clang/include/clang/Lex/ModuleMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -684,9 +684,9 @@ class ModuleMap {
/// that caused us to load this module map file, if any.
///
/// \returns true if an error occurred, false otherwise.
bool parseModuleMapFile(FileEntryRef File, bool IsSystem,
const DirectoryEntry *HomeDir, FileID ID = FileID(),
unsigned *Offset = nullptr,
bool parseModuleMapFile(const FileEntry *File, bool IsSystem,
const DirectoryEntry *HomeDir,
FileID ID = FileID(), unsigned *Offset = nullptr,
SourceLocation ExternModuleLoc = SourceLocation());

/// Dump the contents of the module map, for debugging purposes.
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/Sema/Overload.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
Expand Down
5 changes: 0 additions & 5 deletions clang/lib/CodeGen/CGCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1943,11 +1943,6 @@ void CodeGenModule::ConstructAttributeList(
FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
if (TargetDecl->hasAttr<ColdAttr>())
FuncAttrs.addAttribute(llvm::Attribute::Cold);
if (TargetDecl->hasAttr<HotAttr>()) {
// xur
fprintf(stderr, "hihi 2\n");
// FuncAttrs.addAttribute(llvm::Attribute::Hot);
}
if (TargetDecl->hasAttr<NoDuplicateAttr>())
FuncAttrs.addAttribute(llvm::Attribute::NoDuplicate);
if (TargetDecl->hasAttr<ConvergentAttr>())
Expand Down
7 changes: 0 additions & 7 deletions clang/lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1744,13 +1744,6 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
B.addAttribute(llvm::Attribute::OptimizeForSize);
B.addAttribute(llvm::Attribute::Cold);
}
if (D->hasAttr<HotAttr>()) {
if (!ShouldAddOptNone)
B.addAttribute(llvm::Attribute::OptimizeForSize);
// xur
// B.addAttribute(llvm::Attribute::Hot);
fprintf(stderr, "hihi 1\n");
}

if (D->hasAttr<MinSizeAttr>())
B.addAttribute(llvm::Attribute::MinSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/Errno.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/Path.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/Errno.h"
#include "llvm/Support/Mutex.h"
#include "llvm/Support/Path.h"
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/Frontend/FrontendAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ static bool loadModuleMapForModuleBuild(CompilerInstance &CI, bool IsSystem,

// Map the current input to a file.
FileID ModuleMapID = SrcMgr.getMainFileID();
Optional<FileEntryRef> ModuleMap = SrcMgr.getFileEntryRefForID(ModuleMapID);
const FileEntry *ModuleMap = SrcMgr.getFileEntryForID(ModuleMapID);

// If the module map is preprocessed, handle the initial line marker;
// line directives are not part of the module map syntax in general.
Expand All @@ -445,7 +445,7 @@ static bool loadModuleMapForModuleBuild(CompilerInstance &CI, bool IsSystem,
}

// Load the module map file.
if (HS.loadModuleMapFile(*ModuleMap, IsSystem, ModuleMapID, &Offset,
if (HS.loadModuleMapFile(ModuleMap, IsSystem, ModuleMapID, &Offset,
PresumedModuleMapFile))
return true;

Expand Down Expand Up @@ -807,7 +807,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,

// If we were asked to load any module map files, do so now.
for (const auto &Filename : CI.getFrontendOpts().ModuleMapFiles) {
if (auto File = CI.getFileManager().getOptionalFileRef(Filename))
if (auto File = CI.getFileManager().getFile(Filename))
CI.getPreprocessor().getHeaderSearchInfo().loadModuleMapFile(
*File, /*IsSystem*/false);
else
Expand Down
49 changes: 26 additions & 23 deletions clang/lib/Lex/HeaderSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1499,20 +1499,22 @@ bool HeaderSearch::findUsableModuleForFrameworkHeader(
return true;
}

static Optional<FileEntryRef> getPrivateModuleMap(FileEntryRef File,
FileManager &FileMgr) {
StringRef Filename = llvm::sys::path::filename(File.getName());
SmallString<128> PrivateFilename(File.getDir().getName());
static const FileEntry *getPrivateModuleMap(const FileEntry *File,
FileManager &FileMgr) {
StringRef Filename = llvm::sys::path::filename(File->getName());
SmallString<128> PrivateFilename(File->getDir()->getName());
if (Filename == "module.map")
llvm::sys::path::append(PrivateFilename, "module_private.map");
else if (Filename == "module.modulemap")
llvm::sys::path::append(PrivateFilename, "module.private.modulemap");
else
return None;
return FileMgr.getOptionalFileRef(PrivateFilename);
return nullptr;
if (auto File = FileMgr.getFile(PrivateFilename))
return *File;
return nullptr;
}

bool HeaderSearch::loadModuleMapFile(FileEntryRef File, bool IsSystem,
bool HeaderSearch::loadModuleMapFile(const FileEntry *File, bool IsSystem,
FileID ID, unsigned *Offset,
StringRef OriginalModuleMapFile) {
// Find the directory for the module. For frameworks, that may require going
Expand All @@ -1534,7 +1536,7 @@ bool HeaderSearch::loadModuleMapFile(FileEntryRef File, bool IsSystem,
Dir = FakeFile->getDir();
}
} else {
Dir = File.getDir();
Dir = File->getDir();
}

StringRef DirName(Dir->getName());
Expand All @@ -1561,9 +1563,11 @@ bool HeaderSearch::loadModuleMapFile(FileEntryRef File, bool IsSystem,
}

HeaderSearch::LoadModuleMapResult
HeaderSearch::loadModuleMapFileImpl(FileEntryRef File, bool IsSystem,
HeaderSearch::loadModuleMapFileImpl(const FileEntry *File, bool IsSystem,
const DirectoryEntry *Dir, FileID ID,
unsigned *Offset) {
assert(File && "expected FileEntry");

// Check whether we've already loaded this module map, and mark it as being
// loaded in case we recursively try to load it from itself.
auto AddResult = LoadedModuleMaps.insert(std::make_pair(File, true));
Expand All @@ -1576,8 +1580,8 @@ HeaderSearch::loadModuleMapFileImpl(FileEntryRef File, bool IsSystem,
}

// Try to load a corresponding private module map.
if (Optional<FileEntryRef> PMMFile = getPrivateModuleMap(File, FileMgr)) {
if (ModMap.parseModuleMapFile(*PMMFile, IsSystem, Dir)) {
if (const FileEntry *PMMFile = getPrivateModuleMap(File, FileMgr)) {
if (ModMap.parseModuleMapFile(PMMFile, IsSystem, Dir)) {
LoadedModuleMaps[File] = false;
return LMM_InvalidModuleMap;
}
Expand All @@ -1587,35 +1591,35 @@ HeaderSearch::loadModuleMapFileImpl(FileEntryRef File, bool IsSystem,
return LMM_NewlyLoaded;
}

Optional<FileEntryRef>
const FileEntry *
HeaderSearch::lookupModuleMapFile(const DirectoryEntry *Dir, bool IsFramework) {
if (!HSOpts->ImplicitModuleMaps)
return None;
return nullptr;
// For frameworks, the preferred spelling is Modules/module.modulemap, but
// module.map at the framework root is also accepted.
SmallString<128> ModuleMapFileName(Dir->getName());
if (IsFramework)
llvm::sys::path::append(ModuleMapFileName, "Modules");
llvm::sys::path::append(ModuleMapFileName, "module.modulemap");
if (auto F = FileMgr.getOptionalFileRef(ModuleMapFileName))
return F;
if (auto F = FileMgr.getFile(ModuleMapFileName))
return *F;

// Continue to allow module.map
ModuleMapFileName = Dir->getName();
llvm::sys::path::append(ModuleMapFileName, "module.map");
if (auto F = FileMgr.getOptionalFileRef(ModuleMapFileName))
return F;
if (auto F = FileMgr.getFile(ModuleMapFileName))
return *F;

// For frameworks, allow to have a private module map with a preferred
// spelling when a public module map is absent.
if (IsFramework) {
ModuleMapFileName = Dir->getName();
llvm::sys::path::append(ModuleMapFileName, "Modules",
"module.private.modulemap");
if (auto F = FileMgr.getOptionalFileRef(ModuleMapFileName))
return F;
if (auto F = FileMgr.getFile(ModuleMapFileName))
return *F;
}
return None;
return nullptr;
}

Module *HeaderSearch::loadFrameworkModule(StringRef Name,
Expand Down Expand Up @@ -1659,10 +1663,9 @@ HeaderSearch::loadModuleMapFile(const DirectoryEntry *Dir, bool IsSystem,
if (KnownDir != DirectoryHasModuleMap.end())
return KnownDir->second ? LMM_AlreadyLoaded : LMM_InvalidModuleMap;

if (Optional<FileEntryRef> ModuleMapFile =
lookupModuleMapFile(Dir, IsFramework)) {
if (const FileEntry *ModuleMapFile = lookupModuleMapFile(Dir, IsFramework)) {
LoadModuleMapResult Result =
loadModuleMapFileImpl(*ModuleMapFile, IsSystem, Dir);
loadModuleMapFileImpl(ModuleMapFile, IsSystem, Dir);
// Add Dir explicitly in case ModuleMapFile is in a subdirectory.
// E.g. Foo.framework/Modules/module.modulemap
// ^Dir ^ModuleMapFile
Expand Down
Loading

0 comments on commit cf15849

Please sign in to comment.