Skip to content

Commit

Permalink
Merged main:1a4b9b6f7339 into amd-gfx:31ed504cc6fe
Browse files Browse the repository at this point in the history
Local branch amd-gfx 31ed504 Merged main:c718336c4cb1 into amd-gfx:1d8917372237
Remote branch main 1a4b9b6 [asan] Ensure __asan_register_elf_globals is called in COMDAT asan.module_ctor (llvm#67745)
  • Loading branch information
SC llvm team authored and SC llvm team committed Sep 29, 2023
2 parents 31ed504 + 1a4b9b6 commit 6385230
Show file tree
Hide file tree
Showing 179 changed files with 1,846 additions and 1,180 deletions.
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/IncludeCleaner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ bool mayConsiderUnused(const Inclusion &Inc, ParsedAST &AST,
// Headers without include guards have side effects and are not
// self-contained, skip them.
if (!AST.getPreprocessor().getHeaderSearchInfo().isFileMultipleIncludeGuarded(
&FE->getFileEntry())) {
*FE)) {
dlog("{0} doesn't have header guard and will not be considered unused",
FE->getName());
return false;
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clangd/ParsedAST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,8 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
// (The rest of HeaderFileInfo is not relevant for our purposes).
if (Preamble && Preamble->MainIsIncludeGuarded) {
const SourceManager &SM = Clang->getSourceManager();
const FileEntry *MainFE = SM.getFileEntryForID(SM.getMainFileID());
Clang->getPreprocessor().getHeaderSearchInfo().MarkFileIncludeOnce(MainFE);
OptionalFileEntryRef MainFE = SM.getFileEntryRefForID(SM.getMainFileID());
Clang->getPreprocessor().getHeaderSearchInfo().MarkFileIncludeOnce(*MainFE);
}

// Set up ClangTidy. Must happen after BeginSourceFile() so ASTContext exists.
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clangd/Preamble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ class CppFilePreambleCallbacks : public PreambleCallbacks {
CapturedCtx.emplace(CI);

const SourceManager &SM = CI.getSourceManager();
const FileEntry *MainFE = SM.getFileEntryForID(SM.getMainFileID());
OptionalFileEntryRef MainFE = SM.getFileEntryRefForID(SM.getMainFileID());
IsMainFileIncludeGuarded =
CI.getPreprocessor().getHeaderSearchInfo().isFileMultipleIncludeGuarded(
MainFE);
*MainFE);

if (Stats) {
const ASTContext &AST = CI.getASTContext();
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,10 @@ std::string once(llvm::StringRef Code) {

bool mainIsGuarded(const ParsedAST &AST) {
const auto &SM = AST.getSourceManager();
const FileEntry *MainFE = SM.getFileEntryForID(SM.getMainFileID());
OptionalFileEntryRef MainFE = SM.getFileEntryRefForID(SM.getMainFileID());
return AST.getPreprocessor()
.getHeaderSearchInfo()
.isFileMultipleIncludeGuarded(MainFE);
.isFileMultipleIncludeGuarded(*MainFE);
}

MATCHER_P(diag, Desc, "") {
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/include-cleaner/lib/Record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ class PragmaIncludes::RecordPragma : public PPCallbacks, public CommentHandler {
if (Reason == PPCallbacks::ExitFile) {
// At file exit time HeaderSearchInfo is valid and can be used to
// determine whether the file was a self-contained header or not.
if (const FileEntry *FE = SM.getFileEntryForID(PrevFID)) {
if (tooling::isSelfContainedHeader(FE, SM, HeaderInfo))
if (OptionalFileEntryRef FE = SM.getFileEntryRefForID(PrevFID)) {
if (tooling::isSelfContainedHeader(*FE, SM, HeaderInfo))
Out->NonSelfContainedFiles.erase(FE->getUniqueID());
else
Out->NonSelfContainedFiles.insert(FE->getUniqueID());
Expand Down
5 changes: 5 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ Bug Fixes in This Version
- Fixes crash when trying to obtain the common sugared type of
`decltype(instantiation-dependent-expr)`.
Fixes (`#67603 <https://github.com/llvm/llvm-project/issues/67603>`_)
- Fixes a crash caused by a multidimensional array being captured by a lambda
(`#67722 <https://github.com/llvm/llvm-project/issues/67722>`_).

Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -370,6 +372,9 @@ Bug Fixes to C++ Support
argument. Fixes:
(`#67395 <https://github.com/llvm/llvm-project/issues/67395>`_)

- Fixed a bug causing destructors of constant-evaluated structured bindings
initialized by array elements to be called in the wrong evaluation context.

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed an import failure of recursive friend class template.
Expand Down
21 changes: 21 additions & 0 deletions clang/include/clang/AST/OpenMPClause.h
Original file line number Diff line number Diff line change
Expand Up @@ -9220,6 +9220,27 @@ class OMPXAttributeClause
}
};

/// This represents 'ompx_bare' clause in the '#pragma omp target teams ...'
/// directive.
///
/// \code
/// #pragma omp target teams ompx_bare
/// \endcode
/// In this example directive '#pragma omp target teams' has a 'ompx_bare'
/// clause.
class OMPXBareClause : public OMPNoChildClause<llvm::omp::OMPC_ompx_bare> {
public:
/// Build 'ompx_bare' clause.
///
/// \param StartLoc Starting location of the clause.
/// \param EndLoc Ending location of the clause.
OMPXBareClause(SourceLocation StartLoc, SourceLocation EndLoc)
: OMPNoChildClause(StartLoc, EndLoc) {}

/// Build an empty clause.
OMPXBareClause() = default;
};

} // namespace clang

#endif // LLVM_CLANG_AST_OPENMPCLAUSE_H
5 changes: 5 additions & 0 deletions clang/include/clang/AST/RecursiveASTVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -3890,6 +3890,11 @@ bool RecursiveASTVisitor<Derived>::VisitOMPXAttributeClause(
return true;
}

template <typename Derived>
bool RecursiveASTVisitor<Derived>::VisitOMPXBareClause(OMPXBareClause *C) {
return true;
}

// FIXME: look at the following tricky-seeming exprs to see if we
// need to recurse on anything. These are ones that have methods
// returning decls or qualtypes or nestednamespecifier -- though I'm
Expand Down
4 changes: 4 additions & 0 deletions clang/include/clang/Basic/DiagnosticParseKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,8 @@ def warn_clause_expected_string : Warning<
"expected string literal in 'clause %0' - ignoring">, InGroup<IgnoredPragmas>;
def err_omp_unexpected_clause : Error<
"unexpected OpenMP clause '%0' in directive '#pragma omp %1'">;
def err_omp_unexpected_clause_extension_only : Error<
"OpenMP clause '%0' is only available as extension, use '-fopenmp-extensions'">;
def err_omp_immediate_directive : Error<
"'#pragma omp %0' %select{|with '%2' clause }1cannot be an immediate substatement">;
def err_omp_expected_identifier_for_critical : Error<
Expand Down Expand Up @@ -1452,6 +1454,8 @@ def warn_unknown_declare_variant_isa_trait
"spelling or consider restricting the context selector with the "
"'arch' selector further">,
InGroup<SourceUsesOpenMP>;
def note_ompx_bare_clause : Note<
"OpenMP extension clause '%0' only allowed with '#pragma omp %1'">;
def note_omp_declare_variant_ctx_options
: Note<"context %select{set|selector|property}0 options are: %1">;
def warn_omp_declare_variant_expected
Expand Down
12 changes: 4 additions & 8 deletions clang/include/clang/Basic/SourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -942,12 +942,12 @@ class SourceManager : public RefCountedBase<SourceManager> {
///
/// Returns std::nullopt if the buffer is not valid.
std::optional<llvm::MemoryBufferRef>
getMemoryBufferForFileOrNone(const FileEntry *File);
getMemoryBufferForFileOrNone(FileEntryRef File);

/// Retrieve the memory buffer associated with the given file.
///
/// Returns a fake buffer if there isn't a real one.
llvm::MemoryBufferRef getMemoryBufferForFileOrFake(const FileEntry *File) {
llvm::MemoryBufferRef getMemoryBufferForFileOrFake(FileEntryRef File) {
if (auto B = getMemoryBufferForFileOrNone(File))
return *B;
return getFakeBufferForRecovery();
Expand All @@ -960,7 +960,7 @@ class SourceManager : public RefCountedBase<SourceManager> {
///
/// \param Buffer the memory buffer whose contents will be used as the
/// data in the given source file.
void overrideFileContents(const FileEntry *SourceFile,
void overrideFileContents(FileEntryRef SourceFile,
const llvm::MemoryBufferRef &Buffer) {
overrideFileContents(SourceFile, llvm::MemoryBuffer::getMemBuffer(Buffer));
}
Expand All @@ -972,12 +972,8 @@ class SourceManager : public RefCountedBase<SourceManager> {
///
/// \param Buffer the memory buffer whose contents will be used as the
/// data in the given source file.
void overrideFileContents(const FileEntry *SourceFile,
std::unique_ptr<llvm::MemoryBuffer> Buffer);
void overrideFileContents(FileEntryRef SourceFile,
std::unique_ptr<llvm::MemoryBuffer> Buffer) {
overrideFileContents(&SourceFile.getFileEntry(), std::move(Buffer));
}
std::unique_ptr<llvm::MemoryBuffer> Buffer);

/// Override the given source file with another one.
///
Expand Down
23 changes: 11 additions & 12 deletions clang/include/clang/Lex/HeaderSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class ExternalHeaderFileInfoSource {
/// \returns Header file information for the given file entry, with the
/// \c External bit set. If the file entry is not known, return a
/// default-constructed \c HeaderFileInfo.
virtual HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) = 0;
virtual HeaderFileInfo GetHeaderFileInfo(FileEntryRef FE) = 0;
};

/// This structure is used to record entries in our framework cache.
Expand Down Expand Up @@ -487,7 +487,7 @@ class HeaderSearch {
OptionalFileEntryRef LookupFile(
StringRef Filename, SourceLocation IncludeLoc, bool isAngled,
ConstSearchDirIterator FromDir, ConstSearchDirIterator *CurDir,
ArrayRef<std::pair<const FileEntry *, DirectoryEntryRef>> Includers,
ArrayRef<std::pair<OptionalFileEntryRef, DirectoryEntryRef>> Includers,
SmallVectorImpl<char> *SearchPath, SmallVectorImpl<char> *RelativePath,
Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule,
bool *IsMapped, bool *IsFrameworkFound, bool SkipCache = false,
Expand Down Expand Up @@ -522,33 +522,32 @@ class HeaderSearch {

/// Return whether the specified file is a normal header,
/// a system header, or a C++ friendly system header.
SrcMgr::CharacteristicKind getFileDirFlavor(const FileEntry *File) {
SrcMgr::CharacteristicKind getFileDirFlavor(FileEntryRef File) {
return (SrcMgr::CharacteristicKind)getFileInfo(File).DirInfo;
}

/// Mark the specified file as a "once only" file due to
/// \#pragma once.
void MarkFileIncludeOnce(const FileEntry *File) {
void MarkFileIncludeOnce(FileEntryRef File) {
HeaderFileInfo &FI = getFileInfo(File);
FI.isPragmaOnce = true;
}

/// Mark the specified file as a system header, e.g. due to
/// \#pragma GCC system_header.
void MarkFileSystemHeader(const FileEntry *File) {
void MarkFileSystemHeader(FileEntryRef File) {
getFileInfo(File).DirInfo = SrcMgr::C_System;
}

/// Mark the specified file as part of a module.
void MarkFileModuleHeader(const FileEntry *FE,
ModuleMap::ModuleHeaderRole Role,
void MarkFileModuleHeader(FileEntryRef FE, ModuleMap::ModuleHeaderRole Role,
bool isCompilingModuleHeader);

/// Mark the specified file as having a controlling macro.
///
/// This is used by the multiple-include optimization to eliminate
/// no-op \#includes.
void SetFileControllingMacro(const FileEntry *File,
void SetFileControllingMacro(FileEntryRef File,
const IdentifierInfo *ControllingMacro) {
getFileInfo(File).ControllingMacro = ControllingMacro;
}
Expand All @@ -558,10 +557,10 @@ class HeaderSearch {
/// macro.
///
/// This routine does not consider the effect of \#import
bool isFileMultipleIncludeGuarded(const FileEntry *File) const;
bool isFileMultipleIncludeGuarded(FileEntryRef File) const;

/// Determine whether the given file is known to have ever been \#imported.
bool hasFileBeenImported(const FileEntry *File) const {
bool hasFileBeenImported(FileEntryRef File) const {
const HeaderFileInfo *FI = getExistingFileInfo(File);
return FI && FI->isImport;
}
Expand Down Expand Up @@ -806,13 +805,13 @@ class HeaderSearch {

/// Return the HeaderFileInfo structure for the specified FileEntry,
/// in preparation for updating it in some way.
HeaderFileInfo &getFileInfo(const FileEntry *FE);
HeaderFileInfo &getFileInfo(FileEntryRef FE);

/// Return the HeaderFileInfo structure for the specified FileEntry,
/// if it has ever been filled in.
/// \param WantExternal Whether the caller wants purely-external header file
/// info (where \p External is true).
const HeaderFileInfo *getExistingFileInfo(const FileEntry *FE,
const HeaderFileInfo *getExistingFileInfo(FileEntryRef FE,
bool WantExternal = true) const;

SearchDirIterator search_dir_begin() { return {*this, 0}; }
Expand Down
8 changes: 4 additions & 4 deletions clang/include/clang/Lex/Preprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -1483,13 +1483,13 @@ class Preprocessor {

/// Mark the file as included.
/// Returns true if this is the first time the file was included.
bool markIncluded(const FileEntry *File) {
bool markIncluded(FileEntryRef File) {
HeaderInfo.getFileInfo(File);
return IncludedFiles.insert(File).second;
}

/// Return true if this header has already been included.
bool alreadyIncluded(const FileEntry *File) const {
bool alreadyIncluded(FileEntryRef File) const {
HeaderInfo.getFileInfo(File);
return IncludedFiles.count(File);
}
Expand Down Expand Up @@ -1935,8 +1935,8 @@ class Preprocessor {
/// (1-based).
///
/// \returns true if an error occurred, false otherwise.
bool SetCodeCompletionPoint(const FileEntry *File,
unsigned Line, unsigned Column);
bool SetCodeCompletionPoint(FileEntryRef File, unsigned Line,
unsigned Column);

/// Determine if we are performing code completion.
bool isCodeCompletionEnabled() const { return CodeCompletionFile != nullptr; }
Expand Down
4 changes: 4 additions & 0 deletions clang/include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -12448,6 +12448,10 @@ class Sema final {
SourceLocation LParenLoc,
SourceLocation EndLoc);

/// Called on a well-formed 'ompx_bare' clause.
OMPClause *ActOnOpenMPXBareClause(SourceLocation StartLoc,
SourceLocation EndLoc);

/// The kind of conversion being performed.
enum CheckedConversionKind {
/// An implicit conversion.
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Serialization/ASTReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -1821,7 +1821,7 @@ class ASTReader
SourceRange ReadSkippedRange(unsigned Index) override;

/// Read the header file information for the given file entry.
HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) override;
HeaderFileInfo GetHeaderFileInfo(FileEntryRef FE) override;

void ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag);

Expand Down
4 changes: 2 additions & 2 deletions clang/include/clang/Tooling/Inclusions/HeaderAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
#ifndef LLVM_CLANG_TOOLING_INCLUSIONS_HEADER_ANALYSIS_H
#define LLVM_CLANG_TOOLING_INCLUSIONS_HEADER_ANALYSIS_H

#include "clang/Basic/FileEntry.h"
#include "llvm/ADT/StringRef.h"
#include <optional>

namespace clang {
class FileEntry;
class SourceManager;
class HeaderSearch;

Expand All @@ -27,7 +27,7 @@ namespace tooling {
///
/// This function can be expensive as it may scan the source code to find out
/// dont-include-me pattern heuristically.
bool isSelfContainedHeader(const FileEntry *FE, const SourceManager &SM,
bool isSelfContainedHeader(FileEntryRef FE, const SourceManager &SM,
const HeaderSearch &HeaderInfo);

/// This scans the given source code to see if it contains #import(s).
Expand Down
13 changes: 13 additions & 0 deletions clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10969,6 +10969,16 @@ bool ArrayExprEvaluator::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E) {

bool Success = true;
for (EvalInfo::ArrayInitLoopIndex Index(Info); Index != Elements; ++Index) {
// C++ [class.temporary]/5
// There are four contexts in which temporaries are destroyed at a different
// point than the end of the full-expression. [...] The second context is
// when a copy constructor is called to copy an element of an array while
// the entire array is copied [...]. In either case, if the constructor has
// one or more default arguments, the destruction of every temporary created
// in a default argument is sequenced before the construction of the next
// array element, if any.
FullExpressionRAII Scope(Info);

if (!EvaluateInPlace(Result.getArrayInitializedElt(Index),
Info, Subobject, E->getSubExpr()) ||
!HandleLValueArrayAdjustment(Info, E, Subobject,
Expand All @@ -10977,6 +10987,9 @@ bool ArrayExprEvaluator::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E) {
return false;
Success = false;
}

// Make sure we run the destructors too.
Scope.destroy();
}

return Success;
Expand Down
5 changes: 5 additions & 0 deletions clang/lib/AST/OpenMPClause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) {
case OMPC_affinity:
case OMPC_when:
case OMPC_bind:
case OMPC_ompx_bare:
break;
default:
break;
Expand Down Expand Up @@ -2546,6 +2547,10 @@ void OMPClausePrinter::VisitOMPXAttributeClause(OMPXAttributeClause *Node) {
OS << ")";
}

void OMPClausePrinter::VisitOMPXBareClause(OMPXBareClause *Node) {
OS << "ompx_bare";
}

void OMPTraitInfo::getAsVariantMatchInfo(ASTContext &ASTCtx,
VariantMatchInfo &VMI) const {
for (const OMPTraitSet &Set : Sets) {
Expand Down
1 change: 1 addition & 0 deletions clang/lib/AST/StmtProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@ void OMPClauseProfiler::VisitOMPDoacrossClause(const OMPDoacrossClause *C) {
}
void OMPClauseProfiler::VisitOMPXAttributeClause(const OMPXAttributeClause *C) {
}
void OMPClauseProfiler::VisitOMPXBareClause(const OMPXBareClause *C) {}
} // namespace

void
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/Basic/SourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,14 +681,14 @@ SourceManager::createExpansionLocImpl(const ExpansionInfo &Info,
}

std::optional<llvm::MemoryBufferRef>
SourceManager::getMemoryBufferForFileOrNone(const FileEntry *File) {
SrcMgr::ContentCache &IR = getOrCreateContentCache(File->getLastRef());
SourceManager::getMemoryBufferForFileOrNone(FileEntryRef File) {
SrcMgr::ContentCache &IR = getOrCreateContentCache(File);
return IR.getBufferOrNone(Diag, getFileManager(), SourceLocation());
}

void SourceManager::overrideFileContents(
const FileEntry *SourceFile, std::unique_ptr<llvm::MemoryBuffer> Buffer) {
SrcMgr::ContentCache &IR = getOrCreateContentCache(SourceFile->getLastRef());
FileEntryRef SourceFile, std::unique_ptr<llvm::MemoryBuffer> Buffer) {
SrcMgr::ContentCache &IR = getOrCreateContentCache(SourceFile);

IR.setBuffer(std::move(Buffer));
IR.BufferOverridden = true;
Expand Down
Loading

0 comments on commit 6385230

Please sign in to comment.