Skip to content

Commit fd070d4

Browse files
committed
Merge from 'master' to 'sycl-web' (intel#103)
CONFLICT (content): Merge conflict in clang/test/CodeGen/annotations-field.c CONFLICT (content): Merge conflict in clang/lib/CodeGen/CodeGenFunction.cpp
2 parents 39c338d + d3205bb commit fd070d4

File tree

378 files changed

+10162
-2131
lines changed

Some content is hidden

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

378 files changed

+10162
-2131
lines changed

clang-tools-extra/clangd/ParsedAST.cpp

+5-7
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,9 @@ class ReplayPreamble : private PPCallbacks {
170170

171171
void replay() {
172172
for (const auto &Inc : Includes) {
173-
const FileEntry *File = nullptr;
173+
llvm::Optional<FileEntryRef> File;
174174
if (Inc.Resolved != "")
175-
if (auto FE = SM.getFileManager().getFile(Inc.Resolved))
176-
File = *FE;
175+
File = expectedToOptional(SM.getFileManager().getFileRef(Inc.Resolved));
177176

178177
// Re-lex the #include directive to find its interesting parts.
179178
auto HashLoc = SM.getComposedLoc(SM.getMainFileID(), Inc.HashOffset);
@@ -211,17 +210,16 @@ class ReplayPreamble : private PPCallbacks {
211210
SynthesizedFilenameTok.setKind(tok::header_name);
212211
SynthesizedFilenameTok.setLiteralData(Inc.Written.data());
213212

213+
const FileEntry *FE = File ? &File->getFileEntry() : nullptr;
214214
llvm::StringRef WrittenFilename =
215215
llvm::StringRef(Inc.Written).drop_front().drop_back();
216216
Delegate->InclusionDirective(HashTok->location(), SynthesizedIncludeTok,
217217
WrittenFilename, Inc.Written.front() == '<',
218-
FileTok->range(SM).toCharRange(SM), File,
218+
FileTok->range(SM).toCharRange(SM), FE,
219219
"SearchPath", "RelPath",
220220
/*Imported=*/nullptr, Inc.FileKind);
221221
if (File)
222-
// FIXME: Use correctly named FileEntryRef.
223-
Delegate->FileSkipped(FileEntryRef(File->getName(), *File),
224-
SynthesizedFilenameTok, Inc.FileKind);
222+
Delegate->FileSkipped(*File, SynthesizedFilenameTok, Inc.FileKind);
225223
else {
226224
llvm::SmallString<1> UnusedRecovery;
227225
Delegate->FileNotFound(WrittenFilename, UnusedRecovery);

clang-tools-extra/clangd/index/remote/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
if (CLANGD_ENABLE_REMOTE)
22
generate_protos(RemoteIndexServiceProto "Service.proto" GRPC)
33
generate_protos(RemoteIndexProto "Index.proto")
4+
add_dependencies(RemoteIndexServiceProto RemoteIndexProto)
45
include_directories(${CMAKE_CURRENT_BINARY_DIR})
56
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../)
67

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

-43
Original file line numberDiff line numberDiff line change
@@ -230,49 +230,6 @@ TEST_F(BackgroundIndexTest, IndexTwoFiles) {
230230
FileURI("unittest:///root/B.cc")}));
231231
}
232232

233-
TEST_F(BackgroundIndexTest, RelationsMultiFile) {
234-
MockFS FS;
235-
FS.Files[testPath("root/Base.h")] = "class Base {};";
236-
FS.Files[testPath("root/A.cc")] = R"cpp(
237-
#include "Base.h"
238-
class A : public Base {};
239-
)cpp";
240-
FS.Files[testPath("root/B.cc")] = R"cpp(
241-
#include "Base.h"
242-
class B : public Base {};
243-
)cpp";
244-
245-
llvm::StringMap<std::string> Storage;
246-
size_t CacheHits = 0;
247-
MemoryShardStorage MSS(Storage, CacheHits);
248-
OverlayCDB CDB(/*Base=*/nullptr);
249-
BackgroundIndex Index(FS, CDB, [&](llvm::StringRef) { return &MSS; },
250-
/*Opts=*/{});
251-
252-
tooling::CompileCommand Cmd;
253-
Cmd.Filename = testPath("root/A.cc");
254-
Cmd.Directory = testPath("root");
255-
Cmd.CommandLine = {"clang++", Cmd.Filename};
256-
CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
257-
ASSERT_TRUE(Index.blockUntilIdleForTest());
258-
259-
Cmd.Filename = testPath("root/B.cc");
260-
Cmd.CommandLine = {"clang++", Cmd.Filename};
261-
CDB.setCompileCommand(testPath("root/B.cc"), Cmd);
262-
ASSERT_TRUE(Index.blockUntilIdleForTest());
263-
264-
auto HeaderShard = MSS.loadShard(testPath("root/Base.h"));
265-
EXPECT_NE(HeaderShard, nullptr);
266-
SymbolID Base = findSymbol(*HeaderShard->Symbols, "Base").ID;
267-
268-
RelationsRequest Req;
269-
Req.Subjects.insert(Base);
270-
Req.Predicate = RelationKind::BaseOf;
271-
uint32_t Results = 0;
272-
Index.relations(Req, [&](const SymbolID &, const Symbol &) { ++Results; });
273-
EXPECT_EQ(Results, 2u);
274-
}
275-
276233
TEST_F(BackgroundIndexTest, MainFileRefs) {
277234
MockFS FS;
278235
FS.Files[testPath("root/A.h")] = R"cpp(

clang-tools-extra/clangd/unittests/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ add_unittest(ClangdUnitTests ClangdTests
8888
TestFS.cpp
8989
TestIndex.cpp
9090
TestTU.cpp
91+
TestWorkspace.cpp
9192
TypeHierarchyTests.cpp
9293
TweakTests.cpp
9394
TweakTesting.cpp

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

+28
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "SyncAPI.h"
1515
#include "TestFS.h"
1616
#include "TestTU.h"
17+
#include "TestWorkspace.h"
1718
#include "URI.h"
1819
#include "index/CanonicalIncludes.h"
1920
#include "index/FileIndex.h"
@@ -426,6 +427,33 @@ TEST(FileIndexTest, Relations) {
426427
EXPECT_EQ(Results, 1u);
427428
}
428429

430+
TEST(FileIndexTest, RelationsMultiFile) {
431+
TestWorkspace Workspace;
432+
Workspace.addSource("Base.h", "class Base {};");
433+
Workspace.addMainFile("A.cpp", R"cpp(
434+
#include "Base.h"
435+
class A : public Base {};
436+
)cpp");
437+
Workspace.addMainFile("B.cpp", R"cpp(
438+
#include "Base.h"
439+
class B : public Base {};
440+
)cpp");
441+
442+
auto Index = Workspace.index();
443+
FuzzyFindRequest FFReq;
444+
FFReq.Query = "Base";
445+
FFReq.AnyScope = true;
446+
SymbolID Base;
447+
Index->fuzzyFind(FFReq, [&](const Symbol &S) { Base = S.ID; });
448+
449+
RelationsRequest Req;
450+
Req.Subjects.insert(Base);
451+
Req.Predicate = RelationKind::BaseOf;
452+
uint32_t Results = 0;
453+
Index->relations(Req, [&](const SymbolID &, const Symbol &) { ++Results; });
454+
EXPECT_EQ(Results, 2u);
455+
}
456+
429457
TEST(FileIndexTest, ReferencesInMainFileWithPreamble) {
430458
TestTU TU;
431459
TU.HeaderCode = "class Foo{};";

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ void deleteModuleCache(const std::string ModuleCachePath) {
8080
}
8181
}
8282

83-
std::shared_ptr<const PreambleData> TestTU::preamble() const {
83+
std::shared_ptr<const PreambleData>
84+
TestTU::preamble(PreambleParsedCallback PreambleCallback) const {
8485
MockFS FS;
8586
auto Inputs = inputs(FS);
8687
IgnoreDiagnostics Diags;
@@ -91,8 +92,7 @@ std::shared_ptr<const PreambleData> TestTU::preamble() const {
9192
auto ModuleCacheDeleter = llvm::make_scope_exit(
9293
std::bind(deleteModuleCache, CI->getHeaderSearchOpts().ModuleCachePath));
9394
return clang::clangd::buildPreamble(testPath(Filename), *CI, Inputs,
94-
/*StoreInMemory=*/true,
95-
/*PreambleCallback=*/nullptr);
95+
/*StoreInMemory=*/true, PreambleCallback);
9696
}
9797

9898
ParsedAST TestTU::build() const {

clang-tools-extra/clangd/unittests/TestTU.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ struct TestTU {
7979
// By default, build() will report Error diagnostics as GTest errors.
8080
// Suppress this behavior by adding an 'error-ok' comment to the code.
8181
ParsedAST build() const;
82-
std::shared_ptr<const PreambleData> preamble() const;
82+
std::shared_ptr<const PreambleData>
83+
preamble(PreambleParsedCallback PreambleCallback = nullptr) const;
8384
ParseInputs inputs(MockFS &FS) const;
8485
SymbolSlab headerSymbols() const;
8586
RefSlab headerRefs() const;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//===--- TestWorkspace.cpp - Utility for writing multi-file tests -*- C++-*===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "TestWorkspace.h"
10+
11+
namespace clang {
12+
namespace clangd {
13+
14+
std::unique_ptr<SymbolIndex> TestWorkspace::index() {
15+
auto Index = std::make_unique<FileIndex>();
16+
for (const auto &Input : Inputs) {
17+
if (!Input.second.IsMainFile)
18+
continue;
19+
TU.Code = Input.second.Code;
20+
TU.Filename = Input.first().str();
21+
TU.preamble([&](ASTContext &Ctx, std::shared_ptr<clang::Preprocessor> PP,
22+
const CanonicalIncludes &CanonIncludes) {
23+
Index->updatePreamble(testPath(Input.first()), "null", Ctx, PP,
24+
CanonIncludes);
25+
});
26+
ParsedAST MainAST = TU.build();
27+
Index->updateMain(testPath(Input.first()), MainAST);
28+
}
29+
return Index;
30+
}
31+
32+
Optional<ParsedAST> TestWorkspace::openFile(llvm::StringRef Filename) {
33+
auto It = Inputs.find(Filename);
34+
if (It == Inputs.end()) {
35+
ADD_FAILURE() << "Accessing non-existing file: " << Filename;
36+
return llvm::None;
37+
}
38+
TU.Code = It->second.Code;
39+
TU.Filename = It->first().str();
40+
return TU.build();
41+
}
42+
43+
void TestWorkspace::addInput(llvm::StringRef Filename,
44+
const SourceFile &Input) {
45+
Inputs.insert(std::make_pair(Filename, Input));
46+
TU.AdditionalFiles.insert(std::make_pair(Filename, Input.Code));
47+
}
48+
} // namespace clangd
49+
} // namespace clang
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//===--- TestWorkspace.h - Utility for writing multi-file tests --*- C++-*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// TestWorkspace builds on TestTU to provide a way to write tests involving
10+
// several related files with inclusion relationships between them.
11+
//
12+
// The tests can exercise both index and AST based operations.
13+
//
14+
//===---------------------------------------------------------------------===//
15+
16+
#ifndef LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTWORKSPACE_H
17+
#define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTWORKSPACE_H
18+
19+
#include "TestFS.h"
20+
#include "TestTU.h"
21+
#include "index/FileIndex.h"
22+
#include "index/Index.h"
23+
#include "llvm/ADT/StringRef.h"
24+
#include <string>
25+
#include <vector>
26+
27+
namespace clang {
28+
namespace clangd {
29+
30+
class TestWorkspace {
31+
public:
32+
// The difference between addSource() and addMainFile() is that only main
33+
// files will be indexed.
34+
void addSource(llvm::StringRef Filename, llvm::StringRef Code) {
35+
addInput(Filename.str(), {Code.str(), /*IsMainFile=*/false});
36+
}
37+
void addMainFile(llvm::StringRef Filename, llvm::StringRef Code) {
38+
addInput(Filename.str(), {Code.str(), /*IsMainFile=*/true});
39+
}
40+
41+
std::unique_ptr<SymbolIndex> index();
42+
43+
Optional<ParsedAST> openFile(llvm::StringRef Filename);
44+
45+
private:
46+
struct SourceFile {
47+
std::string Code;
48+
bool IsMainFile = false;
49+
};
50+
llvm::StringMap<SourceFile> Inputs;
51+
TestTU TU;
52+
53+
void addInput(llvm::StringRef Filename, const SourceFile &Input);
54+
};
55+
56+
} // namespace clangd
57+
} // namespace clang
58+
59+
#endif // LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTWORKSPACE_H

clang/docs/ReleaseNotes.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ X86 Support in Clang
190190
- The x86 intrinsics ``__rorb``, ``__rorw``, ``__rord``, ``__rorq`, ``_rotr``,
191191
``_rotwr`` and ``_lrotr`` may now be used within constant expressions.
192192

193-
- Support for ``-march=sapphirerapids`` was added.
193+
- Support for ``-march=alderlake``, ``-march=sapphirerapids`` and
194+
``-march=znver3`` was added.
194195

195196
- Support for ``-march=x86-64-v[234]`` has been added.
196197
See :doc:`UsersManual` for details about these micro-architecture levels.

clang/docs/UsersManual.rst

+39-1
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,7 @@ Note that floating-point operations performed as part of constant initialization
13861386
Details:
13871387

13881388
* ``precise`` Disables optimizations that are not value-safe on floating-point data, although FP contraction (FMA) is enabled (``-ffp-contract=fast``). This is the default behavior.
1389-
* ``strict`` Enables ``-frounding-math`` and ``-ffp-exception-behavior=strict``, and disables contractions (FMA). All of the ``-ffast-math`` enablements are disabled.
1389+
* ``strict`` Enables ``-frounding-math`` and ``-ffp-exception-behavior=strict``, and disables contractions (FMA). All of the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by default ``FENV_ACCESS`` is disabled. This option setting behaves as though ``#pragma STDC FENV_ACESS ON`` appeared at the top of the source file.
13901390
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and ``ffp-contract=fast``
13911391

13921392
Note: If your command line specifies multiple instances
@@ -1408,6 +1408,44 @@ Note that floating-point operations performed as part of constant initialization
14081408
* ``strict`` The compiler ensures that all transformations strictly preserve the floating point exception semantics of the original code.
14091409

14101410

1411+
.. _fp-constant-eval:
1412+
1413+
A note about Floating Point Constant Evaluation
1414+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1415+
1416+
In C, the only place floating point operations are guaranteed to be evaluated
1417+
during translation is in the initializers of variables of static storage
1418+
duration, which are all notionally initialized before the program begins
1419+
executing (and thus before a non-default floating point environment can be
1420+
entered). But C++ has many more contexts where floating point constant
1421+
evaluation occurs. Specifically: for static/thread-local variables,
1422+
first try evaluating the initializer in a constant context, including in the
1423+
constant floating point environment (just like in C), and then, if that fails,
1424+
fall back to emitting runtime code to perform the initialization (which might
1425+
in general be in a different floating point environment).
1426+
1427+
Consider this example when compiled with ``-frounding-math``
1428+
1429+
.. code-block:: console
1430+
1431+
constexpr float func_01(float x, float y) {
1432+
return x + y;
1433+
}
1434+
float V1 = func_01(1.0F, 0x0.000001p0F);
1435+
1436+
The C++ rule is that initializers for static storage duration variables are
1437+
first evaluated during translation (therefore, in the default rounding mode),
1438+
and only evaluated at runtime (and therefore in the runtime rounding mode) if
1439+
the compile-time evaluation fails. This is in line with the C rules;
1440+
C11 F.8.5 says: *All computation for automatic initialization is done (as if)
1441+
at execution time; thus, it is affected by any operative modes and raises
1442+
floating-point exceptions as required by IEC 60559 (provided the state for the
1443+
FENV_ACCESS pragma is ‘‘on’’). All computation for initialization of objects
1444+
that have static or thread storage duration is done (as if) at translation
1445+
time.* C++ generalizes this by adding another phase of initialization
1446+
(at runtime) if the translation-time initialization fails, but the
1447+
translation-time evaluation of the initializer of succeeds, it will be
1448+
treated as a constant initializer.
14111449

14121450

14131451
.. _controlling-code-generation:

clang/examples/clang-interpreter/main.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ class SimpleJIT {
7272
}
7373

7474
public:
75+
~SimpleJIT() {
76+
if (auto Err = ES.endSession())
77+
ES.reportError(std::move(Err));
78+
}
79+
7580
static Expected<std::unique_ptr<SimpleJIT>> Create() {
7681
auto JTMB = JITTargetMachineBuilder::detectHost();
7782
if (!JTMB)

clang/include/clang/AST/Decl.h

-4
Original file line numberDiff line numberDiff line change
@@ -2254,10 +2254,6 @@ class FunctionDecl : public DeclaratorDecl,
22542254
bool usesSEHTry() const { return FunctionDeclBits.UsesSEHTry; }
22552255
void setUsesSEHTry(bool UST) { FunctionDeclBits.UsesSEHTry = UST; }
22562256

2257-
/// Indicates the function uses Floating Point constrained intrinsics
2258-
bool usesFPIntrin() const { return FunctionDeclBits.UsesFPIntrin; }
2259-
void setUsesFPIntrin(bool Val) { FunctionDeclBits.UsesFPIntrin = Val; }
2260-
22612257
/// Whether this function has been deleted.
22622258
///
22632259
/// A function that is "deleted" (via the C++0x "= delete" syntax)

0 commit comments

Comments
 (0)