Skip to content

Commit

Permalink
merge master into amd-stg-open
Browse files Browse the repository at this point in the history
Change-Id: I16df3a4dffd5c2b8cb03697cf3858d85012b5e91
  • Loading branch information
Jenkins committed Jan 22, 2020
2 parents 222262d + b54aa05 commit 4eda3ee
Show file tree
Hide file tree
Showing 543 changed files with 3,974 additions and 2,612 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ void NoInternalDependenciesCheck::check(const MatchFinder::MatchResult &Result)
const auto *InternalDependency =
Result.Nodes.getNodeAs<NestedNameSpecifierLoc>("InternalDep");

diag(InternalDependency->getBeginLoc(),
SourceLocation LocAtFault =
Result.SourceManager->getSpellingLoc(InternalDependency->getBeginLoc());

if (!LocAtFault.isValid())
return;

diag(LocAtFault,
"do not reference any 'internal' namespaces; those implementation "
"details are reserved to Abseil");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static void replaceMoveWithForward(const UnresolvedLookupExpr *Callee,

if (CallRange.isValid()) {
const std::string TypeName =
TypeParmDecl->getIdentifier()
(TypeParmDecl->getIdentifier() && !TypeParmDecl->isImplicit())
? TypeParmDecl->getName().str()
: (llvm::Twine("decltype(") + ParmVar->getName() + ")").str();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ template <class P> P InternalTemplateFunction(P a) {}

namespace container_internal {
struct InternalStruct {};

template <typename T> struct InternalTemplate {};
} // namespace container_internal
} // namespace absl

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,18 @@ std::string Str = absl::StringsFunction("a");
void MacroUse() {
USE_INTERNAL(Function); // no-warning
USE_EXTERNAL(Function);
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil
// CHECK-MESSAGES: :[[@LINE-5]]:25: warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil
}

class A : absl::container_internal::InternalStruct {};
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil

template <typename T>
class B : absl::container_internal::InternalTemplate<T> {};
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil

template <typename T> class C : absl::container_internal::InternalTemplate<T> {
public:
template <typename U> static C Make(U *p) { return C{}; }
};
// CHECK-MESSAGES: :[[@LINE-4]]:33: warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil
3 changes: 2 additions & 1 deletion clang/examples/clang-interpreter/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class SimpleJIT {
MangleAndInterner Mangle{ES, DL};
JITDylib &MainJD{ES.createJITDylib("<main>")};
RTDyldObjectLinkingLayer ObjectLayer{ES, createMemMgr};
IRCompileLayer CompileLayer{ES, ObjectLayer, SimpleCompiler(*TM)};
IRCompileLayer CompileLayer{ES, ObjectLayer,
std::make_unique<SimpleCompiler>(*TM)};

static std::unique_ptr<SectionMemoryManager> createMemMgr() {
return std::make_unique<SectionMemoryManager>();
Expand Down
30 changes: 24 additions & 6 deletions clang/include/clang/AST/ASTConcept.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,23 @@ namespace clang {
class ConceptDecl;
class ConceptSpecializationExpr;

/// \brief The result of a constraint satisfaction check, containing the
/// necessary information to diagnose an unsatisfied constraint.
struct ConstraintSatisfaction {
/// The result of a constraint satisfaction check, containing the necessary
/// information to diagnose an unsatisfied constraint.
class ConstraintSatisfaction : public llvm::FoldingSetNode {
// The template-like entity that 'owns' the constraint checked here (can be a
// constrained entity or a concept).
NamedDecl *ConstraintOwner = nullptr;
llvm::SmallVector<TemplateArgument, 4> TemplateArgs;

public:

ConstraintSatisfaction() = default;

ConstraintSatisfaction(NamedDecl *ConstraintOwner,
ArrayRef<TemplateArgument> TemplateArgs) :
ConstraintOwner(ConstraintOwner), TemplateArgs(TemplateArgs.begin(),
TemplateArgs.end()) { }

using SubstitutionDiagnostic = std::pair<SourceLocation, StringRef>;
using Detail = llvm::PointerUnion<Expr *, SubstitutionDiagnostic *>;

Expand All @@ -38,9 +52,13 @@ struct ConstraintSatisfaction {
/// invalid expression.
llvm::SmallVector<std::pair<const Expr *, Detail>, 4> Details;

// This can leak if used in an AST node, use ASTConstraintSatisfaction
// instead.
void *operator new(size_t bytes, ASTContext &C) = delete;
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &C) {
Profile(ID, C, ConstraintOwner, TemplateArgs);
}

static void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &C,
NamedDecl *ConstraintOwner,
ArrayRef<TemplateArgument> TemplateArgs);
};

/// Pairs of unsatisfied atomic constraint expressions along with the
Expand Down
4 changes: 0 additions & 4 deletions clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -2567,10 +2567,6 @@ def Capability : InheritableAttr {
let Accessors = [Accessor<"isShared",
[Clang<"shared_capability", 0>]>];
let Documentation = [Undocumented];
let AdditionalMembers = [{
bool isMutex() const { return getName().equals_lower("mutex"); }
bool isRole() const { return getName().equals_lower("role"); }
}];
}

def AssertCapability : InheritableAttr {
Expand Down
41 changes: 22 additions & 19 deletions clang/include/clang/Basic/AttrDocs.td
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ The ``sycl_kernel`` attribute specifies that a function template will be used
to outline device code and to generate an OpenCL kernel.
Here is a code example of the SYCL program, which demonstrates the compiler's
outlining job:

.. code-block:: c++

int foo(int x) { return ++x; }
Expand All @@ -282,27 +283,29 @@ compilation of functions for the device part can be found in the SYCL 1.2.1
specification Section 6.4.
To show to the compiler entry point to the "device part" of the code, the SYCL
runtime can use the ``sycl_kernel`` attribute in the following way:

.. code-block:: c++
namespace cl {
namespace sycl {
class handler {
template <typename KernelName, typename KernelType/*, ...*/>
__attribute__((sycl_kernel)) void sycl_kernel_function(KernelType KernelFuncObj) {
// ...
KernelFuncObj();
}

template <typename KernelName, typename KernelType, int Dims>
void parallel_for(range<Dims> NumWorkItems, KernelType KernelFunc) {
#ifdef __SYCL_DEVICE_ONLY__
sycl_kernel_function<KernelName, KernelType, Dims>(KernelFunc);
#else
// Host implementation
#endif
}
};
} // namespace sycl
} // namespace cl
namespace cl {
namespace sycl {
class handler {
template <typename KernelName, typename KernelType/*, ...*/>
__attribute__((sycl_kernel)) void sycl_kernel_function(KernelType KernelFuncObj) {
// ...
KernelFuncObj();
}

template <typename KernelName, typename KernelType, int Dims>
void parallel_for(range<Dims> NumWorkItems, KernelType KernelFunc) {
#ifdef __SYCL_DEVICE_ONLY__
sycl_kernel_function<KernelName, KernelType, Dims>(KernelFunc);
#else
// Host implementation
#endif
}
};
} // namespace sycl
} // namespace cl

The compiler will also generate an OpenCL kernel using the function marked with
the ``sycl_kernel`` attribute.
Expand Down
3 changes: 0 additions & 3 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -3252,9 +3252,6 @@ def warn_at_available_unchecked_use : Warning<
InGroup<DiagGroup<"unsupported-availability-guard">>;

// Thread Safety Attributes
def warn_invalid_capability_name : Warning<
"invalid capability name '%0'; capability name must be 'mutex' or 'role'">,
InGroup<ThreadSafetyAttributes>, DefaultIgnore;
def warn_thread_attribute_ignored : Warning<
"ignoring %0 attribute because its argument is invalid">,
InGroup<ThreadSafetyAttributes>, DefaultIgnore;
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/Basic/LangOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ LANGOPT(AlignedAllocation , 1, 0, "aligned allocation")
LANGOPT(AlignedAllocationUnavailable, 1, 0, "aligned allocation functions are unavailable")
LANGOPT(NewAlignOverride , 32, 0, "maximum alignment guaranteed by '::operator new(size_t)'")
LANGOPT(ConceptsTS , 1, 0, "enable C++ Extensions for Concepts")
LANGOPT(ConceptSatisfactionCaching , 1, 1, "enable satisfaction caching for C++2a Concepts")
BENIGN_LANGOPT(ModulesCodegen , 1, 0, "Modules code generation")
BENIGN_LANGOPT(ModulesDebugInfo , 1, 0, "Modules debug info")
BENIGN_LANGOPT(ElideConstructors , 1, 1, "C++ copy constructor elision")
Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/Driver/CC1Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,9 @@ def ftest_module_file_extension_EQ :
"The argument is parsed as blockname:major:minor:hashed:user info">;
def fconcepts_ts : Flag<["-"], "fconcepts-ts">,
HelpText<"Enable C++ Extensions for Concepts.">;
def fno_concept_satisfaction_caching : Flag<["-"],
"fno-concept-satisfaction-caching">,
HelpText<"Disable satisfaction caching for C++2a Concepts.">;

let Group = Action_Group in {

Expand Down
26 changes: 9 additions & 17 deletions clang/include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -6200,6 +6200,9 @@ class Sema final {
llvm::DenseMap<NamedDecl *, NormalizedConstraint *>
NormalizationCache;

llvm::ContextualFoldingSet<ConstraintSatisfaction, const ASTContext &>
SatisfactionCache;

public:
const NormalizedConstraint *
getNormalizedAssociatedConstraints(
Expand All @@ -6226,6 +6229,8 @@ class Sema final {

/// \brief Check whether the given list of constraint expressions are
/// satisfied (as if in a 'conjunction') given template arguments.
/// \param Template the template-like entity that triggered the constraints
/// check (either a concept or a constrained entity).
/// \param ConstraintExprs a list of constraint expressions, treated as if
/// they were 'AND'ed together.
/// \param TemplateArgs the list of template arguments to substitute into the
Expand All @@ -6237,23 +6242,10 @@ class Sema final {
/// expression.
/// \returns true if an error occurred and satisfaction could not be checked,
/// false otherwise.
bool CheckConstraintSatisfaction(TemplateDecl *Template,
ArrayRef<const Expr *> ConstraintExprs,
ArrayRef<TemplateArgument> TemplateArgs,
SourceRange TemplateIDRange,
ConstraintSatisfaction &Satisfaction);

bool CheckConstraintSatisfaction(ClassTemplatePartialSpecializationDecl *TD,
ArrayRef<const Expr *> ConstraintExprs,
ArrayRef<TemplateArgument> TemplateArgs,
SourceRange TemplateIDRange,
ConstraintSatisfaction &Satisfaction);

bool CheckConstraintSatisfaction(VarTemplatePartialSpecializationDecl *TD,
ArrayRef<const Expr *> ConstraintExprs,
ArrayRef<TemplateArgument> TemplateArgs,
SourceRange TemplateIDRange,
ConstraintSatisfaction &Satisfaction);
bool CheckConstraintSatisfaction(
NamedDecl *Template, ArrayRef<const Expr *> ConstraintExprs,
ArrayRef<TemplateArgument> TemplateArgs,
SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction);

/// \brief Check whether the given non-dependent constraint expression is
/// satisfied. Returns false and updates Satisfaction with the satisfaction
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/Sema/TemplateDeduction.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define LLVM_CLANG_SEMA_TEMPLATEDEDUCTION_H

#include "clang/Sema/Ownership.h"
#include "clang/Sema/SemaConcept.h"
#include "clang/AST/ASTConcept.h"
#include "clang/AST/DeclAccessPair.h"
#include "clang/AST/DeclTemplate.h"
Expand Down
13 changes: 13 additions & 0 deletions clang/lib/AST/ASTConcept.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

#include "clang/AST/ASTConcept.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/AST/TemplateBase.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/FoldingSet.h"
using namespace clang;

ASTConstraintSatisfaction::ASTConstraintSatisfaction(const ASTContext &C,
Expand Down Expand Up @@ -53,3 +57,12 @@ ASTConstraintSatisfaction::Create(const ASTContext &C,
void *Mem = C.Allocate(size, alignof(ASTConstraintSatisfaction));
return new (Mem) ASTConstraintSatisfaction(C, Satisfaction);
}

void ConstraintSatisfaction::Profile(
llvm::FoldingSetNodeID &ID, const ASTContext &C, NamedDecl *ConstraintOwner,
ArrayRef<TemplateArgument> TemplateArgs) {
ID.AddPointer(ConstraintOwner);
ID.AddInteger(TemplateArgs.size());
for (auto &Arg : TemplateArgs)
Arg.Profile(ID, C);
}
8 changes: 4 additions & 4 deletions clang/lib/CodeGen/CGCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2440,9 +2440,8 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
EmitScalarExpr(AVAttr->getAlignment());
llvm::ConstantInt *AlignmentCI =
cast<llvm::ConstantInt>(AlignmentValue);
unsigned Alignment = std::min((unsigned)AlignmentCI->getZExtValue(),
+llvm::Value::MaximumAlignment);
AI->addAttrs(llvm::AttrBuilder().addAlignmentAttr(Alignment));
AI->addAttrs(llvm::AttrBuilder().addAlignmentAttr(llvm::MaybeAlign(
AlignmentCI->getLimitedValue(llvm::Value::MaximumAlignment))));
}
}

Expand Down Expand Up @@ -4628,7 +4627,8 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
llvm::ConstantInt *AlignmentCI = cast<llvm::ConstantInt>(Alignment);
EmitAlignmentAssumption(Ret.getScalarVal(), RetTy, Loc, AA->getLocation(),
AlignmentCI, OffsetValue);
} else if (const auto *AA = TargetDecl->getAttr<AllocAlignAttr>()) {
}
if (const auto *AA = TargetDecl->getAttr<AllocAlignAttr>()) {
llvm::Value *AlignmentVal = CallArgs[AA->getParamIndex().getLLVMIndex()]
.getRValue(*this)
.getScalarVal();
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/Compilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ int Compilation::ExecuteCommand(const Command &C,
}

if (getDriver().CCPrintOptions)
*OS << "[Logging clang options]";
*OS << "[Logging clang options]\n";

C.Print(*OS, "\n", /*Quote=*/getDriver().CCPrintOptions);
}
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Driver/ToolChains/Darwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,6 @@ void Darwin::addProfileRTLibs(const ArgList &Args,
} else {
addExportedSymbol(CmdArgs, "___llvm_profile_filename");
addExportedSymbol(CmdArgs, "___llvm_profile_raw_version");
addExportedSymbol(CmdArgs, "___llvm_profile_counter_bias");
}
addExportedSymbol(CmdArgs, "_lprofDirMode");
}
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2854,6 +2854,8 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
Opts.NewAlignOverride = 0;
}
Opts.ConceptsTS = Args.hasArg(OPT_fconcepts_ts);
Opts.ConceptSatisfactionCaching =
!Args.hasArg(OPT_fno_concept_satisfaction_caching);
Opts.HeinousExtensions = Args.hasArg(OPT_fheinous_gnu_extensions);
Opts.AccessControl = !Args.hasArg(OPT_fno_access_control);
Opts.ElideConstructors = !Args.hasArg(OPT_fno_elide_constructors);
Expand Down
16 changes: 12 additions & 4 deletions clang/lib/Sema/Sema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
TUKind(TUKind), NumSFINAEErrors(0),
FullyCheckedComparisonCategories(
static_cast<unsigned>(ComparisonCategoryType::Last) + 1),
AccessCheckingSFINAE(false), InNonInstantiationSFINAEContext(false),
NonInstantiationEntries(0), ArgumentPackSubstitutionIndex(-1),
CurrentInstantiationScope(nullptr), DisableTypoCorrection(false),
TyposCorrected(0), AnalysisWarnings(*this),
SatisfactionCache(Context), AccessCheckingSFINAE(false),
InNonInstantiationSFINAEContext(false), NonInstantiationEntries(0),
ArgumentPackSubstitutionIndex(-1), CurrentInstantiationScope(nullptr),
DisableTypoCorrection(false), TyposCorrected(0), AnalysisWarnings(*this),
ThreadSafetyDeclCache(nullptr), VarDataSharingAttributesStack(nullptr),
CurScope(nullptr), Ident_super(nullptr), Ident___float128(nullptr) {
TUScope = nullptr;
Expand Down Expand Up @@ -379,6 +379,14 @@ Sema::~Sema() {
if (isMultiplexExternalSource)
delete ExternalSource;

// Delete cached satisfactions.
std::vector<ConstraintSatisfaction *> Satisfactions;
Satisfactions.reserve(Satisfactions.size());
for (auto &Node : SatisfactionCache)
Satisfactions.push_back(&Node);
for (auto *Node : Satisfactions)
delete Node;

threadSafety::threadSafetyCleanup(ThreadSafetyDeclCache);

// Destroys data sharing attributes stack for OpenMP
Expand Down
Loading

0 comments on commit 4eda3ee

Please sign in to comment.