Skip to content

Commit 9b1ee3c

Browse files
authored
merge main into amd-staging (llvm#2023)
2 parents 24be03e + e40732f commit 9b1ee3c

File tree

267 files changed

+7521
-1984
lines changed

Some content is hidden

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

267 files changed

+7521
-1984
lines changed

clang-tools-extra/modularize/ModularizeUtilities.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ std::error_code ModularizeUtilities::loadModuleMap(
290290
Target.get(), *HeaderInfo));
291291

292292
// Parse module.modulemap file into module map.
293-
if (ModMap->loadModuleMapFile(ModuleMapEntry, false, Dir)) {
293+
if (ModMap->parseAndLoadModuleMapFile(ModuleMapEntry, false, Dir)) {
294294
return std::error_code(1, std::generic_category());
295295
}
296296

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Regression test for https://github.com/llvm/llvm-project/issues/59819
2+
3+
// RUN: rm -rf %t && mkdir -p %t
4+
// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s
5+
// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MYCLASS-LINE
6+
// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MYCLASS
7+
8+
// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s
9+
// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html --check-prefix=HTML-MYCLASS-LINE
10+
// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html --check-prefix=HTML-MYCLASS
11+
12+
#define DECLARE_METHODS \
13+
/**
14+
* @brief Declare a method to calculate the sum of two numbers
15+
*/ \
16+
int Add(int a, int b) { \
17+
return a + b; \
18+
}
19+
20+
// MD-MYCLASS: ### Add
21+
// MD-MYCLASS: *public int Add(int a, int b)*
22+
// MD-MYCLASS: **brief** Declare a method to calculate the sum of two numbers
23+
24+
// HTML-MYCLASS: <p>public int Add(int a, int b)</p>
25+
// HTML-MYCLASS: <div>brief</div>
26+
// HTML-MYCLASS: <p> Declare a method to calculate the sum of two numbers</p>
27+
28+
29+
class MyClass {
30+
public:
31+
// MD-MYCLASS-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}comments-in-macros.cpp#[[@LINE+2]]*
32+
// HTML-MYCLASS-LINE: <p>Defined at line [[@LINE+1]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}comments-in-macros.cpp</p>
33+
DECLARE_METHODS
34+
};
35+

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,9 @@ Bug Fixes to C++ Support
673673
- Fixed an assertion when trying to constant-fold various builtins when the argument
674674
referred to a reference to an incomplete type. (#GH129397)
675675
- Fixed a crash when a cast involved a parenthesized aggregate initialization in dependent context. (#GH72880)
676+
- Fixed a crash when forming an invalid function type in a dependent context. (#GH138657) (#GH115725) (#GH68852)
677+
- No longer crashes when instantiating invalid variable template specialization
678+
whose type depends on itself. (#GH51347), (#GH55872)
676679

677680
Bug Fixes to AST Handling
678681
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/ASTContext.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2970,6 +2970,11 @@ class ASTContext : public RefCountedBase<ASTContext> {
29702970
TemplateTemplateParmDecl *insertCanonicalTemplateTemplateParmDeclInternal(
29712971
TemplateTemplateParmDecl *CanonTTP) const;
29722972

2973+
/// Determine whether the given template arguments \p Arg1 and \p Arg2 are
2974+
/// equivalent.
2975+
bool isSameTemplateArgument(const TemplateArgument &Arg1,
2976+
const TemplateArgument &Arg2) const;
2977+
29732978
/// Type Query functions. If the type is an instance of the specified class,
29742979
/// return the Type pointer for the underlying maximally pretty type. This
29752980
/// is a member of ASTContext because this may need to do some amount of

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ def ModuleImport : DiagGroup<"module-import">;
621621
def ModuleConflict : DiagGroup<"module-conflict">;
622622
def ModuleFileExtension : DiagGroup<"module-file-extension">;
623623
def ModuleIncludeDirectiveTranslation : DiagGroup<"module-include-translation">;
624+
def ModuleMap : DiagGroup<"module-map">;
624625
def RoundTripCC1Args : DiagGroup<"round-trip-cc1-args">;
625626
def NewlineEOF : DiagGroup<"newline-eof">;
626627
def Nullability : DiagGroup<"nullability">;

clang/include/clang/Basic/DiagnosticLexKinds.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,12 @@ def warn_pp_date_time : Warning<
841841
ShowInSystemHeader, DefaultIgnore, InGroup<DiagGroup<"date-time">>;
842842

843843
// Module map parsing
844+
def remark_mmap_parse : Remark<
845+
"parsing modulemap '%0'">, ShowInSystemHeader, InGroup<ModuleMap>;
846+
def remark_mmap_load : Remark<
847+
"loading modulemap '%0'">, ShowInSystemHeader, InGroup<ModuleMap>;
848+
def remark_mmap_load_module : Remark<
849+
"loading parsed module '%0'">, ShowInSystemHeader, InGroup<ModuleMap>;
844850
def err_mmap_unknown_token : Error<"skipping stray token">;
845851
def err_mmap_expected_module : Error<"expected module declaration">;
846852
def err_mmap_expected_module_name : Error<"expected module name">;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,9 +2526,14 @@ def note_implicit_deduction_guide : Note<"implicit deduction guide declared as '
25262526
def warn_cxx98_compat_auto_type_specifier : Warning<
25272527
"'auto' type specifier is incompatible with C++98">,
25282528
InGroup<CXX98Compat>, DefaultIgnore;
2529-
def err_auto_variable_cannot_appear_in_own_initializer : Error<
2530-
"variable %0 declared with deduced type %1 "
2531-
"cannot appear in its own initializer">;
2529+
def err_auto_variable_cannot_appear_in_own_initializer
2530+
: Error<
2531+
"%enum_select<ParsingInitFor>{%Var{variable}|"
2532+
"%VarTemplate{variable template}|"
2533+
"%VarTemplatePartialSpec{variable template partial specialization}|"
2534+
"%VarTemplateExplicitSpec{variable template explicit "
2535+
"specialization}}0 %1 "
2536+
"declared with deduced type %2 cannot appear in its own initializer">;
25322537
def err_binding_cannot_appear_in_own_initializer : Error<
25332538
"binding %0 cannot appear in the initializer of its own "
25342539
"decomposition declaration">;
@@ -5302,6 +5307,9 @@ def err_template_member_noparams : Error<
53025307
"extraneous 'template<>' in declaration of member %0">;
53035308
def err_template_tag_noparams : Error<
53045309
"extraneous 'template<>' in declaration of %0 %1">;
5310+
def err_var_template_spec_type_depends_on_self : Error<
5311+
"the type of variable template specialization %0 declared with deduced type "
5312+
"%1 depends on itself">;
53055313

53065314
def warn_unqualified_call_to_std_cast_function : Warning<
53075315
"unqualified call to '%0'">, InGroup<DiagGroup<"unqualified-std-cast-call">>;

clang/include/clang/Basic/FPOptions.def

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,26 @@
77
//===----------------------------------------------------------------------===//
88

99
// This file defines the Floating Point language options. Users of this file
10-
// must define the OPTION macro to make use of this information.
11-
#ifndef OPTION
12-
# error Define the OPTION macro to handle floating point language options
10+
// must define the FP_OPTION macro to make use of this information.
11+
#ifndef FP_OPTION
12+
# error Define the FP_OPTION macro to handle floating point language options
1313
#endif
1414

15-
// OPTION(name, type, width, previousName)
16-
OPTION(FPContractMode, LangOptions::FPModeKind, 2, First)
17-
OPTION(RoundingMath, bool, 1, FPContractMode)
18-
OPTION(ConstRoundingMode, LangOptions::RoundingMode, 3, RoundingMath)
19-
OPTION(SpecifiedExceptionMode, LangOptions::FPExceptionModeKind, 2, ConstRoundingMode)
20-
OPTION(AllowFEnvAccess, bool, 1, SpecifiedExceptionMode)
21-
OPTION(AllowFPReassociate, bool, 1, AllowFEnvAccess)
22-
OPTION(NoHonorNaNs, bool, 1, AllowFPReassociate)
23-
OPTION(NoHonorInfs, bool, 1, NoHonorNaNs)
24-
OPTION(NoSignedZero, bool, 1, NoHonorInfs)
25-
OPTION(AllowReciprocal, bool, 1, NoSignedZero)
26-
OPTION(AllowApproxFunc, bool, 1, AllowReciprocal)
27-
OPTION(FPEvalMethod, LangOptions::FPEvalMethodKind, 2, AllowApproxFunc)
28-
OPTION(Float16ExcessPrecision, LangOptions::ExcessPrecisionKind, 2, FPEvalMethod)
29-
OPTION(BFloat16ExcessPrecision, LangOptions::ExcessPrecisionKind, 2, Float16ExcessPrecision)
30-
OPTION(MathErrno, bool, 1, BFloat16ExcessPrecision)
31-
OPTION(ComplexRange, LangOptions::ComplexRangeKind, 3, MathErrno)
32-
#undef OPTION
15+
// FP_OPTION(name, type, width, previousName)
16+
FP_OPTION(FPContractMode, LangOptions::FPModeKind, 2, First)
17+
FP_OPTION(RoundingMath, bool, 1, FPContractMode)
18+
FP_OPTION(ConstRoundingMode, LangOptions::RoundingMode, 3, RoundingMath)
19+
FP_OPTION(SpecifiedExceptionMode, LangOptions::FPExceptionModeKind, 2, ConstRoundingMode)
20+
FP_OPTION(AllowFEnvAccess, bool, 1, SpecifiedExceptionMode)
21+
FP_OPTION(AllowFPReassociate, bool, 1, AllowFEnvAccess)
22+
FP_OPTION(NoHonorNaNs, bool, 1, AllowFPReassociate)
23+
FP_OPTION(NoHonorInfs, bool, 1, NoHonorNaNs)
24+
FP_OPTION(NoSignedZero, bool, 1, NoHonorInfs)
25+
FP_OPTION(AllowReciprocal, bool, 1, NoSignedZero)
26+
FP_OPTION(AllowApproxFunc, bool, 1, AllowReciprocal)
27+
FP_OPTION(FPEvalMethod, LangOptions::FPEvalMethodKind, 2, AllowApproxFunc)
28+
FP_OPTION(Float16ExcessPrecision, LangOptions::ExcessPrecisionKind, 2, FPEvalMethod)
29+
FP_OPTION(BFloat16ExcessPrecision, LangOptions::ExcessPrecisionKind, 2, Float16ExcessPrecision)
30+
FP_OPTION(MathErrno, bool, 1, BFloat16ExcessPrecision)
31+
FP_OPTION(ComplexRange, LangOptions::ComplexRangeKind, 3, MathErrno)
32+
#undef FP_OPTION

clang/include/clang/Basic/LangOptions.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ class FPOptions {
856856
// Define a fake option named "First" so that we have a PREVIOUS even for the
857857
// real first option.
858858
static constexpr storage_type FirstShift = 0, FirstWidth = 0;
859-
#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
859+
#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
860860
static constexpr storage_type NAME##Shift = \
861861
PREVIOUS##Shift + PREVIOUS##Width; \
862862
static constexpr storage_type NAME##Width = WIDTH; \
@@ -865,7 +865,7 @@ class FPOptions {
865865
#include "clang/Basic/FPOptions.def"
866866

867867
static constexpr storage_type TotalWidth = 0
868-
#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) +WIDTH
868+
#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) +WIDTH
869869
#include "clang/Basic/FPOptions.def"
870870
;
871871
static_assert(TotalWidth <= StorageBitSize, "Too short type for FPOptions");
@@ -974,7 +974,7 @@ class FPOptions {
974974
// We can define most of the accessors automatically:
975975
// TODO: consider enforcing the assertion that value fits within bits
976976
// statically.
977-
#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
977+
#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
978978
TYPE get##NAME() const { \
979979
return static_cast<TYPE>((Value & NAME##Mask) >> NAME##Shift); \
980980
} \
@@ -1085,7 +1085,7 @@ class FPOptionsOverride {
10851085
}
10861086
bool operator!=(FPOptionsOverride other) const { return !(*this == other); }
10871087

1088-
#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
1088+
#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
10891089
bool has##NAME##Override() const { \
10901090
return OverrideMask & FPOptions::NAME##Mask; \
10911091
} \

clang/include/clang/Lex/HeaderSearch.h

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,27 @@ class HeaderSearch {
332332
/// The mapping between modules and headers.
333333
mutable ModuleMap ModMap;
334334

335+
struct ModuleMapDirectoryState {
336+
OptionalFileEntryRef ModuleMapFile;
337+
enum {
338+
Parsed,
339+
Loaded,
340+
Invalid,
341+
} Status;
342+
};
343+
335344
/// Describes whether a given directory has a module map in it.
336-
llvm::DenseMap<const DirectoryEntry *, bool> DirectoryHasModuleMap;
345+
llvm::DenseMap<const DirectoryEntry *, ModuleMapDirectoryState>
346+
DirectoryModuleMap;
337347

338348
/// Set of module map files we've already loaded, and a flag indicating
339349
/// whether they were valid or not.
340350
llvm::DenseMap<const FileEntry *, bool> LoadedModuleMaps;
341351

352+
/// Set of module map files we've already parsed, and a flag indicating
353+
/// whether they were valid or not.
354+
llvm::DenseMap<const FileEntry *, bool> ParsedModuleMaps;
355+
342356
// A map of discovered headers with their associated include file name.
343357
llvm::DenseMap<const FileEntry *, llvm::SmallString<64>> IncludeNames;
344358

@@ -433,11 +447,6 @@ class HeaderSearch {
433447
/// Retrieve the path to the module cache.
434448
StringRef getModuleCachePath() const { return ModuleCachePath; }
435449

436-
/// Consider modules when including files from this directory.
437-
void setDirectoryHasModuleMap(const DirectoryEntry* Dir) {
438-
DirectoryHasModuleMap[Dir] = true;
439-
}
440-
441450
/// Forget everything we know about headers so far.
442451
void ClearFileInfo() {
443452
FileInfo.clear();
@@ -713,9 +722,10 @@ class HeaderSearch {
713722
/// used to resolve paths within the module (this is required when
714723
/// building the module from preprocessed source).
715724
/// \returns true if an error occurred, false otherwise.
716-
bool loadModuleMapFile(FileEntryRef File, bool IsSystem, FileID ID = FileID(),
717-
unsigned *Offset = nullptr,
718-
StringRef OriginalModuleMapFile = StringRef());
725+
bool parseAndLoadModuleMapFile(FileEntryRef File, bool IsSystem,
726+
FileID ID = FileID(),
727+
unsigned *Offset = nullptr,
728+
StringRef OriginalModuleMapFile = StringRef());
719729

720730
/// Collect the set of all known, top-level modules.
721731
///
@@ -915,26 +925,31 @@ class HeaderSearch {
915925
size_t getTotalMemory() const;
916926

917927
private:
918-
/// Describes what happened when we tried to load a module map file.
919-
enum LoadModuleMapResult {
920-
/// The module map file had already been loaded.
921-
LMM_AlreadyLoaded,
928+
/// Describes what happened when we tried to load or parse a module map file.
929+
enum ModuleMapResult {
930+
/// The module map file had already been processed.
931+
MMR_AlreadyProcessed,
922932

923-
/// The module map file was loaded by this invocation.
924-
LMM_NewlyLoaded,
933+
/// The module map file was processed by this invocation.
934+
MMR_NewlyProcessed,
925935

926936
/// There is was directory with the given name.
927-
LMM_NoDirectory,
937+
MMR_NoDirectory,
928938

929939
/// There was either no module map file or the module map file was
930940
/// invalid.
931-
LMM_InvalidModuleMap
941+
MMR_InvalidModuleMap
932942
};
933943

934-
LoadModuleMapResult loadModuleMapFileImpl(FileEntryRef File, bool IsSystem,
935-
DirectoryEntryRef Dir,
936-
FileID ID = FileID(),
937-
unsigned *Offset = nullptr);
944+
ModuleMapResult parseAndLoadModuleMapFileImpl(FileEntryRef File,
945+
bool IsSystem,
946+
DirectoryEntryRef Dir,
947+
FileID ID = FileID(),
948+
unsigned *Offset = nullptr);
949+
950+
ModuleMapResult parseModuleMapFileImpl(FileEntryRef File, bool IsSystem,
951+
DirectoryEntryRef Dir,
952+
FileID ID = FileID());
938953

939954
/// Try to load the module map file in the given directory.
940955
///
@@ -945,8 +960,8 @@ class HeaderSearch {
945960
///
946961
/// \returns The result of attempting to load the module map file from the
947962
/// named directory.
948-
LoadModuleMapResult loadModuleMapFile(StringRef DirName, bool IsSystem,
949-
bool IsFramework);
963+
ModuleMapResult parseAndLoadModuleMapFile(StringRef DirName, bool IsSystem,
964+
bool IsFramework);
950965

951966
/// Try to load the module map file in the given directory.
952967
///
@@ -956,8 +971,13 @@ class HeaderSearch {
956971
///
957972
/// \returns The result of attempting to load the module map file from the
958973
/// named directory.
959-
LoadModuleMapResult loadModuleMapFile(DirectoryEntryRef Dir, bool IsSystem,
960-
bool IsFramework);
974+
ModuleMapResult parseAndLoadModuleMapFile(DirectoryEntryRef Dir,
975+
bool IsSystem, bool IsFramework);
976+
977+
ModuleMapResult parseModuleMapFile(StringRef DirName, bool IsSystem,
978+
bool IsFramework);
979+
ModuleMapResult parseModuleMapFile(DirectoryEntryRef Dir, bool IsSystem,
980+
bool IsFramework);
961981
};
962982

963983
/// Apply the header search options to get given HeaderSearch object.

0 commit comments

Comments
 (0)