Skip to content

Commit 5f429d2

Browse files
authored
Merge branch 'main' into validation/descriptor-tables
2 parents fbf6776 + 3e898bc commit 5f429d2

File tree

145 files changed

+2680
-1660
lines changed

Some content is hidden

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

145 files changed

+2680
-1660
lines changed

clang/docs/OpenMPSupport.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ implementation.
366366
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
367367
| threadset clause | :part:`in progress` | :none:`unclaimed` | |
368368
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
369-
| Recording of task graphs | :none:`unclaimed` | :none:`unclaimed` | |
369+
| Recording of task graphs | :part:`in progress` | :part:`in progress` | clang: jtb20, flang: kparzysz |
370370
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
371371
| Parallel inductions | :none:`unclaimed` | :none:`unclaimed` | |
372372
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3281,7 +3281,8 @@ defm declspec : BoolOption<"f", "declspec",
32813281
def fmodules_cache_path : Joined<["-"], "fmodules-cache-path=">, Group<i_Group>,
32823282
Flags<[]>, Visibility<[ClangOption, CC1Option]>,
32833283
MetaVarName<"<directory>">,
3284-
HelpText<"Specify the module cache path">;
3284+
HelpText<"Specify the module cache path">,
3285+
MarshallingInfoString<HeaderSearchOpts<"ModuleCachePath">>;
32853286
def fmodules_user_build_path : Separate<["-"], "fmodules-user-build-path">, Group<i_Group>,
32863287
Flags<[]>, Visibility<[ClangOption, CC1Option]>,
32873288
MetaVarName<"<directory>">,

clang/include/clang/Lex/HeaderSearch.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,9 @@ void ApplyHeaderSearchOptions(HeaderSearch &HS,
986986
const LangOptions &Lang,
987987
const llvm::Triple &triple);
988988

989+
void normalizeModuleCachePath(FileManager &FileMgr, StringRef Path,
990+
SmallVectorImpl<char> &NormalizedPath);
991+
989992
} // namespace clang
990993

991994
#endif // LLVM_CLANG_LEX_HEADERSEARCH_H

clang/include/clang/Sema/Sema.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,9 +845,16 @@ enum AttrName { Target, TargetClones, TargetVersion };
845845

846846
void inferNoReturnAttr(Sema &S, const Decl *D);
847847

848+
#ifdef __GNUC__
849+
#pragma GCC diagnostic push
850+
#pragma GCC diagnostic ignored "-Wattributes"
851+
#endif
848852
/// Sema - This implements semantic analysis and AST building for C.
849853
/// \nosubgrouping
850854
class Sema final : public SemaBase {
855+
#ifdef __GNUC__
856+
#pragma GCC diagnostic pop
857+
#endif
851858
// Table of Contents
852859
// -----------------
853860
// 1. Semantic Analysis (Sema.cpp)

clang/lib/Frontend/CompilerInstance.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,16 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
554554
}
555555

556556
std::string CompilerInstance::getSpecificModuleCachePath(StringRef ModuleHash) {
557+
assert(FileMgr && "Specific module cache path requires a FileManager");
558+
559+
if (getHeaderSearchOpts().ModuleCachePath.empty())
560+
return "";
561+
557562
// Set up the module path, including the hash for the module-creation options.
558-
SmallString<256> SpecificModuleCache(getHeaderSearchOpts().ModuleCachePath);
559-
if (!SpecificModuleCache.empty() && !getHeaderSearchOpts().DisableModuleHash)
563+
SmallString<256> SpecificModuleCache;
564+
normalizeModuleCachePath(*FileMgr, getHeaderSearchOpts().ModuleCachePath,
565+
SpecificModuleCache);
566+
if (!getHeaderSearchOpts().DisableModuleHash)
560567
llvm::sys::path::append(SpecificModuleCache, ModuleHash);
561568
return std::string(SpecificModuleCache);
562569
}

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3315,9 +3315,6 @@ static void GenerateHeaderSearchArgs(const HeaderSearchOptions &Opts,
33153315
if (Opts.UseLibcxx)
33163316
GenerateArg(Consumer, OPT_stdlib_EQ, "libc++");
33173317

3318-
if (!Opts.ModuleCachePath.empty())
3319-
GenerateArg(Consumer, OPT_fmodules_cache_path, Opts.ModuleCachePath);
3320-
33213318
for (const auto &File : Opts.PrebuiltModuleFiles)
33223319
GenerateArg(Consumer, OPT_fmodule_file, File.first + "=" + File.second);
33233320

@@ -3420,8 +3417,7 @@ static void GenerateHeaderSearchArgs(const HeaderSearchOptions &Opts,
34203417
}
34213418

34223419
static bool ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
3423-
DiagnosticsEngine &Diags,
3424-
const std::string &WorkingDir) {
3420+
DiagnosticsEngine &Diags) {
34253421
unsigned NumErrorsBefore = Diags.getNumErrors();
34263422

34273423
HeaderSearchOptions *HeaderSearchOpts = &Opts;
@@ -3434,17 +3430,6 @@ static bool ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
34343430
if (const Arg *A = Args.getLastArg(OPT_stdlib_EQ))
34353431
Opts.UseLibcxx = (strcmp(A->getValue(), "libc++") == 0);
34363432

3437-
// Canonicalize -fmodules-cache-path before storing it.
3438-
SmallString<128> P(Args.getLastArgValue(OPT_fmodules_cache_path));
3439-
if (!(P.empty() || llvm::sys::path::is_absolute(P))) {
3440-
if (WorkingDir.empty())
3441-
llvm::sys::fs::make_absolute(P);
3442-
else
3443-
llvm::sys::fs::make_absolute(WorkingDir, P);
3444-
}
3445-
llvm::sys::path::remove_dots(P);
3446-
Opts.ModuleCachePath = std::string(P);
3447-
34483433
// Only the -fmodule-file=<name>=<file> form.
34493434
for (const auto *A : Args.filtered(OPT_fmodule_file)) {
34503435
StringRef Val = A->getValue();
@@ -5021,8 +5006,7 @@ bool CompilerInvocation::CreateFromArgsImpl(
50215006
InputKind DashX = Res.getFrontendOpts().DashX;
50225007
ParseTargetArgs(Res.getTargetOpts(), Args, Diags);
50235008
llvm::Triple T(Res.getTargetOpts().Triple);
5024-
ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), Args, Diags,
5025-
Res.getFileSystemOpts().WorkingDir);
5009+
ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), Args, Diags);
50265010
if (Res.getFrontendOpts().GenReducedBMI ||
50275011
Res.getFrontendOpts().ProgramAction ==
50285012
frontend::GenerateReducedModuleInterface ||

clang/lib/Lex/HeaderSearch.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2183,3 +2183,10 @@ std::string HeaderSearch::suggestPathToFileForDiagnostics(
21832183
}
21842184
return path::convert_to_slash(Filename);
21852185
}
2186+
2187+
void clang::normalizeModuleCachePath(FileManager &FileMgr, StringRef Path,
2188+
SmallVectorImpl<char> &NormalizedPath) {
2189+
NormalizedPath.assign(Path.begin(), Path.end());
2190+
FileMgr.makeAbsolutePath(NormalizedPath);
2191+
llvm::sys::path::remove_dots(NormalizedPath);
2192+
}

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#include "clang/Basic/TargetInfo.h"
5858
#include "clang/Basic/TargetOptions.h"
5959
#include "clang/Basic/Version.h"
60+
#include "clang/Frontend/CompilerInstance.h"
6061
#include "clang/Lex/HeaderSearch.h"
6162
#include "clang/Lex/HeaderSearchOptions.h"
6263
#include "clang/Lex/MacroInfo.h"
@@ -1710,9 +1711,13 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
17101711
const HeaderSearchOptions &HSOpts =
17111712
PP.getHeaderSearchInfo().getHeaderSearchOpts();
17121713

1714+
SmallString<256> HSOpts_ModuleCachePath;
1715+
normalizeModuleCachePath(PP.getFileManager(), HSOpts.ModuleCachePath,
1716+
HSOpts_ModuleCachePath);
1717+
17131718
AddString(HSOpts.Sysroot, Record);
17141719
AddString(HSOpts.ResourceDir, Record);
1715-
AddString(HSOpts.ModuleCachePath, Record);
1720+
AddString(HSOpts_ModuleCachePath, Record);
17161721
AddString(HSOpts.ModuleUserBuildPath, Record);
17171722
Record.push_back(HSOpts.DisableModuleHash);
17181723
Record.push_back(HSOpts.ImplicitModuleMaps);

clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,16 @@ bool isASafeCallArg(const Expr *E) {
217217
return isa<CXXThisExpr>(E);
218218
}
219219

220+
bool isNullPtr(const clang::Expr *E) {
221+
if (isa<CXXNullPtrLiteralExpr>(E) || isa<GNUNullExpr>(E))
222+
return true;
223+
if (auto *Int = dyn_cast_or_null<IntegerLiteral>(E)) {
224+
if (Int->getValue().isZero())
225+
return true;
226+
}
227+
return false;
228+
}
229+
220230
bool isConstOwnerPtrMemberExpr(const clang::Expr *E) {
221231
if (auto *MCE = dyn_cast<CXXMemberCallExpr>(E)) {
222232
if (auto *Callee = MCE->getDirectCallee()) {
@@ -275,7 +285,7 @@ class EnsureFunctionVisitor
275285
bool VisitReturnStmt(const ReturnStmt *RS) {
276286
if (auto *RV = RS->getRetValue()) {
277287
RV = RV->IgnoreParenCasts();
278-
if (isa<CXXNullPtrLiteralExpr>(RV))
288+
if (isNullPtr(RV))
279289
return true;
280290
return isConstOwnerPtrMemberExpr(RV);
281291
}

clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ bool tryToFindPtrOrigin(
6666
/// \returns Whether \p E is a safe call arugment.
6767
bool isASafeCallArg(const clang::Expr *E);
6868

69+
/// \returns true if E is nullptr or __null.
70+
bool isNullPtr(const clang::Expr *E);
71+
6972
/// \returns true if E is a MemberExpr accessing a const smart pointer type.
7073
bool isConstOwnerPtrMemberExpr(const clang::Expr *E);
7174

0 commit comments

Comments
 (0)