Skip to content

Commit ece3376

Browse files
author
git apple-llvm automerger
committed
Merge commit '7c5209d01779' from llvm.org/main into experimental/cas/main
2 parents 88ce203 + 7c5209d commit ece3376

File tree

101 files changed

+2477
-1343
lines changed

Some content is hidden

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

101 files changed

+2477
-1343
lines changed

clang-tools-extra/clangd/Hover.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,9 @@ struct PrintExprResult {
468468
std::optional<std::string> PrintedValue;
469469
/// The Expr object that represents the closest evaluable
470470
/// expression.
471-
const clang::Expr *Expr;
471+
const clang::Expr *TheExpr;
472472
/// The node of selection tree where the traversal stops.
473-
const SelectionTree::Node *Node;
473+
const SelectionTree::Node *TheNode;
474474
};
475475

476476
// Seek the closest evaluable expression along the ancestors of node N
@@ -731,12 +731,12 @@ HoverInfo evaluateMacroExpansion(unsigned int SpellingBeginOffset,
731731
// Attempt to evaluate it from Expr first.
732732
auto ExprResult = printExprValue(StartNode, Context);
733733
HI.Value = std::move(ExprResult.PrintedValue);
734-
if (auto *E = ExprResult.Expr)
734+
if (auto *E = ExprResult.TheExpr)
735735
HI.Type = printType(E->getType(), Context, PP);
736736

737737
// If failed, extract the type from Decl if possible.
738-
if (!HI.Value && !HI.Type && ExprResult.Node)
739-
if (auto *VD = ExprResult.Node->ASTNode.get<VarDecl>())
738+
if (!HI.Value && !HI.Type && ExprResult.TheNode)
739+
if (auto *VD = ExprResult.TheNode->ASTNode.get<VarDecl>())
740740
HI.Type = printType(VD->getType(), Context, PP);
741741

742742
return HI;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3998,7 +3998,8 @@ constexpr u64 pow_with_mod(u64 a, u64 b, u64 p) {
39983998
auto H = getHover(AST, C.point(), format::getLLVMStyle(), nullptr);
39993999

40004000
ASSERT_TRUE(H);
4001-
EXPECT_EQ(H->Value, "4");
4001+
EXPECT_TRUE(H->Value);
4002+
EXPECT_TRUE(H->Type);
40024003
}
40034004

40044005
} // namespace

clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-standard-types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ typedef unsigned char uint8_t; // NOLINT
99
typedef unsigned short uint16_t; // NOLINT
1010
typedef unsigned long uint32_t; // NOLINT
1111
typedef unsigned long long uint64_t; // NOLINT
12-
#ifndef _WIN32
12+
#ifndef _MSC_VER
1313
typedef unsigned long long size_t; // NOLINT
1414
#endif
1515
typedef long intptr_t; // NOLINT

clang/docs/ReleaseNotes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,20 @@ New Compiler Flags
192192
- The flag ``-std=c++23`` has been added. This behaves the same as the existing
193193
flag ``-std=c++2b``.
194194

195+
- ``-dumpdir`` has been implemented to specify auxiliary and dump output
196+
filenames for features like ``-gsplit-dwarf``.
197+
195198
Deprecated Compiler Flags
196199
-------------------------
197200

198201
Modified Compiler Flags
199202
-----------------------
200203

204+
- ``clang -g -gsplit-dwarf a.c -o obj/x`` (compile and link) now generates the
205+
``.dwo`` file at ``obj/x-a.dwo``, instead of a file in the temporary
206+
directory (``/tmp`` on \*NIX systems, if none of the environment variables
207+
TMPDIR, TMP, and TEMP are specified).
208+
201209
Removed Compiler Flags
202210
-------------------------
203211
- The deprecated flag `-fmodules-ts` is removed. Please use ``-std=c++20``

clang/docs/StandardCPlusPlusModules.rst

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -461,109 +461,6 @@ Note that **currently** the compiler doesn't consider inconsistent macro definit
461461
Currently Clang would accept the above example. But it may produce surprising results if the
462462
debugging code depends on consistent use of ``NDEBUG`` also in other translation units.
463463

464-
Source content consistency
465-
^^^^^^^^^^^^^^^^^^^^^^^^^^
466-
467-
When the compiler reads a BMI, the compiler will check the consistency of the corresponding
468-
source files. For example:
469-
470-
.. code-block:: c++
471-
472-
// M.cppm
473-
export module M;
474-
export template <class T>
475-
T foo(T t) {
476-
return t;
477-
}
478-
479-
// Use.cpp
480-
import M;
481-
void bar() {
482-
foo(5);
483-
}
484-
485-
.. code-block:: console
486-
487-
$ clang++ -std=c++20 M.cppm --precompile -o M.pcm
488-
$ rm M.cppm
489-
$ clang++ -std=c++20 Use.cpp -fmodule-file=M=M.pcm
490-
491-
The compiler would reject the example since the compiler failed to find the source file to check the consistency.
492-
So the following example would be rejected too.
493-
494-
.. code-block:: console
495-
496-
$ clang++ -std=c++20 M.cppm --precompile -o M.pcm
497-
$ echo "int i=0;" >> M.cppm
498-
$ clang++ -std=c++20 Use.cpp -fmodule-file=M=M.pcm
499-
500-
The compiler would reject it too since the compiler detected the file was changed.
501-
502-
But it is OK to move the BMI as long as the source files remain:
503-
504-
.. code-block:: console
505-
506-
$ clang++ -std=c++20 M.cppm --precompile -o M.pcm
507-
$ mkdir -p tmp
508-
$ mv M.pcm tmp/M.pcm
509-
$ clang++ -std=c++20 Use.cpp -fmodule-file=M=tmp/M.pcm
510-
511-
The above example would be accepted.
512-
513-
If the user doesn't want to follow the consistency requirement due to some reasons (e.g., distributing BMI),
514-
the user could try to use ``-Xclang -fmodules-embed-all-files`` when producing BMI. For example:
515-
516-
.. code-block:: console
517-
518-
$ clang++ -std=c++20 M.cppm --precompile -Xclang -fmodules-embed-all-files -o M.pcm
519-
$ rm M.cppm
520-
$ clang++ -std=c++20 Use.cpp -fmodule-file=M=M.pcm
521-
522-
Now the compiler would accept the above example.
523-
Important note: Xclang options are intended to be used by compiler internally and its semantics
524-
are not guaranteed to be preserved in future versions.
525-
526-
Also the compiler will record the path to the header files included in the global module fragment and compare the
527-
headers when imported. For example,
528-
529-
.. code-block:: c++
530-
531-
// foo.h
532-
#include <iostream>
533-
void Hello() {
534-
std::cout << "Hello World.\n";
535-
}
536-
537-
// foo.cppm
538-
module;
539-
#include "foo.h"
540-
export module foo;
541-
export using ::Hello;
542-
543-
// Use.cpp
544-
import foo;
545-
int main() {
546-
Hello();
547-
}
548-
549-
Then it is problematic if we remove ``foo.h`` before import `foo` module.
550-
551-
.. code-block:: console
552-
553-
$ clang++ -std=c++20 foo.cppm --precompile -o foo.pcm
554-
$ mv foo.h foo.orig.h
555-
# The following one is rejected
556-
$ clang++ -std=c++20 Use.cpp -fmodule-file=foo=foo.pcm -c
557-
558-
The above case will rejected. And we're still able to workaround it by ``-Xclang -fmodules-embed-all-files`` option:
559-
560-
.. code-block:: console
561-
562-
$ clang++ -std=c++20 foo.cppm --precompile -Xclang -fmodules-embed-all-files -o foo.pcm
563-
$ mv foo.h foo.orig.h
564-
$ clang++ -std=c++20 Use.cpp -fmodule-file=foo=foo.pcm -c -o Use.o
565-
$ clang++ Use.o foo.pcm
566-
567464
ABI Impacts
568465
-----------
569466

clang/include/clang/Driver/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,10 @@ def module_dependency_dir : Separate<["-"], "module-dependency-dir">,
11431143
def dsym_dir : JoinedOrSeparate<["-"], "dsym-dir">,
11441144
Flags<[NoXarchOption, RenderAsInput]>,
11451145
HelpText<"Directory to output dSYM's (if any) to">, MetaVarName<"<dir>">;
1146+
// GCC style -dumpdir. We intentionally don't implement the less useful -dumpbase{,-ext}.
1147+
def dumpdir : Separate<["-"], "dumpdir">, Flags<[CC1Option]>,
1148+
MetaVarName<"<dumppfx>">,
1149+
HelpText<"Use <dumpfpx> as a prefix to form auxiliary and dump file names">;
11461150
def dumpmachine : Flag<["-"], "dumpmachine">;
11471151
def dumpspecs : Flag<["-"], "dumpspecs">, Flags<[Unsupported]>;
11481152
def dumpversion : Flag<["-"], "dumpversion">;

clang/include/clang/Lex/HeaderSearch.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,9 +665,13 @@ class HeaderSearch {
665665

666666
/// Retrieve all the modules corresponding to the given file.
667667
///
668+
/// \param AllowCreation Whether to allow inference of a new submodule, or to
669+
/// only return existing known modules.
670+
///
668671
/// \ref findModuleForHeader should typically be used instead of this.
669672
ArrayRef<ModuleMap::KnownHeader>
670-
findAllModulesForHeader(const FileEntry *File) const;
673+
findAllModulesForHeader(const FileEntry *File,
674+
bool AllowCreation = true) const;
671675

672676
/// Read the contents of the given module map file.
673677
///

clang/include/clang/Lex/ModuleMap.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,13 @@ class ModuleMap {
448448
/// and does not consult the external source. (Those checks are the
449449
/// responsibility of \ref HeaderSearch.)
450450
///
451+
/// \param AllowCreation Whether to allow inference of a new submodule, or to
452+
/// only return existing known modules.
453+
///
451454
/// Typically, \ref findModuleForHeader should be used instead, as it picks
452455
/// the preferred module for the header.
453-
ArrayRef<KnownHeader> findAllModulesForHeader(const FileEntry *File);
456+
ArrayRef<KnownHeader> findAllModulesForHeader(const FileEntry *File,
457+
bool AllowCreation = true);
454458

455459
/// Like \ref findAllModulesForHeader, but do not attempt to infer module
456460
/// ownership from umbrella headers if we've not already done so.

clang/lib/Driver/Driver.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3878,6 +3878,21 @@ void Driver::handleArguments(Compilation &C, DerivedArgList &Args,
38783878
!Args.getLastArgValue(options::OPT_fuse_ld_EQ)
38793879
.equals_insensitive("lld"))
38803880
Diag(clang::diag::err_drv_lto_without_lld);
3881+
3882+
// If -dumpdir is not specified, give a default prefix derived from the link
3883+
// output filename. For example, `clang -g -gsplit-dwarf a.c -o x` passes
3884+
// `-dumpdir x-` to cc1. If -o is unspecified, use
3885+
// stem(getDefaultImageName()) (usually stem("a.out") = "a").
3886+
if (!Args.hasArg(options::OPT_dumpdir)) {
3887+
Arg *Arg = Args.MakeSeparateArg(
3888+
nullptr, getOpts().getOption(options::OPT_dumpdir),
3889+
Args.MakeArgString(Args.getLastArgValue(
3890+
options::OPT_o,
3891+
llvm::sys::path::stem(getDefaultImageName())) +
3892+
"-"));
3893+
Arg->claim();
3894+
Args.append(Arg);
3895+
}
38813896
}
38823897

38833898
if (FinalPhase == phases::Preprocess || Args.hasArg(options::OPT__SLASH_Y_)) {

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4996,6 +4996,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &Job,
49964996
}
49974997
}
49984998

4999+
Args.AddLastArg(CmdArgs, options::OPT_dumpdir);
5000+
49995001
if (const Arg *A = Args.getLastArg(options::OPT_fthinlto_index_EQ)) {
50005002
if (!types::isLLVMIR(Input.getType()))
50015003
D.Diag(diag::err_drv_arg_requires_bitcode_input) << A->getAsString(Args);

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,23 +1248,24 @@ const char *tools::SplitDebugName(const JobAction &JA, const ArgList &Args,
12481248
if (StringRef(A->getValue()) == "single")
12491249
return Args.MakeArgString(Output.getFilename());
12501250

1251-
Arg *FinalOutput = Args.getLastArg(options::OPT_o);
1252-
if (FinalOutput && Args.hasArg(options::OPT_c)) {
1253-
SmallString<128> T(FinalOutput->getValue());
1254-
llvm::sys::path::remove_filename(T);
1255-
llvm::sys::path::append(T, llvm::sys::path::stem(FinalOutput->getValue()));
1256-
AddPostfix(T);
1257-
return Args.MakeArgString(T);
1251+
SmallString<128> T;
1252+
if (const Arg *A = Args.getLastArg(options::OPT_dumpdir)) {
1253+
T = A->getValue();
12581254
} else {
1259-
// Use the compilation dir.
1260-
Arg *A = Args.getLastArg(options::OPT_ffile_compilation_dir_EQ,
1261-
options::OPT_fdebug_compilation_dir_EQ);
1262-
SmallString<128> T(A ? A->getValue() : "");
1263-
SmallString<128> F(llvm::sys::path::stem(Input.getBaseInput()));
1264-
AddPostfix(F);
1265-
T += F;
1266-
return Args.MakeArgString(T);
1255+
Arg *FinalOutput = Args.getLastArg(options::OPT_o);
1256+
if (FinalOutput && Args.hasArg(options::OPT_c)) {
1257+
T = FinalOutput->getValue();
1258+
llvm::sys::path::remove_filename(T);
1259+
llvm::sys::path::append(T,
1260+
llvm::sys::path::stem(FinalOutput->getValue()));
1261+
AddPostfix(T);
1262+
return Args.MakeArgString(T);
1263+
}
12671264
}
1265+
1266+
T += llvm::sys::path::stem(Input.getBaseInput());
1267+
AddPostfix(T);
1268+
return Args.MakeArgString(T);
12681269
}
12691270

12701271
void tools::SplitDebugInfo(const ToolChain &TC, Compilation &C, const Tool &T,

clang/lib/Lex/HeaderSearch.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,13 +1565,14 @@ HeaderSearch::findModuleForHeader(const FileEntry *File, bool AllowTextual,
15651565
}
15661566

15671567
ArrayRef<ModuleMap::KnownHeader>
1568-
HeaderSearch::findAllModulesForHeader(const FileEntry *File) const {
1568+
HeaderSearch::findAllModulesForHeader(const FileEntry *File,
1569+
bool AllowCreation) const {
15691570
if (ExternalSource) {
15701571
// Make sure the external source has handled header info about this file,
15711572
// which includes whether the file is part of a module.
15721573
(void)getExistingFileInfo(File);
15731574
}
1574-
return ModMap.findAllModulesForHeader(File);
1575+
return ModMap.findAllModulesForHeader(File, AllowCreation);
15751576
}
15761577

15771578
static bool suggestModule(HeaderSearch &HS, const FileEntry *File,

clang/lib/Lex/ModuleMap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,12 +683,12 @@ ModuleMap::findOrCreateModuleForHeaderInUmbrellaDir(const FileEntry *File) {
683683
}
684684

685685
ArrayRef<ModuleMap::KnownHeader>
686-
ModuleMap::findAllModulesForHeader(const FileEntry *File) {
686+
ModuleMap::findAllModulesForHeader(const FileEntry *File, bool AllowCreation) {
687687
HeadersMap::iterator Known = findKnownHeader(File);
688688
if (Known != Headers.end())
689689
return Known->second;
690690

691-
if (findOrCreateModuleForHeaderInUmbrellaDir(File))
691+
if (AllowCreation && findOrCreateModuleForHeaderInUmbrellaDir(File))
692692
return Headers.find(File)->second;
693693

694694
return std::nullopt;

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ std::set<const FileEntry *> GetAffectingModuleMaps(const Preprocessor &PP,
185185
if (!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader))
186186
continue;
187187

188-
for (const auto &KH : HS.findAllModulesForHeader(File)) {
188+
for (const auto &KH :
189+
HS.findAllModulesForHeader(File, /*AllowCreation=*/false)) {
189190
if (!KH.getModule())
190191
continue;
191192
ModulesToProcess.push_back(KH.getModule());

clang/test/C/drs/dr1xx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ void dr118(void) {
235235
* type at this point.
236236
*/
237237
Val = sizeof(enum E)
238-
#ifndef _WIN32
238+
#ifndef _MSC_VER
239239
/* expected-error@-2 {{invalid application of 'sizeof' to an incomplete type 'enum E'}} */
240240
/* expected-note@-12 {{definition of 'enum E' is not complete until the closing '}'}} */
241241
#endif

clang/test/Driver/experimental-library-flag.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// On some platforms, -stdlib=libc++ is currently ignored, so -lc++experimental is not added.
22
// Once -stdlib=libc++ works on those, this XFAIL can be removed.
3-
// XFAIL: target={{.*-windows.*}}, target={{.*-(ps4|ps5)}}
3+
// XFAIL: target={{.*-windows-msvc.*}}, target={{.*-(ps4|ps5)}}
44

55
// For some reason, this fails with a core dump on AIX. This needs to be investigated.
66
// UNSUPPORTED: target={{.*}}-aix{{.*}}

clang/test/Driver/hip-gsplit-dwarf-options.hip

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@
1313
// RUN: %clang -### --target=x86_64-unknown-linux-gnu \
1414
// RUN: --offload-arch=gfx906:xnack+ %s -nogpulib -nogpuinc \
1515
// RUN: --offload-arch=gfx900 \
16-
// RUN: -ggdb -gsplit-dwarf 2>&1 | FileCheck %s
16+
// RUN: -ggdb -gsplit-dwarf 2>&1 | FileCheck %s --check-prefix=LINK
1717

1818
// RUN: %clang -### --target=x86_64-unknown-linux-gnu \
1919
// RUN: -fgpu-rdc --offload-arch=gfx906:xnack+ %s -nogpulib -nogpuinc \
2020
// RUN: --offload-arch=gfx900 \
21-
// RUN: -ggdb -gsplit-dwarf 2>&1 | FileCheck %s
21+
// RUN: -ggdb -gsplit-dwarf 2>&1 | FileCheck %s --check-prefix=LINK
2222

2323
// CHECK-DAG: {{".*clang.*".* "-target-cpu" "gfx906".* "-split-dwarf-output" "hip-gsplit-dwarf-options_gfx906:xnack\+.dwo"}}
2424
// CHECK-DAG: {{".*clang.*".* "-target-cpu" "gfx900".* "-split-dwarf-output" "hip-gsplit-dwarf-options_gfx900.dwo"}}
2525
// CHECK-DAG: {{".*clang.*".* "-target-cpu" "x86-64".* "-split-dwarf-output" "hip-gsplit-dwarf-options.dwo"}}
26+
27+
// LINK-DAG: {{".*clang.*".* "-target-cpu" "gfx906".* "-split-dwarf-output" "a-hip-gsplit-dwarf-options_gfx906:xnack\+.dwo"}}
28+
// LINK-DAG: {{".*clang.*".* "-target-cpu" "gfx900".* "-split-dwarf-output" "a-hip-gsplit-dwarf-options_gfx900.dwo"}}
29+
// LINK-DAG: {{".*clang.*".* "-target-cpu" "x86-64".* "-split-dwarf-output" "a-hip-gsplit-dwarf-options.dwo"}}

0 commit comments

Comments
 (0)