Skip to content

Commit 2d1319f

Browse files
committed
LLVM and SPIRV-LLVM-Translator pulldown (WW47)
LLVM: llvm/llvm-project@cbcf123 SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@8784853
2 parents 168767c + 3226609 commit 2d1319f

File tree

2,505 files changed

+92535
-28879
lines changed

Some content is hidden

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

2,505 files changed

+92535
-28879
lines changed

bolt/lib/Core/BinaryContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,9 +2036,9 @@ void BinaryContext::renameSection(BinarySection &Section,
20362036
deregisterSectionName(Section);
20372037

20382038
Section.Name = NewName.str();
2039-
Section.setOutputName(NewName);
2039+
Section.setOutputName(Section.Name);
20402040

2041-
NameToSection.insert(std::make_pair(NewName.str(), &Section));
2041+
NameToSection.insert(std::make_pair(Section.Name, &Section));
20422042

20432043
// Reinsert with the new name.
20442044
Sections.insert(&Section);

clang-tools-extra/clangd/Headers.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "clang/Lex/HeaderSearch.h"
1616
#include "clang/Lex/PPCallbacks.h"
1717
#include "clang/Lex/Preprocessor.h"
18+
#include "clang/Tooling/Inclusions/HeaderAnalysis.h"
1819
#include "llvm/ADT/StringRef.h"
1920
#include "llvm/Support/Path.h"
2021
#include <cstring>
@@ -121,12 +122,10 @@ class IncludeStructure::RecordHeaders : public PPCallbacks,
121122
// isSelfContainedHeader only returns true once the full header-guard
122123
// structure has been seen, i.e. when exiting the *outer* copy of the
123124
// file. So last result wins.
124-
if (isSelfContainedHeader(FE, PrevFID, SM, HeaderInfo))
125-
Out->NonSelfContained.erase(
126-
*Out->getID(SM.getFileEntryForID(PrevFID)));
125+
if (tooling::isSelfContainedHeader(FE, SM, HeaderInfo))
126+
Out->NonSelfContained.erase(*Out->getID(FE));
127127
else
128-
Out->NonSelfContained.insert(
129-
*Out->getID(SM.getFileEntryForID(PrevFID)));
128+
Out->NonSelfContained.insert(*Out->getID(FE));
130129
}
131130
break;
132131
}
@@ -164,7 +163,7 @@ class IncludeStructure::RecordHeaders : public PPCallbacks,
164163
LastPragmaKeepInMainFileLine =
165164
SM.getLineNumber(SM.getMainFileID(), Offset) - 1;
166165
} else {
167-
// Memorize headers that that have export pragmas in them. Include Cleaner
166+
// Memorize headers that have export pragmas in them. Include Cleaner
168167
// does not support them properly yet, so they will be not marked as
169168
// unused.
170169
// FIXME: Once IncludeCleaner supports export pragmas, remove this.

clang-tools-extra/clangd/Hover.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,17 @@ HoverInfo getDeducedTypeHoverContents(QualType QT, const syntax::Token &Tok,
777777
return HI;
778778
}
779779

780+
HoverInfo getStringLiteralContents(const StringLiteral *SL,
781+
const PrintingPolicy &PP) {
782+
HoverInfo HI;
783+
784+
HI.Name = "string-literal";
785+
HI.Size = (SL->getLength() + 1) * SL->getCharByteWidth();
786+
HI.Type = SL->getType().getAsString(PP).c_str();
787+
788+
return HI;
789+
}
790+
780791
bool isLiteral(const Expr *E) {
781792
// Unfortunately there's no common base Literal classes inherits from
782793
// (apart from Expr), therefore these exclusions.
@@ -785,7 +796,7 @@ bool isLiteral(const Expr *E) {
785796
llvm::isa<CXXNullPtrLiteralExpr>(E) ||
786797
llvm::isa<FixedPointLiteral>(E) || llvm::isa<FloatingLiteral>(E) ||
787798
llvm::isa<ImaginaryLiteral>(E) || llvm::isa<IntegerLiteral>(E) ||
788-
llvm::isa<StringLiteral>(E) || llvm::isa<UserDefinedLiteral>(E);
799+
llvm::isa<UserDefinedLiteral>(E);
789800
}
790801

791802
llvm::StringLiteral getNameForExpr(const Expr *E) {
@@ -810,6 +821,9 @@ llvm::Optional<HoverInfo> getHoverContents(const Expr *E, ParsedAST &AST,
810821
return llvm::None;
811822

812823
HoverInfo HI;
824+
// Print the type and the size for string literals
825+
if (const StringLiteral *SL = dyn_cast<StringLiteral>(E))
826+
return getStringLiteralContents(SL, PP);
813827
// For `this` expr we currently generate hover with pointee type.
814828
if (const CXXThisExpr *CTE = dyn_cast<CXXThisExpr>(E))
815829
return getThisExprHoverContents(CTE, AST.getASTContext(), PP);

clang-tools-extra/clangd/Protocol.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1700,7 +1700,7 @@ struct SemanticTokensDeltaParams {
17001700
bool fromJSON(const llvm::json::Value &Params, SemanticTokensDeltaParams &R,
17011701
llvm::json::Path);
17021702

1703-
/// Describes a a replacement of a contiguous range of semanticTokens.
1703+
/// Describes a replacement of a contiguous range of semanticTokens.
17041704
struct SemanticTokensEdit {
17051705
// LSP specifies `start` and `deleteCount` which are relative to the array
17061706
// encoding of the previous tokens.

clang-tools-extra/clangd/Selection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ class SelectionTester {
395395
// Implausible if upperbound(Tok) < First.
396396
if (auto Offset = LastAffectedToken(Tok.location()))
397397
return *Offset < First;
398-
// A prefix of the expanded tokens may be from an an implicit
398+
// A prefix of the expanded tokens may be from an implicit
399399
// inclusion (e.g. preamble patch, or command-line -include).
400400
return true;
401401
});

clang-tools-extra/clangd/SourceCode.cpp

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,58 +1183,5 @@ bool isProtoFile(SourceLocation Loc, const SourceManager &SM) {
11831183
return SM.getBufferData(FID).startswith(ProtoHeaderComment);
11841184
}
11851185

1186-
namespace {
1187-
1188-
// Is Line an #if or #ifdef directive?
1189-
// FIXME: This makes headers with #ifdef LINUX/WINDOWS/MACOS marked as non
1190-
// self-contained and is probably not what we want.
1191-
bool isIf(llvm::StringRef Line) {
1192-
Line = Line.ltrim();
1193-
if (!Line.consume_front("#"))
1194-
return false;
1195-
Line = Line.ltrim();
1196-
return Line.startswith("if");
1197-
}
1198-
1199-
// Is Line an #error directive mentioning includes?
1200-
bool isErrorAboutInclude(llvm::StringRef Line) {
1201-
Line = Line.ltrim();
1202-
if (!Line.consume_front("#"))
1203-
return false;
1204-
Line = Line.ltrim();
1205-
if (!Line.startswith("error"))
1206-
return false;
1207-
return Line.contains_insensitive(
1208-
"includ"); // Matches "include" or "including".
1209-
}
1210-
1211-
// Heuristically headers that only want to be included via an umbrella.
1212-
bool isDontIncludeMeHeader(llvm::StringRef Content) {
1213-
llvm::StringRef Line;
1214-
// Only sniff up to 100 lines or 10KB.
1215-
Content = Content.take_front(100 * 100);
1216-
for (unsigned I = 0; I < 100 && !Content.empty(); ++I) {
1217-
std::tie(Line, Content) = Content.split('\n');
1218-
if (isIf(Line) && isErrorAboutInclude(Content.split('\n').first))
1219-
return true;
1220-
}
1221-
return false;
1222-
}
1223-
1224-
} // namespace
1225-
1226-
bool isSelfContainedHeader(const FileEntry *FE, FileID FID,
1227-
const SourceManager &SM, HeaderSearch &HeaderInfo) {
1228-
// FIXME: Should files that have been #import'd be considered
1229-
// self-contained? That's really a property of the includer,
1230-
// not of the file.
1231-
if (!HeaderInfo.isFileMultipleIncludeGuarded(FE) &&
1232-
!HeaderInfo.hasFileBeenImported(FE))
1233-
return false;
1234-
// This pattern indicates that a header can't be used without
1235-
// particular preprocessor state, usually set up by another header.
1236-
return !isDontIncludeMeHeader(SM.getBufferData(FID));
1237-
}
1238-
12391186
} // namespace clangd
12401187
} // namespace clang

clang-tools-extra/clangd/SourceCode.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,6 @@ bool isHeaderFile(llvm::StringRef FileName,
325325
/// Returns true if the given location is in a generated protobuf file.
326326
bool isProtoFile(SourceLocation Loc, const SourceManager &SourceMgr);
327327

328-
/// This scans source code, and should not be called when using a preamble.
329-
/// Prefer to access the cache in IncludeStructure::isSelfContained if you can.
330-
bool isSelfContainedHeader(const FileEntry *FE, FileID ID,
331-
const SourceManager &SM, HeaderSearch &HeaderInfo);
332-
333328
/// Returns true if Name is reserved, like _Foo or __Vector_base.
334329
inline bool isReservedName(llvm::StringRef Name) {
335330
// This doesn't catch all cases, but the most common.

clang-tools-extra/clangd/TUScheduler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class TUScheduler::ASTCache {
245245
/// threads, remove()s mostly from the main thread, and get() from ASTWorker.
246246
/// Writes are rare and reads are cheap, so we don't expect much contention.
247247
class TUScheduler::HeaderIncluderCache {
248-
// We should be be a little careful how we store the include graph of open
248+
// We should be a little careful how we store the include graph of open
249249
// files, as each can have a large number of transitive headers.
250250
// This representation is O(unique transitive source files).
251251
llvm::BumpPtrAllocator Arena;

clang-tools-extra/clangd/index/CanonicalIncludes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class CanonicalIncludes {
4242
/// Returns the overridden include for symbol with \p QualifiedName, or "".
4343
llvm::StringRef mapSymbol(llvm::StringRef QualifiedName) const;
4444

45-
/// Returns the overridden include for for files in \p Header, or "".
45+
/// Returns the overridden include for files in \p Header, or "".
4646
llvm::StringRef mapHeader(FileEntryRef Header) const;
4747

4848
/// Adds mapping for system headers and some special symbols (e.g. STL symbols

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "clang/Index/IndexSymbol.h"
2929
#include "clang/Lex/Preprocessor.h"
3030
#include "clang/Lex/Token.h"
31+
#include "clang/Tooling/Inclusions/HeaderAnalysis.h"
3132
#include "llvm/ADT/ArrayRef.h"
3233
#include "llvm/Support/Casting.h"
3334
#include "llvm/Support/FileSystem.h"
@@ -419,8 +420,8 @@ class SymbolCollector::HeaderFileURICache {
419420
getFrameworkHeaderIncludeSpelling(FE, HFI->Framework, HS))
420421
return *Spelling;
421422

422-
if (!isSelfContainedHeader(FE, FID, PP->getSourceManager(),
423-
PP->getHeaderSearchInfo())) {
423+
if (!tooling::isSelfContainedHeader(FE, PP->getSourceManager(),
424+
PP->getHeaderSearchInfo())) {
424425
// A .inc or .def file is often included into a real header to define
425426
// symbols (e.g. LLVM tablegen files).
426427
if (Filename.endswith(".inc") || Filename.endswith(".def"))

0 commit comments

Comments
 (0)