[PATCH] D40671: [clang-tidy] Support specific checks for NOLINT directive

2017-12-02 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: docs/ReleaseNotes.rst:259
 
+- The ``NOLINT`` and ``NOLINTNEXTLINE`` suppression comments were extended to 
support the list of checks
+  to disable in parentheses.

This reads strange, maybe it can be reworded somehow?


https://reviews.llvm.org/D40671



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


[PATCH] D40671: [clang-tidy] Support specific checks for NOLINT directive

2017-12-02 Thread Anton via Phabricator via cfe-commits
xgsa updated this revision to Diff 125258.
xgsa added a comment.

Release note item was reworded


https://reviews.llvm.org/D40671

Files:
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/nolint.cpp
  test/clang-tidy/nolintnextline.cpp

Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -250,6 +250,27 @@
   value:   'some value'
   ...
 
+Generally, there is no need to suppress :program:`clang-tidy` diagnostics. If
+there are false positives, either a bug should be reported or the code should be
+updated to be clear for both tool and developer. However, if there is a need to
+silent some diagnostics for a line of code, the ``NOLINT`` or ``NOLINTNEXTLINE``
+comments can be used. For example:
+
+.. code-block:: c++
+
+  class Foo
+  {
+// Skip all the diagnostics for the line
+Foo(int param); // NOLINT
+
+// Skip only the specified checks for the line
+Foo(double param); // NOLINT(google-explicit-constructor, google-runtime-int)
+
+// Skip only the specified diagnostics for the next line
+// NOLINTNEXTLINE (google-explicit-constructor, google-runtime-int)
+Foo(bool param); 
+  };
+
 .. _LibTooling: http://clang.llvm.org/docs/LibTooling.html
 .. _How To Setup Tooling For LLVM: http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
 
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -256,6 +256,9 @@
   - `hicpp-use-nullptr `_
   - `hicpp-vararg `_
 
+- Added an ability to specify in parentheses the list of checks to suppress for the ``NOLINT`` 
+  and ``NOLINTNEXTLINE`` comments.
+
 Improvements to include-fixer
 -
 
Index: test/clang-tidy/nolint.cpp
===
--- test/clang-tidy/nolint.cpp
+++ test/clang-tidy/nolint.cpp
@@ -13,7 +13,18 @@
 
 class B { B(int i); }; // NOLINT
 
-class C { C(int i); }; // NOLINT(we-dont-care-about-categories-yet)
+class C { C(int i); }; // NOLINT(for-some-other-check)
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+class C1 { C1(int i); }; // NOLINT(*)
+
+class C2 { C2(int i); }; // NOLINT(not-closed-bracket-is-treated-as-skip-all
+
+class C3 { C3(int i); }; // NOLINT(google-explicit-constructor)
+
+class C4 { C4(int i); }; // NOLINT(some-check, google-explicit-constructor)
+
+class C5 { C5(int i); }; // NOLINT without-brackets-skip-all, another-check
 
 void f() {
   int i;
@@ -35,4 +46,4 @@
 #define DOUBLE_MACRO MACRO(H) // NOLINT
 DOUBLE_MACRO
 
-// CHECK-MESSAGES: Suppressed 8 warnings (8 NOLINT)
+// CHECK-MESSAGES: Suppressed 12 warnings (12 NOLINT)
Index: test/clang-tidy/nolintnextline.cpp
===
--- test/clang-tidy/nolintnextline.cpp
+++ test/clang-tidy/nolintnextline.cpp
@@ -4,8 +4,24 @@
 // NOLINTNEXTLINE
 class B { B(int i); };
 
-// NOLINTNEXTLINE(we-dont-care-about-categories-yet)
+// NOLINTNEXTLINE(for-some-other-check)
 class C { C(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+// NOLINTNEXTLINE(*)
+class C1 { C1(int i); };
+
+// NOLINTNEXTLINE(not-closed-bracket-is-treated-as-skip-all
+class C2 { C2(int i); };
+
+// NOLINTNEXTLINE(google-explicit-constructor)
+class C3 { C3(int i); };
+
+// NOLINTNEXTLINE(some-check, google-explicit-constructor)
+class C4 { C4(int i); };
+
+// NOLINTNEXTLINE without-brackets-skip-all, another-check
+class C5 { C5(int i); };
 
 
 // NOLINTNEXTLINE
@@ -28,6 +44,6 @@
 // NOLINTNEXTLINE
 MACRO_NOARG
 
-// CHECK-MESSAGES: Suppressed 4 warnings (4 NOLINT)
+// CHECK-MESSAGES: Suppressed 8 warnings (8 NOLINT)
 
 // RUN: %check_clang_tidy %s google-explicit-constructor %t --
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -21,6 +21,7 @@
 #include "clang/AST/ASTDiagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Frontend/DiagnosticRenderer.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include 
 #include 
@@ -290,7 +291,38 @@
   LastErrorPassesLineFilter = false;
 }
 
-static bool LineIsMarkedWithNOLINT(SourceManager &SM, SourceLocation Loc) {
+static bool IsNOLINTFound(StringRef NolintMacro, StringRef Line,
+  unsigned DiagID, const ClangTidyContext &Context) {
+  const size_t NolintIndex = Line.find(NolintMacro);
+  if (NolintIndex != StringRef::npos) {
+size_t BracketIndex = Noli

[PATCH] D40739: Pass through --undefined to Wasm LLD

2017-12-02 Thread Nicholas Wilson via Phabricator via cfe-commits
ncw added a comment.

I'm glad to be involved in a small way. Our company uses Emscripten in one of 
our products, and some of our employees were early contributors to Emscripten 
years ago, when they were trying to get C++ working. Now I've been allowed to 
spend a few weeks "investigating" Wasm, then I'll have to get back to my normal 
work on our product. I hope short-term contributors like me don't add too much 
burden.

I'm also really impressed with Wasm, the whole design, tooling and project is 
coming along really well and should provide an excellent foundation for web 
projects.

Regarding this patch - can we get away without a test...? I can confirm that 
I've just done a manual test, and the argument is correctly passed down to LLD. 
Plus the line was simply copied from the existing toolchains.


Repository:
  rC Clang

https://reviews.llvm.org/D40739



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


[PATCH] D40671: [clang-tidy] Support specific checks for NOLINT directive

2017-12-02 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Its good that you added code examples to the clang-tidy documentation page. I 
think that feature was not documented well before.




Comment at: test/clang-tidy/nolintnextline.cpp:23
+
+// NOLINTNEXTLINE without-brackets-skip-all, another-check
+class C5 { C5(int i); };

Ian confused now. The NOLINTNEXTLINE with incorrect parents should not silence 
the diagnostic, should it? 

In my understanding the following line should cause the explicit constructor 
check to warn. Is that check message missing or did I get something wrong?


https://reviews.llvm.org/D40671



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


[PATCH] D40671: [clang-tidy] Support specific checks for NOLINT directive

2017-12-02 Thread Anton via Phabricator via cfe-commits
xgsa added inline comments.



Comment at: test/clang-tidy/nolintnextline.cpp:23
+
+// NOLINTNEXTLINE without-brackets-skip-all, another-check
+class C5 { C5(int i); };

JonasToth wrote:
> Ian confused now. The NOLINTNEXTLINE with incorrect parents should not 
> silence the diagnostic, should it? 
> 
> In my understanding the following line should cause the explicit constructor 
> check to warn. Is that check message missing or did I get something wrong?
Without parentheses, it works just as `NOLINTNEXTLINE` (i.e. suppresses all the 
diagnostics for line), because it's impossible to distinguish check names from 
user comments after `NOLINTNEXTLINE`:
```
// NOLINTNEXTLINE check-name, another-check
// NOLINTNEXTLINE Some description, why the suppression is added
```


https://reviews.llvm.org/D40671



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


[PATCH] D39430: [clangd] formatting: don't ignore style

2017-12-02 Thread Raoul Wols via Phabricator via cfe-commits
rwols updated this revision to Diff 125267.
rwols added a comment.
Herald added a subscriber: klimek.

- Merge with upstream revision 319613
- Fix FixItHints not getting applied correctly in all cases. The problem is 
that clang::CharSourceRange can either be a TokenRange or a CharRange. In the 
case of a TokenRange, we have to determine the end of the token ourselves (this 
would occur, for example, in things like `if (i=1) { ... }`; the fixit hint to 
replace `=` with `==` would be a TokenRange for some reason).

  Consequently, a tiny change had to be made to the fixits.test file, where the 
fixit hint to replace `=` with `==` would previously have an empty replacement 
range, whereas now it has a replacement range of length 1, exactly removing the 
`=` and inserting `==` in its place.

After playing around with these changes more I'm fairly certain I'm on the right
track for converting clang ranges/positions to clangd ranges/positions.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D39430

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/JSONRPCDispatcher.cpp
  clangd/JSONRPCDispatcher.h
  test/clangd/diagnostics.test
  test/clangd/execute-command.test
  test/clangd/extra-flags.test
  test/clangd/fixits.test

Index: test/clangd/fixits.test
===
--- test/clangd/fixits.test
+++ test/clangd/fixits.test
@@ -15,11 +15,11 @@
 # CHECK-NEXT:"message": "using the result of an assignment as a condition without parentheses",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
-# CHECK-NEXT:"character": 35,
+# CHECK-NEXT:"character": 34,
 # CHECK-NEXT:"line": 0
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "start": {
-# CHECK-NEXT:"character": 35,
+# CHECK-NEXT:"character": 34,
 # CHECK-NEXT:"line": 0
 # CHECK-NEXT:  }
 # CHECK-NEXT:},
@@ -29,11 +29,11 @@
 # CHECK-NEXT:"message": "place parentheses around the assignment to silence this warning",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
-# CHECK-NEXT:"character": 35,
+# CHECK-NEXT:"character": 34,
 # CHECK-NEXT:"line": 0
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "start": {
-# CHECK-NEXT:"character": 35,
+# CHECK-NEXT:"character": 34,
 # CHECK-NEXT:"line": 0
 # CHECK-NEXT:  }
 # CHECK-NEXT:},
@@ -43,11 +43,11 @@
 # CHECK-NEXT:"message": "use '==' to turn this assignment into an equality comparison",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
-# CHECK-NEXT:"character": 35,
+# CHECK-NEXT:"character": 34,
 # CHECK-NEXT:"line": 0
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "start": {
-# CHECK-NEXT:"character": 35,
+# CHECK-NEXT:"character": 34,
 # CHECK-NEXT:"line": 0
 # CHECK-NEXT:  }
 # CHECK-NEXT:},
@@ -58,7 +58,7 @@
 # CHECK-NEXT:  }
 Content-Length: 746
 
-{"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///foo.c"},"range":{"start":{"line":104,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":2,"message":"using the result of an assignment as a condition without parentheses"},{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":3,"message":"place parentheses around the assignment to silence this warning"},{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":3,"message":"use '==' to turn this assignment into an equality comparison"}]}}}
+{"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///foo.c"},"range":{"start":{"line":104,"character":13},"end":{"line":0,"character":34}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 34}, "end": {"line": 0, "character": 34}},"severity":2,"message":"using the result of an assignment as a condition without parentheses"},{"range":{"start": {"line": 0, "character": 34}, "end": {"line": 0, "character": 34}},"severity":3,"message":"place parentheses around the assignment to silence this warning"},{"range":{"start": {"line": 0, "character": 34}, "end": {"line": 0, "character": 34}},"severity":3,"message":"use '==' to turn this assignment into an equality comparison"}]}}}
 #  CHECK:  "id": 2,
 # CHECK-NEXT:  "jsonrpc": "2.0",
 # CHECK-NEXT:  "result": [
@@ -128,7 +128,7 @@
 # CHECK-NEXT:  ]
 Content-Length: 771
 
-{"jsonrpc":"2.0","id":3,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///foo.c"},"range":{"start":{"line":104,"cha

[PATCH] D40671: [clang-tidy] Support specific checks for NOLINT directive

2017-12-02 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: test/clang-tidy/nolintnextline.cpp:23
+
+// NOLINTNEXTLINE without-brackets-skip-all, another-check
+class C5 { C5(int i); };

xgsa wrote:
> JonasToth wrote:
> > Ian confused now. The NOLINTNEXTLINE with incorrect parents should not 
> > silence the diagnostic, should it? 
> > 
> > In my understanding the following line should cause the explicit 
> > constructor check to warn. Is that check message missing or did I get 
> > something wrong?
> Without parentheses, it works just as `NOLINTNEXTLINE` (i.e. suppresses all 
> the diagnostics for line), because it's impossible to distinguish check names 
> from user comments after `NOLINTNEXTLINE`:
> ```
> // NOLINTNEXTLINE check-name, another-check
> // NOLINTNEXTLINE Some description, why the suppression is added
> ```
Ah sure, that makes sense.


https://reviews.llvm.org/D40671



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


[PATCH] D40671: [clang-tidy] Support specific checks for NOLINT directive

2017-12-02 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

I am happy with everything now. But one of the reviewers must accept.


https://reviews.llvm.org/D40671



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


r319618 - [CodeGen] remove stale comment; NFC

2017-12-02 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Sat Dec  2 08:29:34 2017
New Revision: 319618

URL: http://llvm.org/viewvc/llvm-project?rev=319618&view=rev
Log:
[CodeGen] remove stale comment; NFC

The libm functions with LLVM intrinsic twins were moved above this blob with:
https://reviews.llvm.org/rL319593


Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=319618&r1=319617&r2=319618&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sat Dec  2 08:29:34 2017
@@ -1028,7 +1028,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   }
 
   switch (BuiltinID) {
-  default: break;  // Handle intrinsics and libm functions below.
+  default: break;
   case Builtin::BI__builtin___CFStringMakeConstantString:
   case Builtin::BI__builtin___NSStringMakeConstantString:
 return RValue::get(ConstantEmitter(*this).emitAbstract(E, E->getType()));


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


r319619 - [CodeGen] fix mapping from fmod calls to frem instruction

2017-12-02 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Sat Dec  2 09:52:00 2017
New Revision: 319619

URL: http://llvm.org/viewvc/llvm-project?rev=319619&view=rev
Log:
[CodeGen] fix mapping from fmod calls to frem instruction

Similar to D40044 and discussed in D40594.

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

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=319619&r1=319618&r2=319619&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sat Dec  2 09:52:00 2017
@@ -854,12 +854,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
Result.Val.getFloat()));
   }
 
-  // Math builtins have the same semantics as their math library twins.
-  // There are LLVM math intrinsics corresponding to math library functions
-  // except the intrinsic will never set errno while the math library might.
-  // Thus, we can transform math library and builtin calls to their
-  // semantically-equivalent LLVM intrinsic counterparts if the call is marked
-  // 'const' (it is known to never set errno).
+  // There are LLVM math intrinsics/instructions corresponding to math library
+  // functions except the LLVM op will never set errno while the math library
+  // might. Also, math builtins have the same semantics as their math library
+  // twins. Thus, we can transform math library and builtin calls to their
+  // LLVM counterparts if the call is marked 'const' (known to never set 
errno).
   if (FD->hasAttr()) {
 switch (BuiltinID) {
 case Builtin::BIceil:
@@ -942,6 +941,19 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 case Builtin::BI__builtin_fminl:
   return RValue::get(emitBinaryBuiltin(*this, E, Intrinsic::minnum));
 
+// fmod() is a special-case. It maps to the frem instruction rather than an
+// LLVM intrinsic.
+case Builtin::BIfmod:
+case Builtin::BIfmodf:
+case Builtin::BIfmodl:
+case Builtin::BI__builtin_fmod:
+case Builtin::BI__builtin_fmodf:
+case Builtin::BI__builtin_fmodl: {
+  Value *Arg1 = EmitScalarExpr(E->getArg(0));
+  Value *Arg2 = EmitScalarExpr(E->getArg(1));
+  return RValue::get(Builder.CreateFRem(Arg1, Arg2, "fmod"));
+}
+
 case Builtin::BIlog:
 case Builtin::BIlogf:
 case Builtin::BIlogl:
@@ -1067,14 +1079,6 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 
 return RValue::get(Result);
   }
-  case Builtin::BI__builtin_fmod:
-  case Builtin::BI__builtin_fmodf:
-  case Builtin::BI__builtin_fmodl: {
-Value *Arg1 = EmitScalarExpr(E->getArg(0));
-Value *Arg2 = EmitScalarExpr(E->getArg(1));
-Value *Result = Builder.CreateFRem(Arg1, Arg2, "fmod");
-return RValue::get(Result);
-  }
   case Builtin::BI__builtin_conj:
   case Builtin::BI__builtin_conjf:
   case Builtin::BI__builtin_conjl: {

Modified: cfe/trunk/test/CodeGen/math-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/math-builtins.c?rev=319619&r1=319618&r2=319619&view=diff
==
--- cfe/trunk/test/CodeGen/math-builtins.c (original)
+++ cfe/trunk/test/CodeGen/math-builtins.c Sat Dec  2 09:52:00 2017
@@ -6,12 +6,21 @@
 // Test attributes and codegen of math builtins.
 
 void foo(double *d, float f, float *fp, long double *l, int *i, const char *c) 
{
+  f = __builtin_fmod(f,f);f = __builtin_fmodf(f,f);   f =  
__builtin_fmodl(f,f);
+
+// NO__ERRNO: frem double
+// NO__ERRNO: frem float
+// NO__ERRNO: frem x86_fp80
+// HAS_ERRNO: declare double @fmod(double, double) [[NOT_READNONE:#[0-9]+]]
+// HAS_ERRNO: declare float @fmodf(float, float) [[NOT_READNONE]]
+// HAS_ERRNO: declare x86_fp80 @fmodl(x86_fp80, x86_fp80) [[NOT_READNONE]]
+
   __builtin_atan2(f,f);__builtin_atan2f(f,f) ;  __builtin_atan2l(f, f);
 
 // NO__ERRNO: declare double @atan2(double, double) [[READNONE:#[0-9]+]]
 // NO__ERRNO: declare float @atan2f(float, float) [[READNONE]]
 // NO__ERRNO: declare x86_fp80 @atan2l(x86_fp80, x86_fp80) [[READNONE]]
-// HAS_ERRNO: declare double @atan2(double, double) [[NOT_READNONE:#[0-9]+]]
+// HAS_ERRNO: declare double @atan2(double, double) [[NOT_READNONE]]
 // HAS_ERRNO: declare float @atan2f(float, float) [[NOT_READNONE]]
 // HAS_ERRNO: declare x86_fp80 @atan2l(x86_fp80, x86_fp80) [[NOT_READNONE]]
 
@@ -33,13 +42,6 @@ void foo(double *d, float f, float *fp,
 // HAS_ERRNO: declare float @llvm.fabs.f32(float) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare x86_fp80 @llvm.fabs.f80(x86_fp80) [[READNONE_INTRINSIC]]
 
-  __builtin_fmod(f,f); __builtin_fmodf(f,f);__builtin_fmodl(f,f);
-
-// NO__ERRNO-NOT: .fmod
-// NO__ERRNO-NOT: @fmod
-// HAS_ERRNO-NOT: .fmod
-// HAS_ERRNO-NOT: @fmod
-
   __builtin_frexp(f,i);__builtin_frexpf(f,i);   __builtin_frexp

[PATCH] D5767: Template Instantiation Observer + a few other templight-related changes

2017-12-02 Thread Ábel Sinkovics via Phabricator via cfe-commits
sabel83 updated this revision to Diff 125272.
sabel83 marked an inline comment as done.

https://reviews.llvm.org/D5767

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Frontend/FrontendActions.h
  include/clang/Frontend/FrontendOptions.h
  include/clang/FrontendTool/Utils.h
  include/clang/Sema/Sema.h
  include/clang/Sema/TemplateInstCallback.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendActions.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  lib/Parse/ParseAST.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/SemaType.cpp
  test/Templight/templight-deduced-func.cpp
  test/Templight/templight-default-arg-inst.cpp
  test/Templight/templight-default-func-arg.cpp
  test/Templight/templight-default-template-arg.cpp
  test/Templight/templight-exception-spec-func.cpp
  test/Templight/templight-explicit-template-arg.cpp
  test/Templight/templight-memoization.cpp
  test/Templight/templight-nested-memoization.cpp
  test/Templight/templight-nested-template-instantiation.cpp
  test/Templight/templight-one-instantiation.cpp
  test/Templight/templight-prior-template-arg.cpp

Index: test/Templight/templight-prior-template-arg.cpp
===
--- test/Templight/templight-prior-template-arg.cpp
+++ test/Templight/templight-prior-template-arg.cpp
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -templight-dump %s 2>&1 | FileCheck %s
+template
+class A {};
+
+template  class Outer>
+class B {};
+
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B::Outer'$}}
+// CHECK: {{^kind:[ ]+PriorTemplateArgumentSubstitution$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+50]]{{:1'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B::Outer'$}}
+// CHECK: {{^kind:[ ]+PriorTemplateArgumentSubstitution$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+45]]{{:1'$}}
+//
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+39]]{{:6'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+34]]{{:6'$}}
+//
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+28]]{{:6'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+23]]{{:6'$}}
+//
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+Memoization$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+17]]{{:6'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+Memoization$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+12]]{{:6'$}}
+//
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+Memoization$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+6]]{{:6'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+Memoization$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+1]]{{:6'$}}
+B b;
Index: test/Templight/templight-one-instantiation.cpp
===
--- test/Templight/templight-one-instantiation.cpp
+++ test/Templight/templight-one-instantiation.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -templight-dump %s 2>&1 | FileCheck %s
+
+template 
+struct foo {};
+
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'foo'$}}
+// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^poi:[ ]+'.*templight-one-instantiation.cpp:}}[[@LINE+6]]{{:10'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'foo'$}}
+// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^poi:[ ]+'.*templight-one-instantiation.cpp:}}[[@LINE+1]]{{:10'$}}
+foo x;
Index: test/Templight/templight-nested-template-instantiation.cpp
===
--- test/Templight/templight-nested-template-instantiation.cpp
+++ test/Templight/templight-nested-template-instantiation.cpp
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -templight-dump %s 2>&1 | FileCheck %s
+
+template 
+struct foo : foo {};
+
+template <>
+struct foo<0> {};
+
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'foo<2>'$}}
+// C

[PATCH] D5767: Template Instantiation Observer + a few other templight-related changes

2017-12-02 Thread Ábel Sinkovics via Phabricator via cfe-commits
sabel83 marked 2 inline comments as done.
sabel83 added a comment.

I have extended the context as suggested.


https://reviews.llvm.org/D5767



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


[PATCH] D39455: [CodeGen] Add initial support for union members in TBAA

2017-12-02 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added a comment.

Once you confirm the bug, could you possibly revert the patch?


Repository:
  rL LLVM

https://reviews.llvm.org/D39455



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


[PATCH] D39455: [CodeGen] Add initial support for union members in TBAA

2017-12-02 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D39455#943182, @aheejin wrote:

> Once you confirm the bug, could you possibly revert the patch?


I agree. We should revert this. The relevant part of the test case is:

  short *q;
  p->u.vec[i] = 0;
  q = &p->u.vec[16];
  *q = 1;
  return p->u.vec[i];

demonstrating that you can't use "union member" as the access type here. You 
need to use the actual access type, or something derived from it, because 
non-type-changing scalar accesses are still allowed to alias with the 
union-member accesses.


Repository:
  rL LLVM

https://reviews.llvm.org/D39455



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


[PATCH] D37903: Fix assume-filename handling in clang-format.el

2017-12-02 Thread Philipp via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC319621: Fix assume-filename handling in clang-format.el 
(authored by phst).

Changed prior to commit:
  https://reviews.llvm.org/D37903?vs=124242&id=125274#toc

Repository:
  rC Clang

https://reviews.llvm.org/D37903

Files:
  tools/clang-format/clang-format.el


Index: tools/clang-format/clang-format.el
===
--- tools/clang-format/clang-format.el
+++ tools/clang-format/clang-format.el
@@ -119,18 +119,23 @@
   (byte-to-position (1+ byte)
 
 ;;;###autoload
-(defun clang-format-region (start end &optional style)
+(defun clang-format-region (start end &optional style assume-file-name)
   "Use clang-format to format the code between START and END according to 
STYLE.
-If called interactively uses the region or the current statement if there
-is no active region.  If no style is given uses `clang-format-style'."
+If called interactively uses the region or the current statement if there is no
+no active region. If no STYLE is given uses `clang-format-style'. Use
+ASSUME-FILE-NAME to locate a style config file, if no ASSUME-FILE-NAME is given
+uses the function `buffer-file-name'."
   (interactive
(if (use-region-p)
(list (region-beginning) (region-end))
  (list (point) (point
 
   (unless style
 (setq style clang-format-style))
 
+  (unless assume-file-name
+(setq assume-file-name buffer-file-name))
+
   (let ((file-start (clang-format--bufferpos-to-filepos start 'approximate
 'utf-8-unix))
 (file-end (clang-format--bufferpos-to-filepos end 'approximate
@@ -144,16 +149,21 @@
 ;; always use ‘utf-8-unix’ and ignore the buffer coding system.
 (default-process-coding-system '(utf-8-unix . utf-8-unix)))
 (unwind-protect
-(let ((status (call-process-region
-   nil nil clang-format-executable
-   nil `(,temp-buffer ,temp-file) nil
-
-   "-output-replacements-xml"
-   "-assume-filename" (or (buffer-file-name) "")
-   "-style" style
-   "-offset" (number-to-string file-start)
-   "-length" (number-to-string (- file-end file-start))
-   "-cursor" (number-to-string cursor)))
+(let ((status (apply #'call-process-region
+ nil nil clang-format-executable
+ nil `(,temp-buffer ,temp-file) nil
+ `("-output-replacements-xml"
+   ;; Gaurd against a nil assume-file-name.
+   ;; If the clang-format option -assume-filename
+   ;; is given a blank string it will crash as per
+   ;; the following bug report
+   ;; https://bugs.llvm.org/show_bug.cgi?id=34667
+   ,@(and assume-file-name
+  (list "-assume-filename" 
assume-file-name))
+   "-style" ,style
+   "-offset" ,(number-to-string file-start)
+   "-length" ,(number-to-string (- file-end 
file-start))
+   "-cursor" ,(number-to-string cursor
   (stderr (with-temp-buffer
 (unless (zerop (cadr (insert-file-contents temp-file)))
   (insert ": "))
@@ -181,10 +191,13 @@
   (when (buffer-name temp-buffer) (kill-buffer temp-buffer)
 
 ;;;###autoload
-(defun clang-format-buffer (&optional style)
-  "Use clang-format to format the current buffer according to STYLE."
+(defun clang-format-buffer (&optional style assume-file-name)
+  "Use clang-format to format the current buffer according to STYLE.
+If no STYLE is given uses `clang-format-style'. Use ASSUME-FILE-NAME
+to locate a style config file. If no ASSUME-FILE-NAME is given uses
+the function `buffer-file-name'."
   (interactive)
-  (clang-format-region (point-min) (point-max) style))
+  (clang-format-region (point-min) (point-max) style assume-file-name))
 
 ;;;###autoload
 (defalias 'clang-format 'clang-format-region)


Index: tools/clang-format/clang-format.el
===
--- tools/clang-format/clang-format.el
+++ tools/clang-format/clang-format.el
@@ -119,18 +119,23 @@
   (byte-to-position (1+ byte)
 
 ;;;###autoload
-(defun clang-format-region (start end &optional style)
+(defun clang-format-region (start end &optional style assume-file-name)
   "Use clang-format to format the code between START and END according to STYLE.
-If called interactively uses the region or the current statement if there
-is no active region.  If no style is given uses `clang-format-style'

r319621 - Fix assume-filename handling in clang-format.el

2017-12-02 Thread Philipp Stephani via cfe-commits
Author: phst
Date: Sat Dec  2 13:18:14 2017
New Revision: 319621

URL: http://llvm.org/viewvc/llvm-project?rev=319621&view=rev
Log:
Fix assume-filename handling in clang-format.el

Summary:
When 'buffer-file-name' is nil 'call-process-region' returned a segmentation 
fault error.

This was a problem when using clang-format-buffer on an orgmode source code 
editing buffer.

I fixed this problem by excluding the '-assume-filename' argument when 
'buffer-file-name' is nil.

To make it a bit more flexible I also added an optional argument, 
'assume-file-name', to specify an assume-filename that overrides 
'buffer-file-name'.

Reviewers: klimek, djasper, phst, phi

Reviewed By: phst, phi

Subscribers: phi, jholewinski, mgorny, javed.absar, eraman, cfe-commits

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

Modified:
cfe/trunk/tools/clang-format/clang-format.el

Modified: cfe/trunk/tools/clang-format/clang-format.el
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format.el?rev=319621&r1=319620&r2=319621&view=diff
==
--- cfe/trunk/tools/clang-format/clang-format.el (original)
+++ cfe/trunk/tools/clang-format/clang-format.el Sat Dec  2 13:18:14 2017
@@ -119,10 +119,12 @@ is a zero-based file offset, assuming â
   (byte-to-position (1+ byte)
 
 ;;;###autoload
-(defun clang-format-region (start end &optional style)
+(defun clang-format-region (start end &optional style assume-file-name)
   "Use clang-format to format the code between START and END according to 
STYLE.
-If called interactively uses the region or the current statement if there
-is no active region.  If no style is given uses `clang-format-style'."
+If called interactively uses the region or the current statement if there is no
+no active region. If no STYLE is given uses `clang-format-style'. Use
+ASSUME-FILE-NAME to locate a style config file, if no ASSUME-FILE-NAME is given
+uses the function `buffer-file-name'."
   (interactive
(if (use-region-p)
(list (region-beginning) (region-end))
@@ -131,6 +133,9 @@ is no active region.  If no style is giv
   (unless style
 (setq style clang-format-style))
 
+  (unless assume-file-name
+(setq assume-file-name buffer-file-name))
+
   (let ((file-start (clang-format--bufferpos-to-filepos start 'approximate
 'utf-8-unix))
 (file-end (clang-format--bufferpos-to-filepos end 'approximate
@@ -144,16 +149,21 @@ is no active region.  If no style is giv
 ;; always use ‘utf-8-unix’ and ignore the buffer coding system.
 (default-process-coding-system '(utf-8-unix . utf-8-unix)))
 (unwind-protect
-(let ((status (call-process-region
-   nil nil clang-format-executable
-   nil `(,temp-buffer ,temp-file) nil
-
-   "-output-replacements-xml"
-   "-assume-filename" (or (buffer-file-name) "")
-   "-style" style
-   "-offset" (number-to-string file-start)
-   "-length" (number-to-string (- file-end file-start))
-   "-cursor" (number-to-string cursor)))
+(let ((status (apply #'call-process-region
+ nil nil clang-format-executable
+ nil `(,temp-buffer ,temp-file) nil
+ `("-output-replacements-xml"
+   ;; Gaurd against a nil assume-file-name.
+   ;; If the clang-format option -assume-filename
+   ;; is given a blank string it will crash as per
+   ;; the following bug report
+   ;; https://bugs.llvm.org/show_bug.cgi?id=34667
+   ,@(and assume-file-name
+  (list "-assume-filename" 
assume-file-name))
+   "-style" ,style
+   "-offset" ,(number-to-string file-start)
+   "-length" ,(number-to-string (- file-end 
file-start))
+   "-cursor" ,(number-to-string cursor
   (stderr (with-temp-buffer
 (unless (zerop (cadr (insert-file-contents temp-file)))
   (insert ": "))
@@ -181,10 +191,13 @@ is no active region.  If no style is giv
   (when (buffer-name temp-buffer) (kill-buffer temp-buffer)
 
 ;;;###autoload
-(defun clang-format-buffer (&optional style)
-  "Use clang-format to format the current buffer according to STYLE."
+(defun clang-format-buffer (&optional style assume-file-name)
+  "Use clang-format to format the current buffer according to STYLE.
+If no STYLE is given uses `clang-format-style'. Use ASSUME-FILE-NAME
+to locate a style config file. If no ASSUME-FILE-NAM

[PATCH] D40739: Pass through --undefined to Wasm LLD

2017-12-02 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

Sure I'll land this now.


Repository:
  rC Clang

https://reviews.llvm.org/D40739



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


r319623 - [WebAssembly] Pass through --undefined to Wasm LLD

2017-12-02 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Sat Dec  2 15:11:13 2017
New Revision: 319623

URL: http://llvm.org/viewvc/llvm-project?rev=319623&view=rev
Log:
[WebAssembly] Pass through --undefined to Wasm LLD

This is a follow-on to D40724 (Wasm entrypoint changes #1,
add `--undefined` argument to LLD).

Patch by Nicholas Wilson

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

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

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=319623&r1=319622&r2=319623&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Sat Dec  2 15:11:13 2017
@@ -47,6 +47,7 @@ void wasm::Linker::ConstructJob(Compilat
 CmdArgs.push_back("--strip-all");
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
+  Args.AddAllArgs(CmdArgs, options::OPT_u);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))


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


[PATCH] D40739: Pass through --undefined to Wasm LLD

2017-12-02 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC319623: [WebAssembly] Pass through --undefined to Wasm LLD 
(authored by sbc).

Repository:
  rC Clang

https://reviews.llvm.org/D40739

Files:
  lib/Driver/ToolChains/WebAssembly.cpp


Index: lib/Driver/ToolChains/WebAssembly.cpp
===
--- lib/Driver/ToolChains/WebAssembly.cpp
+++ lib/Driver/ToolChains/WebAssembly.cpp
@@ -47,6 +47,7 @@
 CmdArgs.push_back("--strip-all");
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
+  Args.AddAllArgs(CmdArgs, options::OPT_u);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))


Index: lib/Driver/ToolChains/WebAssembly.cpp
===
--- lib/Driver/ToolChains/WebAssembly.cpp
+++ lib/Driver/ToolChains/WebAssembly.cpp
@@ -47,6 +47,7 @@
 CmdArgs.push_back("--strip-all");
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
+  Args.AddAllArgs(CmdArgs, options::OPT_u);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r319629 - Revert "[CodeGen] Add initial support for union members in TBAA"

2017-12-02 Thread Hal Finkel via cfe-commits
Author: hfinkel
Date: Sat Dec  2 19:10:13 2017
New Revision: 319629

URL: http://llvm.org/viewvc/llvm-project?rev=319629&view=rev
Log:
Revert "[CodeGen] Add initial support for union members in TBAA"

This reverts commit r319413. See PR35503.

We can't use "union member" as the access type here like this.

Removed:
cfe/trunk/test/CodeGen/tbaa-union.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
cfe/trunk/lib/CodeGen/CodeGenTBAA.h
cfe/trunk/test/CodeGen/union-tbaa1.c

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=319629&r1=319628&r2=319629&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Sat Dec  2 19:10:13 2017
@@ -3723,6 +3723,9 @@ LValue CodeGenFunction::EmitLValueForFie
   if (base.getTBAAInfo().isMayAlias() ||
   rec->hasAttr() || FieldType->isVectorType()) {
 FieldTBAAInfo = TBAAAccessInfo::getMayAliasInfo();
+  } else if (rec->isUnion()) {
+// TODO: Support TBAA for unions.
+FieldTBAAInfo = TBAAAccessInfo::getMayAliasInfo();
   } else {
 // If no base type been assigned for the base access, then try to generate
 // one for this base lvalue.
@@ -3733,26 +3736,16 @@ LValue CodeGenFunction::EmitLValueForFie
"Nonzero offset for an access with no base type!");
 }
 
-// All union members are encoded to be of the same special type.
-if (FieldTBAAInfo.BaseType && rec->isUnion())
-  FieldTBAAInfo = 
TBAAAccessInfo::getUnionMemberInfo(FieldTBAAInfo.BaseType,
- FieldTBAAInfo.Offset,
- FieldTBAAInfo.Size);
-
-// For now we describe accesses to direct and indirect union members as if
-// they were at the offset of their outermost enclosing union.
-if (!FieldTBAAInfo.isUnionMember()) {
-  // Adjust offset to be relative to the base type.
-  const ASTRecordLayout &Layout =
-  getContext().getASTRecordLayout(field->getParent());
-  unsigned CharWidth = getContext().getCharWidth();
-  if (FieldTBAAInfo.BaseType)
-FieldTBAAInfo.Offset +=
-Layout.getFieldOffset(field->getFieldIndex()) / CharWidth;
+// Adjust offset to be relative to the base type.
+const ASTRecordLayout &Layout =
+getContext().getASTRecordLayout(field->getParent());
+unsigned CharWidth = getContext().getCharWidth();
+if (FieldTBAAInfo.BaseType)
+  FieldTBAAInfo.Offset +=
+  Layout.getFieldOffset(field->getFieldIndex()) / CharWidth;
 
-  // Update the final access type.
-  FieldTBAAInfo.AccessType = CGM.getTBAATypeInfo(FieldType);
-}
+// Update the final access type.
+FieldTBAAInfo.AccessType = CGM.getTBAATypeInfo(FieldType);
   }
 
   Address addr = base.getAddress();

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=319629&r1=319628&r2=319629&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Sat Dec  2 19:10:13 2017
@@ -688,9 +688,8 @@ public:
   /// getTBAAInfoForSubobject - Get TBAA information for an access with a given
   /// base lvalue.
   TBAAAccessInfo getTBAAInfoForSubobject(LValue Base, QualType AccessType) {
-TBAAAccessInfo TBAAInfo = Base.getTBAAInfo();
-if (TBAAInfo.isMayAlias() || TBAAInfo.isUnionMember())
-  return TBAAInfo;
+if (Base.getTBAAInfo().isMayAlias())
+  return TBAAAccessInfo::getMayAliasInfo();
 return getTBAAAccessInfo(AccessType);
   }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp?rev=319629&r1=319628&r2=319629&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp Sat Dec  2 19:10:13 2017
@@ -74,10 +74,6 @@ llvm::MDNode *CodeGenTBAA::getChar() {
   return Char;
 }
 
-llvm::MDNode *CodeGenTBAA::getUnionMemberType(uint64_t Size) {
-  return createScalarTypeNode("union member", getChar(), Size);
-}
-
 static bool TypeHasMayAlias(QualType QTy) {
   // Tagged types have declarations, and therefore may have attributes.
   if (const TagType *TTy = dyn_cast(QTy))
@@ -105,8 +101,9 @@ static bool isValidBaseType(QualType QTy
   return false;
 if (RD->hasFlexibleArrayMember())
   return false;
-// For now, we do not allow interface classes to be base access types.
-if (RD->isStruct() || RD->isClass() || RD->isUnion())
+// RD can be struct, union, class, interface or enum.
+// For now, 

[PATCH] D40566: Check if MemberExpr arguments are type-dependent.

2017-12-02 Thread Matt Davis via Phabricator via cfe-commits
mattd added a comment.

Thanks for the comments Eli!  I agree, it makes sense to flag certain 
expressions to be type dependent at the earliest time of compilation.  Clang 
already does this, as the Value/Type dependence is established upon Expr 
construction from MemberExpr construction.

As we have discussed,  in the case of MemberExpr, Clang bases dependence on the 
'this' pointer, which can be seen in the MemberExpr constructor. And from the 
attached test case, this is decision is not correct.  From what we noted, 
member access expressions can base their dependence on the type of the member.

However, after trying to propagate this change sooner rather than later (in the 
MemberExpr ctor), I realized that I might have been changing language 
semantics.  One thing, in particular, is how we handle address-of expressions.  
 Clang predicates them, internally, on type-dependence.  From that perspective, 
we will never try to bind a address-of expression within a template definition, 
if the address-of is for a member variable.  The bind will only occur during 
template instantiation.  Another case we have to be aware of are MemberExpr 
where the member is a CXXMethodExpr, which would be dependent given the 
implicit 'this' parameter; that's correct, but I don't want to break that 
either.


https://reviews.llvm.org/D40566



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


[PATCH] D39455: [CodeGen] Add initial support for union members in TBAA

2017-12-02 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added a comment.

Thank you for confirming and reverting!


Repository:
  rL LLVM

https://reviews.llvm.org/D39455



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