Skip to content

Commit a549cf8

Browse files
committed
Merge from 'main' to 'sycl-web' (#3)
CONFLICT (content): Merge conflict in clang/lib/Driver/Driver.cpp
2 parents f8c34b6 + baebc11 commit a549cf8

File tree

5 files changed

+24
-50
lines changed

5 files changed

+24
-50
lines changed

clang/lib/Driver/Driver.cpp

+14-9
Original file line numberDiff line numberDiff line change
@@ -2455,15 +2455,20 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args,
24552455

24562456
// stdin must be handled specially.
24572457
if (memcmp(Value, "-", 2) == 0) {
2458-
// If running with -E, treat as a C input (this changes the builtin
2459-
// macros, for example). This may be overridden by -ObjC below.
2460-
//
2461-
// Otherwise emit an error but still use a valid type to avoid
2462-
// spurious errors (e.g., no inputs).
2463-
if (!Args.hasArgNoClaim(options::OPT_E) && !CCCIsCPP())
2464-
Diag(IsCLMode() ? clang::diag::err_drv_unknown_stdin_type_clang_cl
2465-
: clang::diag::err_drv_unknown_stdin_type);
2466-
Ty = CType;
2458+
if (IsFlangMode()) {
2459+
Ty = types::TY_Fortran;
2460+
} else {
2461+
// If running with -E, treat as a C input (this changes the
2462+
// builtin macros, for example). This may be overridden by -ObjC
2463+
// below.
2464+
//
2465+
// Otherwise emit an error but still use a valid type to avoid
2466+
// spurious errors (e.g., no inputs).
2467+
if (!Args.hasArgNoClaim(options::OPT_E) && !CCCIsCPP())
2468+
Diag(IsCLMode() ? clang::diag::err_drv_unknown_stdin_type_clang_cl
2469+
: clang::diag::err_drv_unknown_stdin_type);
2470+
Ty = types::TY_C;
2471+
}
24672472
} else {
24682473
// Otherwise lookup by extension.
24692474
// Fallback is C if invoked as C preprocessor, C++ if invoked with

clang/lib/Frontend/CompilerInvocation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,7 @@ GenerateOptimizationRemark(SmallVectorImpl<const char *> &Args,
11481148
} else if (Remark.Kind == CodeGenOptions::RK_Disabled) {
11491149
GenerateArg(Args, OPT_R_Joined, StringRef("no-") + Name, SA);
11501150
}
1151-
};
1151+
}
11521152

11531153
/// Parse a remark command line argument. It may be missing, disabled/enabled by
11541154
/// '-R[no-]group' or specified with a regular expression by '-Rgroup=regexp'.

flang/test/Flang-Driver/input-from-stdin.f90

+9-6
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@
55
!--------------------------
66
! FLANG DRIVER (flang-new)
77
!--------------------------
8-
! TODO: Add support for `flang-new -`
9-
! Currently `bin/flang-new -E -` defaults to `-x c` and e.g. F90 is not allowed
10-
! in `-x <input-type>` (see `clang::driver::types::canTypeBeUserSpecified` in
11-
! Types.cpp)
8+
! Input type is implicit
9+
! RUN: cat %s | flang-new -E - | FileCheck %s --check-prefix=PP-NOT-DEFINED
10+
! RUN: cat %s | flang-new -DNEW -E - | FileCheck %s --check-prefix=PP-DEFINED
11+
12+
! Input type is explicit
13+
! RUN: cat %s | flang-new -E -x f95-cpp-input - | FileCheck %s --check-prefix=PP-NOT-DEFINED
14+
! RUN: cat %s | flang-new -DNEW -E -x f95-cpp-input - | FileCheck %s --check-prefix=PP-DEFINED
1215

1316
!---------------------------------------
1417
! FLANG FRONTEND DRIVER (flang-new -fc1)
1518
!---------------------------------------
16-
! Test `-E` - for the corresponding frontend actions the driver relies on the prescanner API to handle file I/O
19+
! Test `-E`: for the corresponding frontend actions the driver relies on the prescanner API to handle file I/O
1720
! RUN: cat %s | flang-new -fc1 -E | FileCheck %s --check-prefix=PP-NOT-DEFINED
1821
! RUN: cat %s | flang-new -fc1 -DNEW -E | FileCheck %s --check-prefix=PP-DEFINED
1922

20-
! Test `-test-io` - for the corresponding frontend action (`InputOutputTestAction`) the driver handles the file I/O on its own
23+
! Test `-test-io`: for the corresponding frontend action (`InputOutputTestAction`) the driver handles the file I/O on its own
2124
! the corresponding action (`PrintPreprocessedAction`)
2225
! RUN: cat %s | flang-new -fc1 -test-io | FileCheck %s --check-prefix=IO --match-full-lines
2326
! RUN: cat %s | flang-new -fc1 -DNEW -test-io | FileCheck %s --check-prefix=IO --match-full-lines

llvm/include/llvm/Option/ArgList.h

-23
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,6 @@ class ArgList {
137137
/// The first and last index of each different OptSpecifier ID.
138138
DenseMap<unsigned, OptRange> OptRanges;
139139

140-
/// The OptSpecifiers that were queried from this argument list.
141-
mutable DenseSet<unsigned> QueriedOpts;
142-
143-
/// Record the queried OptSpecifiers.
144-
template <typename... OptSpecifiers>
145-
void recordQueriedOpts(OptSpecifiers... Ids) const {
146-
SmallVector<unsigned, 4> OptsSpecifiers({toOptSpecifier(Ids).getID()...});
147-
QueriedOpts.insert(OptsSpecifiers.begin(), OptsSpecifiers.end());
148-
}
149-
150140
/// Get the range of indexes in which options with the specified IDs might
151141
/// reside, or (0, 0) if there are no such options.
152142
OptRange getRange(std::initializer_list<OptSpecifier> Ids) const;
@@ -213,7 +203,6 @@ class ArgList {
213203
template<typename ...OptSpecifiers>
214204
iterator_range<filtered_iterator<sizeof...(OptSpecifiers)>>
215205
filtered(OptSpecifiers ...Ids) const {
216-
recordQueriedOpts(Ids...);
217206
OptRange Range = getRange({toOptSpecifier(Ids)...});
218207
auto B = Args.begin() + Range.first;
219208
auto E = Args.begin() + Range.second;
@@ -225,7 +214,6 @@ class ArgList {
225214
template<typename ...OptSpecifiers>
226215
iterator_range<filtered_reverse_iterator<sizeof...(OptSpecifiers)>>
227216
filtered_reverse(OptSpecifiers ...Ids) const {
228-
recordQueriedOpts(Ids...);
229217
OptRange Range = getRange({toOptSpecifier(Ids)...});
230218
auto B = Args.rend() - Range.second;
231219
auto E = Args.rend() - Range.first;
@@ -320,10 +308,6 @@ class ArgList {
320308
A->render(*this, Output);
321309
}
322310

323-
/// AddAllArgsExcept - Render all arguments not matching any of the excluded
324-
/// ids.
325-
void AddAllArgsExcept(ArgStringList &Output,
326-
const DenseSet<unsigned> &ExcludeIds) const;
327311
/// AddAllArgsExcept - Render all arguments matching any of the given ids
328312
/// and not matching any of the excluded ids.
329313
void AddAllArgsExcept(ArgStringList &Output, ArrayRef<OptSpecifier> Ids,
@@ -357,13 +341,6 @@ class ArgList {
357341
/// ClaimAllArgs - Claim all arguments.
358342
///
359343
void ClaimAllArgs() const;
360-
361-
/// Return the OptSpecifiers queried from this argument list.
362-
const DenseSet<unsigned> &getQueriedOpts() const { return QueriedOpts; }
363-
364-
/// Clear the set of queried OptSpecifiers.
365-
void clearQueriedOpts() const { QueriedOpts.clear(); }
366-
367344
/// @}
368345
/// @name Arg Synthesis
369346
/// @{

llvm/lib/Option/ArgList.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,11 @@ StringRef ArgList::getLastArgValue(OptSpecifier Id, StringRef Default) const {
9090
}
9191

9292
std::vector<std::string> ArgList::getAllArgValues(OptSpecifier Id) const {
93-
recordQueriedOpts(Id);
9493
SmallVector<const char *, 16> Values;
9594
AddAllArgValues(Values, Id);
9695
return std::vector<std::string>(Values.begin(), Values.end());
9796
}
9897

99-
void ArgList::AddAllArgsExcept(ArgStringList &Output,
100-
const DenseSet<unsigned> &ExcludeIds) const {
101-
for (const Arg *Arg : *this) {
102-
if (!ExcludeIds.contains(Arg->getOption().getID())) {
103-
Arg->claim();
104-
Arg->render(*this, Output);
105-
}
106-
}
107-
}
108-
10998
void ArgList::AddAllArgsExcept(ArgStringList &Output,
11099
ArrayRef<OptSpecifier> Ids,
111100
ArrayRef<OptSpecifier> ExcludeIds) const {

0 commit comments

Comments
 (0)