Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

CXXOperatorNames flag overwritten #10830

Open Quuxplusone opened 12 years ago

Quuxplusone commented 12 years ago
Bugzilla Link PR10573
Status NEW
Importance P normal
Reported by Andy Arvanitis (andy.arvanitis@gmail.com)
Reported on 2011-08-02 17:40:41 -0700
Last modified on 2016-04-20 12:26:42 -0700
Version trunk
Hardware All All
CC anastasia.stulova@arm.com, ichesnokov@accesssoftek.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
This flag gets set for the OpenCL language (and possibly others in the future),
and then gets overwritten a few lines later. Code is in file
lib/Frontend/CompilerInvokation.cpp. Bug is specifically here (last line below):

------- snip ---------

  // OpenCL has some additional defaults.
  if (LangStd == LangStandard::lang_opencl) {
    Opts.OpenCL = 1;
    Opts.AltiVec = 1;
    Opts.CXXOperatorNames = 1;          <--------- set here
    Opts.LaxVectorConversions = 1;
    Opts.DefaultFPContract = 1;
  }

  if (LangStd == LangStandard::lang_cuda)
    Opts.CUDA = 1;

  // OpenCL and C++ both have bool, true, false keywords.
  Opts.Bool = Opts.OpenCL || Opts.CPlusPlus;

  Opts.GNUKeywords = Opts.GNUMode;
  Opts.CXXOperatorNames = Opts.CPlusPlus;    <------ overwritten here

----- snip -------

It should be something like:

  if (Opts.CPlusPlus)
    Opts.CXXOperatorNames = 1;

I actually submitted a patch for this back in April, but it didn't get picked
up.

Thanks
Quuxplusone commented 8 years ago
Looking at lib/Frontend/CompilerInvocation.cpp and the problem seems to remain.

-------------------------------------
  // OpenCL has some additional defaults.
  if (Opts.OpenCL) {
    Opts.AltiVec = 0;
    Opts.ZVector = 0;
    Opts.CXXOperatorNames = 1;
    Opts.LaxVectorConversions = 0;
    Opts.DefaultFPContract = 1;
    Opts.NativeHalfType = 1;
    Opts.NativeHalfArgsAndReturns = 1;
  }

  Opts.CUDA = IK == IK_CUDA || IK == IK_PreprocessedCuda ||
              LangStd == LangStandard::lang_cuda;

  // OpenCL and C++ both have bool, true, false keywords.
  Opts.Bool = Opts.OpenCL || Opts.CPlusPlus;

  // OpenCL has half keyword
  Opts.Half = Opts.OpenCL;

  // C++ has wchar_t keyword.
  Opts.WChar = Opts.CPlusPlus;

  Opts.GNUKeywords = Opts.GNUMode;
  Opts.CXXOperatorNames = Opts.CPlusPlus;
-------------------------------------

I think we should remove this line:

Opts.CXXOperatorNames = 1;

from OpenCL as it's overwritten unconditionally. It also comes from an old
commit r90198, so likely to be an obsolete code.