Small code problems in SemaTemplateDeduction.cpp and ASTContext.cpp

Few days ago Andrey Karpov analyzed Clang and LLVM code using statical analisys
tool for Visual Studio his company developed. He wrote a big article in russian
on http://habrahabr.ru/blogs/compilers/125626/ for advertising purposes.

I have wrote to llvmdev list about llvm-related bugs.
However few problems are Clang-related:

clang/lib/Sema/SemaTemplateDeduction.cpp:3239
if ((P->isPointerType() && A->isPointerType()) ||
     (P->isMemberPointerType() && P->isMemberPointerType()))

Note the identical sub-expressions 'P->isMemberPointerType()' to the left and
to the right of the '&&' operator. Probably the second one should be
A->isMemberPointerType().

Few days ago Andrey Karpov analyzed Clang and LLVM code using statical analisys
tool for Visual Studio his company developed. He wrote a big article in russian
on http://habrahabr.ru/blogs/compilers/125626/ for advertising purposes.

I have wrote to llvmdev list about llvm-related bugs.
However few problems are Clang-related:

clang/lib/Sema/SemaTemplateDeduction.cpp:3239
if ((P->isPointerType() && A->isPointerType()) ||
    (P->isMemberPointerType() && P->isMemberPointerType()))

Note the identical sub-expressions 'P->isMemberPointerType()' to the left and
to the right of the '&&' operator. Probably the second one should be
A->isMemberPointerType().

----

clang/lib/AST/ASTContext.cpp:3953
ParmOffset = PtrSize;

// Argument types.
ParmOffset = PtrSize;

Probably just some duplicated code.

Thanks, I've removed the redundant code in clang revision 136907.
I left the first fix for someone who has a better understanding of the template deduction code.

Regards,
  Chad

Few days ago Andrey Karpov analyzed Clang and LLVM code using statical analisys
tool for Visual Studio his company developed. He wrote a big article in russian
on http://habrahabr.ru/blogs/compilers/125626/ for advertising purposes.

I have wrote to llvmdev list about llvm-related bugs.
However few problems are Clang-related:

clang/lib/Sema/SemaTemplateDeduction.cpp:3239
if ((P->isPointerType() && A->isPointerType()) ||
(P->isMemberPointerType() && P->isMemberPointerType()))

Note the identical sub-expressions 'P->isMemberPointerType()' to the left and
to the right of the '&&' operator. Probably the second one should be
A->isMemberPointerType().

This warning has been fairly useful for chromium and webkit, too. It
would be great if clang would warn on some variant of this. I looked
at this for two hours or so a while ago and hope to get back to it
eventually ( http://llvm.org/bugs/show_bug.cgi?id=9952 ).

Nico

Good find, thanks!

  - Doug