[PATCH] D43290: clang-format: tweak formatting of variable initialization blocks

2018-02-20 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

In https://reviews.llvm.org/D43290#1008647, @Typz wrote:

> Tweaking the penalty handling would still be needed in any case, since the 
> problem happens also when Cpp11BracedListStyle is true (though the effect is 
> more subtle)


I don't understand this. Which style do you actually care about? With 
Cpp11BracedListStyle=true or =false?

> Generally, I think it is better to just rely on penalties, since it gives a 
> way to compare and weight each solution. Then each style can decide what 
> should break first: e.g. a style may also have a lower 
> `PenaltyBreakAssignment`, thus wrapping after the equal sign would be 
> expected...

And with my reasoning, I think exactly the opposite. Penalties are nice, but if 
the behavior is generally unwanted, than it's very hard to predict in which 
situations it might still occur.


Repository:
  rC Clang

https://reviews.llvm.org/D43290



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


[PATCH] D43483: [CFG] [analyzer] Add construction context when the constructor is on a branch of a ternary operator

2018-02-20 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

This seems reasonable to me.


https://reviews.llvm.org/D43483



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


[PATCH] D43477: [CFG] [analyzer] Add MaterializeTemporaryExpr into the construction context.

2018-02-20 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D43477



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


[PATCH] D43404: [Fuchsia] Include libClang and clang-include-fixer in the toolchain

2018-02-20 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC325665: [Fuchsia] Include libClang and clang-include-fixer 
in the toolchain (authored by phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43404?vs=134687=135195#toc

Repository:
  rC Clang

https://reviews.llvm.org/D43404

Files:
  cmake/caches/Fuchsia-stage2.cmake


Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -79,10 +79,12 @@
 
 set(LLVM_DISTRIBUTION_COMPONENTS
   clang
+  libclang
   lld
   LTO
   clang-format
   clang-headers
+  clang-include-fixer
   clang-refactor
   clang-tidy
   clangd


Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -79,10 +79,12 @@
 
 set(LLVM_DISTRIBUTION_COMPONENTS
   clang
+  libclang
   lld
   LTO
   clang-format
   clang-headers
+  clang-include-fixer
   clang-refactor
   clang-tidy
   clangd
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r325665 - [Fuchsia] Include libClang and clang-include-fixer in the toolchain

2018-02-20 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Feb 20 20:39:15 2018
New Revision: 325665

URL: http://llvm.org/viewvc/llvm-project?rev=325665=rev
Log:
[Fuchsia] Include libClang and clang-include-fixer in the toolchain

libClang is used by other Clang based tools such as cquery while
clang-include-fixer is generally a useful tool.

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

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

Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia-stage2.cmake?rev=325665=325664=325665=diff
==
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Tue Feb 20 20:39:15 2018
@@ -79,10 +79,12 @@ set(LLVM_TOOLCHAIN_TOOLS
 
 set(LLVM_DISTRIBUTION_COMPONENTS
   clang
+  libclang
   lld
   LTO
   clang-format
   clang-headers
+  clang-include-fixer
   clang-refactor
   clang-tidy
   clangd


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


[PATCH] D43545: [Driver] Make -fno-common default for Fuchsia

2018-02-20 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: mcgrathr, jakehehrlich.
Herald added a subscriber: cfe-commits.

We never want to generate common symbols on Fuchsia.


Repository:
  rC Clang

https://reviews.llvm.org/D43545

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fuchsia.c


Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -10,6 +10,7 @@
 // CHECK: "-fuse-init-array"
 // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
+// CHECK: "-fno-common"
 // CHECK: {{.*}}ld.lld{{.*}}" "-z" "rodynamic"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1306,6 +1306,8 @@
 static bool isNoCommonDefault(const llvm::Triple ) {
   switch (Triple.getArch()) {
   default:
+if (Triple.isOSFuchsia())
+  return true;
 return false;
 
   case llvm::Triple::xcore:


Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -10,6 +10,7 @@
 // CHECK: "-fuse-init-array"
 // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
+// CHECK: "-fno-common"
 // CHECK: {{.*}}ld.lld{{.*}}" "-z" "rodynamic"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1306,6 +1306,8 @@
 static bool isNoCommonDefault(const llvm::Triple ) {
   switch (Triple.getArch()) {
   default:
+if (Triple.isOSFuchsia())
+  return true;
 return false;
 
   case llvm::Triple::xcore:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43428: [CFG] [analyzer] NFC: Allow more complicated construction contexts.

2018-02-20 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

It seems kind of sketchy to me that we're recursing over an expression to find 
construction contexts and then later doing it again for sub-expressions. I 
guess there is precedent here with `VisitForTemporaryDtors()`, but we should 
think about whether there is a better way to do this.




Comment at: lib/Analysis/CFG.cpp:1160
+ConstructionContextMap.lookup(CE)) {
+  // We might have visited this child when we were finding construction
+  // contexts within its parents.

This is kind of scary since it means we'll be recursing over subexpressions 
repeatedly. I guess VisitForTemporaryDtors() does this too, but it sounds like 
we're wasting a lot of computation visiting the subtrees over and over again.


https://reviews.llvm.org/D43428



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


[PATCH] D43497: [analyzer] Introduce correct lifetime extension behavior in simple cases.

2018-02-20 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

Looks good to me. I have a comment about simplifying 
createTemporaryRegionIfNeeded() (if possible) inline.




Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:281
+
+if (!TR) {
+  StorageDuration SD = MT->getStorageDuration();

Would it be safe for the body of the `if (!TR)` to be the else branch of `if 
constCXXTempObjectionRegion *const *TRPtr = ...` rather then its own if 
statement?



Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:289
   }
   if (!TR)
 TR = MRMgr.getCXXTempObjectRegion(Init, LC);

Would it be safe for `TR = MRMgr.getCXXTempObjectRegion(Init, LC);` to be the 
else branch of `if (const MaterializeTemporaryExpr *MT = 
dyn_cast(Result))` rather than its own `if` statement?

Ideally the number paths through this function on which we call 
`MRMgr.getCXXTempObjectRegion()` would be small and very clear.




Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:490
 
+static void printTemporaryMaterializatinosForContext(
+raw_ostream , ProgramStateRef State, const char *NL, const char *Sep,

Nit: There is a typo in the name here ("Materializatinos"). I guess this is the 
sub-atomic particle created as a byproduct of materializing a temporary! We 
have a lot of materializatinos in Cupertino.



Comment at: test/Analysis/lifetime-extension.cpp:45
+  clang_analyzer_eval(z == 2);
+#ifdef TEMPORARIES
+ // expected-warning@-4{{TRUE}}

Yay!



Comment at: test/Analysis/lifetime-extension.cpp:78
+  {
+const C  = C(1, , );
+  }

Nice.


https://reviews.llvm.org/D43497



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


r325663 - In C++14 onwards, it is permitted to read mutable members in constant

2018-02-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Feb 20 19:38:30 2018
New Revision: 325663

URL: http://llvm.org/viewvc/llvm-project?rev=325663=rev
Log:
In C++14 onwards, it is permitted to read mutable members in constant
expressions, if their lifetime began during the evaluation of the expression.

This is technically not allowed in C++11, though we could consider permitting
it there too, as an extension.

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=325663=325662=325663=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Feb 20 19:38:30 2018
@@ -2646,10 +2646,13 @@ struct CompleteObject {
   APValue *Value;
   /// The type of the complete object.
   QualType Type;
+  bool LifetimeStartedInEvaluation;
 
   CompleteObject() : Value(nullptr) {}
-  CompleteObject(APValue *Value, QualType Type)
-  : Value(Value), Type(Type) {
+  CompleteObject(APValue *Value, QualType Type,
+ bool LifetimeStartedInEvaluation)
+  : Value(Value), Type(Type),
+LifetimeStartedInEvaluation(LifetimeStartedInEvaluation) {
 assert(Value && "missing value for complete object");
   }
 
@@ -2679,6 +2682,8 @@ findSubobject(EvalInfo , const Expr
   APValue *O = Obj.Value;
   QualType ObjType = Obj.Type;
   const FieldDecl *LastField = nullptr;
+  const bool MayReadMutableMembers =
+  Obj.LifetimeStartedInEvaluation && Info.getLangOpts().CPlusPlus14;
 
   // Walk the designator's path to find the subobject.
   for (unsigned I = 0, N = Sub.Entries.size(); /**/; ++I) {
@@ -2694,7 +2699,7 @@ findSubobject(EvalInfo , const Expr
   // cannot perform this read. (This only happens when performing a trivial
   // copy or assignment.)
   if (ObjType->isRecordType() && handler.AccessKind == AK_Read &&
-  diagnoseUnreadableFields(Info, E, ObjType))
+  !MayReadMutableMembers && diagnoseUnreadableFields(Info, E, ObjType))
 return handler.failed();
 
   if (!handler.found(*O, ObjType))
@@ -2774,7 +2779,11 @@ findSubobject(EvalInfo , const Expr
: O->getComplexFloatReal(), ObjType);
   }
 } else if (const FieldDecl *Field = getAsField(Sub.Entries[I])) {
-  if (Field->isMutable() && handler.AccessKind == AK_Read) {
+  // In C++14 onwards, it is permitted to read a mutable member whose
+  // lifetime began within the evaluation.
+  // FIXME: Should we also allow this in C++11?
+  if (Field->isMutable() && handler.AccessKind == AK_Read &&
+  !MayReadMutableMembers) {
 Info.FFDiag(E, diag::note_constexpr_ltor_mutable, 1)
   << Field;
 Info.Note(Field->getLocation(), diag::note_declared_at);
@@ -3020,6 +3029,7 @@ static CompleteObject findCompleteObject
   // Compute value storage location and type of base object.
   APValue *BaseVal = nullptr;
   QualType BaseType = getType(LVal.Base);
+  bool LifetimeStartedInEvaluation = Frame;
 
   if (const ValueDecl *D = LVal.Base.dyn_cast()) {
 // In C++98, const, non-volatile integers initialized with ICEs are ICEs.
@@ -3131,7 +3141,7 @@ static CompleteObject findCompleteObject
 //   int & = 1;
 //   int x = ++r;
 //   constexpr int k = r;
-// Therefore we use the C++1y rules in C++11 too.
+// Therefore we use the C++14 rules in C++11 too.
 const ValueDecl *VD = Info.EvaluatingDecl.dyn_cast();
 const ValueDecl *ED = MTE->getExtendingDecl();
 if (!(BaseType.isConstQualified() &&
@@ -3144,6 +3154,7 @@ static CompleteObject findCompleteObject
 
 BaseVal = Info.Ctx.getMaterializedTemporaryValue(MTE, false);
 assert(BaseVal && "got reference to unevaluated temporary");
+LifetimeStartedInEvaluation = true;
   } else {
 Info.FFDiag(E);
 return CompleteObject();
@@ -3172,9 +3183,10 @@ static CompleteObject findCompleteObject
   if (Info.isEvaluatingConstructor(LVal.getLValueBase(), LVal.CallIndex)) {
 BaseType = Info.Ctx.getCanonicalType(BaseType);
 BaseType.removeLocalConst();
+LifetimeStartedInEvaluation = true;
   }
 
-  // In C++1y, we can't safely access any mutable state when we might be
+  // In C++14, we can't safely access any mutable state when we might be
   // evaluating after an unmodeled side effect.
   //
   // FIXME: Not all local state is mutable. Allow local constant subobjects
@@ -3184,7 +3196,7 @@ static CompleteObject findCompleteObject
   (AK != AK_Read && Info.IsSpeculativelyEvaluating))
 return CompleteObject();
 
-  return CompleteObject(BaseVal, BaseType);
+  return CompleteObject(BaseVal, BaseType, LifetimeStartedInEvaluation);
 }
 
 /// \brief Perform an lvalue-to-rvalue conversion on the given glvalue. This
@@ 

[PATCH] D43533: [CFG] [analyzer] NFC: Refactor ConstructionContext into a finite set of cases.

2018-02-20 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

This looks great to me Artem! I'll be very curious to see how you extend this 
to handle initializer lists.




Comment at: lib/Analysis/CFG.cpp:4737
+}
+case ConstructionContext::SimpleVariableKind: {
+  const auto *DSCC = cast(CC);

Eventually (not now) I think it would be great to include the construction 
context kind in the printed CFG. This would make it easier to understand at a 
glance the context.



Comment at: lib/Analysis/ConstructionContext.cpp:49
+  // patterns.
+  if (const Stmt *S = TopLayer->getTriggerStmt()) {
+if (const auto *DS = dyn_cast(S)) {

I like how this puts all the messy pattern matching in one place. The follows 
the general LLVM guidelines of "if it has to be messy, put it all in one place 
and hide the messiness from everything else".



Comment at: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp:643
 
-if (ParentExpr && isa(ParentExpr) &&
+if (CC && isa(CC) &&
 !Opts.mayInlineCXXAllocator())

This is much more semantically clear. Thank you!!


https://reviews.llvm.org/D43533



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


[PATCH] D38639: [clangd] #include statements support for Open definition

2018-02-20 Thread Marc-Andre Laperle via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325662: [clangd] #include statements support for Open 
definition (authored by malaperle, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D38639?vs=134549=135187#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38639

Files:
  clang-tools-extra/trunk/clangd/ClangdUnit.cpp
  clang-tools-extra/trunk/clangd/ClangdUnit.h
  clang-tools-extra/trunk/clangd/Protocol.h
  clang-tools-extra/trunk/clangd/SourceCode.cpp
  clang-tools-extra/trunk/clangd/SourceCode.h
  clang-tools-extra/trunk/clangd/XRefs.cpp
  clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
@@ -36,6 +36,7 @@
 namespace {
 using testing::ElementsAre;
 using testing::Field;
+using testing::IsEmpty;
 using testing::Matcher;
 using testing::UnorderedElementsAreArray;
 
@@ -563,6 +564,73 @@
   }
 }
 
+TEST(GoToInclude, All) {
+  MockFSProvider FS;
+  IgnoreDiagnostics DiagConsumer;
+  MockCompilationDatabase CDB;
+
+  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true);
+
+  auto FooCpp = testPath("foo.cpp");
+  const char *SourceContents = R"cpp(
+  #include ^"$2^foo.h$3^"
+  #include "$4^invalid.h"
+  int b = a;
+  // test
+  int foo;
+  #in$5^clude "$6^foo.h"$7^
+  )cpp";
+  Annotations SourceAnnotations(SourceContents);
+  FS.Files[FooCpp] = SourceAnnotations.code();
+  auto FooH = testPath("foo.h");
+  auto FooHUri = URIForFile{FooH};
+
+  const char *HeaderContents = R"cpp([[]]int a;)cpp";
+  Annotations HeaderAnnotations(HeaderContents);
+  FS.Files[FooH] = HeaderAnnotations.code();
+
+  Server.addDocument(FooH, HeaderAnnotations.code());
+  Server.addDocument(FooCpp, SourceAnnotations.code());
+
+  // Test include in preamble.
+  auto Locations =
+  runFindDefinitions(Server, FooCpp, SourceAnnotations.point());
+  ASSERT_TRUE(bool(Locations)) << "findDefinitions returned an error";
+  EXPECT_THAT(Locations->Value,
+  ElementsAre(Location{FooHUri, HeaderAnnotations.range()}));
+
+  // Test include in preamble, last char.
+  Locations = runFindDefinitions(Server, FooCpp, SourceAnnotations.point("2"));
+  ASSERT_TRUE(bool(Locations)) << "findDefinitions returned an error";
+  EXPECT_THAT(Locations->Value,
+  ElementsAre(Location{FooHUri, HeaderAnnotations.range()}));
+
+  Locations = runFindDefinitions(Server, FooCpp, SourceAnnotations.point("3"));
+  ASSERT_TRUE(bool(Locations)) << "findDefinitions returned an error";
+  EXPECT_THAT(Locations->Value,
+  ElementsAre(Location{FooHUri, HeaderAnnotations.range()}));
+
+  // Test include outside of preamble.
+  Locations = runFindDefinitions(Server, FooCpp, SourceAnnotations.point("6"));
+  ASSERT_TRUE(bool(Locations)) << "findDefinitions returned an error";
+  EXPECT_THAT(Locations->Value,
+  ElementsAre(Location{FooHUri, HeaderAnnotations.range()}));
+
+  // Test a few positions that do not result in Locations.
+  Locations = runFindDefinitions(Server, FooCpp, SourceAnnotations.point("4"));
+  ASSERT_TRUE(bool(Locations)) << "findDefinitions returned an error";
+  EXPECT_THAT(Locations->Value, IsEmpty());
+
+  Locations = runFindDefinitions(Server, FooCpp, SourceAnnotations.point("5"));
+  ASSERT_TRUE(bool(Locations)) << "findDefinitions returned an error";
+  EXPECT_THAT(Locations->Value, IsEmpty());
+
+  Locations = runFindDefinitions(Server, FooCpp, SourceAnnotations.point("7"));
+  ASSERT_TRUE(bool(Locations)) << "findDefinitions returned an error";
+  EXPECT_THAT(Locations->Value, IsEmpty());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/trunk/clangd/ClangdUnit.h
===
--- clang-tools-extra/trunk/clangd/ClangdUnit.h
+++ clang-tools-extra/trunk/clangd/ClangdUnit.h
@@ -45,15 +45,19 @@
   llvm::SmallVector FixIts;
 };
 
+using InclusionLocations = std::vector>;
+
 // Stores Preamble and associated data.
 struct PreambleData {
   PreambleData(PrecompiledPreamble Preamble,
std::vector TopLevelDeclIDs,
-   std::vector Diags);
+   std::vector Diags,
+   InclusionLocations IncLocations);
 
   PrecompiledPreamble Preamble;
   std::vector TopLevelDeclIDs;
   std::vector Diags;
+  InclusionLocations IncLocations;
 };
 
 /// Information required to run clang, e.g. to parse AST or do code completion.
@@ -97,13 +101,14 @@
   /// Returns the esitmated size of the AST and the accessory structures, in
   /// bytes. Does not include the size of the preamble.
   std::size_t 

[PATCH] D43497: [analyzer] Introduce correct lifetime extension behavior in simple cases.

2018-02-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 135186.
NoQ added a comment.

Add one more FIXME test (`dont_forget_destructor_around_logical_op` in 
`temporaries.cpp`) which demonstrates a situation where we fail to call the 
temporary destructor after calling the temporary constructor. It should be 
fixed once we implement return value construction properly, as described at the 
"Return by value" part of 
http://lists.llvm.org/pipermail/cfe-dev/2018-February/056898.html


https://reviews.llvm.org/D43497

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  test/Analysis/lifetime-extension.cpp
  test/Analysis/temporaries.cpp

Index: test/Analysis/temporaries.cpp
===
--- test/Analysis/temporaries.cpp
+++ test/Analysis/temporaries.cpp
@@ -895,6 +895,33 @@
 }
 } // namespace test_match_constructors_and_destructors
 
+namespace dont_forget_destructor_around_logical_op {
+int glob;
+
+class C {
+public:
+  ~C() { glob = 1; }
+};
+
+C get();
+
+bool is(C);
+
+
+void test(int coin) {
+  // Here temporaries are being cleaned up after && is evaluated. There are two
+  // temporaries: the return value of get() and the elidable copy constructor
+  // of that return value into is(). According to the CFG, we need to cleanup
+  // both of them depending on whether the temporary corresponding to the
+  // return value of get() was initialized. However, for now we don't track
+  // temporaries returned from functions, so we take the wrong branch.
+  coin && is(get()); // no-crash
+  // FIXME: We should have called the destructor, i.e. should be TRUE,
+  // at least when we inline temporary destructors.
+  clang_analyzer_eval(glob == 1); // expected-warning{{UNKNOWN}}
+}
+} // namespace dont_forget_destructor_around_logical_op
+
 #if __cplusplus >= 201103L
 namespace temporary_list_crash {
 class C {
Index: test/Analysis/lifetime-extension.cpp
===
--- test/Analysis/lifetime-extension.cpp
+++ test/Analysis/lifetime-extension.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_analyze_cc1 -Wno-unused -std=c++11 -analyzer-checker=debug.ExprInspection -verify %s
+// RUN: %clang_analyze_cc1 -Wno-unused -std=c++11 -analyzer-checker=core,debug.ExprInspection -verify %s
+// RUN: %clang_analyze_cc1 -Wno-unused -std=c++11 -analyzer-checker=core,debug.ExprInspection -analyzer-config cfg-temporary-dtors=true -DTEMPORARIES -verify %s
 
 void clang_analyzer_eval(bool);
 
@@ -38,9 +39,142 @@
   const int  = A().j[1]; // no-crash
   const int  = (A().j[1], A().j[0]); // no-crash
 
-  // FIXME: All of these should be TRUE, but constructors aren't inlined.
-  clang_analyzer_eval(x == 1); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(y == 3); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(z == 2); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(x == 1);
+  clang_analyzer_eval(y == 3);
+  clang_analyzer_eval(z == 2);
+#ifdef TEMPORARIES
+ // expected-warning@-4{{TRUE}}
+ // expected-warning@-4{{TRUE}}
+ // expected-warning@-4{{TRUE}}
+#else
+ // expected-warning@-8{{UNKNOWN}}
+ // expected-warning@-8{{UNKNOWN}}
+ // expected-warning@-8{{UNKNOWN}}
+#endif
 }
 } // end namespace pr19539_crash_on_destroying_an_integer
+
+namespace maintain_original_object_address_on_lifetime_extension {
+class C {
+  C **after, **before;
+  bool x;
+
+public:
+  C(bool x, C **after, C **before) : x(x), after(after), before(before) {
+*before = this;
+  }
+
+  // Don't track copies in our tests.
+  C(const C ) : x(c.x), after(nullptr), before(nullptr) {}
+
+  ~C() { if (after) *after = this; }
+
+  operator bool() const { return x; }
+};
+
+void f1() {
+  C *after, *before;
+  {
+const C  = C(1, , );
+  }
+  clang_analyzer_eval(after == before);
+#ifdef TEMPORARIES
+  // expected-warning@-2{{TRUE}}
+#else
+  // expected-warning@-4{{UNKNOWN}}
+#endif
+}
+
+void f2() {
+  C *after, *before;
+  C c = C(1, , );
+  clang_analyzer_eval(after == before);
+#ifdef TEMPORARIES
+  // expected-warning@-2{{TRUE}}
+#else
+  // expected-warning@-4{{UNKNOWN}}
+#endif
+}
+
+void f3(bool coin) {
+  C *after, *before;
+  {
+const C  = coin ? C(1, , ) : C(2, , );
+  }
+  clang_analyzer_eval(after == before);
+#ifdef TEMPORARIES
+  // expected-warning@-2{{TRUE}}
+#else
+  // expected-warning@-4{{UNKNOWN}}
+#endif
+}
+
+void f4(bool coin) {
+  C *after, *before;
+  {
+// no-crash
+const C  = C(coin, , ) ?: C(false, , );
+  }
+  // FIXME: Add support for lifetime extension through binary conditional
+  // operator. Ideally also add support for the binary conditional operator in
+  // C++. Because for now it calls the constructor for the condition twice.
+  if (coin) {
+clang_analyzer_eval(after == before);
+#ifdef TEMPORARIES
+  // expected-warning@-2{{The left operand of '==' is a garbage value}}
+#else
+  // expected-warning@-4{{UNKNOWN}}

[clang-tools-extra] r325662 - [clangd] #include statements support for Open definition

2018-02-20 Thread Marc-Andre Laperle via cfe-commits
Author: malaperle
Date: Tue Feb 20 18:39:08 2018
New Revision: 325662

URL: http://llvm.org/viewvc/llvm-project?rev=325662=rev
Log:
[clangd] #include statements support for Open definition

Summary: ctrl-clicking on #include statements now opens the file being pointed 
by that statement.

Reviewers: malaperle, krasimir, bkramer, ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: jkorous-apple, ioeric, mgrang, klimek, ilya-biryukov, arphaman, 
cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/clangd/ClangdUnit.h
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/clangd/SourceCode.cpp
clang-tools-extra/trunk/clangd/SourceCode.h
clang-tools-extra/trunk/clangd/XRefs.cpp
clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=325662=325661=325662=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Tue Feb 20 18:39:08 2018
@@ -81,12 +81,60 @@ private:
   std::vector TopLevelDecls;
 };
 
+// Converts a half-open clang source range to an LSP range.
+// Note that clang also uses closed source ranges, which this can't handle!
+Range toRange(CharSourceRange R, const SourceManager ) {
+  // Clang is 1-based, LSP uses 0-based indexes.
+  Position Begin;
+  Begin.line = static_cast(M.getSpellingLineNumber(R.getBegin())) - 1;
+  Begin.character =
+  static_cast(M.getSpellingColumnNumber(R.getBegin())) - 1;
+
+  Position End;
+  End.line = static_cast(M.getSpellingLineNumber(R.getEnd())) - 1;
+  End.character = static_cast(M.getSpellingColumnNumber(R.getEnd())) - 1;
+
+  return {Begin, End};
+}
+
+class InclusionLocationsCollector : public PPCallbacks {
+public:
+  InclusionLocationsCollector(SourceManager ,
+  InclusionLocations )
+  : SourceMgr(SourceMgr), IncLocations(IncLocations) {}
+
+  void InclusionDirective(SourceLocation HashLoc, const Token ,
+  StringRef FileName, bool IsAngled,
+  CharSourceRange FilenameRange, const FileEntry *File,
+  StringRef SearchPath, StringRef RelativePath,
+  const Module *Imported) override {
+auto SR = FilenameRange.getAsRange();
+if (SR.isInvalid() || !File || File->tryGetRealPathName().empty())
+  return;
+
+if (SourceMgr.isInMainFile(SR.getBegin())) {
+  // Only inclusion directives in the main file make sense. The user cannot
+  // select directives not in the main file.
+  IncLocations.emplace_back(toRange(FilenameRange, SourceMgr),
+File->tryGetRealPathName());
+}
+  }
+
+private:
+  SourceManager 
+  InclusionLocations 
+};
+
 class CppFilePreambleCallbacks : public PreambleCallbacks {
 public:
   std::vector takeTopLevelDeclIDs() {
 return std::move(TopLevelDeclIDs);
   }
 
+  InclusionLocations takeInclusionLocations() {
+return std::move(IncLocations);
+  }
+
   void AfterPCHEmitted(ASTWriter ) override {
 TopLevelDeclIDs.reserve(TopLevelDecls.size());
 for (Decl *D : TopLevelDecls) {
@@ -105,9 +153,21 @@ public:
 }
   }
 
+  void BeforeExecute(CompilerInstance ) override {
+SourceMgr = ();
+  }
+
+  std::unique_ptr createPPCallbacks() override {
+assert(SourceMgr && "SourceMgr must be set at this point");
+return llvm::make_unique(*SourceMgr,
+  IncLocations);
+  }
+
 private:
   std::vector TopLevelDecls;
   std::vector TopLevelDeclIDs;
+  InclusionLocations IncLocations;
+  SourceManager *SourceMgr = nullptr;
 };
 
 /// Convert from clang diagnostic level to LSP severity.
@@ -139,22 +199,6 @@ bool locationInRange(SourceLocation L, C
   return L != R.getEnd() && M.isPointWithin(L, R.getBegin(), R.getEnd());
 }
 
-// Converts a half-open clang source range to an LSP range.
-// Note that clang also uses closed source ranges, which this can't handle!
-Range toRange(CharSourceRange R, const SourceManager ) {
-  // Clang is 1-based, LSP uses 0-based indexes.
-  Position Begin;
-  Begin.line = static_cast(M.getSpellingLineNumber(R.getBegin())) - 1;
-  Begin.character =
-  static_cast(M.getSpellingColumnNumber(R.getBegin())) - 1;
-
-  Position End;
-  End.line = static_cast(M.getSpellingLineNumber(R.getEnd())) - 1;
-  End.character = static_cast(M.getSpellingColumnNumber(R.getEnd())) - 1;
-
-  return {Begin, End};
-}
-
 // Clang diags have a location (shown as ^) and 0 or more ranges ().
 // LSP needs a single range.
 Range diagnosticRange(const clang::Diagnostic , const LangOptions ) {
@@ -267,6 +311,17 @@ ParsedAST::Build(std::unique_ptrIncLocations;
+
+  

[PATCH] D43017: Clean up use of C allocation functions

2018-02-20 Thread Serge Pavlov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325661: Clean up use of C allocation functions (authored by 
sepavloff, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43017?vs=133201=135185#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43017

Files:
  cfe/trunk/include/clang/Sema/ParsedTemplate.h
  cfe/trunk/lib/AST/NestedNameSpecifier.cpp
  cfe/trunk/lib/Frontend/CacheTokens.cpp
  cfe/trunk/lib/Frontend/Rewrite/HTMLPrint.cpp
  cfe/trunk/lib/Lex/MacroArgs.cpp
  cfe/trunk/tools/c-index-test/c-index-test.c
  cfe/trunk/tools/libclang/BuildSystem.cpp
  cfe/trunk/tools/libclang/CIndex.cpp
  cfe/trunk/tools/libclang/CXString.cpp

Index: cfe/trunk/include/clang/Sema/ParsedTemplate.h
===
--- cfe/trunk/include/clang/Sema/ParsedTemplate.h
+++ cfe/trunk/include/clang/Sema/ParsedTemplate.h
@@ -199,8 +199,7 @@
SourceLocation LAngleLoc, SourceLocation RAngleLoc,
ArrayRef TemplateArgs,
SmallVectorImpl ) {
-
-  TemplateIdAnnotation *TemplateId = new (std::malloc(
+  TemplateIdAnnotation *TemplateId = new (llvm::safe_malloc(
   totalSizeToAlloc(TemplateArgs.size(
   TemplateIdAnnotation(SS, TemplateKWLoc, TemplateNameLoc, Name,
OperatorKind, OpaqueTemplateName, TemplateKind,
Index: cfe/trunk/lib/Frontend/Rewrite/HTMLPrint.cpp
===
--- cfe/trunk/lib/Frontend/Rewrite/HTMLPrint.cpp
+++ cfe/trunk/lib/Frontend/Rewrite/HTMLPrint.cpp
@@ -86,8 +86,7 @@
 
   // Emit the HTML.
   const RewriteBuffer  = R.getEditBuffer(FID);
-  char *Buffer = (char*)malloc(RewriteBuf.size());
-  std::copy(RewriteBuf.begin(), RewriteBuf.end(), Buffer);
-  Out->write(Buffer, RewriteBuf.size());
-  free(Buffer);
+  std::unique_ptr Buffer(new char[RewriteBuf.size()]);
+  std::copy(RewriteBuf.begin(), RewriteBuf.end(), Buffer.get());
+  Out->write(Buffer.get(), RewriteBuf.size());
 }
Index: cfe/trunk/lib/Frontend/CacheTokens.cpp
===
--- cfe/trunk/lib/Frontend/CacheTokens.cpp
+++ cfe/trunk/lib/Frontend/CacheTokens.cpp
@@ -662,7 +662,8 @@
   //  (2) a map from (IdentifierInfo*, Offset)* -> persistent IDs
 
   // Note that we use 'calloc', so all the bytes are 0.
-  PTHIdKey *IIDMap = (PTHIdKey*)calloc(idcount, sizeof(PTHIdKey));
+  PTHIdKey *IIDMap = static_cast(
+  llvm::safe_calloc(idcount, sizeof(PTHIdKey)));
 
   // Create the hashtable.
   llvm::OnDiskChainedHashTableGenerator IIOffMap;
Index: cfe/trunk/lib/Lex/MacroArgs.cpp
===
--- cfe/trunk/lib/Lex/MacroArgs.cpp
+++ cfe/trunk/lib/Lex/MacroArgs.cpp
@@ -49,7 +49,8 @@
   if (!ResultEnt) {
 // Allocate memory for a MacroArgs object with the lexer tokens at the end,
 // and construct the MacroArgs object.
-Result = new (std::malloc(totalSizeToAlloc(UnexpArgTokens.size(
+Result = new (
+llvm::safe_malloc(totalSizeToAlloc(UnexpArgTokens.size(
 MacroArgs(UnexpArgTokens.size(), VarargsElided, MI->getNumParams());
   } else {
 Result = *ResultEnt;
Index: cfe/trunk/lib/AST/NestedNameSpecifier.cpp
===
--- cfe/trunk/lib/AST/NestedNameSpecifier.cpp
+++ cfe/trunk/lib/AST/NestedNameSpecifier.cpp
@@ -466,7 +466,7 @@
 unsigned NewCapacity = std::max(
 (unsigned)(BufferCapacity ? BufferCapacity * 2 : sizeof(void *) * 2),
 (unsigned)(BufferSize + (End - Start)));
-char *NewBuffer = static_cast(malloc(NewCapacity));
+char *NewBuffer = static_cast(llvm::safe_malloc(NewCapacity));
 if (BufferCapacity) {
   memcpy(NewBuffer, Buffer, BufferSize);
   free(Buffer);
Index: cfe/trunk/tools/libclang/BuildSystem.cpp
===
--- cfe/trunk/tools/libclang/BuildSystem.cpp
+++ cfe/trunk/tools/libclang/BuildSystem.cpp
@@ -17,6 +17,7 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/CBindingWrapping.h"
 #include "llvm/Support/Chrono.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -78,7 +79,7 @@
   unwrap(VFO)->write(OS);
 
   StringRef Data = OS.str();
-  *out_buffer_ptr = (char*)malloc(Data.size());
+  *out_buffer_ptr = static_cast(llvm::safe_malloc(Data.size()));
   *out_buffer_size = Data.size();
   memcpy(*out_buffer_ptr, Data.data(), Data.size());
   return CXError_Success;
@@ -140,7 +141,7 @@
   OS << "}\n";
 
   StringRef Data = OS.str();
-  *out_buffer_ptr = (char*)malloc(Data.size());
+  *out_buffer_ptr = static_cast(llvm::safe_malloc(Data.size()));
   *out_buffer_size = Data.size();
   memcpy(*out_buffer_ptr, Data.data(), Data.size());
   return 

r325661 - Clean up use of C allocation functions

2018-02-20 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Tue Feb 20 18:02:39 2018
New Revision: 325661

URL: http://llvm.org/viewvc/llvm-project?rev=325661=rev
Log:
Clean up use of C allocation functions

If the value returned by `malloc`, `calloc` or `realloc` is not checked
for null pointer, this change replaces them for `safe_malloc`,
`safe_calloc` or `safe_realloc`, which are defined in the namespace `llvm`.
These function report fatal error on out of memory.

In the plain C files, assertion statements are added to ensure that memory
is successfully allocated.

The aim of this change is to get better diagnostics of OOM on Windows.

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

Modified:
cfe/trunk/include/clang/Sema/ParsedTemplate.h
cfe/trunk/lib/AST/NestedNameSpecifier.cpp
cfe/trunk/lib/Frontend/CacheTokens.cpp
cfe/trunk/lib/Frontend/Rewrite/HTMLPrint.cpp
cfe/trunk/lib/Lex/MacroArgs.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/BuildSystem.cpp
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CXString.cpp

Modified: cfe/trunk/include/clang/Sema/ParsedTemplate.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ParsedTemplate.h?rev=325661=325660=325661=diff
==
--- cfe/trunk/include/clang/Sema/ParsedTemplate.h (original)
+++ cfe/trunk/include/clang/Sema/ParsedTemplate.h Tue Feb 20 18:02:39 2018
@@ -199,8 +199,7 @@ namespace clang {
SourceLocation LAngleLoc, SourceLocation RAngleLoc,
ArrayRef TemplateArgs,
SmallVectorImpl ) {
-
-  TemplateIdAnnotation *TemplateId = new (std::malloc(
+  TemplateIdAnnotation *TemplateId = new (llvm::safe_malloc(
   totalSizeToAlloc(TemplateArgs.size(
   TemplateIdAnnotation(SS, TemplateKWLoc, TemplateNameLoc, Name,
OperatorKind, OpaqueTemplateName, TemplateKind,

Modified: cfe/trunk/lib/AST/NestedNameSpecifier.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/NestedNameSpecifier.cpp?rev=325661=325660=325661=diff
==
--- cfe/trunk/lib/AST/NestedNameSpecifier.cpp (original)
+++ cfe/trunk/lib/AST/NestedNameSpecifier.cpp Tue Feb 20 18:02:39 2018
@@ -466,7 +466,7 @@ static void Append(char *Start, char *En
 unsigned NewCapacity = std::max(
 (unsigned)(BufferCapacity ? BufferCapacity * 2 : sizeof(void *) * 2),
 (unsigned)(BufferSize + (End - Start)));
-char *NewBuffer = static_cast(malloc(NewCapacity));
+char *NewBuffer = static_cast(llvm::safe_malloc(NewCapacity));
 if (BufferCapacity) {
   memcpy(NewBuffer, Buffer, BufferSize);
   free(Buffer);

Modified: cfe/trunk/lib/Frontend/CacheTokens.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CacheTokens.cpp?rev=325661=325660=325661=diff
==
--- cfe/trunk/lib/Frontend/CacheTokens.cpp (original)
+++ cfe/trunk/lib/Frontend/CacheTokens.cpp Tue Feb 20 18:02:39 2018
@@ -662,7 +662,8 @@ std::pair PTHWriter::Emit
   //  (2) a map from (IdentifierInfo*, Offset)* -> persistent IDs
 
   // Note that we use 'calloc', so all the bytes are 0.
-  PTHIdKey *IIDMap = (PTHIdKey*)calloc(idcount, sizeof(PTHIdKey));
+  PTHIdKey *IIDMap = static_cast(
+  llvm::safe_calloc(idcount, sizeof(PTHIdKey)));
 
   // Create the hashtable.
   llvm::OnDiskChainedHashTableGenerator IIOffMap;

Modified: cfe/trunk/lib/Frontend/Rewrite/HTMLPrint.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/HTMLPrint.cpp?rev=325661=325660=325661=diff
==
--- cfe/trunk/lib/Frontend/Rewrite/HTMLPrint.cpp (original)
+++ cfe/trunk/lib/Frontend/Rewrite/HTMLPrint.cpp Tue Feb 20 18:02:39 2018
@@ -86,8 +86,7 @@ void HTMLPrinter::HandleTranslationUnit(
 
   // Emit the HTML.
   const RewriteBuffer  = R.getEditBuffer(FID);
-  char *Buffer = (char*)malloc(RewriteBuf.size());
-  std::copy(RewriteBuf.begin(), RewriteBuf.end(), Buffer);
-  Out->write(Buffer, RewriteBuf.size());
-  free(Buffer);
+  std::unique_ptr Buffer(new char[RewriteBuf.size()]);
+  std::copy(RewriteBuf.begin(), RewriteBuf.end(), Buffer.get());
+  Out->write(Buffer.get(), RewriteBuf.size());
 }

Modified: cfe/trunk/lib/Lex/MacroArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/MacroArgs.cpp?rev=325661=325660=325661=diff
==
--- cfe/trunk/lib/Lex/MacroArgs.cpp (original)
+++ cfe/trunk/lib/Lex/MacroArgs.cpp Tue Feb 20 18:02:39 2018
@@ -49,7 +49,8 @@ MacroArgs *MacroArgs::create(const Macro
   if (!ResultEnt) {
 // Allocate memory for a MacroArgs object with the lexer tokens at the end,
 // and construct the MacroArgs object.
-

[PATCH] D43540: [WebAssembly] Enable -Werror=strict-prototypes by default

2018-02-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

If someone is compiling C code that doesn't have undefined behavior, it should 
work; if it doesn't, that's a clear bug.  (As far as I know, there shouldn't be 
any issues here, but if there are, file a bug and CC me.)

WebAssembly is not the only platform where varargs and non-varargs calls are 
incompatible.  Some other popular platforms where this is a problem are 64-bit 
Windows and hard-float AArch32.  So I don't think it makes sense to enable this 
specifically for one target.


Repository:
  rL LLVM

https://reviews.llvm.org/D43540



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


r325659 - [Sema] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

2018-02-20 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Tue Feb 20 17:45:26 2018
New Revision: 325659

URL: http://llvm.org/viewvc/llvm-project?rev=325659=rev
Log:
[Sema] Fix some Clang-tidy modernize and Include What You Use warnings; other 
minor fixes (NFC).

Modified:
cfe/trunk/include/clang/Sema/DelayedDiagnostic.h
cfe/trunk/include/clang/Sema/IdentifierResolver.h
cfe/trunk/include/clang/Sema/Initialization.h
cfe/trunk/include/clang/Sema/Lookup.h
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/lib/Sema/DelayedDiagnostic.cpp
cfe/trunk/lib/Sema/IdentifierResolver.cpp

Modified: cfe/trunk/include/clang/Sema/DelayedDiagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DelayedDiagnostic.h?rev=325659=325658=325659=diff
==
--- cfe/trunk/include/clang/Sema/DelayedDiagnostic.h (original)
+++ cfe/trunk/include/clang/Sema/DelayedDiagnostic.h Tue Feb 20 17:45:26 2018
@@ -1,4 +1,4 @@
-//===--- DelayedDiagnostic.h - Delayed declarator diagnostics ---*- C++ 
-*-===//
+//===- DelayedDiagnostic.h - Delayed declarator diagnostics -*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -6,7 +6,7 @@
 // License. See LICENSE.TXT for details.
 //
 
//===--===//
-///
+//
 /// \file
 /// \brief Defines the classes clang::DelayedDiagnostic and 
 /// clang::AccessedEntity.
@@ -16,15 +16,33 @@
 /// diagnostics -- notably deprecation and access control -- are suppressed
 /// based on semantic properties of the parsed declaration that aren't known
 /// until it is fully parsed.
-///
+//
 
//===--===//
 
 #ifndef LLVM_CLANG_SEMA_DELAYEDDIAGNOSTIC_H
 #define LLVM_CLANG_SEMA_DELAYEDDIAGNOSTIC_H
 
+#include "clang/AST/DeclAccessPair.h"
+#include "clang/AST/DeclBase.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Type.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/PartialDiagnostic.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/Specifiers.h"
 #include "clang/Sema/Sema.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+#include 
+#include 
+#include 
 
 namespace clang {
+
+class ObjCInterfaceDecl;
+class ObjCPropertyDecl;
+
 namespace sema {
 
 /// A declaration being accessed, together with information about how
@@ -39,16 +57,14 @@ public:
   /// The target is the base class.
   enum BaseNonce { Base };
 
-  bool isMemberAccess() const { return IsMember; }
-
   AccessedEntity(PartialDiagnostic::StorageAllocator ,
  MemberNonce _,
  CXXRecordDecl *NamingClass,
  DeclAccessPair FoundDecl,
  QualType BaseObjectType)
-: Access(FoundDecl.getAccess()), IsMember(true),
-  Target(FoundDecl.getDecl()), NamingClass(NamingClass),
-  BaseObjectType(BaseObjectType), Diag(0, Allocator) {
+  : Access(FoundDecl.getAccess()), IsMember(true),
+Target(FoundDecl.getDecl()), NamingClass(NamingClass),
+BaseObjectType(BaseObjectType), Diag(0, Allocator) {
   }
 
   AccessedEntity(PartialDiagnostic::StorageAllocator ,
@@ -56,11 +72,10 @@ public:
  CXXRecordDecl *BaseClass,
  CXXRecordDecl *DerivedClass,
  AccessSpecifier Access)
-: Access(Access), IsMember(false),
-  Target(BaseClass),
-  NamingClass(DerivedClass),
-  Diag(0, Allocator) {
-  }
+  : Access(Access), IsMember(false), Target(BaseClass),
+NamingClass(DerivedClass), Diag(0, Allocator) {}
+
+  bool isMemberAccess() const { return IsMember; }
 
   bool isQuiet() const { return Diag.getDiagID() == 0; }
 
@@ -216,7 +231,6 @@ public:
   }
 
 private:
-
   struct AD {
 const NamedDecl *ReferringDecl;
 const NamedDecl *OffendingDecl;
@@ -248,20 +262,17 @@ class DelayedDiagnosticPool {
   const DelayedDiagnosticPool *Parent;
   SmallVector Diagnostics;
 
-  DelayedDiagnosticPool(const DelayedDiagnosticPool &) = delete;
-  void operator=(const DelayedDiagnosticPool &) = delete;
 public:
   DelayedDiagnosticPool(const DelayedDiagnosticPool *parent) : Parent(parent) 
{}
-  ~DelayedDiagnosticPool() {
-for (SmallVectorImpl::iterator
-   i = Diagnostics.begin(), e = Diagnostics.end(); i != e; ++i)
-  i->Destroy();
-  }
+
+  DelayedDiagnosticPool(const DelayedDiagnosticPool &) = delete;
+  DelayedDiagnosticPool =(const DelayedDiagnosticPool &) = delete;
 
   DelayedDiagnosticPool(DelayedDiagnosticPool &)
-: Parent(Other.Parent), Diagnostics(std::move(Other.Diagnostics)) {
+  : Parent(Other.Parent), Diagnostics(std::move(Other.Diagnostics)) {
 Other.Diagnostics.clear();
   }
+
   DelayedDiagnosticPool =(DelayedDiagnosticPool &) {
 Parent = Other.Parent;
 Diagnostics = std::move(Other.Diagnostics);
@@ -269,6 

[PATCH] D43392: [clang-tidy] Add Fuchsia checker for visibility attributes

2018-02-20 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added inline comments.



Comment at: clang-tidy/fuchsia/AddVisibilityCheck.cpp:68
+  diag(MatchedDecl->getLocStart(),
+   "visibility attribute not set for specified function")
+  << MatchedDecl

aaron.ballman wrote:
> jakehehrlich wrote:
> > aaron.ballman wrote:
> > > How about: "function expected to be annotated with '%0' visibility"
> > > 
> > > I'm mostly worried about the case where the function has a visibility 
> > > attribute, but it has the *wrong* visibility specified. The current 
> > > wording would be confusing in that circumstance. Or is that not a 
> > > scenario you care about, just that *any* visibility is specified on the 
> > > function?
> > The use case for this check is forcing code bases to carefully control what 
> > symbols are exported rather than just exporting everything. So if someone 
> > took the time to explicitly set the visibility of one of these symbols we 
> > care about then we should assume they knew what they were doing.
> > 
> > The specific use case I care about for this check is using 
> > -fvisibility=hidden and then checking to make sure a certain curated list 
> > of symbols has explicit default visibility.
> Ah, so a mismatch is unimportant, that's good to know. How about: "function 
> expected to be annotated with the 'visibility' attribute"?
So in implementing a way to handle #pragma and command line directives, it 
became clear that the more comprehensive check (that replaces existing attrs) 
was a trivial implementation on top of that, so I put it in. If we just want to 
ignore those cases, I can take out the conditional path.


https://reviews.llvm.org/D43392



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


[PATCH] D43392: [clang-tidy] Add Fuchsia checker for visibility attributes

2018-02-20 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 135181.
juliehockett marked 10 inline comments as done.
juliehockett added a comment.

Updating check to allow for #pragma and command line visibility specs, and 
updating tests


https://reviews.llvm.org/D43392

Files:
  clang-tidy/fuchsia/AddVisibilityCheck.cpp
  clang-tidy/fuchsia/AddVisibilityCheck.h
  clang-tidy/fuchsia/CMakeLists.txt
  clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/fuchsia-add-visibility.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/fuchsia-add-visibility.cpp

Index: test/clang-tidy/fuchsia-add-visibility.cpp
===
--- /dev/null
+++ test/clang-tidy/fuchsia-add-visibility.cpp
@@ -0,0 +1,25 @@
+// RUN: %check_clang_tidy %s fuchsia-add-visibility %t -- \
+// RUN:   -config="{CheckOptions: [{key: fuchsia-add-visibility.Names, value: 'foo;bar;baz;foobar'}, \
+// RUN:{key: fuchsia-add-visibility.Visibility, value: 'default'}]}" \
+// RUN:   -- -std=c++11
+
+#pragma GCC visibility push(hidden)
+
+void foo();
+
+void foo() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: no explicit visibility attribute set for specified function
+// CHECK-FIXES: __attribute__((visibility("default")))
+
+__attribute__((visibility("default")))
+void bar() {}
+
+__attribute__((visibility("default")))
+void baz();
+
+void baz() {}
+
+__attribute__((visibility("protected")))
+void foobar() {}
+// CHECK-MESSAGES: [[@LINE-2]]:1: warning: default visibility attribute not set for specified function
+// CHECK-FIXES: __attribute__((visibility("default")))
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -71,6 +71,7 @@
cppcoreguidelines-pro-type-vararg
cppcoreguidelines-slicing
cppcoreguidelines-special-member-functions
+   fuchsia-add-visibility
fuchsia-default-arguments
fuchsia-multiple-inheritance
fuchsia-overloaded-operator
Index: docs/clang-tidy/checks/fuchsia-add-visibility.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/fuchsia-add-visibility.rst
@@ -0,0 +1,34 @@
+.. title:: clang-tidy - fuchsia-add-visibility
+
+fuchsia-add-visibility
+==
+
+Finds functions given a list of names and suggests a fix to add
+an `__attribute__((visibility("VISIBILITY")))` to their definitions,
+if they do not already have a visibility attribute.
+
+For example, given the name 'func':
+
+.. code-block:: c++
+
+  void func() {}
+
+would be changed to 
+
+.. code-block:: c++
+
+  __attribute__((visibility("hidden")))
+  void func() {}
+  
+Options
+---
+
+.. option:: Names
+
+   A string containing a comma-separated list of function names to check for
+   a visibility attribute. Default is an empty string.
+
+.. option:: Visibility
+
+   A string specifying what visibility attribute to set, `hidden`, `default`, 
+   or `protected`. Default is `hidden`.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -70,6 +70,13 @@
   with looping constructs. Every backward jump is rejected. Forward jumps are
   only allowed in nested loops.
 
+- New `fuchsia-add-visibility
+  `_ check
+
+  Finds functions given a list of names and suggests a fix to add
+  an `__attribute__((visibility("VISIBILITY")))` to their definitions,
+  if they do not already have a visibility attribute.
+
 - New `fuchsia-multiple-inheritance
   `_ check
 
Index: clang-tidy/fuchsia/FuchsiaTidyModule.cpp
===
--- clang-tidy/fuchsia/FuchsiaTidyModule.cpp
+++ clang-tidy/fuchsia/FuchsiaTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "AddVisibilityCheck.h"
 #include "DefaultArgumentsCheck.h"
 #include "MultipleInheritanceCheck.h"
 #include "OverloadedOperatorCheck.h"
@@ -27,6 +28,8 @@
 class FuchsiaModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories ) override {
+CheckFactories.registerCheck(
+"fuchsia-add-visibility");
 CheckFactories.registerCheck(
 "fuchsia-default-arguments");
 CheckFactories.registerCheck(
Index: clang-tidy/fuchsia/CMakeLists.txt
===
--- clang-tidy/fuchsia/CMakeLists.txt
+++ clang-tidy/fuchsia/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyFuchsiaModule
+  AddVisibilityCheck.cpp
   DefaultArgumentsCheck.cpp
   FuchsiaTidyModule.cpp
   MultipleInheritanceCheck.cpp

[PATCH] D43540: [WebAssembly] Enable -Werror=strict-prototypes by default

2018-02-20 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

Hmm.. actually this is probably going to break the waterfall pretty badly.
But maybe we can fix it by re-disabling this explicitly when we build the gcc 
tests.


Repository:
  rL LLVM

https://reviews.llvm.org/D43540



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


[PATCH] D43540: [WebAssembly] Enable -Werror=strict-prototypes by default

2018-02-20 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 accepted this revision.
sbc100 added a comment.
This revision is now accepted and ready to land.

Might want to line wrap your change description.


Repository:
  rL LLVM

https://reviews.llvm.org/D43540



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


[PATCH] D43494: [Modules] Fix creating fake definition data for lambdas.

2018-02-20 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 135179.
vsapsai added a comment.

- Set `D->DefinitionData` early.

We already call `MergeDefinitionData` after definition data deserialization is
complete. And I removed previously added `IsBeingDefined`, so left the "all the
bits must match" checks in `MergeDefinitionData` as-is.

As for testing, requirement for `Canon->DefinitionData != DD` check is already
enforced by existing tests.


https://reviews.llvm.org/D43494

Files:
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/test/Modules/Inputs/self-referencing-lambda/a.h
  clang/test/Modules/Inputs/self-referencing-lambda/module.modulemap
  clang/test/Modules/self-referencing-lambda.cpp


Index: clang/test/Modules/self-referencing-lambda.cpp
===
--- /dev/null
+++ clang/test/Modules/self-referencing-lambda.cpp
@@ -0,0 +1,5 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I 
%S/Inputs/self-referencing-lambda %s -verify -emit-obj -o %t2.o
+// expected-no-diagnostics
+
+#include "a.h"
Index: clang/test/Modules/Inputs/self-referencing-lambda/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/self-referencing-lambda/module.modulemap
@@ -0,0 +1,4 @@
+module "a.h" {
+  header "a.h"
+  export *
+}
Index: clang/test/Modules/Inputs/self-referencing-lambda/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/self-referencing-lambda/a.h
@@ -0,0 +1,4 @@
+void f() {
+  int x = 0;
+  auto q = [xm = x]{};
+}
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1782,21 +1782,24 @@
   else
 DD = new (C) struct CXXRecordDecl::DefinitionData(D);
 
+  // Set definition data before reading it, so that during deserialization when
+  // we read CXXRecordDecl, it already has definition data and we don't set 
fake
+  // one.
+  D->DefinitionData = DD;
   ReadCXXDefinitionData(*DD, D);
 
   // We might already have a definition for this record. This can happen either
   // because we're reading an update record, or because we've already done some
   // merging. Either way, just merge into it.
   CXXRecordDecl *Canon = D->getCanonicalDecl();
-  if (Canon->DefinitionData) {
+  if (Canon->DefinitionData && Canon->DefinitionData != DD) {
 MergeDefinitionData(Canon, std::move(*DD));
 D->DefinitionData = Canon->DefinitionData;
 return;
   }
 
   // Mark this declaration as being a definition.
   D->IsCompleteDefinition = true;
-  D->DefinitionData = DD;
 
   // If this is not the first declaration or is an update record, we can have
   // other redeclarations already. Make a note that we need to propagate the


Index: clang/test/Modules/self-referencing-lambda.cpp
===
--- /dev/null
+++ clang/test/Modules/self-referencing-lambda.cpp
@@ -0,0 +1,5 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/self-referencing-lambda %s -verify -emit-obj -o %t2.o
+// expected-no-diagnostics
+
+#include "a.h"
Index: clang/test/Modules/Inputs/self-referencing-lambda/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/self-referencing-lambda/module.modulemap
@@ -0,0 +1,4 @@
+module "a.h" {
+  header "a.h"
+  export *
+}
Index: clang/test/Modules/Inputs/self-referencing-lambda/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/self-referencing-lambda/a.h
@@ -0,0 +1,4 @@
+void f() {
+  int x = 0;
+  auto q = [xm = x]{};
+}
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1782,21 +1782,24 @@
   else
 DD = new (C) struct CXXRecordDecl::DefinitionData(D);
 
+  // Set definition data before reading it, so that during deserialization when
+  // we read CXXRecordDecl, it already has definition data and we don't set fake
+  // one.
+  D->DefinitionData = DD;
   ReadCXXDefinitionData(*DD, D);
 
   // We might already have a definition for this record. This can happen either
   // because we're reading an update record, or because we've already done some
   // merging. Either way, just merge into it.
   CXXRecordDecl *Canon = D->getCanonicalDecl();
-  if (Canon->DefinitionData) {
+  if (Canon->DefinitionData && Canon->DefinitionData != DD) {
 MergeDefinitionData(Canon, std::move(*DD));
 D->DefinitionData = Canon->DefinitionData;
 return;
   }
 
   // Mark this declaration as being a definition.
   

[PATCH] D43540: [WebAssembly] Enable -Werror=strict-prototypes by default

2018-02-20 Thread Dan Gohman via Phabricator via cfe-commits
sunfish created this revision.
sunfish added a reviewer: sbc100.
Herald added subscribers: llvm-commits, aheejin, jfb.

WebAssembly, the architecture, is not designed to support unprototyped calling 
conventions. For example, clang tends to assume that it can use varargs to 
implement parts of the unprototyped function rules, which works on most other 
architectures, however WebAssembly has no straightforward way of allowing 
functions to be callable as both varargs and non-varargs. LLVM's backend does 
find ways to make things work in some cases, however the support is incomplete. 
To protect users from accidentally trying to compile such code and encountering 
bugs, this patch enables -Werror=strict-prototypes by default for the 
WebAssembly target.


Repository:
  rL LLVM

https://reviews.llvm.org/D43540

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/wasm-toolchain.c


Index: test/Driver/wasm-toolchain.c
===
--- test/Driver/wasm-toolchain.c
+++ test/Driver/wasm-toolchain.c
@@ -1,15 +1,21 @@
 // A basic clang -cc1 command-line. WebAssembly is somewhat special in
-// enabling -fvisibility=hidden by default.
+// enabling -fvisibility=hidden and -Werror-strict-prototypes by default.
 
 // RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
2>&1 | FileCheck -check-prefix=CC1 %s
-// CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}} 
"-fvisibility" "hidden" {{.*}}
+// CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}} 
"-Werror=strict-prototypes" "-fvisibility" "hidden" {{.*}}
 
 // Ditto, but ensure that a user -fvisibility=default disables the default
 // -fvisibility=hidden.
 
 // RUN: %clang %s -### -target wasm32-unknown-unknown -fvisibility=default 
2>&1 | FileCheck -check-prefix=FVISIBILITY_DEFAULT %s
 // FVISIBILITY_DEFAULT-NOT: hidden
 
+// Ensure that a user -Wno-strict-prototypes disabled the default
+// -Werror=strict-prototypes.
+
+// RUN: %clang %s -### -target wasm32-unknown-unknown -Wno-strict-prototypes 
2>&1 | FileCheck -check-prefix=WNO_STRICT_PROTOTYPES %s
+// WNO_STRICT_PROTOTYPES: "-Werror=strict-prototypes" {{.*}} 
"-Wno-strict-prototypes"
+
 // A basic C link command-line.
 
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -1820,6 +1820,9 @@
 
 void Clang::AddWebAssemblyTargetArgs(const ArgList ,
  ArgStringList ) const {
+  // WebAssembly doesn't fully support code without prototypes.
+  CmdArgs.push_back("-Werror=strict-prototypes");
+
   // Default to "hidden" visibility.
   if (!Args.hasArg(options::OPT_fvisibility_EQ,
options::OPT_fvisibility_ms_compat)) {


Index: test/Driver/wasm-toolchain.c
===
--- test/Driver/wasm-toolchain.c
+++ test/Driver/wasm-toolchain.c
@@ -1,15 +1,21 @@
 // A basic clang -cc1 command-line. WebAssembly is somewhat special in
-// enabling -fvisibility=hidden by default.
+// enabling -fvisibility=hidden and -Werror-strict-prototypes by default.
 
 // RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 2>&1 | FileCheck -check-prefix=CC1 %s
-// CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}} "-fvisibility" "hidden" {{.*}}
+// CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}} "-Werror=strict-prototypes" "-fvisibility" "hidden" {{.*}}
 
 // Ditto, but ensure that a user -fvisibility=default disables the default
 // -fvisibility=hidden.
 
 // RUN: %clang %s -### -target wasm32-unknown-unknown -fvisibility=default 2>&1 | FileCheck -check-prefix=FVISIBILITY_DEFAULT %s
 // FVISIBILITY_DEFAULT-NOT: hidden
 
+// Ensure that a user -Wno-strict-prototypes disabled the default
+// -Werror=strict-prototypes.
+
+// RUN: %clang %s -### -target wasm32-unknown-unknown -Wno-strict-prototypes 2>&1 | FileCheck -check-prefix=WNO_STRICT_PROTOTYPES %s
+// WNO_STRICT_PROTOTYPES: "-Werror=strict-prototypes" {{.*}} "-Wno-strict-prototypes"
+
 // A basic C link command-line.
 
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -1820,6 +1820,9 @@
 
 void Clang::AddWebAssemblyTargetArgs(const ArgList ,
  ArgStringList ) const {
+  // WebAssembly doesn't fully support code without prototypes.
+  CmdArgs.push_back("-Werror=strict-prototypes");
+
   // Default to "hidden" visibility.
   if (!Args.hasArg(options::OPT_fvisibility_EQ,
   

[PATCH] D43538: [clang-tidy] Update run-clang-tidy.py with config arg

2018-02-20 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett created this revision.
juliehockett added reviewers: aaron.ballman, hokein, alexfh.
juliehockett added a project: clang-tools-extra.
Herald added a subscriber: xazax.hun.

Updating the run-clang-tidy.py script to allow specification of the config 
argument to the clang-tidy invocation.


https://reviews.llvm.org/D43538

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


Index: clang-tidy/tool/run-clang-tidy.py
===
--- clang-tidy/tool/run-clang-tidy.py
+++ clang-tidy/tool/run-clang-tidy.py
@@ -75,7 +75,8 @@
 
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
-header_filter, extra_arg, extra_arg_before, quiet):
+header_filter, extra_arg, extra_arg_before, quiet,
+config):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary]
   if header_filter is not None:
@@ -99,6 +100,8 @@
   start.append('-p=' + build_path)
   if quiet:
   start.append('-quiet')
+  if config:
+  start.append('-config=' + config)
   start.append(f)
   return start
 
@@ -157,7 +160,7 @@
 invocation = get_tidy_invocation(name, args.clang_tidy_binary, args.checks,
  tmpdir, build_path, args.header_filter,
  args.extra_arg, args.extra_arg_before,
- args.quiet)
+ args.quiet, args.config)
 sys.stdout.write(' '.join(invocation) + '\n')
 subprocess.call(invocation)
 queue.task_done()
@@ -177,6 +180,14 @@
   parser.add_argument('-checks', default=None,
   help='checks filter, when not specified, use clang-tidy '
   'default')
+  parser.add_argument('-config', default=None,
+  help='Specifies a configuration in YAML/JSON format: '
+  '  -config="{Checks: \'*\','
+  '   CheckOptions: [{key: x,'
+  '   value: y}]}"'
+  'When the value is empty, clang-tidy will'
+  'attempt to find a file named .clang-tidy for'
+  'each source file in its parent directories.')
   parser.add_argument('-header-filter', default=None,
   help='regular expression matching the names of the '
   'headers to output diagnostics from. Diagnostics from '


Index: clang-tidy/tool/run-clang-tidy.py
===
--- clang-tidy/tool/run-clang-tidy.py
+++ clang-tidy/tool/run-clang-tidy.py
@@ -75,7 +75,8 @@
 
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
-header_filter, extra_arg, extra_arg_before, quiet):
+header_filter, extra_arg, extra_arg_before, quiet,
+config):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary]
   if header_filter is not None:
@@ -99,6 +100,8 @@
   start.append('-p=' + build_path)
   if quiet:
   start.append('-quiet')
+  if config:
+  start.append('-config=' + config)
   start.append(f)
   return start
 
@@ -157,7 +160,7 @@
 invocation = get_tidy_invocation(name, args.clang_tidy_binary, args.checks,
  tmpdir, build_path, args.header_filter,
  args.extra_arg, args.extra_arg_before,
- args.quiet)
+ args.quiet, args.config)
 sys.stdout.write(' '.join(invocation) + '\n')
 subprocess.call(invocation)
 queue.task_done()
@@ -177,6 +180,14 @@
   parser.add_argument('-checks', default=None,
   help='checks filter, when not specified, use clang-tidy '
   'default')
+  parser.add_argument('-config', default=None,
+  help='Specifies a configuration in YAML/JSON format: '
+  '  -config="{Checks: \'*\','
+  '   CheckOptions: [{key: x,'
+  '   value: y}]}"'
+  'When the value is empty, clang-tidy will'
+  'attempt to find a file named .clang-tidy for'
+  'each source file in its parent directories.')
   parser.add_argument('-header-filter', default=None,
   help='regular expression matching the names of the '
   'headers to output diagnostics from. Diagnostics from '
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43494: [Modules] Fix creating fake definition data for lambdas.

2018-02-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:2969
 
+if (!DD && RD->isBeingDefined())
+  return nullptr;

vsapsai wrote:
> vsapsai wrote:
> > aprantl wrote:
> > > Perhaps add a comment explaining what's going on in this early exit?
> > While I was trying to explain this early exit, I realized one of my 
> > assumptions was incorrect. Now I'm not sure returning nullptr is the right 
> > fix, maybe assigning incomplete definition data like
> > 
> > ```lang=c++
> > D->DefinitionData = DD;
> > ReadCXXDefinitionData(*DD, D);
> > ```
> > is better.
> > 
> > I am trying to come up with a test case showing different behaviour for 
> > these 2 different fixes. But so far nothing yet. If anybody can tell which 
> > one is correct: null context for merging or not-yet-populated definition 
> > data, that would be helpful.
> Looks like both fix approaches should work as in 
> `ASTDeclReader::ReadCXXDefinitionData` we read decl only for lambda. If I'm 
> not mistaken, for lambdas merging doesn't really make sense, so no context 
> for merging doesn't have repercussions.
Merging for lambdas does make sense in the context of inline functions (where 
we can import two definitions of the same inline function from two different 
modules, and the definition can contain a lambda).

I think setting `D->DefinitionData` early would be the preferable solution. We 
should also disable the "all the bits must match" checks in 
`MergeDefinitionData` if one of the `DefinitionData` objects has 
`IsBeingDefined` set (or, ideally, defer those checks until recursive 
deserialization is complete).


https://reviews.llvm.org/D43494



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


[PATCH] D41102: Setup clang-doc frontend framework

2018-02-20 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added a comment.

In https://reviews.llvm.org/D41102#1011299, @lebedev.ri wrote:

> I don't know the protocol, but i think it might be a good idea
>  to add a new entry to `CODE_OWNERS.TXT` for `clang-doc`?
>
> `clang-doc` going to be quite distinctive, and bigger/complicated
>  than what already is in `clang-tools-extra`.


Does anyone know what the protocol on this would be?




Comment at: clang-doc/ClangDocBinary.cpp:88
+  Stream.Emit((unsigned)'C', 8);
+  Stream.Emit((unsigned)'S', 8);
+}

lebedev.ri wrote:
> juliehockett wrote:
> > lebedev.ri wrote:
> > > General comment: shouldn't the bitcode be versioned?
> > Possibly? My understanding of the versioning (which could be incorrect) was 
> > that it was for the LLVM IR and how it is written in the given file -- I'm 
> > not writing to LLVM IR here, just using it as a data storage format, and so 
> > didn't think it was necessary. Happy to add it in though, but which version 
> > number should I use?
> The question i'm asking is: what will happen if two different (documenting 
> different attributes, with non-identical `enum {something}Id`, etc) 
> clang-doc's were used to generate two different parts of the docs (two 
> different TU's)?
> When merging two parts, if the older clang-doc is used, will it only accept 
> the part if bc it understands? Or fail altogether?
> And, does it make sense to allow to generate such mixed-up documentation?
> 
After some thought, I think it will depend on how the bitcode changes in the 
future. The reader can be implemented to simply ignore anything it doesn't 
recognize (with a default switch case), so that route is possible, but if the 
representation shifts in a major way it should probably just bail if the 
version is too early. 

I think this a good question to consider in implementing the reader and reducer 
portions of the tool -- for now, I've added the version number to the writer, 
so it can be checked in that part.


https://reviews.llvm.org/D41102



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


[PATCH] D41102: Setup clang-doc frontend framework

2018-02-20 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 135168.
juliehockett marked 13 inline comments as done.
juliehockett added a comment.

1. Updating mapper keys to use USRs instead of names
2. Also updating internal representation to use USRs instead of names
3. Renaming files (getting rid of the ClangDoc prefix in most cases)
4. Added bitcode version number to output
5. Put brief documentation in header files
6. Updating internal representation to generate full infos for all decls 
(regardless of if they're defined -- the reducer step will consolidate these) 
and to store the namespace as a vector instead of a string.


https://reviews.llvm.org/D41102

Files:
  CMakeLists.txt
  clang-doc/BitcodeWriter.cpp
  clang-doc/BitcodeWriter.h
  clang-doc/CMakeLists.txt
  clang-doc/ClangDoc.h
  clang-doc/Mapper.cpp
  clang-doc/Mapper.h
  clang-doc/Representation.h
  clang-doc/tool/CMakeLists.txt
  clang-doc/tool/ClangDocMain.cpp
  docs/clang-doc.rst
  test/CMakeLists.txt
  test/clang-doc/mapper-class.cpp
  test/clang-doc/mapper-enum.cpp
  test/clang-doc/mapper-function.cpp
  test/clang-doc/mapper-method.cpp
  test/clang-doc/mapper-namespace.cpp
  test/clang-doc/mapper-struct.cpp
  test/clang-doc/mapper-union.cpp

Index: test/clang-doc/mapper-union.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-union.cpp
@@ -0,0 +1,29 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@u...@d.bc --dump | FileCheck %s
+
+union D { int X; int Y; };
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'D'
+  // CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'D::X'
+// CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'D::Y'
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+
+
Index: test/clang-doc/mapper-struct.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-struct.cpp
@@ -0,0 +1,23 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@s...@c.bc --dump | FileCheck %s
+
+struct C { int i; };
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'C'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'C::i'
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+
+
Index: test/clang-doc/mapper-namespace.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-namespace.cpp
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@n...@a.bc --dump | FileCheck %s
+
+namespace A {}
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'A'
+// CHECK: 
+
+
Index: test/clang-doc/mapper-method.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-method.cpp
@@ -0,0 +1,31 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@S@G@F@Method#I#.bc --dump | FileCheck %s
+
+class G {
+public: 
+	int Method(int param) { return param; }
+};
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'Method'
+  // CHECK: 
+  // CHECK:  blob data = 'c:@S@G'
+  // CHECK: 
+// CHECK:  blob data = 'int'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'param'
+  // CHECK: 
+// CHECK: 
+
+
+
+
Index: test/clang-doc/mapper-function.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-function.cpp
@@ -0,0 +1,24 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@F@F#I#.bc --dump | FileCheck %s
+
+int F(int param) { return param; }
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'F'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'param'
+  // CHECK: 
+// CHECK: 
+
Index: test/clang-doc/mapper-enum.cpp

[PATCH] D43459: [X86] Disable CLWB in Cannon Lake

2018-02-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325655: [X86] Disable CLWB in Cannon Lake (authored by 
ctopper, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D43459

Files:
  cfe/trunk/lib/Basic/Targets/X86.cpp
  cfe/trunk/test/Preprocessor/predefined-arch-macros.c


Index: cfe/trunk/lib/Basic/Targets/X86.cpp
===
--- cfe/trunk/lib/Basic/Targets/X86.cpp
+++ cfe/trunk/lib/Basic/Targets/X86.cpp
@@ -175,7 +175,8 @@
 setFeatureEnabledImpl(Features, "avx512bw", true);
 setFeatureEnabledImpl(Features, "avx512vl", true);
 setFeatureEnabledImpl(Features, "pku", true);
-setFeatureEnabledImpl(Features, "clwb", true);
+if (Kind != CK_Cannonlake) // CNL inherits all SKX features, except CLWB
+  setFeatureEnabledImpl(Features, "clwb", true);
 LLVM_FALLTHROUGH;
   case CK_SkylakeClient:
 setFeatureEnabledImpl(Features, "xsavec", true);
Index: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
===
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c
@@ -974,7 +974,7 @@
 // CHECK_CNL_M32: #define __BMI2__ 1
 // CHECK_CNL_M32: #define __BMI__ 1
 // CHECK_CNL_M32: #define __CLFLUSHOPT__ 1
-// CHECK_CNL_M32: #define __CLWB__ 1
+// CHECK_CNL_M32-NOT: #define __CLWB__ 1
 // CHECK_CNL_M32: #define __F16C__ 1
 // CHECK_CNL_M32: #define __FMA__ 1
 // CHECK_CNL_M32: #define __LZCNT__ 1
@@ -1022,7 +1022,7 @@
 // CHECK_CNL_M64: #define __BMI2__ 1
 // CHECK_CNL_M64: #define __BMI__ 1
 // CHECK_CNL_M64: #define __CLFLUSHOPT__ 1
-// CHECK_CNL_M64: #define __CLWB__ 1
+// CHECK_CNL_M64-NOT: #define __CLWB__ 1
 // CHECK_CNL_M64: #define __F16C__ 1
 // CHECK_CNL_M64: #define __FMA__ 1
 // CHECK_CNL_M64: #define __LZCNT__ 1


Index: cfe/trunk/lib/Basic/Targets/X86.cpp
===
--- cfe/trunk/lib/Basic/Targets/X86.cpp
+++ cfe/trunk/lib/Basic/Targets/X86.cpp
@@ -175,7 +175,8 @@
 setFeatureEnabledImpl(Features, "avx512bw", true);
 setFeatureEnabledImpl(Features, "avx512vl", true);
 setFeatureEnabledImpl(Features, "pku", true);
-setFeatureEnabledImpl(Features, "clwb", true);
+if (Kind != CK_Cannonlake) // CNL inherits all SKX features, except CLWB
+  setFeatureEnabledImpl(Features, "clwb", true);
 LLVM_FALLTHROUGH;
   case CK_SkylakeClient:
 setFeatureEnabledImpl(Features, "xsavec", true);
Index: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
===
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c
@@ -974,7 +974,7 @@
 // CHECK_CNL_M32: #define __BMI2__ 1
 // CHECK_CNL_M32: #define __BMI__ 1
 // CHECK_CNL_M32: #define __CLFLUSHOPT__ 1
-// CHECK_CNL_M32: #define __CLWB__ 1
+// CHECK_CNL_M32-NOT: #define __CLWB__ 1
 // CHECK_CNL_M32: #define __F16C__ 1
 // CHECK_CNL_M32: #define __FMA__ 1
 // CHECK_CNL_M32: #define __LZCNT__ 1
@@ -1022,7 +1022,7 @@
 // CHECK_CNL_M64: #define __BMI2__ 1
 // CHECK_CNL_M64: #define __BMI__ 1
 // CHECK_CNL_M64: #define __CLFLUSHOPT__ 1
-// CHECK_CNL_M64: #define __CLWB__ 1
+// CHECK_CNL_M64-NOT: #define __CLWB__ 1
 // CHECK_CNL_M64: #define __F16C__ 1
 // CHECK_CNL_M64: #define __FMA__ 1
 // CHECK_CNL_M64: #define __LZCNT__ 1
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r325655 - [X86] Disable CLWB in Cannon Lake

2018-02-20 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue Feb 20 16:16:50 2018
New Revision: 325655

URL: http://llvm.org/viewvc/llvm-project?rev=325655=rev
Log:
[X86] Disable CLWB in Cannon Lake

Cannon Lake does not support CLWB, therefore it
does not include all features listed under SKX.

Patch by Gabor Buella

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

Modified:
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=325655=325654=325655=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Tue Feb 20 16:16:50 2018
@@ -175,7 +175,8 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "avx512bw", true);
 setFeatureEnabledImpl(Features, "avx512vl", true);
 setFeatureEnabledImpl(Features, "pku", true);
-setFeatureEnabledImpl(Features, "clwb", true);
+if (Kind != CK_Cannonlake) // CNL inherits all SKX features, except CLWB
+  setFeatureEnabledImpl(Features, "clwb", true);
 LLVM_FALLTHROUGH;
   case CK_SkylakeClient:
 setFeatureEnabledImpl(Features, "xsavec", true);

Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=325655=325654=325655=diff
==
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Tue Feb 20 16:16:50 
2018
@@ -974,7 +974,7 @@
 // CHECK_CNL_M32: #define __BMI2__ 1
 // CHECK_CNL_M32: #define __BMI__ 1
 // CHECK_CNL_M32: #define __CLFLUSHOPT__ 1
-// CHECK_CNL_M32: #define __CLWB__ 1
+// CHECK_CNL_M32-NOT: #define __CLWB__ 1
 // CHECK_CNL_M32: #define __F16C__ 1
 // CHECK_CNL_M32: #define __FMA__ 1
 // CHECK_CNL_M32: #define __LZCNT__ 1
@@ -1022,7 +1022,7 @@
 // CHECK_CNL_M64: #define __BMI2__ 1
 // CHECK_CNL_M64: #define __BMI__ 1
 // CHECK_CNL_M64: #define __CLFLUSHOPT__ 1
-// CHECK_CNL_M64: #define __CLWB__ 1
+// CHECK_CNL_M64-NOT: #define __CLWB__ 1
 // CHECK_CNL_M64: #define __F16C__ 1
 // CHECK_CNL_M64: #define __FMA__ 1
 // CHECK_CNL_M64: #define __LZCNT__ 1


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


[PATCH] D43487: [mips] Spectre variant two mitigation for MIPSR2

2018-02-20 Thread Simon Dardis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325651: [mips] Spectre variant two mitigation for MIPSR2 
(authored by sdardis, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D43487

Files:
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Basic/Targets/Mips.h
  cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
  cfe/trunk/lib/Driver/ToolChains/Arch/Mips.h
  cfe/trunk/test/Driver/mips-features.c
  cfe/trunk/test/Driver/mips-indirect-branch.c

Index: cfe/trunk/test/Driver/mips-features.c
===
--- cfe/trunk/test/Driver/mips-features.c
+++ cfe/trunk/test/Driver/mips-features.c
@@ -402,3 +402,9 @@
 // RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mno-branch-likely 2>&1 \
 // RUN:   | FileCheck --check-prefix=NO-BRANCH-LIKELY %s
 // NO-BRANCH-LIKELY: argument unused during compilation: '-mno-branch-likely'
+
+// -mindirect-jump=hazard
+// RUN: %clang -target mips-unknown-linux-gnu -### -c %s \
+// RUN:-mindirect-jump=hazard 2>&1 \
+// RUN:   | FileCheck --check-prefix=INDIRECT-BH %s
+// INDIRECT-BH: "-target-feature" "+use-indirect-jump-hazard"
Index: cfe/trunk/test/Driver/mips-indirect-branch.c
===
--- cfe/trunk/test/Driver/mips-indirect-branch.c
+++ cfe/trunk/test/Driver/mips-indirect-branch.c
@@ -0,0 +1,23 @@
+// REQUIRES: mips-registered-target
+// -mindirect-jump=hazard -mips32
+// RUN: %clang -target mips-unknown-linux-gnu -mips32 -### -c %s \
+// RUN:-mindirect-jump=hazard 2>&1 | FileCheck %s --check-prefix=MIPS32
+// MIPS32: error: '-mindirect-jump=hazard' is unsupported with the 'mips32' architecture
+
+// -mindirect-jump=hazard -mmicromips
+// RUN: %clang -target mips-unknown-linux-gnu -mmicromips -### -c %s \
+// RUN:-mindirect-jump=hazard 2>&1 | FileCheck %s --check-prefix=MICROMIPS
+// MICROMIPS: error: '-mindirect-jump=hazard' is unsupported with the 'micromips' architecture
+
+// -mindirect-jump=hazard -mips16
+// RUN: %clang -target mips-unknown-linux-gnu -mips16 -### -c %s \
+// RUN:-mindirect-jump=hazard 2>&1 | FileCheck %s --check-prefix=MIPS16
+// MIPS16: error: '-mindirect-jump=hazard' is unsupported with the 'mips16' architecture
+
+// RUN: %clang -target mips-unknown-linux-gnu  -### -c %s \
+// RUN:-mindirect-jump=retopline 2>&1 | FileCheck %s --check-prefix=RETOPLINE
+// RETOPLINE: error: unknown '-mindirect-jump=' option 'retopline'
+
+// RUN: %clang -target mips-unknown-linux-gnu  -### -mips32 -c %s \
+// RUN:-mindirect-jump=retopline 2>&1 | FileCheck %s --check-prefix=MIXED
+// MIXED: error: unknown '-mindirect-jump=' option 'retopline'
Index: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.h
===
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.h
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.h
@@ -53,6 +53,7 @@
 bool shouldUseFPXX(const llvm::opt::ArgList , const llvm::Triple ,
StringRef CPUName, StringRef ABIName,
mips::FloatABI FloatABI);
+bool supportsIndirectJumpHazardBarrier(StringRef );
 
 } // end namespace mips
 } // end namespace target
Index: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
@@ -343,6 +343,28 @@
   AddTargetFeature(Args, Features, options::OPT_mno_madd4, options::OPT_mmadd4,
"nomadd4");
   AddTargetFeature(Args, Features, options::OPT_mmt, options::OPT_mno_mt, "mt");
+
+  if (Arg *A = Args.getLastArg(options::OPT_mindirect_jump_EQ)) {
+StringRef Val = StringRef(A->getValue());
+if (Val == "hazard") {
+  Arg *B =
+  Args.getLastArg(options::OPT_mmicromips, options::OPT_mno_micromips);
+  Arg *C = Args.getLastArg(options::OPT_mips16, options::OPT_mno_mips16);
+
+  if (B && B->getOption().matches(options::OPT_mmicromips))
+D.Diag(diag::err_drv_unsupported_indirect_jump_opt)
+<< "hazard" << "micromips";
+  else if (C && C->getOption().matches(options::OPT_mips16))
+D.Diag(diag::err_drv_unsupported_indirect_jump_opt)
+<< "hazard" << "mips16";
+  else if (mips::supportsIndirectJumpHazardBarrier(CPUName))
+Features.push_back("+use-indirect-jump-hazard");
+  else
+D.Diag(diag::err_drv_unsupported_indirect_jump_opt)
+<< "hazard" << CPUName;
+} else
+  D.Diag(diag::err_drv_unknown_indirect_jump_opt) << Val;
+  }
 }
 
 mips::IEEE754Standard mips::getIEEE754Standard(StringRef ) {
@@ -447,3 +469,20 @@
 
   return UseFPXX;
 }
+
+bool mips::supportsIndirectJumpHazardBarrier(StringRef ) {
+  // Supporting the hazard barrier method of dealing 

r325651 - [mips] Spectre variant two mitigation for MIPSR2

2018-02-20 Thread Simon Dardis via cfe-commits
Author: sdardis
Date: Tue Feb 20 16:05:05 2018
New Revision: 325651

URL: http://llvm.org/viewvc/llvm-project?rev=325651=rev
Log:
[mips] Spectre variant two mitigation for MIPSR2

This patch provides mitigation for CVE-2017-5715, Spectre variant two,
which affects the P5600 and P6600. It provides the option
-mindirect-jump=hazard, which instructs the LLVM backend to replace
indirect branches with their hazard barrier variants.

This option is accepted when targeting MIPS revision two or later.

The migitation strategy suggested by MIPS for these processors is to
use two hazard barrier instructions. 'jalr.hb' and 'jr.hb' are hazard
barrier variants of the 'jalr' and 'jr' instructions respectively.

These instructions impede the execution of instruction stream until
architecturally defined hazards (changes to the instruction stream,
privileged registers which may affect execution) are cleared. These
instructions in MIPS' designs are not speculated past.

These instructions are used with the option -mindirect-jump=hazard
when branching indirectly and for indirect function calls.

These instructions are defined by the MIPS32R2 ISA, so this mitigation
method is not compatible with processors which implement an earlier
revision of the MIPS ISA.

Implementation note: I've opted to provide this as an
-mindirect-jump={hazard,...} style option in case alternative
mitigation methods are required for other implementations of the MIPS
ISA in future, e.g. retpoline style solutions.

Reviewers: atanasyan

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

Added:
cfe/trunk/test/Driver/mips-indirect-branch.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets/Mips.h
cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
cfe/trunk/lib/Driver/ToolChains/Arch/Mips.h
cfe/trunk/test/Driver/mips-features.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=325651=325650=325651=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Feb 20 16:05:05 
2018
@@ -333,6 +333,10 @@ def warn_drv_unsupported_abicalls : Warn
   "ignoring '-mabicalls' option as it cannot be used with "
   "non position-independent code and the N64 ABI">,
   InGroup;
+def err_drv_unsupported_indirect_jump_opt : Error<
+  "'-mindirect-jump=%0' is unsupported with the '%1' architecture">;
+def err_drv_unknown_indirect_jump_opt : Error<
+  "unknown '-mindirect-jump=' option '%0'">;
 
 def warn_drv_unable_to_find_directory_expected : Warning<
   "unable to find %0 directory, expected to be in '%1'">,

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=325651=325650=325651=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Feb 20 16:05:05 2018
@@ -2022,6 +2022,9 @@ def mbranch_likely : Flag<["-"], "mbranc
   IgnoredGCCCompat;
 def mno_branch_likely : Flag<["-"], "mno-branch-likely">, Group,
   IgnoredGCCCompat;
+def mindirect_jump_EQ : Joined<["-"], "mindirect-jump=">,
+  Group,
+  HelpText<"Change indirect jump instructions to inhibit speculation">;
 def mdsp : Flag<["-"], "mdsp">, Group;
 def mno_dsp : Flag<["-"], "mno-dsp">, Group;
 def mdspr2 : Flag<["-"], "mdspr2">, Group;

Modified: cfe/trunk/lib/Basic/Targets/Mips.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/Mips.h?rev=325651=325650=325651=diff
==
--- cfe/trunk/lib/Basic/Targets/Mips.h (original)
+++ cfe/trunk/lib/Basic/Targets/Mips.h Tue Feb 20 16:05:05 2018
@@ -54,6 +54,7 @@ class LLVM_LIBRARY_VISIBILITY MipsTarget
   enum DspRevEnum { NoDSP, DSP1, DSP2 } DspRev;
   bool HasMSA;
   bool DisableMadd4;
+  bool UseIndirectJumpHazard;
 
 protected:
   bool HasFP64;
@@ -64,7 +65,8 @@ public:
   : TargetInfo(Triple), IsMips16(false), IsMicromips(false),
 IsNan2008(false), IsAbs2008(false), IsSingleFloat(false),
 IsNoABICalls(false), CanUseBSDABICalls(false), FloatABI(HardFloat),
-DspRev(NoDSP), HasMSA(false), DisableMadd4(false), HasFP64(false) {
+DspRev(NoDSP), HasMSA(false), DisableMadd4(false),
+UseIndirectJumpHazard(false), HasFP64(false) {
 TheCXXABI.set(TargetCXXABI::GenericMIPS);
 
 setABI((getTriple().getArch() == llvm::Triple::mips ||
@@ -339,6 +341,8 @@ public:
 IsAbs2008 = false;
   else if (Feature == "+noabicalls")
 IsNoABICalls = true;
+  else if (Feature == "+use-indirect-jump-hazard")
+UseIndirectJumpHazard = 

r325646 - Fix assert when template argument deduction's original call arg checking triggers class template instantiation.

2018-02-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Feb 20 15:47:12 2018
New Revision: 325646

URL: http://llvm.org/viewvc/llvm-project?rev=325646=rev
Log:
Fix assert when template argument deduction's original call arg checking 
triggers class template instantiation.

Added:
cfe/trunk/test/SemaTemplate/temp_arg_pack.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=325646=325645=325646=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Tue Feb 20 15:47:12 2018
@@ -3084,7 +3084,7 @@ CheckOriginalCallArgDeduction(Sema , T
 return Sema::TDK_Success;
 
   if (A->isRecordType() && isSimpleTemplateIdType(OriginalParamType) &&
-  S.IsDerivedFrom(SourceLocation(), A, DeducedA))
+  S.IsDerivedFrom(Info.getLocation(), A, DeducedA))
 return Sema::TDK_Success;
 
   return Failed();

Added: cfe/trunk/test/SemaTemplate/temp_arg_pack.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_pack.cpp?rev=325646=auto
==
--- cfe/trunk/test/SemaTemplate/temp_arg_pack.cpp (added)
+++ cfe/trunk/test/SemaTemplate/temp_arg_pack.cpp Tue Feb 20 15:47:12 2018
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -verify %s
+
+namespace deduce_pack_non_pack {
+  template  class A;
+  template  struct C {};
+  template  void g(C); // expected-note {{candidate template 
ignored: deduced type 'C>' of 1st parameter does not 
match adjusted type 'C>' of argument [with T = bool]}}
+  void h(C> ) { g(x); } // expected-error {{no matching 
function}}
+}


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


[PATCH] D43533: [CFG] [analyzer] NFC: Refactor ConstructionContext into a finite set of cases.

2018-02-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 135154.
NoQ added a comment.

Remove unused methods.


https://reviews.llvm.org/D43533

Files:
  include/clang/Analysis/CFG.h
  include/clang/Analysis/ConstructionContext.h
  lib/Analysis/CFG.cpp
  lib/Analysis/CMakeLists.txt
  lib/Analysis/ConstructionContext.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp

Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -16,6 +16,7 @@
 #include "clang/AST/CXXInheritance.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/Analysis/Analyses/LiveVariables.h"
+#include "clang/Analysis/ConstructionContext.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "llvm/ADT/SmallSet.h"
@@ -635,10 +636,11 @@
 
 const CXXConstructExpr *CtorExpr = Ctor.getOriginExpr();
 
-auto CC = getCurrentCFGElement().getAs();
-const Stmt *ParentExpr = CC ? CC->getTriggerStmt() : nullptr;
+auto CCE = getCurrentCFGElement().getAs();
+const ConstructionContext *CC = CCE ? CCE->getConstructionContext()
+: nullptr;
 
-if (ParentExpr && isa(ParentExpr) &&
+if (CC && isa(CC) &&
 !Opts.mayInlineCXXAllocator())
   return CIP_DisallowedOnce;
 
Index: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -12,6 +12,7 @@
 //===--===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
+#include "clang/Analysis/ConstructionContext.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/ParentMap.h"
@@ -111,47 +112,20 @@
   // See if we're constructing an existing region by looking at the
   // current construction context.
   if (CC) {
-if (const Stmt *TriggerStmt = CC->getTriggerStmt()) {
-  if (const CXXNewExpr *CNE = dyn_cast(TriggerStmt)) {
-if (AMgr.getAnalyzerOptions().mayInlineCXXAllocator()) {
-  // TODO: Detect when the allocator returns a null pointer.
-  // Constructor shall not be called in this case.
-  if (const SubRegion *MR = dyn_cast_or_null(
-  getCXXNewAllocatorValue(State, CNE, LCtx).getAsRegion())) {
-if (CNE->isArray()) {
-  // TODO: In fact, we need to call the constructor for every
-  // allocated element, not just the first one!
-  CallOpts.IsArrayCtorOrDtor = true;
-  return getStoreManager().GetElementZeroRegion(
-  MR, CNE->getType()->getPointeeType());
-}
-return MR;
-  }
-}
-  } else if (auto *DS = dyn_cast(TriggerStmt)) {
-const auto *Var = cast(DS->getSingleDecl());
-SVal LValue = State->getLValue(Var, LCtx);
-QualType Ty = Var->getType();
-LValue = makeZeroElementRegion(State, LValue, Ty,
-   CallOpts.IsArrayCtorOrDtor);
-return LValue.getAsRegion();
-  } else if (isa(TriggerStmt)) {
-// TODO: We should construct into a CXXBindTemporaryExpr or a
-// MaterializeTemporaryExpr around the call-expression on the previous
-// stack frame. Currently we re-bind the temporary to the correct region
-// later, but that's not semantically correct. This of course does not
-// apply when we're in the top frame. But if we are in an inlined
-// function, we should be able to take the call-site CFG element,
-// and it should contain (but right now it wouldn't) some sort of
-// construction context that'd give us the right temporary expression.
-CallOpts.IsTemporaryCtorOrDtor = true;
-return MRMgr.getCXXTempObjectRegion(CE, LCtx);
-  } else if (isa(TriggerStmt)) {
-CallOpts.IsTemporaryCtorOrDtor = true;
-return MRMgr.getCXXTempObjectRegion(CE, LCtx);
-  }
-  // TODO: Consider other directly initialized elements.
-} else if (const CXXCtorInitializer *Init = CC->getTriggerInit()) {
+switch (CC->getKind()) {
+case ConstructionContext::SimpleVariableKind: {
+  const auto *DSCC = cast(CC);
+  const auto *DS = DSCC->getDeclStmt();
+  const auto *Var = cast(DS->getSingleDecl());
+  SVal LValue = State->getLValue(Var, LCtx);
+  QualType Ty = Var->getType();
+  LValue =
+  makeZeroElementRegion(State, LValue, Ty, CallOpts.IsArrayCtorOrDtor);
+  return LValue.getAsRegion();
+}
+case ConstructionContext::ConstructorInitializerKind: {
+  const auto *ICC = cast(CC);
+  const auto *Init = 

[PATCH] D43533: [CFG] [analyzer] NFC: Refactor ConstructionContext into a finite set of cases.

2018-02-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet.
Herald added subscribers: cfe-commits, rnkovacs, mgorny.
NoQ added a dependency: D43497: [analyzer] Introduce correct lifetime extension 
behavior in simple cases..

`ConstructionContext` is moved into a separate translation unit and is 
separated into multiple classes.

The "old" "raw" `ConstructionContext` is renamed into 
`ConstructionContextLayer` - which corresponds to the idea of building the 
context gradually layer-by-layer, but it isn't easy to use in the clients. Once 
`CXXConstructExpr` is reached, layers that we've gathered so far are 
transformed into the actual, "new-style" "flat" `ConstructionContext`, which is 
put into the `CFGConstructor` element and has no layers whatsoever (until it 
actually needs them, eg. aggregate initialization). The new-style 
`ConstructionContext` is instead presented as a variety of sub-classes that 
enumerate different ways of constructing an object in C++. There are 5 (five) 
of these supported for now, which is around a half of what needs to be 
supported.

The layer-by-layer buildup process is still a bit weird, but it's pretty 
functional with all the immutable stuff and pattern-matching, and i'm not 
seeing any easy alternatives.


Repository:
  rC Clang

https://reviews.llvm.org/D43533

Files:
  include/clang/Analysis/CFG.h
  include/clang/Analysis/ConstructionContext.h
  lib/Analysis/CFG.cpp
  lib/Analysis/CMakeLists.txt
  lib/Analysis/ConstructionContext.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp

Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -16,6 +16,7 @@
 #include "clang/AST/CXXInheritance.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/Analysis/Analyses/LiveVariables.h"
+#include "clang/Analysis/ConstructionContext.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "llvm/ADT/SmallSet.h"
@@ -635,10 +636,11 @@
 
 const CXXConstructExpr *CtorExpr = Ctor.getOriginExpr();
 
-auto CC = getCurrentCFGElement().getAs();
-const Stmt *ParentExpr = CC ? CC->getTriggerStmt() : nullptr;
+auto CCE = getCurrentCFGElement().getAs();
+const ConstructionContext *CC = CCE ? CCE->getConstructionContext()
+: nullptr;
 
-if (ParentExpr && isa(ParentExpr) &&
+if (CC && isa(CC) &&
 !Opts.mayInlineCXXAllocator())
   return CIP_DisallowedOnce;
 
Index: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -12,6 +12,7 @@
 //===--===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
+#include "clang/Analysis/ConstructionContext.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/ParentMap.h"
@@ -111,47 +112,20 @@
   // See if we're constructing an existing region by looking at the
   // current construction context.
   if (CC) {
-if (const Stmt *TriggerStmt = CC->getTriggerStmt()) {
-  if (const CXXNewExpr *CNE = dyn_cast(TriggerStmt)) {
-if (AMgr.getAnalyzerOptions().mayInlineCXXAllocator()) {
-  // TODO: Detect when the allocator returns a null pointer.
-  // Constructor shall not be called in this case.
-  if (const SubRegion *MR = dyn_cast_or_null(
-  getCXXNewAllocatorValue(State, CNE, LCtx).getAsRegion())) {
-if (CNE->isArray()) {
-  // TODO: In fact, we need to call the constructor for every
-  // allocated element, not just the first one!
-  CallOpts.IsArrayCtorOrDtor = true;
-  return getStoreManager().GetElementZeroRegion(
-  MR, CNE->getType()->getPointeeType());
-}
-return MR;
-  }
-}
-  } else if (auto *DS = dyn_cast(TriggerStmt)) {
-const auto *Var = cast(DS->getSingleDecl());
-SVal LValue = State->getLValue(Var, LCtx);
-QualType Ty = Var->getType();
-LValue = makeZeroElementRegion(State, LValue, Ty,
-   CallOpts.IsArrayCtorOrDtor);
-return LValue.getAsRegion();
-  } else if (isa(TriggerStmt)) {
-// TODO: We should construct into a CXXBindTemporaryExpr or a
-// MaterializeTemporaryExpr around the call-expression on the previous
-// stack frame. Currently we re-bind the temporary to the correct region
-// later, but that's not semantically correct. This of course does not
-// apply when 

[PATCH] D39571: [clangd] DidChangeConfiguration Notification

2018-02-20 Thread Simon Marchi via Phabricator via cfe-commits
simark updated this revision to Diff 135153.
simark added a comment.

New version, take 2

The previous version contains the changes of already merged patches, I'm not
sure what I did wrong.  This is another try.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D39571

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/DraftStore.cpp
  clangd/DraftStore.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -7,6 +7,7 @@
 //
 //===--===//
 
+#include "Annotations.h"
 #include "ClangdLSPServer.h"
 #include "ClangdServer.h"
 #include "Matchers.h"
@@ -77,6 +78,39 @@
   VFSTag LastVFSTag = VFSTag();
 };
 
+// For each file, record whether the last published diagnostics contained at
+// least one error.
+class MultipleErrorCHeckingDiagConsumer : public DiagnosticsConsumer {
+public:
+  void
+  onDiagnosticsReady(PathRef File,
+ Tagged Diagnostics) override {
+bool HadError = diagsContainErrors(Diagnostics.Value);
+
+std::lock_guard Lock(Mutex);
+LastDiagsHadError[File] = HadError;
+  }
+
+  bool contains(PathRef P) {
+std::lock_guard Lock(Mutex);
+return LastDiagsHadError.find(P) != LastDiagsHadError.end();
+  }
+
+  bool lastHadError(PathRef P) {
+std::lock_guard Lock(Mutex);
+return LastDiagsHadError[P];
+  }
+
+  void clear() {
+std::lock_guard Lock(Mutex);
+LastDiagsHadError.clear();
+  }
+
+private:
+  std::mutex Mutex;
+  std::map LastDiagsHadError;
+};
+
 /// Replaces all patterns of the form 0x123abc with spaces
 std::string replacePtrsInDump(std::string const ) {
   llvm::Regex RE("0x[0-9a-fA-F]+");
@@ -413,6 +447,78 @@
   EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
 }
 
+// Test ClangdServer.reparseOpenedFiles.
+TEST_F(ClangdVFSTest, ReparseOpenedFiles) {
+  Annotations FooSource(R"cpp(
+#ifdef MACRO
+$one[[static void bob() {}]]
+#else
+$two[[static void bob() {}]]
+#endif
+
+int main () { bo^b (); return 0; }
+)cpp");
+
+  Annotations BarSource(R"cpp(
+#ifdef MACRO
+this is an error
+#endif
+)cpp");
+
+  Annotations BazSource(R"cpp(
+int hello;
+)cpp");
+
+  MockFSProvider FS;
+  MockCompilationDatabase CDB;
+  MultipleErrorCHeckingDiagConsumer DiagConsumer;
+  ClangdServer Server(CDB, DiagConsumer, FS,
+  /*AsyncThreadsCount=*/0,
+  /*StorePreamblesInMemory=*/true);
+
+  auto FooCpp = testPath("foo.cpp");
+  auto BarCpp = testPath("bar.cpp");
+  auto BazCpp = testPath("baz.cpp");
+
+  FS.Files[FooCpp] = "";
+  FS.Files[BarCpp] = "";
+  FS.Files[BazCpp] = "";
+
+  CDB.ExtraClangFlags = {"-DMACRO=1"};
+  Server.addDocument(FooCpp, FooSource.code());
+  Server.addDocument(BarCpp, BarSource.code());
+  Server.addDocument(BazCpp, BazSource.code());
+
+  EXPECT_TRUE(DiagConsumer.contains(FooCpp));
+  EXPECT_TRUE(DiagConsumer.contains(BarCpp));
+  EXPECT_TRUE(DiagConsumer.contains(BazCpp));
+  EXPECT_FALSE(DiagConsumer.lastHadError(FooCpp));
+  EXPECT_TRUE(DiagConsumer.lastHadError(BarCpp));
+  EXPECT_FALSE(DiagConsumer.lastHadError(BazCpp));
+
+  auto Locations = runFindDefinitions(Server, FooCpp, FooSource.point());
+  EXPECT_TRUE(bool(Locations));
+  EXPECT_THAT(Locations->Value, ElementsAre(Location{URIForFile{FooCpp},
+ FooSource.range("one")}));
+
+  // Undefine MACRO, close baz.cpp.
+  CDB.ExtraClangFlags.clear();
+  DiagConsumer.clear();
+  Server.removeDocument(BazCpp);
+  Server.reparseOpenedFiles();
+
+  EXPECT_TRUE(DiagConsumer.contains(FooCpp));
+  EXPECT_TRUE(DiagConsumer.contains(BarCpp));
+  EXPECT_FALSE(DiagConsumer.contains(BazCpp));
+  EXPECT_FALSE(DiagConsumer.lastHadError(FooCpp));
+  EXPECT_FALSE(DiagConsumer.lastHadError(BarCpp));
+
+  Locations = runFindDefinitions(Server, FooCpp, FooSource.point());
+  EXPECT_TRUE(bool(Locations));
+  EXPECT_THAT(Locations->Value, ElementsAre(Location{URIForFile{FooCpp},
+ FooSource.range("two")}));
+}
+
 TEST_F(ClangdVFSTest, MemoryUsage) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
Index: clangd/ProtocolHandlers.h
===
--- clangd/ProtocolHandlers.h
+++ clangd/ProtocolHandlers.h
@@ -52,6 +52,7 @@
   virtual void onRename(RenameParams ) = 0;
   virtual void onDocumentHighlight(TextDocumentPositionParams ) = 0;
   virtual void onHover(TextDocumentPositionParams ) = 0;
+  virtual void onChangeConfiguration(DidChangeConfigurationParams ) = 0;
 };
 
 

r325640 - When multiple sanitizers are enabled (ubsan + something else), use all relevant blacklists.

2018-02-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Feb 20 15:17:41 2018
New Revision: 325640

URL: http://llvm.org/viewvc/llvm-project?rev=325640=rev
Log:
When multiple sanitizers are enabled (ubsan + something else), use all relevant 
blacklists.

Ideally, we'd only use the ubsan blacklist for ubsan sanitizers, and only use
the other-sanitizer blacklist for its sanitizers, but this at least enables the
intended suppressions.

Modified:
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/test/Driver/fsanitize-blacklist.c

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=325640=325639=325640=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Tue Feb 20 15:17:41 2018
@@ -92,31 +92,28 @@ static std::string describeSanitizeArg(c
 /// Sanitizers set.
 static std::string toString(const clang::SanitizerSet );
 
-static bool getDefaultBlacklist(const Driver , SanitizerMask Kinds,
-std::string ) {
-  const char *BlacklistFile = nullptr;
-  if (Kinds & Address)
-BlacklistFile = "asan_blacklist.txt";
-  else if (Kinds & HWAddress)
-BlacklistFile = "hwasan_blacklist.txt";
-  else if (Kinds & Memory)
-BlacklistFile = "msan_blacklist.txt";
-  else if (Kinds & Thread)
-BlacklistFile = "tsan_blacklist.txt";
-  else if (Kinds & DataFlow)
-BlacklistFile = "dfsan_abilist.txt";
-  else if (Kinds & CFI)
-BlacklistFile = "cfi_blacklist.txt";
-  else if (Kinds & (Undefined | Integer | Nullability))
-BlacklistFile = "ubsan_blacklist.txt";
+static void addDefaultBlacklists(const Driver , SanitizerMask Kinds,
+ std::vector ) {
+  struct Blacklist {
+const char *File;
+SanitizerMask Mask;
+  } Blacklists[] = {{"asan_blacklist.txt", Address},
+{"hwasan_blacklist.txt", HWAddress},
+{"msan_blacklist.txt", Memory},
+{"tsan_blacklist.txt", Thread},
+{"dfsan_abilist.txt", DataFlow},
+{"cfi_blacklist.txt", CFI},
+{"ubsan_blacklist.txt", Undefined | Integer | 
Nullability}};
+
+  for (auto BL : Blacklists) {
+if (!(Kinds & BL.Mask))
+  continue;
 
-  if (BlacklistFile) {
 clang::SmallString<64> Path(D.ResourceDir);
-llvm::sys::path::append(Path, "share", BlacklistFile);
-BLPath = Path.str();
-return true;
+llvm::sys::path::append(Path, "share", BL.File);
+if (llvm::sys::fs::exists(Path))
+  BlacklistFiles.push_back(Path.str());
   }
-  return false;
 }
 
 /// Sets group bits for every group that has at least one representative 
already
@@ -444,11 +441,7 @@ SanitizerArgs::SanitizerArgs(const ToolC
 
   // Setup blacklist files.
   // Add default blacklist from resource directory.
-  {
-std::string BLPath;
-if (getDefaultBlacklist(D, Kinds, BLPath) && llvm::sys::fs::exists(BLPath))
-  BlacklistFiles.push_back(BLPath);
-  }
+  addDefaultBlacklists(D, Kinds, BlacklistFiles);
   // Parse -f(no-)sanitize-blacklist options.
   for (const auto *Arg : Args) {
 if (Arg->getOption().matches(options::OPT_fsanitize_blacklist)) {
@@ -457,9 +450,9 @@ SanitizerArgs::SanitizerArgs(const ToolC
   if (llvm::sys::fs::exists(BLPath)) {
 BlacklistFiles.push_back(BLPath);
 ExtraDeps.push_back(BLPath);
-  } else
+  } else {
 D.Diag(clang::diag::err_drv_no_such_file) << BLPath;
-
+  }
 } else if (Arg->getOption().matches(options::OPT_fno_sanitize_blacklist)) {
   Arg->claim();
   BlacklistFiles.clear();

Modified: cfe/trunk/test/Driver/fsanitize-blacklist.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize-blacklist.c?rev=325640=325639=325640=diff
==
--- cfe/trunk/test/Driver/fsanitize-blacklist.c (original)
+++ cfe/trunk/test/Driver/fsanitize-blacklist.c Tue Feb 20 15:17:41 2018
@@ -21,17 +21,20 @@
 // CHECK-BLACKLIST2: -fdepfile-entry={{.*}}.good" 
"-fdepfile-entry={{.*}}.second
 
 // Check that the default blacklist is not added as an extra dependency.
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-DEFAULT-BLACKLIST-ASAN --implicit-check-not=fdepfile-entry
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-DEFAULT-BLACKLIST-ASAN --implicit-check-not=fdepfile-entry 
--implicit-check-not=-fsanitize-blacklist=
 // CHECK-DEFAULT-BLACKLIST-ASAN: 
-fsanitize-blacklist={{.*[^w]}}asan_blacklist.txt
-// RUN: %clang -target aarch64-linux-gnu -fsanitize=hwaddress 
-resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s 

[PATCH] D43494: [Modules] Fix creating fake definition data for lambdas.

2018-02-20 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added inline comments.



Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:2969
 
+if (!DD && RD->isBeingDefined())
+  return nullptr;

vsapsai wrote:
> aprantl wrote:
> > Perhaps add a comment explaining what's going on in this early exit?
> While I was trying to explain this early exit, I realized one of my 
> assumptions was incorrect. Now I'm not sure returning nullptr is the right 
> fix, maybe assigning incomplete definition data like
> 
> ```lang=c++
> D->DefinitionData = DD;
> ReadCXXDefinitionData(*DD, D);
> ```
> is better.
> 
> I am trying to come up with a test case showing different behaviour for these 
> 2 different fixes. But so far nothing yet. If anybody can tell which one is 
> correct: null context for merging or not-yet-populated definition data, that 
> would be helpful.
Looks like both fix approaches should work as in 
`ASTDeclReader::ReadCXXDefinitionData` we read decl only for lambda. If I'm not 
mistaken, for lambdas merging doesn't really make sense, so no context for 
merging doesn't have repercussions.


https://reviews.llvm.org/D43494



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


r325633 - [NFC] In Multiversion Check function, switch to return Diag

2018-02-20 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Feb 20 14:25:28 2018
New Revision: 325633

URL: http://llvm.org/viewvc/llvm-project?rev=325633=rev
Log:
[NFC] In Multiversion Check function, switch to return Diag

This function did a lot of 'Diag, return true' stuff.  This resulted in needing
to introduce scopes in quite a few places.  This patch replaces useages of a
single "S.Diag" followed by return true with simply "return S.Diag".

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

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=325633=325632=325633=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Feb 20 14:25:28 2018
@@ -9225,62 +9225,49 @@ static bool CheckMultiVersionAdditionalR
 return true;
   }
 
-  if (std::distance(NewFD->attr_begin(), NewFD->attr_end()) != 1) {
-S.Diag(NewFD->getLocation(), diag::err_multiversion_no_other_attrs);
-return true;
-  }
-
-  if (NewFD->getTemplatedKind() == FunctionDecl::TK_FunctionTemplate) {
-S.Diag(NewFD->getLocation(), diag::err_multiversion_doesnt_support)
-<< FuncTemplates;
-return true;
-  }
+  if (std::distance(NewFD->attr_begin(), NewFD->attr_end()) != 1)
+return S.Diag(NewFD->getLocation(), diag::err_multiversion_no_other_attrs);
 
+  if (NewFD->getTemplatedKind() == FunctionDecl::TK_FunctionTemplate)
+return S.Diag(NewFD->getLocation(), diag::err_multiversion_doesnt_support)
+   << FuncTemplates;
 
   if (const auto *NewCXXFD = dyn_cast(NewFD)) {
-if (NewCXXFD->isVirtual()) {
-  S.Diag(NewCXXFD->getLocation(), diag::err_multiversion_doesnt_support)
-  << VirtFuncs;
-  return true;
-}
-
-if (const auto *NewCXXCtor = dyn_cast(NewFD)) {
-  S.Diag(NewCXXCtor->getLocation(), diag::err_multiversion_doesnt_support)
-  << Constructors;
-  return true;
-}
-
-if (const auto *NewCXXDtor = dyn_cast(NewFD)) {
-  S.Diag(NewCXXDtor->getLocation(), diag::err_multiversion_doesnt_support)
-  << Destructors;
-  return true;
-}
-  }
-
-  if (NewFD->isDeleted()) {
-S.Diag(NewFD->getLocation(), diag::err_multiversion_doesnt_support)
-  << DeletedFuncs;
-  }
-  if (NewFD->isDefaulted()) {
-S.Diag(NewFD->getLocation(), diag::err_multiversion_doesnt_support)
-  << DefaultedFuncs;
-  }
+if (NewCXXFD->isVirtual())
+  return S.Diag(NewCXXFD->getLocation(),
+diag::err_multiversion_doesnt_support)
+ << VirtFuncs;
+
+if (const auto *NewCXXCtor = dyn_cast(NewFD))
+  return S.Diag(NewCXXCtor->getLocation(),
+diag::err_multiversion_doesnt_support)
+ << Constructors;
+
+if (const auto *NewCXXDtor = dyn_cast(NewFD))
+  return S.Diag(NewCXXDtor->getLocation(),
+diag::err_multiversion_doesnt_support)
+ << Destructors;
+  }
+
+  if (NewFD->isDeleted())
+return S.Diag(NewFD->getLocation(), diag::err_multiversion_doesnt_support)
+   << DeletedFuncs;
+
+  if (NewFD->isDefaulted())
+return S.Diag(NewFD->getLocation(), diag::err_multiversion_doesnt_support)
+   << DefaultedFuncs;
 
   QualType NewQType = S.getASTContext().getCanonicalType(NewFD->getType());
   const auto *NewType = cast(NewQType);
   QualType NewReturnType = NewType->getReturnType();
 
-  if (NewReturnType->isUndeducedType()) {
-S.Diag(NewFD->getLocation(), diag::err_multiversion_doesnt_support)
-<< DeducedReturn;
-return true;
-  }
+  if (NewReturnType->isUndeducedType())
+return S.Diag(NewFD->getLocation(), diag::err_multiversion_doesnt_support)
+   << DeducedReturn;
 
   // Only allow transition to MultiVersion if it hasn't been used.
-  if (OldFD && CausesMV && OldFD->isUsed(false)) {
-S.Diag(NewFD->getLocation(), diag::err_multiversion_after_used);
-return true;
-  }
+  if (OldFD && CausesMV && OldFD->isUsed(false))
+return S.Diag(NewFD->getLocation(), diag::err_multiversion_after_used);
 
   // Ensure the return type is identical.
   if (OldFD) {
@@ -9289,38 +9276,31 @@ static bool CheckMultiVersionAdditionalR
 FunctionType::ExtInfo OldTypeInfo = OldType->getExtInfo();
 FunctionType::ExtInfo NewTypeInfo = NewType->getExtInfo();
 
-if (OldTypeInfo.getCC() != NewTypeInfo.getCC()) {
-  S.Diag(NewFD->getLocation(), diag::err_multiversion_diff) << CallingConv;
-  return true;
-}
+if (OldTypeInfo.getCC() != NewTypeInfo.getCC())
+  return S.Diag(NewFD->getLocation(), diag::err_multiversion_diff)
+ << CallingConv;
 
 QualType OldReturnType = OldType->getReturnType();
 
-if (OldReturnType != NewReturnType) {
-  S.Diag(NewFD->getLocation(), diag::err_multiversion_diff) << ReturnType;
-  return true;
-}
-
-if (OldFD->isConstexpr() != NewFD->isConstexpr()) {
-  

[PATCH] D42217: Set Module Metadata "AvoidPLT" when -fno-plt is used.

2018-02-20 Thread Sriraman Tallam via Phabricator via cfe-commits
tmsriram updated this revision to Diff 135144.
tmsriram added a comment.

Updated patch.


https://reviews.llvm.org/D42217

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGen/noplt.c


Index: test/CodeGen/noplt.c
===
--- test/CodeGen/noplt.c
+++ test/CodeGen/noplt.c
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 -emit-llvm -fno-plt %s -o - | FileCheck %s 
-check-prefix=CHECK-NOPLT
+// RUN: %clang_cc1 -emit-llvm -fno-plt %s -o - | FileCheck %s 
-check-prefix=CHECK-NOPLT -check-prefix=CHECK-NOPLT-METADATA
 
 // CHECK-NOPLT: Function Attrs: nonlazybind
 // CHECK-NOPLT-NEXT: declare {{.*}}i32 @foo
+// CHECK-NOPLT-METADATA: !"RtLibUseGOT"
 int foo();
 
 int bar() {
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -555,6 +555,10 @@
   getModule().setPIELevel(static_cast(PLevel));
   }
 
+  if (CodeGenOpts.NoPLT) {
+getModule().setRtLibUseGOT();
+  }
+
   SimplifyPersonality();
 
   if (getCodeGenOpts().EmitDeclMetadata)


Index: test/CodeGen/noplt.c
===
--- test/CodeGen/noplt.c
+++ test/CodeGen/noplt.c
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 -emit-llvm -fno-plt %s -o - | FileCheck %s -check-prefix=CHECK-NOPLT
+// RUN: %clang_cc1 -emit-llvm -fno-plt %s -o - | FileCheck %s -check-prefix=CHECK-NOPLT -check-prefix=CHECK-NOPLT-METADATA
 
 // CHECK-NOPLT: Function Attrs: nonlazybind
 // CHECK-NOPLT-NEXT: declare {{.*}}i32 @foo
+// CHECK-NOPLT-METADATA: !"RtLibUseGOT"
 int foo();
 
 int bar() {
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -555,6 +555,10 @@
   getModule().setPIELevel(static_cast(PLevel));
   }
 
+  if (CodeGenOpts.NoPLT) {
+getModule().setRtLibUseGOT();
+  }
+
   SimplifyPersonality();
 
   if (getCodeGenOpts().EmitDeclMetadata)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: r324991 - Fix for PR32992. Static const classes not exported.

2018-02-20 Thread Ammarguellat, Zahira via cfe-commits
Hello,

Please see https://reviews.llvm.org/D42968
For the fix of the assertion belwo.
Thanks.

-Original Message-
From: hwennb...@google.com [mailto:hwennb...@google.com] On Behalf Of Hans 
Wennborg
Sent: Tuesday, February 20, 2018 4:04 AM
To: Ammarguellat, Zahira 
Cc: cfe-commits 
Subject: Re: r324991 - Fix for PR32992. Static const classes not exported.

The problem is that your patch caused the reproducer to trigger an assert, 
which it didn't do before, causing our builds to break.

Your patch seems like it does fix the PR, but it can't break currently working 
builds.

$ build.release/bin/clang -cc1 -triple i386-pc-windows-msvc19.11.0 -emit-pch 
-fms-extensions -fms-compatibility
-fms-compatibility-version=19.11 -std=c++14 -fdelayed-template-parsing -x 
c++-header /tmp/a.cc -o /dev/null
clang: 
/work/llvm.combined/llvm/tools/clang/lib/Serialization/ASTWriter.cpp:4723:
clang::ASTFileSignature clang::ASTWriter::WriteASTCore(clang::Sema&,
llvm::StringRef, const string&, clang::Module*): Assertion
`SemaRef.PendingLocalImplicitInstantiations.empty() && "There are local ones at 
end of translation unit!"' failed.
build.release/bin/clang(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x1a)[0x55c535576aaa]
build.release/bin/clang(_ZN4llvm3sys17RunSignalHandlersEv+0x3e)[0x55c53557492e]
build.release/bin/clang(+0x2424a7c)[0x55c535574a7c]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x110c0)[0x7f4aeeb9d0c0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcf)[0x7f4aed732fcf]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f4aed7343fa]
/lib/x86_64-linux-gnu/libc.so.6(+0x2be37)[0x7f4aed72be37]
/lib/x86_64-linux-gnu/libc.so.6(+0x2bee2)[0x7f4aed72bee2]
build.release/bin/clang(_ZN5clang9ASTWriter12WriteASTCoreERNS_4SemaEN4llvm9StringRefERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPNS_6ModuleE+0x29fa)[0x55c536444cea]
build.release/bin/clang(_ZN5clang9ASTWriter8WriteASTERNS_4SemaERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPNS_6ModuleEN4llvm9StringRefEb+0xad)[0x55c536444dfd]
build.release/bin/clang(_ZN5clang12PCHGenerator21HandleTranslationUnitERNS_10ASTContextE+0x80)[0x55c536465fe0]
build.release/bin/clang(_ZN5clang17MultiplexConsumer21HandleTranslationUnitERNS_10ASTContextE+0x28)[0x55c535b53488]
build.release/bin/clang(_ZN5clang8ParseASTERNS_4SemaEbb+0x350)[0x55c5362c5d30]
build.release/bin/clang(_ZN5clang14FrontendAction7ExecuteEv+0x11e)[0x55c535b2958e]
build.release/bin/clang(_ZN5clang16CompilerInstance13ExecuteActionERNS_14FrontendActionE+0x176)[0x55c535af54d6]
build.release/bin/clang(_ZN5clang25ExecuteCompilerInvocationEPNS_16CompilerInstanceE+0x981)[0x55c535bc2561]
build.release/bin/clang(_Z8cc1_mainN4llvm8ArrayRefIPKcEES2_Pv+0xc50)[0x55c533e1a890]
build.release/bin/clang(main+0x1295)[0x55c533d9b585]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1)[0x7f4aed7202b1]
build.release/bin/clang(_start+0x2a)[0x55c533e1684a]
Stack dump:
0.  Program arguments: build.release/bin/clang -cc1 -triple
i386-pc-windows-msvc19.11.0 -emit-pch -fms-extensions -fms-compatibility 
-fms-compatibility-version=19.11 -std=c++14 -fdelayed-template-parsing -x 
c++-header /tmp/a.cc -o /dev/null
1.   parser at end of file
Aborted

On Mon, Feb 19, 2018 at 10:18 PM, Ammarguellat, Zahira 
 wrote:
> Hans,
>
>
>
> The reproducer below generates wrong export symbols compared to MSVC 
> but I am not sure it is related to my change.
>
> Compiling this with MSVC generates these symbols:
>
>
>
> ksh-3.2$ dumpbin /directives t3.obj | grep EXPORT
>
>/EXPORT:??4?$d@H@@QEAAAEAV0@AEBV0@@Z
>
>/EXPORT:??4?$d@H@@QEAAAEAV0@$$QEAV0@@Z
>
>/EXPORT:??4?$h@H@f@@QEAAAEAV01@AEBV01@@Z
>
>/EXPORT:??4?$h@H@f@@QEAAAEAV01@$$QEAV01@@Z
>
>/EXPORT:??4i@@QEAAAEAV0@AEBV0@@Z
>
>/EXPORT:??4i@@QEAAAEAV0@$$QEAV0@@Z
>
>
>
>
>
> Compiling with clang (my patches no included) generate these symbols:
>
> ksh-3.2$ dumpbin /directives t3.o | grep EXPORT
>
>/EXPORT:??4?$d@H@@QEAAAEAV0@AEBV0@@Z
>
>/EXPORT:??4?$d@H@@QEAAAEAV0@$$QEAV0@@Z
>
>/EXPORT:??4?$h@H@f@@QEAAAEAV01@AEBV01@@Z
>
>/EXPORT:??4?$h@H@f@@QEAAAEAV01@$$QEAV01@@Z
>
>/EXPORT:??4i@@QEAAAEAV0@AEBV0@@Z
>
>/EXPORT:??4i@@QEAAAEAV0@$$QEAV0@@Z
>
>/EXPORT:?e@?$d@H@@0W4b@a@@B,DATA   ç This is not generated in MSVC.
>
>
>
> Although this is a bug that needs to be fixes, it is in my opinion 
> un-related to the patches I have proposed.
>
>
>
> Your thoughts?
>
>
>
> Thanks.
>
> -Zahira
>
>
>
>
>
> -Original Message-
> From: hwennb...@google.com [mailto:hwennb...@google.com] On Behalf Of 
> Hans Wennborg
> Sent: Monday, February 19, 2018 5:11 AM
> To: cfe-commits ; Ammarguellat, Zahira 
> 
> Subject: Re: r324991 - Fix for PR32992. Static const classes not exported.
>
>
>
> Reduced repro:
>
>
>
> $ clang -cc1 -triple i386-pc-windows-msvc19.11.0 -emit-pch 
> -fms-extensions -fms-compatibility 

r325626 - [CUDA] Added missing __threadfence_system() function for CUDA9.

2018-02-20 Thread Artem Belevich via cfe-commits
Author: tra
Date: Tue Feb 20 13:25:30 2018
New Revision: 325626

URL: http://llvm.org/viewvc/llvm-project?rev=325626=rev
Log:
[CUDA] Added missing __threadfence_system() function for CUDA9.

Modified:
cfe/trunk/lib/Headers/__clang_cuda_device_functions.h

Modified: cfe/trunk/lib/Headers/__clang_cuda_device_functions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_device_functions.h?rev=325626=325625=325626=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_device_functions.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_device_functions.h Tue Feb 20 13:25:30 
2018
@@ -530,6 +530,7 @@ __DEVICE__ int __syncthreads_or(int __a)
 __DEVICE__ float __tanf(float __a) { return __nv_fast_tanf(__a); }
 __DEVICE__ void __threadfence(void) { __nvvm_membar_gl(); }
 __DEVICE__ void __threadfence_block(void) { __nvvm_membar_cta(); };
+__DEVICE__ void __threadfence_system(void) { __nvvm_membar_sys(); };
 __DEVICE__ void __trap(void) { asm volatile("trap;"); }
 __DEVICE__ unsigned int __uAtomicAdd(unsigned int *__p, unsigned int __v) {
   return __nvvm_atom_add_gen_i((int *)__p, __v);


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


[PATCH] D43105: [RISCV] Enable __int128_t and uint128_t through clang flag

2018-02-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM

Please post a follow-up to add this to the 7.0 release notes.


Repository:
  rC Clang

https://reviews.llvm.org/D43105



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


[PATCH] D43522: [clang-format] New API guessLanguage()

2018-02-20 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added a reviewer: jolesiak.
Herald added subscribers: cfe-commits, klimek.
benhamilton added a reviewer: krasimir.

For clients which don't have a filesystem, calling getStyle() doesn't
make much sense (there's no .clang-format files to search for).

In this diff, I hoist out the language-guessing logic from getStyle()
and move it into a new API guessLanguage().

I also added support for guessing the language of files which have no
extension (they could be C++ or ObjC).

Test Plan: New tests added. Ran tests with:

  % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests


Repository:
  rC Clang

https://reviews.llvm.org/D43522

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11952,6 +11952,34 @@
   verifyFormat("auto const &[ a, b ] = f();", Spaces);
 }
 
+struct GuessLanguageTestCase {
+  const char *const FileName;
+  const char *const Code;
+  const FormatStyle::LanguageKind ExpectedResult;
+};
+
+class GuessLanguageTest
+: public FormatTest,
+  public ::testing::WithParamInterface {};
+
+TEST_P(GuessLanguageTest, FileAndCode) {
+  auto TestCase = GetParam();
+  EXPECT_EQ(TestCase.ExpectedResult,
+guessLanguage(TestCase.FileName, TestCase.Code));
+}
+
+static const GuessLanguageTestCase TestCases[] = {
+{"foo.cc", "", FormatStyle::LK_Cpp},
+{"foo.m", "", FormatStyle::LK_ObjC},
+{"foo.mm", "", FormatStyle::LK_ObjC},
+{"foo.h", "", FormatStyle::LK_Cpp},
+{"foo.h", "@interface Foo\n@end\n", FormatStyle::LK_ObjC},
+{"foo", "", FormatStyle::LK_Cpp},
+{"foo", "@interface Foo\n@end\n", FormatStyle::LK_ObjC},
+};
+INSTANTIATE_TEST_CASE_P(ValidLanguages, GuessLanguageTest,
+::testing::ValuesIn(TestCases));
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -2294,24 +2294,33 @@
   return FormatStyle::LK_Cpp;
 }
 
+FormatStyle::LanguageKind guessLanguage(StringRef FileName, StringRef Code) {
+  FormatStyle::LanguageKind result = getLanguageByFileName(FileName);
+  if (result == FormatStyle::LK_Cpp) {
+auto extension = llvm::sys::path::extension(FileName);
+// If there's no file extension (or it's .h), we need to check the contents
+// of the code to see if it contains Objective-C.
+if (extension.empty() || extension == ".h") {
+  std::unique_ptr Env =
+  Environment::CreateVirtualEnvironment(Code, FileName, /*Ranges=*/{});
+  ObjCHeaderStyleGuesser Guesser(*Env, getLLVMStyle());
+  Guesser.process();
+  if (Guesser.isObjC()) {
+result = FormatStyle::LK_ObjC;
+  }
+}
+  }
+  return result;
+}
+
 llvm::Expected getStyle(StringRef StyleName, StringRef FileName,
  StringRef FallbackStyleName,
  StringRef Code, vfs::FileSystem *FS) {
   if (!FS) {
 FS = vfs::getRealFileSystem().get();
   }
   FormatStyle Style = getLLVMStyle();
-  Style.Language = getLanguageByFileName(FileName);
-
-  if (Style.Language == FormatStyle::LK_Cpp && FileName.endswith(".h")) {
-std::unique_ptr Env =
-Environment::CreateVirtualEnvironment(Code, FileName, /*Ranges=*/{});
-ObjCHeaderStyleGuesser Guesser(*Env, Style);
-Guesser.process();
-if (Guesser.isObjC()) {
-  Style.Language = FormatStyle::LK_ObjC;
-}
-  }
+  Style.Language = guessLanguage(FileName, Code);
 
   FormatStyle FallbackStyle = getNoStyle();
   if (!getPredefinedStyle(FallbackStyleName, Style.Language, ))
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -1981,6 +1981,10 @@
  StringRef Code = "",
  vfs::FileSystem *FS = nullptr);
 
+// \brief Guesses the language from the ``FileName`` and ``Code`` to be formatted.
+// Defaults to FormatStyle::LK_Cpp.
+FormatStyle::LanguageKind guessLanguage(StringRef FileName, StringRef Code);
+
 // \brief Returns a string representation of ``Language``.
 inline StringRef getLanguageName(FormatStyle::LanguageKind Language) {
   switch (Language) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43500: [clang-tidy]: modernize-use-default-member-init: Remove trailing comma and colon.

2018-02-20 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D43500#1013497, @aaron.ballman wrote:

> Is there a way to make clang-apply-replacements smarter rather than forcing 
> every check to jump through hoops? I'm worried that if we have to fix 
> individual checks we'll just run into the same bug later.


See http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20161017/174238.html


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43500



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


[PATCH] D43423: [SimplifyCFG] Create flag to disable simplifyCFG.

2018-02-20 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc added a comment.

We use function attributes in similar situations for asan/tsan/msan. 
Similar, but not equivalent, so I don't know if we must follow the same pattern 
here. 
The difference here is that we should keep the ability to turn optimization on 
and off from command line, regardless of what are the coverage instrumentation 
flags.

IIRC, the *function* metadata is not that easily stripped (as opposed to 
metadata attached to instructions).


https://reviews.llvm.org/D43423



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


[PATCH] D40988: Clang-format: add finer-grained options for putting all arguments on one line

2018-02-20 Thread Russell McClellan via Phabricator via cfe-commits
russellmcc added a comment.

Bumping again - thanks so much for your time!


https://reviews.llvm.org/D40988



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


[clang-tools-extra] r325596 - [clangd] Fix formatting in XRefs.cpp

2018-02-20 Thread Simon Marchi via cfe-commits
Author: simark
Date: Tue Feb 20 08:57:47 2018
New Revision: 325596

URL: http://llvm.org/viewvc/llvm-project?rev=325596=rev
Log:
[clangd] Fix formatting in XRefs.cpp

This is also to test my commit access.


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

Modified: clang-tools-extra/trunk/clangd/XRefs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/XRefs.cpp?rev=325596=325595=325596=diff
==
--- clang-tools-extra/trunk/clangd/XRefs.cpp (original)
+++ clang-tools-extra/trunk/clangd/XRefs.cpp Tue Feb 20 08:57:47 2018
@@ -21,7 +21,7 @@ namespace {
 // Get the definition from a given declaration `D`.
 // Return nullptr if no definition is found, or the declaration type of `D` is
 // not supported.
-const Decl* GetDefinition(const Decl* D) {
+const Decl *GetDefinition(const Decl *D) {
   assert(D);
   if (const auto *TD = dyn_cast(D))
 return TD->getDefinition();
@@ -85,7 +85,7 @@ public:
   // We don't use parameter `D`, as Parameter `D` is the canonical
   // declaration, which is the first declaration of a redeclarable
   // declaration, and it could be a forward declaration.
-  if (const auto* Def = GetDefinition(D)) {
+  if (const auto *Def = GetDefinition(D)) {
 Decls.push_back(Def);
   } else {
 // Couldn't find a definition, fall back to use `D`.


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


[PATCH] D43105: [RISCV] Enable __int128_t and uint128_t through clang flag

2018-02-20 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang updated this revision to Diff 135112.
mgrang added a comment.

Updated patch to add -fno version of the flag -fforce-enable-int128.


Repository:
  rC Clang

https://reviews.llvm.org/D43105

Files:
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/TargetOptions.h
  include/clang/Driver/Options.td
  lib/Basic/Targets/Mips.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/types.c

Index: test/Driver/types.c
===
--- /dev/null
+++ test/Driver/types.c
@@ -0,0 +1,18 @@
+// Check whether __int128_t and __uint128_t are supported.
+
+// RUN: not %clang -c --target=riscv32-unknown-linux-gnu -fsyntax-only %s \
+// RUN: 2>&1 | FileCheck %s
+
+// RUN: %clang -c --target=riscv32-unknown-linux-gnu -fsyntax-only %s \
+// RUN: -fno-force-enable-int128 -fforce-enable-int128
+
+// RUN: not %clang -c --target=riscv32-unknown-linux-gnu -fsyntax-only %s \
+// RUN: -fforce-enable-int128 -fno-force-enable-int128
+
+void a() {
+  __int128_t s;
+  __uint128_t t;
+}
+
+// CHECK: error: use of undeclared identifier '__int128_t'
+// CHECK: error: use of undeclared identifier '__uint128_t'
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2765,6 +2765,7 @@
   if (Opts.Triple.empty())
 Opts.Triple = llvm::sys::getDefaultTargetTriple();
   Opts.OpenCLExtensionsAsWritten = Args.getAllArgValues(OPT_cl_ext_EQ);
+  Opts.ForceEnableInt128 = Args.hasArg(OPT_fforce_enable_int128);
 }
 
 bool CompilerInvocation::CreateFromArgs(CompilerInvocation ,
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4725,6 +4725,12 @@
 }
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_fforce_enable_int128,
+   options::OPT_fno_force_enable_int128)) {
+if (A->getOption().matches(options::OPT_fforce_enable_int128))
+  CmdArgs.push_back("-fforce-enable-int128");
+  }
+
   // Finally add the compile command to the compilation.
   if (Args.hasArg(options::OPT__SLASH_fallback) &&
   Output.getType() == types::TY_Object &&
Index: lib/Basic/Targets/Mips.h
===
--- lib/Basic/Targets/Mips.h
+++ lib/Basic/Targets/Mips.h
@@ -387,7 +387,9 @@
 return llvm::makeArrayRef(NewABIRegAliases);
   }
 
-  bool hasInt128Type() const override { return ABI == "n32" || ABI == "n64"; }
+  bool hasInt128Type() const override {
+return (ABI == "n32" || ABI == "n64") || getTargetOpts().ForceEnableInt128;
+  }
 
   bool validateTarget(DiagnosticsEngine ) const override;
 };
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -839,6 +839,12 @@
 def fjump_tables : Flag<["-"], "fjump-tables">, Group;
 def fno_jump_tables : Flag<["-"], "fno-jump-tables">, Group, Flags<[CC1Option]>,
   HelpText<"Do not use jump tables for lowering switches">;
+def fforce_enable_int128 : Flag<["-"], "fforce-enable-int128">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Enable support for int128_t type">;
+def fno_force_enable_int128 : Flag<["-"], "fno-force-enable-int128">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Disable support for int128_t type">;
 
 // Begin sanitizer flags. These should all be core options exposed in all driver
 // modes.
Index: include/clang/Basic/TargetOptions.h
===
--- include/clang/Basic/TargetOptions.h
+++ include/clang/Basic/TargetOptions.h
@@ -60,6 +60,9 @@
   /// \brief The list of OpenCL extensions to enable or disable, as written on
   /// the command line.
   std::vector OpenCLExtensionsAsWritten;
+
+  /// \brief If given, enables support for __int128_t and __uint128_t types.
+  bool ForceEnableInt128;
 };
 
 }  // end namespace clang
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -358,7 +358,7 @@
 
   /// \brief Determine whether the __int128 type is supported on this target.
   virtual bool hasInt128Type() const {
-return getPointerWidth(0) >= 64;
+return (getPointerWidth(0) >= 64) || getTargetOpts().ForceEnableInt128;
   } // FIXME
 
   /// \brief Determine whether the __float128 type is supported on this target.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43500: [clang-tidy]: modernize-use-default-member-init: Remove trailing comma and colon.

2018-02-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

> It seems, when they are apply directly from clang-tidy, the RefactoringTool 
> engine is smart enough to remove trailing tokens. However, when fixes are 
> exported, clang-apply-replacements cannot do the same trick and will lead 
> trailing commas and colon

Is there a way to make clang-apply-replacements smarter rather than forcing 
every check to jump through hoops? I'm worried that if we have to fix 
individual checks we'll just run into the same bug later.




Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:26
+   tok::TokenKind K) {
+  for (;;) {
+Token Tok = utils::lexer::getPreviousToken(*Context, Location);

Eugene.Zelenko wrote:
> Please use while (true) instead.
Better still, don't use an infinite loop.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43500



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


[PATCH] D34367: CodeGen: Fix address space of indirect function argument

2018-02-20 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 135109.
yaxunl added a comment.

Extends NeedsCopy of CallArg for indirect byval arguments.


https://reviews.llvm.org/D34367

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGCall.h
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGObjCGNU.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/amdgcn-func-arg.cpp
  test/CodeGenOpenCL/addr-space-struct-arg.cl
  test/CodeGenOpenCL/byval.cl

Index: test/CodeGenOpenCL/byval.cl
===
--- test/CodeGenOpenCL/byval.cl
+++ test/CodeGenOpenCL/byval.cl
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn %s | FileCheck %s
-// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn---opencl %s | FileCheck %s
 
 struct A {
   int x[100];
Index: test/CodeGenOpenCL/addr-space-struct-arg.cl
===
--- test/CodeGenOpenCL/addr-space-struct-arg.cl
+++ test/CodeGenOpenCL/addr-space-struct-arg.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -ffake-address-space-map -triple i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=COM,X86 %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -triple amdgcn-amdhsa-amd-amdgizcl | FileCheck -enable-var-scope -check-prefixes=COM,AMD %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -triple amdgcn-amdhsa-amd | FileCheck -enable-var-scope -check-prefixes=COM,AMD %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL2.0 -O0 -finclude-default-header -triple amdgcn-amdhsa-amd | FileCheck -enable-var-scope -check-prefixes=COM,AMD,AMD20 %s
 
 typedef struct {
   int cells[9];
@@ -35,6 +36,9 @@
   int2 y[20];
 };
 
+#if __OPENCL_C_VERSION__ >= 200
+struct LargeStructOneMember g_s;
+#endif
 
 // X86-LABEL: define void @foo(%struct.Mat4X4* noalias sret %agg.result, %struct.Mat3X3* byval align 4 %in)
 // AMD-LABEL: define %struct.Mat4X4 @foo([9 x i32] %in.coerce)
@@ -80,10 +84,42 @@
 }
 
 // AMD-LABEL: define void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %u)
+// AMD-NOT: addrspacecast
+// AMD:   store <2 x i32> %{{.*}}, <2 x i32> addrspace(5)*
 void FuncOneLargeMember(struct LargeStructOneMember u) {
   u.x[0] = (int2)(0, 0);
 }
 
+// AMD20-LABEL: define void @test_indirect_arg_globl()
+// AMD20:  %[[byval_temp:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5)
+// AMD20:  %[[r0:.*]] = bitcast %struct.LargeStructOneMember addrspace(5)* %[[byval_temp]] to i8 addrspace(5)*
+// AMD20:  call void @llvm.memcpy.p5i8.p1i8.i64(i8 addrspace(5)* align 8 %[[r0]], i8 addrspace(1)* align 8 bitcast (%struct.LargeStructOneMember addrspace(1)* @g_s to i8 addrspace(1)*), i64 800, i1 false)
+// AMD20:  call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %[[byval_temp]])
+#if __OPENCL_C_VERSION__ >= 200
+void test_indirect_arg_globl(void) {
+  FuncOneLargeMember(g_s);
+}
+#endif
+
+// AMD-LABEL: define amdgpu_kernel void @test_indirect_arg_local()
+// AMD: %[[byval_temp:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5)
+// AMD: %[[r0:.*]] = bitcast %struct.LargeStructOneMember addrspace(5)* %[[byval_temp]] to i8 addrspace(5)*
+// AMD: call void @llvm.memcpy.p5i8.p3i8.i64(i8 addrspace(5)* align 8 %[[r0]], i8 addrspace(3)* align 8 bitcast (%struct.LargeStructOneMember addrspace(3)* @test_indirect_arg_local.l_s to i8 addrspace(3)*), i64 800, i1 false)
+// AMD: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %[[byval_temp]])
+kernel void test_indirect_arg_local(void) {
+  local struct LargeStructOneMember l_s;
+  FuncOneLargeMember(l_s);
+}
+
+// AMD-LABEL: define void @test_indirect_arg_private()
+// AMD: %[[p_s:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5)
+// AMD-NOT: @llvm.memcpy
+// AMD-NEXT: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %[[p_s]])
+void test_indirect_arg_private(void) {
+  struct LargeStructOneMember p_s;
+  FuncOneLargeMember(p_s);
+}
+
 // AMD-LABEL: define amdgpu_kernel void @KernelOneMember
 // AMD-SAME:  (<2 x i32> %[[u_coerce:.*]])
 // AMD:  %[[u:.*]] = alloca %struct.StructOneMember, align 8, addrspace(5)
@@ -112,7 +148,6 @@
   u.y[0] = (int2)(0, 0);
 }
 
-
 // AMD-LABEL: define amdgpu_kernel void @KernelTwoMember
 // AMD-SAME:  (%struct.StructTwoMember %[[u_coerce:.*]])
 // AMD:  %[[u:.*]] = alloca %struct.StructTwoMember, align 8, addrspace(5)
Index: test/CodeGenCXX/amdgcn-func-arg.cpp
===
--- /dev/null
+++ test/CodeGenCXX/amdgcn-func-arg.cpp
@@ -0,0 +1,94 @@
+// RUN: %clang_cc1 -O0 -triple amdgcn---amdgiz -emit-llvm %s -o - | FileCheck %s
+
+class A {
+public:
+  int x;
+  A():x(0) {}
+  ~A() {}
+};
+
+class B {
+int x[100];
+};
+
+A g_a;
+B g_b;
+
+void func_with_ref_arg(A );
+void 

[PATCH] D43494: [Modules] Fix creating fake definition data for lambdas.

2018-02-20 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added inline comments.



Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:2969
 
+if (!DD && RD->isBeingDefined())
+  return nullptr;

aprantl wrote:
> Perhaps add a comment explaining what's going on in this early exit?
While I was trying to explain this early exit, I realized one of my assumptions 
was incorrect. Now I'm not sure returning nullptr is the right fix, maybe 
assigning incomplete definition data like

```lang=c++
D->DefinitionData = DD;
ReadCXXDefinitionData(*DD, D);
```
is better.

I am trying to come up with a test case showing different behaviour for these 2 
different fixes. But so far nothing yet. If anybody can tell which one is 
correct: null context for merging or not-yet-populated definition data, that 
would be helpful.


https://reviews.llvm.org/D43494



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


[PATCH] D43518: [clangd] Allow embedders some control over when diagnostics are generated.

2018-02-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, ioeric, jkorous-apple, klimek.

Through the C++ API, we support for a given snapshot version:

- Yes: make sure we generate diagnostics for exactly this version
- Auto: generate eventually-consistent diagnostics for at least this version
- No: don't generate diagnostics for this version

Eventually auto should be debounced for better UX.

Through LSP, we force diagnostics for initial load (bypassing future debouncing)
and all updates follow the "auto" policy.

This is complicated to implement under the CancellationFlag design, so
rewrote that part to just inspect the queue instead.

It turns out we never pass None to the diagnostics callback, so remove Optional
from the signature. The questionable behavior of not invoking the callback at
all if CppFile::rebuild fails is not changed.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43518

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/TUScheduler.cpp
  clangd/TUScheduler.h
  clangd/Threading.cpp
  clangd/Threading.h
  unittests/clangd/TUSchedulerTests.cpp

Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -50,7 +50,7 @@
   auto Missing = testPath("missing.cpp");
   Files[Missing] = "";
 
-  S.update(Added, getInputs(Added, ""), ignoreUpdate);
+  S.update(Added, getInputs(Added, ""), WantDiagnostics::No, ignoreUpdate);
 
   // Assert each operation for missing file is an error (even if it's available
   // in VFS).
@@ -88,6 +88,37 @@
   S.remove(Added);
 }
 
+TEST_F(TUSchedulerTests, WantDiagnostics) {
+  std::atomic CallbackCount(0);
+  {
+TUScheduler S(getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true,
+  /*ASTParsedCallback=*/nullptr);
+auto Path = testPath("foo.cpp");
+
+// To avoid a racy test, don't allow tasks to actualy run on the worker
+// thread until we've scheduled them all.
+Notification Ready;
+S.update(Path, getInputs(Path, ""), WantDiagnostics::Yes,
+ [&](std::vector) { Ready.wait(); });
+
+S.update(Path, getInputs(Path, "request diags"), WantDiagnostics::Yes,
+ [&](std::vector Diags) { ++CallbackCount; });
+S.update(Path, getInputs(Path, "auto (clobbered)"), WantDiagnostics::Auto,
+ [&](std::vector Diags) {
+   ADD_FAILURE() << "auto should have been cancelled by auto";
+ });
+S.update(Path, getInputs(Path, "request no diags"), WantDiagnostics::No,
+ [&](std::vector Diags) {
+   ADD_FAILURE() << "no diags should not be called back";
+ });
+S.update(Path, getInputs(Path, "auto (produces)"), WantDiagnostics::Auto,
+ [&](std::vector Diags) { ++CallbackCount; });
+Ready.notify();
+  }
+  EXPECT_EQ(2, CallbackCount);
+}
+
 TEST_F(TUSchedulerTests, ManyUpdates) {
   const int FilesCount = 3;
   const int UpdatesPerFile = 10;
@@ -132,7 +163,7 @@
 
 {
   WithContextValue WithNonce(NonceKey, ++Nonce);
-  S.update(File, Inputs,
+  S.update(File, Inputs, WantDiagnostics::Auto,
[Nonce, , ](
llvm::Optional Diags) {
  EXPECT_THAT(Context::current().get(NonceKey),
Index: clangd/Threading.h
===
--- clangd/Threading.h
+++ clangd/Threading.h
@@ -13,7 +13,6 @@
 #include "Context.h"
 #include "Function.h"
 #include "llvm/ADT/Twine.h"
-#include 
 #include 
 #include 
 #include 
@@ -23,24 +22,18 @@
 namespace clang {
 namespace clangd {
 
-/// A shared boolean flag indicating if the computation was cancelled.
-/// Once cancelled, cannot be returned to the previous state.
-class CancellationFlag {
+/// A threadsafe flag that is initially clear.
+class Notification {
 public:
-  CancellationFlag();
-
-  void cancel() {
-assert(WasCancelled && "the object was moved");
-WasCancelled->store(true);
-  }
-
-  bool isCancelled() const {
-assert(WasCancelled && "the object was moved");
-return WasCancelled->load();
-  }
+  // Sets the flag. No-op if already set.
+  void notify();
+  // Blocks until flag is set.
+  void wait() const;
 
 private:
-  std::shared_ptr WasCancelled;
+  bool Notified = false;
+  mutable std::condition_variable CV;
+  mutable std::mutex Mu;
 };
 
 /// Limits the number of threads that can acquire the lock at the same time.
Index: clangd/Threading.cpp
===
--- clangd/Threading.cpp
+++ clangd/Threading.cpp
@@ -7,8 +7,18 @@
 namespace clang {
 namespace clangd {
 
-CancellationFlag::CancellationFlag()
-: WasCancelled(std::make_shared(false)) {}
+void 

[PATCH] D43461: [CUDA] Include single GPU binary, NFCI.

2018-02-20 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: lib/Frontend/CompilerInvocation.cpp:1044-1045
 
-  Opts.CudaGpuBinaryFileNames =
-  Args.getAllArgValues(OPT_fcuda_include_gpubinary);
+  Opts.CudaGpuBinaryFileName =
+  Args.getLastArgValue(OPT_fcuda_include_gpubinary);
 

tra wrote:
> Hahnfeld wrote:
> > tra wrote:
> > > If more than one gpu binary is passed, all but last will be ignored.
> > > IMO in this case we would want to either warn that some inputs were 
> > > ignored or report an error that there is more than one GPU binary.
> > Well, `-fcuda-include-gpubinary` is only recognized on `cc1`. I think we 
> > can assume that we are correctly assembling our command line, can't we? 
> > (Nobody else checks the options here...)
> Fair enough. Assert, then?
I added an `assert` in `lib/Driver/ToolChains/Clang.cpp` where we are 
constructing the command line. I think that guarantees that we are getting only 
a single argument.


Repository:
  rC Clang

https://reviews.llvm.org/D43461



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


r325610 - Correct multiversion unsupported target behavior, add a test.

2018-02-20 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Feb 20 10:44:50 2018
New Revision: 325610

URL: http://llvm.org/viewvc/llvm-project?rev=325610=rev
Log:
Correct multiversion unsupported target behavior, add a test.

Multiversioning SEMA failed to set the declaration as invalid on unsupported
targets.  This patch does that.

Additionally, I noticed that there is no test to validate this error message.
This patch adds one, and uses 'mips' as the test architecture.  

Added:
cfe/trunk/test/Sema/attr-target-unsupported.c
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=325610=325609=325610=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Feb 20 10:44:50 2018
@@ -9365,6 +9365,7 @@ static bool CheckMultiVersionFunction(Se
   }
   if (!S.getASTContext().getTargetInfo().supportsMultiVersioning()) {
 S.Diag(NewFD->getLocation(), diag::err_multiversion_not_supported);
+NewFD->setInvalidDecl();
 return true;
   }
 
@@ -9407,6 +9408,7 @@ static bool CheckMultiVersionFunction(Se
 if (!S.getASTContext().getTargetInfo().supportsMultiVersioning()) {
   S.Diag(NewFD->getLocation(), diag::err_multiversion_not_supported);
   S.Diag(OldFD->getLocation(), diag::note_previous_declaration);
+  NewFD->setInvalidDecl();
   return true;
 }
 

Added: cfe/trunk/test/Sema/attr-target-unsupported.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-target-unsupported.c?rev=325610=auto
==
--- cfe/trunk/test/Sema/attr-target-unsupported.c (added)
+++ cfe/trunk/test/Sema/attr-target-unsupported.c Tue Feb 20 10:44:50 2018
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple mips-linux-gnu  -fsyntax-only -verify %s
+
+void __attribute__((target("arch=mips1")))
+foo(void) {}
+// expected-error@+3 {{function multiversioning is not supported on the 
current target}}
+// expected-note@-2 {{previous declaration is here}}
+void __attribute__((target("arch=mips2")))
+foo(void) {}
+
+// expected-error@+2 {{function multiversioning is not supported on the 
current target}}
+void __attribute__((target("default")))
+bar(void){}


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


[PATCH] D43461: [CUDA] Include single GPU binary, NFCI.

2018-02-20 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/Frontend/CompilerInvocation.cpp:1044-1045
 
-  Opts.CudaGpuBinaryFileNames =
-  Args.getAllArgValues(OPT_fcuda_include_gpubinary);
+  Opts.CudaGpuBinaryFileName =
+  Args.getLastArgValue(OPT_fcuda_include_gpubinary);
 

Hahnfeld wrote:
> tra wrote:
> > If more than one gpu binary is passed, all but last will be ignored.
> > IMO in this case we would want to either warn that some inputs were ignored 
> > or report an error that there is more than one GPU binary.
> Well, `-fcuda-include-gpubinary` is only recognized on `cc1`. I think we can 
> assume that we are correctly assembling our command line, can't we? (Nobody 
> else checks the options here...)
Fair enough. Assert, then?


Repository:
  rC Clang

https://reviews.llvm.org/D43461



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


[PATCH] D43500: modernize-use-default-member-init: Remove trailing comma and colon.

2018-02-20 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:15
 
+#include "../utils/LexerUtils.h"
+

Please place it on a top, since header belong to project.



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:26
+   tok::TokenKind K) {
+  for (;;) {
+Token Tok = utils::lexer::getPreviousToken(*Context, Location);

Please use while (true) instead.



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:48
+  auto NextInit = std::next(pos);
+  if (NextInit != Ctor->init_end()) {
+return (*NextInit)->getSourceLocation();

Unnecessary curvy brackets.



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:177
+  IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true) != 0),
+  RemovedInitializers() {}
 

Unnecessary initializer. See [[ 
http://clang.llvm.org/extra/clang-tidy/checks/readability-redundant-member-init.html
 | readability-redundant-member-init ]].



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:271
+
+  if (++RemovedInitializers[Ctor] == Ctor->getNumCtorInitializers()) {
+removeTrailingColon(Diag, Result.Context, Ctor);

Unnecessary curvy brackets.



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:298
+if (sameValue(NextInit->getMember()->getInClassInitializer(),
+  NextInit->getInit())) {
+  // The next initializer will be removed later. Removing only the

Unnecessary curvy brackets.



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:302
+  Diag << FixItHint::CreateRemoval(Init->getSourceRange());
+} else {
+  // The next initializer will not be remove. In this case, we should 
create

Unnecessary curvy brackets.



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:308
+}
+  } else {
+// This initializer is in the middle of other one.

Unnecessary curvy brackets.



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:317
+
+  if (++RemovedInitializers[Ctor] == Ctor->getNumCtorInitializers()) {
+removeTrailingColon(Diag, Result.Context, Ctor);

Unnecessary curvy brackets.



Comment at: unittests/clang-tidy/ModernizerModuleTest.cpp:62
+}
+} // namespace test
+} // namespace tidy

Please separate function from namespaces ends with empty line.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43500



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


[PATCH] D43461: [CUDA] Include single GPU binary, NFCI.

2018-02-20 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: lib/Frontend/CompilerInvocation.cpp:1044-1045
 
-  Opts.CudaGpuBinaryFileNames =
-  Args.getAllArgValues(OPT_fcuda_include_gpubinary);
+  Opts.CudaGpuBinaryFileName =
+  Args.getLastArgValue(OPT_fcuda_include_gpubinary);
 

tra wrote:
> If more than one gpu binary is passed, all but last will be ignored.
> IMO in this case we would want to either warn that some inputs were ignored 
> or report an error that there is more than one GPU binary.
Well, `-fcuda-include-gpubinary` is only recognized on `cc1`. I think we can 
assume that we are correctly assembling our command line, can't we? (Nobody 
else checks the options here...)


Repository:
  rC Clang

https://reviews.llvm.org/D43461



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


[PATCH] D43461: [CUDA] Include single GPU binary, NFCI.

2018-02-20 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:4659
   if (IsCuda) {
-// Host-side cuda compilation receives device-side outputs as Inputs[1...].
-// Include them with -fcuda-include-gpubinary.
+// Host-side cuda compilation receives device-side outputs as Inputs[1].
+// Include the binary with -fcuda-include-gpubinary.

Nit: Passing multiple things as a single input may need some more details.
E.g. `...receives all device-side outputs in a single fatbin as Inputs[1]`



Comment at: lib/Frontend/CompilerInvocation.cpp:1044-1045
 
-  Opts.CudaGpuBinaryFileNames =
-  Args.getAllArgValues(OPT_fcuda_include_gpubinary);
+  Opts.CudaGpuBinaryFileName =
+  Args.getLastArgValue(OPT_fcuda_include_gpubinary);
 

If more than one gpu binary is passed, all but last will be ignored.
IMO in this case we would want to either warn that some inputs were ignored or 
report an error that there is more than one GPU binary.


Repository:
  rC Clang

https://reviews.llvm.org/D43461



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


[PATCH] D16403: Add scope information to CFG

2018-02-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In https://reviews.llvm.org/D16403#1013346, @m.ostapenko wrote:

> In https://reviews.llvm.org/D16403#1011218, @NoQ wrote:
>
> > Yeah, i mean, like, if we change the scope markers to also appear even when 
> > no variables are present in the scope, then it would be possible to replace 
> > loop markers with some of the scope markers, right?
>
>
> Hm, so does this mean that I need to cover the case when no variables are 
> present in loop scope here in this patch?


Definitely not :) Feel free to address it some day (or let someone else address 
it) - the culture of keeping our patches small is something that we currently 
badly lack :)


Repository:
  rL LLVM

https://reviews.llvm.org/D16403



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


[PATCH] D16403: Add scope information to CFG

2018-02-20 Thread Maxim Ostapenko via Phabricator via cfe-commits
m.ostapenko added a comment.

In https://reviews.llvm.org/D16403#1001466, @NoQ wrote:

> I poked Devin offline and we agreed that the overall approach is good to go. 
> Maxim, thank you for picking it up!
>
> We still don't have scopes for segments of code that don't have any variables 
> in them, so i guess it's not yet in the shape where it is super useful for 
> loops, but it's already useful for finding use of stale stack variables, 
> which was the whole point originally, so i think this should definitely land 
> soon.
>
> In https://reviews.llvm.org/D16403#993512, @m.ostapenko wrote:
>
> > In https://reviews.llvm.org/D16403#992452, @NoQ wrote:
> >
> > > Am i understanding correctly that while destroying `a` you can still use 
> > > the storage of `b` safely? Or should `a` go out of scope before `b` gets 
> > > destroyed?
> >
> >
> > AFAIU, when we destroying `a` we can still use the storage of `b` because 
> > nothing can be allocated into b's storage between calling destructors for 
> > `b` and `a`. So, imho the sequence should look like:
> >
> >   [B4.5].~A() (Implicit destructor)
> >   [B5.3].~A() (Implicit destructor)
> >   CFGScopeEnd(b)
> >   CFGScopeEnd(a)
> >  
> >
>
>
> Thought about it a bit more and this still doesn't look correct to me. Like, 
> `a.~A()` is a function call. It can do a lot of unexpected stuff to registers 
> and stack space before jumping into the function. And given that `a` and `b` 
> are in different scopes (`a` is in loop scope, `b` is in single iteration 
> scope), storage of `b` is not protected from such stuff during call to the 
> destructor of `a`. So there's definitely something fishy here. I guess scope 
> ends and destructors would have to be properly interleaved in all cases of 
> exiting multiple scopes.


Sounds reasonable, I'll fix this.


Repository:
  rL LLVM

https://reviews.llvm.org/D16403



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


[PATCH] D42366: [CodeGen] Fix generation of TBAA tags for may-alias accesses

2018-02-20 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D42366#1012211, @rjmccall wrote:

> I'm fine with that plan.  LGTM.


Thanks.

We should probably discuss what we want to do with unknown-sized things. 
UINT64_MAX is the conservative answer, but maybe there's some value in just 
having 0 mean "unknown size" so we don't need to encode a bunch of UINT64_MAX 
values at the IR level.


Repository:
  rC Clang

https://reviews.llvm.org/D42366



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


[PATCH] D16403: Add scope information to CFG

2018-02-20 Thread Maxim Ostapenko via Phabricator via cfe-commits
m.ostapenko added a comment.

In https://reviews.llvm.org/D16403#1011218, @NoQ wrote:

> In https://reviews.llvm.org/D16403#1010096, @szepet wrote:
>
> > In https://reviews.llvm.org/D16403#992454, @NoQ wrote:
> >
> > > @szepet: so i see that `LoopExit` goes in the beginning of the cleanup 
> > > block after the loop, while various `ScopeEnd`s go after the `LoopExit`. 
> > > Would loop unrolling be significantly broken if you simply subscribe to 
> > > `ScopeEnd` instead of `LoopExit` and avoid cleaning up the loop state 
> > > until destructors are processed? I might not be remembering correctly - 
> > > is `LoopExit` only used for cleanup, or do we have more work to be done 
> > > here?
> >
> >
> > I guess your following comment just answers this:
> >
> > In https://reviews.llvm.org/D16403#1001466, @NoQ wrote:
> >
> > > We still don't have scopes for segments of code that don't have any 
> > > variables in them, so i guess it's not yet in the shape where it is super 
> > > useful for loops, but it's already useful for finding use of stale stack 
> > > variables, which was the whole point originally, so i think this should 
> > > definitely land soon.
> >
> >
> > It could be, however, we would lose cases like:
> >
> >   int i = 0;
> >   int a[32];
> >   for(i = 0;i<32;++i) {a[i] = i;}
> >
> >
> > Since there is no variable which has the scope of the loop, ScopeEnd would 
> > be not enough. Sure, we could remove this case, however, the aim is to 
> > extend the loop-patterns for completely unrolling. Another thing that there 
> > are the patches which would enhance the covered cases by LoopExit 
> > (https://reviews.llvm.org/D39398) and add the LoopEntrance to the 
> > CFG(https://reviews.llvm.org/D41150) as well. So, at this point, I feel 
> > like it would be a huge step back not to use these elements. (Sorry Maxim 
> > that we are discussing this here^^)
>
>
> Yeah, i mean, like, if we change the scope markers to also appear even when 
> no variables are present in the scope, then it would be possible to replace 
> loop markers with some of the scope markers, right?


Hm, so does this mean that I need to cover the case when no variables are 
present in loop scope here in this patch?


Repository:
  rL LLVM

https://reviews.llvm.org/D16403



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


[PATCH] D43513: [OpenMP] Limit reduction support for pragma 'distribute' when combined with pragma 'simd'

2018-02-20 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Tests?


Repository:
  rC Clang

https://reviews.llvm.org/D43513



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


[PATCH] D43514: Start settinng dso_local for COFF

2018-02-20 Thread Rafael Avila de Espindola via Phabricator via cfe-commits
espindola created this revision.
espindola added a reviewer: rnk.
Herald added subscribers: eraman, javed.absar.

With this there are still some GVs where we don't set dso_local because 
setGVProperties is never called. I intend to fix that in followup commits. This 
is just the bare minimum to teach shouldAssumeDSOLocal what it should do for 
COFF.


https://reviews.llvm.org/D43514

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGen/aarch64-varargs-ms.c
  test/CodeGen/attr-x86-interrupt.c
  test/CodeGen/blocks-windows.c
  test/CodeGen/builtins-ms.c
  test/CodeGen/builtins-overflow.c
  test/CodeGen/c-strings.c
  test/CodeGen/cfi-icall-cross-dso.c
  test/CodeGen/cfi-icall.c
  test/CodeGen/cfstring-windows.c
  test/CodeGen/dllexport.c
  test/CodeGen/dllimport.c
  test/CodeGen/dso-local-executable.c
  test/CodeGen/exceptions-seh-finally.c
  test/CodeGen/exceptions-seh-leave.c
  test/CodeGen/exceptions-seh.c
  test/CodeGen/inline.c
  test/CodeGen/mangle-ms.c
  test/CodeGen/mangle-windows-rtd.c
  test/CodeGen/mangle-windows.c
  test/CodeGen/microsoft-call-conv-x64.c
  test/CodeGen/mingw-long-double.c
  test/CodeGen/ms-align-tentative.c
  test/CodeGen/ms-annotation.c
  test/CodeGen/ms-barriers-intrinsics.c
  test/CodeGen/ms-declspecs.c
  test/CodeGen/ms-declspecs.cpp
  test/CodeGen/ms-inline-asm-align.c
  test/CodeGen/ms-inline-asm-avx512.c
  test/CodeGen/ms-intrinsics.c
  test/CodeGen/ms-setjmp.c
  test/CodeGen/ms-x86-intrinsics.c
  test/CodeGen/ms_abi.c
  test/CodeGen/ms_abi_aarch64.c
  test/CodeGen/ms_this.cpp
  test/CodeGen/preserve-call-conv.c
  test/CodeGen/regcall.c
  test/CodeGen/variadic-null-win64.c
  test/CodeGen/vectorcall.c
  test/CodeGen/windows-itanium.c
  test/CodeGen/windows-on-arm-dllimport-dllexport.c
  test/CodeGen/windows-struct-abi.c
  test/CodeGen/windows-swiftcall.c
  test/CodeGen/x86_32-arguments-win32.c
  test/CodeGen/x86_32-fpcc-struct-return.c
  test/CodeGen/x86_64-arguments-win32.c
  test/CodeGenCXX/PR19955.cpp
  test/CodeGenCXX/atomic-dllexport.cpp
  test/CodeGenCXX/attr-x86-interrupt.cpp
  test/CodeGenCXX/constructor-destructor-return-this.cpp
  test/CodeGenCXX/dllexport-alias.cpp
  test/CodeGenCXX/dllexport-ctor-closure.cpp
  test/CodeGenCXX/dllexport-dtor-thunks.cpp
  test/CodeGenCXX/dllexport-members.cpp
  test/CodeGenCXX/dllexport-ms-friend.cpp
  test/CodeGenCXX/dllexport-pr26549.cpp
  test/CodeGenCXX/dllexport-vtable-thunks.cpp
  test/CodeGenCXX/dllexport.cpp
  test/CodeGenCXX/dllimport-dtor-thunks.cpp
  test/CodeGenCXX/dllimport-members.cpp
  test/CodeGenCXX/dllimport-memptr-global.cpp
  test/CodeGenCXX/dllimport-rtti.cpp
  test/CodeGenCXX/dllimport.cpp
  test/CodeGenCXX/exceptions-cxx-ehsc.cpp
  test/CodeGenCXX/exceptions-cxx-new.cpp
  test/CodeGenCXX/exceptions-seh-filter-captures.cpp
  test/CodeGenCXX/exceptions-seh.cpp
  test/CodeGenCXX/explicit-instantiation.cpp
  test/CodeGenCXX/homogeneous-aggregates.cpp
  test/CodeGenCXX/initializer-list-ctor-order.cpp
  test/CodeGenCXX/inline-dllexport-member.cpp
  test/CodeGenCXX/inline-functions.cpp
  test/CodeGenCXX/mangle-ms-cxx11.cpp
  test/CodeGenCXX/mangle-ms-md5.cpp
  test/CodeGenCXX/mangle-ms-templates-memptrs-2.cpp
  test/CodeGenCXX/mangle-ms-vector-types.cpp
  test/CodeGenCXX/mangle-ms.cpp
  test/CodeGenCXX/mangle-windows.cpp
  test/CodeGenCXX/member-function-pointer-calls.cpp
  test/CodeGenCXX/microsoft-abi-arg-order.cpp
  test/CodeGenCXX/microsoft-abi-array-cookies.cpp
  test/CodeGenCXX/microsoft-abi-byval-sret.cpp
  test/CodeGenCXX/microsoft-abi-byval-thunks.cpp
  test/CodeGenCXX/microsoft-abi-byval-vararg.cpp
  test/CodeGenCXX/microsoft-abi-cdecl-method-sret.cpp
  test/CodeGenCXX/microsoft-abi-constexpr-vs-inheritance.cpp
  test/CodeGenCXX/microsoft-abi-default-cc.cpp
  test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp
  test/CodeGenCXX/microsoft-abi-eh-catch.cpp
  test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
  test/CodeGenCXX/microsoft-abi-eh-inlineasm.cpp
  test/CodeGenCXX/microsoft-abi-eh-terminate.cpp
  test/CodeGenCXX/microsoft-abi-extern-template.cpp
  test/CodeGenCXX/microsoft-abi-member-pointers.cpp
  test/CodeGenCXX/microsoft-abi-methods.cpp
  test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
  test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
  test/CodeGenCXX/microsoft-abi-static-initializers.cpp
  test/CodeGenCXX/microsoft-abi-structors-alias.cpp
  test/CodeGenCXX/microsoft-abi-structors.cpp
  test/CodeGenCXX/microsoft-abi-thread-safe-statics.cpp
  test/CodeGenCXX/microsoft-abi-thunks.cpp
  test/CodeGenCXX/microsoft-abi-try-throw.cpp
  test/CodeGenCXX/microsoft-abi-typeid.cpp
  test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
  test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
  test/CodeGenCXX/microsoft-abi-virtual-member-pointers.cpp
  test/CodeGenCXX/microsoft-abi-vmemptr-conflicts.cpp
  test/CodeGenCXX/microsoft-abi-vmemptr-vbase.cpp
  

[PATCH] D43510: [clangd] don't insert new includes if either original header or canonical header is already included.

2018-02-20 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 135074.
ioeric marked 16 inline comments as done.
ioeric added a comment.

- Addressed review comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43510

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/CodeComplete.cpp
  clangd/Headers.cpp
  clangd/Headers.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  test/clangd/insert-include.test
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/HeadersTests.cpp

Index: unittests/clangd/HeadersTests.cpp
===
--- unittests/clangd/HeadersTests.cpp
+++ unittests/clangd/HeadersTests.cpp
@@ -24,17 +24,28 @@
   }
 
 protected:
-  // Calculates the include path for \p Header, or returns "" on error.
-  std::string calculate(PathRef Header) {
+  // Calculates the include path, or returns "" on error.
+  std::string calculate(PathRef Original, PathRef Preferred = "",
+bool ExpectError = false) {
+if (Preferred.empty())
+  Preferred = Original;
 auto VFS = FS.getTaggedFileSystem(MainFile).Value;
 auto Cmd = CDB.getCompileCommand(MainFile);
 assert(static_cast(Cmd));
 VFS->setCurrentWorkingDirectory(Cmd->Directory);
-auto Path =
-calculateIncludePath(MainFile, FS.Files[MainFile], Header, *Cmd, VFS);
+auto ToHeaderFile = [](llvm::StringRef Header) {
+  return HeaderFile{Header,
+/*Verbatim=*/!llvm::sys::path::is_absolute(Header)};
+};
+auto Path = calculateIncludePath(MainFile, FS.Files[MainFile],
+ ToHeaderFile(Original),
+ ToHeaderFile(Preferred), *Cmd, VFS);
 if (!Path) {
   llvm::consumeError(Path.takeError());
+  EXPECT_TRUE(ExpectError);
   return std::string();
+} else {
+  EXPECT_FALSE(ExpectError);
 }
 return std::move(*Path);
   }
@@ -66,7 +77,21 @@
   FS.Files[MainFile] = R"cpp(
 #include "sub/bar.h"  // not shortest
 )cpp";
-  EXPECT_EQ(calculate(BarHeader), "");
+  EXPECT_EQ(calculate("\"sub/bar.h\""), ""); // Duplicate rewritten.
+  EXPECT_EQ(calculate(BarHeader), "");   // Duplicate resolved.
+  EXPECT_EQ(calculate(BarHeader, "\"BAR.h\""), ""); // Do not insert preferred.
+}
+
+TEST_F(HeadersTest, DontInsertDuplicatePreferred) {
+  std::string BarHeader = testPath("sub/bar.h");
+  FS.Files[BarHeader] = "";
+  FS.Files[MainFile] = R"cpp(
+#include "sub/bar.h"  // not shortest
+)cpp";
+  // Duplicate written.
+  EXPECT_EQ(calculate("\"original.h\"", "\"sub/bar.h\""), "");
+  // Duplicate resolved.
+  EXPECT_EQ(calculate("\"original.h\"", BarHeader), "");
 }
 
 TEST_F(HeadersTest, StillInsertIfTrasitivelyIncluded) {
@@ -88,6 +113,17 @@
   EXPECT_EQ(calculate(MainFile), "");
 }
 
+TEST_F(HeadersTest, PreferredHeader) {
+  FS.Files[MainFile] = "";
+  std::string BarHeader = testPath("sub/bar.h");
+  FS.Files[BarHeader] = "";
+  EXPECT_EQ(calculate(BarHeader, ""), "");
+
+  std::string BazHeader = testPath("sub/baz.h");
+  FS.Files[BazHeader] = "";
+  EXPECT_EQ(calculate(BarHeader, BazHeader), "\"baz.h\"");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -862,6 +862,8 @@
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB;
+  std::string SearchDirArg = (llvm::Twine("-I") + testRoot()).str();
+  CDB.ExtraClangFlags.insert(CDB.ExtraClangFlags.end(), {SearchDirArg.c_str()});
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*AsyncThreadsCount=*/0,
   /*StorePreamblesInMemory=*/true);
@@ -877,17 +879,30 @@
   FS.Files[FooCpp] = Code;
   Server.addDocument(FooCpp, Code);
 
-  auto Inserted = [&](llvm::StringRef Header, llvm::StringRef Expected) {
-auto Replaces = Server.insertInclude(FooCpp, Code, Header);
+  auto Inserted = [&](llvm::StringRef Original, llvm::StringRef Preferred,
+  llvm::StringRef Expected) {
+auto Replaces = Server.insertInclude(
+FooCpp, Code, Original, Preferred.empty() ? Original : Preferred);
 EXPECT_TRUE(static_cast(Replaces));
 auto Changed = tooling::applyAllReplacements(Code, *Replaces);
 EXPECT_TRUE(static_cast(Changed));
 return llvm::StringRef(*Changed).contains(
 (llvm::Twine("#include ") + Expected + "").str());
   };
 
-  EXPECT_TRUE(Inserted("\"y.h\"", "\"y.h\""));
-  EXPECT_TRUE(Inserted("", ""));
+  EXPECT_TRUE(Inserted("\"y.h\"", /*Preferred=*/"","\"y.h\""));
+  EXPECT_TRUE(Inserted("\"y.h\"", /*Preferred=*/"\"Y.h\"", "\"Y.h\""));
+  EXPECT_TRUE(Inserted("", /*Preferred=*/"", ""));
+  EXPECT_TRUE(Inserted("", /*Preferred=*/"", ""));
+
+  std::string OriginalHeader = URI::createFile(testPath("y.h")).toString();
+  std::string 

[PATCH] D43513: [OpenMP] Limit reduction support for pragma 'distribute' when combined with pragma 'simd'

2018-02-20 Thread Carlo Bertolli via Phabricator via cfe-commits
carlo.bertolli created this revision.
carlo.bertolli added a reviewer: ABataev.
Herald added a subscriber: guansong.

This is a bug fix that removes the emission of reduction support for pragma 
'distribute' when found alone or in combinations without simd.
Pragma 'distribute' does not have a reduction clause, but when combined with 
pragma 'simd' we need to emit the support for simd's reduction clause as part 
of code generation for distribute. This guard is similar to the one used for 
reduction support earlier in the same code gen function.


Repository:
  rC Clang

https://reviews.llvm.org/D43513

Files:
  lib/CodeGen/CGStmtOpenMP.cpp


Index: lib/CodeGen/CGStmtOpenMP.cpp
===
--- lib/CodeGen/CGStmtOpenMP.cpp
+++ lib/CodeGen/CGStmtOpenMP.cpp
@@ -3358,26 +3358,30 @@
   CGF.EmitLoadOfScalar(IL, S.getLocStart()));
 });
   }
-  OpenMPDirectiveKind ReductionKind = OMPD_unknown;
-  if (isOpenMPParallelDirective(S.getDirectiveKind()) &&
-  isOpenMPSimdDirective(S.getDirectiveKind())) {
-ReductionKind = OMPD_parallel_for_simd;
-  } else if (isOpenMPParallelDirective(S.getDirectiveKind())) {
-ReductionKind = OMPD_parallel_for;
-  } else if (isOpenMPSimdDirective(S.getDirectiveKind())) {
-ReductionKind = OMPD_simd;
-  } else if (!isOpenMPTeamsDirective(S.getDirectiveKind()) &&
- S.hasClausesOfKind()) {
-llvm_unreachable(
-"No reduction clauses is allowed in distribute directive.");
+  if (isOpenMPSimdDirective(S.getDirectiveKind()) &&
+  !isOpenMPParallelDirective(S.getDirectiveKind()) &&
+  !isOpenMPTeamsDirective(S.getDirectiveKind())) {
+OpenMPDirectiveKind ReductionKind = OMPD_unknown;
+if (isOpenMPParallelDirective(S.getDirectiveKind()) &&
+isOpenMPSimdDirective(S.getDirectiveKind())) {
+  ReductionKind = OMPD_parallel_for_simd;
+} else if (isOpenMPParallelDirective(S.getDirectiveKind())) {
+  ReductionKind = OMPD_parallel_for;
+} else if (isOpenMPSimdDirective(S.getDirectiveKind())) {
+  ReductionKind = OMPD_simd;
+} else if (!isOpenMPTeamsDirective(S.getDirectiveKind()) &&
+   S.hasClausesOfKind()) {
+  llvm_unreachable(
+  "No reduction clauses is allowed in distribute directive.");
+}
+EmitOMPReductionClauseFinal(S, ReductionKind);
+// Emit post-update of the reduction variables if IsLastIter != 0.
+emitPostUpdateForReductionClause(
+*this, S, [&](CodeGenFunction ) -> llvm::Value * {
+  return CGF.Builder.CreateIsNotNull(
+  CGF.EmitLoadOfScalar(IL, S.getLocStart()));
+});
   }
-  EmitOMPReductionClauseFinal(S, ReductionKind);
-  // Emit post-update of the reduction variables if IsLastIter != 0.
-  emitPostUpdateForReductionClause(
-  *this, S, [&](CodeGenFunction ) -> llvm::Value * {
-return CGF.Builder.CreateIsNotNull(
-CGF.EmitLoadOfScalar(IL, S.getLocStart()));
-  });
   // Emit final copy of the lastprivate variables if IsLastIter != 0.
   if (HasLastprivateClause) {
 EmitOMPLastprivateClauseFinal(


Index: lib/CodeGen/CGStmtOpenMP.cpp
===
--- lib/CodeGen/CGStmtOpenMP.cpp
+++ lib/CodeGen/CGStmtOpenMP.cpp
@@ -3358,26 +3358,30 @@
   CGF.EmitLoadOfScalar(IL, S.getLocStart()));
 });
   }
-  OpenMPDirectiveKind ReductionKind = OMPD_unknown;
-  if (isOpenMPParallelDirective(S.getDirectiveKind()) &&
-  isOpenMPSimdDirective(S.getDirectiveKind())) {
-ReductionKind = OMPD_parallel_for_simd;
-  } else if (isOpenMPParallelDirective(S.getDirectiveKind())) {
-ReductionKind = OMPD_parallel_for;
-  } else if (isOpenMPSimdDirective(S.getDirectiveKind())) {
-ReductionKind = OMPD_simd;
-  } else if (!isOpenMPTeamsDirective(S.getDirectiveKind()) &&
- S.hasClausesOfKind()) {
-llvm_unreachable(
-"No reduction clauses is allowed in distribute directive.");
+  if (isOpenMPSimdDirective(S.getDirectiveKind()) &&
+  !isOpenMPParallelDirective(S.getDirectiveKind()) &&
+  !isOpenMPTeamsDirective(S.getDirectiveKind())) {
+OpenMPDirectiveKind ReductionKind = OMPD_unknown;
+if (isOpenMPParallelDirective(S.getDirectiveKind()) &&
+isOpenMPSimdDirective(S.getDirectiveKind())) {
+  ReductionKind = OMPD_parallel_for_simd;
+} else if (isOpenMPParallelDirective(S.getDirectiveKind())) {
+  ReductionKind = OMPD_parallel_for;
+} else if (isOpenMPSimdDirective(S.getDirectiveKind())) {
+  ReductionKind = OMPD_simd;
+} else if (!isOpenMPTeamsDirective(S.getDirectiveKind()) &&
+   

[PATCH] D43510: [clangd] don't insert new includes if either original header or canonical header is already included.

2018-02-20 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/ClangdServer.h:243
+  /// string quoted with <> or "" that can be #included directly.
+  /// \p PreferredHeader The preferred header to be inserted. The has the same
+  /// semantic as \p OriginalHeader. If empty, \p OriginalHeader is used to

sammccall wrote:
> sammccall wrote:
> > sammccall wrote:
> > > "this has the same semantic as OriginalHeader" contradicts 
> > > "[OriginalHeader] may be different from preferredHeader" :-)
> > T think `InsertedHeader` might be clearer about its role.
> I'd suggest being explicit, since this is different to above: "if this is a 
> URI, insertInclude will determine how to spell it. If this is a quoted 
> string, it will be inserted verbatim".
Bad wording... sorry about that!



Comment at: clangd/Headers.cpp:126
+  };
+  if (Included(OriginalHeader) || Included(PreferredHeader))
 return llvm::make_error(

sammccall wrote:
> oops, missed this in the previous commit - this isn't an error condition, but 
> a "return empty string" condition.
> 
> Can we add a test for this?
There are tests for this in `HeadersTests.cpp`. It's just that in the tests, we 
treat both errors and empty insertion as no insertion.



Comment at: clangd/Headers.h:23
+/// Returns true if \p Include is literal include like "path" or .
+bool isLiteralInclude(llvm::StringRef Include);
+

sammccall wrote:
> only used in headers.cpp, make static?
Oops, the same logic appeared in ClangdServer. I wanted to share this but 
forgot to...


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43510



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


[PATCH] D41102: Setup clang-doc frontend framework

2018-02-20 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added a comment.

> 2. I've mentioned it before as a comment, but to what extent will you be 
> parsing information in this frontend? Currently the links between types are 
> primarily stored as strings. Are you planning to have the backend that 
> generates the MarkDown parse those strings and link them to types? E.g. the 
> parenttype is a std::vector and assuming you want the markdown 
> to have a link to this parent type, will the MarkDown have to parse this type 
> and lookup the link to the original type? Or will you embed references to 
> other types within the intermediate format?

This is a good question -- expecting the backend to parse the strings is a bit 
of an unrealistic assumption, as you point out. I'm currently switching the key 
type from the names to the USRs, and I think that might help resolve this too. 
With that, each type can reference the USR of the linked def, which can be used 
to directly lookup the linked def. Does that make sense? I have to see where 
the majority of the USR resolution should be done (i.e. here in the mapper or 
later in the reducer), so will update once I take a look at that.


https://reviews.llvm.org/D41102



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


r325594 - PR36442: Correct description of -fsplit-dwarf-inlining

2018-02-20 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Tue Feb 20 08:35:08 2018
New Revision: 325594

URL: http://llvm.org/viewvc/llvm-project?rev=325594=rev
Log:
PR36442: Correct description of -fsplit-dwarf-inlining

Modified:
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=325594=325593=325594=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Feb 20 08:35:08 2018
@@ -1631,7 +1631,7 @@ def fdebug_types_section: Flag <["-"], "
 def fno_debug_types_section: Flag<["-"], "fno-debug-types-section">, 
Group,
   Flags<[CC1Option]>;
 def fsplit_dwarf_inlining: Flag <["-"], "fsplit-dwarf-inlining">, 
Group,
-  Flags<[CC1Option]>, HelpText<"Place debug types in their own section (ELF 
Only)">;
+  Flags<[CC1Option]>, HelpText<"Provide gmlt-like debug info in the 
object/executable to facilitate online symbolication/stack traces in the 
absence of .dwo/.dwp files when using Split DWARF">;
 def fno_split_dwarf_inlining: Flag<["-"], "fno-split-dwarf-inlining">, 
Group,
   Flags<[CC1Option]>;
 def fdebug_prefix_map_EQ


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


r325593 - Stop linking sanitized applications with -lutil and -lkvm on NetBSD

2018-02-20 Thread Kamil Rytarowski via cfe-commits
Author: kamil
Date: Tue Feb 20 08:27:28 2018
New Revision: 325593

URL: http://llvm.org/viewvc/llvm-project?rev=325593=rev
Log:
Stop linking sanitized applications with -lutil and -lkvm on NetBSD

The proper approach is to rebuild libutil and libkvm with a desired sanitizer.
An alternative approach to reimplement these functions (and other ones like
curses(3), editline(3) etc) does not scale and enforces linkage every single
binary with these libraries.

Modified:
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=325593=325592=325593=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Tue Feb 20 08:27:28 2018
@@ -550,16 +550,10 @@ void tools::linkSanitizerRuntimeDeps(con
   TC.getTriple().getOS() != llvm::Triple::NetBSD &&
   TC.getTriple().getOS() != llvm::Triple::RTEMS)
 CmdArgs.push_back("-ldl");
-  // Required for functions like forkpty on some OSes
-  if (TC.getTriple().getOS() == llvm::Triple::NetBSD)
-CmdArgs.push_back("-lutil");
   // Required for backtrace on some OSes
   if (TC.getTriple().getOS() == llvm::Triple::NetBSD ||
   TC.getTriple().getOS() == llvm::Triple::FreeBSD)
 CmdArgs.push_back("-lexecinfo");
-  // Required for kvm (kernel memory interface) on some OSes
-  if (TC.getTriple().getOS() == llvm::Triple::NetBSD)
-CmdArgs.push_back("-lkvm");
 }
 
 static void


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


[PATCH] D41102: Setup clang-doc frontend framework

2018-02-20 Thread Athos via Phabricator via cfe-commits
Athosvk added a comment.

The changes seem good (both mapper and additional changes)! I've added some 
comments, but those are primarily details.

What I'm however primarily interested in is the following:

1. You seemingly output only little information for declarations that are not 
definition. Is that temporary? Will you //need// to have a definition in order 
for a function be documented?
2. I've mentioned it before as a comment, but to what extent will you be 
parsing information in this frontend? Currently the links between types are 
primarily stored as strings. Are you planning to have the backend that 
generates the MarkDown parse those strings and link them to types? E.g. the 
parenttype is a std::vector and assuming you want the markdown to 
have a link to this parent type, will the MarkDown have to parse this type and 
lookup the link to the original type? Or will you embed references to other 
types within the intermediate format?

I'm curious to hear your thoughts on this!




Comment at: clang-doc/ClangDocRepresentation.h:39
+  llvm::SmallVector Position;
+  std::vector Children;
+};

I might be missing something, but can't this be a unique ptr? Shouldn't 
children of comments only have one parent?



Comment at: clang-doc/ClangDocRepresentation.h:46
+struct NamedType {
+  enum FieldName { PARAM = 1, MEMBER, RETTYPE };
+  FieldName Field;

Perhaps use an enum class instead? Same goes for the other enums



Comment at: clang-doc/ClangDocRepresentation.h:63
+  std::string SimpleName;
+  std::string Namespace;
+  llvm::SmallVector Description;

It's not too important for now , but you probably want to at least store the 
namespace identifier for each nested namespace at some point. So instead you 
store a vector of namespaces, which in the final markdown generation stage 
allows you to link to each namespace individually (assuming you'll have some 
kind of namespace overview pages)



Comment at: tools/clang-doc/ClangDocReporter.h:42
   std::string Name;
   AccessSpecifier Access;
 };

You might want to separate this out to a FieldType/MemberType or something 
alike, as only class members will have this set, while you also use this for 
parameters/return types etc. I know there's AS_NONE but it seems a little 
wasteful considering the amount of instances that will not have this set


https://reviews.llvm.org/D41102



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


[PATCH] D42545: [Sema] Classify conversions from enum to float as narrowing

2018-02-20 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

In https://reviews.llvm.org/D42545#1010335, @rogfer01 wrote:

> Do you plan to submit (in another change) the unscoped enum → integer type 
> testcases? If this is not currently tested anywhere I think it may be a good 
> thing to have them too.


Yes, I'll submit them in a follow-up patch.


https://reviews.llvm.org/D42545



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


[PATCH] D41537: Optionally add code completion results for arrow instead of dot

2018-02-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Sorry for not getting back on this earlier.

I wanted to discuss whether returning correction as a enum value is a proper 
interface for users of `libclang`.
It seems easy to replace `.` with `->` inside clang, properly handling all the 
tricky cases (tokens coming from macro substitution, etc)  and making sure it's 
a viable option (again, macro substitutions may make it non-viable).
And even though it's not hard to implement things like "replace . with ->" for 
any particular editor, we still need to do that for **every** small correction 
that may we want to add to the completion in **every** editor.

I propose to return something similar to a `FixItHint` from `Diagnostic.h`, 
i.e. description of a simple text edit that should be applied before inserting 
the completion identifier. In that case, we may hope that every editor will 
implement the corrections once, and we could add more features into code 
completions that will be immediately picked up by all the editors that support 
it.
WDYT?


https://reviews.llvm.org/D41537



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


[PATCH] D42645: New simple Checker for mmap calls

2018-02-20 Thread David CARLIER via Phabricator via cfe-commits
devnexen updated this revision to Diff 135067.
devnexen added a comment.

Updating tests accordingly


https://reviews.llvm.org/D42645

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
  test/Analysis/mmap-writeexec.c

Index: test/Analysis/mmap-writeexec.c
===
--- test/Analysis/mmap-writeexec.c
+++ test/Analysis/mmap-writeexec.c
@@ -0,0 +1,36 @@
+// RUN: %clang_analyze_cc1 -triple i686-unknown-linux -analyzer-checker=alpha.security.MmapWriteExec -analyzer-config alpha.security.MmapWriteExec:MmapProtExec=1 -analyzer-config alpha.security.MmapWriteExec:MmapProtRead=4 -DUSE_ALTERNATIVE_PROT_EXEC_DEFINITION -verify %s
+// RUN: %clang_analyze_cc1 -triple x86_64-unknown-apple-darwin10 -analyzer-checker=alpha.security.MmapWriteExec -verify %s
+
+#define PROT_WRITE  0x02
+#ifndef USE_ALTERNATIVE_PROT_EXEC_DEFINITION
+#define PROT_EXEC   0x04
+#define PROT_READ   0x01
+#else
+#define PROT_EXEC   0x01
+#define PROT_READ   0x04
+#endif
+#define MAP_PRIVATE 0x0002
+#define MAP_ANON0x1000
+#define MAP_FIXED   0x0010
+#define NULL((void *)0)
+
+typedef __typeof(sizeof(int)) size_t;
+void *mmap(void *, size_t, int, int, int, long);
+
+void f1()
+{
+  void *a = mmap(NULL, 16, PROT_READ | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0); // no-warning
+  void *b = mmap(a, 16, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED | MAP_ANON, -1, 0); // no-warning
+  void *c = mmap(NULL, 32, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0); // expected-warning{{Both PROT_WRITE and PROT_EXEC flags are set. This can lead to exploitable memory regions, which could be overwritten with malicious code}}
+  (void)a;
+  (void)b;
+  (void)c;
+}
+
+void f2()
+{
+  void *(*callm)(void *, size_t, int, int, int, long);
+  callm = mmap;
+  int prot = PROT_WRITE | PROT_EXEC;
+  (void)callm(NULL, 1024, prot, MAP_PRIVATE | MAP_ANON, -1, 0); // expected-warning{{Both PROT_WRITE and PROT_EXEC flags are set. This can lead to exploitable memory regions, which could be overwritten with malicious code}}
+}
Index: include/clang/StaticAnalyzer/Checkers/Checkers.td
===
--- include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -414,6 +414,13 @@
   HelpText<"Check for overflows in the arguments to malloc()">,
   DescFile<"MallocOverflowSecurityChecker.cpp">;
 
+// Operating systems specific PROT_READ/PROT_WRITE values is not implemented,
+// thus ought to be overriden with the proper analyser-config variables
+// remain in alpha until the state changes
+def MmapWriteExecChecker : Checker<"MmapWriteExec">,
+  HelpText<"Warn on mmap() calls that are both writable and executable">,
+  DescFile<"MmapWriteExecChecker.cpp">;
+
 } // end "alpha.security"
 
 //===--===//
Index: lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
@@ -0,0 +1,87 @@
+// MmapWriteExecChecker.cpp - Check for the prot argument -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This checker tests the 3rd argument of mmap's calls to check if
+// it is writable and executable in the same time. It's somehow
+// an optional checker since for example in JIT libraries it is pretty common.
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namespace ento;
+using llvm::APSInt;
+
+namespace {
+class MmapWriteExecChecker : public Checker {
+  CallDescription MmapFn;
+  static int ProtWrite;
+  static int ProtExec;
+  static int ProtRead;
+  mutable std::unique_ptr BT;
+public:
+  MmapWriteExecChecker() : MmapFn("mmap", 6) {}
+  void checkPreCall(const CallEvent , CheckerContext ) const;
+  int ProtExecOv;
+  int ProtReadOv;
+};
+}
+
+int MmapWriteExecChecker::ProtWrite = 0x02;
+int MmapWriteExecChecker::ProtExec  = 0x04;
+int MmapWriteExecChecker::ProtRead  = 0x01;
+
+void MmapWriteExecChecker::checkPreCall(const CallEvent ,
+ CheckerContext ) const {
+  if 

Re: [PATCH] D43362: Simplify setting dso_local. NFC.

2018-02-20 Thread Rafael Avila de Espindola via cfe-commits
ping

Rafael Avila de Espindola via Phabricator 
writes:

> espindola created this revision.
> espindola added a reviewer: rnk.
>
> The value of dso_local can be computed from just IR properties and global 
> information (object file type, command line options, etc).
>
> With this patch we no longer pass in the Decl. It was almost unused and 
> making it fully unused guarantees that dso_local is consistent with the rest 
> of the IR.
>
>
> https://reviews.llvm.org/D43362
>
> Files:
>   lib/CodeGen/CodeGenModule.cpp
>   lib/CodeGen/CodeGenModule.h
>   lib/CodeGen/ItaniumCXXABI.cpp
>
>
> Index: lib/CodeGen/ItaniumCXXABI.cpp
> ===
> --- lib/CodeGen/ItaniumCXXABI.cpp
> +++ lib/CodeGen/ItaniumCXXABI.cpp
> @@ -3214,10 +3214,10 @@
>  llvmVisibility = CodeGenModule::GetLLVMVisibility(Ty->getVisibility());
>  
>TypeName->setVisibility(llvmVisibility);
> -  CGM.setDSOLocal(TypeName, Ty->getAsCXXRecordDecl());
> +  CGM.setDSOLocal(TypeName);
>  
>GV->setVisibility(llvmVisibility);
> -  CGM.setDSOLocal(GV, Ty->getAsCXXRecordDecl());
> +  CGM.setDSOLocal(GV);
>  
>if (CGM.getTriple().isWindowsItaniumEnvironment()) {
>  auto RD = Ty->getAsCXXRecordDecl();
> Index: lib/CodeGen/CodeGenModule.h
> ===
> --- lib/CodeGen/CodeGenModule.h
> +++ lib/CodeGen/CodeGenModule.h
> @@ -721,7 +721,7 @@
>/// Set the visibility for the given LLVM GlobalValue.
>void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const;
>  
> -  void setDSOLocal(llvm::GlobalValue *GV, const NamedDecl *D) const;
> +  void setDSOLocal(llvm::GlobalValue *GV) const;
>  
>void setGVProperties(llvm::GlobalValue *GV, const NamedDecl *D) const;
>  
> Index: lib/CodeGen/CodeGenModule.cpp
> ===
> --- lib/CodeGen/CodeGenModule.cpp
> +++ lib/CodeGen/CodeGenModule.cpp
> @@ -716,7 +716,7 @@
>  }
>  
>  static bool shouldAssumeDSOLocal(const CodeGenModule ,
> - llvm::GlobalValue *GV, const NamedDecl *D) {
> + llvm::GlobalValue *GV) {
>const llvm::Triple  = CGM.getTriple();
>// Only handle ELF for now.
>if (!TT.isOSBinFormatELF())
> @@ -746,31 +746,30 @@
>  return false;
>  
>// If we can use copy relocations we can assume it is local.
> -  if (auto *VD = dyn_cast(D))
> -if (VD->getTLSKind() == VarDecl::TLS_None &&
> +  if (auto *Var = dyn_cast(GV))
> +if (!Var->isThreadLocal() &&
>  (RM == llvm::Reloc::Static || CGOpts.PIECopyRelocations))
>return true;
>  
>// If we can use a plt entry as the symbol address we can assume it
>// is local.
>// FIXME: This should work for PIE, but the gold linker doesn't support it.
> -  if (isa(D) && !CGOpts.NoPLT && RM == llvm::Reloc::Static)
> +  if (isa(GV) && !CGOpts.NoPLT && RM == llvm::Reloc::Static)
>  return true;
>  
>// Otherwise don't assue it is local.
>return false;
>  }
>  
> -void CodeGenModule::setDSOLocal(llvm::GlobalValue *GV,
> -const NamedDecl *D) const {
> -  if (shouldAssumeDSOLocal(*this, GV, D))
> +void CodeGenModule::setDSOLocal(llvm::GlobalValue *GV) const {
> +  if (shouldAssumeDSOLocal(*this, GV))
>  GV->setDSOLocal(true);
>  }
>  
>  void CodeGenModule::setGVProperties(llvm::GlobalValue *GV,
>  const NamedDecl *D) const {
>setGlobalVisibility(GV, D);
> -  setDSOLocal(GV, D);
> +  setDSOLocal(GV);
>  }
>  
>  static llvm::GlobalVariable::ThreadLocalMode GetLLVMTLSModel(StringRef S) {
> @@ -2753,14 +2752,15 @@
>  GV->setAlignment(getContext().getDeclAlign(D).getQuantity());
>  
>  setLinkageForGV(GV, D);
> -setGVProperties(GV, D);
>  
>  if (D->getTLSKind()) {
>if (D->getTLSKind() == VarDecl::TLS_Dynamic)
>  CXXThreadLocals.push_back(D);
>setTLSMode(GV, *D);
>  }
>  
> +setGVProperties(GV, D);
> +
>  // If required by the ABI, treat declarations of static data members with
>  // inline initializers as definitions.
>  if (getContext().isMSStaticDataMemberInlineDefinition(D)) {
>
>
> Index: lib/CodeGen/ItaniumCXXABI.cpp
> ===
> --- lib/CodeGen/ItaniumCXXABI.cpp
> +++ lib/CodeGen/ItaniumCXXABI.cpp
> @@ -3214,10 +3214,10 @@
>  llvmVisibility = CodeGenModule::GetLLVMVisibility(Ty->getVisibility());
>  
>TypeName->setVisibility(llvmVisibility);
> -  CGM.setDSOLocal(TypeName, Ty->getAsCXXRecordDecl());
> +  CGM.setDSOLocal(TypeName);
>  
>GV->setVisibility(llvmVisibility);
> -  CGM.setDSOLocal(GV, Ty->getAsCXXRecordDecl());
> +  CGM.setDSOLocal(GV);
>  
>if (CGM.getTriple().isWindowsItaniumEnvironment()) {
>  auto RD = Ty->getAsCXXRecordDecl();
> Index: lib/CodeGen/CodeGenModule.h
> 

[PATCH] D43510: [clangd] don't insert new includes if either original header or canonical header is already included.

2018-02-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Mostly nits around naming/doc: you've convinced me that the two headers that 
are paths or uris or  at different times is the right thing, but we 
need to be really clear about it.




Comment at: clangd/ClangdServer.cpp:320
+StringRef PreferredHeader) {
+  auto Resolve = [File](StringRef Header) -> llvm::Expected {
+if (Header.empty() || Header.startswith("<") || Header.startswith("\""))

For readability, I'd suggest pulling this out into a real function, and 
returning something like
`struct HeaderFile { std::string File; bool Verbatim; }` which could be passed 
to the `Headers.h` functions.

The fold of "literal or uri" -> "literal or file" all typed as 'string' is a 
bit too much I think.
But maybe more explicit names and comments would moke this clearer.



Comment at: clangd/ClangdServer.h:239
+  /// Inserts a new #include into \p File, if it's not present in \p Code.
+  /// \p OriginalHeader The original header corresponding to this insertion.
+  /// This may be different from preferredHeader as a header file can have a

sammccall wrote:
> I really do want to know what this parameter does, but I don't understand it 
> from this comment.
Discussed offline - this is the header file (either URI or ) that 
directly declares the symbol.
I'd suggest calling this `DeclaringHeader`.



Comment at: clangd/ClangdServer.h:240
+  /// \p OriginalHeader The original header corresponding to this insertion.
+  /// This may be different from preferredHeader as a header file can have a
+  /// different canonical include. This could be either a URI or a literal

the "this may be different" probably belongs after the doc of PreferredHeader 
(backreferences are easier to follow than forward ones)



Comment at: clangd/ClangdServer.h:243
+  /// string quoted with <> or "" that can be #included directly.
+  /// \p PreferredHeader The preferred header to be inserted. The has the same
+  /// semantic as \p OriginalHeader. If empty, \p OriginalHeader is used to

sammccall wrote:
> "this has the same semantic as OriginalHeader" contradicts "[OriginalHeader] 
> may be different from preferredHeader" :-)
T think `InsertedHeader` might be clearer about its role.



Comment at: clangd/ClangdServer.h:243
+  /// string quoted with <> or "" that can be #included directly.
+  /// \p PreferredHeader The preferred header to be inserted. The has the same
+  /// semantic as \p OriginalHeader. If empty, \p OriginalHeader is used to

sammccall wrote:
> sammccall wrote:
> > "this has the same semantic as OriginalHeader" contradicts 
> > "[OriginalHeader] may be different from preferredHeader" :-)
> T think `InsertedHeader` might be clearer about its role.
I'd suggest being explicit, since this is different to above: "if this is a 
URI, insertInclude will determine how to spell it. If this is a quoted string, 
it will be inserted verbatim".



Comment at: clangd/ClangdServer.h:244
+  /// \p PreferredHeader The preferred header to be inserted. The has the same
+  /// semantic as \p OriginalHeader. If empty, \p OriginalHeader is used to
+  /// calculate the #include path.

Drop the "empty" special case, the caller should always pass this in.



Comment at: clangd/ClangdServer.h:246
+  /// calculate the #include path.
   Expected insertInclude(PathRef File, StringRef Code,
+StringRef OriginalHeader,

Worth pointing out at the end "Both OriginalHeader and InsertedHeader will be 
considered to determine whether an include needs to be added".



Comment at: clangd/Headers.cpp:72
+return "";
+  if (OriginalHeader.empty() && PreferredHeader.empty())
 return "";

how could this happen?



Comment at: clangd/Headers.cpp:126
+  };
+  if (Included(OriginalHeader) || Included(PreferredHeader))
 return llvm::make_error(

oops, missed this in the previous commit - this isn't an error condition, but a 
"return empty string" condition.

Can we add a test for this?



Comment at: clangd/Headers.h:23
+/// Returns true if \p Include is literal include like "path" or .
+bool isLiteralInclude(llvm::StringRef Include);
+

only used in headers.cpp, make static?



Comment at: clangd/Headers.h:29
 ///
+/// If non-empty, \p PreferredHeader is used to calculate the include path;
+/// otherwise, \p OriginalHeader is used.

again, this special case isn't needed as copying a stringref is cheap



Comment at: clangd/Headers.h:33
 /// \param File is an absolute file path.
-/// \param Header is an absolute file path.
-/// \return A quoted "path" or . This returns an empty string if:
-///   - \p 

[PATCH] D43510: [clangd] don't insert new includes if either original header or canonical header is already included.

2018-02-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/ClangdServer.h:239
+  /// Inserts a new #include into \p File, if it's not present in \p Code.
+  /// \p OriginalHeader The original header corresponding to this insertion.
+  /// This may be different from preferredHeader as a header file can have a

I really do want to know what this parameter does, but I don't understand it 
from this comment.



Comment at: clangd/ClangdServer.h:243
+  /// string quoted with <> or "" that can be #included directly.
+  /// \p PreferredHeader The preferred header to be inserted. The has the same
+  /// semantic as \p OriginalHeader. If empty, \p OriginalHeader is used to

"this has the same semantic as OriginalHeader" contradicts "[OriginalHeader] 
may be different from preferredHeader" :-)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43510



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


[PATCH] D41537: Optionally add code completion results for arrow instead of dot

2018-02-20 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

ping


https://reviews.llvm.org/D41537



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


[PATCH] D43510: [clangd] don't insert new includes if either original header or canonical header is already included.

2018-02-20 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: sammccall.
Herald added subscribers: cfe-commits, jkorous-apple, ilya-biryukov, klimek.

Changes:
o Store both the original header and the canonical header in LSP command.
o Also check that both original and canonical headers are not already included
by comparing both resolved header path and written literal includes.

This addresses the use case where private IWYU pragma is defined in a private
header while it would still be preferrable to include the private header, in the
internal implementation file. If we have seen that the priviate header is 
already
included, we don't try to insert the canonical include.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43510

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/CodeComplete.cpp
  clangd/Headers.cpp
  clangd/Headers.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  test/clangd/insert-include.test
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/HeadersTests.cpp

Index: unittests/clangd/HeadersTests.cpp
===
--- unittests/clangd/HeadersTests.cpp
+++ unittests/clangd/HeadersTests.cpp
@@ -24,14 +24,14 @@
   }
 
 protected:
-  // Calculates the include path for \p Header, or returns "" on error.
-  std::string calculate(PathRef Header) {
+  // Calculates the include path, or returns "" on error.
+  std::string calculate(PathRef Original, PathRef Preferred = "") {
 auto VFS = FS.getTaggedFileSystem(MainFile).Value;
 auto Cmd = CDB.getCompileCommand(MainFile);
 assert(static_cast(Cmd));
 VFS->setCurrentWorkingDirectory(Cmd->Directory);
-auto Path =
-calculateIncludePath(MainFile, FS.Files[MainFile], Header, *Cmd, VFS);
+auto Path = calculateIncludePath(MainFile, FS.Files[MainFile], Original,
+ Preferred, *Cmd, VFS);
 if (!Path) {
   llvm::consumeError(Path.takeError());
   return std::string();
@@ -66,7 +66,21 @@
   FS.Files[MainFile] = R"cpp(
 #include "sub/bar.h"  // not shortest
 )cpp";
-  EXPECT_EQ(calculate(BarHeader), "");
+  EXPECT_EQ(calculate("\"sub/bar.h\""), ""); // Duplicate rewritten.
+  EXPECT_EQ(calculate(BarHeader), "");   // Duplicate resolved.
+  EXPECT_EQ(calculate(BarHeader, "\"BAR.h\""), ""); // Do not insert preferred.
+}
+
+TEST_F(HeadersTest, DontInsertDuplicatePreferred) {
+  std::string BarHeader = testPath("sub/bar.h");
+  FS.Files[BarHeader] = "";
+  FS.Files[MainFile] = R"cpp(
+#include "sub/bar.h"  // not shortest
+)cpp";
+  // Duplicate written.
+  EXPECT_EQ(calculate("\"original.h\"", "\"sub/bar.h\""), "");
+  // Duplicate resolved.
+  EXPECT_EQ(calculate("\"original.h\"", BarHeader), "");
 }
 
 TEST_F(HeadersTest, StillInsertIfTrasitivelyIncluded) {
@@ -88,6 +102,17 @@
   EXPECT_EQ(calculate(MainFile), "");
 }
 
+TEST_F(HeadersTest, PreferredHeader) {
+  FS.Files[MainFile] = "";
+  std::string BarHeader = testPath("sub/bar.h");
+  FS.Files[BarHeader] = "";
+  EXPECT_EQ(calculate(BarHeader, ""), "");
+
+  std::string BazHeader = testPath("sub/baz.h");
+  FS.Files[BazHeader] = "";
+  EXPECT_EQ(calculate(BarHeader, BazHeader), "\"baz.h\"");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -862,6 +862,8 @@
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB;
+  std::string SearchDirArg = (llvm::Twine("-I") + testRoot()).str();
+  CDB.ExtraClangFlags.insert(CDB.ExtraClangFlags.end(), {SearchDirArg.c_str()});
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*AsyncThreadsCount=*/0,
   /*StorePreamblesInMemory=*/true);
@@ -877,17 +879,30 @@
   FS.Files[FooCpp] = Code;
   Server.addDocument(FooCpp, Code);
 
-  auto Inserted = [&](llvm::StringRef Header, llvm::StringRef Expected) {
-auto Replaces = Server.insertInclude(FooCpp, Code, Header);
+  auto Inserted = [&](llvm::StringRef Original, llvm::StringRef Preferred,
+  llvm::StringRef Expected) {
+auto Replaces = Server.insertInclude(FooCpp, Code, Original, Preferred);
 EXPECT_TRUE(static_cast(Replaces));
 auto Changed = tooling::applyAllReplacements(Code, *Replaces);
 EXPECT_TRUE(static_cast(Changed));
 return llvm::StringRef(*Changed).contains(
 (llvm::Twine("#include ") + Expected + "").str());
   };
 
-  EXPECT_TRUE(Inserted("\"y.h\"", "\"y.h\""));
-  EXPECT_TRUE(Inserted("", ""));
+  EXPECT_TRUE(Inserted("\"y.h\"", /*Preferred=*/"","\"y.h\""));
+  EXPECT_TRUE(Inserted("\"y.h\"", /*Preferred=*/"\"Y.h\"", "\"Y.h\""));
+  EXPECT_TRUE(Inserted("", /*Preferred=*/"", ""));
+  EXPECT_TRUE(Inserted("", /*Preferred=*/"", ""));
+
+  std::string OriginalHeader = 

[PATCH] D43509: [libcxx][cmake] Remove libatomic temporarily from CMAKE_REQUIRED_LIBRARIES when configuring

2018-02-20 Thread Simon Dardis via Phabricator via cfe-commits
sdardis created this revision.
sdardis added a reviewer: EricWF.
Herald added subscribers: christof, mgorny.

When libcxx is built in tree for a host which requires libatomic, LLVM's
configuration steps will determine it is required and add it to
CMAKE_REQUIRED_LIBRARIES. When libcxx is later configured, it tests if it
has C++ atomics without libatomic. The test erroneously passes as libatomic
is already part of the set of required libraries.

In turn, a number of the atomic tests will fail as they require libatomic
but the test suite is configured not to use libatomic.

Address this by always dropping libatomic from the set of required libraries
before determining if LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB is true,
then restoring the set of required libraries.


Repository:
  rCXX libc++

https://reviews.llvm.org/D43509

Files:
  cmake/Modules/CheckLibcxxAtomic.cmake


Index: cmake/Modules/CheckLibcxxAtomic.cmake
===
--- cmake/Modules/CheckLibcxxAtomic.cmake
+++ cmake/Modules/CheckLibcxxAtomic.cmake
@@ -31,7 +31,14 @@
   set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
 endfunction(check_cxx_atomics)
 
+# Perform the check for 64bit atomics without libatomic. It may have been added
+# to the required libraries earlier in the configuration, which would cause
+# this check to incorrectly pass.
+set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "atomic")
 check_cxx_atomics(LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB)
+set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
+
 check_library_exists(atomic __atomic_fetch_add_8 "" LIBCXX_HAS_ATOMIC_LIB)
 # If not, check if the library exists, and atomics work with it.
 if(NOT LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB)


Index: cmake/Modules/CheckLibcxxAtomic.cmake
===
--- cmake/Modules/CheckLibcxxAtomic.cmake
+++ cmake/Modules/CheckLibcxxAtomic.cmake
@@ -31,7 +31,14 @@
   set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
 endfunction(check_cxx_atomics)
 
+# Perform the check for 64bit atomics without libatomic. It may have been added
+# to the required libraries earlier in the configuration, which would cause
+# this check to incorrectly pass.
+set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "atomic")
 check_cxx_atomics(LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB)
+set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
+
 check_library_exists(atomic __atomic_fetch_add_8 "" LIBCXX_HAS_ATOMIC_LIB)
 # If not, check if the library exists, and atomics work with it.
 if(NOT LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43162: [Parser] (C++) Make -Wextra-semi slightly more useful

2018-02-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

To be clear -- my concerns were mostly that it seems messy for this sort of 
thing to require three different diagnostic entries and somewhat convoluted 
logic to select them -- if we can find a way to generalize this, that'd be 
better.


Repository:
  rC Clang

https://reviews.llvm.org/D43162



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


Re: r325375 - [MS] Make constexpr static data members implicitly inline

2018-02-20 Thread Hans Wennborg via cfe-commits
Reverted in r325576 due to PR36453, and merged the revert to 6.0 in r325577.

On Mon, Feb 19, 2018 at 3:09 PM, Hans Wennborg  wrote:
> Merged to 6.0 in r325500.
>
> On Fri, Feb 16, 2018 at 8:44 PM, Reid Kleckner via cfe-commits
>  wrote:
>> Author: rnk
>> Date: Fri Feb 16 11:44:47 2018
>> New Revision: 325375
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=325375=rev
>> Log:
>> [MS] Make constexpr static data members implicitly inline
>>
>> This handles them exactly the same way that we handle const integral
>> static data members with inline definitions, which is what MSVC does.
>>
>> As a follow-up, now that we have a way to mark variables inline in the
>> AST, we should consider marking them implicitly inline there instead of
>> only treating them as inline in CodeGen. Unfortunately, this breaks a
>> lot of dllimport test cases, so that is future work for now.
>>
>> Fixes PR36125.
>>
>> Modified:
>> cfe/trunk/lib/AST/ASTContext.cpp
>> cfe/trunk/test/CodeGenCXX/static-data-member.cpp
>>
>> Modified: cfe/trunk/lib/AST/ASTContext.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=325375=325374=325375=diff
>> ==
>> --- cfe/trunk/lib/AST/ASTContext.cpp (original)
>> +++ cfe/trunk/lib/AST/ASTContext.cpp Fri Feb 16 11:44:47 2018
>> @@ -5857,7 +5857,7 @@ CharUnits ASTContext::getObjCEncodingTyp
>>  bool ASTContext::isMSStaticDataMemberInlineDefinition(const VarDecl *VD) 
>> const {
>>return getTargetInfo().getCXXABI().isMicrosoft() &&
>>   VD->isStaticDataMember() &&
>> - VD->getType()->isIntegralOrEnumerationType() &&
>> + (VD->getType()->isIntegralOrEnumerationType() || 
>> VD->isConstexpr()) &&
>>   !VD->getFirstDecl()->isOutOfLine() && 
>> VD->getFirstDecl()->hasInit();
>>  }
>>
>>
>> Modified: cfe/trunk/test/CodeGenCXX/static-data-member.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/static-data-member.cpp?rev=325375=325374=325375=diff
>> ==
>> --- cfe/trunk/test/CodeGenCXX/static-data-member.cpp (original)
>> +++ cfe/trunk/test/CodeGenCXX/static-data-member.cpp Fri Feb 16 11:44:47 2018
>> @@ -1,6 +1,10 @@
>> -// RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
>> -// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | \
>> -// RUN: FileCheck --check-prefix=MACHO %s
>> +// RUN: %clang_cc1 -triple x86_64-pc-linux -std=c++14 -emit-llvm -o - %s | 
>> FileCheck %s
>> +// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++14 -emit-llvm -o - 
>> %s \
>> +// RUN: | FileCheck %s --check-prefix=MACHO
>> +// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -std=c++14 -emit-llvm -o 
>> - %s \
>> +// RUN: | FileCheck %s --check-prefix=MSVC
>> +// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -std=c++17 -emit-llvm -o 
>> - %s \
>> +// RUN: | FileCheck %s --check-prefix=MSVC
>>
>>  // CHECK: @_ZN5test11A1aE = constant i32 10, align 4
>>  // CHECK: @_ZN5test212_GLOBAL__N_11AIiE1xE = internal global i32 0, align 4
>> @@ -9,12 +13,25 @@
>>  // MACHO: @_ZGVN5test31AIiE1xE = weak_odr global i64 0
>>  // MACHO-NOT: comdat
>>
>> +// MSVC: @"\01?a@A@test1@@2HB" = linkonce_odr constant i32 10, comdat, 
>> align 4
>> +// MSVC: @"\01?i@S@test1@@2HA" = external global i32
>> +// MSVC: @"\01?x@?$A@H@?A@test2@@2HA" = internal global i32 0, align 4
>> +
>>  // CHECK: _ZN5test51U2k0E = global i32 0
>>  // CHECK: _ZN5test51U2k1E = global i32 0
>>  // CHECK: _ZN5test51U2k2E = constant i32 76
>>  // CHECK-NOT: test51U2k3E
>>  // CHECK-NOT: test51U2k4E
>>
>> +// On Linux in C++14, neither of these are inline.
>> +// CHECK: @_ZN16inline_constexpr1A10just_constE = available_externally 
>> constant i32 42
>> +// CHECK: @_ZN16inline_constexpr1A10const_exprE = available_externally 
>> constant i32 43
>> +//
>> +// In MSVC, these are both implicitly inline regardless of the C++ standard
>> +// version.
>> +// MSVC: @"\01?just_const@A@inline_constexpr@@2HB" = linkonce_odr constant 
>> i32 42, comdat, align 4
>> +// MSVC: @"\01?const_expr@A@inline_constexpr@@2HB" = linkonce_odr constant 
>> i32 43, comdat, align 4
>> +
>>  // PR5564.
>>  namespace test1 {
>>struct A {
>> @@ -28,7 +45,7 @@ namespace test1 {
>>};
>>
>>void f() {
>> -int a = S::i;
>> +int a = *::a + S::i;
>>}
>>  }
>>
>> @@ -50,6 +67,11 @@ namespace test2 {
>>// CHECK:  [[TMP:%.*]] = call i32 @_ZN5test23fooEv()
>>// CHECK-NEXT: store i32 [[TMP]], i32* @_ZN5test212_GLOBAL__N_11AIiE1xE, 
>> align 4
>>// CHECK-NEXT: ret void
>> +
>> +  // MSVC-LABEL: define internal void 
>> @"\01??__Ex@?$A@H@?A@test2@@2HA@YAXXZ"()
>> +  // MSVC:  [[TMP:%.*]] = call i32 @"\01?foo@test2@@YAHXZ"()
>> +  // MSVC-NEXT: store i32 [[TMP]], i32* @"\01?x@?$A@H@?A@test2@@2HA", align 
>> 4
>> +  // MSVC-NEXT: 

r325576 - Revert r325375 "[MS] Make constexpr static data members implicitly inline"

2018-02-20 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue Feb 20 04:43:02 2018
New Revision: 325576

URL: http://llvm.org/viewvc/llvm-project?rev=325576=rev
Log:
Revert r325375 "[MS] Make constexpr static data members implicitly inline"

This broke Clang bootstrap on Windows, PR36453.

> This handles them exactly the same way that we handle const integral
> static data members with inline definitions, which is what MSVC does.
>
> As a follow-up, now that we have a way to mark variables inline in the
> AST, we should consider marking them implicitly inline there instead of
> only treating them as inline in CodeGen. Unfortunately, this breaks a
> lot of dllimport test cases, so that is future work for now.
>
> Fixes PR36125.

Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/CodeGenCXX/static-data-member.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=325576=325575=325576=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Feb 20 04:43:02 2018
@@ -5857,7 +5857,7 @@ CharUnits ASTContext::getObjCEncodingTyp
 bool ASTContext::isMSStaticDataMemberInlineDefinition(const VarDecl *VD) const 
{
   return getTargetInfo().getCXXABI().isMicrosoft() &&
  VD->isStaticDataMember() &&
- (VD->getType()->isIntegralOrEnumerationType() || VD->isConstexpr()) &&
+ VD->getType()->isIntegralOrEnumerationType() &&
  !VD->getFirstDecl()->isOutOfLine() && VD->getFirstDecl()->hasInit();
 }
 

Modified: cfe/trunk/test/CodeGenCXX/static-data-member.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/static-data-member.cpp?rev=325576=325575=325576=diff
==
--- cfe/trunk/test/CodeGenCXX/static-data-member.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/static-data-member.cpp Tue Feb 20 04:43:02 2018
@@ -1,10 +1,6 @@
-// RUN: %clang_cc1 -triple x86_64-pc-linux -std=c++14 -emit-llvm -o - %s | 
FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++14 -emit-llvm -o - %s \
-// RUN: | FileCheck %s --check-prefix=MACHO
-// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -std=c++14 -emit-llvm -o - 
%s \
-// RUN: | FileCheck %s --check-prefix=MSVC
-// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -std=c++17 -emit-llvm -o - 
%s \
-// RUN: | FileCheck %s --check-prefix=MSVC
+// RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | \
+// RUN: FileCheck --check-prefix=MACHO %s
 
 // CHECK: @_ZN5test11A1aE = constant i32 10, align 4
 // CHECK: @_ZN5test212_GLOBAL__N_11AIiE1xE = internal global i32 0, align 4
@@ -13,25 +9,12 @@
 // MACHO: @_ZGVN5test31AIiE1xE = weak_odr global i64 0
 // MACHO-NOT: comdat
 
-// MSVC: @"\01?a@A@test1@@2HB" = linkonce_odr constant i32 10, comdat, align 4
-// MSVC: @"\01?i@S@test1@@2HA" = external global i32
-// MSVC: @"\01?x@?$A@H@?A@test2@@2HA" = internal global i32 0, align 4
-
 // CHECK: _ZN5test51U2k0E = global i32 0
 // CHECK: _ZN5test51U2k1E = global i32 0
 // CHECK: _ZN5test51U2k2E = constant i32 76
 // CHECK-NOT: test51U2k3E
 // CHECK-NOT: test51U2k4E
 
-// On Linux in C++14, neither of these are inline.
-// CHECK: @_ZN16inline_constexpr1A10just_constE = available_externally 
constant i32 42
-// CHECK: @_ZN16inline_constexpr1A10const_exprE = available_externally 
constant i32 43
-//
-// In MSVC, these are both implicitly inline regardless of the C++ standard
-// version.
-// MSVC: @"\01?just_const@A@inline_constexpr@@2HB" = linkonce_odr constant i32 
42, comdat, align 4
-// MSVC: @"\01?const_expr@A@inline_constexpr@@2HB" = linkonce_odr constant i32 
43, comdat, align 4
-
 // PR5564.
 namespace test1 {
   struct A {
@@ -45,7 +28,7 @@ namespace test1 {
   };
 
   void f() { 
-int a = *::a + S::i;
+int a = S::i;
   }
 }
 
@@ -67,11 +50,6 @@ namespace test2 {
   // CHECK:  [[TMP:%.*]] = call i32 @_ZN5test23fooEv()
   // CHECK-NEXT: store i32 [[TMP]], i32* @_ZN5test212_GLOBAL__N_11AIiE1xE, 
align 4
   // CHECK-NEXT: ret void
-
-  // MSVC-LABEL: define internal void @"\01??__Ex@?$A@H@?A@test2@@2HA@YAXXZ"()
-  // MSVC:  [[TMP:%.*]] = call i32 @"\01?foo@test2@@YAHXZ"()
-  // MSVC-NEXT: store i32 [[TMP]], i32* @"\01?x@?$A@H@?A@test2@@2HA", align 4
-  // MSVC-NEXT: ret void
 }
 
 // Test that we don't use threadsafe statics when initializing
@@ -130,13 +108,3 @@ namespace test5 {
   // CHECK: store i32 {{.*}}, i32* @_ZN5test51U2k1E
   // CHECK-NOT: store {{.*}} i32* @_ZN5test51U2k2E
 }
-
-// Test that MSVC mode static constexpr data members are always inline, even 
pre
-// C++17.
-namespace inline_constexpr {
-struct A {
-  static const int just_const = 42;
-  static constexpr int const_expr = 43;
-};
-int useit() { return *::just_const + *::const_expr; }
-}



[PATCH] D43487: [mips] Spectre variant two mitigation for MIPSR2

2018-02-20 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D43487



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


[PATCH] D42366: [CodeGen] Fix generation of TBAA tags for may-alias accesses

2018-02-20 Thread Ivan Kosarev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC325575: [CodeGen] Fix generation of TBAA tags for may-alias 
accesses (authored by kosarev, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D42366

Files:
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenTBAA.cpp
  lib/CodeGen/CodeGenTBAA.h
  test/CodeGen/may-alias.c

Index: test/CodeGen/may-alias.c
===
--- test/CodeGen/may-alias.c
+++ test/CodeGen/may-alias.c
@@ -1,42 +1,61 @@
-// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 -no-struct-path-tbaa -disable-llvm-passes -o - %s | FileCheck %s
-// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 -disable-llvm-passes -o - %s | FileCheck %s -check-prefix=PATH
+// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 \
+// RUN: -no-struct-path-tbaa -disable-llvm-passes -o - %s | \
+// RUN: FileCheck %s -check-prefixes=CHECK,SCALAR
+// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 \
+// RUN: -disable-llvm-passes -o - %s | \
+// RUN: FileCheck %s -check-prefixes=CHECK,OLD-PATH
+// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 \
+// RUN: -new-struct-path-tbaa -disable-llvm-passes -o - %s | \
+// RUN: FileCheck %s -check-prefixes=CHECK,NEW-PATH
 
 // Types with the may_alias attribute should be considered equivalent
 // to char for aliasing.
 
 typedef int __attribute__((may_alias)) aliasing_int;
 
-void test0(aliasing_int *ai, int *i)
-{
-// CHECK: store i32 0, i32* %{{.*}}, !tbaa [[TAG_CHAR:!.*]]
-// PATH: store i32 0, i32* %{{.*}}, !tbaa [[TAG_CHAR:!.*]]
+void test0(aliasing_int *ai, int *i) {
+// CHECK-LABEL: test0
+// CHECK: store i32 0, {{.*}}, !tbaa [[TAG_alias_int:!.*]]
   *ai = 0;
-// CHECK: store i32 1, i32* %{{.*}}, !tbaa [[TAG_INT:!.*]]
-// PATH: store i32 1, i32* %{{.*}}, !tbaa [[TAG_INT:!.*]]
+
+// CHECK: store i32 1, {{.*}}, !tbaa [[TAG_int:!.*]]
   *i = 1;
 }
 
 // PR9307
 struct Test1 { int x; };
 struct Test1MA { int x; } __attribute__((may_alias));
 void test1(struct Test1MA *p1, struct Test1 *p2) {
-  // CHECK: store i32 2, i32* {{%.*}}, !tbaa [[TAG_CHAR]]
-  // PATH: store i32 2, i32* {{%.*}}, !tbaa [[TAG_CHAR]]
+// CHECK-LABEL: test1
+// CHECK: store i32 2, {{.*}}, !tbaa [[TAG_alias_test1_x:!.*]]
   p1->x = 2;
-  // CHECK: store i32 3, i32* {{%.*}}, !tbaa [[TAG_INT]]
-  // PATH: store i32 3, i32* {{%.*}}, !tbaa [[TAG_test1_x:!.*]]
+
+// CHECK: store i32 3, {{.*}}, !tbaa [[TAG_test1_x:!.*]]
   p2->x = 3;
 }
-// CHECK:  !"any pointer", [[TYPE_CHAR:!.*]],
-// CHECK: [[TYPE_CHAR]] = !{!"omnipotent char", [[TAG_CXX_TBAA:!.*]],
-// CHECK: [[TAG_CXX_TBAA]] = !{!"Simple C/C++ TBAA"}
-// CHECK: [[TAG_CHAR]] = !{[[TYPE_CHAR]], [[TYPE_CHAR]], i64 0}
-// CHECK: [[TAG_INT]] = !{[[TYPE_INT:!.*]], [[TYPE_INT]], i64 0}
-// CHECK: [[TYPE_INT]] = !{!"int", [[TYPE_CHAR]]
-
-// PATH: [[TYPE_CHAR:!.*]] = !{!"omnipotent char", !{{.*}}
-// PATH: [[TAG_CHAR]] = !{[[TYPE_CHAR]], [[TYPE_CHAR]], i64 0}
-// PATH: [[TAG_INT]] = !{[[TYPE_INT:!.*]], [[TYPE_INT]], i64 0}
-// PATH: [[TYPE_INT]] = !{!"int", [[TYPE_CHAR]]
-// PATH: [[TAG_test1_x]] = !{[[TYPE_test1:!.*]], [[TYPE_INT]], i64 0}
-// PATH: [[TYPE_test1]] = !{!"Test1", [[TYPE_INT]], i64 0}
+
+// SCALAR-DAG: [[ROOT:!.*]] = !{!"Simple C/C++ TBAA"}
+// SCALAR-DAG: [[TYPE_char:!.*]] = !{!"omnipotent char", [[ROOT]], i64 0}
+// SCALAR-DAG: [[TAG_alias_int]] = !{[[TYPE_char]], [[TYPE_char]], i64 0}
+// SCALAR-DAG: [[TAG_alias_test1_x]] = !{[[TYPE_char]], [[TYPE_char]], i64 0}
+// SCALAR-DAG: [[TYPE_int:!.*]] = !{!"int", [[TYPE_char]], i64 0}
+// SCALAR-DAG: [[TAG_int]] = !{[[TYPE_int]], [[TYPE_int]], i64 0}
+// SCALAR-DAG: [[TAG_test1_x]] = !{[[TYPE_int]], [[TYPE_int]], i64 0}
+
+// OLD-PATH-DAG: [[ROOT:!.*]] = !{!"Simple C/C++ TBAA"}
+// OLD-PATH-DAG: [[TYPE_char:!.*]] = !{!"omnipotent char", [[ROOT]], i64 0}
+// OLD-PATH-DAG: [[TAG_alias_int]] = !{[[TYPE_char]], [[TYPE_char]], i64 0}
+// OLD-PATH-DAG: [[TAG_alias_test1_x]] = !{[[TYPE_char]], [[TYPE_char]], i64 0}
+// OLD-PATH-DAG: [[TYPE_int:!.*]] = !{!"int", [[TYPE_char]], i64 0}
+// OLD-PATH-DAG: [[TAG_int]] = !{[[TYPE_int]], [[TYPE_int]], i64 0}
+// OLD-PATH-DAG: [[TYPE_test1:!.*]] = !{!"Test1", [[TYPE_int]], i64 0}
+// OLD-PATH-DAG: [[TAG_test1_x]] = !{[[TYPE_test1]], [[TYPE_int]], i64 0}
+
+// NEW-PATH-DAG: [[ROOT:!.*]] = !{!"Simple C/C++ TBAA"}
+// NEW-PATH-DAG: [[TYPE_char:!.*]] = !{[[ROOT]], i64 1, !"omnipotent char"}
+// NEW-PATH-DAG: [[TAG_alias_int]] = !{[[TYPE_char]], [[TYPE_char]], i64 0, i64 0}
+// NEW-PATH-DAG: [[TAG_alias_test1_x]] = !{[[TYPE_char]], [[TYPE_char]], i64 0, i64 0}
+// NEW-PATH-DAG: [[TYPE_int:!.*]] = !{[[TYPE_char]], i64 4, !"int"}
+// NEW-PATH-DAG: [[TAG_int]] = !{[[TYPE_int]], [[TYPE_int]], i64 0, i64 4}
+// NEW-PATH-DAG: [[TYPE_test1:!.*]] = !{[[TYPE_char]], i64 4, !"Test1", [[TYPE_int]], i64 0, i64 4}
+// NEW-PATH-DAG: [[TAG_test1_x]] = 

r325575 - [CodeGen] Fix generation of TBAA tags for may-alias accesses

2018-02-20 Thread Ivan A. Kosarev via cfe-commits
Author: kosarev
Date: Tue Feb 20 04:33:04 2018
New Revision: 325575

URL: http://llvm.org/viewvc/llvm-project?rev=325575=rev
Log:
[CodeGen] Fix generation of TBAA tags for may-alias accesses

This patch fixes creating TBAA access descriptors for
may_alias-marked access types. Currently, for such types we
generate ordinary descriptors with char as its access type. The
patch changes this to produce proper may-alias descriptors.

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

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
cfe/trunk/lib/CodeGen/CodeGenTBAA.h
cfe/trunk/test/CodeGen/may-alias.c

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=325575=325574=325575=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Feb 20 04:33:04 2018
@@ -602,13 +602,9 @@ llvm::MDNode *CodeGenModule::getTBAAType
 }
 
 TBAAAccessInfo CodeGenModule::getTBAAAccessInfo(QualType AccessType) {
-  // Pointee values may have incomplete types, but they shall never be
-  // dereferenced.
-  if (AccessType->isIncompleteType())
-return TBAAAccessInfo::getIncompleteInfo();
-
-  uint64_t Size = Context.getTypeSizeInChars(AccessType).getQuantity();
-  return TBAAAccessInfo(getTBAATypeInfo(AccessType), Size);
+  if (!TBAA)
+return TBAAAccessInfo();
+  return TBAA->getAccessInfo(AccessType);
 }
 
 TBAAAccessInfo

Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp?rev=325575=325574=325575=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp Tue Feb 20 04:33:04 2018
@@ -215,6 +215,19 @@ llvm::MDNode *CodeGenTBAA::getTypeInfo(Q
   return MetadataCache[Ty] = TypeNode;
 }
 
+TBAAAccessInfo CodeGenTBAA::getAccessInfo(QualType AccessType) {
+  // Pointee values may have incomplete types, but they shall never be
+  // dereferenced.
+  if (AccessType->isIncompleteType())
+return TBAAAccessInfo::getIncompleteInfo();
+
+  if (TypeHasMayAlias(AccessType))
+return TBAAAccessInfo::getMayAliasInfo();
+
+  uint64_t Size = Context.getTypeSizeInChars(AccessType).getQuantity();
+  return TBAAAccessInfo(getTypeInfo(AccessType), Size);
+}
+
 TBAAAccessInfo CodeGenTBAA::getVTablePtrAccessInfo(llvm::Type *VTablePtrType) {
   llvm::DataLayout DL();
   unsigned Size = DL.getPointerTypeSize(VTablePtrType);

Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTBAA.h?rev=325575=325574=325575=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenTBAA.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTBAA.h Tue Feb 20 04:33:04 2018
@@ -177,6 +177,10 @@ public:
   /// given type.
   llvm::MDNode *getTypeInfo(QualType QTy);
 
+  /// getAccessInfo - Get TBAA information that describes an access to
+  /// an object of the given type.
+  TBAAAccessInfo getAccessInfo(QualType AccessType);
+
   /// getVTablePtrAccessInfo - Get the TBAA information that describes an
   /// access to a virtual table pointer.
   TBAAAccessInfo getVTablePtrAccessInfo(llvm::Type *VTablePtrType);

Modified: cfe/trunk/test/CodeGen/may-alias.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/may-alias.c?rev=325575=325574=325575=diff
==
--- cfe/trunk/test/CodeGen/may-alias.c (original)
+++ cfe/trunk/test/CodeGen/may-alias.c Tue Feb 20 04:33:04 2018
@@ -1,18 +1,24 @@
-// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 
-no-struct-path-tbaa -disable-llvm-passes -o - %s | FileCheck %s
-// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 
-disable-llvm-passes -o - %s | FileCheck %s -check-prefix=PATH
+// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 \
+// RUN: -no-struct-path-tbaa -disable-llvm-passes -o - %s | \
+// RUN: FileCheck %s -check-prefixes=CHECK,SCALAR
+// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 \
+// RUN: -disable-llvm-passes -o - %s | \
+// RUN: FileCheck %s -check-prefixes=CHECK,OLD-PATH
+// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 \
+// RUN: -new-struct-path-tbaa -disable-llvm-passes -o - %s | \
+// RUN: FileCheck %s -check-prefixes=CHECK,NEW-PATH
 
 // Types with the may_alias attribute should be considered equivalent
 // to char for aliasing.
 
 typedef int __attribute__((may_alias)) aliasing_int;
 
-void test0(aliasing_int *ai, int *i)
-{
-// CHECK: store i32 0, i32* %{{.*}}, !tbaa [[TAG_CHAR:!.*]]
-// PATH: store i32 0, i32* %{{.*}}, !tbaa 

[PATCH] D43162: [Parser] (C++) Make -Wextra-semi slightly more useful

2018-02-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

After a brief disscussion with @aaron.ballman in IRC,
the question still stands whether this is really the correct approach,
or is there some nicer (TableGen-based?) approach.

Mainly waiting for @rsmith's opinion.


Repository:
  rC Clang

https://reviews.llvm.org/D43162



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


[clang-tools-extra] r325574 - [clangd] Dump stack on crash

2018-02-20 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Tue Feb 20 03:46:39 2018
New Revision: 325574

URL: http://llvm.org/viewvc/llvm-project?rev=325574=rev
Log:
[clangd] Dump stack on crash

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

Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp?rev=325574=325573=325574=diff
==
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Tue Feb 20 03:46:39 2018
@@ -135,6 +135,7 @@ static llvm::cl::opt YamlSymbolFil
 llvm::cl::init(""), llvm::cl::Hidden);
 
 int main(int argc, char *argv[]) {
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   llvm::cl::ParseCommandLineOptions(argc, argv, "clangd");
   if (Test) {
 RunSynchronously = true;


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


[PATCH] D40787: [clang-tidy] Replace the usage of std::uncaught_exception with std::uncaught_exceptions

2018-02-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325572: [clang-tidy] Replace the usage of 
std::uncaught_exception with std… (authored by xazax, committed by ).
Herald added subscribers: llvm-commits, klimek.

Changed prior to commit:
  https://reviews.llvm.org/D40787?vs=133814=135031#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40787

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseUncaughtExceptionsCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-uncaught-exceptions.rst
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-uncaught-exceptions.cpp

Index: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
@@ -33,6 +33,7 @@
 #include "UseNullptrCheck.h"
 #include "UseOverrideCheck.h"
 #include "UseTransparentFunctorsCheck.h"
+#include "UseUncaughtExceptionsCheck.h"
 #include "UseUsingCheck.h"
 
 using namespace clang::ast_matchers;
@@ -78,6 +79,8 @@
 CheckFactories.registerCheck("modernize-use-override");
 CheckFactories.registerCheck(
 "modernize-use-transparent-functors");
+CheckFactories.registerCheck(
+"modernize-use-uncaught-exceptions");
 CheckFactories.registerCheck("modernize-use-using");
   }
 
Index: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
@@ -27,6 +27,7 @@
   UseNullptrCheck.cpp
   UseOverrideCheck.cpp
   UseTransparentFunctorsCheck.cpp
+  UseUncaughtExceptionsCheck.cpp
   UseUsingCheck.cpp
 
   LINK_LIBS
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp
@@ -0,0 +1,104 @@
+//===--- UseUncaughtExceptionsCheck.cpp - clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "UseUncaughtExceptionsCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+void UseUncaughtExceptionsCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus17)
+return;
+
+  std::string MatchText = "::std::uncaught_exception";
+
+  // Using declaration: warning and fix-it.
+  Finder->addMatcher(
+  usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(hasName(MatchText
+  .bind("using_decl"),
+  this);
+
+  // DeclRefExpr: warning, no fix-it.
+  Finder->addMatcher(declRefExpr(allOf(to(functionDecl(hasName(MatchText))),
+   unless(callExpr(
+ .bind("decl_ref_expr"),
+ this);
+
+  // CallExpr: warning, fix-it.
+  Finder->addMatcher(
+  callExpr(allOf(hasDeclaration(functionDecl(hasName(MatchText))),
+ unless(hasAncestor(initListExpr()
+  .bind("call_expr"),
+  this);
+  // CallExpr in initialisation list: warning, fix-it with avoiding narrowing
+  // conversions.
+  Finder->addMatcher(
+  callExpr(allOf(hasAncestor(initListExpr()),
+ hasDeclaration(functionDecl(hasName(MatchText)
+  .bind("init_call_expr"),
+  this);
+}
+
+void UseUncaughtExceptionsCheck::check(const MatchFinder::MatchResult ) {
+  SourceLocation BeginLoc;
+  SourceLocation EndLoc;
+  const CallExpr *C = Result.Nodes.getNodeAs("init_call_expr");
+  bool WarnOnly = false;
+
+  if (C) {
+BeginLoc = C->getLocStart();
+EndLoc = C->getLocEnd();
+  } else if (const auto *E = Result.Nodes.getNodeAs("call_expr")) {
+BeginLoc = E->getLocStart();
+EndLoc = E->getLocEnd();
+  } else if (const auto *D =
+ Result.Nodes.getNodeAs("decl_ref_expr")) {
+BeginLoc = D->getLocStart();
+EndLoc = D->getLocEnd();
+WarnOnly = true;
+  } else {
+const auto *U = Result.Nodes.getNodeAs("using_decl");
+assert(U && "Null 

[clang-tools-extra] r325572 - [clang-tidy] Replace the usage of std::uncaught_exception with std::uncaught_exceptions

2018-02-20 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Tue Feb 20 02:48:38 2018
New Revision: 325572

URL: http://llvm.org/viewvc/llvm-project?rev=325572=rev
Log:
[clang-tidy] Replace the usage of std::uncaught_exception with 
std::uncaught_exceptions

Patch by: Daniel Kolozsvari!

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

Added:
clang-tools-extra/trunk/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseUncaughtExceptionsCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-uncaught-exceptions.rst

clang-tools-extra/trunk/test/clang-tidy/modernize-use-uncaught-exceptions.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=325572=325571=325572=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Tue Feb 20 
02:48:38 2018
@@ -27,6 +27,7 @@ add_clang_library(clangTidyModernizeModu
   UseNullptrCheck.cpp
   UseOverrideCheck.cpp
   UseTransparentFunctorsCheck.cpp
+  UseUncaughtExceptionsCheck.cpp
   UseUsingCheck.cpp
 
   LINK_LIBS

Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=325572=325571=325572=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Tue 
Feb 20 02:48:38 2018
@@ -33,6 +33,7 @@
 #include "UseNullptrCheck.h"
 #include "UseOverrideCheck.h"
 #include "UseTransparentFunctorsCheck.h"
+#include "UseUncaughtExceptionsCheck.h"
 #include "UseUsingCheck.h"
 
 using namespace clang::ast_matchers;
@@ -78,6 +79,8 @@ public:
 CheckFactories.registerCheck("modernize-use-override");
 CheckFactories.registerCheck(
 "modernize-use-transparent-functors");
+CheckFactories.registerCheck(
+"modernize-use-uncaught-exceptions");
 CheckFactories.registerCheck("modernize-use-using");
   }
 

Added: 
clang-tools-extra/trunk/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp?rev=325572=auto
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp 
Tue Feb 20 02:48:38 2018
@@ -0,0 +1,104 @@
+//===--- UseUncaughtExceptionsCheck.cpp - clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "UseUncaughtExceptionsCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+void UseUncaughtExceptionsCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus17)
+return;
+
+  std::string MatchText = "::std::uncaught_exception";
+
+  // Using declaration: warning and fix-it.
+  Finder->addMatcher(
+  usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(hasName(MatchText
+  .bind("using_decl"),
+  this);
+
+  // DeclRefExpr: warning, no fix-it.
+  Finder->addMatcher(declRefExpr(allOf(to(functionDecl(hasName(MatchText))),
+   unless(callExpr(
+ .bind("decl_ref_expr"),
+ this);
+
+  // CallExpr: warning, fix-it.
+  Finder->addMatcher(
+  callExpr(allOf(hasDeclaration(functionDecl(hasName(MatchText))),
+ unless(hasAncestor(initListExpr()
+  .bind("call_expr"),
+  this);
+  // CallExpr in initialisation list: warning, fix-it with avoiding narrowing
+  // conversions.
+  Finder->addMatcher(
+  callExpr(allOf(hasAncestor(initListExpr()),
+ hasDeclaration(functionDecl(hasName(MatchText)
+  .bind("init_call_expr"),
+  this);
+}
+
+void UseUncaughtExceptionsCheck::check(const MatchFinder::MatchResult ) 
{
+  SourceLocation BeginLoc;
+  SourceLocation EndLoc;
+  const CallExpr *C = 

r325571 - clang-cl: Make /d1PP an alias for -dD (PR36446)

2018-02-20 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue Feb 20 02:47:14 2018
New Revision: 325571

URL: http://llvm.org/viewvc/llvm-project?rev=325571=rev
Log:
clang-cl: Make /d1PP an alias for -dD (PR36446)

Modified:
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=325571=325570=325571=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Tue Feb 20 02:47:14 2018
@@ -61,6 +61,8 @@ def _SLASH_Brepro_ : CLFlag<"Brepro-">,
 def _SLASH_C : CLFlag<"C">,
   HelpText<"Don't discard comments when preprocessing">, Alias;
 def _SLASH_c : CLFlag<"c">, HelpText<"Compile only">, Alias;
+def _SLASH_d1PP : CLFlag<"d1PP">,
+  HelpText<"Retain macro definitions in /E mode">, Alias;
 def _SLASH_d1reportAllClassLayout : CLFlag<"d1reportAllClassLayout">,
   HelpText<"Dump record layout information">, Alias;
 def _SLASH_diagnostics_caret : CLFlag<"diagnostics:caret">,

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=325571=325570=325571=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Tue Feb 20 02:47:14 2018
@@ -293,6 +293,9 @@
 // RUN: %clang_cl /TP /c /GX /GX- -### -- %s 2>&1 | FileCheck 
-check-prefix=GX_ %s
 // GX_-NOT: "-fcxx-exceptions" "-fexceptions"
 
+// RUN: %clang_cl /d1PP -### -- %s 2>&1 | FileCheck -check-prefix=d1PP %s
+// d1PP: -dD
+
 // We forward any unrecognized -W diagnostic options to cc1.
 // RUN: %clang_cl -Wunused-pragmas -### -- %s 2>&1 | FileCheck 
-check-prefix=WJoined %s
 // WJoined: "-cc1"


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


[PATCH] D42684: clang-format: Allow optimizer to break template declaration.

2018-02-20 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Please given an explanation of what you are trying to achieve with this change. 
Do you intend to set the penalty high so that clang-format does other things 
first before falling back to wrapping template declarations?

Why treat separate declarations differently wrt. wrapping the template 
declarations? Will this stop at classes vs. functions? I generally have doubts 
that this option carries it's weight. Do you have a style guide that explicitly 
tells you to do this?


Repository:
  rC Clang

https://reviews.llvm.org/D42684



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


[PATCH] D42645: New simple Checker for mmap calls

2018-02-20 Thread David CARLIER via Phabricator via cfe-commits
devnexen updated this revision to Diff 135027.
devnexen added a comment.

Moving back the checker to alpha.security level.


https://reviews.llvm.org/D42645

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
  test/Analysis/mmap-writeexec.c

Index: test/Analysis/mmap-writeexec.c
===
--- test/Analysis/mmap-writeexec.c
+++ test/Analysis/mmap-writeexec.c
@@ -0,0 +1,36 @@
+// RUN: %clang_analyze_cc1 -triple i686-unknown-linux -analyzer-checker=security.MmapWriteExec -analyzer-config security.MmapWriteExec:MmapProtExec=1 -analyzer-config security.MmapWriteExec:MmapProtRead=4 -DUSE_ALTERNATIVE_PROT_EXEC_DEFINITION -verify %s
+// RUN: %clang_analyze_cc1 -triple x86_64-unknown-apple-darwin10 -analyzer-checker=security.MmapWriteExec -verify %s
+
+#define PROT_WRITE  0x02
+#ifndef USE_ALTERNATIVE_PROT_EXEC_DEFINITION
+#define PROT_EXEC   0x04
+#define PROT_READ   0x01
+#else
+#define PROT_EXEC   0x01
+#define PROT_READ   0x04
+#endif
+#define MAP_PRIVATE 0x0002
+#define MAP_ANON0x1000
+#define MAP_FIXED   0x0010
+#define NULL((void *)0)
+
+typedef __typeof(sizeof(int)) size_t;
+void *mmap(void *, size_t, int, int, int, long);
+
+void f1()
+{
+  void *a = mmap(NULL, 16, PROT_READ | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0); // no-warning
+  void *b = mmap(a, 16, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED | MAP_ANON, -1, 0); // no-warning
+  void *c = mmap(NULL, 32, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0); // expected-warning{{Both PROT_WRITE and PROT_EXEC flags are set. This can lead to exploitable memory regions, which could be overwritten with malicious code}}
+  (void)a;
+  (void)b;
+  (void)c;
+}
+
+void f2()
+{
+  void *(*callm)(void *, size_t, int, int, int, long);
+  callm = mmap;
+  int prot = PROT_WRITE | PROT_EXEC;
+  (void)callm(NULL, 1024, prot, MAP_PRIVATE | MAP_ANON, -1, 0); // expected-warning{{Both PROT_WRITE and PROT_EXEC flags are set. This can lead to exploitable memory regions, which could be overwritten with malicious code}}
+}
Index: lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
@@ -0,0 +1,87 @@
+// MmapWriteExecChecker.cpp - Check for the prot argument -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This checker tests the 3rd argument of mmap's calls to check if
+// it is writable and executable in the same time. It's somehow
+// an optional checker since for example in JIT libraries it is pretty common.
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namespace ento;
+using llvm::APSInt;
+
+namespace {
+class MmapWriteExecChecker : public Checker {
+  CallDescription MmapFn;
+  static int ProtWrite;
+  static int ProtExec;
+  static int ProtRead;
+  mutable std::unique_ptr BT;
+public:
+  MmapWriteExecChecker() : MmapFn("mmap", 6) {}
+  void checkPreCall(const CallEvent , CheckerContext ) const;
+  int ProtExecOv;
+  int ProtReadOv;
+};
+}
+
+int MmapWriteExecChecker::ProtWrite = 0x02;
+int MmapWriteExecChecker::ProtExec  = 0x04;
+int MmapWriteExecChecker::ProtRead  = 0x01;
+
+void MmapWriteExecChecker::checkPreCall(const CallEvent ,
+ CheckerContext ) const {
+  if (Call.isCalled(MmapFn)) {
+SVal ProtVal = Call.getArgSVal(2); 
+Optional ProtLoc = ProtVal.getAs();
+int64_t Prot = ProtLoc->getValue().getSExtValue();
+if (ProtExecOv != ProtExec)
+  ProtExec = ProtExecOv;
+if (ProtReadOv != ProtRead)
+  ProtRead = ProtReadOv;
+
+// Wrong settings
+if (ProtRead == ProtExec)
+  return;
+
+if ((Prot & (ProtWrite | ProtExec)) == (ProtWrite | ProtExec)) {
+  if (!BT)
+BT.reset(new BugType(this, "W^X check fails, Write Exec prot flags set", "Security"));
+
+  ExplodedNode *N = C.generateNonFatalErrorNode();
+  if (!N)
+return;
+
+  auto Report = llvm::make_unique(
+  *BT, "Both PROT_WRITE and PROT_EXEC flags are set. This can "
+   "lead to exploitable memory regions, which could be overwritten "
+   "with malicious 

[PATCH] D42645: New simple Checker for mmap calls

2018-02-20 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Hello David,
There are still some items for improvement. However, if we move this checker 
into 'alpha' category, as Artem pointed, I think it can be accepted for merge 
in its current state and improved later.


Repository:
  rC Clang

https://reviews.llvm.org/D42645



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


r325566 - clang-format plugin: Add missing semicolon in list of file extensions (PR36383)

2018-02-20 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue Feb 20 01:26:38 2018
New Revision: 325566

URL: http://llvm.org/viewvc/llvm-project?rev=325566=rev
Log:
clang-format plugin: Add missing semicolon in list of file extensions (PR36383)

Modified:
cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs

Modified: cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs?rev=325566=325565=325566=diff
==
--- cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs (original)
+++ cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs Tue Feb 
20 01:26:38 2018
@@ -38,7 +38,7 @@ namespace LLVM.ClangFormat
 private string style = "file";
 private bool formatOnSave = false;
 private string formatOnSaveFileExtensions =
-".c;.cpp;.cxx;.cc;.tli;.tlh;.h;.hh;.hpp;.hxx;.hh;.inl" +
+".c;.cpp;.cxx;.cc;.tli;.tlh;.h;.hh;.hpp;.hxx;.hh;.inl;" +
 ".java;.js;.ts;.m;.mm;.proto;.protodevel;.td";
 
 public OptionPageGrid Clone()


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


Re: r324991 - Fix for PR32992. Static const classes not exported.

2018-02-20 Thread Hans Wennborg via cfe-commits
The problem is that your patch caused the reproducer to trigger an
assert, which it didn't do before, causing our builds to break.

Your patch seems like it does fix the PR, but it can't break currently
working builds.

$ build.release/bin/clang -cc1 -triple i386-pc-windows-msvc19.11.0
-emit-pch -fms-extensions -fms-compatibility
-fms-compatibility-version=19.11 -std=c++14 -fdelayed-template-parsing
-x c++-header /tmp/a.cc -o /dev/null
clang: 
/work/llvm.combined/llvm/tools/clang/lib/Serialization/ASTWriter.cpp:4723:
clang::ASTFileSignature clang::ASTWriter::WriteASTCore(clang::Sema&,
llvm::StringRef, const string&, clang::Module*): Assertion
`SemaRef.PendingLocalImplicitInstantiations.empty() && "There are
local ones at end of translation unit!"' failed.
build.release/bin/clang(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x1a)[0x55c535576aaa]
build.release/bin/clang(_ZN4llvm3sys17RunSignalHandlersEv+0x3e)[0x55c53557492e]
build.release/bin/clang(+0x2424a7c)[0x55c535574a7c]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x110c0)[0x7f4aeeb9d0c0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcf)[0x7f4aed732fcf]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f4aed7343fa]
/lib/x86_64-linux-gnu/libc.so.6(+0x2be37)[0x7f4aed72be37]
/lib/x86_64-linux-gnu/libc.so.6(+0x2bee2)[0x7f4aed72bee2]
build.release/bin/clang(_ZN5clang9ASTWriter12WriteASTCoreERNS_4SemaEN4llvm9StringRefERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPNS_6ModuleE+0x29fa)[0x55c536444cea]
build.release/bin/clang(_ZN5clang9ASTWriter8WriteASTERNS_4SemaERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPNS_6ModuleEN4llvm9StringRefEb+0xad)[0x55c536444dfd]
build.release/bin/clang(_ZN5clang12PCHGenerator21HandleTranslationUnitERNS_10ASTContextE+0x80)[0x55c536465fe0]
build.release/bin/clang(_ZN5clang17MultiplexConsumer21HandleTranslationUnitERNS_10ASTContextE+0x28)[0x55c535b53488]
build.release/bin/clang(_ZN5clang8ParseASTERNS_4SemaEbb+0x350)[0x55c5362c5d30]
build.release/bin/clang(_ZN5clang14FrontendAction7ExecuteEv+0x11e)[0x55c535b2958e]
build.release/bin/clang(_ZN5clang16CompilerInstance13ExecuteActionERNS_14FrontendActionE+0x176)[0x55c535af54d6]
build.release/bin/clang(_ZN5clang25ExecuteCompilerInvocationEPNS_16CompilerInstanceE+0x981)[0x55c535bc2561]
build.release/bin/clang(_Z8cc1_mainN4llvm8ArrayRefIPKcEES2_Pv+0xc50)[0x55c533e1a890]
build.release/bin/clang(main+0x1295)[0x55c533d9b585]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1)[0x7f4aed7202b1]
build.release/bin/clang(_start+0x2a)[0x55c533e1684a]
Stack dump:
0.  Program arguments: build.release/bin/clang -cc1 -triple
i386-pc-windows-msvc19.11.0 -emit-pch -fms-extensions
-fms-compatibility -fms-compatibility-version=19.11 -std=c++14
-fdelayed-template-parsing -x c++-header /tmp/a.cc -o /dev/null
1.   parser at end of file
Aborted

On Mon, Feb 19, 2018 at 10:18 PM, Ammarguellat, Zahira
 wrote:
> Hans,
>
>
>
> The reproducer below generates wrong export symbols compared to MSVC but I
> am not sure it is related to my change.
>
> Compiling this with MSVC generates these symbols:
>
>
>
> ksh-3.2$ dumpbin /directives t3.obj | grep EXPORT
>
>/EXPORT:??4?$d@H@@QEAAAEAV0@AEBV0@@Z
>
>/EXPORT:??4?$d@H@@QEAAAEAV0@$$QEAV0@@Z
>
>/EXPORT:??4?$h@H@f@@QEAAAEAV01@AEBV01@@Z
>
>/EXPORT:??4?$h@H@f@@QEAAAEAV01@$$QEAV01@@Z
>
>/EXPORT:??4i@@QEAAAEAV0@AEBV0@@Z
>
>/EXPORT:??4i@@QEAAAEAV0@$$QEAV0@@Z
>
>
>
>
>
> Compiling with clang (my patches no included) generate these symbols:
>
> ksh-3.2$ dumpbin /directives t3.o | grep EXPORT
>
>/EXPORT:??4?$d@H@@QEAAAEAV0@AEBV0@@Z
>
>/EXPORT:??4?$d@H@@QEAAAEAV0@$$QEAV0@@Z
>
>/EXPORT:??4?$h@H@f@@QEAAAEAV01@AEBV01@@Z
>
>/EXPORT:??4?$h@H@f@@QEAAAEAV01@$$QEAV01@@Z
>
>/EXPORT:??4i@@QEAAAEAV0@AEBV0@@Z
>
>/EXPORT:??4i@@QEAAAEAV0@$$QEAV0@@Z
>
>/EXPORT:?e@?$d@H@@0W4b@a@@B,DATA   ç This is not generated in MSVC.
>
>
>
> Although this is a bug that needs to be fixes, it is in my opinion
> un-related to the patches I have proposed.
>
>
>
> Your thoughts?
>
>
>
> Thanks.
>
> -Zahira
>
>
>
>
>
> -Original Message-
> From: hwennb...@google.com [mailto:hwennb...@google.com] On Behalf Of Hans
> Wennborg
> Sent: Monday, February 19, 2018 5:11 AM
> To: cfe-commits ; Ammarguellat, Zahira
> 
> Subject: Re: r324991 - Fix for PR32992. Static const classes not exported.
>
>
>
> Reduced repro:
>
>
>
> $ clang -cc1 -triple i386-pc-windows-msvc19.11.0 -emit-pch -fms-extensions
> -fms-compatibility -fms-compatibility-version=19.11
>
> -std=c++14 -fdelayed-template-parsing -x c++-header a.ii -o /dev/null
>
>
>
> a.ii:
>
>
>
> namespace a {
>
> enum b { c };
>
> }
>
> template  class d { static constexpr a::b e = a::c; }; namespace f
> { template  class h : d {}; } using f::h; class
> __declspec(dllexport) i : h<> {};
>
>
>
> On Wed, Feb 14, 2018 at 4:22 PM, Hans Wennborg  wrote:
>
>> I ended up having to revert this in