Skip to content

Commit 3c2df0e

Browse files
committed
Merge commit '2f755c543ab357bd83235592fcee37fa391cdd9d' into llvmspirv_pulldown
2 parents 2349154 + 2f755c5 commit 3c2df0e

File tree

186 files changed

+16797
-2256
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+16797
-2256
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ Improvements to Clang's diagnostics
279279
- The :doc:`ThreadSafetyAnalysis` attributes ``ACQUIRED_BEFORE(...)`` and
280280
``ACQUIRED_AFTER(...)`` have been moved to the stable feature set and no
281281
longer require ``-Wthread-safety-beta`` to be used.
282+
- The :doc:`ThreadSafetyAnalysis` gains basic alias-analysis of capability
283+
pointers under ``-Wthread-safety-beta`` (still experimental), which reduces
284+
both false positives but also false negatives through more precise analysis.
282285

283286
Improvements to Clang's time-trace
284287
----------------------------------
@@ -308,6 +311,8 @@ Bug Fixes in This Version
308311
- Builtin elementwise operators now accept vector arguments that have different
309312
qualifiers on their elements. For example, vector of 4 ``const float`` values
310313
and vector of 4 ``float`` values. (#GH155405)
314+
- Fixed a failed assertion with a negative limit parameter value inside of
315+
``__has_embed``. (#GH157842)
311316

312317
Bug Fixes to Compiler Builtins
313318
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "llvm/ADT/PointerUnion.h"
3636
#include "llvm/ADT/SmallVector.h"
3737
#include "llvm/Support/Casting.h"
38+
#include <functional>
3839
#include <sstream>
3940
#include <string>
4041
#include <utility>
@@ -386,6 +387,11 @@ class SExprBuilder {
386387
SelfVar->setKind(til::Variable::VK_SFun);
387388
}
388389

390+
// Create placeholder for this: we don't know the VarDecl on construction yet.
391+
til::LiteralPtr *createThisPlaceholder() {
392+
return new (Arena) til::LiteralPtr(nullptr);
393+
}
394+
389395
// Translate a clang expression in an attribute to a til::SExpr.
390396
// Constructs the context from D, DeclExp, and SelfDecl.
391397
CapabilityExpr translateAttrExpr(const Expr *AttrExp, const NamedDecl *D,
@@ -394,8 +400,8 @@ class SExprBuilder {
394400

395401
CapabilityExpr translateAttrExpr(const Expr *AttrExp, CallingContext *Ctx);
396402

397-
// Translate a variable reference.
398-
til::LiteralPtr *createVariable(const VarDecl *VD);
403+
// Translate a VarDecl to its canonical TIL expression.
404+
til::SExpr *translateVariable(const VarDecl *VD, CallingContext *Ctx);
399405

400406
// Translate a clang statement or expression to a TIL expression.
401407
// Also performs substitution of variables; Ctx provides the context.
@@ -412,6 +418,10 @@ class SExprBuilder {
412418
const til::SCFG *getCFG() const { return Scfg; }
413419
til::SCFG *getCFG() { return Scfg; }
414420

421+
void setLookupLocalVarExpr(std::function<const Expr *(const NamedDecl *)> F) {
422+
LookupLocalVarExpr = std::move(F);
423+
}
424+
415425
private:
416426
// We implement the CFGVisitor API
417427
friend class CFGWalker;
@@ -445,6 +455,7 @@ class SExprBuilder {
445455
const AbstractConditionalOperator *C, CallingContext *Ctx);
446456

447457
til::SExpr *translateDeclStmt(const DeclStmt *S, CallingContext *Ctx);
458+
til::SExpr *translateStmtExpr(const StmtExpr *SE, CallingContext *Ctx);
448459

449460
// Map from statements in the clang CFG to SExprs in the til::SCFG.
450461
using StatementMap = llvm::DenseMap<const Stmt *, til::SExpr *>;
@@ -531,6 +542,11 @@ class SExprBuilder {
531542
std::vector<til::Phi *> IncompleteArgs;
532543
til::BasicBlock *CurrentBB = nullptr;
533544
BlockInfo *CurrentBlockInfo = nullptr;
545+
546+
// Recursion guard.
547+
llvm::DenseSet<const ValueDecl *> VarsBeingTranslated;
548+
// Context-dependent lookup of currently valid definitions of local variables.
549+
std::function<const Expr *(const NamedDecl *)> LookupLocalVarExpr;
534550
};
535551

536552
#ifndef NDEBUG

0 commit comments

Comments
 (0)