Skip to content

Commit e761c8e

Browse files
SC llvm teamSC llvm team
SC llvm team
authored and
SC llvm team
committed
Merged main:f8ced20ad3e8 into amd-gfx:3887b0542d33
Local branch amd-gfx 3887b05 Merged main:d6d4a526f424 into amd-gfx:b39673767903 Remote branch main f8ced20 Revert "[Parse] Split incremental-extensions" (llvm#66281)
2 parents 3887b05 + f8ced20 commit e761c8e

File tree

157 files changed

+13157
-14136
lines changed

Some content is hidden

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

157 files changed

+13157
-14136
lines changed

clang/include/clang/Basic/SourceManager.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class alignas(8) ContentCache {
148148
///
149149
/// Can be different from 'Entry' if we overridden the contents of one file
150150
/// with the contents of another file.
151-
const FileEntry *ContentsEntry;
151+
OptionalFileEntryRef ContentsEntry;
152152

153153
/// The filename that is used to access OrigEntry.
154154
///
@@ -180,13 +180,13 @@ class alignas(8) ContentCache {
180180
mutable unsigned IsBufferInvalid : 1;
181181

182182
ContentCache()
183-
: OrigEntry(std::nullopt), ContentsEntry(nullptr),
183+
: OrigEntry(std::nullopt), ContentsEntry(std::nullopt),
184184
BufferOverridden(false), IsFileVolatile(false), IsTransient(false),
185185
IsBufferInvalid(false) {}
186186

187187
ContentCache(FileEntryRef Ent) : ContentCache(Ent, Ent) {}
188188

189-
ContentCache(FileEntryRef Ent, const FileEntry *contentEnt)
189+
ContentCache(FileEntryRef Ent, FileEntryRef contentEnt)
190190
: OrigEntry(Ent), ContentsEntry(contentEnt), BufferOverridden(false),
191191
IsFileVolatile(false), IsTransient(false), IsBufferInvalid(false) {}
192192

clang/include/clang/Lex/ModuleMap.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ class ModuleMap {
259259
Attributes Attrs;
260260

261261
/// If \c InferModules is non-zero, the module map file that allowed
262-
/// inferred modules. Otherwise, nullptr.
263-
const FileEntry *ModuleMapFile;
262+
/// inferred modules. Otherwise, nullopt.
263+
OptionalFileEntryRef ModuleMapFile;
264264

265265
/// The names of modules that cannot be inferred within this
266266
/// directory.
@@ -275,7 +275,8 @@ class ModuleMap {
275275

276276
/// A mapping from an inferred module to the module map that allowed the
277277
/// inference.
278-
llvm::DenseMap<const Module *, const FileEntry *> InferredModuleAllowedBy;
278+
// FIXME: Consider making the values non-optional.
279+
llvm::DenseMap<const Module *, OptionalFileEntryRef> InferredModuleAllowedBy;
279280

280281
llvm::DenseMap<const Module *, AdditionalModMapsSet> AdditionalModMaps;
281282

@@ -631,7 +632,7 @@ class ModuleMap {
631632
/// getContainingModuleMapFile().
632633
OptionalFileEntryRef getModuleMapFileForUniquing(const Module *M) const;
633634

634-
void setInferredModuleAllowedBy(Module *M, const FileEntry *ModMap);
635+
void setInferredModuleAllowedBy(Module *M, OptionalFileEntryRef ModMap);
635636

636637
/// Canonicalize \p Path in a manner suitable for a module map file. In
637638
/// particular, this canonicalizes the parent directory separately from the

clang/include/clang/Lex/Preprocessor.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,6 @@ class Preprocessor {
277277
/// Empty line handler.
278278
EmptylineHandler *Emptyline = nullptr;
279279

280-
/// True to avoid tearing down the lexer etc on EOF
281-
bool IncrementalProcessing = false;
282-
283280
public:
284281
/// The kind of translation unit we are processing.
285282
const TranslationUnitKind TUKind;
@@ -1913,11 +1910,14 @@ class Preprocessor {
19131910
void recomputeCurLexerKind();
19141911

19151912
/// Returns true if incremental processing is enabled
1916-
bool isIncrementalProcessingEnabled() const { return IncrementalProcessing; }
1913+
bool isIncrementalProcessingEnabled() const {
1914+
return getLangOpts().IncrementalExtensions;
1915+
}
19171916

19181917
/// Enables the incremental processing
19191918
void enableIncrementalProcessing(bool value = true) {
1920-
IncrementalProcessing = value;
1919+
// FIXME: Drop this interface.
1920+
const_cast<LangOptions &>(getLangOpts()).IncrementalExtensions = value;
19211921
}
19221922

19231923
/// Specify the point at which code-completion will be performed.

clang/lib/Basic/SourceManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM,
114114
// return paths.
115115
IsBufferInvalid = true;
116116

117-
auto BufferOrError = FM.getBufferForFile(ContentsEntry, IsFileVolatile);
117+
auto BufferOrError = FM.getBufferForFile(*ContentsEntry, IsFileVolatile);
118118

119119
// If we were unable to open the file, then we are in an inconsistent
120120
// situation where the content cache referenced a file which no longer

clang/lib/Frontend/FrontendAction.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,15 +525,15 @@ static Module *prepareToBuildModule(CompilerInstance &CI,
525525
StringRef OriginalModuleMapName = CI.getFrontendOpts().OriginalModuleMap;
526526
if (!OriginalModuleMapName.empty()) {
527527
auto OriginalModuleMap =
528-
CI.getFileManager().getFile(OriginalModuleMapName,
529-
/*openFile*/ true);
528+
CI.getFileManager().getOptionalFileRef(OriginalModuleMapName,
529+
/*openFile*/ true);
530530
if (!OriginalModuleMap) {
531531
CI.getDiagnostics().Report(diag::err_module_map_not_found)
532532
<< OriginalModuleMapName;
533533
return nullptr;
534534
}
535-
if (*OriginalModuleMap != CI.getSourceManager().getFileEntryForID(
536-
CI.getSourceManager().getMainFileID())) {
535+
if (*OriginalModuleMap != CI.getSourceManager().getFileEntryRefForID(
536+
CI.getSourceManager().getMainFileID())) {
537537
M->IsInferred = true;
538538
CI.getPreprocessor().getHeaderSearchInfo().getModuleMap()
539539
.setInferredModuleAllowedBy(M, *OriginalModuleMap);

clang/lib/Lex/ModuleMap.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ ModuleMap::findOrCreateModuleForHeaderInUmbrellaDir(FileEntryRef File) {
622622
UmbrellaModule = UmbrellaModule->Parent;
623623

624624
if (UmbrellaModule->InferSubmodules) {
625-
OptionalFileEntryRefDegradesToFileEntryPtr UmbrellaModuleMap =
625+
OptionalFileEntryRef UmbrellaModuleMap =
626626
getModuleMapFileForUniquing(UmbrellaModule);
627627

628628
// Infer submodules for each of the directories we found between
@@ -993,7 +993,7 @@ Module *ModuleMap::inferFrameworkModule(DirectoryEntryRef FrameworkDir,
993993

994994
// If the framework has a parent path from which we're allowed to infer
995995
// a framework module, do so.
996-
const FileEntry *ModuleMapFile = nullptr;
996+
OptionalFileEntryRef ModuleMapFile;
997997
if (!Parent) {
998998
// Determine whether we're allowed to infer a module map.
999999
bool canInfer = false;
@@ -1294,13 +1294,13 @@ OptionalFileEntryRef
12941294
ModuleMap::getModuleMapFileForUniquing(const Module *M) const {
12951295
if (M->IsInferred) {
12961296
assert(InferredModuleAllowedBy.count(M) && "missing inferred module map");
1297-
// FIXME: Update InferredModuleAllowedBy to use FileEntryRef.
1298-
return InferredModuleAllowedBy.find(M)->second->getLastRef();
1297+
return InferredModuleAllowedBy.find(M)->second;
12991298
}
13001299
return getContainingModuleMapFile(M);
13011300
}
13021301

1303-
void ModuleMap::setInferredModuleAllowedBy(Module *M, const FileEntry *ModMap) {
1302+
void ModuleMap::setInferredModuleAllowedBy(Module *M,
1303+
OptionalFileEntryRef ModMap) {
13041304
assert(M->IsInferred && "module not inferred");
13051305
InferredModuleAllowedBy[M] = ModMap;
13061306
}

clang/lib/Lex/PPLexerChange.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {
541541
Result.startToken();
542542
CurLexer->BufferPtr = EndPos;
543543

544-
if (getLangOpts().IncrementalExtensions) {
544+
if (isIncrementalProcessingEnabled()) {
545545
CurLexer->FormTokenWithChars(Result, EndPos, tok::annot_repl_input_end);
546546
Result.setAnnotationEndLoc(Result.getLocation());
547547
Result.setAnnotationValue(nullptr);

clang/lib/Lex/Preprocessor.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,6 @@ Preprocessor::Preprocessor(std::shared_ptr<PreprocessorOptions> PPOpts,
146146
Ident_AbnormalTermination = nullptr;
147147
}
148148

149-
// Default incremental processing to -fincremental-extensions, clients can
150-
// override with `enableIncrementalProcessing` if desired.
151-
IncrementalProcessing = LangOpts.IncrementalExtensions;
152-
153149
// If using a PCH where a #pragma hdrstop is expected, start skipping tokens.
154150
if (usingPCHWithPragmaHdrStop())
155151
SkippingUntilPragmaHdrStop = true;

clang/lib/Parse/Parser.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -615,11 +615,6 @@ bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result,
615615
Sema::ModuleImportState &ImportState) {
616616
DestroyTemplateIdAnnotationsRAIIObj CleanupRAII(*this);
617617

618-
// Skip over the EOF token, flagging end of previous input for incremental
619-
// processing
620-
if (PP.isIncrementalProcessingEnabled() && Tok.is(tok::eof))
621-
ConsumeToken();
622-
623618
Result = nullptr;
624619
switch (Tok.getKind()) {
625620
case tok::annot_pragma_unused:
@@ -711,8 +706,7 @@ bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result,
711706

712707
// Late template parsing can begin.
713708
Actions.SetLateTemplateParser(LateTemplateParserCallback, nullptr, this);
714-
if (!PP.isIncrementalProcessingEnabled())
715-
Actions.ActOnEndOfTranslationUnit();
709+
Actions.ActOnEndOfTranslationUnit();
716710
//else don't tell Sema that we ended parsing: more input might come.
717711
return true;
718712

@@ -1044,7 +1038,7 @@ Parser::ParseExternalDeclaration(ParsedAttributes &Attrs,
10441038
ConsumeToken();
10451039
return nullptr;
10461040
}
1047-
if (getLangOpts().IncrementalExtensions &&
1041+
if (PP.isIncrementalProcessingEnabled() &&
10481042
!isDeclarationStatement(/*DisambiguatingWithExpression=*/true))
10491043
return ParseTopLevelStmtDecl();
10501044

clang/unittests/AST/ASTImporterODRStrategiesTest.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,8 @@ ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
599599
INSTANTIATE_TEST_SUITE_P(
600600
ODRViolationTests, FunctionConservative,
601601
DefaultTestValuesForRunOptions );
602+
#else
603+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(FunctionConservative);
602604
#endif
603605
INSTANTIATE_TEST_SUITE_P(
604606
ODRViolationTests, TypedefConservative,
@@ -631,6 +633,8 @@ INSTANTIATE_TEST_SUITE_P(
631633
//INSTANTIATE_TEST_SUITE_P(
632634
//ODRViolationTests, VarTemplateConservative,
633635
//DefaultTestValuesForRunOptions);
636+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VarTemplateConservative);
637+
634638
INSTANTIATE_TEST_SUITE_P(
635639
ODRViolationTests, FunctionTemplateSpecConservative,
636640
DefaultTestValuesForRunOptions);
@@ -641,12 +645,15 @@ INSTANTIATE_TEST_SUITE_P(
641645
//INSTANTIATE_TEST_SUITE_P(
642646
//ODRViolationTests, VarTemplateSpecConservative,
643647
//DefaultTestValuesForRunOptions);
648+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VarTemplateSpecConservative);
644649

645650
// FIXME: These fail on Windows.
646651
#if !defined(_WIN32)
647652
INSTANTIATE_TEST_SUITE_P(
648653
ODRViolationTests, FunctionLiberal,
649654
DefaultTestValuesForRunOptions);
655+
#else
656+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(FunctionLiberal);
650657
#endif
651658
INSTANTIATE_TEST_SUITE_P(
652659
ODRViolationTests, TypedefLiberal,
@@ -679,6 +686,8 @@ INSTANTIATE_TEST_SUITE_P(
679686
// INSTANTIATE_TEST_SUITE_P(
680687
// ODRViolationTests, VarTemplateLiberal,
681688
// DefaultTestValuesForRunOptions);
689+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VarTemplateLiberal);
690+
682691
INSTANTIATE_TEST_SUITE_P(
683692
ODRViolationTests, ClassTemplateSpecLiberal,
684693
DefaultTestValuesForRunOptions);
@@ -689,6 +698,7 @@ INSTANTIATE_TEST_SUITE_P(
689698
//INSTANTIATE_TEST_SUITE_P(
690699
//ODRViolationTests, VarTemplateSpecLiberal,
691700
//DefaultTestValuesForRunOptions );
701+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VarTemplateSpecLiberal);
692702

693703
// clang-format on
694704

clang/unittests/AST/ASTImporterTest.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9227,5 +9227,13 @@ INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ImportAttributes,
92279227
INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ImportInjectedClassNameType,
92289228
DefaultTestValuesForRunOptions);
92299229

9230+
INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ImportMatrixType,
9231+
DefaultTestValuesForRunOptions);
9232+
9233+
// FIXME: Make ImportOpenCLPipe test work.
9234+
// INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ImportOpenCLPipe,
9235+
// DefaultTestValuesForRunOptions);
9236+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ImportOpenCLPipe);
9237+
92309238
} // end namespace ast_matchers
92319239
} // end namespace clang

flang/lib/Semantics/check-declarations.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -419,11 +419,16 @@ void CheckHelper::Check(const Symbol &symbol) {
419419
}
420420
CheckBindCFunctionResult(symbol);
421421
}
422-
if (symbol.owner().IsModule() && IsAutomatic(symbol)) {
423-
messages_.Say(
424-
"Automatic data object '%s' may not appear in the specification part"
425-
" of a module"_err_en_US,
426-
symbol.name());
422+
if (IsAutomatic(symbol)) {
423+
if (const Symbol * common{FindCommonBlockContaining(symbol)}) {
424+
messages_.Say(
425+
"Automatic data object '%s' may not appear in COMMON block /%s/"_err_en_US,
426+
symbol.name(), common->name());
427+
} else if (symbol.owner().IsModule()) {
428+
messages_.Say(
429+
"Automatic data object '%s' may not appear in a module"_err_en_US,
430+
symbol.name());
431+
}
427432
}
428433
if (IsProcedure(symbol) && !symbol.HasExplicitInterface()) {
429434
if (IsAllocatable(symbol)) {

flang/lib/Semantics/runtime-type-info.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,11 @@ static SomeExpr StructureExpr(evaluate::StructureConstructor &&x) {
310310

311311
static int GetIntegerKind(const Symbol &symbol) {
312312
auto dyType{evaluate::DynamicType::From(symbol)};
313-
CHECK(dyType && dyType->category() == TypeCategory::Integer);
314-
return dyType->kind();
313+
CHECK((dyType && dyType->category() == TypeCategory::Integer) ||
314+
symbol.owner().context().HasError(symbol));
315+
return dyType && dyType->category() == TypeCategory::Integer
316+
? dyType->kind()
317+
: symbol.owner().context().GetDefaultKind(TypeCategory::Integer);
315318
}
316319

317320
// Save a rank-1 array constant of some numeric type as an

flang/test/Driver/dump-all-bad.f90

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
! CHECK: Flang: symbols dump
1111

1212
program bad
13-
real,pointer :: x
14-
x = null() ! Error - must be pointer assignment
13+
type dt(k)
14+
integer(kind=16) :: k
15+
integer(kind=16) :: comp
16+
end type dt
1517
end

flang/test/Semantics/resolve77.f90

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@ module m
88
interface ifn3
99
module procedure if3
1010
end interface
11-
!ERROR: Automatic data object 'a' may not appear in the specification part of a module
11+
!ERROR: Automatic data object 'a' may not appear in a module
1212
real :: a(if1(1))
13-
!ERROR: Automatic data object 'b' may not appear in the specification part of a module
13+
!ERROR: Automatic data object 'b' may not appear in a module
1414
real :: b(ifn2(1))
15+
!ERROR: Automatic data object 'c' may not appear in COMMON block /blk/
16+
real :: c(if1(1))
17+
!ERROR: Automatic data object 'd' may not appear in COMMON block //
18+
real :: d(ifn2(1))
19+
common /blk/c
20+
common d
1521
contains
1622
subroutine t1(n)
1723
integer :: iarr(if1(n))

libc/docs/dev/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ Navigate to the links below for information on the respective topics:
1818
header_generation
1919
implementation_standard
2020
undefined_behavior
21+
printf_behavior
2122
api_test
2223
mechanics_of_public_api

0 commit comments

Comments
 (0)