Skip to content

Commit 8d0816e

Browse files
committed
Merge from 'main' to 'sycl-web' (#48)
CONFLICT (content): Merge conflict in clang/lib/Frontend/CompilerInvocation.cpp CONFLICT (content): Merge conflict in clang/include/clang/Driver/Options.td
2 parents 659b778 + 77db83a commit 8d0816e

File tree

216 files changed

+3267
-2472
lines changed

Some content is hidden

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

216 files changed

+3267
-2472
lines changed

clang-tools-extra/clangd/ClangdServer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,8 @@ void ClangdServer::switchSourceHeader(
549549
// the same directory.
550550
// 2) if 1) fails, we use the AST&Index approach, it is slower but supports
551551
// different code layout.
552-
if (auto CorrespondingFile = getCorrespondingHeaderOrSource(
553-
std::string(Path), TFS.view(llvm::None)))
552+
if (auto CorrespondingFile =
553+
getCorrespondingHeaderOrSource(Path, TFS.view(llvm::None)))
554554
return CB(std::move(CorrespondingFile));
555555
auto Action = [Path = Path.str(), CB = std::move(CB),
556556
this](llvm::Expected<InputsAndAST> InpAST) mutable {

clang-tools-extra/clangd/HeaderSourceSwitch.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ namespace clang {
1717
namespace clangd {
1818

1919
llvm::Optional<Path> getCorrespondingHeaderOrSource(
20-
const Path &OriginalFile,
21-
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
20+
PathRef OriginalFile, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
2221
llvm::StringRef SourceExtensions[] = {".cpp", ".c", ".cc", ".cxx",
2322
".c++", ".m", ".mm"};
2423
llvm::StringRef HeaderExtensions[] = {".h", ".hh", ".hpp", ".hxx", ".inc"};
@@ -51,25 +50,23 @@ llvm::Optional<Path> getCorrespondingHeaderOrSource(
5150
NewExts = SourceExtensions;
5251

5352
// Storage for the new path.
54-
llvm::SmallString<128> NewPath = llvm::StringRef(OriginalFile);
53+
llvm::SmallString<128> NewPath = OriginalFile;
5554

5655
// Loop through switched extension candidates.
5756
for (llvm::StringRef NewExt : NewExts) {
5857
llvm::sys::path::replace_extension(NewPath, NewExt);
5958
if (VFS->exists(NewPath))
60-
return NewPath.str().str(); // First str() to convert from SmallString to
61-
// StringRef, second to convert from StringRef
62-
// to std::string
59+
return Path(NewPath);
6360

6461
// Also check NewExt in upper-case, just in case.
6562
llvm::sys::path::replace_extension(NewPath, NewExt.upper());
6663
if (VFS->exists(NewPath))
67-
return NewPath.str().str();
64+
return Path(NewPath);
6865
}
6966
return None;
7067
}
7168

72-
llvm::Optional<Path> getCorrespondingHeaderOrSource(const Path &OriginalFile,
69+
llvm::Optional<Path> getCorrespondingHeaderOrSource(PathRef OriginalFile,
7370
ParsedAST &AST,
7471
const SymbolIndex *Index) {
7572
if (!Index) {
@@ -121,7 +118,7 @@ llvm::Optional<Path> getCorrespondingHeaderOrSource(const Path &OriginalFile,
121118
// candidates.
122119
Best = It;
123120
}
124-
return Path(std::string(Best->first()));
121+
return Path(Best->first());
125122
}
126123

127124
std::vector<const Decl *> getIndexableLocalDecls(ParsedAST &AST) {

clang-tools-extra/clangd/HeaderSourceSwitch.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ namespace clangd {
1818
/// Given a header file, returns the best matching source file, and vice visa.
1919
/// It only uses the filename heuristics to do the inference.
2020
llvm::Optional<Path> getCorrespondingHeaderOrSource(
21-
const Path &OriginalFile,
22-
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS);
21+
PathRef OriginalFile, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS);
2322

2423
/// Given a header file, returns the best matching source file, and vice visa.
2524
/// The heuristics incorporate with the AST and the index (if provided).
26-
llvm::Optional<Path> getCorrespondingHeaderOrSource(const Path &OriginalFile,
25+
llvm::Optional<Path> getCorrespondingHeaderOrSource(PathRef OriginalFile,
2726
ParsedAST &AST,
2827
const SymbolIndex *Index);
2928

clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,10 @@ const FunctionDecl *getSelectedFunction(const SelectionTree::Node *SelNode) {
6565
llvm::Optional<Path> getSourceFile(llvm::StringRef FileName,
6666
const Tweak::Selection &Sel) {
6767
if (auto Source = getCorrespondingHeaderOrSource(
68-
std::string(FileName),
68+
FileName,
6969
&Sel.AST->getSourceManager().getFileManager().getVirtualFileSystem()))
7070
return *Source;
71-
return getCorrespondingHeaderOrSource(std::string(FileName), *Sel.AST,
72-
Sel.Index);
71+
return getCorrespondingHeaderOrSource(FileName, *Sel.AST, Sel.Index);
7372
}
7473

7574
// Synthesize a DeclContext for TargetNS from CurContext. TargetNS must be empty

clang/include/clang/AST/APValue.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
#include "llvm/Support/AlignOf.h"
2424

2525
namespace clang {
26+
namespace serialization {
27+
template <typename T> class BasicReaderBase;
28+
} // end namespace serialization
29+
2630
class AddrLabelExpr;
2731
class ASTContext;
2832
class CharUnits;
@@ -233,12 +237,20 @@ class APValue {
233237
return llvm::hash_value(A.Value);
234238
}
235239
};
240+
class LValuePathSerializationHelper {
241+
const void *ElemTy;
242+
243+
public:
244+
ArrayRef<LValuePathEntry> Path;
245+
246+
LValuePathSerializationHelper(ArrayRef<LValuePathEntry>, QualType);
247+
QualType getType();
248+
};
236249
struct NoLValuePath {};
237250
struct UninitArray {};
238251
struct UninitStruct {};
239252

240-
friend class ASTRecordReader;
241-
friend class ASTWriter;
253+
template <typename Impl> friend class clang::serialization::BasicReaderBase;
242254
friend class ASTImporter;
243255
friend class ASTNodeImporter;
244256

clang/include/clang/AST/AbstractBasicReader.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,40 @@ class DataStreamBasicReader : public BasicReaderBase<Impl> {
177177
return llvm::APInt(bitWidth, numWords, &data[0]);
178178
}
179179

180+
llvm::FixedPointSemantics readFixedPointSemantics() {
181+
unsigned width = asImpl().readUInt32();
182+
unsigned scale = asImpl().readUInt32();
183+
unsigned tmp = asImpl().readUInt32();
184+
bool isSigned = tmp & 0x1;
185+
bool isSaturated = tmp & 0x2;
186+
bool hasUnsignedPadding = tmp & 0x4;
187+
return llvm::FixedPointSemantics(width, scale, isSigned, isSaturated,
188+
hasUnsignedPadding);
189+
}
190+
191+
APValue::LValuePathSerializationHelper readLValuePathSerializationHelper(
192+
SmallVectorImpl<APValue::LValuePathEntry> &path) {
193+
auto elemTy = asImpl().readQualType();
194+
unsigned pathLength = asImpl().readUInt32();
195+
for (unsigned i = 0; i < pathLength; ++i) {
196+
if (elemTy->template getAs<RecordType>()) {
197+
unsigned int_ = asImpl().readUInt32();
198+
Decl *decl = asImpl().template readDeclAs<Decl>();
199+
if (auto *recordDecl = dyn_cast<CXXRecordDecl>(decl))
200+
elemTy = getASTContext().getRecordType(recordDecl);
201+
else
202+
elemTy = cast<ValueDecl>(decl)->getType();
203+
path.push_back(
204+
APValue::LValuePathEntry(APValue::BaseOrMemberType(decl, int_)));
205+
} else {
206+
elemTy = getASTContext().getAsArrayType(elemTy)->getElementType();
207+
path.push_back(
208+
APValue::LValuePathEntry::ArrayIndex(asImpl().readUInt32()));
209+
}
210+
}
211+
return APValue::LValuePathSerializationHelper(path, elemTy);
212+
}
213+
180214
Qualifiers readQualifiers() {
181215
static_assert(sizeof(Qualifiers().getAsOpaqueValue()) <= sizeof(uint32_t),
182216
"update this if the value size changes");

clang/include/clang/AST/AbstractBasicWriter.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef CLANG_AST_ABSTRACTBASICWRITER_H
1010
#define CLANG_AST_ABSTRACTBASICWRITER_H
1111

12+
#include "clang/AST/ASTContext.h"
1213
#include "clang/AST/DeclTemplate.h"
1314

1415
namespace clang {
@@ -121,6 +122,7 @@ template <class Impl>
121122
class DataStreamBasicWriter : public BasicWriterBase<Impl> {
122123
protected:
123124
using BasicWriterBase<Impl>::asImpl;
125+
DataStreamBasicWriter(ASTContext &ctx) : BasicWriterBase<Impl>(ctx) {}
124126

125127
public:
126128
/// Implement property-find by ignoring it. We rely on properties being
@@ -163,6 +165,39 @@ class DataStreamBasicWriter : public BasicWriterBase<Impl> {
163165
asImpl().writeUInt64(words[i]);
164166
}
165167

168+
void writeFixedPointSemantics(const llvm::FixedPointSemantics &sema) {
169+
asImpl().writeUInt32(sema.getWidth());
170+
asImpl().writeUInt32(sema.getScale());
171+
asImpl().writeUInt32(sema.isSigned() | sema.isSaturated() << 1 |
172+
sema.hasUnsignedPadding() << 2);
173+
}
174+
175+
void writeLValuePathSerializationHelper(
176+
APValue::LValuePathSerializationHelper lvaluePath) {
177+
ArrayRef<APValue::LValuePathEntry> path = lvaluePath.Path;
178+
QualType elemTy = lvaluePath.getType();
179+
asImpl().writeQualType(elemTy);
180+
asImpl().writeUInt32(path.size());
181+
auto &ctx = ((BasicWriterBase<Impl> *)this)->getASTContext();
182+
for (auto elem : path) {
183+
if (elemTy->getAs<RecordType>()) {
184+
asImpl().writeUInt32(elem.getAsBaseOrMember().getInt());
185+
const Decl *baseOrMember = elem.getAsBaseOrMember().getPointer();
186+
if (const auto *recordDecl = dyn_cast<CXXRecordDecl>(baseOrMember)) {
187+
asImpl().writeDeclRef(recordDecl);
188+
elemTy = ctx.getRecordType(recordDecl);
189+
} else {
190+
const auto *valueDecl = cast<ValueDecl>(baseOrMember);
191+
asImpl().writeDeclRef(valueDecl);
192+
elemTy = valueDecl->getType();
193+
}
194+
} else {
195+
asImpl().writeUInt32(elem.getAsArrayIndex());
196+
elemTy = ctx.getAsArrayType(elemTy)->getElementType();
197+
}
198+
}
199+
}
200+
166201
void writeQualifiers(Qualifiers value) {
167202
static_assert(sizeof(value.getAsOpaqueValue()) <= sizeof(uint32_t),
168203
"update this if the value size changes");

0 commit comments

Comments
 (0)