Skip to content

Commit f9ad75b

Browse files
committed
Merge commit 'c6f29dbb596ff0fd6d8b6445eabbf01f6d063c8c' into llvmspirv_pulldown
2 parents 10e1c97 + c6f29db commit f9ad75b

File tree

559 files changed

+50358
-7486
lines changed

Some content is hidden

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

559 files changed

+50358
-7486
lines changed

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

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -826,22 +826,8 @@ void SymbolCollector::setIncludeLocation(const Symbol &S, SourceLocation DefLoc,
826826
// We update providers for a symbol with each occurence, as SymbolCollector
827827
// might run while parsing, rather than at the end of a translation unit.
828828
// Hence we see more and more redecls over time.
829-
auto [It, Inserted] = SymbolProviders.try_emplace(S.ID);
830-
auto Headers =
829+
SymbolProviders[S.ID] =
831830
include_cleaner::headersForSymbol(Sym, SM, Opts.PragmaIncludes);
832-
if (Headers.empty())
833-
return;
834-
835-
auto *HeadersIter = Headers.begin();
836-
include_cleaner::Header H = *HeadersIter;
837-
while (HeadersIter != Headers.end() &&
838-
H.kind() == include_cleaner::Header::Physical &&
839-
!tooling::isSelfContainedHeader(H.physical(), SM,
840-
PP->getHeaderSearchInfo())) {
841-
H = *HeadersIter;
842-
HeadersIter++;
843-
}
844-
It->second = H;
845831
}
846832

847833
llvm::StringRef getStdHeader(const Symbol *S, const LangOptions &LangOpts) {
@@ -889,7 +875,7 @@ void SymbolCollector::finish() {
889875
llvm::DenseMap<include_cleaner::Header, std::string> HeaderSpelling;
890876
// Fill in IncludeHeaders.
891877
// We delay this until end of TU so header guards are all resolved.
892-
for (const auto &[SID, OptionalProvider] : SymbolProviders) {
878+
for (const auto &[SID, Providers] : SymbolProviders) {
893879
const Symbol *S = Symbols.find(SID);
894880
if (!S)
895881
continue;
@@ -931,9 +917,27 @@ void SymbolCollector::finish() {
931917
continue;
932918
}
933919

934-
assert(Directives == Symbol::Include);
935920
// For #include's, use the providers computed by the include-cleaner
936921
// library.
922+
assert(Directives == Symbol::Include);
923+
// Ignore providers that are not self-contained, this is especially
924+
// important for symbols defined in the main-file. We want to prefer the
925+
// header, if possible.
926+
// TODO: Limit this to specifically ignore main file, when we're indexing a
927+
// non-header file?
928+
auto SelfContainedProvider =
929+
[this](llvm::ArrayRef<include_cleaner::Header> Providers)
930+
-> std::optional<include_cleaner::Header> {
931+
for (const auto &H : Providers) {
932+
if (H.kind() != include_cleaner::Header::Physical)
933+
return H;
934+
if (tooling::isSelfContainedHeader(H.physical(), PP->getSourceManager(),
935+
PP->getHeaderSearchInfo()))
936+
return H;
937+
}
938+
return std::nullopt;
939+
};
940+
const auto OptionalProvider = SelfContainedProvider(Providers);
937941
if (!OptionalProvider)
938942
continue;
939943
const auto &H = *OptionalProvider;

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,25 @@
1515
#include "index/Relation.h"
1616
#include "index/Symbol.h"
1717
#include "index/SymbolID.h"
18+
#include "index/SymbolLocation.h"
1819
#include "index/SymbolOrigin.h"
1920
#include "clang/AST/ASTContext.h"
2021
#include "clang/AST/Decl.h"
22+
#include "clang/Basic/LLVM.h"
2123
#include "clang/Basic/SourceLocation.h"
2224
#include "clang/Basic/SourceManager.h"
2325
#include "clang/Index/IndexDataConsumer.h"
2426
#include "clang/Index/IndexSymbol.h"
2527
#include "clang/Sema/CodeCompleteConsumer.h"
2628
#include "llvm/ADT/DenseMap.h"
29+
#include "llvm/ADT/DenseSet.h"
30+
#include "llvm/ADT/SmallVector.h"
31+
#include "llvm/ADT/StringRef.h"
2732
#include <functional>
2833
#include <memory>
2934
#include <optional>
35+
#include <string>
36+
#include <utility>
3037

3138
namespace clang {
3239
namespace clangd {
@@ -177,7 +184,7 @@ class SymbolCollector : public index::IndexDataConsumer {
177184

178185
// Providers for Symbol.IncludeHeaders.
179186
// The final spelling is calculated in finish().
180-
llvm::DenseMap<SymbolID, std::optional<include_cleaner::Header>>
187+
llvm::DenseMap<SymbolID, llvm::SmallVector<include_cleaner::Header>>
181188
SymbolProviders;
182189
// Files which contain ObjC symbols.
183190
// This is finalized and used in finish().

clang-tools-extra/clangd/unittests/IndexActionTests.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,36 @@ TEST_F(IndexActionTest, SymbolFromCC) {
341341
hasName("foo"),
342342
includeHeader(URI::create(testPath("main.h")).toString()))));
343343
}
344+
345+
TEST_F(IndexActionTest, IncludeHeaderForwardDecls) {
346+
std::string MainFilePath = testPath("main.cpp");
347+
addFile(MainFilePath, R"cpp(
348+
#include "fwd.h"
349+
#include "full.h"
350+
)cpp");
351+
addFile(testPath("fwd.h"), R"cpp(
352+
#ifndef _FWD_H_
353+
#define _FWD_H_
354+
struct Foo;
355+
#endif
356+
)cpp");
357+
addFile(testPath("full.h"), R"cpp(
358+
#ifndef _FULL_H_
359+
#define _FULL_H_
360+
struct Foo {};
361+
362+
// This decl is important, as otherwise we detect control macro for the file,
363+
// before handling definition of Foo.
364+
void other();
365+
#endif
366+
)cpp");
367+
IndexFileIn IndexFile = runIndexingAction(MainFilePath);
368+
EXPECT_THAT(*IndexFile.Symbols,
369+
testing::Contains(AllOf(
370+
hasName("Foo"),
371+
includeHeader(URI::create(testPath("full.h")).toString()))))
372+
<< *IndexFile.Symbols->begin();
373+
}
344374
} // namespace
345375
} // namespace clangd
346376
} // namespace clang

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,12 +2036,7 @@ bool RecursiveASTVisitor<Derived>::TraverseTemplateArgumentLocsHelper(
20362036
#define DEF_TRAVERSE_TMPL_PART_SPEC_DECL(TMPLDECLKIND, DECLKIND) \
20372037
DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplatePartialSpecializationDecl, { \
20382038
/* The partial specialization. */ \
2039-
if (TemplateParameterList *TPL = D->getTemplateParameters()) { \
2040-
for (TemplateParameterList::iterator I = TPL->begin(), E = TPL->end(); \
2041-
I != E; ++I) { \
2042-
TRY_TO(TraverseDecl(*I)); \
2043-
} \
2044-
} \
2039+
TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \
20452040
/* The args that remains unspecialized. */ \
20462041
TRY_TO(TraverseTemplateArgumentLocsHelper( \
20472042
D->getTemplateArgsAsWritten()->getTemplateArgs(), \

clang/include/clang/Basic/Version.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ namespace clang {
4242
/// string as getClangRevision.
4343
std::string getLLVMRevision();
4444

45+
/// Retrieves the Clang vendor tag.
46+
std::string getClangVendor();
47+
4548
/// Retrieves the full repository version that is an amalgamation of
4649
/// the information in getClangRepositoryPath() and getClangRevision().
4750
std::string getClangFullRepositoryVersion();

clang/include/clang/Basic/arm_sve.td

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,21 +2086,21 @@ let TargetGuard = "sve2p1|sme2" in {
20862086
def SVCNTP_COUNT : SInst<"svcntp_{d}", "n}i", "QcQsQiQl", MergeNone, "aarch64_sve_cntp_{d}", [IsOverloadNone, IsStreamingCompatible], [ImmCheck<1, ImmCheck2_4_Mul2>]>;
20872087
}
20882088

2089-
let TargetGuard = "sve2p1,b16b16" in {
2090-
defm SVMUL_BF : SInstZPZZ<"svmul", "b", "aarch64_sve_fmul", "aarch64_sve_fmul_u">;
2091-
defm SVADD_BF : SInstZPZZ<"svadd", "b", "aarch64_sve_fadd", "aarch64_sve_fadd_u">;
2092-
defm SVSUB_BF : SInstZPZZ<"svsub", "b", "aarch64_sve_fsub", "aarch64_sve_fsub_u">;
2093-
defm SVMAXNM_BF : SInstZPZZ<"svmaxnm","b", "aarch64_sve_fmaxnm", "aarch64_sve_fmaxnm_u">;
2094-
defm SVMINNM_BF : SInstZPZZ<"svminnm","b", "aarch64_sve_fminnm", "aarch64_sve_fminnm_u">;
2095-
defm SVMAX_BF : SInstZPZZ<"svmax", "b", "aarch64_sve_fmax", "aarch64_sve_fmax_u">;
2096-
defm SVMIN_BF : SInstZPZZ<"svmin", "b", "aarch64_sve_fmin", "aarch64_sve_fmin_u">;
2097-
defm SVMLA_BF : SInstZPZZZ<"svmla", "b", "aarch64_sve_fmla", "aarch64_sve_fmla_u", []>;
2098-
defm SVMLS_BF : SInstZPZZZ<"svmls", "b", "aarch64_sve_fmls", "aarch64_sve_fmls_u", []>;
2099-
def SVMLA_LANE_BF : SInst<"svmla_lane[_{d}]", "ddddi", "b", MergeNone, "aarch64_sve_fmla_lane", [], [ImmCheck<3, ImmCheckLaneIndex, 2>]>;
2100-
def SVMLS_LANE_BF : SInst<"svmls_lane[_{d}]", "ddddi", "b", MergeNone, "aarch64_sve_fmls_lane", [], [ImmCheck<3, ImmCheckLaneIndex, 2>]>;
2101-
def SVMUL_LANE_BF : SInst<"svmul_lane[_{d}]", "dddi", "b", MergeNone, "aarch64_sve_fmul_lane", [], [ImmCheck<2, ImmCheckLaneIndex, 1>]>;
2102-
def SVFCLAMP_BF : SInst<"svclamp[_{d}]", "dddd", "b", MergeNone, "aarch64_sve_fclamp", [], []>;
2103-
} //sve2p1,b16b16
2089+
let TargetGuard = "(sve2|sme2),b16b16" in {
2090+
defm SVMUL_BF : SInstZPZZ<"svmul", "b", "aarch64_sve_fmul", "aarch64_sve_fmul_u", [IsStreamingCompatible]>;
2091+
defm SVADD_BF : SInstZPZZ<"svadd", "b", "aarch64_sve_fadd", "aarch64_sve_fadd_u", [IsStreamingCompatible]>;
2092+
defm SVSUB_BF : SInstZPZZ<"svsub", "b", "aarch64_sve_fsub", "aarch64_sve_fsub_u", [IsStreamingCompatible]>;
2093+
defm SVMAXNM_BF : SInstZPZZ<"svmaxnm","b", "aarch64_sve_fmaxnm", "aarch64_sve_fmaxnm_u", [IsStreamingCompatible]>;
2094+
defm SVMINNM_BF : SInstZPZZ<"svminnm","b", "aarch64_sve_fminnm", "aarch64_sve_fminnm_u", [IsStreamingCompatible]>;
2095+
defm SVMAX_BF : SInstZPZZ<"svmax", "b", "aarch64_sve_fmax", "aarch64_sve_fmax_u", [IsStreamingCompatible]>;
2096+
defm SVMIN_BF : SInstZPZZ<"svmin", "b", "aarch64_sve_fmin", "aarch64_sve_fmin_u", [IsStreamingCompatible]>;
2097+
defm SVMLA_BF : SInstZPZZZ<"svmla", "b", "aarch64_sve_fmla", "aarch64_sve_fmla_u", [IsStreamingCompatible]>;
2098+
defm SVMLS_BF : SInstZPZZZ<"svmls", "b", "aarch64_sve_fmls", "aarch64_sve_fmls_u", [IsStreamingCompatible]>;
2099+
def SVMLA_LANE_BF : SInst<"svmla_lane[_{d}]", "ddddi", "b", MergeNone, "aarch64_sve_fmla_lane", [IsStreamingCompatible], [ImmCheck<3, ImmCheckLaneIndex, 2>]>;
2100+
def SVMLS_LANE_BF : SInst<"svmls_lane[_{d}]", "ddddi", "b", MergeNone, "aarch64_sve_fmls_lane", [IsStreamingCompatible], [ImmCheck<3, ImmCheckLaneIndex, 2>]>;
2101+
def SVMUL_LANE_BF : SInst<"svmul_lane[_{d}]", "dddi", "b", MergeNone, "aarch64_sve_fmul_lane", [IsStreamingCompatible], [ImmCheck<2, ImmCheckLaneIndex, 1>]>;
2102+
def SVFCLAMP_BF : SInst<"svclamp[_{d}]", "dddd", "b", MergeNone, "aarch64_sve_fclamp", [IsStreamingCompatible], []>;
2103+
}
21042104

21052105
// SME2
21062106

clang/include/clang/Interpreter/CodeCompletion.h

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,27 @@ namespace clang {
2323
class CodeCompletionResult;
2424
class CompilerInstance;
2525

26-
void codeComplete(CompilerInstance *InterpCI, llvm::StringRef Content,
27-
unsigned Line, unsigned Col, const CompilerInstance *ParentCI,
28-
std::vector<std::string> &CCResults);
26+
struct ReplCodeCompleter {
27+
ReplCodeCompleter() = default;
28+
std::string Prefix;
29+
30+
/// \param InterpCI [in] The compiler instance that is used to trigger code
31+
/// completion
32+
33+
/// \param Content [in] The string where code completion is triggered.
34+
35+
/// \param Line [in] The line number of the code completion point.
36+
37+
/// \param Col [in] The column number of the code completion point.
38+
39+
/// \param ParentCI [in] The running interpreter compiler instance that
40+
/// provides ASTContexts.
41+
42+
/// \param CCResults [out] The completion results.
43+
void codeComplete(CompilerInstance *InterpCI, llvm::StringRef Content,
44+
unsigned Line, unsigned Col,
45+
const CompilerInstance *ParentCI,
46+
std::vector<std::string> &CCResults);
47+
};
2948
} // namespace clang
3049
#endif

clang/include/clang/Interpreter/Interpreter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class Interpreter {
101101
const ASTContext &getASTContext() const;
102102
ASTContext &getASTContext();
103103
const CompilerInstance *getCompilerInstance() const;
104+
CompilerInstance *getCompilerInstance();
104105
llvm::Expected<llvm::orc::LLJIT &> getExecutionEngine();
105106

106107
llvm::Expected<PartialTranslationUnit &> Parse(llvm::StringRef Code);

clang/lib/Basic/Version.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ std::string getLLVMRevision() {
5757
#endif
5858
}
5959

60+
std::string getClangVendor() {
61+
#ifdef CLANG_VENDOR
62+
return CLANG_VENDOR;
63+
#else
64+
return "";
65+
#endif
66+
}
67+
6068
std::string getClangFullRepositoryVersion() {
6169
std::string buf;
6270
llvm::raw_string_ostream OS(buf);
@@ -92,10 +100,7 @@ std::string getClangFullVersion() {
92100
std::string getClangToolFullVersion(StringRef ToolName) {
93101
std::string buf;
94102
llvm::raw_string_ostream OS(buf);
95-
#ifdef CLANG_VENDOR
96-
OS << CLANG_VENDOR;
97-
#endif
98-
OS << ToolName << " version " CLANG_VERSION_STRING;
103+
OS << getClangVendor() << ToolName << " version " CLANG_VERSION_STRING;
99104

100105
std::string repo = getClangFullRepositoryVersion();
101106
if (!repo.empty()) {
@@ -110,10 +115,7 @@ std::string getClangFullCPPVersion() {
110115
// the one we report on the command line.
111116
std::string buf;
112117
llvm::raw_string_ostream OS(buf);
113-
#ifdef CLANG_VENDOR
114-
OS << CLANG_VENDOR;
115-
#endif
116-
OS << "Clang " CLANG_VERSION_STRING;
118+
OS << getClangVendor() << "Clang " CLANG_VERSION_STRING;
117119

118120
std::string repo = getClangFullRepositoryVersion();
119121
if (!repo.empty()) {

clang/lib/CodeGen/CodeGenAction.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,6 @@ namespace clang {
496496
}
497497

498498
bool ClangDiagnosticHandler::handleDiagnostics(const DiagnosticInfo &DI) {
499-
if (DI.getSeverity() == DS_Error)
500-
HasErrors = true;
501499
BackendCon->DiagnosticHandlerImpl(DI);
502500
return true;
503501
}

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,12 +1038,7 @@ void CodeGenModule::Release() {
10381038
uint32_t(CLANG_VERSION_MINOR));
10391039
getModule().addModuleFlag(llvm::Module::Warning, "zos_product_patchlevel",
10401040
uint32_t(CLANG_VERSION_PATCHLEVEL));
1041-
std::string ProductId;
1042-
#ifdef CLANG_VENDOR
1043-
ProductId = #CLANG_VENDOR;
1044-
#else
1045-
ProductId = "clang";
1046-
#endif
1041+
std::string ProductId = getClangVendor() + "clang";
10471042
getModule().addModuleFlag(llvm::Module::Error, "zos_product_id",
10481043
llvm::MDString::get(VMContext, ProductId));
10491044

0 commit comments

Comments
 (0)