[PATCH] D55039: [sema] Warn of mangling change if function parameters are noexcept.

2018-12-03 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:9933
+llvm::any_of(FPT->param_types(),
+ [](QualType Q) { return hasNoexcept(Q); }))
+  return true;

You don't need this lambda.



Comment at: lib/Sema/SemaDecl.cpp:10266
   auto *FPT = NewFD->getType()->castAs();
-  bool AnyNoexcept = HasNoexcept(FPT->getReturnType());
-  for (QualType T : FPT->param_types())
-AnyNoexcept |= HasNoexcept(T);
-  if (AnyNoexcept)
+  if (hasNoexcept(FPT->getReturnType()) ||
+  llvm::any_of(FPT->param_types(),

What you're doing here is a subset of what `hasNoexcept` is doing for function 
types. Do you think it would make sense to use `!FPT->isNothrow() && 
hasNoexcept(NewFW->getType())` or something like that?



Comment at: lib/Sema/SemaDecl.cpp:10268
+  llvm::any_of(FPT->param_types(),
+   [](QualType Q) { return hasNoexcept(Q); })) {
 Diag(NewFD->getLocation(),

Same, that lambda is unnecessary.


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

https://reviews.llvm.org/D55039



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


[PATCH] D53153: [OpenCL] Mark kernel functions with default visibility

2018-12-03 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I think `-fvisibility=hidden` isn't good enough because you want to infer 
hidden visibility even for external symbol references, and that's just not how 
global visibility works.  But after this discussion, I'm prepared to accept 
that (1) we should have some sort of single-image compiler mode that implies 
that all symbols are defined within the image and (2) you can make your 
toolchain imply that together with `-fvisibility=hidden` and then have specific 
symbols opt in to non-hidden visibility if they need to be accessible to 
whatever loader / runtime you have.


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

https://reviews.llvm.org/D53153



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


[PATCH] D54604: Automatic variable initialization

2018-12-03 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added inline comments.



Comment at: include/clang/Driver/ToolChain.h:355
+  virtual LangOptions::TrivialAutoVarInitKind
+  GetDefaultTrivialAutoVarInit() const {
+return LangOptions::TrivialAutoVarInitKind::Uninitialized;

I wouldn't introduce this function because nothing is overriding it (for now, 
at least).



Comment at: lib/CodeGen/CGDecl.cpp:968
+  // The following value is a guaranteed unmappable pointer value and has a
+  // reperated byte-pattern which makes it easier to synthesize. We use it for
+  // pointers as well as integers so that aggregates are likely to be

*repeated



Comment at: lib/CodeGen/CGDecl.cpp:977
+  constexpr uint32_t SmallValue = 0x00AA;
+  if (Ty->isIntOrIntVectorTy()) {
+unsigned BitWidth = llvm::cast(

Do you have test coverage for vectors?



Comment at: lib/CodeGen/CGDecl.cpp:978
+  if (Ty->isIntOrIntVectorTy()) {
+unsigned BitWidth = llvm::cast(
+Ty->isVectorTy() ? Ty->getVectorElementType() : Ty)

Is it necessary to qualify `cast` with `llvm::`? It doesn't seem to be 
qualified elsewhere in this file. (Same below.)



Comment at: lib/CodeGen/CGDecl.cpp:1145
+  if (Ty->isStructTy() || Ty->isArrayTy() || Ty->isVectorTy()) {
+for (unsigned Op = 0, NumOp = constant->getNumOperands(); Op != NumOp;
+ ++Op) {

Maybe use `User::operands()` to enumerate operands here?



Comment at: lib/CodeGen/CGDecl.cpp:1631
+  auto initializeWhatIsTechnicallyUninitialized = [&]() {
+if (trivialAutoVarInit !=
+LangOptions::TrivialAutoVarInitKind::Uninitialized) {

Is it possible to rewrite this function using early returns to avoid all the 
indentation below for the VLA case? I'd also put the code for non-VLAs first to 
make this function easier to understand (on my first reading I somehow got the 
impression that this function is *only* handling VLAs). I'm thinking maybe 
something like:

```
if (trivialAutoVarInit == LangOptions::TrivialAutoVarInitKind::Uninitialized)
  return;

if (!getContext().getTypeSizeInChars(type).isZero()) {
  // handle non-VLAs
}

auto *VlaType = 
dyn_cast_or_null(getContext().getAsArrayType(type));
if (!VlaType)
  return;

// handle VLAs
```



Comment at: lib/CodeGen/CGDecl.cpp:1673
+llvm::BasicBlock *ContBB = createBasicBlock("vla-init.cont");
+EmitBlock(LoopBB);
+llvm::PHINode *Cur =

I think we need to check that the size is non-zero here. Otherwise we're going 
to clobber whatever comes after the VLA if its size is zero (I know that C 
forbids zero-sized VLAs, but I believe we support them as a GNU extension).



Comment at: test/CodeGenCXX/trivial-auto-var-init.cpp:5
+
+// PATTERN-NOT: undef
+// ZERO-NOT: undef

Since this is your only test involving structs and arrays, you probably want to 
test them beyond the fact that they don't contain undef. I also believe that 
this is testing for the absence of `undef` before the first label and not the 
total absence of `undef` in the output.


Repository:
  rC Clang

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

https://reviews.llvm.org/D54604



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


[PATCH] D55250: [clangd] Enhance macro hover to see full definition

2018-12-03 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle created this revision.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
ioeric, ilya-biryukov.

Signed-off-by: Marc-Andre Laperle 


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D55250

Files:
  clangd/XRefs.cpp
  unittests/clangd/XRefsTests.cpp


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -616,7 +616,27 @@
 #define MACRO 2
 #undef macro
   )cpp",
-  "#define MACRO",
+  "```C++\n#define MACRO 1\n```",
+  },
+  {
+  R"cpp(// Macro
+#define MACRO 0
+#define MACRO2 ^MACRO
+  )cpp",
+  "```C++\n#define MACRO 0\n```",
+  },
+  {
+  R"cpp(// Macro
+#define MACRO {\
+  return 0;\
+}
+int main() ^MACRO
+  )cpp",
+  R"cpp(```C++
+#define MACRO {\
+  return 0;\
+}
+```)cpp",
   },
   {
   R"cpp(// Forward class declaration
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -565,12 +565,28 @@
 }
 
 /// Generate a \p Hover object given the macro \p MacroInf.
-static Hover getHoverContents(StringRef MacroName) {
-  Hover H;
-
-  H.contents.value = "#define ";
-  H.contents.value += MacroName;
+static Hover getHoverContents(MacroDecl Decl, ASTContext ) {
+  SourceManager& SM = ASTCtx.getSourceManager();
+  StringRef Definition = Decl.Name;
+
+  // Try to get the full definition, not just the name
+  SourceLocation StartLoc = Decl.Info->getDefinitionLoc();
+  SourceLocation EndLoc = Decl.Info->getDefinitionEndLoc();
+  if (EndLoc.isValid()) {
+EndLoc = Lexer::getLocForEndOfToken(EndLoc, 0, SM, ASTCtx.getLangOpts());
+bool Invalid;
+StringRef Buffer = SM.getBufferData(SM.getFileID(StartLoc), );
+if (!Invalid) {
+  unsigned StartOffset = SM.getFileOffset(StartLoc);
+  unsigned EndOffset = SM.getFileOffset(EndLoc);
+  if (EndOffset <= Buffer.size() && StartOffset < EndOffset)
+Definition = Buffer.substr(StartOffset, EndOffset - StartOffset);
+}
+  }
 
+  Hover H;
+  H.contents.kind = MarkupKind::Markdown;
+  H.contents.value = formatv("```C++\n#define {0}\n```", Definition);
   return H;
 }
 
@@ -694,7 +710,7 @@
   auto Symbols = getSymbolAtPosition(AST, SourceLocationBeg);
 
   if (!Symbols.Macros.empty())
-return getHoverContents(Symbols.Macros[0].Name);
+return getHoverContents(Symbols.Macros[0], AST.getASTContext());
 
   if (!Symbols.Decls.empty())
 return getHoverContents(Symbols.Decls[0].D);


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -616,7 +616,27 @@
 #define MACRO 2
 #undef macro
   )cpp",
-  "#define MACRO",
+  "```C++\n#define MACRO 1\n```",
+  },
+  {
+  R"cpp(// Macro
+#define MACRO 0
+#define MACRO2 ^MACRO
+  )cpp",
+  "```C++\n#define MACRO 0\n```",
+  },
+  {
+  R"cpp(// Macro
+#define MACRO {\
+  return 0;\
+}
+int main() ^MACRO
+  )cpp",
+  R"cpp(```C++
+#define MACRO {\
+  return 0;\
+}
+```)cpp",
   },
   {
   R"cpp(// Forward class declaration
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -565,12 +565,28 @@
 }
 
 /// Generate a \p Hover object given the macro \p MacroInf.
-static Hover getHoverContents(StringRef MacroName) {
-  Hover H;
-
-  H.contents.value = "#define ";
-  H.contents.value += MacroName;
+static Hover getHoverContents(MacroDecl Decl, ASTContext ) {
+  SourceManager& SM = ASTCtx.getSourceManager();
+  StringRef Definition = Decl.Name;
+
+  // Try to get the full definition, not just the name
+  SourceLocation StartLoc = Decl.Info->getDefinitionLoc();
+  SourceLocation EndLoc = Decl.Info->getDefinitionEndLoc();
+  if (EndLoc.isValid()) {
+EndLoc = Lexer::getLocForEndOfToken(EndLoc, 0, SM, ASTCtx.getLangOpts());
+bool Invalid;
+StringRef Buffer = SM.getBufferData(SM.getFileID(StartLoc), );
+if (!Invalid) {
+  unsigned StartOffset = SM.getFileOffset(StartLoc);
+  unsigned EndOffset = SM.getFileOffset(EndLoc);
+  if (EndOffset <= Buffer.size() && StartOffset < EndOffset)
+Definition = Buffer.substr(StartOffset, EndOffset - StartOffset);
+}
+  }
 
+  Hover H;
+  H.contents.kind = MarkupKind::Markdown;
+  H.contents.value = formatv("```C++\n#define {0}\n```", Definition);
   return H;
 }
 
@@ -694,7 +710,7 @@
   auto Symbols = getSymbolAtPosition(AST, 

r348238 - Remove unnecessary include.

2018-12-03 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Mon Dec  3 20:53:18 2018
New Revision: 348238

URL: http://llvm.org/viewvc/llvm-project?rev=348238=rev
Log:
Remove unnecessary include.

Modified:
cfe/trunk/lib/CodeGen/CodeGenTypes.h

Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.h?rev=348238=348237=348238=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenTypes.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.h Mon Dec  3 20:53:18 2018
@@ -17,7 +17,6 @@
 #include "CGCall.h"
 #include "clang/Basic/ABI.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
-#include "clang/Sema/Sema.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/IR/Module.h"
 


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


[PATCH] D55246: AST: Relax an assertion in constexpr constructor evaluation.

2018-12-03 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc created this revision.
pcc added a reviewer: rsmith.
Herald added a subscriber: llvm-commits.

It's possible for the base type specified in a constructor to be
qualified via sugar, so the existing assertion was too strict. Relax
it so that we only check that the unqualified types are the same.


Repository:
  rL LLVM

https://reviews.llvm.org/D55246

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp


Index: clang/test/SemaCXX/constant-expression-cxx11.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -2220,3 +2220,15 @@
   constexpr int *q = ( + 1) - (unsigned __int128)-1; // expected-error 
{{constant expression}} expected-note {{cannot refer to element -3402}}
   constexpr int *r = &( + 1)[(unsigned __int128)-1]; // expected-error 
{{constant expression}} expected-note {{cannot refer to element 3402}}
 }
+
+namespace QualifiedBaseType {
+  template 
+  struct A : T {
+  public:
+constexpr A() : T() {}
+  };
+
+  struct S {};
+
+  A a;
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4542,7 +4542,7 @@
   // Non-virtual base classes are initialized in the order in the class
   // definition. We have already checked for virtual base classes.
   assert(!BaseIt->isVirtual() && "virtual base for literal type");
-  assert(Info.Ctx.hasSameType(BaseIt->getType(), BaseType) &&
+  assert(Info.Ctx.hasSameUnqualifiedType(BaseIt->getType(), BaseType) &&
  "base class initializers not in expected order");
   ++BaseIt;
 #endif


Index: clang/test/SemaCXX/constant-expression-cxx11.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -2220,3 +2220,15 @@
   constexpr int *q = ( + 1) - (unsigned __int128)-1; // expected-error {{constant expression}} expected-note {{cannot refer to element -3402}}
   constexpr int *r = &( + 1)[(unsigned __int128)-1]; // expected-error {{constant expression}} expected-note {{cannot refer to element 3402}}
 }
+
+namespace QualifiedBaseType {
+  template 
+  struct A : T {
+  public:
+constexpr A() : T() {}
+  };
+
+  struct S {};
+
+  A a;
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4542,7 +4542,7 @@
   // Non-virtual base classes are initialized in the order in the class
   // definition. We have already checked for virtual base classes.
   assert(!BaseIt->isVirtual() && "virtual base for literal type");
-  assert(Info.Ctx.hasSameType(BaseIt->getType(), BaseType) &&
+  assert(Info.Ctx.hasSameUnqualifiedType(BaseIt->getType(), BaseType) &&
  "base class initializers not in expected order");
   ++BaseIt;
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54563: [analyzer] MoveChecker Pt.4: Add a few more state reset methods.

2018-12-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC348235: [analyzer] MoveChecker: Add more common state 
resetting methods. (authored by dergachev, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54563?vs=176512=176537#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D54563

Files:
  lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  test/Analysis/use-after-move.cpp


Index: lib/StaticAnalyzer/Checkers/MoveChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MoveChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MoveChecker.cpp
@@ -343,8 +343,11 @@
   return true;
   if (MethodDec->getDeclName().isIdentifier()) {
 std::string MethodName = MethodDec->getName().lower();
+// TODO: Some of these methods (eg., resize) are not always resetting
+// the state, so we should consider looking at the arguments.
 if (MethodName == "reset" || MethodName == "clear" ||
-MethodName == "destroy")
+MethodName == "destroy" || MethodName == "resize" ||
+MethodName == "shrink")
   return true;
   }
   return false;
Index: test/Analysis/use-after-move.cpp
===
--- test/Analysis/use-after-move.cpp
+++ test/Analysis/use-after-move.cpp
@@ -15,6 +15,8 @@
 
 namespace std {
 
+typedef __typeof(sizeof(int)) size_t;
+
 template 
 struct remove_reference;
 
@@ -110,6 +112,7 @@
   void reset();
   void destroy();
   void clear();
+  void resize(std::size_t);
   bool empty() const;
   bool isEmpty() const;
   operator bool() const;
@@ -403,6 +406,13 @@
 a.foo();   // no-warning
 a.b.foo(); // no-warning
   }
+  {
+A a;
+A b = std::move(a);
+a.resize(0); // no-warning
+a.foo();   // no-warning
+a.b.foo(); // no-warning
+  }
 }
 
 // Moves or uses that occur as part of template arguments.


Index: lib/StaticAnalyzer/Checkers/MoveChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MoveChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MoveChecker.cpp
@@ -343,8 +343,11 @@
   return true;
   if (MethodDec->getDeclName().isIdentifier()) {
 std::string MethodName = MethodDec->getName().lower();
+// TODO: Some of these methods (eg., resize) are not always resetting
+// the state, so we should consider looking at the arguments.
 if (MethodName == "reset" || MethodName == "clear" ||
-MethodName == "destroy")
+MethodName == "destroy" || MethodName == "resize" ||
+MethodName == "shrink")
   return true;
   }
   return false;
Index: test/Analysis/use-after-move.cpp
===
--- test/Analysis/use-after-move.cpp
+++ test/Analysis/use-after-move.cpp
@@ -15,6 +15,8 @@
 
 namespace std {
 
+typedef __typeof(sizeof(int)) size_t;
+
 template 
 struct remove_reference;
 
@@ -110,6 +112,7 @@
   void reset();
   void destroy();
   void clear();
+  void resize(std::size_t);
   bool empty() const;
   bool isEmpty() const;
   operator bool() const;
@@ -403,6 +406,13 @@
 a.foo();   // no-warning
 a.b.foo(); // no-warning
   }
+  {
+A a;
+A b = std::move(a);
+a.resize(0); // no-warning
+a.foo();   // no-warning
+a.b.foo(); // no-warning
+  }
 }
 
 // Moves or uses that occur as part of template arguments.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r348235 - [analyzer] MoveChecker: Add more common state resetting methods.

2018-12-03 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Dec  3 19:38:08 2018
New Revision: 348235

URL: http://llvm.org/viewvc/llvm-project?rev=348235=rev
Log:
[analyzer] MoveChecker: Add more common state resetting methods.

Includes "resize" and "shrink" because they can reset the object to a known
state in certain circumstances.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
cfe/trunk/test/Analysis/use-after-move.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp?rev=348235=348234=348235=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp Mon Dec  3 19:38:08 
2018
@@ -343,8 +343,11 @@ bool MoveChecker::isStateResetMethod(con
   return true;
   if (MethodDec->getDeclName().isIdentifier()) {
 std::string MethodName = MethodDec->getName().lower();
+// TODO: Some of these methods (eg., resize) are not always resetting
+// the state, so we should consider looking at the arguments.
 if (MethodName == "reset" || MethodName == "clear" ||
-MethodName == "destroy")
+MethodName == "destroy" || MethodName == "resize" ||
+MethodName == "shrink")
   return true;
   }
   return false;

Modified: cfe/trunk/test/Analysis/use-after-move.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/use-after-move.cpp?rev=348235=348234=348235=diff
==
--- cfe/trunk/test/Analysis/use-after-move.cpp (original)
+++ cfe/trunk/test/Analysis/use-after-move.cpp Mon Dec  3 19:38:08 2018
@@ -15,6 +15,8 @@
 
 namespace std {
 
+typedef __typeof(sizeof(int)) size_t;
+
 template 
 struct remove_reference;
 
@@ -110,6 +112,7 @@ public:
   void reset();
   void destroy();
   void clear();
+  void resize(std::size_t);
   bool empty() const;
   bool isEmpty() const;
   operator bool() const;
@@ -403,6 +406,13 @@ void moveStateResetFunctionsTest() {
 a.foo();   // no-warning
 a.b.foo(); // no-warning
   }
+  {
+A a;
+A b = std::move(a);
+a.resize(0); // no-warning
+a.foo();   // no-warning
+a.b.foo(); // no-warning
+  }
 }
 
 // Moves or uses that occur as part of template arguments.


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


[PATCH] D54563: [analyzer] MoveChecker Pt.4: Add a few more state reset methods.

2018-12-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Hmm, i shouldn't have included `shrink_to_fit`. It definitely keeps the object 
in unspecified state if it is already in unspecified state.


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

https://reviews.llvm.org/D54563



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


[PATCH] D53787: [Sema] Provide -fvisibility-global-new-delete-hidden option

2018-12-03 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348234: [Sema] Provide -fvisibility-global-new-delete-hidden 
option (authored by phosek, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53787?vs=176533=176535#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D53787

Files:
  cfe/trunk/include/clang/Basic/LangOptions.def
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/Sema/SemaExprCXX.cpp


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1734,6 +1734,8 @@
 def fvisibility_ms_compat : Flag<["-"], "fvisibility-ms-compat">, 
Group,
   HelpText<"Give global types 'default' visibility and global functions and "
"variables 'hidden' visibility by default">;
+def fvisibility_global_new_delete_hidden : Flag<["-"], 
"fvisibility-global-new-delete-hidden">, Group,
+  HelpText<"Give global C++ operator new and delete declarations hidden 
visibility">, Flags<[CC1Option]>;
 def fwhole_program_vtables : Flag<["-"], "fwhole-program-vtables">, 
Group,
   Flags<[CoreOption, CC1Option]>,
   HelpText<"Enables whole-program vtable optimization. Requires -flto">;
Index: cfe/trunk/include/clang/Basic/LangOptions.def
===
--- cfe/trunk/include/clang/Basic/LangOptions.def
+++ cfe/trunk/include/clang/Basic/LangOptions.def
@@ -227,7 +227,8 @@
 BENIGN_LANGOPT(DumpRecordLayoutsSimple , 1, 0, "dumping the layout of IRgen'd 
records in a simple form")
 BENIGN_LANGOPT(DumpVTableLayouts , 1, 0, "dumping the layouts of emitted 
vtables")
 LANGOPT(NoConstantCFStrings , 1, 0, "no constant CoreFoundation strings")
-BENIGN_LANGOPT(InlineVisibilityHidden , 1, 0, "hidden default visibility for 
inline C++ methods")
+BENIGN_LANGOPT(InlineVisibilityHidden , 1, 0, "hidden visibility for inline 
C++ methods")
+LANGOPT(GlobalAllocationFunctionVisibilityHidden , 1, 0, "hidden visibility 
for global operator new and delete declaration")
 BENIGN_LANGOPT(ParseUnknownAnytype, 1, 0, "__unknown_anytype")
 BENIGN_LANGOPT(DebuggerSupport , 1, 0, "debugger support")
 BENIGN_LANGOPT(DebuggerCastResultToId, 1, 0, "for 'po' in the debugger, cast 
the result to id if it is of unknown type")
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -4329,6 +4329,7 @@
   }
 
   Args.AddLastArg(CmdArgs, options::OPT_fvisibility_inlines_hidden);
+  Args.AddLastArg(CmdArgs, options::OPT_fvisibility_global_new_delete_hidden);
 
   Args.AddLastArg(CmdArgs, options::OPT_ftlsmodel_EQ);
 
Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -2816,9 +2816,10 @@
 // Global allocation functions should always be visible.
 Alloc->setVisibleDespiteOwningModule();
 
-// Implicit sized deallocation functions always have default visibility.
-Alloc->addAttr(
-VisibilityAttr::CreateImplicit(Context, VisibilityAttr::Default));
+Alloc->addAttr(VisibilityAttr::CreateImplicit(
+Context, LangOpts.GlobalAllocationFunctionVisibilityHidden
+ ? VisibilityAttr::Hidden
+ : VisibilityAttr::Default));
 
 llvm::SmallVector ParamDecls;
 for (QualType T : Params) {
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -2487,6 +2487,9 @@
   if (Args.hasArg(OPT_fvisibility_inlines_hidden))
 Opts.InlineVisibilityHidden = 1;
 
+  if (Args.hasArg(OPT_fvisibility_global_new_delete_hidden))
+Opts.GlobalAllocationFunctionVisibilityHidden = 1;
+
   if (Args.hasArg(OPT_ftrapv)) {
 Opts.setSignedOverflowBehavior(LangOptions::SOB_Trapping);
 // Set the handler, if one is specified.


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1734,6 +1734,8 @@
 def fvisibility_ms_compat : Flag<["-"], "fvisibility-ms-compat">, Group,
   HelpText<"Give global types 'default' visibility and global functions and "
"variables 'hidden' visibility by default">;
+def fvisibility_global_new_delete_hidden : Flag<["-"], "fvisibility-global-new-delete-hidden">, Group,
+  HelpText<"Give global C++ 

r348234 - [Sema] Provide -fvisibility-global-new-delete-hidden option

2018-12-03 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Mon Dec  3 19:25:25 2018
New Revision: 348234

URL: http://llvm.org/viewvc/llvm-project?rev=348234=rev
Log:
[Sema] Provide -fvisibility-global-new-delete-hidden option

When the global new and delete operators aren't declared, Clang
provides and implicit declaration, but this declaration currently
always uses the default visibility. This is a problem when the
C++ library itself is being built with non-default visibility because
the implicit declaration will force the new and delete operators to
have the default visibility unlike the rest of the library.

The existing workaround is to use assembly to enforce the visiblity:
https://fuchsia.googlesource.com/zircon/+/master/system/ulib/zxcpp/new.cpp#108
but that solution is not always available, e.g. in the case of of
libFuzzer which is using an internal version of libc++ that's also built
with -fvisibility=hidden where the existing behavior is causing issues.

This change introduces a new option -fvisibility-global-new-delete-hidden
which makes the implicit declaration of the global new and delete
operators hidden.

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

Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=348234=348233=348234=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Mon Dec  3 19:25:25 2018
@@ -227,7 +227,8 @@ BENIGN_LANGOPT(DumpRecordLayouts , 1, 0,
 BENIGN_LANGOPT(DumpRecordLayoutsSimple , 1, 0, "dumping the layout of IRgen'd 
records in a simple form")
 BENIGN_LANGOPT(DumpVTableLayouts , 1, 0, "dumping the layouts of emitted 
vtables")
 LANGOPT(NoConstantCFStrings , 1, 0, "no constant CoreFoundation strings")
-BENIGN_LANGOPT(InlineVisibilityHidden , 1, 0, "hidden default visibility for 
inline C++ methods")
+BENIGN_LANGOPT(InlineVisibilityHidden , 1, 0, "hidden visibility for inline 
C++ methods")
+LANGOPT(GlobalAllocationFunctionVisibilityHidden , 1, 0, "hidden visibility 
for global operator new and delete declaration")
 BENIGN_LANGOPT(ParseUnknownAnytype, 1, 0, "__unknown_anytype")
 BENIGN_LANGOPT(DebuggerSupport , 1, 0, "debugger support")
 BENIGN_LANGOPT(DebuggerCastResultToId, 1, 0, "for 'po' in the debugger, cast 
the result to id if it is of unknown type")

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=348234=348233=348234=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Dec  3 19:25:25 2018
@@ -1734,6 +1734,8 @@ def fvisibility_inlines_hidden : Flag<["
 def fvisibility_ms_compat : Flag<["-"], "fvisibility-ms-compat">, 
Group,
   HelpText<"Give global types 'default' visibility and global functions and "
"variables 'hidden' visibility by default">;
+def fvisibility_global_new_delete_hidden : Flag<["-"], 
"fvisibility-global-new-delete-hidden">, Group,
+  HelpText<"Give global C++ operator new and delete declarations hidden 
visibility">, Flags<[CC1Option]>;
 def fwhole_program_vtables : Flag<["-"], "fwhole-program-vtables">, 
Group,
   Flags<[CoreOption, CC1Option]>,
   HelpText<"Enables whole-program vtable optimization. Requires -flto">;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=348234=348233=348234=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Dec  3 19:25:25 2018
@@ -4329,6 +4329,7 @@ void Clang::ConstructJob(Compilation ,
   }
 
   Args.AddLastArg(CmdArgs, options::OPT_fvisibility_inlines_hidden);
+  Args.AddLastArg(CmdArgs, options::OPT_fvisibility_global_new_delete_hidden);
 
   Args.AddLastArg(CmdArgs, options::OPT_ftlsmodel_EQ);
 

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=348234=348233=348234=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Dec  3 19:25:25 2018
@@ -2487,6 +2487,9 @@ static void ParseLangArgs(LangOptions 
   if (Args.hasArg(OPT_fvisibility_inlines_hidden))
 Opts.InlineVisibilityHidden = 1;
 
+  if (Args.hasArg(OPT_fvisibility_global_new_delete_hidden))
+

[PATCH] D53787: [Sema] Provide -fvisibility-global-new-delete-hidden option

2018-12-03 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 176533.
phosek marked 2 inline comments as done.

Repository:
  rC Clang

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

https://reviews.llvm.org/D53787

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaExprCXX.cpp


Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -2816,9 +2816,10 @@
 // Global allocation functions should always be visible.
 Alloc->setVisibleDespiteOwningModule();
 
-// Implicit sized deallocation functions always have default visibility.
-Alloc->addAttr(
-VisibilityAttr::CreateImplicit(Context, VisibilityAttr::Default));
+Alloc->addAttr(VisibilityAttr::CreateImplicit(
+Context, LangOpts.GlobalAllocationFunctionVisibilityHidden
+ ? VisibilityAttr::Hidden
+ : VisibilityAttr::Default));
 
 llvm::SmallVector ParamDecls;
 for (QualType T : Params) {
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2487,6 +2487,9 @@
   if (Args.hasArg(OPT_fvisibility_inlines_hidden))
 Opts.InlineVisibilityHidden = 1;
 
+  if (Args.hasArg(OPT_fvisibility_global_new_delete_hidden))
+Opts.GlobalAllocationFunctionVisibilityHidden = 1;
+
   if (Args.hasArg(OPT_ftrapv)) {
 Opts.setSignedOverflowBehavior(LangOptions::SOB_Trapping);
 // Set the handler, if one is specified.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4329,6 +4329,7 @@
   }
 
   Args.AddLastArg(CmdArgs, options::OPT_fvisibility_inlines_hidden);
+  Args.AddLastArg(CmdArgs, options::OPT_fvisibility_global_new_delete_hidden);
 
   Args.AddLastArg(CmdArgs, options::OPT_ftlsmodel_EQ);
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1734,6 +1734,8 @@
 def fvisibility_ms_compat : Flag<["-"], "fvisibility-ms-compat">, 
Group,
   HelpText<"Give global types 'default' visibility and global functions and "
"variables 'hidden' visibility by default">;
+def fvisibility_global_new_delete_hidden : Flag<["-"], 
"fvisibility-global-new-delete-hidden">, Group,
+  HelpText<"Give global C++ operator new and delete declarations hidden 
visibility">, Flags<[CC1Option]>;
 def fwhole_program_vtables : Flag<["-"], "fwhole-program-vtables">, 
Group,
   Flags<[CoreOption, CC1Option]>,
   HelpText<"Enables whole-program vtable optimization. Requires -flto">;
Index: clang/include/clang/Basic/LangOptions.def
===
--- clang/include/clang/Basic/LangOptions.def
+++ clang/include/clang/Basic/LangOptions.def
@@ -227,7 +227,8 @@
 BENIGN_LANGOPT(DumpRecordLayoutsSimple , 1, 0, "dumping the layout of IRgen'd 
records in a simple form")
 BENIGN_LANGOPT(DumpVTableLayouts , 1, 0, "dumping the layouts of emitted 
vtables")
 LANGOPT(NoConstantCFStrings , 1, 0, "no constant CoreFoundation strings")
-BENIGN_LANGOPT(InlineVisibilityHidden , 1, 0, "hidden default visibility for 
inline C++ methods")
+BENIGN_LANGOPT(InlineVisibilityHidden , 1, 0, "hidden visibility for inline 
C++ methods")
+LANGOPT(GlobalAllocationFunctionVisibilityHidden , 1, 0, "hidden visibility 
for global operator new and delete declaration")
 BENIGN_LANGOPT(ParseUnknownAnytype, 1, 0, "__unknown_anytype")
 BENIGN_LANGOPT(DebuggerSupport , 1, 0, "debugger support")
 BENIGN_LANGOPT(DebuggerCastResultToId, 1, 0, "for 'po' in the debugger, cast 
the result to id if it is of unknown type")


Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -2816,9 +2816,10 @@
 // Global allocation functions should always be visible.
 Alloc->setVisibleDespiteOwningModule();
 
-// Implicit sized deallocation functions always have default visibility.
-Alloc->addAttr(
-VisibilityAttr::CreateImplicit(Context, VisibilityAttr::Default));
+Alloc->addAttr(VisibilityAttr::CreateImplicit(
+Context, LangOpts.GlobalAllocationFunctionVisibilityHidden
+ ? VisibilityAttr::Hidden
+ : VisibilityAttr::Default));
 
 llvm::SmallVector ParamDecls;
 for (QualType T : Params) {
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- 

r348233 - Fix -Wmismatched-tags to not warn on redeclarations of structs in system

2018-12-03 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Dec  3 18:45:28 2018
New Revision: 348233

URL: http://llvm.org/viewvc/llvm-project?rev=348233=rev
Log:
Fix -Wmismatched-tags to not warn on redeclarations of structs in system
headers.

Previously, we would only check whether the new declaration is in a
system header, but that requires the user to be able to correctly guess
whether a declaration in a system header is declared as a struct or a
class when specializing standard library traits templates.

We now entirely ignore declarations for which the warning was disabled
when determining whether to warn on a tag mismatch.

Also extend the diagnostic message to clarify that
 a) code containing such a tag mismatch is in fact valid and correct,
and
 b) the (non-coding-style) reason to emit such a warning is that the
Microsoft C++ ABI is broken and includes the tag kind in decorated
names,
as it seems a lot of users are confused by our diagnostic here (either
not understanding why we produce it, or believing that it represents an
actual language rule).

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/struct-class-redecl.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=348233=348232=348233=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Dec  3 18:45:28 
2018
@@ -4806,16 +4806,18 @@ def err_nested_redefinition : Error<"nes
 def err_use_with_wrong_tag : Error<
   "use of %0 with tag type that does not match previous declaration">;
 def warn_struct_class_tag_mismatch : Warning<
-"%select{struct|interface|class}0%select{| template}1 %2 was previously "
-"declared as a %select{struct|interface|class}3%select{| template}1">,
-InGroup, DefaultIgnore;
+  "%select{struct|interface|class}0%select{| template}1 %2 was previously "
+  "declared as a %select{struct|interface|class}3%select{| template}1; "
+  "this is valid, but may result in linker errors under the Microsoft C++ 
ABI">,
+  InGroup, DefaultIgnore;
 def warn_struct_class_previous_tag_mismatch : Warning<
-"%2 defined as %select{a struct|an interface|a class}0%select{| template}1 
"
-"here but previously declared as "
-"%select{a struct|an interface|a class}3%select{| template}1">,
- InGroup, DefaultIgnore;
+  "%2 defined as %select{a struct|an interface|a class}0%select{| template}1 "
+  "here but previously declared as "
+  "%select{a struct|an interface|a class}3%select{| template}1; "
+  "this is valid, but may result in linker errors under the Microsoft C++ 
ABI">,
+  InGroup, DefaultIgnore;
 def note_struct_class_suggestion : Note<
-"did you mean %select{struct|interface|class}0 here?">;
+  "did you mean %select{struct|interface|class}0 here?">;
 def ext_forward_ref_enum : Extension<
   "ISO C forbids forward references to 'enum' types">;
 def err_forward_ref_enum : Error<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=348233=348232=348233=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Dec  3 18:45:28 2018
@@ -13803,76 +13803,106 @@ bool Sema::isAcceptableTagRedeclaration(
   //   struct class-key shall be used to refer to a class (clause 9)
   //   declared using the class or struct class-key.
   TagTypeKind OldTag = Previous->getTagKind();
-  if (!isDefinition || !isClassCompatTagKind(NewTag))
-if (OldTag == NewTag)
+  if (OldTag != NewTag &&
+  !(isClassCompatTagKind(OldTag) && isClassCompatTagKind(NewTag)))
+return false;
+
+  // Tags are compatible, but we might still want to warn on mismatched tags.
+  // Non-class tags can't be mismatched at this point.
+  if (!isClassCompatTagKind(NewTag))
+return true;
+
+  // Declarations for which -Wmismatched-tags is disabled are entirely ignored
+  // by our warning analysis. We don't want to warn about mismatches with (eg)
+  // declarations in system headers that are designed to be specialized, but if
+  // a user asks us to warn, we should warn if their code contains mismatched
+  // declarations.
+  auto IsIgnoredLoc = [&](SourceLocation Loc) {
+return getDiagnostics().isIgnored(diag::warn_struct_class_tag_mismatch,
+  Loc);
+  };
+  if (IsIgnoredLoc(NewTagLoc))
+return true;
+
+  auto IsIgnored = [&](const TagDecl *Tag) {
+return IsIgnoredLoc(Tag->getLocation());
+  };
+  while (IsIgnored(Previous)) {
+Previous = Previous->getPreviousDecl();
+if (!Previous)
   return true;
+OldTag = Previous->getTagKind();
+  }
 
-  if (isClassCompatTagKind(OldTag) && 

[PATCH] D54466: [Analyzer] Iterator Checkers - Use the region of the topmost base class for iterators stored in a region

2018-12-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Looks great, thanks!


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

https://reviews.llvm.org/D54466



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


[PATCH] D51568: [modules] Add `-fno-absolute-module-directory` flag for relocatable modules

2018-12-03 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D51568#1314004 , @andrewjcg wrote:

> > I don't think we need to change the serialization format for this: a 
> > serialized path beginning with / is already treated as absolute and any 
> > other path is already treated as relative, so we don't need a flag to carry 
> > that information.
>
> But I think we need this since we now have two types of relative paths -- a 
> CWD-relative path and a module-home-relative path -- and we use this flag to 
> discern them for the AST reader.  Previously, because `cleanPathForOutput` 
> would always absolutify input paths, we didn't need this flag -- any relative 
> path was relative the module home and all other paths were absolute.


Ah, of course, that's exactly what I was missing :) I guess I live in a 
too-`-fmodule-map-file-home-is-cwd`-centric world where the two are always the 
same (even when modules are relocated).

Following the 0-1-infinity principle, I think it might make sense to have a 
'catalog' of prefixes for paths (relative to the module, relative to the 
compiler's CWD, relative to the compiler's resource directory, relative to the 
sysroot) that we try stripping off, with different markers to say which one we 
removed. (Right now, if you relocate the compiler, you invalidate any .pcm file 
that references files in its resource directory, for instance.) But this seems 
like a step in a good direction.

Just checking that we're on the same page here... suppose I do this:

- compile module described in `foo/module.modulemap` (with no 
`-fmodule-map-file-home-is-cwd`, so module-relative paths have the `foo/` 
prefix stripped off them)
- use `-Ibar/` to find some textual headers

Then, if I relocate the `foo/` module to `elsewhere/foo` and pass the 
corresponding `pcm` file to a compilation using that module, I will still 
expect to find the `bar/` files referenced by the `pcm` file relative to the 
compiler's working directory, not in `elsewhere/bar`. Is that what you're 
expecting, or would you expect the file paths to be emitted as module-relative 
`../bar/...` paths? (Note that the latter can break if `foo` is a symlink.)




Comment at: lib/Serialization/ASTReader.cpp:2094-2096
+  bool IsRelativeModuleDirectory = static_cast(Record[6]);
   R.Filename = Blob;
+  if (IsRelativeModuleDirectory) {

This'd be more readable (throughout the patch) spelled as 
`IsRelativeToModuleDirectory`. (I was wondering "What is a relative module 
directory?")


Repository:
  rC Clang

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

https://reviews.llvm.org/D51568



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


[PATCH] D54560: [analyzer] MoveChecker Pt.3: Improve warning messages a bit.

2018-12-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC348229: [analyzer] MoveChecker: Improve warning and note 
messages. (authored by dergachev, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D54560

Files:
  lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  test/Analysis/use-after-move.cpp

Index: test/Analysis/use-after-move.cpp
===
--- test/Analysis/use-after-move.cpp
+++ test/Analysis/use-after-move.cpp
@@ -88,7 +88,7 @@
   A(const A ) : i(other.i), d(other.d), b(other.b) {}
   A(A &) : i(other.i), d(other.d), b(std::move(other.b)) {
 #ifdef AGGRESSIVE
-// expected-note@-2{{'b' became 'moved-from' here}}
+// expected-note@-2{{Object 'b' is moved}}
 #endif
   }
   A(A &, char *k) {
@@ -137,18 +137,18 @@
 void simpleMoveCtorTest() {
   {
 A a;
-A b = std::move(a); // expected-note {{'a' became 'moved-from' here}}
-a.foo();// expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}}
+A b = std::move(a); // expected-note {{Object 'a' is moved}}
+a.foo();// expected-warning {{Method called on moved-from object 'a'}} expected-note {{Method called on moved-from object 'a'}}
   }
   {
 A a;
-A b = std::move(a); // expected-note {{'a' became 'moved-from' here}}
-b = a;  // expected-warning {{Copying a 'moved-from' object 'a'}} expected-note {{Copying a 'moved-from' object 'a'}}
+A b = std::move(a); // expected-note {{Object 'a' is moved}}
+b = a;  // expected-warning {{Moved-from object 'a' is copied}} expected-note {{Moved-from object 'a' is copied}}
   }
   {
 A a;
-A b = std::move(a); // expected-note {{'a' became 'moved-from' here}}
-b = std::move(a);   // expected-warning {{Moving a 'moved-from' object 'a'}} expected-note {{Moving a 'moved-from' object 'a'}}
+A b = std::move(a); // expected-note {{Object 'a' is moved}}
+b = std::move(a);   // expected-warning {{Moved-from object 'a' is moved}} expected-note {{Moved-from object 'a' is moved}}
   }
 }
 
@@ -156,20 +156,20 @@
   {
 A a;
 A b;
-b = std::move(a); // expected-note {{'a' became 'moved-from' here}}
-a.foo();  // expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}}
+b = std::move(a); // expected-note {{Object 'a' is moved}}
+a.foo();  // expected-warning {{Method called on moved-from object 'a'}} expected-note {{Method called on moved-from object 'a'}}
   }
   {
 A a;
 A b;
-b = std::move(a); // expected-note {{'a' became 'moved-from' here}}
-A c(a);   // expected-warning {{Copying a 'moved-from' object 'a'}} expected-note {{Copying a 'moved-from' object 'a'}}
+b = std::move(a); // expected-note {{Object 'a' is moved}}
+A c(a);   // expected-warning {{Moved-from object 'a' is copied}} expected-note {{Moved-from object 'a' is copied}}
   }
   {
 A a;
 A b;
-b = std::move(a);  // expected-note {{'a' became 'moved-from' here}}
-A c(std::move(a)); // expected-warning {{Moving a 'moved-from' object 'a'}} expected-note {{Moving a 'moved-from' object 'a'}}
+b = std::move(a);  // expected-note {{Object 'a' is moved}}
+A c(std::move(a)); // expected-warning {{Moved-from object 'a' is moved}} expected-note {{Moved-from object 'a' is moved}}
   }
 }
 
@@ -178,8 +178,8 @@
 A a;
   };
   A a;
-  S s{std::move(a)}; // expected-note {{'a' became 'moved-from' here}}
-  a.foo();   // expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}}
+  S s{std::move(a)}; // expected-note {{Object 'a' is moved}}
+  a.foo();   // expected-warning {{Method called on moved-from object 'a'}} expected-note {{Method called on moved-from object 'a'}}
 }
 
 // Don't report a bug if the variable was assigned to in the meantime.
@@ -227,19 +227,19 @@
 A b;
 b = std::move(a);
 a = A();
-b = std::move(a); // expected-note {{'a' became 'moved-from' here}}
-a.foo();  // expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}}
+b = std::move(a); // expected-note {{Object 'a' is moved}}
+a.foo();  // expected-warning {{Method called on moved-from object 'a'}} expected-note {{Method called on moved-from object 'a'}}
   }
   // If a path exist where we not reinitialize the variable we report a bug.
   {
 A a;
 A b;
-b = std::move(a); // expected-note {{'a' became 'moved-from' here}}
+b = std::move(a); // expected-note {{Object 'a' is moved}}
 if (i < 10) { // expected-note {{Assuming 'i' is >= 10}} expected-note {{Taking false branch}}
   a = A();

r348229 - [analyzer] MoveChecker: Improve warning and note messages.

2018-12-03 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Dec  3 18:00:29 2018
New Revision: 348229

URL: http://llvm.org/viewvc/llvm-project?rev=348229=rev
Log:
[analyzer] MoveChecker: Improve warning and note messages.

The warning piece traditionally describes the bug itself, i.e.
"The bug is a _", eg. "Attempt to delete released memory",
"Resource leak", "Method call on a moved-from object".

Event pieces produced by the visitor are usually in a present tense, i.e.
"At this moment _": "Memory is released", "File is closed",
"Object is moved".

Additionally, type information is added into the event pieces for STL objects
(in order to highlight that it is in fact an STL object), and the respective
event piece now mentions that the object is left in an unspecified state
after it was moved, which is a vital piece of information to understand the bug.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
cfe/trunk/test/Analysis/use-after-move.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp?rev=348229=348228=348229=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp Mon Dec  3 18:00:29 
2018
@@ -67,17 +67,29 @@ private:
 bool STL : 1; // Is this an object of a standard type?
   };
 
+  // Obtains ObjectKind of an object. Because class declaration cannot always
+  // be easily obtained from the memory region, it is supplied separately.
   static ObjectKind classifyObject(const MemRegion *MR,
const CXXRecordDecl *RD);
 
+  // Classifies the object and dumps a user-friendly description string to
+  // the stream. Return value is equivalent to classifyObject.
+  static ObjectKind explainObject(llvm::raw_ostream ,
+  const MemRegion *MR, const CXXRecordDecl 
*RD);
+
   class MovedBugVisitor : public BugReporterVisitor {
   public:
-MovedBugVisitor(const MemRegion *R) : Region(R), Found(false) {}
+MovedBugVisitor(const MemRegion *R, const CXXRecordDecl *RD)
+: Region(R), RD(RD), Found(false) {}
 
 void Profile(llvm::FoldingSetNodeID ) const override {
   static int X = 0;
   ID.AddPointer();
   ID.AddPointer(Region);
+  // Don't add RD because it's, in theory, uniquely determined by
+  // the region. In practice though, it's not always possible to obtain
+  // the declaration directly from the region, that's why we store it
+  // in the first place.
 }
 
 std::shared_ptr VisitNode(const ExplodedNode *N,
@@ -87,6 +99,8 @@ private:
   private:
 // The tracked region.
 const MemRegion *Region;
+// The class of the tracked object.
+const CXXRecordDecl *RD;
 bool Found;
   };
 
@@ -164,23 +178,21 @@ MoveChecker::MovedBugVisitor::VisitNode(
 return nullptr;
   Found = true;
 
-  std::string ObjectName;
-  if (const auto DecReg =
-  unwrapRValueReferenceIndirection(Region)->getAs()) {
-const auto *RegionDecl = dyn_cast(DecReg->getDecl());
-ObjectName = RegionDecl->getNameAsString();
-  }
-  std::string InfoText;
-  if (ObjectName != "")
-InfoText = "'" + ObjectName + "' became 'moved-from' here";
+  SmallString<128> Str;
+  llvm::raw_svector_ostream OS(Str);
+
+  OS << "Object";
+  ObjectKind OK = explainObject(OS, Region, RD);
+  if (OK.STL)
+OS << " is left in a valid but unspecified state after move";
   else
-InfoText = "Became 'moved-from' here";
+OS << " is moved";
 
   // Generate the extra diagnostic.
   PathDiagnosticLocation Pos(S, BRC.getSourceManager(),
  N->getLocationContext());
-  return std::make_shared(Pos, InfoText, true);
-}
+  return std::make_shared(Pos, OS.str(), true);
+  }
 
 const ExplodedNode *MoveChecker::getMoveLocation(const ExplodedNode *N,
  const MemRegion *Region,
@@ -205,7 +217,7 @@ ExplodedNode *MoveChecker::reportBug(con
  MisuseKind MK) const {
   if (ExplodedNode *N = C.generateNonFatalErrorNode()) {
 if (!BT)
-  BT.reset(new BugType(this, "Usage of a 'moved-from' object",
+  BT.reset(new BugType(this, "Use-after-move",
"C++ move semantics"));
 
 // Uniqueing report to the same object.
@@ -217,27 +229,29 @@ ExplodedNode *MoveChecker::reportBug(con
   MoveStmt, C.getSourceManager(), MoveNode->getLocationContext());
 
 // Creating the error message.
-std::string ErrorMessage;
+llvm::SmallString<128> Str;
+llvm::raw_svector_ostream OS(Str);
 switch(MK) {
   case MK_FunCall:
-ErrorMessage = "Method call on a 'moved-from' object";
+OS << "Method called on moved-from object";
+

[PATCH] D54560: [analyzer] MoveChecker Pt.3: Improve warning messages a bit.

2018-12-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D54560#1302051 , @MTC wrote:

> > The "moved-from" terminology we adopt here still feels a bit weird to me, 
> > but i don't have a better suggestion, so i just removed the single-quotes 
> > so that to at least feel proud about what we have.
>
> I am personally fine with this terminology, this checker corresponds to the 
> cert rule **EXP63-CPP. Do not rely on the value of a moved-from object**, and 
> **moved from** is also used in many places in CppCoreGuidelines.


Double-checked - this terminology does indeed come from the Standard:

**15.5.5.15 Moved-from state of library types [lib.types.movedfrom]**
1 Objects of types defined in the C++ standard library may be moved from 
(10.3.4.2). Move operations may be explicitly specified or implicitly 
generated. Unless otherwise specified, such moved-from objects shall be placed 
in a valid but unspecified state.


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

https://reviews.llvm.org/D54560



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


[PATCH] D53850: Declares __cpu_model as dso local

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

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D53850



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


[PATCH] D53850: Declares __cpu_model as dso local

2018-12-03 Thread Stephen Hines via Phabricator via cfe-commits
srhines added a comment.

Craig, does this look ok now?


Repository:
  rC Clang

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

https://reviews.llvm.org/D53850



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


[PATCH] D54563: [analyzer] MoveChecker Pt.4: Add a few more state reset methods.

2018-12-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I'm glad you brought this stuff up, found two more bugs to fix.

In D54563#1317678 , @Szelethus wrote:

> Can you add tests for that just in case? :)


The test works, but i noticed that we aren't respecting const references. That 
is, we believe that passing the object by const reference or pointer may reset 
it. I guess i'll make a separate commit.




Comment at: test/Analysis/use-after-move.cpp:260-262
 for (int i = 0; i < bignum(); i++) { // expected-note {{Loop condition is 
false. Execution jumps to the end of the function}}
   rightRefCall(std::move(a));// no-warning
 }

Szelethus wrote:
> NoQ wrote:
> > This would have been the test for our case, but in this test the function 
> > has a body and will not be evaluated conservatively.
> Hmm, since those are all STL containers, we should be able to have their 
> definition? Or only with `c++-container-inlining=true`? Take this as more of 
> a question than anything else.
Yeah, assuming that we only need containers.

As usual, i expect only good things to happen when we inline them. Say, if a 
field is overwritten in the inlined call, this would also trigger 
`checkRegionChanges`. And i doubt that in these examples there will be a path 
through the function that leaves the object entirely untouched.

As a side note, i doubt that we'll actually react to field assignment, because 
this checker's `checkRegionChanges` callback doesn't account for that: it only 
iterates through explicit regions. I guess this needs fixing.


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

https://reviews.llvm.org/D54563



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


[PATCH] D54563: [analyzer] MoveChecker Pt.4: Add a few more state reset methods.

2018-12-03 Thread Kristüf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Okay, I submit! :D




Comment at: test/Analysis/use-after-move.cpp:260-262
 for (int i = 0; i < bignum(); i++) { // expected-note {{Loop condition is 
false. Execution jumps to the end of the function}}
   rightRefCall(std::move(a));// no-warning
 }

NoQ wrote:
> This would have been the test for our case, but in this test the function has 
> a body and will not be evaluated conservatively.
Hmm, since those are all STL containers, we should be able to have their 
definition? Or only with `c++-container-inlining=true`? Take this as more of a 
question than anything else.


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

https://reviews.llvm.org/D54563



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


[PATCH] D52117: Generate llvm.loop.parallel_accesses instead of llvm.mem.parallel_loop_access metadata.

2018-12-03 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added inline comments.



Comment at: lib/CodeGen/CGLoopInfo.cpp:372
+  if (Active.size() >= 2) {
+LoopInfo  = reverse(Active).begin()[1];
+NewFront.addAccGroups(Front.getNestedAccGroups());

reverse(Active).begin() looks odd. Can we get the same thing by calling last()?


Repository:
  rC Clang

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

https://reviews.llvm.org/D52117



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


[PATCH] D53787: [Sema] Provide -fvisibility-global-new-delete-hidden option

2018-12-03 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Looks good with minor changes, thanks.




Comment at: clang/include/clang/Basic/LangOptions.def:228
 BENIGN_LANGOPT(InlineVisibilityHidden , 1, 0, "hidden default visibility for 
inline C++ methods")
+BENIGN_LANGOPT(GlobalAllocationFunctionVisibilityHidden , 1, 0, "hidden 
default visibility for global operator new and delete declaration")
 BENIGN_LANGOPT(ParseUnknownAnytype, 1, 0, "__unknown_anytype")

This should just be `LANGOPT`, not `BENIGN_LANGOPT`, because it changes how we 
construct the AST (in an incompatible way).

Also, could you please remove the "default" from the description of this 
LANGOPT (and the previous one)? "default visibility" means something else, so 
this is confusing as written.



Comment at: clang/include/clang/Driver/Options.td:1728
+def fvisibility_global_new_delete_hidden : Flag<["-"], 
"fvisibility-global-new-delete-hidden">, Group,
+  HelpText<"Give global C++ operator new and delete declarations hidden 
visibility by default">, Flags<[CC1Option]>;
 def fwhole_program_vtables : Flag<["-"], "fwhole-program-vtables">, 
Group,

Remove the "by default" here: the program can't change the visibility to 
anything else via an attribute.


Repository:
  rC Clang

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

https://reviews.llvm.org/D53787



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


[PATCH] D55039: [sema] Warn of mangling change if function parameters are noexcept.

2018-12-03 Thread Matt Davis via Phabricator via cfe-commits
mattd updated this revision to Diff 176515.
mattd added a comment.

- Move the HasNoexcept lambda to its own static function.
- Added an additional check in HasNoexcept to recursively check return values.
- Modified the parameter check in Sema::CheckFunctionDeclaration to use 
llvm::any_of, all we need to know is if any of the parameters might have a 
mangling change.
- Updated the test to include the example provided by @Rakete.


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

https://reviews.llvm.org/D55039

Files:
  lib/Sema/SemaDecl.cpp
  test/CXX/except/except.spec/p2-places.cpp
  test/SemaCXX/cxx1z-noexcept-function-type.cpp

Index: test/SemaCXX/cxx1z-noexcept-function-type.cpp
===
--- test/SemaCXX/cxx1z-noexcept-function-type.cpp
+++ test/SemaCXX/cxx1z-noexcept-function-type.cpp
@@ -83,14 +83,18 @@
   auto f5() -> void (*)() throw();
   auto f6() -> void (&)() throw();
   auto f7() -> void (X::*)() throw();
+  void f8(int, void (*)(int, void (*)() noexcept));
+  void f9(void (*g())() noexcept);
 #if __cplusplus <= 201402L && !defined(NO_COMPAT_MANGLING)
-  // expected-warning@-8 {{mangled name of 'f1' will change in C++17 due to non-throwing exception specification in function signature}}
-  // expected-warning@-8 {{mangled name of 'f2' will change in C++17 due to non-throwing exception specification in function signature}}
-  // expected-warning@-8 {{mangled name of 'f3' will change in C++17 due to non-throwing exception specification in function signature}}
-  // expected-warning@-8 {{mangled name of 'f4' will change in C++17 due to non-throwing exception specification in function signature}}
-  // expected-warning@-8 {{mangled name of 'f5' will change in C++17 due to non-throwing exception specification in function signature}}
-  // expected-warning@-8 {{mangled name of 'f6' will change in C++17 due to non-throwing exception specification in function signature}}
-  // expected-warning@-8 {{mangled name of 'f7' will change in C++17 due to non-throwing exception specification in function signature}}
+  // expected-warning@-10 {{mangled name of 'f1' will change in C++17 due to non-throwing exception specification in function signature}}
+  // expected-warning@-10 {{mangled name of 'f2' will change in C++17 due to non-throwing exception specification in function signature}}
+  // expected-warning@-10 {{mangled name of 'f3' will change in C++17 due to non-throwing exception specification in function signature}}
+  // expected-warning@-10 {{mangled name of 'f4' will change in C++17 due to non-throwing exception specification in function signature}}
+  // expected-warning@-10 {{mangled name of 'f5' will change in C++17 due to non-throwing exception specification in function signature}}
+  // expected-warning@-10 {{mangled name of 'f6' will change in C++17 due to non-throwing exception specification in function signature}}
+  // expected-warning@-10 {{mangled name of 'f7' will change in C++17 due to non-throwing exception specification in function signature}}
+  // expected-warning@-10 {{mangled name of 'f8' will change in C++17 due to non-throwing exception specification in function signature}}
+  // expected-warning@-10 {{mangled name of 'f9' will change in C++17 due to non-throwing exception specification in function signature}}
 #endif
 
   // An instantiation-dependent exception specification needs to be mangled in
Index: test/CXX/except/except.spec/p2-places.cpp
===
--- test/CXX/except/except.spec/p2-places.cpp
+++ test/CXX/except/except.spec/p2-places.cpp
@@ -55,7 +55,7 @@
 
   void (*h())() noexcept(false);
 
-  void (*i() noexcept(false))(void (*)() noexcept(true)) noexcept(false);
+  void (*i() noexcept(false))(void (*)() noexcept(true)) noexcept(false); // expected-warning {{mangled name of 'i' will change in C++17 due to non-throwing exception specification in function signature}}
 
   void (**k)(void pfa() noexcept(false)); // no-error
 
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -9914,6 +9914,28 @@
   OldDecl, MergeTypeWithPrevious, Previous);
 }
 
+/// Returns true if the type T is a function type that contains a noexcept specifier.
+/// This check recursively checks the params and return types of T if T happens
+/// to be a function.
+static bool hasNoexcept(QualType T) {
+  // Strip off declarator chunks that could be between us and a function
+  // type. We don't need to look far, exception specifications are very
+  // restricted prior to C++17.
+  if (auto *RT = T->getAs())
+T = RT->getPointeeType();
+  else if (T->isAnyPointerType())
+T = T->getPointeeType();
+  else if (auto *MPT = T->getAs())
+T = MPT->getPointeeType();
+  if (auto *FPT = T->getAs()) {
+if (FPT->isNothrow() || 

[PATCH] D54563: [analyzer] MoveChecker Pt.4: Add a few more state reset methods.

2018-12-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: test/Analysis/use-after-move.cpp:331
 for (int i = 0; i < bignum(); i++) { // expected-note {{Loop condition is 
true.  Entering loop body}} expected-note {{Loop condition is true.  Entering 
loop body}}
   constCopyOrMoveCall(std::move(a)); // expected-warning {{Moved-from 
object is moved 'a'}} expected-note {{Moved-from object is moved 'a'}}
   // expected-note@-1 {{'a' is moved}}

Szelethus wrote:
> >Because `list2` is passed by non-const reference (eg., rvalue reference) 
> >into an unknown function, it will be invalidated when the call is modeled 
> >conservatively, and therefore we will stop tracking it in the 
> >`checkRegionChanges` callback.
> 
> Hmmm. Doesn't this check something similar, but still cause an warning?
In this case `a` is passed by value. Therefore a move-constructor is called, 
and then the function does not have access to `a`.



Comment at: test/Analysis/use-after-move.cpp:260-262
 for (int i = 0; i < bignum(); i++) { // expected-note {{Loop condition is 
false. Execution jumps to the end of the function}}
   rightRefCall(std::move(a));// no-warning
 }

This would have been the test for our case, but in this test the function has a 
body and will not be evaluated conservatively.



Comment at: test/Analysis/use-after-move.cpp:597-615
 void not_known(A );
 void not_known(A *a);
 
 void regionAndPointerEscapeTest() {
   {
 A a;
 A b;

This would have been the test for our case, but the `&&` case isn't tested.


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

https://reviews.llvm.org/D54563



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


[PATCH] D54563: [analyzer] MoveChecker Pt.4: Add a few more state reset methods.

2018-12-03 Thread Kristüf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Can you add tests for that just in case? :)




Comment at: test/Analysis/use-after-move.cpp:331
 for (int i = 0; i < bignum(); i++) { // expected-note {{Loop condition is 
true.  Entering loop body}} expected-note {{Loop condition is true.  Entering 
loop body}}
   constCopyOrMoveCall(std::move(a)); // expected-warning {{Moved-from 
object is moved 'a'}} expected-note {{Moved-from object is moved 'a'}}
   // expected-note@-1 {{'a' is moved}}

>Because `list2` is passed by non-const reference (eg., rvalue reference) into 
>an unknown function, it will be invalidated when the call is modeled 
>conservatively, and therefore we will stop tracking it in the 
>`checkRegionChanges` callback.

Hmmm. Doesn't this check something similar, but still cause an warning?


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

https://reviews.llvm.org/D54563



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


r348218 - NFC: Make this test kinder on downstream forks

2018-12-03 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Mon Dec  3 16:31:31 2018
New Revision: 348218

URL: http://llvm.org/viewvc/llvm-project?rev=348218=rev
Log:
NFC: Make this test kinder on downstream forks

Downstream forks that have their own attributes often run into this
test failing when a new attribute is added to clang because the
number of supported attributes no longer match. This is redundant
information for this test, so we can get by without it.

rdar://46288577

Modified:
cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test?rev=348218=348217=348218=diff
==
--- cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test 
(original)
+++ cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test Mon Dec 
 3 16:31:31 2018
@@ -2,7 +2,7 @@
 
 // The number of supported attributes should never go down!
 
-// CHECK: #pragma clang attribute supports 133 attributes:
+// CHECK: #pragma clang attribute supports the following attributes:
 // CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)
@@ -136,3 +136,4 @@
 // CHECK-NEXT: WorkGroupSizeHint (SubjectMatchRule_function)
 // CHECK-NEXT: XRayInstrument (SubjectMatchRule_function, 
SubjectMatchRule_objc_method)
 // CHECK-NEXT: XRayLogArgs (SubjectMatchRule_function, 
SubjectMatchRule_objc_method)
+// CHECK-NEXT: End of supported attributes.

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=348218=348217=348218=diff
==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Mon Dec  3 16:31:31 2018
@@ -3977,12 +3977,7 @@ void EmitTestPragmaAttributeSupportedAtt
 raw_ostream ) {
   PragmaClangAttributeSupport Support = getPragmaAttributeSupport(Records);
   ParsedAttrMap Attrs = getParsedAttrList(Records);
-  unsigned NumAttrs = 0;
-  for (const auto  : Attrs) {
-if (Support.isAttributedSupported(*I.second))
-  ++NumAttrs;
-  }
-  OS << "#pragma clang attribute supports " << NumAttrs << " attributes:\n";
+  OS << "#pragma clang attribute supports the following attributes:\n";
   for (const auto  : Attrs) {
 if (!Support.isAttributedSupported(*I.second))
   continue;
@@ -4014,6 +4009,7 @@ void EmitTestPragmaAttributeSupportedAtt
 }
 OS << ")\n";
   }
+  OS << "End of supported attributes.\n";
 }
 
 } // end namespace clang


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


[PATCH] D54563: [analyzer] MoveChecker Pt.4: Add a few more state reset methods.

2018-12-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 176512.
NoQ added a comment.

Add a TODO.


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

https://reviews.llvm.org/D54563

Files:
  lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  test/Analysis/use-after-move.cpp


Index: test/Analysis/use-after-move.cpp
===
--- test/Analysis/use-after-move.cpp
+++ test/Analysis/use-after-move.cpp
@@ -15,6 +15,8 @@
 
 namespace std {
 
+typedef __typeof(sizeof(int)) size_t;
+
 template 
 struct remove_reference;
 
@@ -110,6 +112,7 @@
   void reset();
   void destroy();
   void clear();
+  void resize(std::size_t);
   bool empty() const;
   bool isEmpty() const;
   operator bool() const;
@@ -403,6 +406,13 @@
 a.foo();   // no-warning
 a.b.foo(); // no-warning
   }
+  {
+A a;
+A b = std::move(a);
+a.resize(0); // no-warning
+a.foo();   // no-warning
+a.b.foo(); // no-warning
+  }
 }
 
 // Moves or uses that occur as part of template arguments.
Index: lib/StaticAnalyzer/Checkers/MoveChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MoveChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MoveChecker.cpp
@@ -342,8 +342,11 @@
   return true;
   if (MethodDec->getDeclName().isIdentifier()) {
 std::string MethodName = MethodDec->getName().lower();
+// TODO: Some of these methods (eg., resize) are not always resetting
+// the state, so we should consider looking at the arguments.
 if (MethodName == "reset" || MethodName == "clear" ||
-MethodName == "destroy")
+MethodName == "destroy" || MethodName == "resize" ||
+MethodName == "shrink" || MethodName == "shrink_to_fit")
   return true;
   }
   return false;


Index: test/Analysis/use-after-move.cpp
===
--- test/Analysis/use-after-move.cpp
+++ test/Analysis/use-after-move.cpp
@@ -15,6 +15,8 @@
 
 namespace std {
 
+typedef __typeof(sizeof(int)) size_t;
+
 template 
 struct remove_reference;
 
@@ -110,6 +112,7 @@
   void reset();
   void destroy();
   void clear();
+  void resize(std::size_t);
   bool empty() const;
   bool isEmpty() const;
   operator bool() const;
@@ -403,6 +406,13 @@
 a.foo();   // no-warning
 a.b.foo(); // no-warning
   }
+  {
+A a;
+A b = std::move(a);
+a.resize(0); // no-warning
+a.foo();   // no-warning
+a.b.foo(); // no-warning
+  }
 }
 
 // Moves or uses that occur as part of template arguments.
Index: lib/StaticAnalyzer/Checkers/MoveChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MoveChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MoveChecker.cpp
@@ -342,8 +342,11 @@
   return true;
   if (MethodDec->getDeclName().isIdentifier()) {
 std::string MethodName = MethodDec->getName().lower();
+// TODO: Some of these methods (eg., resize) are not always resetting
+// the state, so we should consider looking at the arguments.
 if (MethodName == "reset" || MethodName == "clear" ||
-MethodName == "destroy")
+MethodName == "destroy" || MethodName == "resize" ||
+MethodName == "shrink" || MethodName == "shrink_to_fit")
   return true;
   }
   return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54563: [analyzer] MoveChecker Pt.4: Add a few more state reset methods.

2018-12-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D54563#1306358 , @Szelethus wrote:

> This suggests to me that `list1.splice(list1.begin(), std::move(list2))` 
> leaves  `list2` in a valid, well-defined, but empty state.


I think this should work automagically. Because `list2` is passed by non-const 
reference (eg., rvalue reference) into an unknown function, it will be 
invalidated when the call is modeled conservatively, and therefore we will stop 
tracking it in the `checkRegionChanges` callback.


Repository:
  rC Clang

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

https://reviews.llvm.org/D54563



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


r348214 - [Hexagon] Fix intrinsic test

2018-12-03 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Mon Dec  3 15:52:33 2018
New Revision: 348214

URL: http://llvm.org/viewvc/llvm-project?rev=348214=rev
Log:
[Hexagon] Fix intrinsic test

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

Modified: cfe/trunk/test/CodeGen/builtins-hexagon.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-hexagon.c?rev=348214=348213=348214=diff
==
--- cfe/trunk/test/CodeGen/builtins-hexagon.c (original)
+++ cfe/trunk/test/CodeGen/builtins-hexagon.c Mon Dec  3 15:52:33 2018
@@ -426,8 +426,6 @@ void test() {
   __builtin_HEXAGON_A5_vaddhubs(0, 0);
   // CHECK: @llvm.hexagon.A6.vcmpbeq.notany
   __builtin_HEXAGON_A6_vcmpbeq_notany(0, 0);
-  // CHECK: @llvm.hexagon.A6.vcmpbeq.notany.128B
-  __builtin_HEXAGON_A6_vcmpbeq_notany_128B(0, 0);
   // CHECK: @llvm.hexagon.C2.all8
   __builtin_HEXAGON_C2_all8(0);
   // CHECK: @llvm.hexagon.C2.and
@@ -1400,8 +1398,6 @@ void test() {
   __builtin_HEXAGON_S2_brev(0);
   // CHECK: @llvm.hexagon.S2.brevp
   __builtin_HEXAGON_S2_brevp(0);
-  // CHECK: @llvm.hexagon.S2.cabacencbin
-  __builtin_HEXAGON_S2_cabacencbin(0, 0, 0);
   // CHECK: @llvm.hexagon.S2.cl0
   __builtin_HEXAGON_S2_cl0(0);
   // CHECK: @llvm.hexagon.S2.cl0p


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


[PATCH] D54560: [analyzer] MoveChecker Pt.3: Improve warning messages a bit.

2018-12-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/MoveChecker.cpp:385-386
+  }
+  // Provide the caller with the classification of the object
+  // we've obtained here accidentally, for later use.
+  return OK;

Szelethus wrote:
> NoQ wrote:
> > Szelethus wrote:
> > > Maybe move this in-class?
> > Mmm, what do you mean?
> `explain.*` sounds like it either returns a string, or writes a stream 
> object, but the return type isn't `void` nor string, maybe it'd be worth to 
> put this comment in-class.
> 
> But yea, this is over the top nitpicking, I don't insist :)
Fxd!



Comment at: test/Analysis/use-after-move.cpp:146
+A b = std::move(a); // expected-note {{Object 'a' is moved}}
+b = a;  // expected-warning {{Moved-from object is copied 
'a'}} expected-note {{Moved-from object is copied 'a'}}
   }

dcoughlin wrote:
> "Moved-from object is copied 'a'" doesn't read quite right. I think the 
> object name is in the wrong spot. Instead, I would suggest: "Moved-from 
> object 'a' is copied"
Whoops!!


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

https://reviews.llvm.org/D54560



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


[PATCH] D54560: [analyzer] MoveChecker Pt.3: Improve warning messages a bit.

2018-12-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 176504.
NoQ marked 4 inline comments as done.
NoQ added a comment.

Address comments!

In D54560#1304155 , @Charusso wrote:

> In D54560#1301870 , @NoQ wrote:
>
> > Write down full messages in tests. When the message was updated from `'x' 
> > is moved'` to `Object 'x' is moved`, the tests were not updated because 
> > they kept passing because the former is still a sub-string of the latter.
>
>
> It would not be cool to rewrite this `contains` effect to equality like in 
> the regex file-checks? I have ran in the same problem and I was very 
> surprised (for an hour) why my error-dumps does not show up on rewriting 
> bug-report messages.


We already have `// expected-warning-re^Message$` for that purpose, 
it's just annoying to write and is rarely an issue, so nobody uses them until 
it's absolutely necessary (cf. `test/Analysis/explain-svals.cpp`). Same with 
`FileCheck` tests.


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

https://reviews.llvm.org/D54560

Files:
  lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  test/Analysis/use-after-move.cpp

Index: test/Analysis/use-after-move.cpp
===
--- test/Analysis/use-after-move.cpp
+++ test/Analysis/use-after-move.cpp
@@ -88,7 +88,7 @@
   A(const A ) : i(other.i), d(other.d), b(other.b) {}
   A(A &) : i(other.i), d(other.d), b(std::move(other.b)) {
 #ifdef AGGRESSIVE
-// expected-note@-2{{'b' became 'moved-from' here}}
+// expected-note@-2{{Object 'b' is moved}}
 #endif
   }
   A(A &, char *k) {
@@ -137,18 +137,18 @@
 void simpleMoveCtorTest() {
   {
 A a;
-A b = std::move(a); // expected-note {{'a' became 'moved-from' here}}
-a.foo();// expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}}
+A b = std::move(a); // expected-note {{Object 'a' is moved}}
+a.foo();// expected-warning {{Method called on moved-from object 'a'}} expected-note {{Method called on moved-from object 'a'}}
   }
   {
 A a;
-A b = std::move(a); // expected-note {{'a' became 'moved-from' here}}
-b = a;  // expected-warning {{Copying a 'moved-from' object 'a'}} expected-note {{Copying a 'moved-from' object 'a'}}
+A b = std::move(a); // expected-note {{Object 'a' is moved}}
+b = a;  // expected-warning {{Moved-from object 'a' is copied}} expected-note {{Moved-from object 'a' is copied}}
   }
   {
 A a;
-A b = std::move(a); // expected-note {{'a' became 'moved-from' here}}
-b = std::move(a);   // expected-warning {{Moving a 'moved-from' object 'a'}} expected-note {{Moving a 'moved-from' object 'a'}}
+A b = std::move(a); // expected-note {{Object 'a' is moved}}
+b = std::move(a);   // expected-warning {{Moved-from object 'a' is moved}} expected-note {{Moved-from object 'a' is moved}}
   }
 }
 
@@ -156,20 +156,20 @@
   {
 A a;
 A b;
-b = std::move(a); // expected-note {{'a' became 'moved-from' here}}
-a.foo();  // expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}}
+b = std::move(a); // expected-note {{Object 'a' is moved}}
+a.foo();  // expected-warning {{Method called on moved-from object 'a'}} expected-note {{Method called on moved-from object 'a'}}
   }
   {
 A a;
 A b;
-b = std::move(a); // expected-note {{'a' became 'moved-from' here}}
-A c(a);   // expected-warning {{Copying a 'moved-from' object 'a'}} expected-note {{Copying a 'moved-from' object 'a'}}
+b = std::move(a); // expected-note {{Object 'a' is moved}}
+A c(a);   // expected-warning {{Moved-from object 'a' is copied}} expected-note {{Moved-from object 'a' is copied}}
   }
   {
 A a;
 A b;
-b = std::move(a);  // expected-note {{'a' became 'moved-from' here}}
-A c(std::move(a)); // expected-warning {{Moving a 'moved-from' object 'a'}} expected-note {{Moving a 'moved-from' object 'a'}}
+b = std::move(a);  // expected-note {{Object 'a' is moved}}
+A c(std::move(a)); // expected-warning {{Moved-from object 'a' is moved}} expected-note {{Moved-from object 'a' is moved}}
   }
 }
 
@@ -178,8 +178,8 @@
 A a;
   };
   A a;
-  S s{std::move(a)}; // expected-note {{'a' became 'moved-from' here}}
-  a.foo();   // expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}}
+  S s{std::move(a)}; // expected-note {{Object 'a' is moved}}
+  a.foo();   // expected-warning {{Method called on moved-from object 'a'}} expected-note {{Method called on moved-from object 'a'}}
 }
 
 // Don't report a bug if the variable was assigned to in the meantime.
@@ -227,19 +227,19 @@
 A b;
 b = std::move(a);
 a = A();

[PATCH] D53738: [Fixed Point Arithmetic] Fixed Point Addition

2018-12-03 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:1304
+RHSTy = ResultTy;
+  }
+

leonardchan wrote:
> rjmccall wrote:
> > ebevhan wrote:
> > > rjmccall wrote:
> > > > leonardchan wrote:
> > > > > rjmccall wrote:
> > > > > > ebevhan wrote:
> > > > > > > rjmccall wrote:
> > > > > > > > Hmm.  So adding a signed integer to an unsigned fixed-point 
> > > > > > > > type always converts the integer to unsigned?  That's a little 
> > > > > > > > weird, but only because the fixed-point rule seems to be the 
> > > > > > > > other way.  Anyway, I assume it's not a bug in the spec.
> > > > > > > `handleFixedPointConversion` only calculates the result type of 
> > > > > > > the expression, not the calculation type. The final result type 
> > > > > > > of the operation will be the unsigned fixed-point type, but the 
> > > > > > > calculation itself will be done in a signed type with enough 
> > > > > > > precision to represent both the signed integer and the unsigned 
> > > > > > > fixed-point type. 
> > > > > > > 
> > > > > > > Though, if the result ends up being negative, the final result is 
> > > > > > > undefined unless the type is saturating. I don't think there is a 
> > > > > > > test for the saturating case (signed integer + unsigned 
> > > > > > > saturating fixed-point) in the SaturatedAddition tests.
> > > > > > > `handleFixedPointConversion` only calculates the result type of 
> > > > > > > the expression, not the calculation type.
> > > > > > 
> > > > > > Right, I understand that, but the result type of the expression 
> > > > > > obviously impacts the expressive range of the result, since you can 
> > > > > > end up with a negative value.
> > > > > > 
> > > > > > Hmm.  With that said, if the general principle is to perform the 
> > > > > > operation with full precision on the original operand values, why 
> > > > > > are unsigned fixed-point operands coerced to their corresponding 
> > > > > > signed types *before* the operation?  This is precision-limiting if 
> > > > > > the unsigned representation doesn't use a padding bit.  That seems 
> > > > > > like a bug in the spec.
> > > > > > Hmm. With that said, if the general principle is to perform the 
> > > > > > operation with full precision on the original operand values, why 
> > > > > > are unsigned fixed-point operands coerced to their corresponding 
> > > > > > signed types *before* the operation? This is precision-limiting if 
> > > > > > the unsigned representation doesn't use a padding bit. That seems 
> > > > > > like a bug in the spec.
> > > > > 
> > > > > Possibly. When the standard mentions converting from signed to 
> > > > > unsigned fixed point, the only requirement involved is conservation 
> > > > > of magnitude (the number of integral bits excluding the sign)
> > > > > 
> > > > > ```
> > > > > when signed and unsigned fixed-point types are mixed, the unsigned 
> > > > > type is converted to the corresponding signed type, and this should 
> > > > > go without loss of magnitude
> > > > > ```
> > > > > 
> > > > > This is just speculation, but I'm under the impression that not as 
> > > > > much "attention" was given for unsigned types as for signed types 
> > > > > since "`In the embedded processor world, support for unsigned 
> > > > > fixed-point data types is rare; normally only signed fixed-point data 
> > > > > types are supported`", but was kept anyway since unsigned types are 
> > > > > used a lot.
> > > > > 
> > > > > ```
> > > > > However, to disallow unsigned fixed-point arithmetic from programming 
> > > > > languages (in general, and from C in particular) based on this 
> > > > > observation, seems overly restrictive.
> > > > > ```
> > > > > 
> > > > > I also imagine that if the programmer needs more precision, the 
> > > > > correct approach would be to cast up to a type with a higher scale. 
> > > > > The standard seems to make an effort to expose as much in regards to 
> > > > > the underlying fixed point types as possible:
> > > > > 
> > > > > ```
> > > > > it should be possible to write fixed-point algorithms that are 
> > > > > independent of the actual fixed-point hardware support. This implies 
> > > > > that a programmer (or a running program) should have access to all 
> > > > > parameters that define the behavior of the underlying hardware (in 
> > > > > other words: even if these parameters are implementation-defined).
> > > > > ```
> > > > > 
> > > > > So the user would at least know that unsigned types may not have the 
> > > > > same scale as their corresponding signed types if the hardware 
> > > > > handles them with different scales.
> > > > > 
> > > > > Also added test for signed integer + unsigned saturating fixed point.
> > > > As long as we maintain the same typing behavior, does the standard 
> > > > permit us to just Do The Right Thing here and do the extended 
> > > > arithmetic with the original unsigned operand?  I'm sure there are some 
> 

r348213 - Relax test even more for Windows

2018-12-03 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Dec  3 15:40:51 2018
New Revision: 348213

URL: http://llvm.org/viewvc/llvm-project?rev=348213=rev
Log:
Relax test even more for Windows

Modified:
cfe/trunk/test/CodeGen/debug-prefix-map.c

Modified: cfe/trunk/test/CodeGen/debug-prefix-map.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-prefix-map.c?rev=348213=348212=348213=diff
==
--- cfe/trunk/test/CodeGen/debug-prefix-map.c (original)
+++ cfe/trunk/test/CodeGen/debug-prefix-map.c Mon Dec  3 15:40:51 2018
@@ -36,5 +36,5 @@ void test_rewrite_includes() {
 // CHECK-NOT: !DIFile(filename:
 
 // CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}", directory: "/var/empty")
-// CHECK-COMPILATION-DIR: !DIFile(filename: "Inputs/stdio.h", directory: 
"/var/empty")
+// CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}Inputs/stdio.h", directory: 
"/var/empty")
 // CHECK-COMPILATION-DIR-NOT: !DIFile(filename:


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


r348211 - Relax tests to also work on Windows

2018-12-03 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Dec  3 15:11:19 2018
New Revision: 348211

URL: http://llvm.org/viewvc/llvm-project?rev=348211=rev
Log:
Relax tests to also work on Windows

Modified:
cfe/trunk/test/CodeGen/debug-prefix-map.c
cfe/trunk/test/Modules/module-debuginfo-prefix.m

Modified: cfe/trunk/test/CodeGen/debug-prefix-map.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-prefix-map.c?rev=348211=348210=348211=diff
==
--- cfe/trunk/test/CodeGen/debug-prefix-map.c (original)
+++ cfe/trunk/test/CodeGen/debug-prefix-map.c Mon Dec  3 15:11:19 2018
@@ -18,19 +18,21 @@ void test_rewrite_includes() {
 
 // CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/var/empty{{/|\\5C}}"
 // CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/var/empty{{[/\\]}}{{.*}}",
-// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "")
+// Dir should always be empty, but on Windows we can't recognize /var
+// as being an absolute path.
+// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
 // CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/var/empty{{[/\\]}}Inputs/stdio.h",
-// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "")
+// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
 // CHECK-NO-MAIN-FILE-NAME-NOT: !DIFile(filename:
 
 // CHECK-EVIL: !DIFile(filename: "/var=empty{{[/\\]}}{{.*}}"
 // CHECK-EVIL: !DIFile(filename: "/var=empty{{[/\\]}}{{.*}}Inputs/stdio.h",
-// CHECK-EVIL-SAME:directory: "")
+// CHECK-EVIL-SAME:directory: "{{()|(.*:.*)}}")
 // CHECK-EVIL-NOT: !DIFile(filename:
 
 // CHECK: !DIFile(filename: "/var/empty{{[/\\]}}{{.*}}"
 // CHECK: !DIFile(filename: "/var/empty{{[/\\]}}{{.*}}Inputs/stdio.h",
-// CHECK-SAME:directory: "")
+// CHECK-SAME:directory: "{{()|(.*:.*)}}")
 // CHECK-NOT: !DIFile(filename:
 
 // CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}", directory: "/var/empty")

Modified: cfe/trunk/test/Modules/module-debuginfo-prefix.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module-debuginfo-prefix.m?rev=348211=348210=348211=diff
==
--- cfe/trunk/test/Modules/module-debuginfo-prefix.m (original)
+++ cfe/trunk/test/Modules/module-debuginfo-prefix.m Mon Dec  3 15:11:19 2018
@@ -20,4 +20,6 @@
 @import DebugObjC;
 #endif
 
-// CHECK: !DIFile(filename: "/OVERRIDE/DebugObjC.h", directory: "")
+// Dir should always be empty, but on Windows we can't recognize /var
+// as being an absolute path.
+// CHECK: !DIFile(filename: "/OVERRIDE/DebugObjC.h", directory: 
"{{()|(.*:.*)}}")


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


Re: r348154 - Avoid emitting redundant or unusable directories in DIFile metadata entries.

2018-12-03 Thread Adrian Prantl via cfe-commits
Should be fixed in r348211.

-- adrian

> On Dec 3, 2018, at 3:07 PM, Adrian Prantl via cfe-commits 
>  wrote:
> 
> No, your failures are Windows-specific (/ vs \), and I haven't fixed them 
> yet. Thanks for letting me know!
> 
> -- adrian
> 
>> On Dec 3, 2018, at 3:06 PM, Galina Kistanova  wrote:
>> 
>> Adrian, did not see your response, please ignore my email.
>> 
>> Thanks
>> 
>> Galina
>> 
>> On Mon, Dec 3, 2018 at 3:04 PM Galina Kistanova  wrote:
>> Hello Adrian,
>> 
>> This commit broke tests on couple of our builders:
>> 
>> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/14371
>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast
>> 
>> . . .
>> Failing Tests (2):
>> Clang :: CodeGen/debug-prefix-map.c
>> Clang :: Modules/module-debuginfo-prefix.m
>> 
>> The builders were already red and no notifications were sent on this.
>> Please have a look?
>> 
>> Thanks
>> 
>> Galina
>> 
>> On Mon, Dec 3, 2018 at 9:58 AM Adrian Prantl via cfe-commits 
>>  wrote:
>> Author: adrian
>> Date: Mon Dec  3 09:55:27 2018
>> New Revision: 348154
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=348154=rev
>> Log:
>> Avoid emitting redundant or unusable directories in DIFile metadata entries.
>> 
>> As discussed on llvm-dev recently, Clang currently emits redundant
>> directories in DIFile entries, such as
>> 
>>   .file  1 "/Volumes/Data/llvm" 
>> "/Volumes/Data/llvm/tools/clang/test/CodeGen/debug-info-abspath.c"
>> 
>> This patch looks at any common prefix between the compilation
>> directory and the (absolute) file path and strips the redundant
>> part. More importantly it leaves the compilation directory empty if
>> the two paths have no common prefix.
>> 
>> After this patch the above entry is (assuming a compilation dir of 
>> "/Volumes/Data/llvm/_build"):
>> 
>>   .file 1 "/Volumes/Data/llvm" 
>> "tools/clang/test/CodeGen/debug-info-abspath.c"
>> 
>> When building the FileCheck binary with debug info, this patch makes
>> the build artifacts ~1kb smaller.
>> 
>> Differential Revision: https://reviews.llvm.org/D55085
>> 
>> Added:
>> cfe/trunk/test/CodeGen/debug-info-abspath.c
>> Modified:
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> cfe/trunk/lib/CodeGen/CodeGenAction.cpp
>> cfe/trunk/test/CodeGen/debug-prefix-map.c
>> cfe/trunk/test/Modules/module-debuginfo-prefix.m
>> 
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=348154=348153=348154=diff
>> ==
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Dec  3 09:55:27 2018
>> @@ -181,8 +181,7 @@ void CGDebugInfo::setLocation(SourceLoca
>>SourceManager  = CGM.getContext().getSourceManager();
>>auto *Scope = cast(LexicalBlockStack.back());
>>PresumedLoc PCLoc = SM.getPresumedLoc(CurLoc);
>> -
>> -  if (PCLoc.isInvalid() || Scope->getFilename() == PCLoc.getFilename())
>> +  if (PCLoc.isInvalid() || Scope->getFile() == getOrCreateFile(CurLoc))
>>  return;
>> 
>>if (auto *LBF = dyn_cast(Scope)) {
>> @@ -410,13 +409,13 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>>SourceManager  = CGM.getContext().getSourceManager();
>>PresumedLoc PLoc = SM.getPresumedLoc(Loc);
>> 
>> -  if (PLoc.isInvalid() || StringRef(PLoc.getFilename()).empty())
>> +  StringRef FileName = PLoc.getFilename();
>> +  if (PLoc.isInvalid() || FileName.empty())
>>  // If the location is not valid then use main input file.
>>  return getOrCreateMainFile();
>> 
>>// Cache the results.
>> -  const char *fname = PLoc.getFilename();
>> -  auto It = DIFileCache.find(fname);
>> +  auto It = DIFileCache.find(FileName.data());
>> 
>>if (It != DIFileCache.end()) {
>>  // Verify that the information still exists.
>> @@ -431,11 +430,41 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>>if (CSKind)
>>  CSInfo.emplace(*CSKind, Checksum);
>> 
>> -  llvm::DIFile *F = DBuilder.createFile(
>> -  remapDIPath(PLoc.getFilename()), remapDIPath(getCurrentDirname()), 
>> CSInfo,
>> -  getSource(SM, SM.getFileID(Loc)));
>> +  StringRef Dir;
>> +  StringRef File;
>> +  std::string RemappedFile = remapDIPath(FileName);
>> +  std::string CurDir = remapDIPath(getCurrentDirname());
>> +  SmallString<128> DirBuf;
>> +  SmallString<128> FileBuf;
>> +  if (llvm::sys::path::is_absolute(RemappedFile)) {
>> +// Strip the common prefix (if it is more than just "/") from current
>> +// directory and FileName for a more space-efficient encoding.
>> +auto FileIt = llvm::sys::path::begin(RemappedFile);
>> +auto FileE = llvm::sys::path::end(RemappedFile);
>> +auto CurDirIt = llvm::sys::path::begin(CurDir);
>> +auto CurDirE = llvm::sys::path::end(CurDir);
>> +for (; CurDirIt != CurDirE && *CurDirIt == *FileIt; ++CurDirIt, 
>> ++FileIt)
>> +  

[PATCH] D54557: [analyzer] MoveChecker Pt.2: Restrict the warning to STL objects and locals.

2018-12-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC348210: [analyzer] MoveChecker: Restrict to locals and std:: 
objects. (authored by dergachev, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54557?vs=174475=176491#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D54557

Files:
  lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  test/Analysis/use-after-move.cpp

Index: test/Analysis/use-after-move.cpp
===
--- test/Analysis/use-after-move.cpp
+++ test/Analysis/use-after-move.cpp
@@ -4,6 +4,14 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=alpha.cplusplus.Move -verify %s\
 // RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
 // RUN:  -analyzer-config exploration_strategy=dfs -DDFS=1
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.cplusplus.Move -verify %s\
+// RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
+// RUN:  -analyzer-config exploration_strategy=unexplored_first_queue\
+// RUN:  -analyzer-config alpha.cplusplus.Move:Aggressive=true -DAGGRESSIVE
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.cplusplus.Move -verify %s\
+// RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
+// RUN:  -analyzer-config exploration_strategy=dfs -DDFS=1\
+// RUN:  -analyzer-config alpha.cplusplus.Move:Aggressive=true -DAGGRESSIVE
 
 namespace std {
 
@@ -36,6 +44,13 @@
   b = std::move(c);
 }
 
+template 
+class vector {
+public:
+  vector();
+  void push_back(const T );
+};
+
 } // namespace std
 
 class B {
@@ -71,7 +86,10 @@
 moveconstruct(std::move(*a));
   }
   A(const A ) : i(other.i), d(other.d), b(other.b) {}
-  A(A &) : i(other.i), d(other.d), b(std::move(other.b)) { // expected-note {{'b' became 'moved-from' here}}
+  A(A &) : i(other.i), d(other.d), b(std::move(other.b)) {
+#ifdef AGGRESSIVE
+// expected-note@-2{{'b' became 'moved-from' here}}
+#endif
   }
   A(A &, char *k) {
 moveconstruct(std::move(other));
@@ -424,26 +442,51 @@
 
   void f() {
 A b;
-b = std::move(a); // expected-note {{'a' became 'moved-from' here}}
-a.foo();  // expected-warning {{Method call on a 'moved-from' object}} expected-note {{Method call on a 'moved-from' object 'a'}}
+b = std::move(a);
+a.foo();
+#ifdef AGGRESSIVE
+// expected-note@-3{{'a' became 'moved-from' here}}
+// expected-warning@-3 {{Method call on a 'moved-from' object 'a'}}
+// expected-note@-4{{Method call on a 'moved-from' object 'a'}}
+#endif
 
-b = std::move(static_a); // expected-note {{'static_a' became 'moved-from' here}}
-static_a.foo();  // expected-warning {{Method call on a 'moved-from' object 'static_a'}} expected-note {{Method call on a 'moved-from' object 'static_a'}}
+b = std::move(static_a);
+static_a.foo();
+#ifdef AGGRESSIVE
+// expected-note@-3{{'static_a' became 'moved-from' here}}
+// expected-warning@-3{{Method call on a 'moved-from' object 'static_a'}}
+// expected-note@-4{{Method call on a 'moved-from' object 'static_a'}}
+#endif
   }
 };
 
 void PtrAndArrayTest() {
   A *Ptr = new A(1, 1.5);
   A Arr[10];
-  Arr[2] = std::move(*Ptr); // expected-note {{Became 'moved-from' here}}
-  (*Ptr).foo(); // expected-warning {{Method call on a 'moved-from' object}} expected-note {{Method call on a 'moved-from' object}}
+  Arr[2] = std::move(*Ptr);
+  (*Ptr).foo();
+#ifdef AGGRESSIVE
+  // expected-note@-3{{Became 'moved-from' here}}
+  // expected-warning@-3{{Method call on a 'moved-from' object}}
+  // expected-note@-4{{Method call on a 'moved-from' object}}
+#endif
 
   Ptr = [1];
-  Arr[3] = std::move(Arr[1]); // expected-note {{Became 'moved-from' here}}
-  Ptr->foo(); // expected-warning {{Method call on a 'moved-from' object}} expected-note {{Method call on a 'moved-from' object}}
+  Arr[3] = std::move(Arr[1]);
+  Ptr->foo();
+#ifdef AGGRESSIVE
+  // expected-note@-3{{Became 'moved-from' here}}
+  // expected-warning@-3{{Method call on a 'moved-from' object}}
+  // expected-note@-4{{Method call on a 'moved-from' object}}
+#endif
 
-  Arr[3] = std::move(Arr[2]); // expected-note {{Became 'moved-from' here}}
-  Arr[2].foo();   // expected-warning {{Method call on a 'moved-from' object}} expected-note {{Method call on a 'moved-from' object}}
+  Arr[3] = std::move(Arr[2]);
+  Arr[2].foo();
+#ifdef AGGRESSIVE
+  // expected-note@-3{{Became 'moved-from' here}}
+  // expected-warning@-3{{Method call on a 'moved-from' object}}
+  // expected-note@-4{{Method call on a 'moved-from' object}}
+#endif
 
   Arr[2] = std::move(Arr[3]); // reinitialization
   Arr[2].foo();   // no-warning
@@ -649,13 +692,24 @@
 void subRegionMoveTest() {
   {
 A a;
-B b = std::move(a.b); // expected-note {{'b' became 'moved-from' here}}
-

r348210 - [analyzer] MoveChecker: Restrict to locals and std:: objects.

2018-12-03 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Dec  3 15:06:07 2018
New Revision: 348210

URL: http://llvm.org/viewvc/llvm-project?rev=348210=rev
Log:
[analyzer] MoveChecker: Restrict to locals and std:: objects.

In general case there use-after-move is not a bug. It depends on how the
move-constructor or move-assignment is implemented.

In STL, the convention that applies to most classes is that the move-constructor
(-assignment) leaves an object in a "valid but unspecified" state. Using such
object without resetting it to a known state first is likely a bug. Objects

Local value-type variables are special because due to their automatic lifetime
there is no intention to reuse space. If you want a fresh object, you might
as well make a new variable, no need to move from a variable and than re-use it.
Therefore, it is not always a bug, but it is obviously easy to suppress when it
isn't, and in most cases it indeed is - as there's no valid intention behind
the intentional use of a local after move.

This applies not only to local variables but also to parameter variables,
not only of value type but also of rvalue reference type (but not to lvalue
references).

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
cfe/trunk/test/Analysis/use-after-move.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp?rev=348210=348209=348210=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp Mon Dec  3 15:06:07 
2018
@@ -60,7 +60,16 @@ public:
   const char *NL, const char *Sep) const override;
 
 private:
-  enum MisuseKind {MK_FunCall, MK_Copy, MK_Move};
+  enum MisuseKind { MK_FunCall, MK_Copy, MK_Move };
+
+  struct ObjectKind {
+bool Local : 1; // Is this a local variable or a local rvalue reference?
+bool STL : 1; // Is this an object of a standard type?
+  };
+
+  static ObjectKind classifyObject(const MemRegion *MR,
+   const CXXRecordDecl *RD);
+
   class MovedBugVisitor : public BugReporterVisitor {
   public:
 MovedBugVisitor(const MemRegion *R) : Region(R), Found(false) {}
@@ -81,8 +90,14 @@ private:
 bool Found;
   };
 
+  bool IsAggressive = false;
+
+public:
+  void setAggressiveness(bool Aggressive) { IsAggressive = Aggressive; }
+
+private:
   mutable std::unique_ptr BT;
-  ExplodedNode *reportBug(const MemRegion *Region, const CallEvent ,
+  ExplodedNode *reportBug(const MemRegion *Region, const CXXRecordDecl *RD,
   CheckerContext , MisuseKind MK) const;
   bool isInMoveSafeContext(const LocationContext *LC) const;
   bool isStateResetMethod(const CXXMethodDecl *MethodDec) const;
@@ -116,6 +131,16 @@ static bool isAnyBaseRegionReported(Prog
   return false;
 }
 
+static const MemRegion *unwrapRValueReferenceIndirection(const MemRegion *MR) {
+  if (const auto *SR = dyn_cast_or_null(MR)) {
+SymbolRef Sym = SR->getSymbol();
+if (Sym->getType()->isRValueReferenceType())
+  if (const MemRegion *OriginMR = Sym->getOriginRegion())
+return OriginMR;
+  }
+  return MR;
+}
+
 std::shared_ptr
 MoveChecker::MovedBugVisitor::VisitNode(const ExplodedNode *N,
 BugReporterContext , BugReport &) {
@@ -140,7 +165,8 @@ MoveChecker::MovedBugVisitor::VisitNode(
   Found = true;
 
   std::string ObjectName;
-  if (const auto DecReg = Region->getAs()) {
+  if (const auto DecReg =
+  unwrapRValueReferenceIndirection(Region)->getAs()) {
 const auto *RegionDecl = dyn_cast(DecReg->getDecl());
 ObjectName = RegionDecl->getNameAsString();
   }
@@ -174,7 +200,8 @@ const ExplodedNode *MoveChecker::getMove
 }
 
 ExplodedNode *MoveChecker::reportBug(const MemRegion *Region,
- const CallEvent , CheckerContext ,
+ const CXXRecordDecl *RD,
+ CheckerContext ,
  MisuseKind MK) const {
   if (ExplodedNode *N = C.generateNonFatalErrorNode()) {
 if (!BT)
@@ -244,6 +271,20 @@ void MoveChecker::checkPostCall(const Ca
   if (!ArgRegion)
 return;
 
+  // In non-aggressive mode, only warn on use-after-move of local variables (or
+  // local rvalue references) and of STL objects. The former is possible 
because
+  // local variables (or local rvalue references) are not tempting their user 
to
+  // re-use the storage. The latter is possible because STL objects are known
+  // to end up in a valid but unspecified state after the move and their
+  // state-reset methods are also known, which allows us to predict
+  // precisely when use-after-move is invalid.
+  // In aggressive mode, warn on any use-after-move because 

[PATCH] D54547: PTH-- Remove feature entirely-

2018-12-03 Thread James Y Knight via Phabricator via cfe-commits
jyknight accepted this revision.
jyknight added a comment.
This revision is now accepted and ready to land.

Since you've already submitted a fix to Boost, 
https://github.com/boostorg/build/commit/3385fe2aa699a45e722a1013658f824b6a7c761f,
 I think this is fine to remove.


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

https://reviews.llvm.org/D54547



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


Re: r348154 - Avoid emitting redundant or unusable directories in DIFile metadata entries.

2018-12-03 Thread Adrian Prantl via cfe-commits
No, your failures are Windows-specific (/ vs \), and I haven't fixed them yet. 
Thanks for letting me know!

-- adrian

> On Dec 3, 2018, at 3:06 PM, Galina Kistanova  wrote:
> 
> Adrian, did not see your response, please ignore my email.
> 
> Thanks
> 
> Galina
> 
> On Mon, Dec 3, 2018 at 3:04 PM Galina Kistanova  > wrote:
> Hello Adrian,
> 
> This commit broke tests on couple of our builders:
> 
> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/14371
>  
> 
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast
>  
> 
> 
> . . .
> Failing Tests (2):
> Clang :: CodeGen/debug-prefix-map.c
> Clang :: Modules/module-debuginfo-prefix.m
> 
> The builders were already red and no notifications were sent on this.
> Please have a look?
> 
> Thanks
> 
> Galina
> 
> On Mon, Dec 3, 2018 at 9:58 AM Adrian Prantl via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: adrian
> Date: Mon Dec  3 09:55:27 2018
> New Revision: 348154
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=348154=rev 
> 
> Log:
> Avoid emitting redundant or unusable directories in DIFile metadata entries.
> 
> As discussed on llvm-dev recently, Clang currently emits redundant
> directories in DIFile entries, such as
> 
>   .file  1 "/Volumes/Data/llvm" 
> "/Volumes/Data/llvm/tools/clang/test/CodeGen/debug-info-abspath.c"
> 
> This patch looks at any common prefix between the compilation
> directory and the (absolute) file path and strips the redundant
> part. More importantly it leaves the compilation directory empty if
> the two paths have no common prefix.
> 
> After this patch the above entry is (assuming a compilation dir of 
> "/Volumes/Data/llvm/_build"):
> 
>   .file 1 "/Volumes/Data/llvm" "tools/clang/test/CodeGen/debug-info-abspath.c"
> 
> When building the FileCheck binary with debug info, this patch makes
> the build artifacts ~1kb smaller.
> 
> Differential Revision: https://reviews.llvm.org/D55085 
> 
> 
> Added:
> cfe/trunk/test/CodeGen/debug-info-abspath.c
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CodeGenAction.cpp
> cfe/trunk/test/CodeGen/debug-prefix-map.c
> cfe/trunk/test/Modules/module-debuginfo-prefix.m
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=348154=348153=348154=diff
>  
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Dec  3 09:55:27 2018
> @@ -181,8 +181,7 @@ void CGDebugInfo::setLocation(SourceLoca
>SourceManager  = CGM.getContext().getSourceManager();
>auto *Scope = cast(LexicalBlockStack.back());
>PresumedLoc PCLoc = SM.getPresumedLoc(CurLoc);
> -
> -  if (PCLoc.isInvalid() || Scope->getFilename() == PCLoc.getFilename())
> +  if (PCLoc.isInvalid() || Scope->getFile() == getOrCreateFile(CurLoc))
>  return;
> 
>if (auto *LBF = dyn_cast(Scope)) {
> @@ -410,13 +409,13 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>SourceManager  = CGM.getContext().getSourceManager();
>PresumedLoc PLoc = SM.getPresumedLoc(Loc);
> 
> -  if (PLoc.isInvalid() || StringRef(PLoc.getFilename()).empty())
> +  StringRef FileName = PLoc.getFilename();
> +  if (PLoc.isInvalid() || FileName.empty())
>  // If the location is not valid then use main input file.
>  return getOrCreateMainFile();
> 
>// Cache the results.
> -  const char *fname = PLoc.getFilename();
> -  auto It = DIFileCache.find(fname);
> +  auto It = DIFileCache.find(FileName.data());
> 
>if (It != DIFileCache.end()) {
>  // Verify that the information still exists.
> @@ -431,11 +430,41 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>if (CSKind)
>  CSInfo.emplace(*CSKind, Checksum);
> 
> -  llvm::DIFile *F = DBuilder.createFile(
> -  remapDIPath(PLoc.getFilename()), remapDIPath(getCurrentDirname()), 
> CSInfo,
> -  getSource(SM, SM.getFileID(Loc)));
> +  StringRef Dir;
> +  StringRef File;
> +  std::string RemappedFile = remapDIPath(FileName);
> +  std::string CurDir = remapDIPath(getCurrentDirname());
> +  SmallString<128> DirBuf;
> +  SmallString<128> FileBuf;
> +  if (llvm::sys::path::is_absolute(RemappedFile)) {
> +// Strip the common prefix (if it is more than just "/") from current
> +// directory and FileName for a more space-efficient encoding.
> +auto FileIt = llvm::sys::path::begin(RemappedFile);
> +auto FileE = 

Re: r348154 - Avoid emitting redundant or unusable directories in DIFile metadata entries.

2018-12-03 Thread Galina Kistanova via cfe-commits
Adrian, did not see your response, please ignore my email.

Thanks

Galina

On Mon, Dec 3, 2018 at 3:04 PM Galina Kistanova 
wrote:

> Hello Adrian,
>
> This commit broke tests on couple of our builders:
>
>
> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/14371
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast
>
> . . .
> Failing Tests (2):
> Clang :: CodeGen/debug-prefix-map.c
> Clang :: Modules/module-debuginfo-prefix.m
>
> The builders were already red and no notifications were sent on this.
> Please have a look?
>
> Thanks
>
> Galina
>
> On Mon, Dec 3, 2018 at 9:58 AM Adrian Prantl via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: adrian
>> Date: Mon Dec  3 09:55:27 2018
>> New Revision: 348154
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=348154=rev
>> Log:
>> Avoid emitting redundant or unusable directories in DIFile metadata
>> entries.
>>
>> As discussed on llvm-dev recently, Clang currently emits redundant
>> directories in DIFile entries, such as
>>
>>   .file  1 "/Volumes/Data/llvm"
>> "/Volumes/Data/llvm/tools/clang/test/CodeGen/debug-info-abspath.c"
>>
>> This patch looks at any common prefix between the compilation
>> directory and the (absolute) file path and strips the redundant
>> part. More importantly it leaves the compilation directory empty if
>> the two paths have no common prefix.
>>
>> After this patch the above entry is (assuming a compilation dir of
>> "/Volumes/Data/llvm/_build"):
>>
>>   .file 1 "/Volumes/Data/llvm"
>> "tools/clang/test/CodeGen/debug-info-abspath.c"
>>
>> When building the FileCheck binary with debug info, this patch makes
>> the build artifacts ~1kb smaller.
>>
>> Differential Revision: https://reviews.llvm.org/D55085
>>
>> Added:
>> cfe/trunk/test/CodeGen/debug-info-abspath.c
>> Modified:
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> cfe/trunk/lib/CodeGen/CodeGenAction.cpp
>> cfe/trunk/test/CodeGen/debug-prefix-map.c
>> cfe/trunk/test/Modules/module-debuginfo-prefix.m
>>
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=348154=348153=348154=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Dec  3 09:55:27 2018
>> @@ -181,8 +181,7 @@ void CGDebugInfo::setLocation(SourceLoca
>>SourceManager  = CGM.getContext().getSourceManager();
>>auto *Scope = cast(LexicalBlockStack.back());
>>PresumedLoc PCLoc = SM.getPresumedLoc(CurLoc);
>> -
>> -  if (PCLoc.isInvalid() || Scope->getFilename() == PCLoc.getFilename())
>> +  if (PCLoc.isInvalid() || Scope->getFile() == getOrCreateFile(CurLoc))
>>  return;
>>
>>if (auto *LBF = dyn_cast(Scope)) {
>> @@ -410,13 +409,13 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>>SourceManager  = CGM.getContext().getSourceManager();
>>PresumedLoc PLoc = SM.getPresumedLoc(Loc);
>>
>> -  if (PLoc.isInvalid() || StringRef(PLoc.getFilename()).empty())
>> +  StringRef FileName = PLoc.getFilename();
>> +  if (PLoc.isInvalid() || FileName.empty())
>>  // If the location is not valid then use main input file.
>>  return getOrCreateMainFile();
>>
>>// Cache the results.
>> -  const char *fname = PLoc.getFilename();
>> -  auto It = DIFileCache.find(fname);
>> +  auto It = DIFileCache.find(FileName.data());
>>
>>if (It != DIFileCache.end()) {
>>  // Verify that the information still exists.
>> @@ -431,11 +430,41 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>>if (CSKind)
>>  CSInfo.emplace(*CSKind, Checksum);
>>
>> -  llvm::DIFile *F = DBuilder.createFile(
>> -  remapDIPath(PLoc.getFilename()), remapDIPath(getCurrentDirname()),
>> CSInfo,
>> -  getSource(SM, SM.getFileID(Loc)));
>> +  StringRef Dir;
>> +  StringRef File;
>> +  std::string RemappedFile = remapDIPath(FileName);
>> +  std::string CurDir = remapDIPath(getCurrentDirname());
>> +  SmallString<128> DirBuf;
>> +  SmallString<128> FileBuf;
>> +  if (llvm::sys::path::is_absolute(RemappedFile)) {
>> +// Strip the common prefix (if it is more than just "/") from current
>> +// directory and FileName for a more space-efficient encoding.
>> +auto FileIt = llvm::sys::path::begin(RemappedFile);
>> +auto FileE = llvm::sys::path::end(RemappedFile);
>> +auto CurDirIt = llvm::sys::path::begin(CurDir);
>> +auto CurDirE = llvm::sys::path::end(CurDir);
>> +for (; CurDirIt != CurDirE && *CurDirIt == *FileIt; ++CurDirIt,
>> ++FileIt)
>> +  llvm::sys::path::append(DirBuf, *CurDirIt);
>> +if (std::distance(llvm::sys::path::begin(CurDir), CurDirIt) == 1) {
>> +  // The common prefix only the root; stripping it would cause
>> +  // LLVM diagnostic locations to be more confusing.
>> +  Dir = {};
>> +  File = RemappedFile;
>> +} else {
>> +  for 

Re: r348154 - Avoid emitting redundant or unusable directories in DIFile metadata entries.

2018-12-03 Thread Galina Kistanova via cfe-commits
Hello Adrian,

This commit broke tests on couple of our builders:

http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/14371
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast

. . .
Failing Tests (2):
Clang :: CodeGen/debug-prefix-map.c
Clang :: Modules/module-debuginfo-prefix.m

The builders were already red and no notifications were sent on this.
Please have a look?

Thanks

Galina

On Mon, Dec 3, 2018 at 9:58 AM Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: adrian
> Date: Mon Dec  3 09:55:27 2018
> New Revision: 348154
>
> URL: http://llvm.org/viewvc/llvm-project?rev=348154=rev
> Log:
> Avoid emitting redundant or unusable directories in DIFile metadata
> entries.
>
> As discussed on llvm-dev recently, Clang currently emits redundant
> directories in DIFile entries, such as
>
>   .file  1 "/Volumes/Data/llvm"
> "/Volumes/Data/llvm/tools/clang/test/CodeGen/debug-info-abspath.c"
>
> This patch looks at any common prefix between the compilation
> directory and the (absolute) file path and strips the redundant
> part. More importantly it leaves the compilation directory empty if
> the two paths have no common prefix.
>
> After this patch the above entry is (assuming a compilation dir of
> "/Volumes/Data/llvm/_build"):
>
>   .file 1 "/Volumes/Data/llvm"
> "tools/clang/test/CodeGen/debug-info-abspath.c"
>
> When building the FileCheck binary with debug info, this patch makes
> the build artifacts ~1kb smaller.
>
> Differential Revision: https://reviews.llvm.org/D55085
>
> Added:
> cfe/trunk/test/CodeGen/debug-info-abspath.c
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CodeGenAction.cpp
> cfe/trunk/test/CodeGen/debug-prefix-map.c
> cfe/trunk/test/Modules/module-debuginfo-prefix.m
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=348154=348153=348154=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Dec  3 09:55:27 2018
> @@ -181,8 +181,7 @@ void CGDebugInfo::setLocation(SourceLoca
>SourceManager  = CGM.getContext().getSourceManager();
>auto *Scope = cast(LexicalBlockStack.back());
>PresumedLoc PCLoc = SM.getPresumedLoc(CurLoc);
> -
> -  if (PCLoc.isInvalid() || Scope->getFilename() == PCLoc.getFilename())
> +  if (PCLoc.isInvalid() || Scope->getFile() == getOrCreateFile(CurLoc))
>  return;
>
>if (auto *LBF = dyn_cast(Scope)) {
> @@ -410,13 +409,13 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>SourceManager  = CGM.getContext().getSourceManager();
>PresumedLoc PLoc = SM.getPresumedLoc(Loc);
>
> -  if (PLoc.isInvalid() || StringRef(PLoc.getFilename()).empty())
> +  StringRef FileName = PLoc.getFilename();
> +  if (PLoc.isInvalid() || FileName.empty())
>  // If the location is not valid then use main input file.
>  return getOrCreateMainFile();
>
>// Cache the results.
> -  const char *fname = PLoc.getFilename();
> -  auto It = DIFileCache.find(fname);
> +  auto It = DIFileCache.find(FileName.data());
>
>if (It != DIFileCache.end()) {
>  // Verify that the information still exists.
> @@ -431,11 +430,41 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>if (CSKind)
>  CSInfo.emplace(*CSKind, Checksum);
>
> -  llvm::DIFile *F = DBuilder.createFile(
> -  remapDIPath(PLoc.getFilename()), remapDIPath(getCurrentDirname()),
> CSInfo,
> -  getSource(SM, SM.getFileID(Loc)));
> +  StringRef Dir;
> +  StringRef File;
> +  std::string RemappedFile = remapDIPath(FileName);
> +  std::string CurDir = remapDIPath(getCurrentDirname());
> +  SmallString<128> DirBuf;
> +  SmallString<128> FileBuf;
> +  if (llvm::sys::path::is_absolute(RemappedFile)) {
> +// Strip the common prefix (if it is more than just "/") from current
> +// directory and FileName for a more space-efficient encoding.
> +auto FileIt = llvm::sys::path::begin(RemappedFile);
> +auto FileE = llvm::sys::path::end(RemappedFile);
> +auto CurDirIt = llvm::sys::path::begin(CurDir);
> +auto CurDirE = llvm::sys::path::end(CurDir);
> +for (; CurDirIt != CurDirE && *CurDirIt == *FileIt; ++CurDirIt,
> ++FileIt)
> +  llvm::sys::path::append(DirBuf, *CurDirIt);
> +if (std::distance(llvm::sys::path::begin(CurDir), CurDirIt) == 1) {
> +  // The common prefix only the root; stripping it would cause
> +  // LLVM diagnostic locations to be more confusing.
> +  Dir = {};
> +  File = RemappedFile;
> +} else {
> +  for (; FileIt != FileE; ++FileIt)
> +llvm::sys::path::append(FileBuf, *FileIt);
> +  Dir = DirBuf;
> +  File = FileBuf;
> +}
> +  } else {
> +Dir = CurDir;
> +File = RemappedFile;
> +  }
> +  llvm::DIFile *F =
> +  DBuilder.createFile(File, Dir, 

r348209 - NFC: Add .vscode to .gitignore

2018-12-03 Thread Gor Nishanov via cfe-commits
Author: gornishanov
Date: Mon Dec  3 14:51:07 2018
New Revision: 348209

URL: http://llvm.org/viewvc/llvm-project?rev=348209=rev
Log:
NFC: Add .vscode to .gitignore

Modified:
cfe/trunk/.gitignore

Modified: cfe/trunk/.gitignore
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/.gitignore?rev=348209=348208=348209=diff
==
--- cfe/trunk/.gitignore (original)
+++ cfe/trunk/.gitignore Mon Dec  3 14:51:07 2018
@@ -36,3 +36,8 @@ docs/_build
 docs/analyzer/_build
 # debug info testsuite
 test/debuginfo-tests
+
+# VS2017 and VSCode config files.
+.vscode
+.vs
+


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


[PATCH] D54372: [analyzer] MisusedMovedObject: NFC: Remove dead code after D18860

2018-12-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348208: [analyzer] MoveChecker: NFC: Remove the workaround 
for the zombie symbols bug. (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D54372?vs=173779=176489#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D54372

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  cfe/trunk/test/Analysis/use-after-move.cpp

Index: cfe/trunk/test/Analysis/use-after-move.cpp
===
--- cfe/trunk/test/Analysis/use-after-move.cpp
+++ cfe/trunk/test/Analysis/use-after-move.cpp
@@ -714,3 +714,15 @@
 Empty f = std::move(e); // no-warning
   }
 }
+
+struct MoveOnlyWithDestructor {
+  MoveOnlyWithDestructor();
+  ~MoveOnlyWithDestructor();
+  MoveOnlyWithDestructor(const MoveOnlyWithDestructor ) = delete;
+  MoveOnlyWithDestructor(MoveOnlyWithDestructor &);
+};
+
+MoveOnlyWithDestructor foo() {
+  MoveOnlyWithDestructor m;
+  return m;
+}
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
@@ -43,7 +43,7 @@
 };
 
 class MoveChecker
-: public Checker {
 public:
   void checkEndFunction(const ReturnStmt *RS, CheckerContext ) const;
@@ -217,42 +217,6 @@
   return nullptr;
 }
 
-// Removing the function parameters' MemRegion from the state. This is needed
-// for PODs where the trivial destructor does not even created nor executed.
-void MoveChecker::checkEndFunction(const ReturnStmt *RS,
-   CheckerContext ) const {
-  auto State = C.getState();
-  TrackedRegionMapTy Objects = State->get();
-  if (Objects.isEmpty())
-return;
-
-  auto LC = C.getLocationContext();
-
-  const auto LD = dyn_cast_or_null(LC->getDecl());
-  if (!LD)
-return;
-  llvm::SmallSet InvalidRegions;
-
-  for (auto Param : LD->parameters()) {
-auto Type = Param->getType().getTypePtrOrNull();
-if (!Type)
-  continue;
-if (!Type->isPointerType() && !Type->isReferenceType()) {
-  InvalidRegions.insert(State->getLValue(Param, LC).getAsRegion());
-}
-  }
-
-  if (InvalidRegions.empty())
-return;
-
-  for (const auto  : State->get()) {
-if (InvalidRegions.count(E.first->getBaseRegion()))
-  State = State->remove(E.first);
-  }
-
-  C.addTransition(State);
-}
-
 void MoveChecker::checkPostCall(const CallEvent ,
 CheckerContext ) const {
   const auto *AFC = dyn_cast();
@@ -382,20 +346,19 @@
   const auto IC = dyn_cast();
   if (!IC)
 return;
-  // In case of destructor call we do not track the object anymore.
-  const MemRegion *ThisRegion = IC->getCXXThisVal().getAsRegion();
-  if (!ThisRegion)
+
+  // Calling a destructor on a moved object is fine.
+  if (isa(IC))
 return;
 
-  if (dyn_cast_or_null(Call.getDecl())) {
-State = removeFromState(State, ThisRegion);
-C.addTransition(State);
+  const MemRegion *ThisRegion = IC->getCXXThisVal().getAsRegion();
+  if (!ThisRegion)
 return;
-  }
 
   const auto MethodDecl = dyn_cast_or_null(IC->getDecl());
   if (!MethodDecl)
 return;
+
   // Checking assignment operators.
   bool OperatorEq = MethodDecl->isOverloadedOperator() &&
 MethodDecl->getOverloadedOperator() == OO_Equal;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r348208 - [analyzer] MoveChecker: NFC: Remove the workaround for the "zombie symbols" bug.

2018-12-03 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Dec  3 14:44:16 2018
New Revision: 348208

URL: http://llvm.org/viewvc/llvm-project?rev=348208=rev
Log:
[analyzer] MoveChecker: NFC: Remove the workaround for the "zombie symbols" bug.

The checker had extra code to clean up memory regions that were sticking around
in the checker without ever being cleaned up due to the bug that was fixed in
r347953. Because of that, if a region was moved from, then became dead,
and then reincarnated, there were false positives.

Why regions are even allowed to reincarnate is a separate story. Luckily, this
only happens for local regions that don't produce symbols when loaded from.

No functional change intended. The newly added test demonstrates that even
though no cleanup is necessary upon destructor calls, the early return
cannot be removed. It was not failing before the patch.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
cfe/trunk/test/Analysis/use-after-move.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp?rev=348208=348207=348208=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp Mon Dec  3 14:44:16 
2018
@@ -43,7 +43,7 @@ public:
 };
 
 class MoveChecker
-: public Checker {
 public:
   void checkEndFunction(const ReturnStmt *RS, CheckerContext ) const;
@@ -217,42 +217,6 @@ ExplodedNode *MoveChecker::reportBug(con
   return nullptr;
 }
 
-// Removing the function parameters' MemRegion from the state. This is needed
-// for PODs where the trivial destructor does not even created nor executed.
-void MoveChecker::checkEndFunction(const ReturnStmt *RS,
-   CheckerContext ) const {
-  auto State = C.getState();
-  TrackedRegionMapTy Objects = State->get();
-  if (Objects.isEmpty())
-return;
-
-  auto LC = C.getLocationContext();
-
-  const auto LD = dyn_cast_or_null(LC->getDecl());
-  if (!LD)
-return;
-  llvm::SmallSet InvalidRegions;
-
-  for (auto Param : LD->parameters()) {
-auto Type = Param->getType().getTypePtrOrNull();
-if (!Type)
-  continue;
-if (!Type->isPointerType() && !Type->isReferenceType()) {
-  InvalidRegions.insert(State->getLValue(Param, LC).getAsRegion());
-}
-  }
-
-  if (InvalidRegions.empty())
-return;
-
-  for (const auto  : State->get()) {
-if (InvalidRegions.count(E.first->getBaseRegion()))
-  State = State->remove(E.first);
-  }
-
-  C.addTransition(State);
-}
-
 void MoveChecker::checkPostCall(const CallEvent ,
 CheckerContext ) const {
   const auto *AFC = dyn_cast();
@@ -382,20 +346,19 @@ void MoveChecker::checkPreCall(const Cal
   const auto IC = dyn_cast();
   if (!IC)
 return;
-  // In case of destructor call we do not track the object anymore.
-  const MemRegion *ThisRegion = IC->getCXXThisVal().getAsRegion();
-  if (!ThisRegion)
+
+  // Calling a destructor on a moved object is fine.
+  if (isa(IC))
 return;
 
-  if (dyn_cast_or_null(Call.getDecl())) {
-State = removeFromState(State, ThisRegion);
-C.addTransition(State);
+  const MemRegion *ThisRegion = IC->getCXXThisVal().getAsRegion();
+  if (!ThisRegion)
 return;
-  }
 
   const auto MethodDecl = dyn_cast_or_null(IC->getDecl());
   if (!MethodDecl)
 return;
+
   // Checking assignment operators.
   bool OperatorEq = MethodDecl->isOverloadedOperator() &&
 MethodDecl->getOverloadedOperator() == OO_Equal;

Modified: cfe/trunk/test/Analysis/use-after-move.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/use-after-move.cpp?rev=348208=348207=348208=diff
==
--- cfe/trunk/test/Analysis/use-after-move.cpp (original)
+++ cfe/trunk/test/Analysis/use-after-move.cpp Mon Dec  3 14:44:16 2018
@@ -714,3 +714,15 @@ void checkLoopZombies() {
 Empty f = std::move(e); // no-warning
   }
 }
+
+struct MoveOnlyWithDestructor {
+  MoveOnlyWithDestructor();
+  ~MoveOnlyWithDestructor();
+  MoveOnlyWithDestructor(const MoveOnlyWithDestructor ) = delete;
+  MoveOnlyWithDestructor(MoveOnlyWithDestructor &);
+};
+
+MoveOnlyWithDestructor foo() {
+  MoveOnlyWithDestructor m;
+  return m;
+}


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


[PATCH] D53738: [Fixed Point Arithmetic] Fixed Point Addition

2018-12-03 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan marked an inline comment as done.
leonardchan added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:1304
+RHSTy = ResultTy;
+  }
+

rjmccall wrote:
> ebevhan wrote:
> > rjmccall wrote:
> > > leonardchan wrote:
> > > > rjmccall wrote:
> > > > > ebevhan wrote:
> > > > > > rjmccall wrote:
> > > > > > > Hmm.  So adding a signed integer to an unsigned fixed-point type 
> > > > > > > always converts the integer to unsigned?  That's a little weird, 
> > > > > > > but only because the fixed-point rule seems to be the other way.  
> > > > > > > Anyway, I assume it's not a bug in the spec.
> > > > > > `handleFixedPointConversion` only calculates the result type of the 
> > > > > > expression, not the calculation type. The final result type of the 
> > > > > > operation will be the unsigned fixed-point type, but the 
> > > > > > calculation itself will be done in a signed type with enough 
> > > > > > precision to represent both the signed integer and the unsigned 
> > > > > > fixed-point type. 
> > > > > > 
> > > > > > Though, if the result ends up being negative, the final result is 
> > > > > > undefined unless the type is saturating. I don't think there is a 
> > > > > > test for the saturating case (signed integer + unsigned saturating 
> > > > > > fixed-point) in the SaturatedAddition tests.
> > > > > > `handleFixedPointConversion` only calculates the result type of the 
> > > > > > expression, not the calculation type.
> > > > > 
> > > > > Right, I understand that, but the result type of the expression 
> > > > > obviously impacts the expressive range of the result, since you can 
> > > > > end up with a negative value.
> > > > > 
> > > > > Hmm.  With that said, if the general principle is to perform the 
> > > > > operation with full precision on the original operand values, why are 
> > > > > unsigned fixed-point operands coerced to their corresponding signed 
> > > > > types *before* the operation?  This is precision-limiting if the 
> > > > > unsigned representation doesn't use a padding bit.  That seems like a 
> > > > > bug in the spec.
> > > > > Hmm. With that said, if the general principle is to perform the 
> > > > > operation with full precision on the original operand values, why are 
> > > > > unsigned fixed-point operands coerced to their corresponding signed 
> > > > > types *before* the operation? This is precision-limiting if the 
> > > > > unsigned representation doesn't use a padding bit. That seems like a 
> > > > > bug in the spec.
> > > > 
> > > > Possibly. When the standard mentions converting from signed to unsigned 
> > > > fixed point, the only requirement involved is conservation of magnitude 
> > > > (the number of integral bits excluding the sign)
> > > > 
> > > > ```
> > > > when signed and unsigned fixed-point types are mixed, the unsigned type 
> > > > is converted to the corresponding signed type, and this should go 
> > > > without loss of magnitude
> > > > ```
> > > > 
> > > > This is just speculation, but I'm under the impression that not as much 
> > > > "attention" was given for unsigned types as for signed types since "`In 
> > > > the embedded processor world, support for unsigned fixed-point data 
> > > > types is rare; normally only signed fixed-point data types are 
> > > > supported`", but was kept anyway since unsigned types are used a lot.
> > > > 
> > > > ```
> > > > However, to disallow unsigned fixed-point arithmetic from programming 
> > > > languages (in general, and from C in particular) based on this 
> > > > observation, seems overly restrictive.
> > > > ```
> > > > 
> > > > I also imagine that if the programmer needs more precision, the correct 
> > > > approach would be to cast up to a type with a higher scale. The 
> > > > standard seems to make an effort to expose as much in regards to the 
> > > > underlying fixed point types as possible:
> > > > 
> > > > ```
> > > > it should be possible to write fixed-point algorithms that are 
> > > > independent of the actual fixed-point hardware support. This implies 
> > > > that a programmer (or a running program) should have access to all 
> > > > parameters that define the behavior of the underlying hardware (in 
> > > > other words: even if these parameters are implementation-defined).
> > > > ```
> > > > 
> > > > So the user would at least know that unsigned types may not have the 
> > > > same scale as their corresponding signed types if the hardware handles 
> > > > them with different scales.
> > > > 
> > > > Also added test for signed integer + unsigned saturating fixed point.
> > > As long as we maintain the same typing behavior, does the standard permit 
> > > us to just Do The Right Thing here and do the extended arithmetic with 
> > > the original unsigned operand?  I'm sure there are some cases where we 
> > > would produce a slightly different value than an implementation that does 
> > > the coercion before the operation, but that might 

Re: r348154 - Avoid emitting redundant or unusable directories in DIFile metadata entries.

2018-12-03 Thread Adrian Prantl via cfe-commits
This should be fixed by LLVM r348203. Thanks for your patience!

-- adrian

> On Dec 3, 2018, at 1:27 PM, Adrian Prantl via cfe-commits 
>  wrote:
> 
> I'll take a look right away. Thanks for letting me know!
> 
> -- adrian
> 
>> On Dec 3, 2018, at 1:26 PM, Vlad Tsyrklevich  wrote:
>> 
>> This change appears to have broken a number of compiler-rt coverage tests, 
>> e.g. in this run. The source of the error appears to be that llvm-cov is now 
>> trying to use a relative path that's not relative to the directory it's in, 
>> though I'm not familiar enough with debuginfo/coverage to understand what an 
>> appropriate fix is. I've not yet reverted these changes to give you a chance 
>> to take a look.
>> 
>> On Mon, Dec 3, 2018 at 9:58 AM Adrian Prantl via cfe-commits 
>>  wrote:
>> Author: adrian
>> Date: Mon Dec  3 09:55:27 2018
>> New Revision: 348154
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=348154=rev
>> Log:
>> Avoid emitting redundant or unusable directories in DIFile metadata entries.
>> 
>> As discussed on llvm-dev recently, Clang currently emits redundant
>> directories in DIFile entries, such as
>> 
>>   .file  1 "/Volumes/Data/llvm" 
>> "/Volumes/Data/llvm/tools/clang/test/CodeGen/debug-info-abspath.c"
>> 
>> This patch looks at any common prefix between the compilation
>> directory and the (absolute) file path and strips the redundant
>> part. More importantly it leaves the compilation directory empty if
>> the two paths have no common prefix.
>> 
>> After this patch the above entry is (assuming a compilation dir of 
>> "/Volumes/Data/llvm/_build"):
>> 
>>   .file 1 "/Volumes/Data/llvm" 
>> "tools/clang/test/CodeGen/debug-info-abspath.c"
>> 
>> When building the FileCheck binary with debug info, this patch makes
>> the build artifacts ~1kb smaller.
>> 
>> Differential Revision: https://reviews.llvm.org/D55085
>> 
>> Added:
>> cfe/trunk/test/CodeGen/debug-info-abspath.c
>> Modified:
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> cfe/trunk/lib/CodeGen/CodeGenAction.cpp
>> cfe/trunk/test/CodeGen/debug-prefix-map.c
>> cfe/trunk/test/Modules/module-debuginfo-prefix.m
>> 
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=348154=348153=348154=diff
>> ==
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Dec  3 09:55:27 2018
>> @@ -181,8 +181,7 @@ void CGDebugInfo::setLocation(SourceLoca
>>SourceManager  = CGM.getContext().getSourceManager();
>>auto *Scope = cast(LexicalBlockStack.back());
>>PresumedLoc PCLoc = SM.getPresumedLoc(CurLoc);
>> -
>> -  if (PCLoc.isInvalid() || Scope->getFilename() == PCLoc.getFilename())
>> +  if (PCLoc.isInvalid() || Scope->getFile() == getOrCreateFile(CurLoc))
>>  return;
>> 
>>if (auto *LBF = dyn_cast(Scope)) {
>> @@ -410,13 +409,13 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>>SourceManager  = CGM.getContext().getSourceManager();
>>PresumedLoc PLoc = SM.getPresumedLoc(Loc);
>> 
>> -  if (PLoc.isInvalid() || StringRef(PLoc.getFilename()).empty())
>> +  StringRef FileName = PLoc.getFilename();
>> +  if (PLoc.isInvalid() || FileName.empty())
>>  // If the location is not valid then use main input file.
>>  return getOrCreateMainFile();
>> 
>>// Cache the results.
>> -  const char *fname = PLoc.getFilename();
>> -  auto It = DIFileCache.find(fname);
>> +  auto It = DIFileCache.find(FileName.data());
>> 
>>if (It != DIFileCache.end()) {
>>  // Verify that the information still exists.
>> @@ -431,11 +430,41 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>>if (CSKind)
>>  CSInfo.emplace(*CSKind, Checksum);
>> 
>> -  llvm::DIFile *F = DBuilder.createFile(
>> -  remapDIPath(PLoc.getFilename()), remapDIPath(getCurrentDirname()), 
>> CSInfo,
>> -  getSource(SM, SM.getFileID(Loc)));
>> +  StringRef Dir;
>> +  StringRef File;
>> +  std::string RemappedFile = remapDIPath(FileName);
>> +  std::string CurDir = remapDIPath(getCurrentDirname());
>> +  SmallString<128> DirBuf;
>> +  SmallString<128> FileBuf;
>> +  if (llvm::sys::path::is_absolute(RemappedFile)) {
>> +// Strip the common prefix (if it is more than just "/") from current
>> +// directory and FileName for a more space-efficient encoding.
>> +auto FileIt = llvm::sys::path::begin(RemappedFile);
>> +auto FileE = llvm::sys::path::end(RemappedFile);
>> +auto CurDirIt = llvm::sys::path::begin(CurDir);
>> +auto CurDirE = llvm::sys::path::end(CurDir);
>> +for (; CurDirIt != CurDirE && *CurDirIt == *FileIt; ++CurDirIt, 
>> ++FileIt)
>> +  llvm::sys::path::append(DirBuf, *CurDirIt);
>> +if (std::distance(llvm::sys::path::begin(CurDir), CurDirIt) == 1) {
>> +  // The common prefix only the root; stripping it would cause
>> +  // LLVM diagnostic locations to be more confusing.
>> +  

[clang-tools-extra] r348202 - [Documentation] Fix formatting and wrap up to 80 characters in Clang-tidy readability-uppercase-literal-suffix documentation.

2018-12-03 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Mon Dec  3 14:35:40 2018
New Revision: 348202

URL: http://llvm.org/viewvc/llvm-project?rev=348202=rev
Log:
[Documentation] Fix formatting and wrap up to 80 characters in Clang-tidy 
readability-uppercase-literal-suffix documentation.

Modified:

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst?rev=348202=348201=348202=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst
 Mon Dec  3 14:35:40 2018
@@ -4,14 +4,14 @@ readability-uppercase-literal-suffix
 
 
 `cert-dcl16-c` redirects here as an alias for this check.
-By default, only the suffixes that begin with 'l' ("l", "ll", "lu", "llu",
-but not "u", "ul", "ull") are diagnosed by that alias.
+By default, only the suffixes that begin with ``l`` (``l``, ``ll``, ``lu``,
+``llu``, but not ``u``, ``ul``, ``ull``) are diagnosed by that alias.
 
 `hicpp-uppercase-literal-suffix` redirects here as an alias for this check.
 
 Detects when the integral literal or floating point (decimal or hexadecimal)
-literal has a non-uppercase suffix and provides a fix-it-hint
-with the uppercase suffix.
+literal has a non-uppercase suffix and provides a fix-it hint with the 
uppercase
+suffix.
 
 All valid combinations of suffixes are supported.
 
@@ -25,13 +25,14 @@ All valid combinations of suffixes are s
 
   ...
 
-Optionally, a list of the destination suffixes can be provided.
-When the suffix is found, a case-insensitive lookup in that list is made,
-and if a replacement is found that is different from the current suffix,
-then the diagnostic is issued. This allows for fine-grained control of
-what suffixes to consider and what their replacements should be.
+Optionally, a list of the destination suffixes can be provided. When the suffix
+is found, a case-insensitive lookup in that list is made, and if a replacement
+is found that is different from the current suffix, then the diagnostic is
+issued. This allows for fine-grained control of what suffixes to consider and
+what their replacements should be.
 
 For example, given a list ``L;uL``:
+
 * ``l`` -> ``L``
 * ``L`` will be kept as is.
 * ``ul`` -> ``uL``


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


[PATCH] D54556: [analyzer] MoveChecker Pt.1: Give MisusedMovedObject checker a more consistent name.

2018-12-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC348201: [analyzer] Rename MisusedMovedObjectChecker to 
MoveChecker (authored by dergachev, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54556?vs=174123=176484#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D54556

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
  lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  test/Analysis/MisusedMovedObject.cpp
  test/Analysis/use-after-move.cpp

Index: include/clang/StaticAnalyzer/Checkers/Checkers.td
===
--- include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -303,9 +303,8 @@
   HelpText<"Check for use of iterators of different containers where iterators "
"of the same container are expected">;
 
-def MisusedMovedObjectChecker: Checker<"MisusedMovedObject">,
- HelpText<"Method calls on a moved-from object and copying a moved-from "
-  "object will be reported">;
+def MoveChecker: Checker<"Move">,
+ HelpText<"Find use-after-move bugs in C++">;
 
 def UninitializedObjectChecker: Checker<"UninitializedObject">,
  HelpText<"Reports uninitialized fields after object construction">;
Index: test/Analysis/use-after-move.cpp
===
--- test/Analysis/use-after-move.cpp
+++ test/Analysis/use-after-move.cpp
@@ -0,0 +1,716 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.cplusplus.Move -verify %s\
+// RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
+// RUN:  -analyzer-config exploration_strategy=unexplored_first_queue
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.cplusplus.Move -verify %s\
+// RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
+// RUN:  -analyzer-config exploration_strategy=dfs -DDFS=1
+
+namespace std {
+
+template 
+struct remove_reference;
+
+template 
+struct remove_reference { typedef _Tp type; };
+
+template 
+struct remove_reference<_Tp &> { typedef _Tp type; };
+
+template 
+struct remove_reference<_Tp &&> { typedef _Tp type; };
+
+template 
+typename remove_reference<_Tp>::type &(_Tp &&__t) {
+  return static_cast::type &&>(__t);
+}
+
+template 
+_Tp &(typename remove_reference<_Tp>::type &__t) noexcept {
+  return static_cast<_Tp &&>(__t);
+}
+
+template 
+void swap(T , T ) {
+  T c(std::move(a));
+  a = std::move(b);
+  b = std::move(c);
+}
+
+} // namespace std
+
+class B {
+public:
+  B() = default;
+  B(const B &) = default;
+  B(B &&) = default;
+  B& operator=(const B ) = default;
+  void operator=(B &) {
+return;
+  }
+  void foo() { return; }
+};
+
+class A {
+  int i;
+  double d;
+
+public:
+  B b;
+  A(int ii = 42, double dd = 1.0) : d(dd), i(ii), b(B()) {}
+  void moveconstruct(A &) {
+std::swap(b, other.b);
+std::swap(d, other.d);
+std::swap(i, other.i);
+return;
+  }
+  static A get() {
+A v(12, 13);
+return v;
+  }
+  A(A *a) {
+moveconstruct(std::move(*a));
+  }
+  A(const A ) : i(other.i), d(other.d), b(other.b) {}
+  A(A &) : i(other.i), d(other.d), b(std::move(other.b)) { // expected-note {{'b' became 'moved-from' here}}
+  }
+  A(A &, char *k) {
+moveconstruct(std::move(other));
+  }
+  void operator=(const A ) {
+i = other.i;
+d = other.d;
+b = other.b;
+return;
+  }
+  void operator=(A &) {
+moveconstruct(std::move(other));
+return;
+  }
+  int getI() { return i; }
+  int foo() const;
+  void bar() const;
+  void reset();
+  void destroy();
+  void clear();
+  bool empty() const;
+  bool isEmpty() const;
+  operator bool() const;
+};
+
+int bignum();
+
+void moveInsideFunctionCall(A a) {
+  A b = std::move(a);
+}
+void leftRefCall(A ) {
+  a.foo();
+}
+void rightRefCall(A &) {
+  a.foo();
+}
+void constCopyOrMoveCall(const A a) {
+  a.foo();
+}
+
+void copyOrMoveCall(A a) {
+  a.foo();
+}
+
+void simpleMoveCtorTest() {
+  {
+A a;
+A b = std::move(a); // expected-note {{'a' became 'moved-from' here}}
+a.foo();// expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}}
+  }
+  {
+A a;
+A b = std::move(a); // expected-note {{'a' became 'moved-from' here}}
+b = a;  // expected-warning {{Copying a 'moved-from' object 'a'}} expected-note {{Copying a 'moved-from' object 'a'}}
+  }
+  {
+A a;
+A b = std::move(a); // expected-note {{'a' became 'moved-from' here}}
+b = std::move(a);   // expected-warning {{Moving a 'moved-from' object 'a'}} expected-note {{Moving a 'moved-from' object 'a'}}
+  }
+}
+
+void simpleMoveAssignementTest() {
+  {
+A a;
+A b;
+b = std::move(a); 

[PATCH] D55057: [Headers] Make max_align_t match GCC's implementation.

2018-12-03 Thread James Y Knight via Phabricator via cfe-commits
jyknight added inline comments.



Comment at: lib/Headers/__stddef_max_align_t.h:40
   __attribute__((__aligned__(__alignof__(long double;
+#ifdef __i386__
+  __float128 __clang_max_align_nonce3

EricWF wrote:
> uweigand wrote:
> > jyknight wrote:
> > > uweigand wrote:
> > > > jyknight wrote:
> > > > > Can you fix clang to consistently define `__SIZEOF_FLOAT128__` in 
> > > > > InitPreprocessor alongside the rest of the SIZEOF macros?
> > > > > 
> > > > > And then use that to determine whether to add float128 to the union? 
> > > > > This change, as is, will break on any target which is i386 but 
> > > > > doesn't define __float128, e.g. i386-unknown-unknown.
> > > > > 
> > > > > The only additional target which will be modified with that (that is: 
> > > > > the only other target which has a float128 type, but for which 
> > > > > max_align isn't already 16) is systemz-*-linux.
> > > > > 
> > > > > But I think that's actually indicating a pre-existing bug in the 
> > > > > SystemZ config -- it's configured for a 16-byte long double, with 
> > > > > 8-byte alignment, but the ABI doc seems to call for 16-byte 
> > > > > alignment. +Ulrich for comment on that.
> > > > That's a bug in the ABI doc which we'll fix once we get around to 
> > > > releasing an updated version.
> > > > 
> > > > long double on SystemZ must be 8-byte aligned, which is the maximum 
> > > > alignment of all standard types on Z, and this was chosen because 
> > > > historically the ABI only guarantees an 8-byte stack alignment, so 
> > > > 16-byte aligned standard types would be awkward.
> > > Then perhaps it's a bug that `__alignof__(__float128)` returns 16 with 
> > > `-target systemz-linux`?
> > Huh, really __float128 should not be supported at all on SystemZ.  It's not 
> > supported with GCC either (GCC never provides __float128 on targets where 
> > long double is already IEEE-128).  (GCC does support the new _Float128 on 
> > SystemZ, but that's not yet supported by clang anywhere.)
> > 
> > If it were supported, I agree it should be an alias for long double, and 
> > also have an alignof of 8.
> @jyknight Ack. I'll add `__SIZEOF_FLOAT128__`.
@uweigand : One of those fixes needs to land before this, so that systemz's 
max_align_t doesn't change to 16 in the meantime. I think your preference would 
be for it to be simply removed, right? Looks like the type was originally added 
in https://reviews.llvm.org/D19125 -- possibly in error, since the focus was 
x86_64.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55057



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


r348201 - [analyzer] Rename MisusedMovedObjectChecker to MoveChecker

2018-12-03 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Dec  3 14:32:32 2018
New Revision: 348201

URL: http://llvm.org/viewvc/llvm-project?rev=348201=rev
Log:
[analyzer] Rename MisusedMovedObjectChecker to MoveChecker

This follows the Static Analyzer's tradition to name checkers after
things in which they find bugs, not after bugs they find.

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

Added:
cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  - copied, changed from r348200, 
cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
cfe/trunk/test/Analysis/use-after-move.cpp
  - copied, changed from r348200, 
cfe/trunk/test/Analysis/MisusedMovedObject.cpp
Removed:
cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
cfe/trunk/test/Analysis/MisusedMovedObject.cpp
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=348201=348200=348201=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Mon Dec  3 
14:32:32 2018
@@ -303,9 +303,8 @@ def MismatchedIteratorChecker : Checker<
   HelpText<"Check for use of iterators of different containers where iterators 
"
"of the same container are expected">;
 
-def MisusedMovedObjectChecker: Checker<"MisusedMovedObject">,
- HelpText<"Method calls on a moved-from object and copying a moved-from "
-  "object will be reported">;
+def MoveChecker: Checker<"Move">,
+ HelpText<"Find use-after-move bugs in C++">;
 
 def UninitializedObjectChecker: Checker<"UninitializedObject">,
  HelpText<"Reports uninitialized fields after object construction">;

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=348201=348200=348201=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Mon Dec  3 14:32:32 
2018
@@ -52,7 +52,7 @@ add_clang_library(clangStaticAnalyzerChe
   MallocOverflowSecurityChecker.cpp
   MallocSizeofChecker.cpp
   MmapWriteExecChecker.cpp
-  MisusedMovedObjectChecker.cpp
+  MoveChecker.cpp
   MPI-Checker/MPIBugReporter.cpp
   MPI-Checker/MPIChecker.cpp
   MPI-Checker/MPIFunctionClassifier.cpp

Removed: cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp?rev=348200=auto
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp 
(original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp 
(removed)
@@ -1,519 +0,0 @@
-// MisusedMovedObjectChecker.cpp - Check use of moved-from objects. - C++ 
-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-//
-// This defines checker which checks for potential misuses of a moved-from
-// object. That means method calls on the object or copying it in moved-from
-// state.
-//
-//===--===//
-
-#include "ClangSACheckers.h"
-#include "clang/AST/ExprCXX.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;
-
-namespace {
-
-struct RegionState {
-private:
-  enum Kind { Moved, Reported } K;
-  RegionState(Kind InK) : K(InK) {}
-
-public:
-  bool isReported() const { return K == Reported; }
-  bool isMoved() const { return K == Moved; }
-
-  static RegionState getReported() { return RegionState(Reported); }
-  static RegionState getMoved() { return RegionState(Moved); }
-
-  bool operator==(const RegionState ) const { return K == X.K; }
-  void Profile(llvm::FoldingSetNodeID ) const { ID.AddInteger(K); }
-};
-
-class MisusedMovedObjectChecker
-: public Checker {
-public:
-  void checkEndFunction(const ReturnStmt *RS, CheckerContext ) const;
-  void checkPreCall(const CallEvent , CheckerContext ) const;
-  void checkPostCall(const CallEvent , CheckerContext ) const;
-  void 

[PATCH] D54757: [clang-tidy] new check: bugprone-branch-clone

2018-12-03 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy added a comment.

Macro-generated long switches: I cannot access the check results right now, but 
if I recall correctly, the check assigned these errors to certain lines in the 
`.inc` files. This means that (1) it is not very easy to to suppress them with 
`//NOLINT` comments, but (2) it should be relatively easy to filter them by 
location (ignore all reports coming from `.inc` file).

A quick, tangentially related idea: Would it be useful to implement multiline 
nolint sections (e.g. `//BEGINNOLINT` – `//ENDNOLINT` or something similar)? 
This would be helpful for using clang-tidy on projects that contain some 
automatically generated fragments.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D54757



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


[PATCH] D55190: Move dump of individual comment nodes to NodeDumper

2018-12-03 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 176481.
steveire added a comment.

Move to implementation


Repository:
  rC Clang

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

https://reviews.llvm.org/D55190

Files:
  include/clang/AST/TextNodeDumper.h
  lib/AST/ASTDumper.cpp
  lib/AST/TextNodeDumper.cpp

Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -17,8 +17,29 @@
 
 TextNodeDumper::TextNodeDumper(raw_ostream , bool ShowColors,
const SourceManager *SM,
-   const PrintingPolicy )
-: OS(OS), ShowColors(ShowColors), SM(SM), PrintPolicy(PrintPolicy) {}
+   const PrintingPolicy ,
+   const comments::CommandTraits *Traits)
+: OS(OS), ShowColors(ShowColors), SM(SM), PrintPolicy(PrintPolicy),
+  Traits(Traits) {}
+
+void TextNodeDumper::visit(const comments::Comment *C,
+   const comments::FullComment *FC) {
+  if (!C) {
+ColorScope Color(OS, ShowColors, NullColor);
+OS << "<<>>";
+return;
+  }
+
+  {
+ColorScope Color(OS, ShowColors, CommentColor);
+OS << C->getCommentKindName();
+  }
+  dumpPointer(C);
+  dumpSourceRange(C->getSourceRange());
+
+  ConstCommentVisitor::visit(C, FC);
+}
 
 void TextNodeDumper::dumpPointer(const void *Ptr) {
   ColorScope Color(OS, ShowColors, AddressColor);
@@ -139,3 +160,126 @@
   dumpPointer(Temporary);
   OS << ")";
 }
+
+const char *TextNodeDumper::getCommandName(unsigned CommandID) {
+  if (Traits)
+return Traits->getCommandInfo(CommandID)->Name;
+  const comments::CommandInfo *Info =
+  comments::CommandTraits::getBuiltinCommandInfo(CommandID);
+  if (Info)
+return Info->Name;
+  return "";
+}
+
+void TextNodeDumper::visitTextComment(const comments::TextComment *C,
+  const comments::FullComment *) {
+  OS << " Text=\"" << C->getText() << "\"";
+}
+
+void TextNodeDumper::visitInlineCommandComment(
+const comments::InlineCommandComment *C, const comments::FullComment *) {
+  OS << " Name=\"" << getCommandName(C->getCommandID()) << "\"";
+  switch (C->getRenderKind()) {
+  case comments::InlineCommandComment::RenderNormal:
+OS << " RenderNormal";
+break;
+  case comments::InlineCommandComment::RenderBold:
+OS << " RenderBold";
+break;
+  case comments::InlineCommandComment::RenderMonospaced:
+OS << " RenderMonospaced";
+break;
+  case comments::InlineCommandComment::RenderEmphasized:
+OS << " RenderEmphasized";
+break;
+  }
+
+  for (unsigned i = 0, e = C->getNumArgs(); i != e; ++i)
+OS << " Arg[" << i << "]=\"" << C->getArgText(i) << "\"";
+}
+
+void TextNodeDumper::visitHTMLStartTagComment(
+const comments::HTMLStartTagComment *C, const comments::FullComment *) {
+  OS << " Name=\"" << C->getTagName() << "\"";
+  if (C->getNumAttrs() != 0) {
+OS << " Attrs: ";
+for (unsigned i = 0, e = C->getNumAttrs(); i != e; ++i) {
+  const comments::HTMLStartTagComment::Attribute  = C->getAttr(i);
+  OS << " \"" << Attr.Name << "=\"" << Attr.Value << "\"";
+}
+  }
+  if (C->isSelfClosing())
+OS << " SelfClosing";
+}
+
+void TextNodeDumper::visitHTMLEndTagComment(
+const comments::HTMLEndTagComment *C, const comments::FullComment *) {
+  OS << " Name=\"" << C->getTagName() << "\"";
+}
+
+void TextNodeDumper::visitBlockCommandComment(
+const comments::BlockCommandComment *C, const comments::FullComment *) {
+  OS << " Name=\"" << getCommandName(C->getCommandID()) << "\"";
+  for (unsigned i = 0, e = C->getNumArgs(); i != e; ++i)
+OS << " Arg[" << i << "]=\"" << C->getArgText(i) << "\"";
+}
+
+void TextNodeDumper::visitParamCommandComment(
+const comments::ParamCommandComment *C, const comments::FullComment *FC) {
+  OS << " "
+ << comments::ParamCommandComment::getDirectionAsString(C->getDirection());
+
+  if (C->isDirectionExplicit())
+OS << " explicitly";
+  else
+OS << " implicitly";
+
+  if (C->hasParamName()) {
+if (C->isParamIndexValid())
+  OS << " Param=\"" << C->getParamName(FC) << "\"";
+else
+  OS << " Param=\"" << C->getParamNameAsWritten() << "\"";
+  }
+
+  if (C->isParamIndexValid() && !C->isVarArgParam())
+OS << " ParamIndex=" << C->getParamIndex();
+}
+
+void TextNodeDumper::visitTParamCommandComment(
+const comments::TParamCommandComment *C, const comments::FullComment *FC) {
+  if (C->hasParamName()) {
+if (C->isPositionValid())
+  OS << " Param=\"" << C->getParamName(FC) << "\"";
+else
+  OS << " Param=\"" << C->getParamNameAsWritten() << "\"";
+  }
+
+  if (C->isPositionValid()) {
+OS << " Position=<";
+for (unsigned i = 0, e = C->getDepth(); i != e; ++i) {
+  OS << C->getIndex(i);
+  if (i != e - 1)
+OS << ", ";
+}
+OS << ">";
+  }
+}
+
+void 

r348200 - [analyzer] Dump stable identifiers for objects under construction.

2018-12-03 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Dec  3 14:23:21 2018
New Revision: 348200

URL: http://llvm.org/viewvc/llvm-project?rev=348200=rev
Log:
[analyzer] Dump stable identifiers for objects under construction.

This continues the work that was started in r342313, which now gets applied to
object-under-construction tracking in C++. Makes it possible to debug
temporaries by dumping exploded graphs again.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/Analysis/dump_egraph.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=348200=348199=348200=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Mon Dec  3 14:23:21 2018
@@ -138,9 +138,17 @@ public:
   const ConstructionContextItem () const { return Impl.first; }
   const LocationContext *getLocationContext() const { return Impl.second; }
 
+  ASTContext () const {
+return getLocationContext()->getDecl()->getASTContext();
+  }
+
   void print(llvm::raw_ostream , PrinterHelper *Helper, PrintingPolicy ) 
{
-OS << '(' << getLocationContext() << ',' << getAnyASTNodePtr() << ','
-   << getItem().getKindAsString();
+OS << "(LC" << getLocationContext()->getID() << ',';
+if (const Stmt *S = getItem().getStmtOrNull())
+  OS << 'S' << S->getID(getASTContext());
+else
+  OS << 'I' << getItem().getCXXCtorInitializer()->getID(getASTContext());
+OS << ',' << getItem().getKindAsString();
 if (getItem().getKind() == ConstructionContextItem::ArgumentKind)
   OS << " #" << getItem().getIndex();
 OS << ") ";

Modified: cfe/trunk/test/Analysis/dump_egraph.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dump_egraph.cpp?rev=348200=348199=348200=diff
==
--- cfe/trunk/test/Analysis/dump_egraph.cpp (original)
+++ cfe/trunk/test/Analysis/dump_egraph.cpp Mon Dec  3 14:23:21 2018
@@ -2,14 +2,21 @@
 // RUN: cat %t.dot | FileCheck %s
 // REQUIRES: asserts
 
-
 struct S {
   ~S();
 };
 
+struct T {
+  S s;
+  T() : s() {}
+};
+
 void foo() {
   // Test that dumping symbols conjured on null statements doesn't crash.
-  S s;
+  T t;
 }
 
-// CHECK: conj_$0\{int, LC1, no stmt, #1\}
+// CHECK: (LC1,S{{[0-9]*}},construct into local variable) T t;\n : 
+// CHECK: (LC2,I{{[0-9]*}},construct into member variable) s : \>s
+// CHECK: conj_$5\{int, LC3, no stmt, #1\}
+


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


[PATCH] D54459: [analyzer] Dump reproducible identifiers for objects under construction.

2018-12-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC348200: [analyzer] Dump stable identifiers for objects under 
construction. (authored by dergachev, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D54459

Files:
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Analysis/dump_egraph.cpp


Index: test/Analysis/dump_egraph.cpp
===
--- test/Analysis/dump_egraph.cpp
+++ test/Analysis/dump_egraph.cpp
@@ -2,14 +2,21 @@
 // RUN: cat %t.dot | FileCheck %s
 // REQUIRES: asserts
 
-
 struct S {
   ~S();
 };
 
+struct T {
+  S s;
+  T() : s() {}
+};
+
 void foo() {
   // Test that dumping symbols conjured on null statements doesn't crash.
-  S s;
+  T t;
 }
 
-// CHECK: conj_$0\{int, LC1, no stmt, #1\}
+// CHECK: (LC1,S{{[0-9]*}},construct into local variable) T t;\n : 
+// CHECK: (LC2,I{{[0-9]*}},construct into member variable) s : \>s
+// CHECK: conj_$5\{int, LC3, no stmt, #1\}
+
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -138,9 +138,17 @@
   const ConstructionContextItem () const { return Impl.first; }
   const LocationContext *getLocationContext() const { return Impl.second; }
 
+  ASTContext () const {
+return getLocationContext()->getDecl()->getASTContext();
+  }
+
   void print(llvm::raw_ostream , PrinterHelper *Helper, PrintingPolicy ) 
{
-OS << '(' << getLocationContext() << ',' << getAnyASTNodePtr() << ','
-   << getItem().getKindAsString();
+OS << "(LC" << getLocationContext()->getID() << ',';
+if (const Stmt *S = getItem().getStmtOrNull())
+  OS << 'S' << S->getID(getASTContext());
+else
+  OS << 'I' << getItem().getCXXCtorInitializer()->getID(getASTContext());
+OS << ',' << getItem().getKindAsString();
 if (getItem().getKind() == ConstructionContextItem::ArgumentKind)
   OS << " #" << getItem().getIndex();
 OS << ") ";


Index: test/Analysis/dump_egraph.cpp
===
--- test/Analysis/dump_egraph.cpp
+++ test/Analysis/dump_egraph.cpp
@@ -2,14 +2,21 @@
 // RUN: cat %t.dot | FileCheck %s
 // REQUIRES: asserts
 
-
 struct S {
   ~S();
 };
 
+struct T {
+  S s;
+  T() : s() {}
+};
+
 void foo() {
   // Test that dumping symbols conjured on null statements doesn't crash.
-  S s;
+  T t;
 }
 
-// CHECK: conj_$0\{int, LC1, no stmt, #1\}
+// CHECK: (LC1,S{{[0-9]*}},construct into local variable) T t;\n : 
+// CHECK: (LC2,I{{[0-9]*}},construct into member variable) s : \>s
+// CHECK: conj_$5\{int, LC3, no stmt, #1\}
+
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -138,9 +138,17 @@
   const ConstructionContextItem () const { return Impl.first; }
   const LocationContext *getLocationContext() const { return Impl.second; }
 
+  ASTContext () const {
+return getLocationContext()->getDecl()->getASTContext();
+  }
+
   void print(llvm::raw_ostream , PrinterHelper *Helper, PrintingPolicy ) {
-OS << '(' << getLocationContext() << ',' << getAnyASTNodePtr() << ','
-   << getItem().getKindAsString();
+OS << "(LC" << getLocationContext()->getID() << ',';
+if (const Stmt *S = getItem().getStmtOrNull())
+  OS << 'S' << S->getID(getASTContext());
+else
+  OS << 'I' << getItem().getCXXCtorInitializer()->getID(getASTContext());
+OS << ',' << getItem().getKindAsString();
 if (getItem().getKind() == ConstructionContextItem::ArgumentKind)
   OS << " #" << getItem().getIndex();
 OS << ") ";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54488: [AST] [analyzer] NFC: Reuse code in stable ID dumping methods.

2018-12-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348199: [AST] [analyzer] NFC: Reuse code in stable ID 
dumping methods. (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D54488?vs=173900=176479#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D54488

Files:
  cfe/trunk/lib/AST/DeclBase.cpp
  cfe/trunk/lib/AST/DeclCXX.cpp
  cfe/trunk/lib/AST/Stmt.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp


Index: cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -70,10 +70,7 @@
 }
 
 int64_t ProgramState::getID() const {
-  Optional Out = getStateManager().Alloc.identifyObject(this);
-  assert(Out && "Wrong allocator used");
-  assert(*Out % alignof(ProgramState) == 0 && "Wrong alignment information");
-  return *Out / alignof(ProgramState);
+  return 
getStateManager().Alloc.identifyKnownAlignedObject(this);
 }
 
 ProgramStateManager::ProgramStateManager(ASTContext ,
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
@@ -284,10 +284,7 @@
 }
 
 int64_t ExplodedNode::getID(ExplodedGraph *G) const {
-  Optional Out = G->getAllocator().identifyObject(this);
-  assert(Out && "Wrong allocator used");
-  assert(*Out % alignof(ExplodedNode) == 0 && "Wrong alignment information");
-  return *Out / alignof(ExplodedNode);
+  return G->getAllocator().identifyKnownAlignedObject(this);
 }
 
 bool ExplodedNode::isTrivial() const {
Index: cfe/trunk/lib/AST/DeclCXX.cpp
===
--- cfe/trunk/lib/AST/DeclCXX.cpp
+++ cfe/trunk/lib/AST/DeclCXX.cpp
@@ -2247,11 +2247,8 @@
   IsDelegating(true), IsVirtual(false), IsWritten(false), SourceOrder(0) {}
 
 int64_t CXXCtorInitializer::getID(const ASTContext ) const {
-  Optional Out = Context.getAllocator().identifyObject(this);
-  assert(Out && "Wrong allocator used");
-  assert(*Out % alignof(CXXCtorInitializer) == 0 &&
- "Wrong alignment information");
-  return *Out / alignof(CXXCtorInitializer);
+  return Context.getAllocator()
+.identifyKnownAlignedObject(this);
 }
 
 TypeLoc CXXCtorInitializer::getBaseClassLoc() const {
Index: cfe/trunk/lib/AST/DeclBase.cpp
===
--- cfe/trunk/lib/AST/DeclBase.cpp
+++ cfe/trunk/lib/AST/DeclBase.cpp
@@ -955,10 +955,7 @@
 static Decl::Kind getKind(const DeclContext *DC) { return DC->getDeclKind(); }
 
 int64_t Decl::getID() const {
-  Optional Out = getASTContext().getAllocator().identifyObject(this);
-  assert(Out && "Wrong allocator used");
-  assert(*Out % alignof(Decl) == 0 && "Wrong alignment information");
-  return *Out / alignof(Decl);
+  return getASTContext().getAllocator().identifyKnownAlignedObject(this);
 }
 
 const FunctionType *Decl::getFunctionType(bool BlocksToo) const {
Index: cfe/trunk/lib/AST/Stmt.cpp
===
--- cfe/trunk/lib/AST/Stmt.cpp
+++ cfe/trunk/lib/AST/Stmt.cpp
@@ -303,10 +303,7 @@
 }
 
 int64_t Stmt::getID(const ASTContext ) const {
-  Optional Out = Context.getAllocator().identifyObject(this);
-  assert(Out && "Wrong allocator used");
-  assert(*Out % alignof(Stmt) == 0 && "Wrong alignment information");
-  return *Out / alignof(Stmt);
+  return Context.getAllocator().identifyKnownAlignedObject(this);
 }
 
 CompoundStmt::CompoundStmt(ArrayRef Stmts, SourceLocation LB,


Index: cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -70,10 +70,7 @@
 }
 
 int64_t ProgramState::getID() const {
-  Optional Out = getStateManager().Alloc.identifyObject(this);
-  assert(Out && "Wrong allocator used");
-  assert(*Out % alignof(ProgramState) == 0 && "Wrong alignment information");
-  return *Out / alignof(ProgramState);
+  return getStateManager().Alloc.identifyKnownAlignedObject(this);
 }
 
 ProgramStateManager::ProgramStateManager(ASTContext ,
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
@@ -284,10 +284,7 @@
 }
 
 int64_t ExplodedNode::getID(ExplodedGraph *G) const {
-  Optional Out = G->getAllocator().identifyObject(this);
-  assert(Out && 

r348199 - [AST] [analyzer] NFC: Reuse code in stable ID dumping methods.

2018-12-03 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Dec  3 14:19:05 2018
New Revision: 348199

URL: http://llvm.org/viewvc/llvm-project?rev=348199=rev
Log:
[AST] [analyzer] NFC: Reuse code in stable ID dumping methods.

Use the new fancy method introduced in r348197 to simplify some code.

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

Modified:
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/Stmt.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=348199=348198=348199=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Mon Dec  3 14:19:05 2018
@@ -955,10 +955,7 @@ static Decl::Kind getKind(const Decl *D)
 static Decl::Kind getKind(const DeclContext *DC) { return DC->getDeclKind(); }
 
 int64_t Decl::getID() const {
-  Optional Out = getASTContext().getAllocator().identifyObject(this);
-  assert(Out && "Wrong allocator used");
-  assert(*Out % alignof(Decl) == 0 && "Wrong alignment information");
-  return *Out / alignof(Decl);
+  return getASTContext().getAllocator().identifyKnownAlignedObject(this);
 }
 
 const FunctionType *Decl::getFunctionType(bool BlocksToo) const {

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=348199=348198=348199=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Mon Dec  3 14:19:05 2018
@@ -2247,11 +2247,8 @@ CXXCtorInitializer::CXXCtorInitializer(A
   IsDelegating(true), IsVirtual(false), IsWritten(false), SourceOrder(0) {}
 
 int64_t CXXCtorInitializer::getID(const ASTContext ) const {
-  Optional Out = Context.getAllocator().identifyObject(this);
-  assert(Out && "Wrong allocator used");
-  assert(*Out % alignof(CXXCtorInitializer) == 0 &&
- "Wrong alignment information");
-  return *Out / alignof(CXXCtorInitializer);
+  return Context.getAllocator()
+.identifyKnownAlignedObject(this);
 }
 
 TypeLoc CXXCtorInitializer::getBaseClassLoc() const {

Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=348199=348198=348199=diff
==
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Mon Dec  3 14:19:05 2018
@@ -303,10 +303,7 @@ SourceLocation Stmt::getEndLoc() const {
 }
 
 int64_t Stmt::getID(const ASTContext ) const {
-  Optional Out = Context.getAllocator().identifyObject(this);
-  assert(Out && "Wrong allocator used");
-  assert(*Out % alignof(Stmt) == 0 && "Wrong alignment information");
-  return *Out / alignof(Stmt);
+  return Context.getAllocator().identifyKnownAlignedObject(this);
 }
 
 CompoundStmt::CompoundStmt(ArrayRef Stmts, SourceLocation LB,

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp?rev=348199=348198=348199=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp Mon Dec  3 14:19:05 2018
@@ -284,10 +284,7 @@ ExplodedNode * const *ExplodedNode::Node
 }
 
 int64_t ExplodedNode::getID(ExplodedGraph *G) const {
-  Optional Out = G->getAllocator().identifyObject(this);
-  assert(Out && "Wrong allocator used");
-  assert(*Out % alignof(ExplodedNode) == 0 && "Wrong alignment information");
-  return *Out / alignof(ExplodedNode);
+  return G->getAllocator().identifyKnownAlignedObject(this);
 }
 
 bool ExplodedNode::isTrivial() const {

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp?rev=348199=348198=348199=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp Mon Dec  3 14:19:05 2018
@@ -70,10 +70,7 @@ ProgramState::~ProgramState() {
 }
 
 int64_t ProgramState::getID() const {
-  Optional Out = getStateManager().Alloc.identifyObject(this);
-  assert(Out && "Wrong allocator used");
-  assert(*Out % alignof(ProgramState) == 0 && "Wrong alignment information");
-  return *Out / alignof(ProgramState);
+  return 
getStateManager().Alloc.identifyKnownAlignedObject(this);
 }
 
 ProgramStateManager::ProgramStateManager(ASTContext ,


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


[PATCH] D55189: Extract TextNodeDumper class

2018-12-03 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 176478.
steveire added a comment.
Herald added a subscriber: mgorny.

Move implementation to cpp file


Repository:
  rC Clang

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

https://reviews.llvm.org/D55189

Files:
  include/clang/AST/TextNodeDumper.h
  lib/AST/ASTDumper.cpp
  lib/AST/CMakeLists.txt
  lib/AST/TextNodeDumper.cpp

Index: lib/AST/TextNodeDumper.cpp
===
--- /dev/null
+++ lib/AST/TextNodeDumper.cpp
@@ -0,0 +1,141 @@
+//===--- TextNodeDumper.cpp - Printing of AST nodes ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file implements AST dumping of components of individual AST nodes.
+//
+//===--===//
+
+#include "clang/AST/TextNodeDumper.h"
+
+using namespace clang;
+
+TextNodeDumper::TextNodeDumper(raw_ostream , bool ShowColors,
+   const SourceManager *SM,
+   const PrintingPolicy )
+: OS(OS), ShowColors(ShowColors), SM(SM), PrintPolicy(PrintPolicy) {}
+
+void TextNodeDumper::dumpPointer(const void *Ptr) {
+  ColorScope Color(OS, ShowColors, AddressColor);
+  OS << ' ' << Ptr;
+}
+
+void TextNodeDumper::dumpLocation(SourceLocation Loc) {
+  if (!SM)
+return;
+
+  ColorScope Color(OS, ShowColors, LocationColor);
+  SourceLocation SpellingLoc = SM->getSpellingLoc(Loc);
+
+  // The general format we print out is filename:line:col, but we drop pieces
+  // that haven't changed since the last loc printed.
+  PresumedLoc PLoc = SM->getPresumedLoc(SpellingLoc);
+
+  if (PLoc.isInvalid()) {
+OS << "";
+return;
+  }
+
+  if (strcmp(PLoc.getFilename(), LastLocFilename) != 0) {
+OS << PLoc.getFilename() << ':' << PLoc.getLine() << ':'
+   << PLoc.getColumn();
+LastLocFilename = PLoc.getFilename();
+LastLocLine = PLoc.getLine();
+  } else if (PLoc.getLine() != LastLocLine) {
+OS << "line" << ':' << PLoc.getLine() << ':' << PLoc.getColumn();
+LastLocLine = PLoc.getLine();
+  } else {
+OS << "col" << ':' << PLoc.getColumn();
+  }
+}
+
+void TextNodeDumper::dumpSourceRange(SourceRange R) {
+  // Can't translate locations if a SourceManager isn't available.
+  if (!SM)
+return;
+
+  OS << " <";
+  dumpLocation(R.getBegin());
+  if (R.getBegin() != R.getEnd()) {
+OS << ", ";
+dumpLocation(R.getEnd());
+  }
+  OS << ">";
+
+  // 
+}
+
+void TextNodeDumper::dumpBareType(QualType T, bool Desugar) {
+  ColorScope Color(OS, ShowColors, TypeColor);
+
+  SplitQualType T_split = T.split();
+  OS << "'" << QualType::getAsString(T_split, PrintPolicy) << "'";
+
+  if (Desugar && !T.isNull()) {
+// If the type is sugared, also dump a (shallow) desugared type.
+SplitQualType D_split = T.getSplitDesugaredType();
+if (T_split != D_split)
+  OS << ":'" << QualType::getAsString(D_split, PrintPolicy) << "'";
+  }
+}
+
+void TextNodeDumper::dumpType(QualType T) {
+  OS << ' ';
+  dumpBareType(T);
+}
+
+void TextNodeDumper::dumpBareDeclRef(const Decl *D) {
+  if (!D) {
+ColorScope Color(OS, ShowColors, NullColor);
+OS << "<<>>";
+return;
+  }
+
+  {
+ColorScope Color(OS, ShowColors, DeclKindNameColor);
+OS << D->getDeclKindName();
+  }
+  dumpPointer(D);
+
+  if (const NamedDecl *ND = dyn_cast(D)) {
+ColorScope Color(OS, ShowColors, DeclNameColor);
+OS << " '" << ND->getDeclName() << '\'';
+  }
+
+  if (const ValueDecl *VD = dyn_cast(D))
+dumpType(VD->getType());
+}
+
+void TextNodeDumper::dumpName(const NamedDecl *ND) {
+  if (ND->getDeclName()) {
+ColorScope Color(OS, ShowColors, DeclNameColor);
+OS << ' ' << ND->getNameAsString();
+  }
+}
+
+void TextNodeDumper::dumpAccessSpecifier(AccessSpecifier AS) {
+  switch (AS) {
+  case AS_none:
+break;
+  case AS_public:
+OS << "public";
+break;
+  case AS_protected:
+OS << "protected";
+break;
+  case AS_private:
+OS << "private";
+break;
+  }
+}
+
+void TextNodeDumper::dumpCXXTemporary(const CXXTemporary *Temporary) {
+  OS << "(CXXTemporary";
+  dumpPointer(Temporary);
+  OS << ")";
+}
Index: lib/AST/CMakeLists.txt
===
--- lib/AST/CMakeLists.txt
+++ lib/AST/CMakeLists.txt
@@ -69,6 +69,7 @@
   StmtViz.cpp
   TemplateBase.cpp
   TemplateName.cpp
+  TextNodeDumper.cpp
   Type.cpp
   TypeLoc.cpp
   TypePrinter.cpp
Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -23,6 +23,7 @@
 #include "clang/AST/DeclVisitor.h"
 #include "clang/AST/LocInfoType.h"
 #include "clang/AST/StmtVisitor.h"

[PATCH] D54457: [AST] Generate unique identifiers for CXXCtorInitializer objects.

2018-12-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348198: [AST] Generate unique identifiers for 
CXXCtorInitializer objects. (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D54457?vs=176470=176477#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D54457

Files:
  cfe/trunk/include/clang/AST/DeclCXX.h
  cfe/trunk/lib/AST/DeclCXX.cpp


Index: cfe/trunk/include/clang/AST/DeclCXX.h
===
--- cfe/trunk/include/clang/AST/DeclCXX.h
+++ cfe/trunk/include/clang/AST/DeclCXX.h
@@ -2315,6 +2315,9 @@
   CXXCtorInitializer(ASTContext , TypeSourceInfo *TInfo,
  SourceLocation L, Expr *Init, SourceLocation R);
 
+  /// \return Unique reproducible object identifier.
+  int64_t getID(const ASTContext ) const;
+
   /// Determine whether this initializer is initializing a base class.
   bool isBaseInitializer() const {
 return Initializee.is() && !IsDelegating;
Index: cfe/trunk/lib/AST/DeclCXX.cpp
===
--- cfe/trunk/lib/AST/DeclCXX.cpp
+++ cfe/trunk/lib/AST/DeclCXX.cpp
@@ -2246,6 +2246,14 @@
 : Initializee(TInfo), Init(Init), LParenLoc(L), RParenLoc(R),
   IsDelegating(true), IsVirtual(false), IsWritten(false), SourceOrder(0) {}
 
+int64_t CXXCtorInitializer::getID(const ASTContext ) const {
+  Optional Out = Context.getAllocator().identifyObject(this);
+  assert(Out && "Wrong allocator used");
+  assert(*Out % alignof(CXXCtorInitializer) == 0 &&
+ "Wrong alignment information");
+  return *Out / alignof(CXXCtorInitializer);
+}
+
 TypeLoc CXXCtorInitializer::getBaseClassLoc() const {
   if (isBaseInitializer())
 return Initializee.get()->getTypeLoc();


Index: cfe/trunk/include/clang/AST/DeclCXX.h
===
--- cfe/trunk/include/clang/AST/DeclCXX.h
+++ cfe/trunk/include/clang/AST/DeclCXX.h
@@ -2315,6 +2315,9 @@
   CXXCtorInitializer(ASTContext , TypeSourceInfo *TInfo,
  SourceLocation L, Expr *Init, SourceLocation R);
 
+  /// \return Unique reproducible object identifier.
+  int64_t getID(const ASTContext ) const;
+
   /// Determine whether this initializer is initializing a base class.
   bool isBaseInitializer() const {
 return Initializee.is() && !IsDelegating;
Index: cfe/trunk/lib/AST/DeclCXX.cpp
===
--- cfe/trunk/lib/AST/DeclCXX.cpp
+++ cfe/trunk/lib/AST/DeclCXX.cpp
@@ -2246,6 +2246,14 @@
 : Initializee(TInfo), Init(Init), LParenLoc(L), RParenLoc(R),
   IsDelegating(true), IsVirtual(false), IsWritten(false), SourceOrder(0) {}
 
+int64_t CXXCtorInitializer::getID(const ASTContext ) const {
+  Optional Out = Context.getAllocator().identifyObject(this);
+  assert(Out && "Wrong allocator used");
+  assert(*Out % alignof(CXXCtorInitializer) == 0 &&
+ "Wrong alignment information");
+  return *Out / alignof(CXXCtorInitializer);
+}
+
 TypeLoc CXXCtorInitializer::getBaseClassLoc() const {
   if (isBaseInitializer())
 return Initializee.get()->getTypeLoc();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r348198 - [AST] Generate unique identifiers for CXXCtorInitializer objects.

2018-12-03 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Dec  3 14:15:34 2018
New Revision: 348198

URL: http://llvm.org/viewvc/llvm-project?rev=348198=rev
Log:
[AST] Generate unique identifiers for CXXCtorInitializer objects.

This continues the work started in r342309 and r342315 to provide identifiers
to AST objects that are shorter and easier to read and remember than pointers.

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

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/DeclCXX.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=348198=348197=348198=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Mon Dec  3 14:15:34 2018
@@ -2315,6 +2315,9 @@ public:
   CXXCtorInitializer(ASTContext , TypeSourceInfo *TInfo,
  SourceLocation L, Expr *Init, SourceLocation R);
 
+  /// \return Unique reproducible object identifier.
+  int64_t getID(const ASTContext ) const;
+
   /// Determine whether this initializer is initializing a base class.
   bool isBaseInitializer() const {
 return Initializee.is() && !IsDelegating;

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=348198=348197=348198=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Mon Dec  3 14:15:34 2018
@@ -2246,6 +2246,14 @@ CXXCtorInitializer::CXXCtorInitializer(A
 : Initializee(TInfo), Init(Init), LParenLoc(L), RParenLoc(R),
   IsDelegating(true), IsVirtual(false), IsWritten(false), SourceOrder(0) {}
 
+int64_t CXXCtorInitializer::getID(const ASTContext ) const {
+  Optional Out = Context.getAllocator().identifyObject(this);
+  assert(Out && "Wrong allocator used");
+  assert(*Out % alignof(CXXCtorInitializer) == 0 &&
+ "Wrong alignment information");
+  return *Out / alignof(CXXCtorInitializer);
+}
+
 TypeLoc CXXCtorInitializer::getBaseClassLoc() const {
   if (isBaseInitializer())
 return Initializee.get()->getTypeLoc();


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


[PATCH] D55016: Correctly support -shared-libgcc.

2018-12-03 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

LGTM.

-eric


Repository:
  rC Clang

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

https://reviews.llvm.org/D55016



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


Re: r348131 - [AST] Fix an uninitialized bug in the bits of FunctionDecl

2018-12-03 Thread David Blaikie via cfe-commits
Why the change from using setter functions to direct assignment?

On Mon, Dec 3, 2018 at 5:06 AM Bruno Ricci via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: brunoricci
> Date: Mon Dec  3 05:04:10 2018
> New Revision: 348131
>
> URL: http://llvm.org/viewvc/llvm-project?rev=348131=rev
> Log:
> [AST] Fix an uninitialized bug in the bits of FunctionDecl
>
> FunctionDeclBits.IsCopyDeductionCandidate was not initialized.
> This caused a warning with valgrind.
>
>
> Modified:
> cfe/trunk/lib/AST/Decl.cpp
>
> Modified: cfe/trunk/lib/AST/Decl.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=348131=348130=348131=diff
>
> ==
> --- cfe/trunk/lib/AST/Decl.cpp (original)
> +++ cfe/trunk/lib/AST/Decl.cpp Mon Dec  3 05:04:10 2018
> @@ -2653,27 +2653,29 @@ FunctionDecl::FunctionDecl(Kind DK, ASTC
>DeclContext(DK), redeclarable_base(C), ODRHash(0),
>EndRangeLoc(NameInfo.getEndLoc()), DNLoc(NameInfo.getInfo()) {
>assert(T.isNull() || T->isFunctionType());
> -  setStorageClass(S);
> -  setInlineSpecified(isInlineSpecified);
> -  setExplicitSpecified(false);
> -  setVirtualAsWritten(false);
> -  setPure(false);
> -  setHasInheritedPrototype(false);
> -  setHasWrittenPrototype(true);
> -  setDeletedAsWritten(false);
> -  setTrivial(false);
> -  setTrivialForCall(false);
> -  setDefaulted(false);
> -  setExplicitlyDefaulted(false);
> -  setHasImplicitReturnZero(false);
> -  setLateTemplateParsed(false);
> -  setConstexpr(isConstexprSpecified);
> -  setInstantiationIsPending(false);
> -  setUsesSEHTry(false);
> -  setHasSkippedBody(false);
> -  setWillHaveBody(false);
> -  setIsMultiVersion(false);
> -  setHasODRHash(false);
> +  FunctionDeclBits.SClass = S;
> +  FunctionDeclBits.IsInline = isInlineSpecified;
> +  FunctionDeclBits.IsInlineSpecified = isInlineSpecified;
> +  FunctionDeclBits.IsExplicitSpecified = false;
> +  FunctionDeclBits.IsVirtualAsWritten = false;
> +  FunctionDeclBits.IsPure = false;
> +  FunctionDeclBits.HasInheritedPrototype = false;
> +  FunctionDeclBits.HasWrittenPrototype = true;
> +  FunctionDeclBits.IsDeleted = false;
> +  FunctionDeclBits.IsTrivial = false;
> +  FunctionDeclBits.IsTrivialForCall = false;
> +  FunctionDeclBits.IsDefaulted = false;
> +  FunctionDeclBits.IsExplicitlyDefaulted = false;
> +  FunctionDeclBits.HasImplicitReturnZero = false;
> +  FunctionDeclBits.IsLateTemplateParsed = false;
> +  FunctionDeclBits.IsConstexpr = isConstexprSpecified;
> +  FunctionDeclBits.InstantiationIsPending = false;
> +  FunctionDeclBits.UsesSEHTry = false;
> +  FunctionDeclBits.HasSkippedBody = false;
> +  FunctionDeclBits.WillHaveBody = false;
> +  FunctionDeclBits.IsMultiVersion = false;
> +  FunctionDeclBits.IsCopyDeductionCandidate = false;
> +  FunctionDeclBits.HasODRHash = false;
>  }
>
>  void FunctionDecl::getNameForDiagnostic(
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53153: [OpenCL] Mark kernel functions with default visibility

2018-12-03 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added a comment.

In D53153#1315109 , @rjmccall wrote:

> Okay.  So it's still the case that all symbols will be defined within the 
> linkage unit; it's just that some things might need to get exposed outside of 
> it.
>
> LLVM does provide a `dso_local` attribute which you could use unconditionally 
> on every symbol without actually changing visibility.


It seems like `dso_local` is an IR concept, and is a guarantee of 
non-preemptability? Marking e.g. a global variable as `dso_local` in IR doesn't 
seem to affect what LLD infers about it;`computeIsPreemptible` in the ELF 
writer still believes it is preemptable, and so LLD complains when it attempts 
to generate a dynamic relocation in a read-only section (i.e. text). Is 
`dso_local` meant to convey anything to the linker?

If this is the intended behavior we could still tell LLD to assume all defined 
symbols are not preemptable with something like `-Bsymbolic`. If we support 
dynamic linking/preemption in the future we will have to revisit this, but at 
that time visibility will be meaningful.

I suppose one approach is then:

- Remove the implicit `-fvisibility=hidden` in the AMDGPU Clang toolchain
- Add a module pass to mark all global values with `dso_local`
- Add an implicit `-Bsymbolic` to the linker commandline


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

https://reviews.llvm.org/D53153



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


[PATCH] D54457: [AST] Generate unique identifiers for CXXCtorInitializer objects.

2018-12-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 176470.
NoQ added a comment.

Wait, i already did that in D54488 .


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

https://reviews.llvm.org/D54457

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


Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -2246,6 +2246,14 @@
 : Initializee(TInfo), Init(Init), LParenLoc(L), RParenLoc(R),
   IsDelegating(true), IsVirtual(false), IsWritten(false), SourceOrder(0) {}
 
+int64_t CXXCtorInitializer::getID(const ASTContext ) const {
+  Optional Out = Context.getAllocator().identifyObject(this);
+  assert(Out && "Wrong allocator used");
+  assert(*Out % alignof(CXXCtorInitializer) == 0 &&
+ "Wrong alignment information");
+  return *Out / alignof(CXXCtorInitializer);
+}
+
 TypeLoc CXXCtorInitializer::getBaseClassLoc() const {
   if (isBaseInitializer())
 return Initializee.get()->getTypeLoc();
Index: include/clang/AST/DeclCXX.h
===
--- include/clang/AST/DeclCXX.h
+++ include/clang/AST/DeclCXX.h
@@ -2315,6 +2315,9 @@
   CXXCtorInitializer(ASTContext , TypeSourceInfo *TInfo,
  SourceLocation L, Expr *Init, SourceLocation R);
 
+  /// \return Unique reproducible object identifier.
+  int64_t getID(const ASTContext ) const;
+
   /// Determine whether this initializer is initializing a base class.
   bool isBaseInitializer() const {
 return Initializee.is() && !IsDelegating;


Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -2246,6 +2246,14 @@
 : Initializee(TInfo), Init(Init), LParenLoc(L), RParenLoc(R),
   IsDelegating(true), IsVirtual(false), IsWritten(false), SourceOrder(0) {}
 
+int64_t CXXCtorInitializer::getID(const ASTContext ) const {
+  Optional Out = Context.getAllocator().identifyObject(this);
+  assert(Out && "Wrong allocator used");
+  assert(*Out % alignof(CXXCtorInitializer) == 0 &&
+ "Wrong alignment information");
+  return *Out / alignof(CXXCtorInitializer);
+}
+
 TypeLoc CXXCtorInitializer::getBaseClassLoc() const {
   if (isBaseInitializer())
 return Initializee.get()->getTypeLoc();
Index: include/clang/AST/DeclCXX.h
===
--- include/clang/AST/DeclCXX.h
+++ include/clang/AST/DeclCXX.h
@@ -2315,6 +2315,9 @@
   CXXCtorInitializer(ASTContext , TypeSourceInfo *TInfo,
  SourceLocation L, Expr *Init, SourceLocation R);
 
+  /// \return Unique reproducible object identifier.
+  int64_t getID(const ASTContext ) const;
+
   /// Determine whether this initializer is initializing a base class.
   bool isBaseInitializer() const {
 return Initializee.is() && !IsDelegating;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54630: Move detection of libc++ include dirs to Driver on MacOS

2018-12-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Please mention this change in the release notes though.


Repository:
  rC Clang

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

https://reviews.llvm.org/D54630



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


[PATCH] D54630: Move detection of libc++ include dirs to Driver on MacOS

2018-12-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D54630



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


[PATCH] D55229: [COFF, ARM64] Make -flto-visibility-public-std a driver and cc1 flag

2018-12-03 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

In D55229#1317333 , @rnk wrote:

> I think @compnerd arranged things this way. I don't know why 
> -flto-visibility-public-std is involved, I have no idea what that does. I 
> think we should do what MSVC does here, which is to leave _CxxThrowException 
> unannotated and let the linker synthesize import thunks.
>
> Here is the code in question that applies dllimport: 
> https://github.com/llvm-git-prototype/llvm/blob/master/clang/lib/CodeGen/CodeGenModule.cpp#L2955
>
> My suggestion would be to make it check `isWindowsItaniumEnvironment` so we 
> can avoid this behavior which isn't desired under either mingw or MSVC.


Even with the isWindowsItaniumEnvironment check I see it generate 
__imp__CxxThrowException and break the unit test 
CodeGenCXX/runtime-dllstorage.cpp. However, with the isOSWindows check it 
generates __CxxThrowException but ends up breaking a few more unit tests.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55229



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


[PATCH] D55127: [OpenCL] Diagnose conflicting address spaces between template definition and its instantiation

2018-12-03 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Okay.  What you're saying is that the current OpenCL C++ compiler is implicitly 
adding an address-space qualifier at the top level to explicit template 
arguments.  I agree that it should not be doing that.

Can you explain why the changes to `TreeTransform` are required?


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

https://reviews.llvm.org/D55127



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


r348192 - Typo correction; NFC.

2018-12-03 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Dec  3 13:27:15 2018
New Revision: 348192

URL: http://llvm.org/viewvc/llvm-project?rev=348192=rev
Log:
Typo correction; NFC.

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=348192=348191=348192=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Mon Dec  3 13:27:15 2018
@@ -1541,7 +1541,7 @@ public:
   ///
   /// C++11 [class]p6:
   ///"A trivial class is a class that has a trivial default constructor and
-  ///is trivially copiable."
+  ///is trivially copyable."
   bool isTrivial() const {
 return isTriviallyCopyable() && hasTrivialDefaultConstructor();
   }


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


Re: r348154 - Avoid emitting redundant or unusable directories in DIFile metadata entries.

2018-12-03 Thread Adrian Prantl via cfe-commits
I'll take a look right away. Thanks for letting me know!

-- adrian

> On Dec 3, 2018, at 1:26 PM, Vlad Tsyrklevich  wrote:
> 
> This change appears to have broken a number of compiler-rt coverage tests, 
> e.g. in this run 
> .
>  The source of the error appears to be that llvm-cov is now trying to use a 
> relative path that's not relative to the directory it's in, though I'm not 
> familiar enough with debuginfo/coverage to understand what an appropriate fix 
> is. I've not yet reverted these changes to give you a chance to take a look.
> 
> On Mon, Dec 3, 2018 at 9:58 AM Adrian Prantl via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: adrian
> Date: Mon Dec  3 09:55:27 2018
> New Revision: 348154
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=348154=rev 
> 
> Log:
> Avoid emitting redundant or unusable directories in DIFile metadata entries.
> 
> As discussed on llvm-dev recently, Clang currently emits redundant
> directories in DIFile entries, such as
> 
>   .file  1 "/Volumes/Data/llvm" 
> "/Volumes/Data/llvm/tools/clang/test/CodeGen/debug-info-abspath.c"
> 
> This patch looks at any common prefix between the compilation
> directory and the (absolute) file path and strips the redundant
> part. More importantly it leaves the compilation directory empty if
> the two paths have no common prefix.
> 
> After this patch the above entry is (assuming a compilation dir of 
> "/Volumes/Data/llvm/_build"):
> 
>   .file 1 "/Volumes/Data/llvm" "tools/clang/test/CodeGen/debug-info-abspath.c"
> 
> When building the FileCheck binary with debug info, this patch makes
> the build artifacts ~1kb smaller.
> 
> Differential Revision: https://reviews.llvm.org/D55085 
> 
> 
> Added:
> cfe/trunk/test/CodeGen/debug-info-abspath.c
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CodeGenAction.cpp
> cfe/trunk/test/CodeGen/debug-prefix-map.c
> cfe/trunk/test/Modules/module-debuginfo-prefix.m
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=348154=348153=348154=diff
>  
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Dec  3 09:55:27 2018
> @@ -181,8 +181,7 @@ void CGDebugInfo::setLocation(SourceLoca
>SourceManager  = CGM.getContext().getSourceManager();
>auto *Scope = cast(LexicalBlockStack.back());
>PresumedLoc PCLoc = SM.getPresumedLoc(CurLoc);
> -
> -  if (PCLoc.isInvalid() || Scope->getFilename() == PCLoc.getFilename())
> +  if (PCLoc.isInvalid() || Scope->getFile() == getOrCreateFile(CurLoc))
>  return;
> 
>if (auto *LBF = dyn_cast(Scope)) {
> @@ -410,13 +409,13 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>SourceManager  = CGM.getContext().getSourceManager();
>PresumedLoc PLoc = SM.getPresumedLoc(Loc);
> 
> -  if (PLoc.isInvalid() || StringRef(PLoc.getFilename()).empty())
> +  StringRef FileName = PLoc.getFilename();
> +  if (PLoc.isInvalid() || FileName.empty())
>  // If the location is not valid then use main input file.
>  return getOrCreateMainFile();
> 
>// Cache the results.
> -  const char *fname = PLoc.getFilename();
> -  auto It = DIFileCache.find(fname);
> +  auto It = DIFileCache.find(FileName.data());
> 
>if (It != DIFileCache.end()) {
>  // Verify that the information still exists.
> @@ -431,11 +430,41 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>if (CSKind)
>  CSInfo.emplace(*CSKind, Checksum);
> 
> -  llvm::DIFile *F = DBuilder.createFile(
> -  remapDIPath(PLoc.getFilename()), remapDIPath(getCurrentDirname()), 
> CSInfo,
> -  getSource(SM, SM.getFileID(Loc)));
> +  StringRef Dir;
> +  StringRef File;
> +  std::string RemappedFile = remapDIPath(FileName);
> +  std::string CurDir = remapDIPath(getCurrentDirname());
> +  SmallString<128> DirBuf;
> +  SmallString<128> FileBuf;
> +  if (llvm::sys::path::is_absolute(RemappedFile)) {
> +// Strip the common prefix (if it is more than just "/") from current
> +// directory and FileName for a more space-efficient encoding.
> +auto FileIt = llvm::sys::path::begin(RemappedFile);
> +auto FileE = llvm::sys::path::end(RemappedFile);
> +auto CurDirIt = llvm::sys::path::begin(CurDir);
> +auto CurDirE = llvm::sys::path::end(CurDir);
> +for (; CurDirIt != CurDirE && *CurDirIt == *FileIt; ++CurDirIt, ++FileIt)
> +  llvm::sys::path::append(DirBuf, *CurDirIt);
> +if (std::distance(llvm::sys::path::begin(CurDir), CurDirIt) == 1) {
> +  // The common prefix only the root; 

[PATCH] D55188: Extract TextChildDumper class

2018-12-03 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 176467.
steveire added a comment.

Remove namespace


Repository:
  rC Clang

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

https://reviews.llvm.org/D55188

Files:
  include/clang/AST/ASTDumperUtils.h
  lib/AST/ASTDumper.cpp

Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTDumperUtils.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/CommentVisitor.h"
 #include "clang/AST/DeclCXX.h"
@@ -35,78 +36,6 @@
 //===--===//
 
 namespace  {
-  // Colors used for various parts of the AST dump
-  // Do not use bold yellow for any text.  It is hard to read on white screens.
-
-  struct TerminalColor {
-raw_ostream::Colors Color;
-bool Bold;
-  };
-
-  // Red   - CastColor
-  // Green - TypeColor
-  // Bold Green- DeclKindNameColor, UndeserializedColor
-  // Yellow- AddressColor, LocationColor
-  // Blue  - CommentColor, NullColor, IndentColor
-  // Bold Blue - AttrColor
-  // Bold Magenta  - StmtColor
-  // Cyan  - ValueKindColor, ObjectKindColor
-  // Bold Cyan - ValueColor, DeclNameColor
-
-  // Decl kind names (VarDecl, FunctionDecl, etc)
-  static const TerminalColor DeclKindNameColor = { raw_ostream::GREEN, true };
-  // Attr names (CleanupAttr, GuardedByAttr, etc)
-  static const TerminalColor AttrColor = { raw_ostream::BLUE, true };
-  // Statement names (DeclStmt, ImplicitCastExpr, etc)
-  static const TerminalColor StmtColor = { raw_ostream::MAGENTA, true };
-  // Comment names (FullComment, ParagraphComment, TextComment, etc)
-  static const TerminalColor CommentColor = { raw_ostream::BLUE, false };
-
-  // Type names (int, float, etc, plus user defined types)
-  static const TerminalColor TypeColor = { raw_ostream::GREEN, false };
-
-  // Pointer address
-  static const TerminalColor AddressColor = { raw_ostream::YELLOW, false };
-  // Source locations
-  static const TerminalColor LocationColor = { raw_ostream::YELLOW, false };
-
-  // lvalue/xvalue
-  static const TerminalColor ValueKindColor = { raw_ostream::CYAN, false };
-  // bitfield/objcproperty/objcsubscript/vectorcomponent
-  static const TerminalColor ObjectKindColor = { raw_ostream::CYAN, false };
-
-  // Null statements
-  static const TerminalColor NullColor = { raw_ostream::BLUE, false };
-
-  // Undeserialized entities
-  static const TerminalColor UndeserializedColor = { raw_ostream::GREEN, true };
-
-  // CastKind from CastExpr's
-  static const TerminalColor CastColor = { raw_ostream::RED, false };
-
-  // Value of the statement
-  static const TerminalColor ValueColor = { raw_ostream::CYAN, true };
-  // Decl names
-  static const TerminalColor DeclNameColor = { raw_ostream::CYAN, true };
-
-  // Indents ( `, -. | )
-  static const TerminalColor IndentColor = { raw_ostream::BLUE, false };
-
-  class ColorScope {
-raw_ostream 
-const bool ShowColors;
-
-  public:
-ColorScope(raw_ostream , bool ShowColors, TerminalColor Color)
-: OS(OS), ShowColors(ShowColors) {
-  if (ShowColors)
-OS.changeColor(Color.Color, Color.Bold);
-}
-~ColorScope() {
-  if (ShowColors)
-OS.resetColor();
-}
-  };
 
   class ASTDumper
   : public ConstDeclVisitor,
@@ -114,6 +43,8 @@
 public ConstCommentVisitor,
 public TypeVisitor {
 
+TextTreeStructure TreeStructure;
+
 raw_ostream 
 const CommandTraits *Traits;
 const SourceManager *SM;
@@ -121,22 +52,10 @@
 /// The policy to use for printing; can be defaulted.
 PrintingPolicy PrintPolicy;
 
-/// Pending[i] is an action to dump an entity at level i.
-llvm::SmallVector, 32> Pending;
-
 /// Indicates whether we should trigger deserialization of nodes that had
 /// not already been loaded.
 bool Deserialize = false;
 
-/// Indicates whether we're at the top level.
-bool TopLevel = true;
-
-/// Indicates if we're handling the first child after entering a new depth.
-bool FirstChild = true;
-
-/// Prefix for currently-being-dumped entity.
-std::string Prefix;
-
 /// Keep track of the last location we print out so that we can
 /// print out deltas from then on out.
 const char *LastLocFilename = "";
@@ -146,65 +65,7 @@
 
 /// Dump a child of the current node.
 template void dumpChild(Fn doDumpChild) {
-  // If we're at the top level, there's nothing interesting to do; just
-  // run the dumper.
-  if (TopLevel) {
-TopLevel = false;
-doDumpChild();
-while (!Pending.empty()) {
-  Pending.back()(true);
-  Pending.pop_back();
-}
-Prefix.clear();
-

Re: r348154 - Avoid emitting redundant or unusable directories in DIFile metadata entries.

2018-12-03 Thread Vlad Tsyrklevich via cfe-commits
This change appears to have broken a number of compiler-rt coverage tests,
e.g. in this run
.
The source of the error appears to be that llvm-cov is now trying to use a
relative path that's not relative to the directory it's in, though I'm not
familiar enough with debuginfo/coverage to understand what an appropriate
fix is. I've not yet reverted these changes to give you a chance to take a
look.

On Mon, Dec 3, 2018 at 9:58 AM Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: adrian
> Date: Mon Dec  3 09:55:27 2018
> New Revision: 348154
>
> URL: http://llvm.org/viewvc/llvm-project?rev=348154=rev
> Log:
> Avoid emitting redundant or unusable directories in DIFile metadata
> entries.
>
> As discussed on llvm-dev recently, Clang currently emits redundant
> directories in DIFile entries, such as
>
>   .file  1 "/Volumes/Data/llvm"
> "/Volumes/Data/llvm/tools/clang/test/CodeGen/debug-info-abspath.c"
>
> This patch looks at any common prefix between the compilation
> directory and the (absolute) file path and strips the redundant
> part. More importantly it leaves the compilation directory empty if
> the two paths have no common prefix.
>
> After this patch the above entry is (assuming a compilation dir of
> "/Volumes/Data/llvm/_build"):
>
>   .file 1 "/Volumes/Data/llvm"
> "tools/clang/test/CodeGen/debug-info-abspath.c"
>
> When building the FileCheck binary with debug info, this patch makes
> the build artifacts ~1kb smaller.
>
> Differential Revision: https://reviews.llvm.org/D55085
>
> Added:
> cfe/trunk/test/CodeGen/debug-info-abspath.c
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CodeGenAction.cpp
> cfe/trunk/test/CodeGen/debug-prefix-map.c
> cfe/trunk/test/Modules/module-debuginfo-prefix.m
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=348154=348153=348154=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Dec  3 09:55:27 2018
> @@ -181,8 +181,7 @@ void CGDebugInfo::setLocation(SourceLoca
>SourceManager  = CGM.getContext().getSourceManager();
>auto *Scope = cast(LexicalBlockStack.back());
>PresumedLoc PCLoc = SM.getPresumedLoc(CurLoc);
> -
> -  if (PCLoc.isInvalid() || Scope->getFilename() == PCLoc.getFilename())
> +  if (PCLoc.isInvalid() || Scope->getFile() == getOrCreateFile(CurLoc))
>  return;
>
>if (auto *LBF = dyn_cast(Scope)) {
> @@ -410,13 +409,13 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>SourceManager  = CGM.getContext().getSourceManager();
>PresumedLoc PLoc = SM.getPresumedLoc(Loc);
>
> -  if (PLoc.isInvalid() || StringRef(PLoc.getFilename()).empty())
> +  StringRef FileName = PLoc.getFilename();
> +  if (PLoc.isInvalid() || FileName.empty())
>  // If the location is not valid then use main input file.
>  return getOrCreateMainFile();
>
>// Cache the results.
> -  const char *fname = PLoc.getFilename();
> -  auto It = DIFileCache.find(fname);
> +  auto It = DIFileCache.find(FileName.data());
>
>if (It != DIFileCache.end()) {
>  // Verify that the information still exists.
> @@ -431,11 +430,41 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>if (CSKind)
>  CSInfo.emplace(*CSKind, Checksum);
>
> -  llvm::DIFile *F = DBuilder.createFile(
> -  remapDIPath(PLoc.getFilename()), remapDIPath(getCurrentDirname()),
> CSInfo,
> -  getSource(SM, SM.getFileID(Loc)));
> +  StringRef Dir;
> +  StringRef File;
> +  std::string RemappedFile = remapDIPath(FileName);
> +  std::string CurDir = remapDIPath(getCurrentDirname());
> +  SmallString<128> DirBuf;
> +  SmallString<128> FileBuf;
> +  if (llvm::sys::path::is_absolute(RemappedFile)) {
> +// Strip the common prefix (if it is more than just "/") from current
> +// directory and FileName for a more space-efficient encoding.
> +auto FileIt = llvm::sys::path::begin(RemappedFile);
> +auto FileE = llvm::sys::path::end(RemappedFile);
> +auto CurDirIt = llvm::sys::path::begin(CurDir);
> +auto CurDirE = llvm::sys::path::end(CurDir);
> +for (; CurDirIt != CurDirE && *CurDirIt == *FileIt; ++CurDirIt,
> ++FileIt)
> +  llvm::sys::path::append(DirBuf, *CurDirIt);
> +if (std::distance(llvm::sys::path::begin(CurDir), CurDirIt) == 1) {
> +  // The common prefix only the root; stripping it would cause
> +  // LLVM diagnostic locations to be more confusing.
> +  Dir = {};
> +  File = RemappedFile;
> +} else {
> +  for (; FileIt != FileE; ++FileIt)
> +llvm::sys::path::append(FileBuf, *FileIt);
> +  Dir = DirBuf;
> +  File = FileBuf;
> +}
> +  } else {
> +Dir = CurDir;
> +File = RemappedFile;
> +  }
> +  

[PATCH] D54905: [AddressSanitizer] Add flag to disable linking with CXX runtime

2018-12-03 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a comment.

Linux linkers won't include a member of an archive only because it resolves a 
weak symbol, so in your example the answer is none.

ASan uses -Wl,-whole-archive to pull all its members, this will resolve 
operator new to ASan definition unless there is another definition in the main 
executable. In general, the first one in the order of command line arguments 
will be used.


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

https://reviews.llvm.org/D54905



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


[PATCH] D55188: Extract TextChildDumper class

2018-12-03 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 176466.
steveire added a comment.

Rename class.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55188

Files:
  include/clang/AST/ASTDumperUtils.h
  lib/AST/ASTDumper.cpp

Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTDumperUtils.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/CommentVisitor.h"
 #include "clang/AST/DeclCXX.h"
@@ -29,84 +30,13 @@
 #include "llvm/Support/raw_ostream.h"
 using namespace clang;
 using namespace clang::comments;
+using namespace clang::ast_dumper;
 
 //===--===//
 // ASTDumper Visitor
 //===--===//
 
 namespace  {
-  // Colors used for various parts of the AST dump
-  // Do not use bold yellow for any text.  It is hard to read on white screens.
-
-  struct TerminalColor {
-raw_ostream::Colors Color;
-bool Bold;
-  };
-
-  // Red   - CastColor
-  // Green - TypeColor
-  // Bold Green- DeclKindNameColor, UndeserializedColor
-  // Yellow- AddressColor, LocationColor
-  // Blue  - CommentColor, NullColor, IndentColor
-  // Bold Blue - AttrColor
-  // Bold Magenta  - StmtColor
-  // Cyan  - ValueKindColor, ObjectKindColor
-  // Bold Cyan - ValueColor, DeclNameColor
-
-  // Decl kind names (VarDecl, FunctionDecl, etc)
-  static const TerminalColor DeclKindNameColor = { raw_ostream::GREEN, true };
-  // Attr names (CleanupAttr, GuardedByAttr, etc)
-  static const TerminalColor AttrColor = { raw_ostream::BLUE, true };
-  // Statement names (DeclStmt, ImplicitCastExpr, etc)
-  static const TerminalColor StmtColor = { raw_ostream::MAGENTA, true };
-  // Comment names (FullComment, ParagraphComment, TextComment, etc)
-  static const TerminalColor CommentColor = { raw_ostream::BLUE, false };
-
-  // Type names (int, float, etc, plus user defined types)
-  static const TerminalColor TypeColor = { raw_ostream::GREEN, false };
-
-  // Pointer address
-  static const TerminalColor AddressColor = { raw_ostream::YELLOW, false };
-  // Source locations
-  static const TerminalColor LocationColor = { raw_ostream::YELLOW, false };
-
-  // lvalue/xvalue
-  static const TerminalColor ValueKindColor = { raw_ostream::CYAN, false };
-  // bitfield/objcproperty/objcsubscript/vectorcomponent
-  static const TerminalColor ObjectKindColor = { raw_ostream::CYAN, false };
-
-  // Null statements
-  static const TerminalColor NullColor = { raw_ostream::BLUE, false };
-
-  // Undeserialized entities
-  static const TerminalColor UndeserializedColor = { raw_ostream::GREEN, true };
-
-  // CastKind from CastExpr's
-  static const TerminalColor CastColor = { raw_ostream::RED, false };
-
-  // Value of the statement
-  static const TerminalColor ValueColor = { raw_ostream::CYAN, true };
-  // Decl names
-  static const TerminalColor DeclNameColor = { raw_ostream::CYAN, true };
-
-  // Indents ( `, -. | )
-  static const TerminalColor IndentColor = { raw_ostream::BLUE, false };
-
-  class ColorScope {
-raw_ostream 
-const bool ShowColors;
-
-  public:
-ColorScope(raw_ostream , bool ShowColors, TerminalColor Color)
-: OS(OS), ShowColors(ShowColors) {
-  if (ShowColors)
-OS.changeColor(Color.Color, Color.Bold);
-}
-~ColorScope() {
-  if (ShowColors)
-OS.resetColor();
-}
-  };
 
   class ASTDumper
   : public ConstDeclVisitor,
@@ -114,6 +44,8 @@
 public ConstCommentVisitor,
 public TypeVisitor {
 
+TextTreeStructure TreeStructure;
+
 raw_ostream 
 const CommandTraits *Traits;
 const SourceManager *SM;
@@ -121,22 +53,10 @@
 /// The policy to use for printing; can be defaulted.
 PrintingPolicy PrintPolicy;
 
-/// Pending[i] is an action to dump an entity at level i.
-llvm::SmallVector, 32> Pending;
-
 /// Indicates whether we should trigger deserialization of nodes that had
 /// not already been loaded.
 bool Deserialize = false;
 
-/// Indicates whether we're at the top level.
-bool TopLevel = true;
-
-/// Indicates if we're handling the first child after entering a new depth.
-bool FirstChild = true;
-
-/// Prefix for currently-being-dumped entity.
-std::string Prefix;
-
 /// Keep track of the last location we print out so that we can
 /// print out deltas from then on out.
 const char *LastLocFilename = "";
@@ -146,65 +66,7 @@
 
 /// Dump a child of the current node.
 template void dumpChild(Fn doDumpChild) {
-  // If we're at the top level, there's nothing interesting to do; just
-  

[PATCH] D54457: [AST] Generate unique identifiers for CXXCtorInitializer objects.

2018-12-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 176465.
NoQ added a comment.

Rebase on top of D54486 !


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

https://reviews.llvm.org/D54457

Files:
  include/clang/AST/DeclCXX.h
  lib/AST/DeclBase.cpp
  lib/AST/DeclCXX.cpp
  lib/AST/Stmt.cpp
  lib/StaticAnalyzer/Core/ExplodedGraph.cpp
  lib/StaticAnalyzer/Core/ProgramState.cpp


Index: lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- lib/StaticAnalyzer/Core/ProgramState.cpp
+++ lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -70,10 +70,7 @@
 }
 
 int64_t ProgramState::getID() const {
-  Optional Out = getStateManager().Alloc.identifyObject(this);
-  assert(Out && "Wrong allocator used");
-  assert(*Out % alignof(ProgramState) == 0 && "Wrong alignment information");
-  return *Out / alignof(ProgramState);
+  return 
getStateManager().Alloc.identifyKnownAlignedObject(this);
 }
 
 ProgramStateManager::ProgramStateManager(ASTContext ,
Index: lib/StaticAnalyzer/Core/ExplodedGraph.cpp
===
--- lib/StaticAnalyzer/Core/ExplodedGraph.cpp
+++ lib/StaticAnalyzer/Core/ExplodedGraph.cpp
@@ -284,10 +284,7 @@
 }
 
 int64_t ExplodedNode::getID(ExplodedGraph *G) const {
-  Optional Out = G->getAllocator().identifyObject(this);
-  assert(Out && "Wrong allocator used");
-  assert(*Out % alignof(ExplodedNode) == 0 && "Wrong alignment information");
-  return *Out / alignof(ExplodedNode);
+  return G->getAllocator().identifyKnownAlignedObject(this);
 }
 
 bool ExplodedNode::isTrivial() const {
Index: lib/AST/Stmt.cpp
===
--- lib/AST/Stmt.cpp
+++ lib/AST/Stmt.cpp
@@ -303,10 +303,7 @@
 }
 
 int64_t Stmt::getID(const ASTContext ) const {
-  Optional Out = Context.getAllocator().identifyObject(this);
-  assert(Out && "Wrong allocator used");
-  assert(*Out % alignof(Stmt) == 0 && "Wrong alignment information");
-  return *Out / alignof(Stmt);
+  return Context.getAllocator().identifyKnownAlignedObject(this);
 }
 
 CompoundStmt::CompoundStmt(ArrayRef Stmts, SourceLocation LB,
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -2246,6 +2246,11 @@
 : Initializee(TInfo), Init(Init), LParenLoc(L), RParenLoc(R),
   IsDelegating(true), IsVirtual(false), IsWritten(false), SourceOrder(0) {}
 
+int64_t CXXCtorInitializer::getID(const ASTContext ) const {
+  return Context.getAllocator()
+.identifyKnownAlignedObject(this);
+}
+
 TypeLoc CXXCtorInitializer::getBaseClassLoc() const {
   if (isBaseInitializer())
 return Initializee.get()->getTypeLoc();
Index: lib/AST/DeclBase.cpp
===
--- lib/AST/DeclBase.cpp
+++ lib/AST/DeclBase.cpp
@@ -955,10 +955,7 @@
 static Decl::Kind getKind(const DeclContext *DC) { return DC->getDeclKind(); }
 
 int64_t Decl::getID() const {
-  Optional Out = getASTContext().getAllocator().identifyObject(this);
-  assert(Out && "Wrong allocator used");
-  assert(*Out % alignof(Decl) == 0 && "Wrong alignment information");
-  return *Out / alignof(Decl);
+  return getASTContext().getAllocator().identifyKnownAlignedObject(this);
 }
 
 const FunctionType *Decl::getFunctionType(bool BlocksToo) const {
Index: include/clang/AST/DeclCXX.h
===
--- include/clang/AST/DeclCXX.h
+++ include/clang/AST/DeclCXX.h
@@ -2315,6 +2315,9 @@
   CXXCtorInitializer(ASTContext , TypeSourceInfo *TInfo,
  SourceLocation L, Expr *Init, SourceLocation R);
 
+  /// \return Unique reproducible object identifier.
+  int64_t getID(const ASTContext ) const;
+
   /// Determine whether this initializer is initializing a base class.
   bool isBaseInitializer() const {
 return Initializee.is() && !IsDelegating;


Index: lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- lib/StaticAnalyzer/Core/ProgramState.cpp
+++ lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -70,10 +70,7 @@
 }
 
 int64_t ProgramState::getID() const {
-  Optional Out = getStateManager().Alloc.identifyObject(this);
-  assert(Out && "Wrong allocator used");
-  assert(*Out % alignof(ProgramState) == 0 && "Wrong alignment information");
-  return *Out / alignof(ProgramState);
+  return getStateManager().Alloc.identifyKnownAlignedObject(this);
 }
 
 ProgramStateManager::ProgramStateManager(ASTContext ,
Index: lib/StaticAnalyzer/Core/ExplodedGraph.cpp
===
--- lib/StaticAnalyzer/Core/ExplodedGraph.cpp
+++ lib/StaticAnalyzer/Core/ExplodedGraph.cpp
@@ -284,10 +284,7 @@
 }
 
 int64_t ExplodedNode::getID(ExplodedGraph *G) const {
-  Optional Out = G->getAllocator().identifyObject(this);
-  

[PATCH] D53157: Teach the IRBuilder about constrained fadd and friends

2018-12-03 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 176464.
kpn added a comment.

Address review comment: Shrink the diff by eliminating unneeded use of else.


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

https://reviews.llvm.org/D53157

Files:
  include/llvm/IR/IRBuilder.h
  unittests/IR/IRBuilderTest.cpp

Index: unittests/IR/IRBuilderTest.cpp
===
--- unittests/IR/IRBuilderTest.cpp
+++ unittests/IR/IRBuilderTest.cpp
@@ -123,6 +123,100 @@
   EXPECT_FALSE(II->hasNoNaNs());
 }
 
+TEST_F(IRBuilderTest, ConstrainedFP) {
+  IRBuilder<> Builder(BB);
+  Value *V;
+  CallInst *Call;
+  IntrinsicInst *II;
+
+  V = Builder.CreateLoad(GV);
+
+  Call = Builder.CreateConstrainedFAdd(V, V);
+  II = cast(Call);
+  EXPECT_EQ(II->getIntrinsicID(), Intrinsic::experimental_constrained_fadd);
+
+  Call = Builder.CreateConstrainedFSub(V, V);
+  II = cast(Call);
+  EXPECT_EQ(II->getIntrinsicID(), Intrinsic::experimental_constrained_fsub);
+
+  Call = Builder.CreateConstrainedFMul(V, V);
+  II = cast(Call);
+  EXPECT_EQ(II->getIntrinsicID(), Intrinsic::experimental_constrained_fmul);
+
+  Call = Builder.CreateConstrainedFDiv(V, V);
+  II = cast(Call);
+  EXPECT_EQ(II->getIntrinsicID(), Intrinsic::experimental_constrained_fdiv);
+
+  Call = Builder.CreateConstrainedFRem(V, V);
+  II = cast(Call);
+  EXPECT_EQ(II->getIntrinsicID(), Intrinsic::experimental_constrained_frem);
+
+  // Now see if we get constrained intrinsics instead of non-constrained
+  // instructions.
+  Builder.setIsConstrainedFP(true);
+
+  V = Builder.CreateFAdd(V, V);
+  ASSERT_TRUE(isa(V));
+  II = cast(V);
+  EXPECT_EQ(II->getIntrinsicID(), Intrinsic::experimental_constrained_fadd);
+
+  V = Builder.CreateFSub(V, V);
+  ASSERT_TRUE(isa(V));
+  II = cast(V);
+  EXPECT_EQ(II->getIntrinsicID(), Intrinsic::experimental_constrained_fsub);
+
+  V = Builder.CreateFMul(V, V);
+  ASSERT_TRUE(isa(V));
+  II = cast(V);
+  EXPECT_EQ(II->getIntrinsicID(), Intrinsic::experimental_constrained_fmul);
+  
+  V = Builder.CreateFDiv(V, V);
+  ASSERT_TRUE(isa(V));
+  II = cast(V);
+  EXPECT_EQ(II->getIntrinsicID(), Intrinsic::experimental_constrained_fdiv);
+  
+  V = Builder.CreateFRem(V, V);
+  ASSERT_TRUE(isa(V));
+  II = cast(V);
+  EXPECT_EQ(II->getIntrinsicID(), Intrinsic::experimental_constrained_frem);
+
+  // Verify the codepaths for setting and overriding the default metadata.
+  MDNode *ExceptStr = MDNode::get(Builder.getContext(), 
+  MDString::get(Builder.getContext(), 
+"fpexcept.strict"));
+  MDNode *ExceptIgn = MDNode::get(Builder.getContext(), 
+  MDString::get(Builder.getContext(), 
+"fpexcept.ignore"));
+  MDNode *RoundDyn = MDNode::get(Builder.getContext(), 
+ MDString::get(Builder.getContext(),
+   "round.dynamic"));
+  MDNode *RoundUp = MDNode::get(Builder.getContext(), 
+MDString::get(Builder.getContext(),
+  "round.upward"));
+
+  V = Builder.CreateFAdd(V, V);
+  ASSERT_TRUE(isa(V));
+  auto *CII = cast(V);
+  ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebStrict);
+  ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmDynamic);
+
+  Builder.setDefaultConstrainedExcept(ExceptIgn);
+  Builder.setDefaultConstrainedRounding(RoundUp);
+  V = Builder.CreateFAdd(V, V);
+  CII = cast(V);
+  ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebIgnore);
+  ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmUpward);
+
+  // Now override the defaults.
+  Call = Builder.CreateConstrainedFAdd(V, V, nullptr, "", RoundDyn, ExceptStr);
+  CII = cast(Call);
+  ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebStrict);
+  ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmDynamic);
+
+  Builder.CreateRetVoid();
+  EXPECT_FALSE(verifyModule(*M));
+}
+
 TEST_F(IRBuilderTest, Lifetime) {
   IRBuilder<> Builder(BB);
   AllocaInst *Var1 = Builder.CreateAlloca(Builder.getInt8Ty());
Index: include/llvm/IR/IRBuilder.h
===
--- include/llvm/IR/IRBuilder.h
+++ include/llvm/IR/IRBuilder.h
@@ -97,13 +97,18 @@
   MDNode *DefaultFPMathTag;
   FastMathFlags FMF;
 
+  bool IsFPConstrained;
+  MDNode *DefaultConstrainedExcept;
+  MDNode *DefaultConstrainedRounding;
+
   ArrayRef DefaultOperandBundles;
 
 public:
   IRBuilderBase(LLVMContext , MDNode *FPMathTag = nullptr,
 ArrayRef OpBundles = None)
   : Context(context), DefaultFPMathTag(FPMathTag),
-DefaultOperandBundles(OpBundles) {
+IsFPConstrained(false), DefaultConstrainedExcept(nullptr),
+DefaultConstrainedRounding(nullptr), DefaultOperandBundles(OpBundles) {
  

[PATCH] D55068: NFC: Simplify dumpStmt child handling

2018-12-03 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348189: NFC: Simplify dumpStmt child handling (authored by 
steveire, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55068

Files:
  cfe/trunk/lib/AST/ASTDumper.cpp


Index: cfe/trunk/lib/AST/ASTDumper.cpp
===
--- cfe/trunk/lib/AST/ASTDumper.cpp
+++ cfe/trunk/lib/AST/ASTDumper.cpp
@@ -1989,18 +1989,13 @@
   return;
 }
 
+ConstStmtVisitor::Visit(S);
+
 // Some statements have custom mechanisms for dumping their children.
-if (const DeclStmt *DS = dyn_cast(S)) {
-  VisitDeclStmt(DS);
-  return;
-}
-if (const GenericSelectionExpr *GSE = dyn_cast(S)) {
-  VisitGenericSelectionExpr(GSE);
+if (isa(S) || isa(S)) {
   return;
 }
 
-ConstStmtVisitor::Visit(S);
-
 for (const Stmt *SubStmt : S->children())
   dumpStmt(SubStmt);
   });


Index: cfe/trunk/lib/AST/ASTDumper.cpp
===
--- cfe/trunk/lib/AST/ASTDumper.cpp
+++ cfe/trunk/lib/AST/ASTDumper.cpp
@@ -1989,18 +1989,13 @@
   return;
 }
 
+ConstStmtVisitor::Visit(S);
+
 // Some statements have custom mechanisms for dumping their children.
-if (const DeclStmt *DS = dyn_cast(S)) {
-  VisitDeclStmt(DS);
-  return;
-}
-if (const GenericSelectionExpr *GSE = dyn_cast(S)) {
-  VisitGenericSelectionExpr(GSE);
+if (isa(S) || isa(S)) {
   return;
 }
 
-ConstStmtVisitor::Visit(S);
-
 for (const Stmt *SubStmt : S->children())
   dumpStmt(SubStmt);
   });
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40218: [Clang] Add __builtin_launder

2018-12-03 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:1425-1426
+
+  // FIXME: We either have an incomplete class type, or we have a class 
template
+  // whose instantiation has not been forced. Example:
+  //

I think it's a bug that `launder` doesn't require `T` to be a complete type. 
Can you file an LWG issue?

We should also decide whether we want to proactively fix this issue (require 
the type to be complete from the `Sema` checking of the builtin and assert that 
it's defined here) or not.



Comment at: lib/CodeGen/CGBuiltin.cpp:1437-1438
+
+  // if (!Seen.insert(Record).second)
+  //  return false;
+  for (FieldDecl *F : Record->fields()) {

Delete this commented-out code.



Comment at: lib/CodeGen/CGBuiltin.cpp:1451
+return false;
+  llvm::DenseSet Seen;
+  return TypeRequiresBuiltinLaunderImp(CGM.getContext(), Ty, Seen);

Would `SmallPtrSet` be a better choice here?



Comment at: lib/Sema/SemaChecking.cpp:885-887
+  // Don't perform LValue conversions since they may strip things like the
+  // restrict qualifier
+  ExprResult Arg = S.DefaultFunctionArrayConversion(OrigArg);

Instead of performing some of the conversions here and some of them as part of 
initialization, I think it'd be more obvious to compute the builtin's parameter 
type here (which is the type of the argument if it's not of array [or function] 
type, and the decayed type of the argument otherwise), and do the decay and 
lvalue-to-rvalue conversion as part of the parameter initialization below.

The current code arrangement (and especially this comment) leaves a reader 
thinking "but you *need* an lvalue-to-rvalue conversion if the argument is an 
lvalue".



Comment at: lib/Sema/SemaChecking.cpp:935
   return true;
+
 }

Did you mean to add this blank line?



Comment at: test/CodeGen/builtins.c:404-409
+  // CHECK: entry
+  // CHECK-NEXT: %p.addr = alloca i32*
+  // CHECK-NEXT: %d = alloca i32*
+  // CHECK-NEXT: store i32* %p, i32** %p.addr, align 8
+  // CHECK-NEXT: [[TMP:%.*]] = load i32*, i32** %p.addr
+  // CHECK-NEXT: store i32* [[TMP]], i32** %d

This test is not robust against minor IR differences such as variable or basic 
block names changing (some of these change in a release build), and is testing 
things that are not related to this builtin (eg, that we produce an alloca for 
a function parameter and its relative order to an alloca for a local variable).

I would remove everything here other than the load and the store, and add an 
explicit check that we don't generate a launder call:

```
  // CHECK: [[TMP:%.*]] = load i32*,
  // CHECK-NOT: @llvm.launder
  // CHECK: store i32* [[TMP]],
```



Comment at: test/CodeGenCXX/builtin-launder.cpp:16
+extern "C" void test_builtin_launder_virtual_fn(TestVirtualFn *p) {
+  // CHECK: entry
+  // CHECK-NEXT: %p.addr = alloca [[TYPE:%.*]], align 8

This is likewise likely to fail with a release build of clang.



Comment at: test/SemaCXX/builtins.cpp:120
+  constexpr int i = 42;
+  // FIXME: Should this work? Since `` doesn't.
+  static_assert(test_in_constexpr(i), "");

`` doesn't what?


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

https://reviews.llvm.org/D40218



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


r348189 - NFC: Simplify dumpStmt child handling

2018-12-03 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Mon Dec  3 13:05:52 2018
New Revision: 348189

URL: http://llvm.org/viewvc/llvm-project?rev=348189=rev
Log:
NFC: Simplify dumpStmt child handling

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=348189=348188=348189=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Mon Dec  3 13:05:52 2018
@@ -1989,18 +1989,13 @@ void ASTDumper::dumpStmt(const Stmt *S)
   return;
 }
 
+ConstStmtVisitor::Visit(S);
+
 // Some statements have custom mechanisms for dumping their children.
-if (const DeclStmt *DS = dyn_cast(S)) {
-  VisitDeclStmt(DS);
-  return;
-}
-if (const GenericSelectionExpr *GSE = dyn_cast(S)) {
-  VisitGenericSelectionExpr(GSE);
+if (isa(S) || isa(S)) {
   return;
 }
 
-ConstStmtVisitor::Visit(S);
-
 for (const Stmt *SubStmt : S->children())
   dumpStmt(SubStmt);
   });


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


[PATCH] D54017: [analyzer] NullabilityChecker: Invariant violation should only be triggered for symbols.

2018-12-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348188: Re-apply r347954 [analyzer] Nullability: 
Dont detect post factum violation... (authored by dergachev, 
committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D54017?vs=176029=176461#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D54017

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  cfe/trunk/test/Analysis/nullability-arc.mm
  cfe/trunk/test/Analysis/nullability.mm

Index: cfe/trunk/test/Analysis/nullability-arc.mm
===
--- cfe/trunk/test/Analysis/nullability-arc.mm
+++ cfe/trunk/test/Analysis/nullability-arc.mm
@@ -0,0 +1,39 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core,nullability\
+// RUN:   -analyzer-output=text -verify %s
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core,nullability\
+// RUN:   -analyzer-output=text -verify %s -fobjc-arc
+
+#if !__has_feature(objc_arc)
+// expected-no-diagnostics
+#endif
+
+
+#define nil ((id)0)
+
+@interface Param
+@end
+
+@interface Base
+- (void)foo:(Param *_Nonnull)param;
+@end
+
+@interface Derived : Base
+@end
+
+@implementation Derived
+- (void)foo:(Param *)param {
+  // FIXME: Why do we not emit the warning under ARC?
+  [super foo:param];
+#if __has_feature(objc_arc)
+  // expected-warning@-2{{nil passed to a callee that requires a non-null 1st parameter}}
+  // expected-note@-3   {{nil passed to a callee that requires a non-null 1st parameter}}
+#endif
+
+  [self foo:nil];
+#if __has_feature(objc_arc)
+  // expected-note@-2{{Calling 'foo:'}}
+  // expected-note@-3{{Passing nil object reference via 1st parameter 'param'}}
+#endif
+}
+@end
+
Index: cfe/trunk/test/Analysis/nullability.mm
===
--- cfe/trunk/test/Analysis/nullability.mm
+++ cfe/trunk/test/Analysis/nullability.mm
@@ -1,5 +1,36 @@
-// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullableDereferenced -DNOSYSTEMHEADERS=0 -verify %s
-// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullableDereferenced -analyzer-config nullability:NoDiagnoseCallsToSystemHeaders=true -DNOSYSTEMHEADERS=1 -verify %s
+// RUN: %clang_analyze_cc1 -fblocks -verify %s -analyzer-checker=core \
+// RUN:   -analyzer-checker=nullability.NullPassedToNonnull \
+// RUN:   -analyzer-checker=nullability.NullReturnedFromNonnull \
+// RUN:   -analyzer-checker=nullability.NullablePassedToNonnull \
+// RUN:   -analyzer-checker=nullability.NullableReturnedFromNonnull \
+// RUN:   -analyzer-checker=nullability.NullableDereferenced \
+// RUN:   -DNOSYSTEMHEADERS=0
+
+// RUN: %clang_analyze_cc1 -fblocks -verify %s -analyzer-checker=core \
+// RUN:   -analyzer-checker=nullability.NullPassedToNonnull \
+// RUN:   -analyzer-checker=nullability.NullReturnedFromNonnull \
+// RUN:   -analyzer-checker=nullability.NullablePassedToNonnull \
+// RUN:   -analyzer-checker=nullability.NullableReturnedFromNonnull \
+// RUN:   -analyzer-checker=nullability.NullableDereferenced \
+// RUN:   -DNOSYSTEMHEADERS=1 \
+// RUN:   -analyzer-config nullability:NoDiagnoseCallsToSystemHeaders=true
+
+// RUN: %clang_analyze_cc1 -fblocks -verify %s -analyzer-checker=core\
+// RUN:   -analyzer-checker=nullability.NullPassedToNonnull\
+// RUN:   -analyzer-checker=nullability.NullReturnedFromNonnull\
+// RUN:   -analyzer-checker=nullability.NullablePassedToNonnull\
+// RUN:   -analyzer-checker=nullability.NullableReturnedFromNonnull\
+// RUN:   -analyzer-checker=nullability.NullableDereferenced\
+// RUN:   -DNOSYSTEMHEADERS=0 -fobjc-arc
+
+// RUN: %clang_analyze_cc1 -fblocks -verify %s -analyzer-checker=core\
+// RUN:   -analyzer-checker=nullability.NullPassedToNonnull\
+// RUN:   -analyzer-checker=nullability.NullReturnedFromNonnull\
+// RUN:   -analyzer-checker=nullability.NullablePassedToNonnull\
+// RUN:   -analyzer-checker=nullability.NullableReturnedFromNonnull\
+// RUN:   -analyzer-checker=nullability.NullableDereferenced\
+// RUN:   -DNOSYSTEMHEADERS=1 -fobjc-arc\
+// RUN:   -analyzer-config nullability:NoDiagnoseCallsToSystemHeaders=true
 
 #include "Inputs/system-header-simulator-for-nullability.h"
 
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -329,8 +329,8 @@
  

r348188 - Re-apply r347954 "[analyzer] Nullability: Don't detect post factum violation..."

2018-12-03 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Dec  3 13:04:30 2018
New Revision: 348188

URL: http://llvm.org/viewvc/llvm-project?rev=348188=rev
Log:
Re-apply r347954 "[analyzer] Nullability: Don't detect post factum violation..."

Buildbot failures were caused by an unrelated UB that was introduced in r347943
and fixed in r347970.

Also the revision was incorrectly specified as r344580 during revert.

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

Added:
cfe/trunk/test/Analysis/nullability-arc.mm
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
cfe/trunk/test/Analysis/nullability.mm

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp?rev=348188=348187=348188=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp Mon Dec  3 
13:04:30 2018
@@ -329,8 +329,8 @@ NullabilityChecker::NullabilityBugVisito
 nullptr);
 }
 
-/// Returns true when the value stored at the given location is null
-/// and the passed in type is nonnnull.
+/// Returns true when the value stored at the given location has been
+/// constrained to null after being passed through an object of nonnnull type.
 static bool checkValueAtLValForInvariantViolation(ProgramStateRef State,
   SVal LV, QualType T) {
   if (getNullabilityAnnotation(T) != Nullability::Nonnull)
@@ -340,9 +340,14 @@ static bool checkValueAtLValForInvariant
   if (!RegionVal)
 return false;
 
-  auto StoredVal =
-  State->getSVal(RegionVal->getRegion()).getAs();
-  if (!StoredVal)
+  // If the value was constrained to null *after* it was passed through that
+  // location, it could not have been a concrete pointer *when* it was passed.
+  // In that case we would have handled the situation when the value was
+  // bound to that location, by emitting (or not emitting) a report.
+  // Therefore we are only interested in symbolic regions that can be either
+  // null or non-null depending on the value of their respective symbol.
+  auto StoredVal = State->getSVal(*RegionVal).getAs();
+  if (!StoredVal || !isa(StoredVal->getRegion()))
 return false;
 
   if (getNullConstraint(*StoredVal, State) == NullConstraint::IsNull)
@@ -1170,10 +1175,15 @@ void NullabilityChecker::printState(raw_
 
   NullabilityMapTy B = State->get();
 
+  if (State->get())
+Out << Sep << NL
+<< "Nullability invariant was violated, warnings suppressed." << NL;
+
   if (B.isEmpty())
 return;
 
-  Out << Sep << NL;
+  if (!State->get())
+Out << Sep << NL;
 
   for (NullabilityMapTy::iterator I = B.begin(), E = B.end(); I != E; ++I) {
 Out << I->first << " : ";

Added: cfe/trunk/test/Analysis/nullability-arc.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/nullability-arc.mm?rev=348188=auto
==
--- cfe/trunk/test/Analysis/nullability-arc.mm (added)
+++ cfe/trunk/test/Analysis/nullability-arc.mm Mon Dec  3 13:04:30 2018
@@ -0,0 +1,39 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core,nullability\
+// RUN:   -analyzer-output=text -verify %s
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core,nullability\
+// RUN:   -analyzer-output=text -verify %s -fobjc-arc
+
+#if !__has_feature(objc_arc)
+// expected-no-diagnostics
+#endif
+
+
+#define nil ((id)0)
+
+@interface Param
+@end
+
+@interface Base
+- (void)foo:(Param *_Nonnull)param;
+@end
+
+@interface Derived : Base
+@end
+
+@implementation Derived
+- (void)foo:(Param *)param {
+  // FIXME: Why do we not emit the warning under ARC?
+  [super foo:param];
+#if __has_feature(objc_arc)
+  // expected-warning@-2{{nil passed to a callee that requires a non-null 1st 
parameter}}
+  // expected-note@-3   {{nil passed to a callee that requires a non-null 1st 
parameter}}
+#endif
+
+  [self foo:nil];
+#if __has_feature(objc_arc)
+  // expected-note@-2{{Calling 'foo:'}}
+  // expected-note@-3{{Passing nil object reference via 1st parameter 'param'}}
+#endif
+}
+@end
+

Modified: cfe/trunk/test/Analysis/nullability.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/nullability.mm?rev=348188=348187=348188=diff
==
--- cfe/trunk/test/Analysis/nullability.mm (original)
+++ cfe/trunk/test/Analysis/nullability.mm Mon Dec  3 13:04:30 2018
@@ -1,5 +1,36 @@
-// RUN: %clang_analyze_cc1 -fblocks 
-analyzer-checker=core,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullableDereferenced
 

[PATCH] D55066: [ASan] Minor documentation fix: remove static linking limitation.

2018-12-03 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a comment.

How about "Static linking of executables is not supported"?


Repository:
  rC Clang

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

https://reviews.llvm.org/D55066



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


[PATCH] D53738: [Fixed Point Arithmetic] Fixed Point Addition

2018-12-03 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:1304
+RHSTy = ResultTy;
+  }
+

ebevhan wrote:
> rjmccall wrote:
> > leonardchan wrote:
> > > rjmccall wrote:
> > > > ebevhan wrote:
> > > > > rjmccall wrote:
> > > > > > Hmm.  So adding a signed integer to an unsigned fixed-point type 
> > > > > > always converts the integer to unsigned?  That's a little weird, 
> > > > > > but only because the fixed-point rule seems to be the other way.  
> > > > > > Anyway, I assume it's not a bug in the spec.
> > > > > `handleFixedPointConversion` only calculates the result type of the 
> > > > > expression, not the calculation type. The final result type of the 
> > > > > operation will be the unsigned fixed-point type, but the calculation 
> > > > > itself will be done in a signed type with enough precision to 
> > > > > represent both the signed integer and the unsigned fixed-point type. 
> > > > > 
> > > > > Though, if the result ends up being negative, the final result is 
> > > > > undefined unless the type is saturating. I don't think there is a 
> > > > > test for the saturating case (signed integer + unsigned saturating 
> > > > > fixed-point) in the SaturatedAddition tests.
> > > > > `handleFixedPointConversion` only calculates the result type of the 
> > > > > expression, not the calculation type.
> > > > 
> > > > Right, I understand that, but the result type of the expression 
> > > > obviously impacts the expressive range of the result, since you can end 
> > > > up with a negative value.
> > > > 
> > > > Hmm.  With that said, if the general principle is to perform the 
> > > > operation with full precision on the original operand values, why are 
> > > > unsigned fixed-point operands coerced to their corresponding signed 
> > > > types *before* the operation?  This is precision-limiting if the 
> > > > unsigned representation doesn't use a padding bit.  That seems like a 
> > > > bug in the spec.
> > > > Hmm. With that said, if the general principle is to perform the 
> > > > operation with full precision on the original operand values, why are 
> > > > unsigned fixed-point operands coerced to their corresponding signed 
> > > > types *before* the operation? This is precision-limiting if the 
> > > > unsigned representation doesn't use a padding bit. That seems like a 
> > > > bug in the spec.
> > > 
> > > Possibly. When the standard mentions converting from signed to unsigned 
> > > fixed point, the only requirement involved is conservation of magnitude 
> > > (the number of integral bits excluding the sign)
> > > 
> > > ```
> > > when signed and unsigned fixed-point types are mixed, the unsigned type 
> > > is converted to the corresponding signed type, and this should go without 
> > > loss of magnitude
> > > ```
> > > 
> > > This is just speculation, but I'm under the impression that not as much 
> > > "attention" was given for unsigned types as for signed types since "`In 
> > > the embedded processor world, support for unsigned fixed-point data types 
> > > is rare; normally only signed fixed-point data types are supported`", but 
> > > was kept anyway since unsigned types are used a lot.
> > > 
> > > ```
> > > However, to disallow unsigned fixed-point arithmetic from programming 
> > > languages (in general, and from C in particular) based on this 
> > > observation, seems overly restrictive.
> > > ```
> > > 
> > > I also imagine that if the programmer needs more precision, the correct 
> > > approach would be to cast up to a type with a higher scale. The standard 
> > > seems to make an effort to expose as much in regards to the underlying 
> > > fixed point types as possible:
> > > 
> > > ```
> > > it should be possible to write fixed-point algorithms that are 
> > > independent of the actual fixed-point hardware support. This implies that 
> > > a programmer (or a running program) should have access to all parameters 
> > > that define the behavior of the underlying hardware (in other words: even 
> > > if these parameters are implementation-defined).
> > > ```
> > > 
> > > So the user would at least know that unsigned types may not have the same 
> > > scale as their corresponding signed types if the hardware handles them 
> > > with different scales.
> > > 
> > > Also added test for signed integer + unsigned saturating fixed point.
> > As long as we maintain the same typing behavior, does the standard permit 
> > us to just Do The Right Thing here and do the extended arithmetic with the 
> > original unsigned operand?  I'm sure there are some cases where we would 
> > produce a slightly different value than an implementation that does the 
> > coercion before the operation, but that might be permitted under the 
> > standard, and as you say, it would only affect some situations that it 
> > doesn't seem the standard has given much thought to.
> The coercion of unsigned to signed is likely done for pragmatic reasons; if 
> you have a 

[PATCH] D54017: [analyzer] NullabilityChecker: Invariant violation should only be triggered for symbols.

2018-12-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Wasn't me: rC347970 .


Repository:
  rC Clang

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

https://reviews.llvm.org/D54017



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


[PATCH] D55229: [COFF, ARM64] Make -flto-visibility-public-std a driver and cc1 flag

2018-12-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I think @compnerd arranged things this way. I don't know why 
-flto-visibility-public-std is involved, I have no idea what that does. I think 
we should do what MSVC does here, which is to leave _CxxThrowException 
unannotated and let the linker synthesize import thunks.

Here is the code in question that applies dllimport: 
https://github.com/llvm-git-prototype/llvm/blob/master/clang/lib/CodeGen/CodeGenModule.cpp#L2955

My suggestion would be to make it check `isWindowsItaniumEnvironment` so we can 
avoid this behavior which isn't desired under either mingw or MSVC.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55229



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


Re: r347588 - Revert "[clang][slh] add attribute for speculative load hardening"

2018-12-03 Thread David Blaikie via cfe-commits
Also, including the SVN revision (llvm's util/git-svn/git-svnrevert script
can help with this) is helpful for other folks following along who may not
be using git.

On Mon, Nov 26, 2018 at 12:19 PM Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Mon, Nov 26, 2018 at 3:13 PM Zola Bridges via cfe-commits
>  wrote:
> >
> > Author: zbrid
> > Date: Mon Nov 26 12:11:18 2018
> > New Revision: 347588
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=347588=rev
> > Log:
> > Revert "[clang][slh] add attribute for speculative load hardening"
> >
> > This reverts commit 801eaf91221ba6dd6996b29ff82659ad6359e885.
>
> Next time you revert something, can you add an explanation as to why
> it was reverted into the commit message? It helps when doing code
> archaeology.
>
> Thanks!
>
> ~Aaron
>
> >
> > Removed:
> > cfe/trunk/test/CodeGen/attr-speculative-load-hardening.cpp
> > cfe/trunk/test/CodeGen/attr-speculative-load-hardening.m
> > cfe/trunk/test/SemaCXX/attr-speculative-load-hardening.cpp
> > Modified:
> > cfe/trunk/include/clang/Basic/Attr.td
> > cfe/trunk/include/clang/Basic/AttrDocs.td
> > cfe/trunk/lib/CodeGen/CGCall.cpp
> > cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> >
> > Modified: cfe/trunk/include/clang/Basic/Attr.td
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=347588=347587=347588=diff
> >
> ==
> > --- cfe/trunk/include/clang/Basic/Attr.td (original)
> > +++ cfe/trunk/include/clang/Basic/Attr.td Mon Nov 26 12:11:18 2018
> > @@ -3091,9 +3091,3 @@ def AlwaysDestroy : InheritableAttr {
> >let Subjects = SubjectList<[Var]>;
> >let Documentation = [AlwaysDestroyDocs];
> >  }
> > -
> > -def SpeculativeLoadHardening : InheritableAttr {
> > -  let Spellings = [Clang<"speculative_load_hardening">];
> > -  let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
> > -  let Documentation = [SpeculativeLoadHardeningDocs];
> > -}
> >
> > Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=347588=347587=347588=diff
> >
> ==
> > --- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
> > +++ cfe/trunk/include/clang/Basic/AttrDocs.td Mon Nov 26 12:11:18 2018
> > @@ -3629,27 +3629,3 @@ GNU inline semantics are the default beh
> >  ``-std=c89``, ``-std=c94``, or ``-fgnu89-inline``.
> >}];
> >  }
> > -
> > -def SpeculativeLoadHardeningDocs : Documentation {
> > -  let Category = DocCatFunction;
> > -  let Content = [{
> > -  This attribute can be applied to a function declaration in order to
> indicate
> > -  that `Speculative Load Hardening <
> https://llvm.org/docs/SpeculativeLoadHardening.html>`_
> > -  should be enabled for the function body. This can also be applied to
> a method
> > -  in Objective C.
> > -
> > -  Speculative Load Hardening is a best-effort mitigation against
> > -  information leak attacks that make use of control flow
> > -  miss-speculation - specifically miss-speculation of whether a branch
> > -  is taken or not. Typically vulnerabilities enabling such attacks are
> > -  classified as "Spectre variant #1". Notably, this does not attempt to
> > -  mitigate against miss-speculation of branch target, classified as
> > -  "Spectre variant #2" vulnerabilities.
> > -
> > -  When inlining, the attribute is sticky. Inlining a function that
> > -  carries this attribute will cause the caller to gain the
> > -  attribute. This is intended to provide a maximally conservative model
> > -  where the code in a function annotated with this attribute will always
> > -  (even after inlining) end up hardened.
> > -  }];
> > -}
> >
> > Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=347588=347587=347588=diff
> >
> ==
> > --- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
> > +++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Nov 26 12:11:18 2018
> > @@ -1791,8 +1791,6 @@ void CodeGenModule::ConstructDefaultFnAt
> >  if (CodeGenOpts.Backchain)
> >FuncAttrs.addAttribute("backchain");
> >
> > -// FIXME: The interaction of this attribute with the SLH command
> line flag
> > -// has not been determined.
> >  if (CodeGenOpts.SpeculativeLoadHardening)
> >FuncAttrs.addAttribute(llvm::Attribute::SpeculativeLoadHardening);
> >}
> > @@ -1856,8 +1854,6 @@ void CodeGenModule::ConstructAttributeLi
> >FuncAttrs.addAttribute(llvm::Attribute::NoDuplicate);
> >  if (TargetDecl->hasAttr())
> >FuncAttrs.addAttribute(llvm::Attribute::Convergent);
> > -if (TargetDecl->hasAttr())
> > -  FuncAttrs.addAttribute(llvm::Attribute::SpeculativeLoadHardening);
> >
> >  if (const FunctionDecl 

[PATCH] D55151: [gcov/Darwin] Ensure external symbols are exported when using an export list

2018-12-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348187: [gcov/Darwin] Ensure external symbols are exported 
when using an export list (authored by vedantk, committed by ).
Herald added subscribers: llvm-commits, delcypher.

Changed prior to commit:
  https://reviews.llvm.org/D55151?vs=176217=176458#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55151

Files:
  cfe/trunk/include/clang/Driver/ToolChain.h
  cfe/trunk/lib/Driver/ToolChain.cpp
  cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
  cfe/trunk/test/Driver/darwin-ld.c
  compiler-rt/trunk/test/profile/instrprof-darwin-exports.c

Index: cfe/trunk/include/clang/Driver/ToolChain.h
===
--- cfe/trunk/include/clang/Driver/ToolChain.h
+++ cfe/trunk/include/clang/Driver/ToolChain.h
@@ -381,6 +381,9 @@
   /// needsProfileRT - returns true if instrumentation profile is on.
   static bool needsProfileRT(const llvm::opt::ArgList );
 
+  /// Returns true if gcov instrumentation (-fprofile-arcs or --coverage) is on.
+  static bool needsGCovInstrumentation(const llvm::opt::ArgList );
+
   /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables
   /// by default.
   virtual bool IsUnwindTablesDefault(const llvm::opt::ArgList ) const;
Index: cfe/trunk/test/Driver/darwin-ld.c
===
--- cfe/trunk/test/Driver/darwin-ld.c
+++ cfe/trunk/test/Driver/darwin-ld.c
@@ -341,10 +341,22 @@
 // RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
 // PROFILE_EXPORT: "-exported_symbol" "___llvm_profile_filename" "-exported_symbol" "___llvm_profile_raw_version" "-exported_symbol" "_lprofCurFilename"
 //
-// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate -### %t.o 2> %t.log
+// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate --coverage -### %t.o 2> %t.log
 // RUN: FileCheck -check-prefix=NO_PROFILE_EXPORT %s < %t.log
 // NO_PROFILE_EXPORT-NOT: "-exported_symbol"
 //
+// RUN: %clang -target x86_64-apple-darwin12 --coverage -exported_symbols_list /dev/null -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=GCOV_EXPORT %s < %t.log
+// RUN: %clang -target x86_64-apple-darwin12 -fprofile-arcs -Wl,-exported_symbols_list,/dev/null -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=GCOV_EXPORT %s < %t.log
+// RUN: %clang -target x86_64-apple-darwin12 -fprofile-arcs -Wl,-exported_symbol,foo -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=GCOV_EXPORT %s < %t.log
+// RUN: %clang -target x86_64-apple-darwin12 -fprofile-arcs -Xlinker -exported_symbol -Xlinker foo -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=GCOV_EXPORT %s < %t.log
+// RUN: %clang -target x86_64-apple-darwin12 -fprofile-arcs -Xlinker -exported_symbols_list -Xlinker /dev/null -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=GCOV_EXPORT %s < %t.log
+// GCOV_EXPORT: "-exported_symbol" "___gcov_flush"
+//
 // Check that we can pass the outliner down to the linker.
 // RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
 // RUN:   %clang -target arm64-apple-darwin -moutline -### %t.o 2> %t.log
Index: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
@@ -1034,11 +1034,17 @@
   // runtime, automatically export symbols necessary to implement some of the
   // runtime's functionality.
   if (hasExportSymbolDirective(Args)) {
-addExportedSymbol(CmdArgs, "___llvm_profile_filename");
-addExportedSymbol(CmdArgs, "___llvm_profile_raw_version");
-addExportedSymbol(CmdArgs, "_lprofCurFilename");
+if (needsGCovInstrumentation(Args)) {
+  addExportedSymbol(CmdArgs, "___gcov_flush");
+  addExportedSymbol(CmdArgs, "_flush_fn_list");
+  addExportedSymbol(CmdArgs, "_writeout_fn_list");
+} else {
+  addExportedSymbol(CmdArgs, "___llvm_profile_filename");
+  addExportedSymbol(CmdArgs, "___llvm_profile_raw_version");
+  addExportedSymbol(CmdArgs, "_lprofCurFilename");
+  addExportedSymbol(CmdArgs, "_lprofMergeValueProfData");
+}
 addExportedSymbol(CmdArgs, "_lprofDirMode");
-addExportedSymbol(CmdArgs, "_lprofMergeValueProfData");
   }
 }
 
Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -403,19 +403,23 @@
 }
 
 bool ToolChain::needsProfileRT(const ArgList ) {
-  if (Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs,
-   false) ||
+  if (needsGCovInstrumentation(Args) ||
   Args.hasArg(options::OPT_fprofile_generate) ||
   Args.hasArg(options::OPT_fprofile_generate_EQ) ||
   Args.hasArg(options::OPT_fprofile_instr_generate) ||
   

r348187 - [gcov/Darwin] Ensure external symbols are exported when using an export list

2018-12-03 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Mon Dec  3 12:53:58 2018
New Revision: 348187

URL: http://llvm.org/viewvc/llvm-project?rev=348187=rev
Log:
[gcov/Darwin] Ensure external symbols are exported when using an export list

Make sure that symbols needed to implement runtime support for gcov are
exported when using an export list on Darwin.

Without the clang driver exporting these symbols, the linker hides them,
resulting in tapi verification failures.

rdar://45944768

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

Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/test/Driver/darwin-ld.c

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=348187=348186=348187=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Mon Dec  3 12:53:58 2018
@@ -381,6 +381,9 @@ public:
   /// needsProfileRT - returns true if instrumentation profile is on.
   static bool needsProfileRT(const llvm::opt::ArgList );
 
+  /// Returns true if gcov instrumentation (-fprofile-arcs or --coverage) is 
on.
+  static bool needsGCovInstrumentation(const llvm::opt::ArgList );
+
   /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables
   /// by default.
   virtual bool IsUnwindTablesDefault(const llvm::opt::ArgList ) const;

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=348187=348186=348187=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Mon Dec  3 12:53:58 2018
@@ -403,19 +403,23 @@ std::string ToolChain::getArchSpecificLi
 }
 
 bool ToolChain::needsProfileRT(const ArgList ) {
-  if (Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs,
-   false) ||
+  if (needsGCovInstrumentation(Args) ||
   Args.hasArg(options::OPT_fprofile_generate) ||
   Args.hasArg(options::OPT_fprofile_generate_EQ) ||
   Args.hasArg(options::OPT_fprofile_instr_generate) ||
   Args.hasArg(options::OPT_fprofile_instr_generate_EQ) ||
-  Args.hasArg(options::OPT_fcreate_profile) ||
-  Args.hasArg(options::OPT_coverage))
+  Args.hasArg(options::OPT_fcreate_profile))
 return true;
 
   return false;
 }
 
+bool ToolChain::needsGCovInstrumentation(const llvm::opt::ArgList ) {
+  return Args.hasFlag(options::OPT_fprofile_arcs, 
options::OPT_fno_profile_arcs,
+  false) ||
+ Args.hasArg(options::OPT_coverage);
+}
+
 Tool *ToolChain::SelectTool(const JobAction ) const {
   if (getDriver().ShouldUseClangCompiler(JA)) return getClang();
   Action::ActionClass AC = JA.getKind();

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=348187=348186=348187=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Mon Dec  3 12:53:58 2018
@@ -1034,11 +1034,17 @@ void Darwin::addProfileRTLibs(const ArgL
   // runtime, automatically export symbols necessary to implement some of the
   // runtime's functionality.
   if (hasExportSymbolDirective(Args)) {
-addExportedSymbol(CmdArgs, "___llvm_profile_filename");
-addExportedSymbol(CmdArgs, "___llvm_profile_raw_version");
-addExportedSymbol(CmdArgs, "_lprofCurFilename");
+if (needsGCovInstrumentation(Args)) {
+  addExportedSymbol(CmdArgs, "___gcov_flush");
+  addExportedSymbol(CmdArgs, "_flush_fn_list");
+  addExportedSymbol(CmdArgs, "_writeout_fn_list");
+} else {
+  addExportedSymbol(CmdArgs, "___llvm_profile_filename");
+  addExportedSymbol(CmdArgs, "___llvm_profile_raw_version");
+  addExportedSymbol(CmdArgs, "_lprofCurFilename");
+  addExportedSymbol(CmdArgs, "_lprofMergeValueProfData");
+}
 addExportedSymbol(CmdArgs, "_lprofDirMode");
-addExportedSymbol(CmdArgs, "_lprofMergeValueProfData");
   }
 }
 

Modified: cfe/trunk/test/Driver/darwin-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-ld.c?rev=348187=348186=348187=diff
==
--- cfe/trunk/test/Driver/darwin-ld.c (original)
+++ cfe/trunk/test/Driver/darwin-ld.c Mon Dec  3 12:53:58 2018
@@ -341,10 +341,22 @@
 // RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
 // PROFILE_EXPORT: "-exported_symbol" "___llvm_profile_filename" 
"-exported_symbol" "___llvm_profile_raw_version" "-exported_symbol" 
"_lprofCurFilename"
 //
-// RUN: %clang -target x86_64-apple-darwin12 

[PATCH] D55190: Move dump of individual comment nodes to NodeDumper

2018-12-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Looks reasonable, but similar to D55189 , can 
more of the implementation be pushed into a .cpp file rather than left in a 
header?


Repository:
  rC Clang

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

https://reviews.llvm.org/D55190



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


[PATCH] D55212: Handle alloc_size attribute on function pointers

2018-12-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/Attr.td:1072
 def AllocSize : InheritableAttr {
   let Spellings = [GCC<"alloc_size">];
+  let Subjects = SubjectList<[HasFunctionProto]>;

arichardson wrote:
> aaron.ballman wrote:
> > arichardson wrote:
> > > aaron.ballman wrote:
> > > > Does GCC support writing `alloc_size` on function pointers?
> > > Yes it does and it seems to be used by some projects. I first discovered 
> > > this while compiling libxml2: 
> > > https://github.com/GNOME/libxml2/blob/35e83488505d501864826125cfe6a7950d6cba78/include/libxml/xmlmemory.h#L66
> > Parsed and ignored is different than supported. For instance, I can't seem 
> > to get GCC to produce different behavior here: https://godbolt.org/z/MI5k_m
> > 
> > Am I missing something?
> Ah yes, it does seem like it is ignored. I assumed it would work for GCC 
> since it handles, e.g. the format attribute on function pointers.
> 
> However, I would like it if we could support it on function pointers even if 
> GCC just ignores is.
> However, I would like it if we could support it on function pointers even if 
> GCC just ignores is.

We can, but the question is: under what spelling(s)? I think we can support 
this under `__attribute__((alloc_size(N)))` without issue. If GCC is looking to 
implement this same behavior, then I think we can also support it under 
`[[gnu::alloc_size(N)]]`.

If GCC doesn't have plans to add this functionality any time soon, we'd be 
stepping on their implementation namespace by implementing this functionality 
under the gnu vendor namespace and users would then be confused as to whose bug 
it is. In that case, I'd recommend we add `[[clang::alloc_size(N)]]` that 
behaves identically to `[[gnu::alloc_size(N)]]' except that it can be applied 
to function pointer types, and not change the behavior of 
`[[gnu::alloc_size(N)]]`. This can be implemented as a single semantic 
attribute by looking at the semantic spelling of the attribute and issuing a 
compatibility warning if you see `[[gnu::alloc_size(N)]]` being applied to a 
function pointer type, and can even recommend a fix-it to switch to 
`[[clang::alloc_size(N)]]` in that case. (See uses of `getSemanticSpelling()` 
elsewhere in the project for examples of how to test which spelling a given 
sematic attribute was spelled with.)


Repository:
  rC Clang

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

https://reviews.llvm.org/D55212



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


[PATCH] D55134: [CTU] Add triple/lang mismatch handling

2018-12-03 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin accepted this revision.
a_sidorin added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D55134



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


r348184 - Portable Python script across Python version

2018-12-03 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Mon Dec  3 12:26:51 2018
New Revision: 348184

URL: http://llvm.org/viewvc/llvm-project?rev=348184=rev
Log:
Portable Python script across Python version

Workaround naming and hierarchy changes in BaseHTTPServer and SimpleHTTPServer 
module.

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

Modified:
cfe/trunk/tools/scan-view/share/ScanView.py

Modified: cfe/trunk/tools/scan-view/share/ScanView.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/share/ScanView.py?rev=348184=348183=348184=diff
==
--- cfe/trunk/tools/scan-view/share/ScanView.py (original)
+++ cfe/trunk/tools/scan-view/share/ScanView.py Mon Dec  3 12:26:51 2018
@@ -1,5 +1,8 @@
-import BaseHTTPServer
-import SimpleHTTPServer
+try:
+from http.server import HTTPServer, SimpleHTTPRequestHandler
+except ImportError:
+from BaseHTTPServer import HTTPServer
+from SimpleHTTPServer import SimpleHTTPRequestHandler
 import os
 import sys
 import urllib, urlparse
@@ -112,9 +115,9 @@ class ReporterThread(threading.Thread):
 print >>s,''
 self.status = s.getvalue()
 
-class ScanViewServer(BaseHTTPServer.HTTPServer):
+class ScanViewServer(HTTPServer):
 def __init__(self, address, handler, root, reporters, options):
-BaseHTTPServer.HTTPServer.__init__(self, address, handler)
+HTTPServer.__init__(self, address, handler)
 self.root = root
 self.reporters = reporters
 self.options = options
@@ -170,7 +173,7 @@ class ScanViewServer(BaseHTTPServer.HTTP
 if self.options.autoReload:
 import ScanView
 self.RequestHandlerClass = reload(ScanView).ScanViewRequestHandler
-BaseHTTPServer.HTTPServer.finish_request(self, request, client_address)
+HTTPServer.finish_request(self, request, client_address)
 
 def handle_error(self, request, client_address):
 # Ignore socket errors
@@ -179,7 +182,7 @@ class ScanViewServer(BaseHTTPServer.HTTP
 if self.options.debug > 1:
 print >>sys.stderr, "%s: SERVER: ignored socket error." % 
(sys.argv[0],)
 return
-BaseHTTPServer.HTTPServer.handle_error(self, request, client_address)
+HTTPServer.handle_error(self, request, client_address)
 
 # Borrowed from Quixote, with simplifications.
 def parse_query(qs, fields=None):
@@ -200,19 +203,19 @@ def parse_query(qs, fields=None):
 item.append(value)
 return fields
 
-class ScanViewRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
+class ScanViewRequestHandler(SimpleHTTPRequestHandler):
 server_version = "ScanViewServer/" + __version__
 dynamic_mtime = time.time()
 
 def do_HEAD(self):
 try:
-SimpleHTTPServer.SimpleHTTPRequestHandler.do_HEAD(self)
+SimpleHTTPRequestHandler.do_HEAD(self)
 except Exception as e:
 self.handle_exception(e)
 
 def do_GET(self):
 try:
-SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
+SimpleHTTPRequestHandler.do_GET(self)
 except Exception as e:
 self.handle_exception(e)
 


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


[PATCH] D55229: [COFF, ARM64] Make -flto-visibility-public-std a driver and cc1 flag

2018-12-03 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

In D55229#1317232 , @pcc wrote:

> The reason why it has that name is that it was originally added to support 
> the logic here: 
> http://llvm-cs.pcc.me.uk/tools/clang/lib/CodeGen/CGVTables.cpp#991
>
> It looks like it was later repurposed as a "was /MT passed to the driver" 
> flag when the logic was added to mark runtime functions as dllimport 
> depending on the value of the flag.
>
> It certainly seems to make sense to rename it since the name makes no sense 
> as a driver flag and is now being used for other purposes.


How about calling it -fmsvc-static-link?


Repository:
  rC Clang

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

https://reviews.llvm.org/D55229



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


[PATCH] D55189: Extract TextNodeDumper class

2018-12-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Basically looking good, modulo namespace questions from D55188 
 and a few other organizational questions.




Comment at: include/clang/AST/ASTTextNodeDumper.h:1
+//===--- ASTTextNodeDumper.h - Printing of AST nodes 
--===//
+//

Perhaps the file should be named `TextNodeDumper.h` to match the class name?



Comment at: include/clang/AST/ASTTextNodeDumper.h:44
+
+  void dumpPointer(const void *Ptr) {
+ColorScope Color(OS, ShowColors, AddressColor);

Should these implementations live in the header file? I feel like they belong 
in a .cpp file instead.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55189



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


[PATCH] D55212: Handle alloc_size attribute on function pointers

2018-12-03 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson marked an inline comment as done.
arichardson added a comment.

Thanks for the review! I'll write a C++ test tomorrow.




Comment at: include/clang/Basic/Attr.td:1072
 def AllocSize : InheritableAttr {
   let Spellings = [GCC<"alloc_size">];
+  let Subjects = SubjectList<[HasFunctionProto]>;

aaron.ballman wrote:
> arichardson wrote:
> > aaron.ballman wrote:
> > > Does GCC support writing `alloc_size` on function pointers?
> > Yes it does and it seems to be used by some projects. I first discovered 
> > this while compiling libxml2: 
> > https://github.com/GNOME/libxml2/blob/35e83488505d501864826125cfe6a7950d6cba78/include/libxml/xmlmemory.h#L66
> Parsed and ignored is different than supported. For instance, I can't seem to 
> get GCC to produce different behavior here: https://godbolt.org/z/MI5k_m
> 
> Am I missing something?
Ah yes, it does seem like it is ignored. I assumed it would work for GCC since 
it handles, e.g. the format attribute on function pointers.

However, I would like it if we could support it on function pointers even if 
GCC just ignores is.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55212



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


[PATCH] D55229: [COFF, ARM64] Make -flto-visibility-public-std a driver and cc1 flag

2018-12-03 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

The reason why it has that name is that it was originally added to support the 
logic here: http://llvm-cs.pcc.me.uk/tools/clang/lib/CodeGen/CGVTables.cpp#991

It looks like it was later repurposed as a "was /MT passed to the driver" flag 
when the logic was added to mark runtime functions as dllimport depending on 
the value of the flag.

It certainly seems to make sense to rename it since the name makes no sense as 
a driver flag and is now being used for other purposes.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55229



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


r348182 - Portable Python script across Python version

2018-12-03 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Mon Dec  3 12:12:34 2018
New Revision: 348182

URL: http://llvm.org/viewvc/llvm-project?rev=348182=rev
Log:
Portable Python script across Python version

Python2 supports both backticks and `repr` to access the __repr__ slot. Python3 
only supports `repr`.

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

Modified:
cfe/trunk/tools/scan-view/share/ScanView.py

Modified: cfe/trunk/tools/scan-view/share/ScanView.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/share/ScanView.py?rev=348182=348181=348182=diff
==
--- cfe/trunk/tools/scan-view/share/ScanView.py (original)
+++ cfe/trunk/tools/scan-view/share/ScanView.py Mon Dec  3 12:12:34 2018
@@ -544,7 +544,7 @@ Line: %s
 """%(r.getName(),display,r.getName(),options))
 reporterSelections = '\n'.join(reporterSelections)
 reporterOptionsDivs = '\n'.join(reporterOptions)
-reportersArray = '[%s]'%(','.join([`r.getName()` for r in 
self.server.reporters]))
+reportersArray = '[%s]'%(','.join([repr(r.getName()) for r in 
self.server.reporters]))
 
 if c.files:
 fieldSize = min(5, len(c.files))


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


[PATCH] D55229: [COFF, ARM64] Make -flto-visibility-public-std a driver and cc1 flag

2018-12-03 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

FWIW, I don't see how this patch is related to ARM64 (the subject/tag of the 
patch). Using that for the test probably is fine as it can use any 
architecture, although an x86 one probably would increase the chances of it 
getting run by everyone.

I don't have much input on the rest of it, although the name of this flag has 
puzzled me also when I've run into it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55229



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


[PATCH] D55188: Extract TextChildDumper class

2018-12-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/AST/ASTDumperUtils.h:22
+
+namespace ast_dumper {
+// Colors used for various parts of the AST dump

steveire wrote:
> aaron.ballman wrote:
> > steveire wrote:
> > > aaron.ballman wrote:
> > > > I'm not certain this namespace is useful, especially when it gets 
> > > > imported at TU scope in ASTDumper.cpp.
> > > > it gets imported at TU scope in ASTDumper.cpp
> > > 
> > > Today that's the only place it is used. In the future that won't be true.
> > Then we can add the namespace in the future when we find a situation where 
> > we're worried about collisions? As it stands, this only provides the 
> > illusion of safety. If you really want to keep it, please pull the global 
> > using declaration.
> There is no need for such churn as adding the namespace later.
> 
> The `using` I added is beside two other `using`s in a cpp file. There is 
> nothing 'global' about it.
> The using I added is beside two other usings in a cpp file. There is nothing 
> 'global' about it.

It applies to the entire TU, so it's global as far as this compilation unit is 
concerned. The existing "clang" and "llvm" using declarations are a pervasive 
thing we do but is not the general rule for how we use namespaces. See 
https://llvm.org/docs/CodingStandards.html#do-not-use-using-namespace-std for 
more details.

I think the idea of an ast dumping namespace is worth exploring, but is 
orthogonal to this NFC patch. If you'd like to propose putting all AST dumping 
functionality into its own namespace, then please propose it as a separate 
patch so that we don't bog this one down with discussion that's not really 
germane to the rest of your patch. Questions I would love to see answered in 
that review are: why is a namespace needed, what should go into it (for 
instance, does ast printing go there, or just ast dumping, or all ast output 
utilities, etc), and whether it's planned to be used outside of its 
implementation file(s).

Alternatively, if you think this is germane to this patch, we can have that 
discussion here.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55188



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


  1   2   3   >