[PATCH] D64475: [clangd] Duplicate lines of semantic highlightings sent removed.

2019-07-17 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom added inline comments.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1110
 PathRef File, std::vector Highlightings) {
+  llvm::ArrayRef Prev;
+  {

hokein wrote:
> this seems unsafe, we get a reference of the map value, we might access it 
> without the mutex being guarded. 
> 
> ```
> std::vector Old;
> {
> std::lock_guard Lock(HighlightingsMutex);
> Old = std::move(FileToHighlightings[File]);
> }
> ```
Aren't the parsing callbacks thread safe in the same file? I think @sammccall 
said so above. 

Although actually, the map might reallocate and move around the memory if 
things are inserted/deleted invalidating the reference maybe (I have no idea of 
how StringMap memory allocation works).

So I guess it doesn't hurt to be safe and copy it.   



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:255
+  // ArrayRefs to the current line in the highlights.
+  ArrayRef NewLine(Highlightings.data(),
+  Highlightings.data()),

hokein wrote:
> IIUC, we are initializing an empty ArrayRef, if so, how about using 
> `NewLine(Highlightings.data(), /*length*/0)`? `NewLine(Highlightings.data(), 
> Highlightings.data())` is a bit weird, it took me a while to understand the 
> purpose.
I couldn't do that because the `ArrayRef(const T *data, size_t length)` and 
`ArrayRef(const T *begin, const T *end)` were ambiguous. Added a cast to cast 0 
to a size_t which solved it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64475



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


[PATCH] D64850: Remove use of malloc in PPC mm_malloc.

2019-07-17 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel accepted this revision.
hfinkel added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D64850



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


[PATCH] D64475: [clangd] Duplicate lines of semantic highlightings sent removed.

2019-07-17 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom updated this revision to Diff 210253.
jvikstrom marked 15 inline comments as done.
jvikstrom added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64475

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/semantic-highlighting.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -29,7 +29,8 @@
   return Tokens;
 }
 
-void checkHighlightings(llvm::StringRef Code) {
+std::pair, std::vector>
+getHighlightingsAnnotated(llvm::StringRef Code) {
   Annotations Test(Code);
   auto AST = TestTU::withCode(Test.code()).build();
   static const std::map KindToString{
@@ -49,9 +50,40 @@
   }
 
   auto ActualTokens = getSemanticHighlightings(AST);
+  return {ActualTokens, ExpectedTokens};
+}
+
+void checkHighlightings(llvm::StringRef Code) {
+  std::vector ActualTokens;
+  std::vector ExpectedTokens;
+  std::tie(ActualTokens, ExpectedTokens) = getHighlightingsAnnotated(Code);
   EXPECT_THAT(ActualTokens, testing::UnorderedElementsAreArray(ExpectedTokens));
 }
 
+void checkDiffedHighlights(const std::vector &ExpectedTokens,
+   const std::vector &EmptyLines,
+   std::vector &ActualDiffed) {
+  std::map> ExpectedLines;
+  for (const HighlightingToken &Token : ExpectedTokens)
+ExpectedLines[Token.R.start.line].push_back(Token);
+  std::vector ExpectedLinePairHighlighting;
+  for (int Line : EmptyLines)
+ExpectedLinePairHighlighting.push_back({Line, {}});
+  for (auto &LineTokens : ExpectedLines) {
+llvm::sort(LineTokens.second);
+ExpectedLinePairHighlighting.push_back(
+{LineTokens.first, LineTokens.second});
+  }
+
+  // The UnorderedElementsAreArray only checks that the top level vector
+  // is unordered. The vectors in the pair must be in the correct order.
+  for (unsigned I = 0, End = ActualDiffed.size(); I < End; ++I)
+llvm::sort(ActualDiffed[I].Tokens);
+
+  EXPECT_THAT(ActualDiffed,
+  testing::UnorderedElementsAreArray(ExpectedLinePairHighlighting));
+}
+
 TEST(SemanticHighlighting, GetsCorrectTokens) {
   const char *TestCases[] = {
 R"cpp(
@@ -211,21 +243,102 @@
 return Pos;
   };
 
-  std::vector Tokens{
-  {HighlightingKind::Variable,
-Range{CreatePosition(3, 8), CreatePosition(3, 12)}},
-  {HighlightingKind::Function,
-Range{CreatePosition(3, 4), CreatePosition(3, 7)}},
-  {HighlightingKind::Variable,
-Range{CreatePosition(1, 1), CreatePosition(1, 5)}}};
+  std::vector Tokens{
+  {3,
+   {{HighlightingKind::Variable,
+ Range{CreatePosition(3, 8), CreatePosition(3, 12)}},
+{HighlightingKind::Function,
+ Range{CreatePosition(3, 4), CreatePosition(3, 7),
+  {1,
+   {{HighlightingKind::Variable,
+ Range{CreatePosition(1, 1), CreatePosition(1, 5)};
   std::vector ActualResults =
   toSemanticHighlightingInformation(Tokens);
   std::vector ExpectedResults = {
-  {1, "AQAEAAA="},
-  {3, "CAAEAAAEAAMAAQ=="}};
+  {3, "CAAEAAAEAAMAAQ=="}, {1, "AQAEAAA="}};
   EXPECT_EQ(ActualResults, ExpectedResults);
 }
 
+TEST(SemanticHighlighting, HighlightingDiffer) {
+  // Each entry is a test case. An entry consists of two things. The first entry
+  // in the pair is every empty line that should be returned by the diffing. The
+  // second entry are the two code samples that should be diffed (first entry
+  // are the old highlightings and the second entry are the new highlightings.)
+  std::vector<
+  std::pair, std::pair>>
+  TestCases{{{},
+ {
+ R"cpp(
+int $Variable[[A]]
+double $Variable[[B]];
+struct $Class[[C]] {};
+  )cpp",
+ R"cpp(
+int A;
+double B;
+struct C {};
+  )cpp"}},
+{{5},
+ {
+ R"cpp(
+  struct $Class[[Alpha]] {
+double SomeVariable = 9483.301;
+  };
+  struct $Class[[Beta]] {};
+  int $Variable[[A]] = 121;
+  $Class[[Alpha]] $Variable[[Var]];
+  )cpp",
+ R"cpp(
+  struct Alpha {
+double SomeVariable = 9483.301;
+  };
+  struct Beta   {}; // Some comment
+  intA = 121;
+  $Class[[Beta]] $Variable[[Var]];
+  )cpp"}},
+{{},
+ 

[PATCH] D64741: [clangd] Added highlighting for tokens that are macro arguments.

2019-07-17 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom updated this revision to Diff 210257.
jvikstrom marked 2 inline comments as done.
jvikstrom added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64741

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -29,9 +29,11 @@
   return Tokens;
 }
 
-void checkHighlightings(llvm::StringRef Code) {
+void checkHighlightings(llvm::StringRef Code, llvm::StringRef HeaderCode = "") {
   Annotations Test(Code);
-  auto AST = TestTU::withCode(Test.code()).build();
+  TestTU TU = TestTU::withCode(Test.code());
+  TU.HeaderCode = HeaderCode;
+  auto AST = TU.build();
   static const std::map KindToString{
   {HighlightingKind::Variable, "Variable"},
   {HighlightingKind::Function, "Function"},
@@ -186,10 +188,57 @@
   using $Enum[[CD]] = $Enum[[CC]];
   $Enum[[CC]] $Function[[f]]($Class[[B]]);
   $Enum[[CD]] $Function[[f]]($Class[[BB]]);
+)cpp",
+R"cpp(
+  #define DEF_MULTIPLE(X) namespace X { class X { int X; }; }
+  #define DEF_CLASS(T) class T {};
+  DEF_CLASS($Class[[A]])
+  DEF_MULTIPLE(XYZ);
+
+  #define MACRO_CONCAT(X, V, T) T foo##X = V
+  #define DEF_VAR(X, V) int X = V
+  #define DEF_VAR_T(T, X, V) T X = V
+  #define DEF_VAR_REV(V, X) DEF_VAR(X, V)
+  #define CPY(X) X
+  #define DEF_VAR_TYPE(X, Y) X Y
+  #define SOME_NAME variable
+  #define SOME_NAME_SET variable2 = 123
+  #define INC_VAR(X) X += 2
+  void $Function[[foo]]() {
+DEF_VAR($Variable[[X]],  123);
+DEF_VAR_REV(908, $Variable[[XY]]);
+int CPY( $Variable[[XX]] );
+DEF_VAR_TYPE($Class[[A]], $Variable[[AA]]);
+double SOME_NAME;
+int SOME_NAME_SET;
+$Variable[[variable]] = 20.1;
+MACRO_CONCAT(var, 2, float);
+DEF_VAR_T($Class[[A]], CPY(CPY($Variable[[Nested]])),
+  CPY($Class[[A]]()));
+INC_VAR($Variable[[variable]]);
+  }
+  void SOME_NAME();
+  DEF_VAR($Variable[[XYZ]], 567);
+  DEF_VAR_REV(756, $Variable[[AB]]);
+
+  #define CALL_FN(F) F();
+  #define DEF_FN(F) void F ()
+  DEF_FN($Function[[g]]) {
+CALL_FN($Function[[foo]]);
+  }
 )cpp"};
   for (const auto &TestCase : TestCases) {
 checkHighlightings(TestCase);
   }
+
+  // A separate test for macros in headers.
+  checkHighlightings(R"cpp(
+#define DEFINE(X) int X;
+#define DEFINE_Y DEFINE(Y)
+  )cpp", R"cpp(
+DEFINE_Y
+DEFINE($Variable[[XYZ]]);
+  )cpp");
 }
 
 TEST(SemanticHighlighting, GeneratesHighlightsWhenFileChange) {
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -12,6 +12,7 @@
 #include "SourceCode.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/RecursiveASTVisitor.h"
+#include "llvm/ADT/ArrayRef.h"
 
 namespace clang {
 namespace clangd {
@@ -39,6 +40,23 @@
});
 auto Last = std::unique(Tokens.begin(), Tokens.end());
 Tokens.erase(Last, Tokens.end());
+
+// Macros can give tokens that have the same source range but conflicting
+// kinds. In this case all tokens sharing this source range should be
+// removed.
+for (unsigned I = 0; I < Tokens.size(); ++I) {
+  ArrayRef TokRef(Tokens);
+  ArrayRef Conflicting =
+  llvm::ArrayRef(TokRef.begin() + I, TokRef.end())
+  .take_while([&](const HighlightingToken &T) {
+return T.R == Tokens[I].R;
+  });
+
+  if (Conflicting.size() > 1)
+Tokens.erase(Tokens.begin() + I,
+ Tokens.begin() + I + Conflicting.size());
+}
+
 return Tokens;
   }
 
@@ -178,9 +196,12 @@
   }
 
   void addToken(SourceLocation Loc, HighlightingKind Kind) {
-if (Loc.isMacroID())
-  // FIXME: skip tokens inside macros for now.
-  return;
+if(Loc.isMacroID()) {
+  // Only intereseted in highlighting arguments in macros (DEF_X(arg)).
+  if (!SM.isMacroArgExpansion(Loc))
+return;
+  Loc = SM.getSpellingLoc(Loc);
+}
 
 auto R = getTokenRange(SM, Ctx.getLangOpts(), Loc);
 if (!R) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64741: [clangd] Added highlighting for tokens that are macro arguments.

2019-07-17 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom marked an inline comment as done.
jvikstrom added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:170
+return;
+  Loc = SM.getSpellingLoc(Loc);
+}

hokein wrote:
> The Loc here maybe not in the main file, considering the case
> 
> ```
> // in .h
> #define DEFINE(X) in X;
> #define DEFINE_Y DEFINE(Y)
> 
> // in .cc
> 
> DEFINE_Y
> ```
The spelling loc is still going to be in `DEFINE_Y` I think. And we only 
highlight arguments in macros. (Added a testcase though)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64741



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


[PATCH] D64741: [clangd] Added highlighting for tokens that are macro arguments.

2019-07-17 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom updated this revision to Diff 210259.
jvikstrom marked an inline comment as done.
jvikstrom added a comment.

Fixed edge case when removing conflicting tokens.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64741

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -29,9 +29,11 @@
   return Tokens;
 }
 
-void checkHighlightings(llvm::StringRef Code) {
+void checkHighlightings(llvm::StringRef Code, llvm::StringRef HeaderCode = "") {
   Annotations Test(Code);
-  auto AST = TestTU::withCode(Test.code()).build();
+  TestTU TU = TestTU::withCode(Test.code());
+  TU.HeaderCode = HeaderCode;
+  auto AST = TU.build();
   static const std::map KindToString{
   {HighlightingKind::Variable, "Variable"},
   {HighlightingKind::Function, "Function"},
@@ -186,10 +188,57 @@
   using $Enum[[CD]] = $Enum[[CC]];
   $Enum[[CC]] $Function[[f]]($Class[[B]]);
   $Enum[[CD]] $Function[[f]]($Class[[BB]]);
+)cpp",
+R"cpp(
+  #define DEF_MULTIPLE(X) namespace X { class X { int X; }; }
+  #define DEF_CLASS(T) class T {};
+  DEF_MULTIPLE(XYZ);
+  DEF_MULTIPLE(XYZW);
+  DEF_CLASS($Class[[A]])
+  #define MACRO_CONCAT(X, V, T) T foo##X = V
+  #define DEF_VAR(X, V) int X = V
+  #define DEF_VAR_T(T, X, V) T X = V
+  #define DEF_VAR_REV(V, X) DEF_VAR(X, V)
+  #define CPY(X) X
+  #define DEF_VAR_TYPE(X, Y) X Y
+  #define SOME_NAME variable
+  #define SOME_NAME_SET variable2 = 123
+  #define INC_VAR(X) X += 2
+  void $Function[[foo]]() {
+DEF_VAR($Variable[[X]],  123);
+DEF_VAR_REV(908, $Variable[[XY]]);
+int CPY( $Variable[[XX]] );
+DEF_VAR_TYPE($Class[[A]], $Variable[[AA]]);
+double SOME_NAME;
+int SOME_NAME_SET;
+$Variable[[variable]] = 20.1;
+MACRO_CONCAT(var, 2, float);
+DEF_VAR_T($Class[[A]], CPY(CPY($Variable[[Nested]])),
+  CPY($Class[[A]]()));
+INC_VAR($Variable[[variable]]);
+  }
+  void SOME_NAME();
+  DEF_VAR($Variable[[XYZ]], 567);
+  DEF_VAR_REV(756, $Variable[[AB]]);
+
+  #define CALL_FN(F) F();
+  #define DEF_FN(F) void F ()
+  DEF_FN($Function[[g]]) {
+CALL_FN($Function[[foo]]);
+  }
 )cpp"};
   for (const auto &TestCase : TestCases) {
 checkHighlightings(TestCase);
   }
+
+  // A separate test for macros in headers.
+  checkHighlightings(R"cpp(
+#define DEFINE(X) int X;
+#define DEFINE_Y DEFINE(Y)
+  )cpp", R"cpp(
+DEFINE_Y
+DEFINE($Variable[[XYZ]]);
+  )cpp");
 }
 
 TEST(SemanticHighlighting, GeneratesHighlightsWhenFileChange) {
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -39,6 +39,26 @@
});
 auto Last = std::unique(Tokens.begin(), Tokens.end());
 Tokens.erase(Last, Tokens.end());
+
+// Macros can give tokens that have the same source range but conflicting
+// kinds. In this case all tokens sharing this source range should be
+// removed.
+for (unsigned I = 0; I < Tokens.size(); ++I) {
+  ArrayRef TokRef(Tokens);
+  ArrayRef Conflicting =
+  llvm::ArrayRef(TokRef.begin() + I, TokRef.end())
+  .take_while([&](const HighlightingToken &T) {
+return T.R == Tokens[I].R;
+  });
+
+  if (Conflicting.size() > 1) {
+Tokens.erase(Tokens.begin() + I,
+ Tokens.begin() + I + Conflicting.size());
+--I;
+  }
+
+}
+
 return Tokens;
   }
 
@@ -178,9 +198,12 @@
   }
 
   void addToken(SourceLocation Loc, HighlightingKind Kind) {
-if (Loc.isMacroID())
-  // FIXME: skip tokens inside macros for now.
-  return;
+if(Loc.isMacroID()) {
+  // Only intereseted in highlighting arguments in macros (DEF_X(arg)).
+  if (!SM.isMacroArgExpansion(Loc))
+return;
+  Loc = SM.getSpellingLoc(Loc);
+}
 
 auto R = getTokenRange(SM, Ctx.getLangOpts(), Loc);
 if (!R) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59555: [analyzer] Add yaml parser to GenericTaintChecker

2019-07-17 Thread Borsik Gábor via Phabricator via cfe-commits
boga95 updated this revision to Diff 210258.
boga95 marked an inline comment as done.

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

https://reviews.llvm.org/D59555

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  lib/StaticAnalyzer/Checkers/Yaml.h
  test/Analysis/Inputs/taint-generic-config.yaml
  test/Analysis/taint-generic.c

Index: test/Analysis/taint-generic.c
===
--- test/Analysis/taint-generic.c
+++ test/Analysis/taint-generic.c
@@ -1,5 +1,27 @@
-// RUN: %clang_analyze_cc1  -analyzer-checker=alpha.security.taint,core,alpha.security.ArrayBoundV2 -Wno-format-security -verify %s
-// RUN: %clang_analyze_cc1  -DFILE_IS_STRUCT -analyzer-checker=alpha.security.taint,core,alpha.security.ArrayBoundV2 -Wno-format-security -verify %s
+// RUN: %clang_analyze_cc1 -Wno-format-security -verify %s \
+// RUN:   -analyzer-checker=alpha.security.taint \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=alpha.security.ArrayBoundV2 \
+// RUN:   -analyzer-config \
+// RUN: alpha.security.taint.TaintPropagation:Config=%S/Inputs/taint-generic-config.yaml
+
+// RUN: %clang_analyze_cc1 -Wno-format-security -verify %s \
+// RUN:   -DFILE_IS_STRUCT \
+// RUN:   -analyzer-checker=alpha.security.taint \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=alpha.security.ArrayBoundV2 \
+// RUN:   -analyzer-config \
+// RUN: alpha.security.taint.TaintPropagation:Config=%S/Inputs/taint-generic-config.yaml
+
+// RUN: not %clang_analyze_cc1 -verify %s \
+// RUN:   -analyzer-checker=alpha.security.taint \
+// RUN:   -analyzer-config \
+// RUN: alpha.security.taint.TaintPropagation:Config=justguessit \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-INVALID-FILE
+
+// CHECK-INVALID-FILE: (frontend): invalid input for checker option
+// CHECK-INVALID-FILE-SAME:'alpha.security.taint.TaintPropagation:Config',
+// CHECK-INVALID-FILE-SAME:that expects a valid filename
 
 int scanf(const char *restrict format, ...);
 char *gets(char *str);
Index: test/Analysis/Inputs/taint-generic-config.yaml
===
--- /dev/null
+++ test/Analysis/Inputs/taint-generic-config.yaml
@@ -0,0 +1,51 @@
+# A list of source/propagation function
+Propagations:
+  # int x = mySource1(); // x is tainted
+  - Name: mySource1
+DstArgs:  [-1] # Index for return value
+
+  # int x;
+  # mySource2(&x); // x is tainted
+  - Name: mySource2
+DstArgs:  [0]
+
+  # int x, y;
+  # myScanf("%d %d", &x, &y); // x and y are tainted
+  - Name:  myScanf
+VariadicType:  Dst
+VariadicIndex: 1
+
+  # int x; // x is tainted
+  # int y;
+  # myPropagator(x, &y); // y is tainted
+  - Name: myPropagator
+SrcArgs:  [0]
+DstArgs:  [1]
+
+  # constexpr unsigned size = 100;
+  # char buf[size];
+  # int x, y;
+  # int n = mySprintf(buf, size, "%d %d", x, y); // If size, x or y is tainted
+  # // the return value and the buf will be tainted
+  - Name:  mySnprintf
+SrcArgs:   [1]
+DstArgs:   [0, -1]
+VariadicType:  Src
+VariadicIndex: 3
+
+# A list of filter functions
+Filters:
+  # int x; // x is tainted
+  # myFilter(&x); // x is not tainted anymore
+  - Name: myFilter
+Args: [0]
+
+# A list of sink functions
+Sinks:
+  # int x, y; // x and y are tainted
+  # mySink(x, 0, 1); // It will warn
+  # mySink(0, 1, y); // It will warn
+  # mySink(0, x, 1); // It won't warn
+  - Name: mySink
+Args: [0, 2]
+
Index: lib/StaticAnalyzer/Checkers/Yaml.h
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/Yaml.h
@@ -0,0 +1,48 @@
+//== Yaml.h --- -*- C++ -*--=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file contains a simple interface allow to open and parse yaml files.
+//
+//===--===//
+
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "llvm/ADT/APInt.h"
+#include "llvm/Support/YAMLTraits.h"
+
+/// Read the given file from the filesystem and parse it as a yaml file. The
+/// template parameter must have a yaml MappingTraits.
+template 
+llvm::Optional getConfiguration(clang::ento::CheckerManager &Mgr,
+   Checker *Chk, llvm::StringRef Option,
+   llvm::StringRef ConfigFile) {
+  if (ConfigFile.trim().empty())
+return {};
+
+  llvm::vfs::FileSystem *FS = llvm::vfs::getRealFileSystem().get();
+  llvm::ErrorOr> Buffer =
+  FS->getBufferForFile(ConfigFile.st

[PATCH] D64741: [clangd] Added highlighting for tokens that are macro arguments.

2019-07-17 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom added a comment.

In D64741#1587204 , @ilya-biryukov 
wrote:

> How should this behave when if the same token is used multiple times inside a 
> macro and the uses are different? Could we add this to tests?
>  E.g.
>
>   #define W(a) class a { void test() { int a = 10; } }
>   W(foo); // <-- `foo` is a variable of a class?
>


I had completely missed that there could be conflicting tokens when only 
highlighting macro arguments as well. Added code to just remove conflicting 
tokens.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64741



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


[PATCH] D59555: [analyzer] Add yaml parser to GenericTaintChecker

2019-07-17 Thread Borsik Gábor via Phabricator via cfe-commits
boga95 updated this revision to Diff 210260.
boga95 marked 2 inline comments as done.

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

https://reviews.llvm.org/D59555

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  lib/StaticAnalyzer/Checkers/Yaml.h
  test/Analysis/Inputs/taint-generic-config.yaml
  test/Analysis/taint-generic.c

Index: test/Analysis/taint-generic.c
===
--- test/Analysis/taint-generic.c
+++ test/Analysis/taint-generic.c
@@ -1,5 +1,27 @@
-// RUN: %clang_analyze_cc1  -analyzer-checker=alpha.security.taint,core,alpha.security.ArrayBoundV2 -Wno-format-security -verify %s
-// RUN: %clang_analyze_cc1  -DFILE_IS_STRUCT -analyzer-checker=alpha.security.taint,core,alpha.security.ArrayBoundV2 -Wno-format-security -verify %s
+// RUN: %clang_analyze_cc1 -Wno-format-security -verify %s \
+// RUN:   -analyzer-checker=alpha.security.taint \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=alpha.security.ArrayBoundV2 \
+// RUN:   -analyzer-config \
+// RUN: alpha.security.taint.TaintPropagation:Config=%S/Inputs/taint-generic-config.yaml
+
+// RUN: %clang_analyze_cc1 -Wno-format-security -verify %s \
+// RUN:   -DFILE_IS_STRUCT \
+// RUN:   -analyzer-checker=alpha.security.taint \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=alpha.security.ArrayBoundV2 \
+// RUN:   -analyzer-config \
+// RUN: alpha.security.taint.TaintPropagation:Config=%S/Inputs/taint-generic-config.yaml
+
+// RUN: not %clang_analyze_cc1 -verify %s \
+// RUN:   -analyzer-checker=alpha.security.taint \
+// RUN:   -analyzer-config \
+// RUN: alpha.security.taint.TaintPropagation:Config=justguessit \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-INVALID-FILE
+
+// CHECK-INVALID-FILE: (frontend): invalid input for checker option
+// CHECK-INVALID-FILE-SAME:'alpha.security.taint.TaintPropagation:Config',
+// CHECK-INVALID-FILE-SAME:that expects a valid filename
 
 int scanf(const char *restrict format, ...);
 char *gets(char *str);
Index: test/Analysis/Inputs/taint-generic-config.yaml
===
--- /dev/null
+++ test/Analysis/Inputs/taint-generic-config.yaml
@@ -0,0 +1,51 @@
+# A list of source/propagation function
+Propagations:
+  # int x = mySource1(); // x is tainted
+  - Name: mySource1
+DstArgs:  [-1] # Index for return value
+
+  # int x;
+  # mySource2(&x); // x is tainted
+  - Name: mySource2
+DstArgs:  [0]
+
+  # int x, y;
+  # myScanf("%d %d", &x, &y); // x and y are tainted
+  - Name:  myScanf
+VariadicType:  Dst
+VariadicIndex: 1
+
+  # int x; // x is tainted
+  # int y;
+  # myPropagator(x, &y); // y is tainted
+  - Name: myPropagator
+SrcArgs:  [0]
+DstArgs:  [1]
+
+  # constexpr unsigned size = 100;
+  # char buf[size];
+  # int x, y;
+  # int n = mySprintf(buf, size, "%d %d", x, y); // If size, x or y is tainted
+  # // the return value and the buf will be tainted
+  - Name:  mySnprintf
+SrcArgs:   [1]
+DstArgs:   [0, -1]
+VariadicType:  Src
+VariadicIndex: 3
+
+# A list of filter functions
+Filters:
+  # int x; // x is tainted
+  # myFilter(&x); // x is not tainted anymore
+  - Name: myFilter
+Args: [0]
+
+# A list of sink functions
+Sinks:
+  # int x, y; // x and y are tainted
+  # mySink(x, 0, 1); // It will warn
+  # mySink(0, 1, y); // It will warn
+  # mySink(0, x, 1); // It won't warn
+  - Name: mySink
+Args: [0, 2]
+
Index: lib/StaticAnalyzer/Checkers/Yaml.h
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/Yaml.h
@@ -0,0 +1,48 @@
+//== Yaml.h --- -*- C++ -*--=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file contains a simple interface allow to open and parse yaml files.
+//
+//===--===//
+
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "llvm/ADT/APInt.h"
+#include "llvm/Support/YAMLTraits.h"
+
+/// Read the given file from the filesystem and parse it as a yaml file. The
+/// template parameter must have a yaml MappingTraits.
+template 
+llvm::Optional getConfiguration(clang::ento::CheckerManager &Mgr,
+   Checker *Chk, llvm::StringRef Option,
+   llvm::StringRef ConfigFile) {
+  if (ConfigFile.trim().empty())
+return {};
+
+  llvm::vfs::FileSystem *FS = llvm::vfs::getRealFileSystem().get();
+  llvm::ErrorOr> Buffer =
+  FS->getBufferForFile(ConfigFile.st

[PATCH] D64741: [clangd] Added highlighting for tokens that are macro arguments.

2019-07-17 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom updated this revision to Diff 210261.
jvikstrom added a comment.

clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64741

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -29,9 +29,11 @@
   return Tokens;
 }
 
-void checkHighlightings(llvm::StringRef Code) {
+void checkHighlightings(llvm::StringRef Code, llvm::StringRef HeaderCode = "") {
   Annotations Test(Code);
-  auto AST = TestTU::withCode(Test.code()).build();
+  TestTU TU = TestTU::withCode(Test.code());
+  TU.HeaderCode = HeaderCode;
+  auto AST = TU.build();
   static const std::map KindToString{
   {HighlightingKind::Variable, "Variable"},
   {HighlightingKind::Function, "Function"},
@@ -186,10 +188,58 @@
   using $Enum[[CD]] = $Enum[[CC]];
   $Enum[[CC]] $Function[[f]]($Class[[B]]);
   $Enum[[CD]] $Function[[f]]($Class[[BB]]);
+)cpp",
+R"cpp(
+  #define DEF_MULTIPLE(X) namespace X { class X { int X; }; }
+  #define DEF_CLASS(T) class T {};
+  DEF_MULTIPLE(XYZ);
+  DEF_MULTIPLE(XYZW);
+  DEF_CLASS($Class[[A]])
+  #define MACRO_CONCAT(X, V, T) T foo##X = V
+  #define DEF_VAR(X, V) int X = V
+  #define DEF_VAR_T(T, X, V) T X = V
+  #define DEF_VAR_REV(V, X) DEF_VAR(X, V)
+  #define CPY(X) X
+  #define DEF_VAR_TYPE(X, Y) X Y
+  #define SOME_NAME variable
+  #define SOME_NAME_SET variable2 = 123
+  #define INC_VAR(X) X += 2
+  void $Function[[foo]]() {
+DEF_VAR($Variable[[X]],  123);
+DEF_VAR_REV(908, $Variable[[XY]]);
+int CPY( $Variable[[XX]] );
+DEF_VAR_TYPE($Class[[A]], $Variable[[AA]]);
+double SOME_NAME;
+int SOME_NAME_SET;
+$Variable[[variable]] = 20.1;
+MACRO_CONCAT(var, 2, float);
+DEF_VAR_T($Class[[A]], CPY(CPY($Variable[[Nested]])),
+  CPY($Class[[A]]()));
+INC_VAR($Variable[[variable]]);
+  }
+  void SOME_NAME();
+  DEF_VAR($Variable[[XYZ]], 567);
+  DEF_VAR_REV(756, $Variable[[AB]]);
+
+  #define CALL_FN(F) F();
+  #define DEF_FN(F) void F ()
+  DEF_FN($Function[[g]]) {
+CALL_FN($Function[[foo]]);
+  }
 )cpp"};
   for (const auto &TestCase : TestCases) {
 checkHighlightings(TestCase);
   }
+
+  // A separate test for macros in headers.
+  checkHighlightings(R"cpp(
+#define DEFINE(X) int X;
+#define DEFINE_Y DEFINE(Y)
+  )cpp",
+ R"cpp(
+DEFINE_Y
+DEFINE($Variable[[XYZ]]);
+  )cpp");
 }
 
 TEST(SemanticHighlighting, GeneratesHighlightsWhenFileChange) {
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -39,6 +39,25 @@
});
 auto Last = std::unique(Tokens.begin(), Tokens.end());
 Tokens.erase(Last, Tokens.end());
+
+// Macros can give tokens that have the same source range but conflicting
+// kinds. In this case all tokens sharing this source range should be
+// removed.
+for (unsigned I = 0; I < Tokens.size(); ++I) {
+  ArrayRef TokRef(Tokens);
+  ArrayRef Conflicting =
+  llvm::ArrayRef(TokRef.begin() + I, TokRef.end())
+  .take_while([&](const HighlightingToken &T) {
+return T.R == Tokens[I].R;
+  });
+
+  if (Conflicting.size() > 1) {
+Tokens.erase(Tokens.begin() + I,
+ Tokens.begin() + I + Conflicting.size());
+--I;
+  }
+}
+
 return Tokens;
   }
 
@@ -178,9 +197,12 @@
   }
 
   void addToken(SourceLocation Loc, HighlightingKind Kind) {
-if (Loc.isMacroID())
-  // FIXME: skip tokens inside macros for now.
-  return;
+if(Loc.isMacroID()) {
+  // Only intereseted in highlighting arguments in macros (DEF_X(arg)).
+  if (!SM.isMacroArgExpansion(Loc))
+return;
+  Loc = SM.getSpellingLoc(Loc);
+}
 
 auto R = getTokenRange(SM, Ctx.getLangOpts(), Loc);
 if (!R) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r366304 - Replace CRLF with LF.

2019-07-17 Thread Rui Ueyama via cfe-commits
Author: ruiu
Date: Wed Jul 17 01:31:51 2019
New Revision: 366304

URL: http://llvm.org/viewvc/llvm-project?rev=366304&view=rev
Log:
Replace CRLF with LF.

Modified:

clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp

Modified: 
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp?rev=366304&r1=366303&r2=366304&view=diff
==
--- 
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
 (original)
+++ 
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
 Wed Jul 17 01:31:51 2019
@@ -1,94 +1,94 @@
-#include "ClangTidy.h"
-#include "ClangTidyTest.h"
-#include "gtest/gtest.h"
-
-namespace clang {
-namespace tidy {
-namespace test {
-
-class TestCheck : public ClangTidyCheck {
-public:
-  TestCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
-  void registerMatchers(ast_matchers::MatchFinder *Finder) override {
-Finder->addMatcher(ast_matchers::varDecl().bind("var"), this);
-  }
-  void check(const ast_matchers::MatchFinder::MatchResult &Result) override {
-const auto *Var = Result.Nodes.getNodeAs("var");
-// Add diagnostics in the wrong order.
-diag(Var->getLocation(), "variable");
-diag(Var->getTypeSpecStartLoc(), "type specifier");
-  }
-};
-
-TEST(ClangTidyDiagnosticConsumer, SortsErrors) {
-  std::vector Errors;
-  runCheckOnCode("int a;", &Errors);
-  EXPECT_EQ(2ul, Errors.size());
-  EXPECT_EQ("type specifier", Errors[0].Message.Message);
-  EXPECT_EQ("variable", Errors[1].Message.Message);
-}
-
-TEST(GlobList, Empty) {
-  GlobList Filter("");
-
-  EXPECT_TRUE(Filter.contains(""));
-  EXPECT_FALSE(Filter.contains("aaa"));
-}
-
-TEST(GlobList, Nothing) {
-  GlobList Filter("-*");
-
-  EXPECT_FALSE(Filter.contains(""));
-  EXPECT_FALSE(Filter.contains("a"));
-  EXPECT_FALSE(Filter.contains("-*"));
-  EXPECT_FALSE(Filter.contains("-"));
-  EXPECT_FALSE(Filter.contains("*"));
-}
-
-TEST(GlobList, Everything) {
-  GlobList Filter("*");
-
-  EXPECT_TRUE(Filter.contains(""));
-  EXPECT_TRUE(Filter.contains(""));
-  EXPECT_TRUE(Filter.contains("-*"));
-  EXPECT_TRUE(Filter.contains("-"));
-  EXPECT_TRUE(Filter.contains("*"));
-}
-
-TEST(GlobList, Simple) {
-  GlobList Filter("aaa");
-
-  EXPECT_TRUE(Filter.contains("aaa"));
-  EXPECT_FALSE(Filter.contains(""));
-  EXPECT_FALSE(Filter.contains("aa"));
-  EXPECT_FALSE(Filter.contains(""));
-  EXPECT_FALSE(Filter.contains("bbb"));
-}
-
-TEST(GlobList, WhitespacesAtBegin) {
-  GlobList Filter("-*,   a.b.*");
-
-  EXPECT_TRUE(Filter.contains("a.b.c"));
-  EXPECT_FALSE(Filter.contains("b.c"));
-}
-
-TEST(GlobList, Complex) {
-  GlobList Filter("*,-a.*, -b.*, \r  \n  a.1.* ,-a.1.A.*,-..,-...,-..+,-*$, 
-*qwe* ");
-
-  EXPECT_TRUE(Filter.contains("aaa"));
-  EXPECT_TRUE(Filter.contains("qqq"));
-  EXPECT_FALSE(Filter.contains("a."));
-  EXPECT_FALSE(Filter.contains("a.b"));
-  EXPECT_FALSE(Filter.contains("b."));
-  EXPECT_FALSE(Filter.contains("b.b"));
-  EXPECT_TRUE(Filter.contains("a.1.b"));
-  EXPECT_FALSE(Filter.contains("a.1.A.a"));
-  EXPECT_FALSE(Filter.contains("qwe"));
-  EXPECT_FALSE(Filter.contains("asdfqweasdf"));
-  EXPECT_TRUE(Filter.contains("asdfqwEasdf"));
-}
-
-} // namespace test
-} // namespace tidy
-} // namespace clang
+#include "ClangTidy.h"
+#include "ClangTidyTest.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tidy {
+namespace test {
+
+class TestCheck : public ClangTidyCheck {
+public:
+  TestCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override {
+Finder->addMatcher(ast_matchers::varDecl().bind("var"), this);
+  }
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override {
+const auto *Var = Result.Nodes.getNodeAs("var");
+// Add diagnostics in the wrong order.
+diag(Var->getLocation(), "variable");
+diag(Var->getTypeSpecStartLoc(), "type specifier");
+  }
+};
+
+TEST(ClangTidyDiagnosticConsumer, SortsErrors) {
+  std::vector Errors;
+  runCheckOnCode("int a;", &Errors);
+  EXPECT_EQ(2ul, Errors.size());
+  EXPECT_EQ("type specifier", Errors[0].Message.Message);
+  EXPECT_EQ("variable", Errors[1].Message.Message);
+}
+
+TEST(GlobList, Empty) {
+  GlobList Filter("");
+
+  EXPECT_TRUE(Filter.contains(""));
+  EXPECT_FALSE(Filter.contains("aaa"));
+}
+
+TEST(GlobList, Nothing) {
+  GlobList Filter("-*");
+
+  EXPECT_FALSE(Filter.contains(""));
+  EXPECT_FALSE(Filter.contains("a"));
+  EXPECT_FALSE(Filter.contains("-*"));
+  EXPECT_FALSE(Filter.contains("-"));
+  EXPECT_FALSE(Filter.contains("*"));
+}
+
+TEST(GlobList, Everything) {
+  GlobList Filter("*");
+
+  EXPECT_TRUE(Filter.contains(""));
+  EXPECT_TRUE(Fi

[PATCH] D64741: [clangd] Added highlighting for tokens that are macro arguments.

2019-07-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

> I had completely missed that there could be conflicting tokens when only 
> highlighting macro arguments as well. Added code to just remove conflicting 
> tokens.

Picking one of the highlightings looks fine, but we probably want to make sure 
it's deterministic. Given that we use `sort` now, I bet it won't be. Maybe 
include kinds into comparison as well? That's not a perfect solution, but would 
at least make sure the user-visible behavior is not random.
Could you add tests for that case too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64741



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


[PATCH] D64491: [Driver] Enable __cxa_atexit on Solaris

2019-07-17 Thread Rainer Orth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366305: [Driver] Enable __cxa_atexit on Solaris (authored by 
ro, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64491?vs=208948&id=210265#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64491

Files:
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/Driver/cxa-atexit.cpp
  cfe/trunk/test/Driver/solaris-opts.c


Index: cfe/trunk/test/Driver/solaris-opts.c
===
--- cfe/trunk/test/Driver/solaris-opts.c
+++ cfe/trunk/test/Driver/solaris-opts.c
@@ -1,4 +1,4 @@
 // RUN: %clang %s --target=sparc-sun-solaris2.11 -### -o %t.o 2>&1 | FileCheck 
%s
 
-// CHECK: "-fno-use-cxa-atexit"
+// CHECK-NOT: "-fno-use-cxa-atexit"
 
Index: cfe/trunk/test/Driver/cxa-atexit.cpp
===
--- cfe/trunk/test/Driver/cxa-atexit.cpp
+++ cfe/trunk/test/Driver/cxa-atexit.cpp
@@ -19,7 +19,7 @@
 // RUN: %clang -### -target sparc-sun-solaris -c %s -o /dev/null 2>&1 | 
FileCheck %s -check-prefix CHECK-SOLARIS
 
 // CHECK-WINDOWS: "-fno-use-cxa-atexit"
-// CHECK-SOLARIS: "-fno-use-cxa-atexit"
+// CHECK-SOLARIS-NOT: "-fno-use-cxa-atexit"
 // CHECK-HEXAGON-NOT: "-fno-use-cxa-atexit"
 // CHECK-XCORE: "-fno-use-cxa-atexit"
 // CHECK-MTI: "-fno-use-cxa-atexit"
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -4749,7 +4749,6 @@
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
   !RawTriple.isOSWindows() &&
-  RawTriple.getOS() != llvm::Triple::Solaris &&
   TC.getArch() != llvm::Triple::xcore &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||


Index: cfe/trunk/test/Driver/solaris-opts.c
===
--- cfe/trunk/test/Driver/solaris-opts.c
+++ cfe/trunk/test/Driver/solaris-opts.c
@@ -1,4 +1,4 @@
 // RUN: %clang %s --target=sparc-sun-solaris2.11 -### -o %t.o 2>&1 | FileCheck %s
 
-// CHECK: "-fno-use-cxa-atexit"
+// CHECK-NOT: "-fno-use-cxa-atexit"
 
Index: cfe/trunk/test/Driver/cxa-atexit.cpp
===
--- cfe/trunk/test/Driver/cxa-atexit.cpp
+++ cfe/trunk/test/Driver/cxa-atexit.cpp
@@ -19,7 +19,7 @@
 // RUN: %clang -### -target sparc-sun-solaris -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-SOLARIS
 
 // CHECK-WINDOWS: "-fno-use-cxa-atexit"
-// CHECK-SOLARIS: "-fno-use-cxa-atexit"
+// CHECK-SOLARIS-NOT: "-fno-use-cxa-atexit"
 // CHECK-HEXAGON-NOT: "-fno-use-cxa-atexit"
 // CHECK-XCORE: "-fno-use-cxa-atexit"
 // CHECK-MTI: "-fno-use-cxa-atexit"
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -4749,7 +4749,6 @@
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
   !RawTriple.isOSWindows() &&
-  RawTriple.getOS() != llvm::Triple::Solaris &&
   TC.getArch() != llvm::Triple::xcore &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r366305 - [Driver] Enable __cxa_atexit on Solaris

2019-07-17 Thread Rainer Orth via cfe-commits
Author: ro
Date: Wed Jul 17 01:37:00 2019
New Revision: 366305

URL: http://llvm.org/viewvc/llvm-project?rev=366305&view=rev
Log:
[Driver] Enable __cxa_atexit on Solaris

Starting with Solaris 11.4 (which is now the required minimal version), Solaris 
does
support __cxa_atexit.  This patch reflects that.

One might consider removing the affected tests altogether instead of inverting 
them,
as is done on other targets.

Besides, this lets two ASan tests PASS:

  AddressSanitizer-i386-sunos :: TestCases/init-order-atexit.cc
  AddressSanitizer-i386-sunos-dynamic :: TestCases/init-order-atexit.cc

Tested on x86_64-pc-solaris2.11 and sparcv9-sun-solaris2.11.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/cxa-atexit.cpp
cfe/trunk/test/Driver/solaris-opts.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=366305&r1=366304&r2=366305&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Jul 17 01:37:00 2019
@@ -4749,7 +4749,6 @@ void Clang::ConstructJob(Compilation &C,
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
   !RawTriple.isOSWindows() &&
-  RawTriple.getOS() != llvm::Triple::Solaris &&
   TC.getArch() != llvm::Triple::xcore &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||

Modified: cfe/trunk/test/Driver/cxa-atexit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cxa-atexit.cpp?rev=366305&r1=366304&r2=366305&view=diff
==
--- cfe/trunk/test/Driver/cxa-atexit.cpp (original)
+++ cfe/trunk/test/Driver/cxa-atexit.cpp Wed Jul 17 01:37:00 2019
@@ -19,7 +19,7 @@
 // RUN: %clang -### -target sparc-sun-solaris -c %s -o /dev/null 2>&1 | 
FileCheck %s -check-prefix CHECK-SOLARIS
 
 // CHECK-WINDOWS: "-fno-use-cxa-atexit"
-// CHECK-SOLARIS: "-fno-use-cxa-atexit"
+// CHECK-SOLARIS-NOT: "-fno-use-cxa-atexit"
 // CHECK-HEXAGON-NOT: "-fno-use-cxa-atexit"
 // CHECK-XCORE: "-fno-use-cxa-atexit"
 // CHECK-MTI: "-fno-use-cxa-atexit"

Modified: cfe/trunk/test/Driver/solaris-opts.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/solaris-opts.c?rev=366305&r1=366304&r2=366305&view=diff
==
--- cfe/trunk/test/Driver/solaris-opts.c (original)
+++ cfe/trunk/test/Driver/solaris-opts.c Wed Jul 17 01:37:00 2019
@@ -1,4 +1,4 @@
 // RUN: %clang %s --target=sparc-sun-solaris2.11 -### -o %t.o 2>&1 | FileCheck 
%s
 
-// CHECK: "-fno-use-cxa-atexit"
+// CHECK-NOT: "-fno-use-cxa-atexit"
 


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


r366306 - [OpenCL][Sema] Minor refactoring and constraint checking

2019-07-17 Thread Marco Antognini via cfe-commits
Author: mantognini
Date: Wed Jul 17 01:52:09 2019
New Revision: 366306

URL: http://llvm.org/viewvc/llvm-project?rev=366306&view=rev
Log:
[OpenCL][Sema] Minor refactoring and constraint checking

Summary:
Simplify code a bit and add assertion to address post-landing comments
from D64083.

Subscribers: yaxunl, Anastasia, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=366306&r1=366305&r2=366306&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Jul 17 01:52:09 2019
@@ -4216,17 +4216,12 @@ Sema::PerformImplicitConversion(Expr *Fr
 break;
 
   case ICK_Block_Pointer_Conversion: {
-QualType LHSType = Context.getCanonicalType(ToType).getUnqualifiedType();
-QualType RHSType = Context.getCanonicalType(FromType).getUnqualifiedType();
-
-// Assumptions based on Sema::IsBlockPointerConversion.
-assert(isa(LHSType) && "BlockPointerType expected");
-assert(isa(RHSType) && "BlockPointerType expected");
-
 LangAS AddrSpaceL =
-LHSType->getAs()->getPointeeType().getAddressSpace();
+ToType->castAs()->getPointeeType().getAddressSpace();
 LangAS AddrSpaceR =
-RHSType->getAs()->getPointeeType().getAddressSpace();
+
FromType->castAs()->getPointeeType().getAddressSpace();
+assert(Qualifiers::isAddressSpaceSupersetOf(AddrSpaceL, AddrSpaceR) &&
+   "Invalid cast");
 CastKind Kind =
 AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
 From = ImpCastExprToType(From, ToType.getUnqualifiedType(), Kind,


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


[PATCH] D64475: [clangd] Duplicate lines of semantic highlightings sent removed.

2019-07-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:255
+  // ArrayRefs to the current line in the highlights.
+  ArrayRef NewLine(Highlightings.data(),
+  Highlightings.data()),

jvikstrom wrote:
> hokein wrote:
> > IIUC, we are initializing an empty ArrayRef, if so, how about using 
> > `NewLine(Highlightings.data(), /*length*/0)`? 
> > `NewLine(Highlightings.data(), Highlightings.data())` is a bit weird, it 
> > took me a while to understand the purpose.
> I couldn't do that because the `ArrayRef(const T *data, size_t length)` and 
> `ArrayRef(const T *begin, const T *end)` were ambiguous. Added a cast to cast 
> 0 to a size_t which solved it.
you could also do it like `NewLine(Highlightings.data(), /*length*/0UL);`, 
which saves you a `static_cast<>`.



Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:281
+  )cpp"}},
+{{5},
+ {

so the empty lines are stored separately, which is not easy to figure out from 
the testing code snippet. I think we should make the empty lines more obvious 
in the code snippet (maybe use an `Empty` annotations?) , and explicitly verify 
the empty lines.

What do you think refining the test like below, just annotate the diff tokens? 
I find it is easy to spot the diff tokens.

```
struct Testcase {
   Code Before;
   Code After;
};

std::vector cases = {
   { 
   R"cpp(
 int a;
 int b; 
 int c;
  )cpp",
  R"cpp(
int a;
$Empty[[]] // int b
int $Variable[[C]];
  )cpp"
  }
}

oldHighlightings = getSemanticHighlightings(OldAST);
newHighlightings = getSemanticHighlightings(NewAST);
diffHighlightings = diff...;
// verify the diffHighlightings has the expected empty lines ("Empty" 
annotations).
// verify the diffHighlightings has the expected highlightings (the regular 
annotations);
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64475



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


[PATCH] D64804: [OpenCL][Sema] Minor refactoring and constraint checking

2019-07-17 Thread Marco Antognini via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366306: [OpenCL][Sema] Minor refactoring and constraint 
checking (authored by mantognini, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64804?vs=210115&id=210269#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64804

Files:
  cfe/trunk/lib/Sema/SemaExprCXX.cpp


Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -4216,17 +4216,12 @@
 break;
 
   case ICK_Block_Pointer_Conversion: {
-QualType LHSType = Context.getCanonicalType(ToType).getUnqualifiedType();
-QualType RHSType = Context.getCanonicalType(FromType).getUnqualifiedType();
-
-// Assumptions based on Sema::IsBlockPointerConversion.
-assert(isa(LHSType) && "BlockPointerType expected");
-assert(isa(RHSType) && "BlockPointerType expected");
-
 LangAS AddrSpaceL =
-LHSType->getAs()->getPointeeType().getAddressSpace();
+ToType->castAs()->getPointeeType().getAddressSpace();
 LangAS AddrSpaceR =
-RHSType->getAs()->getPointeeType().getAddressSpace();
+
FromType->castAs()->getPointeeType().getAddressSpace();
+assert(Qualifiers::isAddressSpaceSupersetOf(AddrSpaceL, AddrSpaceR) &&
+   "Invalid cast");
 CastKind Kind =
 AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
 From = ImpCastExprToType(From, ToType.getUnqualifiedType(), Kind,


Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -4216,17 +4216,12 @@
 break;
 
   case ICK_Block_Pointer_Conversion: {
-QualType LHSType = Context.getCanonicalType(ToType).getUnqualifiedType();
-QualType RHSType = Context.getCanonicalType(FromType).getUnqualifiedType();
-
-// Assumptions based on Sema::IsBlockPointerConversion.
-assert(isa(LHSType) && "BlockPointerType expected");
-assert(isa(RHSType) && "BlockPointerType expected");
-
 LangAS AddrSpaceL =
-LHSType->getAs()->getPointeeType().getAddressSpace();
+ToType->castAs()->getPointeeType().getAddressSpace();
 LangAS AddrSpaceR =
-RHSType->getAs()->getPointeeType().getAddressSpace();
+FromType->castAs()->getPointeeType().getAddressSpace();
+assert(Qualifiers::isAddressSpaceSupersetOf(AddrSpaceL, AddrSpaceR) &&
+   "Invalid cast");
 CastKind Kind =
 AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
 From = ImpCastExprToType(From, ToType.getUnqualifiedType(), Kind,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64855: [clangd] Added highlightings for template parameters and specializations.

2019-07-17 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom created this revision.
jvikstrom added reviewers: hokein, sammccall, ilya-biryukov.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay.
Herald added a project: clang.

Template parameters and specializations were not being highlighted before. This 
adds highlightings to those types of tokens by adding two Visit* methods.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64855

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/semantic-highlighting.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -40,7 +40,8 @@
   {HighlightingKind::Namespace, "Namespace"},
   {HighlightingKind::EnumConstant, "EnumConstant"},
   {HighlightingKind::Field, "Field"},
-  {HighlightingKind::Method, "Method"}};
+  {HighlightingKind::Method, "Method"},
+  {HighlightingKind::TemplateParameter, "TemplateParameter"}};
   std::vector ExpectedTokens;
   for (const auto &KindString : KindToString) {
 std::vector Toks = makeHighlightingTokens(
@@ -80,14 +81,14 @@
 )cpp",
 R"cpp(
   namespace $Namespace[[abc]] {
-template
+template
 struct $Class[[A]] {
-  T $Field[[t]];
+  $TemplateParameter[[T]] $Field[[t]];
 };
   }
-  template
-  struct $Class[[C]] : $Namespace[[abc]]::A {
-typename T::A* $Field[[D]];
+  template
+  struct $Class[[C]] : $Namespace[[abc]]::$Class[[A]]<$TemplateParameter[[T]]> {
+typename $TemplateParameter[[T]]::A* $Field[[D]];
   };
   $Namespace[[abc]]::$Class[[A]] $Variable[[AA]];
   typedef $Namespace[[abc]]::$Class[[A]] AAA;
@@ -173,6 +174,19 @@
   }
   int $Variable[[B]];
   $Class[[AA]] $Variable[[A]]{$Variable[[B]]};
+)cpp",
+R"cpp(
+  template
+  class $Class[[A]] {
+$TemplateParameter[[T]] $Field[[AA]];
+$TemplateParameter[[T]] $Method[[foo]]();
+  };
+  template
+  class $Class[[B]] {
+$Class[[A]]<$TemplateParameter[[TT]]> $Field[[AA]];
+  };
+  template
+  void $Function[[foo]]($TemplateParameter[[T]] ...);
 )cpp"};
   for (const auto &TestCase : TestCases) {
 checkHighlightings(TestCase);
Index: clang-tools-extra/clangd/test/semantic-highlighting.test
===
--- clang-tools-extra/clangd/test/semantic-highlighting.test
+++ clang-tools-extra/clangd/test/semantic-highlighting.test
@@ -27,6 +27,9 @@
 # CHECK-NEXT:  ],
 # CHECK-NEXT:  [
 # CHECK-NEXT:"entity.name.namespace.cpp"
+# CHECK-NEXT:  ],
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.type.template.cpp"
 # CHECK-NEXT:  ]
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -32,6 +32,7 @@
   Enum,
   EnumConstant,
   Namespace,
+  TemplateParameter,
 
   NumKinds,
 };
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -93,6 +93,19 @@
 return true;
   }
 
+  bool VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc &TL) {
+// TemplateTypeParmTypeLoc does not have a TagDecl in its type ptr.
+addToken(TL.getBeginLoc(), TL.getDecl());
+return true;
+  }
+
+  bool VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc &TL) {
+if (const TemplateDecl *TD =
+TL.getTypePtr()->getTemplateName().getAsTemplateDecl())
+  addToken(TL.getBeginLoc(), TD);
+return true;
+  }
+
   bool VisitTypeLoc(TypeLoc &TL) {
 // This check is for not getting two entries when there are anonymous
 // structs. It also makes us not highlight certain namespace qualifiers
@@ -125,6 +138,10 @@
 // We highlight class decls, constructor decls and destructor decls as
 // `Class` type. The destructor decls are handled in `VisitTypeLoc` (we will
 // visit a TypeLoc where the underlying Type is a CXXRecordDecl).
+if(isa(D)) {
+  addToken(Loc, HighlightingKind::Class);
+  return;
+}
 if (isa(D)) {
   addToken(Loc, HighlightingKind::Class);
   return;
@@ -165,6 +182,10 @@
   addToken(Loc, HighlightingKind::Namespace);
   return;
 }
+if(isa(D)) {
+  addToken(Loc, HighlightingKind::TemplateParameter);
+ 

[PATCH] D53191: [clang] Introduce new completion context types

2019-07-17 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.
Herald added a project: clang.

I've bisected https://bugs.llvm.org/show_bug.cgi?id=42646 to this change. 
Reverting it fixes the issue.

Please look into it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D53191



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


[PATCH] D64741: [clangd] Added highlighting for tokens that are macro arguments.

2019-07-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:170
+return;
+  Loc = SM.getSpellingLoc(Loc);
+}

jvikstrom wrote:
> hokein wrote:
> > The Loc here maybe not in the main file, considering the case
> > 
> > ```
> > // in .h
> > #define DEFINE(X) in X;
> > #define DEFINE_Y DEFINE(Y)
> > 
> > // in .cc
> > 
> > DEFINE_Y
> > ```
> The spelling loc is still going to be in `DEFINE_Y` I think. And we only 
> highlight arguments in macros. (Added a testcase though)
ok, I don't have an exact case for macros now, but my gut feeling tells me we 
will encounter cases where the Loc is not in main file.

here is a test case for declarations, we will visit the `foo()` decl in 
`test.h` as well. This could be addressed in a separate patch.

```
// test.h
void foo();

// test.cc
#include "test.h"
void foo() {}
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64741



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


[PATCH] D61446: Generalize the pass registration mechanism used by Polly to any third-party tool

2019-07-17 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 210273.
serge-sans-paille marked 5 inline comments as done and 2 inline comments as 
done.
serge-sans-paille added a comment.

Added a `Bye` project in examples/
Fixed linking of plugins into core tools
Fixed dependency issue


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61446

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CMakeLists.txt
  clang/tools/driver/CMakeLists.txt
  clang/tools/driver/cc1_main.cpp
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/docs/WritingAnLLVMPass.rst
  llvm/examples/Bye/Bye.cpp
  llvm/examples/Bye/CMakeLists.txt
  llvm/examples/CMakeLists.txt
  llvm/include/llvm/Config/llvm-config.h.cmake
  llvm/tools/CMakeLists.txt
  llvm/tools/bugpoint/CMakeLists.txt
  llvm/tools/bugpoint/bugpoint.cpp
  llvm/tools/opt/CMakeLists.txt
  llvm/tools/opt/NewPMDriver.cpp
  llvm/tools/opt/opt.cpp
  llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
  polly/include/polly/RegisterPasses.h
  polly/lib/CMakeLists.txt
  polly/lib/Polly.cpp
  polly/lib/Support/RegisterPasses.cpp
  polly/test/Unit/lit.site.cfg.in
  polly/test/lit.site.cfg.in
  polly/test/update_check.py

Index: polly/test/update_check.py
===
--- polly/test/update_check.py
+++ polly/test/update_check.py
@@ -15,7 +15,7 @@
 polly_lib_dir = '''@POLLY_LIB_DIR@'''
 shlibext = '''@LLVM_SHLIBEXT@'''
 llvm_tools_dir = '''@LLVM_TOOLS_DIR@'''
-link_polly_into_tools = not '''@LINK_POLLY_INTO_TOOLS@'''.lower() in {'','0','n','no','off','false','notfound','link_polly_into_tools-notfound'}
+llvm_polly_link_into_tools = not '''@LLVM_POLLY_LINK_INTO_TOOLS@'''.lower() in {'','0','n','no','off','false','notfound','llvm_polly_link_into_tools-notfound'}
 
 runre = re.compile(r'\s*\;\s*RUN\s*\:(?P.*)')
 filecheckre = re.compile(r'\s*(?P.*)\|\s*(?PFileCheck\s[^|]*)')
@@ -298,7 +298,7 @@
 toolarg = toolarg.replace('%s', filename)
 toolarg = toolarg.replace('%S', os.path.dirname(filename))
 if toolarg == '%loadPolly':
-if not link_polly_into_tools:
+if not llvm_polly_link_into_tools:
 newtool += ['-load',os.path.join(polly_lib_dir,'LLVMPolly' + shlibext)]
 newtool.append('-polly-process-unprofitable')
 newtool.append('-polly-remarks-minimal')
Index: polly/test/lit.site.cfg.in
===
--- polly/test/lit.site.cfg.in
+++ polly/test/lit.site.cfg.in
@@ -8,7 +8,7 @@
 config.polly_lib_dir = "@POLLY_LIB_DIR@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.enable_gpgpu_codegen = "@GPU_CODEGEN@"
-config.link_polly_into_tools = "@LINK_POLLY_INTO_TOOLS@"
+config.llvm_polly_link_into_tools = "@LLVM_POLLY_LINK_INTO_TOOLS@"
 config.targets_to_build = "@TARGETS_TO_BUILD@"
 config.extra_paths = "@POLLY_TEST_EXTRA_PATHS@".split(";")
 
@@ -36,14 +36,14 @@
 # directories.
 config.excludes = ['Inputs']
 
-if config.link_polly_into_tools == '' or \
-   config.link_polly_into_tools.lower() == '0' or \
-   config.link_polly_into_tools.lower() == 'n' or \
-   config.link_polly_into_tools.lower() == 'no' or \
-   config.link_polly_into_tools.lower() == 'off' or \
-   config.link_polly_into_tools.lower() == 'false' or \
-   config.link_polly_into_tools.lower() == 'notfound' or \
-   config.link_polly_into_tools.lower() == 'link_polly_into_tools-notfound':
+if config.llvm_polly_link_into_tools == '' or \
+   config.llvm_polly_link_into_tools.lower() == '0' or \
+   config.llvm_polly_link_into_tools.lower() == 'n' or \
+   config.llvm_polly_link_into_tools.lower() == 'no' or \
+   config.llvm_polly_link_into_tools.lower() == 'off' or \
+   config.llvm_polly_link_into_tools.lower() == 'false' or \
+   config.llvm_polly_link_into_tools.lower() == 'notfound' or \
+   config.llvm_polly_link_into_tools.lower() == 'llvm_polly_link_into_tools-notfound':
 config.substitutions.append(('%loadPolly', '-load '
  + config.polly_lib_dir + '/LLVMPolly@LLVM_SHLIBEXT@'
  + ' -load-pass-plugin '
Index: polly/test/Unit/lit.site.cfg.in
===
--- polly/test/Unit/lit.site.cfg.in
+++ polly/test/Unit/lit.site.cfg.in
@@ -13,7 +13,7 @@
 config.shlibdir = "@SHLIBDIR@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.enable_gpgpu_codegen = "@GPU_CODEGEN@"
-config.link_polly_into_tools = "@LINK_POLLY_INTO_TOOLS@"
+config.llvm_polly_link_into_tools = "@LLVM_POLLY_LINK_INTO_TOOLS@"
 config.has_unittests = @POLLY_GTEST_AVAIL@
 
 # Support substitution of the tools_dir, libs_dirs, and build_mode with user
Index: polly/lib/Support/RegisterPasses.cpp
===
--- polly/lib/Support/RegisterPasses.cpp
+++ polly/lib/Support/Regi

[PATCH] D59555: [analyzer] Add yaml parser to GenericTaintChecker

2019-07-17 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Hmm, okay, so we convert `-1` from the config file to `UINT_MAX` in the code, I 
like it!

I wrote a couple nits but they really are just that. In general, for each 
different error message, a different test case would be great.




Comment at: include/clang/StaticAnalyzer/Checkers/Checkers.td:805
+  "Config",
+  "Specifies the name of the configuration file.",
+  "",

Okay, so how do I know what the format of that file is? How about we create 
another option (in a different revision) that dumps an example configuration 
with comments?



Comment at: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:27
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
-#include 
-#include 
+#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/StringMap.h"

Do we need this include?



Comment at: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:89-92
+  static const unsigned InvalidArgIndex{std::numeric_limits::max()};
   /// Denotes the return vale.
-  static const unsigned ReturnValueIndex = UINT_MAX - 1;
+  static const unsigned ReturnValueIndex{std::numeric_limits::max() -
+ 1};

Leave this as is for now, but maaybe in the future we should just use an enum. 
What do you think?



Comment at: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:304-306
+  Mgr.reportInvalidCheckerOptionValue(
+  this, Option,
+  "an argument number for propagation rules greater or equal to -1");

Could we have a test for this too? :)



Comment at: lib/StaticAnalyzer/Checkers/Yaml.h:1
+//== Yaml.h --- -*- C++ -*--=//
+//

Have with with the same length as the rest :)



Comment at: lib/StaticAnalyzer/Checkers/Yaml.h:9
+//
+// This file contains a simple interface allow to open and parse yaml files.
+//

Is this actually the reason why we have this file? We already have a YAML 
parser in LLVM, what's does this file do that the "default" parser doesn't?



Comment at: lib/StaticAnalyzer/Checkers/Yaml.h:14
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "llvm/ADT/APInt.h"
+#include "llvm/Support/YAMLTraits.h"

Hmmm, do we need this include?



Comment at: lib/StaticAnalyzer/Checkers/Yaml.h:16
+#include "llvm/Support/YAMLTraits.h"
+
+/// Read the given file from the filesystem and parse it as a yaml file. The

```lang=c++
namespace clang {
namespace ento {
```



Comment at: lib/StaticAnalyzer/Checkers/Yaml.h:42-43
+  if (std::error_code ec = Input.error()) {
+Mgr.reportInvalidCheckerOptionValue(Chk, Option,
+"a valid yaml file: " + ec.message());
+return {};

And for this too?



Comment at: lib/StaticAnalyzer/Checkers/Yaml.h:48
+  return Config;
+}

```lang=c++
} // end of namespace clang
} // end of namespace ento
```



Comment at: test/Analysis/taint-generic.c:24
+// CHECK-INVALID-FILE-SAME:
'alpha.security.taint.TaintPropagation:Config',
+// CHECK-INVALID-FILE-SAME:that expects a valid filename
 

Could you please add the rest of the error message?


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

https://reviews.llvm.org/D59555



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


[PATCH] D64418: [Docs][OpenCL] Documentation of C++ for OpenCL mode

2019-07-17 Thread Marco Antognini via Phabricator via cfe-commits
mantognini accepted this revision.
mantognini added a comment.
This revision is now accepted and ready to land.

Beside my two comments, I think this looks good.




Comment at: docs/LanguageExtensions.rst:1614
+
+By default references will refer to ``__generic`` address space objects 
(except for
+dependent types that are not template specializations

` (` -> `, ` (there's no matching closing parenthesis.)



Comment at: docs/LanguageExtensions.rst:1652-1657
+ __kernel void bar() {
+   __local C c1; // will resolve to the first foo
+   C c2; // will resolve to the second foo
+   __constant C c3; // error due to mismatching address spaces - can't convert 
to
+// __local or __generic
+ }

`foo()` isn't actually called here. You probably meant to write this:


```
__local C c1;
C c2;
__constant C c3;

c1.foo(); // will resolve to the first foo
c2.foo(); // will resolve to the second foo
c3.foo(); // error due to mismatching address spaces - can't convert to __local 
or __generic
```


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

https://reviews.llvm.org/D64418



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


[PATCH] D52193: RFC: [clang] Multithreaded compilation support -- NOT FOR SUBMIT

2019-07-17 Thread Yury Bura via Phabricator via cfe-commits
yurybura added a comment.

Dear @aganea,
Do you have any plans to make this PR compatible with trunk? Now MSVC with /MP 
builds much faster than clang-cl (at least 2x faster for our project)... 
Thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D52193



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


[PATCH] D62584: [OpenCL][PR42033] Deducing addr space with template parameter types

2019-07-17 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 210277.
Anastasia added a comment.

Fixed typo in the comment


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

https://reviews.llvm.org/D62584

Files:
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaType.cpp
  lib/Sema/TreeTransform.h
  test/SemaOpenCLCXX/address-space-deduction.cl
  test/SemaOpenCLCXX/address-space-templates.cl


Index: test/SemaOpenCLCXX/address-space-templates.cl
===
--- test/SemaOpenCLCXX/address-space-templates.cl
+++ test/SemaOpenCLCXX/address-space-templates.cl
@@ -3,7 +3,7 @@
 template 
 struct S {
   T a;// expected-error{{field may not be qualified with an address 
space}}
-  T f1(); // expected-error{{function type may not be qualified with an 
address space}}
+  T f1(); // we ignore address space on a return types.
   void f2(T); // expected-error{{parameter may not be qualified with an 
address space}}
 };
 
Index: test/SemaOpenCLCXX/address-space-deduction.cl
===
--- test/SemaOpenCLCXX/address-space-deduction.cl
+++ test/SemaOpenCLCXX/address-space-deduction.cl
@@ -24,3 +24,17 @@
   alias_c1_ptr ptr = &y;
 };
 
+template 
+T xxx(T *in) {
+  // This pointer can't be deduced to generic because addr space
+  // will be taken from the template argument.
+  //CHECK: `-VarDecl {{.*}} i 'T *' cinit
+  T *i = in;
+  T ii;
+  return *i;
+}
+
+__kernel void test() {
+  int foo[10];
+  xxx(&foo[0]);
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -5365,13 +5365,6 @@
 if (ResultType.isNull())
   return QualType();
 
-// Return type can not be qualified with an address space.
-if (ResultType.getAddressSpace() != LangAS::Default) {
-  SemaRef.Diag(TL.getReturnLoc().getBeginLoc(),
-   diag::err_attribute_address_function_type);
-  return QualType();
-}
-
 if (getDerived().TransformFunctionTypeParams(
 TL.getBeginLoc(), TL.getParams(),
 TL.getTypePtr()->param_type_begin(),
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7414,7 +7414,9 @@
   (T->isVoidType() && !IsPointee) ||
   // Do not deduce addr spaces for dependent types because they might end
   // up instantiating to a type with an explicit address space qualifier.
-  T->isDependentType() ||
+  // Except for pointer or reference types because the addr space in
+  // template argument can only belong to a pointee.
+  (T->isDependentType() && !T->isPointerType() && !T->isReferenceType()) ||
   // Do not deduce addr space of decltype because it will be taken from
   // its argument.
   T->isDecltypeType() ||
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7484,7 +7484,10 @@
 return;
   }
 }
-  } else if (T.getAddressSpace() != LangAS::opencl_private) {
+  } else if (T.getAddressSpace() != LangAS::opencl_private &&
+ // If we are parsing a template we didn't deduce an addr
+ // space yet.
+ T.getAddressSpace() != LangAS::Default) {
 // Do not allow other address spaces on automatic variable.
 Diag(NewVD->getLocation(), diag::err_as_qualified_auto_decl) << 1;
 NewVD->setInvalidDecl();


Index: test/SemaOpenCLCXX/address-space-templates.cl
===
--- test/SemaOpenCLCXX/address-space-templates.cl
+++ test/SemaOpenCLCXX/address-space-templates.cl
@@ -3,7 +3,7 @@
 template 
 struct S {
   T a;// expected-error{{field may not be qualified with an address space}}
-  T f1(); // expected-error{{function type may not be qualified with an address space}}
+  T f1(); // we ignore address space on a return types.
   void f2(T); // expected-error{{parameter may not be qualified with an address space}}
 };
 
Index: test/SemaOpenCLCXX/address-space-deduction.cl
===
--- test/SemaOpenCLCXX/address-space-deduction.cl
+++ test/SemaOpenCLCXX/address-space-deduction.cl
@@ -24,3 +24,17 @@
   alias_c1_ptr ptr = &y;
 };
 
+template 
+T xxx(T *in) {
+  // This pointer can't be deduced to generic because addr space
+  // will be taken from the template argument.
+  //CHECK: `-VarDecl {{.*}} i 'T *' cinit
+  T *i = in;
+  T ii;
+  return *i;
+}
+
+__kernel void test() {
+  int foo[10];
+  xxx(&foo[0]);
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -5365,13 +5365,6 @@
 if (ResultType.

[PATCH] D64801: [analyzer] Add CTU user docs

2019-07-17 Thread Daniel Krupp via Phabricator via cfe-commits
dkrupp requested changes to this revision.
dkrupp added a comment.
This revision now requires changes to proceed.

Thanks Gabor for writing this. 
I suggested some minor changes to the txt. Otherwise LGTM.




Comment at: clang/docs/analyzer/user-docs/CrossTranslationUnit.rst:98
+
+This manual procedure is boring and error-prone, so sooner or later we'd like 
to have a script which automates this for us.
+

since CodeChecker automation is already available I suggest rephrasing.

This manual procedure is error-prone and not scalable, so for analyzing real 
projects it is recommended to use the built-in support of  CodeChecker or 
scan-build-py.



Comment at: clang/docs/analyzer/user-docs/CrossTranslationUnit.rst:142
+The `plist` files contain the results of the analysis, which may be viewed 
with the regular analysis tools.
+E.g. one may use `CodeChecker server` and `CodeChecker store` to store and 
view the results in a web browser.
+

I suggest to replace this line with the following:
E.g. one may use CodeChecker parse to view the results in command line or 
CodeChecker parse -e html to export them into HTML format.

pure command line usage without worrying about the server setup better fits 
this command line use-case.



Comment at: clang/docs/analyzer/user-docs/CrossTranslationUnit.rst:147
+We actively develop CTU with CodeChecker as a "runner" script, `scan-build` is 
not actively developed for CTU.
+`scan-build` has different errors and issues, expect it to work with the very 
basic projects only.

Some basic usage description could be added still...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64801



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


[PATCH] D63648: [Preprocessor] Honor absolute paths in diagnostics

2019-07-17 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

I will try to take a look, but can you please expand the patch description a 
little to make it more clear exactly what you're proposing to change? Sorry for 
all the questions below, I'm just trying to understand exactly what the issue 
is.

> Previously, -fdiagnostics-absolute-paths did not have an effect in some 
> cases, for example: when using relative include paths, or relative CPP paths

Are you saying the diagnostics were not using absolute paths in those cases and 
this patch fixes that?

> , or --show-includes, or -E

Those aren't diagnostics, so that's not surprising.

> or displaying notes.

What notes?

> We have a peculiar use-case on our end with Fastbuild, where all this was 
> exposed: CPP files are being are preprocessed on one PC, then compiled on 
> another PC (which doesn't have the source-code); then the compiler's stdout 
> is displayed on the first PC.

And what is the final problem? That diagnostics from the compiler's stdout are 
not absolute because they came from the preprocessed code that doesn't include 
the absolute paths?


Repository:
  rC Clang

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

https://reviews.llvm.org/D63648



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


[PATCH] D61333: [ASTImporter] Fix LLDB lookup in transparent ctx and with ext src

2019-07-17 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/lang/c/ast/TestAST.py:57
+# This expr command imports __sFILE with definition
+# (FILE is a typedef to __sFILE.)
+self.expect(

teemperor wrote:
> I think this test has a good chance to fail once someone 
> renamed/removes/changes this internal struct (especially if it's currently  
> abstracted with a typedef). Would it be possible to just make a minimal 
> module with open and FILE/__sFILE instead? If it's too much trouble, then I'm 
> also fine with merging this as-is (as this regression is easy to fix).
I'd rather keep this as-is, because I don't have enough confidence and 
experience with c modules (and with macOS).



Comment at: lldb/packages/Python/lldbsuite/test/lang/c/ast/TestAST.py:67
+# Check that the AST log contains exactly one definition of __sFILE.
+f = open(log_file)
+log_lines = f.readlines()

teemperor wrote:
> It seems that this is the only different in the test compared to 
> TestCModules.py. Would it be possible to just add this logging/checking to 
> TestCModules.py as it's anyway testing something very similar?
Ok, I have removed the TestAST.py and added the extra logging and the check 
into TestCModules.py.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61333



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


[PATCH] D61333: [ASTImporter] Fix LLDB lookup in transparent ctx and with ext src

2019-07-17 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 210281.
martong marked 5 inline comments as done.
martong added a comment.

- Applied clang-format on lldb parts (this changed two lines)
- Added a comment for predicate
- Merged the test into TestCModules.py


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61333

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  lldb/packages/Python/lldbsuite/test/lang/c/modules/TestCModules.py
  lldb/packages/Python/lldbsuite/test/lang/c/modules/main.c
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp

Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -611,10 +611,15 @@
   if (!original_decl_context)
 return;
 
+  // Indicates whether we skipped any Decls of the original DeclContext.
+  bool SkippedDecls = false;
   for (TagDecl::decl_iterator iter = original_decl_context->decls_begin();
iter != original_decl_context->decls_end(); ++iter) {
 Decl *decl = *iter;
 
+// The predicate function returns true if the passed declaration kind is
+// the one we are looking for.
+// See clang::ExternalASTSource::FindExternalLexicalDecls()
 if (predicate(decl->getKind())) {
   if (log) {
 ASTDumper ast_dumper(decl);
@@ -639,21 +644,22 @@
 
 m_ast_importer_sp->RequireCompleteType(copied_field_type);
   }
-
-  DeclContext *decl_context_non_const =
-  const_cast(decl_context);
-
-  if (copied_decl->getDeclContext() != decl_context) {
-if (copied_decl->getDeclContext()->containsDecl(copied_decl))
-  copied_decl->getDeclContext()->removeDecl(copied_decl);
-copied_decl->setDeclContext(decl_context_non_const);
-  }
-
-  if (!decl_context_non_const->containsDecl(copied_decl))
-decl_context_non_const->addDeclInternal(copied_decl);
+} else {
+  SkippedDecls = true;
 }
   }
 
+  // CopyDecl may build a lookup table which may set up ExternalLexicalStorage
+  // to false.  However, since we skipped some of the external Decls we must
+  // set it back!
+  if (SkippedDecls) {
+decl_context->setHasExternalLexicalStorage(true);
+// This sets HasLazyExternalLexicalLookups to true.  By setting this bit we
+// ensure that the lookup table is rebuilt, which means the external source
+// is consulted again when a clang::DeclContext::lookup is called.
+const_cast(decl_context)->setMustBuildLookupTable();
+  }
+
   return;
 }
 
Index: lldb/packages/Python/lldbsuite/test/lang/c/modules/main.c
===
--- lldb/packages/Python/lldbsuite/test/lang/c/modules/main.c
+++ lldb/packages/Python/lldbsuite/test/lang/c/modules/main.c
@@ -5,11 +5,11 @@
 typedef struct {
 int a;
 int b;
-} FILE;
+} MYFILE;
 
 int main()
 {
-FILE *myFile = malloc(sizeof(FILE));
+MYFILE *myFile = malloc(sizeof(MYFILE));
 
 myFile->a = 5;
 myFile->b = 9;
Index: lldb/packages/Python/lldbsuite/test/lang/c/modules/TestCModules.py
===
--- lldb/packages/Python/lldbsuite/test/lang/c/modules/TestCModules.py
+++ lldb/packages/Python/lldbsuite/test/lang/c/modules/TestCModules.py
@@ -47,6 +47,10 @@
 self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
 substrs=[' resolved, hit count = 1'])
 
+# Enable logging of the imported AST.
+log_file = os.path.join(self.getBuildDir(), "lldb-ast-log.txt")
+self.runCmd("log enable lldb ast -f '%s'" % log_file)
+
 self.expect(
 "expr -l objc++ -- @import Darwin; 3",
 VARIABLES_DISPLAYED_CORRECTLY,
@@ -54,6 +58,8 @@
 "int",
 "3"])
 
+# This expr command imports __sFILE with definition
+# (FILE is a typedef to __sFILE.)
 self.expect(
 "expr *fopen(\"/dev/zero\", \"w\")",
 VARIABLES_DISPLAYED_CORRECTLY,
@@ -61,6 +67,14 @@
 "FILE",
 "_close"])
 
+# Check that the AST log contains exactly one definition of __sFILE.
+f = open(log_file)
+log_lines = f.readlines()
+f.close()
+os.remove(log_file)
+self.assertEqual(" ".join(log_lines).count("struct __sFILE definition"),
+ 1)
+
 self.expect("expr *myFile", VARIABLES_DISPLAYED_CORRECTLY,
 substrs=["a", "5", "b", "9"])
 
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5122,6 +5122,51 @@
   EXPECT_EQ(ToLSize, F

[PATCH] D64504: Various minor tweaks to CLCompatOptions.td

2019-07-17 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Thanks for polishing the UX! :-)


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

https://reviews.llvm.org/D64504



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


[PATCH] D64253: Let unaliased Args track which Alias they were created from, and use that in Arg::getAsString() for diagnostics

2019-07-17 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

I think this is going to be my favourite new feature in clang 9 :-) Do you want 
to put a small note in docs/ReleaseNotes.rst?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64253



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


[PATCH] D64475: [clangd] Duplicate lines of semantic highlightings sent removed.

2019-07-17 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom updated this revision to Diff 210282.
jvikstrom marked 4 inline comments as done.
jvikstrom added a comment.

Rewrote test to be more readable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64475

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/semantic-highlighting.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -29,7 +29,10 @@
   return Tokens;
 }
 
-void checkHighlightings(llvm::StringRef Code) {
+// Returns ActualTokens, ExpectedTokens and the lines that should be empty.
+std::tuple, std::vector,
+   std::vector>
+getHighlightingsAnnotated(llvm::StringRef Code) {
   Annotations Test(Code);
   auto AST = TestTU::withCode(Test.code()).build();
   static const std::map KindToString{
@@ -48,10 +51,56 @@
 ExpectedTokens.insert(ExpectedTokens.end(), Toks.begin(), Toks.end());
   }
 
+  auto EmptyRanges = Test.ranges("Empty");
+  std::vector EmptyLines(EmptyRanges.size());
+  for (unsigned I = 0, End = EmptyRanges.size(); I < End; ++I)
+EmptyLines[I] = EmptyRanges[I].start.line;
   auto ActualTokens = getSemanticHighlightings(AST);
+  return {ActualTokens, ExpectedTokens, EmptyLines};
+}
+
+void checkHighlightings(llvm::StringRef Code) {
+  std::vector ActualTokens;
+  std::vector ExpectedTokens;
+  std::tie(ActualTokens, ExpectedTokens, std::ignore) =
+  getHighlightingsAnnotated(Code);
   EXPECT_THAT(ActualTokens, testing::UnorderedElementsAreArray(ExpectedTokens));
 }
 
+void checkDiffedHighlights(const char *OrgCode, const char *NewCode) {
+  std::vector CompleteTokens1;
+  std::tie(CompleteTokens1, std::ignore, std::ignore) =
+  getHighlightingsAnnotated(OrgCode);
+  std::vector CompleteTokens2;
+  std::vector ExpectedTokens;
+  std::vector EmptyLines;
+  std::tie(CompleteTokens2, ExpectedTokens, EmptyLines) =
+  getHighlightingsAnnotated(NewCode);
+
+  std::vector ActualDiffed =
+  diffHighlightings(CompleteTokens2, CompleteTokens1);
+
+  std::map> ExpectedLines;
+  for (const HighlightingToken &Token : ExpectedTokens)
+ExpectedLines[Token.R.start.line].push_back(Token);
+  std::vector ExpectedLinePairHighlighting;
+  for (int Line : EmptyLines)
+ExpectedLinePairHighlighting.push_back({Line, {}});
+  for (auto &LineTokens : ExpectedLines) {
+llvm::sort(LineTokens.second);
+ExpectedLinePairHighlighting.push_back(
+{LineTokens.first, LineTokens.second});
+  }
+
+  // The UnorderedElementsAreArray only checks that the top level vector
+  // is unordered. The vectors in the pair must be in the correct order.
+  for (unsigned I = 0, End = ActualDiffed.size(); I < End; ++I)
+llvm::sort(ActualDiffed[I].Tokens);
+
+  EXPECT_THAT(ActualDiffed,
+  testing::UnorderedElementsAreArray(ExpectedLinePairHighlighting));
+}
+
 TEST(SemanticHighlighting, GetsCorrectTokens) {
   const char *TestCases[] = {
 R"cpp(
@@ -211,21 +260,82 @@
 return Pos;
   };
 
-  std::vector Tokens{
-  {HighlightingKind::Variable,
-Range{CreatePosition(3, 8), CreatePosition(3, 12)}},
-  {HighlightingKind::Function,
-Range{CreatePosition(3, 4), CreatePosition(3, 7)}},
-  {HighlightingKind::Variable,
-Range{CreatePosition(1, 1), CreatePosition(1, 5)}}};
+  std::vector Tokens{
+  {3,
+   {{HighlightingKind::Variable,
+ Range{CreatePosition(3, 8), CreatePosition(3, 12)}},
+{HighlightingKind::Function,
+ Range{CreatePosition(3, 4), CreatePosition(3, 7),
+  {1,
+   {{HighlightingKind::Variable,
+ Range{CreatePosition(1, 1), CreatePosition(1, 5)};
   std::vector ActualResults =
   toSemanticHighlightingInformation(Tokens);
   std::vector ExpectedResults = {
-  {1, "AQAEAAA="},
-  {3, "CAAEAAAEAAMAAQ=="}};
+  {3, "CAAEAAAEAAMAAQ=="}, {1, "AQAEAAA="}};
   EXPECT_EQ(ActualResults, ExpectedResults);
 }
 
+TEST(SemanticHighlighting, HighlightingDiffer) {
+  // The first entry is the old code. The second entry is the new code.
+  std::vector> TestCases{{
+   R"cpp(
+  int $Variable[[A]]
+  double $Variable[[B]];
+  struct $Class[[C]] {};
+)cpp",
+   R"cpp(
+  int A;
+  double B;
+  struct C {};
+)cpp"},
+   {

[PATCH] D64475: [clangd] Duplicate lines of semantic highlightings sent removed.

2019-07-17 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom added inline comments.



Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:281
+  )cpp"}},
+{{5},
+ {

hokein wrote:
> so the empty lines are stored separately, which is not easy to figure out 
> from the testing code snippet. I think we should make the empty lines more 
> obvious in the code snippet (maybe use an `Empty` annotations?) , and 
> explicitly verify the empty lines.
> 
> What do you think refining the test like below, just annotate the diff 
> tokens? I find it is easy to spot the diff tokens.
> 
> ```
> struct Testcase {
>Code Before;
>Code After;
> };
> 
> std::vector cases = {
>{ 
>R"cpp(
>  int a;
>  int b; 
>  int c;
>   )cpp",
>   R"cpp(
> int a;
> $Empty[[]] // int b
> int $Variable[[C]];
>   )cpp"
>   }
> }
> 
> oldHighlightings = getSemanticHighlightings(OldAST);
> newHighlightings = getSemanticHighlightings(NewAST);
> diffHighlightings = diff...;
> // verify the diffHighlightings has the expected empty lines ("Empty" 
> annotations).
> // verify the diffHighlightings has the expected highlightings (the regular 
> annotations);
> ```
> 
Moved everything into the checkDiffedHighlights as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64475



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


[clang-tools-extra] r366311 - [clangd] Fix error message in tweaktests to be useful. NFC

2019-07-17 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Jul 17 03:17:47 2019
New Revision: 366311

URL: http://llvm.org/viewvc/llvm-project?rev=366311&view=rev
Log:
[clangd] Fix error message in tweaktests to be useful. NFC

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

Modified: clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp?rev=366311&r1=366310&r2=366311&view=diff
==
--- clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp Wed Jul 17 03:17:47 
2019
@@ -17,6 +17,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Testing/Support/Error.h"
+#include "gmock/gmock-matchers.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
@@ -134,10 +135,9 @@ void checkApplyContainsError(llvm::Strin
   auto Result = apply(ID, Input);
   ASSERT_FALSE(Result) << "expected error message:\n   " << ErrorMessage <<
"\non input:" << Input;
-  EXPECT_NE(std::string::npos,
-llvm::toString(Result.takeError()).find(ErrorMessage))
-<< "Wrong error message:\n  " << llvm::toString(Result.takeError())
-<< "\nexpected:\n  " << ErrorMessage;
+  EXPECT_THAT(llvm::toString(Result.takeError()),
+  testing::HasSubstr(ErrorMessage))
+  << Input;
 }
 
 TEST(TweakTest, SwapIfBranches) {


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


[PATCH] D64741: [clangd] Added highlighting for tokens that are macro arguments.

2019-07-17 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom added a comment.

In D64741#1588987 , @ilya-biryukov 
wrote:

> > I had completely missed that there could be conflicting tokens when only 
> > highlighting macro arguments as well. Added code to just remove conflicting 
> > tokens.
>
> Picking one of the highlightings looks fine, but we probably want to make 
> sure it's deterministic. Given that we use `sort` now, I bet it won't be. 
> Maybe include kinds into comparison as well? That's not a perfect solution, 
> but would at least make sure the user-visible behavior is not random.
>  Could you add tests for that case too?


Already added the case you sent a comment on in the test case. (look at the top 
of it)
Don't understand what you mean with the `sort` though. Kinds are already 
included in the comparator for sort. After the call to unique the only tokens 
that will share ranges are the ones that have different kinds.

Could just have a custom comparator in the call to unique that only compares 
the tokens' ranges which would leave us with the token whose kind is the lowest 
when there are conflicting ones. But do we really want to highlight anything 
when there are conflicts?

Maybe we should add another kind of Kind for when a token is conflicting?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64741



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


[PATCH] D52079: [Sema] Do not load macros from preamble when LoadExternal is false.

2019-07-17 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.
Herald added a subscriber: arphaman.
Herald added a project: clang.

I've bisected https://bugs.llvm.org/show_bug.cgi?id=42649 to this change. 
Reverting this change fixes the issue.

Please look into it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D52079



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


[PATCH] D64482: [Driver] Define _FILE_OFFSET_BITS=64 on Solaris

2019-07-17 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

In D64482#1588154 , @rnk wrote:

> > To avoid a similar inconsistence with host compilers that don't predefine 
> > _FILE_OFFSET_BITS=64
> >  (e.g. clang < 9, gcc < 9), this needs a compantion patch to be submitted 
> > shortly.
>
> I'm curious, what's the plan for that? I suppose the user can always take 
> things into their own hands with -D and -U.


The companion patch https://reviews.llvm.org/D64483 unconditionally predefines 
`_FILE_OFFSET_BITS=64` on Solaris, irrespective
of compiler.  It still needs approval and should go in first, otherwise we 
trade the failure with a gcc 9 host compiler for a failure with 
older gcc and clang (and this also would break the Solaris buildbots, which 
currently use gcc 7).

While users could use -D/-U by themselves to select the largefile support they 
want, I wouldn't rely too much on that, with parts of
libstdc++ in headers and the rest in the shared object.  Mixing code with and 
without largefile support in the same executable works,
of course, but the results may be surprising...


Repository:
  rC Clang

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

https://reviews.llvm.org/D64482



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


[PATCH] D52193: RFC: [clang] Multithreaded compilation support -- NOT FOR SUBMIT

2019-07-17 Thread Angus Hewlett via Phabricator via cfe-commits
angushewlett added a comment.

In D52193#1457612 , @aganea wrote:

> That is strange. As you can’t mix /Yc and /Yu on the command line, MSBuild 
> should issue two different calls to clang-cl, one with /Yc and one /Yu /MP. 
> Can you check with ProcMon that commands are issued in the right order?


They're issued in the right order, but the second doesn't wait for the first to 
complete.


Repository:
  rC Clang

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

https://reviews.llvm.org/D52193



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


[PATCH] D64475: [clangd] Duplicate lines of semantic highlightings sent removed.

2019-07-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:275
+bool operator<(const HighlightingToken &L, const HighlightingToken &R) {
+  return std::tie(L.R, L.Kind) < std::tie(R.R, R.Kind);;
+}

nit: remove the redundant `;`.



Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:35
+   std::vector>
+getHighlightingsAnnotated(llvm::StringRef Code) {
   Annotations Test(Code);

could we split it into three functions?

- getExpectedHighlightings
- getActualHighlightings
- getExpectedEmptyLines





Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:70
 
+void checkDiffedHighlights(const char *OrgCode, const char *NewCode) {
+  std::vector CompleteTokens1;

nit: OrgCode => OldCode, use llvm::StringRef



Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:98
+  for (unsigned I = 0, End = ActualDiffed.size(); I < End; ++I)
+llvm::sort(ActualDiffed[I].Tokens);
+

I think the tokens are also sorted, as we pass two sorted lists of 
highlightings to `diffHighlightings`.



Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:282
+  std::vector> TestCases{{
+   R"cpp(
+  int $Variable[[A]]

nit: the code indentation is strange



Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:283
+   R"cpp(
+  int $Variable[[A]]
+  double $Variable[[B]];

The annotations in the OldCode are not used -- you only use the actual 
highlightings in the `checkDiffedHighlights`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64475



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


[PATCH] D64741: [clangd] Added highlighting for tokens that are macro arguments.

2019-07-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Thanks for pointing out I missed stuff. The strategy for conflicting 
highlightings LG, just a few NITs left from my side.

In D64741#1589144 , @jvikstrom wrote:

> Already added the case you sent a comment on in the test case. (look at the 
> top of it)


Ah, sorry, I missed it. There are many there and the one you added slipped my 
mind.

> Don't understand what you mean with the `sort` though. Kinds are already 
> included in the comparator for sort. After the call to unique the only tokens 
> that will share ranges are the ones that have different kinds.

Ah, right. Sorry, missed that as well, `sort()` LG, the results are 
deterministic.

> Could just have a custom comparator in the call to unique that only compares 
> the tokens' ranges which would leave us with the token whose kind is the 
> lowest when there are conflicting ones. But do we really want to highlight 
> anything when there are conflicts?
>  Maybe we should add another kind of Kind for when a token is conflicting?

Not highlighting for conflicting kinds LG (there is one interesting case that I 
think we should support at the end of my comment, other than it looks ok).
Conflicting would be hard to explain to users, so not having it look like a 
better option.

Now, one interesting case that we should probably support is `assert`. 
Schematically, it does something like:

  #define assert(COND) if (!(cond)) { fail("assertion failed" #COND); }
  assert(x != y);

Despite the argument being mentioned twice, we definitely only want 
highlightings from the first occurrence (that would give us kinds for 
expressions).
I would expect that this already works, in which case it's just a matter of 
adding a test case to guard against future regressions.

If this does not work, we should probably fix it in a separate change.




Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:195
+  #define DEF_CLASS(T) class T {};
+  DEF_MULTIPLE(XYZ);
+  DEF_MULTIPLE(XYZW);

Could you add a comment explaining that we choose to not highlight the 
conflicting tokens?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64741



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


[PATCH] D64482: [Driver] Define _FILE_OFFSET_BITS=64 on Solaris

2019-07-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> You may not like them, but there are plenty of examples in OSTargets.h (for 
> kFreeBSD, Hurd, Linux, RTEMS, AIX, Windows, NaCl and

several more). Why take offense in the Solaris case if this is already common 
practice?

I used that as an example. Defining _GNU_SOURCE was a mistake. Making it 
different from C was another mistake. It is very unfortunate that it is too 
late to fix them.

> Even if it were, this would only affect future releases. The user experience 
> of "you need to upgrade to Solaris 11.x" or install update y to get this" 
> seems pretty dismal to me. Besides, that ship has sailed and GCC 9 is 
> released.

Defining `_LARGEFILE_SOURCE`, `_LARGEFILE64_SOURCE` and `_FILE_OFFSET_BITS` on 
the compiler side is exclusively used by Solaris. Do you mean that newer 
Solaris versions may define these macros in the common headers and these macros 
can eventually be removed from compiler drivers?

If these are considered temporary hacks to make some application to compile on 
older Solaris versions, I think the comment should be expanded a bit.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64482



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


[PATCH] D64415: Consistent types and naming for AArch64 target features (NFC)

2019-07-17 Thread Momchil Velikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366315: [AArch64] Consistent types and naming for AArch64 
target features (NFC) (authored by chill, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64415?vs=210286&id=210290#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64415

Files:
  cfe/trunk/lib/Basic/Targets/AArch64.cpp
  cfe/trunk/lib/Basic/Targets/AArch64.h

Index: cfe/trunk/lib/Basic/Targets/AArch64.cpp
===
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp
@@ -199,13 +199,13 @@
   if (FPU & SveMode)
 Builder.defineMacro("__ARM_FEATURE_SVE", "1");
 
-  if (CRC)
+  if (HasCRC)
 Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
 
-  if (Crypto)
+  if (HasCrypto)
 Builder.defineMacro("__ARM_FEATURE_CRYPTO", "1");
 
-  if (Unaligned)
+  if (HasUnaligned)
 Builder.defineMacro("__ARM_FEATURE_UNALIGNED", "1");
 
   if ((FPU & NeonMode) && HasFullFP16)
@@ -263,13 +263,13 @@
 bool AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
  DiagnosticsEngine &Diags) {
   FPU = FPUMode;
-  CRC = 0;
-  Crypto = 0;
-  Unaligned = 1;
-  HasFullFP16 = 0;
-  HasDotProd = 0;
-  HasFP16FML = 0;
-  HasMTE = 0;
+  HasCRC = false;
+  HasCrypto = false;
+  HasUnaligned = true;
+  HasFullFP16 = false;
+  HasDotProd = false;
+  HasFP16FML = false;
+  HasMTE = false;
   ArchKind = llvm::AArch64::ArchKind::ARMV8A;
 
   for (const auto &Feature : Features) {
@@ -278,11 +278,11 @@
 if (Feature == "+sve")
   FPU |= SveMode;
 if (Feature == "+crc")
-  CRC = 1;
+  HasCRC = true;
 if (Feature == "+crypto")
-  Crypto = 1;
+  HasCrypto = true;
 if (Feature == "+strict-align")
-  Unaligned = 0;
+  HasUnaligned = false;
 if (Feature == "+v8.1a")
   ArchKind = llvm::AArch64::ArchKind::ARMV8_1A;
 if (Feature == "+v8.2a")
@@ -294,13 +294,13 @@
 if (Feature == "+v8.5a")
   ArchKind = llvm::AArch64::ArchKind::ARMV8_5A;
 if (Feature == "+fullfp16")
-  HasFullFP16 = 1;
+  HasFullFP16 = true;
 if (Feature == "+dotprod")
-  HasDotProd = 1;
+  HasDotProd = true;
 if (Feature == "+fp16fml")
-  HasFP16FML = 1;
+  HasFP16FML = true;
 if (Feature == "+mte")
-  HasMTE = 1;
+  HasMTE = true;
   }
 
   setDataLayout();
Index: cfe/trunk/lib/Basic/Targets/AArch64.h
===
--- cfe/trunk/lib/Basic/Targets/AArch64.h
+++ cfe/trunk/lib/Basic/Targets/AArch64.h
@@ -28,13 +28,14 @@
   enum FPUModeEnum { FPUMode, NeonMode = (1 << 0), SveMode = (1 << 1) };
 
   unsigned FPU;
-  unsigned CRC;
-  unsigned Crypto;
-  unsigned Unaligned;
-  unsigned HasFullFP16;
-  unsigned HasDotProd;
-  unsigned HasFP16FML;
-  unsigned HasMTE;
+  bool HasCRC;
+  bool HasCrypto;
+  bool HasUnaligned;
+  bool HasFullFP16;
+  bool HasDotProd;
+  bool HasFP16FML;
+  bool HasMTE;
+
   llvm::AArch64::ArchKind ArchKind;
 
   static const Builtin::Info BuiltinInfo[];
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r366315 - [AArch64] Consistent types and naming for AArch64 target features (NFC)

2019-07-17 Thread Momchil Velikov via cfe-commits
Author: chill
Date: Wed Jul 17 04:24:37 2019
New Revision: 366315

URL: http://llvm.org/viewvc/llvm-project?rev=366315&view=rev
Log:
[AArch64] Consistent types and naming for AArch64 target features (NFC)

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

Committed as obvious.

Modified:
cfe/trunk/lib/Basic/Targets/AArch64.cpp
cfe/trunk/lib/Basic/Targets/AArch64.h

Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.cpp?rev=366315&r1=366314&r2=366315&view=diff
==
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp Wed Jul 17 04:24:37 2019
@@ -199,13 +199,13 @@ void AArch64TargetInfo::getTargetDefines
   if (FPU & SveMode)
 Builder.defineMacro("__ARM_FEATURE_SVE", "1");
 
-  if (CRC)
+  if (HasCRC)
 Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
 
-  if (Crypto)
+  if (HasCrypto)
 Builder.defineMacro("__ARM_FEATURE_CRYPTO", "1");
 
-  if (Unaligned)
+  if (HasUnaligned)
 Builder.defineMacro("__ARM_FEATURE_UNALIGNED", "1");
 
   if ((FPU & NeonMode) && HasFullFP16)
@@ -263,13 +263,13 @@ bool AArch64TargetInfo::hasFeature(Strin
 bool AArch64TargetInfo::handleTargetFeatures(std::vector 
&Features,
  DiagnosticsEngine &Diags) {
   FPU = FPUMode;
-  CRC = 0;
-  Crypto = 0;
-  Unaligned = 1;
-  HasFullFP16 = 0;
-  HasDotProd = 0;
-  HasFP16FML = 0;
-  HasMTE = 0;
+  HasCRC = false;
+  HasCrypto = false;
+  HasUnaligned = true;
+  HasFullFP16 = false;
+  HasDotProd = false;
+  HasFP16FML = false;
+  HasMTE = false;
   ArchKind = llvm::AArch64::ArchKind::ARMV8A;
 
   for (const auto &Feature : Features) {
@@ -278,11 +278,11 @@ bool AArch64TargetInfo::handleTargetFeat
 if (Feature == "+sve")
   FPU |= SveMode;
 if (Feature == "+crc")
-  CRC = 1;
+  HasCRC = true;
 if (Feature == "+crypto")
-  Crypto = 1;
+  HasCrypto = true;
 if (Feature == "+strict-align")
-  Unaligned = 0;
+  HasUnaligned = false;
 if (Feature == "+v8.1a")
   ArchKind = llvm::AArch64::ArchKind::ARMV8_1A;
 if (Feature == "+v8.2a")
@@ -294,13 +294,13 @@ bool AArch64TargetInfo::handleTargetFeat
 if (Feature == "+v8.5a")
   ArchKind = llvm::AArch64::ArchKind::ARMV8_5A;
 if (Feature == "+fullfp16")
-  HasFullFP16 = 1;
+  HasFullFP16 = true;
 if (Feature == "+dotprod")
-  HasDotProd = 1;
+  HasDotProd = true;
 if (Feature == "+fp16fml")
-  HasFP16FML = 1;
+  HasFP16FML = true;
 if (Feature == "+mte")
-  HasMTE = 1;
+  HasMTE = true;
   }
 
   setDataLayout();

Modified: cfe/trunk/lib/Basic/Targets/AArch64.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.h?rev=366315&r1=366314&r2=366315&view=diff
==
--- cfe/trunk/lib/Basic/Targets/AArch64.h (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.h Wed Jul 17 04:24:37 2019
@@ -28,13 +28,14 @@ class LLVM_LIBRARY_VISIBILITY AArch64Tar
   enum FPUModeEnum { FPUMode, NeonMode = (1 << 0), SveMode = (1 << 1) };
 
   unsigned FPU;
-  unsigned CRC;
-  unsigned Crypto;
-  unsigned Unaligned;
-  unsigned HasFullFP16;
-  unsigned HasDotProd;
-  unsigned HasFP16FML;
-  unsigned HasMTE;
+  bool HasCRC;
+  bool HasCrypto;
+  bool HasUnaligned;
+  bool HasFullFP16;
+  bool HasDotProd;
+  bool HasFP16FML;
+  bool HasMTE;
+
   llvm::AArch64::ArchKind ArchKind;
 
   static const Builtin::Info BuiltinInfo[];


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


[PATCH] D64736: [clang-tidy] New bugprone-infinite-loop check for detecting obvious infinite loops

2019-07-17 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 210287.
baloghadamsoftware added a comment.
Herald added a subscriber: jfb.

Tests for `volatile`, atomics and noreturn functions added. Check fixed to make 
these tests pass.


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

https://reviews.llvm.org/D64736

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/InfiniteLoopCheck.cpp
  clang-tidy/bugprone/InfiniteLoopCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-infinite-loop.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-infinite-loop.cpp

Index: test/clang-tidy/bugprone-infinite-loop.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-infinite-loop.cpp
@@ -0,0 +1,291 @@
+// RUN: %check_clang_tidy %s bugprone-infinite-loop %t
+
+void simple_infinite_loop1() {
+  int i = 0;
+  int j = 0;
+  while (i < 10) {
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: None of the condition variables (i) are updated in the loop body [bugprone-infinite-loop]
+j++;
+  }
+
+  do {
+j++;
+  } while (i < 10);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: None of the condition variables (i) are updated in the loop body [bugprone-infinite-loop]
+
+  for (i = 0; i < 10; ++j) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: None of the condition variables (i) are updated in the loop body [bugprone-infinite-loop]
+  }
+}
+
+void simple_infinite_loop2() {
+  int i = 0;
+  int j = 0;
+  int Limit = 10;
+  while (i < Limit) {
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: None of the condition variables (i, Limit) are updated in the loop body [bugprone-infinite-loop]
+j++;
+  }
+
+  do {
+j++;
+  } while (i < Limit);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: None of the condition variables (i, Limit) are updated in the loop body [bugprone-infinite-loop]
+
+  for (i = 0; i < Limit; ++j) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: None of the condition variables (i, Limit) are updated in the loop body [bugprone-infinite-loop]
+  }
+}
+
+void simple_not_infinite1() {
+  int i = 0;
+  int Limit = 100;
+  while (i < Limit) { // Not an error since 'Limit' is updated
+Limit--;
+  }
+  do {
+Limit--;
+  } while (i < Limit);
+
+  for (i = 0; i < Limit; Limit--) {
+  }
+}
+
+void simple_not_infinite2() {
+  for (int i = 10; i-- > 0;) // Not an error, since loop variable is modified in
+;// the condition part.
+}
+
+int any_function();
+
+void function_call() {
+  int i = 0;
+  while (i < any_function()) { // Not an error, since the function may return
+   // different values
+  }
+
+  do { // Not an error, since the function may return
+   // different values
+  } while (i < any_function());
+
+  for (i = 0; i < any_function();) { // Not an error, since the function may
+ // return different values
+  }
+}
+
+void escape_before1() {
+  int i = 0;
+  int Limit = 100;
+  int *p = &i;
+  while (i < Limit) { // Not an error, since *p is alias of i.
+(*p)++;
+  }
+
+  do {
+(*p)++;
+  } while (i < Limit);
+
+  for (i = 0; i < Limit; ++(*p)) {
+  }
+}
+
+void escape_before2() {
+  int i = 0;
+  int Limit = 100;
+  int &ii = i;
+  while (i < Limit) { // Not an error, since ii is alias of i.
+ii++;
+  }
+
+  do {
+ii++;
+  } while (i < Limit);
+
+  for (i = 0; i < Limit; ++ii) {
+  }
+}
+
+void escape_inside1() {
+  int i = 0;
+  int Limit = 100;
+  int *p = &i;
+  while (i < Limit) { // Not an error, since *p is alias of i.
+int *p = &i;
+(*p)++;
+  }
+
+  do {
+int *p = &i;
+(*p)++;
+  } while (i < Limit);
+}
+
+void escape_inside2() {
+  int i = 0;
+  int Limit = 100;
+  while (i < Limit) { // Not an error, since ii is alias of i.
+int &ii = i;
+ii++;
+  }
+
+  do {
+int &ii = i;
+ii++;
+  } while (i < Limit);
+}
+
+void escape_after1() {
+  int i = 0;
+  int j = 0;
+  int Limit = 10;
+
+  while (i < Limit) {
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: None of the condition variables (i, Limit) are updated in the loop body [bugprone-infinite-loop]
+  }
+  int *p = &i;
+}
+
+void escape_after2() {
+  int i = 0;
+  int j = 0;
+  int Limit = 10;
+
+  while (i < Limit) {
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: None of the condition variables (i, Limit) are updated in the loop body [bugprone-infinite-loop]
+  }
+  int &ii = i;
+}
+
+int glob;
+
+void global1(int &x) {
+  int i = 0, Limit = 100;
+  while (x < Limit) { // Not an error since 'x' can be an alias of glob.
+glob++;
+  }
+}
+
+void global2() {
+  int i = 0, Limit = 100;
+  while (glob < Limit) { // Since 'glob' is declared out of the function we do
+ // not warn.
+i++;
+  }
+}
+
+struct X {
+  int m;
+
+  void change_m();
+
+  void member_expr1(int i) {
+while (i < m) { // False negat

[PATCH] D64415: Consistent types and naming for AArch64 target features (NFC)

2019-07-17 Thread Momchil Velikov via Phabricator via cfe-commits
chill updated this revision to Diff 210286.

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

https://reviews.llvm.org/D64415

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h

Index: clang/lib/Basic/Targets/AArch64.h
===
--- clang/lib/Basic/Targets/AArch64.h
+++ clang/lib/Basic/Targets/AArch64.h
@@ -28,13 +28,14 @@
   enum FPUModeEnum { FPUMode, NeonMode = (1 << 0), SveMode = (1 << 1) };
 
   unsigned FPU;
-  unsigned CRC;
-  unsigned Crypto;
-  unsigned Unaligned;
-  unsigned HasFullFP16;
-  unsigned HasDotProd;
-  unsigned HasFP16FML;
-  unsigned HasMTE;
+  bool HasCRC;
+  bool HasCrypto;
+  bool HasUnaligned;
+  bool HasFullFP16;
+  bool HasDotProd;
+  bool HasFP16FML;
+  bool HasMTE;
+
   llvm::AArch64::ArchKind ArchKind;
 
   static const Builtin::Info BuiltinInfo[];
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -199,13 +199,13 @@
   if (FPU & SveMode)
 Builder.defineMacro("__ARM_FEATURE_SVE", "1");
 
-  if (CRC)
+  if (HasCRC)
 Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
 
-  if (Crypto)
+  if (HasCrypto)
 Builder.defineMacro("__ARM_FEATURE_CRYPTO", "1");
 
-  if (Unaligned)
+  if (HasUnaligned)
 Builder.defineMacro("__ARM_FEATURE_UNALIGNED", "1");
 
   if ((FPU & NeonMode) && HasFullFP16)
@@ -263,13 +263,13 @@
 bool AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
  DiagnosticsEngine &Diags) {
   FPU = FPUMode;
-  CRC = 0;
-  Crypto = 0;
-  Unaligned = 1;
-  HasFullFP16 = 0;
-  HasDotProd = 0;
-  HasFP16FML = 0;
-  HasMTE = 0;
+  HasCRC = false;
+  HasCrypto = false;
+  HasUnaligned = true;
+  HasFullFP16 = false;
+  HasDotProd = false;
+  HasFP16FML = false;
+  HasMTE = false;
   ArchKind = llvm::AArch64::ArchKind::ARMV8A;
 
   for (const auto &Feature : Features) {
@@ -278,11 +278,11 @@
 if (Feature == "+sve")
   FPU |= SveMode;
 if (Feature == "+crc")
-  CRC = 1;
+  HasCRC = true;
 if (Feature == "+crypto")
-  Crypto = 1;
+  HasCrypto = true;
 if (Feature == "+strict-align")
-  Unaligned = 0;
+  HasUnaligned = false;
 if (Feature == "+v8.1a")
   ArchKind = llvm::AArch64::ArchKind::ARMV8_1A;
 if (Feature == "+v8.2a")
@@ -294,13 +294,13 @@
 if (Feature == "+v8.5a")
   ArchKind = llvm::AArch64::ArchKind::ARMV8_5A;
 if (Feature == "+fullfp16")
-  HasFullFP16 = 1;
+  HasFullFP16 = true;
 if (Feature == "+dotprod")
-  HasDotProd = 1;
+  HasDotProd = true;
 if (Feature == "+fp16fml")
-  HasFP16FML = 1;
+  HasFP16FML = true;
 if (Feature == "+mte")
-  HasMTE = 1;
+  HasMTE = true;
   }
 
   setDataLayout();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64482: [Driver] Define _FILE_OFFSET_BITS=64 on Solaris

2019-07-17 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

In D64482#1589174 , @MaskRay wrote:

>




>> Even if it were, this would only affect future releases. The user experience 
>> of "you need to upgrade to Solaris 11.x" or install update y to get this" 
>> seems pretty dismal to me. Besides, that ship has sailed and GCC 9 is 
>> released.
> 
> Defining `_LARGEFILE_SOURCE`, `_LARGEFILE64_SOURCE` and `_FILE_OFFSET_BITS` 
> on the compiler side is exclusively used by Solaris. Do you mean that newer 
> Solaris versions may define these macros in the common headers and these 
> macros can eventually be removed from compiler drivers?

No, certainly not: it has been this way in gcc since at least 2002 and is not 
going to change. Besides, HP-UX 10 and 11 do the same.

> If these are considered temporary hacks to make some application to compile 
> on older Solaris versions, I think the comment should be expanded a bit.

It's not and thus going to stay.

>> Large file support is only relevant for 32-bit targets.
> 
> Yes. 
> https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff;f=gcc/config/sol2.h;h=bc4f63df03bc8e0b5bceee4e52f48240de7f993d;hp=ec4b111ba0e3cdf56970073959d228fbafe8937d;hb=0f97ccfdccc033f543ccbcb220697e62e84bf01f;hpb=ee621ce77125904f7946ba6cef345cb83e48248d
>  and the previous commits should probably restrict the scope of the hack to 
> 32-bit only.

There's no point: `_FILE_OFFSET_BITS` has no effect when `_LP64` is defined, so 
such an effort would be wasted.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64482



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


[PATCH] D33841: [clang-tidy] redundant 'extern' keyword check

2019-07-17 Thread Daniel Kolozsvari via Phabricator via cfe-commits
koldaniel added a comment.

Hi, do you have any additional comments?


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

https://reviews.llvm.org/D33841



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


[PATCH] D61333: [ASTImporter] Fix LLDB lookup in transparent ctx and with ext src

2019-07-17 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

LGTM, thanks a lot for fixing this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61333



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


[PATCH] D64741: [clangd] Added highlighting for tokens that are macro arguments.

2019-07-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:170
+return;
+  Loc = SM.getSpellingLoc(Loc);
+}

hokein wrote:
> jvikstrom wrote:
> > hokein wrote:
> > > The Loc here maybe not in the main file, considering the case
> > > 
> > > ```
> > > // in .h
> > > #define DEFINE(X) in X;
> > > #define DEFINE_Y DEFINE(Y)
> > > 
> > > // in .cc
> > > 
> > > DEFINE_Y
> > > ```
> > The spelling loc is still going to be in `DEFINE_Y` I think. And we only 
> > highlight arguments in macros. (Added a testcase though)
> ok, I don't have an exact case for macros now, but my gut feeling tells me we 
> will encounter cases where the Loc is not in main file.
> 
> here is a test case for declarations, we will visit the `foo()` decl in 
> `test.h` as well. This could be addressed in a separate patch.
> 
> ```
> // test.h
> void foo();
> 
> // test.cc
> #include "test.h"
> void foo() {}
> ```
> 
ok, here is the case, the spelling loc is not in main file, it is in ``

```
// test.h
#DEFINE(X) class X {};
#DEFINE_Y(Y) DEFINE(x##Y)

// test.cc
DEFINE_Y(a);
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64741



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


[PATCH] D33841: [clang-tidy] redundant 'extern' keyword check

2019-07-17 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In D33841#1589212 , @koldaniel wrote:

> Hi, do you have any additional comments?


Could you mark "Done" the comments you've addressed?


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

https://reviews.llvm.org/D33841



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


[PATCH] D64475: [clangd] Duplicate lines of semantic highlightings sent removed.

2019-07-17 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom updated this revision to Diff 210297.
jvikstrom marked 6 inline comments as done.
jvikstrom added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64475

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/semantic-highlighting.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -29,9 +29,12 @@
   return Tokens;
 }
 
-void checkHighlightings(llvm::StringRef Code) {
-  Annotations Test(Code);
+std::vector getActualTokens(Annotations &Test) {
   auto AST = TestTU::withCode(Test.code()).build();
+  return getSemanticHighlightings(AST);
+}
+
+std::vector getExpectedTokens(Annotations &Test) {
   static const std::map KindToString{
   {HighlightingKind::Variable, "Variable"},
   {HighlightingKind::Function, "Function"},
@@ -47,11 +50,50 @@
 Test.ranges(KindString.second), KindString.first);
 ExpectedTokens.insert(ExpectedTokens.end(), Toks.begin(), Toks.end());
   }
+  return ExpectedTokens;
+}
 
-  auto ActualTokens = getSemanticHighlightings(AST);
+std::vector getExpectedEmptyLines(Annotations &Test) {
+  auto EmptyRanges = Test.ranges("Empty");
+  std::vector EmptyLines(EmptyRanges.size());
+  for (unsigned I = 0, End = EmptyRanges.size(); I < End; ++I)
+EmptyLines[I] = EmptyRanges[I].start.line;
+  return EmptyLines;
+}
+
+void checkHighlightings(llvm::StringRef Code) {
+  Annotations Test(Code);
+  std::vector ActualTokens = getActualTokens(Test);
+  std::vector ExpectedTokens = getExpectedTokens(Test);
   EXPECT_THAT(ActualTokens, testing::UnorderedElementsAreArray(ExpectedTokens));
 }
 
+void checkDiffedHighlights(llvm::StringRef OldCode, llvm::StringRef NewCode) {
+  Annotations OldTest(OldCode);
+  Annotations NewTest(NewCode);
+  std::vector OldActualTokens = getActualTokens(OldTest);
+  std::vector NewActualTokens = getActualTokens(NewTest);
+  std::vector ExpectedTokens = getExpectedTokens(NewTest);
+  std::vector EmptyLines = getExpectedEmptyLines(NewTest);
+  std::vector ActualDiffed =
+  diffHighlightings(NewActualTokens, OldActualTokens);
+
+  std::map> ExpectedLines;
+  for (const HighlightingToken &Token : ExpectedTokens)
+ExpectedLines[Token.R.start.line].push_back(Token);
+  std::vector ExpectedLinePairHighlighting;
+  for (int Line : EmptyLines)
+ExpectedLinePairHighlighting.push_back({Line, {}});
+  for (auto &LineTokens : ExpectedLines) {
+llvm::sort(LineTokens.second);
+ExpectedLinePairHighlighting.push_back(
+{LineTokens.first, LineTokens.second});
+  }
+
+  EXPECT_THAT(ActualDiffed,
+  testing::UnorderedElementsAreArray(ExpectedLinePairHighlighting));
+}
+
 TEST(SemanticHighlighting, GetsCorrectTokens) {
   const char *TestCases[] = {
 R"cpp(
@@ -211,21 +253,82 @@
 return Pos;
   };
 
-  std::vector Tokens{
-  {HighlightingKind::Variable,
-Range{CreatePosition(3, 8), CreatePosition(3, 12)}},
-  {HighlightingKind::Function,
-Range{CreatePosition(3, 4), CreatePosition(3, 7)}},
-  {HighlightingKind::Variable,
-Range{CreatePosition(1, 1), CreatePosition(1, 5)}}};
+  std::vector Tokens{
+  {3,
+   {{HighlightingKind::Variable,
+ Range{CreatePosition(3, 8), CreatePosition(3, 12)}},
+{HighlightingKind::Function,
+ Range{CreatePosition(3, 4), CreatePosition(3, 7),
+  {1,
+   {{HighlightingKind::Variable,
+ Range{CreatePosition(1, 1), CreatePosition(1, 5)};
   std::vector ActualResults =
   toSemanticHighlightingInformation(Tokens);
   std::vector ExpectedResults = {
-  {1, "AQAEAAA="},
-  {3, "CAAEAAAEAAMAAQ=="}};
+  {3, "CAAEAAAEAAMAAQ=="}, {1, "AQAEAAA="}};
   EXPECT_EQ(ActualResults, ExpectedResults);
 }
 
+TEST(SemanticHighlighting, HighlightingDiffer) {
+  // The first entry is the old code. The second entry is the new code.
+  std::vector> TestCases{{
+  R"cpp(
+int A
+double B;
+struct C {};
+  )cpp",
+  R"cpp(
+int A;
+double B;
+struct C {};
+  )cpp"},
+{
+  R"cpp(
+struct Alpha {
+  double SomeVariable = 9483.301;
+};
+struct Beta {};
+int A = 121;
+Alpha Var;
+  )cpp",
+  R"cpp(
+struct Alpha {
+  double SomeVariable = 9483.301;
+};
+struct Beta   {}; // Some comment
+$Empty[

[PATCH] D33841: [clang-tidy] redundant 'extern' keyword check

2019-07-17 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/readability/RedundantExternCheck.cpp:38-40
+Message = "'extern' keyword has no effect";
+  } else {
+Message = "redundant 'extern' keyword";

These messages alone will be quite confusing unless the user has enough 
context. Please expand the messages with the explanations.



Comment at: clang-tidy/readability/RedundantExternCheck.cpp:48-50
+  StringRef Text =
+  Lexer::getSourceText(CharSourceRange::getTokenRange(BeginLoc, EndLoc),
+   *Result.SourceManager, getLangOpts());

I suspect there are many ways the `extern` substring can appear in a function 
definition (`void my_extern()`, `[[some_attribute("extern")]] void f()`, `void 
/*extern*/ f()`, etc.). I don't immediately see how these possible false 
positives are handled here. Am I missing something obvious?

Is it more robust to re-lex the range and search for the raw identifier token 
with the text `extern`?


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

https://reviews.llvm.org/D33841



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


[PATCH] D64860: [clangd] Get rid of dots and dotsdots within GlobalCompilationDatabase

2019-07-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64860

Files:
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp

Index: clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
===
--- clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -10,6 +10,7 @@
 
 #include "Path.h"
 #include "TestFS.h"
+#include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
@@ -31,6 +32,7 @@
 using ::testing::Contains;
 using ::testing::ElementsAre;
 using ::testing::EndsWith;
+using ::testing::HasSubstr;
 using ::testing::IsEmpty;
 using ::testing::Not;
 using ::testing::StartsWith;
@@ -247,9 +249,10 @@
 });
 
 File = FS.Root;
-llvm::sys::path::append(File, "a.cc");
+llvm::sys::path::append(File, "build", "..", "a.cc");
 DB.getCompileCommand(File.str());
-EXPECT_THAT(DiscoveredFiles, UnorderedElementsAre(EndsWith("a.cc")));
+EXPECT_THAT(DiscoveredFiles, UnorderedElementsAre(AllOf(
+ EndsWith("a.cc"), Not(HasSubstr("..");
 DiscoveredFiles.clear();
 
 File = FS.Root;
@@ -282,6 +285,28 @@
   }
 }
 
+TEST(GlobalCompilationDatabaseTest, NonCanonicalFilenames) {
+  OverlayCDB DB(nullptr);
+  std::vector DiscoveredFiles;
+  auto Sub =
+  DB.watch([&DiscoveredFiles](const std::vector Changes) {
+DiscoveredFiles = Changes;
+  });
+
+  llvm::SmallString<128> Root(testRoot());
+  llvm::sys::path::append(Root, "build", "..", "a.cc");
+  DB.setCompileCommand(Root.str(), tooling::CompileCommand());
+  EXPECT_THAT(DiscoveredFiles, UnorderedElementsAre(testPath("a.cc")));
+  DiscoveredFiles.clear();
+
+  llvm::SmallString<128> File(testRoot());
+  llvm::sys::path::append(File, "blabla", "..", "a.cc");
+
+  EXPECT_TRUE(DB.getCompileCommand(File));
+  EXPECT_TRUE(DB.getProjectInfo(File));
+  EXPECT_EQ(DB.getFallbackCommand(File).Directory, testRoot());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
===
--- clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -15,6 +15,7 @@
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include 
@@ -73,16 +74,20 @@
 
 tooling::CompileCommand
 GlobalCompilationDatabase::getFallbackCommand(PathRef File) const {
+  llvm::SmallString<128> CanonPath(File);
+  llvm::sys::path::remove_dots(CanonPath, true);
+
   std::vector Argv = {getFallbackClangPath()};
   // Clang treats .h files as C by default and files without extension as linker
   // input, resulting in unhelpful diagnostics.
   // Parsing as Objective C++ is friendly to more cases.
-  auto FileExtension = llvm::sys::path::extension(File);
+  auto FileExtension = llvm::sys::path::extension(CanonPath);
   if (FileExtension.empty() || FileExtension == ".h")
 Argv.push_back("-xobjective-c++-header");
-  Argv.push_back(File);
-  tooling::CompileCommand Cmd(llvm::sys::path::parent_path(File),
-  llvm::sys::path::filename(File), std::move(Argv),
+  Argv.push_back(CanonPath.str().str());
+  tooling::CompileCommand Cmd(llvm::sys::path::parent_path(CanonPath),
+  llvm::sys::path::filename(CanonPath),
+  std::move(Argv),
   /*Output=*/"");
   Cmd.Heuristic = "clangd fallback";
   return Cmd;
@@ -136,6 +141,8 @@
 CDBLookupRequest Request) const {
   assert(llvm::sys::path::is_absolute(Request.FileName) &&
  "path must be absolute");
+  llvm::SmallString<128> CanonPath(Request.FileName);
+  llvm::sys::path::remove_dots(CanonPath, true);
 
   CDBLookupResult Result;
   bool SentBroadcast = false;
@@ -148,7 +155,7 @@
   Result.PI.SourceRoot = *CompileCommandsDir;
 } else {
   actOnAllParentDirectories(
-  Request.FileName, [this, &SentBroadcast, &Result](PathRef Path) {
+  CanonPath, [this, &SentBroadcast, &Result](PathRef Path) {
 std::tie(Result.CDB, SentBroadcast) = getCDBInDirLocked(Path);
 Result.PI.SourceRoot = Path;
 return Result.CDB != nullptr;
@@ -203,13 +210,17 @@
   }
 
   std::vector GovernedFiles;
+  llvm::SmallString<128> CanonPath;
   for (llvm::StringRef File : AllFiles) {
 // A file

[PATCH] D64861: [clang-tidy] Adjust location of namespace comment diagnostic

2019-07-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: alexfh, hokein.
Herald added subscribers: kadircet, xazax.hun.
Herald added a project: clang.

If there is no comment, place it at the closing brace of a namespace
definition. Previously it was placed at the next character after the
closing brace.

The new position produces a better location for highlighting in clangd
and does not seem to make matters worse for clang-tidy.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64861

Files:
  clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
  clang-tools-extra/test/clang-tidy/google-readability-namespace-comments.cpp
  
clang-tools-extra/test/clang-tidy/google-readability-nested-namespace-comments.cpp
  clang-tools-extra/test/clang-tidy/select-checks.cpp


Index: clang-tools-extra/test/clang-tidy/select-checks.cpp
===
--- clang-tools-extra/test/clang-tidy/select-checks.cpp
+++ clang-tools-extra/test/clang-tidy/select-checks.cpp
@@ -5,7 +5,7 @@
 
 namespace i {
 }
-// CHECK: :[[@LINE-1]]:2: warning: namespace 'i' not terminated with a closing 
comment [llvm-namespace-comment]
+// CHECK: :[[@LINE-1]]:1: warning: namespace 'i' not terminated with a closing 
comment [llvm-namespace-comment]
 
 // Expect no warnings from the google-explicit-constructor check:
 class A { A(int i); };
Index: 
clang-tools-extra/test/clang-tidy/google-readability-nested-namespace-comments.cpp
===
--- 
clang-tools-extra/test/clang-tidy/google-readability-nested-namespace-comments.cpp
+++ 
clang-tools-extra/test/clang-tidy/google-readability-nested-namespace-comments.cpp
@@ -7,9 +7,9 @@
 void f();
 
 
-// CHECK-MESSAGES: :[[@LINE+4]]:2: warning: namespace 'n3' not terminated with
+// CHECK-MESSAGES: :[[@LINE+4]]:1: warning: namespace 'n3' not terminated with
 // CHECK-MESSAGES: :[[@LINE-7]]:11: note: namespace 'n3' starts here
-// CHECK-MESSAGES: :[[@LINE+2]]:3: warning: namespace 'n1::n2' not terminated 
with a closing comment [google-readability-namespace-comments]
+// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: namespace 'n1::n2' not terminated 
with a closing comment [google-readability-namespace-comments]
 // CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'n1::n2' starts here
 }}
 // CHECK-FIXES: }  // namespace n3
Index: 
clang-tools-extra/test/clang-tidy/google-readability-namespace-comments.cpp
===
--- clang-tools-extra/test/clang-tidy/google-readability-namespace-comments.cpp
+++ clang-tools-extra/test/clang-tidy/google-readability-namespace-comments.cpp
@@ -7,9 +7,9 @@
 void f(); // So that the namespace isn't empty.
 
 
-// CHECK-MESSAGES: :[[@LINE+4]]:2: warning: namespace 'n2' not terminated with 
a closing comment [google-readability-namespace-comments]
+// CHECK-MESSAGES: :[[@LINE+4]]:1: warning: namespace 'n2' not terminated with 
a closing comment [google-readability-namespace-comments]
 // CHECK-MESSAGES: :[[@LINE-7]]:11: note: namespace 'n2' starts here
-// CHECK-MESSAGES: :[[@LINE+2]]:3: warning: namespace 'n1' not terminated with
+// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: namespace 'n1' not terminated with
 // CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'n1' starts here
 }}
 // CHECK-FIXES: }  // namespace n2
@@ -25,7 +25,7 @@
 // 5
 // 6
 // 7
-// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: namespace 'macro_expansion' not 
terminated with
+// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: namespace 'macro_expansion' not 
terminated with
 // CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'macro_expansion' starts 
here
 }
 // CHECK-FIXES: }  // namespace macro_expansion
Index: clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
@@ -9,6 +9,7 @@
 #include "NamespaceCommentCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/StringExtras.h"
 
@@ -181,7 +182,13 @@
   ? "anonymous namespace"
   : ("namespace '" + NestedNamespaceName.str() + "'");
 
-  diag(AfterRBrace, Message)
+  // Place diagnostic at an old comment, or closing brace if we did not have 
it.
+  SourceLocation DiagLoc =
+  OldCommentRange.getBegin() != OldCommentRange.getEnd()
+  ? OldCommentRange.getBegin()
+  : ND->getRBraceLoc();
+
+  diag(DiagLoc, Message)
   << NamespaceName
   << FixItHint::CreateReplacement(
  CharSourceRange::getCharRange(OldCommentRange),


Index: clang-tools-extra/test/clang-tidy/select-checks.cpp
===
--- clang-tools-extra/test

[PATCH] D63279: [Analyzer] Unroll for-loops where the upper boundary is a variable with know value

2019-07-17 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added inline comments.



Comment at: lib/StaticAnalyzer/Core/LoopUnrolling.cpp:221-230
+  if (BoundNumVal.isUnknown()) {
+if (const auto *BoundDeclRefExpr = dyn_cast(BoundExpr)) {
+  // FIXME: Add other declarations such as Objective-C fields
+  if (const auto *BoundVarDecl =
+  dyn_cast(BoundDeclRefExpr->getDecl())) {
+BoundNumVal = State->getSVal(
+State->getLValue(BoundVarDecl, Pred->getLocationContext()));

Szelethus wrote:
> NoQ wrote:
> > Szelethus wrote:
> > > I don't see obvious test case for which `BoundNumVal` would be unknown, 
> > > am I wrong?
> > We need an `ExprInspection` method that reliably produces an `UnknownVal`, 
> > because there's no truly valid reason to produce `UnknownVal` apart from 
> > "something is unimplemented".
> For this too.
Wrong request! :-) The test case is there. Actually we need a test case for 
which 'BoundNumVal' is **not** unknown. That I still fail to produce.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63279



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


[PATCH] D64613: [clangd] Type hierarchy: don't resolve parents if the client only asked for children

2019-07-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64613



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


[PATCH] D64712: [clangd][NFC] Refactor background-index shard loading

2019-07-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 210303.
kadircet added a comment.

- As discussed offline, moved the "staleness" detection back to background index
- A renaming within Rebuilder, "LoadedTUs -> LoadedShards"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64712

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/index/BackgroundIndexLoader.cpp
  clang-tools-extra/clangd/index/BackgroundIndexLoader.h
  clang-tools-extra/clangd/index/BackgroundRebuild.cpp
  clang-tools-extra/clangd/index/BackgroundRebuild.h
  clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp

Index: clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
@@ -211,7 +211,7 @@
 OverlayCDB CDB(/*Base=*/nullptr);
 BackgroundIndex Idx(Context::empty(), FS, CDB,
 [&](llvm::StringRef) { return &MSS; });
-CDB.setCompileCommand(testPath("root"), Cmd);
+CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
 ASSERT_TRUE(Idx.blockUntilIdleForTest());
   }
   EXPECT_EQ(CacheHits, 2U); // Check both A.cc and A.h loaded from cache.
@@ -335,7 +335,7 @@
 OverlayCDB CDB(/*Base=*/nullptr);
 BackgroundIndex Idx(Context::empty(), FS, CDB,
 [&](llvm::StringRef) { return &MSS; });
-CDB.setCompileCommand(testPath("root"), Cmd);
+CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
 ASSERT_TRUE(Idx.blockUntilIdleForTest());
   }
   EXPECT_EQ(CacheHits, 2U); // Check both A.cc and A.h loaded from cache.
@@ -353,7 +353,7 @@
 OverlayCDB CDB(/*Base=*/nullptr);
 BackgroundIndex Idx(Context::empty(), FS, CDB,
 [&](llvm::StringRef) { return &MSS; });
-CDB.setCompileCommand(testPath("root"), Cmd);
+CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
 ASSERT_TRUE(Idx.blockUntilIdleForTest());
   }
   EXPECT_EQ(CacheHits, 2U); // Check both A.cc and A.h loaded from cache.
@@ -621,8 +621,8 @@
 
 TEST_F(BackgroundIndexRebuilderTest, LoadingShards) {
   Rebuilder.startLoading();
-  Rebuilder.loadedTU();
-  Rebuilder.loadedTU();
+  Rebuilder.loadedShard();
+  Rebuilder.loadedShard();
   EXPECT_TRUE(checkRebuild([&] { Rebuilder.doneLoading(); }));
 
   // No rebuild for no shards.
@@ -631,11 +631,11 @@
 
   // Loads can overlap.
   Rebuilder.startLoading();
-  Rebuilder.loadedTU();
+  Rebuilder.loadedShard();
   Rebuilder.startLoading();
-  Rebuilder.loadedTU();
+  Rebuilder.loadedShard();
   EXPECT_FALSE(checkRebuild([&] { Rebuilder.doneLoading(); }));
-  Rebuilder.loadedTU();
+  Rebuilder.loadedShard();
   EXPECT_TRUE(checkRebuild([&] { Rebuilder.doneLoading(); }));
 
   // No rebuilding for indexed files while loading.
Index: clang-tools-extra/clangd/index/BackgroundRebuild.h
===
--- clang-tools-extra/clangd/index/BackgroundRebuild.h
+++ clang-tools-extra/clangd/index/BackgroundRebuild.h
@@ -63,7 +63,7 @@
   // sessions may happen concurrently.
   void startLoading();
   // Called to indicate some shards were actually loaded from disk.
-  void loadedTU();
+  void loadedShard();
   // Called to indicate we're finished loading shards from disk.
   // May rebuild (if any were loaded).
   void doneLoading();
@@ -87,7 +87,7 @@
   unsigned IndexedTUsAtLastRebuild = 0;
   // Are we loading shards? May be multiple concurrent sessions.
   unsigned Loading = 0;
-  unsigned LoadedTUs; // In the current loading session.
+  unsigned LoadedShards; // In the current loading session.
 
   SwapIndex *Target;
   FileSymbols *Source;
Index: clang-tools-extra/clangd/index/BackgroundRebuild.cpp
===
--- clang-tools-extra/clangd/index/BackgroundRebuild.cpp
+++ clang-tools-extra/clangd/index/BackgroundRebuild.cpp
@@ -78,13 +78,13 @@
 void BackgroundIndexRebuilder::startLoading() {
   std::lock_guard Lock(Mu);
   if (!Loading)
-LoadedTUs = 0;
+LoadedShards = 0;
   ++Loading;
 }
-void BackgroundIndexRebuilder::loadedTU() {
+void BackgroundIndexRebuilder::loadedShard() {
   std::lock_guard Lock(Mu);
   assert(Loading);
-  ++LoadedTUs;
+  ++LoadedShards;
 }
 void BackgroundIndexRebuilder::doneLoading() {
   maybeRebuild("after loading index from disk", [this] {
@@ -93,7 +93,7 @@
 if (Loading)// was loading multiple batches concurrently
   return false; // rebuild once the last batch is done.
 // Rebuild if we loaded any shards, or if we stopped an indexedTU rebuild.
-return LoadedTUs > 0 || enoughTUsToRebuild();
+return LoadedShards > 0 || enoughTUsToRebuild();
   });
 }
 
Index: clang-tools-extra/clangd/index/Bac

[PATCH] D63279: [Analyzer] Unroll for-loops where the upper boundary is a variable with know value

2019-07-17 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 210302.
baloghadamsoftware added a comment.

Test case added for loop conditions written in reverse order and code fixed to 
make the test pass.


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

https://reviews.llvm.org/D63279

Files:
  lib/StaticAnalyzer/Core/LoopUnrolling.cpp
  test/Analysis/loop-unrolling.cpp

Index: test/Analysis/loop-unrolling.cpp
===
--- test/Analysis/loop-unrolling.cpp
+++ test/Analysis/loop-unrolling.cpp
@@ -7,7 +7,7 @@
 int getNum();
 void foo(int &);
 
-int simple_unroll1() {
+/*int simple_unroll1() {
   int a[9];
   int k = 42;
   for (int i = 0; i < 9; i++) {
@@ -498,4 +498,28 @@
   for (int i = 0; i < 6L; ++i) {
 clang_analyzer_numTimesReached(); // expected-warning {{6}}
   }
+}*/
+
+int unroll_known_value_of_variable1() {
+  int a[9];
+  int k = 42;
+  int n = 9;
+  for (int i = 0; i < n; i++) {
+clang_analyzer_numTimesReached(); // expected-warning {{9}}
+a[i] = 42;
+  }
+  int b = 22 / (k - 42); // expected-warning {{Division by zero}}
+  return 0;
+}
+
+int unroll_known_value_of_variable2() {
+  int a[9];
+  int k = 42;
+  int n = 9;
+  for (int i = 0; n > i; i++) {
+clang_analyzer_numTimesReached(); // expected-warning {{9}}
+a[i] = 42;
+  }
+  int b = 22 / (k - 42); // expected-warning {{Division by zero}}
+  return 0;
 }
Index: lib/StaticAnalyzer/Core/LoopUnrolling.cpp
===
--- lib/StaticAnalyzer/Core/LoopUnrolling.cpp
+++ lib/StaticAnalyzer/Core/LoopUnrolling.cpp
@@ -84,10 +84,9 @@
   hasOperatorName("<="), hasOperatorName(">="),
   hasOperatorName("!=")),
 hasEitherOperand(ignoringParenImpCasts(declRefExpr(
-to(varDecl(hasType(isInteger())).bind(BindName),
-hasEitherOperand(ignoringParenImpCasts(
-integerLiteral().bind("boundNum"
-  .bind("conditionOperator");
+   to(varDecl(allOf(hasType(isInteger()), equalsBoundNode(BindName)
+   .bind("boundVarOperand"
+.bind("conditionOperator");
 }
 
 static internal::Matcher
@@ -138,17 +137,16 @@
 
 static internal::Matcher forLoopMatcher() {
   return forStmt(
- hasCondition(simpleCondition("initVarName")),
  // Initialization should match the form: 'int i = 6' or 'i = 42'.
  hasLoopInit(
  anyOf(declStmt(hasSingleDecl(
-   varDecl(allOf(hasInitializer(ignoringParenImpCasts(
- integerLiteral().bind("initNum"))),
- equalsBoundNode("initVarName"),
-   binaryOperator(hasLHS(declRefExpr(to(varDecl(
-  equalsBoundNode("initVarName"),
+   varDecl(hasInitializer(ignoringParenImpCasts(
+  integerLiteral().bind("initNum".bind("initVarName"))),
+   binaryOperator(hasLHS(declRefExpr(to(varDecl()
+.bind("initVarName",
   hasRHS(ignoringParenImpCasts(
-  integerLiteral().bind("initNum")),
+ integerLiteral().bind("initNum")),
+ hasCondition(simpleCondition("initVarName")),
  // Incrementation should be a simple increment or decrement
  // operator call.
  hasIncrement(unaryOperator(
@@ -196,22 +194,43 @@
 
 bool shouldCompletelyUnroll(const Stmt *LoopStmt, ASTContext &ASTCtx,
 ExplodedNode *Pred, unsigned &maxStep) {
-
   if (!isLoopStmt(LoopStmt))
 return false;
 
-  // TODO: Match the cases where the bound is not a concrete literal but an
-  // integer with known value
   auto Matches = match(forLoopMatcher(), *LoopStmt, ASTCtx);
   if (Matches.empty())
 return false;
 
+  const auto State = Pred->getState();
+  auto &SVB = State->getStateManager().getSValBuilder();
+
   auto CounterVar = Matches[0].getNodeAs("initVarName");
-  llvm::APInt BoundNum =
-  Matches[0].getNodeAs("boundNum")->getValue();
   llvm::APInt InitNum =
   Matches[0].getNodeAs("initNum")->getValue();
   auto CondOp = Matches[0].getNodeAs("conditionOperator");
+
+  const Expr *BoundExpr = CondOp->getLHS()->IgnoreParenImpCasts();
+  if (BoundExpr == Matches[0].getNodeAs("boundVarOperand"))
+BoundExpr = CondOp->getRHS()->IgnoreParenImpCasts();
+  SVal BoundNumVal = Pred->getSVal(BoundExpr);
+
+  // If the value of the expression is unknown and it is a decl

[PATCH] D63279: [Analyzer] Unroll for-loops where the upper boundary is a variable with know value

2019-07-17 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

I am a bit afraid of the performance of the feature because of the extensive 
use of matchers. Based on my previous experiences matcher creation and 
disposition are expensive operations. Matchers are meant to be a kind of 
"static" structures created only once and destroyed at the end. Using them in 
the core infrastructure may negatively affect the execution time of the whole 
analysis. Maybe we should get rid of them before turning on this feature as 
default (which is the ultimate goal).


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

https://reviews.llvm.org/D63279



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


[clang-tools-extra] r366320 - [clangd] Handle windows line endings in QueryDriver

2019-07-17 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Wed Jul 17 06:14:02 2019
New Revision: 366320

URL: http://llvm.org/viewvc/llvm-project?rev=366320&view=rev
Log:
[clangd] Handle windows line endings in QueryDriver

Summary: fixes second case of https://github.com/clangd/clangd/issues/93

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp
clang-tools-extra/trunk/clangd/test/system-include-extractor.test

Modified: clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp?rev=366320&r1=366319&r2=366320&view=diff
==
--- clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp (original)
+++ clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp Wed Jul 17 06:14:02 
2019
@@ -63,7 +63,9 @@ std::vector parseDriverOutp
   llvm::SmallVector Lines;
   Output.split(Lines, '\n', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
 
-  auto StartIt = std::find(Lines.begin(), Lines.end(), SIS);
+  auto StartIt =
+  std::find_if(Lines.begin(), Lines.end(),
+   [](llvm::StringRef Line) { return Line.trim() == SIS; });
   if (StartIt == Lines.end()) {
 elog("System include extraction: start marker not found: {0}", Output);
 return {};

Modified: clang-tools-extra/trunk/clangd/test/system-include-extractor.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/test/system-include-extractor.test?rev=366320&r1=366319&r2=366320&view=diff
==
--- clang-tools-extra/trunk/clangd/test/system-include-extractor.test (original)
+++ clang-tools-extra/trunk/clangd/test/system-include-extractor.test Wed Jul 
17 06:14:02 2019
@@ -5,7 +5,7 @@
 # RUN: echo '#!/bin/bash' >> %t.dir/my_driver.sh
 # RUN: echo '[ "$0" = "%t.dir/my_driver.sh" ] || exit' >> %t.dir/my_driver.sh
 # RUN: echo 'echo line to ignore >&2' >> %t.dir/my_driver.sh
-# RUN: echo 'echo \#include \<...\> search starts here: >&2' >> 
%t.dir/my_driver.sh
+# RUN: echo 'echo -e "#include <...> search starts here:\r" >&2' >> 
%t.dir/my_driver.sh
 # RUN: echo 'echo %t.dir/my/dir/ >&2' >> %t.dir/my_driver.sh
 # RUN: echo 'echo %t.dir/my/dir2/ >&2' >> %t.dir/my_driver.sh
 # RUN: echo 'echo End of search list. >&2' >> %t.dir/my_driver.sh


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


[PATCH] D64789: [clangd] Handle windows line endings in QueryDriver

2019-07-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366320: [clangd] Handle windows line endings in QueryDriver 
(authored by kadircet, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64789?vs=210054&id=210304#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64789

Files:
  clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp
  clang-tools-extra/trunk/clangd/test/system-include-extractor.test


Index: clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp
===
--- clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp
+++ clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp
@@ -63,7 +63,9 @@
   llvm::SmallVector Lines;
   Output.split(Lines, '\n', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
 
-  auto StartIt = std::find(Lines.begin(), Lines.end(), SIS);
+  auto StartIt =
+  std::find_if(Lines.begin(), Lines.end(),
+   [](llvm::StringRef Line) { return Line.trim() == SIS; });
   if (StartIt == Lines.end()) {
 elog("System include extraction: start marker not found: {0}", Output);
 return {};
Index: clang-tools-extra/trunk/clangd/test/system-include-extractor.test
===
--- clang-tools-extra/trunk/clangd/test/system-include-extractor.test
+++ clang-tools-extra/trunk/clangd/test/system-include-extractor.test
@@ -5,7 +5,7 @@
 # RUN: echo '#!/bin/bash' >> %t.dir/my_driver.sh
 # RUN: echo '[ "$0" = "%t.dir/my_driver.sh" ] || exit' >> %t.dir/my_driver.sh
 # RUN: echo 'echo line to ignore >&2' >> %t.dir/my_driver.sh
-# RUN: echo 'echo \#include \<...\> search starts here: >&2' >> 
%t.dir/my_driver.sh
+# RUN: echo 'echo -e "#include <...> search starts here:\r" >&2' >> 
%t.dir/my_driver.sh
 # RUN: echo 'echo %t.dir/my/dir/ >&2' >> %t.dir/my_driver.sh
 # RUN: echo 'echo %t.dir/my/dir2/ >&2' >> %t.dir/my_driver.sh
 # RUN: echo 'echo End of search list. >&2' >> %t.dir/my_driver.sh


Index: clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp
===
--- clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp
+++ clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp
@@ -63,7 +63,9 @@
   llvm::SmallVector Lines;
   Output.split(Lines, '\n', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
 
-  auto StartIt = std::find(Lines.begin(), Lines.end(), SIS);
+  auto StartIt =
+  std::find_if(Lines.begin(), Lines.end(),
+   [](llvm::StringRef Line) { return Line.trim() == SIS; });
   if (StartIt == Lines.end()) {
 elog("System include extraction: start marker not found: {0}", Output);
 return {};
Index: clang-tools-extra/trunk/clangd/test/system-include-extractor.test
===
--- clang-tools-extra/trunk/clangd/test/system-include-extractor.test
+++ clang-tools-extra/trunk/clangd/test/system-include-extractor.test
@@ -5,7 +5,7 @@
 # RUN: echo '#!/bin/bash' >> %t.dir/my_driver.sh
 # RUN: echo '[ "$0" = "%t.dir/my_driver.sh" ] || exit' >> %t.dir/my_driver.sh
 # RUN: echo 'echo line to ignore >&2' >> %t.dir/my_driver.sh
-# RUN: echo 'echo \#include \<...\> search starts here: >&2' >> %t.dir/my_driver.sh
+# RUN: echo 'echo -e "#include <...> search starts here:\r" >&2' >> %t.dir/my_driver.sh
 # RUN: echo 'echo %t.dir/my/dir/ >&2' >> %t.dir/my_driver.sh
 # RUN: echo 'echo %t.dir/my/dir2/ >&2' >> %t.dir/my_driver.sh
 # RUN: echo 'echo End of search list. >&2' >> %t.dir/my_driver.sh
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r366321 - [clangd] Force the required interpretation of #import on windows tests.

2019-07-17 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Jul 17 06:21:25 2019
New Revision: 366321

URL: http://llvm.org/viewvc/llvm-project?rev=366321&view=rev
Log:
[clangd] Force the required interpretation of #import on windows tests.

Summary: NFC but should fix a bunch of tests.

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, llvm-commits

Tags: #llvm

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

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

Modified: clang-tools-extra/trunk/clangd/unittests/TestTU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/TestTU.cpp?rev=366321&r1=366320&r2=366321&view=diff
==
--- clang-tools-extra/trunk/clangd/unittests/TestTU.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/TestTU.cpp Wed Jul 17 06:21:25 2019
@@ -38,6 +38,10 @@ ParsedAST TestTU::build() const {
 Cmd.push_back("-include");
 Cmd.push_back(ImplicitHeaderGuard ? ImportThunk.c_str()
   : FullHeaderName.c_str());
+// ms-compatibility changes the meaning of #import.
+// The default is OS-dependent (on on windows), ensure it's off.
+if (ImplicitHeaderGuard)
+  Cmd.push_back("-fno-ms-compatibility");
   }
   Cmd.insert(Cmd.end(), ExtraArgs.begin(), ExtraArgs.end());
   // Put the file name at the end -- this allows the extra arg (-xc++) to


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


[PATCH] D64863: [clangd] Ignore diags from builtin files

2019-07-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay.
Herald added a project: clang.

This fixes a case where we show diagnostics on arbitrary lines, in an
internal codebase.

Open for ideas on unittesting this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64863

Files:
  clang-tools-extra/clangd/Diagnostics.cpp


Index: clang-tools-extra/clangd/Diagnostics.cpp
===
--- clang-tools-extra/clangd/Diagnostics.cpp
+++ clang-tools-extra/clangd/Diagnostics.cpp
@@ -469,6 +469,11 @@
   }
 
   bool InsideMainFile = isInsideMainFile(Info);
+  SourceManager &SM = Info.getSourceManager();
+  if (!InsideMainFile && SM.isWrittenInBuiltinFile(Info.getLocation())) {
+IgnoreDiagnostics::log(DiagLevel, Info);
+return;
+  }
 
   auto FillDiagBase = [&](DiagBase &D) {
 D.Range = diagnosticRange(Info, *LangOpts);
@@ -476,8 +481,7 @@
 Info.FormatDiagnostic(Message);
 D.Message = Message.str();
 D.InsideMainFile = InsideMainFile;
-D.File = Info.getSourceManager().getFilename(Info.getLocation());
-auto &SM = Info.getSourceManager();
+D.File = SM.getFilename(Info.getLocation());
 D.AbsFile = getCanonicalPath(
 SM.getFileEntryForID(SM.getFileID(Info.getLocation())), SM);
 D.Severity = DiagLevel;
@@ -500,10 +504,9 @@
   if (FixIt.RemoveRange.getBegin().isMacroID() ||
   FixIt.RemoveRange.getEnd().isMacroID())
 return false;
-  if (!isInsideMainFile(FixIt.RemoveRange.getBegin(),
-Info.getSourceManager()))
+  if (!isInsideMainFile(FixIt.RemoveRange.getBegin(), SM))
 return false;
-  Edits.push_back(toTextEdit(FixIt, Info.getSourceManager(), *LangOpts));
+  Edits.push_back(toTextEdit(FixIt, SM, *LangOpts));
 }
 
 llvm::SmallString<64> Message;
@@ -511,8 +514,8 @@
 if (SyntheticMessage && Info.getNumFixItHints() == 1) {
   const auto &FixIt = Info.getFixItHint(0);
   bool Invalid = false;
-  llvm::StringRef Remove = Lexer::getSourceText(
-  FixIt.RemoveRange, Info.getSourceManager(), *LangOpts, &Invalid);
+  llvm::StringRef Remove =
+  Lexer::getSourceText(FixIt.RemoveRange, SM, *LangOpts, &Invalid);
   llvm::StringRef Insert = FixIt.CodeToInsert;
   if (!Invalid) {
 llvm::raw_svector_ostream M(Message);


Index: clang-tools-extra/clangd/Diagnostics.cpp
===
--- clang-tools-extra/clangd/Diagnostics.cpp
+++ clang-tools-extra/clangd/Diagnostics.cpp
@@ -469,6 +469,11 @@
   }
 
   bool InsideMainFile = isInsideMainFile(Info);
+  SourceManager &SM = Info.getSourceManager();
+  if (!InsideMainFile && SM.isWrittenInBuiltinFile(Info.getLocation())) {
+IgnoreDiagnostics::log(DiagLevel, Info);
+return;
+  }
 
   auto FillDiagBase = [&](DiagBase &D) {
 D.Range = diagnosticRange(Info, *LangOpts);
@@ -476,8 +481,7 @@
 Info.FormatDiagnostic(Message);
 D.Message = Message.str();
 D.InsideMainFile = InsideMainFile;
-D.File = Info.getSourceManager().getFilename(Info.getLocation());
-auto &SM = Info.getSourceManager();
+D.File = SM.getFilename(Info.getLocation());
 D.AbsFile = getCanonicalPath(
 SM.getFileEntryForID(SM.getFileID(Info.getLocation())), SM);
 D.Severity = DiagLevel;
@@ -500,10 +504,9 @@
   if (FixIt.RemoveRange.getBegin().isMacroID() ||
   FixIt.RemoveRange.getEnd().isMacroID())
 return false;
-  if (!isInsideMainFile(FixIt.RemoveRange.getBegin(),
-Info.getSourceManager()))
+  if (!isInsideMainFile(FixIt.RemoveRange.getBegin(), SM))
 return false;
-  Edits.push_back(toTextEdit(FixIt, Info.getSourceManager(), *LangOpts));
+  Edits.push_back(toTextEdit(FixIt, SM, *LangOpts));
 }
 
 llvm::SmallString<64> Message;
@@ -511,8 +514,8 @@
 if (SyntheticMessage && Info.getNumFixItHints() == 1) {
   const auto &FixIt = Info.getFixItHint(0);
   bool Invalid = false;
-  llvm::StringRef Remove = Lexer::getSourceText(
-  FixIt.RemoveRange, Info.getSourceManager(), *LangOpts, &Invalid);
+  llvm::StringRef Remove =
+  Lexer::getSourceText(FixIt.RemoveRange, SM, *LangOpts, &Invalid);
   llvm::StringRef Insert = FixIt.CodeToInsert;
   if (!Invalid) {
 llvm::raw_svector_ostream M(Message);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r366322 - [AArch64] Add support for Transactional Memory Extension (TME)

2019-07-17 Thread Momchil Velikov via cfe-commits
Author: chill
Date: Wed Jul 17 06:23:27 2019
New Revision: 366322

URL: http://llvm.org/viewvc/llvm-project?rev=366322&view=rev
Log:
[AArch64] Add support for Transactional Memory Extension (TME)

TME is a future architecture technology, documented in

https://developer.arm.com/architectures/cpu-architecture/a-profile/exploration-tools
https://developer.arm.com/docs/ddi0601/a

More about the future architectures:

https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/new-technologies-for-the-arm-a-profile-architecture

This patch adds support for the TME instructions TSTART, TTEST, TCOMMIT, and
TCANCEL and the target feature/arch extension "tme".

It also implements TME builtin functions, defined in ACLE Q2 2019
(https://developer.arm.com/docs/101028/latest)

Patch by Javed Absar and Momchil Velikov

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

Added:
cfe/trunk/test/CodeGen/aarch64-tme-tcancel-arg.cpp
cfe/trunk/test/CodeGen/aarch64-tme.c
cfe/trunk/test/Sema/aarch64-tme-errors.c
cfe/trunk/test/Sema/aarch64-tme-tcancel-const-error.c
cfe/trunk/test/Sema/aarch64-tme-tcancel-range-error.c
Modified:
cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
cfe/trunk/lib/Basic/Targets/AArch64.cpp
cfe/trunk/lib/Basic/Targets/AArch64.h
cfe/trunk/lib/Headers/arm_acle.h
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAArch64.def?rev=366322&r1=366321&r2=366322&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAArch64.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAArch64.def Wed Jul 17 06:23:27 2019
@@ -91,6 +91,12 @@ LANGBUILTIN(__sevl,  "v", "",   ALL_MS_L
 // Misc
 BUILTIN(__builtin_sponentry, "v*", "c")
 
+// Transactional Memory Extension
+BUILTIN(__builtin_arm_tstart, "WUi", "nj")
+BUILTIN(__builtin_arm_tcommit, "v", "n")
+BUILTIN(__builtin_arm_tcancel, "vWUIi", "nr")
+BUILTIN(__builtin_arm_ttest, "WUi", "nc")
+
 TARGET_HEADER_BUILTIN(_BitScanForward, "UcUNi*UNi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_BitScanReverse, "UcUNi*UNi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_BitScanForward64, "UcUNi*ULLi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")

Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.cpp?rev=366322&r1=366321&r2=366322&view=diff
==
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp Wed Jul 17 06:23:27 2019
@@ -219,6 +219,9 @@ void AArch64TargetInfo::getTargetDefines
   if (HasMTE)
 Builder.defineMacro("__ARM_FEATURE_MEMORY_TAGGING", "1");
 
+  if (HasTME)
+Builder.defineMacro("__ARM_FEATURE_TME", "1");
+
   if ((FPU & NeonMode) && HasFP16FML)
 Builder.defineMacro("__ARM_FEATURE_FP16FML", "1");
 
@@ -270,6 +273,7 @@ bool AArch64TargetInfo::handleTargetFeat
   HasDotProd = false;
   HasFP16FML = false;
   HasMTE = false;
+  HasTME = false;
   ArchKind = llvm::AArch64::ArchKind::ARMV8A;
 
   for (const auto &Feature : Features) {
@@ -301,6 +305,8 @@ bool AArch64TargetInfo::handleTargetFeat
   HasFP16FML = true;
 if (Feature == "+mte")
   HasMTE = true;
+if (Feature == "+tme")
+  HasTME = true;
   }
 
   setDataLayout();

Modified: cfe/trunk/lib/Basic/Targets/AArch64.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.h?rev=366322&r1=366321&r2=366322&view=diff
==
--- cfe/trunk/lib/Basic/Targets/AArch64.h (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.h Wed Jul 17 06:23:27 2019
@@ -35,6 +35,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64Tar
   bool HasDotProd;
   bool HasFP16FML;
   bool HasMTE;
+  bool HasTME;
 
   llvm::AArch64::ArchKind ArchKind;
 

Modified: cfe/trunk/lib/Headers/arm_acle.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/arm_acle.h?rev=366322&r1=366321&r2=366322&view=diff
==
--- cfe/trunk/lib/Headers/arm_acle.h (original)
+++ cfe/trunk/lib/Headers/arm_acle.h Wed Jul 17 06:23:27 2019
@@ -613,7 +613,7 @@ __jcvt(double __a) {
 #define __arm_wsr64(sysreg, v) __builtin_arm_wsr64(sysreg, v)
 #define __arm_wsrp(sysreg, v) __builtin_arm_wsrp(sysreg, v)
 
-// Memory Tagging Extensions (MTE) Intrinsics
+/* Memory Tagging Extensions (MTE) Intrinsics */
 #if __ARM_FEATURE_MEMORY_TAGGING
 #define __arm_mte_create_random_tag(__ptr, __mask)  __builtin_arm_irg(__ptr, 
__mask)
 #define __arm_mte_increment_tag(__ptr, __tag_offset)  
__builtin_arm_addg(__ptr, __tag_offset)
@@ -623,6 +623,28 @@ __jcvt(double __a) {
 #define __arm_mte_ptrdiff(__ptra,

[PATCH] D64416: [AArch64] Add support for Transactional Memory Extension (TME)

2019-07-17 Thread Momchil Velikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366322: [AArch64] Add support for Transactional Memory 
Extension (TME) (authored by chill, committed by ).
Herald added a subscriber: kristina.

Changed prior to commit:
  https://reviews.llvm.org/D64416?vs=209188&id=210310#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64416

Files:
  cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
  cfe/trunk/lib/Basic/Targets/AArch64.cpp
  cfe/trunk/lib/Basic/Targets/AArch64.h
  cfe/trunk/lib/Headers/arm_acle.h
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/CodeGen/aarch64-tme-tcancel-arg.cpp
  cfe/trunk/test/CodeGen/aarch64-tme.c
  cfe/trunk/test/Sema/aarch64-tme-errors.c
  cfe/trunk/test/Sema/aarch64-tme-tcancel-const-error.c
  cfe/trunk/test/Sema/aarch64-tme-tcancel-range-error.c
  llvm/trunk/include/llvm/IR/IntrinsicsAArch64.td
  llvm/trunk/include/llvm/Support/AArch64TargetParser.def
  llvm/trunk/include/llvm/Support/AArch64TargetParser.h
  llvm/trunk/lib/Target/AArch64/AArch64.td
  llvm/trunk/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/trunk/lib/Target/AArch64/AArch64Subtarget.h
  llvm/trunk/test/CodeGen/AArch64/tme-tcancel.ll
  llvm/trunk/test/CodeGen/AArch64/tme-tcommit.ll
  llvm/trunk/test/CodeGen/AArch64/tme-tstart.ll
  llvm/trunk/test/CodeGen/AArch64/tme-ttest.ll
  llvm/trunk/test/MC/AArch64/tme-error.s
  llvm/trunk/test/MC/AArch64/tme.s
  llvm/trunk/test/MC/Disassembler/AArch64/tme.txt
  llvm/trunk/unittests/Support/TargetParserTest.cpp

Index: llvm/trunk/include/llvm/Support/AArch64TargetParser.def
===
--- llvm/trunk/include/llvm/Support/AArch64TargetParser.def
+++ llvm/trunk/include/llvm/Support/AArch64TargetParser.def
@@ -79,6 +79,7 @@
 AARCH64_ARCH_EXT_NAME("ssbs",  AArch64::AEK_SSBS, "+ssbs",  "-ssbs")
 AARCH64_ARCH_EXT_NAME("sb",AArch64::AEK_SB,   "+sb","-sb")
 AARCH64_ARCH_EXT_NAME("predres",   AArch64::AEK_PREDRES,  "+predres", "-predres")
+AARCH64_ARCH_EXT_NAME("tme",   AArch64::AEK_TME,  "+tme",   "-tme")
 #undef AARCH64_ARCH_EXT_NAME
 
 #ifndef AARCH64_CPU_NAME
Index: llvm/trunk/include/llvm/Support/AArch64TargetParser.h
===
--- llvm/trunk/include/llvm/Support/AArch64TargetParser.h
+++ llvm/trunk/include/llvm/Support/AArch64TargetParser.h
@@ -54,6 +54,7 @@
   AEK_SVE2SM4 = 1 << 25,
   AEK_SVE2SHA3 =1 << 26,
   AEK_BITPERM = 1 << 27,
+  AEK_TME = 1 << 28,
 };
 
 enum class ArchKind {
Index: llvm/trunk/include/llvm/IR/IntrinsicsAArch64.td
===
--- llvm/trunk/include/llvm/IR/IntrinsicsAArch64.td
+++ llvm/trunk/include/llvm/IR/IntrinsicsAArch64.td
@@ -703,3 +703,20 @@
 def int_aarch64_subp :  Intrinsic<[llvm_i64_ty], [llvm_ptr_ty, llvm_ptr_ty],
 [IntrNoMem]>;
 }
+
+// Transactional Memory Extension (TME) Intrinsics
+let TargetPrefix = "aarch64" in {
+def int_aarch64_tstart  : GCCBuiltin<"__builtin_arm_tstart">,
+ Intrinsic<[llvm_i64_ty]>;
+
+def int_aarch64_tcommit : GCCBuiltin<"__builtin_arm_tcommit">, Intrinsic<[]>;
+
+def int_aarch64_tcancel : GCCBuiltin<"__builtin_arm_tcancel">,
+  Intrinsic<[], [llvm_i64_ty],
+[ImmArg<0>, IntrNoMem, IntrHasSideEffects,
+ IntrNoReturn]>;
+
+def int_aarch64_ttest   : GCCBuiltin<"__builtin_arm_ttest">,
+  Intrinsic<[llvm_i64_ty], [],
+[IntrNoMem, IntrHasSideEffects]>;
+}
Index: llvm/trunk/test/MC/AArch64/tme.s
===
--- llvm/trunk/test/MC/AArch64/tme.s
+++ llvm/trunk/test/MC/AArch64/tme.s
@@ -0,0 +1,24 @@
+// Tests for transaction memory extension instructions
+//
+// RUN: llvm-mc -triple aarch64 -show-encoding -mattr=+tme   < %s  | FileCheck %s
+// RUN: not llvm-mc -triple aarch64 -show-encoding -mattr=-tme   < %s 2>&1 | FileCheck %s --check-prefix=NOTME
+
+tstart x3
+ttest  x4
+tcommit
+tcancel #0x1234
+
+// CHECK: tstart x3 // encoding: [0x63,0x30,0x23,0xd5]
+// CHECK: ttest x4  // encoding: [0x64,0x31,0x23,0xd5]
+// CHECK: tcommit   // encoding: [0x7f,0x30,0x03,0xd5]
+// CHECK: tcancel #0x1234   // encoding: [0x80,0x46,0x62,0xd4]
+
+
+// NOTME: instruction requires: tme
+// NOTME-NEXT: tstart x3
+// NOTME: instruction requires: tme
+// NOTME-NEXT: ttest  x4
+// NOTME: instruction requires: tme
+// NOTME-NEXT: tcommit
+// NOTME: instruction requires: tme
+// NOTME-NEXT: tcancel #0x1234
Index: llvm/trunk/test/MC/AArch64/tme-error.s
===
--- llvm/trunk/test/MC/AArch64/tme-error.s
+++ llvm/trunk/test/MC/AArch64/tm

[PATCH] D64744: #pragma clang loop predicate(enable|disable)

2019-07-17 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer updated this revision to Diff 210314.
SjoerdMeijer retitled this revision from "Loop #pragma tail_predicate" to " 
#pragma clang loop predicate(enable|disable)".
SjoerdMeijer edited the summary of this revision.
Herald added a subscriber: zzheng.

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

https://reviews.llvm.org/D64744

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/CodeGen/CGLoopInfo.cpp
  clang/lib/CodeGen/CGLoopInfo.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/AST/ast-print-pragmas.cpp
  clang/test/CodeGenCXX/pragma-loop.cpp
  clang/test/Parser/pragma-loop.cpp
  clang/test/Parser/pragma-unroll-and-jam.cpp

Index: clang/test/Parser/pragma-unroll-and-jam.cpp
===
--- clang/test/Parser/pragma-unroll-and-jam.cpp
+++ clang/test/Parser/pragma-unroll-and-jam.cpp
@@ -67,7 +67,7 @@
   }
 
 // pragma clang unroll_and_jam is disabled for the moment
-/* expected-error {{invalid option 'unroll_and_jam'; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, or distribute}} */ #pragma clang loop unroll_and_jam(4)
+/* expected-error {{invalid option 'unroll_and_jam'; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, predicate, or distribute}} */ #pragma clang loop unroll_and_jam(4)
   for (int i = 0; i < Length; i++) {
 for (int j = 0; j < Length; j++) {
   List[i * Length + j] = Value;
Index: clang/test/Parser/pragma-loop.cpp
===
--- clang/test/Parser/pragma-loop.cpp
+++ clang/test/Parser/pragma-loop.cpp
@@ -81,6 +81,7 @@
 
 #pragma clang loop vectorize(enable)
 #pragma clang loop interleave(enable)
+#pragma clang loop predicate(enable)
 #pragma clang loop unroll(full)
   while (i + 1 < Length) {
 List[i] = i;
@@ -95,6 +96,7 @@
 
 #pragma clang loop vectorize(disable)
 #pragma clang loop interleave(disable)
+#pragma clang loop predicate(disable)
 #pragma clang loop unroll(disable)
   while (i - 1 < Length) {
 List[i] = i;
@@ -111,7 +113,7 @@
   }
 
   int VList[Length];
-#pragma clang loop vectorize(disable) interleave(disable) unroll(disable)
+#pragma clang loop vectorize(disable) interleave(disable) unroll(disable) predicate(disable)
   for (int j : VList) {
 VList[j] = List[j];
   }
@@ -130,11 +132,13 @@
 
 /* expected-error {{expected '('}} */ #pragma clang loop vectorize
 /* expected-error {{expected '('}} */ #pragma clang loop interleave
+/* expected-error {{expected '('}} */ #pragma clang loop predicate
 /* expected-error {{expected '('}} */ #pragma clang loop unroll
 /* expected-error {{expected '('}} */ #pragma clang loop distribute
 
 /* expected-error {{expected ')'}} */ #pragma clang loop vectorize(enable
 /* expected-error {{expected ')'}} */ #pragma clang loop interleave(enable
+/* expected-error {{expected ')'}} */ #pragma clang loop predicate(enable
 /* expected-error {{expected ')'}} */ #pragma clang loop unroll(full
 /* expected-error {{expected ')'}} */ #pragma clang loop distribute(enable
 
@@ -147,7 +151,7 @@
 /* expected-error {{missing argument; expected 'enable', 'full' or 'disable'}} */ #pragma clang loop unroll()
 /* expected-error {{missing argument; expected 'enable' or 'disable'}} */ #pragma clang loop distribute()
 
-/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, or distribute}} */ #pragma clang loop
+/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, predicate, or distribute}} */ #pragma clang loop
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword(enable)
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop vectorize(enable) badkeyword(4)
@@ -245,6 +249,8 @@
 /* expected-error {{duplicate directives 'vectorize(enable)' and 'vectorize(disable)'}} */ #pragma clang loop vectorize(disable)
 #pragma clang loop interleave(enable)
 /* expected-error {{duplicate directives 'interleave(enable)' and 'interleave(disable)'}} */ #pragma clang loop interleave(disable)
+#pragma clang loop predicate(enable)
+/* expected-error {{duplicate directives 'predicate(enable)' and 'predicate(disable)'}} */ #pragma clang loop predicate(disable)
 #pragma clang loop unroll(full)
 /* expected-error {{duplicate directives 'unroll(full)' and 'unroll(disable)'}} */ #pragma clang loop unroll(disable)
 #pragma clang loop distribute(enable)
@@ -281,3 +287,7 @@
 
 #pragma clang loop interleave(enable)
 /* expected-error {{expected 

[PATCH] D64867: [OpenCL] Update comments/diagnostics to refer to C++ for OpenCL mode

2019-07-17 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: neil.hickey, svenvh.
Herald added subscribers: ebevhan, yaxunl.

https://reviews.llvm.org/D64867

Files:
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/LangOptions.def
  include/clang/Basic/TokenKinds.def
  include/clang/Frontend/LangStandards.def
  lib/Frontend/InitPreprocessor.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExprCXX.cpp
  test/Driver/unknown-std.cl
  test/Parser/opencl-cxx-keywords.cl
  test/Parser/opencl-cxx-virtual.cl
  test/SemaOpenCLCXX/newdelete.cl
  test/SemaOpenCLCXX/restricted.cl

Index: test/SemaOpenCLCXX/restricted.cl
===
--- test/SemaOpenCLCXX/restricted.cl
+++ test/SemaOpenCLCXX/restricted.cl
@@ -1,9 +1,9 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify -fsyntax-only
 
 // This test checks that various C/C++/OpenCL C constructs are not available in
-// OpenCL C++, according to OpenCL C++ 1.0 Specification Section 2.9.
+// C++ for OpenCL.
 
-// Test that typeid is not available in OpenCL C++.
+// Test that typeid is not available.
 namespace std {
   // Provide a dummy std::type_info so that we can use typeid.
   class type_info {
@@ -11,9 +11,9 @@
   };
 }
 __constant std::type_info int_ti = typeid(int);
-// expected-error@-1 {{'typeid' is not supported in OpenCL C++}}
+// expected-error@-1 {{'typeid' is not supported in C++ for OpenCL}}
 
-// Test that dynamic_cast is not available in OpenCL C++.
+// Test that dynamic_cast is not available in C++ for OpenCL.
 class A {
 public:
   int a;
@@ -25,17 +25,17 @@
 
 B *test_dynamic_cast(B *p) {
   return dynamic_cast(p);
-  // expected-error@-1 {{'dynamic_cast' is not supported in OpenCL C++}}
+  // expected-error@-1 {{'dynamic_cast' is not supported in C++ for OpenCL}}
 }
 
 // Test storage class qualifiers.
 __constant _Thread_local int a = 1;
-// expected-error@-1 {{OpenCL C++ version 1.0 does not support the '_Thread_local' storage class specifier}}
+// expected-error@-1 {{C++ for OpenCL version 1.0 does not support the '_Thread_local' storage class specifier}}
 __constant __thread int b = 2;
-// expected-error@-1 {{OpenCL C++ version 1.0 does not support the '__thread' storage class specifier}}
+// expected-error@-1 {{C++ for OpenCL version 1.0 does not support the '__thread' storage class specifier}}
 kernel void test_storage_classes() {
   register int x;
-  // expected-error@-1 {{OpenCL C++ version 1.0 does not support the 'register' storage class specifier}}
+  // expected-error@-1 {{C++ for OpenCL version 1.0 does not support the 'register' storage class specifier}}
   thread_local int y;
-  // expected-error@-1 {{OpenCL C++ version 1.0 does not support the 'thread_local' storage class specifier}}
+  // expected-error@-1 {{C++ for OpenCL version 1.0 does not support the 'thread_local' storage class specifier}}
 }
Index: test/SemaOpenCLCXX/newdelete.cl
===
--- test/SemaOpenCLCXX/newdelete.cl
+++ test/SemaOpenCLCXX/newdelete.cl
@@ -19,8 +19,8 @@
 // There are no global user-defined new operators at this point. Test that clang
 // rejects these gracefully.
 void test_default_new_delete(void *buffer, A **pa) {
-  A *a = new A; // expected-error {{'default new' is not supported in OpenCL C++}}
-  delete a; // expected-error {{'default delete' is not supported in OpenCL C++}}
+  A *a = new A; // expected-error {{'default new' is not supported in C++ for OpenCL}}
+  delete a; // expected-error {{'default delete' is not supported in C++ for OpenCL}}
   *pa = new (buffer) A; // expected-error {{use of placement new requires explicit declaration}}
 }
 
@@ -36,10 +36,10 @@
 
 void test_new_delete(void *buffer, A **a, B **b) {
   *a = new A; // expected-error {{no matching function for call to 'operator new'}}
-  delete a;   // expected-error {{'default delete' is not supported in OpenCL C++}}
+  delete a;   // expected-error {{'default delete' is not supported in C++ for OpenCL}}
 
   *a = new A[20]; // expected-error {{no matching function for call to 'operator new[]'}}
-  delete[] *a;// expected-error {{'default delete' is not supported in OpenCL C++}}
+  delete[] *a;// expected-error {{'default delete' is not supported in C++ for OpenCL}}
 
   // User-defined placement new is supported.
   *a = new (buffer) A;
Index: test/Parser/opencl-cxx-virtual.cl
===
--- test/Parser/opencl-cxx-virtual.cl
+++ test/Parser/opencl-cxx-virtual.cl
@@ -3,17 +3,17 @@
 // Test that virtual functions and abstract classes are rejected.
 class virtual_functions {
   virtual void bad1() {}
-  //expected-error@-1 {{virtual functions are not supported in OpenCL C++}}

[PATCH] D64744: #pragma clang loop predicate(enable|disable)

2019-07-17 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

So I went for:

  predicate(enable)

as I think that is most general, best capturing it, but I am of course 
completely open to bikeshedding names :-)


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

https://reviews.llvm.org/D64744



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


r366325 - [ASTImporter] Fix LLDB lookup in transparent ctx and with ext src

2019-07-17 Thread Gabor Marton via cfe-commits
Author: martong
Date: Wed Jul 17 06:47:46 2019
New Revision: 366325

URL: http://llvm.org/viewvc/llvm-project?rev=366325&view=rev
Log:
[ASTImporter] Fix LLDB lookup in transparent ctx and with ext src

Summary:
With LLDB we use localUncachedLookup(), however, that fails to find
Decls when a transparent context is involved and the given DC has
external lexical storage.  The solution is to use noload_lookup, which
works well with transparent contexts.  But, we cannot use only the
noload_lookup since the slow case of localUncachedLookup is still needed
in some other cases.

These other cases are handled in ASTImporterLookupTable, but we cannot
use that with LLDB since that traverses through the AST which initiates
the load of external decls again via DC::decls().

We must avoid loading external decls during the import becuase
ExternalASTSource is implemented with ASTImporter, so external loads
during import results in uncontrolled and faulty import.

Reviewers: shafik, teemperor, jingham, clayborg, a_sidorin, a.sidorin

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

Tags: #clang, #lldb

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

Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=366325&r1=366324&r2=366325&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Wed Jul 17 06:47:46 2019
@@ -1707,6 +1707,17 @@ static Error setTypedefNameForAnonDecl(T
 
 Error ASTNodeImporter::ImportDefinition(
 RecordDecl *From, RecordDecl *To, ImportDefinitionKind Kind) {
+  auto DefinitionCompleter = [To]() {
+// There are cases in LLDB when we first import a class without its
+// members. The class will have DefinitionData, but no members. Then,
+// importDefinition is called from LLDB, which tries to get the members, so
+// when we get here, the class already has the DefinitionData set, so we
+// must unset the CompleteDefinition here to be able to complete again the
+// definition.
+To->setCompleteDefinition(false);
+To->completeDefinition();
+  };
+
   if (To->getDefinition() || To->isBeingDefined()) {
 if (Kind == IDK_Everything ||
 // In case of lambdas, the class already has a definition ptr set, but
@@ -1717,7 +1728,7 @@ Error ASTNodeImporter::ImportDefinition(
   Error Result = ImportDeclContext(From, /*ForceImport=*/true);
   // Finish the definition of the lambda, set isBeingDefined to false.
   if (To->isLambda())
-To->completeDefinition();
+DefinitionCompleter();
   return Result;
 }
 
@@ -1728,8 +1739,8 @@ Error ASTNodeImporter::ImportDefinition(
   // Complete the definition even if error is returned.
   // The RecordDecl may be already part of the AST so it is better to
   // have it in complete state even if something is wrong with it.
-  auto DefinitionCompleter =
-  llvm::make_scope_exit([To]() { To->completeDefinition(); });
+  auto DefinitionCompleterScopeExit =
+  llvm::make_scope_exit(DefinitionCompleter);
 
   if (Error Err = setTypedefNameForAnonDecl(From, To, Importer))
 return Err;
@@ -7757,10 +7768,20 @@ ASTImporter::findDeclsInToCtx(DeclContex
 SharedState->getLookupTable()->lookup(ReDC, Name);
 return FoundDeclsTy(LookupResult.begin(), LookupResult.end());
   } else {
-// FIXME Can we remove this kind of lookup?
-// Or lldb really needs this C/C++ lookup?
-FoundDeclsTy Result;
-ReDC->localUncachedLookup(Name, Result);
+DeclContext::lookup_result NoloadLookupResult = ReDC->noload_lookup(Name);
+FoundDeclsTy Result(NoloadLookupResult.begin(), NoloadLookupResult.end());
+// We must search by the slow case of localUncachedLookup because that is
+// working even if there is no LookupPtr for the DC. We could use
+// DC::buildLookup() to create the LookupPtr, but that would load external
+// decls again, we must avoid that case.
+// Also, even if we had the LookupPtr, we must find Decls which are not
+// in the LookupPtr, so we need the slow case.
+// These cases are handled in ASTImporterLookupTable, but we cannot use
+// that with LLDB since that traverses through the AST which initiates the
+// load of external decls again via DC::decls().  And again, we must avoid
+// loading external decls during the import.
+if (Result.empty())
+  ReDC->localUncachedLookup(Name, Result);
 return Result;
   }
 }

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=366325&r1=366324&r2=366325&view=diff
==
--- cfe/trunk/unittests/AST/ASTImporte

[PATCH] D61333: [ASTImporter] Fix LLDB lookup in transparent ctx and with ext src

2019-07-17 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366325: [ASTImporter] Fix LLDB lookup in transparent ctx and 
with ext src (authored by martong, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61333?vs=210281&id=210318#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61333

Files:
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/unittests/AST/ASTImporterTest.cpp
  lldb/trunk/packages/Python/lldbsuite/test/lang/c/modules/TestCModules.py
  lldb/trunk/packages/Python/lldbsuite/test/lang/c/modules/main.c
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp

Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -1707,6 +1707,17 @@
 
 Error ASTNodeImporter::ImportDefinition(
 RecordDecl *From, RecordDecl *To, ImportDefinitionKind Kind) {
+  auto DefinitionCompleter = [To]() {
+// There are cases in LLDB when we first import a class without its
+// members. The class will have DefinitionData, but no members. Then,
+// importDefinition is called from LLDB, which tries to get the members, so
+// when we get here, the class already has the DefinitionData set, so we
+// must unset the CompleteDefinition here to be able to complete again the
+// definition.
+To->setCompleteDefinition(false);
+To->completeDefinition();
+  };
+
   if (To->getDefinition() || To->isBeingDefined()) {
 if (Kind == IDK_Everything ||
 // In case of lambdas, the class already has a definition ptr set, but
@@ -1717,7 +1728,7 @@
   Error Result = ImportDeclContext(From, /*ForceImport=*/true);
   // Finish the definition of the lambda, set isBeingDefined to false.
   if (To->isLambda())
-To->completeDefinition();
+DefinitionCompleter();
   return Result;
 }
 
@@ -1728,8 +1739,8 @@
   // Complete the definition even if error is returned.
   // The RecordDecl may be already part of the AST so it is better to
   // have it in complete state even if something is wrong with it.
-  auto DefinitionCompleter =
-  llvm::make_scope_exit([To]() { To->completeDefinition(); });
+  auto DefinitionCompleterScopeExit =
+  llvm::make_scope_exit(DefinitionCompleter);
 
   if (Error Err = setTypedefNameForAnonDecl(From, To, Importer))
 return Err;
@@ -7757,10 +7768,20 @@
 SharedState->getLookupTable()->lookup(ReDC, Name);
 return FoundDeclsTy(LookupResult.begin(), LookupResult.end());
   } else {
-// FIXME Can we remove this kind of lookup?
-// Or lldb really needs this C/C++ lookup?
-FoundDeclsTy Result;
-ReDC->localUncachedLookup(Name, Result);
+DeclContext::lookup_result NoloadLookupResult = ReDC->noload_lookup(Name);
+FoundDeclsTy Result(NoloadLookupResult.begin(), NoloadLookupResult.end());
+// We must search by the slow case of localUncachedLookup because that is
+// working even if there is no LookupPtr for the DC. We could use
+// DC::buildLookup() to create the LookupPtr, but that would load external
+// decls again, we must avoid that case.
+// Also, even if we had the LookupPtr, we must find Decls which are not
+// in the LookupPtr, so we need the slow case.
+// These cases are handled in ASTImporterLookupTable, but we cannot use
+// that with LLDB since that traverses through the AST which initiates the
+// load of external decls again via DC::decls().  And again, we must avoid
+// loading external decls during the import.
+if (Result.empty())
+  ReDC->localUncachedLookup(Name, Result);
 return Result;
   }
 }
Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -5122,6 +5122,51 @@
   EXPECT_EQ(ToLSize, FromLSize);
 }
 
+struct LLDBLookupTest : ASTImporterOptionSpecificTestBase {
+  LLDBLookupTest() {
+Creator = [](ASTContext &ToContext, FileManager &ToFileManager,
+ ASTContext &FromContext, FileManager &FromFileManager,
+ bool MinimalImport,
+ const std::shared_ptr &SharedState) {
+  return new ASTImporter(ToContext, ToFileManager, FromContext,
+ FromFileManager, MinimalImport,
+ // We use the regular lookup.
+ /*SharedState=*/nullptr);
+};
+  }
+};
+
+TEST_P(LLDBLookupTest, ImporterShouldFindInTransparentContext) {
+  TranslationUnitDecl *ToTU = getToTuDecl(
+  R"(
+  extern "C" {
+class X{};
+  };
+  )",
+  Lang_CXX);
+  auto *ToX = FirstDeclMatcher().match(
+  ToTU, cxxRecordDecl(ha

[PATCH] D64671: [clang-tidy] New check: misc-init-local-variables

2019-07-17 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tools-extra/clang-tidy/misc/InitLocalVariablesCheck.cpp:21
+  Finder->addMatcher(
+  varDecl(unless(hasInitializer(anything(.bind("vardecl"), this);
+}

jpakkane wrote:
> alexfh wrote:
> > jpakkane wrote:
> > > alexfh wrote:
> > > > I believe, this should skip matches within template instantiations. 
> > > > Consider this code:
> > > > ```
> > > > template
> > > > void f(T) { T t; }
> > > > void g() {
> > > > f(0);
> > > > f(0.0);
> > > > }
> > > > ```
> > > > 
> > > > What will the fix  be?
> > > I tested with the following function:
> > > 
> > > 
> > > ```
> > > template
> > > void template_test_function() {
> > >   T t;
> > >   int uninitialized;
> > > }
> > > ```
> > > 
> > > Currently it warns on the "uninitialized" variable regardless of whether 
> > > the template is instantiated or not. If you call it with an int type, it 
> > > will warn about variable t being uninitialized. If you call it with a, 
> > > say, struct type, there is no warnings. Is this a reasonable approach?
> > And what happens, if there are multiple instantiations of the same 
> > template, each of them requiring a different fix? Can you try the check 
> > with my example above (and maybe also add `f("");`inside `g()`). I believe, 
> > the check will produce multiple warnings with conflicting fixes (and each 
> > of them will be wrong, btw).
> Interestingly it does warn about it, but only once, even if you have two 
> different template specializations.
> 
> I tried to suppress this warning when the type being instantiated is a 
> template argument type but no matter what I tried I could not get this to 
> work. Is there a way to get this information from the MatchedDecl object or 
> does one need to do something more complicated like going up the AST until a 
> function definition is found and checking if it is a template specialization 
> (presumably with TemplatedKind)? Any help would be appreciated.
If there are multiple warnings with the same message at the same location 
(clang-tidy/ClangTidyDiagnosticConsumer.cpp:745), they will be deduplicated. 
Thus, a random fix will probably be suggested. The proper way to filter out 
matches in template instantiations is to add 
`unless(isInTemplateInstantiation())` to the matcher.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D64671



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


[PATCH] D61333: [ASTImporter] Fix LLDB lookup in transparent ctx and with ext src

2019-07-17 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Thank you guys for the review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61333



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


[PATCH] D64418: [Docs][OpenCL] Documentation of C++ for OpenCL mode

2019-07-17 Thread Kévin Petit via Phabricator via cfe-commits
kpet requested changes to this revision.
kpet added a comment.
This revision now requires changes to proceed.

Very useful to have all of this documented! Thanks!




Comment at: docs/LanguageExtensions.rst:1527
+This functionality is built on top of OpenCL C v2.0 and C++17. Regular C++
+features can be used in OpenCL kernel code. All functionality from OpenCL C
+is inherited. This section describes minor differences to OpenCL C and any

I'm tempted to suggest you merge the first two sentences and tone down the 
claim in the second. "This functionality [...] and C++17, enabling _some_ 
regular C++ features [...].



Comment at: docs/LanguageExtensions.rst:1527
+This functionality is built on top of OpenCL C v2.0 and C++17. Regular C++
+features can be used in OpenCL kernel code. All functionality from OpenCL C
+is inherited. This section describes minor differences to OpenCL C and any

kpet wrote:
> I'm tempted to suggest you merge the first two sentences and tone down the 
> claim in the second. "This functionality [...] and C++17, enabling _some_ 
> regular C++ features [...].
s/All/Most/? Stating that all functionality from OpenCL C is available right 
before stating that the differences will be described feels like a 
contradiction.



Comment at: docs/LanguageExtensions.rst:1535
+
+The following features are not supported:
+

Probably worth adding exceptions to the list.



Comment at: docs/LanguageExtensions.rst:1541
+- Standard C++ libraries. Currently there is no solution for alternative C++
+  libraries provided. Future release will feature library support.
+

I would remove this last sentence. Only a very small portion of the libray can 
be supported anyway.



Comment at: docs/LanguageExtensions.rst:1553
+extension ISO/IEC JTC1 SC22 WG14 N1021 s3.1. Note that since the address space
+behavior in C++ is not documented formally yet, Clang extends existing concept
+from C and OpenCL. For example conversion rules are extended from qualification

I would remove the "yet", unless we can refer to an on-going and visible effort.



Comment at: docs/LanguageExtensions.rst:1553
+extension ISO/IEC JTC1 SC22 WG14 N1021 s3.1. Note that since the address space
+behavior in C++ is not documented formally yet, Clang extends existing concept
+from C and OpenCL. For example conversion rules are extended from qualification

kpet wrote:
> I would remove the "yet", unless we can refer to an on-going and visible 
> effort.
"Clang extends existing concept" feels like it should be re-worded.



Comment at: docs/LanguageExtensions.rst:1555
+from C and OpenCL. For example conversion rules are extended from qualification
+conversion but the compatibility is determined using sets and overlapping from
+Embedded C (ISO/IEC JTC1 SC22 WG14 N1021 s3.1.3). For OpenCL it means that

"using sets and overlapping" feels incomplete. Pretending I can't guess: sets 
of what? What is overlapping what? :)



Comment at: docs/LanguageExtensions.rst:1557
+Embedded C (ISO/IEC JTC1 SC22 WG14 N1021 s3.1.3). For OpenCL it means that
+implicit conversions are allowed from named to ``__generic`` but not vice versa
+(OpenCL C v2.0 s6.5.5) except for ``__constant`` address space. Most of the

Why use `__generic` when `generic` is equally valid and easier on the eyes? The 
same comment applies to other mentions of address space keywords.



Comment at: docs/LanguageExtensions.rst:1558
+implicit conversions are allowed from named to ``__generic`` but not vice versa
+(OpenCL C v2.0 s6.5.5) except for ``__constant`` address space. Most of the
+rules are built on top of this behavior.

This is ambiguous. One could read that conversions from `__generic` to 
`__constant` are allowed.



Comment at: docs/LanguageExtensions.rst:1564
+C style cast will follow OpenCL C v2.0 rules (s6.5.5). All cast operators will
+permit implicit conversion to ``__generic``. However converting from named
+address spaces to ``__generic`` can only be done using ``addrspace_cast``. Note

Isn't a conversion explicit if a cast operator is used?



Comment at: docs/LanguageExtensions.rst:1565
+permit implicit conversion to ``__generic``. However converting from named
+address spaces to ``__generic`` can only be done using ``addrspace_cast``. Note
+that conversions between ``__constant`` and any other is still disallowed.

At the time of writing `addrspace_cast` doesn't seem to exist in trunk and 
C-style casts seem to work.



Comment at: docs/LanguageExtensions.rst:1565
+permit implicit conversion to ``__generic``. However converting from named
+address spaces to ``__generic`` can only be done using ``addrspace_cast``.

[PATCH] D64861: [clang-tidy] Adjust location of namespace comment diagnostic

2019-07-17 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

LG. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64861



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


[PATCH] D59474: [OpenMP 5.0] Codegen support for user-defined mappers

2019-07-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D59474#1561161 , @lildmh wrote:

> Change the type of size from `size_t` to `int64_t`, and rebase


Lingda, could you rebase it again? Thanks.


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

https://reviews.llvm.org/D59474



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


[PATCH] D61333: [ASTImporter] Fix LLDB lookup in transparent ctx and with ext src

2019-07-17 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Jenkins looks okay: 
http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/31157/ .The build is 
red but the the previous run has the very same failing test case:
expression_command/weak_symbols/TestWeakSymbols.py


Repository:
  rL LLVM

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

https://reviews.llvm.org/D61333



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


[PATCH] D64075: [ASTImporter] Fix structural eq of lambdas

2019-07-17 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

@shafik I've been looking for any lldb regression in our Mac machine, could not 
find any. Now I am looking at 
http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/ .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64075



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


r366332 - [ASTImporter] Fix structural eq of lambdas

2019-07-17 Thread Gabor Marton via cfe-commits
Author: martong
Date: Wed Jul 17 07:40:09 2019
New Revision: 366332

URL: http://llvm.org/viewvc/llvm-project?rev=366332&view=rev
Log:
[ASTImporter] Fix structural eq of lambdas

Summary:
The structural equivalence check reported false eq between lambda classes
with different parameters in their call signature.
The solution is to check the methods for equality too in case of lambda
classes.

Reviewers: a_sidorin, a.sidorin

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

Tags: #clang

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

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

Modified: cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp?rev=366332&r1=366331&r2=366332&view=diff
==
--- cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp (original)
+++ cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp Wed Jul 17 07:40:09 2019
@@ -1085,6 +1085,19 @@ static bool IsStructurallyEquivalent(Str
   return true;
 }
 
+/// Determine structural equivalence of two lambda classes.
+static bool
+IsStructurallyEquivalentLambdas(StructuralEquivalenceContext &Context,
+CXXRecordDecl *D1, CXXRecordDecl *D2) {
+  assert(D1->isLambda() && D2->isLambda() &&
+ "Must be called on lambda classes");
+  if (!IsStructurallyEquivalent(Context, D1->getLambdaCallOperator(),
+D2->getLambdaCallOperator()))
+return false;
+
+  return true;
+}
+
 /// Determine structural equivalence of two records.
 static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
  RecordDecl *D1, RecordDecl *D2) {
@@ -1166,6 +1179,13 @@ static bool IsStructurallyEquivalent(Str
 D1CXX->getASTContext().getExternalSource()->CompleteType(D1CXX);
   }
 
+  if (D1CXX->isLambda() != D2CXX->isLambda())
+return false;
+  if (D1CXX->isLambda()) {
+if (!IsStructurallyEquivalentLambdas(Context, D1CXX, D2CXX))
+  return false;
+  }
+
   if (D1CXX->getNumBases() != D2CXX->getNumBases()) {
 if (Context.Complain) {
   Context.Diag2(D2->getLocation(),

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=366332&r1=366331&r2=366332&view=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Wed Jul 17 07:40:09 2019
@@ -5122,6 +5122,22 @@ TEST_P(ASTImporterOptionSpecificTestBase
   EXPECT_EQ(ToLSize, FromLSize);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, LambdaInGlobalScope) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  auto l1 = [](unsigned lp) { return 1; };
+  auto l2 = [](int lp) { return 2; };
+  int f(int p) {
+return l1(p) + l2(p);
+  }
+  )",
+  Lang_CXX11, "input0.cc");
+  FunctionDecl *FromF = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("f")));
+  FunctionDecl *ToF = Import(FromF, Lang_CXX11);
+  EXPECT_TRUE(ToF);
+}
+
 struct LLDBLookupTest : ASTImporterOptionSpecificTestBase {
   LLDBLookupTest() {
 Creator = [](ASTContext &ToContext, FileManager &ToFileManager,

Modified: cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp?rev=366332&r1=366331&r2=366332&view=diff
==
--- cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp (original)
+++ cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp Wed Jul 17 07:40:09 
2019
@@ -797,6 +797,58 @@ TEST_F(StructuralEquivalenceRecordTest,
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
+struct StructuralEquivalenceLambdaTest : StructuralEquivalenceTest {};
+
+TEST_F(StructuralEquivalenceLambdaTest, LambdaClassesWithDifferentMethods) {
+  // Get the LambdaExprs, unfortunately we can't match directly the underlying
+  // implicit CXXRecordDecl of the Lambda classes.
+  auto t = makeDecls(
+  "void f() { auto L0 = [](int){}; }",
+  "void f() { auto L1 = [](){}; }",
+  Lang_CXX11,
+  lambdaExpr(),
+  lambdaExpr());
+  CXXRecordDecl *L0 = get<0>(t)->getLambdaClass();
+  CXXRecordDecl *L1 = get<1>(t)->getLambdaClass();
+  EXPECT_FALSE(testStructuralMatch(L0, L1));
+}
+
+TEST_F(StructuralEquivalenceLambdaTest, LambdaClassesWithEqMethods) {
+  auto t = makeDecls(
+  "void f() { auto L0 = [](int){}; }",
+  "void f() { auto L1 = [](int){}; }",
+  Lang_CXX11,
+  lambdaExpr(),
+  lambdaExpr());
+  CXXRecordDecl *L0 = get<0>(t)->getLambdaClass();
+  CXXRecordDecl *L1 =

[PATCH] D64075: [ASTImporter] Fix structural eq of lambdas

2019-07-17 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366332: [ASTImporter] Fix structural eq of lambdas (authored 
by martong, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64075?vs=208727&id=210326#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64075

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

Index: cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
===
--- cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
+++ cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
@@ -1085,6 +1085,19 @@
   return true;
 }
 
+/// Determine structural equivalence of two lambda classes.
+static bool
+IsStructurallyEquivalentLambdas(StructuralEquivalenceContext &Context,
+CXXRecordDecl *D1, CXXRecordDecl *D2) {
+  assert(D1->isLambda() && D2->isLambda() &&
+ "Must be called on lambda classes");
+  if (!IsStructurallyEquivalent(Context, D1->getLambdaCallOperator(),
+D2->getLambdaCallOperator()))
+return false;
+
+  return true;
+}
+
 /// Determine structural equivalence of two records.
 static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
  RecordDecl *D1, RecordDecl *D2) {
@@ -1166,6 +1179,13 @@
 D1CXX->getASTContext().getExternalSource()->CompleteType(D1CXX);
   }
 
+  if (D1CXX->isLambda() != D2CXX->isLambda())
+return false;
+  if (D1CXX->isLambda()) {
+if (!IsStructurallyEquivalentLambdas(Context, D1CXX, D2CXX))
+  return false;
+  }
+
   if (D1CXX->getNumBases() != D2CXX->getNumBases()) {
 if (Context.Complain) {
   Context.Diag2(D2->getLocation(),
Index: cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp
===
--- cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp
+++ cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp
@@ -797,6 +797,58 @@
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
+struct StructuralEquivalenceLambdaTest : StructuralEquivalenceTest {};
+
+TEST_F(StructuralEquivalenceLambdaTest, LambdaClassesWithDifferentMethods) {
+  // Get the LambdaExprs, unfortunately we can't match directly the underlying
+  // implicit CXXRecordDecl of the Lambda classes.
+  auto t = makeDecls(
+  "void f() { auto L0 = [](int){}; }",
+  "void f() { auto L1 = [](){}; }",
+  Lang_CXX11,
+  lambdaExpr(),
+  lambdaExpr());
+  CXXRecordDecl *L0 = get<0>(t)->getLambdaClass();
+  CXXRecordDecl *L1 = get<1>(t)->getLambdaClass();
+  EXPECT_FALSE(testStructuralMatch(L0, L1));
+}
+
+TEST_F(StructuralEquivalenceLambdaTest, LambdaClassesWithEqMethods) {
+  auto t = makeDecls(
+  "void f() { auto L0 = [](int){}; }",
+  "void f() { auto L1 = [](int){}; }",
+  Lang_CXX11,
+  lambdaExpr(),
+  lambdaExpr());
+  CXXRecordDecl *L0 = get<0>(t)->getLambdaClass();
+  CXXRecordDecl *L1 = get<1>(t)->getLambdaClass();
+  EXPECT_TRUE(testStructuralMatch(L0, L1));
+}
+
+TEST_F(StructuralEquivalenceLambdaTest, LambdaClassesWithDifferentFields) {
+  auto t = makeDecls(
+  "void f() { char* X; auto L0 = [X](){}; }",
+  "void f() { float X; auto L1 = [X](){}; }",
+  Lang_CXX11,
+  lambdaExpr(),
+  lambdaExpr());
+  CXXRecordDecl *L0 = get<0>(t)->getLambdaClass();
+  CXXRecordDecl *L1 = get<1>(t)->getLambdaClass();
+  EXPECT_FALSE(testStructuralMatch(L0, L1));
+}
+
+TEST_F(StructuralEquivalenceLambdaTest, LambdaClassesWithEqFields) {
+  auto t = makeDecls(
+  "void f() { float X; auto L0 = [X](){}; }",
+  "void f() { float X; auto L1 = [X](){}; }",
+  Lang_CXX11,
+  lambdaExpr(),
+  lambdaExpr());
+  CXXRecordDecl *L0 = get<0>(t)->getLambdaClass();
+  CXXRecordDecl *L1 = get<1>(t)->getLambdaClass();
+  EXPECT_TRUE(testStructuralMatch(L0, L1));
+}
+
 TEST_F(StructuralEquivalenceTest, CompareSameDeclWithMultiple) {
   auto t = makeNamedDecls(
   "struct A{ }; struct B{ }; void foo(A a, A b);",
Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -5122,6 +5122,22 @@
   EXPECT_EQ(ToLSize, FromLSize);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, LambdaInGlobalScope) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  auto l1 = [](unsigned lp) { return 1; };
+  auto l2 = [](int lp) { return 2; };
+  int f(int p) {
+return l1(p) + l2(p);
+  }
+  )",
+  Lang_CXX11, "input0.cc");
+  FunctionDecl *FromF = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasNam

[PATCH] D63279: [Analyzer] Unroll for-loops where the upper boundary is a variable with know value

2019-07-17 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

I think you forgot to remove `/* */` and clang formatting before uploading the 
patch.




Comment at: lib/StaticAnalyzer/Core/LoopUnrolling.cpp:214-216
+  const Expr *BoundExpr = CondOp->getLHS()->IgnoreParenImpCasts();
+  if (BoundExpr == Matches[0].getNodeAs("boundVarOperand"))
+BoundExpr = CondOp->getRHS()->IgnoreParenImpCasts();

Szelethus wrote:
> NoQ wrote:
> > Szelethus wrote:
> > > Alright, I stood on top of this for longer than I'd like to admit, what's 
> > > happening here? Like, `CondExpr`, with the given testfile, should be `i < 
> > > n`, right? Then `BoundExpr` is supposed to be `i`, and if that is equal 
> > > to `Matches[0].getNodeAs("boundVarOperand")` (which I guess is 
> > > supposed to `n`), which I'm not sure how it could ever happen, we assign 
> > > the RHS of the assignment to `BoundExpr`?
> > > 
> > > What does this do? Why is it needed? Which 2 test cases cover these lines?
> > I think this is about `i < n` vs. `n > i`.
> If that is the case, I'd be more comfortable seeing a test for it (there 
> doesn't seem to be any) before landing this.
I'd appreciate a few lines of comment, given that there's evidence that it 
might not be obvious what's happening here :^)


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

https://reviews.llvm.org/D63279



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


[PATCH] D64418: [Docs][OpenCL] Documentation of C++ for OpenCL mode

2019-07-17 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D64418#1589401 , @kpet wrote:

> Very useful to have all of this documented! Thanks!


Would it be ok if I fix those in a separate commit? I would really like to 
commit the core part before the release branch is taken.


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

https://reviews.llvm.org/D64418



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


[PATCH] D55044: [clang-tidy] check for Abseil make_unique

2019-07-17 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Seems good now. Haojian, do you have any concerns?


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

https://reviews.llvm.org/D55044



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


[PATCH] D64695: [clang-format] Added new style rule: SortNetBSDIncludes

2019-07-17 Thread Ronald Wampler via Phabricator via cfe-commits
rdwampler added a comment.

Thanks! Can you update the documentation too?




Comment at: lib/Tooling/Inclusions/HeaderIncludes.cpp:211
+  Ret = 0;
+}
+  return Ret;

I think you can drop the else block and just return immediately from the for 
loop.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64695



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


[PATCH] D64695: [clang-format] Added new style rule: SortNetBSDIncludes

2019-07-17 Thread Manikishan Ghantasala via Phabricator via cfe-commits
Manikishan added a comment.

In D64695#1589497 , @rdwampler wrote:

> Thanks! Can you update the documentation too?


Thanks!
So, is this Implementation fine? But there is a thing, The values which we give 
two Priority does not really matter they need to be different to be in 
different groups. Is that ok? and should I Rename any options?.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64695



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


[PATCH] D64695: [clang-format] Added new style rule: SortNetBSDIncludes

2019-07-17 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Is there sufficient test coverage as to what happens if `SortPriority` is not 
set?




Comment at: lib/Format/Format.cpp:455-456
Style.KeepEmptyLinesAtTheStartOfBlocks);
-IO.mapOptional("BitFieldDeclarationsOnePerLine", 
Style.BitFieldDeclarationsOnePerLine);
+IO.mapOptional("BitFieldDeclarationsOnePerLine",
+   Style.BitFieldDeclarationsOnePerLine);
 IO.mapOptional("MacroBlockBegin", Style.MacroBlockBegin);

Unrelated change



Comment at: lib/Format/Format.cpp:613-614
   Expanded.BraceWrapping = {false, false, false, false, false, false,
-false, false, false, false, false,
-false, false, true,  true,  true};
+false, false, false, false, false, false,
+false, true,  true,  true};
   switch (Style.BreakBeforeBraces) {

Unrelated change



Comment at: lib/Format/Format.cpp:692-693
   LLVMStyle.BraceWrapping = {false, false, false, false, false, false,
- false, false, false, false, false,
- false, false, true,  true,  true};
+ false, false, false, false, false, false,
+ false, true,  true,  true};
   LLVMStyle.BreakAfterJavaFieldAnnotations = false;

Unrelated change


Repository:
  rC Clang

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

https://reviews.llvm.org/D64695



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


[PATCH] D64232: [analyzer] Prune calls to functions with linear CFGs that return a non-zero constrained value

2019-07-17 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 210330.
Szelethus added a comment.

Rebase on top master. Putting this on the bottom of the patch stack because 
this really deserves it's own analysis. (Side note, I completely messed up like 
~40 hrs worth of analysis because I didn't check which branches do I have 
stacked on top of each other, so this might take a while...)


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

https://reviews.llvm.org/D64232

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/test/Analysis/diagnostics/find_last_store.c
  clang/test/Analysis/track-control-dependency-conditions.cpp
  clang/test/Analysis/uninit-vals.c

Index: clang/test/Analysis/uninit-vals.c
===
--- clang/test/Analysis/uninit-vals.c
+++ clang/test/Analysis/uninit-vals.c
@@ -149,8 +149,6 @@
   RetVoidFuncType f = foo_radar12278788_fp;
   return ((RetIntFuncType)f)(); //expected-warning {{Undefined or garbage value returned to caller}}
 //expected-note@-1 {{Undefined or garbage value returned to caller}}
-//expected-note@-2 {{Calling 'foo_radar12278788_fp'}}
-//expected-note@-3 {{Returning from 'foo_radar12278788_fp'}}
 }
 
 void rdar13665798() {
@@ -164,8 +162,6 @@
 RetVoidFuncType f = foo_radar12278788_fp;
 return ((RetIntFuncType)f)(); //expected-warning {{Undefined or garbage value returned to caller}}
   //expected-note@-1 {{Undefined or garbage value returned to caller}}
-  //expected-note@-2 {{Calling 'foo_radar12278788_fp'}}
-  //expected-note@-3 {{Returning from 'foo_radar12278788_fp'}}
   }();
 }
 
@@ -182,18 +178,14 @@
 void use(struct Point p); 
 
 void testUseHalfPoint() {
-  struct Point p = getHalfPoint(); // expected-note{{Calling 'getHalfPoint'}}
-   // expected-note@-1{{Returning from 'getHalfPoint'}}
-   // expected-note@-2{{'p' initialized here}}
+  struct Point p = getHalfPoint(); // expected-note{{'p' initialized here}}
   use(p); // expected-warning{{uninitialized}}
   // expected-note@-1{{uninitialized}}
 }
 
 void testUseHalfPoint2() {
   struct Point p;
-  p = getHalfPoint(); // expected-note{{Calling 'getHalfPoint'}}
-  // expected-note@-1{{Returning from 'getHalfPoint'}}
-  // expected-note@-2{{Value assigned to 'p'}}
+  p = getHalfPoint(); // expected-note{{Value assigned to 'p'}}
   use(p); // expected-warning{{uninitialized}}
   // expected-note@-1{{uninitialized}}
 }
Index: clang/test/Analysis/track-control-dependency-conditions.cpp
===
--- clang/test/Analysis/track-control-dependency-conditions.cpp
+++ clang/test/Analysis/track-control-dependency-conditions.cpp
@@ -119,7 +119,7 @@
 bool coin();
 
 bool foo() {
-  return coin(); // tracking-note{{Returning value}}
+  return coin();
 }
 
 int bar;
@@ -127,12 +127,10 @@
 void test() {
   int *x = 0; // expected-note{{'x' initialized to a null pointer value}}
 
-  if (int flag = foo()) // tracking-note{{Calling 'foo'}}
-// tracking-note@-1{{Returning from 'foo'}}
-// tracking-note@-2{{'flag' initialized here}}
-// debug-note@-3{{Tracking condition 'flag'}}
-// expected-note@-4{{Assuming 'flag' is not equal to 0}}
-// expected-note@-5{{Taking true branch}}
+  if (int flag = foo()) // tracking-note{{'flag' initialized here}}
+// debug-note@-1{{Tracking condition 'flag'}}
+// expected-note@-2{{Assuming 'flag' is not equal to 0}}
+// expected-note@-3{{Taking true branch}}
 
 *x = 5; // expected-warning{{Dereference of null pointer}}
 // expected-note@-1{{Dereference of null pointer}}
@@ -143,18 +141,16 @@
 bool coin();
 
 struct ConvertsToBool {
-  operator bool() const { return coin(); } // tracking-note{{Returning value}}
+  operator bool() const { return coin(); }
 };
 
 void test() {
   int *x = 0; // expected-note{{'x' initialized to a null pointer value}}
 
   if (ConvertsToBool())
-// tracking-note@-1 {{Calling 'ConvertsToBool::operator bool'}}
-// tracking-note@-2{{Returning from 'ConvertsToBool::operator bool'}}
-// debug-note@-3{{Tracking condition 'ConvertsToBool()'}}
-// expected-note@-4{{Assuming the condition is true}}
-// expected-note@-5{{Taking true branch}}
+// debug-note@-1{{Tracking condition 'ConvertsToBool()'}}
+// expected-note@-2{{Assuming the condition is true}}
+// expected-note@-3{{Taking true branch}}
 *x = 5; // expected-warning{{Dereference of null pointer}}
 // expected-note@-1{{Dereferen

[PATCH] D64287: [analyzer] Track the right hand side of the last store regardless of its value

2019-07-17 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 210333.

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

https://reviews.llvm.org/D64287

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/test/Analysis/track-control-dependency-conditions.cpp
  clang/test/Analysis/uninit-const.c
  clang/test/Analysis/uninit-const.cpp

Index: clang/test/Analysis/uninit-const.cpp
===
--- clang/test/Analysis/uninit-const.cpp
+++ clang/test/Analysis/uninit-const.cpp
@@ -66,8 +66,8 @@
 
 void f6_2(void) {
   int t;   //expected-note {{'t' declared without an initial value}}
-  int &p = t;
-  int &s = p;
+  int &p = t;  //expected-note {{'p' initialized here}}
+  int &s = p;  //expected-note {{'s' initialized here}}
   int &q = s;  //expected-note {{'q' initialized here}}
   doStuff6(q); //expected-warning {{1st function call argument is an uninitialized value}}
//expected-note@-1 {{1st function call argument is an uninitialized value}}
@@ -96,7 +96,7 @@
 
 
 void f5(void) {
-  int t;
+  int t; // expected-note {{'t' declared without an initial value}}
   int* tp = &t;// expected-note {{'tp' initialized here}}
   doStuff_uninit(tp);  // expected-warning {{1st function call argument is a pointer to uninitialized value}}
// expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
Index: clang/test/Analysis/uninit-const.c
===
--- clang/test/Analysis/uninit-const.c
+++ clang/test/Analysis/uninit-const.c
@@ -24,15 +24,15 @@
 void doStuff_variadic(const int *u, ...){};
 
 void f_1(void) {
-  int t;
+  int t; // expected-note {{'t' declared without an initial value}}
   int* tp = &t;// expected-note {{'tp' initialized here}}
   doStuff_pointerToConstInt(tp);  // expected-warning {{1st function call argument is a pointer to uninitialized value}}
// expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
 
 void f_1_1(void) {
-  int t;
-  int* tp1 = &t;
+  int t; // expected-note {{'t' declared without an initial value}}
+  int* tp1 = &t; // expected-note {{'tp1' initialized here}}
   int* tp2 = tp1;// expected-note {{'tp2' initialized here}}
   doStuff_pointerToConstInt(tp2);  // expected-warning {{1st function call argument is a pointer to uninitialized value}}
// expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
@@ -40,12 +40,15 @@
 
 
 int *f_2_sub(int *p) {
-  return p;
+  return p; // expected-note {{Returning pointer (loaded from 'p')}}
 }
 
 void f_2(void) {
-  int t;
-  int* p = f_2_sub(&t);
+  int t; // expected-note {{'t' declared without an initial value}}
+  int* p = f_2_sub(&t); // expected-note {{Passing value via 1st parameter 'p'}}
+// expected-note@-1{{Calling 'f_2_sub'}}
+// expected-note@-2{{Returning from 'f_2_sub'}}
+// expected-note@-3{{'p' initialized here}}
   int* tp = p; // expected-note {{'tp' initialized here}}
   doStuff_pointerToConstInt(tp); // expected-warning {{1st function call argument is a pointer to uninitialized value}}
   // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
@@ -62,7 +65,7 @@
 }
 
 void f_5(void) {
-  int ta[5];
+  int ta[5]; // expected-note {{'ta' initialized here}}
   int* tp = ta;// expected-note {{'tp' initialized here}}
   doStuff_pointerToConstInt(tp);  // expected-warning {{1st function call argument is a pointer to uninitialized value}}
// expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
@@ -99,7 +102,7 @@
 }
 
 void f_9(void) {
-  int  a[6];
+  int  a[6]; // expected-note {{'a' initialized here}}
   int const *ptau = a; // expected-note {{'ptau' initialized here}}
   doStuff_arrayOfConstInt(ptau);// expected-warning {{1st function call argument is a pointer to uninitialized value}}
// expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
@@ -173,7 +176,7 @@
 
 // uninit pointer, uninit val
 void f_variadic_unp_unv(void) {
-  int t;
+  int t; // expected-note {{'t' declared without an initial value}}
   int v;
   int* tp = &t;   // expected-note {{'tp' initialized here}}
   doStuff_variadic(tp,v);  // expected-warning {{1st function call argument is a pointer to uninitialized value}}
@@ -181,7 +184,7 @@
 }
 // uninit pointer, init val
 void f_variadic_unp_inv(void) {
-  int t;
+  int t; // expected-note {{'t' declared without an initial value}}
   int v = 3;
   int* tp = &t;   // expected-note {{'tp' initialized here}}
   doStuff_variadic(tp,v);  // expected-warning {{1st function call argument is a pointer to uninitialized value

[PATCH] D64799: [Sema] Emit diagnostics for uncorrected delayed typos at the end of TU

2019-07-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

I tried to find a good place to emit unresolved typos earlier (to make sure 
CodeGen does not ever get `TypoExpr`), but couldn't find one.
Please let me know if there's some obvious place I'm missing.

Also open to suggestions for putting assertions on whether codegen is being 
called on `TypoExpr`s.
From looking at the code, it seems that currently if the codegen eventually 
arrives at a `TypoExpr`, it will emit an error saying this expression is not 
yet supported.
There might be other failure modes (computing values of exprs containing 
`TypoExpr`, etc), but it feels like the current state should catch most of the 
potential bugs there.

This change seems to be an improvement over what we had before (clangd and 
libclang do not crash, no errors are lost) and it's very simple. So unless 
people object I would propose to land it even if it does not solve all of the 
problems around delayed exprs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64799



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


r366336 - [OPENMP]Fix crash in LoopCounterRefChecker when MemberExpr is not Var or Field

2019-07-17 Thread Mike Rice via cfe-commits
Author: mikerice
Date: Wed Jul 17 08:18:45 2019
New Revision: 366336

URL: http://llvm.org/viewvc/llvm-project?rev=366336&view=rev
Log:
[OPENMP]Fix crash in LoopCounterRefChecker when MemberExpr is not Var or Field

checkDecl is only valid for VarDecls or FieldDecls, since getCanonicalDecl
expects only these. Prevent other Decl kinds (such as CXXMethodDecls and
EnumConstantDecls) from entering and asserting.

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


Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/for_loop_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=366336&r1=366335&r2=366336&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Jul 17 08:18:45 2019
@@ -4992,7 +4992,8 @@ public:
   bool VisitMemberExpr(const MemberExpr *E) {
 if (isa(E->getBase()->IgnoreParens())) {
   const ValueDecl *VD = E->getMemberDecl();
-  return checkDecl(E, VD);
+  if (isa(VD) || isa(VD))
+return checkDecl(E, VD);
 }
 return false;
   }

Modified: cfe/trunk/test/OpenMP/for_loop_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_loop_messages.cpp?rev=366336&r1=366335&r2=366336&view=diff
==
--- cfe/trunk/test/OpenMP/for_loop_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/for_loop_messages.cpp Wed Jul 17 08:18:45 2019
@@ -626,6 +626,8 @@ template 
 class TC {
   int ii, iii, kk;
 public:
+  enum { myconstant = 42 };
+  int ub();
   int dotest_lt(IT begin, IT end) {
 #pragma omp parallel
 // expected-error@+3 3 {{the loop initializer expression depends on the 
current loop control variable}}
@@ -634,6 +636,12 @@ public:
   for (ii = ii * 10 + 25; ii < ii / ii - 23; ii += 1)
 ;
 
+// Check that member function calls and enum constants in the condition is
+// handled.
+#pragma omp for
+  for (ii = 0; ii < ub() + this->myconstant; ii += 1) // expected-no-error
+;
+
 #pragma omp parallel
 // expected-error@+4 2 {{expected loop invariant expression or ' * 
ii + ' kind of expression}}
 // expected-error@+3 {{expected loop invariant expression or ' * 
TC::ii + ' kind of expression}}


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


[PATCH] D64842: [OPENMP] Fix crash in LoopCounterRefChecker when MemberExpr is not Var or Field

2019-07-17 Thread Mike Rice via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366336: [OPENMP]Fix crash in LoopCounterRefChecker when 
MemberExpr is not Var or Field (authored by mikerice, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64842?vs=210226&id=210335#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64842

Files:
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/test/OpenMP/for_loop_messages.cpp


Index: cfe/trunk/lib/Sema/SemaOpenMP.cpp
===
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp
@@ -4992,7 +4992,8 @@
   bool VisitMemberExpr(const MemberExpr *E) {
 if (isa(E->getBase()->IgnoreParens())) {
   const ValueDecl *VD = E->getMemberDecl();
-  return checkDecl(E, VD);
+  if (isa(VD) || isa(VD))
+return checkDecl(E, VD);
 }
 return false;
   }
Index: cfe/trunk/test/OpenMP/for_loop_messages.cpp
===
--- cfe/trunk/test/OpenMP/for_loop_messages.cpp
+++ cfe/trunk/test/OpenMP/for_loop_messages.cpp
@@ -626,6 +626,8 @@
 class TC {
   int ii, iii, kk;
 public:
+  enum { myconstant = 42 };
+  int ub();
   int dotest_lt(IT begin, IT end) {
 #pragma omp parallel
 // expected-error@+3 3 {{the loop initializer expression depends on the 
current loop control variable}}
@@ -634,6 +636,12 @@
   for (ii = ii * 10 + 25; ii < ii / ii - 23; ii += 1)
 ;
 
+// Check that member function calls and enum constants in the condition is
+// handled.
+#pragma omp for
+  for (ii = 0; ii < ub() + this->myconstant; ii += 1) // expected-no-error
+;
+
 #pragma omp parallel
 // expected-error@+4 2 {{expected loop invariant expression or ' * 
ii + ' kind of expression}}
 // expected-error@+3 {{expected loop invariant expression or ' * 
TC::ii + ' kind of expression}}


Index: cfe/trunk/lib/Sema/SemaOpenMP.cpp
===
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp
@@ -4992,7 +4992,8 @@
   bool VisitMemberExpr(const MemberExpr *E) {
 if (isa(E->getBase()->IgnoreParens())) {
   const ValueDecl *VD = E->getMemberDecl();
-  return checkDecl(E, VD);
+  if (isa(VD) || isa(VD))
+return checkDecl(E, VD);
 }
 return false;
   }
Index: cfe/trunk/test/OpenMP/for_loop_messages.cpp
===
--- cfe/trunk/test/OpenMP/for_loop_messages.cpp
+++ cfe/trunk/test/OpenMP/for_loop_messages.cpp
@@ -626,6 +626,8 @@
 class TC {
   int ii, iii, kk;
 public:
+  enum { myconstant = 42 };
+  int ub();
   int dotest_lt(IT begin, IT end) {
 #pragma omp parallel
 // expected-error@+3 3 {{the loop initializer expression depends on the current loop control variable}}
@@ -634,6 +636,12 @@
   for (ii = ii * 10 + 25; ii < ii / ii - 23; ii += 1)
 ;
 
+// Check that member function calls and enum constants in the condition is
+// handled.
+#pragma omp for
+  for (ii = 0; ii < ub() + this->myconstant; ii += 1) // expected-no-error
+;
+
 #pragma omp parallel
 // expected-error@+4 2 {{expected loop invariant expression or ' * ii + ' kind of expression}}
 // expected-error@+3 {{expected loop invariant expression or ' * TC::ii + ' kind of expression}}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64861: [clang-tidy] Adjust location of namespace comment diagnostic

2019-07-17 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366337: [clang-tidy] Adjust location of namespace comment 
diagnostic (authored by ibiryukov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64861?vs=210300&id=210336#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64861

Files:
  clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp
  
clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments.cpp
  
clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp
  clang-tools-extra/trunk/test/clang-tidy/select-checks.cpp


Index: clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp
@@ -9,6 +9,7 @@
 #include "NamespaceCommentCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/StringExtras.h"
 
@@ -181,7 +182,13 @@
   ? "anonymous namespace"
   : ("namespace '" + NestedNamespaceName.str() + "'");
 
-  diag(AfterRBrace, Message)
+  // Place diagnostic at an old comment, or closing brace if we did not have 
it.
+  SourceLocation DiagLoc =
+  OldCommentRange.getBegin() != OldCommentRange.getEnd()
+  ? OldCommentRange.getBegin()
+  : ND->getRBraceLoc();
+
+  diag(DiagLoc, Message)
   << NamespaceName
   << FixItHint::CreateReplacement(
  CharSourceRange::getCharRange(OldCommentRange),
Index: 
clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments.cpp
@@ -7,9 +7,9 @@
 void f(); // So that the namespace isn't empty.
 
 
-// CHECK-MESSAGES: :[[@LINE+4]]:2: warning: namespace 'n2' not terminated with 
a closing comment [google-readability-namespace-comments]
+// CHECK-MESSAGES: :[[@LINE+4]]:1: warning: namespace 'n2' not terminated with 
a closing comment [google-readability-namespace-comments]
 // CHECK-MESSAGES: :[[@LINE-7]]:11: note: namespace 'n2' starts here
-// CHECK-MESSAGES: :[[@LINE+2]]:3: warning: namespace 'n1' not terminated with
+// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: namespace 'n1' not terminated with
 // CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'n1' starts here
 }}
 // CHECK-FIXES: }  // namespace n2
@@ -25,7 +25,7 @@
 // 5
 // 6
 // 7
-// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: namespace 'macro_expansion' not 
terminated with
+// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: namespace 'macro_expansion' not 
terminated with
 // CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'macro_expansion' starts 
here
 }
 // CHECK-FIXES: }  // namespace macro_expansion
Index: clang-tools-extra/trunk/test/clang-tidy/select-checks.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/select-checks.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/select-checks.cpp
@@ -5,7 +5,7 @@
 
 namespace i {
 }
-// CHECK: :[[@LINE-1]]:2: warning: namespace 'i' not terminated with a closing 
comment [llvm-namespace-comment]
+// CHECK: :[[@LINE-1]]:1: warning: namespace 'i' not terminated with a closing 
comment [llvm-namespace-comment]
 
 // Expect no warnings from the google-explicit-constructor check:
 class A { A(int i); };
Index: 
clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp
@@ -7,9 +7,9 @@
 void f();
 
 
-// CHECK-MESSAGES: :[[@LINE+4]]:2: warning: namespace 'n3' not terminated with
+// CHECK-MESSAGES: :[[@LINE+4]]:1: warning: namespace 'n3' not terminated with
 // CHECK-MESSAGES: :[[@LINE-7]]:11: note: namespace 'n3' starts here
-// CHECK-MESSAGES: :[[@LINE+2]]:3: warning: namespace 'n1::n2' not terminated 
with a closing comment [google-readability-namespace-comments]
+// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: namespace 'n1::n2' not terminated 
with a closing comment [google-readability-namespace-comments]
 // CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'n1::n2' starts here
 }}
 // CHECK-FIXES: }  // namespace n3


Index: clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp
===

[clang-tools-extra] r366337 - [clang-tidy] Adjust location of namespace comment diagnostic

2019-07-17 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Jul 17 08:22:14 2019
New Revision: 366337

URL: http://llvm.org/viewvc/llvm-project?rev=366337&view=rev
Log:
[clang-tidy] Adjust location of namespace comment diagnostic

Summary:
If there is no comment, place it at the closing brace of a namespace
definition. Previously it was placed at the next character after the
closing brace.

The new position produces a better location for highlighting in clangd
and does not seem to make matters worse for clang-tidy.

Reviewers: alexfh, hokein

Reviewed By: alexfh, hokein

Subscribers: xazax.hun, kadircet, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments.cpp

clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp
clang-tools-extra/trunk/test/clang-tidy/select-checks.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp?rev=366337&r1=366336&r2=366337&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp 
Wed Jul 17 08:22:14 2019
@@ -9,6 +9,7 @@
 #include "NamespaceCommentCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/StringExtras.h"
 
@@ -181,7 +182,13 @@ void NamespaceCommentCheck::check(const
   ? "anonymous namespace"
   : ("namespace '" + NestedNamespaceName.str() + "'");
 
-  diag(AfterRBrace, Message)
+  // Place diagnostic at an old comment, or closing brace if we did not have 
it.
+  SourceLocation DiagLoc =
+  OldCommentRange.getBegin() != OldCommentRange.getEnd()
+  ? OldCommentRange.getBegin()
+  : ND->getRBraceLoc();
+
+  diag(DiagLoc, Message)
   << NamespaceName
   << FixItHint::CreateReplacement(
  CharSourceRange::getCharRange(OldCommentRange),

Modified: 
clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments.cpp?rev=366337&r1=366336&r2=366337&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments.cpp
 Wed Jul 17 08:22:14 2019
@@ -7,9 +7,9 @@ namespace n2 {
 void f(); // So that the namespace isn't empty.
 
 
-// CHECK-MESSAGES: :[[@LINE+4]]:2: warning: namespace 'n2' not terminated with 
a closing comment [google-readability-namespace-comments]
+// CHECK-MESSAGES: :[[@LINE+4]]:1: warning: namespace 'n2' not terminated with 
a closing comment [google-readability-namespace-comments]
 // CHECK-MESSAGES: :[[@LINE-7]]:11: note: namespace 'n2' starts here
-// CHECK-MESSAGES: :[[@LINE+2]]:3: warning: namespace 'n1' not terminated with
+// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: namespace 'n1' not terminated with
 // CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'n1' starts here
 }}
 // CHECK-FIXES: }  // namespace n2
@@ -25,7 +25,7 @@ void f(); // So that the namespace isn't
 // 5
 // 6
 // 7
-// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: namespace 'macro_expansion' not 
terminated with
+// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: namespace 'macro_expansion' not 
terminated with
 // CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'macro_expansion' starts 
here
 }
 // CHECK-FIXES: }  // namespace macro_expansion

Modified: 
clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp?rev=366337&r1=366336&r2=366337&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp
 Wed Jul 17 08:22:14 2019
@@ -7,9 +7,9 @@ namespace n3 {
 void f();
 
 
-// CHECK-MESSAGES: :[[@LINE+4]]:2: warning: namespace 'n3' not terminated with
+// CHECK-MESSAGES: :[[@LINE+4]]:1: warning: namespace 'n3' not terminated with
 // CHECK-MESSAGES: :[[@LINE-7]]:11: note: namespace 'n3' starts here
-// CHECK-MESSAGES: :[[@LINE+2]]:3: warning: namespace 'n1::n2' not terminated 
with a closing comment [google-readability-namespace-comments]
+// CHECK-

[clang-tools-extra] r366338 - [clangd] Type hierarchy: don't resolve parents if the client only asked for children

2019-07-17 Thread Nathan Ridge via cfe-commits
Author: nridge
Date: Wed Jul 17 08:26:49 2019
New Revision: 366338

URL: http://llvm.org/viewvc/llvm-project?rev=366338&view=rev
Log:
[clangd] Type hierarchy: don't resolve parents if the client only asked for 
children

Summary: Also reorganize the code for computing supertypes to make it more 
symmetric to subtypes.

Reviewers: kadircet

Reviewed By: kadircet

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

Tags: #clang

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

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

Modified: clang-tools-extra/trunk/clangd/XRefs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/XRefs.cpp?rev=366338&r1=366337&r2=366338&view=diff
==
--- clang-tools-extra/trunk/clangd/XRefs.cpp (original)
+++ clang-tools-extra/trunk/clangd/XRefs.cpp Wed Jul 17 08:26:49 2019
@@ -1132,15 +1132,9 @@ static void fillSubTypes(const SymbolID
 
 using RecursionProtectionSet = llvm::SmallSet;
 
-static Optional
-getTypeAncestors(const CXXRecordDecl &CXXRD, ASTContext &ASTCtx,
- RecursionProtectionSet &RPSet) {
-  Optional Result = declToTypeHierarchyItem(ASTCtx, CXXRD);
-  if (!Result)
-return Result;
-
-  Result->parents.emplace();
-
+static void fillSuperTypes(const CXXRecordDecl &CXXRD, ASTContext &ASTCtx,
+   std::vector &SuperTypes,
+   RecursionProtectionSet &RPSet) {
   // typeParents() will replace dependent template specializations
   // with their class template, so to avoid infinite recursion for
   // certain types of hierarchies, keep the templates encountered
@@ -1149,22 +1143,22 @@ getTypeAncestors(const CXXRecordDecl &CX
   auto *Pattern = CXXRD.getDescribedTemplate() ? &CXXRD : nullptr;
   if (Pattern) {
 if (!RPSet.insert(Pattern).second) {
-  return Result;
+  return;
 }
   }
 
   for (const CXXRecordDecl *ParentDecl : typeParents(&CXXRD)) {
 if (Optional ParentSym =
-getTypeAncestors(*ParentDecl, ASTCtx, RPSet)) {
-  Result->parents->emplace_back(std::move(*ParentSym));
+declToTypeHierarchyItem(ASTCtx, *ParentDecl)) {
+  ParentSym->parents.emplace();
+  fillSuperTypes(*ParentDecl, ASTCtx, *ParentSym->parents, RPSet);
+  SuperTypes.emplace_back(std::move(*ParentSym));
 }
   }
 
   if (Pattern) {
 RPSet.erase(Pattern);
   }
-
-  return Result;
 }
 
 const CXXRecordDecl *findRecordTypeAt(ParsedAST &AST, Position Pos) {
@@ -1231,12 +1225,19 @@ getTypeHierarchy(ParsedAST &AST, Positio
   if (!CXXRD)
 return llvm::None;
 
-  RecursionProtectionSet RPSet;
   Optional Result =
-  getTypeAncestors(*CXXRD, AST.getASTContext(), RPSet);
+  declToTypeHierarchyItem(AST.getASTContext(), *CXXRD);
   if (!Result)
 return Result;
 
+  if (Direction == TypeHierarchyDirection::Parents ||
+  Direction == TypeHierarchyDirection::Both) {
+Result->parents.emplace();
+
+RecursionProtectionSet RPSet;
+fillSuperTypes(*CXXRD, AST.getASTContext(), *Result->parents, RPSet);
+  }
+
   if ((Direction == TypeHierarchyDirection::Children ||
Direction == TypeHierarchyDirection::Both) &&
   ResolveLevels > 0) {

Modified: clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp?rev=366338&r1=366337&r2=366338&view=diff
==
--- clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp Wed Jul 17 
08:26:49 2019
@@ -630,7 +630,8 @@ struct Child2b : Child1 {};
   ASSERT_TRUE(bool(Result));
   EXPECT_THAT(
   *Result,
-  AllOf(WithName("Parent"), WithKind(SymbolKind::Struct), Parents(),
+  AllOf(WithName("Parent"), WithKind(SymbolKind::Struct),
+ParentsNotResolved(),
 Children(AllOf(WithName("Child1"), WithKind(SymbolKind::Struct),
ParentsNotResolved(), ChildrenNotResolved();
 


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


[PATCH] D64270: [analyzer][NFC] Prepare visitors for different tracking kinds

2019-07-17 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 210337.
Szelethus marked an inline comment as done.

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

https://reviews.llvm.org/D64270

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -71,6 +71,20 @@
 // Utility functions.
 //===--===//
 
+/// Implementation function for trackExpressionValue().
+static bool trackExpressionValue(
+const ExplodedNode *InputNode,
+const Expr *E, BugReport &report,
+bool EnableNullFPSuppression,
+bugreporter::TrackingKind TKind);
+
+bool bugreporter::trackExpressionValue(const ExplodedNode *InputNode,
+   const Expr *E, BugReport &report,
+   bool EnableNullFPSuppression) {
+  return ::trackExpressionValue(InputNode, E, report, EnableNullFPSuppression,
+TrackingKind::ThoroughTracking);
+}
+
 static const Expr *peelOffPointerArithmetic(const BinaryOperator *B) {
   if (B->isAdditiveOp() && B->getType()->isPointerType()) {
 if (B->getLHS()->getType()->isPointerType()) {
@@ -1162,9 +1176,45 @@
   ID.AddPointer(&tag);
   ID.AddPointer(R);
   ID.Add(V);
+  ID.AddInteger(static_cast(TKind));
   ID.AddBoolean(EnableNullFPSuppression);
 }
 
+void FindLastStoreBRVisitor::registerStatementVarDecls(
+BugReport &BR, const Stmt *S, bool EnableNullFPSuppression,
+TrackingKind TKind) {
+
+  const ExplodedNode *N = BR.getErrorNode();
+  std::deque WorkList;
+  WorkList.push_back(S);
+
+  while (!WorkList.empty()) {
+const Stmt *Head = WorkList.front();
+WorkList.pop_front();
+
+ProgramStateManager &StateMgr = N->getState()->getStateManager();
+
+if (const auto *DR = dyn_cast(Head)) {
+  if (const auto *VD = dyn_cast(DR->getDecl())) {
+const VarRegion *R =
+StateMgr.getRegionManager().getVarRegion(VD, N->getLocationContext());
+
+// What did we load?
+SVal V = N->getSVal(S);
+
+if (V.getAs() || V.getAs()) {
+  // Register a new visitor with the BugReport.
+  BR.addVisitor(llvm::make_unique(
+  V.castAs(), R, EnableNullFPSuppression, TKind));
+}
+  }
+}
+
+for (const Stmt *SubStmt : Head->children())
+  WorkList.push_back(SubStmt);
+  }
+}
+
 /// Returns true if \p N represents the DeclStmt declaring and initializing
 /// \p VR.
 static bool isInitializationOfVar(const ExplodedNode *N, const VarRegion *VR) {
@@ -1335,7 +1385,7 @@
   // should track the initializer expression.
   if (Optional PIP = Pred->getLocationAs()) {
 const MemRegion *FieldReg = (const MemRegion *)PIP->getLocationValue();
-if (FieldReg && FieldReg == R) {
+if (FieldReg == R) {
   StoreSite = Pred;
   InitE = PIP->getInitializer()->getInit();
 }
@@ -1400,8 +1450,7 @@
 if (!IsParam)
   InitE = InitE->IgnoreParenCasts();
 
-bugreporter::trackExpressionValue(StoreSite, InitE, BR,
-  EnableNullFPSuppression);
+trackExpressionValue(StoreSite, InitE, BR, EnableNullFPSuppression, TKind);
   }
 
   // Okay, we've found the binding. Emit an appropriate message.
@@ -1429,7 +1478,7 @@
   if (const VarRegion *OriginalR = BDR->getOriginalRegion(VR)) {
 if (auto KV = State->getSVal(OriginalR).getAs())
   BR.addVisitor(llvm::make_unique(
-  *KV, OriginalR, EnableNullFPSuppression));
+  *KV, OriginalR, EnableNullFPSuppression, TKind));
   }
 }
   }
@@ -1730,8 +1779,9 @@
   // isn't sufficient, because a new visitor is created for each tracked
   // expression, hence the BugReport level set.
   if (BR.addTrackedCondition(N)) {
-bugreporter::trackExpressionValue(
-N, Condition, BR, /*EnableNullFPSuppression=*/false);
+trackExpressionValue(
+N, Condition, BR, /*EnableNullFPSuppression=*/false,
+bugreporter::TrackingKind::ConditionTracking);
 return constructDebugPieceForTrackedCondition(Condition, N, BRC);
   }
 }
@@ -1843,9 +1893,14 @@
   return N;
 }
 
-bool bugreporter::trackExpressionValue(const ExplodedNode *InputNode,
-   const Expr *E, BugReport &report,
-   bool EnableNullFPSuppression) {
+static bool trackExpressionValue(
+const ExplodedNode *InputNode,
+const Expr *E, BugReport &report,
+bool EnableNullFPSuppression,
+bugreporter::TrackingKind TKind

[PATCH] D64799: [Sema] Emit diagnostics for uncorrected delayed typos at the end of TU

2019-07-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 210338.
ilya-biryukov added a comment.

- Remove -disable-free from the test, it is no longer required to workaround 
the crash


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64799

Files:
  clang/lib/Sema/Sema.cpp
  clang/test/SemaObjC/typo-correction-subscript.m


Index: clang/test/SemaObjC/typo-correction-subscript.m
===
--- clang/test/SemaObjC/typo-correction-subscript.m
+++ clang/test/SemaObjC/typo-correction-subscript.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i386-apple-macosx10.10 -fobjc-arc -fsyntax-only 
-Wno-objc-root-class %s -verify -disable-free
+// RUN: %clang_cc1 -triple i386-apple-macosx10.10 -fobjc-arc -fsyntax-only 
-Wno-objc-root-class %s -verify
 
 @class Dictionary;
 
@@ -9,6 +9,7 @@
 - (void)rdar47403222:(Dictionary *)opts {
   [self undeclaredMethod:undeclaredArg];
   // expected-error@-1{{no visible @interface for 'Test' declares the selector 
'undeclaredMethod:'}}
+  // expected-error@-2{{use of undeclared identifier 'undeclaredArg}}
   opts[(__bridge id)undeclaredKey] = 0;
   // expected-error@-1{{use of undeclared identifier 'undeclaredKey'}}
 }
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -37,6 +37,7 @@
 #include "clang/Sema/SemaInternal.h"
 #include "clang/Sema/TemplateDeduction.h"
 #include "clang/Sema/TemplateInstCallback.h"
+#include "clang/Sema/TypoCorrection.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/Support/TimeProfiler.h"
@@ -376,8 +377,6 @@
   // Detach from the PP callback handler which outlives Sema since it's owned
   // by the preprocessor.
   SemaPPCallbackHandler->reset();
-
-  assert(DelayedTypos.empty() && "Uncorrected typos!");
 }
 
 /// makeUnavailableInSystemHeader - There is an error in the current
@@ -910,6 +909,15 @@
   assert(LateParsedInstantiations.empty() &&
  "end of TU template instantiation should not create more "
  "late-parsed templates");
+
+  // Report diagnostics for uncorrected delayed typos. Ideally all of them
+  // should have been corrected by that time, but it is very hard to cover all
+  // cases in practice.
+  for (const auto &Typo : DelayedTypos) {
+// We pass an empty TypoCorrection to indicate no correction was performed.
+Typo.second.DiagHandler(TypoCorrection());
+  }
+  DelayedTypos.clear();
 }
 
 /// ActOnEndOfTranslationUnit - This is called at the very end of the


Index: clang/test/SemaObjC/typo-correction-subscript.m
===
--- clang/test/SemaObjC/typo-correction-subscript.m
+++ clang/test/SemaObjC/typo-correction-subscript.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i386-apple-macosx10.10 -fobjc-arc -fsyntax-only -Wno-objc-root-class %s -verify -disable-free
+// RUN: %clang_cc1 -triple i386-apple-macosx10.10 -fobjc-arc -fsyntax-only -Wno-objc-root-class %s -verify
 
 @class Dictionary;
 
@@ -9,6 +9,7 @@
 - (void)rdar47403222:(Dictionary *)opts {
   [self undeclaredMethod:undeclaredArg];
   // expected-error@-1{{no visible @interface for 'Test' declares the selector 'undeclaredMethod:'}}
+  // expected-error@-2{{use of undeclared identifier 'undeclaredArg}}
   opts[(__bridge id)undeclaredKey] = 0;
   // expected-error@-1{{use of undeclared identifier 'undeclaredKey'}}
 }
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -37,6 +37,7 @@
 #include "clang/Sema/SemaInternal.h"
 #include "clang/Sema/TemplateDeduction.h"
 #include "clang/Sema/TemplateInstCallback.h"
+#include "clang/Sema/TypoCorrection.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/Support/TimeProfiler.h"
@@ -376,8 +377,6 @@
   // Detach from the PP callback handler which outlives Sema since it's owned
   // by the preprocessor.
   SemaPPCallbackHandler->reset();
-
-  assert(DelayedTypos.empty() && "Uncorrected typos!");
 }
 
 /// makeUnavailableInSystemHeader - There is an error in the current
@@ -910,6 +909,15 @@
   assert(LateParsedInstantiations.empty() &&
  "end of TU template instantiation should not create more "
  "late-parsed templates");
+
+  // Report diagnostics for uncorrected delayed typos. Ideally all of them
+  // should have been corrected by that time, but it is very hard to cover all
+  // cases in practice.
+  for (const auto &Typo : DelayedTypos) {
+// We pass an empty TypoCorrection to indicate no correction was performed.
+Typo.second.DiagHandler(TypoCorrection());
+  }
+  DelayedTypos.clear();
 }
 
 /// ActOnEndOfTranslationUnit - This is called at the very end of the
___
cfe-commits mailing list
cfe-co

[PATCH] D64613: [clangd] Type hierarchy: don't resolve parents if the client only asked for children

2019-07-17 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366338: [clangd] Type hierarchy: don't resolve parents 
if the client only asked for… (authored by nridge, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64613?vs=209677&id=210339#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64613

Files:
  clang-tools-extra/trunk/clangd/XRefs.cpp
  clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp


Index: clang-tools-extra/trunk/clangd/XRefs.cpp
===
--- clang-tools-extra/trunk/clangd/XRefs.cpp
+++ clang-tools-extra/trunk/clangd/XRefs.cpp
@@ -1132,15 +1132,9 @@
 
 using RecursionProtectionSet = llvm::SmallSet;
 
-static Optional
-getTypeAncestors(const CXXRecordDecl &CXXRD, ASTContext &ASTCtx,
- RecursionProtectionSet &RPSet) {
-  Optional Result = declToTypeHierarchyItem(ASTCtx, CXXRD);
-  if (!Result)
-return Result;
-
-  Result->parents.emplace();
-
+static void fillSuperTypes(const CXXRecordDecl &CXXRD, ASTContext &ASTCtx,
+   std::vector &SuperTypes,
+   RecursionProtectionSet &RPSet) {
   // typeParents() will replace dependent template specializations
   // with their class template, so to avoid infinite recursion for
   // certain types of hierarchies, keep the templates encountered
@@ -1149,22 +1143,22 @@
   auto *Pattern = CXXRD.getDescribedTemplate() ? &CXXRD : nullptr;
   if (Pattern) {
 if (!RPSet.insert(Pattern).second) {
-  return Result;
+  return;
 }
   }
 
   for (const CXXRecordDecl *ParentDecl : typeParents(&CXXRD)) {
 if (Optional ParentSym =
-getTypeAncestors(*ParentDecl, ASTCtx, RPSet)) {
-  Result->parents->emplace_back(std::move(*ParentSym));
+declToTypeHierarchyItem(ASTCtx, *ParentDecl)) {
+  ParentSym->parents.emplace();
+  fillSuperTypes(*ParentDecl, ASTCtx, *ParentSym->parents, RPSet);
+  SuperTypes.emplace_back(std::move(*ParentSym));
 }
   }
 
   if (Pattern) {
 RPSet.erase(Pattern);
   }
-
-  return Result;
 }
 
 const CXXRecordDecl *findRecordTypeAt(ParsedAST &AST, Position Pos) {
@@ -1231,12 +1225,19 @@
   if (!CXXRD)
 return llvm::None;
 
-  RecursionProtectionSet RPSet;
   Optional Result =
-  getTypeAncestors(*CXXRD, AST.getASTContext(), RPSet);
+  declToTypeHierarchyItem(AST.getASTContext(), *CXXRD);
   if (!Result)
 return Result;
 
+  if (Direction == TypeHierarchyDirection::Parents ||
+  Direction == TypeHierarchyDirection::Both) {
+Result->parents.emplace();
+
+RecursionProtectionSet RPSet;
+fillSuperTypes(*CXXRD, AST.getASTContext(), *Result->parents, RPSet);
+  }
+
   if ((Direction == TypeHierarchyDirection::Children ||
Direction == TypeHierarchyDirection::Both) &&
   ResolveLevels > 0) {
Index: clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp
===
--- clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp
+++ clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp
@@ -630,7 +630,8 @@
   ASSERT_TRUE(bool(Result));
   EXPECT_THAT(
   *Result,
-  AllOf(WithName("Parent"), WithKind(SymbolKind::Struct), Parents(),
+  AllOf(WithName("Parent"), WithKind(SymbolKind::Struct),
+ParentsNotResolved(),
 Children(AllOf(WithName("Child1"), WithKind(SymbolKind::Struct),
ParentsNotResolved(), ChildrenNotResolved();
 


Index: clang-tools-extra/trunk/clangd/XRefs.cpp
===
--- clang-tools-extra/trunk/clangd/XRefs.cpp
+++ clang-tools-extra/trunk/clangd/XRefs.cpp
@@ -1132,15 +1132,9 @@
 
 using RecursionProtectionSet = llvm::SmallSet;
 
-static Optional
-getTypeAncestors(const CXXRecordDecl &CXXRD, ASTContext &ASTCtx,
- RecursionProtectionSet &RPSet) {
-  Optional Result = declToTypeHierarchyItem(ASTCtx, CXXRD);
-  if (!Result)
-return Result;
-
-  Result->parents.emplace();
-
+static void fillSuperTypes(const CXXRecordDecl &CXXRD, ASTContext &ASTCtx,
+   std::vector &SuperTypes,
+   RecursionProtectionSet &RPSet) {
   // typeParents() will replace dependent template specializations
   // with their class template, so to avoid infinite recursion for
   // certain types of hierarchies, keep the templates encountered
@@ -1149,22 +1143,22 @@
   auto *Pattern = CXXRD.getDescribedTemplate() ? &CXXRD : nullptr;
   if (Pattern) {
 if (!RPSet.insert(Pattern).second) {
-  return Result;
+  return;
 }
   }
 
   for (const CXXRecordDecl *ParentDecl : typeParents(&CXXRD)) {
 if (Optional ParentSym =
-getTypeAncestors(*ParentDecl,

[PATCH] D64272: [analyzer] Note last writes to a condition only in a nested stackframe

2019-07-17 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 210340.

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

https://reviews.llvm.org/D64272

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/test/Analysis/track-control-dependency-conditions.cpp

Index: clang/test/Analysis/track-control-dependency-conditions.cpp
===
--- clang/test/Analysis/track-control-dependency-conditions.cpp
+++ clang/test/Analysis/track-control-dependency-conditions.cpp
@@ -127,10 +127,9 @@
 void test() {
   int *x = 0; // expected-note{{'x' initialized to a null pointer value}}
 
-  if (int flag = foo()) // tracking-note{{'flag' initialized here}}
-// debug-note@-1{{Tracking condition 'flag'}}
-// expected-note@-2{{Assuming 'flag' is not equal to 0}}
-// expected-note@-3{{Taking true branch}}
+  if (int flag = foo()) // debug-note{{Tracking condition 'flag'}}
+// expected-note@-1{{Assuming 'flag' is not equal to 0}}
+// expected-note@-2{{Taking true branch}}
 
 *x = 5; // expected-warning{{Dereference of null pointer}}
 // expected-note@-1{{Dereference of null pointer}}
@@ -205,7 +204,7 @@
 int getInt();
 
 void f() {
-  int flag = getInt(); // tracking-note{{'flag' initialized here}}
+  int flag = getInt();
   int *x = 0; // expected-note{{'x' initialized to a null pointer value}}
   if (flag) // expected-note{{Assuming 'flag' is not equal to 0}}
 // expected-note@-1{{Taking true branch}}
@@ -220,8 +219,8 @@
 int getInt();
 
 void f(int y) {
-  y = 1; // tracking-note{{The value 1 is assigned to 'y'}}
-  flag = y; // tracking-note{{The value 1 is assigned to 'flag'}}
+  y = 1;
+  flag = y;
 
   int *x = 0; // expected-note{{'x' initialized to a null pointer value}}
   if (flag) // expected-note{{'flag' is 1}}
@@ -238,9 +237,8 @@
 
 void foo() {
   int y;
-  y = 1; // tracking-note{{The value 1 is assigned to 'y'}}
+  y = 1;
   flag = y; // tracking-note{{The value 1 is assigned to 'flag'}}
-
 }
 
 void f(int y) {
@@ -271,7 +269,7 @@
 
   foo(); // tracking-note{{Calling 'foo'}}
  // tracking-note@-1{{Returning from 'foo'}}
-  y = flag; // tracking-note{{Value assigned to 'y'}}
+  y = flag;
 
   if (y) // expected-note{{Assuming 'y' is not equal to 0}}
  // expected-note@-1{{Taking true branch}}
@@ -320,7 +318,7 @@
 void f(int flag) {
   int *x = 0; // expected-note{{'x' initialized to a null pointer value}}
 
-  flag = getInt(); // tracking-note{{Value assigned to 'flag'}}
+  flag = getInt();
   assert(flag); // tracking-note{{Calling 'assert'}}
 // tracking-note@-1{{Returning from 'assert'}}
 
Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1453,6 +1453,10 @@
 trackExpressionValue(StoreSite, InitE, BR, EnableNullFPSuppression, TKind);
   }
 
+  if (TKind == TrackingKind::ConditionTracking &&
+  StoreSite->getStackFrame() == OriginSFC)
+return nullptr;
+
   // Okay, we've found the binding. Emit an appropriate message.
   SmallString<256> sbuf;
   llvm::raw_svector_ostream os(sbuf);
@@ -1478,7 +1482,7 @@
   if (const VarRegion *OriginalR = BDR->getOriginalRegion(VR)) {
 if (auto KV = State->getSVal(OriginalR).getAs())
   BR.addVisitor(llvm::make_unique(
-  *KV, OriginalR, EnableNullFPSuppression, TKind));
+  *KV, OriginalR, EnableNullFPSuppression, TKind, OriginSFC));
   }
 }
   }
@@ -1910,6 +1914,7 @@
 return false;
 
   ProgramStateRef LVState = LVNode->getState();
+	const StackFrameContext *SFC = LVNode->getStackFrame();
 
   // We only track expressions if we believe that they are important. Chances
   // are good that control dependencies to the tracking point are also improtant
@@ -1945,7 +1950,7 @@
 if (RR && !LVIsNull)
   if (auto KV = LVal.getAs())
 report.addVisitor(llvm::make_unique(
-  *KV, RR, EnableNullFPSuppression, TKind));
+  *KV, RR, EnableNullFPSuppression, TKind, SFC));
 
 // In case of C++ references, we want to differentiate between a null
 // reference and reference to null pointer.
@@ -1982,7 +1987,7 @@
 
   if (auto KV = V.getAs())
 report.addVisitor(llvm::make_unique(
-  *KV, R, EnableNullFPSuppression, TKind));
+  *KV, R, EnableNullFPSuppression, TKind, SFC));
   return true;
 }
   }
@@ -2022,7 +2027,7 @@
 if (CanDereference)
   if (auto KV = RVal.getAs())
 report.addVisitor(llvm::make_unique(
-*KV, L->getRegion(), EnableNullFPSuppression, TKind));
+   

[PATCH] D64537: [WebAssembly] Implement thread-local storage (local-exec model)

2019-07-17 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

In D64537#1586614 , @quantum wrote:

> In D64537#1586577 , @dschuff wrote:
>
> > Another high-level question (based just on reading the CL description): The 
> > TLS-size intrinsic is per-function, does that mean that the tls-init 
> > function is called for every function? are there just multiple TLS sections 
> > per object file?
>
>
> The TLS-size intrinsic returns the total size of TLS for the module it's 
> called from. The initialization function initializes the TLS for the entire 
> module.
>
> In D64537#1586556 , @dschuff wrote:
>
> > The `offset` field of a segment can be a constant expression 
> > 
> >  which can be a `global.get` of an imported global. So we could have an 
> > imported global `__tls_base` which is different for each thread, and have 
> > an active segment with that as its segment offset?
>
>
> I didn't know that it could have been a constant expression. I don't think 
> this would have worked very well on the main thread though, since we need to 
> run `malloc` before we can compute `__tls_base`. I think this requires the 
> global to be mutable, if only because we need to be able to initialize it on 
> the main thread.


Interesting.  I was assuming we could be clever and make the main thread 
special and have the linker allocate its tls space upfront (like we do for main 
thread stack space) rather than do it a runtime, but maybe that needlessly 
complicated.  Seems like ideally we could want to import __tls_base but not for 
the main thread but I don't think of a way to express that.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64537



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


[clang-tools-extra] r366339 - Fix MSVC 'implicitly capture' compile error. NFCI.

2019-07-17 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Wed Jul 17 08:31:53 2019
New Revision: 366339

URL: http://llvm.org/viewvc/llvm-project?rev=366339&view=rev
Log:
Fix MSVC 'implicitly capture' compile error. NFCI.

Modified:
clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp

Modified: clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp?rev=366339&r1=366338&r2=366339&view=diff
==
--- clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp (original)
+++ clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp Wed Jul 17 08:31:53 
2019
@@ -65,7 +65,7 @@ std::vector parseDriverOutp
 
   auto StartIt =
   std::find_if(Lines.begin(), Lines.end(),
-   [](llvm::StringRef Line) { return Line.trim() == SIS; });
+   [SIS](llvm::StringRef Line) { return Line.trim() == SIS; });
   if (StartIt == Lines.end()) {
 elog("System include extraction: start marker not found: {0}", Output);
 return {};


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


[PATCH] D64418: [Docs][OpenCL] Documentation of C++ for OpenCL mode

2019-07-17 Thread Kévin Petit via Phabricator via cfe-commits
kpet accepted this revision.
kpet added a comment.
This revision is now accepted and ready to land.

> Would it be ok if I fix those in a separate commit? I would really like to 
> commit the core part before the release branch is taken.

I'm fine with this as long as we can continue the discussion for open comments 
in this review. Accepting the revision as I don't seem to be able to go back on 
my request for another patch.


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

https://reviews.llvm.org/D64418



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


  1   2   3   >