[PATCH] D62115: fix a issue that clang is incompatible with gcc with -H option.

2019-05-20 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: lib/Frontend/HeaderIncludeGen.cpp:56
+  if (Filename.startswith("./"));
+Filename=Filename.substr(2);
+

Formatting


Repository:
  rC Clang

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

https://reviews.llvm.org/D62115



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


[PATCH] D62115: fix a issue that clang is incompatible with gcc with -H option.

2019-05-20 Thread Xiang Zhang via Phabricator via cfe-commits
xiangzhangllvm added inline comments.



Comment at: lib/Frontend/HeaderIncludeGen.cpp:55
+  // Simplify Filename that starts with "./"
+  if (Filename.startswith("./"));
+Filename=Filename.substr(2);

Need remove ";" ? 


Repository:
  rC Clang

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

https://reviews.llvm.org/D62115



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


[PATCH] D61722: [AST] Add RecoveryExpr; produce it on overload resolution failure and missing member.

2019-05-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D61722#1504376 , @sammccall wrote:

> In D61722#1503863 , @rsmith wrote:
>
> > I expect we'll want a `ContainsErrors` bit on `Stmt`, propagated similarly 
> > to the existing `InstantiationDependent` / 
> > `ContainsUnexpandedParameterPack` / ... bits.
>
>
> This sounds good (as an alternative to using dependent bits for this).
>
> Do you think we want a similar bit on `Type` (set on e.g. `vector`) 
> , or should be ensure `ErrorTy` never gets used for compound types?


The simplest thing to do might be to ensure that `vector` is itself 
`ErrorTy`. There might be some cases where we can get better recovery by 
keeping a more precise type (eg, maybe we can infer something from an operation 
on `ErrorTy*` that we couldn't infer from merely `ErrorTy`), but I suspect the 
added complexity isn't worthwhile.

>> For example, the constant evaluator will want to quickly bail out of 
>> evaluating expressions and statements containing errors, and the error 
>> recovery `TreeTransform` that we perform to fix typos will want that too 
>> (and maybe could be able to fix other kinds of errors for which we build 
>> these error nodes eventually?).
> 
> Definitely possible, I don't know whether it's worth it or not:
> 
> 1. errors that can be recovered eagerly: They are, and `RecoveryExpr` or 
> equivalent never kicks in here. This seems ideal.
> 2. errors that can never be recovered: returned as `RecoveryExpr` or 
> equivalent. This is a difference from current TypoExpr which never does this.
> 3. errors that must be recovered lazily: we could e.g. add TypoExpr-style 
> recovery callbacks to `RecoveryExpr` and merge the two concepts. I don't have 
> a clear idea of how large/important this category is compared to 1 though.

Well, typo correction would be in case 1: we can recover from typos eagerly, 
but we choose to defer them because we might be able to figure out a better 
recovery based on looking at context that we don't have yet. The same is 
probably true for a lot of our error recovery, but it's probably not worth it 
most of the time. So I think it's more of a question of balancing when it's 
worthwhile to save enough state to recover.

What kinds of cases are you thinking of that would be in your second category? 
The examples you give for `RecoveryExpr` (a call that can't be resolved and a 
member access that can't be resolved) are *already* in case 3 when the reason 
they can't be resolved is due to a typo within them. We model that today by 
treating them as dependent in the initial parse, but that's problematic and we 
will want to use whatever replacement mechanism we come up with here instead.

Looking at your current uses for `RecoveryExpr`, I'm not sure whether adding a 
new AST node is the right model:

> a function call where overload resolution failed (most typically: wrong args) 
> Callee is captured as an UnresolvedLookupExpr, and args are captured. Type is 
> available if the "best" candidates have the same return type.

I would assume that we would represent a function call for which the callee or 
an argument contains an error as a `CallExpr` with the "contains error" flag 
set and with `ErrorTy` as its type. Could we use the same representation here? 
(That is, represent this case as a `CallExpr` whose type is `ErrorTy` with the 
"contains error" flag set, with no `RecoveryExpr`.)

> access of a nonexistent member Base expression is captured, type is never 
> available.

Using `UnresolvedMemberExpr` for this case might make sense. I think we should 
think about how we'd represent a member access that can't be fully analyzed 
because the object expression contains errors, and think about whether it makes 
sense to use that same representation for the case where the error is 
immediately in forming the member access itself. (And similarly across all 
other kinds of recovery expression we might create.)

If we want to enable (eg) AST matchers to operate on erroneous AST, using a 
homogeneous `RecoveryExpr` for all different syntaxes that originate errors 
seems like it would introduce complexity, especially if all consumers of the 
AST already need to deal with the case that some existing AST node is marked as 
being erroneous so don't get any benefit from having a concrete `RecoveryExpr` 
as a known stopping point. (If you get there, you've probably already gone too 
far.)


Repository:
  rC Clang

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

https://reviews.llvm.org/D61722



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


[PATCH] D62115: fix a issue that clang is incompatible with gcc with -H option.

2019-05-20 Thread Kan Shengchen via Phabricator via cfe-commits
skan updated this revision to Diff 200212.
skan added a comment.

remove ";" and format the code


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

https://reviews.llvm.org/D62115

Files:
  lib/Frontend/HeaderIncludeGen.cpp
  test/Driver/clang_H_opt.c
  test/Driver/clang_H_opt.h


Index: test/Driver/clang_H_opt.h
===
--- /dev/null
+++ test/Driver/clang_H_opt.h
@@ -0,0 +1,2 @@
+// This header file is included by clang_H_opt.c. It can not be deleted,
+// otherwise Clang will complain when compiling the clang_H_opt.c.
Index: test/Driver/clang_H_opt.c
===
--- /dev/null
+++ test/Driver/clang_H_opt.c
@@ -0,0 +1,6 @@
+// RUN: %clang -H -fsyntax-only %s 2>&1 | FileCheck %s
+
+#include "clang_H_opt.h"
+// CHECK: .
+// CHECK-NOT: ./
+// CHECK-SAME: clang_H_opt.h
Index: lib/Frontend/HeaderIncludeGen.cpp
===
--- lib/Frontend/HeaderIncludeGen.cpp
+++ lib/Frontend/HeaderIncludeGen.cpp
@@ -51,6 +51,10 @@
 static void PrintHeaderInfo(raw_ostream *OutputFile, StringRef Filename,
 bool ShowDepth, unsigned CurrentIncludeDepth,
 bool MSStyle) {
+  // Simplify Filename that starts with "./"
+  if (Filename.startswith("./"))
+Filename = Filename.substr(2);
+
   // Write to a temporary string to avoid unnecessary flushing on errs().
   SmallString<512> Pathname(Filename);
   if (!MSStyle)


Index: test/Driver/clang_H_opt.h
===
--- /dev/null
+++ test/Driver/clang_H_opt.h
@@ -0,0 +1,2 @@
+// This header file is included by clang_H_opt.c. It can not be deleted,
+// otherwise Clang will complain when compiling the clang_H_opt.c.
Index: test/Driver/clang_H_opt.c
===
--- /dev/null
+++ test/Driver/clang_H_opt.c
@@ -0,0 +1,6 @@
+// RUN: %clang -H -fsyntax-only %s 2>&1 | FileCheck %s
+
+#include "clang_H_opt.h"
+// CHECK: .
+// CHECK-NOT: ./
+// CHECK-SAME: clang_H_opt.h
Index: lib/Frontend/HeaderIncludeGen.cpp
===
--- lib/Frontend/HeaderIncludeGen.cpp
+++ lib/Frontend/HeaderIncludeGen.cpp
@@ -51,6 +51,10 @@
 static void PrintHeaderInfo(raw_ostream *OutputFile, StringRef Filename,
 bool ShowDepth, unsigned CurrentIncludeDepth,
 bool MSStyle) {
+  // Simplify Filename that starts with "./"
+  if (Filename.startswith("./"))
+Filename = Filename.substr(2);
+
   // Write to a temporary string to avoid unnecessary flushing on errs().
   SmallString<512> Pathname(Filename);
   if (!MSStyle)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59887: [Syntax] Introduce TokenBuffer, start clangToolingSyntax library

2019-05-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 200213.
ilya-biryukov marked 3 inline comments as done.
ilya-biryukov added a comment.

- Fix a comment, reformat
- Use assertions instead of returning optionals


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59887

Files:
  clang/include/clang/Tooling/Syntax/Tokens.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/Syntax/CMakeLists.txt
  clang/lib/Tooling/Syntax/Tokens.cpp
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/Syntax/CMakeLists.txt
  clang/unittests/Tooling/Syntax/TokensTest.cpp

Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -0,0 +1,654 @@
+//===- TokensTest.cpp -===//
+//
+// 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
+//
+//===--===//
+
+#include "clang/Tooling/Syntax/Tokens.h"
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/Expr.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticIDs.h"
+#include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/FileSystemOptions.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.def"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/Frontend/Utils.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Lex/Token.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include "llvm/Support/raw_os_ostream.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Testing/Support/Annotations.h"
+#include "llvm/Testing/Support/SupportHelpers.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+using namespace clang;
+using namespace clang::syntax;
+
+using llvm::ValueIs;
+using ::testing::AllOf;
+using ::testing::Contains;
+using ::testing::ElementsAre;
+using ::testing::Matcher;
+using ::testing::Not;
+using ::testing::StartsWith;
+
+namespace {
+// Checks the passed ArrayRef has the same begin() and end() iterators as the
+// argument.
+MATCHER_P(SameRange, A, "") {
+  return A.begin() == arg.begin() && A.end() == arg.end();
+}
+// Matchers for syntax::Token.
+MATCHER_P(Kind, K, "") { return arg.kind() == K; }
+MATCHER_P2(HasText, Text, SourceMgr, "") {
+  return arg.text(*SourceMgr) == Text;
+}
+/// Checks the start and end location of a token are equal to SourceRng.
+MATCHER_P(RangeIs, SourceRng, "") {
+  return arg.location() == SourceRng.first &&
+ arg.endLocation() == SourceRng.second;
+}
+
+class TokenCollectorTest : public ::testing::Test {
+public:
+  /// Run the clang frontend, collect the preprocessed tokens from the frontend
+  /// invocation and store them in this->Buffer.
+  /// This also clears SourceManager before running the compiler.
+  void recordTokens(llvm::StringRef Code) {
+class RecordTokens : public ASTFrontendAction {
+public:
+  explicit RecordTokens(TokenBuffer &Result) : Result(Result) {}
+
+  bool BeginSourceFileAction(CompilerInstance &CI) override {
+assert(!Collector && "expected only a single call to BeginSourceFile");
+Collector.emplace(CI.getPreprocessor());
+return true;
+  }
+  void EndSourceFileAction() override {
+assert(Collector && "BeginSourceFileAction was never called");
+Result = std::move(*Collector).consume();
+  }
+
+  std::unique_ptr
+  CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override {
+return llvm::make_unique();
+  }
+
+private:
+  TokenBuffer &Result;
+  llvm::Optional Collector;
+};
+
+constexpr const char *FileName = "./input.cpp";
+FS->addFile(FileName, time_t(), llvm::MemoryBuffer::getMemBufferCopy(""));
+// Prepare to run a compiler.
+std::vector Args = {"tok-test", "-std=c++03", "-fsyntax-only",
+  FileName};
+auto CI = createInvocationFromCommandLine(Args, Diags, FS);
+assert(CI);
+CI->getFrontendOpts().DisableFree = false;
+CI->getPreprocessorOpts().addRemappedFile(
+

[PATCH] D59887: [Syntax] Introduce TokenBuffer, start clangToolingSyntax library

2019-05-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:115
+  /// expansion.
+  llvm::Optional range(const SourceManager &SM) const;
+

sammccall wrote:
> ilya-biryukov wrote:
> > sammccall wrote:
> > > I think this might need a more explicit name. It's reasonably obvious 
> > > that this needs to be optional for some cases (token pasting), but it's 
> > > not obvious at callsites that (or why) we don't use the spelling location 
> > > for macro-expanded tokens.
> > > 
> > > One option would be just do that and add an expandedFromMacro() helper so 
> > > the no-macros version is easy to express too.
> > > If we can't do that, maybe `directlySpelledRange` or something?
> > As mentioned in the offline conversation, the idea is that mapping from a 
> > token inside a macro expansion to a spelled token should be handled by 
> > `TokenBuffer` and these two functions is really just a convenience helper 
> > to get to a range *after* the mapping.
> > 
> > This change has been boiling for some time and I think the other bits of it 
> > seem to be non-controversial and agreed upon.
> > Would it be ok if we land it with this function using a more concrete name 
> > (`directlySpelledRange` or something else) or move it into a separate 
> > change?
> > 
> > There's a follow-up change that adds an 'expand macro' action to clangd, 
> > which both has a use-site for these method and provides a functional 
> > feature based on `TokenBuffer`. Iterating on the design with (even a 
> > single) use-case should be simpler.
> If we do want to reflect expanded/spelled as types, this will rapidly get 
> harder to change. But we do need to make progress here.
> 
> If passing spelled tokens is the intended/well-understood use, let's just 
> assert on that and not return Optional. Then I'm less worried about the name: 
> misuse will be reliably punished.
Added an assertion. Not sure about the name, kept `range` for now for the lack 
of a better alternative.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59887



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


[PATCH] D61974: [ObjC] Fix encoding of ObjC pointer types that are pointers to typedefs

2019-05-20 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 200216.
ahatanak marked an inline comment as done.
ahatanak added a comment.

Delete the entire code path that tries to work around a bug in gcc.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61974

Files:
  lib/AST/ASTContext.cpp
  test/CodeGenObjC/encode-test-6.m
  test/CodeGenObjC/encode-test.m
  test/CodeGenObjCXX/encode.mm


Index: test/CodeGenObjCXX/encode.mm
===
--- test/CodeGenObjCXX/encode.mm
+++ test/CodeGenObjCXX/encode.mm
@@ -242,6 +242,6 @@
 @end
 
 const char *expand_struct() {
-  // CHECK: @{{.*}} = private unnamed_addr constant [16 x i8] 
c"{N={S=^{N}}}\00"
+  // CHECK: @{{.*}} = private unnamed_addr constant [13 x i8] 
c"{N={S=@}}\00"
   return @encode(N);
 }
Index: test/CodeGenObjC/encode-test.m
===
--- test/CodeGenObjC/encode-test.m
+++ test/CodeGenObjC/encode-test.m
@@ -107,7 +107,7 @@
 // CHECK: @g4 = constant [6 x i8] c"{S=i}\00"
 const char g4[] = @encode(const struct S);
 
-// CHECK: @g5 = constant [12 x i8] c"^{Object=#}\00"
+// CHECK: @g5 = constant [2 x i8] c"@\00"
 const char g5[] = @encode(MyObj * const);
 
 
Index: test/CodeGenObjC/encode-test-6.m
===
--- test/CodeGenObjC/encode-test-6.m
+++ test/CodeGenObjC/encode-test-6.m
@@ -34,7 +34,7 @@
 @synthesize property = _property;
 @end
 
-// CHECK: private unnamed_addr constant [24 x i8] c"^{BABugExample=@}16
+// CHECK: private unnamed_addr constant [8 x i8] c"@16
 
 // rdar://14408244
 @class SCNCamera;
@@ -52,7 +52,7 @@
 C3DCameraStorage _storage;
 }
 @end
-// CHECK: private unnamed_addr constant [39 x i8] 
c"{?=\22presentationInstance\22^{SCNCamera}}\00"
+// CHECK: private unnamed_addr constant [39 x i8] 
c"{?=\22presentationInstance\22@\22SCNCamera\22}\00"
 
 // rdar://16655340
 int i;
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -6969,36 +6969,6 @@
   return;
 }
 
-QualType PointeeTy = OPT->getPointeeType();
-if (!Options.EncodingProperty() &&
-isa(PointeeTy.getTypePtr()) &&
-!Options.EncodePointerToObjCTypedef()) {
-  // Another historical/compatibility reason.
-  // We encode the underlying type which comes out as
-  // {...};
-  S += '^';
-  if (FD && OPT->getInterfaceDecl()) {
-// Prevent recursive encoding of fields in some rare cases.
-ObjCInterfaceDecl *OI = OPT->getInterfaceDecl();
-SmallVector Ivars;
-DeepCollectObjCIvars(OI, true, Ivars);
-for (unsigned i = 0, e = Ivars.size(); i != e; ++i) {
-  if (Ivars[i] == FD) {
-S += '{';
-S += OI->getObjCRuntimeNameAsString();
-S += '}';
-return;
-  }
-}
-  }
-  ObjCEncOptions NewOptions =
-  ObjCEncOptions().setEncodePointerToObjCTypedef();
-  if (Options.ExpandPointedToStructures())
-NewOptions.setExpandStructures();
-  getObjCEncodingForTypeImpl(PointeeTy, S, NewOptions, /*Field=*/nullptr);
-  return;
-}
-
 S += '@';
 if (OPT->getInterfaceDecl() &&
 (FD || Options.EncodingProperty() || Options.EncodeClassNames())) {


Index: test/CodeGenObjCXX/encode.mm
===
--- test/CodeGenObjCXX/encode.mm
+++ test/CodeGenObjCXX/encode.mm
@@ -242,6 +242,6 @@
 @end
 
 const char *expand_struct() {
-  // CHECK: @{{.*}} = private unnamed_addr constant [16 x i8] c"{N={S=^{N}}}\00"
+  // CHECK: @{{.*}} = private unnamed_addr constant [13 x i8] c"{N={S=@}}\00"
   return @encode(N);
 }
Index: test/CodeGenObjC/encode-test.m
===
--- test/CodeGenObjC/encode-test.m
+++ test/CodeGenObjC/encode-test.m
@@ -107,7 +107,7 @@
 // CHECK: @g4 = constant [6 x i8] c"{S=i}\00"
 const char g4[] = @encode(const struct S);
 
-// CHECK: @g5 = constant [12 x i8] c"^{Object=#}\00"
+// CHECK: @g5 = constant [2 x i8] c"@\00"
 const char g5[] = @encode(MyObj * const);
 
 
Index: test/CodeGenObjC/encode-test-6.m
===
--- test/CodeGenObjC/encode-test-6.m
+++ test/CodeGenObjC/encode-test-6.m
@@ -34,7 +34,7 @@
 @synthesize property = _property;
 @end
 
-// CHECK: private unnamed_addr constant [24 x i8] c"^{BABugExample=@}16
+// CHECK: private unnamed_addr constant [8 x i8] c"@16
 
 // rdar://14408244
 @class SCNCamera;
@@ -52,7 +52,7 @@
 C3DCameraStorage _storage;
 }
 @end
-// CHECK: private unnamed_addr constant [39 x i8] c"{?=\22presentationInstance\22^{SCNCamera}}\00"
+// CHECK: private unnamed_addr constant [39 x i8] c"{?=\22presentationInstance\22@\22SCNCamera\22}\00"
 
 // rdar://16655340
 int i

[PATCH] D62125: Run ClangTidy tests in all C++ language modes

2019-05-20 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
gribozavr added a reviewer: alexfh.
Herald added subscribers: cfe-commits, lebedev.ri, jdoerfert, arphaman, 
kbarton, nemanjai.
Herald added a reviewer: lebedev.ri.
Herald added a project: clang.

I inspected every test and did one of the following:

- changed the test to run in all language modes,

- added a comment explaining why the test is only applicable in a certain mode,

- limited the test to language modes where it passes and added a FIXME to fix 
the checker or the test.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62125

Files:
  clang-tools-extra/test/clang-tidy/abseil-duration-unnecessary-conversion.cpp
  clang-tools-extra/test/clang-tidy/abseil-faster-strsplit-delimiter.cpp
  clang-tools-extra/test/clang-tidy/abseil-str-cat-append.cpp
  clang-tools-extra/test/clang-tidy/abseil-string-find-startswith.cpp
  clang-tools-extra/test/clang-tidy/abseil-time-subtraction.cpp
  clang-tools-extra/test/clang-tidy/abseil-upgrade-duration-conversions.cpp
  clang-tools-extra/test/clang-tidy/bugprone-dangling-handle.cpp
  clang-tools-extra/test/clang-tidy/bugprone-exception-escape.cpp
  clang-tools-extra/test/clang-tidy/bugprone-forwarding-reference-overload.cpp
  clang-tools-extra/test/clang-tidy/bugprone-inaccurate-erase.cpp
  clang-tools-extra/test/clang-tidy/bugprone-move-forwarding-reference.cpp
  clang-tools-extra/test/clang-tidy/bugprone-sizeof-container.cpp
  clang-tools-extra/test/clang-tidy/cert-err34-c.cpp
  clang-tools-extra/test/clang-tidy/cert-msc51-cpp.cpp
  clang-tools-extra/test/clang-tidy/cert-oop11-cpp.cpp
  clang-tools-extra/test/clang-tidy/cert-setlongjmp.cpp
  clang-tools-extra/test/clang-tidy/cert-throw-exception-type.cpp
  clang-tools-extra/test/clang-tidy/check_clang_tidy.py
  
clang-tools-extra/test/clang-tidy/cppcoreguidelines-owning-memory-legacy-functions.cpp
  
clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp
  
clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-gslheader.cpp
  
clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic-pr36489.cpp
  
clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx2a.cpp
  
clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
  clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
  
clang-tools-extra/test/clang-tidy/cppcoreguidelines-special-member-functions-cxx-03.cpp
  clang-tools-extra/test/clang-tidy/expand-modular-headers-ppcallbacks.cpp
  clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes-all.cpp
  clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes-glob.cpp
  clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp
  clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes.cpp
  clang-tools-extra/test/clang-tidy/google-readability-casting.cpp
  clang-tools-extra/test/clang-tidy/google-runtime-int-std.cpp
  clang-tools-extra/test/clang-tidy/google-runtime-references.cpp
  clang-tools-extra/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp
  clang-tools-extra/test/clang-tidy/hicpp-signed-bitwise.cpp
  clang-tools-extra/test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp
  clang-tools-extra/test/clang-tidy/misc-new-delete-overloads.cpp
  clang-tools-extra/test/clang-tidy/misc-redundant-expression.cpp
  clang-tools-extra/test/clang-tidy/misc-throw-by-value-catch-by-reference.cpp
  
clang-tools-extra/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp
  clang-tools-extra/test/clang-tidy/misc-unconventional-assign-operator.cpp
  clang-tools-extra/test/clang-tidy/misc-unused-parameters.cpp
  clang-tools-extra/test/clang-tidy/modernize-avoid-bind.cpp
  clang-tools-extra/test/clang-tidy/modernize-concat-nested-namespaces.cpp
  clang-tools-extra/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
  clang-tools-extra/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
  clang-tools-extra/test/clang-tidy/modernize-loop-convert-basic.cpp
  clang-tools-extra/test/clang-tidy/modernize-loop-convert-camelback.cpp
  clang-tools-extra/test/clang-tidy/modernize-loop-convert-const.cpp
  clang-tools-extra/test/clang-tidy/modernize-loop-convert-extra.cpp
  clang-tools-extra/test/clang-tidy/modernize-loop-convert-lowercase.cpp
  clang-tools-extra/test/clang-tidy/modernize-loop-convert-negative.cpp
  clang-tools-extra/test/clang-tidy/modernize-loop-convert-uppercase.cpp
  clang-tools-extra/test/clang-tidy/modernize-make-shared-header.cpp
  clang-tools-extra/test/clang-tidy/modernize-make-shared.cpp
  clang-tools-extra/test/clang-tidy/modernize-make-unique-cxx11.cpp
  clang-tools-extra/test/clang-tidy/modernize-make-unique-cxx14.cpp
  clang-tools-extra/test/clang-tidy/modernize-make-unique-header.cpp
  clang-tools-extra/test/clang-tidy/modernize-make-unique-macros.cpp
  clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp
  clang-t

[PATCH] D62125: Run ClangTidy tests in all C++ language modes

2019-05-20 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Wow, a lot of work!

I did not check all test files, but I saw that you explicitly enabled 
c++11,14,17 but not 98. Is there a reason for that? I think we should test that 
standard too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62125



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


[PATCH] D62127: [Hexagon] driver uses out-of-date option name and binary name

2019-05-20 Thread A. Skrobov via Phabricator via cfe-commits
t.yomitch created this revision.
t.yomitch added reviewers: kparzysz, sidneym, sgundapa.
Herald added a project: clang.

Repository:
  rC Clang

https://reviews.llvm.org/D62127

Files:
  lib/Driver/ToolChains/Hexagon.cpp


Index: lib/Driver/ToolChains/Hexagon.cpp
===
--- lib/Driver/ToolChains/Hexagon.cpp
+++ lib/Driver/ToolChains/Hexagon.cpp
@@ -130,11 +130,11 @@
   const Driver &D = HTC.getDriver();
   ArgStringList CmdArgs;
 
-  CmdArgs.push_back("-march=hexagon");
+  CmdArgs.push_back("--arch=hexagon");
 
   RenderExtraToolArgs(JA, CmdArgs);
 
-  const char *AsName = "hexagon-llvm-mc";
+  const char *AsName = "llvm-mc";
   CmdArgs.push_back("-filetype=obj");
   CmdArgs.push_back(Args.MakeArgString(
   "-mcpu=hexagon" +


Index: lib/Driver/ToolChains/Hexagon.cpp
===
--- lib/Driver/ToolChains/Hexagon.cpp
+++ lib/Driver/ToolChains/Hexagon.cpp
@@ -130,11 +130,11 @@
   const Driver &D = HTC.getDriver();
   ArgStringList CmdArgs;
 
-  CmdArgs.push_back("-march=hexagon");
+  CmdArgs.push_back("--arch=hexagon");
 
   RenderExtraToolArgs(JA, CmdArgs);
 
-  const char *AsName = "hexagon-llvm-mc";
+  const char *AsName = "llvm-mc";
   CmdArgs.push_back("-filetype=obj");
   CmdArgs.push_back(Args.MakeArgString(
   "-mcpu=hexagon" +
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62125: Run ClangTidy tests in all C++ language modes

2019-05-20 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

That's a quite impressive amount of work. Thanks! Looks good.

In D62125#1508113 , @JonasToth wrote:

> Wow, a lot of work!
>
> I did not check all test files, but I saw that you explicitly enabled 
> c++11,14,17 but not 98. Is there a reason for that? I think we should test 
> that standard too.


Having seen the amount of work out into this I wouldn't demand c++98 coverage 
from Dimitri. It's a huge improvement already and c++98 coverage is a rather 
niche thing there days. I believe, someone with genuine need for C++98 support 
can work on that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62125



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


[PATCH] D62125: Run ClangTidy tests in all C++ language modes

2019-05-20 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

> c++98 coverage is a rather niche thing there days. I believe, someone with 
> genuine need for C++98 support can work on that.

+1, that's exactly the reason why I skipped 98.  C++98 is 21 years old now (or 
16 if you count from C++03).  Most projects that build with a modern toolchain 
and care about code quality enough to run static analysis tools have migrated 
to C++11.  Many ClangTidy checkers have not even been tested *ever* on 98, many 
(`modernize-*`) don't apply in 98.

We wouldn't refuse patches to annotate tests with C++98 support or fix bugs in 
C++98 mode, but I believe as far as ClangTidy is concerned C++98 is a niche use 
case, so I personally find it difficult to justify spending my time on it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62125



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


[PATCH] D61722: [AST] Add RecoveryExpr; produce it on overload resolution failure and missing member.

2019-05-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added subscribers: gribozavr, klimek.
sammccall added a comment.

In D61722#1508050 , @rsmith wrote:

> The simplest thing to do might be to ensure that `vector` is itself 
> `ErrorTy`.


You're probably right, I'll try this.

> For example, the constant evaluator will want to quickly bail out of 
> evaluating expressions and statements containing errors

Thinking more - how important is this? These expressions are expected to be 
rare.
Discussing offline with @gribozavr, it seemed likely we could get away with the 
"errorness" of an expr being a local property, which would be simplifying. 
(Whereas the errorness of a type needs to be a transitive one).

> What kinds of cases are you thinking of that would be in your second category?

Incomplete code, either new code or during refactoring

- not enough arguments
- symbol not found due to missing #include
- member not added yet
- function not defined yet

In an IDE context, it's *much* more important that diagnostics are useful and 
AST nodes aren't discarded, than that recovery correctly "fixes" the AST to 
have the intended semantics.

From that point of view, typo recovery/TypoExpr spends too much complexity 
budget on accurate recovery, rather than generality. RecoveryExpr is a 
different part of the design space for sure.

> I would assume that we would represent a function call for which the callee 
> or an argument contains an error as a `CallExpr` with the "contains error" 
> flag set and with `ErrorTy` as its type.

Almost:

- if the argument has an error, but its type is still known, then overload 
resolution runs as normal and this CallExpr doesn't itself have an error. (If 
there's a **transitive** HasError bit on Expr, it would be set).
- if the argument has an error and has ErrorTy, overload resolution may still 
succeed (depending on the rules we choose for ErrorTy). In which case again, 
the CallExpr itself has no error.
- if the argument has an error and has ErrorTy, and this causes overload 
resolution to fail, but all (best) overloads have the same type, we get a 
RecoveryExpr/CallExpr-with-error with a real type
- if the argument has an error and has ErrorTy, and this causes overload 
resolution to fail, and the type is unknown, then we get a 
RecoveryExpr/CallExpr-with-error with ErrorTy.

> Could we use the same representation here? (That is, represent this case as a 
> `CallExpr` whose type is `ErrorTy` with the "contains error" flag set, with 
> no `RecoveryExpr`.)

We can, but it breaks a lot of client code. These two cases are pretty 
different for clients:

- for an otherwise-valid CallExpr where one argument has errors, all the 
*local* invariants are preserved.
- for a CallExpr where callee is null, or the #args don't match the function, 
the client code often crashed or did the wrong thing.

My view is that we're fundamentally better having two types to keep the 
guarantees around `CallExpr` stronger. That we want matchers to "match through" 
RecoveryExpr, but callExpr shouldn't match here.
@ilya-biryukov disagreed and thought the main virtue of `RecoveryExpr` is 
backwards-compatibility.
Either way, I'm not optimistic about being able to get recovery changes to 
stick under this model. I'm willing to try if you feel strongly.

>> access of a nonexistent member Base expression is captured, type is never 
>> available.
> 
> Using `UnresolvedMemberExpr` for this case might make sense. I think we 
> should think about how we'd represent a member access that can't be fully 
> analyzed because the object expression contains errors, and think about 
> whether it makes sense to use that same representation for the case where the 
> error is immediately in forming the member access itself. (And similarly 
> across all other kinds of recovery expression we might create.)

I agree it's important to be consistent here. It's hard work to be consistent 
and also precise!
Using RecoveryExpr for both cases seems sufficient to me, and one of its 
advantages is that it avoids having to make lots of hard decisions one-by-one, 
many of which will be wrong :-)

But that aside, I agree the best way to model that in the existing AST is make 
`UnresolvedMemberExpr` available in C, allow it to have no candidate decls, etc.
For the object expression, the error can be nested arbitrarily deep and I think 
we just have to apply whatever usual "subexpression-has-errors" strategy to 
`UnresolvedMemberExpr` and `MemberExpr`.

> If we want to enable (eg) AST matchers to operate on erroneous AST, using a 
> homogeneous `RecoveryExpr` for all different syntaxes that originate errors 
> seems like it would introduce complexity, especially if all consumers of the 
> AST already need to deal with the case that some existing AST node is marked 
> as being erroneous so don't get any benefit from having a concrete 
> `RecoveryExpr` as a known stopping point. (If you get there, you've probably 
> already gone too far.

[PATCH] D62115: fix a issue that clang is incompatible with gcc with -H option.

2019-05-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: lib/Frontend/HeaderIncludeGen.cpp:55
+  // Simplify Filename that starts with "./"
+  if (Filename.startswith("./"));
+Filename=Filename.substr(2);

xiangzhangllvm wrote:
> Need remove ";" ? 
This was fixed but no test was added?
Was some existing test failing previously? Which one?


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

https://reviews.llvm.org/D62115



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


[PATCH] D62131: [ASTImporter] Remove NonEquivalentDecls from ASTImporter

2019-05-20 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added a reviewer: a_sidorin.
Herald added subscribers: cfe-commits, gamesh411, Szelethus, dkrupp, rnkovacs.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: clang.

Currently ASTImporter::NonEquivalentDecls member keeps its state and
shares it between consecutive calls of
StructuralEquivalenceContesxt::IsEquivalent().  Thus, we cache
inequivalent pairs from a previous snapshot of the AST. However, we
continuously build the AST and a pair which used to be inequivalent may
be equivalent later (or vica-versa).  NonEquivalentDecls behaves
similarly to other internal states of StructuralEquivalenceContext
(TentativeEquivalences, DeclsToCheck).  I.e this state too should be
reset before each IsEquivalent() call.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62131

Files:
  clang/include/clang/AST/ASTImporter.h
  clang/include/clang/AST/ASTStructuralEquivalence.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/ASTMerge/class-template/test.cpp
  clang/test/ASTMerge/enum/test.c
  clang/test/ASTMerge/struct/test.c
  clang/unittests/AST/StructuralEquivalenceTest.cpp

Index: clang/unittests/AST/StructuralEquivalenceTest.cpp
===
--- clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -78,14 +78,12 @@
   }
 
   bool testStructuralMatch(Decl *D0, Decl *D1) {
-llvm::DenseSet> NonEquivalentDecls01;
-llvm::DenseSet> NonEquivalentDecls10;
-StructuralEquivalenceContext Ctx01(
-D0->getASTContext(), D1->getASTContext(),
-NonEquivalentDecls01, StructuralEquivalenceKind::Default, false, false);
-StructuralEquivalenceContext Ctx10(
-D1->getASTContext(), D0->getASTContext(),
-NonEquivalentDecls10, StructuralEquivalenceKind::Default, false, false);
+StructuralEquivalenceContext Ctx01(D0->getASTContext(), D1->getASTContext(),
+   StructuralEquivalenceKind::Default,
+   false, false);
+StructuralEquivalenceContext Ctx10(D1->getASTContext(), D0->getASTContext(),
+   StructuralEquivalenceKind::Default,
+   false, false);
 bool Eq01 = Ctx01.IsEquivalent(D0, D1);
 bool Eq10 = Ctx10.IsEquivalent(D1, D0);
 EXPECT_EQ(Eq01, Eq10);
Index: clang/test/ASTMerge/struct/test.c
===
--- clang/test/ASTMerge/struct/test.c
+++ clang/test/ASTMerge/struct/test.c
@@ -34,11 +34,6 @@
 // CHECK: struct1.c:56:10: warning: type 'struct DeeperError' has incompatible definitions in different translation units
 // CHECK: struct1.c:56:35: note: field 'f' has type 'int' here
 // CHECK: struct2.c:53:37: note: field 'f' has type 'float' here
-// CHECK: struct1.c:54:8: warning: type 'struct DeepError' has incompatible definitions in different translation units
-// CHECK: struct1.c:56:41: note: field 'Deeper' has type 'struct DeeperError *' here
-// CHECK: struct2.c:53:43: note: field 'Deeper' has type 'struct DeeperError *' here
-// CHECK: struct2.c:54:3: warning: external variable 'xDeep' declared with incompatible types in different translation units ('struct DeepError' vs. 'struct DeepError')
-// CHECK: struct1.c:57:3: note: declared here with type 'struct DeepError'
 // CHECK: struct1.c:74:9: warning: type 'S13' has incompatible definitions in different translation units
 // CHECK: struct1.c:75:9: note: field 'i' has type 'Float' (aka 'float') here
 // CHECK: struct2.c:72:7: note: field 'i' has type 'int' here
@@ -47,9 +42,5 @@
 // CHECK: struct1.c:130:7: warning: type 'struct DeepUnnamedError::(anonymous at [[PATH_TO_INPUTS:.+]]struct1.c:130:7)' has incompatible definitions in different translation units
 // CHECK: struct1.c:131:14: note: field 'i' has type 'long' here
 // CHECK: struct2.c:128:15: note: field 'i' has type 'float' here
-// CHECK: struct1.c:129:5: warning: type 'union DeepUnnamedError::(anonymous at [[PATH_TO_INPUTS]]struct1.c:129:5)' has incompatible definitions in different translation units
-// CHECK: struct1.c:132:9: note: field 'S' has type 'struct (anonymous struct at [[PATH_TO_INPUTS]]struct1.c:130:7)' here
-// CHECK: struct2.c:129:9: note: field 'S' has type 'struct (anonymous struct at [[PATH_TO_INPUTS]]struct2.c:127:7)' here
 // CHECK: struct2.c:138:3: warning: external variable 'x16' declared with incompatible types in different translation units ('struct DeepUnnamedError' vs. 'struct DeepUnnamedError')
 // CHECK: struct1.c:141:3: note: declared here with type 'struct DeepUnnamedError'
-// CHECK: 20 warnings generated
Index: clang/test/ASTMerge/enum/test.c
===
--- clang/test/ASTMerge/enum/test.c
+++ clang/test/ASTMe

[PATCH] D62009: [clang] perform semantic checking in constant context

2019-05-20 Thread Tyker via Phabricator via cfe-commits
Tyker updated this revision to Diff 200231.
Tyker edited the summary of this revision.

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

https://reviews.llvm.org/D62009

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CXX/expr/expr.const/p3-0x.cpp
  clang/test/Sema/integer-overflow.c
  clang/test/Sema/switch.c
  clang/test/SemaCXX/builtin-is-constant-evaluated.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/integer-overflow.cpp

Index: clang/test/SemaCXX/integer-overflow.cpp
===
--- clang/test/SemaCXX/integer-overflow.cpp
+++ clang/test/SemaCXX/integer-overflow.cpp
@@ -92,6 +92,7 @@
 // expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
   case ((1ULL * ((4608) * ((1024) * (1024))) + 2ULL)):
 return 9;
+// expected-warning@+3 {{implicit conversion}}
 // expected-warning@+2 2{{overflow in expression; result is 536870912 with type 'int'}}
 // expected-warning@+1 {{overflow converting case value to switch condition type (288230376151711744 to 0)}}
   case ((uint64_t)((uint64_t)(4608 * 1024 * 1024) * (uint64_t)(4608 * 1024 * 1024))):
Index: clang/test/SemaCXX/constant-expression-cxx11.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -438,8 +438,8 @@
 
 constexpr char c0 = "nought index"[0];
 constexpr char c1 = "nice index"[10];
-constexpr char c2 = "nasty index"[12]; // expected-error {{must be initialized by a constant expression}} expected-warning {{is past the end}} expected-note {{read of dereferenced one-past-the-end pointer}}
-constexpr char c3 = "negative index"[-1]; // expected-error {{must be initialized by a constant expression}} expected-warning {{is before the beginning}} expected-note {{cannot refer to element -1 of array of 15 elements}}
+constexpr char c2 = "nasty index"[12]; // expected-error {{must be initialized by a constant expression}} expected-note {{read of dereferenced one-past-the-end pointer}}
+constexpr char c3 = "negative index"[-1]; // expected-error {{must be initialized by a constant expression}} expected-note {{cannot refer to element -1 of array of 15 elements}}
 constexpr char c4 = ((char*)(int*)"no reinterpret_casts allowed")[14]; // expected-error {{must be initialized by a constant expression}} expected-note {{cast that performs the conversions of a reinterpret_cast}}
 
 constexpr const char *p = "test" + 2;
@@ -547,7 +547,7 @@
 constexpr int xs0 = p[-3]; // ok
 constexpr int xs_1 = p[-4]; // expected-error {{constant expression}} expected-note {{cannot refer to element -1}}
 
-constexpr int zs[2][2][2][2] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; // expected-note {{array 'zs' declared here}}
+constexpr int zs[2][2][2][2] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
 static_assert(zs[0][0][0][0] == 1, "");
 static_assert(zs[1][1][1][1] == 16, "");
 static_assert(zs[0][0][0][2] == 3, ""); // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end pointer}}
@@ -557,8 +557,7 @@
 static_assert(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][2] - 2) == 11, "");
 constexpr int err_zs_1_2_0_0 = zs[1][2][0][0]; // \
 expected-error {{constant expression}} \
-expected-note {{cannot access array element of pointer past the end}} \
-expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+expected-note {{cannot access array element of pointer past the end}}
 
 constexpr int fail(const int &p) {
   return (&p)[64]; // expected-note {{cannot refer to element 64 of array of 2 elements}}
Index: clang/test/SemaCXX/builtin-is-constant-evaluated.cpp
===
--- clang/test/SemaCXX/builtin-is-constant-evaluated.cpp
+++ clang/test/SemaCXX/builtin-is-constant-evaluated.cpp
@@ -119,3 +119,15 @@
 };
 TestConditionalExplicit e = 42;
 #endif
+
+constexpr int i1 = (long long)__builtin_is_constant_evaluated() * (1ll << 33);
+// expected-warning@-1 {{implicit conversion}}
+
+constexpr int i2 = (long long)!__builtin_is_constant_evaluated() * (1ll << 33);
+
+ void f(int i) {
+   switch (i) {
+   case (long long)__builtin_is_constant_evaluated() * (1ll << 33):;
+// expected-warning@-1 {{implicit conversion}}
+   }
+ }
Index: clang/test/Sema/switch.c
===
--- clang/test/Sema/switch.c
+++ clang/test/Sema/switch.c
@@ -8,7 +8,7 @@
 void foo(int X) {
   switch (X) {
   case 42: ; // expected-note {{previous case}}
-  case 50LL: // expected-warning {{overflow}}
+  case 50LL: // expected-warning {{overflow}} expected-warning {{implicit conversion}} 
   case 42:

[clang-tools-extra] r361138 - [clang-tidy] Sort this list alphabetically

2019-05-20 Thread Tamas Zolnai via cfe-commits
Author: ztamas
Date: Mon May 20 03:37:42 2019
New Revision: 361138

URL: http://llvm.org/viewvc/llvm-project?rev=361138&view=rev
Log:
[clang-tidy] Sort this list alphabetically

Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp?rev=361138&r1=361137&r2=361138&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp Mon May 
20 03:37:42 2019
@@ -100,8 +100,6 @@ public:
 "bugprone-move-forwarding-reference");
 CheckFactories.registerCheck(
 "bugprone-multiple-statement-macro");
-CheckFactories.registerCheck(
-"bugprone-too-small-loop-variable");
 CheckFactories.registerCheck(
 "bugprone-narrowing-conversions");
 CheckFactories.registerCheck(
@@ -132,6 +130,8 @@ public:
 "bugprone-terminating-continue");
 CheckFactories.registerCheck(
 "bugprone-throw-keyword-missing");
+CheckFactories.registerCheck(
+"bugprone-too-small-loop-variable");
 CheckFactories.registerCheck(
 "bugprone-undefined-memory-manipulation");
 CheckFactories.registerCheck(


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


[PATCH] D62066: [ASTImporter] Enable disabled but passing tests

2019-05-20 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361139: [ASTImporter] Enable disabled but passing tests 
(authored by martong, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62066?vs=200046&id=200239#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62066

Files:
  cfe/trunk/unittests/AST/ASTImporterTest.cpp
  cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp


Index: cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp
===
--- cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp
+++ cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp
@@ -300,8 +300,7 @@
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
-TEST_F(StructuralEquivalenceFunctionTest, DISABLED_NoexceptNonMatch) {
-  // The expression is not checked yet.
+TEST_F(StructuralEquivalenceFunctionTest, NoexceptNonMatch) {
   auto t = makeNamedDecls("void foo() noexcept(false);",
   "void foo() noexcept(true);", Lang_CXX11);
   EXPECT_FALSE(testStructuralMatch(t));
Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -2362,12 +2362,7 @@
   EXPECT_EQ(ToFD->getPreviousDecl(), ImportedD);
 }
 
-// Disabled temporarily, because the new structural equivalence check
-// (https://reviews.llvm.org/D48628) breaks it.
-// PreviousDecl is not set because there is no structural match.
-// FIXME Enable!
-TEST_P(ImportFriendFunctions,
-DISABLED_ImportFriendFunctionRedeclChainDefWithClass) {
+TEST_P(ImportFriendFunctions, ImportFriendFunctionRedeclChainDefWithClass) {
   auto Pattern = functionDecl(hasName("f"));
 
   Decl *FromTU = getTuDecl(
@@ -2395,12 +2390,8 @@
 (*ImportedD->param_begin())->getOriginalType());
 }
 
-// Disabled temporarily, because the new structural equivalence check
-// (https://reviews.llvm.org/D48628) breaks it.
-// PreviousDecl is not set because there is no structural match.
-// FIXME Enable!
 TEST_P(ImportFriendFunctions,
-DISABLED_ImportFriendFunctionRedeclChainDefWithClass_ImportTheProto) {
+   ImportFriendFunctionRedeclChainDefWithClass_ImportTheProto) {
   auto Pattern = functionDecl(hasName("f"));
 
   Decl *FromTU = getTuDecl(


Index: cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp
===
--- cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp
+++ cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp
@@ -300,8 +300,7 @@
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
-TEST_F(StructuralEquivalenceFunctionTest, DISABLED_NoexceptNonMatch) {
-  // The expression is not checked yet.
+TEST_F(StructuralEquivalenceFunctionTest, NoexceptNonMatch) {
   auto t = makeNamedDecls("void foo() noexcept(false);",
   "void foo() noexcept(true);", Lang_CXX11);
   EXPECT_FALSE(testStructuralMatch(t));
Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -2362,12 +2362,7 @@
   EXPECT_EQ(ToFD->getPreviousDecl(), ImportedD);
 }
 
-// Disabled temporarily, because the new structural equivalence check
-// (https://reviews.llvm.org/D48628) breaks it.
-// PreviousDecl is not set because there is no structural match.
-// FIXME Enable!
-TEST_P(ImportFriendFunctions,
-DISABLED_ImportFriendFunctionRedeclChainDefWithClass) {
+TEST_P(ImportFriendFunctions, ImportFriendFunctionRedeclChainDefWithClass) {
   auto Pattern = functionDecl(hasName("f"));
 
   Decl *FromTU = getTuDecl(
@@ -2395,12 +2390,8 @@
 (*ImportedD->param_begin())->getOriginalType());
 }
 
-// Disabled temporarily, because the new structural equivalence check
-// (https://reviews.llvm.org/D48628) breaks it.
-// PreviousDecl is not set because there is no structural match.
-// FIXME Enable!
 TEST_P(ImportFriendFunctions,
-DISABLED_ImportFriendFunctionRedeclChainDefWithClass_ImportTheProto) {
+   ImportFriendFunctionRedeclChainDefWithClass_ImportTheProto) {
   auto Pattern = functionDecl(hasName("f"));
 
   Decl *FromTU = getTuDecl(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62133: test/CodeGen/builtin-stackaddress.c duplicates test/CodeGen/2004-02-13-BuiltinFrameReturnAddress.c

2019-05-20 Thread A. Skrobov via Phabricator via cfe-commits
t.yomitch created this revision.
t.yomitch added reviewers: efriedma, echristo, ddunbar.
Herald added a subscriber: kristina.
Herald added a project: clang.

Repository:
  rC Clang

https://reviews.llvm.org/D62133

Files:
  test/CodeGen/builtin-stackaddress.c


Index: test/CodeGen/builtin-stackaddress.c
===
--- test/CodeGen/builtin-stackaddress.c
+++ /dev/null
@@ -1,9 +0,0 @@
-// RUN: %clang_cc1 -emit-llvm < %s | grep "llvm.returnaddress"
-// RUN: %clang_cc1 -emit-llvm < %s | grep "llvm.frameaddress"
-void* a(unsigned x) {
-return __builtin_return_address(0);
-}
-
-void* c(unsigned x) {
-return __builtin_frame_address(0);
-}


Index: test/CodeGen/builtin-stackaddress.c
===
--- test/CodeGen/builtin-stackaddress.c
+++ /dev/null
@@ -1,9 +0,0 @@
-// RUN: %clang_cc1 -emit-llvm < %s | grep "llvm.returnaddress"
-// RUN: %clang_cc1 -emit-llvm < %s | grep "llvm.frameaddress"
-void* a(unsigned x) {
-return __builtin_return_address(0);
-}
-
-void* c(unsigned x) {
-return __builtin_frame_address(0);
-}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61136: [Analyzer] Refactor begin and end symbol creation

2019-05-20 Thread Balogh, Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361141: [Analyzer] Refactor begin and end symbol creation 
(authored by baloghadamsoftware, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61136?vs=197980&id=200243#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61136

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -300,10 +300,13 @@
 SymbolRef getContainerBegin(ProgramStateRef State, const MemRegion *Cont);
 SymbolRef getContainerEnd(ProgramStateRef State, const MemRegion *Cont);
 ProgramStateRef createContainerBegin(ProgramStateRef State,
- const MemRegion *Cont,
- const SymbolRef Sym);
+ const MemRegion *Cont, const Expr *E,
+ QualType T, const LocationContext *LCtx,
+ unsigned BlockCount);
 ProgramStateRef createContainerEnd(ProgramStateRef State, const MemRegion *Cont,
-   const SymbolRef Sym);
+   const Expr *E, QualType T,
+   const LocationContext *LCtx,
+   unsigned BlockCount);
 const IteratorPosition *getIteratorPosition(ProgramStateRef State,
 const SVal &Val);
 ProgramStateRef setIteratorPosition(ProgramStateRef State, const SVal &Val,
@@ -1142,11 +1145,9 @@
   auto State = C.getState();
   auto BeginSym = getContainerBegin(State, ContReg);
   if (!BeginSym) {
-auto &SymMgr = C.getSymbolManager();
-BeginSym = SymMgr.conjureSymbol(CE, C.getLocationContext(),
-C.getASTContext().LongTy, C.blockCount());
-State = assumeNoOverflow(State, BeginSym, 4);
-State = createContainerBegin(State, ContReg, BeginSym);
+State = createContainerBegin(State, ContReg, CE, C.getASTContext().LongTy,
+ C.getLocationContext(), C.blockCount());
+BeginSym = getContainerBegin(State, ContReg);
   }
   State = setIteratorPosition(State, RetVal,
   IteratorPosition::getPosition(ContReg, BeginSym));
@@ -1166,11 +1167,9 @@
   auto State = C.getState();
   auto EndSym = getContainerEnd(State, ContReg);
   if (!EndSym) {
-auto &SymMgr = C.getSymbolManager();
-EndSym = SymMgr.conjureSymbol(CE, C.getLocationContext(),
-  C.getASTContext().LongTy, C.blockCount());
-State = assumeNoOverflow(State, EndSym, 4);
-State = createContainerEnd(State, ContReg, EndSym);
+State = createContainerEnd(State, ContReg, CE, C.getASTContext().LongTy,
+   C.getLocationContext(), C.blockCount());
+EndSym = getContainerEnd(State, ContReg);
   }
   State = setIteratorPosition(State, RetVal,
   IteratorPosition::getPosition(ContReg, EndSym));
@@ -1934,32 +1933,47 @@
 }
 
 ProgramStateRef createContainerBegin(ProgramStateRef State,
- const MemRegion *Cont,
- const SymbolRef Sym) {
+ const MemRegion *Cont, const Expr *E,
+ QualType T, const LocationContext *LCtx,
+ unsigned BlockCount) {
   // Only create if it does not exist
   const auto *CDataPtr = getContainerData(State, Cont);
+  if (CDataPtr && CDataPtr->getBegin())
+return State;
+
+  auto &SymMgr = State->getSymbolManager();
+  const SymbolConjured *Sym = SymMgr.conjureSymbol(E, LCtx, T, BlockCount,
+   "begin");
+  State = assumeNoOverflow(State, Sym, 4);
+
   if (CDataPtr) {
-if (CDataPtr->getBegin()) {
-  return State;
-}
 const auto CData = CDataPtr->newBegin(Sym);
 return setContainerData(State, Cont, CData);
   }
+
   const auto CData = ContainerData::fromBegin(Sym);
   return setContainerData(State, Cont, CData);
 }
 
 ProgramStateRef createContainerEnd(ProgramStateRef State, const MemRegion *Cont,
-   const SymbolRef Sym) {
+   const Expr *E, QualType T,
+   const LocationContext *LCtx,
+   unsigned BlockCount) {
   // Only create if it does not exist
   const auto *CDataPtr = getContainerData(State, Cont);
+  if (CDataPtr && CDataPtr->getEnd())
+return State;

r361141 - [Analyzer] Refactor begin and end symbol creation

2019-05-20 Thread Adam Balogh via cfe-commits
Author: baloghadamsoftware
Date: Mon May 20 04:04:27 2019
New Revision: 361141

URL: http://llvm.org/viewvc/llvm-project?rev=361141&view=rev
Log:
[Analyzer] Refactor begin and end symbol creation

This patch refactors begin and end symbol creation by moving symbol
conjuration into the `create...` functions. This way the functions'
responsibilities are clearer and makes possible to add more functions
handling these symbols (e.g. functions for handling the container's
size) without code multiplication.

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


Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp?rev=361141&r1=361140&r2=361141&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp Mon May 20 
04:04:27 2019
@@ -300,10 +300,13 @@ bool backModifiable(ProgramStateRef Stat
 SymbolRef getContainerBegin(ProgramStateRef State, const MemRegion *Cont);
 SymbolRef getContainerEnd(ProgramStateRef State, const MemRegion *Cont);
 ProgramStateRef createContainerBegin(ProgramStateRef State,
- const MemRegion *Cont,
- const SymbolRef Sym);
+ const MemRegion *Cont, const Expr *E,
+ QualType T, const LocationContext *LCtx,
+ unsigned BlockCount);
 ProgramStateRef createContainerEnd(ProgramStateRef State, const MemRegion 
*Cont,
-   const SymbolRef Sym);
+   const Expr *E, QualType T,
+   const LocationContext *LCtx,
+   unsigned BlockCount);
 const IteratorPosition *getIteratorPosition(ProgramStateRef State,
 const SVal &Val);
 ProgramStateRef setIteratorPosition(ProgramStateRef State, const SVal &Val,
@@ -1142,11 +1145,9 @@ void IteratorChecker::handleBegin(Checke
   auto State = C.getState();
   auto BeginSym = getContainerBegin(State, ContReg);
   if (!BeginSym) {
-auto &SymMgr = C.getSymbolManager();
-BeginSym = SymMgr.conjureSymbol(CE, C.getLocationContext(),
-C.getASTContext().LongTy, C.blockCount());
-State = assumeNoOverflow(State, BeginSym, 4);
-State = createContainerBegin(State, ContReg, BeginSym);
+State = createContainerBegin(State, ContReg, CE, C.getASTContext().LongTy,
+ C.getLocationContext(), C.blockCount());
+BeginSym = getContainerBegin(State, ContReg);
   }
   State = setIteratorPosition(State, RetVal,
   IteratorPosition::getPosition(ContReg, 
BeginSym));
@@ -1166,11 +1167,9 @@ void IteratorChecker::handleEnd(CheckerC
   auto State = C.getState();
   auto EndSym = getContainerEnd(State, ContReg);
   if (!EndSym) {
-auto &SymMgr = C.getSymbolManager();
-EndSym = SymMgr.conjureSymbol(CE, C.getLocationContext(),
-  C.getASTContext().LongTy, C.blockCount());
-State = assumeNoOverflow(State, EndSym, 4);
-State = createContainerEnd(State, ContReg, EndSym);
+State = createContainerEnd(State, ContReg, CE, C.getASTContext().LongTy,
+   C.getLocationContext(), C.blockCount());
+EndSym = getContainerEnd(State, ContReg);
   }
   State = setIteratorPosition(State, RetVal,
   IteratorPosition::getPosition(ContReg, EndSym));
@@ -1934,32 +1933,47 @@ SymbolRef getContainerEnd(ProgramStateRe
 }
 
 ProgramStateRef createContainerBegin(ProgramStateRef State,
- const MemRegion *Cont,
- const SymbolRef Sym) {
+ const MemRegion *Cont, const Expr *E,
+ QualType T, const LocationContext *LCtx,
+ unsigned BlockCount) {
   // Only create if it does not exist
   const auto *CDataPtr = getContainerData(State, Cont);
+  if (CDataPtr && CDataPtr->getBegin())
+return State;
+
+  auto &SymMgr = State->getSymbolManager();
+  const SymbolConjured *Sym = SymMgr.conjureSymbol(E, LCtx, T, BlockCount,
+   "begin");
+  State = assumeNoOverflow(State, Sym, 4);
+
   if (CDataPtr) {
-if (CDataPtr->getBegin()) {
-  return State;
-}
 const auto CData = CDataPtr->newBegin(Sym);
 return setContainerData(State, Cont, CData);
   }
+
   const auto CData = ContainerData::fromBegin(Sym);
   return setContainerData(State, Cont, CData);
 }
 
 ProgramStateRef createContainerE

[PATCH] D62135: [clangd] Turn no-parse-completion on by when preamble isn't ready. Add flag to force it.

2019-05-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D62135

Files:
  clangd/ClangdServer.cpp
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/tool/ClangdMain.cpp
  clangd/unittests/ClangdTests.cpp

Index: clangd/unittests/ClangdTests.cpp
===
--- clangd/unittests/ClangdTests.cpp
+++ clangd/unittests/ClangdTests.cpp
@@ -9,6 +9,7 @@
 #include "Annotations.h"
 #include "ClangdLSPServer.h"
 #include "ClangdServer.h"
+#include "CodeComplete.h"
 #include "GlobalCompilationDatabase.h"
 #include "Matchers.h"
 #include "SyncAPI.h"
@@ -1075,7 +1076,7 @@
   FS.Files[FooCpp] = FooCpp;
 
   auto Opts = clangd::CodeCompleteOptions();
-  Opts.AllowFallback = true;
+  Opts.RunParser = CodeCompleteOptions::ParseIfReady;
 
   // This will make compile command broken and preamble absent.
   CDB.ExtraClangFlags = {"yolo.cc"};
@@ -1092,11 +1093,17 @@
   CDB.ExtraClangFlags = {"-std=c++11"};
   Server.addDocument(FooCpp, Code.code());
   ASSERT_TRUE(Server.blockUntilIdleForTest());
-  EXPECT_THAT(cantFail(runCodeComplete(Server, FooCpp, Code.point(),
-   clangd::CodeCompleteOptions()))
-  .Completions,
-  ElementsAre(AllOf(Field(&CodeCompletion::Name, "xyz"),
-Field(&CodeCompletion::Scope, "ns::";
+  EXPECT_THAT(
+  cantFail(runCodeComplete(Server, FooCpp, Code.point(), Opts)).Completions,
+  ElementsAre(AllOf(Field(&CodeCompletion::Name, "xyz"),
+Field(&CodeCompletion::Scope, "ns::";
+
+  // Now force identifier-based completion.
+  Opts.RunParser = CodeCompleteOptions::NeverParse;
+  EXPECT_THAT(
+  cantFail(runCodeComplete(Server, FooCpp, Code.point(), Opts)).Completions,
+  ElementsAre(AllOf(Field(&CodeCompletion::Name, "xyz"),
+Field(&CodeCompletion::Scope, "";
 }
 
 TEST_F(ClangdVFSTest, FallbackWhenWaitingForCompileCommand) {
@@ -1143,7 +1150,7 @@
   // hasn't been scheduled.
   std::this_thread::sleep_for(std::chrono::milliseconds(10));
   auto Opts = clangd::CodeCompleteOptions();
-  Opts.AllowFallback = true;
+  Opts.RunParser = CodeCompleteOptions::ParseIfReady;
 
   auto Res = cantFail(runCodeComplete(Server, FooCpp, Code.point(), Opts));
   EXPECT_EQ(Res.Context, CodeCompletionContext::CCC_Recovery);
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -254,13 +254,18 @@
 "Offsets are in UTF-16 code units")),
 llvm::cl::init(OffsetEncoding::UnsupportedEncoding));
 
-static llvm::cl::opt AllowFallbackCompletion(
-"allow-fallback-completion",
-llvm::cl::desc(
-"Allow falling back to code completion without compiling files (using "
-"identifiers and symbol indexes), when file cannot be built or the "
-"build is not ready."),
-llvm::cl::init(false));
+static llvm::cl::opt
+CodeCompletionParse(
+"code-completion-parse",
+llvm::cl::desc("Whether the clang-parser is used for code-completion"),
+llvm::cl::values(clEnumValN(CodeCompleteOptions::AlwaysParse, "always",
+"Block until the parser can be used"),
+ clEnumValN(CodeCompleteOptions::ParseIfReady, "auto",
+"Use text-based completion if the parser "
+"is not ready"),
+ clEnumValN(CodeCompleteOptions::NeverParse, "never",
+"Always used text-based completion")),
+llvm::cl::init(CodeCompleteOptions::ParseIfReady), llvm::cl::Hidden);
 
 namespace {
 
@@ -473,7 +478,7 @@
   CCOpts.SpeculativeIndexRequest = Opts.StaticIndex;
   CCOpts.EnableFunctionArgSnippets = EnableFunctionArgSnippets;
   CCOpts.AllScopes = AllScopesCompletion;
-  CCOpts.AllowFallback = AllowFallbackCompletion;
+  CCOpts.RunParser = CodeCompletionParse;
 
   RealFileSystemProvider FSProvider;
   // Initialize and run ClangdLSPServer.
Index: clangd/CodeComplete.h
===
--- clangd/CodeComplete.h
+++ clangd/CodeComplete.h
@@ -115,11 +115,18 @@
   /// Such completions can insert scope qualifiers.
   bool AllScopes = false;
 
-  /// Whether to allow falling back to code completion without compiling files
-  /// (using identifiers in the current file and symbol indexes), when file
-  /// cannot be built (e.g. missing compile command), or the build is not ready
-  /// (e.g. preamble is still being built).
-  bool AllowFallback = false;
+  /// Whether to use the clang parser, or fallback to text-based completion

[PATCH] D62135: [clangd] Turn no-parse-completion on by when preamble isn't ready. Add flag to force it.

2019-05-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 200249.
sammccall added a comment.

code-completion-parse -> completion-parse


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D62135

Files:
  clangd/ClangdServer.cpp
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/tool/ClangdMain.cpp
  clangd/unittests/ClangdTests.cpp

Index: clangd/unittests/ClangdTests.cpp
===
--- clangd/unittests/ClangdTests.cpp
+++ clangd/unittests/ClangdTests.cpp
@@ -9,6 +9,7 @@
 #include "Annotations.h"
 #include "ClangdLSPServer.h"
 #include "ClangdServer.h"
+#include "CodeComplete.h"
 #include "GlobalCompilationDatabase.h"
 #include "Matchers.h"
 #include "SyncAPI.h"
@@ -1075,7 +1076,7 @@
   FS.Files[FooCpp] = FooCpp;
 
   auto Opts = clangd::CodeCompleteOptions();
-  Opts.AllowFallback = true;
+  Opts.RunParser = CodeCompleteOptions::ParseIfReady;
 
   // This will make compile command broken and preamble absent.
   CDB.ExtraClangFlags = {"yolo.cc"};
@@ -1092,11 +1093,17 @@
   CDB.ExtraClangFlags = {"-std=c++11"};
   Server.addDocument(FooCpp, Code.code());
   ASSERT_TRUE(Server.blockUntilIdleForTest());
-  EXPECT_THAT(cantFail(runCodeComplete(Server, FooCpp, Code.point(),
-   clangd::CodeCompleteOptions()))
-  .Completions,
-  ElementsAre(AllOf(Field(&CodeCompletion::Name, "xyz"),
-Field(&CodeCompletion::Scope, "ns::";
+  EXPECT_THAT(
+  cantFail(runCodeComplete(Server, FooCpp, Code.point(), Opts)).Completions,
+  ElementsAre(AllOf(Field(&CodeCompletion::Name, "xyz"),
+Field(&CodeCompletion::Scope, "ns::";
+
+  // Now force identifier-based completion.
+  Opts.RunParser = CodeCompleteOptions::NeverParse;
+  EXPECT_THAT(
+  cantFail(runCodeComplete(Server, FooCpp, Code.point(), Opts)).Completions,
+  ElementsAre(AllOf(Field(&CodeCompletion::Name, "xyz"),
+Field(&CodeCompletion::Scope, "";
 }
 
 TEST_F(ClangdVFSTest, FallbackWhenWaitingForCompileCommand) {
@@ -1143,7 +1150,7 @@
   // hasn't been scheduled.
   std::this_thread::sleep_for(std::chrono::milliseconds(10));
   auto Opts = clangd::CodeCompleteOptions();
-  Opts.AllowFallback = true;
+  Opts.RunParser = CodeCompleteOptions::ParseIfReady;
 
   auto Res = cantFail(runCodeComplete(Server, FooCpp, Code.point(), Opts));
   EXPECT_EQ(Res.Context, CodeCompletionContext::CCC_Recovery);
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -254,13 +254,18 @@
 "Offsets are in UTF-16 code units")),
 llvm::cl::init(OffsetEncoding::UnsupportedEncoding));
 
-static llvm::cl::opt AllowFallbackCompletion(
-"allow-fallback-completion",
-llvm::cl::desc(
-"Allow falling back to code completion without compiling files (using "
-"identifiers and symbol indexes), when file cannot be built or the "
-"build is not ready."),
-llvm::cl::init(false));
+static llvm::cl::opt
+CodeCompletionParse(
+"completion-parse",
+llvm::cl::desc("Whether the clang-parser is used for code-completion"),
+llvm::cl::values(clEnumValN(CodeCompleteOptions::AlwaysParse, "always",
+"Block until the parser can be used"),
+ clEnumValN(CodeCompleteOptions::ParseIfReady, "auto",
+"Use text-based completion if the parser "
+"is not ready"),
+ clEnumValN(CodeCompleteOptions::NeverParse, "never",
+"Always used text-based completion")),
+llvm::cl::init(CodeCompleteOptions::ParseIfReady), llvm::cl::Hidden);
 
 namespace {
 
@@ -473,7 +478,7 @@
   CCOpts.SpeculativeIndexRequest = Opts.StaticIndex;
   CCOpts.EnableFunctionArgSnippets = EnableFunctionArgSnippets;
   CCOpts.AllScopes = AllScopesCompletion;
-  CCOpts.AllowFallback = AllowFallbackCompletion;
+  CCOpts.RunParser = CodeCompletionParse;
 
   RealFileSystemProvider FSProvider;
   // Initialize and run ClangdLSPServer.
Index: clangd/CodeComplete.h
===
--- clangd/CodeComplete.h
+++ clangd/CodeComplete.h
@@ -115,11 +115,18 @@
   /// Such completions can insert scope qualifiers.
   bool AllScopes = false;
 
-  /// Whether to allow falling back to code completion without compiling files
-  /// (using identifiers in the current file and symbol indexes), when file
-  /// cannot be built (e.g. missing compile command), or the build is not ready
-  /// (e.g. preamble is still being built).
-  bool AllowFallback = false;
+  /// Whether to use the clang parser, or fallback to text-based completion
+  //

[PATCH] D62137: [Frontend] Return an error on bad inputs to PrecompiledPreabmle

2019-05-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: sammccall.
Herald added a project: clang.

Instead of failing with assertions.
Fixed a crash found by oss-fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=12865


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62137

Files:
  clang/include/clang/Frontend/PrecompiledPreamble.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp


Index: clang/lib/Frontend/PrecompiledPreamble.cpp
===
--- clang/lib/Frontend/PrecompiledPreamble.cpp
+++ clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -299,14 +299,13 @@
   // created. This complexity should be lifted elsewhere.
   Clang->getTarget().adjust(Clang->getLangOpts());
 
-  assert(Clang->getFrontendOpts().Inputs.size() == 1 &&
- "Invocation must have exactly one source file!");
-  assert(Clang->getFrontendOpts().Inputs[0].getKind().getFormat() ==
- InputKind::Source &&
- "FIXME: AST inputs not yet supported here!");
-  assert(Clang->getFrontendOpts().Inputs[0].getKind().getLanguage() !=
- InputKind::LLVM_IR &&
- "IR inputs not support here!");
+  if (Clang->getFrontendOpts().Inputs.size() != 1 ||
+  Clang->getFrontendOpts().Inputs[0].getKind().getFormat() !=
+  InputKind::Source ||
+  Clang->getFrontendOpts().Inputs[0].getKind().getLanguage() ==
+  InputKind::LLVM_IR) {
+return BuildPreambleError::BadInputs;
+  }
 
   // Clear out old caches and data.
   Diagnostics.Reset();
@@ -770,6 +769,8 @@
 return "BeginSourceFile() return an error";
   case BuildPreambleError::CouldntEmitPCH:
 return "Could not emit PCH";
+  case BuildPreambleError::BadInputs:
+return "Command line arguments must contain exactly one source file";
   }
   llvm_unreachable("unexpected BuildPreambleError");
 }
Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -1366,6 +1366,7 @@
   case BuildPreambleError::CouldntCreateTargetInfo:
   case BuildPreambleError::BeginSourceFileFailed:
   case BuildPreambleError::CouldntEmitPCH:
+  case BuildPreambleError::BadInputs:
 // These erros are more likely to repeat, retry after some period.
 PreambleRebuildCounter = DefaultPreambleRebuildInterval;
 return nullptr;
Index: clang/include/clang/Frontend/PrecompiledPreamble.h
===
--- clang/include/clang/Frontend/PrecompiledPreamble.h
+++ clang/include/clang/Frontend/PrecompiledPreamble.h
@@ -291,7 +291,8 @@
   CouldntCreateTempFile = 1,
   CouldntCreateTargetInfo,
   BeginSourceFileFailed,
-  CouldntEmitPCH
+  CouldntEmitPCH,
+  BadInputs
 };
 
 class BuildPreambleErrorCategory final : public std::error_category {


Index: clang/lib/Frontend/PrecompiledPreamble.cpp
===
--- clang/lib/Frontend/PrecompiledPreamble.cpp
+++ clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -299,14 +299,13 @@
   // created. This complexity should be lifted elsewhere.
   Clang->getTarget().adjust(Clang->getLangOpts());
 
-  assert(Clang->getFrontendOpts().Inputs.size() == 1 &&
- "Invocation must have exactly one source file!");
-  assert(Clang->getFrontendOpts().Inputs[0].getKind().getFormat() ==
- InputKind::Source &&
- "FIXME: AST inputs not yet supported here!");
-  assert(Clang->getFrontendOpts().Inputs[0].getKind().getLanguage() !=
- InputKind::LLVM_IR &&
- "IR inputs not support here!");
+  if (Clang->getFrontendOpts().Inputs.size() != 1 ||
+  Clang->getFrontendOpts().Inputs[0].getKind().getFormat() !=
+  InputKind::Source ||
+  Clang->getFrontendOpts().Inputs[0].getKind().getLanguage() ==
+  InputKind::LLVM_IR) {
+return BuildPreambleError::BadInputs;
+  }
 
   // Clear out old caches and data.
   Diagnostics.Reset();
@@ -770,6 +769,8 @@
 return "BeginSourceFile() return an error";
   case BuildPreambleError::CouldntEmitPCH:
 return "Could not emit PCH";
+  case BuildPreambleError::BadInputs:
+return "Command line arguments must contain exactly one source file";
   }
   llvm_unreachable("unexpected BuildPreambleError");
 }
Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -1366,6 +1366,7 @@
   case BuildPreambleError::CouldntCreateTargetInfo:
   case BuildPreambleError::BeginSourceFileFailed:
   case BuildPreambleError::CouldntEmitPCH:
+  case BuildPreambleError::BadInputs:
 // These erros are more likely to repeat, retry after some period.
 PreambleRebuildCounter = DefaultPreambleRebuildInterval;
 return nullptr;
Index: clan

[PATCH] D59415: Do not resolve directory junctions for `-fdiagnostics-absolute-paths` on Windows.

2019-05-20 Thread Igor Kudrin via Phabricator via cfe-commits
ikudrin updated this revision to Diff 200252.
ikudrin added a comment.

- Made the patch affect only `-fdiagnostics-absolute-paths` option.


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

https://reviews.llvm.org/D59415

Files:
  lib/Frontend/TextDiagnostic.cpp
  test/Frontend/absolute-paths-windows.test
  test/Frontend/lit.local.cfg


Index: test/Frontend/lit.local.cfg
===
--- test/Frontend/lit.local.cfg
+++ test/Frontend/lit.local.cfg
@@ -1 +1 @@
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll', '.cl']
+config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll', '.cl', '.test']
Index: test/Frontend/absolute-paths-windows.test
===
--- /dev/null
+++ test/Frontend/absolute-paths-windows.test
@@ -0,0 +1,9 @@
+// REQUIRES: system-windows
+// RUN: rm -rf %t.dir
+// RUN: mkdir -p %t.dir\real
+// RUN: cmd /c mklink /j %t.dir\junc %t.dir\real
+// RUN: echo "wrong code" > %t.dir\real\foo.cpp
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-absolute-paths 
%t.dir\junc\foo.cpp 2>&1 | FileCheck %s
+
+// CHECK-NOT: .dir\real\foo.cpp
+// CHECK: .dir\junc\foo.cpp
Index: lib/Frontend/TextDiagnostic.cpp
===
--- lib/Frontend/TextDiagnostic.cpp
+++ lib/Frontend/TextDiagnostic.cpp
@@ -765,7 +765,14 @@
 const DirectoryEntry *Dir = SM.getFileManager().getDirectory(
 llvm::sys::path::parent_path(Filename));
 if (Dir) {
+#ifdef _WIN32
+  SmallString<4096> DirName = Dir->getName();
+  llvm::sys::fs::make_absolute(DirName);
+  llvm::sys::path::native(DirName);
+  llvm::sys::path::remove_dots(DirName, /* remove_dot_dot */ true);
+#else
   StringRef DirName = SM.getFileManager().getCanonicalName(Dir);
+#endif
   llvm::sys::path::append(AbsoluteFilename, DirName,
   llvm::sys::path::filename(Filename));
   Filename = StringRef(AbsoluteFilename.data(), AbsoluteFilename.size());


Index: test/Frontend/lit.local.cfg
===
--- test/Frontend/lit.local.cfg
+++ test/Frontend/lit.local.cfg
@@ -1 +1 @@
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll', '.cl']
+config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll', '.cl', '.test']
Index: test/Frontend/absolute-paths-windows.test
===
--- /dev/null
+++ test/Frontend/absolute-paths-windows.test
@@ -0,0 +1,9 @@
+// REQUIRES: system-windows
+// RUN: rm -rf %t.dir
+// RUN: mkdir -p %t.dir\real
+// RUN: cmd /c mklink /j %t.dir\junc %t.dir\real
+// RUN: echo "wrong code" > %t.dir\real\foo.cpp
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-absolute-paths %t.dir\junc\foo.cpp 2>&1 | FileCheck %s
+
+// CHECK-NOT: .dir\real\foo.cpp
+// CHECK: .dir\junc\foo.cpp
Index: lib/Frontend/TextDiagnostic.cpp
===
--- lib/Frontend/TextDiagnostic.cpp
+++ lib/Frontend/TextDiagnostic.cpp
@@ -765,7 +765,14 @@
 const DirectoryEntry *Dir = SM.getFileManager().getDirectory(
 llvm::sys::path::parent_path(Filename));
 if (Dir) {
+#ifdef _WIN32
+  SmallString<4096> DirName = Dir->getName();
+  llvm::sys::fs::make_absolute(DirName);
+  llvm::sys::path::native(DirName);
+  llvm::sys::path::remove_dots(DirName, /* remove_dot_dot */ true);
+#else
   StringRef DirName = SM.getFileManager().getCanonicalName(Dir);
+#endif
   llvm::sys::path::append(AbsoluteFilename, DirName,
   llvm::sys::path::filename(Filename));
   Filename = StringRef(AbsoluteFilename.data(), AbsoluteFilename.size());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r361145 - Fix compilation warning about unused variable [NFC]

2019-05-20 Thread Mikael Holmen via cfe-commits
Author: uabelho
Date: Mon May 20 04:38:33 2019
New Revision: 361145

URL: http://llvm.org/viewvc/llvm-project?rev=361145&view=rev
Log:
Fix compilation warning about unused variable [NFC]

Without the fix at least clang 3.6 complains with

../tools/clang/lib/AST/ExprConstant.cpp:90:24: error: unused variable 'TI' 
[-Werror,-Wunused-variable]
if (TypeInfoLValue TI = B.dyn_cast())
   ^
1 error generated.

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=361145&r1=361144&r2=361145&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon May 20 04:38:33 2019
@@ -87,7 +87,7 @@ namespace {
   return D->getType();
 }
 
-if (TypeInfoLValue TI = B.dyn_cast())
+if (B.is())
   return B.getTypeInfoType();
 
 const Expr *Base = B.get();


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


[clang-tools-extra] r361147 - [clangd] Fix naming warning from clang-tidy. NFC

2019-05-20 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon May 20 05:17:36 2019
New Revision: 361147

URL: http://llvm.org/viewvc/llvm-project?rev=361147&view=rev
Log:
[clangd] Fix naming warning from clang-tidy. NFC

Also remove newlines and braces.

Modified:
clang-tools-extra/trunk/clangd/unittests/ClangdTests.cpp

Modified: clang-tools-extra/trunk/clangd/unittests/ClangdTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/ClangdTests.cpp?rev=361147&r1=361146&r2=361147&view=diff
==
--- clang-tools-extra/trunk/clangd/unittests/ClangdTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/ClangdTests.cpp Mon May 20 
05:17:36 2019
@@ -95,11 +95,8 @@ public:
   std::vector> filesWithDiags() const {
 std::vector> Result;
 std::lock_guard Lock(Mutex);
-
-for (const auto &it : LastDiagsHadError) {
-  Result.emplace_back(it.first(), it.second);
-}
-
+for (const auto &It : LastDiagsHadError)
+  Result.emplace_back(It.first(), It.second);
 return Result;
   }
 


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


[PATCH] D62135: [clangd] Turn no-parse-completion on by when preamble isn't ready. Add flag to force it.

2019-05-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added inline comments.
This revision is now accepted and ready to land.



Comment at: clangd/CodeComplete.h:128
+/// Always use text-based completion.
+NeverParse,
+  } RunParser = ParseIfReady;

Do we really have any real use case for this option apart from testing ?



Comment at: clangd/tool/ClangdMain.cpp:268
+"Always used text-based completion")),
+llvm::cl::init(CodeCompleteOptions::ParseIfReady), llvm::cl::Hidden);
 

Maybe `CodeCompletionOptions().RunParser` to keep the defaults at one place


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D62135



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


r361139 - [ASTImporter] Enable disabled but passing tests

2019-05-20 Thread Gabor Marton via cfe-commits
Author: martong
Date: Mon May 20 03:38:14 2019
New Revision: 361139

URL: http://llvm.org/viewvc/llvm-project?rev=361139&view=rev
Log:
[ASTImporter] Enable disabled but passing tests

Reviewers: a_sidorin, a.sidorin, shafik

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/unittests/AST/ASTImporterTest.cpp
cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=361139&r1=361138&r2=361139&view=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Mon May 20 03:38:14 2019
@@ -2362,12 +2362,7 @@ TEST_P(ImportFriendFunctions,
   EXPECT_EQ(ToFD->getPreviousDecl(), ImportedD);
 }
 
-// Disabled temporarily, because the new structural equivalence check
-// (https://reviews.llvm.org/D48628) breaks it.
-// PreviousDecl is not set because there is no structural match.
-// FIXME Enable!
-TEST_P(ImportFriendFunctions,
-DISABLED_ImportFriendFunctionRedeclChainDefWithClass) {
+TEST_P(ImportFriendFunctions, ImportFriendFunctionRedeclChainDefWithClass) {
   auto Pattern = functionDecl(hasName("f"));
 
   Decl *FromTU = getTuDecl(
@@ -2395,12 +2390,8 @@ TEST_P(ImportFriendFunctions,
 (*ImportedD->param_begin())->getOriginalType());
 }
 
-// Disabled temporarily, because the new structural equivalence check
-// (https://reviews.llvm.org/D48628) breaks it.
-// PreviousDecl is not set because there is no structural match.
-// FIXME Enable!
 TEST_P(ImportFriendFunctions,
-DISABLED_ImportFriendFunctionRedeclChainDefWithClass_ImportTheProto) {
+   ImportFriendFunctionRedeclChainDefWithClass_ImportTheProto) {
   auto Pattern = functionDecl(hasName("f"));
 
   Decl *FromTU = getTuDecl(

Modified: cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp?rev=361139&r1=361138&r2=361139&view=diff
==
--- cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp (original)
+++ cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp Mon May 20 03:38:14 
2019
@@ -300,8 +300,7 @@ TEST_F(StructuralEquivalenceFunctionTest
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
-TEST_F(StructuralEquivalenceFunctionTest, DISABLED_NoexceptNonMatch) {
-  // The expression is not checked yet.
+TEST_F(StructuralEquivalenceFunctionTest, NoexceptNonMatch) {
   auto t = makeNamedDecls("void foo() noexcept(false);",
   "void foo() noexcept(true);", Lang_CXX11);
   EXPECT_FALSE(testStructuralMatch(t));


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


[PATCH] D61774: [LibTooling] Add RangeSelector library for defining source ranges based on bound AST nodes.

2019-05-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

Thanks! LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61774



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


[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2019-05-20 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam marked 12 inline comments as done.
zahiraam added a comment.

@rsmith I think I have made all the changes you have pointed out to. But please 
note that this new patch only impements an explicit AST representation of uuid  
in template arguments. It **does not** fix the bug for which this review was 
opened for. 
I will take care of the bug in time. But before doing that I want to make sure 
that the changes required to give an explicit AST for uuid is correct.

Thanks for taking the time to review. And sorry my response is slow to come. 
This work is done in my "spare" time.




Comment at: lib/Sema/SemaExprCXX.cpp:675-678
+  if (expr.isUnset()) {
+uuid_expr =
+new (Context) CXXUuidofExpr(TypeInfoType.withConst(), Operand, UuidStr,
+SourceRange(TypeidLoc, RParenLoc));

rsmith wrote:
> We should store a pointer to the UUID declaration on a non-dependent 
> `CXXUuidofExpr`.
Not sure what that means.



Comment at: lib/Sema/SemaExprCXX.cpp:675-678
+  if (expr.isUnset()) {
+uuid_expr =
+new (Context) CXXUuidofExpr(TypeInfoType.withConst(), Operand, UuidStr,
+SourceRange(TypeidLoc, RParenLoc));

zahiraam wrote:
> rsmith wrote:
> > We should store a pointer to the UUID declaration on a non-dependent 
> > `CXXUuidofExpr`.
> Not sure what that means.
However the test case is still failing. Still need to find a solution for the 
fail.



Comment at: lib/Sema/SemaExprCXX.cpp:619
+ /// Finds the __declSpec uuid Decl off a type.
+ static void FindADeclOffAType(Sema &SemaRef,
+   QualType QT,

rsmith wrote:
> Do we need both this and getUuidAttrOfType?
No.


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

https://reviews.llvm.org/D43576



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


[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2019-05-20 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 200258.
zahiraam marked 2 inline comments as done.

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

https://reviews.llvm.org/D43576

Files:
  include/clang/AST/Decl.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/Attr.td
  include/clang/Basic/DeclNodes.td
  include/clang/Sema/ParsedAttr.h
  include/clang/Sema/Sema.h
  lib/AST/Decl.cpp
  lib/AST/DeclBase.cpp
  lib/AST/DeclCXX.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTCommon.cpp
  test/Sema/ms-uuid-1.cpp
  test/Sema/ms-uuid-2.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -321,12 +321,15 @@
 OS << "\" << get" << getUpperName() << "().getAsString() << \"";
   else if (type == "ParamIdx")
 OS << "\" << get" << getUpperName() << "().getSourceIndex() << \"";
-  else
+  else if (type == "DeclSpecUuidDecl *") {
+OS << "\" << get" << getUpperName() << "() << \"";
+  } else
 OS << "\" << get" << getUpperName() << "() << \"";
 }
 
 void writeDump(raw_ostream &OS) const override {
-  if (type == "FunctionDecl *" || type == "NamedDecl *") {
+  if (type == "FunctionDecl *" || type == "NamedDecl *" ||
+  type == "DeclSpecUuidDecl *") {
 OS << "OS << \" \";\n";
 OS << "dumpBareDeclRef(SA->get" << getUpperName() << "());\n"; 
   } else if (type == "IdentifierInfo *") {
@@ -1296,6 +1299,9 @@
 Ptr = llvm::make_unique(Arg, Attr);
   else if (ArgName == "VersionArgument")
 Ptr = llvm::make_unique(Arg, Attr);
+  else if (ArgName == "DeclSpecUuidDeclArgument")
+Ptr = llvm::make_unique(Arg, Attr, "DeclSpecUuidDecl *");
+
 
   if (!Ptr) {
 // Search in reverse order so that the most-derived type is handled first.
Index: test/Sema/ms-uuid-2.cpp
===
--- /dev/null
+++ test/Sema/ms-uuid-2.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -fms-compatibility -std=c++14  %s
+
+
+typedef struct _GUID
+{
+unsigned long  Data1;
+unsigned short Data2;
+unsigned short Data3;
+unsigned char  Data4[8];
+} GUID;
+
+// expected-error@+5 {{C++ requires a type specifier for all declarations}}
+// expected-error@+4 {{invalid digit 'a' in decimal constant}}
+// expected-error@+3 {{use of undeclared identifier 'def0'}}
+// expected-error@+2 {{invalid digit 'a' in decimal constant}}
+// expected-error@+1 {{expected ';' after top level declarator}}
+uuid(12345678-9abc-def0-1234-56789abcdef0) struct S2;
+
Index: test/Sema/ms-uuid-1.cpp
===
--- /dev/null
+++ test/Sema/ms-uuid-1.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -fms-compatibility -std=c++14 %s
+// expected-no-diagnostics
+typedef struct _GUID {
+  int i;
+} IID;
+template 
+class A {};
+
+struct
+__declspec(uuid("{DDB47A6A-0F23-11D5-9109-00E0296B75D3}"))
+S1 {};
+
+struct
+__declspec(uuid("{DDB47A6A-0F23-11D5-9109-00E0296B75D3}"))
+S2 {};
+
+struct __declspec(dllexport)
+C1 : public A<&__uuidof(S1)> {};
+
+struct __declspec(dllexport)
+C2 : public A<&__uuidof(S2)> {};
+int printf(const char *, ...);
+int main() {
+
+  if (&__uuidof(S1) == &__uuidof(S2))
+printf("OK\n");
+  else
+printf("ERROR\n");
+
+  return 0;
+}
Index: lib/Serialization/ASTCommon.cpp
===
--- lib/Serialization/ASTCommon.cpp
+++ lib/Serialization/ASTCommon.cpp
@@ -348,6 +348,7 @@
   case Decl::ObjCProtocol:
   case Decl::ObjCInterface:
   case Decl::Empty:
+  case Decl::DeclSpecUuid:
 return true;
 
   // Never redeclarable.
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -630,6 +630,11 @@
   return Inst;
 }
 
+ Decl *
+ TemplateDeclInstantiator::VisitDeclSpecUuidDecl(DeclSpecUuidDecl *D) {
+   llvm_unreachable("DeclSpecUuidDecl cannot be instantiated");
+}
+
 Decl *TemplateDeclInstantiator::InstantiateTypedefNameDecl(TypedefNameDecl *D,
bool IsTypeAlias) {
   bool Invalid = false;
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -628,11 +628,12 @@
   return ExprError(Diag(TypeidLoc, diag::err_uuidof_without_guid));
 if (UuidAttrs.size() > 1)
   return ExprError(Diag(TypeidLoc, diag::err_uuidof_

r361148 - [Syntax] Introduce TokenBuffer, start clangToolingSyntax library

2019-05-20 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon May 20 06:00:42 2019
New Revision: 361148

URL: http://llvm.org/viewvc/llvm-project?rev=361148&view=rev
Log:
[Syntax] Introduce TokenBuffer, start clangToolingSyntax library

Summary:
TokenBuffer stores the list of tokens for a file obtained after
preprocessing. This is a base building block for syntax trees,
see [1] for the full proposal on syntax trees.

This commits also starts a new sub-library of ClangTooling, which
would be the home for the syntax trees and syntax-tree-based refactoring
utilities.

[1]: https://lists.llvm.org/pipermail/cfe-dev/2019-February/061414.html

Reviewers: gribozavr, sammccall

Reviewed By: sammccall

Subscribers: mgrang, riccibruno, Eugene.Zelenko, mgorny, jdoerfert, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/include/clang/Tooling/Syntax/
cfe/trunk/include/clang/Tooling/Syntax/Tokens.h
cfe/trunk/lib/Tooling/Syntax/
cfe/trunk/lib/Tooling/Syntax/CMakeLists.txt
cfe/trunk/lib/Tooling/Syntax/Tokens.cpp
cfe/trunk/unittests/Tooling/Syntax/
cfe/trunk/unittests/Tooling/Syntax/CMakeLists.txt
cfe/trunk/unittests/Tooling/Syntax/TokensTest.cpp
Modified:
cfe/trunk/lib/Tooling/CMakeLists.txt
cfe/trunk/unittests/Tooling/CMakeLists.txt

Added: cfe/trunk/include/clang/Tooling/Syntax/Tokens.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Syntax/Tokens.h?rev=361148&view=auto
==
--- cfe/trunk/include/clang/Tooling/Syntax/Tokens.h (added)
+++ cfe/trunk/include/clang/Tooling/Syntax/Tokens.h Mon May 20 06:00:42 2019
@@ -0,0 +1,302 @@
+//===- Tokens.h - collect tokens from preprocessing --*- 
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
+//
+//===--===//
+// Record tokens that a preprocessor emits and define operations to map between
+// the tokens written in a file and tokens produced by the preprocessor.
+//
+// When running the compiler, there are two token streams we are interested in:
+//   - "spelled" tokens directly correspond to a substring written in some
+// source file.
+//   - "expanded" tokens represent the result of preprocessing, parses consumes
+// this token stream to produce the AST.
+//
+// Expanded tokens correspond directly to locations found in the AST, allowing
+// to find subranges of the token stream covered by various AST nodes. Spelled
+// tokens correspond directly to the source code written by the user.
+//
+// To allow composing these two use-cases, we also define operations that map
+// between expanded and spelled tokens that produced them (macro calls,
+// directives, etc).
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLING_SYNTAX_TOKENS_H
+#define LLVM_CLANG_TOOLING_SYNTAX_TOKENS_H
+
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Lex/Token.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Compiler.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+#include 
+
+namespace clang {
+class Preprocessor;
+
+namespace syntax {
+
+/// A half-open character range inside a particular file, the start offset is
+/// included and the end offset is excluded from the range.
+struct FileRange {
+  /// EXPECTS: File.isValid() && Begin <= End.
+  FileRange(FileID File, unsigned BeginOffset, unsigned EndOffset);
+  /// EXPECTS: BeginLoc.isValid() && BeginLoc.isFileID().
+  FileRange(const SourceManager &SM, SourceLocation BeginLoc, unsigned Length);
+  /// EXPECTS: BeginLoc.isValid() && BeginLoc.isFileID(), Begin <= End and 
files
+  ///  are the same.
+  FileRange(const SourceManager &SM, SourceLocation BeginLoc,
+SourceLocation EndLoc);
+
+  FileID file() const { return File; }
+  /// Start is a start offset (inclusive) in the corresponding file.
+  unsigned beginOffset() const { return Begin; }
+  /// End offset (exclusive) in the corresponding file.
+  unsigned endOffset() const { return End; }
+
+  unsigned length() const { return End - Begin; }
+
+  /// Gets the substring that this FileRange refers to.
+  llvm::StringRef text(const SourceManager &SM) const;
+
+  friend bool operator==(const FileRange &L, const FileRange &R) {
+return std::tie(L.File, L.Begin, L.End) == std::tie(R.File, R.Begin, 
R.End);
+  }
+  friend bool operator!=(const FileRange &L, const FileRange &R) {
+return !(L == R);
+  }
+
+private:
+  FileID File;
+  unsigned Begin;
+  unsigned End;
+};
+

[PATCH] D62138: [Docs] Increase Doxygen cache size

2019-05-20 Thread J. Ryan Stinnett via Phabricator via cfe-commits
jryans created this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

When building Doxygen docs for llvm and clang, it helpfully prints a warning at
the end noting that the `LOOKUP_CACHE_SIZE` value was too small to keep all
symbols in memory.

By increasing to the size it recommends, Doxygen builds have greatly improved
performance. On my machine, time to run `doxygen-llvm` changes from 34 minutes
to 22 minutes, which is a decent amount of time saved by changing a single
number.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62138

Files:
  clang/docs/doxygen.cfg.in
  llvm/docs/doxygen.cfg.in


Index: llvm/docs/doxygen.cfg.in
===
--- llvm/docs/doxygen.cfg.in
+++ llvm/docs/doxygen.cfg.in
@@ -385,7 +385,7 @@
 # the optimal cache size from a speed point of view.
 # Minimum value: 0, maximum value: 9, default value: 0.
 
-LOOKUP_CACHE_SIZE  = 2
+LOOKUP_CACHE_SIZE  = 4
 
 #---
 # Build related configuration options
Index: clang/docs/doxygen.cfg.in
===
--- clang/docs/doxygen.cfg.in
+++ clang/docs/doxygen.cfg.in
@@ -384,7 +384,7 @@
 # the optimal cache size from a speed point of view.
 # Minimum value: 0, maximum value: 9, default value: 0.
 
-LOOKUP_CACHE_SIZE  = 2
+LOOKUP_CACHE_SIZE  = 3
 
 #---
 # Build related configuration options


Index: llvm/docs/doxygen.cfg.in
===
--- llvm/docs/doxygen.cfg.in
+++ llvm/docs/doxygen.cfg.in
@@ -385,7 +385,7 @@
 # the optimal cache size from a speed point of view.
 # Minimum value: 0, maximum value: 9, default value: 0.
 
-LOOKUP_CACHE_SIZE  = 2
+LOOKUP_CACHE_SIZE  = 4
 
 #---
 # Build related configuration options
Index: clang/docs/doxygen.cfg.in
===
--- clang/docs/doxygen.cfg.in
+++ clang/docs/doxygen.cfg.in
@@ -384,7 +384,7 @@
 # the optimal cache size from a speed point of view.
 # Minimum value: 0, maximum value: 9, default value: 0.
 
-LOOKUP_CACHE_SIZE  = 2
+LOOKUP_CACHE_SIZE  = 3
 
 #---
 # Build related configuration options
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59887: [Syntax] Introduce TokenBuffer, start clangToolingSyntax library

2019-05-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361148: [Syntax] Introduce TokenBuffer, start 
clangToolingSyntax library (authored by ibiryukov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D59887?vs=200213&id=200260#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D59887

Files:
  include/clang/Tooling/Syntax/Tokens.h
  lib/Tooling/CMakeLists.txt
  lib/Tooling/Syntax/CMakeLists.txt
  lib/Tooling/Syntax/Tokens.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/Syntax/CMakeLists.txt
  unittests/Tooling/Syntax/TokensTest.cpp

Index: lib/Tooling/Syntax/CMakeLists.txt
===
--- lib/Tooling/Syntax/CMakeLists.txt
+++ lib/Tooling/Syntax/CMakeLists.txt
@@ -0,0 +1,10 @@
+set(LLVM_LINK_COMPONENTS Support)
+
+add_clang_library(clangToolingSyntax
+  Tokens.cpp
+
+  LINK_LIBS
+  clangBasic
+  clangFrontend
+  clangLex
+  )
Index: lib/Tooling/Syntax/Tokens.cpp
===
--- lib/Tooling/Syntax/Tokens.cpp
+++ lib/Tooling/Syntax/Tokens.cpp
@@ -0,0 +1,509 @@
+//===- Tokens.cpp - collect tokens from preprocessing -===//
+//
+// 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
+//
+//===--===//
+#include "clang/Tooling/Syntax/Tokens.h"
+
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/Token.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+using namespace clang;
+using namespace clang::syntax;
+
+syntax::Token::Token(const clang::Token &T)
+: Token(T.getLocation(), T.getLength(), T.getKind()) {
+  assert(!T.isAnnotation());
+}
+
+llvm::StringRef syntax::Token::text(const SourceManager &SM) const {
+  bool Invalid = false;
+  const char *Start = SM.getCharacterData(location(), &Invalid);
+  assert(!Invalid);
+  return llvm::StringRef(Start, length());
+}
+
+FileRange syntax::Token::range(const SourceManager &SM) const {
+  assert(location().isFileID() && "must be a spelled token");
+  FileID File;
+  unsigned StartOffset;
+  std::tie(File, StartOffset) = SM.getDecomposedLoc(location());
+  return FileRange(File, StartOffset, StartOffset + length());
+}
+
+FileRange syntax::Token::range(const SourceManager &SM,
+   const syntax::Token &First,
+   const syntax::Token &Last) {
+  auto F = First.range(SM);
+  auto L = Last.range(SM);
+  assert(F.file() == L.file() && "tokens from different files");
+  assert(F.endOffset() <= L.beginOffset() && "wrong order of tokens");
+  return FileRange(F.file(), F.beginOffset(), L.endOffset());
+}
+
+llvm::raw_ostream &syntax::operator<<(llvm::raw_ostream &OS, const Token &T) {
+  return OS << T.str();
+}
+
+FileRange::FileRange(FileID File, unsigned BeginOffset, unsigned EndOffset)
+: File(File), Begin(BeginOffset), End(EndOffset) {
+  assert(File.isValid());
+  assert(BeginOffset <= EndOffset);
+}
+
+FileRange::FileRange(const SourceManager &SM, SourceLocation BeginLoc,
+ unsigned Length) {
+  assert(BeginLoc.isValid());
+  assert(BeginLoc.isFileID());
+
+  std::tie(File, Begin) = SM.getDecomposedLoc(BeginLoc);
+  End = Begin + Length;
+}
+FileRange::FileRange(const SourceManager &SM, SourceLocation BeginLoc,
+ SourceLocation EndLoc) {
+  assert(BeginLoc.isValid());
+  assert(BeginLoc.isFileID());
+  assert(EndLoc.isValid());
+  assert(EndLoc.isFileID());
+  assert(SM.getFileID(BeginLoc) == SM.getFileID(EndLoc));
+  assert(SM.getFileOffset(BeginLoc) <= SM.getFileOffset(EndLoc));
+
+  std::tie(File, Begin) = SM.getDecomposedLoc(BeginLoc);
+  End = SM.getFileOffset(EndLoc);
+}
+
+llvm::raw_ostream &syntax::operator<<(llvm::raw_ostream &OS,
+  const FileRange &R) {
+  return OS << llvm::formatv("FileRange(file = {0}, offsets = {1}-{2})",
+ R.file().getHashValue(), R.beginOffset(),
+ R.endOffset());
+}
+
+llvm::StringRef FileRange::text(const SourceManager &SM) const {
+  bool Invalid = false;
+  StringRef Text = SM.getBufferData(F

[PATCH] D61774: [LibTooling] Add RangeSelector library for defining source ranges based on bound AST nodes.

2019-05-20 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 200262.
ymandel added a comment.

updated some comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61774

Files:
  clang/include/clang/Tooling/Refactoring/RangeSelector.h
  clang/lib/Tooling/Refactoring/CMakeLists.txt
  clang/lib/Tooling/Refactoring/RangeSelector.cpp
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/RangeSelectorTest.cpp

Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -0,0 +1,496 @@
+//===- unittest/Tooling/RangeSelectorTest.cpp -===//
+//
+// 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
+//
+//===--===//
+
+#include "clang/Tooling/Refactoring/RangeSelector.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/FixIt.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace tooling;
+using namespace ast_matchers;
+
+namespace {
+using ::testing::AllOf;
+using ::testing::HasSubstr;
+using MatchResult = MatchFinder::MatchResult;
+using ::llvm::Expected;
+using ::llvm::Failed;
+using ::llvm::HasValue;
+using ::llvm::StringError;
+
+struct TestMatch {
+  // The AST unit from which `result` is built. We bundle it because it backs
+  // the result. Users are not expected to access it.
+  std::unique_ptr ASTUnit;
+  // The result to use in the test. References `ast_unit`.
+  MatchResult Result;
+};
+
+template  TestMatch matchCode(StringRef Code, M Matcher) {
+  auto ASTUnit = buildASTFromCode(Code);
+  assert(ASTUnit != nullptr && "AST construction failed");
+
+  ASTContext &Context = ASTUnit->getASTContext();
+  assert(!Context.getDiagnostics().hasErrorOccurred() && "Compilation error");
+
+  auto Matches = ast_matchers::match(Matcher, Context);
+  // We expect a single, exact match.
+  assert(Matches.size() != 0 && "no matches found");
+  assert(Matches.size() == 1 && "too many matches");
+
+  return TestMatch{std::move(ASTUnit), MatchResult(Matches[0], &Context)};
+}
+
+// Applies \p Selector to \p Match and, on success, returns the selected source.
+Expected apply(RangeSelector Selector, const TestMatch &Match) {
+  Expected Range = Selector(Match.Result);
+  if (!Range)
+return Range.takeError();
+  return fixit::internal::getText(*Range, *Match.Result.Context);
+}
+
+// Applies \p Selector to a trivial match with only a single bound node with id
+// "bound_node_id".  For use in testing unbound-node errors.
+Expected applyToTrivial(const RangeSelector &Selector) {
+  // We need to bind the result to something, or the match will fail. Use a
+  // binding that is not used in the unbound node tests.
+  TestMatch Match =
+  matchCode("static int x = 0;", varDecl().bind("bound_node_id"));
+  return Selector(Match.Result);
+}
+
+// Matches the message expected for unbound-node failures.
+testing::Matcher withUnboundNodeMessage() {
+  return testing::Property(
+  &StringError::getMessage,
+  AllOf(HasSubstr("unbound_id"), HasSubstr("not bound")));
+}
+
+// Applies \p Selector to code containing assorted node types, where the match
+// binds each one: a statement ("stmt"), a (non-member) ctor-initializer
+// ("init"), an expression ("expr") and a (nameless) declaration ("decl").  Used
+// to test failures caused by applying selectors to nodes of the wrong type.
+Expected applyToAssorted(RangeSelector Selector) {
+  StringRef Code = R"cc(
+  struct A {};
+  class F : public A {
+   public:
+F(int) {}
+  };
+  void g() { F f(1); }
+)cc";
+
+  auto Matcher =
+  compoundStmt(
+  hasDescendant(
+  cxxConstructExpr(
+  hasDeclaration(
+  decl(hasDescendant(cxxCtorInitializer(isBaseInitializer())
+ .bind("init")))
+  .bind("decl")))
+  .bind("expr")))
+  .bind("stmt");
+
+  return Selector(matchCode(Code, Matcher).Result);
+}
+
+// Matches the message expected for type-error failures.
+testing::Matcher withTypeErrorMessage(StringRef NodeID) {
+  return testing::Property(
+  &StringError::getMessage,
+  AllOf(HasSubstr(NodeID), HasSubstr("mismatched type")));
+}
+
+TEST(RangeSelectorTest, UnboundNode) {
+  EXPECT_THAT_EXPECTED(applyToTrivial(node("unbound_id")),
+   Failed(withUnboundNodeMessage()));
+}
+
+TEST(RangeSelectorTest, RangeOp) {
+  StringRef Code = R"cc(
+int f(int x, int y, 

r361152 - [LibTooling] Add RangeSelector library for defining source ranges based on bound AST nodes.

2019-05-20 Thread Yitzhak Mandelbaum via cfe-commits
Author: ymandel
Date: Mon May 20 06:15:14 2019
New Revision: 361152

URL: http://llvm.org/viewvc/llvm-project?rev=361152&view=rev
Log:
[LibTooling] Add RangeSelector library for defining source ranges based on 
bound AST nodes.

Summary:

The RangeSelector library defines a combinator language for specifying source
ranges based on bound ids for AST nodes.  The combinator approach follows the
design of the AST matchers.  The RangeSelectors defined here will be used in
both RewriteRule, for specifying source affected by edit, and in Stencil for
specifying source to use constructively in a replacement.

Reviewers: ilya-biryukov

Subscribers: mgorny, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h
cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp
cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp
Modified:
cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
cfe/trunk/unittests/Tooling/CMakeLists.txt

Added: cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h?rev=361152&view=auto
==
--- cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h (added)
+++ cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h Mon May 20 
06:15:14 2019
@@ -0,0 +1,80 @@
+//===--- RangeSelector.h - Source-selection library -*- 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
+//
+//===--===//
+///
+///  \file
+///  Defines a combinator library supporting the definition of _selectors_,
+///  which select source ranges based on (bound) AST nodes.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLING_REFACTOR_RANGE_SELECTOR_H_
+#define LLVM_CLANG_TOOLING_REFACTOR_RANGE_SELECTOR_H_
+
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+#include 
+
+namespace clang {
+namespace tooling {
+using RangeSelector = std::function(
+const ast_matchers::MatchFinder::MatchResult &)>;
+
+inline RangeSelector charRange(CharSourceRange R) {
+  return [R](const ast_matchers::MatchFinder::MatchResult &)
+ -> Expected { return R; };
+}
+
+/// Selects from the start of \p Begin and to the end of \p End.
+RangeSelector range(RangeSelector Begin, RangeSelector End);
+
+/// Convenience version of \c range where end-points are bound nodes.
+RangeSelector range(StringRef BeginID, StringRef EndID);
+
+/// Selects a node, including trailing semicolon (for non-expression
+/// statements). \p ID is the node's binding in the match result.
+RangeSelector node(StringRef ID);
+
+/// Selects a node, including trailing semicolon (always). Useful for selecting
+/// expression statements. \p ID is the node's binding in the match result.
+RangeSelector statement(StringRef ID);
+
+/// Given a \c MemberExpr, selects the member token. \p ID is the node's
+/// binding in the match result.
+RangeSelector member(StringRef ID);
+
+/// Given a node with a "name", (like \c NamedDecl, \c DeclRefExpr or \c
+/// CxxCtorInitializer) selects the name's token.  Only selects the final
+/// identifier of a qualified name, but not any qualifiers or template
+/// arguments.  For example, for `::foo::bar::baz` and `::foo::bar::baz`,
+/// it selects only `baz`.
+///
+/// \param ID is the node's binding in the match result.
+RangeSelector name(StringRef ID);
+
+// Given a \c CallExpr (bound to \p ID), selects the arguments' source text 
(all
+// source between the call's parentheses).
+RangeSelector callArgs(StringRef ID);
+
+// Given a \c CompoundStmt (bound to \p ID), selects the source of the
+// statements (all source between the braces).
+RangeSelector statements(StringRef ID);
+
+// Given a \c InitListExpr (bound to \p ID), selects the range of the elements
+// (all source between the braces).
+RangeSelector initListElements(StringRef ID);
+
+/// Selects the range from which `S` was expanded (possibly along with other
+/// source), if `S` is an expansion, and `S` itself, otherwise.  Corresponds to
+/// `SourceManager::getExpansionRange`.
+RangeSelector expansion(RangeSelector S);
+} // namespace tooling
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLING_REFACTOR_RANGE_SELECTOR_H_

Modified: cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt?rev=361152&r1=361151&r2=361152&view=diff
==
--- cfe

[PATCH] D61774: [LibTooling] Add RangeSelector library for defining source ranges based on bound AST nodes.

2019-05-20 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361152: [LibTooling] Add RangeSelector library for defining 
source ranges based on… (authored by ymandel, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61774?vs=200262&id=200265#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61774

Files:
  cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h
  cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
  cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp
  cfe/trunk/unittests/Tooling/CMakeLists.txt
  cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp

Index: cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp
===
--- cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp
+++ cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp
@@ -0,0 +1,264 @@
+//===--- RangeSelector.cpp - RangeSelector implementations --*- 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
+//
+//===--===//
+
+#include "clang/Tooling/Refactoring/RangeSelector.h"
+#include "clang/AST/Expr.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Tooling/Refactoring/SourceCode.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Errc.h"
+#include "llvm/Support/Error.h"
+#include 
+#include 
+#include 
+
+using namespace clang;
+using namespace tooling;
+
+using ast_matchers::MatchFinder;
+using ast_type_traits::ASTNodeKind;
+using ast_type_traits::DynTypedNode;
+using llvm::Error;
+using llvm::StringError;
+
+using MatchResult = MatchFinder::MatchResult;
+
+static Error invalidArgumentError(Twine Message) {
+  return llvm::make_error(llvm::errc::invalid_argument, Message);
+}
+
+static Error typeError(StringRef ID, const ASTNodeKind &Kind) {
+  return invalidArgumentError("mismatched type (node id=" + ID +
+  " kind=" + Kind.asStringRef() + ")");
+}
+
+static Error typeError(StringRef ID, const ASTNodeKind &Kind,
+   Twine ExpectedType) {
+  return invalidArgumentError("mismatched type: expected one of " +
+  ExpectedType + " (node id=" + ID +
+  " kind=" + Kind.asStringRef() + ")");
+}
+
+static Error missingPropertyError(StringRef ID, Twine Description,
+  StringRef Property) {
+  return invalidArgumentError(Description + " requires property '" + Property +
+  "' (node id=" + ID + ")");
+}
+
+static Expected getNode(const ast_matchers::BoundNodes &Nodes,
+  StringRef ID) {
+  auto &NodesMap = Nodes.getMap();
+  auto It = NodesMap.find(ID);
+  if (It == NodesMap.end())
+return invalidArgumentError("ID not bound: " + ID);
+  return It->second;
+}
+
+// FIXME: handling of macros should be configurable.
+static SourceLocation findPreviousTokenStart(SourceLocation Start,
+ const SourceManager &SM,
+ const LangOptions &LangOpts) {
+  if (Start.isInvalid() || Start.isMacroID())
+return SourceLocation();
+
+  SourceLocation BeforeStart = Start.getLocWithOffset(-1);
+  if (BeforeStart.isInvalid() || BeforeStart.isMacroID())
+return SourceLocation();
+
+  return Lexer::GetBeginningOfToken(BeforeStart, SM, LangOpts);
+}
+
+// Finds the start location of the previous token of kind \p TK.
+// FIXME: handling of macros should be configurable.
+static SourceLocation findPreviousTokenKind(SourceLocation Start,
+const SourceManager &SM,
+const LangOptions &LangOpts,
+tok::TokenKind TK) {
+  while (true) {
+SourceLocation L = findPreviousTokenStart(Start, SM, LangOpts);
+if (L.isInvalid() || L.isMacroID())
+  return SourceLocation();
+
+Token T;
+if (Lexer::getRawToken(L, T, SM, LangOpts, /*IgnoreWhiteSpace=*/true))
+  return SourceLocation();
+
+if (T.is(TK))
+  return T.getLocation();
+
+Start = L;
+  }
+}
+
+static SourceLocation findOpenParen(const CallExpr &E, const SourceManager &SM,
+const LangOptions &LangOpts) {
+  SourceLocation EndLoc =
+  E.getNumArgs() == 0 ? E.getRParenLoc() : E.getArg(0)->getBeginLoc();
+  return findPreviousTokenKind(EndLoc, SM, LangOpts, tok::TokenKind::l_paren);
+}
+
+RangeSelector tooling::node(StringRef ID) {
+  return [ID](const Match

[PATCH] D60283: [DebugInfo] Don't emit checksums when compiling a preprocessed CPP

2019-05-20 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Ping! Any further comments?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60283



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


[PATCH] D61851: [clang-tidy] New option for misc-throw-by-value-catch-by-reference

2019-05-20 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 200266.
baloghadamsoftware added a comment.

Updated according to the comments.


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

https://reviews.llvm.org/D61851

Files:
  clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
  clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
  
test/clang-tidy/misc-throw-by-value-catch-by-reference-warn-on-large-object.cpp

Index: test/clang-tidy/misc-throw-by-value-catch-by-reference-warn-on-large-object.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-throw-by-value-catch-by-reference-warn-on-large-object.cpp
@@ -0,0 +1,36 @@
+// RUN: %check_clang_tidy %s misc-throw-by-value-catch-by-reference %t -- -config="{CheckOptions: [{key: misc-throw-by-value-catch-by-reference.WarnOnLargeObject, value: 1}]}" -- -std=c++11 -fcxx-exceptions
+
+struct SmallType {
+  long n;
+};
+
+struct LargeType {
+  long v[255];
+};
+
+void testThrowFunc() {
+  throw SmallType();
+  throw LargeType();
+}
+
+void catchSmall() {
+  try {
+testThrowFunc();
+  } catch (SmallType s) {
+  }
+}
+
+void catchLarge() {
+  try {
+testThrowFunc();
+  } catch (LargeType l) {
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: catch handler catches by value; should catch by reference instead [misc-throw-by-value-catch-by-reference]
+  }
+}
+
+void catchByReference() {
+  try {
+testThrowFunc();
+  } catch (LargeType &l) {
+  }
+}
Index: docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
===
--- docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
+++ docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
@@ -32,3 +32,18 @@
`_.
Default is `1`.
 
+.. option:: WarnOnLargeObject
+
+   Also warns for any large, trivial object caught by value. Catching a large
+   object by value is not dangerous but affects the performance negatively. The
+   maximum size of an object allowed to be caught without warning can be set
+   using the `MaxSize` option.
+   Default is `0`.
+
+.. option:: MaxSize
+
+   Determines the maximum size of an object allowed to be caught without
+   warning. Only applicable if `WarnOnLargeObject` is set to `1`. If option is
+   set by the user to `std::numeric_limits::max()` then it reverts to
+   the default value.
+   Default is the size of `size_t`.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -170,6 +170,11 @@
 
   Rewrites function signatures to use a trailing return type.
 
+- The :doc:`misc-throw-by-value-catch-by-reference
+  ` now supports
+  `WarnOnLargeObject` and `MaxSize` options to warn on any large trivial
+  object caught by value.
+
 Improvements to include-fixer
 -
 
Index: clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h
===
--- clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h
+++ clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h
@@ -41,6 +41,8 @@
   bool isCatchVariable(const DeclRefExpr *declRefExpr);
   bool isFunctionOrCatchVar(const DeclRefExpr *declRefExpr);
   const bool CheckAnonymousTemporaries;
+  const bool WarnOnLargeObject;
+  uint64_t MaxSize; // No `const` bacause we have to set it in two steps.
 };
 
 } // namespace misc
Index: clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
===
--- clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
+++ clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
@@ -20,7 +20,10 @@
 ThrowByValueCatchByReferenceCheck::ThrowByValueCatchByReferenceCheck(
 StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  CheckAnonymousTemporaries(Options.get("CheckThrowTemporaries", true)) {}
+  CheckAnonymousTemporaries(Options.get("CheckThrowTemporaries", true)),
+  WarnOnLargeObject(Options.get("WarnOnLargeObject", false)),
+  // Cannot access `ASTContext` from here so set it to an extremal value.
+  MaxSize(Options.get("MaxSize", std::numeric_limits::max())) {}
 
 void ThrowByValueCatchByReferenceCheck::registerMatchers(MatchFinder *Finder) {
   // This is a C++ only check thus we register the matchers only for C++
@@ -150,8 +153,19 @@
 // If it's not a pointer and not a reference then it must be caught "by
 // value". In this case we should emit a diagnosis message unless the type
 // is trivial.
-if (!caughtType.isTrivialType(context))
+if (!caughtType.isTrivialType(context)) {
   diag(varDecl->getBeginLoc(), diagMsgCatchReference);
+} else if (WarnO

[PATCH] D61851: [clang-tidy] New option for misc-throw-by-value-catch-by-reference

2019-05-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Looks good




Comment at: clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h:45
+  const bool WarnOnLargeObject;
+  uint64_t MaxSize; // No `const` bacause we have to set it in two steps.
 };

because


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

https://reviews.llvm.org/D61851



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


[PATCH] D62138: [Docs] Increase Doxygen cache size

2019-05-20 Thread J. Ryan Stinnett via Phabricator via cfe-commits
jryans added a comment.

I don't currently have commit access, so I would need someone to land this for 
me assuming it's approved. If it would be easier for me to submit separate 
patches for the llvm and clang changes, please let me know! 😄


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62138



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


[PATCH] D61743: New clang option -MD-filter=prefix to filter files from make dependencies

2019-05-20 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

@rjmccall Can you take a look at this patch or recommend someone who can review 
it? Many thanks. --Melanie


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

https://reviews.llvm.org/D61743



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


[PATCH] D60283: [DebugInfo] Don't emit checksums when compiling a preprocessed CPP

2019-05-20 Thread Paul Robinson via Phabricator via cfe-commits
probinson accepted this revision.
probinson added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D60283



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


[PATCH] D61851: [clang-tidy] New option for misc-throw-by-value-catch-by-reference

2019-05-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM (with the typo fix).


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

https://reviews.llvm.org/D61851



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


[PATCH] D62121: [PowerPC] [Clang] Port SSE intrinsics to PowerPC

2019-05-20 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added subscribers: MaskRay, rjmccall, aaron.ballman, rnk, jyknight.
jsji added a comment.

Add more subscribers, reviews and comments are welcome and appreciated. Thanks.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62121



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


[PATCH] D61774: [LibTooling] Add RangeSelector library for defining source ranges based on bound AST nodes.

2019-05-20 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

Test file broke gcc builds. Fix in progress...


Repository:
  rL LLVM

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

https://reviews.llvm.org/D61774



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


[PATCH] D62138: [Docs] Increase Doxygen cache size

2019-05-20 Thread Don Hinton via Phabricator via cfe-commits
hintonda accepted this revision.
hintonda added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM!

I'll give it a day for further comments, and barring any, commit it for you 
tomorrow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62138



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


r361160 - [LibTooling] Fix build break in test after r361152.

2019-05-20 Thread Yitzhak Mandelbaum via cfe-commits
Author: ymandel
Date: Mon May 20 07:44:40 2019
New Revision: 361160

URL: http://llvm.org/viewvc/llvm-project?rev=361160&view=rev
Log:
[LibTooling] Fix build break in test after r361152.

r361152 broke gcc builds.

Modified:
cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp

Modified: cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp?rev=361160&r1=361159&r2=361160&view=diff
==
--- cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp Mon May 20 07:44:40 2019
@@ -8,6 +8,7 @@
 
 #include "clang/Tooling/Refactoring/RangeSelector.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Frontend/ASTUnit.h"
 #include "clang/Tooling/FixIt.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/Error.h"
@@ -31,7 +32,7 @@ using ::llvm::StringError;
 struct TestMatch {
   // The AST unit from which `result` is built. We bundle it because it backs
   // the result. Users are not expected to access it.
-  std::unique_ptr ASTUnit;
+  std::unique_ptr ASTUnit;
   // The result to use in the test. References `ast_unit`.
   MatchResult Result;
 };


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


[PATCH] D61774: [LibTooling] Add RangeSelector library for defining source ranges based on bound AST nodes.

2019-05-20 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

Fixed with r361160.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D61774



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


[PATCH] D37813: clang-format: better handle namespace macros

2019-05-20 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

In D37813#1254891 , @Typz wrote:

> In D37813#1254865 , @klimek wrote:
>
> > In D37813#1253813 , @Typz wrote:
> >
> > > In D37813#1184051 , @klimek 
> > > wrote:
> > >
> > > > The problem here is that we have different opinions on how the 
> > > > formatting on namespace macros should behave in the first place- I 
> > > > think they should behave like namespaces, you want them to be formatted 
> > > > differently.
> > > >  Given that you want full control over the formatting of those macros, 
> > > > and them not actually be formatted exactly like namespaces or classes, 
> > > > I think we need a more generic mechanism for you to express that.
> > >
> > >
> > > Not sure what you mean here. I want them to behave like namespaces as 
> > > well, this is actually the use case I have... As implemented, they indeed 
> > > behave exactly like namespaces :
> > >
> > >   TESTSUITE(a) {   namespace a {
> > >   } // TESTSUITE(a)} // namespace a
> > >   VS
> > >   TESTSUITE(a) { TESTSUITE(b) {namespace a { namespace b {
> > >   } // TESTSUITE(a::b) }} // namespace a::b
> >
> >
> > I thought we had the discussion upthread that they indent differently from 
> > namespaces. I'm working on a patch that allows you to configure macros.
>
>
> The current behavior is that they indent differently from namespace, because 
> clang does not know these macros are conceptually equivalent to namespaces. 
> And this patch actually fixes that, letting clang know they are actually 
> macros.


You say "and this patch fixes that", but in your test cases it looks like the 
indent of things within the namespace is not like the indent for namespaces. 
I'm thoroughly confused.


Repository:
  rC Clang

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

https://reviews.llvm.org/D37813



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


[PATCH] D58418: [clang][DirectoryWatcher] Upstream DirectoryWatcher

2019-05-20 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: clang/include/clang/DirectoryWatcher/DirectoryWatcher.h:78
+  /// The DirectoryWatcher that originated this event is no longer valid 
and
+  /// it's behavior is undefined.
+  /// The prime case is kernel signalling to OS-specific implementation of

"its"



Comment at: clang/include/clang/DirectoryWatcher/DirectoryWatcher.h:78
+  /// The DirectoryWatcher that originated this event is no longer valid 
and
+  /// it's behavior is undefined.
+  /// The prime case is kernel signalling to OS-specific implementation of

gribozavr wrote:
> "its"
I'd say "unspecified".  "Undefined behavior" has a specific meaning in C++, and 
I don't believe we have that.

Everywhere in the patch.



Comment at: clang/include/clang/DirectoryWatcher/DirectoryWatcher.h:79
+  /// it's behavior is undefined.
+  /// The prime case is kernel signalling to OS-specific implementation of
+  /// DirectoryWatcher some resource limit being hit.

Please add blank lines between paragraphs (everywhere in the patch).



Comment at: clang/include/clang/DirectoryWatcher/DirectoryWatcher.h:95
+EventKind Kind;
+/// Filename - a relative path to the watched directory or empty string in
+/// case event is related to the directory itself.

Don't repeat field names in comments.



Comment at: clang/include/clang/DirectoryWatcher/DirectoryWatcher.h:95
+EventKind Kind;
+/// Filename - a relative path to the watched directory or empty string in
+/// case event is related to the directory itself.

gribozavr wrote:
> Don't repeat field names in comments.
"a relative path" -- relative to what?



Comment at: clang/include/clang/DirectoryWatcher/DirectoryWatcher.h:95
+EventKind Kind;
+/// Filename - a relative path to the watched directory or empty string in
+/// case event is related to the directory itself.

gribozavr wrote:
> gribozavr wrote:
> > Don't repeat field names in comments.
> "a relative path" -- relative to what?
Is it really a path to the directory?



Comment at: clang/include/clang/DirectoryWatcher/DirectoryWatcher.h:103
+
+  typedef std::function Events, bool isInitial)>
+  EventReceiver;

"IsInitial"



Comment at: clang/include/clang/DirectoryWatcher/DirectoryWatcher.h:103
+
+  typedef std::function Events, bool isInitial)>
+  EventReceiver;

gribozavr wrote:
> "IsInitial"
Users are not going to use this typedef in their code, so I feel like it is 
obfuscating code -- could you expand it in places where it is used?





Comment at: clang/include/clang/DirectoryWatcher/DirectoryWatcher.h:123
+   DirectoryWatcher::EventReceiver Receiver,
+   bool WaitInitialSync, std::string &Error);
+

Make it a static function in the DirectoryWatcher?



Comment at: clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp:86
+  EventQueue Queue;
+  // flag used for stopping all async acions
+  std::atomic Stop;

Don't write what something is used for (it can change), write what something is.

"If true, all async actions are requested to stop."



Comment at: clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp:106
+  FinishedInitScan(false), Receiver(Receiver),
+  InotifyPollingThread([this, InotifyFD]() {
+// We want to be able to read ~30 events at once even in the worst case

I think this is too much code in the initializer list.  Could you move the body 
of the lambda into a method, and call it from this lambda?



Comment at: clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp:110
+constexpr size_t EventBufferLength =
+30 * (sizeof(struct inotify_event) + NAME_MAX + 1);
+// http://man7.org/linux/man-pages/man7/inotify.7.html

NAME_MAX is 255, add some for inotify_event, and multiply by 30... we get 
almost 8 Kb on the stack. Should we allocate on the heap instead?





Comment at: clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp:112
+// http://man7.org/linux/man-pages/man7/inotify.7.html
+/* Some systems cannot read integer variables if they are not
+properly aligned. On other systems, incorrect alignment may

Please use "//" comments.



Comment at: clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp:118
+char Buf[EventBufferLength]
+__attribute__((aligned(__alignof__(struct inotify_event;
+

Please use AlignedCharArray from llvm/include/llvm/Support/AlignOf.h



Comment at: clang/lib/DirectoryWatcher/lin

r361161 - Fix test not to use UNSUPPORTED as a FileCheck prefix.

2019-05-20 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Mon May 20 07:57:18 2019
New Revision: 361161

URL: http://llvm.org/viewvc/llvm-project?rev=361161&view=rev
Log:
Fix test not to use UNSUPPORTED as a FileCheck prefix.
It was not causing a problem but it's not good practice.

Modified:
cfe/trunk/test/Driver/cl-cc-flags.c

Modified: cfe/trunk/test/Driver/cl-cc-flags.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-cc-flags.c?rev=361161&r1=361160&r2=361161&view=diff
==
--- cfe/trunk/test/Driver/cl-cc-flags.c (original)
+++ cfe/trunk/test/Driver/cl-cc-flags.c Mon May 20 07:57:18 2019
@@ -26,11 +26,11 @@
 
 // No fastcall or stdcall on x86_64:
 
-// RUN: %clang_cl -Wno-msvc-not-found --target=x86_64-windows-msvc /Gr -### -- 
%s 2>&1 | FileCheck --check-prefix=UNSUPPORTED %s
-// RUN: %clang_cl -Wno-msvc-not-found --target=x86_64-windows-msvc /Gz -### -- 
%s 2>&1 | FileCheck --check-prefix=UNSUPPORTED %s
-// RUN: %clang_cl -Wno-msvc-not-found --target=thumbv7-windows-msvc /Gv -### 
-- %s 2>&1 | FileCheck --check-prefix=UNSUPPORTED %s
+// RUN: %clang_cl -Wno-msvc-not-found --target=x86_64-windows-msvc /Gr -### -- 
%s 2>&1 | FileCheck --check-prefix=UNAVAILABLE %s
+// RUN: %clang_cl -Wno-msvc-not-found --target=x86_64-windows-msvc /Gz -### -- 
%s 2>&1 | FileCheck --check-prefix=UNAVAILABLE %s
+// RUN: %clang_cl -Wno-msvc-not-found --target=thumbv7-windows-msvc /Gv -### 
-- %s 2>&1 | FileCheck --check-prefix=UNAVAILABLE %s
 
-// UNSUPPORTED-NOT: error:
-// UNSUPPORTED-NOT: warning:
-// UNSUPPORTED-NOT: -fdefault-calling-conv=
+// UNAVAILABLE-NOT: error:
+// UNAVAILABLE-NOT: warning:
+// UNAVAILABLE-NOT: -fdefault-calling-conv=
 


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


[PATCH] D62143: [clangd] Make it possible to use VFS from parsing for getting tidy options

2019-05-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: sammccall.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay.
Herald added a project: clang.

To give an option for clangd embedders with snapshotted filesystem to
read config files from exact snapshots, possibly loosing some
performance from caching capabilities of the current implementations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62143

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/Version.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -505,7 +506,11 @@
 /* Default */ tidy::ClangTidyOptions::getDefaults(),
 /* Override */ OverrideClangTidyOptions, FSProvider.getFileSystem());
   }
-  Opts.ClangTidyOptProvider = ClangTidyOptProvider.get();
+  Opts.GetClangTidyOptions = [&](llvm::vfs::FileSystem &,
+ llvm::StringRef File) {
+// FIXME: use the FS provided to the function.
+return ClangTidyOptProvider->getOptions(File);
+  };
   Opts.SuggestMissingIncludes = SuggestMissingIncludes;
   llvm::Optional OffsetEncodingFromFlag;
   if (ForceOffsetEncoding != OffsetEncoding::UnsupportedEncoding)
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -99,7 +99,9 @@
 /// Clangd supports only a small subset of ClangTidyOptions, these options
 /// (Checks, CheckOptions) are about which clang-tidy checks will be
 /// enabled.
-tidy::ClangTidyOptionsProvider *ClangTidyOptProvider = nullptr;
+std::function
+GetClangTidyOptions;
 
 /// Clangd's workspace root. Relevant for "workspace" operations not bound
 /// to a particular file.
@@ -278,8 +280,10 @@
   // Storage for merged views of the various indexes.
   std::vector> MergedIdx;
 
-  // The provider used to provide a clang-tidy option for a specific file.
-  tidy::ClangTidyOptionsProvider *ClangTidyOptProvider = nullptr;
+  // When set, provides clang-tidy options for a specific file.
+  std::function
+  GetClangTidyOptions;
 
   // If this is true, suggest include insertion fixes for diagnostic errors 
that
   // can be caused by missing includes (e.g. member access in incomplete type).
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -90,7 +90,7 @@
   DynamicIdx(Opts.BuildDynamicSymbolIndex
  ? new FileIndex(Opts.HeavyweightDynamicSymbolIndex)
  : nullptr),
-  ClangTidyOptProvider(Opts.ClangTidyOptProvider),
+  GetClangTidyOptions(Opts.GetClangTidyOptions),
   SuggestMissingIncludes(Opts.SuggestMissingIncludes),
   WorkspaceRoot(Opts.WorkspaceRoot),
   // Pass a callback into `WorkScheduler` to extract symbols from a newly
@@ -126,15 +126,18 @@
 
 void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents,
WantDiagnostics WantDiags) {
+  auto FS = FSProvider.getFileSystem();
+
   ParseOptions Opts;
   Opts.ClangTidyOpts = tidy::ClangTidyOptions::getDefaults();
-  if (ClangTidyOptProvider)
-Opts.ClangTidyOpts = ClangTidyOptProvider->getOptions(File);
+  // FIXME: call on the worker thread when GetClangTidyOptions is thread-safe.
+  if (GetClangTidyOptions)
+Opts.ClangTidyOpts = GetClangTidyOptions(*FS, File);
   Opts.SuggestMissingIncludes = SuggestMissingIncludes;
 
   // Compile command is set asynchronously during update, as it can be slow.
   ParseInputs Inputs;
-  Inputs.FS = FSProvider.getFileSystem();
+  Inputs.FS = FS;
   Inputs.Contents = Contents;
   Inputs.Opts = std::move(Opts);
   Inputs.Index = Index;


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/Version.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -505,7 +506,11 @@
 /* Default */ tidy::ClangTidyOptions::getDefaults(),
 /* Override */ OverrideClangTidyOptions, FSProvider.getFi

[clang-tools-extra] r361163 - Disable the modernize-use-trailing-return-type.cpp test in C++2a mode

2019-05-20 Thread Dmitri Gribenko via cfe-commits
Author: gribozavr
Date: Mon May 20 08:12:12 2019
New Revision: 361163

URL: http://llvm.org/viewvc/llvm-project?rev=361163&view=rev
Log:
Disable the modernize-use-trailing-return-type.cpp test in C++2a mode

It is performing a use-of-uninitialized-value, as detected by MSan.

Modified:

clang-tools-extra/trunk/test/clang-tidy/modernize-use-trailing-return-type.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-trailing-return-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-trailing-return-type.cpp?rev=361163&r1=361162&r2=361163&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-trailing-return-type.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-trailing-return-type.cpp 
Mon May 20 08:12:12 2019
@@ -1,4 +1,6 @@
-// RUN: %check_clang_tidy -std=c++14-or-later %s 
modernize-use-trailing-return-type %t -- -- -fdeclspec -fexceptions
+// RUN: %check_clang_tidy -std=c++14,c++17 %s 
modernize-use-trailing-return-type %t -- -- -fdeclspec -fexceptions
+// FIXME: Fix the checker to work in C++2a mode, it is performing a
+// use-of-uninitialized-value.
 
 namespace std {
 template 


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


[PATCH] D62019: [clang] Handle lrint/llrint builtins

2019-05-20 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz updated this revision to Diff 200291.
zatrazz added a comment.

Updated patch based on D62026 .


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

https://reviews.llvm.org/D62019

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins.c
  clang/test/CodeGen/math-builtins.c
  clang/test/CodeGen/math-libcalls.c

Index: clang/test/CodeGen/math-libcalls.c
===
--- clang/test/CodeGen/math-libcalls.c
+++ clang/test/CodeGen/math-libcalls.c
@@ -308,9 +308,9 @@
 
   llrint(f); llrintf(f);llrintl(f);
 
-// NO__ERRNO: declare i64 @llrint(double) [[READNONE]]
-// NO__ERRNO: declare i64 @llrintf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @llrintl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.llrint.i64.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llrint.i64.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llrint.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @llrint(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llrintf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llrintl(x86_fp80) [[NOT_READNONE]]
@@ -371,9 +371,9 @@
 
   lrint(f);  lrintf(f); lrintl(f);
 
-// NO__ERRNO: declare i64 @lrint(double) [[READNONE]]
-// NO__ERRNO: declare i64 @lrintf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @lrintl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @lrint(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lrintf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lrintl(x86_fp80) [[NOT_READNONE]]
Index: clang/test/CodeGen/math-builtins.c
===
--- clang/test/CodeGen/math-builtins.c
+++ clang/test/CodeGen/math-builtins.c
@@ -353,9 +353,9 @@
 
   __builtin_llrint(f); __builtin_llrintf(f);__builtin_llrintl(f);
 
-// NO__ERRNO: declare i64 @llrint(double) [[READNONE]]
-// NO__ERRNO: declare i64 @llrintf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @llrintl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.llrint.i64.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llrint.i64.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llrint.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @llrint(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llrintf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llrintl(x86_fp80) [[NOT_READNONE]]
@@ -416,9 +416,9 @@
 
   __builtin_lrint(f);  __builtin_lrintf(f); __builtin_lrintl(f);
 
-// NO__ERRNO: declare i64 @lrint(double) [[READNONE]]
-// NO__ERRNO: declare i64 @lrintf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @lrintl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @lrint(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lrintf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lrintl(x86_fp80) [[NOT_READNONE]]
Index: clang/test/CodeGen/builtins.c
===
--- clang/test/CodeGen/builtins.c
+++ clang/test/CodeGen/builtins.c
@@ -390,6 +390,15 @@
 
   resli = __builtin_lroundl (LD);
   // CHECK: call i64 @llvm.lround.i64.f80
+
+  resli = __builtin_lrintf (F);
+  // CHECK: call i64 @llvm.lrint.i64.f32
+
+  resli = __builtin_lrint (D);
+  // CHECK: call i64 @llvm.lrint.i64.f64
+
+  resli = __builtin_lrintl (LD);
+  // CHECK: call i64 @llvm.lrint.i64.f80
 }
 
 // __builtin_longjmp isn't supported on all platforms, so only test it on X86.
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -1749,6 +1749,22 @@
 case Builtin::BI__builtin_llroundl:
   return RValue::get(emitFPToIntRoundBuiltin(*this, E, Intrinsic::llround));
 
+case Builtin::BIlrint:
+case Builtin::BIlrintf:
+case Builtin::BIlrintl:
+case Builtin::BI__builtin_lrint:
+case Builtin::BI__builtin_lrintf:
+case Builtin::BI__builtin_lrintl:
+  return RValue::get(emitFPToIntRoundBuiltin(*this, E, Intrinsic::lrint));
+
+case Builtin::BIllrint:
+case Builtin::BIllrintf:
+case Builtin::BIllrintl:
+case Builtin::BI__builtin_llrint:
+case Builtin::BI__builtin_llrintf:
+case Builtin::BI__builtin_llrintl:
+  return RValue::get(emitFPToIntRoundBuiltin(*this, E, Intrinsic::llrint));
+
 default:
   break;
 }
__

[PATCH] D62149: [LibTooling] Update Transformer to use RangeSelector instead of NodePart enum.

2019-05-20 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: ilya-biryukov.
Herald added a project: clang.
ymandel updated this revision to Diff 200310.
ymandel added a comment.

reordered some declarations.


Transformer provides an enum to indicate the range of source text to be edited.
That support is now redundant with the new (and more general) RangeSelector
library, so we remove the custom enum support in favor of supporting any
RangeSelector.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62149

Files:
  clang/include/clang/Tooling/Refactoring/Transformer.h
  clang/lib/Tooling/Refactoring/Transformer.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -7,8 +7,8 @@
 //===--===//
 
 #include "clang/Tooling/Refactoring/Transformer.h"
-
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Refactoring/RangeSelector.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
@@ -147,7 +147,7 @@
   on(expr(hasType(isOrPointsTo(StringType)))
  .bind(StringExpr)),
   callee(cxxMethodDecl(hasName("c_str")),
-  change("REPLACED"));
+  change("REPLACED"));
   R.Cases[0].Explanation = text("Use size() method directly on string.");
   return R;
 }
@@ -183,7 +183,7 @@
 hasName("proto::ProtoCommandLineFlag"
.bind(Flag)),
 unless(callee(cxxMethodDecl(hasName("GetProto"),
-  change(Flag, "EXPR"));
+  change(Flag, "EXPR"));
 
   std::string Input = R"cc(
 proto::ProtoCommandLineFlag flag;
@@ -201,9 +201,8 @@
 
 TEST_F(TransformerTest, NodePartNameNamedDecl) {
   StringRef Fun = "fun";
-  RewriteRule Rule =
-  makeRule(functionDecl(hasName("bad")).bind(Fun),
-   change(Fun, NodePart::Name, "good"));
+  RewriteRule Rule = makeRule(functionDecl(hasName("bad")).bind(Fun),
+  change(name(Fun), "good"));
 
   std::string Input = R"cc(
 int bad(int x);
@@ -235,7 +234,7 @@
 
   StringRef Ref = "ref";
   testRule(makeRule(declRefExpr(to(functionDecl(hasName("bad".bind(Ref),
-change(Ref, NodePart::Name, "good")),
+change(name(Ref), "good")),
Input, Expected);
 }
 
@@ -253,7 +252,7 @@
 
   StringRef Ref = "ref";
   Transformer T(makeRule(declRefExpr(to(functionDecl())).bind(Ref),
- change(Ref, NodePart::Name, "good")),
+ change(name(Ref), "good")),
 consumer());
   T.registerMatchers(&MatchFinder);
   EXPECT_FALSE(rewrite(Input));
@@ -262,7 +261,7 @@
 TEST_F(TransformerTest, NodePartMember) {
   StringRef E = "expr";
   RewriteRule Rule = makeRule(memberExpr(member(hasName("bad"))).bind(E),
-  change(E, NodePart::Member, "good"));
+  change(member(E), "good"));
 
   std::string Input = R"cc(
 struct S {
@@ -315,9 +314,8 @@
   )cc";
 
   StringRef E = "expr";
-  testRule(makeRule(memberExpr().bind(E),
-change(E, NodePart::Member, "good")),
-   Input, Expected);
+  testRule(makeRule(memberExpr().bind(E), change(member(E), "good")), Input,
+   Expected);
 }
 
 TEST_F(TransformerTest, NodePartMemberMultiToken) {
@@ -347,9 +345,9 @@
   )cc";
 
   StringRef MemExpr = "member";
-  testRule(makeRule(memberExpr().bind(MemExpr),
-change(MemExpr, NodePart::Member, "good")),
-   Input, Expected);
+  testRule(
+  makeRule(memberExpr().bind(MemExpr), change(member(MemExpr), "good")),
+  Input, Expected);
 }
 
 TEST_F(TransformerTest, MultiChange) {
@@ -371,8 +369,8 @@
   StringRef C = "C", T = "T", E = "E";
   testRule(makeRule(ifStmt(hasCondition(expr().bind(C)),
hasThen(stmt().bind(T)), hasElse(stmt().bind(E))),
-{change(C, "true"), change(T, "{ /* then */ }"),
- change(E, "{ /* else */ }")}),
+{change(C, "true"), change(statement(T), "{ /* then */ }"),
+ change(statement(E), "{ /* else */ }")}),
Input, Expected);
 }
 
@@ -383,7 +381,7 @@
 hasName("proto::ProtoCommandLineFlag"
.bind(Flag)),
 unless(callee(cxxMethodDecl(hasName("GetProto"),
-  change(Flag, "PROTO"));
+  change(Flag, "PROTO"));
 
   std::string Input = R"cc(
 proto::ProtoCommandLineFlag flag;
@@ -410,7 +408,7 @@
hasArgument(0, cxxMemberCallExpr(
   

[PATCH] D62149: [LibTooling] Update Transformer to use RangeSelector instead of NodePart enum.

2019-05-20 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 200310.
ymandel added a comment.

reordered some declarations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62149

Files:
  clang/include/clang/Tooling/Refactoring/Transformer.h
  clang/lib/Tooling/Refactoring/Transformer.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -7,8 +7,8 @@
 //===--===//
 
 #include "clang/Tooling/Refactoring/Transformer.h"
-
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Refactoring/RangeSelector.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
@@ -147,7 +147,7 @@
   on(expr(hasType(isOrPointsTo(StringType)))
  .bind(StringExpr)),
   callee(cxxMethodDecl(hasName("c_str")),
-  change("REPLACED"));
+  change("REPLACED"));
   R.Cases[0].Explanation = text("Use size() method directly on string.");
   return R;
 }
@@ -183,7 +183,7 @@
 hasName("proto::ProtoCommandLineFlag"
.bind(Flag)),
 unless(callee(cxxMethodDecl(hasName("GetProto"),
-  change(Flag, "EXPR"));
+  change(Flag, "EXPR"));
 
   std::string Input = R"cc(
 proto::ProtoCommandLineFlag flag;
@@ -201,9 +201,8 @@
 
 TEST_F(TransformerTest, NodePartNameNamedDecl) {
   StringRef Fun = "fun";
-  RewriteRule Rule =
-  makeRule(functionDecl(hasName("bad")).bind(Fun),
-   change(Fun, NodePart::Name, "good"));
+  RewriteRule Rule = makeRule(functionDecl(hasName("bad")).bind(Fun),
+  change(name(Fun), "good"));
 
   std::string Input = R"cc(
 int bad(int x);
@@ -235,7 +234,7 @@
 
   StringRef Ref = "ref";
   testRule(makeRule(declRefExpr(to(functionDecl(hasName("bad".bind(Ref),
-change(Ref, NodePart::Name, "good")),
+change(name(Ref), "good")),
Input, Expected);
 }
 
@@ -253,7 +252,7 @@
 
   StringRef Ref = "ref";
   Transformer T(makeRule(declRefExpr(to(functionDecl())).bind(Ref),
- change(Ref, NodePart::Name, "good")),
+ change(name(Ref), "good")),
 consumer());
   T.registerMatchers(&MatchFinder);
   EXPECT_FALSE(rewrite(Input));
@@ -262,7 +261,7 @@
 TEST_F(TransformerTest, NodePartMember) {
   StringRef E = "expr";
   RewriteRule Rule = makeRule(memberExpr(member(hasName("bad"))).bind(E),
-  change(E, NodePart::Member, "good"));
+  change(member(E), "good"));
 
   std::string Input = R"cc(
 struct S {
@@ -315,9 +314,8 @@
   )cc";
 
   StringRef E = "expr";
-  testRule(makeRule(memberExpr().bind(E),
-change(E, NodePart::Member, "good")),
-   Input, Expected);
+  testRule(makeRule(memberExpr().bind(E), change(member(E), "good")), Input,
+   Expected);
 }
 
 TEST_F(TransformerTest, NodePartMemberMultiToken) {
@@ -347,9 +345,9 @@
   )cc";
 
   StringRef MemExpr = "member";
-  testRule(makeRule(memberExpr().bind(MemExpr),
-change(MemExpr, NodePart::Member, "good")),
-   Input, Expected);
+  testRule(
+  makeRule(memberExpr().bind(MemExpr), change(member(MemExpr), "good")),
+  Input, Expected);
 }
 
 TEST_F(TransformerTest, MultiChange) {
@@ -371,8 +369,8 @@
   StringRef C = "C", T = "T", E = "E";
   testRule(makeRule(ifStmt(hasCondition(expr().bind(C)),
hasThen(stmt().bind(T)), hasElse(stmt().bind(E))),
-{change(C, "true"), change(T, "{ /* then */ }"),
- change(E, "{ /* else */ }")}),
+{change(C, "true"), change(statement(T), "{ /* then */ }"),
+ change(statement(E), "{ /* else */ }")}),
Input, Expected);
 }
 
@@ -383,7 +381,7 @@
 hasName("proto::ProtoCommandLineFlag"
.bind(Flag)),
 unless(callee(cxxMethodDecl(hasName("GetProto"),
-  change(Flag, "PROTO"));
+  change(Flag, "PROTO"));
 
   std::string Input = R"cc(
 proto::ProtoCommandLineFlag flag;
@@ -410,7 +408,7 @@
hasArgument(0, cxxMemberCallExpr(
   on(expr().bind(S)),
   callee(cxxMethodDecl(hasName("c_str")),
-  change("DISTINCT"));
+  change("DISTINCT"));
 }
 
 TEST_F(TransformerTest, OrderedRuleRelated) {
@@ -475,7 +473,7 @@
   -> llvm::Expected {
 retu

[PATCH] D61963: [clang][Darwin] Refactor header search path logic into the driver

2019-05-20 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 200311.
ldionne added a comment.

Fix test that fails on systems that don't have /usr/include/c++.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61963

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/lib/Frontend/InitHeaderSearch.cpp
  
clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_aarch64/usr/include/c++/4.2.1/arm64-apple-darwin10/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_aarch64/usr/lib/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_arm/usr/include/c++/4.2.1/arm-apple-darwin10/v6/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_arm/usr/include/c++/4.2.1/arm-apple-darwin10/v7/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_arm/usr/lib/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/usr/include/c++/4.0.0/powerpc-apple-darwin10/ppc64/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/usr/include/c++/4.2.1/powerpc-apple-darwin10/ppc64/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/usr/lib/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_x86/usr/include/c++/4.0.0/i686-apple-darwin8/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_x86/usr/include/c++/4.2.1/i686-apple-darwin10/x86_64/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_x86/usr/lib/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_no_libcxx/usr/include/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_no_libcxx/usr/lib/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_no_libstdcxx/usr/include/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_no_libstdcxx/usr/lib/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_usr/usr/include/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_usr/usr/lib/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_usr_and_usr_local/usr/include/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_usr_and_usr_local/usr/lib/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_usr_and_usr_local/usr/local/include/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_usr_and_usr_local/usr/local/lib/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_usr_local/usr/local/include/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_usr_local/usr/local/lib/.keep
  clang/test/Driver/Inputs/basic_darwin_toolchain/usr/bin/.keep
  clang/test/Driver/Inputs/basic_darwin_toolchain/usr/include/c++/v1/.keep
  clang/test/Driver/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin/.keep
  clang/test/Driver/darwin-header-search-libcxx.cpp
  clang/test/Driver/darwin-header-search-libstdcxx.cpp
  clang/test/Driver/darwin-header-search-system.cpp
  clang/test/Driver/darwin-stdlib.cpp
  clang/test/Frontend/warning-stdlibcxx-darwin.cpp

Index: clang/test/Frontend/warning-stdlibcxx-darwin.cpp
===
--- clang/test/Frontend/warning-stdlibcxx-darwin.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-// RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist %s 2>&1 | FileCheck %s
-// RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist -stdlib=libc++ %s -verify
-// RUN: %clang -cc1 -x c++-cpp-output -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist %s -verify
-// CHECK: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead
-
-// expected-no-diagnostics
Index: clang/test/Driver/darwin-stdlib.cpp
===
--- clang/test/Driver/darwin-stdlib.cpp
+++ clang/test/Driver/darwin-stdlib.cpp
@@ -3,19 +3,12 @@
 // XFAIL: default-cxx-stdlib-set
 
 // RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch arm64 -miphoneos-version-min=7.0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX
-// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -mmacosx-version-min=10.8 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBSTDCXX
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -mmacosx-version-min=10.8 -Wno-stdlibcxx-not-found %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBSTDCXX
 // RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -mmacosx-version-min=10.9 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX
-// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7s -miphoneos-version-min=6.1 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBSTDCXX
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7s -miphoneos-version-min=6.1 -Wno-stdlibcxx-not-found %s 

[PATCH] D62149: [LibTooling] Update Transformer to use RangeSelector instead of NodePart enum.

2019-05-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Looks neat! The only concern I have is about the growing number of overloads in 
`Transformer.h`, see the relevant comment.




Comment at: clang/include/clang/Tooling/Refactoring/Transformer.h:186
+/// where a \c TextGenerator, \c RangeSelector are otherwise expected.
+inline ASTEdit change(RangeSelector Target, std::string Replacement) {
+  return change(std::move(Target), text(std::move(Replacement)));

The overloads create quite a lot of noise (and we are already starting to see a 
combinatorial explosion with two classes).

Could we try to overcome this? I see two options:
1. Turn `TextGenerator` and `RangeSelector` into classes, which are 
constructible from `string` or `function`.
2. Remove the string overloads, force users to explicitly construct the 
parameters.

Option (2) actually is simple and would add a bit of type safety, but will make 
some client code a bit less readable. Do you think the readability hit is 
significant?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62149



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


r361169 - [Intrinsics] Merge lround.i32 and lround.i64 into a single intrinsic with overloaded result type. Make result type for llvm.llround overloaded instead of fixing to i64

2019-05-20 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon May 20 09:27:09 2019
New Revision: 361169

URL: http://llvm.org/viewvc/llvm-project?rev=361169&view=rev
Log:
[Intrinsics] Merge lround.i32 and lround.i64 into a single intrinsic with 
overloaded result type. Make result type for llvm.llround overloaded instead of 
fixing to i64

We shouldn't really make assumptions about possible sizes for long and long 
long. And longer term we should probably support vectorizing these intrinsics. 
By making the result types not fixed we can support vectors as well.

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

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/math-builtins.c
cfe/trunk/test/CodeGen/math-libcalls.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=361169&r1=361168&r2=361169&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon May 20 09:27:09 2019
@@ -391,6 +391,18 @@ static Value *emitFPIntBuiltin(CodeGenFu
   return CGF.Builder.CreateCall(F, {Src0, Src1});
 }
 
+// Emit an intrinsic that has overloaded integer result and fp operand.
+static Value *emitFPToIntRoundBuiltin(CodeGenFunction &CGF,
+  const CallExpr *E,
+  unsigned IntrinsicID) {
+   llvm::Type *ResultType = CGF.ConvertType(E->getType());
+   llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+
+   Function *F = CGF.CGM.getIntrinsic(IntrinsicID,
+  {ResultType, Src0->getType()});
+   return CGF.Builder.CreateCall(F, Src0);
+}
+
 /// EmitFAbs - Emit a call to @llvm.fabs().
 static Value *EmitFAbs(CodeGenFunction &CGF, Value *V) {
   Function *F = CGF.CGM.getIntrinsic(Intrinsic::fabs, V->getType());
@@ -1726,13 +1738,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 case Builtin::BIlroundl:
 case Builtin::BI__builtin_lround:
 case Builtin::BI__builtin_lroundf:
-case Builtin::BI__builtin_lroundl: {
-  llvm::Type *ResultType = ConvertType(E->getType());
-  int Width = ResultType->getPrimitiveSizeInBits();
-  return RValue::get(emitUnaryBuiltin(*this, E,
-  Width == 32 ? Intrinsic::lround_i32
-  : 
Intrinsic::lround_i64));
-}
+case Builtin::BI__builtin_lroundl:
+  return RValue::get(emitFPToIntRoundBuiltin(*this, E, Intrinsic::lround));
 
 case Builtin::BIllround:
 case Builtin::BIllroundf:
@@ -1740,7 +1747,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 case Builtin::BI__builtin_llround:
 case Builtin::BI__builtin_llroundf:
 case Builtin::BI__builtin_llroundl:
-  return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::llround));
+  return RValue::get(emitFPToIntRoundBuiltin(*this, E, 
Intrinsic::llround));
 
 default:
   break;

Modified: cfe/trunk/test/CodeGen/math-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/math-builtins.c?rev=361169&r1=361168&r2=361169&view=diff
==
--- cfe/trunk/test/CodeGen/math-builtins.c (original)
+++ cfe/trunk/test/CodeGen/math-builtins.c Mon May 20 09:27:09 2019
@@ -362,9 +362,9 @@ void foo(double *d, float f, float *fp,
 
   __builtin_llround(f);__builtin_llroundf(f);   __builtin_llroundl(f);
 
-// NO__ERRNO: declare i64 @llvm.llround.f64(double) [[READNONE_INTRINSIC]]
-// NO__ERRNO: declare i64 @llvm.llround.f32(float) [[READNONE_INTRINSIC]]
-// NO__ERRNO: declare i64 @llvm.llround.f80(x86_fp80) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llround.i64.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llround.i64.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llround.i64.f80(x86_fp80) 
[[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @llround(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llroundf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llroundl(x86_fp80) [[NOT_READNONE]]

Modified: cfe/trunk/test/CodeGen/math-libcalls.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/math-libcalls.c?rev=361169&r1=361168&r2=361169&view=diff
==
--- cfe/trunk/test/CodeGen/math-libcalls.c (original)
+++ cfe/trunk/test/CodeGen/math-libcalls.c Mon May 20 09:27:09 2019
@@ -317,9 +317,9 @@ void foo(double *d, float f, float *fp,
 
   llround(f);llroundf(f);   llroundl(f);
 
-// NO__ERRNO: declare i64 @llvm.llround.f64(double) [[READNONE_INTRINSIC]]
-// NO__ERRNO: declare i64 @llvm.llround.f32(float) [[READNONE_INTRINSIC]]
-// NO__ERRNO: declare i64 @llvm.llround.f80(x86_fp80) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llround.i64.f64(double) [[READNONE_INTRINSIC]]
+//

[PATCH] D62150: Renamed `apply` to `select` to avoid ADL conflict with `std::apply`

2019-05-20 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
gribozavr added a reviewer: ilya-biryukov.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

`std::apply` in C++14 and above is defined with two unrestricted arguments, and
it wins overload resolution in this case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62150

Files:
  clang/unittests/Tooling/RangeSelectorTest.cpp

Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===
--- clang/unittests/Tooling/RangeSelectorTest.cpp
+++ clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -53,7 +53,7 @@
 }
 
 // Applies \p Selector to \p Match and, on success, returns the selected source.
-Expected apply(RangeSelector Selector, const TestMatch &Match) {
+Expected select(RangeSelector Selector, const TestMatch &Match) {
   Expected Range = Selector(Match.Result);
   if (!Range)
 return Range.takeError();
@@ -62,7 +62,7 @@
 
 // Applies \p Selector to a trivial match with only a single bound node with id
 // "bound_node_id".  For use in testing unbound-node errors.
-Expected applyToTrivial(const RangeSelector &Selector) {
+Expected selectFromTrivial(const RangeSelector &Selector) {
   // We need to bind the result to something, or the match will fail. Use a
   // binding that is not used in the unbound node tests.
   TestMatch Match =
@@ -81,7 +81,7 @@
 // binds each one: a statement ("stmt"), a (non-member) ctor-initializer
 // ("init"), an expression ("expr") and a (nameless) declaration ("decl").  Used
 // to test failures caused by applying selectors to nodes of the wrong type.
-Expected applyToAssorted(RangeSelector Selector) {
+Expected selectFromAssorted(RangeSelector Selector) {
   StringRef Code = R"cc(
   struct A {};
   class F : public A {
@@ -113,7 +113,7 @@
 }
 
 TEST(RangeSelectorTest, UnboundNode) {
-  EXPECT_THAT_EXPECTED(applyToTrivial(node("unbound_id")),
+  EXPECT_THAT_EXPECTED(selectFromTrivial(node("unbound_id")),
Failed(withUnboundNodeMessage()));
 }
 
@@ -131,9 +131,9 @@
   TestMatch Match = matchCode(Code, Matcher);
 
   // Node-id specific version:
-  EXPECT_THAT_EXPECTED(apply(range(Arg0, Arg1), Match), HasValue("3, 7"));
+  EXPECT_THAT_EXPECTED(select(range(Arg0, Arg1), Match), HasValue("3, 7"));
   // General version:
-  EXPECT_THAT_EXPECTED(apply(range(node(Arg0), node(Arg1)), Match),
+  EXPECT_THAT_EXPECTED(select(range(node(Arg0), node(Arg1)), Match),
HasValue("3, 7"));
 }
 
@@ -141,21 +141,21 @@
   StringRef Code = "int f() { return 3; }";
   StringRef ID = "id";
   TestMatch Match = matchCode(Code, returnStmt().bind(ID));
-  EXPECT_THAT_EXPECTED(apply(node(ID), Match), HasValue("return 3;"));
+  EXPECT_THAT_EXPECTED(select(node(ID), Match), HasValue("return 3;"));
 }
 
 TEST(RangeSelectorTest, NodeOpExpression) {
   StringRef Code = "int f() { return 3; }";
   StringRef ID = "id";
   TestMatch Match = matchCode(Code, expr().bind(ID));
-  EXPECT_THAT_EXPECTED(apply(node(ID), Match), HasValue("3"));
+  EXPECT_THAT_EXPECTED(select(node(ID), Match), HasValue("3"));
 }
 
 TEST(RangeSelectorTest, StatementOp) {
   StringRef Code = "int f() { return 3; }";
   StringRef ID = "id";
   TestMatch Match = matchCode(Code, expr().bind(ID));
-  EXPECT_THAT_EXPECTED(apply(statement(ID), Match), HasValue("3;"));
+  EXPECT_THAT_EXPECTED(select(statement(ID), Match), HasValue("3;"));
 }
 
 TEST(RangeSelectorTest, MemberOp) {
@@ -170,7 +170,7 @@
   )cc";
   StringRef ID = "id";
   TestMatch Match = matchCode(Code, memberExpr().bind(ID));
-  EXPECT_THAT_EXPECTED(apply(member(ID), Match), HasValue("member"));
+  EXPECT_THAT_EXPECTED(select(member(ID), Match), HasValue("member"));
 }
 
 // Tests that member does not select any qualifiers on the member name.
@@ -189,7 +189,7 @@
   )cc";
   StringRef ID = "id";
   TestMatch Match = matchCode(Code, memberExpr().bind(ID));
-  EXPECT_THAT_EXPECTED(apply(member(ID), Match), HasValue("member"));
+  EXPECT_THAT_EXPECTED(select(member(ID), Match), HasValue("member"));
 }
 
 TEST(RangeSelectorTest, MemberOpTemplate) {
@@ -205,7 +205,7 @@
 
   StringRef ID = "id";
   TestMatch Match = matchCode(Code, memberExpr().bind(ID));
-  EXPECT_THAT_EXPECTED(apply(member(ID), Match), HasValue("foo"));
+  EXPECT_THAT_EXPECTED(select(member(ID), Match), HasValue("foo"));
 }
 
 TEST(RangeSelectorTest, MemberOpOperator) {
@@ -221,7 +221,7 @@
 
   StringRef ID = "id";
   TestMatch Match = matchCode(Code, memberExpr().bind(ID));
-  EXPECT_THAT_EXPECTED(apply(member(ID), Match), HasValue("operator *"));
+  EXPECT_THAT_EXPECTED(select(member(ID), Match), HasValue("operator *"));
 }
 
 TEST(RangeSelectorTest, NameOpNamedDecl) {
@@ -232,7 +232,7 @@
   )cc";
   StringRef ID = "id";
   TestMatch Match = matchCode(Code, functionDecl().bind(ID));
-  EXPECT_THAT_EXPECTED(apply(name(ID), Match), HasValue("myfun"));
+  EXPECT_THAT_EXPECTED(select(name(ID), Match), HasValue("myfun"));
 }
 
 TEST(Rang

[PATCH] D62151: [clangd] Add tweak to convert normal to raw string literal, when it contains escapes.

2019-05-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
mgorny.
Herald added a project: clang.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D62151

Files:
  clangd/refactor/tweaks/CMakeLists.txt
  clangd/refactor/tweaks/RawStringLiteral.cpp
  clangd/unittests/TweakTests.cpp

Index: clangd/unittests/TweakTests.cpp
===
--- clangd/unittests/TweakTests.cpp
+++ clangd/unittests/TweakTests.cpp
@@ -105,9 +105,10 @@
 }
 
 void checkTransform(llvm::StringRef ID, llvm::StringRef Input,
-llvm::StringRef Output) {
-  EXPECT_THAT_EXPECTED(apply(ID, Input), HasValue(Output))
-  << "action id is" << ID;
+std::string Output) {
+  auto Result = apply(ID, Input);
+  ASSERT_TRUE(bool(Result)) << llvm::toString(Result.takeError()) << Input;
+  EXPECT_EQ(Output, std::string(*Result)) << Input;
 }
 
 TEST(TweakTest, SwapIfBranches) {
@@ -185,6 +186,37 @@
   )cpp");
 }
 
+TEST(TweakTest, RawStringLiteral) {
+  llvm::StringLiteral ID = "RawStringLiteral";
+
+  checkAvailable(ID, R"cpp(
+const char *A = ^"^f^o^o^\^n^";
+const char *B = R"(multi )" ^"token " "str\ning";
+  )cpp");
+
+  checkNotAvailable(ID, R"cpp(
+const char *A = ^"f^o^o^o^"; // no chars need escaping
+const char *B = R"(multi )" ^"token " u8"str\ning"; // not all ascii
+const char *C = ^R^"^(^multi )" "token " "str\ning"; // chunk is raw
+const char *D = ^"token\n" __FILE__; // chunk is macro expansion
+const char *E = ^"a\r\n"; // contains forbidden escape character
+  )cpp");
+
+  const char *Input = R"cpp(
+const char *X = R"(multi
+token)" "\nst^ring\n" "literal";
+}
+  )cpp";
+  const char *Output = R"cpp(
+const char *X = R"(multi
+token
+string
+literal)";
+}
+  )cpp";
+  checkTransform(ID, Input, Output);
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/refactor/tweaks/RawStringLiteral.cpp
===
--- /dev/null
+++ clangd/refactor/tweaks/RawStringLiteral.cpp
@@ -0,0 +1,103 @@
+//===--- RawStringLiteral.cpp *- 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
+//
+//===--===//
+#include "ClangdUnit.h"
+#include "Logger.h"
+#include "SourceCode.h"
+#include "refactor/Tweak.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Stmt.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+/// Converts a string literal to a raw string.
+/// Before:
+///   printf("\"a\"\nb");
+///  ^
+/// After:
+///   printf(R"("a"
+/// b)");
+class RawStringLiteral : public Tweak {
+public:
+  const char *id() const override final;
+
+  bool prepare(const Selection &Inputs) override;
+  Expected apply(const Selection &Inputs) override;
+  std::string title() const override;
+
+private:
+  const clang::StringLiteral *Str = nullptr;
+};
+
+REGISTER_TWEAK(RawStringLiteral)
+
+static bool isNormalString(const StringLiteral &Str, SourceLocation Cursor,
+  SourceManager &SM) {
+  // All chunks must be normal ASCII strings, not u8"..." etc.
+  if (!Str.isAscii())
+return false;
+  SourceLocation LastTokenBeforeCursor;
+  for (auto I = Str.tokloc_begin(), E = Str.tokloc_end(); I != E; ++I) {
+if (I->isMacroID()) // No tokens in the string may be macro expansions.
+  return false;
+if (SM.isBeforeInTranslationUnit(*I, Cursor) || *I == Cursor)
+  LastTokenBeforeCursor = *I;
+  }
+  // Token we care about must be a normal "string": not raw, u8, etc.
+  const char* Data = SM.getCharacterData(LastTokenBeforeCursor);
+  return Data && *Data == '"';
+}
+
+static bool needsRaw(llvm::StringRef Content) {
+  return Content.find_first_of("\"\n\t") != StringRef::npos;
+}
+
+static bool canBeRaw(llvm::StringRef Content) {
+  for (char C : Content)
+if (!llvm::isPrint(C) && C != '\n' && C != '\t')
+  return false;
+  return !Content.contains(")\"");
+}
+
+bool RawStringLiteral::prepare(const Selection &Inputs) {
+  const SelectionTree::Node *N = Inputs.ASTSelection.commonAncestor();
+  if (!N)
+return false;
+  Str = dyn_cast_or_null(N->ASTNode.get());
+  return Str &&
+

[PATCH] D62150: Renamed `apply` to `select` to avoid ADL conflict with `std::apply`

2019-05-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

Quick LGTM to unbreak our integrate!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62150



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


r361170 - Renamed `apply` to `select` to avoid ADL conflict with `std::apply`

2019-05-20 Thread Dmitri Gribenko via cfe-commits
Author: gribozavr
Date: Mon May 20 09:30:49 2019
New Revision: 361170

URL: http://llvm.org/viewvc/llvm-project?rev=361170&view=rev
Log:
Renamed `apply` to `select` to avoid ADL conflict with `std::apply`

Summary:
`std::apply` in C++14 and above is defined with two unrestricted arguments, and
it wins overload resolution in this case.

Reviewers: ilya-biryukov

Subscribers: cfe-commits, ymandel

Tags: #clang

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

Modified:
cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp

Modified: cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp?rev=361170&r1=361169&r2=361170&view=diff
==
--- cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp Mon May 20 09:30:49 2019
@@ -53,7 +53,7 @@ template  TestMatch matchCod
 }
 
 // Applies \p Selector to \p Match and, on success, returns the selected 
source.
-Expected apply(RangeSelector Selector, const TestMatch &Match) {
+Expected select(RangeSelector Selector, const TestMatch &Match) {
   Expected Range = Selector(Match.Result);
   if (!Range)
 return Range.takeError();
@@ -62,7 +62,7 @@ Expected apply(RangeSelector
 
 // Applies \p Selector to a trivial match with only a single bound node with id
 // "bound_node_id".  For use in testing unbound-node errors.
-Expected applyToTrivial(const RangeSelector &Selector) {
+Expected selectFromTrivial(const RangeSelector &Selector) {
   // We need to bind the result to something, or the match will fail. Use a
   // binding that is not used in the unbound node tests.
   TestMatch Match =
@@ -81,7 +81,7 @@ testing::Matcher withUnboun
 // binds each one: a statement ("stmt"), a (non-member) ctor-initializer
 // ("init"), an expression ("expr") and a (nameless) declaration ("decl").  
Used
 // to test failures caused by applying selectors to nodes of the wrong type.
-Expected applyToAssorted(RangeSelector Selector) {
+Expected selectFromAssorted(RangeSelector Selector) {
   StringRef Code = R"cc(
   struct A {};
   class F : public A {
@@ -113,7 +113,7 @@ testing::Matcher withTypeEr
 }
 
 TEST(RangeSelectorTest, UnboundNode) {
-  EXPECT_THAT_EXPECTED(applyToTrivial(node("unbound_id")),
+  EXPECT_THAT_EXPECTED(selectFromTrivial(node("unbound_id")),
Failed(withUnboundNodeMessage()));
 }
 
@@ -131,9 +131,9 @@ TEST(RangeSelectorTest, RangeOp) {
   TestMatch Match = matchCode(Code, Matcher);
 
   // Node-id specific version:
-  EXPECT_THAT_EXPECTED(apply(range(Arg0, Arg1), Match), HasValue("3, 7"));
+  EXPECT_THAT_EXPECTED(select(range(Arg0, Arg1), Match), HasValue("3, 7"));
   // General version:
-  EXPECT_THAT_EXPECTED(apply(range(node(Arg0), node(Arg1)), Match),
+  EXPECT_THAT_EXPECTED(select(range(node(Arg0), node(Arg1)), Match),
HasValue("3, 7"));
 }
 
@@ -141,21 +141,21 @@ TEST(RangeSelectorTest, NodeOpStatement)
   StringRef Code = "int f() { return 3; }";
   StringRef ID = "id";
   TestMatch Match = matchCode(Code, returnStmt().bind(ID));
-  EXPECT_THAT_EXPECTED(apply(node(ID), Match), HasValue("return 3;"));
+  EXPECT_THAT_EXPECTED(select(node(ID), Match), HasValue("return 3;"));
 }
 
 TEST(RangeSelectorTest, NodeOpExpression) {
   StringRef Code = "int f() { return 3; }";
   StringRef ID = "id";
   TestMatch Match = matchCode(Code, expr().bind(ID));
-  EXPECT_THAT_EXPECTED(apply(node(ID), Match), HasValue("3"));
+  EXPECT_THAT_EXPECTED(select(node(ID), Match), HasValue("3"));
 }
 
 TEST(RangeSelectorTest, StatementOp) {
   StringRef Code = "int f() { return 3; }";
   StringRef ID = "id";
   TestMatch Match = matchCode(Code, expr().bind(ID));
-  EXPECT_THAT_EXPECTED(apply(statement(ID), Match), HasValue("3;"));
+  EXPECT_THAT_EXPECTED(select(statement(ID), Match), HasValue("3;"));
 }
 
 TEST(RangeSelectorTest, MemberOp) {
@@ -170,7 +170,7 @@ TEST(RangeSelectorTest, MemberOp) {
   )cc";
   StringRef ID = "id";
   TestMatch Match = matchCode(Code, memberExpr().bind(ID));
-  EXPECT_THAT_EXPECTED(apply(member(ID), Match), HasValue("member"));
+  EXPECT_THAT_EXPECTED(select(member(ID), Match), HasValue("member"));
 }
 
 // Tests that member does not select any qualifiers on the member name.
@@ -189,7 +189,7 @@ TEST(RangeSelectorTest, MemberOpQualifie
   )cc";
   StringRef ID = "id";
   TestMatch Match = matchCode(Code, memberExpr().bind(ID));
-  EXPECT_THAT_EXPECTED(apply(member(ID), Match), HasValue("member"));
+  EXPECT_THAT_EXPECTED(select(member(ID), Match), HasValue("member"));
 }
 
 TEST(RangeSelectorTest, MemberOpTemplate) {
@@ -205,7 +205,7 @@ TEST(RangeSelectorTest, MemberOpTemplate
 
   StringRef ID = "id";
   TestMatch Match = matchCode(Code, memberExpr().bind(ID));
-  EXPECT_THAT_EXPECTED(apply(member(ID), Match), HasValue("foo"));
+  EXPECT_THAT_EXPECTED(select(member(ID), Match), HasV

[PATCH] D62150: Renamed `apply` to `select` to avoid ADL conflict with `std::apply`

2019-05-20 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361170: Renamed `apply` to `select` to avoid ADL conflict 
with `std::apply` (authored by gribozavr, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62150?vs=200313&id=200316#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D62150

Files:
  unittests/Tooling/RangeSelectorTest.cpp

Index: unittests/Tooling/RangeSelectorTest.cpp
===
--- unittests/Tooling/RangeSelectorTest.cpp
+++ unittests/Tooling/RangeSelectorTest.cpp
@@ -53,7 +53,7 @@
 }
 
 // Applies \p Selector to \p Match and, on success, returns the selected source.
-Expected apply(RangeSelector Selector, const TestMatch &Match) {
+Expected select(RangeSelector Selector, const TestMatch &Match) {
   Expected Range = Selector(Match.Result);
   if (!Range)
 return Range.takeError();
@@ -62,7 +62,7 @@
 
 // Applies \p Selector to a trivial match with only a single bound node with id
 // "bound_node_id".  For use in testing unbound-node errors.
-Expected applyToTrivial(const RangeSelector &Selector) {
+Expected selectFromTrivial(const RangeSelector &Selector) {
   // We need to bind the result to something, or the match will fail. Use a
   // binding that is not used in the unbound node tests.
   TestMatch Match =
@@ -81,7 +81,7 @@
 // binds each one: a statement ("stmt"), a (non-member) ctor-initializer
 // ("init"), an expression ("expr") and a (nameless) declaration ("decl").  Used
 // to test failures caused by applying selectors to nodes of the wrong type.
-Expected applyToAssorted(RangeSelector Selector) {
+Expected selectFromAssorted(RangeSelector Selector) {
   StringRef Code = R"cc(
   struct A {};
   class F : public A {
@@ -113,7 +113,7 @@
 }
 
 TEST(RangeSelectorTest, UnboundNode) {
-  EXPECT_THAT_EXPECTED(applyToTrivial(node("unbound_id")),
+  EXPECT_THAT_EXPECTED(selectFromTrivial(node("unbound_id")),
Failed(withUnboundNodeMessage()));
 }
 
@@ -131,9 +131,9 @@
   TestMatch Match = matchCode(Code, Matcher);
 
   // Node-id specific version:
-  EXPECT_THAT_EXPECTED(apply(range(Arg0, Arg1), Match), HasValue("3, 7"));
+  EXPECT_THAT_EXPECTED(select(range(Arg0, Arg1), Match), HasValue("3, 7"));
   // General version:
-  EXPECT_THAT_EXPECTED(apply(range(node(Arg0), node(Arg1)), Match),
+  EXPECT_THAT_EXPECTED(select(range(node(Arg0), node(Arg1)), Match),
HasValue("3, 7"));
 }
 
@@ -141,21 +141,21 @@
   StringRef Code = "int f() { return 3; }";
   StringRef ID = "id";
   TestMatch Match = matchCode(Code, returnStmt().bind(ID));
-  EXPECT_THAT_EXPECTED(apply(node(ID), Match), HasValue("return 3;"));
+  EXPECT_THAT_EXPECTED(select(node(ID), Match), HasValue("return 3;"));
 }
 
 TEST(RangeSelectorTest, NodeOpExpression) {
   StringRef Code = "int f() { return 3; }";
   StringRef ID = "id";
   TestMatch Match = matchCode(Code, expr().bind(ID));
-  EXPECT_THAT_EXPECTED(apply(node(ID), Match), HasValue("3"));
+  EXPECT_THAT_EXPECTED(select(node(ID), Match), HasValue("3"));
 }
 
 TEST(RangeSelectorTest, StatementOp) {
   StringRef Code = "int f() { return 3; }";
   StringRef ID = "id";
   TestMatch Match = matchCode(Code, expr().bind(ID));
-  EXPECT_THAT_EXPECTED(apply(statement(ID), Match), HasValue("3;"));
+  EXPECT_THAT_EXPECTED(select(statement(ID), Match), HasValue("3;"));
 }
 
 TEST(RangeSelectorTest, MemberOp) {
@@ -170,7 +170,7 @@
   )cc";
   StringRef ID = "id";
   TestMatch Match = matchCode(Code, memberExpr().bind(ID));
-  EXPECT_THAT_EXPECTED(apply(member(ID), Match), HasValue("member"));
+  EXPECT_THAT_EXPECTED(select(member(ID), Match), HasValue("member"));
 }
 
 // Tests that member does not select any qualifiers on the member name.
@@ -189,7 +189,7 @@
   )cc";
   StringRef ID = "id";
   TestMatch Match = matchCode(Code, memberExpr().bind(ID));
-  EXPECT_THAT_EXPECTED(apply(member(ID), Match), HasValue("member"));
+  EXPECT_THAT_EXPECTED(select(member(ID), Match), HasValue("member"));
 }
 
 TEST(RangeSelectorTest, MemberOpTemplate) {
@@ -205,7 +205,7 @@
 
   StringRef ID = "id";
   TestMatch Match = matchCode(Code, memberExpr().bind(ID));
-  EXPECT_THAT_EXPECTED(apply(member(ID), Match), HasValue("foo"));
+  EXPECT_THAT_EXPECTED(select(member(ID), Match), HasValue("foo"));
 }
 
 TEST(RangeSelectorTest, MemberOpOperator) {
@@ -221,7 +221,7 @@
 
   StringRef ID = "id";
   TestMatch Match = matchCode(Code, memberExpr().bind(ID));
-  EXPECT_THAT_EXPECTED(apply(member(ID), Match), HasValue("operator *"));
+  EXPECT_THAT_EXPECTED(select(member(ID), Match), HasValue("operator *"));
 }
 
 TEST(RangeSelectorTest, NameOpNamedDecl) {
@@ -232,7 +232,7 @@
   )cc";
   StringRef ID = "id";
   TestMatch Match = matchCode(Code, functionDecl().bind(ID));
-  EXPECT_THAT_EXPECTED(apply(name(ID), Match), HasValue("myfun"));
+  EXPECT_THAT_EXPECTED(select(nam

[PATCH] D62019: [clang] Handle lrint/llrint builtins

2019-05-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D62019



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


[PATCH] D62150: Renamed `apply` to `select` to avoid ADL conflict with `std::apply`

2019-05-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

@ymandel, feel free to change the name to your liking if you don't like 
`select`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62150



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


[PATCH] D62143: [clangd] Make it possible to use VFS from parsing for getting tidy options

2019-05-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

This seems fine:

- please give this `function<>` type a name - maybe `ClangTidyOptionsBuilder` 
or so?
- while we're defining this, we should make it threadsafe because that's what 
we really want
- document that it's threadsafe and approximately why we don't use 
ClangTidyOptionsProvider


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62143



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


[PATCH] D62050: [Analysis] Only run plugins tests if plugins are actually enabled

2019-05-20 Thread Don Hinton via Phabricator via cfe-commits
hintonda added inline comments.



Comment at: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake:930
-else()
+if(BUILD_SHARED_LIBS OR LLVM_BUILD_LLVM_DYLIB)
   set(LLVM_ENABLE_PLUGINS ON)
 endif()

This is a breaking patch.  What's the rational for unilaterally disabling 
LLVM_ENABLE_PLUGINS.

```
It gives the following errors:
-- PrintFunctionNames ignored -- Loadable modules not supported on this 
platform.
-- AnnotateFunctions ignored -- Loadable modules not supported on this platform.
-- SampleAnalyzerPlugin ignored -- Loadable modules not supported on this 
platform.
-- CheckerDependencyHandlingAnalyzerPlugin ignored -- Loadable modules not 
supported on this platform.
-- CheckerOptionHandlingAnalyzerPlugin ignored -- Loadable modules not 
supported on this platform.
-- BugpointPasses ignored -- Loadable modules not supported on this platform.
-- TestPlugin ignored -- Loadable modules not supported on this platform.
```


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62050



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


[PATCH] D62152: [ARM][AArch64] Fix incorrect handling of alignment in va_arg code generation

2019-05-20 Thread John Brawn via Phabricator via cfe-commits
john.brawn created this revision.
john.brawn added reviewers: chill, efriedma, t.p.northover, rjmccall.
Herald added subscribers: kristof.beyls, javed.absar.
Herald added a project: clang.

Overaligned and underaligned types (i.e. types where the alignment has been 
increased or decreased using the aligned and packed attributes) weren't being 
correctly handled in all cases, as the unadjusted alignment should be used.

This patch also adjusts getTypeUnadjustedAlign to correctly handle typedefs of 
non-aggregate types, which it appears it never had to handle before.


Repository:
  rC Clang

https://reviews.llvm.org/D62152

Files:
  lib/AST/ASTContext.cpp
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/aarch64-varargs.c
  test/CodeGen/arm-varargs.c

Index: test/CodeGen/arm-varargs.c
===
--- /dev/null
+++ test/CodeGen/arm-varargs.c
@@ -0,0 +1,322 @@
+// RUN: %clang_cc1 -triple arm-none-eabi -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-LE %s
+// RUN: %clang_cc1 -triple armeb-none-eabi -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-BE %s
+
+#include 
+
+// Obviously there's more than one way to implement va_arg. This test should at
+// least prevent unintentional regressions caused by refactoring.
+
+va_list the_list;
+
+int simple_int(void) {
+// CHECK-LABEL: define i32 @simple_int
+  return va_arg(the_list, int);
+// CHECK: [[CUR:%[a-z0-9._]+]] = load i8*, i8** getelementptr inbounds (%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 0), align 4
+// CHECK: [[NEXT:%[a-z0-9._]+]] = getelementptr inbounds i8, i8* [[CUR]], i32 4
+// CHECK: store i8* [[NEXT]], i8** getelementptr inbounds (%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 0), align 4
+// CHECK: [[ADDR:%[a-z0-9._]+]] = bitcast i8* [[CUR]] to i32*
+// CHECK: [[RESULT:%[a-z0-9._]+]] = load i32, i32* [[ADDR]]
+// CHECK: ret i32 [[RESULT]]
+}
+
+struct bigstruct {
+  int a[10];
+};
+
+struct bigstruct simple_struct(void) {
+// CHECK-LABEL: define void @simple_struct(%struct.bigstruct* noalias sret %agg.result)
+  return va_arg(the_list, struct bigstruct);
+// CHECK: [[CUR:%[a-z0-9._]+]] = load i8*, i8** getelementptr inbounds (%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 0), align 4
+// CHECK: [[NEXT:%[a-z0-9._]+]] = getelementptr inbounds i8, i8* [[CUR]], i32 40
+// CHECK: store i8* [[NEXT]], i8** getelementptr inbounds (%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 0), align 4
+// CHECK: [[ADDR:%[a-z0-9._]+]] = bitcast i8* [[CUR]] to %struct.bigstruct*
+// CHECK: [[DEST_ADDR:%[a-z0-9._]+]] = bitcast %struct.bigstruct* %agg.result to i8*
+// CHECK: [[SRC_ADDR:%[a-z0-9._]+]] = bitcast %struct.bigstruct* [[ADDR]] to i8*
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 [[DEST_ADDR]], i8* align 4 [[SRC_ADDR]], i32 40, i1 false)
+// CHECK: ret void
+}
+
+struct aligned_bigstruct {
+  float a;
+  long double b;
+};
+
+struct aligned_bigstruct simple_aligned_struct(void) {
+// CHECK-LABEL: define void @simple_aligned_struct(%struct.aligned_bigstruct* noalias sret %agg.result)
+  return va_arg(the_list, struct aligned_bigstruct);
+// CHECK: [[CUR:%[a-z0-9._]+]] = load i8*, i8** getelementptr inbounds (%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 0), align 4
+// CHECK: [[CUR_INT:%[a-z0-9._]+]] = ptrtoint i8* [[CUR]] to i32
+// CHECK: [[CUR_INT_ADD:%[a-z0-9._]+]] = add i32 [[CUR_INT]], 7
+// CHECK: [[CUR_INT_ALIGNED:%[a-z0-9._]+]] = and i32 [[CUR_INT_ADD]], -8
+// CHECK: [[CUR_ALIGNED:%[a-z0-9._]+]] = inttoptr i32 [[CUR_INT_ALIGNED]] to i8*
+// CHECK: [[NEXT:%[a-z0-9._]+]] = getelementptr inbounds i8, i8* [[CUR_ALIGNED]], i32 16
+// CHECK: store i8* [[NEXT]], i8** getelementptr inbounds (%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 0), align 4
+// CHECK: [[ADDR:%[a-z0-9._]+]] = bitcast i8* [[CUR_ALIGNED]] to %struct.aligned_bigstruct*
+// CHECK: [[DEST_ADDR:%[a-z0-9._]+]] = bitcast %struct.aligned_bigstruct* %agg.result to i8*
+// CHECK: [[SRC_ADDR:%[a-z0-9._]+]] = bitcast %struct.aligned_bigstruct* [[ADDR]] to i8*
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 [[DEST_ADDR]], i8* align 8 [[SRC_ADDR]], i32 16, i1 false)
+// CHECK: ret void
+}
+
+double simple_double(void) {
+// CHECK-LABEL: define double @simple_double
+  return va_arg(the_list, double);
+// CHECK: [[CUR:%[a-z0-9._]+]] = load i8*, i8** getelementptr inbounds (%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 0), align 4
+// CHECK: [[CUR_INT:%[a-z0-9._]+]] = ptrtoint i8* [[CUR]] to i32
+// CHECK: [[CUR_INT_ADD:%[a-z0-9._]+]] = add i32 [[CUR_INT]], 7
+// CHECK: [[CUR_INT_ALIGNED:%[a-z0-9._]+]] = and i32 [[CUR_INT_ADD]], -8
+// CHECK: [[CUR_ALIGNED:%[a-z0-9._]+]] = inttoptr i32 [[CUR_INT_ALIGNED]] to i8*
+// CHECK: [[NEXT:%[a-z0-9._]+]] = getelementptr inbounds i8, i8* [[CUR_ALIGNED]], i32 8
+// CHECK: store i8* [[NEXT]], i8** getelementptr inbounds (%struct.__va_list, %struc

r361172 - Dump macro expansion information as needed when outputting the AST to JSON.

2019-05-20 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon May 20 09:46:44 2019
New Revision: 361172

URL: http://llvm.org/viewvc/llvm-project?rev=361172&view=rev
Log:
Dump macro expansion information as needed when outputting the AST to JSON.

Added:
cfe/trunk/test/AST/ast-dump-macro-json.c
Modified:
cfe/trunk/include/clang/AST/JSONNodeDumper.h
cfe/trunk/lib/AST/JSONNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/JSONNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/JSONNodeDumper.h?rev=361172&r1=361171&r2=361172&view=diff
==
--- cfe/trunk/include/clang/AST/JSONNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/JSONNodeDumper.h Mon May 20 09:46:44 2019
@@ -132,6 +132,12 @@ class JSONNodeDumper
   JOS.attribute(Key, Value);
   }
 
+  // Creates a single SourceLocation JSON representation of the given location.
+  llvm::json::Object createBareSourceLocation(SourceLocation Loc);
+  // Creates a JSON representation of a SourceLocation based on its presumed
+  // spelling location. If the given location represents a macro invocation,
+  // this outputs two sub-objects: one for the spelling and one for the
+  // expansion location.
   llvm::json::Object createSourceLocation(SourceLocation Loc);
   llvm::json::Object createSourceRange(SourceRange R);
   std::string createPointerRepresentation(const void *Ptr);

Modified: cfe/trunk/lib/AST/JSONNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/JSONNodeDumper.cpp?rev=361172&r1=361171&r2=361172&view=diff
==
--- cfe/trunk/lib/AST/JSONNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/JSONNodeDumper.cpp Mon May 20 09:46:44 2019
@@ -146,9 +146,9 @@ void JSONNodeDumper::Visit(const Generic
   attributeOnlyIfTrue("selected", A.isSelected());
 }
 
-llvm::json::Object JSONNodeDumper::createSourceLocation(SourceLocation Loc) {
-  SourceLocation Spelling = SM.getSpellingLoc(Loc);
-  PresumedLoc Presumed = SM.getPresumedLoc(Spelling);
+llvm::json::Object
+JSONNodeDumper::createBareSourceLocation(SourceLocation Loc) {
+  PresumedLoc Presumed = SM.getPresumedLoc(Loc);
 
   if (Presumed.isInvalid())
 return llvm::json::Object{};
@@ -158,6 +158,28 @@ llvm::json::Object JSONNodeDumper::creat
 {"col", Presumed.getColumn()}};
 }
 
+llvm::json::Object JSONNodeDumper::createSourceLocation(SourceLocation Loc) {
+  SourceLocation Spelling = SM.getSpellingLoc(Loc);
+  SourceLocation Expansion = SM.getExpansionLoc(Loc);
+
+  llvm::json::Object SLoc = createBareSourceLocation(Spelling);
+  if (Expansion != Spelling) {
+// If the expansion and the spelling are different, output subobjects
+// describing both locations.
+llvm::json::Object ELoc = createBareSourceLocation(Expansion);
+
+// If there is a macro expansion, add extra information if the interesting
+// bit is the macro arg expansion.
+if (SM.isMacroArgExpansion(Loc))
+  ELoc["isMacroArgExpansion"] = true;
+
+return llvm::json::Object{{"spellingLoc", std::move(SLoc)},
+  {"expansionLoc", std::move(ELoc)}};
+  }
+
+  return SLoc;
+}
+
 llvm::json::Object JSONNodeDumper::createSourceRange(SourceRange R) {
   return llvm::json::Object{{"begin", createSourceLocation(R.getBegin())},
 {"end", createSourceLocation(R.getEnd())}};

Added: cfe/trunk/test/AST/ast-dump-macro-json.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-macro-json.c?rev=361172&view=auto
==
--- cfe/trunk/test/AST/ast-dump-macro-json.c (added)
+++ cfe/trunk/test/AST/ast-dump-macro-json.c Mon May 20 09:46:44 2019
@@ -0,0 +1,179 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump=json %s | 
FileCheck %s
+
+#define FOO frobble
+#define BAR FOO
+
+void FOO(void);
+void BAR(void);
+
+#define BING(x)x
+
+void BING(quux)(void);
+
+#define BLIP(x, y) x ## y
+#define BLAP(x, y) BLIP(x, y)
+
+void BLAP(foo, __COUNTER__)(void);
+void BLAP(foo, __COUNTER__)(void);
+
+
+// CHECK:  "kind": "FunctionDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "expansionLoc": {
+// CHECK-NEXT:"col": 6,
+// CHECK-NEXT:"file": "{{.*}}",
+// CHECK-NEXT:"line": 6
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "spellingLoc": {
+// CHECK-NEXT:"col": 13,
+// CHECK-NEXT:"file": "{{.*}}",
+// CHECK-NEXT:"line": 3
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"file": "{{.*}}",
+// CHECK-NEXT:"line": 6
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"col": 14,
+// CHECK-NEXT:"file": "{{.*}}",
+// CHECK-NEXT:"line": 6
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "frobble",
+// CHECK-NEXT:  "type": {
+// CHECK

[PATCH] D62050: [Analysis] Only run plugins tests if plugins are actually enabled

2019-05-20 Thread Don Hinton via Phabricator via cfe-commits
hintonda added inline comments.



Comment at: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake:930
-else()
+if(BUILD_SHARED_LIBS OR LLVM_BUILD_LLVM_DYLIB)
   set(LLVM_ENABLE_PLUGINS ON)
 endif()

hintonda wrote:
> This is a breaking patch.  What's the rational for unilaterally disabling 
> LLVM_ENABLE_PLUGINS.
> 
> ```
> It gives the following errors:
> -- PrintFunctionNames ignored -- Loadable modules not supported on this 
> platform.
> -- AnnotateFunctions ignored -- Loadable modules not supported on this 
> platform.
> -- SampleAnalyzerPlugin ignored -- Loadable modules not supported on this 
> platform.
> -- CheckerDependencyHandlingAnalyzerPlugin ignored -- Loadable modules not 
> supported on this platform.
> -- CheckerOptionHandlingAnalyzerPlugin ignored -- Loadable modules not 
> supported on this platform.
> -- BugpointPasses ignored -- Loadable modules not supported on this platform.
> -- TestPlugin ignored -- Loadable modules not supported on this platform.
> ```
Btw, the change essentially turns off testing of plugins, and bugpoint, etc., 
in all the buildbots, but since it isn't reported as an error, they don't 
report that these tests are no longer run.,


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62050



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


[PATCH] D61838: [Sema] Suppress additional warnings for C's zero initializer

2019-05-20 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn accepted this revision.
Lekensteyn added a comment.

Verified again!


Repository:
  rC Clang

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

https://reviews.llvm.org/D61838



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


[PATCH] D62149: [LibTooling] Update Transformer to use RangeSelector instead of NodePart enum.

2019-05-20 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 200325.
ymandel added a comment.

Removed most `change` overloads.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62149

Files:
  clang/include/clang/Tooling/Refactoring/Transformer.h
  clang/lib/Tooling/Refactoring/Transformer.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -7,8 +7,8 @@
 //===--===//
 
 #include "clang/Tooling/Refactoring/Transformer.h"
-
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Refactoring/RangeSelector.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
@@ -147,7 +147,7 @@
   on(expr(hasType(isOrPointsTo(StringType)))
  .bind(StringExpr)),
   callee(cxxMethodDecl(hasName("c_str")),
-  change("REPLACED"));
+  change(text("REPLACED")));
   R.Cases[0].Explanation = text("Use size() method directly on string.");
   return R;
 }
@@ -183,7 +183,7 @@
 hasName("proto::ProtoCommandLineFlag"
.bind(Flag)),
 unless(callee(cxxMethodDecl(hasName("GetProto"),
-  change(Flag, "EXPR"));
+  change(node(Flag), text("EXPR")));
 
   std::string Input = R"cc(
 proto::ProtoCommandLineFlag flag;
@@ -201,9 +201,8 @@
 
 TEST_F(TransformerTest, NodePartNameNamedDecl) {
   StringRef Fun = "fun";
-  RewriteRule Rule =
-  makeRule(functionDecl(hasName("bad")).bind(Fun),
-   change(Fun, NodePart::Name, "good"));
+  RewriteRule Rule = makeRule(functionDecl(hasName("bad")).bind(Fun),
+  change(name(Fun), text("good")));
 
   std::string Input = R"cc(
 int bad(int x);
@@ -235,7 +234,7 @@
 
   StringRef Ref = "ref";
   testRule(makeRule(declRefExpr(to(functionDecl(hasName("bad".bind(Ref),
-change(Ref, NodePart::Name, "good")),
+change(name(Ref), text("good"))),
Input, Expected);
 }
 
@@ -253,7 +252,7 @@
 
   StringRef Ref = "ref";
   Transformer T(makeRule(declRefExpr(to(functionDecl())).bind(Ref),
- change(Ref, NodePart::Name, "good")),
+ change(name(Ref), text("good"))),
 consumer());
   T.registerMatchers(&MatchFinder);
   EXPECT_FALSE(rewrite(Input));
@@ -262,7 +261,7 @@
 TEST_F(TransformerTest, NodePartMember) {
   StringRef E = "expr";
   RewriteRule Rule = makeRule(memberExpr(member(hasName("bad"))).bind(E),
-  change(E, NodePart::Member, "good"));
+  change(member(E), text("good")));
 
   std::string Input = R"cc(
 struct S {
@@ -315,8 +314,7 @@
   )cc";
 
   StringRef E = "expr";
-  testRule(makeRule(memberExpr().bind(E),
-change(E, NodePart::Member, "good")),
+  testRule(makeRule(memberExpr().bind(E), change(member(E), text("good"))),
Input, Expected);
 }
 
@@ -348,7 +346,7 @@
 
   StringRef MemExpr = "member";
   testRule(makeRule(memberExpr().bind(MemExpr),
-change(MemExpr, NodePart::Member, "good")),
+change(member(MemExpr), text("good"))),
Input, Expected);
 }
 
@@ -371,8 +369,9 @@
   StringRef C = "C", T = "T", E = "E";
   testRule(makeRule(ifStmt(hasCondition(expr().bind(C)),
hasThen(stmt().bind(T)), hasElse(stmt().bind(E))),
-{change(C, "true"), change(T, "{ /* then */ }"),
- change(E, "{ /* else */ }")}),
+{change(node(C), text("true")),
+ change(statement(T), text("{ /* then */ }")),
+ change(statement(E), text("{ /* else */ }"))}),
Input, Expected);
 }
 
@@ -383,7 +382,7 @@
 hasName("proto::ProtoCommandLineFlag"
.bind(Flag)),
 unless(callee(cxxMethodDecl(hasName("GetProto"),
-  change(Flag, "PROTO"));
+  change(node(Flag), text("PROTO")));
 
   std::string Input = R"cc(
 proto::ProtoCommandLineFlag flag;
@@ -410,7 +409,7 @@
hasArgument(0, cxxMemberCallExpr(
   on(expr().bind(S)),
   callee(cxxMethodDecl(hasName("c_str")),
-  change("DISTINCT"));
+  change(text("DISTINCT")));
 }
 
 TEST_F(TransformerTest, OrderedRuleRelated) {
@@ -475,7 +474,7 @@
   -> llvm::Expected {
 return llvm::createStringError(llvm::errc::invalid_argument, "ERROR");
   }

[PATCH] D62149: [LibTooling] Update Transformer to use RangeSelector instead of NodePart enum.

2019-05-20 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 2 inline comments as done.
ymandel added inline comments.



Comment at: clang/include/clang/Tooling/Refactoring/Transformer.h:186
+/// where a \c TextGenerator, \c RangeSelector are otherwise expected.
+inline ASTEdit change(RangeSelector Target, std::string Replacement) {
+  return change(std::move(Target), text(std::move(Replacement)));

ilya-biryukov wrote:
> The overloads create quite a lot of noise (and we are already starting to see 
> a combinatorial explosion with two classes).
> 
> Could we try to overcome this? I see two options:
> 1. Turn `TextGenerator` and `RangeSelector` into classes, which are 
> constructible from `string` or `function`.
> 2. Remove the string overloads, force users to explicitly construct the 
> parameters.
> 
> Option (2) actually is simple and would add a bit of type safety, but will 
> make some client code a bit less readable. Do you think the readability hit 
> is significant?
Agreed. I wasn't loving all the overloads myself.  I removed all the 
string-related overloads. left the one overload that lets the user implicitly 
specify the entirety of the match.

I'm ok with the result.  Certainly for RangeSelector, it forces a consistency 
which I like. For the use of text() -- I could go both ways, but i think pure 
text replacements will be rare outside of tests, so I'm not sure users will be 
terribly inconvenienced by this.

The only overload i'm unsure about is the one I left, because I think a) it 
will be a common case and b) it will confuse users to learn to use 
`RewriteRule::RootID`.  That said, if you have an elegant, but explicit, 
alternative I'm interested.  We could, for example, add combinators 
`matchedNode()` and `matchedStatement()`, defined respectively as 
`node(RewriteRule::RootID)` and `statement(RewriteRule::RootID)`.  Or, add 
a`makeRule` overload for the `node()` case (and let users be explicit when they 
want the `statement()` case.).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62149



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


[PATCH] D62143: [clangd] Make it possible to use VFS from parsing for getting tidy options

2019-05-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 200328.
ilya-biryukov added a comment.

- Add a typedef for function
- Make the provider thread-safe


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62143

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp

Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/Version.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -27,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -496,7 +498,9 @@
   }
 
   // Create an empty clang-tidy option.
-  std::unique_ptr ClangTidyOptProvider;
+  std::mutex ClangTidyOptMu;
+  std::unique_ptr
+  ClangTidyOptProvider; /*GUARDED_BY(ClangTidyOptLock)*/
   if (EnableClangTidy) {
 auto OverrideClangTidyOptions = tidy::ClangTidyOptions::getDefaults();
 OverrideClangTidyOptions.Checks = ClangTidyChecks;
@@ -505,7 +509,13 @@
 /* Default */ tidy::ClangTidyOptions::getDefaults(),
 /* Override */ OverrideClangTidyOptions, FSProvider.getFileSystem());
   }
-  Opts.ClangTidyOptProvider = ClangTidyOptProvider.get();
+  Opts.GetClangTidyOptions = [&](llvm::vfs::FileSystem &,
+ llvm::StringRef File) {
+// This function must be thread-safe and tidy option provides are not.
+std::lock_guard Lock(ClangTidyOptMu);
+// FIXME: use the FS provided to the function.
+return ClangTidyOptProvider->getOptions(File);
+  };
   Opts.SuggestMissingIncludes = SuggestMissingIncludes;
   llvm::Optional OffsetEncodingFromFlag;
   if (ForceOffsetEncoding != OffsetEncoding::UnsupportedEncoding)
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -50,6 +50,12 @@
   virtual void onFileUpdated(PathRef File, const TUStatus &Status){};
 };
 
+/// When set, used by ClangdServer to get clang-tidy options for each particular
+/// file. Must be thread-safe. We use this instead of ClangTidyOptionsProvider
+/// to allow reading tidy configs from the VFS used for parsing.
+using ClangTidyOptionsBuilder = std::function;
+
 /// Manages a collection of source files and derived data (ASTs, indexes),
 /// and provides language-aware features such as code completion.
 ///
@@ -94,12 +100,12 @@
 /// If set, use this index to augment code completion results.
 SymbolIndex *StaticIndex = nullptr;
 
-/// If set, enable clang-tidy in clangd, used to get clang-tidy
+/// If set, enable clang-tidy in clangd and use to it get clang-tidy
 /// configurations for a particular file.
 /// Clangd supports only a small subset of ClangTidyOptions, these options
 /// (Checks, CheckOptions) are about which clang-tidy checks will be
 /// enabled.
-tidy::ClangTidyOptionsProvider *ClangTidyOptProvider = nullptr;
+ClangTidyOptionsBuilder GetClangTidyOptions;
 
 /// Clangd's workspace root. Relevant for "workspace" operations not bound
 /// to a particular file.
@@ -278,8 +284,8 @@
   // Storage for merged views of the various indexes.
   std::vector> MergedIdx;
 
-  // The provider used to provide a clang-tidy option for a specific file.
-  tidy::ClangTidyOptionsProvider *ClangTidyOptProvider = nullptr;
+  // When set, provides clang-tidy options for a specific file.
+  ClangTidyOptionsBuilder GetClangTidyOptions;
 
   // If this is true, suggest include insertion fixes for diagnostic errors that
   // can be caused by missing includes (e.g. member access in incomplete type).
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -90,7 +90,7 @@
   DynamicIdx(Opts.BuildDynamicSymbolIndex
  ? new FileIndex(Opts.HeavyweightDynamicSymbolIndex)
  : nullptr),
-  ClangTidyOptProvider(Opts.ClangTidyOptProvider),
+  GetClangTidyOptions(Opts.GetClangTidyOptions),
   SuggestMissingIncludes(Opts.SuggestMissingIncludes),
   WorkspaceRoot(Opts.WorkspaceRoot),
   // Pass a callback into `WorkScheduler` to extract symbols from a newly
@@ -126,15 +126,18 @@
 
 void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents,
WantDiagnostics WantDiags) {
+  auto FS = FSProvider.getFileSystem();
+
   ParseOptions Opts;
   Opts.ClangTidyOpts 

[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-05-20 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

ping


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


[PATCH] D62143: [clangd] Make it possible to use VFS from parsing for getting tidy options

2019-05-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 200329.
ilya-biryukov added a comment.

- Fix a typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62143

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp

Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/Version.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -27,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -496,7 +498,9 @@
   }
 
   // Create an empty clang-tidy option.
-  std::unique_ptr ClangTidyOptProvider;
+  std::mutex ClangTidyOptMu;
+  std::unique_ptr
+  ClangTidyOptProvider; /*GUARDED_BY(ClangTidyOptLock)*/
   if (EnableClangTidy) {
 auto OverrideClangTidyOptions = tidy::ClangTidyOptions::getDefaults();
 OverrideClangTidyOptions.Checks = ClangTidyChecks;
@@ -505,7 +509,13 @@
 /* Default */ tidy::ClangTidyOptions::getDefaults(),
 /* Override */ OverrideClangTidyOptions, FSProvider.getFileSystem());
   }
-  Opts.ClangTidyOptProvider = ClangTidyOptProvider.get();
+  Opts.GetClangTidyOptions = [&](llvm::vfs::FileSystem &,
+ llvm::StringRef File) {
+// This function must be thread-safe and tidy option providers are not.
+std::lock_guard Lock(ClangTidyOptMu);
+// FIXME: use the FS provided to the function.
+return ClangTidyOptProvider->getOptions(File);
+  };
   Opts.SuggestMissingIncludes = SuggestMissingIncludes;
   llvm::Optional OffsetEncodingFromFlag;
   if (ForceOffsetEncoding != OffsetEncoding::UnsupportedEncoding)
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -50,6 +50,12 @@
   virtual void onFileUpdated(PathRef File, const TUStatus &Status){};
 };
 
+/// When set, used by ClangdServer to get clang-tidy options for each particular
+/// file. Must be thread-safe. We use this instead of ClangTidyOptionsProvider
+/// to allow reading tidy configs from the VFS used for parsing.
+using ClangTidyOptionsBuilder = std::function;
+
 /// Manages a collection of source files and derived data (ASTs, indexes),
 /// and provides language-aware features such as code completion.
 ///
@@ -94,12 +100,12 @@
 /// If set, use this index to augment code completion results.
 SymbolIndex *StaticIndex = nullptr;
 
-/// If set, enable clang-tidy in clangd, used to get clang-tidy
+/// If set, enable clang-tidy in clangd and use to it get clang-tidy
 /// configurations for a particular file.
 /// Clangd supports only a small subset of ClangTidyOptions, these options
 /// (Checks, CheckOptions) are about which clang-tidy checks will be
 /// enabled.
-tidy::ClangTidyOptionsProvider *ClangTidyOptProvider = nullptr;
+ClangTidyOptionsBuilder GetClangTidyOptions;
 
 /// Clangd's workspace root. Relevant for "workspace" operations not bound
 /// to a particular file.
@@ -278,8 +284,8 @@
   // Storage for merged views of the various indexes.
   std::vector> MergedIdx;
 
-  // The provider used to provide a clang-tidy option for a specific file.
-  tidy::ClangTidyOptionsProvider *ClangTidyOptProvider = nullptr;
+  // When set, provides clang-tidy options for a specific file.
+  ClangTidyOptionsBuilder GetClangTidyOptions;
 
   // If this is true, suggest include insertion fixes for diagnostic errors that
   // can be caused by missing includes (e.g. member access in incomplete type).
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -90,7 +90,7 @@
   DynamicIdx(Opts.BuildDynamicSymbolIndex
  ? new FileIndex(Opts.HeavyweightDynamicSymbolIndex)
  : nullptr),
-  ClangTidyOptProvider(Opts.ClangTidyOptProvider),
+  GetClangTidyOptions(Opts.GetClangTidyOptions),
   SuggestMissingIncludes(Opts.SuggestMissingIncludes),
   WorkspaceRoot(Opts.WorkspaceRoot),
   // Pass a callback into `WorkScheduler` to extract symbols from a newly
@@ -126,15 +126,18 @@
 
 void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents,
WantDiagnostics WantDiags) {
+  auto FS = FSProvider.getFileSystem();
+
   ParseOptions Opts;
   Opts.ClangTidyOpts = tidy::ClangTidyOptions::getDefaults();
-  if 

[PATCH] D62143: [clangd] Make it possible to use VFS from parsing for getting tidy options

2019-05-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 200330.
ilya-biryukov added a comment.

- Fix another typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62143

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp

Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/Version.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -27,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -496,7 +498,9 @@
   }
 
   // Create an empty clang-tidy option.
-  std::unique_ptr ClangTidyOptProvider;
+  std::mutex ClangTidyOptMu;
+  std::unique_ptr
+  ClangTidyOptProvider; /*GUARDED_BY(ClangTidyOptMu)*/
   if (EnableClangTidy) {
 auto OverrideClangTidyOptions = tidy::ClangTidyOptions::getDefaults();
 OverrideClangTidyOptions.Checks = ClangTidyChecks;
@@ -505,7 +509,13 @@
 /* Default */ tidy::ClangTidyOptions::getDefaults(),
 /* Override */ OverrideClangTidyOptions, FSProvider.getFileSystem());
   }
-  Opts.ClangTidyOptProvider = ClangTidyOptProvider.get();
+  Opts.GetClangTidyOptions = [&](llvm::vfs::FileSystem &,
+ llvm::StringRef File) {
+// This function must be thread-safe and tidy option providers are not.
+std::lock_guard Lock(ClangTidyOptMu);
+// FIXME: use the FS provided to the function.
+return ClangTidyOptProvider->getOptions(File);
+  };
   Opts.SuggestMissingIncludes = SuggestMissingIncludes;
   llvm::Optional OffsetEncodingFromFlag;
   if (ForceOffsetEncoding != OffsetEncoding::UnsupportedEncoding)
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -50,6 +50,12 @@
   virtual void onFileUpdated(PathRef File, const TUStatus &Status){};
 };
 
+/// When set, used by ClangdServer to get clang-tidy options for each particular
+/// file. Must be thread-safe. We use this instead of ClangTidyOptionsProvider
+/// to allow reading tidy configs from the VFS used for parsing.
+using ClangTidyOptionsBuilder = std::function;
+
 /// Manages a collection of source files and derived data (ASTs, indexes),
 /// and provides language-aware features such as code completion.
 ///
@@ -94,12 +100,12 @@
 /// If set, use this index to augment code completion results.
 SymbolIndex *StaticIndex = nullptr;
 
-/// If set, enable clang-tidy in clangd, used to get clang-tidy
+/// If set, enable clang-tidy in clangd and use to it get clang-tidy
 /// configurations for a particular file.
 /// Clangd supports only a small subset of ClangTidyOptions, these options
 /// (Checks, CheckOptions) are about which clang-tidy checks will be
 /// enabled.
-tidy::ClangTidyOptionsProvider *ClangTidyOptProvider = nullptr;
+ClangTidyOptionsBuilder GetClangTidyOptions;
 
 /// Clangd's workspace root. Relevant for "workspace" operations not bound
 /// to a particular file.
@@ -278,8 +284,8 @@
   // Storage for merged views of the various indexes.
   std::vector> MergedIdx;
 
-  // The provider used to provide a clang-tidy option for a specific file.
-  tidy::ClangTidyOptionsProvider *ClangTidyOptProvider = nullptr;
+  // When set, provides clang-tidy options for a specific file.
+  ClangTidyOptionsBuilder GetClangTidyOptions;
 
   // If this is true, suggest include insertion fixes for diagnostic errors that
   // can be caused by missing includes (e.g. member access in incomplete type).
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -90,7 +90,7 @@
   DynamicIdx(Opts.BuildDynamicSymbolIndex
  ? new FileIndex(Opts.HeavyweightDynamicSymbolIndex)
  : nullptr),
-  ClangTidyOptProvider(Opts.ClangTidyOptProvider),
+  GetClangTidyOptions(Opts.GetClangTidyOptions),
   SuggestMissingIncludes(Opts.SuggestMissingIncludes),
   WorkspaceRoot(Opts.WorkspaceRoot),
   // Pass a callback into `WorkScheduler` to extract symbols from a newly
@@ -126,15 +126,18 @@
 
 void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents,
WantDiagnostics WantDiags) {
+  auto FS = FSProvider.getFileSystem();
+
   ParseOptions Opts;
   Opts.ClangTidyOpts = tidy::ClangTidyOptions::getDefaults();
- 

[clang-tools-extra] r361178 - [clangd] Make it possible to use VFS from parsing for getting tidy options

2019-05-20 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon May 20 10:30:46 2019
New Revision: 361178

URL: http://llvm.org/viewvc/llvm-project?rev=361178&view=rev
Log:
[clangd] Make it possible to use VFS from parsing for getting tidy options

Summary:
To give an option for clangd embedders with snapshotted filesystem to
read config files from exact snapshots, possibly loosing some
performance from caching capabilities of the current implementations.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=361178&r1=361177&r2=361178&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Mon May 20 10:30:46 2019
@@ -90,7 +90,7 @@ ClangdServer::ClangdServer(const GlobalC
   DynamicIdx(Opts.BuildDynamicSymbolIndex
  ? new FileIndex(Opts.HeavyweightDynamicSymbolIndex)
  : nullptr),
-  ClangTidyOptProvider(Opts.ClangTidyOptProvider),
+  GetClangTidyOptions(Opts.GetClangTidyOptions),
   SuggestMissingIncludes(Opts.SuggestMissingIncludes),
   WorkspaceRoot(Opts.WorkspaceRoot),
   // Pass a callback into `WorkScheduler` to extract symbols from a newly
@@ -126,15 +126,18 @@ ClangdServer::ClangdServer(const GlobalC
 
 void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents,
WantDiagnostics WantDiags) {
+  auto FS = FSProvider.getFileSystem();
+
   ParseOptions Opts;
   Opts.ClangTidyOpts = tidy::ClangTidyOptions::getDefaults();
-  if (ClangTidyOptProvider)
-Opts.ClangTidyOpts = ClangTidyOptProvider->getOptions(File);
+  // FIXME: call tidy options builder on the worker thread, it can do IO.
+  if (GetClangTidyOptions)
+Opts.ClangTidyOpts = GetClangTidyOptions(*FS, File);
   Opts.SuggestMissingIncludes = SuggestMissingIncludes;
 
   // Compile command is set asynchronously during update, as it can be slow.
   ParseInputs Inputs;
-  Inputs.FS = FSProvider.getFileSystem();
+  Inputs.FS = FS;
   Inputs.Contents = Contents;
   Inputs.Opts = std::move(Opts);
   Inputs.Index = Index;

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=361178&r1=361177&r2=361178&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Mon May 20 10:30:46 2019
@@ -50,6 +50,12 @@ public:
   virtual void onFileUpdated(PathRef File, const TUStatus &Status){};
 };
 
+/// When set, used by ClangdServer to get clang-tidy options for each 
particular
+/// file. Must be thread-safe. We use this instead of ClangTidyOptionsProvider
+/// to allow reading tidy configs from the VFS used for parsing.
+using ClangTidyOptionsBuilder = std::function;
+
 /// Manages a collection of source files and derived data (ASTs, indexes),
 /// and provides language-aware features such as code completion.
 ///
@@ -94,12 +100,12 @@ public:
 /// If set, use this index to augment code completion results.
 SymbolIndex *StaticIndex = nullptr;
 
-/// If set, enable clang-tidy in clangd, used to get clang-tidy
+/// If set, enable clang-tidy in clangd and use to it get clang-tidy
 /// configurations for a particular file.
 /// Clangd supports only a small subset of ClangTidyOptions, these options
 /// (Checks, CheckOptions) are about which clang-tidy checks will be
 /// enabled.
-tidy::ClangTidyOptionsProvider *ClangTidyOptProvider = nullptr;
+ClangTidyOptionsBuilder GetClangTidyOptions;
 
 /// Clangd's workspace root. Relevant for "workspace" operations not bound
 /// to a particular file.
@@ -278,8 +284,8 @@ private:
   // Storage for merged views of the various indexes.
   std::vector> MergedIdx;
 
-  // The provider used to provide a clang-tidy option for a specific file.
-  tidy::ClangTidyOptionsProvider *ClangTidyOptProvider = nullptr;
+  // When set, provides clang-tidy options for a specific file.
+  ClangTidyOptionsBuilder GetClangTidyOptions;
 
   // If this is true, suggest include insertion fixes for diagnostic errors 
that
   // can be caused by missing includes (e.g. member access in incomplete type).

Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp?rev=361178&r1=361177&r2=361178&view=diff
==

[PATCH] D62143: [clangd] Make it possible to use VFS from parsing for getting tidy options

2019-05-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361178: [clangd] Make it possible to use VFS from parsing 
for getting tidy options (authored by ibiryukov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62143?vs=200330&id=200331#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62143

Files:
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.h
  clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp

Index: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/Version.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -27,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -496,7 +498,9 @@
   }
 
   // Create an empty clang-tidy option.
-  std::unique_ptr ClangTidyOptProvider;
+  std::mutex ClangTidyOptMu;
+  std::unique_ptr
+  ClangTidyOptProvider; /*GUARDED_BY(ClangTidyOptMu)*/
   if (EnableClangTidy) {
 auto OverrideClangTidyOptions = tidy::ClangTidyOptions::getDefaults();
 OverrideClangTidyOptions.Checks = ClangTidyChecks;
@@ -505,7 +509,13 @@
 /* Default */ tidy::ClangTidyOptions::getDefaults(),
 /* Override */ OverrideClangTidyOptions, FSProvider.getFileSystem());
   }
-  Opts.ClangTidyOptProvider = ClangTidyOptProvider.get();
+  Opts.GetClangTidyOptions = [&](llvm::vfs::FileSystem &,
+ llvm::StringRef File) {
+// This function must be thread-safe and tidy option providers are not.
+std::lock_guard Lock(ClangTidyOptMu);
+// FIXME: use the FS provided to the function.
+return ClangTidyOptProvider->getOptions(File);
+  };
   Opts.SuggestMissingIncludes = SuggestMissingIncludes;
   llvm::Optional OffsetEncodingFromFlag;
   if (ForceOffsetEncoding != OffsetEncoding::UnsupportedEncoding)
Index: clang-tools-extra/trunk/clangd/ClangdServer.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp
@@ -90,7 +90,7 @@
   DynamicIdx(Opts.BuildDynamicSymbolIndex
  ? new FileIndex(Opts.HeavyweightDynamicSymbolIndex)
  : nullptr),
-  ClangTidyOptProvider(Opts.ClangTidyOptProvider),
+  GetClangTidyOptions(Opts.GetClangTidyOptions),
   SuggestMissingIncludes(Opts.SuggestMissingIncludes),
   WorkspaceRoot(Opts.WorkspaceRoot),
   // Pass a callback into `WorkScheduler` to extract symbols from a newly
@@ -126,15 +126,18 @@
 
 void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents,
WantDiagnostics WantDiags) {
+  auto FS = FSProvider.getFileSystem();
+
   ParseOptions Opts;
   Opts.ClangTidyOpts = tidy::ClangTidyOptions::getDefaults();
-  if (ClangTidyOptProvider)
-Opts.ClangTidyOpts = ClangTidyOptProvider->getOptions(File);
+  // FIXME: call tidy options builder on the worker thread, it can do IO.
+  if (GetClangTidyOptions)
+Opts.ClangTidyOpts = GetClangTidyOptions(*FS, File);
   Opts.SuggestMissingIncludes = SuggestMissingIncludes;
 
   // Compile command is set asynchronously during update, as it can be slow.
   ParseInputs Inputs;
-  Inputs.FS = FSProvider.getFileSystem();
+  Inputs.FS = FS;
   Inputs.Contents = Contents;
   Inputs.Opts = std::move(Opts);
   Inputs.Index = Index;
Index: clang-tools-extra/trunk/clangd/ClangdServer.h
===
--- clang-tools-extra/trunk/clangd/ClangdServer.h
+++ clang-tools-extra/trunk/clangd/ClangdServer.h
@@ -50,6 +50,12 @@
   virtual void onFileUpdated(PathRef File, const TUStatus &Status){};
 };
 
+/// When set, used by ClangdServer to get clang-tidy options for each particular
+/// file. Must be thread-safe. We use this instead of ClangTidyOptionsProvider
+/// to allow reading tidy configs from the VFS used for parsing.
+using ClangTidyOptionsBuilder = std::function;
+
 /// Manages a collection of source files and derived data (ASTs, indexes),
 /// and provides language-aware features such as code completion.
 ///
@@ -94,12 +100,12 @@
 /// If set, use this index to augment code completion results.
 SymbolIndex *StaticIndex = nullptr;
 
-/// If set, enable clang-tidy in clangd, used to get clang-tidy
+/// If set, enable clang-tidy in clangd and use to it get clang-tidy
 /// configurations for a particular file.
 /// Clangd supports only a small s

[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-05-20 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Looks good, in general. Just one more question: will __tgt_register_requires be 
emitted if only -fopenmp is used? If -fopenmp-targets is not provided, this 
function should not be called, I think, because we're not going to use 
offloading at all in this case and __tgt_register_requires should not be 
emitted. Otherwise, we may end up with the linker error that 
__tgt_register_requires is not found. Would be good to have a test with 
-fopenmp and #pragma omp requires that check that no __tgt_register_requires is 
emitted in this case.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


r361182 - Rearrange and clean up how we disambiguate lambda-introducers from ObjC

2019-05-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon May 20 11:01:54 2019
New Revision: 361182

URL: http://llvm.org/viewvc/llvm-project?rev=361182&view=rev
Log:
Rearrange and clean up how we disambiguate lambda-introducers from ObjC
message sends, designators, and attributes.

Instead of having the tentative parsing phase sometimes return an
indicator to say what diagnostic to produce if parsing fails and
sometimes ask the caller to run it again, consistently ask the caller to
try parsing again if tentative parsing would fail or is otherwise unable
to completely parse the lambda-introducer without producing an
irreversible semantic effect.

Mostly NFC, but we should recover marginally better in some error cases
(avoiding duplicate diagnostics).

Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Parse/ParseInit.cpp
cfe/trunk/lib/Parse/ParseTentative.cpp
cfe/trunk/test/Parser/objcxx11-invalid-lambda.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=361182&r1=361181&r2=361182&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Mon May 20 11:01:54 2019
@@ -1752,16 +1752,29 @@ private:
   bool OnlyNamespace = false);
 
   
//======//
-  // C++0x 5.1.2: Lambda expressions
+  // C++11 5.1.2: Lambda expressions
+
+  /// Result of tentatively parsing a lambda-introducer.
+  enum class LambdaIntroducerTentativeParse {
+/// This appears to be a lambda-introducer, which has been fully parsed.
+Success,
+/// This is a lambda-introducer, but has not been fully parsed, and this
+/// function needs to be called again to parse it.
+Incomplete,
+/// This is definitely an Objective-C message send expression, rather than
+/// a lambda-introducer, attribute-specifier, or array designator.
+MessageSend,
+/// This is not a lambda-introducer.
+Invalid,
+  };
 
   // [...] () -> type {...}
   ExprResult ParseLambdaExpression();
   ExprResult TryParseLambdaExpression();
-  Optional ParseLambdaIntroducer(LambdaIntroducer &Intro,
-   bool *SkippedInits = nullptr);
-  bool TryParseLambdaIntroducer(LambdaIntroducer &Intro);
-  ExprResult ParseLambdaExpressionAfterIntroducer(
-   LambdaIntroducer &Intro);
+  bool
+  ParseLambdaIntroducer(LambdaIntroducer &Intro,
+LambdaIntroducerTentativeParse *Tentative = nullptr);
+  ExprResult ParseLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro);
 
   
//======//
   // C++ 5.2p1: C++ Casts

Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=361182&r1=361181&r2=361182&view=diff
==
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Mon May 20 11:01:54 2019
@@ -686,9 +686,7 @@ ExprResult Parser::ParseCXXIdExpression(
 ExprResult Parser::ParseLambdaExpression() {
   // Parse lambda-introducer.
   LambdaIntroducer Intro;
-  Optional DiagID = ParseLambdaIntroducer(Intro);
-  if (DiagID) {
-Diag(Tok, DiagID.getValue());
+  if (ParseLambdaIntroducer(Intro)) {
 SkipUntil(tok::r_square, StopAtSemi);
 SkipUntil(tok::l_brace, StopAtSemi);
 SkipUntil(tok::r_brace, StopAtSemi);
@@ -698,9 +696,8 @@ ExprResult Parser::ParseLambdaExpression
   return ParseLambdaExpressionAfterIntroducer(Intro);
 }
 
-/// TryParseLambdaExpression - Use lookahead and potentially tentative
-/// parsing to determine if we are looking at a C++0x lambda expression, and 
parse
-/// it if we are.
+/// Use lookahead and potentially tentative parsing to determine if we are
+/// looking at a C++11 lambda expression, and parse it if we are.
 ///
 /// If we are not looking at a lambda expression, returns ExprError().
 ExprResult Parser::TryParseLambdaExpression() {
@@ -726,19 +723,44 @@ ExprResult Parser::TryParseLambdaExpress
 
   // If lookahead indicates an ObjC message send...
   // [identifier identifier
-  if (Next.is(tok::identifier) && After.is(tok::identifier)) {
+  if (Next.is(tok::identifier) && After.is(tok::identifier))
 return ExprEmpty();
-  }
 
   // Here, we're stuck: lambda introducers and Objective-C message sends are
   // unambiguous, but it requires arbitrary lookhead.  [a,b,c,d,e,f,g] is a
   // lambda, and [a,b,c,d,e,f,g h] is a Objective-C message send.  Instead of
   // writing two routines to parse a lambda introducer, just try to parse
   // a lambda introducer first, and fall back if that fails.
-  // (TryParseLambdaIntroducer never produces any diagnos

r361184 - [CMake] Update DistributionExample for mono repo

2019-05-20 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Mon May 20 11:10:20 2019
New Revision: 361184

URL: http://llvm.org/viewvc/llvm-project?rev=361184&view=rev
Log:
[CMake] Update DistributionExample for mono repo

This just updates the DistributionExamples from my 2016 Dev Meeting talk to 
work more seamlessly with the monorepo.

Modified:
cfe/trunk/cmake/caches/DistributionExample-stage2.cmake
cfe/trunk/cmake/caches/DistributionExample.cmake

Modified: cfe/trunk/cmake/caches/DistributionExample-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/DistributionExample-stage2.cmake?rev=361184&r1=361183&r2=361184&view=diff
==
--- cfe/trunk/cmake/caches/DistributionExample-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/DistributionExample-stage2.cmake Mon May 20 11:10:20 
2019
@@ -1,6 +1,9 @@
 # This file sets up a CMakeCache for the second stage of a simple distribution
 # bootstrap build.
 
+set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
+
 set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "")
 
 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")

Modified: cfe/trunk/cmake/caches/DistributionExample.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/DistributionExample.cmake?rev=361184&r1=361183&r2=361184&view=diff
==
--- cfe/trunk/cmake/caches/DistributionExample.cmake (original)
+++ cfe/trunk/cmake/caches/DistributionExample.cmake Mon May 20 11:10:20 2019
@@ -1,5 +1,9 @@
 # This file sets up a CMakeCache for a simple distribution bootstrap build.
 
+#Enable LLVM projects and runtimes
+set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
+
 # Only build the native target in stage1 since it is a throwaway build.
 set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
 


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


[PATCH] D61974: [ObjC] Fix encoding of ObjC pointer types that are pointers to typedefs

2019-05-20 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In D61974#1508097 , @ahatanak wrote:

> Delete the entire code path that tries to work around a bug in gcc.


Should something be added to the release notes for this?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61974



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


[PATCH] D62156: [Sema] Diagnose addr space mismatch while constructing objects

2019-05-20 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked 3 inline comments as done.
Anastasia added inline comments.



Comment at: lib/Sema/SemaInit.cpp:3771
 else {
-  // C++ [over.match.copy]p1:
-  //   - When initializing a temporary to be bound to the first parameter
-  // of a constructor [for type T] that takes a reference to possibly
-  // cv-qualified T as its first argument, called with a single
-  // argument in the context of direct-initialization, explicit
-  // conversion functions are also considered.
-  // FIXME: What if a constructor template instantiates to such a 
signature?
-  bool AllowExplicitConv = AllowExplicit && !CopyInitializing &&
-   Args.size() == 1 &&
-   hasCopyOrMoveCtorParam(S.Context, Info);
-  S.AddOverloadCandidate(Info.Constructor, Info.FoundDecl, Args,
- CandidateSet, SuppressUserConversions,
- /*PartialOverloading=*/false,
- /*AllowExplicit=*/AllowExplicitConv);
+  // Check that address space match to resolve the constructors correctly.
+  if (Info.Constructor->getMethodQualifiers().isAddressSpaceSupersetOf(

matches



Comment at: lib/Sema/SemaInit.cpp:5023
   else
+  // Check that address space match to resolve the constructors
+  // correctly.

matches



Comment at: test/CodeGenOpenCLCXX/addrspace-ctor.cl:7
+  int i;
+  void bar();
+};

remove unused bar


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

https://reviews.llvm.org/D62156



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


[PATCH] D62156: [Sema] Diagnose addr space mismatch while constructing objects

2019-05-20 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added a reviewer: rjmccall.
Herald added a subscriber: ebevhan.
Anastasia edited the summary of this revision.
Anastasia marked 3 inline comments as done.
Anastasia added inline comments.



Comment at: lib/Sema/SemaInit.cpp:3771
 else {
-  // C++ [over.match.copy]p1:
-  //   - When initializing a temporary to be bound to the first parameter
-  // of a constructor [for type T] that takes a reference to possibly
-  // cv-qualified T as its first argument, called with a single
-  // argument in the context of direct-initialization, explicit
-  // conversion functions are also considered.
-  // FIXME: What if a constructor template instantiates to such a 
signature?
-  bool AllowExplicitConv = AllowExplicit && !CopyInitializing &&
-   Args.size() == 1 &&
-   hasCopyOrMoveCtorParam(S.Context, Info);
-  S.AddOverloadCandidate(Info.Constructor, Info.FoundDecl, Args,
- CandidateSet, SuppressUserConversions,
- /*PartialOverloading=*/false,
- /*AllowExplicit=*/AllowExplicitConv);
+  // Check that address space match to resolve the constructors correctly.
+  if (Info.Constructor->getMethodQualifiers().isAddressSpaceSupersetOf(

matches



Comment at: lib/Sema/SemaInit.cpp:5023
   else
+  // Check that address space match to resolve the constructors
+  // correctly.

matches



Comment at: test/CodeGenOpenCLCXX/addrspace-ctor.cl:7
+  int i;
+  void bar();
+};

remove unused bar


If we construct an object in some arbitrary non-default addr space it should 
fail unless either:

1. There is an implicit conversion from the address space to default/generic 
address space.
2. There is a matching ctor qualified with an address space that is either 
exactly matching or convertible to the address space of an object.

Example - case 1:

  struct MyType {
 MyType(int i)  : i(i) {}
 int i;
   };
  __constant MyType m(1); // error: can't convert from __constant to __generic

Example - case 2:

  struct MyType {
 MyType(int i) __constant  : i(i) {}
 MyType(int i)  : i(i) {}
 int i;
   };
  __constant MyType c(1); // there is __constant qualified ctor
  __global MyType g(1); // there is a valid conversion between __global and 
__generic




https://reviews.llvm.org/D62156

Files:
  include/clang/Sema/DeclSpec.h
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaInit.cpp
  test/CodeGenCXX/address-space-of-this.cpp
  test/CodeGenOpenCLCXX/addrspace-ctor.cl
  test/SemaCXX/address-space-ctor.cpp

Index: test/SemaCXX/address-space-ctor.cpp
===
--- /dev/null
+++ test/SemaCXX/address-space-ctor.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -std=c++14 -triple=spir -verify -fsyntax-only
+// RUN: %clang_cc1 %s -std=c++17 -triple=spir -verify -fsyntax-only
+
+struct MyType {
+  MyType(int i) : i(i) {}
+  int i;
+};
+
+// FIXME: We can't implicitly convert between address spaces yet.
+MyType __attribute__((address_space(10))) m1 = 123; //expected-error{{no viable conversion from 'int' to '__attribute__((address_space(10))) MyType'}}
+MyType __attribute__((address_space(10))) m2(123);  //expected-error{{no matching constructor for initialization of '__attribute__((address_space(10))) MyType'}}
Index: test/CodeGenOpenCLCXX/addrspace-ctor.cl
===
--- /dev/null
+++ test/CodeGenOpenCLCXX/addrspace-ctor.cl
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -emit-llvm -O0 -o - | FileCheck %s
+
+struct MyType {
+  MyType(int i) : i(i) {}
+  MyType(int i) __constant : i(i) {}
+  int i;
+  void bar();
+};
+
+//CHECK: call void @_ZNU3AS26MyTypeC1Ei(%struct.MyType addrspace(2)* @const1, i32 1)
+__constant MyType const1 = 1;
+//CHECK: call void @_ZNU3AS26MyTypeC1Ei(%struct.MyType addrspace(2)* @const2, i32 2)
+__constant MyType const2(2);
+//CHECK: call void @_ZNU3AS46MyTypeC1Ei(%struct.MyType addrspace(4)* addrspacecast (%struct.MyType addrspace(1)* @glob to %struct.MyType addrspace(4)*), i32 1)
+MyType glob(1);
Index: test/CodeGenCXX/address-space-of-this.cpp
===
--- test/CodeGenCXX/address-space-of-this.cpp
+++ test/CodeGenCXX/address-space-of-this.cpp
@@ -1,8 +1,11 @@
 // RUN: %clang_cc1 %s -std=c++14 -triple=spir -emit-llvm -o - | FileCheck %s
 // RUN: %clang_cc1 %s -std=c++17 -triple=spir -emit-llvm -o - | FileCheck %s
+// XFAIL: *
 
+// FIXME: We can't compile address space method qualifiers yet.
+// Therefore there is no way to check correctness of this code.
 struct MyType {
-  MyType(int i) : i(i) {}
+  MyType(int i) __attribute__((address_space(10))) 

[PATCH] D59988: [PR41276] Generate address space cast of 'this' for objects attributed by an address space in C++

2019-05-20 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked an inline comment as done.
Anastasia added inline comments.



Comment at: test/CodeGenCXX/address-space-of-this.cpp:9
+//CHECK: call void @_ZN6MyTypeC1Ei(%struct.MyType* addrspacecast 
(%struct.MyType addrspace(10)* @m to %struct.MyType*), i32 123)
+MyType __attribute__((address_space(10))) m = 123;

rjmccall wrote:
> Anastasia wrote:
> > rjmccall wrote:
> > > Anastasia wrote:
> > > > rjmccall wrote:
> > > > > Sorry I didn't catch this before, but I don't see why this test is 
> > > > > expected to work.  We can't actually pass a pointer in address space 
> > > > > 10 to that constructor.
> > > > Ok, I have created a bug to follow up on this issues:
> > > > https://bugs.llvm.org/show_bug.cgi?id=41730
> > > > 
> > > > It seems that the check is missing here for allowing the address space 
> > > > conversions implicitly, but I am afraid if I add it now addr spaces 
> > > > will become less usable because implicit conversions can't be setup by 
> > > > the target yet. And everyone is using no address space as some sort of 
> > > > `__generic` but unofficially. :(
> > > > 
> > > > I have some thoughts about adding something like `__generic` address 
> > > > space to C++ that can either be resolved by the compiler or supported 
> > > > by HW. I think it might help to implement those cases correctly without 
> > > > modifying too much of code base. I just struggled to find enough 
> > > > bandwidth to send an RFC but I will try to progress on this asap.
> > > > Ok, I have created a bug to follow up on this issues:
> > > 
> > > Thanks.
> > > 
> > > > It seems that the check is missing here for allowing the address space 
> > > > conversions implicitly, but I am afraid if I add it now addr spaces 
> > > > will become less usable because implicit conversions can't be setup by 
> > > > the target yet. And everyone is using no address space as some sort of 
> > > > __generic but unofficially. :(
> > > 
> > > As far as I'm concerned, address-space support in the C++ feature set is 
> > > all still extremely experimental and there are no real users that we have 
> > > to worry about making things less useful for.  The right thing for the 
> > > basic model is for constructors to only work when the object is being 
> > > constructed in an address space that's convertible to the address space 
> > > of the constructor.  Languages with a `__generic` superspace (whether 
> > > implemented with dynamic selection or cloning or anything else) can 
> > > consider making it the default address space of constructors, but that's 
> > > not something we should be pushing in the basic model.
> > > As far as I'm concerned, address-space support in the C++ feature set is 
> > > all still extremely experimental and there are no real users that we have 
> > > to worry about making things less useful for. 
> > 
> > Ok, then I can try to fix that generically. And at least we can test it 
> > using `__constant` in OpenCL.
> > 
> > 
> > > The right thing for the basic model is for constructors to only work when 
> > > the object is being constructed in an address space that's convertible to 
> > > the address space of the constructor.
> > 
> > Just to understand a bit more. Would the constructor address space be given 
> > in the source code or would it be up to the target to set it up? Also would 
> > it be applied to all other methods too?
> > 
> > 
> > 
> > > Languages with a __generic superspace (whether implemented with dynamic 
> > > selection or cloning or anything else) can consider making it the default 
> > > address space of constructors, but that's not something we should be 
> > > pushing in the basic model.
> > 
> > Ok, I have drafted an RFC around this topic that I was planning to share 
> > with Clang dev community at some point.
> > https://docs.google.com/document/d/1YybeeRgGrckMjxjtLdRUf0V5f9Psq97cWxBN4npDoqk/edit?usp=sharing
> > 
> > Just in short the idea of this proposal is to make something like 
> > `__generic` address space as a feature configurable by the targets. It is 
> > extending the original idea described in 
> > http://lists.llvm.org/pipermail/cfe-dev/2019-March/061541.html
> > 
> > I am also discussing briefly some extra ideas of language based solutions 
> > to provide information on address spaces for class instantiations at the 
> > source level. Your feedback would be highly appreciated even at this very 
> > early stage (of course if you have any extra bandwidth). It would be much 
> > easier to fix remaining issues once we agree on the future directions. 
> > Thanks!
> > Just to understand a bit more. Would the constructor address space be given 
> > in the source code or would it be up to the target to set it up? Also would 
> > it be applied to all other methods too?
> 
> 1. It should be possible to give a method / constructor an address space 
> explicitly in source code.  This would be treated basically like a `const` or 
> `volatile` qualifier o

Re: r360109 - Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an attribute declaration"

2019-05-20 Thread Nico Weber via cfe-commits
Hello, it seems this broke building some iOS programs.

$ cat test.m
# define UI_APPEARANCE_SELECTOR
__attribute__((annotate("ui_appearance_selector")))

@class UIColor;

@interface Test
@property(null_resettable, nonatomic, strong)  UIColor *onTintColor
UI_APPEARANCE_SELECTOR;
@end

@implementation Test
- (void)setOnTintColor:(nullable UIColor *)onTintColor {
}

@end

$ out/gn/bin/clang -c test.m -Wno-objc-root-class
test.m:10:44: error: nullability specifier 'nullable' conflicts with
existing specifier '_Null_unspecified'
- (void)setOnTintColor:(nullable UIColor *)onTintColor {
   ^
1 error generated.


Before this change, that compiled fine. Surprisingly, it still builds fine
if UI_APPEARANCE_SELECTOR is replaced by
`__attribute__((annotate("ui_appearance_selector")))` in the source code,
even though both lead to the same -E output.

*From: *Leonard Chan via cfe-commits 
*Date: *Mon, May 6, 2019 at 11:17 PM
*To: * 

Author: leonardchan
> Date: Mon May  6 20:20:17 2019
> New Revision: 360109
>
> URL: http://llvm.org/viewvc/llvm-project?rev=360109&view=rev
> Log:
> Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an
> attribute declaration"
>
> Updated with fix for read of uninitialized memory.
>
> Added:
> cfe/trunk/test/Frontend/macro_defined_type.cpp
> cfe/trunk/test/Sema/address_space_print_macro.c
> Modified:
> cfe/trunk/include/clang/AST/ASTContext.h
> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
> cfe/trunk/include/clang/AST/Type.h
> cfe/trunk/include/clang/AST/TypeLoc.h
> cfe/trunk/include/clang/AST/TypeNodes.def
> cfe/trunk/include/clang/Parse/Parser.h
> cfe/trunk/include/clang/Sema/ParsedAttr.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
> cfe/trunk/lib/AST/ASTContext.cpp
> cfe/trunk/lib/AST/ASTDiagnostic.cpp
> cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
> cfe/trunk/lib/AST/ItaniumMangle.cpp
> cfe/trunk/lib/AST/Type.cpp
> cfe/trunk/lib/AST/TypePrinter.cpp
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> cfe/trunk/lib/Parse/ParseDecl.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaStmt.cpp
> cfe/trunk/lib/Sema/SemaType.cpp
> cfe/trunk/lib/Sema/TreeTransform.h
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/test/Sema/address_spaces.c
> cfe/trunk/test/SemaObjC/externally-retained.m
> cfe/trunk/test/SemaObjC/gc-attributes.m
> cfe/trunk/test/SemaObjC/mrc-weak.m
> cfe/trunk/test/SemaObjCXX/gc-attributes.mm
> cfe/trunk/tools/libclang/CIndex.cpp
>
> Modified: cfe/trunk/include/clang/AST/ASTContext.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=360109&r1=360108&r2=360109&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
> +++ cfe/trunk/include/clang/AST/ASTContext.h Mon May  6 20:20:17 2019
> @@ -1441,6 +1441,9 @@ public:
>
>QualType getParenType(QualType NamedType) const;
>
> +  QualType getMacroQualifiedType(QualType UnderlyingTy,
> + const IdentifierInfo *MacroII) const;
> +
>QualType getElaboratedType(ElaboratedTypeKeyword Keyword,
>   NestedNameSpecifier *NNS, QualType NamedType,
>   TagDecl *OwnedTagDecl = nullptr) const;
>
> Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=360109&r1=360108&r2=360109&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
> +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Mon May  6 20:20:17
> 2019
> @@ -1065,6 +1065,9 @@ DEF_TRAVERSE_TYPE(AttributedType,
>
>  DEF_TRAVERSE_TYPE(ParenType, { TRY_TO(TraverseType(T->getInnerType())); })
>
> +DEF_TRAVERSE_TYPE(MacroQualifiedType,
> +  { TRY_TO(TraverseType(T->getUnderlyingType())); })
> +
>  DEF_TRAVERSE_TYPE(ElaboratedType, {
>if (T->getQualifier()) {
>  TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
> @@ -1308,6 +1311,9 @@ DEF_TRAVERSE_TYPELOC(InjectedClassNameTy
>
>  DEF_TRAVERSE_TYPELOC(ParenType, {
> TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })
>
> +DEF_TRAVERSE_TYPELOC(MacroQualifiedType,
> + { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })
> +
>  DEF_TRAVERSE_TYPELOC(AttributedType,
>   { TRY_TO(TraverseTypeLoc(TL.getModifiedLoc())); })
>
>
> Modified: cfe/trunk/include/clang/AST/Type.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=360109&r1=360108&r2=360109&vi

r361187 - [X86] Check the alignment argument for the masked.load/store for the _mm_mask_store_ss/sd and _mm_mask(z)_load_ss/sd intrinsics.

2019-05-20 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon May 20 11:48:31 2019
New Revision: 361187

URL: http://llvm.org/viewvc/llvm-project?rev=361187&view=rev
Log:
[X86] Check the alignment argument for the masked.load/store for the 
_mm_mask_store_ss/sd and _mm_mask(z)_load_ss/sd intrinsics.

Modified:
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=361187&r1=361186&r2=361187&view=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Mon May 20 11:48:31 2019
@@ -10733,42 +10733,42 @@ __m128d test_mm_maskz_move_sd (__mmask8
 void test_mm_mask_store_ss(float * __P, __mmask8 __U, __m128 __A)
 {
   // CHECK-LABEL: @test_mm_mask_store_ss
-  // CHECK: call void @llvm.masked.store.v4f32.p0v4f32(
+  // CHECK: call void @llvm.masked.store.v4f32.p0v4f32(<4 x float> %{{.*}}, <4 
x float>* %{{.*}}, i32 1, <4 x i1> %{{.*}})
   _mm_mask_store_ss(__P, __U, __A);
 }
 
 void test_mm_mask_store_sd(double * __P, __mmask8 __U, __m128d __A)
 {
   // CHECK-LABEL: @test_mm_mask_store_sd
-  // CHECK: call void @llvm.masked.store.v2f64.p0v2f64(
+  // CHECK: call void @llvm.masked.store.v2f64.p0v2f64(<2 x double> %{{.*}}, 
<2 x double>* %{{.*}}, i32 1, <2 x i1> %{{.*}})
   _mm_mask_store_sd(__P, __U, __A);
 }
 
 __m128 test_mm_mask_load_ss(__m128 __A, __mmask8 __U, const float* __W)
 {
   // CHECK-LABEL: @test_mm_mask_load_ss
-  // CHECK: call <4 x float> @llvm.masked.load.v4f32.p0v4f32(
+  // CHECK: call <4 x float> @llvm.masked.load.v4f32.p0v4f32(<4 x float>* 
%{{.*}}, i32 1, <4 x i1> %{{.*}}, <4 x float> %{{.*}})
   return _mm_mask_load_ss(__A, __U, __W);
 }
 
 __m128 test_mm_maskz_load_ss (__mmask8 __U, const float * __W)
 {
   // CHECK-LABEL: @test_mm_maskz_load_ss
-  // CHECK: call <4 x float> @llvm.masked.load.v4f32.p0v4f32(
+  // CHECK: call <4 x float> @llvm.masked.load.v4f32.p0v4f32(<4 x float>* 
%{{.*}}, i32 1, <4 x i1> %{{.*}}, <4 x float> %{{.*}})
   return _mm_maskz_load_ss (__U, __W);
 }
 
 __m128d test_mm_mask_load_sd (__m128d __A, __mmask8 __U, const double * __W)
 {
   // CHECK-LABEL: @test_mm_mask_load_sd
-  // CHECK: call <2 x double> @llvm.masked.load.v2f64.p0v2f64(
+  // CHECK: call <2 x double> @llvm.masked.load.v2f64.p0v2f64(<2 x double>* 
%{{.*}}, i32 1, <2 x i1> %{{.*}}, <2 x double> %{{.*}})
   return _mm_mask_load_sd (__A, __U, __W);
 }
 
 __m128d test_mm_maskz_load_sd (__mmask8 __U, const double * __W)
 {
   // CHECK-LABEL: @test_mm_maskz_load_sd
-  // CHECK: call <2 x double> @llvm.masked.load.v2f64.p0v2f64(
+  // CHECK: call <2 x double> @llvm.masked.load.v2f64.p0v2f64(<2 x double>* 
%{{.*}}, i32 1, <2 x i1> %{{.*}}, <2 x double> %{{.*}})
   return _mm_maskz_load_sd (__U, __W);
 }
 


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


[PATCH] D62152: [ARM][AArch64] Fix incorrect handling of alignment in va_arg code generation

2019-05-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Please verify my understanding of the following is correct:

1. getTypeUnadjustedAlign() is currently only used to compute calling 
convention alignment for ARM and AArch64.
2. Without this patch, we use the unadjusted alignment to pass arguments, but 
the adjusted alignment to compute the alignment for the corresponding va_arg 
calls.
3. Without this patch, the unadjusted alignment for non-struct types is 
actually adjusted based on attributes on typedefs.

I'm not confident about changing the calling convention again at this point for 
non-struct types.  I guess it's obscure enough that changing it is probably 
okay.  But would you mind splitting it into a separate followup, with a better 
description of the impact?


Repository:
  rC Clang

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

https://reviews.llvm.org/D62152



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


[PATCH] D59887: [Syntax] Introduce TokenBuffer, start clangToolingSyntax library

2019-05-20 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Out of interest: The RecursiveASTVisitorTests are part of the ToolingTests 
binary while this adds a new binary TokensTest. Can you say why?

(No change needed, just curious.)


Repository:
  rC Clang

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

https://reviews.llvm.org/D59887



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


[PATCH] D59887: [Syntax] Introduce TokenBuffer, start clangToolingSyntax library

2019-05-20 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Another comment: The new binary is called TokensTest but is in a directory 
"Syntax". For consistency with all other unit test binaries, please either 
rename the binary to SyntaxTests, or rename the directory to "Tokens". (From 
the patch description, the former seems more appropriate.) Note the missing 
trailing "s" in the binary name too.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59887



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


[PATCH] D62157: Remove explicit header-filter in run_clang_tidy.py

2019-05-20 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett created this revision.
juliehockett added reviewers: alexfh, hokein.
juliehockett added a project: clang-tools-extra.

This removes the else clause that adds a default `-header-filter` flag to 
clang-tidy invocations from the run_clang_tidy.py script. If this clause is 
present, any HeaderFilterRegex settings in the `.clang-tidy` file are ignored 
and would have to be explicitly passed to the script each time.


https://reviews.llvm.org/D62157

Files:
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -84,9 +84,6 @@
   start = [clang_tidy_binary]
   if header_filter is not None:
 start.append('-header-filter=' + header_filter)
-  else:
-# Show warnings in all in-project headers by default.
-start.append('-header-filter=^' + build_path + '/.*')
   if checks:
 start.append('-checks=' + checks)
   if tmpdir is not None:


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -84,9 +84,6 @@
   start = [clang_tidy_binary]
   if header_filter is not None:
 start.append('-header-filter=' + header_filter)
-  else:
-# Show warnings in all in-project headers by default.
-start.append('-header-filter=^' + build_path + '/.*')
   if checks:
 start.append('-checks=' + checks)
   if tmpdir is not None:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58418: [clang][DirectoryWatcher] Upstream DirectoryWatcher

2019-05-20 Thread Jan Korous via Phabricator via cfe-commits
jkorous marked 2 inline comments as done.
jkorous added a comment.

Thanks for taking a look @gribozavr!

I briefly scanned the rest of your comments and I agree with you (or don't 
really have a strong opinion) in all cases. I'll work on that today.




Comment at: clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp:136
+
+const int PollResult = poll(&PollReq, 1, TimeoutMs);
+// There are inotify events waiting to be read!

gribozavr wrote:
> What is the role of the timeout and why does it need to be so small?
The whole idea is that we can't block on `read()` if we ever want to stop 
watching the directory, release resources (file descriptors, threads) and 
correctly destruct the DirectoryWatcher instance either
- because of a bug in some other thread in the implementation
- or asynchronous client action (e. g. destructor being called) in main 
application thread

The timeout adds latency in those scenarios.



Comment at: clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp:131
+  // the async event handling picks them up. Can make this test flaky.
+  std::this_thread::sleep_for(std::chrono::milliseconds(100)); // 0.1s
+}

gribozavr wrote:
> I'm certain this sleep will be flaky on heavily-loaded CI machines.  If you 
> are going to leave it as a sleep, please make it 1s.  But is there really no 
> better way?
That was exactly my thinking! Honestly, I don't know - I wasn't able to come up 
with any reasonably simple, deterministic approach even on a single platform :(
I eventually picked 0.1s as a tradeoff between slowing the test for everyone 
and getting less false positives.

The problem as I understand it is that we're making changes and monitoring them 
asynchronously with no guarantee from the kernel API (true for FSEvents, not 
100% about inotify) about when (if) we receive notifications.

If you have any idea for robust testing approach I'd be totally happy to use it.


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

https://reviews.llvm.org/D58418



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


[PATCH] D62156: [Sema] Diagnose addr space mismatch while constructing objects

2019-05-20 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/Sema/SemaDeclCXX.cpp:8229
+  if (FTI.hasMethodTypeCVRUQualifiers()) {
+FTI.MethodQualifiers->forEachCVRUQualifier(
 [&](DeclSpec::TQ TypeQual, StringRef QualName, SourceLocation SL) {

We want to catch `_Atomic`, too, so please just change this loop to ignore 
address-space qualifiers, using a flag to decide whether to call 
`setInvalidType`.



Comment at: lib/Sema/SemaInit.cpp:3773
+  if (Info.Constructor->getMethodQualifiers().isAddressSpaceSupersetOf(
+  DestType.getQualifiers())) {
+// C++ [over.match.copy]p1:

Please add these constructors as candidates and then teach 
`AddOverloadCandidate` to reject them.  If you need to set the destination 
address space on the `OverloadCandidateSet`, I think that would be reasonable.


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

https://reviews.llvm.org/D62156



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


[PATCH] D62009: [clang] perform semantic checking in constant context

2019-05-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D62009#1506415 , @Tyker wrote:

> there are issues with using ConstantExpr to mark expressions as constant for 
> semantic checking:
>
> - #1 multpile Expr::Ignore* operation remove ConstantExpr from the expression.


`Ignore*` is generally used when walking the syntactic form of an expression, 
so this is usually appropriate.

> - #2 Semantic checking Traverses the AST so all methods that only mark the 
> top-level Node will not completely work.

Semantic checks that care about constant evaluation should not walk over a 
`ConstantExpr` node. Generally, we want rather different checking inside a 
`ConstantExpr` node than outside (for example, we shouldn't be performing any 
checks for potential overflow or narrowing or conversions, and instead should 
be finding out what *actually* happens by evaluating the expression and 
diagnosing problems in it). So this seems fine too, though there may still be 
places that need updates to properly handle `ConstantExpr`.

> - #3 at short term: adding ConstantExpr modifies the AST structure, so adding 
> it everywhere it is needed for semantic checking will require changing code 
> that depend closely on the AST structure.

Yes. But that's going to be the case for any approach we take here.

> - push a ExpressionEvaluationContext::ConstantEvaluated so Sema will 
> propagate it and propagate from Sema to the expression evaluator via boolean 
> values.
> - put all semantic checking function's in a SemaCheckContext class and 
> propagate via this class to the expression evaluator. this class will be 
> usable to propagate Sema and probably other informations.
> - keep the bit in ExprBitfield but make all nodes created in 
> ExpressionEvaluationContext::ConstantEvaluated marked for constant evaluation 
> to fixes limitation #2.

We don't always know whether an expression is constant evaluated until after 
we've parsed it (eg, for a call to a function that might be `consteval` we need 
to perform overload resolution before we find out). And this would require 
changing all the (many) places that create `Expr` nodes to pass in new 
information. That sounds unpleasant and expensive, and adds a permanent cost to 
all future AST changes.

So far we don't appear to need any per-`Expr` indicator of whether that 
expression is transitively within a `ConstantExpr`, so let's not add that.


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

https://reviews.llvm.org/D62009



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


[PATCH] D61865: [clangd] improve help message for limit-results

2019-05-20 Thread Brennan Vincent via Phabricator via cfe-commits
umanwizard added a comment.

Ping.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61865



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


[PATCH] D62065: Move dump method implementations to their respective class files

2019-05-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/AST/Comment.cpp:378-380
+LLVM_DUMP_METHOD void Comment::dump() const {
+  dump(llvm::errs(), nullptr, nullptr);
+}

If we're moving things around, is there a reason we should keep this in a 
source file as opposed to inlining it in the header? Same goes for the other 
trivial implementations.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62065



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


  1   2   >