Skip to content

Commit 354f429

Browse files
committed
Merge remote-tracking branch 'origin/main' into req-attach
2 parents bdf27cd + a63fd59 commit 354f429

File tree

138 files changed

+4649
-1760
lines changed

Some content is hidden

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

138 files changed

+4649
-1760
lines changed
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@ Bug Fixes to C++ Support
657657
- Fixed an assertion when trying to constant-fold various builtins when the argument
658658
referred to a reference to an incomplete type. (#GH129397)
659659
- Fixed a crash when a cast involved a parenthesized aggregate initialization in dependent context. (#GH72880)
660+
- Fixed a crash when forming an invalid function type in a dependent context. (#GH138657) (#GH115725) (#GH68852)
660661

661662
Bug Fixes to AST Handling
662663
^^^^^^^^^^^^^^^^^^^^^^^^^

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/lib/AST/JSONNodeDumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1864,7 +1864,7 @@ void JSONNodeDumper::visitVerbatimLineComment(
18641864

18651865
llvm::json::Object JSONNodeDumper::createFPOptions(FPOptionsOverride FPO) {
18661866
llvm::json::Object Ret;
1867-
#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
1867+
#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
18681868
if (FPO.has##NAME##Override()) \
18691869
Ret.try_emplace(#NAME, static_cast<unsigned>(FPO.get##NAME##Override()));
18701870
#include "clang/Basic/FPOptions.def"

clang/lib/AST/TextNodeDumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ const char *TextNodeDumper::getCommandName(unsigned CommandID) {
11141114
}
11151115

11161116
void TextNodeDumper::printFPOptions(FPOptionsOverride FPO) {
1117-
#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
1117+
#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
11181118
if (FPO.has##NAME##Override()) \
11191119
OS << " " #NAME "=" << FPO.get##NAME##Override();
11201120
#include "clang/Basic/FPOptions.def"

clang/lib/Basic/LangOptions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,22 +219,22 @@ FPOptions FPOptions::defaultWithoutTrailingStorage(const LangOptions &LO) {
219219

220220
FPOptionsOverride FPOptions::getChangesSlow(const FPOptions &Base) const {
221221
FPOptions::storage_type OverrideMask = 0;
222-
#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
222+
#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
223223
if (get##NAME() != Base.get##NAME()) \
224224
OverrideMask |= NAME##Mask;
225225
#include "clang/Basic/FPOptions.def"
226226
return FPOptionsOverride(*this, OverrideMask);
227227
}
228228

229229
LLVM_DUMP_METHOD void FPOptions::dump() {
230-
#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
230+
#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
231231
llvm::errs() << "\n " #NAME " " << get##NAME();
232232
#include "clang/Basic/FPOptions.def"
233233
llvm::errs() << "\n";
234234
}
235235

236236
LLVM_DUMP_METHOD void FPOptionsOverride::dump() {
237-
#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
237+
#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
238238
if (has##NAME##Override()) \
239239
llvm::errs() << "\n " #NAME " Override is " << get##NAME##Override();
240240
#include "clang/Basic/FPOptions.def"

clang/lib/Basic/Targets/X86.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,6 @@ class LLVM_LIBRARY_VISIBILITY CygwinX86_64TargetInfo : public X86_64TargetInfo {
965965
CygwinX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
966966
: X86_64TargetInfo(Triple, Opts) {
967967
this->WCharType = TargetInfo::UnsignedShort;
968-
TLSSupported = false;
969968
}
970969

971970
void getTargetDefines(const LangOptions &Opts,

clang/lib/CIR/CodeGen/CIRGenOpenACCClause.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <type_traits>
1414

15+
#include "mlir/Dialect/Arith/IR/Arith.h"
1516
#include "mlir/Dialect/OpenACC/OpenACC.h"
1617
namespace clang {
1718
// Simple type-trait to see if the first template arg is one of the list, so we
@@ -82,6 +83,17 @@ class OpenACCClauseCIREmitter final
8283
return conversionOp.getResult(0);
8384
}
8485

86+
mlir::Value createConstantInt(mlir::Location loc, unsigned width,
87+
int64_t value) {
88+
mlir::IntegerType ty = mlir::IntegerType::get(
89+
&cgf.getMLIRContext(), width,
90+
mlir::IntegerType::SignednessSemantics::Signless);
91+
auto constOp = builder.create<mlir::arith::ConstantOp>(
92+
loc, builder.getIntegerAttr(ty, value));
93+
94+
return constOp.getResult();
95+
}
96+
8597
mlir::acc::DeviceType decodeDeviceType(const IdentifierInfo *ii) {
8698
// '*' case leaves no identifier-info, just a nullptr.
8799
if (!ii)
@@ -336,6 +348,50 @@ class OpenACCClauseCIREmitter final
336348
return clauseNotImplemented(clause);
337349
}
338350
}
351+
352+
void VisitCollapseClause(const OpenACCCollapseClause &clause) {
353+
if constexpr (isOneOfTypes<OpTy, mlir::acc::LoopOp>) {
354+
llvm::APInt value =
355+
clause.getIntExpr()->EvaluateKnownConstInt(cgf.cgm.getASTContext());
356+
357+
value = value.sextOrTrunc(64);
358+
operation.setCollapseForDeviceTypes(builder.getContext(),
359+
lastDeviceTypeValues, value);
360+
} else {
361+
// TODO: When we've implemented this for everything, switch this to an
362+
// unreachable. Combined constructs remain.
363+
return clauseNotImplemented(clause);
364+
}
365+
}
366+
367+
void VisitTileClause(const OpenACCTileClause &clause) {
368+
if constexpr (isOneOfTypes<OpTy, mlir::acc::LoopOp>) {
369+
llvm::SmallVector<mlir::Value> values;
370+
371+
for (const Expr *e : clause.getSizeExprs()) {
372+
mlir::Location exprLoc = cgf.cgm.getLoc(e->getBeginLoc());
373+
374+
// We represent the * as -1. Additionally, this is a constant, so we
375+
// can always just emit it as 64 bits to avoid having to do any more
376+
// work to determine signedness or size.
377+
if (isa<OpenACCAsteriskSizeExpr>(e)) {
378+
values.push_back(createConstantInt(exprLoc, 64, -1));
379+
} else {
380+
llvm::APInt curValue =
381+
e->EvaluateKnownConstInt(cgf.cgm.getASTContext());
382+
values.push_back(createConstantInt(
383+
exprLoc, 64, curValue.sextOrTrunc(64).getSExtValue()));
384+
}
385+
}
386+
387+
operation.setTileForDeviceTypes(builder.getContext(),
388+
lastDeviceTypeValues, values);
389+
} else {
390+
// TODO: When we've implemented this for everything, switch this to an
391+
// unreachable. Combined constructs remain.
392+
return clauseNotImplemented(clause);
393+
}
394+
}
339395
};
340396

341397
template <typename OpTy>

clang/lib/Index/IndexingContext.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class IndexingContext {
4444

4545
public:
4646
IndexingContext(IndexingOptions IndexOpts, IndexDataConsumer &DataConsumer);
47+
// Defaulted, but defined out of line to avoid a dependency on
48+
// HeuristicResolver.h (unique_ptr requires a complete type at
49+
// the point where its destructor is called).
4750
~IndexingContext();
4851

4952
const IndexingOptions &getIndexOpts() const { return IndexOpts; }

0 commit comments

Comments
 (0)