Skip to content

Commit

Permalink
Merge from 'main' to 'sycl-web' (#1)
Browse files Browse the repository at this point in the history
  Resolved build issue due to https://reviews.llvm.org/D101506
  • Loading branch information
abhinavgaba committed Jun 15, 2021
2 parents 17cc5ed + 3302af9 commit 0b75243
Show file tree
Hide file tree
Showing 504 changed files with 12,073 additions and 6,862 deletions.
40 changes: 22 additions & 18 deletions clang/include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -3689,6 +3689,12 @@ class Sema final {
bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType);
bool isSameOrCompatibleFunctionType(CanQualType Param, CanQualType Arg);

ExprResult PerformMoveOrCopyInitialization(const InitializedEntity &Entity,
const VarDecl *NRVOCandidate,
QualType ResultType,
Expr *Value,
bool AllowNRVO = true);

bool CanPerformAggregateInitializationForOverloadResolution(
const InitializedEntity &Entity, InitListExpr *From);

Expand Down Expand Up @@ -4990,30 +4996,28 @@ class Sema final {
SourceLocation Loc,
unsigned NumParams);

struct NamedReturnInfo {
const VarDecl *Candidate;

enum Status : uint8_t { None, MoveEligible, MoveEligibleAndCopyElidable };
Status S;

bool isMoveEligible() const { return S != None; };
bool isCopyElidable() const { return S == MoveEligibleAndCopyElidable; }
enum CopyElisionSemanticsKind {
CES_Strict = 0,
CES_AllowParameters = 1,
CES_AllowDifferentTypes = 2,
CES_AllowExceptionVariables = 4,
CES_AllowRValueReferenceType = 8,
CES_ImplicitlyMovableCXX11CXX14CXX17 =
(CES_AllowParameters | CES_AllowDifferentTypes),
CES_ImplicitlyMovableCXX20 =
(CES_AllowParameters | CES_AllowDifferentTypes |
CES_AllowExceptionVariables | CES_AllowRValueReferenceType),
};
NamedReturnInfo getNamedReturnInfo(Expr *&E, bool ForceCXX2b = false);
NamedReturnInfo getNamedReturnInfo(const VarDecl *VD,
bool ForceCXX20 = false);
const VarDecl *getCopyElisionCandidate(NamedReturnInfo &Info,
QualType ReturnType);

ExprResult PerformMoveOrCopyInitialization(const InitializedEntity &Entity,
const NamedReturnInfo &NRInfo,
Expr *Value);
VarDecl *getCopyElisionCandidate(QualType ReturnType, Expr *E,
CopyElisionSemanticsKind CESK);
bool isCopyElisionCandidate(QualType ReturnType, const VarDecl *VD,
CopyElisionSemanticsKind CESK);

StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
Scope *CurScope);
StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp);
StmtResult ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
NamedReturnInfo &NRInfo);
StmtResult ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp);

StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
bool IsVolatile, unsigned NumOutputs,
Expand Down
54 changes: 35 additions & 19 deletions clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -725,14 +725,43 @@ class BugReporterContext {
}
};

/// The tag that carries some information with it.
///
/// It can be valuable to produce tags with some bits of information and later
/// reuse them for a better diagnostic.
///
/// Please make sure that derived class' constuctor is private and that the user
/// can only create objects using DataTag::Factory. This also means that
/// DataTag::Factory should be friend for every derived class.
class DataTag : public ProgramPointTag {
public:
StringRef getTagDescription() const override { return "Data Tag"; }

// Manage memory for DataTag objects.
class Factory {
std::vector<std::unique_ptr<DataTag>> Tags;

public:
template <class DataTagType, class... Args>
const DataTagType *make(Args &&... ConstructorArgs) {
// We cannot use std::make_unique because we cannot access the private
// constructor from inside it.
Tags.emplace_back(
new DataTagType(std::forward<Args>(ConstructorArgs)...));
return static_cast<DataTagType *>(Tags.back().get());
}
};

protected:
DataTag(void *TagKind) : ProgramPointTag(TagKind) {}
};

/// The tag upon which the TagVisitor reacts. Add these in order to display
/// additional PathDiagnosticEventPieces along the path.
class NoteTag : public ProgramPointTag {
class NoteTag : public DataTag {
public:
using Callback =
std::function<std::string(BugReporterContext &,
PathSensitiveBugReport &)>;
using Callback = std::function<std::string(BugReporterContext &,
PathSensitiveBugReport &)>;

private:
static int Kind;
Expand All @@ -741,7 +770,7 @@ class NoteTag : public ProgramPointTag {
const bool IsPrunable;

NoteTag(Callback &&Cb, bool IsPrunable)
: ProgramPointTag(&Kind), Cb(std::move(Cb)), IsPrunable(IsPrunable) {}
: DataTag(&Kind), Cb(std::move(Cb)), IsPrunable(IsPrunable) {}

public:
static bool classof(const ProgramPointTag *T) {
Expand All @@ -766,20 +795,7 @@ class NoteTag : public ProgramPointTag {

bool isPrunable() const { return IsPrunable; }

// Manage memory for NoteTag objects.
class Factory {
std::vector<std::unique_ptr<NoteTag>> Tags;

public:
const NoteTag *makeNoteTag(Callback &&Cb, bool IsPrunable = false) {
// We cannot use std::make_unique because we cannot access the private
// constructor from inside it.
std::unique_ptr<NoteTag> T(new NoteTag(std::move(Cb), IsPrunable));
Tags.push_back(std::move(T));
return Tags.back().get();
}
};

friend class Factory;
friend class TagVisitor;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ struct StoreInfo {
/// int x;
/// x = 42;
Assignment,
/// The value got stored into the parameter region as the result
/// of a call.
CallArgument,
/// The value got stored into the region as block capture.
/// Block data is modeled as a separate region, thus whenever
/// the analyzer sees a captured variable, its value is copied
Expand All @@ -138,7 +141,7 @@ struct StoreInfo {
const ExplodedNode *StoreSite;
/// The expression where the value comes from.
/// NOTE: might be null.
Expr *SourceOfTheValue;
const Expr *SourceOfTheValue;
/// Symbolic value that is being stored.
SVal Value;
/// Memory regions involved in the store operation.
Expand Down Expand Up @@ -230,7 +233,8 @@ class Tracker : public llvm::RefCountedBase<Tracker> {
/// \param Opts Tracking options specifying how we got to it.
///
/// NOTE: this method is designed for sub-trackers and visitors.
virtual PathDiagnosticPieceRef handle(StoreInfo SI, TrackingOptions Opts);
virtual PathDiagnosticPieceRef handle(StoreInfo SI, BugReporterContext &BRC,
TrackingOptions Opts);

/// Add custom expression handler with the highest priority.
///
Expand Down Expand Up @@ -322,9 +326,14 @@ class StoreHandler {
///
/// \return the produced note, null if the handler doesn't support this kind
/// of stores.
virtual PathDiagnosticPieceRef handle(StoreInfo SI, TrackingOptions Opts) = 0;
virtual PathDiagnosticPieceRef handle(StoreInfo SI, BugReporterContext &BRC,
TrackingOptions Opts) = 0;

Tracker &getParentTracker() { return ParentTracker; }

protected:
PathDiagnosticPieceRef constructNote(StoreInfo SI, BugReporterContext &BRC,
StringRef NodeText);
};

/// Visitor that tracks expressions and values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class CheckerContext {
/// to omit the note from the report if it would make the displayed
/// bug path significantly shorter.
const NoteTag *getNoteTag(NoteTag::Callback &&Cb, bool IsPrunable = false) {
return Eng.getNoteTags().makeNoteTag(std::move(Cb), IsPrunable);
return Eng.getDataTags().make<NoteTag>(std::move(Cb), IsPrunable);
}

/// A shorthand version of getNoteTag that doesn't require you to accept
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ class CoreEngine {
/// (This data is owned by AnalysisConsumer.)
FunctionSummariesTy *FunctionSummaries;

/// Add path note tags along the path when we see that something interesting
/// is happening. This field is the allocator for such tags.
NoteTag::Factory NoteTags;
/// Add path tags with some useful data along the path when we see that
/// something interesting is happening. This field is the allocator for such
/// tags.
DataTag::Factory DataTags;

void generateNode(const ProgramPoint &Loc,
ProgramStateRef State,
Expand Down Expand Up @@ -200,7 +201,7 @@ class CoreEngine {
/// Enqueue a single node created as a result of statement processing.
void enqueueStmtNode(ExplodedNode *N, const CFGBlock *Block, unsigned Idx);

NoteTag::Factory &getNoteTags() { return NoteTags; }
DataTag::Factory &getDataTags() { return DataTags; }
};

// TODO: Turn into a class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,7 @@ class ExprEngine {
SymbolManager &getSymbolManager() { return SymMgr; }
MemRegionManager &getRegionManager() { return MRMgr; }

NoteTag::Factory &getNoteTags() { return Engine.getNoteTags(); }

DataTag::Factory &getDataTags() { return Engine.getDataTags(); }

// Functions for external checking of whether we have unfinished work
bool wasBlocksExhausted() const { return Engine.wasBlocksExhausted(); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ class DependencyConsumer {
public:
virtual ~DependencyConsumer() {}

virtual void handleFileDependency(const DependencyOutputOptions &Opts,
StringRef Filename) = 0;
virtual void
handleDependencyOutputOpts(const DependencyOutputOptions &Opts) = 0;

virtual void handleFileDependency(StringRef Filename) = 0;

virtual void handlePrebuiltModuleDependency(PrebuiltModuleDep PMD) = 0;

Expand Down
35 changes: 29 additions & 6 deletions clang/lib/Basic/Targets/Hexagon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,37 @@ bool HexagonTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
}

const char *const HexagonTargetInfo::GCCRegNames[] = {
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8",
"r9", "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17",
"r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26",
"r27", "r28", "r29", "r30", "r31", "p0", "p1", "p2", "p3",
"sa0", "lc0", "sa1", "lc1", "m0", "m1", "usr", "ugp", "cs0", "cs1",
// Scalar registers:
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11",
"r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20", "r21",
"r22", "r23", "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
"r1:0", "r3:2", "r5:4", "r7:6", "r9:8", "r11:10", "r13:12", "r15:14",
"r17:16", "r19:18", "r21:20", "r23:22", "r25:24", "r27:26", "r29:28",
"r31:30"
"r31:30",
// Predicate registers:
"p0", "p1", "p2", "p3",
// Control registers:
"c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11",
"c12", "c13", "c14", "c15", "c16", "c17", "c18", "c19", "c20", "c21",
"c22", "c23", "c24", "c25", "c26", "c27", "c28", "c29", "c30", "c31",
"c1:0", "c3:2", "c5:4", "c7:6", "c9:8", "c11:10", "c13:12", "c15:14",
"c17:16", "c19:18", "c21:20", "c23:22", "c25:24", "c27:26", "c29:28",
"c31:30",
// Control register aliases:
"sa0", "lc0", "sa1", "lc1", "p3:0", "m0", "m1", "usr", "pc", "ugp",
"gp", "cs0", "cs1", "upcyclelo", "upcyclehi", "framelimit", "framekey",
"pktcountlo", "pktcounthi", "utimerlo", "utimerhi",
"upcycle", "pktcount", "utimer",
// HVX vector registers:
"v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11",
"v12", "v13", "v14", "v15", "v16", "v17", "v18", "v19", "v20", "v21",
"v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
"v1:0", "v3:2", "v5:4", "v7:6", "v9:8", "v11:10", "v13:12", "v15:14",
"v17:16", "v19:18", "v21:20", "v23:22", "v25:24", "v27:26", "v29:28",
"v31:30",
"v3:0", "v7:4", "v11:8", "v15:12", "v19:16", "v23:20", "v27:24", "v31:28",
// HVX vector predicates:
"q0", "q1", "q2", "q3",
};

ArrayRef<const char *> HexagonTargetInfo::getGCCRegNames() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ DirectoryWatcherWindows::~DirectoryWatcherWindows() {
}

void DirectoryWatcherWindows::InitialScan() {
std::unique_lock<std::mutex> lock(Mutex);
Ready.wait(lock, [this] { return this->WatcherActive; });

Callback(getAsFileEvents(scanDirectory(Path.data())), /*IsInitial=*/true);
}

Expand Down
5 changes: 2 additions & 3 deletions clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,10 +779,9 @@ void tools::linkSanitizerRuntimeDeps(const ToolChain &TC,
}
CmdArgs.push_back("-lm");
// There's no libdl on all OSes.
if (!TC.getTriple().isOSFreeBSD() &&
!TC.getTriple().isOSNetBSD() &&
if (!TC.getTriple().isOSFreeBSD() && !TC.getTriple().isOSNetBSD() &&
!TC.getTriple().isOSOpenBSD() &&
TC.getTriple().getOS() != llvm::Triple::RTEMS)
TC.getTriple().getOS() != llvm::Triple::RTEMS)
CmdArgs.push_back("-ldl");
// Required for backtrace on some OSes
if (TC.getTriple().isOSFreeBSD() ||
Expand Down
6 changes: 5 additions & 1 deletion clang/lib/Format/TokenAnnotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,13 @@ class AnnotatingParser {
!CurrentToken->Next->HasUnescapedNewline &&
!CurrentToken->Next->isTrailingComment())
HasMultipleParametersOnALine = true;
bool ProbablyFunctionTypeLParen =
(CurrentToken->is(tok::l_paren) && CurrentToken->Next &&
CurrentToken->Next->isOneOf(tok::star, tok::amp, tok::caret));
if ((CurrentToken->Previous->isOneOf(tok::kw_const, tok::kw_auto) ||
CurrentToken->Previous->isSimpleTypeSpecifier()) &&
!CurrentToken->isOneOf(tok::l_brace, tok::l_paren))
!(CurrentToken->is(tok::l_brace) ||
(CurrentToken->is(tok::l_paren) && !ProbablyFunctionTypeLParen)))
Contexts.back().IsExpression = false;
if (CurrentToken->isOneOf(tok::semi, tok::colon)) {
MightBeObjCForRangeLoop = false;
Expand Down
3 changes: 0 additions & 3 deletions clang/lib/Format/WhitespaceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1068,9 +1068,6 @@ void WhitespaceManager::alignArrayInitializersLeftJustified(
Changes[CellIter->Index].Spaces = CellDescs.InitialSpaces;
++CellIter;
for (auto i = 1U; i < CellDescs.CellCount; i++, ++CellIter) {
unsigned NetWidth = 0U;
if (isSplitCell(*CellIter))
NetWidth = getNetWidth(Cells.begin(), CellIter, CellDescs.InitialSpaces);
auto MaxNetWidth = getMaximumNetWidth(
Cells.begin(), CellIter, CellDescs.InitialSpaces, CellDescs.CellCount);
auto ThisNetWidth =
Expand Down
6 changes: 4 additions & 2 deletions clang/lib/Parse/ParseOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2708,7 +2708,8 @@ OMPClause *Parser::ParseOpenMPUsesAllocatorClause(OpenMPDirectiveKind DKind) {
return nullptr;
SmallVector<Sema::UsesAllocatorsData, 4> Data;
do {
ExprResult Allocator = ParseCXXIdExpression();
ExprResult Allocator =
getLangOpts().CPlusPlus ? ParseCXXIdExpression() : ParseExpression();
if (Allocator.isInvalid()) {
SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
StopBeforeMatch);
Expand All @@ -2720,7 +2721,8 @@ OMPClause *Parser::ParseOpenMPUsesAllocatorClause(OpenMPDirectiveKind DKind) {
BalancedDelimiterTracker T(*this, tok::l_paren,
tok::annot_pragma_openmp_end);
T.consumeOpen();
ExprResult AllocatorTraits = ParseCXXIdExpression();
ExprResult AllocatorTraits =
getLangOpts().CPlusPlus ? ParseCXXIdExpression() : ParseExpression();
T.consumeClose();
if (AllocatorTraits.isInvalid()) {
SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
Expand Down
7 changes: 3 additions & 4 deletions clang/lib/Sema/Sema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2029,10 +2029,9 @@ static void checkEscapingByref(VarDecl *VD, Sema &S) {
SourceLocation Loc = VD->getLocation();
Expr *VarRef =
new (S.Context) DeclRefExpr(S.Context, VD, false, T, VK_LValue, Loc);
ExprResult Result = S.PerformCopyInitialization(
InitializedEntity::InitializeBlock(Loc, T, false), SourceLocation(),
VarRef);

ExprResult Result = S.PerformMoveOrCopyInitialization(
InitializedEntity::InitializeBlock(Loc, T, false), VD, VD->getType(),
VarRef, /*AllowNRVO=*/true);
if (!Result.isInvalid()) {
Result = S.MaybeCreateExprWithCleanups(Result);
Expr *Init = Result.getAs<Expr>();
Expand Down
Loading

0 comments on commit 0b75243

Please sign in to comment.