Skip to content

Commit 7bd9143

Browse files
committed
Merge from 'master' to 'sycl-web' (intel#36)
2 parents e42a6f0 + 1b2842b commit 7bd9143

File tree

476 files changed

+3979
-5329
lines changed

Some content is hidden

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

476 files changed

+3979
-5329
lines changed

clang-tools-extra/clangd/AST.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,12 @@ bool isImplementationDetail(const Decl *D) {
156156
D->getASTContext().getSourceManager());
157157
}
158158

159-
SourceLocation findName(const clang::Decl *D) { return D->getLocation(); }
159+
SourceLocation nameLocation(const clang::Decl &D, const SourceManager &SM) {
160+
auto L = D.getLocation();
161+
if (isSpelledInSource(L, SM))
162+
return SM.getSpellingLoc(L);
163+
return SM.getExpansionLoc(L);
164+
}
160165

161166
std::string printQualifiedName(const NamedDecl &ND) {
162167
std::string QName;

clang-tools-extra/clangd/AST.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ namespace clangd {
3434
/// in code is considered implementation detail.
3535
bool isImplementationDetail(const Decl *D);
3636

37-
/// Find the identifier source location of the given D.
38-
///
39-
/// The returned location is usually the spelling location where the name of the
40-
/// decl occurs in the code.
41-
SourceLocation findName(const clang::Decl *D);
37+
/// Find the source location of the identifier for \p D.
38+
/// Transforms macro locations to locations spelled inside files. All code
39+
/// that needs locations of declaration names (e.g. the index) should go through
40+
/// this function.
41+
SourceLocation nameLocation(const clang::Decl &D, const SourceManager &SM);
4242

4343
/// Returns the qualified name of ND. The scope doesn't contain unwritten scopes
4444
/// like inline namespaces.

clang-tools-extra/clangd/FindSymbols.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ namespace {
131131
llvm::Optional<DocumentSymbol> declToSym(ASTContext &Ctx, const NamedDecl &ND) {
132132
auto &SM = Ctx.getSourceManager();
133133

134-
SourceLocation NameLoc = spellingLocIfSpelled(findName(&ND), SM);
134+
SourceLocation NameLoc = nameLocation(ND, SM);
135135
// getFileLoc is a good choice for us, but we also need to make sure
136136
// sourceLocToPosition won't switch files, so we call getSpellingLoc on top of
137137
// that to make sure it does not switch files.

clang-tools-extra/clangd/SourceCode.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,6 @@ bool isSpelledInSource(SourceLocation Loc, const SourceManager &SM) {
224224
return true;
225225
}
226226

227-
SourceLocation spellingLocIfSpelled(SourceLocation Loc,
228-
const SourceManager &SM) {
229-
if (!isSpelledInSource(Loc, SM))
230-
// Use the expansion location as spelling location is not interesting.
231-
return SM.getExpansionRange(Loc).getBegin();
232-
return SM.getSpellingLoc(Loc);
233-
}
234-
235227
llvm::Optional<Range> getTokenRange(const SourceManager &SM,
236228
const LangOptions &LangOpts,
237229
SourceLocation TokLoc) {

clang-tools-extra/clangd/SourceCode.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,6 @@ SourceLocation includeHashLoc(FileID IncludedFile, const SourceManager &SM);
107107
/// `-DName=foo`, the spelling location will be "<command line>".
108108
bool isSpelledInSource(SourceLocation Loc, const SourceManager &SM);
109109

110-
/// Returns the spelling location of the token at Loc if isSpelledInSource,
111-
/// otherwise its expansion location.
112-
/// FIXME: Most callers likely want some variant of "file location" instead.
113-
SourceLocation spellingLocIfSpelled(SourceLocation Loc,
114-
const SourceManager &SM);
115-
116110
/// Turns a token range into a half-open range and checks its correctness.
117111
/// The resulting range will have only valid source location on both sides, both
118112
/// of which are file locations.

clang-tools-extra/clangd/XRefs.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,7 @@ std::vector<LocatedSymbol> locateSymbolAt(ParsedAST &AST, Position Pos,
246246
}
247247
}
248248

249-
auto Loc = makeLocation(AST.getASTContext(),
250-
spellingLocIfSpelled(findName(Preferred), SM),
249+
auto Loc = makeLocation(AST.getASTContext(), nameLocation(*Preferred, SM),
251250
*MainFilePath);
252251
if (!Loc)
253252
continue;
@@ -535,8 +534,7 @@ static llvm::Optional<TypeHierarchyItem>
535534
declToTypeHierarchyItem(ASTContext &Ctx, const NamedDecl &ND) {
536535
auto &SM = Ctx.getSourceManager();
537536

538-
SourceLocation NameLoc =
539-
spellingLocIfSpelled(findName(&ND), Ctx.getSourceManager());
537+
SourceLocation NameLoc = nameLocation(ND, Ctx.getSourceManager());
540538
// getFileLoc is a good choice for us, but we also need to make sure
541539
// sourceLocToPosition won't switch files, so we call getSpellingLoc on top of
542540
// that to make sure it does not switch files.

clang-tools-extra/clangd/index/SymbolCollector.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static const char *PROTO_HEADER_COMMENT =
8282
// filters.
8383
bool isPrivateProtoDecl(const NamedDecl &ND) {
8484
const auto &SM = ND.getASTContext().getSourceManager();
85-
auto Loc = spellingLocIfSpelled(findName(&ND), SM);
85+
auto Loc = nameLocation(ND, SM);
8686
auto FileName = SM.getFilename(Loc);
8787
if (!FileName.endswith(".proto.h") && !FileName.endswith(".pb.h"))
8888
return false;
@@ -595,7 +595,7 @@ const Symbol *SymbolCollector::addDeclaration(const NamedDecl &ND, SymbolID ID,
595595
S.Flags |= Symbol::VisibleOutsideFile;
596596
S.SymInfo = index::getSymbolInfo(&ND);
597597
std::string FileURI;
598-
auto Loc = spellingLocIfSpelled(findName(&ND), SM);
598+
auto Loc = nameLocation(ND, SM);
599599
assert(Loc.isValid() && "Invalid source location for NamedDecl");
600600
// FIXME: use the result to filter out symbols.
601601
shouldIndexFile(SM.getFileID(Loc));
@@ -656,7 +656,7 @@ void SymbolCollector::addDefinition(const NamedDecl &ND,
656656
Symbol S = DeclSym;
657657
std::string FileURI;
658658
const auto &SM = ND.getASTContext().getSourceManager();
659-
auto Loc = spellingLocIfSpelled(findName(&ND), SM);
659+
auto Loc = nameLocation(ND, SM);
660660
// FIXME: use the result to filter out symbols.
661661
shouldIndexFile(SM.getFileID(Loc));
662662
if (auto DefLoc =

clang-tools-extra/test/clang-tidy/checkers/cert-mem57-cpp-cpp17.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %check_clang_tidy %s -std=c++14 cert-mem57-cpp %t
2-
// RUN: clang-tidy --extra-arg='-std=c++17' --extra-arg='-faligned-allocation' -checks='-*,cert-mem57-cpp' --warnings-as-errors='*' %s
3-
// RUN: clang-tidy --extra-arg='-std=c++2a' --extra-arg='-faligned-allocation' -checks='-*,cert-mem57-cpp' --warnings-as-errors='*' %s
2+
// RUN: clang-tidy --extra-arg='-std=c++17' --extra-arg='-faligned-allocation' -checks='-*,cert-mem57-cpp' --extra-arg=-Wno-unused-variable --warnings-as-errors='*' %s
3+
// RUN: clang-tidy --extra-arg='-std=c++2a' --extra-arg='-faligned-allocation' -checks='-*,cert-mem57-cpp' --extra-arg=-Wno-unused-variable --warnings-as-errors='*' %s
44

55
struct alignas(128) Vector {
66
char Elems[128];

clang/docs/ClangCommandLineReference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1701,7 +1701,7 @@ Emit OpenMP code only for SIMD-based constructs.
17011701

17021702
.. option:: -foptimization-record-file=<arg>
17031703

1704-
Specify the file name of any generated YAML optimization record
1704+
Specify the output name of the file containing the optimization remarks. Implies -fsave-optimization-record. On Darwin platforms, this cannot be used with multiple -arch <arch> options.
17051705

17061706
.. option:: -foptimize-sibling-calls, -fno-optimize-sibling-calls
17071707

clang/include/clang/AST/Decl.h

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "clang/AST/APValue.h"
1717
#include "clang/AST/ASTContextAllocate.h"
18+
#include "clang/AST/DeclAccessPair.h"
1819
#include "clang/AST/DeclBase.h"
1920
#include "clang/AST/DeclarationName.h"
2021
#include "clang/AST/ExternalASTSource.h"
@@ -1812,13 +1813,37 @@ class FunctionDecl : public DeclaratorDecl,
18121813
TK_DependentFunctionTemplateSpecialization
18131814
};
18141815

1816+
/// Stashed information about a defaulted function definition whose body has
1817+
/// not yet been lazily generated.
1818+
class DefaultedFunctionInfo final
1819+
: llvm::TrailingObjects<DefaultedFunctionInfo, DeclAccessPair> {
1820+
friend TrailingObjects;
1821+
unsigned NumLookups;
1822+
1823+
public:
1824+
static DefaultedFunctionInfo *Create(ASTContext &Context,
1825+
ArrayRef<DeclAccessPair> Lookups);
1826+
/// Get the unqualified lookup results that should be used in this
1827+
/// defaulted function definition.
1828+
ArrayRef<DeclAccessPair> getUnqualifiedLookups() const {
1829+
return {getTrailingObjects<DeclAccessPair>(), NumLookups};
1830+
}
1831+
};
1832+
18151833
private:
18161834
/// A new[]'d array of pointers to VarDecls for the formal
18171835
/// parameters of this function. This is null if a prototype or if there are
18181836
/// no formals.
18191837
ParmVarDecl **ParamInfo = nullptr;
18201838

1821-
LazyDeclStmtPtr Body;
1839+
/// The active member of this union is determined by
1840+
/// FunctionDeclBits.HasDefaultedFunctionInfo.
1841+
union {
1842+
/// The body of the function.
1843+
LazyDeclStmtPtr Body;
1844+
/// Information about a future defaulted function definition.
1845+
DefaultedFunctionInfo *DefaultedInfo;
1846+
};
18221847

18231848
unsigned ODRHash;
18241849

@@ -2050,17 +2075,25 @@ class FunctionDecl : public DeclaratorDecl,
20502075
/// parser reaches the definition, if called before, this function will return
20512076
/// `false`.
20522077
bool isThisDeclarationADefinition() const {
2053-
return isDeletedAsWritten() || isDefaulted() || Body || hasSkippedBody() ||
2054-
isLateTemplateParsed() || willHaveBody() || hasDefiningAttr();
2078+
return isDeletedAsWritten() || isDefaulted() ||
2079+
doesThisDeclarationHaveABody() || hasSkippedBody() ||
2080+
willHaveBody() || hasDefiningAttr();
20552081
}
20562082

20572083
/// Returns whether this specific declaration of the function has a body.
20582084
bool doesThisDeclarationHaveABody() const {
2059-
return Body || isLateTemplateParsed();
2085+
return (!FunctionDeclBits.HasDefaultedFunctionInfo && Body) ||
2086+
isLateTemplateParsed();
20602087
}
20612088

20622089
void setBody(Stmt *B);
2063-
void setLazyBody(uint64_t Offset) { Body = Offset; }
2090+
void setLazyBody(uint64_t Offset) {
2091+
FunctionDeclBits.HasDefaultedFunctionInfo = false;
2092+
Body = LazyDeclStmtPtr(Offset);
2093+
}
2094+
2095+
void setDefaultedFunctionInfo(DefaultedFunctionInfo *Info);
2096+
DefaultedFunctionInfo *getDefaultedFunctionInfo() const;
20642097

20652098
/// Whether this function is variadic.
20662099
bool isVariadic() const;

clang/include/clang/AST/DeclBase.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,10 +1501,9 @@ class DeclContext {
15011501
/// constructor or a destructor.
15021502
uint64_t IsTrivialForCall : 1;
15031503

1504-
/// Used by CXXMethodDecl
15051504
uint64_t IsDefaulted : 1;
1506-
/// Used by CXXMethodDecl
15071505
uint64_t IsExplicitlyDefaulted : 1;
1506+
uint64_t HasDefaultedFunctionInfo : 1;
15081507
uint64_t HasImplicitReturnZero : 1;
15091508
uint64_t IsLateTemplateParsed : 1;
15101509

@@ -1540,7 +1539,7 @@ class DeclContext {
15401539
};
15411540

15421541
/// Number of non-inherited bits in FunctionDeclBitfields.
1543-
enum { NumFunctionDeclBits = 26 };
1542+
enum { NumFunctionDeclBits = 27 };
15441543

15451544
/// Stores the bits used by CXXConstructorDecl. If modified
15461545
/// NumCXXConstructorDeclBits and the accessor
@@ -1557,7 +1556,7 @@ class DeclContext {
15571556
/// exactly 64 bits and thus the width of NumCtorInitializers
15581557
/// will need to be shrunk if some bit is added to NumDeclContextBitfields,
15591558
/// NumFunctionDeclBitfields or CXXConstructorDeclBitfields.
1560-
uint64_t NumCtorInitializers : 22;
1559+
uint64_t NumCtorInitializers : 21;
15611560
uint64_t IsInheritingConstructor : 1;
15621561

15631562
/// Whether this constructor has a trail-allocated explicit specifier.

clang/include/clang/AST/OpenMPClause.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,17 @@ class OMPClauseWithPreInit {
111111
Stmt *PreInit = nullptr;
112112

113113
/// Region that captures the associated stmt.
114-
OpenMPDirectiveKind CaptureRegion = OMPD_unknown;
114+
OpenMPDirectiveKind CaptureRegion = llvm::omp::OMPD_unknown;
115115

116116
protected:
117117
OMPClauseWithPreInit(const OMPClause *This) {
118118
assert(get(This) && "get is not tuned for pre-init.");
119119
}
120120

121121
/// Set pre-initialization statement for the clause.
122-
void setPreInitStmt(Stmt *S, OpenMPDirectiveKind ThisRegion = OMPD_unknown) {
122+
void
123+
setPreInitStmt(Stmt *S,
124+
OpenMPDirectiveKind ThisRegion = llvm::omp::OMPD_unknown) {
123125
PreInit = S;
124126
CaptureRegion = ThisRegion;
125127
}
@@ -432,7 +434,7 @@ class OMPIfClause : public OMPClause, public OMPClauseWithPreInit {
432434
SourceLocation ColonLoc;
433435

434436
/// Directive name modifier for the clause.
435-
OpenMPDirectiveKind NameModifier = OMPD_unknown;
437+
OpenMPDirectiveKind NameModifier = llvm::omp::OMPD_unknown;
436438

437439
/// Name modifier location.
438440
SourceLocation NameModifierLoc;

0 commit comments

Comments
 (0)