[clang] d2ddc69 - Revert "Revert "[analyzer] NFC: Move path diagnostic consumer implementations to libAnalysis.""

2021-01-07 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2021-01-07T00:28:22-08:00
New Revision: d2ddc694ff94743d9735aaf07edcaf6db8aaca04

URL: 
https://github.com/llvm/llvm-project/commit/d2ddc694ff94743d9735aaf07edcaf6db8aaca04
DIFF: 
https://github.com/llvm/llvm-project/commit/d2ddc694ff94743d9735aaf07edcaf6db8aaca04.diff

LOG: Revert "Revert "[analyzer] NFC: Move path diagnostic consumer 
implementations to libAnalysis.""

This reverts commit 5663bf201f5c444d6fb56fb1bd471bc53c17d837.

The cyclic dependency problem is addressed now.
This is the ~fifth attempt to land this change.

Added: 
clang/include/clang/Analysis/CrossTUAnalysisHelper.h
clang/include/clang/Analysis/PathDiagnosticConsumers.def
clang/include/clang/Analysis/PathDiagnosticConsumers.h
clang/lib/Analysis/HTMLPathDiagnosticConsumer.cpp
clang/lib/Analysis/PlistHTMLPathDiagnosticConsumer.cpp
clang/lib/Analysis/PlistPathDiagnosticConsumer.cpp
clang/lib/Analysis/SarifPathDiagnosticConsumer.cpp
clang/lib/Analysis/TextPathDiagnosticConsumer.cpp

Modified: 
clang/include/clang/CrossTU/CrossTranslationUnit.h
clang/include/clang/StaticAnalyzer/Core/Analyses.def
clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
clang/include/clang/module.modulemap
clang/lib/Analysis/CMakeLists.txt
clang/lib/CrossTU/CrossTranslationUnit.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/StaticAnalyzer/Core/CMakeLists.txt
clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Removed: 
clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp



diff  --git a/clang/include/clang/Analysis/CrossTUAnalysisHelper.h 
b/clang/include/clang/Analysis/CrossTUAnalysisHelper.h
new file mode 100644
index ..500e78ddedcf
--- /dev/null
+++ b/clang/include/clang/Analysis/CrossTUAnalysisHelper.h
@@ -0,0 +1,41 @@
+//===- CrossTUAnalysisHelper.h - Abstraction layer for CTU --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#ifndef LLVM_CLANG_ANALYSIS_CROSS_TU_HELPER_H
+#define LLVM_CLANG_ANALYSIS_CROSS_TU_HELPER_H
+
+#include "llvm/ADT/Optional.h"
+#include "clang/Basic/SourceManager.h"
+
+namespace clang {
+
+class ASTUnit;
+
+/// This class is an abstract interface acting as a bridge between
+/// an analysis that requires lookups across translation units (a user
+/// of that interface) and the facility that implements such lookups
+/// (an implementation of that interface). This is useful to break direct
+/// link-time dependencies between the (possibly shared) libraries in which
+/// the user and the implementation live.
+class CrossTUAnalysisHelper {
+public:
+  /// Determine the original source location in the original TU for an
+  /// imported source location.
+  /// \p ToLoc Source location in the imported-to AST.
+  /// \return Source location in the imported-from AST and the corresponding
+  /// ASTUnit object (the AST was loaded from a file using an internal ASTUnit
+  /// object that is returned here).
+  /// If any error happens (ToLoc is a non-imported source location) empty is
+  /// returned.
+  virtual llvm::Optional>
+  getImportedFromSourceLocationWithPreprocessor(SourceLocation ToLoc) const = 
0;
+
+  virtual ~CrossTUAnalysisHelper() {}
+};
+} // namespace clang
+
+#endif // LLVM_CLANG_ANALYSIS_CROSS_TU_HELPER_H

diff  --git a/clang/include/clang/Analysis/PathDiagnosticConsumers.def 
b/clang/include/clang/Analysis/PathDiagnosticConsumers.def
new file mode 100644
index ..33d2072fcf31
--- /dev/null
+++ b/clang/include/clang/Analysis/PathDiagnosticConsumers.def
@@ -0,0 +1,50 @@
+//===-- PathDiagnosticConsumers.def - Visualizing warnings --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file defines the set of path diagnostic consumers - objects that
+// implement 
diff erent representations of static analysis results.
+//
+//===--===//
+
+#ifndef ANALYSIS_DIAGNOSTICS
+#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN)
+#endif
+
+ANALYSIS_DIAGNOSTICS(HTML, "html", "Output analysis results using HTML",

[PATCH] D94217: [clang-format] Find main include after block ended with #pragma hdrstop

2021-01-07 Thread Rafał Jelonek via Phabricator via cfe-commits
rjelonek created this revision.
rjelonek added reviewers: rsmith, rnk.
rjelonek created this object with visibility "All Users".
rjelonek created this object with edit policy "Members of Project: clang".
rjelonek added a project: clang-format.
rjelonek requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Find main include in first include block not ended with #pragma hdrstop


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94217

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/SortIncludesTest.cpp


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -879,6 +879,27 @@
  "#include \"a.h\""));
 }
 
+TEST_F(SortIncludesTest, DoNotTreatPrecompiledHeadersAsFirstBlock) {
+  Style.IncludeBlocks = Style.IBS_Merge;
+  std::string Code = "#include \"d.h\"\r\n"
+ "#include \"b.h\"\r\n"
+ "#pragma hdrstop\r\n"
+ "\r\n"
+ "#include \"c.h\"\r\n"
+ "#include \"a.h\"\r\n"
+ "#include \"e.h\"\r\n";
+
+  std::string Expected = "#include \"b.h\"\r\n"
+ "#include \"d.h\"\r\n"
+ "#pragma hdrstop\r\n"
+ "\r\n"
+ "#include \"e.h\"\r\n"
+ "#include \"a.h\"\r\n"
+ "#include \"c.h\"\r\n";
+
+  EXPECT_EQ(Expected, sort(Code, "e.cpp", 2));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2305,7 +2305,10 @@
 sortCppIncludes(Style, IncludesInBlock, Ranges, FileName, Code,
 Replaces, Cursor);
 IncludesInBlock.clear();
-FirstIncludeBlock = false;
+if (Trimmed == "#pragma hdrstop") // precompiled headers
+  FirstIncludeBlock = true;
+else
+  FirstIncludeBlock = false;
   }
   Prev = Pos + 1;
 }


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -879,6 +879,27 @@
  "#include \"a.h\""));
 }
 
+TEST_F(SortIncludesTest, DoNotTreatPrecompiledHeadersAsFirstBlock) {
+  Style.IncludeBlocks = Style.IBS_Merge;
+  std::string Code = "#include \"d.h\"\r\n"
+ "#include \"b.h\"\r\n"
+ "#pragma hdrstop\r\n"
+ "\r\n"
+ "#include \"c.h\"\r\n"
+ "#include \"a.h\"\r\n"
+ "#include \"e.h\"\r\n";
+
+  std::string Expected = "#include \"b.h\"\r\n"
+ "#include \"d.h\"\r\n"
+ "#pragma hdrstop\r\n"
+ "\r\n"
+ "#include \"e.h\"\r\n"
+ "#include \"a.h\"\r\n"
+ "#include \"c.h\"\r\n";
+
+  EXPECT_EQ(Expected, sort(Code, "e.cpp", 2));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2305,7 +2305,10 @@
 sortCppIncludes(Style, IncludesInBlock, Ranges, FileName, Code,
 Replaces, Cursor);
 IncludesInBlock.clear();
-FirstIncludeBlock = false;
+if (Trimmed == "#pragma hdrstop") // precompiled headers
+  FirstIncludeBlock = true;
+else
+  FirstIncludeBlock = false;
   }
   Prev = Pos + 1;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89031: [SVE] Add support to vectorize_width loop pragma for scalable vectors

2021-01-07 Thread David Sherwood via Phabricator via cfe-commits
david-arm added inline comments.



Comment at: clang/lib/CodeGen/CGLoopInfo.cpp:751-753
+  // they effectively want vectorization disabled. We leave the
+  // scalable flag unspecified in this case to avoid setting the
+  // vectorize.enable flag later on.

sdesmalen wrote:
> is that not something to fix in the code that conditionally sets 
> vectorize.enable later on instead of working around it here?
I did originally try to do that, but I had trouble with it and found it broke 
other places too. It ended up being simpler to fix it here, but I can play 
around with it again. Even if this is still the simplest solution I can come 
back with a more detailed explanation at least!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89031/new/

https://reviews.llvm.org/D89031

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89490: Introduce __attribute__((darwin_abi))

2021-01-07 Thread Adrien Guinet via Phabricator via cfe-commits
aguinet added a comment.

In D89490#2482531 , @rjmccall wrote:

> I'm not calling Wine a niche use-case, I'm calling this feature a niche 
> use-case.  The lack of this feature has not blocked Wine from being a 
> successful project.  The feature has to stand on its own and be more broadly 
> useful than the momentary convenience of a few developers.

I am not saying this **exact** feature is needed by Wine. What I am doing is a 
parallel with `__attribute__((ms_abi))`, which is exactly the same as this 
exact feature, but to target the MS ABI from a foreign OS (instead of the 
Darwin one). Wine just can't work without that attribute.

Let's imagine that, at the time people had wanted to introduce 
`__attribute__((ms_abi))`, we would have told them "this is a niche, hack 
 instead". Do you really think that would have 
been a serious solution?

I'd say that we are in a chicken and egg problem: we don't have users for this, 
but maybe because we don't have the feature. We already have internal tools 
that are using this feature, and have lots of hopes it will simplify some of 
our more complex internal CI and debugging processes. We plan to open source 
all of this, because we also believe that will also help others with the same 
kind of issues. But I agree that we might be wrong.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89490/new/

https://reviews.llvm.org/D89490

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93846: [clang-format] PR16518 Add flag to suppress empty line insertion before access modifier

2021-01-07 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

I think your base for the diff is wrong, there are many "added" things which 
are already in clang-format. Could you update the diff?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93846/new/

https://reviews.llvm.org/D93846

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 77db83a - [clang][cli] Allow users to specify a conditional to prevent parsing options with MarshallingInfo

2021-01-07 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-01-07T10:01:49+01:00
New Revision: 77db83ae997767400ffcbe0101f8ee867ebaa111

URL: 
https://github.com/llvm/llvm-project/commit/77db83ae997767400ffcbe0101f8ee867ebaa111
DIFF: 
https://github.com/llvm/llvm-project/commit/77db83ae997767400ffcbe0101f8ee867ebaa111.diff

LOG: [clang][cli] Allow users to specify a conditional to prevent parsing 
options with MarshallingInfo

Depends on D84189 & D93540.

Reviewed By: Bigcheese

Differential Revision: https://reviews.llvm.org/D84674

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/unittests/Frontend/CompilerInvocationTest.cpp
llvm/include/llvm/Option/OptParser.td
llvm/utils/TableGen/OptParserEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 428c14a7d9bb..33b5cd09004e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4091,7 +4091,9 @@ defm sycl : BoolOption<"sycl",
   BothFlags<[CoreOption], " SYCL kernels compilation for device">, "f">,
   Group;
 def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group, 
Flags<[CC1Option, NoArgumentUnused, CoreOption]>,
-  HelpText<"SYCL language standard to compile for.">, Values<"2017, 121, 
1.2.1, sycl-1.2.1">;
+  HelpText<"SYCL language standard to compile for.">, 
Values<"2017,121,1.2.1,sycl-1.2.1">,
+  NormalizedValues<["SYCL_2017", "SYCL_2017", "SYCL_2017", "SYCL_2017"]>, 
NormalizedValuesScope<"LangOptions">,
+  MarshallingInfoString<"LangOpts->SYCLVersion", "SYCL_None">, 
ShouldParseIf, AutoNormalizeEnum;
 
 
//===--===//
 // FlangOption and FC1 Options

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 57027cea5659..962f72963cd2 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2282,23 +2282,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
   }
 
   Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
-  if (Opts.SYCL) {
-// -sycl-std applies to any SYCL source, not only those containing kernels,
-// but also those using the SYCL API
-if (const Arg *A = Args.getLastArg(OPT_sycl_std_EQ)) {
-  Opts.setSYCLVersion(
-  llvm::StringSwitch(A->getValue())
-  .Cases("2017", "1.2.1", "121", "sycl-1.2.1",
- LangOptions::SYCL_2017)
-  .Default(LangOptions::SYCL_None));
-
-  if (Opts.getSYCLVersion() == LangOptions::SYCL_None) {
-// User has passed an invalid value to the flag, this is an error
-Diags.Report(diag::err_drv_invalid_value)
-<< A->getAsString(Args) << A->getValue();
-  }
-}
-  }
 
   llvm::Triple T(TargetOpts.Triple);
   CompilerInvocation::setLangDefaults(Opts, IK, T, PPOpts, LangStd);
@@ -3003,16 +2986,17 @@ bool CompilerInvocation::parseSimpleArgs(const ArgList 
&Args,
  DiagnosticsEngine &Diags) {
 #define OPTION_WITH_MARSHALLING(   
\
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
-HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
-IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, 
\
-TABLE_INDEX)   
\
+HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   
\
+DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, 
\
+MERGER, EXTRACTOR, TABLE_INDEX)
\
   if ((FLAGS)&options::CC1Option) {
\
 this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);  
\
 if (IMPLIED_CHECK) 
\
   this->KEYPATH = MERGER(this->KEYPATH, IMPLIED_VALUE);
\
-if (auto MaybeValue = NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags))  
\
-  this->KEYPATH = MERGER(  
\
-  this->KEYPATH, static_castKEYPATH)>(*MaybeValue));   
\
+if (SHOULD_PARSE)  
\
+  if (auto MaybeValue = NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags))
\
+this->KEYPATH = MERGER(
\
+this->KEYPATH, static_castKEYPATH)>(*MaybeValue)); 
\
   }
 
 #include "clang/Driver/Options.inc"
@@ -3265,9 +3249,9 @@ void CompilerInvocation::generateCC1CommandLine(
   // with lifetime extension of the reference.
 #define OPTION_WITH_MARSHALLING(  

[clang] c6ea4d5 - [clang][cli] Implement ContainsN Google Test matcher

2021-01-07 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-01-07T10:01:49+01:00
New Revision: c6ea4d5b2c0054f3e2fa06b911ed3933fe59bc5b

URL: 
https://github.com/llvm/llvm-project/commit/c6ea4d5b2c0054f3e2fa06b911ed3933fe59bc5b
DIFF: 
https://github.com/llvm/llvm-project/commit/c6ea4d5b2c0054f3e2fa06b911ed3933fe59bc5b.diff

LOG: [clang][cli] Implement ContainsN Google Test matcher

This allows us to verify that we don't emit options multiple times.

In most cases, that would be benign, but for options with 
`MarshallingInfoVectorString`, emitting wrong number of arguments might change 
the semantics.

Reviewed By: Bigcheese

Differential Revision: https://reviews.llvm.org/D93636

Added: 


Modified: 
clang/unittests/Frontend/CompilerInvocationTest.cpp

Removed: 




diff  --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp 
b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index 89d9c88cc604..8fcf34d5c874 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -39,6 +39,61 @@ class CommandLineTest : public ::testing::Test {
   }
 };
 
+template 
+std::string describeContainsN(M InnerMatcher, unsigned N, bool Negation) {
+  StringRef Contains = Negation ? "doesn't contain" : "contains";
+  StringRef Instance = N == 1 ? " instance " : " instances ";
+  StringRef Element = "of element that ";
+
+  std::ostringstream Inner;
+  InnerMatcher.impl().DescribeTo(&Inner);
+
+  return (Contains + " exactly " + Twine(N) + Instance + Element + Inner.str())
+  .str();
+}
+
+MATCHER_P2(ContainsN, InnerMatcher, N,
+   describeContainsN(InnerMatcher, N, negation)) {
+  auto InnerMatches = [this](const auto &Element) {
+::testing::internal::DummyMatchResultListener InnerListener;
+return InnerMatcher.impl().MatchAndExplain(Element, &InnerListener);
+  };
+
+  return count_if(arg, InnerMatches) == N;
+}
+
+TEST(ContainsN, Empty) {
+  const char *Array[] = {""};
+
+  ASSERT_THAT(Array, ContainsN(StrEq("x"), 0));
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 1)));
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 2)));
+}
+
+TEST(ContainsN, Zero) {
+  const char *Array[] = {"y"};
+
+  ASSERT_THAT(Array, ContainsN(StrEq("x"), 0));
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 1)));
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 2)));
+}
+
+TEST(ContainsN, One) {
+  const char *Array[] = {"a", "b", "x", "z"};
+
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 0)));
+  ASSERT_THAT(Array, ContainsN(StrEq("x"), 1));
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 2)));
+}
+
+TEST(ContainsN, Two) {
+  const char *Array[] = {"x", "a", "b", "x"};
+
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 0)));
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 1)));
+  ASSERT_THAT(Array, ContainsN(StrEq("x"), 2));
+}
+
 // Boolean option with a keypath that defaults to true.
 // The only flag with a negative spelling can set the keypath to false.
 
@@ -270,7 +325,7 @@ TEST_F(CommandLineTest, BoolOptionCC1ViaLetPresentPos) {
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
-  ASSERT_EQ(count(GeneratedArgs, StringRef("-fdebug-pass-manager")), 1);
+  ASSERT_THAT(GeneratedArgs, ContainsN(StrEq("-fdebug-pass-manager"), 1));
   ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-debug-pass-manager";
 }
 
@@ -418,7 +473,8 @@ TEST_F(CommandLineTest, StringVectorEmpty) {
   ASSERT_TRUE(Invocation.getFrontendOpts().ModuleMapFiles.empty());
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
-  ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-fmodule-map-file=";
+
+  ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-fmodule-map-file";
 }
 
 TEST_F(CommandLineTest, StringVectorSingle) {
@@ -431,7 +487,9 @@ TEST_F(CommandLineTest, StringVectorSingle) {
 std::vector({"a"}));
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
-  ASSERT_EQ(count(GeneratedArgs, StringRef("-fmodule-map-file=a")), 1);
+
+  ASSERT_THAT(GeneratedArgs, ContainsN(StrEq("-fmodule-map-file=a"), 1));
+  ASSERT_THAT(GeneratedArgs, ContainsN(HasSubstr("-fmodule-map-file"), 1));
 }
 
 TEST_F(CommandLineTest, StringVectorMultiple) {
@@ -444,8 +502,10 @@ TEST_F(CommandLineTest, StringVectorMultiple) {
   std::vector({"a", "b"}));
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
-  ASSERT_EQ(count(GeneratedArgs, StringRef("-fmodule-map-file=a")), 1);
-  ASSERT_EQ(count(GeneratedArgs, StringRef("-fmodule-map-file=b")), 1);
+
+  ASSERT_THAT(GeneratedArgs, ContainsN(StrEq("-fmodule-map-file=a"), 1));
+  ASSERT_THAT(GeneratedArgs, ContainsN(StrEq("-fmodule-map-file=b"), 1));
+  ASSERT_THAT(GeneratedArgs, ContainsN(HasSubstr("-fmodule-map-file"), 2));
 }
 
 // A flag that should be parsed only if a condition is met.



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.or

[PATCH] D84674: [clang][cli] Allow users to specify a conditional to prevent parsing options with MarshallingInfo

2021-01-07 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG77db83ae9977: [clang][cli] Allow users to specify a 
conditional to prevent parsing options… (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D84674?vs=312785&id=315067#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84674/new/

https://reviews.llvm.org/D84674

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -71,6 +71,7 @@
   StringRef NormalizedValuesScope;
   StringRef ImpliedCheck;
   StringRef ImpliedValue;
+  StringRef ShouldParse;
   StringRef Normalizer;
   StringRef Denormalizer;
   StringRef ValueMerger;
@@ -102,6 +103,8 @@
   void emit(raw_ostream &OS) const {
 write_cstring(OS, StringRef(getOptionSpelling(R)));
 OS << ", ";
+OS << ShouldParse;
+OS << ", ";
 OS << ShouldAlwaysEmit;
 OS << ", ";
 OS << KeyPath;
@@ -167,6 +170,7 @@
   Ret.ImpliedValue =
   R.getValueAsOptionalString("ImpliedValue").getValueOr(Ret.DefaultValue);
 
+  Ret.ShouldParse = R.getValueAsString("ShouldParse");
   Ret.Normalizer = R.getValueAsString("Normalizer");
   Ret.Denormalizer = R.getValueAsString("Denormalizer");
   Ret.ValueMerger = R.getValueAsString("ValueMerger");
Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -101,6 +101,7 @@
   code DefaultValue = ?;
   code ImpliedValue = ?;
   code ImpliedCheck = "false";
+  code ShouldParse = "true";
   bit ShouldAlwaysEmit = false;
   code NormalizerRetTy = ?;
   code NormalizedValuesScope = "";
@@ -202,6 +203,7 @@
 
 // Mixins for additional marshalling attributes.
 
+class ShouldParseIf { code ShouldParse = condition; }
 class AlwaysEmit { bit ShouldAlwaysEmit = true; }
 class Normalizer { code Normalizer = normalizer; }
 class Denormalizer { code Denormalizer = denormalizer; }
Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -448,6 +448,68 @@
   ASSERT_EQ(count(GeneratedArgs, StringRef("-fmodule-map-file=b")), 1);
 }
 
+// A flag that should be parsed only if a condition is met.
+
+TEST_F(CommandLineTest, ConditionalParsingIfFalseFlagNotPresent) {
+  const char *Args[] = {""};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_FALSE(Invocation.getLangOpts()->SYCL);
+  ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_None);
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl";
+  ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-sycl-std=";
+}
+
+TEST_F(CommandLineTest, ConditionalParsingIfFalseFlagPresent) {
+  const char *Args[] = {"-sycl-std=2017"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_FALSE(Invocation.getLangOpts()->SYCL);
+  ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_None);
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl";
+  ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-sycl-std=";
+}
+
+TEST_F(CommandLineTest, ConditionalParsingIfTrueFlagNotPresent) {
+  const char *Args[] = {"-fsycl"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(Invocation.getLangOpts()->SYCL);
+  ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_None);
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fsycl")));
+  ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-sycl-std=";
+}
+
+TEST_F(CommandLineTest, ConditionalParsingIfTrueFlagPresent) {
+  const char *Args[] = {"-fsycl", "-sycl-std=2017"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(Invocation.getLangOpts()->SYCL);
+  ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_2017);
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fsycl")));
+  ASSERT_THAT(Generated

[PATCH] D93636: [clang][cli] Implement ContainsN Google Test matcher

2021-01-07 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc6ea4d5b2c00: [clang][cli] Implement ContainsN Google Test 
matcher (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D93636?vs=313105&id=315068#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93636/new/

https://reviews.llvm.org/D93636

Files:
  clang/unittests/Frontend/CompilerInvocationTest.cpp

Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -39,6 +39,61 @@
   }
 };
 
+template 
+std::string describeContainsN(M InnerMatcher, unsigned N, bool Negation) {
+  StringRef Contains = Negation ? "doesn't contain" : "contains";
+  StringRef Instance = N == 1 ? " instance " : " instances ";
+  StringRef Element = "of element that ";
+
+  std::ostringstream Inner;
+  InnerMatcher.impl().DescribeTo(&Inner);
+
+  return (Contains + " exactly " + Twine(N) + Instance + Element + Inner.str())
+  .str();
+}
+
+MATCHER_P2(ContainsN, InnerMatcher, N,
+   describeContainsN(InnerMatcher, N, negation)) {
+  auto InnerMatches = [this](const auto &Element) {
+::testing::internal::DummyMatchResultListener InnerListener;
+return InnerMatcher.impl().MatchAndExplain(Element, &InnerListener);
+  };
+
+  return count_if(arg, InnerMatches) == N;
+}
+
+TEST(ContainsN, Empty) {
+  const char *Array[] = {""};
+
+  ASSERT_THAT(Array, ContainsN(StrEq("x"), 0));
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 1)));
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 2)));
+}
+
+TEST(ContainsN, Zero) {
+  const char *Array[] = {"y"};
+
+  ASSERT_THAT(Array, ContainsN(StrEq("x"), 0));
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 1)));
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 2)));
+}
+
+TEST(ContainsN, One) {
+  const char *Array[] = {"a", "b", "x", "z"};
+
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 0)));
+  ASSERT_THAT(Array, ContainsN(StrEq("x"), 1));
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 2)));
+}
+
+TEST(ContainsN, Two) {
+  const char *Array[] = {"x", "a", "b", "x"};
+
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 0)));
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 1)));
+  ASSERT_THAT(Array, ContainsN(StrEq("x"), 2));
+}
+
 // Boolean option with a keypath that defaults to true.
 // The only flag with a negative spelling can set the keypath to false.
 
@@ -270,7 +325,7 @@
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
-  ASSERT_EQ(count(GeneratedArgs, StringRef("-fdebug-pass-manager")), 1);
+  ASSERT_THAT(GeneratedArgs, ContainsN(StrEq("-fdebug-pass-manager"), 1));
   ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-debug-pass-manager";
 }
 
@@ -418,7 +473,8 @@
   ASSERT_TRUE(Invocation.getFrontendOpts().ModuleMapFiles.empty());
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
-  ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-fmodule-map-file=";
+
+  ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-fmodule-map-file";
 }
 
 TEST_F(CommandLineTest, StringVectorSingle) {
@@ -431,7 +487,9 @@
 std::vector({"a"}));
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
-  ASSERT_EQ(count(GeneratedArgs, StringRef("-fmodule-map-file=a")), 1);
+
+  ASSERT_THAT(GeneratedArgs, ContainsN(StrEq("-fmodule-map-file=a"), 1));
+  ASSERT_THAT(GeneratedArgs, ContainsN(HasSubstr("-fmodule-map-file"), 1));
 }
 
 TEST_F(CommandLineTest, StringVectorMultiple) {
@@ -444,8 +502,10 @@
   std::vector({"a", "b"}));
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
-  ASSERT_EQ(count(GeneratedArgs, StringRef("-fmodule-map-file=a")), 1);
-  ASSERT_EQ(count(GeneratedArgs, StringRef("-fmodule-map-file=b")), 1);
+
+  ASSERT_THAT(GeneratedArgs, ContainsN(StrEq("-fmodule-map-file=a"), 1));
+  ASSERT_THAT(GeneratedArgs, ContainsN(StrEq("-fmodule-map-file=b"), 1));
+  ASSERT_THAT(GeneratedArgs, ContainsN(HasSubstr("-fmodule-map-file"), 2));
 }
 
 // A flag that should be parsed only if a condition is met.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94206: [clang-format] turn on formatting after "clang-format on" while sorting includes

2021-01-07 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

I don't know if I would create that many test functions, but put it all in one 
(maybe even one existing). Otherwise this looks ok.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94206/new/

https://reviews.llvm.org/D94206

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94201: [clang-format] Skip UTF8 Byte Order Mark while sorting includes

2021-01-07 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

Should the BOM not be ignored in ANY case, not just while sorting includes? And 
thus a different code should be touched?

How about aligned assignments at the beginning of the line with a BOM, does it 
count to the type name, or does clang-format handle that correctly right now?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94201/new/

https://reviews.llvm.org/D94201

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d0fa7a0 - Revert "[clang][cli] Allow users to specify a conditional to prevent parsing options with MarshallingInfo"

2021-01-07 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-01-07T10:12:53+01:00
New Revision: d0fa7a05be92617a0262ec8b622f158971a54c54

URL: 
https://github.com/llvm/llvm-project/commit/d0fa7a05be92617a0262ec8b622f158971a54c54
DIFF: 
https://github.com/llvm/llvm-project/commit/d0fa7a05be92617a0262ec8b622f158971a54c54.diff

LOG: Revert "[clang][cli] Allow users to specify a conditional to prevent 
parsing options with MarshallingInfo"

This reverts commit 77db83ae

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/unittests/Frontend/CompilerInvocationTest.cpp
llvm/include/llvm/Option/OptParser.td
llvm/utils/TableGen/OptParserEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 33b5cd09004e..428c14a7d9bb 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4091,9 +4091,7 @@ defm sycl : BoolOption<"sycl",
   BothFlags<[CoreOption], " SYCL kernels compilation for device">, "f">,
   Group;
 def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group, 
Flags<[CC1Option, NoArgumentUnused, CoreOption]>,
-  HelpText<"SYCL language standard to compile for.">, 
Values<"2017,121,1.2.1,sycl-1.2.1">,
-  NormalizedValues<["SYCL_2017", "SYCL_2017", "SYCL_2017", "SYCL_2017"]>, 
NormalizedValuesScope<"LangOptions">,
-  MarshallingInfoString<"LangOpts->SYCLVersion", "SYCL_None">, 
ShouldParseIf, AutoNormalizeEnum;
+  HelpText<"SYCL language standard to compile for.">, Values<"2017, 121, 
1.2.1, sycl-1.2.1">;
 
 
//===--===//
 // FlangOption and FC1 Options

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 962f72963cd2..57027cea5659 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2282,6 +2282,23 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
   }
 
   Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
+  if (Opts.SYCL) {
+// -sycl-std applies to any SYCL source, not only those containing kernels,
+// but also those using the SYCL API
+if (const Arg *A = Args.getLastArg(OPT_sycl_std_EQ)) {
+  Opts.setSYCLVersion(
+  llvm::StringSwitch(A->getValue())
+  .Cases("2017", "1.2.1", "121", "sycl-1.2.1",
+ LangOptions::SYCL_2017)
+  .Default(LangOptions::SYCL_None));
+
+  if (Opts.getSYCLVersion() == LangOptions::SYCL_None) {
+// User has passed an invalid value to the flag, this is an error
+Diags.Report(diag::err_drv_invalid_value)
+<< A->getAsString(Args) << A->getValue();
+  }
+}
+  }
 
   llvm::Triple T(TargetOpts.Triple);
   CompilerInvocation::setLangDefaults(Opts, IK, T, PPOpts, LangStd);
@@ -2986,17 +3003,16 @@ bool CompilerInvocation::parseSimpleArgs(const ArgList 
&Args,
  DiagnosticsEngine &Diags) {
 #define OPTION_WITH_MARSHALLING(   
\
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
-HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   
\
-DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, 
\
-MERGER, EXTRACTOR, TABLE_INDEX)
\
+HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
+IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, 
\
+TABLE_INDEX)   
\
   if ((FLAGS)&options::CC1Option) {
\
 this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);  
\
 if (IMPLIED_CHECK) 
\
   this->KEYPATH = MERGER(this->KEYPATH, IMPLIED_VALUE);
\
-if (SHOULD_PARSE)  
\
-  if (auto MaybeValue = NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags))
\
-this->KEYPATH = MERGER(
\
-this->KEYPATH, static_castKEYPATH)>(*MaybeValue)); 
\
+if (auto MaybeValue = NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags))  
\
+  this->KEYPATH = MERGER(  
\
+  this->KEYPATH, static_castKEYPATH)>(*MaybeValue));   
\
   }
 
 #include "clang/Driver/Options.inc"
@@ -3249,9 +3265,9 @@ void CompilerInvocation::generateCC1CommandLine(
   // with lifetime extension of the reference.
 #define OPTION_WITH_MARSHALLING(   
\
 PREFIX_TYPE, NAME, ID, KIND, GROUP, A

[PATCH] D92751: [clang][aarch64] Precondition isHomogeneousAggregate on isCXX14Aggregate

2021-01-07 Thread Peter Waller via Phabricator via cfe-commits
peterwaller-arm added a comment.

Suggesting a few small tweaks. Otherwise LGTM when @rnk is happy.




Comment at: clang/test/CodeGenCXX/homogeneous-aggregates.cpp:129
+struct Empty {};
+// A class with a base is returned using the sret calling convetion by MSVC.
+struct HasEmptyBase : public Empty {





Comment at: clang/test/CodeGenCXX/homogeneous-aggregates.cpp:147
+  *pod = copy(pod);
+  // WOA64-LABEL: %{{.*}} = call %"struct.pr47611::Pod" 
@"?copy@pr47611@@YA?AUPod@1@PEAU21@@Z"(%"struct.pr47611::Pod"* %{{.*}})
+}

Same comment (from below) about -LABEL for each of these functions. This should 
be a 'check'-alike and each function header should have a CHECK-LABEL.



Comment at: llvm/test/CodeGen/AArch64/arm64-windows-calls.ll:117
+  ret %struct.Pod %x1
+; CHECK: ldp d0, d1, [x0]
+}

rnk wrote:
> Please use CHECK-LABEL directives to ensure that these assembly checks are 
> from the function you intend to match.
@DavidTruby I think the intent here is:

CHECK-LABEL: < something matching the first line of the function definition >
CHECK: 

CHECK-LABEL: 

Such that if by some fluke some other function in the interim produces , it won't be allowed to match something produced in the 
subsequent function. This also renders the code safe against this problem if 
functions are added or moved around. I suggest having a CHECK-LABEL on each 
function heading, and the code within those functions should be 
CHECK/CHECK-NEXT as appropriate.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92751/new/

https://reviews.llvm.org/D92751

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93977: [clangd] Pass DraftStore to Tweak Apply and Prepare.

2021-01-07 Thread Nathan James via Phabricator via cfe-commits
njames93 abandoned this revision.
njames93 added a comment.

Abandoning in favour of VFS approach


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93977/new/

https://reviews.llvm.org/D93977

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93638: [hip] Enable HIP compilation with ` on MSVC.

2021-01-07 Thread Michael Liao via Phabricator via cfe-commits
hliao added inline comments.



Comment at: clang/lib/Headers/__clang_hip_runtime_wrapper.h:73-74
+#define __HOST_DEVICE__
\
+  static __host__ __device__ inline __attribute__((always_inline))
+__HOST_DEVICE__ double _Cosh(double x, double y) { return cosh(x) * y; }
+__HOST_DEVICE__ float _FCosh(float x, float y) { return coshf(x) * y; }

hliao wrote:
> hliao wrote:
> > tra wrote:
> > > hliao wrote:
> > > > tra wrote:
> > > > > hliao wrote:
> > > > > > tra wrote:
> > > > > > > hliao wrote:
> > > > > > > > tra wrote:
> > > > > > > > > I don't think we want to provide a HD implementation.
> > > > > > > > > This will potentially change the meaning of these functions 
> > > > > > > > > on the host side vs what they do in a C++ compilation.
> > > > > > > > > It should probably be just `__device__`.
> > > > > > > > > 
> > > > > > > > > Next question is -- do we want to provide the definitions, or 
> > > > > > > > > would just declarations be sufficient?
> > > > > > > > > In other words -- are these functions needed for some 
> > > > > > > > > standard C++ library functionality that we expect to work on 
> > > > > > > > > the GPU?
> > > > > > > > > If it's just to aid with overload resolution, declarations 
> > > > > > > > > should do. 
> > > > > > > > > 
> > > > > > > > These functions are declared in ymath.h and, in the host 
> > > > > > > > compilation, are resolved by linking MSVC RT libraries. For the 
> > > > > > > > device function, as we already mark all prototypes in ymath.h 
> > > > > > > > as HD, we have to implement them as HD to match the 
> > > > > > > > declaration. But, those definitions should be only available in 
> > > > > > > > the device compilation to avoid conflicts in the host 
> > > > > > > > compilation.
> > > > > > > You don't need the definitions to avoid conflicting declarations.
> > > > > > > 
> > > > > > > I'm still not convinced that HD is needed.
> > > > > > > Did you try just making these declarations `__device__` and 
> > > > > > > remove the `ymath.h` wrapper?
> > > > > > > Basically I'm trying to find the bare minimum we need to do to 
> > > > > > > make it work.
> > > > > > We don't call these functions directly. They are called in MSVC's 
> > > > > > . As functions in  are marked as HD, we need to 
> > > > > > mark these functions in ymath.h as HD to pass the compilation.
> > > > > I assume that we're dealing with this file:
> > > > > https://github.com/microsoft/STL/blob/master/stl/inc/ymath.h
> > > > > 
> > > > > I don't think we need a wrapper for ymath.
> > > > > It may be sufficient to define or declare  `__device__ _Cosh()` and 
> > > > > other functions and let overload resolution pick the right function.
> > > > > I think it would be a better approach than providing an `inline 
> > > > > __host__ __device__` definition for those functions and effectively 
> > > > > replacing MSVC-provided host-side implementation of those functions.
> > > > > 
> > > > `ymath.h` could be included before ``. That implies `_Cosh` 
> > > > could be declared as H only and results in the compilation failure.
> > > > BTW, I don't think replacing host-side implementation is a good idea as 
> > > > the host compilation should be kept consistent with the host compiler 
> > > > as much as possible.
> > > How? Isn't __clang_hip_runtime_wrapper.h included before anything in the 
> > > user source file is processed? If the __clang_hip_runtime_wrapper.h is 
> > > not included, first, then the ymath.h wrapper will not work either as it 
> > > needs `__device__` macros.
> > > 
> > > > replacing host-side implementation is a good idea 
> > > 
> > > While consistency between host/device is good, we should not introduce a 
> > > possible inconsistency between host-side TUs.
> > > Considering vastly larger amounts of host-side code compiled as C++ (e.g. 
> > > TF has way more C++ code than HIP/CUDA) and correspondingly more [[ 
> > > https://www.hyrumslaw.com/ | reliance on every possible detail of the 
> > > implementation ]], I would err on the side of not changing host-side 
> > > behavior in any way at all, if possible.
> > > 
> > > It's reasonably safe to add an overload (it may still be observable, but 
> > > it's usually possible to add it in a way that does not affect the host). 
> > > Replacing host-side things is more risky, as it greatly expands the 
> > > opportunities for things to go wrong.
> > > 
> > > 
> > > 
> > `` is also included in other headers, which is not wrapped. If we 
> > don't wrap ``, there's a chance that it's included as it is. 
> > That's why we have to wrap `` to ensure all functions marked with 
> > HD. Do I miss anything?
> I am wondering whether we could assume `` is an internal header 
> *only*.
It's turned out that `` (an internal header) is included in other 
headers, which is not wrapped like ``. The sequence including 
`` using MSVC 2017 is from ``, ``, ``, 
``, and then ``. As

[PATCH] D93978: [clangd] DefineOutline doesn't require implementation file being saved

2021-01-07 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 315070.
njames93 added a comment.
Herald added a subscriber: javed.absar.

Use VFS instead of DraftStore


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93978/new/

https://reviews.llvm.org/D93978

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/refactor/Tweak.cpp
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
@@ -74,7 +74,8 @@
   SelectionTree::createEach(AST.getASTContext(), AST.getTokens(), Range.first,
 Range.second, [&](SelectionTree ST) {
   Tweak::Selection S(Index, AST, Range.first,
- Range.second, std::move(ST));
+ Range.second, std::move(ST),
+ nullptr);
   if (auto T = prepareTweak(TweakID, S)) {
 Result = (*T)->apply(S);
 return true;
Index: clang-tools-extra/clangd/tool/Check.cpp
===
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -202,7 +202,8 @@
   vlog("  {0} {1}", Pos, Tok.text(AST->getSourceManager()));
   auto Tree = SelectionTree::createRight(AST->getASTContext(),
  AST->getTokens(), Start, End);
-  Tweak::Selection Selection(&Index, *AST, Start, End, std::move(Tree));
+  Tweak::Selection Selection(&Index, *AST, Start, End, std::move(Tree),
+ nullptr);
   for (const auto &T : prepareTweaks(Selection, Opts.TweakFilter)) {
 auto Result = T->apply(Selection);
 if (!Result) {
Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -36,6 +36,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include 
 #include 
 
@@ -63,10 +64,9 @@
 }
 
 llvm::Optional getSourceFile(llvm::StringRef FileName,
-   const Tweak::Selection &Sel) {
-  if (auto Source = getCorrespondingHeaderOrSource(
-  FileName,
-  &Sel.AST->getSourceManager().getFileManager().getVirtualFileSystem()))
+   const Tweak::Selection &Sel,
+   llvm::vfs::FileSystem *FS) {
+  if (auto Source = getCorrespondingHeaderOrSource(FileName, FS))
 return *Source;
   return getCorrespondingHeaderOrSource(FileName, *Sel.AST, Sel.Index);
 }
@@ -403,13 +403,18 @@
 if (!MainFileName)
   return error("Couldn't get absolute path for main file.");
 
-auto CCFile = getSourceFile(*MainFileName, Sel);
+// If we have a Filesystem attached to the Selection, use that, otherwise
+// fallback to the SourceManagar Filesystem.
+auto *FS = Sel.VFS ? Sel.VFS
+   : &Sel.AST->getSourceManager()
+  .getFileManager()
+  .getVirtualFileSystem();
+
+auto CCFile = getSourceFile(*MainFileName, Sel, FS);
+
 if (!CCFile)
   return error("Couldn't find a suitable implementation file.");
-
-auto &FS =
-Sel.AST->getSourceManager().getFileManager().getVirtualFileSystem();
-auto Buffer = FS.getBufferForFile(*CCFile);
+auto Buffer = FS->getBufferForFile(*CCFile);
 // FIXME: Maybe we should consider creating the implementation file if it
 // doesn't exist?
 if (!Buffer)
Index: clang-tools-extra/clangd/refactor/Tweak.h
===
--- clang-tools-extra/clangd/refactor/Tweak.h
+++ clang-tools-extra/clangd/refactor/Tweak.h
@@ -30,6 +30,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include 
 
 namespace clang {
@@ -48,7 +49,8 @@
   /// Input to prepare and apply tweaks.
   struct Selection {
 Selection(const SymbolIndex *Index, ParsedAST &AST, unsigned RangeBegin,
-  unsigned RangeEnd, SelectionTree ASTSelection);
+  unsigned Rang

[PATCH] D94201: [clang-format] Skip UTF8 Byte Order Mark while sorting includes

2021-01-07 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

This LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94201/new/

https://reviews.llvm.org/D94201

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89490: Introduce __attribute__((darwin_abi))

2021-01-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D89490#2483792 , @aguinet wrote:

> In D89490#2482531 , @rjmccall wrote:
>
>> I'm not calling Wine a niche use-case, I'm calling this feature a niche 
>> use-case.  The lack of this feature has not blocked Wine from being a 
>> successful project.  The feature has to stand on its own and be more broadly 
>> useful than the momentary convenience of a few developers.
>
> I am not saying this **exact** feature is needed by Wine. What I am doing is 
> a parallel with `__attribute__((ms_abi))`, which is exactly the same as this 
> exact feature, but to target the MS ABI from a foreign OS (instead of the 
> Darwin one). Wine just can't work without that attribute.
>
> Let's imagine that, at the time people had wanted to introduce 
> `__attribute__((ms_abi))`, we would have told them "this is a niche, hack 
>  instead". Do you really think that would 
> have been a serious solution?
>
> I'd say that we are in a chicken and egg problem: we don't have users for 
> this, but maybe because we don't have the feature. At my company, we already 
> have internal tools that are using this feature, and have lots of hopes it 
> will simplify some of our more complex internal CI and debugging processes. 
> We plan to open source all of this, because we also believe that will also 
> help others with the same kind of issues. But I agree that we might be wrong, 
> I honestly don't know.

I may be over-reacting to the way the patch seemed to be touching on the C++ 
ABI in multiple places.  My understanding is that `ms_abi` is just a 
calling-convention attribute; it's basically "use the (default) calling 
convention that MSVC would use for this function".  If that's all you want, 
then this is reasonable, although I am worried about creating a new attribute 
for every system that Wine chooses to target.

About "darwin": technically, every Apple platform has a different ABI.  Our 
current ARM64 platforms do all agree about things like the calling convention, 
at least if you count newer watches (which use a 32-on-64 ABI in userspace) as 
not ARM64.  That is not true of other architectures, most notably on ARM32, 
where the 32-bit iOS ABI is very different from the armv7k Apple Watch ABI; and 
it is certainly conceivable that Apple might release a new ARM64 platform in 
the future with a different calling convention.  The more technically correct 
and future-proof thing would be to use the OS name (or maybe even the triple!) 
in the attribute, probably as an argument to the attribute, like 
`__attribute__((target_abi("arm64-apple-ios")))`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89490/new/

https://reviews.llvm.org/D89490

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94201: [clang-format] Skip UTF8 Byte Order Mark while sorting includes

2021-01-07 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D94201#2483824 , 
@HazardyKnusperkeks wrote:

> Should the BOM not be ignored in ANY case, not just while sorting includes? 
> And thus a different code should be touched?
>
> How about aligned assignments at the beginning of the line with a BOM, does 
> it count to the type name, or does clang-format handle that correctly right 
> now?

I think its better that issues are kept small and compact and single units of 
work, lets not make more problems for ourselves by making every bug have to fix 
every possible permutation.

I follow the "Beyonce Rule" if aligned assignments are an issue when using BOM 
then the person who added that "should have put a test on it"

But @HazardyKnusperkeks feel free to investigate that if you are interested to 
see if this issue is further reaching, patches are always welcome


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94201/new/

https://reviews.llvm.org/D94201

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94206: [clang-format] turn on formatting after "clang-format on" while sorting includes

2021-01-07 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added subscribers: krasimir, klimek.
MyDeveloperDay added a comment.

@rjelonek  please don't set the editable to "clang" but leave it as all users

F14974099: image.png 

otherwise only members of the clang project can actually edit it the review and 
leave comments (this massively cuts down who can review it)

Also not wanting to talk for @rsmith but you need to ensure that you are adding 
people as reviewers who generally look after #clang-format 
 for which I'm always happy to be a 
reviewer, but a quick look at other clang-format commits will give you an idea 
of people  who at least I normally include (but not limited to)  @curdeius , 
@krasimir , @klimek  these people are well versed in how clang-format works. 
Not all may have time to respond.

see https://llvm.org/docs/Phabricator.html#finding-potential-reviewers


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94206/new/

https://reviews.llvm.org/D94206

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94206: [clang-format] turn on formatting after "clang-format on" while sorting includes

2021-01-07 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Could you add user case where you see this issue to the description or add a 
link to the related bug in the bug tracker if there is one, I'm just struggling 
a little to see what the original problem was.

Generally it looks fine, just for understanding I'd like to know how the 
problem manifested


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94206/new/

https://reviews.llvm.org/D94206

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 67a4c67 - Reapply "[clang][cli] Allow users to specify a conditional to prevent parsing options with MarshallingInfo"

2021-01-07 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-01-07T11:11:47+01:00
New Revision: 67a4c672b02359fa6f723249f633ffc76aff2174

URL: 
https://github.com/llvm/llvm-project/commit/67a4c672b02359fa6f723249f633ffc76aff2174
DIFF: 
https://github.com/llvm/llvm-project/commit/67a4c672b02359fa6f723249f633ffc76aff2174.diff

LOG: Reapply "[clang][cli] Allow users to specify a conditional to prevent 
parsing options with MarshallingInfo"

This reverts commit d0fa7a05 and fixes failing OptionMarshallingTest by adding 
the SHOULD_PARSE macro argument

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/unittests/Frontend/CompilerInvocationTest.cpp
llvm/include/llvm/Option/OptParser.td
llvm/unittests/Option/OptionMarshallingTest.cpp
llvm/utils/TableGen/OptParserEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 428c14a7d9bb..33b5cd09004e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4091,7 +4091,9 @@ defm sycl : BoolOption<"sycl",
   BothFlags<[CoreOption], " SYCL kernels compilation for device">, "f">,
   Group;
 def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group, 
Flags<[CC1Option, NoArgumentUnused, CoreOption]>,
-  HelpText<"SYCL language standard to compile for.">, Values<"2017, 121, 
1.2.1, sycl-1.2.1">;
+  HelpText<"SYCL language standard to compile for.">, 
Values<"2017,121,1.2.1,sycl-1.2.1">,
+  NormalizedValues<["SYCL_2017", "SYCL_2017", "SYCL_2017", "SYCL_2017"]>, 
NormalizedValuesScope<"LangOptions">,
+  MarshallingInfoString<"LangOpts->SYCLVersion", "SYCL_None">, 
ShouldParseIf, AutoNormalizeEnum;
 
 
//===--===//
 // FlangOption and FC1 Options

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 57027cea5659..962f72963cd2 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2282,23 +2282,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
   }
 
   Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
-  if (Opts.SYCL) {
-// -sycl-std applies to any SYCL source, not only those containing kernels,
-// but also those using the SYCL API
-if (const Arg *A = Args.getLastArg(OPT_sycl_std_EQ)) {
-  Opts.setSYCLVersion(
-  llvm::StringSwitch(A->getValue())
-  .Cases("2017", "1.2.1", "121", "sycl-1.2.1",
- LangOptions::SYCL_2017)
-  .Default(LangOptions::SYCL_None));
-
-  if (Opts.getSYCLVersion() == LangOptions::SYCL_None) {
-// User has passed an invalid value to the flag, this is an error
-Diags.Report(diag::err_drv_invalid_value)
-<< A->getAsString(Args) << A->getValue();
-  }
-}
-  }
 
   llvm::Triple T(TargetOpts.Triple);
   CompilerInvocation::setLangDefaults(Opts, IK, T, PPOpts, LangStd);
@@ -3003,16 +2986,17 @@ bool CompilerInvocation::parseSimpleArgs(const ArgList 
&Args,
  DiagnosticsEngine &Diags) {
 #define OPTION_WITH_MARSHALLING(   
\
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
-HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
-IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, 
\
-TABLE_INDEX)   
\
+HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   
\
+DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, 
\
+MERGER, EXTRACTOR, TABLE_INDEX)
\
   if ((FLAGS)&options::CC1Option) {
\
 this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);  
\
 if (IMPLIED_CHECK) 
\
   this->KEYPATH = MERGER(this->KEYPATH, IMPLIED_VALUE);
\
-if (auto MaybeValue = NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags))  
\
-  this->KEYPATH = MERGER(  
\
-  this->KEYPATH, static_castKEYPATH)>(*MaybeValue));   
\
+if (SHOULD_PARSE)  
\
+  if (auto MaybeValue = NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags))
\
+this->KEYPATH = MERGER(
\
+this->KEYPATH, static_castKEYPATH)>(*MaybeValue)); 
\
   }
 
 #include "clang/Driver/Options.inc"
@@ -3265,9 +3249,9 @@ void CompilerInvocation::generateCC1CommandLine(
   // with lifetime extension of the 

[PATCH] D94206: [clang-format] turn on formatting after "clang-format on" while sorting includes

2021-01-07 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I'm not seeing this

  // clang-format off
  #include "d.h"
  #include "b.h"
  // clang-format on
  
  #include "a.h"
  #include "c.h"
  #include "e.h"

$ unix2dos test1.cpp
unix2dos: converting file test1.cpp to DOS format...

$ clang-format test1.cpp
// clang-format off
#include "d.h"
#include "b.h"
// clang-format on

#include "a.h"
#include "c.h"
#include "e.h"

  


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94206/new/

https://reviews.llvm.org/D94206

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0877b96 - [clang][ASTImporter] Fix a possible assertion failure `NeedsInjectedClassNameType(Decl)'.

2021-01-07 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2021-01-07T11:28:11+01:00
New Revision: 0877b963ef2d3c384b47f7a6161c9d9ab106a7f2

URL: 
https://github.com/llvm/llvm-project/commit/0877b963ef2d3c384b47f7a6161c9d9ab106a7f2
DIFF: 
https://github.com/llvm/llvm-project/commit/0877b963ef2d3c384b47f7a6161c9d9ab106a7f2.diff

LOG: [clang][ASTImporter] Fix a possible assertion failure 
`NeedsInjectedClassNameType(Decl)'.

The assertion can happen if ASTImporter imports a CXXRecordDecl in a template
and then imports another redeclaration of this declaration, while the first 
import is in progress.
The process of first import did not set the "described template" yet
and the second import finds the first declaration at setting the injected types.
Setting the injected type requires in the assertion that the described template 
is set.
The exact assertion was:
clang/lib/AST/ASTContext.cpp:4411:
clang::QualType 
clang::ASTContext::getInjectedClassNameType(clang::CXXRecordDecl*, 
clang::QualType) const:
Assertion `NeedsInjectedClassNameType(Decl)' failed.

Reviewed By: shafik

Differential Revision: https://reviews.llvm.org/D94067

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 54816b721a4a..5c6aa5d3c015 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -5393,16 +5393,16 @@ ExpectedDecl 
ASTNodeImporter::VisitClassTemplateDecl(ClassTemplateDecl *D) {
 
   CXXRecordDecl *FromTemplated = D->getTemplatedDecl();
 
+  auto TemplateParamsOrErr = import(D->getTemplateParameters());
+  if (!TemplateParamsOrErr)
+return TemplateParamsOrErr.takeError();
+
   // Create the declaration that is being templated.
   CXXRecordDecl *ToTemplated;
   if (Error Err = importInto(ToTemplated, FromTemplated))
 return std::move(Err);
 
   // Create the class template declaration itself.
-  auto TemplateParamsOrErr = import(D->getTemplateParameters());
-  if (!TemplateParamsOrErr)
-return TemplateParamsOrErr.takeError();
-
   ClassTemplateDecl *D2;
   if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(), DC, Loc, Name,
   *TemplateParamsOrErr, ToTemplated))

diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 2472fa265589..8a07a5b8e0df 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -6141,6 +6141,41 @@ TEST_P(ASTImporterOptionSpecificTestBase, 
TypedefWithAttribute) {
   EXPECT_EQ(ToAttr->getAnnotation(), "A");
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase,
+   ImportOfTemplatedDeclWhenPreviousDeclHasNoDescribedTemplateSet) {
+  Decl *FromTU = getTuDecl(
+  R"(
+
+  namespace std {
+template
+class basic_stringbuf;
+  }
+  namespace std {
+class char_traits;
+template
+class basic_stringbuf;
+  }
+  namespace std {
+template
+class basic_stringbuf {};
+  }
+
+  )",
+  Lang_CXX11);
+
+  auto *From1 = FirstDeclMatcher().match(
+  FromTU,
+  classTemplateDecl(hasName("basic_stringbuf"), unless(isImplicit(;
+  auto *To1 = cast_or_null(Import(From1, Lang_CXX11));
+  EXPECT_TRUE(To1);
+
+  auto *From2 = LastDeclMatcher().match(
+  FromTU,
+  classTemplateDecl(hasName("basic_stringbuf"), unless(isImplicit(;
+  auto *To2 = cast_or_null(Import(From2, Lang_CXX11));
+  EXPECT_TRUE(To2);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94067: [clang][ASTImporter] Fix a possible assertion failure `NeedsInjectedClassNameType(Decl)'.

2021-01-07 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0877b963ef2d: [clang][ASTImporter] Fix a possible assertion 
failure… (authored by balazske).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94067/new/

https://reviews.llvm.org/D94067

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -6141,6 +6141,41 @@
   EXPECT_EQ(ToAttr->getAnnotation(), "A");
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase,
+   ImportOfTemplatedDeclWhenPreviousDeclHasNoDescribedTemplateSet) {
+  Decl *FromTU = getTuDecl(
+  R"(
+
+  namespace std {
+template
+class basic_stringbuf;
+  }
+  namespace std {
+class char_traits;
+template
+class basic_stringbuf;
+  }
+  namespace std {
+template
+class basic_stringbuf {};
+  }
+
+  )",
+  Lang_CXX11);
+
+  auto *From1 = FirstDeclMatcher().match(
+  FromTU,
+  classTemplateDecl(hasName("basic_stringbuf"), unless(isImplicit(;
+  auto *To1 = cast_or_null(Import(From1, Lang_CXX11));
+  EXPECT_TRUE(To1);
+
+  auto *From2 = LastDeclMatcher().match(
+  FromTU,
+  classTemplateDecl(hasName("basic_stringbuf"), unless(isImplicit(;
+  auto *To2 = cast_or_null(Import(From2, Lang_CXX11));
+  EXPECT_TRUE(To2);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -5393,16 +5393,16 @@
 
   CXXRecordDecl *FromTemplated = D->getTemplatedDecl();
 
+  auto TemplateParamsOrErr = import(D->getTemplateParameters());
+  if (!TemplateParamsOrErr)
+return TemplateParamsOrErr.takeError();
+
   // Create the declaration that is being templated.
   CXXRecordDecl *ToTemplated;
   if (Error Err = importInto(ToTemplated, FromTemplated))
 return std::move(Err);
 
   // Create the class template declaration itself.
-  auto TemplateParamsOrErr = import(D->getTemplateParameters());
-  if (!TemplateParamsOrErr)
-return TemplateParamsOrErr.takeError();
-
   ClassTemplateDecl *D2;
   if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(), DC, Loc, Name,
   *TemplateParamsOrErr, ToTemplated))


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -6141,6 +6141,41 @@
   EXPECT_EQ(ToAttr->getAnnotation(), "A");
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase,
+   ImportOfTemplatedDeclWhenPreviousDeclHasNoDescribedTemplateSet) {
+  Decl *FromTU = getTuDecl(
+  R"(
+
+  namespace std {
+template
+class basic_stringbuf;
+  }
+  namespace std {
+class char_traits;
+template
+class basic_stringbuf;
+  }
+  namespace std {
+template
+class basic_stringbuf {};
+  }
+
+  )",
+  Lang_CXX11);
+
+  auto *From1 = FirstDeclMatcher().match(
+  FromTU,
+  classTemplateDecl(hasName("basic_stringbuf"), unless(isImplicit(;
+  auto *To1 = cast_or_null(Import(From1, Lang_CXX11));
+  EXPECT_TRUE(To1);
+
+  auto *From2 = LastDeclMatcher().match(
+  FromTU,
+  classTemplateDecl(hasName("basic_stringbuf"), unless(isImplicit(;
+  auto *To2 = cast_or_null(Import(From2, Lang_CXX11));
+  EXPECT_TRUE(To2);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -5393,16 +5393,16 @@
 
   CXXRecordDecl *FromTemplated = D->getTemplatedDecl();
 
+  auto TemplateParamsOrErr = import(D->getTemplateParameters());
+  if (!TemplateParamsOrErr)
+return TemplateParamsOrErr.takeError();
+
   // Create the declaration that is being templated.
   CXXRecordDecl *ToTemplated;
   if (Error Err = importInto(ToTemplated, FromTemplated))
 return std::move(Err);
 
   // Create the class template declaration itself.
-  auto TemplateParamsOrErr = import(D->getTemplateParameters());
-  if (!TemplateParamsOrErr)
-return TemplateParamsOrErr.takeError();
-
   ClassTemplateDecl *D2;
   if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(), DC, Loc, Name,
   *TemplateParamsOrErr, ToTemplated))
___
cfe-commits mailing list
cfe-commits@lis

[PATCH] D94217: [clang-format] Find main include after block ended with #pragma hdrstop

2021-01-07 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I've not used this before, but you seem to be suggesting that `#pragma hdrstop` 
should be used to determine when the files main header should now be placed?

Could you explain a little more as to why you think that should be the case 
(i.e. is there a technical reason as to why, I'm happy to be educated).




Comment at: clang/lib/Format/Format.cpp:2308
 IncludesInBlock.clear();
-FirstIncludeBlock = false;
+if (Trimmed == "#pragma hdrstop") // precompiled headers
+  FirstIncludeBlock = true;

Should this handle this form?

```
#pragma hdrstop( "c:\\projects\\include\\myinc.pch" )
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94217/new/

https://reviews.llvm.org/D94217

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94206: [clang-format] turn on formatting after "clang-format on" while sorting includes

2021-01-07 Thread Rafał Jelonek via Phabricator via cfe-commits
rjelonek added a comment.

In unit test "DetectClangFormatOn" is my real case. I have problems with D94201 
 and D94217  
so i tried to turn off sorting for first block (with #pragma hdrstop at the end 
of this block). But sorting turned off for whole file instead of to // 
clang-format on.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94206/new/

https://reviews.llvm.org/D94206

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93638: [hip] Enable HIP compilation with ` on MSVC.

2021-01-07 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 315073.
hliao added a comment.

Forget that C function could be overloaded on Clang with overloadable
extension. With that, we don't need to mark functions from `` as HD.
Instead, we could provide their device-side implementation directly.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93638/new/

https://reviews.llvm.org/D93638

Files:
  clang/lib/Headers/__clang_hip_cmath.h


Index: clang/lib/Headers/__clang_hip_cmath.h
===
--- clang/lib/Headers/__clang_hip_cmath.h
+++ clang/lib/Headers/__clang_hip_cmath.h
@@ -624,6 +624,34 @@
 } // namespace std
 #endif
 
+// Define device-side math functions from  on MSVC.
+#if defined(_MSC_VER)
+#if defined(__cplusplus)
+extern "C" {
+#endif // defined(__cplusplus)
+__DEVICE__ __attribute__((overloadable)) double _Cosh(double x, double y) {
+  return cosh(x) * y;
+}
+__DEVICE__ __attribute__((overloadable)) float _FCosh(float x, float y) {
+  return coshf(x) * y;
+}
+__DEVICE__ __attribute__((overloadable)) short _Dtest(double *p) {
+  return fpclassify(*p);
+}
+__DEVICE__ __attribute__((overloadable)) short _FDtest(float *p) {
+  return fpclassify(*p);
+}
+__DEVICE__ __attribute__((overloadable)) double _Sinh(double x, double y) {
+  return sinh(x) * y;
+}
+__DEVICE__ __attribute__((overloadable)) float _FSinh(float x, float y) {
+  return sinhf(x) * y;
+}
+#if defined(__cplusplus)
+}
+#endif // defined(__cplusplus)
+#endif // defined(_MSC_VER)
+
 #pragma pop_macro("__DEVICE__")
 
 #endif // __CLANG_HIP_CMATH_H__


Index: clang/lib/Headers/__clang_hip_cmath.h
===
--- clang/lib/Headers/__clang_hip_cmath.h
+++ clang/lib/Headers/__clang_hip_cmath.h
@@ -624,6 +624,34 @@
 } // namespace std
 #endif
 
+// Define device-side math functions from  on MSVC.
+#if defined(_MSC_VER)
+#if defined(__cplusplus)
+extern "C" {
+#endif // defined(__cplusplus)
+__DEVICE__ __attribute__((overloadable)) double _Cosh(double x, double y) {
+  return cosh(x) * y;
+}
+__DEVICE__ __attribute__((overloadable)) float _FCosh(float x, float y) {
+  return coshf(x) * y;
+}
+__DEVICE__ __attribute__((overloadable)) short _Dtest(double *p) {
+  return fpclassify(*p);
+}
+__DEVICE__ __attribute__((overloadable)) short _FDtest(float *p) {
+  return fpclassify(*p);
+}
+__DEVICE__ __attribute__((overloadable)) double _Sinh(double x, double y) {
+  return sinh(x) * y;
+}
+__DEVICE__ __attribute__((overloadable)) float _FSinh(float x, float y) {
+  return sinhf(x) * y;
+}
+#if defined(__cplusplus)
+}
+#endif // defined(__cplusplus)
+#endif // defined(_MSC_VER)
+
 #pragma pop_macro("__DEVICE__")
 
 #endif // __CLANG_HIP_CMATH_H__
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94217: [clang-format] Find main include after block ended with #pragma hdrstop

2021-01-07 Thread Rafał Jelonek via Phabricator via cfe-commits
rjelonek added a comment.

Currently at work we use Embarcadero Builder C++
In builder all above #pragma hdrstop is a precompiled header. And we have this 
#pragma at almost all cpp files, so mainInclude is ignored because is in second 
include block.

`#pragma hdrstop( "c:\\projects\\include\\myinc.pch" )`
This form shoudnt be handled


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94217/new/

https://reviews.llvm.org/D94217

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94222: [clangd] Add server capability advertising hot-reloading of CDBs.

2021-01-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

Currently some clients watch for CDB changes and restart clangd, now that we
can reload compile_commands.json ourselves this is counterproductive.
The capability allows this behavior to be phased out.

This is going to be a mild regression, as we do not actually watch for files on
disk and so new diagnostics need to wait until a rebuild is requested e.g. due
to file change (and the internal caches have expired).
However this is still a better tradeoff (and if it's important, we can request
the client to watch files for us in the future).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94222

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/test/initialize-params.test


Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -8,6 +8,9 @@
 # CHECK-NEXT:  "astProvider": true,
 # CHECK-NEXT:  "callHierarchyProvider": true,
 # CHECK-NEXT:  "codeActionProvider": true,
+# CHECK-NEXT:  "compilationDatabase": {
+# CHECK-NEXT:"automaticReload": true
+# CHECK-NEXT:  },
 # CHECK-NEXT:  "completionProvider": {
 # CHECK-NEXT:"allCommitCharacters": [
 # CHECK-NEXT:  " ",
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -620,7 +620,7 @@
 {"documentSymbolProvider", true},
 {"workspaceSymbolProvider", true},
 {"referencesProvider", true},
-{"astProvider", true},
+{"astProvider", true}, // clangd extension
 {"executeCommandProvider",
  llvm::json::Object{
  {"commands",
@@ -628,7 +628,9 @@
ExecuteCommandParams::CLANGD_APPLY_TWEAK}},
  }},
 {"typeHierarchyProvider", true},
-{"memoryUsageProvider", true}, // clangd extension.
+{"memoryUsageProvider", true}, // clangd extension
+{"compilationDatabase",// clangd extension
+ llvm::json::Object{{"automaticReload", true}}},
 {"callHierarchyProvider", true},
 ;
   if (Opts.Encoding)


Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -8,6 +8,9 @@
 # CHECK-NEXT:  "astProvider": true,
 # CHECK-NEXT:  "callHierarchyProvider": true,
 # CHECK-NEXT:  "codeActionProvider": true,
+# CHECK-NEXT:  "compilationDatabase": {
+# CHECK-NEXT:"automaticReload": true
+# CHECK-NEXT:  },
 # CHECK-NEXT:  "completionProvider": {
 # CHECK-NEXT:"allCommitCharacters": [
 # CHECK-NEXT:  " ",
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -620,7 +620,7 @@
 {"documentSymbolProvider", true},
 {"workspaceSymbolProvider", true},
 {"referencesProvider", true},
-{"astProvider", true},
+{"astProvider", true}, // clangd extension
 {"executeCommandProvider",
  llvm::json::Object{
  {"commands",
@@ -628,7 +628,9 @@
ExecuteCommandParams::CLANGD_APPLY_TWEAK}},
  }},
 {"typeHierarchyProvider", true},
-{"memoryUsageProvider", true}, // clangd extension.
+{"memoryUsageProvider", true}, // clangd extension
+{"compilationDatabase",// clangd extension
+ llvm::json::Object{{"automaticReload", true}}},
 {"callHierarchyProvider", true},
 ;
   if (Opts.Encoding)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92634: [Analyzer] Diagnose signed integer overflow

2021-01-07 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> My code seems to think that a variable print_count has the value INT_MAX for 
> some reason

Typically in such cases bug visitors should be added/improved until it is clear 
from the user-facing report why does the analyzer think so. They'd highlight 
the important events, prevent path pruning, and potentially suppress reports if 
the reason is discovered to not be valid.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92634/new/

https://reviews.llvm.org/D92634

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94201: [clang-format] Skip UTF8 Byte Order Mark while sorting includes

2021-01-07 Thread Rafał Jelonek via Phabricator via cfe-commits
rjelonek added a comment.

I do not have commit access.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94201/new/

https://reviews.llvm.org/D94201

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a828fb4 - [clang][cli] Port a CommaJoined option to the marshalling infrastructure

2021-01-07 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-01-07T11:52:06+01:00
New Revision: a828fb463ed9f6085849bb3a4f225b3c84e7cf29

URL: 
https://github.com/llvm/llvm-project/commit/a828fb463ed9f6085849bb3a4f225b3c84e7cf29
DIFF: 
https://github.com/llvm/llvm-project/commit/a828fb463ed9f6085849bb3a4f225b3c84e7cf29.diff

LOG: [clang][cli] Port a CommaJoined option to the marshalling infrastructure

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D93698

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/unittests/Frontend/CompilerInvocationTest.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 33b5cd09004e..6b5ae35ad7e0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1201,7 +1201,7 @@ def fansi_escape_codes : Flag<["-"], 
"fansi-escape-codes">, Group,
   MarshallingInfoFlag<"DiagnosticOpts->UseANSIEscapeCodes">;
 def fcomment_block_commands : CommaJoined<["-"], "fcomment-block-commands=">, 
Group, Flags<[CC1Option]>,
   HelpText<"Treat each comma separated argument in  as a documentation 
comment block command">,
-  MetaVarName<"">;
+  MetaVarName<"">, 
MarshallingInfoStringVector<"LangOpts->CommentOpts.BlockCommandNames">;
 def fparse_all_comments : Flag<["-"], "fparse-all-comments">, 
Group, Flags<[CC1Option]>,
   MarshallingInfoFlag<"LangOpts->CommentOpts.ParseAllComments">;
 def frecord_command_line : Flag<["-"], "frecord-command-line">,

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 962f72963cd2..da4213e8952e 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -328,8 +328,20 @@ static void denormalizeStringVector(SmallVectorImpl &Args,
 Option::OptionClass OptClass,
 unsigned TableIndex,
 const std::vector &Values) {
-  for (const std::string &Value : Values) {
-denormalizeString(Args, Spelling, SA, OptClass, TableIndex, Value);
+  if (OptClass == Option::OptionClass::CommaJoinedClass) {
+std::string CommaJoinedValue;
+if (!Values.empty()) {
+  CommaJoinedValue.append(Values.front());
+  for (const std::string &Value : llvm::drop_begin(Values, 1)) {
+CommaJoinedValue.append(",");
+CommaJoinedValue.append(Value);
+  }
+}
+denormalizeString(Args, Spelling, SA, Option::OptionClass::JoinedClass,
+  TableIndex, CommaJoinedValue);
+  } else if (OptClass == Option::OptionClass::JoinedClass) {
+for (const std::string &Value : Values)
+  denormalizeString(Args, Spelling, SA, OptClass, TableIndex, Value);
   }
 }
 
@@ -785,7 +797,6 @@ static void parseAnalyzerConfigs(AnalyzerOptions &AnOpts,
 }
 
 static void ParseCommentArgs(CommentOptions &Opts, ArgList &Args) {
-  Opts.BlockCommandNames = Args.getAllArgValues(OPT_fcomment_block_commands);
   Opts.ParseAllComments = Args.hasArg(OPT_fparse_all_comments);
 }
 

diff  --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp 
b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index 8fcf34d5c874..7b8efb9af2e2 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -508,6 +508,53 @@ TEST_F(CommandLineTest, StringVectorMultiple) {
   ASSERT_THAT(GeneratedArgs, ContainsN(HasSubstr("-fmodule-map-file"), 2));
 }
 
+// CommaJoined option with MarshallingInfoStringVector.
+
+TEST_F(CommandLineTest, StringVectorCommaJoinedNone) {
+  const char *Args[] = {""};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(Invocation.getLangOpts()->CommentOpts.BlockCommandNames.empty());
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs,
+  Not(Contains(HasSubstr("-fcomment-block-commands";
+}
+
+TEST_F(CommandLineTest, StringVectorCommaJoinedSingle) {
+  const char *Args[] = {"-fcomment-block-commands=x,y"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_EQ(Invocation.getLangOpts()->CommentOpts.BlockCommandNames,
+std::vector({"x", "y"}));
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs,
+  ContainsN(StrEq("-fcomment-block-commands=x,y"), 1));
+}
+
+TEST_F(CommandLineTest, StringVectorCommaJoinedMultiple) {
+  const char *Args[] = {"-fcomment-block-commands=x,y",
+"-fcomment-block-commands=a,b"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_EQ(Invocation.getLangOpts()->Co

[PATCH] D93698: [clang][cli] Port a CommaJoined option to the marshalling infrastructure

2021-01-07 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa828fb463ed9: [clang][cli] Port a CommaJoined option to the 
marshalling infrastructure (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D93698?vs=313324&id=315079#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93698/new/

https://reviews.llvm.org/D93698

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp

Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -508,6 +508,53 @@
   ASSERT_THAT(GeneratedArgs, ContainsN(HasSubstr("-fmodule-map-file"), 2));
 }
 
+// CommaJoined option with MarshallingInfoStringVector.
+
+TEST_F(CommandLineTest, StringVectorCommaJoinedNone) {
+  const char *Args[] = {""};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(Invocation.getLangOpts()->CommentOpts.BlockCommandNames.empty());
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs,
+  Not(Contains(HasSubstr("-fcomment-block-commands";
+}
+
+TEST_F(CommandLineTest, StringVectorCommaJoinedSingle) {
+  const char *Args[] = {"-fcomment-block-commands=x,y"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_EQ(Invocation.getLangOpts()->CommentOpts.BlockCommandNames,
+std::vector({"x", "y"}));
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs,
+  ContainsN(StrEq("-fcomment-block-commands=x,y"), 1));
+}
+
+TEST_F(CommandLineTest, StringVectorCommaJoinedMultiple) {
+  const char *Args[] = {"-fcomment-block-commands=x,y",
+"-fcomment-block-commands=a,b"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_EQ(Invocation.getLangOpts()->CommentOpts.BlockCommandNames,
+std::vector({"x", "y", "a", "b"}));
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs,
+  ContainsN(StrEq("-fcomment-block-commands=x,y,a,b"), 1));
+}
+
 // A flag that should be parsed only if a condition is met.
 
 TEST_F(CommandLineTest, ConditionalParsingIfFalseFlagNotPresent) {
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -328,8 +328,20 @@
 Option::OptionClass OptClass,
 unsigned TableIndex,
 const std::vector &Values) {
-  for (const std::string &Value : Values) {
-denormalizeString(Args, Spelling, SA, OptClass, TableIndex, Value);
+  if (OptClass == Option::OptionClass::CommaJoinedClass) {
+std::string CommaJoinedValue;
+if (!Values.empty()) {
+  CommaJoinedValue.append(Values.front());
+  for (const std::string &Value : llvm::drop_begin(Values, 1)) {
+CommaJoinedValue.append(",");
+CommaJoinedValue.append(Value);
+  }
+}
+denormalizeString(Args, Spelling, SA, Option::OptionClass::JoinedClass,
+  TableIndex, CommaJoinedValue);
+  } else if (OptClass == Option::OptionClass::JoinedClass) {
+for (const std::string &Value : Values)
+  denormalizeString(Args, Spelling, SA, OptClass, TableIndex, Value);
   }
 }
 
@@ -785,7 +797,6 @@
 }
 
 static void ParseCommentArgs(CommentOptions &Opts, ArgList &Args) {
-  Opts.BlockCommandNames = Args.getAllArgValues(OPT_fcomment_block_commands);
   Opts.ParseAllComments = Args.hasArg(OPT_fparse_all_comments);
 }
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1201,7 +1201,7 @@
   MarshallingInfoFlag<"DiagnosticOpts->UseANSIEscapeCodes">;
 def fcomment_block_commands : CommaJoined<["-"], "fcomment-block-commands=">, Group, Flags<[CC1Option]>,
   HelpText<"Treat each comma separated argument in  as a documentation comment block command">,
-  MetaVarName<"">;
+  MetaVarName<"">, MarshallingInfoStringVector<"LangOpts->CommentOpts.BlockCommandNames">;
 def fparse_all_comments : Flag<["-"], "fparse-all-comments">, Group, Flags<[CC1Option]>,
   MarshallingInfoFlag<"LangOpts->CommentOpts.ParseAllComments">;
 def frecord_command_line : Flag<["-"], "frecord-command-line">,

[PATCH] D92409: [AST][NFC] Silence GCC warning about multiline comments

2021-01-07 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre updated this revision to Diff 315080.
thopre added a comment.

Change approach to remove continuation line instead


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92409/new/

https://reviews.llvm.org/D92409

Files:
  clang/include/clang/AST/DeclOpenMP.h


Index: clang/include/clang/AST/DeclOpenMP.h
===
--- clang/include/clang/AST/DeclOpenMP.h
+++ clang/include/clang/AST/DeclOpenMP.h
@@ -163,7 +163,7 @@
 /// 'float':
 ///
 /// \code
-/// #pragma omp declare reduction (foo : int,float : omp_out += omp_in) \
+/// #pragma omp declare reduction (foo : int,float : omp_out += omp_in)
 /// initializer (omp_priv = 0)
 /// \endcode
 ///


Index: clang/include/clang/AST/DeclOpenMP.h
===
--- clang/include/clang/AST/DeclOpenMP.h
+++ clang/include/clang/AST/DeclOpenMP.h
@@ -163,7 +163,7 @@
 /// 'float':
 ///
 /// \code
-/// #pragma omp declare reduction (foo : int,float : omp_out += omp_in) \
+/// #pragma omp declare reduction (foo : int,float : omp_out += omp_in)
 /// initializer (omp_priv = 0)
 /// \endcode
 ///
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e5cdb6c - [flang][driver] Add support for `-c` and `-emit-obj`

2021-01-07 Thread Andrzej Warzynski via cfe-commits

Author: Andrzej Warzynski
Date: 2021-01-07T10:52:38Z
New Revision: e5cdb6c56edf656d03f57c5c285cfa8c6b7b6f57

URL: 
https://github.com/llvm/llvm-project/commit/e5cdb6c56edf656d03f57c5c285cfa8c6b7b6f57
DIFF: 
https://github.com/llvm/llvm-project/commit/e5cdb6c56edf656d03f57c5c285cfa8c6b7b6f57.diff

LOG: [flang][driver] Add support for `-c` and `-emit-obj`

This patch adds a frontend action for emitting object files. While Flang
does not support code-generation, this action remains a placeholder.
This patch simply provides glue-code to connect the compiler driver
with the appropriate frontend action.

The new action is triggered with the `-c` compiler driver flag, i.e.
`flang-new -c`. This is then translated to `flang-new -fc1 -emit-obj`,
so `-emit-obj` has to be marked as supported as well.

As code-generation is not available yet, `flang-new -c` results in a
driver error:
```
error: code-generation is not available yet
```
Hopefully this will help communicating the level of available
functionality within Flang.

The definition of `emit-obj` is updated so that it can be shared between
Clang and Flang. As the original definition was enclosed within a
Clang-specific TableGen `let` statement, it is extracted into a new `let`
statement. That felt like the cleanest option.

I also commented out `-triple` in Flang::ConstructJob and updated some
comments there. This is similar to https://reviews.llvm.org/D93027. I
wanted to make sure that it's clear that we can't support `-triple`
until we have code-generation. However, once code-generation is
available we _will need_ `-triple`.

As this patch adds `-emit-obj`, the emit-obj.f90 becomes irrelevant and
is deleted. Instead, phases.f90 is added to demonstrate that users can
control compilation phases (indeed, `-c` is a phase control flag).

Reviewed By: SouraVX, clementval

Differential Revision: https://reviews.llvm.org/D93301

Added: 
flang/test/Flang-Driver/code-gen.f90
flang/test/Flang-Driver/phases.f90

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/include/flang/Frontend/FrontendActions.h
flang/include/flang/Frontend/FrontendOptions.h
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Frontend/FrontendActions.cpp
flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
flang/test/Flang-Driver/driver-help-hidden.f90
flang/test/Flang-Driver/driver-help.f90

Removed: 
flang/test/Flang-Driver/emit-obj.f90



diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 6b5ae35ad7e0..ffa7fbd84df9 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -857,7 +857,7 @@ def current__version : JoinedOrSeparate<["-"], 
"current_version">;
 def cxx_isystem : JoinedOrSeparate<["-"], "cxx-isystem">, Group,
   HelpText<"Add directory to the C++ SYSTEM include search path">, 
Flags<[CC1Option]>,
   MetaVarName<"">;
-def c : Flag<["-"], "c">, Flags<[NoXarchOption]>, Group,
+def c : Flag<["-"], "c">, Flags<[NoXarchOption, FlangOption]>, 
Group,
   HelpText<"Only run preprocess, compile, and assemble steps">;
 def fconvergent_functions : Flag<["-"], "fconvergent-functions">, 
Group, Flags<[CC1Option]>,
   HelpText<"Assume functions may be convergent">;
@@ -4854,8 +4854,6 @@ def emit_llvm_only : Flag<["-"], "emit-llvm-only">,
   HelpText<"Build ASTs and convert to LLVM, discarding output">;
 def emit_codegen_only : Flag<["-"], "emit-codegen-only">,
   HelpText<"Generate machine code, but discard output">;
-def emit_obj : Flag<["-"], "emit-obj">,
-  HelpText<"Emit native object files">;
 def rewrite_test : Flag<["-"], "rewrite-test">,
   HelpText<"Rewriter playground">;
 def rewrite_macros : Flag<["-"], "rewrite-macros">,
@@ -5229,6 +5227,18 @@ def fsycl_is_device : Flag<["-"], "fsycl-is-device">,
 
 } // let Flags = [CC1Option, NoDriverOption]
 
+//===--===//
+// Frontend Options - cc1 + fc1
+//===--===//
+let Flags = [CC1Option, FC1Option, NoDriverOption] in {
+let Group = Action_Group in {
+
+def emit_obj : Flag<["-"], "emit-obj">,
+  HelpText<"Emit native object files">;
+
+} // let Group = Action_Group
+} // let Flags = [CC1Option, FC1Option, NoDriverOption]
+
 
//===--===//
 // cc1as-only Options
 
//===--===//

diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 69f0841bb0c5..bf300d737991 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -28,17 +28,22 @@ void Flang::ConstructJob(Compilation &C, const JobAction 
&JA,
  const InputInfo &Output, co

[PATCH] D93301: [flang][driver] Add support for `-c` and `-emit-obj`

2021-01-07 Thread Andrzej Warzynski via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe5cdb6c56edf: [flang][driver] Add support for `-c` and 
`-emit-obj` (authored by awarzynski).

Changed prior to commit:
  https://reviews.llvm.org/D93301?vs=312457&id=315081#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93301/new/

https://reviews.llvm.org/D93301

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Flang-Driver/code-gen.f90
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/emit-obj.f90
  flang/test/Flang-Driver/phases.f90

Index: flang/test/Flang-Driver/phases.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/phases.f90
@@ -0,0 +1,20 @@
+! RUN: %flang-new -E -ccc-print-phases %s 2>&1 | FileCheck %s --check-prefix=PP
+! RUN: %flang-new -fsyntax-only -ccc-print-phases %s 2>&1 | FileCheck %s --check-prefix=COMPILE
+! RUN: %flang-new -c -ccc-print-phases %s 2>&1 | FileCheck %s --check-prefix=EMIT_OBJ
+
+! REQUIRES: new-flang-driver
+
+! This test verifies the phase control in Flang compiler driver.
+
+! PP: +- 0: input, "{{.*}}phases.f90", f95-cpp-input
+! PP-NEXT: 1: preprocessor, {0}, f95
+
+! COMPILE: +- 0: input, "{{.*}}phases.f90", f95-cpp-input
+! COMPILE-NEXT: 1: preprocessor, {0}, f95
+! COMPILE-NEXT: 2: compiler, {1}, none
+
+! EMIT_OBJ: +- 0: input, "{{.*}}phases.f90", f95-cpp-input
+! EMIT_OBJ-NEXT: 1: preprocessor, {0}, f95
+! EMIT_OBJ-NEXT: 2: compiler, {1}, ir
+! EMIT_OBJ-NEXT: +- 3: backend, {2}, assembler
+! EMIT_OBJ-NEXT: 4: assembler, {3}, object
Index: flang/test/Flang-Driver/emit-obj.f90
===
--- flang/test/Flang-Driver/emit-obj.f90
+++ /dev/null
@@ -1,14 +0,0 @@
-! RUN: not %flang-new  %s 2>&1 | FileCheck %s --check-prefix=ERROR
-! RUN: not %flang-new  -emit-obj %s 2>&1 | FileCheck %s --check-prefix=ERROR
-! RUN: not %flang-new  -fc1 -emit-obj %s 2>&1 | FileCheck %s --check-prefix=ERROR-FC1
-
-! REQUIRES: new-flang-driver
-
-! By default (e.g. when no options like `-E` are passed) flang-new
-! creates a job that corresponds to `-emit-obj`. This option/action is
-! not yet supported. Verify that this is correctly reported as error.
-
-! ERROR: error: unknown argument: '-triple'
-! ERROR: error: unknown argument: '-emit-obj'
-
-! ERROR-FC1: error: unknown argument: '-emit-obj'
Index: flang/test/Flang-Driver/driver-help.f90
===
--- flang/test/Flang-Driver/driver-help.f90
+++ flang/test/Flang-Driver/driver-help.f90
@@ -19,6 +19,7 @@
 ! HELP-EMPTY:
 ! HELP-NEXT:OPTIONS:
 ! HELP-NEXT: -###   Print (but do not run) the commands to run for this compilation
+! HELP-NEXT: -c Only run preprocess, compile, and assemble steps
 ! HELP-NEXT: -D = Define  to  (or 1 if  omitted)
 ! HELP-NEXT: -E Only run the preprocessor
 ! HELP-NEXT: -fcolor-diagnosticsEnable colors in diagnostics
@@ -35,6 +36,7 @@
 ! HELP-FC1-EMPTY:
 ! HELP-FC1-NEXT:OPTIONS:
 ! HELP-FC1-NEXT: -D = Define  to  (or 1 if  omitted)
+! HELP-FC1-NEXT: -emit-obj Emit native object files
 ! HELP-FC1-NEXT: -E Only run the preprocessor
 ! HELP-FC1-NEXT: -help  Display available options
 ! HELP-FC1-NEXT: -o   Write output to 
Index: flang/test/Flang-Driver/driver-help-hidden.f90
===
--- flang/test/Flang-Driver/driver-help-hidden.f90
+++ flang/test/Flang-Driver/driver-help-hidden.f90
@@ -19,6 +19,7 @@
 ! CHECK-EMPTY:
 ! CHECK-NEXT:OPTIONS:
 ! CHECK-NEXT: -###  Print (but do not run) the commands to run for this compilation
+! CHECK-NEXT: -cOnly run preprocess, compile, and assemble steps
 ! CHECK-NEXT: -D = Define  to  (or 1 if  omitted)
 ! CHECK-NEXT: -EOnly run the preprocessor
 ! CHECK-NEXT: -fcolor-diagnosticsEnable colors in diagnostics
Index: flang/test/Flang-Driver/code-gen.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/code-gen.f90
@@ -0,0 +1,15 @@
+! RUN: not %flang-new %s 2>&1 | FileCheck %s --check-prefix=ERROR
+! RUN: not %flang-new -c %s 2>&1 | FileCheck %s --check-prefix=ERROR
+! RUN: not %flang-new -emit-obj %s 2>&1 | FileCheck %s --check-prefix=ERROR
+! RUN: not %flang-new -fc1 -emit-obj %s 2>&1 | FileCheck %s --check-prefix=ERROR
+
+! REQUIRES: new-flang-driver
+
+! Although code-generation is not yet available, we 

[PATCH] D92409: [AST][NFC] Silence GCC warning about multiline comments

2021-01-07 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre added a comment.

In D92409#2481300 , @rjmccall wrote:

> People can't actually just copy/paste from the comment anyway because of the 
> comment characters on the line, and I don't think anyone will misunderstand 
> the example if the backslash is missing.  It's silly that GCC has a problem 
> with this, but since it does, let's just work around the problem and drop the 
> backslash rather than having one comment block in the header use a different 
> style.

They can from the online documentation 
(https://clang.llvm.org/doxygen/classclang_1_1OMPDeclareReductionDecl.html#details)
 but since other approaches are unfortunately not working this is probably the 
best approach indeed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92409/new/

https://reviews.llvm.org/D92409

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b6ba598 - [clang][cli] Port getAllArgumentValues to the marshalling infrastructure

2021-01-07 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-01-07T12:02:07+01:00
New Revision: b6ba59830796b4efad69a3d3c1fae56c20029f30

URL: 
https://github.com/llvm/llvm-project/commit/b6ba59830796b4efad69a3d3c1fae56c20029f30
DIFF: 
https://github.com/llvm/llvm-project/commit/b6ba59830796b4efad69a3d3c1fae56c20029f30.diff

LOG: [clang][cli] Port getAllArgumentValues to the marshalling infrastructure

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D93679

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index ffa7fbd84df93..6585fd1ceb013 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -679,7 +679,8 @@ def MP : Flag<["-"], "MP">, Group, 
Flags<[CC1Option]>,
 def MQ : JoinedOrSeparate<["-"], "MQ">, Group, Flags<[CC1Option]>,
 HelpText<"Specify name of main file output to quote in depfile">;
 def MT : JoinedOrSeparate<["-"], "MT">, Group, Flags<[CC1Option]>,
-HelpText<"Specify name of main file output in depfile">;
+HelpText<"Specify name of main file output in depfile">,
+MarshallingInfoStringVector<"DependencyOutputOpts.Targets">;
 def MV : Flag<["-"], "MV">, Group, Flags<[CC1Option]>,
 HelpText<"Use NMake/Jom format for the depfile">,
 MarshallingInfoFlag<"DependencyOutputOpts.OutputFormat", 
"DependencyOutputFormat::Make">,
@@ -753,7 +754,8 @@ def Wp_COMMA : CommaJoined<["-"], "Wp,">,
   MetaVarName<"">, Group;
 def Wundef_prefix_EQ : CommaJoined<["-"], "Wundef-prefix=">, 
Group,
   Flags<[CC1Option, CoreOption, HelpHidden]>, MetaVarName<"">,
-  HelpText<"Enable warnings for undefined macros with a prefix in the comma 
separated list ">;
+  HelpText<"Enable warnings for undefined macros with a prefix in the comma 
separated list ">,
+  MarshallingInfoStringVector<"DiagnosticOpts->UndefPrefixes">;
 def Wwrite_strings : Flag<["-"], "Wwrite-strings">, Group, 
Flags<[CC1Option, HelpHidden]>;
 def Wno_write_strings : Flag<["-"], "Wno-write-strings">, Group, 
Flags<[CC1Option, HelpHidden]>;
 def W_Joined : Joined<["-"], "W">, Group, Flags<[CC1Option, 
CoreOption]>,
@@ -1387,7 +1389,8 @@ def fno_sanitize_EQ : CommaJoined<["-"], 
"fno-sanitize=">, Group,
   Flags<[CoreOption, NoXarchOption]>;
 def fsanitize_blacklist : Joined<["-"], "fsanitize-blacklist=">,
   Group,
-  HelpText<"Path to blacklist file for sanitizers">;
+  HelpText<"Path to blacklist file for sanitizers">,
+  
MarshallingInfoStringVector<"LangOpts->SanitizerBlacklistFiles">;
 def fsanitize_system_blacklist : Joined<["-"], "fsanitize-system-blacklist=">,
   HelpText<"Path to system blacklist file for sanitizers">,
   Flags<[CC1Option]>;
@@ -1405,13 +1408,15 @@ def fno_sanitize_coverage
"Sanitizers">, 
Values<"func,bb,edge,indirect-calls,trace-bb,trace-cmp,trace-div,trace-gep,8bit-counters,trace-pc,trace-pc-guard,no-prune,inline-8bit-counters,inline-bool-flag">;
 def fsanitize_coverage_allowlist : Joined<["-"], 
"fsanitize-coverage-allowlist=">,
 Group, Flags<[CoreOption, NoXarchOption]>,
-HelpText<"Restrict sanitizer coverage instrumentation exclusively to 
modules and functions that match the provided special case list, except the 
blocked ones">;
+HelpText<"Restrict sanitizer coverage instrumentation exclusively to 
modules and functions that match the provided special case list, except the 
blocked ones">,
+MarshallingInfoStringVector<"CodeGenOpts.SanitizeCoverageAllowlistFiles">;
 def : Joined<["-"], "fsanitize-coverage-whitelist=">,
   Group, Flags<[CoreOption, HelpHidden]>, 
Alias,
   HelpText<"Deprecated, use -fsanitize-coverage-allowlist= instead">;
 def fsanitize_coverage_blocklist : Joined<["-"], 
"fsanitize-coverage-blocklist=">,
 Group, Flags<[CoreOption, NoXarchOption]>,
-HelpText<"Disable sanitizer coverage instrumentation for modules and 
functions that match the provided special case list, even the allowed ones">;
+HelpText<"Disable sanitizer coverage instrumentation for modules and 
functions that match the provided special case list, even the allowed ones">,
+MarshallingInfoStringVector<"CodeGenOpts.SanitizeCoverageBlocklistFiles">;
 def : Joined<["-"], "fsanitize-coverage-blacklist=">,
   Group, Flags<[CoreOption, HelpHidden]>, 
Alias,
   HelpText<"Deprecated, use -fsanitize-coverage-blocklist= instead">;
@@ -1616,7 +1621,8 @@ defm delete_null_pointer_checks : 
BoolFOption<"delete-null-pointer-checks",
 
 def frewrite_map_file : Separate<["-"], "frewrite-map-file">,
 Group,
-Flags<[ NoXarchOption, CC1Option ]>;
+Flags<[ NoXarchOption, CC1Option ]>,
+
M

[PATCH] D93679: [clang][cli] Port getAllArgumentValues to the marshalling infrastructure

2021-01-07 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb6ba59830796: [clang][cli] Port getAllArgumentValues to the 
marshalling infrastructure (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D93679?vs=313266&id=315083#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93679/new/

https://reviews.llvm.org/D93679

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -328,7 +328,8 @@
 Option::OptionClass OptClass,
 unsigned TableIndex,
 const std::vector &Values) {
-  if (OptClass == Option::OptionClass::CommaJoinedClass) {
+  switch (OptClass) {
+  case Option::CommaJoinedClass: {
 std::string CommaJoinedValue;
 if (!Values.empty()) {
   CommaJoinedValue.append(Values.front());
@@ -339,9 +340,17 @@
 }
 denormalizeString(Args, Spelling, SA, Option::OptionClass::JoinedClass,
   TableIndex, CommaJoinedValue);
-  } else if (OptClass == Option::OptionClass::JoinedClass) {
+break;
+  }
+  case Option::JoinedClass:
+  case Option::SeparateClass:
+  case Option::JoinedOrSeparateClass:
 for (const std::string &Value : Values)
   denormalizeString(Args, Spelling, SA, OptClass, TableIndex, Value);
+break;
+  default:
+llvm_unreachable("Cannot denormalize an option with option class "
+ "incompatible with string vector denormalization.");
   }
 }
 
@@ -996,8 +1005,6 @@
 }
   }
 
-  Opts.Reciprocals = Args.getAllArgValues(OPT_mrecip_EQ);
-
   // Basic Block Sections implies Function Sections.
   Opts.FunctionSections =
   Args.hasArg(OPT_ffunction_sections) ||
@@ -1127,10 +1134,6 @@
 }
 Opts.LinkBitcodeFiles.push_back(F);
   }
-  Opts.SanitizeCoverageAllowlistFiles =
-  Args.getAllArgValues(OPT_fsanitize_coverage_allowlist);
-  Opts.SanitizeCoverageBlocklistFiles =
-  Args.getAllArgValues(OPT_fsanitize_coverage_blocklist);
   Opts.SSPBufferSize =
   getLastArgIntValue(Args, OPT_stack_protector_buffer_size, 8, Diags);
 
@@ -1212,8 +1215,6 @@
 }
   }
 
-  Opts.DependentLibraries = Args.getAllArgValues(OPT_dependent_lib);
-  Opts.LinkerOptions = Args.getAllArgValues(OPT_linker_option);
   bool NeedLocTracking = false;
 
   if (!Opts.OptRecordFile.empty())
@@ -1287,8 +1288,6 @@
   if (NeedLocTracking && Opts.getDebugInfo() == codegenoptions::NoDebugInfo)
 Opts.setDebugInfo(codegenoptions::LocTrackingOnly);
 
-  Opts.RewriteMapFiles = Args.getAllArgValues(OPT_frewrite_map_file);
-
   // Parse -fsanitize-recover= arguments.
   // FIXME: Report unrecoverable sanitizers incorrectly specified here.
   parseSanitizerKinds("-fsanitize-recover=",
@@ -1300,16 +1299,11 @@
 
   Opts.EmitVersionIdentMetadata = Args.hasFlag(OPT_Qy, OPT_Qn, true);
 
-  Opts.DefaultFunctionAttrs = Args.getAllArgValues(OPT_default_function_attr);
-
-  Opts.PassPlugins = Args.getAllArgValues(OPT_fpass_plugin_EQ);
-
   return Success;
 }
 
 static void ParseDependencyOutputArgs(DependencyOutputOptions &Opts,
   ArgList &Args) {
-  Opts.Targets = Args.getAllArgValues(OPT_MT);
   if (Args.hasArg(OPT_show_includes)) {
 // Writing both /showIncludes and preprocessor output to stdout
 // would produce interleaved output, so use stderr for /showIncludes.
@@ -1487,7 +1481,6 @@
   Opts.ShowParseableFixits = Args.hasArg(OPT_fdiagnostics_parseable_fixits);
   Opts.ShowPresumedLoc = !Args.hasArg(OPT_fno_diagnostics_use_presumed_location);
   Opts.VerifyDiagnostics = Args.hasArg(OPT_verify) || Args.hasArg(OPT_verify_EQ);
-  Opts.VerifyPrefixes = Args.getAllArgValues(OPT_verify_EQ);
   if (Args.hasArg(OPT_verify))
 Opts.VerifyPrefixes.push_back("expected");
   // Keep VerifyPrefixes in its original order for the sake of diagnostics, and
@@ -1534,8 +1527,6 @@
   Opts.MessageLength =
   getLastArgIntValue(Args, OPT_fmessage_length_EQ, 0, Diags);
 
-  Opts.UndefPrefixes = Args.getAllArgValues(OPT_Wundef_prefix_EQ);
-
   addDiagnosticArgs(Args, OPT_W_Group, OPT_W_value_Group, Opts.Warnings);
   addDiagnosticArgs(Args, OPT_R_Group, OPT_R_value_Group, Opts.Remarks);
 
@@ -1732,8 +1723,6 @@
   }
 
   Opts.Plugins = Args.getAllArgValues(OPT_load);
-  Opts.ASTMergeFiles = Args.getAllArgValues(OPT_ast_merge);
-  Opts.LLVMArgs = Args.getAllArgValues(OPT_mllvm);
   Opts.ASTDumpDecls = Args.hasArg(OPT_ast_dump, OPT_ast_dump_EQ);
   Opts.ASTDumpAll = Args.hasArg(OPT_ast_dump_all, OPT_ast_dump_all_EQ);
   // Only the -fmodule-file= form.
@@ -1742,7 +1731,6 @@
 if (Val.find('=') == StringRef::npo

[PATCH] D94206: [clang-format] turn on formatting after "clang-format on" while sorting includes

2021-01-07 Thread Rafał Jelonek via Phabricator via cfe-commits
rjelonek added a comment.

there is no related bug.

About Line.endswith("\\") -> Trimmed.endswith("\\")
When i debugging clang-format, i noticed that "Line.endswith("\\")" never 
result with true (even if i put \ at the end of line - in my case CRLF). But 
when i change line ending to LF condition return true.
After work i will merge:

- "MergeLinesWhenCodeContainsLF" and "MergeLinesWhenCodeContainsCRLF"
- "DetectClangFormatOn" to "SupportClangFormatOff"


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94206/new/

https://reviews.llvm.org/D94206

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94206: [clang-format] turn on formatting after "clang-format on" while sorting includes

2021-01-07 Thread Rafał Jelonek via Phabricator via cfe-commits
rjelonek added a comment.



In D94206#2483901 , @MyDeveloperDay 
wrote:

> I'm not seeing this
>
>   // clang-format off
>   #include "d.h"
>   #include "b.h"
>   // clang-format on
>   
>   #include "a.h"
>   #include "c.h"
>   #include "e.h"
>
>   $ unix2dos test1.cpp
>   unix2dos: converting file test1.cpp to DOS format...
>
>   $ clang-format test1.cpp
>   // clang-format off
>   #include "d.h"
>   #include "b.h"
>   // clang-format on
>   
>   #include "a.h"
>   #include "c.h"
>   #include "e.h"

In unit test "e.h" is mainInclude. Maybe change test1.cpp to e.cpp


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94206/new/

https://reviews.llvm.org/D94206

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 33f90f3 - [clang][cli] Report the actual argument parsing result

2021-01-07 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-01-07T12:37:04+01:00
New Revision: 33f90f38e11c7c23d6e2a23ca526f8b0d8f53771

URL: 
https://github.com/llvm/llvm-project/commit/33f90f38e11c7c23d6e2a23ca526f8b0d8f53771
DIFF: 
https://github.com/llvm/llvm-project/commit/33f90f38e11c7c23d6e2a23ca526f8b0d8f53771.diff

LOG: [clang][cli] Report the actual argument parsing result

Reviewed By: Bigcheese

Differential Revision: https://reviews.llvm.org/D93700

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp
clang/unittests/Frontend/CompilerInvocationTest.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 49447f16637f..7fb7ec896e64 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -129,10 +129,9 @@ CompilerInvocationBase::~CompilerInvocationBase() = 
default;
 #include "clang/Driver/Options.inc"
 #undef SIMPLE_ENUM_VALUE_TABLE
 
-static llvm::Optional normalizeSimpleFlag(OptSpecifier Opt,
-unsigned TableIndex,
-const ArgList &Args,
-DiagnosticsEngine &Diags) {
+static llvm::Optional
+normalizeSimpleFlag(OptSpecifier Opt, unsigned TableIndex, const ArgList &Args,
+DiagnosticsEngine &Diags, bool &Success) {
   if (Args.hasArg(Opt))
 return true;
   return None;
@@ -140,7 +139,8 @@ static llvm::Optional 
normalizeSimpleFlag(OptSpecifier Opt,
 
 static Optional normalizeSimpleNegativeFlag(OptSpecifier Opt, unsigned,
   const ArgList &Args,
-  DiagnosticsEngine &) {
+  DiagnosticsEngine &,
+  bool &Success) {
   if (Args.hasArg(Opt))
 return false;
   return None;
@@ -166,7 +166,7 @@ template (), bool> = false>
 static auto makeFlagToValueNormalizer(T Value) {
   return [Value](OptSpecifier Opt, unsigned, const ArgList &Args,
- DiagnosticsEngine &) -> Optional {
+ DiagnosticsEngine &, bool &Success) -> Optional {
 if (Args.hasArg(Opt))
   return Value;
 return None;
@@ -182,8 +182,8 @@ static auto makeFlagToValueNormalizer(T Value) {
 static auto makeBooleanOptionNormalizer(bool Value, bool OtherValue,
 OptSpecifier OtherOpt) {
   return [Value, OtherValue, OtherOpt](OptSpecifier Opt, unsigned,
-   const ArgList &Args,
-   DiagnosticsEngine &) -> Optional {
+   const ArgList &Args, DiagnosticsEngine 
&,
+   bool &Success) -> Optional {
 if (const Arg *A = Args.getLastArg(Opt, OtherOpt)) {
   return A->getOption().matches(Opt) ? Value : OtherValue;
 }
@@ -246,10 +246,9 @@ findValueTableByValue(const SimpleEnumValueTable &Table, 
unsigned Value) {
   return None;
 }
 
-static llvm::Optional normalizeSimpleEnum(OptSpecifier Opt,
-unsigned TableIndex,
-const ArgList &Args,
-DiagnosticsEngine &Diags) {
+static llvm::Optional
+normalizeSimpleEnum(OptSpecifier Opt, unsigned TableIndex, const ArgList &Args,
+DiagnosticsEngine &Diags, bool &Success) {
   assert(TableIndex < SimpleEnumValueTablesSize);
   const SimpleEnumValueTable &Table = SimpleEnumValueTables[TableIndex];
 
@@ -261,6 +260,7 @@ static llvm::Optional 
normalizeSimpleEnum(OptSpecifier Opt,
   if (auto MaybeEnumVal = findValueTableByName(Table, ArgValue))
 return MaybeEnumVal->Value;
 
+  Success = false;
   Diags.Report(diag::err_drv_invalid_value)
   << Arg->getAsString(Args) << ArgValue;
   return None;
@@ -294,7 +294,8 @@ static void denormalizeSimpleEnum(SmallVectorImpl &Args,
 
 static Optional normalizeString(OptSpecifier Opt, int TableIndex,
  const ArgList &Args,
- DiagnosticsEngine &Diags) {
+ DiagnosticsEngine &Diags,
+ bool &Success) {
   auto *Arg = Args.getLastArg(Opt);
   if (!Arg)
 return None;
@@ -302,14 +303,15 @@ static Optional normalizeString(OptSpecifier 
Opt, int TableIndex,
 }
 
 template 
-static Optional normalizeStringIntegral(OptSpecifier Opt, int,
-   const ArgList &Args,
-   DiagnosticsEngine &Diags) {
+static Optional
+normalizeStringIntegral(OptSpecifier Opt, int, const ArgList

[PATCH] D93700: [clang][cli] Report the actual argument parsing result

2021-01-07 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG33f90f38e11c: [clang][cli] Report the actual argument 
parsing result (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D93700?vs=313327&id=315087#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93700/new/

https://reviews.llvm.org/D93700

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp

Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -100,9 +100,7 @@
 TEST_F(CommandLineTest, BoolOptionDefaultTrueSingleFlagNotPresent) {
   const char *Args[] = {""};
 
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
-  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
   ASSERT_TRUE(Invocation.getFrontendOpts().UseTemporary);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -113,9 +111,7 @@
 TEST_F(CommandLineTest, BoolOptionDefaultTrueSingleFlagPresent) {
   const char *Args[] = {"-fno-temp-file"};
 
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
-  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
   ASSERT_FALSE(Invocation.getFrontendOpts().UseTemporary);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -126,10 +122,8 @@
 TEST_F(CommandLineTest, BoolOptionDefaultTrueSingleFlagUnknownPresent) {
   const char *Args[] = {"-ftemp-file"};
 
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
   // Driver-only flag.
-  ASSERT_TRUE(Diags->hasErrorOccurred());
+  ASSERT_FALSE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
   ASSERT_TRUE(Invocation.getFrontendOpts().UseTemporary);
 }
 
@@ -140,8 +134,7 @@
 TEST_F(CommandLineTest, BoolOptionDefaultTruePresentNone) {
   const char *Args[] = {""};
 
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
   ASSERT_TRUE(Invocation.getCodeGenOpts().Autolink);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -152,8 +145,7 @@
 TEST_F(CommandLineTest, BoolOptionDefaultTruePresentNegChange) {
   const char *Args[] = {"-fno-autolink"};
 
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
   ASSERT_FALSE(Invocation.getCodeGenOpts().Autolink);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -164,8 +156,8 @@
 TEST_F(CommandLineTest, BoolOptionDefaultTruePresentPosReset) {
   const char *Args[] = {"-fautolink"};
 
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_TRUE(Diags->hasErrorOccurred()); // Driver-only flag.
+  // Driver-only flag.
+  ASSERT_FALSE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
   ASSERT_TRUE(Invocation.getCodeGenOpts().Autolink);
 }
 
@@ -176,8 +168,7 @@
 TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNone) {
   const char *Args[] = {""};
 
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
   ASSERT_FALSE(Invocation.getCodeGenOpts().NoInlineLineTables);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -188,8 +179,7 @@
 TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNegChange) {
   const char *Args[] = {"-gno-inline-line-tables"};
 
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
   ASSERT_TRUE(Invocation.getCodeGenOpts().NoInlineLineTables);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -200,8 +190,8 @@
 TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentPosReset) {
   const char *Args[] = {"-ginline-line-tables"};
 
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_TRUE(Diags->hasErrorOccurred()); // Driver-only flag.
+  // Driver-only flag.
+  ASSERT_FALSE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
   ASSERT_FALSE(Invocation.getCodeGenOpts().NoInlineLineTables);
 }
 
@@ -212,8 +202,7 @@
 TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNoneX) {
   const char *Args[] = {""};
 
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));

[PATCH] D93453: [flang][driver] Add support for `-I`

2021-01-07 Thread Faris via Phabricator via cfe-commits
FarisRehman updated this revision to Diff 315090.
FarisRehman added a comment.

Rename test files

Rename test files to use dashes instead of underscores, as other test files do.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93453/new/

https://reviews.llvm.org/D93453

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/PreprocessorOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Flang-Driver/Inputs/basic-test-header.h
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/include-header.f90

Index: flang/test/Flang-Driver/include-header.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/include-header.f90
@@ -0,0 +1,39 @@
+! Ensure argument -I works as expected.
+
+! REQUIRES: new-flang-driver
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: %flang-new -E %s  2>&1 | FileCheck %s --check-prefix=UNINCLUDED
+! RUN: %flang-new -E -I %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
+! RUN: %flang-new -E -I %S/InvalidFolder %s  2>&1 | FileCheck %s --check-prefix=UNINCLUDED
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang-new -fc1 -E %s  2>&1 | FileCheck %s --check-prefix=UNINCLUDED
+! RUN: %flang-new -fc1 -E -I %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
+! RUN: %flang-new -fc1 -E -I %S/InvalidFolder %s  2>&1 | FileCheck %s --check-prefix=UNINCLUDED
+
+!
+! EXPECTED OUTPUT FOR MISSING INCLUDED FILE
+!
+! UNINCLUDED:program b
+! UNINCLUDED-NOT:program a
+! UNINCLUDED-NEXT:end
+
+!--
+! EXPECTED OUTPUT FOR INCLUDE
+!--
+! INCLUDED:program a
+! INCLUDED-NOT:program b
+! INCLUDED-NEXT:end
+
+#include 
+#ifdef X
+program A
+#else
+program B
+#endif
+end
\ No newline at end of file
Index: flang/test/Flang-Driver/driver-help.f90
===
--- flang/test/Flang-Driver/driver-help.f90
+++ flang/test/Flang-Driver/driver-help.f90
@@ -24,6 +24,7 @@
 ! HELP-NEXT: -fcolor-diagnosticsEnable colors in diagnostics
 ! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
 ! HELP-NEXT: -help  Display available options
+! HELP-NEXT: -IAdd directory to include search path
 ! HELP-NEXT: -o   Write output to 
 ! HELP-NEXT: -U  Undefine macro 
 ! HELP-NEXT: --version  Print version information
@@ -37,6 +38,7 @@
 ! HELP-FC1-NEXT: -D = Define  to  (or 1 if  omitted)
 ! HELP-FC1-NEXT: -E Only run the preprocessor
 ! HELP-FC1-NEXT: -help  Display available options
+! HELP-FC1-NEXT: -IAdd directory to include search path
 ! HELP-FC1-NEXT: -o   Write output to 
 ! HELP-FC1-NEXT: -U  Undefine macro 
 ! HELP-FC1-NEXT: --version  Print version information
Index: flang/test/Flang-Driver/driver-help-hidden.f90
===
--- flang/test/Flang-Driver/driver-help-hidden.f90
+++ flang/test/Flang-Driver/driver-help-hidden.f90
@@ -24,6 +24,7 @@
 ! CHECK-NEXT: -fcolor-diagnosticsEnable colors in diagnostics
 ! CHECK-NEXT: -fno-color-diagnostics Disable colors in diagnostics
 ! CHECK-NEXT: -help Display available options
+! CHECK-NEXT: -IAdd directory to include search path
 ! CHECK-NEXT: -o  Write output to 
 ! CHECK-NEXT: -test-io  Run the InputOuputTest action. Use for development and testing only.
 ! CHECK-NEXT: -U  Undefine macro 
Index: flang/test/Flang-Driver/Inputs/basic-test-header.h
===
--- /dev/null
+++ flang/test/Flang-Driver/Inputs/basic-test-header.h
@@ -0,0 +1 @@
+#define X
\ No newline at end of file
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -171,6 +171,10 @@
   opts.addMacroUndef(currentArg->getValue());
 }
   }
+
+  // Add the ordered list of -I's.
+  for (const auto *currentArg : args.filtered(clang::driver::options::OPT_I))
+opts.searchDirectoriesFromDashI.emplace_back(currentArg->getValue());
 }
 
 bool CompilerInvocation::CreateFromArgs(CompilerInvocation &res,
@@ -256,4 +260,9 @@
   const auto &preprocessorOptions = preprocessorOpts();
 
   collectMacroDefinitions(preprocessorOptions, fortranOptions);
-}
\ No newline at end of file
+
+  fortranOptions.searchDirectories.insert(
+  fortranOptions.searchDirector

[PATCH] D94224: [clang][AST] Get rid of an alignment hack in DeclObjC.h [NFCI]

2021-01-07 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki created this revision.
miyuki added reviewers: dexonsmith, aprantl.
miyuki requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch utilizes the `alignas` specifier and removes the workaround
which used a union object for the same purpose. Removing the union
allows using the SourceRange class directly instead of re-implementing
it with raw representations of source locations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94224

Files:
  clang/include/clang/AST/DeclObjC.h
  clang/lib/AST/DeclObjC.cpp


Index: clang/lib/AST/DeclObjC.cpp
===
--- clang/lib/AST/DeclObjC.cpp
+++ clang/lib/AST/DeclObjC.cpp
@@ -1461,9 +1461,8 @@
 ObjCTypeParamList::ObjCTypeParamList(SourceLocation lAngleLoc,
  ArrayRef typeParams,
  SourceLocation rAngleLoc)
-: NumParams(typeParams.size()) {
-  Brackets.Begin = lAngleLoc.getRawEncoding();
-  Brackets.End = rAngleLoc.getRawEncoding();
+: Brackets(lAngleLoc, rAngleLoc),
+  NumParams(typeParams.size()) {
   std::copy(typeParams.begin(), typeParams.end(), begin());
 }
 
Index: clang/include/clang/AST/DeclObjC.h
===
--- clang/include/clang/AST/DeclObjC.h
+++ clang/include/clang/AST/DeclObjC.h
@@ -656,20 +656,8 @@
 /// \endcode
 class ObjCTypeParamList final
 : private llvm::TrailingObjects {
-  /// Stores the components of a SourceRange as a POD.
-  struct PODSourceRange {
-unsigned Begin;
-unsigned End;
-  };
-
-  union {
-/// Location of the left and right angle brackets.
-PODSourceRange Brackets;
-
-// Used only for alignment.
-ObjCTypeParamDecl *AlignmentHack;
-  };
-
+  /// Location of the left and right angle brackets.
+  alignas(ObjCTypeParamDecl *) SourceRange Brackets;
   /// The number of parameters in the list, which are tail-allocated.
   unsigned NumParams;
 
@@ -718,15 +706,15 @@
   }
 
   SourceLocation getLAngleLoc() const {
-return SourceLocation::getFromRawEncoding(Brackets.Begin);
+return Brackets.getBegin();
   }
 
   SourceLocation getRAngleLoc() const {
-return SourceLocation::getFromRawEncoding(Brackets.End);
+return Brackets.getEnd();
   }
 
   SourceRange getSourceRange() const {
-return SourceRange(getLAngleLoc(), getRAngleLoc());
+return Brackets;
   }
 
   /// Gather the default set of type arguments to be substituted for


Index: clang/lib/AST/DeclObjC.cpp
===
--- clang/lib/AST/DeclObjC.cpp
+++ clang/lib/AST/DeclObjC.cpp
@@ -1461,9 +1461,8 @@
 ObjCTypeParamList::ObjCTypeParamList(SourceLocation lAngleLoc,
  ArrayRef typeParams,
  SourceLocation rAngleLoc)
-: NumParams(typeParams.size()) {
-  Brackets.Begin = lAngleLoc.getRawEncoding();
-  Brackets.End = rAngleLoc.getRawEncoding();
+: Brackets(lAngleLoc, rAngleLoc),
+  NumParams(typeParams.size()) {
   std::copy(typeParams.begin(), typeParams.end(), begin());
 }
 
Index: clang/include/clang/AST/DeclObjC.h
===
--- clang/include/clang/AST/DeclObjC.h
+++ clang/include/clang/AST/DeclObjC.h
@@ -656,20 +656,8 @@
 /// \endcode
 class ObjCTypeParamList final
 : private llvm::TrailingObjects {
-  /// Stores the components of a SourceRange as a POD.
-  struct PODSourceRange {
-unsigned Begin;
-unsigned End;
-  };
-
-  union {
-/// Location of the left and right angle brackets.
-PODSourceRange Brackets;
-
-// Used only for alignment.
-ObjCTypeParamDecl *AlignmentHack;
-  };
-
+  /// Location of the left and right angle brackets.
+  alignas(ObjCTypeParamDecl *) SourceRange Brackets;
   /// The number of parameters in the list, which are tail-allocated.
   unsigned NumParams;
 
@@ -718,15 +706,15 @@
   }
 
   SourceLocation getLAngleLoc() const {
-return SourceLocation::getFromRawEncoding(Brackets.Begin);
+return Brackets.getBegin();
   }
 
   SourceLocation getRAngleLoc() const {
-return SourceLocation::getFromRawEncoding(Brackets.End);
+return Brackets.getEnd();
   }
 
   SourceRange getSourceRange() const {
-return SourceRange(getLAngleLoc(), getRAngleLoc());
+return Brackets;
   }
 
   /// Gather the default set of type arguments to be substituted for
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 213329d - [clangd] Add server capability advertising hot-reloading of CDBs.

2021-01-07 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-01-07T13:39:21+01:00
New Revision: 213329d7c64f9710f23a78596255509b147b37c6

URL: 
https://github.com/llvm/llvm-project/commit/213329d7c64f9710f23a78596255509b147b37c6
DIFF: 
https://github.com/llvm/llvm-project/commit/213329d7c64f9710f23a78596255509b147b37c6.diff

LOG: [clangd] Add server capability advertising hot-reloading of CDBs.

Currently some clients watch for CDB changes and restart clangd, now that we
can reload compile_commands.json ourselves this is counterproductive.
The capability allows this behavior to be phased out.

This is going to be a mild regression, as we do not actually watch for files on
disk and so new diagnostics need to wait until a rebuild is requested e.g. due
to file change (and the internal caches have expired).
However this is still a better tradeoff (and if it's important, we can request
the client to watch files for us in the future).

Differential Revision: https://reviews.llvm.org/D94222

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/test/initialize-params.test

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index c606ccae4fdc..4e5d9f8bf0fa 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -620,7 +620,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
&Params,
 {"documentSymbolProvider", true},
 {"workspaceSymbolProvider", true},
 {"referencesProvider", true},
-{"astProvider", true},
+{"astProvider", true}, // clangd extension
 {"executeCommandProvider",
  llvm::json::Object{
  {"commands",
@@ -628,7 +628,9 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
&Params,
ExecuteCommandParams::CLANGD_APPLY_TWEAK}},
  }},
 {"typeHierarchyProvider", true},
-{"memoryUsageProvider", true}, // clangd extension.
+{"memoryUsageProvider", true}, // clangd extension
+{"compilationDatabase",// clangd extension
+ llvm::json::Object{{"automaticReload", true}}},
 {"callHierarchyProvider", true},
 ;
   if (Opts.Encoding)

diff  --git a/clang-tools-extra/clangd/test/initialize-params.test 
b/clang-tools-extra/clangd/test/initialize-params.test
index e4f4bf18dee4..907ab0ade420 100644
--- a/clang-tools-extra/clangd/test/initialize-params.test
+++ b/clang-tools-extra/clangd/test/initialize-params.test
@@ -8,6 +8,9 @@
 # CHECK-NEXT:  "astProvider": true,
 # CHECK-NEXT:  "callHierarchyProvider": true,
 # CHECK-NEXT:  "codeActionProvider": true,
+# CHECK-NEXT:  "compilationDatabase": {
+# CHECK-NEXT:"automaticReload": true
+# CHECK-NEXT:  },
 # CHECK-NEXT:  "completionProvider": {
 # CHECK-NEXT:"allCommitCharacters": [
 # CHECK-NEXT:  " ",



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94222: [clangd] Add server capability advertising hot-reloading of CDBs.

2021-01-07 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG213329d7c64f: [clangd] Add server capability advertising 
hot-reloading of CDBs. (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94222/new/

https://reviews.llvm.org/D94222

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/test/initialize-params.test


Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -8,6 +8,9 @@
 # CHECK-NEXT:  "astProvider": true,
 # CHECK-NEXT:  "callHierarchyProvider": true,
 # CHECK-NEXT:  "codeActionProvider": true,
+# CHECK-NEXT:  "compilationDatabase": {
+# CHECK-NEXT:"automaticReload": true
+# CHECK-NEXT:  },
 # CHECK-NEXT:  "completionProvider": {
 # CHECK-NEXT:"allCommitCharacters": [
 # CHECK-NEXT:  " ",
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -620,7 +620,7 @@
 {"documentSymbolProvider", true},
 {"workspaceSymbolProvider", true},
 {"referencesProvider", true},
-{"astProvider", true},
+{"astProvider", true}, // clangd extension
 {"executeCommandProvider",
  llvm::json::Object{
  {"commands",
@@ -628,7 +628,9 @@
ExecuteCommandParams::CLANGD_APPLY_TWEAK}},
  }},
 {"typeHierarchyProvider", true},
-{"memoryUsageProvider", true}, // clangd extension.
+{"memoryUsageProvider", true}, // clangd extension
+{"compilationDatabase",// clangd extension
+ llvm::json::Object{{"automaticReload", true}}},
 {"callHierarchyProvider", true},
 ;
   if (Opts.Encoding)


Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -8,6 +8,9 @@
 # CHECK-NEXT:  "astProvider": true,
 # CHECK-NEXT:  "callHierarchyProvider": true,
 # CHECK-NEXT:  "codeActionProvider": true,
+# CHECK-NEXT:  "compilationDatabase": {
+# CHECK-NEXT:"automaticReload": true
+# CHECK-NEXT:  },
 # CHECK-NEXT:  "completionProvider": {
 # CHECK-NEXT:"allCommitCharacters": [
 # CHECK-NEXT:  " ",
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -620,7 +620,7 @@
 {"documentSymbolProvider", true},
 {"workspaceSymbolProvider", true},
 {"referencesProvider", true},
-{"astProvider", true},
+{"astProvider", true}, // clangd extension
 {"executeCommandProvider",
  llvm::json::Object{
  {"commands",
@@ -628,7 +628,9 @@
ExecuteCommandParams::CLANGD_APPLY_TWEAK}},
  }},
 {"typeHierarchyProvider", true},
-{"memoryUsageProvider", true}, // clangd extension.
+{"memoryUsageProvider", true}, // clangd extension
+{"compilationDatabase",// clangd extension
+ llvm::json::Object{{"automaticReload", true}}},
 {"callHierarchyProvider", true},
 ;
   if (Opts.Encoding)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 236129f - [CompilationDatabase] Pass Twine by const reference instead of by value. NFCI.

2021-01-07 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2021-01-07T12:53:28Z
New Revision: 236129fb4460a4030eee685abc2f02b32458e775

URL: 
https://github.com/llvm/llvm-project/commit/236129fb4460a4030eee685abc2f02b32458e775
DIFF: 
https://github.com/llvm/llvm-project/commit/236129fb4460a4030eee685abc2f02b32458e775.diff

LOG: [CompilationDatabase] Pass Twine by const reference instead of by value. 
NFCI.

Added: 


Modified: 
clang/include/clang/Tooling/CompilationDatabase.h
clang/lib/Tooling/CompilationDatabase.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/CompilationDatabase.h 
b/clang/include/clang/Tooling/CompilationDatabase.h
index cbd57e9609aa..44af236347b3 100644
--- a/clang/include/clang/Tooling/CompilationDatabase.h
+++ b/clang/include/clang/Tooling/CompilationDatabase.h
@@ -43,10 +43,10 @@ namespace tooling {
 /// Specifies the working directory and command of a compilation.
 struct CompileCommand {
   CompileCommand() = default;
-  CompileCommand(Twine Directory, Twine Filename,
- std::vector CommandLine, Twine Output)
+  CompileCommand(const Twine &Directory, const Twine &Filename,
+ std::vector CommandLine, const Twine &Output)
   : Directory(Directory.str()), Filename(Filename.str()),
-CommandLine(std::move(CommandLine)), Output(Output.str()){}
+CommandLine(std::move(CommandLine)), Output(Output.str()) {}
 
   /// The working directory the command was executed from.
   std::string Directory;
@@ -180,9 +180,9 @@ class FixedCompilationDatabase : public CompilationDatabase 
{
   /// \param Argv Points to the command line arguments.
   /// \param ErrorMsg Contains error text if the function returns null pointer.
   /// \param Directory The base directory used in the FixedCompilationDatabase.
-  static std::unique_ptr loadFromCommandLine(
-  int &Argc, const char *const *Argv, std::string &ErrorMsg,
-  Twine Directory = ".");
+  static std::unique_ptr
+  loadFromCommandLine(int &Argc, const char *const *Argv, std::string 
&ErrorMsg,
+  const Twine &Directory = ".");
 
   /// Reads flags from the given file, one-per-line.
   /// Returns nullptr and sets ErrorMessage if we can't read the file.
@@ -196,7 +196,8 @@ class FixedCompilationDatabase : public CompilationDatabase 
{
 
   /// Constructs a compilation data base from a specified directory
   /// and command line.
-  FixedCompilationDatabase(Twine Directory, ArrayRef CommandLine);
+  FixedCompilationDatabase(const Twine &Directory,
+   ArrayRef CommandLine);
 
   /// Returns the given compile command.
   ///

diff  --git a/clang/lib/Tooling/CompilationDatabase.cpp 
b/clang/lib/Tooling/CompilationDatabase.cpp
index d339fd044c02..1e19e68633d2 100644
--- a/clang/lib/Tooling/CompilationDatabase.cpp
+++ b/clang/lib/Tooling/CompilationDatabase.cpp
@@ -323,7 +323,7 @@ std::unique_ptr
 FixedCompilationDatabase::loadFromCommandLine(int &Argc,
   const char *const *Argv,
   std::string &ErrorMsg,
-  Twine Directory) {
+  const Twine &Directory) {
   ErrorMsg.clear();
   if (Argc == 0)
 return nullptr;
@@ -368,8 +368,8 @@ FixedCompilationDatabase::loadFromBuffer(StringRef 
Directory, StringRef Data,
   return std::make_unique(Directory, 
std::move(Args));
 }
 
-FixedCompilationDatabase::
-FixedCompilationDatabase(Twine Directory, ArrayRef CommandLine) {
+FixedCompilationDatabase::FixedCompilationDatabase(
+const Twine &Directory, ArrayRef CommandLine) {
   std::vector ToolCommandLine(1, GetClangToolCommand());
   ToolCommandLine.insert(ToolCommandLine.end(),
  CommandLine.begin(), CommandLine.end());



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93701: [clang][cli] NFC: Ensure non-null DiagnosticsEngine in ParseDiagnosticArgs

2021-01-07 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1400-1402
 bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
-DiagnosticsEngine *Diags,
+DiagnosticsEngine &Diags,
 bool DefaultDiagColor) {

dexonsmith wrote:
> Instead of this change (and updating callers), I suggest adding:
> ```
>   Optional IgnoredDiags;
>   if (!Diags) {
> IgnoredDiags.emplace(new DiagnosticIDs(), new DiagnosticOptions(),
>  new IgnoringDiagConsumer());
> Diags = &*IgnoredDiags;
>   }
> ```
> 
That's a nice way to keep the signature intact. Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93701/new/

https://reviews.llvm.org/D93701

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e72cdc5 - [clang][cli] NFC: Ensure non-null DiagnosticsEngine in ParseDiagnosticArgs

2021-01-07 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-01-07T14:15:08+01:00
New Revision: e72cdc5ba1e65ecd8632663b6604eb9be8d1a162

URL: 
https://github.com/llvm/llvm-project/commit/e72cdc5ba1e65ecd8632663b6604eb9be8d1a162
DIFF: 
https://github.com/llvm/llvm-project/commit/e72cdc5ba1e65ecd8632663b6604eb9be8d1a162.diff

LOG: [clang][cli] NFC: Ensure non-null DiagnosticsEngine in ParseDiagnosticArgs

Before this patch, ParseDiagnosticArgs can be called with a nullptr 
DiagnosticsEngine *. This happens early on in the compilation process, where no 
proper DiagnosticEngine exists, because the diagnostic options (passed through 
command line) are not known yet.

This patch ensures nullptr is replaced by an ignoring DiagnosticEngine in 
ParseDiagnosticArgs, which allows to switch from pointer to a reference in some 
utility functions.

Besides simplifying the code, this patch enables a future patch (D84673) that 
ports diagnostic options to the new marshalling infrastructure.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D93701

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 7fb7ec896e64..7f3e39ede281 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -830,7 +830,7 @@ GenerateOptimizationRemarkRegex(DiagnosticsEngine &Diags, 
ArgList &Args,
 
 static bool parseDiagnosticLevelMask(StringRef FlagName,
  const std::vector &Levels,
- DiagnosticsEngine *Diags,
+ DiagnosticsEngine &Diags,
  DiagnosticLevelMask &M) {
   bool Success = true;
   for (const auto &Level : Levels) {
@@ -843,8 +843,7 @@ static bool parseDiagnosticLevelMask(StringRef FlagName,
 .Default(DiagnosticLevelMask::None);
 if (PM == DiagnosticLevelMask::None) {
   Success = false;
-  if (Diags)
-Diags->Report(diag::err_drv_invalid_value) << FlagName << Level;
+  Diags.Report(diag::err_drv_invalid_value) << FlagName << Level;
 }
 M = M | PM;
   }
@@ -1383,7 +1382,7 @@ static bool parseShowColorsArgs(const ArgList &Args, bool 
DefaultColor) {
 }
 
 static bool checkVerifyPrefixes(const std::vector &VerifyPrefixes,
-DiagnosticsEngine *Diags) {
+DiagnosticsEngine &Diags) {
   bool Success = true;
   for (const auto &Prefix : VerifyPrefixes) {
 // Every prefix must start with a letter and contain only alphanumeric
@@ -1393,10 +1392,8 @@ static bool checkVerifyPrefixes(const 
std::vector &VerifyPrefixes,
 });
 if (BadChar != Prefix.end() || !isLetter(Prefix[0])) {
   Success = false;
-  if (Diags) {
-Diags->Report(diag::err_drv_invalid_value) << "-verify=" << Prefix;
-Diags->Report(diag::note_drv_verify_prefix_spelling);
-  }
+  Diags.Report(diag::err_drv_invalid_value) << "-verify=" << Prefix;
+  Diags.Report(diag::note_drv_verify_prefix_spelling);
 }
   }
   return Success;
@@ -1405,6 +1402,13 @@ static bool checkVerifyPrefixes(const 
std::vector &VerifyPrefixes,
 bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
 DiagnosticsEngine *Diags,
 bool DefaultDiagColor) {
+  Optional IgnoringDiags;
+  if (!Diags) {
+IgnoringDiags.emplace(new DiagnosticIDs(), new DiagnosticOptions(),
+  new IgnoringDiagConsumer());
+Diags = &*IgnoringDiags;
+  }
+
   bool Success = true;
 
   Opts.DiagnosticLogFile =
@@ -1439,10 +1443,9 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, 
ArgList &Args,
 Opts.setShowOverloads(Ovl_All);
   else {
 Success = false;
-if (Diags)
-  Diags->Report(diag::err_drv_invalid_value)
-  << Args.getLastArg(OPT_fshow_overloads_EQ)->getAsString(Args)
-  << ShowOverloads;
+Diags->Report(diag::err_drv_invalid_value)
+<< Args.getLastArg(OPT_fshow_overloads_EQ)->getAsString(Args)
+<< ShowOverloads;
   }
 
   StringRef ShowCategory =
@@ -1455,10 +1458,9 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, 
ArgList &Args,
 Opts.ShowCategories = 2;
   else {
 Success = false;
-if (Diags)
-  Diags->Report(diag::err_drv_invalid_value)
-  << Args.getLastArg(OPT_fdiagnostics_show_category)->getAsString(Args)
-  << ShowCategory;
+Diags->Report(diag::err_drv_invalid_value)
+<< Args.getLastArg(OPT_fdiagnostics_show_category)->getAsString(Args)
+<< ShowCategory;
   }
 
   StringRef Format =
@@ -1474,10 +1476,9 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, 
ArgList &Args,
 Opts.setFormat(DiagnosticOptions::Vi);
   else {
 Success = false;
-

[clang] 75d6363 - [clang][cli] NFC: Move parseSimpleArgs

2021-01-07 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-01-07T14:15:08+01:00
New Revision: 75d63630ebb197c338801d6b100ae2e06800c4ce

URL: 
https://github.com/llvm/llvm-project/commit/75d63630ebb197c338801d6b100ae2e06800c4ce
DIFF: 
https://github.com/llvm/llvm-project/commit/75d63630ebb197c338801d6b100ae2e06800c4ce.diff

LOG: [clang][cli] NFC: Move parseSimpleArgs

This patch moves `parseSimpleArgs` closer to `ParseDiagnosticArgs` so that 
sharing the parsing macro between them can be done more locally in a future 
patch.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D94172

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 7f3e39ede281..8b641aabd1af 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1399,6 +1399,32 @@ static bool checkVerifyPrefixes(const 
std::vector &VerifyPrefixes,
   return Success;
 }
 
+bool CompilerInvocation::parseSimpleArgs(const ArgList &Args,
+ DiagnosticsEngine &Diags) {
+  bool Success = true;
+
+#define OPTION_WITH_MARSHALLING(   
\
+PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
+HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   
\
+DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, 
\
+MERGER, EXTRACTOR, TABLE_INDEX)
\
+  if ((FLAGS)&options::CC1Option) {
\
+this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);  
\
+if (IMPLIED_CHECK) 
\
+  this->KEYPATH = MERGER(this->KEYPATH, IMPLIED_VALUE);
\
+if (SHOULD_PARSE)  
\
+  if (auto MaybeValue =
\
+  NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags, Success)) 
\
+this->KEYPATH = MERGER(
\
+this->KEYPATH, static_castKEYPATH)>(*MaybeValue)); 
\
+  }
+
+#include "clang/Driver/Options.inc"
+#undef OPTION_WITH_MARSHALLING
+
+  return Success;
+}
+
 bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
 DiagnosticsEngine *Diags,
 bool DefaultDiagColor) {
@@ -2971,32 +2997,6 @@ static void ParseTargetArgs(TargetOptions &Opts, ArgList 
&Args,
   }
 }
 
-bool CompilerInvocation::parseSimpleArgs(const ArgList &Args,
- DiagnosticsEngine &Diags) {
-  bool Success = true;
-
-#define OPTION_WITH_MARSHALLING(   
\
-PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
-HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   
\
-DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, 
\
-MERGER, EXTRACTOR, TABLE_INDEX)
\
-  if ((FLAGS)&options::CC1Option) {
\
-this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);  
\
-if (IMPLIED_CHECK) 
\
-  this->KEYPATH = MERGER(this->KEYPATH, IMPLIED_VALUE);
\
-if (SHOULD_PARSE)  
\
-  if (auto MaybeValue = \
-NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags, Success))\
-this->KEYPATH = MERGER(
\
-this->KEYPATH, static_castKEYPATH)>(*MaybeValue)); 
\
-  }
-
-#include "clang/Driver/Options.inc"
-#undef OPTION_WITH_MARSHALLING
-
-  return Success;
-}
-
 bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
 ArrayRef CommandLineArgs,
 DiagnosticsEngine &Diags,



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93701: [clang][cli] NFC: Ensure non-null DiagnosticsEngine in ParseDiagnosticArgs

2021-01-07 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe72cdc5ba1e6: [clang][cli] NFC: Ensure non-null 
DiagnosticsEngine in ParseDiagnosticArgs (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D93701?vs=314866&id=315108#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93701/new/

https://reviews.llvm.org/D93701

Files:
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -830,7 +830,7 @@
 
 static bool parseDiagnosticLevelMask(StringRef FlagName,
  const std::vector &Levels,
- DiagnosticsEngine *Diags,
+ DiagnosticsEngine &Diags,
  DiagnosticLevelMask &M) {
   bool Success = true;
   for (const auto &Level : Levels) {
@@ -843,8 +843,7 @@
 .Default(DiagnosticLevelMask::None);
 if (PM == DiagnosticLevelMask::None) {
   Success = false;
-  if (Diags)
-Diags->Report(diag::err_drv_invalid_value) << FlagName << Level;
+  Diags.Report(diag::err_drv_invalid_value) << FlagName << Level;
 }
 M = M | PM;
   }
@@ -1383,7 +1382,7 @@
 }
 
 static bool checkVerifyPrefixes(const std::vector &VerifyPrefixes,
-DiagnosticsEngine *Diags) {
+DiagnosticsEngine &Diags) {
   bool Success = true;
   for (const auto &Prefix : VerifyPrefixes) {
 // Every prefix must start with a letter and contain only alphanumeric
@@ -1393,10 +1392,8 @@
 });
 if (BadChar != Prefix.end() || !isLetter(Prefix[0])) {
   Success = false;
-  if (Diags) {
-Diags->Report(diag::err_drv_invalid_value) << "-verify=" << Prefix;
-Diags->Report(diag::note_drv_verify_prefix_spelling);
-  }
+  Diags.Report(diag::err_drv_invalid_value) << "-verify=" << Prefix;
+  Diags.Report(diag::note_drv_verify_prefix_spelling);
 }
   }
   return Success;
@@ -1405,6 +1402,13 @@
 bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
 DiagnosticsEngine *Diags,
 bool DefaultDiagColor) {
+  Optional IgnoringDiags;
+  if (!Diags) {
+IgnoringDiags.emplace(new DiagnosticIDs(), new DiagnosticOptions(),
+  new IgnoringDiagConsumer());
+Diags = &*IgnoringDiags;
+  }
+
   bool Success = true;
 
   Opts.DiagnosticLogFile =
@@ -1439,10 +1443,9 @@
 Opts.setShowOverloads(Ovl_All);
   else {
 Success = false;
-if (Diags)
-  Diags->Report(diag::err_drv_invalid_value)
-  << Args.getLastArg(OPT_fshow_overloads_EQ)->getAsString(Args)
-  << ShowOverloads;
+Diags->Report(diag::err_drv_invalid_value)
+<< Args.getLastArg(OPT_fshow_overloads_EQ)->getAsString(Args)
+<< ShowOverloads;
   }
 
   StringRef ShowCategory =
@@ -1455,10 +1458,9 @@
 Opts.ShowCategories = 2;
   else {
 Success = false;
-if (Diags)
-  Diags->Report(diag::err_drv_invalid_value)
-  << Args.getLastArg(OPT_fdiagnostics_show_category)->getAsString(Args)
-  << ShowCategory;
+Diags->Report(diag::err_drv_invalid_value)
+<< Args.getLastArg(OPT_fdiagnostics_show_category)->getAsString(Args)
+<< ShowCategory;
   }
 
   StringRef Format =
@@ -1474,10 +1476,9 @@
 Opts.setFormat(DiagnosticOptions::Vi);
   else {
 Success = false;
-if (Diags)
-  Diags->Report(diag::err_drv_invalid_value)
-  << Args.getLastArg(OPT_fdiagnostics_format)->getAsString(Args)
-  << Format;
+Diags->Report(diag::err_drv_invalid_value)
+<< Args.getLastArg(OPT_fdiagnostics_format)->getAsString(Args)
+<< Format;
   }
 
   Opts.ShowSourceRanges = Args.hasArg(OPT_fdiagnostics_print_source_range_info);
@@ -1488,7 +1489,7 @@
 Opts.VerifyPrefixes.push_back("expected");
   // Keep VerifyPrefixes in its original order for the sake of diagnostics, and
   // then sort it to prepare for fast lookup using std::binary_search.
-  if (!checkVerifyPrefixes(Opts.VerifyPrefixes, Diags)) {
+  if (!checkVerifyPrefixes(Opts.VerifyPrefixes, *Diags)) {
 Opts.VerifyDiagnostics = false;
 Success = false;
   }
@@ -1497,7 +1498,7 @@
   DiagnosticLevelMask DiagMask = DiagnosticLevelMask::None;
   Success &= parseDiagnosticLevelMask("-verify-ignore-unexpected=",
 Args.getAllArgValues(OPT_verify_ignore_unexpected_EQ),
-Diags, DiagMask);
+*Diags, DiagMask);
   if (Args.hasArg(OPT_verify_ignore_unexpected))
 DiagMask = DiagnosticLevelMask::All;
   Opts.setVerifyIgnoreUnexpected(DiagMask);
@@ -1523,9 +1524,8 @@
 DiagnosticOptions::DefaultTabStop, Diags);
   if (Opts.TabStop == 0 || Opts.Ta

[PATCH] D94172: [clang][cli] NFC: Move parseSimpleArgs

2021-01-07 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG75d63630ebb1: [clang][cli] NFC: Move parseSimpleArgs 
(authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D94172?vs=314876&id=315109#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94172/new/

https://reviews.llvm.org/D94172

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1399,6 +1399,32 @@
   return Success;
 }
 
+bool CompilerInvocation::parseSimpleArgs(const ArgList &Args,
+ DiagnosticsEngine &Diags) {
+  bool Success = true;
+
+#define OPTION_WITH_MARSHALLING(   
\
+PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
+HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   
\
+DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, 
\
+MERGER, EXTRACTOR, TABLE_INDEX)
\
+  if ((FLAGS)&options::CC1Option) {
\
+this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);  
\
+if (IMPLIED_CHECK) 
\
+  this->KEYPATH = MERGER(this->KEYPATH, IMPLIED_VALUE);
\
+if (SHOULD_PARSE)  
\
+  if (auto MaybeValue =
\
+  NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags, Success)) 
\
+this->KEYPATH = MERGER(
\
+this->KEYPATH, static_castKEYPATH)>(*MaybeValue)); 
\
+  }
+
+#include "clang/Driver/Options.inc"
+#undef OPTION_WITH_MARSHALLING
+
+  return Success;
+}
+
 bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
 DiagnosticsEngine *Diags,
 bool DefaultDiagColor) {
@@ -2971,32 +2997,6 @@
   }
 }
 
-bool CompilerInvocation::parseSimpleArgs(const ArgList &Args,
- DiagnosticsEngine &Diags) {
-  bool Success = true;
-
-#define OPTION_WITH_MARSHALLING(   
\
-PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
-HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   
\
-DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, 
\
-MERGER, EXTRACTOR, TABLE_INDEX)
\
-  if ((FLAGS)&options::CC1Option) {
\
-this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);  
\
-if (IMPLIED_CHECK) 
\
-  this->KEYPATH = MERGER(this->KEYPATH, IMPLIED_VALUE);
\
-if (SHOULD_PARSE)  
\
-  if (auto MaybeValue = \
-NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags, Success))\
-this->KEYPATH = MERGER(
\
-this->KEYPATH, static_castKEYPATH)>(*MaybeValue)); 
\
-  }
-
-#include "clang/Driver/Options.inc"
-#undef OPTION_WITH_MARSHALLING
-
-  return Success;
-}
-
 bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
 ArrayRef CommandLineArgs,
 DiagnosticsEngine &Diags,


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1399,6 +1399,32 @@
   return Success;
 }
 
+bool CompilerInvocation::parseSimpleArgs(const ArgList &Args,
+ DiagnosticsEngine &Diags) {
+  bool Success = true;
+
+#define OPTION_WITH_MARSHALLING(   \
+PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
+HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   \
+DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, \
+MERGER, EXTRACTOR, TABLE_INDEX)\
+  if ((FLAGS)&options::CC1Option) {\
+this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);  \
+if (IMPLIED_CHECK) 

[PATCH] D89649: Fix __has_unique_object_representations with no_unique_address

2021-01-07 Thread Gabor Bencze via Phabricator via cfe-commits
gbencze added a comment.

Ping @rsmith


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89649/new/

https://reviews.llvm.org/D89649

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fcd1e35 - [clang][cli] NFC: Make parsing macro reusable

2021-01-07 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-01-07T14:25:48+01:00
New Revision: fcd1e35e4cc6887c3fb880126e60676458e60680

URL: 
https://github.com/llvm/llvm-project/commit/fcd1e35e4cc6887c3fb880126e60676458e60680
DIFF: 
https://github.com/llvm/llvm-project/commit/fcd1e35e4cc6887c3fb880126e60676458e60680.diff

LOG: [clang][cli] NFC: Make parsing macro reusable

This is necessary for a future patch, where we start using this macro in 
another function.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D93702

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 8b641aabd1af..348f5582bde2 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1399,32 +1399,42 @@ static bool checkVerifyPrefixes(const 
std::vector &VerifyPrefixes,
   return Success;
 }
 
-bool CompilerInvocation::parseSimpleArgs(const ArgList &Args,
- DiagnosticsEngine &Diags) {
-  bool Success = true;
-
-#define OPTION_WITH_MARSHALLING(   
\
-PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
-HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   
\
-DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, 
\
-MERGER, EXTRACTOR, TABLE_INDEX)
\
+#define PARSE_OPTION_WITH_MARSHALLING(ARGS, DIAGS, SUCCESS, ID, FLAGS, PARAM,  
\
+  SHOULD_PARSE, KEYPATH, DEFAULT_VALUE,
\
+  IMPLIED_CHECK, IMPLIED_VALUE,
\
+  NORMALIZER, MERGER, TABLE_INDEX) 
\
   if ((FLAGS)&options::CC1Option) {
\
 this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);  
\
 if (IMPLIED_CHECK) 
\
   this->KEYPATH = MERGER(this->KEYPATH, IMPLIED_VALUE);
\
 if (SHOULD_PARSE)  
\
   if (auto MaybeValue =
\
-  NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags, Success)) 
\
+  NORMALIZER(OPT_##ID, TABLE_INDEX, ARGS, DIAGS, SUCCESS)) 
\
 this->KEYPATH = MERGER(
\
 this->KEYPATH, static_castKEYPATH)>(*MaybeValue)); 
\
   }
 
+bool CompilerInvocation::parseSimpleArgs(const ArgList &Args,
+ DiagnosticsEngine &Diags) {
+  bool Success = true;
+
+#define OPTION_WITH_MARSHALLING(   
\
+PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
+HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   
\
+DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, 
\
+MERGER, EXTRACTOR, TABLE_INDEX)
\
+  PARSE_OPTION_WITH_MARSHALLING(Args, Diags, Success, ID, FLAGS, PARAM,
\
+SHOULD_PARSE, KEYPATH, DEFAULT_VALUE,  
\
+IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER,  
\
+MERGER, TABLE_INDEX)
 #include "clang/Driver/Options.inc"
 #undef OPTION_WITH_MARSHALLING
 
   return Success;
 }
 
+#undef PARSE_OPTION_WITH_MARSHALLING
+
 bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
 DiagnosticsEngine *Diags,
 bool DefaultDiagColor) {



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93702: [clang][cli] NFC: Make parsing macro reusable

2021-01-07 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfcd1e35e4cc6: [clang][cli] NFC: Make parsing macro reusable 
(authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D93702?vs=314877&id=315111#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93702/new/

https://reviews.llvm.org/D93702

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1399,32 +1399,42 @@
   return Success;
 }
 
-bool CompilerInvocation::parseSimpleArgs(const ArgList &Args,
- DiagnosticsEngine &Diags) {
-  bool Success = true;
-
-#define OPTION_WITH_MARSHALLING(   
\
-PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
-HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   
\
-DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, 
\
-MERGER, EXTRACTOR, TABLE_INDEX)
\
+#define PARSE_OPTION_WITH_MARSHALLING(ARGS, DIAGS, SUCCESS, ID, FLAGS, PARAM,  
\
+  SHOULD_PARSE, KEYPATH, DEFAULT_VALUE,
\
+  IMPLIED_CHECK, IMPLIED_VALUE,
\
+  NORMALIZER, MERGER, TABLE_INDEX) 
\
   if ((FLAGS)&options::CC1Option) {
\
 this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);  
\
 if (IMPLIED_CHECK) 
\
   this->KEYPATH = MERGER(this->KEYPATH, IMPLIED_VALUE);
\
 if (SHOULD_PARSE)  
\
   if (auto MaybeValue =
\
-  NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags, Success)) 
\
+  NORMALIZER(OPT_##ID, TABLE_INDEX, ARGS, DIAGS, SUCCESS)) 
\
 this->KEYPATH = MERGER(
\
 this->KEYPATH, static_castKEYPATH)>(*MaybeValue)); 
\
   }
 
+bool CompilerInvocation::parseSimpleArgs(const ArgList &Args,
+ DiagnosticsEngine &Diags) {
+  bool Success = true;
+
+#define OPTION_WITH_MARSHALLING(   
\
+PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
+HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   
\
+DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, 
\
+MERGER, EXTRACTOR, TABLE_INDEX)
\
+  PARSE_OPTION_WITH_MARSHALLING(Args, Diags, Success, ID, FLAGS, PARAM,
\
+SHOULD_PARSE, KEYPATH, DEFAULT_VALUE,  
\
+IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER,  
\
+MERGER, TABLE_INDEX)
 #include "clang/Driver/Options.inc"
 #undef OPTION_WITH_MARSHALLING
 
   return Success;
 }
 
+#undef PARSE_OPTION_WITH_MARSHALLING
+
 bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
 DiagnosticsEngine *Diags,
 bool DefaultDiagColor) {


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1399,32 +1399,42 @@
   return Success;
 }
 
-bool CompilerInvocation::parseSimpleArgs(const ArgList &Args,
- DiagnosticsEngine &Diags) {
-  bool Success = true;
-
-#define OPTION_WITH_MARSHALLING(   \
-PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
-HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   \
-DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, \
-MERGER, EXTRACTOR, TABLE_INDEX)\
+#define PARSE_OPTION_WITH_MARSHALLING(ARGS, DIAGS, SUCCESS, ID, FLAGS, PARAM,  \
+  SHOULD_PARSE, KEYPATH, DEFAULT_VALUE,\
+  IMPLIED_CHECK, IMPLIED_VALUE,\
+  NORMALIZER, MERGER, TABLE_INDEX) \
   if ((FLAGS)&options::CC1Option) {\
 this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);   

[PATCH] D94231: [clang][Sema] Compare SourceLocations directly [NFCI]

2021-01-07 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki created this revision.
miyuki added reviewers: dexonsmith, aprantl, rsmith.
miyuki requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The ordered comparison operators are defined for the SourceLocation
class, so SourceLocation objects can be compared directly. There is no
need to extract the internal representation for comparison.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94231

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaStmt.cpp


Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -672,8 +672,7 @@
 return true;
 
   if (lhs.first == rhs.first &&
-  lhs.second->getCaseLoc().getRawEncoding()
-   < rhs.second->getCaseLoc().getRawEncoding())
+  lhs.second->getCaseLoc() < rhs.second->getCaseLoc())
 return true;
   return false;
 }
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -436,9 +436,7 @@
  Res != ResEnd; ++Res) {
   if (isa(*Res) || isa(*Res) ||
   (AllowDeducedTemplate && getAsTypeTemplateDecl(*Res))) {
-if (!IIDecl ||
-(*Res)->getLocation().getRawEncoding() <
-  IIDecl->getLocation().getRawEncoding())
+if (!IIDecl || (*Res)->getLocation() < IIDecl->getLocation())
   IIDecl = *Res;
   }
 }


Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -672,8 +672,7 @@
 return true;
 
   if (lhs.first == rhs.first &&
-  lhs.second->getCaseLoc().getRawEncoding()
-   < rhs.second->getCaseLoc().getRawEncoding())
+  lhs.second->getCaseLoc() < rhs.second->getCaseLoc())
 return true;
   return false;
 }
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -436,9 +436,7 @@
  Res != ResEnd; ++Res) {
   if (isa(*Res) || isa(*Res) ||
   (AllowDeducedTemplate && getAsTypeTemplateDecl(*Res))) {
-if (!IIDecl ||
-(*Res)->getLocation().getRawEncoding() <
-  IIDecl->getLocation().getRawEncoding())
+if (!IIDecl || (*Res)->getLocation() < IIDecl->getLocation())
   IIDecl = *Res;
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94224: [clang][AST] Get rid of an alignment hack in DeclObjC.h [NFCI]

2021-01-07 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki updated this revision to Diff 315113.
miyuki added a comment.

Fixed formatting.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94224/new/

https://reviews.llvm.org/D94224

Files:
  clang/include/clang/AST/DeclObjC.h
  clang/lib/AST/DeclObjC.cpp


Index: clang/lib/AST/DeclObjC.cpp
===
--- clang/lib/AST/DeclObjC.cpp
+++ clang/lib/AST/DeclObjC.cpp
@@ -1461,9 +1461,7 @@
 ObjCTypeParamList::ObjCTypeParamList(SourceLocation lAngleLoc,
  ArrayRef typeParams,
  SourceLocation rAngleLoc)
-: NumParams(typeParams.size()) {
-  Brackets.Begin = lAngleLoc.getRawEncoding();
-  Brackets.End = rAngleLoc.getRawEncoding();
+: Brackets(lAngleLoc, rAngleLoc), NumParams(typeParams.size()) {
   std::copy(typeParams.begin(), typeParams.end(), begin());
 }
 
Index: clang/include/clang/AST/DeclObjC.h
===
--- clang/include/clang/AST/DeclObjC.h
+++ clang/include/clang/AST/DeclObjC.h
@@ -656,20 +656,8 @@
 /// \endcode
 class ObjCTypeParamList final
 : private llvm::TrailingObjects {
-  /// Stores the components of a SourceRange as a POD.
-  struct PODSourceRange {
-unsigned Begin;
-unsigned End;
-  };
-
-  union {
-/// Location of the left and right angle brackets.
-PODSourceRange Brackets;
-
-// Used only for alignment.
-ObjCTypeParamDecl *AlignmentHack;
-  };
-
+  /// Location of the left and right angle brackets.
+  alignas(ObjCTypeParamDecl *) SourceRange Brackets;
   /// The number of parameters in the list, which are tail-allocated.
   unsigned NumParams;
 
@@ -717,17 +705,11 @@
 return *(end() - 1);
   }
 
-  SourceLocation getLAngleLoc() const {
-return SourceLocation::getFromRawEncoding(Brackets.Begin);
-  }
+  SourceLocation getLAngleLoc() const { return Brackets.getBegin(); }
 
-  SourceLocation getRAngleLoc() const {
-return SourceLocation::getFromRawEncoding(Brackets.End);
-  }
+  SourceLocation getRAngleLoc() const { return Brackets.getEnd(); }
 
-  SourceRange getSourceRange() const {
-return SourceRange(getLAngleLoc(), getRAngleLoc());
-  }
+  SourceRange getSourceRange() const { return Brackets; }
 
   /// Gather the default set of type arguments to be substituted for
   /// these type parameters when dealing with an unspecialized type.


Index: clang/lib/AST/DeclObjC.cpp
===
--- clang/lib/AST/DeclObjC.cpp
+++ clang/lib/AST/DeclObjC.cpp
@@ -1461,9 +1461,7 @@
 ObjCTypeParamList::ObjCTypeParamList(SourceLocation lAngleLoc,
  ArrayRef typeParams,
  SourceLocation rAngleLoc)
-: NumParams(typeParams.size()) {
-  Brackets.Begin = lAngleLoc.getRawEncoding();
-  Brackets.End = rAngleLoc.getRawEncoding();
+: Brackets(lAngleLoc, rAngleLoc), NumParams(typeParams.size()) {
   std::copy(typeParams.begin(), typeParams.end(), begin());
 }
 
Index: clang/include/clang/AST/DeclObjC.h
===
--- clang/include/clang/AST/DeclObjC.h
+++ clang/include/clang/AST/DeclObjC.h
@@ -656,20 +656,8 @@
 /// \endcode
 class ObjCTypeParamList final
 : private llvm::TrailingObjects {
-  /// Stores the components of a SourceRange as a POD.
-  struct PODSourceRange {
-unsigned Begin;
-unsigned End;
-  };
-
-  union {
-/// Location of the left and right angle brackets.
-PODSourceRange Brackets;
-
-// Used only for alignment.
-ObjCTypeParamDecl *AlignmentHack;
-  };
-
+  /// Location of the left and right angle brackets.
+  alignas(ObjCTypeParamDecl *) SourceRange Brackets;
   /// The number of parameters in the list, which are tail-allocated.
   unsigned NumParams;
 
@@ -717,17 +705,11 @@
 return *(end() - 1);
   }
 
-  SourceLocation getLAngleLoc() const {
-return SourceLocation::getFromRawEncoding(Brackets.Begin);
-  }
+  SourceLocation getLAngleLoc() const { return Brackets.getBegin(); }
 
-  SourceLocation getRAngleLoc() const {
-return SourceLocation::getFromRawEncoding(Brackets.End);
-  }
+  SourceLocation getRAngleLoc() const { return Brackets.getEnd(); }
 
-  SourceRange getSourceRange() const {
-return SourceRange(getLAngleLoc(), getRAngleLoc());
-  }
+  SourceRange getSourceRange() const { return Brackets; }
 
   /// Gather the default set of type arguments to be substituted for
   /// these type parameters when dealing with an unspecialized type.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84673: [clang][cli] Port DiagnosticOpts to new option parsing system

2021-01-07 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 315115.
jansvoboda11 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84673/new/

https://reviews.llvm.org/D84673

Files:
  clang/include/clang/Basic/DiagnosticOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -66,6 +66,7 @@
   static constexpr const char *MacroName = "OPTION_WITH_MARSHALLING";
   const Record &R;
   bool ShouldAlwaysEmit;
+  StringRef MacroPrefix;
   StringRef KeyPath;
   StringRef DefaultValue;
   StringRef NormalizedValuesScope;
@@ -100,6 +101,10 @@
 
   MarshallingInfo(const Record &R) : R(R) {}
 
+  std::string getMacroName() const {
+return (MacroPrefix + MarshallingInfo::MacroName).str();
+  }
+
   void emit(raw_ostream &OS) const {
 write_cstring(OS, StringRef(getOptionSpelling(R)));
 OS << ", ";
@@ -163,6 +168,7 @@
   MarshallingInfo Ret(R);
 
   Ret.ShouldAlwaysEmit = R.getValueAsBit("ShouldAlwaysEmit");
+  Ret.MacroPrefix = R.getValueAsString("MacroPrefix");
   Ret.KeyPath = R.getValueAsString("KeyPath");
   Ret.DefaultValue = R.getValueAsString("DefaultValue");
   Ret.NormalizedValuesScope = R.getValueAsString("NormalizedValuesScope");
@@ -424,13 +430,13 @@
 MarshallingInfos.push_back(createMarshallingInfo(*R));
 
   for (const auto &MI : MarshallingInfos) {
-OS << "#ifdef " << MarshallingInfo::MacroName << "\n";
-OS << MarshallingInfo::MacroName << "(";
+OS << "#ifdef " << MI.getMacroName() << "\n";
+OS << MI.getMacroName() << "(";
 WriteOptRecordFields(OS, MI.R);
 OS << ", ";
 MI.emit(OS);
 OS << ")\n";
-OS << "#endif // " << MarshallingInfo::MacroName << "\n";
+OS << "#endif // " << MI.getMacroName() << "\n";
   }
 
   OS << "\n";
Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -97,6 +97,7 @@
   OptionGroup Group = ?;
   Option Alias = ?;
   list AliasArgs = [];
+  code MacroPrefix = "";
   code KeyPath = ?;
   code DefaultValue = ?;
   code ImpliedValue = ?;
Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -680,4 +680,19 @@
   ASSERT_THAT(GeneratedArgs, Contains(StrEq("-cl-mad-enable")));
   ASSERT_THAT(GeneratedArgs, Contains(StrEq("-menable-unsafe-fp-math")));
 }
+
+// Diagnostic option.
+
+TEST_F(CommandLineTest, DiagnosticOptionPresent) {
+  const char *Args[] = {"-verify=xyz"};
+
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
+
+  ASSERT_EQ(Invocation.getDiagnosticOpts().VerifyPrefixes,
+std::vector({"xyz"}));
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs, ContainsN(StrEq("-verify=xyz"), 1));
+}
 } // anonymous namespace
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -388,7 +388,6 @@
 DiagnosticsEngine &Diags,
 const InputArgList &Args) {
   LangOptions &LangOpts = *Invocation.getLangOpts();
-  DiagnosticOptions &DiagOpts = Invocation.getDiagnosticOpts();
   CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts();
   TargetOptions &TargetOpts = Invocation.getTargetOpts();
   FrontendOptions &FrontendOpts = Invocation.getFrontendOpts();
@@ -402,8 +401,6 @@
   LangOpts.SpeculativeLoadHardening = CodeGenOpts.SpeculativeLoadHardening;
   LangOpts.CurrentModule = LangOpts.ModuleName;
 
-  llvm::sys::Process::UseANSIEscapeCodes(DiagOpts.UseANSIEscapeCodes);
-
   llvm::Triple T(TargetOpts.Triple);
   llvm::Triple::ArchType Arch = T.getArch();
 
@@ -1404,14 +1401,13 @@
   IMPLIED_CHECK, IMPLIED_VALUE,\
   NORMALIZER, MERGER, TABLE_INDEX) \
   if ((FLAGS)&options::CC1Option) {\
-this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);  \
+KEYPATH = MERGER(KEYPATH, DEFAULT_VALUE);  \
 if (IMPLIED_CHECK) \
-  this->KEYPATH = MERGER(this->KEYPATH, IMPLIED_VALUE);\
+  KEYPATH = MERGER(KEYPATH, IMPLIED_VALUE);  

[PATCH] D93978: [clangd] DefineOutline doesn't require implementation file being saved

2021-01-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks, this looks much better!




Comment at: clang-tools-extra/clangd/ClangdServer.cpp:434
+tweakSelection(const Range &Sel, const InputsAndAST &AST,
+   llvm::vfs::FileSystem *VFS = nullptr) {
   auto Begin = positionToOffset(AST.Inputs.Contents, Sel.start);

nit: pass nullptr explicitly rather than as a default arg.



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:1462
+TUScheduler::getAllFileContentsFS() const {
+  // FIXME: Copying the files is needlessly expensive and grows according to 
how
+  // many files are being tracked, it may be worthwhile to create a Filesystem

nit: say why it's needless: usually 0-1 buffer is ever read.



Comment at: clang-tools-extra/clangd/TUScheduler.h:239
 
   /// Returns a snapshot of all file buffer contents, per last update().
   llvm::StringMap getAllFileContents() const;

FIXME to remove this?



Comment at: clang-tools-extra/clangd/TUScheduler.h:243
+  /// Returns a Filesystem snapshot of all file buffer contents, per last
+  /// update().
+  llvm::IntrusiveRefCntPtr getAllFileContentsFS() const;

I do think this is the best option, but just wanted to spell out the 
implications to make sure we're on the same page...

- edits that occur while the action is queued will not be seen. (This is bad 
for the use cases we know of, but minor)
- the optimization of deferring buffer copies (hinted to in the implementation) 
would actually break the contract, as you may see a *newer* version of the file
- we don't have to worry about locking inside TUScheduler to grab the buffers



Comment at: clang-tools-extra/clangd/TUScheduler.h:246
+
+  /// Returns a Snapshot of all file buffer contents in a Filesystem overlayed
+  /// ontop of \p Base.

there's no need for both of these to be methods on TUScheduler, pick one?

(I'd lean towards exposing this one only as it simplifies callers and has a 
better name)



Comment at: clang-tools-extra/clangd/TUScheduler.h:248
+  /// ontop of \p Base.
+  llvm::IntrusiveRefCntPtr overlayFileContents(
+  llvm::IntrusiveRefCntPtr Base) const;

nit: take const TFS& as arg, as this function is designed for caller 
convenience and that's always how it'll be used



Comment at: clang-tools-extra/clangd/TUScheduler.h:248
+  /// ontop of \p Base.
+  llvm::IntrusiveRefCntPtr overlayFileContents(
+  llvm::IntrusiveRefCntPtr Base) const;

sammccall wrote:
> nit: take const TFS& as arg, as this function is designed for caller 
> convenience and that's always how it'll be used
nit: return `unique_ptr` (which can implicitly convert)



Comment at: clang-tools-extra/clangd/refactor/Tweak.h:53
+  unsigned RangeEnd, SelectionTree ASTSelection,
+  llvm::vfs::FileSystem *VFS);
 /// The text of the active document.

VFS is a public field, and optional, so we could omit it from the constructor 
and assign it explicitly instead.



Comment at: clang-tools-extra/clangd/refactor/Tweak.h:69
 SelectionTree ASTSelection;
+/// The file system that should be queried for cross file tweaks.
+llvm::vfs::FileSystem *VFS = nullptr;

let's be a bit more explicit here.

```
/// File system used to access source code (for cross-file tweaks).
/// This overlays the "dirty" contents of files open in the editor, which (in 
case of headers)
/// may not match the saved contents used for building the AST.
```



Comment at: clang-tools-extra/clangd/refactor/Tweak.h:69
 SelectionTree ASTSelection;
+/// The file system that should be queried for cross file tweaks.
+llvm::vfs::FileSystem *VFS = nullptr;

sammccall wrote:
> let's be a bit more explicit here.
> 
> ```
> /// File system used to access source code (for cross-file tweaks).
> /// This overlays the "dirty" contents of files open in the editor, which (in 
> case of headers)
> /// may not match the saved contents used for building the AST.
> ```
mention that this is only populated for apply(), not prepare()?



Comment at: clang-tools-extra/clangd/refactor/Tweak.h:70
+/// The file system that should be queried for cross file tweaks.
+llvm::vfs::FileSystem *VFS = nullptr;
 // FIXME: provide a way to get sources and ASTs for other files.

nit: FS rather than VFS
(the "V" is already implied by the presence of the object)



Comment at: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp:406
 
-auto CCFile = getSourceFile(*MainFileName, Sel);
+// If we have a Filesystem attached to the Selection, use that, otherwise
+// fallback to the SourceManagar Filesystem.

It's not actually optional for apply, right? We shouldn'

[PATCH] D84673: [clang][cli] Port DiagnosticOpts to new option parsing system

2021-01-07 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 315117.
jansvoboda11 added a comment.

Move the "DiagnosticOpts->" prefix from TableGen definitions to macros


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84673/new/

https://reviews.llvm.org/D84673

Files:
  clang/include/clang/Basic/DiagnosticOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -66,6 +66,7 @@
   static constexpr const char *MacroName = "OPTION_WITH_MARSHALLING";
   const Record &R;
   bool ShouldAlwaysEmit;
+  StringRef MacroPrefix;
   StringRef KeyPath;
   StringRef DefaultValue;
   StringRef NormalizedValuesScope;
@@ -100,6 +101,10 @@
 
   MarshallingInfo(const Record &R) : R(R) {}
 
+  std::string getMacroName() const {
+return (MacroPrefix + MarshallingInfo::MacroName).str();
+  }
+
   void emit(raw_ostream &OS) const {
 write_cstring(OS, StringRef(getOptionSpelling(R)));
 OS << ", ";
@@ -163,6 +168,7 @@
   MarshallingInfo Ret(R);
 
   Ret.ShouldAlwaysEmit = R.getValueAsBit("ShouldAlwaysEmit");
+  Ret.MacroPrefix = R.getValueAsString("MacroPrefix");
   Ret.KeyPath = R.getValueAsString("KeyPath");
   Ret.DefaultValue = R.getValueAsString("DefaultValue");
   Ret.NormalizedValuesScope = R.getValueAsString("NormalizedValuesScope");
@@ -424,13 +430,13 @@
 MarshallingInfos.push_back(createMarshallingInfo(*R));
 
   for (const auto &MI : MarshallingInfos) {
-OS << "#ifdef " << MarshallingInfo::MacroName << "\n";
-OS << MarshallingInfo::MacroName << "(";
+OS << "#ifdef " << MI.getMacroName() << "\n";
+OS << MI.getMacroName() << "(";
 WriteOptRecordFields(OS, MI.R);
 OS << ", ";
 MI.emit(OS);
 OS << ")\n";
-OS << "#endif // " << MarshallingInfo::MacroName << "\n";
+OS << "#endif // " << MI.getMacroName() << "\n";
   }
 
   OS << "\n";
Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -97,6 +97,7 @@
   OptionGroup Group = ?;
   Option Alias = ?;
   list AliasArgs = [];
+  code MacroPrefix = "";
   code KeyPath = ?;
   code DefaultValue = ?;
   code ImpliedValue = ?;
Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -680,4 +680,19 @@
   ASSERT_THAT(GeneratedArgs, Contains(StrEq("-cl-mad-enable")));
   ASSERT_THAT(GeneratedArgs, Contains(StrEq("-menable-unsafe-fp-math")));
 }
+
+// Diagnostic option.
+
+TEST_F(CommandLineTest, DiagnosticOptionPresent) {
+  const char *Args[] = {"-verify=xyz"};
+
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
+
+  ASSERT_EQ(Invocation.getDiagnosticOpts().VerifyPrefixes,
+std::vector({"xyz"}));
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs, ContainsN(StrEq("-verify=xyz"), 1));
+}
 } // anonymous namespace
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -388,7 +388,6 @@
 DiagnosticsEngine &Diags,
 const InputArgList &Args) {
   LangOptions &LangOpts = *Invocation.getLangOpts();
-  DiagnosticOptions &DiagOpts = Invocation.getDiagnosticOpts();
   CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts();
   TargetOptions &TargetOpts = Invocation.getTargetOpts();
   FrontendOptions &FrontendOpts = Invocation.getFrontendOpts();
@@ -402,8 +401,6 @@
   LangOpts.SpeculativeLoadHardening = CodeGenOpts.SpeculativeLoadHardening;
   LangOpts.CurrentModule = LangOpts.ModuleName;
 
-  llvm::sys::Process::UseANSIEscapeCodes(DiagOpts.UseANSIEscapeCodes);
-
   llvm::Triple T(TargetOpts.Triple);
   llvm::Triple::ArchType Arch = T.getArch();
 
@@ -1404,14 +1401,13 @@
   IMPLIED_CHECK, IMPLIED_VALUE,\
   NORMALIZER, MERGER, TABLE_INDEX) \
   if ((FLAGS)&options::CC1Option) {\
-this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);  \
+KEYPATH = MERGER(KEYPATH, DEFAULT_VALUE);  \
 if (IMPLIED_CHECK) \
-  this->KEYPATH = MERGER(this->KEYPATH, IMPLIED_VALUE);

[PATCH] D94067: [clang][ASTImporter] Fix a possible assertion failure `NeedsInjectedClassNameType(Decl)'.

2021-01-07 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked an inline comment as done.
balazske added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:2901
+  // Skip the declaration if injected type is already set.
+  if (isa(RI->getTypeForDecl()))
+continue;

shafik wrote:
> balazske wrote:
> > shafik wrote:
> > > Is this to fix the bug or is this for efficiency sake?
> > This is not needed for the fix, it was used in the first version of the fix 
> > (still only for efficiency). In the current form this looks like unrelated 
> > change (the old fix included other code at the same location) so I am not 
> > against removing this part (but add it in a separate change).
> Yes, please if we can split the two changes that would be great.
I checked if this "skip" is needed, but it turned out (at least on this test 
file) that in all cases  (1060 total) the `InjectedClassNameType` is already 
there, so this loop would do nothing useful if the skip is added. And the same 
for the code in `if (Injected)` branch, the type is already 
`InjectedClassNameType`. I do not plan to make a new change for this issue, but 
it needs investigation to check if this change of the type is needed at all (if 
not, and why not, if yes, is the "skip" useful). Probably a FIXME could be 
added here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94067/new/

https://reviews.llvm.org/D94067

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89031: [SVE] Add support to vectorize_width loop pragma for scalable vectors

2021-01-07 Thread David Sherwood via Phabricator via cfe-commits
david-arm updated this revision to Diff 315121.
david-arm added a comment.

- Updated documentation as per review comments.
- Fixed an issue with using value->prettyPrint on a null ptr.
- Reworked the code that sets vectorize.enable.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89031/new/

https://reviews.llvm.org/D89031

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/AST/AttrImpl.cpp
  clang/lib/CodeGen/CGLoopInfo.cpp
  clang/lib/CodeGen/CGLoopInfo.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/AST/ast-print-pragmas.cpp
  clang/test/CodeGenCXX/pragma-loop-pr27643.cpp
  clang/test/CodeGenCXX/pragma-loop.cpp
  clang/test/Parser/pragma-loop.cpp

Index: clang/test/Parser/pragma-loop.cpp
===
--- clang/test/Parser/pragma-loop.cpp
+++ clang/test/Parser/pragma-loop.cpp
@@ -60,7 +60,8 @@
 
 template 
 void test_nontype_template_badarg(int *List, int Length) {
-  /* expected-error {{use of undeclared identifier 'Vec'}} */ #pragma clang loop vectorize_width(Vec) interleave_count(I)
+  /* expected-error {{use of undeclared identifier 'Vec'}} */ #pragma clang loop vectorize_width(Vec) interleave_count(I) /*
+ expected-note {{vectorize_width loop hint malformed; use vectorize_width(X, fixed) or vectorize_width(X, scalable) where X is an integer, or vectorize_width('fixed' or 'scalable')}} */
   /* expected-error {{use of undeclared identifier 'Int'}} */ #pragma clang loop vectorize_width(V) interleave_count(Int)
   for (int i = 0; i < Length; i++) {
 List[i] = i;
@@ -189,12 +190,15 @@
 /* expected-warning {{extra tokens at end of '#pragma clang loop'}} */ #pragma clang loop vectorize_width(1 +) 1
 /* expected-warning {{extra tokens at end of '#pragma clang loop'}} */ #pragma clang loop vectorize_width(1) +1
 const int VV = 4;
-/* expected-error {{expected expression}} */ #pragma clang loop vectorize_width(VV +/ 2)
-/* expected-error {{use of undeclared identifier 'undefined'}} */ #pragma clang loop vectorize_width(VV+undefined)
+/* expected-error {{expected expression}} */ #pragma clang loop vectorize_width(VV +/ 2) /*
+   expected-note {{vectorize_width loop hint malformed; use vectorize_width(X, fixed) or vectorize_width(X, scalable) where X is an integer, or vectorize_width('fixed' or 'scalable')}} */
+/* expected-error {{use of undeclared identifier 'undefined'}} */ #pragma clang loop vectorize_width(VV+undefined) /*
+   expected-note {{vectorize_width loop hint malformed; use vectorize_width(X, fixed) or vectorize_width(X, scalable) where X is an integer, or vectorize_width('fixed' or 'scalable')}} */
 /* expected-error {{expected ')'}} */ #pragma clang loop vectorize_width(1+(^*/2 * ()
 /* expected-warning {{extra tokens at end of '#pragma clang loop' - ignored}} */ #pragma clang loop vectorize_width(1+(-0[0]))
 
-/* expected-error {{use of undeclared identifier 'badvalue'}} */ #pragma clang loop vectorize_width(badvalue)
+/* expected-error {{use of undeclared identifier 'badvalue'}} */ #pragma clang loop vectorize_width(badvalue) /*
+   expected-note {{vectorize_width loop hint malformed; use vectorize_width(X, fixed) or vectorize_width(X, scalable) where X is an integer, or vectorize_width('fixed' or 'scalable')}} */
 /* expected-error {{use of undeclared identifier 'badvalue'}} */ #pragma clang loop interleave_count(badvalue)
 /* expected-error {{use of undeclared identifier 'badvalue'}} */ #pragma clang loop unroll_count(badvalue)
   while (i-6 < Length) {
@@ -215,7 +219,7 @@
 /* expected-error {{invalid argument; expected 'enable', 'assume_safety' or 'disable'}} */ #pragma clang loop interleave(*)
 /* expected-error {{invalid argument; expected 'enable', 'full' or 'disable'}} */ #pragma clang loop unroll(=)
 /* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop distribute(+)
-/* expected-error {{type name requires a specifier or qualifier}} expected-error {{expected expression}} */ #pragma clang loop vectorize_width(^)
+/* expected-error {{type name requires a specifier or qualifier}} expected-error {{expected expression}} */ #pragma clang loop vectorize_width(^) /* expected-note {{vectorize_width loop hint malformed; use vectorize_width(X, fixed) or vectorize_width(X, scalable) where X is an integer, or vectorize_width('fixed' or 'scalable')}} */
 /* expected-error {{expected expression}} expected-error {{expected expression}} */ #pragma clang loop interleave_count(/)
 /* expected-error {{expected expression}} expected-error {{expected expression}} */ #pragma clang loop unroll_count(==)
   while (i-8 < Length) {
Index: clang/test/CodeGenCXX/pragma-loop.cpp
===
--- clang/test/CodeGenCXX/pragma-loop.cpp
+++ clang/test/CodeGenCXX/pragma-loop.cpp
@@ -158,51 +158,97 @@
   for_template_constant_ex

[PATCH] D87702: [Frontend] Add pragma align natural and sort out pragma pack stack effect

2021-01-07 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 315126.
Xiangling_L marked 5 inline comments as done.
Xiangling_L added a comment.

Addressed the comments;
Rebased the patch on latest master;


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87702/new/

https://reviews.llvm.org/D87702

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Driver/aix-pragma-pack.c
  clang/test/Layout/aix-double-struct-member.cpp
  clang/test/Layout/aix-power-natural-interaction.cpp
  clang/test/PCH/aix-pragma-pack.c
  clang/test/Sema/aix-pragma-pack-and-align.c

Index: clang/test/Sema/aix-pragma-pack-and-align.c
===
--- /dev/null
+++ clang/test/Sema/aix-pragma-pack-and-align.c
@@ -0,0 +1,231 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fxl-pragma-pack -verify -fsyntax-only -x c++ %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fxl-pragma-pack -verify -fsyntax-only -x c++ %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+#pragma align(natural)
+#pragma pack(4)
+#pragma pack(2)
+struct A {
+  int i;
+  double d;
+};
+
+int a = sizeof(A);
+#pragma pack()
+#pragma pack(show) // expected-warning {{value of #pragma pack(show) == 4}}
+#pragma pack(pop)
+#pragma pack(show) // expected-warning {{value of #pragma pack(show) == 8}}
+struct B {
+  int i;
+  double d;
+};
+#pragma align(reset)
+
+int b = sizeof(B);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct test1::A
+// CHECK-NEXT:  0 |   int i
+// CHECK-NEXT:  4 |   double d
+// CHECK-NEXT:| [sizeof=12, dsize=12, align=2, preferredalign=2,
+// CHECK-NEXT:|  nvsize=12, nvalign=2, preferrednvalign=2]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct test1::B
+// CHECK-NEXT:  0 |   int i
+// CHECK-NEXT:  8 |   double d
+// CHECK-NEXT:| [sizeof=16, dsize=16, align=4, preferredalign=8,
+// CHECK-NEXT:|  nvsize=16, nvalign=4, preferrednvalign=8]
+
+} // namespace test1
+
+namespace test2 {
+#pragma align(natural)
+#pragma pack(2)
+struct A {
+  int i;
+  double d;
+};
+
+int a = sizeof(A);
+#pragma align(reset)
+
+struct B {
+  int i;
+  double d;
+};
+
+int b = sizeof(B);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct test2::A
+// CHECK-NEXT:  0 |   int i
+// CHECK-NEXT:  4 |   double d
+// CHECK-NEXT:| [sizeof=12, dsize=12, align=2, preferredalign=2,
+// CHECK-NEXT:|  nvsize=12, nvalign=2, preferrednvalign=2]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct test2::B
+// CHECK-NEXT:  0 |   int i
+// CHECK-NEXT:  4 |   double d
+// CHECK-NEXT:| [sizeof=12, dsize=12, align=4, preferredalign=4,
+// CHECK-NEXT:|  nvsize=12, nvalign=4, preferrednvalign=4]
+
+} // namespace test2
+
+namespace test3 {
+#pragma pack(2)
+#pragma align(natural)
+struct A {
+  double d;
+};
+#pragma align(reset)
+#pragma pack(pop)
+
+int a = sizeof(A);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct test3::A
+// CHECK-NEXT:  0 |   double d
+// CHECK-NEXT:| [sizeof=8, dsize=8, align=4, preferredalign=8,
+// CHECK-NEXT:|  nvsize=8, nvalign=4, preferrednvalign=8]
+
+} // namespace test3
+
+namespace test4 {
+#pragma pack(2)
+#pragma align(natural)
+#pragma pack(pop)
+
+struct A {
+  int i;
+  double d;
+} a;
+#pragma align(reset)
+#pragma pack(pop)
+
+int i = sizeof(A);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct test4::A
+// CHECK-NEXT:  0 |   int i
+// CHECK-NEXT:  8 |   double d
+// CHECK-NEXT:| [sizeof=16, dsize=16, align=4, preferredalign=8,
+// CHECK-NEXT:|  nvsize=16, nvalign=4, preferrednvalign=8]
+
+} // namespace test4
+
+namespace test5 {
+#pragma align(power)
+#pragma align(natural)
+#pragma pack(2)
+#pragma align(reset)
+struct A {
+  int i;
+  double d;
+};
+#pragma align(reset)
+
+int a = sizeof(A);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct test5::A
+// CHECK-NEXT:  0 |   int i
+// CHECK-NEXT:  4 |   double d
+// CHECK-NEXT:| [sizeof=12, dsize=12, align=4, 

[PATCH] D84673: [clang][cli] Port DiagnosticOpts to new option parsing system

2021-01-07 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 315131.
jansvoboda11 added a comment.

Don't create diagnostics_fixit_info via BoolXxxOption to keep the distinstion 
of Group and Group


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84673/new/

https://reviews.llvm.org/D84673

Files:
  clang/include/clang/Basic/DiagnosticOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -66,6 +66,7 @@
   static constexpr const char *MacroName = "OPTION_WITH_MARSHALLING";
   const Record &R;
   bool ShouldAlwaysEmit;
+  StringRef MacroPrefix;
   StringRef KeyPath;
   StringRef DefaultValue;
   StringRef NormalizedValuesScope;
@@ -100,6 +101,10 @@
 
   MarshallingInfo(const Record &R) : R(R) {}
 
+  std::string getMacroName() const {
+return (MacroPrefix + MarshallingInfo::MacroName).str();
+  }
+
   void emit(raw_ostream &OS) const {
 write_cstring(OS, StringRef(getOptionSpelling(R)));
 OS << ", ";
@@ -163,6 +168,7 @@
   MarshallingInfo Ret(R);
 
   Ret.ShouldAlwaysEmit = R.getValueAsBit("ShouldAlwaysEmit");
+  Ret.MacroPrefix = R.getValueAsString("MacroPrefix");
   Ret.KeyPath = R.getValueAsString("KeyPath");
   Ret.DefaultValue = R.getValueAsString("DefaultValue");
   Ret.NormalizedValuesScope = R.getValueAsString("NormalizedValuesScope");
@@ -424,13 +430,13 @@
 MarshallingInfos.push_back(createMarshallingInfo(*R));
 
   for (const auto &MI : MarshallingInfos) {
-OS << "#ifdef " << MarshallingInfo::MacroName << "\n";
-OS << MarshallingInfo::MacroName << "(";
+OS << "#ifdef " << MI.getMacroName() << "\n";
+OS << MI.getMacroName() << "(";
 WriteOptRecordFields(OS, MI.R);
 OS << ", ";
 MI.emit(OS);
 OS << ")\n";
-OS << "#endif // " << MarshallingInfo::MacroName << "\n";
+OS << "#endif // " << MI.getMacroName() << "\n";
   }
 
   OS << "\n";
Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -97,6 +97,7 @@
   OptionGroup Group = ?;
   Option Alias = ?;
   list AliasArgs = [];
+  code MacroPrefix = "";
   code KeyPath = ?;
   code DefaultValue = ?;
   code ImpliedValue = ?;
Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -680,4 +680,19 @@
   ASSERT_THAT(GeneratedArgs, Contains(StrEq("-cl-mad-enable")));
   ASSERT_THAT(GeneratedArgs, Contains(StrEq("-menable-unsafe-fp-math")));
 }
+
+// Diagnostic option.
+
+TEST_F(CommandLineTest, DiagnosticOptionPresent) {
+  const char *Args[] = {"-verify=xyz"};
+
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
+
+  ASSERT_EQ(Invocation.getDiagnosticOpts().VerifyPrefixes,
+std::vector({"xyz"}));
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs, ContainsN(StrEq("-verify=xyz"), 1));
+}
 } // anonymous namespace
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -388,7 +388,6 @@
 DiagnosticsEngine &Diags,
 const InputArgList &Args) {
   LangOptions &LangOpts = *Invocation.getLangOpts();
-  DiagnosticOptions &DiagOpts = Invocation.getDiagnosticOpts();
   CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts();
   TargetOptions &TargetOpts = Invocation.getTargetOpts();
   FrontendOptions &FrontendOpts = Invocation.getFrontendOpts();
@@ -402,8 +401,6 @@
   LangOpts.SpeculativeLoadHardening = CodeGenOpts.SpeculativeLoadHardening;
   LangOpts.CurrentModule = LangOpts.ModuleName;
 
-  llvm::sys::Process::UseANSIEscapeCodes(DiagOpts.UseANSIEscapeCodes);
-
   llvm::Triple T(TargetOpts.Triple);
   llvm::Triple::ArchType Arch = T.getArch();
 
@@ -1404,14 +1401,14 @@
   IMPLIED_CHECK, IMPLIED_VALUE,\
   NORMALIZER, MERGER, TABLE_INDEX) \
   if ((FLAGS)&options::CC1Option) {\
-this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);  \
+KEYPATH = MERGER(KEYPATH, DEFAULT_VALUE);  \
 if (IMPLIED_CHECK) \
-  this->KEYPATH = MERGER(this->KEYPA

[PATCH] D84673: [clang][cli] Port DiagnosticOpts to new option parsing system

2021-01-07 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1193-1195
+defm caret_diagnostics : BoolFOption<"caret-diagnostics",
+  "DiagnosticOpts->ShowCarets", DefaultsToTrue,
+  ChangedBy, ResetBy>, IsDiag;

dexonsmith wrote:
> There was one thing in the original patch that was a bit of sanity check for 
> whether `IsDiag` was added to the wrong option: the `DiagnosticOpts->` part 
> of the keypath was implicit. What do you think of adding that back? That 
> would make the keypath here `ShowCarets`.
> 
> It highlights that diagnostics are special (since `DiagnosticOpts` is never 
> mentioned in the file, and any mistakes could be found with a `grep`).
I agree that now, when we don't use the keypath as the "source of truth", the 
original solution where `DiagnosticOpts->` is implied by something else is 
cleaner. Thanks for pointing that out!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84673/new/

https://reviews.llvm.org/D84673

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92935: Introduce support for PowerPC devices with an Embedded Floating-point APU version 2 (efpu2)

2021-01-07 Thread Michael Kiausch via Phabricator via cfe-commits
kiausch updated this revision to Diff 315119.
kiausch marked an inline comment as done.
kiausch added a comment.

- enable -mspe if -mefpu2 is defined in clang interface
- added clang feature test


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92935/new/

https://reviews.llvm.org/D92935

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/Driver/ppc-features.cpp
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCSubtarget.cpp
  llvm/lib/Target/PowerPC/PPCSubtarget.h
  llvm/test/CodeGen/PowerPC/spe.ll

Index: llvm/test/CodeGen/PowerPC/spe.ll
===
--- llvm/test/CodeGen/PowerPC/spe.ll
+++ llvm/test/CodeGen/PowerPC/spe.ll
@@ -1,6 +1,18 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc-unknown-linux-gnu \
-; RUN:  -mattr=+spe |  FileCheck %s
+; RUN: split-file %s %t
+; RUN: llc -verify-machineinstrs < %t/single.ll -mtriple=powerpc-unknown-linux-gnu \
+; RUN:  -mattr=+spe |  FileCheck %t/single.ll
+; RUN: llc -verify-machineinstrs < %t/double.ll -mtriple=powerpc-unknown-linux-gnu \
+; RUN:  -mattr=+spe |  FileCheck %t/double.ll -check-prefix=SPE
+; RUN: llc -verify-machineinstrs < %t/hwdouble.ll -mtriple=powerpc-unknown-linux-gnu \
+; RUN:  -mattr=+spe |  FileCheck %t/hwdouble.ll -check-prefix=SPE
+; RUN: llc -verify-machineinstrs < %t/single.ll -mtriple=powerpc-unknown-linux-gnu \
+; RUN:  -mattr=+efpu2 |  FileCheck %t/single.ll
+; RUN: llc -verify-machineinstrs < %t/double.ll -mtriple=powerpc-unknown-linux-gnu \
+; RUN:  -mattr=+efpu2 |  FileCheck %t/double.ll -check-prefix=EFPU2
+
+;--- single.ll
+; single tests (identical for -mattr=+spe and -mattr=+efpu2)
 
 declare float @llvm.fabs.float(float)
 define float @test_float_abs(float %a) #0 {
@@ -75,30 +87,19 @@
   ret float %v
 }
 
-define float @test_dtos(double %a) {
-; CHECK-LABEL: test_dtos:
-; CHECK:   # %bb.0: # %entry
-; CHECK-NEXT:evmergelo 3, 3, 4
-; CHECK-NEXT:efscfd 3, 3
-; CHECK-NEXT:blr
-  entry:
-  %v = fptrunc double %a to float
-  ret float %v
-}
-
 define i32 @test_fcmpgt(float %a, float %b) {
 ; CHECK-LABEL: test_fcmpgt:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:stwu 1, -16(1)
 ; CHECK-NEXT:.cfi_def_cfa_offset 16
 ; CHECK-NEXT:efscmpgt 0, 3, 4
-; CHECK-NEXT:ble 0, .LBB8_2
+; CHECK-NEXT:ble 0, .LBB7_2
 ; CHECK-NEXT:  # %bb.1: # %tr
 ; CHECK-NEXT:li 3, 1
-; CHECK-NEXT:b .LBB8_3
-; CHECK-NEXT:  .LBB8_2: # %fa
+; CHECK-NEXT:b .LBB7_3
+; CHECK-NEXT:  .LBB7_2: # %fa
 ; CHECK-NEXT:li 3, 0
-; CHECK-NEXT:  .LBB8_3: # %ret
+; CHECK-NEXT:  .LBB7_3: # %ret
 ; CHECK-NEXT:stw 3, 12(1)
 ; CHECK-NEXT:lwz 3, 12(1)
 ; CHECK-NEXT:addi 1, 1, 16
@@ -124,19 +125,19 @@
 ; CHECK-NEXT:stwu 1, -16(1)
 ; CHECK-NEXT:.cfi_def_cfa_offset 16
 ; CHECK-NEXT:efscmpeq 0, 4, 4
-; CHECK-NEXT:bc 4, 1, .LBB9_4
+; CHECK-NEXT:bc 4, 1, .LBB8_4
 ; CHECK-NEXT:  # %bb.1: # %entry
 ; CHECK-NEXT:efscmpeq 0, 3, 3
-; CHECK-NEXT:bc 4, 1, .LBB9_4
+; CHECK-NEXT:bc 4, 1, .LBB8_4
 ; CHECK-NEXT:  # %bb.2: # %entry
 ; CHECK-NEXT:efscmpgt 0, 3, 4
-; CHECK-NEXT:bc 12, 1, .LBB9_4
+; CHECK-NEXT:bc 12, 1, .LBB8_4
 ; CHECK-NEXT:  # %bb.3: # %fa
 ; CHECK-NEXT:li 3, 0
-; CHECK-NEXT:b .LBB9_5
-; CHECK-NEXT:  .LBB9_4: # %tr
+; CHECK-NEXT:b .LBB8_5
+; CHECK-NEXT:  .LBB8_4: # %tr
 ; CHECK-NEXT:li 3, 1
-; CHECK-NEXT:  .LBB9_5: # %ret
+; CHECK-NEXT:  .LBB8_5: # %ret
 ; CHECK-NEXT:stw 3, 12(1)
 ; CHECK-NEXT:lwz 3, 12(1)
 ; CHECK-NEXT:addi 1, 1, 16
@@ -162,19 +163,19 @@
 ; CHECK-NEXT:stwu 1, -16(1)
 ; CHECK-NEXT:.cfi_def_cfa_offset 16
 ; CHECK-NEXT:efscmpeq 0, 3, 3
-; CHECK-NEXT:bc 4, 1, .LBB10_4
+; CHECK-NEXT:bc 4, 1, .LBB9_4
 ; CHECK-NEXT:  # %bb.1: # %entry
 ; CHECK-NEXT:efscmpeq 0, 4, 4
-; CHECK-NEXT:bc 4, 1, .LBB10_4
+; CHECK-NEXT:bc 4, 1, .LBB9_4
 ; CHECK-NEXT:  # %bb.2: # %entry
 ; CHECK-NEXT:efscmpgt 0, 3, 4
-; CHECK-NEXT:bc 12, 1, .LBB10_4
+; CHECK-NEXT:bc 12, 1, .LBB9_4
 ; CHECK-NEXT:  # %bb.3: # %tr
 ; CHECK-NEXT:li 3, 1
-; CHECK-NEXT:b .LBB10_5
-; CHECK-NEXT:  .LBB10_4: # %fa
+; CHECK-NEXT:b .LBB9_5
+; CHECK-NEXT:  .LBB9_4: # %fa
 ; CHECK-NEXT:li 3, 0
-; CHECK-NEXT:  .LBB10_5: # %ret
+; CHECK-NEXT:  .LBB9_5: # %ret
 ; CHECK-NEXT:stw 3, 12(1)
 ; CHECK-NEXT:lwz 3, 12(1)
 ; CHECK-NEXT:addi 1, 1, 16
@@ -200,13 +201,13 @@
 ; CHECK-NEXT:stwu 1, -16(1)
 ; CHECK-NEXT:.cfi_def_cfa_offset 16
 ; CHECK-NEXT:efscmpgt 0, 3, 4
-; CHECK-NEXT:bgt 0, .LBB11_2
+; CHECK-NEXT:bgt 0, .LBB10_2
 ; CHECK-NEXT:  # %bb.1: # %tr
 ; CHECK-NEXT:li 3, 1
-; CHECK-NEXT:b .LBB11_3
-; CHECK-NEXT:  .LBB11_2: # %fa
+; CHECK-NEXT:b .LBB10_3
+; CHECK-NEX

[PATCH] D89031: [SVE] Add support to vectorize_width loop pragma for scalable vectors

2021-01-07 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for all the changes @david-arm!




Comment at: clang/lib/AST/AttrImpl.cpp:46
+  else if (state == FixedWidth || state == ScalableWidth) {
+if (value) {
+  value->printPretty(OS, nullptr, Policy);

nit:
```if (value) {
  value->printPretty(OS, nullptr, Policy);
  OS << ", ";
}
OS << (state == ScalableWidth ? "scalable" : "fixed";```
?



Comment at: clang/lib/CodeGen/CGLoopInfo.cpp:309
+  (Attrs.VectorizeScalable == LoopAttributes::Disable &&
+   Attrs.VectorizeWidth == 0)) {
 bool AttrVal = Attrs.VectorizeEnable != LoopAttributes::Disable;

nit: `!= 1` (it should be functionally the same because the >1 is already 
caught above, but this is specifically testing that VF=1 (scalar) is not 
specified)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89031/new/

https://reviews.llvm.org/D89031

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94188: [OpenCL] Documentation for experimental C++ libraries support

2021-01-07 Thread Marco Antognini via Phabricator via cfe-commits
mantognini added a comment.

Looks good overall.




Comment at: clang/docs/OpenCLSupport.rst:104
+Clang provides the following new WIP features for the developers to experiment
+with and provide early feedback or contribute with further improvements.
+Feel free to contact us on `cfe-dev

Remove "with".



Comment at: clang/docs/OpenCLSupport.rst:115
+
+It is currently possible to use `type_traits` from C++17 in the kernel sources
+if the following clang extensions are enabled ``__cl_clang_function_pointers``

s/use/include/



Comment at: clang/docs/OpenCLSupport.rst:116
+It is currently possible to use `type_traits` from C++17 in the kernel sources
+if the following clang extensions are enabled ``__cl_clang_function_pointers``
+and ``__cl_clang_variadic_functions``, see :doc:`LanguageExtensions` for more

s/if/when/



Comment at: clang/docs/OpenCLSupport.rst:134
+  #pragma OPENCL EXTENSION __cl_clang_variadic_functions : enable
+  #include "type_traits"
+  #pragma OPENCL EXTENSION __cl_clang_function_pointers : disable

I'd use < and > instead of ". It should work too, right? It would be closer to 
standard C++ usage.



Comment at: clang/docs/OpenCLSupport.rst:138
+ 
+  typedef std::make_signed::type sint_t;
+

Two things:
- identifier ending with `_t` are reserved for the compiler I believe.
- to show usage of modern C++, this could be rewritten into `using sint = 
std::...`.



Comment at: clang/docs/OpenCLSupport.rst:151
+Note that `type_traits` is a header only library and therefore no extra
+linking step for the standard libraries is required.

s/for/against/


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94188/new/

https://reviews.llvm.org/D94188

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92634: [Analyzer] Diagnose signed integer overflow

2021-01-07 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Here is a link for our results on a few more projects. It might be useful for 
you.
https://codechecker-demo.eastus.cloudapp.azure.com/Default/runs?run=D92634&items-per-page=50&sort-by=name&sort-desc=false
Note: use the diff to filter only for the new reports.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92634/new/

https://reviews.llvm.org/D92634

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93395: [clang][cli] Remove -f[no-]trapping-math from -cc1 command line

2021-01-07 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer accepted this revision.
SjoerdMeijer added a comment.
This revision is now accepted and ready to land.

Thanks for getting to the bottom of this. Agreed, and also LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93395/new/

https://reviews.llvm.org/D93395

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94217: [clang-format] Find main include after block ended with #pragma hdrstop

2021-01-07 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D94217#2483925 , @rjelonek wrote:

> Currently at work we use Embarcadero Builder C++

I'm very sorry for you! (As someone who has (had?) also to use it.)

> In builder all above #pragma hdrstop is a precompiled header. And we have 
> this #pragma at almost all cpp files, so mainInclude is ignored because is in 
> second include block.
>
> `#pragma hdrstop( "c:\\projects\\include\\myinc.pch" )`
> This form shouldn't be handled

Why not? I don't know if `bcc` does support it, but `MSVC` does. So I think it 
definitely should support both, or none.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94217/new/

https://reviews.llvm.org/D94217

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92753: [clang-format] Add IndentPragma style to eliminate common clang-format off scenario

2021-01-07 Thread Tobias Nöll via Phabricator via cfe-commits
RatTac reopened this revision.
RatTac added a comment.
This revision is now accepted and ready to land.

This is a great feature. However I found two issues:

First issue is with combination of IndentPPDirectives

  // IndentPPDirectives: BeforeHash
  // IndentPragmas: true
  
  #if defined(WIN32)
#define TEST // Correctly indented because IndentPPDirectives: 
BeforeHash
  #endif
  
  #if defined(WIN32)
  #pragma warning(disable : 4005) // NOT indented even though 
IndentPPDirectives: BeforeHash
  #endif

Second issue is with combination of lambda function:

  inline void ompExecuteParallel(unsigned int endIndex, const 
std::function& computeFunction, unsigned int startIdx)
  {
#pragma omp parallel for
for(int i = (int)startIdx; i < (int)endIndex; i++)
computeFunction(i);
  }
  
  int main()
  {
#pragma omp parallel for
for(int i = 0; i < 10; i++)
{
// Correctly indented because IndentPragmas: true
#pragma openmp critical
{
std::cout << i << endl;
}
}
  
ompExecuteParallel(10, [&](unsigned int i) {
#pragma openmp critical // Incorrectly indented even though 
IndentPragmas: true
{
std::cout << i << endl;
}
});
  
return 0;
  }

Hope this is the right place to raise concerns...

Regards
Tobias


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92753/new/

https://reviews.llvm.org/D92753

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93483: Add element-type to the Vector TypeLoc types.

2021-01-07 Thread Florian Hahn via Phabricator via cfe-commits
fhahn accepted this revision.
fhahn added a comment.
This revision is now accepted and ready to land.

LGTM, thanks




Comment at: clang/include/clang/AST/TypeLoc.h:1756
+
+class VectorTypeLoc : public ConcreteTypeLoc {

erichkeane wrote:
> fhahn wrote:
> > Can we reuse/unify this with `MatrixTypeLoc`? And then have `MatrixTypeLoc` 
> > just deal with the row/column operands.
> Since these have to be ConcreteTypeLocs, I don't think the matrix type can 
> directly inherit from it, but it can do something very similar.
Oh right, that's a shame, given there already is a `MatrixTypeLoc`, which 
essentially does the same thing, but it also carries locations for the row and 
column operands.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93483/new/

https://reviews.llvm.org/D93483

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94162: [PowerPC] Add variants of 64-bit vector types for vec_sel.

2021-01-07 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf added a comment.

Can we add tests to `builtins-ppc-altivec.c`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94162/new/

https://reviews.llvm.org/D94162

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94217: [clang-format] Find main include after block ended with #pragma hdrstop

2021-01-07 Thread Rafał Jelonek via Phabricator via cfe-commits
rjelonek added a comment.

heh, maybe you seen unexpectedly closed IDE, errors while expanding list in 
source editor or blinking gui, etc ;D
I made plugin to use clang-format in Builder.

After reading the msvc documentation, I agree with you.  `#pragma hdrstop( 
"c:\\projects\\include\\myinc.pch" )` should be supported, also. I will change 
this soon.
Builder just ignore everything after `#pragma hdrstop` to the end of line. I 
check it on Builder ver. XE7




Comment at: clang/lib/Format/Format.cpp:2308
 IncludesInBlock.clear();
-FirstIncludeBlock = false;
+if (Trimmed == "#pragma hdrstop") // precompiled headers
+  FirstIncludeBlock = true;

MyDeveloperDay wrote:
> Should this handle this form?
> 
> ```
> #pragma hdrstop( "c:\\projects\\include\\myinc.pch" )
> ```
No


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94217/new/

https://reviews.llvm.org/D94217

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86844: [LoopDeletion] Allows deletion of possibly infinite side-effect free loops

2021-01-07 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D86844#2481922 , @xbolva00 wrote:

>   int a, b;
>   
>   int f(void) {
>   while (1) {
>   if (a != b) return 1;
>   }
>   return 0;
>   }
>   
>   int g(int a, int b) {
>   while (1) {
>   if (a != b) return 1;
>   }
>   return 0;
>   }
>
> LLVM does not catch these cases; gcc does.
>
> https://godbolt.org/z/jW7son

Looks like `must progress` does not get added? If it gets added to the IR the 
loops get removed: https://godbolt.org/z/77v17P


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86844/new/

https://reviews.llvm.org/D86844

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94237: [clang] Use SourceLocations in unions

2021-01-07 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki created this revision.
miyuki added reviewers: dexonsmith, aprantl, rsmith.
Herald added a subscriber: jfb.
miyuki requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Currently, there are many instances where `SourceLocation` objects are
converted to raw representation to be stored in structs that are
used as fields of tagged unions.

This is done to make the corresponding structs trivial.
Triviality allows avoiding undefined behavior when implicitly changing
the active member of the union.

However, in most cases, we can explicitly construct an active member
using placement new. This patch adds the required active member
selections and replaces `SourceLocation`-s represented as
`unsigned int` with proper `SourceLocation`-s.

One notable exception is `DeclarationNameLoc`: the objects of this class
are often not properly initialized (so the code currently relies on
its default constructor which uses memset). This class will be fixed
in a separate patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94237

Files:
  clang/include/clang/AST/DependentDiagnostic.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/Designator.h
  clang/include/clang/Sema/Initialization.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp

Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -3125,11 +3125,11 @@
   diag::warn_qual_return_type,
   PTI.TypeQuals,
   SourceLocation(),
-  SourceLocation::getFromRawEncoding(PTI.ConstQualLoc),
-  SourceLocation::getFromRawEncoding(PTI.VolatileQualLoc),
-  SourceLocation::getFromRawEncoding(PTI.RestrictQualLoc),
-  SourceLocation::getFromRawEncoding(PTI.AtomicQualLoc),
-  SourceLocation::getFromRawEncoding(PTI.UnalignedQualLoc));
+  PTI.ConstQualLoc,
+  PTI.VolatileQualLoc,
+  PTI.RestrictQualLoc,
+  PTI.AtomicQualLoc,
+  PTI.UnalignedQualLoc);
   return;
 }
 
@@ -6086,7 +6086,7 @@
   }
 
   // Finally fill in MemberPointerLocInfo fields.
-  TL.setStarLoc(SourceLocation::getFromRawEncoding(Chunk.Mem.StarLoc));
+  TL.setStarLoc(Chunk.Mem.StarLoc);
   TL.setClassTInfo(ClsTInfo);
 }
 void VisitLValueReferenceTypeLoc(LValueReferenceTypeLoc TL) {
@@ -6152,7 +6152,7 @@
 llvm_unreachable("cannot be _Atomic qualified");
 
   case DeclaratorChunk::Pointer:
-Loc = SourceLocation::getFromRawEncoding(Chunk.Ptr.AtomicQualLoc);
+Loc = Chunk.Ptr.AtomicQualLoc;
 break;
 
   case DeclaratorChunk::BlockPointer:
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -2851,8 +2851,7 @@
   // turn this into Self->ivar, just return a BareIVarExpr or something.
   IdentifierInfo &II = Context.Idents.get("self");
   UnqualifiedId SelfName;
-  SelfName.setIdentifier(&II, SourceLocation());
-  SelfName.setKind(UnqualifiedIdKind::IK_ImplicitSelfParam);
+  SelfName.setImplcitSelfParam(&II);
   CXXScopeSpec SelfScopeSpec;
   SourceLocation TemplateKWLoc;
   ExprResult SelfExpr =
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -5342,8 +5342,8 @@
   case UnqualifiedIdKind::IK_OperatorFunctionId:
 NameInfo.setName(Context.DeclarationNames.getCXXOperatorName(
Name.OperatorFunctionId.Operator));
-NameInfo.getInfo().CXXOperatorName.BeginOpNameLoc
-  = Name.OperatorFunctionId.SymbolLocations[0];
+NameInfo.getInfo().CXXOperatorName.BeginOpNameLoc =
+Name.OperatorFunctionId.SymbolLocations[0].getRawEncoding();
 NameInfo.getInfo().CXXOperatorName.EndOpNameLoc
   = Name.EndLocation.getRawEncoding();
 return NameInfo;
Index: clang/lib/Sema/DeclSpec.cpp
===
--- clang/lib/Sema/DeclSpec.cpp
+++ clang/lib/Sema/DeclSpec.cpp
@@ -191,28 +191,29 @@
   I.Kind= Function;
   I.Loc = LocalRangeBegin;
   I.EndLoc  = LocalRangeEnd;
+  new (&I.Fun) FunctionTypeInfo;
   I.Fun.hasPrototype= hasProto;
   I.Fun.isVariadic  = EllipsisLoc.isValid();
   I.Fun.isAmbiguous = isAmbiguous;
-  I.Fun.LParenLoc   = LParenLoc.getRawEncoding();
-  I.Fun.EllipsisLoc = EllipsisLoc.getRawEncoding();
-  I.Fun.RParenLoc   = RParenLoc.getRawEncoding();
+  I.F

[PATCH] D94239: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests

2021-01-07 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
abhina.sreeskantharajan added reviewers: Kai, fanbo-meng, muiez, zibi, 
hubert.reinterpretcast.
Herald added subscribers: wenlei, rupprecht, steven_wu, gbedwell, hiraditya, 
emaste.
Herald added a reviewer: JDevlieghere.
Herald added a reviewer: espindola.
Herald added a reviewer: andreadb.
Herald added a reviewer: alexshap.
Herald added a reviewer: rupprecht.
Herald added a reviewer: jhenderson.
abhina.sreeskantharajan requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay.
Herald added projects: clang, LLVM.

On z/OS, the following error message is not matched correctly in lit tests. 
This patch updates the CHECK expression to match successfully.

  EDC5129I No such file or directory.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94239

Files:
  clang/test/CodeGen/basic-block-sections.c
  clang/test/CodeGen/ubsan-blacklist-vfs.c
  clang/test/Frontend/stats-file.c
  lld/test/COFF/driver.test
  lld/test/COFF/manifestinput-error.test
  lld/test/COFF/nodefaultlib.test
  lld/test/COFF/pdb-type-server-invalid-signature.yaml
  lld/test/ELF/archive-thin-missing-member.s
  lld/test/ELF/basic.s
  lld/test/ELF/symbol-ordering-file.s
  llvm/test/DebugInfo/symbolize-missing-file.test
  llvm/test/tools/dsymutil/X86/papertrail-warnings.test
  llvm/test/tools/llvm-ar/missing-thin-archive-member.test
  llvm/test/tools/llvm-ar/replace.test
  llvm/test/tools/llvm-ar/response.test
  llvm/test/tools/llvm-cxxdump/trivial.test
  llvm/test/tools/llvm-lto2/X86/stats-file-option.ll
  llvm/test/tools/llvm-mc/basic.test
  llvm/test/tools/llvm-mca/invalid_input_file_name.test
  llvm/test/tools/llvm-ml/basic.test
  llvm/test/tools/llvm-objcopy/COFF/add-section.test
  llvm/test/tools/llvm-objcopy/ELF/add-section.test
  llvm/test/tools/llvm-objcopy/ELF/error-format.test
  llvm/test/tools/llvm-objcopy/MachO/add-section-error.test
  llvm/test/tools/llvm-objcopy/redefine-symbols.test
  llvm/test/tools/llvm-profdata/weight-instr.test
  llvm/test/tools/llvm-profdata/weight-sample.test
  llvm/test/tools/llvm-readobj/ELF/thin-archive-paths.test
  llvm/test/tools/llvm-readobj/basic.test
  llvm/test/tools/llvm-readobj/thin-archive.test
  llvm/test/tools/llvm-size/no-input.test
  llvm/test/tools/llvm-xray/X86/no-such-file.txt
  llvm/test/tools/obj2yaml/invalid_input_file.test
  llvm/test/tools/yaml2obj/output-file.yaml

Index: llvm/test/tools/yaml2obj/output-file.yaml
===
--- llvm/test/tools/yaml2obj/output-file.yaml
+++ llvm/test/tools/yaml2obj/output-file.yaml
@@ -9,7 +9,7 @@
 
 # RUN: not yaml2obj -o %p/path/does/not/exist 2>&1 | FileCheck %s
 
-# CHECK: yaml2obj: error: failed to open '{{.*}}/path/does/not/exist': {{[Nn]}}o such file or directory
+# CHECK: yaml2obj: error: failed to open '{{.*}}/path/does/not/exist': {{.*}}{{[Nn]}}o such file or directory
 
 !ELF
 FileHeader:
Index: llvm/test/tools/obj2yaml/invalid_input_file.test
===
--- llvm/test/tools/obj2yaml/invalid_input_file.test
+++ llvm/test/tools/obj2yaml/invalid_input_file.test
@@ -1,3 +1,3 @@
 # RUN: not obj2yaml  %p/path/does/not/exist 2>&1 | FileCheck %s
 
-# CHECK: Error reading file: {{.*}}/path/does/not/exist: {{[Nn]}}o such file or directory
+# CHECK: Error reading file: {{.*}}/path/does/not/exist: {{.*}}{{[Nn]}}o such file or directory
Index: llvm/test/tools/llvm-xray/X86/no-such-file.txt
===
--- llvm/test/tools/llvm-xray/X86/no-such-file.txt
+++ llvm/test/tools/llvm-xray/X86/no-such-file.txt
@@ -1,4 +1,4 @@
 ; RUN: not llvm-xray extract no-such-file 2>&1 | FileCheck %s
 
 ; CHECK: llvm-xray: Cannot extract instrumentation map from 'no-such-file'.
-; CHECK-NEXT: {{[Nn]}}o such file or directory
+; CHECK-NEXT: {{.*}}{{[Nn]}}o such file or directory
Index: llvm/test/tools/llvm-size/no-input.test
===
--- llvm/test/tools/llvm-size/no-input.test
+++ llvm/test/tools/llvm-size/no-input.test
@@ -1,7 +1,7 @@
 ## Show that llvm-size emits an error if passed in a non-existent file.
 
 # RUN: not llvm-size %t.blah 2>&1 | FileCheck %s -DFILE=%t.blah --check-prefix=ENOENT
-# ENOENT: {{.*}}llvm-size{{.*}}: error: '[[FILE]]': {{[Nn]}}o such file or directory
+# ENOENT: {{.*}}llvm-size{{.*}}: error: '[[FILE]]': {{.*}}{{[Nn]}}o such file or directory
 
 ## Show that llvm-size reads a.out if not passed any file.
 
Index: llvm/test/tools/llvm-readobj/thin-archive.test
===
--- llvm/test/tools/llvm-readobj/thin-archive.test
+++ llvm/test/tools/llvm-readobj/thin-archive.test
@@ -60,7 +60,7 @@
 # MISSING: File: {{.*}}1.o
 # MISSING: Format: elf64-x86-64
 # MISSING-NOT: File: {{.*}}3.o
-# ERR: error: '{{.*}}.a': '{{.*}}2.o': {{[Nn]}}o such file or directory
+# ERR: err

[PATCH] D92409: [AST][NFC] Silence GCC warning about multiline comments

2021-01-07 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Okay, LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92409/new/

https://reviews.llvm.org/D92409

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86844: [LoopDeletion] Allows deletion of possibly infinite side-effect free loops

2021-01-07 Thread Atmn Patel via Phabricator via cfe-commits
atmnpatel added a comment.

In D86844#2484568 , @fhahn wrote:

> In D86844#2481922 , @xbolva00 wrote:
>
>>   int a, b;
>>   
>>   int f(void) {
>>   while (1) {
>>   if (a != b) return 1;
>>   }
>>   return 0;
>>   }
>>   
>>   int g(int a, int b) {
>>   while (1) {
>>   if (a != b) return 1;
>>   }
>>   return 0;
>>   }
>>
>> LLVM does not catch these cases; gcc does.
>>
>> https://godbolt.org/z/jW7son
>
> Looks like `must progress` does not get added? If it gets added to the IR the 
> loops get removed: https://godbolt.org/z/77v17P

I might be misunderstanding the standard here but since 1 is a non-zero 
constant expression, it can't be assumed to terminate by the implementation 
right? The relevant section from C11 at least is "An iteration statement whose 
controlling expression is not a constant expression that performs [explanation 
of what it deems as progress] may be assumed by the implementation to 
terminate" (C11 6.8.5 p6).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86844/new/

https://reviews.llvm.org/D86844

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86841: [clang] Add mustprogress and llvm.loop.mustprogress attribute deduction

2021-01-07 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added subscribers: xbolva00, fhahn.
fhahn added inline comments.



Comment at: clang/lib/CodeGen/CGStmt.cpp:799
   EmitBoolCondBranch = false;
+  FnIsMustProgress = false;
+}

Shouldn't this only apply for C? http://eel.is/c++draft/intro.progress#1 does 
not seem to have this escape hatch?

See the example by @xbolva00 for which we fail to eliminate the loops from a 
C++ source https://godbolt.org/z/jW7son


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86841/new/

https://reviews.llvm.org/D86841

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86844: [LoopDeletion] Allows deletion of possibly infinite side-effect free loops

2021-01-07 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D86844#2484639 , @atmnpatel wrote:

> I might be misunderstanding the standard here but since 1 is a non-zero 
> constant expression, it can't be assumed to terminate by the implementation 
> right? The relevant section from C11 at least is "An iteration statement 
> whose controlling expression is not a constant expression that performs 
> [explanation of what it deems as progress] may be assumed by the 
> implementation to terminate" (C11 6.8.5 p6). I think these cases fall outside 
> of the scope of this particular change ...

The source is C++, so the C11 standard should be irrelevant. I left a comment 
at D86841 , this seems more appropriate to 
discuss the issue, as it is unrelated to `-loop-deletion`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86844/new/

https://reviews.llvm.org/D86844

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86844: [LoopDeletion] Allows deletion of possibly infinite side-effect free loops

2021-01-07 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

In D86844#2484639 , @atmnpatel wrote:

> In D86844#2484568 , @fhahn wrote:
>
>> In D86844#2481922 , @xbolva00 wrote:
>>
>>>   int a, b;
>>>   
>>>   int f(void) {
>>>   while (1) {
>>>   if (a != b) return 1;
>>>   }
>>>   return 0;
>>>   }
>>>   
>>>   int g(int a, int b) {
>>>   while (1) {
>>>   if (a != b) return 1;
>>>   }
>>>   return 0;
>>>   }
>>>
>>> LLVM does not catch these cases; gcc does.
>>>
>>> https://godbolt.org/z/jW7son
>>
>> Looks like `must progress` does not get added? If it gets added to the IR 
>> the loops get removed: https://godbolt.org/z/77v17P
>
> I might be misunderstanding the standard here but since 1 is a non-zero 
> constant expression, it can't be assumed to terminate by the implementation 
> right? The relevant section from C11 at least is "An iteration statement 
> whose controlling expression is not a constant expression that performs 
> [explanation of what it deems as progress] may be assumed by the 
> implementation to terminate" (C11 6.8.5 p6). I think these cases fall outside 
> of the scope of this particular change ...

For C yes, but are there such rules for C++? GCC in c++ mode does not check for 
non-zero constant expr and happily performs this optimization.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86844/new/

https://reviews.llvm.org/D86844

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94169: [clang][driver] Restore the original help text for `-I`

2021-01-07 Thread Richard Barton via Phabricator via cfe-commits
richard.barton.arm accepted this revision.
richard.barton.arm added a comment.
This revision is now accepted and ready to land.

The rationale for this revert looks good to me.

I don't see the rationale behind the original change as it was committed 
without review. If @andrei99 gets back to us then we can consider reinstating 
it, perhaps in an adjusted form.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94169/new/

https://reviews.llvm.org/D94169

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 59fce6b - [NFC] make clang/test/CodeGen/arm_neon_intrinsics.c resistent to function attribute id changes

2021-01-07 Thread Lucas Prates via cfe-commits

Author: Jeroen Dobbelaere
Date: 2021-01-07T17:08:15Z
New Revision: 59fce6b0661647062918a47bdb1874950d3938d5

URL: 
https://github.com/llvm/llvm-project/commit/59fce6b0661647062918a47bdb1874950d3938d5
DIFF: 
https://github.com/llvm/llvm-project/commit/59fce6b0661647062918a47bdb1874950d3938d5.diff

LOG: [NFC] make clang/test/CodeGen/arm_neon_intrinsics.c resistent to function 
attribute id changes

When introducing support for @llvm.experimental.noalias.scope.decl, this tests 
started failing because it checks
(for no good reason) for a function attribute id of '#8' which now becomes '#9'

Reviewed By: pratlucas

Differential Revision: https://reviews.llvm.org/D94233

Added: 


Modified: 
clang/test/CodeGen/arm_neon_intrinsics.c

Removed: 




diff  --git a/clang/test/CodeGen/arm_neon_intrinsics.c 
b/clang/test/CodeGen/arm_neon_intrinsics.c
index 9d3f35f48bb7..56e105a41962 100644
--- a/clang/test/CodeGen/arm_neon_intrinsics.c
+++ b/clang/test/CodeGen/arm_neon_intrinsics.c
@@ -7114,7 +7114,7 @@ uint64x2_t test_vmlal_u32(uint64x2_t a, uint32x2_t b, 
uint32x2_t c) {
 // CHECK:   [[LANE:%.*]] = shufflevector <4 x i16> [[TMP1]], <4 x i16> 
[[TMP1]], <4 x i32> 
 // CHECK:   [[TMP2:%.*]] = bitcast <4 x i16> [[B:%.*]] to <8 x i8>
 // CHECK:   [[TMP3:%.*]] = bitcast <4 x i16> [[LANE]] to <8 x i8>
-// CHECK:   [[VMULL2_I:%.*]] = call <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x 
i16> [[B]], <4 x i16> [[LANE]]) #8
+// CHECK:   [[VMULL2_I:%.*]] = call <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x 
i16> [[B]], <4 x i16> [[LANE]])
 // CHECK:   [[ADD:%.*]] = add <4 x i32> [[A:%.*]], [[VMULL2_I]]
 // CHECK:   ret <4 x i32> [[ADD]]
 int32x4_t test_vmlal_lane_s16(int32x4_t a, int16x4_t b, int16x4_t c) {
@@ -7127,7 +7127,7 @@ int32x4_t test_vmlal_lane_s16(int32x4_t a, int16x4_t b, 
int16x4_t c) {
 // CHECK:   [[LANE:%.*]] = shufflevector <2 x i32> [[TMP1]], <2 x i32> 
[[TMP1]], <2 x i32> 
 // CHECK:   [[TMP2:%.*]] = bitcast <2 x i32> [[B:%.*]] to <8 x i8>
 // CHECK:   [[TMP3:%.*]] = bitcast <2 x i32> [[LANE]] to <8 x i8>
-// CHECK:   [[VMULL2_I:%.*]] = call <2 x i64> @llvm.arm.neon.vmulls.v2i64(<2 x 
i32> [[B]], <2 x i32> [[LANE]]) #8
+// CHECK:   [[VMULL2_I:%.*]] = call <2 x i64> @llvm.arm.neon.vmulls.v2i64(<2 x 
i32> [[B]], <2 x i32> [[LANE]])
 // CHECK:   [[ADD:%.*]] = add <2 x i64> [[A:%.*]], [[VMULL2_I]]
 // CHECK:   ret <2 x i64> [[ADD]]
 int64x2_t test_vmlal_lane_s32(int64x2_t a, int32x2_t b, int32x2_t c) {
@@ -7140,7 +7140,7 @@ int64x2_t test_vmlal_lane_s32(int64x2_t a, int32x2_t b, 
int32x2_t c) {
 // CHECK:   [[LANE:%.*]] = shufflevector <4 x i16> [[TMP1]], <4 x i16> 
[[TMP1]], <4 x i32> 
 // CHECK:   [[TMP2:%.*]] = bitcast <4 x i16> [[B:%.*]] to <8 x i8>
 // CHECK:   [[TMP3:%.*]] = bitcast <4 x i16> [[LANE]] to <8 x i8>
-// CHECK:   [[VMULL2_I:%.*]] = call <4 x i32> @llvm.arm.neon.vmullu.v4i32(<4 x 
i16> [[B]], <4 x i16> [[LANE]]) #8
+// CHECK:   [[VMULL2_I:%.*]] = call <4 x i32> @llvm.arm.neon.vmullu.v4i32(<4 x 
i16> [[B]], <4 x i16> [[LANE]])
 // CHECK:   [[ADD:%.*]] = add <4 x i32> [[A:%.*]], [[VMULL2_I]]
 // CHECK:   ret <4 x i32> [[ADD]]
 uint32x4_t test_vmlal_lane_u16(uint32x4_t a, uint16x4_t b, uint16x4_t c) {
@@ -7153,7 +7153,7 @@ uint32x4_t test_vmlal_lane_u16(uint32x4_t a, uint16x4_t 
b, uint16x4_t c) {
 // CHECK:   [[LANE:%.*]] = shufflevector <2 x i32> [[TMP1]], <2 x i32> 
[[TMP1]], <2 x i32> 
 // CHECK:   [[TMP2:%.*]] = bitcast <2 x i32> [[B:%.*]] to <8 x i8>
 // CHECK:   [[TMP3:%.*]] = bitcast <2 x i32> [[LANE]] to <8 x i8>
-// CHECK:   [[VMULL2_I:%.*]] = call <2 x i64> @llvm.arm.neon.vmullu.v2i64(<2 x 
i32> [[B]], <2 x i32> [[LANE]]) #8
+// CHECK:   [[VMULL2_I:%.*]] = call <2 x i64> @llvm.arm.neon.vmullu.v2i64(<2 x 
i32> [[B]], <2 x i32> [[LANE]])
 // CHECK:   [[ADD:%.*]] = add <2 x i64> [[A:%.*]], [[VMULL2_I]]
 // CHECK:   ret <2 x i64> [[ADD]]
 uint64x2_t test_vmlal_lane_u32(uint64x2_t a, uint32x2_t b, uint32x2_t c) {
@@ -7618,7 +7618,7 @@ uint64x2_t test_vmlsl_u32(uint64x2_t a, uint32x2_t b, 
uint32x2_t c) {
 // CHECK:   [[LANE:%.*]] = shufflevector <4 x i16> [[TMP1]], <4 x i16> 
[[TMP1]], <4 x i32> 
 // CHECK:   [[TMP2:%.*]] = bitcast <4 x i16> [[B:%.*]] to <8 x i8>
 // CHECK:   [[TMP3:%.*]] = bitcast <4 x i16> [[LANE]] to <8 x i8>
-// CHECK:   [[VMULL2_I:%.*]] = call <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x 
i16> [[B]], <4 x i16> [[LANE]]) #8
+// CHECK:   [[VMULL2_I:%.*]] = call <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x 
i16> [[B]], <4 x i16> [[LANE]])
 // CHECK:   [[SUB:%.*]] = sub <4 x i32> [[A:%.*]], [[VMULL2_I]]
 // CHECK:   ret <4 x i32> [[SUB]]
 int32x4_t test_vmlsl_lane_s16(int32x4_t a, int16x4_t b, int16x4_t c) {
@@ -7631,7 +7631,7 @@ int32x4_t test_vmlsl_lane_s16(int32x4_t a, int16x4_t b, 
int16x4_t c) {
 // CHECK:   [[LANE:%.*]] = shufflevector <2 x i32> [[TMP1]], <2 x i32> 
[[TMP1]], <2 x i32> 
 // CHECK:   [[TMP2:%.*]] = bitcast <2 x i32> [[B:%.*]] to <8 x i8>
 // CHECK:   [[TMP3:%.*]] = bitcast

[PATCH] D94233: [NFC] make clang/test/CodeGen/arm_neon_intrinsics.c resistent to function attribute id changes

2021-01-07 Thread Lucas Prates via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG59fce6b06616: [NFC] make 
clang/test/CodeGen/arm_neon_intrinsics.c resistent to function… (authored by 
jeroen.dobbelaere, committed by pratlucas).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94233/new/

https://reviews.llvm.org/D94233

Files:
  clang/test/CodeGen/arm_neon_intrinsics.c

Index: clang/test/CodeGen/arm_neon_intrinsics.c
===
--- clang/test/CodeGen/arm_neon_intrinsics.c
+++ clang/test/CodeGen/arm_neon_intrinsics.c
@@ -7114,7 +7114,7 @@
 // CHECK:   [[LANE:%.*]] = shufflevector <4 x i16> [[TMP1]], <4 x i16> [[TMP1]], <4 x i32> 
 // CHECK:   [[TMP2:%.*]] = bitcast <4 x i16> [[B:%.*]] to <8 x i8>
 // CHECK:   [[TMP3:%.*]] = bitcast <4 x i16> [[LANE]] to <8 x i8>
-// CHECK:   [[VMULL2_I:%.*]] = call <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x i16> [[B]], <4 x i16> [[LANE]]) #8
+// CHECK:   [[VMULL2_I:%.*]] = call <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x i16> [[B]], <4 x i16> [[LANE]])
 // CHECK:   [[ADD:%.*]] = add <4 x i32> [[A:%.*]], [[VMULL2_I]]
 // CHECK:   ret <4 x i32> [[ADD]]
 int32x4_t test_vmlal_lane_s16(int32x4_t a, int16x4_t b, int16x4_t c) {
@@ -7127,7 +7127,7 @@
 // CHECK:   [[LANE:%.*]] = shufflevector <2 x i32> [[TMP1]], <2 x i32> [[TMP1]], <2 x i32> 
 // CHECK:   [[TMP2:%.*]] = bitcast <2 x i32> [[B:%.*]] to <8 x i8>
 // CHECK:   [[TMP3:%.*]] = bitcast <2 x i32> [[LANE]] to <8 x i8>
-// CHECK:   [[VMULL2_I:%.*]] = call <2 x i64> @llvm.arm.neon.vmulls.v2i64(<2 x i32> [[B]], <2 x i32> [[LANE]]) #8
+// CHECK:   [[VMULL2_I:%.*]] = call <2 x i64> @llvm.arm.neon.vmulls.v2i64(<2 x i32> [[B]], <2 x i32> [[LANE]])
 // CHECK:   [[ADD:%.*]] = add <2 x i64> [[A:%.*]], [[VMULL2_I]]
 // CHECK:   ret <2 x i64> [[ADD]]
 int64x2_t test_vmlal_lane_s32(int64x2_t a, int32x2_t b, int32x2_t c) {
@@ -7140,7 +7140,7 @@
 // CHECK:   [[LANE:%.*]] = shufflevector <4 x i16> [[TMP1]], <4 x i16> [[TMP1]], <4 x i32> 
 // CHECK:   [[TMP2:%.*]] = bitcast <4 x i16> [[B:%.*]] to <8 x i8>
 // CHECK:   [[TMP3:%.*]] = bitcast <4 x i16> [[LANE]] to <8 x i8>
-// CHECK:   [[VMULL2_I:%.*]] = call <4 x i32> @llvm.arm.neon.vmullu.v4i32(<4 x i16> [[B]], <4 x i16> [[LANE]]) #8
+// CHECK:   [[VMULL2_I:%.*]] = call <4 x i32> @llvm.arm.neon.vmullu.v4i32(<4 x i16> [[B]], <4 x i16> [[LANE]])
 // CHECK:   [[ADD:%.*]] = add <4 x i32> [[A:%.*]], [[VMULL2_I]]
 // CHECK:   ret <4 x i32> [[ADD]]
 uint32x4_t test_vmlal_lane_u16(uint32x4_t a, uint16x4_t b, uint16x4_t c) {
@@ -7153,7 +7153,7 @@
 // CHECK:   [[LANE:%.*]] = shufflevector <2 x i32> [[TMP1]], <2 x i32> [[TMP1]], <2 x i32> 
 // CHECK:   [[TMP2:%.*]] = bitcast <2 x i32> [[B:%.*]] to <8 x i8>
 // CHECK:   [[TMP3:%.*]] = bitcast <2 x i32> [[LANE]] to <8 x i8>
-// CHECK:   [[VMULL2_I:%.*]] = call <2 x i64> @llvm.arm.neon.vmullu.v2i64(<2 x i32> [[B]], <2 x i32> [[LANE]]) #8
+// CHECK:   [[VMULL2_I:%.*]] = call <2 x i64> @llvm.arm.neon.vmullu.v2i64(<2 x i32> [[B]], <2 x i32> [[LANE]])
 // CHECK:   [[ADD:%.*]] = add <2 x i64> [[A:%.*]], [[VMULL2_I]]
 // CHECK:   ret <2 x i64> [[ADD]]
 uint64x2_t test_vmlal_lane_u32(uint64x2_t a, uint32x2_t b, uint32x2_t c) {
@@ -7618,7 +7618,7 @@
 // CHECK:   [[LANE:%.*]] = shufflevector <4 x i16> [[TMP1]], <4 x i16> [[TMP1]], <4 x i32> 
 // CHECK:   [[TMP2:%.*]] = bitcast <4 x i16> [[B:%.*]] to <8 x i8>
 // CHECK:   [[TMP3:%.*]] = bitcast <4 x i16> [[LANE]] to <8 x i8>
-// CHECK:   [[VMULL2_I:%.*]] = call <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x i16> [[B]], <4 x i16> [[LANE]]) #8
+// CHECK:   [[VMULL2_I:%.*]] = call <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x i16> [[B]], <4 x i16> [[LANE]])
 // CHECK:   [[SUB:%.*]] = sub <4 x i32> [[A:%.*]], [[VMULL2_I]]
 // CHECK:   ret <4 x i32> [[SUB]]
 int32x4_t test_vmlsl_lane_s16(int32x4_t a, int16x4_t b, int16x4_t c) {
@@ -7631,7 +7631,7 @@
 // CHECK:   [[LANE:%.*]] = shufflevector <2 x i32> [[TMP1]], <2 x i32> [[TMP1]], <2 x i32> 
 // CHECK:   [[TMP2:%.*]] = bitcast <2 x i32> [[B:%.*]] to <8 x i8>
 // CHECK:   [[TMP3:%.*]] = bitcast <2 x i32> [[LANE]] to <8 x i8>
-// CHECK:   [[VMULL2_I:%.*]] = call <2 x i64> @llvm.arm.neon.vmulls.v2i64(<2 x i32> [[B]], <2 x i32> [[LANE]]) #8
+// CHECK:   [[VMULL2_I:%.*]] = call <2 x i64> @llvm.arm.neon.vmulls.v2i64(<2 x i32> [[B]], <2 x i32> [[LANE]])
 // CHECK:   [[SUB:%.*]] = sub <2 x i64> [[A:%.*]], [[VMULL2_I]]
 // CHECK:   ret <2 x i64> [[SUB]]
 int64x2_t test_vmlsl_lane_s32(int64x2_t a, int32x2_t b, int32x2_t c) {
@@ -7644,7 +7644,7 @@
 // CHECK:   [[LANE:%.*]] = shufflevector <4 x i16> [[TMP1]], <4 x i16> [[TMP1]], <4 x i32> 
 // CHECK:   [[TMP2:%.*]] = bitcast <4 x i16> [[B:%.*]] to <8 x i8>
 // CHECK:   [[TMP3:%.*]] = bitcast <4 x i16> [[LANE]] to <8 x i8>
-// CHECK:   [[VMULL2_I:%.*]] = call <4 x i32> @llvm.arm.neon.vmullu.v4i32(<4 x i16> [[B]], <4 x i16> [[LANE]]) #8
+// CHECK:   [[VMULL2_I:

[PATCH] D94233: [NFC] make clang/test/CodeGen/arm_neon_intrinsics.c resistent to function attribute id changes

2021-01-07 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas added a comment.

No problem! I've pushed the commit on your behalf.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94233/new/

https://reviews.llvm.org/D94233

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] acbb365 - [AST][NFC] Silence GCC warning about multiline comments

2021-01-07 Thread Thomas Preud'homme via cfe-commits

Author: Thomas Preud'homme
Date: 2021-01-07T17:11:49Z
New Revision: acbb3652931a735a861b756075b1cc86fd041761

URL: 
https://github.com/llvm/llvm-project/commit/acbb3652931a735a861b756075b1cc86fd041761
DIFF: 
https://github.com/llvm/llvm-project/commit/acbb3652931a735a861b756075b1cc86fd041761.diff

LOG: [AST][NFC] Silence GCC warning about multiline comments

Remove continuation line in code snippet to prevent GCC warning about
multiline comments (-Wcomment) when building a project using libclang
with GCC.

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D92409

Added: 


Modified: 
clang/include/clang/AST/DeclOpenMP.h

Removed: 




diff  --git a/clang/include/clang/AST/DeclOpenMP.h 
b/clang/include/clang/AST/DeclOpenMP.h
index e595ec98d914c..4aa5bde92e123 100644
--- a/clang/include/clang/AST/DeclOpenMP.h
+++ b/clang/include/clang/AST/DeclOpenMP.h
@@ -163,7 +163,7 @@ class OMPThreadPrivateDecl final : public 
OMPDeclarativeDirective {
 /// 'float':
 ///
 /// \code
-/// #pragma omp declare reduction (foo : int,float : omp_out += omp_in) \
+/// #pragma omp declare reduction (foo : int,float : omp_out += omp_in)
 /// initializer (omp_priv = 0)
 /// \endcode
 ///



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92409: [AST][NFC] Silence GCC warning about multiline comments

2021-01-07 Thread Thomas Preud'homme via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGacbb3652931a: [AST][NFC] Silence GCC warning about multiline 
comments (authored by thopre).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92409/new/

https://reviews.llvm.org/D92409

Files:
  clang/include/clang/AST/DeclOpenMP.h


Index: clang/include/clang/AST/DeclOpenMP.h
===
--- clang/include/clang/AST/DeclOpenMP.h
+++ clang/include/clang/AST/DeclOpenMP.h
@@ -163,7 +163,7 @@
 /// 'float':
 ///
 /// \code
-/// #pragma omp declare reduction (foo : int,float : omp_out += omp_in) \
+/// #pragma omp declare reduction (foo : int,float : omp_out += omp_in)
 /// initializer (omp_priv = 0)
 /// \endcode
 ///


Index: clang/include/clang/AST/DeclOpenMP.h
===
--- clang/include/clang/AST/DeclOpenMP.h
+++ clang/include/clang/AST/DeclOpenMP.h
@@ -163,7 +163,7 @@
 /// 'float':
 ///
 /// \code
-/// #pragma omp declare reduction (foo : int,float : omp_out += omp_in) \
+/// #pragma omp declare reduction (foo : int,float : omp_out += omp_in)
 /// initializer (omp_priv = 0)
 /// \endcode
 ///
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 43043ad - Add element-type to the Vector TypeLoc types.

2021-01-07 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2021-01-07T09:14:36-08:00
New Revision: 43043adcfbc60945646b791d7162e5a1307a5318

URL: 
https://github.com/llvm/llvm-project/commit/43043adcfbc60945646b791d7162e5a1307a5318
DIFF: 
https://github.com/llvm/llvm-project/commit/43043adcfbc60945646b791d7162e5a1307a5318.diff

LOG: Add element-type to the Vector TypeLoc types.

As shown by bug 48540, GCC vector types would cause a crash when the
declaration hada ParenType. This was because the walking of the
declaration would try to expand the 'inner' type, but there was no
ability to get it from the vector type.  This patch adds that element
type access to the vector type loc objects.

Differential Revision: https://reviews.llvm.org/D93483

Added: 


Modified: 
clang/include/clang/AST/TypeLoc.h
clang/lib/Sema/SemaType.cpp
clang/lib/Sema/TreeTransform.h
clang/test/SemaCXX/vector.cpp

Removed: 




diff  --git a/clang/include/clang/AST/TypeLoc.h 
b/clang/include/clang/AST/TypeLoc.h
index 4c320ce26e4f..65e95d52c303 100644
--- a/clang/include/clang/AST/TypeLoc.h
+++ b/clang/include/clang/AST/TypeLoc.h
@@ -1749,30 +1749,79 @@ class DependentAddressSpaceTypeLoc
 
 // FIXME: size expression and attribute locations (or keyword if we
 // ever fully support altivec syntax).
-class VectorTypeLoc : public InheritingConcreteTypeLoc {
+struct VectorTypeLocInfo {
+  SourceLocation NameLoc;
+};
+
+class VectorTypeLoc : public ConcreteTypeLoc {
+public:
+  SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
+
+  void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
+
+  SourceRange getLocalSourceRange() const {
+return SourceRange(getNameLoc(), getNameLoc());
+  }
+
+  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
+setNameLoc(Loc);
+  }
+
+  TypeLoc getElementLoc() const { return getInnerTypeLoc(); }
+
+  QualType getInnerType() const { return this->getTypePtr()->getElementType(); 
}
 };
 
 // FIXME: size expression and attribute locations (or keyword if we
 // ever fully support altivec syntax).
 class DependentVectorTypeLoc
-: public InheritingConcreteTypeLoc {};
+: public ConcreteTypeLoc {
+public:
+  SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
 
-// FIXME: size expression and attribute locations.
-class ExtVectorTypeLoc : public InheritingConcreteTypeLoc {
+  void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
+
+  SourceRange getLocalSourceRange() const {
+return SourceRange(getNameLoc(), getNameLoc());
+  }
+
+  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
+setNameLoc(Loc);
+  }
+
+  TypeLoc getElementLoc() const { return getInnerTypeLoc(); }
+
+  QualType getInnerType() const { return this->getTypePtr()->getElementType(); 
}
 };
 
+// FIXME: size expression and attribute locations.
+class ExtVectorTypeLoc
+: public InheritingConcreteTypeLoc {};
+
 // FIXME: attribute locations.
 // For some reason, this isn't a subtype of VectorType.
-class DependentSizedExtVectorTypeLoc :
-public InheritingConcreteTypeLoc {
+class DependentSizedExtVectorTypeLoc
+: public ConcreteTypeLoc {
+public:
+  SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
+
+  void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
+
+  SourceRange getLocalSourceRange() const {
+return SourceRange(getNameLoc(), getNameLoc());
+  }
+
+  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
+setNameLoc(Loc);
+  }
+
+  TypeLoc getElementLoc() const { return getInnerTypeLoc(); }
+
+  QualType getInnerType() const { return this->getTypePtr()->getElementType(); 
}
 };
 
 struct MatrixTypeLocInfo {

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index f51c616169f5..fe775b82a1d6 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -6135,6 +6135,17 @@ namespace {
 void VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) {
   TL.setExpansionLoc(Chunk.Loc);
 }
+void VisitVectorTypeLoc(VectorTypeLoc TL) { TL.setNameLoc(Chunk.Loc); }
+void VisitDependentVectorTypeLoc(DependentVectorTypeLoc TL) {
+  TL.setNameLoc(Chunk.Loc);
+}
+void VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) {
+  TL.setNameLoc(Chunk.Loc);
+}
+void
+VisitDependentSizedExtVectorTypeLoc(DependentSizedExtVectorTypeLoc TL) {
+  TL.setNameLoc(Chunk.Loc);
+}
 
 void VisitTypeLoc(TypeLoc TL) {
   llvm_unreachable("unsupported TypeLoc kind in declarator!");

diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 2cc8b9c8324f..0a596e50658b 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -5178,7 +5178,7 @@ template 
 QualType TreeTransform::TransformDependentVectorType(
 TypeLocBuilder &TLB, DependentVectorTypeLoc TL) {

[PATCH] D93483: Add element-type to the Vector TypeLoc types.

2021-01-07 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG43043adcfbc6: Add element-type to the Vector TypeLoc types. 
(authored by erichkeane).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D93483?vs=312582&id=315164#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93483/new/

https://reviews.llvm.org/D93483

Files:
  clang/include/clang/AST/TypeLoc.h
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/SemaCXX/vector.cpp

Index: clang/test/SemaCXX/vector.cpp
===
--- clang/test/SemaCXX/vector.cpp
+++ clang/test/SemaCXX/vector.cpp
@@ -513,3 +513,20 @@
 }
 
 } // namespace PR45780
+
+namespace PR48540 {
+// The below used to cause an OOM error, or an assert, make sure it is still
+//  valid.
+int (__attribute__((vector_size(16))) a);
+
+template 
+struct S {
+  T (__attribute__((vector_size(16))) a);
+  int (__attribute__((vector_size(I))) b);
+  T (__attribute__((vector_size(I))) c);
+};
+
+void use() {
+  S s;
+}
+} // namespace PR48540
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -5178,7 +5178,7 @@
 QualType TreeTransform::TransformDependentVectorType(
 TypeLocBuilder &TLB, DependentVectorTypeLoc TL) {
   const DependentVectorType *T = TL.getTypePtr();
-  QualType ElementType = getDerived().TransformType(T->getElementType());
+  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
   if (ElementType.isNull())
 return QualType();
 
@@ -5219,7 +5219,7 @@
   const DependentSizedExtVectorType *T = TL.getTypePtr();
 
   // FIXME: ext vector locs should be nested
-  QualType ElementType = getDerived().TransformType(T->getElementType());
+  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
   if (ElementType.isNull())
 return QualType();
 
@@ -5386,7 +5386,7 @@
 QualType TreeTransform::TransformVectorType(TypeLocBuilder &TLB,
  VectorTypeLoc TL) {
   const VectorType *T = TL.getTypePtr();
-  QualType ElementType = getDerived().TransformType(T->getElementType());
+  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
   if (ElementType.isNull())
 return QualType();
 
@@ -5409,7 +5409,7 @@
 QualType TreeTransform::TransformExtVectorType(TypeLocBuilder &TLB,
 ExtVectorTypeLoc TL) {
   const VectorType *T = TL.getTypePtr();
-  QualType ElementType = getDerived().TransformType(T->getElementType());
+  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
   if (ElementType.isNull())
 return QualType();
 
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -6135,6 +6135,17 @@
 void VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) {
   TL.setExpansionLoc(Chunk.Loc);
 }
+void VisitVectorTypeLoc(VectorTypeLoc TL) { TL.setNameLoc(Chunk.Loc); }
+void VisitDependentVectorTypeLoc(DependentVectorTypeLoc TL) {
+  TL.setNameLoc(Chunk.Loc);
+}
+void VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) {
+  TL.setNameLoc(Chunk.Loc);
+}
+void
+VisitDependentSizedExtVectorTypeLoc(DependentSizedExtVectorTypeLoc TL) {
+  TL.setNameLoc(Chunk.Loc);
+}
 
 void VisitTypeLoc(TypeLoc TL) {
   llvm_unreachable("unsupported TypeLoc kind in declarator!");
Index: clang/include/clang/AST/TypeLoc.h
===
--- clang/include/clang/AST/TypeLoc.h
+++ clang/include/clang/AST/TypeLoc.h
@@ -1749,30 +1749,79 @@
 
 // FIXME: size expression and attribute locations (or keyword if we
 // ever fully support altivec syntax).
-class VectorTypeLoc : public InheritingConcreteTypeLoc {
+struct VectorTypeLocInfo {
+  SourceLocation NameLoc;
+};
+
+class VectorTypeLoc : public ConcreteTypeLoc {
+public:
+  SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
+
+  void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
+
+  SourceRange getLocalSourceRange() const {
+return SourceRange(getNameLoc(), getNameLoc());
+  }
+
+  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
+setNameLoc(Loc);
+  }
+
+  TypeLoc getElementLoc() const { return getInnerTypeLoc(); }
+
+  QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
 };
 
 // FIXME: size expression and attribute locations (or keyword if we
 // ever fully support altivec syntax).
 class DependentVectorTypeLoc
-: public InheritingConcreteTypeLoc {};
+: public ConcreteTypeLoc {
+public:
+  SourceLocation getNameLoc() const { return 

[PATCH] D86841: [clang] Add mustprogress and llvm.loop.mustprogress attribute deduction

2021-01-07 Thread Atmn Patel via Phabricator via cfe-commits
atmnpatel added a comment.

I'm happy to add a patch amending this, the reason it wasn't done that way was 
because at the time and even now, out of icc/clang/msvc/gcc, gcc seems to be 
the only one that happily removed such loops in C++ 
(https://godbolt.org/z/W9vj99), and I didn't have a particularly strong opinion 
on which way we should lean at the time.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86841/new/

https://reviews.llvm.org/D86841

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94206: [clang-format] turn on formatting after "clang-format on" while sorting includes

2021-01-07 Thread Rafał Jelonek via Phabricator via cfe-commits
rjelonek updated this revision to Diff 315166.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94206/new/

https://reviews.llvm.org/D94206

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/SortIncludesTest.cpp


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -207,6 +207,27 @@
  "#include \n"
  "#include \n"
  "// clang-format on\n"));
+
+  Style.IncludeBlocks = Style.IBS_Merge;
+  std::string Code = "// clang-format off\r\n"
+ "#include \"d.h\"\r\n"
+ "#include \"b.h\"\r\n"
+ "// clang-format on\r\n"
+ "\r\n"
+ "#include \"c.h\"\r\n"
+ "#include \"a.h\"\r\n"
+ "#include \"e.h\"\r\n";
+
+  std::string Expected = "// clang-format off\r\n"
+ "#include \"d.h\"\r\n"
+ "#include \"b.h\"\r\n"
+ "// clang-format on\r\n"
+ "\r\n"
+ "#include \"e.h\"\r\n"
+ "#include \"a.h\"\r\n"
+ "#include \"c.h\"\r\n";
+
+  EXPECT_EQ(Expected, sort(Code, "e.cpp", 1));
 }
 
 TEST_F(SortIncludesTest, SupportClangFormatOffCStyle) {
@@ -879,6 +900,21 @@
  "#include \"a.h\""));
 }
 
+TEST_F(SortIncludesTest, MergeLines) {
+  Style.IncludeBlocks = Style.IBS_Merge;
+  std::string Code = "#include \"c.h\"\r\n"
+ "#include \"b\\\r\n"
+ ".h\"\r\n"
+ "#include \"a.h\"\r\n";
+
+  std::string Expected = "#include \"a.h\"\r\n"
+ "#include \"b\\\r\n"
+ ".h\"\r\n"
+ "#include \"c.h\"\r\n";
+
+  EXPECT_EQ(Expected, sort(Code, "a.cpp", 1));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2289,7 +2289,8 @@
  Style.IncludeStyle.IncludeBlocks ==
  tooling::IncludeStyle::IBS_Regroup);
 
-if (!FormattingOff && !Line.endswith("\\")) {
+bool MergeWithNextLine = Trimmed.endswith("\\");
+if (!FormattingOff && !MergeWithNextLine) {
   if (IncludeRegex.match(Line, &Matches)) {
 StringRef IncludeName = Matches[2];
 int Category = Categories.getIncludePriority(
@@ -2307,10 +2308,12 @@
 IncludesInBlock.clear();
 FirstIncludeBlock = false;
   }
-  Prev = Pos + 1;
 }
 if (Pos == StringRef::npos || Pos + 1 == Code.size())
   break;
+
+if (!MergeWithNextLine)
+  Prev = Pos + 1;
 SearchFrom = Pos + 1;
   }
   if (!IncludesInBlock.empty()) {


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -207,6 +207,27 @@
  "#include \n"
  "#include \n"
  "// clang-format on\n"));
+
+  Style.IncludeBlocks = Style.IBS_Merge;
+  std::string Code = "// clang-format off\r\n"
+ "#include \"d.h\"\r\n"
+ "#include \"b.h\"\r\n"
+ "// clang-format on\r\n"
+ "\r\n"
+ "#include \"c.h\"\r\n"
+ "#include \"a.h\"\r\n"
+ "#include \"e.h\"\r\n";
+
+  std::string Expected = "// clang-format off\r\n"
+ "#include \"d.h\"\r\n"
+ "#include \"b.h\"\r\n"
+ "// clang-format on\r\n"
+ "\r\n"
+ "#include \"e.h\"\r\n"
+ "#include \"a.h\"\r\n"
+ "#include \"c.h\"\r\n";
+
+  EXPECT_EQ(Expected, sort(Code, "e.cpp", 1));
 }
 
 TEST_F(SortIncludesTest, SupportClangFormatOffCStyle) {
@@ -879,6 +900,21 @@
  "#include \"a.h\""));
 }
 
+TEST_F(SortIncludesTest, MergeLines) {
+  Style.IncludeBlocks = Style.IBS_Merge;
+  std::string Code = "#include \"c.h\"\r\n"
+ "#include \"b\\\r\n"
+ ".h\"\r\n"
+ "#include \"a.h\"\r\n";
+
+  std::string Expected = "#include \"a.h\"\r\n"
+ "#include \"b\\\r\n"
+ ".h\"\r\n"
+ "#include \"c.h\"\r\n";
+
+  EXPECT_EQ(Expected, sort(Code, "a.cpp", 1));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format

[PATCH] D94217: [clang-format] Find main include after block ended with #pragma hdrstop

2021-01-07 Thread Rafał Jelonek via Phabricator via cfe-commits
rjelonek updated this revision to Diff 315169.
rjelonek added a comment.

Add support to `#pragma hdrstop( "c:\\projects\\include\\myinc.pch" )'


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94217/new/

https://reviews.llvm.org/D94217

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/SortIncludesTest.cpp


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -879,6 +879,27 @@
  "#include \"a.h\""));
 }
 
+TEST_F(SortIncludesTest, DoNotTreatPrecompiledHeadersAsFirstBlock) {
+  Style.IncludeBlocks = Style.IBS_Merge;
+  std::string Code = "#include \"d.h\"\r\n"
+ "#include \"b.h\"\r\n"
+ "#pragma hdrstop\r\n"
+ "\r\n"
+ "#include \"c.h\"\r\n"
+ "#include \"a.h\"\r\n"
+ "#include \"e.h\"\r\n";
+
+  std::string Expected = "#include \"b.h\"\r\n"
+ "#include \"d.h\"\r\n"
+ "#pragma hdrstop\r\n"
+ "\r\n"
+ "#include \"e.h\"\r\n"
+ "#include \"a.h\"\r\n"
+ "#include \"c.h\"\r\n";
+
+  EXPECT_EQ(Expected, sort(Code, "e.cpp", 2));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2305,7 +2305,10 @@
 sortCppIncludes(Style, IncludesInBlock, Ranges, FileName, Code,
 Replaces, Cursor);
 IncludesInBlock.clear();
-FirstIncludeBlock = false;
+if (Trimmed.startswith("#pragma hdrstop")) // precompiled headers
+  FirstIncludeBlock = true;
+else
+  FirstIncludeBlock = false;
   }
   Prev = Pos + 1;
 }


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -879,6 +879,27 @@
  "#include \"a.h\""));
 }
 
+TEST_F(SortIncludesTest, DoNotTreatPrecompiledHeadersAsFirstBlock) {
+  Style.IncludeBlocks = Style.IBS_Merge;
+  std::string Code = "#include \"d.h\"\r\n"
+ "#include \"b.h\"\r\n"
+ "#pragma hdrstop\r\n"
+ "\r\n"
+ "#include \"c.h\"\r\n"
+ "#include \"a.h\"\r\n"
+ "#include \"e.h\"\r\n";
+
+  std::string Expected = "#include \"b.h\"\r\n"
+ "#include \"d.h\"\r\n"
+ "#pragma hdrstop\r\n"
+ "\r\n"
+ "#include \"e.h\"\r\n"
+ "#include \"a.h\"\r\n"
+ "#include \"c.h\"\r\n";
+
+  EXPECT_EQ(Expected, sort(Code, "e.cpp", 2));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2305,7 +2305,10 @@
 sortCppIncludes(Style, IncludesInBlock, Ranges, FileName, Code,
 Replaces, Cursor);
 IncludesInBlock.clear();
-FirstIncludeBlock = false;
+if (Trimmed.startswith("#pragma hdrstop")) // precompiled headers
+  FirstIncludeBlock = true;
+else
+  FirstIncludeBlock = false;
   }
   Prev = Pos + 1;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92892: [clang] Change builtin object size to be compatible with GCC when sub-object is invalid

2021-01-07 Thread Mott, Jeffrey T via Phabricator via cfe-commits
jtmott-intel added a comment.

Seems I don't have commit access. I'll look into it. For now, could someone 
push this commit? Thanks.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92892/new/

https://reviews.llvm.org/D92892

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92751: [clang][aarch64] Precondition isHomogeneousAggregate on isCXX14Aggregate

2021-01-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/CodeGen/CGCXXABI.h:143
   /// Returns how an argument of the given record type should be passed.
   virtual RecordArgABI getRecordArgABI(const CXXRecordDecl *RD) const = 0;
 

nit: I would group the new virtual method declaration after these two, since it 
also has to do with argument classification.



Comment at: clang/lib/CodeGen/MicrosoftCXXABI.cpp:4370
+  // AAPCS64, but is defacto spec on that platform.
+  return isTrivialForAArch64MSVC(CXXRD);
+}

I think x64 vectorcall supports HVAs, so this could change behavior there, 
unless you check the triple for aarch64.

Following the principle of limiting the scope of the change, this seems like 
the right condition:
  return !CGM.getTarget().getTriple().isAArch64() || 
isTrivialForAArch64MSVC(CXXRD);

We can follow up with more x64 vectorcall tests later.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92751/new/

https://reviews.llvm.org/D92751

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d015445 - Silence warning: comparison of integers of different signs: 'const unsigned int' and 'const long' [-Wsign-compare]

2021-01-07 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2021-01-07T13:01:06-05:00
New Revision: d0154456e61c5ab79e25fc9b8bb684ebdca3a7c2

URL: 
https://github.com/llvm/llvm-project/commit/d0154456e61c5ab79e25fc9b8bb684ebdca3a7c2
DIFF: 
https://github.com/llvm/llvm-project/commit/d0154456e61c5ab79e25fc9b8bb684ebdca3a7c2.diff

LOG: Silence warning: comparison of integers of different signs: 'const 
unsigned int' and 'const long' [-Wsign-compare]

(off_t being a signed type)

Added: 


Modified: 
clang/unittests/Basic/FileEntryTest.cpp

Removed: 




diff  --git a/clang/unittests/Basic/FileEntryTest.cpp 
b/clang/unittests/Basic/FileEntryTest.cpp
index a3e03e6c7c29..16c8e57d9a17 100644
--- a/clang/unittests/Basic/FileEntryTest.cpp
+++ b/clang/unittests/Basic/FileEntryTest.cpp
@@ -57,7 +57,7 @@ struct RefMaps {
 
 TEST(FileEntryTest, Constructor) {
   FileEntry FE;
-  EXPECT_EQ(0U, FE.getSize());
+  EXPECT_EQ(0, FE.getSize());
   EXPECT_EQ(0, FE.getModificationTime());
   EXPECT_EQ(nullptr, FE.getDir());
   EXPECT_EQ(0U, FE.getUniqueID().getDevice());



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94188: [OpenCL] Documentation for experimental C++ libraries support

2021-01-07 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 315173.
Anastasia added a comment.

Addressed review comments


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94188/new/

https://reviews.llvm.org/D94188

Files:
  clang/docs/OpenCLSupport.rst


Index: clang/docs/OpenCLSupport.rst
===
--- clang/docs/OpenCLSupport.rst
+++ clang/docs/OpenCLSupport.rst
@@ -96,3 +96,57 @@
 
+--+--+--+---+
 | New functionality| Atomic mem scopes: subgroup, all devices 
including functions | :part:`worked on`| https://reviews.llvm.org/D92004 
(functions only)  |
 
+--+--+--+---+
+
+Experimental features
+=
+
+Clang provides the following new WIP features for the developers to experiment
+and provide early feedback or contribute with further improvements.
+Feel free to contact us on `cfe-dev
+`_ or via `Bugzilla
+`_.
+
+C++ libraries for OpenCL
+
+
+There is ongoing work to support C++ standard libraries from `LLVM's libcxx
+`_ in OpenCL kernel code using C++ for OpenCL mode.
+
+It is currently possible to include `type_traits` from C++17 in the kernel
+sources when the following clang extensions are enabled
+``__cl_clang_function_pointers`` and ``__cl_clang_variadic_functions``,
+see :doc:`LanguageExtensions` for more details. The use of non-conformant
+features enabled by the extensions does not expose non-conformant behavior
+beyond the compilation i.e. does not get generated in IR or binary.
+The extension only appear in metaprogramming
+mechanism to identify or verify the properties of types. This allows to provide
+the full C++ functionality without a loss of portability. To avoid unsafe use
+of the extensions it is recommended that the extensions are disabled directly
+after the header include.
+
+**Example of Use**:
+
+The example of kernel code with `type_traits` is illustrated here.
+
+.. code-block:: c++
+
+  #pragma OPENCL EXTENSION __cl_clang_function_pointers : enable
+  #pragma OPENCL EXTENSION __cl_clang_variadic_functions : enable
+  #include 
+  #pragma OPENCL EXTENSION __cl_clang_function_pointers : disable
+  #pragma OPENCL EXTENSION __cl_clang_variadic_functions : disable
+ 
+  using sint_type = std::make_signed::type;
+
+  __kernel void foo() {
+static_assert(!std::is_same::value);
+  }
+
+The possible clang invocation to compile the example is as follows:
+
+   .. code-block:: console
+
+ $ clang -cl-std=clc++  -I/include test.cl
+
+Note that `type_traits` is a header only library and therefore no extra
+linking step against the standard libraries is required.


Index: clang/docs/OpenCLSupport.rst
===
--- clang/docs/OpenCLSupport.rst
+++ clang/docs/OpenCLSupport.rst
@@ -96,3 +96,57 @@
 +--+--+--+---+
 | New functionality| Atomic mem scopes: subgroup, all devices including functions | :part:`worked on`| https://reviews.llvm.org/D92004 (functions only)  |
 +--+--+--+---+
+
+Experimental features
+=
+
+Clang provides the following new WIP features for the developers to experiment
+and provide early feedback or contribute with further improvements.
+Feel free to contact us on `cfe-dev
+`_ or via `Bugzilla
+`_.
+
+C++ libraries for OpenCL
+
+
+There is ongoing work to support C++ standard libraries from `LLVM's libcxx
+`_ in OpenCL kernel code using C++ for OpenCL mode.
+
+It is currently possible to include `type_traits` from C++17 in the kernel
+sources when the following clang extensions are enabled
+``__cl_clang_function_pointers`` and ``__cl_clang_variadic_functions``,
+see :doc:`LanguageExtensions` for more details. The use of non-conformant
+features enabled by the extensions does not expose non-conformant behavior
+beyond the compilation i.e. does not get generated in IR or binary.
+The extension only appear in metaprogramming
+mechanism to identify or verify the properties of types. This allows to pr

  1   2   >