Skip to content

Commit c4d4d7a

Browse files
authored
Merge branch 'main' into makslevental/update-create-3n
2 parents df96a8d + 54492c2 commit c4d4d7a

35 files changed

+1220
-547
lines changed

clang/docs/ClangTools.rst

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,50 @@ they'll be tracked here. The focus of this documentation is on the scope
8989
and features of the tools for other tool developers; each tool should
9090
provide its own user-focused documentation.
9191

92-
``clang-tidy``
92+
``Clang-Doc``
93+
-------------
94+
95+
`Clang-Doc <https://clang.llvm.org/extra/clang-doc.html>`_ is a tool for
96+
generating C and C++ documentation from source code and comments.
97+
98+
``Clang-Include-Fixer``
99+
-----------------------
100+
101+
`Clang-Include-Fixer <https://clang.llvm.org/extra/clang-include-fixer.html>`_
102+
is a tool to automate the addition of missing ``#include`` directives in a C++
103+
file. It adds missing namespace qualifiers to unidentified symbols when
104+
necessary and also removes unused headers.
105+
106+
``Clang-Tidy``
93107
--------------
94108

95-
`clang-tidy <https://clang.llvm.org/extra/clang-tidy/>`_ is a clang-based C++
109+
`Clang-Tidy <https://clang.llvm.org/extra/clang-tidy/>`_ is a Clang-based C++
96110
linter tool. It provides an extensible framework for building compiler-based
97111
static analyses detecting and fixing bug-prone patterns, performance,
98-
portability and maintainability issues.
112+
portability and maintainability issues. It also has checks for modernizing code
113+
to newer language standards.
114+
115+
``Clangd``
116+
----------
117+
118+
`Clangd <https://clangd.llvm.org/>`_ is a language server that can work with
119+
many editors via a plugin. It understands your C++ code and adds smart
120+
features to your editor: code completion, compile errors, go-to-definition and
121+
more.
122+
123+
``Modularize``
124+
--------------
125+
126+
`Modularize <https://clang.llvm.org/extra/modularize.html>`_ is a standalone
127+
tool that checks whether a set of headers provides the consistent definitions
128+
required to use modules.
129+
130+
``pp-trace``
131+
------------
132+
133+
`pp-trace <https://clang.llvm.org/extra/pp-trace.html>`_ is a standalone tool
134+
that traces preprocessor activity. It’s also used as a test of Clang’s
135+
``PPCallbacks`` interface.
99136

100137

101138
Ideas for new Tools

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6375,6 +6375,9 @@ bool Compiler<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
63756375
if (!this->visit(SubExpr))
63766376
return false;
63776377

6378+
if (!this->emitCheckNull(E))
6379+
return false;
6380+
63786381
if (classifyPrim(SubExpr) == PT_Ptr)
63796382
return this->emitNarrowPtr(E);
63806383
return true;

clang/lib/AST/ByteCode/Interp.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,6 +1885,16 @@ inline bool Dump(InterpState &S, CodePtr OpPC) {
18851885
return true;
18861886
}
18871887

1888+
inline bool CheckNull(InterpState &S, CodePtr OpPC) {
1889+
const auto &Ptr = S.Stk.peek<Pointer>();
1890+
if (Ptr.isZero()) {
1891+
S.FFDiag(S.Current->getSource(OpPC),
1892+
diag::note_constexpr_dereferencing_null);
1893+
return S.noteUndefinedBehavior();
1894+
}
1895+
return true;
1896+
}
1897+
18881898
inline bool VirtBaseHelper(InterpState &S, CodePtr OpPC, const RecordDecl *Decl,
18891899
const Pointer &Ptr) {
18901900
Pointer Base = Ptr;

clang/lib/AST/ByteCode/Opcodes.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,7 @@ def CheckNewTypeMismatchArray : Opcode {
865865

866866
def IsConstantContext: Opcode;
867867
def CheckAllocations : Opcode;
868+
def CheckNull : Opcode;
868869

869870
def BitCastTypeClass : TypeClass {
870871
let Types = [Uint8, Sint8, Uint16, Sint16, Uint32, Sint32, Uint64, Sint64,

clang/test/AST/ByteCode/complex.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,9 @@ namespace ComplexConstexpr {
396396
// both-note {{cannot refer to element 3 of array of 2 elements}}
397397
constexpr _Complex float *p = 0;
398398
constexpr float pr = __real *p; // both-error {{constant expr}} \
399-
// expected-note {{read of dereferenced null pointer}} \
400-
// ref-note {{dereferencing a null pointer}}
399+
// both-note {{dereferencing a null pointer}}
401400
constexpr float pi = __imag *p; // both-error {{constant expr}} \
402-
// ref-note {{dereferencing a null pointer}}
401+
// both-note {{dereferencing a null pointer}}
403402
constexpr const _Complex double *q = &test3 + 1;
404403
constexpr double qr = __real *q; // ref-error {{constant expr}} \
405404
// ref-note {{cannot access real component of pointer past the end}}

clang/test/AST/ByteCode/const-eval.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ typedef __INTPTR_TYPE__ intptr_t;
180180
const intptr_t A = (intptr_t)(((int*) 0) + 1);
181181
const intptr_t B = (intptr_t)(((char*)0) + 3);
182182
_Static_assert(A > B, "");
183+
int * GH149500_p = &(*(int *)0x400);
184+
static const void *GH149500_q = &(*(const struct sysrq_key_op *)0);
185+
183186
#else
184187
#error :(
185188
#endif

clang/test/AST/ByteCode/cxx11.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ struct S {
3939
constexpr S s = { 5 };
4040
constexpr const int *p = &s.m + 1;
4141

42-
constexpr const int *np2 = &(*(int(*)[4])nullptr)[0];
43-
// ref-error@-1 {{constexpr variable 'np2' must be initialized by a constant expression}} \
44-
// ref-note@-1 {{dereferencing a null pointer is not allowed in a constant expression}}
42+
constexpr const int *np2 = &(*(int(*)[4])nullptr)[0]; // both-error {{constexpr variable 'np2' must be initialized by a constant expression}} \
43+
// both-note {{dereferencing a null pointer is not allowed in a constant expression}}
4544

4645
constexpr int preDec(int x) { // both-error {{never produces a constant expression}}
4746
return --x; // both-note {{subexpression}}

clang/test/AST/ByteCode/records.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,11 +1660,9 @@ namespace NullptrCast {
16601660
constexpr A *na = nullptr;
16611661
constexpr B *nb = nullptr;
16621662
constexpr A &ra = *nb; // both-error {{constant expression}} \
1663-
// ref-note {{dereferencing a null pointer}} \
1664-
// expected-note {{cannot access base class of null pointer}}
1663+
// both-note {{dereferencing a null pointer}}
16651664
constexpr B &rb = (B&)*na; // both-error {{constant expression}} \
1666-
// ref-note {{dereferencing a null pointer}} \
1667-
// expected-note {{cannot access derived class of null pointer}}
1665+
// both-note {{dereferencing a null pointer}}
16681666
constexpr bool test() {
16691667
auto a = (A*)(B*)nullptr;
16701668

clang/test/CXX/drs/cwg14xx.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
// RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions -fcxx-exceptions -pedantic-errors
77
// RUN: %clang_cc1 -std=c++2c %s -verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions -fcxx-exceptions -pedantic-errors
88

9+
// RUN: %clang_cc1 -std=c++98 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -fexperimental-new-constant-interpreter
10+
// RUN: %clang_cc1 -std=c++11 %s -verify=expected,cxx11-17,since-cxx11, -fexceptions -fcxx-exceptions -pedantic-errors -fexperimental-new-constant-interpreter
11+
// RUN: %clang_cc1 -std=c++14 %s -verify=expected,cxx14-17,cxx11-17,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors -fexperimental-new-constant-interpreter
12+
// RUN: %clang_cc1 -std=c++17 %s -verify=expected,cxx14-17,cxx11-17,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors -fexperimental-new-constant-interpreter
13+
// RUN: %clang_cc1 -std=c++20 %s -verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions -fcxx-exceptions -pedantic-errors -fexperimental-new-constant-interpreter
14+
// RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions -fcxx-exceptions -pedantic-errors -fexperimental-new-constant-interpreter
15+
// RUN: %clang_cc1 -std=c++2c %s -verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions -fcxx-exceptions -pedantic-errors -fexperimental-new-constant-interpreter
16+
917
namespace cwg1413 { // cwg1413: 12
1018
template<int> struct Check {
1119
typedef int type;

clang/test/Interpreter/pretty-print.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
22
// RUN: 'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s
3-
// UNSUPPORTED: system-aix
3+
// UNSUPPORTED: system-aix, system-zos, asan
44
// CHECK-DRIVER: i = 10
55
// RUN: cat %s | clang-repl -Xcc -std=c++11 -Xcc -fno-delayed-template-parsing | FileCheck %s
66
extern "C" int printf(const char*,...);

0 commit comments

Comments
 (0)