Skip to content

Commit 66292f0

Browse files
committed
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/meinersbur/flang_runtime
2 parents 45795cd + 6708dc3 commit 66292f0

File tree

302 files changed

+28567
-3023
lines changed

Some content is hidden

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

302 files changed

+28567
-3023
lines changed

bolt/lib/Core/BinaryContext.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1759,7 +1759,11 @@ void BinaryContext::preprocessDebugInfo() {
17591759
dwarf::toString(CU->getUnitDIE().find(dwarf::DW_AT_name), nullptr);
17601760
if (std::optional<uint64_t> DWOID = CU->getDWOId()) {
17611761
auto Iter = DWOCUs.find(*DWOID);
1762-
assert(Iter != DWOCUs.end() && "DWO CU was not found.");
1762+
if (Iter == DWOCUs.end()) {
1763+
this->errs() << "BOLT-ERROR: DWO CU was not found for " << Name
1764+
<< '\n';
1765+
exit(1);
1766+
}
17631767
Name = dwarf::toString(
17641768
Iter->second->getUnitDIE().find(dwarf::DW_AT_name), nullptr);
17651769
}

clang-tools-extra/clang-doc/HTMLGenerator.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,18 +494,31 @@ genReferencesBlock(const std::vector<Reference> &References,
494494
static std::unique_ptr<TagNode>
495495
writeFileDefinition(const Location &L,
496496
std::optional<StringRef> RepositoryUrl = std::nullopt) {
497-
if (!L.IsFileInRootDir || !RepositoryUrl)
497+
if (!L.IsFileInRootDir && !RepositoryUrl)
498498
return std::make_unique<TagNode>(
499499
HTMLTag::TAG_P, "Defined at line " + std::to_string(L.LineNumber) +
500500
" of file " + L.Filename);
501501
SmallString<128> FileURL(*RepositoryUrl);
502-
llvm::sys::path::append(FileURL, llvm::sys::path::Style::posix, L.Filename);
502+
llvm::sys::path::append(
503+
FileURL, llvm::sys::path::Style::posix,
504+
// If we're on Windows, the file name will be in the wrong format, and
505+
// append won't convert the full path being appended to the correct
506+
// format, so we need to do that here.
507+
llvm::sys::path::convert_to_slash(
508+
L.Filename,
509+
// The style here is the current style of the path, not the one we're
510+
// targeting. If the string is already in the posix style, it will do
511+
// nothing.
512+
llvm::sys::path::Style::windows));
503513
auto Node = std::make_unique<TagNode>(HTMLTag::TAG_P);
504514
Node->Children.emplace_back(std::make_unique<TextNode>("Defined at line "));
505515
auto LocNumberNode =
506516
std::make_unique<TagNode>(HTMLTag::TAG_A, std::to_string(L.LineNumber));
507517
// The links to a specific line in the source code use the github /
508518
// googlesource notation so it won't work for all hosting pages.
519+
// FIXME: we probably should have a configuration setting for line number
520+
// rendering in the HTML. For example, GitHub uses #L22, while googlesource
521+
// uses #22 for line numbers.
509522
LocNumberNode->Attributes.emplace_back(
510523
"href", (FileURL + "#" + std::to_string(L.LineNumber)).str());
511524
Node->Children.emplace_back(std::move(LocNumberNode));

clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Circle.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ double Circle::area() const {
88

99
double Circle::perimeter() const {
1010
return 3.141 * radius_;
11-
}
11+
}
12+

clang-tools-extra/test/clang-doc/basic-project.test

Lines changed: 176 additions & 123 deletions
Large diffs are not rendered by default.

clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,12 @@ TEST(HTMLGeneratorTest, emitFunctionHTML) {
319319
<a href="path/to/int.html">int</a>
320320
P)
321321
</p>
322-
<p>Defined at line 10 of file dir/test.cpp</p>
322+
<p>
323+
Defined at line
324+
<a href="https://www.repository.com/dir/test.cpp#10">10</a>
325+
of file
326+
<a href="https://www.repository.com/dir/test.cpp">test.cpp</a>
327+
</p>
323328
</div>
324329
<div id="sidebar-right" class="col-xs-6 col-sm-6 col-md-2 sidebar sidebar-offcanvas-right"></div>
325330
</main>

clang/docs/OpenMPSupport.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ implementation.
364364
+=============================================================+===========================+===========================+==========================================================================+
365365
| free-agent threads | :none:`unclaimed` | :none:`unclaimed` | |
366366
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
367+
| threadset clause | :`worked on` | :none:`unclaimed` | |
368+
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
367369
| Recording of task graphs | :none:`unclaimed` | :none:`unclaimed` | |
368370
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
369371
| Parallel inductions | :none:`unclaimed` | :none:`unclaimed` | |
@@ -410,7 +412,7 @@ implementation.
410412
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
411413
| Extensions to interop construct | :none:`unclaimed` | :none:`unclaimed` | |
412414
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
413-
| no_openmp_constructs | :none:`unclaimed` | :none:`unclaimed` | |
415+
| no_openmp_constructs | :good:`done` | :none:`unclaimed` | https://github.com/llvm/llvm-project/pull/125933 |
414416
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
415417
| safe_sync and progress with identifier and API | :none:`unclaimed` | :none:`unclaimed` | |
416418
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+

clang/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@ Improvements
263263
Moved checkers
264264
^^^^^^^^^^^^^^
265265

266+
- After lots of improvements, the checker ``alpha.security.ArrayBoundV2`` is
267+
renamed to ``security.ArrayBound``. As this checker is stable now, the old
268+
checker ``alpha.security.ArrayBound`` (which was searching for the same kind
269+
of bugs with an different, simpler and less accurate algorithm) is removed.
270+
266271
.. _release-notes-sanitizers:
267272

268273
Sanitizers
@@ -273,6 +278,7 @@ Python Binding Changes
273278

274279
OpenMP Support
275280
--------------
281+
- Added support 'no_openmp_constructs' assumption clause.
276282

277283
Improvements
278284
^^^^^^^^^^^^

clang/docs/analyzer/checkers.rst

Lines changed: 60 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,10 +1332,69 @@ security
13321332
13331333
Security related checkers.
13341334
1335+
.. _security-ArrayBound:
1336+
1337+
security.ArrayBound (C, C++)
1338+
""""""""""""""""""""""""""""
1339+
Report out of bounds access to memory that is before the start or after the end
1340+
of the accessed region (array, heap-allocated region, string literal etc.).
1341+
This usually means incorrect indexing, but the checker also detects access via
1342+
the operators ``*`` and ``->``.
1343+
1344+
.. code-block:: c
1345+
1346+
void test_underflow(int x) {
1347+
int buf[100][100];
1348+
if (x < 0)
1349+
buf[0][x] = 1; // warn
1350+
}
1351+
1352+
void test_overflow() {
1353+
int buf[100];
1354+
int *p = buf + 100;
1355+
*p = 1; // warn
1356+
}
1357+
1358+
If checkers like :ref:`unix-Malloc` or :ref:`cplusplus-NewDelete` are enabled
1359+
to model the behavior of ``malloc()``, ``operator new`` and similar
1360+
allocators), then this checker can also reports out of bounds access to
1361+
dynamically allocated memory:
1362+
1363+
.. code-block:: cpp
1364+
1365+
int *test_dynamic() {
1366+
int *mem = new int[100];
1367+
mem[-1] = 42; // warn
1368+
return mem;
1369+
}
1370+
1371+
In uncertain situations (when the checker can neither prove nor disprove that
1372+
overflow occurs), the checker assumes that the the index (more precisely, the
1373+
memory offeset) is within bounds.
1374+
1375+
However, if :ref:`optin-taint-GenericTaint` is enabled and the index/offset is
1376+
tainted (i.e. it is influenced by an untrusted souce), then this checker
1377+
reports the potential out of bounds access:
1378+
1379+
.. code-block:: c
1380+
1381+
void test_with_tainted_index() {
1382+
char s[] = "abc";
1383+
int x = getchar();
1384+
char c = s[x]; // warn: potential out of bounds access with tainted index
1385+
}
1386+
1387+
.. note::
1388+
1389+
This checker is an improved and renamed version of the checker that was
1390+
previously known as ``alpha.security.ArrayBoundV2``. The old checker
1391+
``alpha.security.ArrayBound`` was removed when the (previously
1392+
"experimental") V2 variant became stable enough for regular use.
1393+
13351394
.. _security-cert-env-InvalidPtr:
13361395
13371396
security.cert.env.InvalidPtr
1338-
""""""""""""""""""""""""""""""""""
1397+
""""""""""""""""""""""""""""
13391398
13401399
Corresponds to SEI CERT Rules `ENV31-C <https://wiki.sei.cmu.edu/confluence/display/c/ENV31-C.+Do+not+rely+on+an+environment+pointer+following+an+operation+that+may+invalidate+it>`_ and `ENV34-C <https://wiki.sei.cmu.edu/confluence/display/c/ENV34-C.+Do+not+store+pointers+returned+by+certain+functions>`_.
13411400
@@ -3216,78 +3275,6 @@ Warns against using one vs. many plural pattern in code when generating localize
32163275
alpha.security
32173276
^^^^^^^^^^^^^^
32183277
3219-
.. _alpha-security-ArrayBound:
3220-
3221-
alpha.security.ArrayBound (C)
3222-
"""""""""""""""""""""""""""""
3223-
Warn about buffer overflows (older checker).
3224-
3225-
.. code-block:: c
3226-
3227-
void test() {
3228-
char *s = "";
3229-
char c = s[1]; // warn
3230-
}
3231-
3232-
struct seven_words {
3233-
int c[7];
3234-
};
3235-
3236-
void test() {
3237-
struct seven_words a, *p;
3238-
p = &a;
3239-
p[0] = a;
3240-
p[1] = a;
3241-
p[2] = a; // warn
3242-
}
3243-
3244-
// note: requires unix.Malloc or
3245-
// alpha.unix.MallocWithAnnotations checks enabled.
3246-
void test() {
3247-
int *p = malloc(12);
3248-
p[3] = 4; // warn
3249-
}
3250-
3251-
void test() {
3252-
char a[2];
3253-
int *b = (int*)a;
3254-
b[1] = 3; // warn
3255-
}
3256-
3257-
.. _alpha-security-ArrayBoundV2:
3258-
3259-
alpha.security.ArrayBoundV2 (C)
3260-
"""""""""""""""""""""""""""""""
3261-
Warn about buffer overflows (newer checker).
3262-
3263-
.. code-block:: c
3264-
3265-
void test() {
3266-
char *s = "";
3267-
char c = s[1]; // warn
3268-
}
3269-
3270-
void test() {
3271-
int buf[100];
3272-
int *p = buf;
3273-
p = p + 99;
3274-
p[1] = 1; // warn
3275-
}
3276-
3277-
// note: compiler has internal check for this.
3278-
// Use -Wno-array-bounds to suppress compiler warning.
3279-
void test() {
3280-
int buf[100][100];
3281-
buf[0][-1] = 1; // warn
3282-
}
3283-
3284-
// note: requires optin.taint check turned on.
3285-
void test() {
3286-
char s[] = "abc";
3287-
int x = getchar();
3288-
char c = s[x]; // warn: index is tainted
3289-
}
3290-
32913278
.. _alpha-security-ReturnPtrRange:
32923279
32933280
alpha.security.ReturnPtrRange (C)

clang/include/clang/AST/OpenMPClause.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2423,6 +2423,28 @@ class OMPNoOpenMPRoutinesClause final
24232423
OMPNoOpenMPRoutinesClause() : OMPNoChildClause() {}
24242424
};
24252425

2426+
/// This represents the 'no_openmp_constructs' clause in the
2427+
//// '#pragma omp assume' directive.
2428+
///
2429+
/// \code
2430+
/// #pragma omp assume no_openmp_constructs
2431+
/// \endcode
2432+
/// In this example directive '#pragma omp assume' has a 'no_openmp_constructs'
2433+
/// clause.
2434+
class OMPNoOpenMPConstructsClause final
2435+
: public OMPNoChildClause<llvm::omp::OMPC_no_openmp_constructs> {
2436+
public:
2437+
/// Build 'no_openmp_constructs' clause.
2438+
///
2439+
/// \param StartLoc Starting location of the clause.
2440+
/// \param EndLoc Ending location of the clause.
2441+
OMPNoOpenMPConstructsClause(SourceLocation StartLoc, SourceLocation EndLoc)
2442+
: OMPNoChildClause(StartLoc, EndLoc) {}
2443+
2444+
/// Build an empty clause.
2445+
OMPNoOpenMPConstructsClause() : OMPNoChildClause() {}
2446+
};
2447+
24262448
/// This represents the 'no_parallelism' clause in the '#pragma omp assume'
24272449
/// directive.
24282450
///

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3544,6 +3544,12 @@ bool RecursiveASTVisitor<Derived>::VisitOMPNoOpenMPRoutinesClause(
35443544
return true;
35453545
}
35463546

3547+
template <typename Derived>
3548+
bool RecursiveASTVisitor<Derived>::VisitOMPNoOpenMPConstructsClause(
3549+
OMPNoOpenMPConstructsClause *) {
3550+
return true;
3551+
}
3552+
35473553
template <typename Derived>
35483554
bool RecursiveASTVisitor<Derived>::VisitOMPNoParallelismClause(
35493555
OMPNoParallelismClause *) {

clang/include/clang/Basic/AttrDocs.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5274,6 +5274,7 @@ optimization passes are aware of the following assumptions:
52745274
"omp_no_openmp"
52755275
"omp_no_openmp_routines"
52765276
"omp_no_parallelism"
5277+
"omp_no_openmp_constructs"
52775278

52785279
The OpenMP standard defines the meaning of OpenMP assumptions ("omp_XYZ" is
52795280
spelled "XYZ" in the `OpenMP 5.1 Standard`_).

clang/include/clang/StaticAnalyzer/Checkers/Checkers.td

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -989,30 +989,41 @@ def decodeValueOfObjCType : Checker<"decodeValueOfObjCType">,
989989

990990
let ParentPackage = Security in {
991991

992-
def FloatLoopCounter : Checker<"FloatLoopCounter">,
993-
HelpText<"Warn on using a floating point value as a loop counter (CERT: "
994-
"FLP30-C, FLP30-CPP)">,
995-
Dependencies<[SecuritySyntaxChecker]>,
996-
Documentation<HasDocumentation>;
997-
998-
def MmapWriteExecChecker : Checker<"MmapWriteExec">,
999-
HelpText<"Warn on mmap() calls with both writable and executable access">,
1000-
Documentation<HasDocumentation>;
1001-
1002-
def PointerSubChecker : Checker<"PointerSub">,
1003-
HelpText<"Check for pointer subtractions on two pointers pointing to "
1004-
"different memory chunks">,
1005-
Documentation<HasDocumentation>;
1006-
1007-
def PutenvStackArray : Checker<"PutenvStackArray">,
1008-
HelpText<"Finds calls to the function 'putenv' which pass a pointer to "
1009-
"an automatic (stack-allocated) array as the argument.">,
1010-
Documentation<HasDocumentation>;
1011-
1012-
def SetgidSetuidOrderChecker : Checker<"SetgidSetuidOrder">,
1013-
HelpText<"Warn on possible reversed order of 'setgid(getgid()))' and "
1014-
"'setuid(getuid())' (CERT: POS36-C)">,
1015-
Documentation<HasDocumentation>;
992+
def ArrayBoundChecker : Checker<"ArrayBound">,
993+
HelpText<"Warn about out of bounds access to memory">,
994+
Documentation<HasDocumentation>;
995+
996+
def FloatLoopCounter
997+
: Checker<"FloatLoopCounter">,
998+
HelpText<
999+
"Warn on using a floating point value as a loop counter (CERT: "
1000+
"FLP30-C, FLP30-CPP)">,
1001+
Dependencies<[SecuritySyntaxChecker]>,
1002+
Documentation<HasDocumentation>;
1003+
1004+
def MmapWriteExecChecker
1005+
: Checker<"MmapWriteExec">,
1006+
HelpText<
1007+
"Warn on mmap() calls with both writable and executable access">,
1008+
Documentation<HasDocumentation>;
1009+
1010+
def PointerSubChecker
1011+
: Checker<"PointerSub">,
1012+
HelpText<"Check for pointer subtractions on two pointers pointing to "
1013+
"different memory chunks">,
1014+
Documentation<HasDocumentation>;
1015+
1016+
def PutenvStackArray
1017+
: Checker<"PutenvStackArray">,
1018+
HelpText<"Finds calls to the function 'putenv' which pass a pointer to "
1019+
"an automatic (stack-allocated) array as the argument.">,
1020+
Documentation<HasDocumentation>;
1021+
1022+
def SetgidSetuidOrderChecker
1023+
: Checker<"SetgidSetuidOrder">,
1024+
HelpText<"Warn on possible reversed order of 'setgid(getgid()))' and "
1025+
"'setuid(getuid())' (CERT: POS36-C)">,
1026+
Documentation<HasDocumentation>;
10161027

10171028
} // end "security"
10181029

@@ -1035,14 +1046,6 @@ let ParentPackage = ENV in {
10351046

10361047
let ParentPackage = SecurityAlpha in {
10371048

1038-
def ArrayBoundChecker : Checker<"ArrayBound">,
1039-
HelpText<"Warn about buffer overflows (older checker)">,
1040-
Documentation<HasDocumentation>;
1041-
1042-
def ArrayBoundCheckerV2 : Checker<"ArrayBoundV2">,
1043-
HelpText<"Warn about buffer overflows (newer checker)">,
1044-
Documentation<HasDocumentation>;
1045-
10461049
def ReturnPointerRangeChecker : Checker<"ReturnPtrRange">,
10471050
HelpText<"Check for an out-of-bound pointer being returned to callers">,
10481051
Documentation<HasDocumentation>;

clang/include/module.modulemap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ module Clang_Diagnostics {
112112
module Parse { header "clang/Basic/DiagnosticParse.h" export * }
113113
module Serialization { header "clang/Serialization/SerializationDiagnostic.h" export * }
114114
module Refactoring { header "clang/Tooling/Refactoring/RefactoringDiagnostic.h" export * }
115+
116+
textual header "clang/Basic/AllDiagnosticKinds.inc"
115117
}
116118

117119
module Clang_Driver {

0 commit comments

Comments
 (0)