Skip to content

Commit 29f8470

Browse files
authored
Merge branch 'main' into fix/100394
2 parents ca389fc + c77b107 commit 29f8470

File tree

62 files changed

+940
-287
lines changed

Some content is hidden

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

62 files changed

+940
-287
lines changed

.ci/generate-buildkite-pipeline-premerge

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ function keep-modified-projects() {
191191
}
192192

193193
function check-targets() {
194+
# Do not use "check-all" here because if there is "check-all" plus a
195+
# project specific target like "check-clang", that project's tests
196+
# will be run twice.
194197
projects=${@}
195198
for project in ${projects}; do
196199
case ${project} in
@@ -216,7 +219,7 @@ function check-targets() {
216219
echo "check-lldb"
217220
;;
218221
pstl)
219-
echo "check-all"
222+
# Currently we do not run pstl tests in CI.
220223
;;
221224
libclc)
222225
# Currently there is no testing for libclc.

clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,8 @@ groupReplacements(const TUReplacements &TUs, const TUDiagnostics &TUDs,
148148

149149
if (auto Entry = SM.getFileManager().getOptionalFileRef(Path)) {
150150
if (SourceTU) {
151-
auto &Replaces = DiagReplacements[*Entry];
152-
auto It = Replaces.find(R);
153-
if (It == Replaces.end())
154-
Replaces.emplace(R, SourceTU);
155-
else if (It->second != SourceTU)
151+
auto [It, Inserted] = DiagReplacements[*Entry].try_emplace(R, SourceTU);
152+
if (!Inserted && It->second != SourceTU)
156153
// This replacement is a duplicate of one suggested by another TU.
157154
return;
158155
}

clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,9 +606,8 @@ void ChangeNamespaceTool::run(
606606
Result.Nodes.getNodeAs<DeclRefExpr>("func_ref")) {
607607
// If this reference has been processed as a function call, we do not
608608
// process it again.
609-
if (ProcessedFuncRefs.count(FuncRef))
609+
if (!ProcessedFuncRefs.insert(FuncRef).second)
610610
return;
611-
ProcessedFuncRefs.insert(FuncRef);
612611
const auto *Func = Result.Nodes.getNodeAs<FunctionDecl>("func_decl");
613612
assert(Func);
614613
const auto *Context = Result.Nodes.getNodeAs<Decl>("dc");

clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,13 @@ void ForwardDeclarationNamespaceCheck::onEndOfTranslationUnit() {
146146
}
147147
// Check if a definition in another namespace exists.
148148
const auto DeclName = CurDecl->getName();
149-
if (!DeclNameToDefinitions.contains(DeclName)) {
149+
auto It = DeclNameToDefinitions.find(DeclName);
150+
if (It == DeclNameToDefinitions.end()) {
150151
continue; // No definition in this translation unit, we can skip it.
151152
}
152153
// Make a warning for each definition with the same name (in other
153154
// namespaces).
154-
const auto &Definitions = DeclNameToDefinitions[DeclName];
155+
const auto &Definitions = It->second;
155156
for (const auto *Def : Definitions) {
156157
diag(CurDecl->getLocation(),
157158
"no definition found for %0, but a definition with "

clang/test/SemaCXX/attr-lifetimebound.cpp

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,26 @@ namespace usage_ok {
7575
}
7676
}
7777

78-
# 1 "<std>" 1 3
7978
namespace std {
8079
using size_t = __SIZE_TYPE__;
81-
struct string {
82-
string();
83-
string(const char*);
80+
template<typename T>
81+
struct basic_string {
82+
basic_string();
83+
basic_string(const T*);
8484

8585
char &operator[](size_t) const [[clang::lifetimebound]];
8686
};
87-
string operator""s(const char *, size_t);
88-
89-
struct string_view {
90-
string_view();
91-
string_view(const char *p [[clang::lifetimebound]]);
92-
string_view(const string &s [[clang::lifetimebound]]);
87+
using string = basic_string<char>;
88+
string operator""s(const char *, size_t); // expected-warning {{user-defined literal suffixes not starting with '_' are reserved}}
89+
90+
template<typename T>
91+
struct basic_string_view {
92+
basic_string_view();
93+
basic_string_view(const T *p);
94+
basic_string_view(const string &s [[clang::lifetimebound]]);
9395
};
94-
string_view operator""sv(const char *, size_t);
96+
using string_view = basic_string_view<char>;
97+
string_view operator""sv(const char *, size_t); // expected-warning {{user-defined literal suffixes not starting with '_' are reserved}}
9598

9699
struct vector {
97100
int *data();
@@ -100,7 +103,6 @@ namespace std {
100103

101104
template<typename K, typename V> struct map {};
102105
}
103-
# 68 "attr-lifetimebound.cpp" 2
104106

105107
using std::operator""s;
106108
using std::operator""sv;
@@ -112,7 +114,7 @@ namespace p0936r0_examples {
112114
void f() {
113115
std::string_view sv = "hi";
114116
std::string_view sv2 = sv + sv; // expected-warning {{temporary}}
115-
sv2 = sv + sv; // FIXME: can we infer that we should warn here too?
117+
sv2 = sv + sv; // expected-warning {{object backing the pointer}}
116118
}
117119

118120
struct X { int a, b; };
@@ -238,11 +240,6 @@ template <class T> T *addressof(T &arg) {
238240
&const_cast<char &>(reinterpret_cast<const volatile char &>(arg)));
239241
}
240242

241-
template<typename T>
242-
struct basic_string_view {
243-
basic_string_view(const T *);
244-
};
245-
246243
template <class T> struct span {
247244
template<size_t _ArrayExtent>
248245
span(const T (&__arr)[_ArrayExtent]) noexcept;

cross-project-tests/debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"""Interface for communicating with the LLDB debugger via its python interface.
88
"""
99

10-
import imp
1110
import os
1211
import shlex
1312
from subprocess import CalledProcessError, check_output, STDOUT
@@ -18,6 +17,7 @@
1817
from dex.dextIR import StackFrame, SourceLocation, ProgramState
1918
from dex.utils.Exceptions import DebuggerException, LoadDebuggerException
2019
from dex.utils.ReturnCode import ReturnCode
20+
from dex.utils.Imports import load_module
2121

2222

2323
class LLDB(DebuggerBase):
@@ -82,8 +82,7 @@ def _load_interface(self):
8282
)
8383

8484
try:
85-
module_info = imp.find_module("lldb", [pythonpath])
86-
return imp.load_module("lldb", *module_info)
85+
return load_module("lldb", pythonpath)
8786
except ImportError as e:
8887
msg = str(e)
8988
if msg.endswith("not a valid Win32 application."):

cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"""Interface for communicating with the Visual Studio debugger via DTE."""
88

99
import abc
10-
import imp
1110
import os
1211
import sys
1312
from enum import IntEnum
@@ -19,15 +18,14 @@
1918
from dex.dextIR import FrameIR, LocIR, StepIR, StopReason, ValueIR
2019
from dex.dextIR import StackFrame, SourceLocation, ProgramState
2120
from dex.utils.Exceptions import Error, LoadDebuggerException
21+
from dex.utils.Imports import load_module
2222
from dex.utils.ReturnCode import ReturnCode
2323

24-
2524
def _load_com_module():
2625
try:
27-
module_info = imp.find_module(
28-
"ComInterface", [os.path.join(os.path.dirname(__file__), "windows")]
26+
return load_module(
27+
"ComInterface", os.path.join(os.path.dirname(__file__), "windows")
2928
)
30-
return imp.load_module("ComInterface", *module_info)
3129
except ImportError as e:
3230
raise LoadDebuggerException(e, sys.exc_info())
3331

cross-project-tests/debuginfo-tests/dexter/dex/tools/Main.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
subtool.
1111
"""
1212

13-
import imp
1413
import os
1514
import sys
1615

1716
from dex.utils import PrettyOutput, Timer
1817
from dex.utils import ExtArgParse as argparse
1918
from dex.utils import get_root_directory
2019
from dex.utils.Exceptions import Error, ToolArgumentError
20+
from dex.utils.Imports import load_module
2121
from dex.utils.Logging import Logger
2222
from dex.utils.UnitTests import unit_tests_ok
2323
from dex.utils.Version import version
@@ -135,9 +135,7 @@ def _import_tool_module(tool_name):
135135
tool_name = tool_name.replace("-", "_")
136136

137137
tools_directory = get_tools_directory()
138-
module_info = imp.find_module(tool_name, [tools_directory])
139-
140-
return imp.load_module(tool_name, *module_info)
138+
return load_module(tool_name, tools_directory)
141139

142140

143141
def tool_main(context, tool, args):

cross-project-tests/debuginfo-tests/dexter/dex/tools/help/Tool.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77
"""Help tool."""
88

9-
import imp
109
import textwrap
1110

1211
from dex.tools import ToolBase, get_tool_names, get_tools_directory, tool_main
12+
from dex.utils.Imports import load_module
1313
from dex.utils.ReturnCode import ReturnCode
1414

1515

@@ -39,8 +39,7 @@ def _default_text(self):
3939
tools_directory = get_tools_directory()
4040
for tool_name in sorted(self._visible_tool_names):
4141
internal_name = tool_name.replace("-", "_")
42-
module_info = imp.find_module(internal_name, [tools_directory])
43-
tool_doc = imp.load_module(internal_name, *module_info).Tool.__doc__
42+
tool_doc = load_module(internal_name, tools_directory).Tool.__doc__
4443
tool_doc = tool_doc.strip() if tool_doc else ""
4544
tool_doc = textwrap.fill(" ".join(tool_doc.split()), 80)
4645
s += "<g>{}</>\n{}\n\n".format(tool_name, tool_doc)
@@ -53,6 +52,5 @@ def go(self) -> ReturnCode:
5352

5453
tool_name = self.context.options.tool.replace("-", "_")
5554
tools_directory = get_tools_directory()
56-
module_info = imp.find_module(tool_name, [tools_directory])
57-
module = imp.load_module(tool_name, *module_info)
55+
module = load_module(tool_name, tools_directory)
5856
return tool_main(self.context, module.Tool(self.context), ["--help"])
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import importlib
2+
import os
3+
import sys
4+
5+
6+
def load_module(name, path):
7+
spec = importlib.util.spec_from_file_location(
8+
name, os.path.join(path, name, "__init__.py")
9+
)
10+
module = importlib.util.module_from_spec(spec)
11+
sys.modules[name] = module
12+
spec.loader.exec_module(module)
13+
return module

0 commit comments

Comments
 (0)